persistent-data.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. Introduction
  2. ============
  3. The more-sophisticated device-mapper targets require complex metadata
  4. that is managed in kernel. In late 2010 we were seeing that various
  5. different targets were rolling their own data structures, for example:
  6. - Mikulas Patocka's multisnap implementation
  7. - Heinz Mauelshagen's thin provisioning target
  8. - Another btree-based caching target posted to dm-devel
  9. - Another multi-snapshot target based on a design of Daniel Phillips
  10. Maintaining these data structures takes a lot of work, so if possible
  11. we'd like to reduce the number.
  12. The persistent-data library is an attempt to provide a re-usable
  13. framework for people who want to store metadata in device-mapper
  14. targets. It's currently used by the thin-provisioning target and an
  15. upcoming hierarchical storage target.
  16. Overview
  17. ========
  18. The main documentation is in the header files which can all be found
  19. under drivers/md/persistent-data.
  20. The block manager
  21. -----------------
  22. dm-block-manager.[hc]
  23. This provides access to the data on disk in fixed sized-blocks. There
  24. is a read/write locking interface to prevent concurrent accesses, and
  25. keep data that is being used in the cache.
  26. Clients of persistent-data are unlikely to use this directly.
  27. The transaction manager
  28. -----------------------
  29. dm-transaction-manager.[hc]
  30. This restricts access to blocks and enforces copy-on-write semantics.
  31. The only way you can get hold of a writable block through the
  32. transaction manager is by shadowing an existing block (ie. doing
  33. copy-on-write) or allocating a fresh one. Shadowing is elided within
  34. the same transaction so performance is reasonable. The commit method
  35. ensures that all data is flushed before it writes the superblock.
  36. On power failure your metadata will be as it was when last committed.
  37. The Space Maps
  38. --------------
  39. dm-space-map.h
  40. dm-space-map-metadata.[hc]
  41. dm-space-map-disk.[hc]
  42. On-disk data structures that keep track of reference counts of blocks.
  43. Also acts as the allocator of new blocks. Currently two
  44. implementations: a simpler one for managing blocks on a different
  45. device (eg. thinly-provisioned data blocks); and one for managing
  46. the metadata space. The latter is complicated by the need to store
  47. its own data within the space it's managing.
  48. The data structures
  49. -------------------
  50. dm-btree.[hc]
  51. dm-btree-remove.c
  52. dm-btree-spine.c
  53. dm-btree-internal.h
  54. Currently there is only one data structure, a hierarchical btree.
  55. There are plans to add more. For example, something with an
  56. array-like interface would see a lot of use.
  57. The btree is 'hierarchical' in that you can define it to be composed
  58. of nested btrees, and take multiple keys. For example, the
  59. thin-provisioning target uses a btree with two levels of nesting.
  60. The first maps a device id to a mapping tree, and that in turn maps a
  61. virtual block to a physical block.
  62. Values stored in the btrees can have arbitrary size. Keys are always
  63. 64bits, although nesting allows you to use multiple keys.