diff mbox series

[v5,06/10] scsi: export scsi_mq_free_sgtables

Message ID 20200409165352.2126-7-johannes.thumshirn@wdc.com (mailing list archive)
State Superseded
Headers show
Series Introduce Zone Append for writing to zoned block devices | expand

Commit Message

Johannes Thumshirn April 9, 2020, 4:53 p.m. UTC
scsi_mq_free_sgtables is used to free the sg_tables, uninitialize the
command and delete it from the command list.

Export this function so it can be used from modular code to free the
memory allocated by scsi_init_io() if the caller of scsi_init_io() needs
to do error recovery.

While we're at it, rename scsi_mq_free_sgtables() to scsi_free_sgtables().

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

---
Changes to v4:
- Export scsi_mq_free_sgtables() instead of scsi_mq_uninit_cmnd()
---
 drivers/scsi/scsi_lib.c  | 7 ++++---
 include/scsi/scsi_cmnd.h | 1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig April 10, 2020, 5:58 a.m. UTC | #1
Looks good, althrough we really don't need the extern for the
prototype in the header (that also applies to a few other patches in
the series):

Reviewed-by: Christoph Hellwig <hch@lst.de>
Johannes Thumshirn April 10, 2020, 7:46 a.m. UTC | #2
On 10/04/2020 07:58, Christoph Hellwig wrote:
> Looks good, althrough we really don't need the extern for the
> prototype in the header (that also applies to a few other patches in
> the series):

I know but all prototypes have an 'extern' prefix so I did to match the 
style of the file.
Bart Van Assche April 10, 2020, 2:22 p.m. UTC | #3
On 2020-04-09 09:53, Johannes Thumshirn wrote:
> scsi_mq_free_sgtables is used to free the sg_tables, uninitialize the
> command and delete it from the command list.
> 
> Export this function so it can be used from modular code to free the
> memory allocated by scsi_init_io() if the caller of scsi_init_io() needs
> to do error recovery.
> 
> While we're at it, rename scsi_mq_free_sgtables() to scsi_free_sgtables().

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ea327f320b7f..b6b3ccd366da 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -548,7 +548,7 @@  static void scsi_uninit_cmd(struct scsi_cmnd *cmd)
 	}
 }
 
-static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
+void scsi_free_sgtables(struct scsi_cmnd *cmd)
 {
 	if (cmd->sdb.table.nents)
 		sg_free_table_chained(&cmd->sdb.table,
@@ -557,10 +557,11 @@  static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
 		sg_free_table_chained(&cmd->prot_sdb->table,
 				SCSI_INLINE_PROT_SG_CNT);
 }
+EXPORT_SYMBOL_GPL(scsi_free_sgtables);
 
 static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
 {
-	scsi_mq_free_sgtables(cmd);
+	scsi_free_sgtables(cmd);
 	scsi_uninit_cmd(cmd);
 	scsi_del_cmd_from_list(cmd);
 }
@@ -1060,7 +1061,7 @@  blk_status_t scsi_init_io(struct scsi_cmnd *cmd)
 
 	return BLK_STS_OK;
 out_free_sgtables:
-	scsi_mq_free_sgtables(cmd);
+	scsi_free_sgtables(cmd);
 	return ret;
 }
 EXPORT_SYMBOL(scsi_init_io);
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index a2849bb9cd19..a6383ced6156 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -167,6 +167,7 @@  extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
 extern void scsi_kunmap_atomic_sg(void *virt);
 
 extern blk_status_t scsi_init_io(struct scsi_cmnd *cmd);
+extern void scsi_free_sgtables(struct scsi_cmnd *cmd);
 
 #ifdef CONFIG_SCSI_DMA
 extern int scsi_dma_map(struct scsi_cmnd *cmd);