mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Joshua Hudson" <joshudson@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: RFC replace some locking of i_sem wiht atomic_t
Date: Sun, 2 Apr 2006 11:01:30 -0700	[thread overview]
Message-ID: <bda6d13a0604021101h6cd362efn6d832bfb1275080c@mail.gmail.com> (raw)
In-Reply-To: <bda6d13a0603311608p5b74df13i259c2b9efa539330@mail.gmail.com>

On 3/31/06, Joshua Hudson <joshudson@gmail.com> wrote:
> This might be a way to decrease complexity of locking in vfs.
>
> Basic idea: for local filesystems, i_sem gets taken on several objects
> only to protect i_nlink.
> These can be removed if i_nlink is atomic.
>
That doesn't work. Some code in affs I don't understand and the code in ext2
that checks for maximum hard links basically makes this not work. The
ext2 problem is solvable in assembly (adding a new atomic_* operation),
but the affs problem is not.

Scratch that idea.

Herein lies the problem with the current locking scheme:
1. rename locks target if it exists, but target may be created by
link() immediately
after the check&lock procedure.
2. The target of link() is completely unprotected.

Against ext2, this can result in a corrupted filesystem (two directory
entries with
the same name) by a three-way race between two instances of link() and one
unlink().

1. Both instances of link are started with target being the same name
in the same directory.
2. unlink() is started on a different name in the same directory.
3. link() 1 doesn't find a free slot in the first page, moves to the second.
    *rescheduled before locking second page*
4. unlink() finds target in first page, removes it.
5. link() 2 finds free slot in first page, creates entry, finishes
6. link() 1 continues, finds space in second page, creates entry

  reply	other threads:[~2006-04-02 18:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-01  0:08 Joshua Hudson
2006-04-02 18:01 ` Joshua Hudson [this message]
2006-04-02 18:43   ` Al Viro
     [not found]     ` <bda6d13a0604021508g3cc03506yce0170166dc0eda2@mail.gmail.com>
2006-04-02 22:09       ` Joshua Hudson

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=bda6d13a0604021101h6cd362efn6d832bfb1275080c@mail.gmail.com \
    --to=joshudson@gmail.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

all inboxes | Powered by JetHome®