From: viro@parcelfarce.linux.theplanet.co.uk
To: Maurice van der Stee <stee@planet.nl>
Cc: linux-kernel@vger.kernel.org, Linus Torvalds <torvalds@osdl.org>
Subject: Re: 2.6.4-rc1 oops on HPFS filesystem file rename
Date: Sun, 29 Feb 2004 13:14:25 +0000 [thread overview]
Message-ID: <20040229131425.GH16357@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20040229113130.GA577@maurice.stee.nl>
On Sun, Feb 29, 2004 at 12:31:30PM +0100, Maurice van der Stee wrote:
> I think I tested most of the basic file system operations, rename,
> move, copy, edit, truncate etc. and found no problems with the second
> patch applied..
Actually, I've found a problem with the original - race between write_inode()
and cross-directory rename(), of all things. Mind testing the patchset on
ftp.linux.org.uk/pub/people/viro/HPFS*? First two patches were posted in
this thread, the rest goes on top of them.
Race in question is funny, BTW - write_inode() might have to find and
update directory entry in the parent, so it gets the parent inode and locks
it (that's what hpfs-private lock was for - it gave exclusion between
directory modifications and write_inode() directory entry update; directory
entries can move on insertion/removal, so we need to make sure that it
won't happen during that updating). The trouble being, it did not make
sure that we lock the right directory - if rename() had moved the file
in question while we were trying to lock the parent, we would end up with
very confused write_inode().
Similar race exists for unlink() vs. write_inode() - the latter checks
->i_nlink, but there is no warranty that it won't become 0 between the
check and locking the parent. Ditto for rmdir() and overwriting rename().
The fix is simple: we turn semaphore into sempahore + rwsem and
1) on mkdir/mknod/create/symlink grab rwsem on parent for writing
2) on rmdir/unlink/rename we grab semaphore on victim and object
being moved, then grab rwsem on parent(s) for writing.
3) on write_inode we grab semaphore on inode, then check that
it has non-zero ->i_nlink, get parent and grab rwsem on parent for reading.
Exclusion already provided by VFS makes order in rename() (there we might
get two semaphores and two rwsems) a non-issue - we already have all ->rename()
on given fs serialized. Order among semaphores and among rwsems, that is -
semaphores are always taken first.
Aside of that, patchset switches from use of iget() to use of iget_locked(),
which allows to kill the horrors in hpfs_lock_iget(), and does general
cleanup.
Unless there are complaints and bug reports, it will go to Linus in a couple
of days.
next prev parent reply other threads:[~2004-02-29 13:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-28 17:12 Maurice van der Stee
2004-02-28 19:06 ` viro
2004-02-29 11:31 ` Maurice van der Stee
2004-02-29 13:14 ` viro [this message]
2004-02-29 13:58 ` viro
2004-02-29 14:41 ` viro
-- strict thread matches above, loose matches on Subject: below --
2004-02-28 11:04 Maurice van der Stee
2004-02-28 11:42 ` viro
2004-02-28 17:05 ` Diego Calleja
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=20040229131425.GH16357@parcelfarce.linux.theplanet.co.uk \
--to=viro@parcelfarce.linux.theplanet.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=stee@planet.nl \
--cc=torvalds@osdl.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
all inboxes | Powered by JetHome®