Merge tag 'for_v4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
[sfrench/cifs-2.6.git] / include / linux / fs.h
index 00b23b21e78af61425e2ccfac6e402670fb0e174..8252df30b9a16afe53c269b912b47e17edac7b41 100644 (file)
@@ -403,24 +403,40 @@ int pagecache_write_end(struct file *, struct address_space *mapping,
                                loff_t pos, unsigned len, unsigned copied,
                                struct page *page, void *fsdata);
 
+/**
+ * struct address_space - Contents of a cacheable, mappable object.
+ * @host: Owner, either the inode or the block_device.
+ * @i_pages: Cached pages.
+ * @gfp_mask: Memory allocation flags to use for allocating pages.
+ * @i_mmap_writable: Number of VM_SHARED mappings.
+ * @i_mmap: Tree of private and shared mappings.
+ * @i_mmap_rwsem: Protects @i_mmap and @i_mmap_writable.
+ * @nrpages: Number of page entries, protected by the i_pages lock.
+ * @nrexceptional: Shadow or DAX entries, protected by the i_pages lock.
+ * @writeback_index: Writeback starts here.
+ * @a_ops: Methods.
+ * @flags: Error bits and flags (AS_*).
+ * @wb_err: The most recent error which has occurred.
+ * @private_lock: For use by the owner of the address_space.
+ * @private_list: For use by the owner of the address_space.
+ * @private_data: For use by the owner of the address_space.
+ */
 struct address_space {
-       struct inode            *host;          /* owner: inode, block_device */
-       struct radix_tree_root  i_pages;        /* cached pages */
-       atomic_t                i_mmap_writable;/* count VM_SHARED mappings */
-       struct rb_root_cached   i_mmap;         /* tree of private and shared mappings */
-       struct rw_semaphore     i_mmap_rwsem;   /* protect tree, count, list */
-       /* Protected by the i_pages lock */
-       unsigned long           nrpages;        /* number of total pages */
-       /* number of shadow or DAX exceptional entries */
+       struct inode            *host;
+       struct xarray           i_pages;
+       gfp_t                   gfp_mask;
+       atomic_t                i_mmap_writable;
+       struct rb_root_cached   i_mmap;
+       struct rw_semaphore     i_mmap_rwsem;
+       unsigned long           nrpages;
        unsigned long           nrexceptional;
-       pgoff_t                 writeback_index;/* writeback starts here */
-       const struct address_space_operations *a_ops;   /* methods */
-       unsigned long           flags;          /* error bits */
-       spinlock_t              private_lock;   /* for use by the address_space */
-       gfp_t                   gfp_mask;       /* implicit gfp mask for allocations */
-       struct list_head        private_list;   /* for use by the address_space */
-       void                    *private_data;  /* ditto */
+       pgoff_t                 writeback_index;
+       const struct address_space_operations *a_ops;
+       unsigned long           flags;
        errseq_t                wb_err;
+       spinlock_t              private_lock;
+       struct list_head        private_list;
+       void                    *private_data;
 } __attribute__((aligned(sizeof(long)))) __randomize_layout;
        /*
         * On most architectures that alignment is already the case; but
@@ -467,15 +483,18 @@ struct block_device {
        struct mutex            bd_fsfreeze_mutex;
 } __randomize_layout;
 
+/* XArray tags, for tagging dirty and writeback pages in the pagecache. */
+#define PAGECACHE_TAG_DIRTY    XA_MARK_0
+#define PAGECACHE_TAG_WRITEBACK        XA_MARK_1
+#define PAGECACHE_TAG_TOWRITE  XA_MARK_2
+
 /*
- * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
- * radix trees
+ * Returns true if any of the pages in the mapping are marked with the tag.
  */
-#define PAGECACHE_TAG_DIRTY    0
-#define PAGECACHE_TAG_WRITEBACK        1
-#define PAGECACHE_TAG_TOWRITE  2
-
-int mapping_tagged(struct address_space *mapping, int tag);
+static inline bool mapping_tagged(struct address_space *mapping, xa_mark_t tag)
+{
+       return xa_marked(&mapping->i_pages, tag);
+}
 
 static inline void i_mmap_lock_write(struct address_space *mapping)
 {
@@ -1775,6 +1794,7 @@ struct file_operations {
                        u64);
        int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t,
                        u64);
+       int (*fadvise)(struct file *, loff_t, loff_t, int);
 } __randomize_layout;
 
 struct inode_operations {
@@ -1839,8 +1859,10 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *,
 extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in,
                                      struct inode *inode_out, loff_t pos_out,
                                      u64 *len, bool is_dedupe);
+extern int do_clone_file_range(struct file *file_in, loff_t pos_in,
+                              struct file *file_out, loff_t pos_out, u64 len);
 extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
-               struct file *file_out, loff_t pos_out, u64 len);
+                               struct file *file_out, loff_t pos_out, u64 len);
 extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
                                         struct inode *dest, loff_t destoff,
                                         loff_t len, bool *is_same);
@@ -2784,19 +2806,6 @@ static inline void file_end_write(struct file *file)
        __sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE);
 }
 
-static inline int do_clone_file_range(struct file *file_in, loff_t pos_in,
-                                     struct file *file_out, loff_t pos_out,
-                                     u64 len)
-{
-       int ret;
-
-       file_start_write(file_out);
-       ret = vfs_clone_file_range(file_in, pos_in, file_out, pos_out, len);
-       file_end_write(file_out);
-
-       return ret;
-}
-
 /*
  * get_write_access() gets write permission for a file.
  * put_write_access() releases this write permission.
@@ -3471,4 +3480,8 @@ static inline bool dir_relax_shared(struct inode *inode)
 extern bool path_noexec(const struct path *path);
 extern void inode_nohighmem(struct inode *inode);
 
+/* mm/fadvise.c */
+extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,
+                      int advice);
+
 #endif /* _LINUX_FS_H */