Whamcloud - gitweb
LU-543 mdd: fix rename changelog
authorNiu Yawei <niu@whamcloud.com>
Sat, 5 Nov 2011 05:21:12 +0000 (22:21 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 14 Dec 2011 12:56:15 +0000 (07:56 -0500)
Current rename changelog stores source fid in both CL_RENAME & CL_EXT
records, which is redundant, and the 'tfid' in CL_EXT is never been
used.

Actually, we'd store target fid in the CL_EXT record, then application
could detect the fid unlinked by rename in changelog.

Signed-off-by: Niu Yawei <niu@whamcloud.com>
Change-Id: I0c616f813657a2faefa60a707f4fc1d9dc971b39
Reviewed-on: http://review.whamcloud.com/1652
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mikhail Pershin <tappro@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdd/mdd_dir.c

index 7491ff3..14c0ed8 100644 (file)
@@ -2247,9 +2247,16 @@ cleanup_unlocked:
         if (rc == 0)
                 rc = mdd_changelog_ns_store(env, mdd, CL_RENAME, 0, mdd_tobj,
                                             mdd_spobj, lf, lsname, handle);
-        if (rc == 0)
+        if (rc == 0) {
+                struct lu_fid zero_fid;
+                fid_zero(&zero_fid);
+                /* If the rename target exist, The CL_EXT record should save
+                 * the target fid as tfid, otherwise, use zero fid. LU-543 */
                 rc = mdd_changelog_ns_store(env, mdd, CL_EXT, 0, mdd_tobj,
-                                            mdd_tpobj, lf, ltname, handle);
+                                            mdd_tpobj,
+                                            mdd_tobj ? NULL : &zero_fid,
+                                            ltname, handle);
+        }
 
         mdd_trans_stop(env, mdd, rc, handle);
         if (mdd_sobj)