[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1396451946-13924-1-git-send-email-nasa4836@gmail.com>
Date: Wed, 2 Apr 2014 23:19:06 +0800
From: Jianyu Zhan <nasa4836@...il.com>
To: axboe@...nel.dk
Cc: hch@....de, jack@...e.cz, viro@...iv.linux.org.uk,
kmo@...erainc.com, namjae.jeon@...sung.com, nasa4836@...il.com,
linux-kernel@...r.kernel.org
Subject: [PATCH] blkdev: use an efficient way to check merge flags
A bitwise flag comparison could be done using a more efficient bit-ops way.
Signed-off-by: Jianyu Zhan <nasa4836@...il.com>
---
include/linux/blkdev.h | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 1e1fa3f..adfa40a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -655,16 +655,9 @@ 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 & (REQ_DISCARD | REQ_SECURE | REQ_WRITE_SAME)) ^
+ (flags2 & (REQ_DISCARD | REQ_SECURE | REQ_WRITE_SAME))
+ == 0;
}
static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b)
--
1.9.0.GIT
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists