Skip to content

Commit

Permalink
xfs: format log items write directly into the linear CIL buffer
Browse files Browse the repository at this point in the history
Instead of setting up pointers to memory locations in iop_format which then
get copied into the CIL linear buffer after return move the copy into
the individual inode items.  This avoids the need to always have a memory
block in the exact same layout that gets written into the log around, and
allow the log items to be much more flexible in their in-memory layouts.

The only caveat is that we need to properly align the data for each
iovec so that don't have structures misaligned in subsequent iovecs.

Note that all log item format routines now need to be careful to modify
the copy of the item that was placed into the CIL after calls to
xlog_copy_iovec instead of the in-memory copy.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Dave Chinner <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
  • Loading branch information
Christoph Hellwig authored and dchinner committed Dec 13, 2013
1 parent 1234351 commit bde7cff
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 114 deletions.
29 changes: 14 additions & 15 deletions fs/xfs/xfs_buf_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,15 @@ xfs_buf_item_size(

static inline void
xfs_buf_item_copy_iovec(
struct xfs_log_vec *lv,
struct xfs_log_iovec **vecp,
struct xfs_buf *bp,
uint offset,
int first_bit,
uint nbits)
{
offset += first_bit * XFS_BLF_CHUNK;
xlog_copy_iovec(vecp, XLOG_REG_TYPE_BCHUNK,
xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_BCHUNK,
xfs_buf_offset(bp, offset),
nbits * XFS_BLF_CHUNK);
}
Expand All @@ -211,13 +212,13 @@ xfs_buf_item_straddle(
static void
xfs_buf_item_format_segment(
struct xfs_buf_log_item *bip,
struct xfs_log_vec *lv,
struct xfs_log_iovec **vecp,
uint offset,
struct xfs_buf_log_format *blfp)
{
struct xfs_buf *bp = bip->bli_buf;
uint base_size;
uint nvecs;
int first_bit;
int last_bit;
int next_bit;
Expand All @@ -233,18 +234,17 @@ xfs_buf_item_format_segment(
*/
base_size = xfs_buf_log_format_size(blfp);

nvecs = 0;
first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
if (!(bip->bli_flags & XFS_BLI_STALE) && first_bit == -1) {
/*
* If the map is not be dirty in the transaction, mark
* the size as zero and do not advance the vector pointer.
*/
goto out;
return;
}

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

if (bip->bli_flags & XFS_BLI_STALE) {
/*
Expand All @@ -254,7 +254,7 @@ xfs_buf_item_format_segment(
*/
trace_xfs_buf_item_format_stale(bip);
ASSERT(blfp->blf_flags & XFS_BLF_CANCEL);
goto out;
return;
}


Expand All @@ -280,15 +280,15 @@ xfs_buf_item_format_segment(
* same set of bits so just keep counting and scanning.
*/
if (next_bit == -1) {
xfs_buf_item_copy_iovec(vecp, bp, offset,
xfs_buf_item_copy_iovec(lv, vecp, bp, offset,
first_bit, nbits);
nvecs++;
blfp->blf_size++;
break;
} else if (next_bit != last_bit + 1 ||
xfs_buf_item_straddle(bp, offset, next_bit, last_bit)) {
xfs_buf_item_copy_iovec(vecp, bp, offset,
xfs_buf_item_copy_iovec(lv, vecp, bp, offset,
first_bit, nbits);
nvecs++;
blfp->blf_size++;
first_bit = next_bit;
last_bit = next_bit;
nbits = 1;
Expand All @@ -297,8 +297,6 @@ xfs_buf_item_format_segment(
nbits++;
}
}
out:
blfp->blf_size = nvecs;
}

/*
Expand All @@ -310,10 +308,11 @@ xfs_buf_item_format_segment(
STATIC void
xfs_buf_item_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *vecp)
struct xfs_log_vec *lv)
{
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;

Expand Down Expand Up @@ -354,7 +353,7 @@ xfs_buf_item_format(
}

for (i = 0; i < bip->bli_format_count; i++) {
xfs_buf_item_format_segment(bip, &vecp, offset,
xfs_buf_item_format_segment(bip, lv, &vecp, offset,
&bip->bli_formats[i]);
offset += bp->b_maps[i].bm_len;
}
Expand Down
19 changes: 10 additions & 9 deletions fs/xfs/xfs_dquot_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,19 @@ xfs_qm_dquot_logitem_size(
STATIC void
xfs_qm_dquot_logitem_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *vecp)
struct xfs_log_vec *lv)
{
struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip);
struct xfs_log_iovec *vecp = NULL;

xlog_copy_iovec(&vecp, XLOG_REG_TYPE_QFORMAT,
qlip->qli_format.qlf_size = 2;

xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_QFORMAT,
&qlip->qli_format,
sizeof(struct xfs_dq_logformat));
xlog_copy_iovec(&vecp, XLOG_REG_TYPE_DQUOT,
xlog_copy_iovec(lv, &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 @@ -302,17 +303,17 @@ xfs_qm_qoff_logitem_size(
STATIC void
xfs_qm_qoff_logitem_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *vecp)
struct xfs_log_vec *lv)
{
struct xfs_qoff_logitem *qflip = QOFF_ITEM(lip);
struct xfs_log_iovec *vecp = NULL;

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

xlog_copy_iovec(&vecp, XLOG_REG_TYPE_QUOTAOFF,
xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_QUOTAOFF,
&qflip->qql_format,
sizeof(struct xfs_qoff_logitem));

qflip->qql_format.qf_size = 1;
}

/*
Expand Down
10 changes: 6 additions & 4 deletions fs/xfs/xfs_extfree_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,18 @@ xfs_efi_item_size(
STATIC void
xfs_efi_item_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *vecp)
struct xfs_log_vec *lv)
{
struct xfs_efi_log_item *efip = EFI_ITEM(lip);
struct xfs_log_iovec *vecp = NULL;

ASSERT(atomic_read(&efip->efi_next_extent) ==
efip->efi_format.efi_nextents);

efip->efi_format.efi_type = XFS_LI_EFI;
efip->efi_format.efi_size = 1;

xlog_copy_iovec(&vecp, XLOG_REG_TYPE_EFI_FORMAT,
xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_EFI_FORMAT,
&efip->efi_format,
xfs_efi_item_sizeof(efip));
}
Expand Down Expand Up @@ -368,16 +369,17 @@ xfs_efd_item_size(
STATIC void
xfs_efd_item_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *vecp)
struct xfs_log_vec *lv)
{
struct xfs_efd_log_item *efdp = EFD_ITEM(lip);
struct xfs_log_iovec *vecp = NULL;

ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents);

efdp->efd_format.efd_type = XFS_LI_EFD;
efdp->efd_format.efd_size = 1;

xlog_copy_iovec(&vecp, XLOG_REG_TYPE_EFD_FORMAT,
xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_EFD_FORMAT,
&efdp->efd_format,
xfs_efd_item_sizeof(efdp));
}
Expand Down
5 changes: 3 additions & 2 deletions fs/xfs/xfs_icreate_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ xfs_icreate_item_size(
STATIC void
xfs_icreate_item_format(
struct xfs_log_item *lip,
struct xfs_log_iovec *vecp)
struct xfs_log_vec *lv)
{
struct xfs_icreate_item *icp = ICR_ITEM(lip);
struct xfs_log_iovec *vecp = NULL;

xlog_copy_iovec(&vecp, XLOG_REG_TYPE_ICREATE,
xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ICREATE,
&icp->ic_format,
sizeof(struct xfs_icreate_log));
}
Expand Down
Loading

0 comments on commit bde7cff

Please sign in to comment.