All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Myers <bpm@sgi.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	"J. Bruce Fields" <bfields@fieldses.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC] freeing unlinked file indefinitely delayed
Date: Mon, 13 Jul 2015 13:17:51 -0500	[thread overview]
Message-ID: <20150713181751.GZ4568@sgi.com> (raw)
In-Reply-To: <20150712150035.GJ17109@ZenIV.linux.org.uk>

Hey Al,

On Sun, Jul 12, 2015 at 04:00:35PM +0100, Al Viro wrote:
> On Wed, Jul 08, 2015 at 10:41:43AM -0500, Ben Myers wrote:
> 
> > The bug rings a bell for me so I will stick my neck out instead of
> > lurking.  Don't you need to sample that link count under the filesystems
> > internal lock in order to avoid an unlink/iget race?  I suggest creating
> > a helper to prune disconnected dentries which a filesystem could call in
> > .unlink.  That would avoid the risk of unintended side effects with the
> > d_alloc/d_free/icache approach and have provable link count correctness.
> 
> For one thing, this patch does *not* check for i_nlink at all.

I agree that no checking of i_nlink has the advantage of brevity.
Anyone who is using dentry.d_fsdata with an open_by_handle workload (if
there are any) will be affected.

> For another, there's no such thing as 'filesystems internal lock' for
> i_nlink protection - that's handled by i_mutex...  And what does
> iget() have to do with any of that?

i_mutex is good enough only for local filesystems.
Network/clustered/distributed filesystems need to take an internal lock
to provide exclusion for this .unlink with a .link on another host.
That's where I'm coming from with iget().  

Maybe plumbing i_op.unlink with another argument to return i_nlink is
something to consider?  A helper for the few filesystems that need to do
this might be good enough in the near term.

Thanks,
Ben

  reply	other threads:[~2015-07-13 18:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08  1:42 [RFC] freeing unliked file indefinitely delayed Al Viro
2015-07-08  2:39 ` J. Bruce Fields
2015-07-08 15:41 ` Ben Myers
2015-07-12 15:00   ` [RFC] freeing unlinked " Al Viro
2015-07-13 18:17     ` Ben Myers [this message]
2015-07-13 19:56       ` Al Viro
2015-07-14  0:54         ` Ben Myers
2015-07-09 11:17 ` [RFC] freeing unliked " Ian Kent
2015-07-09 11:26   ` Ian Kent
2015-07-12 15:17     ` [RFC] freeing unlinked " Al Viro
2015-07-13  2:30       ` Ian Kent

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=20150713181751.GZ4568@sgi.com \
    --to=bpm@sgi.com \
    --cc=bfields@fieldses.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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.