mediatek: fix ESW EINT pinctrl define
[oweals/openwrt.git] / target / linux / generic / patches-4.9 / 903-debloat_direct_io.patch
1 --- a/fs/Kconfig
2 +++ b/fs/Kconfig
3 @@ -97,6 +97,11 @@ config MANDATORY_FILE_LOCKING
4  
5  source "fs/crypto/Kconfig"
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 @@ -2852,6 +2852,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 @@ -2859,6 +2860,20 @@ ssize_t __blockdev_direct_IO(struct kioc
38                              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
46 +ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
47 +                            struct block_device *bdev, struct iov_iter *iter,
48 +                            get_block_t get_block,
49 +                            dio_iodone_t end_io, dio_submit_t submit_io,
50 +                            int flags)
51 +{
52 +       return -EOPNOTSUPP;
53 +}
54 +#endif
55  
56  static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
57                                          struct inode *inode,
58 --- a/fs/fcntl.c
59 +++ b/fs/fcntl.c
60 @@ -53,8 +53,10 @@ static int setfl(int fd, struct file * f
61  
62         /* Pipe packetized mode is controlled by O_DIRECT flag */
63         if (!S_ISFIFO(filp->f_inode->i_mode) && (arg & O_DIRECT)) {
64 +#ifdef CONFIG_DIRECT_IO
65                 if (!filp->f_mapping || !filp->f_mapping->a_ops ||
66                         !filp->f_mapping->a_ops->direct_IO)
67 +#endif
68                                 return -EINVAL;
69         }
70  
71 --- a/fs/open.c
72 +++ b/fs/open.c
73 @@ -690,7 +690,9 @@ int open_check_o_direct(struct file *f)
74  {
75         /* NB: we're sure to have correct a_ops only after f_op->open */
76         if (f->f_flags & O_DIRECT) {
77 +#ifdef CONFIG_DIRECT_IO
78                 if (!f->f_mapping->a_ops || !f->f_mapping->a_ops->direct_IO)
79 +#endif
80                         return -EINVAL;
81         }
82         return 0;