Skip to content

Commit

Permalink
xfs: remove duplicate code in xlog_cil_insert_format_items
Browse files Browse the repository at this point in the history
Share code that was previously duplicated in two branches.

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 f9b395a commit 9597df6
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions fs/xfs/xfs_log_cil.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,29 +254,22 @@ xlog_cil_insert_format_items(
*/
*diff_iovecs -= lv->lv_niovecs;
*diff_len -= lv->lv_buf_len;

/* Ensure the lv is set up according to ->iop_size */
lv->lv_niovecs = niovecs;
lv->lv_buf = (char *)lv + buf_size - nbytes;

lv->lv_buf_len = xlog_cil_lv_item_format(lip, lv);
goto insert;
} else {
/* allocate new data chunk */
lv = kmem_zalloc(buf_size, KM_SLEEP|KM_NOFS);
lv->lv_item = lip;
lv->lv_size = buf_size;
if (ordered) {
/* track as an ordered logvec */
ASSERT(lip->li_lv == NULL);
lv->lv_buf_len = XFS_LOG_VEC_ORDERED;
goto insert;
}
lv->lv_iovecp = (struct xfs_log_iovec *)&lv[1];
}

/* allocate new data chunk */
lv = kmem_zalloc(buf_size, KM_SLEEP|KM_NOFS);
lv->lv_item = lip;
lv->lv_size = buf_size;
/* Ensure the lv is set up according to ->iop_size */
lv->lv_niovecs = niovecs;
if (ordered) {
/* track as an ordered logvec */
ASSERT(lip->li_lv == NULL);
lv->lv_buf_len = XFS_LOG_VEC_ORDERED;
goto insert;
}

/* The allocated iovec region lies beyond the log vector. */
lv->lv_iovecp = (struct xfs_log_iovec *)&lv[1];

/* The allocated data region lies beyond the iovec region */
lv->lv_buf = (char *)lv + buf_size - nbytes;
Expand Down

0 comments on commit 9597df6

Please sign in to comment.