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: wang di <di.wang@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6088
Reviewed-on: http://review.whamcloud.com/13432
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 *,
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,
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;
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->nlink = inode->i_nlink;
+ stat->size = i_size_read(inode);
+ stat->blocks = inode->i_blocks;
return 0;
}
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 */
}
}
- /*
- * 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,
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)
{
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;
/**
}
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;
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);
* 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)
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);
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)
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);
.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,