From: braam Date: Wed, 21 Aug 2002 19:05:40 +0000 (+0000) Subject: - redo rename to instantiate d_new on the client, instead of X-Git-Tag: 0.5.5~103 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=cf372c0e4ab0097ab39484d4d40db21dc7e823d2;p=fs%2Flustre-release.git - redo rename to instantiate d_new on the client, instead of trying to bypass that step (and run into troubles). --- diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index cc5412f..128b361 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -155,12 +155,6 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry, if (dentry->d_name.len > EXT2_NAME_LEN) RETURN(ERR_PTR(-ENAMETOOLONG)); - if (it->it_op == IT_RENAME2) { - /* Set below to be the old dentry from the IT_RENAME intent */ - inode = ((struct dentry *)(it->it_data))->d_inode; - LASSERT(inode); - } - err = ll_lock(dir, dentry, it, &lockh); if (err < 0) RETURN(ERR_PTR(err)); @@ -190,11 +184,12 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry, if (it->it_status && it->it_status != -EEXIST) GOTO(neg_req, NULL); } else if (it->it_op == IT_RENAME2) { - /* FIXME: make old_de negative, and drop - * new_de->d_inode if needed. - */ + struct mds_body *body = + lustre_msg_buf(request->rq_repmsg, offset); it->it_data = NULL; - GOTO(out_req, NULL); + if (body->valid == 0) + GOTO(neg_req, NULL); + GOTO(iget, NULL); } /* Do a getattr now that we have the lock */ @@ -249,7 +244,6 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry, /* No rpc's happen during iget4, -ENOMEM's are possible */ inode = iget4(dir->i_sb, ino, ll_find_inode, &md); - out_req: LASSERT(!IS_ERR(inode)); if (!inode) { ptlrpc_free_req(request); @@ -643,12 +637,18 @@ static int ll_rename(struct inode * old_dir, struct dentry * old_dentry, struct inode * new_inode = new_dentry->d_inode; struct page * dir_page = NULL; struct ext2_dir_entry_2 * dir_de = NULL; - struct page * old_page; struct ext2_dir_entry_2 * old_de; + struct page * old_page; int err = -ENOENT; - if (new_dentry->d_it && new_dentry->d_it->it_disposition) + if (new_dentry->d_it && new_dentry->d_it->it_disposition) { + if (new_inode) { + new_inode->i_ctime = CURRENT_TIME; + new_inode->i_nlink--; + dput(new_dentry); + } GOTO(out, err = new_dentry->d_it->it_status); + } err = ll_mdc_rename(old_dir, new_dir, old_dentry, new_dentry); if (err) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index bd5badd..b8cac01 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -281,7 +281,7 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type, mds_rename_pack(req, 2, old_de->d_parent->d_inode, dir, old_de->d_name.name, old_de->d_name.len, de->d_name.name, de->d_name.len); - req->rq_replen = lustre_msg_size(1, repsize); + req->rq_replen = lustre_msg_size(3, repsize); } else if (it->it_op == IT_UNLINK || it->it_op == IT_RMDIR) { size[2] = sizeof(struct mds_rec_unlink); size[3] = de->d_name.len + 1; diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index aac4edb..11b3dda 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1205,7 +1205,7 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie, struct mds_body *mds_rep; struct ldlm_reply *rep; __u64 new_resid[3] = {0, 0, 0}, old_res; - int bufcount = -1, rc, size[3] = {sizeof(struct ldlm_reply), + int rc, size[3] = {sizeof(struct ldlm_reply), sizeof(struct mds_body), mds->mds_max_mdsize}; @@ -1214,34 +1214,7 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie, LDLM_DEBUG(lock, "intent policy, opc: %s", ldlm_it2str(it->opc)); - /* prepare reply */ - switch((long)it->opc) { - case IT_GETATTR: - /* Note that in the negative case you may be returning - * a file and its obdo */ - case IT_CREAT: - case IT_CREAT|IT_OPEN: - case IT_LINK: - case IT_LOOKUP: - case IT_MKDIR: - case IT_MKNOD: - case IT_OPEN: - case IT_READLINK: - case IT_RENAME: - case IT_RMDIR: - case IT_SETATTR: - case IT_SYMLINK: - case IT_UNLINK: - bufcount = 3; - break; - case IT_RENAME2: - bufcount = 1; - break; - default: - LBUG(); - } - - rc = lustre_pack_msg(bufcount, size, NULL, &req->rq_replen, + rc = lustre_pack_msg(3, size, NULL, &req->rq_replen, &req->rq_repmsg); if (rc) { rc = req->rq_status = -ENOMEM; diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index ab2409f..d8e764a 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -637,6 +637,30 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, rec->ur_tgtlen - 1, rec->ur_tgt, PTR_ERR(de_new)); GOTO(out_rename_deold, rc = -ENOENT); } + + /* in intent case ship back attributes to client */ + if (offset) { + struct mds_body *body = lustre_msg_buf(req->rq_repmsg, 1); + struct inode *inode = de_new->d_inode; + + if (!inode) { + body->valid = 0; + } else { + mds_pack_inode2fid(&body->fid1, inode); + mds_pack_inode2body(body, inode); + if (S_ISREG(inode->i_mode)) { + struct lov_mds_md *md; + + md = lustre_msg_buf(req->rq_repmsg, 2); + md->lmd_easize = mds->mds_max_mdsize; + if ((rc = mds_fs_get_md(mds, inode, md)) < 0) { + CDEBUG(D_INFO,"No md for %ld: rc %d\n", + inode->i_ino, rc); + memset(md, 0, md->lmd_easize); + } + } + } + } OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_RENAME_WRITE, de_srcdir->d_inode->i_sb->s_dev);