mirror of
git://sourceware.org/git/lvm2.git
synced 2025-12-31 12:32:49 +03:00
Compare commits
900 Commits
dev-mcsont
...
dev-dct-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d479cc96ea | ||
|
|
57e9083c90 | ||
|
|
76bd678ce3 | ||
|
|
92fd2cb498 | ||
|
|
82d145a372 | ||
|
|
ad1d688734 | ||
|
|
8b4701d7c4 | ||
|
|
5551e4a1e9 | ||
|
|
5f26c05bf2 | ||
|
|
2f8550a388 | ||
|
|
3ced86217c | ||
|
|
200b05cec0 | ||
|
|
b8869e2d4e | ||
|
|
24943fe9d3 | ||
|
|
990f4f7c4f | ||
|
|
680f7bd676 | ||
|
|
54a8562804 | ||
|
|
f1d88007b0 | ||
|
|
d85ceff9c5 | ||
|
|
f32fd1fcb9 | ||
|
|
943e979079 | ||
|
|
9ea5ff3db5 | ||
|
|
4d8fb10af2 | ||
|
|
bada03cd48 | ||
|
|
e777ef720c | ||
|
|
5e1d64a991 | ||
|
|
039be7d5b9 | ||
|
|
55687b6656 | ||
|
|
58e75f6178 | ||
|
|
4dc009c872 | ||
|
|
bf60cb4da2 | ||
|
|
1b9bf5007b | ||
|
|
ab93e1c38d | ||
|
|
82ea579ba2 | ||
|
|
21b215ee63 | ||
|
|
336cb32884 | ||
|
|
57e6e94a83 | ||
|
|
88fb07b669 | ||
|
|
cc344c3e69 | ||
|
|
e0537559c6 | ||
|
|
4b126fd953 | ||
|
|
ed440367b9 | ||
|
|
e30bc9b179 | ||
|
|
14f782c5a7 | ||
|
|
b1d80a0ffd | ||
|
|
64ccbc4b52 | ||
|
|
a98beb8ee3 | ||
|
|
f8907b8f3c | ||
|
|
d01e5ec126 | ||
|
|
cc6ddf978a | ||
|
|
2468b66b30 | ||
|
|
6e6d4c62b3 | ||
|
|
fe68fb0525 | ||
|
|
3a9689652d | ||
|
|
1813d0d186 | ||
|
|
b77edc337a | ||
|
|
1e2a3445d9 | ||
|
|
88681f05f1 | ||
|
|
5731d06bc5 | ||
|
|
76ca20a9af | ||
|
|
524df486b3 | ||
|
|
896410b393 | ||
|
|
cd0f5ee36c | ||
|
|
13e0222ba2 | ||
|
|
fffff2c2a2 | ||
|
|
915dd18361 | ||
|
|
85e0636623 | ||
|
|
91502446ac | ||
|
|
a8b8e1f074 | ||
|
|
ace25d5eeb | ||
|
|
9ee6a9b982 | ||
|
|
c14e0282ec | ||
|
|
2c8ff67470 | ||
|
|
f10de12ade | ||
|
|
7e59c3aa58 | ||
|
|
9207bae33b | ||
|
|
fbdd26a4a3 | ||
|
|
533a87d0ea | ||
|
|
80fa3511be | ||
|
|
c496cfa99a | ||
|
|
d825e8887c | ||
|
|
9dfe5ce2bc | ||
|
|
90c6c421cd | ||
|
|
3b649c3076 | ||
|
|
403ecb46fa | ||
|
|
1b90865843 | ||
|
|
88e0060aa8 | ||
|
|
2e6e752c3a | ||
|
|
cd56b04ef6 | ||
|
|
cdcd482fa4 | ||
|
|
e1fd179dc5 | ||
|
|
eaa4882924 | ||
|
|
ddf3b6e5e3 | ||
|
|
9ab2607c7f | ||
|
|
40cf4ce1e1 | ||
|
|
45c06025da | ||
|
|
bbe1b93ed9 | ||
|
|
93115ef91d | ||
|
|
fdfe80f024 | ||
|
|
01e014a246 | ||
|
|
b63e54d0ed | ||
|
|
e211768d1c | ||
|
|
d192477ae6 | ||
|
|
dac2bfe6a4 | ||
|
|
5da282fa23 | ||
|
|
1712845ab5 | ||
|
|
36691b9844 | ||
|
|
5c24d6d4db | ||
|
|
aad1add77f | ||
|
|
314c759a09 | ||
|
|
a198224666 | ||
|
|
d8e639ecba | ||
|
|
caa0e08738 | ||
|
|
2e0ac97903 | ||
|
|
9a371639fc | ||
|
|
83c0b19f61 | ||
|
|
93918a1990 | ||
|
|
59345da03f | ||
|
|
dd78573073 | ||
|
|
38d34dbe75 | ||
|
|
5173b0c222 | ||
|
|
73298635b9 | ||
|
|
47f8bda051 | ||
|
|
c609dedc2f | ||
|
|
6fdc8787eb | ||
|
|
90ec2cd92f | ||
|
|
15413226a8 | ||
|
|
5906f44bee | ||
|
|
32b2776afc | ||
|
|
a0c5b2c9fd | ||
|
|
e59c84ca3a | ||
|
|
e3dff2cba2 | ||
|
|
7d22be22d9 | ||
|
|
e08e5a5a07 | ||
|
|
915267c900 | ||
|
|
c2c028c680 | ||
|
|
a86fb27607 | ||
|
|
c6b5eb5b50 | ||
|
|
d58a2644e6 | ||
|
|
aafa22e643 | ||
|
|
af983ad3d3 | ||
|
|
c0e7cdff9d | ||
|
|
a1a1e13dbe | ||
|
|
60bad2f22d | ||
|
|
026344e8cc | ||
|
|
ee3be2807f | ||
|
|
d25c43c8cd | ||
|
|
ffdceeb982 | ||
|
|
74e487f3a9 | ||
|
|
8da0ab6fc1 | ||
|
|
c7a9a1fb6c | ||
|
|
46669fe9e8 | ||
|
|
5b7e30da76 | ||
|
|
429ab45a1c | ||
|
|
f86bdcb6e9 | ||
|
|
25236a963f | ||
|
|
fd8ed7554e | ||
|
|
1a219c69ee | ||
|
|
bebbb1e66a | ||
|
|
5840f90e82 | ||
|
|
82617852a4 | ||
|
|
f854e3a722 | ||
|
|
abe1b49b47 | ||
|
|
433154fc8a | ||
|
|
8ac1cc593e | ||
|
|
d85c9728fb | ||
|
|
1c396598ff | ||
|
|
d3c22aedc4 | ||
|
|
057b1bde75 | ||
|
|
e54bfe2a83 | ||
|
|
cd6e1d0475 | ||
|
|
b678decfca | ||
|
|
87cd61c6bd | ||
|
|
00cfe3a24e | ||
|
|
55a9fb98d1 | ||
|
|
44d58f28f1 | ||
|
|
d2c6866bdb | ||
|
|
868bd3b51e | ||
|
|
5aff63c07b | ||
|
|
8a323082ef | ||
|
|
04d9f13fa6 | ||
|
|
298bd24e53 | ||
|
|
7a74229a8e | ||
|
|
a3dcdf5671 | ||
|
|
6db19f6b51 | ||
|
|
57143a216e | ||
|
|
7c016506a2 | ||
|
|
5561f2a530 | ||
|
|
2f3fcbd245 | ||
|
|
4dda6d1555 | ||
|
|
8168b5e71d | ||
|
|
c48cc22b18 | ||
|
|
edbc0ed447 | ||
|
|
383d7c4413 | ||
|
|
cfcbf89ed0 | ||
|
|
09f70dbb87 | ||
|
|
5f1c799e6a | ||
|
|
f0d3d0482e | ||
|
|
5818fbfbcf | ||
|
|
3e91823b3e | ||
|
|
59b4c97564 | ||
|
|
3f41b4af55 | ||
|
|
5c7d6083a9 | ||
|
|
bbf352892d | ||
|
|
d7c2fe9723 | ||
|
|
f6e0e7b9aa | ||
|
|
9f4dc4170b | ||
|
|
a07bf7b90b | ||
|
|
dae792baad | ||
|
|
db40a2e33c | ||
|
|
4761753a6f | ||
|
|
04b407674c | ||
|
|
61a11f25a3 | ||
|
|
099a4e2146 | ||
|
|
91991e3cc1 | ||
|
|
e56e7ed533 | ||
|
|
a763420786 | ||
|
|
75a03c2c26 | ||
|
|
495ea0f058 | ||
|
|
c140601cf6 | ||
|
|
5d573cc91d | ||
|
|
7b872bc4cd | ||
|
|
2a75dc7465 | ||
|
|
09426b4663 | ||
|
|
d16a8f80e9 | ||
|
|
f3d3d4a07d | ||
|
|
2e38369ecf | ||
|
|
011e0672c5 | ||
|
|
2b198cd874 | ||
|
|
8daa702880 | ||
|
|
781bb0ea37 | ||
|
|
f65f5e1c22 | ||
|
|
9a9db862a4 | ||
|
|
7f25e58f66 | ||
|
|
0eb6a59299 | ||
|
|
e0bd66b73a | ||
|
|
8bbd00162b | ||
|
|
c9f9744f50 | ||
|
|
9247e754fe | ||
|
|
eae0314b55 | ||
|
|
9cf127b429 | ||
|
|
0e5250c475 | ||
|
|
e6f46fafe7 | ||
|
|
0bcf2c6514 | ||
|
|
efe2005022 | ||
|
|
abf7c40185 | ||
|
|
acabc995c0 | ||
|
|
9f506eb89e | ||
|
|
6430a6ca63 | ||
|
|
ff699eab24 | ||
|
|
41ffa8c74d | ||
|
|
64cb8b5940 | ||
|
|
effafa8fc8 | ||
|
|
2a1e200f7a | ||
|
|
9b2f9d64c0 | ||
|
|
e02695cb45 | ||
|
|
a6f4aed3c0 | ||
|
|
1f92fc2af7 | ||
|
|
a98f908c23 | ||
|
|
54e2de82c0 | ||
|
|
8f37c22df2 | ||
|
|
1ab66f37ae | ||
|
|
611975c51b | ||
|
|
eeffc1d52b | ||
|
|
b4670db008 | ||
|
|
0b064aedb3 | ||
|
|
6f8abdc978 | ||
|
|
db6bb6e90b | ||
|
|
061fa7b690 | ||
|
|
2a39ed7741 | ||
|
|
b8d5c4b41a | ||
|
|
d5da7604e5 | ||
|
|
7ec0f69cd1 | ||
|
|
9162ae0a0a | ||
|
|
c35385a1cd | ||
|
|
26cbd4057a | ||
|
|
e654b9cba9 | ||
|
|
45d9b2c470 | ||
|
|
d2f953c9db | ||
|
|
063910c54b | ||
|
|
f453665f92 | ||
|
|
cd69d58fcd | ||
|
|
0316dd7955 | ||
|
|
e1211d38a4 | ||
|
|
ee45cd8965 | ||
|
|
6ece8b74f0 | ||
|
|
063ade474c | ||
|
|
ecabdf68cf | ||
|
|
1bb03cff66 | ||
|
|
7c4be946cb | ||
|
|
d194fb8513 | ||
|
|
b3189d9b15 | ||
|
|
6e985f553b | ||
|
|
e51c2376dd | ||
|
|
38cc021d67 | ||
|
|
41e0a93a8f | ||
|
|
ce97056a7a | ||
|
|
82c062be74 | ||
|
|
95fca3d1d5 | ||
|
|
3fc34ac7ee | ||
|
|
21b683614c | ||
|
|
db96e81f76 | ||
|
|
d0cfe73326 | ||
|
|
57ab219d9b | ||
|
|
c6a37ddca4 | ||
|
|
4c5eb2e713 | ||
|
|
4557427a61 | ||
|
|
b0c0e8bd7a | ||
|
|
68a8555d69 | ||
|
|
baebd7ca29 | ||
|
|
b14f29ab5b | ||
|
|
a8009f72bf | ||
|
|
ba13ac8704 | ||
|
|
f569ac59a7 | ||
|
|
078445658c | ||
|
|
f022da9e5f | ||
|
|
5d23054cb3 | ||
|
|
0b3b40f056 | ||
|
|
6caeffa4be | ||
|
|
22571fb36a | ||
|
|
6ee731ba1a | ||
|
|
79bb9e3172 | ||
|
|
85b711caae | ||
|
|
f4911177da | ||
|
|
77ff83f784 | ||
|
|
b885355e76 | ||
|
|
2d01af8e56 | ||
|
|
bb276bf250 | ||
|
|
93c47a2b94 | ||
|
|
4ca9d478d4 | ||
|
|
485a1961e8 | ||
|
|
d3d06f8ca0 | ||
|
|
569dd5d089 | ||
|
|
3b9bb773fe | ||
|
|
716fc27fdd | ||
|
|
79cdfc8ca6 | ||
|
|
ecb8399005 | ||
|
|
84b084c9b6 | ||
|
|
2ea8afba93 | ||
|
|
f59ec61fa7 | ||
|
|
0168de83de | ||
|
|
fcfbef26e4 | ||
|
|
8ce8e33a44 | ||
|
|
aae7c98aaa | ||
|
|
81dc0e72da | ||
|
|
d6b15e755e | ||
|
|
5e3224c57d | ||
|
|
54840d867e | ||
|
|
3a433b14f2 | ||
|
|
449af6c335 | ||
|
|
fd0517c82b | ||
|
|
543011fa86 | ||
|
|
ac3cee638b | ||
|
|
8ba9574ed4 | ||
|
|
faf4fe0714 | ||
|
|
a14cb2495b | ||
|
|
8d1a946a9b | ||
|
|
8a2839c867 | ||
|
|
6382d141fa | ||
|
|
32c6dbb425 | ||
|
|
6a95c66f5b | ||
|
|
fa62397ff8 | ||
|
|
2b9c3f8dc9 | ||
|
|
82f50dc800 | ||
|
|
2b802ab413 | ||
|
|
c5b4574729 | ||
|
|
2a8c195360 | ||
|
|
cb16f5053f | ||
|
|
e7a54c1a50 | ||
|
|
3ce83f923d | ||
|
|
8545621d39 | ||
|
|
22a0cfdc05 | ||
|
|
f27273e1f0 | ||
|
|
f27388b5d8 | ||
|
|
cd9b2b32aa | ||
|
|
9dad6f202c | ||
|
|
f404d8ccb7 | ||
|
|
5125629f2a | ||
|
|
39d375ecd1 | ||
|
|
b120b2932d | ||
|
|
08888d57cb | ||
|
|
f524dd80f4 | ||
|
|
092951f634 | ||
|
|
d8e52aed87 | ||
|
|
6ec84993bd | ||
|
|
88ad83e3d6 | ||
|
|
d490572410 | ||
|
|
aae27f6be6 | ||
|
|
04e8f8c93d | ||
|
|
d6df31fba1 | ||
|
|
2fdf3b137a | ||
|
|
dbc0105e1a | ||
|
|
a82b93b298 | ||
|
|
7fbd3bac71 | ||
|
|
6305db53c1 | ||
|
|
dda859027c | ||
|
|
203c8b3997 | ||
|
|
000f55a1a2 | ||
|
|
ecacb2b544 | ||
|
|
50b188eebd | ||
|
|
41f13b2a3b | ||
|
|
5dec664ccf | ||
|
|
f9fefaaabe | ||
|
|
995ff58903 | ||
|
|
295e632e81 | ||
|
|
5c0ade35e2 | ||
|
|
fa81c7561f | ||
|
|
c78970c0d0 | ||
|
|
6d6e8d69eb | ||
|
|
fb80ed3143 | ||
|
|
adfa16c899 | ||
|
|
d39b47d665 | ||
|
|
46ef562c50 | ||
|
|
d65a428f2d | ||
|
|
b8d5744c6e | ||
|
|
4151df32c1 | ||
|
|
6172db5326 | ||
|
|
eba277bca8 | ||
|
|
a98709aeae | ||
|
|
466265eaa6 | ||
|
|
ee496f2846 | ||
|
|
93a633092a | ||
|
|
960df88621 | ||
|
|
fef49a0e86 | ||
|
|
fe2294769c | ||
|
|
2b7d0db7f1 | ||
|
|
7ec7d8cf54 | ||
|
|
59b46fc8cd | ||
|
|
f2edc96bb6 | ||
|
|
3430395c85 | ||
|
|
fc477192e5 | ||
|
|
4ba683bb18 | ||
|
|
f1e80f3be0 | ||
|
|
8965fd18aa | ||
|
|
1d150d63c7 | ||
|
|
69f9fcfd20 | ||
|
|
4a69bacc20 | ||
|
|
83b726e5dd | ||
|
|
0dbd90d74e | ||
|
|
2b864aeb14 | ||
|
|
f98d2ffe87 | ||
|
|
8c4b8c6e27 | ||
|
|
1c2dff2655 | ||
|
|
c4b1bfa5f0 | ||
|
|
421afd287a | ||
|
|
4abdc5981a | ||
|
|
4f1d89d37f | ||
|
|
ac90ab7736 | ||
|
|
ae7b59f509 | ||
|
|
b84702349f | ||
|
|
7e5e98e4f2 | ||
|
|
05993fd432 | ||
|
|
75e532417e | ||
|
|
8716d8c188 | ||
|
|
46e013988f | ||
|
|
3b47ce0a37 | ||
|
|
1ba2d40473 | ||
|
|
bca6f58848 | ||
|
|
835e8f9d7a | ||
|
|
781bf867cc | ||
|
|
658c446f13 | ||
|
|
e8b7b53db1 | ||
|
|
68939136c1 | ||
|
|
d7f6d5b9da | ||
|
|
e36c6a31e6 | ||
|
|
e450ad287e | ||
|
|
b951f81db5 | ||
|
|
50ad27a4ab | ||
|
|
ab3c690077 | ||
|
|
2eff6e1974 | ||
|
|
f09a992720 | ||
|
|
4203fdbfef | ||
|
|
eb4f744820 | ||
|
|
48188d7181 | ||
|
|
71bac6f45b | ||
|
|
038f9254d9 | ||
|
|
a196752969 | ||
|
|
21ca92c432 | ||
|
|
2b2f11a74c | ||
|
|
f98d020ead | ||
|
|
0fe2d778aa | ||
|
|
6f44e1093c | ||
|
|
e5dc11e26d | ||
|
|
635df7486f | ||
|
|
c5827b2013 | ||
|
|
b47b66ebff | ||
|
|
622884d67a | ||
|
|
363e8888ae | ||
|
|
a985d5c63d | ||
|
|
ad582da3ca | ||
|
|
abc1b44d8d | ||
|
|
9718fd2496 | ||
|
|
1658776aaf | ||
|
|
2fc66d2835 | ||
|
|
4efe8e83cf | ||
|
|
4b1664236b | ||
|
|
f93446486e | ||
|
|
d0c83d4680 | ||
|
|
7084b17c95 | ||
|
|
9c9c37aa11 | ||
|
|
901becc748 | ||
|
|
68fdae1184 | ||
|
|
8c7400121e | ||
|
|
3b9787d4ee | ||
|
|
7ae9662b4e | ||
|
|
457bd1392a | ||
|
|
a0776fe409 | ||
|
|
3bd9f936da | ||
|
|
386f0bfb4f | ||
|
|
edc91caffb | ||
|
|
27bdd038a8 | ||
|
|
9e2870cc9f | ||
|
|
d356561465 | ||
|
|
9d145c17c3 | ||
|
|
d1aacae0f7 | ||
|
|
e53703b88a | ||
|
|
66be32fbc1 | ||
|
|
4f936f2312 | ||
|
|
c534cf3bca | ||
|
|
d486b379d0 | ||
|
|
d19235993e | ||
|
|
1453ccd5b8 | ||
|
|
55937f9c8e | ||
|
|
4f9215e70f | ||
|
|
e59027e4f7 | ||
|
|
ee73875ff0 | ||
|
|
fe822f7043 | ||
|
|
82f187ce88 | ||
|
|
1c3ae2b678 | ||
|
|
5533f034e2 | ||
|
|
9d9e43b87f | ||
|
|
c81e204fd0 | ||
|
|
cdeb491498 | ||
|
|
c8f9dd2368 | ||
|
|
4ad98540bc | ||
|
|
cd3275ce73 | ||
|
|
db0de73d6e | ||
|
|
6ec2f1f44b | ||
|
|
7544b9fc10 | ||
|
|
4ccedceaa8 | ||
|
|
c496f80379 | ||
|
|
a176184b7d | ||
|
|
f3f7f5db89 | ||
|
|
2770485737 | ||
|
|
18d3283157 | ||
|
|
a882878eba | ||
|
|
2135bbe558 | ||
|
|
73967233e4 | ||
|
|
b058498404 | ||
|
|
b1e8af1c0c | ||
|
|
b69f73b13e | ||
|
|
d68c227aad | ||
|
|
7b64d9946d | ||
|
|
28786f826a | ||
|
|
ee31ba5023 | ||
|
|
d1f0b89e65 | ||
|
|
22e482d965 | ||
|
|
d786a8f820 | ||
|
|
9cf9ff6caf | ||
|
|
bbbe02b227 | ||
|
|
f4edd87ffc | ||
|
|
3589e515dc | ||
|
|
921ceddebf | ||
|
|
c44f3a5889 | ||
|
|
0e4fd4485f | ||
|
|
7ba0d8e07b | ||
|
|
622284740a | ||
|
|
29c0763480 | ||
|
|
6c6aebba88 | ||
|
|
8edc60ffdd | ||
|
|
8f77a14b69 | ||
|
|
db03270135 | ||
|
|
e71b663bf5 | ||
|
|
631b8edefb | ||
|
|
de2b11f39a | ||
|
|
2b7c832847 | ||
|
|
e38d974b50 | ||
|
|
35cefa50fa | ||
|
|
37773c1055 | ||
|
|
a5628cf782 | ||
|
|
ec47f0763d | ||
|
|
55e36d78a4 | ||
|
|
5210f6665c | ||
|
|
0e2904d2c5 | ||
|
|
3fa424f893 | ||
|
|
3f084b06e9 | ||
|
|
282d947c36 | ||
|
|
e291178633 | ||
|
|
46521a46d2 | ||
|
|
9ff0615546 | ||
|
|
c36e012926 | ||
|
|
d019c41f7a | ||
|
|
c7851b9c34 | ||
|
|
5d4b2f9ea9 | ||
|
|
e41da923a3 | ||
|
|
2b01af3de9 | ||
|
|
2e56778038 | ||
|
|
beae68890c | ||
|
|
8b8c9dea8a | ||
|
|
249446e0aa | ||
|
|
cb2873ba1c | ||
|
|
493af2bb16 | ||
|
|
7e017abb30 | ||
|
|
be9a64e654 | ||
|
|
a836872199 | ||
|
|
d8d4260df8 | ||
|
|
e6c6713a1b | ||
|
|
d12e843e4a | ||
|
|
f55dc3006e | ||
|
|
098bc780a2 | ||
|
|
dfaa891281 | ||
|
|
d5e58768aa | ||
|
|
63885da5b9 | ||
|
|
5cc54458b7 | ||
|
|
d2d8d0ab5a | ||
|
|
1a67bfe396 | ||
|
|
26766dcf73 | ||
|
|
c6efab0111 | ||
|
|
e8e5e6ee3c | ||
|
|
6afaaca2e5 | ||
|
|
9668d40d5a | ||
|
|
43020cc474 | ||
|
|
0627716f8a | ||
|
|
dd7663d2ae | ||
|
|
afe1b2bef7 | ||
|
|
46eeb62b04 | ||
|
|
85c7629345 | ||
|
|
b162475391 | ||
|
|
0bbbe08343 | ||
|
|
0b11b08b6e | ||
|
|
8b8b8ac1f8 | ||
|
|
9fa364414c | ||
|
|
1605d39b93 | ||
|
|
be2b3d5ab8 | ||
|
|
061c008e15 | ||
|
|
53da646495 | ||
|
|
627535f33e | ||
|
|
f117d47ffa | ||
|
|
48fd9fbd02 | ||
|
|
dc8837f079 | ||
|
|
fb124f0839 | ||
|
|
0ff027ae2c | ||
|
|
995c7b503b | ||
|
|
9aa47f9768 | ||
|
|
7d8981dd3f | ||
|
|
33931431c3 | ||
|
|
ac41deeeac | ||
|
|
f0fd03b122 | ||
|
|
eda99fc383 | ||
|
|
25ef7a7b1a | ||
|
|
63b469c160 | ||
|
|
f20be398a1 | ||
|
|
25a87ea16a | ||
|
|
f960fe0578 | ||
|
|
2c3742039c | ||
|
|
f5512315d2 | ||
|
|
37329e4184 | ||
|
|
44f86d38f9 | ||
|
|
1901a47df1 | ||
|
|
bccfd92f4a | ||
|
|
ede63b5029 | ||
|
|
b80404f2c6 | ||
|
|
470f1058a8 | ||
|
|
e3adccb528 | ||
|
|
e72e130e9d | ||
|
|
4edaa9fdf5 | ||
|
|
8f61a127b5 | ||
|
|
cf46f4baee | ||
|
|
0e8c631f5e | ||
|
|
c818f3dabc | ||
|
|
48fd6d6d40 | ||
|
|
6f52091668 | ||
|
|
d01e9de8b8 | ||
|
|
13bf42b8b8 | ||
|
|
a540b3f189 | ||
|
|
36bccbc4f3 | ||
|
|
3c70c243c5 | ||
|
|
19df4510c2 | ||
|
|
80899f7010 | ||
|
|
ffaff7afa6 | ||
|
|
e3cee67d77 | ||
|
|
368ab3051f | ||
|
|
529fe9ef75 | ||
|
|
e3dd3424fc | ||
|
|
d7b4a4ce01 | ||
|
|
df9e5f39a7 | ||
|
|
88aa285a79 | ||
|
|
d06378373e | ||
|
|
cb8486a9b2 | ||
|
|
d54deae0ad | ||
|
|
e930ee93f7 | ||
|
|
a9d7a9d128 | ||
|
|
3da18a06d8 | ||
|
|
744cdc3ba8 | ||
|
|
80d34abf49 | ||
|
|
637d812df5 | ||
|
|
c31dcf3632 | ||
|
|
396024713f | ||
|
|
a203499ba3 | ||
|
|
90713c84f3 | ||
|
|
a8fd6de907 | ||
|
|
fc2feabef7 | ||
|
|
984c024ef2 | ||
|
|
c7c51329f4 | ||
|
|
e2f29c4989 | ||
|
|
970e4d295e | ||
|
|
f5781144ab | ||
|
|
9d7061f1a3 | ||
|
|
f9d17f1f6d | ||
|
|
fac2e07333 | ||
|
|
fba81cf3e9 | ||
|
|
738c4b84fb | ||
|
|
de4cb219fb | ||
|
|
4276c703c5 | ||
|
|
f968833570 | ||
|
|
1885655e9a | ||
|
|
e75ac1b4c0 | ||
|
|
e1cfc075c2 | ||
|
|
8cbfd72f68 | ||
|
|
ab73ad4e5f | ||
|
|
b1b60887f0 | ||
|
|
d9cebeaf34 | ||
|
|
fa49651301 | ||
|
|
2eb34edeba | ||
|
|
5a44135233 | ||
|
|
2b8b51291f | ||
|
|
cc8178e911 | ||
|
|
e9eeb84040 | ||
|
|
86cf593e87 | ||
|
|
b85f9c183c | ||
|
|
39f312108d | ||
|
|
06464f7cfc | ||
|
|
9087ace2af | ||
|
|
d34d1f0173 | ||
|
|
670d982568 | ||
|
|
97770d5aeb | ||
|
|
a48847269a | ||
|
|
6a0e54f84f | ||
|
|
cb61d2294a | ||
|
|
29630b2d7f | ||
|
|
aa7f2ac954 | ||
|
|
c693aa8dac | ||
|
|
b81835b5ca | ||
|
|
c37416b6aa | ||
|
|
65d23a1d75 | ||
|
|
092f58a762 | ||
|
|
1f02c5f2e4 | ||
|
|
2ab2da5e02 | ||
|
|
5a6d1369f6 | ||
|
|
5a1248f1d4 | ||
|
|
14d0a9eef6 | ||
|
|
12b60e7c25 | ||
|
|
c4b42e9f59 | ||
|
|
71ff21f57c | ||
|
|
941c4a20d6 | ||
|
|
73abdedbc9 | ||
|
|
5803d9b689 | ||
|
|
61499e870a | ||
|
|
ba36ba8853 | ||
|
|
dde5b81079 | ||
|
|
ad73f571b8 | ||
|
|
8698f9dce6 | ||
|
|
6ca97e6e62 | ||
|
|
696ee52ffd | ||
|
|
096196281e | ||
|
|
5a96ca4a7f | ||
|
|
728617d25d | ||
|
|
085c3821a8 | ||
|
|
41e4cefc2e | ||
|
|
54617805b8 | ||
|
|
13225f1371 | ||
|
|
e548afd175 | ||
|
|
060491c4ee | ||
|
|
b764665f4d | ||
|
|
ee6519f8e2 | ||
|
|
741a166f3c | ||
|
|
23019946c2 | ||
|
|
2f3d8659b1 | ||
|
|
0b7239ebc7 | ||
|
|
80377eeb13 | ||
|
|
ac36153e99 | ||
|
|
2928891bd0 | ||
|
|
847f1dd99c | ||
|
|
abdb87dd23 | ||
|
|
606ecae5d7 | ||
|
|
016e469caf | ||
|
|
1fe2a74995 | ||
|
|
9385bea571 | ||
|
|
0e9fe272bc | ||
|
|
7cc414135a | ||
|
|
e3cc3e55c8 | ||
|
|
b2431d105e | ||
|
|
1c2782354c | ||
|
|
32b2e416cc | ||
|
|
ace8a2a868 | ||
|
|
39cc12e7c2 | ||
|
|
06e39625ee | ||
|
|
284fdb1745 | ||
|
|
96b2c20991 | ||
|
|
09e17f99c5 | ||
|
|
469bcc28ac | ||
|
|
d6771e513e | ||
|
|
f078ffc5e6 | ||
|
|
d040b68aee | ||
|
|
409a79621a | ||
|
|
4d2311655b | ||
|
|
f78b02477b | ||
|
|
c5e4326337 | ||
|
|
0670338e0b | ||
|
|
f6104adcb6 | ||
|
|
55b498b6b5 | ||
|
|
9b23ff5d50 | ||
|
|
ac25dd9be6 | ||
|
|
f71d3cce93 | ||
|
|
914d793858 | ||
|
|
81ef1fd0cc | ||
|
|
b3e45219c2 | ||
|
|
fdf2571679 | ||
|
|
1c60c6785c | ||
|
|
482501c21f | ||
|
|
a997714648 | ||
|
|
b89fc0564b | ||
|
|
a2b2ae35b2 | ||
|
|
8cbba1d164 | ||
|
|
75b28ab49d | ||
|
|
8eb3a5b557 | ||
|
|
bdcfd2d730 | ||
|
|
93484c2a62 | ||
|
|
97fc0ca49b | ||
|
|
f24eb81dbe | ||
|
|
4ae2dde5c3 | ||
|
|
2ecd290c0d | ||
|
|
ae512e20f5 | ||
|
|
7171260b94 | ||
|
|
f8712c6cab | ||
|
|
5ce236a691 | ||
|
|
64b28e0839 | ||
|
|
cb2d32bdc4 | ||
|
|
6e3b51681f | ||
|
|
6f1318c474 | ||
|
|
33f022617a | ||
|
|
85fb46d8a6 | ||
|
|
80bad4a3b4 | ||
|
|
a51c68aacb | ||
|
|
4d70e7bf78 | ||
|
|
c38b668fc3 | ||
|
|
7ec97ed5f2 | ||
|
|
491ee5d106 | ||
|
|
4c78bdcfaa | ||
|
|
857f5d6e65 | ||
|
|
b3b6c6b576 | ||
|
|
52f939caa7 | ||
|
|
00b5d7b037 | ||
|
|
9abcf5cb48 | ||
|
|
935813457f | ||
|
|
9ba9e99716 | ||
|
|
70c911b63f | ||
|
|
39457234db | ||
|
|
f35fa8c178 | ||
|
|
96123b9059 | ||
|
|
98a34e43ab | ||
|
|
721bee1b70 | ||
|
|
975368ba18 | ||
|
|
077b46e014 | ||
|
|
e022805f1d | ||
|
|
e36028b7d2 | ||
|
|
88f1e7a9a7 | ||
|
|
0dee6fc28c | ||
|
|
9bbbc1b265 | ||
|
|
558890ad0e | ||
|
|
5175e87fda | ||
|
|
226429058c | ||
|
|
44b070415b | ||
|
|
d43a79eec9 | ||
|
|
5154054af4 | ||
|
|
b90c5d6015 | ||
|
|
e84b00964f | ||
|
|
3596558861 | ||
|
|
8a07f57ba4 | ||
|
|
8b75bbe47d | ||
|
|
e48c9826e3 | ||
|
|
6ff65e6755 | ||
|
|
fa434a1837 | ||
|
|
b8db2c0a4a | ||
|
|
04860b6324 | ||
|
|
5848f75278 | ||
|
|
0a5712ada4 | ||
|
|
9756824f64 | ||
|
|
46fe47b8e0 | ||
|
|
a1d5fba666 | ||
|
|
aed91e49ae | ||
|
|
39d6a9601f | ||
|
|
2cb43449ee | ||
|
|
fec3087eef | ||
|
|
8d09124c62 | ||
|
|
657dde6208 | ||
|
|
ea6b5b694b | ||
|
|
1dbb86f8c7 | ||
|
|
7c3eca833f | ||
|
|
228a8e8c1f |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -14,6 +14,8 @@
|
||||
*.so
|
||||
*.so.*
|
||||
*.sw*
|
||||
*.su
|
||||
*.patch
|
||||
*~
|
||||
|
||||
# gcov files:
|
||||
@@ -50,7 +52,6 @@ daemons/dmfilemapd
|
||||
daemons/lvmetad/
|
||||
|
||||
tools/man-generator
|
||||
tools/man-generator.c
|
||||
|
||||
test/.lib-dir-stamp
|
||||
test/.tests-stamp
|
||||
@@ -144,6 +145,8 @@ test/lib/lvmchange
|
||||
test/lib/lvmdbusd.profile
|
||||
test/lib/lvmdevices
|
||||
test/lib/lvmetad
|
||||
test/lib/lvmlockctl
|
||||
test/lib/lvmlockd
|
||||
test/lib/lvmpolld
|
||||
test/lib/lvm_import_vdo
|
||||
test/lib/lvm_vdo_wrapper
|
||||
|
||||
104
.gitlab-ci.yml
Normal file
104
.gitlab-ci.yml
Normal file
@@ -0,0 +1,104 @@
|
||||
stages:
|
||||
- approve
|
||||
- test
|
||||
|
||||
approve1:
|
||||
stage: approve
|
||||
script:
|
||||
- echo "Approved..."
|
||||
rules:
|
||||
# TODO: Filter only safe repositories, or user in developers
|
||||
- if: $CI_PROJECT_PATH != "csonto/lvm2" && $CI_PROJECT_PATH != "lvmteam/lvm2"
|
||||
when: manual
|
||||
# TODO: for other branches than main/rhel: run pipeline only when requested:
|
||||
- if: $CI_COMMIT_BRANCH != "main" && $CI_COMMIT_BRANCH !~ "^rhel.*"
|
||||
when: manual
|
||||
- when: on_success
|
||||
allow_failure: false
|
||||
|
||||
|
||||
pages:
|
||||
image: elecnix/ikiwiki
|
||||
stage: test
|
||||
script:
|
||||
- ikiwiki --setup ikiwiki.setup --libdir themes/ikistrap/lib
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
only:
|
||||
refs:
|
||||
- main
|
||||
changes:
|
||||
- doc/**/*
|
||||
- ikiwiki.setup
|
||||
|
||||
|
||||
# TODO:
|
||||
# - check results of autoreconf and make generate - may need additional commit
|
||||
# - we need a particular setup (rawhide OR latest supported fedora?)
|
||||
# - do make rpm and publish results as artifacts - we will use packit/COPR for this eventually
|
||||
|
||||
# Run on any commits to main (master), rhel8, rhel9 branches
|
||||
test-job:
|
||||
stage: test
|
||||
parallel:
|
||||
matrix:
|
||||
- TAG: rhel8
|
||||
CONFIGURE: >
|
||||
--with-cluster=internal
|
||||
--enable-cmirrord
|
||||
- TAG: rhel9
|
||||
CONFIGURE: >
|
||||
--with-default-use-devices-file=1
|
||||
--enable-app-machineid
|
||||
--enable-editline
|
||||
--disable-readline
|
||||
artifacts:
|
||||
paths:
|
||||
- test/results/
|
||||
expire_in: 1 week
|
||||
tags:
|
||||
- ${TAG}
|
||||
timeout: 2h
|
||||
script:
|
||||
# Common options go here, diffs to the above matrix
|
||||
- >
|
||||
./configure ${CONFIGURE}
|
||||
--enable-fsadm
|
||||
--enable-write_install
|
||||
--enable-pkgconfig
|
||||
--enable-cmdlib
|
||||
--enable-dmeventd
|
||||
--enable-blkid_wiping
|
||||
--enable-udev_sync
|
||||
--with-thin=internal
|
||||
--with-cache=internal
|
||||
--enable-lvmpolld
|
||||
--enable-lvmlockd-dlm --enable-lvmlockd-dlmcontrol
|
||||
--enable-lvmlockd-sanlock
|
||||
--enable-dbus-service --enable-notify-dbus
|
||||
--enable-dmfilemapd
|
||||
--with-writecache=internal
|
||||
--with-vdo=internal --with-vdo-format=/usr/bin/vdoformat
|
||||
--with-integrity=internal
|
||||
--disable-silent-rules
|
||||
- make
|
||||
- rm -rf test/results
|
||||
- mkdir -p /dev/shm/lvm2-test
|
||||
- mount -o remount,dev /dev/shm
|
||||
# TODO: Need to distinguish failed test from failed harness
|
||||
# TODO: Also need a way to find if run is incomplete, e.g. full disk resulting in many skipped tests
|
||||
- VERBOSE=0 BATCH=1 LVM_TEST_DIR=/dev/shm/lvm2-test make check || true
|
||||
- rm -rf /dev/shm/lvm2-test
|
||||
- cut -d' ' -f2 test/results/list | sort | uniq -c
|
||||
# Filter artifacts - keep only logs from tests which are not pass
|
||||
- cd test/results && rm $(grep 'passed$' list | cut -d' ' -f1 | sed -e 's|/|_|g' -e 's|.*|\0.txt|')
|
||||
# TODO: Keep a list of known failures, and translate into regexp - or simply use python...
|
||||
- if grep failed test/results/list | grep -v '\\\(dbustest\|lvconvert-mirror\)\.sh' | sort; then false; else true; fi
|
||||
rules:
|
||||
# Filter only safe repositories, or user in developers:
|
||||
# NOTE: Already done in approve stage, may be more caution than necessary
|
||||
- if: $CI_PROJECT_PATH != "csonto/lvm2" && $CI_PROJECT_PATH != "lvmteam/lvm2"
|
||||
when: manual
|
||||
- when: on_success
|
||||
|
||||
@@ -38,7 +38,7 @@ ifeq ($(MAKECMDGOALS),distclean)
|
||||
udev po
|
||||
tools.distclean: test.distclean
|
||||
endif
|
||||
DISTCLEAN_DIRS += lcov_reports*
|
||||
DISTCLEAN_DIRS += lcov_reports* autom4te.cache
|
||||
DISTCLEAN_TARGETS += config.cache config.log config.status make.tmpl
|
||||
|
||||
include make.tmpl
|
||||
@@ -55,7 +55,7 @@ po: tools daemons
|
||||
man: tools
|
||||
all_man: tools
|
||||
test: tools daemons
|
||||
unit-test run-unit-test: test
|
||||
unit-test run-unit-test: test libdm
|
||||
|
||||
daemons.device-mapper: libdm.device-mapper
|
||||
tools.device-mapper: libdm.device-mapper
|
||||
@@ -127,6 +127,7 @@ all_man:
|
||||
|
||||
install_system_dirs:
|
||||
$(INSTALL_DIR) $(DESTDIR)$(DEFAULT_SYS_DIR)
|
||||
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_SYS_DIR)/devices
|
||||
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_ARCHIVE_DIR)
|
||||
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_BACKUP_DIR)
|
||||
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_CACHE_DIR)
|
||||
|
||||
29
README
29
README
@@ -1,7 +1,5 @@
|
||||
This tree contains the LVM2 and device-mapper tools and libraries.
|
||||
|
||||
This is development branch, for stable 2.02 release see stable-2.02 branch.
|
||||
|
||||
For more information about LVM2 read the changelog in the WHATS_NEW file.
|
||||
Installation instructions are in INSTALL.
|
||||
|
||||
@@ -12,20 +10,30 @@ Tarballs are available from:
|
||||
https://github.com/lvmteam/lvm2/releases
|
||||
|
||||
The source code is stored in git:
|
||||
https://sourceware.org/git/?p=lvm2.git
|
||||
git clone git://sourceware.org/git/lvm2.git
|
||||
mirrored to:
|
||||
https://github.com/lvmteam/lvm2
|
||||
https://gitlab.com/lvmteam/lvm2
|
||||
Clone:
|
||||
git clone git@gitlab.com:lvmteam/lvm2.git
|
||||
Anonymous access:
|
||||
git clone https://gitlab.com/lvmteam/lvm2.git
|
||||
Mirrored to:
|
||||
* https://github.com/lvmteam/lvm2
|
||||
git clone https://github.com/lvmteam/lvm2.git
|
||||
git clone git@github.com:lvmteam/lvm2.git
|
||||
* https://sourceware.org/git/?p=lvm2.git
|
||||
git clone https://sourceware.org/git/lvm2.git
|
||||
git clone git://sourceware.org/git/lvm2.git
|
||||
|
||||
Mailing list for general discussion related to LVM2:
|
||||
linux-lvm@redhat.com
|
||||
Subscribe from https://www.redhat.com/mailman/listinfo/linux-lvm
|
||||
linux-lvm@lists.linux.dev
|
||||
Subscribe via email to: linux-lvm+subscribe@lists.linux.dev
|
||||
Archive https://lore.kernel.org/linux-lvm/
|
||||
Older archive https://listman.redhat.com/archives/linux-lvm/
|
||||
|
||||
Mailing lists for LVM2 development, patches and commits:
|
||||
lvm-devel@redhat.com
|
||||
Subscribe from https://www.redhat.com/mailman/listinfo/lvm-devel
|
||||
lvm-devel@lists.linux.dev
|
||||
Subscribe via email to: lvm-devel+subscribe@lists.linux.dev
|
||||
Archive https://lore.kernel.org/lvm-devel/
|
||||
Older archive https://listman.redhat.com/archives/lvm-devel/
|
||||
|
||||
lvm2-commits@lists.fedorahosted.org (Read-only archive of commits)
|
||||
Subscribe from https://fedorahosted.org/mailman/listinfo/lvm2-commits
|
||||
@@ -41,6 +49,7 @@ Website:
|
||||
Report upstream bugs at:
|
||||
https://bugzilla.redhat.com/enter_bug.cgi?product=LVM%20and%20device-mapper
|
||||
or open issues at:
|
||||
https://gitlab.com/groups/lvmteam/-/issues
|
||||
https://github.com/lvmteam/lvm2/issues
|
||||
|
||||
The source code repository used until 7th June 2012 is accessible using CVS:
|
||||
|
||||
5
TESTING
5
TESTING
@@ -21,6 +21,11 @@ You MUST disable (or mask) any LVM daemons:
|
||||
- clvmd
|
||||
- cmirrord
|
||||
|
||||
Some lvm.conf options should be set:
|
||||
|
||||
- global/event_activation = 0
|
||||
- activation/monitoring = 0
|
||||
|
||||
For running cluster tests, we are using singlenode locking. Pass
|
||||
`--with-clvmd=singlenode` to configure.
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.02.196-git (2023-04-21)
|
||||
1.02.199-git (2024-05-16)
|
||||
|
||||
105
WHATS_NEW
105
WHATS_NEW
@@ -1,8 +1,101 @@
|
||||
version 2.03.22 -
|
||||
=================================
|
||||
Version 2.03.25 -
|
||||
==================
|
||||
Utilize more radix_tree instead of dm_hash and btree.
|
||||
Refactor DM uuid caching from device_mapper directory.
|
||||
Enhance checking for DM uuid device.
|
||||
Fix lvm shell command completion on tab key (2.03.24).
|
||||
Avoid lockd_vg call to lvmlockd for local VGs.
|
||||
Allow forced change of locktype from none.
|
||||
Handle OPTIONS defined in /etc/sysconfig/lvmlockd.
|
||||
|
||||
Version 2.03.24 - 16th May 2024
|
||||
===============================
|
||||
Lvconvert supports VDO options for thin-pool with vdo conversion.
|
||||
Improve placement to .data.rel.ro and .rodata sections.
|
||||
Fix support for -y and -W when creating thinpool with vdo.
|
||||
Bettter support for runtime valgrind detection.
|
||||
Allow command interruption when communicating with dmeventd.
|
||||
Fix resize of VDO volume used for thin pool data volume.
|
||||
Use -Wl,-z,now and -Wl,--as-needed for compilation by default.
|
||||
Require 3.7 as minimal version for sanlock.
|
||||
Share code for closing opened desriptors on program startup.
|
||||
Fix memleak in lvmcache.
|
||||
Add configure --with-default-event-activation=ON setting.
|
||||
Fix return value from reporter function when hitting internal error.
|
||||
Skip checking of pools for lvremove and vgremove commands.
|
||||
VDO modprobes dm-vdo for 6.9 kernel and kvdo for older kernel version.
|
||||
Fix lvs reporting for VDO volumes with new upstream kernel driver.
|
||||
Don't import DM_UDEV_DISABLE_OTHER_RULES_FLAG in LVM rules, DM rules cover it.
|
||||
Fix table line generation for cache snapshots using cachevol.
|
||||
Enhance lvconvert support for external origins stacking.
|
||||
When swapping LV names also swap properties like hostname, time and data.
|
||||
Fix removal of stacked external origins.
|
||||
Lock filesystem when converting volume to read-only external origin.
|
||||
Support external origin between different thin-pool.
|
||||
Improve validation of acceptable volumes for external origins.
|
||||
Reduce amount of preloaded devices for complex device trees.
|
||||
Avoid logging problems from monitoring snapshots with inactive origins.
|
||||
Check for cache policy module presence in kernel's builtin modules file.
|
||||
Add configure --with-modulesdir to select kernel modules directory.
|
||||
Support creation of thin-pool with VDO use for its data volume.
|
||||
|
||||
Version 2.03.23 - 21st November 2023
|
||||
====================================
|
||||
Set the first lv_attr flag for raid integrity images to i or I.
|
||||
Add -A option for pvs and pvscan to show PVs outside devices file.
|
||||
Improve searched_devnames temp file usage to prevent redundant scanning.
|
||||
Change default search_for_devnames from auto to all.
|
||||
Add lvmdevices --refresh to search for missing PVIDs on all devices.
|
||||
Add comparison between old and new entries in lvmdevices --check.
|
||||
Fix device_id matching order - match non-devname first.
|
||||
Fix "lvconvert -m 0" when there is other than first in-sync leg.
|
||||
Use system.devices as default for dmeventd when dmeventd.devices is undefined.
|
||||
Accept WWIDs containing QEMU HARDDISK for device_id.
|
||||
Improve handling of non-standard WWID prefixes used for device_id.
|
||||
Configure automatically enables cmdlib for dmeventd and notify-dbus for dbus.
|
||||
Fix hint calculation for pools with zero or error segment.
|
||||
Configure supports --disable-shared to build only static binaries.
|
||||
Configure supports --without-{blkid|systemd|udev} for easier static build.
|
||||
Refresh device ids if the system changes.
|
||||
Fix pvmove when specifying raid components as moved LVs.
|
||||
Enhance error detection for lvm_import_vdo.
|
||||
Support PV lists with thin lvconvert.
|
||||
Fix support for lvm_import_vdo with SCSI VDO volumes.
|
||||
Fix locking issue leading to hanging concurrent vgchange --refresh.
|
||||
Recognize lvm.conf report/headings=2 for full column names in report headings.
|
||||
Add --headings none|abbrev|full cmd line option to set report headings type.
|
||||
Fix conversion to thin pool using lvmlockd.
|
||||
Fix conversion from thick into thin volume using lvmlockd.
|
||||
Require writable LV for conversion to vdo pool.
|
||||
Fix return value from lvconvert integrity remove.
|
||||
Preserve UUID for pool metadata spare.
|
||||
Preserve UUID for swapped pool metadata.
|
||||
Rewrite validation of device name entries used as device_id.
|
||||
|
||||
version 2.03.22 - 02nd August 2023
|
||||
==================================
|
||||
Fix pv_major/pv_minor report field types so they are integers, not strings.
|
||||
Add lvmdevices --delnotfound to delete entries for missing devices.
|
||||
Always use cachepool name for metadata backup LV for lvconvert --repair.
|
||||
Make metadata backup LVs read-only after pool's lvconvert --repair.
|
||||
Improve VDO and Thin support with lvmlockd.
|
||||
Handle 'lvextend --usepolicies' for pools for all activation variants.
|
||||
Fix memleak in vgchange autoactivation setup.
|
||||
Update py-compile building script.
|
||||
Support conversion from thick to fully provisioned thin LV.
|
||||
Cache/Thin-pool can use error and zero volumes for testing.
|
||||
Individual thin volume can be cached, but cannot take snapshot.
|
||||
Better internal support for handling error and zero target (for testing).
|
||||
Resize COW above trimmed maximal size is does not return error.
|
||||
Support parsing of vdo geometry format version 4.
|
||||
Add lvm.conf thin_restore and cache_restore settings.
|
||||
Handle multiple mounts while resizing volume with a FS.
|
||||
Handle leading/trailing spaces in sys_wwid and sys_serial used by device_id.
|
||||
Enhance lvm_import_vdo and use snapshot when converting VDO volume.
|
||||
Fix parsed of VDO metadata.
|
||||
Fix parsing of VDO metadata.
|
||||
Fix failing -S|--select for non-reporting cmds if using LV info/status fields.
|
||||
Allow snapshots of raid+integrity LV.
|
||||
Fix multisegment RAID1 allocator to prevent using single disk for more legs.
|
||||
|
||||
version 2.03.21 - 21st April 2023
|
||||
=================================
|
||||
@@ -146,7 +239,7 @@ Version 2.03.12 - 07th May 2021
|
||||
Fix IMSM MD RAID detection on 4k devices.
|
||||
Check for presence of VDO target before starting any conversion.
|
||||
Support metatadata profiles with volume VDO pool conversions.
|
||||
Support -Zn for conversion of already formated VDO pools.
|
||||
Support -Zn for conversion of already formatted VDO pools.
|
||||
Avoid removing LVs on error path of lvconvert during creation volumes.
|
||||
Fix crashing lvdisplay when thin volume was waiting for merge.
|
||||
Support option --errorwhenfull when converting volume to thin-pool.
|
||||
@@ -3232,7 +3325,7 @@ Version 2.02.68 - 23rd June 2010
|
||||
Add device name and offset to raw_read_mda_header error messages.
|
||||
Honour log argument when down-converting stacked mirror.
|
||||
Sleep to workaround clvmd -S race: socket closed early and server drops cmd.
|
||||
Use early udev synchronisation and update of dev nodes for clustered mirrors.
|
||||
Use early udev synchronization and update of dev nodes for clustered mirrors.
|
||||
Remove incorrect inclusion of kdev_t.h from cmirrord/functions.h.
|
||||
Add man pages for lvmconf and non-existent lvmsadc and lvmsar tools.
|
||||
Exit successfully when using -o help (but not -o +help) with LVM reports.
|
||||
@@ -5366,3 +5459,5 @@ Display output. Some metadata information cannot yet be displayed.
|
||||
|
||||
Recovery tools to salvage "lost" metadata directly from the disks:
|
||||
but we hope the new format will mean such tools are hardly ever needed!
|
||||
|
||||
|
||||
|
||||
39
WHATS_NEW_DM
39
WHATS_NEW_DM
@@ -1,5 +1,36 @@
|
||||
Version 1.02.196 -
|
||||
==================================
|
||||
Version 1.02.199 -
|
||||
===================
|
||||
|
||||
Version 1.02.198 - 16th May 2024
|
||||
================================
|
||||
Fix static only compilation of libdevmapper.a and dmsetup tool.
|
||||
Use better code for closing opened descriptors when starting dmeventd.
|
||||
Correct dmeventd -R for systemd environment.
|
||||
Restart of dmeventd -R checks pid file to detect running dmeventd first.
|
||||
Query with dmeventd -i quickly ends when there is no running dmeventd.
|
||||
Enhance dm_get_status_raid to handle mismatching status or reported legs.
|
||||
Create /dev/disk/by-label symlinks for DM devs that have crypto as next layer.
|
||||
Persist udev db for DM devs on cleanup used in initrd to rootfs transition.
|
||||
Process synthetic udev events other than 'add/change' as 'change' events.
|
||||
Increase DM_UDEV_RULES_VSN to 3 to indicate changed udev rules.
|
||||
Rename DM_NOSCAN to .DM_NOSCAN so it's not stored in udev db.
|
||||
Rename DM_SUSPENDED to .DM_SUSPENDED so it's not stored in udev db.
|
||||
Do not import DM_UDEV_DISABLE_OTHER_RULES_FLAG from db in 10-dm-disk.rules.
|
||||
Test DISK_RO after importing properties from db in 10-dm.rules.
|
||||
Also import ID_FS_TYPE in 13-dm-disk.rules from db if needed.
|
||||
|
||||
Version 1.02.197 - 21st November 2023
|
||||
=====================================
|
||||
Fix invalid JSON report if using DM_REPORT_OUTPUT_MULTIPLE_TIMES and selection.
|
||||
Propagate ioctl errno from dm_task_run when creating new table line.
|
||||
Add support for group aliases in dmstats.
|
||||
Add support for exit-on file for dmeventd to reduce shutdown delays.
|
||||
Add configure option --with-dmeventd-exit-on-path to specify default path.
|
||||
Add dmsetup --headings none|abbrev|full to set report headings type.
|
||||
Add DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS to provide alternative headings.
|
||||
|
||||
Version 1.02.196 - 02nd August 2023
|
||||
===================================
|
||||
|
||||
Version 1.02.195 - 21st April 2023
|
||||
==================================
|
||||
@@ -1122,7 +1153,7 @@ Version 1.02.37 - 15th September 2009
|
||||
Version 1.02.36 - 6th August 2009
|
||||
=================================
|
||||
Add udevcookies, udevcomplete, udevcomplete_all and --noudevwait to dmsetup.
|
||||
Add libdevmapper functions to support synchronisation with udev.
|
||||
Add libdevmapper functions to support synchronization with udev.
|
||||
|
||||
Version 1.02.35 - 28th July 2009
|
||||
================================
|
||||
@@ -1525,3 +1556,5 @@ Version 1.00.08 - 27 Feb 2004
|
||||
Fixed DESTDIR for make install/install_static_lib.
|
||||
Updated README/INSTALL to reflect move to sources.redhat.com.
|
||||
Updated autoconf files to 2003-06-17.
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/bin/sh
|
||||
# py-compile - Compile a Python program
|
||||
|
||||
scriptversion=2011-06-08.12; # UTC
|
||||
scriptversion=2023-03-30.00; # UTC
|
||||
|
||||
# Copyright (C) 2000-2014 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2000-2023 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -16,7 +16,7 @@ scriptversion=2011-06-08.12; # UTC
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -27,7 +27,7 @@ scriptversion=2011-06-08.12; # UTC
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
if [ -z "$PYTHON" ]; then
|
||||
if test -z "$PYTHON"; then
|
||||
PYTHON=python
|
||||
fi
|
||||
|
||||
@@ -62,13 +62,19 @@ while test $# -ne 0; do
|
||||
;;
|
||||
-h|--help)
|
||||
cat <<\EOF
|
||||
Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..."
|
||||
Usage: py-compile [options] FILES...
|
||||
|
||||
Byte compile some python scripts FILES. Use --destdir to specify any
|
||||
leading directory path to the FILES that you don't want to include in the
|
||||
byte compiled file. Specify --basedir for any additional path information you
|
||||
do want to be shown in the byte compiled file.
|
||||
|
||||
Options:
|
||||
--basedir DIR Prefix all FILES with DIR, and include in error messages.
|
||||
--destdir DIR Prefix all FILES with DIR before compiling.
|
||||
-v, --version Display version information.
|
||||
-h, --help This help screen.
|
||||
|
||||
Example:
|
||||
py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py
|
||||
|
||||
@@ -94,77 +100,143 @@ EOF
|
||||
shift
|
||||
done
|
||||
|
||||
files=$*
|
||||
if test -z "$files"; then
|
||||
usage_error "no files given"
|
||||
if test $# -eq 0; then
|
||||
usage_error "no files given"
|
||||
fi
|
||||
|
||||
# if basedir was given, then it should be prepended to filenames before
|
||||
# byte compilation.
|
||||
if [ -z "$basedir" ]; then
|
||||
pathtrans="path = file"
|
||||
if test -z "$basedir"; then
|
||||
pathtrans="path = file"
|
||||
else
|
||||
pathtrans="path = os.path.join('$basedir', file)"
|
||||
pathtrans="path = os.path.join('$basedir', file)"
|
||||
fi
|
||||
|
||||
# if destdir was given, then it needs to be prepended to the filename to
|
||||
# byte compile but not go into the compiled file.
|
||||
if [ -z "$destdir" ]; then
|
||||
filetrans="filepath = path"
|
||||
if test -z "$destdir"; then
|
||||
filetrans="filepath = path"
|
||||
else
|
||||
filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
|
||||
filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
|
||||
fi
|
||||
|
||||
$PYTHON -c "
|
||||
import sys, os, py_compile, imp
|
||||
python_major=`$PYTHON -c 'import sys; print(sys.version_info[0])'`
|
||||
if test -z "$python_major"; then
|
||||
usage_error "could not determine $PYTHON major version"
|
||||
fi
|
||||
|
||||
files = '''$files'''
|
||||
case $python_major in
|
||||
[01])
|
||||
usage_error "python version 0.x and 1.x not supported"
|
||||
;;
|
||||
esac
|
||||
|
||||
python_minor=`$PYTHON -c 'import sys; print(sys.version_info[1])'`
|
||||
|
||||
# NB: When adding support for newer versions, prefer copying & adding new cases
|
||||
# rather than try to keep things merged with shell variables.
|
||||
|
||||
# First byte compile (no optimization) all the modules.
|
||||
# This works for all currently known Python versions.
|
||||
$PYTHON -c "
|
||||
import sys, os, py_compile
|
||||
|
||||
try:
|
||||
import importlib
|
||||
except ImportError:
|
||||
importlib = None
|
||||
|
||||
# importlib.util.cache_from_source was added in 3.4
|
||||
if (
|
||||
hasattr(importlib, 'util')
|
||||
and hasattr(importlib.util, 'cache_from_source')
|
||||
):
|
||||
destpath = importlib.util.cache_from_source
|
||||
else:
|
||||
destpath = lambda filepath: filepath + 'c'
|
||||
|
||||
sys.stdout.write('Byte-compiling python modules...\n')
|
||||
for file in files.split():
|
||||
for file in sys.argv[1:]:
|
||||
$pathtrans
|
||||
$filetrans
|
||||
if not os.path.exists(filepath) or not (len(filepath) >= 3
|
||||
and filepath[-3:] == '.py'):
|
||||
continue
|
||||
sys.stdout.write(file)
|
||||
if (
|
||||
not os.path.exists(filepath)
|
||||
or not (len(filepath) >= 3 and filepath[-3:] == '.py')
|
||||
):
|
||||
continue
|
||||
sys.stdout.write(file + ' ')
|
||||
sys.stdout.flush()
|
||||
if hasattr(imp, 'get_tag'):
|
||||
py_compile.compile(filepath, imp.cache_from_source(filepath), path)
|
||||
else:
|
||||
py_compile.compile(filepath, filepath + 'c', path)
|
||||
sys.stdout.write('\n')" || exit $?
|
||||
py_compile.compile(filepath, destpath(filepath), path)
|
||||
sys.stdout.write('\n')" "$@" || exit $?
|
||||
|
||||
# this will fail for python < 1.5, but that doesn't matter ...
|
||||
# Then byte compile w/optimization all the modules.
|
||||
$PYTHON -O -c "
|
||||
import sys, os, py_compile, imp
|
||||
import sys, os, py_compile
|
||||
|
||||
# pypy does not use .pyo optimization
|
||||
if hasattr(sys, 'pypy_translation_info'):
|
||||
try:
|
||||
import importlib
|
||||
except ImportError:
|
||||
importlib = None
|
||||
|
||||
# importlib.util.cache_from_source was added in 3.4
|
||||
if (
|
||||
hasattr(importlib, 'util')
|
||||
and hasattr(importlib.util, 'cache_from_source')
|
||||
):
|
||||
destpath = importlib.util.cache_from_source
|
||||
else:
|
||||
destpath = lambda filepath: filepath + 'o'
|
||||
|
||||
# pypy2 does not use .pyo optimization
|
||||
if sys.version_info.major <= 2 and hasattr(sys, 'pypy_translation_info'):
|
||||
sys.exit(0)
|
||||
|
||||
files = '''$files'''
|
||||
sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
|
||||
for file in files.split():
|
||||
for file in sys.argv[1:]:
|
||||
$pathtrans
|
||||
$filetrans
|
||||
if not os.path.exists(filepath) or not (len(filepath) >= 3
|
||||
and filepath[-3:] == '.py'):
|
||||
continue
|
||||
sys.stdout.write(file)
|
||||
if (
|
||||
not os.path.exists(filepath)
|
||||
or not (len(filepath) >= 3 and filepath[-3:] == '.py')
|
||||
):
|
||||
continue
|
||||
sys.stdout.write(file + ' ')
|
||||
sys.stdout.flush()
|
||||
if hasattr(imp, 'get_tag'):
|
||||
py_compile.compile(filepath, imp.cache_from_source(filepath, False), path)
|
||||
else:
|
||||
py_compile.compile(filepath, filepath + 'o', path)
|
||||
sys.stdout.write('\n')" 2>/dev/null || :
|
||||
py_compile.compile(filepath, destpath(filepath), path)
|
||||
sys.stdout.write('\n')" "$@" 2>/dev/null || exit $?
|
||||
|
||||
# Then byte compile w/more optimization.
|
||||
# Only do this for Python 3.5+, see https://bugs.gnu.org/38043 for background.
|
||||
case $python_major.$python_minor in
|
||||
2.*|3.[0-4])
|
||||
;;
|
||||
*)
|
||||
$PYTHON -OO -c "
|
||||
import sys, os, py_compile, importlib
|
||||
|
||||
sys.stdout.write('Byte-compiling python modules (more optimized versions)'
|
||||
' ...\n')
|
||||
for file in sys.argv[1:]:
|
||||
$pathtrans
|
||||
$filetrans
|
||||
if (
|
||||
not os.path.exists(filepath)
|
||||
or not (len(filepath) >= 3 and filepath[-3:] == '.py')
|
||||
):
|
||||
continue
|
||||
sys.stdout.write(file + ' ')
|
||||
sys.stdout.flush()
|
||||
py_compile.compile(filepath, importlib.util.cache_from_source(filepath), path)
|
||||
sys.stdout.write('\n')" "$@" 2>/dev/null || exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
||||
@@ -31,10 +31,10 @@ CLEAN_TARGETS += $(BASE_DEPENDS) $(BASE_OBJECTS) \
|
||||
$(BASE_TARGET)
|
||||
|
||||
$(BASE_TARGET): $(BASE_OBJECTS)
|
||||
@echo " [AR] $@"
|
||||
$(SHOW) " [AR] $@"
|
||||
$(Q) $(RM) $@
|
||||
$(Q) $(AR) rsv $@ $(BASE_OBJECTS) > /dev/null
|
||||
|
||||
ifeq ("$(DEPENDS)","yes")
|
||||
ifeq ("$(USE_TRACKING)","yes")
|
||||
-include $(BASE_DEPENDS)
|
||||
endif
|
||||
|
||||
@@ -41,7 +41,7 @@ struct dm_hash_table {
|
||||
static unsigned _hash(const void *key, unsigned len)
|
||||
{
|
||||
/* Permutation of the Integers 0 through 255 */
|
||||
static unsigned char _nums[] = {
|
||||
static const unsigned char _nums[] = {
|
||||
1, 14, 110, 25, 97, 174, 132, 119, 138, 170, 125, 118, 27, 233, 140, 51,
|
||||
87, 197, 177, 107, 234, 169, 56, 68, 30, 7, 173, 73, 188, 40, 36, 65,
|
||||
49, 213, 104, 190, 57, 211, 148, 223, 48, 115, 15, 2, 67, 186, 210, 28,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
@@ -69,7 +70,7 @@ struct node48 {
|
||||
};
|
||||
|
||||
struct node256 {
|
||||
uint32_t nr_entries;
|
||||
uint32_t nr_entries;
|
||||
struct value values[256];
|
||||
};
|
||||
|
||||
@@ -99,7 +100,7 @@ struct radix_tree *radix_tree_create(radix_value_dtr dtr, void *dtr_context)
|
||||
static inline void _dtr(struct radix_tree *rt, union radix_value v)
|
||||
{
|
||||
if (rt->dtr)
|
||||
rt->dtr(rt->dtr_context, v);
|
||||
rt->dtr(rt->dtr_context, v);
|
||||
}
|
||||
|
||||
// Returns the number of values removed
|
||||
@@ -118,8 +119,8 @@ static unsigned _free_node(struct radix_tree *rt, struct value v)
|
||||
break;
|
||||
|
||||
case VALUE:
|
||||
_dtr(rt, v.value);
|
||||
nr = 1;
|
||||
_dtr(rt, v.value);
|
||||
nr = 1;
|
||||
break;
|
||||
|
||||
case VALUE_CHAIN:
|
||||
@@ -178,9 +179,9 @@ unsigned radix_tree_size(struct radix_tree *rt)
|
||||
return rt->nr_entries;
|
||||
}
|
||||
|
||||
static bool _insert(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv);
|
||||
static bool _insert(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv);
|
||||
|
||||
static bool _insert_unset(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_unset(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
unsigned len = ke - kb;
|
||||
|
||||
@@ -207,7 +208,7 @@ static bool _insert_unset(struct radix_tree *rt, struct value *v, uint8_t *kb, u
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_value(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_value(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
unsigned len = ke - kb;
|
||||
|
||||
@@ -234,7 +235,7 @@ static bool _insert_value(struct radix_tree *rt, struct value *v, uint8_t *kb, u
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_value_chain(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_value_chain(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct value_chain *vc = v->value.ptr;
|
||||
return _insert(rt, &vc->child, kb, ke, rv);
|
||||
@@ -248,7 +249,7 @@ static unsigned min(unsigned lhs, unsigned rhs)
|
||||
return rhs;
|
||||
}
|
||||
|
||||
static bool _insert_prefix_chain(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_prefix_chain(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct prefix_chain *pc = v->value.ptr;
|
||||
|
||||
@@ -313,7 +314,7 @@ static bool _insert_prefix_chain(struct radix_tree *rt, struct value *v, uint8_t
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_node4(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_node4(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct node4 *n4 = v->value.ptr;
|
||||
if (n4->nr_entries == 4) {
|
||||
@@ -343,7 +344,7 @@ static bool _insert_node4(struct radix_tree *rt, struct value *v, uint8_t *kb, u
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_node16(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_node16(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct node16 *n16 = v->value.ptr;
|
||||
|
||||
@@ -382,7 +383,7 @@ static bool _insert_node16(struct radix_tree *rt, struct value *v, uint8_t *kb,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_node48(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_node48(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct node48 *n48 = v->value.ptr;
|
||||
if (n48->nr_entries == 48) {
|
||||
@@ -417,20 +418,20 @@ static bool _insert_node48(struct radix_tree *rt, struct value *v, uint8_t *kb,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_node256(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_node256(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct node256 *n256 = v->value.ptr;
|
||||
bool r, was_unset = n256->values[*kb].type == UNSET;
|
||||
|
||||
r = _insert(rt, n256->values + *kb, kb + 1, ke, rv);
|
||||
if (r && was_unset)
|
||||
n256->nr_entries++;
|
||||
n256->nr_entries++;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// FIXME: the tree should not be touched if insert fails (eg, OOM)
|
||||
static bool _insert(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
static bool _insert(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
if (kb == ke) {
|
||||
if (v->type == UNSET) {
|
||||
@@ -487,10 +488,10 @@ static bool _insert(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t
|
||||
|
||||
struct lookup_result {
|
||||
struct value *v;
|
||||
uint8_t *kb;
|
||||
const uint8_t *kb;
|
||||
};
|
||||
|
||||
static struct lookup_result _lookup_prefix(struct value *v, uint8_t *kb, uint8_t *ke)
|
||||
static struct lookup_result _lookup_prefix(struct value *v, const uint8_t *kb, const uint8_t *ke)
|
||||
{
|
||||
unsigned i;
|
||||
struct value_chain *vc;
|
||||
@@ -500,7 +501,7 @@ static struct lookup_result _lookup_prefix(struct value *v, uint8_t *kb, uint8_t
|
||||
struct node48 *n48;
|
||||
struct node256 *n256;
|
||||
|
||||
if (kb == ke)
|
||||
if (kb == ke || !kb) /* extra check for !kb for coverity */
|
||||
return (struct lookup_result) {.v = v, .kb = kb};
|
||||
|
||||
switch (v->type) {
|
||||
@@ -555,8 +556,10 @@ static struct lookup_result _lookup_prefix(struct value *v, uint8_t *kb, uint8_t
|
||||
return (struct lookup_result) {.v = v, .kb = kb};
|
||||
}
|
||||
|
||||
bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
bool radix_tree_insert(struct radix_tree *rt, const void *key, size_t keylen, union radix_value rv)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke);
|
||||
return _insert(rt, lr.v, lr.kb, ke, rv);
|
||||
}
|
||||
@@ -564,14 +567,14 @@ bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union ra
|
||||
// Note the degrade functions also free the original node.
|
||||
static void _degrade_to_n4(struct node16 *n16, struct value *result)
|
||||
{
|
||||
struct node4 *n4 = zalloc(sizeof(*n4));
|
||||
struct node4 *n4 = zalloc(sizeof(*n4));
|
||||
|
||||
assert(n4 != NULL);
|
||||
|
||||
n4->nr_entries = n16->nr_entries;
|
||||
memcpy(n4->keys, n16->keys, n16->nr_entries * sizeof(*n4->keys));
|
||||
memcpy(n4->values, n16->values, n16->nr_entries * sizeof(*n4->values));
|
||||
free(n16);
|
||||
n4->nr_entries = n16->nr_entries;
|
||||
memcpy(n4->keys, n16->keys, n16->nr_entries * sizeof(*n4->keys));
|
||||
memcpy(n4->values, n16->values, n16->nr_entries * sizeof(*n4->values));
|
||||
free(n16);
|
||||
|
||||
result->type = NODE4;
|
||||
result->value.ptr = n4;
|
||||
@@ -580,20 +583,20 @@ static void _degrade_to_n4(struct node16 *n16, struct value *result)
|
||||
static void _degrade_to_n16(struct node48 *n48, struct value *result)
|
||||
{
|
||||
unsigned i, count = 0;
|
||||
struct node16 *n16 = zalloc(sizeof(*n16));
|
||||
struct node16 *n16 = zalloc(sizeof(*n16));
|
||||
|
||||
assert(n16 != NULL);
|
||||
|
||||
n16->nr_entries = n48->nr_entries;
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (n48->keys[i] < 48) {
|
||||
n16->keys[count] = i;
|
||||
n16->values[count] = n48->values[n48->keys[i]];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
n16->nr_entries = n48->nr_entries;
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (n48->keys[i] < 48) {
|
||||
n16->keys[count] = i;
|
||||
n16->values[count] = n48->values[n48->keys[i]];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
free(n48);
|
||||
free(n48);
|
||||
|
||||
result->type = NODE16;
|
||||
result->value.ptr = n16;
|
||||
@@ -601,13 +604,13 @@ static void _degrade_to_n16(struct node48 *n48, struct value *result)
|
||||
|
||||
static void _degrade_to_n48(struct node256 *n256, struct value *result)
|
||||
{
|
||||
unsigned i, count = 0;
|
||||
struct node48 *n48 = zalloc(sizeof(*n48));
|
||||
unsigned i, count = 0;
|
||||
struct node48 *n48 = zalloc(sizeof(*n48));
|
||||
|
||||
assert(n48 != NULL);
|
||||
|
||||
n48->nr_entries = n256->nr_entries;
|
||||
for (i = 0; i < 256; i++) {
|
||||
n48->nr_entries = n256->nr_entries;
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (n256->values[i].type == UNSET)
|
||||
n48->keys[i] = 48;
|
||||
|
||||
@@ -616,9 +619,9 @@ static void _degrade_to_n48(struct node256 *n256, struct value *result)
|
||||
n48->values[count] = n256->values[i];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(n256);
|
||||
free(n256);
|
||||
|
||||
result->type = NODE48;
|
||||
result->value.ptr = n48;
|
||||
@@ -632,14 +635,14 @@ static void _erase_elt(void *array, size_t obj_size, unsigned count, unsigned id
|
||||
return;
|
||||
|
||||
memmove(((uint8_t *) array) + (obj_size * idx),
|
||||
((uint8_t *) array) + (obj_size * (idx + 1)),
|
||||
obj_size * (count - idx - 1));
|
||||
((uint8_t *) array) + (obj_size * (idx + 1)),
|
||||
obj_size * (count - idx - 1));
|
||||
|
||||
// Zero the now unused last elt (set's v.type to UNSET)
|
||||
memset(((uint8_t *) array) + (count - 1) * obj_size, 0, obj_size);
|
||||
}
|
||||
|
||||
static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint8_t *ke)
|
||||
static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb, const uint8_t *ke)
|
||||
{
|
||||
bool r;
|
||||
unsigned i, j;
|
||||
@@ -651,27 +654,27 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint
|
||||
struct node256 *n256;
|
||||
|
||||
if (kb == ke) {
|
||||
if (root->type == VALUE) {
|
||||
root->type = UNSET;
|
||||
_dtr(rt, root->value);
|
||||
return true;
|
||||
if (root->type == VALUE) {
|
||||
root->type = UNSET;
|
||||
_dtr(rt, root->value);
|
||||
return true;
|
||||
|
||||
} else if (root->type == VALUE_CHAIN) {
|
||||
} else if (root->type == VALUE_CHAIN) {
|
||||
vc = root->value.ptr;
|
||||
_dtr(rt, vc->value);
|
||||
memcpy(root, &vc->child, sizeof(*root));
|
||||
free(vc);
|
||||
return true;
|
||||
|
||||
} else
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (root->type) {
|
||||
case UNSET:
|
||||
case VALUE:
|
||||
// this is a value for a prefix of the key
|
||||
return false;
|
||||
// this is a value for a prefix of the key
|
||||
return false;
|
||||
|
||||
case VALUE_CHAIN:
|
||||
vc = root->value.ptr;
|
||||
@@ -686,11 +689,11 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint
|
||||
case PREFIX_CHAIN:
|
||||
pc = root->value.ptr;
|
||||
if (ke - kb < pc->len)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
for (i = 0; i < pc->len; i++)
|
||||
if (kb[i] != pc->prefix[i])
|
||||
return false;
|
||||
return false;
|
||||
|
||||
r = _remove(rt, &pc->child, kb + pc->len, ke);
|
||||
if (r && pc->child.type == UNSET) {
|
||||
@@ -705,12 +708,12 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint
|
||||
if (n4->keys[i] == *kb) {
|
||||
r = _remove(rt, n4->values + i, kb + 1, ke);
|
||||
if (r && n4->values[i].type == UNSET) {
|
||||
if (i < n4->nr_entries) {
|
||||
_erase_elt(n4->keys, sizeof(*n4->keys), n4->nr_entries, i);
|
||||
_erase_elt(n4->values, sizeof(*n4->values), n4->nr_entries, i);
|
||||
}
|
||||
if (i < n4->nr_entries) {
|
||||
_erase_elt(n4->keys, sizeof(*n4->keys), n4->nr_entries, i);
|
||||
_erase_elt(n4->values, sizeof(*n4->values), n4->nr_entries, i);
|
||||
}
|
||||
|
||||
n4->nr_entries--;
|
||||
n4->nr_entries--;
|
||||
if (!n4->nr_entries) {
|
||||
free(n4);
|
||||
root->type = UNSET;
|
||||
@@ -722,19 +725,19 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint
|
||||
return false;
|
||||
|
||||
case NODE16:
|
||||
n16 = root->value.ptr;
|
||||
n16 = root->value.ptr;
|
||||
for (i = 0; i < n16->nr_entries; i++) {
|
||||
if (n16->keys[i] == *kb) {
|
||||
r = _remove(rt, n16->values + i, kb + 1, ke);
|
||||
if (r && n16->values[i].type == UNSET) {
|
||||
if (i < n16->nr_entries) {
|
||||
_erase_elt(n16->keys, sizeof(*n16->keys), n16->nr_entries, i);
|
||||
_erase_elt(n16->values, sizeof(*n16->values), n16->nr_entries, i);
|
||||
}
|
||||
if (i < n16->nr_entries) {
|
||||
_erase_elt(n16->keys, sizeof(*n16->keys), n16->nr_entries, i);
|
||||
_erase_elt(n16->values, sizeof(*n16->values), n16->nr_entries, i);
|
||||
}
|
||||
|
||||
n16->nr_entries--;
|
||||
n16->nr_entries--;
|
||||
if (n16->nr_entries <= 4) {
|
||||
_degrade_to_n4(n16, root);
|
||||
_degrade_to_n4(n16, root);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
@@ -746,18 +749,18 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint
|
||||
n48 = root->value.ptr;
|
||||
i = n48->keys[*kb];
|
||||
if (i < 48) {
|
||||
r = _remove(rt, n48->values + i, kb + 1, ke);
|
||||
if (r && n48->values[i].type == UNSET) {
|
||||
n48->keys[*kb] = 48;
|
||||
for (j = 0; j < 256; j++)
|
||||
if (n48->keys[j] < 48 && n48->keys[j] > i)
|
||||
n48->keys[j]--;
|
||||
r = _remove(rt, n48->values + i, kb + 1, ke);
|
||||
if (r && n48->values[i].type == UNSET) {
|
||||
n48->keys[*kb] = 48;
|
||||
for (j = 0; j < 256; j++)
|
||||
if (n48->keys[j] < 48 && n48->keys[j] > i)
|
||||
n48->keys[j]--;
|
||||
_erase_elt(n48->values, sizeof(*n48->values), n48->nr_entries, i);
|
||||
n48->nr_entries--;
|
||||
if (n48->nr_entries <= 16)
|
||||
_degrade_to_n16(n48, root);
|
||||
}
|
||||
return r;
|
||||
_degrade_to_n16(n48, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -767,7 +770,7 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint
|
||||
if (r && n256->values[*kb].type == UNSET) {
|
||||
n256->nr_entries--;
|
||||
if (n256->nr_entries <= 48)
|
||||
_degrade_to_n48(n256, root);
|
||||
_degrade_to_n48(n256, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -775,11 +778,14 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint
|
||||
return false;
|
||||
}
|
||||
|
||||
bool radix_tree_remove(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_end)
|
||||
bool radix_tree_remove(struct radix_tree *rt, const void *key, size_t keylen)
|
||||
{
|
||||
if (_remove(rt, &rt->root, key_begin, key_end)) {
|
||||
rt->nr_entries--;
|
||||
return true;
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
|
||||
if (_remove(rt, &rt->root, kb, ke)) {
|
||||
rt->nr_entries--;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -787,25 +793,25 @@ bool radix_tree_remove(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_e
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
static bool _prefix_chain_matches(struct lookup_result *lr, uint8_t *ke)
|
||||
static bool _prefix_chain_matches(const struct lookup_result *lr, const uint8_t *ke)
|
||||
{
|
||||
// It's possible the top node is a prefix chain, and
|
||||
// the remaining key matches part of it.
|
||||
if (lr->v->type == PREFIX_CHAIN) {
|
||||
unsigned i, rlen = ke - lr->kb;
|
||||
struct prefix_chain *pc = lr->v->value.ptr;
|
||||
if (rlen < pc->len) {
|
||||
for (i = 0; i < rlen; i++)
|
||||
if (pc->prefix[i] != lr->kb[i])
|
||||
return false;
|
||||
return true;
|
||||
// It's possible the top node is a prefix chain, and
|
||||
// the remaining key matches part of it.
|
||||
if (lr->v->type == PREFIX_CHAIN) {
|
||||
unsigned i, rlen = ke - lr->kb;
|
||||
const struct prefix_chain *pc = lr->v->value.ptr;
|
||||
if (rlen < pc->len) {
|
||||
for (i = 0; i < rlen; i++)
|
||||
if (pc->prefix[i] != lr->kb[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *kb, uint8_t *ke, unsigned *count)
|
||||
static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uint8_t *kb, const uint8_t *ke, unsigned *count)
|
||||
{
|
||||
bool r;
|
||||
unsigned i, j, len;
|
||||
@@ -826,7 +832,7 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *
|
||||
case UNSET:
|
||||
case VALUE:
|
||||
// No entries with the given prefix
|
||||
return true;
|
||||
return true;
|
||||
|
||||
case VALUE_CHAIN:
|
||||
vc = root->value.ptr;
|
||||
@@ -843,7 +849,7 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *
|
||||
len = min(pc->len, ke - kb);
|
||||
for (i = 0; i < len; i++)
|
||||
if (kb[i] != pc->prefix[i])
|
||||
return true;
|
||||
return true;
|
||||
|
||||
r = _remove_subtree(rt, &pc->child, len < pc->len ? ke : (kb + pc->len), ke, count);
|
||||
if (r && pc->child.type == UNSET) {
|
||||
@@ -858,12 +864,12 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *
|
||||
if (n4->keys[i] == *kb) {
|
||||
r = _remove_subtree(rt, n4->values + i, kb + 1, ke, count);
|
||||
if (r && n4->values[i].type == UNSET) {
|
||||
if (i < n4->nr_entries) {
|
||||
_erase_elt(n4->keys, sizeof(*n4->keys), n4->nr_entries, i);
|
||||
_erase_elt(n4->values, sizeof(*n4->values), n4->nr_entries, i);
|
||||
}
|
||||
if (i < n4->nr_entries) {
|
||||
_erase_elt(n4->keys, sizeof(*n4->keys), n4->nr_entries, i);
|
||||
_erase_elt(n4->values, sizeof(*n4->values), n4->nr_entries, i);
|
||||
}
|
||||
|
||||
n4->nr_entries--;
|
||||
n4->nr_entries--;
|
||||
if (!n4->nr_entries) {
|
||||
free(n4);
|
||||
root->type = UNSET;
|
||||
@@ -875,19 +881,19 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *
|
||||
return true;
|
||||
|
||||
case NODE16:
|
||||
n16 = root->value.ptr;
|
||||
n16 = root->value.ptr;
|
||||
for (i = 0; i < n16->nr_entries; i++) {
|
||||
if (n16->keys[i] == *kb) {
|
||||
r = _remove_subtree(rt, n16->values + i, kb + 1, ke, count);
|
||||
if (r && n16->values[i].type == UNSET) {
|
||||
if (i < n16->nr_entries) {
|
||||
_erase_elt(n16->keys, sizeof(*n16->keys), n16->nr_entries, i);
|
||||
_erase_elt(n16->values, sizeof(*n16->values), n16->nr_entries, i);
|
||||
}
|
||||
if (i < n16->nr_entries) {
|
||||
_erase_elt(n16->keys, sizeof(*n16->keys), n16->nr_entries, i);
|
||||
_erase_elt(n16->values, sizeof(*n16->values), n16->nr_entries, i);
|
||||
}
|
||||
|
||||
n16->nr_entries--;
|
||||
n16->nr_entries--;
|
||||
if (n16->nr_entries <= 4)
|
||||
_degrade_to_n4(n16, root);
|
||||
_degrade_to_n4(n16, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -898,18 +904,18 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *
|
||||
n48 = root->value.ptr;
|
||||
i = n48->keys[*kb];
|
||||
if (i < 48) {
|
||||
r = _remove_subtree(rt, n48->values + i, kb + 1, ke, count);
|
||||
if (r && n48->values[i].type == UNSET) {
|
||||
n48->keys[*kb] = 48;
|
||||
for (j = 0; j < 256; j++)
|
||||
if (n48->keys[j] < 48 && n48->keys[j] > i)
|
||||
n48->keys[j]--;
|
||||
r = _remove_subtree(rt, n48->values + i, kb + 1, ke, count);
|
||||
if (r && n48->values[i].type == UNSET) {
|
||||
n48->keys[*kb] = 48;
|
||||
for (j = 0; j < 256; j++)
|
||||
if (n48->keys[j] < 48 && n48->keys[j] > i)
|
||||
n48->keys[j]--;
|
||||
_erase_elt(n48->values, sizeof(*n48->values), n48->nr_entries, i);
|
||||
n48->nr_entries--;
|
||||
if (n48->nr_entries <= 16)
|
||||
_degrade_to_n16(n48, root);
|
||||
}
|
||||
return r;
|
||||
_degrade_to_n16(n48, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -922,7 +928,7 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *
|
||||
if (r && n256->values[*kb].type == UNSET) {
|
||||
n256->nr_entries--;
|
||||
if (n256->nr_entries <= 48)
|
||||
_degrade_to_n48(n256, root);
|
||||
_degrade_to_n48(n256, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -931,11 +937,13 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *ke)
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, const void *prefix, size_t prefix_len)
|
||||
{
|
||||
unsigned count = 0;
|
||||
const uint8_t *kb = prefix;
|
||||
const uint8_t *ke = kb + prefix_len;
|
||||
unsigned count = 0;
|
||||
|
||||
if (_remove_subtree(rt, &rt->root, kb, ke, &count))
|
||||
if (_remove_subtree(rt, &rt->root, kb, ke, &count))
|
||||
rt->nr_entries -= count;
|
||||
|
||||
return count;
|
||||
@@ -943,9 +951,11 @@ unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *k
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
bool radix_tree_lookup(struct radix_tree *rt,
|
||||
uint8_t *kb, uint8_t *ke, union radix_value *result)
|
||||
bool radix_tree_lookup(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value *result)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct value_chain *vc;
|
||||
struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke);
|
||||
if (lr.kb == ke) {
|
||||
@@ -968,58 +978,58 @@ bool radix_tree_lookup(struct radix_tree *rt,
|
||||
}
|
||||
|
||||
// FIXME: build up the keys too
|
||||
static bool _iterate(struct value *v, struct radix_tree_iterator *it)
|
||||
static bool _iterate(struct radix_tree_iterator *it, const struct value *v)
|
||||
{
|
||||
unsigned i;
|
||||
struct value_chain *vc;
|
||||
struct prefix_chain *pc;
|
||||
struct node4 *n4;
|
||||
struct node16 *n16;
|
||||
struct node48 *n48;
|
||||
struct node256 *n256;
|
||||
const struct value_chain *vc;
|
||||
const struct prefix_chain *pc;
|
||||
const struct node4 *n4;
|
||||
const struct node16 *n16;
|
||||
const struct node48 *n48;
|
||||
const struct node256 *n256;
|
||||
|
||||
switch (v->type) {
|
||||
case UNSET:
|
||||
// can't happen
|
||||
// can't happen
|
||||
break;
|
||||
|
||||
case VALUE:
|
||||
return it->visit(it, NULL, NULL, v->value);
|
||||
return it->visit(it, NULL, 0, v->value);
|
||||
|
||||
case VALUE_CHAIN:
|
||||
vc = v->value.ptr;
|
||||
return it->visit(it, NULL, NULL, vc->value) && _iterate(&vc->child, it);
|
||||
return it->visit(it, NULL, 0, vc->value) && _iterate(it, &vc->child);
|
||||
|
||||
case PREFIX_CHAIN:
|
||||
pc = v->value.ptr;
|
||||
return _iterate(&pc->child, it);
|
||||
return _iterate(it, &pc->child);
|
||||
|
||||
case NODE4:
|
||||
n4 = (struct node4 *) v->value.ptr;
|
||||
n4 = (const struct node4 *) v->value.ptr;
|
||||
for (i = 0; i < n4->nr_entries; i++)
|
||||
if (!_iterate(n4->values + i, it))
|
||||
return false;
|
||||
return true;
|
||||
if (!_iterate(it, n4->values + i))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
case NODE16:
|
||||
n16 = (struct node16 *) v->value.ptr;
|
||||
n16 = (const struct node16 *) v->value.ptr;
|
||||
for (i = 0; i < n16->nr_entries; i++)
|
||||
if (!_iterate(n16->values + i, it))
|
||||
return false;
|
||||
if (!_iterate(it, n16->values + i))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
case NODE48:
|
||||
n48 = (struct node48 *) v->value.ptr;
|
||||
n48 = (const struct node48 *) v->value.ptr;
|
||||
for (i = 0; i < n48->nr_entries; i++)
|
||||
if (!_iterate(n48->values + i, it))
|
||||
return false;
|
||||
if (!_iterate(it, n48->values + i))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
case NODE256:
|
||||
n256 = (struct node256 *) v->value.ptr;
|
||||
n256 = (const struct node256 *) v->value.ptr;
|
||||
for (i = 0; i < 256; i++)
|
||||
if (n256->values[i].type != UNSET && !_iterate(n256->values + i, it))
|
||||
return false;
|
||||
if (n256->values[i].type != UNSET && !_iterate(it, n256->values + i))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1027,12 +1037,14 @@ static bool _iterate(struct value *v, struct radix_tree_iterator *it)
|
||||
return false;
|
||||
}
|
||||
|
||||
void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke,
|
||||
struct radix_tree_iterator *it)
|
||||
void radix_tree_iterate(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
struct radix_tree_iterator *it)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke);
|
||||
if (lr.kb == ke || _prefix_chain_matches(&lr, ke))
|
||||
(void) _iterate(lr.v, it);
|
||||
(void) _iterate(it, lr.v);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
@@ -1130,7 +1142,7 @@ static bool _check_nodes(struct value *v, unsigned *count)
|
||||
|
||||
if (ncount != n48->nr_entries) {
|
||||
fprintf(stderr, "incorrect number of entries in n48, n48->nr_entries = %u, actual = %u\n",
|
||||
n48->nr_entries, ncount);
|
||||
n48->nr_entries, ncount);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1166,7 +1178,7 @@ static bool _check_nodes(struct value *v, unsigned *count)
|
||||
|
||||
if (ncount != n256->nr_entries) {
|
||||
fprintf(stderr, "incorrect number of entries in n256, n256->nr_entries = %u, actual = %u\n",
|
||||
n256->nr_entries, ncount);
|
||||
n256->nr_entries, ncount);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1189,7 +1201,7 @@ bool radix_tree_is_well_formed(struct radix_tree *rt)
|
||||
|
||||
if (rt->nr_entries != count) {
|
||||
fprintf(stderr, "incorrect entry count: rt->nr_entries = %u, actual = %u\n",
|
||||
rt->nr_entries, count);
|
||||
rt->nr_entries, count);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1207,6 +1219,7 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
struct node16 *n16;
|
||||
struct node48 *n48;
|
||||
struct node256 *n256;
|
||||
unsigned printable;
|
||||
|
||||
if (v.type == UNSET)
|
||||
return;
|
||||
@@ -1231,9 +1244,22 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
|
||||
case PREFIX_CHAIN:
|
||||
pc = v.value.ptr;
|
||||
fprintf(out, "<prefix: ");
|
||||
fprintf(out, "<prefix(%u): ", pc->len);
|
||||
printable = 1;
|
||||
for (i = 0; i < pc->len; i++)
|
||||
fprintf(out, "%x.", (unsigned) *(pc->prefix + i));
|
||||
if (!isprint(pc->prefix[i])) {
|
||||
printable = 0;
|
||||
break;
|
||||
}
|
||||
if (printable)
|
||||
fputc('"', out);
|
||||
for (i = 0; i < pc->len; i++)
|
||||
if (printable)
|
||||
fprintf(out, "%c", pc->prefix[i]);
|
||||
else
|
||||
fprintf(out, "%02x.", (unsigned) *(pc->prefix + i));
|
||||
if (printable)
|
||||
fputc('"', out);
|
||||
fprintf(out, ">\n");
|
||||
_dump(out, pc->child, indent + 1);
|
||||
break;
|
||||
@@ -1242,7 +1268,7 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
n4 = v.value.ptr;
|
||||
fprintf(out, "<n4: ");
|
||||
for (i = 0; i < n4->nr_entries; i++)
|
||||
fprintf(out, "%x ", (unsigned) n4->keys[i]);
|
||||
fprintf(out, "%02x ", (unsigned) n4->keys[i]);
|
||||
fprintf(out, ">\n");
|
||||
|
||||
for (i = 0; i < n4->nr_entries; i++)
|
||||
@@ -1253,7 +1279,7 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
n16 = v.value.ptr;
|
||||
fprintf(out, "<n16: ");
|
||||
for (i = 0; i < n16->nr_entries; i++)
|
||||
fprintf(out, "%x ", (unsigned) n16->keys[i]);
|
||||
fprintf(out, "%02x ", (unsigned) n16->keys[i]);
|
||||
fprintf(out, ">\n");
|
||||
|
||||
for (i = 0; i < n16->nr_entries; i++)
|
||||
@@ -1265,7 +1291,7 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
fprintf(out, "<n48: ");
|
||||
for (i = 0; i < 256; i++)
|
||||
if (n48->keys[i] < 48)
|
||||
fprintf(out, "%x ", i);
|
||||
fprintf(out, "%02x ", i);
|
||||
fprintf(out, ">\n");
|
||||
|
||||
for (i = 0; i < n48->nr_entries; i++) {
|
||||
@@ -1279,7 +1305,7 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
fprintf(out, "<n256: ");
|
||||
for (i = 0; i < 256; i++)
|
||||
if (n256->values[i].type != UNSET)
|
||||
fprintf(out, "%x ", i);
|
||||
fprintf(out, "%02x ", i);
|
||||
fprintf(out, ">\n");
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (C) 2018 Red Hat, Inc. All rights reserved.
|
||||
//
|
||||
//
|
||||
// This file is part of LVM2.
|
||||
//
|
||||
// This copyrighted material is made available to anyone wishing to use,
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// This implementation is based around nested binary trees. Very
|
||||
@@ -37,12 +38,12 @@ struct node {
|
||||
struct radix_tree {
|
||||
radix_value_dtr dtr;
|
||||
void *dtr_context;
|
||||
unsigned nr_entries;
|
||||
|
||||
struct node *root;
|
||||
};
|
||||
|
||||
struct radix_tree *
|
||||
radix_tree_create(radix_value_dtr dtr, void *dtr_context)
|
||||
struct radix_tree *radix_tree_create(radix_value_dtr dtr, void *dtr_context)
|
||||
{
|
||||
struct radix_tree *rt = zalloc(sizeof(*rt));
|
||||
|
||||
@@ -105,7 +106,7 @@ unsigned radix_tree_size(struct radix_tree *rt)
|
||||
return _count(rt->root);
|
||||
}
|
||||
|
||||
static struct node **_lookup(struct node **pn, uint8_t *kb, uint8_t *ke)
|
||||
static struct node **_lookup(struct node **pn, const uint8_t *kb, const uint8_t *ke)
|
||||
{
|
||||
struct node *n = *pn;
|
||||
|
||||
@@ -122,7 +123,7 @@ static struct node **_lookup(struct node **pn, uint8_t *kb, uint8_t *ke)
|
||||
return _lookup(&n->center, kb + 1, ke);
|
||||
}
|
||||
|
||||
static bool _insert(struct node **pn, uint8_t *kb, uint8_t *ke, union radix_value v)
|
||||
static bool _insert(struct node **pn, const uint8_t *kb, const uint8_t *ke, union radix_value v)
|
||||
{
|
||||
struct node *n = *pn;
|
||||
|
||||
@@ -151,39 +152,51 @@ static bool _insert(struct node **pn, uint8_t *kb, uint8_t *ke, union radix_valu
|
||||
return _insert(&n->center, kb + 1, ke, v);
|
||||
}
|
||||
|
||||
bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value v)
|
||||
bool radix_tree_insert(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value v)
|
||||
{
|
||||
return _insert(&rt->root, kb, ke, v);
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
|
||||
if (!_insert(&rt->root, kb, ke, v))
|
||||
return false;
|
||||
|
||||
rt->nr_entries++;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool radix_tree_remove(struct radix_tree *rt, uint8_t *kb, uint8_t *ke)
|
||||
bool radix_tree_remove(struct radix_tree *rt, const void *key, size_t keylen)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct node **pn = _lookup(&rt->root, kb, ke);
|
||||
struct node *n = *pn;
|
||||
|
||||
if (!n || !n->has_value)
|
||||
return false;
|
||||
|
||||
else {
|
||||
if (rt->dtr)
|
||||
rt->dtr(rt->dtr_context, n->value);
|
||||
rt->nr_entries--;
|
||||
|
||||
if (n->left || n->center || n->right) {
|
||||
n->has_value = false;
|
||||
return true;
|
||||
if (rt->dtr)
|
||||
rt->dtr(rt->dtr_context, n->value);
|
||||
|
||||
} else {
|
||||
// FIXME: delete parent if this was the last entry
|
||||
free(n);
|
||||
*pn = NULL;
|
||||
}
|
||||
if (n->left || n->center || n->right) {
|
||||
n->has_value = false;
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: delete parent if this was the last entry
|
||||
free(n);
|
||||
*pn = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *ke)
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, const void *key, size_t keylen)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct node **pn;
|
||||
unsigned count;
|
||||
|
||||
@@ -197,17 +210,20 @@ unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *k
|
||||
return count;
|
||||
}
|
||||
|
||||
bool
|
||||
radix_tree_lookup(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value *result)
|
||||
bool radix_tree_lookup(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value *result)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct node **pn = _lookup(&rt->root, kb, ke);
|
||||
struct node *n = *pn;
|
||||
|
||||
if (n && n->has_value) {
|
||||
*result = n->value;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void _iterate(struct node *n, struct radix_tree_iterator *it)
|
||||
@@ -219,15 +235,18 @@ static void _iterate(struct node *n, struct radix_tree_iterator *it)
|
||||
|
||||
if (n->has_value)
|
||||
// FIXME: fill out the key
|
||||
it->visit(it, NULL, NULL, n->value);
|
||||
it->visit(it, NULL, 0, n->value);
|
||||
|
||||
_iterate(n->center, it);
|
||||
_iterate(n->right, it);
|
||||
}
|
||||
|
||||
void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke,
|
||||
void radix_tree_iterate(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
struct radix_tree_iterator *it)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
|
||||
if (kb == ke)
|
||||
_iterate(rt->root, it);
|
||||
|
||||
@@ -237,7 +256,7 @@ void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke,
|
||||
|
||||
if (n) {
|
||||
if (n->has_value)
|
||||
it->visit(it, NULL, NULL, n->value);
|
||||
it->visit(it, NULL, 0, n->value);
|
||||
_iterate(n->center, it);
|
||||
}
|
||||
}
|
||||
@@ -248,8 +267,32 @@ bool radix_tree_is_well_formed(struct radix_tree *rt)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void _dump(FILE *out, struct node *n, unsigned indent)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (!n)
|
||||
return;
|
||||
|
||||
_dump(out, n->left, indent + 1);
|
||||
|
||||
for (i = 0; i < 2 * indent; i++)
|
||||
fprintf(out, " ");
|
||||
|
||||
if (n->has_value) {
|
||||
fprintf(out, "value: %llu\n", n->value.n);
|
||||
} else {
|
||||
fprintf(out, "key: '%c' [0x%02x] %u\n",
|
||||
isprint(n->key) ? n->key : ' ', n->key, indent);
|
||||
}
|
||||
|
||||
_dump(out, n->center, indent + 1);
|
||||
_dump(out, n->right, indent + 1);
|
||||
}
|
||||
|
||||
void radix_tree_dump(struct radix_tree *rt, FILE *out)
|
||||
{
|
||||
_dump(out, rt->root, 0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
@@ -19,3 +19,45 @@
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
struct visitor {
|
||||
struct radix_tree_iterator it;
|
||||
unsigned pos, nr_entries;
|
||||
union radix_value *values;
|
||||
};
|
||||
|
||||
static bool _visitor(struct radix_tree_iterator *it,
|
||||
const void *key, size_t keylen,
|
||||
union radix_value v)
|
||||
{
|
||||
struct visitor *vt = container_of(it, struct visitor, it);
|
||||
|
||||
if (vt->pos >= vt->nr_entries)
|
||||
return false;
|
||||
|
||||
vt->values[vt->pos++] = v;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool radix_tree_values(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value **values, unsigned *nr_values)
|
||||
{
|
||||
struct visitor vt = {
|
||||
.it.visit = _visitor,
|
||||
.nr_entries = rt->nr_entries,
|
||||
.values = calloc(rt->nr_entries + 1, sizeof(union radix_value)),
|
||||
};
|
||||
|
||||
if (vt.values) {
|
||||
// build set of all values in current radix tree
|
||||
radix_tree_iterate(rt, key, keylen, &vt.it);
|
||||
*nr_values = vt.pos;
|
||||
*values = vt.values;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
@@ -33,32 +33,51 @@ struct radix_tree *radix_tree_create(radix_value_dtr dtr, void *dtr_context);
|
||||
void radix_tree_destroy(struct radix_tree *rt);
|
||||
|
||||
unsigned radix_tree_size(struct radix_tree *rt);
|
||||
bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value v);
|
||||
bool radix_tree_remove(struct radix_tree *rt, uint8_t *kb, uint8_t *ke);
|
||||
bool radix_tree_insert(struct radix_tree *rt, const void *key, size_t keylen, union radix_value v);
|
||||
bool radix_tree_remove(struct radix_tree *rt, const void *key, size_t keylen);
|
||||
|
||||
// Returns the number of values removed
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *prefix_b, uint8_t *prefix_e);
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, const void *prefix, size_t prefix_len);
|
||||
|
||||
bool radix_tree_lookup(struct radix_tree *rt,
|
||||
uint8_t *kb, uint8_t *ke, union radix_value *result);
|
||||
bool radix_tree_lookup(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value *result);
|
||||
|
||||
// The radix tree stores entries in lexicographical order. Which means
|
||||
// we can iterate entries, in order. Or iterate entries with a particular
|
||||
// prefix.
|
||||
struct radix_tree_iterator {
|
||||
// Returns false if the iteration should end.
|
||||
// Returns false if the iteration should end.
|
||||
bool (*visit)(struct radix_tree_iterator *it,
|
||||
uint8_t *kb, uint8_t *ke, union radix_value v);
|
||||
const void *key, size_t keylen, union radix_value v);
|
||||
};
|
||||
|
||||
void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke,
|
||||
struct radix_tree_iterator *it);
|
||||
void radix_tree_iterate(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
struct radix_tree_iterator *it);
|
||||
|
||||
// Alternative traversing radix_tree.
|
||||
// Builds whole set all radix_tree nr_values values.
|
||||
// After use, free(values).
|
||||
bool radix_tree_values(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value **values, unsigned *nr_values);
|
||||
|
||||
// Checks that some constraints on the shape of the tree are
|
||||
// being held. For debug only.
|
||||
bool radix_tree_is_well_formed(struct radix_tree *rt);
|
||||
void radix_tree_dump(struct radix_tree *rt, FILE *out);
|
||||
|
||||
// Shortcut for ptr value return
|
||||
// Note: if value would be NULL, it's same result for not/found case.
|
||||
static inline void *radix_tree_lookup_ptr(struct radix_tree *rt, const void *key, size_t keylen)
|
||||
{
|
||||
union radix_value v;
|
||||
return radix_tree_lookup(rt, key, keylen, &v) ? v.ptr : NULL;
|
||||
}
|
||||
|
||||
static inline bool radix_tree_insert_ptr(struct radix_tree *rt, const void *key, size_t keylen, void *ptr)
|
||||
{
|
||||
union radix_value v = { .ptr = ptr };
|
||||
return radix_tree_insert(rt, key, keylen, v);
|
||||
}
|
||||
//----------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
|
||||
@@ -49,7 +49,7 @@ install_localconf: $(CONFLOCAL)
|
||||
fi
|
||||
|
||||
install_profiles: $(PROFILES)
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_DIR) $(profiledir)
|
||||
$(Q) $(INSTALL_DATA) $(PROFILES) $(profiledir)/
|
||||
|
||||
|
||||
@@ -135,6 +135,16 @@ devices {
|
||||
# This configuration option has an automatic default value.
|
||||
# devicesfile = "system.devices"
|
||||
|
||||
# Configuration option devices/devicesfile_backup_limit.
|
||||
# The max number of backup files to keep in /etc/lvm/devices/backup.
|
||||
# LVM creates a backup of the devices file each time a new
|
||||
# version is created, or each time a modification is detected.
|
||||
# When the max number of backups is reached, the oldest are
|
||||
# removed to remain at the limit. Set to 0 to disable backups.
|
||||
# Only the system devices file is backed up.
|
||||
# This configuration option has an automatic default value.
|
||||
# devicesfile_backup_limit = 50
|
||||
|
||||
# Configuration option devices/search_for_devnames.
|
||||
# Look outside of the devices file for missing devname entries.
|
||||
# A devname entry is used for a device that does not have a stable
|
||||
@@ -149,7 +159,27 @@ devices {
|
||||
# at other devices, but only those that are likely to have the PV.
|
||||
# If "all", lvm will look at all devices on the system.
|
||||
# This configuration option has an automatic default value.
|
||||
# search_for_devnames = "auto"
|
||||
# search_for_devnames = "all"
|
||||
|
||||
# Configuration option devices/device_ids_refresh.
|
||||
# Find PVs on new devices and update the device IDs in the devices file.
|
||||
# If PVs are restored or moved to a new system with new devices, but
|
||||
# an old system.devices remains with old device IDs, then search for
|
||||
# the PVIDs on new devices and update the device IDs in system.devices.
|
||||
# The original device IDs must also not be found on the new system.
|
||||
# See device_ids_refresh_check for conditions that trigger the refresh.
|
||||
# This configuration option has an automatic default value.
|
||||
# device_ids_refresh = 1
|
||||
|
||||
# Configuration option devices/device_ids_refresh_checks.
|
||||
# Conditions that trigger device_ids_refresh to locate PVIDs on new devices.
|
||||
# product_uuid: refresh if /sys/devices/virtual/dmi/id/product_uuid does not
|
||||
# match the value saved in system.devices.
|
||||
# hostname: refresh if hostname does not match the value saved in system.devices.
|
||||
# (hostname is used if product_uuid is not available.)
|
||||
# Remove values from this list to prevent lvm from using them.
|
||||
# This configuration option has an automatic default value.
|
||||
# device_ids_refresh_checks = [ "product_uuid", "hostname" ]
|
||||
|
||||
# Configuration option devices/filter.
|
||||
# Limit the block devices that are used by LVM commands.
|
||||
@@ -211,17 +241,12 @@ devices {
|
||||
# sysfs_scan = 1
|
||||
|
||||
# Configuration option devices/scan_lvs.
|
||||
# Scan LVM LVs for layered PVs, allowing LVs to be used as PVs.
|
||||
# When 1, LVM will detect PVs layered on LVs, and caution must be
|
||||
# taken to avoid a host accessing a layered VG that may not belong
|
||||
# to it, e.g. from a guest image. This generally requires excluding
|
||||
# the LVs with device filters. Also, when this setting is enabled,
|
||||
# every LVM command will scan every active LV on the system (unless
|
||||
# filtered), which can cause performance problems on systems with
|
||||
# many active LVs. When this setting is 0, LVM will not detect or
|
||||
# use PVs that exist on LVs, and will not allow a PV to be created on
|
||||
# an LV. The LVs are ignored using a built in device filter that
|
||||
# identifies and excludes LVs.
|
||||
# Allow LVM LVs to be used as PVs. When enabled, LVM commands will
|
||||
# scan active LVs to look for other PVs. Caution is required to
|
||||
# avoid using PVs that belong to guest images stored on LVs.
|
||||
# When enabled, the LVs scanned should be restricted using the
|
||||
# devices file or the filter. This option does not enable autoactivation
|
||||
# of layered VGs, which requires editing LVM udev rules (see LVM_PVSCAN_ON_LVS.)
|
||||
# This configuration option has an automatic default value.
|
||||
# scan_lvs = 0
|
||||
|
||||
@@ -650,11 +675,6 @@ allocation {
|
||||
# This configuration option has an automatic default value.
|
||||
# vdo_block_map_period = 16380
|
||||
|
||||
# Configuration option allocation/vdo_check_point_frequency.
|
||||
# The default check point frequency for VDO volume.
|
||||
# This configuration option has an automatic default value.
|
||||
# vdo_check_point_frequency = 0
|
||||
|
||||
# Configuration option allocation/vdo_use_sparse_index.
|
||||
# Enables sparse indexing for VDO volume.
|
||||
# This configuration option has an automatic default value.
|
||||
@@ -1012,7 +1032,7 @@ global {
|
||||
# Location of proc filesystem.
|
||||
# This configuration option is advanced.
|
||||
# This configuration option has an automatic default value.
|
||||
# proc = "/proc"
|
||||
# proc = "@DEFAULT_PROC_DIR@"
|
||||
|
||||
# Configuration option global/etc.
|
||||
# Location of /etc system configuration directory.
|
||||
@@ -1156,7 +1176,7 @@ global {
|
||||
# services (via the lvm2-activation-generator), but the autoactivation
|
||||
# services and generator have been removed.
|
||||
# This configuration option has an automatic default value.
|
||||
# event_activation = 1
|
||||
# event_activation = @DEFAULT_EVENT_ACTIVATION@
|
||||
|
||||
# Configuration option global/use_aio.
|
||||
# Use async I/O when reading and writing devices.
|
||||
@@ -1201,7 +1221,7 @@ global {
|
||||
|
||||
# Configuration option global/thin_check_executable.
|
||||
# The full path to the thin_check command.
|
||||
# LVM uses this command to check that a thin metadata device is in a
|
||||
# LVM uses this command to check that a thin pool metadata device is in a
|
||||
# usable state. When a thin pool is activated and after it is
|
||||
# deactivated, this command is run. Activation will only proceed if
|
||||
# the command has an exit status of 0. Set to "" to skip this check.
|
||||
@@ -1225,6 +1245,14 @@ global {
|
||||
# This configuration option has an automatic default value.
|
||||
# thin_repair_executable = "@THIN_REPAIR_CMD@"
|
||||
|
||||
# Configuration option global/thin_restore_executable.
|
||||
# The full path to the thin_restore command.
|
||||
# LVM uses this command to restore generated data for a thin pool metadata device.
|
||||
# Also see thin_restore_options.
|
||||
# (See package device-mapper-persistent-data or thin-provisioning-tools)
|
||||
# This configuration option has an automatic default value.
|
||||
# thin_restore_executable = "@THIN_RESTORE_CMD@"
|
||||
|
||||
# Configuration option global/thin_check_options.
|
||||
# List of options passed to the thin_check command.
|
||||
# With thin_check version 2.1 or newer you can add the option
|
||||
@@ -1239,6 +1267,11 @@ global {
|
||||
# This configuration option has an automatic default value.
|
||||
# thin_repair_options = [ "" ]
|
||||
|
||||
# Configuration option global/thin_restore_options.
|
||||
# List of options passed to the thin_restore command.
|
||||
# This configuration option has an automatic default value.
|
||||
# thin_restore_options = [ "" ]
|
||||
|
||||
# Configuration option global/thin_disabled_features.
|
||||
# Features to not use in the thin driver.
|
||||
# This can be helpful for testing, or to avoid using a feature that is
|
||||
@@ -1287,6 +1320,14 @@ global {
|
||||
# This configuration option has an automatic default value.
|
||||
# cache_repair_executable = "@CACHE_REPAIR_CMD@"
|
||||
|
||||
# Configuration option global/cache_restore_executable.
|
||||
# The full path to the cache_restore command.
|
||||
# LVM uses this command to restore generated data for a cache metadata device.
|
||||
# Also see cache_restore_options.
|
||||
# (See package device-mapper-persistent-data or thin-provisioning-tools)
|
||||
# This configuration option has an automatic default value.
|
||||
# cache_restore_executable = "@CACHE_RESTORE_CMD@"
|
||||
|
||||
# Configuration option global/cache_check_options.
|
||||
# List of options passed to the cache_check command.
|
||||
# With cache_check version 5.0 or newer you should include the option
|
||||
@@ -1299,6 +1340,11 @@ global {
|
||||
# This configuration option has an automatic default value.
|
||||
# cache_repair_options = [ "" ]
|
||||
|
||||
# Configuration option global/cache_restore_options.
|
||||
# List of options passed to the cache_restore command.
|
||||
# This configuration option has an automatic default value.
|
||||
# cache_restore_options = [ "" ]
|
||||
|
||||
# Configuration option global/vdo_format_executable.
|
||||
# The full path to the vdoformat command.
|
||||
# LVM uses this command to initial data volume for VDO type logical volume
|
||||
@@ -1346,8 +1392,9 @@ global {
|
||||
# Use an LVM-specific derivation of the local machine-id as the
|
||||
# system ID. See 'man machine-id'.
|
||||
# machineid
|
||||
# Use the contents of the machine-id file to set the system ID
|
||||
# (appmachineid is recommended.)
|
||||
# Use the contents of the machine-id file to set the system ID.
|
||||
# (appmachineid is recommended to avoid exposing the confidential
|
||||
# machine-id.)
|
||||
# file
|
||||
# Use the contents of another file (system_id_file) to set the
|
||||
# system ID.
|
||||
@@ -1790,7 +1837,7 @@ activation {
|
||||
# Configuration option activation/polling_interval.
|
||||
# Check pvmove or lvconvert progress at this interval (seconds).
|
||||
# When pvmove or lvconvert must wait for the kernel to finish
|
||||
# synchronising or merging data, they check and report progress at
|
||||
# synchronizing or merging data, they check and report progress at
|
||||
# intervals of this number of seconds. If this is set to 0 and there
|
||||
# is only one thing to wait for, there are no progress reports, but
|
||||
# the process is awoken immediately once the operation is complete.
|
||||
@@ -1935,8 +1982,7 @@ activation {
|
||||
|
||||
# Configuration section report.
|
||||
# LVM report command output formatting.
|
||||
# This configuration section has an automatic default value.
|
||||
# report {
|
||||
report {
|
||||
|
||||
# Configuration option report/output_format.
|
||||
# Format of LVM command's report output.
|
||||
@@ -1996,7 +2042,11 @@ activation {
|
||||
# buffered = 1
|
||||
|
||||
# Configuration option report/headings.
|
||||
# Show headings for columns on report.
|
||||
# Format of LVM command's report output headings.
|
||||
# Accepted values:
|
||||
# 0 no headings,
|
||||
# 1 headings with column abbreviations,
|
||||
# 2 headings with full column names.
|
||||
# This configuration option has an automatic default value.
|
||||
# headings = 1
|
||||
|
||||
@@ -2346,7 +2396,7 @@ activation {
|
||||
# This is displayed when the device for a PV is not known.
|
||||
# This configuration option has an automatic default value.
|
||||
# two_word_unknown_device = 0
|
||||
# }
|
||||
}
|
||||
|
||||
# Configuration section dmeventd.
|
||||
# Settings for the LVM event daemon.
|
||||
|
||||
@@ -8,7 +8,6 @@ allocation {
|
||||
vdo_minimum_io_size=4096
|
||||
vdo_block_map_cache_size_mb=128
|
||||
vdo_block_map_period=16380
|
||||
vdo_check_point_frequency=0
|
||||
vdo_use_sparse_index=0
|
||||
vdo_index_memory_size_mb=256
|
||||
vdo_slab_size_mb=2048
|
||||
|
||||
276
configure.ac
276
configure.ac
@@ -57,7 +57,7 @@ AS_CASE(["$host_os"],
|
||||
FSADM="no"
|
||||
LVMIMPORTVDO="no"
|
||||
BLKDEACTIVATE="no"],
|
||||
[CLDFLAGS="${CLDFLAGS-"$LDFLAGS"}"])
|
||||
[])
|
||||
|
||||
################################################################################
|
||||
dnl -- Checks for programs.
|
||||
@@ -75,6 +75,8 @@ dnl probably no longer needed in 2008, but...
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_GREP
|
||||
AC_PROG_EGREP
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_MKDIR_P
|
||||
AC_PROG_RANLIB
|
||||
@@ -185,11 +187,19 @@ AC_ARG_ENABLE(static_link,
|
||||
STATIC_LINK=$enableval, STATIC_LINK="no")
|
||||
AC_MSG_RESULT([$STATIC_LINK])
|
||||
|
||||
################################################################################
|
||||
dnl -- Disables shared linking
|
||||
AC_MSG_CHECKING([whether to use dynamic linking])
|
||||
AC_ARG_ENABLE(shared,
|
||||
AS_HELP_STRING([--disable-shared], [disable dynamic linking]),
|
||||
SHARED_LINK=$enableval, SHARED_LINK="yes")
|
||||
AC_MSG_RESULT([$SHARED_LINK])
|
||||
|
||||
################################################################################
|
||||
dnl -- Check if compiler/linker supports PIE and RELRO
|
||||
AC_TRY_CCFLAG([-pie], [HAVE_PIE], [], [])
|
||||
AC_SUBST(HAVE_PIE)
|
||||
AC_TRY_LDFLAGS([-Wl,-z,relro,-z,now], [HAVE_FULL_RELRO], [], [])
|
||||
AC_TRY_LDFLAGS([-Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed], [HAVE_FULL_RELRO], [], [])
|
||||
AC_SUBST(HAVE_FULL_RELRO)
|
||||
|
||||
################################################################################
|
||||
@@ -204,6 +214,14 @@ test "$prefix" = "NONE" && prefix=$ac_default_prefix
|
||||
# Let make expand exec_prefix.
|
||||
test "$exec_prefix" = "NONE" && exec_prefix='${prefix}'
|
||||
|
||||
|
||||
AC_ARG_WITH(blkid, [AS_HELP_STRING([--without-blkid], [do not build with blkid library])],
|
||||
[], with_blkid="yes")
|
||||
AC_ARG_WITH(systemd, [AS_HELP_STRING([--without-systemd], [do not build with systemd library])],
|
||||
[], with_systemd="yes")
|
||||
AC_ARG_WITH(udev, [AS_HELP_STRING([--without-udev], [do not build with udev library])],
|
||||
[], with_udev="yes")
|
||||
|
||||
################################################################################
|
||||
dnl -- Setup the ownership of the files
|
||||
AC_MSG_CHECKING([file owner])
|
||||
@@ -273,7 +291,7 @@ AC_DEFINE_UNQUOTED([DEFAULT_DM_ADD_NODE], $add_on, [Define default node creation
|
||||
dnl -- Default settings for lvm.conf { devices/use_devicesfile }
|
||||
AC_MSG_CHECKING([default for use_devicesfile])
|
||||
AC_ARG_WITH(default-use-devices-file,
|
||||
AS_HELP_STRING([--with-default-use-devices-file], [default for lvm.conf devices/use_devicesfile = [0]]),
|
||||
AS_HELP_STRING([--with-default-use-devices-file=ON], [default lvm.conf devices/use_devicesfile = [ON=0]]),
|
||||
DEFAULT_USE_DEVICES_FILE=$withval, DEFAULT_USE_DEVICES_FILE=0)
|
||||
AS_CASE(["$DEFAULT_USE_DEVICES_FILE"],
|
||||
[0|1], [],
|
||||
@@ -295,6 +313,17 @@ AS_CASE(["$MANGLING"],
|
||||
AC_MSG_RESULT([$MANGLING])
|
||||
AC_DEFINE_UNQUOTED([DEFAULT_DM_NAME_MANGLING], $mangling, [Define default name mangling behaviour])
|
||||
|
||||
AC_MSG_CHECKING([default for event_activation])
|
||||
AC_ARG_WITH(default-event-activation,
|
||||
AS_HELP_STRING([--with-default-event-activation=ON], [default lvm.conf global/event_activation = [ON=1]]),
|
||||
DEFAULT_EVENT_ACTIVATION=$withval, DEFAULT_EVENT_ACTIVATION=1)
|
||||
AS_CASE(["$DEFAULT_EVENT_ACTIVATION"],
|
||||
[0|1], [],
|
||||
[AC_MSG_ERROR([--with-default-event-activation parameter invalid])])
|
||||
AC_MSG_RESULT([$DEFAULT_EVENT_ACTIVATION])
|
||||
AC_DEFINE_UNQUOTED(DEFAULT_EVENT_ACTIVATION, [$DEFAULT_EVENT_ACTIVATION],
|
||||
[Default for lvm.conf event_activation.])
|
||||
|
||||
################################################################################
|
||||
dnl -- snapshots inclusion type
|
||||
AC_MSG_CHECKING([whether to include snapshots])
|
||||
@@ -410,6 +439,7 @@ AS_CASE(["$THIN"],
|
||||
])
|
||||
AS_IF([test "$THIN_CHECK_NEEDS_CHECK" = "yes" && test "$THIN_CONFIGURE_WARN" != "y"], [
|
||||
THIN_CHECK_VSN=$("$THIN_CHECK_CMD" -V 2>/dev/null)
|
||||
THIN_CHECK_VSN=${THIN_CHECK_VSN##* } # trim away all before the first space
|
||||
THIN_CHECK_VSN_MAJOR=$(echo "$THIN_CHECK_VSN" | $AWK -F '.' '{print $1}')
|
||||
THIN_CHECK_VSN_MINOR=$(echo "$THIN_CHECK_VSN" | $AWK -F '.' '{print $2}')
|
||||
|
||||
@@ -451,7 +481,7 @@ AS_CASE(["$THIN"],
|
||||
])
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([whether thin_check supports the needs-check flag])
|
||||
AC_MSG_CHECKING([whether $THIN_CHECK_CMD ($THIN_CHECK_VSN_MAJOR.$THIN_CHECK_VSN_MINOR) supports the needs-check flag])
|
||||
AC_MSG_RESULT([$THIN_CHECK_NEEDS_CHECK])
|
||||
AS_IF([test "$THIN_CHECK_NEEDS_CHECK" = "yes"], [
|
||||
AC_DEFINE([THIN_CHECK_NEEDS_CHECK], 1, [Define to 1 if the external 'thin_check' tool requires the --clear-needs-check-flag option])
|
||||
@@ -521,12 +551,13 @@ AS_CASE(["$CACHE"],
|
||||
])
|
||||
])
|
||||
AS_IF([test "$CACHE_CHECK_NEEDS_CHECK" = "yes" && test "$CACHE_CONFIGURE_WARN" != "y"], [
|
||||
$CACHE_CHECK_CMD -V 2>/dev/null >conftest.tmp
|
||||
"$CACHE_CHECK_CMD" -V 2>/dev/null >conftest.tmp
|
||||
read -r CACHE_CHECK_VSN < conftest.tmp
|
||||
IFS=.- read -r CACHE_CHECK_VSN_MAJOR CACHE_CHECK_VSN_MINOR CACHE_CHECK_VSN_PATCH LEFTOVER < conftest.tmp
|
||||
rm -f conftest.tmp
|
||||
|
||||
# Require version >= 0.5.4 for --clear-needs-check-flag
|
||||
CACHE_CHECK_VSN_MAJOR=${CACHE_CHECK_VSN_MAJOR##* }
|
||||
AS_IF([test -z "$CACHE_CHECK_VSN_MAJOR" \
|
||||
|| test -z "$CACHE_CHECK_VSN_MINOR" \
|
||||
|| test -z "$CACHE_CHECK_VSN_PATCH"], [
|
||||
@@ -574,7 +605,7 @@ AS_CASE(["$CACHE"],
|
||||
])
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([whether cache_check supports the needs-check flag])
|
||||
AC_MSG_CHECKING([whether $CACHE_CHECK_CMD ($CACHE_CHECK_VSN_MAJOR.$CACHE_CHECK_VSN_MINOR.$CACHE_CHECK_VSN_PATCH) supports the needs-check flag])
|
||||
AC_MSG_RESULT([$CACHE_CHECK_NEEDS_CHECK])
|
||||
AS_IF([test "$CACHE_CHECK_NEEDS_CHECK" = "yes"], [
|
||||
AC_DEFINE([CACHE_CHECK_NEEDS_CHECK], 1, [Define to 1 if the external 'cache_check' tool requires the --clear-needs-check-flag option])
|
||||
@@ -625,7 +656,7 @@ AC_DEFINE_UNQUOTED([VDO_FORMAT_CMD], ["$VDO_FORMAT_CMD"],
|
||||
[The path to 'vdoformat', if available.])
|
||||
#
|
||||
# Do we need to use the API??
|
||||
# Do we want to link lvm2 with a big library for vdoformating ?
|
||||
# Do we want to link lvm2 with a big library for vdoformatting ?
|
||||
#
|
||||
#AC_ARG_WITH(vdo-include,
|
||||
# AS_HELP_STRING([--with-vdo-include=PATH],
|
||||
@@ -805,7 +836,7 @@ AS_IF([test "$GCC" = "yes" && test "$symvers" = "gnu"], [
|
||||
[Define to use GNU versioning in the shared library.])
|
||||
AS_CASE(["$host_os"],
|
||||
[linux*], [
|
||||
CLDFLAGS="${CLDFLAGS-"$LDFLAGS"} -Wl,--version-script,.export.sym"
|
||||
CLDFLAGS="-Wl,--version-script,.export.sym"
|
||||
LDDEPS="$LDDEPS .export.sym"])
|
||||
])
|
||||
|
||||
@@ -819,7 +850,7 @@ AC_ARG_ENABLE(profiling,
|
||||
AC_MSG_RESULT([$PROFILING])
|
||||
|
||||
AS_IF([test "$PROFILING" = "yes"], [
|
||||
COPTIMISE_FLAG="$COPTIMISE_FLAG -fprofile-arcs -ftest-coverage"
|
||||
COPTIMISE_FLAG="$COPTIMISE_FLAG -fprofile-arcs -fprofile-update=atomic -ftest-coverage"
|
||||
AC_PATH_TOOL(LCOV, lcov)
|
||||
AC_PATH_TOOL(GENHTML, genhtml)
|
||||
AS_IF([test -z "$LCOV" || test -z "$GENHTML"], [
|
||||
@@ -902,7 +933,7 @@ AC_MSG_RESULT([$BUILD_LOCKDSANLOCK])
|
||||
|
||||
dnl -- Look for sanlock libraries
|
||||
AS_IF([test "$BUILD_LOCKDSANLOCK" = "yes"], [
|
||||
PKG_CHECK_MODULES(LIBSANLOCKCLIENT, libsanlock_client >= 3.3.0, [BUILD_LVMLOCKD="yes"])
|
||||
PKG_CHECK_MODULES(LIBSANLOCKCLIENT, libsanlock_client >= 3.7.0, [BUILD_LVMLOCKD="yes"])
|
||||
AC_DEFINE([LOCKDSANLOCK_SUPPORT], 1, [Define to 1 to include code that uses lvmlockd sanlock option.])
|
||||
])
|
||||
|
||||
@@ -1012,36 +1043,24 @@ AC_DEFINE_UNQUOTED(DEFAULT_USE_LVMPOLLD, [$DEFAULT_USE_LVMPOLLD],
|
||||
|
||||
|
||||
SYSTEMD_MIN_VERSION=0
|
||||
PKG_CHECK_EXISTS(systemd >= 221, [SYSTEMD_MIN_VERSION=221])
|
||||
PKG_CHECK_EXISTS(systemd >= 234, [SYSTEMD_MIN_VERSION=234])
|
||||
|
||||
################################################################################
|
||||
dnl -- Build notifydbus
|
||||
AC_MSG_CHECKING([whether to build notifydbus])
|
||||
AC_ARG_ENABLE(notify-dbus,
|
||||
AS_HELP_STRING([--enable-notify-dbus],
|
||||
[enable LVM notification using dbus]),
|
||||
NOTIFYDBUS_SUPPORT=$enableval, NOTIFYDBUS_SUPPORT="no")
|
||||
AS_IF([test "$NOTIFYDBUS_SUPPORT" = "yes" && test "$SYSTEMD_MIN_VERSION" -lt 221],
|
||||
[AC_MSG_ERROR([Enabling notify-dbus requires systemd >= 221])])
|
||||
AC_MSG_RESULT([$NOTIFYDBUS_SUPPORT])
|
||||
|
||||
AS_IF([test "$NOTIFYDBUS_SUPPORT" = "yes"],
|
||||
AC_DEFINE([NOTIFYDBUS_SUPPORT], 1, [Define to 1 to include code that uses dbus notification.]))
|
||||
NOTIFYDBUS_SUPPORT="no"
|
||||
SYSTEMD_JOURNAL_SUPPORT="no"
|
||||
APP_MACHINEID_SUPPORT="no"
|
||||
AS_IF([test "$with_systemd" = "yes"],
|
||||
PKG_CHECK_EXISTS(systemd >= 221, [SYSTEMD_MIN_VERSION=221 NOTIFYDBUS_SUPPORT="maybe" SYSTEMD_JOURNAL_SUPPORT="maybe"])
|
||||
PKG_CHECK_EXISTS(systemd >= 234, [SYSTEMD_MIN_VERSION=234 APP_MACHINEID_SUPPORT="maybe"]))
|
||||
|
||||
################################################################################
|
||||
dnl -- Build with systemd journaling when the header file is present
|
||||
AS_IF([test "$SYSTEMD_MIN_VERSION" -ge 221], [SYSTEMD_JOURNAL_SUPPORT="maybe"], [SYSTEMD_JOURNAL_SUPPORT="no"])
|
||||
AC_CHECK_HEADER([systemd/sd-journal.h],
|
||||
[AS_IF([test "$SYSTEMD_JOURNAL_SUPPORT" != "no"], [SYSTEMD_JOURNAL_SUPPORT="yes"])],
|
||||
[SYSTEMD_JOURNAL_SUPPORT="no"])
|
||||
AC_MSG_CHECKING([whether to log to systemd journal])
|
||||
AS_IF([test "$SYSTEMD_JOURNAL_SUPPORT" != "no"],
|
||||
AC_CHECK_HEADER([systemd/sd-journal.h], [SYSTEMD_JOURNAL_SUPPORT="yes"], [SYSTEMD_JOURNAL_SUPPORT="no"]))
|
||||
AC_ARG_ENABLE(systemd-journal,
|
||||
AS_HELP_STRING([--disable-systemd-journal],
|
||||
[disable LVM systemd journaling]),
|
||||
AS_IF([test "$enableval" = "yes" && test "$SYSTEMD_JOURNAL_SUPPORT" = "no"],
|
||||
AC_MSG_ERROR([Enabling systemd journal requires systemd/sd-journal.h and systemd >= 221.]))
|
||||
AC_MSG_ERROR([--enable-systemd-journal requires systemd/sd-journal.h and systemd >= 221. (--with-systemd=$with_systemd)]))
|
||||
SYSTEMD_JOURNAL_SUPPORT=$enableval, [])
|
||||
AC_MSG_CHECKING([whether to log to systemd journal])
|
||||
AC_MSG_RESULT([$SYSTEMD_JOURNAL_SUPPORT])
|
||||
|
||||
AS_IF([test "$SYSTEMD_JOURNAL_SUPPORT" = "yes"],
|
||||
@@ -1049,27 +1068,20 @@ AS_IF([test "$SYSTEMD_JOURNAL_SUPPORT" = "yes"],
|
||||
|
||||
################################################################################
|
||||
dnl -- Build appmachineid when header file sd-id128.h is present
|
||||
AS_IF([test "$SYSTEMD_MIN_VERSION" -ge 234], [APP_MACHINEID_SUPPORT="maybe"], [APP_MACHINEID_SUPPORT="no"])
|
||||
AC_CHECK_HEADER([systemd/sd-id128.h],
|
||||
[AS_IF([test "$APP_MACHINEID_SUPPORT" != "no"], [APP_MACHINEID_SUPPORT="yes"])],
|
||||
[APP_MACHINEID_SUPPORT="no"])
|
||||
AC_MSG_CHECKING([whether to support systemd appmachineid])
|
||||
AS_IF([test "$APP_MACHINEID_SUPPORT" != "no"],
|
||||
[AC_CHECK_HEADER([systemd/sd-id128.h], [APP_MACHINEID_SUPPORT="yes"], [APP_MACHINEID_SUPPORT="no"])])
|
||||
AC_ARG_ENABLE(app-machineid,
|
||||
AS_HELP_STRING([--disable-app-machineid],
|
||||
[disable LVM system ID using app-specific machine-id]),
|
||||
AS_IF([test "$enableval" = "yes" && test "$APP_MACHINEID_SUPPORT" = "no"],
|
||||
AC_MSG_ERROR([Enabling app machineid requires systemd/sd-id128.h and systemd >= 234.]))
|
||||
AC_MSG_ERROR([--enable-app-machineid requires systemd/sd-id128.h and systemd >= 234. (--with-systemd=$with_systemd)]))
|
||||
APP_MACHINEID_SUPPORT=$enableval, [])
|
||||
AC_MSG_CHECKING([whether to support systemd appmachineid])
|
||||
AC_MSG_RESULT([$APP_MACHINEID_SUPPORT])
|
||||
|
||||
AS_IF([test "$APP_MACHINEID_SUPPORT" = "yes"],
|
||||
AC_DEFINE([APP_MACHINEID_SUPPORT], 1, [Define to 1 to include code that uses libsystemd machine-id apis.]))
|
||||
|
||||
dnl -- Look for libsystemd libraries if needed
|
||||
AS_IF([test "$NOTIFYDBUS_SUPPORT" = "yes" || test "$SYSTEMD_JOURNAL_SUPPORT" = "yes" || test "$APP_MACHINEID_SUPPORT" = "yes"], [
|
||||
PKG_CHECK_MODULES(LIBSYSTEMD, [libsystemd])
|
||||
])
|
||||
|
||||
################################################################################
|
||||
dnl -- Support override for systemd-run path if they need to (NixOS builds)
|
||||
AC_ARG_WITH(systemd-run,
|
||||
@@ -1084,67 +1096,64 @@ AC_MSG_RESULT([$SYSTEMD_RUN_CMD])
|
||||
################################################################################
|
||||
|
||||
dnl -- Enable blkid wiping functionality
|
||||
AC_ARG_ENABLE(blkid_wiping,
|
||||
AS_HELP_STRING([--disable-blkid_wiping],
|
||||
[disable libblkid detection of signatures when wiping and use native code instead]),
|
||||
BLKID_WIPING=$enableval, BLKID_WIPING="maybe")
|
||||
|
||||
# TODO: possibly detect right version of blkid with BLKID_SUBLKS_FSINFO support
|
||||
# so lvresize can check detected flag here
|
||||
#
|
||||
DEFAULT_USE_BLKID_WIPING=0
|
||||
PKG_CHECK_EXISTS([blkid >= 2.24], [HAVE_BLKID="yes"], [HAVE_BLKID="no"])
|
||||
|
||||
AS_IF([test "$HAVE_BLKID" = "yes"], [
|
||||
PKG_CHECK_MODULES([BLKID], [blkid >= 2.24], [
|
||||
|
||||
AC_CACHE_CHECK([for blkid.h defines BLKID_SUBLKS_FSINFO.],
|
||||
[ac_cv_have_blkid_sublks_fsinfo],
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <blkid/blkid.h>
|
||||
#ifndef BLKID_SUBLKS_FSINFO
|
||||
#error BLKID_SUBLKS_FSINFO is missing
|
||||
#endif])],
|
||||
[ac_cv_have_blkid_sublks_fsinfo="yes"], [ac_cv_have_blkid_sublks_fsinfo="no"])])
|
||||
|
||||
AC_IF_YES(ac_cv_have_blkid_sublks_fsinfo,
|
||||
AC_DEFINE(HAVE_BLKID_SUBLKS_FSINFO, 1,
|
||||
[Define if blkid.h has BLKID_SUBLKS_FSINFO]))
|
||||
])
|
||||
])
|
||||
AC_ARG_ENABLE(blkid_wiping,
|
||||
AS_HELP_STRING([--disable-blkid_wiping],
|
||||
[disable libblkid detection of signatures when wiping and use native code instead]),
|
||||
BLKID_WIPING=$enableval,
|
||||
[AS_IF([test "$with_blkid" = "yes"], [BLKID_WIPING="maybe"], [BLKID_WIPING="no"])])
|
||||
|
||||
AS_IF([test "$BLKID_WIPING" != "no"], [
|
||||
AS_IF([test "$HAVE_BLKID" = "yes"], [
|
||||
BLKID_WIPING="yes"
|
||||
BLKID_PC="blkid"
|
||||
DEFAULT_USE_BLKID_WIPING=1
|
||||
BLKID_STATIC_LIBS=$("$PKG_CONFIG" --static --libs blkid)
|
||||
AC_DEFINE([BLKID_WIPING_SUPPORT], 1, [Define to 1 to use libblkid detection of signatures when wiping.])
|
||||
], [
|
||||
AS_IF([test "$BLKID_WIPING" = "maybe"], [
|
||||
BLKID_WIPING=no
|
||||
], [
|
||||
AC_MSG_ERROR([bailing out... blkid library >= 2.24 is required])
|
||||
])
|
||||
])
|
||||
PKG_CHECK_MODULES([BLKID], [blkid >= 2.24], [
|
||||
AC_CACHE_CHECK([for blkid.h defines BLKID_SUBLKS_FSINFO.],
|
||||
[ac_cv_have_blkid_sublks_fsinfo],
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <blkid/blkid.h>
|
||||
#ifndef BLKID_SUBLKS_FSINFO
|
||||
#error BLKID_SUBLKS_FSINFO is missing
|
||||
#endif
|
||||
])], [ac_cv_have_blkid_sublks_fsinfo="yes"], [ac_cv_have_blkid_sublks_fsinfo="no"])])
|
||||
|
||||
AC_IF_YES(ac_cv_have_blkid_sublks_fsinfo,
|
||||
AC_DEFINE(HAVE_BLKID_SUBLKS_FSINFO, 1,
|
||||
[Define if blkid.h has BLKID_SUBLKS_FSINFO]))
|
||||
|
||||
AS_IF([test "$with_blkid" = "no"], [BLKID_WIPING="error"], [
|
||||
BLKID_WIPING="yes"
|
||||
BLKID_PC="blkid"
|
||||
DEFAULT_USE_BLKID_WIPING=1
|
||||
# pkg_config --static does not really work ATM...
|
||||
BLKID_STATIC_LIBS=$("$PKG_CONFIG" --static --libs blkid)
|
||||
AC_DEFINE([BLKID_WIPING_SUPPORT], 1, [Define to 1 to use libblkid detection of signatures when wiping.])
|
||||
])
|
||||
], [AS_IF([test "$BLKID_WIPING" = "yes"], [BLKID_WIPING="error"], [BLKID_WIPING="no"])])
|
||||
])
|
||||
|
||||
AS_IF([test "$BLKID_WIPING" = "error"],
|
||||
[AC_MSG_ERROR([--enable-blkid_wiping requires blkid library >= 2.24. (--with-blkid=$with_blkid)])])
|
||||
|
||||
AC_MSG_CHECKING([whether to enable libblkid detection of signatures when wiping])
|
||||
AC_MSG_RESULT([$BLKID_WIPING])
|
||||
AC_DEFINE_UNQUOTED(DEFAULT_USE_BLKID_WIPING, [$DEFAULT_USE_BLKID_WIPING],
|
||||
[Use blkid wiping by default.])
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable udev synchronisation
|
||||
AC_MSG_CHECKING([whether to enable synchronisation with udev processing])
|
||||
dnl -- Enable udev synchronization
|
||||
AC_MSG_CHECKING([whether to enable synchronization with udev processing])
|
||||
AC_ARG_ENABLE(udev_sync,
|
||||
AS_HELP_STRING([--enable-udev_sync],
|
||||
[enable synchronisation with udev processing]),
|
||||
[enable synchronization with udev processing]),
|
||||
UDEV_SYNC=$enableval, UDEV_SYNC="no")
|
||||
AC_MSG_RESULT([$UDEV_SYNC])
|
||||
AS_IF([test "$UDEV_SYNC" = "yes" && test "$with_udev" = "no"],
|
||||
[AC_MSG_ERROR([--enable-udev_sync requires udev >= 143. (--with-udev=$with_udev)])])
|
||||
|
||||
AS_IF([test "$UDEV_SYNC" = "yes"], [
|
||||
PKG_CHECK_MODULES(UDEV, libudev >= 143, [UDEV_PC="libudev"])
|
||||
UDEV_STATIC_LIBS=$("$PKG_CONFIG" --static --libs libudev)
|
||||
AC_DEFINE([UDEV_SYNC_SUPPORT], 1, [Define to 1 to enable synchronisation with udev processing.])
|
||||
AC_DEFINE([UDEV_SYNC_SUPPORT], 1, [Define to 1 to enable synchronization with udev processing.])
|
||||
|
||||
AC_CHECK_LIB(udev, udev_device_get_is_initialized, AC_DEFINE([HAVE_LIBUDEV_UDEV_DEVICE_GET_IS_INITIALIZED], 1,
|
||||
[Define to 1 if udev_device_get_is_initialized is available.]))
|
||||
@@ -1152,10 +1161,10 @@ AS_IF([test "$UDEV_SYNC" = "yes"], [
|
||||
])
|
||||
|
||||
dnl -- Enable udev rules
|
||||
AC_MSG_CHECKING([whether to enable installation of udev rules required for synchronisation])
|
||||
AC_MSG_CHECKING([whether to enable installation of udev rules required for synchronization])
|
||||
AC_ARG_ENABLE(udev_rules,
|
||||
AS_HELP_STRING([--enable-udev_rules],
|
||||
[install rule files needed for udev synchronisation]),
|
||||
[install rule files needed for udev synchronization]),
|
||||
UDEV_RULES=$enableval, UDEV_RULES=$UDEV_SYNC)
|
||||
AC_MSG_RESULT([$UDEV_RULES])
|
||||
|
||||
@@ -1210,16 +1219,6 @@ AS_IF([test "$ODIRECT" = "yes"], [
|
||||
AC_DEFINE([O_DIRECT_SUPPORT], 1, [Define to 1 to enable O_DIRECT support.])
|
||||
])
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable cmdlib
|
||||
AC_MSG_CHECKING([whether to compile liblvm2cmd.so])
|
||||
AC_ARG_ENABLE(cmdlib,
|
||||
AS_HELP_STRING([--enable-cmdlib], [build shared command library]),
|
||||
CMDLIB=$enableval, CMDLIB="no")
|
||||
AC_MSG_RESULT([$CMDLIB])
|
||||
AC_SUBST([LVM2CMD_LIB])
|
||||
AS_IF([test "$CMDLIB" = "yes"], [LVM2CMD_LIB="-llvm2cmd"], [LVM2CMD_LIB=])
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable D-Bus service
|
||||
AC_MSG_CHECKING([whether to include Python D-Bus support])
|
||||
@@ -1227,8 +1226,29 @@ AC_ARG_ENABLE(dbus-service,
|
||||
AS_HELP_STRING([--enable-dbus-service], [install D-Bus support]),
|
||||
BUILD_LVMDBUSD=$enableval, BUILD_LVMDBUSD="no")
|
||||
AC_MSG_RESULT([$BUILD_LVMDBUSD])
|
||||
AS_IF([test "$NOTIFYDBUS_SUPPORT" = "no" && test "$BUILD_LVMDBUSD" = "yes"],
|
||||
[AC_MSG_WARN([Building D-Bus support without D-Bus notifications.])])
|
||||
|
||||
################################################################################
|
||||
dnl -- Build notifydbus
|
||||
AC_ARG_ENABLE(notify-dbus,
|
||||
[AS_HELP_STRING([--enable-notify-dbus], [enable LVM notification using dbus])],
|
||||
[NOTIFYDBUS_SUPPORT=$enableval])
|
||||
|
||||
AS_IF([test "$NOTIFYDBUS_SUPPORT" = "maybe"],
|
||||
[AS_IF([test "$BUILD_LVMDBUSD" = "yes"], [NOTIFYDBUS_SUPPORT="yes"], [NOTIFYDBUS_SUPPORT="no"])])
|
||||
|
||||
AS_IF([test "$NOTIFYDBUS_SUPPORT" = "yes"],
|
||||
[AS_IF([test "$SYSTEMD_MIN_VERSION" -lt 221],
|
||||
[AC_MSG_ERROR([--enable-notify-dbus requires systemd >= 221. (--with-systemd=$with_systemd)])])
|
||||
AC_DEFINE([NOTIFYDBUS_SUPPORT], 1, [Define to 1 to include code that uses dbus notification.])])
|
||||
|
||||
AC_MSG_CHECKING([whether to build notifydbus])
|
||||
AC_MSG_RESULT([$NOTIFYDBUS_SUPPORT])
|
||||
|
||||
################################################################################
|
||||
dnl -- Look for libsystemd libraries if needed
|
||||
AS_IF([test "$NOTIFYDBUS_SUPPORT" = "yes" || test "$SYSTEMD_JOURNAL_SUPPORT" = "yes" || test "$APP_MACHINEID_SUPPORT" = "yes"], [
|
||||
PKG_CHECK_MODULES(LIBSYSTEMD, [libsystemd])
|
||||
])
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable Python dbus library
|
||||
@@ -1302,15 +1322,28 @@ AC_MSG_RESULT([$BUILD_DMEVENTD])
|
||||
|
||||
dnl -- dmeventd currently requires internal mirror support
|
||||
AS_IF([test "$BUILD_DMEVENTD" = "yes"], [
|
||||
AS_IF([test "$MIRRORS" != "internal"], [
|
||||
AC_MSG_ERROR([--enable-dmeventd currently requires --with-mirrors=internal])
|
||||
])
|
||||
AS_IF([test "$CMDLIB" = "no"], [
|
||||
AC_MSG_ERROR([--enable-dmeventd requires --enable-cmdlib to be used as well])
|
||||
])
|
||||
AS_IF([test "$MIRRORS" != "internal"],
|
||||
[AC_MSG_ERROR([--enable-dmeventd currently requires --with-mirrors=internal])])
|
||||
AC_DEFINE([DMEVENTD], 1, [Define to 1 to enable the device-mapper event daemon.])])
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable cmdlib
|
||||
AC_ARG_ENABLE(cmdlib, [AS_HELP_STRING([--enable-cmdlib], [build shared command library])],
|
||||
CMDLIB=$enableval, CMDLIB="maybe")
|
||||
|
||||
AS_IF([test "$BUILD_DMEVENTD" = "yes"],
|
||||
[AS_IF([test "$CMDLIB" = "no"],
|
||||
[AC_MSG_ERROR([--enable-dmeventd requires --enable-cmdlib to be used as well])],
|
||||
[CMDLIB="yes"])])
|
||||
|
||||
AS_IF([test "$CMDLIB" != "yes"], [CMDLIB="no" LVM2CMD_LIB=], [LVM2CMD_LIB="-llvm2cmd"])
|
||||
|
||||
AC_MSG_CHECKING([whether to compile liblvm2cmd.so])
|
||||
AC_MSG_RESULT([$CMDLIB])
|
||||
|
||||
AS_IF([test "$CMDLIB" == "yes" && test "$SHARED_LINK" = "no"],
|
||||
[AC_MSG_ERROR([--enable-cmdlib requires dynamic linking.])])
|
||||
|
||||
AC_DEFINE([DMEVENTD], 1, [Define to 1 to enable the device-mapper event daemon.])
|
||||
])
|
||||
|
||||
################################################################################
|
||||
dnl -- Check dmfilemapd
|
||||
@@ -1322,8 +1355,7 @@ AC_MSG_RESULT([$BUILD_DMFILEMAPD])
|
||||
|
||||
dnl -- dmfilemapd requires FIEMAP
|
||||
AS_IF([test "$BUILD_DMFILEMAPD" = "yes"],
|
||||
[AC_CHECK_HEADER([linux/fiemap.h], [],
|
||||
,[AC_MSG_ERROR(--enable-dmfilemapd requires fiemap.h)])
|
||||
[AC_CHECK_HEADER([linux/fiemap.h], [], [AC_MSG_ERROR(--enable-dmfilemapd requires fiemap.h)])
|
||||
AC_DEFINE([DMFILEMAPD], 1, [Define to 1 to enable the device-mapper filemap daemon.])])
|
||||
|
||||
################################################################################
|
||||
@@ -1596,6 +1628,17 @@ AC_ARG_WITH(tmpfilesdir,
|
||||
AS_HELP_STRING([--with-tmpfilesdir=DIR],
|
||||
[install configuration files for management of volatile files and directories in DIR [PREFIX/lib/tmpfiles.d]]),
|
||||
tmpfilesdir=$withval, tmpfilesdir='${prefix}/lib/tmpfiles.d')
|
||||
|
||||
################################################################################
|
||||
dnl - Where to look for modules.builtin file for a kernel - most typically in /lib/modules/
|
||||
AC_MSG_CHECKING([for kernel modules directory])
|
||||
AC_ARG_WITH(modulesdir,
|
||||
AS_HELP_STRING([--with-modulesdir=DIR],
|
||||
[Dir to look for file `uname -r`/modules.builtin [/lib/modules]]),
|
||||
[modulesdir=$withval], [modulesdir="/lib/modules"])
|
||||
AC_DEFINE_UNQUOTED(MODULES_PATH, ["$modulesdir"], [The path to kernel modules.])
|
||||
AC_MSG_RESULT([$modulesdir])
|
||||
|
||||
################################################################################
|
||||
dnl -- Ensure additional headers required
|
||||
AS_IF([test "$READLINE" = "yes"], [
|
||||
@@ -1686,12 +1729,19 @@ AC_ARG_WITH(dmeventd-path,
|
||||
[dmeventd path [EPREFIX/sbin/dmeventd]]),
|
||||
DMEVENTD_PATH=$withval,
|
||||
DMEVENTD_PATH="$SBINDIR/dmeventd")
|
||||
AC_ARG_WITH(dmeventd-exit-on-path,
|
||||
AS_HELP_STRING([--with-dmeventd-exit-on-path=PATH],
|
||||
[Default path to exit-on file in dmeventd [/run/nologin]]),
|
||||
DEFAULT_DMEVENTD_EXIT_ON_PATH=$withval,
|
||||
DEFAULT_DMEVENTD_EXIT_ON_PATH="/run/nologin")
|
||||
|
||||
AS_IF([test "$BUILD_DMEVENTD" = "yes"], [
|
||||
AC_DEFINE_UNQUOTED(DMEVENTD_PIDFILE, ["$DMEVENTD_PIDFILE"],
|
||||
[Path to dmeventd pidfile.])
|
||||
AC_DEFINE_UNQUOTED(DMEVENTD_PATH, ["$DMEVENTD_PATH"],
|
||||
[Path to dmeventd binary.])
|
||||
AC_DEFINE_UNQUOTED(DEFAULT_DMEVENTD_EXIT_ON_PATH, ["$DEFAULT_DMEVENTD_EXIT_ON_PATH"],
|
||||
[Path to exit-on dmeventd file.])
|
||||
])
|
||||
|
||||
################################################################################
|
||||
@@ -1746,6 +1796,9 @@ AC_MSG_RESULT([$DEFAULT_LOCK_DIR])
|
||||
AC_DEFINE_UNQUOTED(DEFAULT_LOCK_DIR, ["$DEFAULT_LOCK_DIR"],
|
||||
[Name of default locking directory.])
|
||||
|
||||
# No --with configure setting, but store in the main configure.h
|
||||
AC_DEFINE_UNQUOTED(DEFAULT_PROC_DIR, ["/proc"], [Path to /proc.])
|
||||
|
||||
################################################################################
|
||||
dnl -- which kernel interface to use (ioctl only)
|
||||
AC_MSG_CHECKING([for kernel interface choice])
|
||||
@@ -1825,9 +1878,12 @@ AC_SUBST(DEFAULT_ARCHIVE_SUBDIR)
|
||||
AC_SUBST(DEFAULT_BACKUP_SUBDIR)
|
||||
AC_SUBST(DEFAULT_CACHE_SUBDIR)
|
||||
AC_SUBST(DEFAULT_DM_RUN_DIR)
|
||||
AC_SUBST(DEFAULT_DMEVENTD_EXIT_ON_PATH)
|
||||
AC_SUBST(DEFAULT_EVENT_ACTIVATION)
|
||||
AC_SUBST(DEFAULT_LOCK_DIR)
|
||||
AC_SUBST(DEFAULT_MIRROR_SEGTYPE)
|
||||
AC_SUBST(DEFAULT_PID_DIR)
|
||||
AC_SUBST(DEFAULT_PROC_DIR)
|
||||
AC_SUBST(DEFAULT_PROFILE_SUBDIR)
|
||||
AC_SUBST(DEFAULT_RAID10_SEGTYPE)
|
||||
AC_SUBST(DEFAULT_RUN_DIR)
|
||||
@@ -1853,6 +1909,7 @@ AC_SUBST(LDDEPS)
|
||||
AC_SUBST(LIBS)
|
||||
AC_SUBST(LIB_SUFFIX)
|
||||
AC_SUBST(localedir)
|
||||
AC_SUBST(LVM2CMD_LIB)
|
||||
AC_SUBST(LVMIMPORTVDO)
|
||||
AC_SUBST(LVMIMPORTVDO_PATH)
|
||||
AC_SUBST(LVMLOCKD_PIDFILE)
|
||||
@@ -1884,6 +1941,7 @@ AC_SUBST(SBINDIR)
|
||||
AC_SUBST(SELINUX_LIBS)
|
||||
AC_SUBST(SELINUX_PC)
|
||||
AC_SUBST(SELINUX_STATIC_LIBS)
|
||||
AC_SUBST(SHARED_LINK)
|
||||
AC_SUBST(SILENT_RULES)
|
||||
AC_SUBST(SNAPSHOTS)
|
||||
AC_SUBST(STATICDIR)
|
||||
@@ -1917,6 +1975,7 @@ AC_SUBST(kerneldir)
|
||||
AC_SUBST(kernelvsn)
|
||||
AC_SUBST(libexecdir)
|
||||
AC_SUBST(missingkernel)
|
||||
AC_SUBST(modulesdir)
|
||||
AC_SUBST(systemdsystemunitdir)
|
||||
AC_SUBST(systemdutildir)
|
||||
AC_SUBST(tmpdir)
|
||||
@@ -2013,3 +2072,6 @@ AS_IF([test -n "$LVM_NEEDS_LIBAIO_WARN"],
|
||||
|
||||
AS_IF([test "$ODIRECT" != "yes"],
|
||||
[AC_MSG_WARN([O_DIRECT disabled: low-memory pvmove may lock up])])
|
||||
|
||||
AS_IF([test "$BUILD_LVMDBUSD" = "yes" && test "$NOTIFYDBUS_SUPPORT" = "no"],
|
||||
[AC_MSG_WARN([Building D-Bus support without D-Bus notifications!])])
|
||||
|
||||
@@ -32,12 +32,12 @@ CFLAGS += $(CPG_CFLAGS) $(EXTRA_EXEC_CFLAGS)
|
||||
LDFLAGS += $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
|
||||
|
||||
cmirrord: $(OBJECTS)
|
||||
@echo " [CC] $@"
|
||||
$(SHOW) " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) \
|
||||
$(LMLIBS) -L$(top_builddir)/libdm -ldevmapper $(LIBS)
|
||||
|
||||
install_cluster: $(TARGETS)
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(usrsbindir)/$(<F)
|
||||
|
||||
install: install_cluster
|
||||
|
||||
@@ -43,14 +43,14 @@ static void usage (FILE *dest)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foreground_mode = 0;
|
||||
struct option longopts[] = {
|
||||
static const struct option _long_options[] = {
|
||||
{ "foreground", no_argument, NULL, 'f' },
|
||||
{ "help" , no_argument, NULL, 'h' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt_long (argc, argv, "fh", longopts, NULL)) != -1) {
|
||||
while ((opt = getopt_long (argc, argv, "fh", _long_options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
foreground_mode = 1;
|
||||
|
||||
@@ -1091,6 +1091,7 @@ static void cpg_message_callback(cpg_handle_t handle, const struct cpg_name *gna
|
||||
(rq->u_rq.request_type != DM_ULOG_RESUME) &&
|
||||
(rq->u_rq.request_type != DM_ULOG_CLEAR_REGION) &&
|
||||
(rq->u_rq.request_type != DM_ULOG_CHECKPOINT_READY)) {
|
||||
/* coverity[suspicious_sizeof] allocation is using varargs data @end */
|
||||
tmp_rq = malloc(DM_ULOG_REQUEST_SIZE);
|
||||
if (!tmp_rq) {
|
||||
/*
|
||||
@@ -1340,6 +1341,7 @@ static void cpg_join_callback(struct clog_cpg *match,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* coverity[suspicious_sizeof] allocation is using varargs data @end */
|
||||
rq = malloc(DM_ULOG_REQUEST_SIZE);
|
||||
if (!rq) {
|
||||
LOG_ERROR("cpg_config_callback: "
|
||||
@@ -1632,7 +1634,7 @@ int create_cluster_cpg(char *uuid, uint64_t luid)
|
||||
|
||||
size = ((strlen(uuid) + 1) > CPG_MAX_NAME_LENGTH) ?
|
||||
CPG_MAX_NAME_LENGTH : (strlen(uuid) + 1);
|
||||
(void) dm_strncpy(new->name.value, uuid, size);
|
||||
dm_strncpy(new->name.value, uuid, size);
|
||||
new->name.length = (uint32_t)size;
|
||||
new->luid = luid;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ struct log_c {
|
||||
uint32_t recoverer;
|
||||
uint64_t recovering_region; /* -1 means not recovering */
|
||||
uint64_t skip_bit_warning; /* used to warn if region skipped */
|
||||
int sync_search;
|
||||
unsigned sync_search;
|
||||
|
||||
int resume_override;
|
||||
|
||||
@@ -220,7 +220,7 @@ static int rw_log(struct log_c *lc, int do_write)
|
||||
if (r < 0)
|
||||
LOG_ERROR("[%s] rw_log: read failure: %s",
|
||||
SHORT_UUID(lc->uuid), strerror(errno));
|
||||
if (r != lc->disk_size)
|
||||
if ((unsigned) r != lc->disk_size)
|
||||
return -EIO; /* Failed disk read */
|
||||
return 0;
|
||||
}
|
||||
@@ -292,13 +292,13 @@ static int write_log(struct log_c *lc)
|
||||
}
|
||||
|
||||
/* FIXME Rewrite this function taking advantage of the udev changes (where in use) to improve its efficiency! */
|
||||
static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_path __attribute__((unused)))
|
||||
static int find_disk_path(char *major_minor_str, char *path_rtn, size_t sz, int *unlink_path __attribute__((unused)))
|
||||
{
|
||||
int r;
|
||||
DIR *dp;
|
||||
struct dirent *dep;
|
||||
struct stat statbuf;
|
||||
int major, minor;
|
||||
unsigned major, minor;
|
||||
|
||||
if (!strstr(major_minor_str, ":")) {
|
||||
r = stat(major_minor_str, &statbuf);
|
||||
@@ -306,7 +306,7 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
|
||||
return -errno;
|
||||
if (!S_ISBLK(statbuf.st_mode))
|
||||
return -EINVAL;
|
||||
sprintf(path_rtn, "%s", major_minor_str);
|
||||
dm_strncpy(path_rtn, major_minor_str, sz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
|
||||
* wanted.
|
||||
*/
|
||||
|
||||
sprintf(path_rtn, "/dev/mapper/%s", dep->d_name);
|
||||
snprintf(path_rtn, sz, "/dev/mapper/%s", dep->d_name);
|
||||
if (stat(path_rtn, &statbuf) < 0) {
|
||||
LOG_DBG("Unable to stat %s", path_rtn);
|
||||
continue;
|
||||
@@ -394,7 +394,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = find_disk_path(argv[0], disk_path, &unlink_path);
|
||||
r = find_disk_path(argv[0], disk_path, sizeof(disk_path), &unlink_path);
|
||||
if (r) {
|
||||
LOG_ERROR("Unable to find path to device %s", argv[0]);
|
||||
goto fail;
|
||||
@@ -452,7 +452,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
|
||||
lc->skip_bit_warning = region_count;
|
||||
lc->disk_fd = -1;
|
||||
lc->log_dev_failed = 0;
|
||||
if (!dm_strncpy(lc->uuid, uuid, DM_UUID_LEN)) {
|
||||
if (!_dm_strncpy(lc->uuid, uuid, DM_UUID_LEN)) {
|
||||
LOG_ERROR("Cannot use too long UUID %s.", uuid);
|
||||
r = -EINVAL;
|
||||
goto fail;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define _LVM_CLOG_FUNCTIONS_H
|
||||
|
||||
#include "libdm/libdevmapper.h"
|
||||
#include "libdm/dm-tools/util.h"
|
||||
#include "libdm/misc/dm-log-userspace.h"
|
||||
#include "cluster.h"
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ static int do_local_work(void *data __attribute__((unused)))
|
||||
RQ_TYPE(u_rq->request_type));
|
||||
break;
|
||||
}
|
||||
/* ELSE, fall through */
|
||||
/* ELSE */ /* fall through */
|
||||
case DM_ULOG_IS_CLEAN:
|
||||
case DM_ULOG_FLUSH:
|
||||
case DM_ULOG_MARK_REGION:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
#include "logging.h"
|
||||
|
||||
const char *__rq_types_off_by_one[] = {
|
||||
const char * const __rq_types_off_by_one[] = {
|
||||
"DM_ULOG_CTR",
|
||||
"DM_ULOG_DTR",
|
||||
"DM_ULOG_PRESUSPEND",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/* SHORT_UUID - print last 8 chars of a string */
|
||||
#define SHORT_UUID(x) (strlen(x) > 8) ? ((x) + (strlen(x) - 8)) : (x)
|
||||
|
||||
extern const char *__rq_types_off_by_one[];
|
||||
extern const char * const __rq_types_off_by_one[];
|
||||
#define RQ_TYPE(x) __rq_types_off_by_one[(x) - 1]
|
||||
|
||||
extern int log_tabbing;
|
||||
|
||||
@@ -70,12 +70,12 @@ plugins.device-mapper: $(LIB_SHARED)
|
||||
CFLAGS_dmeventd.o += $(EXTRA_EXEC_CFLAGS)
|
||||
|
||||
dmeventd: $(LIB_SHARED) dmeventd.o
|
||||
@echo " [CC] $@"
|
||||
$(SHOW) " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) dmeventd.o \
|
||||
-o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(LIBS)
|
||||
|
||||
dmeventd.static: $(LIB_STATIC) dmeventd.o
|
||||
@echo " [CC] $@"
|
||||
$(SHOW) " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static dmeventd.o \
|
||||
-o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(LIBS) $(STATIC_LIBS)
|
||||
|
||||
@@ -84,27 +84,27 @@ ifeq ("@PKGCONFIG@", "yes")
|
||||
endif
|
||||
|
||||
install_include: $(srcdir)/libdevmapper-event.h
|
||||
@echo " [INSTALL] $(<F)"
|
||||
$(SHOW) " [INSTALL] $(<F)"
|
||||
$(Q) $(INSTALL_DATA) -D $< $(includedir)/$(<F)
|
||||
|
||||
install_pkgconfig: libdevmapper-event.pc
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_DATA) -D $< $(pkgconfigdir)/devmapper-event.pc
|
||||
|
||||
install_lib_dynamic: install_lib_shared
|
||||
|
||||
install_lib_static: $(LIB_STATIC)
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_DATA) -D $< $(usrlibdir)/$(<F)
|
||||
|
||||
install_lib: $(INSTALL_LIB_TARGETS)
|
||||
|
||||
install_dmeventd_dynamic: dmeventd
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
|
||||
|
||||
install_dmeventd_static: dmeventd.static
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
|
||||
|
||||
install_dmeventd: $(INSTALL_DMEVENTD_TARGETS)
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
#include "libdm/misc/dm-logging.h"
|
||||
#include "base/memory/zalloc.h"
|
||||
|
||||
#include "libdaemon/server/daemon-stray.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <signal.h>
|
||||
#include <arpa/inet.h> /* for htonl, ntohl */
|
||||
@@ -92,12 +92,10 @@ static const size_t THREAD_STACK_SIZE = 300 * 1024;
|
||||
/* Default idle exit timeout 1 hour (in seconds) */
|
||||
static const time_t DMEVENTD_IDLE_EXIT_TIMEOUT = 60 * 60;
|
||||
|
||||
static int _debug_level = 0;
|
||||
static int _use_syslog = 1;
|
||||
static int _systemd_activation = 0;
|
||||
static int _foreground = 0;
|
||||
static int _restart = 0;
|
||||
static time_t _idle_since = 0;
|
||||
static const char *_exit_on = DEFAULT_DMEVENTD_EXIT_ON_PATH;
|
||||
static char **_initial_registrations = 0;
|
||||
|
||||
/* FIXME Make configurable at runtime */
|
||||
@@ -202,9 +200,9 @@ struct message_data {
|
||||
char *dso_name; /* Name of DSO. */
|
||||
char *device_uuid; /* Mapped device path. */
|
||||
char *events_str; /* Events string as fetched from message. */
|
||||
enum dm_event_mask events_field; /* Events bitfield. */
|
||||
char *timeout_str;
|
||||
unsigned events_field; /* Events bitfield. */
|
||||
uint32_t timeout_secs;
|
||||
char *timeout_str;
|
||||
struct dm_event_daemon_message *msg; /* Pointer to message buffer. */
|
||||
};
|
||||
|
||||
@@ -723,12 +721,18 @@ static int _get_status(struct message_data *message_data)
|
||||
static int _get_parameters(struct message_data *message_data) {
|
||||
struct dm_event_daemon_message *msg = message_data->msg;
|
||||
int size;
|
||||
char idle_buf[32] = "";
|
||||
|
||||
if (_idle_since)
|
||||
(void)dm_snprintf(idle_buf, sizeof(idle_buf), " idle=%lu", (long unsigned) (time(NULL) - _idle_since));
|
||||
|
||||
free(msg->data);
|
||||
if ((size = dm_asprintf(&msg->data, "%s pid=%d daemon=%s exec_method=%s",
|
||||
if ((size = dm_asprintf(&msg->data, "%s pid=%d daemon=%s exec_method=%s exit_on=\"%s\"%s",
|
||||
message_data->id, getpid(),
|
||||
_foreground ? "no" : "yes",
|
||||
_systemd_activation ? "systemd" : "direct")) < 0) {
|
||||
_systemd_activation ? "systemd" : "direct",
|
||||
_exit_on,
|
||||
idle_buf)) < 0) {
|
||||
stack;
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -998,6 +1002,8 @@ static void _monitor_unregister(void *arg)
|
||||
_lock_mutex();
|
||||
thread->status = DM_THREAD_DONE; /* Last access to thread memory! */
|
||||
_unlock_mutex();
|
||||
if (_exit_now) /* Exit is already in-progress, wake-up sleeping select() */
|
||||
kill(getpid(), SIGINT);
|
||||
}
|
||||
|
||||
/* Device monitoring thread. */
|
||||
@@ -1044,9 +1050,9 @@ static void *_monitor_thread(void *arg)
|
||||
_unlock_mutex();
|
||||
|
||||
_do_process_event(thread);
|
||||
thread->current_events = 0; /* Current events processed */
|
||||
|
||||
_lock_mutex();
|
||||
thread->current_events = 0; /* Current events processed */
|
||||
thread->processing = 0;
|
||||
|
||||
/*
|
||||
@@ -1162,6 +1168,36 @@ static int _unregister_for_event(struct message_data *message_data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void _unregister_all_threads(void)
|
||||
{
|
||||
struct thread_status *thread, *tmp;
|
||||
|
||||
_lock_mutex();
|
||||
|
||||
dm_list_iterate_items_safe(thread, tmp, &_thread_registry)
|
||||
_update_events(thread, 0);
|
||||
|
||||
_unlock_mutex();
|
||||
}
|
||||
|
||||
static void _wait_for_new_pid(void)
|
||||
{
|
||||
unsigned long st_ino = 0;
|
||||
struct stat st;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 400000; ++i) {
|
||||
if (lstat(DMEVENTD_PIDFILE, &st) == 0) {
|
||||
if (!st_ino)
|
||||
st_ino = st.st_ino;
|
||||
else if (st_ino != st.st_ino)
|
||||
break; /* different pidfile */
|
||||
} else if (errno == ENOENT)
|
||||
break; /* pidfile is removed */
|
||||
usleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Register for an event.
|
||||
*
|
||||
@@ -1405,7 +1441,8 @@ static int _open_fifo(const char *path)
|
||||
} else if (!S_ISFIFO(st.st_mode) || st.st_uid ||
|
||||
(st.st_mode & (S_IEXEC | S_IRWXG | S_IRWXO))) {
|
||||
log_warn("WARNING: %s has wrong attributes: Replacing.", path);
|
||||
if (unlink(path)) {
|
||||
/* coverity[toctou] don't care, path is going to be recreated */
|
||||
if (unlink(path) && (errno != ENOENT)) {
|
||||
log_sys_error("unlink", path);
|
||||
return -1;
|
||||
}
|
||||
@@ -1413,6 +1450,7 @@ static int _open_fifo(const char *path)
|
||||
|
||||
/* Create fifo. */
|
||||
(void) dm_prepare_selinux_context(path, S_IFIFO);
|
||||
/* coverity[toctou] revalidating things again */
|
||||
if ((mkfifo(path, 0600) == -1) && errno != EEXIST) {
|
||||
log_sys_error("mkfifo", path);
|
||||
(void) dm_prepare_selinux_context(NULL, 0);
|
||||
@@ -1641,7 +1679,7 @@ static int _do_process_request(struct dm_event_daemon_message *msg)
|
||||
} else
|
||||
ret = _handle_request(msg, &message_data);
|
||||
|
||||
msg->cmd = ret;
|
||||
msg->cmd = (uint32_t)ret;
|
||||
if (!msg->data)
|
||||
msg->size = dm_asprintf(&(msg->data), "%s %s", message_data.id, strerror(-ret));
|
||||
|
||||
@@ -1678,9 +1716,9 @@ static void _process_request(struct dm_event_fifos *fifos)
|
||||
free(msg.data);
|
||||
|
||||
if (cmd == DM_EVENT_CMD_DIE) {
|
||||
if (unlink(DMEVENTD_PIDFILE))
|
||||
log_sys_error("unlink", DMEVENTD_PIDFILE);
|
||||
_exit(0);
|
||||
_unregister_all_threads();
|
||||
_exit_now = DM_SCHEDULED_EXIT;
|
||||
log_info("dmeventd exiting for restart.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1727,7 +1765,7 @@ static void _cleanup_unused_threads(void)
|
||||
DEBUGLOG("Destroying Thr %x.", (int)thread->thread);
|
||||
|
||||
if (pthread_join(thread->thread, NULL))
|
||||
log_sys_error("pthread_join", "");
|
||||
log_sys_debug("pthread_join", "");
|
||||
|
||||
_free_thread_status(thread);
|
||||
_lock_mutex();
|
||||
@@ -1758,7 +1796,7 @@ static void _init_thread_signals(void)
|
||||
sigdelset(&my_sigset, SIGQUIT);
|
||||
|
||||
if (pthread_sigmask(SIG_BLOCK, &my_sigset, NULL))
|
||||
log_sys_error("pthread_sigmask", "SIG_BLOCK");
|
||||
log_sys_debug("pthread_sigmask", "SIG_BLOCK");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1770,7 +1808,8 @@ static void _init_thread_signals(void)
|
||||
*/
|
||||
static void _exit_handler(int sig __attribute__((unused)))
|
||||
{
|
||||
_exit_now = DM_SIGNALED_EXIT;
|
||||
if (!_exit_now)
|
||||
_exit_now = DM_SIGNALED_EXIT;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
@@ -1786,7 +1825,7 @@ static int _set_oom_adj(const char *oom_adj_path, int val)
|
||||
fprintf(fp, "%i", val);
|
||||
|
||||
if (dm_fclose(fp))
|
||||
log_sys_error("fclose", oom_adj_path);
|
||||
log_sys_debug("fclose", oom_adj_path);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1800,11 +1839,11 @@ static int _protect_against_oom_killer(void)
|
||||
|
||||
if (stat(OOM_ADJ_FILE, &st) == -1) {
|
||||
if (errno != ENOENT)
|
||||
log_sys_error("stat", OOM_ADJ_FILE);
|
||||
log_sys_debug("stat", OOM_ADJ_FILE);
|
||||
|
||||
/* Try old oom_adj interface as a fallback */
|
||||
if (stat(OOM_ADJ_FILE_OLD, &st) == -1) {
|
||||
log_sys_error("stat", OOM_ADJ_FILE_OLD);
|
||||
log_sys_debug("stat", OOM_ADJ_FILE_OLD);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1892,26 +1931,30 @@ out:
|
||||
|
||||
static void _remove_files_on_exit(void)
|
||||
{
|
||||
if (unlink(DMEVENTD_PIDFILE))
|
||||
log_sys_error("unlink", DMEVENTD_PIDFILE);
|
||||
if (unlink(DMEVENTD_PIDFILE) && (errno != ENOENT))
|
||||
log_sys_debug("unlink", DMEVENTD_PIDFILE);
|
||||
|
||||
if (!_systemd_activation) {
|
||||
if (unlink(DM_EVENT_FIFO_CLIENT))
|
||||
log_sys_error("unlink", DM_EVENT_FIFO_CLIENT);
|
||||
if (unlink(DM_EVENT_FIFO_CLIENT) && (errno != ENOENT))
|
||||
log_sys_debug("unlink", DM_EVENT_FIFO_CLIENT);
|
||||
|
||||
if (unlink(DM_EVENT_FIFO_SERVER))
|
||||
log_sys_error("unlink", DM_EVENT_FIFO_SERVER);
|
||||
if (unlink(DM_EVENT_FIFO_SERVER) && (errno != ENOENT))
|
||||
log_sys_debug("unlink", DM_EVENT_FIFO_SERVER);
|
||||
}
|
||||
}
|
||||
|
||||
static void _daemonize(void)
|
||||
{
|
||||
int child_status;
|
||||
int fd;
|
||||
int child_status, null_fd;
|
||||
pid_t pid;
|
||||
struct rlimit rlim;
|
||||
struct timeval tval;
|
||||
sigset_t my_sigset;
|
||||
struct custom_fds custom_fds = {
|
||||
/* Do not close fds preloaded by systemd! */
|
||||
.out = (_systemd_activation) ? SD_FD_FIFO_SERVER : -1,
|
||||
.err = -1,
|
||||
.report = (_systemd_activation) ? SD_FD_FIFO_CLIENT : -1,
|
||||
};
|
||||
|
||||
sigemptyset(&my_sigset);
|
||||
if (sigprocmask(SIG_SETMASK, &my_sigset, NULL) < 0) {
|
||||
@@ -1955,34 +1998,28 @@ static void _daemonize(void)
|
||||
if (chdir("/"))
|
||||
exit(EXIT_CHDIR_FAILURE);
|
||||
|
||||
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
|
||||
fd = 256; /* just have to guess */
|
||||
else
|
||||
fd = rlim.rlim_cur;
|
||||
daemon_close_stray_fds("dmeventd", 0, -1, &custom_fds);
|
||||
|
||||
for (--fd; fd >= 0; fd--) {
|
||||
#ifdef __linux__
|
||||
/* Do not close fds preloaded by systemd! */
|
||||
if (_systemd_activation &&
|
||||
(fd == SD_FD_FIFO_SERVER || fd == SD_FD_FIFO_CLIENT))
|
||||
continue;
|
||||
#endif
|
||||
(void) close(fd);
|
||||
}
|
||||
|
||||
/* coverity[leaked_handle] dont't care */
|
||||
if ((open("/dev/null", O_RDONLY) < 0) ||
|
||||
(open("/dev/null", O_WRONLY) < 0) ||
|
||||
(open("/dev/null", O_WRONLY) < 0))
|
||||
if ((null_fd = open("/dev/null", O_RDWR)) < 0)
|
||||
exit(EXIT_DESC_OPEN_FAILURE);
|
||||
|
||||
if ((dup2(null_fd, STDIN_FILENO) == -1) ||
|
||||
(dup2(null_fd, STDOUT_FILENO) == -1) ||
|
||||
(dup2(null_fd, STDERR_FILENO) == -1))
|
||||
exit(EXIT_DESC_OPEN_FAILURE);
|
||||
|
||||
if ((null_fd > STDERR_FILENO) && close(null_fd))
|
||||
exit(EXIT_DESC_CLOSE_FAILURE);
|
||||
|
||||
setsid();
|
||||
|
||||
/* coverity[leaked_handle] 'null_fd' handle is not leaking */
|
||||
}
|
||||
|
||||
static int _reinstate_registrations(struct dm_event_fifos *fifos)
|
||||
{
|
||||
static const char _failed_parsing_msg[] = "Failed to parse existing event registration.\n";
|
||||
static const char *_delim = " ";
|
||||
static const char _delim[] = " ";
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
char *endp, *dso_name, *dev_name, *mask, *timeout;
|
||||
unsigned long mask_value, timeout_value;
|
||||
@@ -2032,28 +2069,94 @@ static int _reinstate_registrations(struct dm_event_fifos *fifos)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _restart_dmeventd(void)
|
||||
static int _info_dmeventd(const char *name, struct dm_event_fifos *fifos)
|
||||
{
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
int i, count = 0;
|
||||
char *line;
|
||||
int version;
|
||||
int ret = 0;
|
||||
|
||||
if (!dm_daemon_is_running(DMEVENTD_PIDFILE)) {
|
||||
fprintf(stderr, "No running dmeventd instance for status query.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get the list of registrations from the running daemon. */
|
||||
if (!init_fifos(fifos)) {
|
||||
fprintf(stderr, "Could not initiate communication with existing dmeventd.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!dm_event_get_version(fifos, &version)) {
|
||||
fprintf(stderr, "Could not communicate with existing dmeventd.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (version < 1) {
|
||||
fprintf(stderr, "The running dmeventd instance is too old.\n"
|
||||
"Protocol version %d (required: 1). Action cancelled.\n", version);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0)) {
|
||||
fprintf(stderr, "Failed to acquire status from existing dmeventd.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
line = strchr(msg.data, ' ') + 1;
|
||||
for (i = 0; msg.data[i]; ++i)
|
||||
if (msg.data[i] == ';') {
|
||||
msg.data[i] = 0;
|
||||
if (!count)
|
||||
printf("%s is monitoring:\n", name);
|
||||
printf("%s\n", line);
|
||||
line = msg.data + i + 1;
|
||||
++count;
|
||||
}
|
||||
|
||||
free(msg.data);
|
||||
|
||||
if (!count)
|
||||
printf("%s does not monitor any device.\n", name);
|
||||
|
||||
if (version >= 2) {
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_GET_PARAMETERS, "-", "-", 0, 0)) {
|
||||
fprintf(stderr, "Failed to acquire parameters from existing dmeventd.\n");
|
||||
goto out;
|
||||
}
|
||||
printf("%s internal status: %s\n", name, msg.data);
|
||||
free(msg.data);
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
out:
|
||||
fini_fifos(fifos);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return 0 - fail, 1 - success, 2 - continue */
|
||||
static int _restart_dmeventd(struct dm_event_fifos *fifos)
|
||||
{
|
||||
struct dm_event_fifos fifos = {
|
||||
.client = -1,
|
||||
.server = -1,
|
||||
/* FIXME Make these either configurable or depend directly on dmeventd_path */
|
||||
.client_path = DM_EVENT_FIFO_CLIENT,
|
||||
.server_path = DM_EVENT_FIFO_SERVER
|
||||
};
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
int i, count = 0;
|
||||
char *message;
|
||||
int version;
|
||||
const char *e;
|
||||
|
||||
/* Get the list of registrations from the running daemon. */
|
||||
if (!init_fifos(&fifos)) {
|
||||
fprintf(stderr, "WARNING: Could not initiate communication with existing dmeventd.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
if (!dm_daemon_is_running(DMEVENTD_PIDFILE)) {
|
||||
fprintf(stderr, "WARNING: Could not find running dmeventd associated with pid file %s.\n", DMEVENTD_PIDFILE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!dm_event_get_version(&fifos, &version)) {
|
||||
/* Get the list of registrations from the running daemon. */
|
||||
if (!init_fifos(fifos)) {
|
||||
fprintf(stderr, "WARNING: Could not initiate communication with existing dmeventd.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!dm_event_get_version(fifos, &version)) {
|
||||
fprintf(stderr, "WARNING: Could not communicate with existing dmeventd.\n");
|
||||
goto bad;
|
||||
}
|
||||
@@ -2065,7 +2168,7 @@ static void _restart_dmeventd(void)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0))
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0))
|
||||
goto bad;
|
||||
|
||||
message = strchr(msg.data, ' ') + 1;
|
||||
@@ -2089,7 +2192,7 @@ static void _restart_dmeventd(void)
|
||||
}
|
||||
|
||||
if (version >= 2) {
|
||||
if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_GET_PARAMETERS, "-", "-", 0, 0)) {
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_GET_PARAMETERS, "-", "-", 0, 0)) {
|
||||
fprintf(stderr, "Failed to acquire parameters from old dmeventd.\n");
|
||||
goto bad;
|
||||
}
|
||||
@@ -2109,7 +2212,7 @@ static void _restart_dmeventd(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_DIE, "-", "-", 0, 0)) {
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_DIE, "-", "-", 0, 0)) {
|
||||
fprintf(stderr, "Old dmeventd refused to die.\n");
|
||||
goto bad;
|
||||
}
|
||||
@@ -2118,43 +2221,41 @@ static void _restart_dmeventd(void)
|
||||
((e = getenv(SD_ACTIVATION_ENV_VAR_NAME)) && strcmp(e, "1")))
|
||||
_systemd_activation = 1;
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
if ((access(DMEVENTD_PIDFILE, F_OK) == -1) && (errno == ENOENT))
|
||||
break;
|
||||
usleep(10);
|
||||
}
|
||||
fini_fifos(fifos);
|
||||
|
||||
if (!_systemd_activation) {
|
||||
fini_fifos(&fifos);
|
||||
return;
|
||||
}
|
||||
/* Give a few seconds dmeventd to finish */
|
||||
_wait_for_new_pid();
|
||||
|
||||
if (!_systemd_activation)
|
||||
return 2; // continue with dmeventd start up
|
||||
|
||||
/* Reopen fifos. */
|
||||
fini_fifos(&fifos);
|
||||
if (!init_fifos(&fifos)) {
|
||||
if (!init_fifos(fifos)) {
|
||||
fprintf(stderr, "Could not initiate communication with new instance of dmeventd.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_reinstate_registrations(&fifos)) {
|
||||
if (!_reinstate_registrations(fifos)) {
|
||||
fprintf(stderr, "Failed to reinstate monitoring with new instance of dmeventd.\n");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
fini_fifos(&fifos);
|
||||
exit(EXIT_SUCCESS);
|
||||
fini_fifos(fifos);
|
||||
return 1;
|
||||
bad:
|
||||
fini_fifos(&fifos);
|
||||
exit(EXIT_FAILURE);
|
||||
fini_fifos(fifos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _usage(char *prog, FILE *file)
|
||||
{
|
||||
fprintf(file, "Usage:\n"
|
||||
"%s [-d [-d [-d]]] [-f] [-h] [-l] [-R] [-V] [-?]\n\n"
|
||||
"%s [-d [-d [-d]]] [-e path] [-f] [-h] [i] [-l] [-R] [-V] [-?]\n\n"
|
||||
" -d Log debug messages to syslog (-d, -dd, -ddd)\n"
|
||||
" -e Select a file path checked on exit\n"
|
||||
" -f Don't fork, run in the foreground\n"
|
||||
" -h Show this help information\n"
|
||||
" -i Query running instance of dmeventd for info\n"
|
||||
" -l Log to stdout,stderr instead of syslog\n"
|
||||
" -? Show this help information on stderr\n"
|
||||
" -R Restart dmeventd\n"
|
||||
@@ -2164,6 +2265,10 @@ static void _usage(char *prog, FILE *file)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
signed char opt;
|
||||
int debug_level = 0;
|
||||
int info = 0;
|
||||
int restart = 0;
|
||||
int use_syslog = 1;
|
||||
struct dm_event_fifos fifos = {
|
||||
.client = -1,
|
||||
.server = -1,
|
||||
@@ -2171,39 +2276,58 @@ int main(int argc, char *argv[])
|
||||
.server_path = DM_EVENT_FIFO_SERVER
|
||||
};
|
||||
time_t now, idle_exit_timeout = DMEVENTD_IDLE_EXIT_TIMEOUT;
|
||||
opterr = 0;
|
||||
optind = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "?fhVdlR")) != EOF) {
|
||||
optopt = optind = opterr = 0;
|
||||
optarg = (char*) "";
|
||||
while ((opt = getopt(argc, argv, ":?e:fhiVdlR")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
_usage(argv[0], stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
case '?':
|
||||
_usage(argv[0], stderr);
|
||||
exit(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
case 'i':
|
||||
info++;
|
||||
break;
|
||||
case 'R':
|
||||
_restart++;
|
||||
restart++;
|
||||
break;
|
||||
case 'e':
|
||||
if (strchr(optarg, '"')) {
|
||||
fprintf(stderr, "dmeventd: option -e does not accept path \"%s\" with '\"' character.\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
_exit_on=optarg;
|
||||
break;
|
||||
case 'f':
|
||||
_foreground++;
|
||||
break;
|
||||
case 'd':
|
||||
_debug_level++;
|
||||
debug_level++;
|
||||
break;
|
||||
case 'l':
|
||||
_use_syslog = 0;
|
||||
use_syslog = 0;
|
||||
break;
|
||||
case 'V':
|
||||
printf("dmeventd version: %s\n", DM_LIB_VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
case ':':
|
||||
fprintf(stderr, "dmeventd: option -%c requires an argument.\n", optopt);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_foreground && !_use_syslog) {
|
||||
printf("WARNING: Ignoring logging to stdout, needs options -f\n");
|
||||
_use_syslog = 1;
|
||||
if (info) {
|
||||
_foreground = 1;
|
||||
use_syslog = 0;
|
||||
}
|
||||
|
||||
if (!_foreground && !use_syslog) {
|
||||
printf("WARNING: Ignoring logging to stdout, needs options -f\n");
|
||||
use_syslog = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Switch to C locale to avoid reading large locale-archive file
|
||||
* used by some glibc (on some distributions it takes over 100MB).
|
||||
@@ -2212,21 +2336,29 @@ int main(int argc, char *argv[])
|
||||
if (setenv("LC_ALL", "C", 1))
|
||||
perror("Cannot set LC_ALL to C");
|
||||
|
||||
if (_restart)
|
||||
_restart_dmeventd();
|
||||
if (info)
|
||||
return _info_dmeventd(argv[0], &fifos) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
||||
#ifdef __linux__
|
||||
_systemd_activation = _systemd_handover(&fifos);
|
||||
#endif
|
||||
|
||||
dm_log_with_errno_init(_libdm_log);
|
||||
|
||||
if (restart) {
|
||||
dm_event_log_set(debug_level, 0);
|
||||
|
||||
if ((restart = _restart_dmeventd(&fifos)) < 2)
|
||||
return restart ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!_foreground)
|
||||
_daemonize();
|
||||
|
||||
if (_use_syslog)
|
||||
if (use_syslog)
|
||||
openlog("dmeventd", LOG_PID, LOG_DAEMON);
|
||||
|
||||
dm_event_log_set(_debug_level, _use_syslog);
|
||||
dm_log_with_errno_init(_libdm_log);
|
||||
dm_event_log_set(debug_level, use_syslog);
|
||||
|
||||
(void) dm_prepare_selinux_context(DMEVENTD_PIDFILE, S_IFREG);
|
||||
if (dm_create_lockfile(DMEVENTD_PIDFILE) == 0)
|
||||
@@ -2287,15 +2419,28 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (_exit_now == DM_SIGNALED_EXIT) {
|
||||
_exit_now = DM_SCHEDULED_EXIT;
|
||||
/*
|
||||
* When '_exit_now' is set, signal has been received,
|
||||
* but can not simply exit unless all
|
||||
* threads are done processing.
|
||||
*/
|
||||
log_info("dmeventd received break, scheduling exit.");
|
||||
}
|
||||
} else
|
||||
switch (_exit_now) {
|
||||
case DM_SIGNALED_EXIT:
|
||||
_exit_now = DM_SCHEDULED_EXIT;
|
||||
/*
|
||||
* When '_exit_now' is set, signal has been received,
|
||||
* but can not simply exit unless all
|
||||
* threads are done processing.
|
||||
*/
|
||||
log_info("dmeventd received break, scheduling exit.");
|
||||
/* fall through */
|
||||
case DM_SCHEDULED_EXIT:
|
||||
/* While exit is scheduled, check for exit_on file */
|
||||
DEBUGLOG("Checking exit on file \"%s\".", _exit_on);
|
||||
if (_exit_on[0] && (access(_exit_on, F_OK) == 0)) {
|
||||
log_info("dmeventd detected exit on file %s, unregistering all monitored devices.",
|
||||
_exit_on);
|
||||
_unregister_all_threads();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
_process_request(&fifos);
|
||||
_cleanup_unused_threads();
|
||||
}
|
||||
@@ -2305,11 +2450,11 @@ int main(int argc, char *argv[])
|
||||
log_notice("dmeventd shutting down.");
|
||||
|
||||
if (fifos.client >= 0 && close(fifos.client))
|
||||
log_sys_error("client close", fifos.client_path);
|
||||
log_sys_debug("client close", fifos.client_path);
|
||||
if (fifos.server >= 0 && close(fifos.server))
|
||||
log_sys_error("server close", fifos.server_path);
|
||||
log_sys_debug("server close", fifos.server_path);
|
||||
|
||||
if (_use_syslog)
|
||||
if (use_syslog)
|
||||
closelog();
|
||||
|
||||
_exit_dm_lib();
|
||||
|
||||
@@ -68,7 +68,7 @@ struct dm_event_fifos {
|
||||
int daemon_talk(struct dm_event_fifos *fifos,
|
||||
struct dm_event_daemon_message *msg, int cmd,
|
||||
const char *dso_name, const char *dev_name,
|
||||
enum dm_event_mask evmask, uint32_t timeout);
|
||||
unsigned evmask, uint32_t timeout);
|
||||
int init_fifos(struct dm_event_fifos *fifos);
|
||||
void fini_fifos(struct dm_event_fifos *fifos);
|
||||
int dm_event_get_version(struct dm_event_fifos *fifos, int *version);
|
||||
|
||||
@@ -352,7 +352,7 @@ static int _daemon_write(struct dm_event_fifos *fifos,
|
||||
int daemon_talk(struct dm_event_fifos *fifos,
|
||||
struct dm_event_daemon_message *msg, int cmd,
|
||||
const char *dso_name, const char *dev_name,
|
||||
enum dm_event_mask evmask, uint32_t timeout)
|
||||
unsigned evmask, uint32_t timeout)
|
||||
{
|
||||
int msg_size;
|
||||
memset(msg, 0, sizeof(*msg));
|
||||
@@ -400,25 +400,16 @@ int daemon_talk(struct dm_event_fifos *fifos,
|
||||
return (int32_t) msg->cmd;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* start_daemon
|
||||
* Check for usable client fifo file
|
||||
*
|
||||
* This function forks off a process (dmeventd) that will handle
|
||||
* the events. I am currently test opening one of the fifos to
|
||||
* ensure that the daemon is running and listening... I thought
|
||||
* this would be less expensive than fork/exec'ing every time.
|
||||
* Perhaps there is an even quicker/better way (no, checking the
|
||||
* lock file is _not_ a better way).
|
||||
*
|
||||
* Returns: 1 on success, 0 otherwise
|
||||
* Returns: 2 cliant path does not exists, dmeventd should be restarted
|
||||
* 1 on success, 0 otherwise
|
||||
*/
|
||||
static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
static int _check_for_usable_fifos(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
{
|
||||
int pid, ret = 0;
|
||||
int status;
|
||||
struct stat statbuf;
|
||||
char default_dmeventd_path[] = DMEVENTD_PATH;
|
||||
char *args[] = { dmeventd_path ? : default_dmeventd_path, NULL };
|
||||
|
||||
/*
|
||||
* FIXME Explicitly verify the code's requirement that client_path is secure:
|
||||
@@ -429,7 +420,7 @@ static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
if ((lstat(fifos->client_path, &statbuf) < 0)) {
|
||||
if (errno == ENOENT)
|
||||
/* Jump ahead if fifo does not already exist. */
|
||||
goto start_server;
|
||||
return 2;
|
||||
else {
|
||||
log_sys_error("stat", fifos->client_path);
|
||||
return 0;
|
||||
@@ -455,12 +446,14 @@ static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
log_error("%s is no longer a secure root-owned fifo with mode 0600.", fifos->client_path);
|
||||
if (close(fifos->client))
|
||||
log_sys_debug("close", fifos->client_path);
|
||||
fifos->client = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* server is running and listening */
|
||||
if (close(fifos->client))
|
||||
log_sys_debug("close", fifos->client_path);
|
||||
fifos->client = -1;
|
||||
return 1;
|
||||
}
|
||||
if (errno != ENXIO && errno != ENOENT) {
|
||||
@@ -469,9 +462,36 @@ static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
return 0;
|
||||
}
|
||||
|
||||
start_server:
|
||||
/* server is not running */
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* start_daemon
|
||||
*
|
||||
* This function forks off a process (dmeventd) that will handle
|
||||
* the events. I am currently test opening one of the fifos to
|
||||
* ensure that the daemon is running and listening... I thought
|
||||
* this would be less expensive than fork/exec'ing every time.
|
||||
* Perhaps there is an even quicker/better way (no, checking the
|
||||
* lock file is _not_ a better way).
|
||||
*
|
||||
* Returns: 1 on success, 0 otherwise
|
||||
*/
|
||||
static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
{
|
||||
struct stat statbuf;
|
||||
char default_dmeventd_path[] = DMEVENTD_PATH;
|
||||
char *args[] = { dmeventd_path ? : default_dmeventd_path, NULL };
|
||||
int pid, ret = 0;
|
||||
int status;
|
||||
|
||||
switch (_check_for_usable_fifos(dmeventd_path, fifos)) {
|
||||
case 0: return_0;
|
||||
case 1: return 1; /* Already running dmeventd */
|
||||
}
|
||||
|
||||
/* server is not running */
|
||||
if ((args[0][0] == '/') && stat(args[0], &statbuf)) {
|
||||
log_sys_error("stat", args[0]);
|
||||
return 0;
|
||||
@@ -492,8 +512,17 @@ start_server:
|
||||
strerror(errno));
|
||||
else if (WEXITSTATUS(status))
|
||||
log_error("Unable to start dmeventd.");
|
||||
else
|
||||
ret = 1;
|
||||
else {
|
||||
/* Loop here till forked dmeventd is serving fifos */
|
||||
for (ret = 100; ret > 0; --ret)
|
||||
switch (_check_for_usable_fifos(dmeventd_path, fifos)) {
|
||||
case 0: return_0;
|
||||
case 1: return 1;
|
||||
case 2: usleep(1000); break;
|
||||
}
|
||||
/* ret == 0 */
|
||||
log_error("Dmeventd is not serving fifos.");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -513,7 +542,7 @@ int init_fifos(struct dm_event_fifos *fifos)
|
||||
/* Lock out anyone else trying to do communication with the daemon. */
|
||||
if (flock(fifos->server, LOCK_EX) < 0) {
|
||||
log_sys_error("flock", fifos->server_path);
|
||||
goto bad;
|
||||
goto bad_no_unlock;
|
||||
}
|
||||
|
||||
/* if ((fifos->client = open(fifos->client_path, O_WRONLY | O_NONBLOCK)) < 0) {*/
|
||||
@@ -524,6 +553,9 @@ int init_fifos(struct dm_event_fifos *fifos)
|
||||
|
||||
return 1;
|
||||
bad:
|
||||
if (flock(fifos->server, LOCK_UN))
|
||||
log_sys_debug("flock unlock", fifos->server_path);
|
||||
bad_no_unlock:
|
||||
if (close(fifos->server))
|
||||
log_sys_debug("close", fifos->server_path);
|
||||
fifos->server = -1;
|
||||
@@ -552,6 +584,8 @@ void fini_fifos(struct dm_event_fifos *fifos)
|
||||
if (close(fifos->server))
|
||||
log_sys_debug("close", fifos->server_path);
|
||||
}
|
||||
|
||||
fifos->client = fifos->server = -1;
|
||||
}
|
||||
|
||||
/* Get uuid of a device */
|
||||
@@ -720,7 +754,7 @@ static char *_fetch_string(char **src, const int delimiter)
|
||||
|
||||
/* Parse a device message from the daemon. */
|
||||
static int _parse_message(struct dm_event_daemon_message *msg, char **dso_name,
|
||||
char **uuid, enum dm_event_mask *evmask)
|
||||
char **uuid, unsigned *evmask)
|
||||
{
|
||||
char *id;
|
||||
char *p = msg->data;
|
||||
@@ -745,7 +779,7 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
|
||||
int ret = 0;
|
||||
const char *uuid = NULL;
|
||||
char *reply_dso = NULL, *reply_uuid = NULL;
|
||||
enum dm_event_mask reply_mask = 0;
|
||||
unsigned reply_mask = 0;
|
||||
struct dm_task *dmt = NULL;
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
struct dm_info info;
|
||||
@@ -844,6 +878,7 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
|
||||
int dm_event_get_version(struct dm_event_fifos *fifos, int *version) {
|
||||
char *p;
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
int ret = 0;
|
||||
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0))
|
||||
return 0;
|
||||
@@ -851,13 +886,17 @@ int dm_event_get_version(struct dm_event_fifos *fifos, int *version) {
|
||||
*version = 0;
|
||||
|
||||
if (!p || !(p = strchr(p, ' '))) /* Message ID */
|
||||
return 0;
|
||||
goto out;
|
||||
if (!(p = strchr(p + 1, ' '))) /* HELLO */
|
||||
return 0;
|
||||
goto out;
|
||||
if ((p = strchr(p + 1, ' '))) /* HELLO, once more */
|
||||
*version = atoi(p);
|
||||
|
||||
return 1;
|
||||
ret = 1;
|
||||
out:
|
||||
free(msg.data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void dm_event_log_set(int debug_log_level, int use_syslog)
|
||||
@@ -872,11 +911,11 @@ void dm_event_log(const char *subsys, int level, const char *file,
|
||||
{
|
||||
static int _abort_on_internal_errors = -1;
|
||||
static pthread_mutex_t _log_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static time_t start = 0;
|
||||
static long long _start = 0;
|
||||
const char *indent = "";
|
||||
FILE *stream = log_stderr(level) ? stderr : stdout;
|
||||
int prio;
|
||||
time_t now;
|
||||
long long now, now_nsec;
|
||||
int log_with_debug = 0;
|
||||
|
||||
if (subsys[0] == '#') {
|
||||
@@ -923,17 +962,28 @@ void dm_event_log(const char *subsys, int level, const char *file,
|
||||
if (_use_syslog) {
|
||||
vsyslog(prio, format, ap);
|
||||
} else {
|
||||
now = time(NULL);
|
||||
if (!start)
|
||||
start = now;
|
||||
now -= start;
|
||||
if (_debug_level)
|
||||
fprintf(stream, "[%2lld:%02lld] %8x:%-6s%s",
|
||||
(long long)now / 60, (long long)now % 60,
|
||||
if (_debug_level) {
|
||||
#define _NSEC_PER_SEC (1000000000LL)
|
||||
#ifdef HAVE_REALTIME
|
||||
struct timespec mono_time = { 0 };
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &mono_time) == 0)
|
||||
now = mono_time.tv_sec * _NSEC_PER_SEC + mono_time.tv_nsec;
|
||||
else
|
||||
#endif
|
||||
now = time(NULL) * _NSEC_PER_SEC;
|
||||
|
||||
if (!_start)
|
||||
_start = now;
|
||||
now -= _start;
|
||||
now_nsec = now %_NSEC_PER_SEC;
|
||||
now /= _NSEC_PER_SEC;
|
||||
fprintf(stream, "[%2lld:%02lld.%06lld] %8x:%-6s%s",
|
||||
now / 60, now % 60, now_nsec / 1000,
|
||||
// TODO: Maybe use shorter ID
|
||||
// ((int)(pthread_self()) >> 6) & 0xffff,
|
||||
(int)pthread_self(), subsys,
|
||||
(_debug_level > 3) ? "" : indent);
|
||||
}
|
||||
if (_debug_level > 3)
|
||||
fprintf(stream, "%28s:%4d %s", file, line, indent);
|
||||
vfprintf(stream, _(format), ap);
|
||||
|
||||
@@ -51,18 +51,14 @@ include $(top_builddir)/make.tmpl
|
||||
|
||||
.PHONY: install_lvmdbusd
|
||||
|
||||
all:
|
||||
$(Q) test -x $(LVMDBUSD) || chmod 755 $(LVMDBUSD)
|
||||
|
||||
install_lvmdbusd: $(LVMDBUSD)
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_DIR) $(sbindir)
|
||||
$(Q) $(INSTALL_SCRIPT) $(LVMDBUSD) $(sbindir)
|
||||
$(Q) $(INSTALL_DIR) $(lvmdbusdir)
|
||||
$(Q) $(INSTALL_DIR) $(lvmdbusdir) $(lvmdbusdir)/__pycache__
|
||||
$(Q) (cd $(srcdir); $(INSTALL_DATA) $(LVMDBUS_SRCDIR_FILES) $(lvmdbusdir))
|
||||
$(Q) $(INSTALL_DATA) $(LVMDBUS_BUILDDIR_FILES) $(lvmdbusdir)
|
||||
$(Q) PYTHON=$(PYTHON3) $(PYCOMPILE) --destdir "$(DESTDIR)" --basedir "$(lvmdbuspydir)" $(LVMDBUS_SRCDIR_FILES) $(LVMDBUS_BUILDDIR_FILES)
|
||||
$(Q) $(CHMOD) 755 $(lvmdbusdir)/__pycache__
|
||||
$(Q) $(CHMOD) 444 $(lvmdbusdir)/__pycache__/*.py[co]
|
||||
|
||||
install_lvm2: install_lvmdbusd
|
||||
|
||||
@@ -50,6 +50,8 @@ worker_q = queue.Queue()
|
||||
# Main event loop
|
||||
loop = None
|
||||
|
||||
G_LOOP_TMO = 0.5
|
||||
|
||||
# Used to instruct the daemon if we should ignore SIGTERM
|
||||
ignore_sigterm = False
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ def call_lvm(command, debug=False, line_cb=None,
|
||||
while True and cfg.run.value != 0:
|
||||
try:
|
||||
rd_fd = [process.stdout.fileno(), process.stderr.fileno()]
|
||||
ready = select.select(rd_fd, [], [], 2)
|
||||
ready = select.select(rd_fd, [], [], cfg.G_LOOP_TMO)
|
||||
|
||||
for r in ready[0]:
|
||||
if r == process.stdout.fileno():
|
||||
|
||||
@@ -183,9 +183,9 @@ class StateUpdate(object):
|
||||
obj.deferred = False
|
||||
|
||||
if len(queued_requests) == 0 and wait:
|
||||
# Note: If we don't have anything for 2 seconds we will
|
||||
# Note: If we don't have anything for N seconds we will
|
||||
# get a queue.Empty exception raised here
|
||||
queued_requests.append(obj.queue.get(block=True, timeout=2))
|
||||
queued_requests.append(obj.queue.get(block=True, timeout=cfg.G_LOOP_TMO))
|
||||
|
||||
# Ok we have one or the deferred queue has some,
|
||||
# check if any others and grab them too
|
||||
|
||||
2
daemons/lvmdbusd/lvm_shell_proxy.py.in
Executable file → Normal file
2
daemons/lvmdbusd/lvm_shell_proxy.py.in
Executable file → Normal file
@@ -66,7 +66,7 @@ class LVMShellProxy(object):
|
||||
self.parent_stdout_fd,
|
||||
self.report_stream.fileno(),
|
||||
self.parent_stderr_fd]
|
||||
ready = select.select(rd_fd, [], [], 2)
|
||||
ready = select.select(rd_fd, [], [], cfg.G_LOOP_TMO)
|
||||
|
||||
for r in ready[0]:
|
||||
if r == self.parent_stdout_fd:
|
||||
|
||||
@@ -41,7 +41,7 @@ def process_request():
|
||||
while cfg.run.value != 0:
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
req = cfg.worker_q.get(True, 5)
|
||||
req = cfg.worker_q.get(True, cfg.G_LOOP_TMO)
|
||||
log_debug(
|
||||
"Method start: %s with args %s (callback = %s)" %
|
||||
(str(req.method), str(req.arguments), str(req.cb)))
|
||||
|
||||
@@ -543,7 +543,7 @@ def round_size(size_bytes):
|
||||
return size_bytes + bs - remainder
|
||||
|
||||
|
||||
_ALLOWABLE_CH = string.ascii_letters + string.digits + '#+-.:=@_\/%'
|
||||
_ALLOWABLE_CH = string.ascii_letters + string.digits + '#+-.:=@_/%'
|
||||
_ALLOWABLE_CH_SET = set(_ALLOWABLE_CH)
|
||||
|
||||
_ALLOWABLE_VG_LV_CH = string.ascii_letters + string.digits + '.-_+'
|
||||
@@ -778,6 +778,7 @@ class LockFile(object):
|
||||
|
||||
def __enter__(self):
|
||||
try:
|
||||
os.makedirs(os.path.dirname(self.lock_file), exist_ok=True)
|
||||
self.fd = os.open(self.lock_file, os.O_CREAT | os.O_RDWR, stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
# Get and set the close on exec and lock the file
|
||||
|
||||
@@ -51,24 +51,25 @@ LDFLAGS += -L$(top_builddir)/libdaemon/server $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
|
||||
LIBS += $(DAEMON_LIBS) $(PTHREAD_LIBS)
|
||||
|
||||
ifneq (,$(firstword $(LIBSYSTEMD_LIBS)))
|
||||
CFLAGS += $(LIBSYSTEMD_CFLAGS) -DUSE_SD_NOTIFY
|
||||
DEFS += -DUSE_SD_NOTIFY
|
||||
CFLAGS += $(LIBSYSTEMD_CFLAGS)
|
||||
LIBS += $(LIBSYSTEMD_LIBS)
|
||||
endif
|
||||
|
||||
lvmlockd: $(OBJECTS) $(top_builddir)/libdaemon/server/libdaemonserver.a $(INTERNAL_LIBS)
|
||||
@echo " [CC] $@"
|
||||
$(SHOW) " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LOCK_LIBS) $(LIBS)
|
||||
|
||||
lvmlockctl: lvmlockctl.o $(INTERNAL_LIBS)
|
||||
@echo " [CC] $@"
|
||||
$(SHOW) " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
|
||||
|
||||
install_lvmlockd: lvmlockd
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
|
||||
|
||||
install_lvmlockctl: lvmlockctl
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
|
||||
|
||||
install_lvm2: install_lvmlockd install_lvmlockctl
|
||||
|
||||
@@ -264,19 +264,19 @@ static void format_info_r_action(char *line, char *r_name, char *r_type)
|
||||
|
||||
static void format_info_line(char *line, char *r_name, char *r_type)
|
||||
{
|
||||
if (!strncmp(line, "info=structs ", strlen("info=structs "))) {
|
||||
if (!strncmp(line, "info=structs ", sizeof("info=structs ") - 1)) {
|
||||
/* only print this in the raw info dump */
|
||||
|
||||
} else if (!strncmp(line, "info=client ", strlen("info=client "))) {
|
||||
} else if (!strncmp(line, "info=client ", sizeof("info=client ") - 1)) {
|
||||
save_client_info(line);
|
||||
|
||||
} else if (!strncmp(line, "info=ls ", strlen("info=ls "))) {
|
||||
} else if (!strncmp(line, "info=ls ", sizeof("info=ls ") - 1)) {
|
||||
format_info_ls(line);
|
||||
|
||||
} else if (!strncmp(line, "info=ls_action ", strlen("info=ls_action "))) {
|
||||
} else if (!strncmp(line, "info=ls_action ", sizeof("info=ls_action ") - 1)) {
|
||||
format_info_ls_action(line);
|
||||
|
||||
} else if (!strncmp(line, "info=r ", strlen("info=r "))) {
|
||||
} else if (!strncmp(line, "info=r ", sizeof("info=r ") - 1)) {
|
||||
/*
|
||||
* r_name/r_type are reset when a new resource is found.
|
||||
* They are reused for the lock and action lines that
|
||||
@@ -286,11 +286,11 @@ static void format_info_line(char *line, char *r_name, char *r_type)
|
||||
memset(r_type, 0, MAX_NAME+1);
|
||||
format_info_r(line, r_name, r_type);
|
||||
|
||||
} else if (!strncmp(line, "info=lk ", strlen("info=lk "))) {
|
||||
} else if (!strncmp(line, "info=lk ", sizeof("info=lk ") - 1)) {
|
||||
/* will use info from previous r */
|
||||
format_info_lk(line, r_name, r_type);
|
||||
|
||||
} else if (!strncmp(line, "info=r_action ", strlen("info=r_action "))) {
|
||||
} else if (!strncmp(line, "info=r_action ", sizeof("info=r_action ") - 1)) {
|
||||
/* will use info from previous r */
|
||||
format_info_r_action(line, r_name, r_type);
|
||||
} else {
|
||||
@@ -940,7 +940,7 @@ static int read_options(int argc, char *argv[])
|
||||
int option_index = 0;
|
||||
int c;
|
||||
|
||||
static struct option long_options[] = {
|
||||
static const struct option _long_options[] = {
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{"quit", no_argument, 0, 'q' },
|
||||
{"info", no_argument, 0, 'i' },
|
||||
@@ -962,7 +962,7 @@ static int read_options(int argc, char *argv[])
|
||||
}
|
||||
|
||||
while (1) {
|
||||
c = getopt_long(argc, argv, "hqidE:D:w:k:r:Se", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "hqidE:D:w:k:r:Se", _long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
#define LVMLOCKD_SOCKET DEFAULT_RUN_DIR "/lvmlockd.socket"
|
||||
#define LVMLOCKD_ADOPT_FILE DEFAULT_RUN_DIR "/lvmlockd.adopt"
|
||||
|
||||
#define LVMLOCKD_USE_SANLOCK_LVB 0
|
||||
|
||||
/* Wrappers to open/close connection */
|
||||
|
||||
static inline daemon_handle lvmlockd_open(const char *sock)
|
||||
static inline __attribute__((always_inline))
|
||||
daemon_handle lvmlockd_open(const char *sock)
|
||||
{
|
||||
daemon_info lvmlockd_info = {
|
||||
.path = "lvmlockd",
|
||||
@@ -51,5 +54,8 @@ static inline void lvmlockd_close(daemon_handle h)
|
||||
#define EREMOVED 219
|
||||
#define EDEVOPEN 220 /* sanlock failed to open lvmlock LV */
|
||||
#define ELMERR 221
|
||||
#define EORPHAN 222
|
||||
#define EADOPT_NONE 223
|
||||
#define EADOPT_RETRY 224
|
||||
|
||||
#endif /* _LVM_LVMLOCKD_CLIENT_H */
|
||||
|
||||
@@ -140,7 +140,7 @@ static int str_to_mode(const char *str);
|
||||
* the act is passed back to the client_thread to be returned to the client.
|
||||
*/
|
||||
|
||||
static const char *lvmlockd_protocol = "lvmlockd";
|
||||
static const char lvmlockd_protocol[] = "lvmlockd";
|
||||
static const int lvmlockd_protocol_version = 1;
|
||||
static int daemon_quit;
|
||||
static int adopt_opt;
|
||||
@@ -810,6 +810,27 @@ static const char *op_str(int x)
|
||||
};
|
||||
}
|
||||
|
||||
static const char *op_mode_str(int op, int mode)
|
||||
{
|
||||
if (op != LD_OP_LOCK)
|
||||
return op_str(op);
|
||||
|
||||
switch (mode) {
|
||||
case LD_LK_IV:
|
||||
return "lock_iv";
|
||||
case LD_LK_UN:
|
||||
return "unlock";
|
||||
case LD_LK_NL:
|
||||
return "lock_nl";
|
||||
case LD_LK_SH:
|
||||
return "lock_sh";
|
||||
case LD_LK_EX:
|
||||
return "lock_ex";
|
||||
default:
|
||||
return "lock_bad";
|
||||
}
|
||||
}
|
||||
|
||||
int last_string_from_args(char *args_in, char *last)
|
||||
{
|
||||
const char *args = args_in;
|
||||
@@ -1041,16 +1062,16 @@ static int lm_prepare_lockspace(struct lockspace *ls, struct action *act)
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int lm_add_lockspace(struct lockspace *ls, struct action *act, int adopt)
|
||||
static int lm_add_lockspace(struct lockspace *ls, struct action *act, int adopt_only, int adopt_ok)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (ls->lm_type == LD_LM_DLM)
|
||||
rv = lm_add_lockspace_dlm(ls, adopt);
|
||||
rv = lm_add_lockspace_dlm(ls, adopt_only, adopt_ok);
|
||||
else if (ls->lm_type == LD_LM_SANLOCK)
|
||||
rv = lm_add_lockspace_sanlock(ls, adopt);
|
||||
rv = lm_add_lockspace_sanlock(ls, adopt_only, adopt_ok);
|
||||
else if (ls->lm_type == LD_LM_IDM)
|
||||
rv = lm_add_lockspace_idm(ls, adopt);
|
||||
rv = lm_add_lockspace_idm(ls, adopt_only, adopt_ok);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -1078,17 +1099,17 @@ static int lm_rem_lockspace(struct lockspace *ls, struct action *act, int free_v
|
||||
}
|
||||
|
||||
static int lm_lock(struct lockspace *ls, struct resource *r, int mode, struct action *act,
|
||||
struct val_blk *vb_out, int *retry, int adopt)
|
||||
struct val_blk *vb_out, int *retry, int adopt_only, int adopt_ok)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (ls->lm_type == LD_LM_DLM)
|
||||
rv = lm_lock_dlm(ls, r, mode, vb_out, adopt);
|
||||
rv = lm_lock_dlm(ls, r, mode, vb_out, adopt_only, adopt_ok);
|
||||
else if (ls->lm_type == LD_LM_SANLOCK)
|
||||
rv = lm_lock_sanlock(ls, r, mode, vb_out, retry, adopt);
|
||||
rv = lm_lock_sanlock(ls, r, mode, vb_out, retry, adopt_only, adopt_ok);
|
||||
else if (ls->lm_type == LD_LM_IDM)
|
||||
rv = lm_lock_idm(ls, r, mode, vb_out, act->lv_uuid,
|
||||
&act->pvs, adopt);
|
||||
&act->pvs, adopt_only, adopt_ok);
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -1169,10 +1190,13 @@ static int lm_find_free_lock(struct lockspace *ls, uint64_t *free_offset, int *s
|
||||
|
||||
/*
|
||||
* While adopting locks, actions originate from the adopt_locks()
|
||||
* function, not from a client. So, these actions (flagged ADOPT),
|
||||
* function, not from a client. So, these actions (flagged ADOPT_ONLY),
|
||||
* should be passed back to the adopt_locks() function through the
|
||||
* adopt_results list, and not be sent back to a client via the
|
||||
* client_list/client_thread.
|
||||
* client_list/client_thread. INTERNAL_CLIENT_ID indicates the
|
||||
* act was generated internally and not from a client, and
|
||||
* distinguishes internal adopt request from those received from
|
||||
* a client.
|
||||
*/
|
||||
|
||||
static void add_client_result(struct action *act)
|
||||
@@ -1185,7 +1209,7 @@ static void add_client_result(struct action *act)
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&client_mutex);
|
||||
if (act->flags & LD_AF_ADOPT)
|
||||
if ((act->flags & LD_AF_ADOPT_ONLY) && (act->client_id == INTERNAL_CLIENT_ID))
|
||||
list_add_tail(&act->list, &adopt_results);
|
||||
else
|
||||
list_add_tail(&act->list, &client_results);
|
||||
@@ -1250,9 +1274,11 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
r->last_client_id = act->client_id;
|
||||
|
||||
if (r->type == LD_RT_LV)
|
||||
log_debug("S %s R %s res_lock cl %u mode %s (%s)", ls->name, r->name, act->client_id, mode_str(act->mode), act->lv_name);
|
||||
log_debug("%s:%s res_lock %s cl %u (%s)", ls->name, r->name,
|
||||
mode_str(act->mode), act->client_id, act->lv_name);
|
||||
else
|
||||
log_debug("S %s R %s res_lock cl %u mode %s", ls->name, r->name, act->client_id, mode_str(act->mode));
|
||||
log_debug("%s:%s res_lock %s cl %u", ls->name, r->name,
|
||||
mode_str(act->mode), act->client_id);
|
||||
|
||||
if (r->mode == LD_LK_SH && act->mode == LD_LK_SH)
|
||||
goto add_lk;
|
||||
@@ -1260,13 +1286,15 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
if (r->type == LD_RT_LV && act->lv_args[0])
|
||||
memcpy(r->lv_args, act->lv_args, MAX_ARGS);
|
||||
|
||||
rv = lm_lock(ls, r, act->mode, act, &vb, retry, act->flags & LD_AF_ADOPT);
|
||||
rv = lm_lock(ls, r, act->mode, act, &vb, retry,
|
||||
act->flags & LD_AF_ADOPT_ONLY ? 1 : 0,
|
||||
act->flags & LD_AF_ADOPT ? 1 : 0);
|
||||
|
||||
if (r->use_vb)
|
||||
log_debug("S %s R %s res_lock rv %d read vb %x %x %u",
|
||||
if (rv && r->use_vb)
|
||||
log_debug("%s:%s res_lock rv %d read vb %x %x %u",
|
||||
ls->name, r->name, rv, vb.version, vb.flags, vb.r_version);
|
||||
else
|
||||
log_debug("S %s R %s res_lock rv %d", ls->name, r->name, rv);
|
||||
else if (rv)
|
||||
log_debug("%s:%s res_lock rv %d", ls->name, r->name, rv);
|
||||
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
@@ -1289,7 +1317,7 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
/* LV locks don't use an lvb. */
|
||||
|
||||
} else if (vb.version && ((vb.version & 0xFF00) > (VAL_BLK_VERSION & 0xFF00))) {
|
||||
log_error("S %s R %s res_lock invalid val_blk version %x flags %x r_version %u",
|
||||
log_error("%s:%s res_lock invalid val_blk version %x flags %x r_version %u",
|
||||
ls->name, r->name, vb.version, vb.flags, vb.r_version);
|
||||
inval_meta = 1;
|
||||
new_version = 0;
|
||||
@@ -1307,7 +1335,7 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
* acquired it, and increased r_version so we know that our
|
||||
* cache is invalid.
|
||||
*/
|
||||
log_debug("S %s R %s res_lock got version %u our %u",
|
||||
log_debug("%s:%s res_lock got version %u our %u",
|
||||
ls->name, r->name, vb.r_version, r->version);
|
||||
r->version = vb.r_version;
|
||||
new_version = vb.r_version;
|
||||
@@ -1320,7 +1348,9 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
* once someone uses the lock and writes a new lvb value.
|
||||
* Do nothing.
|
||||
*/
|
||||
log_debug("S %s R %s res_lock version_zero_valid still zero", ls->name, r->name);
|
||||
/*
|
||||
log_debug("%s:%s res_lock version_zero_valid still zero", ls->name, r->name);
|
||||
*/
|
||||
|
||||
} else if (r->version_zero_valid && vb.r_version) {
|
||||
/*
|
||||
@@ -1343,11 +1373,11 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
* larger version?)
|
||||
*/
|
||||
if (r->version && (r->version >= vb.r_version)) {
|
||||
log_debug("S %s R %s res_lock version_zero_valid got version %u less than our %u",
|
||||
log_debug("%s:%s res_lock version_zero_valid got version %u less than our %u",
|
||||
ls->name, r->name, vb.r_version, r->version);
|
||||
new_version = 0;
|
||||
} else {
|
||||
log_debug("S %s R %s res_lock version_zero_valid got version %u our %u",
|
||||
log_debug("%s:%s res_lock version_zero_valid got version %u our %u",
|
||||
ls->name, r->name, vb.r_version, r->version);
|
||||
new_version = vb.r_version;
|
||||
}
|
||||
@@ -1359,7 +1389,7 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
/*
|
||||
* The first time we've acquired the lock and seen the lvb.
|
||||
*/
|
||||
log_debug("S %s R %s res_lock initial version %u", ls->name, r->name, vb.r_version);
|
||||
log_debug("%s:%s res_lock initial version %u", ls->name, r->name, vb.r_version);
|
||||
r->version = vb.r_version;
|
||||
inval_meta = 1;
|
||||
new_version = vb.r_version;
|
||||
@@ -1370,7 +1400,7 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
* The lock may have never been used to change something.
|
||||
* (e.g. a new sanlock GL?)
|
||||
*/
|
||||
log_debug("S %s R %s res_lock all versions zero", ls->name, r->name);
|
||||
log_debug("%s:%s res_lock all versions zero", ls->name, r->name);
|
||||
if (!r->version_zero_valid) {
|
||||
inval_meta = 1;
|
||||
new_version = 0;
|
||||
@@ -1394,9 +1424,9 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
* is unchanged and we don't need to invalidate metadata.
|
||||
*/
|
||||
if ((ls->lm_type == LD_LM_DLM) && !vb.version && !vb.flags)
|
||||
log_debug("S %s R %s res_lock all lvb content is blank",
|
||||
log_debug("%s:%s res_lock all lvb content is blank",
|
||||
ls->name, r->name);
|
||||
log_debug("S %s R %s res_lock our version %u got vb %x %x %u",
|
||||
log_debug("%s:%s res_lock our version %u got vb %x %x %u",
|
||||
ls->name, r->name, r->version, vb.version, vb.flags, vb.r_version);
|
||||
r->version_zero_valid = 1;
|
||||
inval_meta = 1;
|
||||
@@ -1413,21 +1443,21 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
* FIXME: how does the cache validation and replacement in lvmetad
|
||||
* work in this case?
|
||||
*/
|
||||
log_debug("S %s R %s res_lock got version %u less than our version %u",
|
||||
log_debug("%s:%s res_lock got version %u less than our version %u",
|
||||
ls->name, r->name, vb.r_version, r->version);
|
||||
r->version = vb.r_version;
|
||||
inval_meta = 1;
|
||||
new_version = 0;
|
||||
r->version_zero_valid = 0;
|
||||
} else {
|
||||
log_debug("S %s R %s res_lock undefined vb condition vzv %d our version %u vb %x %x %u",
|
||||
log_debug("%s:%s res_lock undefined vb condition vzv %d our version %u vb %x %x %u",
|
||||
ls->name, r->name, r->version_zero_valid, r->version,
|
||||
vb.version, vb.flags, vb.r_version);
|
||||
}
|
||||
|
||||
if (vb.version && vb.r_version && (vb.flags & VBF_REMOVED)) {
|
||||
/* Should we set ls->thread_stop = 1 ? */
|
||||
log_debug("S %s R %s res_lock vb flag REMOVED",
|
||||
log_debug("%s:%s res_lock vb flag REMOVED",
|
||||
ls->name, r->name);
|
||||
rv = -EREMOVED;
|
||||
}
|
||||
@@ -1469,12 +1499,12 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
|
||||
*/
|
||||
|
||||
if (inval_meta && (r->type == LD_RT_VG)) {
|
||||
log_debug("S %s R %s res_lock invalidate vg state version %u",
|
||||
log_debug("%s:%s res_lock invalidate vg state version %u",
|
||||
ls->name, r->name, new_version);
|
||||
}
|
||||
|
||||
if (inval_meta && (r->type == LD_RT_GL)) {
|
||||
log_debug("S %s R %s res_lock invalidate global state", ls->name, r->name);
|
||||
log_debug("%s:%s res_lock invalidate global state", ls->name, r->name);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1531,7 +1561,8 @@ static int res_convert(struct lockspace *ls, struct resource *r,
|
||||
|
||||
r->last_client_id = act->client_id;
|
||||
|
||||
log_debug("S %s R %s res_convert cl %u mode %s", ls->name, r->name, act->client_id, mode_str(act->mode));
|
||||
log_debug("%s:%s res_convert %s cl %u", ls->name, r->name,
|
||||
mode_str(act->mode), act->client_id);
|
||||
|
||||
if (act->mode == LD_LK_EX && lk->mode == LD_LK_SH && r->sh_count > 1)
|
||||
return -EAGAIN;
|
||||
@@ -1547,7 +1578,7 @@ static int res_convert(struct lockspace *ls, struct resource *r,
|
||||
r_version = r->version;
|
||||
r->version_zero_valid = 0;
|
||||
|
||||
log_debug("S %s R %s res_convert r_version inc %u",
|
||||
log_debug("%s:%s res_convert r_version inc %u",
|
||||
ls->name, r->name, r_version);
|
||||
|
||||
} else if ((r->type == LD_RT_VG) && (r->mode == LD_LK_EX) && (lk->version > r->version)) {
|
||||
@@ -1555,14 +1586,14 @@ static int res_convert(struct lockspace *ls, struct resource *r,
|
||||
r_version = r->version;
|
||||
r->version_zero_valid = 0;
|
||||
|
||||
log_debug("S %s R %s res_convert r_version new %u", ls->name, r->name, r_version);
|
||||
log_debug("%s:%s res_convert r_version new %u", ls->name, r->name, r_version);
|
||||
} else {
|
||||
r_version = 0;
|
||||
}
|
||||
|
||||
rv = lm_convert(ls, r, act->mode, act, r_version);
|
||||
|
||||
log_debug("S %s R %s res_convert rv %d", ls->name, r->name, rv);
|
||||
log_debug("%s:%s res_convert rv %d", ls->name, r->name, rv);
|
||||
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
@@ -1573,7 +1604,7 @@ static int res_convert(struct lockspace *ls, struct resource *r,
|
||||
r->sh_count = 0;
|
||||
} else {
|
||||
/* should not be possible */
|
||||
log_error("S %s R %s res_convert invalid modes %d %d",
|
||||
log_error("%s:%s res_convert invalid modes %d %d",
|
||||
ls->name, r->name, lk->mode, act->mode);
|
||||
return -1;
|
||||
}
|
||||
@@ -1612,7 +1643,7 @@ static int res_cancel(struct lockspace *ls, struct resource *r,
|
||||
return -ENOENT;
|
||||
|
||||
do_cancel:
|
||||
log_debug("S %s R %s res_cancel cl %u", ls->name, r->name, cact->client_id);
|
||||
log_debug("%s:%s res_cancel cl %u", ls->name, r->name, cact->client_id);
|
||||
cact->result = -ECANCELED;
|
||||
list_del(&cact->list);
|
||||
add_client_result(cact);
|
||||
@@ -1660,12 +1691,12 @@ static int res_unlock(struct lockspace *ls, struct resource *r,
|
||||
}
|
||||
|
||||
if (act->op != LD_OP_CLOSE)
|
||||
log_debug("S %s R %s res_unlock cl %u no locks", ls->name, r->name, act->client_id);
|
||||
log_debug("%s:%s res_unlock cl %u no locks", ls->name, r->name, act->client_id);
|
||||
return -ENOENT;
|
||||
|
||||
do_unlock:
|
||||
if ((act->flags & LD_AF_LV_UNLOCK) && (r->last_client_id != act->client_id)) {
|
||||
log_debug("S %s R %s res_unlock cl %u for failed client ignored, last client %u",
|
||||
log_debug("%s:%s res_unlock cl %u for failed client ignored, last client %u",
|
||||
ls->name, r->name, act->client_id, r->last_client_id);
|
||||
return -ENOENT;
|
||||
}
|
||||
@@ -1673,17 +1704,17 @@ do_unlock:
|
||||
r->last_client_id = act->client_id;
|
||||
|
||||
if (act->op == LD_OP_CLOSE)
|
||||
log_debug("S %s R %s res_unlock cl %u from close", ls->name, r->name, act->client_id);
|
||||
log_debug("%s:%s res_unlock cl %u from close", ls->name, r->name, act->client_id);
|
||||
else if (r->type == LD_RT_LV)
|
||||
log_debug("S %s R %s res_unlock cl %u (%s)", ls->name, r->name, act->client_id, act->lv_name);
|
||||
log_debug("%s:%s res_unlock cl %u (%s)", ls->name, r->name, act->client_id, act->lv_name);
|
||||
else
|
||||
log_debug("S %s R %s res_unlock cl %u", ls->name, r->name, act->client_id);
|
||||
log_debug("%s:%s res_unlock cl %u", ls->name, r->name, act->client_id);
|
||||
|
||||
/* send unlock to lm when last sh lock is unlocked */
|
||||
if (lk->mode == LD_LK_SH) {
|
||||
r->sh_count--;
|
||||
if (r->sh_count > 0) {
|
||||
log_debug("S %s R %s res_unlock sh_count %u", ls->name, r->name, r->sh_count);
|
||||
log_debug("%s:%s res_unlock sh_count %u", ls->name, r->name, r->sh_count);
|
||||
goto rem_lk;
|
||||
}
|
||||
}
|
||||
@@ -1694,14 +1725,14 @@ do_unlock:
|
||||
r_version = r->version;
|
||||
r->version_zero_valid = 0;
|
||||
|
||||
log_debug("S %s R %s res_unlock r_version inc %u", ls->name, r->name, r_version);
|
||||
log_debug("%s:%s res_unlock r_version inc %u", ls->name, r->name, r_version);
|
||||
|
||||
} else if ((r->type == LD_RT_VG) && (r->mode == LD_LK_EX) && (lk->version > r->version)) {
|
||||
r->version = lk->version;
|
||||
r_version = r->version;
|
||||
r->version_zero_valid = 0;
|
||||
|
||||
log_debug("S %s R %s res_unlock r_version new %u",
|
||||
log_debug("%s:%s res_unlock r_version new %u",
|
||||
ls->name, r->name, r_version);
|
||||
} else {
|
||||
r_version = 0;
|
||||
@@ -1710,11 +1741,11 @@ do_unlock:
|
||||
rv = lm_unlock(ls, r, act, r_version, 0);
|
||||
if (rv < 0) {
|
||||
/* should never happen, retry? */
|
||||
log_error("S %s R %s res_unlock lm error %d", ls->name, r->name, rv);
|
||||
log_error("%s:%s res_unlock lm error %d", ls->name, r->name, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
log_debug("S %s R %s res_unlock lm done", ls->name, r->name);
|
||||
/* log_debug("%s:%s res_unlock lm done", ls->name, r->name); */
|
||||
|
||||
rem_lk:
|
||||
list_del(&lk->list);
|
||||
@@ -1733,13 +1764,13 @@ static int res_update(struct lockspace *ls, struct resource *r,
|
||||
|
||||
lk = find_lock_client(r, act->client_id);
|
||||
if (!lk) {
|
||||
log_error("S %s R %s res_update cl %u lock not found",
|
||||
log_error("%s:%s res_update cl %u lock not found",
|
||||
ls->name, r->name, act->client_id);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (r->mode != LD_LK_EX) {
|
||||
log_error("S %s R %s res_update cl %u version on non-ex lock",
|
||||
log_error("%s:%s res_update cl %u version on non-ex lock",
|
||||
ls->name, r->name, act->client_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1760,13 +1791,13 @@ static int res_update(struct lockspace *ls, struct resource *r,
|
||||
* force an invalidation on other hosts. The next change
|
||||
* will return to using the seqno again.
|
||||
*/
|
||||
log_error("S %s R %s res_update cl %u old version %u new version %u too small",
|
||||
log_error("%s:%s res_update cl %u old version %u new version %u too small",
|
||||
ls->name, r->name, act->client_id, r->version, act->version);
|
||||
}
|
||||
lk->version = act->version;
|
||||
}
|
||||
|
||||
log_debug("S %s R %s res_update cl %u lk version to %u", ls->name, r->name, act->client_id, lk->version);
|
||||
log_debug("%s:%s res_update cl %u lk version to %u", ls->name, r->name, act->client_id, lk->version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1919,7 +1950,7 @@ static void res_process(struct lockspace *ls, struct resource *r,
|
||||
|
||||
list_for_each_entry_safe(act, safe, &r->actions, list) {
|
||||
if (act->op == LD_OP_FREE && act->rt == LD_RT_LV) {
|
||||
log_debug("S %s R %s free_lv", ls->name, r->name);
|
||||
log_debug("%s:%s free_lv", ls->name, r->name);
|
||||
rv = free_lv(ls, r);
|
||||
act->result = rv;
|
||||
list_del(&act->list);
|
||||
@@ -1941,7 +1972,7 @@ static void res_process(struct lockspace *ls, struct resource *r,
|
||||
add_client_result(act);
|
||||
|
||||
if (!rv && act->op == LD_OP_DISABLE) {
|
||||
log_debug("S %s R %s free disabled", ls->name, r->name);
|
||||
log_debug("%s:%s free disabled", ls->name, r->name);
|
||||
goto r_free;
|
||||
}
|
||||
}
|
||||
@@ -2159,7 +2190,7 @@ static void res_process(struct lockspace *ls, struct resource *r,
|
||||
(act->retries <= act->max_retries) &&
|
||||
(lm_retry || (r->type != LD_RT_LV))) {
|
||||
/* leave act on list */
|
||||
log_debug("S %s R %s res_lock EAGAIN retry", ls->name, r->name);
|
||||
log_debug("%s:%s res_lock EAGAIN retry", ls->name, r->name);
|
||||
act->retries++;
|
||||
*retry_out = 1;
|
||||
} else {
|
||||
@@ -2192,7 +2223,7 @@ static void res_process(struct lockspace *ls, struct resource *r,
|
||||
(act->retries <= act->max_retries) &&
|
||||
(lm_retry || (r->type != LD_RT_LV))) {
|
||||
/* leave act on list */
|
||||
log_debug("S %s R %s res_lock EAGAIN retry", ls->name, r->name);
|
||||
log_debug("%s:%s res_lock EAGAIN retry", ls->name, r->name);
|
||||
act->retries++;
|
||||
*retry_out = 1;
|
||||
} else {
|
||||
@@ -2211,13 +2242,13 @@ static void res_process(struct lockspace *ls, struct resource *r,
|
||||
r_free:
|
||||
/* For the EUNATCH case it may be possible there are queued actions? */
|
||||
list_for_each_entry_safe(act, safe, &r->actions, list) {
|
||||
log_error("S %s R %s res_process r_free cancel %s client %d",
|
||||
log_error("%s:%s res_process r_free cancel %s client %d",
|
||||
ls->name, r->name, op_str(act->op), act->client_id);
|
||||
act->result = -ECANCELED;
|
||||
list_del(&act->list);
|
||||
add_client_result(act);
|
||||
}
|
||||
log_debug("S %s R %s res_process free", ls->name, r->name);
|
||||
log_debug("%s:%s res_process free", ls->name, r->name);
|
||||
lm_rem_resource(ls, r);
|
||||
list_del(&r->list);
|
||||
free_resource(r);
|
||||
@@ -2275,9 +2306,9 @@ static int clear_locks(struct lockspace *ls, int free_vg, int drop_vg)
|
||||
*/
|
||||
|
||||
if (lk->flags & LD_LF_PERSISTENT && !drop_vg)
|
||||
log_error("S %s R %s clear lock persistent", ls->name, r->name);
|
||||
log_error("%s:%s clear lock persistent", ls->name, r->name);
|
||||
else
|
||||
log_debug("S %s R %s clear lock mode %s client %d", ls->name, r->name, mode_str(lk->mode), lk->client_id);
|
||||
log_debug("%s:%s clear lock mode %s client %d", ls->name, r->name, mode_str(lk->mode), lk->client_id);
|
||||
|
||||
if (lk->version > lk_version)
|
||||
lk_version = lk->version;
|
||||
@@ -2292,13 +2323,13 @@ static int clear_locks(struct lockspace *ls, int free_vg, int drop_vg)
|
||||
if ((r->type == LD_RT_GL) && (r->mode == LD_LK_EX)) {
|
||||
r->version++;
|
||||
r_version = r->version;
|
||||
log_debug("S %s R %s clear_locks r_version inc %u",
|
||||
log_debug("%s:%s clear_locks r_version inc %u",
|
||||
ls->name, r->name, r_version);
|
||||
|
||||
} else if ((r->type == LD_RT_VG) && (r->mode == LD_LK_EX) && (lk_version > r->version)) {
|
||||
r->version = lk_version;
|
||||
r_version = r->version;
|
||||
log_debug("S %s R %s clear_locks r_version new %u",
|
||||
log_debug("%s:%s clear_locks r_version new %u",
|
||||
ls->name, r->name, r_version);
|
||||
|
||||
} else {
|
||||
@@ -2308,19 +2339,19 @@ static int clear_locks(struct lockspace *ls, int free_vg, int drop_vg)
|
||||
rv = lm_unlock(ls, r, NULL, r_version, free_vg ? LMUF_FREE_VG : 0);
|
||||
if (rv < 0) {
|
||||
/* should never happen */
|
||||
log_error("S %s R %s clear_locks free %d drop %d lm unlock error %d",
|
||||
log_error("%s:%s clear_locks free %d drop %d lm unlock error %d",
|
||||
ls->name, r->name, free_vg, drop_vg, rv);
|
||||
}
|
||||
|
||||
list_for_each_entry_safe(act, act_safe, &r->actions, list) {
|
||||
log_error("S %s R %s clear_locks cancel %s client %d",
|
||||
log_error("%s:%s clear_locks cancel %s client %d",
|
||||
ls->name, r->name, op_str(act->op), act->client_id);
|
||||
act->result = -ECANCELED;
|
||||
list_del(&act->list);
|
||||
add_client_result(act);
|
||||
}
|
||||
r_free:
|
||||
log_debug("S %s R %s free", ls->name, r->name);
|
||||
log_debug("%s:%s free", ls->name, r->name);
|
||||
lm_rem_resource(ls, r);
|
||||
list_del(&r->list);
|
||||
free_resource(r);
|
||||
@@ -2367,13 +2398,13 @@ static struct resource *find_resource_act(struct lockspace *ls,
|
||||
r->mode = LD_LK_UN;
|
||||
|
||||
if (r->type == LD_RT_GL) {
|
||||
strncpy(r->name, R_NAME_GL, MAX_NAME);
|
||||
dm_strncpy(r->name, R_NAME_GL, sizeof(r->name));
|
||||
r->use_vb = 1;
|
||||
} else if (r->type == LD_RT_VG) {
|
||||
strncpy(r->name, R_NAME_VG, MAX_NAME);
|
||||
dm_strncpy(r->name, R_NAME_VG, sizeof(r->name));
|
||||
r->use_vb = 1;
|
||||
} else if (r->type == LD_RT_LV) {
|
||||
strncpy(r->name, act->lv_uuid, MAX_NAME);
|
||||
dm_strncpy(r->name, act->lv_uuid, sizeof(r->name));
|
||||
r->use_vb = 0;
|
||||
}
|
||||
|
||||
@@ -2457,15 +2488,18 @@ static void *lockspace_thread_main(void *arg_in)
|
||||
struct list_head tmp_act;
|
||||
struct list_head act_close;
|
||||
char tmp_name[MAX_NAME+5];
|
||||
int fail_stop_busy;
|
||||
int free_vg = 0;
|
||||
int drop_vg = 0;
|
||||
int error = 0;
|
||||
int adopt_flag = 0;
|
||||
int adopt_only = 0;
|
||||
int adopt_ok = 0;
|
||||
int wait_flag = 0;
|
||||
int retry;
|
||||
int rv;
|
||||
|
||||
INIT_LIST_HEAD(&act_close);
|
||||
INIT_LIST_HEAD(&tmp_act);
|
||||
|
||||
/* first action may be client add */
|
||||
pthread_mutex_lock(&ls->mutex);
|
||||
@@ -2479,14 +2513,21 @@ static void *lockspace_thread_main(void *arg_in)
|
||||
|
||||
if (add_act->flags & LD_AF_WAIT)
|
||||
wait_flag = 1;
|
||||
if (add_act->flags & LD_AF_ADOPT_ONLY)
|
||||
adopt_only = 1;
|
||||
if (add_act->flags & LD_AF_ADOPT)
|
||||
adopt_flag = 1;
|
||||
adopt_ok = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&ls->mutex);
|
||||
|
||||
log_debug("S %s lm_add_lockspace %s wait %d adopt %d",
|
||||
ls->name, lm_str(ls->lm_type), wait_flag, adopt_flag);
|
||||
if (ls->lm_type == LD_LM_DLM && !strcmp(gl_lsname_dlm, ls->name)) {
|
||||
log_debug("dlm global lockspace adopt_ok");
|
||||
adopt_ok = 1;
|
||||
}
|
||||
|
||||
log_debug("S %s lm_add_lockspace %s wait %d adopt_only %d adopt_ok %d",
|
||||
ls->name, lm_str(ls->lm_type), wait_flag, adopt_only, adopt_ok);
|
||||
|
||||
/*
|
||||
* The prepare step does not wait for anything and is quick;
|
||||
@@ -2505,7 +2546,7 @@ static void *lockspace_thread_main(void *arg_in)
|
||||
* The actual lockspace join can take a while.
|
||||
*/
|
||||
if (!error) {
|
||||
error = lm_add_lockspace(ls, add_act, adopt_flag);
|
||||
error = lm_add_lockspace(ls, add_act, adopt_only, adopt_ok);
|
||||
|
||||
log_debug("S %s lm_add_lockspace done %d", ls->name, error);
|
||||
|
||||
@@ -2532,6 +2573,8 @@ static void *lockspace_thread_main(void *arg_in)
|
||||
if (error)
|
||||
goto out_act;
|
||||
|
||||
restart:
|
||||
|
||||
while (1) {
|
||||
pthread_mutex_lock(&ls->mutex);
|
||||
while (!ls->thread_work) {
|
||||
@@ -2712,7 +2755,7 @@ static void *lockspace_thread_main(void *arg_in)
|
||||
|
||||
list_add_tail(&act->list, &r->actions);
|
||||
|
||||
log_debug("S %s R %s action %s %s", ls->name, r->name,
|
||||
log_debug("%s:%s action %s %s", ls->name, r->name,
|
||||
op_str(act->op), mode_str(act->mode));
|
||||
}
|
||||
pthread_mutex_unlock(&ls->mutex);
|
||||
@@ -2784,17 +2827,48 @@ out_rem:
|
||||
* Leave the lockspace.
|
||||
*/
|
||||
|
||||
rv = lm_rem_lockspace(ls, NULL, free_vg);
|
||||
fail_stop_busy = 0;
|
||||
|
||||
log_debug("S %s rem_lockspace done %d", ls->name, rv);
|
||||
rv = lm_rem_lockspace(ls, NULL, free_vg);
|
||||
if (rv < 0) {
|
||||
pthread_mutex_lock(&ls->mutex);
|
||||
list_for_each_entry_safe(act, safe, &ls->actions, list) {
|
||||
/*
|
||||
* If there's a stop action then there's a path to return an error,
|
||||
* and in the case of EBUSY presumably there's a chance to redo it.
|
||||
*/
|
||||
if ((act->op == LD_OP_STOP) && (rv == -EBUSY)) {
|
||||
log_debug("S %s rem_lockspace for stop error %d", ls->name, rv);
|
||||
act->result = -EBUSY;
|
||||
list_del(&act->list);
|
||||
list_add_tail(&act->list, &tmp_act);
|
||||
ls->thread_stop = 0;
|
||||
fail_stop_busy = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&ls->mutex);
|
||||
|
||||
if (fail_stop_busy) {
|
||||
pthread_mutex_lock(&client_mutex);
|
||||
list_del(&act->list);
|
||||
list_add_tail(&act->list, &client_results);
|
||||
pthread_cond_signal(&client_cond);
|
||||
pthread_mutex_unlock(&client_mutex);
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
|
||||
if (rv < 0)
|
||||
log_debug("S %s rem_lockspace error %d", ls->name, rv);
|
||||
else
|
||||
log_debug("S %s rem_lockspace done", ls->name);
|
||||
|
||||
out_act:
|
||||
/*
|
||||
* Move remaining actions to results; this will usually (always?)
|
||||
* be only the stop action.
|
||||
*/
|
||||
INIT_LIST_HEAD(&tmp_act);
|
||||
|
||||
pthread_mutex_lock(&ls->mutex);
|
||||
list_for_each_entry_safe(act, safe, &ls->actions, list) {
|
||||
if (act->op == LD_OP_FREE) {
|
||||
@@ -2918,12 +2992,11 @@ static struct lockspace *find_lockspace_name(char *ls_name)
|
||||
|
||||
static int vg_ls_name(const char *vg_name, char *ls_name)
|
||||
{
|
||||
if (strlen(vg_name) + 4 > MAX_NAME) {
|
||||
if (snprintf(ls_name, MAX_NAME, "%s%s", LVM_LS_PREFIX, vg_name) >= MAX_NAME) {
|
||||
log_error("vg name too long %s", vg_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(ls_name, MAX_NAME, "%s%s", LVM_LS_PREFIX, vg_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2981,13 +3054,13 @@ static int add_lockspace_thread(const char *ls_name,
|
||||
|
||||
if (vg_uuid)
|
||||
/* coverity[buffer_size_warning] */
|
||||
strncpy(ls->vg_uuid, vg_uuid, 64);
|
||||
memccpy(ls->vg_uuid, vg_uuid, 0, 64);
|
||||
|
||||
if (vg_name)
|
||||
strncpy(ls->vg_name, vg_name, MAX_NAME);
|
||||
dm_strncpy(ls->vg_name, vg_name, sizeof(ls->vg_name));
|
||||
|
||||
if (vg_args)
|
||||
strncpy(ls->vg_args, vg_args, MAX_ARGS);
|
||||
dm_strncpy(ls->vg_args, vg_args, sizeof(ls->vg_args));
|
||||
|
||||
if (act)
|
||||
ls->host_id = act->host_id;
|
||||
@@ -3529,7 +3602,7 @@ static void work_test_gl(void)
|
||||
is_enabled = lm_gl_is_enabled(ls);
|
||||
if (is_enabled) {
|
||||
log_debug("S %s worker found gl_is_enabled", ls->name);
|
||||
strncpy(gl_lsname_sanlock, ls->name, MAX_NAME);
|
||||
dm_strncpy(gl_lsname_sanlock, ls->name, sizeof(gl_lsname_sanlock));
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&ls->mutex);
|
||||
@@ -4071,7 +4144,7 @@ static int client_send_result(struct client *cl, struct action *act)
|
||||
|
||||
log_debug("send %s[%d] cl %u %s %s rv %d %s %s",
|
||||
cl->name[0] ? cl->name : "client", cl->pid, cl->id,
|
||||
op_str(act->op), rt_str(act->rt),
|
||||
op_mode_str(act->op, act->mode), rt_str(act->rt),
|
||||
act->result, (act->result == -ENOLS) ? "ENOLS" : "", result_flags);
|
||||
|
||||
res = daemon_reply_simple("OK",
|
||||
@@ -4155,12 +4228,26 @@ static int add_lock_action(struct action *act)
|
||||
vg_ls_name(act->vg_name, ls_name);
|
||||
} else {
|
||||
if (!gl_use_dlm && !gl_use_sanlock && !gl_use_idm) {
|
||||
if (lm_is_running_dlm())
|
||||
gl_use_dlm = 1;
|
||||
else if (lm_is_running_sanlock())
|
||||
gl_use_sanlock = 1;
|
||||
else if (lm_is_running_idm())
|
||||
gl_use_idm = 1;
|
||||
int run_sanlock = lm_is_running_sanlock();
|
||||
int run_dlm = lm_is_running_dlm();
|
||||
int run_idm = lm_is_running_idm();
|
||||
|
||||
if (run_sanlock + run_dlm + run_idm >= 2) {
|
||||
log_error("global lock op %s mode %s: multiple lock managers running sanlock=%d dlm=%d idm=%d",
|
||||
op_str(act->op), mode_str(act->mode), run_sanlock, run_dlm, run_idm);
|
||||
} else if (!run_sanlock && !run_dlm && !run_idm) {
|
||||
log_debug("global lock op %s mode %s: no lock manager running",
|
||||
op_str(act->op), mode_str(act->mode));
|
||||
} else {
|
||||
if (run_dlm)
|
||||
gl_use_dlm = 1;
|
||||
else if (run_sanlock)
|
||||
gl_use_sanlock = 1;
|
||||
else if (run_idm)
|
||||
gl_use_idm = 1;
|
||||
log_debug("global lock op %s mode %s: gl_use_sanlock %d gl_use_dlm %d gl_use_idm %d",
|
||||
op_str(act->op), mode_str(act->mode), gl_use_sanlock, gl_use_dlm, gl_use_idm);
|
||||
}
|
||||
}
|
||||
gl_ls_name(ls_name);
|
||||
}
|
||||
@@ -4466,6 +4553,12 @@ static uint32_t str_to_opts(const char *str)
|
||||
flags |= LD_AF_ENABLE;
|
||||
if (strstr(str, "disable"))
|
||||
flags |= LD_AF_DISABLE;
|
||||
|
||||
/* FIXME: parse the flag values properly */
|
||||
if (strstr(str, "adopt_only"))
|
||||
flags |= LD_AF_ADOPT_ONLY;
|
||||
else if (strstr(str, "adopt"))
|
||||
flags |= LD_AF_ADOPT;
|
||||
out:
|
||||
return flags;
|
||||
}
|
||||
@@ -4690,9 +4783,12 @@ static int dump_info(int *dump_len)
|
||||
|
||||
/*
|
||||
* clients
|
||||
* Proper lock order is client_mutex then cl->mutex,
|
||||
* but cl->mutex is already held so skip client info
|
||||
* if it would block.
|
||||
*/
|
||||
|
||||
pthread_mutex_lock(&client_mutex);
|
||||
if (pthread_mutex_trylock(&client_mutex))
|
||||
goto print_ls;
|
||||
list_for_each_entry(cl, &client_list, list) {
|
||||
ret = print_client(cl, "client", pos, len);
|
||||
if (ret >= len - pos) {
|
||||
@@ -4706,6 +4802,7 @@ static int dump_info(int *dump_len)
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
||||
print_ls:
|
||||
/*
|
||||
* lockspaces with their action/resource/lock info
|
||||
*/
|
||||
@@ -4902,13 +4999,13 @@ static void client_recv_action(struct client *cl)
|
||||
act->path = strdup(path);
|
||||
|
||||
if (vg_name && strcmp(vg_name, "none"))
|
||||
strncpy(act->vg_name, vg_name, MAX_NAME);
|
||||
dm_strncpy(act->vg_name, vg_name, sizeof(act->vg_name));
|
||||
|
||||
if (vg_uuid && strcmp(vg_uuid, "none"))
|
||||
strncpy(act->vg_uuid, vg_uuid, 64);
|
||||
memccpy(act->vg_uuid, vg_uuid, 0, 64);
|
||||
|
||||
if (vg_sysid && strcmp(vg_sysid, "none"))
|
||||
strncpy(act->vg_sysid, vg_sysid, MAX_NAME);
|
||||
dm_strncpy(act->vg_sysid, vg_sysid, sizeof(act->vg_sysid));
|
||||
|
||||
str = daemon_request_str(req, "lv_name", NULL);
|
||||
if (str && strcmp(str, "none"))
|
||||
@@ -4974,9 +5071,9 @@ skip_pvs_path:
|
||||
dm_config_destroy(req.cft);
|
||||
buffer_destroy(&req.buffer);
|
||||
|
||||
log_debug("recv %s[%d] cl %u %s %s \"%s\" mode %s flags %x",
|
||||
log_debug("recv %s[%d] cl %u %s %s \"%s\" flags %x",
|
||||
cl->name[0] ? cl->name : "client", cl->pid, cl->id,
|
||||
op_str(act->op), rt_str(act->rt), act->vg_name, mode_str(act->mode), opts);
|
||||
op_mode_str(act->op, act->mode), rt_str(act->rt), act->vg_name, opts);
|
||||
|
||||
if (lm == LD_LM_DLM && !lm_support_dlm()) {
|
||||
log_debug("dlm not supported");
|
||||
@@ -5280,7 +5377,7 @@ static int match_dm_uuid(char *dm_uuid, char *lv_lock_uuid)
|
||||
{
|
||||
char buf1[64];
|
||||
char buf2[64];
|
||||
int i, j;
|
||||
unsigned i, j;
|
||||
|
||||
memset(buf1, 0, sizeof(buf1));
|
||||
memset(buf2, 0, sizeof(buf2));
|
||||
@@ -5364,7 +5461,7 @@ static int remove_inactive_lvs(struct list_head *vg_lockd)
|
||||
goto next_dmname;
|
||||
}
|
||||
|
||||
log_debug("adopt remove_inactive dm name %s dm uuid %s vgname %s lvname %s",
|
||||
log_debug("adopt found active dm %s %s lv %s/%s",
|
||||
names->name, dm_uuid, vgname, lvname);
|
||||
|
||||
if (!vgname || !lvname) {
|
||||
@@ -5385,8 +5482,7 @@ static int remove_inactive_lvs(struct list_head *vg_lockd)
|
||||
continue;
|
||||
|
||||
/* Found an active LV in a lockd VG. */
|
||||
log_debug("dm device %s adopt in vg %s lv %s",
|
||||
names->name, ls->vg_name, r->name);
|
||||
log_debug("adopting %s", names->name);
|
||||
r->adopt = 1;
|
||||
goto next_dmname;
|
||||
}
|
||||
@@ -5623,7 +5719,7 @@ static void adopt_locks(void)
|
||||
act->rt = LD_RT_VG;
|
||||
act->lm_type = ls->lm_type;
|
||||
act->client_id = INTERNAL_CLIENT_ID;
|
||||
strncpy(act->vg_name, ls->vg_name, MAX_NAME);
|
||||
dm_strncpy(act->vg_name, ls->vg_name, sizeof(act->vg_name));
|
||||
memcpy(act->vg_uuid, ls->vg_uuid, 64);
|
||||
memcpy(act->vg_args, ls->vg_args, MAX_ARGS);
|
||||
act->host_id = ls->host_id;
|
||||
@@ -5658,7 +5754,6 @@ static void adopt_locks(void)
|
||||
*/
|
||||
|
||||
while (count_start_done < count_start) {
|
||||
sleep(1);
|
||||
act = NULL;
|
||||
|
||||
pthread_mutex_lock(&client_mutex);
|
||||
@@ -5668,8 +5763,10 @@ static void adopt_locks(void)
|
||||
}
|
||||
pthread_mutex_unlock(&client_mutex);
|
||||
|
||||
if (!act)
|
||||
if (!act) {
|
||||
usleep(500000);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (act->result < 0) {
|
||||
log_error("adopt add lockspace failed vg %s %d", act->vg_name, act->result);
|
||||
@@ -5712,12 +5809,12 @@ static void adopt_locks(void)
|
||||
act->op = LD_OP_LOCK;
|
||||
act->rt = LD_RT_LV;
|
||||
act->mode = r->adopt_mode;
|
||||
act->flags = (LD_AF_ADOPT | LD_AF_PERSISTENT);
|
||||
act->flags = (LD_AF_ADOPT_ONLY | LD_AF_PERSISTENT);
|
||||
act->client_id = INTERNAL_CLIENT_ID;
|
||||
act->lm_type = ls->lm_type;
|
||||
strncpy(act->vg_name, ls->vg_name, MAX_NAME);
|
||||
strncpy(act->lv_uuid, r->name, MAX_NAME);
|
||||
strncpy(act->lv_args, r->lv_args, MAX_ARGS);
|
||||
dm_strncpy(act->vg_name, ls->vg_name, sizeof(act->vg_name));
|
||||
dm_strncpy(act->lv_uuid, r->name, sizeof(act->lv_uuid));
|
||||
dm_strncpy(act->lv_args, r->lv_args, sizeof(act->lv_args));
|
||||
|
||||
log_debug("adopt lock for lv %s %s", act->vg_name, act->lv_uuid);
|
||||
|
||||
@@ -5740,10 +5837,10 @@ static void adopt_locks(void)
|
||||
act->op = LD_OP_LOCK;
|
||||
act->rt = LD_RT_VG;
|
||||
act->mode = LD_LK_SH;
|
||||
act->flags = LD_AF_ADOPT;
|
||||
act->flags = LD_AF_ADOPT_ONLY;
|
||||
act->client_id = INTERNAL_CLIENT_ID;
|
||||
act->lm_type = ls->lm_type;
|
||||
strncpy(act->vg_name, ls->vg_name, MAX_NAME);
|
||||
dm_strncpy(act->vg_name, ls->vg_name, sizeof(act->vg_name));
|
||||
|
||||
log_debug("adopt lock for vg %s", act->vg_name);
|
||||
|
||||
@@ -5766,7 +5863,7 @@ static void adopt_locks(void)
|
||||
act->op = LD_OP_LOCK;
|
||||
act->rt = LD_RT_GL;
|
||||
act->mode = LD_LK_SH;
|
||||
act->flags = LD_AF_ADOPT;
|
||||
act->flags = LD_AF_ADOPT_ONLY;
|
||||
act->client_id = INTERNAL_CLIENT_ID;
|
||||
act->lm_type = (gl_use_sanlock ? LD_LM_SANLOCK : LD_LM_DLM);
|
||||
|
||||
@@ -5787,7 +5884,6 @@ static void adopt_locks(void)
|
||||
*/
|
||||
|
||||
while (count_adopt_done < count_adopt) {
|
||||
sleep(1);
|
||||
act = NULL;
|
||||
|
||||
pthread_mutex_lock(&client_mutex);
|
||||
@@ -5797,14 +5893,16 @@ static void adopt_locks(void)
|
||||
}
|
||||
pthread_mutex_unlock(&client_mutex);
|
||||
|
||||
if (!act)
|
||||
if (!act) {
|
||||
usleep(200000);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* lock adopt results
|
||||
*/
|
||||
|
||||
if (act->result == -EUCLEAN) {
|
||||
if (act->result == -EADOPT_RETRY) {
|
||||
/*
|
||||
* Adopt failed because the orphan has a different mode
|
||||
* than initially requested. Repeat the lock-adopt operation
|
||||
@@ -5843,7 +5941,7 @@ static void adopt_locks(void)
|
||||
free_action(act);
|
||||
}
|
||||
|
||||
} else if (act->result == -ENOENT) {
|
||||
} else if (act->result == -EADOPT_NONE) {
|
||||
/*
|
||||
* No orphan lock exists. This is common for GL/VG locks
|
||||
* because they may not have been held when lvmlockd exited.
|
||||
@@ -5933,7 +6031,6 @@ static void adopt_locks(void)
|
||||
/* Wait for the unlocks to complete. */
|
||||
|
||||
while (count_adopt_done < count_adopt) {
|
||||
sleep(1);
|
||||
act = NULL;
|
||||
|
||||
pthread_mutex_lock(&client_mutex);
|
||||
@@ -5943,8 +6040,10 @@ static void adopt_locks(void)
|
||||
}
|
||||
pthread_mutex_unlock(&client_mutex);
|
||||
|
||||
if (!act)
|
||||
if (!act) {
|
||||
usleep(200000);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (act->result < 0)
|
||||
log_error("adopt unlock error %d", act->result);
|
||||
@@ -6003,7 +6102,7 @@ static void process_listener(int poll_fd)
|
||||
return;
|
||||
|
||||
if (!(cl = alloc_client())) {
|
||||
if (!close(fd))
|
||||
if (close(fd))
|
||||
log_error("failed to close lockd poll fd");
|
||||
return;
|
||||
}
|
||||
@@ -6280,9 +6379,8 @@ int main(int argc, char *argv[])
|
||||
.daemon_fini = NULL,
|
||||
.daemon_main = main_loop,
|
||||
};
|
||||
daemon_host_id_file = NULL;
|
||||
|
||||
static struct option long_options[] = {
|
||||
static const struct option long_options[] = {
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{"version", no_argument, 0, 'V' },
|
||||
{"test", no_argument, 0, 'T' },
|
||||
@@ -6300,6 +6398,8 @@ int main(int argc, char *argv[])
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
daemon_host_id_file = NULL;
|
||||
|
||||
while (1) {
|
||||
int c;
|
||||
int lm;
|
||||
|
||||
@@ -96,7 +96,6 @@ static int check_args_version(char *vg_args)
|
||||
|
||||
static int read_cluster_name(char *clustername)
|
||||
{
|
||||
static const char close_error_msg[] = "read_cluster_name: close_error %d";
|
||||
char *n;
|
||||
int fd;
|
||||
int rv;
|
||||
@@ -115,18 +114,19 @@ static int read_cluster_name(char *clustername)
|
||||
rv = read(fd, clustername, MAX_ARGS);
|
||||
if (rv < 0) {
|
||||
log_error("read_cluster_name: cluster name read error %d, check dlm_controld", fd);
|
||||
if (close(fd))
|
||||
log_error(close_error_msg, fd);
|
||||
return rv;
|
||||
goto out;
|
||||
}
|
||||
clustername[rv] = 0;
|
||||
|
||||
n = strstr(clustername, "\n");
|
||||
if (n)
|
||||
*n = '\0';
|
||||
rv = 0;
|
||||
out:
|
||||
if (close(fd))
|
||||
log_error(close_error_msg, fd);
|
||||
return 0;
|
||||
log_error("read_cluster_name: close_error %d", fd);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define MAX_VERSION 16
|
||||
@@ -226,14 +226,14 @@ static int get_local_nodeid(void)
|
||||
{
|
||||
struct dirent *de;
|
||||
DIR *ls_dir;
|
||||
char ls_comms_path[PATH_MAX];
|
||||
char ls_comms_path[PATH_MAX] = { 0 };
|
||||
char path[PATH_MAX] = { 0 };
|
||||
FILE *file;
|
||||
char line[LOCK_LINE_MAX];
|
||||
char *str1, *str2;
|
||||
int rv = -1, val;
|
||||
|
||||
memset(ls_comms_path, 0, sizeof(ls_comms_path));
|
||||
snprintf(ls_comms_path, PATH_MAX, "%s",DLM_COMMS_PATH);
|
||||
snprintf(ls_comms_path, sizeof(ls_comms_path), "%s", DLM_COMMS_PATH);
|
||||
|
||||
if (!(ls_dir = opendir(ls_comms_path)))
|
||||
return -ECONNREFUSED;
|
||||
@@ -241,31 +241,31 @@ static int get_local_nodeid(void)
|
||||
while ((de = readdir(ls_dir))) {
|
||||
if (de->d_name[0] == '.')
|
||||
continue;
|
||||
memset(ls_comms_path, 0, sizeof(ls_comms_path));
|
||||
snprintf(ls_comms_path, PATH_MAX, "%s/%s/local",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
|
||||
snprintf(path, sizeof(path), "%s/%s/local",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
|
||||
if (!(file = fopen(ls_comms_path, "r")))
|
||||
continue;
|
||||
str1 = fgets(line, LOCK_LINE_MAX, file);
|
||||
fclose(file);
|
||||
|
||||
str1 = fgets(line, sizeof(line), file);
|
||||
if (fclose(file))
|
||||
log_sys_debug("fclose", path);
|
||||
if (str1) {
|
||||
rv = sscanf(line, "%d", &val);
|
||||
if ((rv == 1) && (val == 1 )) {
|
||||
memset(ls_comms_path, 0, sizeof(ls_comms_path));
|
||||
snprintf(ls_comms_path, PATH_MAX, "%s/%s/nodeid",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
snprintf(path, sizeof(path), "%s/%s/nodeid",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
|
||||
if (!(file = fopen(ls_comms_path, "r")))
|
||||
if (!(file = fopen(path, "r")))
|
||||
continue;
|
||||
str2 = fgets(line, LOCK_LINE_MAX, file);
|
||||
fclose(file);
|
||||
|
||||
str2 = fgets(line, sizeof(line), file);
|
||||
if (fclose(file))
|
||||
log_sys_debug("fclose", path);
|
||||
if (str2) {
|
||||
rv = sscanf(line, "%d", &val);
|
||||
if (rv == 1) {
|
||||
closedir(ls_dir);
|
||||
if (closedir(ls_dir))
|
||||
log_sys_debug("closedir", ls_comms_path);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,8 @@ static int get_local_nodeid(void)
|
||||
}
|
||||
|
||||
if (closedir(ls_dir))
|
||||
log_error("get_local_nodeid closedir error");
|
||||
log_sys_debug("closedir", ls_comms_path);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -304,20 +305,27 @@ fail:
|
||||
return rv;
|
||||
}
|
||||
|
||||
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt)
|
||||
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
{
|
||||
struct lm_dlm *lmd = (struct lm_dlm *)ls->lm_data;
|
||||
|
||||
if (daemon_test)
|
||||
return 0;
|
||||
|
||||
if (adopt)
|
||||
if (adopt_only || adopt_ok) {
|
||||
lmd->dh = dlm_open_lockspace(ls->name);
|
||||
else
|
||||
if (!lmd->dh && adopt_ok)
|
||||
lmd->dh = dlm_new_lockspace(ls->name, 0600, DLM_LSFL_NEWEXCL);
|
||||
if (!lmd->dh)
|
||||
log_error("add_lockspace_dlm adopt_only %d adopt_ok %d %s error",
|
||||
adopt_only, adopt_ok, ls->name);
|
||||
} else {
|
||||
lmd->dh = dlm_new_lockspace(ls->name, 0600, DLM_LSFL_NEWEXCL);
|
||||
if (!lmd->dh)
|
||||
log_error("add_lockspace_dlm %s error", ls->name);
|
||||
}
|
||||
|
||||
if (!lmd->dh) {
|
||||
log_error("add_lockspace_dlm %s adopt %d error", ls->name, adopt);
|
||||
free(lmd);
|
||||
ls->lm_data = NULL;
|
||||
return -1;
|
||||
@@ -385,7 +393,7 @@ static int lm_add_resource_dlm(struct lockspace *ls, struct resource *r, int wit
|
||||
r->name, strlen(r->name),
|
||||
0, NULL, NULL, NULL);
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s add_resource_dlm lock error %d", ls->name, r->name, rv);
|
||||
log_error("%s:%s add_resource_dlm lock error %d", ls->name, r->name, rv);
|
||||
return rv;
|
||||
}
|
||||
out:
|
||||
@@ -409,7 +417,7 @@ int lm_rem_resource_dlm(struct lockspace *ls, struct resource *r)
|
||||
|
||||
rv = dlm_ls_unlock_wait(lmd->dh, lksb->sb_lkid, 0, lksb);
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s rem_resource_dlm unlock error %d", ls->name, r->name, rv);
|
||||
log_error("%s:%s rem_resource_dlm unlock error %d", ls->name, r->name, rv);
|
||||
}
|
||||
out:
|
||||
free(rdd->vb);
|
||||
@@ -464,7 +472,7 @@ static int lm_adopt_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
log_debug("S %s R %s adopt_dlm", ls->name, r->name);
|
||||
log_debug("%s:%s adopt_dlm", ls->name, r->name);
|
||||
|
||||
if (daemon_test)
|
||||
return 0;
|
||||
@@ -473,29 +481,29 @@ static int lm_adopt_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
* dlm returns 0 for success, -EAGAIN if an orphan is
|
||||
* found with another mode, and -ENOENT if no orphan.
|
||||
*
|
||||
* cast/bast/param are (void *)1 because the kernel
|
||||
* cast/bast/param are (void (*)(void*))1 because the kernel
|
||||
* returns errors if some are null.
|
||||
*/
|
||||
|
||||
rv = dlm_ls_lockx(lmd->dh, mode, lksb, flags,
|
||||
r->name, strlen(r->name), 0,
|
||||
(void *)1, (void *)1, (void *)1,
|
||||
(void (*)(void*))1, (void (*)(void*))1, (void (*)(void*))1,
|
||||
NULL, NULL);
|
||||
|
||||
if (rv == -1 && (errno == EAGAIN)) {
|
||||
log_debug("S %s R %s adopt_dlm adopt mode %d try other mode",
|
||||
log_debug("%s:%s adopt_dlm adopt mode %d try other mode",
|
||||
ls->name, r->name, ld_mode);
|
||||
rv = -EUCLEAN;
|
||||
rv = -EADOPT_RETRY;
|
||||
goto fail;
|
||||
}
|
||||
if (rv == -1 && (errno == ENOENT)) {
|
||||
log_debug("S %s R %s adopt_dlm adopt mode %d no lock",
|
||||
log_debug("%s:%s adopt_dlm adopt mode %d no lock",
|
||||
ls->name, r->name, ld_mode);
|
||||
rv = -ENOENT;
|
||||
rv = -EADOPT_NONE;
|
||||
goto fail;
|
||||
}
|
||||
if (rv < 0) {
|
||||
log_debug("S %s R %s adopt_dlm mode %d flags %x error %d errno %d",
|
||||
log_debug("%s:%s adopt_dlm mode %d flags %x error %d errno %d",
|
||||
ls->name, r->name, mode, flags, rv, errno);
|
||||
goto fail;
|
||||
}
|
||||
@@ -525,7 +533,7 @@ static int lm_adopt_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
*/
|
||||
|
||||
int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int adopt)
|
||||
struct val_blk *vb_out, int adopt_only, int adopt_ok)
|
||||
{
|
||||
struct lm_dlm *lmd = (struct lm_dlm *)ls->lm_data;
|
||||
struct rd_dlm *rdd = (struct rd_dlm *)r->lm_data;
|
||||
@@ -535,7 +543,13 @@ int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
int mode;
|
||||
int rv;
|
||||
|
||||
if (adopt) {
|
||||
if (adopt_ok) {
|
||||
log_debug("%s:%s lock_dlm adopt_ok not supported", ls->name, r->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (adopt_only) {
|
||||
log_debug("%s:%s lock_dlm adopt_only", ls->name, r->name);
|
||||
/* When adopting, we don't follow the normal method
|
||||
of acquiring a NL lock then converting it to the
|
||||
desired mode. */
|
||||
@@ -564,7 +578,7 @@ int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
log_debug("S %s R %s lock_dlm", ls->name, r->name);
|
||||
log_debug("%s:%s lock_dlm", ls->name, r->name);
|
||||
|
||||
if (daemon_test) {
|
||||
if (rdd->vb) {
|
||||
@@ -584,7 +598,7 @@ int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
r->name, strlen(r->name),
|
||||
0, NULL, NULL, NULL);
|
||||
if (rv == -1) {
|
||||
log_debug("S %s R %s lock_dlm acquire mode PR for %d rv %d",
|
||||
log_debug("%s:%s lock_dlm acquire mode PR for %d rv %d",
|
||||
ls->name, r->name, mode, rv);
|
||||
goto lockrv;
|
||||
}
|
||||
@@ -597,17 +611,17 @@ int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
0, NULL, NULL, NULL);
|
||||
lockrv:
|
||||
if (rv == -1 && errno == EAGAIN) {
|
||||
log_debug("S %s R %s lock_dlm acquire mode %d rv EAGAIN", ls->name, r->name, mode);
|
||||
log_debug("%s:%s lock_dlm acquire mode %d rv EAGAIN", ls->name, r->name, mode);
|
||||
return -EAGAIN;
|
||||
}
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s lock_dlm acquire error %d errno %d", ls->name, r->name, rv, errno);
|
||||
log_error("%s:%s lock_dlm acquire error %d errno %d", ls->name, r->name, rv, errno);
|
||||
return -ELMERR;
|
||||
}
|
||||
|
||||
if (rdd->vb) {
|
||||
if (lksb->sb_flags & DLM_SBF_VALNOTVALID) {
|
||||
log_debug("S %s R %s lock_dlm VALNOTVALID", ls->name, r->name);
|
||||
log_debug("%s:%s lock_dlm VALNOTVALID", ls->name, r->name);
|
||||
memset(rdd->vb, 0, sizeof(struct val_blk));
|
||||
memset(vb_out, 0, sizeof(struct val_blk));
|
||||
goto out;
|
||||
@@ -636,11 +650,11 @@ int lm_convert_dlm(struct lockspace *ls, struct resource *r,
|
||||
struct lm_dlm *lmd = (struct lm_dlm *)ls->lm_data;
|
||||
struct rd_dlm *rdd = (struct rd_dlm *)r->lm_data;
|
||||
struct dlm_lksb *lksb = &rdd->lksb;
|
||||
uint32_t mode;
|
||||
int mode;
|
||||
uint32_t flags = 0;
|
||||
int rv;
|
||||
|
||||
log_debug("S %s R %s convert_dlm", ls->name, r->name);
|
||||
log_debug("%s:%s convert_dlm", ls->name, r->name);
|
||||
|
||||
flags |= LKF_CONVERT;
|
||||
flags |= LKF_NOQUEUE;
|
||||
@@ -654,14 +668,16 @@ int lm_convert_dlm(struct lockspace *ls, struct resource *r,
|
||||
rdd->vb->r_version = cpu_to_le32(r_version);
|
||||
memcpy(lksb->sb_lvbptr, rdd->vb, sizeof(struct val_blk));
|
||||
|
||||
log_debug("S %s R %s convert_dlm set r_version %u",
|
||||
log_debug("%s:%s convert_dlm set r_version %u",
|
||||
ls->name, r->name, r_version);
|
||||
|
||||
flags |= LKF_VALBLK;
|
||||
}
|
||||
|
||||
mode = to_dlm_mode(ld_mode);
|
||||
|
||||
if ((mode = to_dlm_mode(ld_mode)) < 0) {
|
||||
log_error("lm_convert_dlm invalid mode %d", ld_mode);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (daemon_test)
|
||||
return 0;
|
||||
|
||||
@@ -670,11 +686,11 @@ int lm_convert_dlm(struct lockspace *ls, struct resource *r,
|
||||
0, NULL, NULL, NULL);
|
||||
if (rv == -1 && errno == EAGAIN) {
|
||||
/* FIXME: When does this happen? Should something different be done? */
|
||||
log_error("S %s R %s convert_dlm mode %d rv EAGAIN", ls->name, r->name, mode);
|
||||
log_error("%s:%s convert_dlm mode %d rv EAGAIN", ls->name, r->name, mode);
|
||||
return -EAGAIN;
|
||||
}
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s convert_dlm error %d", ls->name, r->name, rv);
|
||||
log_error("%s:%s convert_dlm error %d", ls->name, r->name, rv);
|
||||
rv = -ELMERR;
|
||||
}
|
||||
return rv;
|
||||
@@ -724,7 +740,7 @@ int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
memcpy(rdd->vb, &vb_next, sizeof(struct val_blk));
|
||||
memcpy(lksb->sb_lvbptr, &vb_next, sizeof(struct val_blk));
|
||||
|
||||
log_debug("S %s R %s unlock_dlm vb old %x %x %u new %x %x %u",
|
||||
log_debug("%s:%s unlock_dlm vb old %x %x %u new %x %x %u",
|
||||
ls->name, r->name,
|
||||
le16_to_cpu(vb_prev.version),
|
||||
le16_to_cpu(vb_prev.flags),
|
||||
@@ -733,12 +749,12 @@ int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
le16_to_cpu(vb_next.flags),
|
||||
le32_to_cpu(vb_next.r_version));
|
||||
} else {
|
||||
log_debug("S %s R %s unlock_dlm vb unchanged", ls->name, r->name);
|
||||
log_debug("%s:%s unlock_dlm vb unchanged", ls->name, r->name);
|
||||
}
|
||||
|
||||
flags |= LKF_VALBLK;
|
||||
} else {
|
||||
log_debug("S %s R %s unlock_dlm", ls->name, r->name);
|
||||
log_debug("%s:%s unlock_dlm", ls->name, r->name);
|
||||
}
|
||||
|
||||
if (daemon_test)
|
||||
@@ -748,7 +764,7 @@ int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
r->name, strlen(r->name),
|
||||
0, NULL, NULL, NULL);
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s unlock_dlm error %d", ls->name, r->name, rv);
|
||||
log_error("%s:%s unlock_dlm error %d", ls->name, r->name, rv);
|
||||
rv = -ELMERR;
|
||||
}
|
||||
|
||||
@@ -783,7 +799,6 @@ int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
|
||||
int lm_hosts_dlm(struct lockspace *ls, int notify)
|
||||
{
|
||||
static const char closedir_err_msg[] = "lm_hosts_dlm: closedir failed";
|
||||
char ls_nodes_path[PATH_MAX];
|
||||
struct dirent *de;
|
||||
DIR *ls_dir;
|
||||
@@ -806,7 +821,7 @@ int lm_hosts_dlm(struct lockspace *ls, int notify)
|
||||
}
|
||||
|
||||
if (closedir(ls_dir))
|
||||
log_error(closedir_err_msg);
|
||||
log_error("lm_hosts_dlm: closedir failed");
|
||||
|
||||
if (!count) {
|
||||
log_error("lm_hosts_dlm found no nodes in %s", ls_nodes_path);
|
||||
@@ -823,10 +838,10 @@ int lm_hosts_dlm(struct lockspace *ls, int notify)
|
||||
|
||||
int lm_get_lockspaces_dlm(struct list_head *ls_rejoin)
|
||||
{
|
||||
static const char closedir_err_msg[] = "lm_get_lockspace_dlm: closedir failed";
|
||||
struct lockspace *ls;
|
||||
struct dirent *de;
|
||||
DIR *ls_dir;
|
||||
int ret = 0;
|
||||
|
||||
if (!(ls_dir = opendir(DLM_LOCKSPACES_PATH)))
|
||||
return -ECONNREFUSED;
|
||||
@@ -839,20 +854,20 @@ int lm_get_lockspaces_dlm(struct list_head *ls_rejoin)
|
||||
continue;
|
||||
|
||||
if (!(ls = alloc_lockspace())) {
|
||||
if (closedir(ls_dir))
|
||||
log_error(closedir_err_msg);
|
||||
return -ENOMEM;
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ls->lm_type = LD_LM_DLM;
|
||||
strncpy(ls->name, de->d_name, MAX_NAME);
|
||||
strncpy(ls->vg_name, ls->name + strlen(LVM_LS_PREFIX), MAX_NAME);
|
||||
dm_strncpy(ls->name, de->d_name, sizeof(ls->name));
|
||||
dm_strncpy(ls->vg_name, ls->name + strlen(LVM_LS_PREFIX), sizeof(ls->vg_name));
|
||||
list_add_tail(&ls->list, ls_rejoin);
|
||||
}
|
||||
|
||||
out:
|
||||
if (closedir(ls_dir))
|
||||
log_error(closedir_err_msg);
|
||||
return 0;
|
||||
log_error("lm_get_lockspace_dlm: closedir failed");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int lm_is_running_dlm(void)
|
||||
@@ -882,7 +897,7 @@ int lm_refresh_lv_start_dlm(struct action *act)
|
||||
int rv;
|
||||
|
||||
/* split /dev/vgname/lvname into vgname and lvname strings */
|
||||
strncpy(path, act->path, PATH_MAX-1);
|
||||
dm_strncpy(path, act->path, sizeof(path));
|
||||
|
||||
/* skip past dev */
|
||||
if (!(p = strchr(path + 1, '/')))
|
||||
|
||||
@@ -391,7 +391,7 @@ int lm_prepare_lockspace_idm(struct lockspace *ls)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lm_add_lockspace_idm(struct lockspace *ls, int adopt)
|
||||
int lm_add_lockspace_idm(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
{
|
||||
char killpath[IDM_FAILURE_PATH_LEN];
|
||||
char killargs[IDM_FAILURE_ARGS_LEN];
|
||||
@@ -530,7 +530,7 @@ static int to_idm_mode(int ld_mode)
|
||||
|
||||
int lm_lock_idm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, char *lv_uuid, struct pvs *pvs,
|
||||
int adopt)
|
||||
int adopt_only, int adopt_ok)
|
||||
{
|
||||
struct lm_idm *lmi = (struct lm_idm *)ls->lm_data;
|
||||
struct rd_idm *rdi = (struct rd_idm *)r->lm_data;
|
||||
|
||||
@@ -107,11 +107,12 @@ struct client {
|
||||
#define LD_AF_SEARCH_LS 0x00000200
|
||||
#define LD_AF_WAIT_STARTING 0x00001000
|
||||
#define LD_AF_DUP_GL_LS 0x00002000
|
||||
#define LD_AF_ADOPT 0x00010000
|
||||
#define LD_AF_ADOPT 0x00010000 /* adopt ok but not required */
|
||||
#define LD_AF_WARN_GL_REMOVED 0x00020000
|
||||
#define LD_AF_LV_LOCK 0x00040000
|
||||
#define LD_AF_LV_UNLOCK 0x00080000
|
||||
#define LD_AF_SH_EXISTS 0x00100000
|
||||
#define LD_AF_ADOPT_ONLY 0x00200000 /* adopt orphan or fail */
|
||||
|
||||
/*
|
||||
* Number of times to repeat a lock request after
|
||||
@@ -363,6 +364,8 @@ void log_level(int level, const char *fmt, ...) __attribute__((format(printf, 2
|
||||
#define log_debug(fmt, args...) log_level(LOG_DEBUG, fmt, ##args)
|
||||
#define log_error(fmt, args...) log_level(LOG_ERR, fmt, ##args)
|
||||
#define log_warn(fmt, args...) log_level(LOG_WARNING, fmt, ##args)
|
||||
#define log_sys_debug(x, y) \
|
||||
log_debug("%s: %s failed: %s", y, x, strerror(errno))
|
||||
|
||||
struct lockspace *alloc_lockspace(void);
|
||||
int lockspaces_empty(void);
|
||||
@@ -391,11 +394,11 @@ static inline const char *mode_str(int x)
|
||||
|
||||
int lm_init_vg_dlm(char *ls_name, char *vg_name, uint32_t flags, char *vg_args);
|
||||
int lm_prepare_lockspace_dlm(struct lockspace *ls);
|
||||
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt);
|
||||
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt_only, int adopt_ok);
|
||||
int lm_purge_locks_dlm(struct lockspace *ls);
|
||||
int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg);
|
||||
int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int adopt);
|
||||
struct val_blk *vb_out, int adopt_only, int adopt_ok);
|
||||
int lm_convert_dlm(struct lockspace *ls, struct resource *r,
|
||||
int ld_mode, uint32_t r_version);
|
||||
int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
@@ -425,7 +428,7 @@ static inline int lm_prepare_lockspace_dlm(struct lockspace *ls)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int lm_add_lockspace_dlm(struct lockspace *ls, int adopt)
|
||||
static inline int lm_add_lockspace_dlm(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -441,7 +444,7 @@ static inline int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg)
|
||||
}
|
||||
|
||||
static inline int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int adopt)
|
||||
struct val_blk *vb_out, int adopt_only, int adopt_ok)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -507,10 +510,11 @@ int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name, char *vg_arg
|
||||
int lm_free_lv_sanlock(struct lockspace *ls, struct resource *r);
|
||||
int lm_rename_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args);
|
||||
int lm_prepare_lockspace_sanlock(struct lockspace *ls);
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt);
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok);
|
||||
int lm_rem_lockspace_sanlock(struct lockspace *ls, int free_vg);
|
||||
int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int *retry, int adopt);
|
||||
struct val_blk *vb_out, int *retry,
|
||||
int adopt_only, int adopt_ok);
|
||||
int lm_convert_sanlock(struct lockspace *ls, struct resource *r,
|
||||
int ld_mode, uint32_t r_version);
|
||||
int lm_unlock_sanlock(struct lockspace *ls, struct resource *r,
|
||||
@@ -557,7 +561,7 @@ static inline int lm_prepare_lockspace_sanlock(struct lockspace *ls)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt)
|
||||
static inline int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -568,7 +572,8 @@ static inline int lm_rem_lockspace_sanlock(struct lockspace *ls, int free_vg)
|
||||
}
|
||||
|
||||
static inline int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int *retry, int adopt)
|
||||
struct val_blk *vb_out, int *retry,
|
||||
int adopt_only, int adopt_ok)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -642,11 +647,11 @@ static inline int lm_support_sanlock(void)
|
||||
int lm_data_size_idm(void);
|
||||
int lm_init_vg_idm(char *ls_name, char *vg_name, uint32_t flags, char *vg_args);
|
||||
int lm_prepare_lockspace_idm(struct lockspace *ls);
|
||||
int lm_add_lockspace_idm(struct lockspace *ls, int adopt);
|
||||
int lm_add_lockspace_idm(struct lockspace *ls, int adopt_only, int adopt_ok);
|
||||
int lm_rem_lockspace_idm(struct lockspace *ls, int free_vg);
|
||||
int lm_lock_idm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, char *lv_uuid, struct pvs *pvs,
|
||||
int adopt);
|
||||
int adopt_only, int adopt_ok);
|
||||
int lm_convert_idm(struct lockspace *ls, struct resource *r,
|
||||
int ld_mode, uint32_t r_version);
|
||||
int lm_unlock_idm(struct lockspace *ls, struct resource *r,
|
||||
@@ -679,7 +684,7 @@ static inline int lm_prepare_lockspace_idm(struct lockspace *ls)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int lm_add_lockspace_idm(struct lockspace *ls, int adopt)
|
||||
static inline int lm_add_lockspace_idm(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -691,7 +696,7 @@ static inline int lm_rem_lockspace_idm(struct lockspace *ls, int free_vg)
|
||||
|
||||
static inline int lm_lock_idm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, char *lv_uuid, struct pvs *pvs,
|
||||
int adopt)
|
||||
int adopt_only, int adopt_ok)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -24,21 +24,6 @@
|
||||
#include "sanlock_admin.h"
|
||||
#include "sanlock_resource.h"
|
||||
|
||||
/* FIXME: these are copied from sanlock.h only until
|
||||
an updated version of sanlock is available with them. */
|
||||
#define SANLK_RES_ALIGN1M 0x00000010
|
||||
#define SANLK_RES_ALIGN2M 0x00000020
|
||||
#define SANLK_RES_ALIGN4M 0x00000040
|
||||
#define SANLK_RES_ALIGN8M 0x00000080
|
||||
#define SANLK_RES_SECTOR512 0x00000100
|
||||
#define SANLK_RES_SECTOR4K 0x00000200
|
||||
#define SANLK_LSF_ALIGN1M 0x00000010
|
||||
#define SANLK_LSF_ALIGN2M 0x00000020
|
||||
#define SANLK_LSF_ALIGN4M 0x00000040
|
||||
#define SANLK_LSF_ALIGN8M 0x00000080
|
||||
#define SANLK_LSF_SECTOR512 0x00000100
|
||||
#define SANLK_LSF_SECTOR4K 0x00000200
|
||||
|
||||
#include <stddef.h>
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
@@ -229,13 +214,13 @@ static uint64_t daemon_test_lv_count;
|
||||
|
||||
/*
|
||||
* Copy a null-terminated string "str" into a fixed
|
||||
* size (SANLK_NAME_LEN) struct field "buf" which is
|
||||
* not null terminated.
|
||||
* size struct field "buf" which is not null terminated.
|
||||
* (ATM SANLK_NAME_LEN is only 48 bytes.
|
||||
* Use memccpy() instead of strncpy().
|
||||
*/
|
||||
static void strcpy_name_len(char *buf, char *str, int len)
|
||||
static void strcpy_name_len(char *buf, const char *str, size_t len)
|
||||
{
|
||||
/* coverity[buffer_size_warning] */
|
||||
strncpy(buf, str, SANLK_NAME_LEN);
|
||||
memccpy(buf, str, 0, len);
|
||||
}
|
||||
|
||||
static int lock_lv_name_from_args(char *vg_args, char *lock_lv_name)
|
||||
@@ -531,7 +516,6 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
memset(&ss, 0, sizeof(ss));
|
||||
memset(&rd, 0, sizeof(rd));
|
||||
memset(&disk, 0, sizeof(disk));
|
||||
memset(lock_lv_name, 0, sizeof(lock_lv_name));
|
||||
memset(lock_args_version, 0, sizeof(lock_args_version));
|
||||
|
||||
if (!vg_args || !vg_args[0] || !strcmp(vg_args, "none")) {
|
||||
@@ -543,7 +527,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
VG_LOCK_ARGS_MAJOR, VG_LOCK_ARGS_MINOR, VG_LOCK_ARGS_PATCH);
|
||||
|
||||
/* see comment above about input vg_args being only lock_lv_name */
|
||||
snprintf(lock_lv_name, MAX_ARGS, "%s", vg_args);
|
||||
dm_strncpy(lock_lv_name, vg_args, sizeof(lock_lv_name));
|
||||
|
||||
if (strlen(lock_lv_name) + strlen(lock_args_version) + 2 > MAX_ARGS)
|
||||
return -EARGS;
|
||||
@@ -618,7 +602,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
gl_name = R_NAME_GL;
|
||||
|
||||
memcpy(rd.rs.lockspace_name, ss.name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, (char *)gl_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, gl_name, SANLK_NAME_LEN);
|
||||
memcpy(rd.rs.disks[0].path, disk.path, SANLK_PATH_LEN);
|
||||
rd.rs.disks[0].offset = align_size * GL_LOCK_BEGIN;
|
||||
rd.rs.num_disks = 1;
|
||||
@@ -633,7 +617,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
}
|
||||
|
||||
memcpy(rd.rs.lockspace_name, ss.name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, (char *)R_NAME_VG, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, R_NAME_VG, SANLK_NAME_LEN);
|
||||
memcpy(rd.rs.disks[0].path, disk.path, SANLK_PATH_LEN);
|
||||
rd.rs.disks[0].offset = align_size * VG_LOCK_BEGIN;
|
||||
rd.rs.num_disks = 1;
|
||||
@@ -648,7 +632,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
}
|
||||
|
||||
if (!strcmp(gl_name, R_NAME_GL))
|
||||
strncpy(gl_lsname_sanlock, ls_name, MAX_NAME);
|
||||
dm_strncpy(gl_lsname_sanlock, ls_name, sizeof(gl_lsname_sanlock));
|
||||
|
||||
rv = snprintf(vg_args, MAX_ARGS, "%s:%s", lock_args_version, lock_lv_name);
|
||||
if (rv >= MAX_ARGS)
|
||||
@@ -668,7 +652,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
(SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M);
|
||||
memcpy(rd.rs.disks[0].path, disk.path, SANLK_PATH_LEN);
|
||||
strcpy_name_len(rd.rs.lockspace_name, ls_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, (char *)"#unused", SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, "#unused", SANLK_NAME_LEN);
|
||||
|
||||
offset = align_size * LV_LOCK_BEGIN;
|
||||
|
||||
@@ -1015,16 +999,16 @@ int lm_free_lv_sanlock(struct lockspace *ls, struct resource *r)
|
||||
struct sanlk_resource *rs = &rds->rs;
|
||||
int rv;
|
||||
|
||||
log_debug("S %s R %s free_lv_san", ls->name, r->name);
|
||||
log_debug("%s:%s free_lv_san", ls->name, r->name);
|
||||
|
||||
if (daemon_test)
|
||||
return 0;
|
||||
|
||||
strcpy_name_len(rs->name, (char *)"#unused", SANLK_NAME_LEN);
|
||||
strcpy_name_len(rs->name, "#unused", SANLK_NAME_LEN);
|
||||
|
||||
rv = sanlock_write_resource(rs, 0, 0, 0);
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s free_lv_san write error %d",
|
||||
log_error("%s:%s free_lv_san write error %d",
|
||||
ls->name, r->name, rv);
|
||||
}
|
||||
|
||||
@@ -1055,10 +1039,10 @@ int lm_ex_disable_gl_sanlock(struct lockspace *ls)
|
||||
memset(&rd2, 0, sizeof(rd2));
|
||||
|
||||
strcpy_name_len(rd1.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd1.rs.name, (char *)R_NAME_GL, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd1.rs.name, R_NAME_GL, SANLK_NAME_LEN);
|
||||
|
||||
strcpy_name_len(rd2.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd2.rs.name, (char *)R_NAME_GL_DISABLED, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd2.rs.name, R_NAME_GL_DISABLED, SANLK_NAME_LEN);
|
||||
|
||||
rd1.rs.num_disks = 1;
|
||||
memcpy(rd1.rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN-1);
|
||||
@@ -1124,7 +1108,7 @@ int lm_able_gl_sanlock(struct lockspace *ls, int enable)
|
||||
memset(&rd, 0, sizeof(rd));
|
||||
|
||||
strcpy_name_len(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, (char *)gl_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, gl_name, SANLK_NAME_LEN);
|
||||
|
||||
rd.rs.num_disks = 1;
|
||||
memcpy(rd.rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN-1);
|
||||
@@ -1144,7 +1128,7 @@ out:
|
||||
ls->sanlock_gl_enabled = enable;
|
||||
|
||||
if (enable)
|
||||
strncpy(gl_lsname_sanlock, ls->name, MAX_NAME);
|
||||
dm_strncpy(gl_lsname_sanlock, ls->name, sizeof(gl_lsname_sanlock));
|
||||
|
||||
if (!enable && !strcmp(gl_lsname_sanlock, ls->name))
|
||||
memset(gl_lsname_sanlock, 0, sizeof(gl_lsname_sanlock));
|
||||
@@ -1335,7 +1319,7 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls)
|
||||
struct stat st;
|
||||
struct lm_sanlock *lms = NULL;
|
||||
char lock_lv_name[MAX_ARGS+1];
|
||||
char lsname[SANLK_NAME_LEN + 1];
|
||||
char lsname[SANLK_NAME_LEN + 1] = { 0 };
|
||||
char disk_path[SANLK_PATH_LEN];
|
||||
char killpath[SANLK_PATH_LEN];
|
||||
char killargs[SANLK_PATH_LEN];
|
||||
@@ -1416,8 +1400,7 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
memset(lsname, 0, sizeof(lsname));
|
||||
strncpy(lsname, ls->name, SANLK_NAME_LEN);
|
||||
dm_strncpy(lsname, ls->name, sizeof(lsname));
|
||||
|
||||
memcpy(lms->ss.name, lsname, SANLK_NAME_LEN);
|
||||
lms->ss.host_id_disk.offset = 0;
|
||||
@@ -1518,7 +1501,7 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt)
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
{
|
||||
struct lm_sanlock *lms = (struct lm_sanlock *)ls->lm_data;
|
||||
int rv;
|
||||
@@ -1529,11 +1512,15 @@ int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt)
|
||||
}
|
||||
|
||||
rv = sanlock_add_lockspace_timeout(&lms->ss, 0, sanlock_io_timeout);
|
||||
if (rv == -EEXIST && adopt) {
|
||||
if (rv == -EEXIST && (adopt_ok || adopt_only)) {
|
||||
/* We could alternatively just skip the sanlock call for adopt. */
|
||||
log_debug("S %s add_lockspace_san adopt found ls", ls->name);
|
||||
goto out;
|
||||
}
|
||||
if ((rv != -EEXIST) && adopt_only) {
|
||||
log_error("S %s add_lockspace_san add_lockspace adopt_only not found", ls->name);
|
||||
goto fail;
|
||||
}
|
||||
if (rv < 0) {
|
||||
/* retry for some errors? */
|
||||
log_error("S %s add_lockspace_san add_lockspace error %d", ls->name, rv);
|
||||
@@ -1576,8 +1563,10 @@ int lm_rem_lockspace_sanlock(struct lockspace *ls, int free_vg)
|
||||
goto out;
|
||||
|
||||
rv = sanlock_rem_lockspace(&lms->ss, 0);
|
||||
if (rv < 0)
|
||||
if (rv < 0) {
|
||||
log_error("S %s rem_lockspace_san error %d", ls->name, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (free_vg) {
|
||||
/*
|
||||
@@ -1586,7 +1575,7 @@ int lm_rem_lockspace_sanlock(struct lockspace *ls, int free_vg)
|
||||
* This shouldn't be generally necessary, but there may some races
|
||||
* between nodes starting and removing a vg which this could help.
|
||||
*/
|
||||
strcpy_name_len(lms->ss.name, (char *)"#unused", SANLK_NAME_LEN);
|
||||
strcpy_name_len(lms->ss.name, "#unused", SANLK_NAME_LEN);
|
||||
|
||||
rv = sanlock_write_lockspace(&lms->ss, 0, 0, sanlock_io_timeout);
|
||||
if (rv < 0) {
|
||||
@@ -1627,12 +1616,17 @@ static int lm_add_resource_sanlock(struct lockspace *ls, struct resource *r)
|
||||
|
||||
/* LD_RT_LV offset is set in each lm_lock call from lv_args. */
|
||||
|
||||
/*
|
||||
* Disable sanlock lvb since lock versions are not currently used for
|
||||
* anything, and it's nice to avoid the extra i/o used for lvb's.
|
||||
*/
|
||||
#if LVMLOCKD_USE_SANLOCK_LVB
|
||||
if (r->type == LD_RT_GL || r->type == LD_RT_VG) {
|
||||
rds->vb = zalloc(sizeof(struct val_blk));
|
||||
if (!rds->vb)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1641,16 +1635,16 @@ int lm_rem_resource_sanlock(struct lockspace *ls, struct resource *r)
|
||||
struct rd_sanlock *rds = (struct rd_sanlock *)r->lm_data;
|
||||
|
||||
/* FIXME: assert r->mode == UN or unlock if it's not? */
|
||||
|
||||
#ifdef LVMLOCKD_USE_SANLOCK_LVB
|
||||
free(rds->vb);
|
||||
|
||||
#endif
|
||||
memset(rds, 0, sizeof(struct rd_sanlock));
|
||||
r->lm_init = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int *retry, int adopt)
|
||||
struct val_blk *vb_out, int *retry, int adopt_only, int adopt_ok)
|
||||
{
|
||||
struct lm_sanlock *lms = (struct lm_sanlock *)ls->lm_data;
|
||||
struct rd_sanlock *rds = (struct rd_sanlock *)r->lm_data;
|
||||
@@ -1690,20 +1684,20 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
|
||||
rv = check_args_version(r->lv_args, LV_LOCK_ARGS_MAJOR);
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s lock_san wrong lv_args version %s",
|
||||
log_error("%s:%s lock_san wrong lv_args version %s",
|
||||
ls->name, r->name, r->lv_args);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = lock_lv_offset_from_args(r->lv_args, &lock_lv_offset);
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s lock_san lv_offset_from_args error %d %s",
|
||||
log_error("%s:%s lock_san lv_offset_from_args error %d %s",
|
||||
ls->name, r->name, rv, r->lv_args);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!added && (rds->rs.disks[0].offset != lock_lv_offset)) {
|
||||
log_debug("S %s R %s lock_san offset old %llu new %llu",
|
||||
log_debug("%s:%s lock_san offset old %llu new %llu",
|
||||
ls->name, r->name,
|
||||
(unsigned long long)rds->rs.disks[0].offset,
|
||||
(unsigned long long)lock_lv_offset);
|
||||
@@ -1729,7 +1723,7 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
|
||||
rs->flags |= SANLK_RES_PERSISTENT;
|
||||
|
||||
log_debug("S %s R %s lock_san %s at %s:%llu",
|
||||
log_debug("%s:%s lock_san %s at %s:%llu",
|
||||
ls->name, r->name, mode_str(ld_mode), rs->disks[0].path,
|
||||
(unsigned long long)rs->disks[0].offset);
|
||||
|
||||
@@ -1744,8 +1738,10 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
|
||||
if (rds->vb)
|
||||
flags |= SANLK_ACQUIRE_LVB;
|
||||
if (adopt)
|
||||
if (adopt_only)
|
||||
flags |= SANLK_ACQUIRE_ORPHAN_ONLY;
|
||||
if (adopt_ok)
|
||||
flags |= SANLK_ACQUIRE_ORPHAN;
|
||||
|
||||
/*
|
||||
* Don't block waiting for a failed lease to expire since it causes
|
||||
@@ -1771,7 +1767,7 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
* a shared lock but the lock is held ex by another host.
|
||||
* There's no point in retrying this case, just return an error.
|
||||
*/
|
||||
log_debug("S %s R %s lock_san acquire mode %d rv EAGAIN", ls->name, r->name, ld_mode);
|
||||
log_debug("%s:%s lock_san acquire mode %d rv EAGAIN", ls->name, r->name, ld_mode);
|
||||
*retry = 0;
|
||||
return -EAGAIN;
|
||||
}
|
||||
@@ -1785,31 +1781,31 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
* The lvm command will see this error, refresh the lvmlock
|
||||
* lv, and try again.
|
||||
*/
|
||||
log_debug("S %s R %s lock_san acquire offset %llu rv EMSGSIZE",
|
||||
log_debug("%s:%s lock_san acquire offset %llu rv EMSGSIZE",
|
||||
ls->name, r->name, (unsigned long long)rs->disks[0].offset);
|
||||
*retry = 0;
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
if (adopt && (rv == -EUCLEAN)) {
|
||||
if ((adopt_only || adopt_ok) && (rv == -EUCLEAN)) {
|
||||
/*
|
||||
* The orphan lock exists but in a different mode than we asked
|
||||
* for, so the caller should try again with the other mode.
|
||||
*/
|
||||
log_debug("S %s R %s lock_san adopt mode %d try other mode",
|
||||
log_debug("%s:%s lock_san adopt mode %d try other mode",
|
||||
ls->name, r->name, ld_mode);
|
||||
*retry = 0;
|
||||
return -EUCLEAN;
|
||||
return -EADOPT_RETRY;
|
||||
}
|
||||
|
||||
if (adopt && (rv == -ENOENT)) {
|
||||
if (adopt_only && (rv == -ENOENT)) {
|
||||
/*
|
||||
* No orphan lock exists.
|
||||
*/
|
||||
log_debug("S %s R %s lock_san adopt mode %d no orphan found",
|
||||
log_debug("%s:%s lock_san adopt_only mode %d no orphan found",
|
||||
ls->name, r->name, ld_mode);
|
||||
*retry = 0;
|
||||
return -ENOENT;
|
||||
return -EADOPT_NONE;
|
||||
}
|
||||
|
||||
if (rv == SANLK_ACQUIRE_IDLIVE || rv == SANLK_ACQUIRE_OWNED || rv == SANLK_ACQUIRE_OTHER) {
|
||||
@@ -1828,7 +1824,7 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
* so if requesting a sh lock, retry a couple times,
|
||||
* otherwise don't.
|
||||
*/
|
||||
log_debug("S %s R %s lock_san acquire mode %d rv %d", ls->name, r->name, ld_mode, rv);
|
||||
log_debug("%s:%s lock_san acquire mode %d rv %d", ls->name, r->name, ld_mode, rv);
|
||||
*retry = (ld_mode == LD_LK_SH) ? 1 : 0;
|
||||
return -EAGAIN;
|
||||
}
|
||||
@@ -1838,7 +1834,7 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
* sanlock got an i/o timeout when trying to acquire the
|
||||
* lease on disk.
|
||||
*/
|
||||
log_debug("S %s R %s lock_san acquire mode %d rv %d", ls->name, r->name, ld_mode, rv);
|
||||
log_debug("%s:%s lock_san acquire mode %d rv %d", ls->name, r->name, ld_mode, rv);
|
||||
*retry = 0;
|
||||
return -EAGAIN;
|
||||
}
|
||||
@@ -1848,7 +1844,7 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
* There was contention with another host for the lease,
|
||||
* and we lost.
|
||||
*/
|
||||
log_debug("S %s R %s lock_san acquire mode %d rv %d", ls->name, r->name, ld_mode, rv);
|
||||
log_debug("%s:%s lock_san acquire mode %d rv %d", ls->name, r->name, ld_mode, rv);
|
||||
*retry = 0;
|
||||
return -EAGAIN;
|
||||
}
|
||||
@@ -1867,19 +1863,19 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
* command can print an different error indicating that the
|
||||
* owner of the lease is in the process of expiring?
|
||||
*/
|
||||
log_debug("S %s R %s lock_san acquire mode %d rv %d", ls->name, r->name, ld_mode, rv);
|
||||
log_debug("%s:%s lock_san acquire mode %d rv %d", ls->name, r->name, ld_mode, rv);
|
||||
*retry = 0;
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s lock_san acquire error %d",
|
||||
log_error("%s:%s lock_san acquire error %d",
|
||||
ls->name, r->name, rv);
|
||||
|
||||
/* if the gl has been disabled, remove and free the gl resource */
|
||||
if ((rv == SANLK_LEADER_RESOURCE) && (r->type == LD_RT_GL)) {
|
||||
if (!lm_gl_is_enabled(ls)) {
|
||||
log_error("S %s R %s lock_san gl has been disabled",
|
||||
log_error("%s:%s lock_san gl has been disabled",
|
||||
ls->name, r->name);
|
||||
if (!strcmp(gl_lsname_sanlock, ls->name))
|
||||
memset(gl_lsname_sanlock, 0, sizeof(gl_lsname_sanlock));
|
||||
@@ -1892,7 +1888,7 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
|
||||
/* sanlock gets i/o errors trying to read/write the leases. */
|
||||
if (rv == -EIO)
|
||||
rv = -ELOCKIO;
|
||||
return -ELOCKIO;
|
||||
|
||||
/*
|
||||
* The sanlock lockspace can disappear if the lease storage fails,
|
||||
@@ -1901,7 +1897,11 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
* stop and free the lockspace.
|
||||
*/
|
||||
if (rv == -ENOSPC)
|
||||
rv = -ELOCKIO;
|
||||
return -ELOCKIO;
|
||||
|
||||
/* The request conflicted with an orphan lock. */
|
||||
if (rv == -EUCLEAN)
|
||||
return -EORPHAN;
|
||||
|
||||
/*
|
||||
* generic error number for sanlock errors that we are not
|
||||
@@ -1917,7 +1917,7 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
if (rds->vb) {
|
||||
rv = sanlock_get_lvb(0, rs, (char *)&vb, sizeof(vb));
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s lock_san get_lvb error %d", ls->name, r->name, rv);
|
||||
log_error("%s:%s lock_san get_lvb error %d", ls->name, r->name, rv);
|
||||
memset(rds->vb, 0, sizeof(struct val_blk));
|
||||
memset(vb_out, 0, sizeof(struct val_blk));
|
||||
/* the lock is still acquired, the vb values considered invalid */
|
||||
@@ -1952,7 +1952,7 @@ int lm_convert_sanlock(struct lockspace *ls, struct resource *r,
|
||||
uint32_t flags = 0;
|
||||
int rv;
|
||||
|
||||
log_debug("S %s R %s convert_san %s to %s",
|
||||
log_debug("%s:%s convert_san %s to %s",
|
||||
ls->name, r->name, mode_str(r->mode), mode_str(ld_mode));
|
||||
|
||||
if (daemon_test)
|
||||
@@ -1967,12 +1967,12 @@ int lm_convert_sanlock(struct lockspace *ls, struct resource *r,
|
||||
rds->vb->r_version = cpu_to_le32(r_version);
|
||||
memcpy(&vb, rds->vb, sizeof(vb));
|
||||
|
||||
log_debug("S %s R %s convert_san set r_version %u",
|
||||
log_debug("%s:%s convert_san set r_version %u",
|
||||
ls->name, r->name, r_version);
|
||||
|
||||
rv = sanlock_set_lvb(0, rs, (char *)&vb, sizeof(vb));
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s convert_san set_lvb error %d",
|
||||
log_error("%s:%s convert_san set_lvb error %d",
|
||||
ls->name, r->name, rv);
|
||||
return -ELMERR;
|
||||
}
|
||||
@@ -2011,10 +2011,10 @@ int lm_convert_sanlock(struct lockspace *ls, struct resource *r,
|
||||
case SANLK_DBLOCK_LVER:
|
||||
case SANLK_DBLOCK_MBAL:
|
||||
/* expected errors from known/normal cases like lock contention or io timeouts */
|
||||
log_debug("S %s R %s convert_san error %d", ls->name, r->name, rv);
|
||||
log_debug("%s:%s convert_san error %d", ls->name, r->name, rv);
|
||||
return -EAGAIN;
|
||||
default:
|
||||
log_error("S %s R %s convert_san convert error %d", ls->name, r->name, rv);
|
||||
log_error("%s:%s convert_san convert error %d", ls->name, r->name, rv);
|
||||
rv = -ELMERR;
|
||||
}
|
||||
|
||||
@@ -2032,7 +2032,7 @@ static int release_rename(struct lockspace *ls, struct resource *r)
|
||||
struct rd_sanlock *rds = (struct rd_sanlock *)r->lm_data;
|
||||
int rv;
|
||||
|
||||
log_debug("S %s R %s release rename", ls->name, r->name);
|
||||
log_debug("%s:%s release rename", ls->name, r->name);
|
||||
|
||||
res_args = malloc(2 * sizeof(struct sanlk_resource *));
|
||||
if (!res_args)
|
||||
@@ -2044,14 +2044,14 @@ static int release_rename(struct lockspace *ls, struct resource *r)
|
||||
res1 = (struct sanlk_resource *)&rd1;
|
||||
res2 = (struct sanlk_resource *)&rd2;
|
||||
|
||||
strcpy_name_len(res2->name, (char *)"invalid_removed", SANLK_NAME_LEN);
|
||||
strcpy_name_len(res2->name, "invalid_removed", SANLK_NAME_LEN);
|
||||
|
||||
res_args[0] = res1;
|
||||
res_args[1] = res2;
|
||||
|
||||
rv = sanlock_release(lms->sock, -1, SANLK_REL_RENAME, 2, res_args);
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s unlock_san release rename error %d", ls->name, r->name, rv);
|
||||
log_error("%s:%s unlock_san release rename error %d", ls->name, r->name, rv);
|
||||
rv = -ELMERR;
|
||||
}
|
||||
|
||||
@@ -2080,7 +2080,7 @@ int lm_unlock_sanlock(struct lockspace *ls, struct resource *r,
|
||||
struct val_blk vb;
|
||||
int rv;
|
||||
|
||||
log_debug("S %s R %s unlock_san %s r_version %u flags %x",
|
||||
log_debug("%s:%s unlock_san %s r_version %u flags %x",
|
||||
ls->name, r->name, mode_str(r->mode), r_version, lmu_flags);
|
||||
|
||||
if (daemon_test) {
|
||||
@@ -2102,12 +2102,12 @@ int lm_unlock_sanlock(struct lockspace *ls, struct resource *r,
|
||||
rds->vb->r_version = cpu_to_le32(r_version);
|
||||
memcpy(&vb, rds->vb, sizeof(vb));
|
||||
|
||||
log_debug("S %s R %s unlock_san set r_version %u",
|
||||
log_debug("%s:%s unlock_san set r_version %u",
|
||||
ls->name, r->name, r_version);
|
||||
|
||||
rv = sanlock_set_lvb(0, rs, (char *)&vb, sizeof(vb));
|
||||
if (rv < 0) {
|
||||
log_error("S %s R %s unlock_san set_lvb error %d",
|
||||
log_error("%s:%s unlock_san set_lvb error %d",
|
||||
ls->name, r->name, rv);
|
||||
return -ELMERR;
|
||||
}
|
||||
@@ -2124,7 +2124,7 @@ int lm_unlock_sanlock(struct lockspace *ls, struct resource *r,
|
||||
|
||||
rv = sanlock_release(lms->sock, -1, 0, 1, &rs);
|
||||
if (rv < 0)
|
||||
log_error("S %s R %s unlock_san release error %d", ls->name, r->name, rv);
|
||||
log_error("%s:%s unlock_san release error %d", ls->name, r->name, rv);
|
||||
|
||||
/*
|
||||
* sanlock may return an error here if it fails to release the lease on
|
||||
|
||||
@@ -32,11 +32,11 @@ LDFLAGS += $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
|
||||
LIBS += $(DAEMON_LIBS) $(PTHREAD_LIBS)
|
||||
|
||||
lvmpolld: $(OBJECTS) $(top_builddir)/libdaemon/server/libdaemonserver.a $(INTERNAL_LIBS)
|
||||
@echo " [CC] $@"
|
||||
$(SHOW) " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
|
||||
|
||||
install_lvmpolld: lvmpolld
|
||||
@echo " [INSTALL] $<"
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
|
||||
|
||||
install_lvm2: install_lvmpolld
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#define MIN_ARGV_SIZE 8
|
||||
|
||||
static const char *const polling_ops[] = {
|
||||
static const char *const _polling_ops[] = {
|
||||
[PVMOVE] = LVMPD_REQ_PVMOVE,
|
||||
[CONVERT] = LVMPD_REQ_CONVERT,
|
||||
[MERGE] = LVMPD_REQ_MERGE,
|
||||
@@ -28,7 +28,7 @@ static const char *const polling_ops[] = {
|
||||
|
||||
const char *polling_op(enum poll_type type)
|
||||
{
|
||||
return type < POLL_TYPE_MAX ? polling_ops[type] : "<undefined>";
|
||||
return type < POLL_TYPE_MAX ? _polling_ops[type] : "<undefined>";
|
||||
}
|
||||
|
||||
static int add_to_cmd_arr(const char ***cmdargv, const char *str, unsigned *ind)
|
||||
@@ -81,7 +81,7 @@ const char **cmdargv_ctr(const struct lvmpolld_lv *pdlv, const char *lvm_binary,
|
||||
|
||||
/* one of: "convert", "pvmove", "merge", "merge_thin" */
|
||||
if (!add_to_cmd_arr(&cmd_argv, "--polloperation", &i) ||
|
||||
!add_to_cmd_arr(&cmd_argv, polling_ops[pdlv->type], &i))
|
||||
!add_to_cmd_arr(&cmd_argv, _polling_ops[pdlv->type], &i))
|
||||
goto err;
|
||||
|
||||
/* vg/lv name */
|
||||
|
||||
@@ -781,7 +781,7 @@ struct log_line_baton {
|
||||
const char *prefix;
|
||||
};
|
||||
|
||||
daemon_handle _lvmpolld = { .error = 0 };
|
||||
static daemon_handle _lvmpolld = { .error = 0 };
|
||||
|
||||
static daemon_handle _lvmpolld_open(const char *socket)
|
||||
{
|
||||
@@ -867,14 +867,14 @@ enum action_index {
|
||||
ACTION_MAX /* keep at the end */
|
||||
};
|
||||
|
||||
static const action_fn_t actions[ACTION_MAX] = { [ACTION_DUMP] = action_dump };
|
||||
|
||||
static int _make_action(enum action_index idx, void *args)
|
||||
{
|
||||
return idx < ACTION_MAX ? actions[idx](args) : 0;
|
||||
static const action_fn_t _actions[ACTION_MAX] = { [ACTION_DUMP] = action_dump };
|
||||
|
||||
return idx < ACTION_MAX ? _actions[idx](args) : 0;
|
||||
}
|
||||
|
||||
static int _lvmpolld_client(const char *socket, unsigned action)
|
||||
static int _lvmpolld_client(const char *socket, enum action_index action)
|
||||
{
|
||||
int r;
|
||||
|
||||
@@ -892,10 +892,9 @@ static int _lvmpolld_client(const char *socket, unsigned action)
|
||||
return r ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
static int action_idx = ACTION_MAX;
|
||||
static struct option long_options[] = {
|
||||
static const struct option _long_options[] = {
|
||||
/* Have actions always at the beginning of the array. */
|
||||
{"dump", no_argument, &action_idx, ACTION_DUMP }, /* or an option_index ? */
|
||||
{"dump", no_argument, 0, ACTION_DUMP }, /* or an option_index ? */
|
||||
|
||||
/* other options */
|
||||
{"binary", required_argument, 0, 'B' },
|
||||
@@ -914,7 +913,7 @@ int main(int argc, char *argv[])
|
||||
int opt;
|
||||
int option_index = 0;
|
||||
int client = 0, server = 0;
|
||||
unsigned action = ACTION_MAX;
|
||||
enum action_index action = ACTION_MAX;
|
||||
struct timespec timeout;
|
||||
daemon_idle di = { .ptimeout = &timeout };
|
||||
struct lvmpolld_state ls = { .log_config = "" };
|
||||
@@ -930,16 +929,16 @@ int main(int argc, char *argv[])
|
||||
.socket_path = getenv("LVM_LVMPOLLD_SOCKET") ?: LVMPOLLD_SOCKET,
|
||||
};
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "fhVl:p:s:B:t:", long_options, &option_index)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "fhVl:p:s:B:t:", _long_options, &option_index)) != -1) {
|
||||
switch (opt) {
|
||||
case 0 :
|
||||
if (action < ACTION_MAX) {
|
||||
if (action != ACTION_MAX) {
|
||||
fprintf(stderr, "Can't perform more actions. Action already requested: %s\n",
|
||||
long_options[action].name);
|
||||
_long_options[action].name);
|
||||
_usage(argv[0], stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
action = action_idx;
|
||||
action = ACTION_DUMP;
|
||||
client = 1;
|
||||
break;
|
||||
case '?':
|
||||
|
||||
@@ -46,12 +46,12 @@ struct lvmpolld_lv {
|
||||
* require struct lvmpolld_lv lock
|
||||
*/
|
||||
struct lvmpolld_state *ls;
|
||||
const enum poll_type type;
|
||||
enum poll_type type;
|
||||
const char *lvid;
|
||||
const char *lvmpolld_id;
|
||||
const char *devicesfile;
|
||||
const char *lvname; /* full vg/lv name */
|
||||
const unsigned pdtimeout; /* in seconds */
|
||||
unsigned pdtimeout; /* in seconds */
|
||||
const char *sinterval;
|
||||
const char *lvm_system_dir_env;
|
||||
struct lvmpolld_store *pdst;
|
||||
@@ -66,7 +66,7 @@ struct lvmpolld_lv {
|
||||
|
||||
/* block of shared variables protected by lock */
|
||||
struct lvmpolld_cmd_stat cmd_state;
|
||||
unsigned init_rq_count; /* for debuging purposes only */
|
||||
unsigned init_rq_count; /* for debugging purposes only */
|
||||
unsigned polling_finished:1; /* no more updates */
|
||||
unsigned error:1; /* unrecoverable error occured in lvmpolld */
|
||||
};
|
||||
|
||||
@@ -44,10 +44,10 @@ CLEAN_TARGETS += $(DEVICE_MAPPER_DEPENDS) $(DEVICE_MAPPER_OBJECTS) \
|
||||
#$(DEVICE_MAPPER_OBJECTS): INCLUDES+=$(VDO_INCLUDES)
|
||||
|
||||
$(DEVICE_MAPPER_TARGET): $(DEVICE_MAPPER_OBJECTS)
|
||||
@echo " [AR] $@"
|
||||
$(SHOW) " [AR] $@"
|
||||
$(Q) $(RM) $@
|
||||
$(Q) $(AR) rsv $@ $(DEVICE_MAPPER_OBJECTS) > /dev/null
|
||||
|
||||
ifeq ("$(DEPENDS)","yes")
|
||||
ifeq ("$(USE_TRACKING)","yes")
|
||||
-include $(DEVICE_MAPPER_DEPENDS)
|
||||
endif
|
||||
|
||||
@@ -175,12 +175,11 @@ struct dm_names {
|
||||
|
||||
struct dm_active_device {
|
||||
struct dm_list list;
|
||||
int major;
|
||||
int minor;
|
||||
char *name; /* device name */
|
||||
dev_t devno;
|
||||
const char *name; /* device name */
|
||||
|
||||
uint32_t event_nr; /* valid when DM_DEVICE_LIST_HAS_EVENT_NR is set */
|
||||
char *uuid; /* valid uuid when DM_DEVICE_LIST_HAS_UUID is set */
|
||||
const char *uuid; /* valid uuid when DM_DEVICE_LIST_HAS_UUID is set */
|
||||
};
|
||||
|
||||
struct dm_versions {
|
||||
@@ -230,13 +229,6 @@ struct dm_names *dm_task_get_names(struct dm_task *dmt);
|
||||
#define DM_DEVICE_LIST_HAS_UUID 2
|
||||
int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
unsigned *devs_features);
|
||||
/*
|
||||
* -1: no idea about uuid (not provided by DM_DEVICE_LIST ioctl)
|
||||
* 0: uuid not present
|
||||
* 1: listed and dm_active_device will be set for not NULL pointer
|
||||
*/
|
||||
int dm_device_list_find_by_uuid(struct dm_list *devs_list, const char *uuid,
|
||||
const struct dm_active_device **dev);
|
||||
/* Release all associated memory with list of active DM devices */
|
||||
void dm_device_list_destroy(struct dm_list **devs_list);
|
||||
|
||||
@@ -1875,6 +1867,7 @@ const void *dm_report_value_cache_get(struct dm_report *rh, const char *name);
|
||||
#define DM_REPORT_OUTPUT_FIELD_UNQUOTED 0x00000010
|
||||
#define DM_REPORT_OUTPUT_COLUMNS_AS_ROWS 0x00000020
|
||||
#define DM_REPORT_OUTPUT_MULTIPLE_TIMES 0x00000040
|
||||
#define DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS 0x00000080
|
||||
|
||||
struct dm_report *dm_report_init(uint32_t *report_types,
|
||||
const struct dm_report_object_type *types,
|
||||
@@ -2243,7 +2236,7 @@ struct dm_pool *dm_config_memory(struct dm_config_tree *cft);
|
||||
int dm_cookie_supported(void);
|
||||
|
||||
/*
|
||||
* Udev synchronisation functions.
|
||||
* Udev synchronization functions.
|
||||
*/
|
||||
void dm_udev_set_sync_support(int sync_with_udev);
|
||||
int dm_udev_get_sync_support(void);
|
||||
|
||||
@@ -87,10 +87,8 @@ static int _version_checked = 0;
|
||||
static int _version_ok = 1;
|
||||
static unsigned _ioctl_buffer_double_factor = 0;
|
||||
|
||||
const int _dm_compat = 0;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static struct cmd_data _cmd_data_v4[] = {
|
||||
static const struct cmd_data _cmd_data_v4[] = {
|
||||
{"create", DM_DEV_CREATE, {4, 0, 0}},
|
||||
{"reload", DM_TABLE_LOAD, {4, 0, 0}},
|
||||
{"remove", DM_DEV_REMOVE, {4, 0, 0}},
|
||||
@@ -200,6 +198,7 @@ static int _get_proc_number(const char *file, const char *name,
|
||||
char *line = NULL;
|
||||
size_t len;
|
||||
uint32_t num;
|
||||
unsigned blocksection = (strcmp(file, PROC_DEVICES) == 0) ? 0 : 1;
|
||||
|
||||
if (!(fl = fopen(file, "r"))) {
|
||||
log_sys_error("fopen", file);
|
||||
@@ -207,7 +206,9 @@ static int _get_proc_number(const char *file, const char *name,
|
||||
}
|
||||
|
||||
while (getline(&line, &len, fl) != -1) {
|
||||
if (sscanf(line, "%u %255s\n", &num, &nm[0]) == 2) {
|
||||
if (!blocksection && (line[0] == 'B'))
|
||||
blocksection = 1;
|
||||
else if (sscanf(line, "%u %255s\n", &num, &nm[0]) == 2) {
|
||||
if (!strcmp(name, nm)) {
|
||||
if (number) {
|
||||
*number = num;
|
||||
@@ -247,6 +248,16 @@ static int _control_device_number(uint32_t *major, uint32_t *minor)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _control_unlink(const char *control)
|
||||
{
|
||||
if (unlink(control) && (errno != ENOENT)) {
|
||||
log_sys_error("unlink", control);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns 1 if it exists on returning; 0 if it doesn't; -1 if it's wrong.
|
||||
*/
|
||||
@@ -262,10 +273,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
|
||||
|
||||
if (!S_ISCHR(buf.st_mode)) {
|
||||
log_verbose("%s: Wrong inode type", control);
|
||||
if (!unlink(control))
|
||||
return 0;
|
||||
log_sys_error("unlink", control);
|
||||
return -1;
|
||||
return _control_unlink(control);
|
||||
}
|
||||
|
||||
if (major && buf.st_rdev != MKDEV(major, minor)) {
|
||||
@@ -273,10 +281,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
|
||||
"(%u, %u)", control,
|
||||
MAJOR(buf.st_mode), MINOR(buf.st_mode),
|
||||
major, minor);
|
||||
if (!unlink(control))
|
||||
return 0;
|
||||
log_sys_error("unlink", control);
|
||||
return -1;
|
||||
return _control_unlink(control);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -404,7 +409,7 @@ static void _close_control_fd(void)
|
||||
{
|
||||
if (_control_fd != -1) {
|
||||
if (close(_control_fd) < 0)
|
||||
log_sys_error("close", "_control_fd");
|
||||
log_sys_debug("close", "_control_fd");
|
||||
_control_fd = -1;
|
||||
}
|
||||
}
|
||||
@@ -593,23 +598,9 @@ int dm_check_version(void)
|
||||
|
||||
_version_checked = 1;
|
||||
|
||||
if (_check_version(dmversion, sizeof(dmversion), _dm_compat))
|
||||
if (_check_version(dmversion, sizeof(dmversion), 0))
|
||||
return 1;
|
||||
|
||||
if (!_dm_compat)
|
||||
goto_bad;
|
||||
|
||||
log_verbose("device-mapper ioctl protocol version %u failed. "
|
||||
"Trying protocol version 1.", _dm_version);
|
||||
_dm_version = 1;
|
||||
if (_check_version(dmversion, sizeof(dmversion), 0)) {
|
||||
log_verbose("Using device-mapper ioctl protocol version 1");
|
||||
return 1;
|
||||
}
|
||||
|
||||
compat = "(compat)";
|
||||
|
||||
bad:
|
||||
dm_get_library_version(libversion, sizeof(libversion));
|
||||
|
||||
log_error("Incompatible libdevmapper %s%s and kernel driver %s.",
|
||||
@@ -757,6 +748,11 @@ uint32_t dm_task_get_read_ahead(const struct dm_task *dmt, uint32_t *read_ahead)
|
||||
|
||||
struct dm_deps *dm_task_get_deps(struct dm_task *dmt)
|
||||
{
|
||||
if (!dmt) {
|
||||
log_error(INTERNAL_ERROR "Missing dm_task.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (struct dm_deps *) (((char *) dmt->dmi.v4) +
|
||||
dmt->dmi.v4->data_start);
|
||||
}
|
||||
@@ -786,19 +782,12 @@ static int _check_has_event_nr(void) {
|
||||
return _has_event_nr;
|
||||
}
|
||||
|
||||
struct dm_device_list {
|
||||
struct dm_list list;
|
||||
unsigned count;
|
||||
unsigned features;
|
||||
struct dm_hash_table *uuids;
|
||||
};
|
||||
|
||||
int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
unsigned *devs_features)
|
||||
{
|
||||
struct dm_names *names, *names1;
|
||||
struct dm_active_device *dm_dev, *dm_new_dev;
|
||||
struct dm_device_list *devs;
|
||||
struct dm_list *devs;
|
||||
unsigned next = 0;
|
||||
uint32_t *event_nr;
|
||||
char *uuid_ptr;
|
||||
@@ -819,12 +808,12 @@ int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
} while (next);
|
||||
}
|
||||
|
||||
if (!(devs = malloc(sizeof(*devs) + (cnt ? cnt * sizeof(*dm_dev) + (char*)names1 - (char*)names + 256 : 0))))
|
||||
/* buffer for devs + sorted ptrs + dm_devs + aligned strings */
|
||||
if (!(devs = malloc(sizeof(*devs) + cnt * (2 * sizeof(void*) + sizeof(*dm_dev)) +
|
||||
(cnt ? (char*)names1 - (char*)names + 256 : 0))))
|
||||
return_0;
|
||||
|
||||
dm_list_init(&devs->list);
|
||||
devs->count = cnt;
|
||||
devs->uuids = NULL;
|
||||
dm_list_init(devs);
|
||||
|
||||
if (!cnt) {
|
||||
/* nothing in the list -> mark all features present */
|
||||
@@ -832,27 +821,22 @@ int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
goto out; /* nothing else to do */
|
||||
}
|
||||
|
||||
dm_dev = (struct dm_active_device *) (devs + 1);
|
||||
/* Shift position where to store individual dm_devs */
|
||||
dm_dev = (struct dm_active_device *) ((long*) (devs + 1) + cnt);
|
||||
|
||||
do {
|
||||
names = (struct dm_names *)((char *) names + next);
|
||||
|
||||
dm_dev->major = MAJOR(names->dev);
|
||||
dm_dev->minor = MINOR(names->dev);
|
||||
dm_dev->name = (char*)(dm_dev + 1);
|
||||
dm_dev->devno = (dev_t) names->dev;
|
||||
dm_dev->name = (const char *)(dm_dev + 1);
|
||||
dm_dev->event_nr = 0;
|
||||
dm_dev->uuid = NULL;
|
||||
dm_dev->uuid = "";
|
||||
|
||||
len = strlen(names->name) + 1;
|
||||
memcpy(dm_dev->name, names->name, len);
|
||||
memcpy((char*)dm_dev->name, names->name, len);
|
||||
|
||||
dm_new_dev = _align_ptr((char*)(dm_dev + 1) + len);
|
||||
if (_check_has_event_nr()) {
|
||||
/* Hash for UUIDs with some more bits to reduce colision count */
|
||||
if (!devs->uuids && !(devs->uuids = dm_hash_create(cnt * 8))) {
|
||||
free(devs);
|
||||
return_0;
|
||||
}
|
||||
|
||||
*devs_features |= DM_DEVICE_LIST_HAS_EVENT_NR;
|
||||
event_nr = _align_ptr(names->name + len);
|
||||
@@ -861,55 +845,29 @@ int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
if ((event_nr[1] & DM_NAME_LIST_FLAG_HAS_UUID)) {
|
||||
*devs_features |= DM_DEVICE_LIST_HAS_UUID;
|
||||
uuid_ptr = _align_ptr(event_nr + 2);
|
||||
dm_dev->uuid = (char*) dm_new_dev;
|
||||
len = strlen(uuid_ptr) + 1;
|
||||
memcpy(dm_new_dev, uuid_ptr, len);
|
||||
dm_dev->uuid = (const char *) dm_new_dev;
|
||||
dm_new_dev = _align_ptr((char*)dm_new_dev + len);
|
||||
memcpy(dm_dev->uuid, uuid_ptr, len);
|
||||
if (!dm_hash_insert(devs->uuids, dm_dev->uuid, dm_dev))
|
||||
return_0; // FIXME
|
||||
#if 0
|
||||
log_debug("Active %s (%s) %d:%d event:%u",
|
||||
dm_dev->name, dm_dev->uuid,
|
||||
dm_dev->major, dm_dev->minor, dm_dev->event_nr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
dm_list_add(&devs->list, &dm_dev->list);
|
||||
dm_list_add(devs, &dm_dev->list);
|
||||
dm_dev = dm_new_dev;
|
||||
next = names->next;
|
||||
} while (next);
|
||||
|
||||
out:
|
||||
*devs_list = (struct dm_list *)devs;
|
||||
*devs_list = devs;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dm_device_list_find_by_uuid(struct dm_list *devs_list, const char *uuid,
|
||||
const struct dm_active_device **dev)
|
||||
{
|
||||
struct dm_device_list *devs = (struct dm_device_list *) devs_list;
|
||||
struct dm_active_device *dm_dev;
|
||||
|
||||
if (devs->uuids &&
|
||||
(dm_dev = dm_hash_lookup(devs->uuids, uuid))) {
|
||||
if (dev)
|
||||
*dev = dm_dev;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dm_device_list_destroy(struct dm_list **devs_list)
|
||||
{
|
||||
struct dm_device_list *devs = (struct dm_device_list *) *devs_list;
|
||||
|
||||
if (devs) {
|
||||
if (devs->uuids)
|
||||
dm_hash_destroy(devs->uuids);
|
||||
|
||||
free(devs);
|
||||
*devs_list = NULL;
|
||||
}
|
||||
@@ -1256,7 +1214,7 @@ static int _lookup_dev_name(uint64_t dev, char *buf, size_t len)
|
||||
do {
|
||||
names = (struct dm_names *)((char *) names + next);
|
||||
if (names->dev == dev) {
|
||||
strncpy(buf, names->name, len);
|
||||
memccpy(buf, names->name, 0, len);
|
||||
r = 1;
|
||||
break;
|
||||
}
|
||||
@@ -1425,12 +1383,10 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||
/* FIXME Until resume ioctl supplies name, use dev_name for readahead */
|
||||
if (DEV_NAME(dmt) && (dmt->type != DM_DEVICE_RESUME || dmt->minor < 0 ||
|
||||
dmt->major < 0))
|
||||
/* coverity[buffer_size_warning] */
|
||||
strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
|
||||
memccpy(dmi->name, DEV_NAME(dmt), 0, sizeof(dmi->name));
|
||||
|
||||
if (DEV_UUID(dmt))
|
||||
/* coverity[buffer_size_warning] */
|
||||
strncpy(dmi->uuid, DEV_UUID(dmt), sizeof(dmi->uuid));
|
||||
memccpy(dmi->uuid, DEV_UUID(dmt), 0, sizeof(dmi->uuid));
|
||||
|
||||
if (dmt->type == DM_DEVICE_SUSPEND)
|
||||
dmi->flags |= DM_SUSPEND_FLAG;
|
||||
@@ -1620,7 +1576,7 @@ static int _check_uevent_generated(struct dm_ioctl *dmi)
|
||||
static int _create_and_load_v4(struct dm_task *dmt)
|
||||
{
|
||||
struct dm_task *task;
|
||||
int r;
|
||||
int r, ioctl_errno = 0;
|
||||
uint32_t cookie;
|
||||
|
||||
/* Use new task struct to create the device */
|
||||
@@ -1646,8 +1602,10 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
task->cookie_set = dmt->cookie_set;
|
||||
task->add_node = dmt->add_node;
|
||||
|
||||
if (!dm_task_run(task))
|
||||
if (!dm_task_run(task)) {
|
||||
ioctl_errno = task->ioctl_errno;
|
||||
goto_bad;
|
||||
}
|
||||
|
||||
dm_task_destroy(task);
|
||||
|
||||
@@ -1673,6 +1631,8 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
task->ima_measurement = dmt->ima_measurement;
|
||||
|
||||
r = dm_task_run(task);
|
||||
if (!r)
|
||||
ioctl_errno = task->ioctl_errno;
|
||||
|
||||
task->head = NULL;
|
||||
task->tail = NULL;
|
||||
@@ -1690,6 +1650,7 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
dmt->uuid = NULL;
|
||||
free(dmt->mangled_uuid);
|
||||
dmt->mangled_uuid = NULL;
|
||||
/* coverity[double_free] recursive function call */
|
||||
_dm_task_free_targets(dmt);
|
||||
|
||||
if (dm_task_run(dmt))
|
||||
@@ -1701,6 +1662,7 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
dmt->uuid = NULL;
|
||||
free(dmt->mangled_uuid);
|
||||
dmt->mangled_uuid = NULL;
|
||||
/* coverity[double_free] recursive function call */
|
||||
_dm_task_free_targets(dmt);
|
||||
|
||||
/*
|
||||
@@ -1719,12 +1681,18 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
if (!dm_task_run(dmt))
|
||||
log_error("Failed to revert device creation.");
|
||||
|
||||
if (ioctl_errno != 0)
|
||||
dmt->ioctl_errno = ioctl_errno;
|
||||
|
||||
return 0;
|
||||
|
||||
bad:
|
||||
dm_task_destroy(task);
|
||||
_udev_complete(dmt);
|
||||
|
||||
if (ioctl_errno != 0)
|
||||
dmt->ioctl_errno = ioctl_errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2066,7 +2034,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
||||
/*
|
||||
* Prevent udev vs. libdevmapper race when processing nodes
|
||||
* and symlinks. This can happen when the udev rules are
|
||||
* installed and udev synchronisation code is enabled in
|
||||
* installed and udev synchronization code is enabled in
|
||||
* libdevmapper but the software using libdevmapper does not
|
||||
* make use of it (by not calling dm_task_set_cookie before).
|
||||
* We need to instruct the udev rules not to be applied at
|
||||
@@ -2076,7 +2044,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
||||
if (!dmt->cookie_set && dm_udev_get_sync_support()) {
|
||||
log_debug_activation("Cookie value is not set while trying to call %s "
|
||||
"ioctl. Please, consider using libdevmapper's udev "
|
||||
"synchronisation interface or disable it explicitly "
|
||||
"synchronization interface or disable it explicitly "
|
||||
"by calling dm_udev_set_sync_support(0).",
|
||||
dmt->type == DM_DEVICE_RESUME ? "DM_DEVICE_RESUME" :
|
||||
dmt->type == DM_DEVICE_REMOVE ? "DM_DEVICE_REMOVE" :
|
||||
|
||||
@@ -79,7 +79,7 @@ struct dm_task {
|
||||
};
|
||||
|
||||
struct cmd_data {
|
||||
const char *name;
|
||||
const char name[16];
|
||||
const unsigned cmd;
|
||||
const int version[3];
|
||||
};
|
||||
|
||||
@@ -537,7 +537,8 @@ int unmangle_string(const char *str, const char *str_name, size_t len,
|
||||
}
|
||||
|
||||
if (str[i] == '\\' && str[i+1] == 'x') {
|
||||
if (!sscanf(&str[i+2], "%2x%s", &code, str_rest)) {
|
||||
if (!sscanf(&str[i+2], "%2x%" DM_TO_STRING(DM_NAME_LEN) "s",
|
||||
&code, str_rest)) {
|
||||
log_debug_activation("Hex encoding mismatch detected in %s \"%s\" "
|
||||
"while trying to unmangle it.", str_name, str);
|
||||
goto out;
|
||||
@@ -1060,9 +1061,8 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
|
||||
if (info.st_rdev == dev)
|
||||
return 1;
|
||||
|
||||
if (unlink(path) < 0) {
|
||||
log_error("Unable to unlink device node for '%s'",
|
||||
dev_name);
|
||||
if (unlink(path) && (errno != ENOENT)) {
|
||||
log_sys_error("unlink", path);
|
||||
return 0;
|
||||
}
|
||||
} else if (_warn_if_op_needed(warn_if_udev_failed))
|
||||
@@ -1106,8 +1106,8 @@ static int _rm_dev_node(const char *dev_name, int warn_if_udev_failed)
|
||||
"Falling back to direct node removal.", path);
|
||||
|
||||
/* udev may already have deleted the node. Ignore ENOENT. */
|
||||
if (unlink(path) < 0 && errno != ENOENT) {
|
||||
log_error("Unable to unlink device node for '%s'", dev_name);
|
||||
if (unlink(path) && (errno != ENOENT)) {
|
||||
log_sys_error("unlink", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1451,9 +1451,10 @@ struct node_op_parms {
|
||||
|
||||
static void _store_str(char **pos, char **ptr, const char *str)
|
||||
{
|
||||
strcpy(*pos, str);
|
||||
size_t len = strlen(str) + 1;
|
||||
memcpy(*pos, str, len);
|
||||
*ptr = *pos;
|
||||
*pos += strlen(*ptr) + 1;
|
||||
*pos += len;
|
||||
}
|
||||
|
||||
static void _del_node_op(struct node_op_parms *nop)
|
||||
@@ -1703,15 +1704,17 @@ const char *dm_sysfs_dir(void)
|
||||
*/
|
||||
int dm_set_uuid_prefix(const char *uuid_prefix)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (!uuid_prefix)
|
||||
return_0;
|
||||
|
||||
if (strlen(uuid_prefix) > DM_MAX_UUID_PREFIX_LEN) {
|
||||
if ((len = strlen(uuid_prefix)) > DM_MAX_UUID_PREFIX_LEN) {
|
||||
log_error("New uuid prefix %s too long.", uuid_prefix);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(_default_uuid_prefix, uuid_prefix);
|
||||
memcpy(_default_uuid_prefix, uuid_prefix, len + 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1740,6 +1743,9 @@ static void _unmangle_mountinfo_string(const char *src, char *buf)
|
||||
*buf = '\0';
|
||||
}
|
||||
|
||||
/* coverity[+tainted_string_sanitize_content:arg-0] */
|
||||
static int _sanitize_line(const char *line) { return 1; }
|
||||
|
||||
/* Parse one line of mountinfo and unmangled target line */
|
||||
static int _mountinfo_parse_line(const char *line, unsigned *maj, unsigned *min, char *buf)
|
||||
{
|
||||
@@ -1810,7 +1816,8 @@ int dm_mountinfo_read(dm_mountinfo_line_callback_fn read_fn, void *cb_data)
|
||||
}
|
||||
|
||||
while (!feof(minfo) && fgets(buffer, sizeof(buffer), minfo))
|
||||
if (!_mountinfo_parse_line(buffer, &maj, &min, target) ||
|
||||
if (!_sanitize_line(buffer) ||
|
||||
!_mountinfo_parse_line(buffer, &maj, &min, target) ||
|
||||
!read_fn(buffer, maj, min, target, cb_data)) {
|
||||
stack;
|
||||
r = 0;
|
||||
@@ -2311,7 +2318,7 @@ static int _check_semaphore_is_supported(void)
|
||||
|
||||
if (maxid < 0) {
|
||||
log_warn("Kernel not configured for semaphores (System V IPC). "
|
||||
"Not using udev synchronisation code.");
|
||||
"Not using udev synchronization code.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2334,7 +2341,7 @@ static int _check_udev_is_running(void)
|
||||
|
||||
if (!(r = udev_queue_get_udev_is_active(udev_queue)))
|
||||
log_debug_activation("Udev is not running. "
|
||||
"Not using udev synchronisation code.");
|
||||
"Not using udev synchronization code.");
|
||||
|
||||
udev_queue_unref(udev_queue);
|
||||
udev_unref(udev);
|
||||
|
||||
@@ -74,8 +74,6 @@ static struct dm_config_node *_create_node(struct dm_pool *mem);
|
||||
static char *_dup_tok(struct parser *p);
|
||||
static char *_dup_token(struct dm_pool *mem, const char *b, const char *e);
|
||||
|
||||
static const int _sep = '/';
|
||||
|
||||
#define MAX_INDENT 32
|
||||
|
||||
#define match(t) do {\
|
||||
@@ -177,19 +175,18 @@ static int _do_dm_config_parse(struct dm_config_tree *cft, const char *start, co
|
||||
{
|
||||
/* TODO? if (start == end) return 1; */
|
||||
|
||||
struct parser *p;
|
||||
if (!(p = dm_pool_zalloc(cft->mem, sizeof(*p))))
|
||||
return_0;
|
||||
struct parser p = {
|
||||
.mem = cft->mem,
|
||||
.tb = start,
|
||||
.te = start,
|
||||
.fb = start,
|
||||
.fe = end,
|
||||
.line = 1,
|
||||
.no_dup_node_check = no_dup_node_check
|
||||
};
|
||||
|
||||
p->mem = cft->mem;
|
||||
p->fb = start;
|
||||
p->fe = end;
|
||||
p->tb = p->te = p->fb;
|
||||
p->line = 1;
|
||||
p->no_dup_node_check = no_dup_node_check;
|
||||
|
||||
_get_token(p, TOK_SECTION_E);
|
||||
if (!(cft->root = _file(p)))
|
||||
_get_token(&p, TOK_SECTION_E);
|
||||
if (!(cft->root = _file(&p)))
|
||||
return_0;
|
||||
|
||||
cft->root = _config_reverse(cft->root);
|
||||
@@ -526,17 +523,18 @@ static struct dm_config_node *_find_or_make_node(struct dm_pool *mem,
|
||||
const char *path,
|
||||
int no_dup_node_check)
|
||||
{
|
||||
const int sep = '/';
|
||||
const char *e;
|
||||
struct dm_config_node *cn = parent ? parent->child : NULL;
|
||||
struct dm_config_node *cn_found = NULL;
|
||||
|
||||
while (cn || mem) {
|
||||
/* trim any leading slashes */
|
||||
while (*path && (*path == _sep))
|
||||
while (*path && (*path == sep))
|
||||
path++;
|
||||
|
||||
/* find the end of this segment */
|
||||
for (e = path; *e && (*e != _sep); e++) ;
|
||||
for (e = path; *e && (*e != sep); e++) ;
|
||||
|
||||
/* hunt for the node */
|
||||
cn_found = NULL;
|
||||
|
||||
@@ -171,7 +171,7 @@ struct load_segment {
|
||||
uint32_t region_size; /* Mirror + raid */
|
||||
unsigned clustered; /* Mirror */
|
||||
unsigned mirror_area_count; /* Mirror */
|
||||
uint32_t flags; /* Mirror + raid + Cache */
|
||||
uint64_t flags; /* Mirror + Raid + Cache */
|
||||
char *uuid; /* Clustered mirror log */
|
||||
|
||||
const char *policy_name; /* Cache */
|
||||
@@ -348,7 +348,7 @@ struct dm_tree {
|
||||
int retry_remove; /* 1 retries remove if not successful */
|
||||
uint32_t cookie;
|
||||
char buf[DM_NAME_LEN + 32]; /* print buffer for device_name (major:minor) */
|
||||
const char **optional_uuid_suffixes; /* uuid suffixes ignored when matching */
|
||||
const char * const *optional_uuid_suffixes; /* uuid suffixes ignored when matching */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -590,6 +590,7 @@ void dm_tree_set_optional_uuid_suffixes(struct dm_tree *dtree, const char **opti
|
||||
dtree->optional_uuid_suffixes = optional_uuid_suffixes;
|
||||
}
|
||||
|
||||
static const char *_node_name(struct dm_tree_node *dnode);
|
||||
static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
|
||||
const char *uuid)
|
||||
{
|
||||
@@ -597,28 +598,26 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
|
||||
const char *default_uuid_prefix;
|
||||
size_t default_uuid_prefix_len;
|
||||
const char *suffix, *suffix_position;
|
||||
char uuid_without_suffix[DM_UUID_LEN];
|
||||
char uuid_without_suffix[DM_UUID_LEN + 1];
|
||||
unsigned i = 0;
|
||||
const char **suffix_list = dtree->optional_uuid_suffixes;
|
||||
const char * const *suffix_list = dtree->optional_uuid_suffixes;
|
||||
|
||||
if ((node = dm_hash_lookup(dtree->uuids, uuid))) {
|
||||
log_debug("Matched uuid %s in deptree.", uuid);
|
||||
log_debug_activation("Matched uuid %s %s in deptree.", uuid, _node_name(node));
|
||||
return node;
|
||||
}
|
||||
|
||||
default_uuid_prefix = dm_uuid_prefix();
|
||||
default_uuid_prefix_len = strlen(default_uuid_prefix);
|
||||
|
||||
if (suffix_list && (suffix_position = strrchr(uuid, '-'))) {
|
||||
while ((suffix = suffix_list[i++])) {
|
||||
if (strcmp(suffix_position + 1, suffix))
|
||||
continue;
|
||||
|
||||
(void) strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
|
||||
dm_strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
|
||||
uuid_without_suffix[suffix_position - uuid] = '\0';
|
||||
|
||||
if ((node = dm_hash_lookup(dtree->uuids, uuid_without_suffix))) {
|
||||
log_debug("Matched uuid %s (missing suffix -%s) in deptree.", uuid_without_suffix, suffix);
|
||||
log_debug_activation("Matched uuid %s %s (missing suffix -%s) in deptree.",
|
||||
uuid_without_suffix, _node_name(node), suffix);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -626,15 +625,17 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
|
||||
};
|
||||
}
|
||||
|
||||
if (strncmp(uuid, default_uuid_prefix, default_uuid_prefix_len))
|
||||
return NULL;
|
||||
default_uuid_prefix = dm_uuid_prefix();
|
||||
default_uuid_prefix_len = strlen(default_uuid_prefix);
|
||||
|
||||
if ((node = dm_hash_lookup(dtree->uuids, uuid + default_uuid_prefix_len))) {
|
||||
log_debug("Matched uuid %s (missing prefix) in deptree.", uuid + default_uuid_prefix_len);
|
||||
if ((strncmp(uuid, default_uuid_prefix, default_uuid_prefix_len) == 0) &&
|
||||
(node = dm_hash_lookup(dtree->uuids, uuid + default_uuid_prefix_len))) {
|
||||
log_debug_activation("Matched uuid %s %s (missing prefix) in deptree.",
|
||||
uuid + default_uuid_prefix_len, _node_name(node));
|
||||
return node;
|
||||
}
|
||||
|
||||
log_debug("Not matched uuid %s in deptree.", uuid);
|
||||
log_debug_activation("Not matched uuid %s in deptree.", uuid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3863,7 +3864,7 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
|
||||
{
|
||||
struct dm_config_node *cn;
|
||||
struct load_segment *seg;
|
||||
static const uint64_t _modemask =
|
||||
const uint64_t modemask =
|
||||
DM_CACHE_FEATURE_PASSTHROUGH |
|
||||
DM_CACHE_FEATURE_WRITETHROUGH |
|
||||
DM_CACHE_FEATURE_WRITEBACK;
|
||||
@@ -3875,12 +3876,12 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (feature_flags & _modemask) {
|
||||
switch (feature_flags & modemask) {
|
||||
case DM_CACHE_FEATURE_PASSTHROUGH:
|
||||
case DM_CACHE_FEATURE_WRITEBACK:
|
||||
if (strcmp(policy_name, "cleaner") == 0) {
|
||||
/* Enforce writethrough mode for cleaner policy */
|
||||
feature_flags = ~_modemask;
|
||||
feature_flags = ~modemask;
|
||||
feature_flags |= DM_CACHE_FEATURE_WRITETHROUGH;
|
||||
}
|
||||
/* Fall through */
|
||||
@@ -4363,6 +4364,12 @@ int dm_tree_node_set_thin_external_origin(struct dm_tree_node *node,
|
||||
|
||||
seg->external = external;
|
||||
|
||||
if (!external->info.minor) {
|
||||
log_debug_activation("Delaying resume for new external origin %s.",
|
||||
external->name);
|
||||
external->props.delay_resume_if_new = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ struct op_def {
|
||||
* shorter one if one is a prefix of another!
|
||||
* (e.g. =~ comes before =)
|
||||
*/
|
||||
static struct op_def _op_cmp[] = {
|
||||
static const struct op_def _op_cmp[] = {
|
||||
{ "=~", FLD_CMP_REGEX, "Matching regular expression. [regex]" },
|
||||
{ "!~", FLD_CMP_REGEX|FLD_CMP_NOT, "Not matching regular expression. [regex]" },
|
||||
{ "=", FLD_CMP_EQUAL, "Equal to. [number, size, percent, string, string list, time]" },
|
||||
@@ -187,7 +187,7 @@ static struct op_def _op_cmp[] = {
|
||||
#define SEL_LIST_SUBSET_LS 0x00040000
|
||||
#define SEL_LIST_SUBSET_LE 0x00080000
|
||||
|
||||
static struct op_def _op_log[] = {
|
||||
static const struct op_def _op_log[] = {
|
||||
{ "&&", SEL_AND, "All fields must match" },
|
||||
{ ",", SEL_AND, "All fields must match" },
|
||||
{ "||", SEL_OR, "At least one field must match" },
|
||||
@@ -796,11 +796,11 @@ static const char *_get_field_type_name(unsigned field_type)
|
||||
static size_t _get_longest_field_id_len(const struct dm_report_field_type *fields)
|
||||
{
|
||||
uint32_t f;
|
||||
size_t id_len = 0;
|
||||
size_t l, id_len = 0;
|
||||
|
||||
for (f = 0; fields[f].report_fn; f++)
|
||||
if (strlen(fields[f].id) > id_len)
|
||||
id_len = strlen(fields[f].id);
|
||||
if ((l = strlen(fields[f].id)) > id_len)
|
||||
id_len = l;
|
||||
|
||||
return id_len;
|
||||
}
|
||||
@@ -811,16 +811,17 @@ static void _display_fields_more(struct dm_report *rh,
|
||||
int display_field_types)
|
||||
{
|
||||
uint32_t f;
|
||||
size_t l;
|
||||
const struct dm_report_object_type *type;
|
||||
const char *desc, *last_desc = "";
|
||||
|
||||
for (f = 0; fields[f].report_fn; f++)
|
||||
if (strlen(fields[f].id) > id_len)
|
||||
id_len = strlen(fields[f].id);
|
||||
if ((l = strlen(fields[f].id)) > id_len)
|
||||
id_len = l;
|
||||
|
||||
for (type = rh->types; type->data_fn; type++)
|
||||
if (strlen(type->prefix) + 3 > id_len)
|
||||
id_len = strlen(type->prefix) + 3;
|
||||
if ((l = strlen(type->prefix) + 3) > id_len)
|
||||
id_len = l;
|
||||
|
||||
for (f = 0; fields[f].report_fn; f++) {
|
||||
if (!(type = _find_type(rh, fields[f].type))) {
|
||||
@@ -964,16 +965,13 @@ static int _get_canonical_field_name(const char *field,
|
||||
* Both names are always null-terminated.
|
||||
*/
|
||||
static int _is_same_field(const char *canonical_name1, const char *canonical_name2,
|
||||
const char *prefix)
|
||||
const char *prefix, size_t prefix_len)
|
||||
{
|
||||
size_t prefix_len;
|
||||
|
||||
/* Exact match? */
|
||||
if (!strcasecmp(canonical_name1, canonical_name2))
|
||||
return 1;
|
||||
|
||||
/* Match including prefix? */
|
||||
prefix_len = strlen(prefix) - 1;
|
||||
if (!strncasecmp(prefix, canonical_name1, prefix_len) &&
|
||||
!strcasecmp(canonical_name1 + prefix_len, canonical_name2))
|
||||
return 1;
|
||||
@@ -1049,6 +1047,7 @@ static int _get_field(struct dm_report *rh, const char *field, size_t flen,
|
||||
{
|
||||
char field_canon[DM_REPORT_FIELD_TYPE_ID_LEN];
|
||||
uint32_t f;
|
||||
size_t prefix_len;
|
||||
|
||||
if (!flen)
|
||||
return 0;
|
||||
@@ -1056,8 +1055,9 @@ static int _get_field(struct dm_report *rh, const char *field, size_t flen,
|
||||
if (!_get_canonical_field_name(field, flen, field_canon, sizeof(field_canon), NULL))
|
||||
return_0;
|
||||
|
||||
prefix_len = strlen(rh->field_prefix) - 1;
|
||||
for (f = 0; _implicit_report_fields[f].report_fn; f++) {
|
||||
if (_is_same_field(_implicit_report_fields[f].id, field_canon, rh->field_prefix)) {
|
||||
if (_is_same_field(_implicit_report_fields[f].id, field_canon, rh->field_prefix, prefix_len)) {
|
||||
*f_ret = f;
|
||||
*implicit = 1;
|
||||
return 1;
|
||||
@@ -1065,7 +1065,7 @@ static int _get_field(struct dm_report *rh, const char *field, size_t flen,
|
||||
}
|
||||
|
||||
for (f = 0; rh->fields[f].report_fn; f++) {
|
||||
if (_is_same_field(rh->canonical_field_ids[f], field_canon, rh->field_prefix)) {
|
||||
if (_is_same_field(rh->canonical_field_ids[f], field_canon, rh->field_prefix, prefix_len)) {
|
||||
*f_ret = f;
|
||||
*implicit = 0;
|
||||
return 1;
|
||||
@@ -1146,7 +1146,7 @@ static int _add_sort_key(struct dm_report *rh, uint32_t field_num, int implicit,
|
||||
static int _key_match(struct dm_report *rh, const char *key, size_t len,
|
||||
unsigned report_type_only)
|
||||
{
|
||||
char key_canon[DM_REPORT_FIELD_TYPE_ID_LEN];
|
||||
int implicit;
|
||||
uint32_t f;
|
||||
uint32_t flags;
|
||||
|
||||
@@ -1169,16 +1169,8 @@ static int _key_match(struct dm_report *rh, const char *key, size_t len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_get_canonical_field_name(key, len, key_canon, sizeof(key_canon), NULL))
|
||||
return_0;
|
||||
|
||||
for (f = 0; _implicit_report_fields[f].report_fn; f++)
|
||||
if (_is_same_field(_implicit_report_fields[f].id, key_canon, rh->field_prefix))
|
||||
return _add_sort_key(rh, f, 1, flags, report_type_only);
|
||||
|
||||
for (f = 0; rh->fields[f].report_fn; f++)
|
||||
if (_is_same_field(rh->canonical_field_ids[f], key_canon, rh->field_prefix))
|
||||
return _add_sort_key(rh, f, 0, flags, report_type_only);
|
||||
if (_get_field(rh, key, len, &f, &implicit))
|
||||
return _add_sort_key(rh, f, implicit, flags, report_type_only);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1461,9 +1453,14 @@ static void *_report_get_field_data(struct dm_report *rh,
|
||||
const struct dm_report_field_type *fields = fp->implicit ? _implicit_report_fields
|
||||
: rh->fields;
|
||||
|
||||
char *ret = fp->type->data_fn(object);
|
||||
char *ret;
|
||||
|
||||
if (!ret)
|
||||
if (!object) {
|
||||
log_error(INTERNAL_ERROR "_report_get_field_data: missing object.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ret = fp->type->data_fn(object)))
|
||||
return NULL;
|
||||
|
||||
return (void *)(ret + fields[fp->field_num].offset);
|
||||
@@ -2264,7 +2261,7 @@ static const char * _skip_space(const char *s)
|
||||
return s;
|
||||
}
|
||||
|
||||
static int _tok_op(struct op_def *t, const char *s, const char **end,
|
||||
static int _tok_op(const struct op_def *t, const char *s, const char **end,
|
||||
uint32_t expect)
|
||||
{
|
||||
size_t len;
|
||||
@@ -2505,7 +2502,7 @@ float dm_percent_to_float(dm_percent_t percent)
|
||||
|
||||
float dm_percent_to_round_float(dm_percent_t percent, unsigned digits)
|
||||
{
|
||||
static const float power10[] = {
|
||||
const float power10[] = {
|
||||
1.f, .1f, .01f, .001f, .0001f, .00001f, .000001f,
|
||||
.0000001f, .00000001f, .000000001f,
|
||||
.0000000001f
|
||||
@@ -2571,12 +2568,12 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
|
||||
const struct dm_report_reserved_value *iter;
|
||||
const struct dm_report_field_reserved_value *field_res;
|
||||
const struct dm_report_field_type *field;
|
||||
static uint32_t supported_reserved_types = DM_REPORT_FIELD_TYPE_NUMBER |
|
||||
const uint32_t supported_reserved_types = DM_REPORT_FIELD_TYPE_NUMBER |
|
||||
DM_REPORT_FIELD_TYPE_SIZE |
|
||||
DM_REPORT_FIELD_TYPE_PERCENT |
|
||||
DM_REPORT_FIELD_TYPE_STRING |
|
||||
DM_REPORT_FIELD_TYPE_TIME;
|
||||
static uint32_t supported_reserved_types_with_range = DM_REPORT_FIELD_RESERVED_VALUE_RANGE |
|
||||
const uint32_t supported_reserved_types_with_range = DM_REPORT_FIELD_RESERVED_VALUE_RANGE |
|
||||
DM_REPORT_FIELD_TYPE_NUMBER |
|
||||
DM_REPORT_FIELD_TYPE_SIZE |
|
||||
DM_REPORT_FIELD_TYPE_PERCENT |
|
||||
@@ -2592,7 +2589,8 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
|
||||
if (iter->type & DM_REPORT_FIELD_TYPE_MASK) {
|
||||
if (!(iter->type & supported_reserved_types) ||
|
||||
((iter->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
|
||||
!(iter->type & supported_reserved_types_with_range))) {
|
||||
!(iter->type & (supported_reserved_types_with_range &
|
||||
~DM_REPORT_FIELD_RESERVED_VALUE_RANGE)))) {
|
||||
log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
|
||||
"global reserved value for type 0x%x not supported",
|
||||
iter->type);
|
||||
@@ -2602,8 +2600,9 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
|
||||
field_res = (const struct dm_report_field_reserved_value *) iter->value;
|
||||
field = &fields[field_res->field_num];
|
||||
if (!(field->flags & supported_reserved_types) ||
|
||||
((iter->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
|
||||
!(iter->type & supported_reserved_types_with_range))) {
|
||||
((field->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
|
||||
!(field->type & (supported_reserved_types_with_range &
|
||||
~DM_REPORT_FIELD_RESERVED_VALUE_RANGE)))) {
|
||||
log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
|
||||
"field-specific reserved value of type 0x%x for "
|
||||
"field %s not supported",
|
||||
@@ -2843,7 +2842,7 @@ struct time_value {
|
||||
time_t t2;
|
||||
};
|
||||
|
||||
static const char *_out_of_range_msg = "Field selection value %s out of supported range for field %s.";
|
||||
static const char _out_of_range_msg[] = "Field selection value %s out of supported range for field %s.";
|
||||
|
||||
/*
|
||||
* Standard formatted date and time - ISO8601.
|
||||
@@ -2868,7 +2867,7 @@ static const char *_out_of_range_msg = "Field selection value %s out of supporte
|
||||
#define DELIM_DATE '-'
|
||||
#define DELIM_TIME ':'
|
||||
|
||||
static int _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
static const int _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
static int _is_leap_year(long year)
|
||||
{
|
||||
@@ -2893,7 +2892,6 @@ typedef enum {
|
||||
|
||||
static char *_get_date(char *str, struct tm *tm, time_range_t *range)
|
||||
{
|
||||
static const char incorrect_date_format_msg[] = "Incorrect date format.";
|
||||
time_range_t tmp_range = RANGE_NONE;
|
||||
long n1, n2 = -1, n3 = -1;
|
||||
char *s = str, *end;
|
||||
@@ -2939,19 +2937,15 @@ static char *_get_date(char *str, struct tm *tm, time_range_t *range)
|
||||
n3 = n1 % 100;
|
||||
n2 = (n1 / 100) % 100;
|
||||
n1 = n1 / 10000;
|
||||
} else {
|
||||
log_error(incorrect_date_format_msg);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
goto_bad;
|
||||
} else {
|
||||
if (len == 7) {
|
||||
tmp_range = RANGE_MONTH;
|
||||
/* YYYY-MM */
|
||||
n3 = 1;
|
||||
} else {
|
||||
log_error(incorrect_date_format_msg);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
goto_bad;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2974,11 +2968,15 @@ static char *_get_date(char *str, struct tm *tm, time_range_t *range)
|
||||
*range = tmp_range;
|
||||
|
||||
return (char *) _skip_space(end);
|
||||
|
||||
bad:
|
||||
log_error("Incorrect date format.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *_get_time(char *str, struct tm *tm, time_range_t *range)
|
||||
{
|
||||
static const char incorrect_time_format_msg[] = "Incorrect time format.";
|
||||
time_range_t tmp_range = RANGE_NONE;
|
||||
long n1, n2 = -1, n3 = -1;
|
||||
char *s = str, *end;
|
||||
@@ -3026,19 +3024,15 @@ static char *_get_time(char *str, struct tm *tm, time_range_t *range)
|
||||
n3 = n1 % 100;
|
||||
n2 = (n1 / 100) % 100;
|
||||
n1 = n1 / 10000;
|
||||
} else {
|
||||
log_error(incorrect_time_format_msg);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
goto_bad;
|
||||
} else {
|
||||
if (len == 5) {
|
||||
/* HH:MM */
|
||||
tmp_range = RANGE_MINUTE;
|
||||
n3 = 0;
|
||||
} else {
|
||||
log_error(incorrect_time_format_msg);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
goto_bad;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3069,6 +3063,11 @@ static char *_get_time(char *str, struct tm *tm, time_range_t *range)
|
||||
*range = tmp_range;
|
||||
|
||||
return (char *) _skip_space(end);
|
||||
|
||||
bad:
|
||||
log_error("Incorrect time format.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The offset is always an absolute offset against GMT! */
|
||||
@@ -3517,7 +3516,6 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
|
||||
struct reserved_value_wrapper *rvw,
|
||||
void *custom)
|
||||
{
|
||||
static const char *_field_selection_value_alloc_failed_msg = "dm_report: struct field_selection_value allocation failed for selection field %s";
|
||||
const struct dm_report_field_type *fields = implicit ? _implicit_report_fields
|
||||
: rh->fields;
|
||||
struct field_properties *fp, *found = NULL;
|
||||
@@ -3565,8 +3563,8 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
|
||||
}
|
||||
|
||||
if (!(fs->value = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) {
|
||||
log_error(_field_selection_value_alloc_failed_msg, field_id);
|
||||
goto error;
|
||||
stack;
|
||||
goto error_field_id;
|
||||
}
|
||||
|
||||
if (((rvw->reserved && (rvw->reserved->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE)) ||
|
||||
@@ -3574,8 +3572,8 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
|
||||
custom && ((struct time_value *) custom)->range))
|
||||
&&
|
||||
!(fs->value->next = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) {
|
||||
log_error(_field_selection_value_alloc_failed_msg, field_id);
|
||||
goto error;
|
||||
stack;
|
||||
goto error_field_id;
|
||||
}
|
||||
|
||||
fs->fp = found;
|
||||
@@ -3724,6 +3722,10 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
|
||||
}
|
||||
|
||||
return fs;
|
||||
error_field_id:
|
||||
log_error("dm_report: struct field_selection_value allocation failed for selection field %s",
|
||||
field_id);
|
||||
goto error;
|
||||
bad:
|
||||
log_error(INTERNAL_ERROR "Forbiden NULL custom detected.");
|
||||
error:
|
||||
@@ -3752,7 +3754,7 @@ static struct selection_node *_alloc_selection_node(struct dm_pool *mem, uint32_
|
||||
static void _display_selection_help(struct dm_report *rh)
|
||||
{
|
||||
static const char _grow_object_failed_msg[] = "_display_selection_help: dm_pool_grow_object failed";
|
||||
struct op_def *t;
|
||||
const struct op_def *t;
|
||||
const struct dm_report_reserved_value *rv;
|
||||
size_t len_all, len_final = 0;
|
||||
const char **rvs;
|
||||
@@ -4105,7 +4107,7 @@ static int _alloc_rh_selection(struct dm_report *rh)
|
||||
static int _report_set_selection(struct dm_report *rh, const char *selection, int add_new_fields)
|
||||
{
|
||||
struct selection_node *root = NULL;
|
||||
const char *fin, *next;
|
||||
const char *fin = NULL, *next;
|
||||
|
||||
if (rh->selection) {
|
||||
if (rh->selection->selection_root)
|
||||
@@ -4125,7 +4127,7 @@ static int _report_set_selection(struct dm_report *rh, const char *selection, in
|
||||
if (!(root = _alloc_selection_node(rh->selection->mem, SEL_OR)))
|
||||
return 0;
|
||||
|
||||
if (!_parse_or_ex(rh, selection, &fin, root))
|
||||
if (!_parse_or_ex(rh, selection, &fin, root) || !fin)
|
||||
goto_bad;
|
||||
|
||||
next = _skip_space(fin);
|
||||
@@ -4263,7 +4265,9 @@ static int _report_headings(struct dm_report *rh)
|
||||
|
||||
fields = fp->implicit ? _implicit_report_fields : rh->fields;
|
||||
|
||||
heading = fields[fp->field_num].heading;
|
||||
heading = rh->flags & DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS ?
|
||||
fields[fp->field_num].id : fields[fp->field_num].heading;
|
||||
|
||||
if (rh->flags & DM_REPORT_OUTPUT_ALIGNED) {
|
||||
if (dm_snprintf(buf, buf_size, "%-*.*s",
|
||||
fp->width, fp->width, heading) < 0) {
|
||||
@@ -4315,6 +4319,7 @@ static void _recalculate_fields(struct dm_report *rh)
|
||||
struct row *row;
|
||||
struct dm_report_field *field;
|
||||
int len;
|
||||
int id_len;
|
||||
|
||||
dm_list_iterate_items(row, &rh->rows) {
|
||||
dm_list_iterate_items(field, &row->fields) {
|
||||
@@ -4329,6 +4334,12 @@ static void _recalculate_fields(struct dm_report *rh)
|
||||
field->props->width = len;
|
||||
|
||||
}
|
||||
|
||||
if (rh->flags & DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS) {
|
||||
id_len = (int) strlen(rh->fields[field->props->field_num].id);
|
||||
if (field->props->width < id_len)
|
||||
field->props->width = id_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4415,8 +4426,9 @@ static int _sort_rows(struct dm_report *rh)
|
||||
qsort(rows, count, sizeof(**rows), _row_compare);
|
||||
|
||||
dm_list_init(&rh->rows);
|
||||
while (count--)
|
||||
dm_list_add_h(&rh->rows, &(*rows)[count]->list);
|
||||
|
||||
while (count > 0)
|
||||
dm_list_add_h(&rh->rows, &(*rows)[--count]->list);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -4740,6 +4752,7 @@ static int _output_as_rows(struct dm_report *rh)
|
||||
struct field_properties *fp;
|
||||
struct dm_report_field *field;
|
||||
struct row *row;
|
||||
const char *heading;
|
||||
|
||||
dm_list_iterate_items(fp, &rh->field_props) {
|
||||
if (fp->flags & FLD_HIDDEN) {
|
||||
@@ -4758,7 +4771,10 @@ static int _output_as_rows(struct dm_report *rh)
|
||||
}
|
||||
|
||||
if ((rh->flags & DM_REPORT_OUTPUT_HEADINGS)) {
|
||||
if (!dm_pool_grow_object(rh->mem, fields[fp->field_num].heading, 0)) {
|
||||
heading = rh->flags & DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS ?
|
||||
fields[fp->field_num].id : fields[fp->field_num].heading;
|
||||
|
||||
if (!dm_pool_grow_object(rh->mem, heading, 0)) {
|
||||
log_error("dm_report: Failed to extend row for field name");
|
||||
goto bad;
|
||||
}
|
||||
@@ -4798,12 +4814,36 @@ static int _output_as_rows(struct dm_report *rh)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct dm_list *_get_last_displayed_rowh(struct dm_report *rh)
|
||||
{
|
||||
struct dm_list *rowh;
|
||||
struct row *row;
|
||||
|
||||
/*
|
||||
* We need to find 'last displayed row', not just 'last row'.
|
||||
*
|
||||
* This is because the report may be marked with
|
||||
* DM_REPORT_OUTPUT_MULTIPLE_TIMES flag. In that case, the report
|
||||
* may be used more than once and with different selection
|
||||
* criteria each time. Therefore, such report may also contain
|
||||
* rows which we do not display on output with current selection
|
||||
* criteria.
|
||||
*/
|
||||
for (rowh = dm_list_last(&rh->rows); rowh; rowh = dm_list_prev(&rh->rows, rowh)) {
|
||||
row = dm_list_item(rowh, struct row);
|
||||
if (_should_display_row(row))
|
||||
return rowh;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int _output_as_columns(struct dm_report *rh)
|
||||
{
|
||||
struct dm_list *fh, *rowh, *ftmp, *rtmp;
|
||||
struct row *row = NULL;
|
||||
struct dm_report_field *field;
|
||||
struct dm_list *last_row;
|
||||
struct dm_list *last_rowh;
|
||||
int do_field_delim;
|
||||
char *line;
|
||||
|
||||
@@ -4812,7 +4852,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
_report_headings(rh);
|
||||
|
||||
/* Print and clear buffer */
|
||||
last_row = dm_list_last(&rh->rows);
|
||||
last_rowh = _get_last_displayed_rowh(rh);
|
||||
dm_list_iterate_safe(rowh, rtmp, &rh->rows) {
|
||||
row = dm_list_item(rowh, struct row);
|
||||
|
||||
@@ -4866,7 +4906,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
goto bad;
|
||||
}
|
||||
if (rowh != last_row &&
|
||||
if (rowh != last_rowh &&
|
||||
!dm_pool_grow_object(rh->mem, JSON_SEPARATOR, 0)) {
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
goto bad;
|
||||
|
||||
@@ -192,7 +192,7 @@ int dm_asprintf(char **result, const char *format, ...)
|
||||
}
|
||||
|
||||
/*
|
||||
* Count occurences of 'c' in 'str' until we reach a null char.
|
||||
* Count occurrences of 'c' in 'str' until we reach a null char.
|
||||
*
|
||||
* Returns:
|
||||
* len - incremented for each char we encounter.
|
||||
@@ -385,7 +385,7 @@ char *dm_build_dm_uuid(struct dm_pool *mem, const char *uuid_prefix, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sprintf(dmuuid, "%s%s%s%s", uuid_prefix, lvid, (*layer) ? "-" : "", layer);
|
||||
snprintf(dmuuid, len, "%s%s%s%s", uuid_prefix, lvid, (*layer) ? "-" : "", layer);
|
||||
|
||||
return dmuuid;
|
||||
}
|
||||
@@ -552,7 +552,7 @@ const char *dm_size_to_string(struct dm_pool *mem, uint64_t size,
|
||||
if (size == UINT64_C(0)) {
|
||||
if (base == BASE_UNKNOWN)
|
||||
s = 0;
|
||||
sprintf(size_buf, "0%s", include_suffix ? size_str[base + s][suffix_type] : "");
|
||||
snprintf(size_buf, SIZE_BUF, "0%s", include_suffix ? size_str[base + s][suffix_type] : "");
|
||||
return size_buf;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,26 +106,31 @@ int dm_get_status_raid(struct dm_pool *mem, const char *params,
|
||||
|
||||
/* Second field holds the device count */
|
||||
msg_fields = "<#devs> ";
|
||||
if (!(p = _skip_fields(params, 1)) || (sscanf(p, "%d", &i) != 1))
|
||||
if (!(pp = _skip_fields(params, 1)) || (sscanf(pp, "%d", &i) != 1) || !(p = _skip_fields(pp, 1)))
|
||||
goto_bad;
|
||||
|
||||
msg_fields = "";
|
||||
if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_raid))))
|
||||
goto_bad;
|
||||
|
||||
if (!(s->raid_type = dm_pool_zalloc(mem, p - params)))
|
||||
msg_fields = "<raid_type> <#devices> <health_chars> and <sync_ratio> ";
|
||||
if (!(s->raid_type = dm_pool_strndup(mem, params, pp - params - 1)))
|
||||
goto_bad; /* memory is freed when pool is destroyed */
|
||||
|
||||
if (!(s->dev_health = dm_pool_zalloc(mem, i + 1))) /* Space for health chars */
|
||||
if (!(pp = _skip_fields(p, 1)))
|
||||
goto_bad;
|
||||
|
||||
msg_fields = "<raid_type> <#devices> <health_chars> and <sync_ratio> ";
|
||||
if (sscanf(params, "%s %u %s " FMTu64 "/" FMTu64,
|
||||
s->raid_type,
|
||||
&s->dev_count,
|
||||
s->dev_health,
|
||||
&s->insync_regions,
|
||||
&s->total_regions) != 5)
|
||||
/* Raid target can actually report more then real number of legs in a case
|
||||
* raid legs have been removed during initial raid array resynchronization */
|
||||
if (i > (pp - p - 1))
|
||||
i = pp - p - 1;
|
||||
|
||||
if (!(s->dev_health = dm_pool_strndup(mem, p, i))) /* health chars */
|
||||
goto_bad;
|
||||
p = pp;
|
||||
|
||||
s->dev_count = i;
|
||||
if (sscanf(p, FMTu64 "/" FMTu64, &s->insync_regions, &s->total_regions) != 2)
|
||||
goto_bad;
|
||||
|
||||
/*
|
||||
@@ -141,13 +146,13 @@ int dm_get_status_raid(struct dm_pool *mem, const char *params,
|
||||
msg_fields = "<sync_action> and <mismatch_cnt> ";
|
||||
|
||||
/* Skip pre-1.5.0 params */
|
||||
if (!(p = _skip_fields(params, 4)) || !(pp = _skip_fields(p, 1)))
|
||||
if (!(pp = _skip_fields(params, 4)) || !(p = _skip_fields(pp, 1)))
|
||||
goto_bad;
|
||||
|
||||
if (!(s->sync_action = dm_pool_zalloc(mem, pp - p)))
|
||||
if (!(s->sync_action = dm_pool_strndup(mem, pp, p - pp - 1)))
|
||||
goto_bad;
|
||||
|
||||
if (sscanf(p, "%s " FMTu64, s->sync_action, &s->mismatch_count) != 2)
|
||||
if (sscanf(p, FMTu64, &s->mismatch_count) != 1)
|
||||
goto_bad;
|
||||
|
||||
if (num_fields < 7)
|
||||
@@ -166,23 +171,35 @@ int dm_get_status_raid(struct dm_pool *mem, const char *params,
|
||||
if (sscanf(p, FMTu64, &s->data_offset) != 1)
|
||||
goto bad;
|
||||
|
||||
/* <journal_char> - 'A' - active write-through journal device.
|
||||
* - 'a' - active write-back journal device.
|
||||
* - 'D' - dead journal device.
|
||||
* - '-' - no journal device.
|
||||
*/
|
||||
|
||||
out:
|
||||
*status = s;
|
||||
|
||||
if (s->insync_regions == s->total_regions) {
|
||||
/* FIXME: kernel gives misleading info here
|
||||
* Trying to recognize a true state */
|
||||
while (i-- > 0)
|
||||
if (s->dev_health[i] == 'a')
|
||||
a++; /* Count number of 'a' */
|
||||
while (i-- > 0)
|
||||
if (s->dev_health[i] == 'a')
|
||||
a++; /* Count number of 'a' */
|
||||
|
||||
if (a && a < s->dev_count) {
|
||||
/* SOME legs are in 'a' */
|
||||
if (!strcasecmp(s->sync_action, "recover")
|
||||
|| !strcasecmp(s->sync_action, "idle"))
|
||||
/* Kernel may possibly start some action
|
||||
* in near-by future, do not report 100% */
|
||||
s->insync_regions--;
|
||||
if (a) {
|
||||
if ((a < s->dev_count) && /* SOME legs are in 'a' */
|
||||
/* FIXME: kernel gives misleading info here
|
||||
* Trying to recognize a true state */
|
||||
(s->insync_regions == s->total_regions) &&
|
||||
(!strcasecmp(s->sync_action, "recover") ||
|
||||
!strcasecmp(s->sync_action, "idle"))) {
|
||||
/* Kernel may possibly start some action
|
||||
* in near-by future, do not report 100% */
|
||||
s->insync_regions--;
|
||||
}
|
||||
if ((a == s->dev_count) && /* all legs are in 'a' */
|
||||
(!strcasecmp(s->sync_action, "resync") ||
|
||||
!strcasecmp(s->sync_action, "idle"))) {
|
||||
/* Mark 1st. leg in sync */
|
||||
s->dev_health[0] = 'A';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,6 +528,21 @@ int dm_get_status_thin(struct dm_pool *mem, const char *params,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static dm_status_mirror_health_t _get_health(char c)
|
||||
{
|
||||
switch (c) {
|
||||
case 'A': return DM_STATUS_MIRROR_ALIVE;
|
||||
case 'F': return DM_STATUS_MIRROR_FLUSH_FAILED;
|
||||
case 'D': return DM_STATUS_MIRROR_WRITE_FAILED;
|
||||
case 'S': return DM_STATUS_MIRROR_SYNC_FAILED;
|
||||
case 'R': return DM_STATUS_MIRROR_READ_FAILED;
|
||||
default:
|
||||
log_warn("WARNING: Unknown mirror health status char: %c", c);
|
||||
/* fall through */
|
||||
case 'U': return DM_STATUS_MIRROR_UNCLASSIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dm core parms: 0 409600 mirror
|
||||
* Mirror core parms: 2 253:4 253:5 400/400
|
||||
@@ -564,7 +596,7 @@ int dm_get_status_mirror(struct dm_pool *mem, const char *params,
|
||||
pos += used;
|
||||
|
||||
for (i = 0; i < num_devs ; ++i)
|
||||
s->devs[i].health = pos[i];
|
||||
s->devs[i].health = _get_health(pos[i]);
|
||||
|
||||
if (!(pos = _skip_fields(pos, argc)))
|
||||
goto_out;
|
||||
@@ -609,7 +641,7 @@ int dm_get_status_mirror(struct dm_pool *mem, const char *params,
|
||||
goto_out;
|
||||
|
||||
for (i = 0; i < s->log_count; ++i)
|
||||
s->logs[i].health = pos[i];
|
||||
s->logs[i].health = _get_health(pos[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@ struct dm_vdo_target_params {
|
||||
uint32_t block_map_era_length; // format period
|
||||
uint32_t block_map_period; // supported alias
|
||||
};
|
||||
uint32_t check_point_frequency;
|
||||
uint32_t index_memory_size_mb; // format
|
||||
|
||||
uint32_t slab_size_mb; // format
|
||||
|
||||
@@ -128,6 +128,14 @@ struct vdo_volume_geometry {
|
||||
struct vdo_index_config index_config;
|
||||
} __packed;
|
||||
|
||||
struct vdo_volume_geometry_4 {
|
||||
uint32_t release_version;
|
||||
uint64_t nonce;
|
||||
uuid_t uuid;
|
||||
struct vdo_volume_region regions[VDO_VOLUME_REGION_COUNT];
|
||||
struct vdo_index_config index_config;
|
||||
} __packed;
|
||||
|
||||
/* Decoding mostly only some used stucture members */
|
||||
|
||||
static void _vdo_decode_version(struct vdo_version_number *v)
|
||||
@@ -157,6 +165,16 @@ static void _vdo_decode_volume_geometry(struct vdo_volume_geometry *vg)
|
||||
_vdo_decode_geometry_region(&vg->regions[VDO_DATA_REGION]);
|
||||
}
|
||||
|
||||
static void _vdo_decode_volume_geometry_4(struct vdo_volume_geometry *vg,
|
||||
struct vdo_volume_geometry_4 *vg_4)
|
||||
{
|
||||
vg->release_version = le32_to_cpu(vg_4->release_version);
|
||||
vg->nonce = le64_to_cpu(vg_4->nonce);
|
||||
vg->bio_offset = 0;
|
||||
vg->regions[VDO_DATA_REGION] = vg_4->regions[VDO_DATA_REGION];
|
||||
_vdo_decode_geometry_region(&vg->regions[VDO_DATA_REGION]);
|
||||
}
|
||||
|
||||
static void _vdo_decode_config(struct vdo_config *vc)
|
||||
{
|
||||
vc->logical_blocks = le64_to_cpu(vc->logical_blocks);
|
||||
@@ -184,6 +202,7 @@ bool dm_vdo_parse_logical_size(const char *vdo_path, uint64_t *logical_blocks)
|
||||
struct vdo_header h;
|
||||
struct vdo_version_number vn;
|
||||
struct vdo_volume_geometry vg;
|
||||
struct vdo_volume_geometry_4 vg_4;
|
||||
struct vdo_component_41_0 pvc;
|
||||
|
||||
*logical_blocks = 0;
|
||||
@@ -220,17 +239,24 @@ bool dm_vdo_parse_logical_size(const char *vdo_path, uint64_t *logical_blocks)
|
||||
memcpy(&h, buffer + MAGIC_NUMBER_SIZE, sizeof(h));
|
||||
_vdo_decode_header(&h);
|
||||
|
||||
if (h.version.major_version != 5) {
|
||||
log_debug_activation("Unsupported VDO version %u.%u.", h.version.major_version, h.version.minor_version);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (h.id != 5) {
|
||||
log_debug_activation("Expected geometry VDO block instead of block %u.", h.id);
|
||||
goto err;
|
||||
}
|
||||
memcpy(&vg, buffer + MAGIC_NUMBER_SIZE + sizeof(h), sizeof(vg));
|
||||
_vdo_decode_volume_geometry(&vg);
|
||||
|
||||
switch (h.version.major_version) {
|
||||
case 4:
|
||||
memcpy(&vg_4, buffer + MAGIC_NUMBER_SIZE + sizeof(h), sizeof(vg_4));
|
||||
_vdo_decode_volume_geometry_4(&vg, &vg_4);
|
||||
break;
|
||||
case 5:
|
||||
memcpy(&vg, buffer + MAGIC_NUMBER_SIZE + sizeof(h), sizeof(vg));
|
||||
_vdo_decode_volume_geometry(&vg);
|
||||
break;
|
||||
default:
|
||||
log_debug_activation("Unsupported VDO version %u.%u.", h.version.major_version, h.version.minor_version);
|
||||
goto err;
|
||||
}
|
||||
|
||||
regpos = (vg.regions[VDO_DATA_REGION].start_block - vg.bio_offset) * 4096;
|
||||
|
||||
|
||||
24
doc/Problems.mdwn
Normal file
24
doc/Problems.mdwn
Normal file
@@ -0,0 +1,24 @@
|
||||
# Common problems
|
||||
|
||||
## Duplicate PVs in the system
|
||||
|
||||
LVM tries to detect the common sources of duplicates, mdadm RAID and multipath,
|
||||
there are cases where duplicate PV appears on the system.
|
||||
|
||||
There are two solutions to this problem:
|
||||
|
||||
* Setting a *global_filter* configuration option.
|
||||
* Using of *devices_file* (See [lvmdevices(8)](https://man7.org/linux/man-pages/man8/lvmdevices.8.html))
|
||||
|
||||
## Device Filtering
|
||||
|
||||
*filter* and *global_filter* are meant to be used in two ways:
|
||||
|
||||
* as an allow list, listing patterns for devices which will be accepted
|
||||
* `a|/dev/sdX|`, and rejecting the rest `r|.*|`,
|
||||
* as a reject list, listing only patterns for devices which will be rejected
|
||||
* `r|/dev/sdX|`,
|
||||
|
||||
Even though there are situations where it works, mixing reject and accept
|
||||
patterns is not recommended.
|
||||
|
||||
34
doc/README.mdwn
Normal file
34
doc/README.mdwn
Normal file
@@ -0,0 +1,34 @@
|
||||
LVM2 Wiki Documentation
|
||||
=======================
|
||||
|
||||
If you are looking for information about LVM2 visit the [[Index]] page,
|
||||
|
||||
There are only some notes about writing stuff under *./doc* here:
|
||||
|
||||
* If possible use [[MarkDown]] for formatting, use *.md* (or *.mdwn*) suffix.
|
||||
* For linking between files, use [[IkiWiki]] syntax `[[FileName]]` or
|
||||
`[[FileName#Anchor]]`, or `[[link text|FileName]]`
|
||||
|
||||
Markdown
|
||||
--------
|
||||
|
||||
* Use `<!-- comment -->` to keep notes, which will not be rendered.
|
||||
* Use `[[TODO]]` for anything what needs attention. This will be accessible
|
||||
through the linked [[TODO]] page.
|
||||
|
||||
IkiWiki
|
||||
-------
|
||||
|
||||
* Install ikiwiki:
|
||||
|
||||
yum install ikiwiki
|
||||
|
||||
* To generate the content, run following in the LVM2 top directory:
|
||||
|
||||
ikiwiki --setup ikiwiki.setup
|
||||
|
||||
Internal Stuff:
|
||||
---------------
|
||||
|
||||
* [[TODO]] Can we have a section which is hidden by default? Like this one?
|
||||
* [[TODO]] Add basic IkiWiki and MarkDown How To.
|
||||
152
doc/index.mdwn
Normal file
152
doc/index.mdwn
Normal file
@@ -0,0 +1,152 @@
|
||||
# LVM - Logical Volume Manager for Linux
|
||||
|
||||
<!--
|
||||
* TODO: Add banner for Important News: Critical Bugs, Important Announcements,...
|
||||
-->
|
||||
|
||||
<!--
|
||||
* TODO: Add a feed for latest articles/release-notes on the right
|
||||
-->
|
||||
|
||||
<!--
|
||||
## About LVM2
|
||||
-->
|
||||
LVM aka LVM2 refers to the userspace toolset that provide logical volume
|
||||
management facilities on linux.
|
||||
<!--
|
||||
It is reasonably backwards-compatible with the
|
||||
original LVM1 toolset.
|
||||
* TODO: Add information about LVM1 metadata format conversion!
|
||||
-->
|
||||
|
||||
LVM offers more flexibility than using partitions, allowing one to
|
||||
|
||||
* grow and, where supported by filesystem, shrink volumes,
|
||||
* create snapshots of existing volumes,
|
||||
* mirror data on multiple disks including RAID levels 5 or 6,
|
||||
* striping data on multiple disks,
|
||||
* create a read or write cache.
|
||||
|
||||
To use LVM2 you need 3 things:
|
||||
|
||||
* [device-mapper](https://sourceware.org/dm/) in your kernel (upstream since long ago)
|
||||
* the userspace device-mapper support library (*libdevmapper*) (part of lvm2)
|
||||
* and the userspace LVM2 tools.
|
||||
|
||||
## Getting LVM
|
||||
|
||||
Most of linux distribution offer packaged LVM tools.
|
||||
Depending on your distribution use
|
||||
|
||||
# RPM based distributions (Fedora):
|
||||
yum install lvm2
|
||||
# DEB based distributions (Debian, Ubuntu):
|
||||
apt-get install lvm2
|
||||
|
||||
Tarballs of the userspace LVM2 source code releases are available from [sourceware.org](https://sourceware.org/pub/lvm2/) [ftp](ftp://sourceware.org/pub/lvm2/).
|
||||
|
||||
List of official [mirror sites](https://sourceware.org/mirrors.html) (including http and rsync protocols).
|
||||
|
||||
### LVM Releases
|
||||
|
||||
[[!inline pages="release-notes/2.03.* and !*/template and !*/Discussion and !tagged(draft) and !tagged(pending)" limit=2 rootpage="release-notes"]]
|
||||
|
||||
[[More releases|release-notes/index]]
|
||||
|
||||
## Getting Started
|
||||
|
||||
<!--
|
||||
TODO: We are missing a lvm(7) man page explaining this, I think it would be a nic addition!
|
||||
And perhaps so would be a lvmtroubleshooting(7) guide.
|
||||
-->
|
||||
Word of warning first! Even though LVM errs on the side of data safety it is a
|
||||
tool with low level access and one may seriously harm their data when used
|
||||
incorrectly!
|
||||
|
||||
|
||||
* Physical Volume (PV) is underlying disk, local or remote, encrypted or even
|
||||
a mdadm RAID volume. PV is divided into so called Physical Extents (PE) which
|
||||
are a basic allocation unit.
|
||||
List PVs using [pvs(8)](https://man7.org/linux/man-pages/man8/pvs.8.html) or
|
||||
[pvdisplay(8)](https://man7.org/linux/man-pages/man8/pvdisplay.8.html).
|
||||
|
||||
Make one by running `pvcreate /dev/sdX`.
|
||||
See [pvcreate(8)](https://man7.org/linux/man-pages/man8/pvcreate.8.html). This step is optional.
|
||||
* Volume Group (VG) consisting of one or more PVs is used as a pool from which LVs are allocated.
|
||||
List VGs using [vgs(8)](https://man7.org/linux/man-pages/man8/vgs.8.html) or
|
||||
[vgdisplay(8)](https://man7.org/linux/man-pages/man8/vgdisplay.8.html).
|
||||
|
||||
Make one by running `vgcreate VGNAME /dev/sdX...`, add PVs to existing one by `vgextend VGNAME /dev/sdX`.
|
||||
To use LVM at least one Volume Group must be present on the system.
|
||||
See [vgcreate(8)](https://man7.org/linux/man-pages/man8/vgcreate.8.html), and
|
||||
[vgextend(8)](https://man7.org/linux/man-pages/man8/vgextend.8.html).
|
||||
* Logical Volume (LV) is the block device usually visible to user to be used for file system.
|
||||
List PVs using [lvs(8)](https://man7.org/linux/man-pages/man8/lvs.8.html) or
|
||||
[lvdisplay(8)](https://man7.org/linux/man-pages/man8/lvdisplay.8.html).
|
||||
|
||||
Make one by running `lvcreate [-n LVNAME] -L SIZE VGNAME`, and you are done!
|
||||
See [vgcreate(8)](https://man7.org/linux/man-pages/man8/vgcreate.8.html).
|
||||
|
||||
## Avoiding Problems
|
||||
|
||||
Good start is to avoid using `{--force|-f}` and `{--yes|-y}` options which are
|
||||
often seen on internet discussions.
|
||||
there is a possibility of data loss, LVM tools usually ask, so read the prompts
|
||||
carefully! Using `--yes` removes these safety.
|
||||
Also in some cases where it is too dangerous to proceed, e.g. device is used,
|
||||
LVM refuses to do so, which can be overridden by `--force`.
|
||||
|
||||
Second, when resizing and especially when shrinking LVs it is always a good
|
||||
idea to use `--resizefs` option which ensures the devices are resized in
|
||||
correct order.
|
||||
|
||||
Third, if you still make a mess, never ever run fsck on damaged LV/FS, this is
|
||||
usually the final blow to your data. It is always better to ask first!
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
## Resolving Problems
|
||||
|
||||
* Backup if possible!
|
||||
* Search the problem first, check the list of [[common problems|Problems]]
|
||||
* Never run `fsck` on damaged LV, LV must be recovered first!
|
||||
* When asking for help describe exactly how the system got corrupted. It really
|
||||
does not help trying to cover one's mistakes in such situation, it takes
|
||||
longer to get help and also you are likely to get wrong answer making repair
|
||||
impossible.
|
||||
|
||||
## Reporting Bugs
|
||||
|
||||
* When you find a problem there is often something specific about your system.
|
||||
If the problem is reproducible run the failing command(s) with verbose flag
|
||||
`-vvvv` which gives developers clue where the problem might be.
|
||||
There is a [lvmdump(8)](https://man7.org/linux/man-pages/man8/lvmdump.8.html)
|
||||
tool to help collect data about your system, block devices and LVM setup.
|
||||
* Please report upstream bugs or request features in [Red Hat Bugzilla](https://bugzilla.redhat.com/enter_bug.cgi?product=LVM%20and%20device-mapper)
|
||||
|
||||
<!--
|
||||
TODO:
|
||||
* Add links to other documentation
|
||||
* Add links to git
|
||||
* Add links to mailing lists
|
||||
|
||||
* Resolving problems
|
||||
* Backup if possible!
|
||||
* Newer run fsck! Do the research first!
|
||||
* List of Common issues
|
||||
* Resizing in wrong order
|
||||
* Thin pool running out of space
|
||||
* Configuration - duplicates
|
||||
* Mailing list
|
||||
* IRC?
|
||||
|
||||
* Reporting Bugs
|
||||
* sosreport/lvmdump
|
||||
* BZ
|
||||
|
||||
* Contributing
|
||||
* gitlab MR
|
||||
|
||||
* Add latest articles
|
||||
-->
|
||||
4
doc/local.css
Normal file
4
doc/local.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.page {
|
||||
max-width: 1280px;
|
||||
margin: auto;
|
||||
}
|
||||
@@ -51,3 +51,5 @@ In future optional target flags will be given in two situations:
|
||||
|
||||
This decision could well be contentious, so could distro maintainers feel
|
||||
free to comment.
|
||||
|
||||
[[!tag legacy]]
|
||||
|
||||
76
doc/release-notes/2.03.24.mdwn
Normal file
76
doc/release-notes/2.03.24.mdwn
Normal file
@@ -0,0 +1,76 @@
|
||||
<!-- Page title -->
|
||||
[[!meta title="Version 2.03.24 - Feature and Bug Fix Release"]]
|
||||
|
||||
Version 2.03.24
|
||||
===============
|
||||
|
||||
* **Changes in udev rules, new version of systemd is recommended (256).**
|
||||
* **When using LVs as PVs these are no longer auto activated!**
|
||||
* Allow creating VDO device for thin data when creating thin pool.
|
||||
* More devices can be used as external origin for thin snapshot.
|
||||
* And [[!toggle text="more"]]
|
||||
|
||||
[[!toggleable text="""
|
||||
Features
|
||||
-----------------------
|
||||
|
||||
* Swap properties like hostname, date and time when swapping LVs.
|
||||
* Allow thin snapshot taken of thin volume from another pool as external origin.
|
||||
* Allow chaining of external origins.
|
||||
|
||||
### Changes to device handling
|
||||
|
||||
* **IMPORTANT:** When `devices/scan_lvs` is enabled found LVs are no longer auto
|
||||
activated, must enable `LVM_PVSCAN_ON_LVS` in udev rules (*69-dm-lvm.rules*.)
|
||||
* NOTE: It is not recommended to use LVs for PVs. If you have an use case for
|
||||
this talk to us, please.
|
||||
* Changes to devices file are now backed up in */etc/lvm/devices/backup/*.
|
||||
Controlled by `devices/devicesfile_backup_limit` configuration option.
|
||||
* When `devices/use_devicesfile` is set to `0` existing file is renamed to
|
||||
*system.devices-unused.YYYYMMDD.HHMMSS* to prevent outdated file to be used
|
||||
on reenabling.
|
||||
|
||||
### Use VDO device for thin pool's data
|
||||
|
||||
New option `--pooldatavdo` during lvcreate or lvconvert allows using VDO as backing device.
|
||||
|
||||
More options (`--compression {y|n}`, `--deduplication {y|n}`,
|
||||
`--vdosettings STRING`) to control the options are supported by these commands.
|
||||
|
||||
Example of converting a *lvol1* to a thin pool with enabled compression and deduplication:
|
||||
|
||||
lvconvert --type thin-pool --pooldatavdo y vg/lvol1
|
||||
|
||||
Changes in command line
|
||||
-----------------------
|
||||
|
||||
* Add *--wipesignature* option controlling signature wiping when converting volume to thin-pool.
|
||||
* Allow *lvcreate --snapshot* without *{-T|--thin}* option when creating snapshot of a thin volume.
|
||||
* Allow *--raidintegrity{,mode,blocksize}* options with implicit RAID1 (i.e. when *-m1* is used on command line)
|
||||
|
||||
./configure options
|
||||
-------------------
|
||||
|
||||
These changes are for packagers:
|
||||
|
||||
* Add `--with-default-event-activation` option controlling default for
|
||||
`global/event_activation`. Default value is unchanged. Useful when creating
|
||||
builds for testing.
|
||||
* Add `--with-modulesdir` option.
|
||||
|
||||
Changes in udev rules
|
||||
---------------------
|
||||
|
||||
**IMPORTANT:** Rework of udev rules in cooperation with systemd is included in this release.
|
||||
|
||||
* `DM_SUSPENDED` and `DM_NOSCAN` are now entirely internal for DM and cannot be used outside of DM rules.
|
||||
* Upper level rules should consume `DM_UDEV_DISABLE_OTHER_RULES_FLAG` rather than `DM_NOSCAN` and `DM_SUSPENDED`.
|
||||
|
||||
Also few more minor improvements:
|
||||
|
||||
* Better handling of `DISK_RO` events and suspended devices
|
||||
|
||||
"""]]
|
||||
|
||||
[[!tag]]
|
||||
[[!meta date="Thu May 16 12:12:06 2024 +0200"]]
|
||||
22
doc/release-notes/2.03.25.mdwn
Normal file
22
doc/release-notes/2.03.25.mdwn
Normal file
@@ -0,0 +1,22 @@
|
||||
<!-- Page title -->
|
||||
[[!meta title="Version 2.03.25 - Feature and Bug Fix Release"]]
|
||||
|
||||
Version 2.03.25
|
||||
===============
|
||||
|
||||
* Add `vgimportdevices --rootvg [--auto]` adding devices from root VG to devices file.
|
||||
* Add `lvm-devices-import.{path,service}` service using the above to initialize devices file.
|
||||
* Handle pruning ids from devices file when lvremove is called and a PV is on top of the LV.
|
||||
* Change device cache data structures and caching to speed up operations with many LVs.
|
||||
* Fix infinite loop in lvm shell completion causing out of memory issue (2.03.24).
|
||||
* Allow forced change of locktype from none.
|
||||
* Handle OPTIONS defined in /etc/sysconfig/lvmlockd.
|
||||
* And as usually some clean up, static analysis fixes, etc.
|
||||
|
||||
<!-- remove the pending tag on release, remove draft tag once editing is complete -->
|
||||
[[!tag draft pending]]
|
||||
<!--
|
||||
For old releases add Release Timestamp like this, date from git show $COMMIT is fine.
|
||||
\[[!meta date="Tue Nov 21 14:26:07 2023 +0100"]]
|
||||
-->
|
||||
|
||||
9
doc/release-notes/index.mdwn
Normal file
9
doc/release-notes/index.mdwn
Normal file
@@ -0,0 +1,9 @@
|
||||
# LVM Releases
|
||||
|
||||
This list is incomplete, only releases with a release-note are included.
|
||||
|
||||
For releases of legacy branch *2.02* see [[legacy]].
|
||||
|
||||
Too see what's cooking see [[pending]].
|
||||
|
||||
[[!inline pages="release-notes/2.03.* and !*/template and !*/Discussion and !tagged(draft) and !tagged(pending)" rootpage="release-notes"]]
|
||||
8
doc/release-notes/legacy.mdwn
Normal file
8
doc/release-notes/legacy.mdwn
Normal file
@@ -0,0 +1,8 @@
|
||||
# Legacy 2.02 Releases
|
||||
|
||||
This list is incomplete, only releases with a release-note are included.
|
||||
|
||||
For releases of stable branch 2.03 see [[index]].
|
||||
|
||||
[[!inline pages="release-notes/2.02.* and !*/template and !*/Discussion and !tagged(draft) and !tagged(pending)" limit=2 rootpage="release-notes"]]
|
||||
|
||||
3
doc/release-notes/pending.mdwn
Normal file
3
doc/release-notes/pending.mdwn
Normal file
@@ -0,0 +1,3 @@
|
||||
# Pending Release
|
||||
|
||||
[[!inline pages="release-notes/* and !*/template and !*/Discussion and tagged(pending)" rootpage="release-notes"]]
|
||||
52
doc/release-notes/template.mdwn
Normal file
52
doc/release-notes/template.mdwn
Normal file
@@ -0,0 +1,52 @@
|
||||
<!-- Page title -->
|
||||
[[!meta title="Version 2.03. - Feature and Bug Fix Release"]]
|
||||
|
||||
Version 2.03.
|
||||
===============
|
||||
|
||||
* List of important/interesting changes
|
||||
* And [[!toggle text="more"]]
|
||||
|
||||
[[!toggleable text="""
|
||||
Features
|
||||
-----------------------
|
||||
|
||||
* List new features worth mentioning here in one line.
|
||||
|
||||
### New Feature Worth a Paragraph or Two
|
||||
|
||||
Write a paragraph or two covering feature where some examples of usage are expected.
|
||||
|
||||
<!--
|
||||
TODO: It would be nice if we could use a real session output, so we could test the examples
|
||||
- During tests, save some outputs
|
||||
-->
|
||||
|
||||
Changes in command line
|
||||
-----------------------
|
||||
|
||||
Describe important changes in command line tools, especially any chnages of behavior, which user must be aware of:
|
||||
|
||||
* New options
|
||||
* Removed options
|
||||
* Use a separate page in *./doc* for larger features worth separate article, or a man page
|
||||
|
||||
Changes in lvm.conf
|
||||
-------------------
|
||||
|
||||
* New options.
|
||||
* Change of defaults.
|
||||
|
||||
./configure options
|
||||
-------------------
|
||||
|
||||
* New options and features the enable.
|
||||
|
||||
"""]]
|
||||
|
||||
<!-- remove the pending tag on release, remove draft tag once editing is complete -->
|
||||
[[!tag draft pending]]
|
||||
<!--
|
||||
For old releases add Release Timestamp like this, date from git show $COMMIT is fine.
|
||||
\[[!meta date="Tue Nov 21 14:26:07 2023 +0100"]]
|
||||
-->
|
||||
420
ikiwiki.setup
Normal file
420
ikiwiki.setup
Normal file
@@ -0,0 +1,420 @@
|
||||
# IkiWiki::Setup::Yaml - YAML formatted setup file
|
||||
#
|
||||
# Setup file for ikiwiki.
|
||||
#
|
||||
# Passing this to ikiwiki --setup will make ikiwiki generate
|
||||
# wrappers and build the wiki.
|
||||
#
|
||||
# Remember to re-run ikiwiki --setup any time you edit this file.
|
||||
#
|
||||
# name of the wiki
|
||||
wikiname: LVM
|
||||
# contact email for wiki
|
||||
#adminemail: me@example.com
|
||||
# users who are wiki admins
|
||||
adminuser: []
|
||||
# users who are banned from the wiki
|
||||
banned_users: []
|
||||
# where the source of the wiki is located
|
||||
srcdir: ./doc
|
||||
# where to build the wiki
|
||||
destdir: ./public
|
||||
# base url to the wiki
|
||||
url: https://sourceware.org/lvm2/
|
||||
# url to the ikiwiki.cgi
|
||||
cgiurl: ''
|
||||
# do not adjust cgiurl if CGI is accessed via different URL
|
||||
reverse_proxy: 0
|
||||
# filename of cgi wrapper to generate
|
||||
cgi_wrapper: ''
|
||||
# mode for cgi_wrapper (can safely be made suid)
|
||||
cgi_wrappermode: 06755
|
||||
# number of seconds to delay CGI requests when overloaded
|
||||
cgi_overload_delay: ''
|
||||
# message to display when overloaded (may contain html)
|
||||
cgi_overload_message: ''
|
||||
# enable optimization of only refreshing committed changes?
|
||||
only_committed_changes: 0
|
||||
# rcs backend to use
|
||||
rcs: ''
|
||||
# plugins to add to the default configuration
|
||||
add_plugins:
|
||||
- sidebar
|
||||
- tag
|
||||
- toggle
|
||||
# plugins to disable
|
||||
disable_plugins: []
|
||||
# additional directory to search for template files
|
||||
templatedir: /usr/share/ikiwiki/templates
|
||||
# base wiki source location
|
||||
underlaydir: /usr/share/ikiwiki/basewiki
|
||||
# display verbose messages?
|
||||
#verbose: 1
|
||||
# log to syslog?
|
||||
#syslog: 1
|
||||
# create output files named page/index.html?
|
||||
usedirs: 1
|
||||
# use '!'-prefixed preprocessor directives?
|
||||
prefix_directives: 1
|
||||
# use page/index.mdwn source files
|
||||
indexpages: 0
|
||||
# enable Discussion pages?
|
||||
discussion: 1
|
||||
# name of Discussion pages
|
||||
discussionpage: Discussion
|
||||
# use elements new in HTML5 like <section>?
|
||||
html5: 0
|
||||
# only send cookies over SSL connections?
|
||||
sslcookie: 0
|
||||
# extension to use for new pages
|
||||
default_pageext: mdwn
|
||||
# extension to use for html files
|
||||
htmlext: html
|
||||
# strftime format string to display date
|
||||
timeformat: '%c'
|
||||
# UTF-8 locale to use
|
||||
#locale: en_US.UTF-8
|
||||
# put user pages below specified page
|
||||
userdir: ''
|
||||
# how many backlinks to show before hiding excess (0 to show all)
|
||||
numbacklinks: 10
|
||||
# attempt to hardlink source files? (optimisation for large files)
|
||||
hardlink: 0
|
||||
# force ikiwiki to use a particular umask (keywords public, group or private, or a number)
|
||||
#umask: public
|
||||
# group for wrappers to run in
|
||||
#wrappergroup: ikiwiki
|
||||
# extra library and plugin directories
|
||||
libdirs: []
|
||||
# extra library and plugin directory (searched after libdirs)
|
||||
libdir: ''
|
||||
# environment variables
|
||||
ENV: {}
|
||||
# time zone name
|
||||
timezone: :/etc/localtime
|
||||
# regexp of normally excluded files to include
|
||||
#include: ^\.htaccess$
|
||||
# regexp of files that should be skipped
|
||||
#exclude: ^(*\.private|Makefile)$
|
||||
# specifies the characters that are allowed in source filenames
|
||||
wiki_file_chars: -[:alnum:]+/.:_
|
||||
# allow symlinks in the path leading to the srcdir (potentially insecure)
|
||||
allow_symlinks_before_srcdir: 0
|
||||
# cookie control
|
||||
cookiejar:
|
||||
file: /home/mcsontos/.ikiwiki/cookies
|
||||
# set custom user agent string for outbound HTTP requests e.g. when fetching aggregated RSS feeds
|
||||
useragent: ikiwiki/3.20200202.3
|
||||
# theme has a responsive layout? (mobile-optimized)
|
||||
responsive_layout: 1
|
||||
# try harder to produce deterministic output
|
||||
deterministic: 0
|
||||
|
||||
######################################################################
|
||||
# core plugins
|
||||
# (editpage, htmlscrubber, inline, link, meta, parentlinks, templatebody)
|
||||
######################################################################
|
||||
|
||||
# htmlscrubber plugin
|
||||
# PageSpec specifying pages not to scrub
|
||||
#htmlscrubber_skip: '!*/Discussion'
|
||||
|
||||
# inline plugin
|
||||
# enable rss feeds by default?
|
||||
#rss: 0
|
||||
# enable atom feeds by default?
|
||||
#atom: 0
|
||||
# allow rss feeds to be used?
|
||||
#allowrss: 0
|
||||
# allow atom feeds to be used?
|
||||
#allowatom: 0
|
||||
# urls to ping (using XML-RPC) on feed update
|
||||
pingurl: []
|
||||
|
||||
######################################################################
|
||||
# auth plugins
|
||||
# (anonok, blogspam, emailauth, httpauth, lockedit, moderatedcomments,
|
||||
# opendiscussion, openid, passwordauth, signinedit)
|
||||
######################################################################
|
||||
|
||||
# anonok plugin
|
||||
# PageSpec to limit which pages anonymous users can edit
|
||||
#anonok_pagespec: '*/discussion'
|
||||
|
||||
# blogspam plugin
|
||||
# PageSpec of pages to check for spam
|
||||
#blogspam_pagespec: postcomment(*)
|
||||
# options to send to blogspam server
|
||||
#blogspam_options: blacklist=1.2.3.4,blacklist=8.7.6.5,max-links=10
|
||||
# blogspam server JSON url
|
||||
#blogspam_server: ''
|
||||
|
||||
# emailauth plugin
|
||||
# email address to send emailauth mails as (default: adminemail)
|
||||
#emailauth_sender: ''
|
||||
|
||||
# httpauth plugin
|
||||
# url to redirect to when authentication is needed
|
||||
#cgiauthurl: http://example.com/wiki/auth/ikiwiki.cgi
|
||||
# PageSpec of pages where only httpauth will be used for authentication
|
||||
#httpauth_pagespec: '!*/Discussion'
|
||||
|
||||
# lockedit plugin
|
||||
# PageSpec controlling which pages are locked
|
||||
#locked_pages: '!*/Discussion'
|
||||
|
||||
# moderatedcomments plugin
|
||||
# PageSpec matching users or comment locations to moderate
|
||||
#moderate_pagespec: '*'
|
||||
|
||||
# openid plugin
|
||||
# url pattern of openid realm (default is cgiurl)
|
||||
#openid_realm: ''
|
||||
# url to ikiwiki cgi to use for openid authentication (default is cgiurl)
|
||||
#openid_cgiurl: ''
|
||||
|
||||
# passwordauth plugin
|
||||
# a password that must be entered when signing up for an account
|
||||
#account_creation_password: s3cr1t
|
||||
# cost of generating a password using Authen::Passphrase::BlowfishCrypt
|
||||
#password_cost: 8
|
||||
|
||||
######################################################################
|
||||
# format plugins
|
||||
# (creole, highlight, hnb, html, mdwn, otl, po, rawhtml, textile, txt)
|
||||
######################################################################
|
||||
|
||||
# highlight plugin
|
||||
# types of source files to syntax highlight
|
||||
#tohighlight: .c .h .cpp .pl .py Makefile:make
|
||||
# location of highlight's filetypes.conf
|
||||
#filetypes_conf: /etc/highlight/filetypes.conf
|
||||
# location of highlight's langDefs directory
|
||||
#langdefdir: /usr/share/highlight/langDefs
|
||||
|
||||
# mdwn plugin
|
||||
# enable multimarkdown features?
|
||||
#multimarkdown: 0
|
||||
# disable use of markdown discount?
|
||||
#nodiscount: 0
|
||||
# enable footnotes in Markdown (where supported)?
|
||||
mdwn_footnotes: 1
|
||||
# interpret line like 'A. First item' as ordered list when using Discount?
|
||||
mdwn_alpha_lists: 0
|
||||
|
||||
# po plugin
|
||||
# master language (non-PO files)
|
||||
#po_master_language: en|English
|
||||
# slave languages (translated via PO files) format: ll|Langname
|
||||
#po_slave_languages:
|
||||
#- fr|Français
|
||||
#- es|Español
|
||||
#- de|Deutsch
|
||||
# PageSpec controlling which pages are translatable
|
||||
#po_translatable_pages: '* and !*/Discussion'
|
||||
# internal linking behavior (default/current/negotiated)
|
||||
#po_link_to: current
|
||||
|
||||
######################################################################
|
||||
# special-purpose plugins
|
||||
# (osm, underlay)
|
||||
######################################################################
|
||||
|
||||
# osm plugin
|
||||
# the default zoom when you click on the map link
|
||||
#osm_default_zoom: 15
|
||||
# the icon shown on links and on the main map
|
||||
#osm_default_icon: ikiwiki/images/osm.png
|
||||
# the alt tag of links, defaults to empty
|
||||
#osm_alt: ''
|
||||
# the output format for waypoints, can be KML, GeoJSON or CSV (one or many, comma-separated)
|
||||
#osm_format: KML
|
||||
# the icon attached to a tag, displayed on the map for tagged pages
|
||||
#osm_tag_default_icon: icon.png
|
||||
# Url for the OpenLayers.js file
|
||||
#osm_openlayers_url: http://www.openlayers.org/api/OpenLayers.js
|
||||
# Layers to use in the map. Can be either the 'OSM' string or a type option for Google maps (GoogleNormal, GoogleSatellite, GoogleHybrid or GooglePhysical). It can also be an arbitrary URL in a syntax acceptable for OpenLayers.Layer.OSM.url parameter.
|
||||
#osm_layers:
|
||||
# OSM: GoogleSatellite
|
||||
# Google maps API key, Google layer not used if missing, see https://code.google.com/apis/console/ to get an API key
|
||||
#osm_google_apikey: ''
|
||||
|
||||
# underlay plugin
|
||||
# extra underlay directories to add
|
||||
#add_underlays:
|
||||
#- /home/mcsontos/wiki.underlay
|
||||
|
||||
######################################################################
|
||||
# web plugins
|
||||
# (404, attachment, comments, editdiff, edittemplate, getsource, google,
|
||||
# goto, mirrorlist, remove, rename, repolist, search, theme, userlist,
|
||||
# websetup, wmd)
|
||||
######################################################################
|
||||
|
||||
# attachment plugin
|
||||
# enhanced PageSpec specifying what attachments are allowed
|
||||
#allowed_attachments: virusfree() and mimetype(image/*) and maxsize(50kb)
|
||||
# virus checker program (reads STDIN, returns nonzero if virus found)
|
||||
#virus_checker: clamdscan -
|
||||
|
||||
# comments plugin
|
||||
# PageSpec of pages where comments are allowed
|
||||
#comments_pagespec: blog/* and !*/Discussion
|
||||
# PageSpec of pages where posting new comments is not allowed
|
||||
#comments_closed_pagespec: blog/controversial or blog/flamewar
|
||||
# Base name for comments, e.g. "comment_" for pages like "sandbox/comment_12"
|
||||
#comments_pagename: ''
|
||||
# Interpret directives in comments?
|
||||
#comments_allowdirectives: 0
|
||||
# Allow anonymous commenters to set an author name?
|
||||
#comments_allowauthor: 0
|
||||
# commit comments to the VCS
|
||||
#comments_commit: 1
|
||||
# Restrict formats for comments to (no restriction if empty)
|
||||
#comments_allowformats: mdwn txt
|
||||
|
||||
# getsource plugin
|
||||
# Mime type for returned source.
|
||||
#getsource_mimetype: text/plain; charset=utf-8
|
||||
|
||||
# mirrorlist plugin
|
||||
# list of mirrors
|
||||
#mirrorlist: {}
|
||||
# generate links that point to the mirrors' ikiwiki CGI
|
||||
#mirrorlist_use_cgi: 1
|
||||
|
||||
# repolist plugin
|
||||
# URIs of repositories containing the wiki's source
|
||||
#repositories:
|
||||
#- svn://svn.example.org/wiki/trunk
|
||||
|
||||
# search plugin
|
||||
# path to the omega cgi program
|
||||
#omega_cgi: /usr/lib/cgi-bin/omega/omega
|
||||
# use google site search rather than internal xapian index?
|
||||
#google_search: 1
|
||||
|
||||
# theme plugin
|
||||
# name of theme to enable
|
||||
#theme: actiontabs
|
||||
|
||||
# websetup plugin
|
||||
# list of plugins that cannot be enabled/disabled via the web interface
|
||||
#websetup_force_plugins: []
|
||||
# list of additional setup field keys to treat as unsafe
|
||||
#websetup_unsafe: []
|
||||
# show unsafe settings, read-only, in web interface?
|
||||
#websetup_show_unsafe: 1
|
||||
|
||||
######################################################################
|
||||
# widget plugins
|
||||
# (calendar, color, conditional, cutpaste, date, format, fortune,
|
||||
# graphviz, haiku, headinganchors, img, linkmap, listdirectives, map,
|
||||
# more, orphans, pagecount, pagestats, poll, polygen, postsparkline,
|
||||
# progress, shortcut, sparkline, table, template, teximg, toc, toggle,
|
||||
# version)
|
||||
######################################################################
|
||||
|
||||
# calendar plugin
|
||||
# base of the archives hierarchy
|
||||
#archivebase: archives
|
||||
# PageSpec of pages to include in the archives, if option `calendar_autocreate` is true.
|
||||
#archive_pagespec: page(posts/*) and !*/Discussion
|
||||
# autocreate new calendar pages?
|
||||
#calendar_autocreate: 1
|
||||
# if set, when building calendar pages, also build pages of year and month when no pages were published (building empty calendars).
|
||||
#calendar_fill_gaps: 1
|
||||
|
||||
# img plugin
|
||||
# Image formats to process (jpeg, png, gif, svg, pdf or 'everything' to accept all)
|
||||
#img_allowed_formats: ''
|
||||
|
||||
# listdirectives plugin
|
||||
# directory in srcdir that contains directive descriptions
|
||||
#directive_description_dir: ikiwiki/directive
|
||||
|
||||
# teximg plugin
|
||||
# Should teximg use dvipng to render, or dvips and convert?
|
||||
#teximg_dvipng: ''
|
||||
# LaTeX prefix for teximg plugin
|
||||
#teximg_prefix: |
|
||||
# \documentclass{article}
|
||||
# \usepackage[utf8]{inputenc}
|
||||
# \usepackage{amsmath}
|
||||
# \usepackage{amsfonts}
|
||||
# \usepackage{amssymb}
|
||||
# \pagestyle{empty}
|
||||
# \begin{document}
|
||||
# LaTeX postfix for teximg plugin
|
||||
#teximg_postfix: \end{document}
|
||||
|
||||
######################################################################
|
||||
# other plugins
|
||||
# (aggregate, amazon_s3, autoindex, brokenlinks, camelcase, ddate, embed,
|
||||
# favicon, filecheck, flattr, goodstuff, htmlbalance, localstyle,
|
||||
# loginselector, notifyemail, pagetemplate, pingee, pinger, prettydate,
|
||||
# recentchanges, recentchangesdiff, relativedate, rsync, sidebar,
|
||||
# smiley, sortnaturally, tag, testpagespec, trail, transient)
|
||||
######################################################################
|
||||
|
||||
# aggregate plugin
|
||||
# enable aggregation to internal pages?
|
||||
#aggregateinternal: 1
|
||||
# allow aggregation to be triggered via the web?
|
||||
#aggregate_webtrigger: 0
|
||||
|
||||
# amazon_s3 plugin
|
||||
# public access key id
|
||||
#amazon_s3_key_id: XXXXXXXXXXXXXXXXXXXX
|
||||
# file holding secret key (must not be readable by others!)
|
||||
#amazon_s3_key_id: /home/mcsontos/.s3_key
|
||||
# globally unique name of bucket to store wiki in
|
||||
#amazon_s3_bucket: mywiki
|
||||
# a prefix to prepend to each page name
|
||||
#amazon_s3_prefix: wiki/
|
||||
# which S3 datacenter to use (leave blank for default)
|
||||
#amazon_s3_location: EU
|
||||
# store each index file twice? (allows urls ending in "/index.html" and "/")
|
||||
#amazon_s3_dupindex: 0
|
||||
|
||||
# autoindex plugin
|
||||
# commit autocreated index pages
|
||||
#autoindex_commit: 1
|
||||
|
||||
# camelcase plugin
|
||||
# list of words to not turn into links
|
||||
#camelcase_ignore: []
|
||||
|
||||
# flattr plugin
|
||||
# userid or user name to use by default for Flattr buttons
|
||||
#flattr_userid: joeyh
|
||||
|
||||
# pinger plugin
|
||||
# how many seconds to try pinging before timing out
|
||||
#pinger_timeout: 15
|
||||
|
||||
# prettydate plugin
|
||||
# format to use to display date
|
||||
#prettydateformat: '%X, %B %o, %Y'
|
||||
|
||||
# recentchanges plugin
|
||||
# name of the recentchanges page
|
||||
recentchangespage: recentchanges
|
||||
# number of changes to track
|
||||
recentchangesnum: 100
|
||||
|
||||
# rsync plugin
|
||||
# command to run to sync updated pages
|
||||
#rsync_command: rsync -qa --delete . user@host:/path/to/docroot/
|
||||
|
||||
# sidebar plugin
|
||||
# show sidebar page on all pages?
|
||||
#global_sidebars: 1
|
||||
|
||||
# tag plugin
|
||||
# parent page tags are located under
|
||||
#tagbase: tag
|
||||
# autocreate new tag pages?
|
||||
#tag_autocreate: 1
|
||||
# commit autocreated tag pages
|
||||
#tag_autocreate_commit: 1
|
||||
@@ -20,7 +20,7 @@ include $(top_builddir)/make.tmpl
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
cmds.h: $(top_srcdir)/tools/command-lines.in $(top_srcdir)/tools/license.inc Makefile
|
||||
@echo " [GEN] $@"
|
||||
$(SHOW) " [GEN] $@"
|
||||
$(Q) \
|
||||
( cat $(top_srcdir)/tools/license.inc && \
|
||||
echo "/* Do not edit. This file is generated by the Makefile. */" && \
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
/* The path to 'cache_restore', if available. */
|
||||
#undef CACHE_RESTORE_CMD
|
||||
|
||||
/* Define to 1 if the `closedir' function returns void instead of int. */
|
||||
/* Define to 1 if the 'closedir' function returns void instead of int. */
|
||||
#undef CLOSEDIR_VOID
|
||||
|
||||
/* Path to cmirrord pidfile. */
|
||||
@@ -43,6 +43,9 @@
|
||||
/* Name of default metadata cache subdirectory. */
|
||||
#undef DEFAULT_CACHE_SUBDIR
|
||||
|
||||
/* Path to exit-on dmeventd file. */
|
||||
#undef DEFAULT_DMEVENTD_EXIT_ON_PATH
|
||||
|
||||
/* Define default node creation behavior with dmsetup create */
|
||||
#undef DEFAULT_DM_ADD_NODE
|
||||
|
||||
@@ -55,6 +58,9 @@
|
||||
/* Default system configuration directory. */
|
||||
#undef DEFAULT_ETC_DIR
|
||||
|
||||
/* Default for lvm.conf event_activation. */
|
||||
#undef DEFAULT_EVENT_ACTIVATION
|
||||
|
||||
/* Name of default locking directory. */
|
||||
#undef DEFAULT_LOCK_DIR
|
||||
|
||||
@@ -64,6 +70,9 @@
|
||||
/* Default directory to keep PID files in. */
|
||||
#undef DEFAULT_PID_DIR
|
||||
|
||||
/* Path to /proc. */
|
||||
#undef DEFAULT_PROC_DIR
|
||||
|
||||
/* Name of default configuration profile subdirectory. */
|
||||
#undef DEFAULT_PROFILE_SUBDIR
|
||||
|
||||
@@ -133,7 +142,7 @@
|
||||
/* Define to use GNU versioning in the shared library. */
|
||||
#undef GNU_SYMVER
|
||||
|
||||
/* Define to 1 if you have the `alarm' function. */
|
||||
/* Define to 1 if you have the 'alarm' function. */
|
||||
#undef HAVE_ALARM
|
||||
|
||||
/* Define to 1 if you have 'alloca', as a function or macro. */
|
||||
@@ -151,7 +160,7 @@
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#undef HAVE_ASSERT_H
|
||||
|
||||
/* Define to 1 if you have the `atexit' function. */
|
||||
/* Define to 1 if you have the 'atexit' function. */
|
||||
#undef HAVE_ATEXIT
|
||||
|
||||
/* Define if blkid.h has BLKID_SUBLKS_FSINFO */
|
||||
@@ -163,16 +172,16 @@
|
||||
/* Define to 1 if canonicalize_file_name is available. */
|
||||
#undef HAVE_CANONICALIZE_FILE_NAME
|
||||
|
||||
/* Define to 1 if your system has a working `chown' function. */
|
||||
/* Define to 1 if your system has a working 'chown' function. */
|
||||
#undef HAVE_CHOWN
|
||||
|
||||
/* Define to 1 if you have the `clock_gettime' function. */
|
||||
/* Define to 1 if you have the 'clock_gettime' function. */
|
||||
#undef HAVE_CLOCK_GETTIME
|
||||
|
||||
/* Define to 1 if you have the <ctype.h> header file. */
|
||||
#undef HAVE_CTYPE_H
|
||||
|
||||
/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
|
||||
/* Define to 1 if you have the declaration of 'strerror_r', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_STRERROR_R
|
||||
|
||||
@@ -182,7 +191,7 @@
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||
/* Define to 1 if you don't have 'vprintf' but do have '_doprnt.' */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define to 1 if you have the <editline/readline.h> header file. */
|
||||
@@ -194,19 +203,19 @@
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `ffs' function. */
|
||||
/* Define to 1 if you have the 'ffs' function. */
|
||||
#undef HAVE_FFS
|
||||
|
||||
/* Define to 1 if you have the <float.h> header file. */
|
||||
#undef HAVE_FLOAT_H
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
/* Define to 1 if you have the 'fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define to 1 if you have the `ftruncate' function. */
|
||||
/* Define to 1 if you have the 'ftruncate' function. */
|
||||
#undef HAVE_FTRUNCATE
|
||||
|
||||
/* Define to 1 if you have the `gethostname' function. */
|
||||
/* Define to 1 if you have the 'gethostname' function. */
|
||||
#undef HAVE_GETHOSTNAME
|
||||
|
||||
/* Define to 1 if getline is available. */
|
||||
@@ -218,10 +227,10 @@
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
#undef HAVE_GETOPT_H
|
||||
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
/* Define to 1 if you have the 'getpagesize' function. */
|
||||
#undef HAVE_GETPAGESIZE
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
/* Define to 1 if you have the 'gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
@@ -260,60 +269,60 @@
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* Define to 1 if you have the `localtime_r' function. */
|
||||
/* Define to 1 if you have the 'localtime_r' function. */
|
||||
#undef HAVE_LOCALTIME_R
|
||||
|
||||
/* Define to 1 if `lstat' has the bug that it succeeds when given the
|
||||
/* Define to 1 if 'lstat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
#undef HAVE_LSTAT_EMPTY_STRING_BUG
|
||||
|
||||
/* Define to 1 if you have the <machine/endian.h> header file. */
|
||||
#undef HAVE_MACHINE_ENDIAN_H
|
||||
|
||||
/* Define to 1 if you have the `mallinfo2' function. */
|
||||
/* Define to 1 if you have the 'mallinfo2' function. */
|
||||
#undef HAVE_MALLINFO2
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
/* Define to 1 if your system has a GNU libc compatible 'malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#undef HAVE_MALLOC
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* Define to 1 if you have the `memchr' function. */
|
||||
/* Define to 1 if you have the 'memchr' function. */
|
||||
#undef HAVE_MEMCHR
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
/* Define to 1 if you have the 'memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the `mkdir' function. */
|
||||
/* Define to 1 if you have the 'mkdir' function. */
|
||||
#undef HAVE_MKDIR
|
||||
|
||||
/* Define to 1 if you have the `mkfifo' function. */
|
||||
/* Define to 1 if you have the 'mkfifo' function. */
|
||||
#undef HAVE_MKFIFO
|
||||
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
/* Define to 1 if you have a working 'mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define to 1 if you have the `munmap' function. */
|
||||
/* Define to 1 if you have the 'munmap' function. */
|
||||
#undef HAVE_MUNMAP
|
||||
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines 'DIR'. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the `nl_langinfo' function. */
|
||||
/* Define to 1 if you have the 'nl_langinfo' function. */
|
||||
#undef HAVE_NL_LANGINFO
|
||||
|
||||
/* Define to 1 if you have the <paths.h> header file. */
|
||||
#undef HAVE_PATHS_H
|
||||
|
||||
/* Define to 1 if you have the `prlimit' function. */
|
||||
/* Define to 1 if you have the 'prlimit' function. */
|
||||
#undef HAVE_PRLIMIT
|
||||
|
||||
/* Define to 1 if you have the `pselect' function. */
|
||||
/* Define to 1 if you have the 'pselect' function. */
|
||||
#undef HAVE_PSELECT
|
||||
|
||||
/* Define to 1 if the system has the type `ptrdiff_t'. */
|
||||
/* Define to 1 if the system has the type 'ptrdiff_t'. */
|
||||
#undef HAVE_PTRDIFF_T
|
||||
|
||||
/* Define to 1 if you have the <readline/history.h> header file. */
|
||||
@@ -322,20 +331,20 @@
|
||||
/* Define to 1 if you have the <readline/readline.h> header file. */
|
||||
#undef HAVE_READLINE_READLINE_H
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
|
||||
/* Define to 1 if your system has a GNU libc compatible 'realloc' function,
|
||||
and to 0 otherwise. */
|
||||
#undef HAVE_REALLOC
|
||||
|
||||
/* Define to 1 if you have the `realpath' function. */
|
||||
/* Define to 1 if you have the 'realpath' function. */
|
||||
#undef HAVE_REALPATH
|
||||
|
||||
/* Define to 1 to include support for realtime clock. */
|
||||
#undef HAVE_REALTIME
|
||||
|
||||
/* Define to 1 if you have the `rl_completion_matches' function. */
|
||||
/* Define to 1 if you have the 'rl_completion_matches' function. */
|
||||
#undef HAVE_RL_COMPLETION_MATCHES
|
||||
|
||||
/* Define to 1 if you have the `rmdir' function. */
|
||||
/* Define to 1 if you have the 'rmdir' function. */
|
||||
#undef HAVE_RMDIR
|
||||
|
||||
/* Define to 1 to include support for selinux. */
|
||||
@@ -350,16 +359,16 @@
|
||||
/* Define to 1 if sepol_check_context is available. */
|
||||
#undef HAVE_SEPOL
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
/* Define to 1 if you have the 'setenv' function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
/* Define to 1 if you have the 'setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#undef HAVE_SIGNAL_H
|
||||
|
||||
/* Define to 1 if `stat' has the bug that it succeeds when given the
|
||||
/* Define to 1 if 'stat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
#undef HAVE_STAT_EMPTY_STRING_BUG
|
||||
|
||||
@@ -384,22 +393,22 @@
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
/* Define to 1 if you have the 'strcasecmp' function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
/* Define to 1 if you have the 'strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define to 1 if you have the `strcspn' function. */
|
||||
/* Define to 1 if you have the 'strcspn' function. */
|
||||
#undef HAVE_STRCSPN
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
/* Define to 1 if you have the 'strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
/* Define to 1 if you have the 'strerror' function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define if you have `strerror_r'. */
|
||||
/* Define if you have 'strerror_r'. */
|
||||
#undef HAVE_STRERROR_R
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
@@ -408,47 +417,47 @@
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
/* Define to 1 if you have the 'strncasecmp' function. */
|
||||
#undef HAVE_STRNCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strndup' function. */
|
||||
/* Define to 1 if you have the 'strndup' function. */
|
||||
#undef HAVE_STRNDUP
|
||||
|
||||
/* Define to 1 if you have the `strpbrk' function. */
|
||||
/* Define to 1 if you have the 'strpbrk' function. */
|
||||
#undef HAVE_STRPBRK
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
/* Define to 1 if you have the 'strrchr' function. */
|
||||
#undef HAVE_STRRCHR
|
||||
|
||||
/* Define to 1 if you have the `strspn' function. */
|
||||
/* Define to 1 if you have the 'strspn' function. */
|
||||
#undef HAVE_STRSPN
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
/* Define to 1 if you have the 'strstr' function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
/* Define to 1 if you have the 'strtol' function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
/* Define to 1 if you have the `strtoul' function. */
|
||||
/* Define to 1 if you have the 'strtoul' function. */
|
||||
#undef HAVE_STRTOUL
|
||||
|
||||
/* Define to 1 if you have the `strtoull' function. */
|
||||
/* Define to 1 if you have the 'strtoull' function. */
|
||||
#undef HAVE_STRTOULL
|
||||
|
||||
/* Define to 1 if `st_blocks' is a member of `struct stat'. */
|
||||
/* Define to 1 if 'st_blocks' is a member of 'struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_BLOCKS
|
||||
|
||||
/* Define to 1 if `st_rdev' is a member of `struct stat'. */
|
||||
/* Define to 1 if 'st_rdev' is a member of 'struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_RDEV
|
||||
|
||||
/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use
|
||||
`HAVE_STRUCT_STAT_ST_BLOCKS' instead. */
|
||||
/* Define to 1 if your 'struct stat' has 'st_blocks'. Deprecated, use
|
||||
'HAVE_STRUCT_STAT_ST_BLOCKS' instead. */
|
||||
#undef HAVE_ST_BLOCKS
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
#undef HAVE_SYSLOG_H
|
||||
|
||||
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
|
||||
/* Define to 1 if you have the <sys/dir.h> header file, and it defines 'DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
@@ -470,7 +479,7 @@
|
||||
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines 'DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
@@ -513,7 +522,7 @@
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#undef HAVE_TIME_H
|
||||
|
||||
/* Define to 1 if you have the `uname' function. */
|
||||
/* Define to 1 if you have the 'uname' function. */
|
||||
#undef HAVE_UNAME
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
@@ -522,25 +531,25 @@
|
||||
/* valgrind.h found */
|
||||
#undef HAVE_VALGRIND
|
||||
|
||||
/* Define to 1 if you have the `versionsort' function. */
|
||||
/* Define to 1 if you have the 'versionsort' function. */
|
||||
#undef HAVE_VERSIONSORT
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
/* Define to 1 if you have the 'vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
/* Define to 1 if you have the `vprintf' function. */
|
||||
/* Define to 1 if you have the 'vprintf' function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
/* Define to 1 if 'fork' works. */
|
||||
#undef HAVE_WORKING_FORK
|
||||
|
||||
/* Define to 1 if `vfork' works. */
|
||||
/* Define to 1 if 'vfork' works. */
|
||||
#undef HAVE_WORKING_VFORK
|
||||
|
||||
/* Define to 1 if the system has the type `_Bool'. */
|
||||
/* Define to 1 if the system has the type '_Bool'. */
|
||||
#undef HAVE__BOOL
|
||||
|
||||
/* Define to 1 if the system has the `__builtin_clz' built-in function */
|
||||
@@ -573,7 +582,7 @@
|
||||
/* Define to 1 to include code that uses lvmlockd sanlock option. */
|
||||
#undef LOCKDSANLOCK_SUPPORT
|
||||
|
||||
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
|
||||
/* Define to 1 if 'lstat' dereferences a symlink specified with a trailing
|
||||
slash. */
|
||||
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
|
||||
|
||||
@@ -604,11 +613,11 @@
|
||||
/* Path to lvresize_fs_helper script. */
|
||||
#undef LVRESIZE_FS_HELPER_PATH
|
||||
|
||||
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
|
||||
/* Define to 1 if 'major', 'minor', and 'makedev' are declared in <mkdev.h>.
|
||||
*/
|
||||
#undef MAJOR_IN_MKDEV
|
||||
|
||||
/* Define to 1 if `major', `minor', and `makedev' are declared in
|
||||
/* Define to 1 if 'major', 'minor', and 'makedev' are declared in
|
||||
<sysmacros.h>. */
|
||||
#undef MAJOR_IN_SYSMACROS
|
||||
|
||||
@@ -618,6 +627,9 @@
|
||||
/* The path to 'modprobe', if available. */
|
||||
#undef MODPROBE_CMD
|
||||
|
||||
/* The path to kernel modules. */
|
||||
#undef MODULES_PATH
|
||||
|
||||
/* Define to 1 to include code that uses dbus notification. */
|
||||
#undef NOTIFYDBUS_SUPPORT
|
||||
|
||||
@@ -659,7 +671,7 @@
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define to 1 if all of the C90 standard headers exist (not just the ones
|
||||
/* Define to 1 if all of the C89 standard headers exist (not just the ones
|
||||
required in a freestanding environment). This macro is provided for
|
||||
backward compatibility; new code need not use it. */
|
||||
#undef STDC_HEADERS
|
||||
@@ -692,10 +704,10 @@
|
||||
/* The path to 'thin_restore', if available. */
|
||||
#undef THIN_RESTORE_CMD
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
/* Define to 1 if your <sys/time.h> declares 'struct tm'. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Define to 1 to enable synchronisation with udev processing. */
|
||||
/* Define to 1 to enable synchronization with udev processing. */
|
||||
#undef UDEV_SYNC_SUPPORT
|
||||
|
||||
/* Enable a valgrind aware build of pool */
|
||||
@@ -731,13 +743,13 @@
|
||||
#define below would cause a syntax error. */
|
||||
#undef _UINT8_T
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* Define to empty if 'const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* Define as 'int' if <sys/types.h> doesn't define. */
|
||||
#undef gid_t
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
/* Define to '__inline__' or '__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
@@ -762,10 +774,10 @@
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* Define to 'int' if <sys/types.h> does not define. */
|
||||
#undef mode_t
|
||||
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
/* Define to 'long int' if <sys/types.h> does not define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define as a signed integer type capable of holding a process identifier. */
|
||||
@@ -774,13 +786,13 @@
|
||||
/* Define to rpl_realloc if the replacement function should be used. */
|
||||
#undef realloc
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* Define as 'unsigned int' if <stddef.h> doesn't define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* Define as 'int' if <sys/types.h> doesn't define. */
|
||||
#undef ssize_t
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* Define as 'int' if <sys/types.h> doesn't define. */
|
||||
#undef uid_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 16 bits if
|
||||
@@ -799,5 +811,5 @@
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint8_t
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
/* Define as 'fork' if 'vfork' does not work. */
|
||||
#undef vfork
|
||||
|
||||
@@ -418,7 +418,7 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_usable_check_params check, int *is_lv)
|
||||
int dm_device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_usable_check_params check, int *is_lv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -502,7 +502,7 @@ int driver_version(char *version, size_t size)
|
||||
!dm_driver_version(_vsn, sizeof(_vsn)))
|
||||
return_0;
|
||||
|
||||
(void) dm_strncpy(version, _vsn, size);
|
||||
dm_strncpy(version, _vsn, size);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -563,12 +563,50 @@ int lvm_dm_prefix_check(int major, int minor, const char *prefix)
|
||||
return dev_manager_check_prefix_dm_major_minor(major, minor, prefix);
|
||||
}
|
||||
|
||||
/* Search modules.builtin file for built-in kernel module */
|
||||
static int _check_modules_builtin(struct cmd_context *cmd, const char *target)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line = NULL;
|
||||
size_t len;
|
||||
int r = 0;
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (dm_snprintf(path, sizeof(path), "%s/%s/modules.builtin",
|
||||
MODULES_PATH, cmd->kernel_vsn) < 0) {
|
||||
log_debug_activation("Modules path %s/%s/modules.builtin is too long.",
|
||||
MODULES_PATH, cmd->kernel_vsn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(fp = fopen(path, "r"))) {
|
||||
if (errno != ENOENT)
|
||||
log_sys_debug("fopen", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (getline(&line, &len, fp) > 0)
|
||||
if (strstr(line, target)) {
|
||||
log_debug_activation("Found %s as built-in kernel module.", target);
|
||||
r = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
free(line);
|
||||
|
||||
if (fclose(fp))
|
||||
log_sys_debug("fclose", path);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int module_present(struct cmd_context *cmd, const char *target_name)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef MODPROBE_CMD
|
||||
char module[128];
|
||||
const char *argv[] = { MODPROBE_CMD, module, NULL };
|
||||
unsigned maj, min;
|
||||
#endif
|
||||
struct stat st;
|
||||
char path[PATH_MAX];
|
||||
@@ -584,11 +622,16 @@ int module_present(struct cmd_context *cmd, const char *target_name)
|
||||
log_debug_activation("Module directory %s exists.", path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (path[i] == '/' && _check_modules_builtin(cmd, path + i + 1))
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef MODPROBE_CMD
|
||||
if (strcmp(target_name, TARGET_NAME_VDO) == 0)
|
||||
argv[1] = MODULE_NAME_VDO; /* ATM kvdo is without dm- prefix */
|
||||
if ((strcmp(target_name, TARGET_NAME_VDO) == 0) &&
|
||||
(sscanf(cmd->kernel_vsn, "%u.%u", &maj, &min) == 2) &&
|
||||
((maj < 6) || ((maj == 6) && (min < 9))))
|
||||
argv[1] = MODULE_NAME_VDO; /* Kernels < 6.9 -> "kvdo" without dm- prefix */
|
||||
else if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
|
||||
log_error("module_present module name too long: %s",
|
||||
target_name);
|
||||
@@ -629,13 +672,13 @@ int target_present(struct cmd_context *cmd, const char *target_name,
|
||||
&maj, &min, &patchlevel);
|
||||
}
|
||||
|
||||
int get_device_list(const struct volume_group *vg, struct dm_list **devs,
|
||||
unsigned *devs_features)
|
||||
int get_dm_active_devices(const struct volume_group *vg, struct dm_list **devs,
|
||||
unsigned *devs_features)
|
||||
{
|
||||
if (!activation())
|
||||
return 0;
|
||||
|
||||
return dev_manager_get_device_list(NULL, devs, devs_features);
|
||||
return dev_manager_get_dm_active_devices(NULL, devs, devs_features);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1399,9 +1442,9 @@ static int _lv_active(struct cmd_context *cmd, const struct logical_volume *lv)
|
||||
struct lvinfo info;
|
||||
|
||||
if (!lv_info(cmd, lv, 0, &info, 0, 0)) {
|
||||
log_debug("Cannot determine activation status of %s%s.",
|
||||
display_lvname(lv),
|
||||
activation() ? "" : " (no device driver)");
|
||||
log_debug_activation("Cannot determine activation status of %s%s.",
|
||||
display_lvname(lv),
|
||||
activation() ? "" : " (no device driver)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1606,18 +1649,7 @@ char *get_monitor_dso_path(struct cmd_context *cmd, int id)
|
||||
|
||||
static char *_build_target_uuid(struct cmd_context *cmd, const struct logical_volume *lv)
|
||||
{
|
||||
const char *layer;
|
||||
|
||||
if (lv_is_thin_pool(lv))
|
||||
layer = "tpool"; /* Monitor "tpool" for the "thin pool". */
|
||||
else if (lv_is_vdo_pool(lv))
|
||||
layer = "vpool"; /* Monitor "vpool" for the "VDO pool". */
|
||||
else if (lv_is_origin(lv) || lv_is_external_origin(lv))
|
||||
layer = "real"; /* Monitor "real" for "snapshot-origin". */
|
||||
else
|
||||
layer = NULL;
|
||||
|
||||
return build_dm_uuid(cmd->mem, lv, layer);
|
||||
return build_dm_uuid(cmd->mem, lv, lv_layer(lv));
|
||||
}
|
||||
|
||||
static int _device_registered_with_dmeventd(struct cmd_context *cmd,
|
||||
@@ -1760,7 +1792,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
|
||||
struct lv_segment *log_seg;
|
||||
int (*monitor_fn) (struct lv_segment *s, int e);
|
||||
uint32_t s;
|
||||
static const struct lv_activate_opts zlaopts = { 0 };
|
||||
const struct lv_activate_opts zlaopts = { 0 };
|
||||
struct lv_activate_opts mirr_laopts = { .origin_only = 1 };
|
||||
struct lvinfo info;
|
||||
const char *dso = NULL;
|
||||
@@ -1781,6 +1813,9 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
|
||||
if (monitor && !dmeventd_monitor_mode())
|
||||
return 1;
|
||||
|
||||
if (sigint_caught())
|
||||
return_0;
|
||||
|
||||
/*
|
||||
* Activation of unused cache-pool activates metadata device as
|
||||
* a public LV for clearing purpose.
|
||||
@@ -1838,8 +1873,10 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
|
||||
* each of its respective snapshots. The origin itself may
|
||||
* also need to be monitored if it is a mirror, for example,
|
||||
* so fall through to process it afterwards.
|
||||
* Before monitoring snapshots verify origin is active as with
|
||||
* external origin only read-only -real device can be active.
|
||||
*/
|
||||
if (!laopts->origin_only && lv_is_origin(lv))
|
||||
if (!laopts->origin_only && lv_is_origin(lv) && lv_info(lv->vg->cmd, lv, 0, NULL, 0, 0))
|
||||
dm_list_iterate_safe(snh, snht, &lv->snapshot_segs)
|
||||
if (!monitor_dev_for_events(cmd, dm_list_struct_base(snh,
|
||||
struct lv_segment, origin_list)->cow, NULL, monitor)) {
|
||||
@@ -1860,6 +1897,12 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
|
||||
}
|
||||
|
||||
dm_list_iterate_items(seg, &lv->segments) {
|
||||
if (sigint_caught()) {
|
||||
stack;
|
||||
r = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Recurse for AREA_LV */
|
||||
for (s = 0; s < seg->area_count; s++) {
|
||||
if (seg_type(seg, s) != AREA_LV)
|
||||
@@ -1991,7 +2034,11 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
|
||||
break;
|
||||
log_very_verbose("%s %smonitoring still pending: waiting...",
|
||||
display_lvname(lv), monitor ? "" : "un");
|
||||
usleep(10000 * i);
|
||||
if (interruptible_usleep(10000 * i)) {
|
||||
stack;
|
||||
r = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (r)
|
||||
@@ -2008,7 +2055,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
|
||||
}
|
||||
|
||||
struct detached_lv_data {
|
||||
const struct logical_volume *lv_pre;
|
||||
const struct volume_group *vg_pre;
|
||||
struct lv_activate_opts *laopts;
|
||||
int *flush_required;
|
||||
};
|
||||
@@ -2018,40 +2065,17 @@ static int _preload_detached_lv(struct logical_volume *lv, void *data)
|
||||
struct detached_lv_data *detached = data;
|
||||
struct logical_volume *lv_pre;
|
||||
|
||||
/* Check and preload removed raid image leg or metadata */
|
||||
if (lv_is_raid_image(lv)) {
|
||||
if ((lv_pre = find_lv_in_vg_by_lvid(detached->lv_pre->vg, &lv->lvid)) &&
|
||||
!lv_is_raid_image(lv_pre) && lv_is_active(lv) &&
|
||||
!_lv_preload(lv_pre, detached->laopts, detached->flush_required))
|
||||
return_0;
|
||||
} else if (lv_is_raid_metadata(lv)) {
|
||||
if ((lv_pre = find_lv_in_vg_by_lvid(detached->lv_pre->vg, &lv->lvid)) &&
|
||||
!lv_is_raid_metadata(lv_pre) && lv_is_active(lv) &&
|
||||
!_lv_preload(lv_pre, detached->laopts, detached->flush_required))
|
||||
return_0;
|
||||
} else if (lv_is_mirror_image(lv)) {
|
||||
if ((lv_pre = find_lv_in_vg_by_lvid(detached->lv_pre->vg, &lv->lvid)) &&
|
||||
!lv_is_mirror_image(lv_pre) && lv_is_active(lv) &&
|
||||
!_lv_preload(lv_pre, detached->laopts, detached->flush_required))
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (!lv_is_visible(lv) && (lv_pre = find_lv(detached->lv_pre->vg, lv->name)) &&
|
||||
/* Check if the LV was 'hidden' (non-toplevel) in committed metadata
|
||||
* and becomes 'visible' (toplevel) in precommitted metadata */
|
||||
if (!lv_is_visible(lv) &&
|
||||
(lv_pre = find_lv_in_vg_by_lvid(detached->vg_pre, &lv->lvid)) &&
|
||||
lv_is_visible(lv_pre)) {
|
||||
log_debug_activation("Preloading detached hidden volume %s as visible volume %s.",
|
||||
display_lvname(lv), display_lvname(lv_pre));
|
||||
if (!_lv_preload(lv_pre, detached->laopts, detached->flush_required))
|
||||
return_0;
|
||||
}
|
||||
|
||||
/* FIXME: condition here should be far more limiting to really
|
||||
* detect detached LVs */
|
||||
if ((lv_pre = find_lv(detached->lv_pre->vg, lv->name))) {
|
||||
if (lv_is_visible(lv_pre) && lv_is_active(lv) &&
|
||||
!lv_is_pool(lv) &&
|
||||
(!lv_is_cow(lv) || !lv_is_cow(lv_pre)) &&
|
||||
!_lv_preload(lv_pre, detached->laopts, detached->flush_required))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2097,9 +2121,13 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
|
||||
/* Ignore origin_only unless LV is origin in both old and new metadata */
|
||||
/* or LV is thin or thin pool volume */
|
||||
if (!lv_is_thin_volume(lv) && !lv_is_thin_pool(lv) &&
|
||||
!(lv_is_origin(lv) && lv_is_origin(lv_pre)))
|
||||
if (laopts->origin_only &&
|
||||
!lv_is_thin_volume(lv) && !lv_is_thin_pool(lv) &&
|
||||
!(lv_is_origin(lv) && lv_is_origin(lv_pre))) {
|
||||
log_debug_activation("Not using origin only for suspend of %s.",
|
||||
display_lvname(lv));
|
||||
laopts->origin_only = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Preload devices for the LV.
|
||||
@@ -2142,7 +2170,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
/*
|
||||
* Search for existing LVs that have become detached and preload them.
|
||||
*/
|
||||
detached.lv_pre = lv_pre;
|
||||
detached.vg_pre = lv_pre->vg;
|
||||
detached.laopts = laopts;
|
||||
detached.flush_required = &flush_required;
|
||||
|
||||
@@ -2177,7 +2205,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
!lv_is_thin_pool(lv) &&
|
||||
!lv_is_vdo(lv) &&
|
||||
!lv_is_vdo_pool(lv)))) {
|
||||
log_debug("Requiring flush for LV %s.", display_lvname(lv));
|
||||
log_debug_activation("Requiring flush for LV %s.", display_lvname(lv));
|
||||
flush_required = 1;
|
||||
}
|
||||
|
||||
@@ -2185,16 +2213,23 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
/* FIXME Consider aborting here */
|
||||
stack;
|
||||
|
||||
if (!laopts->origin_only &&
|
||||
(lv_is_origin(lv_pre) || lv_is_cow(lv_pre)))
|
||||
lockfs = 1;
|
||||
|
||||
/* Converting non-thin LV to thin external origin ? */
|
||||
if (!lv_is_thin_volume(lv) && lv_is_thin_volume(lv_pre))
|
||||
lockfs = 1; /* Sync before conversion */
|
||||
|
||||
/* Require fs synchronization when taking a thin snapshot */
|
||||
if (laopts->origin_only && lv_is_thin_volume(lv) && lv_is_thin_volume(lv_pre))
|
||||
lockfs = 1;
|
||||
/* Require fs synchronization when taking a thick snapshot */
|
||||
else if (!laopts->origin_only &&
|
||||
(lv_is_origin(lv_pre) || lv_is_cow(lv_pre)))
|
||||
lockfs = 1;
|
||||
/* Require fs synchronization when converting a non-thin LV to a thin LV or
|
||||
* a non/thin LV with/out external origin to a thin LV with external origin LV. */
|
||||
else if (!laopts->origin_only &&
|
||||
lv_is_thin_volume(lv_pre) && /* new LV is a Thin */
|
||||
(!lv_is_thin_volume(lv) || /* and either the existing LV is NOT a Thin */
|
||||
(first_seg(lv_pre)->external_lv && /* or the existing LV IS Thin and the new LV is Thin with the external origin */
|
||||
(!first_seg(lv)->external_lv || /* and check if existing Thin is either without the external origin */
|
||||
memcmp(&first_seg(lv_pre)->external_lv->lvid.id[1], /* or it uses a different external origin */
|
||||
&first_seg(lv)->external_lv->lvid.id[1], ID_LEN) != 0))))
|
||||
lockfs = 1;
|
||||
|
||||
if (!lv_is_locked(lv) && lv_is_locked(lv_pre) &&
|
||||
(pvmove_lv = find_pvmove_lv_in_lv(lv_pre))) {
|
||||
@@ -2285,12 +2320,12 @@ static int _check_suspended_lv(struct logical_volume *lv, void *data)
|
||||
struct lvinfo info;
|
||||
|
||||
if (lv_info(lv->vg->cmd, lv, 0, &info, 0, 0) && info.exists && info.suspended) {
|
||||
log_debug("Found suspended LV %s in critical section().", display_lvname(lv));
|
||||
log_debug_activation("Found suspended LV %s in critical section().", display_lvname(lv));
|
||||
return 0; /* There is suspended subLV in the tree */
|
||||
}
|
||||
|
||||
if (lv_layer(lv) && lv_info(lv->vg->cmd, lv, 1, &info, 0, 0) && info.exists && info.suspended) {
|
||||
log_debug("Found suspended layered LV %s in critical section().", display_lvname(lv));
|
||||
log_debug_activation("Found suspended layered LV %s in critical section().", display_lvname(lv));
|
||||
return 0; /* There is suspended subLV in the tree */
|
||||
}
|
||||
|
||||
@@ -2423,10 +2458,9 @@ static int _lv_has_open_snapshots(const struct logical_volume *lv)
|
||||
int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logical_volume *lv)
|
||||
{
|
||||
struct lvinfo info;
|
||||
static const struct lv_activate_opts laopts = { .skip_in_use = 1 };
|
||||
const struct lv_activate_opts laopts = { .skip_in_use = 1 };
|
||||
struct dm_list *snh;
|
||||
int r = 0;
|
||||
unsigned tmp_state;
|
||||
|
||||
if (!activation())
|
||||
return 1;
|
||||
@@ -2499,9 +2533,6 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logi
|
||||
}
|
||||
critical_section_dec(cmd, "deactivated");
|
||||
|
||||
tmp_state = cmd->disable_dm_devs;
|
||||
cmd->disable_dm_devs = 1;
|
||||
|
||||
if (!lv_info(cmd, lv, 0, &info, 0, 0) || info.exists) {
|
||||
/* Turn into log_error, but we do not log error */
|
||||
log_debug_activation("Deactivated volume is still %s present.",
|
||||
@@ -2509,7 +2540,6 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logi
|
||||
r = 0;
|
||||
}
|
||||
|
||||
cmd->disable_dm_devs = tmp_state;
|
||||
out:
|
||||
|
||||
return r;
|
||||
@@ -2605,6 +2635,8 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
|
||||
if (!lv_is_visible(lv) && lv_is_component(lv)) {
|
||||
laopts->read_only = 1;
|
||||
laopts->component_lv = lv;
|
||||
} else if (lv_is_pool_metadata_spare(lv)) {
|
||||
laopts->component_lv = lv;
|
||||
} else if (filter)
|
||||
laopts->read_only = _passes_readonly_filter(cmd, lv);
|
||||
|
||||
@@ -2721,16 +2753,16 @@ static int _remove_dm_dev_by_name(const char *name)
|
||||
/* Work all segments of @lv removing any existing, closed "*-missing_N_0" sub devices. */
|
||||
static int _lv_remove_any_missing_subdevs(struct logical_volume *lv)
|
||||
{
|
||||
if (lv) {
|
||||
uint32_t seg_no = 0;
|
||||
char name[257];
|
||||
struct lv_segment *seg;
|
||||
char name[NAME_LEN];
|
||||
struct lv_segment *seg;
|
||||
uint32_t seg_no = 0;
|
||||
|
||||
if (lv) {
|
||||
dm_list_iterate_items(seg, &lv->segments) {
|
||||
if (dm_snprintf(name, sizeof(name), "%s-%s-missing_%u_0", seg->lv->vg->name, seg->lv->name, seg_no) < 0)
|
||||
return_0;
|
||||
if (!_remove_dm_dev_by_name(name))
|
||||
return 0;
|
||||
return_0;
|
||||
|
||||
seg_no++;
|
||||
}
|
||||
@@ -2748,10 +2780,10 @@ int lv_deactivate_any_missing_subdevs(const struct logical_volume *lv)
|
||||
for (s = 0; s < seg->area_count; s++) {
|
||||
if (seg_type(seg, s) == AREA_LV &&
|
||||
!_lv_remove_any_missing_subdevs(seg_lv(seg, s)))
|
||||
return 0;
|
||||
return_0;
|
||||
if (seg->meta_areas && seg_metatype(seg, s) == AREA_LV &&
|
||||
!_lv_remove_any_missing_subdevs(seg_metalv(seg, s)))
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -107,8 +107,12 @@ int target_present(struct cmd_context *cmd, const char *target_name,
|
||||
int target_version(const char *target_name, uint32_t *maj,
|
||||
uint32_t *min, uint32_t *patchlevel);
|
||||
|
||||
int get_device_list(const struct volume_group *vg, struct dm_list **devs,
|
||||
int get_dm_active_devices(const struct volume_group *vg, struct dm_list **devs,
|
||||
unsigned *devs_features);
|
||||
int devno_dm_uuid(struct cmd_context *cmd, int major, int minor,
|
||||
char *uuid_buf, size_t uuid_buf_size);
|
||||
int dev_dm_uuid(struct cmd_context *cmd, struct device *dev,
|
||||
char *uuid_buf, size_t uuid_buf_size);
|
||||
|
||||
int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype);
|
||||
int lvm_dm_prefix_check(int major, int minor, const char *prefix);
|
||||
@@ -260,7 +264,7 @@ struct dev_usable_check_params {
|
||||
* Returns 1 if mapped device is not suspended, blocked or
|
||||
* is using a reserved name.
|
||||
*/
|
||||
int device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_usable_check_params check, int *is_lv);
|
||||
int dm_device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_usable_check_params check, int *is_lv);
|
||||
|
||||
/*
|
||||
* Declaration moved here from fs.h to keep header fs.h hidden
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -108,7 +108,7 @@ int dev_manager_device_uses_vg(struct device *dev,
|
||||
int dev_manager_remove_dm_major_minor(uint32_t major, uint32_t minor);
|
||||
|
||||
int dev_manager_check_prefix_dm_major_minor(uint32_t major, uint32_t minor, const char *prefix);
|
||||
int dev_manager_get_device_list(const char *prefix, struct dm_list **devs,
|
||||
unsigned *devs_features);
|
||||
int dev_manager_get_dm_active_devices(const char *prefix, struct dm_list **devs,
|
||||
unsigned *devs_features);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -112,7 +112,7 @@ static void _rm_blks(const char *dir)
|
||||
if (!S_ISBLK(buf.st_mode))
|
||||
continue;
|
||||
log_very_verbose("Removing %s", path);
|
||||
if (unlink(path) < 0)
|
||||
if (unlink(path) && (errno != ENOENT))
|
||||
log_sys_debug("unlink", path);
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ static int _mk_link(const char *dev_dir, const char *vg_name,
|
||||
_rm_blks(vg_path);
|
||||
|
||||
log_very_verbose("Removing %s", lvm1_group_path);
|
||||
if (unlink(lvm1_group_path) < 0)
|
||||
if (unlink(lvm1_group_path) && (errno != ENOENT))
|
||||
log_sys_debug("unlink", lvm1_group_path);
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ static int _mk_link(const char *dev_dir, const char *vg_name,
|
||||
}
|
||||
|
||||
log_very_verbose("Removing %s", lv_path);
|
||||
if (unlink(lv_path) < 0) {
|
||||
if (unlink(lv_path) && (errno != ENOENT)) {
|
||||
log_sys_error("unlink", lv_path);
|
||||
return 0;
|
||||
}
|
||||
@@ -252,7 +252,7 @@ static int _rm_link(const char *dev_dir, const char *vg_name,
|
||||
}
|
||||
|
||||
log_very_verbose("Removing link %s", lv_path);
|
||||
if (unlink(lv_path) < 0) {
|
||||
if (unlink(lv_path) && (errno != ENOENT)) {
|
||||
log_sys_error("unlink", lv_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
150
lib/cache/lvmcache.c
vendored
150
lib/cache/lvmcache.c
vendored
@@ -83,7 +83,6 @@ static struct dm_hash_table *_vgname_hash = NULL;
|
||||
static DM_LIST_INIT(_vginfos);
|
||||
static DM_LIST_INIT(_initial_duplicates);
|
||||
static DM_LIST_INIT(_unused_duplicates);
|
||||
static DM_LIST_INIT(_prev_unused_duplicate_devs);
|
||||
static int _vgs_locked = 0;
|
||||
static int _found_duplicate_vgnames = 0;
|
||||
static int _outdated_warning = 0;
|
||||
@@ -99,7 +98,6 @@ int lvmcache_init(struct cmd_context *cmd)
|
||||
dm_list_init(&_vginfos);
|
||||
dm_list_init(&_initial_duplicates);
|
||||
dm_list_init(&_unused_duplicates);
|
||||
dm_list_init(&_prev_unused_duplicate_devs);
|
||||
|
||||
if (!(_vgname_hash = dm_hash_create(127)))
|
||||
return 0;
|
||||
@@ -191,21 +189,6 @@ static void _destroy_device_list(struct dm_list *head)
|
||||
dm_list_init(head);
|
||||
}
|
||||
|
||||
bool lvmcache_has_bad_metadata(struct device *dev)
|
||||
{
|
||||
struct lvmcache_info *info;
|
||||
|
||||
if (!(info = lvmcache_info_from_pvid(dev->pvid, dev, 0))) {
|
||||
/* shouldn't happen */
|
||||
log_error("No lvmcache info for checking bad metadata on %s", dev_name(dev));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (info->mda1_bad || info->mda2_bad)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void lvmcache_save_bad_mda(struct lvmcache_info *info, struct metadata_area *mda)
|
||||
{
|
||||
if (mda->mda_num == 1)
|
||||
@@ -401,10 +384,10 @@ const char *lvmcache_vgid_from_vgname(struct cmd_context *cmd, const char *vgnam
|
||||
|
||||
if (_found_duplicate_vgnames) {
|
||||
if (!(vginfo = _search_vginfos_list(vgname, NULL)))
|
||||
return_NULL;
|
||||
return NULL;
|
||||
} else {
|
||||
if (!(vginfo = dm_hash_lookup(_vgname_hash, vgname)))
|
||||
return_NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (vginfo->has_duplicate_local_vgname) {
|
||||
@@ -844,7 +827,6 @@ static void _choose_duplicates(struct cmd_context *cmd,
|
||||
int same_size1, same_size2;
|
||||
int same_name1 = 0, same_name2 = 0;
|
||||
int same_id1 = 0, same_id2 = 0;
|
||||
int prev_unchosen1, prev_unchosen2;
|
||||
int change;
|
||||
|
||||
dm_list_init(&new_unused);
|
||||
@@ -912,8 +894,10 @@ next:
|
||||
}
|
||||
|
||||
/* Remove dev_mpath from altdevs. */
|
||||
if ((devl = device_list_find_dev(&altdevs, dev_mpath)))
|
||||
if ((devl = device_list_find_dev(&altdevs, dev_mpath))) {
|
||||
dm_list_del(&devl->list);
|
||||
free(devl);
|
||||
}
|
||||
|
||||
/* Remove info from lvmcache that came from the component dev. */
|
||||
log_debug("Ignoring multipath component %s with PVID %s (dropping info)", dev_name(dev_drop), pvid);
|
||||
@@ -950,6 +934,7 @@ next:
|
||||
|
||||
log_debug("Ignoring multipath component %s with PVID %s (dropping duplicate)", dev_name(dev_drop), pvid);
|
||||
dm_list_del(&devl->list);
|
||||
free(devl);
|
||||
|
||||
cmd->filter->wipe(cmd, cmd->filter, dev_drop, NULL);
|
||||
dev_drop->flags &= ~DEV_SCAN_FOUND_LABEL;
|
||||
@@ -979,8 +964,10 @@ next:
|
||||
}
|
||||
|
||||
/* Remove dev_md from altdevs. */
|
||||
if ((devl = device_list_find_dev(&altdevs, dev_md)))
|
||||
if ((devl = device_list_find_dev(&altdevs, dev_md))) {
|
||||
dm_list_del(&devl->list);
|
||||
free(devl);
|
||||
}
|
||||
|
||||
/* Remove info from lvmcache that came from the component dev. */
|
||||
log_debug("Ignoring md component %s with PVID %s (dropping info)", dev_name(dev_drop), pvid);
|
||||
@@ -1007,8 +994,10 @@ next:
|
||||
}
|
||||
|
||||
/* Remove dev_md from altdevs. */
|
||||
if ((devl = device_list_find_dev(&altdevs, dev_md)))
|
||||
if ((devl = device_list_find_dev(&altdevs, dev_md))) {
|
||||
dm_list_del(&devl->list);
|
||||
free(devl);
|
||||
}
|
||||
}
|
||||
|
||||
if (info && !dev_md) {
|
||||
@@ -1036,6 +1025,7 @@ next:
|
||||
|
||||
log_debug("Ignoring md component %s with PVID %s (dropping duplicate)", dev_name(dev_drop), pvid);
|
||||
dm_list_del(&devl->list);
|
||||
free(devl);
|
||||
|
||||
cmd->filter->wipe(cmd, cmd->filter, dev_drop, NULL);
|
||||
dev_drop->flags &= ~DEV_SCAN_FOUND_LABEL;
|
||||
@@ -1085,21 +1075,6 @@ next:
|
||||
if (dev1 == dev2)
|
||||
continue;
|
||||
|
||||
prev_unchosen1 = device_list_find_dev(&_unused_duplicates, dev1) ? 1 :0;
|
||||
prev_unchosen2 = device_list_find_dev(&_unused_duplicates, dev2) ? 1 :0;
|
||||
|
||||
if (!prev_unchosen1 && !prev_unchosen2) {
|
||||
/*
|
||||
* The prev list saves the unchosen preference across
|
||||
* lvmcache_destroy. Sometimes a single command will
|
||||
* fill lvmcache, destroy it, and refill it, and we
|
||||
* want the same duplicate preference to be preserved
|
||||
* in each instance of lvmcache for a single command.
|
||||
*/
|
||||
prev_unchosen1 = device_list_find_dev(&_prev_unused_duplicate_devs, dev1) ? 1 :0;
|
||||
prev_unchosen2 = device_list_find_dev(&_prev_unused_duplicate_devs, dev2) ? 1 : 0;
|
||||
}
|
||||
|
||||
dev1_major = MAJOR(dev1->dev);
|
||||
dev1_minor = MINOR(dev1->dev);
|
||||
dev2_major = MAJOR(dev2->dev);
|
||||
@@ -1162,11 +1137,6 @@ next:
|
||||
dev_name(dev1), (unsigned long long)dev1_size,
|
||||
dev_name(dev2), (unsigned long long)dev2_size);
|
||||
|
||||
log_debug_cache("PV %s: %s was prev %s. %s was prev %s.",
|
||||
devl->dev->pvid,
|
||||
dev_name(dev1), prev_unchosen1 ? "not chosen" : "<none>",
|
||||
dev_name(dev2), prev_unchosen2 ? "not chosen" : "<none>");
|
||||
|
||||
log_debug_cache("PV %s: %s %s subsystem. %s %s subsystem.",
|
||||
devl->dev->pvid,
|
||||
dev_name(dev1), in_subsys1 ? "is in" : "is not in",
|
||||
@@ -1194,14 +1164,7 @@ next:
|
||||
|
||||
change = 0;
|
||||
|
||||
if (prev_unchosen1 && !prev_unchosen2) {
|
||||
/* change to 2 (NB when unchosen is set we unprefer) */
|
||||
change = 1;
|
||||
reason = "of previous preference";
|
||||
} else if (prev_unchosen2 && !prev_unchosen1) {
|
||||
/* keep 1 (NB when unchosen is set we unprefer) */
|
||||
reason = "of previous preference";
|
||||
} else if (same_id1 && !same_id2) {
|
||||
if (same_id1 && !same_id2) {
|
||||
/* keep 1 */
|
||||
reason = "device id";
|
||||
} else if (same_id2 && !same_id1) {
|
||||
@@ -1597,12 +1560,9 @@ int lvmcache_label_scan(struct cmd_context *cmd)
|
||||
{
|
||||
struct dm_list del_cache_devs;
|
||||
struct dm_list add_cache_devs;
|
||||
struct dm_list renamed_devs;
|
||||
struct lvmcache_info *info;
|
||||
struct device_list *devl;
|
||||
|
||||
dm_list_init(&renamed_devs);
|
||||
|
||||
log_debug_cache("lvmcache label scan begin");
|
||||
|
||||
/*
|
||||
@@ -1630,25 +1590,43 @@ int lvmcache_label_scan(struct cmd_context *cmd)
|
||||
if (!dm_list_empty(&cmd->device_ids_check_serial)) {
|
||||
struct dm_list scan_devs;
|
||||
dm_list_init(&scan_devs);
|
||||
device_ids_check_serial(cmd, &scan_devs, NULL, 0);
|
||||
device_ids_check_serial(cmd, &scan_devs, 0, NULL);
|
||||
if (!dm_list_empty(&scan_devs))
|
||||
label_scan_devs(cmd, cmd->filter, &scan_devs);
|
||||
}
|
||||
|
||||
/*
|
||||
* When devnames are used as device ids (which is dispreferred),
|
||||
* changing/unstable devnames can lead to entries in the devices file
|
||||
* not being matched to a dev even if the PV is present on the system.
|
||||
* Or, a devices file entry may have been matched to the wrong device
|
||||
* (with the previous name) that does not have the PVID specified in
|
||||
* the entry. This function detects that problem, scans labels on all
|
||||
* devs on the system to find the missing PVIDs, and corrects the
|
||||
* devices file. We then need to run label scan on these correct
|
||||
* devices.
|
||||
* device_ids_invalid is set by device_ids_validate() when there
|
||||
* are entries in the devices file that need to be corrected,
|
||||
* i.e. device IDs read from the system and/or PVIDs read from
|
||||
* disk do not match info in the devices file. This is usually
|
||||
* related to incorrect device names which routinely change on
|
||||
* reboot. When device names change for entries that use
|
||||
* IDTYPE=devname, it often means that all devs on the system
|
||||
* need to be scanned to find the new device for the PVIDs.
|
||||
* device_ids_validate() will update the devices file to correct
|
||||
* some info, but to locate new devices for PVIDs, it defers
|
||||
* to device_ids_search() which involves label scanning.
|
||||
*
|
||||
* device_ids_refresh_trigger is set by device_ids_read() when
|
||||
* it sees that the local machine doesn't match the machine
|
||||
* that wrote the devices file, and device IDs of all types
|
||||
* may need to be replaced for the PVIDs in the devices file.
|
||||
* This also means that all devs on the system need to be
|
||||
* scanned to find the new devices for the PVIDs.
|
||||
*
|
||||
* When device_ids_search() locates the correct devices
|
||||
* for the PVs in the devices file, it returns those new
|
||||
* devices in the refresh_devs list. Those devs need to
|
||||
* be passed to label_scan to populate lvmcache info.
|
||||
*/
|
||||
device_ids_find_renamed_devs(cmd, &renamed_devs, NULL, 0);
|
||||
if (!dm_list_empty(&renamed_devs))
|
||||
label_scan_devs(cmd, cmd->filter, &renamed_devs);
|
||||
if (cmd->device_ids_invalid || cmd->device_ids_refresh_trigger) {
|
||||
struct dm_list new_devs;
|
||||
dm_list_init(&new_devs);
|
||||
device_ids_search(cmd, &new_devs, 0, 0, NULL);
|
||||
if (!dm_list_empty(&new_devs))
|
||||
label_scan_devs(cmd, cmd->filter, &new_devs);
|
||||
}
|
||||
|
||||
/*
|
||||
* _choose_duplicates() returns:
|
||||
@@ -1687,6 +1665,8 @@ int lvmcache_label_scan(struct cmd_context *cmd)
|
||||
label_scan_dev(cmd, devl->dev);
|
||||
}
|
||||
|
||||
_destroy_device_list(&add_cache_devs);
|
||||
|
||||
dm_list_splice(&_unused_duplicates, &del_cache_devs);
|
||||
|
||||
/* Warn about unused duplicates that the user might want to resolve. */
|
||||
@@ -2635,20 +2615,6 @@ void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset)
|
||||
|
||||
dm_list_init(&_vginfos);
|
||||
|
||||
/*
|
||||
* Move the current _unused_duplicates to _prev_unused_duplicate_devs
|
||||
* before destroying _unused_duplicates.
|
||||
*
|
||||
* One command can init/populate/destroy lvmcache multiple times. Each
|
||||
* time it will encounter duplicates and choose the preferrred devs.
|
||||
* We want the same preferred devices to be chosen each time, so save
|
||||
* the unpreferred devs here so that _choose_preferred_devs can use
|
||||
* this to make the same choice each time.
|
||||
*
|
||||
* FIXME: I don't think is is needed any more.
|
||||
*/
|
||||
_destroy_device_list(&_prev_unused_duplicate_devs);
|
||||
dm_list_splice(&_prev_unused_duplicate_devs, &_unused_duplicates);
|
||||
_destroy_device_list(&_unused_duplicates);
|
||||
_destroy_device_list(&_initial_duplicates); /* should be empty anyway */
|
||||
|
||||
@@ -3011,9 +2977,11 @@ void lvmcache_get_max_name_lengths(struct cmd_context *cmd,
|
||||
*pv_max_name_len = 0;
|
||||
|
||||
dm_list_iterate_items(vginfo, &_vginfos) {
|
||||
len = strlen(vginfo->vgname);
|
||||
if (*vg_max_name_len < len)
|
||||
*vg_max_name_len = len;
|
||||
if (!is_orphan_vg(vginfo->vgname)) {
|
||||
len = strlen(vginfo->vgname);
|
||||
if (*vg_max_name_len < len)
|
||||
*vg_max_name_len = len;
|
||||
}
|
||||
|
||||
dm_list_iterate_items(info, &vginfo->infos) {
|
||||
len = strlen(dev_name(info->dev));
|
||||
@@ -3034,6 +3002,16 @@ int lvmcache_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const ch
|
||||
return ret;
|
||||
}
|
||||
|
||||
int lvmcache_vg_is_lockd_type(struct cmd_context *cmd, const char *vgname, const char *vgid)
|
||||
{
|
||||
struct lvmcache_vginfo *vginfo;
|
||||
|
||||
if ((vginfo = lvmcache_vginfo_from_vgname(vgname, vgid)))
|
||||
return is_lockd_type(vginfo->lock_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Example of reading four devs in sequence from the same VG:
|
||||
*
|
||||
@@ -3259,11 +3237,11 @@ const char *dev_filtered_reason(struct device *dev)
|
||||
return "device cannot be used";
|
||||
}
|
||||
|
||||
const char *devname_error_reason(const char *devname)
|
||||
const char *devname_error_reason(struct cmd_context *cmd, const char *devname)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
if ((dev = dev_hash_get(devname))) {
|
||||
if ((dev = dev_cache_get_by_name(cmd, devname))) {
|
||||
if (dev->filtered_flags)
|
||||
return dev_filtered_reason(dev);
|
||||
if (lvmcache_dev_is_unused_duplicate(dev))
|
||||
|
||||
6
lib/cache/lvmcache.h
vendored
6
lib/cache/lvmcache.h
vendored
@@ -179,6 +179,8 @@ void lvmcache_get_max_name_lengths(struct cmd_context *cmd,
|
||||
|
||||
int lvmcache_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const char *vgid);
|
||||
|
||||
int lvmcache_vg_is_lockd_type(struct cmd_context *cmd, const char *vgname, const char *vgid);
|
||||
|
||||
bool lvmcache_scan_mismatch(struct cmd_context *cmd, const char *vgname, const char *vgid);
|
||||
|
||||
int lvmcache_vginfo_has_pvid(struct lvmcache_vginfo *vginfo, const char *pvid_arg);
|
||||
@@ -186,8 +188,6 @@ int lvmcache_vginfo_has_pvid(struct lvmcache_vginfo *vginfo, const char *pvid_ar
|
||||
uint64_t lvmcache_max_metadata_size(void);
|
||||
void lvmcache_save_metadata_size(uint64_t val);
|
||||
|
||||
bool lvmcache_has_bad_metadata(struct device *dev);
|
||||
|
||||
bool lvmcache_has_old_metadata(struct cmd_context *cmd, const char *vgname, const char *vgid, struct device *dev);
|
||||
|
||||
void lvmcache_get_outdated_devs(struct cmd_context *cmd,
|
||||
@@ -218,7 +218,7 @@ void lvmcache_get_mdas(struct cmd_context *cmd,
|
||||
struct dm_list *mda_list);
|
||||
|
||||
const char *dev_filtered_reason(struct device *dev);
|
||||
const char *devname_error_reason(const char *devname);
|
||||
const char *devname_error_reason(struct cmd_context *cmd, const char *devname);
|
||||
|
||||
struct metadata_area *lvmcache_get_dev_mda(struct device *dev, int mda_num);
|
||||
|
||||
|
||||
@@ -300,38 +300,6 @@ static void _destroy(struct segment_type *segtype)
|
||||
}
|
||||
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
/*
|
||||
* Parse and look for kernel symbol in /proc/kallsyms
|
||||
* this could be our only change to figure out there is
|
||||
* cache policy symbol already in the monolithic kernel
|
||||
* where 'modprobe dm-cache-smq' will simply not work
|
||||
*/
|
||||
static int _lookup_kallsyms(const char *symbol)
|
||||
{
|
||||
static const char _syms[] = "/proc/kallsyms";
|
||||
int ret = 0;
|
||||
char *line = NULL;
|
||||
size_t len;
|
||||
FILE *s;
|
||||
|
||||
if (!(s = fopen(_syms, "r")))
|
||||
log_sys_debug("fopen", _syms);
|
||||
else {
|
||||
while (getline(&line, &len, s) != -1)
|
||||
if (strstr(line, symbol)) {
|
||||
ret = 1; /* Found symbol */
|
||||
log_debug("Found kernel symbol%s.", symbol); /* space is in symbol */
|
||||
break;
|
||||
}
|
||||
|
||||
free(line);
|
||||
if (fclose(s))
|
||||
log_sys_debug("fclose", _syms);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int _target_present(struct cmd_context *cmd,
|
||||
const struct lv_segment *seg __attribute__((unused)),
|
||||
@@ -339,21 +307,20 @@ static int _target_present(struct cmd_context *cmd,
|
||||
{
|
||||
/* List of features with their kernel target version */
|
||||
static const struct feature {
|
||||
uint32_t maj;
|
||||
uint32_t min;
|
||||
unsigned cache_feature;
|
||||
unsigned cache_alias;
|
||||
uint16_t maj;
|
||||
uint16_t min;
|
||||
uint16_t cache_feature;
|
||||
uint16_t cache_alias;
|
||||
const char feature[12];
|
||||
const char module[12]; /* check dm-%s */
|
||||
const char ksymbol[12]; /* check for kernel symbol */
|
||||
const char *aliasing;
|
||||
const char aliasing[24];
|
||||
} _features[] = {
|
||||
{ 1, 10, CACHE_FEATURE_METADATA2, 0, "metadata2" },
|
||||
/* Assumption: cache >=1.9 always aliases MQ policy */
|
||||
{ 1, 9, CACHE_FEATURE_POLICY_SMQ, CACHE_FEATURE_POLICY_MQ, "policy_smq", "cache-smq",
|
||||
" smq_exit", " and aliases cache-mq" },
|
||||
{ 1, 8, CACHE_FEATURE_POLICY_SMQ, 0, "policy_smq", "cache-smq", " smq_exit" },
|
||||
{ 1, 3, CACHE_FEATURE_POLICY_MQ, 0, "policy_mq", "cache-mq", " mq_init" },
|
||||
" and aliases cache-mq" },
|
||||
{ 1, 8, CACHE_FEATURE_POLICY_SMQ, 0, "policy_smq", "cache-smq" },
|
||||
{ 1, 3, CACHE_FEATURE_POLICY_MQ, 0, "policy_mq", "cache-mq" },
|
||||
};
|
||||
static const char _lvmconf[] = "global/cache_disabled_features";
|
||||
static unsigned _attrs = 0;
|
||||
@@ -399,11 +366,10 @@ static int _target_present(struct cmd_context *cmd,
|
||||
}
|
||||
if (((maj > _features[i].maj) ||
|
||||
(maj == _features[i].maj && min >= _features[i].min)) &&
|
||||
((_features[i].ksymbol[0] && _lookup_kallsyms(_features[i].ksymbol)) ||
|
||||
module_present(cmd, _features[i].module))) {
|
||||
module_present(cmd, _features[i].module)) {
|
||||
log_debug_activation("Cache policy %s is available%s.",
|
||||
_features[i].module,
|
||||
_features[i].aliasing ? : "");
|
||||
_features[i].aliasing);
|
||||
_attrs |= (_features[i].cache_feature | _features[i].cache_alias);
|
||||
} else if (!_features[i].cache_alias)
|
||||
log_very_verbose("Target %s does not support %s.",
|
||||
@@ -457,7 +423,7 @@ static int _modules_needed(struct dm_pool *mem,
|
||||
}
|
||||
#endif /* DEVMAPPER_SUPPORT */
|
||||
|
||||
static struct segtype_handler _cache_pool_ops = {
|
||||
static const struct segtype_handler _cache_pool_ops = {
|
||||
.display = _cache_display,
|
||||
.text_import = _cache_pool_text_import,
|
||||
.text_import_area_count = _cache_pool_text_import_area_count,
|
||||
@@ -796,7 +762,7 @@ static int _cache_add_target_line(struct dev_manager *dm,
|
||||
}
|
||||
#endif /* DEVMAPPER_SUPPORT */
|
||||
|
||||
static struct segtype_handler _cache_ops = {
|
||||
static const struct segtype_handler _cache_ops = {
|
||||
.display = _cache_display,
|
||||
.text_import = _cache_text_import,
|
||||
.text_import_area_count = _cache_text_import_area_count,
|
||||
|
||||
@@ -45,6 +45,12 @@
|
||||
#include <systemd/sd-id128.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
#include <valgrind.h>
|
||||
#else
|
||||
#define RUNNING_ON_VALGRIND 0
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
@@ -252,7 +258,7 @@ static void _get_sysfs_dir(struct cmd_context *cmd, char *buf, size_t buf_size)
|
||||
return;
|
||||
}
|
||||
|
||||
(void) dm_strncpy(buf, sys_mnt, buf_size);
|
||||
dm_strncpy(buf, sys_mnt, buf_size);
|
||||
}
|
||||
|
||||
static uint32_t _parse_debug_fields(struct cmd_context *cmd, int cfg, const char *cfgname)
|
||||
@@ -500,10 +506,10 @@ static int _check_config(struct cmd_context *cmd)
|
||||
static const char *_set_time_format(struct cmd_context *cmd)
|
||||
{
|
||||
/* Compared to strftime, we do not allow "newline" character - the %n in format. */
|
||||
static const char *allowed_format_chars = "aAbBcCdDeFGghHIjklmMpPrRsStTuUVwWxXyYzZ%";
|
||||
static const char *allowed_alternative_format_chars_e = "cCxXyY";
|
||||
static const char *allowed_alternative_format_chars_o = "deHImMSuUVwWy";
|
||||
static const char *chars_to_check;
|
||||
static const char _allowed_format_chars[] = "aAbBcCdDeFGghHIjklmMpPrRsStTuUVwWxXyYzZ%";
|
||||
static const char _allowed_alternative_format_chars_e[] = "cCxXyY";
|
||||
static const char _allowed_alternative_format_chars_o[] = "deHImMSuUVwWy";
|
||||
const char *chars_to_check;
|
||||
const char *tf = find_config_tree_str(cmd, report_time_format_CFG, NULL);
|
||||
const char *p_fmt;
|
||||
size_t i;
|
||||
@@ -519,12 +525,12 @@ static const char *_set_time_format(struct cmd_context *cmd)
|
||||
c = *++p_fmt;
|
||||
if (c == 'E') {
|
||||
c = *++p_fmt;
|
||||
chars_to_check = allowed_alternative_format_chars_e;
|
||||
chars_to_check = _allowed_alternative_format_chars_e;
|
||||
} else if (c == 'O') {
|
||||
c = *++p_fmt;
|
||||
chars_to_check = allowed_alternative_format_chars_o;
|
||||
chars_to_check = _allowed_alternative_format_chars_o;
|
||||
} else
|
||||
chars_to_check = allowed_format_chars;
|
||||
chars_to_check = _allowed_format_chars;
|
||||
|
||||
for (i = 0; chars_to_check[i]; i++) {
|
||||
if (c == chars_to_check[i])
|
||||
@@ -608,6 +614,46 @@ static int _init_system_id(struct cmd_context *cmd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _init_device_ids_refresh(struct cmd_context *cmd)
|
||||
{
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *cv;
|
||||
int check_product_uuid = 0;
|
||||
int check_hostname = 0;
|
||||
char path[PATH_MAX];
|
||||
char uuid[128] = { 0 };
|
||||
|
||||
cmd->device_ids_check_product_uuid = 0;
|
||||
cmd->device_ids_check_hostname = 0;
|
||||
|
||||
if (!find_config_tree_bool(cmd, devices_device_ids_refresh_CFG, NULL))
|
||||
return;
|
||||
if (!(cn = find_config_tree_array(cmd, devices_device_ids_refresh_checks_CFG, NULL)))
|
||||
return;
|
||||
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != DM_CFG_STRING)
|
||||
continue;
|
||||
if (!strcmp(cv->v.str, "product_uuid"))
|
||||
check_product_uuid = 1;
|
||||
if (!strcmp(cv->v.str, "hostname"))
|
||||
check_hostname = 1;
|
||||
}
|
||||
|
||||
if (check_product_uuid) {
|
||||
const char *sysfs_dir = cmd->device_id_sysfs_dir ?: dm_sysfs_dir();
|
||||
if (dm_snprintf(path, sizeof(path), "%sdevices/virtual/dmi/id/product_uuid", sysfs_dir) < 0)
|
||||
return;
|
||||
if (get_sysfs_value(path, uuid, sizeof(uuid), 0) && uuid[0])
|
||||
cmd->product_uuid = dm_pool_strdup(cmd->libmem, uuid);;
|
||||
if (cmd->product_uuid)
|
||||
cmd->device_ids_check_product_uuid = 1;
|
||||
}
|
||||
|
||||
if (check_hostname && cmd->hostname)
|
||||
cmd->device_ids_check_hostname = 1;
|
||||
}
|
||||
|
||||
static int _process_config(struct cmd_context *cmd)
|
||||
{
|
||||
mode_t old_umask;
|
||||
@@ -779,6 +825,8 @@ static int _process_config(struct cmd_context *cmd)
|
||||
if (!_init_system_id(cmd))
|
||||
return_0;
|
||||
|
||||
_init_device_ids_refresh(cmd);
|
||||
|
||||
init_io_memory_size(find_config_tree_int(cmd, global_io_memory_size_CFG, NULL));
|
||||
|
||||
return 1;
|
||||
@@ -1119,7 +1167,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
|
||||
}
|
||||
}
|
||||
|
||||
if (!dev_cache_add_dir(cv->v.str)) {
|
||||
if (!dev_cache_add_dir(cmd, cv->v.str)) {
|
||||
log_error("Failed to add %s to internal device cache",
|
||||
cv->v.str);
|
||||
return 0;
|
||||
@@ -1183,12 +1231,12 @@ static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
|
||||
* (currently not used for devs match to device id using syfs)
|
||||
*/
|
||||
if (find_config_tree_bool(cmd, devices_sysfs_scan_CFG, NULL)) {
|
||||
if ((filters[nr_filt] = sysfs_filter_create()))
|
||||
if ((filters[nr_filt] = sysfs_filter_create(dm_sysfs_dir())))
|
||||
nr_filt++;
|
||||
}
|
||||
|
||||
/* usable device filter. Required. */
|
||||
if (!(filters[nr_filt] = usable_filter_create(cmd, cmd->dev_types, FILTER_MODE_NO_LVMETAD))) {
|
||||
if (!(filters[nr_filt] = usable_filter_create(cmd, cmd->dev_types))) {
|
||||
log_error("Failed to create usabled device filter");
|
||||
goto bad;
|
||||
}
|
||||
@@ -1568,62 +1616,6 @@ void destroy_config_context(struct cmd_context *cmd)
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
/*
|
||||
* A "config context" is a very light weight toolcontext that
|
||||
* is only used for reading config settings from lvm.conf.
|
||||
*
|
||||
* FIXME: this needs to go back to parametrized create_toolcontext()
|
||||
*/
|
||||
struct cmd_context *create_config_context(void)
|
||||
{
|
||||
struct cmd_context *cmd;
|
||||
|
||||
if (!(cmd = zalloc(sizeof(*cmd))))
|
||||
goto_out;
|
||||
|
||||
strncpy(cmd->system_dir, DEFAULT_SYS_DIR, sizeof(cmd->system_dir) - 1);
|
||||
|
||||
if (!_get_env_vars(cmd))
|
||||
goto_out;
|
||||
|
||||
if (!(cmd->libmem = dm_pool_create("library", 4 * 1024)))
|
||||
goto_out;
|
||||
|
||||
if (!(cmd->mem = dm_pool_create("command", 4 * 1024)))
|
||||
goto out;
|
||||
|
||||
if (!(cmd->pending_delete_mem = dm_pool_create("pending_delete", 1024)))
|
||||
goto_out;
|
||||
|
||||
dm_list_init(&cmd->config_files);
|
||||
dm_list_init(&cmd->tags);
|
||||
|
||||
if (!_init_lvm_conf(cmd))
|
||||
goto_out;
|
||||
|
||||
if (!_init_hostname(cmd))
|
||||
goto_out;
|
||||
|
||||
if (!_init_tags(cmd, cmd->cft))
|
||||
goto_out;
|
||||
|
||||
/* Load lvmlocal.conf */
|
||||
if (*cmd->system_dir && !_load_config_file(cmd, "", 1))
|
||||
goto_out;
|
||||
|
||||
if (!_init_tag_configs(cmd))
|
||||
goto_out;
|
||||
|
||||
if (!(cmd->cft = _merge_config_files(cmd, cmd->cft)))
|
||||
goto_out;
|
||||
|
||||
return cmd;
|
||||
out:
|
||||
if (cmd)
|
||||
destroy_config_context(cmd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Entry point */
|
||||
struct cmd_context *create_toolcontext(unsigned is_clvmd,
|
||||
const char *system_dir,
|
||||
@@ -1633,7 +1625,6 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
|
||||
unsigned set_filters)
|
||||
{
|
||||
struct cmd_context *cmd;
|
||||
int flags;
|
||||
|
||||
#ifdef M_MMAP_MAX
|
||||
mallopt(M_MMAP_MAX, 0);
|
||||
@@ -1657,6 +1648,8 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
|
||||
cmd->handles_unknown_segments = 0;
|
||||
cmd->hosttags = 0;
|
||||
cmd->check_devs_used = 1;
|
||||
cmd->running_on_valgrind = RUNNING_ON_VALGRIND;
|
||||
|
||||
dm_list_init(&cmd->arg_value_groups);
|
||||
dm_list_init(&cmd->formats);
|
||||
dm_list_init(&cmd->segtypes);
|
||||
@@ -1667,15 +1660,17 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
|
||||
/* FIXME Make this configurable? */
|
||||
reset_lvm_errno(1);
|
||||
|
||||
#ifndef VALGRIND_POOL
|
||||
/* Set in/out stream buffering before glibc */
|
||||
if (set_buffering
|
||||
&& !cmd->running_on_valgrind /* Skipping within valgrind execution. */
|
||||
#ifdef SYS_gettid
|
||||
/* For threaded programs no changes of streams */
|
||||
/* On linux gettid() is implemented only via syscall */
|
||||
&& (syscall(SYS_gettid) == getpid())
|
||||
#endif
|
||||
) {
|
||||
int flags;
|
||||
|
||||
/* Allocate 2 buffers */
|
||||
if (!(cmd->linebuffer = malloc(2 * _linebuffer_size))) {
|
||||
log_error("Failed to allocate line buffer.");
|
||||
@@ -1709,7 +1704,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
|
||||
} else if (!set_buffering)
|
||||
/* Without buffering, must not use stdin/stdout */
|
||||
init_silent(1);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Environment variable LVM_SYSTEM_DIR overrides this below.
|
||||
*/
|
||||
@@ -1904,7 +1899,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
|
||||
_destroy_segtypes(&cmd->segtypes);
|
||||
_destroy_formats(cmd, &cmd->formats);
|
||||
|
||||
if (!dev_cache_exit())
|
||||
if (!dev_cache_exit(cmd))
|
||||
stack;
|
||||
_destroy_dev_types(cmd);
|
||||
_destroy_tags(cmd);
|
||||
@@ -1926,6 +1921,8 @@ int refresh_toolcontext(struct cmd_context *cmd)
|
||||
|
||||
cmd->lib_dir = NULL;
|
||||
|
||||
cmd->lvcreate_vcp = NULL;
|
||||
|
||||
if (!_init_lvm_conf(cmd))
|
||||
return_0;
|
||||
|
||||
@@ -2021,7 +2018,6 @@ int refresh_toolcontext(struct cmd_context *cmd)
|
||||
void destroy_toolcontext(struct cmd_context *cmd)
|
||||
{
|
||||
struct dm_config_tree *cft_cmdline;
|
||||
int flags;
|
||||
|
||||
archive_exit(cmd);
|
||||
backup_exit(cmd);
|
||||
@@ -2032,7 +2028,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
||||
_destroy_segtypes(&cmd->segtypes);
|
||||
_destroy_formats(cmd, &cmd->formats);
|
||||
_destroy_filters(cmd);
|
||||
dev_cache_exit();
|
||||
dev_cache_exit(cmd);
|
||||
_destroy_dev_types(cmd);
|
||||
_destroy_tags(cmd);
|
||||
|
||||
@@ -2042,9 +2038,8 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
||||
if (cmd->cft_def_hash)
|
||||
dm_hash_destroy(cmd->cft_def_hash);
|
||||
|
||||
dm_device_list_destroy(&cmd->cache_dm_devs);
|
||||
#ifndef VALGRIND_POOL
|
||||
if (cmd->linebuffer) {
|
||||
if (!cmd->running_on_valgrind && cmd->linebuffer) {
|
||||
int flags;
|
||||
/* Reset stream buffering to defaults */
|
||||
if (is_valid_fd(STDIN_FILENO) &&
|
||||
((flags = fcntl(STDIN_FILENO, F_GETFL)) > 0) &&
|
||||
@@ -2066,7 +2061,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
||||
|
||||
free(cmd->linebuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
destroy_config_context(cmd);
|
||||
|
||||
lvmpolld_disconnect();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "lib/device/dev-cache.h"
|
||||
#include "lib/device/dev-type.h"
|
||||
#include "lib/commands/cmd_enum.h"
|
||||
#include "base/data-struct/radix-tree.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
@@ -93,7 +94,7 @@ struct cmd_context {
|
||||
*/
|
||||
const char *cmd_line;
|
||||
const char *name; /* needed before cmd->command is set */
|
||||
struct command_name *cname;
|
||||
const struct command_name *cname;
|
||||
struct command *command;
|
||||
int command_enum; /* duplicate from command->command_enum for lib code */
|
||||
char **argv;
|
||||
@@ -120,6 +121,7 @@ struct cmd_context {
|
||||
* Machine and system identification.
|
||||
*/
|
||||
const char *system_id;
|
||||
const char *product_uuid;
|
||||
const char *hostname;
|
||||
const char *kernel_vsn;
|
||||
|
||||
@@ -138,6 +140,7 @@ struct cmd_context {
|
||||
*/
|
||||
unsigned is_long_lived:1; /* optimises persistent_filter handling */
|
||||
unsigned is_interactive:1;
|
||||
unsigned running_on_valgrind:1;
|
||||
unsigned check_pv_dev_sizes:1;
|
||||
unsigned handles_missing_pvs:1;
|
||||
unsigned handles_unknown_segments:1;
|
||||
@@ -188,6 +191,8 @@ struct cmd_context {
|
||||
unsigned pvscan_recreate_hints:1; /* enable special case hint handling for pvscan --cache */
|
||||
unsigned scan_lvs:1;
|
||||
unsigned wipe_outdated_pvs:1;
|
||||
unsigned devices_file_hash_mismatch:1;
|
||||
unsigned devices_file_hash_ignore:1;
|
||||
unsigned enable_devices_list:1; /* command is using --devices option */
|
||||
unsigned enable_devices_file:1; /* command is using devices file */
|
||||
unsigned pending_devices_file:1; /* command may create and enable devices file */
|
||||
@@ -207,12 +212,22 @@ struct cmd_context {
|
||||
unsigned event_activation:1; /* whether event_activation is set */
|
||||
unsigned udevoutput:1;
|
||||
unsigned online_vg_file_removed:1;
|
||||
unsigned disable_dm_devs:1; /* temporarily disable use of dm devs cache */
|
||||
unsigned filter_regex_set_preferred_name_disable:1; /* prevent dev_set_preferred_name */
|
||||
unsigned device_ids_check_product_uuid:1;
|
||||
unsigned device_ids_check_hostname:1;
|
||||
unsigned device_ids_refresh_trigger:1;
|
||||
unsigned device_ids_invalid:1;
|
||||
unsigned device_ids_auto_import:1;
|
||||
unsigned get_vgname_from_options:1; /* used by lvconvert */
|
||||
|
||||
/*
|
||||
* Devices and filtering.
|
||||
*/
|
||||
struct dm_list dev_dirs; /* paths, like /dev, to look for devnames */
|
||||
struct radix_tree *devnames; /* path names in dev_dirs, get struct device from path name */
|
||||
struct radix_tree *devnos; /* devnos found in dev_dirs, get struct device from devno */
|
||||
struct dm_regex *preferred_names_matcher; /* preferred dev names to display from lvm.conf */
|
||||
|
||||
struct dev_filter *filter;
|
||||
struct dm_list use_devices; /* struct dev_use for each entry in devices file */
|
||||
const char *md_component_checks;
|
||||
@@ -221,7 +236,21 @@ struct cmd_context {
|
||||
const char *devicesfile; /* from --devicesfile option */
|
||||
struct dm_list deviceslist; /* from --devices option, struct dm_str_list */
|
||||
|
||||
struct dm_list *cache_dm_devs; /* cache with UUIDs from DM_DEVICE_LIST (when available) */
|
||||
/*
|
||||
* LV dev index.
|
||||
*/
|
||||
struct dm_hash_table *vgid_index;
|
||||
struct dm_hash_table *lvid_index;
|
||||
struct radix_tree *sysfs_only_devices;
|
||||
|
||||
/*
|
||||
* Cache of DM devices.
|
||||
* Look up struct dm_active_device from devno or dm uuid.
|
||||
*/
|
||||
int use_dm_devs_cache; /* use this cache or not */
|
||||
struct dm_list *dm_devs; /* list of dm_active_device */
|
||||
struct radix_tree *dm_uuids; /* dm uuids of dm devices, get entry from dm_devs */
|
||||
struct radix_tree *dm_devnos; /* devnos of dm devices, get entry from dm_devs */
|
||||
|
||||
/*
|
||||
* Configuration.
|
||||
@@ -276,6 +305,8 @@ struct cmd_context {
|
||||
unsigned rand_seed;
|
||||
struct dm_list pending_delete; /* list of LVs for removal */
|
||||
struct dm_pool *pending_delete_mem; /* memory pool for pending deletes */
|
||||
struct vdo_convert_params *lvcreate_vcp;/* params for LV to VDO conversion */
|
||||
uint32_t lockopt; /* LOCKOPT_* from --lockopt string */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -303,7 +334,6 @@ int init_run_by_dmeventd(struct cmd_context *cmd);
|
||||
* is only used for reading config settings from lvm.conf,
|
||||
* which are at cmd->cft.
|
||||
*/
|
||||
struct cmd_context *create_config_context(void);
|
||||
void destroy_config_context(struct cmd_context *cmd);
|
||||
|
||||
struct format_type *get_format_by_name(struct cmd_context *cmd, const char *format);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
static const char *_config_source_names[] = {
|
||||
static const char _config_source_names[][24] = {
|
||||
[CONFIG_UNDEFINED] = "undefined",
|
||||
[CONFIG_FILE] = "file",
|
||||
[CONFIG_MERGED_FILES] = "merged files",
|
||||
@@ -49,7 +49,6 @@ struct config_file {
|
||||
off_t st_size;
|
||||
char *filename;
|
||||
int exists;
|
||||
int keep_open;
|
||||
struct device *dev;
|
||||
};
|
||||
|
||||
@@ -66,7 +65,7 @@ struct config_source {
|
||||
/*
|
||||
* Map each ID to respective definition of the configuration item.
|
||||
*/
|
||||
static struct cfg_def_item _cfg_def_items[CFG_COUNT + 1] = {
|
||||
static const struct cfg_def_item _cfg_def_items[CFG_COUNT + 1] = {
|
||||
#define cfg_section(id, name, parent, flags, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, (flags), since_version, {0}, deprecated_since_version, deprecation_comment, comment},
|
||||
#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, deprecated_since_version, deprecation_comment, comment) {id, parent, name, type, {.v_##type = (default_value)}, (flags), since_version, {.v_UNCONFIGURED = (unconfigured_value)}, deprecated_since_version, deprecation_comment, comment},
|
||||
#define cfg_runtime(id, name, parent, flags, type, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, (flags) | CFG_DEFAULT_RUN_TIME, since_version, {.fn_UNCONFIGURED = get_default_unconfigured_##id}, deprecated_since_version, (deprecation_comment), comment},
|
||||
@@ -104,7 +103,7 @@ static inline int _is_file_based_config_source(config_source_t source)
|
||||
*/
|
||||
struct dm_config_tree *config_open(config_source_t source,
|
||||
const char *filename,
|
||||
int keep_open)
|
||||
int unused)
|
||||
{
|
||||
struct dm_config_tree *cft = dm_config_create();
|
||||
struct config_source *cs;
|
||||
@@ -124,7 +123,6 @@ struct dm_config_tree *config_open(config_source_t source,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
cf->keep_open = keep_open;
|
||||
if (filename &&
|
||||
!(cf->filename = dm_pool_strdup(cft->mem, filename))) {
|
||||
log_error("Failed to duplicate filename.");
|
||||
@@ -241,22 +239,8 @@ int config_file_changed(struct dm_config_tree *cft)
|
||||
|
||||
void config_destroy(struct dm_config_tree *cft)
|
||||
{
|
||||
struct config_source *cs;
|
||||
struct config_file *cf;
|
||||
|
||||
if (!cft)
|
||||
return;
|
||||
|
||||
cs = dm_config_get_custom(cft);
|
||||
|
||||
if (_is_file_based_config_source(cs->type)) {
|
||||
cf = cs->source.file;
|
||||
if (cf && cf->dev)
|
||||
if (!dev_close(cf->dev))
|
||||
stack;
|
||||
}
|
||||
|
||||
dm_config_destroy(cft);
|
||||
if (cft)
|
||||
dm_config_destroy(cft);
|
||||
}
|
||||
|
||||
struct dm_config_tree *config_file_open_and_read(const char *config_file,
|
||||
@@ -281,7 +265,7 @@ struct dm_config_tree *config_file_open_and_read(const char *config_file,
|
||||
}
|
||||
|
||||
log_very_verbose("Loading config file: %s", config_file);
|
||||
if (!config_file_read(cft)) {
|
||||
if (!config_file_read_from_file(cft)) {
|
||||
log_error("Failed to load config file %s", config_file);
|
||||
goto bad;
|
||||
}
|
||||
@@ -605,12 +589,15 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r
|
||||
return r;
|
||||
}
|
||||
|
||||
int config_file_read(struct dm_config_tree *cft)
|
||||
int config_file_read_from_file(struct dm_config_tree *cft)
|
||||
{
|
||||
const char *filename = NULL;
|
||||
struct config_source *cs = dm_config_get_custom(cft);
|
||||
struct config_file *cf;
|
||||
struct stat info;
|
||||
struct device fake_dev = { 0 };
|
||||
struct dm_str_list *alias;
|
||||
int fd;
|
||||
int r;
|
||||
|
||||
if (!config_file_check(cft, &filename, &info))
|
||||
@@ -622,25 +609,39 @@ int config_file_read(struct dm_config_tree *cft)
|
||||
|
||||
cf = cs->source.file;
|
||||
|
||||
if (!cf->dev) {
|
||||
if (!(cf->dev = dev_create_file(filename, NULL, NULL, 1)))
|
||||
return_0;
|
||||
if (cf->dev)
|
||||
return_0;
|
||||
|
||||
if (!dev_open_readonly_buffered(cf->dev)) {
|
||||
dev_destroy_file(cf->dev);
|
||||
cf->dev = NULL;
|
||||
return_0;
|
||||
}
|
||||
/* fixme: get rid of fake dev and just
|
||||
add separate code paths for files */
|
||||
|
||||
if (!(alias = zalloc(sizeof(*alias))))
|
||||
return_0;
|
||||
if (!(alias->str = strdup(filename))) {
|
||||
free(alias);
|
||||
return_0;
|
||||
}
|
||||
dev_init(&fake_dev);
|
||||
fake_dev.flags = DEV_REGULAR;
|
||||
dm_list_add(&fake_dev.aliases, &alias->list);
|
||||
|
||||
if ((fd = open(filename, O_RDONLY, 0777)) < 0) {
|
||||
log_error("Failed to open config file %s.", filename);
|
||||
free((void*)alias->str);
|
||||
free((void*)alias);
|
||||
return_0;
|
||||
}
|
||||
fake_dev.fd = fd;
|
||||
cf->dev = &fake_dev;
|
||||
|
||||
r = config_file_read_fd(cft, cf->dev, DEV_IO_MDA_CONTENT, 0, (size_t) info.st_size, 0, 0,
|
||||
(checksum_fn_t) NULL, 0, 0, 0);
|
||||
|
||||
if (!cf->keep_open) {
|
||||
if (!dev_close(cf->dev))
|
||||
stack;
|
||||
cf->dev = NULL;
|
||||
}
|
||||
free((void*)alias->str);
|
||||
free((void*)alias);
|
||||
close(fd);
|
||||
|
||||
cf->dev = NULL;
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -656,7 +657,7 @@ struct timespec config_file_timestamp(struct dm_config_tree *cft)
|
||||
#define cfg_def_get_default_value_hint(cmd,item,type,profile) (((item)->flags & CFG_DEFAULT_RUN_TIME) ? (item)->default_value.fn_##type(cmd,profile) : (item)->default_value.v_##type)
|
||||
#define cfg_def_get_default_value(cmd,item,type,profile) ((item)->flags & CFG_DEFAULT_UNDEFINED ? 0 : cfg_def_get_default_value_hint(cmd,item,type,profile))
|
||||
|
||||
static int _cfg_def_make_path(char *buf, size_t buf_size, int id, cfg_def_item_t *item, int xlate)
|
||||
static int _cfg_def_make_path(char *buf, size_t buf_size, int id, const cfg_def_item_t *item, int xlate)
|
||||
{
|
||||
int variable = item->flags & CFG_NAME_VARIABLE;
|
||||
int parent_id = item->parent;
|
||||
@@ -687,7 +688,7 @@ int config_def_get_path(char *buf, size_t buf_size, int id)
|
||||
return _cfg_def_make_path(buf, buf_size, id, cfg_def_get_item_p(id), 0);
|
||||
}
|
||||
|
||||
static void _get_type_name(char *buf, size_t buf_size, cfg_def_type_t type)
|
||||
static void _get_type_name(char *buf, size_t buf_size, unsigned type)
|
||||
{
|
||||
(void) dm_snprintf(buf, buf_size, "%s%s%s%s%s%s",
|
||||
(type & CFG_TYPE_ARRAY) ?
|
||||
@@ -700,8 +701,8 @@ static void _get_type_name(char *buf, size_t buf_size, cfg_def_type_t type)
|
||||
(type & CFG_TYPE_STRING) ? " string" : "");
|
||||
}
|
||||
|
||||
static void _log_type_error(const char *path, cfg_def_type_t actual,
|
||||
cfg_def_type_t expected, int suppress_messages)
|
||||
static void _log_type_error(const char *path, unsigned actual, unsigned expected,
|
||||
int suppress_messages)
|
||||
{
|
||||
static char actual_type_name[128];
|
||||
static char expected_type_name[128];
|
||||
@@ -741,13 +742,13 @@ static struct dm_config_value *_get_def_array_values(struct cmd_context *cmd,
|
||||
}
|
||||
/* Proper value always starts with '#'. */
|
||||
if (token[0] != '#')
|
||||
goto bad;
|
||||
goto_bad;
|
||||
|
||||
while (token) {
|
||||
/* Move to type identifier. Error on no char. */
|
||||
token++;
|
||||
if (!token[0])
|
||||
goto bad;
|
||||
goto_bad;
|
||||
|
||||
/* Move to the actual value and decode any "##" into "#". */
|
||||
p = token + 1;
|
||||
@@ -941,7 +942,7 @@ static int _check_value_differs_from_default(struct cft_check_handle *handle,
|
||||
diff = (v_def && (v_def->type != DM_CFG_EMPTY_ARRAY));
|
||||
break;
|
||||
default:
|
||||
log_error(INTERNAL_ERROR "inconsistent state reached in _check_value_differs_from_default");
|
||||
log_error(INTERNAL_ERROR "Inconsistent state reached in _check_value_differs_from_default.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1107,7 +1108,7 @@ static int _config_def_check_tree(struct cft_check_handle *handle,
|
||||
size_t buf_size, struct dm_config_node *root)
|
||||
{
|
||||
struct dm_config_node *cn;
|
||||
cfg_def_item_t *def;
|
||||
const cfg_def_item_t *def;
|
||||
int valid, r = 1;
|
||||
size_t len;
|
||||
|
||||
@@ -1131,7 +1132,7 @@ static int _config_def_check_tree(struct cft_check_handle *handle,
|
||||
|
||||
int config_def_check(struct cft_check_handle *handle)
|
||||
{
|
||||
cfg_def_item_t *def;
|
||||
const cfg_def_item_t *def;
|
||||
struct dm_config_node *cn;
|
||||
char vp[CFG_PATH_MAX_LEN], rp[CFG_PATH_MAX_LEN];
|
||||
size_t rplen;
|
||||
@@ -1180,7 +1181,7 @@ int config_def_check(struct cft_check_handle *handle)
|
||||
handle->cmd->cft_def_hash = NULL;
|
||||
r = 0; goto out;
|
||||
}
|
||||
if (!dm_hash_insert(handle->cmd->cft_def_hash, vp, def)) {
|
||||
if (!dm_hash_insert(handle->cmd->cft_def_hash, vp, (void*)def)) {
|
||||
log_error("Failed to insert configuration to hash.");
|
||||
r = 0;
|
||||
goto out;
|
||||
@@ -1246,7 +1247,7 @@ static int _apply_local_profile(struct cmd_context *cmd, struct profile *profile
|
||||
return override_config_tree_from_profile(cmd, profile);
|
||||
}
|
||||
|
||||
static int _config_disabled(struct cmd_context *cmd, cfg_def_item_t *item, const char *path)
|
||||
static int _config_disabled(struct cmd_context *cmd, const cfg_def_item_t *item, const char *path)
|
||||
{
|
||||
if ((item->flags & CFG_DISABLED) && dm_config_tree_find_node(cmd->cft, path)) {
|
||||
log_warn("WARNING: Configuration setting %s is disabled. Using default value.", path);
|
||||
@@ -1258,7 +1259,7 @@ static int _config_disabled(struct cmd_context *cmd, cfg_def_item_t *item, const
|
||||
|
||||
const struct dm_config_node *find_config_node(struct cmd_context *cmd, struct dm_config_tree *cft, int id)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
const struct dm_config_node *cn;
|
||||
|
||||
@@ -1271,7 +1272,7 @@ const struct dm_config_node *find_config_node(struct cmd_context *cmd, struct dm
|
||||
|
||||
const struct dm_config_node *find_config_tree_node(struct cmd_context *cmd, int id, struct profile *profile)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
int profile_applied;
|
||||
const struct dm_config_node *cn;
|
||||
@@ -1289,7 +1290,7 @@ const struct dm_config_node *find_config_tree_node(struct cmd_context *cmd, int
|
||||
|
||||
const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile *profile)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
int profile_applied;
|
||||
const char *str;
|
||||
@@ -1312,7 +1313,7 @@ const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile
|
||||
|
||||
const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id, struct profile *profile)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
int profile_applied;
|
||||
const char *str;
|
||||
@@ -1337,7 +1338,7 @@ const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id, st
|
||||
|
||||
int find_config_tree_int(struct cmd_context *cmd, int id, struct profile *profile)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
int profile_applied;
|
||||
int i;
|
||||
@@ -1360,7 +1361,7 @@ int find_config_tree_int(struct cmd_context *cmd, int id, struct profile *profil
|
||||
|
||||
int64_t find_config_tree_int64(struct cmd_context *cmd, int id, struct profile *profile)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
int profile_applied;
|
||||
int i64;
|
||||
@@ -1383,7 +1384,7 @@ int64_t find_config_tree_int64(struct cmd_context *cmd, int id, struct profile *
|
||||
|
||||
float find_config_tree_float(struct cmd_context *cmd, int id, struct profile *profile)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
int profile_applied;
|
||||
float f;
|
||||
@@ -1406,7 +1407,7 @@ float find_config_tree_float(struct cmd_context *cmd, int id, struct profile *pr
|
||||
|
||||
int find_config_bool(struct cmd_context *cmd, struct dm_config_tree *cft, int id)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
int b;
|
||||
|
||||
@@ -1424,7 +1425,7 @@ int find_config_bool(struct cmd_context *cmd, struct dm_config_tree *cft, int id
|
||||
|
||||
int find_config_tree_bool(struct cmd_context *cmd, int id, struct profile *profile)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
int profile_applied;
|
||||
int b;
|
||||
@@ -1446,7 +1447,7 @@ int find_config_tree_bool(struct cmd_context *cmd, int id, struct profile *profi
|
||||
}
|
||||
|
||||
static struct dm_config_node *_get_array_def_node(struct cmd_context *cmd,
|
||||
cfg_def_item_t *def,
|
||||
const cfg_def_item_t *def,
|
||||
struct profile *profile)
|
||||
{
|
||||
struct dm_config_node *cn;
|
||||
@@ -1518,7 +1519,7 @@ static void _log_array_value_used(struct dm_pool *mem, const struct dm_config_no
|
||||
|
||||
const struct dm_config_node *find_config_tree_array(struct cmd_context *cmd, int id, struct profile *profile)
|
||||
{
|
||||
cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *item = cfg_def_get_item_p(id);
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
int profile_applied;
|
||||
const struct dm_config_node *cn = NULL, *cn_def = NULL;
|
||||
@@ -1650,14 +1651,10 @@ int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft,
|
||||
if (merge_type == CONFIG_MERGE_TYPE_TAGS) {
|
||||
/* Remove any "tags" nodes */
|
||||
for (cn2 = cn->child; cn2; cn2 = cn2->sib) {
|
||||
if (!strcmp(cn2->key, "tags")) {
|
||||
if (!strcmp(cn2->key, "tags"))
|
||||
cn->child = cn2->sib;
|
||||
continue;
|
||||
}
|
||||
if (cn2->sib && !strcmp(cn2->sib->key, "tags")) {
|
||||
else if (cn2->sib && !strcmp(cn2->sib->key, "tags"))
|
||||
cn2->sib = cn2->sib->sib;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@@ -1728,7 +1725,7 @@ static int _get_config_node_version(uint16_t version_enc, char *version)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _def_node_is_deprecated(cfg_def_item_t *def, struct config_def_tree_spec *spec)
|
||||
static int _def_node_is_deprecated(const cfg_def_item_t *def, const struct config_def_tree_spec *spec)
|
||||
{
|
||||
return def->deprecated_since_version &&
|
||||
(spec->version >= def->deprecated_since_version);
|
||||
@@ -1737,7 +1734,7 @@ static int _def_node_is_deprecated(cfg_def_item_t *def, struct config_def_tree_s
|
||||
static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, void *baton)
|
||||
{
|
||||
struct out_baton *out = baton;
|
||||
struct cfg_def_item *cfg_def;
|
||||
const struct cfg_def_item *cfg_def;
|
||||
char version[9]; /* 8+1 chars for max version of 7.15.511 */
|
||||
const char *node_type_name = cn->v ? "option" : "section";
|
||||
char path[CFG_PATH_MAX_LEN];
|
||||
@@ -1819,7 +1816,7 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _should_print_cfg_with_undef_def_val(struct out_baton *out, cfg_def_item_t *cfg_def,
|
||||
static int _should_print_cfg_with_undef_def_val(struct out_baton *out, const cfg_def_item_t *cfg_def,
|
||||
const struct dm_config_node *cn)
|
||||
{
|
||||
if (!(cfg_def->flags & CFG_DEFAULT_UNDEFINED))
|
||||
@@ -1832,7 +1829,7 @@ static int _should_print_cfg_with_undef_def_val(struct out_baton *out, cfg_def_i
|
||||
static int _out_line_fn(const struct dm_config_node *cn, const char *line, void *baton)
|
||||
{
|
||||
struct out_baton *out = baton;
|
||||
struct cfg_def_item *cfg_def;
|
||||
const struct cfg_def_item *cfg_def;
|
||||
char config_path[CFG_PATH_MAX_LEN];
|
||||
char summary[MAX_COMMENT_LINE+1];
|
||||
char version[9];
|
||||
@@ -1983,7 +1980,7 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
|
||||
struct config_def_tree_spec *spec,
|
||||
struct dm_config_node *parent,
|
||||
struct dm_config_node *relay,
|
||||
cfg_def_item_t *def)
|
||||
const cfg_def_item_t *def)
|
||||
{
|
||||
struct dm_config_node *cn;
|
||||
const char *str;
|
||||
@@ -2063,14 +2060,14 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
|
||||
return cn;
|
||||
}
|
||||
|
||||
static int _should_skip_deprecated_def_node(cfg_def_item_t *def, struct config_def_tree_spec *spec)
|
||||
static int _should_skip_deprecated_def_node(const cfg_def_item_t *def, const struct config_def_tree_spec *spec)
|
||||
{
|
||||
return spec->ignoredeprecated && _def_node_is_deprecated(def, spec);
|
||||
}
|
||||
|
||||
static int _should_skip_def_node(struct config_def_tree_spec *spec, int section_id, int id)
|
||||
static int _should_skip_def_node(const struct config_def_tree_spec *spec, int section_id, int id)
|
||||
{
|
||||
cfg_def_item_t *def = cfg_def_get_item_p(id);
|
||||
const cfg_def_item_t *def = cfg_def_get_item_p(id);
|
||||
uint16_t flags;
|
||||
|
||||
if ((def->parent != section_id) ||
|
||||
@@ -2141,7 +2138,7 @@ static struct dm_config_node *_add_def_section_subtree(struct dm_config_tree *cf
|
||||
int section_id)
|
||||
{
|
||||
struct dm_config_node *cn = NULL, *relay_sub = NULL, *tmp;
|
||||
cfg_def_item_t *def;
|
||||
const cfg_def_item_t *def;
|
||||
int id;
|
||||
|
||||
for (id = 0; id < CFG_COUNT; id++) {
|
||||
@@ -2337,7 +2334,7 @@ int load_profile(struct cmd_context *cmd, struct profile *profile) {
|
||||
static char profile_path[PATH_MAX];
|
||||
|
||||
if (critical_section()) {
|
||||
log_error(INTERNAL_ERROR "trying to load profile %s "
|
||||
log_error(INTERNAL_ERROR "Trying to load profile %s "
|
||||
"in critical section.", profile->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r
|
||||
off_t offset, size_t size, off_t offset2, size_t size2,
|
||||
checksum_fn_t checksum_fn, uint32_t checksum,
|
||||
int skip_parse, int no_dup_node_check);
|
||||
int config_file_read(struct dm_config_tree *cft);
|
||||
int config_file_read_from_file(struct dm_config_tree *cft);
|
||||
struct dm_config_tree *config_file_open_and_read(const char *config_file, config_source_t source,
|
||||
struct cmd_context *cmd);
|
||||
int config_write(struct dm_config_tree *cft, struct config_def_tree_spec *tree_spec,
|
||||
|
||||
@@ -174,7 +174,7 @@ cfg_section(activation_CFG_SECTION, "activation", root_CFG_SECTION, CFG_PROFILAB
|
||||
|
||||
cfg_section(metadata_CFG_SECTION, "metadata", root_CFG_SECTION, CFG_DEFAULT_COMMENTED, vsn(1, 0, 0), 0, NULL, NULL)
|
||||
|
||||
cfg_section(report_CFG_SECTION, "report", root_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, vsn(1, 0, 0), 0, NULL,
|
||||
cfg_section(report_CFG_SECTION, "report", root_CFG_SECTION, CFG_PROFILABLE, vsn(1, 0, 0), 0, NULL,
|
||||
"LVM report command output formatting.\n")
|
||||
|
||||
cfg_section(dmeventd_CFG_SECTION, "dmeventd", root_CFG_SECTION, 0, vsn(1, 2, 3), 0, NULL,
|
||||
@@ -292,6 +292,14 @@ cfg(devices_devicesfile_CFG, "devicesfile", devices_CFG_SECTION, CFG_DEFAULT_COM
|
||||
"This should not be used to select a non-system devices file.\n"
|
||||
"The --devicesfile option is intended for alternative devices files.\n")
|
||||
|
||||
cfg(devices_devicesfile_backup_limit_CFG, "devicesfile_backup_limit", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_DEVICESFILE_BACKUP_LIMIT, vsn(2, 3, 23), NULL, 0, NULL,
|
||||
"The max number of backup files to keep in /etc/lvm/devices/backup.\n"
|
||||
"LVM creates a backup of the devices file each time a new\n"
|
||||
"version is created, or each time a modification is detected.\n"
|
||||
"When the max number of backups is reached, the oldest are\n"
|
||||
"removed to remain at the limit. Set to 0 to disable backups.\n"
|
||||
"Only the system devices file is backed up.\n")
|
||||
|
||||
cfg(devices_search_for_devnames_CFG, "search_for_devnames", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_SEARCH_FOR_DEVNAMES, vsn(2, 3, 12), NULL, 0, NULL,
|
||||
"Look outside of the devices file for missing devname entries.\n"
|
||||
"A devname entry is used for a device that does not have a stable\n"
|
||||
@@ -306,6 +314,22 @@ cfg(devices_search_for_devnames_CFG, "search_for_devnames", devices_CFG_SECTION,
|
||||
"at other devices, but only those that are likely to have the PV.\n"
|
||||
"If \"all\", lvm will look at all devices on the system.\n")
|
||||
|
||||
cfg(devices_device_ids_refresh_CFG, "device_ids_refresh", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 1, vsn(2, 3, 23), NULL, 0, NULL,
|
||||
"Find PVs on new devices and update the device IDs in the devices file.\n"
|
||||
"If PVs are restored or moved to a new system with new devices, but\n"
|
||||
"an old system.devices remains with old device IDs, then search for\n"
|
||||
"the PVIDs on new devices and update the device IDs in system.devices.\n"
|
||||
"The original device IDs must also not be found on the new system.\n"
|
||||
"See device_ids_refresh_check for conditions that trigger the refresh.\n")
|
||||
|
||||
cfg_array(devices_device_ids_refresh_checks_CFG, "device_ids_refresh_checks", devices_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, "#Sproduct_uuid#Shostname", vsn(2, 3, 23), NULL, 0, NULL,
|
||||
"Conditions that trigger device_ids_refresh to locate PVIDs on new devices.\n"
|
||||
"product_uuid: refresh if /sys/devices/virtual/dmi/id/product_uuid does not\n"
|
||||
"match the value saved in system.devices.\n"
|
||||
"hostname: refresh if hostname does not match the value saved in system.devices.\n"
|
||||
"(hostname is used if product_uuid is not available.)\n"
|
||||
"Remove values from this list to prevent lvm from using them.\n")
|
||||
|
||||
cfg_array(devices_filter_CFG, "filter", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, "#Sa|.*|", vsn(1, 0, 0), NULL, 0, NULL,
|
||||
"Limit the block devices that are used by LVM commands.\n"
|
||||
"This is a list of regular expressions used to accept or reject block\n"
|
||||
@@ -370,17 +394,12 @@ cfg(devices_sysfs_scan_CFG, "sysfs_scan", devices_CFG_SECTION, CFG_DEFAULT_COMME
|
||||
"present on the system. sysfs must be part of the kernel and mounted.)\n")
|
||||
|
||||
cfg(devices_scan_lvs_CFG, "scan_lvs", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_SCAN_LVS, vsn(2, 2, 182), NULL, 0, NULL,
|
||||
"Scan LVM LVs for layered PVs, allowing LVs to be used as PVs.\n"
|
||||
"When 1, LVM will detect PVs layered on LVs, and caution must be\n"
|
||||
"taken to avoid a host accessing a layered VG that may not belong\n"
|
||||
"to it, e.g. from a guest image. This generally requires excluding\n"
|
||||
"the LVs with device filters. Also, when this setting is enabled,\n"
|
||||
"every LVM command will scan every active LV on the system (unless\n"
|
||||
"filtered), which can cause performance problems on systems with\n"
|
||||
"many active LVs. When this setting is 0, LVM will not detect or\n"
|
||||
"use PVs that exist on LVs, and will not allow a PV to be created on\n"
|
||||
"an LV. The LVs are ignored using a built in device filter that\n"
|
||||
"identifies and excludes LVs.\n")
|
||||
"Allow LVM LVs to be used as PVs. When enabled, LVM commands will\n"
|
||||
"scan active LVs to look for other PVs. Caution is required to\n"
|
||||
"avoid using PVs that belong to guest images stored on LVs.\n"
|
||||
"When enabled, the LVs scanned should be restricted using the\n"
|
||||
"devices file or the filter. This option does not enable autoactivation\n"
|
||||
"of layered VGs, which requires editing LVM udev rules (see LVM_PVSCAN_ON_LVS.)\n")
|
||||
|
||||
cfg(devices_multipath_component_detection_CFG, "multipath_component_detection", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_MULTIPATH_COMPONENT_DETECTION, vsn(2, 2, 89), NULL, 0, NULL,
|
||||
"Ignore devices that are components of DM multipath devices.\n")
|
||||
@@ -732,8 +751,8 @@ cfg(allocation_vdo_block_map_era_length_CFG, "vdo_block_map_period", allocation_
|
||||
"The maximum and recommended value is " DM_TO_STRING(DM_VDO_BLOCK_MAP_ERA_LENGTH_MAXIMUM)
|
||||
"; the minimum value is " DM_TO_STRING(DM_VDO_BLOCK_MAP_ERA_LENGTH_MINIMUM) ".\n")
|
||||
|
||||
cfg(allocation_vdo_check_point_frequency_CFG, "vdo_check_point_frequency", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_VDO_CHECK_POINT_FREQUENCY, VDO_1ST_VSN, NULL, 0, NULL,
|
||||
"The default check point frequency for VDO volume.\n")
|
||||
cfg(allocation_vdo_check_point_frequency_CFG, "vdo_check_point_frequency", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_VDO_CHECK_POINT_FREQUENCY, VDO_1ST_VSN, NULL, vsn(2, 3, 22), NULL,
|
||||
"Deprecated option to set default check point frequency for VDO volume.\n")
|
||||
|
||||
// vdo format
|
||||
cfg(allocation_vdo_use_sparse_index_CFG, "vdo_use_sparse_index", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_VDO_USE_SPARSE_INDEX, VDO_1ST_VSN, NULL, 0, NULL,
|
||||
@@ -1000,7 +1019,7 @@ cfg_array(global_format_libraries_CFG, "format_libraries", global_CFG_SECTION, C
|
||||
|
||||
cfg_array(global_segment_libraries_CFG, "segment_libraries", global_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 18), NULL, vsn(2, 3, 3), NULL, NULL)
|
||||
|
||||
cfg(global_proc_CFG, "proc", global_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_PROC_DIR, vsn(1, 0, 0), NULL, 0, NULL,
|
||||
cfg(global_proc_CFG, "proc", global_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_PROC_DIR, vsn(1, 0, 0), "@DEFAULT_PROC_DIR@", 0, NULL,
|
||||
"Location of proc filesystem.\n")
|
||||
|
||||
cfg(global_etc_CFG, "etc", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_ETC_DIR, vsn(2, 2, 117), "@CONFDIR@", 0, NULL,
|
||||
@@ -1131,7 +1150,7 @@ cfg(global_lvdisplay_shows_full_device_path_CFG, "lvdisplay_shows_full_device_pa
|
||||
"Previously this was always shown as /dev/vgname/lvname even when that\n"
|
||||
"was never a valid path in the /dev filesystem.\n")
|
||||
|
||||
cfg(global_event_activation_CFG, "event_activation", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 1, vsn(2, 3, 1), 0, 0, NULL,
|
||||
cfg(global_event_activation_CFG, "event_activation", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_EVENT_ACTIVATION, vsn(2, 3, 1), "@DEFAULT_EVENT_ACTIVATION@", 0, NULL,
|
||||
"Disable event based autoactivation commands.\n"
|
||||
"WARNING: setting this to zero may cause machine startup to fail.\n"
|
||||
"Previously, setting this to zero would enable static autoactivation\n"
|
||||
@@ -1177,7 +1196,7 @@ cfg(global_lvmlockctl_kill_command_CFG, "lvmlockctl_kill_command", global_CFG_SE
|
||||
|
||||
cfg(global_thin_check_executable_CFG, "thin_check_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, THIN_CHECK_CMD, vsn(2, 2, 94), "@THIN_CHECK_CMD@", 0, NULL,
|
||||
"The full path to the thin_check command.\n"
|
||||
"LVM uses this command to check that a thin metadata device is in a\n"
|
||||
"LVM uses this command to check that a thin pool metadata device is in a\n"
|
||||
"usable state. When a thin pool is activated and after it is\n"
|
||||
"deactivated, this command is run. Activation will only proceed if\n"
|
||||
"the command has an exit status of 0. Set to \"\" to skip this check.\n"
|
||||
@@ -1195,6 +1214,12 @@ cfg(global_thin_repair_executable_CFG, "thin_repair_executable", global_CFG_SECT
|
||||
"an unusable state. Also see thin_repair_options.\n"
|
||||
"(See package device-mapper-persistent-data or thin-provisioning-tools)\n")
|
||||
|
||||
cfg(global_thin_restore_executable_CFG, "thin_restore_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, THIN_RESTORE_CMD, vsn(2, 3, 22), "@THIN_RESTORE_CMD@", 0, NULL,
|
||||
"The full path to the thin_restore command.\n"
|
||||
"LVM uses this command to restore generated data for a thin pool metadata device.\n"
|
||||
"Also see thin_restore_options.\n"
|
||||
"(See package device-mapper-persistent-data or thin-provisioning-tools)\n")
|
||||
|
||||
cfg_array(global_thin_check_options_CFG, "thin_check_options", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_THIN_CHECK_OPTIONS_CONFIG, vsn(2, 2, 96), NULL, 0, NULL,
|
||||
"List of options passed to the thin_check command.\n"
|
||||
"With thin_check version 2.1 or newer you can add the option\n"
|
||||
@@ -1205,6 +1230,9 @@ cfg_array(global_thin_check_options_CFG, "thin_check_options", global_CFG_SECTIO
|
||||
cfg_array(global_thin_repair_options_CFG, "thin_repair_options", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_THIN_REPAIR_OPTIONS_CONFIG, vsn(2, 2, 100), NULL, 0, NULL,
|
||||
"List of options passed to the thin_repair command.\n")
|
||||
|
||||
cfg_array(global_thin_restore_options_CFG, "thin_restore_options", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_THIN_RESTORE_OPTIONS_CONFIG, vsn(2, 3, 22), NULL, 0, NULL,
|
||||
"List of options passed to the thin_restore command.\n")
|
||||
|
||||
cfg_array(global_thin_disabled_features_CFG, "thin_disabled_features", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 99), NULL, 0, NULL,
|
||||
"Features to not use in the thin driver.\n"
|
||||
"This can be helpful for testing, or to avoid using a feature that is\n"
|
||||
@@ -1245,6 +1273,12 @@ cfg(global_cache_repair_executable_CFG, "cache_repair_executable", global_CFG_SE
|
||||
"an unusable state. Also see cache_repair_options.\n"
|
||||
"(See package device-mapper-persistent-data or thin-provisioning-tools)\n")
|
||||
|
||||
cfg(global_cache_restore_executable_CFG, "cache_restore_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, CACHE_RESTORE_CMD, vsn(2, 3, 22), "@CACHE_RESTORE_CMD@", 0, NULL,
|
||||
"The full path to the cache_restore command.\n"
|
||||
"LVM uses this command to restore generated data for a cache metadata device.\n"
|
||||
"Also see cache_restore_options.\n"
|
||||
"(See package device-mapper-persistent-data or thin-provisioning-tools)\n")
|
||||
|
||||
cfg_array(global_cache_check_options_CFG, "cache_check_options", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_CACHE_CHECK_OPTIONS_CONFIG, vsn(2, 2, 108), NULL, 0, NULL,
|
||||
"List of options passed to the cache_check command.\n"
|
||||
"With cache_check version 5.0 or newer you should include the option\n"
|
||||
@@ -1253,6 +1287,9 @@ cfg_array(global_cache_check_options_CFG, "cache_check_options", global_CFG_SECT
|
||||
cfg_array(global_cache_repair_options_CFG, "cache_repair_options", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_CACHE_REPAIR_OPTIONS_CONFIG, vsn(2, 2, 108), NULL, 0, NULL,
|
||||
"List of options passed to the cache_repair command.\n")
|
||||
|
||||
cfg_array(global_cache_restore_options_CFG, "cache_restore_options", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_CACHE_RESTORE_OPTIONS_CONFIG, vsn(2, 3, 22), NULL, 0, NULL,
|
||||
"List of options passed to the cache_restore command.\n")
|
||||
|
||||
cfg(global_vdo_format_executable_CFG, "vdo_format_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, VDO_FORMAT_CMD, VDO_1ST_VSN, "@VDO_FORMAT_CMD@", 0, NULL,
|
||||
"The full path to the vdoformat command.\n"
|
||||
"LVM uses this command to initial data volume for VDO type logical volume\n")
|
||||
@@ -1293,8 +1330,9 @@ cfg(global_system_id_source_CFG, "system_id_source", global_CFG_SECTION, CFG_DEF
|
||||
" Use an LVM-specific derivation of the local machine-id as the\n"
|
||||
" system ID. See 'man machine-id'.\n"
|
||||
" machineid\n"
|
||||
" Use the contents of the machine-id file to set the system ID\n"
|
||||
" (appmachineid is recommended.)\n"
|
||||
" Use the contents of the machine-id file to set the system ID.\n"
|
||||
" (appmachineid is recommended to avoid exposing the confidential\n"
|
||||
" machine-id.)\n"
|
||||
" file\n"
|
||||
" Use the contents of another file (system_id_file) to set the\n"
|
||||
" system ID.\n"
|
||||
@@ -1678,7 +1716,7 @@ cfg(activation_monitoring_CFG, "monitoring", activation_CFG_SECTION, CFG_DEFAULT
|
||||
cfg(activation_polling_interval_CFG, "polling_interval", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_INTERVAL, vsn(2, 2, 63), NULL, 0, NULL,
|
||||
"Check pvmove or lvconvert progress at this interval (seconds).\n"
|
||||
"When pvmove or lvconvert must wait for the kernel to finish\n"
|
||||
"synchronising or merging data, they check and report progress at\n"
|
||||
"synchronizing or merging data, they check and report progress at\n"
|
||||
"intervals of this number of seconds. If this is set to 0 and there\n"
|
||||
"is only one thing to wait for, there are no progress reports, but\n"
|
||||
"the process is awoken immediately once the operation is complete.\n")
|
||||
@@ -1845,8 +1883,12 @@ cfg(report_buffered_CFG, "buffered", report_CFG_SECTION, CFG_PROFILABLE | CFG_DE
|
||||
"execution. Otherwise, if buffering is not used, each object is\n"
|
||||
"reported as soon as its processing is finished.\n")
|
||||
|
||||
cfg(report_headings_CFG, "headings", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REP_HEADINGS, vsn(1, 0, 0), NULL, 0, NULL,
|
||||
"Show headings for columns on report.\n")
|
||||
cfg(report_headings_CFG, "headings", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_REP_HEADINGS, vsn(1, 0, 0), NULL, 0, NULL,
|
||||
"Format of LVM command's report output headings.\n"
|
||||
"Accepted values:\n"
|
||||
" 0 no headings,\n"
|
||||
" 1 headings with column abbreviations,\n"
|
||||
" 2 headings with full column names.\n")
|
||||
|
||||
cfg(report_separator_CFG, "separator", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_REP_SEPARATOR, vsn(1, 0, 0), NULL, 0, NULL,
|
||||
"A separator to use on report after each field.\n")
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#define DEFAULT_ARCHIVE_NUMBER 10
|
||||
|
||||
#define DEFAULT_DEV_DIR "/dev"
|
||||
#define DEFAULT_PROC_DIR "/proc"
|
||||
#define DEFAULT_SYSTEM_ID_SOURCE "none"
|
||||
#define DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV 0
|
||||
#define DEFAULT_EXTERNAL_DEVICE_INFO_SOURCE "none"
|
||||
@@ -105,6 +104,8 @@
|
||||
# define DEFAULT_DMEVENTD_PATH DMEVENTD_PATH
|
||||
#endif
|
||||
|
||||
#define DEFAULT_MAX_EXEC_ARGS 15 /* Max number of accepted options args */
|
||||
|
||||
#ifdef THIN_CHECK_NEEDS_CHECK
|
||||
# define DEFAULT_THIN_CHECK_OPTION1 "-q"
|
||||
# define DEFAULT_THIN_CHECK_OPTION2 "--clear-needs-check-flag"
|
||||
@@ -117,6 +118,8 @@
|
||||
|
||||
#define DEFAULT_THIN_REPAIR_OPTION1 ""
|
||||
#define DEFAULT_THIN_REPAIR_OPTIONS_CONFIG "#S" DEFAULT_THIN_REPAIR_OPTION1
|
||||
#define DEFAULT_THIN_RESTORE_OPTION1 ""
|
||||
#define DEFAULT_THIN_RESTORE_OPTIONS_CONFIG "#S" DEFAULT_THIN_RESTORE_OPTION1
|
||||
#define DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS 0
|
||||
#define DEFAULT_THIN_POOL_CROP_METADATA 0
|
||||
#define DEFAULT_THIN_POOL_MAX_METADATA_SIZE_V1_KB (UINT64_C(255) * ((1 << 14) - 64) * 4) /* KB */ /* 0x3f8040 blocks */
|
||||
@@ -145,6 +148,8 @@
|
||||
|
||||
#define DEFAULT_CACHE_REPAIR_OPTION1 ""
|
||||
#define DEFAULT_CACHE_REPAIR_OPTIONS_CONFIG "#S" DEFAULT_CACHE_REPAIR_OPTION1
|
||||
#define DEFAULT_CACHE_RESTORE_OPTION1 ""
|
||||
#define DEFAULT_CACHE_RESTORE_OPTIONS_CONFIG "#S" DEFAULT_CACHE_RESTORE_OPTION1
|
||||
#define DEFAULT_CACHE_POOL_METADATA_REQUIRE_SEPARATE_PVS 0
|
||||
#define DEFAULT_CACHE_POOL_CHUNK_SIZE 64 /* KB */
|
||||
#define DEFAULT_CACHE_POOL_MAX_CHUNKS 1000000
|
||||
@@ -324,7 +329,7 @@
|
||||
|
||||
#define DEFAULT_DEVICES_FILE "system.devices"
|
||||
|
||||
#define DEFAULT_SEARCH_FOR_DEVNAMES "auto"
|
||||
#define DEFAULT_SEARCH_FOR_DEVNAMES "all"
|
||||
|
||||
#define DEFAULT_WWIDS_FILE "/etc/multipath/wwids"
|
||||
|
||||
@@ -332,6 +337,10 @@
|
||||
#define VGS_ONLINE_DIR DEFAULT_RUN_DIR "/vgs_online"
|
||||
#define PVS_LOOKUP_DIR DEFAULT_RUN_DIR "/pvs_lookup"
|
||||
|
||||
#define DEVICES_IMPORT_PATH DEFAULT_RUN_DIR "/lvm-devices-import"
|
||||
|
||||
#define DEFAULT_DEVICE_ID_SYSFS_DIR "/sys/" /* trailing / to match dm_sysfs_dir() */
|
||||
|
||||
#define DEFAULT_DEVICESFILE_BACKUP_LIMIT 50
|
||||
|
||||
#endif /* _LVM_DEFAULTS_H */
|
||||
|
||||
@@ -58,6 +58,7 @@ bool bcache_read_bytes(struct bcache *cache, int di, uint64_t start, size_t len,
|
||||
block_address bb, be;
|
||||
uint64_t block_size = bcache_block_sectors(cache) << SECTOR_SHIFT;
|
||||
uint64_t block_offset = start % block_size;
|
||||
size_t blen;
|
||||
|
||||
bcache_prefetch_bytes(cache, di, start, len);
|
||||
|
||||
@@ -67,7 +68,7 @@ bool bcache_read_bytes(struct bcache *cache, int di, uint64_t start, size_t len,
|
||||
if (!bcache_get(cache, di, bb, 0, &b))
|
||||
return false;
|
||||
|
||||
size_t blen = _min(block_size - block_offset, len);
|
||||
blen = _min(block_size - block_offset, len);
|
||||
memcpy(data, ((unsigned char *) b->data) + block_offset, blen);
|
||||
bcache_put(b);
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
#define SECTOR_SHIFT 9L
|
||||
|
||||
#define FD_TABLE_INC 1024
|
||||
static int _fd_table_size;
|
||||
static int *_fd_table;
|
||||
static int _fd_table_size = 0;
|
||||
static int *_fd_table = NULL;
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
@@ -67,7 +67,7 @@ struct cb_set {
|
||||
struct dm_list free;
|
||||
struct dm_list allocated;
|
||||
struct control_block vec[];
|
||||
} control_block_set;
|
||||
};
|
||||
|
||||
static struct cb_set *_cb_set_create(unsigned nr)
|
||||
{
|
||||
@@ -711,7 +711,7 @@ static struct block *_block_lookup(struct bcache *cache, int di, uint64_t i)
|
||||
k.parts.di = di;
|
||||
k.parts.b = i;
|
||||
|
||||
if (radix_tree_lookup(cache->rtree, k.bytes, k.bytes + sizeof(k.bytes), &v))
|
||||
if (radix_tree_lookup(cache->rtree, k.bytes, sizeof(k.bytes), &v))
|
||||
return v.ptr;
|
||||
|
||||
return NULL;
|
||||
@@ -726,7 +726,7 @@ static bool _block_insert(struct block *b)
|
||||
k.parts.b = b->index;
|
||||
v.ptr = b;
|
||||
|
||||
return radix_tree_insert(b->cache->rtree, k.bytes, k.bytes + sizeof(k.bytes), v);
|
||||
return radix_tree_insert(b->cache->rtree, k.bytes, sizeof(k.bytes), v);
|
||||
}
|
||||
|
||||
static void _block_remove(struct block *b)
|
||||
@@ -736,7 +736,7 @@ static void _block_remove(struct block *b)
|
||||
k.parts.di = b->di;
|
||||
k.parts.b = b->index;
|
||||
|
||||
(void) radix_tree_remove(b->cache->rtree, k.bytes, k.bytes + sizeof(k.bytes));
|
||||
(void) radix_tree_remove(b->cache->rtree, k.bytes, sizeof(k.bytes));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
@@ -1181,7 +1181,6 @@ void bcache_destroy(struct bcache *cache)
|
||||
|
||||
if (!bcache_flush(cache))
|
||||
stack;
|
||||
_wait_all(cache);
|
||||
_exit_free_list(cache);
|
||||
radix_tree_destroy(cache->rtree);
|
||||
cache->engine->destroy(cache->engine);
|
||||
@@ -1354,7 +1353,7 @@ struct invalidate_iterator {
|
||||
};
|
||||
|
||||
static bool _writeback_v(struct radix_tree_iterator *it,
|
||||
uint8_t *kb, uint8_t *ke, union radix_value v)
|
||||
const void *kb, size_t keylen, union radix_value v)
|
||||
{
|
||||
struct block *b = v.ptr;
|
||||
|
||||
@@ -1365,7 +1364,7 @@ static bool _writeback_v(struct radix_tree_iterator *it,
|
||||
}
|
||||
|
||||
static bool _invalidate_v(struct radix_tree_iterator *it,
|
||||
uint8_t *kb, uint8_t *ke, union radix_value v)
|
||||
const void *kb, size_t keylen, union radix_value v)
|
||||
{
|
||||
struct block *b = v.ptr;
|
||||
struct invalidate_iterator *iit = container_of(it, struct invalidate_iterator, it);
|
||||
@@ -1400,16 +1399,16 @@ bool bcache_invalidate_di(struct bcache *cache, int di)
|
||||
k.parts.di = di;
|
||||
|
||||
it.it.visit = _writeback_v;
|
||||
radix_tree_iterate(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.di), &it.it);
|
||||
radix_tree_iterate(cache->rtree, k.bytes, sizeof(k.parts.di), &it.it);
|
||||
|
||||
_wait_all(cache);
|
||||
|
||||
it.success = true;
|
||||
it.it.visit = _invalidate_v;
|
||||
radix_tree_iterate(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.di), &it.it);
|
||||
radix_tree_iterate(cache->rtree, k.bytes, sizeof(k.parts.di), &it.it);
|
||||
|
||||
if (it.success)
|
||||
(void) radix_tree_remove_prefix(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.di));
|
||||
(void) radix_tree_remove_prefix(cache->rtree, k.bytes, sizeof(k.parts.di));
|
||||
|
||||
return it.success;
|
||||
}
|
||||
@@ -1417,7 +1416,7 @@ bool bcache_invalidate_di(struct bcache *cache, int di)
|
||||
//----------------------------------------------------------------
|
||||
|
||||
static bool _abort_v(struct radix_tree_iterator *it,
|
||||
uint8_t *kb, uint8_t *ke, union radix_value v)
|
||||
const void *kb, size_t keylen, union radix_value v)
|
||||
{
|
||||
struct block *b = v.ptr;
|
||||
|
||||
@@ -1443,8 +1442,8 @@ void bcache_abort_di(struct bcache *cache, int di)
|
||||
k.parts.di = di;
|
||||
|
||||
it.visit = _abort_v;
|
||||
radix_tree_iterate(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.di), &it);
|
||||
(void) radix_tree_remove_prefix(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.di));
|
||||
radix_tree_iterate(cache->rtree, k.bytes, sizeof(k.parts.di), &it);
|
||||
(void) radix_tree_remove_prefix(cache->rtree, k.bytes, sizeof(k.parts.di));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,48 +34,63 @@ struct dev_filter {
|
||||
const char *name;
|
||||
};
|
||||
|
||||
struct dm_list *dev_cache_get_dev_list_for_vgid(const char *vgid);
|
||||
struct dm_list *dev_cache_get_dev_list_for_lvid(const char *lvid);
|
||||
void dev_init(struct device *dev);
|
||||
|
||||
struct dm_list *dev_cache_get_dev_list_for_vgid(struct cmd_context *cmd, const char *vgid);
|
||||
struct dm_list *dev_cache_get_dev_list_for_lvid(struct cmd_context *cmd, const char *lvid);
|
||||
|
||||
/*
|
||||
* The cache of dm devices is enabled when the kernel
|
||||
* supports the ability to quickly report on many dm
|
||||
* devs together, in which case we can get all the dm
|
||||
* info at once and store it in this dm_devs_cache.
|
||||
* This avoids many individual dm dev ioctl calls.
|
||||
* The callers of these dm_devs_cache functions must
|
||||
* have an alternative for when dm_devs_cache_use()
|
||||
* returns 0.
|
||||
*/
|
||||
int dm_devs_cache_use(struct cmd_context *cmd);
|
||||
int dm_devs_cache_update(struct cmd_context *cmd);
|
||||
void dm_devs_cache_destroy(struct cmd_context *cmd);
|
||||
void dm_devs_cache_label_invalidate(struct cmd_context *cmd);
|
||||
const struct dm_active_device *
|
||||
dm_devs_cache_get_by_devno(struct cmd_context *cmd, dev_t devno);
|
||||
const struct dm_active_device *
|
||||
dm_devs_cache_get_by_uuid(struct cmd_context *cmd, const char *dm_uuid);
|
||||
|
||||
/*
|
||||
* The global device cache.
|
||||
*/
|
||||
int dev_cache_init(struct cmd_context *cmd);
|
||||
int dev_cache_exit(void);
|
||||
|
||||
/*
|
||||
* Returns number of open devices.
|
||||
*/
|
||||
int dev_cache_check_for_open_devices(void);
|
||||
int dev_cache_exit(struct cmd_context *cmd);
|
||||
|
||||
void dev_cache_scan(struct cmd_context *cmd);
|
||||
int dev_cache_has_scanned(void);
|
||||
|
||||
int dev_cache_add_dir(const char *path);
|
||||
int dev_cache_add_dir(struct cmd_context *cmd, const char *path);
|
||||
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
|
||||
struct device *dev_cache_get_existing(struct cmd_context *cmd, const char *name, struct dev_filter *f);
|
||||
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt);
|
||||
void dev_cache_verify_aliases(struct device *dev);
|
||||
void dev_cache_verify_aliases(struct cmd_context *cmd, struct device *dev);
|
||||
|
||||
struct device *dev_hash_get(const char *name);
|
||||
struct device *dev_cache_get_by_devno(struct cmd_context *cmd, dev_t devno);
|
||||
struct device *dev_cache_get_by_name(struct cmd_context *cmd, const char *name);
|
||||
struct device *dev_cache_get_by_pvid(struct cmd_context *cmd, const char *pvid);
|
||||
|
||||
void dev_set_preferred_name(struct dm_str_list *sl, struct device *dev);
|
||||
void dev_set_preferred_name(struct cmd_context *cmd, struct dm_str_list *sl, struct device *dev);
|
||||
|
||||
/*
|
||||
* Object for iterating through the cache.
|
||||
*/
|
||||
struct dev_iter;
|
||||
struct dev_iter *dev_iter_create(struct dev_filter *f, int unused);
|
||||
struct dev_iter *dev_iter_create(struct cmd_context *cmd, struct dev_filter *f, int unused);
|
||||
void dev_iter_destroy(struct dev_iter *iter);
|
||||
struct device *dev_iter_get(struct cmd_context *cmd, struct dev_iter *iter);
|
||||
|
||||
void dev_cache_failed_path(struct device *dev, const char *path);
|
||||
void dev_cache_failed_path(struct cmd_context *cmd, struct device *dev, const char *path);
|
||||
|
||||
bool dev_cache_has_md_with_end_superblock(struct dev_types *dt);
|
||||
bool dev_cache_has_md_with_end_superblock(struct cmd_context *cmd, struct dev_types *dt);
|
||||
|
||||
int get_sysfs_value(const char *path, char *buf, size_t buf_size, int error_if_no_value);
|
||||
int get_sysfs_binary(const char *path, char *buf, size_t buf_size, int *retlen);
|
||||
int get_dm_uuid_from_sysfs(char *buf, size_t buf_size, int major, int minor);
|
||||
|
||||
int setup_devices_file(struct cmd_context *cmd);
|
||||
int setup_devices(struct cmd_context *cmd);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#endif
|
||||
|
||||
struct ext_registry_item {
|
||||
const char *name;
|
||||
const char name[16];
|
||||
struct dev_ext *(* dev_ext_get) (struct device *dev);
|
||||
int (*dev_ext_release) (struct device *dev);
|
||||
};
|
||||
@@ -90,7 +90,7 @@ static int _dev_ext_release_udev(struct device *dev)
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct ext_registry_item _ext_registry[DEV_EXT_NUM] = {
|
||||
static const struct ext_registry_item _ext_registry[DEV_EXT_NUM] = {
|
||||
EXT_REGISTER(DEV_EXT_NONE, none),
|
||||
EXT_REGISTER(DEV_EXT_UDEV, udev)
|
||||
};
|
||||
|
||||
@@ -310,7 +310,8 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
|
||||
|
||||
if (dm_list_empty(&dev->aliases)) {
|
||||
/* shouldn't happen */
|
||||
log_print_unless_silent("Cannot open device %d:%d with no valid paths.", (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
|
||||
log_print_unless_silent("Cannot open device %u:%u with no valid paths.",
|
||||
MAJOR(dev->dev), MINOR(dev->dev));
|
||||
return 0;
|
||||
}
|
||||
name = dev_name(dev);
|
||||
@@ -447,11 +448,6 @@ int dev_open_readonly(struct device *dev)
|
||||
return dev_open_flags(dev, O_RDONLY, 1, 0);
|
||||
}
|
||||
|
||||
int dev_open_readonly_buffered(struct device *dev)
|
||||
{
|
||||
return dev_open_flags(dev, O_RDONLY, 0, 0);
|
||||
}
|
||||
|
||||
int dev_open_readonly_quiet(struct device *dev)
|
||||
{
|
||||
return dev_open_flags(dev, O_RDONLY, 1, 1);
|
||||
@@ -464,9 +460,6 @@ static void _close(struct device *dev)
|
||||
dev->fd = -1;
|
||||
|
||||
log_debug_devs("Closed %s", dev_name(dev));
|
||||
|
||||
if (dev->flags & DEV_ALLOCED)
|
||||
dev_destroy_file(dev);
|
||||
}
|
||||
|
||||
static int _dev_close(struct device *dev, int immediate)
|
||||
|
||||
@@ -322,8 +322,8 @@ static int _md_sysfs_attribute_snprintf(char *path, size_t size,
|
||||
if (MAJOR(dev) != dt->md_major)
|
||||
return ret;
|
||||
|
||||
ret = dm_snprintf(path, size, "%s/dev/block/%d:%d/md/%s", sysfs_dir,
|
||||
(int)MAJOR(dev), (int)MINOR(dev), attribute);
|
||||
ret = dm_snprintf(path, size, "%s/dev/block/%u:%u/md/%s", sysfs_dir,
|
||||
MAJOR(dev), MINOR(dev), attribute);
|
||||
if (ret < 0) {
|
||||
log_error("dm_snprintf md %s failed", attribute);
|
||||
return ret;
|
||||
@@ -335,8 +335,8 @@ static int _md_sysfs_attribute_snprintf(char *path, size_t size,
|
||||
return ret;
|
||||
}
|
||||
/* old sysfs structure */
|
||||
ret = dm_snprintf(path, size, "%s/block/md%d/md/%s",
|
||||
sysfs_dir, (int)MINOR(dev), attribute);
|
||||
ret = dm_snprintf(path, size, "%s/block/md%u/md/%s",
|
||||
sysfs_dir, MINOR(dev), attribute);
|
||||
if (ret < 0) {
|
||||
log_error("dm_snprintf old md %s failed", attribute);
|
||||
return ret;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "lib/commands/toolcontext.h"
|
||||
#include "lib/device/device_id.h"
|
||||
#include "lib/datastruct/str_list.h"
|
||||
#include "device_mapper/misc/dm-ioctl.h"
|
||||
#ifdef UDEV_SYNC_SUPPORT
|
||||
#include <libudev.h>
|
||||
#include "lib/device/dev-ext-udev-constants.h"
|
||||
@@ -164,6 +165,7 @@ static void _read_blacklist_file(const char *path)
|
||||
|
||||
static void _read_wwid_exclusions(void)
|
||||
{
|
||||
static const char _mpath_conf[] = "/etc/multipath/conf.d";
|
||||
char path[PATH_MAX] = { 0 };
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
@@ -172,14 +174,15 @@ static void _read_wwid_exclusions(void)
|
||||
|
||||
_read_blacklist_file("/etc/multipath.conf");
|
||||
|
||||
if ((dir = opendir("/etc/multipath/conf.d"))) {
|
||||
if ((dir = opendir(_mpath_conf))) {
|
||||
while ((de = readdir(dir))) {
|
||||
if (de->d_name[0] == '.')
|
||||
continue;
|
||||
snprintf(path, PATH_MAX-1, "/etc/multipath/conf.d/%s", de->d_name);
|
||||
snprintf(path, sizeof(path), "%s/%s", _mpath_conf, de->d_name);
|
||||
_read_blacklist_file(path);
|
||||
}
|
||||
closedir(dir);
|
||||
if (closedir(dir))
|
||||
log_sys_debug("closedir", _mpath_conf);
|
||||
}
|
||||
|
||||
/* for each wwid in ignored_exceptions, remove it from ignored */
|
||||
@@ -356,8 +359,8 @@ static const char *_get_sysfs_name_by_devt(const char *sysfs_dir, dev_t devno,
|
||||
char path[PATH_MAX];
|
||||
int size;
|
||||
|
||||
if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d", sysfs_dir,
|
||||
(int) MAJOR(devno), (int) MINOR(devno)) < 0) {
|
||||
if (dm_snprintf(path, sizeof(path), "%sdev/block/%u:%u", sysfs_dir,
|
||||
MAJOR(devno), MINOR(devno)) < 0) {
|
||||
log_error("Sysfs path string is too long.");
|
||||
return NULL;
|
||||
}
|
||||
@@ -377,48 +380,6 @@ static const char *_get_sysfs_name_by_devt(const char *sysfs_dir, dev_t devno,
|
||||
return name;
|
||||
}
|
||||
|
||||
static int _get_sysfs_string(const char *path, char *buffer, int max_size)
|
||||
{
|
||||
FILE *fp;
|
||||
int r = 0;
|
||||
|
||||
if (!(fp = fopen(path, "r"))) {
|
||||
log_sys_error("fopen", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!fgets(buffer, max_size, fp))
|
||||
log_sys_error("fgets", path);
|
||||
else
|
||||
r = 1;
|
||||
|
||||
if (fclose(fp))
|
||||
log_sys_error("fclose", path);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _get_sysfs_dm_mpath(struct dev_types *dt, const char *sysfs_dir, const char *holder_name)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
char buffer[128];
|
||||
|
||||
if (dm_snprintf(path, sizeof(path), "%sblock/%s/dm/uuid", sysfs_dir, holder_name) < 0) {
|
||||
log_error("Sysfs path string is too long.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer[0] = '\0';
|
||||
|
||||
if (!_get_sysfs_string(path, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
|
||||
if (!strncmp(buffer, MPATH_PREFIX, 6))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef UDEV_SYNC_SUPPORT
|
||||
static int _dev_is_mpath_component_udev(struct device *dev)
|
||||
{
|
||||
@@ -460,14 +421,15 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
|
||||
char link_path[PATH_MAX]; /* some obscure, unpredictable sysfs path */
|
||||
char holders_path[PATH_MAX]; /* e.g. "/sys/block/sda/holders/" */
|
||||
char dm_dev_path[PATH_MAX]; /* e.g. "/dev/dm-1" */
|
||||
char uuid[DM_UUID_LEN];
|
||||
char *holder_name; /* e.g. "dm-1" */
|
||||
const char *sysfs_dir = dm_sysfs_dir();
|
||||
DIR *dr;
|
||||
struct dirent *de;
|
||||
int dev_major = MAJOR(dev->dev);
|
||||
int dev_minor = MINOR(dev->dev);
|
||||
int dm_dev_major;
|
||||
int dm_dev_minor;
|
||||
unsigned dev_major = MAJOR(dev->dev);
|
||||
unsigned dev_minor = MINOR(dev->dev);
|
||||
unsigned dm_dev_major;
|
||||
unsigned dm_dev_minor;
|
||||
struct stat info;
|
||||
int is_mpath_component = 0;
|
||||
|
||||
@@ -488,7 +450,7 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
|
||||
break;
|
||||
|
||||
default: /* 0, error. */
|
||||
log_warn("Failed to get primary device for %d:%d.", dev_major, dev_minor);
|
||||
log_warn("Failed to get primary device for %u:%u.", dev_major, dev_minor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -539,8 +501,8 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
|
||||
dev_name(dev), dm_dev_path, errno);
|
||||
continue;
|
||||
}
|
||||
dm_dev_major = (int)MAJOR(info.st_rdev);
|
||||
dm_dev_minor = (int)MINOR(info.st_rdev);
|
||||
dm_dev_major = MAJOR(info.st_rdev);
|
||||
dm_dev_minor = MINOR(info.st_rdev);
|
||||
|
||||
if (dm_dev_major != dt->device_mapper_major) {
|
||||
log_debug_devs("dev_is_mpath_component %s holder %s %d:%d does not have dm major",
|
||||
@@ -558,7 +520,8 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
|
||||
*/
|
||||
|
||||
if (_minor_hash_tab) {
|
||||
long look = (long) dm_hash_lookup_binary(_minor_hash_tab, &dm_dev_minor, sizeof(dm_dev_minor));
|
||||
void *d = dm_hash_lookup_binary(_minor_hash_tab, &dm_dev_minor, sizeof(dm_dev_minor));
|
||||
long look = (long) d;
|
||||
if (look > 0) {
|
||||
log_debug_devs("dev_is_mpath_component %s holder %s %u:%u already checked as %sbeing mpath.",
|
||||
dev_name(dev), holder_name, dm_dev_major, dm_dev_minor, (look > 1) ? "" : "not ");
|
||||
@@ -570,12 +533,10 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
|
||||
/* no saved result for dm_dev_minor, so check the uuid for it */
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns 1 if /sys/block/<holder_name>/dm/uuid indicates that
|
||||
* <holder_name> is a dm device with dm uuid prefix mpath-.
|
||||
* When true, <holder_name> will be something like "dm-1".
|
||||
*/
|
||||
if (_get_sysfs_dm_mpath(dt, sysfs_dir, holder_name)) {
|
||||
/* Check whether holder's UUID uses MPATH prefix */
|
||||
/* TODO: reuse/merge with dev_has_mpath_uuid() as this function also recognizes kpartx partition */
|
||||
if (devno_dm_uuid(cmd, dm_dev_major, dm_dev_minor, uuid, sizeof(uuid)) &&
|
||||
!strncmp(uuid, MPATH_PREFIX, sizeof(MPATH_PREFIX) - 1)) {
|
||||
log_debug_devs("dev_is_mpath_component %s holder %s %u:%u ignore mpath component",
|
||||
dev_name(dev), holder_name, dm_dev_major, dm_dev_minor);
|
||||
|
||||
@@ -594,7 +555,7 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
|
||||
|
||||
out:
|
||||
if (closedir(dr))
|
||||
stack;
|
||||
log_sys_debug("closedir", holders_path);
|
||||
|
||||
if (is_mpath_component)
|
||||
*mpath_devno = MKDEV(dm_dev_major, dm_dev_minor);
|
||||
@@ -615,7 +576,7 @@ static int _dev_in_wwid_file(struct cmd_context *cmd, struct device *dev,
|
||||
* Check the primary device, not the partition.
|
||||
*/
|
||||
if (primary_result == 2) {
|
||||
if (!(dev = dev_cache_get_by_devt(cmd, primary_dev))) {
|
||||
if (!(dev = dev_cache_get_by_devno(cmd, primary_dev))) {
|
||||
log_debug("dev_is_mpath_component %s no primary dev", dev_name(dev));
|
||||
return 0;
|
||||
}
|
||||
@@ -720,30 +681,24 @@ const char *dev_mpath_component_wwid(struct cmd_context *cmd, struct device *dev
|
||||
char sysbuf[PATH_MAX] = { 0 };
|
||||
char *slave_name;
|
||||
const char *wwid = NULL;
|
||||
struct stat info;
|
||||
DIR *dr;
|
||||
struct dirent *de;
|
||||
|
||||
/* /sys/dev/block/253:7/slaves/sda/device/wwid */
|
||||
|
||||
if (dm_snprintf(slaves_path, sizeof(slaves_path), "%sdev/block/%d:%d/slaves",
|
||||
dm_sysfs_dir(), (int)MAJOR(dev->dev), (int)MINOR(dev->dev)) < 0) {
|
||||
if (dm_snprintf(slaves_path, sizeof(slaves_path), "%sdev/block/%u:%u/slaves",
|
||||
dm_sysfs_dir(), MAJOR(dev->dev), MINOR(dev->dev)) < 0) {
|
||||
log_warn("Sysfs path to check mpath components is too long.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (stat(slaves_path, &info))
|
||||
return NULL;
|
||||
|
||||
if (!S_ISDIR(info.st_mode)) {
|
||||
log_warn("Path %s is not a directory.", slaves_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Get wwid from first component */
|
||||
|
||||
if (!(dr = opendir(slaves_path))) {
|
||||
log_debug("Device %s has no slaves dir", dev_name(dev));
|
||||
if (errno == ENOTDIR)
|
||||
log_warn("WARNING: Path %s is not a directory.", slaves_path);
|
||||
else if (errno != ENOENT)
|
||||
log_sys_debug("opendir", slaves_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -757,17 +712,19 @@ const char *dev_mpath_component_wwid(struct cmd_context *cmd, struct device *dev
|
||||
/* read /sys/block/sda/device/wwid */
|
||||
|
||||
if (dm_snprintf(wwid_path, sizeof(wwid_path), "%sblock/%s/device/wwid",
|
||||
dm_sysfs_dir(), slave_name) < 0) {
|
||||
dm_sysfs_dir(), slave_name) < 0) {
|
||||
log_warn("Failed to create sysfs wwid path for %s", slave_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
get_sysfs_value(wwid_path, sysbuf, sizeof(sysbuf), 0);
|
||||
if (!get_sysfs_value(wwid_path, sysbuf, sizeof(sysbuf), 0))
|
||||
stack;
|
||||
|
||||
if (!sysbuf[0])
|
||||
continue;
|
||||
|
||||
if (strstr(sysbuf, "scsi_debug")) {
|
||||
int i;
|
||||
unsigned i;
|
||||
for (i = 0; i < strlen(sysbuf); i++) {
|
||||
if (sysbuf[i] == ' ')
|
||||
sysbuf[i] = '_';
|
||||
@@ -778,9 +735,7 @@ const char *dev_mpath_component_wwid(struct cmd_context *cmd, struct device *dev
|
||||
break;
|
||||
}
|
||||
if (closedir(dr))
|
||||
stack;
|
||||
log_sys_debug("closedir", slaves_path);
|
||||
|
||||
return wwid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user