Whamcloud - gitweb
LU-14644 vvp: wait for nrpages to be updated
authorVitaly Fertman <c17818@cray.com>
Tue, 27 Apr 2021 18:43:06 +0000 (21:43 +0300)
committerJohn L. Hammond <jhammond@whamcloud.com>
Tue, 5 Apr 2022 20:58:21 +0000 (20:58 +0000)
truncate_inode_pages() says there still may be a page in a process
of deletion upon return. wait for another thread which is doing
__delete_from_page_cache() to get nrpages updated.

Lustre-change: https://review.whamcloud.com/43464
Lustre-commit: 7d5d004506650c3739898e70d72c9a86b8aeeb88

Signed-off-by: Vitaly Fertman <c17818@cray.com>
Change-Id: I165b3d0866efaf2eb7e977520ebba4ee831874ab
HPE-bug-id: LUS-8842
Reviewed-on: https://review.whamcloud.com/46954
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/vvp_object.c

index 105355b..3958266 100644 (file)
@@ -1285,6 +1285,7 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md);
 void ll_update_inode_flags(struct inode *inode, int ext_flags);
 void ll_update_dir_depth(struct inode *dir, struct inode *inode);
 int ll_read_inode2(struct inode *inode, void *opaque);
+void ll_truncate_inode_pages_final(struct inode *inode);
 void ll_delete_inode(struct inode *inode);
 int ll_iocontrol(struct inode *inode, struct file *file,
                  unsigned int cmd, unsigned long arg);
index 1924914..8fc5b95 100644 (file)
@@ -2626,6 +2626,34 @@ void ll_update_dir_depth(struct inode *dir, struct inode *inode)
               PFID(&lli->lli_fid), lli->lli_dir_depth);
 }
 
+void ll_truncate_inode_pages_final(struct inode *inode)
+{
+       struct address_space *mapping = &inode->i_data;
+       unsigned long nrpages;
+       unsigned long flags;
+
+       truncate_inode_pages_final(mapping);
+
+       /* Workaround for LU-118: Note nrpages may not be totally updated when
+        * truncate_inode_pages() returns, as there can be a page in the process
+        * of deletion (inside __delete_from_page_cache()) in the specified
+        * range. Thus mapping->nrpages can be non-zero when this function
+        * returns even after truncation of the whole mapping.  Only do this if
+        * npages isn't already zero.
+        */
+       nrpages = mapping->nrpages;
+       if (nrpages) {
+               ll_xa_lock_irqsave(&mapping->i_pages, flags);
+               nrpages = mapping->nrpages;
+               ll_xa_unlock_irqrestore(&mapping->i_pages, flags);
+       } /* Workaround end */
+
+       LASSERTF(nrpages == 0, "%s: inode="DFID"(%p) nrpages=%lu, "
+                "see https://jira.whamcloud.com/browse/LU-118\n",
+                ll_i2sbi(inode)->ll_fsname,
+                PFID(ll_inode2fid(inode)), inode, nrpages);
+}
+
 int ll_read_inode2(struct inode *inode, void *opaque)
 {
         struct lustre_md *md = opaque;
@@ -2683,10 +2711,6 @@ int ll_read_inode2(struct inode *inode, void *opaque)
 void ll_delete_inode(struct inode *inode)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
-       struct address_space *mapping = &inode->i_data;
-       unsigned long nrpages;
-       unsigned long flags;
-
        ENTRY;
 
        if (S_ISREG(inode->i_mode) && lli->lli_clob != NULL) {
@@ -2700,27 +2724,8 @@ void ll_delete_inode(struct inode *inode)
                cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, inode->i_nlink ?
                                   CL_FSYNC_LOCAL : CL_FSYNC_DISCARD, 1);
        }
-       truncate_inode_pages_final(mapping);
-
-       /* Workaround for LU-118: Note nrpages may not be totally updated when
-        * truncate_inode_pages() returns, as there can be a page in the process
-        * of deletion (inside __delete_from_page_cache()) in the specified
-        * range. Thus mapping->nrpages can be non-zero when this function
-        * returns even after truncation of the whole mapping.  Only do this if
-        * npages isn't already zero.
-        */
-       nrpages = mapping->nrpages;
-       if (nrpages) {
-               ll_xa_lock_irqsave(&mapping->i_pages, flags);
-               nrpages = mapping->nrpages;
-               ll_xa_unlock_irqrestore(&mapping->i_pages, flags);
-       } /* Workaround end */
-
-       LASSERTF(nrpages == 0, "%s: inode="DFID"(%p) nrpages=%lu, "
-                "see https://jira.whamcloud.com/browse/LU-118\n",
-                ll_i2sbi(inode)->ll_fsname,
-                PFID(ll_inode2fid(inode)), inode, nrpages);
 
+       ll_truncate_inode_pages_final(inode);
        ll_clear_inode(inode);
        clear_inode(inode);
 
index 95f5e89..a2aa79a 100644 (file)
@@ -168,13 +168,8 @@ static int vvp_prune(const struct lu_env *env, struct cl_object *obj)
                RETURN(rc);
        }
 
-       truncate_inode_pages(inode->i_mapping, 0);
-       if (inode->i_mapping->nrpages) {
-               CDEBUG(D_VFSTRACE, DFID ": still has %lu pages remaining\n",
-                      PFID(lu_object_fid(&obj->co_lu)),
-                      inode->i_mapping->nrpages);
-               RETURN(-EIO);
-       }
+       ll_truncate_inode_pages_final(inode);
+       clear_bit(AS_EXITING, &inode->i_mapping->flags);
 
        RETURN(0);
 }