LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Fix soft lockup with iSeries viocd driver
@ 2007-02-27  5:55 Tony Breeds
  2007-02-27 14:33 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Tony Breeds @ 2007-02-27  5:55 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Stephen Rothwell, Linux Kernel ML

From: Tony Breeds <tony@bakeyournoodle.com>

Fix soft lockup with iSeries viocd driver, caused by eventually calling
end_that_request_first() with nr_bytes 0.

The lockup is triggered by hald, interrogating the device.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>

---
Implementation based on drivers/ide/ide-io.c:ide_end_request()

 viocd.c |   24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

Index: linux-2.6.20-rc5/drivers/cdrom/viocd.c
===================================================================
--- linux-2.6.20-rc5.orig/drivers/cdrom/viocd.c
+++ linux-2.6.20-rc5/drivers/cdrom/viocd.c
@@ -376,6 +376,22 @@ static int send_request(struct request *
        return 0;
 }
 
+static void viocd_end_request(struct request *req, int uptodate)
+{
+       int nsectors = req->hard_cur_sectors;
+
+       /* Make sure it's fully ended */
+       if (blk_pc_request(req))
+               nsectors = (req->data_len + 511) >> 9;
+       if (!nsectors)
+               nsectors = 1;
+
+       if (!end_that_request_first(req, uptodate, nsectors)) {
+               add_disk_randomness(req->rq_disk);
+               blkdev_dequeue_request(req);
+               end_that_request_last(req, uptodate);
+       }
+}
 
 static int rwreq;
 
@@ -385,11 +401,11 @@ static void do_viocd_request(request_que
 
        while ((rwreq == 0) && ((req = elv_next_request(q)) != NULL)) {
                if (!blk_fs_request(req))
-                       end_request(req, 0);
+                       viocd_end_request(req, 0);
                else if (send_request(req) < 0) {
                        printk(VIOCD_KERN_WARNING
                                        "unable to send message to OS/400!");
-                       end_request(req, 0);
+                       viocd_end_request(req, 0);
                } else
                        rwreq++;
        }
@@ -601,9 +617,9 @@ return_complete:
                                        "with rc %d:0x%04X: %s\n",
                                        req, event->xRc,
                                        bevent->sub_result, err->msg);
-                       end_request(req, 0);
+                       viocd_end_request(req, 0);
                } else
-                       end_request(req, 1);
+                       viocd_end_request(req, 1);
 
                /* restart handling of incoming requests */
                spin_unlock_irqrestore(&viocd_reqlock, flags);




Yours Tony

  linux.conf.au        http://linux.conf.au/ || http://lca2008.linux.org.au/
  Jan 28 - Feb 02 2008 The Australian Linux Technical Conference!


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

* Re: Fix soft lockup with iSeries viocd driver
  2007-02-27  5:55 Fix soft lockup with iSeries viocd driver Tony Breeds
@ 2007-02-27 14:33 ` Jens Axboe
  2007-02-27 23:42   ` Tony Breeds
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2007-02-27 14:33 UTC (permalink / raw)
  To: Stephen Rothwell, Linux Kernel ML

On Tue, Feb 27 2007, Tony Breeds wrote:
> From: Tony Breeds <tony@bakeyournoodle.com>
> 
> Fix soft lockup with iSeries viocd driver, caused by eventually calling
> end_that_request_first() with nr_bytes 0.
> 
> The lockup is triggered by hald, interrogating the device.
> 
> Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
> 
> ---
> Implementation based on drivers/ide/ide-io.c:ide_end_request()
> 
>  viocd.c |   24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> Index: linux-2.6.20-rc5/drivers/cdrom/viocd.c
> ===================================================================
> --- linux-2.6.20-rc5.orig/drivers/cdrom/viocd.c
> +++ linux-2.6.20-rc5/drivers/cdrom/viocd.c
> @@ -376,6 +376,22 @@ static int send_request(struct request *
>         return 0;
>  }
>  
> +static void viocd_end_request(struct request *req, int uptodate)
> +{
> +       int nsectors = req->hard_cur_sectors;
> +
> +       /* Make sure it's fully ended */
> +       if (blk_pc_request(req))
> +               nsectors = (req->data_len + 511) >> 9;
> +       if (!nsectors)
> +               nsectors = 1;
> +
> +       if (!end_that_request_first(req, uptodate, nsectors)) {
> +               add_disk_randomness(req->rq_disk);
> +               blkdev_dequeue_request(req);
> +               end_that_request_last(req, uptodate);
> +       }
> +}

It looks ok (better than end_request()), though it would still be nice
to properly end requests. See the recent thread on the lguest block
driver.

-- 
Jens Axboe


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

* Re: Fix soft lockup with iSeries viocd driver
  2007-02-27 14:33 ` Jens Axboe
@ 2007-02-27 23:42   ` Tony Breeds
  2007-02-28 12:16     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Tony Breeds @ 2007-02-27 23:42 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Stephen Rothwell, Linux Kernel ML

On Tue, Feb 27, 2007 at 03:33:34PM +0100, Jens Axboe wrote:

> It looks ok (better than end_request()), though it would still be nice
> to properly end requests. See the recent thread on the lguest block
> driver.

Hi Jens,
	I read through the lguest thread and came up with the patch
below, I hope I understood correctly.  We still need to do the check to
make sure we ask for at least one sector to be processed in
end_that_request_first(), as the request that triggers the lockup here
(an sg_io ioctl in this case), has both req->hard_nr_sectors and
req->hard_cur_sectors = 0.

From: Tony Breeds <tony@bakeyournoodle.com>

Fix soft lockup with iSeries viocd driver, caused by eventually calling
end_that_request_first() with nr_bytes 0.

The lockup is triggered by hald, interrogating the device.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>

---
 viocd.c |   27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

Index: linux-2.6.20-rc5/drivers/cdrom/viocd.c
===================================================================
--- linux-2.6.20-rc5.orig/drivers/cdrom/viocd.c
+++ linux-2.6.20-rc5/drivers/cdrom/viocd.c
@@ -376,6 +376,25 @@ static int send_request(struct request *
        return 0;
 }
 
+static void viocd_end_request(struct request *req, int uptodate)
+{
+       int nsectors = req->hard_nr_sectors;
+
+       /*
+        * Make sure it's fully ended, and ensure that we process
+        * at least one sector.
+        */
+       if (blk_pc_request(req))
+               nsectors = (req->data_len + 511) >> 9;
+       if (!nsectors)
+               nsectors = 1;
+
+       if (end_that_request_first(req, uptodate, nsectors))
+               BUG();
+       add_disk_randomness(req->rq_disk);
+       blkdev_dequeue_request(req);
+       end_that_request_last(req, uptodate);
+}
 
 static int rwreq;
 
@@ -385,11 +404,11 @@ static void do_viocd_request(request_que
 
        while ((rwreq == 0) && ((req = elv_next_request(q)) != NULL)) {
                if (!blk_fs_request(req))
-                       end_request(req, 0);
+                       viocd_end_request(req, 0);
                else if (send_request(req) < 0) {
                        printk(VIOCD_KERN_WARNING
                                        "unable to send message to OS/400!");
-                       end_request(req, 0);
+                       viocd_end_request(req, 0);
                } else
                        rwreq++;
        }
@@ -601,9 +620,9 @@ return_complete:
                                        "with rc %d:0x%04X: %s\n",
                                        req, event->xRc,
                                        bevent->sub_result, err->msg);
-                       end_request(req, 0);
+                       viocd_end_request(req, 0);
                } else
-                       end_request(req, 1);
+                       viocd_end_request(req, 1);
 
                /* restart handling of incoming requests */
                spin_unlock_irqrestore(&viocd_reqlock, flags);





Yours Tony

  linux.conf.au        http://linux.conf.au/ || http://lca2008.linux.org.au/
  Jan 28 - Feb 02 2008 The Australian Linux Technical Conference!


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

* Re: Fix soft lockup with iSeries viocd driver
  2007-02-27 23:42   ` Tony Breeds
@ 2007-02-28 12:16     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2007-02-28 12:16 UTC (permalink / raw)
  To: Stephen Rothwell, Linux Kernel ML

On Wed, Feb 28 2007, Tony Breeds wrote:
> On Tue, Feb 27, 2007 at 03:33:34PM +0100, Jens Axboe wrote:
> 
> > It looks ok (better than end_request()), though it would still be nice
> > to properly end requests. See the recent thread on the lguest block
> > driver.
> 
> Hi Jens,
> 	I read through the lguest thread and came up with the patch
> below, I hope I understood correctly.  We still need to do the check to
> make sure we ask for at least one sector to be processed in
> end_that_request_first(), as the request that triggers the lockup here
> (an sg_io ioctl in this case), has both req->hard_nr_sectors and
> req->hard_cur_sectors = 0.

Yep that looks better.

> From: Tony Breeds <tony@bakeyournoodle.com>
> 
> Fix soft lockup with iSeries viocd driver, caused by eventually calling
> end_that_request_first() with nr_bytes 0.
> 
> The lockup is triggered by hald, interrogating the device.
> 
> Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

-- 
Jens Axboe


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

end of thread, other threads:[~2007-02-28 12:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-27  5:55 Fix soft lockup with iSeries viocd driver Tony Breeds
2007-02-27 14:33 ` Jens Axboe
2007-02-27 23:42   ` Tony Breeds
2007-02-28 12:16     ` 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).