]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: add a ci_entry helper
authorDarrick J. Wong <djwong@kernel.org>
Fri, 17 Nov 2023 17:48:14 +0000 (09:48 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 22 Nov 2023 23:03:40 +0000 (15:03 -0800)
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 <hch@lst.de>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/defer_item.c

index 9e521b497ed961ef1a2ab4d3a285aefba2d230f9..f0addacade6e44c84aa29a29718712342f9bb401 100644 (file)
@@ -484,6 +484,11 @@ const struct xfs_defer_op_type xfs_rtrmap_update_defer_type = {
 
 /* Reference Counting */
 
+static inline struct xfs_refcount_intent *ci_entry(const struct list_head *e)
+{
+       return list_entry(e, struct xfs_refcount_intent, ri_list);
+}
+
 /* Sort refcount intents by AG. */
 static int
 xfs_refcount_update_diff_items(
@@ -491,11 +496,8 @@ xfs_refcount_update_diff_items(
        const struct list_head          *a,
        const struct list_head          *b)
 {
-       const struct xfs_refcount_intent *ra;
-       const struct xfs_refcount_intent *rb;
-
-       ra = container_of(a, struct xfs_refcount_intent, ri_list);
-       rb = container_of(b, struct xfs_refcount_intent, ri_list);
+       struct xfs_refcount_intent      *ra = ci_entry(a);
+       struct xfs_refcount_intent      *rb = ci_entry(b);
 
        return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno;
 }
@@ -550,10 +552,9 @@ xfs_refcount_update_finish_item(
        struct list_head                *item,
        struct xfs_btree_cur            **state)
 {
-       struct xfs_refcount_intent      *ri;
+       struct xfs_refcount_intent      *ri = ci_entry(item);
        int                             error;
 
-       ri = container_of(item, struct xfs_refcount_intent, ri_list);
        error = xfs_refcount_finish_one(tp, ri, state);
 
        /* Did we run out of reservation?  Requeue what we didn't finish. */
@@ -580,9 +581,7 @@ STATIC void
 xfs_refcount_update_cancel_item(
        struct list_head                *item)
 {
-       struct xfs_refcount_intent      *ri;
-
-       ri = container_of(item, struct xfs_refcount_intent, ri_list);
+       struct xfs_refcount_intent      *ri = ci_entry(item);
 
        xfs_refcount_update_put_group(ri);
        kmem_cache_free(xfs_refcount_intent_cache, ri);