Re: [RFC v5 PATCH 2/9] xfs: introduce ->tr_relog transaction

Darrick J. Wong
2020-02-27T23:32:00Z

On Thu, Feb 27, 2020 at 08:43:14AM -0500, Brian Foster wrote:
> Create a transaction reservation specifically for relog
> transactions. For now it only supports the quotaoff intent, so use
> the associated reservation.
>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
> fs/xfs/libxfs/xfs_trans_resv.c | 15 +++++++++++++++
> fs/xfs/libxfs/xfs_trans_resv.h | 1 +
> 2 files changed, 16 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c
> index 7a9c04920505..1f5c9e6e1afc 100644
> --- a/fs/xfs/libxfs/xfs_trans_resv.c
> +++ b/fs/xfs/libxfs/xfs_trans_resv.c
> @@ -832,6 +832,17 @@ xfs_calc_sb_reservation(
> return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
> }
>
> +/*
> + * Internal relog transaction.
> + * quotaoff intent
> + */
> +STATIC uint
> +xfs_calc_relog_reservation(
> + struct xfs_mount *mp)
> +{
> + return xfs_calc_qm_quotaoff_reservation(mp);

So when we add the next reloggable intent item, this will turn this
into an n-way max(sizeof(type0), sizeof(type1), ...sizeof(typeN)); ?

> +}
> +
> void
> xfs_trans_resv_calc(
> struct xfs_mount *mp,
> @@ -946,4 +957,8 @@ xfs_trans_resv_calc(
> resp->tr_clearagi.tr_logres = xfs_calc_clear_agi_bucket_reservation(mp);
> resp->tr_growrtzero.tr_logres = xfs_calc_growrtzero_reservation(mp);
> resp->tr_growrtfree.tr_logres = xfs_calc_growrtfree_reservation(mp);
> +
> + resp->tr_relog.tr_logres = xfs_calc_relog_reservation(mp);
> + resp->tr_relog.tr_logcount = XFS_DEFAULT_PERM_LOG_COUNT;

Relog operations can roll? I would have figured that you'd simply log
the old item(s) in a new transaction and commit it, along with some
magic to let the log tail move forward. I guess I'll see what happens
in the next 7 patches. :)

--D

> + resp->tr_relog.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
> }
> diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h
> index 7241ab28cf84..b723979cad09 100644
> --- a/fs/xfs/libxfs/xfs_trans_resv.h
> +++ b/fs/xfs/libxfs/xfs_trans_resv.h
> @@ -50,6 +50,7 @@ struct xfs_trans_resv {
> struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */
> struct xfs_trans_res tr_sb; /* modify superblock */
> struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */
> + struct xfs_trans_res tr_relog; /* internal relog transaction */
> };
>
> /* shorthand way of accessing reservation structure */
> --
> 2.21.1
>