summaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkfront.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-06-03 03:38:04 -0400
committerJens Axboe <axboe@fb.com>2017-06-09 11:27:32 -0400
commit2a842acab109f40f0d7d10b38e9ca88390628996 (patch)
treebdfc7a47fe655c2ea7a5f74127015d7a502042f0 /drivers/block/xen-blkfront.c
parent1be5690984588953e759af0a4c6ddac182a1806c (diff)
block: introduce new block status code type
Currently we use nornal Linux errno values in the block layer, and while we accept any error a few have overloaded magic meanings. This patch instead introduces a new blk_status_t value that holds block layer specific status codes and explicitly explains their meaning. Helpers to convert from and to the previous special meanings are provided for now, but I suspect we want to get rid of them in the long run - those drivers that have a errno input (e.g. networking) usually get errnos that don't know about the special block layer overloads, and similarly returning them to userspace will usually return somethings that strictly speaking isn't correct for file system operations, but that's left as an exercise for later. For now the set of errors is a very limited set that closely corresponds to the previous overloaded errno values, but there is some low hanging fruite to improve it. blk_status_t (ab)uses the sparse __bitwise annotations to allow for sparse typechecking, so that we can easily catch places passing the wrong values. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block/xen-blkfront.c')
-rw-r--r--drivers/block/xen-blkfront.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 39459631667c..aedc3c759273 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -1601,14 +1601,18 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
1601 continue; 1601 continue;
1602 } 1602 }
1603 1603
1604 blkif_req(req)->error = (bret->status == BLKIF_RSP_OKAY) ? 0 : -EIO; 1604 if (bret->status == BLKIF_RSP_OKAY)
1605 blkif_req(req)->error = BLK_STS_OK;
1606 else
1607 blkif_req(req)->error = BLK_STS_IOERR;
1608
1605 switch (bret->operation) { 1609 switch (bret->operation) {
1606 case BLKIF_OP_DISCARD: 1610 case BLKIF_OP_DISCARD:
1607 if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) { 1611 if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) {
1608 struct request_queue *rq = info->rq; 1612 struct request_queue *rq = info->rq;
1609 printk(KERN_WARNING "blkfront: %s: %s op failed\n", 1613 printk(KERN_WARNING "blkfront: %s: %s op failed\n",
1610 info->gd->disk_name, op_name(bret->operation)); 1614 info->gd->disk_name, op_name(bret->operation));
1611 blkif_req(req)->error = -EOPNOTSUPP; 1615 blkif_req(req)->error = BLK_STS_NOTSUPP;
1612 info->feature_discard = 0; 1616 info->feature_discard = 0;
1613 info->feature_secdiscard = 0; 1617 info->feature_secdiscard = 0;
1614 queue_flag_clear(QUEUE_FLAG_DISCARD, rq); 1618 queue_flag_clear(QUEUE_FLAG_DISCARD, rq);
@@ -1626,11 +1630,11 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
1626 rinfo->shadow[id].req.u.rw.nr_segments == 0)) { 1630 rinfo->shadow[id].req.u.rw.nr_segments == 0)) {
1627 printk(KERN_WARNING "blkfront: %s: empty %s op failed\n", 1631 printk(KERN_WARNING "blkfront: %s: empty %s op failed\n",
1628 info->gd->disk_name, op_name(bret->operation)); 1632 info->gd->disk_name, op_name(bret->operation));
1629 blkif_req(req)->error = -EOPNOTSUPP; 1633 blkif_req(req)->error = BLK_STS_NOTSUPP;
1630 } 1634 }
1631 if (unlikely(blkif_req(req)->error)) { 1635 if (unlikely(blkif_req(req)->error)) {
1632 if (blkif_req(req)->error == -EOPNOTSUPP) 1636 if (blkif_req(req)->error == BLK_STS_NOTSUPP)
1633 blkif_req(req)->error = 0; 1637 blkif_req(req)->error = BLK_STS_OK;
1634 info->feature_fua = 0; 1638 info->feature_fua = 0;
1635 info->feature_flush = 0; 1639 info->feature_flush = 0;
1636 xlvbd_flush(info); 1640 xlvbd_flush(info);
@@ -2137,7 +2141,7 @@ static int blkfront_resume(struct xenbus_device *dev)
2137 merge_bio.tail = shadow[j].request->biotail; 2141 merge_bio.tail = shadow[j].request->biotail;
2138 bio_list_merge(&info->bio_list, &merge_bio); 2142 bio_list_merge(&info->bio_list, &merge_bio);
2139 shadow[j].request->bio = NULL; 2143 shadow[j].request->bio = NULL;
2140 blk_mq_end_request(shadow[j].request, 0); 2144 blk_mq_end_request(shadow[j].request, BLK_STS_OK);
2141 } 2145 }
2142 } 2146 }
2143 2147