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