]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/scsi_tgt_lib.c
es1968: fix sleep-while-holding-lock bug
[linux-2.6-omap-h63xx.git] / drivers / scsi / scsi_tgt_lib.c
index 93ece8f4e5dea391c07c8a4241df9d180489c869..a0f308bd145b062e2403af9b57a2c32d92108ca0 100644 (file)
@@ -103,7 +103,6 @@ struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *shost,
        if (!cmd)
                goto release_rq;
 
-       memset(cmd, 0, sizeof(*cmd));
        cmd->sc_data_direction = data_dir;
        cmd->jiffies_at_alloc = jiffies;
        cmd->request = rq;
@@ -320,7 +319,7 @@ int scsi_tgt_queue_command(struct scsi_cmnd *cmd, u64 itn_id,
 EXPORT_SYMBOL_GPL(scsi_tgt_queue_command);
 
 /*
- * This is run from a interrpt handler normally and the unmap
+ * This is run from a interrupt handler normally and the unmap
  * needs process context so we must queue
  */
 static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)
@@ -331,8 +330,7 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)
 
        scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag);
 
-       if (scsi_sglist(cmd))
-               scsi_free_sgtable(cmd);
+       scsi_release_buffers(cmd);
 
        queue_work(scsi_tgtd, &tcmd->work);
 }
@@ -353,26 +351,6 @@ static int scsi_tgt_transfer_response(struct scsi_cmnd *cmd)
        return 0;
 }
 
-static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask)
-{
-       struct request *rq = cmd->request;
-       int count;
-
-       cmd->use_sg = rq->nr_phys_segments;
-       cmd->request_buffer = scsi_alloc_sgtable(cmd, gfp_mask);
-       if (!cmd->request_buffer)
-               return -ENOMEM;
-
-       cmd->request_bufflen = rq->data_len;
-
-       dprintk("cmd %p cnt %d %lu\n", cmd, scsi_sg_count(cmd),
-               rq_data_dir(rq));
-       count = blk_rq_map_sg(rq->q, rq, scsi_sglist(cmd));
-       BUG_ON(count > cmd->use_sg);
-       cmd->use_sg = count;
-       return 0;
-}
-
 /* TODO: test this crap and replace bio_map_user with new interface maybe */
 static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
                               unsigned long uaddr, unsigned int len, int rw)
@@ -398,9 +376,16 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
        }
 
        tcmd->bio = rq->bio;
-       err = scsi_tgt_init_cmd(cmd, GFP_KERNEL);
-       if (err)
+       err = scsi_init_io(cmd, GFP_KERNEL);
+       if (err) {
+               scsi_release_buffers(cmd);
                goto unmap_rq;
+       }
+       /*
+        * we use REQ_TYPE_BLOCK_PC so scsi_init_io doesn't set the
+        * length for us.
+        */
+       cmd->sdb.length = rq->data_len;
 
        return 0;