linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: test for device flush-able should be after wait code
@ 2017-06-14 10:02 Anand Jain
  2017-06-14 12:26 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Anand Jain @ 2017-06-14 10:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

write_dev_flush() checks if the device is flush capable, however as
the device mode can change any time, this check should be after the
wait part of the code.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
 Fixes: c2a9c7ab475b btrfs: check if the device is flush capable
---
 fs/btrfs/disk-io.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 9f2ffe2c6afb..603a7e32e708 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3496,13 +3496,10 @@ static void btrfs_end_empty_barrier(struct bio *bio)
  */
 static int write_dev_flush(struct btrfs_device *device, int wait)
 {
-	struct request_queue *q = bdev_get_queue(device->bdev);
+	struct request_queue *devq;
 	struct bio *bio;
 	int ret = 0;
 
-	if (!test_bit(QUEUE_FLAG_WC, &q->queue_flags))
-		return 0;
-
 	if (wait) {
 		bio = device->flush_bio;
 		if (!bio)
@@ -3527,6 +3524,10 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
 		return ret;
 	}
 
+	devq = bdev_get_queue(device->bdev);
+	if (!test_bit(QUEUE_FLAG_WC, &devq->queue_flags))
+		return 0;
+
 	/*
 	 * one reference for us, and we leave it for the
 	 * caller
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-14 13:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-14 10:02 [PATCH] btrfs: test for device flush-able should be after wait code Anand Jain
2017-06-14 12:26 ` David Sterba
2017-06-14 14:01   ` Anand Jain

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).