3 @@ -97,6 +97,11 @@ config MANDATORY_FILE_LOCKING
5 source "fs/crypto/Kconfig"
8 + bool "Enable O_DIRECT support" if EXPERT
12 source "fs/notify/Kconfig"
14 source "fs/quota/Kconfig"
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
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
27 --- a/include/linux/fs.h
28 +++ b/include/linux/fs.h
29 @@ -2852,6 +2852,7 @@ enum {
30 DIO_SKIP_DIO_COUNT = 0x08,
33 +#ifdef CONFIG_DIRECT_IO
34 void dio_end_io(struct bio *bio, int error);
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,
42 +static inline void dio_end_io(struct bio *bio, int error)
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,
56 static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
60 @@ -53,8 +53,10 @@ static int setfl(int fd, struct file * f
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)
73 @@ -690,7 +690,9 @@ int open_check_o_direct(struct file *f)
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)