X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Finclude%2Flprocfs_status.h;h=bce41a8f61789bcb2ec448349fe5b903ac05b465;hb=c4ec46c0ca89b9c8ed5dec0763b6d7537363e65f;hp=44d1a2a3fed59ae1443267fa854c8f72a49eb741;hpb=98a2ab6915c16fd8745437bfed71889588880e12;p=fs%2Flustre-release.git diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 44d1a2a..bce41a8 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -24,6 +24,7 @@ #ifndef _LPROCFS_SNMP_H #define _LPROCFS_SNMP_H +#include #if defined(__linux__) #include #elif defined(__APPLE__) @@ -123,11 +124,11 @@ struct lprocfs_atomic { struct lprocfs_counter { struct lprocfs_atomic lc_cntl; /* may need to move to per set */ unsigned int lc_config; - __u64 lc_count; - __u64 lc_sum; - __u64 lc_min; - __u64 lc_max; - __u64 lc_sumsquare; + __s64 lc_count; + __s64 lc_sum; + __s64 lc_min; + __s64 lc_max; + __s64 lc_sumsquare; const char *lc_name; /* must be static */ const char *lc_units; /* must be static */ }; @@ -140,10 +141,21 @@ struct lprocfs_percpu { #define LPROCFS_GET_SMP_ID 0x0002 enum lprocfs_stats_flags { + LPROCFS_STATS_FLAG_PERCPU = 0x0000, /* per cpu counter */ LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu * area and need locking */ }; +enum lprocfs_fields_flags { + LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001, + LPROCFS_FIELDS_FLAGS_SUM = 0x0002, + LPROCFS_FIELDS_FLAGS_MIN = 0x0003, + LPROCFS_FIELDS_FLAGS_MAX = 0x0004, + LPROCFS_FIELDS_FLAGS_AVG = 0x0005, + LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006, + LPROCFS_FIELDS_FLAGS_COUNT = 0x0007, +}; + struct lprocfs_stats { unsigned int ls_num; /* # of counters */ unsigned int ls_percpu_size; @@ -153,7 +165,116 @@ struct lprocfs_stats { struct lprocfs_percpu *ls_percpu[0]; }; +static inline int opcode_offset(__u32 opc) { + if (opc < OST_LAST_OPC) { + /* OST opcode */ + return (opc - OST_FIRST_OPC); + } else if (opc < MDS_LAST_OPC) { + /* MDS opcode */ + return (opc - MDS_FIRST_OPC + + (OST_LAST_OPC - OST_FIRST_OPC)); + } else if (opc < LDLM_LAST_OPC) { + /* LDLM Opcode */ + return (opc - LDLM_FIRST_OPC + + (MDS_LAST_OPC - MDS_FIRST_OPC) + + (OST_LAST_OPC - OST_FIRST_OPC)); + } else if (opc < MGS_LAST_OPC) { + /* MGS Opcode */ + return (opc - MGS_FIRST_OPC + + (LDLM_LAST_OPC - LDLM_FIRST_OPC) + + (MDS_LAST_OPC - MDS_FIRST_OPC) + + (OST_LAST_OPC - OST_FIRST_OPC)); + } else if (opc < OBD_LAST_OPC) { + /* OBD Ping */ + return (opc - OBD_FIRST_OPC + + (MGS_LAST_OPC - MGS_FIRST_OPC) + + (LDLM_LAST_OPC - LDLM_FIRST_OPC) + + (MDS_LAST_OPC - MDS_FIRST_OPC) + + (OST_LAST_OPC - OST_FIRST_OPC)); + } else if (opc < LLOG_LAST_OPC) { + /* LLOG Opcode */ + return (opc - LLOG_FIRST_OPC + + (OBD_LAST_OPC - OBD_FIRST_OPC) + + (MGS_LAST_OPC - MGS_FIRST_OPC) + + (LDLM_LAST_OPC - LDLM_FIRST_OPC) + + (MDS_LAST_OPC - MDS_FIRST_OPC) + + (OST_LAST_OPC - OST_FIRST_OPC)); +} else if (opc < FLD_LAST_OPC) { + /* FLD opcode */ + return (opc - FLD_FIRST_OPC + + (LLOG_LAST_OPC - LLOG_FIRST_OPC) + + (OBD_LAST_OPC - OBD_FIRST_OPC) + + (MGS_LAST_OPC - MGS_FIRST_OPC) + + (LDLM_LAST_OPC - LDLM_FIRST_OPC) + + (MDS_LAST_OPC - MDS_FIRST_OPC) + + (OST_LAST_OPC - OST_FIRST_OPC)); + } else if (opc < SEQ_LAST_OPC) { + /* SEQ opcode */ + return (opc - SEQ_FIRST_OPC + + (FLD_LAST_OPC - FLD_FIRST_OPC) + + (LLOG_LAST_OPC - LLOG_FIRST_OPC) + + (OBD_LAST_OPC - OBD_FIRST_OPC) + + (MGS_LAST_OPC - MGS_FIRST_OPC) + + (LDLM_LAST_OPC - LDLM_FIRST_OPC) + + (MDS_LAST_OPC - MDS_FIRST_OPC) + + (OST_LAST_OPC - OST_FIRST_OPC)); + } else if (opc < SEC_LAST_OPC) { + /* SEC opcode */ + return (opc - SEC_FIRST_OPC + + (SEQ_LAST_OPC - SEQ_FIRST_OPC) + + (FLD_LAST_OPC - FLD_FIRST_OPC) + + (LLOG_LAST_OPC - LLOG_FIRST_OPC) + + (OBD_LAST_OPC - OBD_FIRST_OPC) + + (MGS_LAST_OPC - MGS_FIRST_OPC) + + (LDLM_LAST_OPC - LDLM_FIRST_OPC) + + (MDS_LAST_OPC - MDS_FIRST_OPC) + + (OST_LAST_OPC - OST_FIRST_OPC)); + } else { + /* Unknown Opcode */ + return -1; + } +} + +#define LUSTRE_MAX_OPCODES ((LDLM_LAST_OPC - LDLM_FIRST_OPC) + \ + (MDS_LAST_OPC - MDS_FIRST_OPC) + \ + (OST_LAST_OPC - OST_FIRST_OPC) + \ + (OBD_LAST_OPC - OBD_FIRST_OPC) + \ + (FLD_LAST_OPC - FLD_FIRST_OPC) + \ + (SEQ_LAST_OPC - SEQ_FIRST_OPC) + \ + (MGS_LAST_OPC - MGS_FIRST_OPC) + \ + (LLOG_LAST_OPC - LLOG_FIRST_OPC) + \ + (SEC_LAST_OPC - SEC_FIRST_OPC)) + +#define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \ + (EXTRA_LAST_OPC - EXTRA_FIRST_OPC)) + +enum { + PTLRPC_REQWAIT_CNTR = 0, + PTLRPC_REQQDEPTH_CNTR, + PTLRPC_REQACTIVE_CNTR, + PTLRPC_TIMEOUT, + PTLRPC_REQBUF_AVAIL_CNTR, + PTLRPC_LAST_CNTR +}; + +#define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR + +enum { + LDLM_GLIMPSE_ENQUEUE = 0, + LDLM_PLAIN_ENQUEUE, + LDLM_EXTENT_ENQUEUE, + LDLM_FLOCK_ENQUEUE, + LDLM_IBITS_ENQUEUE, + MDS_REINT_CREATE, + MDS_REINT_LINK, + MDS_REINT_OPEN, + MDS_REINT_SETATTR, + MDS_REINT_RENAME, + MDS_REINT_UNLINK, + EXTRA_LAST_OPC +}; +#define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE /* class_obd.c */ extern cfs_proc_dir_entry_t *proc_lustre_root; @@ -225,7 +346,11 @@ static inline void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, lprocfs_stats_unlock(stats); } -static inline void lprocfs_counter_incr(struct lprocfs_stats *stats, int idx) +#define lprocfs_counter_incr(stats, idx) \ + lprocfs_counter_add(stats, idx, 1) + +static inline void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx, + long amount) { struct lprocfs_counter *percpu_cntr; int smp_id; @@ -233,14 +358,35 @@ static inline void lprocfs_counter_incr(struct lprocfs_stats *stats, int idx) if (stats == NULL) return; + /* With per-client stats, statistics are allocated only for + * single CPU area, so the smp_id should be 0 always. */ smp_id = lprocfs_stats_lock(stats, LPROCFS_GET_SMP_ID); - percpu_cntr = &(stats->ls_percpu[smp_id]->lp_cntr[idx]); + percpu_cntr = &(stats->ls_percpu[smp_id]->lp_cntr[idx]); atomic_inc(&percpu_cntr->lc_cntl.la_entry); - percpu_cntr->lc_count++; + if (percpu_cntr->lc_config & LPROCFS_CNTR_AVGMINMAX) + percpu_cntr->lc_sum -= amount; atomic_inc(&percpu_cntr->lc_cntl.la_exit); lprocfs_stats_unlock(stats); } +#define lprocfs_counter_decr(stats, idx) \ + lprocfs_counter_sub(stats, idx, 1) + +extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc, + enum lprocfs_fields_flags field); +static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, + int idx, + enum lprocfs_fields_flags field) +{ + __u64 ret = 0; + int i; + + LASSERT(stats != NULL); + for (i = 0; i < num_possible_cpus(); i++) + ret += lprocfs_read_helper(&(stats->ls_percpu[i]->lp_cntr[idx]), + field); + return ret; +} extern struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags); @@ -260,19 +406,6 @@ extern int lprocfs_exp_cleanup(struct obd_export *exp); extern int lprocfs_register_stats(cfs_proc_dir_entry_t *root, const char *name, struct lprocfs_stats *stats); -#define LPROCFS_INIT_VARS(name, vclass, vinstance) \ -void lprocfs_##name##_init_vars(struct lprocfs_static_vars *x) \ -{ \ - x->module_vars = vclass; \ - x->obd_vars = vinstance; \ -} \ - -#define lprocfs_init_vars(NAME, VAR) \ -do { \ - extern void lprocfs_##NAME##_init_vars(struct lprocfs_static_vars *); \ - lprocfs_##NAME##_init_vars(VAR); \ -} while (0) - /* lprocfs_status.c */ extern int lprocfs_add_vars(cfs_proc_dir_entry_t *root, struct lprocfs_vars *var, @@ -434,19 +567,32 @@ struct file_operations name##_fops = { \ #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL) #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write) +/* lprocfs_status.c: read recovery max time bz13079 */ +int lprocfs_obd_rd_recovery_maxtime(char *page, char **start, off_t off, + int count, int *eof, void *data); + +/* lprocfs_status.c: write recovery max time bz13079 */ +int lprocfs_obd_wr_recovery_maxtime(struct file *file, const char *buffer, + unsigned long count, void *data); #else /* LPROCFS is not defined */ static inline void lprocfs_counter_add(struct lprocfs_stats *stats, int index, long amount) { return; } static inline void lprocfs_counter_incr(struct lprocfs_stats *stats, int index) { return; } +static inline void lprocfs_counter_sub(struct lprocfs_stats *stats, + int index, long amount) { return; } static inline void lprocfs_counter_init(struct lprocfs_stats *stats, int index, unsigned conf, const char *name, const char *units) { return; } +static inline __u64 lc_read_helper(struct lprocfs_counter *lc, + enum lprocfs_fields_flags field) +{ return 0; } + static inline struct lprocfs_stats* lprocfs_alloc_stats(unsigned int num, - int client_stat) + enum lprocfs_stats_flags flags) { return NULL; } static inline void lprocfs_clear_stats(struct lprocfs_stats *stats) { return; } @@ -474,8 +620,6 @@ static inline int lprocfs_exp_cleanup(struct obd_export *exp) static inline cfs_proc_dir_entry_t * lprocfs_register(const char *name, cfs_proc_dir_entry_t *parent, struct lprocfs_vars *list, void *data) { return NULL; } -#define LPROCFS_INIT_VARS(name, vclass, vinstance) -#define lprocfs_init_vars(...) do {} while (0) static inline int lprocfs_add_vars(cfs_proc_dir_entry_t *root, struct lprocfs_vars *var, void *data) { return 0; } @@ -551,6 +695,11 @@ static inline int lprocfs_counter_write(struct file *file, const char *buffer, unsigned long count, void *data) { return 0; } +static inline +__u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, + enum lprocfs_fields_flags field) +{ return (__u64)0; } + #define LPROCFS_ENTRY() #define LPROCFS_EXIT() #define LPROCFS_ENTRY_AND_CHECK(dp)