File: refactoring.txt

package info (click to toggle)
lvm2 2.03.11-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,096 kB
  • sloc: ansic: 167,186; sh: 31,637; python: 5,638; makefile: 1,962; ruby: 66; awk: 20; cpp: 10
file content (158 lines) | stat: -rw-r--r-- 5,865 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Over time, I'd like to refactor the LVM code into these high level modules.


         +-------------------------------------------+
         |                                           |
         |   User Interface                          |
         |                                           |
         |                                           |
         +-------------------+-----------------------+
                             |
        +--------------------v-----------------------+
        |                                            |
        |   LVM Core                                 |
        |                                            |
        |                                            |
        +----+----------------+-----------------+----+
             |                |                 |
       +-----v-----+    +-----v------+   +------v----+
       |           |    |            |   |           |
       |  Device   |    |  Metadata  |   |  System   |
       |  Mapper   |    |            |   |           |
       |           |    |            |   |           |
       |           |    |            |   |           |
       |           |    |            |   |           |
       +-----------+    +------------+   +-----------+

+---------------------------------------------------------+


       +------------------------------------+
       |                                    |
       |   Base                             |
       |                                    |
       |                                    |
       |                                    |
       |                                    |
       +------------------------------------+

Going from the bottom up we have:

Base
----

This holds all our general purpose code such as data structures, regex engine,
memory allocators.  In fact pretty much everything in libdevmapper apart from
the dm code and config.

This can be used by any code in the system, which is why I've drawn a line
between it and the code above rather than using arrows.

If anyone can come up with a better name please do.  I'm trying to stay away
from 'utils'.


Device mapper
-------------

As well as the low level dm-ioctl driving code we need to have all our dm 'best
practise' stuff in here.  For instance this is the code that decides to use the
mirror target to move some data around; that knows to suspend a thin volume
before taking a snapshot of it.  This module is going to have a lot more code
in it than the current libdevmapper.

It should not know anything about the LVM abstractions or metadata (no PVs, LVs
or VGs).  It just knows about the dm world.

Code in here is only allowed to use base.


Metadata model
--------------

Here we have all the format handling, labelling, config parsing etc.  We try
and put *everything* to do with LVM in here that doesn't actually require dm.


System
------

Code that interfaces with the system (udev etc).


LVM Core
--------

[terrible name]

This ties together the last 3 units.  It should just be glue.  We need to be
strict about pushing code down from here to keep this as small as possible.


User interface
--------------

Self explanatory.


Headers
-------

Headers will be included using sub directories to make it clearer where they
are in the tree.

eg,
  #include "base/mm/pool.h"
  #include "base/data-struct/list.h"
  #include "dm/thin-provisioning.h"
  #include "core/pvmove.h"


Getting there
=============

+-------------------------------------------+
|                                           |
|                                           |
|    Tools                                  |
|                                           |
|                                           |
|                                           |
+---------+------------------------------+--+
          |                              |
          |              +---------------v---------------------------+
          |              |                                           |
          |              |                                           |
          |              |    Lib                                    |
          |              |                                           |
          |              |                                           |
          |              |                                           |
          |              |                                           |
          |              +----------------+--------------------------+
          |                               |
          |                               |
    +-----v-------------------------------v-----+
    |                                           |
    |                                           |
    |    libdevmapper                           |
    |                                           |
    |                                           |
    |                                           |
    |                                           |
    +-------------------------------------------+

This is where I see us now.

'base' should be easy to factor out, it's just the non-dm part of libdevmapper
(ie. the bulk of it).  But we have the problem that libdevmapper is a public
interface to get round.

'lib' is where the bulk of our code currently is.  Dependency-wise the code is
a bit like a ball of string.  So splitting it up is going to take time.  We can
probably pull code pretty quickly into the 'metadata model' dir.  But factoring
out the dm best practises stuff is going to require splitting at least
files, and probably functions.  Certainly not something that can be done in one
go.  System should just be a question of cherry picking functions.

I'm not too familiar with the tools dir.  Hopefully it just corresponds with
the User Interface module and doesn't contain any business logic.