Commit 8e762534 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Carlos Maiolino
Browse files

xfs: improve the ->iop_format interface



Export a higher level interface to format log items.  The xlog_format_buf
structure is hidden inside xfs_log_cil.c and only accessed using two
helpers (and a wrapper build on top), hiding details of log iovecs from
the log items.  This also allows simply using an index into lv_iovecp
instead of keeping a cursor vec.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarCarlos Maiolino <cem@kernel.org>
parent c53fbeed
Loading
Loading
Loading
Loading
+12 −15
Original line number Diff line number Diff line
@@ -192,10 +192,9 @@ xfs_attri_item_size(
STATIC void
xfs_attri_item_format(
	struct xfs_log_item		*lip,
	struct xfs_log_vec		*lv)
	struct xlog_format_buf		*lfb)
{
	struct xfs_attri_log_item	*attrip = ATTRI_ITEM(lip);
	struct xfs_log_iovec		*vecp = NULL;
	struct xfs_attri_log_nameval	*nv = attrip->attri_nameval;

	attrip->attri_format.alfi_type = XFS_LI_ATTRI;
@@ -220,23 +219,22 @@ xfs_attri_item_format(
	if (nv->new_value.iov_len > 0)
		attrip->attri_format.alfi_size++;

	xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRI_FORMAT,
			&attrip->attri_format,
	xlog_format_copy(lfb, XLOG_REG_TYPE_ATTRI_FORMAT, &attrip->attri_format,
			sizeof(struct xfs_attri_log_format));

	xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NAME, nv->name.iov_base,
	xlog_format_copy(lfb, XLOG_REG_TYPE_ATTR_NAME, nv->name.iov_base,
			nv->name.iov_len);

	if (nv->new_name.iov_len > 0)
		xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NEWNAME,
		xlog_format_copy(lfb, XLOG_REG_TYPE_ATTR_NEWNAME,
				nv->new_name.iov_base, nv->new_name.iov_len);

	if (nv->value.iov_len > 0)
		xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_VALUE,
		xlog_format_copy(lfb, XLOG_REG_TYPE_ATTR_VALUE,
				nv->value.iov_base, nv->value.iov_len);

	if (nv->new_value.iov_len > 0)
		xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NEWVALUE,
		xlog_format_copy(lfb, XLOG_REG_TYPE_ATTR_NEWVALUE,
				nv->new_value.iov_base, nv->new_value.iov_len);
}

@@ -323,15 +321,14 @@ xfs_attrd_item_size(
STATIC void
xfs_attrd_item_format(
	struct xfs_log_item		*lip,
	struct xfs_log_vec	*lv)
	struct xlog_format_buf		*lfb)
{
	struct xfs_attrd_log_item	*attrdp = ATTRD_ITEM(lip);
	struct xfs_log_iovec		*vecp = NULL;

	attrdp->attrd_format.alfd_type = XFS_LI_ATTRD;
	attrdp->attrd_format.alfd_size = 1;

	xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRD_FORMAT,
	xlog_format_copy(lfb, XLOG_REG_TYPE_ATTRD_FORMAT,
			&attrdp->attrd_format,
			sizeof(struct xfs_attrd_log_format));
}
+4 −6
Original line number Diff line number Diff line
@@ -92,10 +92,9 @@ unsigned int xfs_bui_log_space(unsigned int nr)
STATIC void
xfs_bui_item_format(
	struct xfs_log_item	*lip,
	struct xfs_log_vec	*lv)
	struct xlog_format_buf	*lfb)
{
	struct xfs_bui_log_item	*buip = BUI_ITEM(lip);
	struct xfs_log_iovec	*vecp = NULL;

	ASSERT(atomic_read(&buip->bui_next_extent) ==
			buip->bui_format.bui_nextents);
@@ -103,7 +102,7 @@ xfs_bui_item_format(
	buip->bui_format.bui_type = XFS_LI_BUI;
	buip->bui_format.bui_size = 1;

	xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_BUI_FORMAT, &buip->bui_format,
	xlog_format_copy(lfb, XLOG_REG_TYPE_BUI_FORMAT, &buip->bui_format,
			xfs_bui_log_format_sizeof(buip->bui_format.bui_nextents));
}

@@ -188,15 +187,14 @@ unsigned int xfs_bud_log_space(void)
STATIC void
xfs_bud_item_format(
	struct xfs_log_item	*lip,
	struct xfs_log_vec	*lv)
	struct xlog_format_buf	*lfb)
{
	struct xfs_bud_log_item	*budp = BUD_ITEM(lip);
	struct xfs_log_iovec	*vecp = NULL;

	budp->bud_format.bud_type = XFS_LI_BUD;
	budp->bud_format.bud_size = 1;

	xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_BUD_FORMAT, &budp->bud_format,
	xlog_format_copy(lfb, XLOG_REG_TYPE_BUD_FORMAT, &budp->bud_format,
			sizeof(struct xfs_bud_log_format));
}

+7 −12
Original line number Diff line number Diff line
@@ -263,24 +263,21 @@ xfs_buf_item_size(

static inline void
xfs_buf_item_copy_iovec(
	struct xfs_log_vec	*lv,
	struct xfs_log_iovec	**vecp,
	struct xlog_format_buf	*lfb,
	struct xfs_buf		*bp,
	uint			offset,
	int			first_bit,
	uint			nbits)
{
	offset += first_bit * XFS_BLF_CHUNK;
	xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_BCHUNK,
			xfs_buf_offset(bp, offset),
	xlog_format_copy(lfb, XLOG_REG_TYPE_BCHUNK, xfs_buf_offset(bp, offset),
			nbits * XFS_BLF_CHUNK);
}

static void
xfs_buf_item_format_segment(
	struct xfs_buf_log_item	*bip,
	struct xfs_log_vec	*lv,
	struct xfs_log_iovec	**vecp,
	struct xlog_format_buf	*lfb,
	uint			offset,
	struct xfs_buf_log_format *blfp)
{
@@ -308,7 +305,7 @@ xfs_buf_item_format_segment(
		return;
	}

	blfp = xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_BFORMAT, blfp, base_size);
	blfp = xlog_format_copy(lfb, XLOG_REG_TYPE_BFORMAT, blfp, base_size);
	blfp->blf_size = 1;

	if (bip->bli_flags & XFS_BLI_STALE) {
@@ -331,8 +328,7 @@ xfs_buf_item_format_segment(
		nbits = xfs_contig_bits(blfp->blf_data_map,
					blfp->blf_map_size, first_bit);
		ASSERT(nbits > 0);
		xfs_buf_item_copy_iovec(lv, vecp, bp, offset,
					first_bit, nbits);
		xfs_buf_item_copy_iovec(lfb, bp, offset, first_bit, nbits);
		blfp->blf_size++;

		/*
@@ -357,11 +353,10 @@ xfs_buf_item_format_segment(
STATIC void
xfs_buf_item_format(
	struct xfs_log_item	*lip,
	struct xfs_log_vec	*lv)
	struct xlog_format_buf	*lfb)
{
	struct xfs_buf_log_item	*bip = BUF_ITEM(lip);
	struct xfs_buf		*bp = bip->bli_buf;
	struct xfs_log_iovec	*vecp = NULL;
	uint			offset = 0;
	int			i;

@@ -398,7 +393,7 @@ xfs_buf_item_format(
	}

	for (i = 0; i < bip->bli_format_count; i++) {
		xfs_buf_item_format_segment(bip, lv, &vecp, offset,
		xfs_buf_item_format_segment(bip, lfb, offset,
					    &bip->bli_formats[i]);
		offset += BBTOB(bp->b_maps[i].bm_len);
	}
+4 −5
Original line number Diff line number Diff line
@@ -44,25 +44,24 @@ xfs_qm_dquot_logitem_size(
STATIC void
xfs_qm_dquot_logitem_format(
	struct xfs_log_item	*lip,
	struct xfs_log_vec	*lv)
	struct xlog_format_buf	*lfb)
{
	struct xfs_disk_dquot	ddq;
	struct xfs_dq_logitem	*qlip = DQUOT_ITEM(lip);
	struct xfs_log_iovec	*vecp = NULL;
	struct xfs_dq_logformat	*qlf;

	qlf = xlog_prepare_iovec(lv, &vecp, XLOG_REG_TYPE_QFORMAT);
	qlf = xlog_format_start(lfb, XLOG_REG_TYPE_QFORMAT);
	qlf->qlf_type = XFS_LI_DQUOT;
	qlf->qlf_size = 2;
	qlf->qlf_id = qlip->qli_dquot->q_id;
	qlf->qlf_blkno = qlip->qli_dquot->q_blkno;
	qlf->qlf_len = 1;
	qlf->qlf_boffset = qlip->qli_dquot->q_bufoffset;
	xlog_finish_iovec(lv, vecp, sizeof(struct xfs_dq_logformat));
	xlog_format_commit(lfb, sizeof(struct xfs_dq_logformat));

	xfs_dquot_to_disk(&ddq, qlip->qli_dquot);

	xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_DQUOT, &ddq,
	xlog_format_copy(lfb, XLOG_REG_TYPE_DQUOT, &ddq,
			sizeof(struct xfs_disk_dquot));
}

+4 −7
Original line number Diff line number Diff line
@@ -83,16 +83,14 @@ xfs_xmi_item_size(
STATIC void
xfs_xmi_item_format(
	struct xfs_log_item	*lip,
	struct xfs_log_vec	*lv)
	struct xlog_format_buf	*lfb)
{
	struct xfs_xmi_log_item	*xmi_lip = XMI_ITEM(lip);
	struct xfs_log_iovec	*vecp = NULL;

	xmi_lip->xmi_format.xmi_type = XFS_LI_XMI;
	xmi_lip->xmi_format.xmi_size = 1;

	xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_XMI_FORMAT,
			&xmi_lip->xmi_format,
	xlog_format_copy(lfb, XLOG_REG_TYPE_XMI_FORMAT, &xmi_lip->xmi_format,
			sizeof(struct xfs_xmi_log_format));
}

@@ -166,15 +164,14 @@ xfs_xmd_item_size(
STATIC void
xfs_xmd_item_format(
	struct xfs_log_item	*lip,
	struct xfs_log_vec	*lv)
	struct xlog_format_buf	*lfb)
{
	struct xfs_xmd_log_item	*xmd_lip = XMD_ITEM(lip);
	struct xfs_log_iovec	*vecp = NULL;

	xmd_lip->xmd_format.xmd_type = XFS_LI_XMD;
	xmd_lip->xmd_format.xmd_size = 1;

	xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_XMD_FORMAT, &xmd_lip->xmd_format,
	xlog_format_copy(lfb, XLOG_REG_TYPE_XMD_FORMAT, &xmd_lip->xmd_format,
			sizeof(struct xfs_xmd_log_format));
}

Loading