Skip to content

Commit 4f4eeba

Browse files
Bijan Mottahedehaxboe
authored andcommitted
io_uring: don't use kiocb.private to store buf_index
kiocb.private is used in iomap_dio_rw() so store buf_index separately. Signed-off-by: Bijan Mottahedeh <[email protected]> Move 'buf_index' to a hole in io_kiocb. Signed-off-by: Jens Axboe <[email protected]>
1 parent e3aabf9 commit 4f4eeba

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/io_uring.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,8 @@ struct io_kiocb {
619619
bool needs_fixed_file;
620620
u8 opcode;
621621

622+
u16 buf_index;
623+
622624
struct io_ring_ctx *ctx;
623625
struct list_head list;
624626
unsigned int flags;
@@ -2101,9 +2103,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
21012103

21022104
req->rw.addr = READ_ONCE(sqe->addr);
21032105
req->rw.len = READ_ONCE(sqe->len);
2104-
/* we own ->private, reuse it for the buffer index / buffer ID */
2105-
req->rw.kiocb.private = (void *) (unsigned long)
2106-
READ_ONCE(sqe->buf_index);
2106+
req->buf_index = READ_ONCE(sqe->buf_index);
21072107
return 0;
21082108
}
21092109

@@ -2146,15 +2146,15 @@ static ssize_t io_import_fixed(struct io_kiocb *req, int rw,
21462146
struct io_ring_ctx *ctx = req->ctx;
21472147
size_t len = req->rw.len;
21482148
struct io_mapped_ubuf *imu;
2149-
unsigned index, buf_index;
2149+
u16 index, buf_index;
21502150
size_t offset;
21512151
u64 buf_addr;
21522152

21532153
/* attempt to use fixed buffers without having provided iovecs */
21542154
if (unlikely(!ctx->user_bufs))
21552155
return -EFAULT;
21562156

2157-
buf_index = (unsigned long) req->rw.kiocb.private;
2157+
buf_index = req->buf_index;
21582158
if (unlikely(buf_index >= ctx->nr_user_bufs))
21592159
return -EFAULT;
21602160

@@ -2270,10 +2270,10 @@ static void __user *io_rw_buffer_select(struct io_kiocb *req, size_t *len,
22702270
bool needs_lock)
22712271
{
22722272
struct io_buffer *kbuf;
2273-
int bgid;
2273+
u16 bgid;
22742274

22752275
kbuf = (struct io_buffer *) (unsigned long) req->rw.addr;
2276-
bgid = (int) (unsigned long) req->rw.kiocb.private;
2276+
bgid = req->buf_index;
22772277
kbuf = io_buffer_select(req, len, bgid, kbuf, needs_lock);
22782278
if (IS_ERR(kbuf))
22792279
return kbuf;
@@ -2364,7 +2364,7 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
23642364
}
23652365

23662366
/* buffer index only valid with fixed read/write, or buffer select */
2367-
if (req->rw.kiocb.private && !(req->flags & REQ_F_BUFFER_SELECT))
2367+
if (req->buf_index && !(req->flags & REQ_F_BUFFER_SELECT))
23682368
return -EINVAL;
23692369

23702370
if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE) {

0 commit comments

Comments
 (0)