Skip to contentSkip to conversation

bcache-tools: only discard cache device during making when discard is enabled

PATCH New Coly Li 1 participant 1 message Jun 16, 2021 bcache (block layer cache)

lore
Share & tools
lore

Coly Li

author
#0 lore raw

PATCH 1/1 bcache-tools: only discard cache device during making when discard is enabled

Currently in cache device making time, discard is always issued onto the cache device. It is unncessary and might be slow if the cache device is combined by md raid device (e.g. raid10).

Therefore when making a new cache device, this patch only issue discard when it is explicitly enabled by --discard option.

Cc Shaoxiong Li <[email protected]>
---
 make.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
make.c +2 -1
index 4ca7734..34d8011 100644
@@ -446,7 +446,8 @@ static void write_sb(char *dev, struct sb_context *sbc, bool bdev, bool force)
 
 		/* Attempting to discard cache device
 		 */
-		blkdiscard_all(dev, fd);
+		if (discard)
+			blkdiscard_all(dev, fd);
 		putchar('\n');
 	}
 
Signature · 1 line
2.26.2