diff options
Diffstat (limited to 'drivers/scsi/scsi_tgt_lib.c')
-rw-r--r-- | drivers/scsi/scsi_tgt_lib.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c index dc8781a68d7c..c05dff95bd95 100644 --- a/drivers/scsi/scsi_tgt_lib.c +++ b/drivers/scsi/scsi_tgt_lib.c | |||
@@ -459,6 +459,16 @@ static struct request *tgt_cmd_hash_lookup(struct request_queue *q, u64 tag) | |||
459 | return rq; | 459 | return rq; |
460 | } | 460 | } |
461 | 461 | ||
462 | static void scsi_tgt_build_sense(unsigned char *sense_buffer, unsigned char key, | ||
463 | unsigned char asc, unsigned char asq) | ||
464 | { | ||
465 | sense_buffer[0] = 0x70; | ||
466 | sense_buffer[2] = key; | ||
467 | sense_buffer[7] = 0xa; | ||
468 | sense_buffer[12] = asc; | ||
469 | sense_buffer[13] = asq; | ||
470 | } | ||
471 | |||
462 | int scsi_tgt_kspace_exec(int host_no, int result, u64 tag, | 472 | int scsi_tgt_kspace_exec(int host_no, int result, u64 tag, |
463 | unsigned long uaddr, u32 len, unsigned long sense_uaddr, | 473 | unsigned long uaddr, u32 len, unsigned long sense_uaddr, |
464 | u32 sense_len, u8 rw) | 474 | u32 sense_len, u8 rw) |
@@ -514,9 +524,16 @@ int scsi_tgt_kspace_exec(int host_no, int result, u64 tag, | |||
514 | if (len) { | 524 | if (len) { |
515 | err = scsi_map_user_pages(rq->end_io_data, cmd, uaddr, len, rw); | 525 | err = scsi_map_user_pages(rq->end_io_data, cmd, uaddr, len, rw); |
516 | if (err) { | 526 | if (err) { |
517 | eprintk("%p %d\n", cmd, err); | 527 | /* |
518 | err = -EAGAIN; | 528 | * user-space daemon bugs or OOM |
519 | goto done; | 529 | * TODO: we can do better for OOM. |
530 | */ | ||
531 | eprintk("cmd %p ret %d uaddr %lx len %d rw %d\n", | ||
532 | cmd, err, uaddr, len, rw); | ||
533 | cmd->result = SAM_STAT_CHECK_CONDITION; | ||
534 | memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); | ||
535 | scsi_tgt_build_sense(cmd->sense_buffer, | ||
536 | HARDWARE_ERROR, 0, 0); | ||
520 | } | 537 | } |
521 | } | 538 | } |
522 | err = scsi_tgt_transfer_response(cmd); | 539 | err = scsi_tgt_transfer_response(cmd); |