Whamcloud - gitweb
LU-17413 llite: protect check in ll_merge_md_attr() 39/53639/2
authorAlex Zhuravlev <bzzz@whamcloud.com>
Wed, 10 Jan 2024 19:09:18 +0000 (22:09 +0300)
committerOleg Drokin <green@whamcloud.com>
Sat, 17 Feb 2024 06:58:41 +0000 (06:58 +0000)
striping can apply in a concurrent process, so the check for striping
should be serialized against any concurrent process.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Iffac2f1f9b53abc26705d70a30c2201b48156ac8
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53639
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/llite/file.c
lustre/llite/llite_internal.h

index 10c03f3..ab776c4 100644 (file)
@@ -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);
index 115c06e..624c11e 100644 (file)
@@ -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;