kernel: generic: add kernel 4.3
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-4.3 / 903-debloat_direct_io.patch
1 --- a/fs/Kconfig
2 +++ b/fs/Kconfig
3 @@ -68,6 +68,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 nsfs.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 @@ -2695,6 +2695,7 @@ enum {
30 DIO_SKIP_DIO_COUNT = 0x08,
31 };
32
33 +#ifdef CONFIG_DIRECT_IO
34 void dio_end_io(struct bio *bio, int error);
35
36 ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
37 @@ -2702,6 +2703,18 @@ ssize_t __blockdev_direct_IO(struct kioc
38 loff_t offset, get_block_t get_block,
39 dio_iodone_t end_io, dio_submit_t submit_io,
40 int flags);
41 +#else
42 +static inline void dio_end_io(struct bio *bio, int error)
43 +{
44 +}
45 +static inline ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
46 + struct block_device *bdev, struct iov_iter *iter, loff_t offset,
47 + get_block_t get_block, dio_iodone_t end_io,
48 + dio_submit_t submit_io, int flags)
49 +{
50 + return -EOPNOTSUPP;
51 +}
52 +#endif
53
54 static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
55 struct inode *inode,
56 --- a/fs/fcntl.c
57 +++ b/fs/fcntl.c
58 @@ -52,8 +52,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 @@ -673,7 +673,9 @@ 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 || !f->f_mapping->a_ops->direct_IO)
77 +#endif
78 return -EINVAL;
79 }
80 return 0;