1307 sc->scsi_done = NULL;
1308 iscsi_complete_command(task);
1309 reason = FAILURE_SESSION_NOT_READY;
1310 goto reject;
1311 }
1312 } else
1313 scsi_queue_work(session->host, &conn->xmitwork);
1314
1315 session->queued_cmdsn++;
1316 spin_unlock(&session->lock);
1317 spin_lock(host->host_lock);
1318 return 0;
1319
1320reject:
1321 spin_unlock(&session->lock);
1322 debug_scsi("cmd 0x%x rejected (%d)\n", sc->cmnd[0], reason);
1323 spin_lock(host->host_lock);
1324 return SCSI_MLQUEUE_TARGET_BUSY;
1325
1326fault:
1327 spin_unlock(&session->lock);
1328 debug_scsi("iscsi: cmd 0x%x is not queued (%d)\n", sc->cmnd[0], reason);
1329 if (!scsi_bidi_cmnd(sc))
1330 scsi_set_resid(sc, scsi_bufflen(sc));
1331 else {
1332 scsi_out(sc)->resid = scsi_out(sc)->length;
1333 scsi_in(sc)->resid = scsi_in(sc)->length;
1334 }
1335 done(sc);
1336 spin_lock(host->host_lock);
1337 return 0;
1338}
1339EXPORT_SYMBOL_GPL(iscsi_queuecommand);
1340
1341int iscsi_change_queue_depth(struct scsi_device *sdev, int depth)
1342{
1343 if (depth > ISCSI_MAX_CMD_PER_LUN)
1344 depth = ISCSI_MAX_CMD_PER_LUN;
1345 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth);
1346 return sdev->queue_depth;
1347}