Re: [PATCH] block: fix residual byte count handling

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: FUJITA Tomonori <tomof@...>
Cc: <efault@...>, <jens.axboe@...>, <fujita.tomonori@...>, <James.Bottomley@...>, <akpm@...>, <linux-kernel@...>, <linux-ide@...>, <linux-scsi@...>, <jgarzik@...>, <bzolnier@...>
Date: Tuesday, March 4, 2008 - 12:42 pm

Tejun Heo wrote:

Okay, I got it.  Heh, it turns out SCSI and/or block layer is not
ready for rq->data_len != sum(sg).  When adjusted command completes,
SCSI midlayer completes the command with rq->data_len for PC commands
which eventually ends up in __end_that_request_first().  As there are
extra sg area left after completing rq->data_len, blk layer says so to
SCSI layer and SCSI layer retries the command only with the appended
area.

The following patch gets the writing going.  I really think it's a
serious mistake to break rq->data_len == sum(sg).  If we break
rq->data_len == requested size, the worst bugs are giving wrong size
when issuing commands to application layer of devices which is
relatively easy to spot and not all that command anyway.  Breaking
rq->data_len == sum(sg), bugs will be in internal mechanics, DMA
engine programming and transport layer.  Oh well...

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index fecba05..32439ac 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -757,7 +757,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
 				"Notifying upper driver of completion "
 				"(result %x)\n", cmd->result));
 
-	good_bytes = scsi_bufflen(cmd);
+	good_bytes = scsi_bufflen(cmd) + cmd->request->data_len;
         if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
 		drv = scsi_cmd_to_driver(cmd);
 		if (drv->done)


-- 
tejun
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
regression: CD burning (k3b) went broke, Mike Galbraith, (Thu Feb 21, 4:42 am)
Re: regression: CD burning (k3b) went broke, Jens Axboe, (Fri Feb 22, 3:32 am)
Re: regression: CD burning (k3b) went broke, Mike Galbraith, (Sat Feb 23, 3:42 am)
Re: regression: CD burning (k3b) went broke, Mike Galbraith, (Sun Feb 24, 3:54 am)
Re: regression: CD burning (k3b) went broke, Mike Galbraith, (Tue Feb 26, 5:48 am)
Re: regression: CD burning (k3b) went broke, Mike Galbraith, (Tue Feb 26, 9:36 am)
Re: regression: CD burning (k3b) went broke, Andrew Morton, (Tue Feb 26, 7:08 pm)
Re: regression: CD burning (k3b) went broke, Jeff Garzik, (Tue Feb 26, 8:46 pm)
Re: regression: CD burning (k3b) went broke, Mike Galbraith, (Tue Feb 26, 10:58 pm)
Re: regression: CD burning (k3b) went broke, Mike Galbraith, (Tue Feb 26, 10:24 pm)
Re: regression: CD burning (k3b) went broke, Mike Galbraith, (Wed Feb 27, 2:00 am)
Re: regression: CD burning (k3b) went broke, Mike Galbraith, (Wed Feb 27, 3:07 am)
Re: regression: CD burning (k3b) went broke, Tejun Heo, (Thu Feb 28, 3:43 am)
Re: regression: CD burning (k3b) went broke, Mike Galbraith, (Thu Feb 28, 4:20 am)
[PATCH] block: fix residual byte count handling, Tejun Heo, (Thu Feb 28, 4:50 am)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Thu Feb 28, 11:35 am)
Re: [PATCH] block: fix residual byte count handling, Tejun Heo, (Thu Feb 28, 11:46 am)
Re: [PATCH] block: fix residual byte count handling, James Bottomley, (Fri Feb 29, 12:47 pm)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Fri Feb 29, 4:11 pm)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Sun Mar 2, 10:52 am)
Re: [PATCH] block: fix residual byte count handling, Tejun Heo, (Sun Mar 2, 10:40 pm)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Sun Mar 2, 11:59 pm)
Re: [PATCH] block: fix residual byte count handling, Tejun Heo, (Mon Mar 3, 12:09 am)
Re: [PATCH] block: separate out padding from alignment, James Bottomley, (Mon Mar 3, 2:27 pm)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Mon Mar 3, 4:26 am)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Mon Mar 3, 8:17 am)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Mon Mar 3, 9:50 am)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Mon Mar 3, 10:01 am)
Re: [PATCH] block: fix residual byte count handling, Tejun Heo, (Mon Mar 3, 10:22 am)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Mon Mar 3, 10:52 am)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Mon Mar 3, 10:11 pm)
Re: [PATCH] block: fix residual byte count handling, Tejun Heo, (Mon Mar 3, 10:32 pm)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Tue Mar 4, 4:53 am)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 4:59 am)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Tue Mar 4, 5:06 am)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Tue Mar 4, 5:22 am)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 5:35 am)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 5:46 am)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 8:37 am)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Tue Mar 4, 9:30 am)
Re: [PATCH] block: fix residual byte count handling, Tejun Heo, (Tue Mar 4, 12:17 pm)
Re: [PATCH] block: fix residual byte count handling, Tejun Heo, (Tue Mar 4, 12:42 pm)
Re: [PATCH] block: fix residual byte count handling, Boaz Harrosh, (Tue Mar 4, 2:26 pm)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Tue Mar 4, 3:19 pm)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Tue Mar 4, 8:26 pm)
Re: [PATCH] block: fix residual byte count handling, FUJITA Tomonori, (Thu Mar 6, 12:56 am)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 2:45 pm)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 3:25 pm)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 3:33 pm)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 3:34 pm)
Re: [PATCH] block: fix residual byte count handling, James Bottomley, (Tue Mar 4, 2:27 pm)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 8:45 am)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 8:39 am)
Re: [PATCH] block: fix residual byte count handling, Kiyoshi Ueda, (Tue Mar 4, 3:42 pm)
Re: [PATCH] block: fix residual byte count handling, James Bottomley, (Tue Mar 4, 12:04 pm)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 2:46 pm)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 8:43 am)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 8:58 am)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 9:03 am)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 10:25 am)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 2:17 pm)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 2:29 pm)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 2:35 pm)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 2:45 pm)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 2:49 pm)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 2:54 pm)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Tue Mar 4, 3:26 pm)
Re: [PATCH] block: fix residual byte count handling, Jens Axboe, (Tue Mar 4, 3:28 pm)
Re: [PATCH] block: fix residual byte count handling, Mike Christie, (Sun Mar 2, 2:46 pm)
Re: [PATCH] block: fix residual byte count handling, Mike Galbraith, (Sun Mar 2, 11:27 pm)
Re: [PATCH] block: fix residual byte count handling, James Bottomley, (Sat Mar 1, 11:19 am)