Skip to contentSkip to conversation

block: fix failfast merge testing in elv_rq_merge_ok()

PATCH In review Tejun Heo 2 participants 7 messages Jul 16, 2009 – Jul 17, 2009 Block layer

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 block: fix failfast merge testing in elv_rq_merge_ok()

Commit ab0fd1debe730ec9998678a0c53caefbd121ed10 tries to prevent merge of requests with different failfast settings. In elv_rq_merge_ok(), it compares new bio's failfast flags against the merge target request's. However, the flag testing accessors for bio and blk don't return boolean but the tested bit value directly and FAILFAST on bio and blk don't match, so directly comparing them with == results in false negative unnecessary preventing merge of readahead requests.

This patch convert the results to boolean by negating them before comparison.

Cc Jens Axboe <[email protected]>
Cc Boaz Harrosh <[email protected]>
Cc FUJITA Tomonori <[email protected]>
Cc James Bottomley <[email protected]>
Cc Jeff Garzik <[email protected]>

---
Eh... talk about being obscure. :-( I've put this onto the following temp block tree I'm running and will push toward Linus in a few days.

git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git tj-block-for-linus

Thanks.

 block/elevator.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
block/elevator.c +3 -3
index 6f23753..977aa7c 100644
@@ -103,9 +103,9 @@ int elv_rq_merge_ok(struct request *rq, struct bio *bio)
 	/*
 	 * Don't merge if failfast settings don't match
 	 */
-	if (bio_failfast_dev(bio)	!= blk_failfast_dev(rq)		||
-	    bio_failfast_transport(bio)	!= blk_failfast_transport(rq)	||
-	    bio_failfast_driver(bio)	!= blk_failfast_driver(rq))
+	if (!bio_failfast_dev(bio)	 != !blk_failfast_dev(rq)	||
+	    !bio_failfast_transport(bio) != !blk_failfast_transport(rq)	||
+	    !bio_failfast_driver(bio)	 != !blk_failfast_driver(rq))
 		return 0;
 
 	if (!elv_iosched_allow_merge(rq, bio))
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 10 lines · Tejun Heo

Commit ab0fd1debe730ec9998678a0c53caefbd121ed10 tries to prevent merge of requests with different failfast settings. In elv_rq_merge_ok(), it compares new bio's failfast flags against the merge target request's. However, the flag testing accessors for bio and blk don't return boolean but the tested bit value directly and FAILFAST on bio and blk don't match, so directly comparing them with == results in false negative unnecessary preventing merge of readahead requests.

This patch convert the results to boolean by negating them before comparison.

I don't like that at all. Please fix the accessors to return boolean. They look and regarded as boolean. I've never seen them used as their bit value.

if you are concerned with performance don't
an if(flag & bit) is even slightly slower then
if(0 != (flag & bit)) on some processors

Quoted 24 lines
Cc Jens Axboe <[email protected]>
Cc Boaz Harrosh <[email protected]>
Cc FUJITA Tomonori <[email protected]>
Cc James Bottomley <[email protected]>
Cc Jeff Garzik <[email protected]>

---
Eh... talk about being obscure. :-( I've put this onto the following temp block tree I'm running and will push toward Linus in a few days.

git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git tj-block-for-linus

Thanks.

 block/elevator.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
block/elevator.c +0 -0
index 6f23753..977aa7c 100644
@@ -103,9 +103,9 @@ int elv_rq_merge_ok(struct request *rq, struct bio *bio)
 	/*
 	 * Don't merge if failfast settings don't match

block/elevator.c int elv_rq_merge_ok(struct request *rq, struct bio *bio) · line 111

Quoted 10 lines
block/elevator.c +3 -3
 	 */
-	if (bio_failfast_dev(bio)	!= blk_failfast_dev(rq)		||
-	    bio_failfast_transport(bio)	!= blk_failfast_transport(rq)	||
-	    bio_failfast_driver(bio)	!= blk_failfast_driver(rq))
+	if (!bio_failfast_dev(bio)	 != !blk_failfast_dev(rq)	||
+	    !bio_failfast_transport(bio) != !blk_failfast_transport(rq)	||
+	    !bio_failfast_driver(bio)	 != !blk_failfast_driver(rq))
 		return 0;
 
 	if (!elv_iosched_allow_merge(rq, bio))

Boaz

author
#2 lore raw
Quoted 9 lines · Boaz Harrosh
Quoted 8 lines · Tejun Heo

Commit ab0fd1debe730ec9998678a0c53caefbd121ed10 tries to prevent merge of requests with different failfast settings. In elv_rq_merge_ok(), it compares new bio's failfast flags against the merge target request's. However, the flag testing accessors for bio and blk don't return boolean but the tested bit value directly and FAILFAST on bio and blk don't match, so directly comparing them with == results in false negative unnecessary preventing merge of readahead requests.

Quoted 6 lines
Quoted 2 lines

This patch convert the results to boolean by negating them before comparison.

I don't like that at all. Please fix the accessors to return boolean. They look and regarded as boolean. I've never seen them used as their bit value.

Yeah, I'll be happier that way but please note that this patch is only for 2.6.31. 2.6.32 won't have this code at all and we're past the merge window, so the smallest fix wins in this case, I think. Also, changing only some of the accessors will increase the level of confusion while changing all of them for 2.6.31 at this point is way too invasive (there can be cases where the bit mask return value is depended upon).

Looks like the flags are gonna go through considerable cleanup pretty soon, so let's postpone small things till then.

Quoted 3 lines

if you are concerned with performance don't
an if(flag & bit) is even slightly slower then
if(0 != (flag & bit)) on some processors

I wasn't worried about the performance at all.

Thanks.

Signature · 1 line
tejun
#3 lore raw
Quoted 16 lines · Tejun Heo
Quoted 9 lines · Boaz Harrosh
Quoted 8 lines · Tejun Heo

Commit ab0fd1debe730ec9998678a0c53caefbd121ed10 tries to prevent merge of requests with different failfast settings. In elv_rq_merge_ok(), it compares new bio's failfast flags against the merge target request's. However, the flag testing accessors for bio and blk don't return boolean but the tested bit value directly and FAILFAST on bio and blk don't match, so directly comparing them with == results in false negative unnecessary preventing merge of readahead requests.

Quoted 5 lines
Quoted 2 lines

This patch convert the results to boolean by negating them before comparison.

I don't like that at all. Please fix the accessors to return boolean. They look and regarded as boolean. I've never seen them used as their bit value.

Quoted 8 lines

Yeah, I'll be happier that way but please note that this patch is only for 2.6.31. 2.6.32 won't have this code at all and we're past the merge window, so the smallest fix wins in this case, I think. Also, changing only some of the accessors will increase the level of confusion while changing all of them for 2.6.31 at this point is way too invasive (there can be cases where the bit mask return value is depended upon).

OK So could you put a FIXME: and fat comment, on that weird "!"(s) everywhere?

Quoted 11 lines

Looks like the flags are gonna go through considerable cleanup pretty soon, so let's postpone small things till then.

Quoted 3 lines

if you are concerned with performance don't
an if(flag & bit) is even slightly slower then
if(0 != (flag & bit)) on some processors

I wasn't worried about the performance at all.

Thanks.

Thanks

author
#4 lore raw
Quoted 2 lines · Boaz Harrosh

OK So could you put a FIXME: and fat comment, on that weird "!"(s) everywhere?

Yeap, sure. How about something like the following?

/*
* Don't merge if failfast settings don't match. The negation
* in front of each condition is necessary because bio and
* request flags use different bit positions and the accessors
* return those bits directly. This ugliness will soon go
* away.
*/

Signature · 1 line
tejun
#5 lore raw
Quoted 8 lines · Tejun Heo
Quoted 2 lines · Boaz Harrosh

OK So could you put a FIXME: and fat comment, on that weird "!"(s) everywhere?

Yeap, sure. How about something like the following?

	/*
	 * Don't merge if failfast settings don't match.  The negation

- * Don't merge if failfast settings don't match. The negation
+ * Don't merge if failfast settings don't match.
+ * FIXME: The negation ...

Quoted 6 lines

* in front of each condition is necessary because bio and
* request flags use different bit positions and the accessors
* return those bits directly. This ugliness will soon go
* away.
*/

Boaz

author
#6 lore raw

Review

Quoted 12 lines · Boaz Harrosh
Quoted 7 lines · Tejun Heo
Quoted 2 lines · Boaz Harrosh

OK So could you put a FIXME: and fat comment, on that weird "!"(s) everywhere?

Yeap, sure. How about something like the following?

	/*
	 * Don't merge if failfast settings don't match.  The negation
(quoted diff) +2 -1
- 	 * Don't merge if failfast settings don't match.  The negation
+ 	 * Don't merge if failfast settings don't match.
+	 * FIXME:   The negation ...

So updated. Thanks.

Signature · 1 line
tejun