diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2008-07-17 17:08:48 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-07-26 15:14:55 -0400 |
commit | 7027ad72a689797475973c6feb5f0b673382f779 (patch) | |
tree | 4f6daa1d509708fb340d09608d79557a9af57f00 /drivers/scsi/scsi_lib.c | |
parent | db007fc5e20c00b356e9ffe2d0e007398c65c837 (diff) |
[SCSI] Support devices with protection information
Implement support for DMA of protection information for devices that
are data integrity capable.
- Add support for mapping an extra scatter-gather list containing
the protection information.
- Allocate protection scsi_data_buffer if host is DIX (integrity DMA)
capable.
- Accessor function for checking whether a device has protection
enabled.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r-- | drivers/scsi/scsi_lib.c | 25 |
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 | ||
68 | static struct kmem_cache *scsi_sdb_cache; | 68 | struct kmem_cache *scsi_sdb_cache; |
69 | 69 | ||
70 | static void scsi_run_queue(struct request_queue *q); | 70 | static 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 | } |
791 | EXPORT_SYMBOL(scsi_release_buffers); | 794 | EXPORT_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 | ||
1077 | err_exit: | 1100 | err_exit: |