Whamcloud - gitweb
LU-2901 ldlm: fix resource/fid check, use DLDLMRES
[fs/lustre-release.git] / lustre / llite / namei.c
index 9073f85..81bf255 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -187,7 +187,7 @@ static void ll_invalidate_negative_children(struct inode *dir)
                                                 &dentry->d_subdirs,
                                                 d_u.d_child) {
                                if (child->d_inode == NULL)
-                                       d_lustre_invalidate(child);
+                                       d_lustre_invalidate(child, 1);
                        }
                }
                spin_unlock(&dentry->d_lock);
@@ -205,19 +205,23 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
         switch (flag) {
         case LDLM_CB_BLOCKING:
                 ldlm_lock2handle(lock, &lockh);
-                rc = ldlm_cli_cancel(&lockh);
+               rc = ldlm_cli_cancel(&lockh, LCF_ASYNC);
                 if (rc < 0) {
                         CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc);
                         RETURN(rc);
                 }
                 break;
         case LDLM_CB_CANCELING: {
-                struct inode *inode = ll_inode_from_lock(lock);
+               struct inode *inode = ll_inode_from_resource_lock(lock);
                 struct ll_inode_info *lli;
                 __u64 bits = lock->l_policy_data.l_inodebits.bits;
                 struct lu_fid *fid;
                 ldlm_mode_t mode = lock->l_req_mode;
 
+               /* Inode is set to lock->l_resource->lr_lvb_inode
+                * for mdc - bug 24555 */
+               LASSERT(lock->l_ast_data == NULL);
+
                 /* Invalidate all dentries associated with this inode */
                 if (inode == NULL)
                         break;
@@ -226,19 +230,16 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                 /* For OPEN locks we differentiate between lock modes
                 * LCK_CR, LCK_CW, LCK_PR - bug 22891 */
                if (bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE |
-                           MDS_INODELOCK_LAYOUT))
+                           MDS_INODELOCK_LAYOUT | MDS_INODELOCK_PERM))
                         ll_have_md_lock(inode, &bits, LCK_MINMODE);
 
                 if (bits & MDS_INODELOCK_OPEN)
                         ll_have_md_lock(inode, &bits, mode);
 
-                fid = ll_inode2fid(inode);
-                if (lock->l_resource->lr_name.name[0] != fid_seq(fid) ||
-                    lock->l_resource->lr_name.name[1] != fid_oid(fid) ||
-                    lock->l_resource->lr_name.name[2] != fid_ver(fid)) {
-                        LDLM_ERROR(lock, "data mismatch with object "
-                                   DFID" (%p)", PFID(fid), inode);
-                }
+               fid = ll_inode2fid(inode);
+               if (!fid_res_name_eq(fid, &lock->l_resource->lr_name))
+                       LDLM_ERROR(lock, "data mismatch with object "
+                                  DFID" (%p)", PFID(fid), inode);
 
                 if (bits & MDS_INODELOCK_OPEN) {
                         int flags = 0;
@@ -271,8 +272,11 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                                CDEBUG(D_INODE, "invaliding layout %d.\n", rc);
                }
 
-                if (bits & MDS_INODELOCK_UPDATE)
+               if (bits & MDS_INODELOCK_UPDATE) {
+                       spin_lock(&lli->lli_lock);
                         lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK;
+                       spin_unlock(&lli->lli_lock);
+               }
 
                 if (S_ISDIR(inode->i_mode) &&
                      (bits & MDS_INODELOCK_UPDATE)) {
@@ -284,7 +288,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
 
                if (inode->i_sb->s_root &&
                    inode != inode->i_sb->s_root->d_inode &&
-                   (bits & MDS_INODELOCK_LOOKUP))
+                   (bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM)))
                        ll_invalidate_aliases(inode);
                 iput(inode);
                 break;
@@ -1208,8 +1212,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
         if (oa == NULL)
                 GOTO(out_free_memmd, rc = -ENOMEM);
 
-        oa->o_id = lsm->lsm_object_id;
-        oa->o_seq = lsm->lsm_object_seq;
+       oa->o_oi = lsm->lsm_oi;
         oa->o_mode = body->mode & S_IFMT;
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLGROUP;
 
@@ -1232,17 +1235,17 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
                         GOTO(out_free_memmd, rc);
         }
 
-        rc = obd_destroy(NULL, ll_i2dtexp(dir), oa, lsm, &oti,
-                         ll_i2mdexp(dir), oc);
-        capa_put(oc);
-        if (rc)
-                CERROR("obd destroy objid "LPX64" error %d\n",
-                       lsm->lsm_object_id, rc);
- out_free_memmd:
-        obd_free_memmd(ll_i2dtexp(dir), &lsm);
+       rc = obd_destroy(NULL, ll_i2dtexp(dir), oa, lsm, &oti,
+                        ll_i2mdexp(dir), oc);
+       capa_put(oc);
+       if (rc)
+               CERROR("obd destroy objid "DOSTID" error %d\n",
+                      POSTID(&lsm->lsm_oi), rc);
+out_free_memmd:
+       obd_free_memmd(ll_i2dtexp(dir), &lsm);
        OBDO_FREE(oa);
- out:
-        return rc;
+out:
+       return rc;
 }
 
 /* ll_unlink_generic() doesn't update the inode with the new link count.