linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcache: fix wrong BITMASK offset value for BDEV_CACHE_MODE
@ 2021-07-20 10:32 Lin Feng
  2022-05-13 15:20 ` Coly Li
  0 siblings, 1 reply; 3+ messages in thread
From: Lin Feng @ 2021-07-20 10:32 UTC (permalink / raw)
  To: colyli; +Cc: axboe, linf, linux-kernel, linux-bcache

Original codes:
BITMASK(CACHE_SYNC,			struct cache_sb, flags, 0, 1);
BITMASK(CACHE_DISCARD,			struct cache_sb, flags, 1, 1);
BITMASK(CACHE_REPLACEMENT,		struct cache_sb, flags, 2, 3);
...
BITMASK(BDEV_CACHE_MODE,		struct cache_sb, flags, 0, 4);

Should BDEV_CACHE_MODE bits start from bit-nr 5(2+3) else it overlaps
with previous defined bit chunks, since we have 4 types of cache modes,
BDEV_CACHE_MODE will overwrite CACHE_SYNC and CACHE_DISCARD bits.

This bug stays there since first upstream version of bcache, don't know
why it lives so long, or am i missing something, please point me out
if I'm wrong, thanks!

Signed-off-by: Lin Feng <linf@wangsu.com>
---
 include/uapi/linux/bcache.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
index cf7399f03b71..dccd89756451 100644
--- a/include/uapi/linux/bcache.h
+++ b/include/uapi/linux/bcache.h
@@ -288,7 +288,7 @@ BITMASK(CACHE_REPLACEMENT,		struct cache_sb, flags, 2, 3);
 #define CACHE_REPLACEMENT_FIFO		1U
 #define CACHE_REPLACEMENT_RANDOM	2U
 
-BITMASK(BDEV_CACHE_MODE,		struct cache_sb, flags, 0, 4);
+BITMASK(BDEV_CACHE_MODE,		struct cache_sb, flags, 5, 4);
 #define CACHE_MODE_WRITETHROUGH		0U
 #define CACHE_MODE_WRITEBACK		1U
 #define CACHE_MODE_WRITEAROUND		2U
-- 
2.31.1


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

end of thread, other threads:[~2022-05-16  1:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 10:32 [PATCH] bcache: fix wrong BITMASK offset value for BDEV_CACHE_MODE Lin Feng
2022-05-13 15:20 ` Coly Li
2022-05-16  1:50   ` Lin Feng

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).