On 02/07/2020 09:21, Johannes Thumshirn wrote:
On 02/07/2020 09:59, Hannes Reinecke wrote:
That's one of the best-kept secrets in the block layer:
op_is_write()
The assumption is that every request with a REQ_OP which has the lowest
bit set is a write.
And quite a lot of accounting the the block layer revolves around that.
So we'll need to keep it.
... and we probably should document it somewhere.
Now that I check further, it is documented in blk_types.h:
* The least significant bit of the operation number indicates the data
* transfer direction:
*
* - if the least significant bit is set transfers are TO the device
* - if the least significant bit is not set transfers are FROM the
device
*
I personally find this very obvious:
static inline bool op_is_write(unsigned int op) > {
return (op & 1);
}
.