Whamcloud - gitweb
LU-10948 llite: Revalidate dentries in ll_intent_file_open
[fs/lustre-release.git] / lustre / llite / file.c
index 8d2368b..6f26724 100644 (file)
@@ -413,27 +413,14 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req,
        struct page *vmpage;
        struct niobuf_remote *rnb;
        char *data;
-       struct lustre_handle lockh;
-       struct ldlm_lock *lock;
        unsigned long index, start;
        struct niobuf_local lnb;
-       bool dom_lock = false;
 
        ENTRY;
 
        if (obj == NULL)
                RETURN_EXIT;
 
-       if (it->it_lock_mode != 0) {
-               lockh.cookie = it->it_lock_handle;
-               lock = ldlm_handle2lock(&lockh);
-               if (lock != NULL)
-                       dom_lock = ldlm_has_dom(lock);
-               LDLM_LOCK_PUT(lock);
-       }
-       if (!dom_lock)
-               RETURN_EXIT;
-
        if (!req_capsule_has_field(&req->rq_pill, &RMF_NIOBUF_INLINE,
                                   RCL_SERVER))
                RETURN_EXIT;
@@ -570,8 +557,27 @@ retry:
        rc = ll_prep_inode(&de->d_inode, req, NULL, itp);
 
        if (!rc && itp->it_lock_mode) {
-               ll_dom_finish_open(de->d_inode, req, itp);
+               struct lustre_handle handle = {.cookie = itp->it_lock_handle};
+               struct ldlm_lock *lock;
+               bool has_dom_bit = false;
+
+               /* If we got a lock back and it has a LOOKUP bit set,
+                * make sure the dentry is marked as valid so we can find it.
+                * We don't need to care about actual hashing since other bits
+                * of kernel will deal with that later.
+                */
+               lock = ldlm_handle2lock(&handle);
+               if (lock) {
+                       has_dom_bit = ldlm_has_dom(lock);
+                       if (lock->l_policy_data.l_inodebits.bits &
+                           MDS_INODELOCK_LOOKUP)
+                               d_lustre_revalidate(de);
+
+                       LDLM_LOCK_PUT(lock);
+               }
                ll_set_lock_data(sbi->ll_md_exp, de->d_inode, itp, NULL);
+               if (has_dom_bit)
+                       ll_dom_finish_open(de->d_inode, req, itp);
        }
 
 out:
@@ -3301,7 +3307,7 @@ static void ll_heat_get(struct inode *inode, struct lu_heat *heat)
        spin_unlock(&lli->lli_heat_lock);
 }
 
-static int ll_heat_set(struct inode *inode, __u64 flags)
+static int ll_heat_set(struct inode *inode, enum lu_heat_flag flags)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
        int rc = 0;
@@ -4474,6 +4480,11 @@ static int ll_merge_md_attr(struct inode *inode)
        int rc;
 
        LASSERT(lli->lli_lsm_md != NULL);
+
+       /* foreign dir is not striped dir */
+       if (lli->lli_lsm_md->lsm_md_magic == LMV_MAGIC_FOREIGN)
+               RETURN(0);
+
        down_read(&lli->lli_lsm_sem);
        rc = md_merge_attr(ll_i2mdexp(inode), ll_i2info(inode)->lli_lsm_md,
                           &attr, ll_md_blocking_ast);