aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r--drivers/scsi/scsi_lib.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index fe77ccacf319..a47c05d7829a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -65,7 +65,7 @@ static struct scsi_host_sg_pool scsi_sg_pools[] = {
65}; 65};
66#undef SP 66#undef SP
67 67
68static struct kmem_cache *scsi_sdb_cache; 68struct kmem_cache *scsi_sdb_cache;
69 69
70static void scsi_run_queue(struct request_queue *q); 70static void scsi_run_queue(struct request_queue *q);
71 71
@@ -787,6 +787,9 @@ void scsi_release_buffers(struct scsi_cmnd *cmd)
787 kmem_cache_free(scsi_sdb_cache, bidi_sdb); 787 kmem_cache_free(scsi_sdb_cache, bidi_sdb);
788 cmd->request->next_rq->special = NULL; 788 cmd->request->next_rq->special = NULL;
789 } 789 }
790
791 if (scsi_prot_sg_count(cmd))
792 scsi_free_sgtable(cmd->prot_sdb);
790} 793}
791EXPORT_SYMBOL(scsi_release_buffers); 794EXPORT_SYMBOL(scsi_release_buffers);
792 795
@@ -1072,6 +1075,26 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
1072 goto err_exit; 1075 goto err_exit;
1073 } 1076 }
1074 1077
1078 if (blk_integrity_rq(cmd->request)) {
1079 struct scsi_data_buffer *prot_sdb = cmd->prot_sdb;
1080 int ivecs, count;
1081
1082 BUG_ON(prot_sdb == NULL);
1083 ivecs = blk_rq_count_integrity_sg(cmd->request);
1084
1085 if (scsi_alloc_sgtable(prot_sdb, ivecs, gfp_mask)) {
1086 error = BLKPREP_DEFER;
1087 goto err_exit;
1088 }
1089
1090 count = blk_rq_map_integrity_sg(cmd->request,
1091 prot_sdb->table.sgl);
1092 BUG_ON(unlikely(count > ivecs));
1093
1094 cmd->prot_sdb = prot_sdb;
1095 cmd->prot_sdb->table.nents = count;
1096 }
1097
1075 return BLKPREP_OK ; 1098 return BLKPREP_OK ;
1076 1099
1077err_exit: 1100err_exit: