xfs: move inode lease breaking functions to xfs_inode.c
authorDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:54:07 +0000 (14:54 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:54:07 +0000 (14:54 -0700)
The lease breaking functions operate at the scope of the entire VFS
inode, not subranges of a file.  Move them to xfs_inode.c since they're
already declared in xfs_inode.h.  This cleanup moves us closer to
having xfs_FOO.h declare only the symbols in xfs_FOO.c.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_file.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h

index 632653e00906fa32e2b5a8c70451522952a8660a..40b778415f5fc4432aa4676320b88e8d3006e3fd 100644 (file)
@@ -861,67 +861,6 @@ xfs_file_write_iter(
        return xfs_file_buffered_write(iocb, from);
 }
 
-static void
-xfs_wait_dax_page(
-       struct inode            *inode)
-{
-       struct xfs_inode        *ip = XFS_I(inode);
-
-       xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
-       schedule();
-       xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
-}
-
-int
-xfs_break_dax_layouts(
-       struct inode            *inode,
-       bool                    *retry)
-{
-       struct page             *page;
-
-       xfs_assert_ilocked(XFS_I(inode), XFS_MMAPLOCK_EXCL);
-
-       page = dax_layout_busy_page(inode->i_mapping);
-       if (!page)
-               return 0;
-
-       *retry = true;
-       return ___wait_var_event(&page->_refcount,
-                       atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE,
-                       0, 0, xfs_wait_dax_page(inode));
-}
-
-int
-xfs_break_layouts(
-       struct inode            *inode,
-       uint                    *iolock,
-       enum layout_break_reason reason)
-{
-       bool                    retry;
-       int                     error;
-
-       xfs_assert_ilocked(XFS_I(inode), XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL);
-
-       do {
-               retry = false;
-               switch (reason) {
-               case BREAK_UNMAP:
-                       error = xfs_break_dax_layouts(inode, &retry);
-                       if (error || retry)
-                               break;
-                       fallthrough;
-               case BREAK_WRITE:
-                       error = xfs_break_leased_layouts(inode, iolock, &retry);
-                       break;
-               default:
-                       WARN_ON_ONCE(1);
-                       error = -EINVAL;
-               }
-       } while (error == 0 && retry);
-
-       return error;
-}
-
 /* Does this file, inode, or mount want synchronous writes? */
 static inline bool xfs_file_sync_writes(struct file *filp)
 {
index 3e667a19b80bad36f72b1e3e0b58327672f15a6e..39e6f88e9691a70fe54a17cb54d96806bde1f85e 100644 (file)
@@ -38,6 +38,7 @@
 #include "xfs_ag.h"
 #include "xfs_log_priv.h"
 #include "xfs_health.h"
+#include "xfs_pnfs.h"
 
 struct kmem_cache *xfs_inode_cache;
 
@@ -3946,3 +3947,64 @@ xfs_inode_count_blocks(
                xfs_bmap_count_leaves(ifp, rblocks);
        *dblocks = ip->i_nblocks - *rblocks;
 }
+
+static void
+xfs_wait_dax_page(
+       struct inode            *inode)
+{
+       struct xfs_inode        *ip = XFS_I(inode);
+
+       xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
+       schedule();
+       xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
+}
+
+int
+xfs_break_dax_layouts(
+       struct inode            *inode,
+       bool                    *retry)
+{
+       struct page             *page;
+
+       xfs_assert_ilocked(XFS_I(inode), XFS_MMAPLOCK_EXCL);
+
+       page = dax_layout_busy_page(inode->i_mapping);
+       if (!page)
+               return 0;
+
+       *retry = true;
+       return ___wait_var_event(&page->_refcount,
+                       atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE,
+                       0, 0, xfs_wait_dax_page(inode));
+}
+
+int
+xfs_break_layouts(
+       struct inode            *inode,
+       uint                    *iolock,
+       enum layout_break_reason reason)
+{
+       bool                    retry;
+       int                     error;
+
+       xfs_assert_ilocked(XFS_I(inode), XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL);
+
+       do {
+               retry = false;
+               switch (reason) {
+               case BREAK_UNMAP:
+                       error = xfs_break_dax_layouts(inode, &retry);
+                       if (error || retry)
+                               break;
+                       fallthrough;
+               case BREAK_WRITE:
+                       error = xfs_break_leased_layouts(inode, iolock, &retry);
+                       break;
+               default:
+                       WARN_ON_ONCE(1);
+                       error = -EINVAL;
+               }
+       } while (error == 0 && retry);
+
+       return error;
+}
index ab46ffb3ac19ee91c8f12ea9980fa7d5c410ad93..5164c5d3e549cd3ba725800f26f5d841448e5b53 100644 (file)
@@ -565,7 +565,6 @@ xfs_itruncate_extents(
        return xfs_itruncate_extents_flags(tpp, ip, whichfork, new_size, 0);
 }
 
-/* from xfs_file.c */
 int    xfs_break_dax_layouts(struct inode *inode, bool *retry);
 int    xfs_break_layouts(struct inode *inode, uint *iolock,
                enum layout_break_reason reason);