Skip to content

Commit

Permalink
xfs: introduce xlog_copy_iovec
Browse files Browse the repository at this point in the history
Add a helper to abstract out filling the log iovecs in the log item
format handlers.  This will allow us to change the way we do the log
item formatting more easily.

The copy in the name is a bit confusing for now as it just assigns a
pointer and lets the CIL code perform the copy, but that will change
soon.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
  • Loading branch information
Christoph Hellwig authored and Dave Chinner committed Dec 13, 2013
1 parent 3de559f commit 1234351
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 108 deletions.
30 changes: 12 additions & 18 deletions fs/xfs/xfs_buf_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,18 @@ xfs_buf_item_size(
trace_xfs_buf_item_size(bip);
}

static inline struct xfs_log_iovec *
static inline void
xfs_buf_item_copy_iovec(
struct xfs_log_iovec *vecp,
struct xfs_log_iovec **vecp,
struct xfs_buf *bp,
uint offset,
int first_bit,
uint nbits)
{
offset += first_bit * XFS_BLF_CHUNK;

vecp->i_type = XLOG_REG_TYPE_BCHUNK;
vecp->i_addr = xfs_buf_offset(bp, offset);
vecp->i_len = nbits * XFS_BLF_CHUNK;
return vecp + 1;
xlog_copy_iovec(vecp, XLOG_REG_TYPE_BCHUNK,
xfs_buf_offset(bp, offset),
nbits * XFS_BLF_CHUNK);
}

static inline bool
Expand All @@ -210,10 +208,10 @@ xfs_buf_item_straddle(
XFS_BLF_CHUNK);
}

static struct xfs_log_iovec *
static void
xfs_buf_item_format_segment(
struct xfs_buf_log_item *bip,
struct xfs_log_iovec *vecp,
struct xfs_log_iovec **vecp,
uint offset,
struct xfs_buf_log_format *blfp)
{
Expand Down Expand Up @@ -245,10 +243,7 @@ xfs_buf_item_format_segment(
goto out;
}

vecp->i_addr = blfp;
vecp->i_len = base_size;
vecp->i_type = XLOG_REG_TYPE_BFORMAT;
vecp++;
xlog_copy_iovec(vecp, XLOG_REG_TYPE_BFORMAT, blfp, base_size);
nvecs = 1;

if (bip->bli_flags & XFS_BLI_STALE) {
Expand Down Expand Up @@ -291,8 +286,8 @@ xfs_buf_item_format_segment(
break;
} else if (next_bit != last_bit + 1 ||
xfs_buf_item_straddle(bp, offset, next_bit, last_bit)) {
vecp = xfs_buf_item_copy_iovec(vecp, bp, offset,
first_bit, nbits);
xfs_buf_item_copy_iovec(vecp, bp, offset,
first_bit, nbits);
nvecs++;
first_bit = next_bit;
last_bit = next_bit;
Expand All @@ -304,7 +299,6 @@ xfs_buf_item_format_segment(
}
out:
blfp->blf_size = nvecs;
return vecp;
}

/*
Expand Down Expand Up @@ -360,8 +354,8 @@ xfs_buf_item_format(
}

for (i = 0; i < bip->bli_format_count; i++) {
vecp = xfs_buf_item_format_segment(bip, vecp, offset,
&bip->bli_formats[i]);
xfs_buf_item_format_segment(bip, &vecp, offset,
&bip->bli_formats[i]);
offset += bp->b_maps[i].bm_len;
}

Expand Down
25 changes: 12 additions & 13 deletions fs/xfs/xfs_dquot_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,18 @@ xfs_qm_dquot_logitem_size(
STATIC void
xfs_qm_dquot_logitem_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *logvec)
struct xfs_log_iovec *vecp)
{
struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip);

logvec->i_addr = &qlip->qli_format;
logvec->i_len = sizeof(xfs_dq_logformat_t);
logvec->i_type = XLOG_REG_TYPE_QFORMAT;
logvec++;
logvec->i_addr = &qlip->qli_dquot->q_core;
logvec->i_len = sizeof(xfs_disk_dquot_t);
logvec->i_type = XLOG_REG_TYPE_DQUOT;
xlog_copy_iovec(&vecp, XLOG_REG_TYPE_QFORMAT,
&qlip->qli_format,
sizeof(struct xfs_dq_logformat));
xlog_copy_iovec(&vecp, XLOG_REG_TYPE_DQUOT,
&qlip->qli_dquot->q_core,
sizeof(struct xfs_disk_dquot));

qlip->qli_format.qlf_size = 2;

}

/*
Expand Down Expand Up @@ -304,15 +302,16 @@ xfs_qm_qoff_logitem_size(
STATIC void
xfs_qm_qoff_logitem_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *log_vector)
struct xfs_log_iovec *vecp)
{
struct xfs_qoff_logitem *qflip = QOFF_ITEM(lip);

ASSERT(qflip->qql_format.qf_type == XFS_LI_QUOTAOFF);

log_vector->i_addr = &qflip->qql_format;
log_vector->i_len = sizeof(xfs_qoff_logitem_t);
log_vector->i_type = XLOG_REG_TYPE_QUOTAOFF;
xlog_copy_iovec(&vecp, XLOG_REG_TYPE_QUOTAOFF,
&qflip->qql_format,
sizeof(struct xfs_qoff_logitem));

qflip->qql_format.qf_size = 1;
}

Expand Down
19 changes: 9 additions & 10 deletions fs/xfs/xfs_extfree_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "xfs_trans_priv.h"
#include "xfs_buf_item.h"
#include "xfs_extfree_item.h"
#include "xfs_log.h"


kmem_zone_t *xfs_efi_zone;
Expand Down Expand Up @@ -101,7 +102,7 @@ xfs_efi_item_size(
STATIC void
xfs_efi_item_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *log_vector)
struct xfs_log_iovec *vecp)
{
struct xfs_efi_log_item *efip = EFI_ITEM(lip);

Expand All @@ -111,10 +112,9 @@ xfs_efi_item_format(
efip->efi_format.efi_type = XFS_LI_EFI;
efip->efi_format.efi_size = 1;

log_vector->i_addr = &efip->efi_format;
log_vector->i_len = xfs_efi_item_sizeof(efip);
log_vector->i_type = XLOG_REG_TYPE_EFI_FORMAT;
ASSERT(log_vector->i_len >= sizeof(xfs_efi_log_format_t));
xlog_copy_iovec(&vecp, XLOG_REG_TYPE_EFI_FORMAT,
&efip->efi_format,
xfs_efi_item_sizeof(efip));
}


Expand Down Expand Up @@ -368,7 +368,7 @@ xfs_efd_item_size(
STATIC void
xfs_efd_item_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *log_vector)
struct xfs_log_iovec *vecp)
{
struct xfs_efd_log_item *efdp = EFD_ITEM(lip);

Expand All @@ -377,10 +377,9 @@ xfs_efd_item_format(
efdp->efd_format.efd_type = XFS_LI_EFD;
efdp->efd_format.efd_size = 1;

log_vector->i_addr = &efdp->efd_format;
log_vector->i_len = xfs_efd_item_sizeof(efdp);
log_vector->i_type = XLOG_REG_TYPE_EFD_FORMAT;
ASSERT(log_vector->i_len >= sizeof(xfs_efd_log_format_t));
xlog_copy_iovec(&vecp, XLOG_REG_TYPE_EFD_FORMAT,
&efdp->efd_format,
xfs_efd_item_sizeof(efdp));
}

/*
Expand Down
9 changes: 5 additions & 4 deletions fs/xfs/xfs_icreate_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "xfs_trans_priv.h"
#include "xfs_error.h"
#include "xfs_icreate_item.h"
#include "xfs_log.h"

kmem_zone_t *xfs_icreate_zone; /* inode create item zone */

Expand Down Expand Up @@ -58,13 +59,13 @@ xfs_icreate_item_size(
STATIC void
xfs_icreate_item_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *log_vector)
struct xfs_log_iovec *vecp)
{
struct xfs_icreate_item *icp = ICR_ITEM(lip);

log_vector->i_addr = (xfs_caddr_t)&icp->ic_format;
log_vector->i_len = sizeof(struct xfs_icreate_log);
log_vector->i_type = XLOG_REG_TYPE_ICREATE;
xlog_copy_iovec(&vecp, XLOG_REG_TYPE_ICREATE,
&icp->ic_format,
sizeof(struct xfs_icreate_log));
}


Expand Down
Loading

0 comments on commit 1234351

Please sign in to comment.