~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/io_uring/advise.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /io_uring/advise.c (Version linux-6.11.5) and /io_uring/advise.c (Version linux-6.9.12)


  1 // SPDX-License-Identifier: GPL-2.0                 1 // SPDX-License-Identifier: GPL-2.0
  2 #include <linux/kernel.h>                           2 #include <linux/kernel.h>
  3 #include <linux/errno.h>                            3 #include <linux/errno.h>
  4 #include <linux/fs.h>                               4 #include <linux/fs.h>
  5 #include <linux/file.h>                             5 #include <linux/file.h>
  6 #include <linux/mm.h>                               6 #include <linux/mm.h>
  7 #include <linux/slab.h>                             7 #include <linux/slab.h>
  8 #include <linux/namei.h>                            8 #include <linux/namei.h>
  9 #include <linux/io_uring.h>                         9 #include <linux/io_uring.h>
 10                                                    10 
 11 #include <uapi/linux/fadvise.h>                    11 #include <uapi/linux/fadvise.h>
 12 #include <uapi/linux/io_uring.h>                   12 #include <uapi/linux/io_uring.h>
 13                                                    13 
 14 #include "io_uring.h"                              14 #include "io_uring.h"
 15 #include "advise.h"                                15 #include "advise.h"
 16                                                    16 
 17 struct io_fadvise {                                17 struct io_fadvise {
 18         struct file                     *file;     18         struct file                     *file;
 19         u64                             offset     19         u64                             offset;
 20         u64                             len;   !!  20         u32                             len;
 21         u32                             advice     21         u32                             advice;
 22 };                                                 22 };
 23                                                    23 
 24 struct io_madvise {                                24 struct io_madvise {
 25         struct file                     *file;     25         struct file                     *file;
 26         u64                             addr;      26         u64                             addr;
 27         u64                             len;   !!  27         u32                             len;
 28         u32                             advice     28         u32                             advice;
 29 };                                                 29 };
 30                                                    30 
 31 int io_madvise_prep(struct io_kiocb *req, cons     31 int io_madvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 32 {                                                  32 {
 33 #if defined(CONFIG_ADVISE_SYSCALLS) && defined     33 #if defined(CONFIG_ADVISE_SYSCALLS) && defined(CONFIG_MMU)
 34         struct io_madvise *ma = io_kiocb_to_cm     34         struct io_madvise *ma = io_kiocb_to_cmd(req, struct io_madvise);
 35                                                    35 
 36         if (sqe->buf_index || sqe->splice_fd_i !!  36         if (sqe->buf_index || sqe->off || sqe->splice_fd_in)
 37                 return -EINVAL;                    37                 return -EINVAL;
 38                                                    38 
 39         ma->addr = READ_ONCE(sqe->addr);           39         ma->addr = READ_ONCE(sqe->addr);
 40         ma->len = READ_ONCE(sqe->off);         !!  40         ma->len = READ_ONCE(sqe->len);
 41         if (!ma->len)                          << 
 42                 ma->len = READ_ONCE(sqe->len); << 
 43         ma->advice = READ_ONCE(sqe->fadvise_ad     41         ma->advice = READ_ONCE(sqe->fadvise_advice);
 44         req->flags |= REQ_F_FORCE_ASYNC;           42         req->flags |= REQ_F_FORCE_ASYNC;
 45         return 0;                                  43         return 0;
 46 #else                                              44 #else
 47         return -EOPNOTSUPP;                        45         return -EOPNOTSUPP;
 48 #endif                                             46 #endif
 49 }                                                  47 }
 50                                                    48 
 51 int io_madvise(struct io_kiocb *req, unsigned      49 int io_madvise(struct io_kiocb *req, unsigned int issue_flags)
 52 {                                                  50 {
 53 #if defined(CONFIG_ADVISE_SYSCALLS) && defined     51 #if defined(CONFIG_ADVISE_SYSCALLS) && defined(CONFIG_MMU)
 54         struct io_madvise *ma = io_kiocb_to_cm     52         struct io_madvise *ma = io_kiocb_to_cmd(req, struct io_madvise);
 55         int ret;                                   53         int ret;
 56                                                    54 
 57         WARN_ON_ONCE(issue_flags & IO_URING_F_     55         WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK);
 58                                                    56 
 59         ret = do_madvise(current->mm, ma->addr     57         ret = do_madvise(current->mm, ma->addr, ma->len, ma->advice);
 60         io_req_set_res(req, ret, 0);               58         io_req_set_res(req, ret, 0);
 61         return IOU_OK;                             59         return IOU_OK;
 62 #else                                              60 #else
 63         return -EOPNOTSUPP;                        61         return -EOPNOTSUPP;
 64 #endif                                             62 #endif
 65 }                                                  63 }
 66                                                    64 
 67 static bool io_fadvise_force_async(struct io_f     65 static bool io_fadvise_force_async(struct io_fadvise *fa)
 68 {                                                  66 {
 69         switch (fa->advice) {                      67         switch (fa->advice) {
 70         case POSIX_FADV_NORMAL:                    68         case POSIX_FADV_NORMAL:
 71         case POSIX_FADV_RANDOM:                    69         case POSIX_FADV_RANDOM:
 72         case POSIX_FADV_SEQUENTIAL:                70         case POSIX_FADV_SEQUENTIAL:
 73                 return false;                      71                 return false;
 74         default:                                   72         default:
 75                 return true;                       73                 return true;
 76         }                                          74         }
 77 }                                                  75 }
 78                                                    76 
 79 int io_fadvise_prep(struct io_kiocb *req, cons     77 int io_fadvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 80 {                                                  78 {
 81         struct io_fadvise *fa = io_kiocb_to_cm     79         struct io_fadvise *fa = io_kiocb_to_cmd(req, struct io_fadvise);
 82                                                    80 
 83         if (sqe->buf_index || sqe->splice_fd_i !!  81         if (sqe->buf_index || sqe->addr || sqe->splice_fd_in)
 84                 return -EINVAL;                    82                 return -EINVAL;
 85                                                    83 
 86         fa->offset = READ_ONCE(sqe->off);          84         fa->offset = READ_ONCE(sqe->off);
 87         fa->len = READ_ONCE(sqe->addr);        !!  85         fa->len = READ_ONCE(sqe->len);
 88         if (!fa->len)                          << 
 89                 fa->len = READ_ONCE(sqe->len); << 
 90         fa->advice = READ_ONCE(sqe->fadvise_ad     86         fa->advice = READ_ONCE(sqe->fadvise_advice);
 91         if (io_fadvise_force_async(fa))            87         if (io_fadvise_force_async(fa))
 92                 req->flags |= REQ_F_FORCE_ASYN     88                 req->flags |= REQ_F_FORCE_ASYNC;
 93         return 0;                                  89         return 0;
 94 }                                                  90 }
 95                                                    91 
 96 int io_fadvise(struct io_kiocb *req, unsigned      92 int io_fadvise(struct io_kiocb *req, unsigned int issue_flags)
 97 {                                                  93 {
 98         struct io_fadvise *fa = io_kiocb_to_cm     94         struct io_fadvise *fa = io_kiocb_to_cmd(req, struct io_fadvise);
 99         int ret;                                   95         int ret;
100                                                    96 
101         WARN_ON_ONCE(issue_flags & IO_URING_F_     97         WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK && io_fadvise_force_async(fa));
102                                                    98 
103         ret = vfs_fadvise(req->file, fa->offse     99         ret = vfs_fadvise(req->file, fa->offset, fa->len, fa->advice);
104         if (ret < 0)                              100         if (ret < 0)
105                 req_set_fail(req);                101                 req_set_fail(req);
106         io_req_set_res(req, ret, 0);              102         io_req_set_res(req, ret, 0);
107         return IOU_OK;                            103         return IOU_OK;
108 }                                                 104 }
109                                                   105 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php