Commit 001d63be61c3b5a0413a46bacafbfc60c353951a

Authored by Ming Lin
Committed by Martin K. Petersen
1 parent 22cc3d4c6f

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>

Showing 1 changed file with 26 additions and 26 deletions Side-by-side Diff

drivers/scsi/scsi_lib.c
... ... @@ -40,10 +40,10 @@
40 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 44 #define SG_MEMPOOL_SIZE 2
45 45  
46   -struct scsi_host_sg_pool {
  46 +struct sg_pool {
47 47 size_t size;
48 48 char *name;
49 49 struct kmem_cache *slab;
... ... @@ -54,7 +54,7 @@
54 54 #if (SCSI_MAX_SG_SEGMENTS < 32)
55 55 #error SCSI_MAX_SG_SEGMENTS is too small (must be 32 or greater)
56 56 #endif
57   -static struct scsi_host_sg_pool scsi_sg_pools[] = {
  57 +static struct sg_pool sg_pools[] = {
58 58 SP(8),
59 59 SP(16),
60 60 #if (SCSI_MAX_SG_SEGMENTS > 32)
... ... @@ -553,7 +553,7 @@
553 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 558 unsigned int index;
559 559  
560 560  
561 561  
562 562  
563 563  
564 564  
565 565  
566 566  
567 567  
... ... @@ -567,30 +567,30 @@
567 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 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 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 588 if (first_chunk && table->orig_nents <= SCSI_MAX_SG_SEGMENTS)
589 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 594 struct scatterlist *first_chunk)
595 595 {
596 596 int ret;
597 597  
... ... @@ -606,9 +606,9 @@
606 606 }
607 607  
608 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 610 if (unlikely(ret))
611   - scsi_free_sgtable(table, (bool)first_chunk);
  611 + sg_free_table_chained(table, (bool)first_chunk);
612 612 return ret;
613 613 }
614 614  
615 615  
616 616  
... ... @@ -627,14 +627,14 @@
627 627 struct scsi_data_buffer *sdb;
628 628  
629 629 if (cmd->sdb.table.nents)
630   - scsi_free_sgtable(&cmd->sdb.table, true);
  630 + sg_free_table_chained(&cmd->sdb.table, true);
631 631 if (cmd->request->next_rq) {
632 632 sdb = cmd->request->next_rq->special;
633 633 if (sdb)
634   - scsi_free_sgtable(&sdb->table, true);
  634 + sg_free_table_chained(&sdb->table, true);
635 635 }
636 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 640 static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
641 641  
642 642  
... ... @@ -673,19 +673,19 @@
673 673 static void scsi_release_buffers(struct scsi_cmnd *cmd)
674 674 {
675 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 678 memset(&cmd->sdb, 0, sizeof(cmd->sdb));
679 679  
680 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 684 static void scsi_release_bidi_buffers(struct scsi_cmnd *cmd)
685 685 {
686 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 689 kmem_cache_free(scsi_sdb_cache, bidi_sdb);
690 690 cmd->request->next_rq->special = NULL;
691 691 }
... ... @@ -1089,7 +1089,7 @@
1089 1089 /*
1090 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 1093 sdb->table.sgl)))
1094 1094 return BLKPREP_DEFER;
1095 1095  
... ... @@ -1162,7 +1162,7 @@
1162 1162  
1163 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 1166 prot_sdb->table.sgl)) {
1167 1167 error = BLKPREP_DEFER;
1168 1168 goto err_exit;
... ... @@ -2280,7 +2280,7 @@
2280 2280 }
2281 2281  
2282 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 2284 int size = sgp->size * sizeof(struct scatterlist);
2285 2285  
2286 2286 sgp->slab = kmem_cache_create(sgp->name, size, 0,
... ... @@ -2304,7 +2304,7 @@
2304 2304  
2305 2305 cleanup_sdb:
2306 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 2308 if (sgp->pool)
2309 2309 mempool_destroy(sgp->pool);
2310 2310 if (sgp->slab)
... ... @@ -2322,7 +2322,7 @@
2322 2322 kmem_cache_destroy(scsi_sdb_cache);
2323 2323  
2324 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 2326 mempool_destroy(sgp->pool);
2327 2327 kmem_cache_destroy(sgp->slab);
2328 2328 }