Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.34 KB | None | 0 0
  1. diff --git a/fs/io_uring.c b/fs/io_uring.c
  2. index 405be10da73d..a2974d560246 100644
  3. --- a/fs/io_uring.c
  4. +++ b/fs/io_uring.c
  5. @@ -1773,8 +1773,15 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,
  6.     iov_count = iov_iter_count(&iter);
  7.     ret = rw_verify_area(READ, file, &kiocb->ki_pos, iov_count);
  8.     if (!ret) {
  9. +       struct inode *inode = file_inode(req->file);
  10. +       off_t start = req->rw.ki_pos >> PAGE_SHIFT;
  11. +       off_t end = (req->rw.ki_pos + io_size - 1) >> PAGE_SHIFT;
  12. +       bool do_inval = false;
  13.         ssize_t ret2;
  14.  
  15. +       if (force_nonblock && (kiocb->ki_flags & IOCB_DROPBEHIND))
  16. +           do_inval = true;
  17. +
  18.         if (file->f_op->read_iter)
  19.             ret2 = call_read_iter(file, kiocb, &iter);
  20.         else
  21. @@ -1795,6 +1802,9 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,
  22.         /* Catch -EAGAIN return for forced non-blocking submission */
  23.         if (!force_nonblock || ret2 != -EAGAIN) {
  24.             kiocb_done(kiocb, ret2, nxt, req->in_async);
  25. +           if (force_nonblock)
  26. +               invalidate_inode_pages2_range(inode->i_mapping,
  27. +                       start, end);
  28.         } else {
  29.  copy_iov:
  30.             ret = io_setup_async_io(req, io_size, iovec,
  31. diff --git a/include/linux/fs.h b/include/linux/fs.h
  32. index 98e0349adb52..647f7e38927c 100644
  33. --- a/include/linux/fs.h
  34. +++ b/include/linux/fs.h
  35. @@ -314,6 +314,7 @@ enum rw_hint {
  36.  #define IOCB_SYNC      (1 << 5)
  37.  #define IOCB_WRITE     (1 << 6)
  38.  #define IOCB_NOWAIT        (1 << 7)
  39. +#define IOCB_DROPBEHIND        (1 << 8)
  40.  
  41.  struct kiocb {
  42.     struct file     *ki_filp;
  43. @@ -3418,6 +3419,8 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)
  44.         ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC);
  45.     if (flags & RWF_APPEND)
  46.         ki->ki_flags |= IOCB_APPEND;
  47. +   if (flags & RWF_DROPBEHIND)
  48. +       ki->ki_flags |= IOCB_DROPBEHIND;
  49.     return 0;
  50.  }
  51.  
  52. diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
  53. index 379a612f8f1d..f4ac77da2429 100644
  54. --- a/include/uapi/linux/fs.h
  55. +++ b/include/uapi/linux/fs.h
  56. @@ -299,8 +299,11 @@ typedef int __bitwise __kernel_rwf_t;
  57.  /* per-IO O_APPEND */
  58.  #define RWF_APPEND ((__force __kernel_rwf_t)0x00000010)
  59.  
  60. +/* drop behind cached IO */
  61. +#define RWF_DROPBEHIND ((__force __kernel_rwf_t)0x00000020)
  62. +
  63.  /* mask of flags supported by the kernel */
  64.  #define RWF_SUPPORTED  (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
  65. -            RWF_APPEND)
  66. +            RWF_APPEND | RWF_DROPBEHIND)
  67.  
  68.  #endif /* _UAPI_LINUX_FS_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement