Whamcloud - gitweb
LU-15535 revert: "LU-15284 llite: access lli_lsm_md with lock in all places" 88/50488/4
authorVitaly Fertman <c17818@cray.com>
Fri, 31 Mar 2023 17:30:27 +0000 (20:30 +0300)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 Jul 2023 16:47:17 +0000 (16:47 +0000)
This reverts commit 1dfae156d1dbc11cfb77b2d35cbffb2da7f28137
as a prerequisite of a larger fix in this ticket which covers
this problem as well.

Signed-off-by: Vitaly Fertman <vitaly.fertman@hpe.com>
Change-Id: Ic1b0b6c963ea96e9f51324625deaa851245f8a7d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50488
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/namei.c
lustre/llite/statahead.c
lustre/lmv/lmv_obd.c

index e6921c2..2a1393b 100644 (file)
@@ -166,8 +166,7 @@ void ll_release_page(struct inode *inode, struct page *page,
 
        /* Always remove the page for striped dir, because the page is
         * built from temporarily in LMV layer */
-       if (inode && S_ISDIR(inode->i_mode) &&
-           lmv_dir_striped(ll_i2info(inode)->lli_lsm_md)) {
+       if (inode && ll_dir_striped(inode)) {
                __free_page(page);
                return;
        }
index bc06c69..a2d74ed 100644 (file)
@@ -5427,14 +5427,12 @@ static int ll_merge_md_attr(struct inode *inode)
        struct cl_attr attr = { 0 };
        int rc;
 
-       if (!lli->lli_lsm_md)
+       LASSERT(lli->lli_lsm_md != NULL);
+
+       if (!lmv_dir_striped(lli->lli_lsm_md))
                RETURN(0);
 
        down_read(&lli->lli_lsm_sem);
-       if (!lmv_dir_striped(lli->lli_lsm_md)) {
-               up_read(&lli->lli_lsm_sem);
-               RETURN(0);
-       }
        rc = md_merge_attr(ll_i2mdexp(inode), ll_i2info(inode)->lli_lsm_md,
                           &attr, ll_md_blocking_ast);
        up_read(&lli->lli_lsm_sem);
index 2892ba3..cf80970 100644 (file)
@@ -1546,22 +1546,9 @@ static inline struct lu_fid *ll_inode2fid(struct inode *inode)
 
 static inline bool ll_dir_striped(struct inode *inode)
 {
-       struct ll_inode_info *lli;
-       bool rc;
-
        LASSERT(inode);
-       if (!S_ISDIR(inode->i_mode))
-               return false;
-
-       lli = ll_i2info(inode);
-       if (!lli->lli_lsm_md)
-               return false;
-
-       down_read(&lli->lli_lsm_sem);
-       rc = lmv_dir_striped(lli->lli_lsm_md);
-       up_read(&lli->lli_lsm_sem);
-
-       return rc;
+       return S_ISDIR(inode->i_mode) &&
+              lmv_dir_striped(ll_i2info(inode)->lli_lsm_md);
 }
 
 static inline loff_t ll_file_maxbytes(struct inode *inode)
index f5e7043..4767355 100644 (file)
@@ -1829,21 +1829,21 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
        }
 
        rc = ll_init_lsm_md(inode, md);
-       if (rc) {
-               up_write(&lli->lli_lsm_sem);
-               RETURN(rc);
-       }
+       up_write(&lli->lli_lsm_sem);
 
-       /* md_merge_attr() may take long, since lsm is already set, switch to
-        * read lock.
-        */
-       downgrade_write(&lli->lli_lsm_sem);
+       if (rc)
+               RETURN(rc);
 
        /* set md->lmv to NULL, so the following free lustre_md will not free
         * this lsm.
         */
        md->lmv = NULL;
 
+       /* md_merge_attr() may take long, since lsm is already set, switch to
+        * read lock.
+        */
+       down_read(&lli->lli_lsm_sem);
+
        if (!lmv_dir_striped(lli->lli_lsm_md))
                GOTO(unlock, rc = 0);
 
index 039508c..0a58e96 100644 (file)
@@ -772,17 +772,14 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
                struct lookup_intent parent_it = {
                                        .it_op = IT_GETATTR,
                                        .it_lock_handle = 0 };
-               struct ll_inode_info *lli = ll_i2info(parent);
-               struct lu_fid fid = lli->lli_fid;
+               struct lu_fid   fid = ll_i2info(parent)->lli_fid;
 
                /* If it is striped directory, get the real stripe parent */
                if (unlikely(ll_dir_striped(parent))) {
-                       down_read(&lli->lli_lsm_sem);
                        rc = md_get_fid_from_lsm(ll_i2mdexp(parent),
-                                                lli->lli_lsm_md,
+                                                ll_i2info(parent)->lli_lsm_md,
                                                 (*de)->d_name.name,
                                                 (*de)->d_name.len, &fid);
-                       up_read(&lli->lli_lsm_sem);
                        if (rc != 0)
                                GOTO(out, rc);
                }
index 6d056fc..0253b0d 100644 (file)
@@ -1227,10 +1227,8 @@ static int ll_statahead_thread(void *arg)
                }
 
                pos = le64_to_cpu(dp->ldp_hash_end);
-               down_read(&lli->lli_lsm_sem);
                ll_release_page(dir, page,
                                le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE);
-               up_read(&lli->lli_lsm_sem);
 
                if (sa_low_hit(sai)) {
                        rc = -EFAULT;
index efcefcb..967270f 100644 (file)
@@ -3805,8 +3805,7 @@ static int lmv_get_fid_from_lsm(struct obd_export *exp,
 {
        const struct lmv_oinfo *oinfo;
 
-       if (!lmv_dir_striped(lsm))
-               RETURN(-ESTALE);
+       LASSERT(lmv_dir_striped(lsm));
 
        oinfo = lsm_name_to_stripe_info(lsm, name, namelen, false);
        if (IS_ERR(oinfo))