Whamcloud - gitweb
LU-231 sanity test_170: FAIL: expected 248 bad lines, but got 249
[fs/lustre-release.git] / lustre / mdt / mdt_reint.c
index 3ffd2e6..343fcc9 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -557,13 +557,13 @@ static int mdt_reint_setattr(struct mdt_thread_info *info,
 
                 /* Close the found mfd, update attributes. */
                 ma->ma_lmm_size = info->mti_mdt->mdt_max_mdsize;
-                OBD_ALLOC(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
+                OBD_ALLOC_LARGE(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
                 if (ma->ma_lmm == NULL)
                         GOTO(out_put, rc = -ENOMEM);
 
                 mdt_mfd_close(info, mfd);
 
-                OBD_FREE(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
+                OBD_FREE_LARGE(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
         } else {
                 rc = mdt_attr_set(info, mo, ma, rr->rr_flags);
                 if (rc)
@@ -605,7 +605,8 @@ out:
 static int mdt_reint_create(struct mdt_thread_info *info,
                             struct mdt_lock_handle *lhc)
 {
-        int rc;
+        struct ptlrpc_request   *req = mdt_info_req(info);
+        int                     rc;
         ENTRY;
 
         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE))
@@ -617,10 +618,15 @@ static int mdt_reint_create(struct mdt_thread_info *info,
         switch (info->mti_attr.ma_attr.la_mode & S_IFMT) {
         case S_IFDIR:{
                 /* Cross-ref case. */
+                /* TODO: we can add LPROC_MDT_CROSS for cross-ref stats */
                 if (info->mti_cross_ref) {
                         rc = mdt_md_mkobj(info);
-                        break;
+                } else {
+                        LASSERT(info->mti_rr.rr_namelen > 0);
+                        mdt_counter_incr(req->rq_export, LPROC_MDT_MKDIR);
+                        rc = mdt_md_create(info);
                 }
+                break;
         }
         case S_IFREG:
         case S_IFLNK:
@@ -630,6 +636,7 @@ static int mdt_reint_create(struct mdt_thread_info *info,
         case S_IFSOCK:{
                 /* Special file should stay on the same node as parent. */
                 LASSERT(info->mti_rr.rr_namelen > 0);
+                mdt_counter_incr(req->rq_export, LPROC_MDT_MKNOD);
                 rc = mdt_md_create(info);
                 break;
         }
@@ -641,7 +648,7 @@ static int mdt_reint_create(struct mdt_thread_info *info,
 
 /*
  * VBR: save parent version in reply and child version getting by its name.
- * Version of child is getting and checking during its lookup. If 
+ * Version of child is getting and checking during its lookup. If
  */
 static int mdt_reint_unlink(struct mdt_thread_info *info,
                             struct mdt_lock_handle *lhc)
@@ -754,6 +761,25 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
         if (rc == 0)
                 mdt_handle_last_unlink(info, mc, ma);
 
+        if (ma->ma_valid & MA_INODE) {
+                switch (ma->ma_attr.la_mode & S_IFMT) {
+                case S_IFDIR:
+                        mdt_counter_incr(req->rq_export, LPROC_MDT_RMDIR);
+                        break;
+                case S_IFREG:
+                case S_IFLNK:
+                case S_IFCHR:
+                case S_IFBLK:
+                case S_IFIFO:
+                case S_IFSOCK:
+                        mdt_counter_incr(req->rq_export, LPROC_MDT_UNLINK);
+                        break;
+                default:
+                        LASSERTF(0, "bad file type %o unlinking\n",
+                                 ma->ma_attr.la_mode);
+                }
+        }
+
         EXIT;
 
         mdt_object_unlock_put(info, mc, child_lh, rc);
@@ -861,6 +887,9 @@ static int mdt_reint_link(struct mdt_thread_info *info,
         rc = mdo_link(info->mti_env, mdt_object_child(mp),
                       mdt_object_child(ms), lname, ma);
 
+        if (rc == 0)
+                mdt_counter_incr(req->rq_export, LPROC_MDT_LINK);
+
         EXIT;
 out_unlock_child:
         mdt_object_unlock_put(info, ms, lhs, rc);
@@ -1245,8 +1274,11 @@ static int mdt_reint_rename(struct mdt_thread_info *info,
                         lname, ma);
 
         /* handle last link of tgt object */
-        if (rc == 0 && mnew)
-                mdt_handle_last_unlink(info, mnew, ma);
+        if (rc == 0) {
+                mdt_counter_incr(req->rq_export, LPROC_MDT_RENAME);
+                if (mnew)
+                        mdt_handle_last_unlink(info, mnew, ma);
+        }
 
         EXIT;
 out_unlock_new: