^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) ======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) dm-era
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) Introduction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) dm-era is a target that behaves similar to the linear target. In
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) addition it keeps track of which blocks were written within a user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) defined period of time called an 'era'. Each era target instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) maintains the current era as a monotonically increasing 32-bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) counter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) Use cases include tracking changed blocks for backup software, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) partially invalidating the contents of a cache to restore cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) coherency after rolling back a vendor snapshot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) Constructor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) era <metadata dev> <origin dev> <block size>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ================ ======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) metadata dev fast device holding the persistent metadata
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) origin dev device holding data blocks that may change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) block size block size of origin data device, granularity that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) tracked by the target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ================ ======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) Messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) None of the dm messages take any arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) checkpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) Possibly move to a new era. You shouldn't assume the era has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) incremented. After sending this message, you should check the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) current era via the status line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) take_metadata_snap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) Create a clone of the metadata, to allow a userland process to read it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) drop_metadata_snap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) Drop the metadata snapshot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) ======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) <metadata block size> <#used metadata blocks>/<#total metadata blocks>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) <current era> <held metadata root | '-'>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ========================= ==============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) metadata block size Fixed block size for each metadata block in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) sectors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #used metadata blocks Number of metadata blocks used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #total metadata blocks Total number of metadata blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) current era The current era
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) held metadata root The location, in blocks, of the metadata root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) that has been 'held' for userspace read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) access. '-' indicates there is no held root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) ========================= ==============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) Detailed use case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) =================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) The scenario of invalidating a cache when rolling back a vendor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) snapshot was the primary use case when developing this target:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) Taking a vendor snapshot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) - Send a checkpoint message to the era target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) - Make a note of the current era in its status line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) - Take vendor snapshot (the era and snapshot should be forever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) associated now).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) Rolling back to an vendor snapshot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) ----------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) - Cache enters passthrough mode (see: dm-cache's docs in cache.txt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) - Rollback vendor storage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) - Take metadata snapshot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) - Ascertain which blocks have been written since the snapshot was taken
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) by checking each block's era
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) - Invalidate those blocks in the caching software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) - Cache returns to writeback/writethrough mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) Memory usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) The target uses a bitset to record writes in the current era. It also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) has a spare bitset ready for switching over to a new era. Other than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) that it uses a few 4k blocks for updating metadata::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) (4 * nr_blocks) bytes + buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) Resilience
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) ==========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) Metadata is updated on disk before a write to a previously unwritten
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) block is performed. As such dm-era should not be effected by a hard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) crash such as power failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) Userland tools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) ==============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) Userland tools are found in the increasingly poorly named
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) thin-provisioning-tools project:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) https://github.com/jthornber/thin-provisioning-tools