aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2018-03-07 18:26:44 -0500
committerDan Williams <dan.j.williams@intel.com>2018-03-30 14:34:55 -0400
commitf44c77630d26ca2c2a60b20c47dd9ce07c4361b3 (patch)
treeec06b086dc96720330ede25f4cd74909f0e8bde1
parent3fe0791c295cfd3cd735de7a32cc0780949c009f (diff)
fs, dax: prepare for dax-specific address_space_operations
In preparation for the dax implementation to start associating dax pages to inodes via page->mapping, we need to provide a 'struct address_space_operations' instance for dax. Define some generic VFS aops helpers for dax. These noop implementations are there in the dax case to prevent the VFS from falling back to operations with page-cache assumptions, dax_writeback_mapping_range() may not be referenced in the FS_DAX=n case. Cc: Jeff Moyer <jmoyer@redhat.com> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Suggested-by: Matthew Wilcox <mawilcox@microsoft.com> Suggested-by: Jan Kara <jack@suse.cz> Suggested-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Suggested-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--fs/libfs.c39
-rw-r--r--include/linux/dax.h12
-rw-r--r--include/linux/fs.h4
3 files changed, 52 insertions, 3 deletions
diff --git a/fs/libfs.c b/fs/libfs.c
index 7ff3cb904acd..0fb590d79f30 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1060,6 +1060,45 @@ int noop_fsync(struct file *file, loff_t start, loff_t end, int datasync)
1060} 1060}
1061EXPORT_SYMBOL(noop_fsync); 1061EXPORT_SYMBOL(noop_fsync);
1062 1062
1063int noop_set_page_dirty(struct page *page)
1064{
1065 /*
1066 * Unlike __set_page_dirty_no_writeback that handles dirty page
1067 * tracking in the page object, dax does all dirty tracking in
1068 * the inode address_space in response to mkwrite faults. In the
1069 * dax case we only need to worry about potentially dirty CPU
1070 * caches, not dirty page cache pages to write back.
1071 *
1072 * This callback is defined to prevent fallback to
1073 * __set_page_dirty_buffers() in set_page_dirty().
1074 */
1075 return 0;
1076}
1077EXPORT_SYMBOL_GPL(noop_set_page_dirty);
1078
1079void noop_invalidatepage(struct page *page, unsigned int offset,
1080 unsigned int length)
1081{
1082 /*
1083 * There is no page cache to invalidate in the dax case, however
1084 * we need this callback defined to prevent falling back to
1085 * block_invalidatepage() in do_invalidatepage().
1086 */
1087}
1088EXPORT_SYMBOL_GPL(noop_invalidatepage);
1089
1090ssize_t noop_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
1091{
1092 /*
1093 * iomap based filesystems support direct I/O without need for
1094 * this callback. However, it still needs to be set in
1095 * inode->a_ops so that open/fcntl know that direct I/O is
1096 * generally supported.
1097 */
1098 return -EINVAL;
1099}
1100EXPORT_SYMBOL_GPL(noop_direct_IO);
1101
1063/* Because kfree isn't assignment-compatible with void(void*) ;-/ */ 1102/* Because kfree isn't assignment-compatible with void(void*) ;-/ */
1064void kfree_link(void *p) 1103void kfree_link(void *p)
1065{ 1104{
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 0185ecdae135..ae27a7efe7ab 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -38,6 +38,7 @@ static inline void put_dax(struct dax_device *dax_dev)
38} 38}
39#endif 39#endif
40 40
41struct writeback_control;
41int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); 42int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff);
42#if IS_ENABLED(CONFIG_FS_DAX) 43#if IS_ENABLED(CONFIG_FS_DAX)
43int __bdev_dax_supported(struct super_block *sb, int blocksize); 44int __bdev_dax_supported(struct super_block *sb, int blocksize);
@@ -57,6 +58,8 @@ static inline void fs_put_dax(struct dax_device *dax_dev)
57} 58}
58 59
59struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev); 60struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev);
61int dax_writeback_mapping_range(struct address_space *mapping,
62 struct block_device *bdev, struct writeback_control *wbc);
60#else 63#else
61static inline int bdev_dax_supported(struct super_block *sb, int blocksize) 64static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
62{ 65{
@@ -76,6 +79,12 @@ static inline struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev)
76{ 79{
77 return NULL; 80 return NULL;
78} 81}
82
83static inline int dax_writeback_mapping_range(struct address_space *mapping,
84 struct block_device *bdev, struct writeback_control *wbc)
85{
86 return -EOPNOTSUPP;
87}
79#endif 88#endif
80 89
81int dax_read_lock(void); 90int dax_read_lock(void);
@@ -121,7 +130,4 @@ static inline bool dax_mapping(struct address_space *mapping)
121 return mapping->host && IS_DAX(mapping->host); 130 return mapping->host && IS_DAX(mapping->host);
122} 131}
123 132
124struct writeback_control;
125int dax_writeback_mapping_range(struct address_space *mapping,
126 struct block_device *bdev, struct writeback_control *wbc);
127#endif 133#endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 79c413985305..44f7f7080faa 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3129,6 +3129,10 @@ extern int simple_rmdir(struct inode *, struct dentry *);
3129extern int simple_rename(struct inode *, struct dentry *, 3129extern int simple_rename(struct inode *, struct dentry *,
3130 struct inode *, struct dentry *, unsigned int); 3130 struct inode *, struct dentry *, unsigned int);
3131extern int noop_fsync(struct file *, loff_t, loff_t, int); 3131extern int noop_fsync(struct file *, loff_t, loff_t, int);
3132extern int noop_set_page_dirty(struct page *page);
3133extern void noop_invalidatepage(struct page *page, unsigned int offset,
3134 unsigned int length);
3135extern ssize_t noop_direct_IO(struct kiocb *iocb, struct iov_iter *iter);
3132extern int simple_empty(struct dentry *); 3136extern int simple_empty(struct dentry *);
3133extern int simple_readpage(struct file *file, struct page *page); 3137extern int simple_readpage(struct file *file, struct page *page);
3134extern int simple_write_begin(struct file *file, struct address_space *mapping, 3138extern int simple_write_begin(struct file *file, struct address_space *mapping,