All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niels de Vos <ndevos@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org, Niels de Vos <ndevos@redhat.com>,
	"Bryn M. Reeves" <bmr@redhat.com>
Subject: [PATCH] block: Invalidate the cache for a parent block-device if blkdev_issue_flush() was called for a partition
Date: Thu, 19 Jan 2012 08:50:38 +0000	[thread overview]
Message-ID: <4F17D95E.7070403@redhat.com> (raw)

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@redhat.com>
Signed-off-by: Niels de Vos <ndevos@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_mask,
 
 	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


             reply	other threads:[~2012-01-19  8:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-19  8:50 Niels de Vos [this message]
2012-01-19 15:06 ` [PATCH] block: Invalidate the cache for a parent block-device if blkdev_issue_flush() was called for a partition Bryn M. Reeves

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=4F17D95E.7070403@redhat.com \
    --to=ndevos@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bmr@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.