diff mbox

[2/2] fs: Add aio priority support for block_dev

Message ID 20180430165740.2842-3-adam.manzanares@wdc.com (mailing list archive)
State New, archived
Headers show

Commit Message

Adam Manzanares April 30, 2018, 4:57 p.m. UTC
From: Adam Manzanares <adam.manzanares@wdc.com>

When the IOCB_IOPRIO flag is set because the user supplied iocb
has the RWF_IOPRIO flag is set then we set the priority value of
the kiocb from the iocb.

When a bio is created for an aio request by the block dev we set the
priority value of the bio to the user supplied value.

Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com>
---
 fs/aio.c       | 9 +++++++++
 fs/block_dev.c | 1 +
 2 files changed, 10 insertions(+)

Comments

Christoph Hellwig May 2, 2018, 5:33 p.m. UTC | #1
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -1603,6 +1603,15 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
>  		goto out_put_req;
>  	}
>  
> +	if (req->common.ki_flags & IOCB_IOPRIO)
> +		/*
> +		 * The IOCB_IOPRIO flag is set when the user supplied iocb
> +		 * aio_rw_flag field has the RWF_IOPRIO flag set. If so,
> +		 * aio_reqprio is interpreted as a I/O scheduling class and
> +		 * priority.
> +		 */
> +		req->common.ki_ioprio = iocb->aio_reqprio;

Do we need any validation of the field here?

The only other thing I am a bit worried about is bloating struct kiocb
with a field for a relatively uncommon feature, but I can't really
see any much better way to pass it.
Adam Manzanares May 2, 2018, 6:07 p.m. UTC | #2
On 5/2/18 10:33 AM, Christoph Hellwig wrote:
>> --- a/fs/aio.c

>> +++ b/fs/aio.c

>> @@ -1603,6 +1603,15 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,

>>   		goto out_put_req;

>>   	}

>>   

>> +	if (req->common.ki_flags & IOCB_IOPRIO)

>> +		/*

>> +		 * The IOCB_IOPRIO flag is set when the user supplied iocb

>> +		 * aio_rw_flag field has the RWF_IOPRIO flag set. If so,

>> +		 * aio_reqprio is interpreted as a I/O scheduling class and

>> +		 * priority.

>> +		 */

>> +		req->common.ki_ioprio = iocb->aio_reqprio;

> 

> Do we need any validation of the field here?


With this patch the only consumer of the ki_ioprio field is a block 
device, which will eventually hit blk_init_request_from_bio where a
validation of the ioprio is hit.

I was hoping to get a simple patch in for the block device case and then
go back and look at other consumers of the kiocb and add ioprio support.
At that point it may be worth it to pull a check into this code.

> 

> The only other thing I am a bit worried about is bloating struct kiocb

> with a field for a relatively uncommon feature, but I can't really

> see any much better way to pass it.

> 


I'll look more closely at reusing existing fields for the next patch 
submission. I am hoping that the feature will be used more often given 
that WRR for NVME should be coming soon.

Thanks,
Adam
diff mbox

Patch

diff --git a/fs/aio.c b/fs/aio.c
index 88d7927ffbc6..47591f9e7ba3 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1603,6 +1603,15 @@  static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
 		goto out_put_req;
 	}
 
+	if (req->common.ki_flags & IOCB_IOPRIO)
+		/*
+		 * The IOCB_IOPRIO flag is set when the user supplied iocb
+		 * aio_rw_flag field has the RWF_IOPRIO flag set. If so,
+		 * aio_reqprio is interpreted as a I/O scheduling class and
+		 * priority.
+		 */
+		req->common.ki_ioprio = iocb->aio_reqprio;
+
 	ret = put_user(KIOCB_KEY, &user_iocb->aio_key);
 	if (unlikely(ret)) {
 		pr_debug("EFAULT: aio_key\n");
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 7ec920e27065..da1e94d2bb75 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -355,6 +355,7 @@  __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 		bio->bi_write_hint = iocb->ki_hint;
 		bio->bi_private = dio;
 		bio->bi_end_io = blkdev_bio_end_io;
+		bio->bi_ioprio = iocb->ki_ioprio;
 
 		ret = bio_iov_iter_get_pages(bio, iter);
 		if (unlikely(ret)) {