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>
This commit is contained in:

committed by
Jens Axboe

parent
1be5690984
commit
2a842acab1
@@ -177,7 +177,7 @@ typedef struct sg_device { /* holds the state of each scsi generic device */
|
||||
} Sg_device;
|
||||
|
||||
/* tasklet or soft irq callback */
|
||||
static void sg_rq_end_io(struct request *rq, int uptodate);
|
||||
static void sg_rq_end_io(struct request *rq, blk_status_t status);
|
||||
static int sg_start_req(Sg_request *srp, unsigned char *cmd);
|
||||
static int sg_finish_rem_req(Sg_request * srp);
|
||||
static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size);
|
||||
@@ -808,7 +808,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
|
||||
if (atomic_read(&sdp->detaching)) {
|
||||
if (srp->bio) {
|
||||
scsi_req_free_cmd(scsi_req(srp->rq));
|
||||
blk_end_request_all(srp->rq, -EIO);
|
||||
blk_end_request_all(srp->rq, BLK_STS_IOERR);
|
||||
srp->rq = NULL;
|
||||
}
|
||||
|
||||
@@ -1300,7 +1300,7 @@ sg_rq_end_io_usercontext(struct work_struct *work)
|
||||
* level when a command is completed (or has failed).
|
||||
*/
|
||||
static void
|
||||
sg_rq_end_io(struct request *rq, int uptodate)
|
||||
sg_rq_end_io(struct request *rq, blk_status_t status)
|
||||
{
|
||||
struct sg_request *srp = rq->end_io_data;
|
||||
struct scsi_request *req = scsi_req(rq);
|
||||
|
Reference in New Issue
Block a user