From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9398738399D for ; Thu, 20 Aug 2026 03:17:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787195861; cv=none; b=U452371fPecy+UqINoEPULgaIxUKnYCW0TG97Ux8KjP4XoWo5HVvirHemiVgZC6idi4+g5J/S6QtbGaco97Hw0w1P/BLgFWW23m0RnNvc649HxTS1bCQnfON3cmAa8QAcFgGbXPtBjthgUUPISLlFvWs1ggxq1V0LXkQivDeAFY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787195861; c=relaxed/simple; bh=sNCGxL+tfytLcCOUluNkrHc2iYsdRz9Sg5xWRGmGh4Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rnjt3r5Y4CUtZPeIrisK420eFVDgTI94eZT1zjQbT5CZ2lf9FFuaoCOo5s6SP93/tquZEYQnKrIHCpyHsWjLLjAVs43AyD55MghoceCr3vL2w8eh0sVuaL1uUdH52w2pvzwfajwubNr6dt5RG51WtY5vzasLZQWOyJ2iqMRog14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NagxIGbr; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NagxIGbr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6A891F00AC4; Thu, 20 Aug 2026 03:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787195859; bh=oTqEd0voYGtT537IzPkiJFfZHAD1HJt51CGNpbeKdN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NagxIGbrtBC/whT6VatfwuM4FXpXHgah3pR8/26tT6Iqek5SPo/yf+z2Fsu5imu3l sNI1iJ7++gfqeLF1jiDvb+IZIm7XzeubUIBQP1blDiOvoG6VmkC5i8x6mMeqfa6aLx xVbDzcDxPuCC7Gdfmp10oSOybIC7jo0E90o2TVC9mEm/UiBNfX/v5BKDdvnrXujnwN bx4SMfquAhNxiSoLvhfIn8Mw8VKfq1ej9FT41VwSHKhx8hX7D9PRIA7dfyXBxIOhyI /tgy2a9VU3M02nTNsHW2VN8Z5UwIRPAkscpTfOvIUms8uvn8htmxNIWjJrha4q7ZHM kpvOBrSLIdl0A== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v1 10/12] f2fs: cache: support fault injection Date: Thu, 20 Aug 2026 11:17:19 +0800 Message-ID: <20260820031721.12218-11-chao@kernel.org> X-Mailer: git-send-email 2.55.0.737.g08866a6d13-goog In-Reply-To: <20260820031721.12218-1-chao@kernel.org> References: <20260820031721.12218-1-chao@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This patch adds fault injection support for metadata cache allocations to improve error-path test coverage. - it integrates entry allocations with FAULT_KALLOC Signed-off-by: Chao Yu --- fs/f2fs/cache.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fs/f2fs/cache.c b/fs/f2fs/cache.c index 173bbf3aa94c..c1e5c945391f 100644 --- a/fs/f2fs/cache.c +++ b/fs/f2fs/cache.c @@ -175,20 +175,24 @@ 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 (nofail) + if (nofail) { flags |= __GFP_NOFAIL; - - entry = kzalloc_obj(*entry, flags); - if (!entry) - return ERR_PTR(-ENOMEM); - - entry->data = kzalloc(cache->sbi->blocksize, flags); - if (!entry->data) { - kfree(entry); - return ERR_PTR(-ENOMEM); + entry = kzalloc_obj(*entry, flags); + entry->data = kzalloc(sbi->blocksize, flags); + } else { + entry = f2fs_kzalloc(sbi, sizeof(*entry), flags); + if (!entry) + return ERR_PTR(-ENOMEM); + + entry->data = f2fs_kzalloc(sbi, sbi->blocksize, flags); + if (!entry->data) { + kfree(entry); + return ERR_PTR(-ENOMEM); + } } entry->index = index; -- 2.49.0