From dda8a0261c47a52db55ccf7bd14dce657713c413 Mon Sep 17 00:00:00 2001 From: wangdi Date: Thu, 24 Aug 2006 08:37:51 +0000 Subject: [PATCH] Branch: b_new_cmd 1)add O_CHECK_STALE flags to indicate wether it should check stale in mdc_intent_lock. 2) some related fixes to make 48 pass --- lustre/include/lustre/lustre_user.h | 1 + lustre/llite/dcache.c | 32 +++++++------------------------- lustre/llite/file.c | 2 ++ lustre/mdc/mdc_locks.c | 11 +++++------ 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index 8e748fc..5183732 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -74,6 +74,7 @@ struct obd_statfs; #define O_LOV_DELAY_CREATE 0100000000 /* hopefully this does not conflict */ #define O_JOIN_FILE 0400000000 /* hopefully this does not conflict */ +#define O_CHECK_STALE 0200000000 /* hopefully this does not conflict */ #define LL_FILE_IGNORE_LOCK 0x00000001 #define LL_FILE_GROUP_LOCKED 0x00000002 diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 43c6e27..4ea16cf 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -281,30 +281,8 @@ int ll_revalidate_it_finish(struct ptlrpc_request *request, if (!request) RETURN(0); - if (it_disposition(it, DISP_LOOKUP_NEG)) { - /* Sometimes, revalidate_it might also create node in MDS, - * So we need check whether it is really created, if not, - * just return the -ENOENT, if it is, return -ESTALE anyway. - * which is original done in md_intent_lock, - * but no chance for new fid allocation in client. - */ - if (it_disposition(it, DISP_OPEN_CREATE) && - !it_open_error(DISP_OPEN_CREATE, it)) { - /* These 2 req finished is for balancing 2 add ref - * in md_intent_lock, since there are no create_node - * and file_open following revalidate_it*/ - it_set_disposition(it, DISP_ENQ_COMPLETE); - if (it_disposition(it, DISP_OPEN_CREATE) && - !it_open_error(DISP_OPEN_CREATE, it)) - ptlrpc_req_finished(request); - if (it_disposition(it, DISP_OPEN_OPEN) && - !it_open_error(DISP_OPEN_OPEN, it)) - ptlrpc_req_finished(request); - - RETURN(-ESTALE); - } + if (it_disposition(it, DISP_LOOKUP_NEG)) RETURN(-ENOENT); - } rc = ll_prep_inode(&de->d_inode, request, offset, NULL); @@ -414,7 +392,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, OBD_ALLOC_PTR(op_data); if (op_data == NULL) RETURN(-ENOMEM); - + if (it->it_op & IT_CREAT) { struct lu_placement_hint hint = { .ph_pname = NULL, .ph_pfid = ll_inode2fid(parent), @@ -423,7 +401,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, ll_prepare_md_op_data(op_data, parent, NULL, de->d_name.name, de->d_name.len, 0); - rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data->fid2, + rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data->fid2, &hint); if (rc) { CERROR("can't allocate new fid, rc %d\n", rc); @@ -481,8 +459,11 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, } do_lock: + it->it_flags |= O_CHECK_STALE; rc = md_intent_lock(exp, op_data, NULL, 0, it, lookup_flags, &req, ll_md_blocking_ast, 0); + it->it_flags &= ~O_CHECK_STALE; + OBD_FREE_PTR(op_data); /* If req is NULL, then md_intent_lock only tried to do a lock match; * if all was well, it will return 1 if it found locks, 0 otherwise. */ @@ -507,6 +488,7 @@ revalidate_finish: ll_intent_release(it); GOTO(out, rc = 0); } + if ((it->it_op & IT_OPEN) && de->d_inode && !S_ISREG(de->d_inode->i_mode) && !S_ISDIR(de->d_inode->i_mode)) { diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 86423b0..ac1b588 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2291,11 +2291,13 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) /* Call getattr by fid, so do not provide name at all. */ ll_prepare_md_op_data(op_data, dentry->d_parent->d_inode, dentry->d_inode, NULL, 0, 0); + it->it_flags |= O_CHECK_STALE; rc = md_intent_lock(exp, op_data, NULL, 0, /* we are not interested in name based lookup */ &oit, 0, &req, ll_md_blocking_ast, 0); + it->it_flags &= ~ O_CHECK_STALE; OBD_FREE_PTR(op_data); if (rc < 0) { rc = ll_inode_revalidate_fini(inode, rc); diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index af0a150..4eb55fd 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -664,7 +664,8 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, if (rc < 0) RETURN(rc); memcpy(&it->d.lustre.it_lock_handle, &lockh, sizeof(lockh)); - } else if (!fid_is_sane(&op_data->fid2)) { + } else if (!fid_is_sane(&op_data->fid2) || + !(it->it_flags & O_CHECK_STALE)) { /* DISP_ENQ_COMPLETE set means there is extra reference on * request referenced from this intent, saved for subsequent * lookup. This path is executed when we proceed to this @@ -704,13 +705,11 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, /* If we were revalidating a fid/name pair, mark the intent in * case we fail and get called again from lookup */ - if (fid_is_sane(&op_data->fid2) && - !(it->it_op & IT_GETATTR) && !(it->it_op & IT_CREAT) - && !(it->it_op & IT_OPEN && it->it_create_mode & O_CREAT)) { + if (fid_is_sane(&op_data->fid2) && it->it_flags & O_CHECK_STALE + && it->it_op != IT_GETATTR) { it_set_disposition(it, DISP_ENQ_COMPLETE); /* Also: did we find the same inode? */ - if (!it_disposition(it, DISP_OPEN_CREATE) && - memcmp(&op_data->fid2, &mdt_body->fid1, + if (memcmp(&op_data->fid2, &mdt_body->fid1, sizeof(op_data->fid2))) RETURN(-ESTALE); } -- 1.8.3.1