Skip to content

Commit 0e92548

Browse files
author
Darrick J. Wong
committed
xfs: add a ci_entry helper
Add a helper to translate from the item list head to the refcount_intent_item structure and use it so shorten assignments and avoid the need for extra local variables. Inspired-by: Christoph Hellwig <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent e69682e commit 0e92548

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

fs/xfs/xfs_refcount_item.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,20 @@ static const struct xfs_item_ops xfs_cud_item_ops = {
227227
.iop_intent = xfs_cud_item_intent,
228228
};
229229

230+
static inline struct xfs_refcount_intent *ci_entry(const struct list_head *e)
231+
{
232+
return list_entry(e, struct xfs_refcount_intent, ri_list);
233+
}
234+
230235
/* Sort refcount intents by AG. */
231236
static int
232237
xfs_refcount_update_diff_items(
233238
void *priv,
234239
const struct list_head *a,
235240
const struct list_head *b)
236241
{
237-
struct xfs_refcount_intent *ra;
238-
struct xfs_refcount_intent *rb;
239-
240-
ra = container_of(a, struct xfs_refcount_intent, ri_list);
241-
rb = container_of(b, struct xfs_refcount_intent, ri_list);
242+
struct xfs_refcount_intent *ra = ci_entry(a);
243+
struct xfs_refcount_intent *rb = ci_entry(b);
242244

243245
return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno;
244246
}
@@ -341,11 +343,9 @@ xfs_refcount_update_finish_item(
341343
struct list_head *item,
342344
struct xfs_btree_cur **state)
343345
{
344-
struct xfs_refcount_intent *ri;
346+
struct xfs_refcount_intent *ri = ci_entry(item);
345347
int error;
346348

347-
ri = container_of(item, struct xfs_refcount_intent, ri_list);
348-
349349
/* Did we run out of reservation? Requeue what we didn't finish. */
350350
error = xfs_refcount_finish_one(tp, ri, state);
351351
if (!error && ri->ri_blockcount > 0) {
@@ -372,9 +372,7 @@ STATIC void
372372
xfs_refcount_update_cancel_item(
373373
struct list_head *item)
374374
{
375-
struct xfs_refcount_intent *ri;
376-
377-
ri = container_of(item, struct xfs_refcount_intent, ri_list);
375+
struct xfs_refcount_intent *ri = ci_entry(item);
378376

379377
xfs_refcount_update_put_group(ri);
380378
kmem_cache_free(xfs_refcount_intent_cache, ri);

0 commit comments

Comments
 (0)