linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blk: use REQ_OP_WRITE instead of hard code
@ 2020-10-19 13:50 Hui Su
  2020-10-19 14:09 ` Johannes Thumshirn
  0 siblings, 1 reply; 4+ messages in thread
From: Hui Su @ 2020-10-19 13:50 UTC (permalink / raw)
  To: axboe, linux-block, linux-kernel, sh_def

use REQ_OP_WRITE instead of hard code in
op_is_write().

Signed-off-by: Hui Su <sh_def@163.com>
---
 include/linux/blk_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 7d7c13238fdb..7b9b02378c24 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -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);
 }
 
 /*
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] blk: use REQ_OP_WRITE instead of hard code
  2020-10-19 13:50 [PATCH] blk: use REQ_OP_WRITE instead of hard code Hui Su
@ 2020-10-19 14:09 ` Johannes Thumshirn
  2020-10-19 14:30   ` 苏辉
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Thumshirn @ 2020-10-19 14:09 UTC (permalink / raw)
  To: Hui Su, axboe, linux-block, linux-kernel

On 19/10/2020 16:06, Hui Su wrote:
> use REQ_OP_WRITE instead of hard code in
> op_is_write().
> 
> Signed-off-by: Hui Su <sh_def@163.com>
> ---
>  include/linux/blk_types.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
> index 7d7c13238fdb..7b9b02378c24 100644
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re:Re: [PATCH] blk: use REQ_OP_WRITE instead of hard code
  2020-10-19 14:09 ` Johannes Thumshirn
@ 2020-10-19 14:30   ` 苏辉
  2020-10-19 14:32     ` Johannes Thumshirn
  0 siblings, 1 reply; 4+ messages in thread
From: 苏辉 @ 2020-10-19 14:30 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: axboe, linux-block, linux-kernel

Yeah, you are right, thanks for your explanation<br/><br/>Maybe we should define a MASK to do this?
At 2020-10-19 22:09:40, "Johannes Thumshirn" <Johannes.Thumshirn@wdc.com> wrote:
>On 19/10/2020 16:06, Hui Su wrote:
>> use REQ_OP_WRITE instead of hard code in
>> op_is_write().
>> 
>> Signed-off-by: Hui Su <sh_def@163.com>
>> ---
>>  include/linux/blk_types.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
>> index 7d7c13238fdb..7b9b02378c24 100644
>> --- a/include/linux/blk_types.h
>> +++ b/include/linux/blk_types.h
>> @@ -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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] blk: use REQ_OP_WRITE instead of hard code
  2020-10-19 14:30   ` 苏辉
@ 2020-10-19 14:32     ` Johannes Thumshirn
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2020-10-19 14:32 UTC (permalink / raw)
  To: 苏辉; +Cc: axboe, linux-block, linux-kernel

On 19/10/2020 16:30, 苏辉 wrote:
> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-19 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 13:50 [PATCH] blk: use REQ_OP_WRITE instead of hard code Hui Su
2020-10-19 14:09 ` Johannes Thumshirn
2020-10-19 14:30   ` 苏辉
2020-10-19 14:32     ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).