From: nikita Date: Tue, 15 Aug 2006 14:55:52 +0000 (+0000) Subject: lu_object_attr() is only defined for local objects: check this in assertion X-Git-Tag: v1_8_0_110~486^2~1170 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=1e6299e183964ffdf57e341057d4b64d05a77576;p=fs%2Flustre-release.git lu_object_attr() is only defined for local objects: check this in assertion --- diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index efc8541..447738a 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -710,14 +710,6 @@ static inline const struct lu_fid *lu_object_fid(const struct lu_object *o) } /* - * Attr of this object. - */ -static inline const __u32 lu_object_attr(const struct lu_object *o) -{ - return o->lo_header->loh_attr; -} - -/* * return device operations vector for this object */ static inline struct lu_device_operations * @@ -796,6 +788,16 @@ static inline int lu_object_assert_not_exists(const struct lu_context *ctx, return lu_object_exists(ctx, o) <= 0; } +/* + * Attr of this object. + */ +static inline const __u32 lu_object_attr(const struct lu_context *ctx, + const struct lu_object *o) +{ + LASSERT(lu_object_exists(ctx, o) > 0); + return o->lo_header->loh_attr; +} + struct lu_rdpg { /* input params, should be filled out by mdt */ __u32 rp_hash; /* hash */ diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 22c25fb..bb8ed07 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -190,13 +190,13 @@ static int mdd_may_delete(const struct lu_context *ctxt, /*TODO:check append flags*/ if (is_dir) { - if (!S_ISDIR(mdd_object_type(cobj))) + if (!S_ISDIR(mdd_object_type(ctxt, cobj))) RETURN(-ENOTDIR); if (lu_fid_eq(mdo2fid(cobj), &mdd->mdd_root_fid)) RETURN(-EBUSY); - } else if (S_ISDIR(mdd_object_type(cobj))) + } else if (S_ISDIR(mdd_object_type(ctxt, cobj))) RETURN(-EISDIR); if (mdd_is_dead_obj(pobj)) @@ -245,8 +245,8 @@ static int mdd_attr_get_internal(const struct lu_context *ctxt, rc = __mdd_iattr_get(ctxt, mdd_obj, ma); if (rc == 0 && ma->ma_need & MA_LOV) { - if (S_ISREG(lu_object_attr(mdd2lu_obj(mdd_obj))) || - S_ISDIR(lu_object_attr(mdd2lu_obj(mdd_obj)))) { + if (S_ISREG(lu_object_attr(ctxt, mdd2lu_obj(mdd_obj))) || + S_ISDIR(lu_object_attr(ctxt, mdd2lu_obj(mdd_obj)))) { rc = __mdd_lmm_get(ctxt, mdd_obj, ma); } } @@ -572,9 +572,9 @@ int mdd_attr_set_internal(const struct lu_context *ctxt, struct mdd_object *o, return next->do_ops->do_attr_set(ctxt, next, attr, handle); } -int mdd_attr_set_internal_locked(const struct lu_context *ctxt, +int mdd_attr_set_internal_locked(const struct lu_context *ctxt, struct mdd_object *o, - const struct lu_attr *attr, + const struct lu_attr *attr, struct thandle *handle) { int rc; @@ -730,7 +730,7 @@ static int mdd_attr_set(const struct lu_context *ctxt, RETURN(PTR_ERR(handle)); /*TODO: add lock here*/ /* start a log jounal handle if needed */ - if (S_ISREG(mdd_object_type(mdd_obj)) && + if (S_ISREG(mdd_object_type(ctxt, mdd_obj)) && ma->ma_attr.la_valid & (LA_UID | LA_GID)) { max_size = mdd_lov_mdsize(ctxt, mdd); OBD_ALLOC(lmm, max_size); @@ -751,13 +751,13 @@ static int mdd_attr_set(const struct lu_context *ctxt, rc = mdd_fix_attr(ctxt, mdd_obj, ma, la_copy); if (rc) GOTO(cleanup, rc); - + if (ma->ma_valid & MA_FLAGS) { la_copy->la_flags = ma->ma_attr_flags; la_copy->la_valid |= LA_FLAGS; rc = mdd_attr_set_internal_locked(ctxt, mdd_obj, la_copy, handle); - }else if (la_copy->la_valid) { /* setattr */ + } else if (la_copy->la_valid) { /* setattr */ rc = mdd_attr_set_internal_locked(ctxt, mdd_obj, la_copy, handle); /* journal chown/chgrp in llog, just like unlink */ @@ -767,8 +767,10 @@ static int mdd_attr_set(const struct lu_context *ctxt, } if (rc == 0 && ma->ma_valid & MA_LOV) { - if ((S_ISREG(mdd_object_type(mdd_obj)) || - S_ISDIR(mdd_object_type(mdd_obj)))) { + umode_t mode; + + mode = mdd_object_type(ctxt, mdd_obj); + if (S_ISREG(mode) || S_ISDIR(mode)) { /*TODO check permission*/ rc = mdd_lov_set_md(ctxt, NULL, mdd_obj, ma->ma_lmm, ma->ma_lmm_size, handle, 1); @@ -900,7 +902,7 @@ static int mdd_link_sanity_check(const struct lu_context *ctxt, rc = mdd_may_create(ctxt, tgt_obj, NULL); if (rc) RETURN(rc); - if (S_ISDIR(mdd_object_type(src_obj))) + if (S_ISDIR(mdd_object_type(ctxt, src_obj))) RETURN(-EPERM); RETURN(rc); @@ -993,7 +995,7 @@ static int __mdd_finish_unlink(const struct lu_context *ctxt, if (rc == 0) { if (atomic_read(&obj->mod_count) == 0 && ma->ma_attr.la_nlink == 0 && - S_ISREG(mdd_object_type(obj))) { + S_ISREG(mdd_object_type(ctxt, obj))) { rc = __mdd_lmm_get(ctxt, obj, ma); if (rc == 0 && ma->ma_valid & MA_LOV) rc = mdd_unlink_log(ctxt, @@ -1017,7 +1019,7 @@ static int mdd_unlink_sanity_check(const struct lu_context *ctxt, if (rc) RETURN(rc); - if (S_ISDIR(mdd_object_type(cobj)) && + if (S_ISDIR(mdd_object_type(ctxt, cobj)) && dt_try_as_dir(ctxt, dt_cobj)) { rc = mdd_dir_is_empty(ctxt, cobj); if (rc != 0) @@ -1055,7 +1057,7 @@ static int mdd_unlink(const struct lu_context *ctxt, struct md_object *pobj, GOTO(cleanup, rc); __mdd_ref_del(ctxt, mdd_cobj, handle); - if (S_ISDIR(lu_object_attr(&cobj->mo_lu))) { + if (S_ISDIR(lu_object_attr(ctxt, &cobj->mo_lu))) { /* unlink dot */ __mdd_ref_del(ctxt, mdd_cobj, handle); /* unlink dotdot */ @@ -1164,7 +1166,7 @@ static int mdd_rename_sanity_check(const struct lu_context *ctxt, int rc = 0, src_is_dir, tgt_is_dir; ENTRY; - src_is_dir = S_ISDIR(mdd_object_type(sobj)); + src_is_dir = S_ISDIR(mdd_object_type(ctxt, sobj)); rc = mdd_may_delete(ctxt, src_pobj, sobj, src_is_dir); if (rc) GOTO(out, rc); @@ -1186,7 +1188,7 @@ static int mdd_rename_sanity_check(const struct lu_context *ctxt, if (rc) GOTO(out, rc); - tgt_is_dir = S_ISDIR(mdd_object_type(tobj)); + tgt_is_dir = S_ISDIR(mdd_object_type(ctxt, tobj)); if (tgt_is_dir && mdd_dir_is_empty(ctxt, tobj)) GOTO(out, rc = -ENOTEMPTY); out: @@ -1232,7 +1234,7 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj, GOTO(cleanup, rc); /*if sobj is dir, its parent object nlink should be dec too*/ - if (S_ISDIR(mdd_object_type(mdd_sobj))) + if (S_ISDIR(mdd_object_type(ctxt, mdd_sobj))) __mdd_ref_del(ctxt, mdd_spobj, handle); if (tobj) { @@ -1248,7 +1250,7 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj, if (tobj && lu_object_exists(ctxt, &tobj->mo_lu)) { __mdd_ref_del(ctxt, mdd_tobj, handle); /* remove dot reference */ - if (S_ISDIR(mdd_object_type(mdd_tobj))) + if (S_ISDIR(mdd_object_type(ctxt, mdd_tobj))) __mdd_ref_del(ctxt, mdd_tobj, handle); rc = __mdd_finish_unlink(ctxt, mdd_tobj, ma); @@ -1274,7 +1276,7 @@ static int mdd_lookup(const struct lu_context *ctxt, struct md_object *pobj, if (mdd_is_dead_obj(mdd_obj)) RETURN(-ESTALE); mdd_lock(ctxt, mdd_obj, DT_READ_LOCK); - if (S_ISDIR(mdd_object_type(mdd_obj)) && dt_try_as_dir(ctxt, dir)) + if (S_ISDIR(mdd_object_type(ctxt, mdd_obj)) && dt_try_as_dir(ctxt, dir)) rc = dir->do_index_ops->dio_lookup(ctxt, dir, rec, key); else rc = -ENOTDIR; @@ -1775,7 +1777,7 @@ static int mdd_ref_del(const struct lu_context *ctxt, struct md_object *obj, mdd_lock(ctxt, mdd_obj, DT_WRITE_LOCK); /* rmdir checks */ - if (S_ISDIR(lu_object_attr(&obj->mo_lu)) && + if (S_ISDIR(lu_object_attr(ctxt, &obj->mo_lu)) && dt_try_as_dir(ctxt, mdd_object_child(mdd_obj))) { rc = mdd_dir_is_empty(ctxt, mdd_obj); if (rc != 0) @@ -1784,7 +1786,7 @@ static int mdd_ref_del(const struct lu_context *ctxt, struct md_object *obj, __mdd_ref_del(ctxt, mdd_obj, handle); - if (S_ISDIR(lu_object_attr(&obj->mo_lu))) { + if (S_ISDIR(lu_object_attr(ctxt, &obj->mo_lu))) { /* unlink dot */ __mdd_ref_del(ctxt, mdd_obj, handle); } @@ -1824,7 +1826,8 @@ static int mdd_readpage(const struct lu_context *ctxt, struct md_object *obj, next = mdd_object_child(mdd_obj); mdd_lock(ctxt, mdd_obj, DT_READ_LOCK); - if (S_ISDIR(mdd_object_type(mdd_obj)) && dt_try_as_dir(ctxt, next)) + if (S_ISDIR(mdd_object_type(ctxt, mdd_obj)) && + dt_try_as_dir(ctxt, next)) rc = next->do_ops->do_readpage(ctxt, next, rdpg); else rc = -ENOTDIR; diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 90ced73..0afcc41 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -41,7 +41,7 @@ struct mdd_device { enum mod_flags { /*The dir object has been unlinked*/ - DEAD_OBJ = 1 << 0, + DEAD_OBJ = 1 << 0, }; struct mdd_object { @@ -87,9 +87,9 @@ int mdd_lov_setattr_async(const struct lu_context *ctxt, struct mdd_object *obj, struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx); -void mdd_lock(const struct lu_context *ctxt, struct mdd_object *obj, +void mdd_lock(const struct lu_context *ctxt, struct mdd_object *obj, enum dt_lock_mode mode); -void mdd_unlock(const struct lu_context *ctxt, struct mdd_object *obj, +void mdd_unlock(const struct lu_context *ctxt, struct mdd_object *obj, enum dt_lock_mode mode); extern struct lu_device_operations mdd_lu_ops; static inline int lu_device_is_mdd(struct lu_device *d) @@ -149,19 +149,20 @@ static inline const struct lu_fid *mdo2fid(const struct mdd_object *obj) return lu_object_fid(&obj->mod_obj.mo_lu); } -static inline umode_t mdd_object_type(const struct mdd_object *obj) +static inline umode_t mdd_object_type(const struct lu_context *ctxt, + const struct mdd_object *obj) { - return lu_object_attr(&obj->mod_obj.mo_lu); + return lu_object_attr(ctxt, &obj->mod_obj.mo_lu); } -static inline int mdd_lov_mdsize(const struct lu_context *ctxt, +static inline int mdd_lov_mdsize(const struct lu_context *ctxt, struct mdd_device *mdd) { struct obd_device *obd = mdd2_obd(mdd); return obd->u.mds.mds_max_mdsize; } -static inline int mdd_lov_cookiesize(const struct lu_context *ctxt, +static inline int mdd_lov_cookiesize(const struct lu_context *ctxt, struct mdd_device *mdd) { struct obd_device *obd = mdd2_obd(mdd); diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index 656d9dc..d734115 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -187,22 +187,23 @@ static int mdd_lov_set_stripe_md(const struct lu_context *ctxt, struct lov_stripe_md *lsm = NULL; int rc; ENTRY; - - LASSERT(S_ISDIR(mdd_object_type(obj)) || S_ISREG(mdd_object_type(obj))); + + LASSERT(S_ISDIR(mdd_object_type(ctxt, obj)) || + S_ISREG(mdd_object_type(ctxt, obj))); rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, lov_exp, 0, &lsm, lmmp); if (rc) RETURN(rc); obd_free_memmd(lov_exp, &lsm); - rc = mdd_xattr_set_txn(ctxt, obj, lmmp, lmm_size, MDS_LOV_MD_NAME, 0, + rc = mdd_xattr_set_txn(ctxt, obj, lmmp, lmm_size, MDS_LOV_MD_NAME, 0, handle); - + CDEBUG(D_INFO, "set lov ea of "DFID" rc %d \n", PFID(mdo2fid(obj)), rc); RETURN(rc); } - -static int mdd_lov_set_dir_md(const struct lu_context *ctxt, + +static int mdd_lov_set_dir_md(const struct lu_context *ctxt, struct mdd_object *obj, struct lov_mds_md *lmmp, int lmm_size, struct thandle *handle) { @@ -211,35 +212,37 @@ static int mdd_lov_set_dir_md(const struct lu_context *ctxt, ENTRY; /*TODO check permission*/ - LASSERT(S_ISDIR(mdd_object_type(obj))); + LASSERT(S_ISDIR(mdd_object_type(ctxt, obj))); lum = (struct lov_user_md*)lmmp; /* if { size, offset, count } = { 0, -1, 0 } (i.e. all default * values specified) then delete default striping from dir. */ - if ((lum->lmm_stripe_size == 0 && lum->lmm_stripe_count == 0 && + if ((lum->lmm_stripe_size == 0 && lum->lmm_stripe_count == 0 && lum->lmm_stripe_offset == (typeof(lum->lmm_stripe_offset))(-1)) || /* lmm_stripe_size == -1 is deprecated in 1.4.6 */ lum->lmm_stripe_size == (typeof(lum->lmm_stripe_size))(-1)){ - rc = mdd_xattr_set_txn(ctxt, obj, NULL, 0, MDS_LOV_MD_NAME, 0, + rc = mdd_xattr_set_txn(ctxt, obj, NULL, 0, MDS_LOV_MD_NAME, 0, handle); if (rc == -ENODATA) rc = 0; CDEBUG(D_INFO, "delete lov ea of "DFID" rc %d \n", PFID(mdo2fid(obj)), rc); } else { - rc = mdd_lov_set_stripe_md(ctxt, obj, lmmp, lmm_size, handle); + rc = mdd_lov_set_stripe_md(ctxt, obj, lmmp, lmm_size, handle); } RETURN(rc); } - + int mdd_lov_set_md(const struct lu_context *ctxt, struct mdd_object *pobj, struct mdd_object *child, struct lov_mds_md *lmmp, int lmm_size, struct thandle *handle, int set_stripe) { int rc = 0; + umode_t mode; ENTRY; - if (S_ISREG(mdd_object_type(child)) && lmm_size > 0) { + mode = mdd_object_type(ctxt, child); + if (S_ISREG(mode) && lmm_size > 0) { if (set_stripe) { rc = mdd_lov_set_stripe_md(ctxt, child, lmmp, lmm_size, handle); @@ -247,7 +250,7 @@ int mdd_lov_set_md(const struct lu_context *ctxt, struct mdd_object *pobj, rc = mdd_xattr_set_txn(ctxt, child, lmmp, lmm_size, MDS_LOV_MD_NAME, 0, handle); } - } else if (S_ISDIR(mdd_object_type(child))) { + } else if (S_ISDIR(mode)) { if (lmmp == NULL && lmm_size == 0) { struct lov_mds_md *lmm = &mdd_ctx_info(ctxt)->mti_lmm; int size = sizeof(lmm); @@ -280,7 +283,7 @@ static obd_id mdd_lov_create_id(const struct lu_fid *fid) return ((fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid)); } -/*FIXME: it is just the helper function used by mdd lov obd to +/*FIXME: it is just the helper function used by mdd lov obd to * get attr from obdo, copied from obdo_from_inode*/ static void obdo_from_la(struct obdo *dst, struct lu_attr *la, obd_flag valid) { @@ -394,13 +397,13 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, LASSERT(eadata != NULL); rc = obd_iocontrol(OBD_IOC_LOV_SETEA, lov_exp, 0, &lsm, (void*)eadata); - if (rc) + if (rc) GOTO(out_oa, rc); lsm->lsm_object_id = oa->o_id; } - /*Sometimes, we may truncate some object(without lsm) - *then open (with write flags)it, so creating lsm above. - *The Nonzero(truncated) size should tell ost. since size + /*Sometimes, we may truncate some object(without lsm) + *then open (with write flags)it, so creating lsm above. + *The Nonzero(truncated) size should tell ost. since size *attr is in charged by OST. */ if (la->la_size && la->la_valid & LA_SIZE) { @@ -408,8 +411,8 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, obdo_from_la(oa, la, OBD_MD_FLTYPE | OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE); - /* FIXME:pack lustre id to OST, in OST, it will be packed - * by filter_fid, but can not see what is the usages. So just + /* FIXME:pack lustre id to OST, in OST, it will be packed + * by filter_fid, but can not see what is the usages. So just * pack o_seq o_ver here, maybe fix it after this cycle*/ oa->o_fid = lu_object_fid(mdd2lu_obj(child))->f_seq; oa->o_generation = lu_object_fid(mdd2lu_obj(child))->f_oid; @@ -420,7 +423,7 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, CERROR("error setting attrs for "DFID": rc %d\n", PFID(mdo2fid(child)), rc); if (rc > 0) { - CERROR("obd_setattr for "DFID" rc %d\n", + CERROR("obd_setattr for "DFID" rc %d\n", PFID(mdo2fid(child)), rc); rc = -EIO; } diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index b56576f..c19b3d7 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -46,7 +46,7 @@ void mdt_dump_lmm(int level, struct lov_mds_md *lmm) { struct lov_ost_data_v1 *lod; int i; - __s16 stripe_count = + __s16 stripe_count = le16_to_cpu(((struct lov_user_md*)lmm)->lmm_stripe_count); CDEBUG_EX(level, "objid "LPX64", magic 0x%08X, pattern %#X\n", @@ -102,25 +102,28 @@ int mdt_handle_last_unlink(struct mdt_thread_info *info, struct mdt_object *mo, ENTRY; repbody = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY); - + if (ma->ma_valid & MA_INODE) mdt_pack_attr2body(repbody, la, mdt_object_fid(mo)); if (ma->ma_valid & MA_LOV) { + __u32 mode; + + mode = lu_object_attr(info->mti_ctxt, &mo->mot_obj.mo_lu); LASSERT(ma->ma_lmm_size); mdt_dump_lmm(D_INFO, ma->ma_lmm); repbody->eadatasize = ma->ma_lmm_size; - if (S_ISREG(lu_object_attr(&mo->mot_obj.mo_lu))) + if (S_ISREG(mode)) repbody->valid |= OBD_MD_FLEASIZE; - else if (S_ISDIR(lu_object_attr(&mo->mot_obj.mo_lu))) + else if (S_ISDIR(mode)) repbody->valid |= OBD_MD_FLDIREA; - else + else LBUG(); } - + if (ma->ma_cookie_size && (ma->ma_valid & MA_COOKIE)) repbody->valid |= OBD_MD_FLCOOKIE; - + RETURN(0); } @@ -159,7 +162,7 @@ static __u64 mdt_attr_valid_xlate(__u64 in, struct mdt_reint_record *rr, in &= ~(ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE| ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_FROM_OPEN| ATTR_ATIME_SET|ATTR_CTIME_SET|ATTR_MTIME_SET| - ATTR_ATTR_FLAG|ATTR_RAW); + ATTR_ATTR_FLAG|ATTR_RAW); if (in != 0) CERROR("Unknown attr bits: %#llx\n", in); return out; @@ -180,7 +183,7 @@ static int mdt_setattr_unpack(struct mdt_thread_info *info) RETURN(-EFAULT); rr->rr_fid1 = &rec->sa_fid; - la->la_valid = mdt_attr_valid_xlate(rec->sa_valid, rr, ma, + la->la_valid = mdt_attr_valid_xlate(rec->sa_valid, rr, ma, rec->sa_attr_flags); la->la_mode = rec->sa_mode; la->la_uid = rec->sa_uid; @@ -230,7 +233,7 @@ static int mdt_create_unpack(struct mdt_thread_info *info) attr->la_mtime = rec->cr_time; attr->la_atime = rec->cr_time; attr->la_valid = LA_MODE | LA_RDEV | LA_UID | LA_GID | - LA_CTIME | LA_MTIME | LA_ATIME; + LA_CTIME | LA_MTIME | LA_ATIME; info->mti_spec.sp_cr_flags = rec->cr_flags; rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);