xfs: turn dfp_done into a xfs_log_item

All defer op instance place their own extension of the log item into
the dfp_done field.  Replace that with a xfs_log_item to improve type
safety and make the code easier to follow.

Also use the opportunity to improve the ->finish_item calling conventions
to place the done log item as the higher level structure before the
list_entry used for the individual items.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
Christoph Hellwig 2020-04-30 12:52:22 -07:00 committed by Darrick J. Wong
parent bb47d79750
commit f09d167c20
6 changed files with 24 additions and 24 deletions

View File

@ -371,7 +371,7 @@ xfs_defer_finish_one(
list_for_each_safe(li, n, &dfp->dfp_work) { list_for_each_safe(li, n, &dfp->dfp_work) {
list_del(li); list_del(li);
dfp->dfp_count--; dfp->dfp_count--;
error = ops->finish_item(tp, li, dfp->dfp_done, &state); error = ops->finish_item(tp, dfp->dfp_done, li, &state);
if (error == -EAGAIN) { if (error == -EAGAIN) {
/* /*
* Caller wants a fresh transaction; put the work item * Caller wants a fresh transaction; put the work item

View File

@ -29,7 +29,7 @@ struct xfs_defer_pending {
struct list_head dfp_list; /* pending items */ struct list_head dfp_list; /* pending items */
struct list_head dfp_work; /* work items */ struct list_head dfp_work; /* work items */
struct xfs_log_item *dfp_intent; /* log intent item */ struct xfs_log_item *dfp_intent; /* log intent item */
void *dfp_done; /* log done item */ struct xfs_log_item *dfp_done; /* log done item */
unsigned int dfp_count; /* # extent items */ unsigned int dfp_count; /* # extent items */
enum xfs_defer_ops_type dfp_type; enum xfs_defer_ops_type dfp_type;
}; };
@ -46,10 +46,10 @@ struct xfs_defer_op_type {
struct xfs_log_item *(*create_intent)(struct xfs_trans *tp, struct xfs_log_item *(*create_intent)(struct xfs_trans *tp,
struct list_head *items, unsigned int count, bool sort); struct list_head *items, unsigned int count, bool sort);
void (*abort_intent)(struct xfs_log_item *intent); void (*abort_intent)(struct xfs_log_item *intent);
void *(*create_done)(struct xfs_trans *tp, struct xfs_log_item *intent, struct xfs_log_item *(*create_done)(struct xfs_trans *tp,
unsigned int count); struct xfs_log_item *intent, unsigned int count);
int (*finish_item)(struct xfs_trans *, struct list_head *, void *, int (*finish_item)(struct xfs_trans *tp, struct xfs_log_item *done,
void **); struct list_head *item, void **state);
void (*finish_cleanup)(struct xfs_trans *, void *, int); void (*finish_cleanup)(struct xfs_trans *, void *, int);
void (*cancel_item)(struct list_head *); void (*cancel_item)(struct list_head *);
unsigned int max_items; unsigned int max_items;

View File

@ -352,21 +352,21 @@ xfs_bmap_update_create_intent(
} }
/* Get an BUD so we can process all the deferred rmap updates. */ /* Get an BUD so we can process all the deferred rmap updates. */
STATIC void * static struct xfs_log_item *
xfs_bmap_update_create_done( xfs_bmap_update_create_done(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_log_item *intent, struct xfs_log_item *intent,
unsigned int count) unsigned int count)
{ {
return xfs_trans_get_bud(tp, BUI_ITEM(intent)); return &xfs_trans_get_bud(tp, BUI_ITEM(intent))->bud_item;
} }
/* Process a deferred rmap update. */ /* Process a deferred rmap update. */
STATIC int STATIC int
xfs_bmap_update_finish_item( xfs_bmap_update_finish_item(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_log_item *done,
struct list_head *item, struct list_head *item,
void *done_item,
void **state) void **state)
{ {
struct xfs_bmap_intent *bmap; struct xfs_bmap_intent *bmap;
@ -375,7 +375,7 @@ xfs_bmap_update_finish_item(
bmap = container_of(item, struct xfs_bmap_intent, bi_list); bmap = container_of(item, struct xfs_bmap_intent, bi_list);
count = bmap->bi_bmap.br_blockcount; count = bmap->bi_bmap.br_blockcount;
error = xfs_trans_log_finish_bmap_update(tp, done_item, error = xfs_trans_log_finish_bmap_update(tp, BUD_ITEM(done),
bmap->bi_type, bmap->bi_type,
bmap->bi_owner, bmap->bi_whichfork, bmap->bi_owner, bmap->bi_whichfork,
bmap->bi_bmap.br_startoff, bmap->bi_bmap.br_startoff,

View File

@ -459,28 +459,28 @@ xfs_extent_free_create_intent(
} }
/* Get an EFD so we can process all the free extents. */ /* Get an EFD so we can process all the free extents. */
STATIC void * static struct xfs_log_item *
xfs_extent_free_create_done( xfs_extent_free_create_done(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_log_item *intent, struct xfs_log_item *intent,
unsigned int count) unsigned int count)
{ {
return xfs_trans_get_efd(tp, EFI_ITEM(intent), count); return &xfs_trans_get_efd(tp, EFI_ITEM(intent), count)->efd_item;
} }
/* Process a free extent. */ /* Process a free extent. */
STATIC int STATIC int
xfs_extent_free_finish_item( xfs_extent_free_finish_item(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_log_item *done,
struct list_head *item, struct list_head *item,
void *done_item,
void **state) void **state)
{ {
struct xfs_extent_free_item *free; struct xfs_extent_free_item *free;
int error; int error;
free = container_of(item, struct xfs_extent_free_item, xefi_list); free = container_of(item, struct xfs_extent_free_item, xefi_list);
error = xfs_trans_free_extent(tp, done_item, error = xfs_trans_free_extent(tp, EFD_ITEM(done),
free->xefi_startblock, free->xefi_startblock,
free->xefi_blockcount, free->xefi_blockcount,
&free->xefi_oinfo, free->xefi_skip_discard); &free->xefi_oinfo, free->xefi_skip_discard);
@ -523,12 +523,12 @@ const struct xfs_defer_op_type xfs_extent_free_defer_type = {
STATIC int STATIC int
xfs_agfl_free_finish_item( xfs_agfl_free_finish_item(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_log_item *done,
struct list_head *item, struct list_head *item,
void *done_item,
void **state) void **state)
{ {
struct xfs_mount *mp = tp->t_mountp; struct xfs_mount *mp = tp->t_mountp;
struct xfs_efd_log_item *efdp = done_item; struct xfs_efd_log_item *efdp = EFD_ITEM(done);
struct xfs_extent_free_item *free; struct xfs_extent_free_item *free;
struct xfs_extent *extp; struct xfs_extent *extp;
struct xfs_buf *agbp; struct xfs_buf *agbp;

View File

@ -351,21 +351,21 @@ xfs_refcount_update_create_intent(
} }
/* Get an CUD so we can process all the deferred refcount updates. */ /* Get an CUD so we can process all the deferred refcount updates. */
STATIC void * static struct xfs_log_item *
xfs_refcount_update_create_done( xfs_refcount_update_create_done(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_log_item *intent, struct xfs_log_item *intent,
unsigned int count) unsigned int count)
{ {
return xfs_trans_get_cud(tp, CUI_ITEM(intent)); return &xfs_trans_get_cud(tp, CUI_ITEM(intent))->cud_item;
} }
/* Process a deferred refcount update. */ /* Process a deferred refcount update. */
STATIC int STATIC int
xfs_refcount_update_finish_item( xfs_refcount_update_finish_item(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_log_item *done,
struct list_head *item, struct list_head *item,
void *done_item,
void **state) void **state)
{ {
struct xfs_refcount_intent *refc; struct xfs_refcount_intent *refc;
@ -374,7 +374,7 @@ xfs_refcount_update_finish_item(
int error; int error;
refc = container_of(item, struct xfs_refcount_intent, ri_list); refc = container_of(item, struct xfs_refcount_intent, ri_list);
error = xfs_trans_log_finish_refcount_update(tp, done_item, error = xfs_trans_log_finish_refcount_update(tp, CUD_ITEM(done),
refc->ri_type, refc->ri_type,
refc->ri_startblock, refc->ri_startblock,
refc->ri_blockcount, refc->ri_blockcount,

View File

@ -403,28 +403,28 @@ xfs_rmap_update_create_intent(
} }
/* Get an RUD so we can process all the deferred rmap updates. */ /* Get an RUD so we can process all the deferred rmap updates. */
STATIC void * static struct xfs_log_item *
xfs_rmap_update_create_done( xfs_rmap_update_create_done(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_log_item *intent, struct xfs_log_item *intent,
unsigned int count) unsigned int count)
{ {
return xfs_trans_get_rud(tp, RUI_ITEM(intent)); return &xfs_trans_get_rud(tp, RUI_ITEM(intent))->rud_item;
} }
/* Process a deferred rmap update. */ /* Process a deferred rmap update. */
STATIC int STATIC int
xfs_rmap_update_finish_item( xfs_rmap_update_finish_item(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_log_item *done,
struct list_head *item, struct list_head *item,
void *done_item,
void **state) void **state)
{ {
struct xfs_rmap_intent *rmap; struct xfs_rmap_intent *rmap;
int error; int error;
rmap = container_of(item, struct xfs_rmap_intent, ri_list); rmap = container_of(item, struct xfs_rmap_intent, ri_list);
error = xfs_trans_log_finish_rmap_update(tp, done_item, error = xfs_trans_log_finish_rmap_update(tp, RUD_ITEM(done),
rmap->ri_type, rmap->ri_type,
rmap->ri_owner, rmap->ri_whichfork, rmap->ri_owner, rmap->ri_whichfork,
rmap->ri_bmap.br_startoff, rmap->ri_bmap.br_startoff,