linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Mason <mason@suse.com>
To: Oleg Drokin <green@namesys.com>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [2.5] reiserfs: fix races between link and unlink on same file
Date: 01 Aug 2003 10:05:40 -0400	[thread overview]
Message-ID: <1059746739.5881.20.camel@tiny.suse.com> (raw)
In-Reply-To: <20030801111027.GA1108@namesys.com>

On Fri, 2003-08-01 at 07:10, Oleg Drokin wrote:
> Hello!
> 
> On Thu, Jul 31, 2003 at 01:37:08PM -0700, Andrew Morton wrote:
> 
> > > This patch (originally by Chris Mason) fixes link/unlink races in reiserfs.
> > Could you describe the race a little more please?  Why is the VFS's hold of
> > i_sem on the parent directory not sufficient?
> 
> Well, we do not take i_sem on parent directory of source filename for sys_link, I think.
> So we might endup in sys_link() with inode that is already deleted/being deleted (and nlink==0).
> Actually, I naturally thought that only i_nlink check to be non zero at reiserfs_link time should be
> enough, but Chris is sure that we need entire patch, so may be he may add more comments to that.
> 

Yes, it's basically a problem of making sure reiserfs_link sees any
changes made by reiserfs_unlink and vice versa.  Toss in the BKL and a
few funcs that schedule and you get small windows where the object
you're linking to can have a inode->i_nlink of zero.

All of which is dealt with properly at the VFS level.  The trick in
reiserfs is that somebody needs to take care of removing the savelink
used to prevent lost files after a crash.  If we don't get the i_nlink
timing right, two different procs might try to remove the savelink, or
it might not get removed at all.

> BTW, looking at vfs_link, this patch (below the message) seems to be
> natural thing to do, is not it?
> 

Looks fine.

-chris



      reply	other threads:[~2003-08-01 14:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-31 14:42 [PATCH] [2.5] reiserfs: fix races between link and unlink on same file Oleg Drokin
2003-07-31 20:37 ` Andrew Morton
2003-08-01 11:10   ` Oleg Drokin
2003-08-01 14:05     ` Chris Mason [this message]

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=1059746739.5881.20.camel@tiny.suse.com \
    --to=mason@suse.com \
    --cc=akpm@osdl.org \
    --cc=green@namesys.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 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).