mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: continue to allocate pinned section when gc happens EAGAIN
@ 2025-06-12  3:27 wangzijie
  2025-06-12  8:31 ` Chao Yu
  0 siblings, 1 reply; 7+ messages in thread
From: wangzijie @ 2025-06-12  3:27 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: bo.wu, linux-f2fs-devel, linux-kernel, wangzijie

Wu Bo once mentioned a fallocate fail scenario in this link[1].
After commit 3fdd89b452c2("f2fs: prevent writing without fallocate()
for pinned files"), we cannot directly generate 4K size file and
pin it, but we can still generate non-segment aligned pinned file:

touch test_file
./f2fs_io pinfile set test_file
./f2fs_io fallocate 0 0 8192 test_file
truncate -s 4096 test_file

By doing this, pin+fallocate failure(gc happens EAGAIN but f2fs shows
enough spare space) may occurs.

From message in commit 2e42b7f817ac("f2fs: stop allocating pinned sections
if EAGAIN happens"), gc EAGAIN doesn't guarantee a free section, so we stop
allocating. But after commit 48ea8b200414 ("f2fs: fix to avoid panic once 
fallocation fails for pinfile"), we have a way to avoid panic caused by
concurrent pinfile allocation run out of free section, so I think that we 
can continue to allocate pinned section when gc happens EAGAIN. Even if we
don't have free section, f2fs_allocate_pinning_section() can fail with ENOSPC.

[1] https://lore.kernel.org/linux-f2fs-devel/20231030094024.263707-1-bo.wu@vivo.com/t/#u

Signed-off-by: wangzijie <wangzijie1@honor.com>
---
 fs/f2fs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 6bd3de64f..05c80d2b5 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1859,7 +1859,7 @@ static int f2fs_expand_inode_data(struct inode *inode, loff_t offset,
 			f2fs_down_write(&sbi->gc_lock);
 			stat_inc_gc_call_count(sbi, FOREGROUND);
 			err = f2fs_gc(sbi, &gc_control);
-			if (err && err != -ENODATA) {
+			if (err && err != -ENODATA && err != -EAGAIN) {
 				f2fs_up_write(&sbi->pin_sem);
 				goto out_err;
 			}
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-13  8:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-12  3:27 [f2fs-dev] [PATCH] f2fs: continue to allocate pinned section when gc happens EAGAIN wangzijie
2025-06-12  8:31 ` Chao Yu
2025-06-12 12:34   ` wangzijie
2025-06-12 14:07     ` Chao Yu
2025-06-13  2:03       ` wangzijie
2025-06-13  8:25     ` Zhiguo Niu
2025-06-13  8:49       ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®