From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796025655; b=pdhBYyqUgedQDPrddavQWEXluvmodgGDUEYKiltQx0orwbBtWfU6fldYDbRims+YCdK1 ZkdnaTc8wxGvpdLZFC5Sp8jzHOVUoab1xinxGxORqIt6qiVUVdIQogEA7XhkzrB/vcKoQ L7rPZ5rqrWqVquk7TDi71MjPT9CGU2RVXtXrH70HHsTTbmtFtPn/fuLW1xWSVCA8/2aUK jdFbTqkb2AAiPBZ0MUyGuUdtYoEm1sIsheh9U5AOnrFgnR9tvIpPnfApYFalVKSGT0agu jK0cONBQigSNcoh8rVTR5uF0p+s4/NfYfcv16ZU8cq8rTPEq5QAVYUKe1jdvzDOk13A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796025655; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=jaFX6lDwsTOUdt2Dm42PXI3a5eauMxeumCaen5Xc6kU=; b=1aLqyyjk9OJNmLFxs38Y4JSmuZCMK4aS0KrJLr6ntlCAu52nAbILhwgWbnhGK/LTYIKo LvOFYQXkSO5zM8R0jS1Qd91YuHAcxm1wzPQGWMimA42W8XTggtBqB77DYHfCsontG0uvs fxPIIjxWSykggGCPVf6rypUIJBmAPAGA+Nrtf/fIKqmTPiv/gkUiY3Td22XJYzzU7VOYh ClSKQNOFUvV9NEZ/CRi3VQvYkbf1VC8eZy+ytst1wIJMaMz2o+hguuXgasjs+QjwwSH/J vNJv/1pGuFrf+sLAtD+xmvnF+FeemXsyEJOCUOMcE5vsgUAeH3Hxfr2OLWf2ak+i0LQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JMwiSwJ8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 596CE606A32A for ; Mon, 30 Nov 2026 08:00:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JMwiSwJ8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E8F91F00927; Mon, 30 Nov 2026 08:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796025654; bh=jaFX6lDwsTOUdt2Dm42PXI3a5eauMxeumCaen5Xc6kU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JMwiSwJ8CftROtzD6iXNItriJh0ovkMeJXwaa3WLVOQN7nOe6GaGf5QCagy5/dqc5 GOVapjgNzmWy7+cdsMVPJe8Y26PaSLA3XdyVqkK2Ql3p2ptx+D+J71ZfyihCtUalYx iBIkvBgKc9t0OKVRVjXJkAX5E9m/KqXPqtO09jOvwl6qJ5Q0n4yqTceVcq+/CvE80n xI70qG1Ids918sx9IB+r7NRjv9INRZ1IwGXKO49u8fU2eXWioVVLhUpISPTaydnwoy FMHFzK1DubAftmBntAmUZjZZ9uAMiTIut59D7SqhZxC3NRFmzV0jeYkbXM12L6Hbd2 kOi8IltzD3o/A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 2/3] ext4: submit mapped buffers after fatal mapping errors Reply-To: sashiko-reviews@lists.linux.dev To: "Julian Sun" , linux-ext4@vger.kernel.org Cc: tytso@mit.edu In-Reply-To: <20261130073139.4183184-3-sunjunchao@bytedance.com> References: <20261130073139.4183184-1-sunjunchao@bytedance.com> <20261130073139.4183184-3-sunjunchao@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 08:00:54 +0000 X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ext4: writeback loop retries after fatal error with give_up_on_write stuck true -- commit a666f18d34d90ff94f75e3f4027ae28b8d8778ad Author: Julian Sun ext4: submit mapped buffers after fatal mapping errors This commit updates mpage_map_and_submit_extent() to submit already mapped buffers in a folio when a subsequent extent mapping or io_end_vec allocation fails. > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 407a60ac6b85f..ee51b12e31afe 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -2607,6 +2607,7 @@ static int mpage_map_and_submit_extent(handle_t *ha= ndle, > int progress =3D 0; > ext4_io_end_t *io_end =3D mpd->io_submit.io_end; > struct ext4_io_end_vec *io_end_vec; > + bool fatal =3D false; > =20 > io_end_vec =3D ext4_alloc_io_end_vec(io_end); > if (IS_ERR(io_end_vec)) > @@ -2617,8 +2618,10 @@ static int mpage_map_and_submit_extent(handle_t *h= andle, > if (err < 0) { > struct super_block *sb =3D inode->i_sb; > =20 > - if (ext4_emergency_state(sb)) > - goto invalidate_dirty_pages; > + if (ext4_emergency_state(sb)) { > + *give_up_on_write =3D true; > + return err; > + } > /* > * Let the uper layers retry transient errors. > * In the case of ENOSPC, if ext4_count_free_blocks() > @@ -2626,18 +2629,7 @@ static int mpage_map_and_submit_extent(handle_t *h= andle, > */ > if ((err =3D=3D -ENOMEM) || (err =3D=3D -EAGAIN) || > (err =3D=3D -ENOSPC && ext4_count_free_clusters(sb))) { > - /* > - * We may have already allocated extents for > - * some bhs inside the folio, issue the > - * corresponding data to prevent stale data. > - */ > - if (progress) { > - if (mpage_submit_partial_folio(mpd, > - partial_folio_end)) > - goto invalidate_dirty_pages; > - goto update_disksize; > - } > - return err; > + break; > } > ext4_msg(sb, KERN_CRIT, > "Delayed block allocation failed for " > @@ -2651,9 +2643,8 @@ static int mpage_map_and_submit_extent(handle_t *ha= ndle, > "be lost\n"); > if (err =3D=3D -ENOSPC) > ext4_print_free_blocks(inode); > - invalidate_dirty_pages: > - *give_up_on_write =3D true; > - return err; > + fatal =3D true; > + break; > } > progress =3D 1; > /* > @@ -2662,10 +2653,24 @@ static int mpage_map_and_submit_extent(handle_t *= handle, > */ > err =3D mpage_map_and_submit_buffers(mpd); > if (err < 0) > - goto update_disksize; > + break; > } while (map->m_len); > =20 > -update_disksize: > + if (err < 0) { > + /* > + * We may have already allocated extents for some bhs inside > + * the folio, issue the corresponding data to prevent stale > + * data. > + */ > + if (progress && mpage_submit_partial_folio(mpd, partial_folio_end)) > + fatal =3D true; > + > + if (fatal) > + *give_up_on_write =3D true; > + if (!progress) > + return err; > + } [Severity: Medium] Does ext4_do_writepages() keep looping with give_up_on_write latched to true when a fatal -ENOSPC occurs after partial progress in a folio? When mpage_map_one_extent() fails with fatal -ENOSPC (free clusters =3D=3D = 0) after progress =3D=3D 1, mpage_map_and_submit_extent() submits the partial folio, sets *give_up_on_write =3D true, and returns -ENOSPC. In ext4_do_writepages(), mpage_release_unused_pages() sets mpd->scanned_until_end =3D 0 and skips the partially submitted folio up to partial_folio_end, but the loop then treats -ENOSPC as retryable without checking give_up_on_write: fs/ext4/inode.c:ext4_do_writepages() { ... bool give_up_on_write =3D false; ... while (!mpd->scanned_until_end && wbc->nr_to_write > 0) { loff_t partial_folio_end =3D 0; ... if (ret =3D=3D -ENOSPC && sbi->s_journal) { jbd2_journal_force_commit_nested(sbi->s_journal); ret =3D 0; continue; } if (ret =3D=3D -EAGAIN) ret =3D 0; /* Fatal error - ENOMEM, EIO... */ if (ret) break; } } Because give_up_on_write is never reset and the loop does not break when it is set, the next iteration re-enters with partial_folio_end =3D=3D 0 and give_up_on_write =3D=3D true. In WB_SYNC_ALL mode (or once the bio finishes during jbd2_journal_force_commit_nested()), it immediately re-processes the partially submitted folio at mpd->start_pos, fails on the unmapped extent with progress =3D=3D 0, invalidates the folio that was meant to be preserved, and clears ret to 0; if the loop instead advances to later folios, the stale give_up_on_write =3D=3D true causes mpage_release_unused_pages() to invalidate valid dirty folios on any subsequent extent boundary or transient error. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130073139.4183= 184-1-sunjunchao@bytedance.com?part=3D2