From: Qian Yingjin Date: Thu, 16 Sep 2021 02:45:37 +0000 (+0800) Subject: LU-10499 pcc: print help msg more clearly for detach X-Git-Tag: 2.15.91~60 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=e37c7507673742ae981ba0065af13154dff1e8fc;p=fs%2Flustre-release.git LU-10499 pcc: print help msg more clearly for detach In this patch, it prints the help message for detach_fid and detach commands more clearly when not given the required parameters such as mount point or FIDs. It also ignores the -EINPROGRESS error if the file is being attached, i.e. copy data from Lustre OSTs into PCC. Reset llite.*.pcc_async_threshold to the original value when the subtest exits, so that it doesn't affect later tests. Wait for async pcc attach to finish in test_47. EX-bug-id: EX-3814 EX-3409 Signed-off-by: Qian Yingjin Change-Id: I547e80e5c9c213b159039b9b79da176cdb91c4bc Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54425 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: James Simmons --- diff --git a/lustre/llite/pcc.c b/lustre/llite/pcc.c index 64e28ba..489adf3 100644 --- a/lustre/llite/pcc.c +++ b/lustre/llite/pcc.c @@ -3996,8 +3996,12 @@ static int pcc_readonly_attach_sync(struct file *file, CDEBUG(D_CACHE, "PCC-RO caching for "DFID" not allowed, rc = %d\n", PFID(ll_inode2fid(inode)), rc); - /* Ignore EEXIST error if the file has already attached. */ - if (rc == -EEXIST) + /* + * Ignore EEXIST error if the file has already attached. + * Ignore EINPROGRESS error if the file is being attached, + * i.e. copy data from OSTs into PCC. + */ + if (rc == -EEXIST || rc == -EINPROGRESS) rc = 0; RETURN(rc); } @@ -4084,7 +4088,7 @@ int pcc_ioctl_detach(struct inode *inode, __u32 *flags) ENTRY; pcc_inode_lock(inode); - pcci = lli->lli_pcc_inode; + pcci = ll_i2pcci(inode); if (lli->lli_pcc_state & PCC_STATE_FL_ATTACHING) { *flags |= PCC_DETACH_FL_ATTACHING; GOTO(out_unlock, rc = 0); diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index ba7ffad..1823d1a 100755 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -3404,7 +3404,7 @@ test_44() { head -n 1) stack_trap "$LCTL set_param llite.*.pcc_async_threshold=$thresh" - $LCTL set_param llite.*.pcc_async_threshold=1G + $LCTL set_param llite.*.pcc_async_threshold=0 dd if=/dev/zero of=$file bs=$bs count=$count || error "Write $file failed" @@ -3634,7 +3634,7 @@ test_47() { sleep 3 cat $file || error "cat $file failed" - check_lpcc_state $file "readonly" client + wait_readonly_attach_fini $file client mtime1=$(stat -c "%Y" $file) (( mtime0 == mtime1 )) || error "mtime changed from $mtime0 to $mtime1" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 3067a49..51bae69 100755 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -13949,6 +13949,11 @@ static int lfs_pcc_detach(int argc, char **argv) } } + if (argc <= optind) { + fprintf(stderr, "%s: must specify one or more FIDs\n", argv[0]); + return CMD_HELP; + } + while (optind < argc) { int rc2; @@ -14004,7 +14009,18 @@ static int lfs_pcc_detach_fid(int argc, char **argv) } } + if (argc <= optind) { + fprintf(stderr, "%s: must specify Lustre mount point\n", + argv[0]); + return CMD_HELP; + } + mntpath = argv[optind++]; + if (argc <= optind) { + fprintf(stderr, "%s: must specify one or more fids\n", argv[0]); + return CMD_HELP; + } + dirfd = open(mntpath, O_RDONLY); if (dirfd < 0) { rc = -errno;