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 6D2FE456E18 for ; Tue, 25 Aug 2026 13:02:00 +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=1787662921; cv=none; b=k0kyZ0NIuyLrcZ0F2gQR8QrfCgXjj6+Zd6K2F3gTanD1GBQzAAQ+3GgaRcD/ObN/4nj+kWYJ3fI2IhvK5FFoZXSzLtc0whI61HjqNa7jVoRtLkSCLjJiHcv8El1e1XD0PDz2FjHPUg/mbHmVLbfQegjEO2wiRJUs7psy/R10K6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787662921; c=relaxed/simple; bh=u1a8tpw5pwGfgs0PnBkXuSAXD3pFDnKK4tzguNfoz/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lafjkPLAwS3ZQuoetABg4QYeBhSVgAhVZ8uQ2dFg+Qjbd3e1hLcoXWA6Q55h7n1G0Ynq6XVi5wxuj3ViXx3yBYg0daMYAurPmsCbBgcDKKMrbGZ2+hPU+SIQ12mQ23w5sFIGbpOG9HxVkkpKsdDFsPLBQ1m8sa/SlzF8naJiKUU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BZ2niHR7; 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="BZ2niHR7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74C9B1F00A3A; Tue, 25 Aug 2026 13:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787662920; bh=woi8uMQ7S42OB583LusLSO/YvHwGV7JGGq/jwY/otO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BZ2niHR7tNqstR5qOh/xtKAi8jrturxm7wso4l+A2WKXDpAXjpTSrEIMbJQQq3IkO 6ZMM1iZxXmTG3rrPjfSz8hXNcYTAo1TTWKk1rjNsk0Fe9SjNKN/kdvA9aRv91TQ8BD 3bn2l6LRSKkOu4iX/0ZFqckFEpiQbUFhnoY/SKCGxK5qkFngaBnDOk6EixoUqEWepq tgaI3S0w3tR/uCcobKSPZkWH8m9zipvvXhgOaUfoUpDPdyYpwYZnwNLhqz/gJReyU0 FM5l8bVWCUqVvsjB55FIPSB/7FTdWN7fSSlGWIj4oT/T9DqPDdy1XXPueY3X04Dfow /pKubFwfida+A== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v3 10/12] f2fs: cache: support fault injection Date: Tue, 25 Aug 2026 21:01:24 +0800 Message-ID: <20260825130126.2078627-11-chao@kernel.org> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog In-Reply-To: <20260825130126.2078627-1-chao@kernel.org> References: <20260825130126.2078627-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 5b9055ad49b9..013433ce96dc 100644 --- a/fs/f2fs/cache.c +++ b/fs/f2fs/cache.c @@ -176,20 +176,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 = 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; -- 2.49.0