Whamcloud - gitweb
LU-5005 utils: handle ROOT path correctly
authorNiu Yawei <yawei.niu@intel.com>
Mon, 5 May 2014 03:41:42 +0000 (23:41 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 14 May 2014 21:05:38 +0000 (17:05 -0400)
MDT replies path '\0' to the request of fid2path on ROOT,
client utils should handle it properly.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: Ic7064866b0e8ef33fc0a17e273a120d6d6dae4fe
Reviewed-on: http://review.whamcloud.com/10211
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/lustre-rsync-test.sh
lustre/utils/liblustreapi.c

index 656cd00..29b1478 100644 (file)
@@ -207,6 +207,49 @@ test_1() {
 }
 run_test 1 "Simple Replication"
 
+# Test 1a - test create/delete operations in ROOT directory
+test_1a() { # LU-5005
+       rm -rf $TGT/root-* 2> /dev/null
+       rm -rf $DIR/root-* 2> /dev/null
+       init_changelog
+
+       # Directory create
+       mkdir $DIR/root-dir
+
+       # File create
+       touch $DIR/root-file
+       touch $DIR/root-file2
+
+       # File rename
+       mv $DIR/root-file2 $DIR/root-file3
+
+       # File and directory delete
+       touch $DIR/root-file4
+       mkdir $DIR/root-dir1
+       rm $DIR/root-file4
+       rm -rf $DIR/root-dir1
+
+       # Replicate
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       echo "Replication"
+       $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+
+       # Verify
+       stat $TGT/root-dir || error "Dir create not replicated"
+       stat $TGT/root-file || error "File create not replicated"
+       stat $TGT/root-file2 && error "Rename not replicated (src)"
+       stat $TGT/root-file3 || error "Rename not replicated (tgt)"
+       stat $TGT/root-dir1 && error "Dir delete not replicated"
+       stat $TGT/root-file4 && error "File delete not replicated"
+
+       fini_changelog
+       rm -fr $TGT/root-*
+       rm -fr $DIR/root-*
+       return 0
+}
+run_test 1a "Replicate create/delete operations in ROOT directory"
+
 # Test 2a - Replicate files created by dbench
 test_2a() {
        init_src
index 0b17db1..2565afe 100644 (file)
@@ -4156,9 +4156,13 @@ int llapi_fid2path(const char *device, const char *fidstr, char *buf,
                 if (rc != -ENOENT)
                         llapi_error(LLAPI_MSG_ERROR, rc, "ioctl err %d", rc);
         } else {
-                memcpy(buf, gf->gf_path, gf->gf_pathlen);
-                *recno = gf->gf_recno;
-                *linkno = gf->gf_linkno;
+               memcpy(buf, gf->gf_path, gf->gf_pathlen);
+               if (buf[0] == '\0') { /* ROOT path */
+                       buf[0] = '/';
+                       buf[1] = '\0';
+               }
+               *recno = gf->gf_recno;
+               *linkno = gf->gf_linkno;
         }
 
         free(gf);