diff options
author | Ming Lin <ming.l@ssi.samsung.com> | 2016-04-04 17:48:09 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-04-15 16:53:13 -0400 |
commit | 001d63be61c3b5a0413a46bacafbfc60c353951a (patch) | |
tree | 695d82b082d306f891098c6bda206911276e77cb | |
parent | 22cc3d4c6f4c529f4bf17445c60893b13e7611fb (diff) |
scsi: rename SG related struct and functions
Rename SCSI specific struct and functions to more genenic names.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lin <ming.l@ssi.samsung.com>
Reviewed-by: Sagi Grimberg <sgi@grimberg.me>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/scsi_lib.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 9675353770e9..08134f621450 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -40,10 +40,10 @@ | |||
40 | #include "scsi_logging.h" | 40 | #include "scsi_logging.h" |
41 | 41 | ||
42 | 42 | ||
43 | #define SG_MEMPOOL_NR ARRAY_SIZE(scsi_sg_pools) | 43 | #define SG_MEMPOOL_NR ARRAY_SIZE(sg_pools) |
44 | #define SG_MEMPOOL_SIZE 2 | 44 | #define SG_MEMPOOL_SIZE 2 |
45 | 45 | ||
46 | struct scsi_host_sg_pool { | 46 | struct sg_pool { |
47 | size_t size; | 47 | size_t size; |
48 | char *name; | 48 | char *name; |
49 | struct kmem_cache *slab; | 49 | struct kmem_cache *slab; |
@@ -54,7 +54,7 @@ struct scsi_host_sg_pool { | |||
54 | #if (SCSI_MAX_SG_SEGMENTS < 32) | 54 | #if (SCSI_MAX_SG_SEGMENTS < 32) |
55 | #error SCSI_MAX_SG_SEGMENTS is too small (must be 32 or greater) | 55 | #error SCSI_MAX_SG_SEGMENTS is too small (must be 32 or greater) |
56 | #endif | 56 | #endif |
57 | static struct scsi_host_sg_pool scsi_sg_pools[] = { | 57 | static struct sg_pool sg_pools[] = { |
58 | SP(8), | 58 | SP(8), |
59 | SP(16), | 59 | SP(16), |
60 | #if (SCSI_MAX_SG_SEGMENTS > 32) | 60 | #if (SCSI_MAX_SG_SEGMENTS > 32) |
@@ -553,7 +553,7 @@ void scsi_run_host_queues(struct Scsi_Host *shost) | |||
553 | scsi_run_queue(sdev->request_queue); | 553 | scsi_run_queue(sdev->request_queue); |
554 | } | 554 | } |
555 | 555 | ||
556 | static inline unsigned int scsi_sgtable_index(unsigned short nents) | 556 | static inline unsigned int sg_pool_index(unsigned short nents) |
557 | { | 557 | { |
558 | unsigned int index; | 558 | unsigned int index; |
559 | 559 | ||
@@ -567,30 +567,30 @@ static inline unsigned int scsi_sgtable_index(unsigned short nents) | |||
567 | return index; | 567 | return index; |
568 | } | 568 | } |
569 | 569 | ||
570 | static void scsi_sg_free(struct scatterlist *sgl, unsigned int nents) | 570 | static void sg_pool_free(struct scatterlist *sgl, unsigned int nents) |
571 | { | 571 | { |
572 | struct scsi_host_sg_pool *sgp; | 572 | struct sg_pool *sgp; |
573 | 573 | ||
574 | sgp = scsi_sg_pools + scsi_sgtable_index(nents); | 574 | sgp = sg_pools + sg_pool_index(nents); |
575 | mempool_free(sgl, sgp->pool); | 575 | mempool_free(sgl, sgp->pool); |
576 | } | 576 | } |
577 | 577 | ||
578 | static struct scatterlist *scsi_sg_alloc(unsigned int nents, gfp_t gfp_mask) | 578 | static struct scatterlist *sg_pool_alloc(unsigned int nents, gfp_t gfp_mask) |
579 | { | 579 | { |
580 | struct scsi_host_sg_pool *sgp; | 580 | struct sg_pool *sgp; |
581 | 581 | ||
582 | sgp = scsi_sg_pools + scsi_sgtable_index(nents); | 582 | sgp = sg_pools + sg_pool_index(nents); |
583 | return mempool_alloc(sgp->pool, gfp_mask); | 583 | return mempool_alloc(sgp->pool, gfp_mask); |
584 | } | 584 | } |
585 | 585 | ||
586 | static void scsi_free_sgtable(struct sg_table *table, bool first_chunk) | 586 | static void sg_free_table_chained(struct sg_table *table, bool first_chunk) |
587 | { | 587 | { |
588 | if (first_chunk && table->orig_nents <= SCSI_MAX_SG_SEGMENTS) | 588 | if (first_chunk && table->orig_nents <= SCSI_MAX_SG_SEGMENTS) |
589 | return; | 589 | return; |
590 | __sg_free_table(table, SCSI_MAX_SG_SEGMENTS, first_chunk, scsi_sg_free); | 590 | __sg_free_table(table, SCSI_MAX_SG_SEGMENTS, first_chunk, sg_pool_free); |
591 | } | 591 | } |
592 | 592 | ||
593 | static int scsi_alloc_sgtable(struct sg_table *table, int nents, | 593 | static int sg_alloc_table_chained(struct sg_table *table, int nents, |
594 | struct scatterlist *first_chunk) | 594 | struct scatterlist *first_chunk) |
595 | { | 595 | { |
596 | int ret; | 596 | int ret; |
@@ -606,9 +606,9 @@ static int scsi_alloc_sgtable(struct sg_table *table, int nents, | |||
606 | } | 606 | } |
607 | 607 | ||
608 | ret = __sg_alloc_table(table, nents, SCSI_MAX_SG_SEGMENTS, | 608 | ret = __sg_alloc_table(table, nents, SCSI_MAX_SG_SEGMENTS, |
609 | first_chunk, GFP_ATOMIC, scsi_sg_alloc); | 609 | first_chunk, GFP_ATOMIC, sg_pool_alloc); |
610 | if (unlikely(ret)) | 610 | if (unlikely(ret)) |
611 | scsi_free_sgtable(table, (bool)first_chunk); | 611 | sg_free_table_chained(table, (bool)first_chunk); |
612 | return ret; | 612 | return ret; |
613 | } | 613 | } |
614 | 614 | ||
@@ -627,14 +627,14 @@ static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd) | |||
627 | struct scsi_data_buffer *sdb; | 627 | struct scsi_data_buffer *sdb; |
628 | 628 | ||
629 | if (cmd->sdb.table.nents) | 629 | if (cmd->sdb.table.nents) |
630 | scsi_free_sgtable(&cmd->sdb.table, true); | 630 | sg_free_table_chained(&cmd->sdb.table, true); |
631 | if (cmd->request->next_rq) { | 631 | if (cmd->request->next_rq) { |
632 | sdb = cmd->request->next_rq->special; | 632 | sdb = cmd->request->next_rq->special; |
633 | if (sdb) | 633 | if (sdb) |
634 | scsi_free_sgtable(&sdb->table, true); | 634 | sg_free_table_chained(&sdb->table, true); |
635 | } | 635 | } |
636 | if (scsi_prot_sg_count(cmd)) | 636 | if (scsi_prot_sg_count(cmd)) |
637 | scsi_free_sgtable(&cmd->prot_sdb->table, true); | 637 | sg_free_table_chained(&cmd->prot_sdb->table, true); |
638 | } | 638 | } |
639 | 639 | ||
640 | static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd) | 640 | static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd) |
@@ -673,19 +673,19 @@ static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd) | |||
673 | static void scsi_release_buffers(struct scsi_cmnd *cmd) | 673 | static void scsi_release_buffers(struct scsi_cmnd *cmd) |
674 | { | 674 | { |
675 | if (cmd->sdb.table.nents) | 675 | if (cmd->sdb.table.nents) |
676 | scsi_free_sgtable(&cmd->sdb.table, false); | 676 | sg_free_table_chained(&cmd->sdb.table, false); |
677 | 677 | ||
678 | memset(&cmd->sdb, 0, sizeof(cmd->sdb)); | 678 | memset(&cmd->sdb, 0, sizeof(cmd->sdb)); |
679 | 679 | ||
680 | if (scsi_prot_sg_count(cmd)) | 680 | if (scsi_prot_sg_count(cmd)) |
681 | scsi_free_sgtable(&cmd->prot_sdb->table, false); | 681 | sg_free_table_chained(&cmd->prot_sdb->table, false); |
682 | } | 682 | } |
683 | 683 | ||
684 | static void scsi_release_bidi_buffers(struct scsi_cmnd *cmd) | 684 | static void scsi_release_bidi_buffers(struct scsi_cmnd *cmd) |
685 | { | 685 | { |
686 | struct scsi_data_buffer *bidi_sdb = cmd->request->next_rq->special; | 686 | struct scsi_data_buffer *bidi_sdb = cmd->request->next_rq->special; |
687 | 687 | ||
688 | scsi_free_sgtable(&bidi_sdb->table, false); | 688 | sg_free_table_chained(&bidi_sdb->table, false); |
689 | kmem_cache_free(scsi_sdb_cache, bidi_sdb); | 689 | kmem_cache_free(scsi_sdb_cache, bidi_sdb); |
690 | cmd->request->next_rq->special = NULL; | 690 | cmd->request->next_rq->special = NULL; |
691 | } | 691 | } |
@@ -1089,7 +1089,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb) | |||
1089 | /* | 1089 | /* |
1090 | * If sg table allocation fails, requeue request later. | 1090 | * If sg table allocation fails, requeue request later. |
1091 | */ | 1091 | */ |
1092 | if (unlikely(scsi_alloc_sgtable(&sdb->table, req->nr_phys_segments, | 1092 | if (unlikely(sg_alloc_table_chained(&sdb->table, req->nr_phys_segments, |
1093 | sdb->table.sgl))) | 1093 | sdb->table.sgl))) |
1094 | return BLKPREP_DEFER; | 1094 | return BLKPREP_DEFER; |
1095 | 1095 | ||
@@ -1162,7 +1162,7 @@ int scsi_init_io(struct scsi_cmnd *cmd) | |||
1162 | 1162 | ||
1163 | ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio); | 1163 | ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio); |
1164 | 1164 | ||
1165 | if (scsi_alloc_sgtable(&prot_sdb->table, ivecs, | 1165 | if (sg_alloc_table_chained(&prot_sdb->table, ivecs, |
1166 | prot_sdb->table.sgl)) { | 1166 | prot_sdb->table.sgl)) { |
1167 | error = BLKPREP_DEFER; | 1167 | error = BLKPREP_DEFER; |
1168 | goto err_exit; | 1168 | goto err_exit; |
@@ -2280,7 +2280,7 @@ int __init scsi_init_queue(void) | |||
2280 | } | 2280 | } |
2281 | 2281 | ||
2282 | for (i = 0; i < SG_MEMPOOL_NR; i++) { | 2282 | for (i = 0; i < SG_MEMPOOL_NR; i++) { |
2283 | struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; | 2283 | struct sg_pool *sgp = sg_pools + i; |
2284 | int size = sgp->size * sizeof(struct scatterlist); | 2284 | int size = sgp->size * sizeof(struct scatterlist); |
2285 | 2285 | ||
2286 | sgp->slab = kmem_cache_create(sgp->name, size, 0, | 2286 | sgp->slab = kmem_cache_create(sgp->name, size, 0, |
@@ -2304,7 +2304,7 @@ int __init scsi_init_queue(void) | |||
2304 | 2304 | ||
2305 | cleanup_sdb: | 2305 | cleanup_sdb: |
2306 | for (i = 0; i < SG_MEMPOOL_NR; i++) { | 2306 | for (i = 0; i < SG_MEMPOOL_NR; i++) { |
2307 | struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; | 2307 | struct sg_pool *sgp = sg_pools + i; |
2308 | if (sgp->pool) | 2308 | if (sgp->pool) |
2309 | mempool_destroy(sgp->pool); | 2309 | mempool_destroy(sgp->pool); |
2310 | if (sgp->slab) | 2310 | if (sgp->slab) |
@@ -2322,7 +2322,7 @@ void scsi_exit_queue(void) | |||
2322 | kmem_cache_destroy(scsi_sdb_cache); | 2322 | kmem_cache_destroy(scsi_sdb_cache); |
2323 | 2323 | ||
2324 | for (i = 0; i < SG_MEMPOOL_NR; i++) { | 2324 | for (i = 0; i < SG_MEMPOOL_NR; i++) { |
2325 | struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; | 2325 | struct sg_pool *sgp = sg_pools + i; |
2326 | mempool_destroy(sgp->pool); | 2326 | mempool_destroy(sgp->pool); |
2327 | kmem_cache_destroy(sgp->slab); | 2327 | kmem_cache_destroy(sgp->slab); |
2328 | } | 2328 | } |