Whamcloud - gitweb
b=14194
authorkomaln <komaln>
Thu, 31 Jan 2008 11:39:31 +0000 (11:39 +0000)
committerkomaln <komaln>
Thu, 31 Jan 2008 11:39:31 +0000 (11:39 +0000)
r=Adilger, Wandgi
To detail ldlm_enqueue and mds_reint stats.

lustre/include/lprocfs_status.h
lustre/ldlm/ldlm_lockd.c
lustre/mds/handler.c
lustre/ptlrpc/lproc_ptlrpc.c
lustre/ptlrpc/ptlrpc_internal.h
lustre/ptlrpc/service.c

index 4516175..bce41a8 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef _LPROCFS_SNMP_H
 #define _LPROCFS_SNMP_H
 
+#include <lustre/lustre_idl.h>
 #if defined(__linux__)
 #include <linux/lprocfs_status.h>
 #elif defined(__APPLE__)
@@ -164,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;
 
index 9e2e644..23cb151 100644 (file)
@@ -832,6 +832,40 @@ extern unsigned long long lu_time_stamp_get(void);
 #define lu_time_stamp_get() time(NULL)
 #endif
 
+static void ldlm_svc_get_eopc(struct ldlm_request *dlm_req,
+                       struct lprocfs_stats *srv_stats)
+{
+        int lock_type = 0, op = 0;
+
+        lock_type = dlm_req->lock_desc.l_resource.lr_type;
+
+        switch (lock_type) {
+        case LDLM_PLAIN:
+                op = PTLRPC_LAST_CNTR + LDLM_PLAIN_ENQUEUE;
+                break;
+        case LDLM_EXTENT:
+                if (dlm_req->lock_flags & LDLM_FL_HAS_INTENT)
+                        op = PTLRPC_LAST_CNTR + LDLM_GLIMPSE_ENQUEUE;
+                else
+                        op = PTLRPC_LAST_CNTR + LDLM_EXTENT_ENQUEUE;
+                break;
+        case LDLM_FLOCK:
+                op = PTLRPC_LAST_CNTR + LDLM_FLOCK_ENQUEUE;
+                break;
+        case LDLM_IBITS:
+                op = PTLRPC_LAST_CNTR + LDLM_IBITS_ENQUEUE;
+                break;
+        default:
+                op = 0;
+                break;
+        }
+
+        if (op)
+                lprocfs_counter_incr(srv_stats, op);
+
+        return ;
+}
+
 /*
  * Main server-side entry point into LDLM. This is called by ptlrpc service
  * threads to carry out client lock enqueueing requests.
@@ -858,6 +892,10 @@ int ldlm_handle_enqueue0(struct ldlm_namespace *ns,
 
         LASSERT(req->rq_export);
 
+        if (req->rq_rqbd->rqbd_service->srv_stats)
+                ldlm_svc_get_eopc(dlm_req,
+                                  req->rq_rqbd->rqbd_service->srv_stats);
+
         if (req->rq_export->exp_ldlm_stats)
                 lprocfs_counter_incr(req->rq_export->exp_ldlm_stats,
                                      LDLM_ENQUEUE - LDLM_FIRST_OPC);
@@ -1106,7 +1144,6 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req,
                 .lcs_glimpse    = glimpse_callback
         };
 
-
         dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF,
                                      sizeof *dlm_req, lustre_swab_ldlm_request);
         if (dlm_req != NULL) {
index d5f60de..44ef204 100644 (file)
@@ -1633,6 +1633,7 @@ int mds_handle(struct ptlrpc_request *req)
                 __u32 *opcp = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF,
                                              sizeof(*opcp));
                 __u32  opc;
+                int op = 0;
                 int size[4] = { sizeof(struct ptlrpc_body),
                                 sizeof(struct mds_body),
                                 mds->mds_max_mdsize,
@@ -1653,6 +1654,33 @@ int mds_handle(struct ptlrpc_request *req)
                           (opc < sizeof(reint_names) / sizeof(reint_names[0]) ||
                            reint_names[opc] == NULL) ? reint_names[opc] :
                                                        "unknown opcode");
+                switch (opc) {
+                case REINT_CREATE:
+                        op = PTLRPC_LAST_CNTR + MDS_REINT_CREATE;
+                        break;
+                case REINT_LINK:
+                        op = PTLRPC_LAST_CNTR + MDS_REINT_LINK;
+                        break;
+                case REINT_OPEN:
+                        op = PTLRPC_LAST_CNTR + MDS_REINT_OPEN;
+                        break;
+                case REINT_SETATTR:
+                        op = PTLRPC_LAST_CNTR + MDS_REINT_SETATTR;
+                        break;
+                case REINT_RENAME:
+                        op = PTLRPC_LAST_CNTR + MDS_REINT_RENAME;
+                        break;
+                case REINT_UNLINK:
+                        op = PTLRPC_LAST_CNTR + MDS_REINT_UNLINK;
+                        break;
+                default:
+                        op = 0;
+                        break;
+                }
+
+                if (op && req->rq_rqbd->rqbd_service->srv_stats)
+                        lprocfs_counter_incr(
+                                req->rq_rqbd->rqbd_service->srv_stats, op);
 
                 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_NET))
                         RETURN(0);
index 4b453b0..ede3bc8 100644 (file)
@@ -112,7 +112,24 @@ struct ll_rpc_opcode {
         { SEC_CTX_FINI,     "sec_ctx_fini" }
 };
 
-const char* ll_opcode2str(__u32 opcode)
+struct ll_eopcode {
+     __u32       opcode;
+     const char *opname;
+} ll_eopcode_table[EXTRA_LAST_OPC] = {
+        { LDLM_GLIMPSE_ENQUEUE, "ldlm_glimpse_enqueue" },
+        { LDLM_PLAIN_ENQUEUE,   "ldlm_plain_enqueue" },
+        { LDLM_EXTENT_ENQUEUE,  "ldlm_extent_enqueue" },
+        { LDLM_FLOCK_ENQUEUE,   "ldlm_flock_enqueue" },
+        { LDLM_IBITS_ENQUEUE,   "ldlm_ibits_enqueue" },
+        { MDS_REINT_CREATE,     "mds_reint_create" },
+        { MDS_REINT_LINK,       "mds_reint_link" },
+        { MDS_REINT_OPEN,       "mds_reint_open" },
+        { MDS_REINT_SETATTR,    "mds_reint_setattr" },
+        { MDS_REINT_RENAME,     "mds_reint_rename" },
+        { MDS_REINT_UNLINK,     "mds_reint_unlink" }
+};
+
+const char *ll_opcode2str(__u32 opcode)
 {
         /* When one of the assertions below fail, chances are that:
          *     1) A new opcode was added in lustre_idl.h, but was
@@ -127,6 +144,11 @@ const char* ll_opcode2str(__u32 opcode)
         return ll_rpc_opcode_table[offset].opname;
 }
 
+const char* ll_eopcode2str(__u32 opcode)
+{
+        LASSERT(ll_eopcode_table[opcode].opcode == opcode);
+        return ll_eopcode_table[opcode].opname;
+}
 #ifdef LPROCFS
 void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
                              char *name, struct proc_dir_entry **procroot_ret,
@@ -141,7 +163,7 @@ void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
         LASSERT(*procroot_ret == NULL);
         LASSERT(*stats_ret == NULL);
 
-        svc_stats = lprocfs_alloc_stats(PTLRPC_LAST_CNTR + LUSTRE_MAX_OPCODES, 0);
+        svc_stats = lprocfs_alloc_stats(EXTRA_MAX_OPCODES + LUSTRE_MAX_OPCODES, 0);
         if (svc_stats == NULL)
                 return;
 
@@ -163,11 +185,16 @@ void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
                              svc_counter_config, "req_active", "reqs");
         lprocfs_counter_init(svc_stats, PTLRPC_REQBUF_AVAIL_CNTR,
                              svc_counter_config, "reqbuf_avail", "bufs");
+        for (i = 0; i < EXTRA_LAST_OPC; i++) {
+                lprocfs_counter_init(svc_stats, PTLRPC_LAST_CNTR + i,
+                                     svc_counter_config,
+                                     ll_eopcode2str(i), "reqs");
+        }
         for (i = 0; i < LUSTRE_MAX_OPCODES; i++) {
                 __u32 opcode = ll_rpc_opcode_table[i].opcode;
-                lprocfs_counter_init(svc_stats, PTLRPC_LAST_CNTR + i,
-                                     svc_counter_config, ll_opcode2str(opcode),
-                                     "usec");
+                lprocfs_counter_init(svc_stats,
+                                     EXTRA_MAX_OPCODES + i, svc_counter_config,
+                                     ll_opcode2str(opcode), "usec");
         }
 
         rc = lprocfs_register_stats(svc_procroot, name, svc_stats);
@@ -444,15 +471,17 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd);
 void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req)
 {
         struct lprocfs_stats *svc_stats;
-        int opc = opcode_offset(lustre_msg_get_opc(req->rq_reqmsg));
+        __u32 op = lustre_msg_get_opc(req->rq_reqmsg);
+        int opc = opcode_offset(op);
 
         svc_stats = req->rq_import->imp_obd->obd_svc_stats;
         if (svc_stats == NULL || opc <= 0)
                 return;
         LASSERT(opc < LUSTRE_MAX_OPCODES);
         /* These two use the ptlrpc_lprocfs_brw below */
-        if (!(opc == OST_WRITE || opc == OST_READ))
-                lprocfs_counter_add(svc_stats, opc + PTLRPC_LAST_CNTR, 0);
+        if (!(opc == OST_WRITE || opc == OST_READ || op == LDLM_ENQUEUE
+              || op == MDS_REINT))
+                lprocfs_counter_add(svc_stats, opc + EXTRA_MAX_OPCODES, 0);
 }
 
 void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int opc, int bytes)
@@ -461,7 +490,7 @@ void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int opc, int bytes)
         svc_stats = req->rq_import->imp_obd->obd_svc_stats;
         if (!svc_stats) 
                 return;
-        lprocfs_counter_add(svc_stats, opc + PTLRPC_LAST_CNTR, bytes);
+        lprocfs_counter_add(svc_stats, opc + EXTRA_MAX_OPCODES, bytes);
 }
 EXPORT_SYMBOL(ptlrpc_lprocfs_brw);
 
index 4d80f48..1cce741 100644 (file)
@@ -47,7 +47,6 @@ void ptlrpc_initiate_recovery(struct obd_import *imp);
 int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset);
 int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset);
 
-
 #ifdef LPROCFS
 void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry,
                                      struct ptlrpc_service *svc);
@@ -66,93 +65,6 @@ void ptlrpc_lprocfs_do_request_stat (struct ptlrpc_request *req,
 int llog_init_commit_master(void);
 int llog_cleanup_commit_master(int force);
 
-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))
-enum {
-        PTLRPC_REQWAIT_CNTR = 0,
-        PTLRPC_REQQDEPTH_CNTR,
-        PTLRPC_REQACTIVE_CNTR,
-        PTLRPC_REQBUF_AVAIL_CNTR,
-        PTLRPC_LAST_CNTR
-};
-
 int ptlrpc_expire_one_request(struct ptlrpc_request *req);
 
 /* pers.c */
index 1e6a812..d4091c9 100644 (file)
@@ -758,11 +758,12 @@ put_conn:
                        reply ? lustre_msg_get_status(request->rq_repmsg) : -999);
 
         if (likely(svc->srv_stats != NULL && request->rq_reqmsg != NULL)) {
-                int opc = opcode_offset(lustre_msg_get_opc(request->rq_reqmsg));
-                if (opc > 0) {
+                __u32 op = lustre_msg_get_opc(request->rq_reqmsg);
+                int opc = opcode_offset(op);
+                if (opc > 0 && !(op == LDLM_ENQUEUE || op == MDS_REINT)) {
                         LASSERT(opc < LUSTRE_MAX_OPCODES);
                         lprocfs_counter_add(svc->srv_stats,
-                                            opc + PTLRPC_LAST_CNTR,
+                                            opc + EXTRA_MAX_OPCODES,
                                             timediff);
                 }
         }