From: "J. Bruce Fields" <bfields@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: Christoph Hellwig <hch@infradead.org>,
Al Viro <viro@ZenIV.linux.org.uk>,
linux-nfs@vger.kernel.org
Subject: simplify reconnecting dentries looked up by filehandle
Date: Tue, 15 Oct 2013 16:39:28 -0400 [thread overview]
Message-ID: <1381869574-10662-1-git-send-email-bfields@redhat.com> (raw)
When we lookup a filehandle for a directory not already in the dentry
cache, fs/exportfs/expfs.c:reconnect_path() is what populates the dentry
cache with the directory and its parents.
The current code looks more complicated than necessary:
- after looking up the parent, it searches the parent directory
for our target dentry. If that search fails with -ENOENT, it
retries up to 10 times. I don't understand why. This should
only happen if there's a concurrent rename or rmdir, in which
case that concurrent operation should have reconnected the
dentry for us, and we're done.
- each time it succesfully connects a dentry to its parent, it
restarts from scratch with the original dentry. Why not
continue working with the parent we just found?
Have I missed some reason that we need the more complicated approach?
Patches showing my attempted simplification follow.
Most of the work is in the last patch (which I didn't manage to break up
as well as I'd like), but there's also a smaller optimization in the
first patch.
I tested performance with a script that creates an N-deep directory
tree, gets a filehandle for the bottom directory, writes 2 to
/proc/sys/vm/drop_caches, then times an open_by_handle_at() of the
filehandle. Code at
git://linux-nfs.org/~bfields/fhtests.git
For directories of various depths, some example observed times (median
results of 3 similar runs, in seconds), were:
depth: 8000 2000 200
no patches: 11 0.7 0.02
first patch: 6 0.4 0.01
all patches: 0.1 0.03 0.01
For depths < 2000 I used an ugly hack to shrink_slab_node() to force
drop_caches to free more dentries. Difference look lost in the noise
for much smaller depths.
Nesting that deep sounds crazy to me, and cold lookup of a
filehandle isn't the common case. But maybe it's worth not having to
worry about the awful performance in these pathalogical cases. And it
does simplify the code.
--b.
next reply other threads:[~2013-10-15 20:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-15 20:39 J. Bruce Fields [this message]
2013-10-15 20:39 ` [PATCH 1/5] exportfs: clear DISCONNECTED on all parents sooner J. Bruce Fields
2013-10-16 7:13 ` Christoph Hellwig
2013-10-16 7:13 ` Christoph Hellwig
2013-10-16 13:56 ` J. Bruce Fields
2013-10-16 13:56 ` J. Bruce Fields
2013-10-15 20:39 ` [PATCH 2/5] exportfs: move most of reconnect_path to helper function J. Bruce Fields
2013-10-16 7:16 ` Christoph Hellwig
2013-10-16 7:16 ` Christoph Hellwig
2013-10-15 20:39 ` [PATCH 3/5] exportfs: make variable names more helpful J. Bruce Fields
2013-10-15 20:39 ` J. Bruce Fields
2013-10-16 7:18 ` Christoph Hellwig
2013-10-16 7:18 ` Christoph Hellwig
2013-10-15 20:39 ` [PATCH 4/5] exportfs: slight reorganization of reconnect loop J. Bruce Fields
2013-10-16 7:19 ` Christoph Hellwig
2013-10-15 20:39 ` [PATCH 5/5] exportfs: fix quadratic behavior in filehandle lookup J. Bruce Fields
2013-10-15 20:39 ` J. Bruce Fields
2013-10-16 8:04 ` Christoph Hellwig
2013-10-16 8:04 ` Christoph Hellwig
2013-10-16 18:29 ` J. Bruce Fields
2013-10-16 19:22 ` J. Bruce Fields
2013-10-16 22:00 ` J. Bruce Fields
2013-10-16 18:24 ` simplify reconnecting dentries looked up by filehandle Christoph Hellwig
2013-10-16 18:24 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1381869574-10662-1-git-send-email-bfields@redhat.com \
--to=bfields@redhat.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.