Whamcloud - gitweb
LU-5823 clio: add cl_object_find_cbdata() 94/12494/13
authorBobi Jam <bobijam.xu@intel.com>
Thu, 30 Oct 2014 07:00:22 +0000 (15:00 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 27 Jan 2015 20:03:10 +0000 (20:03 +0000)
* Delete obsolete obd_ops::o_find_cbdata interface.
* Delete obsolete obd_ops::o_change_cbdata interface.
* Add cl_object_find_cbdata().

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: I2e64e2e9a112783cb5c66bf4580fd1aec794417b
Reviewed-on: http://review.whamcloud.com/12494
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/cl_object.h
lustre/include/obd.h
lustre/include/obd_class.h
lustre/llite/dcache.c
lustre/lov/lov_obd.c
lustre/lov/lov_object.c
lustre/obdclass/cl_object.c
lustre/obdclass/lprocfs_status_server.c
lustre/osc/osc_object.c
lustre/osc/osc_request.c

index 7a8da87..028b4a2 100644 (file)
 #include <linux/radix-tree.h>
 #include <linux/spinlock.h>
 #include <linux/wait.h>
 #include <linux/radix-tree.h>
 #include <linux/spinlock.h>
 #include <linux/wait.h>
+#include <lustre_dlm.h>
 
 struct inode;
 
 
 struct inode;
 
@@ -402,6 +403,12 @@ struct cl_object_operations {
         */
        int (*coo_getstripe)(const struct lu_env *env, struct cl_object *obj,
                             struct lov_user_md __user *lum);
         */
        int (*coo_getstripe)(const struct lu_env *env, struct cl_object *obj,
                             struct lov_user_md __user *lum);
+       /**
+        * Find whether there is any callback data (ldlm lock) attached upon
+        * the object.
+        */
+       int (*coo_find_cbdata)(const struct lu_env *env, struct cl_object *obj,
+                              ldlm_iterator_t iter, void *data);
 };
 
 /**
 };
 
 /**
@@ -2177,8 +2184,10 @@ int  cl_conf_set          (const struct lu_env *env, struct cl_object *obj,
                            const struct cl_object_conf *conf);
 int  cl_object_prune      (const struct lu_env *env, struct cl_object *obj);
 void cl_object_kill       (const struct lu_env *env, struct cl_object *obj);
                            const struct cl_object_conf *conf);
 int  cl_object_prune      (const struct lu_env *env, struct cl_object *obj);
 void cl_object_kill       (const struct lu_env *env, struct cl_object *obj);
-int  cl_object_getstripe(const struct lu_env *env, struct cl_object *obj,
-                        struct lov_user_md __user *lum);
+int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj,
+                       struct lov_user_md __user *lum);
+int cl_object_find_cbdata(const struct lu_env *env, struct cl_object *obj,
+                         ldlm_iterator_t iter, void *data);
 
 /**
  * Returns true, iff \a o0 and \a o1 are slices of the same object.
 
 /**
  * Returns true, iff \a o0 and \a o1 are slices of the same object.
index 9ec325a..3b660e9 100644 (file)
@@ -938,10 +938,6 @@ struct obd_ops {
                           struct niobuf_remote *remote, int pages,
                           struct niobuf_local *local,
                           struct obd_trans_info *oti, int rc);
                           struct niobuf_remote *remote, int pages,
                           struct niobuf_local *local,
                           struct obd_trans_info *oti, int rc);
-        int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
-                               ldlm_iterator_t it, void *data);
-        int (*o_find_cbdata)(struct obd_export *, struct lov_stripe_md *,
-                             ldlm_iterator_t it, void *data);
         int (*o_init_export)(struct obd_export *exp);
         int (*o_destroy_export)(struct obd_export *exp);
 
         int (*o_init_export)(struct obd_export *exp);
         int (*o_destroy_export)(struct obd_export *exp);
 
index dc9bb2d..cc4ab8d 100644 (file)
@@ -1269,34 +1269,6 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static inline int obd_change_cbdata(struct obd_export *exp,
-                                    struct lov_stripe_md *lsm,
-                                    ldlm_iterator_t it, void *data)
-{
-        int rc;
-        ENTRY;
-
-        EXP_CHECK_DT_OP(exp, change_cbdata);
-        EXP_COUNTER_INCREMENT(exp, change_cbdata);
-
-        rc = OBP(exp->exp_obd, change_cbdata)(exp, lsm, it, data);
-        RETURN(rc);
-}
-
-static inline int obd_find_cbdata(struct obd_export *exp,
-                                  struct lov_stripe_md *lsm,
-                                  ldlm_iterator_t it, void *data)
-{
-        int rc;
-        ENTRY;
-
-        EXP_CHECK_DT_OP(exp, find_cbdata);
-        EXP_COUNTER_INCREMENT(exp, find_cbdata);
-
-        rc = OBP(exp->exp_obd, find_cbdata)(exp, lsm, it, data);
-        RETURN(rc);
-}
-
 static inline void obd_import_event(struct obd_device *obd,
                                     struct obd_import *imp,
                                     enum obd_import_event event)
 static inline void obd_import_event(struct obd_device *obd,
                                     struct obd_import *imp,
                                     enum obd_import_event event)
index 1ad9659..074bc34 100644 (file)
@@ -137,23 +137,27 @@ static inline int return_if_equal(struct ldlm_lock *lock, void *data)
  *      < 0    error */
 static int find_cbdata(struct inode *inode)
 {
  *      < 0    error */
 static int find_cbdata(struct inode *inode)
 {
-       struct ll_sb_info *sbi = ll_i2sbi(inode);
-       struct lov_stripe_md *lsm;
-        int rc = 0;
-        ENTRY;
+       struct lu_env                   *env;
+       int                             refcheck;
+       struct ll_sb_info               *sbi = ll_i2sbi(inode);
+       int                             rc = 0;
+       ENTRY;
 
 
-        LASSERT(inode);
-        rc = md_find_cbdata(sbi->ll_md_exp, ll_inode2fid(inode),
-                            return_if_equal, NULL);
+       LASSERT(inode);
+       rc = md_find_cbdata(sbi->ll_md_exp, ll_inode2fid(inode),
+                           return_if_equal, NULL);
        if (rc != 0)
                RETURN(rc);
 
        if (rc != 0)
                RETURN(rc);
 
-       lsm = ccc_inode_lsm_get(inode);
-       if (lsm == NULL)
-               RETURN(rc);
+       if (ll_i2info(inode)->lli_clob != NULL) {
+               env = cl_env_get(&refcheck);
+               if (IS_ERR(env))
+                       RETURN(PTR_ERR(env));
 
 
-       rc = obd_find_cbdata(sbi->ll_dt_exp, lsm, return_if_equal, NULL);
-       ccc_inode_lsm_put(inode, lsm);
+               rc = cl_object_find_cbdata(env, ll_i2info(inode)->lli_clob,
+                                          return_if_equal, NULL);
+               cl_env_put(env, &refcheck);
+       }
 
        RETURN(rc);
 }
 
        RETURN(rc);
 }
index 1161be3..3f8bbb6 100644 (file)
@@ -1181,80 +1181,6 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
        RETURN(0);
 }
 
        RETURN(0);
 }
 
-static int lov_change_cbdata(struct obd_export *exp,
-                             struct lov_stripe_md *lsm, ldlm_iterator_t it,
-                             void *data)
-{
-        struct lov_obd *lov;
-        int rc = 0, i;
-        ENTRY;
-
-        ASSERT_LSM_MAGIC(lsm);
-
-        if (!exp || !exp->exp_obd)
-                RETURN(-ENODEV);
-
-        lov = &exp->exp_obd->u.lov;
-        for (i = 0; i < lsm->lsm_stripe_count; i++) {
-                struct lov_stripe_md submd;
-                struct lov_oinfo *loi = lsm->lsm_oinfo[i];
-
-               if (lov_oinfo_is_dummy(loi))
-                       continue;
-
-               if (!lov->lov_tgts[loi->loi_ost_idx]) {
-                       CDEBUG(D_HA, "lov idx %d NULL\n", loi->loi_ost_idx);
-                       continue;
-               }
-
-               submd.lsm_oi = loi->loi_oi;
-               submd.lsm_stripe_count = 0;
-               rc = obd_change_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp,
-                                      &submd, it, data);
-       }
-       RETURN(rc);
-}
-
-/* find any ldlm lock of the inode in lov
- * return 0    not find
- *        1    find one
- *      < 0    error */
-static int lov_find_cbdata(struct obd_export *exp,
-                           struct lov_stripe_md *lsm, ldlm_iterator_t it,
-                           void *data)
-{
-        struct lov_obd *lov;
-        int rc = 0, i;
-        ENTRY;
-
-        ASSERT_LSM_MAGIC(lsm);
-
-        if (!exp || !exp->exp_obd)
-                RETURN(-ENODEV);
-
-        lov = &exp->exp_obd->u.lov;
-        for (i = 0; i < lsm->lsm_stripe_count; i++) {
-                struct lov_stripe_md submd;
-                struct lov_oinfo *loi = lsm->lsm_oinfo[i];
-
-               if (lov_oinfo_is_dummy(loi))
-                       continue;
-
-               if (!lov->lov_tgts[loi->loi_ost_idx]) {
-                       CDEBUG(D_HA, "lov idx %d NULL\n", loi->loi_ost_idx);
-                       continue;
-               }
-
-               submd.lsm_oi = loi->loi_oi;
-               submd.lsm_stripe_count = 0;
-               rc = obd_find_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp,
-                                    &submd, it, data);
-               if (rc != 0)
-                       RETURN(rc);
-       }
-       RETURN(rc);
-}
-
 int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc)
 {
        struct lov_request_set *lovset = (struct lov_request_set *)data;
 int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc)
 {
        struct lov_request_set *lovset = (struct lov_request_set *)data;
@@ -2147,8 +2073,6 @@ static struct obd_ops lov_obd_ops = {
        .o_unpackmd             = lov_unpackmd,
        .o_getattr_async        = lov_getattr_async,
        .o_setattr_async        = lov_setattr_async,
        .o_unpackmd             = lov_unpackmd,
        .o_getattr_async        = lov_getattr_async,
        .o_setattr_async        = lov_setattr_async,
-       .o_change_cbdata        = lov_change_cbdata,
-       .o_find_cbdata          = lov_find_cbdata,
        .o_iocontrol            = lov_iocontrol,
        .o_get_info             = lov_get_info,
        .o_set_info_async       = lov_set_info_async,
        .o_iocontrol            = lov_iocontrol,
        .o_get_info             = lov_get_info,
        .o_set_info_async       = lov_set_info_async,
index aff9328..7d66e66 100644 (file)
@@ -75,6 +75,8 @@ struct lov_layout_operations {
                             struct cl_object *obj, struct cl_io *io);
         int  (*llo_getattr)(const struct lu_env *env, struct cl_object *obj,
                             struct cl_attr *attr);
                             struct cl_object *obj, struct cl_io *io);
         int  (*llo_getattr)(const struct lu_env *env, struct cl_object *obj,
                             struct cl_attr *attr);
+       int  (*llo_find_cbdata)(const struct lu_env *env, struct cl_object *obj,
+                               ldlm_iterator_t iter, void *data);
 };
 
 static int lov_layout_wait(const struct lu_env *env, struct lov_object *lov);
 };
 
 static int lov_layout_wait(const struct lu_env *env, struct lov_object *lov);
@@ -575,6 +577,37 @@ static int lov_attr_get_raid0(const struct lu_env *env, struct cl_object *obj,
        RETURN(result);
 }
 
        RETURN(result);
 }
 
+static int lov_find_cbdata_empty(const struct lu_env *env,
+                                struct cl_object *obj, ldlm_iterator_t iter,
+                                void *data)
+{
+       return 0;
+}
+
+static int lov_find_cbdata_raid0(const struct lu_env *env,
+                                struct cl_object *obj, ldlm_iterator_t iter,
+                                void *data)
+{
+       struct lov_object       *lov = cl2lov(obj);
+       struct lov_layout_raid0 *r0 = lov_r0(lov);
+       struct cl_object        *subobj;
+       int                     i;
+       int                     rc = 0;
+
+       for (i = 0; i < r0->lo_nr; ++i) {
+               if (r0->lo_sub[i] == NULL)
+                       continue;
+
+               subobj = lovsub2cl(r0->lo_sub[i]);
+
+               rc = cl_object_find_cbdata(env, subobj, iter, data);
+               if (rc != 0)
+                       break;
+       }
+
+       return rc;
+}
+
 const static struct lov_layout_operations lov_dispatch[] = {
         [LLT_EMPTY] = {
                 .llo_init      = lov_init_empty,
 const static struct lov_layout_operations lov_dispatch[] = {
         [LLT_EMPTY] = {
                 .llo_init      = lov_init_empty,
@@ -585,7 +618,8 @@ const static struct lov_layout_operations lov_dispatch[] = {
                 .llo_page_init = lov_page_init_empty,
                 .llo_lock_init = lov_lock_init_empty,
                 .llo_io_init   = lov_io_init_empty,
                 .llo_page_init = lov_page_init_empty,
                 .llo_lock_init = lov_lock_init_empty,
                 .llo_io_init   = lov_io_init_empty,
-                .llo_getattr   = lov_attr_get_empty
+               .llo_getattr   = lov_attr_get_empty,
+               .llo_find_cbdata = lov_find_cbdata_empty
         },
         [LLT_RAID0] = {
                 .llo_init      = lov_init_raid0,
         },
         [LLT_RAID0] = {
                 .llo_init      = lov_init_raid0,
@@ -596,7 +630,8 @@ const static struct lov_layout_operations lov_dispatch[] = {
                 .llo_page_init = lov_page_init_raid0,
                 .llo_lock_init = lov_lock_init_raid0,
                 .llo_io_init   = lov_io_init_raid0,
                 .llo_page_init = lov_page_init_raid0,
                 .llo_lock_init = lov_lock_init_raid0,
                 .llo_io_init   = lov_io_init_raid0,
-                .llo_getattr   = lov_attr_get_raid0
+               .llo_getattr   = lov_attr_get_raid0,
+               .llo_find_cbdata = lov_find_cbdata_raid0
        },
         [LLT_RELEASED] = {
                 .llo_init      = lov_init_released,
        },
         [LLT_RELEASED] = {
                 .llo_init      = lov_init_released,
@@ -607,7 +642,8 @@ const static struct lov_layout_operations lov_dispatch[] = {
                 .llo_page_init = lov_page_init_empty,
                 .llo_lock_init = lov_lock_init_empty,
                 .llo_io_init   = lov_io_init_released,
                 .llo_page_init = lov_page_init_empty,
                 .llo_lock_init = lov_lock_init_empty,
                 .llo_io_init   = lov_io_init_released,
-                .llo_getattr   = lov_attr_get_empty
+               .llo_getattr   = lov_attr_get_empty,
+               .llo_find_cbdata = lov_find_cbdata_empty
         }
 };
 
         }
 };
 
@@ -956,6 +992,19 @@ static int lov_object_getstripe(const struct lu_env *env, struct cl_object *obj,
        RETURN(rc);
 }
 
        RETURN(rc);
 }
 
+static int lov_object_find_cbdata(const struct lu_env *env,
+                                 struct cl_object *obj, ldlm_iterator_t iter,
+                                 void *data)
+{
+       int rc;
+       ENTRY;
+
+       /* call cl_object_find_cbdata for sub obj */
+       rc = LOV_2DISPATCH_NOLOCK(cl2lov(obj), llo_find_cbdata,
+                                 env, obj, iter, data);
+       RETURN(rc);
+}
+
 static const struct cl_object_operations lov_ops = {
        .coo_page_init    = lov_page_init,
        .coo_lock_init    = lov_lock_init,
 static const struct cl_object_operations lov_ops = {
        .coo_page_init    = lov_page_init,
        .coo_lock_init    = lov_lock_init,
@@ -963,7 +1012,8 @@ static const struct cl_object_operations lov_ops = {
        .coo_attr_get     = lov_attr_get,
        .coo_attr_update  = lov_attr_update,
        .coo_conf_set     = lov_conf_set,
        .coo_attr_get     = lov_attr_get,
        .coo_attr_update  = lov_attr_update,
        .coo_conf_set     = lov_conf_set,
-       .coo_getstripe    = lov_object_getstripe
+       .coo_getstripe    = lov_object_getstripe,
+       .coo_find_cbdata  = lov_object_find_cbdata
 };
 
 static const struct lu_object_operations lov_lu_obj_ops = {
 };
 
 static const struct lu_object_operations lov_lu_obj_ops = {
index e400f30..eb23c9b 100644 (file)
@@ -363,6 +363,30 @@ int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj,
 EXPORT_SYMBOL(cl_object_getstripe);
 
 /**
 EXPORT_SYMBOL(cl_object_getstripe);
 
 /**
+ * Find whether there is any callback data (ldlm lock) attached upon this
+ * object.
+ */
+int cl_object_find_cbdata(const struct lu_env *env, struct cl_object *obj,
+                          ldlm_iterator_t iter, void *data)
+{
+       struct lu_object_header *top;
+       int                     result = 0;
+       ENTRY;
+
+       top = obj->co_lu.lo_header;
+       list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) {
+               if (obj->co_ops->coo_find_cbdata != NULL) {
+                       result = obj->co_ops->coo_find_cbdata(env, obj, iter,
+                                                             data);
+                       if (result != 0)
+                               break;
+               }
+       }
+       RETURN(result);
+}
+EXPORT_SYMBOL(cl_object_find_cbdata);
+
+/**
  * Helper function removing all object locks, and marking object for
  * deletion. All object pages must have been deleted at this point.
  *
  * Helper function removing all object locks, and marking object for
  * deletion. All object pages must have been deleted at this point.
  *
index 00298d4..4939e1b 100644 (file)
@@ -456,8 +456,6 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, getattr_async);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, preprw);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, commitrw);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, getattr_async);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, preprw);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, commitrw);
-       LPROCFS_OBD_OP_INIT(num_private_stats, stats, change_cbdata);
-       LPROCFS_OBD_OP_INIT(num_private_stats, stats, find_cbdata);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, init_export);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy_export);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, init_export);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy_export);
        LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event);
index 728b758..c03582a 100644 (file)
@@ -230,6 +230,31 @@ static int osc_object_prune(const struct lu_env *env, struct cl_object *obj)
                              osc_object_ast_clear, osc);
        return 0;
 }
                              osc_object_ast_clear, osc);
        return 0;
 }
+/**
+ * Find any ldlm lock covers the osc object.
+ * \retval 0   not found
+ * \retval 1   find one
+ * \retval < 0 error
+ */
+static int osc_object_find_cbdata(const struct lu_env *env,
+                                 struct cl_object *obj, ldlm_iterator_t iter,
+                                 void *data)
+{
+       struct ldlm_res_id              res_id;
+       struct obd_device               *obd;
+       int                             rc = 0;
+
+       ostid_build_res_name(&cl2osc(obj)->oo_oinfo->loi_oi, &res_id);
+       obd = obj->co_lu.lo_dev->ld_obd;
+       rc = ldlm_resource_iterate(obd->obd_namespace, &res_id, iter, data);
+       if (rc == LDLM_ITER_STOP)
+               return 1;
+
+       if (rc == LDLM_ITER_CONTINUE)
+               return 0;
+
+       return rc;
+}
 
 void osc_object_set_contended(struct osc_object *obj)
 {
 
 void osc_object_set_contended(struct osc_object *obj)
 {
@@ -276,7 +301,8 @@ static const struct cl_object_operations osc_ops = {
        .coo_attr_get     = osc_attr_get,
        .coo_attr_update  = osc_attr_update,
        .coo_glimpse      = osc_object_glimpse,
        .coo_attr_get     = osc_attr_get,
        .coo_attr_update  = osc_attr_update,
        .coo_glimpse      = osc_object_glimpse,
-       .coo_prune        = osc_object_prune
+       .coo_prune        = osc_object_prune,
+       .coo_find_cbdata  = osc_object_find_cbdata
 };
 
 static const struct lu_object_operations osc_lu_obj_ops = {
 };
 
 static const struct lu_object_operations osc_lu_obj_ops = {
index a0d19d5..75d1290 100644 (file)
@@ -2026,37 +2026,6 @@ static int osc_set_data_with_check(struct lustre_handle *lockh,
         return set;
 }
 
         return set;
 }
 
-static int osc_change_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm,
-                             ldlm_iterator_t replace, void *data)
-{
-        struct ldlm_res_id res_id;
-        struct obd_device *obd = class_exp2obd(exp);
-
-       ostid_build_res_name(&lsm->lsm_oi, &res_id);
-        ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data);
-        return 0;
-}
-
-/* find any ldlm lock of the inode in osc
- * return 0    not find
- *        1    find one
- *      < 0    error */
-static int osc_find_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm,
-                           ldlm_iterator_t replace, void *data)
-{
-        struct ldlm_res_id res_id;
-        struct obd_device *obd = class_exp2obd(exp);
-        int rc = 0;
-
-       ostid_build_res_name(&lsm->lsm_oi, &res_id);
-        rc = ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data);
-        if (rc == LDLM_ITER_STOP)
-                return(1);
-        if (rc == LDLM_ITER_CONTINUE)
-                return(0);
-        return(rc);
-}
-
 static int osc_enqueue_fini(struct ptlrpc_request *req,
                            osc_enqueue_upcall_f upcall, void *cookie,
                            struct lustre_handle *lockh, ldlm_mode_t mode,
 static int osc_enqueue_fini(struct ptlrpc_request *req,
                            osc_enqueue_upcall_f upcall, void *cookie,
                            struct lustre_handle *lockh, ldlm_mode_t mode,
@@ -3105,8 +3074,6 @@ static struct obd_ops osc_obd_ops = {
         .o_getattr_async        = osc_getattr_async,
         .o_setattr              = osc_setattr,
         .o_setattr_async        = osc_setattr_async,
         .o_getattr_async        = osc_getattr_async,
         .o_setattr              = osc_setattr,
         .o_setattr_async        = osc_setattr_async,
-        .o_change_cbdata        = osc_change_cbdata,
-        .o_find_cbdata          = osc_find_cbdata,
         .o_iocontrol            = osc_iocontrol,
         .o_get_info             = osc_get_info,
         .o_set_info_async       = osc_set_info_async,
         .o_iocontrol            = osc_iocontrol,
         .o_get_info             = osc_get_info,
         .o_set_info_async       = osc_set_info_async,