All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: disable FUA if mounted with nobarrier
@ 2017-12-06  6:54 Omar Sandoval
  2017-12-06  7:11 ` Qu Wenruo
  2017-12-06 14:20 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Omar Sandoval @ 2017-12-06  6:54 UTC (permalink / raw)
  To: linux-btrfs; +Cc: kernel-team

From: Omar Sandoval <osandov@fb.com>

I was seeing disk flushes still happening when I mounted a Btrfs
filesystem with nobarrier for testing. This is because we use FUA to
write out the first super block, and on devices without FUA support, the
block layer translates FUA to a flush. Even on devices supporting true
FUA, using FUA when we asked for no barriers is surprising.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 fs/btrfs/disk-io.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 10a2a579cc7f..a8ecccfc36de 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3231,6 +3231,7 @@ static int write_dev_supers(struct btrfs_device *device,
 	int errors = 0;
 	u32 crc;
 	u64 bytenr;
+	int op_flags;
 
 	if (max_mirrors == 0)
 		max_mirrors = BTRFS_SUPER_MIRROR_MAX;
@@ -3273,13 +3274,10 @@ static int write_dev_supers(struct btrfs_device *device,
 		 * we fua the first super.  The others we allow
 		 * to go down lazy.
 		 */
-		if (i == 0) {
-			ret = btrfsic_submit_bh(REQ_OP_WRITE,
-				REQ_SYNC | REQ_FUA | REQ_META | REQ_PRIO, bh);
-		} else {
-			ret = btrfsic_submit_bh(REQ_OP_WRITE,
-				REQ_SYNC | REQ_META | REQ_PRIO, bh);
-		}
+		op_flags = REQ_SYNC | REQ_META | REQ_PRIO;
+		if (i == 0 && !btrfs_test_opt(device->fs_info, NOBARRIER))
+			op_flags |= REQ_FUA;
+		ret = btrfsic_submit_bh(REQ_OP_WRITE, op_flags, bh);
 		if (ret)
 			errors++;
 	}
-- 
2.15.1


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

* Re: [PATCH] Btrfs: disable FUA if mounted with nobarrier
  2017-12-06  6:54 [PATCH] Btrfs: disable FUA if mounted with nobarrier Omar Sandoval
@ 2017-12-06  7:11 ` Qu Wenruo
  2017-12-06 14:20 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2017-12-06  7:11 UTC (permalink / raw)
  To: Omar Sandoval, linux-btrfs; +Cc: kernel-team


[-- Attachment #1.1: Type: text/plain, Size: 1703 bytes --]



On 2017年12月06日 14:54, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> I was seeing disk flushes still happening when I mounted a Btrfs
> filesystem with nobarrier for testing. This is because we use FUA to
> write out the first super block, and on devices without FUA support, the
> block layer translates FUA to a flush. Even on devices supporting true
> FUA, using FUA when we asked for no barriers is surprising.
> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>  fs/btrfs/disk-io.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 10a2a579cc7f..a8ecccfc36de 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3231,6 +3231,7 @@ static int write_dev_supers(struct btrfs_device *device,
>  	int errors = 0;
>  	u32 crc;
>  	u64 bytenr;
> +	int op_flags;
>  
>  	if (max_mirrors == 0)
>  		max_mirrors = BTRFS_SUPER_MIRROR_MAX;
> @@ -3273,13 +3274,10 @@ static int write_dev_supers(struct btrfs_device *device,
>  		 * we fua the first super.  The others we allow
>  		 * to go down lazy.
>  		 */
> -		if (i == 0) {
> -			ret = btrfsic_submit_bh(REQ_OP_WRITE,
> -				REQ_SYNC | REQ_FUA | REQ_META | REQ_PRIO, bh);
> -		} else {
> -			ret = btrfsic_submit_bh(REQ_OP_WRITE,
> -				REQ_SYNC | REQ_META | REQ_PRIO, bh);
> -		}
> +		op_flags = REQ_SYNC | REQ_META | REQ_PRIO;
> +		if (i == 0 && !btrfs_test_opt(device->fs_info, NOBARRIER))
> +			op_flags |= REQ_FUA;
> +		ret = btrfsic_submit_bh(REQ_OP_WRITE, op_flags, bh);
>  		if (ret)
>  			errors++;
>  	}
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]

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

* Re: [PATCH] Btrfs: disable FUA if mounted with nobarrier
  2017-12-06  6:54 [PATCH] Btrfs: disable FUA if mounted with nobarrier Omar Sandoval
  2017-12-06  7:11 ` Qu Wenruo
@ 2017-12-06 14:20 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2017-12-06 14:20 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-btrfs, kernel-team

On Tue, Dec 05, 2017 at 10:54:02PM -0800, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> I was seeing disk flushes still happening when I mounted a Btrfs
> filesystem with nobarrier for testing. This is because we use FUA to
> write out the first super block, and on devices without FUA support, the
> block layer translates FUA to a flush. Even on devices supporting true
> FUA, using FUA when we asked for no barriers is surprising.
> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>

Reviewed-by: David Sterba <dsterba@suse.com>

The documented nobarrier behaviour matches the updated code.

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-06  6:54 [PATCH] Btrfs: disable FUA if mounted with nobarrier Omar Sandoval
2017-12-06  7:11 ` Qu Wenruo
2017-12-06 14:20 ` David Sterba

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.