1*86d7f5d3SJohn MarinoLet's say we have an LV, made up of three segments of different PV's,
2*86d7f5d3SJohn MarinoI've also added in the device major:minor as this will be useful
3*86d7f5d3SJohn Marinolater:
4*86d7f5d3SJohn Marino
5*86d7f5d3SJohn Marino+-----------------------------+
6*86d7f5d3SJohn Marino|  PV1     |   PV2   |   PV3  | 254:3
7*86d7f5d3SJohn Marino+----------+---------+--------+
8*86d7f5d3SJohn Marino
9*86d7f5d3SJohn Marino
10*86d7f5d3SJohn MarinoNow our hero decides to PV move PV2 to PV4:
11*86d7f5d3SJohn Marino
12*86d7f5d3SJohn Marino1. Suspend our LV (254:3), this starts queueing all io, and flushes
13*86d7f5d3SJohn Marino   all pending io.  Once the suspend has completed we are free to change
14*86d7f5d3SJohn Marino   the mapping table.
15*86d7f5d3SJohn Marino
16*86d7f5d3SJohn Marino2. Set up *another* (254:4) device with the mapping table of our LV.
17*86d7f5d3SJohn Marino
18*86d7f5d3SJohn Marino3. Load a new mapping table into (254:3) that has identity targets for
19*86d7f5d3SJohn Marino   parts that aren't moving, and a mirror target for parts that are.
20*86d7f5d3SJohn Marino
21*86d7f5d3SJohn Marino4. Unsuspend (254:3)
22*86d7f5d3SJohn Marino
23*86d7f5d3SJohn MarinoSo now we have:
24*86d7f5d3SJohn Marino                           destination of copy
25*86d7f5d3SJohn Marino               +--------------------->--------------+
26*86d7f5d3SJohn Marino               |                                    |
27*86d7f5d3SJohn Marino+-----------------------------+               + -----------+
28*86d7f5d3SJohn Marino| Identity | mirror  | Ident. | 254:3         |    PV4     |
29*86d7f5d3SJohn Marino+----------+---------+--------+               +------------+
30*86d7f5d3SJohn Marino     |         |         |
31*86d7f5d3SJohn Marino     \/        \/        \/
32*86d7f5d3SJohn Marino+-----------------------------+
33*86d7f5d3SJohn Marino|  PV1     |   PV2   |   PV3  | 254:4
34*86d7f5d3SJohn Marino+----------+---------+--------+
35*86d7f5d3SJohn Marino
36*86d7f5d3SJohn MarinoAny writes to segment2 of the LV get intercepted by the mirror target
37*86d7f5d3SJohn Marinowho checks that that chunk has been copied to the new destination, if
38*86d7f5d3SJohn Marinoit hasn't it queues the initial copy and defers the current io until
39*86d7f5d3SJohn Marinoit has finished.  Then the current io is written to *both* PV2 and the
40*86d7f5d3SJohn MarinoPV4.
41*86d7f5d3SJohn Marino
42*86d7f5d3SJohn Marino5. When the copying has completed 254:3 is suspended/pending flushed.
43*86d7f5d3SJohn Marino
44*86d7f5d3SJohn Marino6. 254:4 is taken down
45*86d7f5d3SJohn Marino
46*86d7f5d3SJohn Marino7. metadata is updated on disk
47*86d7f5d3SJohn Marino
48*86d7f5d3SJohn Marino8. 254:3 has new mapping table loaded:
49*86d7f5d3SJohn Marino
50*86d7f5d3SJohn Marino+-----------------------------+
51*86d7f5d3SJohn Marino|  PV1     |   PV4   |   PV3  | 254:3
52*86d7f5d3SJohn Marino+----------+---------+--------+
53