From mboxrd@z Thu Jan 1 00:00:00 1970 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 A95A01E1A17 for ; Thu, 5 Mar 2026 01:38:41 +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=1772674721; cv=none; b=OqqHbDLt1zSpJwQcsw7YNX1uq3VaBS2aF6Eb8LGlrkzzzenmiLnwwdkPp/UpLkggLQRgFFt6va2j7OKoA6igOl6oQGIvnbb8Q6axK6cssQoMw13239Ks+j+H8x/dXuyYxrajsDNuB/A9Nqss8XdUOhJAFD3Tw9SCA6XYbLVuIyE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772674721; c=relaxed/simple; bh=PC0x8rLLQccI9BVwFZh3mpYbi/GIUaRDVYCDGHFylsk=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=AFnP8Wcj/bzLLu+MsLwHBElHi4sEQ2sePzdGLOOH4ebiyY6TVDCAJMuPni2WLikGUGPfxWVyxUDXljIjnsLx1PTMnQ8O+IQ9YkzN90Jfr9TTE62i7fcp301HqiOCEx67yqazbxICb9Ueh1TN42CTru69//xfAJb262xooBVHtro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jG/CbIB9; 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="jG/CbIB9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 839E7C4CEF7; Thu, 5 Mar 2026 01:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772674721; bh=PC0x8rLLQccI9BVwFZh3mpYbi/GIUaRDVYCDGHFylsk=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=jG/CbIB9m5fUWW35CPG1wUpqV2q5g7gMA36Kuqu/tp41UL4w4UTo8QT2/VaqbuRn2 1xjuzDRnMwkbVq/3ist5dGJMz3P39F9AfyvXhnLf9dvd7zAVsMzhkr03Kp7EqUn+2L /VPloSsKC9Smceza4iCrELvVGVMbtsUkx1texR1SxdvB8n70mG+LmSQc6nsNrHAR58 7pvLkjYU/Yrlx+U6DDC7h9u3eFGlvLlCqpdajF0A8yLhB3hG/WdkyPx6uIr2uA7/c1 EL0FWT88KZ49zehQeCMUApxMeMX3B9FjtJ/7IattIonWHoOgz6zi+yCrVBbWKf4NPJ FhLgzIMX6nQ6g== Message-ID: <40f2718e-73b7-415f-9ea1-fb478b987ffe@kernel.org> Date: Thu, 5 Mar 2026 09:38:37 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, wanghui33@xiaomi.com, linux-kernel@vger.kernel.org, Sheng Yong Subject: Re: [PATCH v2] f2fs: avoid reading already updated pages during GC To: Jianan Huang , linux-f2fs-devel@lists.sourceforge.net, jaegeuk@kernel.org References: <20260305011810.4189655-1-huangjianan@xiaomi.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20260305011810.4189655-1-huangjianan@xiaomi.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026/3/5 09:18, Jianan Huang wrote: > We found the following issue during fuzz testing: > > page: refcount:3 mapcount:0 mapping:00000000b6e89c65 index:0x18b2dc pfn:0x161ba9 > memcg:f8ffff800e269c00 > aops:f2fs_meta_aops ino:2 > flags: 0x52880000000080a9(locked|waiters|uptodate|lru|private|zone=1|kasantag=0x4a) > raw: 52880000000080a9 fffffffec6e17588 fffffffec0ccc088 a7ffff8067063618 > raw: 000000000018b2dc 0000000000000009 00000003ffffffff f8ffff800e269c00 > page dumped because: VM_BUG_ON_FOLIO(folio_test_uptodate(folio)) > page_owner tracks the page as allocated > post_alloc_hook+0x58c/0x5ec > prep_new_page+0x34/0x284 > get_page_from_freelist+0x2dcc/0x2e8c > __alloc_pages_noprof+0x280/0x76c > __folio_alloc_noprof+0x18/0xac > __filemap_get_folio+0x6bc/0xdc4 > pagecache_get_page+0x3c/0x104 > do_garbage_collect+0x5c78/0x77a4 > f2fs_gc+0xd74/0x25f0 > gc_thread_func+0xb28/0x2930 > kthread+0x464/0x5d8 > ret_from_fork+0x10/0x20 > ------------[ cut here ]------------ > kernel BUG at mm/filemap.c:1563! > folio_end_read+0x140/0x168 > f2fs_finish_read_bio+0x5c4/0xb80 > f2fs_read_end_io+0x64c/0x708 > bio_endio+0x85c/0x8c0 > blk_update_request+0x690/0x127c > scsi_end_request+0x9c/0xb8c > scsi_io_completion+0xf0/0x250 > scsi_finish_command+0x430/0x45c > scsi_complete+0x178/0x6d4 > blk_mq_complete_request+0xcc/0x104 > scsi_done_internal+0x214/0x454 > scsi_done+0x24/0x34 > > which is similar to the problem reported by syzbot: > https://syzkaller.appspot.com/bug?extid=3686758660f980b402dc > > This case is consistent with the description in commit 9bf1a3f > ("f2fs: avoid GC causing encrypted file corrupted"): > Page 1 is moved from blkaddr A to blkaddr B by move_data_block, and after > being written it is marked as uptodate. Then, Page 1 is moved from blkaddr > B to blkaddr C, VM_BUG_ON_FOLIO was triggered in the endio initiated by > ra_data_block. > > There is no need to read Page 1 again from blkaddr B, since it has already > been updated. Therefore, avoid initiating I/O in this case. > > Fixes: 6aa58d8ad20a ("f2fs: readahead encrypted block during GC") > Signed-off-by: Jianan Huang > Signed-off-by: Sheng Yong Reviewed-by: Chao Yu Thanks,