int (*m_clear_open_replay_data)(struct obd_export *,
struct obd_client_handle *);
int (*m_set_lock_data)(struct obd_export *, __u64 *, void *);
-
+
+ int (*m_lock_match)(struct obd_export *, int, struct lu_fid *,
+ ldlm_type_t, ldlm_policy_data_t *, ldlm_mode_t,
+ struct lustre_handle *);
+
+ int (*m_cancel_unused)(struct obd_export *, struct lu_fid *,
+ int flags, void *opaque);
int (*m_delete)(struct obd_export *, struct lu_fid *);
/*
}
static inline int obd_cancel_unused(struct obd_export *exp,
- struct lov_stripe_md *ea, int flags,
- void *opaque)
+ struct lov_stripe_md *ea,
+ int flags, void *opaque)
{
int rc;
ENTRY;
RETURN(MDP(exp->exp_obd, set_lock_data)(exp, lockh, data));
}
+static inline int md_cancel_unused(struct obd_export *exp,
+ struct lu_fid *fid,
+ int flags, void *opaque)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_MD_OP(exp, cancel_unused);
+ MD_COUNTER_INCREMENT(exp->exp_obd, cancel_unused);
+
+ rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, flags, opaque);
+ RETURN(rc);
+}
+
+static inline int md_lock_match(struct obd_export *exp, int flags,
+ struct lu_fid *fid, ldlm_type_t type,
+ ldlm_policy_data_t *policy, ldlm_mode_t mode,
+ struct lustre_handle *lockh)
+{
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, lock_match);
+ MD_COUNTER_INCREMENT(exp->exp_obd, lock_match);
+ RETURN(MDP(exp->exp_obd, lock_match)(exp, flags, fid, type,
+ policy, mode, lockh));
+}
+
static inline int md_init_ea_size(struct obd_export *exp,
int easize, int def_asize,
int cookiesize)
static struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
{
- struct ldlm_res_id res_id =
- { .name = { fid_seq(ll_inode2fid(dir)), fid_num(ll_inode2fid(dir)) } };
- struct lustre_handle lockh;
- struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_md_exp);
+ ldlm_policy_data_t policy = {.l_inodebits = {MDS_INODELOCK_UPDATE} };
struct address_space *mapping = dir->i_mapping;
+ struct lustre_handle lockh;
struct page *page;
- ldlm_policy_data_t policy = {.l_inodebits = {MDS_INODELOCK_UPDATE} };
int rc;
- rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED,
- &res_id, LDLM_IBITS, &policy, LCK_CR, &lockh);
+ rc = md_lock_match(ll_i2sbi(dir)->ll_md_exp, LDLM_FL_BLOCK_GRANTED,
+ ll_inode2fid(dir), LDLM_IBITS, &policy, LCK_CR, &lockh);
if (!rc) {
struct lookup_intent it = { .it_op = IT_READDIR };
- struct ptlrpc_request *request;
struct md_op_data op_data = { { 0 } };
+ struct ptlrpc_request *request;
ll_prepare_md_op_data(&op_data, dir, NULL, NULL, 0, 0);
struct inode *ll_iget(struct super_block *sb, ino_t hash,
struct lustre_md *lic);
struct dentry *ll_find_alias(struct inode *, struct dentry *);
-int ll_mdc_cancel_unused(struct lustre_handle *, struct inode *, int flags,
- void *opaque);
int ll_mdc_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
void *data, int flag);
void ll_prepare_md_op_data(struct md_op_data *op_data, struct inode *i1,
RETURN(0);
}
-int ll_mdc_cancel_unused(struct lustre_handle *conn, struct inode *inode,
- int flags, void *opaque)
-{
- struct ldlm_res_id res_id =
- { .name = {fid_seq(ll_inode2fid(inode)), fid_num(ll_inode2fid(inode))} };
- struct obd_device *obddev = class_conn2obd(conn);
- ENTRY;
-
- RETURN(ldlm_cli_cancel_unused(obddev->obd_namespace, &res_id, flags,
- opaque));
-}
-
/* Pack the required supplementary groups into the supplied groups array.
* If we don't need to use the groups from the target inode(s) then we
* instead pack one or more groups from the user's supplementary group
RETURN(rc);
CDEBUG(D_OTHER, "CBDATA for "DFID3"\n", PFID3(fid));
- i = lmv_fld_lookup(obd, fid);
- LASSERT(i < lmv->desc.ld_tgt_count);
- /* with CMD every object can have two locks in different
- * namespaces: lookup lock in space of mds storing direntry
- * and update/open lock in space of mds storing inode */
+ /* with CMD every object can have two locks in different namespaces:
+ * lookup lock in space of mds storing direntry and update/open lock in
+ * space of mds storing inode */
for (i = 0; i < lmv->desc.ld_tgt_count; i++)
md_change_cbdata(lmv->tgts[i].ltd_exp, fid, it, data);
#endif
static int lmv_cancel_unused(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- int flags, void *opaque)
+ struct lu_fid *fid,
+ int flags, void *opaque)
{
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
int rc = 0, err, i;
ENTRY;
- LASSERT(lsm == NULL);
+ LASSERT(fid != NULL);
for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
if (!lmv->tgts[i].ltd_exp || !lmv->tgts[i].active)
continue;
- err = obd_cancel_unused(lmv->tgts[i].ltd_exp,
- NULL, flags, opaque);
+ err = md_cancel_unused(lmv->tgts[i].ltd_exp,
+ fid, flags, opaque);
if (!rc)
rc = err;
}
RETURN(md_set_lock_data(lmv->tgts[0].ltd_exp, lockh, data));
}
+int lmv_lock_match(struct obd_export *exp, int flags,
+ struct lu_fid *fid, ldlm_type_t type,
+ ldlm_policy_data_t *policy, ldlm_mode_t mode,
+ struct lustre_handle *lockh)
+{
+ struct obd_device *obd = exp->exp_obd;
+ struct lmv_obd *lmv = &obd->u.lmv;
+ int i, rc = 0;
+ ENTRY;
+
+ CDEBUG(D_OTHER, "lock match for "DFID3"\n", PFID3(fid));
+
+ /* with CMD every object can have two locks in different namespaces:
+ * lookup lock in space of mds storing direntry and update/open lock in
+ * space of mds storing inode. Thus we check all targets, not only that
+ * one fid was created in. */
+ for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
+ rc = md_lock_match(lmv->tgts[i].ltd_exp, flags, fid,
+ type, policy, mode, lockh);
+ if (rc)
+ RETURN(1);
+ }
+
+ RETURN(rc);
+}
+
int lmv_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
int offset, struct obd_export *dt_exp, struct lustre_md *md)
{
.o_unpackmd = lmv_unpackmd,
.o_notify = lmv_notify,
.o_iocontrol = lmv_iocontrol,
- .o_cancel_unused = lmv_cancel_unused,
};
struct md_ops lmv_md_ops = {
.m_unlink = lmv_unlink,
.m_init_ea_size = lmv_init_ea_size,
.m_delete = lmv_delete,
+ .m_cancel_unused = lmv_cancel_unused,
.m_set_lock_data = lmv_set_lock_data,
+ .m_lock_match = lmv_lock_match,
.m_get_lustre_md = lmv_get_lustre_md,
.m_free_lustre_md = lmv_free_lustre_md,
.m_set_open_replay_data = lmv_set_open_replay_data,
}
static int lov_cancel_unused(struct obd_export *exp,
- struct lov_stripe_md *lsm, int flags, void *opaque)
+ struct lov_stripe_md *lsm,
+ int flags, void *opaque)
{
- struct lov_obd *lov;
struct lov_oinfo *loi;
+ struct lov_obd *lov;
int rc = 0, i;
ENTRY;
int mdc_sync(struct obd_export *exp, struct lu_fid *fid,
struct ptlrpc_request **);
+int mdc_lock_match(struct obd_export *exp, int flags,
+ struct lu_fid *fid, ldlm_type_t type,
+ ldlm_policy_data_t *policy, ldlm_mode_t mode,
+ struct lustre_handle *lockh);
+
+int mdc_cancel_unused(struct obd_export *exp, struct lu_fid *fid,
+ int flags, void *opaque);
+
int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data);
#endif
RETURN(0);
}
+int mdc_lock_match(struct obd_export *exp, int flags,
+ struct lu_fid *fid, ldlm_type_t type,
+ ldlm_policy_data_t *policy, ldlm_mode_t mode,
+ struct lustre_handle *lockh)
+{
+ struct ldlm_res_id res_id =
+ { .name = {fid_seq(fid), fid_num(fid)} };
+ struct obd_device *obd = class_exp2obd(exp);
+ int rc;
+ ENTRY;
+
+ rc = ldlm_lock_match(obd->obd_namespace, flags,
+ &res_id, type, policy, mode, lockh);
+
+ RETURN(rc);
+}
+
+int mdc_cancel_unused(struct obd_export *exp,
+ struct lu_fid *fid,
+ int flags, void *opaque)
+{
+ struct ldlm_res_id res_id =
+ { .name = {fid_seq(fid), fid_num(fid)} };
+ struct obd_device *obd = class_exp2obd(exp);
+ int rc;
+
+ ENTRY;
+
+ rc = ldlm_cli_cancel_unused(obd->obd_namespace, &res_id,
+ flags, opaque);
+ RETURN(rc);
+}
+
int mdc_change_cbdata(struct obd_export *exp, struct lu_fid *fid,
ldlm_iterator_t it, void *data)
{
.m_sync = mdc_sync,
.m_readpage = mdc_readpage,
.m_unlink = mdc_unlink,
+ .m_cancel_unused = mdc_cancel_unused,
.m_init_ea_size = mdc_init_ea_size,
.m_set_lock_data = mdc_set_lock_data,
+ .m_lock_match = mdc_lock_match,
.m_get_lustre_md = mdc_get_lustre_md,
.m_free_lustre_md = mdc_free_lustre_md,
.m_set_open_replay_data = mdc_set_open_replay_data,
LPROCFS_MD_OP_INIT(num_private_stats, stats, getattr);
LPROCFS_MD_OP_INIT(num_private_stats, stats, getattr_name);
LPROCFS_MD_OP_INIT(num_private_stats, stats, intent_lock);
+ LPROCFS_MD_OP_INIT(num_private_stats, stats, lock_match);
+ LPROCFS_MD_OP_INIT(num_private_stats, stats, cancel_unused);
LPROCFS_MD_OP_INIT(num_private_stats, stats, link);
LPROCFS_MD_OP_INIT(num_private_stats, stats, rename);
LPROCFS_MD_OP_INIT(num_private_stats, stats, setattr);
}
static int osc_cancel_unused(struct obd_export *exp,
- struct lov_stripe_md *lsm, int flags, void *opaque)
+ struct lov_stripe_md *lsm,
+ int flags, void *opaque)
{
- struct obd_device *obd = class_exp2obd(exp);
struct ldlm_res_id res_id = { .name = {lsm->lsm_object_id} };
+ struct obd_device *obd = class_exp2obd(exp);
- return ldlm_cli_cancel_unused(obd->obd_namespace, &res_id, flags,
- opaque);
+ return ldlm_cli_cancel_unused(obd->obd_namespace, &res_id,
+ flags, opaque);
}
static int osc_join_lru(struct obd_export *exp,