From: "Michael S. Tsirkin" <mst@redhat.com>
To: kernel test robot <lkp@intel.com>
Cc: Max Gurtovoy <mgurtovoy@nvidia.com>,
Feng Li <lifeng1519@gmail.com>,
kbuild-all@lists.01.org, kvm@vger.kernel.org,
Israel Rukshin <israelr@nvidia.com>,
netdev@vger.kernel.org,
virtualization@lists.linux-foundation.org,
Stefan Hajnoczi <stefanha@redhat.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [mst-vhost:vhost 4/47] drivers/block/virtio_blk.c:238:24: sparse: sparse: incorrect type in return expression (different base types)
Date: Mon, 25 Oct 2021 03:59:07 -0400 [thread overview]
Message-ID: <20211025034645-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <202110251506.OFYmNDFp-lkp@intel.com>
On Mon, Oct 25, 2021 at 03:24:16PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
> head: 2b109044b081148b58974f5696ffd4383c3e9abb
> commit: b2c5221fd074fbb0e57d6707bed5b7386bf430ed [4/47] virtio-blk: avoid preallocating big SGL for data
> config: i386-randconfig-s001-20211025 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce:
> # apt-get install sparse
> # sparse version: v0.6.4-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git/commit/?id=b2c5221fd074fbb0e57d6707bed5b7386bf430ed
> git remote add mst-vhost https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git
> git fetch --no-tags mst-vhost vhost
> git checkout b2c5221fd074fbb0e57d6707bed5b7386bf430ed
> # save the attached .config to linux build tree
> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
Patch sent. Max can you take a look pls?
>
> sparse warnings: (new ones prefixed by >>)
> >> drivers/block/virtio_blk.c:238:24: sparse: sparse: incorrect type in return expression (different base types) @@ expected int @@ got restricted blk_status_t [usertype] @@
> drivers/block/virtio_blk.c:238:24: sparse: expected int
> drivers/block/virtio_blk.c:238:24: sparse: got restricted blk_status_t [usertype]
> drivers/block/virtio_blk.c:246:32: sparse: sparse: incorrect type in return expression (different base types) @@ expected int @@ got restricted blk_status_t [usertype] @@
> drivers/block/virtio_blk.c:246:32: sparse: expected int
> drivers/block/virtio_blk.c:246:32: sparse: got restricted blk_status_t [usertype]
> >> drivers/block/virtio_blk.c:320:24: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted blk_status_t @@ got int [assigned] err @@
> drivers/block/virtio_blk.c:320:24: sparse: expected restricted blk_status_t
> drivers/block/virtio_blk.c:320:24: sparse: got int [assigned] err
>
> vim +238 drivers/block/virtio_blk.c
>
> 203
> 204 static int virtblk_setup_cmd(struct virtio_device *vdev, struct request *req,
> 205 struct virtblk_req *vbr)
> 206 {
> 207 bool unmap = false;
> 208 u32 type;
> 209
> 210 vbr->out_hdr.sector = 0;
> 211
> 212 switch (req_op(req)) {
> 213 case REQ_OP_READ:
> 214 type = VIRTIO_BLK_T_IN;
> 215 vbr->out_hdr.sector = cpu_to_virtio64(vdev,
> 216 blk_rq_pos(req));
> 217 break;
> 218 case REQ_OP_WRITE:
> 219 type = VIRTIO_BLK_T_OUT;
> 220 vbr->out_hdr.sector = cpu_to_virtio64(vdev,
> 221 blk_rq_pos(req));
> 222 break;
> 223 case REQ_OP_FLUSH:
> 224 type = VIRTIO_BLK_T_FLUSH;
> 225 break;
> 226 case REQ_OP_DISCARD:
> 227 type = VIRTIO_BLK_T_DISCARD;
> 228 break;
> 229 case REQ_OP_WRITE_ZEROES:
> 230 type = VIRTIO_BLK_T_WRITE_ZEROES;
> 231 unmap = !(req->cmd_flags & REQ_NOUNMAP);
> 232 break;
> 233 case REQ_OP_DRV_IN:
> 234 type = VIRTIO_BLK_T_GET_ID;
> 235 break;
> 236 default:
> 237 WARN_ON_ONCE(1);
> > 238 return BLK_STS_IOERR;
> 239 }
> 240
> 241 vbr->out_hdr.type = cpu_to_virtio32(vdev, type);
> 242 vbr->out_hdr.ioprio = cpu_to_virtio32(vdev, req_get_ioprio(req));
> 243
> 244 if (type == VIRTIO_BLK_T_DISCARD || type == VIRTIO_BLK_T_WRITE_ZEROES) {
> 245 if (virtblk_setup_discard_write_zeroes(req, unmap))
> 246 return BLK_STS_RESOURCE;
> 247 }
> 248
> 249 return 0;
> 250 }
> 251
> 252 static inline void virtblk_request_done(struct request *req)
> 253 {
> 254 struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
> 255
> 256 virtblk_unmap_data(req, vbr);
> 257 virtblk_cleanup_cmd(req);
> 258 blk_mq_end_request(req, virtblk_result(vbr));
> 259 }
> 260
> 261 static void virtblk_done(struct virtqueue *vq)
> 262 {
> 263 struct virtio_blk *vblk = vq->vdev->priv;
> 264 bool req_done = false;
> 265 int qid = vq->index;
> 266 struct virtblk_req *vbr;
> 267 unsigned long flags;
> 268 unsigned int len;
> 269
> 270 spin_lock_irqsave(&vblk->vqs[qid].lock, flags);
> 271 do {
> 272 virtqueue_disable_cb(vq);
> 273 while ((vbr = virtqueue_get_buf(vblk->vqs[qid].vq, &len)) != NULL) {
> 274 struct request *req = blk_mq_rq_from_pdu(vbr);
> 275
> 276 if (likely(!blk_should_fake_timeout(req->q)))
> 277 blk_mq_complete_request(req);
> 278 req_done = true;
> 279 }
> 280 if (unlikely(virtqueue_is_broken(vq)))
> 281 break;
> 282 } while (!virtqueue_enable_cb(vq));
> 283
> 284 /* In case queue is stopped waiting for more buffers. */
> 285 if (req_done)
> 286 blk_mq_start_stopped_hw_queues(vblk->disk->queue, true);
> 287 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
> 288 }
> 289
> 290 static void virtio_commit_rqs(struct blk_mq_hw_ctx *hctx)
> 291 {
> 292 struct virtio_blk *vblk = hctx->queue->queuedata;
> 293 struct virtio_blk_vq *vq = &vblk->vqs[hctx->queue_num];
> 294 bool kick;
> 295
> 296 spin_lock_irq(&vq->lock);
> 297 kick = virtqueue_kick_prepare(vq->vq);
> 298 spin_unlock_irq(&vq->lock);
> 299
> 300 if (kick)
> 301 virtqueue_notify(vq->vq);
> 302 }
> 303
> 304 static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
> 305 const struct blk_mq_queue_data *bd)
> 306 {
> 307 struct virtio_blk *vblk = hctx->queue->queuedata;
> 308 struct request *req = bd->rq;
> 309 struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
> 310 unsigned long flags;
> 311 unsigned int num;
> 312 int qid = hctx->queue_num;
> 313 int err;
> 314 bool notify = false;
> 315
> 316 BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
> 317
> 318 err = virtblk_setup_cmd(vblk->vdev, req, vbr);
> 319 if (unlikely(err))
> > 320 return err;
> 321
> 322 blk_mq_start_request(req);
> 323
> 324 num = virtblk_map_data(hctx, req, vbr);
> 325 if (unlikely(num < 0)) {
> 326 virtblk_cleanup_cmd(req);
> 327 return BLK_STS_RESOURCE;
> 328 }
> 329
> 330 spin_lock_irqsave(&vblk->vqs[qid].lock, flags);
> 331 err = virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg_table.sgl, num);
> 332 if (err) {
> 333 virtqueue_kick(vblk->vqs[qid].vq);
> 334 /* Don't stop the queue if -ENOMEM: we may have failed to
> 335 * bounce the buffer due to global resource outage.
> 336 */
> 337 if (err == -ENOSPC)
> 338 blk_mq_stop_hw_queue(hctx);
> 339 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
> 340 virtblk_unmap_data(req, vbr);
> 341 virtblk_cleanup_cmd(req);
> 342 switch (err) {
> 343 case -ENOSPC:
> 344 return BLK_STS_DEV_RESOURCE;
> 345 case -ENOMEM:
> 346 return BLK_STS_RESOURCE;
> 347 default:
> 348 return BLK_STS_IOERR;
> 349 }
> 350 }
> 351
> 352 if (bd->last && virtqueue_kick_prepare(vblk->vqs[qid].vq))
> 353 notify = true;
> 354 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
> 355
> 356 if (notify)
> 357 virtqueue_notify(vblk->vqs[qid].vq);
> 358 return BLK_STS_OK;
> 359 }
> 360
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: kernel test robot <lkp@intel.com>
Cc: Max Gurtovoy <mgurtovoy@nvidia.com>,
kbuild-all@lists.01.org, kvm@vger.kernel.org,
virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, Israel Rukshin <israelr@nvidia.com>,
Feng Li <lifeng1519@gmail.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [mst-vhost:vhost 4/47] drivers/block/virtio_blk.c:238:24: sparse: sparse: incorrect type in return expression (different base types)
Date: Mon, 25 Oct 2021 03:59:07 -0400 [thread overview]
Message-ID: <20211025034645-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <202110251506.OFYmNDFp-lkp@intel.com>
On Mon, Oct 25, 2021 at 03:24:16PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
> head: 2b109044b081148b58974f5696ffd4383c3e9abb
> commit: b2c5221fd074fbb0e57d6707bed5b7386bf430ed [4/47] virtio-blk: avoid preallocating big SGL for data
> config: i386-randconfig-s001-20211025 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce:
> # apt-get install sparse
> # sparse version: v0.6.4-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git/commit/?id=b2c5221fd074fbb0e57d6707bed5b7386bf430ed
> git remote add mst-vhost https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git
> git fetch --no-tags mst-vhost vhost
> git checkout b2c5221fd074fbb0e57d6707bed5b7386bf430ed
> # save the attached .config to linux build tree
> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
Patch sent. Max can you take a look pls?
>
> sparse warnings: (new ones prefixed by >>)
> >> drivers/block/virtio_blk.c:238:24: sparse: sparse: incorrect type in return expression (different base types) @@ expected int @@ got restricted blk_status_t [usertype] @@
> drivers/block/virtio_blk.c:238:24: sparse: expected int
> drivers/block/virtio_blk.c:238:24: sparse: got restricted blk_status_t [usertype]
> drivers/block/virtio_blk.c:246:32: sparse: sparse: incorrect type in return expression (different base types) @@ expected int @@ got restricted blk_status_t [usertype] @@
> drivers/block/virtio_blk.c:246:32: sparse: expected int
> drivers/block/virtio_blk.c:246:32: sparse: got restricted blk_status_t [usertype]
> >> drivers/block/virtio_blk.c:320:24: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted blk_status_t @@ got int [assigned] err @@
> drivers/block/virtio_blk.c:320:24: sparse: expected restricted blk_status_t
> drivers/block/virtio_blk.c:320:24: sparse: got int [assigned] err
>
> vim +238 drivers/block/virtio_blk.c
>
> 203
> 204 static int virtblk_setup_cmd(struct virtio_device *vdev, struct request *req,
> 205 struct virtblk_req *vbr)
> 206 {
> 207 bool unmap = false;
> 208 u32 type;
> 209
> 210 vbr->out_hdr.sector = 0;
> 211
> 212 switch (req_op(req)) {
> 213 case REQ_OP_READ:
> 214 type = VIRTIO_BLK_T_IN;
> 215 vbr->out_hdr.sector = cpu_to_virtio64(vdev,
> 216 blk_rq_pos(req));
> 217 break;
> 218 case REQ_OP_WRITE:
> 219 type = VIRTIO_BLK_T_OUT;
> 220 vbr->out_hdr.sector = cpu_to_virtio64(vdev,
> 221 blk_rq_pos(req));
> 222 break;
> 223 case REQ_OP_FLUSH:
> 224 type = VIRTIO_BLK_T_FLUSH;
> 225 break;
> 226 case REQ_OP_DISCARD:
> 227 type = VIRTIO_BLK_T_DISCARD;
> 228 break;
> 229 case REQ_OP_WRITE_ZEROES:
> 230 type = VIRTIO_BLK_T_WRITE_ZEROES;
> 231 unmap = !(req->cmd_flags & REQ_NOUNMAP);
> 232 break;
> 233 case REQ_OP_DRV_IN:
> 234 type = VIRTIO_BLK_T_GET_ID;
> 235 break;
> 236 default:
> 237 WARN_ON_ONCE(1);
> > 238 return BLK_STS_IOERR;
> 239 }
> 240
> 241 vbr->out_hdr.type = cpu_to_virtio32(vdev, type);
> 242 vbr->out_hdr.ioprio = cpu_to_virtio32(vdev, req_get_ioprio(req));
> 243
> 244 if (type == VIRTIO_BLK_T_DISCARD || type == VIRTIO_BLK_T_WRITE_ZEROES) {
> 245 if (virtblk_setup_discard_write_zeroes(req, unmap))
> 246 return BLK_STS_RESOURCE;
> 247 }
> 248
> 249 return 0;
> 250 }
> 251
> 252 static inline void virtblk_request_done(struct request *req)
> 253 {
> 254 struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
> 255
> 256 virtblk_unmap_data(req, vbr);
> 257 virtblk_cleanup_cmd(req);
> 258 blk_mq_end_request(req, virtblk_result(vbr));
> 259 }
> 260
> 261 static void virtblk_done(struct virtqueue *vq)
> 262 {
> 263 struct virtio_blk *vblk = vq->vdev->priv;
> 264 bool req_done = false;
> 265 int qid = vq->index;
> 266 struct virtblk_req *vbr;
> 267 unsigned long flags;
> 268 unsigned int len;
> 269
> 270 spin_lock_irqsave(&vblk->vqs[qid].lock, flags);
> 271 do {
> 272 virtqueue_disable_cb(vq);
> 273 while ((vbr = virtqueue_get_buf(vblk->vqs[qid].vq, &len)) != NULL) {
> 274 struct request *req = blk_mq_rq_from_pdu(vbr);
> 275
> 276 if (likely(!blk_should_fake_timeout(req->q)))
> 277 blk_mq_complete_request(req);
> 278 req_done = true;
> 279 }
> 280 if (unlikely(virtqueue_is_broken(vq)))
> 281 break;
> 282 } while (!virtqueue_enable_cb(vq));
> 283
> 284 /* In case queue is stopped waiting for more buffers. */
> 285 if (req_done)
> 286 blk_mq_start_stopped_hw_queues(vblk->disk->queue, true);
> 287 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
> 288 }
> 289
> 290 static void virtio_commit_rqs(struct blk_mq_hw_ctx *hctx)
> 291 {
> 292 struct virtio_blk *vblk = hctx->queue->queuedata;
> 293 struct virtio_blk_vq *vq = &vblk->vqs[hctx->queue_num];
> 294 bool kick;
> 295
> 296 spin_lock_irq(&vq->lock);
> 297 kick = virtqueue_kick_prepare(vq->vq);
> 298 spin_unlock_irq(&vq->lock);
> 299
> 300 if (kick)
> 301 virtqueue_notify(vq->vq);
> 302 }
> 303
> 304 static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
> 305 const struct blk_mq_queue_data *bd)
> 306 {
> 307 struct virtio_blk *vblk = hctx->queue->queuedata;
> 308 struct request *req = bd->rq;
> 309 struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
> 310 unsigned long flags;
> 311 unsigned int num;
> 312 int qid = hctx->queue_num;
> 313 int err;
> 314 bool notify = false;
> 315
> 316 BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
> 317
> 318 err = virtblk_setup_cmd(vblk->vdev, req, vbr);
> 319 if (unlikely(err))
> > 320 return err;
> 321
> 322 blk_mq_start_request(req);
> 323
> 324 num = virtblk_map_data(hctx, req, vbr);
> 325 if (unlikely(num < 0)) {
> 326 virtblk_cleanup_cmd(req);
> 327 return BLK_STS_RESOURCE;
> 328 }
> 329
> 330 spin_lock_irqsave(&vblk->vqs[qid].lock, flags);
> 331 err = virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg_table.sgl, num);
> 332 if (err) {
> 333 virtqueue_kick(vblk->vqs[qid].vq);
> 334 /* Don't stop the queue if -ENOMEM: we may have failed to
> 335 * bounce the buffer due to global resource outage.
> 336 */
> 337 if (err == -ENOSPC)
> 338 blk_mq_stop_hw_queue(hctx);
> 339 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
> 340 virtblk_unmap_data(req, vbr);
> 341 virtblk_cleanup_cmd(req);
> 342 switch (err) {
> 343 case -ENOSPC:
> 344 return BLK_STS_DEV_RESOURCE;
> 345 case -ENOMEM:
> 346 return BLK_STS_RESOURCE;
> 347 default:
> 348 return BLK_STS_IOERR;
> 349 }
> 350 }
> 351
> 352 if (bd->last && virtqueue_kick_prepare(vblk->vqs[qid].vq))
> 353 notify = true;
> 354 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
> 355
> 356 if (notify)
> 357 virtqueue_notify(vblk->vqs[qid].vq);
> 358 return BLK_STS_OK;
> 359 }
> 360
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
WARNING: multiple messages have this Message-ID (diff)
From: Michael S. Tsirkin <mst@redhat.com>
To: kbuild-all@lists.01.org
Subject: Re: [mst-vhost:vhost 4/47] drivers/block/virtio_blk.c:238:24: sparse: sparse: incorrect type in return expression (different base types)
Date: Mon, 25 Oct 2021 03:59:07 -0400 [thread overview]
Message-ID: <20211025034645-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <202110251506.OFYmNDFp-lkp@intel.com>
[-- Attachment #1: Type: text/plain, Size: 7879 bytes --]
On Mon, Oct 25, 2021 at 03:24:16PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
> head: 2b109044b081148b58974f5696ffd4383c3e9abb
> commit: b2c5221fd074fbb0e57d6707bed5b7386bf430ed [4/47] virtio-blk: avoid preallocating big SGL for data
> config: i386-randconfig-s001-20211025 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce:
> # apt-get install sparse
> # sparse version: v0.6.4-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git/commit/?id=b2c5221fd074fbb0e57d6707bed5b7386bf430ed
> git remote add mst-vhost https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git
> git fetch --no-tags mst-vhost vhost
> git checkout b2c5221fd074fbb0e57d6707bed5b7386bf430ed
> # save the attached .config to linux build tree
> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
Patch sent. Max can you take a look pls?
>
> sparse warnings: (new ones prefixed by >>)
> >> drivers/block/virtio_blk.c:238:24: sparse: sparse: incorrect type in return expression (different base types) @@ expected int @@ got restricted blk_status_t [usertype] @@
> drivers/block/virtio_blk.c:238:24: sparse: expected int
> drivers/block/virtio_blk.c:238:24: sparse: got restricted blk_status_t [usertype]
> drivers/block/virtio_blk.c:246:32: sparse: sparse: incorrect type in return expression (different base types) @@ expected int @@ got restricted blk_status_t [usertype] @@
> drivers/block/virtio_blk.c:246:32: sparse: expected int
> drivers/block/virtio_blk.c:246:32: sparse: got restricted blk_status_t [usertype]
> >> drivers/block/virtio_blk.c:320:24: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted blk_status_t @@ got int [assigned] err @@
> drivers/block/virtio_blk.c:320:24: sparse: expected restricted blk_status_t
> drivers/block/virtio_blk.c:320:24: sparse: got int [assigned] err
>
> vim +238 drivers/block/virtio_blk.c
>
> 203
> 204 static int virtblk_setup_cmd(struct virtio_device *vdev, struct request *req,
> 205 struct virtblk_req *vbr)
> 206 {
> 207 bool unmap = false;
> 208 u32 type;
> 209
> 210 vbr->out_hdr.sector = 0;
> 211
> 212 switch (req_op(req)) {
> 213 case REQ_OP_READ:
> 214 type = VIRTIO_BLK_T_IN;
> 215 vbr->out_hdr.sector = cpu_to_virtio64(vdev,
> 216 blk_rq_pos(req));
> 217 break;
> 218 case REQ_OP_WRITE:
> 219 type = VIRTIO_BLK_T_OUT;
> 220 vbr->out_hdr.sector = cpu_to_virtio64(vdev,
> 221 blk_rq_pos(req));
> 222 break;
> 223 case REQ_OP_FLUSH:
> 224 type = VIRTIO_BLK_T_FLUSH;
> 225 break;
> 226 case REQ_OP_DISCARD:
> 227 type = VIRTIO_BLK_T_DISCARD;
> 228 break;
> 229 case REQ_OP_WRITE_ZEROES:
> 230 type = VIRTIO_BLK_T_WRITE_ZEROES;
> 231 unmap = !(req->cmd_flags & REQ_NOUNMAP);
> 232 break;
> 233 case REQ_OP_DRV_IN:
> 234 type = VIRTIO_BLK_T_GET_ID;
> 235 break;
> 236 default:
> 237 WARN_ON_ONCE(1);
> > 238 return BLK_STS_IOERR;
> 239 }
> 240
> 241 vbr->out_hdr.type = cpu_to_virtio32(vdev, type);
> 242 vbr->out_hdr.ioprio = cpu_to_virtio32(vdev, req_get_ioprio(req));
> 243
> 244 if (type == VIRTIO_BLK_T_DISCARD || type == VIRTIO_BLK_T_WRITE_ZEROES) {
> 245 if (virtblk_setup_discard_write_zeroes(req, unmap))
> 246 return BLK_STS_RESOURCE;
> 247 }
> 248
> 249 return 0;
> 250 }
> 251
> 252 static inline void virtblk_request_done(struct request *req)
> 253 {
> 254 struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
> 255
> 256 virtblk_unmap_data(req, vbr);
> 257 virtblk_cleanup_cmd(req);
> 258 blk_mq_end_request(req, virtblk_result(vbr));
> 259 }
> 260
> 261 static void virtblk_done(struct virtqueue *vq)
> 262 {
> 263 struct virtio_blk *vblk = vq->vdev->priv;
> 264 bool req_done = false;
> 265 int qid = vq->index;
> 266 struct virtblk_req *vbr;
> 267 unsigned long flags;
> 268 unsigned int len;
> 269
> 270 spin_lock_irqsave(&vblk->vqs[qid].lock, flags);
> 271 do {
> 272 virtqueue_disable_cb(vq);
> 273 while ((vbr = virtqueue_get_buf(vblk->vqs[qid].vq, &len)) != NULL) {
> 274 struct request *req = blk_mq_rq_from_pdu(vbr);
> 275
> 276 if (likely(!blk_should_fake_timeout(req->q)))
> 277 blk_mq_complete_request(req);
> 278 req_done = true;
> 279 }
> 280 if (unlikely(virtqueue_is_broken(vq)))
> 281 break;
> 282 } while (!virtqueue_enable_cb(vq));
> 283
> 284 /* In case queue is stopped waiting for more buffers. */
> 285 if (req_done)
> 286 blk_mq_start_stopped_hw_queues(vblk->disk->queue, true);
> 287 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
> 288 }
> 289
> 290 static void virtio_commit_rqs(struct blk_mq_hw_ctx *hctx)
> 291 {
> 292 struct virtio_blk *vblk = hctx->queue->queuedata;
> 293 struct virtio_blk_vq *vq = &vblk->vqs[hctx->queue_num];
> 294 bool kick;
> 295
> 296 spin_lock_irq(&vq->lock);
> 297 kick = virtqueue_kick_prepare(vq->vq);
> 298 spin_unlock_irq(&vq->lock);
> 299
> 300 if (kick)
> 301 virtqueue_notify(vq->vq);
> 302 }
> 303
> 304 static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
> 305 const struct blk_mq_queue_data *bd)
> 306 {
> 307 struct virtio_blk *vblk = hctx->queue->queuedata;
> 308 struct request *req = bd->rq;
> 309 struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
> 310 unsigned long flags;
> 311 unsigned int num;
> 312 int qid = hctx->queue_num;
> 313 int err;
> 314 bool notify = false;
> 315
> 316 BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
> 317
> 318 err = virtblk_setup_cmd(vblk->vdev, req, vbr);
> 319 if (unlikely(err))
> > 320 return err;
> 321
> 322 blk_mq_start_request(req);
> 323
> 324 num = virtblk_map_data(hctx, req, vbr);
> 325 if (unlikely(num < 0)) {
> 326 virtblk_cleanup_cmd(req);
> 327 return BLK_STS_RESOURCE;
> 328 }
> 329
> 330 spin_lock_irqsave(&vblk->vqs[qid].lock, flags);
> 331 err = virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg_table.sgl, num);
> 332 if (err) {
> 333 virtqueue_kick(vblk->vqs[qid].vq);
> 334 /* Don't stop the queue if -ENOMEM: we may have failed to
> 335 * bounce the buffer due to global resource outage.
> 336 */
> 337 if (err == -ENOSPC)
> 338 blk_mq_stop_hw_queue(hctx);
> 339 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
> 340 virtblk_unmap_data(req, vbr);
> 341 virtblk_cleanup_cmd(req);
> 342 switch (err) {
> 343 case -ENOSPC:
> 344 return BLK_STS_DEV_RESOURCE;
> 345 case -ENOMEM:
> 346 return BLK_STS_RESOURCE;
> 347 default:
> 348 return BLK_STS_IOERR;
> 349 }
> 350 }
> 351
> 352 if (bd->last && virtqueue_kick_prepare(vblk->vqs[qid].vq))
> 353 notify = true;
> 354 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
> 355
> 356 if (notify)
> 357 virtqueue_notify(vblk->vqs[qid].vq);
> 358 return BLK_STS_OK;
> 359 }
> 360
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
next prev parent reply other threads:[~2021-10-25 7:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 7:24 [mst-vhost:vhost 4/47] drivers/block/virtio_blk.c:238:24: sparse: sparse: incorrect type in return expression (different base types) kernel test robot
2021-10-25 7:24 ` kernel test robot
2021-10-25 7:24 ` kernel test robot
2021-10-25 7:59 ` Michael S. Tsirkin [this message]
2021-10-25 7:59 ` Michael S. Tsirkin
2021-10-25 7:59 ` Michael S. Tsirkin
2021-10-25 8:30 ` Max Gurtovoy
2021-10-25 8:30 ` Max Gurtovoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211025034645-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=hch@lst.de \
--cc=israelr@nvidia.com \
--cc=kbuild-all@lists.01.org \
--cc=kvm@vger.kernel.org \
--cc=lifeng1519@gmail.com \
--cc=lkp@intel.com \
--cc=mgurtovoy@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.