linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: viro@zeniv.linux.org.uk,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix bmap-vs-truncate race
Date: Tue, 31 Mar 2009 18:42:34 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0903311728530.32061@hs20-bc2-1.build.redhat.com> (raw)
In-Reply-To: <20090331175451.GA19484@infradead.org>

On Tue, 31 Mar 2009, Christoph Hellwig wrote:

> On Mon, Mar 30, 2009 at 03:20:24PM -0400, Mikulas Patocka wrote:
> > Hi
> > 
> > I'm submitting this patch for 2.6.30 merge window.
> 
> Please not.  i_alloc_sem is really a horrible hack needed for a couple
> filesystems only and we should not leak it into more generic code but
> rather move the few instances into the filesystem.

Could you please document locking rules for get_block(), truncate, bmap & 
direct i/o in Documentation/filesystems/Locking ?

There is a lot of text about directories, but nothing about locking of 
block mappings.

I was living under an impression that get_block() cannot be called on a 
block that is being truncated. That's what read/write/direct-io vs 
truncate seems to guarante --- truncate will first lower i_size 
(preventing any new pages past i_size from being created), then destroy 
any existing pages past i_size (that includes waiting for pagelock until 
all get_blocks on that page end) and finally truncate the metadata on the 
filesystem.

So there should be no situation when you truncate block and call get_block 
on it simultaneously. If get_block can race with truncate, document it.

There are filesystems that don't do any locking on get_block() (for 
example UFS, HPFS; FAT does it only for bmap and doesn't do it for general 
accesses) and other filesystems verify indirect block chains obsessively 
if they were truncated under get_block (why? because of bmap? or some 
other possibility?) --- so the rules should really be documented.

Mikulas

  reply	other threads:[~2009-03-31 22:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-30 19:20 [PATCH] fix bmap-vs-truncate race Mikulas Patocka
2009-03-31 14:48 ` Aneesh Kumar K.V
2009-03-31 17:54 ` Christoph Hellwig
2009-03-31 22:42   ` Mikulas Patocka [this message]
2009-04-01 11:36     ` Al Viro
2009-04-02 23:22       ` Mikulas Patocka

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=Pine.LNX.4.64.0903311728530.32061@hs20-bc2-1.build.redhat.com \
    --to=mpatocka@redhat.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 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).