From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH 3/3 v2.2] btrfs: wait part of the write_dev_flush() can be separated out
Date: Wed, 14 Jun 2017 18:12:30 +0800 [thread overview]
Message-ID: <1497435150-961-1-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1497346349-1194-1-git-send-email-anand.jain@oracle.com>
Submit and wait parts of write_dev_flush() can be split into two
separate functions for better readability.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2.2: Make it conflict free patch on top of
[PATCH] btrfs: test for device flush-able should be after wait code
There is no other changes. Sorry for another version. Thxs.
v2.1: Part of commit log got missed out during send. fix it.
v2: . Add the removal of submit_flush_error in check_barrier_error()
from 2/2 before to 1/3 here, as its appropriate to be here.
. Did not split the write and wait part here in this patch.
fs/btrfs/disk-io.c | 60 ++++++++++++++++++++++++++++--------------------------
1 file changed, 31 insertions(+), 29 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 42bb674028f6..9b9375469134 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3488,39 +3488,17 @@ static void btrfs_end_empty_barrier(struct bio *bio)
}
/*
- * trigger flushes for one the devices. If you pass wait == 0, the flushes are
- * sent down. With wait == 1, it waits for the previous flush.
- *
- * any device where the flush fails with eopnotsupp are flagged as not-barrier
- * capable
+ * Submit a flush request to the device if it supports it. Error handling is
+ * done in the waiting counterpart.
*/
-static int write_dev_flush(struct btrfs_device *device, int wait)
+static void write_dev_flush(struct btrfs_device *device)
{
struct request_queue *devq;
struct bio *bio;
- int ret = 0;
-
- if (wait) {
- bio = device->flush_bio;
-
- wait_for_completion(&device->flush_wait);
-
- if (bio->bi_error) {
- ret = bio->bi_error;
- btrfs_dev_stat_inc_and_print(device,
- BTRFS_DEV_STAT_FLUSH_ERRS);
- }
-
- /* drop the reference from the wait == 0 run */
- bio_put(bio);
- device->flush_bio = NULL;
-
- return ret;
- }
devq = bdev_get_queue(device->bdev);
if (!test_bit(QUEUE_FLAG_WC, &devq->queue_flags))
- return 0;
+ return;
/*
* one reference for us, and we leave it for the
@@ -3537,8 +3515,32 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
bio_get(bio);
btrfsic_submit_bio(bio);
+}
- return 0;
+/*
+ * If the flush bio has been submitted by write_dev_flush, wait for it.
+ */
+static int wait_dev_flush(struct btrfs_device *device)
+{
+ int ret = 0;
+ struct bio *bio = device->flush_bio;
+
+ if (!bio)
+ return 0;
+
+ wait_for_completion(&device->flush_wait);
+
+ if (bio->bi_error) {
+ ret = bio->bi_error;
+ btrfs_dev_stat_inc_and_print(device,
+ BTRFS_DEV_STAT_FLUSH_ERRS);
+ }
+
+ /* drop the reference from the wait == 0 run */
+ bio_put(bio);
+ device->flush_bio = NULL;
+
+ return ret;
}
static int check_barrier_error(struct btrfs_fs_devices *fsdevs)
@@ -3579,7 +3581,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
if (!dev->in_fs_metadata || !dev->writeable)
continue;
- write_dev_flush(dev, 0);
+ write_dev_flush(dev);
dev->last_flush_error = 0;
}
@@ -3594,7 +3596,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
if (!dev->in_fs_metadata || !dev->writeable)
continue;
- ret = write_dev_flush(dev, 1);
+ ret = wait_dev_flush(dev);
if (ret) {
dev->last_flush_error = ret;
errors_wait++;
--
2.7.0
prev parent reply other threads:[~2017-06-14 10:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 9:05 [PATCH 1/3 v2] btrfs: write_dev_flush does not return ENOMEM anymore Anand Jain
2017-06-13 9:05 ` [PATCH 2/3 v2] btrfs: remove redundant null bdev counting during flush submit Anand Jain
2017-06-13 9:05 ` [PATCH 3/3 v2] btrfs: wait part of the write_dev_flush() can be separated out Anand Jain
2017-06-13 9:32 ` [PATCH 1/3 v2.1] btrfs: write_dev_flush does not return ENOMEM anymore Anand Jain
2017-06-13 15:23 ` David Sterba
2017-06-14 9:01 ` Anand Jain
2017-06-15 16:27 ` David Sterba
2017-06-15 20:29 ` Anand Jain
2017-06-14 10:12 ` Anand Jain [this message]
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=1497435150-961-1-git-send-email-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@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;
as well as URLs for NNTP newsgroup(s).