Skip to contentSkip to conversation

dm-cache: document zeroing metadata device step

PATCH Superseded Austin Chang 2 participants 4 messages Jul 12, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm-cache: document zeroing metadata device step

Inform dmsetup users to zero the first 4k of the metadata device at cache creation in examples, just as mentioned in thin-provisioning documentation. Instructions to use lvmcache for end users may be added as well.

---
 Documentation/admin-guide/device-mapper/cache.rst | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/admin-guide/device-mapper/cache.rst +4 -0
index f15e5254d05b..ef9a82d50d19 100644
@@ -330,6 +330,10 @@ https://github.com/jthornber/device-mapper-test-suite
 
 ::
 
+  # When using dmsetup directly instead of volume manager like lvm2,
+  # the first 4k of the metadata device should be zeroed to indicate
+  # empty metadata.
+  dd if=/dev/zero of=/dev/mapper/metadata bs=4k conv=notrunc
   dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \
 	  /dev/mapper/ssd /dev/mapper/origin 512 1 writeback default 0'
   dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \
Signature · 1 line
2.26.2
#1 lore raw

Documentation/admin-guide/device-mapper/cache.rst https://github.com/jthornber/device-mapper-test-suite · line 336

Quoted 4 lines · Austin Chang
Documentation/admin-guide/device-mapper/cache.rst +4 -0
+  # When using dmsetup directly instead of volume manager like lvm2,
+  # the first 4k of the metadata device should be zeroed to indicate
+  # empty metadata.
+  dd if=/dev/zero of=/dev/mapper/metadata bs=4k conv=notrunc

... don't you need 'count=1' or you'll zero the entire device?

Quoted 6 lines
   dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \

/dev/mapper/ssd /dev/mapper/origin 512 1 writeback default 0'
dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \

Signature · 1 line
2.26.2
#2 lore raw
Quoted 7 lines · Matthew Wilcox

Documentation/admin-guide/device-mapper/cache.rst https://github.com/jthornber/device-mapper-test-suite · line 336

Quoted 4 lines · Austin Chang
Documentation/admin-guide/device-mapper/cache.rst +4 -0
+  # When using dmsetup directly instead of volume manager like lvm2,
+  # the first 4k of the metadata device should be zeroed to indicate
+  # empty metadata.
+  dd if=/dev/zero of=/dev/mapper/metadata bs=4k conv=notrunc

... don't you need 'count=1' or you'll zero the entire device?

Oops, I copied the command I just used since zeroing the whole metadata device didn't harm. But 'count=1' should match what I've just written. I will send a v2 patch later

#3 lore raw

PATCH v2 1/1 dm-cache: document zeroing metadata device step

Inform dmsetup users to zero the first 4k of the metadata device at cache creation in examples, just as mentioned in thin-provisioning documentation. Instructions to use lvmcache for end users may be added as well.

---
Changes in v2:
- Correct the dd arguments

 Documentation/admin-guide/device-mapper/cache.rst | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/admin-guide/device-mapper/cache.rst +4 -0
index f15e5254d05b..16a1c96946a6 100644
@@ -330,6 +330,10 @@ https://github.com/jthornber/device-mapper-test-suite
 
 ::
 
+  # When using dmsetup directly instead of volume manager like lvm2,
+  # the first 4k of the metadata device should be zeroed to indicate
+  # empty metadata.
+  dd if=/dev/zero of=/dev/mapper/metadata bs=4k count=1
   dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \
 	  /dev/mapper/ssd /dev/mapper/origin 512 1 writeback default 0'
   dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \
Signature · 1 line
2.26.2