if (err != cmd->bufflen) { scsi_tgt_sense_data_build(cmd, HARDWARE_ERROR, 0, 0); return TGT_CMD_FAILED; } else { cmd->result = SAM_STAT_GOOD; return TGT_CMD_COMPLETED; }
failed: scsi_tgt_sense_data_build(cmd, HARDWARE_ERROR, 0, 0); return TGT_CMD_FAILED;
static int tgt_vsd_queue(struct tgt_cmd *cmd){	struct scsi_tgt_cmd *scmd = tgt_cmd_to_scsi(cmd);	struct tgt_device *device = cmd->device;	loff_t pos = cmd->offset;	int err = 0, rw;	if (cmd->bufflen + pos > device->size) {		scsi_tgt_sense_data_build(cmd, HARDWARE_ERROR, 0, 0);		return TGT_CMD_FAILED;	}	switch (scmd->scb[0]) {	case READ_6:	case READ_10:	case READ_16:		rw = READ;		break;	case WRITE_6:	case WRITE_10:	case WRITE_16:	case WRITE_VERIFY:		rw = WRITE;		break;	default:		err = tgt_uspace_cmd_send(cmd);		/*		 * successfully queued		 */		if (err >= 0)			return TGT_CMD_USPACE_QUEUED;		scsi_tgt_sense_data_build(cmd, HARDWARE_ERROR, 0, 0);		return TGT_CMD_FAILED;	};	/*	 * TODO this will become device->io_handler->queue_cmd	 * when we seperate the io_handlers	 */	err = vsd_queue_file_io(cmd, rw);	/*	 * we should to a switch but I am not sure of all the err values	 * returned. If you find one add it	 */	if (err != cmd->bufflen) {		scsi_tgt_sense_data_build(cmd, HARDWARE_ERROR, 0, 0);		return TGT_CMD_FAILED;	} else {		cmd->result = SAM_STAT_GOOD;		return TGT_CMD_COMPLETED;	}}