aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2024-02-22 20:18:51 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2024-02-29 08:34:34 -0800
commit8b10d3653735e117bc1954ade80d75ad7b46b801 (patch)
tree1a10c5b7bfab11d04f5da5995e77f5c0a5fff218
parentf2fs: compress: fix to check compress flag w/ .i_sem lock (diff)
downloadwireguard-linux-8b10d3653735e117bc1954ade80d75ad7b46b801.tar.xz
wireguard-linux-8b10d3653735e117bc1954ade80d75ad7b46b801.zip
f2fs: introduce FAULT_NO_SEGMENT
Use it to simulate no free segment case during block allocation. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--Documentation/ABI/testing/sysfs-fs-f2fs1
-rw-r--r--Documentation/filesystems/f2fs.rst1
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/segment.c5
-rw-r--r--fs/f2fs/super.c1
5 files changed, 9 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index 22d070c0de40..1a4d83953379 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -724,6 +724,7 @@ Description: Support configuring fault injection type, should be
FAULT_LOCK_OP 0x000020000
FAULT_BLKADDR_VALIDITY 0x000040000
FAULT_BLKADDR_CONSISTENCE 0x000080000
+ FAULT_NO_SEGMENT 0x000100000
=========================== ===========
What: /sys/fs/f2fs/<disk>/discard_io_aware_gran
diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst
index 8930d9ea8c4e..efc3493fd6f8 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -205,6 +205,7 @@ fault_type=%d Support configuring fault injection type, should be
FAULT_LOCK_OP 0x000020000
FAULT_BLKADDR_VALIDITY 0x000040000
FAULT_BLKADDR_CONSISTENCE 0x000080000
+ FAULT_NO_SEGMENT 0x000100000
=========================== ===========
mode=%s Control block allocation mode which supports "adaptive"
and "lfs". In "lfs" mode, there should be no random
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 4ce48dbae55b..f1ec1a53afec 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -62,6 +62,7 @@ enum {
FAULT_LOCK_OP,
FAULT_BLKADDR_VALIDITY,
FAULT_BLKADDR_CONSISTENCE,
+ FAULT_NO_SEGMENT,
FAULT_MAX,
};
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index a5339dd7a932..dab9544f871a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2656,6 +2656,11 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
spin_lock(&free_i->segmap_lock);
+ if (time_to_inject(sbi, FAULT_NO_SEGMENT)) {
+ ret = -ENOSPC;
+ goto out_unlock;
+ }
+
if (!new_sec && ((*newseg + 1) % SEGS_PER_SEC(sbi))) {
segno = find_next_zero_bit(free_i->free_segmap,
GET_SEG_FROM_SEC(sbi, hint + 1), *newseg + 1);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 329f317e6f09..6190aace3d8c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -63,6 +63,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
[FAULT_LOCK_OP] = "lock_op",
[FAULT_BLKADDR_VALIDITY] = "invalid blkaddr",
[FAULT_BLKADDR_CONSISTENCE] = "inconsistent blkaddr",
+ [FAULT_NO_SEGMENT] = "no free segment",
};
void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,