On 2025-07-14 22:17:24, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > 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@xxxxxxxxxx> LGTM Reviewed-by: Andrey Albershteyn <aalbersh@xxxxxxxxxx> > --- > libxfs/defer_item.h | 14 ++++++++++++++ > libxfs/defer_item.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 65 insertions(+) > > > diff --git a/libxfs/defer_item.h b/libxfs/defer_item.h > index 93cf1eed58a382..325a6f7b2dcbce 100644 > --- a/libxfs/defer_item.h > +++ b/libxfs/defer_item.h > @@ -39,4 +39,18 @@ struct xfs_refcount_intent; > void xfs_refcount_defer_add(struct xfs_trans *tp, > struct xfs_refcount_intent *ri); > > +/* log intent size calculations */ > + > +unsigned int xfs_efi_log_space(unsigned int nr); > +unsigned int xfs_efd_log_space(unsigned int nr); > + > +unsigned int xfs_rui_log_space(unsigned int nr); > +unsigned int xfs_rud_log_space(void); > + > +unsigned int xfs_bui_log_space(unsigned int nr); > +unsigned int xfs_bud_log_space(void); > + > +unsigned int xfs_cui_log_space(unsigned int nr); > +unsigned int xfs_cud_log_space(void); > + > #endif /* __LIBXFS_DEFER_ITEM_H_ */ > diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c > index 6beefa6a439980..4530583ddabae1 100644 > --- a/libxfs/defer_item.c > +++ b/libxfs/defer_item.c > @@ -942,3 +942,54 @@ const struct xfs_defer_op_type xfs_exchmaps_defer_type = { > .finish_item = xfs_exchmaps_finish_item, > .cancel_item = xfs_exchmaps_cancel_item, > }; > + > +/* log intent size calculations */ > + > +static inline unsigned int > +xlog_item_space( > + unsigned int niovecs, > + unsigned int nbytes) > +{ > + nbytes += niovecs * (sizeof(uint64_t) + sizeof(struct xlog_op_header)); > + return round_up(nbytes, sizeof(uint64_t)); > +} > + > +unsigned int xfs_efi_log_space(unsigned int nr) > +{ > + return xlog_item_space(1, xfs_efi_log_format_sizeof(nr)); > +} > + > +unsigned int xfs_efd_log_space(unsigned int nr) > +{ > + return xlog_item_space(1, xfs_efd_log_format_sizeof(nr)); > +} > + > +unsigned int xfs_rui_log_space(unsigned int nr) > +{ > + return xlog_item_space(1, xfs_rui_log_format_sizeof(nr)); > +} > + > +unsigned int xfs_rud_log_space(void) > +{ > + return xlog_item_space(1, sizeof(struct xfs_rud_log_format)); > +} > + > +unsigned int xfs_bui_log_space(unsigned int nr) > +{ > + return xlog_item_space(1, xfs_bui_log_format_sizeof(nr)); > +} > + > +unsigned int xfs_bud_log_space(void) > +{ > + return xlog_item_space(1, sizeof(struct xfs_bud_log_format)); > +} > + > +unsigned int xfs_cui_log_space(unsigned int nr) > +{ > + return xlog_item_space(1, xfs_cui_log_format_sizeof(nr)); > +} > + > +unsigned int xfs_cud_log_space(void) > +{ > + return xlog_item_space(1, sizeof(struct xfs_cud_log_format)); > +} > -- - Andrey