]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: stop passing an inode to the zone space reservation helpers
authorChristoph Hellwig <hch@lst.de>
Wed, 16 Jul 2025 12:54:04 +0000 (14:54 +0200)
committerCarlos Maiolino <cem@kernel.org>
Thu, 24 Jul 2025 15:30:14 +0000 (17:30 +0200)
None of them actually needs the inode, the mount is enough.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_file.c
fs/xfs/xfs_iops.c
fs/xfs/xfs_zone_alloc.h
fs/xfs/xfs_zone_space_resv.c

index 38e365b16348d8c2a20af75c4aedb3b379800c8b..ed69a65f56d79579a7dce9466fec8a663c87d2eb 100644 (file)
@@ -497,7 +497,7 @@ restart:
 
 static ssize_t
 xfs_zoned_write_space_reserve(
-       struct xfs_inode                *ip,
+       struct xfs_mount                *mp,
        struct kiocb                    *iocb,
        struct iov_iter                 *from,
        unsigned int                    flags,
@@ -533,8 +533,8 @@ xfs_zoned_write_space_reserve(
         *
         * Any remaining block will be returned after the write.
         */
-       return xfs_zoned_space_reserve(ip,
-                       XFS_B_TO_FSB(ip->i_mount, count) + 1 + 2, flags, ac);
+       return xfs_zoned_space_reserve(mp, XFS_B_TO_FSB(mp, count) + 1 + 2,
+                       flags, ac);
 }
 
 static int
@@ -718,13 +718,13 @@ xfs_file_dio_write_zoned(
        struct xfs_zone_alloc_ctx ac = { };
        ssize_t                 ret;
 
-       ret = xfs_zoned_write_space_reserve(ip, iocb, from, 0, &ac);
+       ret = xfs_zoned_write_space_reserve(ip->i_mount, iocb, from, 0, &ac);
        if (ret < 0)
                return ret;
        ret = xfs_file_dio_write_aligned(ip, iocb, from,
                        &xfs_zoned_direct_write_iomap_ops,
                        &xfs_dio_zoned_write_ops, &ac);
-       xfs_zoned_space_unreserve(ip, &ac);
+       xfs_zoned_space_unreserve(ip->i_mount, &ac);
        return ret;
 }
 
@@ -1032,7 +1032,7 @@ xfs_file_buffered_write_zoned(
        struct xfs_zone_alloc_ctx ac = { };
        ssize_t                 ret;
 
-       ret = xfs_zoned_write_space_reserve(ip, iocb, from, XFS_ZR_GREEDY, &ac);
+       ret = xfs_zoned_write_space_reserve(mp, iocb, from, XFS_ZR_GREEDY, &ac);
        if (ret < 0)
                return ret;
 
@@ -1073,7 +1073,7 @@ retry:
 out_unlock:
        xfs_iunlock(ip, iolock);
 out_unreserve:
-       xfs_zoned_space_unreserve(ip, &ac);
+       xfs_zoned_space_unreserve(ip->i_mount, &ac);
        if (ret > 0) {
                XFS_STATS_ADD(mp, xs_write_bytes, ret);
                ret = generic_write_sync(iocb, ret);
@@ -1414,11 +1414,11 @@ xfs_file_zoned_fallocate(
        struct xfs_inode        *ip = XFS_I(file_inode(file));
        int                     error;
 
-       error = xfs_zoned_space_reserve(ip, 2, XFS_ZR_RESERVED, &ac);
+       error = xfs_zoned_space_reserve(ip->i_mount, 2, XFS_ZR_RESERVED, &ac);
        if (error)
                return error;
        error = __xfs_file_fallocate(file, mode, offset, len, &ac);
-       xfs_zoned_space_unreserve(ip, &ac);
+       xfs_zoned_space_unreserve(ip->i_mount, &ac);
        return error;
 }
 
@@ -1828,12 +1828,12 @@ xfs_write_fault_zoned(
         * But as the overallocation is limited to less than a folio and will be
         * release instantly that's just fine.
         */
-       error = xfs_zoned_space_reserve(ip, XFS_B_TO_FSB(ip->i_mount, len), 0,
-                       &ac);
+       error = xfs_zoned_space_reserve(ip->i_mount,
+                       XFS_B_TO_FSB(ip->i_mount, len), 0, &ac);
        if (error < 0)
                return vmf_fs_error(error);
        ret = __xfs_write_fault(vmf, order, &ac);
-       xfs_zoned_space_unreserve(ip, &ac);
+       xfs_zoned_space_unreserve(ip->i_mount, &ac);
        return ret;
 }
 
index 01e597290eb5d479d3f89cda58911895fb1e6976..149b5460fbfd8016cb62728d38235e8de7eccb31 100644 (file)
@@ -970,7 +970,7 @@ xfs_setattr_size(
         * change.
         */
        if (xfs_is_zoned_inode(ip)) {
-               error = xfs_zoned_space_reserve(ip, 1,
+               error = xfs_zoned_space_reserve(mp, 1,
                                XFS_ZR_NOWAIT | XFS_ZR_RESERVED, &ac);
                if (error) {
                        if (error == -EAGAIN)
@@ -998,7 +998,7 @@ xfs_setattr_size(
        }
 
        if (xfs_is_zoned_inode(ip))
-               xfs_zoned_space_unreserve(ip, &ac);
+               xfs_zoned_space_unreserve(mp, &ac);
 
        if (error)
                return error;
index ecf39106704c2fd76c61d499bdf3a647faf58ac7..4db02816d0fdad038e9d4904eed12f61e82bd99b 100644 (file)
@@ -23,9 +23,9 @@ struct xfs_zone_alloc_ctx {
  */
 #define XFS_ZR_RESERVED                (1U << 2)
 
-int xfs_zoned_space_reserve(struct xfs_inode *ip, xfs_filblks_t count_fsb,
+int xfs_zoned_space_reserve(struct xfs_mount *mp, xfs_filblks_t count_fsb,
                unsigned int flags, struct xfs_zone_alloc_ctx *ac);
-void xfs_zoned_space_unreserve(struct xfs_inode *ip,
+void xfs_zoned_space_unreserve(struct xfs_mount *mp,
                struct xfs_zone_alloc_ctx *ac);
 void xfs_zoned_add_available(struct xfs_mount *mp, xfs_filblks_t count_fsb);
 
index 93c9a7721139472f2ed38b754a2218a7ec46bba9..1313c55b8cbe512ca7cf1f45d43aad075d12fefc 100644 (file)
@@ -117,11 +117,10 @@ xfs_zoned_space_wait_error(
 
 static int
 xfs_zoned_reserve_available(
-       struct xfs_inode                *ip,
+       struct xfs_mount                *mp,
        xfs_filblks_t                   count_fsb,
        unsigned int                    flags)
 {
-       struct xfs_mount                *mp = ip->i_mount;
        struct xfs_zone_info            *zi = mp->m_zone_info;
        struct xfs_zone_reservation     reservation = {
                .task           = current,
@@ -198,11 +197,10 @@ xfs_zoned_reserve_available(
  */
 static int
 xfs_zoned_reserve_extents_greedy(
-       struct xfs_inode                *ip,
+       struct xfs_mount                *mp,
        xfs_filblks_t                   *count_fsb,
        unsigned int                    flags)
 {
-       struct xfs_mount                *mp = ip->i_mount;
        struct xfs_zone_info            *zi = mp->m_zone_info;
        s64                             len = *count_fsb;
        int                             error = -ENOSPC;
@@ -220,12 +218,11 @@ xfs_zoned_reserve_extents_greedy(
 
 int
 xfs_zoned_space_reserve(
-       struct xfs_inode                *ip,
+       struct xfs_mount                *mp,
        xfs_filblks_t                   count_fsb,
        unsigned int                    flags,
        struct xfs_zone_alloc_ctx       *ac)
 {
-       struct xfs_mount                *mp = ip->i_mount;
        int                             error;
 
        ASSERT(ac->reserved_blocks == 0);
@@ -234,11 +231,11 @@ xfs_zoned_space_reserve(
        error = xfs_dec_freecounter(mp, XC_FREE_RTEXTENTS, count_fsb,
                        flags & XFS_ZR_RESERVED);
        if (error == -ENOSPC && (flags & XFS_ZR_GREEDY) && count_fsb > 1)
-               error = xfs_zoned_reserve_extents_greedy(ip, &count_fsb, flags);
+               error = xfs_zoned_reserve_extents_greedy(mp, &count_fsb, flags);
        if (error)
                return error;
 
-       error = xfs_zoned_reserve_available(ip, count_fsb, flags);
+       error = xfs_zoned_reserve_available(mp, count_fsb, flags);
        if (error) {
                xfs_add_freecounter(mp, XC_FREE_RTEXTENTS, count_fsb);
                return error;
@@ -249,12 +246,10 @@ xfs_zoned_space_reserve(
 
 void
 xfs_zoned_space_unreserve(
-       struct xfs_inode                *ip,
+       struct xfs_mount                *mp,
        struct xfs_zone_alloc_ctx       *ac)
 {
        if (ac->reserved_blocks > 0) {
-               struct xfs_mount        *mp = ip->i_mount;
-
                xfs_zoned_add_available(mp, ac->reserved_blocks);
                xfs_add_freecounter(mp, XC_FREE_RTEXTENTS, ac->reserved_blocks);
        }