ledtrig-netdev: update base driver instead of patching it for every kernel
[openwrt/openwrt.git] / target / linux / generic / patches-3.18 / 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 fs_pin.o
19
20 ifeq ($(CONFIG_BLOCK),y)
21 -obj-y += buffer.o block_dev.o direct-io.o mpage.o
22 +obj-y += buffer.o block_dev.o mpage.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 @@ -2528,12 +2528,25 @@ enum {
30 DIO_ASYNC_EXTEND = 0x04,
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, struct iov_iter *iter, loff_t offset,
38 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, struct iov_iter *iter, loff_t offset,
46 + 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 static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
54 struct inode *inode, struct iov_iter *iter, loff_t offset,
55 --- a/fs/fcntl.c
56 +++ b/fs/fcntl.c
57 @@ -52,8 +52,10 @@ static int setfl(int fd, struct file * f
58 arg |= O_NONBLOCK;
59
60 if (arg & O_DIRECT) {
61 +#ifdef CONFIG_DIRECT_IO
62 if (!filp->f_mapping || !filp->f_mapping->a_ops ||
63 !filp->f_mapping->a_ops->direct_IO)
64 +#endif
65 return -EINVAL;
66 }
67
68 --- a/fs/open.c
69 +++ b/fs/open.c
70 @@ -655,9 +655,12 @@ int open_check_o_direct(struct file *f)
71 {
72 /* NB: we're sure to have correct a_ops only after f_op->open */
73 if (f->f_flags & O_DIRECT) {
74 +#ifdef CONFIG_DIRECT_IO
75 if (!f->f_mapping->a_ops ||
76 ((!f->f_mapping->a_ops->direct_IO) &&
77 - (!f->f_mapping->a_ops->get_xip_mem))) {
78 + (!f->f_mapping->a_ops->get_xip_mem)))
79 +#endif
80 + {
81 return -EINVAL;
82 }
83 }