f2fs: skip f2fs_preallocate_blocks() for overwrite case
Chao Yu
maintainerPATCH 1/1 f2fs: skip f2fs_preallocate_blocks() for overwrite case
In f2fs_file_write_iter(), let's use f2fs_overwrite_io() to check whethere it is overwrite case, for such case, we can skip f2fs_preallocate_blocks() in order to avoid f2fs_do_map_lock(), which may be blocked by checkpoint() potentially.
--- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/f2fs/file.c +4 -0
@@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos +iov_iter_count (from); +if (f2fs_overwrite_io (inode, iocb->ki_pos, +iov_iter_count (from))) + goto write; + err =f2fs_preallocate_blocks (iocb, from);if (err) { out_err:
Signature · 1 line
2.32.0
Jaegeuk Kim
maintainerQuoted 15 lines · Chao Yu
In
f2fs_file_write_iter(), let's usef2fs_overwrite_io()to check whethere it is overwrite case, for such case, we can skipf2fs_preallocate_blocks()in order to avoidf2fs_do_map_lock(), which may be blocked bycheckpoint()potentially.Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+)fs/f2fs/file.c +0
-0
fs/f2fs/file.c static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 4326
Quoted 6 lines
fs/f2fs/file.c +3
-0@@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos +iov_iter_count (from); +if (f2fs_overwrite_io (inode, iocb->ki_pos, +iov_iter_count (from))) + goto write;
This calls f2fs_map_blocks() which can be duplicate, if it's not the overwirte case. Do we have other benefit?
Quoted 6 lines
fs/f2fs/file.c +1
-0+ err =f2fs_preallocate_blocks (iocb, from);if (err) { out_err:Signature · 1 line
2.32.0
Chao Yu
maintainerQuoted 19 lines · Jaegeuk Kim
Quoted 18 lines · Chao Yu
In
f2fs_file_write_iter(), let's usef2fs_overwrite_io()to check whethere it is overwrite case, for such case, we can skipf2fs_preallocate_blocks()in order to avoidf2fs_do_map_lock(), which may be blocked bycheckpoint()potentially.Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+)fs/f2fs/file.c +0
-0@@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos +iov_iter_count (from);
Quoted 6 lines
fs/f2fs/file.c static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 4326
Quoted 3 lines
fs/f2fs/file.c +3
-0+if (f2fs_overwrite_io (inode, iocb->ki_pos, +iov_iter_count (from))) + goto write;This calls
f2fs_map_blocks()which can be duplicate, if it's not the overwirte case. Do we have other benefit?
f2fs_overwrite_io() will break for append write case w/ below check:
if (pos + len > i_size_read(inode)) return false;
I guess we may only suffer double f2fs_map_blocks() for write hole case, e.g. truncate to large size & write inside the filesize. For this case, how about adding a condition to allow double f2fs_map_blocks() only if write size is smaller than a threshold?
Thanks,
Quoted 7 lines
Quoted 7 lines
fs/f2fs/file.c +1
-0+ err =f2fs_preallocate_blocks (iocb, from);if (err) { out_err:Signature · 1 line
2.32.0
Chao Yu
maintainerPing,
Quoted 51 lines · Chao Yu
Quoted 11 lines · Jaegeuk Kim
Quoted 10 lines · Chao Yu
In
f2fs_file_write_iter(), let's usef2fs_overwrite_io()to check whethere it is overwrite case, for such case, we can skipf2fs_preallocate_blocks()in order to avoidf2fs_do_map_lock(), which may be blocked bycheckpoint()potentially.Signed-off-by Chao Yu <[email protected]>---
fs/f2fs/file.c| 4 ++++1 file changed, 4 insertions(+)Quoted 13 lines
fs/f2fs/file.c static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 4325
Quoted 10 lines
fs/f2fs/file.c +3
-0@@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos + iov_iter_count(from); + if (f2fs_overwrite_io(inode, iocb->ki_pos, + iov_iter_count(from))) + goto write;This calls
f2fs_map_blocks()which can be duplicate, if it's not the overwirte case. Do we have other benefit?
f2fs_overwrite_io()will break for append write case w/ below check:if (pos + len >
i_size_read(inode))
return false;I guess we may only suffer double
f2fs_map_blocks()for write hole case, e.g. truncate to large size & write inside the filesize. For this case, how about adding a condition to allow doublef2fs_map_blocks()only if write size is smaller than a threshold?Thanks,
Quoted 7 lines
Quoted 7 lines
fs/f2fs/file.c +1
-0+ err = f2fs_preallocate_blocks(iocb, from); if (err) {
out_err:Signature · 1 line
2.32.0_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Flinux-f2fs-devel&data=04%7C01%7Cchao.yu%40oppo.com%7C421c06812eba4f922b0908d982dcdcc5%7Cf1905eb1c35341c5951662b4a54b5ee6%7C0%7C0%7C637684707374940190%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=u22eEWDAPaAZCyISyjTUOtQDLDuyKxTnNCI3eSwwWro%3D&reserved=0
Jaegeuk Kim
maintainerQuoted 38 lines · Chao Yu
Ping,
Quoted 35 lines · Chao Yu
Quoted 11 lines · Jaegeuk Kim
Quoted 10 lines · Chao Yu
In
f2fs_file_write_iter(), let's usef2fs_overwrite_io()to check whethere it is overwrite case, for such case, we can skipf2fs_preallocate_blocks()in order to avoidf2fs_do_map_lock(), which may be blocked bycheckpoint()potentially.Signed-off-by Chao Yu <[email protected]>---
fs/f2fs/file.c| 4 ++++1 file changed, 4 insertions(+)Quoted 13 lines
fs/f2fs/file.c static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 4325
Quoted 10 lines
fs/f2fs/file.c +3
-0@@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos + iov_iter_count(from); + if (f2fs_overwrite_io(inode, iocb->ki_pos, + iov_iter_count(from))) + goto write;This calls
f2fs_map_blocks()which can be duplicate, if it's not the overwirte case. Do we have other benefit?
f2fs_overwrite_io()will break for append write case w/ below check:if (pos + len >
i_size_read(inode))
return false;I guess we may only suffer double
f2fs_map_blocks()for write hole case, e.g. truncate to large size & write inside the filesize. For this case, how about adding a condition to allow doublef2fs_map_blocks()only if write size is smaller than a threshold?
I still don't see the benefit much to do double f2fs_map_blocks. What is the problem here?
Quoted 16 lines
Quoted 16 lines
Thanks,
Quoted 7 lines
Quoted 7 lines
fs/f2fs/file.c +1
-0+ err = f2fs_preallocate_blocks(iocb, from); if (err) {
out_err:Signature · 1 line
2.32.0_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Flinux-f2fs-devel&data=04%7C01%7Cchao.yu%40oppo.com%7C421c06812eba4f922b0908d982dcdcc5%7Cf1905eb1c35341c5951662b4a54b5ee6%7C0%7C0%7C637684707374940190%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=u22eEWDAPaAZCyISyjTUOtQDLDuyKxTnNCI3eSwwWro%3D&reserved=0
Chao Yu
maintainerQuoted 35 lines · Jaegeuk Kim
Quoted 34 lines · Chao Yu
Ping,
Quoted 31 lines · Chao Yu
Quoted 11 lines · Jaegeuk Kim
Quoted 10 lines · Chao Yu
In
f2fs_file_write_iter(), let's usef2fs_overwrite_io()to check whethere it is overwrite case, for such case, we can skipf2fs_preallocate_blocks()in order to avoidf2fs_do_map_lock(), which may be blocked bycheckpoint()potentially.Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+)Quoted 13 lines
fs/f2fs/file.c static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 4325
Quoted 10 lines
fs/f2fs/file.c +3
-0@@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos + iov_iter_count(from); + if (f2fs_overwrite_io(inode, iocb->ki_pos, + iov_iter_count(from))) + goto write;This calls
f2fs_map_blocks()which can be duplicate, if it's not the overwirte case. Do we have other benefit?
f2fs_overwrite_io()will break for append write case w/ below check:if (pos + len >
i_size_read(inode))
return false;
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
I guess we may only suffer double
f2fs_map_blocks()for write hole case, e.g. truncate to large size & write inside the filesize. For this case, how about adding a condition to allow doublef2fs_map_blocks()only if write size is smaller than a threshold?I still don't see the benefit much to do double
f2fs_map_blocks. What is the problem here?
There is potential hangtask happened during swapfile's writeback:
- loop_kthread_worker_fn
- kthread_worker_fn
- loop_queue_work
- lo_rw_aio
- f2fs_file_write_iter
- f2fs_preallocate_blocks
- f2fs_map_blocks
- down_read
- rwsem_down_read_slowpath
- schedule
I try to mitigate such issue by preallocating swapfile's block address and avoid f2fs_do_map_lock() as much as possible in swapfile's writeback path...
Thanks,
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Thanks,
Quoted 7 lines
Quoted 7 lines
fs/f2fs/file.c +1
-0+ err = f2fs_preallocate_blocks(iocb, from); if (err) { out_err:Signature · 1 line
2.32.0
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Flinux-f2fs-devel&data=04%7C01%7Cchao.yu%40oppo.com%7C421c06812eba4f922b0908d982dcdcc5%7Cf1905eb1c35341c5951662b4a54b5ee6%7C0%7C0%7C637684707374940190%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=u22eEWDAPaAZCyISyjTUOtQDLDuyKxTnNCI3eSwwWro%3D&reserved=0
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerPing,
Quoted 81 lines · Chao Yu
Quoted 35 lines · Jaegeuk Kim
Quoted 34 lines · Chao Yu
Ping,
Quoted 31 lines · Chao Yu
Quoted 11 lines · Jaegeuk Kim
Quoted 10 lines · Chao Yu
In
f2fs_file_write_iter(), let's usef2fs_overwrite_io()to check whethere it is overwrite case, for such case, we can skipf2fs_preallocate_blocks()in order to avoidf2fs_do_map_lock(), which may be blocked bycheckpoint()potentially.Signed-off-by Chao Yu <[email protected]>---
fs/f2fs/file.c| 4 ++++1 file changed, 4 insertions(+)Quoted 13 lines
fs/f2fs/file.c static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 4325
Quoted 10 lines
fs/f2fs/file.c +3
-0@@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos + iov_iter_count(from); + if (f2fs_overwrite_io(inode, iocb->ki_pos, + iov_iter_count(from))) + goto write;This calls
f2fs_map_blocks()which can be duplicate, if it's not the overwirte case. Do we have other benefit?
f2fs_overwrite_io()will break for append write case w/ below check:if (pos + len >
i_size_read(inode))
return false;Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
I guess we may only suffer double
f2fs_map_blocks()for write hole case, e.g. truncate to large size & write inside the filesize. For this case, how about adding a condition to allow doublef2fs_map_blocks()only if write size is smaller than a threshold?I still don't see the benefit much to do double
f2fs_map_blocks. What is the problem here?There is potential hangtask happened during swapfile's writeback:
-
loop_kthread_worker_fn
-kthread_worker_fn
-loop_queue_work
-lo_rw_aio
-f2fs_file_write_iter
-f2fs_preallocate_blocks
-f2fs_map_blocks
-down_read
-rwsem_down_read_slowpath
- scheduleI try to mitigate such issue by preallocating swapfile's block address and avoid
f2fs_do_map_lock()as much as possible in swapfile's writeback path...Thanks,
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Thanks,
Quoted 7 lines
Quoted 7 lines
fs/f2fs/file.c +1
-0+ err = f2fs_preallocate_blocks(iocb, from); if (err) {
out_err:Signature · 1 line
2.32.0Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Flinux-f2fs-devel&data=04%7C01%7Cchao.yu%40oppo.com%7Cbb41006c3f6d4e4d600a08d99b51cbcd%7Cf1905eb1c35341c5951662b4a54b5ee6%7C0%7C0%7C637711597895400286%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2BlEAXWLpV5wGX2hL0Wj5p2qX0AqfUFI05Qiqdp8PK8g%3D&reserved=0
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 62 lines · Chao Yu
Ping,
Quoted 59 lines · Chao Yu
Quoted 35 lines · Jaegeuk Kim
Quoted 34 lines · Chao Yu
Ping,
Quoted 31 lines · Chao Yu
Quoted 11 lines · Jaegeuk Kim
Quoted 10 lines · Chao Yu
In
f2fs_file_write_iter(), let's usef2fs_overwrite_io()to check whethere it is overwrite case, for such case, we can skipf2fs_preallocate_blocks()in order to avoidf2fs_do_map_lock(), which may be blocked bycheckpoint()potentially.Signed-off-by Chao Yu <[email protected]>---
fs/f2fs/file.c| 4 ++++1 file changed, 4 insertions(+)Quoted 13 lines
fs/f2fs/file.c static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 4325
Quoted 10 lines
fs/f2fs/file.c +3
-0@@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos + iov_iter_count(from); + if (f2fs_overwrite_io(inode, iocb->ki_pos, + iov_iter_count(from))) + goto write;This calls
f2fs_map_blocks()which can be duplicate, if it's not the overwirte case. Do we have other benefit?
f2fs_overwrite_io()will break for append write case w/ below check:if (pos + len >
i_size_read(inode))
return false;Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
I guess we may only suffer double
f2fs_map_blocks()for write hole case, e.g. truncate to large size & write inside the filesize. For this case, how about adding a condition to allow doublef2fs_map_blocks()only if write size is smaller than a threshold?I still don't see the benefit much to do double
f2fs_map_blocks. What is the problem here?There is potential hangtask happened during swapfile's writeback:
-
loop_kthread_worker_fn
-kthread_worker_fn
-loop_queue_work
-lo_rw_aio
-f2fs_file_write_iter
-f2fs_preallocate_blocks
-f2fs_map_blocks
-down_read
-rwsem_down_read_slowpath
- scheduleI try to mitigate such issue by preallocating swapfile's block address and avoid
f2fs_do_map_lock()as much as possible in swapfile's writeback path...
How about checking i_blocks and i_size instead of checking the entire map?
Quoted 26 lines
Quoted 26 lines
Thanks,
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Thanks,
Quoted 7 lines
Quoted 7 lines
fs/f2fs/file.c +1
-0+ err = f2fs_preallocate_blocks(iocb, from); if (err) {
out_err:Signature · 1 line
2.32.0Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Flinux-f2fs-devel&data=04%7C01%7Cchao.yu%40oppo.com%7Cbb41006c3f6d4e4d600a08d99b51cbcd%7Cf1905eb1c35341c5951662b4a54b5ee6%7C0%7C0%7C637711597895400286%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2BlEAXWLpV5wGX2hL0Wj5p2qX0AqfUFI05Qiqdp8PK8g%3D&reserved=0_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerQuoted 61 lines · Jaegeuk Kim
Quoted 60 lines · Chao Yu
Ping,
Quoted 57 lines · Chao Yu
Quoted 35 lines · Jaegeuk Kim
Quoted 34 lines · Chao Yu
Ping,
Quoted 31 lines · Chao Yu
Quoted 11 lines · Jaegeuk Kim
Quoted 10 lines · Chao Yu
In
f2fs_file_write_iter(), let's usef2fs_overwrite_io()to check whethere it is overwrite case, for such case, we can skipf2fs_preallocate_blocks()in order to avoidf2fs_do_map_lock(), which may be blocked bycheckpoint()potentially.Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+)Quoted 13 lines
fs/f2fs/file.c static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 4325
Quoted 10 lines
fs/f2fs/file.c +3
-0@@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos + iov_iter_count(from); + if (f2fs_overwrite_io(inode, iocb->ki_pos, + iov_iter_count(from))) + goto write;This calls
f2fs_map_blocks()which can be duplicate, if it's not the overwirte case. Do we have other benefit?
f2fs_overwrite_io()will break for append write case w/ below check:if (pos + len >
i_size_read(inode))
return false;Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
I guess we may only suffer double
f2fs_map_blocks()for write hole case, e.g. truncate to large size & write inside the filesize. For this case, how about adding a condition to allow doublef2fs_map_blocks()only if write size is smaller than a threshold?I still don't see the benefit much to do double
f2fs_map_blocks. What is the problem here?There is potential hangtask happened during swapfile's writeback:
-
loop_kthread_worker_fn
-kthread_worker_fn
-loop_queue_work
-lo_rw_aio
-f2fs_file_write_iter
-f2fs_preallocate_blocks
-f2fs_map_blocks
-down_read
-rwsem_down_read_slowpath
- schedule
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
I try to mitigate such issue by preallocating swapfile's block address and avoid
f2fs_do_map_lock()as much as possible in swapfile's writeback path...How about checking
i_blocksandi_sizeinstead of checking the entire map?
How about v2?
Thanks,
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Thanks,
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Thanks,
Quoted 7 lines
Quoted 7 lines
fs/f2fs/file.c +1
-0+ err = f2fs_preallocate_blocks(iocb, from); if (err) { out_err:Signature · 1 line
2.32.0Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Flinux-f2fs-devel&data=04%7C01%7Cchao.yu%40oppo.com%7Cbb41006c3f6d4e4d600a08d99b51cbcd%7Cf1905eb1c35341c5951662b4a54b5ee6%7C0%7C0%7C637711597895400286%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2BlEAXWLpV5wGX2hL0Wj5p2qX0AqfUFI05Qiqdp8PK8g%3D&reserved=0_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel