Skip to content

Commit 4693422

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: don't pass the old lv to xfs_cil_prepare_item
By the time xfs_cil_prepare_item is called, the old lv is still pointed to by the log item. Take it from there instead of spreading the old lv logic over xlog_cil_insert_format_items and xfs_cil_prepare_item. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 75fe259 commit 4693422

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

fs/xfs/xfs_log_cil.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ xlog_cil_alloc_shadow_bufs(
370370
STATIC void
371371
xfs_cil_prepare_item(
372372
struct xlog *log,
373+
struct xfs_log_item *lip,
373374
struct xfs_log_vec *lv,
374-
struct xfs_log_vec *old_lv,
375375
int *diff_len)
376376
{
377377
/* Account for the new LV being passed in */
@@ -381,19 +381,19 @@ xfs_cil_prepare_item(
381381
/*
382382
* If there is no old LV, this is the first time we've seen the item in
383383
* this CIL context and so we need to pin it. If we are replacing the
384-
* old_lv, then remove the space it accounts for and make it the shadow
384+
* old lv, then remove the space it accounts for and make it the shadow
385385
* buffer for later freeing. In both cases we are now switching to the
386386
* shadow buffer, so update the pointer to it appropriately.
387387
*/
388-
if (!old_lv) {
388+
if (!lip->li_lv) {
389389
if (lv->lv_item->li_ops->iop_pin)
390390
lv->lv_item->li_ops->iop_pin(lv->lv_item);
391391
lv->lv_item->li_lv_shadow = NULL;
392-
} else if (old_lv != lv) {
392+
} else if (lip->li_lv != lv) {
393393
ASSERT(lv->lv_buf_len != XFS_LOG_VEC_ORDERED);
394394

395-
*diff_len -= old_lv->lv_bytes;
396-
lv->lv_item->li_lv_shadow = old_lv;
395+
*diff_len -= lip->li_lv->lv_bytes;
396+
lv->lv_item->li_lv_shadow = lip->li_lv;
397397
}
398398

399399
/* attach new log vector to log item */
@@ -453,7 +453,6 @@ xlog_cil_insert_format_items(
453453

454454
list_for_each_entry(lip, &tp->t_items, li_trans) {
455455
struct xfs_log_vec *lv;
456-
struct xfs_log_vec *old_lv = NULL;
457456
struct xfs_log_vec *shadow;
458457
bool ordered = false;
459458

@@ -474,7 +473,6 @@ xlog_cil_insert_format_items(
474473
continue;
475474

476475
/* compare to existing item size */
477-
old_lv = lip->li_lv;
478476
if (lip->li_lv && shadow->lv_size <= lip->li_lv->lv_size) {
479477
/* same or smaller, optimise common overwrite case */
480478
lv = lip->li_lv;
@@ -510,7 +508,7 @@ xlog_cil_insert_format_items(
510508
ASSERT(IS_ALIGNED((unsigned long)lv->lv_buf, sizeof(uint64_t)));
511509
lip->li_ops->iop_format(lip, lv);
512510
insert:
513-
xfs_cil_prepare_item(log, lv, old_lv, diff_len);
511+
xfs_cil_prepare_item(log, lip, lv, diff_len);
514512
}
515513
}
516514

0 commit comments

Comments
 (0)