Archive-only list for patches
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Jan Kara <jack@suse.cz>,
	Zhang Yi <yi.zhang@huawei.com>, Theodore Tso <tytso@mit.edu>
Subject: [PATCH 6.16 8/9] ext4: reserved credits for one extent during the folio writeback
Date: Fri, 22 Aug 2025 14:37:08 +0200	[thread overview]
Message-ID: <20250822123517.094089854@linuxfoundation.org> (raw)
In-Reply-To: <20250822123516.780248736@linuxfoundation.org>

6.16-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Zhang Yi <yi.zhang@huawei.com>

commit bbbf150f3f85619569ac19dc6458cca7c492e715 upstream.

After ext4 supports large folios, reserving journal credits for one
maximum-ordered folio based on the worst case cenario during the
writeback process can easily exceed the maximum transaction credits.
Additionally, reserving journal credits for one page is also no
longer appropriate.

Currently, the folio writeback process can either extend the journal
credits or initiate a new transaction if the currently reserved journal
credits are insufficient. Therefore, it can be modified to reserve
credits for only one extent at the outset. In most cases involving
continuous mapping, these credits are generally adequate, and we may
only need to perform some basic credit expansion. However, in extreme
cases where the block size and folio size differ significantly, or when
the folios are sufficiently discontinuous, it may be necessary to
restart a new transaction and resubmit the folios.

Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20250707140814.542883-9-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/ext4/inode.c |   25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2548,21 +2548,6 @@ update_disksize:
 	return err;
 }
 
-/*
- * Calculate the total number of credits to reserve for one writepages
- * iteration. This is called from ext4_writepages(). We map an extent of
- * up to MAX_WRITEPAGES_EXTENT_LEN blocks and then we go on and finish mapping
- * the last partial page. So in total we can map MAX_WRITEPAGES_EXTENT_LEN +
- * bpp - 1 blocks in bpp different extents.
- */
-static int ext4_da_writepages_trans_blocks(struct inode *inode)
-{
-	int bpp = ext4_journal_blocks_per_folio(inode);
-
-	return ext4_meta_trans_blocks(inode,
-				MAX_WRITEPAGES_EXTENT_LEN + bpp - 1, bpp);
-}
-
 static int ext4_journal_folio_buffers(handle_t *handle, struct folio *folio,
 				     size_t len)
 {
@@ -2919,8 +2904,14 @@ retry:
 		 * not supported by delalloc.
 		 */
 		BUG_ON(ext4_should_journal_data(inode));
-		needed_blocks = ext4_da_writepages_trans_blocks(inode);
-
+		/*
+		 * Calculate the number of credits needed to reserve for one
+		 * extent of up to MAX_WRITEPAGES_EXTENT_LEN blocks. It will
+		 * attempt to extend the transaction or start a new iteration
+		 * if the reserved credits are insufficient.
+		 */
+		needed_blocks = ext4_chunk_trans_blocks(inode,
+						MAX_WRITEPAGES_EXTENT_LEN);
 		/* start a new transaction */
 		handle = ext4_journal_start_with_reserve(inode,
 				EXT4_HT_WRITE_PAGE, needed_blocks, rsv_blocks);



  parent reply	other threads:[~2025-08-22 12:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22 12:37 [PATCH 6.16 0/9] 6.16.3-rc1 review Greg Kroah-Hartman
2025-08-22 12:37 ` [PATCH 6.16 1/9] ext4: process folios writeback in bytes Greg Kroah-Hartman
2025-08-22 12:37 ` [PATCH 6.16 2/9] ext4: move the calculation of wbc->nr_to_write to mpage_folio_done() Greg Kroah-Hartman
2025-08-22 12:37 ` [PATCH 6.16 3/9] ext4: fix stale data if it bail out of the extents mapping loop Greg Kroah-Hartman
2025-08-22 12:37 ` [PATCH 6.16 4/9] ext4: refactor the block allocation process of ext4_page_mkwrite() Greg Kroah-Hartman
2025-08-22 12:37 ` [PATCH 6.16 5/9] ext4: restart handle if credits are insufficient during allocating blocks Greg Kroah-Hartman
2025-08-22 12:37 ` [PATCH 6.16 6/9] ext4: enhance tracepoints during the folios writeback Greg Kroah-Hartman
2025-08-22 12:37 ` [PATCH 6.16 7/9] ext4: correct the reserved credits for extent conversion Greg Kroah-Hartman
2025-08-22 12:37 ` Greg Kroah-Hartman [this message]
2025-08-22 12:37 ` [PATCH 6.16 9/9] ext4: replace ext4_writepage_trans_blocks() Greg Kroah-Hartman
2025-08-22 13:42 ` [PATCH 6.16 0/9] 6.16.3-rc1 review Ronald Warsow
2025-08-22 21:00 ` Takeshi Ogasawara
2025-08-22 21:29 ` Florian Fainelli
2025-08-22 23:27 ` Peter Schneider
2025-08-23  8:32 ` Naresh Kamboju
2025-08-23 12:42 ` Brett A C Sheffield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250822123517.094089854@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox