aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/zvol.c
diff options
context:
space:
mode:
authorChunwei Chen <[email protected]>2015-12-08 12:37:24 -0800
committerBrian Behlendorf <[email protected]>2015-12-15 16:21:43 -0800
commit2727b9d3b63a938c1797d31378e6a5a1dcd43573 (patch)
treef85bd88b0ab3c09fecf27f39af6e736f8ae20815 /module/zfs/zvol.c
parent502923bb447cdf4f9bc1271a46dfc11d5e0f2e9b (diff)
Use uio for zvol_{read,write}
Since uio now supports bvec, we can convert bio into uio and reuse dmu_{read,write}_uio. This way, we can remove some duplicate code. Signed-off-by: Chunwei Chen <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #4078
Diffstat (limited to 'module/zfs/zvol.c')
-rw-r--r--module/zfs/zvol.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
index 574d3c306..8208d29f3 100644
--- a/module/zfs/zvol.c
+++ b/module/zfs/zvol.c
@@ -597,6 +597,7 @@ zvol_write(struct bio *bio)
int error = 0;
dmu_tx_t *tx;
rl_t *rl;
+ uio_t uio;
if (bio->bi_rw & VDEV_REQ_FLUSH)
zil_commit(zv->zv_zilog, ZVOL_OBJ);
@@ -607,6 +608,14 @@ zvol_write(struct bio *bio)
if (size == 0)
goto out;
+ uio.uio_bvec = &bio->bi_io_vec[BIO_BI_IDX(bio)];
+ uio.uio_skip = BIO_BI_SKIP(bio);
+ uio.uio_resid = size;
+ uio.uio_iovcnt = bio->bi_vcnt - BIO_BI_IDX(bio);
+ uio.uio_loffset = offset;
+ uio.uio_limit = MAXOFFSET_T;
+ uio.uio_segflg = UIO_BVEC;
+
rl = zfs_range_lock(&zv->zv_znode, offset, size, RL_WRITER);
tx = dmu_tx_create(zv->zv_objset);
@@ -620,7 +629,7 @@ zvol_write(struct bio *bio)
goto out;
}
- error = dmu_write_bio(zv->zv_objset, ZVOL_OBJ, bio, tx);
+ error = dmu_write_uio(zv->zv_objset, ZVOL_OBJ, &uio, size, tx);
if (error == 0)
zvol_log_write(zv, tx, offset, size,
!!(bio->bi_rw & VDEV_REQ_FUA));
@@ -686,17 +695,25 @@ zvol_read(struct bio *bio)
{
zvol_state_t *zv = bio->bi_bdev->bd_disk->private_data;
uint64_t offset = BIO_BI_SECTOR(bio) << 9;
- uint64_t len = BIO_BI_SIZE(bio);
+ uint64_t size = BIO_BI_SIZE(bio);
int error;
rl_t *rl;
+ uio_t uio;
- if (len == 0)
+ if (size == 0)
return (0);
+ uio.uio_bvec = &bio->bi_io_vec[BIO_BI_IDX(bio)];
+ uio.uio_skip = BIO_BI_SKIP(bio);
+ uio.uio_resid = size;
+ uio.uio_iovcnt = bio->bi_vcnt - BIO_BI_IDX(bio);
+ uio.uio_loffset = offset;
+ uio.uio_limit = MAXOFFSET_T;
+ uio.uio_segflg = UIO_BVEC;
- rl = zfs_range_lock(&zv->zv_znode, offset, len, RL_READER);
+ rl = zfs_range_lock(&zv->zv_znode, offset, size, RL_READER);
- error = dmu_read_bio(zv->zv_objset, ZVOL_OBJ, bio);
+ error = dmu_read_uio(zv->zv_objset, ZVOL_OBJ, &uio, size);
zfs_range_unlock(rl);