[PATCH 3/3] bcache-tools: convert writeback to writethrough mode for zoned backing device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently bcache does not support writeback cache mode for zoned device
as backing device.

If the backing device is zoned device, and cache mode is explicitly set
to writeback mode, a information will be print to terminal,
  "Zoned device <device name> detected: convert to writethrough mode."
Then the cache mode will be automatically converted to writethrough,
which is the default cache mode of bcache-tools.

Signed-off-by: Coly Li <colyli@xxxxxxx>
---
 make.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/make.c b/make.c
index c1090a6..c5658ba 100644
--- a/make.c
+++ b/make.c
@@ -378,6 +378,19 @@ static void write_sb(char *dev, unsigned int block_size,
 		SET_BDEV_CACHE_MODE(&sb, writeback ?
 			CACHE_MODE_WRITEBACK : CACHE_MODE_WRITETHROUGH);
 
+		/*
+		 * Currently bcache does not support writeback mode for
+		 * zoned device as backing device. If the cache mode is
+		 * explicitly set to writeback, automatically convert to
+		 * writethough mode.
+		 */
+		if (is_zoned_device(dev) &&
+		    BDEV_CACHE_MODE(&sb) == CACHE_MODE_WRITEBACK) {
+			printf("Zoned device %s detected: convert to writethrough mode.\n",
+				dev);
+			SET_BDEV_CACHE_MODE(&sb, CACHE_MODE_WRITETHROUGH);
+		}
+
 		if (data_offset != BDEV_DATA_START_DEFAULT) {
 			sb.version = BCACHE_SB_VERSION_BDEV_WITH_OFFSET;
 			sb.data_offset = data_offset;
-- 
2.25.0




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux