Thread (5 messages) 5 messages, 5 authors, 2023-05-15

Re: [RFC PATCH] block: add meaningful macro for flush op flags

From: Coly Li <hidden>
Date: 2023-05-14 11:11:42
Also in: dm-devel, linux-bcache, linux-block, linux-nvme, linux-scsi, target-devel

2023年5月12日 10:07,Chaitanya Kulkarni [off-list ref] 写道:

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/ (local)
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@nvidia.com>
quoted hunk ↗ jump to hunk
--- 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help