]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: rearrange code in xfs_buf_item.c
authorDave Chinner <dchinner@redhat.com>
Wed, 25 Jun 2025 22:48:58 +0000 (08:48 +1000)
committerCarlos Maiolino <cem@kernel.org>
Fri, 27 Jun 2025 12:14:37 +0000 (14:14 +0200)
The code to initialise, release and free items is all the way down
the bottom of the file. Upcoming fixes need to these functions
earlier in the file, so move them to the top.

There is one code change in this move - the parameter to
xfs_buf_item_relse() is changed from the xfs_buf to the
xfs_buf_log_item - the thing that the function is releasing.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_buf_item.c
fs/xfs/xfs_buf_item.h

index 90139e0f32719214b8ef1bf3117fdbf7545e88d8..3e3c0f65a25c1e9b1eb47b05dc1cc298f76a5bc1 100644 (file)
@@ -32,6 +32,61 @@ static inline struct xfs_buf_log_item *BUF_ITEM(struct xfs_log_item *lip)
        return container_of(lip, struct xfs_buf_log_item, bli_item);
 }
 
+static void
+xfs_buf_item_get_format(
+       struct xfs_buf_log_item *bip,
+       int                     count)
+{
+       ASSERT(bip->bli_formats == NULL);
+       bip->bli_format_count = count;
+
+       if (count == 1) {
+               bip->bli_formats = &bip->__bli_format;
+               return;
+       }
+
+       bip->bli_formats = kzalloc(count * sizeof(struct xfs_buf_log_format),
+                               GFP_KERNEL | __GFP_NOFAIL);
+}
+
+static void
+xfs_buf_item_free_format(
+       struct xfs_buf_log_item *bip)
+{
+       if (bip->bli_formats != &bip->__bli_format) {
+               kfree(bip->bli_formats);
+               bip->bli_formats = NULL;
+       }
+}
+
+static void
+xfs_buf_item_free(
+       struct xfs_buf_log_item *bip)
+{
+       xfs_buf_item_free_format(bip);
+       kvfree(bip->bli_item.li_lv_shadow);
+       kmem_cache_free(xfs_buf_item_cache, bip);
+}
+
+/*
+ * xfs_buf_item_relse() is called when the buf log item is no longer needed.
+ */
+static void
+xfs_buf_item_relse(
+       struct xfs_buf_log_item *bip)
+{
+       struct xfs_buf          *bp = bip->bli_buf;
+
+       trace_xfs_buf_item_relse(bp, _RET_IP_);
+
+       ASSERT(!test_bit(XFS_LI_IN_AIL, &bip->bli_item.li_flags));
+       ASSERT(atomic_read(&bip->bli_refcount) == 0);
+
+       bp->b_log_item = NULL;
+       xfs_buf_rele(bp);
+       xfs_buf_item_free(bip);
+}
+
 /* Is this log iovec plausibly large enough to contain the buffer log format? */
 bool
 xfs_buf_log_check_iovec(
@@ -468,7 +523,7 @@ xfs_buf_item_unpin(
                        ASSERT(list_empty(&bp->b_li_list));
                } else {
                        xfs_trans_ail_delete(lip, SHUTDOWN_LOG_IO_ERROR);
-                       xfs_buf_item_relse(bp);
+                       xfs_buf_item_relse(bip);
                        ASSERT(bp->b_log_item == NULL);
                }
                xfs_buf_relse(bp);
@@ -578,7 +633,7 @@ xfs_buf_item_put(
         */
        if (aborted)
                xfs_trans_ail_delete(lip, 0);
-       xfs_buf_item_relse(bip->bli_buf);
+       xfs_buf_item_relse(bip);
        return true;
 }
 
@@ -729,33 +784,6 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
        .iop_push       = xfs_buf_item_push,
 };
 
-STATIC void
-xfs_buf_item_get_format(
-       struct xfs_buf_log_item *bip,
-       int                     count)
-{
-       ASSERT(bip->bli_formats == NULL);
-       bip->bli_format_count = count;
-
-       if (count == 1) {
-               bip->bli_formats = &bip->__bli_format;
-               return;
-       }
-
-       bip->bli_formats = kzalloc(count * sizeof(struct xfs_buf_log_format),
-                               GFP_KERNEL | __GFP_NOFAIL);
-}
-
-STATIC void
-xfs_buf_item_free_format(
-       struct xfs_buf_log_item *bip)
-{
-       if (bip->bli_formats != &bip->__bli_format) {
-               kfree(bip->bli_formats);
-               bip->bli_formats = NULL;
-       }
-}
-
 /*
  * Allocate a new buf log item to go with the given buffer.
  * Set the buffer's b_log_item field to point to the new
@@ -976,34 +1004,6 @@ xfs_buf_item_dirty_format(
        return false;
 }
 
-STATIC void
-xfs_buf_item_free(
-       struct xfs_buf_log_item *bip)
-{
-       xfs_buf_item_free_format(bip);
-       kvfree(bip->bli_item.li_lv_shadow);
-       kmem_cache_free(xfs_buf_item_cache, bip);
-}
-
-/*
- * xfs_buf_item_relse() is called when the buf log item is no longer needed.
- */
-void
-xfs_buf_item_relse(
-       struct xfs_buf  *bp)
-{
-       struct xfs_buf_log_item *bip = bp->b_log_item;
-
-       trace_xfs_buf_item_relse(bp, _RET_IP_);
-       ASSERT(!test_bit(XFS_LI_IN_AIL, &bip->bli_item.li_flags));
-
-       if (atomic_read(&bip->bli_refcount))
-               return;
-       bp->b_log_item = NULL;
-       xfs_buf_rele(bp);
-       xfs_buf_item_free(bip);
-}
-
 void
 xfs_buf_item_done(
        struct xfs_buf          *bp)
@@ -1023,5 +1023,5 @@ xfs_buf_item_done(
        xfs_trans_ail_delete(&bp->b_log_item->bli_item,
                             (bp->b_flags & _XBF_LOGRECOVERY) ? 0 :
                             SHUTDOWN_CORRUPT_INCORE);
-       xfs_buf_item_relse(bp);
+       xfs_buf_item_relse(bp->b_log_item);
 }
index e10e324cd24504e3135acd1383ec769a7ce405de..50dd79b59cf5a3d2f4984c15df73d64542dd0bc4 100644 (file)
@@ -49,7 +49,6 @@ struct xfs_buf_log_item {
 
 int    xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
 void   xfs_buf_item_done(struct xfs_buf *bp);
-void   xfs_buf_item_relse(struct xfs_buf *);
 bool   xfs_buf_item_put(struct xfs_buf_log_item *);
 void   xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
 bool   xfs_buf_item_dirty_format(struct xfs_buf_log_item *);