]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/target/loopback/tcm_loop.c
Merge tag 'staging-3.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[mirror_ubuntu-artful-kernel.git] / drivers / target / loopback / tcm_loop.c
index 73ab75ddaf42e9b3fc8e378cf3ae3669d1e040e8..8c64b8776a9634e34027098ef3ca8976e9e5691e 100644 (file)
@@ -179,7 +179,7 @@ static void tcm_loop_submission_work(struct work_struct *work)
        struct tcm_loop_hba *tl_hba;
        struct tcm_loop_tpg *tl_tpg;
        struct scatterlist *sgl_bidi = NULL;
-       u32 sgl_bidi_count = 0;
+       u32 sgl_bidi_count = 0, transfer_length;
        int rc;
 
        tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
@@ -213,12 +213,21 @@ static void tcm_loop_submission_work(struct work_struct *work)
 
        }
 
-       if (!scsi_prot_sg_count(sc) && scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
+       transfer_length = scsi_transfer_length(sc);
+       if (!scsi_prot_sg_count(sc) &&
+           scsi_get_prot_op(sc) != SCSI_PROT_NORMAL) {
                se_cmd->prot_pto = true;
+               /*
+                * loopback transport doesn't support
+                * WRITE_GENERATE, READ_STRIP protection
+                * information operations, go ahead unprotected.
+                */
+               transfer_length = scsi_bufflen(sc);
+       }
 
        rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
                        &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
-                       scsi_bufflen(sc), tcm_loop_sam_attr(sc),
+                       transfer_length, tcm_loop_sam_attr(sc),
                        sc->sc_data_direction, 0,
                        scsi_sglist(sc), scsi_sg_count(sc),
                        sgl_bidi, sgl_bidi_count,
@@ -230,6 +239,7 @@ static void tcm_loop_submission_work(struct work_struct *work)
        return;
 
 out_done:
+       kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
        sc->scsi_done(sc);
        return;
 }