]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: preserve RT reservations across remounts
authorHans Holmberg <hans.holmberg@wdc.com>
Tue, 9 Jan 2024 18:01:15 +0000 (19:01 +0100)
committerChristoph Hellwig <hch@lst.de>
Tue, 5 Nov 2024 08:29:51 +0000 (09:29 +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 aae796246eb9b3f29adcb6fcc1d7b8530f1043de..4d8cbf173f60ec4b1ad7eb4fff9fb750e6a58342 100644 (file)
@@ -465,10 +465,15 @@ xfs_mount_reset_sbqflags(
 }
 
 uint64_t
-xfs_default_resblks(xfs_mount_t *mp)
+xfs_default_resblks(
+       struct xfs_mount        *mp,
+       unsigned int            idx)
 {
        uint64_t resblks;
 
+       if (idx == FREE_RTEXTENTS)
+               return 0;
+
        /*
         * We default to 5% or 8192 fsbs of space reserved, whichever is
         * smaller.  This is intended to cover concurrent allocation
@@ -683,6 +688,7 @@ xfs_mountfs(
        uint                    quotamount = 0;
        uint                    quotaflags = 0;
        int                     error = 0;
+       int                     i;
 
        xfs_sb_mount_common(mp, sbp);
 
@@ -1051,18 +1057,20 @@ 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, FREE_BLOCKS,
-                               xfs_default_resblks(mp));
-               if (error)
-                       xfs_warn(mp,
+               for (i = 0; i < 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.");
+               }
 
                /* Reserve AG blocks for future btree expansion. */
                error = xfs_fs_reserve_ag_blocks(mp);
index 5f6fb6329d524c1f384759df780b2348aae61b2a..0d3bfce0bd99e8e6b2e21b443e5f58cb5e5c30f3 100644 (file)
@@ -640,7 +640,7 @@ 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, unsigned int idx);
 extern int     xfs_mountfs(xfs_mount_t *mp);
 extern void    xfs_unmountfs(xfs_mount_t *);
 
index 740451d12d7c6df1f06f2d79699bba850467e3c9..2d1c97b333358244b3143d80add8ddddd4221c18 100644 (file)
@@ -919,7 +919,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);
        }
 }