Patchwork ide: no need to check for the rq pointer to be NULL

login
register
mail settings
Submitter Vasily Tarasov
Date Jan. 9, 2011, 11:51 p.m.
Message ID <20110109235146.GA5353@white.fsl.cs.sunysb.edu>
Download mbox | patch
Permalink /patch/78063/
State Rejected
Delegated to: David Miller
Headers show

Comments

Vasily Tarasov - Jan. 9, 2011, 11:51 p.m.
From: Vasily Tarasov <sectorsize512@gmail.com>

No need to check for the rq pointer to be NULL before calling
blk_fetch_request().  First we call it, then we test the pointer that it
returns.

Signed-off-by: Vasily Tarasov <sectorsize512@gmail.com>

---

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov - Jan. 10, 2011, 12:25 p.m.
Hello.

On 10-01-2011 2:51, Vasily Tarasov wrote:

> From: Vasily Tarasov<sectorsize512@gmail.com>

> No need to check for the rq pointer to be NULL before calling
> blk_fetch_request().  First we call it, then we test the pointer that it
> returns.

> Signed-off-by: Vasily Tarasov<sectorsize512@gmail.com>

    I'm not feeling sure about this patch...

> --- linux-2.6.37/drivers/ide/ide-io.c.orig	2011-01-04 19:50:19.000000000 -0500
> +++ linux-2.6.37/drivers/ide/ide-io.c	2011-01-09 18:15:44.000000000 -0500
> @@ -438,7 +438,7 @@ void do_ide_request(struct request_queue
>   	ide_drive_t	*drive = q->queuedata;
>   	ide_hwif_t	*hwif = drive->hwif;
>   	struct ide_host *host = hwif->host;
> -	struct request	*rq = NULL;
> +	struct request	*rq;
>   	ide_startstop_t	startstop;
>
>   	spin_unlock_irq(q->queue_lock);
> @@ -485,16 +485,13 @@ repeat:
>
>   		spin_unlock_irq(&hwif->lock);
>   		spin_lock_irq(q->queue_lock);
> +		rq = blk_fetch_request(drive->queue);
> +		spin_unlock_irq(q->queue_lock);
> +		spin_lock_irq(&hwif->lock);
>   		/*
>   		 * we know that the queue isn't empty, but this can happen
>   		 * if the q->prep_rq_fn() decides to kill a request
>   		 */
> -		if (!rq)
> -			rq = blk_fetch_request(drive->queue);

    Did you consider the scenario where the 'goto' is taken at the end of this 
*if* branch? 'rq' is non-NULL then...

> -
> -		spin_unlock_irq(q->queue_lock);
> -		spin_lock_irq(&hwif->lock);
> -
>   		if (!rq) {
>   			ide_unlock_port(hwif);
>   			goto out;

WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vasily Tarasov - Jan. 10, 2011, 5:30 p.m.
Ooops, you're right, ide_kill_rq() sets  hwif->rq (and rq in turn) to NULL.
Please disregard this patch.

Vasily

On Mon, Jan 10, 2011 at 03:25:47PM +0300, Sergei Shtylyov wrote:
> Hello.
> 
> On 10-01-2011 2:51, Vasily Tarasov wrote:
> 
> >From: Vasily Tarasov<sectorsize512@gmail.com>
> 
> >No need to check for the rq pointer to be NULL before calling
> >blk_fetch_request().  First we call it, then we test the pointer that it
> >returns.
> 
> >Signed-off-by: Vasily Tarasov<sectorsize512@gmail.com>
> 
>    I'm not feeling sure about this patch...
> 
> >--- linux-2.6.37/drivers/ide/ide-io.c.orig	2011-01-04 19:50:19.000000000 -0500
> >+++ linux-2.6.37/drivers/ide/ide-io.c	2011-01-09 18:15:44.000000000 -0500
> >@@ -438,7 +438,7 @@ void do_ide_request(struct request_queue
> >  	ide_drive_t	*drive = q->queuedata;
> >  	ide_hwif_t	*hwif = drive->hwif;
> >  	struct ide_host *host = hwif->host;
> >-	struct request	*rq = NULL;
> >+	struct request	*rq;
> >  	ide_startstop_t	startstop;
> >
> >  	spin_unlock_irq(q->queue_lock);
> >@@ -485,16 +485,13 @@ repeat:
> >
> >  		spin_unlock_irq(&hwif->lock);
> >  		spin_lock_irq(q->queue_lock);
> >+		rq = blk_fetch_request(drive->queue);
> >+		spin_unlock_irq(q->queue_lock);
> >+		spin_lock_irq(&hwif->lock);
> >  		/*
> >  		 * we know that the queue isn't empty, but this can happen
> >  		 * if the q->prep_rq_fn() decides to kill a request
> >  		 */
> >-		if (!rq)
> >-			rq = blk_fetch_request(drive->queue);
> 
>    Did you consider the scenario where the 'goto' is taken at the
> end of this *if* branch? 'rq' is non-NULL then...
> 
> >-
> >-		spin_unlock_irq(q->queue_lock);
> >-		spin_lock_irq(&hwif->lock);
> >-
> >  		if (!rq) {
> >  			ide_unlock_port(hwif);
> >  			goto out;
> 
> WBR, Serge
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov - Jan. 10, 2011, 6:03 p.m.
Vasily Tarasov wrote:

> Ooops, you're right, ide_kill_rq() sets  hwif->rq (and rq in turn) to NULL.

    Frankly speaking, I don't see where...

WBR, Serge
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- linux-2.6.37/drivers/ide/ide-io.c.orig	2011-01-04 19:50:19.000000000 -0500
+++ linux-2.6.37/drivers/ide/ide-io.c	2011-01-09 18:15:44.000000000 -0500
@@ -438,7 +438,7 @@  void do_ide_request(struct request_queue
 	ide_drive_t	*drive = q->queuedata;
 	ide_hwif_t	*hwif = drive->hwif;
 	struct ide_host *host = hwif->host;
-	struct request	*rq = NULL;
+	struct request	*rq;
 	ide_startstop_t	startstop;
 
 	spin_unlock_irq(q->queue_lock);
@@ -485,16 +485,13 @@  repeat:
 
 		spin_unlock_irq(&hwif->lock);
 		spin_lock_irq(q->queue_lock);
+		rq = blk_fetch_request(drive->queue);
+		spin_unlock_irq(q->queue_lock);
+		spin_lock_irq(&hwif->lock);
 		/*
 		 * we know that the queue isn't empty, but this can happen
 		 * if the q->prep_rq_fn() decides to kill a request
 		 */
-		if (!rq)
-			rq = blk_fetch_request(drive->queue);
-
-		spin_unlock_irq(q->queue_lock);
-		spin_lock_irq(&hwif->lock);
-
 		if (!rq) {
 			ide_unlock_port(hwif);
 			goto out;