Skip to content

Commit f939637

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: add a ri_entry helper
Add a helper to translate from the item list head to the rmap_intent_item structure and use it so shorten assignments and avoid the need for extra local variables. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent c9099a2 commit f939637

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

fs/xfs/xfs_rmap_item.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,20 @@ static const struct xfs_item_ops xfs_rud_item_ops = {
226226
.iop_intent = xfs_rud_item_intent,
227227
};
228228

229+
static inline struct xfs_rmap_intent *ri_entry(const struct list_head *e)
230+
{
231+
return list_entry(e, struct xfs_rmap_intent, ri_list);
232+
}
233+
229234
/* Sort rmap intents by AG. */
230235
static int
231236
xfs_rmap_update_diff_items(
232237
void *priv,
233238
const struct list_head *a,
234239
const struct list_head *b)
235240
{
236-
struct xfs_rmap_intent *ra;
237-
struct xfs_rmap_intent *rb;
238-
239-
ra = container_of(a, struct xfs_rmap_intent, ri_list);
240-
rb = container_of(b, struct xfs_rmap_intent, ri_list);
241+
struct xfs_rmap_intent *ra = ri_entry(a);
242+
struct xfs_rmap_intent *rb = ri_entry(b);
241243

242244
return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno;
243245
}
@@ -364,11 +366,9 @@ xfs_rmap_update_finish_item(
364366
struct list_head *item,
365367
struct xfs_btree_cur **state)
366368
{
367-
struct xfs_rmap_intent *ri;
369+
struct xfs_rmap_intent *ri = ri_entry(item);
368370
int error;
369371

370-
ri = container_of(item, struct xfs_rmap_intent, ri_list);
371-
372372
error = xfs_rmap_finish_one(tp, ri, state);
373373

374374
xfs_rmap_update_put_group(ri);
@@ -389,9 +389,7 @@ STATIC void
389389
xfs_rmap_update_cancel_item(
390390
struct list_head *item)
391391
{
392-
struct xfs_rmap_intent *ri;
393-
394-
ri = container_of(item, struct xfs_rmap_intent, ri_list);
392+
struct xfs_rmap_intent *ri = ri_entry(item);
395393

396394
xfs_rmap_update_put_group(ri);
397395
kmem_cache_free(xfs_rmap_intent_cache, ri);

0 commit comments

Comments
 (0)