Re: [PATCH v6 02/12] xfs: add helpers to compute log item overhead

Dave Chinner
2025-04-08T22:51:02Z

On Tue, Apr 08, 2025 at 10:41:59AM +0000, John Garry wrote:
> From: "Darrick J. Wong" <djwong@kernel.org>
>
> Add selected helpers to estimate the transaction reservation required to
> write various log intent and buffer items to the log. These helpers
> will be used by the online repair code for more precise estimations of
> how much work can be done in a single transaction.
>
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
> fs/xfs/libxfs/xfs_trans_resv.c | 6 +++---
> fs/xfs/libxfs/xfs_trans_resv.h | 4 ++++
> fs/xfs/xfs_bmap_item.c | 10 ++++++++++
> fs/xfs/xfs_bmap_item.h | 3 +++
> fs/xfs/xfs_buf_item.c | 19 +++++++++++++++++++
> fs/xfs/xfs_buf_item.h | 3 +++
> fs/xfs/xfs_extfree_item.c | 10 ++++++++++
> fs/xfs/xfs_extfree_item.h | 3 +++
> fs/xfs/xfs_log_cil.c | 4 +---
> fs/xfs/xfs_log_priv.h | 13 +++++++++++++
> fs/xfs/xfs_refcount_item.c | 10 ++++++++++
> fs/xfs/xfs_refcount_item.h | 3 +++
> fs/xfs/xfs_rmap_item.c | 10 ++++++++++
> fs/xfs/xfs_rmap_item.h | 3 +++
> 14 files changed, 95 insertions(+), 6 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c
> index 13d00c7166e1..ce1393bd3561 100644
> --- a/fs/xfs/libxfs/xfs_trans_resv.c
> +++ b/fs/xfs/libxfs/xfs_trans_resv.c
> @@ -47,7 +47,7 @@ xfs_buf_log_overhead(void)
> * will be changed in a transaction. size is used to tell how many
> * bytes should be reserved per item.
> */
> -STATIC uint
> +uint
> xfs_calc_buf_res(
> uint nbufs,
> uint size)
> @@ -84,7 +84,7 @@ xfs_allocfree_block_count(
> * in the same transaction as an allocation or a free, so we compute them
> * separately.
> */
> -static unsigned int
> +unsigned int
> xfs_refcountbt_block_count(
> struct xfs_mount *mp,
> unsigned int num_ops)
> @@ -129,7 +129,7 @@ xfs_rtrefcountbt_block_count(
> * additional to the records and pointers that fit inside the inode
> * forks.
> */
> -STATIC uint
> +uint
> xfs_calc_inode_res(
> struct xfs_mount *mp,
> uint ninodes)
> diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h
> index 0554b9d775d2..e76052028cc9 100644
> --- a/fs/xfs/libxfs/xfs_trans_resv.h
> +++ b/fs/xfs/libxfs/xfs_trans_resv.h
> @@ -97,6 +97,10 @@ struct xfs_trans_resv {
>
> void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp);
> uint xfs_allocfree_block_count(struct xfs_mount *mp, uint num_ops);
> +unsigned int xfs_refcountbt_block_count(struct xfs_mount *mp,
> + unsigned int num_ops);
> +uint xfs_calc_buf_res(uint nbufs, uint size);
> +uint xfs_calc_inode_res(struct xfs_mount *mp, uint ninodes);

Why are these exported? They aren't used in this patch, and any code
that doing calculate log reservation calculation should really be
placed in xfs_trans_resv.c along with all the existing log
reservation calculations...

-Dave
--
Dave Chinner
david@fromorbit.com