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 0A72242F71E for ; Mon, 24 Aug 2026 13:47:58 +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=1787579279; cv=none; b=Aa78TaJqF712HyZ0Fwe4wjPmoHazPI/2WPEmUaWapscpegzDmUifHDFIJzv8QKqI+LALzK8r9VatvJpgJXMNwgeOxjVcoY+XRCzwK/lFtTK5f2wLrr41gNnh2xSxm2AJTQTuOhLdatanhJNS7l5idIk+cLOqArvP3uWK8+Watfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787579279; c=relaxed/simple; bh=xQqRDUDuQl5Ut1UmguH8glG9gsbPMn9MbQN2wIYELnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EXr8QZhYR+luZ2k5iSqCxggPSP1Eu2z89hsqOH711bfQKGZd5bHOC9J65dQ61lyf0CU2AT4Y1YL1OG6HujNewVD+J+FMNICKUrE/yhe5tcEfBsy9JBHcZWQBvFm/2aP83ifW68QYUqGm2gYQ1U4m/Q/SbGiI6C6VJOFWMmmyq0k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NRyb33YF; 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="NRyb33YF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA1EB1F00A3E; Mon, 24 Aug 2026 13:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787579277; bh=AuBQ7SzUhmbIpKh6rJqhmzk4+eaWZE2juoVfuGuipNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NRyb33YFulkboG+pVU6wkOECYWEm8g6wPsXhWujBiLnmyWb4b5yBztj5UGWOrxzuN JFEzTQog2rcDPWp/ovu+se3n1LnxDFCXZfWWQ07J5dXN+wZAs4wmWulaz9Ump6KID5 3p8RbhXaE++/QhR0Gg/7+GstqI/iSlErDAM6/U3u8YSD4uRUNsULx81GFzfUqwQwXI LoIG3x1YparSLpQjHmv8YFIT4jmDMOrgjgdCH30ptk7Ho8nTuJoRRdWeaVaftoknME 4vuGBdIDHGNsJvis39H/v7SALEaVhzcFaTQPCITXpUj/x8MvLug9nUxL6Wlhcb9hEk y3an1yuHNdO3Q== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v2 10/12] f2fs: cache: support fault injection Date: Mon, 24 Aug 2026 21:47:29 +0800 Message-ID: <20260824134731.3704352-11-chao@kernel.org> X-Mailer: git-send-email 2.55.0.766.g2966f0265a-goog In-Reply-To: <20260824134731.3704352-1-chao@kernel.org> References: <20260824134731.3704352-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 77b40a98380c..9a9d62283ae0 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