mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Francis Moreau <francis.moro@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: Question regarding concurrent accesses through block device and fs
Date: Mon, 23 Feb 2009 14:58:32 +1100	[thread overview]
Message-ID: <200902231458.32911.nickpiggin@yahoo.com.au> (raw)
In-Reply-To: <38b2ab8a0902200610i6c91725cjc91adca31042daa9@mail.gmail.com>

On Saturday 21 February 2009 01:10:24 Francis Moreau wrote:
> On Thu, Feb 19, 2009 at 2:44 PM, Nick Piggin <nickpiggin@yahoo.com.au> 
> > This is done for only newly allocated on-disk blocks, (which is what
> > buffer_new means, not new in-memory buffers). And it is only there to
> > synchronize buffercache access by the filesystem for its metadata, rather
> > than trying to make /dev/bdev access coherent with file access.
>
> Well I'm (still) confused by 2 things:
>
>   - the comments of unmap_underlying_metadata() doesn't sound that we're
>     dealing with meta data only:
>
>     " ... we don't want any output from any buffer-cache aliases starting
> ... "
>
>     note the word *any*. But I must admit that I don't understand the whole
>     comment.

Well buffer cache is (almost) always metadata from the filesystem pov. The
comment *could* be talking about access to /dev/bdev, but in that case the
code is doing the wrong thing WRT coherency anyway (clearing dirty bit), so
I don't see how it could be talking about that.


>   - looking at unmap_underlying_metadata(), there's no code to deal with
>     meta data buffers. It gets the buffer and unmap it whatever the type of
>     data it contains.

That's why I say it only really works for buffer cache used by the same
filesystem that is now known to be unused.


> But at least the name of this function is now more clear.
>
> > Basically what can happen is that a filesystem will have perhaps
> > allocated a block for an array of indirect pointers. The filesystem
> > manages this via the buffercache and writes a few pointers into it. Then
> > suppose the file is truncated and that block becomes unused so it can be
> > freed by the filesystem block allocator. And the filesystem may also call
> > bforget to prevent the now useless buffer from being written out in
> > future.
>
> ok, so now  the buffercache is discarded and its content is either
> discarded or is writing back.
>
> > Now suppose a new block required for *file* data, and the filesystem
> > happens to reallocate that block. So now we may still have that old
> > buffercache and buffer head around, but we also have this new pagecache
> > and buffer head for the file that points to the same block (buffer_new
> > will be set on this new buffer head, btw, to reflect that it is a newly
> > allocated block).
>
> ok
>
> > All fine so far.
> >
> > Now there is a potential problem because the old buffer can *still be
> > under writeback* dating back from when it was still good metadata and
> > before bforget was called. That's a problem because the new buffer is
> > expecting to be the owner and master of the block and its data.
>
> Now I don't see the problem.
>
> Even if the old meta data is under writeback process, the new buffer can
> still be used: since it's new there's no point to do IOs to read its
> content. If we need to write it to disk then the IOs will overwrite the old
> meta data, there's
> no risk that the old meta data overwrite the new data.
>
> What am I missing ?

That we might complete the write of the new buffer before the
old buffer is finished writing out?

Or, I suppose it also covers filesystems that do not always
discard old buffers with bforget, so they don't have dirty
bit cleared (but I don't know 100% sure if this is considered a
filesystem bug or not -- but at least unmap_underlying_metadata
protects against it).


  reply	other threads:[~2009-02-23  3:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <m2hc2yulrw.fsf@gmail.com>
2009-02-19 11:07 ` Francis Moreau
2009-02-19 13:44   ` Nick Piggin
2009-02-20 14:10     ` Francis Moreau
2009-02-23  3:58       ` Nick Piggin [this message]
2009-03-01 14:42         ` Francis Moreau
2009-03-01 15:32           ` Nick Piggin
2009-03-01 21:07             ` Francis Moreau
2009-03-02  7:11               ` Nick Piggin
2009-03-02 13:30                 ` Francis Moreau
2009-03-03  3:52                   ` Nick Piggin
2009-03-12  8:05                     ` Francis Moreau
2009-03-12  8:22                       ` Nick Piggin
2009-03-12  9:00                         ` Francis Moreau
2009-03-12  9:12                           ` Nick Piggin

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=200902231458.32911.nickpiggin@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=francis.moro@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®