blk: use REQ_OP_WRITE instead of hard code
PATCH 1/1 blk: use REQ_OP_WRITE instead of hard code
use REQ_OP_WRITE instead of hard code inop_is_write().
--- include/linux/blk_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blk_types.h +1 -1
@@ -440,7 +440,7 @@ static inline void bio_set_op_attrs(struct bio *bio, unsigned op,static inline bool op_is_write (unsigned int op) { -return (op &1 ); +return (op &REQ_OP_WRITE ); }/*
Signature · 1 line
2.25.1
Quoted 13 lines · Hui Su
use
REQ_OP_WRITEinstead of hard code inop_is_write().Signed-off-by Hui Su <[email protected]>--- include/linux/blk_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/blk_types.h +0
-0
include/linux/blk_types.h static inline void bio_set_op_attrs(struct bio *bio, unsigned op, · line 443
Quoted 5 lines
include/linux/blk_types.h +1
-1@@ -440,7 +440,7 @@ static inline void bio_set_op_attrs(struct bio *bio, unsigned op,static inline bool op_is_write (unsigned int op) { -return (op &1 ); +return (op &REQ_OP_WRITE );
op_is_write() returns true for every req_op that writes to a device (they all have the lowest bit set), while REQ_OP_WRITE means a WRITE. You'll change the semantics with this patch.
Yeah, you are right, thanks for your explanation<br/><br/>Maybe we should define a MASK to do this?
Quoted 23 lines · Johannes Thumshirn
Quoted 13 lines · Hui Su
use
REQ_OP_WRITEinstead of hard code inop_is_write().Signed-off-by Hui Su <[email protected]>--- include/linux/blk_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/blk_types.h +0
-0include/linux/blk_types.h static inline void bio_set_op_attrs(struct bio *bio, unsigned op, · line 443
Quoted 5 lines
include/linux/blk_types.h +1
-1@@ -440,7 +440,7 @@ static inline void bio_set_op_attrs(struct bio *bio, unsigned op,static inline bool op_is_write (unsigned int op) { -return (op &1 ); +return (op &REQ_OP_WRITE );
op_is_write()returns true for everyreq_opthat writes to a device (they all have the lowest bit set), whileREQ_OP_WRITEmeans a WRITE. You'll change the semantics with this patch.
Quoted 1 line · 苏辉
Yeah, you are right, thanks for your explanation<br/><br/>Maybe we should define a MASK to do this?
Why? I personally find a '& 1' way more understandable than a REQ_OP_IS_WRITE_MASK or sth like that. The former I can just read, for the latter I would need to look up the definition to be able to understand the code.