]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: add helpers to compute log item overhead
authorDarrick J. Wong <djwong@kernel.org>
Tue, 1 Jul 2025 17:45:12 +0000 (10:45 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Fri, 18 Jul 2025 14:04:58 +0000 (16:04 +0200)
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>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
libxfs/defer_item.c
libxfs/defer_item.h

index 6beefa6a439980bac9583f8a2717481dbf2c7e66..4530583ddabae1566376b81b53f006e80be20695 100644 (file)
@@ -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));
+}
index 93cf1eed58a382a9c7ed1af86fff599d52642657..325a6f7b2dcbce67b15d361c63fb7f10aec696f6 100644 (file)
@@ -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_ */