xfs: move the xfs_is_always_cow_inode check into xfs_alloc_file_space
authorChristoph Hellwig <hch@lst.de>
Tue, 27 Aug 2024 06:50:49 +0000 (08:50 +0200)
committerChristian Brauner <brauner@kernel.org>
Wed, 28 Aug 2024 14:53:58 +0000 (16:53 +0200)
Move the xfs_is_always_cow_inode check from the caller into
xfs_alloc_file_space to prepare for refactoring of xfs_file_fallocate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240827065123.1762168-6-hch@lst.de
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/xfs/xfs_bmap_util.c
fs/xfs/xfs_file.c

index 187a0dbda24fc4a4f905ffa73d9d20fc43feff2f..e9fdebaa40ea59b02873695d9818606ba28e1fe4 100644 (file)
@@ -653,6 +653,9 @@ xfs_alloc_file_space(
        xfs_bmbt_irec_t         imaps[1], *imapp;
        int                     error;
 
+       if (xfs_is_always_cow_inode(ip))
+               return 0;
+
        trace_xfs_alloc_file_space(ip);
 
        if (xfs_is_shutdown(mp))
index 5b9e49da06013c66a859f662d303bf0cabb59c20..489bc1b173c26835650503bd837636b46c483d82 100644 (file)
@@ -987,11 +987,9 @@ xfs_file_fallocate(
                        }
                }
 
-               if (!xfs_is_always_cow_inode(ip)) {
-                       error = xfs_alloc_file_space(ip, offset, len);
-                       if (error)
-                               goto out_unlock;
-               }
+               error = xfs_alloc_file_space(ip, offset, len);
+               if (error)
+                       goto out_unlock;
        }
 
        /* Change file size if needed */