Skip to content

Commit 9830f4b

Browse files
goldwynraxboe
authored andcommitted
fs: Use RWF_* flags for AIO operations
aio_rw_flags is introduced in struct iocb (using aio_reserved1) which will carry the RWF_* flags. We cannot use aio_flags because they are not checked for validity which may break existing applications. Note, the only place RWF_HIPRI comes in effect is dio_await_one(). All the rest of the locations, aio code return -EIOCBQUEUED before the checks for RWF_HIPRI. Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Goldwyn Rodrigues <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 7fc9e47 commit 9830f4b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

fs/aio.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
15411541
ssize_t ret;
15421542

15431543
/* enforce forwards compatibility on users */
1544-
if (unlikely(iocb->aio_reserved1 || iocb->aio_reserved2)) {
1544+
if (unlikely(iocb->aio_reserved2)) {
15451545
pr_debug("EINVAL: reserve field set\n");
15461546
return -EINVAL;
15471547
}
@@ -1586,6 +1586,12 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
15861586
req->common.ki_flags |= IOCB_EVENTFD;
15871587
}
15881588

1589+
ret = kiocb_set_rw_flags(&req->common, iocb->aio_rw_flags);
1590+
if (unlikely(ret)) {
1591+
pr_debug("EINVAL: aio_rw_flags\n");
1592+
goto out_put_req;
1593+
}
1594+
15891595
ret = put_user(KIOCB_KEY, &user_iocb->aio_key);
15901596
if (unlikely(ret)) {
15911597
pr_debug("EFAULT: aio_key\n");

include/uapi/linux/aio_abi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct io_event {
7979
struct iocb {
8080
/* these are internal to the kernel/libc. */
8181
__u64 aio_data; /* data to be returned in event's data */
82-
__u32 PADDED(aio_key, aio_reserved1);
82+
__u32 PADDED(aio_key, aio_rw_flags);
8383
/* the kernel sets aio_key to the req # */
8484

8585
/* common fields */

0 commit comments

Comments
 (0)