[RFC PATCH] block: add meaningful macro for flush op flags
Coly Li
colyli at suse.de
Sun May 14 04:11:22 PDT 2023
> 2023年5月12日 10:07,Chaitanya Kulkarni <kch at nvidia.com> 写道:
>
> Flush requests are implemented as REQ_OP_WRITE + REQ_OP_PREFLUSH
> combination and not REQ_OP_FLUSH + REQ_PREFLUSH combination.
>
> This unclear nature has lead to the confusion and bugs in the code for
> block drivers causing more work for testing, reviews and fixes :-
>
> 1. https://lore.kernel.org/all/ZFHgefWofVt24tRl@infradead.org/
> 2. https://marc.info/?l=linux-block&m=168386364026498&w=2
>
> Add a macro (name can me more meaningful) with a meaningful comment
> clearing the confusion and replace the REQ_OP_WRITE | REQ_PREFLUSH with
> the new macro name that also saves code repetation.
>
> Signed-off-by: Chaitanya Kulkarni <kch at nvidia.com>
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -455,6 +455,13 @@ enum req_flag_bits {
> #define REQ_NOMERGE_FLAGS \
> (REQ_NOMERGE | REQ_PREFLUSH | REQ_FUA)
>
> +/*
> + * Flush requests are implemented as REQ_OP_WRITE + REQ_OP_PREFLUSH combination
> + * and not REQ_OP_FLUSH + REQ_PREFLUSH combination.
> + */
> +
> +#define REQ_FLUSH_OPF (REQ_OP_WRITE | REQ_PREFLUSH)
> +
> enum stat_group {
> STAT_READ,
> STAT_WRITE,
> --
Personally I like current explicit way, it is simpler than an extra macro. This is just my own points, FYI.
Thanks.
Coly Li
More information about the Linux-nvme
mailing list