From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20B0A3D3307 for ; Mon, 9 Mar 2026 14:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773066316; cv=none; b=WMJSTeqPhB+BN5brYVjN407WT09BFmAXRZWv42ScvraEoCROX9/zF6WjJGvepg2zgwnUqjCzzsZrJdZdFGLLpZZecvHQLrnHc8ykhWSaIm5aKsyt5Mt6WEbmxWG4R7A2pMmRMoZsEtrqi9ME2U55cLjkY6PBg+q2wgcxo/GlNK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773066316; c=relaxed/simple; bh=/9fVPkow3relxh9kYE+o4Tw5C28MgVzYPKFTlG5sw5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OtPnodYqR9JOeGhjkbLE5C6TXMs/0N3NW64p4GS+MNmGSlk35vdzJ/PGAo3KbBgpY6Rkt/nmJCSvw82zBmt1/BZsUS7/N4J+5TPXEp7P3s2VdyujwDlt9RwZSK3AYJHNEZ9buSO5MIHQjqFPACP9UVELZt9BBUnTehtinylxBHA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cKBPHuvV; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cKBPHuvV" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-8244105fa96so600271b3a.3 for ; Mon, 09 Mar 2026 07:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773066314; x=1773671114; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c7aG9u42wmFmQg8NexFKsDrO72+eXJWZ5zwfM9O0k3U=; b=cKBPHuvVkK9K+7MAClC5WU3peP1OoblKy0fQlQjiqgHmVulG+7qQWeX5n1hgan4Byj PygIsvTbPCnCQxklld8UjRXNs0W+lFGd69q6/DztO3SBTfUEEUdM8Wm+a9dPFbVoU0yD +S1dpr30m14teZiM9k1fC3E9Xnhg5aqUBxZwhpEAYLfIMbEsXgNdp6zyGUcTsiZDEmoz fWLd2uSLrW5eg0ABSeYf2dRXYXPbkpll3ABFF/haI6GB5gZBeRgws3edtbSPbdH3KvSV oWkUxFR/wboZGwp9gHxaep4caVZ4z5krk9qIAtNRHzmK3jwy+rjPw/J7VqdnYZCcmbrb +0iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773066314; x=1773671114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=c7aG9u42wmFmQg8NexFKsDrO72+eXJWZ5zwfM9O0k3U=; b=fDO+kWDOjEL6v/P1N8cC/kr3GxEcmSJ3ZvRjidnX7T7XrITEnab1DoERqxcRaz9oQl JsfYQtq5yZtRDZI6jVhrLqblpWV1qLo6gHululpDvtvBjRSLi68FtIA500rfWdKkq5KG C/8gxFl5f2bF7bqB9zxUAjKjcg9yM7TnqqW6ZvNwB+dJHH/x/fpy7tqpv9YeICLzl6jU 84jFDKTYHsdee14oi4ZO2jJanvUrB5QP1ttoS4c3Kkuea985lwAs/cWmJiH5rU1/AmDg +ZRLYUfUjSmCqVMOIBQ9S8aPaSGovVCl4/83pz65IgKZ3LrGATi2vyQy/XIwrlJXD8Mn I94A== X-Forwarded-Encrypted: i=1; AJvYcCXbFI55NMP3R6HtH0wBH0VmVtF0cKGJsW0Dt1BaHFXLTA4AAIYFVqZZzwjnC6nXhuFvVjt2EgyhodIWw4A=@vger.kernel.org X-Gm-Message-State: AOJu0YxKh73TRi92WrExQ0uQQUMIoGahPT9o+7glkiQdLGP1sxm1aAzV Z0/Jt+y/Ns5OZmIv9McfQ0rqmE429B+F4jiUu360/Y+Kb+Mdg3v7Faud X-Gm-Gg: ATEYQzxB4TU7oWk0fR86AEIM3rC6qMlzZVOfajfn7Bw873O/SRFQARSr/rzkcqbx0Dr 5w6hWMDtfeJmro2nugEryvB/oOCWF7cxNweV32act4z1+e2Pm83RWDcZv/tBZOd7kKHsMB/7pKV uhgC4jeRDMqNULZalW9vFjw/ThXoTdqm5Fv2wCdhA49VoAxO4x0J4YJ15MGbAvJm96PUVZup6MZ TAG7a3sjr2ag1VEu0yG6twCxvdZxDa1i3Qd9r4fL1Uf0Fy4s1bboag/cWOtgk2Jg6Myx61uD+IC ml+OKkcVrR+EwgpzkTigyDKuCm8dYMObayF+UGW7rtA5eKVHgLjgh9ncXnkuuMFzHJnU33pNrMO CTPrYmNZsb3csXXa6cFHPfr2LgXkUybbGfbhytndVkiVIPW/I8hOUCWvaNmCV4sWENL9MjvbEsW /4h3qoAQ5hBBDTa+pGgLQxy3qiwkCT9g== X-Received: by 2002:a05:6a00:7087:b0:81f:e791:ea3d with SMTP id d2e1a72fcca58-829a2bc7669mr5220002b3a.0.1773066314438; Mon, 09 Mar 2026 07:25:14 -0700 (PDT) Received: from kt5965-NUC8i3BEH.. ([182.217.14.201]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-829a4636a9dsm10482027b3a.4.2026.03.09.07.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2026 07:25:13 -0700 (PDT) From: kth5965@gmail.com To: Chao Yu , jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: syzbot+fc026e87558558f75c00@syzkaller.appspotmail.com, linux-kernel@vger.kernel.org, kth5965@gmail.com Subject: Re: [f2fs-dev] [PATCH v2] f2fs: evict: truncate page cache before clear_inode Date: Mon, 9 Mar 2026 23:25:09 +0900 Message-ID: <20260309142509.75703-1-kth5965@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <9df7bc57-f0e1-4c7b-9ce1-0017eab62c2a@kernel.org> References: <20260224160654.448538-1-kth5965@gmail.com> <20260224165408.450957-1-kth5965@gmail.com> <9df7bc57-f0e1-4c7b-9ce1-0017eab62c2a@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Chao, Thanks for the comment. I took another look at the path, and I think you are right that my current fix is too broad and may hide the real problem. It looks like this happens in a more specific case, where an inode still has FI_INLINE_DATA set, but FI_DATA_EXIST is not set. In that case, f2fs_truncate() goes into the inline conversion path, and f2fs_convert_inline_inode() grabs folio 0 before it checks whether there is real inline data to move. Then f2fs_convert_inline_folio() does this: if (!f2fs_exist_data(dn->inode)) goto clear_out; So for the empty-inline case, it returns success, but folio 0 seems to have already been added to the page cache by then. >From what I can see, f2fs_grab_cache_folio() may create folio 0 and add it to inode->i_mapping when there is no folio at that index, so inode->i_data.nrpages becomes 1 there. After that, f2fs_folio_put() only drops the ref, and the folio stays there. Because of that, clear_inode() later sees nrpages != 0 and hits the BUG. This is the flow I am seeing: f2fs_evict_inode() -> truncate_inode_pages_final(&inode->i_data) // nrpages = 0 -> i_size_write(inode, 0) -> f2fs_truncate(inode) -> !f2fs_may_inline_data(inode) -> f2fs_convert_inline_inode(inode) -> f2fs_grab_cache_folio(inode->i_mapping, 0, false) // folio 0 is inserted into page cache // nrpages = 1 -> f2fs_convert_inline_folio(&dn, folio) -> !f2fs_exist_data(inode) -> clear_out -> f2fs_folio_put(folio, true) // only drops the ref // folio stays in page cache -> clear_inode() -> BUG_ON(inode->i_data.nrpages) So it seems better to fix this in the inline conversion path, instead of truncating all page cache again at the end of eviction. If you agree, I can send a new patch in that direction. Thanks,