From d175c9be5d066febf3a8ae5ac836310ec906ab0d Mon Sep 17 00:00:00 2001 From: yury Date: Wed, 23 Feb 2005 14:59:02 +0000 Subject: [PATCH] - fix from b1_4 in MDS_CHECK_RESENT() - more fixes about fid extracting on MDS. By now correct fid is always should be returned to client. --- lustre/include/linux/lustre_mds.h | 2 +- lustre/llite/llite_lib.c | 2 +- lustre/mds/handler.c | 6 +++--- lustre/mds/mds_fs.c | 2 +- lustre/mds/mds_internal.h | 8 ++++---- lustre/mds/mds_lib.c | 38 +++++++++++++++----------------------- lustre/mds/mds_open.c | 23 +++++++++-------------- lustre/mds/mds_reint.c | 23 +++++++++++------------ 8 files changed, 45 insertions(+), 59 deletions(-) diff --git a/lustre/include/linux/lustre_mds.h b/lustre/include/linux/lustre_mds.h index 19aaee9..d918380 100644 --- a/lustre/include/linux/lustre_mds.h +++ b/lustre/include/linux/lustre_mds.h @@ -290,7 +290,7 @@ int mdc_done_writing(struct obd_export *, struct obdo *); req->rq_export->exp_mds_data.med_mcd; \ if (mcd->mcd_last_xid == req->rq_xid) { \ reconstruct; \ - RETURN(0); \ + RETURN(req->rq_repmsg->status); \ } \ DEBUG_REQ(D_HA, req, "no reply for RESENT req (have "LPD64")", \ mcd->mcd_last_xid); \ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index bef852f..26533b8 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1223,6 +1223,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) (struct lov_stripe_md **) &mea); } + /* MDS is supposed to return correct fid always. */ LASSERT(id_fid(&body->id1) != 0); id_assign_fid(&lli->lli_id, &body->id1); @@ -1277,7 +1278,6 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) inode->i_dev = (kdev_t)id_group(&lli->lli_id); #endif - LASSERT(id_fid(&lli->lli_id) != 0); } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 2e8c20c..bf83cd8 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -756,13 +756,13 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry, LASSERT(body != NULL); /* caller prepped reply */ if (dentry->d_flags & DCACHE_CROSS_REF) { - mds_pack_dentry2body(obd, body, dentry, 1); + mds_pack_dentry2body(obd, body, dentry); CDEBUG(D_OTHER, "cross reference: "DLID4"\n", OLID4(&body->id1)); RETURN(0); } - mds_pack_inode2body(obd, body, inode, 1); + mds_pack_inode2body(obd, body, inode); if ((S_ISREG(inode->i_mode) && (reqbody->valid & OBD_MD_FLEASIZE)) || (S_ISDIR(inode->i_mode) && (reqbody->valid & OBD_MD_FLDIREA))) { @@ -1271,7 +1271,7 @@ static int mds_sync(struct ptlrpc_request *req, int offset) GOTO(out, rc); body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_inode2body(obd, body, de->d_inode, 0); + mds_pack_inode2body(obd, body, de->d_inode); l_dput(de); } diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index ed41934..c71cd36 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -476,7 +476,7 @@ int mds_fs_setup_rootid(struct obd_device *obd) inode = dentry->d_inode; LASSERT(dentry->d_inode); - rc = mds_pack_inode2id(obd, &mds->mds_rootid, inode, 1); + rc = mds_pack_inode2id(obd, &mds->mds_rootid, inode); if (rc < 0) { if (rc != -ENODATA) GOTO(out_dentry, rc); diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index be2fcfc..b0bbf19 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -207,16 +207,16 @@ int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset, struct mds_body *, struct inode *, int lock); int mds_pack_inode2id(struct obd_device *, struct lustre_id *, - struct inode *, int); + struct inode *); void mds_pack_inode2body(struct obd_device *, struct mds_body *, - struct inode *, int); + struct inode *); void mds_pack_dentry2id(struct obd_device *, struct lustre_id *, - struct dentry *, int); + struct dentry *); void mds_pack_dentry2body(struct obd_device *, struct mds_body *b, - struct dentry *, int); + struct dentry *); #endif /* mds/mds_lmv.c */ diff --git a/lustre/mds/mds_lib.c b/lustre/mds/mds_lib.c index 556b1eb..33f8000 100644 --- a/lustre/mds/mds_lib.c +++ b/lustre/mds/mds_lib.c @@ -160,47 +160,39 @@ void groups_from_buffer(struct group_info *ginfo, __u32 *gids) void mds_pack_dentry2id(struct obd_device *obd, struct lustre_id *id, - struct dentry *dentry, - int read_fid) + struct dentry *dentry) { id_ino(id) = dentry->d_inum; id_gen(id) = dentry->d_generation; - - if (read_fid) { - id_fid(id) = dentry->d_fid; - id_group(id) = dentry->d_mdsnum; - } + id_fid(id) = dentry->d_fid; + id_group(id) = dentry->d_mdsnum; } void mds_pack_dentry2body(struct obd_device *obd, struct mds_body *b, - struct dentry *dentry, - int read_fid) + struct dentry *dentry) { b->valid |= OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_MDS; - mds_pack_dentry2id(obd, &b->id1, dentry, - read_fid); + mds_pack_dentry2id(obd, &b->id1, dentry); } int mds_pack_inode2id(struct obd_device *obd, struct lustre_id *id, - struct inode *inode, - int read_fid) + struct inode *inode) { int rc = 0; ENTRY; - if (read_fid) { - /* we have to avoid deadlock. */ - if (!down_trylock(&inode->i_sem)) { - rc = mds_read_inode_sid(obd, inode, id); - up(&inode->i_sem); - } else { - rc = mds_read_inode_sid(obd, inode, id); - } + /* we have to avoid deadlock. */ + if (!down_trylock(&inode->i_sem)) { + rc = mds_read_inode_sid(obd, inode, id); + up(&inode->i_sem); + } else { + rc = mds_read_inode_sid(obd, inode, id); } + if (rc == 0) { id_ino(id) = inode->i_ino; id_gen(id) = inode->i_generation; @@ -211,7 +203,7 @@ int mds_pack_inode2id(struct obd_device *obd, /* Note that we can copy all of the fields, just some will not be "valid" */ void mds_pack_inode2body(struct obd_device *obd, struct mds_body *b, - struct inode *inode, int read_fid) + struct inode *inode) { b->valid |= OBD_MD_FLID | OBD_MD_FLCTIME | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLFLAGS | OBD_MD_FLTYPE | @@ -242,7 +234,7 @@ void mds_pack_inode2body(struct obd_device *obd, struct mds_body *b, } else { b->nlink = inode->i_nlink; } - mds_pack_inode2id(obd, &b->id1, inode, read_fid); + mds_pack_inode2id(obd, &b->id1, inode); } /* unpacking */ diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index 2209c17..8c21af3 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -527,7 +527,7 @@ static void reconstruct_open(struct mds_update_record *rec, int offset, GOTO(out_dput, 0); /* get lock (write for O_CREAT, read otherwise) */ - mds_pack_inode2body(obd, body, dchild->d_inode, 0); + mds_pack_inode2body(obd, body, dchild->d_inode); if (S_ISREG(dchild->d_inode->i_mode)) { rc = mds_pack_md(obd, req->rq_repmsg, 2, body, dchild->d_inode, 1); @@ -721,7 +721,7 @@ static int mds_open_by_id(struct ptlrpc_request *req, if (dchild->d_inode != NULL) { up(&pending_dir->i_sem); mds_inode_set_orphan(dchild->d_inode); - mds_pack_inode2body(req2obd(req), body, dchild->d_inode, 0); + mds_pack_inode2body(req2obd(req), body, dchild->d_inode); intent_set_disposition(rep, DISP_LOOKUP_EXECD); intent_set_disposition(rep, DISP_LOOKUP_POS); CWARN("Orphan %s found and opened in PENDING directory\n", @@ -739,7 +739,7 @@ static int mds_open_by_id(struct ptlrpc_request *req, if (IS_ERR(dchild)) RETURN(PTR_ERR(dchild)); - mds_pack_inode2body(req2obd(req), body, dchild->d_inode, 0); + mds_pack_inode2body(req2obd(req), body, dchild->d_inode); intent_set_disposition(rep, DISP_LOOKUP_EXECD); intent_set_disposition(rep, DISP_LOOKUP_POS); @@ -977,7 +977,7 @@ got_child: ldlm_policy_data_t policy; int flags = 0; - mds_pack_dentry2body(obd, body, dchild, 1); + mds_pack_dentry2body(obd, body, dchild); intent_set_disposition(rep, DISP_LOOKUP_POS); CDEBUG(D_OTHER, "cross reference: "DLID4"\n", @@ -1128,15 +1128,9 @@ got_child: } acc_mode = 0; /* Don't check for permissions */ - - /* - * we do not read fid from EA here, because it is already - * updated and thus we avoid not needed IO, locking, etc. - */ - mds_pack_inode2body(obd, body, dchild->d_inode, 0); - } else { - mds_pack_inode2body(obd, body, dchild->d_inode, 1); } + mds_pack_inode2body(obd, body, dchild->d_inode); + LASSERTF(!mds_inode_is_orphan(dchild->d_inode), "dchild %*s (%p) inode %p\n", dchild->d_name.len, dchild->d_name.name, dchild, dchild->d_inode); @@ -1489,8 +1483,9 @@ int mds_close(struct ptlrpc_request *req, int offset) body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); LASSERT(body != NULL); - mds_pack_inode2body(obd, body, inode, 0); - mds_pack_md(obd, req->rq_repmsg, 1, body, inode, MDS_PACK_MD_LOCK); + mds_pack_inode2body(obd, body, inode); + mds_pack_md(obd, req->rq_repmsg, 1, body, + inode, MDS_PACK_MD_LOCK); } spin_lock(&med->med_open_lock); list_del(&mfd->mfd_list); diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 69df665..5eefba5 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -357,7 +357,7 @@ static void reconstruct_reint_setattr(struct mds_update_record *rec, } body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_inode2body(req2obd(req), body, de->d_inode, 0); + mds_pack_inode2body(req2obd(req), body, de->d_inode); /* Don't return OST-specific attributes if we didn't just set them */ if (rec->ur_iattr.ia_valid & ATTR_SIZE) @@ -465,8 +465,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset, } body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); - mds_pack_inode2body(obd, body, inode, 0); - body->id1 = *rec->ur_id1; + mds_pack_inode2body(obd, body, inode); /* Don't return OST-specific attributes if we didn't just set them */ if (rec->ur_iattr.ia_valid & ATTR_SIZE) @@ -552,14 +551,14 @@ static void reconstruct_reint_create(struct mds_update_record *rec, int offset, if ((child->d_flags & DCACHE_CROSS_REF)) { LASSERTF(child->d_inode == NULL, "BUG 3869\n"); body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_dentry2body(req2obd(req), body, child, 1); + mds_pack_dentry2body(req2obd(req), body, child); } else if (child->d_inode == NULL) { DEBUG_REQ(D_ERROR, req, "parent "DLID4" name %s mode %o", OLID4(rec->ur_id1), rec->ur_name, rec->ur_mode); LASSERTF(child->d_inode != NULL, "BUG 3869\n"); } else { body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_inode2body(req2obd(req), body, child->d_inode, 1); + mds_pack_inode2body(req2obd(req), body, child->d_inode); } l_dput(parent); l_dput(child); @@ -992,7 +991,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, MD_COUNTER_INCREMENT(obd, create); body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_inode2body(obd, body, inode, 1); + mds_pack_inode2body(obd, body, inode); } EXIT; @@ -1821,7 +1820,7 @@ static int mds_reint_unlink_remote(struct mds_update_record *rec, RETURN(-ENOMEM); memset(op_data, 0, sizeof(*op_data)); - mds_pack_dentry2id(obd, &op_data->id1, dchild, 1); + mds_pack_dentry2id(obd, &op_data->id1, dchild); op_data->create_mode = rec->ur_mode; DEBUG_REQ(D_INODE, req, "unlink %*s (remote inode "DLID4")", @@ -2032,7 +2031,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset, down(&mds->mds_pending_dir->d_inode->i_sem); cleanup_phase = 5; /* up(&pending_dir->i_sem) */ } else if (S_ISREG(child_inode->i_mode)) { - mds_pack_inode2body(obd, body, child_inode, 0); + mds_pack_inode2body(obd, body, child_inode); mds_pack_md(obd, req->rq_repmsg, offset + 1, body, child_inode, MDS_PACK_MD_LOCK); } @@ -2828,7 +2827,7 @@ static int mds_check_for_rename(struct obd_device *obd, RETURN(-ENOMEM); } memset(op_data, 0, sizeof(*op_data)); - mds_pack_dentry2id(obd, &op_data->id1, dentry, 1); + mds_pack_dentry2id(obd, &op_data->id1, dentry); it.it_op = IT_UNLINK; rc = md_enqueue(mds->mds_md_exp, LDLM_IBITS, &it, LCK_EX, @@ -3068,7 +3067,7 @@ static int mds_reint_rename_to_remote(struct mds_update_record *rec, int offset, if (de_old->d_flags & DCACHE_CROSS_REF) { LASSERT(de_old->d_inode == NULL); CDEBUG(D_OTHER, "request to move remote name\n"); - mds_pack_dentry2id(obd, &op_data->id1, de_old, 1); + mds_pack_dentry2id(obd, &op_data->id1, de_old); } else if (de_old->d_inode == NULL) { /* oh, source doesn't exist */ OBD_FREE(op_data, sizeof(*op_data)); @@ -3270,7 +3269,7 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, down(&mds->mds_pending_dir->d_inode->i_sem); cleanup_phase = 3; /* up(&pending_dir->i_sem) */ } else if (S_ISREG(new_inode->i_mode)) { - mds_pack_inode2body(obd, body, new_inode, 0); + mds_pack_inode2body(obd, body, new_inode); mds_pack_md(obd, req->rq_repmsg, 1, body, new_inode, MDS_PACK_MD_LOCK); } @@ -3282,7 +3281,7 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, if (de_old->d_flags & DCACHE_CROSS_REF) { struct lustre_id old_id; - mds_pack_dentry2id(obd, &old_id, de_old, 1); + mds_pack_dentry2id(obd, &old_id, de_old); rc = mds_add_local_dentry(rec, offset, req, &old_id, de_tgtdir, de_new, 1); -- 1.8.3.1