From 276af9bf6285982b8c4fa4708991114a5ff2d444 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Wed, 10 Jan 2024 22:09:18 +0300 Subject: [PATCH] LU-17413 llite: protect check in ll_merge_md_attr() striping can apply in a concurrent process, so the check for striping should be serialized against any concurrent process. Signed-off-by: Alex Zhuravlev Change-Id: Iffac2f1f9b53abc26705d70a30c2201b48156ac8 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53639 Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lustre/llite/file.c | 4 ++++ lustre/llite/llite_internal.h | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 10c03f3..ab776c4 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -5468,6 +5468,10 @@ static int ll_merge_md_attr(struct inode *inode) RETURN(0); down_read(&lli->lli_lsm_sem); + if (!ll_dir_striped_locked(inode)) { + up_read(&lli->lli_lsm_sem); + RETURN(0); + } LASSERT(lli->lli_lsm_obj != NULL); lsm_obj = lmv_stripe_object_get(lli->lli_lsm_obj); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 115c06e..624c11e 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -1638,7 +1638,7 @@ static inline struct lu_fid *ll_inode2fid(struct inode *inode) return fid; } -static inline bool ll_dir_striped(struct inode *inode) +static inline bool ll_dir_striped_locked(struct inode *inode) { bool rc; LASSERT(inode); @@ -1646,9 +1646,21 @@ static inline bool ll_dir_striped(struct inode *inode) if (!S_ISDIR(inode->i_mode)) return false; - down_read(&ll_i2info(inode)->lli_lsm_sem); rc = !!(ll_i2info(inode)->lli_lsm_obj && lmv_dir_striped(ll_i2info(inode)->lli_lsm_obj)); + + return rc; +} + +static inline bool ll_dir_striped(struct inode *inode) +{ + bool rc; + + if (!S_ISDIR(inode->i_mode)) + return false; + + down_read(&ll_i2info(inode)->lli_lsm_sem); + rc = ll_dir_striped_locked(inode); up_read(&ll_i2info(inode)->lli_lsm_sem); return rc; -- 1.8.3.1