From: Bobi Jam Date: Tue, 14 Mar 2023 02:02:12 +0000 (+0800) Subject: LU-16637 llite: call truncate_inode_pages() under inode lock X-Git-Tag: 2.15.55~55 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=ef9be34478036db0544753e33030fff7e32bfe44;p=fs%2Flustre-release.git LU-16637 llite: call truncate_inode_pages() under inode lock truncate_inode_pages() is required to be called under (and serialised by) inode lock. Signed-off-by: Bobi Jam Change-Id: I0f1a09c8756522f87a2e5d8030d12f80e2f630b4 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50284 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index bf632d4..6e76c82 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -1306,7 +1306,7 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md); void ll_update_inode_flags(struct inode *inode, unsigned 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_truncate_inode_pages_final(struct inode *inode, struct cl_io *io); void ll_delete_inode(struct inode *inode); int ll_iocontrol(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 054661e..cbe56d0 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2863,12 +2863,15 @@ void ll_update_dir_depth(struct inode *dir, struct inode *inode) PFID(&lli->lli_fid), lli->lli_dir_depth, lli->lli_inherit_depth); } -void ll_truncate_inode_pages_final(struct inode *inode) +void ll_truncate_inode_pages_final(struct inode *inode, struct cl_io *io) { struct address_space *mapping = &inode->i_data; unsigned long nrpages; unsigned long flags; + LASSERTF(io == NULL || inode_is_locked(inode), "io %p (type %d)\n", + io, io ? io->ci_type : 0); + truncate_inode_pages_final(mapping); /* Workaround for LU-118: Note nrpages may not be totally updated when @@ -2885,10 +2888,12 @@ void ll_truncate_inode_pages_final(struct inode *inode) ll_xa_unlock_irqrestore(&mapping->i_pages, flags); } /* Workaround end */ - LASSERTF(nrpages == 0, "%s: inode="DFID"(%p) nrpages=%lu, " + LASSERTF(nrpages == 0, "%s: inode="DFID"(%p) nrpages=%lu " + "io %p (io_type %d), " "see https://jira.whamcloud.com/browse/LU-118\n", ll_i2sbi(inode)->ll_fsname, - PFID(ll_inode2fid(inode)), inode, nrpages); + PFID(ll_inode2fid(inode)), inode, nrpages, + io, io ? io->ci_type : 0); } int ll_read_inode2(struct inode *inode, void *opaque) @@ -2962,7 +2967,7 @@ void ll_delete_inode(struct inode *inode) CL_FSYNC_LOCAL : CL_FSYNC_DISCARD, 1); } - ll_truncate_inode_pages_final(inode); + ll_truncate_inode_pages_final(inode, NULL); ll_clear_inode(inode); clear_inode(inode); diff --git a/lustre/llite/vvp_object.c b/lustre/llite/vvp_object.c index b19b30f..650df1b 100644 --- a/lustre/llite/vvp_object.c +++ b/lustre/llite/vvp_object.c @@ -155,6 +155,7 @@ static int vvp_conf_set(const struct lu_env *env, struct cl_object *obj, static int vvp_prune(const struct lu_env *env, struct cl_object *obj) { + struct cl_io *io = vvp_env_io(env)->vui_cl.cis_io; struct inode *inode = vvp_object_inode(obj); int rc; ENTRY; @@ -166,9 +167,15 @@ static int vvp_prune(const struct lu_env *env, struct cl_object *obj) RETURN(rc); } - ll_truncate_inode_pages_final(inode); + if (io != NULL) + inode_lock(inode); + + ll_truncate_inode_pages_final(inode, io); mapping_clear_exiting(inode->i_mapping); + if (io != NULL) + inode_unlock(inode); + RETURN(0); }