Whamcloud - gitweb
Branch b1_8_gate
authorhuanghua <huanghua>
Thu, 17 Jul 2008 14:43:34 +0000 (14:43 +0000)
committerhuanghua <huanghua>
Thu, 17 Jul 2008 14:43:34 +0000 (14:43 +0000)
b=15993

a=17865
i=adilger,nikita

a=17883
i=adilger

- remove common EA (in downgraded mode) if it exists, and its test case.

lustre/mds/mds_reint.c

index 72b4aeb..8ed9e65 100644 (file)
@@ -60,6 +60,38 @@ struct mds_logcancel_data {
         struct llog_cookie      mlcd_cookies[0];
 };
 
+/** lookup child dentry in parent dentry according to the name.
+ *  if dentry is found, delete "lustre_mdt_attrs" EA (with name "lma")
+ *  if it exists by checking OBD_INCOMPAT_FID.
+ */
+struct dentry *mds_lookup(struct obd_device *obd, const char *fid_name,
+                          struct dentry *dparent, int fid_namelen)
+{
+        struct dentry *dchild;
+        struct lr_server_data *lsd = obd->u.mds.mds_server_data;
+        EXIT;
+        
+        dchild = ll_lookup_one_len(fid_name, dparent, fid_namelen);
+        if (!IS_ERR(dchild) &&
+            unlikely((lsd->lsd_feature_incompat & OBD_INCOMPAT_FID) ||
+                      OBD_FAIL_CHECK(OBD_FAIL_MDS_REMOVE_COMMON_EA))) {
+                struct inode *inode = dchild->d_inode; 
+                void         *handle;
+                if (inode != NULL) {
+                        handle = fsfilt_start(obd, inode, FSFILT_OP_SETATTR,
+                                              NULL);
+                        if (!IS_ERR(handle)) {
+                                LOCK_INODE_MUTEX(inode);
+                                fsfilt_set_md(obd, inode, handle, NULL, 0,
+                                              "lma");
+                                /* result is ignored. */
+                                UNLOCK_INODE_MUTEX(inode);
+                                fsfilt_commit(obd, inode, handle, 0);
+                        }
+                }
+        }
+        RETURN(dchild);
+}
 
 static void mds_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
                                   void *cb_data, int error)
@@ -768,7 +800,8 @@ static void reconstruct_reint_create(struct mds_update_record *rec, int offset,
                 EXIT;
                 return;
         }
-        child = ll_lookup_one_len(rec->ur_name, parent, rec->ur_namelen - 1);
+        child = mds_lookup(exp->exp_obd, rec->ur_name, parent,
+                           rec->ur_namelen - 1);
         if (IS_ERR(child)) {
                 rc = PTR_ERR(child);
                 LCONSOLE_WARN("Child "LPU64"/%u lookup error %d." 
@@ -841,7 +874,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
 
         ldlm_lock_dump_handle(D_OTHER, &lockh);
 
-        dchild = ll_lookup_one_len(rec->ur_name, dparent, rec->ur_namelen - 1);
+        dchild = mds_lookup(obd, rec->ur_name, dparent, rec->ur_namelen - 1);
         if (IS_ERR(dchild)) {
                 rc = PTR_ERR(dchild);
                 CDEBUG(D_DENTRY, "child lookup error %d\n", rc);
@@ -1395,7 +1428,7 @@ int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds,
         cleanup_phase = 1; /* parent dentry */
 
         /* Step 2: Lookup child (without DLM lock, to get resource name) */
-        *dchildp = ll_lookup_one_len(name, *dparentp, namelen - 1);
+        *dchildp = mds_lookup(obd, name, *dparentp, namelen - 1);
         if (IS_ERR(*dchildp)) {
                 rc = PTR_ERR(*dchildp);
                 CDEBUG(D_INODE, "child lookup error %d\n", rc);
@@ -1904,7 +1937,7 @@ static int mds_reint_link(struct mds_update_record *rec, int offset,
         }
 
         /* Step 3: Lookup the child */
-        dchild = ll_lookup_one_len(rec->ur_name, de_tgt_dir, rec->ur_namelen-1);
+        dchild = mds_lookup(obd, rec->ur_name, de_tgt_dir, rec->ur_namelen-1);
         if (IS_ERR(dchild)) {
                 rc = PTR_ERR(dchild);
                 if (rc != -EPERM && rc != -EACCES && rc != -ENAMETOOLONG)
@@ -2043,7 +2076,7 @@ int mds_get_parents_children_locked(struct obd_device *obd,
         p2_res_id.name[1] = (*de_tgtdirp)->d_inode->i_generation;
 
         /* Step 3: Lookup the source child entry */
-        *de_oldp = ll_lookup_one_len(old_name, *de_srcdirp, old_len - 1);
+        *de_oldp = mds_lookup(obd, old_name, *de_srcdirp, old_len - 1);
         if (IS_ERR(*de_oldp)) {
                 rc = PTR_ERR(*de_oldp);
                 CDEBUG(D_INODE, "old child lookup error (%.*s): rc %d\n",
@@ -2067,7 +2100,7 @@ int mds_get_parents_children_locked(struct obd_device *obd,
         /* Step 4: Lookup the target child entry */
         if (!new_name)
                 GOTO(retry_locks, rc);
-        *de_newp = ll_lookup_one_len(new_name, *de_tgtdirp, new_len - 1);
+        *de_newp = mds_lookup(obd, new_name, *de_tgtdirp, new_len - 1);
         if (IS_ERR(*de_newp)) {
                 rc = PTR_ERR(*de_newp);
                 CDEBUG(D_DENTRY, "new child lookup error (%.*s): rc %d\n",