From 43a6fab6aa7e3ce15c4d9d5654cfaf748dd85553 Mon Sep 17 00:00:00 2001 From: fanyong Date: Mon, 9 Oct 2006 02:40:16 +0000 Subject: [PATCH] Small bug fix and make the code more conciser. --- lustre/mdt/mdt_handler.c | 18 +++++++++--------- lustre/mdt/mdt_internal.h | 4 ++-- lustre/mdt/mdt_lib.c | 6 ++---- lustre/mdt/mdt_open.c | 3 +-- lustre/mdt/mdt_recovery.c | 6 ++---- lustre/mdt/mdt_reint.c | 9 +++------ 6 files changed, 19 insertions(+), 27 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 19e625c..dc43d2d 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -230,8 +230,8 @@ void mdt_pack_size2body(struct mdt_body *b, const struct lu_attr *attr, } } -void mdt_pack_attr2body(struct mdt_body *b, const struct lu_attr *attr, - const struct lu_fid *fid) +void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b, + const struct lu_attr *attr, const struct lu_fid *fid) { /*XXX should pack the reply body according to lu_valid*/ b->valid |= OBD_MD_FLCTIME | OBD_MD_FLUID | @@ -260,6 +260,9 @@ void mdt_pack_attr2body(struct mdt_body *b, const struct lu_attr *attr, CDEBUG(D_INODE, ""DFID": nlink=%d, mode=%o, size="LPU64"\n", PFID(fid), b->nlink, b->mode, b->size); } + + if (info) + mdt_body_reverse_idmap(info, b); } static inline int mdt_body_has_lov(const struct lu_attr *la, @@ -317,12 +320,10 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, RETURN(rc); } - if (ma->ma_valid & MA_INODE) { - mdt_pack_attr2body(repbody, la, mdt_object_fid(o)); - mdt_body_reverse_idmap(info, repbody); - } else { + if (ma->ma_valid & MA_INODE) + mdt_pack_attr2body(info, repbody, la, mdt_object_fid(o)); + else RETURN(-EFAULT); - } if (mdt_body_has_lov(la, reqbody)) { if (ma->ma_valid & MA_LOV) { @@ -1192,8 +1193,7 @@ static int mdt_sync(struct mdt_thread_info *info) body = req_capsule_server_get(pill, &RMF_MDT_BODY); fid = mdt_object_fid(info->mti_object); - mdt_pack_attr2body(body, la, fid); - mdt_body_reverse_idmap(info, body); + mdt_pack_attr2body(info, body, la, fid); } } } else diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index fe65b12..26a0f09 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -406,8 +406,8 @@ int mdt_reint_unpack(struct mdt_thread_info *info, __u32 op); int mdt_reint_rec(struct mdt_thread_info *, struct mdt_lock_handle *); void mdt_pack_size2body(struct mdt_body *b, const struct lu_attr *attr, struct mdt_object *o); -void mdt_pack_attr2body(struct mdt_body *b, const struct lu_attr *attr, - const struct lu_fid *fid); +void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b, + const struct lu_attr *attr, const struct lu_fid *fid); int mdt_getxattr(struct mdt_thread_info *info); int mdt_setxattr(struct mdt_thread_info *info); diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index 0c7bcf3..d0464c4 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -525,10 +525,8 @@ int mdt_handle_last_unlink(struct mdt_thread_info *info, struct mdt_object *mo, repbody = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY); LASSERT(repbody != NULL); - if (ma->ma_valid & MA_INODE) { - mdt_pack_attr2body(repbody, la, mdt_object_fid(mo)); - mdt_body_reverse_idmap(info, repbody); - } + if (ma->ma_valid & MA_INODE) + mdt_pack_attr2body(info, repbody, la, mdt_object_fid(mo)); if (ma->ma_valid & MA_LOV) { __u32 mode; diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 51c48c2..35237e3 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -329,8 +329,7 @@ static int mdt_mfd_open(struct mdt_thread_info *info, isreg = S_ISREG(la->la_mode); isdir = S_ISDIR(la->la_mode); islnk = S_ISLNK(la->la_mode); - mdt_pack_attr2body(repbody, la, mdt_object_fid(o)); - mdt_body_reverse_idmap(info, repbody); + mdt_pack_attr2body(info, repbody, la, mdt_object_fid(o)); if (med->med_rmtclient) { void *buf = req_capsule_server_get(&info->mti_pill, &RMF_ACL); diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index 4fc13fe..78c3db6 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -1042,8 +1042,7 @@ static void mdt_reconstruct_create(struct mdt_thread_info *mti, req->rq_status = rc; body->valid |= OBD_MD_MDS; } - mdt_pack_attr2body(body, &mti->mti_attr.ma_attr, mdt_object_fid(child)); - mdt_body_reverse_idmap(mti, body); + mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr, mdt_object_fid(child)); mdt_object_put(mti->mti_env, child); } @@ -1064,8 +1063,7 @@ static void mdt_reconstruct_setattr(struct mdt_thread_info *mti, obj = mdt_object_find(mti->mti_env, mdt, mti->mti_rr.rr_fid1); LASSERT(!IS_ERR(obj)); mo_attr_get(mti->mti_env, mdt_object_child(obj), &mti->mti_attr); - mdt_pack_attr2body(body, &mti->mti_attr.ma_attr, mdt_object_fid(obj)); - mdt_body_reverse_idmap(mti, body); + mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr, mdt_object_fid(obj)); /* Don't return OST-specific attributes if we didn't just set them */ /* diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index f7c7ae3..c1c8394 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -73,9 +73,8 @@ static int mdt_md_create(struct mdt_thread_info *info) if (rc == 0) { /* return fid & attr to client. */ if (ma->ma_valid & MA_INODE) - mdt_pack_attr2body(repbody, &ma->ma_attr, + mdt_pack_attr2body(info, repbody, &ma->ma_attr, mdt_object_fid(child)); - mdt_body_reverse_idmap(info, repbody); } mdt_object_put(info->mti_env, child); } else @@ -112,9 +111,8 @@ static int mdt_md_mkobj(struct mdt_thread_info *info) if (rc == 0) { /* return fid & attr to client. */ if (ma->ma_valid & MA_INODE) - mdt_pack_attr2body(repbody, &ma->ma_attr, + mdt_pack_attr2body(info, repbody, &ma->ma_attr, mdt_object_fid(o)); - mdt_body_reverse_idmap(info, repbody); } mdt_object_put(info->mti_env, o); } else @@ -273,7 +271,7 @@ static int mdt_reint_setattr(struct mdt_thread_info *info, if (rc != 0) GOTO(out, rc); - mdt_pack_attr2body(repbody, &ma->ma_attr, mdt_object_fid(mo)); + mdt_pack_attr2body(info, repbody, &ma->ma_attr, mdt_object_fid(mo)); if (mdt->mdt_opts.mo_oss_capa && S_ISREG(lu_object_attr(&mo->mot_obj.mo_lu))) { @@ -288,7 +286,6 @@ static int mdt_reint_setattr(struct mdt_thread_info *info, repbody->valid |= OBD_MD_FLOSSCAPA; } - mdt_body_reverse_idmap(info, repbody); EXIT; out: mdt_object_put(info->mti_env, mo); -- 1.8.3.1