Whamcloud - gitweb
LU-10499 pcc: keep PCC copy when it is being attached 89/54389/5
authorQian Yingjin <qian@ddn.com>
Tue, 11 May 2021 03:38:36 +0000 (11:38 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 8 Jul 2024 20:10:29 +0000 (20:10 +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.

EX-3144 pcc: revalidate the pointer after attach
In this patch, we also fix a bug during PCC open attach. It
refreshes @pcci pointer since the lock may be released in
@pcc_try_readonly_open_attach().
Was-Change-Id: I470358dfde525e08e7110e862b30b527e5db94fe

EX-bug-id: EX-3133 EX-3144
Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I8a8f7c6986d51eaf9b2516e5dd5a6f21aa38b7db
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54389
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/llite/pcc.c
lustre/utils/liblustreapi_pcc.c

index 3904e44..46cede1 100644 (file)
@@ -3004,6 +3004,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 dd08925..a1a1df0 100644 (file)
@@ -2262,8 +2262,7 @@ int pcc_file_open(struct inode *inode, struct file *file)
                if (rc < 0 || !cached)
                        GOTO(out_unlock, rc);
 
-               if (!pcci)
-                       pcci = ll_i2pcci(inode);
+               pcci = ll_i2pcci(inode);
        }
 
        pcc_inode_get(pcci);
@@ -3925,8 +3924,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 9e6710b..0376e76 100644 (file)
@@ -609,6 +609,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,