変更の始まり

Statistics Compression Information

目的

zEDC システムの圧縮の有効性およびパフォーマンスをモニターするために圧縮統計を表示します。

フォーマット

syscall_parmlist
   opcode                int                      256 STATOP_COMPRESSION       
   parms[0]              int                      Offset of output following STAT_API 
   parms[1]              int                      Offset to system name (optional) 
   parms[2]              int                      0       
   parms[3]              int                      0       
   parms[4]              int                      0      
   parms[5]              int                      0
   parms[6]              int                      0  

STAT_API         
   sa_eye                char[4]                  "STAP"
   sa_len                int                      Length of buffer that follows STAT_API
   sa_ver                int                      1 
   sa_flags              char[1]                  0x80 for reset; 0x00 otherwise
   sa_fill               char[3]                  Reserved
   sa_support_ver        int                      Version of data returned  
   sa_reserve            int[3]                   Reserved
   posix_time_high       unsigned int             High order 32 bits since epoch
   posix_time_low        unsigned int             Low order 32 bits since epoch
   posix_useconds        unsigned int             Microseconds  
   pad1                  int                      Reserved

API_COMPRESSION_STATS
   comp_eye              char[4]                  "COMP"
   comp_size             short                    Size of the output structure
   comp_version          char                     1
   future1               char                     For future use
   comp_calls            unsigned long long int   Number of compression calls made    
   comp_kbytesin         unsigned long long int   Number of kilobytes sent to the zEDC 
						                                            compression card by zFS for compression calls 
   comp_kbytesout        unsigned long long int   Number of kilobytes returned by the zEDC 
						                                            compression card from compression calls 
   comp_calltime         unsigned long long int   Average number of microseconds per compression call 
   decomp_calls          unsigned long long int   Number of decompression calls made    
   decomp_kbytesin       unsigned long long int   Number of kilobytes sent to the zEDC cards for 
						                                            decompression calls 
   decomp_kbytesout      unsigned long long int   Number of kilobytes returned from zEDC cards 
						                                            from decompression calls 
   decomp_calltime       unsigned long long int   Average number of microseconds per decompression call   
   future2               int[16]                  For future use

Return_value         0 if request is successful, -1 if it is not successful

Return_code
	EINTR         zFS is shutting down
	EINVAL        Invalid parameter list
	EMVSERR       Internal error occurred
	E2BIG         Information too big for buffer supplied

Reason_code
	0xEFnnxxxx See z/OS Distributed File Service Messages and Codes

Statistics Compression Information の使用上の注意

  1. 予約フィールドおよび未定義のフラグは、2 進ゼロに設定されていなければなりません。

必要特権

なし。

関連サービス

  • Encrypt (Decrypt、Compress、Decompress) Aggregate

制約事項

なし。

#pragma linkage(BPX1PCT, OS)
#pragma LANGLVL(EXTENDED)

extern void BPX1PCT(char *, int, int, char *, int *, int *, int *);

#include <stdio.h>
#include <errno.h>

#define ZFSCALL_STATS 0x40000007     
#define STATOP_COMPRESSION   256
#define BUFFER_SIZE   1024 * 64

#define CONVERT_RATIO_TO_INTS(RATIO, INTEGER, DECIMAL)                   \
  {                                                                      \
    INTEGER = (int)RATIO;                                                \
    DECIMAL = (int)((RATIO - (double)INTEGER) * (double)1000.0);         \
  }
#define zCOUNT_FIELD(COUNT, COUNT_STRING)                                \
        zCOUNT_FIELD_MAX(COUNT, COUNT_STRING, 10)

/* This macro takes a unsigned long long int, a pointer to an output        */
/* string pointer and the max len of the output string.                     */
/* This macro assumes the format field for the string is %(MAXLEN)s         */
#define zCOUNT_FIELD_MAX(COUNT, COUNT_STRING, MAXLEN)                       \
{                                                                           \
  unsigned long long int tcount = COUNT;                                    \
  char suffixp[3] = {0, 0, 0};                                              \
  unsigned long long int max_val[11] = {0LL, 9LL, 99LL, 999LL, 9999LL,      \
     99999LL, 999999LL, 9999999LL, 99999999LL, 999999999LL, 9999999999LL};  \
  unsigned long long int MAXVAL = max_val[MAXLEN-1];           \
  unsigned long long int maxval = MAXVAL;                      \
  unsigned long long int maxval2 = MAXVAL/10;                  \
  unsigned long long int maxval3 = maxval2/10;                 \
  if (tcount > max_val[MAXLEN])                                \
  {                                                            \
    if (tcount > maxval)                                       \
    {                                                          \
      tcount /= 1000ll;                                        \
      suffixp[0] = 't';                                        \
      if (tcount > maxval2)                                    \
      {                                                        \
        tcount /= 1000ll;                                      \
        suffixp[0] = 'm';                                      \
        if (tcount > maxval2)                                  \
        {                                                      \
          tcount /= 1000ll;                                    \
          suffixp[0] = 'b';                                    \
          if (tcount > maxval3)                                \
          {                                                    \
            tcount /= 1000ll;                                  \
            suffixp[0] = 't';                                  \
            suffixp[1] = 'r';                                  \
          }                                                    \
        }                                                      \
      }                                                        \
    }                                                          \
  }                                                            \
  sprintf(COUNT_STRING, "%llu%s", tcount, suffixp);            \
}

typedef struct syscall_parmlist_t {
    int opcode;                  /* Operation code to perform     */
    int parms[7];                /* Specific to type of operation */

} syscall_parmlist;

typedef  struct  reset_time {
    unsigned int   posix_time_high;   
    unsigned int   posix_time_low;    
    unsigned int   posix_usecs;       
    int     pad1;             
} RESET_TIME;

typedef struct stat_api_t {
#define     SA_EYE "STAP"
    char    sa_eye[4];           /* 4 byte identifier must be             */
    int     sa_len;              /* length of the buffer to put data into */
                                 /* this buffer area follows this struct  */
    int     sa_ver;              /* the version number currently always 1 */
#define     SA_VER_INIT 0x01
    char    sa_flags;            /* command field  must be x00 or x80,    */
                                 /* x80 means reset statistics            */
#define     SA_RESET 0x80
    char    sa_fill[3];          /* spare bytes                           */
    int     sa_reserve[4];       /* Reserved                              */
    struct  reset_time reset_time_info;
} STAT_API;

typedef struct API_COMPRESSION_STATS_t  {
  char     comp_eye[4];          /* Eye catcher */
#define COMP_EYE "COMP"
  short    comp_size;            /* Size of output structure       */
  char     comp_version;         /* Version of statistics returned */
  char     comp_future;          /* Future use */
  unsigned long long int comp_calls;         
  unsigned long long int comp_kbytesin;     
  unsigned long long int comp_kbytesout;  
  unsigned long long int comp_calltime;    
  unsigned long long int decomp_calls;      
  unsigned long long int decomp_kbytesin;  
  unsigned long long int decomp_kbytesout;  
  unsigned long long int decomp_calltime;    
  int       comp_future2[16];             
} API_COMPRESSION_STATS;


int main(int argc, char** argv)
{
    int  buff_fill_len = 0;
    int  bpxrv, bpxrc, bpxrs;
    char sysname[9];
    STAT_API              local_req;
    STAT_API              *st_req     = NULL;
    syscall_parmlist      *parmp      = NULL;
    API_COMPRESSION_STATS *statsp     = NULL;
    char                  *buffp      = NULL;
    double temp_ratio;
    int whole, decimal;
    char string1[16];
    char string2[16];
    char *p;
    unsigned long long int  *temp; 

    /* Initialize the local_req to 0s */
    st_req = &local_req;
    memset( st_req, 0x00, sizeof(STAT_API) );

    strcpy( local_req.sa_eye, SA_EYE, sizeof(local_req.sa_eye) );
    local_req.sa_len = sizeof(API_COMPRESSION_STATS);
    local_req.sa_ver = SA_VER_INIT;

    /* Allocate Buffer */
    buffp = (char*) malloc(BUFFER_SIZE);
    if( buffp == NULL )
    {
        printf("Malloc Error\n");
        return ENOMEM;
    }
    memset( buffp, 0x00, sizeof(syscall_parmlist) + sizeof(STAT_API));

    /* Set the run parms */
    parmp = (syscall_parmlist*) &buffp[0];
    parmp->opcode   = STATOP_COMPRESSION;
    parmp->parms[0] = buff_fill_len = sizeof(syscall_parmlist);
    parmp->parms[1] = sizeof(syscall_parmlist) + sizeof(STAT_API);
    parmp->parms[2] = 0;
    parmp->parms[3] = 0;
    parmp->parms[4] = 0;
    parmp->parms[5] = 0;
    parmp->parms[6] = 0;
    
    st_req = (STAT_API*) &buffp[buff_fill_len];

    memcpy( st_req, &local_req, sizeof(STAT_API) );
    buff_fill_len += sizeof(STAT_API);
           
    BPX1PCT("ZFS     ",
            ZFSCALL_STATS,              /* Aggregate operation */
            BUFFER_SIZE,                /* Length of Argument */
            (char*) buffp,              /* Pointer to Argument */
            &bpxrv,                     /* Pointer to Return_value */
            &bpxrc,                     /* Pointer to Return_code */
            &bpxrs);                    /* Pointer to Reason_code */
    
    if( bpxrv )
    {
        /* Bad Return code */
        printf("Error requesting info for compression stats\n");
        printf("Return Value: %d Return Code: %d Reason Code: %x\n",
            bpxrv, bpxrc, bpxrs);
        return bpxrc;
    }
    else
    {
        /* Success.  Print the information in a table */
        statsp = (API_COMPRESSION_STATS *) &buffp[buff_fill_len];
        
        zCOUNT_FIELD(statsp->comp_calls, string1);
        temp_ratio = ((double)statsp->comp_calltime)/1000;
        temp = (unsigned long long int *)&statsp->comp_calltime;        
        CONVERT_RATIO_TO_INTS(temp_ratio,whole, decimal);
        printf("%-20s %10s  %-20s %10u.%3.3u \n",
                  "Compression calls:", string1,
                  "Avg. call time: ", whole, decimal);

        zCOUNT_FIELD(statsp->comp_kbytesin, string1);
        zCOUNT_FIELD(statsp->comp_kbytesout, string2);
        printf("  %-18s %10s    %-18s %10s \n",
                  "KB input", string1,
                  "KB output", string2);

        zCOUNT_FIELD(statsp->decomp_calls, string1);
        temp_ratio = ((double)statsp->decomp_calltime)/1000;
        temp = (unsigned long long int *)&statsp->decomp_calltime;        
        CONVERT_RATIO_TO_INTS(temp_ratio,whole, decimal);
        printf("%-20s %10s  %-20s %10u.%3.3u \n",
                  "Decompression calls:", string1,
                  "Avg. call time: ", whole, decimal);

        zCOUNT_FIELD(statsp->decomp_kbytesin, string1);
        zCOUNT_FIELD(statsp->decomp_kbytesout, string2);
        printf("  %-18s %10s    %-18s %10s \n",
               "KB input", string1,
               "KB output", string2);

        printf("\n");
        return 0;
    }
}
変更の終わり