aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-01-14 04:42:32 -0500
committerJens Axboe <axboe@fb.com>2015-01-20 16:02:58 -0500
commitb4caecd48005fbed3949dde6c1cb233142fd69e9 (patch)
tree1fdd9b7c15568c79eb3c1ed84a39858ddbcbc88b /include
parent97b713ba3ebaa6c8d84c2c720f5468a7c6a6eb4e (diff)
fs: introduce f_op->mmap_capabilities for nommu mmap support
Since "BDI: Provide backing device capability information [try #3]" the backing_dev_info structure also provides flags for the kind of mmap operation available in a nommu environment, which is entirely unrelated to it's original purpose. Introduce a new nommu-only file operation to provide this information to the nommu mmap code instead. Splitting this from the backing_dev_info structure allows to remove lots of backing_dev_info instance that aren't otherwise needed, and entirely gets rid of the concept of providing a backing_dev_info for a character device. It also removes the need for the mtd_inodefs filesystem. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Tejun Heo <tj@kernel.org> Acked-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/backing-dev.h33
-rw-r--r--include/linux/cdev.h2
-rw-r--r--include/linux/fs.h23
-rw-r--r--include/linux/mtd/mtd.h2
4 files changed, 29 insertions, 31 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index e936cea856dc..478f95d92d73 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -114,7 +114,7 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
114 const char *fmt, ...); 114 const char *fmt, ...);
115int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); 115int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
116void bdi_unregister(struct backing_dev_info *bdi); 116void bdi_unregister(struct backing_dev_info *bdi);
117int __must_check bdi_setup_and_register(struct backing_dev_info *, char *, unsigned int); 117int __must_check bdi_setup_and_register(struct backing_dev_info *, char *);
118void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages, 118void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages,
119 enum wb_reason reason); 119 enum wb_reason reason);
120void bdi_start_background_writeback(struct backing_dev_info *bdi); 120void bdi_start_background_writeback(struct backing_dev_info *bdi);
@@ -228,42 +228,17 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
228 * BDI_CAP_NO_ACCT_DIRTY: Dirty pages shouldn't contribute to accounting 228 * BDI_CAP_NO_ACCT_DIRTY: Dirty pages shouldn't contribute to accounting
229 * BDI_CAP_NO_WRITEBACK: Don't write pages back 229 * BDI_CAP_NO_WRITEBACK: Don't write pages back
230 * BDI_CAP_NO_ACCT_WB: Don't automatically account writeback pages 230 * BDI_CAP_NO_ACCT_WB: Don't automatically account writeback pages
231 *
232 * These flags let !MMU mmap() govern direct device mapping vs immediate
233 * copying more easily for MAP_PRIVATE, especially for ROM filesystems.
234 *
235 * BDI_CAP_MAP_COPY: Copy can be mapped (MAP_PRIVATE)
236 * BDI_CAP_MAP_DIRECT: Can be mapped directly (MAP_SHARED)
237 * BDI_CAP_READ_MAP: Can be mapped for reading
238 * BDI_CAP_WRITE_MAP: Can be mapped for writing
239 * BDI_CAP_EXEC_MAP: Can be mapped for execution
240 *
241 * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold. 231 * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold.
242 */ 232 */
243#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 233#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
244#define BDI_CAP_NO_WRITEBACK 0x00000002 234#define BDI_CAP_NO_WRITEBACK 0x00000002
245#define BDI_CAP_MAP_COPY 0x00000004 235#define BDI_CAP_NO_ACCT_WB 0x00000004
246#define BDI_CAP_MAP_DIRECT 0x00000008 236#define BDI_CAP_STABLE_WRITES 0x00000008
247#define BDI_CAP_READ_MAP 0x00000010 237#define BDI_CAP_STRICTLIMIT 0x00000010
248#define BDI_CAP_WRITE_MAP 0x00000020
249#define BDI_CAP_EXEC_MAP 0x00000040
250#define BDI_CAP_NO_ACCT_WB 0x00000080
251#define BDI_CAP_STABLE_WRITES 0x00000200
252#define BDI_CAP_STRICTLIMIT 0x00000400
253
254#define BDI_CAP_VMFLAGS \
255 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP)
256 238
257#define BDI_CAP_NO_ACCT_AND_WRITEBACK \ 239#define BDI_CAP_NO_ACCT_AND_WRITEBACK \
258 (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB) 240 (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
259 241
260#if defined(VM_MAYREAD) && \
261 (BDI_CAP_READ_MAP != VM_MAYREAD || \
262 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \
263 BDI_CAP_EXEC_MAP != VM_MAYEXEC)
264#error please change backing_dev_info::capabilities flags
265#endif
266
267extern struct backing_dev_info default_backing_dev_info; 242extern struct backing_dev_info default_backing_dev_info;
268extern struct backing_dev_info noop_backing_dev_info; 243extern struct backing_dev_info noop_backing_dev_info;
269 244
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
index fb4591977b03..f8763615a5f2 100644
--- a/include/linux/cdev.h
+++ b/include/linux/cdev.h
@@ -30,6 +30,4 @@ void cdev_del(struct cdev *);
30 30
31void cd_forget(struct inode *); 31void cd_forget(struct inode *);
32 32
33extern struct backing_dev_info directly_mappable_cdev_bdi;
34
35#endif 33#endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 42efe13077b6..1dada399aa23 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1502,6 +1502,26 @@ struct block_device_operations;
1502#define HAVE_COMPAT_IOCTL 1 1502#define HAVE_COMPAT_IOCTL 1
1503#define HAVE_UNLOCKED_IOCTL 1 1503#define HAVE_UNLOCKED_IOCTL 1
1504 1504
1505/*
1506 * These flags let !MMU mmap() govern direct device mapping vs immediate
1507 * copying more easily for MAP_PRIVATE, especially for ROM filesystems.
1508 *
1509 * NOMMU_MAP_COPY: Copy can be mapped (MAP_PRIVATE)
1510 * NOMMU_MAP_DIRECT: Can be mapped directly (MAP_SHARED)
1511 * NOMMU_MAP_READ: Can be mapped for reading
1512 * NOMMU_MAP_WRITE: Can be mapped for writing
1513 * NOMMU_MAP_EXEC: Can be mapped for execution
1514 */
1515#define NOMMU_MAP_COPY 0x00000001
1516#define NOMMU_MAP_DIRECT 0x00000008
1517#define NOMMU_MAP_READ VM_MAYREAD
1518#define NOMMU_MAP_WRITE VM_MAYWRITE
1519#define NOMMU_MAP_EXEC VM_MAYEXEC
1520
1521#define NOMMU_VMFLAGS \
1522 (NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC)
1523
1524
1505struct iov_iter; 1525struct iov_iter;
1506 1526
1507struct file_operations { 1527struct file_operations {
@@ -1536,6 +1556,9 @@ struct file_operations {
1536 long (*fallocate)(struct file *file, int mode, loff_t offset, 1556 long (*fallocate)(struct file *file, int mode, loff_t offset,
1537 loff_t len); 1557 loff_t len);
1538 void (*show_fdinfo)(struct seq_file *m, struct file *f); 1558 void (*show_fdinfo)(struct seq_file *m, struct file *f);
1559#ifndef CONFIG_MMU
1560 unsigned (*mmap_capabilities)(struct file *);
1561#endif
1539}; 1562};
1540 1563
1541struct inode_operations { 1564struct inode_operations {
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 031ff3a9a0bd..3301c4c289d6 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -408,4 +408,6 @@ static inline int mtd_is_bitflip_or_eccerr(int err) {
408 return mtd_is_bitflip(err) || mtd_is_eccerr(err); 408 return mtd_is_bitflip(err) || mtd_is_eccerr(err);
409} 409}
410 410
411unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
412
411#endif /* __MTD_MTD_H__ */ 413#endif /* __MTD_MTD_H__ */