linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2
@ 2009-05-19  9:33 Tejun Heo
  2009-05-19  9:33 ` [PATCH 1/3] ub: use __blk_end_request_all() Tejun Heo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tejun Heo @ 2009-05-19  9:33 UTC (permalink / raw)
  To: linux-ide, jens.axboe, bharrosh, linux-kernel, linux-scsi,
	bzolnier, petkovbb, zaitcev@

Hello,

This is the second take of fix-fallouts patchset.  The first one[L]
was posted without header message.  Changes from the last take are

* ub change updated per Pete Zitcev's comment

* resid_len init bug spotted by Boaz Harrosh fixed

This patchset contains the following three patches.

  0001-ub-use-__blk_end_request_all.patch
  0002-block-set-rq-resid_len-to-blk_rq_bytes-on-issue.patch
  0003-bio-always-copy-back-data-for-copied-kernel-request.patch

0001 updates ub to use __blk_end_request_all() and 0002 restores the
original residue count behavior.  0003 makes sure kernel pc buffer is
bounced back even on request failure as user pc ones do.  This
inconsistency was discovered during discussion over residue count
semantics.

This patchset contains the following changes.

 block/blk-core.c                         |    5 +++--
 drivers/block/ub.c                       |   30 +++++++++++-------------------
 drivers/ide/ide-cd.c                     |    4 ++--
 drivers/ide/ide-tape.c                   |    2 +-
 drivers/message/fusion/mptsas.c          |    3 ++-
 drivers/scsi/libsas/sas_expander.c       |    4 ++++
 drivers/scsi/libsas/sas_host_smp.c       |    3 ---
 drivers/scsi/mpt2sas/mpt2sas_transport.c |    4 ++--
 fs/bio.c                                 |    2 +-
 9 files changed, 26 insertions(+), 31 deletions(-)

Thanks.

--
tejun

[L] http://thread.gmane.org/gmane.linux.ide/40728

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] ub: use __blk_end_request_all()
  2009-05-19  9:33 [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2 Tejun Heo
@ 2009-05-19  9:33 ` Tejun Heo
  2009-05-19  9:33 ` [PATCH 2/3] block: set rq->resid_len to blk_rq_bytes() on issue Tejun Heo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2009-05-19  9:33 UTC (permalink / raw)
  To: linux-ide, jens.axboe, bharrosh, linux-kernel, linux-scsi,
	bzolnier, petkovbb, zaitcev@
  Cc: Tejun Heo

ub_end_rq() always tries to complete full request.  The @cmd_len
parameter was there because rq->data_len used to be overwritten with
residue count.  Drop @cmd_len and use __blk_end_request_all().

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Pete Zaitcev <zaitcev@redhat.com>
---
 drivers/block/ub.c |   24 +++++++-----------------
 1 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 178f459..f32781c 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -360,8 +360,7 @@ static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
 static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
     struct ub_scsi_cmd *cmd, struct ub_request *urq);
 static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
-static void ub_end_rq(struct request *rq, unsigned int status,
-    unsigned int cmd_len);
+static void ub_end_rq(struct request *rq, unsigned int status);
 static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
     struct ub_request *urq, struct ub_scsi_cmd *cmd);
 static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
@@ -644,13 +643,13 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
 
 	if (atomic_read(&sc->poison)) {
 		blk_start_request(rq);
-		ub_end_rq(rq, DID_NO_CONNECT << 16, blk_rq_bytes(rq));
+		ub_end_rq(rq, DID_NO_CONNECT << 16);
 		return 0;
 	}
 
 	if (lun->changed && !blk_pc_request(rq)) {
 		blk_start_request(rq);
-		ub_end_rq(rq, SAM_STAT_CHECK_CONDITION, blk_rq_bytes(rq));
+		ub_end_rq(rq, SAM_STAT_CHECK_CONDITION);
 		return 0;
 	}
 
@@ -702,7 +701,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
 
 drop:
 	ub_put_cmd(lun, cmd);
-	ub_end_rq(rq, DID_ERROR << 16, blk_rq_bytes(rq));
+	ub_end_rq(rq, DID_ERROR << 16);
 	return 0;
 }
 
@@ -777,7 +776,6 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
 	struct ub_request *urq = cmd->back;
 	struct request *rq;
 	unsigned int scsi_status;
-	unsigned int cmd_len;
 
 	rq = urq->rq;
 
@@ -816,17 +814,14 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
 
 	urq->rq = NULL;
 
-	cmd_len = cmd->len;
 	ub_put_cmd(lun, cmd);
-	ub_end_rq(rq, scsi_status, cmd_len);
+	ub_end_rq(rq, scsi_status);
 	blk_start_queue(lun->disk->queue);
 }
 
-static void ub_end_rq(struct request *rq, unsigned int scsi_status,
-    unsigned int cmd_len)
+static void ub_end_rq(struct request *rq, unsigned int scsi_status)
 {
 	int error;
-	long rqlen;
 
 	if (scsi_status == 0) {
 		error = 0;
@@ -834,12 +829,7 @@ static void ub_end_rq(struct request *rq, unsigned int scsi_status,
 		error = -EIO;
 		rq->errors = scsi_status;
 	}
-	rqlen = blk_rq_bytes(rq);    /* Oddly enough, this is the residue. */
-	if (__blk_end_request(rq, error, cmd_len)) {
-		printk(KERN_WARNING DRV_NAME
-		    ": __blk_end_request blew, %s-cmd total %u rqlen %ld\n",
-		    blk_pc_request(rq)? "pc": "fs", cmd_len, rqlen);
-	}
+	__blk_end_request_all(rq, error);
 }
 
 static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
-- 
1.6.0.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] block: set rq->resid_len to blk_rq_bytes() on issue
  2009-05-19  9:33 [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2 Tejun Heo
  2009-05-19  9:33 ` [PATCH 1/3] ub: use __blk_end_request_all() Tejun Heo
@ 2009-05-19  9:33 ` Tejun Heo
  2009-05-19  9:33 ` [PATCH 3/3] bio: always copy back data for copied kernel requests Tejun Heo
  2009-05-19  9:39 ` [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2 Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2009-05-19  9:33 UTC (permalink / raw)
  To: linux-ide, jens.axboe, bharrosh, linux-kernel, linux-scsi,
	bzolnier, petkovbb, zaitcev@
  Cc: Tejun Heo, James Bottomley

In commit c3a4d78c580de4edc9ef0f7c59812fb02ceb037f, while introducing
rq->resid_len, the default value of residue count was changed from
full count to zero.  The conversion was done under the assumption that
when a request fails residue count wasn't defined.  However, Boaz and
James pointed out that this wasn't true and the residue count should
be preserved for failed requests too.

This patchset restores the original behavior by setting rq->resid_len
to blk_rq_bytes(rq) on request start and restoring explicit clearing
in affected drivers.  While at it, take advantage of the fact that
rq->resid_len is set to full count where applicable.

* ide-cd: rq->resid_len cleared on pc success

* mptsas: req->resid_len cleared on success

* sas_expander: rsp/req->resid_len cleared on success

* mpt2sas_transport: req->resid_len cleared on success

* ide-cd, ide-tape, mptsas, sas_host_smp, mpt2sas_transport, ub: take
  advantage of initial full count to simplify code

Boaz Harrosh spotted bug in resid_len initialization.  Fixed as
suggested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Borislav Petkov <petkovbb@googlemail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Boaz Harrosh <bharrosh@panasas.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Eric Moore <Eric.Moore@lsi.com>
Cc: Darrick J. Wong <djwong@us.ibm.com>
---
 block/blk-core.c                         |    5 +++--
 drivers/block/ub.c                       |    6 ++++--
 drivers/ide/ide-cd.c                     |    4 ++--
 drivers/ide/ide-tape.c                   |    2 +-
 drivers/message/fusion/mptsas.c          |    3 ++-
 drivers/scsi/libsas/sas_expander.c       |    4 ++++
 drivers/scsi/libsas/sas_host_smp.c       |    3 ---
 drivers/scsi/mpt2sas/mpt2sas_transport.c |    4 ++--
 8 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index a2d97de..e3f7e6a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1783,9 +1783,10 @@ void blk_start_request(struct request *req)
 	blk_dequeue_request(req);
 
 	/*
-	 * We are now handing the request to the hardware, add the
-	 * timeout handler.
+	 * We are now handing the request to the hardware, initialize
+	 * resid_len to full count and add the timeout handler.
 	 */
+	req->resid_len = blk_rq_bytes(req);
 	blk_add_timer(req);
 }
 EXPORT_SYMBOL(blk_start_request);
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index f32781c..e67bbae 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -781,8 +781,10 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
 
 	if (cmd->error == 0) {
 		if (blk_pc_request(rq)) {
-			if (cmd->act_len < blk_rq_bytes(rq))
-				rq->resid_len = blk_rq_bytes(rq) - cmd->act_len;
+			if (cmd->act_len >= rq->resid_len)
+				rq->resid_len = 0;
+			else
+				rq->resid_len -= cmd->act_len;
 			scsi_status = 0;
 		} else {
 			if (cmd->act_len != cmd->len) {
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 4c7792f..081aed6 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -699,6 +699,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 
 out_end:
 	if (blk_pc_request(rq) && rc == 0) {
+		rq->resid_len = 0;
 		blk_end_request_all(rq, 0);
 		hwif->rq = NULL;
 	} else {
@@ -718,8 +719,7 @@ out_end:
 
 		/* make sure it's fully ended */
 		if (blk_fs_request(rq) == 0) {
-			rq->resid_len = blk_rq_bytes(rq) -
-				(cmd->nbytes - cmd->nleft);
+			rq->resid_len -= cmd->nbytes - cmd->nleft;
 			if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE))
 				rq->resid_len += cmd->last_xfer_len;
 		}
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index e166045..683ff37 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -380,7 +380,7 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
 		}
 
 		tape->first_frame += blocks;
-		rq->resid_len = blk_rq_bytes(rq) - blocks * tape->blk_size;
+		rq->resid_len -= blocks * tape->blk_size;
 
 		if (pc->error) {
 			uptodate = 0;
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 4e6fcf0..79f5433 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1357,7 +1357,8 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 		smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;
 		memcpy(req->sense, smprep, sizeof(*smprep));
 		req->sense_len = sizeof(*smprep);
-		rsp->resid_len = blk_rq_bytes(rsp) - smprep->ResponseDataLength;
+		req->resid_len = 0;
+		rsp->resid_len -= smprep->ResponseDataLength;
 	} else {
 		printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n",
 		    ioc->name, __func__);
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 531af9e..54fa1e4 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1937,7 +1937,11 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 	if (ret > 0) {
 		/* positive number is the untransferred residual */
 		rsp->resid_len = ret;
+		req->resid_len = 0;
 		ret = 0;
+	} else if (ret == 0) {
+		rsp->resid_len = 0;
+		req->resid_len = 0;
 	}
 
 	return ret;
diff --git a/drivers/scsi/libsas/sas_host_smp.c b/drivers/scsi/libsas/sas_host_smp.c
index be9a951..1bc3b75 100644
--- a/drivers/scsi/libsas/sas_host_smp.c
+++ b/drivers/scsi/libsas/sas_host_smp.c
@@ -176,9 +176,6 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
 	resp_data[1] = req_data[1];
 	resp_data[2] = SMP_RESP_FUNC_UNK;
 
-	req->resid_len = blk_rq_bytes(req);
-	rsp->resid_len = blk_rq_bytes(rsp);
-
 	switch (req_data[1]) {
 	case SMP_REPORT_GENERAL:
 		req->resid_len -= 8;
diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c
index af95a44..5c65da5 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_transport.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c
@@ -1170,8 +1170,8 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 
 		memcpy(req->sense, mpi_reply, sizeof(*mpi_reply));
 		req->sense_len = sizeof(*mpi_reply);
-		rsp->resid_len = blk_rq_bytes(rsp) -
-				 mpi_reply->ResponseDataLength;
+		req->resid_len = 0;
+		rsp->resid_len -= mpi_reply->ResponseDataLength;
 	} else {
 		dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT
 		    "%s - no reply\n", ioc->name, __func__));
-- 
1.6.0.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] bio: always copy back data for copied kernel requests
  2009-05-19  9:33 [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2 Tejun Heo
  2009-05-19  9:33 ` [PATCH 1/3] ub: use __blk_end_request_all() Tejun Heo
  2009-05-19  9:33 ` [PATCH 2/3] block: set rq->resid_len to blk_rq_bytes() on issue Tejun Heo
@ 2009-05-19  9:33 ` Tejun Heo
  2009-05-19  9:39 ` [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2 Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2009-05-19  9:33 UTC (permalink / raw)
  To: linux-ide, jens.axboe, bharrosh, linux-kernel, linux-scsi,
	bzolnier, petkovbb, zaitcev@
  Cc: Tejun Heo, James Bottomley

When a read bio_copy_kern() request fails, the content of the bounce
buffer is not copied back.  However, as request failure doesn't
necessarily mean complete failure, the buffer state can be useful.
This behavior is also inconsistent with the user map counterpart and
causes the subtle difference between bounced and unbounced IO causes
confusion.

This patch makes bio_copy_kern_endio() ignore @err and always copy
back data on request completion.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Boaz Harrosh <bharrosh@panasas.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 fs/bio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/bio.c b/fs/bio.c
index 7bbc98f..ee3bc67 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1198,7 +1198,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
 		char *addr = page_address(bvec->bv_page);
 		int len = bmd->iovecs[i].bv_len;
 
-		if (read && !err)
+		if (read)
 			memcpy(p, addr, len);
 
 		__free_page(bvec->bv_page);
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2
  2009-05-19  9:33 [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2 Tejun Heo
                   ` (2 preceding siblings ...)
  2009-05-19  9:33 ` [PATCH 3/3] bio: always copy back data for copied kernel requests Tejun Heo
@ 2009-05-19  9:39 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2009-05-19  9:39 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, bharrosh, linux-kernel, linux-scsi, bzolnier, petkovbb,
	zaitcev, sshtylyov, Eric.Moore, djwong

On Tue, May 19 2009, Tejun Heo wrote:
> Hello,
> 
> This is the second take of fix-fallouts patchset.  The first one[L]
> was posted without header message.  Changes from the last take are
> 
> * ub change updated per Pete Zitcev's comment
> 
> * resid_len init bug spotted by Boaz Harrosh fixed
> 
> This patchset contains the following three patches.
> 
>   0001-ub-use-__blk_end_request_all.patch
>   0002-block-set-rq-resid_len-to-blk_rq_bytes-on-issue.patch
>   0003-bio-always-copy-back-data-for-copied-kernel-request.patch
> 
> 0001 updates ub to use __blk_end_request_all() and 0002 restores the
> original residue count behavior.  0003 makes sure kernel pc buffer is
> bounced back even on request failure as user pc ones do.  This
> inconsistency was discovered during discussion over residue count
> semantics.
> 
> This patchset contains the following changes.

Applied!

> 
>  block/blk-core.c                         |    5 +++--
>  drivers/block/ub.c                       |   30 +++++++++++-------------------
>  drivers/ide/ide-cd.c                     |    4 ++--
>  drivers/ide/ide-tape.c                   |    2 +-
>  drivers/message/fusion/mptsas.c          |    3 ++-
>  drivers/scsi/libsas/sas_expander.c       |    4 ++++
>  drivers/scsi/libsas/sas_host_smp.c       |    3 ---
>  drivers/scsi/mpt2sas/mpt2sas_transport.c |    4 ++--
>  fs/bio.c                                 |    2 +-
>  9 files changed, 26 insertions(+), 31 deletions(-)
> 
> Thanks.
> 
> --
> tejun
> 
> [L] http://thread.gmane.org/gmane.linux.ide/40728

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-05-19  9:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-19  9:33 [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2 Tejun Heo
2009-05-19  9:33 ` [PATCH 1/3] ub: use __blk_end_request_all() Tejun Heo
2009-05-19  9:33 ` [PATCH 2/3] block: set rq->resid_len to blk_rq_bytes() on issue Tejun Heo
2009-05-19  9:33 ` [PATCH 3/3] bio: always copy back data for copied kernel requests Tejun Heo
2009-05-19  9:39 ` [PATCHSET block#for-2.6.31] block: fix fallouts from recent cleanups, take#2 Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).