Whamcloud - gitweb
- fixed direct access to obd->obd_namespace in llite. That should be delegated to...
authoryury <yury>
Tue, 25 Apr 2006 15:07:46 +0000 (15:07 +0000)
committeryury <yury>
Tue, 25 Apr 2006 15:07:46 +0000 (15:07 +0000)
12 files changed:
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/llite/dir.c
lustre/llite/llite_internal.h
lustre/llite/namei.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_internal.h
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_request.c
lustre/obdclass/lprocfs_status.c
lustre/osc/osc_request.c

index aedb75f..e56bb94 100644 (file)
@@ -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 *);
 
         /*
index da0e647..7cf6874 100644 (file)
@@ -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)
index 8c31a85..8c788ca 100644 (file)
@@ -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);
 
index c6efc05..b104888 100644 (file)
@@ -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,
index edec18f..f9af820 100644 (file)
@@ -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
index 9739b4d..d723c05 100644 (file)
@@ -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,
index bcf6c4a..b78c15f 100644 (file)
@@ -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;
 
index 938a654..852046c 100644 (file)
@@ -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
index 803e40a..a21d911 100644 (file)
@@ -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)
 {
index cbf222e..712268b 100644 (file)
@@ -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,
index 3e62e19..6efba72 100644 (file)
@@ -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);
index d30dfb6..5b1c9ff 100644 (file)
@@ -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,