@@ -347,7 +347,8 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx)
struct inode *parent;
parent = file_dentry(filp)->d_parent->d_inode;
- if (ll_have_md_lock(parent, &ibits, LCK_MINMODE))
+ if (ll_have_md_lock(ll_i2mdexp(parent), parent, &ibits,
+ LCK_MINMODE))
pfid = *ll_inode2fid(parent);
}
@@ -5198,7 +5198,7 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum,
*
* Returns: boolean, true iff all bits are found
*/
-int ll_have_md_lock(struct inode *inode, u64 *bits,
+int ll_have_md_lock(struct obd_export *exp, struct inode *inode, u64 *bits,
enum ldlm_mode l_req_mode)
{
struct lustre_handle lockh;
@@ -5222,8 +5222,8 @@ int ll_have_md_lock(struct inode *inode, u64 *bits,
if (policy.l_inodebits.bits == 0)
continue;
- if (md_lock_match(ll_i2mdexp(inode), flags, fid, LDLM_IBITS,
- &policy, mode, &lockh)) {
+ if (md_lock_match(exp, flags, fid, LDLM_IBITS, &policy, mode,
+ &lockh)) {
struct ldlm_lock *lock;
lock = ldlm_handle2lock(&lockh);
@@ -1175,8 +1175,8 @@ static inline void mapping_clear_exiting(struct address_space *mapping)
/* llite/file.c */
extern const struct inode_operations ll_file_inode_operations;
const struct file_operations *ll_select_file_operations(struct ll_sb_info *sbi);
-int ll_have_md_lock(struct inode *inode, u64 *bits,
- enum ldlm_mode l_req_mode);
+int ll_have_md_lock(struct obd_export *exp, struct inode *inode,
+ u64 *bits, enum ldlm_mode l_req_mode);
enum ldlm_mode ll_take_md_lock(struct inode *inode, u64 bits,
struct lustre_handle *lockh, u64 flags,
enum ldlm_mode mode);
@@ -256,7 +256,8 @@ static void ll_lock_cancel_bits(struct ldlm_lock *lock, u64 to_cancel)
* LCK_CR, LCK_CW, LCK_PR - bug 22891
*/
if (bits & MDS_INODELOCK_OPEN)
- ll_have_md_lock(inode, &bits, lock->l_req_mode);
+ ll_have_md_lock(lock->l_conn_export, inode, &bits,
+ lock->l_req_mode);
if (bits & MDS_INODELOCK_OPEN) {
fmode_t fmode;
@@ -284,7 +285,7 @@ static void ll_lock_cancel_bits(struct ldlm_lock *lock, u64 to_cancel)
if (bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE |
MDS_INODELOCK_LAYOUT | MDS_INODELOCK_PERM |
MDS_INODELOCK_DOM))
- ll_have_md_lock(inode, &bits, LCK_MINMODE);
+ ll_have_md_lock(lock->l_conn_export, inode, &bits, LCK_MINMODE);
if (bits & MDS_INODELOCK_DOM) {
rc = ll_dom_lock_cancel(inode, lock);
@@ -435,7 +436,7 @@ int ll_md_need_convert(struct ldlm_lock *lock)
unlock_res_and_lock(lock);
inode = ll_inode_from_resource_lock(lock);
- ll_have_md_lock(inode, &bits, mode);
+ ll_have_md_lock(lock->l_conn_export, inode, &bits, mode);
iput(inode);
return !!(bits);
}
@@ -3558,39 +3558,49 @@ static enum ldlm_mode lmv_lock_match(struct obd_export *exp, u64 flags,
{
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
- enum ldlm_mode rc;
struct lu_tgt_desc *tgt;
- int i;
+ u64 bits = policy->l_inodebits.bits;
+ enum ldlm_mode rc = LCK_MINMODE;
int index;
+ int i;
CDEBUG(D_INODE, "Lock match for " DFID "\n", PFID(fid));
- /*
- * With DNE every object can have two locks in different namespaces:
+ /* only one bit is set */
+ LASSERT(bits && !(bits & (bits - 1)));
+ /* With DNE every object can have two locks in different namespaces:
* lookup lock in space of MDT storing direntry and update/open lock in
* space of MDT storing inode. Try the MDT that the FID maps to first,
* since this can be easily found, and only try others if that fails.
*/
- for (i = 0, index = lmv_fid2tgt_index(lmv, fid);
- i < lmv->lmv_mdt_descs.ltd_tgts_size;
- i++, index = (index + 1) % lmv->lmv_mdt_descs.ltd_tgts_size) {
- if (index < 0) {
- CDEBUG(D_HA, "%s: " DFID " is inaccessible: rc = %d\n",
- obd->obd_name, PFID(fid), index);
- index = 0;
+ if (bits == MDS_INODELOCK_LOOKUP) {
+ for (i = 0, index = lmv_fid2tgt_index(lmv, fid);
+ i < lmv->lmv_mdt_descs.ltd_tgts_size; i++,
+ index = (index + 1) % lmv->lmv_mdt_descs.ltd_tgts_size) {
+ if (index < 0) {
+ CDEBUG(D_HA,
+ "%s: " DFID " is inaccessible: rc = %d\n",
+ obd->obd_name, PFID(fid), index);
+ index = 0;
+ }
+ tgt = lmv_tgt(lmv, index);
+ if (!tgt || !tgt->ltd_exp || !tgt->ltd_active)
+ continue;
+ rc = md_lock_match(tgt->ltd_exp, flags, fid, type,
+ policy, mode, lockh);
+ if (rc)
+ break;
}
-
- tgt = lmv_tgt(lmv, index);
- if (!tgt || !tgt->ltd_exp || !tgt->ltd_active)
- continue;
-
- rc = md_lock_match(tgt->ltd_exp, flags, fid, type, policy, mode,
- lockh);
- if (rc)
- return rc;
+ } else {
+ tgt = lmv_fid2tgt(lmv, fid);
+ if (!IS_ERR(tgt) && tgt->ltd_exp && tgt->ltd_active)
+ rc = md_lock_match(tgt->ltd_exp, flags, fid, type,
+ policy, mode, lockh);
}
- return 0;
+ CDEBUG(D_INODE, "Lock match for "DFID": %d\n", PFID(fid), rc);
+
+ return rc;
}
static int lmv_get_lustre_md(struct obd_export *exp,