Whamcloud - gitweb
LU-5823 clio: add cl_object_find_cbdata()
[fs/lustre-release.git] / lustre / osc / osc_object.c
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;
 }
+/**
+ * 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)
 {
@@ -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_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 = {