[05/15] btrfs: optimize btrfs_check_degradable() for calls outside of barrier
diff mbox

Message ID 1447066589-3835-6-git-send-email-anand.jain@oracle.com
State New
Headers show

Commit Message

Anand Jain Nov. 9, 2015, 10:56 a.m. UTC
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/disk-io.c | 8 +++++++-
 fs/btrfs/volumes.c | 2 --
 2 files changed, 7 insertions(+), 3 deletions(-)

Patch
diff mbox

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 958c2a6..d3303f9 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3428,6 +3428,7 @@  static int write_dev_flush(struct btrfs_device *device, int wait)
 /*
  * send an empty flush down to each device in parallel,
  * then wait for them
+ * fixme: optimize err_wait, err_send.
  */
 static int barrier_all_devices(struct btrfs_fs_info *info)
 {
@@ -3467,8 +3468,13 @@  static int barrier_all_devices(struct btrfs_fs_info *info)
 		if (ret)
 			dev->err_wait = 1;
 	}
-	if (btrfs_check_degradable(info, info->sb->s_flags) < 0)
+	if (btrfs_check_degradable(info, info->sb->s_flags) < 0) {
+		dev->err_send = 0;
+		dev->err_wait = 0;
 		return -EIO;
+	}
+	dev->err_send = 0;
+	dev->err_wait = 0;
 	return 0;
 }
 
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8acf69b..a5262bf 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6848,8 +6848,6 @@  int btrfs_check_degradable(struct btrfs_fs_info *fs_info, unsigned flags)
 			    map->stripes[i].dev->err_wait ||
 			    map->stripes[i].dev->err_send)
 				missing++;
-			map->stripes[i].dev->err_wait = 0;
-			map->stripes[i].dev->err_send = 0;
 		}
 		if (missing > max_tolerated) {
 			ret = -EIO;