diff mbox series

[3/4] block_dev: support protect information passthrough

Message ID 20200226083719.4389-4-bob.liu@oracle.com (mailing list archive)
State New, archived
Headers show
Series userspace PI passthrough via io_uring | expand

Commit Message

Bob Liu Feb. 26, 2020, 8:37 a.m. UTC
Support protect information passed from use sapce, on direct io
is considered now.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
---
 fs/block_dev.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Darrick J. Wong Feb. 26, 2020, 4:04 p.m. UTC | #1
On Wed, Feb 26, 2020 at 04:37:18PM +0800, Bob Liu wrote:
> Support protect information passed from use sapce, on direct io
> is considered now.
> 
> Signed-off-by: Bob Liu <bob.liu@oracle.com>
> ---
>  fs/block_dev.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 69bf2fb..10e3299 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -348,6 +348,13 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
>  	loff_t pos = iocb->ki_pos;
>  	blk_qc_t qc = BLK_QC_T_NONE;
>  	int ret = 0;
> +	struct iovec *pi_iov;
> +
> +	if (iocb->ki_flags & IOCB_USE_PI) {
> +		ret = iter_slice_protect_info(iter, nr_pages, &pi_iov);
> +		if (ret)
> +			return -EINVAL;
> +	}
>  
>  	if ((pos | iov_iter_alignment(iter)) &
>  	    (bdev_logical_block_size(bdev) - 1))
> @@ -411,6 +418,16 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
>  				polled = true;
>  			}
>  
> +			/* Add protection information to bio */
> +			if (iocb->ki_flags & IOCB_USE_PI) {
> +				ret = bio_integrity_prep_from_iovec(bio, pi_iov);
> +				if (ret) {
> +					bio->bi_status = BLK_STS_IOERR;
> +					bio_endio(bio);

If you're just going to mash all the error codes into IOERR, then this
could very well become bio_io_error() ?

--D

> +					break;
> +				}
> +			}
> +
>  			qc = submit_bio(bio);
>  
>  			if (polled)
> -- 
> 2.9.5
>
diff mbox series

Patch

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 69bf2fb..10e3299 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -348,6 +348,13 @@  __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 	loff_t pos = iocb->ki_pos;
 	blk_qc_t qc = BLK_QC_T_NONE;
 	int ret = 0;
+	struct iovec *pi_iov;
+
+	if (iocb->ki_flags & IOCB_USE_PI) {
+		ret = iter_slice_protect_info(iter, nr_pages, &pi_iov);
+		if (ret)
+			return -EINVAL;
+	}
 
 	if ((pos | iov_iter_alignment(iter)) &
 	    (bdev_logical_block_size(bdev) - 1))
@@ -411,6 +418,16 @@  __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 				polled = true;
 			}
 
+			/* Add protection information to bio */
+			if (iocb->ki_flags & IOCB_USE_PI) {
+				ret = bio_integrity_prep_from_iovec(bio, pi_iov);
+				if (ret) {
+					bio->bi_status = BLK_STS_IOERR;
+					bio_endio(bio);
+					break;
+				}
+			}
+
 			qc = submit_bio(bio);
 
 			if (polled)