Re: [PATCH scsi-misc-2.6 01/08] scsi: remove unused bounce-buffer release path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



01_scsi_remove_scsi_release_buffers.patch

	Buffer bouncing hasn't been done inside the scsi midlayer for
	quite sometime now, but bounce-buffer release paths are still
	around.  This patch removes these unused paths.

Signed-off-by: Tejun Heo <[email protected]>

 scsi_lib.c |   60 +++++-------------------------------------------------------
 1 files changed, 5 insertions(+), 55 deletions(-)

Index: scsi-export/drivers/scsi/scsi_lib.c
===================================================================
--- scsi-export.orig/drivers/scsi/scsi_lib.c	2005-03-23 09:39:36.000000000 +0900
+++ scsi-export/drivers/scsi/scsi_lib.c	2005-03-23 09:40:09.000000000 +0900
@@ -622,45 +622,6 @@ static void scsi_free_sgtable(struct sca
 }
 
 /*
- * Function:    scsi_release_buffers()
- *
- * Purpose:     Completion processing for block device I/O requests.
- *
- * Arguments:   cmd	- command that we are bailing.
- *
- * Lock status: Assumed that no lock is held upon entry.
- *
- * Returns:     Nothing
- *
- * Notes:       In the event that an upper level driver rejects a
- *		command, we must release resources allocated during
- *		the __init_io() function.  Primarily this would involve
- *		the scatter-gather table, and potentially any bounce
- *		buffers.
- */
-static void scsi_release_buffers(struct scsi_cmnd *cmd)
-{
-	struct request *req = cmd->request;
-
-	/*
-	 * Free up any indirection buffers we allocated for DMA purposes. 
-	 */
-	if (cmd->use_sg)
-		scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);
-	else if (cmd->request_buffer != req->buffer)
-		kfree(cmd->request_buffer);
-
-	/*
-	 * Zero these out.  They now point to freed memory, and it is
-	 * dangerous to hang onto the pointers.
-	 */
-	cmd->buffer  = NULL;
-	cmd->bufflen = 0;
-	cmd->request_buffer = NULL;
-	cmd->request_bufflen = 0;
-}
-
-/*
  * Function:    scsi_io_completion()
  *
  * Purpose:     Completion processing for block device I/O requests.
@@ -703,22 +664,8 @@ void scsi_io_completion(struct scsi_cmnd
 	if (blk_complete_barrier_rq(q, req, good_bytes >> 9))
 		return;
 
-	/*
-	 * Free up any indirection buffers we allocated for DMA purposes. 
-	 * For the case of a READ, we need to copy the data out of the
-	 * bounce buffer and into the real buffer.
-	 */
 	if (cmd->use_sg)
 		scsi_free_sgtable(cmd->buffer, cmd->sglist_len);
-	else if (cmd->buffer != req->buffer) {
-		if (rq_data_dir(req) == READ) {
-			unsigned long flags;
-			char *to = bio_kmap_irq(req->bio, &flags);
-			memcpy(to, cmd->buffer, cmd->bufflen);
-			bio_kunmap_irq(to, &flags);
-		}
-		kfree(cmd->buffer);
-	}
 
 	if (result) {
 		sense_valid = scsi_command_normalize_sense(cmd, &sshdr);
@@ -963,7 +910,8 @@ static int scsi_init_io(struct scsi_cmnd
 			req->current_nr_sectors);
 
 	/* release the command and kill it */
-	scsi_release_buffers(cmd);
+	if (cmd->use_sg)
+		scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);
 	scsi_put_command(cmd);
 	return BLKPREP_KILL;
 }
@@ -1140,7 +1088,9 @@ static int scsi_prep_fn(struct request_q
 		 */
 		drv = *(struct scsi_driver **)req->rq_disk->private_data;
 		if (unlikely(!drv->init_command(cmd))) {
-			scsi_release_buffers(cmd);
+			if (cmd->use_sg)
+				scsi_free_sgtable(cmd->request_buffer,
+						  cmd->sglist_len);
 			scsi_put_command(cmd);
 			return BLKPREP_KILL;
 		}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux