From: Jan Kara <jack@suse.cz>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Jan Kara <jack@suse.cz>, Ted Tso <tytso@mit.edu>,
linux-ext4@vger.kernel.org,
Alexander Coffin <alex.coffin@maticrobots.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 2/4] jbd2: Precompute number of transaction descriptor blocks
Date: Tue, 25 Jun 2024 13:07:26 +0200 [thread overview]
Message-ID: <20240625110726.wny5vmig7v2ugdbh@quack3> (raw)
In-Reply-To: <483983e0-8827-9801-5268-abfd97865d94@huaweicloud.com>
On Tue 25-06-24 17:31:15, Kemeng Shi wrote:
> on 6/25/2024 1:01 AM, Jan Kara wrote:
> > Instead of computing the number of descriptor blocks a transaction can
> > have each time we need it (which is currently when starting each
> > transaction but will become more frequent later) precompute the number
> > once during journal initialization together with maximum transaction
> > size. We perform the precomputation whenever journal feature set is
> > updated similarly as for computation of
> > journal->j_revoke_records_per_block.
> >
> > CC: stable@vger.kernel.org
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> > fs/jbd2/journal.c | 61 ++++++++++++++++++++++++++++++++-----------
> > fs/jbd2/transaction.c | 24 +----------------
> > include/linux/jbd2.h | 7 +++++
> > 3 files changed, 54 insertions(+), 38 deletions(-)
> >
> > +static int jbd2_descriptor_blocks_per_trans(journal_t *journal)
> > +{
> > + int tag_space = journal->j_blocksize - sizeof(journal_header_t);
> > + int tags_per_block;
> > +
> > + /* Subtract UUID */
> > + tag_space -= 16;
> > + if (jbd2_journal_has_csum_v2or3(journal))
> > + tag_space -= sizeof(struct jbd2_journal_block_tail);
> > + /* Commit code leaves a slack space of 16 bytes at the end of block */
> > + tags_per_block = (tag_space - 16) / journal_tag_bytes(journal);
> > + /*
> > + * Revoke descriptors are accounted separately so we need to reserve
> > + * space for commit block and normal transaction descriptor blocks.
> > + */
> > + return 1 + DIV_ROUND_UP(jbd2_journal_get_max_txn_bufs(journal),
> > + tags_per_block);
> > +}
> The change looks good to me. I wonder if the original calculation of
> number of JBD2_DESCRIPTOR_BLOCK blocks is correct.
> In my opinion, it should be:
> DIV_ROUND_UP(jbd2_journal_get_max_txn_bufs(journal), tags_per_block *+ 1*)
> Assume max_txn_bufs is 6, tags_per_block is 1, then we have one tag block
> after each JBD2_DESCRIPTOR_BLOCK block. Then we could get 3
> JBD2_DESCRIPTOR_BLOCK block at most rather than 6.
> Please let me konw if I miss something, this confused me for sometime...
So you are correct that the expression is overestimating the number of
descriptor blocks required, essentially because we don't need descriptor
blocks for descriptor blocks. But given tags_per_block is at least over 60,
in common configurations over 250, this imprecision is not really
substantial and I prefer a simple to argue about upper estimate...
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-06-25 11:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240624165406.12784-1-jack@suse.cz>
2024-06-24 17:01 ` [PATCH v2 1/4] jbd2: Make jbd2_journal_get_max_txn_bufs() internal Jan Kara
2024-06-27 6:47 ` Zhang Yi
2024-07-11 2:35 ` Theodore Ts'o
2024-06-24 17:01 ` [PATCH v2 2/4] jbd2: Precompute number of transaction descriptor blocks Jan Kara
2024-06-25 9:31 ` Kemeng Shi
2024-06-25 11:07 ` Jan Kara [this message]
2024-06-25 12:02 ` Kemeng Shi
2024-06-27 7:06 ` Zhang Yi
2024-06-24 17:01 ` [PATCH v2 3/4] jbd2: Avoid infinite transaction commit loop Jan Kara
2024-06-26 7:38 ` Zhang Yi
2024-06-26 11:22 ` Jan Kara
2024-06-26 13:24 ` Zhang Yi
2024-06-26 14:55 ` Jan Kara
2024-06-27 6:43 ` Zhang Yi
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=20240625110726.wny5vmig7v2ugdbh@quack3 \
--to=jack@suse.cz \
--cc=alex.coffin@maticrobots.com \
--cc=linux-ext4@vger.kernel.org \
--cc=shikemeng@huaweicloud.com \
--cc=stable@vger.kernel.org \
--cc=tytso@mit.edu \
/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