diff options
| author | Chao Yu <chao@kernel.org> | 2026-09-17 15:33:41 +0800 |
|---|---|---|
| committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2026-09-18 01:34:22 +0000 |
| commit | 4f9ad04b59c6b7fc6df6e40c5722c6c201ee018f (patch) | |
| tree | 877462a2fd42cdd254e4a14347454da003fdd126 | |
| parent | 6a78d048811659669d9c47bb845c6a5fbca56700 (diff) | |
| download | linux-next-4f9ad04b59c6b7fc6df6e40c5722c6c201ee018f.tar.gz linux-next-4f9ad04b59c6b7fc6df6e40c5722c6c201ee018f.zip | |
f2fs: cache: support fault injection
This patch adds fault injection support for metadata cache allocations
to improve error-path test coverage.
- it integrates entry allocations with FAULT_KMALLOC
Reviewed-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
| -rw-r--r-- | fs/f2fs/cache.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/fs/f2fs/cache.c b/fs/f2fs/cache.c index a56982a02585..0814c38b24bc 100644 --- a/fs/f2fs/cache.c +++ b/fs/f2fs/cache.c @@ -154,23 +154,27 @@ static struct f2fs_cached_block *f2fs_create_cache( struct f2fs_cached_block_list *cache, unsigned long index, bool nofail) { + struct f2fs_sb_info *sbi = cache->sbi; struct f2fs_cached_block *entry; unsigned int flags = GFP_NOFS; if (index == ULONG_MAX) return ERR_PTR(-ERANGE); - if (nofail) + if (nofail) { flags |= __GFP_NOFAIL; - - entry = kzalloc_obj(*entry, flags); - if (!entry) - return ERR_PTR(-ENOMEM); - - entry->data = kmalloc(cache->sbi->blocksize, flags); - if (!entry->data) { - kfree(entry); - return ERR_PTR(-ENOMEM); + entry = kzalloc_obj(*entry, flags); + entry->data = kmalloc(sbi->blocksize, flags); + } else { + entry = f2fs_kzalloc(sbi, sizeof(*entry), flags); + if (!entry) + return ERR_PTR(-ENOMEM); + + entry->data = f2fs_kmalloc(sbi, sbi->blocksize, flags); + if (!entry->data) { + kfree(entry); + return ERR_PTR(-ENOMEM); + } } entry->index = index; |
