Whamcloud - gitweb
LU-207 adding stats for some operations in MDT
authorhongchao.zhang <hongchao.zhang@whamcloud.com>
Fri, 29 Jul 2011 03:33:13 +0000 (11:33 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 29 Jul 2011 22:46:57 +0000 (18:46 -0400)
Adding stats for getattr, setattr, statfs and sync in MDT

Change-Id: I4790bb2eb6bc756a24942224506c7306429243bc
Signed-off-by: Hongchao Zhang <hongchao.zhang@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/427
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lproc.c
lustre/mdt/mdt_reint.c
lustre/tests/sanity.sh

index b91322e..3ff76c8 100644 (file)
@@ -344,6 +344,7 @@ static int mdt_getstatus(struct mdt_thread_info *info)
 
 static int mdt_statfs(struct mdt_thread_info *info)
 {
+        struct ptlrpc_request *req = mdt_info_req(info);
         struct md_device      *next  = info->mti_mdt->mdt_child;
         struct ptlrpc_service *svc;
         struct obd_statfs     *osfs;
@@ -370,6 +371,10 @@ static int mdt_statfs(struct mdt_thread_info *info)
                                               &info->mti_u.ksfs);
                 statfs_pack(osfs, &info->mti_u.ksfs);
         }
+
+        if (rc == 0)
+                mdt_counter_incr(req->rq_export, LPROC_MDT_STATFS);
+
         RETURN(rc);
 }
 
@@ -670,6 +675,7 @@ static int mdt_renew_capa(struct mdt_thread_info *info)
 
 static int mdt_getattr(struct mdt_thread_info *info)
 {
+        struct ptlrpc_request   *req = mdt_info_req(info);
         struct mdt_object       *obj = info->mti_object;
         struct req_capsule      *pill = info->mti_pill;
         struct mdt_body         *reqbody;
@@ -731,6 +737,9 @@ static int mdt_getattr(struct mdt_thread_info *info)
                 mdt_exit_ucred(info);
         EXIT;
 out_shrink:
+        if (rc == 0)
+                mdt_counter_incr(req->rq_export, LPROC_MDT_GETATTR);
+
         mdt_shrink_reply(info);
         return rc;
 }
@@ -1641,6 +1650,7 @@ static int mdt_object_sync(struct mdt_thread_info *info)
 
 static int mdt_sync(struct mdt_thread_info *info)
 {
+        struct ptlrpc_request *req = mdt_info_req(info);
         struct req_capsule *pill = info->mti_pill;
         struct mdt_body *body;
         int rc;
@@ -1688,6 +1698,9 @@ static int mdt_sync(struct mdt_thread_info *info)
                 } else
                         rc = err_serious(rc);
         }
+        if (rc == 0)
+                mdt_counter_incr(req->rq_export, LPROC_MDT_SYNC);
+
         RETURN(rc);
 }
 
index 1df6c83..615f402 100644 (file)
@@ -818,8 +818,12 @@ enum {
         LPROC_MDT_MKDIR,
         LPROC_MDT_RMDIR,
         LPROC_MDT_RENAME,
+        LPROC_MDT_GETATTR,
+        LPROC_MDT_SETATTR,
         LPROC_MDT_GETXATTR,
         LPROC_MDT_SETXATTR,
+        LPROC_MDT_STATFS,
+        LPROC_MDT_SYNC,
         LPROC_MDT_LAST,
 };
 void mdt_counter_incr(struct obd_export *exp, int opcode);
index 8fa813d..47f75cd 100644 (file)
@@ -839,6 +839,10 @@ void mdt_stats_counter_init(struct lprocfs_stats *stats)
         lprocfs_counter_init(stats, LPROC_MDT_MKDIR, 0, "mkdir", "reqs");
         lprocfs_counter_init(stats, LPROC_MDT_RMDIR, 0, "rmdir", "reqs");
         lprocfs_counter_init(stats, LPROC_MDT_RENAME, 0, "rename", "reqs");
+        lprocfs_counter_init(stats, LPROC_MDT_GETATTR, 0, "getattr", "reqs");
+        lprocfs_counter_init(stats, LPROC_MDT_SETATTR, 0, "setattr", "reqs");
         lprocfs_counter_init(stats, LPROC_MDT_GETXATTR, 0, "getxattr", "reqs");
         lprocfs_counter_init(stats, LPROC_MDT_SETXATTR, 0, "setxattr", "reqs");
+        lprocfs_counter_init(stats, LPROC_MDT_STATFS, 0, "statfs", "reqs");
+        lprocfs_counter_init(stats, LPROC_MDT_SYNC, 0, "sync", "reqs");
 }
index 343fcc9..c843512 100644 (file)
@@ -598,6 +598,9 @@ static int mdt_reint_setattr(struct mdt_thread_info *info,
 out_put:
         mdt_object_put(info->mti_env, mo);
 out:
+        if (rc == 0)
+                mdt_counter_incr(req->rq_export, LPROC_MDT_SETATTR);
+
         mdt_shrink_reply(info);
         return rc;
 }
index b1e0583..fa33841 100644 (file)
@@ -6725,6 +6725,105 @@ test_132() { #1028, SOM
 }
 run_test 132 "som avoids glimpse rpc"
 
+check_stats() {
+       local res
+       local count
+       case $1 in
+       $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
+                ;;
+       ost) res=`do_facet ost $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
+                ;;
+       *) error "Wrong argument $1" ;;
+       esac
+       echo $res
+       count=`echo $res | awk '{print $2}'`
+       [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
+       # if the argument $3 is zero, it means any stat increment is ok.
+       if [ $3 -gt 0 ] ; then
+               [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
+       fi
+}
+
+test_133a() {
+       local testdir=$DIR/${tdir}/stats_testdir
+       mkdir -p $DIR/${tdir}
+
+       # clear stats.
+       do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
+       do_facet ost $LCTL set_param obdfilter.*.stats=clear
+
+       # verify mdt stats first.
+       mkdir ${testdir} || error "mkdir failed"
+       check_stats $SINGLEMDS "mkdir" 1
+       touch ${testdir}/${tfile} || "touch failed"
+       check_stats $SINGLEMDS "open" 1
+       check_stats $SINGLEMDS "close" 1
+       mknod ${testdir}/${tfile}-pipe p || "mknod failed"
+       check_stats $SINGLEMDS "mknod" 1
+       rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
+       check_stats $SINGLEMDS "unlink" 1
+       rm -f ${testdir}/${tfile} || error "file remove failed"
+       check_stats $SINGLEMDS "unlink" 2
+
+       # remove working dir and check mdt stats again.
+       rmdir ${testdir} || error "rmdir failed"
+       check_stats $SINGLEMDS "rmdir" 1
+
+       rm -rf $DIR/${tdir}
+}
+run_test 133a "Verifying MDT stats ========================================"
+
+test_133b() {
+       local testdir=$DIR/${tdir}/stats_testdir
+       mkdir -p ${testdir} || error "mkdir failed"
+       touch ${testdir}/${tfile} || "touch failed"
+       cancel_lru_locks mdc
+
+       # clear stats.
+       do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
+       do_facet ost $LCTL set_param obdfilter.*.stats=clear
+
+       # extra mdt stats verification.
+       chmod 444 ${testdir}/${tfile} || error "chmod failed"
+       check_stats $SINGLEMDS "setattr" 1
+       $LFS df || error "lfs failed"
+       check_stats $SINGLEMDS "statfs" 1
+
+       rm -rf $DIR/${tdir}
+}
+run_test 133b "Verifying extra MDT stats =================================="
+
+test_133c() {
+       local testdir=$DIR/${tdir}/stats_testdir
+       mkdir -p ${testdir} || error "mkdir failed"
+
+       # verify obdfilter stats.
+       $LFS setstripe -c 1 -o 0 ${testdir}/${tfile}
+       sync
+       cancel_lru_locks osc
+
+       # clear stats.
+       do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
+       do_facet ost $LCTL set_param obdfilter.*.stats=clear
+
+       dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=1024k count=1 || error "dd failed"
+       sync
+       cancel_lru_locks osc
+       check_stats ost "write" 1
+
+       dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
+       check_stats ost "read" 1
+
+       > ${testdir}/${tfile} || error "truncate failed"
+       check_stats ost "punch" 1
+
+       rm -f ${testdir}/${tfile} || error "file remove failed"
+       check_stats ost "destroy" 1
+
+       rm -rf $DIR/${tdir}
+}
+run_test 133c "Verifying OST stats ========================================"
+
 test_140() { #bug-17379
         mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
         cd $DIR/$tdir || error "Changing to $DIR/$tdir"