linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 12/30] blk_end_request: changing ub (take 4)
@ 2007-12-11 22:46 Kiyoshi Ueda
  2007-12-11 23:48 ` Pete Zaitcev
  0 siblings, 1 reply; 6+ messages in thread
From: Kiyoshi Ueda @ 2007-12-11 22:46 UTC (permalink / raw)
  To: jens.axboe
  Cc: linux-kernel, linux-scsi, linux-ide, dm-devel, j-nomura, k-ueda, zaitcev

This patch converts ub to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
---
 drivers/block/ub.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

Index: 2.6.24-rc4/drivers/block/ub.c
===================================================================
--- 2.6.24-rc4.orig/drivers/block/ub.c
+++ 2.6.24-rc4/drivers/block/ub.c
@@ -808,16 +808,16 @@ static void ub_rw_cmd_done(struct ub_dev
 
 static void ub_end_rq(struct request *rq, unsigned int scsi_status)
 {
-	int uptodate;
+	int error;
 
 	if (scsi_status == 0) {
-		uptodate = 1;
+		error = 0;
 	} else {
-		uptodate = 0;
+		error = -EIO;
 		rq->errors = scsi_status;
 	}
-	end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
-	end_that_request_last(rq, uptodate);
+	if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
+		BUG();
 }
 
 static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,

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

* Re: [PATCH 12/30] blk_end_request: changing ub (take 4)
  2007-12-11 22:46 [PATCH 12/30] blk_end_request: changing ub (take 4) Kiyoshi Ueda
@ 2007-12-11 23:48 ` Pete Zaitcev
  2007-12-12 20:38   ` Kiyoshi Ueda
  0 siblings, 1 reply; 6+ messages in thread
From: Pete Zaitcev @ 2007-12-11 23:48 UTC (permalink / raw)
  To: Kiyoshi Ueda
  Cc: jens.axboe, linux-kernel, linux-scsi, linux-ide, dm-devel,
	j-nomura, zaitcev

On Tue, 11 Dec 2007 17:46:47 -0500 (EST), Kiyoshi Ueda <k-ueda@ct.jp.nec.com> wrote:

>  	if (scsi_status == 0) {
> -		uptodate = 1;
> +		error = 0;
>  	} else {
> -		uptodate = 0;
> +		error = -EIO;
>  		rq->errors = scsi_status;
>  	}
> -	end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
> -	end_that_request_last(rq, uptodate);
> +	if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
> +		BUG();

Acked-by: Pete Zaitcev <zaitcev@redhat.com>

I follow the discussion, actually, and wanted to ask someone to look
closer if it's appropriate to use __blk_end_request() here.
My understanding was, blk_end_request() is the same thing, only
takes the queue lock. But then, should I refactor ub so that it
calls __blk_end_request if request function ends with an error
and blk_end_request if the end-of-IO even is processed? If not,
and the above is sufficient, why have blk_end_request at all?

-- Pete

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

* Re: [PATCH 12/30] blk_end_request: changing ub (take 4)
  2007-12-11 23:48 ` Pete Zaitcev
@ 2007-12-12 20:38   ` Kiyoshi Ueda
  2007-12-13 21:59     ` Pete Zaitcev
  0 siblings, 1 reply; 6+ messages in thread
From: Kiyoshi Ueda @ 2007-12-12 20:38 UTC (permalink / raw)
  To: zaitcev
  Cc: jens.axboe, linux-kernel, linux-scsi, linux-ide, dm-devel,
	j-nomura, k-ueda

Hi Pete,

On Tue, 11 Dec 2007 15:48:03 -0800, Pete Zaitcev <zaitcev@redhat.com> wrote:
> >  	if (scsi_status == 0) {
> > -		uptodate = 1;
> > +		error = 0;
> >  	} else {
> > -		uptodate = 0;
> > +		error = -EIO;
> >  		rq->errors = scsi_status;
> >  	}
> > -	end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
> > -	end_that_request_last(rq, uptodate);
> > +	if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
> > +		BUG();
> 
> Acked-by: Pete Zaitcev <zaitcev@redhat.com>
> 
> I follow the discussion, actually, and wanted to ask someone to look
> closer if it's appropriate to use __blk_end_request() here.
> My understanding was, blk_end_request() is the same thing, only
> takes the queue lock. But then, should I refactor ub so that it
> calls __blk_end_request if request function ends with an error
> and blk_end_request if the end-of-IO even is processed? If not,
> and the above is sufficient, why have blk_end_request at all?

The difference between blk_end_request() and __blk_end_request() is
whether the queue lock is held or not when end_that_request_last()
is called.
It's not relevant to the status of the request (error or not).

I'm using __blk_end_request() here and I think it's sufficient, because:
  o end_that_request_last() must be called with the queue lock held
  o ub_end_rq() calls end_that_request_last() without taking
    the queue lock in itself.
    So the queue lock must have been taken outside ub_end_rq().

But, if ub is calling end_that_request_last() without the queue lock,
it is a bug in the original code and we should use blk_end_request()
to fix that.

Does that answer satisfy you?

Thanks,
Kiyoshi Ueda

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

* Re: [PATCH 12/30] blk_end_request: changing ub (take 4)
  2007-12-12 20:38   ` Kiyoshi Ueda
@ 2007-12-13 21:59     ` Pete Zaitcev
  2007-12-14 17:04       ` Kiyoshi Ueda
  0 siblings, 1 reply; 6+ messages in thread
From: Pete Zaitcev @ 2007-12-13 21:59 UTC (permalink / raw)
  To: Kiyoshi Ueda
  Cc: jens.axboe, linux-kernel, linux-scsi, linux-ide, dm-devel,
	j-nomura, zaitcev

On Wed, 12 Dec 2007 15:38:15 -0500 (EST), Kiyoshi Ueda <k-ueda@ct.jp.nec.com> wrote:
> On Tue, 11 Dec 2007 15:48:03 -0800, Pete Zaitcev <zaitcev@redhat.com> wrote:

> > > -	end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
> > > -	end_that_request_last(rq, uptodate);
> > > +	if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
> > > +		BUG();

> > My understanding was, blk_end_request() is the same thing, only
> > takes the queue lock. But then, should I refactor ub so that it
> > calls __blk_end_request if request function ends with an error
> > and blk_end_request if the end-of-IO even is processed?

> I'm using __blk_end_request() here and I think it's sufficient, because:
>   o end_that_request_last() must be called with the queue lock held
>   o ub_end_rq() calls end_that_request_last() without taking
>     the queue lock in itself.
>     So the queue lock must have been taken outside ub_end_rq().

> But, if ub is calling end_that_request_last() without the queue lock,
> it is a bug in the original code and we should use blk_end_request()
> to fix that.

So, I have to rewrite ub to split the paths after all, right?
Let's do this then: I'll wait until your patch gets to Linus and
then update it with the split. The reason is, I need the whole
enchilada applied and I don't want to bother tracking iterations
and all the little segments (of which you already have 30).
Until then, ub will have a race by using your original small patch.

Best wishes,
-- Pete

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

* Re: [PATCH 12/30] blk_end_request: changing ub (take 4)
  2007-12-13 21:59     ` Pete Zaitcev
@ 2007-12-14 17:04       ` Kiyoshi Ueda
  2007-12-14 19:49         ` Pete Zaitcev
  0 siblings, 1 reply; 6+ messages in thread
From: Kiyoshi Ueda @ 2007-12-14 17:04 UTC (permalink / raw)
  To: zaitcev
  Cc: jens.axboe, linux-kernel, linux-scsi, linux-ide, dm-devel,
	j-nomura, k-ueda

Hi Pete,

On Thu, 13 Dec 2007 13:59:16 -0800, Pete Zaitcev <zaitcev@redhat.com> wrote:
> > > > -	end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
> > > > -	end_that_request_last(rq, uptodate);
> > > > +	if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
> > > > +		BUG();
> > >
> > > My understanding was, blk_end_request() is the same thing, only
> > > takes the queue lock. But then, should I refactor ub so that it
> > > calls __blk_end_request if request function ends with an error
> > > and blk_end_request if the end-of-IO even is processed?
> >
> > I'm using __blk_end_request() here and I think it's sufficient, because:
> >   o end_that_request_last() must be called with the queue lock held
> >   o ub_end_rq() calls end_that_request_last() without taking
> >     the queue lock in itself.
> >     So the queue lock must have been taken outside ub_end_rq().
> >
> > But, if ub is calling end_that_request_last() without the queue lock,
> > it is a bug in the original code and we should use blk_end_request()
> > to fix that.
> 
> So, I have to rewrite ub to split the paths after all, right?
> Let's do this then: I'll wait until your patch gets to Linus and
> then update it with the split. The reason is, I need the whole
> enchilada applied and I don't want to bother tracking iterations
> and all the little segments (of which you already have 30).
> Until then, ub will have a race by using your original small patch.

No.
Are you doubting that the current ub code has the problem, aren't you?
My patch shouldn't introduce a NEW problem to ub.

I have investigated all code paths which call ub_end_rq() in ub.c,
and confirmed that ub_end_rq() is always called with the queue lock
held.  (sc->lock is registered as a queue lock.)

So there is no such race in the current ub code.
You don't need to rewrite ub.

Thanks,
Kiyoshi Ueda

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

* Re: [PATCH 12/30] blk_end_request: changing ub (take 4)
  2007-12-14 17:04       ` Kiyoshi Ueda
@ 2007-12-14 19:49         ` Pete Zaitcev
  0 siblings, 0 replies; 6+ messages in thread
From: Pete Zaitcev @ 2007-12-14 19:49 UTC (permalink / raw)
  To: Kiyoshi Ueda
  Cc: jens.axboe, linux-kernel, linux-scsi, linux-ide, dm-devel,
	j-nomura, zaitcev

On Fri, 14 Dec 2007 12:04:54 -0500 (EST), Kiyoshi Ueda <k-ueda@ct.jp.nec.com> wrote:

> I have investigated all code paths which call ub_end_rq() in ub.c,
> and confirmed that ub_end_rq() is always called with the queue lock
> held.  (sc->lock is registered as a queue lock.)

Thanks for reminding me about blk_init_queue, I forgot. Sorry for the
confusion.

Greetings,
-- Pete

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

end of thread, other threads:[~2007-12-14 19:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-11 22:46 [PATCH 12/30] blk_end_request: changing ub (take 4) Kiyoshi Ueda
2007-12-11 23:48 ` Pete Zaitcev
2007-12-12 20:38   ` Kiyoshi Ueda
2007-12-13 21:59     ` Pete Zaitcev
2007-12-14 17:04       ` Kiyoshi Ueda
2007-12-14 19:49         ` Pete Zaitcev

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).