|
97 | 97 | #include "fs.h" |
98 | 98 | #include "splice.h" |
99 | 99 | #include "sync.h" |
| 100 | +#include "advise.h" |
100 | 101 |
|
101 | 102 | #define IORING_MAX_ENTRIES 32768 |
102 | 103 | #define IORING_MAX_CQ_ENTRIES (2 * IORING_MAX_ENTRIES) |
@@ -408,20 +409,6 @@ struct io_rsrc_update { |
408 | 409 | u32 offset; |
409 | 410 | }; |
410 | 411 |
|
411 | | -struct io_fadvise { |
412 | | - struct file *file; |
413 | | - u64 offset; |
414 | | - u32 len; |
415 | | - u32 advice; |
416 | | -}; |
417 | | - |
418 | | -struct io_madvise { |
419 | | - struct file *file; |
420 | | - u64 addr; |
421 | | - u32 len; |
422 | | - u32 advice; |
423 | | -}; |
424 | | - |
425 | 412 | struct io_epoll { |
426 | 413 | struct file *file; |
427 | 414 | int epfd; |
@@ -4428,76 +4415,6 @@ static int io_epoll_ctl(struct io_kiocb *req, unsigned int issue_flags) |
4428 | 4415 | #endif |
4429 | 4416 | } |
4430 | 4417 |
|
4431 | | -static int io_madvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) |
4432 | | -{ |
4433 | | -#if defined(CONFIG_ADVISE_SYSCALLS) && defined(CONFIG_MMU) |
4434 | | - struct io_madvise *ma = io_kiocb_to_cmd(req); |
4435 | | - |
4436 | | - if (sqe->buf_index || sqe->off || sqe->splice_fd_in) |
4437 | | - return -EINVAL; |
4438 | | - |
4439 | | - ma->addr = READ_ONCE(sqe->addr); |
4440 | | - ma->len = READ_ONCE(sqe->len); |
4441 | | - ma->advice = READ_ONCE(sqe->fadvise_advice); |
4442 | | - return 0; |
4443 | | -#else |
4444 | | - return -EOPNOTSUPP; |
4445 | | -#endif |
4446 | | -} |
4447 | | - |
4448 | | -static int io_madvise(struct io_kiocb *req, unsigned int issue_flags) |
4449 | | -{ |
4450 | | -#if defined(CONFIG_ADVISE_SYSCALLS) && defined(CONFIG_MMU) |
4451 | | - struct io_madvise *ma = io_kiocb_to_cmd(req); |
4452 | | - int ret; |
4453 | | - |
4454 | | - if (issue_flags & IO_URING_F_NONBLOCK) |
4455 | | - return -EAGAIN; |
4456 | | - |
4457 | | - ret = do_madvise(current->mm, ma->addr, ma->len, ma->advice); |
4458 | | - io_req_set_res(req, ret, 0); |
4459 | | - return IOU_OK; |
4460 | | -#else |
4461 | | - return -EOPNOTSUPP; |
4462 | | -#endif |
4463 | | -} |
4464 | | - |
4465 | | -static int io_fadvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) |
4466 | | -{ |
4467 | | - struct io_fadvise *fa = io_kiocb_to_cmd(req); |
4468 | | - |
4469 | | - if (sqe->buf_index || sqe->addr || sqe->splice_fd_in) |
4470 | | - return -EINVAL; |
4471 | | - |
4472 | | - fa->offset = READ_ONCE(sqe->off); |
4473 | | - fa->len = READ_ONCE(sqe->len); |
4474 | | - fa->advice = READ_ONCE(sqe->fadvise_advice); |
4475 | | - return 0; |
4476 | | -} |
4477 | | - |
4478 | | -static int io_fadvise(struct io_kiocb *req, unsigned int issue_flags) |
4479 | | -{ |
4480 | | - struct io_fadvise *fa = io_kiocb_to_cmd(req); |
4481 | | - int ret; |
4482 | | - |
4483 | | - if (issue_flags & IO_URING_F_NONBLOCK) { |
4484 | | - switch (fa->advice) { |
4485 | | - case POSIX_FADV_NORMAL: |
4486 | | - case POSIX_FADV_RANDOM: |
4487 | | - case POSIX_FADV_SEQUENTIAL: |
4488 | | - break; |
4489 | | - default: |
4490 | | - return -EAGAIN; |
4491 | | - } |
4492 | | - } |
4493 | | - |
4494 | | - ret = vfs_fadvise(req->file, fa->offset, fa->len, fa->advice); |
4495 | | - if (ret < 0) |
4496 | | - req_set_fail(req); |
4497 | | - io_req_set_res(req, ret, 0); |
4498 | | - return IOU_OK; |
4499 | | -} |
4500 | | - |
4501 | 4418 | static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) |
4502 | 4419 | { |
4503 | 4420 | struct io_statx *sx = io_kiocb_to_cmd(req); |
|
0 commit comments