Merge tag 'xfs-4.18-merge-10' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[platform/kernel/linux-starfive.git] / fs / xfs / xfs_inode.h
index 1eebc53..2ed63a4 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_INODE_H__
 #define        __XFS_INODE_H__
@@ -379,6 +367,20 @@ static inline void xfs_ifunlock(struct xfs_inode *ip)
                                        >> XFS_ILOCK_SHIFT)
 
 /*
+ * Layouts are broken in the BREAK_WRITE case to ensure that
+ * layout-holders do not collide with local writes. Additionally,
+ * layouts are broken in the BREAK_UNMAP case to make sure the
+ * layout-holder has a consistent view of the file's extent map. While
+ * BREAK_WRITE breaks can be satisfied by recalling FL_LAYOUT leases,
+ * BREAK_UNMAP breaks additionally require waiting for busy dax-pages to
+ * go idle.
+ */
+enum layout_break_reason {
+        BREAK_WRITE,
+        BREAK_UNMAP,
+};
+
+/*
  * For multiple groups support: if S_ISGID bit is set in the parent
  * directory, group of new file is set to that of the parent, and
  * new subdirectory gets S_ISGID bit from parent.
@@ -415,8 +417,8 @@ uint                xfs_ilock_attr_map_shared(struct xfs_inode *);
 uint           xfs_ip2xflags(struct xfs_inode *);
 int            xfs_ifree(struct xfs_trans *, xfs_inode_t *,
                           struct xfs_defer_ops *);
-int            xfs_itruncate_extents(struct xfs_trans **, struct xfs_inode *,
-                                     int, xfs_fsize_t);
+int            xfs_itruncate_extents_flags(struct xfs_trans **,
+                               struct xfs_inode *, int, xfs_fsize_t, int);
 void           xfs_iext_realloc(xfs_inode_t *, int, int);
 
 void           xfs_iunpin_wait(xfs_inode_t *);
@@ -433,6 +435,16 @@ int                xfs_dir_ialloc(struct xfs_trans **, struct xfs_inode *, umode_t,
                               xfs_nlink_t, dev_t, prid_t,
                               struct xfs_inode **);
 
+static inline int
+xfs_itruncate_extents(
+       struct xfs_trans        **tpp,
+       struct xfs_inode        *ip,
+       int                     whichfork,
+       xfs_fsize_t             new_size)
+{
+       return xfs_itruncate_extents_flags(tpp, ip, whichfork, new_size, 0);
+}
+
 /* from xfs_file.c */
 enum xfs_prealloc_flags {
        XFS_PREALLOC_SET        = (1 << 1),
@@ -443,6 +455,8 @@ enum xfs_prealloc_flags {
 
 int    xfs_update_prealloc_flags(struct xfs_inode *ip,
                                  enum xfs_prealloc_flags flags);
+int    xfs_break_layouts(struct inode *inode, uint *iolock,
+               enum layout_break_reason reason);
 
 /* from xfs_iops.c */
 extern void xfs_setup_inode(struct xfs_inode *ip);