@@ -512,8 +512,6 @@ void scsi_run_host_queues(struct Scsi_Host *shost)
512
512
scsi_run_queue (sdev -> request_queue );
513
513
}
514
514
515
- static void __scsi_release_buffers (struct scsi_cmnd * , int );
516
-
517
515
/*
518
516
* Function: scsi_end_request()
519
517
*
@@ -569,7 +567,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
569
567
* This will goose the queue request function at the end, so we don't
570
568
* need to worry about launching another command.
571
569
*/
572
- __scsi_release_buffers (cmd , 0 );
570
+ scsi_release_buffers (cmd );
573
571
scsi_next_command (cmd );
574
572
return NULL ;
575
573
}
@@ -625,30 +623,10 @@ static void scsi_free_sgtable(struct scsi_data_buffer *sdb)
625
623
__sg_free_table (& sdb -> table , SCSI_MAX_SG_SEGMENTS , scsi_sg_free );
626
624
}
627
625
628
- static void __scsi_release_buffers (struct scsi_cmnd * cmd , int do_bidi_check )
629
- {
630
-
631
- if (cmd -> sdb .table .nents )
632
- scsi_free_sgtable (& cmd -> sdb );
633
-
634
- memset (& cmd -> sdb , 0 , sizeof (cmd -> sdb ));
635
-
636
- if (do_bidi_check && scsi_bidi_cmnd (cmd )) {
637
- struct scsi_data_buffer * bidi_sdb =
638
- cmd -> request -> next_rq -> special ;
639
- scsi_free_sgtable (bidi_sdb );
640
- kmem_cache_free (scsi_sdb_cache , bidi_sdb );
641
- cmd -> request -> next_rq -> special = NULL ;
642
- }
643
-
644
- if (scsi_prot_sg_count (cmd ))
645
- scsi_free_sgtable (cmd -> prot_sdb );
646
- }
647
-
648
626
/*
649
627
* Function: scsi_release_buffers()
650
628
*
651
- * Purpose: Completion processing for block device I/O requests .
629
+ * Purpose: Free resources allocate for a scsi_command .
652
630
*
653
631
* Arguments: cmd - command that we are bailing.
654
632
*
@@ -659,15 +637,29 @@ static void __scsi_release_buffers(struct scsi_cmnd *cmd, int do_bidi_check)
659
637
* Notes: In the event that an upper level driver rejects a
660
638
* command, we must release resources allocated during
661
639
* the __init_io() function. Primarily this would involve
662
- * the scatter-gather table, and potentially any bounce
663
- * buffers.
640
+ * the scatter-gather table.
664
641
*/
665
642
void scsi_release_buffers (struct scsi_cmnd * cmd )
666
643
{
667
- __scsi_release_buffers (cmd , 1 );
644
+ if (cmd -> sdb .table .nents )
645
+ scsi_free_sgtable (& cmd -> sdb );
646
+
647
+ memset (& cmd -> sdb , 0 , sizeof (cmd -> sdb ));
648
+
649
+ if (scsi_prot_sg_count (cmd ))
650
+ scsi_free_sgtable (cmd -> prot_sdb );
668
651
}
669
652
EXPORT_SYMBOL (scsi_release_buffers );
670
653
654
+ static void scsi_release_bidi_buffers (struct scsi_cmnd * cmd )
655
+ {
656
+ struct scsi_data_buffer * bidi_sdb = cmd -> request -> next_rq -> special ;
657
+
658
+ scsi_free_sgtable (bidi_sdb );
659
+ kmem_cache_free (scsi_sdb_cache , bidi_sdb );
660
+ cmd -> request -> next_rq -> special = NULL ;
661
+ }
662
+
671
663
/**
672
664
* __scsi_error_from_host_byte - translate SCSI error code into errno
673
665
* @cmd: SCSI command (unused)
@@ -801,6 +793,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
801
793
req -> next_rq -> resid_len = scsi_in (cmd )-> resid ;
802
794
803
795
scsi_release_buffers (cmd );
796
+ scsi_release_bidi_buffers (cmd );
804
797
blk_end_request_all (req , 0 );
805
798
806
799
scsi_next_command (cmd );
0 commit comments