903-debloat_direct_io.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --- a/fs/Kconfig
  2. +++ b/fs/Kconfig
  3. @@ -74,6 +74,11 @@ config FILE_LOCKING
  4. for filesystems like NFS and for the flock() system
  5. call. Disabling this option saves about 11k.
  6. +config DIRECT_IO
  7. + bool "Enable O_DIRECT support" if EXPERT
  8. + depends on BLOCK
  9. + default y
  10. +
  11. source "fs/notify/Kconfig"
  12. source "fs/quota/Kconfig"
  13. --- a/fs/Makefile
  14. +++ b/fs/Makefile
  15. @@ -14,7 +14,8 @@ obj-y := open.o read_write.o file_table.
  16. stack.o fs_struct.o statfs.o fs_pin.o nsfs.o
  17. ifeq ($(CONFIG_BLOCK),y)
  18. -obj-y += buffer.o block_dev.o direct-io.o mpage.o
  19. +obj-y += buffer.o block_dev.o mpage.o
  20. +obj-$(CONFIG_DIRECT_IO) += direct-io.o
  21. else
  22. obj-y += no-block.o
  23. endif
  24. --- a/include/linux/fs.h
  25. +++ b/include/linux/fs.h
  26. @@ -2691,6 +2691,7 @@ enum {
  27. DIO_SKIP_DIO_COUNT = 0x08,
  28. };
  29. +#ifdef CONFIG_DIRECT_IO
  30. void dio_end_io(struct bio *bio, int error);
  31. ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
  32. @@ -2698,6 +2699,18 @@ ssize_t __blockdev_direct_IO(struct kioc
  33. loff_t offset, get_block_t get_block,
  34. dio_iodone_t end_io, dio_submit_t submit_io,
  35. int flags);
  36. +#else
  37. +static inline void dio_end_io(struct bio *bio, int error)
  38. +{
  39. +}
  40. +static inline ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
  41. + struct block_device *bdev, struct iov_iter *iter, loff_t offset,
  42. + get_block_t get_block, dio_iodone_t end_io,
  43. + dio_submit_t submit_io, int flags)
  44. +{
  45. + return -EOPNOTSUPP;
  46. +}
  47. +#endif
  48. static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
  49. struct inode *inode,
  50. --- a/fs/fcntl.c
  51. +++ b/fs/fcntl.c
  52. @@ -52,8 +52,10 @@ static int setfl(int fd, struct file * f
  53. arg |= O_NONBLOCK;
  54. if (arg & O_DIRECT) {
  55. +#ifdef CONFIG_DIRECT_IO
  56. if (!filp->f_mapping || !filp->f_mapping->a_ops ||
  57. !filp->f_mapping->a_ops->direct_IO)
  58. +#endif
  59. return -EINVAL;
  60. }
  61. --- a/fs/open.c
  62. +++ b/fs/open.c
  63. @@ -673,7 +673,9 @@ int open_check_o_direct(struct file *f)
  64. {
  65. /* NB: we're sure to have correct a_ops only after f_op->open */
  66. if (f->f_flags & O_DIRECT) {
  67. +#ifdef CONFIG_DIRECT_IO
  68. if (!f->f_mapping->a_ops || !f->f_mapping->a_ops->direct_IO)
  69. +#endif
  70. return -EINVAL;
  71. }
  72. return 0;