From nobody Sat Feb 7 21:08:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 991AD2940D for ; Fri, 16 Jan 2026 08:58:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768553896; cv=none; b=gzJqISjOxU+aMugZ5Q1PBVjWkp+8YSioTtFm0EIskOFachvHUX6hhpxo6h9srWVKMXBMU33kXn2EiY3ysAaPGhbPO/+8jo/qNmlCdH+T5vTrO0UV21cK+taDd00nYnbNFe8kBvEStjh45shJbQTHT3rvYbyLZX7EmPX5CRNOwMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768553896; c=relaxed/simple; bh=WTvV40fRxMzH1AP7htSCOKbaMIyOF0igMiKpWQjc6AQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=AMwXmz3nWmeaGCheM79omN0tsy9AOe+nyNymbk5x6vJfQkqEWqCbzdv21Xo6Nhl4pGsQb0FbiB0Yi6ig0ZHM6bjQQ/d4vFVyzs/6MsazXuJKE2NmRKePJxP6IfS17kR1CQ6yVmPcnezI30kx2xpDwYsz1A/6LqHCbQyGaPkyHEM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hDn14edj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hDn14edj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F955C116C6; Fri, 16 Jan 2026 08:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768553896; bh=WTvV40fRxMzH1AP7htSCOKbaMIyOF0igMiKpWQjc6AQ=; h=From:To:Cc:Subject:Date:From; b=hDn14edjLUc2O5CkHOfWpwX7Hv9YCZzKMJqpxQ7qeNg1XS36aD0NUtVFfBrVKM/vs yL3oUtDFysK8Qi5X+6eAMJ9G3H1iAKL9MGfbzsi6XbjwwgJgJ6ADBJBwWq0es6h7nn 7uOpYPVQWbont4bmGDKD0NwOzUNYpdw0ya9Egpzank3bIzkYEiAmwgmkQN3OIRdk9V gbVWsb5bryiXWc1MN7RUtBYI2TJYEuAVZLEG57AwHJ0rOWxYVp0aqy4kiz8eProjX1 RKelVd/MxTSwcNtFBbkBjCOHSqeYFJ1QNfUMMqyvIpcbjKfW3QFAYXQaoXAz6JLUpf 1X3wdT8PbC+dw== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v2] f2fs: fix to unlock folio in f2fs_read_data_large_folio() Date: Fri, 16 Jan 2026 14:31:15 +0800 Message-Id: <20260116063115.21938-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We missed to unlock folio in error path of f2fs_read_data_large_folio(), fix it. With below testcase, it can reproduce the bug. touch /mnt/f2fs/file truncate -s $((1024*1024*1024)) /mnt/f2fs/file f2fs_io setflags immutable /mnt/f2fs/file sync echo 3 > /proc/sys/vm/drop_caches time dd if=3D/mnt/f2fs/file of=3D/dev/null bs=3D1M count=3D1024 f2fs_io clearflags immutable /mnt/f2fs/file echo 1 > /proc/sys/vm/drop_caches time dd if=3D/mnt/f2fs/file of=3D/dev/null bs=3D1M count=3D1024 time dd if=3D/mnt/f2fs/file of=3D/dev/null bs=3D1M count=3D1024 Signed-off-by: Chao Yu --- v2: - rebase to last dev-test branch fs/f2fs/data.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d685c889f7b6..d509172b51df 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2453,11 +2453,11 @@ static int f2fs_read_data_large_folio(struct inode = *inode, int ret =3D 0; bool folio_in_bio; =20 - if (!IS_IMMUTABLE(inode)) - return -EOPNOTSUPP; - - if (f2fs_compressed_file(inode)) + if (!IS_IMMUTABLE(inode) || f2fs_compressed_file(inode)) { + if (folio) + folio_unlock(folio); return -EOPNOTSUPP; + } =20 map.m_seg_type =3D NO_CHECK_TYPE; =20 @@ -2565,18 +2565,16 @@ static int f2fs_read_data_large_folio(struct inode = *inode, last_block_in_bio =3D block_nr; } trace_f2fs_read_folio(folio, DATA); +err_out: + if (!folio_in_bio) { + folio_end_read(folio, !ret); + if (ret) + return ret; + } if (rac) { - if (!folio_in_bio) - folio_end_read(folio, true); folio =3D readahead_folio(rac); goto next_folio; } -err_out: - /* Nothing was submitted. */ - if (!bio) { - folio_end_read(folio, !ret); - return ret; - } out: f2fs_submit_read_bio(F2FS_I_SB(inode), bio, DATA); if (ret) { --=20 2.40.1