Skip to content

Commit fa8e36c

Browse files
committed
[SCSI] fix barrier failure issue
Currently, if the barrier command fails, the error return isn't seen by the block layer and it proceeds on regardless. The problem is that SCSI always returns no error for REQ_TYPE_BLOCK_PC ... it expects the submitter to pick the errors out of req->errors, which the block barrier functions don't do. Since it appears that the way SG_IO and scsi_execute_request() work they discard the block error return and always use req->errors, the best fix for this is to have the SCSI layer return an error to block if one actually occurred (this also allows us to filter out spurious errors, like deferred sense). This patch is a bug fix that will need backporting to stable, but it's also quite a big change and in need of testing, so we'll incubate in the main kernel tree and backport at the -rc2 or so stage if no problems turn up. Acked-by: Jens Axboe <jens.axboe@oracle.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
1 parent bfab163 commit fa8e36c

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎drivers/scsi/scsi_lib.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
839839
int this_count = scsi_bufflen(cmd);
840840
struct request_queue *q = cmd->device->request_queue;
841841
struct request *req = cmd->request;
842-
int clear_errors = 1;
842+
int error = 0;
843843
struct scsi_sense_hdr sshdr;
844844
int sense_valid = 0;
845845
int sense_deferred = 0;
@@ -853,7 +853,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
853853
if (blk_pc_request(req)) { /* SG_IO ioctl from block level */
854854
req->errors = result;
855855
if (result) {
856-
clear_errors = 0;
857856
if (sense_valid && req->sense) {
858857
/*
859858
* SG_IO wants current and deferred errors
@@ -865,6 +864,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
865864
memcpy(req->sense, cmd->sense_buffer, len);
866865
req->sense_len = len;
867866
}
867+
if (!sense_deferred)
868+
error = -EIO;
868869
}
869870
if (scsi_bidi_cmnd(cmd)) {
870871
/* will also release_buffers */
@@ -885,14 +886,11 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
885886
"%d bytes done.\n",
886887
req->nr_sectors, good_bytes));
887888

888-
if (clear_errors)
889-
req->errors = 0;
890-
891889
/* A number of bytes were successfully read. If there
892890
* are leftovers and there is some kind of error
893891
* (result != 0), retry the rest.
894892
*/
895-
if (scsi_end_request(cmd, 0, good_bytes, result == 0) == NULL)
893+
if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
896894
return;
897895

898896
/* good_bytes = 0, or (inclusive) there were leftovers and

0 commit comments

Comments
 (0)