From: tappro Date: Fri, 23 Jun 2006 18:56:59 +0000 (+0000) Subject: - change lu_object_exists() so it may return -1 for remote object. X-Git-Tag: v1_8_0_110~486^2~1555 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=849a965f035fc4d6df3c87f14a1f9caef06d5359;p=fs%2Flustre-release.git - change lu_object_exists() so it may return -1 for remote object. - make the second parameter in lu_object_exists() constant - use lu_object_exists instead of cmm_is_local_object() --- diff --git a/lustre/cmm/cmm_internal.h b/lustre/cmm/cmm_internal.h index 1215ad3..12806c4 100644 --- a/lustre/cmm/cmm_internal.h +++ b/lustre/cmm/cmm_internal.h @@ -80,7 +80,6 @@ static inline struct lu_device *cmm2lu_dev(struct cmm_device *d) struct cmm_object { struct md_object cmo_obj; - int cmo_local; }; /* local CMM object */ @@ -117,12 +116,6 @@ static inline struct md_object *cmm2child_obj(struct cmm_object *o) 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, diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 88ddf24..2ab41f8 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -107,8 +107,7 @@ struct lu_object *cmm_object_alloc(const struct lu_context *ctx, 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; @@ -121,7 +120,6 @@ struct lu_object *cmm_object_alloc(const struct lu_context *ctx, 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); @@ -189,7 +187,7 @@ static int cml_object_init(const struct lu_context *ctx, struct lu_object *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)); } @@ -351,7 +349,7 @@ static int cml_rename(const struct lu_context *ctx, struct md_object *mo_po, 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) @@ -455,10 +453,11 @@ static int cmr_object_init(const struct lu_context *ctx, struct lu_object *lo) 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, diff --git a/lustre/cmm/mdc_object.c b/lustre/cmm/mdc_object.c index 54319f8..f975560 100644 --- a/lustre/cmm/mdc_object.c +++ b/lustre/cmm/mdc_object.c @@ -77,13 +77,6 @@ static int mdc_object_init(const struct lu_context *ctx, struct lu_object *lo) 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) { @@ -94,7 +87,6 @@ static struct lu_object_operations mdc_obj_ops = { .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 */ diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index dd8eac6..3f0f860 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -182,7 +182,7 @@ struct lu_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. */ @@ -682,14 +682,35 @@ int lu_object_print(const struct lu_context *ctxt, 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. diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index a641cd4..3dfce1f 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -335,7 +335,8 @@ static int mdd_object_print(const struct lu_context *ctxt, 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)); } diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 70589a1..5e5ba05 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -342,8 +342,8 @@ static int mdt_getattr(struct mdt_thread_info *info) 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)) { @@ -894,6 +894,18 @@ static int mdt_lock_reply_compat(struct mdt_device *m, struct ldlm_reply *rep) 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; @@ -930,18 +942,6 @@ static int mdt_body_unpack(struct mdt_thread_info *info, __u32 flags) 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; @@ -2189,7 +2189,8 @@ static void mdt_object_free(const struct lu_context *ctxt, struct lu_object *o) 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)); } diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 6b09d40..e3e1dcd 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -177,7 +177,7 @@ static int mdt_reint_setattr(struct mdt_thread_info *info) 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) diff --git a/lustre/mdt/mdt_xattr.c b/lustre/mdt/mdt_xattr.c index b666082..1752b1e 100644 --- a/lustre/mdt/mdt_xattr.c +++ b/lustre/mdt/mdt_xattr.c @@ -105,7 +105,7 @@ int mdt_getxattr(struct mdt_thread_info *info) 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; diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index d974100..df4b0a4 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -111,7 +111,7 @@ static int osd_object_init (const struct lu_context *ctxt, 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, @@ -335,7 +335,8 @@ static void osd_object_release(const struct lu_context *ctxt, 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;