From: Oleg Drokin Date: Wed, 6 Jul 2016 00:35:30 +0000 (-0400) Subject: LU-8371 llite: optimize atomic_open of negative dentry. X-Git-Tag: 2.8.57~47 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=7334a2d33cc4cf4cda0c81b126c4cb8ab28a888d;p=fs%2Flustre-release.git LU-8371 llite: optimize atomic_open of negative dentry. No point in talking to MDS in that case if we are not creating, just return -ENOENT. Change-Id: I15c00fdc841e5e9d4d1923b2353f7fdc5910d67b Signed-off-by: Oleg Drokin Reviewed-on: http://review.whamcloud.com/21161 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Andreas Dilger --- diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 89624e6..b78ad91 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -466,6 +466,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, struct inode *inode = NULL; __u64 bits = 0; int rc; + struct dentry *alias; ENTRY; /* NB 1 request reference will be taken away by ll_intent_lock() @@ -492,21 +493,11 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, /* Only hash *de if it is unhashed (new dentry). * Atoimc_open may passin hashed dentries for open. */ - if (d_unhashed(*de)) { - struct dentry *alias; - - alias = ll_splice_alias(inode, *de); - if (IS_ERR(alias)) - GOTO(out, rc = PTR_ERR(alias)); - - *de = alias; - } else if (!it_disposition(it, DISP_LOOKUP_NEG) && - !it_disposition(it, DISP_OPEN_CREATE)) { - /* With DISP_OPEN_CREATE dentry will - instantiated in ll_create_it. */ - LASSERT((*de)->d_inode == NULL); - d_instantiate(*de, inode); - } + alias = ll_splice_alias(inode, *de); + if (IS_ERR(alias)) + GOTO(out, rc = PTR_ERR(alias)); + + *de = alias; if (!it_disposition(it, DISP_LOOKUP_NEG)) { /* we have lookup look - unhide dentry */ @@ -708,6 +699,24 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, dentry->d_name.len, dentry->d_name.name, PFID(ll_inode2fid(dir)), dir, file, open_flags, mode, *opened); + /* Only negative dentries enter here */ + LASSERT(dentry->d_inode == NULL); + + if (!d_unhashed(dentry)) { + /* A valid negative dentry that just passed revalidation, + * there's little point to try and open it server-side, + * even though there's a minuscule chance it might succeed. + * Either way it's a valid race to just return -ENOENT here. + */ + if (!(open_flags & O_CREAT)) + return -ENOENT; + + /* Otherwise we just unhash it to be rehashed afresh via + * lookup if necessary + */ + d_drop(dentry); + } + OBD_ALLOC(it, sizeof(*it)); if (!it) RETURN(-ENOMEM);