From 6a3599a9389da07ac435d94873376c9f86edea9d Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Thu, 20 Aug 2020 12:09:19 +0800 Subject: [PATCH] LU-13910 mdt: 0 for success in mdt_path_current() 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 Change-Id: I1c10b023da9bbbb908dfb691fcea6e84ced67a8d Reviewed-on: https://review.whamcloud.com/39688 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_handler.c | 5 +++-- lustre/tests/sanity.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index b4416c0..68f98d0 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -6790,8 +6790,6 @@ static int mdt_path_current(struct mdt_thread_info *info, 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) @@ -6807,6 +6805,9 @@ static int mdt_path_current(struct mdt_thread_info *info, first = false; } + /* non-zero will be treated as an error */ + rc = 0; + remote_out: ptr++; /* skip leading / */ memmove(fp->gf_u.gf_path, ptr, diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index dba98f2..f50c83a 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -17214,6 +17214,34 @@ test_226b () { } 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() { -- 1.8.3.1