kernel: add some debloat patches, strip down procfs and make O_DIRECT support optiona...
[openwrt/staging/wigyori.git] / 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,20 +2444,36 @@ 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 unsigned long nr_segs, get_block_t get_block)
57 {
58 +#ifdef CONFIG_DIRECT_IO
59 return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
60 offset, nr_segs, get_block, NULL, NULL,
61 DIO_LOCKING | DIO_SKIP_HOLES);
62 +#endif
63 }
64 #endif
65
66 --- a/fs/fcntl.c
67 +++ b/fs/fcntl.c
68 @@ -51,8 +51,10 @@ static int setfl(int fd, struct file * f
69 arg |= O_NONBLOCK;
70
71 if (arg & O_DIRECT) {
72 +#ifdef CONFIG_DIRECT_IO
73 if (!filp->f_mapping || !filp->f_mapping->a_ops ||
74 !filp->f_mapping->a_ops->direct_IO)
75 +#endif
76 return -EINVAL;
77 }
78
79 --- a/fs/open.c
80 +++ b/fs/open.c
81 @@ -630,9 +630,12 @@ int open_check_o_direct(struct file *f)
82 {
83 /* NB: we're sure to have correct a_ops only after f_op->open */
84 if (f->f_flags & O_DIRECT) {
85 +#ifdef CONFIG_DIRECT_IO
86 if (!f->f_mapping->a_ops ||
87 ((!f->f_mapping->a_ops->direct_IO) &&
88 - (!f->f_mapping->a_ops->get_xip_mem))) {
89 + (!f->f_mapping->a_ops->get_xip_mem)))
90 +#endif
91 + {
92 return -EINVAL;
93 }
94 }