[PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case
From: Chao Yu
Date: Tue Sep 28 2021 - 11:19:29 EST
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@xxxxxxxxxx>
---
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