linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] Fix fallout from changes to FUA and PREFLUSH definitions
@ 2017-05-02 15:03 Jan Kara
  2017-05-02 15:03 ` [PATCH 6/7] btrfs: Make flush bios explicitely sync Jan Kara
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kara @ 2017-05-02 15:03 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Christoph Hellwig, Jan Kara, linux-ext4, Theodore Ts'o,
	Jaegeuk Kim, linux-f2fs-devel, Steven Whitehouse, cluster-devel,
	reiserfs-devel, David Sterba, linux-btrfs, linux-raid, Shaohua Li,
	Mike Snitzer, dm-devel

Hello,

this series addresses a performance issue caused by commit b685d3d65ac7 "block:
treat REQ_FUA and REQ_PREFLUSH as synchronous". We know for certain this
problem significanly regresses (over 10%, in some cases up to 100%) ext4 and
btrfs for dbench4 and reaim benchmarks.  Based on this I have fixed up also
other places which suffer from the same problem however those changes are
untested so maintainers please have a look whether the change makes sense to
you and also whether I possibly didn't miss some cases where REQ_SYNC should be
also added. Patches in this series are completely independent so if maintainers
agree with the change, feel free to take it through your tree.

The core of the problem is that above mentioned commit removed REQ_SYNC flag
from WRITE_{FUA|PREFLUSH|...} definitions.  generic_make_request_checks()
however strips REQ_FUA and REQ_PREFLUSH flags from a bio when the storage
doesn't report volatile write cache and thus write effectively becomes
asynchronous which can lead to performance regressions.

A side note for ext4: The two patches for ext4 & jbd2 are on top of the change
that got merged in the ext4 tree already.

								Honza

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

* [PATCH 6/7] btrfs: Make flush bios explicitely sync
  2017-05-02 15:03 [PATCH 0/7] Fix fallout from changes to FUA and PREFLUSH definitions Jan Kara
@ 2017-05-02 15:03 ` Jan Kara
  2017-05-02 15:38   ` David Sterba
  2017-05-09 19:09   ` Liu Bo
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Kara @ 2017-05-02 15:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Christoph Hellwig, Jan Kara, David Sterba, linux-btrfs

Commit b685d3d65ac7 "block: treat REQ_FUA and REQ_PREFLUSH as
synchronous" removed REQ_SYNC flag from WRITE_{FUA|PREFLUSH|...}
definitions.  generic_make_request_checks() however strips REQ_FUA and
REQ_PREFLUSH flags from a bio when the storage doesn't report volatile
write cache and thus write effectively becomes asynchronous which can
lead to performance regressions

Fix the problem by making sure all bios which are synchronous are
properly marked with REQ_SYNC.

CC: David Sterba <dsterba@suse.com>
CC: linux-btrfs@vger.kernel.org
Fixes: b685d3d65ac791406e0dfd8779cc9b3707fea5a3
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/btrfs/disk-io.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index eb1ee7b6f532..af75a9aab81e 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3488,10 +3488,12 @@ 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_FUA, bh);
-		else
+		if (i == 0) {
+			ret = btrfsic_submit_bh(REQ_OP_WRITE,
+						REQ_SYNC | REQ_FUA, bh);
+		} else {
 			ret = btrfsic_submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
+		}
 		if (ret)
 			errors++;
 	}
@@ -3555,7 +3557,7 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
 
 	bio->bi_end_io = btrfs_end_empty_barrier;
 	bio->bi_bdev = device->bdev;
-	bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
+	bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH;
 	init_completion(&device->flush_wait);
 	bio->bi_private = &device->flush_wait;
 	device->flush_bio = bio;
-- 
2.12.0


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

* Re: [PATCH 6/7] btrfs: Make flush bios explicitely sync
  2017-05-02 15:03 ` [PATCH 6/7] btrfs: Make flush bios explicitely sync Jan Kara
@ 2017-05-02 15:38   ` David Sterba
  2017-05-09 19:09   ` Liu Bo
  1 sibling, 0 replies; 4+ messages in thread
From: David Sterba @ 2017-05-02 15:38 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel, Christoph Hellwig, David Sterba, linux-btrfs

On Tue, May 02, 2017 at 05:03:50PM +0200, Jan Kara wrote:
> Commit b685d3d65ac7 "block: treat REQ_FUA and REQ_PREFLUSH as
> synchronous" removed REQ_SYNC flag from WRITE_{FUA|PREFLUSH|...}
> definitions.  generic_make_request_checks() however strips REQ_FUA and
> REQ_PREFLUSH flags from a bio when the storage doesn't report volatile
> write cache and thus write effectively becomes asynchronous which can
> lead to performance regressions
> 
> Fix the problem by making sure all bios which are synchronous are
> properly marked with REQ_SYNC.
> 
> CC: David Sterba <dsterba@suse.com>
> CC: linux-btrfs@vger.kernel.org
> Fixes: b685d3d65ac791406e0dfd8779cc9b3707fea5a3
> Signed-off-by: Jan Kara <jack@suse.cz>

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

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

* Re: [PATCH 6/7] btrfs: Make flush bios explicitely sync
  2017-05-02 15:03 ` [PATCH 6/7] btrfs: Make flush bios explicitely sync Jan Kara
  2017-05-02 15:38   ` David Sterba
@ 2017-05-09 19:09   ` Liu Bo
  1 sibling, 0 replies; 4+ messages in thread
From: Liu Bo @ 2017-05-09 19:09 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel, Christoph Hellwig, David Sterba, linux-btrfs

On Tue, May 02, 2017 at 05:03:50PM +0200, Jan Kara wrote:
> Commit b685d3d65ac7 "block: treat REQ_FUA and REQ_PREFLUSH as
> synchronous" removed REQ_SYNC flag from WRITE_{FUA|PREFLUSH|...}
> definitions.  generic_make_request_checks() however strips REQ_FUA and
> REQ_PREFLUSH flags from a bio when the storage doesn't report volatile
> write cache and thus write effectively becomes asynchronous which can
> lead to performance regressions
> 
> Fix the problem by making sure all bios which are synchronous are
> properly marked with REQ_SYNC.
>

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Thanks,

-liubo
> CC: David Sterba <dsterba@suse.com>
> CC: linux-btrfs@vger.kernel.org
> Fixes: b685d3d65ac791406e0dfd8779cc9b3707fea5a3
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  fs/btrfs/disk-io.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index eb1ee7b6f532..af75a9aab81e 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3488,10 +3488,12 @@ 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_FUA, bh);
> -		else
> +		if (i == 0) {
> +			ret = btrfsic_submit_bh(REQ_OP_WRITE,
> +						REQ_SYNC | REQ_FUA, bh);
> +		} else {
>  			ret = btrfsic_submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
> +		}
>  		if (ret)
>  			errors++;
>  	}
> @@ -3555,7 +3557,7 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
>  
>  	bio->bi_end_io = btrfs_end_empty_barrier;
>  	bio->bi_bdev = device->bdev;
> -	bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
> +	bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH;
>  	init_completion(&device->flush_wait);
>  	bio->bi_private = &device->flush_wait;
>  	device->flush_bio = bio;
> -- 
> 2.12.0
> 

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

end of thread, other threads:[~2017-05-09 19:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-02 15:03 [PATCH 0/7] Fix fallout from changes to FUA and PREFLUSH definitions Jan Kara
2017-05-02 15:03 ` [PATCH 6/7] btrfs: Make flush bios explicitely sync Jan Kara
2017-05-02 15:38   ` David Sterba
2017-05-09 19:09   ` Liu Bo

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