path: root/block/blk.h
diff options
authorColy Li <>2020-07-17 10:42:29 +0800
committerJens Axboe <>2020-07-17 07:15:10 -0600
commitecdef9f459ad24bf987267df6c25967819016707 (patch)
tree2540f8c004f2dcc52ddd59d7bf2dbe9a8e61a887 /block/blk.h
parentb5718d6c00afe51ce5327cf2beae4019da0c8e74 (diff)
block: change REQ_OP_ZONE_RESET and REQ_OP_ZONE_RESET_ALL to be odd numbers
Currently REQ_OP_ZONE_RESET and REQ_OP_ZONE_RESET_ALL are defined as even numbers 6 and 8, such zone reset bios are treated as READ bios by bio_data_dir(), which is obviously misleading. The macro bio_data_dir() is defined in include/linux/bio.h as, 55 #define bio_data_dir(bio) \ 56 (op_is_write(bio_op(bio)) ? WRITE : READ) And op_is_write() is defined in include/linux/blk_types.h as, 397 static inline bool op_is_write(unsigned int op) 398 { 399 return (op & 1); 400 } The convention of op_is_write() is when there is data transfer then the op code should be odd number, and treat as a write op. bio_data_dir() treats all bio direction as READ if op_is_write() reports false, and WRITE if op_is_write() reports true. Because REQ_OP_ZONE_RESET and REQ_OP_ZONE_RESET_ALL are even numbers, although they don't transfer data but reporting them as READ bio by bio_data_dir() is misleading and might be wrong. Because these two commands will reset the writer pointers of the resetting zones, and all content after the reset write pointer will be invalid and unaccessible, obviously they are not READ bios in any means. This patch changes REQ_OP_ZONE_RESET from 6 to 15, and changes REQ_OP_ZONE_RESET_ALL from 8 to 17. Now bios with these two op code can be treated as WRITE by bio_data_dir(). Although they don't transfer data, now we keep them consistent with REQ_OP_DISCARD and REQ_OP_WRITE_ZEROES with the ituition that they change on-media content and should be WRITE request. Signed-off-by: Coly Li <> Reviewed-by: Damien Le Moal <> Reviewed-by: Chaitanya Kulkarni <> Cc: Christoph Hellwig <> Cc: Hannes Reinecke <> Cc: Jens Axboe <> Cc: Johannes Thumshirn <> Cc: Keith Busch <> Cc: Shaun Tancheff <> Signed-off-by: Jens Axboe <>
Diffstat (limited to 'block/blk.h')
0 files changed, 0 insertions, 0 deletions