Root/target/linux/generic/patches-3.7/903-debloat_direct_io.patch

1--- a/fs/Kconfig
2+++ b/fs/Kconfig
3@@ -62,6 +62,11 @@ config FILE_LOCKING
4           for filesystems like NFS and for the flock() system
5           call. Disabling this option saves about 11k.
6 
7+config DIRECT_IO
8+ bool "Enable O_DIRECT support" if EXPERT
9+ depends on BLOCK
10+ default y
11+
12 source "fs/notify/Kconfig"
13 
14 source "fs/quota/Kconfig"
15--- a/fs/Makefile
16+++ b/fs/Makefile
17@@ -14,7 +14,8 @@ obj-y := open.o read_write.o file_table.
18         stack.o fs_struct.o statfs.o
19 
20 ifeq ($(CONFIG_BLOCK),y)
21-obj-y += buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
22+obj-y += buffer.o bio.o block_dev.o mpage.o ioprio.o
23+obj-$(CONFIG_DIRECT_IO) += direct-io.o
24 else
25 obj-y += no-block.o
26 endif
27--- a/include/linux/fs.h
28+++ b/include/linux/fs.h
29@@ -2444,12 +2444,26 @@ enum {
30     DIO_SKIP_HOLES = 0x02,
31 };
32 
33+#ifdef CONFIG_DIRECT_IO
34 void dio_end_io(struct bio *bio, int error);
35 
36 ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
37     struct block_device *bdev, const struct iovec *iov, loff_t offset,
38     unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io,
39     dio_submit_t submit_io, int flags);
40+#else
41+static inline void dio_end_io(struct bio *bio, int error)
42+{
43+}
44+static inline ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
45+ struct block_device *bdev, const struct iovec *iov, loff_t offset,
46+ unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io,
47+ dio_submit_t submit_io, int flags)
48+{
49+ return -EOPNOTSUPP;
50+}
51+#endif
52+
53 
54 static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
55         struct inode *inode, const struct iovec *iov, loff_t offset,
56--- a/fs/fcntl.c
57+++ b/fs/fcntl.c
58@@ -51,8 +51,10 @@ static int setfl(int fd, struct file * f
59            arg |= O_NONBLOCK;
60 
61     if (arg & O_DIRECT) {
62+#ifdef CONFIG_DIRECT_IO
63         if (!filp->f_mapping || !filp->f_mapping->a_ops ||
64             !filp->f_mapping->a_ops->direct_IO)
65+#endif
66                 return -EINVAL;
67     }
68 
69--- a/fs/open.c
70+++ b/fs/open.c
71@@ -630,9 +630,12 @@ int open_check_o_direct(struct file *f)
72 {
73     /* NB: we're sure to have correct a_ops only after f_op->open */
74     if (f->f_flags & O_DIRECT) {
75+#ifdef CONFIG_DIRECT_IO
76         if (!f->f_mapping->a_ops ||
77             ((!f->f_mapping->a_ops->direct_IO) &&
78- (!f->f_mapping->a_ops->get_xip_mem))) {
79+ (!f->f_mapping->a_ops->get_xip_mem)))
80+#endif
81+ {
82             return -EINVAL;
83         }
84     }
85

Archive Download this file



interactive