|
39 | 39 | #include "scsi_priv.h"
|
40 | 40 | #include "scsi_logging.h"
|
41 | 41 |
|
| 42 | +/* |
| 43 | + * Size of integrity metadata is usually small, 1 inline sg should |
| 44 | + * cover normal cases. |
| 45 | + */ |
| 46 | +#define SCSI_INLINE_PROT_SG_CNT 1 |
| 47 | + |
42 | 48 | static struct kmem_cache *scsi_sdb_cache;
|
43 | 49 | static struct kmem_cache *scsi_sense_cache;
|
44 | 50 | static struct kmem_cache *scsi_sense_isadma_cache;
|
@@ -543,7 +549,8 @@ static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
|
543 | 549 | if (cmd->sdb.table.nents)
|
544 | 550 | sg_free_table_chained(&cmd->sdb.table, SG_CHUNK_SIZE);
|
545 | 551 | if (scsi_prot_sg_count(cmd))
|
546 |
| - sg_free_table_chained(&cmd->prot_sdb->table, SG_CHUNK_SIZE); |
| 552 | + sg_free_table_chained(&cmd->prot_sdb->table, |
| 553 | + SCSI_INLINE_PROT_SG_CNT); |
547 | 554 | }
|
548 | 555 |
|
549 | 556 | static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
|
@@ -1032,7 +1039,7 @@ blk_status_t scsi_init_io(struct scsi_cmnd *cmd)
|
1032 | 1039 |
|
1033 | 1040 | if (sg_alloc_table_chained(&prot_sdb->table, ivecs,
|
1034 | 1041 | prot_sdb->table.sgl,
|
1035 |
| - SG_CHUNK_SIZE)) { |
| 1042 | + SCSI_INLINE_PROT_SG_CNT)) { |
1036 | 1043 | ret = BLK_STS_RESOURCE;
|
1037 | 1044 | goto out_free_sgtables;
|
1038 | 1045 | }
|
@@ -1824,7 +1831,8 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
|
1824 | 1831 | sgl_size = scsi_mq_sgl_size(shost);
|
1825 | 1832 | cmd_size = sizeof(struct scsi_cmnd) + shost->hostt->cmd_size + sgl_size;
|
1826 | 1833 | if (scsi_host_get_prot(shost))
|
1827 |
| - cmd_size += sizeof(struct scsi_data_buffer) + sgl_size; |
| 1834 | + cmd_size += sizeof(struct scsi_data_buffer) + |
| 1835 | + sizeof(struct scatterlist) * SCSI_INLINE_PROT_SG_CNT; |
1828 | 1836 |
|
1829 | 1837 | memset(&shost->tag_set, 0, sizeof(shost->tag_set));
|
1830 | 1838 | shost->tag_set.ops = &scsi_mq_ops;
|
|
0 commit comments