~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/admin-guide/device-mapper/snapshot.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/admin-guide/device-mapper/snapshot.rst (Version linux-6.12-rc7) and /Documentation/admin-guide/device-mapper/snapshot.rst (Version linux-5.17.15)


  1 ==============================                      1 ==============================
  2 Device-mapper snapshot support                      2 Device-mapper snapshot support
  3 ==============================                      3 ==============================
  4                                                     4 
  5 Device-mapper allows you, without massive data      5 Device-mapper allows you, without massive data copying:
  6                                                     6 
  7 -  To create snapshots of any block device i.e      7 -  To create snapshots of any block device i.e. mountable, saved states of
  8    the block device which are also writable wi      8    the block device which are also writable without interfering with the
  9    original content;                                9    original content;
 10 -  To create device "forks", i.e. multiple dif     10 -  To create device "forks", i.e. multiple different versions of the
 11    same data stream.                               11    same data stream.
 12 -  To merge a snapshot of a block device back      12 -  To merge a snapshot of a block device back into the snapshot's origin
 13    device.                                         13    device.
 14                                                    14 
 15 In the first two cases, dm copies only the chu     15 In the first two cases, dm copies only the chunks of data that get
 16 changed and uses a separate copy-on-write (COW     16 changed and uses a separate copy-on-write (COW) block device for
 17 storage.                                           17 storage.
 18                                                    18 
 19 For snapshot merge the contents of the COW sto     19 For snapshot merge the contents of the COW storage are merged back into
 20 the origin device.                                 20 the origin device.
 21                                                    21 
 22                                                    22 
 23 There are three dm targets available:              23 There are three dm targets available:
 24 snapshot, snapshot-origin, and snapshot-merge.     24 snapshot, snapshot-origin, and snapshot-merge.
 25                                                    25 
 26 -  snapshot-origin <origin>                        26 -  snapshot-origin <origin>
 27                                                    27 
 28 which will normally have one or more snapshots     28 which will normally have one or more snapshots based on it.
 29 Reads will be mapped directly to the backing d     29 Reads will be mapped directly to the backing device. For each write, the
 30 original data will be saved in the <COW device     30 original data will be saved in the <COW device> of each snapshot to keep
 31 its visible content unchanged, at least until      31 its visible content unchanged, at least until the <COW device> fills up.
 32                                                    32 
 33                                                    33 
 34 -  snapshot <origin> <COW device> <persistent?     34 -  snapshot <origin> <COW device> <persistent?> <chunksize>
 35    [<# feature args> [<arg>]*]                     35    [<# feature args> [<arg>]*]
 36                                                    36 
 37 A snapshot of the <origin> block device is cre     37 A snapshot of the <origin> block device is created. Changed chunks of
 38 <chunksize> sectors will be stored on the <COW     38 <chunksize> sectors will be stored on the <COW device>.  Writes will
 39 only go to the <COW device>.  Reads will come      39 only go to the <COW device>.  Reads will come from the <COW device> or
 40 from <origin> for unchanged data.  <COW device     40 from <origin> for unchanged data.  <COW device> will often be
 41 smaller than the origin and if it fills up the     41 smaller than the origin and if it fills up the snapshot will become
 42 useless and be disabled, returning errors.  So     42 useless and be disabled, returning errors.  So it is important to monitor
 43 the amount of free space and expand the <COW d     43 the amount of free space and expand the <COW device> before it fills up.
 44                                                    44 
 45 <persistent?> is P (Persistent) or N (Not pers     45 <persistent?> is P (Persistent) or N (Not persistent - will not survive
 46 after reboot).  O (Overflow) can be added as a     46 after reboot).  O (Overflow) can be added as a persistent store option
 47 to allow userspace to advertise its support fo     47 to allow userspace to advertise its support for seeing "Overflow" in the
 48 snapshot status.  So supported store types are     48 snapshot status.  So supported store types are "P", "PO" and "N".
 49                                                    49 
 50 The difference between persistent and transien     50 The difference between persistent and transient is with transient
 51 snapshots less metadata must be saved on disk      51 snapshots less metadata must be saved on disk - they can be kept in
 52 memory by the kernel.                              52 memory by the kernel.
 53                                                    53 
 54 When loading or unloading the snapshot target,     54 When loading or unloading the snapshot target, the corresponding
 55 snapshot-origin or snapshot-merge target must      55 snapshot-origin or snapshot-merge target must be suspended. A failure to
 56 suspend the origin target could result in data     56 suspend the origin target could result in data corruption.
 57                                                    57 
 58 Optional features:                                 58 Optional features:
 59                                                    59 
 60    discard_zeroes_cow - a discard issued to th     60    discard_zeroes_cow - a discard issued to the snapshot device that
 61    maps to entire chunks to will zero the corr     61    maps to entire chunks to will zero the corresponding exception(s) in
 62    the snapshot's exception store.                 62    the snapshot's exception store.
 63                                                    63 
 64    discard_passdown_origin - a discard to the      64    discard_passdown_origin - a discard to the snapshot device is passed
 65    down to the snapshot-origin's underlying de     65    down to the snapshot-origin's underlying device.  This doesn't cause
 66    copy-out to the snapshot exception store be     66    copy-out to the snapshot exception store because the snapshot-origin
 67    target is bypassed.                             67    target is bypassed.
 68                                                    68 
 69    The discard_passdown_origin feature depends     69    The discard_passdown_origin feature depends on the discard_zeroes_cow
 70    feature being enabled.                          70    feature being enabled.
 71                                                    71 
 72                                                    72 
 73 -  snapshot-merge <origin> <COW device> <persi     73 -  snapshot-merge <origin> <COW device> <persistent> <chunksize>
 74    [<# feature args> [<arg>]*]                     74    [<# feature args> [<arg>]*]
 75                                                    75 
 76 takes the same table arguments as the snapshot     76 takes the same table arguments as the snapshot target except it only
 77 works with persistent snapshots.  This target      77 works with persistent snapshots.  This target assumes the role of the
 78 "snapshot-origin" target and must not be loade     78 "snapshot-origin" target and must not be loaded if the "snapshot-origin"
 79 is still present for <origin>.                     79 is still present for <origin>.
 80                                                    80 
 81 Creates a merging snapshot that takes control      81 Creates a merging snapshot that takes control of the changed chunks
 82 stored in the <COW device> of an existing snap     82 stored in the <COW device> of an existing snapshot, through a handover
 83 procedure, and merges these chunks back into t     83 procedure, and merges these chunks back into the <origin>.  Once merging
 84 has started (in the background) the <origin> m     84 has started (in the background) the <origin> may be opened and the merge
 85 will continue while I/O is flowing to it.  Cha     85 will continue while I/O is flowing to it.  Changes to the <origin> are
 86 deferred until the merging snapshot's correspo     86 deferred until the merging snapshot's corresponding chunk(s) have been
 87 merged.  Once merging has started the snapshot     87 merged.  Once merging has started the snapshot device, associated with
 88 the "snapshot" target, will return -EIO when a     88 the "snapshot" target, will return -EIO when accessed.
 89                                                    89 
 90                                                    90 
 91 How snapshot is used by LVM2                       91 How snapshot is used by LVM2
 92 ============================                       92 ============================
 93 When you create the first LVM2 snapshot of a v     93 When you create the first LVM2 snapshot of a volume, four dm devices are used:
 94                                                    94 
 95 1) a device containing the original mapping ta     95 1) a device containing the original mapping table of the source volume;
 96 2) a device used as the <COW device>;              96 2) a device used as the <COW device>;
 97 3) a "snapshot" device, combining #1 and #2, w     97 3) a "snapshot" device, combining #1 and #2, which is the visible snapshot
 98    volume;                                         98    volume;
 99 4) the "original" volume (which uses the devic     99 4) the "original" volume (which uses the device number used by the original
100    source volume), whose table is replaced by     100    source volume), whose table is replaced by a "snapshot-origin" mapping
101    from device #1.                                101    from device #1.
102                                                   102 
103 A fixed naming scheme is used, so with the fol    103 A fixed naming scheme is used, so with the following commands::
104                                                   104 
105   lvcreate -L 1G -n base volumeGroup              105   lvcreate -L 1G -n base volumeGroup
106   lvcreate -L 100M --snapshot -n snap volumeGr    106   lvcreate -L 100M --snapshot -n snap volumeGroup/base
107                                                   107 
108 we'll have this situation (with volumes in abo    108 we'll have this situation (with volumes in above order)::
109                                                   109 
110   # dmsetup table|grep volumeGroup                110   # dmsetup table|grep volumeGroup
111                                                   111 
112   volumeGroup-base-real: 0 2097152 linear 8:19    112   volumeGroup-base-real: 0 2097152 linear 8:19 384
113   volumeGroup-snap-cow: 0 204800 linear 8:19 2    113   volumeGroup-snap-cow: 0 204800 linear 8:19 2097536
114   volumeGroup-snap: 0 2097152 snapshot 254:11     114   volumeGroup-snap: 0 2097152 snapshot 254:11 254:12 P 16
115   volumeGroup-base: 0 2097152 snapshot-origin     115   volumeGroup-base: 0 2097152 snapshot-origin 254:11
116                                                   116 
117   # ls -lL /dev/mapper/volumeGroup-*              117   # ls -lL /dev/mapper/volumeGroup-*
118   brw-------  1 root root 254, 11 29 ago 18:15    118   brw-------  1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real
119   brw-------  1 root root 254, 12 29 ago 18:15    119   brw-------  1 root root 254, 12 29 ago 18:15 /dev/mapper/volumeGroup-snap-cow
120   brw-------  1 root root 254, 13 29 ago 18:15    120   brw-------  1 root root 254, 13 29 ago 18:15 /dev/mapper/volumeGroup-snap
121   brw-------  1 root root 254, 10 29 ago 18:14    121   brw-------  1 root root 254, 10 29 ago 18:14 /dev/mapper/volumeGroup-base
122                                                   122 
123                                                   123 
124 How snapshot-merge is used by LVM2                124 How snapshot-merge is used by LVM2
125 ==================================                125 ==================================
126 A merging snapshot assumes the role of the "sn    126 A merging snapshot assumes the role of the "snapshot-origin" while
127 merging.  As such the "snapshot-origin" is rep    127 merging.  As such the "snapshot-origin" is replaced with
128 "snapshot-merge".  The "-real" device is not c    128 "snapshot-merge".  The "-real" device is not changed and the "-cow"
129 device is renamed to <origin name>-cow to aid     129 device is renamed to <origin name>-cow to aid LVM2's cleanup of the
130 merging snapshot after it completes.  The "sna    130 merging snapshot after it completes.  The "snapshot" that hands over its
131 COW device to the "snapshot-merge" is deactiva    131 COW device to the "snapshot-merge" is deactivated (unless using lvchange
132 --refresh); but if it is left active it will s    132 --refresh); but if it is left active it will simply return I/O errors.
133                                                   133 
134 A snapshot will merge into its origin with the    134 A snapshot will merge into its origin with the following command::
135                                                   135 
136   lvconvert --merge volumeGroup/snap              136   lvconvert --merge volumeGroup/snap
137                                                   137 
138 we'll now have this situation::                   138 we'll now have this situation::
139                                                   139 
140   # dmsetup table|grep volumeGroup                140   # dmsetup table|grep volumeGroup
141                                                   141 
142   volumeGroup-base-real: 0 2097152 linear 8:19    142   volumeGroup-base-real: 0 2097152 linear 8:19 384
143   volumeGroup-base-cow: 0 204800 linear 8:19 2    143   volumeGroup-base-cow: 0 204800 linear 8:19 2097536
144   volumeGroup-base: 0 2097152 snapshot-merge 2    144   volumeGroup-base: 0 2097152 snapshot-merge 254:11 254:12 P 16
145                                                   145 
146   # ls -lL /dev/mapper/volumeGroup-*              146   # ls -lL /dev/mapper/volumeGroup-*
147   brw-------  1 root root 254, 11 29 ago 18:15    147   brw-------  1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real
148   brw-------  1 root root 254, 12 29 ago 18:16    148   brw-------  1 root root 254, 12 29 ago 18:16 /dev/mapper/volumeGroup-base-cow
149   brw-------  1 root root 254, 10 29 ago 18:16    149   brw-------  1 root root 254, 10 29 ago 18:16 /dev/mapper/volumeGroup-base
150                                                   150 
151                                                   151 
152 How to determine when a merging is complete       152 How to determine when a merging is complete
153 ===========================================       153 ===========================================
154 The snapshot-merge and snapshot status lines e    154 The snapshot-merge and snapshot status lines end with:
155                                                   155 
156   <sectors_allocated>/<total_sectors> <metadat    156   <sectors_allocated>/<total_sectors> <metadata_sectors>
157                                                   157 
158 Both <sectors_allocated> and <total_sectors> i    158 Both <sectors_allocated> and <total_sectors> include both data and metadata.
159 During merging, the number of sectors allocate    159 During merging, the number of sectors allocated gets smaller and
160 smaller.  Merging has finished when the number    160 smaller.  Merging has finished when the number of sectors holding data
161 is zero, in other words <sectors_allocated> ==    161 is zero, in other words <sectors_allocated> == <metadata_sectors>.
162                                                   162 
163 Here is a practical example (using a hybrid of    163 Here is a practical example (using a hybrid of lvm and dmsetup commands)::
164                                                   164 
165   # lvs                                           165   # lvs
166     LV      VG          Attr   LSize Origin  S    166     LV      VG          Attr   LSize Origin  Snap%  Move Log Copy%  Convert
167     base    volumeGroup owi-a- 4.00g              167     base    volumeGroup owi-a- 4.00g
168     snap    volumeGroup swi-a- 1.00g base  18.    168     snap    volumeGroup swi-a- 1.00g base  18.97
169                                                   169 
170   # dmsetup status volumeGroup-snap               170   # dmsetup status volumeGroup-snap
171   0 8388608 snapshot 397896/2097152 1560          171   0 8388608 snapshot 397896/2097152 1560
172                                     ^^^^ metad    172                                     ^^^^ metadata sectors
173                                                   173 
174   # lvconvert --merge -b volumeGroup/snap         174   # lvconvert --merge -b volumeGroup/snap
175     Merging of volume snap started.               175     Merging of volume snap started.
176                                                   176 
177   # lvs volumeGroup/snap                          177   # lvs volumeGroup/snap
178     LV      VG          Attr   LSize Origin  S    178     LV      VG          Attr   LSize Origin  Snap%  Move Log Copy%  Convert
179     base    volumeGroup Owi-a- 4.00g              179     base    volumeGroup Owi-a- 4.00g          17.23
180                                                   180 
181   # dmsetup status volumeGroup-base               181   # dmsetup status volumeGroup-base
182   0 8388608 snapshot-merge 281688/2097152 1104    182   0 8388608 snapshot-merge 281688/2097152 1104
183                                                   183 
184   # dmsetup status volumeGroup-base               184   # dmsetup status volumeGroup-base
185   0 8388608 snapshot-merge 180480/2097152 712     185   0 8388608 snapshot-merge 180480/2097152 712
186                                                   186 
187   # dmsetup status volumeGroup-base               187   # dmsetup status volumeGroup-base
188   0 8388608 snapshot-merge 16/2097152 16          188   0 8388608 snapshot-merge 16/2097152 16
189                                                   189 
190 Merging has finished.                             190 Merging has finished.
191                                                   191 
192 ::                                                192 ::
193                                                   193 
194   # lvs                                           194   # lvs
195     LV      VG          Attr   LSize Origin  S    195     LV      VG          Attr   LSize Origin  Snap%  Move Log Copy%  Convert
196     base    volumeGroup owi-a- 4.00g              196     base    volumeGroup owi-a- 4.00g
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php