Commit 15b241c5 authored by wang di's avatar wang di Committed by Greg Kroah-Hartman

staging: lustre: lmv: Do not revalidate stripes with master lock

Do not revalidate slave stripes while holding master lock.
Otherwise if the revalidating slaves are blocked, then the
master lock can not be released in time.

Remove some unnecesary merging in ll_revalidate_slave(), and
the attributes will be stored in each stripe, only
merging them if required.
Signed-off-by: default avatarwang di <di.wang@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6088
Reviewed-on: http://review.whamcloud.com/13432Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarLai Siyao <lai.siyao@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0022c6bc
......@@ -1000,10 +1000,7 @@ struct md_ops {
int (*merge_attr)(struct obd_export *,
const struct lmv_stripe_md *lsm,
struct cl_attr *attr);
int (*update_lsm_md)(struct obd_export *, struct lmv_stripe_md *lsm,
struct mdt_body *, ldlm_blocking_callback);
struct cl_attr *attr, ldlm_blocking_callback);
int (*set_open_replay_data)(struct obd_export *,
struct obd_client_handle *,
......
......@@ -1497,23 +1497,14 @@ static inline int md_free_lustre_md(struct obd_export *exp,
return MDP(exp->exp_obd, free_lustre_md)(exp, md);
}
static inline int md_update_lsm_md(struct obd_export *exp,
struct lmv_stripe_md *lsm,
struct mdt_body *body,
ldlm_blocking_callback cb)
{
EXP_CHECK_MD_OP(exp, update_lsm_md);
EXP_MD_COUNTER_INCREMENT(exp, update_lsm_md);
return MDP(exp->exp_obd, update_lsm_md)(exp, lsm, body, cb);
}
static inline int md_merge_attr(struct obd_export *exp,
const struct lmv_stripe_md *lsm,
struct cl_attr *attr)
struct cl_attr *attr,
ldlm_blocking_callback cb)
{
EXP_CHECK_MD_OP(exp, merge_attr);
EXP_MD_COUNTER_INCREMENT(exp, merge_attr);
return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr);
return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb);
}
static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
......
......@@ -3045,12 +3045,13 @@ static int ll_merge_md_attr(struct inode *inode)
LASSERT(ll_i2info(inode)->lli_lsm_md);
rc = md_merge_attr(ll_i2mdexp(inode), ll_i2info(inode)->lli_lsm_md,
&attr);
&attr, ll_md_blocking_ast);
if (rc)
return rc;
ll_i2info(inode)->lli_stripe_dir_size = attr.cat_size;
ll_i2info(inode)->lli_stripe_dir_nlink = attr.cat_nlink;
set_nlink(inode, attr.cat_nlink);
inode->i_blocks = attr.cat_blocks;
i_size_write(inode, attr.cat_size);
ll_i2info(inode)->lli_atime = attr.cat_atime;
ll_i2info(inode)->lli_mtime = attr.cat_mtime;
......@@ -3123,16 +3124,10 @@ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat)
stat->mtime = inode->i_mtime;
stat->ctime = inode->i_ctime;
stat->blksize = 1 << inode->i_blkbits;
stat->blocks = inode->i_blocks;
if (S_ISDIR(inode->i_mode) &&
ll_i2info(inode)->lli_lsm_md) {
stat->nlink = lli->lli_stripe_dir_nlink;
stat->size = lli->lli_stripe_dir_size;
} else {
stat->nlink = inode->i_nlink;
stat->size = i_size_read(inode);
}
stat->blocks = inode->i_blocks;
return 0;
}
......
......@@ -191,9 +191,6 @@ struct ll_inode_info {
unsigned int lli_sa_generation;
/* directory stripe information */
struct lmv_stripe_md *lli_lsm_md;
/* striped directory size */
loff_t lli_stripe_dir_size;
u64 lli_stripe_dir_nlink;
};
/* for non-directory */
......
......@@ -1117,12 +1117,7 @@ static int ll_init_lsm_md(struct inode *inode, struct lustre_md *md)
}
}
/*
* Here is where the lsm is being initialized(fill lmo_info) after
* client retrieve MD stripe information from MDT.
*/
return md_update_lsm_md(ll_i2mdexp(inode), lsm, md->body,
ll_md_blocking_ast);
return 0;
}
static inline int lli_lsm_md_eq(const struct lmv_stripe_md *lsm_md1,
......
......@@ -148,8 +148,8 @@ static int lmv_intent_remote(struct obd_export *exp, struct lookup_intent *it,
return rc;
}
int lmv_revalidate_slaves(struct obd_export *exp, struct mdt_body *mbody,
struct lmv_stripe_md *lsm,
int lmv_revalidate_slaves(struct obd_export *exp,
const struct lmv_stripe_md *lsm,
ldlm_blocking_callback cb_blocking,
int extra_lock_flags)
{
......@@ -158,11 +158,6 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct mdt_body *mbody,
struct ptlrpc_request *req = NULL;
struct mdt_body *body;
struct md_op_data *op_data;
unsigned long size = 0;
unsigned long nlink = 0;
__s64 atime = 0;
__s64 ctime = 0;
__s64 mtime = 0;
int rc = 0, i;
/**
......@@ -243,6 +238,7 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct mdt_body *mbody,
}
i_size_write(inode, body->mbo_size);
inode->i_blocks = body->mbo_blocks;
set_nlink(inode, body->mbo_nlink);
LTIME_S(inode->i_atime) = body->mbo_atime;
LTIME_S(inode->i_ctime) = body->mbo_ctime;
......@@ -251,41 +247,12 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct mdt_body *mbody,
md_set_lock_data(tgt->ltd_exp, lockh, inode, NULL);
if (i != 0)
nlink += inode->i_nlink - 2;
else
nlink += inode->i_nlink;
atime = LTIME_S(inode->i_atime) > atime ?
LTIME_S(inode->i_atime) : atime;
ctime = LTIME_S(inode->i_ctime) > ctime ?
LTIME_S(inode->i_ctime) : ctime;
mtime = LTIME_S(inode->i_mtime) > mtime ?
LTIME_S(inode->i_mtime) : mtime;
if (it.it_lock_mode && lockh) {
ldlm_lock_decref(lockh, it.it_lock_mode);
it.it_lock_mode = 0;
}
CDEBUG(D_INODE, "i %d "DFID" size %llu, nlink %u, atime %lu, mtime %lu, ctime %lu.\n",
i, PFID(&fid), i_size_read(inode), inode->i_nlink,
LTIME_S(inode->i_atime), LTIME_S(inode->i_mtime),
LTIME_S(inode->i_ctime));
}
/*
* update attr of master request.
*/
CDEBUG(D_INODE, "Return refreshed attrs: size = %lu nlink %lu atime %llu ctime %llu mtime %llu for " DFID"\n",
size, nlink, atime, ctime, mtime,
PFID(&lsm->lsm_md_oinfo[0].lmo_fid));
if (mbody) {
mbody->mbo_atime = atime;
mbody->mbo_ctime = ctime;
mbody->mbo_mtime = mtime;
}
cleanup:
if (req)
ptlrpc_req_finished(req);
......@@ -445,7 +412,7 @@ static int lmv_intent_lookup(struct obd_export *exp,
* during update_inode process (see ll_update_lsm_md)
*/
if (op_data->op_mea2) {
rc = lmv_revalidate_slaves(exp, NULL, op_data->op_mea2,
rc = lmv_revalidate_slaves(exp, op_data->op_mea2,
cb_blocking,
extra_lock_flags);
if (rc != 0)
......
......@@ -57,8 +57,8 @@ int lmv_fid_alloc(const struct lu_env *env, struct obd_export *exp,
int lmv_unpack_md(struct obd_export *exp, struct lmv_stripe_md **lsmp,
const union lmv_mds_md *lmm, int stripe_count);
int lmv_revalidate_slaves(struct obd_export *exp, struct mdt_body *mbody,
struct lmv_stripe_md *lsm,
int lmv_revalidate_slaves(struct obd_export *exp,
const struct lmv_stripe_md *lsm,
ldlm_blocking_callback cb_blocking,
int extra_lock_flags);
......
......@@ -3240,27 +3240,25 @@ static int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp,
return rc;
}
static int
lmv_update_lsm_md(struct obd_export *exp, struct lmv_stripe_md *lsm,
struct mdt_body *body, ldlm_blocking_callback cb_blocking)
static int lmv_merge_attr(struct obd_export *exp,
const struct lmv_stripe_md *lsm,
struct cl_attr *attr,
ldlm_blocking_callback cb_blocking)
{
return lmv_revalidate_slaves(exp, body, lsm, cb_blocking, 0);
}
int rc, i;
static int
lmv_merge_attr(struct obd_export *exp, const struct lmv_stripe_md *lsm,
struct cl_attr *attr)
{
int i;
rc = lmv_revalidate_slaves(exp, lsm, cb_blocking, 0);
if (rc < 0)
return rc;
for (i = 0; i < lsm->lsm_md_stripe_count; i++) {
struct inode *inode = lsm->lsm_md_oinfo[i].lmo_root;
CDEBUG(D_INFO, ""DFID" size %llu, nlink %u, atime %lu ctime %lu, mtime %lu.\n",
CDEBUG(D_INFO, ""DFID" size %llu, blocks %llu nlink %u, atime %lu ctime %lu, mtime %lu.\n",
PFID(&lsm->lsm_md_oinfo[i].lmo_fid),
i_size_read(inode), inode->i_nlink,
LTIME_S(inode->i_atime), LTIME_S(inode->i_ctime),
LTIME_S(inode->i_mtime));
i_size_read(inode), (unsigned long long)inode->i_blocks,
inode->i_nlink, LTIME_S(inode->i_atime),
LTIME_S(inode->i_ctime), LTIME_S(inode->i_mtime));
/* for slave stripe, it needs to subtract nlink for . and .. */
if (i)
......@@ -3269,6 +3267,7 @@ lmv_merge_attr(struct obd_export *exp, const struct lmv_stripe_md *lsm,
attr->cat_nlink = inode->i_nlink;
attr->cat_size += i_size_read(inode);
attr->cat_blocks += inode->i_blocks;
if (attr->cat_atime < LTIME_S(inode->i_atime))
attr->cat_atime = LTIME_S(inode->i_atime);
......@@ -3326,7 +3325,6 @@ static struct md_ops lmv_md_ops = {
.lock_match = lmv_lock_match,
.get_lustre_md = lmv_get_lustre_md,
.free_lustre_md = lmv_free_lustre_md,
.update_lsm_md = lmv_update_lsm_md,
.merge_attr = lmv_merge_attr,
.set_open_replay_data = lmv_set_open_replay_data,
.clear_open_replay_data = lmv_clear_open_replay_data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment