Whamcloud - gitweb
LU-13910 mdt: 0 for success in mdt_path_current() 88/39688/6
authorEmoly Liu <emoly@whamcloud.com>
Thu, 20 Aug 2020 04:09:19 +0000 (12:09 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 1 Sep 2020 03:44:50 +0000 (03:44 +0000)
0 should be returned if no error is found in mdt_path_current(),
otherwise, the non-zero value will be treated as an error in
mdc_ioc_fid2path() and null will be returned by "lfs fid2path".

sanity.sh test_226c is added to verify this patch.

Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I1c10b023da9bbbb908dfb691fcea6e84ced67a8d
Reviewed-on: https://review.whamcloud.com/39688
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_handler.c
lustre/tests/sanity.sh

index b4416c0..68f98d0 100644 (file)
@@ -6790,8 +6790,6 @@ static int mdt_path_current(struct mdt_thread_info *info,
                        GOTO(out, rc);
                }
 
                        GOTO(out, rc);
                }
 
-               rc = 0;
-
                /* Pack the name in the end of the buffer */
                ptr -= tmpname->ln_namelen;
                if (ptr - 1 <= fp->gf_u.gf_path)
                /* Pack the name in the end of the buffer */
                ptr -= tmpname->ln_namelen;
                if (ptr - 1 <= fp->gf_u.gf_path)
@@ -6807,6 +6805,9 @@ static int mdt_path_current(struct mdt_thread_info *info,
                first = false;
        }
 
                first = false;
        }
 
+       /* non-zero will be treated as an error */
+       rc = 0;
+
 remote_out:
        ptr++; /* skip leading / */
        memmove(fp->gf_u.gf_path, ptr,
 remote_out:
        ptr++; /* skip leading / */
        memmove(fp->gf_u.gf_path, ptr,
index dba98f2..f50c83a 100755 (executable)
@@ -17214,6 +17214,34 @@ test_226b () {
 }
 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
 
 }
 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
 
+test_226c () {
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+       [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
+               skip "Need MDS version at least 2.13.55"
+
+       local submnt=/mnt/submnt
+       local srcfile=/etc/passwd
+       local dstfile=$submnt/passwd
+       local path
+       local fid
+
+       rm -rf $DIR/$tdir
+       rm -rf $submnt
+       $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
+               error "create remote directory failed"
+       mkdir -p $submnt || error "create $submnt failed"
+       $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
+               error "mount $submnt failed"
+       stack_trap "umount $submnt" EXIT
+
+       cp $srcfile $dstfile
+       fid=$($LFS path2fid $dstfile)
+       path=$($LFS fid2path $submnt "$fid")
+       [ "$path" = "$dstfile" ] ||
+               error "fid2path $submnt $fid failed ($path != $dstfile)"
+}
+run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
+
 # LU-1299 Executing or running ldd on a truncated executable does not
 # cause an out-of-memory condition.
 test_227() {
 # LU-1299 Executing or running ldd on a truncated executable does not
 # cause an out-of-memory condition.
 test_227() {