Skip to contentSkip to conversation

block: change blk_check_merge_flags() implementation

RFC New yalin wang 1 participant 1 message Nov 20, 2015 Block layer

lore
Share & tools
lore

yalin wang

author
#0 lore raw

RFC 1/1 block: change blk_check_merge_flags() implementation

Use XOR to chenk some flags in flags1 and flags2 if the same, much faster on some platforms.

---
 include/linux/blkdev.h | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
include/linux/blkdev.h +1 -10
index c401ecd..3d0f053 100644
@@ -655,16 +655,7 @@ static inline bool rq_mergeable(struct request *rq)
 static inline bool blk_check_merge_flags(unsigned int flags1,
 					 unsigned int flags2)
 {
-	if ((flags1 & REQ_DISCARD) != (flags2 & REQ_DISCARD))
-		return false;
-
-	if ((flags1 & REQ_SECURE) != (flags2 & REQ_SECURE))
-		return false;
-
-	if ((flags1 & REQ_WRITE_SAME) != (flags2 & REQ_WRITE_SAME))
-		return false;
-
-	return true;
+	return !((flags1 ^ flags2) & (REQ_DISCARD | REQ_SECURE | REQ_WRITE_SAME));
 }
 
 static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b)
Signature · 1 line
1.9.1