]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: preserve RT reservations across remounts
authorHans Holmberg <hans.holmberg@wdc.com>
Sat, 30 Nov 2024 04:39:47 +0000 (05:39 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 3 Feb 2025 04:49:07 +0000 (05:49 +0100)
Introduce a reservation setting for rt devices so that zoned GC
reservations are preserved over remount ro/rw cycles.

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_mount.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_super.c

index b81a03b3133daeca495c5b9c84f406a134a1ac1d..26793d4f2707e18208c2c1c457234b4dae22e744 100644 (file)
@@ -464,11 +464,21 @@ xfs_mount_reset_sbqflags(
        return xfs_sync_sb(mp, false);
 }
 
+static const char *const xfs_free_pool_name[] = {
+       [XC_FREE_BLOCKS]        = "free blocks",
+       [XC_FREE_RTEXTENTS]     = "free rt extents",
+};
+
 uint64_t
-xfs_default_resblks(xfs_mount_t *mp)
+xfs_default_resblks(
+       struct xfs_mount        *mp,
+       enum xfs_free_counter   ctr)
 {
        uint64_t resblks;
 
+       if (ctr == XC_FREE_RTEXTENTS)
+               return 0;
+
        /*
         * We default to 5% or 8192 fsbs of space reserved, whichever is
         * smaller.  This is intended to cover concurrent allocation
@@ -681,6 +691,7 @@ xfs_mountfs(
        uint                    quotamount = 0;
        uint                    quotaflags = 0;
        int                     error = 0;
+       int                     i;
 
        xfs_sb_mount_common(mp, sbp);
 
@@ -1049,18 +1060,21 @@ xfs_mountfs(
         * privileged transactions. This is needed so that transaction
         * space required for critical operations can dip into this pool
         * when at ENOSPC. This is needed for operations like create with
-        * attr, unwritten extent conversion at ENOSPC, etc. Data allocations
-        * are not allowed to use this reserved space.
+        * attr, unwritten extent conversion at ENOSPC, garbage collection
+        * etc. Data allocations are not allowed to use this reserved space.
         *
         * This may drive us straight to ENOSPC on mount, but that implies
         * we were already there on the last unmount. Warn if this occurs.
         */
        if (!xfs_is_readonly(mp)) {
-               error = xfs_reserve_blocks(mp, XC_FREE_BLOCKS,
-                               xfs_default_resblks(mp));
-               if (error)
-                       xfs_warn(mp,
-       "Unable to allocate reserve blocks. Continuing without reserve pool.");
+               for (i = 0; i < XC_FREE_NR; i++) {
+                       error = xfs_reserve_blocks(mp, i,
+                                       xfs_default_resblks(mp, i));
+                       if (error)
+                               xfs_warn(mp,
+"Unable to allocate reserve blocks. Continuing without reserve pool for %s.",
+                                       xfs_free_pool_name[i]);
+               }
 
                /* Reserve AG blocks for future btree expansion. */
                error = xfs_fs_reserve_ag_blocks(mp);
index 300ffefb2abdb0519cc673b5a84210bb494e093e..2d0e34e517b13630fe998bd1b57d9b0b5cc5d1d6 100644 (file)
@@ -647,7 +647,8 @@ xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
 }
 
 extern void    xfs_uuid_table_free(void);
-extern uint64_t xfs_default_resblks(xfs_mount_t *mp);
+uint64_t       xfs_default_resblks(struct xfs_mount *mp,
+                       enum xfs_free_counter ctr);
 extern int     xfs_mountfs(xfs_mount_t *mp);
 extern void    xfs_unmountfs(xfs_mount_t *);
 
index f0b0d8320c510bb42eac78ad15ae558cb6cf75df..5c9a2a0826ffb71b30a56da2e1a3c2f316c44ccc 100644 (file)
@@ -947,7 +947,7 @@ xfs_restore_resvblks(
                        resblks = mp->m_resblks[i].save;
                        mp->m_resblks[i].save = 0;
                } else
-                       resblks = xfs_default_resblks(mp);
+                       resblks = xfs_default_resblks(mp, i);
                xfs_reserve_blocks(mp, i, resblks);
        }
 }