struct cmm_object {
struct md_object cmo_obj;
- int cmo_local;
};
/* local CMM object */
return (o ? lu2md(lu_object_next(&o->cmo_obj.mo_lu)) : NULL);
}
-static inline int cmm_is_local_obj(struct cmm_object *c)
-{
- return (c->cmo_local);
-}
-
-
/* cmm_object.c */
struct lu_object *cmm_object_alloc(const struct lu_context *ctx,
const struct lu_object_header *hdr,
lu_object_init(lo, NULL, ld);
clo->cmm_obj.cmo_obj.mo_ops = &cml_mo_ops;
clo->cmm_obj.cmo_obj.mo_dir_ops = &cml_dir_ops;
- lo->lo_ops = &cml_obj_ops;
- clo->cmm_obj.cmo_local = 1;
+ lo->lo_ops = &cml_obj_ops;
}
} else {
struct cmr_object *cro;
cro->cmm_obj.cmo_obj.mo_dir_ops = &cmr_dir_ops;
lo->lo_ops = &cmr_obj_ops;
cro->cmo_num = mdsnum;
- cro->cmm_obj.cmo_local = 0;
}
}
RETURN(lo);
}
static int cml_object_exists(const struct lu_context *ctx,
- struct lu_object *lo)
+ const struct lu_object *lo)
{
return lu_object_exists(ctx, lu_object_next(lo));
}
int rc;
ENTRY;
- if (mo_t && !cmm_is_local_obj(md2cmm_obj(mo_t))) {
+ if (mo_t && lu_object_exists(ctx, &mo_t->mo_lu) < 0) {
/* mo_t is remote object and there is RPC to unlink it */
rc = mo_ref_del(ctx, md_object_next(mo_t));
if (rc)
RETURN(rc);
}
+/* -1 is returned for remote object */
static int cmr_object_exists(const struct lu_context *ctx,
- struct lu_object *lo)
+ const struct lu_object *lo)
{
- return lu_object_exists(ctx, lu_object_next(lo));
+ return -1;
}
static int cmr_object_print(const struct lu_context *ctx,
RETURN(0);
}
-static int mdc_object_exists(const struct lu_context *ctx,
- struct lu_object *lo)
-{
- /* we don't know does it exists or not - but suppose that it does*/
- return 1;
-}
-
static int mdc_object_print(const struct lu_context *ctx,
struct seq_file *f, const struct lu_object *lo)
{
.loo_object_init = mdc_object_init,
.loo_object_free = mdc_object_free,
.loo_object_print = mdc_object_print,
- .loo_object_exists = mdc_object_exists
};
/* md_object_operations */
* Return true off object @o exists on a storage.
*/
int (*loo_object_exists)(const struct lu_context *ctx,
- struct lu_object *o);
+ const struct lu_object *o);
/*
* Debugging helper. Print given object.
*/
int lu_object_invariant(const struct lu_object *o);
/*
- * Returns true iff object @o exists on the stable storage.
+ * Returns 1 iff object @o exists on the stable storage,
+ * returns -1 iif object @o is on remote server.
*/
static inline int lu_object_exists(const struct lu_context *ctx,
- struct lu_object *o)
+ const struct lu_object *o)
{
return o->lo_ops->loo_object_exists(ctx, o);
}
+static inline int lu_object_assert_exists(const struct lu_context *ctx,
+ const struct lu_object *o)
+{
+ int result;
+ result = lu_object_exists(ctx, o);
+ if (result < 0)
+ result = 1;
+ return result;
+}
+
+static inline int lu_object_assert_not_exists(const struct lu_context *ctx,
+ const struct lu_object *o)
+{
+ int result;
+ result = lu_object_exists(ctx, o);
+ if (result < 0)
+ result = 0;
+ return !result;
+}
+
/*
* lu_context. Execution context for lu_object methods. Currently associated
* with thread.
return seq_printf(f, LUSTRE_MDD0_NAME"-object@%p", o);
}
-static int mdd_object_exists(const struct lu_context *ctx, struct lu_object *o)
+static int mdd_object_exists(const struct lu_context *ctx,
+ const struct lu_object *o)
{
return lu_object_exists(ctx, lu_object_next(o));
}
int result;
LASSERT(info->mti_object != NULL);
- LASSERT(lu_object_exists(info->mti_ctxt,
- &info->mti_object->mot_obj.mo_lu));
+ LASSERT(lu_object_assert_exists(info->mti_ctxt,
+ &info->mti_object->mot_obj.mo_lu));
ENTRY;
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK)) {
return 0;
}
+/*
+ * Generic code handling requests that have struct mdt_body passed in:
+ *
+ * - extract mdt_body from request and save it in @info, if present;
+ *
+ * - create lu_object, corresponding to the fid in mdt_body, and save it in
+ * @info;
+ *
+ * - if HABEO_CORPUS flag is set for this request type check whether object
+ * actually exists on storage (lu_object_exists()).
+ *
+ */
static int mdt_body_unpack(struct mdt_thread_info *info, __u32 flags)
{
int result;
return result;
}
-/*
- * Generic code handling requests that have struct mdt_body passed in:
- *
- * - extract mdt_body from request and save it in @info, if present;
- *
- * - create lu_object, corresponding to the fid in mdt_body, and save it in
- * @info;
- *
- * - if HABEO_CORPUS flag is set for this request type check whether object
- * actually exists on storage (lu_object_exists()).
- *
- */
static int mdt_unpack_req_pack_rep(struct mdt_thread_info *info, __u32 flags)
{
struct req_capsule *pill;
EXIT;
}
-static int mdt_object_exists(const struct lu_context *ctx, struct lu_object *o)
+static int mdt_object_exists(const struct lu_context *ctx,
+ const struct lu_object *o)
{
return lu_object_exists(ctx, lu_object_next(o));
}
locked = 1;
}
- LASSERT(lu_object_exists(info->mti_ctxt, &mo->mot_obj.mo_lu));
+ LASSERT(lu_object_assert_exists(info->mti_ctxt, &mo->mot_obj.mo_lu));
rc = mo_attr_set(info->mti_ctxt, mdt_object_child(mo), attr);
if (rc != 0)
ENTRY;
LASSERT(info->mti_object != NULL);
- LASSERT(lu_object_exists(info->mti_ctxt,
+ LASSERT(lu_object_assert_exists(info->mti_ctxt,
&info->mti_object->mot_obj.mo_lu));
ENTRY;
static void osd_object_release(const struct lu_context *ctxt,
struct lu_object *l);
static int osd_object_exists (const struct lu_context *ctx,
- struct lu_object *o);
+ const struct lu_object *o);
static int osd_object_print (const struct lu_context *ctx,
struct seq_file *f, const struct lu_object *o);
static void osd_device_free (const struct lu_context *ctx,
set_bit(LU_OBJECT_HEARD_BANSHEE, &l->lo_header->loh_flags);
}
-static int osd_object_exists(const struct lu_context *ctx, struct lu_object *o)
+static int osd_object_exists(const struct lu_context *ctx,
+ const struct lu_object *o)
{
LASSERT(osd_invariant(osd_obj(o)));
return osd_obj(o)->oo_inode != NULL;