* [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case @ 2021-09-28 15:19 Chao Yu 2021-09-28 19:08 ` Jaegeuk Kim 0 siblings, 1 reply; 9+ messages in thread From: Chao Yu @ 2021-09-28 15:19 UTC (permalink / raw) To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu 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. Signed-off-by: Chao Yu <chao@kernel.org> --- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 13deae03df06..51fecb2f4db5 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -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: -- 2.32.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case 2021-09-28 15:19 [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case Chao Yu @ 2021-09-28 19:08 ` Jaegeuk Kim 2021-09-29 0:05 ` Chao Yu 0 siblings, 1 reply; 9+ messages in thread From: Jaegeuk Kim @ 2021-09-28 19:08 UTC (permalink / raw) To: Chao Yu; +Cc: linux-f2fs-devel, linux-kernel On 09/28, Chao Yu wrote: > 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. > > Signed-off-by: Chao Yu <chao@kernel.org> > --- > fs/f2fs/file.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 13deae03df06..51fecb2f4db5 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -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? > + > err = f2fs_preallocate_blocks(iocb, from); > if (err) { > out_err: > -- > 2.32.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case 2021-09-28 19:08 ` Jaegeuk Kim @ 2021-09-29 0:05 ` Chao Yu 2021-10-29 2:34 ` [f2fs-dev] " Chao Yu 0 siblings, 1 reply; 9+ messages in thread From: Chao Yu @ 2021-09-29 0:05 UTC (permalink / raw) To: Jaegeuk Kim; +Cc: linux-f2fs-devel, linux-kernel On 2021/9/29 3:08, Jaegeuk Kim wrote: > On 09/28, Chao Yu wrote: >> 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. >> >> Signed-off-by: Chao Yu <chao@kernel.org> >> --- >> fs/f2fs/file.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >> index 13deae03df06..51fecb2f4db5 100644 >> --- a/fs/f2fs/file.c >> +++ b/fs/f2fs/file.c >> @@ -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 double f2fs_map_blocks() only if write size is smaller than a threshold? Thanks, > >> + >> err = f2fs_preallocate_blocks(iocb, from); >> if (err) { >> out_err: >> -- >> 2.32.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case 2021-09-29 0:05 ` Chao Yu @ 2021-10-29 2:34 ` Chao Yu 2021-10-29 17:43 ` Jaegeuk Kim 0 siblings, 1 reply; 9+ messages in thread From: Chao Yu @ 2021-10-29 2:34 UTC (permalink / raw) To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel Ping, On 2021/9/29 8:05, Chao Yu wrote: > On 2021/9/29 3:08, Jaegeuk Kim wrote: >> On 09/28, Chao Yu wrote: >>> 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. >>> >>> Signed-off-by: Chao Yu <chao@kernel.org> >>> --- >>> fs/f2fs/file.c | 4 ++++ >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>> index 13deae03df06..51fecb2f4db5 100644 >>> --- a/fs/f2fs/file.c >>> +++ b/fs/f2fs/file.c >>> @@ -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 double f2fs_map_blocks() > only if write size is smaller than a threshold? > > Thanks, > >> >>> + >>> err = f2fs_preallocate_blocks(iocb, from); >>> if (err) { >>> out_err: >>> -- >>> 2.32.0 > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case 2021-10-29 2:34 ` [f2fs-dev] " Chao Yu @ 2021-10-29 17:43 ` Jaegeuk Kim 2021-10-30 3:02 ` Chao Yu 0 siblings, 1 reply; 9+ messages in thread From: Jaegeuk Kim @ 2021-10-29 17:43 UTC (permalink / raw) To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel On 10/29, Chao Yu wrote: > Ping, > > On 2021/9/29 8:05, Chao Yu wrote: > > On 2021/9/29 3:08, Jaegeuk Kim wrote: > > > On 09/28, Chao Yu wrote: > > > > 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. > > > > > > > > Signed-off-by: Chao Yu <chao@kernel.org> > > > > --- > > > > fs/f2fs/file.c | 4 ++++ > > > > 1 file changed, 4 insertions(+) > > > > > > > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > > > > index 13deae03df06..51fecb2f4db5 100644 > > > > --- a/fs/f2fs/file.c > > > > +++ b/fs/f2fs/file.c > > > > @@ -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 double f2fs_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? > > > > Thanks, > > > > > > > > > + > > > > err = f2fs_preallocate_blocks(iocb, from); > > > > if (err) { > > > > out_err: > > > > -- > > > > 2.32.0 > > > > > > _______________________________________________ > > Linux-f2fs-devel mailing list > > Linux-f2fs-devel@lists.sourceforge.net > > 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case 2021-10-29 17:43 ` Jaegeuk Kim @ 2021-10-30 3:02 ` Chao Yu 2021-12-12 3:57 ` Chao Yu 0 siblings, 1 reply; 9+ messages in thread From: Chao Yu @ 2021-10-30 3:02 UTC (permalink / raw) To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel On 2021/10/30 1:43, Jaegeuk Kim wrote: > On 10/29, Chao Yu wrote: >> Ping, >> >> On 2021/9/29 8:05, Chao Yu wrote: >>> On 2021/9/29 3:08, Jaegeuk Kim wrote: >>>> On 09/28, Chao Yu wrote: >>>>> 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. >>>>> >>>>> Signed-off-by: Chao Yu <chao@kernel.org> >>>>> --- >>>>> fs/f2fs/file.c | 4 ++++ >>>>> 1 file changed, 4 insertions(+) >>>>> >>>>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>>>> index 13deae03df06..51fecb2f4db5 100644 >>>>> --- a/fs/f2fs/file.c >>>>> +++ b/fs/f2fs/file.c >>>>> @@ -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 double f2fs_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, > >>> >>> Thanks, >>> >>>> >>>>> + >>>>> err = f2fs_preallocate_blocks(iocb, from); >>>>> if (err) { >>>>> out_err: >>>>> -- >>>>> 2.32.0 >>> >>> >>> _______________________________________________ >>> Linux-f2fs-devel mailing list >>> Linux-f2fs-devel@lists.sourceforge.net >>> 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case 2021-10-30 3:02 ` Chao Yu @ 2021-12-12 3:57 ` Chao Yu 2021-12-14 18:56 ` Jaegeuk Kim 0 siblings, 1 reply; 9+ messages in thread From: Chao Yu @ 2021-12-12 3:57 UTC (permalink / raw) To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel Ping, On 2021/10/30 11:02, Chao Yu wrote: > On 2021/10/30 1:43, Jaegeuk Kim wrote: >> On 10/29, Chao Yu wrote: >>> Ping, >>> >>> On 2021/9/29 8:05, Chao Yu wrote: >>>> On 2021/9/29 3:08, Jaegeuk Kim wrote: >>>>> On 09/28, Chao Yu wrote: >>>>>> 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. >>>>>> >>>>>> Signed-off-by: Chao Yu <chao@kernel.org> >>>>>> --- >>>>>> fs/f2fs/file.c | 4 ++++ >>>>>> 1 file changed, 4 insertions(+) >>>>>> >>>>>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>>>>> index 13deae03df06..51fecb2f4db5 100644 >>>>>> --- a/fs/f2fs/file.c >>>>>> +++ b/fs/f2fs/file.c >>>>>> @@ -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 double f2fs_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, > >> >>>> >>>> Thanks, >>>> >>>>> >>>>>> + >>>>>> err = f2fs_preallocate_blocks(iocb, from); >>>>>> if (err) { >>>>>> out_err: >>>>>> -- >>>>>> 2.32.0 >>>> >>>> >>>> _______________________________________________ >>>> Linux-f2fs-devel mailing list >>>> Linux-f2fs-devel@lists.sourceforge.net >>>> 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 > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case 2021-12-12 3:57 ` Chao Yu @ 2021-12-14 18:56 ` Jaegeuk Kim 2022-02-04 9:10 ` Chao Yu 0 siblings, 1 reply; 9+ messages in thread From: Jaegeuk Kim @ 2021-12-14 18:56 UTC (permalink / raw) To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel On 12/12, Chao Yu wrote: > Ping, > > On 2021/10/30 11:02, Chao Yu wrote: > > On 2021/10/30 1:43, Jaegeuk Kim wrote: > > > On 10/29, Chao Yu wrote: > > > > Ping, > > > > > > > > On 2021/9/29 8:05, Chao Yu wrote: > > > > > On 2021/9/29 3:08, Jaegeuk Kim wrote: > > > > > > On 09/28, Chao Yu wrote: > > > > > > > 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. > > > > > > > > > > > > > > Signed-off-by: Chao Yu <chao@kernel.org> > > > > > > > --- > > > > > > > fs/f2fs/file.c | 4 ++++ > > > > > > > 1 file changed, 4 insertions(+) > > > > > > > > > > > > > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > > > > > > > index 13deae03df06..51fecb2f4db5 100644 > > > > > > > --- a/fs/f2fs/file.c > > > > > > > +++ b/fs/f2fs/file.c > > > > > > > @@ -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 double f2fs_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... How about checking i_blocks and i_size instead of checking the entire map? > > > > Thanks, > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > + > > > > > > > err = f2fs_preallocate_blocks(iocb, from); > > > > > > > if (err) { > > > > > > > out_err: > > > > > > > -- > > > > > > > 2.32.0 > > > > > > > > > > > > > > > _______________________________________________ > > > > > Linux-f2fs-devel mailing list > > > > > Linux-f2fs-devel@lists.sourceforge.net > > > > > 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 > > Linux-f2fs-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case 2021-12-14 18:56 ` Jaegeuk Kim @ 2022-02-04 9:10 ` Chao Yu 0 siblings, 0 replies; 9+ messages in thread From: Chao Yu @ 2022-02-04 9:10 UTC (permalink / raw) To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel On 2021/12/15 2:56, Jaegeuk Kim wrote: > On 12/12, Chao Yu wrote: >> Ping, >> >> On 2021/10/30 11:02, Chao Yu wrote: >>> On 2021/10/30 1:43, Jaegeuk Kim wrote: >>>> On 10/29, Chao Yu wrote: >>>>> Ping, >>>>> >>>>> On 2021/9/29 8:05, Chao Yu wrote: >>>>>> On 2021/9/29 3:08, Jaegeuk Kim wrote: >>>>>>> On 09/28, Chao Yu wrote: >>>>>>>> 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. >>>>>>>> >>>>>>>> Signed-off-by: Chao Yu <chao@kernel.org> >>>>>>>> --- >>>>>>>> fs/f2fs/file.c | 4 ++++ >>>>>>>> 1 file changed, 4 insertions(+) >>>>>>>> >>>>>>>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>>>>>>> index 13deae03df06..51fecb2f4db5 100644 >>>>>>>> --- a/fs/f2fs/file.c >>>>>>>> +++ b/fs/f2fs/file.c >>>>>>>> @@ -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 double f2fs_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... > > How about checking i_blocks and i_size instead of checking the entire map? How about v2? Thanks, > >>> >>> Thanks, >>> >>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>>> >>>>>>>> + >>>>>>>> err = f2fs_preallocate_blocks(iocb, from); >>>>>>>> if (err) { >>>>>>>> out_err: >>>>>>>> -- >>>>>>>> 2.32.0 >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Linux-f2fs-devel mailing list >>>>>> Linux-f2fs-devel@lists.sourceforge.net >>>>>> 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 >>> Linux-f2fs-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-02-04 9:11 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-09-28 15:19 [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case Chao Yu 2021-09-28 19:08 ` Jaegeuk Kim 2021-09-29 0:05 ` Chao Yu 2021-10-29 2:34 ` [f2fs-dev] " Chao Yu 2021-10-29 17:43 ` Jaegeuk Kim 2021-10-30 3:02 ` Chao Yu 2021-12-12 3:57 ` Chao Yu 2021-12-14 18:56 ` Jaegeuk Kim 2022-02-04 9:10 ` Chao Yu
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).