From: yury Date: Tue, 25 Apr 2006 15:07:46 +0000 (+0000) Subject: - fixed direct access to obd->obd_namespace in llite. That should be delegated to... X-Git-Tag: v1_8_0_110~486^2~1931 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=d81c23af604ea668bb21e8bfd94aa9b4b72af3b7;p=fs%2Flustre-release.git - fixed direct access to obd->obd_namespace in llite. That should be delegated to md_ methods as there is LMV obd which has no namespace. --- diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index aedb75f..e56bb94 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -980,7 +980,13 @@ struct md_ops { 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 *); /* diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index da0e647..7cf6874 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -1079,8 +1079,8 @@ static inline int obd_cancel(struct obd_export *exp, } 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; @@ -1566,6 +1566,32 @@ static inline int md_set_lock_data(struct obd_export *exp, 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) diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 8c31a85..8c788ca 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -202,21 +202,18 @@ fail: 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); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index c6efc05..b104888 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -343,8 +343,6 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir); 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, diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index edec18f..f9af820 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -155,18 +155,6 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, 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 diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 9739b4d..d723c05 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -874,12 +874,10 @@ static int lmv_change_cbdata(struct obd_export *exp, 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); @@ -2193,22 +2191,22 @@ int lmv_brw(int rw, struct obd_export *exp, struct obdo *oa, #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; } @@ -2224,6 +2222,32 @@ int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data) 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) { @@ -2284,7 +2308,6 @@ struct obd_ops lmv_obd_ops = { .o_unpackmd = lmv_unpackmd, .o_notify = lmv_notify, .o_iocontrol = lmv_iocontrol, - .o_cancel_unused = lmv_cancel_unused, }; struct md_ops lmv_md_ops = { @@ -2305,7 +2328,9 @@ 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, diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index bcf6c4a..b78c15f 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1862,10 +1862,11 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, } 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; diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h index 938a654..852046c 100644 --- a/lustre/mdc/mdc_internal.h +++ b/lustre/mdc/mdc_internal.h @@ -192,6 +192,14 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, 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 diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index 803e40a..a21d911 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -142,6 +142,39 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data) 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) { diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index cbf222e..712268b 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1244,8 +1244,10 @@ struct md_ops mdc_md_ops = { .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, diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 3e62e1908..6efba72 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -788,6 +788,8 @@ int lprocfs_alloc_md_stats(struct obd_device *obd, 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); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index d30dfb6..5b1c9ff 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2819,13 +2819,14 @@ static int osc_cancel(struct obd_export *exp, struct lov_stripe_md *md, } 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,