~curtin-dev/curtin/trunk

« back to all changes in this revision

Viewing changes to doc/devel/clear_holders_doc.txt

  • Committer: Scott Moser
  • Date: 2017-12-20 17:33:03 UTC
  • Revision ID: smoser@ubuntu.com-20171220173303-29gha5qb8wpqrd40
README: Mention move of revision control to git.

curtin development has moved its revision control to git.
It is available at
  https://code.launchpad.net/curtin

Clone with
  git clone https://git.launchpad.net/curtin
or
  git clone git+ssh://git.launchpad.net/curtin

For more information see
  http://curtin.readthedocs.io/en/latest/topics/development.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
The new version of clear_holders is based around a data structure called a
2
 
holder_tree which represents the current storage hirearchy above a specified
3
 
starting device. Each node in a holders tree contains data about the node and a
4
 
key 'holders' which contains a list of all nodes that depend on it. The keys in
5
 
a holdres_tree node are:
6
 
  - device: the path to the device in /sys/class/block
7
 
  - dev_type: what type of storage layer the device is. possible values:
8
 
      - disk
9
 
      - lvm
10
 
      - crypt
11
 
      - raid
12
 
      - bcache
13
 
      - disk
14
 
  - name: the kname of the device (used for display)
15
 
  - holders: holders_trees for devices depending on the current device
16
 
 
17
 
A holders tree can be generated for a device using the function
18
 
clear_holders.gen_holders_tree. The device can be specified either as a path in
19
 
/sys/class/block or as a path in /dev.
20
 
 
21
 
The new implementation of block.clear_holders shuts down storage devices in a
22
 
holders tree starting from the leaves of the tree and ascending towards the
23
 
root. The old implementation of clear_holders ascended up each path of the tree
24
 
separately, in a pattern similar to depth first search. The problem with the
25
 
old implementation is that in some cases either an attempt would be made to
26
 
remove one storage device while other devices depended on it or clear_holders
27
 
would attempt to shut down the same storage device several times. In order to
28
 
cope with this the old version of clear_holders had logic to handle expected
29
 
failures and hope for the best moving forward. The new version of clear_holders
30
 
is able to run without many anticipated failures.
31
 
 
32
 
The logic to plan what order to shut down storage layers in is in
33
 
clear_holders.plan_shutdown_holders_trees. This function accepts either a
34
 
single holders tree or a list of holders trees. When run with a list of holders
35
 
trees, it assumes that all of these trees start at basically the same layer in
36
 
the overall storage hirearcy for the system (i.e. a list of holders trees
37
 
starting from all of the target installation disks). This function returns a
38
 
list of dictionaries, with each dictionary containing the keys:
39
 
  - device: the path to the device in /sys/class/block
40
 
  - dev_type: what type of storage layer the device is. possible values:
41
 
      - disk
42
 
      - lvm
43
 
      - crypt
44
 
      - raid
45
 
      - bcache
46
 
      - disk
47
 
  - level: the level of the device in the current storage hirearchy
48
 
           (starting from 0)
49
 
 
50
 
The items in the list returned by clear_holders.plan_shutdown_holders_trees
51
 
should be processed in order to make sure the holders trees are shutdown fully
52
 
 
53
 
The main interface for clear_holders is the function
54
 
clear_holders.clear_holders. If the system has just been booted it could be
55
 
beneficial to run the function clear_holders.start_clear_holders_deps before
56
 
using clear_holders.clear_holders. This ensures clear_holders will be able to
57
 
properly storage devices. The function clear_holders.clear_holders can be
58
 
passed either a single device or a list of devices and will shut down all
59
 
storage devices above the device(s). The devices can be specified either by
60
 
path in /dev or by path in /sys/class/block.
61
 
 
62
 
In order to test if a device or devices are free to be partitioned/formatted,
63
 
the function clear_holders.assert_clear can be passed either a single device or
64
 
a list of devices, with devices specified either by path in /dev or by path in
65
 
/sys/class/block. If there are any storage devices that depend on one of the
66
 
devices passed to clear_holders.assert_clear, then an OSError will be raised.
67
 
If clear_holders.assert_clear does not raise any errors, then the devices
68
 
specified should be ready for partitioning.
69
 
 
70
 
It is possible to query further information about storage devices using
71
 
clear_holders.
72
 
 
73
 
Holders for a individual device can be queried using clear_holders.get_holders.
74
 
Results are returned as a list or knames for holding devices.
75
 
 
76
 
A holders tree can be printed in a human readable format using
77
 
clear_holders.format_holders_tree(). Example output:
78
 
sda
79
 
|-- sda1
80
 
|-- sda2
81
 
`-- sda5
82
 
    `-- dm-0
83
 
        |-- dm-1
84
 
        `-- dm-2
85
 
            `-- dm-3