linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* simplify reconnecting dentries looked up by filehandle
@ 2013-10-15 20:39 J. Bruce Fields
  2013-10-15 20:39 ` [PATCH 1/5] exportfs: clear DISCONNECTED on all parents sooner J. Bruce Fields
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: J. Bruce Fields @ 2013-10-15 20:39 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Christoph Hellwig, Al Viro, linux-nfs

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.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-10-16 22:39 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-15 20:39 simplify reconnecting dentries looked up by filehandle J. Bruce Fields
2013-10-15 20:39 ` [PATCH 1/5] exportfs: clear DISCONNECTED on all parents sooner J. Bruce Fields
     [not found]   ` <1381869574-10662-2-git-send-email-bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-10-16  7:13     ` Christoph Hellwig
     [not found]       ` <20131016071343.GB27799-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
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
     [not found]   ` <1381869574-10662-3-git-send-email-bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-10-16  7:16     ` 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
     [not found] ` <1381869574-10662-1-git-send-email-bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-10-15 20:39   ` [PATCH 3/5] exportfs: make variable names more helpful J. Bruce Fields
     [not found]     ` <1381869574-10662-4-git-send-email-bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-10-16  7:18       ` Christoph Hellwig
2013-10-15 20:39   ` [PATCH 5/5] exportfs: fix quadratic behavior in filehandle lookup J. Bruce Fields
     [not found]     ` <1381869574-10662-6-git-send-email-bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).