Whamcloud - gitweb
EX-3133 pcc: keep PCC copy when it is being attached
authorQian Yingjin <qian@ddn.com>
Tue, 11 May 2021 03:38:36 +0000 (11:38 +0800)
committerLi Xi <lixi@ddn.com>
Fri, 14 May 2021 08:12:48 +0000 (08:12 +0000)
When detach a file from PCC backend via FID, if the file is being
attached, it should not purge the coresponding PCC copy from the
PCC backend. Just keep the PCC copy to finish the attach process.

Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I8a8f7c6986d51eaf9b2516e5dd5a6f21aa38b7db
Reviewed-on: https://review.whamcloud.com/43637
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/llite/pcc.c
lustre/utils/liblustreapi_pcc.c

index 5393bfb..86a4f0d 100644 (file)
@@ -2751,6 +2751,8 @@ enum lu_pcc_detach_flags {
        PCC_DETACH_FL_KNOWN_READONLY    = 0x04,
        /* Indicate PCC cached copy is removed */
        PCC_DETACH_FL_CACHE_REMOVED     = 0x08,
+       /* Indicate the file is being attached */
+       PCC_DETACH_FL_ATTACHING         = 0x10,
 };
 
 struct lu_pcc_detach_fid {
index b7c8d68..18f675c 100644 (file)
@@ -3802,8 +3802,12 @@ int pcc_ioctl_detach(struct inode *inode, __u32 *flags)
 
        pcc_inode_lock(inode);
        pcci = lli->lli_pcc_inode;
-       if (!pcci || lli->lli_pcc_state & PCC_STATE_FL_ATTACHING ||
-           !pcc_inode_has_layout(pcci))
+       if (lli->lli_pcc_state & PCC_STATE_FL_ATTACHING) {
+               *flags |= PCC_DETACH_FL_ATTACHING;
+               GOTO(out_unlock, rc = 0);
+       }
+
+       if (!pcci || !pcc_inode_has_layout(pcci))
                GOTO(out_unlock, rc = 0);
 
        LASSERT(atomic_read(&pcci->pcci_refcount) > 0);
index 885a4cc..e7a4ced 100644 (file)
@@ -611,6 +611,9 @@ static int llapi_pcc_scan_detach(const char *pname, const char *fname,
                llapi_printf(LLAPI_MSG_DEBUG,
                             "Detach and remove the PCC cached file: %s\n",
                             fidname);
+       } else if (detach.pccd_flags & PCC_DETACH_FL_ATTACHING) {
+               llapi_printf(LLAPI_MSG_DEBUG,
+                            "'%s' is being attached, skip it", fidname);
        } else {
                snprintf(fullname, sizeof(fullname), "%s/%s", pname, fidname);
                llapi_printf(LLAPI_MSG_DEBUG,