Skip to contentSkip to conversation

f2fs: merge WRITE bio into previous WRITE_SYNC

PATCH In review Jaegeuk Kim 3 participants 6 messages Aug 27, 2016 – Sep 8, 2016

Subsystems (2)
lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/1 f2fs: merge WRITE bio into previous WRITE_SYNC

This can avoid bio splits due to different op_flags.

---
 fs/f2fs/data.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/f2fs/data.c +5 -0
index 7c8e219..c7c2022 100644
@@ -267,6 +267,11 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
 
 	down_write(&io->io_rwsem);
 
+	/* WRITE can be merged into previous WRITE_SYNC */
+	if (io->bio && io->last_block_in_bio == fio->new_blkaddr - 1 &&
+			io->fio.op == fio->op && io->fio.op_flags == WRITE_SYNC)
+		fio->op_flags = WRITE_SYNC;
+
 	if (io->bio && (io->last_block_in_bio != fio->new_blkaddr - 1 ||
 	    (io->fio.op != fio->op || io->fio.op_flags != fio->op_flags)))
 		__submit_merged_bio(io);
Signature · 1 line
2.8.3
#1 lore raw

Hi Jaegeuk,

Quoted 1 line · Jaegeuk Kim

This can avoid bio splits due to different op_flags.

I thought about this, but I think this is not a good idea to increase merging ratio of pages in bio. It breaks the rule of SYNC/ASYNC IO defined by system which indicate degree of IO emergency, finally, some/more non-emergent IO will treated as emergent one by IO scheduler, it will interrupt SYNC IOs in block layer, more seriously, it may make real SYNC IO starvation.

Thanks,

Quoted 23 lines
---
 fs/f2fs/data.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/f2fs/data.c +5 -0
index 7c8e219..c7c2022 100644
@@ -267,6 +267,11 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
 
 	down_write(&io->io_rwsem);
 
+	/* WRITE can be merged into previous WRITE_SYNC */
+	if (io->bio && io->last_block_in_bio == fio->new_blkaddr - 1 &&
+			io->fio.op == fio->op && io->fio.op_flags == WRITE_SYNC)
+		fio->op_flags = WRITE_SYNC;
+
 	if (io->bio && (io->last_block_in_bio != fio->new_blkaddr - 1 ||
 	    (io->fio.op != fio->op || io->fio.op_flags != fio->op_flags)))
 		__submit_merged_bio(io);
author maintainer
#2 lore raw
Quoted 10 lines · Chao Yu

Hi Jaegeuk,

Quoted 1 line · Jaegeuk Kim

This can avoid bio splits due to different op_flags.

I thought about this, but I think this is not a good idea to increase merging ratio of pages in bio. It breaks the rule of SYNC/ASYNC IO defined by system which indicate degree of IO emergency, finally, some/more non-emergent IO will treated as emergent one by IO scheduler, it will interrupt SYNC IOs in block layer, more seriously, it may make real SYNC IO starvation.

I understand your concern.
Originally, I tried to avoid breaking a big WRITE_SYNC by a small number of WRITE. And, I thought new WRITE can be piggybacked into previous WRITE_SYNC.

IMO, this happens very occassionally since previous pending bio should be WRITE_SYNC while a new request is WRITE. Even if this happens, the piggybacked size would not exceed over bio's max pages.
If lots of WRITE come, we won't change at all.

Thanks,

Quoted 26 lines

Thanks,

Quoted 23 lines
---
 fs/f2fs/data.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/f2fs/data.c +5 -0
index 7c8e219..c7c2022 100644
@@ -267,6 +267,11 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
 
 	down_write(&io->io_rwsem);
 
+	/* WRITE can be merged into previous WRITE_SYNC */
+	if (io->bio && io->last_block_in_bio == fio->new_blkaddr - 1 &&
+			io->fio.op == fio->op && io->fio.op_flags == WRITE_SYNC)
+		fio->op_flags = WRITE_SYNC;
+
 	if (io->bio && (io->last_block_in_bio != fio->new_blkaddr - 1 ||
 	    (io->fio.op != fio->op || io->fio.op_flags != fio->op_flags)))
 		__submit_merged_bio(io);
maintainer
#3 lore raw
Quoted 6 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu

Hi Jaegeuk,

Quoted 1 line · Jaegeuk Kim

This can avoid bio splits due to different op_flags.

Quoted 8 lines
Quoted 5 lines

I thought about this, but I think this is not a good idea to increase merging ratio of pages in bio. It breaks the rule of SYNC/ASYNC IO defined by system which indicate degree of IO emergency, finally, some/more non-emergent IO will treated as emergent one by IO scheduler, it will interrupt SYNC IOs in block layer, more seriously, it may make real SYNC IO starvation.

I understand your concern.
Originally, I tried to avoid breaking a big WRITE_SYNC by a small number of

Hmm.. I'm worry about the opposite case: user triggers small WRITE_SYNC IO periodically, meanwhile there are big number of WRITE, with our new approach, actually we will increase the number of synchronous WRITE IO obviously because we will mix ASYNC/SYNC WRITE into bio cache intensively more than before since we drop writepages mutexlock. So I'm afread the result is that it will mislead scheduling of block layer.

Quoted 6 lines

WRITE. And, I thought new WRITE can be piggybacked into previous WRITE_SYNC.

IMO, this happens very occassionally since previous pending bio should be WRITE_SYNC while a new request is WRITE. Even if this happens, the piggybacked size would not exceed over bio's max pages.
If lots of WRITE come, we won't change at all.

I thinks this is related to writeback / blocklayer / cgroup subsystem which use this tag frequently, maybe we should Cc their's mailing list for more opinion...

What's your opinion? :)

thanks,

Quoted 36 lines

Thanks,

Quoted 17 lines

Thanks,

Quoted 14 lines
---
 fs/f2fs/data.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/f2fs/data.c +0 -0
index 7c8e219..c7c2022 100644
@@ -267,6 +267,11 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
 
 	down_write(&io->io_rwsem);
 
Quoted 9 lines

fs/f2fs/data.c void f2fs_submit_page_mbio(struct f2fs_io_info *fio) · line 277

Quoted 9 lines
fs/f2fs/data.c +5 -0
+	/* WRITE can be merged into previous WRITE_SYNC */
+	if (io->bio && io->last_block_in_bio == fio->new_blkaddr - 1 &&
+			io->fio.op == fio->op && io->fio.op_flags == WRITE_SYNC)
+		fio->op_flags = WRITE_SYNC;
+
 	if (io->bio && (io->last_block_in_bio != fio->new_blkaddr - 1 ||
 	    (io->fio.op != fio->op || io->fio.op_flags != fio->op_flags)))
 		__submit_merged_bio(io);

------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#4 lore raw
Quoted 25 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu

Hi Jaegeuk,

Quoted 1 line · Jaegeuk Kim

This can avoid bio splits due to different op_flags.

Quoted 8 lines
Quoted 5 lines

I thought about this, but I think this is not a good idea to increase merging ratio of pages in bio. It breaks the rule of SYNC/ASYNC IO defined by system which indicate degree of IO emergency, finally, some/more non-emergent IO will treated as emergent one by IO scheduler, it will interrupt SYNC IOs in block layer, more seriously, it may make real SYNC IO starvation.

I understand your concern.
Originally, I tried to avoid breaking a big WRITE_SYNC by a small number of

Hmm.. I'm worry about the opposite case: user triggers small WRITE_SYNC IO periodically, meanwhile there are big number of WRITE, with our new approach, actually we will increase the number of synchronous WRITE IO obviously because we will mix ASYNC/SYNC WRITE into bio cache intensively more than before since we drop writepages mutexlock. So I'm afread the result is that it will mislead scheduling of block layer.

Quoted 2 lines

WRITE. And, I thought new WRITE can be piggybacked into previous WRITE_SYNC.

Quoted 7 lines
Quoted 4 lines

IMO, this happens very occassionally since previous pending bio should be WRITE_SYNC while a new request is WRITE. Even if this happens, the piggybacked size would not exceed over bio's max pages.
If lots of WRITE come, we won't change at all.

I thinks this is related to writeback / blocklayer / cgroup subsystem which use this tag frequently, maybe we should Cc their's mailing list for more opinion...

Except cgroup, since we do not support it yet. :P

Anyway, I think we'd better verify the effect of this for a while. For example, I'm able to write a simple program to measure fsync latency while a bunch of buffered writes.
Meanwhile, I'll put it back to the end of dev-test repo. :)

Thanks,

Quoted 41 lines

What's your opinion? :)

thanks,

Quoted 36 lines

Thanks,

Quoted 17 lines

Thanks,

Quoted 14 lines
---
 fs/f2fs/data.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/f2fs/data.c +0 -0
index 7c8e219..c7c2022 100644
@@ -267,6 +267,11 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
 
 	down_write(&io->io_rwsem);
 
Quoted 9 lines

fs/f2fs/data.c void f2fs_submit_page_mbio(struct f2fs_io_info *fio) · line 277

Quoted 9 lines
fs/f2fs/data.c +5 -0
+	/* WRITE can be merged into previous WRITE_SYNC */
+	if (io->bio && io->last_block_in_bio == fio->new_blkaddr - 1 &&
+			io->fio.op == fio->op && io->fio.op_flags == WRITE_SYNC)
+		fio->op_flags = WRITE_SYNC;
+
 	if (io->bio && (io->last_block_in_bio != fio->new_blkaddr - 1 ||
 	    (io->fio.op != fio->op || io->fio.op_flags != fio->op_flags)))
 		__submit_merged_bio(io);

------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#5 lore raw
Quoted 31 lines · Jaegeuk Kim
Quoted 30 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu

Hi Jaegeuk,

Quoted 1 line · Jaegeuk Kim

This can avoid bio splits due to different op_flags.

Quoted 8 lines
Quoted 5 lines

I thought about this, but I think this is not a good idea to increase merging ratio of pages in bio. It breaks the rule of SYNC/ASYNC IO defined by system which indicate degree of IO emergency, finally, some/more non-emergent IO will treated as emergent one by IO scheduler, it will interrupt SYNC IOs in block layer, more seriously, it may make real SYNC IO starvation.

I understand your concern.
Originally, I tried to avoid breaking a big WRITE_SYNC by a small number of

Hmm.. I'm worry about the opposite case: user triggers small WRITE_SYNC IO periodically, meanwhile there are big number of WRITE, with our new approach, actually we will increase the number of synchronous WRITE IO obviously because we will mix ASYNC/SYNC WRITE into bio cache intensively more than before since we drop writepages mutexlock. So I'm afread the result is that it will mislead scheduling of block layer.

Quoted 6 lines

WRITE. And, I thought new WRITE can be piggybacked into previous WRITE_SYNC.

IMO, this happens very occassionally since previous pending bio should be WRITE_SYNC while a new request is WRITE. Even if this happens, the piggybacked size would not exceed over bio's max pages.
If lots of WRITE come, we won't change at all.

Quoted 4 lines
Quoted 2 lines

I thinks this is related to writeback / blocklayer / cgroup subsystem which use this tag frequently, maybe we should Cc their's mailing list for more opinion...

Except cgroup, since we do not support it yet. :P

Yeap.

Quoted 5 lines

Anyway, I think we'd better verify the effect of this for a while. For example, I'm able to write a simple program to measure fsync latency while a bunch of buffered writes.
Meanwhile, I'll put it back to the end of dev-test repo. :)

Sounds good plan. Hoping we will not suffer from regression here. ;)

Thanks,

Quoted 44 lines

Thanks,

Quoted 41 lines

What's your opinion? :)

thanks,

Quoted 36 lines

Thanks,

Quoted 17 lines

Thanks,

Quoted 14 lines
---
 fs/f2fs/data.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/f2fs/data.c +0 -0
index 7c8e219..c7c2022 100644
@@ -267,6 +267,11 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
 
 	down_write(&io->io_rwsem);
 
Quoted 9 lines

fs/f2fs/data.c void f2fs_submit_page_mbio(struct f2fs_io_info *fio) · line 277

Quoted 9 lines
fs/f2fs/data.c +5 -0
+	/* WRITE can be merged into previous WRITE_SYNC */
+	if (io->bio && io->last_block_in_bio == fio->new_blkaddr - 1 &&
+			io->fio.op == fio->op && io->fio.op_flags == WRITE_SYNC)
+		fio->op_flags = WRITE_SYNC;
+
 	if (io->bio && (io->last_block_in_bio != fio->new_blkaddr - 1 ||
 	    (io->fio.op != fio->op || io->fio.op_flags != fio->op_flags)))
 		__submit_merged_bio(io);

------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel