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.
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
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
27 --- a/include/linux/fs.h
28 +++ b/include/linux/fs.h
29 @@ -2632,20 +2632,36 @@ enum {
30 DIO_SKIP_HOLES = 0x02,
33 +#ifdef CONFIG_DIRECT_IO
34 void dio_end_io(struct bio *bio, int error);
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);
41 +static inline void dio_end_io(struct bio *bio, int error)
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)
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)
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);
68 @@ -169,8 +169,10 @@ static int setfl(int fd, struct file * f
72 +#ifdef CONFIG_DIRECT_IO
73 if (!filp->f_mapping || !filp->f_mapping->a_ops ||
74 !filp->f_mapping->a_ops->direct_IO)
81 @@ -636,9 +636,12 @@ int open_check_o_direct(struct file *f)
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)))