Whamcloud - gitweb
LU-10499 pcc: print help msg more clearly for detach 25/54425/8
authorQian Yingjin <qian@ddn.com>
Thu, 16 Sep 2021 02:45:37 +0000 (10:45 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 30 Aug 2024 05:59:37 +0000 (05:59 +0000)
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 <qian@ddn.com>
Change-Id: I547e80e5c9c213b159039b9b79da176cdb91c4bc
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54425
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
lustre/llite/pcc.c
lustre/tests/sanity-pcc.sh
lustre/utils/lfs.c

index 64e28ba..489adf3 100644 (file)
@@ -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);
index ba7ffad..1823d1a 100755 (executable)
@@ -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"
index 3067a49..51bae69 100755 (executable)
@@ -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;