From: Mikulas Patocka <mpatocka@redhat.com>
To: ndevos@redhat.com
Cc: linux-kernel@vger.kernel.org, bmr@redhat.com
Subject: Re: [PATCH] block: Invalidate the cache for a parent block-device
Date: Thu, 19 Jan 2012 20:58:39 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.64.1201192057540.17908@hs20-bc2-1.build.redhat.com> (raw)
Hi
This definitely doesn't belong to blkdev_issue_flush.
blkdev_issue_flush is called by filesystems each time they want to
synchronize hardware disk cache (for example, when committing a journal).
The patch may cause serious performance regressions (each time a
filesystem commits journal, the patch causes it to walk all buffers in the
whole-disk device).
You should put this code into fsync_bdev (so that it is called only on
fsync or BLKFLSBUF) and not to blkdev_issue_flush.
Mikulas
> Executing a BLKFLSBUF-ioctl on a partition flushes the caches for that
> partition but reading data through the parent device will still return
> the old cached data.
>
> The cache for the block-device is not synced if the block-device is kept
> open (due to a mounted partition, for example). Only when all users for
> the disk have exited, the cache for the disk is made consistent again.
>
> Calling invalidate_bdev() on the parent block-device in case
> blkdev_issue_flush() was called for a partition fixes this.
>
> The problem can be worked around by forcing the caches to be flushed
> with either
> # blockdev --flushbufs ${dev_disk}
> or
> # echo 3 > /proc/sys/vm/drop_caches
>
> CC: Bryn M. Reeves <bmr <at> redhat.com>
> Signed-off-by: Niels de Vos <ndevos <at> redhat.com>
> ---
> block/blk-flush.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/block/blk-flush.c b/block/blk-flush.c
> index 720ad60..e876f8e 100644
> --- a/block/blk-flush.c
> +++ b/block/blk-flush.c
> @@ -448,6 +448,9 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_
>
> if (!bio_flagged(bio, BIO_UPTODATE))
> ret = -EIO;
> + else if (bdev != bdev->bd_contains)
> + /* invalidate parent block_device */
> + invalidate_bdev(bdev->bd_contains);
>
> bio_put(bio);
> return ret;
> --
> 1.7.6.5
>
next reply other threads:[~2012-01-20 1:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-20 1:58 Mikulas Patocka [this message]
2012-01-20 9:35 ` [PATCH] block: Invalidate the cache for a parent block-device Niels de Vos
2012-01-23 10:38 ` [PATCH v2] fs: Invalidate the cache for a parent block-device if fsync() is called for a partition Niels de Vos
2012-01-23 16:27 ` Jeff Moyer
2012-01-23 16:46 ` Niels de Vos
2012-01-23 19:23 ` Mikulas Patocka
2012-01-23 20:04 ` Jeff Moyer
2012-01-26 10:03 ` Andrew Morton
2012-01-26 11:50 ` Niels de Vos
2012-01-26 13:33 ` [PATCH v3] " Niels de Vos
2012-01-26 21:40 ` Andrew Morton
2012-01-26 21:45 ` Christoph Hellwig
2012-01-26 21:50 ` Mikulas Patocka
2012-01-27 12:19 ` Ric Wheeler
2012-01-31 16:00 ` Niels de Vos
2012-01-31 18:58 ` Andrew Morton
2012-01-31 19:04 ` Christoph Hellwig
2012-01-31 19:32 ` Andrew Morton
2012-01-31 19:37 ` Christoph Hellwig
2012-01-31 19:48 ` Andrew Morton
2012-01-26 21:49 ` Jeff Moyer
2012-01-26 22:13 ` Mikulas Patocka
2012-01-26 22:26 ` Kernel Oops report (Android gingerbread) Fan Zhang
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.1201192057540.17908@hs20-bc2-1.build.redhat.com \
--to=mpatocka@redhat.com \
--cc=bmr@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ndevos@redhat.com \
/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).