search for: virtblk_setup_discard_write_zeroes

Displaying 20 results from an estimated 21 matches for "virtblk_setup_discard_write_zeroes".

2018 Jun 06
10
[PATCH v6] virtio_blk: add DISCARD and WRIET ZEROES commands support
...irtio_blk.c index 4a07593c..5aabc63 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -172,10 +172,45 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } +static inline int virtblk_setup_discard_write_zeroes(struct request *req, + bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req); + unsigned short n = 0; + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + + range = kmalloc_array(segments, sizeof(*range), GFP_KERNEL); + if (!range) + return -ENOMEM; + + _...
2018 Jun 06
10
[PATCH v6] virtio_blk: add DISCARD and WRIET ZEROES commands support
...irtio_blk.c index 4a07593c..5aabc63 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -172,10 +172,45 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } +static inline int virtblk_setup_discard_write_zeroes(struct request *req, + bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req); + unsigned short n = 0; + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + + range = kmalloc_array(segments, sizeof(*range), GFP_KERNEL); + if (!range) + return -ENOMEM; + + _...
2018 Oct 15
3
[PATCH v8] virtio_blk: add discard and write zeroes support
...ather inefficient. Write zeroes really should use the same format as read and write. Second the unmap flag isn't properly specified at all, as nothing says the device may not unmap without the unmap flag. Please take a look at the SCSI or NVMe ?pec for some guidance. > +static inline int virtblk_setup_discard_write_zeroes(struct request *req, > + bool unmap) Why is this an inline function?
2020 Jul 30
0
[PATCH] virtio-blk: fix discard buffer overrun
...----- > 1 file changed, 18 insertions(+), 5 deletions(-) > > diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c > index 980df853ee49..248c8f46b51c 100644 > --- a/drivers/block/virtio_blk.c > +++ b/drivers/block/virtio_blk.c > @@ -130,12 +130,19 @@ static int virtblk_setup_discard_write_zeroes(struct request *req, bool unmap) > u64 sector = bio->bi_iter.bi_sector; > u32 num_sectors = bio->bi_iter.bi_size >> SECTOR_SHIFT; > > - range[n].flags = cpu_to_le32(flags); > - range[n].num_sectors = cpu_to_le32(num_sectors); > - range[n].sector = cpu_to_...
2018 Oct 15
3
[PATCH v8] virtio_blk: add discard and write zeroes support
...ather inefficient. Write zeroes really should use the same format as read and write. Second the unmap flag isn't properly specified at all, as nothing says the device may not unmap without the unmap flag. Please take a look at the SCSI or NVMe ?pec for some guidance. > +static inline int virtblk_setup_discard_write_zeroes(struct request *req, > + bool unmap) Why is this an inline function?
2018 Mar 30
2
[PATCH v3] virtio_blk: add DISCARD and WRIET ZEROES command support
...irtio_blk.c index 4a07593c..1943adb 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -172,10 +172,53 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } +static inline int virtblk_setup_discard_write_zeroes(struct request *req, bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req), n = 0; + u32 block_size = queue_logical_block_size(req->q); + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + + if (block_size < 512 || !block_size) + return -1; + + range = k...
2018 Mar 30
2
[PATCH v3] virtio_blk: add DISCARD and WRIET ZEROES command support
...irtio_blk.c index 4a07593c..1943adb 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -172,10 +172,53 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } +static inline int virtblk_setup_discard_write_zeroes(struct request *req, bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req), n = 0; + u32 block_size = queue_logical_block_size(req->q); + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + + if (block_size < 512 || !block_size) + return -1; + + range = k...
2018 Nov 01
1
[PATCH v9] virtio_blk: add discard and write zeroes support
...ISCARD_SEGMENTS 256u > > static int major; > static DEFINE_IDA(vd_index_ida); > @@ -172,10 +173,48 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, > return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); > } > > +static int virtblk_setup_discard_write_zeroes(struct request *req, bool unmap) > +{ > + unsigned short segments = blk_rq_nr_discard_segments(req); > + unsigned short n = 0; > + struct virtio_blk_discard_write_zeroes *range; > + struct bio *bio; > + u32 flags = 0; > + > + if (unmap) > + flags |= VIRTIO_BLK_WRITE_ZERO...
2018 Jun 07
2
[PATCH v6] virtio_blk: add DISCARD and WRIET ZEROES commands support
...type = VIRTIO_BLK_T_SCSI_CMD; > > @@ -256,6 +299,12 @@ static blk_status_t virtio_queue_rq(struct > blk_mq_hw_ctx *hctx, > > > > blk_mq_start_request(req); > > > > + if (type == VIRTIO_BLK_T_DISCARD || type == > VIRTIO_BLK_T_WRITE_ZEROES) { > > + err = virtblk_setup_discard_write_zeroes(req, unmap); > > + if (err) > > + return BLK_STS_RESOURCE; > > + } > > + > > num = blk_rq_map_sg(hctx->queue, req, vbr->sg); > > if (num) { > > if (rq_data_dir(req) == WRITE) > > ...since we still do blk_rq_map_sg() here and num shoul...
2018 Jun 07
2
[PATCH v6] virtio_blk: add DISCARD and WRIET ZEROES commands support
...type = VIRTIO_BLK_T_SCSI_CMD; > > @@ -256,6 +299,12 @@ static blk_status_t virtio_queue_rq(struct > blk_mq_hw_ctx *hctx, > > > > blk_mq_start_request(req); > > > > + if (type == VIRTIO_BLK_T_DISCARD || type == > VIRTIO_BLK_T_WRITE_ZEROES) { > > + err = virtblk_setup_discard_write_zeroes(req, unmap); > > + if (err) > > + return BLK_STS_RESOURCE; > > + } > > + > > num = blk_rq_map_sg(hctx->queue, req, vbr->sg); > > if (num) { > > if (rq_data_dir(req) == WRITE) > > ...since we still do blk_rq_map_sg() here and num shoul...
2018 Mar 30
0
[PATCH v3] virtio_blk: add DISCARD and WRIET ZEROES command support
...100644 > --- a/drivers/block/virtio_blk.c > +++ b/drivers/block/virtio_blk.c > @@ -172,10 +172,53 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, > return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); > } > > +static inline int virtblk_setup_discard_write_zeroes(struct request *req, bool unmap) > +{ > + unsigned short segments = blk_rq_nr_discard_segments(req), n = 0; Split on two lines pls: unsigned short n = 0; > + u32 block_size = queue_logical_block_size(req->q); Seems to be unused except for the sanity check below. Why? > + struct...
2018 Oct 12
0
[PATCH v8] virtio_blk: add discard and write zeroes support
...ne VQ_NAME_LEN 16 +#define MAX_DISCARD_SEGMENTS 256 static int major; static DEFINE_IDA(vd_index_ida); @@ -172,10 +173,50 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } + +static inline int virtblk_setup_discard_write_zeroes(struct request *req, + bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req); + unsigned short n = 0; + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + u32 flags = 0; + + if (unmap) + flags |= VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP; + + range = kmalloc_arr...
2018 Nov 01
0
[PATCH v9] virtio_blk: add discard and write zeroes support
...4 #define VQ_NAME_LEN 16 +#define MAX_DISCARD_SEGMENTS 256u static int major; static DEFINE_IDA(vd_index_ida); @@ -172,10 +173,48 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } +static int virtblk_setup_discard_write_zeroes(struct request *req, bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req); + unsigned short n = 0; + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + u32 flags = 0; + + if (unmap) + flags |= VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP; + + range = kmalloc_array(segm...
2018 May 29
0
[PATCH v5] virtio_blk: add DISCARD and WRIET ZEROES commands support
...irtio_blk.c index 4a07593c..a250fcc 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -172,10 +172,45 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } +static inline int virtblk_setup_discard_write_zeroes(struct request *req, + bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req); + unsigned short n = 0; + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + + range = kmalloc_array(segments, sizeof(*range), GFP_KERNEL); + if (!range) + return -ENOMEM; + + _...
2018 May 29
0
[PATCH v5] virtio_blk: add DISCARD and WRIET ZEROES commands support
...irtio_blk.c index 4a07593c..fabab2a 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -172,10 +172,45 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } +static inline int virtblk_setup_discard_write_zeroes(struct request *req, + bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req); + unsigned short n = 0; + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + + range = kmalloc_array(segments, sizeof(*range), GFP_KERNEL); + if (!range) + return -ENOMEM; + + _...
2018 Jun 11
1
[PATCH v6] virtio_blk: add DISCARD and WRIET ZEROES commands support
...blk_status_t virtio_queue_rq(struct > > > blk_mq_hw_ctx *hctx, > > > > > > > > blk_mq_start_request(req); > > > > > > > > + if (type == VIRTIO_BLK_T_DISCARD || type == > > > VIRTIO_BLK_T_WRITE_ZEROES) { > > > > + err = virtblk_setup_discard_write_zeroes(req, unmap); > > > > + if (err) > > > > + return BLK_STS_RESOURCE; > > > > + } > > > > + > > > > num = blk_rq_map_sg(hctx->queue, req, vbr->sg); > > > > if (num) { > > > > if (rq_data_dir(req) == WRI...
2018 May 29
2
[PATCH v4] virtio_blk: add DISCARD and WRIET ZEROES commands support
...irtio_blk.c index 4a07593c..a250fcc 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -172,10 +172,45 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } +static inline int virtblk_setup_discard_write_zeroes(struct request *req, + bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req); + unsigned short n = 0; + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + + range = kmalloc_array(segments, sizeof(*range), GFP_KERNEL); + if (!range) + return -ENOMEM; + + _...
2018 May 29
2
[PATCH v4] virtio_blk: add DISCARD and WRIET ZEROES commands support
...irtio_blk.c index 4a07593c..a250fcc 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -172,10 +172,45 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr, return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC); } +static inline int virtblk_setup_discard_write_zeroes(struct request *req, + bool unmap) +{ + unsigned short segments = blk_rq_nr_discard_segments(req); + unsigned short n = 0; + struct virtio_blk_discard_write_zeroes *range; + struct bio *bio; + + range = kmalloc_array(segments, sizeof(*range), GFP_KERNEL); + if (!range) + return -ENOMEM; + + _...
2018 Jun 07
0
[PATCH v6] virtio_blk: add DISCARD and WRIET ZEROES commands support
...> case REQ_OP_SCSI_OUT: > type = VIRTIO_BLK_T_SCSI_CMD; > @@ -256,6 +299,12 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx, > > blk_mq_start_request(req); > > + if (type == VIRTIO_BLK_T_DISCARD || type == VIRTIO_BLK_T_WRITE_ZEROES) { > + err = virtblk_setup_discard_write_zeroes(req, unmap); > + if (err) > + return BLK_STS_RESOURCE; > + } > + > num = blk_rq_map_sg(hctx->queue, req, vbr->sg); > if (num) { > if (rq_data_dir(req) == WRITE) ...since we still do blk_rq_map_sg() here and num should be != 0. -------------- next part ---------...
2018 Oct 15
0
[PATCH v8] virtio_blk: add discard and write zeroes support
...nt from the driver to indicate whether the device should attempt to keep storage allocated for the zeroed blocks, if that is indeed the intended behavior. Is there some in-kernel doc that describes what behavior the Linux block layer needs from a write zeroes command? > > +static inline int virtblk_setup_discard_write_zeroes(struct request *req, > > + bool unmap) > > Why is this an inline function? I don't think there's any reason it needs to be inline; I can drop the inline in the next revision. Given (as far as I can tell) your concerns seem to apply t...