From nobody Sun Feb 8 05:27:23 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 51223500948 for ; Mon, 12 Jan 2026 01:30:58 +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=1768181458; cv=none; b=tDBlm96pDXI8rXC6ewogquDKbjUe0xkWHeUnjZ8w8etxJrTqLVsrfFx5wvlTu7IShH/XrbXEoauQ5QFiytpayZKl2Jhl7bslN5dBIF4Ud/FdqPzYrMX5XpQZlnQLrvfUtSB3XfXi4NfQdHqvA1kibYYo0amESDKVfkjad9oO3GQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768181458; c=relaxed/simple; bh=zb6R+J9kkW67RrSB5zaxDMsHKu/A1fi9UpiW2r/jkL0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=rm+fRjqrIG3en1b7zbBF6+928FB075/o8F0g+lnpARwQpKw9v4BkcMlv6C7HuWkkCwl7SwzG3wRIov31K3tflZT5D2PM3vQZ7Shtq7l9MGFzLPmu2BLQgNh7PkGtXze+d+3SZsdb/SKPdYVwdvxX3rZd5GkAWIQqB7bHR6VEfDA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KnXVJaqe; 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="KnXVJaqe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7D5DC4CEF7; Mon, 12 Jan 2026 01:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768181457; bh=zb6R+J9kkW67RrSB5zaxDMsHKu/A1fi9UpiW2r/jkL0=; h=From:To:Cc:Subject:Date:From; b=KnXVJaqeBj6/lKmz8vDUkzLzhMLuTLlQRKU7DOQdGOFGcY8sUDiwWjlqpmyrrvnbI RPx9HMm1hzTHZmUhnc3yM97p9c+EPhx/2h5Mmuuqq3in2YSYOnXgUUt+/yZQ8CyhrC KhiuSAqtItTsX+G0IrshuJ1VHHBF0PBliDhbWKNpn7x+X6ah5JfnZboK06rtXHnB1R AOmyGVrf+TnElXj2nG0fhNHlvQSxhoTP/ApO+Le/4/5HokqGHXtnK5LtjUY0fPbYuu eZ05WaCKYJbxi+h6shr8fb3M+7YyW0XQ1eb9JhUPpKd521B6VznEGyw3wAFGHSzSHJ Q2YSbRnghyRcg== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH] f2fs: fix to unlock folio in f2fs_read_data_large_folio() Date: Mon, 12 Jan 2026 09:30:52 +0800 Message-Id: <20260112013052.7623-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 --- Changelog: - this patch is based on Nanzhe Zhao's patchset fs/f2fs/data.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index eeeb70bff101..a2c4769d0ae1 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2462,11 +2462,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 @@ -2569,22 +2569,18 @@ static int f2fs_read_data_large_folio(struct inode = *inode, last_block_in_bio =3D block_nr; } trace_f2fs_read_folio(folio, DATA); - if (rac) { - if (!folio_in_bio) { - if (!ret) - folio_mark_uptodate(folio); - folio_unlock(folio); - } - folio =3D readahead_folio(rac); - goto next_folio; - } + err_out: - /* Nothing was submitted. */ - if (!bio) { + if (!folio_in_bio) { if (!ret) folio_mark_uptodate(folio); folio_unlock(folio); - return ret; + if (ret) + return ret; + } + if (rac) { + folio =3D readahead_folio(rac); + goto next_folio; } out: f2fs_submit_read_bio(F2FS_I_SB(inode), bio, DATA); --=20 2.40.1