era.txt 3.1 KB

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