]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: add a ri_entry helper
authorChristoph Hellwig <hch@lst.de>
Wed, 3 Jul 2024 21:21:40 +0000 (14:21 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 31 Jul 2024 01:46:44 +0000 (18:46 -0700)
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 <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/defer_item.c

index 2df0ce4e8ae9729b4ed487da3d79b73700074599..013ce0304c42f36d67e3fa06087f1a44cec09d42 100644 (file)
@@ -200,6 +200,11 @@ const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
 
 /* Reverse Mapping */
 
+static inline struct xfs_rmap_intent *ri_entry(const struct list_head *e)
+{
+       return list_entry(e, struct xfs_rmap_intent, ri_list);
+}
+
 /* Sort rmap intents by AG. */
 static int
 xfs_rmap_update_diff_items(
@@ -207,11 +212,8 @@ xfs_rmap_update_diff_items(
        const struct list_head          *a,
        const struct list_head          *b)
 {
-       const struct xfs_rmap_intent    *ra;
-       const struct xfs_rmap_intent    *rb;
-
-       ra = container_of(a, struct xfs_rmap_intent, ri_list);
-       rb = container_of(b, struct xfs_rmap_intent, ri_list);
+       struct xfs_rmap_intent          *ra = ri_entry(a);
+       struct xfs_rmap_intent          *rb = ri_entry(b);
 
        return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno;
 }
@@ -266,11 +268,9 @@ xfs_rmap_update_finish_item(
        struct list_head                *item,
        struct xfs_btree_cur            **state)
 {
-       struct xfs_rmap_intent          *ri;
+       struct xfs_rmap_intent          *ri = ri_entry(item);
        int                             error;
 
-       ri = container_of(item, struct xfs_rmap_intent, ri_list);
-
        error = xfs_rmap_finish_one(tp, ri, state);
 
        xfs_rmap_update_put_group(ri);
@@ -290,9 +290,7 @@ STATIC void
 xfs_rmap_update_cancel_item(
        struct list_head                *item)
 {
-       struct xfs_rmap_intent          *ri;
-
-       ri = container_of(item, struct xfs_rmap_intent, ri_list);
+       struct xfs_rmap_intent          *ri = ri_entry(item);
 
        xfs_rmap_update_put_group(ri);
        kmem_cache_free(xfs_rmap_intent_cache, ri);