* [PATCH v2] f2fs: skip f2fs_preallocate_blocks() for overwrite case
@ 2022-02-04 9:10 ` Chao Yu
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-02-04 9:10 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu
There is potential hangtask happened during swapfile's writeback:
- loop_kthread_worker_fn - do_checkpoint
- kthread_worker_fn
- loop_queue_work
- lo_rw_aio
- f2fs_file_write_iter
- f2fs_preallocate_blocks
- f2fs_map_blocks
- down_write
- down_read
- rwsem_down_read_slowpath
- schedule
One cause is f2fs_preallocate_blocks() will always be called no matter
the physical block addresses are allocated or not.
This patch tries to check whether block addresses are all allocated with
i_size and i_blocks of inode, it's rough because blocks can be allocated
beyond i_size, however, we can afford skipping block preallocation in this
condition since it's not necessary to do preallocation all the time.
Signed-off-by: Chao Yu <chao@kernel.org>
---
v2:
- check overwrite case with i_size and i_blocks roughly.
fs/f2fs/file.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index cfdc41f87f5d..09565d10611d 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -4390,6 +4390,16 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter,
int flag;
int ret;
+ /*
+ * It tries to check whether block addresses are all allocated,
+ * it's rough because blocks can be allocated beyond i_size,
+ * however, we can afford skipping block preallocation since
+ * it's not necessary all the time.
+ */
+ if (F2FS_BLK_ALIGN(i_size_read(inode)) ==
+ SECTOR_TO_BLOCK(inode->i_blocks))
+ return 0;
+
/* If it will be an out-of-place direct write, don't bother. */
if (dio && f2fs_lfs_mode(sbi))
return 0;
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [f2fs-dev] [PATCH v2] f2fs: skip f2fs_preallocate_blocks() for overwrite case
@ 2022-02-04 9:10 ` Chao Yu
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-02-04 9:10 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel
There is potential hangtask happened during swapfile's writeback:
- loop_kthread_worker_fn - do_checkpoint
- kthread_worker_fn
- loop_queue_work
- lo_rw_aio
- f2fs_file_write_iter
- f2fs_preallocate_blocks
- f2fs_map_blocks
- down_write
- down_read
- rwsem_down_read_slowpath
- schedule
One cause is f2fs_preallocate_blocks() will always be called no matter
the physical block addresses are allocated or not.
This patch tries to check whether block addresses are all allocated with
i_size and i_blocks of inode, it's rough because blocks can be allocated
beyond i_size, however, we can afford skipping block preallocation in this
condition since it's not necessary to do preallocation all the time.
Signed-off-by: Chao Yu <chao@kernel.org>
---
v2:
- check overwrite case with i_size and i_blocks roughly.
fs/f2fs/file.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index cfdc41f87f5d..09565d10611d 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -4390,6 +4390,16 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter,
int flag;
int ret;
+ /*
+ * It tries to check whether block addresses are all allocated,
+ * it's rough because blocks can be allocated beyond i_size,
+ * however, we can afford skipping block preallocation since
+ * it's not necessary all the time.
+ */
+ if (F2FS_BLK_ALIGN(i_size_read(inode)) ==
+ SECTOR_TO_BLOCK(inode->i_blocks))
+ return 0;
+
/* If it will be an out-of-place direct write, don't bother. */
if (dio && f2fs_lfs_mode(sbi))
return 0;
--
2.32.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: skip f2fs_preallocate_blocks() for overwrite case
2022-02-04 9:10 ` [f2fs-dev] " Chao Yu
@ 2022-02-07 19:16 ` Jaegeuk Kim
-1 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2022-02-07 19:16 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel
On 02/04, Chao Yu wrote:
> There is potential hangtask happened during swapfile's writeback:
>
> - loop_kthread_worker_fn - do_checkpoint
> - kthread_worker_fn
> - loop_queue_work
> - lo_rw_aio
> - f2fs_file_write_iter
> - f2fs_preallocate_blocks
> - f2fs_map_blocks
> - down_write
> - down_read
> - rwsem_down_read_slowpath
> - schedule
>
> One cause is f2fs_preallocate_blocks() will always be called no matter
> the physical block addresses are allocated or not.
>
> This patch tries to check whether block addresses are all allocated with
> i_size and i_blocks of inode, it's rough because blocks can be allocated
> beyond i_size, however, we can afford skipping block preallocation in this
> condition since it's not necessary to do preallocation all the time.
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> v2:
> - check overwrite case with i_size and i_blocks roughly.
> fs/f2fs/file.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index cfdc41f87f5d..09565d10611d 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -4390,6 +4390,16 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter,
> int flag;
> int ret;
>
> + /*
> + * It tries to check whether block addresses are all allocated,
> + * it's rough because blocks can be allocated beyond i_size,
> + * however, we can afford skipping block preallocation since
> + * it's not necessary all the time.
> + */
> + if (F2FS_BLK_ALIGN(i_size_read(inode)) ==
> + SECTOR_TO_BLOCK(inode->i_blocks))
Do we count i_blocks only for data?
> + return 0;
> +
> /* If it will be an out-of-place direct write, don't bother. */
> if (dio && f2fs_lfs_mode(sbi))
> return 0;
> --
> 2.32.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] f2fs: skip f2fs_preallocate_blocks() for overwrite case
@ 2022-02-07 19:16 ` Jaegeuk Kim
0 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2022-02-07 19:16 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-f2fs-devel, linux-kernel
On 02/04, Chao Yu wrote:
> There is potential hangtask happened during swapfile's writeback:
>
> - loop_kthread_worker_fn - do_checkpoint
> - kthread_worker_fn
> - loop_queue_work
> - lo_rw_aio
> - f2fs_file_write_iter
> - f2fs_preallocate_blocks
> - f2fs_map_blocks
> - down_write
> - down_read
> - rwsem_down_read_slowpath
> - schedule
>
> One cause is f2fs_preallocate_blocks() will always be called no matter
> the physical block addresses are allocated or not.
>
> This patch tries to check whether block addresses are all allocated with
> i_size and i_blocks of inode, it's rough because blocks can be allocated
> beyond i_size, however, we can afford skipping block preallocation in this
> condition since it's not necessary to do preallocation all the time.
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> v2:
> - check overwrite case with i_size and i_blocks roughly.
> fs/f2fs/file.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index cfdc41f87f5d..09565d10611d 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -4390,6 +4390,16 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter,
> int flag;
> int ret;
>
> + /*
> + * It tries to check whether block addresses are all allocated,
> + * it's rough because blocks can be allocated beyond i_size,
> + * however, we can afford skipping block preallocation since
> + * it's not necessary all the time.
> + */
> + if (F2FS_BLK_ALIGN(i_size_read(inode)) ==
> + SECTOR_TO_BLOCK(inode->i_blocks))
Do we count i_blocks only for data?
> + return 0;
> +
> /* If it will be an out-of-place direct write, don't bother. */
> if (dio && f2fs_lfs_mode(sbi))
> return 0;
> --
> 2.32.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: skip f2fs_preallocate_blocks() for overwrite case
2022-02-07 19:16 ` Jaegeuk Kim
@ 2022-02-08 1:41 ` Chao Yu
-1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-02-08 1:41 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel
On 2022/2/8 3:16, Jaegeuk Kim wrote:
> On 02/04, Chao Yu wrote:
>> There is potential hangtask happened during swapfile's writeback:
>>
>> - loop_kthread_worker_fn - do_checkpoint
>> - kthread_worker_fn
>> - loop_queue_work
>> - lo_rw_aio
>> - f2fs_file_write_iter
>> - f2fs_preallocate_blocks
>> - f2fs_map_blocks
>> - down_write
>> - down_read
>> - rwsem_down_read_slowpath
>> - schedule
>>
>> One cause is f2fs_preallocate_blocks() will always be called no matter
>> the physical block addresses are allocated or not.
>>
>> This patch tries to check whether block addresses are all allocated with
>> i_size and i_blocks of inode, it's rough because blocks can be allocated
>> beyond i_size, however, we can afford skipping block preallocation in this
>> condition since it's not necessary to do preallocation all the time.
>>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> v2:
>> - check overwrite case with i_size and i_blocks roughly.
>> fs/f2fs/file.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index cfdc41f87f5d..09565d10611d 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -4390,6 +4390,16 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter,
>> int flag;
>> int ret;
>>
>> + /*
>> + * It tries to check whether block addresses are all allocated,
>> + * it's rough because blocks can be allocated beyond i_size,
>> + * however, we can afford skipping block preallocation since
>> + * it's not necessary all the time.
>> + */
>> + if (F2FS_BLK_ALIGN(i_size_read(inode)) ==
>> + SECTOR_TO_BLOCK(inode->i_blocks))
>
> Do we count i_blocks only for data?
Oops, it seems it's not...
Needs to introduce another function to calculate node block count based on i_size?
Thanks,
>
>> + return 0;
>> +
>> /* If it will be an out-of-place direct write, don't bother. */
>> if (dio && f2fs_lfs_mode(sbi))
>> return 0;
>> --
>> 2.32.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] f2fs: skip f2fs_preallocate_blocks() for overwrite case
@ 2022-02-08 1:41 ` Chao Yu
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-02-08 1:41 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-f2fs-devel, linux-kernel
On 2022/2/8 3:16, Jaegeuk Kim wrote:
> On 02/04, Chao Yu wrote:
>> There is potential hangtask happened during swapfile's writeback:
>>
>> - loop_kthread_worker_fn - do_checkpoint
>> - kthread_worker_fn
>> - loop_queue_work
>> - lo_rw_aio
>> - f2fs_file_write_iter
>> - f2fs_preallocate_blocks
>> - f2fs_map_blocks
>> - down_write
>> - down_read
>> - rwsem_down_read_slowpath
>> - schedule
>>
>> One cause is f2fs_preallocate_blocks() will always be called no matter
>> the physical block addresses are allocated or not.
>>
>> This patch tries to check whether block addresses are all allocated with
>> i_size and i_blocks of inode, it's rough because blocks can be allocated
>> beyond i_size, however, we can afford skipping block preallocation in this
>> condition since it's not necessary to do preallocation all the time.
>>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> v2:
>> - check overwrite case with i_size and i_blocks roughly.
>> fs/f2fs/file.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index cfdc41f87f5d..09565d10611d 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -4390,6 +4390,16 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter,
>> int flag;
>> int ret;
>>
>> + /*
>> + * It tries to check whether block addresses are all allocated,
>> + * it's rough because blocks can be allocated beyond i_size,
>> + * however, we can afford skipping block preallocation since
>> + * it's not necessary all the time.
>> + */
>> + if (F2FS_BLK_ALIGN(i_size_read(inode)) ==
>> + SECTOR_TO_BLOCK(inode->i_blocks))
>
> Do we count i_blocks only for data?
Oops, it seems it's not...
Needs to introduce another function to calculate node block count based on i_size?
Thanks,
>
>> + return 0;
>> +
>> /* If it will be an out-of-place direct write, don't bother. */
>> if (dio && f2fs_lfs_mode(sbi))
>> return 0;
>> --
>> 2.32.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-02-08 1:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 9:10 [PATCH v2] f2fs: skip f2fs_preallocate_blocks() for overwrite case Chao Yu
2022-02-04 9:10 ` [f2fs-dev] " Chao Yu
2022-02-07 19:16 ` Jaegeuk Kim
2022-02-07 19:16 ` Jaegeuk Kim
2022-02-08 1:41 ` [f2fs-dev] " Chao Yu
2022-02-08 1:41 ` Chao Yu
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.