Commit 6d1bdc73 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: add helpers to compute log item overhead



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: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
Signed-off-by: default avatarJohn Garry <john.g.garry@oracle.com>
parent 13c7c54b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -77,6 +77,11 @@ xfs_bui_item_size(
	*nbytes += xfs_bui_log_format_sizeof(buip->bui_format.bui_nextents);
}

unsigned int xfs_bui_log_space(unsigned int nr)
{
	return xlog_item_space(1, xfs_bui_log_format_sizeof(nr));
}

/*
 * This is called to fill in the vector of log iovecs for the
 * given bui log item. We use only 1 iovec, and we point that
@@ -168,6 +173,11 @@ xfs_bud_item_size(
	*nbytes += sizeof(struct xfs_bud_log_format);
}

unsigned int xfs_bud_log_space(void)
{
	return xlog_item_space(1, sizeof(struct xfs_bud_log_format));
}

/*
 * This is called to fill in the vector of log iovecs for the
 * given bud log item. We use only 1 iovec, and we point that
+3 −0
Original line number Diff line number Diff line
@@ -72,4 +72,7 @@ struct xfs_bmap_intent;

void xfs_bmap_defer_add(struct xfs_trans *tp, struct xfs_bmap_intent *bi);

unsigned int xfs_bui_log_space(unsigned int nr);
unsigned int xfs_bud_log_space(void);

#endif	/* __XFS_BMAP_ITEM_H__ */
+19 −0
Original line number Diff line number Diff line
@@ -103,6 +103,25 @@ xfs_buf_item_size_segment(
	return;
}

/*
 * Compute the worst case log item overhead for an invalidated buffer with the
 * given map count and block size.
 */
unsigned int
xfs_buf_inval_log_space(
	unsigned int	map_count,
	unsigned int	blocksize)
{
	unsigned int	chunks = DIV_ROUND_UP(blocksize, XFS_BLF_CHUNK);
	unsigned int	bitmap_size = DIV_ROUND_UP(chunks, NBWORD);
	unsigned int	ret =
		offsetof(struct xfs_buf_log_format, blf_data_map) +
			(bitmap_size * sizeof_field(struct xfs_buf_log_format,
						    blf_data_map[0]));

	return ret * map_count;
}

/*
 * Return the number of log iovecs and space needed to log the given buf log
 * item.
+3 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ static inline void xfs_buf_dquot_iodone(struct xfs_buf *bp)
void	xfs_buf_iodone(struct xfs_buf *);
bool	xfs_buf_log_check_iovec(struct xfs_log_iovec *iovec);

unsigned int xfs_buf_inval_log_space(unsigned int map_count,
		unsigned int blocksize);

extern struct kmem_cache	*xfs_buf_item_cache;

#endif	/* __XFS_BUF_ITEM_H__ */
+10 −0
Original line number Diff line number Diff line
@@ -83,6 +83,11 @@ xfs_efi_item_size(
	*nbytes += xfs_efi_log_format_sizeof(efip->efi_format.efi_nextents);
}

unsigned int xfs_efi_log_space(unsigned int nr)
{
	return xlog_item_space(1, xfs_efi_log_format_sizeof(nr));
}

/*
 * This is called to fill in the vector of log iovecs for the
 * given efi log item. We use only 1 iovec, and we point that
@@ -254,6 +259,11 @@ xfs_efd_item_size(
	*nbytes += xfs_efd_log_format_sizeof(efdp->efd_format.efd_nextents);
}

unsigned int xfs_efd_log_space(unsigned int nr)
{
	return xlog_item_space(1, xfs_efd_log_format_sizeof(nr));
}

/*
 * This is called to fill in the vector of log iovecs for the
 * given efd log item. We use only 1 iovec, and we point that
Loading