forked from vitalif/vitastor
Compare commits
703 Commits
blocking-u
...
master
Author | SHA1 | Date |
---|---|---|
huy | b57a40a67e | |
huy | fa95a26109 | |
huy | ec44cb09e7 | |
huy | 25fccefe6d | |
Vitaliy Filippov | 20a4406acc | |
Vitaliy Filippov | f93491bc6c | |
Vitaliy Filippov | 999bed8514 | |
Vitaliy Filippov | 3f33095fd7 | |
Vitaliy Filippov | dd74c5ce1b | |
Vitaliy Filippov | c6d104ecd6 | |
Vitaliy Filippov | e544aef7d0 | |
Vitaliy Filippov | 616c18c786 | |
Vitaliy Filippov | fa687d3878 | |
Vitaliy Filippov | 2c7556e536 | |
Vitaliy Filippov | 2020608a39 | |
Vitaliy Filippov | 139b98d80f | |
Vitaliy Filippov | f54ff6ad5d | |
Vitaliy Filippov | b376ef2ed9 | |
Vitaliy Filippov | 5a234588b9 | |
Vitaliy Filippov | b82c30328f | |
Vitaliy Filippov | 0ee5e0a7fe | |
Vitaliy Filippov | 0a1640d169 | |
Vitaliy Filippov | 3482bb0860 | |
Vitaliy Filippov | 526995f486 | |
Vitaliy Filippov | 073b505928 | |
Vitaliy Filippov | a8b21a22d0 | |
Vitaliy Filippov | 0b1ffba62b | |
Vitaliy Filippov | 8dfbd7943c | |
Vitaliy Filippov | 39e7f98e54 | |
Vitaliy Filippov | 3a83a32cb7 | |
Vitaliy Filippov | 20d5ed799a | |
Vitaliy Filippov | b262938bca | |
Vitaliy Filippov | 7e54242251 | |
Vitaliy Filippov | c3c2e68cc1 | |
Vitaliy Filippov | aa1e21dd99 | |
Vitaliy Filippov | f4b57d487f | |
Vitaliy Filippov | 711ecd2f8e | |
Vitaliy Filippov | 9fca01dc62 | |
Vitaliy Filippov | 0bd3a94efd | |
Vitaliy Filippov | 9ffdeef93b | |
Vitaliy Filippov | 589892d501 | |
Vitaliy Filippov | 5fe3a40416 | |
Vitaliy Filippov | a453db9c8e | |
Vitaliy Filippov | e6498a52ca | |
Vitaliy Filippov | 4bc41aed9d | |
Vitaliy Filippov | 4da51f9c4c | |
Vitaliy Filippov | c6cee6f734 | |
Vitaliy Filippov | 6fc08f5581 | |
Vitaliy Filippov | 15957b7d13 | |
Vitaliy Filippov | 09a3987e83 | |
Vitaliy Filippov | cd6820c439 | |
Vitaliy Filippov | dcd8f5e76c | |
Vitaliy Filippov | 5859f913fc | |
Vitaliy Filippov | cac6a1d8d1 | |
Vitaliy Filippov | a0c32e7de9 | |
Vitaliy Filippov | 8b37610dd0 | |
Vitaliy Filippov | ae82ca3b08 | |
Vitaliy Filippov | 92362027a8 | |
Vitaliy Filippov | c4aeeda143 | |
Vitaliy Filippov | 24f0f8278a | |
Vitaliy Filippov | 95496d0845 | |
Vitaliy Filippov | 94b1f09ef2 | |
Vitaliy Filippov | 32b1312abb | |
Vitaliy Filippov | d5c8fde5de | |
Vitaliy Filippov | 7a0b5212fe | |
Vitaliy Filippov | a8f5c71ae8 | |
Vitaliy Filippov | ce5b6253ab | |
Vitaliy Filippov | 8398ad0117 | |
Vitaliy Filippov | fea451b4db | |
Vitaliy Filippov | 6e12aca53b | |
Vitaliy Filippov | 8b007d531f | |
Vitaliy Filippov | 7b7f20fb89 | |
Vitaliy Filippov | 300d507026 | |
harley | 6886171289 | |
Vitaliy Filippov | 43f8ea47a0 | |
Vitaliy Filippov | 6e0e172e15 | |
Vitaliy Filippov | 655a2c871d | |
Vitaliy Filippov | 879fe9b2b4 | |
Vitaliy Filippov | 660c3f7b0d | |
Vitaliy Filippov | f0ebfae3b8 | |
Vitaliy Filippov | eb7ad2c114 | |
Tân Lê | b4235b4edf | |
Vitaliy Filippov | cd21ff0b6a | |
Vitaliy Filippov | d3903f039c | |
Vitaliy Filippov | 66fe1a469b | |
Vitaliy Filippov | 24409bd4c4 | |
Vitaliy Filippov | c5029961ea | |
Vitaliy Filippov | 1ca1143d4a | |
Vitaliy Filippov | 920345f7b6 | |
Vitaliy Filippov | 75b47a6298 | |
Vitaliy Filippov | 6e446653ae | |
Vitaliy Filippov | e51edf2542 | |
Vitaliy Filippov | ce170af91f | |
Vitaliy Filippov | 7eabc364bf | |
Vitaliy Filippov | a346f84c69 | |
Vitaliy Filippov | 71a0c1a7b9 | |
Vitaliy Filippov | 20e86c7d84 | |
Vitaliy Filippov | 110b39900b | |
Vitaliy Filippov | 697ee30a26 | |
Vitaliy Filippov | 42479b4590 | |
Vitaliy Filippov | 6e82044e84 | |
Vitaliy Filippov | 2cb3e84882 | |
Vitaliy Filippov | 32614c5bc8 | |
Vitaliy Filippov | aa436027c8 | |
Vitaliy Filippov | 577a563b91 | |
Vitaliy Filippov | e4efa2c08a | |
Vitaliy Filippov | 0f3f0a9d29 | |
Vitaliy Filippov | 0544a16f95 | |
Tân Lê | 30d8930958 | |
Tân Lê | baf003fbd3 | |
Tân Lê | ba39a38dc4 | |
Vitaliy Filippov | d528cd77f1 | |
Vitaliy Filippov | 6e6f407df3 | |
Vitaliy Filippov | 4d43774cbb | |
Vitaliy Filippov | a1488f7217 | |
Vitaliy Filippov | 404e07d365 | |
Vitaliy Filippov | b3dcee0d43 | |
Vitaliy Filippov | 609bd4eb59 | |
Vitaliy Filippov | 8e445ddc9a | |
Vitaliy Filippov | ffb06536ff | |
Vitaliy Filippov | eeecab20c2 | |
Tân Lê | e889ac4209 | |
Vitaliy Filippov | cfe8de9b84 | |
Vitaliy Filippov | 24b9b19066 | |
Vitaliy Filippov | ef645ee0c2 | |
Tân Lê | 8a9bae5216 | |
Vitaliy Filippov | da99686a15 | |
Vitaliy Filippov | dcc03ee41f | |
Vitaliy Filippov | fb2f7a0d3c | |
Vitaliy Filippov | 38d85da19a | |
Vitaliy Filippov | dc3caee284 | |
Vitaliy Filippov | 89dcda1fed | |
Vitaliy Filippov | 1526e2055e | |
Vitaliy Filippov | 74cb3911db | |
Vitaliy Filippov | d5efbbb6b9 | |
Vitaliy Filippov | 4319091bd3 | |
Vitaliy Filippov | 6d307d5391 | |
Vitaliy Filippov | 065dfef683 | |
Vitaliy Filippov | 4d6b85fe67 | |
Vitaliy Filippov | 2dd2f29f46 | |
Vitaliy Filippov | fc3a1e076a | |
Vitaliy Filippov | 3a3e168c42 | |
Vitaliy Filippov | 95c55da0ad | |
Vitaliy Filippov | 5cf1157f16 | |
Vitaliy Filippov | acf637950c | |
Vitaliy Filippov | a02b02eb04 | |
Vitaliy Filippov | 7d3d696110 | |
Vitaliy Filippov | 712576ca75 | |
Vitaliy Filippov | 28bd94d2c2 | |
Vitaliy Filippov | 148ff04aa8 | |
JiangYu | e86df4a2a2 | |
Vitaliy Filippov | e74af9745e | |
Vitaliy Filippov | 0e0509e3da | |
Vitaliy Filippov | cb282d25e0 | |
Vitaliy Filippov | 8b2a4c9539 | |
Vitaliy Filippov | b66a079892 | |
Vitaliy Filippov | e90bbe6385 | |
Vitaliy Filippov | 4be761254c | |
Vitaliy Filippov | 7a45c5f86c | |
Vitaliy Filippov | bff413584d | |
Vitaliy Filippov | bb31050ab5 | |
Vitaliy Filippov | b52dd6843a | |
Vitaliy Filippov | b66160a7ad | |
Vitaliy Filippov | 30bb602681 | |
Vitaliy Filippov | eb0a3adafc | |
Vitaliy Filippov | 24301b116c | |
Vitaliy Filippov | 1d00c17d68 | |
Vitaliy Filippov | 24f19c4b80 | |
Vitaliy Filippov | dfdf5c1f9c | |
Vitaliy Filippov | aad7792d3f | |
Vitaliy Filippov | 6ca8afffe5 | |
Vitaliy Filippov | 511a89948b | |
Vitaliy Filippov | 3de553ecd7 | |
Vitaliy Filippov | 9c45d43e74 | |
Vitaliy Filippov | 891250d355 | |
Vitaliy Filippov | f9fe72d40a | |
Vitaliy Filippov | 10ee4f7c1d | |
Vitaliy Filippov | fd8244699b | |
Vitaliy Filippov | eaac1fc5d1 | |
Vitaliy Filippov | 57be1923d3 | |
Vitaliy Filippov | c467acc388 | |
Vitaliy Filippov | bf591ba3ee | |
Vitaliy Filippov | 699a0fbbc7 | |
Vitaliy Filippov | 6b2dd50f27 | |
Vitaliy Filippov | caf2f3c56f | |
Vitaliy Filippov | 9174f188b1 | |
Vitaliy Filippov | d3978c6d0e | |
Vitaliy Filippov | 4a7365660d | |
Vitaliy Filippov | 818ae5d61d | |
Vitaliy Filippov | 6810e93c3f | |
Vitaliy Filippov | f6f35f4127 | |
Vitaliy Filippov | 72aa2fd819 | |
Vitaliy Filippov | 5010b0dd75 | |
Vitaliy Filippov | 483c5ab380 | |
Vitaliy Filippov | 6a6fd6544d | |
Vitaliy Filippov | 971aa4ae4f | |
Vitaliy Filippov | 9e6cbc6ebc | |
Vitaliy Filippov | ce777319c3 | |
Vitaliy Filippov | f8ff39b0ab | |
Vitaliy Filippov | d749159585 | |
Vitaliy Filippov | 9703773a63 | |
Vitaliy Filippov | 5d8d486f7c | |
Vitaliy Filippov | 2b546cdd55 | |
Vitaliy Filippov | bd7b177707 | |
Vitaliy Filippov | 33f9d03d22 | |
Vitaliy Filippov | 82e6aff17b | |
Vitaliy Filippov | 57e2c503f7 | |
Vitaliy Filippov | 715bc8d53d | |
Vitaliy Filippov | 0af077701c | |
Vitaliy Filippov | cac976ce25 | |
Vitaliy Filippov | acf0646542 | |
Vitaliy Filippov | ede1c1d667 | |
Vitaliy Filippov | 38bd51c97f | |
Vitaliy Filippov | 8c9f32cd45 | |
Vitaliy Filippov | 966fb763ca | |
Vitaliy Filippov | 0b41ffc08d | |
Vitaliy Filippov | 64eeb79051 | |
Vitaliy Filippov | 2a02f3c4c7 | |
Vitaliy Filippov | f684d9101a | |
Vitaliy Filippov | c72fddd714 | |
Vitaliy Filippov | a1f2f19489 | |
Vitaliy Filippov | 82c1a7ec67 | |
Vitaliy Filippov | 2ab423d4ef | |
Vitaliy Filippov | 4694811eab | |
Vitaliy Filippov | 6b988de17d | |
Vitaliy Filippov | 37efdc2a83 | |
Vitaliy Filippov | 591cad09c9 | |
Vitaliy Filippov | b907ad50aa | |
Vitaliy Filippov | 7308d6a6c0 | |
Vitaliy Filippov | 5f5b6ef150 | |
Vitaliy Filippov | 38a3df4a0e | |
Vitaliy Filippov | 6950b8e3a0 | |
Vitaliy Filippov | 0cea3576fb | |
Vitaliy Filippov | f01eea07d3 | |
Vitaliy Filippov | 2c2f08aca2 | |
Vitaliy Filippov | d6524670e1 | |
Vitaliy Filippov | 879ecfa74d | |
Vitaliy Filippov | aea2d19d35 | |
Vitaliy Filippov | 04f86dc00b | |
Vitaliy Filippov | 7aeb2cbac7 | |
Vitaliy Filippov | 519f081006 | |
Vitaliy Filippov | e50f703e1d | |
Vitaliy Filippov | 2612d3198a | |
Vitaliy Filippov | ab39ce2bbb | |
Vitaliy Filippov | d0c2e31312 | |
Vitaliy Filippov | 9038d42327 | |
Vitaliy Filippov | 691f066055 | |
Vitaliy Filippov | ffe1cd4c79 | |
Vitaliy Filippov | 4ae1b84c67 | |
Vitaliy Filippov | c35963967f | |
Vitaliy Filippov | 0aa2dd2890 | |
Vitaliy Filippov | 6bf88883ac | |
Vitaliy Filippov | 004f265393 | |
Vitaliy Filippov | 860ac24762 | |
Vitaliy Filippov | 6107a4d07b | |
Vitaliy Filippov | 95c29b9dc3 | |
Vitaliy Filippov | d99407dcec | |
Vitaliy Filippov | 6909807068 | |
Vitaliy Filippov | ec90fe6ec1 | |
Vitaliy Filippov | 18c72f4835 | |
Vitaliy Filippov | 59fbcef734 | |
Vitaliy Filippov | 40b7c21fb1 | |
Vitaliy Filippov | efb3678606 | |
Vitaliy Filippov | 462650134e | |
Vitaliy Filippov | 8d87e32175 | |
Vitaliy Filippov | b0b2e7df3c | |
Vitaliy Filippov | 97efb9e299 | |
Vitaliy Filippov | f6d705383a | |
Vitaliy Filippov | 68567c0e1f | |
Vitaliy Filippov | 04b00003e9 | |
Vitaliy Filippov | 307c1731c1 | |
Vitaliy Filippov | 75a6a556b5 | |
Vitaliy Filippov | a48e2bbf18 | |
Vitaliy Filippov | 688821665a | |
Vitaliy Filippov | 3e162d95a0 | |
Vitaliy Filippov | 829381b335 | |
Vitaliy Filippov | 54f2353f24 | |
Vitaliy Filippov | e47f6fba60 | |
Vitaliy Filippov | 883bf84a16 | |
Vitaliy Filippov | 52097c4856 | |
Vitaliy Filippov | e1355cbc74 | |
Vitaliy Filippov | 8f8b90be7a | |
Vitaliy Filippov | ad9f619370 | |
Vitaliy Filippov | f4769ba7c7 | |
Vitaliy Filippov | 843b7052d2 | |
Vitaliy Filippov | df99e232ee | |
Vitaliy Filippov | 3a40fa4127 | |
Vitaliy Filippov | 4095bcc558 | |
Vitaliy Filippov | 564d64e271 | |
Vitaliy Filippov | cf54741c95 | |
Vitaliy Filippov | 18a5fafa2a | |
Vitaliy Filippov | 06f4978085 | |
Vitaliy Filippov | 7ebf1588c5 | |
Vitaliy Filippov | b0ad1e1e6d | |
Vitaliy Filippov | 0949f08407 | |
Vitaliy Filippov | 04a1f18fa5 | |
Vitaliy Filippov | cf9a641d66 | |
Vitaliy Filippov | 05db1308aa | |
Vitaliy Filippov | 98b54ca948 | |
Vitaliy Filippov | 23225c5e62 | |
Vitaliy Filippov | 7e6e1a5a82 | |
Vitaliy Filippov | 435045751d | |
Vitaliy Filippov | c5fb1d5987 | |
Vitaliy Filippov | 9f59381bea | |
Vitaliy Filippov | 9ac7e75178 | |
Vitaliy Filippov | 88671cf745 | |
Vitaliy Filippov | fe1749c427 | |
Vitaliy Filippov | ceb9c28de7 | |
Vitaliy Filippov | 299d7d7c95 | |
Vitaliy Filippov | d1526b415f | |
Vitaliy Filippov | f49fd53d55 | |
Vitaliy Filippov | dd76eda5e5 | |
Vitaliy Filippov | 87dbd8fa57 | |
Vitaliy Filippov | b44f49aab2 | |
Vitaliy Filippov | 036555638e | |
Vitaliy Filippov | af5155fcd9 | |
Vitaliy Filippov | 0d2efbecc9 | |
Vitaliy Filippov | e62e8b6bae | |
Vitaliy Filippov | c4ba24c305 | |
Vitaliy Filippov | 19e47a0279 | |
Vitaliy Filippov | bd178ac20f | |
Vitaliy Filippov | 7006875a24 | |
Vitaliy Filippov | ad577c4aac | |
Vitaliy Filippov | 836635c518 | |
Vitaliy Filippov | 88a03f4e98 | |
Vitaliy Filippov | 2a5036669d | |
Vitaliy Filippov | 2e0c853180 | |
Vitaliy Filippov | e91ff2a9ec | |
Vitaliy Filippov | 086667f568 | |
Vitaliy Filippov | 73ce20e246 | |
Vitaliy Filippov | 1be94da437 | |
Vitaliy Filippov | 80e12358a2 | |
Vitaliy Filippov | 36c935ace6 | |
Vitaliy Filippov | 0d8b5e2ef9 | |
Vitaliy Filippov | 98f1e2c277 | |
Vitaliy Filippov | 21e7686037 | |
Vitaliy Filippov | ab21a1908b | |
Vitaliy Filippov | 30d1ccd43e | |
Vitaliy Filippov | 8bdd6d8d78 | |
Vitaliy Filippov | 09b3e4e789 | |
Vitaliy Filippov | 07912fd670 | |
Vitaliy Filippov | bc742ccf8c | |
Vitaliy Filippov | 314b20437b | |
Vitaliy Filippov | 29bac892ad | |
Vitaliy Filippov | cf7547faf3 | |
Vitaliy Filippov | ab90ed747f | |
Vitaliy Filippov | 29d8ac8b1b | |
Vitaliy Filippov | 97795ea1b1 | |
Vitaliy Filippov | 24e7075f08 | |
Vitaliy Filippov | 6155b23a7e | |
Vitaliy Filippov | 7d49706c07 | |
Vitaliy Filippov | 46e79f3306 | |
Vitaliy Filippov | 41fd14e024 | |
Vitaliy Filippov | bb2d9a3afe | |
Vitaliy Filippov | e899ed2c25 | |
Vitaliy Filippov | e21b14b72c | |
Vitaliy Filippov | 5af8eddaa9 | |
Vitaliy Filippov | 4f5a94c07a | |
Vitaliy Filippov | e16b87ecc8 | |
Vitaliy Filippov | fcb4aa0a11 | |
Vitaliy Filippov | 12adfa470c | |
Vitaliy Filippov | 7f15e0c084 | |
Vitaliy Filippov | 08d4bef419 | |
Vitaliy Filippov | 2d73b19a6c | |
Vitaliy Filippov | 69c87009e9 | |
Vitaliy Filippov | c974cb539c | |
Vitaliy Filippov | 00e98f64f3 | |
Vitaliy Filippov | 91a70dfb1b | |
Vitaliy Filippov | 178388ac8c | |
Vitaliy Filippov | bf9a175efc | |
Vitaliy Filippov | 08aed962de | |
Vitaliy Filippov | 8c65e890b9 | |
Vitaliy Filippov | 8cda70b889 | |
Vitaliy Filippov | 61ab22403a | |
Vitaliy Filippov | 16da663a66 | |
Vitaliy Filippov | 4a2dcf7b6b | |
Vitaliy Filippov | 8d48cc56b0 | |
Vitaliy Filippov | 9f58f01425 | |
Vitaliy Filippov | b9e7d31aa1 | |
Vitaliy Filippov | 2d9f09dcb6 | |
Vitaliy Filippov | 7cc59260c5 | |
Vitaliy Filippov | ca0a11ec85 | |
Vitaliy Filippov | 51c0b5afee | |
Vitaliy Filippov | e1e01d042e | |
Vitaliy Filippov | 534a4a657e | |
Vitaliy Filippov | 9b5d8b9ad4 | |
Vitaliy Filippov | e66ed47515 | |
Vitaliy Filippov | 036c6d4c42 | |
Vitaliy Filippov | 4cb79a3bf8 | |
Vitaliy Filippov | 3bf53754c2 | |
Vitaliy Filippov | 6023cac361 | |
Vitaliy Filippov | 915d04c446 | |
Vitaliy Filippov | 21e06ea40d | |
Vitaliy Filippov | 9ef7f865b0 | |
Vitaliy Filippov | 9dd20a31aa | |
Vitaliy Filippov | 28be049909 | |
Vitaliy Filippov | 78fbaacf1f | |
Vitaliy Filippov | 1526c5a213 | |
Vitaliy Filippov | c7cc414c90 | |
Vitaliy Filippov | f4ea313707 | |
Vitaliy Filippov | b88b76f316 | |
Vitaliy Filippov | 4a17a61d1f | |
Vitaliy Filippov | ccabbbfbcb | |
Vitaliy Filippov | 26dac57083 | |
Vitaliy Filippov | 44a53d8352 | |
Vitaliy Filippov | 9d80bd2d98 | |
Vitaliy Filippov | 322a38a144 | |
Vitaliy Filippov | 1018764c91 | |
Vitaliy Filippov | a45e0e5e67 | |
Vitaliy Filippov | 44656fbf67 | |
Vitaliy Filippov | 089f138e0c | |
Vitaliy Filippov | bcc8e697f9 | |
Vitaliy Filippov | a4c46ba745 | |
Vitaliy Filippov | 5596ad8997 | |
Vitaliy Filippov | 59c29b0cee | |
Vitaliy Filippov | 959089b919 | |
Vitaliy Filippov | d3e7749616 | |
Vitaliy Filippov | b56f8820ec | |
Vitaliy Filippov | 4bd2bd48eb | |
Vitaliy Filippov | a3fc9f8d7d | |
Vitaliy Filippov | 530975aed7 | |
Vitaliy Filippov | 1446aad107 | |
Vitaliy Filippov | 46479e2456 | |
Vitaliy Filippov | e41bee72a5 | |
Vitaliy Filippov | 2e0f223ddb | |
Vitaliy Filippov | 3be7bc29d8 | |
Vitaliy Filippov | 0c43ff9daf | |
Vitaliy Filippov | 64d471cf53 | |
Vitaliy Filippov | 809b2ad8cd | |
Vitaliy Filippov | 550d4af151 | |
Vitaliy Filippov | cf0f23ab8e | |
Vitaliy Filippov | a516fefa8c | |
Vitaliy Filippov | 3b7279b376 | |
Vitaliy Filippov | 824ea507d0 | |
Vitaliy Filippov | 23ea409081 | |
Vitaliy Filippov | 2ccb75974b | |
Vitaliy Filippov | 6561d4e040 | |
Vitaliy Filippov | 1eda7f529d | |
Vitaliy Filippov | 0a174bb313 | |
Vitaliy Filippov | 720985e4c7 | |
Vitaliy Filippov | 4872f617a4 | |
Vitaliy Filippov | e8ac08be14 | |
Vitaliy Filippov | 660c2412fb | |
Vitaliy Filippov | faa5e1436f | |
Vitaliy Filippov | 5fbe36198a | |
Vitaliy Filippov | 99c45bb5ed | |
Vitaliy Filippov | 701eb79422 | |
Vitaliy Filippov | 220bda0667 | |
Vitaliy Filippov | 1e8f0328e0 | |
Vitaliy Filippov | f011e0c675 | |
Vitaliy Filippov | 1a694c387e | |
Vitaliy Filippov | 738ad5af79 | |
Vitaliy Filippov | 9abf3c17c9 | |
Vitaliy Filippov | d2b901aa09 | |
Vitaliy Filippov | befff09370 | |
Vitaliy Filippov | d1645551d4 | |
Vitaliy Filippov | 7cb561f95a | |
Vitaliy Filippov | ae480196e2 | |
Vitaliy Filippov | 398c86f943 | |
Vitaliy Filippov | bec5f921a6 | |
Vitaliy Filippov | 5335c8de8e | |
Vitaliy Filippov | c696a82083 | |
Vitaliy Filippov | 900171586b | |
Vitaliy Filippov | 70612e5df0 | |
Vitaliy Filippov | d952c24979 | |
Vitaliy Filippov | 776fe954a5 | |
Vitaliy Filippov | 9350656af6 | |
Vitaliy Filippov | ece14a7d65 | |
Vitaliy Filippov | be5f314c32 | |
Vitaliy Filippov | 15dba96375 | |
Vitaliy Filippov | 3d05aa9362 | |
Vitaliy Filippov | 94efb54feb | |
Vitaliy Filippov | aa2a0ee00f | |
Vitaliy Filippov | 9f2a948712 | |
Vitaliy Filippov | ba74eece4a | |
Vitaliy Filippov | 2fdd8a1b38 | |
Vitaliy Filippov | 526983f7a9 | |
Vitaliy Filippov | 8e36f04482 | |
Vitaliy Filippov | f460d8c1c8 | |
Vitaliy Filippov | 7619a789c0 | |
Vitaliy Filippov | e65a28e27e | |
Vitaliy Filippov | 6852f299ae | |
Vitaliy Filippov | 1967269c13 | |
Vitaliy Filippov | 7574183ba6 | |
Vitaliy Filippov | 108cd6312d | |
Vitaliy Filippov | 588b9e6393 | |
Vitaliy Filippov | 0471b09b9c | |
Vitaliy Filippov | ef911555ed | |
Vitaliy Filippov | 9d20839a02 | |
Vitaliy Filippov | 67a2e5640c | |
Vitaliy Filippov | 28a0f08ce7 | |
Vitaliy Filippov | 9b4e5b64ae | |
Vitaliy Filippov | 4ca2eeafff | |
Vitaliy Filippov | 79156e0ee1 | |
Vitaliy Filippov | ed26c33f85 | |
Vitaliy Filippov | 18692517be | |
Vitaliy Filippov | de6919b02b | |
Vitaliy Filippov | 8f9f438e25 | |
Vitaliy Filippov | db4b82089e | |
Vitaliy Filippov | faa871090f | |
Vitaliy Filippov | 49ec8c7c63 | |
Vitaliy Filippov | eadd454992 | |
Vitaliy Filippov | a15bd23ebd | |
Vitaliy Filippov | e3f502b466 | |
Vitaliy Filippov | 6e72cf2732 | |
Vitaliy Filippov | 53832d184a | |
Vitaliy Filippov | 352caeba14 | |
Vitaliy Filippov | fb533991b7 | |
Vitaliy Filippov | 73e26dbbea | |
Vitaliy Filippov | 44973e7f27 | |
Vitaliy Filippov | 242d9a42a2 | |
Vitaliy Filippov | 68c3e96e46 | |
Vitaliy Filippov | cc4714a3a7 | |
Vitaliy Filippov | e051db5a73 | |
Vitaliy Filippov | 4f9b5286a0 | |
Vitaliy Filippov | 168cc2c803 | |
Vitaliy Filippov | 4cdad634b5 | |
Vitaliy Filippov | 293cb5bd1d | |
Vitaliy Filippov | 0918ea08fa | |
Vitaliy Filippov | a8b3cbd6af | |
Vitaliy Filippov | fe0d78bf8e | |
Vitaliy Filippov | 085c145a18 | |
Vitaliy Filippov | 30da4bddbe | |
Vitaliy Filippov | 14b4a4617e | |
Vitaliy Filippov | 3932c9b2e2 | |
Vitaliy Filippov | 2e8c69fc5b | |
Vitaliy Filippov | a86788fe3b | |
Vitaliy Filippov | 95ebfad283 | |
Vitaliy Filippov | 6022f28dc9 | |
Vitaliy Filippov | 9d10a4d057 | |
Vitaliy Filippov | ec7acc8f3a | |
Vitaliy Filippov | 416a80b099 | |
Vitaliy Filippov | a7929931eb | |
Vitaliy Filippov | e680d6c1c3 | |
Vitaliy Filippov | 9b33f598d3 | |
Vitaliy Filippov | 592bcd3699 | |
Vitaliy Filippov | 5e1e39633d | |
Vitaliy Filippov | 41c2655edd | |
Vitaliy Filippov | d68370304e | |
Vitaliy Filippov | a22d9f38aa | |
Vitaliy Filippov | 8736b3ad32 | |
Vitaliy Filippov | 62343c8022 | |
Vitaliy Filippov | 9abaf5b735 | |
Vitaliy Filippov | badf68c039 | |
Vitaliy Filippov | 0f6d193d73 | |
Vitaliy Filippov | 27ee14a4e6 | |
Vitaliy Filippov | 64afec03ec | |
Vitaliy Filippov | 4dde8b8a42 | |
Vitaliy Filippov | f5ccb154af | |
Vitaliy Filippov | 73c80e2c39 | |
Vitaliy Filippov | 437dc5b630 | |
Vitaliy Filippov | 226f5a2945 | |
Vitaliy Filippov | 2187d06eac | |
Vitaliy Filippov | c573bc6bb3 | |
Vitaliy Filippov | 2f6cf605a1 | |
Vitaliy Filippov | 05ea97119f | |
Vitaliy Filippov | 571be0f380 | |
Vitaliy Filippov | 985c309d7f | |
Vitaliy Filippov | a56f8cd14e | |
Vitaliy Filippov | 46e111272f | |
Vitaliy Filippov | 165c204555 | |
Vitaliy Filippov | af5cd45071 | |
Vitaliy Filippov | c3fe9ad0d1 | |
Vitaliy Filippov | 0fcdeae18b | |
Vitaliy Filippov | e6a4b634f8 | |
Vitaliy Filippov | c22e096943 | |
Vitaliy Filippov | 45b1c2fbf1 | |
Vitaliy Filippov | 3469bead67 | |
Vitaliy Filippov | 3a5d488f19 | |
Vitaliy Filippov | 73e4e30b1f | |
Vitaliy Filippov | 5feff1ffb9 | |
Vitaliy Filippov | b466e215f0 | |
Vitaliy Filippov | 36f995367f | |
Vitaliy Filippov | 0aca6e9ca8 | |
Vitaliy Filippov | fa98be6bc0 | |
Vitaliy Filippov | 256a7f2667 | |
Vitaliy Filippov | 79bf57b6e2 | |
Vitaliy Filippov | 53f6aba3e6 | |
Vitaliy Filippov | 36595eb669 | |
Vitaliy Filippov | e09d0e0678 | |
Vitaliy Filippov | d1602b50b3 | |
Vitaliy Filippov | 7df384031a | |
Vitaliy Filippov | e614a98543 | |
Vitaliy Filippov | 01dd3ef89e | |
Vitaliy Filippov | cdccc23aff | |
Vitaliy Filippov | 700428829a | |
Vitaliy Filippov | 6488d0044a | |
Vitaliy Filippov | 393fe75900 | |
Vitaliy Filippov | f036eecf1c | |
Vitaliy Filippov | e56909fb45 | |
Vitaliy Filippov | fac75b0b57 | |
Vitaliy Filippov | 9f842ec9a5 | |
Vitaliy Filippov | f6a01a4819 | |
Vitaliy Filippov | 6202260018 | |
Vitaliy Filippov | a61ede9951 | |
Vitaliy Filippov | f57731f8ca | |
Vitaliy Filippov | 19f25c7cd5 | |
Vitaliy Filippov | 2c3e84cc41 | |
Vitaliy Filippov | 7bda66b866 | |
Vitaliy Filippov | b467d0559f | |
Vitaliy Filippov | c2c2eefea4 | |
Vitaliy Filippov | 5084ff7c6c | |
Vitaliy Filippov | 47b6f64106 | |
Vitaliy Filippov | f71d0c117b | |
Vitaliy Filippov | 2b854948f9 | |
Vitaliy Filippov | e7f897ed65 | |
Vitaliy Filippov | c26b6e1fc3 | |
Vitaliy Filippov | aaa054e644 | |
Vitaliy Filippov | 706a44d4d4 | |
Vitaliy Filippov | 842f88f94f | |
Vitaliy Filippov | e8149e5848 | |
Vitaliy Filippov | 6355b968f4 | |
Vitaliy Filippov | 00cf24fbd7 | |
Vitaliy Filippov | 1bc08174f9 | |
Vitaliy Filippov | cd87333091 | |
Vitaliy Filippov | bd0fe6e4cc | |
Vitaliy Filippov | ce78454215 | |
Vitaliy Filippov | 762bd42096 | |
Vitaliy Filippov | 7b57eeeeb3 | |
Vitaliy Filippov | ec4a52af48 | |
Vitaliy Filippov | 268b497c0b | |
Vitaliy Filippov | 35481925b1 | |
Vitaliy Filippov | 895a80dfc4 | |
Vitaliy Filippov | caa01c6aaf | |
Vitaliy Filippov | d398ddfd3b | |
Vitaliy Filippov | 0f2b8dbf6f | |
Vitaliy Filippov | 4f42e9659e | |
Vitaliy Filippov | 7cf71a8031 | |
Vitaliy Filippov | 9d22559bcf | |
Vitaliy Filippov | 8c03e3ebab | |
Vitaliy Filippov | 2a640ba2e8 | |
Vitaliy Filippov | 6a21ea207e | |
Vitaliy Filippov | 642802b595 | |
Vitaliy Filippov | ff38b464a5 | |
Vitaliy Filippov | 663153713b | |
Vitaliy Filippov | dc57c5c362 | |
Vitaliy Filippov | f95299b769 | |
Vitaliy Filippov | 9126ffb0f9 | |
Vitaliy Filippov | 2a8e40835e | |
Vitaliy Filippov | 309486d746 | |
Vitaliy Filippov | 582f485578 | |
Vitaliy Filippov | 089b4eb208 | |
Vitaliy Filippov | d78ce509c6 | |
Vitaliy Filippov | f3a7ccff50 | |
Vitaliy Filippov | 37b27c3025 | |
Vitaliy Filippov | edf6d6f897 | |
Vitaliy Filippov | d11e8dcb5e | |
Vitaliy Filippov | dd02bc1c44 | |
Vitaliy Filippov | 298b013eae | |
Vitaliy Filippov | 0880a77c1a | |
Vitaliy Filippov | aa849ea07b | |
Vitaliy Filippov | d59be0e8b4 | |
Vitaliy Filippov | cf7de0f181 | |
Vitaliy Filippov | 6212195440 | |
Vitaliy Filippov | dfb6e15eaa | |
Vitaliy Filippov | afe2e76c87 | |
Vitaliy Filippov | 0f43f6d3f6 | |
Vitaliy Filippov | 92c800bb64 | |
Vitaliy Filippov | 8a8b619875 | |
Vitaliy Filippov | 43fe1d88e7 | |
Vitaliy Filippov | 1b30120918 | |
Vitaliy Filippov | c0a22d825d | |
Vitaliy Filippov | 7acfc95f75 | |
Vitaliy Filippov | 250f22c0b6 | |
Vitaliy Filippov | dbd8418798 | |
Vitaliy Filippov | 036f4c5bf3 | |
Vitaliy Filippov | fd8e1a8418 | |
Vitaliy Filippov | a08e0bfacd | |
Vitaliy Filippov | ddc3e927d3 | |
Vitaliy Filippov | 2aa605f2bb | |
Vitaliy Filippov | 18915b264a | |
Vitaliy Filippov | 60f795e7eb | |
Vitaliy Filippov | 3a4279adbf | |
Vitaliy Filippov | 1ec9794376 | |
Vitaliy Filippov | d8164e9d84 | |
Vitaliy Filippov | 21d0b06959 | |
Vitaliy Filippov | 46f9bd2a69 | |
Vitaliy Filippov | 6982fe1255 | |
Vitaliy Filippov | eba053febe | |
Vitaliy Filippov | 899946ff96 | |
Vitaliy Filippov | 3dd1b22d55 | |
Vitaliy Filippov | 31f9445030 | |
Vitaliy Filippov | 3f522c66e6 | |
Vitaliy Filippov | c3737ae3ff | |
Vitaliy Filippov | c863543bfe | |
Vitaliy Filippov | 1696446545 | |
Vitaliy Filippov | 41dddddbf2 | |
Vitaliy Filippov | 2d4e24c9ce | |
Vitaliy Filippov | 844cacd357 | |
Vitaliy Filippov | e19d9fde5f | |
Vitaliy Filippov | 9cb07d844b | |
Vitaliy Filippov | 1e21555343 | |
Vitaliy Filippov | 94cdbcd085 | |
Vitaliy Filippov | 8315407558 | |
Vitaliy Filippov | b27ad550cf | |
Vitaliy Filippov | 8e63995306 | |
Vitaliy Filippov | c9f3654905 | |
Vitaliy Filippov | 2a5ca4ff6f | |
Vitaliy Filippov | 2575431176 | |
Vitaliy Filippov | 20125db181 | |
Vitaliy Filippov | 7eac7b6d55 | |
Vitaliy Filippov | 79839ec31d | |
Vitaliy Filippov | 9d96e4bf0b |
|
@ -0,0 +1,19 @@
|
||||||
|
.git
|
||||||
|
build
|
||||||
|
packages
|
||||||
|
mon/node_modules
|
||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
osd
|
||||||
|
stub_osd
|
||||||
|
stub_uring_osd
|
||||||
|
stub_bench
|
||||||
|
osd_test
|
||||||
|
dump_journal
|
||||||
|
nbd_proxy
|
||||||
|
rm_inode
|
||||||
|
fio
|
||||||
|
qemu
|
||||||
|
rpm/*.Dockerfile
|
||||||
|
debian/*.Dockerfile
|
||||||
|
Dockerfile
|
|
@ -0,0 +1,18 @@
|
||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
package-lock.json
|
||||||
|
fio
|
||||||
|
qemu
|
||||||
|
osd
|
||||||
|
stub_osd
|
||||||
|
stub_uring_osd
|
||||||
|
stub_bench
|
||||||
|
osd_test
|
||||||
|
osd_peering_pg_test
|
||||||
|
dump_journal
|
||||||
|
nbd_proxy
|
||||||
|
rm_inode
|
||||||
|
test_allocator
|
||||||
|
test_blockstore
|
||||||
|
test_shit
|
||||||
|
osd_rmw_test
|
|
@ -0,0 +1,6 @@
|
||||||
|
[submodule "cpp-btree"]
|
||||||
|
path = cpp-btree
|
||||||
|
url = ../cpp-btree.git
|
||||||
|
[submodule "json11"]
|
||||||
|
path = json11
|
||||||
|
url = ../json11.git
|
|
@ -0,0 +1,7 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
project(vitastor)
|
||||||
|
|
||||||
|
set(VERSION "0.6.10")
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
|
@ -0,0 +1,339 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
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, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) Vitaliy Filippov (vitalif [at] yourcmc.ru), 2019+
|
||||||
|
|
||||||
|
All server-side code (OSD, Monitor and so on) is licensed under the terms of
|
||||||
|
Vitastor Network Public License 1.1 (VNPL 1.1), a copyleft license based on
|
||||||
|
GNU GPLv3.0 with the additional "Network Interaction" clause which requires
|
||||||
|
opensourcing all programs directly or indirectly interacting with Vitastor
|
||||||
|
through a computer network and expressly designed to be used in conjunction
|
||||||
|
with it ("Proxy Programs"). Proxy Programs may be made public not only under
|
||||||
|
the terms of the same license, but also under the terms of any GPL-Compatible
|
||||||
|
Free Software License, as listed by the Free Software Foundation.
|
||||||
|
This is a stricter copyleft license than the Affero GPL.
|
||||||
|
|
||||||
|
Please note that VNPL doesn't require you to open the code of proprietary
|
||||||
|
software running inside a VM if it's not specially designed to be used with
|
||||||
|
Vitastor.
|
||||||
|
|
||||||
|
Basically, you can't use the software in a proprietary environment to provide
|
||||||
|
its functionality to users without opensourcing all intermediary components
|
||||||
|
standing between the user and Vitastor or purchasing a commercial license
|
||||||
|
from the author 😀.
|
||||||
|
|
||||||
|
Client libraries (cluster_client and so on) are dual-licensed under the same
|
||||||
|
VNPL 1.1 and also GNU GPL 2.0 or later to allow for compatibility with GPLed
|
||||||
|
software like QEMU and fio.
|
||||||
|
|
||||||
|
You can find the full text of VNPL-1.1 in the file [VNPL-1.1.txt](VNPL-1.1.txt).
|
||||||
|
GPL 2.0 is also included in this repository as [GPL-2.0.txt](GPL-2.0.txt).
|
64
Makefile
64
Makefile
|
@ -1,64 +0,0 @@
|
||||||
BLOCKSTORE_OBJS := allocator.o blockstore.o blockstore_impl.o blockstore_init.o blockstore_open.o blockstore_journal.o blockstore_read.o \
|
|
||||||
blockstore_write.o blockstore_sync.o blockstore_stable.o blockstore_rollback.o blockstore_flush.o crc32c.o ringloop.o timerfd_interval.o
|
|
||||||
# -fsanitize=address
|
|
||||||
CXXFLAGS := -g -O3 -Wall -Wno-sign-compare -Wno-comment -Wno-parentheses -Wno-pointer-arith -fPIC -fdiagnostics-color=always
|
|
||||||
all: $(BLOCKSTORE_OBJS) libfio_blockstore.so osd libfio_sec_osd.so test_blockstore stub_osd osd_test
|
|
||||||
clean:
|
|
||||||
rm -f *.o
|
|
||||||
|
|
||||||
crc32c.o: crc32c.c
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
json11.o: json11/json11.cpp
|
|
||||||
g++ $(CXXFLAGS) -c -o json11.o json11/json11.cpp
|
|
||||||
allocator.o: allocator.cpp allocator.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
ringloop.o: ringloop.cpp ringloop.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
timerfd_interval.o: timerfd_interval.cpp timerfd_interval.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
%.o: %.cpp allocator.h blockstore_flush.h blockstore.h blockstore_impl.h blockstore_init.h blockstore_journal.h crc32c.h ringloop.h timerfd_interval.h object_id.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
libblockstore.so: $(BLOCKSTORE_OBJS)
|
|
||||||
g++ $(CXXFLAGS) -o libblockstore.so -shared $(BLOCKSTORE_OBJS) -ltcmalloc_minimal -luring
|
|
||||||
libfio_blockstore.so: ./libblockstore.so fio_engine.cpp json11.o
|
|
||||||
g++ $(CXXFLAGS) -shared -o libfio_blockstore.so fio_engine.cpp json11.o ./libblockstore.so -ltcmalloc_minimal -luring
|
|
||||||
|
|
||||||
OSD_OBJS := osd.o osd_secondary.o osd_receive.o osd_send.o osd_peering.o osd_peering_pg.o osd_primary.o osd_rmw.o json11.o timerfd_interval.o
|
|
||||||
osd_secondary.o: osd_secondary.cpp osd.h osd_ops.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
osd_receive.o: osd_receive.cpp osd.h osd_ops.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
osd_send.o: osd_send.cpp osd.h osd_ops.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
osd_peering.o: osd_peering.cpp osd.h osd_ops.h osd_peering_pg.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
osd_peering_pg.o: osd_peering_pg.cpp object_id.h osd_peering_pg.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
osd_rmw.o: osd_rmw.cpp osd_rmw.h xor.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
osd_rmw_test: osd_rmw_test.cpp osd_rmw.cpp osd_rmw.h xor.h
|
|
||||||
g++ $(CXXFLAGS) -o $@ $<
|
|
||||||
osd_primary.o: osd_primary.cpp osd.h osd_ops.h osd_peering_pg.h xor.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
osd.o: osd.cpp osd.h osd_ops.h osd_peering_pg.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
osd: ./libblockstore.so osd_main.cpp osd.h osd_ops.h $(OSD_OBJS)
|
|
||||||
g++ $(CXXFLAGS) -o osd osd_main.cpp $(OSD_OBJS) ./libblockstore.so -ltcmalloc_minimal -luring
|
|
||||||
stub_osd: stub_osd.cpp osd_ops.h rw_blocking.o
|
|
||||||
g++ $(CXXFLAGS) -o stub_osd stub_osd.cpp rw_blocking.o -ltcmalloc_minimal
|
|
||||||
rw_blocking.o: rw_blocking.cpp rw_blocking.h
|
|
||||||
g++ $(CXXFLAGS) -c -o $@ $<
|
|
||||||
osd_test: osd_test.cpp osd_ops.h rw_blocking.o
|
|
||||||
g++ $(CXXFLAGS) -o osd_test osd_test.cpp rw_blocking.o -ltcmalloc_minimal
|
|
||||||
|
|
||||||
libfio_sec_osd.so: fio_sec_osd.cpp osd_ops.h rw_blocking.o
|
|
||||||
g++ $(CXXFLAGS) -ltcmalloc_minimal -shared -o libfio_sec_osd.so fio_sec_osd.cpp rw_blocking.o -luring
|
|
||||||
|
|
||||||
test_blockstore: ./libblockstore.so test_blockstore.cpp
|
|
||||||
g++ $(CXXFLAGS) -o test_blockstore test_blockstore.cpp ./libblockstore.so -ltcmalloc_minimal -luring
|
|
||||||
test: test.cpp osd_peering_pg.o
|
|
||||||
g++ $(CXXFLAGS) -o test test.cpp osd_peering_pg.o -luring
|
|
||||||
test_allocator: test_allocator.cpp allocator.o
|
|
||||||
g++ $(CXXFLAGS) -o test_allocator test_allocator.cpp allocator.o
|
|
|
@ -0,0 +1,660 @@
|
||||||
|
## Vitastor
|
||||||
|
|
||||||
|
[Read English version](README.md)
|
||||||
|
|
||||||
|
## Идея
|
||||||
|
|
||||||
|
Я всего лишь хочу сделать качественную блочную SDS!
|
||||||
|
|
||||||
|
Vitastor - распределённая блочная SDS, прямой аналог Ceph RBD и внутренних СХД популярных
|
||||||
|
облачных провайдеров. Однако, в отличие от них, Vitastor быстрый и при этом простой.
|
||||||
|
Только пока маленький :-).
|
||||||
|
|
||||||
|
Архитектурная схожесть с Ceph означает заложенную на уровне алгоритмов записи строгую консистентность,
|
||||||
|
репликацию через первичный OSD, симметричную кластеризацию без единой точки отказа
|
||||||
|
и автоматическое распределение данных по любому числу дисков любого размера с настраиваемыми схемами
|
||||||
|
избыточности - репликацией или с произвольными кодами коррекции ошибок.
|
||||||
|
|
||||||
|
## Возможности
|
||||||
|
|
||||||
|
Vitastor на данный момент находится в статусе предварительного выпуска, расширенные
|
||||||
|
возможности пока отсутствуют, а в будущих версиях вероятны "ломающие" изменения.
|
||||||
|
|
||||||
|
Однако следующее уже реализовано:
|
||||||
|
|
||||||
|
- Базовая часть - надёжное кластерное блочное хранилище без единой точки отказа
|
||||||
|
- Производительность ;-D
|
||||||
|
- Несколько схем отказоустойчивости: репликация, XOR n+1 (1 диск чётности), коды коррекции ошибок
|
||||||
|
Рида-Соломона на основе библиотеки jerasure с любым числом дисков данных и чётности в группе
|
||||||
|
- Конфигурация через простые человекочитаемые JSON-структуры в etcd
|
||||||
|
- Автоматическое распределение данных по OSD, с поддержкой:
|
||||||
|
- Математической оптимизации для лучшей равномерности распределения и минимизации перемещений данных
|
||||||
|
- Нескольких пулов с разными схемами избыточности
|
||||||
|
- Дерева распределения, выбора OSD по тегам / классам устройств (только SSD, только HDD) и по поддереву
|
||||||
|
- Настраиваемых доменов отказа (диск/сервер/стойка и т.п.)
|
||||||
|
- Восстановление деградированных блоков
|
||||||
|
- Ребаланс, то есть перемещение данных между OSD (дисками)
|
||||||
|
- Поддержка "ленивого" fsync (fsync не на каждую операцию)
|
||||||
|
- Сбор статистики ввода/вывода в etcd
|
||||||
|
- Клиентская библиотека режима пользователя для ввода/вывода
|
||||||
|
- Драйвер диска для QEMU (собирается вне дерева исходников QEMU)
|
||||||
|
- Драйвер диска для утилиты тестирования производительности fio (также собирается вне дерева исходников fio)
|
||||||
|
- NBD-прокси для монтирования образов ядром ("блочное устройство в режиме пользователя")
|
||||||
|
- Утилита для удаления образов/инодов (vitastor-cli rm-data)
|
||||||
|
- Пакеты для Debian и CentOS
|
||||||
|
- Статистика операций ввода/вывода и занятого места в разрезе инодов
|
||||||
|
- Именование инодов через хранение их метаданных в etcd
|
||||||
|
- Снапшоты и copy-on-write клоны
|
||||||
|
- Сглаживание производительности случайной записи в SSD+HDD конфигурациях
|
||||||
|
- Поддержка RDMA/RoCEv2 через libibverbs
|
||||||
|
- CSI-плагин для Kubernetes
|
||||||
|
- Базовая поддержка OpenStack: драйвер Cinder, патчи для Nova и libvirt
|
||||||
|
- Слияние снапшотов (vitastor-cli {snap-rm,flatten,merge})
|
||||||
|
- Консольный интерфейс для управления образами (vitastor-cli {ls,create,modify})
|
||||||
|
- Плагин для Proxmox
|
||||||
|
|
||||||
|
## Планы развития
|
||||||
|
|
||||||
|
- Поддержка удаления снапшотов (слияния слоёв)
|
||||||
|
- Более корректные скрипты разметки дисков и автоматического запуска OSD
|
||||||
|
- Другие инструменты администрирования
|
||||||
|
- Плагины для OpenNebula и других облачных систем
|
||||||
|
- iSCSI-прокси
|
||||||
|
- Более быстрое переключение при отказах
|
||||||
|
- Фоновая проверка целостности без контрольных сумм (сверка реплик)
|
||||||
|
- Контрольные суммы
|
||||||
|
- Поддержка SSD-кэширования (tiered storage)
|
||||||
|
- Поддержка NVDIMM
|
||||||
|
- Web-интерфейс
|
||||||
|
- Возможно, сжатие
|
||||||
|
- Возможно, поддержка кэширования данных через системный page cache
|
||||||
|
|
||||||
|
## Архитектура
|
||||||
|
|
||||||
|
Так же, как и в Ceph, в Vitastor:
|
||||||
|
|
||||||
|
- Есть пулы (pools), PG, OSD, мониторы, домены отказа, дерево распределения (аналог crush-дерева).
|
||||||
|
- Образы делятся на блоки фиксированного размера (объекты), и эти объекты распределяются по OSD.
|
||||||
|
- У OSD есть журнал и метаданные и они тоже могут размещаться на отдельных быстрых дисках.
|
||||||
|
- Все операции записи тоже транзакционны. В Vitastor, правда, есть режим отложенного/ленивого fsync
|
||||||
|
(коммита), в котором fsync не вызывается на каждую операцию записи, что делает его более
|
||||||
|
пригодным для использования на "плохих" (десктопных) SSD. Однако все операции записи
|
||||||
|
в любом случае атомарны.
|
||||||
|
- Клиентская библиотека тоже старается ждать восстановления после любого отказа кластера, то есть,
|
||||||
|
вы тоже можете перезагрузить хоть весь кластер разом, и клиенты только на время зависнут,
|
||||||
|
но не отключатся.
|
||||||
|
|
||||||
|
Некоторые базовые термины для тех, кто не знаком с Ceph:
|
||||||
|
|
||||||
|
- OSD (Object Storage Daemon) - процесс, который хранит данные на одном диске и обрабатывает
|
||||||
|
запросы чтения/записи от клиентов.
|
||||||
|
- Пул (Pool) - контейнер для данных, имеющих одну и ту же схему избыточности и правила распределения по OSD.
|
||||||
|
- PG (Placement Group) - группа объектов, хранимых на одном и том же наборе реплик (OSD).
|
||||||
|
Несколько PG могут храниться на одном и том же наборе реплик, но объекты одной PG
|
||||||
|
в норме не хранятся на разных наборах OSD.
|
||||||
|
- Монитор - демон, хранящий состояние кластера.
|
||||||
|
- Домен отказа (Failure Domain) - группа OSD, которым вы разрешаете "упасть" всем вместе.
|
||||||
|
Иными словами, это группа OSD, в которые СХД не помещает разные копии одного и того же
|
||||||
|
блока данных. Например, если домен отказа - сервер, то на двух дисках одного сервера
|
||||||
|
никогда не окажется 2 и более копий одного и того же блока данных, а значит, даже
|
||||||
|
если в этом сервере откажут все диски, это будет равносильно потере только 1 копии
|
||||||
|
любого блока данных.
|
||||||
|
- Дерево распределения (Placement Tree / CRUSH Tree) - иерархическая группировка OSD
|
||||||
|
в узлы, которые далее можно использовать как домены отказа. То есть, диск (OSD) входит в
|
||||||
|
сервер, сервер входит в стойку, стойка входит в ряд, ряд в датацентр и т.п.
|
||||||
|
|
||||||
|
Чем Vitastor отличается от Ceph:
|
||||||
|
|
||||||
|
- Vitastor в первую очередь сфокусирован на SSD. Также Vitastor, вероятно, должен неплохо работать
|
||||||
|
с комбинацией SSD и HDD через bcache, а в будущем, возможно, будут добавлены и нативные способы
|
||||||
|
оптимизации под SSD+HDD. Однако хранилище на основе одних лишь жёстких дисков, вообще без SSD,
|
||||||
|
не в приоритете, поэтому оптимизации под этот кейс могут вообще не состояться.
|
||||||
|
- OSD Vitastor однопоточный и всегда таким останется, так как это самый оптимальный способ работы.
|
||||||
|
Если вам не хватает 1 ядра на 1 диск, просто делите диск на разделы и запускайте на нём несколько OSD.
|
||||||
|
Но, скорее всего, вам хватит и 1 ядра - Vitastor не так прожорлив к ресурсам CPU, как Ceph.
|
||||||
|
- Журнал и метаданные всегда размещаются в памяти, благодаря чему никогда не тратится лишнее время
|
||||||
|
на чтение метаданных с диска. Размер метаданных линейно зависит от размера диска и блока данных,
|
||||||
|
который задаётся в конфигурации кластера и по умолчанию составляет 128 КБ. С блоком 128 КБ метаданные
|
||||||
|
занимают примерно 512 МБ памяти на 1 ТБ дискового пространства (и это всё равно меньше, чем нужно Ceph-у).
|
||||||
|
Журнал вообще не должен быть большим, например, тесты производительности в данном документе проводились
|
||||||
|
с журналом размером всего 16 МБ. Большой журнал, вероятно, даже вреден, т.к. "грязные" записи (записи,
|
||||||
|
не сброшенные из журнала) тоже занимают память и могут немного замедлять работу.
|
||||||
|
- В Vitastor нет внутреннего copy-on-write. Я считаю, что реализация CoW-хранилища гораздо сложнее,
|
||||||
|
поэтому сложнее добиться устойчиво хороших результатов. Возможно, в один прекрасный день
|
||||||
|
я придумаю красивый алгоритм для CoW-хранилища, но пока нет - внутреннего CoW в Vitastor не будет.
|
||||||
|
Всё это не относится к "внешнему" CoW (снапшотам и клонам).
|
||||||
|
- Базовый слой Vitastor - простое блочное хранилище с блоками фиксированного размера, а не сложное
|
||||||
|
объектное хранилище с расширенными возможностями, как в Ceph (RADOS).
|
||||||
|
- В Vitastor есть режим "ленивых fsync", в котором OSD группирует запросы записи перед сбросом их
|
||||||
|
на диск, что позволяет получить лучшую производительность с дешёвыми настольными SSD без конденсаторов
|
||||||
|
("Advanced Power Loss Protection" / "Capacitor-Based Power Loss Protection").
|
||||||
|
Тем не менее, такой режим всё равно медленнее использования нормальных серверных SSD и мгновенного
|
||||||
|
fsync, так как приводит к дополнительным операциям передачи данных по сети, поэтому рекомендуется
|
||||||
|
всё-таки использовать хорошие серверные диски, тем более, стоят они почти так же, как десктопные.
|
||||||
|
- PG эфемерны. Это означает, что они не хранятся на дисках и существуют только в памяти работающих OSD.
|
||||||
|
- Процессы восстановления оперируют отдельными объектами, а не целыми PG.
|
||||||
|
- PGLOG-ов нет.
|
||||||
|
- "Мониторы" не хранят данные. Конфигурация и состояние кластера хранятся в etcd в простых человекочитаемых
|
||||||
|
JSON-структурах. Мониторы Vitastor только следят за состоянием кластера и управляют перемещением данных.
|
||||||
|
В этом смысле монитор Vitastor не является критичным компонентом системы и больше похож на Ceph-овский
|
||||||
|
менеджер (MGR). Монитор Vitastor написан на node.js.
|
||||||
|
- Распределение PG не основано на консистентных хешах. Вместо этого все маппинги PG хранятся прямо в etcd
|
||||||
|
(ибо нет никакой проблемы сохранить несколько сотен-тысяч записей в памяти, а не считать каждый раз хеши).
|
||||||
|
Перераспределение PG по OSD выполняется через математическую оптимизацию,
|
||||||
|
а конкретно, сведение задачи к ЛП (задаче линейного программирования) и решение оной с помощью утилиты
|
||||||
|
lp_solve. Такой подход позволяет обычно выравнивать распределение места почти идеально - равномерность
|
||||||
|
обычно составляет 96-99%, в отличие от Ceph, где на голом CRUSH-е без балансировщика обычно выходит 80-90%.
|
||||||
|
Также это позволяет минимизировать объём перемещения данных и случайность связей между OSD, а также менять
|
||||||
|
распределение вручную, не боясь сломать логику перебалансировки. В таком подходе есть и потенциальный
|
||||||
|
недостаток - есть предположение, что в очень большом кластере он может сломаться - однако вплоть до
|
||||||
|
нескольких сотен OSD подход точно работает нормально. Ну и, собственно, при необходимости легко
|
||||||
|
реализовать и консистентные хеши.
|
||||||
|
- Отдельный слой, подобный слою "CRUSH-правил", отсутствует. Вы настраиваете схемы отказоустойчивости,
|
||||||
|
домены отказа и правила выбора OSD напрямую в конфигурации пулов.
|
||||||
|
|
||||||
|
## Понимание сути производительности систем хранения
|
||||||
|
|
||||||
|
Вкратце: для быстрой хранилки задержки важнее, чем пиковые iops-ы.
|
||||||
|
|
||||||
|
Лучшая возможная задержка достигается при тестировании в 1 поток с глубиной очереди 1,
|
||||||
|
что приблизительно означает минимально нагруженное состояние кластера. В данном случае
|
||||||
|
IOPS = 1/задержка. Ни числом серверов, ни дисков, ни серверных процессов/потоков
|
||||||
|
задержка не масштабируется... Она зависит только от того, насколько быстро один
|
||||||
|
серверный процесс (и клиент) обрабатывают одну операцию.
|
||||||
|
|
||||||
|
Почему задержки важны? Потому, что некоторые приложения *не могут* использовать глубину
|
||||||
|
очереди больше 1, ибо их задача не параллелизуется. Важный пример - это все СУБД
|
||||||
|
с поддержкой консистентности (ACID), потому что все они обеспечивают её через
|
||||||
|
журналирование, а журналы пишутся последовательно и с fsync() после каждой операции.
|
||||||
|
|
||||||
|
fsync, кстати - это ещё одна очень важная вещь, про которую почти всегда забывают в тестах.
|
||||||
|
Смысл в том, что все современные диски имеют кэши/буферы записи и не гарантируют, что
|
||||||
|
данные реально физически записываются на носитель до того, как вы делаете fsync(),
|
||||||
|
который транслируется в команду сброса кэша операционной системой.
|
||||||
|
|
||||||
|
Дешёвые SSD для настольных ПК и ноутбуков очень быстрые без fsync - NVMe диски, например,
|
||||||
|
могут обработать порядка 80000 операций записи в секунду с глубиной очереди 1 без fsync.
|
||||||
|
Однако с fsync, когда они реально вынуждены писать каждый блок данных во флеш-память,
|
||||||
|
они выжимают лишь 1000-2000 операций записи в секунду (число практически постоянное
|
||||||
|
для всех моделей SSD).
|
||||||
|
|
||||||
|
Серверные SSD часто имеют суперконденсаторы, работающие как встроенный источник
|
||||||
|
бесперебойного питания и дающие дискам успеть сбросить их DRAM-кэш в постоянную
|
||||||
|
флеш-память при отключении питания. Благодаря этому диски с чистой совестью
|
||||||
|
*игнорируют fsync*, так как точно знают, что данные из кэша доедут до постоянной
|
||||||
|
памяти.
|
||||||
|
|
||||||
|
Все наиболее известные программные СХД, например, Ceph и внутренние СХД, используемые
|
||||||
|
такими облачными провайдерами, как Amazon, Google, Яндекс, медленные в смысле задержки.
|
||||||
|
В лучшем случае они дают задержки от 0.3мс на чтение и 0.6мс на запись 4 КБ блоками
|
||||||
|
даже при условии использования наилучшего возможного железа.
|
||||||
|
|
||||||
|
И это в эпоху SSD, когда вы можете пойти на рынок и купить там SSD, задержка которого
|
||||||
|
на чтение будет 0.1мс, а на запись - 0.04мс, за 100$ или даже дешевле.
|
||||||
|
|
||||||
|
Когда мне нужно быстро протестировать производительность дисковой подсистемы, я
|
||||||
|
использую следующие 6 команд, с небольшими вариациями:
|
||||||
|
|
||||||
|
- Линейная запись:
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4M -iodepth=32 -rw=write -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Линейное чтение:
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4M -iodepth=32 -rw=read -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Запись в 1 поток (T1Q1):
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4k -iodepth=1 -fsync=1 -rw=randwrite -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Чтение в 1 поток (T1Q1):
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4k -iodepth=1 -rw=randread -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Параллельная запись (numjobs используется, когда 1 ядро CPU не может насытить диск):
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4k -iodepth=128 [-numjobs=4 -group_reporting] -rw=randwrite -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Параллельное чтение (numjobs - аналогично):
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4k -iodepth=128 [-numjobs=4 -group_reporting] -rw=randread -runtime=60 -filename=/dev/sdX`
|
||||||
|
|
||||||
|
## Теоретическая максимальная производительность Vitastor
|
||||||
|
|
||||||
|
При использовании репликации:
|
||||||
|
- Задержка чтения в 1 поток (T1Q1): 1 сетевой RTT + 1 чтение с диска.
|
||||||
|
- Запись+fsync в 1 поток:
|
||||||
|
- С мгновенным сбросом: 2 RTT + 1 запись.
|
||||||
|
- С отложенным ("ленивым") сбросом: 4 RTT + 1 запись + 1 fsync.
|
||||||
|
- Параллельное чтение: сумма IOPS всех дисков либо производительность сети, если в сеть упрётся раньше.
|
||||||
|
- Параллельная запись: сумма IOPS всех дисков / число реплик / WA либо производительность сети, если в сеть упрётся раньше.
|
||||||
|
|
||||||
|
При использовании кодов коррекции ошибок (EC):
|
||||||
|
- Задержка чтения в 1 поток (T1Q1): 1.5 RTT + 1 чтение.
|
||||||
|
- Запись+fsync в 1 поток:
|
||||||
|
- С мгновенным сбросом: 3.5 RTT + 1 чтение + 2 записи.
|
||||||
|
- С отложенным ("ленивым") сбросом: 5.5 RTT + 1 чтение + 2 записи + 2 fsync.
|
||||||
|
- Под 0.5 на самом деле подразумевается (k-1)/k, где k - число дисков данных,
|
||||||
|
что означает, что дополнительное обращение по сети не нужно, когда операция
|
||||||
|
чтения обслуживается локально.
|
||||||
|
- Параллельное чтение: сумма IOPS всех дисков либо производительность сети, если в сеть упрётся раньше.
|
||||||
|
- Параллельная запись: сумма IOPS всех дисков / общее число дисков данных и чётности / WA либо производительность сети, если в сеть упрётся раньше.
|
||||||
|
Примечание: IOPS дисков в данном случае надо брать в смешанном режиме чтения/записи в пропорции, аналогичной формулам выше.
|
||||||
|
|
||||||
|
WA (мультипликатор записи) для 4 КБ блоков в Vitastor обычно составляет 3-5:
|
||||||
|
1. Запись метаданных в журнал
|
||||||
|
2. Запись блока данных в журнал
|
||||||
|
3. Запись метаданных в БД
|
||||||
|
4. Ещё одна запись метаданных в журнал при использовании EC
|
||||||
|
5. Запись блока данных на диск данных
|
||||||
|
|
||||||
|
Если вы найдёте SSD, хорошо работающий с 512-байтными блоками данных (Optane?),
|
||||||
|
то 1, 3 и 4 можно снизить до 512 байт (1/8 от размера данных) и получить WA всего 2.375.
|
||||||
|
|
||||||
|
Кроме того, WA снижается при использовании отложенного/ленивого сброса при параллельной
|
||||||
|
нагрузке, т.к. блоки журнала записываются на диск только когда они заполняются или явным
|
||||||
|
образом запрашивается fsync.
|
||||||
|
|
||||||
|
## Пример сравнения с Ceph
|
||||||
|
|
||||||
|
Железо - 4 сервера, в каждом:
|
||||||
|
- 6x SATA SSD Intel D3-4510 3.84 TB
|
||||||
|
- 2x Xeon Gold 6242 (16 cores @ 2.8 GHz)
|
||||||
|
- 384 GB RAM
|
||||||
|
- 1x 25 GbE сетевая карта (Mellanox ConnectX-4 LX), подключённая к свитчу Juniper QFX5200
|
||||||
|
|
||||||
|
Экономия энергии CPU отключена. В тестах и Vitastor, и Ceph развёрнуто по 2 OSD на 1 SSD.
|
||||||
|
|
||||||
|
Все результаты ниже относятся к случайной нагрузке 4 КБ блоками (если явно не указано обратное).
|
||||||
|
|
||||||
|
Производительность голых дисков:
|
||||||
|
- T1Q1 запись ~27000 iops (задержка ~0.037ms)
|
||||||
|
- T1Q1 чтение ~9800 iops (задержка ~0.101ms)
|
||||||
|
- T1Q32 запись ~60000 iops
|
||||||
|
- T1Q32 чтение ~81700 iops
|
||||||
|
|
||||||
|
Ceph 15.2.4 (Bluestore):
|
||||||
|
- T1Q1 запись ~1000 iops (задержка ~1ms)
|
||||||
|
- T1Q1 чтение ~1750 iops (задержка ~0.57ms)
|
||||||
|
- T8Q64 запись ~100000 iops, потребление CPU процессами OSD около 40 ядер на каждом сервере
|
||||||
|
- T8Q64 чтение ~480000 iops, потребление CPU процессами OSD около 40 ядер на каждом сервере
|
||||||
|
|
||||||
|
Тесты в 8 потоков проводились на 8 400GB RBD образах со всех хостов (с каждого хоста запускалось 2 процесса fio).
|
||||||
|
Это нужно потому, что в Ceph несколько RBD-клиентов, пишущих в 1 образ, очень сильно замедляются.
|
||||||
|
|
||||||
|
Настройки RocksDB и Bluestore в Ceph не менялись, единственным изменением было отключение cephx_sign_messages.
|
||||||
|
|
||||||
|
На самом деле, результаты теста не такие уж и плохие для Ceph (могло быть хуже).
|
||||||
|
Собственно говоря, эти серверы как раз хорошо сбалансированы для Ceph - 6 SATA SSD как раз
|
||||||
|
утилизируют 25-гигабитную сеть, а без 2 мощных процессоров Ceph-у бы не хватило ядер,
|
||||||
|
чтобы выдать пристойный результат. Собственно, что и показывает жор 40 ядер в процессе
|
||||||
|
параллельного теста.
|
||||||
|
|
||||||
|
Vitastor:
|
||||||
|
- T1Q1 запись: 7087 iops (задержка 0.14ms)
|
||||||
|
- T1Q1 чтение: 6838 iops (задержка 0.145ms)
|
||||||
|
- T2Q64 запись: 162000 iops, потребление CPU - 3 ядра на каждом сервере
|
||||||
|
- T8Q64 чтение: 895000 iops, потребление CPU - 4 ядра на каждом сервере
|
||||||
|
- Линейная запись (4M T1Q32): 2800 МБ/с
|
||||||
|
- Линейное чтение (4M T1Q32): 1500 МБ/с
|
||||||
|
|
||||||
|
Тест на чтение в 8 потоков проводился на 1 большом образе (3.2 ТБ) со всех хостов (опять же, по 2 fio с каждого).
|
||||||
|
В Vitastor никакой разницы между 1 образом и 8-ю нет. Естественно, примерно 1/4 запросов чтения
|
||||||
|
в такой конфигурации, как и в тестах Ceph выше, обслуживалась с локальной машины. Если проводить
|
||||||
|
тест так, чтобы все операции всегда обращались к первичным OSD по сети - тест сильнее упирался
|
||||||
|
в сеть и результат составлял примерно 689000 iops.
|
||||||
|
|
||||||
|
Настройки Vitastor: `--disable_data_fsync true --immediate_commit all --flusher_count 8
|
||||||
|
--disk_alignment 4096 --journal_block_size 4096 --meta_block_size 4096
|
||||||
|
--journal_no_same_sector_overwrites true --journal_sector_buffer_count 1024
|
||||||
|
--journal_size 16777216`.
|
||||||
|
|
||||||
|
### EC/XOR 2+1
|
||||||
|
|
||||||
|
Vitastor:
|
||||||
|
- T1Q1 запись: 2808 iops (задержка ~0.355ms)
|
||||||
|
- T1Q1 чтение: 6190 iops (задержка ~0.16ms)
|
||||||
|
- T2Q64 запись: 85500 iops, потребление CPU - 3.4 ядра на каждом сервере
|
||||||
|
- T8Q64 чтение: 812000 iops, потребление CPU - 4.7 ядра на каждом сервере
|
||||||
|
- Линейная запись (4M T1Q32): 3200 МБ/с
|
||||||
|
- Линейное чтение (4M T1Q32): 1800 МБ/с
|
||||||
|
|
||||||
|
Ceph:
|
||||||
|
- T1Q1 запись: 730 iops (задержка ~1.37ms latency)
|
||||||
|
- T1Q1 чтение: 1500 iops с холодным кэшем метаданных (задержка ~0.66ms), 2300 iops через 2 минуты прогрева (задержка ~0.435ms)
|
||||||
|
- T4Q128 запись (4 RBD images): 45300 iops, потребление CPU - 30 ядер на каждом сервере
|
||||||
|
- T8Q64 чтение (4 RBD images): 278600 iops, потребление CPU - 40 ядер на каждом сервере
|
||||||
|
- Линейная запись (4M T1Q32): 1950 МБ/с в пустой образ, 2500 МБ/с в заполненный образ
|
||||||
|
- Линейное чтение (4M T1Q32): 2400 МБ/с
|
||||||
|
|
||||||
|
### NBD
|
||||||
|
|
||||||
|
NBD расшифровывается как "сетевое блочное устройство", но на самом деле оно также
|
||||||
|
работает просто как аналог FUSE для блочных устройств, то есть, представляет собой
|
||||||
|
"блочное устройство в пространстве пользователя".
|
||||||
|
|
||||||
|
NBD - на данный момент единственный способ монтировать Vitastor ядром Linux.
|
||||||
|
NBD немного снижает производительность, так как приводит к дополнительным копированиям
|
||||||
|
данных между ядром и пространством пользователя. Тем не менее, способ достаточно оптимален,
|
||||||
|
а производительность случайного доступа вообще затрагивается слабо.
|
||||||
|
|
||||||
|
Vitastor с однопоточной NBD прокси на том же стенде:
|
||||||
|
- T1Q1 запись: 6000 iops (задержка 0.166ms)
|
||||||
|
- T1Q1 чтение: 5518 iops (задержка 0.18ms)
|
||||||
|
- T1Q128 запись: 94400 iops
|
||||||
|
- T1Q128 чтение: 103000 iops
|
||||||
|
- Линейная запись (4M T1Q128): 1266 МБ/с (в сравнении с 2800 МБ/с через fio)
|
||||||
|
- Линейное чтение (4M T1Q128): 975 МБ/с (в сравнении с 1500 МБ/с через fio)
|
||||||
|
|
||||||
|
## Установка
|
||||||
|
|
||||||
|
### Debian
|
||||||
|
|
||||||
|
- Добавьте ключ репозитория Vitastor:
|
||||||
|
`wget -q -O - https://vitastor.io/debian/pubkey | sudo apt-key add -`
|
||||||
|
- Добавьте репозиторий Vitastor в /etc/apt/sources.list:
|
||||||
|
- Debian 11 (Bullseye/Sid): `deb https://vitastor.io/debian bullseye main`
|
||||||
|
- Debian 10 (Buster): `deb https://vitastor.io/debian buster main`
|
||||||
|
- Для Debian 10 (Buster) также включите репозиторий backports:
|
||||||
|
`deb http://deb.debian.org/debian buster-backports main`
|
||||||
|
- Установите пакеты: `apt update; apt install vitastor lp-solve etcd linux-image-amd64 qemu`
|
||||||
|
|
||||||
|
### CentOS
|
||||||
|
|
||||||
|
- Добавьте в систему репозиторий Vitastor:
|
||||||
|
- CentOS 7: `yum install https://vitastor.io/rpms/centos/7/vitastor-release-1.0-1.el7.noarch.rpm`
|
||||||
|
- CentOS 8: `dnf install https://vitastor.io/rpms/centos/8/vitastor-release-1.0-1.el8.noarch.rpm`
|
||||||
|
- Включите EPEL: `yum/dnf install epel-release`
|
||||||
|
- Включите дополнительные репозитории CentOS:
|
||||||
|
- CentOS 7: `yum install centos-release-scl`
|
||||||
|
- CentOS 8: `dnf install centos-release-advanced-virtualization`
|
||||||
|
- Включите elrepo-kernel:
|
||||||
|
- CentOS 7: `yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm`
|
||||||
|
- CentOS 8: `dnf install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm`
|
||||||
|
- Установите пакеты: `yum/dnf install vitastor lpsolve etcd kernel-ml qemu-kvm`
|
||||||
|
|
||||||
|
### Установка из исходников
|
||||||
|
|
||||||
|
- Установите ядро 5.4 или более новое, для поддержки io_uring. Желательно 5.8 или даже новее,
|
||||||
|
так как в 5.4 есть как минимум 1 известный баг, ведущий к зависанию с io_uring и контроллером HP SmartArray.
|
||||||
|
- Установите liburing 0.4 или более новый и его заголовки.
|
||||||
|
- Установите lp_solve.
|
||||||
|
- Установите etcd, версии не ниже 3.4.15. Более ранние версии работать не будут из-за различных багов,
|
||||||
|
например [#12402](https://github.com/etcd-io/etcd/pull/12402). Также вы можете взять версию 3.4.13 с
|
||||||
|
этим конкретным исправлением из ветки release-3.4 репозитория https://github.com/vitalif/etcd/.
|
||||||
|
- Установите node.js 10 или новее.
|
||||||
|
- Установите gcc и g++ 8.x или новее.
|
||||||
|
- Склонируйте данный репозиторий с подмодулями: `git clone https://yourcmc.ru/git/vitalif/vitastor/`.
|
||||||
|
- Желательно пересобрать QEMU с патчем, который делает необязательным запуск через LD_PRELOAD.
|
||||||
|
См `patches/qemu-*.*-vitastor.patch` - выберите версию, наиболее близкую вашей версии QEMU.
|
||||||
|
- Установите QEMU 3.0 или новее, возьмите исходные коды установленного пакета, начните его пересборку,
|
||||||
|
через некоторое время остановите её и скопируйте следующие заголовки:
|
||||||
|
- `<qemu>/include` → `<vitastor>/qemu/include`
|
||||||
|
- Debian:
|
||||||
|
* Берите qemu из основного репозитория
|
||||||
|
* `<qemu>/b/qemu/config-host.h` → `<vitastor>/qemu/b/qemu/config-host.h`
|
||||||
|
* `<qemu>/b/qemu/qapi` → `<vitastor>/qemu/b/qemu/qapi`
|
||||||
|
- CentOS 8:
|
||||||
|
* Берите qemu из репозитория Advanced-Virtualization. Чтобы включить его, запустите
|
||||||
|
`yum install centos-release-advanced-virtualization.noarch` и далее `yum install qemu`
|
||||||
|
* `<qemu>/config-host.h` → `<vitastor>/qemu/b/qemu/config-host.h`
|
||||||
|
* Для QEMU 3.0+: `<qemu>/qapi` → `<vitastor>/qemu/b/qemu/qapi`
|
||||||
|
* Для QEMU 2.0+: `<qemu>/qapi-types.h` → `<vitastor>/qemu/b/qemu/qapi-types.h`
|
||||||
|
- `config-host.h` и `qapi` нужны, т.к. в них содержатся автогенерируемые заголовки
|
||||||
|
- Установите fio 3.7 или новее, возьмите исходники пакета и сделайте на них симлинк с `<vitastor>/fio`.
|
||||||
|
- Соберите и установите Vitastor командой `mkdir build && cd build && cmake .. && make -j8 && make install`.
|
||||||
|
Обратите внимание на переменную cmake `QEMU_PLUGINDIR` - под RHEL её нужно установить равной `qemu-kvm`.
|
||||||
|
|
||||||
|
## Запуск
|
||||||
|
|
||||||
|
Внимание: процедура пока что достаточно нетривиальная, задавать конфигурацию и смещения
|
||||||
|
на диске нужно почти вручную. Это будет исправлено в ближайшем будущем.
|
||||||
|
|
||||||
|
- Желательны SATA SSD или NVMe диски с конденсаторами (серверные SSD). Можно использовать и
|
||||||
|
десктопные SSD, включив режим отложенного fsync, но производительность однопоточной записи
|
||||||
|
в этом случае пострадает.
|
||||||
|
- Быстрая сеть, минимум 10 гбит/с
|
||||||
|
- Для наилучшей производительности нужно отключить энергосбережение CPU: `cpupower idle-set -D 0 && cpupower frequency-set -g performance`.
|
||||||
|
- На хостах мониторов:
|
||||||
|
- Пропишите нужные вам значения в файле `/usr/lib/vitastor/mon/make-units.sh`
|
||||||
|
- Создайте юниты systemd для etcd и мониторов: `/usr/lib/vitastor/mon/make-units.sh`
|
||||||
|
- Пропишите etcd_address и osd_network в `/etc/vitastor/vitastor.conf`. Например:
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"etcd_address": ["10.200.1.10:2379","10.200.1.11:2379","10.200.1.12:2379"],
|
||||||
|
"osd_network": "10.200.1.0/24"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- Создайте юниты systemd для OSD: `/usr/lib/vitastor/make-osd.sh /dev/disk/by-partuuid/XXX [/dev/disk/by-partuuid/YYY ...]`
|
||||||
|
- Вы можете менять параметры OSD в юнитах systemd или в `vitastor.conf`. Смысл некоторых параметров:
|
||||||
|
- `disable_data_fsync 1` - отключает fsync, используется с SSD с конденсаторами.
|
||||||
|
- `immediate_commit all` - используется с SSD с конденсаторами.
|
||||||
|
Внимание: если установлено, также нужно установить его в то же значение в etcd в /vitastor/config/global
|
||||||
|
- `disable_device_lock 1` - отключает блокировку файла устройства, нужно, только если вы запускаете
|
||||||
|
несколько OSD на одном блочном устройстве.
|
||||||
|
- `flusher_count 256` - "flusher" - микропоток, удаляющий старые данные из журнала.
|
||||||
|
Не волнуйтесь об этой настройке, 256 теперь достаточно практически всегда.
|
||||||
|
- `disk_alignment`, `journal_block_size`, `meta_block_size` следует установить равными размеру
|
||||||
|
внутреннего блока SSD. Это почти всегда 4096.
|
||||||
|
- `journal_no_same_sector_overwrites true` запрещает перезапись одного и того же сектора журнала подряд
|
||||||
|
много раз в процессе записи. Большинство (99%) SSD не нуждаются в данной опции. Однако выяснилось, что
|
||||||
|
диски, используемые на одном из тестовых стендов - Intel D3-S4510 - очень сильно не любят такую
|
||||||
|
перезапись, и для них была добавлена эта опция. Когда данный режим включён, также нужно поднимать
|
||||||
|
значение `journal_sector_buffer_count`, так как иначе Vitastor не хватит буферов для записи в журнал.
|
||||||
|
- Запустите все etcd: `systemctl start etcd`
|
||||||
|
- Создайте глобальную конфигурацию в etcd: `etcdctl --endpoints=... put /vitastor/config/global '{"immediate_commit":"all"}'`
|
||||||
|
(если все ваши диски - серверные с конденсаторами).
|
||||||
|
- Создайте пулы: `etcdctl --endpoints=... put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":256,"failure_domain":"host"}}'`.
|
||||||
|
Для jerasure EC-пулов конфигурация должна выглядеть так: `2:{"name":"ecpool","scheme":"jerasure","pg_size":4,"parity_chunks":2,"pg_minsize":2,"pg_count":256,"failure_domain":"host"}`.
|
||||||
|
- Запустите все OSD: `systemctl start vitastor.target`
|
||||||
|
- Ваш кластер должен быть готов - один из мониторов должен уже сконфигурировать PG, а OSD должны запустить их.
|
||||||
|
- Вы можете проверить состояние PG прямо в etcd: `etcdctl --endpoints=... get --prefix /vitastor/pg/state`. Все PG должны быть 'active'.
|
||||||
|
|
||||||
|
### Задать имя образу
|
||||||
|
|
||||||
|
```
|
||||||
|
etcdctl --endpoints=<etcd> put /vitastor/config/inode/<pool>/<inode> '{"name":"<name>","size":<size>[,"parent_id":<parent_inode_number>][,"readonly":true]}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Например:
|
||||||
|
|
||||||
|
```
|
||||||
|
etcdctl --endpoints=http://10.115.0.10:2379/v3 put /vitastor/config/inode/1/1 '{"name":"testimg","size":2147483648}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Если вы зададите parent_id, то образ станет CoW-клоном, т.е. все новые запросы записи пойдут в новый инод, а запросы
|
||||||
|
чтения будут проверять сначала его, а потом родительские слои по цепочке вверх. Чтобы случайно не перезаписать данные
|
||||||
|
в родительском слое, вы можете переключить его в режим "только чтение", добавив флаг `"readonly":true` в его запись
|
||||||
|
метаданных. В таком случае родительский образ становится просто снапшотом.
|
||||||
|
|
||||||
|
Таким образом, для создания снапшота вам нужно просто переименовать предыдущий inode (например, из testimg в testimg@0),
|
||||||
|
сделать его readonly и создать новый слой с исходным именем образа (testimg), ссылающийся на только что переименованный
|
||||||
|
в качестве родительского.
|
||||||
|
|
||||||
|
### Запуск тестов с fio
|
||||||
|
|
||||||
|
Пример команды для запуска тестов:
|
||||||
|
|
||||||
|
```
|
||||||
|
fio -thread -ioengine=libfio_vitastor.so -name=test -bs=4M -direct=1 -iodepth=16 -rw=write -etcd=10.115.0.10:2379/v3 -image=testimg
|
||||||
|
```
|
||||||
|
|
||||||
|
Если вы не хотите обращаться к образу по имени, вместо `-image=testimg` можно указать номер пула, номер инода и размер:
|
||||||
|
`-pool=1 -inode=1 -size=400G`.
|
||||||
|
|
||||||
|
### Загрузить образ диска ВМ в/из Vitastor
|
||||||
|
|
||||||
|
Используйте qemu-img и строку `vitastor:etcd_host=<HOST>:image=<IMAGE>` в качестве имени файла диска. Например:
|
||||||
|
|
||||||
|
```
|
||||||
|
qemu-img convert -f qcow2 debian10.qcow2 -p -O raw 'vitastor:etcd_host=10.115.0.10\:2379/v3:image=testimg'
|
||||||
|
```
|
||||||
|
|
||||||
|
Обратите внимание, что если вы используете немодифицированный QEMU, потребуется установить переменную окружения
|
||||||
|
`LD_PRELOAD=/usr/lib/x86_64-linux-gnu/qemu/block-vitastor.so`.
|
||||||
|
|
||||||
|
Если вы не хотите обращаться к образу по имени, вместо `:image=<IMAGE>` можно указать номер пула, номер инода и размер:
|
||||||
|
`:pool=<POOL>:inode=<INODE>:size=<SIZE>`.
|
||||||
|
|
||||||
|
### Запустить ВМ
|
||||||
|
|
||||||
|
Для запуска QEMU используйте опцию `-drive file=vitastor:etcd_host=<HOST>:image=<IMAGE>` (аналогично qemu-img)
|
||||||
|
и физический размер блока 4 KB.
|
||||||
|
|
||||||
|
Например:
|
||||||
|
|
||||||
|
```
|
||||||
|
qemu-system-x86_64 -enable-kvm -m 1024
|
||||||
|
-drive 'file=vitastor:etcd_host=10.115.0.10\:2379/v3:image=testimg',format=raw,if=none,id=drive-virtio-disk0,cache=none
|
||||||
|
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,write-cache=off,physical_block_size=4096,logical_block_size=512
|
||||||
|
-vnc 0.0.0.0:0
|
||||||
|
```
|
||||||
|
|
||||||
|
Обращение по номерам (`:pool=<POOL>:inode=<INODE>:size=<SIZE>` вместо `:image=<IMAGE>`) работает аналогично qemu-img.
|
||||||
|
|
||||||
|
### Удалить образ
|
||||||
|
|
||||||
|
Используйте утилиту vitastor-cli rm-data. Например:
|
||||||
|
|
||||||
|
```
|
||||||
|
vitastor-cli rm-data --etcd_address 10.115.0.10:2379/v3 --pool 1 --inode 1 --parallel_osds 16 --iodepth 32
|
||||||
|
```
|
||||||
|
|
||||||
|
### NBD
|
||||||
|
|
||||||
|
Чтобы создать локальное блочное устройство, используйте NBD. Например:
|
||||||
|
|
||||||
|
```
|
||||||
|
vitastor-nbd map --etcd_address 10.115.0.10:2379/v3 --image testimg
|
||||||
|
```
|
||||||
|
|
||||||
|
Команда напечатает название устройства вида /dev/nbd0, которое потом можно будет форматировать
|
||||||
|
и использовать как обычное блочное устройство.
|
||||||
|
|
||||||
|
Для обращения по номеру инода, аналогично другим командам, можно использовать опции
|
||||||
|
`--pool <POOL> --inode <INODE> --size <SIZE>` вместо `--image testimg`.
|
||||||
|
|
||||||
|
### Kubernetes
|
||||||
|
|
||||||
|
У Vitastor есть CSI-плагин для Kubernetes, поддерживающий RWO-тома.
|
||||||
|
|
||||||
|
Для установки возьмите манифесты из директории [csi/deploy/](csi/deploy/), поместите
|
||||||
|
вашу конфигурацию подключения к Vitastor в [csi/deploy/001-csi-config-map.yaml](001-csi-config-map.yaml),
|
||||||
|
настройте StorageClass в [csi/deploy/009-storage-class.yaml](009-storage-class.yaml)
|
||||||
|
и примените все `NNN-*.yaml` к вашей инсталляции Kubernetes.
|
||||||
|
|
||||||
|
```
|
||||||
|
for i in ./???-*.yaml; do kubectl apply -f $i; done
|
||||||
|
```
|
||||||
|
|
||||||
|
После этого вы сможете создавать PersistentVolume. Пример смотрите в файле [csi/deploy/example-pvc.yaml](csi/deploy/example-pvc.yaml).
|
||||||
|
|
||||||
|
### OpenStack
|
||||||
|
|
||||||
|
Чтобы подключить Vitastor к OpenStack:
|
||||||
|
|
||||||
|
- Установите пакеты vitastor-client, libvirt и QEMU из DEB или RPM репозитория Vitastor
|
||||||
|
- Примените патч `patches/nova-21.diff` или `patches/nova-23.diff` к вашей инсталляции Nova.
|
||||||
|
nova-21.diff подходит для Nova 21-22, nova-23.diff подходит для Nova 23-24.
|
||||||
|
- Скопируйте `patches/cinder-vitastor.py` в инсталляцию Cinder как `cinder/volume/drivers/vitastor.py`
|
||||||
|
- Создайте тип томов в cinder.conf (см. ниже)
|
||||||
|
- Обязательно заблокируйте доступ от виртуальных машин к сети Vitastor (OSD и etcd), т.к. Vitastor (пока) не поддерживает аутентификацию
|
||||||
|
- Перезапустите Cinder и Nova
|
||||||
|
|
||||||
|
Пример конфигурации Cinder:
|
||||||
|
|
||||||
|
```
|
||||||
|
[DEFAULT]
|
||||||
|
enabled_backends = lvmdriver-1, vitastor-testcluster
|
||||||
|
# ...
|
||||||
|
|
||||||
|
[vitastor-testcluster]
|
||||||
|
volume_driver = cinder.volume.drivers.vitastor.VitastorDriver
|
||||||
|
volume_backend_name = vitastor-testcluster
|
||||||
|
image_volume_cache_enabled = True
|
||||||
|
volume_clear = none
|
||||||
|
vitastor_etcd_address = 192.168.7.2:2379
|
||||||
|
vitastor_etcd_prefix =
|
||||||
|
vitastor_config_path = /etc/vitastor/vitastor.conf
|
||||||
|
vitastor_pool_id = 1
|
||||||
|
image_upload_use_cinder_backend = True
|
||||||
|
```
|
||||||
|
|
||||||
|
Чтобы помещать в Vitastor Glance-образы, нужно использовать
|
||||||
|
[https://docs.openstack.org/cinder/pike/admin/blockstorage-volume-backed-image.html](образы на основе томов Cinder),
|
||||||
|
однако, поддержка этой функции ещё не проверялась.
|
||||||
|
|
||||||
|
### Proxmox
|
||||||
|
|
||||||
|
Чтобы подключить Vitastor к Proxmox Virtual Environment (поддерживаются версии 6.4 и 7.1):
|
||||||
|
|
||||||
|
- Добавьте соответствующий Debian-репозиторий Vitastor в sources.list на хостах Proxmox
|
||||||
|
(buster для 6.4, bullseye для 7.1)
|
||||||
|
- Установите пакеты vitastor-client, pve-qemu-kvm, pve-storage-vitastor (* или см. сноску) из репозитория Vitastor
|
||||||
|
- Определите тип хранилища в `/etc/pve/storage.cfg` (см. ниже)
|
||||||
|
- Обязательно заблокируйте доступ от виртуальных машин к сети Vitastor (OSD и etcd), т.к. Vitastor (пока) не поддерживает аутентификацию
|
||||||
|
- Перезапустите демон Proxmox: `systemctl restart pvedaemon`
|
||||||
|
|
||||||
|
Пример `/etc/pve/storage.cfg` (единственная обязательная опция - vitastor_pool, все остальные
|
||||||
|
перечислены внизу для понимания значений по умолчанию):
|
||||||
|
|
||||||
|
```
|
||||||
|
vitastor: vitastor
|
||||||
|
# Пул, в который будут помещаться образы дисков
|
||||||
|
vitastor_pool testpool
|
||||||
|
# Путь к файлу конфигурации
|
||||||
|
vitastor_config_path /etc/vitastor/vitastor.conf
|
||||||
|
# Адрес(а) etcd, нужны, только если не указаны в vitastor.conf
|
||||||
|
vitastor_etcd_address 192.168.7.2:2379/v3
|
||||||
|
# Префикс ключей метаданных в etcd
|
||||||
|
vitastor_etcd_prefix /vitastor
|
||||||
|
# Префикс имён образов
|
||||||
|
vitastor_prefix pve/
|
||||||
|
# Монтировать образы через NBD прокси, через ядро (нужно только для контейнеров)
|
||||||
|
vitastor_nbd 0
|
||||||
|
```
|
||||||
|
|
||||||
|
\* Примечание: вместо установки пакета pve-storage-vitastor вы можете вручную скопировать файл
|
||||||
|
[patches/PVE_VitastorPlugin.pm](patches/PVE_VitastorPlugin.pm) на хосты Proxmox как
|
||||||
|
`/usr/share/perl5/PVE/Storage/Custom/VitastorPlugin.pm`.
|
||||||
|
|
||||||
|
## Известные проблемы
|
||||||
|
|
||||||
|
- Запросы удаления объектов могут в данный момент приводить к "неполным" объектам в EC-пулах,
|
||||||
|
если в процессе удаления произойдут отказы OSD или серверов, потому что правильная обработка
|
||||||
|
запросов удаления в кластере должна быть "трёхфазной", а это пока не реализовано. Если вы
|
||||||
|
столкнётесь с такой ситуацией, просто повторите запрос удаления.
|
||||||
|
|
||||||
|
## Принципы реализации
|
||||||
|
|
||||||
|
- Я люблю архитектурно простые решения. Vitastor проектируется именно так и я намерен
|
||||||
|
и далее следовать данному принципу.
|
||||||
|
- Если вы пришли сюда за идеальным кодом на C++, вы, вероятно, не по адресу. "Общепринятые"
|
||||||
|
практики написания C++ кода меня не очень волнуют, так как зачастую, опять-таки, ведут к
|
||||||
|
излишним усложнениям и код получается красивый... но медленный.
|
||||||
|
- По той же причине в коде иногда можно встретить велосипеды типа собственного упрощённого
|
||||||
|
HTTP-клиента для работы с etcd. Зато эти велосипеды маленькие и компактные и не требуют
|
||||||
|
использования десятка внешних библиотек.
|
||||||
|
- node.js для монитора - не случайный выбор. Он очень быстрый, имеет встроенную событийную
|
||||||
|
машину, приятный нейтральный C-подобный язык программирования и развитую инфраструктуру.
|
||||||
|
|
||||||
|
## Автор и лицензия
|
||||||
|
|
||||||
|
Автор: Виталий Филиппов (vitalif [at] yourcmc.ru), 2019+
|
||||||
|
|
||||||
|
Заходите в Telegram-чат Vitastor: https://t.me/vitastor
|
||||||
|
|
||||||
|
Лицензия: VNPL 1.1 на серверный код и двойная VNPL 1.1 + GPL 2.0+ на клиентский.
|
||||||
|
|
||||||
|
VNPL - "сетевой копилефт", собственная свободная копилефт-лицензия
|
||||||
|
Vitastor Network Public License 1.1, основанная на GNU GPL 3.0 с дополнительным
|
||||||
|
условием "Сетевого взаимодействия", требующим распространять все программы,
|
||||||
|
специально разработанные для использования вместе с Vitastor и взаимодействующие
|
||||||
|
с ним по сети, под лицензией VNPL или под любой другой свободной лицензией.
|
||||||
|
|
||||||
|
Идея VNPL - расширение действия копилефта не только на модули, явным образом
|
||||||
|
связываемые с кодом Vitastor, но также на модули, оформленные в виде микросервисов
|
||||||
|
и взаимодействующие с ним по сети.
|
||||||
|
|
||||||
|
Таким образом, если вы хотите построить на основе Vitastor сервис, содержаший
|
||||||
|
компоненты с закрытым кодом, взаимодействующие с Vitastor, вам нужна коммерческая
|
||||||
|
лицензия от автора 😀.
|
||||||
|
|
||||||
|
На Windows и любое другое ПО, не разработанное *специально* для использования
|
||||||
|
вместе с Vitastor, никакие ограничения не накладываются.
|
||||||
|
|
||||||
|
Клиентские библиотеки распространяются на условиях двойной лицензии VNPL 1.0
|
||||||
|
и также на условиях GNU GPL 2.0 или более поздней версии. Так сделано в целях
|
||||||
|
совместимости с таким ПО, как QEMU и fio.
|
||||||
|
|
||||||
|
Вы можете найти полный текст VNPL 1.1 в файле [VNPL-1.1.txt](VNPL-1.1.txt),
|
||||||
|
а GPL 2.0 в файле [GPL-2.0.txt](GPL-2.0.txt).
|
|
@ -0,0 +1,608 @@
|
||||||
|
## Vitastor
|
||||||
|
|
||||||
|
[Читать на русском](README-ru.md)
|
||||||
|
|
||||||
|
## The Idea
|
||||||
|
|
||||||
|
Make Software-Defined Block Storage Great Again.
|
||||||
|
|
||||||
|
Vitastor is a small, simple and fast clustered block storage (storage for VM drives),
|
||||||
|
architecturally similar to Ceph which means strong consistency, primary-replication, symmetric
|
||||||
|
clustering and automatic data distribution over any number of drives of any size
|
||||||
|
with configurable redundancy (replication or erasure codes/XOR).
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
Vitastor is currently a pre-release, a lot of features are missing and you can still expect
|
||||||
|
breaking changes in the future. However, the following is implemented:
|
||||||
|
|
||||||
|
- Basic part: highly-available block storage with symmetric clustering and no SPOF
|
||||||
|
- Performance ;-D
|
||||||
|
- Multiple redundancy schemes: Replication, XOR n+1, Reed-Solomon erasure codes
|
||||||
|
based on jerasure library with any number of data and parity drives in a group
|
||||||
|
- Configuration via simple JSON data structures in etcd
|
||||||
|
- Automatic data distribution over OSDs, with support for:
|
||||||
|
- Mathematical optimization for better uniformity and less data movement
|
||||||
|
- Multiple pools
|
||||||
|
- Placement tree, OSD selection by tags (device classes) and placement root
|
||||||
|
- Configurable failure domains
|
||||||
|
- Recovery of degraded blocks
|
||||||
|
- Rebalancing (data movement between OSDs)
|
||||||
|
- Lazy fsync support
|
||||||
|
- I/O statistics reporting to etcd
|
||||||
|
- Generic user-space client library
|
||||||
|
- QEMU driver (built out-of-tree)
|
||||||
|
- Loadable fio engine for benchmarks (also built out-of-tree)
|
||||||
|
- NBD proxy for kernel mounts
|
||||||
|
- Inode removal tool (vitastor-cli rm-data)
|
||||||
|
- Packaging for Debian and CentOS
|
||||||
|
- Per-inode I/O and space usage statistics
|
||||||
|
- Inode metadata storage in etcd
|
||||||
|
- Snapshots and copy-on-write image clones
|
||||||
|
- Write throttling to smooth random write workloads in SSD+HDD configurations
|
||||||
|
- RDMA/RoCEv2 support via libibverbs
|
||||||
|
- CSI plugin for Kubernetes
|
||||||
|
- Basic OpenStack support: Cinder driver, Nova and libvirt patches
|
||||||
|
- Snapshot merge tool (vitastor-cli {snap-rm,flatten,merge})
|
||||||
|
- Image management CLI (vitastor-cli {ls,create,modify})
|
||||||
|
- Proxmox storage plugin
|
||||||
|
|
||||||
|
## Roadmap
|
||||||
|
|
||||||
|
- Snapshot deletion (layer merge) support
|
||||||
|
- Better OSD creation and auto-start tools
|
||||||
|
- Other administrative tools
|
||||||
|
- Plugins for OpenNebula, Proxmox and other cloud systems
|
||||||
|
- iSCSI proxy
|
||||||
|
- Faster failover
|
||||||
|
- Scrubbing without checksums (verification of replicas)
|
||||||
|
- Checksums
|
||||||
|
- Tiered storage
|
||||||
|
- NVDIMM support
|
||||||
|
- Web GUI
|
||||||
|
- Compression (possibly)
|
||||||
|
- Read caching using system page cache (possibly)
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
Similarities:
|
||||||
|
|
||||||
|
- Just like Ceph, Vitastor has Pools, PGs, OSDs, Monitors, Failure Domains, Placement Tree.
|
||||||
|
- Just like Ceph, Vitastor is transactional (even though there's a "lazy fsync mode" which
|
||||||
|
doesn't implicitly flush every operation to disks).
|
||||||
|
- OSDs also have journal and metadata and they can also be put on separate drives.
|
||||||
|
- Just like in Ceph, client library attempts to recover from any cluster failure so
|
||||||
|
you can basically reboot the whole cluster and only pause, but not crash, your clients
|
||||||
|
(I consider this a bug if the client crashes in that case).
|
||||||
|
|
||||||
|
Some basic terms for people not familiar with Ceph:
|
||||||
|
|
||||||
|
- OSD (Object Storage Daemon) is a process that stores data and serves read/write requests.
|
||||||
|
- PG (Placement Group) is a container for data that (normally) shares the same replicas.
|
||||||
|
- Pool is a container for data that has the same redundancy scheme and placement rules.
|
||||||
|
- Monitor is a separate daemon that watches cluster state and handles failures.
|
||||||
|
- Failure Domain is a group of OSDs that you allow to fail. It's "host" by default.
|
||||||
|
- Placement Tree groups OSDs in a hierarchy to later split them into Failure Domains.
|
||||||
|
|
||||||
|
Architectural differences from Ceph:
|
||||||
|
|
||||||
|
- Vitastor's primary focus is on SSDs. Proper SSD+HDD optimizations may be added in the future, though.
|
||||||
|
- Vitastor OSD is (and will always be) single-threaded. If you want to dedicate more than 1 core
|
||||||
|
per drive you should run multiple OSDs each on a different partition of the drive.
|
||||||
|
Vitastor isn't CPU-hungry though (as opposed to Ceph), so 1 core is sufficient in a lot of cases.
|
||||||
|
- Metadata and journal are always kept in memory. Metadata size depends linearly on drive capacity
|
||||||
|
and data store block size which is 128 KB by default. With 128 KB blocks metadata should occupy
|
||||||
|
around 512 MB per 1 TB (which is still less than Ceph wants). Journal doesn't have to be big,
|
||||||
|
the example test below was conducted with only 16 MB journal. A big journal is probably even
|
||||||
|
harmful as dirty write metadata also take some memory.
|
||||||
|
- Vitastor storage layer doesn't have internal copy-on-write or redirect-write. I know that maybe
|
||||||
|
it's possible to create a good copy-on-write storage, but it's much harder and makes performance
|
||||||
|
less deterministic, so CoW isn't used in Vitastor.
|
||||||
|
- The basic layer of Vitastor is block storage with fixed-size blocks, not object storage with
|
||||||
|
rich semantics like in Ceph (RADOS).
|
||||||
|
- There's a "lazy fsync" mode which allows to batch writes before flushing them to the disk.
|
||||||
|
This allows to use Vitastor with desktop SSDs, but still lowers performance due to additional
|
||||||
|
network roundtrips, so use server SSDs with capacitor-based power loss protection
|
||||||
|
("Advanced Power Loss Protection") for best performance.
|
||||||
|
- PGs are ephemeral. This means that they aren't stored on data disks and only exist in memory
|
||||||
|
while OSDs are running.
|
||||||
|
- Recovery process is per-object (per-block), not per-PG. Also there are no PGLOGs.
|
||||||
|
- Monitors don't store data. Cluster configuration and state is stored in etcd in simple human-readable
|
||||||
|
JSON structures. Monitors only watch cluster state and handle data movement.
|
||||||
|
Thus Vitastor's Monitor isn't a critical component of the system and is more similar to Ceph's Manager.
|
||||||
|
Vitastor's Monitor is implemented in node.js.
|
||||||
|
- PG distribution isn't based on consistent hashes. All PG mappings are stored in etcd.
|
||||||
|
Rebalancing PGs between OSDs is done by mathematical optimization - data distribution problem
|
||||||
|
is reduced to a linear programming problem and solved by lp_solve. This allows for almost
|
||||||
|
perfect (96-99% uniformity compared to Ceph's 80-90%) data distribution in most cases, ability
|
||||||
|
to map PGs by hand without breaking rebalancing logic, reduced OSD peer-to-peer communication
|
||||||
|
(on average, OSDs have fewer peers) and less data movement. It also probably has a drawback -
|
||||||
|
this method may fail in very large clusters, but up to several hundreds of OSDs it's perfectly fine.
|
||||||
|
It's also easy to add consistent hashes in the future if something proves their necessity.
|
||||||
|
- There's no separate CRUSH layer. You select pool redundancy scheme, placement root, failure domain
|
||||||
|
and so on directly in pool configuration.
|
||||||
|
|
||||||
|
## Understanding Storage Performance
|
||||||
|
|
||||||
|
The most important thing for fast storage is latency, not parallel iops.
|
||||||
|
|
||||||
|
The best possible latency is achieved with one thread and queue depth of 1 which basically means
|
||||||
|
"client load as low as possible". In this case IOPS = 1/latency, and this number doesn't
|
||||||
|
scale with number of servers, drives, server processes or threads and so on.
|
||||||
|
Single-threaded IOPS and latency numbers only depend on *how fast a single daemon is*.
|
||||||
|
|
||||||
|
Why is it important? It's important because some of the applications *can't* use
|
||||||
|
queue depth greater than 1 because their task isn't parallelizable. A notable example
|
||||||
|
is any ACID DBMS because all of them write their WALs sequentially with fsync()s.
|
||||||
|
|
||||||
|
fsync, by the way, is another important thing often missing in benchmarks. The point is
|
||||||
|
that drives have cache buffers and don't guarantee that your data is actually persisted
|
||||||
|
until you call fsync() which is translated to a FLUSH CACHE command by the OS.
|
||||||
|
|
||||||
|
Desktop SSDs are very fast without fsync - NVMes, for example, can process ~80000 write
|
||||||
|
operations per second with queue depth of 1 without fsync - but they're really slow with
|
||||||
|
fsync because they have to actually write data to flash chips when you call fsync. Typical
|
||||||
|
number is around 1000-2000 iops with fsync.
|
||||||
|
|
||||||
|
Server SSDs often have supercapacitors that act as a built-in UPS and allow the drive
|
||||||
|
to flush its DRAM cache to the persistent flash storage when a power loss occurs.
|
||||||
|
This makes them perform equally well with and without fsync. This feature is called
|
||||||
|
"Advanced Power Loss Protection" by Intel; other vendors either call it similarly
|
||||||
|
or directly as "Full Capacitor-Based Power Loss Protection".
|
||||||
|
|
||||||
|
All software-defined storages that I currently know are slow in terms of latency.
|
||||||
|
Notable examples are Ceph and internal SDSes used by cloud providers like Amazon, Google,
|
||||||
|
Yandex and so on. They're all slow and can only reach ~0.3ms read and ~0.6ms 4 KB write latency
|
||||||
|
with best-in-slot hardware.
|
||||||
|
|
||||||
|
And that's in the SSD era when you can buy an SSD that has ~0.04ms latency for 100 $.
|
||||||
|
|
||||||
|
I use the following 6 commands with small variations to benchmark any storage:
|
||||||
|
|
||||||
|
- Linear write:
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4M -iodepth=32 -rw=write -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Linear read:
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4M -iodepth=32 -rw=read -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Random write latency (T1Q1, this hurts storages the most):
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4k -iodepth=1 -fsync=1 -rw=randwrite -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Random read latency (T1Q1):
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4k -iodepth=1 -rw=randread -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Parallel write iops (use numjobs if a single CPU core is insufficient to saturate the load):
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4k -iodepth=128 [-numjobs=4 -group_reporting] -rw=randwrite -runtime=60 -filename=/dev/sdX`
|
||||||
|
- Parallel read iops (use numjobs if a single CPU core is insufficient to saturate the load):
|
||||||
|
`fio -ioengine=libaio -direct=1 -invalidate=1 -name=test -bs=4k -iodepth=128 [-numjobs=4 -group_reporting] -rw=randread -runtime=60 -filename=/dev/sdX`
|
||||||
|
|
||||||
|
## Vitastor's Theoretical Maximum Random Access Performance
|
||||||
|
|
||||||
|
Replicated setups:
|
||||||
|
- Single-threaded (T1Q1) read latency: 1 network roundtrip + 1 disk read.
|
||||||
|
- Single-threaded write+fsync latency:
|
||||||
|
- With immediate commit: 2 network roundtrips + 1 disk write.
|
||||||
|
- With lazy commit: 4 network roundtrips + 1 disk write + 1 disk flush.
|
||||||
|
- Saturated parallel read iops: min(network bandwidth, sum(disk read iops)).
|
||||||
|
- Saturated parallel write iops: min(network bandwidth, sum(disk write iops / number of replicas / write amplification)).
|
||||||
|
|
||||||
|
EC/XOR setups:
|
||||||
|
- Single-threaded (T1Q1) read latency: 1.5 network roundtrips + 1 disk read.
|
||||||
|
- Single-threaded write+fsync latency:
|
||||||
|
- With immediate commit: 3.5 network roundtrips + 1 disk read + 2 disk writes.
|
||||||
|
- With lazy commit: 5.5 network roundtrips + 1 disk read + 2 disk writes + 2 disk fsyncs.
|
||||||
|
- 0.5 in actually (k-1)/k which means that an additional roundtrip doesn't happen when
|
||||||
|
the read sub-operation can be served locally.
|
||||||
|
- Saturated parallel read iops: min(network bandwidth, sum(disk read iops)).
|
||||||
|
- Saturated parallel write iops: min(network bandwidth, sum(disk write iops * number of data drives / (number of data + parity drives) / write amplification)).
|
||||||
|
In fact, you should put disk write iops under the condition of ~10% reads / ~90% writes in this formula.
|
||||||
|
|
||||||
|
Write amplification for 4 KB blocks is usually 3-5 in Vitastor:
|
||||||
|
1. Journal block write
|
||||||
|
2. Journal data write
|
||||||
|
3. Metadata block write
|
||||||
|
4. Another journal block write for EC/XOR setups
|
||||||
|
5. Data block write
|
||||||
|
|
||||||
|
If you manage to get an SSD which handles 512 byte blocks well (Optane?) you may
|
||||||
|
lower 1, 3 and 4 to 512 bytes (1/8 of data size) and get WA as low as 2.375.
|
||||||
|
|
||||||
|
Lazy fsync also reduces WA for parallel workloads because journal blocks are only
|
||||||
|
written when they fill up or fsync is requested.
|
||||||
|
|
||||||
|
## Example Comparison with Ceph
|
||||||
|
|
||||||
|
Hardware configuration: 4 nodes, each with:
|
||||||
|
- 6x SATA SSD Intel D3-4510 3.84 TB
|
||||||
|
- 2x Xeon Gold 6242 (16 cores @ 2.8 GHz)
|
||||||
|
- 384 GB RAM
|
||||||
|
- 1x 25 GbE network interface (Mellanox ConnectX-4 LX), connected to a Juniper QFX5200 switch
|
||||||
|
|
||||||
|
CPU powersaving was disabled. Both Vitastor and Ceph were configured with 2 OSDs per 1 SSD.
|
||||||
|
|
||||||
|
All of the results below apply to 4 KB blocks and random access (unless indicated otherwise).
|
||||||
|
|
||||||
|
Raw drive performance:
|
||||||
|
- T1Q1 write ~27000 iops (~0.037ms latency)
|
||||||
|
- T1Q1 read ~9800 iops (~0.101ms latency)
|
||||||
|
- T1Q32 write ~60000 iops
|
||||||
|
- T1Q32 read ~81700 iops
|
||||||
|
|
||||||
|
Ceph 15.2.4 (Bluestore):
|
||||||
|
- T1Q1 write ~1000 iops (~1ms latency)
|
||||||
|
- T1Q1 read ~1750 iops (~0.57ms latency)
|
||||||
|
- T8Q64 write ~100000 iops, total CPU usage by OSDs about 40 virtual cores on each node
|
||||||
|
- T8Q64 read ~480000 iops, total CPU usage by OSDs about 40 virtual cores on each node
|
||||||
|
|
||||||
|
T8Q64 tests were conducted over 8 400GB RBD images from all hosts (every host was running 2 instances of fio).
|
||||||
|
This is because Ceph has performance penalties related to running multiple clients over a single RBD image.
|
||||||
|
|
||||||
|
cephx_sign_messages was set to false during tests, RocksDB and Bluestore settings were left at defaults.
|
||||||
|
|
||||||
|
In fact, not that bad for Ceph. These servers are an example of well-balanced Ceph nodes.
|
||||||
|
However, CPU usage and I/O latency were through the roof, as usual.
|
||||||
|
|
||||||
|
Vitastor:
|
||||||
|
- T1Q1 write: 7087 iops (0.14ms latency)
|
||||||
|
- T1Q1 read: 6838 iops (0.145ms latency)
|
||||||
|
- T2Q64 write: 162000 iops, total CPU usage by OSDs about 3 virtual cores on each node
|
||||||
|
- T8Q64 read: 895000 iops, total CPU usage by OSDs about 4 virtual cores on each node
|
||||||
|
- Linear write (4M T1Q32): 2800 MB/s
|
||||||
|
- Linear read (4M T1Q32): 1500 MB/s
|
||||||
|
|
||||||
|
T8Q64 read test was conducted over 1 larger inode (3.2T) from all hosts (every host was running 2 instances of fio).
|
||||||
|
Vitastor has no performance penalties related to running multiple clients over a single inode.
|
||||||
|
If conducted from one node with all primary OSDs moved to other nodes the result was slightly lower (689000 iops),
|
||||||
|
this is because all operations resulted in network roundtrips between the client and the primary OSD.
|
||||||
|
When fio was colocated with OSDs (like in Ceph benchmarks above), 1/4 of the read workload actually
|
||||||
|
used the loopback network.
|
||||||
|
|
||||||
|
Vitastor was configured with: `--disable_data_fsync true --immediate_commit all --flusher_count 8
|
||||||
|
--disk_alignment 4096 --journal_block_size 4096 --meta_block_size 4096
|
||||||
|
--journal_no_same_sector_overwrites true --journal_sector_buffer_count 1024
|
||||||
|
--journal_size 16777216`.
|
||||||
|
|
||||||
|
### EC/XOR 2+1
|
||||||
|
|
||||||
|
Vitastor:
|
||||||
|
- T1Q1 write: 2808 iops (~0.355ms latency)
|
||||||
|
- T1Q1 read: 6190 iops (~0.16ms latency)
|
||||||
|
- T2Q64 write: 85500 iops, total CPU usage by OSDs about 3.4 virtual cores on each node
|
||||||
|
- T8Q64 read: 812000 iops, total CPU usage by OSDs about 4.7 virtual cores on each node
|
||||||
|
- Linear write (4M T1Q32): 3200 MB/s
|
||||||
|
- Linear read (4M T1Q32): 1800 MB/s
|
||||||
|
|
||||||
|
Ceph:
|
||||||
|
- T1Q1 write: 730 iops (~1.37ms latency)
|
||||||
|
- T1Q1 read: 1500 iops with cold cache (~0.66ms latency), 2300 iops after 2 minute metadata cache warmup (~0.435ms latency)
|
||||||
|
- T4Q128 write (4 RBD images): 45300 iops, total CPU usage by OSDs about 30 virtual cores on each node
|
||||||
|
- T8Q64 read (4 RBD images): 278600 iops, total CPU usage by OSDs about 40 virtual cores on each node
|
||||||
|
- Linear write (4M T1Q32): 1950 MB/s before preallocation, 2500 MB/s after preallocation
|
||||||
|
- Linear read (4M T1Q32): 2400 MB/s
|
||||||
|
|
||||||
|
### NBD
|
||||||
|
|
||||||
|
NBD is currently required to mount Vitastor via kernel, but it imposes additional overhead
|
||||||
|
due to additional copying between the kernel and userspace. This mostly hurts linear
|
||||||
|
bandwidth, not iops.
|
||||||
|
|
||||||
|
Vitastor with single-thread NBD on the same hardware:
|
||||||
|
- T1Q1 write: 6000 iops (0.166ms latency)
|
||||||
|
- T1Q1 read: 5518 iops (0.18ms latency)
|
||||||
|
- T1Q128 write: 94400 iops
|
||||||
|
- T1Q128 read: 103000 iops
|
||||||
|
- Linear write (4M T1Q128): 1266 MB/s (compared to 2800 MB/s via fio)
|
||||||
|
- Linear read (4M T1Q128): 975 MB/s (compared to 1500 MB/s via fio)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Debian
|
||||||
|
|
||||||
|
- Trust Vitastor package signing key:
|
||||||
|
`wget -q -O - https://vitastor.io/debian/pubkey | sudo apt-key add -`
|
||||||
|
- Add Vitastor package repository to your /etc/apt/sources.list:
|
||||||
|
- Debian 11 (Bullseye/Sid): `deb https://vitastor.io/debian bullseye main`
|
||||||
|
- Debian 10 (Buster): `deb https://vitastor.io/debian buster main`
|
||||||
|
- For Debian 10 (Buster) also enable backports repository:
|
||||||
|
`deb http://deb.debian.org/debian buster-backports main`
|
||||||
|
- Install packages: `apt update; apt install vitastor lp-solve etcd linux-image-amd64 qemu`
|
||||||
|
|
||||||
|
### CentOS
|
||||||
|
|
||||||
|
- Add Vitastor package repository:
|
||||||
|
- CentOS 7: `yum install https://vitastor.io/rpms/centos/7/vitastor-release-1.0-1.el7.noarch.rpm`
|
||||||
|
- CentOS 8: `dnf install https://vitastor.io/rpms/centos/8/vitastor-release-1.0-1.el8.noarch.rpm`
|
||||||
|
- Enable EPEL: `yum/dnf install epel-release`
|
||||||
|
- Enable additional CentOS repositories:
|
||||||
|
- CentOS 7: `yum install centos-release-scl`
|
||||||
|
- CentOS 8: `dnf install centos-release-advanced-virtualization`
|
||||||
|
- Enable elrepo-kernel:
|
||||||
|
- CentOS 7: `yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm`
|
||||||
|
- CentOS 8: `dnf install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm`
|
||||||
|
- Install packages: `yum/dnf install vitastor lpsolve etcd kernel-ml qemu-kvm`
|
||||||
|
|
||||||
|
### Building from Source
|
||||||
|
|
||||||
|
- Install Linux kernel 5.4 or newer, for io_uring support. 5.8 or later is highly recommended because
|
||||||
|
there is at least one known io_uring hang with 5.4 and an HP SmartArray controller.
|
||||||
|
- Install liburing 0.4 or newer and its headers.
|
||||||
|
- Install lp_solve.
|
||||||
|
- Install etcd, at least version 3.4.15. Earlier versions won't work because of various bugs,
|
||||||
|
for example [#12402](https://github.com/etcd-io/etcd/pull/12402). You can also take 3.4.13
|
||||||
|
with this specific fix from here: https://github.com/vitalif/etcd/, branch release-3.4.
|
||||||
|
- Install node.js 10 or newer.
|
||||||
|
- Install gcc and g++ 8.x or newer.
|
||||||
|
- Clone https://yourcmc.ru/git/vitalif/vitastor/ with submodules.
|
||||||
|
- Install QEMU 3.0+, get its source, begin to build it, stop the build and copy headers:
|
||||||
|
- `<qemu>/include` → `<vitastor>/qemu/include`
|
||||||
|
- Debian:
|
||||||
|
* Use qemu packages from the main repository
|
||||||
|
* `<qemu>/b/qemu/config-host.h` → `<vitastor>/qemu/b/qemu/config-host.h`
|
||||||
|
* `<qemu>/b/qemu/qapi` → `<vitastor>/qemu/b/qemu/qapi`
|
||||||
|
- CentOS 8:
|
||||||
|
* Use qemu packages from the Advanced-Virtualization repository. To enable it, run
|
||||||
|
`yum install centos-release-advanced-virtualization.noarch` and then `yum install qemu`
|
||||||
|
* `<qemu>/config-host.h` → `<vitastor>/qemu/b/qemu/config-host.h`
|
||||||
|
* For QEMU 3.0+: `<qemu>/qapi` → `<vitastor>/qemu/b/qemu/qapi`
|
||||||
|
* For QEMU 2.0+: `<qemu>/qapi-types.h` → `<vitastor>/qemu/b/qemu/qapi-types.h`
|
||||||
|
- `config-host.h` and `qapi` are required because they contain generated headers
|
||||||
|
- You can also rebuild QEMU with a patch that makes LD_PRELOAD unnecessary to load vitastor driver.
|
||||||
|
See `patches/qemu-*.*-vitastor.patch`.
|
||||||
|
- Install fio 3.7 or later, get its source and symlink it into `<vitastor>/fio`.
|
||||||
|
- Build & install Vitastor with `mkdir build && cd build && cmake .. && make -j8 && make install`.
|
||||||
|
Pay attention to the `QEMU_PLUGINDIR` cmake option - it must be set to `qemu-kvm` on RHEL.
|
||||||
|
|
||||||
|
## Running
|
||||||
|
|
||||||
|
Please note that startup procedure isn't currently simple - you specify configuration
|
||||||
|
and calculate disk offsets almost by hand. This will be fixed in near future.
|
||||||
|
|
||||||
|
- Get some SATA or NVMe SSDs with capacitors (server-grade drives). You can use desktop SSDs
|
||||||
|
with lazy fsync, but prepare for inferior single-thread latency.
|
||||||
|
- Get a fast network (at least 10 Gbit/s).
|
||||||
|
- Disable CPU powersaving: `cpupower idle-set -D 0 && cpupower frequency-set -g performance`.
|
||||||
|
- On the monitor hosts:
|
||||||
|
- Edit variables at the top of `/usr/lib/vitastor/mon/make-units.sh` to desired values.
|
||||||
|
- Create systemd units for the monitor and etcd: `/usr/lib/vitastor/mon/make-units.sh`
|
||||||
|
- Put etcd_address and osd_network into `/etc/vitastor/vitastor.conf`. Example:
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"etcd_address": ["10.200.1.10:2379","10.200.1.11:2379","10.200.1.12:2379"],
|
||||||
|
"osd_network": "10.200.1.0/24"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- Create systemd units for your OSDs: `/usr/lib/vitastor/mon/make-osd.sh /dev/disk/by-partuuid/XXX [/dev/disk/by-partuuid/YYY ...]`
|
||||||
|
- You can change OSD configuration in units or in `vitastor.conf`. Notable configuration variables:
|
||||||
|
- `disable_data_fsync 1` - only safe with server-grade drives with capacitors.
|
||||||
|
- `immediate_commit all` - use this if all your drives are server-grade.
|
||||||
|
If all OSDs have it set to all then you should also put the same value in etcd into /vitastor/config/global
|
||||||
|
- `disable_device_lock 1` - only required if you run multiple OSDs on one block device.
|
||||||
|
- `flusher_count 256` - flusher is a micro-thread that removes old data from the journal.
|
||||||
|
You don't have to worry about this parameter anymore, 256 is enough.
|
||||||
|
- `disk_alignment`, `journal_block_size`, `meta_block_size` should be set to the internal
|
||||||
|
block size of your SSDs which is 4096 on most drives.
|
||||||
|
- `journal_no_same_sector_overwrites true` prevents multiple overwrites of the same journal sector.
|
||||||
|
Most (99%) SSDs don't need this option. But Intel D3-4510 does because it doesn't like when you
|
||||||
|
overwrite the same sector twice in a short period of time. The setting forces Vitastor to never
|
||||||
|
overwrite the same journal sector twice in a row which makes D3-4510 almost happy. Not totally
|
||||||
|
happy, because overwrites of the same block can still happen in the metadata area... When this
|
||||||
|
setting is set, it is also required to raise `journal_sector_buffer_count` setting, which is the
|
||||||
|
number of dirty journal sectors that may be written to at the same time.
|
||||||
|
- `systemctl start vitastor.target` everywhere.
|
||||||
|
- Create global configuration in etcd: `etcdctl --endpoints=... put /vitastor/config/global '{"immediate_commit":"all"}'`
|
||||||
|
(if all your drives have capacitors).
|
||||||
|
- Create pool configuration in etcd: `etcdctl --endpoints=... put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":256,"failure_domain":"host"}}'`.
|
||||||
|
For jerasure pools the configuration should look like the following: `2:{"name":"ecpool","scheme":"jerasure","pg_size":4,"parity_chunks":2,"pg_minsize":2,"pg_count":256,"failure_domain":"host"}`.
|
||||||
|
- At this point, one of the monitors will configure PGs and OSDs will start them.
|
||||||
|
- You can check PG states with `etcdctl --endpoints=... get --prefix /vitastor/pg/state`. All PGs should become 'active'.
|
||||||
|
|
||||||
|
### Name an image
|
||||||
|
|
||||||
|
```
|
||||||
|
etcdctl --endpoints=<etcd> put /vitastor/config/inode/<pool>/<inode> '{"name":"<name>","size":<size>[,"parent_id":<parent_inode_number>][,"readonly":true]}'
|
||||||
|
```
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
etcdctl --endpoints=http://10.115.0.10:2379/v3 put /vitastor/config/inode/1/1 '{"name":"testimg","size":2147483648}'
|
||||||
|
```
|
||||||
|
|
||||||
|
If you specify parent_id the image becomes a CoW clone. I.e. all writes go to the new inode and reads first check it
|
||||||
|
and then upper layers. You can then make parent readonly by updating its entry with `"readonly":true` for safety and
|
||||||
|
basically treat it as a snapshot.
|
||||||
|
|
||||||
|
So to create a snapshot you basically rename the previous upper layer (for example from testimg to testimg@0), make it readonly
|
||||||
|
and create a new top layer with the original name (testimg) and the previous one as a parent.
|
||||||
|
|
||||||
|
### Run fio benchmarks
|
||||||
|
|
||||||
|
fio command example:
|
||||||
|
|
||||||
|
```
|
||||||
|
fio -thread -ioengine=libfio_vitastor.so -name=test -bs=4M -direct=1 -iodepth=16 -rw=write -etcd=10.115.0.10:2379/v3 -image=testimg
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't want to access your image by name, you can specify pool number, inode number and size
|
||||||
|
(`-pool=1 -inode=1 -size=400G`) instead of the image name (`-image=testimg`).
|
||||||
|
|
||||||
|
### Upload VM image
|
||||||
|
|
||||||
|
Use qemu-img and `vitastor:etcd_host=<HOST>:image=<IMAGE>` disk filename. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
qemu-img convert -f qcow2 debian10.qcow2 -p -O raw 'vitastor:etcd_host=10.115.0.10\:2379/v3:image=testimg'
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that the command requires to be run with `LD_PRELOAD=/usr/lib/x86_64-linux-gnu/qemu/block-vitastor.so qemu-img ...`
|
||||||
|
if you use unmodified QEMU.
|
||||||
|
|
||||||
|
You can also specify `:pool=<POOL>:inode=<INODE>:size=<SIZE>` instead of `:image=<IMAGE>`
|
||||||
|
if you don't want to use inode metadata.
|
||||||
|
|
||||||
|
### Start a VM
|
||||||
|
|
||||||
|
Run QEMU with `-drive file=vitastor:etcd_host=<HOST>:image=<IMAGE>` and use 4 KB physical block size.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
qemu-system-x86_64 -enable-kvm -m 1024
|
||||||
|
-drive 'file=vitastor:etcd_host=10.115.0.10\:2379/v3:image=testimg',format=raw,if=none,id=drive-virtio-disk0,cache=none
|
||||||
|
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,write-cache=off,physical_block_size=4096,logical_block_size=512
|
||||||
|
-vnc 0.0.0.0:0
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also specify `:pool=<POOL>:inode=<INODE>:size=<SIZE>` instead of `:image=<IMAGE>`,
|
||||||
|
just like in qemu-img.
|
||||||
|
|
||||||
|
### Remove inode
|
||||||
|
|
||||||
|
Use vitastor-rm / vitastor-cli rm-data. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
vitastor-cli rm-data --etcd_address 10.115.0.10:2379/v3 --pool 1 --inode 1 --parallel_osds 16 --iodepth 32
|
||||||
|
```
|
||||||
|
|
||||||
|
### NBD
|
||||||
|
|
||||||
|
To create a local block device for a Vitastor image, use NBD. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
vitastor-nbd map --etcd_address 10.115.0.10:2379/v3 --image testimg
|
||||||
|
```
|
||||||
|
|
||||||
|
It will output the device name, like /dev/nbd0 which you can then format and mount as a normal block device.
|
||||||
|
|
||||||
|
Again, you can use `--pool <POOL> --inode <INODE> --size <SIZE>` insteaf of `--image <IMAGE>` if you want.
|
||||||
|
|
||||||
|
### Kubernetes
|
||||||
|
|
||||||
|
Vitastor has a CSI plugin for Kubernetes which supports RWO volumes.
|
||||||
|
|
||||||
|
To deploy it, take manifests from [csi/deploy/](csi/deploy/) directory, put your
|
||||||
|
Vitastor configuration in [csi/deploy/001-csi-config-map.yaml](001-csi-config-map.yaml),
|
||||||
|
configure storage class in [csi/deploy/009-storage-class.yaml](009-storage-class.yaml)
|
||||||
|
and apply all `NNN-*.yaml` manifests to your Kubernetes installation:
|
||||||
|
|
||||||
|
```
|
||||||
|
for i in ./???-*.yaml; do kubectl apply -f $i; done
|
||||||
|
```
|
||||||
|
|
||||||
|
After that you'll be able to create PersistentVolumes. See example in [csi/deploy/example-pvc.yaml](csi/deploy/example-pvc.yaml).
|
||||||
|
|
||||||
|
### OpenStack
|
||||||
|
|
||||||
|
To enable Vitastor support in an OpenStack installation:
|
||||||
|
|
||||||
|
- Install vitastor-client, patched QEMU and libvirt packages from Vitastor DEB or RPM repository
|
||||||
|
- Use `patches/nova-21.diff` or `patches/nova-23.diff` to patch your Nova installation.
|
||||||
|
Patch 21 fits Nova 21-22, patch 23 fits Nova 23-24.
|
||||||
|
- Install `patches/cinder-vitastor.py` as `..../cinder/volume/drivers/vitastor.py`
|
||||||
|
- Define a volume type in cinder.conf (see below)
|
||||||
|
- Block network access from VMs to Vitastor network (to OSDs and etcd), because Vitastor doesn't support authentication (yet)
|
||||||
|
- Restart Cinder and Nova
|
||||||
|
|
||||||
|
Cinder volume type configuration example:
|
||||||
|
|
||||||
|
```
|
||||||
|
[DEFAULT]
|
||||||
|
enabled_backends = lvmdriver-1, vitastor-testcluster
|
||||||
|
# ...
|
||||||
|
|
||||||
|
[vitastor-testcluster]
|
||||||
|
volume_driver = cinder.volume.drivers.vitastor.VitastorDriver
|
||||||
|
volume_backend_name = vitastor-testcluster
|
||||||
|
image_volume_cache_enabled = True
|
||||||
|
volume_clear = none
|
||||||
|
vitastor_etcd_address = 192.168.7.2:2379
|
||||||
|
vitastor_etcd_prefix =
|
||||||
|
vitastor_config_path = /etc/vitastor/vitastor.conf
|
||||||
|
vitastor_pool_id = 1
|
||||||
|
image_upload_use_cinder_backend = True
|
||||||
|
```
|
||||||
|
|
||||||
|
To put Glance images in Vitastor, use [https://docs.openstack.org/cinder/pike/admin/blockstorage-volume-backed-image.html](volume-backed images),
|
||||||
|
although the support has not been verified yet.
|
||||||
|
|
||||||
|
### Proxmox
|
||||||
|
|
||||||
|
To enable Vitastor support in Proxmox Virtual Environment (6.4 and 7.1 are supported):
|
||||||
|
|
||||||
|
- Add the corresponding Vitastor Debian repository into sources.list on Proxmox hosts
|
||||||
|
(buster for 6.4, bullseye for 7.1)
|
||||||
|
- Install vitastor-client, pve-qemu-kvm, pve-storage-vitastor (* or see note) packages from Vitastor repository
|
||||||
|
- Define storage in `/etc/pve/storage.cfg` (see below)
|
||||||
|
- Block network access from VMs to Vitastor network (to OSDs and etcd), because Vitastor doesn't support authentication (yet)
|
||||||
|
- Restart pvedaemon: `systemctl restart pvedaemon`
|
||||||
|
|
||||||
|
`/etc/pve/storage.cfg` example (the only required option is vitastor_pool, all others
|
||||||
|
are listed below with their default values):
|
||||||
|
|
||||||
|
```
|
||||||
|
vitastor: vitastor
|
||||||
|
# pool to put new images into
|
||||||
|
vitastor_pool testpool
|
||||||
|
# path to the configuration file
|
||||||
|
vitastor_config_path /etc/vitastor/vitastor.conf
|
||||||
|
# etcd address(es), required only if missing in the configuration file
|
||||||
|
vitastor_etcd_address 192.168.7.2:2379/v3
|
||||||
|
# prefix for keys in etcd
|
||||||
|
vitastor_etcd_prefix /vitastor
|
||||||
|
# prefix for images
|
||||||
|
vitastor_prefix pve/
|
||||||
|
# use NBD mounter (only required for containers)
|
||||||
|
vitastor_nbd 0
|
||||||
|
```
|
||||||
|
|
||||||
|
\* Note: you can also manually copy [patches/PVE_VitastorPlugin.pm](patches/PVE_VitastorPlugin.pm) to Proxmox hosts
|
||||||
|
as `/usr/share/perl5/PVE/Storage/Custom/VitastorPlugin.pm` instead of installing pve-storage-vitastor.
|
||||||
|
|
||||||
|
## Known Problems
|
||||||
|
|
||||||
|
- Object deletion requests may currently lead to 'incomplete' objects in EC pools
|
||||||
|
if your OSDs crash during deletion because proper handling of object cleanup
|
||||||
|
in a cluster should be "three-phase" and it's currently not implemented.
|
||||||
|
Just repeat the removal request again in this case.
|
||||||
|
|
||||||
|
## Implementation Principles
|
||||||
|
|
||||||
|
- I like architecturally simple solutions. Vitastor is and will always be designed
|
||||||
|
exactly like that.
|
||||||
|
- I also like reinventing the wheel to some extent, like writing my own HTTP client
|
||||||
|
for etcd interaction instead of using prebuilt libraries, because in this case
|
||||||
|
I'm confident about what my code does and what it doesn't do.
|
||||||
|
- I don't care about C++ "best practices" like RAII or proper inheritance or usage of
|
||||||
|
smart pointers or whatever and I don't intend to change my mind, so if you're here
|
||||||
|
looking for ideal reference C++ code, this probably isn't the right place.
|
||||||
|
- I like node.js better than any other dynamically-typed language interpreter
|
||||||
|
because it's faster than any other interpreter in the world, has neutral C-like
|
||||||
|
syntax and built-in event loop. That's why Monitor is implemented in node.js.
|
||||||
|
|
||||||
|
## Author and License
|
||||||
|
|
||||||
|
Copyright (c) Vitaliy Filippov (vitalif [at] yourcmc.ru), 2019+
|
||||||
|
|
||||||
|
Join Vitastor Telegram Chat: https://t.me/vitastor
|
||||||
|
|
||||||
|
All server-side code (OSD, Monitor and so on) is licensed under the terms of
|
||||||
|
Vitastor Network Public License 1.1 (VNPL 1.1), a copyleft license based on
|
||||||
|
GNU GPLv3.0 with the additional "Network Interaction" clause which requires
|
||||||
|
opensourcing all programs directly or indirectly interacting with Vitastor
|
||||||
|
through a computer network and expressly designed to be used in conjunction
|
||||||
|
with it ("Proxy Programs"). Proxy Programs may be made public not only under
|
||||||
|
the terms of the same license, but also under the terms of any GPL-Compatible
|
||||||
|
Free Software License, as listed by the Free Software Foundation.
|
||||||
|
This is a stricter copyleft license than the Affero GPL.
|
||||||
|
|
||||||
|
Please note that VNPL doesn't require you to open the code of proprietary
|
||||||
|
software running inside a VM if it's not specially designed to be used with
|
||||||
|
Vitastor.
|
||||||
|
|
||||||
|
Basically, you can't use the software in a proprietary environment to provide
|
||||||
|
its functionality to users without opensourcing all intermediary components
|
||||||
|
standing between the user and Vitastor or purchasing a commercial license
|
||||||
|
from the author 😀.
|
||||||
|
|
||||||
|
Client libraries (cluster_client and so on) are dual-licensed under the same
|
||||||
|
VNPL 1.1 and also GNU GPL 2.0 or later to allow for compatibility with GPLed
|
||||||
|
software like QEMU and fio.
|
||||||
|
|
||||||
|
You can find the full text of VNPL-1.1 in the file [VNPL-1.1.txt](VNPL-1.1.txt).
|
||||||
|
GPL 2.0 is also included in this repository as [GPL-2.0.txt](GPL-2.0.txt).
|
|
@ -0,0 +1,648 @@
|
||||||
|
VITASTOR NETWORK PUBLIC LICENSE
|
||||||
|
Version 1.1, 6 February 2021
|
||||||
|
|
||||||
|
Copyright (C) 2021 Vitaliy Filippov <vitalif@yourcmc.ru>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The Vitastor Network Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
GNU General Public Licenses and Vitastor Network Public License are
|
||||||
|
intended to guarantee your freedom to share and change all versions
|
||||||
|
of a program--to make sure it remains free software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. GNU General Public Licenses and Vitastor Network Public License
|
||||||
|
are designed to make sure that you have the freedom to distribute copies
|
||||||
|
of free software (and charge for them if you wish), that you receive
|
||||||
|
source code or can get it if you want it, that you can change the software
|
||||||
|
or use pieces of it in new free programs, and that you know you can do these
|
||||||
|
things.
|
||||||
|
|
||||||
|
Developers that use GNU General Public Licenses and Vitastor
|
||||||
|
Network Public License protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public. Even the GNU Affero General Public License
|
||||||
|
permits running a modified version in a closed environment where
|
||||||
|
public users only interact with it through a closed-source proxy, again,
|
||||||
|
without making the program and the proxy available to the public
|
||||||
|
for free.
|
||||||
|
|
||||||
|
The Vitastor Network Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified program and the proxy stays
|
||||||
|
available to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the original program and all other programs
|
||||||
|
communicating with it running there to the users of that server.
|
||||||
|
Therefore, public use of a modified version, on a server accessible
|
||||||
|
directly or indirectly to the public, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 1 of the Vitastor Network Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction.
|
||||||
|
|
||||||
|
A "Proxy Program" means a separate program which is specially designed to
|
||||||
|
be used in conjunction with the covered work and interacts with it directly
|
||||||
|
or indirectly through any kind of API (application programming interfaces),
|
||||||
|
a computer network, an imitation of such network, or another Proxy Program
|
||||||
|
itself.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you provide any user
|
||||||
|
with an opportunity to interact with the covered work through a computer
|
||||||
|
network, an imitation of such network, or any number of "Proxy Programs",
|
||||||
|
you must prominently offer that user an opportunity to receive the
|
||||||
|
Corresponding Source of the covered work and all Proxy Programs from a
|
||||||
|
network server at no charge, through some standard or customary means of
|
||||||
|
facilitating copying of software. The Corresponding Source for the covered
|
||||||
|
work must be made available under the conditions of this License, and
|
||||||
|
the Corresponding Source for all Proxy Programs must be made available
|
||||||
|
under the conditions of either this License or any GPL-Compatible
|
||||||
|
Free Software License, as described by the Free Software Foundation
|
||||||
|
in their "GPL-Compatible License List".
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
Vitastor Author may publish revised and/or new versions of
|
||||||
|
the Vitastor Network Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the Vitastor Network
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version. If the Program does not specify a version
|
||||||
|
number of the Vitastor Network Public License, you may choose any version
|
||||||
|
ever published.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the Vitastor Network Public License as published by
|
||||||
|
the Vitastor Author, either version 1 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
Vitastor Network Public License for more details.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
|
@ -1,61 +0,0 @@
|
||||||
#include "blockstore_impl.h"
|
|
||||||
|
|
||||||
blockstore_t::blockstore_t(blockstore_config_t & config, ring_loop_t *ringloop)
|
|
||||||
{
|
|
||||||
impl = new blockstore_impl_t(config, ringloop);
|
|
||||||
}
|
|
||||||
|
|
||||||
blockstore_t::~blockstore_t()
|
|
||||||
{
|
|
||||||
delete impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_t::loop()
|
|
||||||
{
|
|
||||||
impl->loop();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool blockstore_t::is_started()
|
|
||||||
{
|
|
||||||
return impl->is_started();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool blockstore_t::is_stalled()
|
|
||||||
{
|
|
||||||
return impl->is_stalled();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool blockstore_t::is_safe_to_stop()
|
|
||||||
{
|
|
||||||
return impl->is_safe_to_stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_t::enqueue_op(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
impl->enqueue_op(op, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_t::enqueue_op_first(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
impl->enqueue_op(op, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_map<object_id, uint64_t> & blockstore_t::get_unstable_writes()
|
|
||||||
{
|
|
||||||
return impl->unstable_writes;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t blockstore_t::get_block_size()
|
|
||||||
{
|
|
||||||
return impl->get_block_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t blockstore_t::get_block_count()
|
|
||||||
{
|
|
||||||
return impl->get_block_count();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t blockstore_t::get_disk_alignment()
|
|
||||||
{
|
|
||||||
return impl->get_disk_alignment();
|
|
||||||
}
|
|
|
@ -1,458 +0,0 @@
|
||||||
#include "blockstore_impl.h"
|
|
||||||
|
|
||||||
blockstore_impl_t::blockstore_impl_t(blockstore_config_t & config, ring_loop_t *ringloop)
|
|
||||||
{
|
|
||||||
assert(sizeof(blockstore_op_private_t) <= BS_OP_PRIVATE_DATA_SIZE);
|
|
||||||
this->ringloop = ringloop;
|
|
||||||
ring_consumer.loop = [this]() { loop(); };
|
|
||||||
ringloop->register_consumer(ring_consumer);
|
|
||||||
initialized = 0;
|
|
||||||
zero_object = (uint8_t*)memalign(MEM_ALIGNMENT, block_size);
|
|
||||||
data_fd = meta_fd = journal.fd = -1;
|
|
||||||
parse_config(config);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
open_data();
|
|
||||||
open_meta();
|
|
||||||
open_journal();
|
|
||||||
calc_lengths();
|
|
||||||
data_alloc = new allocator(block_count);
|
|
||||||
}
|
|
||||||
catch (std::exception & e)
|
|
||||||
{
|
|
||||||
if (data_fd >= 0)
|
|
||||||
close(data_fd);
|
|
||||||
if (meta_fd >= 0 && meta_fd != data_fd)
|
|
||||||
close(meta_fd);
|
|
||||||
if (journal.fd >= 0 && journal.fd != meta_fd)
|
|
||||||
close(journal.fd);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
flusher = new journal_flusher_t(flusher_count, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
blockstore_impl_t::~blockstore_impl_t()
|
|
||||||
{
|
|
||||||
delete data_alloc;
|
|
||||||
delete flusher;
|
|
||||||
free(zero_object);
|
|
||||||
ringloop->unregister_consumer(ring_consumer);
|
|
||||||
if (data_fd >= 0)
|
|
||||||
close(data_fd);
|
|
||||||
if (meta_fd >= 0 && meta_fd != data_fd)
|
|
||||||
close(meta_fd);
|
|
||||||
if (journal.fd >= 0 && journal.fd != meta_fd)
|
|
||||||
close(journal.fd);
|
|
||||||
if (metadata_buffer)
|
|
||||||
free(metadata_buffer);
|
|
||||||
if (clean_bitmap)
|
|
||||||
free(clean_bitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool blockstore_impl_t::is_started()
|
|
||||||
{
|
|
||||||
return initialized == 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool blockstore_impl_t::is_stalled()
|
|
||||||
{
|
|
||||||
return queue_stall;
|
|
||||||
}
|
|
||||||
|
|
||||||
// main event loop - produce requests
|
|
||||||
void blockstore_impl_t::loop()
|
|
||||||
{
|
|
||||||
// FIXME: initialized == 10 is ugly
|
|
||||||
if (initialized != 10)
|
|
||||||
{
|
|
||||||
// read metadata, then journal
|
|
||||||
if (initialized == 0)
|
|
||||||
{
|
|
||||||
metadata_init_reader = new blockstore_init_meta(this);
|
|
||||||
initialized = 1;
|
|
||||||
}
|
|
||||||
if (initialized == 1)
|
|
||||||
{
|
|
||||||
int res = metadata_init_reader->loop();
|
|
||||||
if (!res)
|
|
||||||
{
|
|
||||||
delete metadata_init_reader;
|
|
||||||
metadata_init_reader = NULL;
|
|
||||||
journal_init_reader = new blockstore_init_journal(this);
|
|
||||||
initialized = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (initialized == 2)
|
|
||||||
{
|
|
||||||
int res = journal_init_reader->loop();
|
|
||||||
if (!res)
|
|
||||||
{
|
|
||||||
delete journal_init_reader;
|
|
||||||
journal_init_reader = NULL;
|
|
||||||
initialized = 10;
|
|
||||||
ringloop->wakeup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// try to submit ops
|
|
||||||
unsigned initial_ring_space = ringloop->space_left();
|
|
||||||
auto cur_sync = in_progress_syncs.begin();
|
|
||||||
while (cur_sync != in_progress_syncs.end())
|
|
||||||
{
|
|
||||||
continue_sync(*cur_sync++);
|
|
||||||
}
|
|
||||||
auto cur = submit_queue.begin();
|
|
||||||
int has_writes = 0;
|
|
||||||
while (cur != submit_queue.end())
|
|
||||||
{
|
|
||||||
auto op_ptr = cur;
|
|
||||||
auto op = *(cur++);
|
|
||||||
// FIXME: This needs some simplification
|
|
||||||
// Writes should not block reads if the ring is not full and reads don't depend on them
|
|
||||||
// In all other cases we should stop submission
|
|
||||||
if (PRIV(op)->wait_for)
|
|
||||||
{
|
|
||||||
check_wait(op);
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
if (PRIV(op)->wait_for)
|
|
||||||
{
|
|
||||||
printf("still waiting for %d\n", PRIV(op)->wait_for);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (PRIV(op)->wait_for == WAIT_SQE)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (PRIV(op)->wait_for)
|
|
||||||
{
|
|
||||||
if (op->opcode == BS_OP_WRITE || op->opcode == BS_OP_DELETE)
|
|
||||||
{
|
|
||||||
has_writes = 2;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unsigned ring_space = ringloop->space_left();
|
|
||||||
unsigned prev_sqe_pos = ringloop->save();
|
|
||||||
int dequeue_op = 0;
|
|
||||||
if (op->opcode == BS_OP_READ)
|
|
||||||
{
|
|
||||||
dequeue_op = dequeue_read(op);
|
|
||||||
}
|
|
||||||
else if (op->opcode == BS_OP_WRITE || op->opcode == BS_OP_DELETE)
|
|
||||||
{
|
|
||||||
if (has_writes == 2)
|
|
||||||
{
|
|
||||||
// Some writes could not be submitted
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dequeue_op = dequeue_write(op);
|
|
||||||
has_writes = dequeue_op ? 1 : 2;
|
|
||||||
}
|
|
||||||
else if (op->opcode == BS_OP_SYNC)
|
|
||||||
{
|
|
||||||
// wait for all small writes to be submitted
|
|
||||||
// wait for all big writes to complete, submit data device fsync
|
|
||||||
// wait for the data device fsync to complete, then submit journal writes for big writes
|
|
||||||
// then submit an fsync operation
|
|
||||||
if (has_writes)
|
|
||||||
{
|
|
||||||
// Can't submit SYNC before previous writes
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
dequeue_op = dequeue_sync(op);
|
|
||||||
}
|
|
||||||
else if (op->opcode == BS_OP_STABLE)
|
|
||||||
{
|
|
||||||
dequeue_op = dequeue_stable(op);
|
|
||||||
}
|
|
||||||
else if (op->opcode == BS_OP_ROLLBACK)
|
|
||||||
{
|
|
||||||
dequeue_op = dequeue_rollback(op);
|
|
||||||
}
|
|
||||||
else if (op->opcode == BS_OP_LIST)
|
|
||||||
{
|
|
||||||
process_list(op);
|
|
||||||
dequeue_op = true;
|
|
||||||
}
|
|
||||||
if (dequeue_op)
|
|
||||||
{
|
|
||||||
submit_queue.erase(op_ptr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ringloop->restore(prev_sqe_pos);
|
|
||||||
if (PRIV(op)->wait_for == WAIT_SQE)
|
|
||||||
{
|
|
||||||
PRIV(op)->wait_detail = 1 + ring_space;
|
|
||||||
// ring is full, stop submission
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!readonly)
|
|
||||||
{
|
|
||||||
flusher->loop();
|
|
||||||
}
|
|
||||||
int ret = ringloop->submit();
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(std::string("io_uring_submit: ") + strerror(-ret));
|
|
||||||
}
|
|
||||||
if ((initial_ring_space - ringloop->space_left()) > 0)
|
|
||||||
{
|
|
||||||
live = true;
|
|
||||||
}
|
|
||||||
queue_stall = !live && !ringloop->get_loop_again();
|
|
||||||
live = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool blockstore_impl_t::is_safe_to_stop()
|
|
||||||
{
|
|
||||||
// It's safe to stop blockstore when there are no in-flight operations,
|
|
||||||
// no in-progress syncs and flusher isn't doing anything
|
|
||||||
if (submit_queue.size() > 0 || in_progress_syncs.size() > 0 || !readonly && flusher->is_active())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (unsynced_big_writes.size() > 0 || unsynced_small_writes.size() > 0)
|
|
||||||
{
|
|
||||||
if (!readonly && !stop_sync_submitted)
|
|
||||||
{
|
|
||||||
// We should sync the blockstore before unmounting
|
|
||||||
blockstore_op_t *op = new blockstore_op_t;
|
|
||||||
op->opcode = BS_OP_SYNC;
|
|
||||||
op->buf = NULL;
|
|
||||||
op->callback = [](blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
delete op;
|
|
||||||
};
|
|
||||||
enqueue_op(op);
|
|
||||||
stop_sync_submitted = true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::check_wait(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
if (PRIV(op)->wait_for == WAIT_SQE)
|
|
||||||
{
|
|
||||||
if (ringloop->space_left() < PRIV(op)->wait_detail)
|
|
||||||
{
|
|
||||||
// stop submission if there's still no free space
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PRIV(op)->wait_for = 0;
|
|
||||||
}
|
|
||||||
else if (PRIV(op)->wait_for == WAIT_IN_FLIGHT)
|
|
||||||
{
|
|
||||||
auto dirty_it = dirty_db.find((obj_ver_id){
|
|
||||||
.oid = op->oid,
|
|
||||||
.version = PRIV(op)->wait_detail,
|
|
||||||
});
|
|
||||||
if (dirty_it != dirty_db.end() && IS_IN_FLIGHT(dirty_it->second.state))
|
|
||||||
{
|
|
||||||
// do not submit
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PRIV(op)->wait_for = 0;
|
|
||||||
}
|
|
||||||
else if (PRIV(op)->wait_for == WAIT_JOURNAL)
|
|
||||||
{
|
|
||||||
if (journal.used_start == PRIV(op)->wait_detail)
|
|
||||||
{
|
|
||||||
// do not submit
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PRIV(op)->wait_for = 0;
|
|
||||||
}
|
|
||||||
else if (PRIV(op)->wait_for == WAIT_JOURNAL_BUFFER)
|
|
||||||
{
|
|
||||||
int next = ((journal.cur_sector + 1) % journal.sector_count);
|
|
||||||
if (journal.sector_info[next].usage_count > 0 ||
|
|
||||||
journal.sector_info[next].dirty)
|
|
||||||
{
|
|
||||||
// do not submit
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PRIV(op)->wait_for = 0;
|
|
||||||
}
|
|
||||||
else if (PRIV(op)->wait_for == WAIT_FREE)
|
|
||||||
{
|
|
||||||
if (!data_alloc->get_free_count() && !flusher->is_active())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PRIV(op)->wait_for = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::runtime_error("BUG: op->wait_for value is unexpected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::enqueue_op(blockstore_op_t *op, bool first)
|
|
||||||
{
|
|
||||||
if (op->opcode < BS_OP_MIN || op->opcode > BS_OP_MAX ||
|
|
||||||
((op->opcode == BS_OP_READ || op->opcode == BS_OP_WRITE) && (
|
|
||||||
op->offset >= block_size ||
|
|
||||||
op->len > block_size-op->offset ||
|
|
||||||
(op->len % disk_alignment)
|
|
||||||
)) ||
|
|
||||||
readonly && op->opcode != BS_OP_READ ||
|
|
||||||
first && op->opcode == BS_OP_WRITE)
|
|
||||||
{
|
|
||||||
// Basic verification not passed
|
|
||||||
op->retval = -EINVAL;
|
|
||||||
op->callback(op);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (op->opcode == BS_OP_SYNC_STAB_ALL)
|
|
||||||
{
|
|
||||||
std::function<void(blockstore_op_t*)> *old_callback = new std::function<void(blockstore_op_t*)>(op->callback);
|
|
||||||
op->opcode = BS_OP_SYNC;
|
|
||||||
op->callback = [this, old_callback](blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
if (op->retval >= 0 && unstable_writes.size() > 0)
|
|
||||||
{
|
|
||||||
op->opcode = BS_OP_STABLE;
|
|
||||||
op->len = unstable_writes.size();
|
|
||||||
obj_ver_id *vers = new obj_ver_id[op->len];
|
|
||||||
op->buf = vers;
|
|
||||||
int i = 0;
|
|
||||||
for (auto it = unstable_writes.begin(); it != unstable_writes.end(); it++, i++)
|
|
||||||
{
|
|
||||||
vers[i] = {
|
|
||||||
.oid = it->first,
|
|
||||||
.version = it->second,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
unstable_writes.clear();
|
|
||||||
op->callback = [this, old_callback](blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
obj_ver_id *vers = (obj_ver_id*)op->buf;
|
|
||||||
delete[] vers;
|
|
||||||
op->buf = NULL;
|
|
||||||
(*old_callback)(op);
|
|
||||||
delete old_callback;
|
|
||||||
};
|
|
||||||
this->enqueue_op(op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(*old_callback)(op);
|
|
||||||
delete old_callback;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (op->opcode == BS_OP_WRITE && !enqueue_write(op))
|
|
||||||
{
|
|
||||||
op->callback(op);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (0 && op->opcode == BS_OP_SYNC && immediate_commit)
|
|
||||||
{
|
|
||||||
op->retval = 0;
|
|
||||||
op->callback(op);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Call constructor without allocating memory. We'll call destructor before returning op back
|
|
||||||
new ((void*)op->private_data) blockstore_op_private_t;
|
|
||||||
PRIV(op)->wait_for = 0;
|
|
||||||
PRIV(op)->sync_state = 0;
|
|
||||||
PRIV(op)->pending_ops = 0;
|
|
||||||
if (!first)
|
|
||||||
{
|
|
||||||
submit_queue.push_back(op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
submit_queue.push_front(op);
|
|
||||||
}
|
|
||||||
ringloop->wakeup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::process_list(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
// Count objects
|
|
||||||
uint32_t list_pg = op->offset;
|
|
||||||
uint32_t pg_count = op->len;
|
|
||||||
uint64_t parity_block_size = op->oid.stripe;
|
|
||||||
if (pg_count != 0 && (parity_block_size < MIN_BLOCK_SIZE || list_pg >= pg_count))
|
|
||||||
{
|
|
||||||
op->retval = -EINVAL;
|
|
||||||
FINISH_OP(op);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uint64_t stable_count = 0;
|
|
||||||
if (pg_count > 0)
|
|
||||||
{
|
|
||||||
for (auto it = clean_db.begin(); it != clean_db.end(); it++)
|
|
||||||
{
|
|
||||||
uint32_t pg = (it->first.inode + it->first.stripe / parity_block_size) % pg_count;
|
|
||||||
if (pg == list_pg)
|
|
||||||
{
|
|
||||||
stable_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stable_count = clean_db.size();
|
|
||||||
}
|
|
||||||
uint64_t total_count = stable_count;
|
|
||||||
for (auto it = dirty_db.begin(); it != dirty_db.end(); it++)
|
|
||||||
{
|
|
||||||
if (!pg_count || ((it->first.oid.inode + it->first.oid.stripe / parity_block_size) % pg_count) == list_pg)
|
|
||||||
{
|
|
||||||
if (IS_STABLE(it->second.state))
|
|
||||||
{
|
|
||||||
stable_count++;
|
|
||||||
}
|
|
||||||
total_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Allocate memory
|
|
||||||
op->version = stable_count;
|
|
||||||
op->retval = total_count;
|
|
||||||
op->buf = malloc(sizeof(obj_ver_id) * total_count);
|
|
||||||
if (!op->buf)
|
|
||||||
{
|
|
||||||
op->retval = -ENOMEM;
|
|
||||||
FINISH_OP(op);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
obj_ver_id *vers = (obj_ver_id*)op->buf;
|
|
||||||
int i = 0;
|
|
||||||
for (auto it = clean_db.begin(); it != clean_db.end(); it++)
|
|
||||||
{
|
|
||||||
if (!pg_count || ((it->first.inode + it->first.stripe / parity_block_size) % pg_count) == list_pg)
|
|
||||||
{
|
|
||||||
vers[i++] = {
|
|
||||||
.oid = it->first,
|
|
||||||
.version = it->second.version,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int j = stable_count;
|
|
||||||
for (auto it = dirty_db.begin(); it != dirty_db.end(); it++)
|
|
||||||
{
|
|
||||||
if (!pg_count || ((it->first.oid.inode + it->first.oid.stripe / parity_block_size) % pg_count) == list_pg)
|
|
||||||
{
|
|
||||||
if (IS_STABLE(it->second.state))
|
|
||||||
{
|
|
||||||
vers[i++] = it->first;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vers[j++] = it->first;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FINISH_OP(op);
|
|
||||||
}
|
|
|
@ -1,186 +0,0 @@
|
||||||
#include "blockstore_impl.h"
|
|
||||||
|
|
||||||
blockstore_journal_check_t::blockstore_journal_check_t(blockstore_impl_t *bs)
|
|
||||||
{
|
|
||||||
this->bs = bs;
|
|
||||||
sectors_required = 0;
|
|
||||||
next_pos = bs->journal.next_free;
|
|
||||||
next_sector = bs->journal.cur_sector;
|
|
||||||
next_in_pos = bs->journal.in_sector_pos;
|
|
||||||
right_dir = next_pos >= bs->journal.used_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we can write <required> entries of <size> bytes and <data_after> data bytes after them to the journal
|
|
||||||
int blockstore_journal_check_t::check_available(blockstore_op_t *op, int required, int size, int data_after)
|
|
||||||
{
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
int fits = (bs->journal.block_size - next_in_pos) / size;
|
|
||||||
if (fits > 0)
|
|
||||||
{
|
|
||||||
required -= fits;
|
|
||||||
next_in_pos += fits * size;
|
|
||||||
sectors_required++;
|
|
||||||
}
|
|
||||||
else if (bs->journal.sector_info[next_sector].dirty)
|
|
||||||
{
|
|
||||||
// sectors_required is more like "sectors to write"
|
|
||||||
sectors_required++;
|
|
||||||
}
|
|
||||||
if (required <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
next_pos = next_pos + bs->journal.block_size;
|
|
||||||
if (next_pos >= bs->journal.len)
|
|
||||||
{
|
|
||||||
next_pos = bs->journal.block_size;
|
|
||||||
right_dir = false;
|
|
||||||
}
|
|
||||||
next_in_pos = 0;
|
|
||||||
if (bs->journal.sector_info[next_sector].usage_count > 0 ||
|
|
||||||
bs->journal.sector_info[next_sector].dirty)
|
|
||||||
{
|
|
||||||
next_sector = ((next_sector + 1) % bs->journal.sector_count);
|
|
||||||
}
|
|
||||||
if (bs->journal.sector_info[next_sector].usage_count > 0 ||
|
|
||||||
bs->journal.sector_info[next_sector].dirty)
|
|
||||||
{
|
|
||||||
// No memory buffer available. Wait for it.
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("next journal buffer %d is still dirty=%d used=%d\n", next_sector,
|
|
||||||
bs->journal.sector_info[next_sector].dirty, bs->journal.sector_info[next_sector].usage_count);
|
|
||||||
#endif
|
|
||||||
PRIV(op)->wait_for = WAIT_JOURNAL_BUFFER;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (data_after > 0)
|
|
||||||
{
|
|
||||||
next_pos = next_pos + data_after;
|
|
||||||
if (next_pos > bs->journal.len)
|
|
||||||
{
|
|
||||||
next_pos = bs->journal.block_size + data_after;
|
|
||||||
right_dir = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!right_dir && next_pos >= bs->journal.used_start-bs->journal.block_size)
|
|
||||||
{
|
|
||||||
// No space in the journal. Wait until used_start changes.
|
|
||||||
printf(
|
|
||||||
"Ran out of journal space (free space: %lu bytes)\n",
|
|
||||||
(bs->journal.next_free >= bs->journal.used_start
|
|
||||||
? bs->journal.len-bs->journal.block_size - (bs->journal.next_free-bs->journal.used_start)
|
|
||||||
: bs->journal.used_start - bs->journal.next_free)
|
|
||||||
);
|
|
||||||
PRIV(op)->wait_for = WAIT_JOURNAL;
|
|
||||||
bs->flusher->force_start();
|
|
||||||
PRIV(op)->wait_detail = bs->journal.used_start;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
journal_entry* prefill_single_journal_entry(journal_t & journal, uint16_t type, uint32_t size)
|
|
||||||
{
|
|
||||||
if (journal.block_size - journal.in_sector_pos < size)
|
|
||||||
{
|
|
||||||
assert(!journal.sector_info[journal.cur_sector].dirty);
|
|
||||||
// Move to the next journal sector
|
|
||||||
if (journal.sector_info[journal.cur_sector].usage_count > 0)
|
|
||||||
{
|
|
||||||
// Also select next sector buffer in memory
|
|
||||||
journal.cur_sector = ((journal.cur_sector + 1) % journal.sector_count);
|
|
||||||
}
|
|
||||||
journal.sector_info[journal.cur_sector].offset = journal.next_free;
|
|
||||||
journal.in_sector_pos = 0;
|
|
||||||
journal.next_free = (journal.next_free+journal.block_size) < journal.len ? journal.next_free + journal.block_size : journal.block_size;
|
|
||||||
memset(journal.inmemory
|
|
||||||
? journal.buffer + journal.sector_info[journal.cur_sector].offset
|
|
||||||
: journal.sector_buf + journal.block_size*journal.cur_sector, 0, journal.block_size);
|
|
||||||
}
|
|
||||||
journal_entry *je = (struct journal_entry*)(
|
|
||||||
(journal.inmemory
|
|
||||||
? journal.buffer + journal.sector_info[journal.cur_sector].offset
|
|
||||||
: journal.sector_buf + journal.block_size*journal.cur_sector) + journal.in_sector_pos
|
|
||||||
);
|
|
||||||
journal.in_sector_pos += size;
|
|
||||||
je->magic = JOURNAL_MAGIC;
|
|
||||||
je->type = type;
|
|
||||||
je->size = size;
|
|
||||||
je->crc32_prev = journal.crc32_last;
|
|
||||||
journal.sector_info[journal.cur_sector].dirty = true;
|
|
||||||
return je;
|
|
||||||
}
|
|
||||||
|
|
||||||
void prepare_journal_sector_write(journal_t & journal, int cur_sector, io_uring_sqe *sqe, std::function<void(ring_data_t*)> cb)
|
|
||||||
{
|
|
||||||
journal.sector_info[cur_sector].dirty = false;
|
|
||||||
journal.sector_info[cur_sector].usage_count++;
|
|
||||||
ring_data_t *data = ((ring_data_t*)sqe->user_data);
|
|
||||||
data->iov = (struct iovec){
|
|
||||||
(journal.inmemory
|
|
||||||
? journal.buffer + journal.sector_info[cur_sector].offset
|
|
||||||
: journal.sector_buf + journal.block_size*cur_sector),
|
|
||||||
journal.block_size
|
|
||||||
};
|
|
||||||
data->callback = cb;
|
|
||||||
my_uring_prep_writev(
|
|
||||||
sqe, journal.fd, &data->iov, 1, journal.offset + journal.sector_info[cur_sector].offset
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
journal_t::~journal_t()
|
|
||||||
{
|
|
||||||
if (sector_buf)
|
|
||||||
free(sector_buf);
|
|
||||||
if (sector_info)
|
|
||||||
free(sector_info);
|
|
||||||
if (buffer)
|
|
||||||
free(buffer);
|
|
||||||
sector_buf = NULL;
|
|
||||||
sector_info = NULL;
|
|
||||||
buffer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool journal_t::trim()
|
|
||||||
{
|
|
||||||
auto journal_used_it = used_sectors.lower_bound(used_start);
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf(
|
|
||||||
"Trimming journal (used_start=%lu, next_free=%lu, first_used=%lu, usage_count=%lu)\n",
|
|
||||||
used_start, next_free,
|
|
||||||
journal_used_it == used_sectors.end() ? 0 : journal_used_it->first,
|
|
||||||
journal_used_it == used_sectors.end() ? 0 : journal_used_it->second
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
if (journal_used_it == used_sectors.end())
|
|
||||||
{
|
|
||||||
// Journal is cleared to its end, restart from the beginning
|
|
||||||
journal_used_it = used_sectors.begin();
|
|
||||||
if (journal_used_it == used_sectors.end())
|
|
||||||
{
|
|
||||||
// Journal is empty
|
|
||||||
used_start = next_free;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
used_start = journal_used_it->first;
|
|
||||||
// next_free does not need updating here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (journal_used_it->first > used_start)
|
|
||||||
{
|
|
||||||
// Journal is cleared up to <journal_used_it>
|
|
||||||
used_start = journal_used_it->first;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Can't trim journal
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("Journal trimmed to %lu (next_free=%lu)\n", used_start, next_free);
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
|
@ -1,187 +0,0 @@
|
||||||
#include "blockstore_impl.h"
|
|
||||||
|
|
||||||
int blockstore_impl_t::dequeue_rollback(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
obj_ver_id* v;
|
|
||||||
int i, todo = op->len;
|
|
||||||
for (i = 0, v = (obj_ver_id*)op->buf; i < op->len; i++, v++)
|
|
||||||
{
|
|
||||||
// Check that there are some versions greater than v->version (which may be zero),
|
|
||||||
// check that they're unstable, synced, and not currently written to
|
|
||||||
auto dirty_it = dirty_db.lower_bound((obj_ver_id){
|
|
||||||
.oid = v->oid,
|
|
||||||
.version = UINT64_MAX,
|
|
||||||
});
|
|
||||||
if (dirty_it == dirty_db.begin())
|
|
||||||
{
|
|
||||||
bad_op:
|
|
||||||
op->retval = -EINVAL;
|
|
||||||
FINISH_OP(op);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dirty_it--;
|
|
||||||
if (dirty_it->first.oid != v->oid || dirty_it->first.version < v->version)
|
|
||||||
{
|
|
||||||
goto bad_op;
|
|
||||||
}
|
|
||||||
while (dirty_it->first.oid == v->oid && dirty_it->first.version > v->version)
|
|
||||||
{
|
|
||||||
if (!IS_SYNCED(dirty_it->second.state) ||
|
|
||||||
IS_STABLE(dirty_it->second.state))
|
|
||||||
{
|
|
||||||
goto bad_op;
|
|
||||||
}
|
|
||||||
if (dirty_it == dirty_db.begin())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dirty_it--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check journal space
|
|
||||||
blockstore_journal_check_t space_check(this);
|
|
||||||
if (!space_check.check_available(op, todo, sizeof(journal_entry_rollback), 0))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// There is sufficient space. Get SQEs
|
|
||||||
struct io_uring_sqe *sqe[space_check.sectors_required];
|
|
||||||
for (i = 0; i < space_check.sectors_required; i++)
|
|
||||||
{
|
|
||||||
BS_SUBMIT_GET_SQE_DECL(sqe[i]);
|
|
||||||
}
|
|
||||||
// Prepare and submit journal entries
|
|
||||||
auto cb = [this, op](ring_data_t *data) { handle_rollback_event(data, op); };
|
|
||||||
int s = 0, cur_sector = -1;
|
|
||||||
if ((journal_block_size - journal.in_sector_pos) < sizeof(journal_entry_rollback) &&
|
|
||||||
journal.sector_info[journal.cur_sector].dirty)
|
|
||||||
{
|
|
||||||
if (cur_sector == -1)
|
|
||||||
PRIV(op)->min_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
cur_sector = journal.cur_sector;
|
|
||||||
prepare_journal_sector_write(journal, cur_sector, sqe[s++], cb);
|
|
||||||
}
|
|
||||||
for (i = 0, v = (obj_ver_id*)op->buf; i < op->len; i++, v++)
|
|
||||||
{
|
|
||||||
// FIXME This is here only for the purpose of tracking unstable_writes. Remove if not required
|
|
||||||
// FIXME ...aaaand this is similar to blockstore_init.cpp - maybe dedup it?
|
|
||||||
auto dirty_it = dirty_db.lower_bound((obj_ver_id){
|
|
||||||
.oid = v->oid,
|
|
||||||
.version = UINT64_MAX,
|
|
||||||
});
|
|
||||||
uint64_t max_unstable = 0;
|
|
||||||
while (dirty_it != dirty_db.begin())
|
|
||||||
{
|
|
||||||
dirty_it--;
|
|
||||||
if (dirty_it->first.oid != v->oid)
|
|
||||||
break;
|
|
||||||
else if (dirty_it->first.version <= v->version)
|
|
||||||
{
|
|
||||||
if (!IS_STABLE(dirty_it->second.state))
|
|
||||||
max_unstable = dirty_it->first.version;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auto unstab_it = unstable_writes.find(v->oid);
|
|
||||||
if (unstab_it != unstable_writes.end())
|
|
||||||
{
|
|
||||||
if (max_unstable == 0)
|
|
||||||
unstable_writes.erase(unstab_it);
|
|
||||||
else
|
|
||||||
unstab_it->second = max_unstable;
|
|
||||||
}
|
|
||||||
journal_entry_rollback *je = (journal_entry_rollback*)
|
|
||||||
prefill_single_journal_entry(journal, JE_ROLLBACK, sizeof(journal_entry_rollback));
|
|
||||||
journal.sector_info[journal.cur_sector].dirty = false;
|
|
||||||
je->oid = v->oid;
|
|
||||||
je->version = v->version;
|
|
||||||
je->crc32 = je_crc32((journal_entry*)je);
|
|
||||||
journal.crc32_last = je->crc32;
|
|
||||||
if (cur_sector != journal.cur_sector)
|
|
||||||
{
|
|
||||||
if (cur_sector == -1)
|
|
||||||
PRIV(op)->min_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
cur_sector = journal.cur_sector;
|
|
||||||
prepare_journal_sector_write(journal, cur_sector, sqe[s++], cb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRIV(op)->max_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
PRIV(op)->pending_ops = s;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::handle_rollback_event(ring_data_t *data, blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
live = true;
|
|
||||||
if (data->res != data->iov.iov_len)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(
|
|
||||||
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
|
|
||||||
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
PRIV(op)->pending_ops--;
|
|
||||||
if (PRIV(op)->pending_ops == 0)
|
|
||||||
{
|
|
||||||
// Release used journal sectors
|
|
||||||
release_journal_sectors(op);
|
|
||||||
obj_ver_id* v;
|
|
||||||
int i;
|
|
||||||
for (i = 0, v = (obj_ver_id*)op->buf; i < op->len; i++, v++)
|
|
||||||
{
|
|
||||||
// Erase dirty_db entries
|
|
||||||
auto rm_end = dirty_db.lower_bound((obj_ver_id){
|
|
||||||
.oid = v->oid,
|
|
||||||
.version = UINT64_MAX,
|
|
||||||
});
|
|
||||||
rm_end--;
|
|
||||||
auto rm_start = rm_end;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
if (rm_end->first.oid != v->oid)
|
|
||||||
break;
|
|
||||||
else if (rm_end->first.version <= v->version)
|
|
||||||
break;
|
|
||||||
rm_start = rm_end;
|
|
||||||
if (rm_end == dirty_db.begin())
|
|
||||||
break;
|
|
||||||
rm_end--;
|
|
||||||
}
|
|
||||||
if (rm_end != rm_start)
|
|
||||||
erase_dirty(rm_start, rm_end, UINT64_MAX);
|
|
||||||
}
|
|
||||||
journal.trim();
|
|
||||||
// Acknowledge op
|
|
||||||
op->retval = 0;
|
|
||||||
FINISH_OP(op);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::erase_dirty(blockstore_dirty_db_t::iterator dirty_start, blockstore_dirty_db_t::iterator dirty_end, uint64_t clean_loc)
|
|
||||||
{
|
|
||||||
auto dirty_it = dirty_end;
|
|
||||||
while (dirty_it != dirty_start)
|
|
||||||
{
|
|
||||||
dirty_it--;
|
|
||||||
if (IS_BIG_WRITE(dirty_it->second.state) && dirty_it->second.location != clean_loc)
|
|
||||||
{
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("Free block %lu\n", dirty_it->second.location >> block_order);
|
|
||||||
#endif
|
|
||||||
data_alloc->set(dirty_it->second.location >> block_order, false);
|
|
||||||
}
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("remove usage of journal offset %lu by %lu:%lu v%lu\n", dirty_it->second.journal_sector,
|
|
||||||
dirty_it->first.oid.inode, dirty_it->first.oid.stripe, dirty_it->first.version);
|
|
||||||
#endif
|
|
||||||
int used = --journal.used_sectors[dirty_it->second.journal_sector];
|
|
||||||
if (used == 0)
|
|
||||||
{
|
|
||||||
journal.used_sectors.erase(dirty_it->second.journal_sector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dirty_db.erase(dirty_start, dirty_end);
|
|
||||||
}
|
|
|
@ -1,195 +0,0 @@
|
||||||
#include "blockstore_impl.h"
|
|
||||||
|
|
||||||
// Stabilize small write:
|
|
||||||
// 1) Copy data from the journal to the data device
|
|
||||||
// 2) Increase version on the metadata device and sync it
|
|
||||||
// 3) Advance clean_db entry's version, clear previous journal entries
|
|
||||||
//
|
|
||||||
// This makes 1 4K small write+sync look like:
|
|
||||||
// 512b+4K (journal) + sync + 512b (journal) + sync + 4K (data) [+ sync?] + 512b (metadata) + sync.
|
|
||||||
// WA = 2.375. It's not the best, SSD FTL-like redirect-write could probably be lower
|
|
||||||
// even with defragmentation. But it's fixed and it's still better than in Ceph. :)
|
|
||||||
// except for HDD-only clusters, because each write results in 3 seeks.
|
|
||||||
|
|
||||||
// Stabilize big write:
|
|
||||||
// 1) Copy metadata from the journal to the metadata device
|
|
||||||
// 2) Move dirty_db entry to clean_db and clear previous journal entries
|
|
||||||
//
|
|
||||||
// This makes 1 128K big write+sync look like:
|
|
||||||
// 128K (data) + sync + 512b (journal) + sync + 512b (journal) + sync + 512b (metadata) + sync.
|
|
||||||
// WA = 1.012. Very good :)
|
|
||||||
|
|
||||||
// Stabilize delete:
|
|
||||||
// 1) Remove metadata entry and sync it
|
|
||||||
// 2) Remove dirty_db entry and clear previous journal entries
|
|
||||||
// We have 2 problems here:
|
|
||||||
// - In the cluster environment, we must store the "tombstones" of deleted objects until
|
|
||||||
// all replicas (not just quorum) agrees about their deletion. That is, "stabilize" is
|
|
||||||
// not possible for deletes in degraded placement groups
|
|
||||||
// - With simple "fixed" metadata tables we can't just clear the metadata entry of the latest
|
|
||||||
// object version. We must clear all previous entries, too.
|
|
||||||
// FIXME Fix both problems - probably, by switching from "fixed" metadata tables to "dynamic"
|
|
||||||
|
|
||||||
// AND We must do it in batches, for the sake of reduced fsync call count
|
|
||||||
// AND We must know what we stabilize. Basic workflow is like:
|
|
||||||
// 1) primary OSD receives sync request
|
|
||||||
// 2) it submits syncs to blockstore and peers
|
|
||||||
// 3) after everyone acks sync it acks sync to the client
|
|
||||||
// 4) after a while it takes his synced object list and sends stabilize requests
|
|
||||||
// to peers and to its own blockstore, thus freeing the old version
|
|
||||||
|
|
||||||
int blockstore_impl_t::dequeue_stable(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
obj_ver_id* v;
|
|
||||||
int i, todo = 0;
|
|
||||||
for (i = 0, v = (obj_ver_id*)op->buf; i < op->len; i++, v++)
|
|
||||||
{
|
|
||||||
auto dirty_it = dirty_db.find(*v);
|
|
||||||
if (dirty_it == dirty_db.end())
|
|
||||||
{
|
|
||||||
auto clean_it = clean_db.find(v->oid);
|
|
||||||
if (clean_it == clean_db.end() || clean_it->second.version < v->version)
|
|
||||||
{
|
|
||||||
// No such object version
|
|
||||||
op->retval = -EINVAL;
|
|
||||||
FINISH_OP(op);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Already stable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (IS_UNSYNCED(dirty_it->second.state))
|
|
||||||
{
|
|
||||||
// Object not synced yet. Caller must sync it first
|
|
||||||
op->retval = EAGAIN;
|
|
||||||
FINISH_OP(op);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (!IS_STABLE(dirty_it->second.state))
|
|
||||||
{
|
|
||||||
todo++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!todo)
|
|
||||||
{
|
|
||||||
// Already stable
|
|
||||||
op->retval = 0;
|
|
||||||
FINISH_OP(op);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
// Check journal space
|
|
||||||
blockstore_journal_check_t space_check(this);
|
|
||||||
if (!space_check.check_available(op, todo, sizeof(journal_entry_stable), 0))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// There is sufficient space. Get SQEs
|
|
||||||
struct io_uring_sqe *sqe[space_check.sectors_required];
|
|
||||||
for (i = 0; i < space_check.sectors_required; i++)
|
|
||||||
{
|
|
||||||
BS_SUBMIT_GET_SQE_DECL(sqe[i]);
|
|
||||||
}
|
|
||||||
// Prepare and submit journal entries
|
|
||||||
auto cb = [this, op](ring_data_t *data) { handle_stable_event(data, op); };
|
|
||||||
int s = 0, cur_sector = -1;
|
|
||||||
if ((journal_block_size - journal.in_sector_pos) < sizeof(journal_entry_stable) &&
|
|
||||||
journal.sector_info[journal.cur_sector].dirty)
|
|
||||||
{
|
|
||||||
if (cur_sector == -1)
|
|
||||||
PRIV(op)->min_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
cur_sector = journal.cur_sector;
|
|
||||||
prepare_journal_sector_write(journal, cur_sector, sqe[s++], cb);
|
|
||||||
}
|
|
||||||
for (i = 0, v = (obj_ver_id*)op->buf; i < op->len; i++, v++)
|
|
||||||
{
|
|
||||||
auto unstab_it = unstable_writes.find(v->oid);
|
|
||||||
if (unstab_it != unstable_writes.end() &&
|
|
||||||
unstab_it->second <= v->version)
|
|
||||||
{
|
|
||||||
unstable_writes.erase(unstab_it);
|
|
||||||
}
|
|
||||||
journal_entry_stable *je = (journal_entry_stable*)
|
|
||||||
prefill_single_journal_entry(journal, JE_STABLE, sizeof(journal_entry_stable));
|
|
||||||
journal.sector_info[journal.cur_sector].dirty = false;
|
|
||||||
je->oid = v->oid;
|
|
||||||
je->version = v->version;
|
|
||||||
je->crc32 = je_crc32((journal_entry*)je);
|
|
||||||
journal.crc32_last = je->crc32;
|
|
||||||
if (cur_sector != journal.cur_sector)
|
|
||||||
{
|
|
||||||
if (cur_sector == -1)
|
|
||||||
PRIV(op)->min_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
cur_sector = journal.cur_sector;
|
|
||||||
prepare_journal_sector_write(journal, cur_sector, sqe[s++], cb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRIV(op)->max_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
PRIV(op)->pending_ops = s;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::handle_stable_event(ring_data_t *data, blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
live = true;
|
|
||||||
if (data->res != data->iov.iov_len)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(
|
|
||||||
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
|
|
||||||
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
PRIV(op)->pending_ops--;
|
|
||||||
if (PRIV(op)->pending_ops == 0)
|
|
||||||
{
|
|
||||||
// Release used journal sectors
|
|
||||||
release_journal_sectors(op);
|
|
||||||
// Mark dirty_db entries as stable, acknowledge op completion
|
|
||||||
obj_ver_id* v;
|
|
||||||
int i;
|
|
||||||
for (i = 0, v = (obj_ver_id*)op->buf; i < op->len; i++, v++)
|
|
||||||
{
|
|
||||||
// Mark all dirty_db entries up to op->version as stable
|
|
||||||
auto dirty_it = dirty_db.find(*v);
|
|
||||||
if (dirty_it != dirty_db.end())
|
|
||||||
{
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
if (dirty_it->second.state == ST_J_SYNCED)
|
|
||||||
{
|
|
||||||
dirty_it->second.state = ST_J_STABLE;
|
|
||||||
}
|
|
||||||
else if (dirty_it->second.state == ST_D_META_SYNCED)
|
|
||||||
{
|
|
||||||
dirty_it->second.state = ST_D_STABLE;
|
|
||||||
}
|
|
||||||
else if (dirty_it->second.state == ST_DEL_SYNCED)
|
|
||||||
{
|
|
||||||
dirty_it->second.state = ST_DEL_STABLE;
|
|
||||||
}
|
|
||||||
else if (IS_STABLE(dirty_it->second.state))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (dirty_it == dirty_db.begin())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dirty_it--;
|
|
||||||
if (dirty_it->first.oid != v->oid)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("enqueue_flush %lu:%lu v%lu\n", v->oid.inode, v->oid.stripe, v->version);
|
|
||||||
#endif
|
|
||||||
flusher->enqueue_flush(*v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Acknowledge op
|
|
||||||
op->retval = 0;
|
|
||||||
FINISH_OP(op);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,269 +0,0 @@
|
||||||
#include "blockstore_impl.h"
|
|
||||||
|
|
||||||
#define SYNC_HAS_SMALL 1
|
|
||||||
#define SYNC_HAS_BIG 2
|
|
||||||
#define SYNC_DATA_SYNC_SENT 3
|
|
||||||
#define SYNC_DATA_SYNC_DONE 4
|
|
||||||
#define SYNC_JOURNAL_WRITE_SENT 5
|
|
||||||
#define SYNC_JOURNAL_WRITE_DONE 6
|
|
||||||
#define SYNC_JOURNAL_SYNC_SENT 7
|
|
||||||
#define SYNC_DONE 8
|
|
||||||
|
|
||||||
int blockstore_impl_t::dequeue_sync(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
if (PRIV(op)->sync_state == 0)
|
|
||||||
{
|
|
||||||
stop_sync_submitted = false;
|
|
||||||
PRIV(op)->sync_big_writes.swap(unsynced_big_writes);
|
|
||||||
PRIV(op)->sync_small_writes.swap(unsynced_small_writes);
|
|
||||||
PRIV(op)->sync_small_checked = 0;
|
|
||||||
PRIV(op)->sync_big_checked = 0;
|
|
||||||
unsynced_big_writes.clear();
|
|
||||||
unsynced_small_writes.clear();
|
|
||||||
if (PRIV(op)->sync_big_writes.size() > 0)
|
|
||||||
PRIV(op)->sync_state = SYNC_HAS_BIG;
|
|
||||||
else if (PRIV(op)->sync_small_writes.size() > 0)
|
|
||||||
PRIV(op)->sync_state = SYNC_HAS_SMALL;
|
|
||||||
else
|
|
||||||
PRIV(op)->sync_state = SYNC_DONE;
|
|
||||||
// Always add sync to in_progress_syncs because we clear unsynced_big_writes and unsynced_small_writes
|
|
||||||
PRIV(op)->prev_sync_count = in_progress_syncs.size();
|
|
||||||
PRIV(op)->in_progress_ptr = in_progress_syncs.insert(in_progress_syncs.end(), op);
|
|
||||||
}
|
|
||||||
continue_sync(op);
|
|
||||||
// Always dequeue because we always add syncs to in_progress_syncs
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int blockstore_impl_t::continue_sync(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
auto cb = [this, op](ring_data_t *data) { handle_sync_event(data, op); };
|
|
||||||
if (PRIV(op)->sync_state == SYNC_HAS_SMALL)
|
|
||||||
{
|
|
||||||
// No big writes, just fsync the journal
|
|
||||||
for (; PRIV(op)->sync_small_checked < PRIV(op)->sync_small_writes.size(); PRIV(op)->sync_small_checked++)
|
|
||||||
{
|
|
||||||
if (IS_IN_FLIGHT(dirty_db[PRIV(op)->sync_small_writes[PRIV(op)->sync_small_checked]].state))
|
|
||||||
{
|
|
||||||
// Wait for small inflight writes to complete
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (journal.sector_info[journal.cur_sector].dirty)
|
|
||||||
{
|
|
||||||
// Write out the last journal sector if it happens to be dirty
|
|
||||||
BS_SUBMIT_GET_ONLY_SQE(sqe);
|
|
||||||
prepare_journal_sector_write(journal, journal.cur_sector, sqe, cb);
|
|
||||||
PRIV(op)->min_used_journal_sector = PRIV(op)->max_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
PRIV(op)->pending_ops = 1;
|
|
||||||
PRIV(op)->sync_state = SYNC_JOURNAL_WRITE_SENT;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PRIV(op)->sync_state = SYNC_JOURNAL_WRITE_DONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (PRIV(op)->sync_state == SYNC_HAS_BIG)
|
|
||||||
{
|
|
||||||
for (; PRIV(op)->sync_big_checked < PRIV(op)->sync_big_writes.size(); PRIV(op)->sync_big_checked++)
|
|
||||||
{
|
|
||||||
if (IS_IN_FLIGHT(dirty_db[PRIV(op)->sync_big_writes[PRIV(op)->sync_big_checked]].state))
|
|
||||||
{
|
|
||||||
// Wait for big inflight writes to complete
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 1st step: fsync data
|
|
||||||
if (!disable_data_fsync)
|
|
||||||
{
|
|
||||||
BS_SUBMIT_GET_SQE(sqe, data);
|
|
||||||
my_uring_prep_fsync(sqe, data_fd, IORING_FSYNC_DATASYNC);
|
|
||||||
data->iov = { 0 };
|
|
||||||
data->callback = cb;
|
|
||||||
PRIV(op)->min_used_journal_sector = PRIV(op)->max_used_journal_sector = 0;
|
|
||||||
PRIV(op)->pending_ops = 1;
|
|
||||||
PRIV(op)->sync_state = SYNC_DATA_SYNC_SENT;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PRIV(op)->sync_state = SYNC_DATA_SYNC_DONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (PRIV(op)->sync_state == SYNC_DATA_SYNC_DONE)
|
|
||||||
{
|
|
||||||
for (; PRIV(op)->sync_small_checked < PRIV(op)->sync_small_writes.size(); PRIV(op)->sync_small_checked++)
|
|
||||||
{
|
|
||||||
if (IS_IN_FLIGHT(dirty_db[PRIV(op)->sync_small_writes[PRIV(op)->sync_small_checked]].state))
|
|
||||||
{
|
|
||||||
// Wait for small inflight writes to complete
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 2nd step: Data device is synced, prepare & write journal entries
|
|
||||||
// Check space in the journal and journal memory buffers
|
|
||||||
blockstore_journal_check_t space_check(this);
|
|
||||||
if (!space_check.check_available(op, PRIV(op)->sync_big_writes.size(), sizeof(journal_entry_big_write), 0))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// Get SQEs. Don't bother about merging, submit each journal sector as a separate request
|
|
||||||
struct io_uring_sqe *sqe[space_check.sectors_required];
|
|
||||||
for (int i = 0; i < space_check.sectors_required; i++)
|
|
||||||
{
|
|
||||||
BS_SUBMIT_GET_SQE_DECL(sqe[i]);
|
|
||||||
}
|
|
||||||
// Prepare and submit journal entries
|
|
||||||
auto it = PRIV(op)->sync_big_writes.begin();
|
|
||||||
int s = 0, cur_sector = -1;
|
|
||||||
if ((journal_block_size - journal.in_sector_pos) < sizeof(journal_entry_big_write) &&
|
|
||||||
journal.sector_info[journal.cur_sector].dirty)
|
|
||||||
{
|
|
||||||
if (cur_sector == -1)
|
|
||||||
PRIV(op)->min_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
cur_sector = journal.cur_sector;
|
|
||||||
prepare_journal_sector_write(journal, cur_sector, sqe[s++], cb);
|
|
||||||
}
|
|
||||||
while (it != PRIV(op)->sync_big_writes.end())
|
|
||||||
{
|
|
||||||
journal_entry_big_write *je = (journal_entry_big_write*)
|
|
||||||
prefill_single_journal_entry(journal, JE_BIG_WRITE, sizeof(journal_entry_big_write));
|
|
||||||
dirty_db[*it].journal_sector = journal.sector_info[journal.cur_sector].offset;
|
|
||||||
journal.sector_info[journal.cur_sector].dirty = false;
|
|
||||||
journal.used_sectors[journal.sector_info[journal.cur_sector].offset]++;
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("journal offset %lu is used by %lu:%lu v%lu\n", dirty_db[*it].journal_sector, it->oid.inode, it->oid.stripe, it->version);
|
|
||||||
#endif
|
|
||||||
je->oid = it->oid;
|
|
||||||
je->version = it->version;
|
|
||||||
je->offset = dirty_db[*it].offset;
|
|
||||||
je->len = dirty_db[*it].len;
|
|
||||||
je->location = dirty_db[*it].location;
|
|
||||||
je->crc32 = je_crc32((journal_entry*)je);
|
|
||||||
journal.crc32_last = je->crc32;
|
|
||||||
it++;
|
|
||||||
if (cur_sector != journal.cur_sector)
|
|
||||||
{
|
|
||||||
if (cur_sector == -1)
|
|
||||||
PRIV(op)->min_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
cur_sector = journal.cur_sector;
|
|
||||||
prepare_journal_sector_write(journal, cur_sector, sqe[s++], cb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRIV(op)->max_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
PRIV(op)->pending_ops = s;
|
|
||||||
PRIV(op)->sync_state = SYNC_JOURNAL_WRITE_SENT;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (PRIV(op)->sync_state == SYNC_JOURNAL_WRITE_DONE)
|
|
||||||
{
|
|
||||||
if (!disable_journal_fsync)
|
|
||||||
{
|
|
||||||
BS_SUBMIT_GET_SQE(sqe, data);
|
|
||||||
my_uring_prep_fsync(sqe, journal.fd, IORING_FSYNC_DATASYNC);
|
|
||||||
data->iov = { 0 };
|
|
||||||
data->callback = cb;
|
|
||||||
PRIV(op)->pending_ops = 1;
|
|
||||||
PRIV(op)->sync_state = SYNC_JOURNAL_SYNC_SENT;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PRIV(op)->sync_state = SYNC_DONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (PRIV(op)->sync_state == SYNC_DONE)
|
|
||||||
{
|
|
||||||
ack_sync(op);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::handle_sync_event(ring_data_t *data, blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
live = true;
|
|
||||||
if (data->res != data->iov.iov_len)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(
|
|
||||||
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
|
|
||||||
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
PRIV(op)->pending_ops--;
|
|
||||||
if (PRIV(op)->pending_ops == 0)
|
|
||||||
{
|
|
||||||
// Release used journal sectors
|
|
||||||
release_journal_sectors(op);
|
|
||||||
// Handle states
|
|
||||||
if (PRIV(op)->sync_state == SYNC_DATA_SYNC_SENT)
|
|
||||||
{
|
|
||||||
PRIV(op)->sync_state = SYNC_DATA_SYNC_DONE;
|
|
||||||
}
|
|
||||||
else if (PRIV(op)->sync_state == SYNC_JOURNAL_WRITE_SENT)
|
|
||||||
{
|
|
||||||
PRIV(op)->sync_state = SYNC_JOURNAL_WRITE_DONE;
|
|
||||||
}
|
|
||||||
else if (PRIV(op)->sync_state == SYNC_JOURNAL_SYNC_SENT)
|
|
||||||
{
|
|
||||||
PRIV(op)->sync_state = SYNC_DONE;
|
|
||||||
ack_sync(op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::runtime_error("BUG: unexpected sync op state");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int blockstore_impl_t::ack_sync(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
if (PRIV(op)->sync_state == SYNC_DONE && PRIV(op)->prev_sync_count == 0)
|
|
||||||
{
|
|
||||||
// Remove dependency of subsequent syncs
|
|
||||||
auto it = PRIV(op)->in_progress_ptr;
|
|
||||||
int done_syncs = 1;
|
|
||||||
++it;
|
|
||||||
// Acknowledge sync
|
|
||||||
ack_one_sync(op);
|
|
||||||
while (it != in_progress_syncs.end())
|
|
||||||
{
|
|
||||||
auto & next_sync = *it++;
|
|
||||||
PRIV(next_sync)->prev_sync_count -= done_syncs;
|
|
||||||
if (PRIV(next_sync)->prev_sync_count == 0 && PRIV(next_sync)->sync_state == SYNC_DONE)
|
|
||||||
{
|
|
||||||
done_syncs++;
|
|
||||||
// Acknowledge next_sync
|
|
||||||
ack_one_sync(next_sync);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::ack_one_sync(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
// Handle states
|
|
||||||
for (auto it = PRIV(op)->sync_big_writes.begin(); it != PRIV(op)->sync_big_writes.end(); it++)
|
|
||||||
{
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("Ack sync big %lu:%lu v%lu\n", it->oid.inode, it->oid.stripe, it->version);
|
|
||||||
#endif
|
|
||||||
auto & unstab = unstable_writes[it->oid];
|
|
||||||
unstab = unstab < it->version ? it->version : unstab;
|
|
||||||
dirty_db[*it].state = ST_D_META_SYNCED;
|
|
||||||
}
|
|
||||||
for (auto it = PRIV(op)->sync_small_writes.begin(); it != PRIV(op)->sync_small_writes.end(); it++)
|
|
||||||
{
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("Ack sync small %lu:%lu v%lu\n", it->oid.inode, it->oid.stripe, it->version);
|
|
||||||
#endif
|
|
||||||
auto & unstab = unstable_writes[it->oid];
|
|
||||||
unstab = unstab < it->version ? it->version : unstab;
|
|
||||||
dirty_db[*it].state = dirty_db[*it].state == ST_DEL_WRITTEN ? ST_DEL_SYNCED : ST_J_SYNCED;
|
|
||||||
}
|
|
||||||
in_progress_syncs.erase(PRIV(op)->in_progress_ptr);
|
|
||||||
op->retval = 0;
|
|
||||||
FINISH_OP(op);
|
|
||||||
}
|
|
|
@ -1,328 +0,0 @@
|
||||||
#include "blockstore_impl.h"
|
|
||||||
|
|
||||||
bool blockstore_impl_t::enqueue_write(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
// Check or assign version number
|
|
||||||
bool found = false, deleted = false, is_del = (op->opcode == BS_OP_DELETE);
|
|
||||||
uint64_t version = 1;
|
|
||||||
if (dirty_db.size() > 0)
|
|
||||||
{
|
|
||||||
auto dirty_it = dirty_db.upper_bound((obj_ver_id){
|
|
||||||
.oid = op->oid,
|
|
||||||
.version = UINT64_MAX,
|
|
||||||
});
|
|
||||||
dirty_it--; // segfaults when dirty_db is empty
|
|
||||||
if (dirty_it != dirty_db.end() && dirty_it->first.oid == op->oid)
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
version = dirty_it->first.version + 1;
|
|
||||||
deleted = IS_DELETE(dirty_it->second.state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
auto clean_it = clean_db.find(op->oid);
|
|
||||||
if (clean_it != clean_db.end())
|
|
||||||
{
|
|
||||||
version = clean_it->second.version + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
deleted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (op->version == 0)
|
|
||||||
{
|
|
||||||
op->version = version;
|
|
||||||
}
|
|
||||||
else if (op->version < version)
|
|
||||||
{
|
|
||||||
// Invalid version requested
|
|
||||||
op->retval = -EINVAL;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (deleted && is_del)
|
|
||||||
{
|
|
||||||
// Already deleted
|
|
||||||
op->retval = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Immediately add the operation into dirty_db, so subsequent reads could see it
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("%s %lu:%lu v%lu\n", is_del ? "Delete" : "Write", op->oid.inode, op->oid.stripe, op->version);
|
|
||||||
#endif
|
|
||||||
dirty_db.emplace((obj_ver_id){
|
|
||||||
.oid = op->oid,
|
|
||||||
.version = op->version,
|
|
||||||
}, (dirty_entry){
|
|
||||||
.state = (uint32_t)(
|
|
||||||
is_del
|
|
||||||
? ST_DEL_IN_FLIGHT
|
|
||||||
: (op->len == block_size || deleted ? ST_D_IN_FLIGHT : ST_J_IN_FLIGHT)
|
|
||||||
),
|
|
||||||
.flags = 0,
|
|
||||||
.location = 0,
|
|
||||||
.offset = is_del ? 0 : op->offset,
|
|
||||||
.len = is_del ? 0 : op->len,
|
|
||||||
.journal_sector = 0,
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// First step of the write algorithm: dequeue operation and submit initial write(s)
|
|
||||||
int blockstore_impl_t::dequeue_write(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
auto dirty_it = dirty_db.find((obj_ver_id){
|
|
||||||
.oid = op->oid,
|
|
||||||
.version = op->version,
|
|
||||||
});
|
|
||||||
if (dirty_it->second.state == ST_D_IN_FLIGHT)
|
|
||||||
{
|
|
||||||
blockstore_journal_check_t space_check(this);
|
|
||||||
if (!space_check.check_available(op, unsynced_big_writes.size() + 1, sizeof(journal_entry_big_write), JOURNAL_STABILIZE_RESERVATION))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// Big (redirect) write
|
|
||||||
uint64_t loc = data_alloc->find_free();
|
|
||||||
if (loc == UINT64_MAX)
|
|
||||||
{
|
|
||||||
// no space
|
|
||||||
if (flusher->is_active())
|
|
||||||
{
|
|
||||||
// hope that some space will be available after flush
|
|
||||||
PRIV(op)->wait_for = WAIT_FREE;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
op->retval = -ENOSPC;
|
|
||||||
FINISH_OP(op);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
BS_SUBMIT_GET_SQE(sqe, data);
|
|
||||||
dirty_it->second.location = loc << block_order;
|
|
||||||
dirty_it->second.state = ST_D_SUBMITTED;
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("Allocate block %lu\n", loc);
|
|
||||||
#endif
|
|
||||||
data_alloc->set(loc, true);
|
|
||||||
uint64_t stripe_offset = (op->offset % bitmap_granularity);
|
|
||||||
uint64_t stripe_end = (op->offset + op->len) % bitmap_granularity;
|
|
||||||
// Zero fill up to bitmap_granularity
|
|
||||||
int vcnt = 0;
|
|
||||||
if (stripe_offset)
|
|
||||||
{
|
|
||||||
PRIV(op)->iov_zerofill[vcnt++] = (struct iovec){ zero_object, stripe_offset };
|
|
||||||
}
|
|
||||||
PRIV(op)->iov_zerofill[vcnt++] = (struct iovec){ op->buf, op->len };
|
|
||||||
if (stripe_end)
|
|
||||||
{
|
|
||||||
stripe_end = bitmap_granularity - stripe_end;
|
|
||||||
PRIV(op)->iov_zerofill[vcnt++] = (struct iovec){ zero_object, stripe_end };
|
|
||||||
}
|
|
||||||
data->iov.iov_len = op->len + stripe_offset + stripe_end; // to check it in the callback
|
|
||||||
data->callback = [this, op](ring_data_t *data) { handle_write_event(data, op); };
|
|
||||||
my_uring_prep_writev(
|
|
||||||
sqe, data_fd, PRIV(op)->iov_zerofill, vcnt, data_offset + (loc << block_order) + op->offset - stripe_offset
|
|
||||||
);
|
|
||||||
PRIV(op)->pending_ops = 1;
|
|
||||||
PRIV(op)->min_used_journal_sector = PRIV(op)->max_used_journal_sector = 0;
|
|
||||||
// Remember big write as unsynced
|
|
||||||
unsynced_big_writes.push_back((obj_ver_id){
|
|
||||||
.oid = op->oid,
|
|
||||||
.version = op->version,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Small (journaled) write
|
|
||||||
// First check if the journal has sufficient space
|
|
||||||
blockstore_journal_check_t space_check(this);
|
|
||||||
if (unsynced_big_writes.size() && !space_check.check_available(op, unsynced_big_writes.size(), sizeof(journal_entry_big_write), 0)
|
|
||||||
|| !space_check.check_available(op, 1, sizeof(journal_entry_small_write), op->len + JOURNAL_STABILIZE_RESERVATION))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// There is sufficient space. Get SQE(s)
|
|
||||||
struct io_uring_sqe *sqe1 = NULL;
|
|
||||||
if ((journal_block_size - journal.in_sector_pos) < sizeof(journal_entry_small_write) &&
|
|
||||||
journal.sector_info[journal.cur_sector].dirty)
|
|
||||||
{
|
|
||||||
// Write current journal sector only if it's dirty and full
|
|
||||||
BS_SUBMIT_GET_SQE_DECL(sqe1);
|
|
||||||
}
|
|
||||||
struct io_uring_sqe *sqe2 = NULL;
|
|
||||||
if (op->len > 0)
|
|
||||||
{
|
|
||||||
BS_SUBMIT_GET_SQE_DECL(sqe2);
|
|
||||||
}
|
|
||||||
// Got SQEs. Prepare previous journal sector write if required
|
|
||||||
auto cb = [this, op](ring_data_t *data) { handle_write_event(data, op); };
|
|
||||||
if (sqe1)
|
|
||||||
{
|
|
||||||
prepare_journal_sector_write(journal, journal.cur_sector, sqe1, cb);
|
|
||||||
// FIXME rename to min/max _flushing
|
|
||||||
PRIV(op)->min_used_journal_sector = PRIV(op)->max_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
PRIV(op)->pending_ops++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PRIV(op)->min_used_journal_sector = PRIV(op)->max_used_journal_sector = 0;
|
|
||||||
}
|
|
||||||
// Then pre-fill journal entry
|
|
||||||
journal_entry_small_write *je = (journal_entry_small_write*)
|
|
||||||
prefill_single_journal_entry(journal, JE_SMALL_WRITE, sizeof(journal_entry_small_write));
|
|
||||||
dirty_it->second.journal_sector = journal.sector_info[journal.cur_sector].offset;
|
|
||||||
journal.used_sectors[journal.sector_info[journal.cur_sector].offset]++;
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("journal offset %lu is used by %lu:%lu v%lu\n", dirty_it->second.journal_sector, dirty_it->first.oid.inode, dirty_it->first.oid.stripe, dirty_it->first.version);
|
|
||||||
#endif
|
|
||||||
// Figure out where data will be
|
|
||||||
journal.next_free = (journal.next_free + op->len) <= journal.len ? journal.next_free : journal_block_size;
|
|
||||||
je->oid = op->oid;
|
|
||||||
je->version = op->version;
|
|
||||||
je->offset = op->offset;
|
|
||||||
je->len = op->len;
|
|
||||||
je->data_offset = journal.next_free;
|
|
||||||
je->crc32_data = crc32c(0, op->buf, op->len);
|
|
||||||
je->crc32 = je_crc32((journal_entry*)je);
|
|
||||||
journal.crc32_last = je->crc32;
|
|
||||||
if (op->len > 0)
|
|
||||||
{
|
|
||||||
// Prepare journal data write
|
|
||||||
if (journal.inmemory)
|
|
||||||
{
|
|
||||||
// Copy data
|
|
||||||
memcpy(journal.buffer + journal.next_free, op->buf, op->len);
|
|
||||||
}
|
|
||||||
ring_data_t *data2 = ((ring_data_t*)sqe2->user_data);
|
|
||||||
data2->iov = (struct iovec){ op->buf, op->len };
|
|
||||||
data2->callback = cb;
|
|
||||||
my_uring_prep_writev(
|
|
||||||
sqe2, journal.fd, &data2->iov, 1, journal.offset + journal.next_free
|
|
||||||
);
|
|
||||||
PRIV(op)->pending_ops++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Zero-length overwrite. Allowed to bump object version in EC placement groups without actually writing data
|
|
||||||
}
|
|
||||||
dirty_it->second.location = journal.next_free;
|
|
||||||
dirty_it->second.state = ST_J_SUBMITTED;
|
|
||||||
journal.next_free += op->len;
|
|
||||||
if (journal.next_free >= journal.len)
|
|
||||||
{
|
|
||||||
journal.next_free = journal_block_size;
|
|
||||||
}
|
|
||||||
// Remember small write as unsynced
|
|
||||||
unsynced_small_writes.push_back((obj_ver_id){
|
|
||||||
.oid = op->oid,
|
|
||||||
.version = op->version,
|
|
||||||
});
|
|
||||||
if (!PRIV(op)->pending_ops)
|
|
||||||
{
|
|
||||||
ack_write(op);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::handle_write_event(ring_data_t *data, blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
live = true;
|
|
||||||
if (data->res != data->iov.iov_len)
|
|
||||||
{
|
|
||||||
// FIXME: our state becomes corrupted after a write error. maybe do something better than just die
|
|
||||||
throw std::runtime_error(
|
|
||||||
"write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+
|
|
||||||
"). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
PRIV(op)->pending_ops--;
|
|
||||||
if (PRIV(op)->pending_ops == 0)
|
|
||||||
{
|
|
||||||
release_journal_sectors(op);
|
|
||||||
ack_write(op);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::release_journal_sectors(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
// Release used journal sectors
|
|
||||||
if (PRIV(op)->min_used_journal_sector > 0 &&
|
|
||||||
PRIV(op)->max_used_journal_sector > 0)
|
|
||||||
{
|
|
||||||
uint64_t s = PRIV(op)->min_used_journal_sector;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
journal.sector_info[s-1].usage_count--;
|
|
||||||
if (s == PRIV(op)->max_used_journal_sector)
|
|
||||||
break;
|
|
||||||
s = 1 + s % journal.sector_count;
|
|
||||||
}
|
|
||||||
PRIV(op)->min_used_journal_sector = PRIV(op)->max_used_journal_sector = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockstore_impl_t::ack_write(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
// Switch object state
|
|
||||||
auto & dirty_entry = dirty_db[(obj_ver_id){
|
|
||||||
.oid = op->oid,
|
|
||||||
.version = op->version,
|
|
||||||
}];
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("Ack write %lu:%lu v%lu = %d\n", op->oid.inode, op->oid.stripe, op->version, dirty_entry.state);
|
|
||||||
#endif
|
|
||||||
if (dirty_entry.state == ST_J_SUBMITTED)
|
|
||||||
{
|
|
||||||
dirty_entry.state = ST_J_WRITTEN;
|
|
||||||
}
|
|
||||||
else if (dirty_entry.state == ST_D_SUBMITTED)
|
|
||||||
{
|
|
||||||
dirty_entry.state = ST_D_WRITTEN;
|
|
||||||
}
|
|
||||||
else if (dirty_entry.state == ST_DEL_SUBMITTED)
|
|
||||||
{
|
|
||||||
dirty_entry.state = ST_DEL_WRITTEN;
|
|
||||||
}
|
|
||||||
// Acknowledge write without sync
|
|
||||||
op->retval = op->len;
|
|
||||||
FINISH_OP(op);
|
|
||||||
}
|
|
||||||
|
|
||||||
int blockstore_impl_t::dequeue_del(blockstore_op_t *op)
|
|
||||||
{
|
|
||||||
auto dirty_it = dirty_db.find((obj_ver_id){
|
|
||||||
.oid = op->oid,
|
|
||||||
.version = op->version,
|
|
||||||
});
|
|
||||||
blockstore_journal_check_t space_check(this);
|
|
||||||
if (!space_check.check_available(op, 1, sizeof(journal_entry_del), 0))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
BS_SUBMIT_GET_ONLY_SQE(sqe);
|
|
||||||
// Prepare journal sector write
|
|
||||||
journal_entry_del *je = (journal_entry_del*)
|
|
||||||
prefill_single_journal_entry(journal, JE_DELETE, sizeof(struct journal_entry_del));
|
|
||||||
dirty_it->second.journal_sector = journal.sector_info[journal.cur_sector].offset;
|
|
||||||
journal.used_sectors[journal.sector_info[journal.cur_sector].offset]++;
|
|
||||||
#ifdef BLOCKSTORE_DEBUG
|
|
||||||
printf("journal offset %lu is used by %lu:%lu v%lu\n", dirty_it->second.journal_sector, dirty_it->first.oid.inode, dirty_it->first.oid.stripe, dirty_it->first.version);
|
|
||||||
#endif
|
|
||||||
je->oid = op->oid;
|
|
||||||
je->version = op->version;
|
|
||||||
je->crc32 = je_crc32((journal_entry*)je);
|
|
||||||
journal.crc32_last = je->crc32;
|
|
||||||
auto cb = [this, op](ring_data_t *data) { handle_write_event(data, op); };
|
|
||||||
prepare_journal_sector_write(journal, journal.cur_sector, sqe, cb);
|
|
||||||
PRIV(op)->min_used_journal_sector = PRIV(op)->max_used_journal_sector = 1 + journal.cur_sector;
|
|
||||||
PRIV(op)->pending_ops = 1;
|
|
||||||
dirty_it->second.state = ST_DEL_SUBMITTED;
|
|
||||||
// Remember small write as unsynced
|
|
||||||
unsynced_small_writes.push_back((obj_ver_id){
|
|
||||||
.oid = op->oid,
|
|
||||||
.version = op->version,
|
|
||||||
});
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
gcc -I. -E -o fio_headers.i src/fio_headers.h
|
||||||
|
|
||||||
|
rm -rf fio-copy
|
||||||
|
for i in `grep -Po 'fio/[^"]+' fio_headers.i | sort | uniq`; do
|
||||||
|
j=${i##fio/}
|
||||||
|
p=$(dirname $j)
|
||||||
|
mkdir -p fio-copy/$p
|
||||||
|
cp $i fio-copy/$j
|
||||||
|
done
|
||||||
|
|
||||||
|
rm fio_headers.i
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#cd qemu
|
||||||
|
#debian/rules b/configure-stamp
|
||||||
|
#cd b/qemu; make qapi
|
||||||
|
|
||||||
|
gcc -I qemu/b/qemu `pkg-config glib-2.0 --cflags` \
|
||||||
|
-I qemu/include -E -o qemu_driver.i src/qemu_driver.c
|
||||||
|
|
||||||
|
rm -rf qemu-copy
|
||||||
|
for i in `grep -Po 'qemu/[^"]+' qemu_driver.i | sort | uniq`; do
|
||||||
|
j=${i##qemu/}
|
||||||
|
p=$(dirname $j)
|
||||||
|
mkdir -p qemu-copy/$p
|
||||||
|
cp $i qemu-copy/$j
|
||||||
|
done
|
||||||
|
|
||||||
|
rm qemu_driver.i
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 5dc108754ad40d3b1d024f9bd7cca0595ef1a1db
|
|
@ -0,0 +1,2 @@
|
||||||
|
vitastor-csi
|
||||||
|
Dockerfile
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Compile stage
|
||||||
|
FROM golang:buster AS build
|
||||||
|
|
||||||
|
ADD go.sum go.mod /app/
|
||||||
|
RUN cd /app; CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go mod download -x
|
||||||
|
ADD . /app
|
||||||
|
RUN perl -i -e '$/ = undef; while(<>) { s/\n\s*(\{\s*\n)/$1\n/g; s/\}(\s*\n\s*)else\b/$1} else/g; print; }' `find /app -name '*.go'`
|
||||||
|
RUN cd /app; CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o vitastor-csi
|
||||||
|
|
||||||
|
# Final stage
|
||||||
|
FROM debian:buster
|
||||||
|
|
||||||
|
LABEL maintainers="Vitaliy Filippov <vitalif@yourcmc.ru>"
|
||||||
|
LABEL description="Vitastor CSI Driver"
|
||||||
|
|
||||||
|
ENV NODE_ID=""
|
||||||
|
ENV CSI_ENDPOINT=""
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y wget && \
|
||||||
|
wget -q -O /etc/apt/trusted.gpg.d/vitastor.gpg https://vitastor.io/debian/pubkey.gpg && \
|
||||||
|
(echo deb http://vitastor.io/debian buster main > /etc/apt/sources.list.d/vitastor.list) && \
|
||||||
|
(echo deb http://deb.debian.org/debian buster-backports main > /etc/apt/sources.list.d/backports.list) && \
|
||||||
|
(echo "APT::Install-Recommends false;" > /etc/apt/apt.conf) && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y e2fsprogs xfsprogs vitastor kmod && \
|
||||||
|
apt-get clean && \
|
||||||
|
(echo options nbd nbds_max=128 > /etc/modprobe.d/nbd.conf)
|
||||||
|
|
||||||
|
COPY --from=build /app/vitastor-csi /bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/vitastor-csi"]
|
|
@ -0,0 +1,9 @@
|
||||||
|
VERSION ?= v0.6.10
|
||||||
|
|
||||||
|
all: build push
|
||||||
|
|
||||||
|
build:
|
||||||
|
@docker build --rm -t vitalif/vitastor-csi:$(VERSION) .
|
||||||
|
|
||||||
|
push:
|
||||||
|
@docker push vitalif/vitastor-csi:$(VERSION)
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: vitastor-system
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
data:
|
||||||
|
vitastor.conf: |-
|
||||||
|
{"etcd_address":"http://192.168.7.2:2379","etcd_prefix":"/vitastor"}
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-config
|
|
@ -0,0 +1,37 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-nodeplugin
|
||||||
|
---
|
||||||
|
kind: ClusterRole
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-nodeplugin
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["nodes"]
|
||||||
|
verbs: ["get"]
|
||||||
|
# allow to read Vault Token and connection options from the Tenants namespace
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["secrets"]
|
||||||
|
verbs: ["get"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["configmaps"]
|
||||||
|
verbs: ["get"]
|
||||||
|
---
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-nodeplugin
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: vitastor-csi-nodeplugin
|
||||||
|
namespace: vitastor-system
|
||||||
|
roleRef:
|
||||||
|
kind: ClusterRole
|
||||||
|
name: vitastor-csi-nodeplugin
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
|
@ -0,0 +1,72 @@
|
||||||
|
---
|
||||||
|
apiVersion: policy/v1beta1
|
||||||
|
kind: PodSecurityPolicy
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-nodeplugin-psp
|
||||||
|
spec:
|
||||||
|
allowPrivilegeEscalation: true
|
||||||
|
allowedCapabilities:
|
||||||
|
- 'SYS_ADMIN'
|
||||||
|
fsGroup:
|
||||||
|
rule: RunAsAny
|
||||||
|
privileged: true
|
||||||
|
hostNetwork: true
|
||||||
|
hostPID: true
|
||||||
|
runAsUser:
|
||||||
|
rule: RunAsAny
|
||||||
|
seLinux:
|
||||||
|
rule: RunAsAny
|
||||||
|
supplementalGroups:
|
||||||
|
rule: RunAsAny
|
||||||
|
volumes:
|
||||||
|
- 'configMap'
|
||||||
|
- 'emptyDir'
|
||||||
|
- 'projected'
|
||||||
|
- 'secret'
|
||||||
|
- 'downwardAPI'
|
||||||
|
- 'hostPath'
|
||||||
|
allowedHostPaths:
|
||||||
|
- pathPrefix: '/dev'
|
||||||
|
readOnly: false
|
||||||
|
- pathPrefix: '/run/mount'
|
||||||
|
readOnly: false
|
||||||
|
- pathPrefix: '/sys'
|
||||||
|
readOnly: false
|
||||||
|
- pathPrefix: '/lib/modules'
|
||||||
|
readOnly: true
|
||||||
|
- pathPrefix: '/var/lib/kubelet/pods'
|
||||||
|
readOnly: false
|
||||||
|
- pathPrefix: '/var/lib/kubelet/plugins/csi.vitastor.io'
|
||||||
|
readOnly: false
|
||||||
|
- pathPrefix: '/var/lib/kubelet/plugins_registry'
|
||||||
|
readOnly: false
|
||||||
|
- pathPrefix: '/var/lib/kubelet/plugins'
|
||||||
|
readOnly: false
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: Role
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-nodeplugin-psp
|
||||||
|
rules:
|
||||||
|
- apiGroups: ['policy']
|
||||||
|
resources: ['podsecuritypolicies']
|
||||||
|
verbs: ['use']
|
||||||
|
resourceNames: ['vitastor-csi-nodeplugin-psp']
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: RoleBinding
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-nodeplugin-psp
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: vitastor-csi-nodeplugin
|
||||||
|
namespace: vitastor-system
|
||||||
|
roleRef:
|
||||||
|
kind: Role
|
||||||
|
name: vitastor-csi-nodeplugin-psp
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
|
@ -0,0 +1,140 @@
|
||||||
|
---
|
||||||
|
kind: DaemonSet
|
||||||
|
apiVersion: apps/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: csi-vitastor
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: csi-vitastor
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
labels:
|
||||||
|
app: csi-vitastor
|
||||||
|
spec:
|
||||||
|
serviceAccountName: vitastor-csi-nodeplugin
|
||||||
|
hostNetwork: true
|
||||||
|
hostPID: true
|
||||||
|
priorityClassName: system-node-critical
|
||||||
|
# to use e.g. Rook orchestrated cluster, and mons' FQDN is
|
||||||
|
# resolved through k8s service, set dns policy to cluster first
|
||||||
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
|
containers:
|
||||||
|
- name: driver-registrar
|
||||||
|
# This is necessary only for systems with SELinux, where
|
||||||
|
# non-privileged sidecar containers cannot access unix domain socket
|
||||||
|
# created by privileged CSI driver container.
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.2.0
|
||||||
|
args:
|
||||||
|
- "--v=5"
|
||||||
|
- "--csi-address=/csi/csi.sock"
|
||||||
|
- "--kubelet-registration-path=/var/lib/kubelet/plugins/csi.vitastor.io/csi.sock"
|
||||||
|
env:
|
||||||
|
- name: KUBE_NODE_NAME
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: spec.nodeName
|
||||||
|
volumeMounts:
|
||||||
|
- name: socket-dir
|
||||||
|
mountPath: /csi
|
||||||
|
- name: registration-dir
|
||||||
|
mountPath: /registration
|
||||||
|
- name: csi-vitastor
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
capabilities:
|
||||||
|
add: ["SYS_ADMIN"]
|
||||||
|
allowPrivilegeEscalation: true
|
||||||
|
image: vitalif/vitastor-csi:v0.6.10
|
||||||
|
args:
|
||||||
|
- "--node=$(NODE_ID)"
|
||||||
|
- "--endpoint=$(CSI_ENDPOINT)"
|
||||||
|
env:
|
||||||
|
- name: NODE_ID
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: spec.nodeName
|
||||||
|
- name: CSI_ENDPOINT
|
||||||
|
value: unix:///csi/csi.sock
|
||||||
|
imagePullPolicy: "IfNotPresent"
|
||||||
|
ports:
|
||||||
|
- containerPort: 9898
|
||||||
|
name: healthz
|
||||||
|
protocol: TCP
|
||||||
|
livenessProbe:
|
||||||
|
failureThreshold: 5
|
||||||
|
httpGet:
|
||||||
|
path: /healthz
|
||||||
|
port: healthz
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
timeoutSeconds: 3
|
||||||
|
periodSeconds: 2
|
||||||
|
volumeMounts:
|
||||||
|
- name: socket-dir
|
||||||
|
mountPath: /csi
|
||||||
|
- mountPath: /dev
|
||||||
|
name: host-dev
|
||||||
|
- mountPath: /sys
|
||||||
|
name: host-sys
|
||||||
|
- mountPath: /run/mount
|
||||||
|
name: host-mount
|
||||||
|
- mountPath: /lib/modules
|
||||||
|
name: lib-modules
|
||||||
|
readOnly: true
|
||||||
|
- name: vitastor-config
|
||||||
|
mountPath: /etc/vitastor
|
||||||
|
- name: plugin-dir
|
||||||
|
mountPath: /var/lib/kubelet/plugins
|
||||||
|
mountPropagation: "Bidirectional"
|
||||||
|
- name: mountpoint-dir
|
||||||
|
mountPath: /var/lib/kubelet/pods
|
||||||
|
mountPropagation: "Bidirectional"
|
||||||
|
- name: liveness-probe
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
image: quay.io/k8scsi/livenessprobe:v1.1.0
|
||||||
|
args:
|
||||||
|
- "--csi-address=$(CSI_ENDPOINT)"
|
||||||
|
- "--health-port=9898"
|
||||||
|
env:
|
||||||
|
- name: CSI_ENDPOINT
|
||||||
|
value: unix://csi/csi.sock
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /csi
|
||||||
|
name: socket-dir
|
||||||
|
volumes:
|
||||||
|
- name: socket-dir
|
||||||
|
hostPath:
|
||||||
|
path: /var/lib/kubelet/plugins/csi.vitastor.io
|
||||||
|
type: DirectoryOrCreate
|
||||||
|
- name: plugin-dir
|
||||||
|
hostPath:
|
||||||
|
path: /var/lib/kubelet/plugins
|
||||||
|
type: Directory
|
||||||
|
- name: mountpoint-dir
|
||||||
|
hostPath:
|
||||||
|
path: /var/lib/kubelet/pods
|
||||||
|
type: DirectoryOrCreate
|
||||||
|
- name: registration-dir
|
||||||
|
hostPath:
|
||||||
|
path: /var/lib/kubelet/plugins_registry/
|
||||||
|
type: Directory
|
||||||
|
- name: host-dev
|
||||||
|
hostPath:
|
||||||
|
path: /dev
|
||||||
|
- name: host-sys
|
||||||
|
hostPath:
|
||||||
|
path: /sys
|
||||||
|
- name: host-mount
|
||||||
|
hostPath:
|
||||||
|
path: /run/mount
|
||||||
|
- name: lib-modules
|
||||||
|
hostPath:
|
||||||
|
path: /lib/modules
|
||||||
|
- name: vitastor-config
|
||||||
|
configMap:
|
||||||
|
name: vitastor-config
|
|
@ -0,0 +1,102 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-provisioner
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: ClusterRole
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-external-provisioner-runner
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["nodes"]
|
||||||
|
verbs: ["get", "list", "watch"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["secrets"]
|
||||||
|
verbs: ["get", "list", "watch"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["events"]
|
||||||
|
verbs: ["list", "watch", "create", "update", "patch"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["persistentvolumes"]
|
||||||
|
verbs: ["get", "list", "watch", "create", "update", "delete", "patch"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["persistentvolumeclaims"]
|
||||||
|
verbs: ["get", "list", "watch", "update"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["persistentvolumeclaims/status"]
|
||||||
|
verbs: ["update", "patch"]
|
||||||
|
- apiGroups: ["storage.k8s.io"]
|
||||||
|
resources: ["storageclasses"]
|
||||||
|
verbs: ["get", "list", "watch"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshots"]
|
||||||
|
verbs: ["get", "list"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshotcontents"]
|
||||||
|
verbs: ["create", "get", "list", "watch", "update", "delete"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshotclasses"]
|
||||||
|
verbs: ["get", "list", "watch"]
|
||||||
|
- apiGroups: ["storage.k8s.io"]
|
||||||
|
resources: ["volumeattachments"]
|
||||||
|
verbs: ["get", "list", "watch", "update", "patch"]
|
||||||
|
- apiGroups: ["storage.k8s.io"]
|
||||||
|
resources: ["volumeattachments/status"]
|
||||||
|
verbs: ["patch"]
|
||||||
|
- apiGroups: ["storage.k8s.io"]
|
||||||
|
resources: ["csinodes"]
|
||||||
|
verbs: ["get", "list", "watch"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshotcontents/status"]
|
||||||
|
verbs: ["update"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["configmaps"]
|
||||||
|
verbs: ["get"]
|
||||||
|
---
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-provisioner-role
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: vitastor-csi-provisioner
|
||||||
|
namespace: vitastor-system
|
||||||
|
roleRef:
|
||||||
|
kind: ClusterRole
|
||||||
|
name: vitastor-external-provisioner-runner
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: Role
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-external-provisioner-cfg
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["configmaps"]
|
||||||
|
verbs: ["get", "list", "watch", "create", "update", "delete"]
|
||||||
|
- apiGroups: ["coordination.k8s.io"]
|
||||||
|
resources: ["leases"]
|
||||||
|
verbs: ["get", "watch", "list", "delete", "update", "create"]
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: RoleBinding
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
name: vitastor-csi-provisioner-role-cfg
|
||||||
|
namespace: vitastor-system
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: vitastor-csi-provisioner
|
||||||
|
namespace: vitastor-system
|
||||||
|
roleRef:
|
||||||
|
kind: Role
|
||||||
|
name: vitastor-external-provisioner-cfg
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
|
@ -0,0 +1,60 @@
|
||||||
|
---
|
||||||
|
apiVersion: policy/v1beta1
|
||||||
|
kind: PodSecurityPolicy
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-provisioner-psp
|
||||||
|
spec:
|
||||||
|
allowPrivilegeEscalation: true
|
||||||
|
allowedCapabilities:
|
||||||
|
- 'SYS_ADMIN'
|
||||||
|
fsGroup:
|
||||||
|
rule: RunAsAny
|
||||||
|
privileged: true
|
||||||
|
runAsUser:
|
||||||
|
rule: RunAsAny
|
||||||
|
seLinux:
|
||||||
|
rule: RunAsAny
|
||||||
|
supplementalGroups:
|
||||||
|
rule: RunAsAny
|
||||||
|
volumes:
|
||||||
|
- 'configMap'
|
||||||
|
- 'emptyDir'
|
||||||
|
- 'projected'
|
||||||
|
- 'secret'
|
||||||
|
- 'downwardAPI'
|
||||||
|
- 'hostPath'
|
||||||
|
allowedHostPaths:
|
||||||
|
- pathPrefix: '/dev'
|
||||||
|
readOnly: false
|
||||||
|
- pathPrefix: '/sys'
|
||||||
|
readOnly: false
|
||||||
|
- pathPrefix: '/lib/modules'
|
||||||
|
readOnly: true
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: Role
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor-csi-provisioner-psp
|
||||||
|
rules:
|
||||||
|
- apiGroups: ['policy']
|
||||||
|
resources: ['podsecuritypolicies']
|
||||||
|
verbs: ['use']
|
||||||
|
resourceNames: ['vitastor-csi-provisioner-psp']
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: RoleBinding
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
name: vitastor-csi-provisioner-psp
|
||||||
|
namespace: vitastor-system
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: vitastor-csi-provisioner
|
||||||
|
namespace: vitastor-system
|
||||||
|
roleRef:
|
||||||
|
kind: Role
|
||||||
|
name: vitastor-csi-provisioner-psp
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
|
@ -0,0 +1,159 @@
|
||||||
|
---
|
||||||
|
kind: Service
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: csi-vitastor-provisioner
|
||||||
|
labels:
|
||||||
|
app: csi-metrics
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: csi-vitastor-provisioner
|
||||||
|
ports:
|
||||||
|
- name: http-metrics
|
||||||
|
port: 8080
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 8680
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: csi-vitastor-provisioner
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: csi-vitastor-provisioner
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
labels:
|
||||||
|
app: csi-vitastor-provisioner
|
||||||
|
spec:
|
||||||
|
affinity:
|
||||||
|
podAntiAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- labelSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- key: app
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- csi-vitastor-provisioner
|
||||||
|
topologyKey: "kubernetes.io/hostname"
|
||||||
|
serviceAccountName: vitastor-csi-provisioner
|
||||||
|
priorityClassName: system-cluster-critical
|
||||||
|
containers:
|
||||||
|
- name: csi-provisioner
|
||||||
|
image: k8s.gcr.io/sig-storage/csi-provisioner:v2.2.0
|
||||||
|
args:
|
||||||
|
- "--csi-address=$(ADDRESS)"
|
||||||
|
- "--v=5"
|
||||||
|
- "--timeout=150s"
|
||||||
|
- "--retry-interval-start=500ms"
|
||||||
|
- "--leader-election=true"
|
||||||
|
# set it to true to use topology based provisioning
|
||||||
|
- "--feature-gates=Topology=false"
|
||||||
|
# if fstype is not specified in storageclass, ext4 is default
|
||||||
|
- "--default-fstype=ext4"
|
||||||
|
- "--extra-create-metadata=true"
|
||||||
|
env:
|
||||||
|
- name: ADDRESS
|
||||||
|
value: unix:///csi/csi-provisioner.sock
|
||||||
|
imagePullPolicy: "IfNotPresent"
|
||||||
|
volumeMounts:
|
||||||
|
- name: socket-dir
|
||||||
|
mountPath: /csi
|
||||||
|
- name: csi-snapshotter
|
||||||
|
image: k8s.gcr.io/sig-storage/csi-snapshotter:v4.0.0
|
||||||
|
args:
|
||||||
|
- "--csi-address=$(ADDRESS)"
|
||||||
|
- "--v=5"
|
||||||
|
- "--timeout=150s"
|
||||||
|
- "--leader-election=true"
|
||||||
|
env:
|
||||||
|
- name: ADDRESS
|
||||||
|
value: unix:///csi/csi-provisioner.sock
|
||||||
|
imagePullPolicy: "IfNotPresent"
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
volumeMounts:
|
||||||
|
- name: socket-dir
|
||||||
|
mountPath: /csi
|
||||||
|
- name: csi-attacher
|
||||||
|
image: k8s.gcr.io/sig-storage/csi-attacher:v3.1.0
|
||||||
|
args:
|
||||||
|
- "--v=5"
|
||||||
|
- "--csi-address=$(ADDRESS)"
|
||||||
|
- "--leader-election=true"
|
||||||
|
- "--retry-interval-start=500ms"
|
||||||
|
env:
|
||||||
|
- name: ADDRESS
|
||||||
|
value: /csi/csi-provisioner.sock
|
||||||
|
imagePullPolicy: "IfNotPresent"
|
||||||
|
volumeMounts:
|
||||||
|
- name: socket-dir
|
||||||
|
mountPath: /csi
|
||||||
|
- name: csi-resizer
|
||||||
|
image: k8s.gcr.io/sig-storage/csi-resizer:v1.1.0
|
||||||
|
args:
|
||||||
|
- "--csi-address=$(ADDRESS)"
|
||||||
|
- "--v=5"
|
||||||
|
- "--timeout=150s"
|
||||||
|
- "--leader-election"
|
||||||
|
- "--retry-interval-start=500ms"
|
||||||
|
- "--handle-volume-inuse-error=false"
|
||||||
|
env:
|
||||||
|
- name: ADDRESS
|
||||||
|
value: unix:///csi/csi-provisioner.sock
|
||||||
|
imagePullPolicy: "IfNotPresent"
|
||||||
|
volumeMounts:
|
||||||
|
- name: socket-dir
|
||||||
|
mountPath: /csi
|
||||||
|
- name: csi-vitastor
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
capabilities:
|
||||||
|
add: ["SYS_ADMIN"]
|
||||||
|
image: vitalif/vitastor-csi:v0.6.10
|
||||||
|
args:
|
||||||
|
- "--node=$(NODE_ID)"
|
||||||
|
- "--endpoint=$(CSI_ENDPOINT)"
|
||||||
|
env:
|
||||||
|
- name: NODE_ID
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: spec.nodeName
|
||||||
|
- name: CSI_ENDPOINT
|
||||||
|
value: unix:///csi/csi-provisioner.sock
|
||||||
|
imagePullPolicy: "IfNotPresent"
|
||||||
|
volumeMounts:
|
||||||
|
- name: socket-dir
|
||||||
|
mountPath: /csi
|
||||||
|
- mountPath: /dev
|
||||||
|
name: host-dev
|
||||||
|
- mountPath: /sys
|
||||||
|
name: host-sys
|
||||||
|
- mountPath: /lib/modules
|
||||||
|
name: lib-modules
|
||||||
|
readOnly: true
|
||||||
|
- name: vitastor-config
|
||||||
|
mountPath: /etc/vitastor
|
||||||
|
volumes:
|
||||||
|
- name: host-dev
|
||||||
|
hostPath:
|
||||||
|
path: /dev
|
||||||
|
- name: host-sys
|
||||||
|
hostPath:
|
||||||
|
path: /sys
|
||||||
|
- name: lib-modules
|
||||||
|
hostPath:
|
||||||
|
path: /lib/modules
|
||||||
|
- name: socket-dir
|
||||||
|
emptyDir: {
|
||||||
|
medium: "Memory"
|
||||||
|
}
|
||||||
|
- name: vitastor-config
|
||||||
|
configMap:
|
||||||
|
name: vitastor-config
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
# if Kubernetes version is less than 1.18 change
|
||||||
|
# apiVersion to storage.k8s.io/v1betav1
|
||||||
|
apiVersion: storage.k8s.io/v1
|
||||||
|
kind: CSIDriver
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: csi.vitastor.io
|
||||||
|
spec:
|
||||||
|
attachRequired: true
|
||||||
|
podInfoOnMount: false
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
apiVersion: storage.k8s.io/v1
|
||||||
|
kind: StorageClass
|
||||||
|
metadata:
|
||||||
|
namespace: vitastor-system
|
||||||
|
name: vitastor
|
||||||
|
annotations:
|
||||||
|
storageclass.kubernetes.io/is-default-class: "true"
|
||||||
|
provisioner: csi.vitastor.io
|
||||||
|
volumeBindingMode: Immediate
|
||||||
|
parameters:
|
||||||
|
etcdVolumePrefix: ""
|
||||||
|
poolId: "1"
|
||||||
|
# you can choose other configuration file if you have it in the config map
|
||||||
|
#configPath: "/etc/vitastor/vitastor.conf"
|
||||||
|
# you can also specify etcdUrl here, maybe to connect to another Vitastor cluster
|
||||||
|
# multiple etcdUrls may be specified, delimited by comma
|
||||||
|
#etcdUrl: "http://192.168.7.2:2379"
|
||||||
|
#etcdPrefix: "/vitastor"
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: test-vitastor-pvc
|
||||||
|
spec:
|
||||||
|
storageClassName: vitastor
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
|
@ -0,0 +1,35 @@
|
||||||
|
module vitastor.io/csi
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/container-storage-interface/spec v1.4.0
|
||||||
|
github.com/coreos/bbolt v0.0.0-00010101000000-000000000000 // indirect
|
||||||
|
github.com/coreos/etcd v3.3.25+incompatible // indirect
|
||||||
|
github.com/coreos/go-semver v0.3.0 // indirect
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
|
||||||
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
|
||||||
|
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||||
|
github.com/gorilla/websocket v1.4.2 // indirect
|
||||||
|
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
|
||||||
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
|
||||||
|
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||||
|
github.com/kubernetes-csi/csi-lib-utils v0.9.1
|
||||||
|
github.com/soheilhy/cmux v0.1.5 // indirect
|
||||||
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
|
||||||
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
|
||||||
|
go.etcd.io/bbolt v0.0.0-00010101000000-000000000000 // indirect
|
||||||
|
go.etcd.io/etcd v3.3.25+incompatible
|
||||||
|
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb
|
||||||
|
google.golang.org/grpc v1.33.1
|
||||||
|
k8s.io/klog v1.0.0
|
||||||
|
k8s.io/utils v0.0.0-20210305010621-2afb4311ab10
|
||||||
|
)
|
||||||
|
|
||||||
|
replace github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5
|
||||||
|
|
||||||
|
replace go.etcd.io/bbolt => github.com/coreos/bbolt v1.3.5
|
||||||
|
|
||||||
|
replace google.golang.org/grpc => google.golang.org/grpc v1.25.1
|
|
@ -0,0 +1,448 @@
|
||||||
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||||
|
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||||
|
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||||
|
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||||
|
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||||
|
cloud.google.com/go v0.51.0/go.mod h1:hWtGJ6gnXH+KgDv+V0zFGDvpi07n3z8ZNj3T1RW0Gcw=
|
||||||
|
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||||
|
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||||
|
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||||
|
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||||
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
|
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
|
||||||
|
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
|
||||||
|
github.com/Azure/go-autorest/autorest v0.9.6/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630=
|
||||||
|
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
|
||||||
|
github.com/Azure/go-autorest/autorest/adal v0.8.2/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q=
|
||||||
|
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
|
||||||
|
github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g=
|
||||||
|
github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
|
||||||
|
github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
|
||||||
|
github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM=
|
||||||
|
github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
|
||||||
|
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
|
||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
|
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||||
|
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
|
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||||
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
|
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
|
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||||
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
|
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||||
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
|
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
|
||||||
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
|
github.com/container-storage-interface/spec v1.2.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
|
||||||
|
github.com/container-storage-interface/spec v1.4.0 h1:ozAshSKxpJnYUfmkpZCTYyF/4MYeYlhdXbAvPvfGmkg=
|
||||||
|
github.com/container-storage-interface/spec v1.4.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
|
||||||
|
github.com/coreos/bbolt v1.3.5 h1:XFv7xaq7701j8ZSEzR28VohFYSlyakMyqNMU5FQH6Ac=
|
||||||
|
github.com/coreos/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||||
|
github.com/coreos/etcd v3.3.25+incompatible h1:0GQEw6h3YnuOVdtwygkIfJ+Omx0tZ8/QkVyXI4LkbeY=
|
||||||
|
github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
|
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
|
||||||
|
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
|
||||||
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||||
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
|
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
||||||
|
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
||||||
|
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||||
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
|
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||||
|
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
|
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
|
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
|
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
|
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
||||||
|
github.com/go-logr/logr v0.2.0 h1:QvGt2nLcHH0WK9orKa+ppBPAxREcH364nPUedEpK0TY=
|
||||||
|
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||||
|
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||||
|
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
|
||||||
|
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
||||||
|
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||||
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
|
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
|
||||||
|
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||||
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7 h1:5ZkaAPbicIKTF2I64qf5Fh8Aa83Q/dnOafMYV0OMwjA=
|
||||||
|
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
|
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||||
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
|
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
|
||||||
|
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||||
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
|
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
|
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
|
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||||
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
|
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||||
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||||
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
|
github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg=
|
||||||
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||||
|
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw=
|
||||||
|
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y=
|
||||||
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
|
||||||
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||||
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
|
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
|
||||||
|
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||||
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
|
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
||||||
|
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
|
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||||
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
|
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||||
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||||
|
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/kubernetes-csi/csi-lib-utils v0.9.1 h1:sGq6ifVujfMSkfTsMZip44Ttv8SDXvsBlFk9GdYl/b8=
|
||||||
|
github.com/kubernetes-csi/csi-lib-utils v0.9.1/go.mod h1:8E2jVUX9j3QgspwHXa6LwyN7IHQDjW9jX3kwoWnSC+M=
|
||||||
|
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||||
|
github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||||
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
|
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
|
||||||
|
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||||
|
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
|
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||||
|
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
||||||
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
|
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||||
|
github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA=
|
||||||
|
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||||
|
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||||
|
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
|
||||||
|
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||||
|
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
|
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
|
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
|
||||||
|
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||||
|
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||||
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
|
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
|
||||||
|
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||||
|
github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=
|
||||||
|
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
|
||||||
|
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||||
|
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||||
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA=
|
||||||
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
|
||||||
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
|
||||||
|
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||||
|
go.etcd.io/etcd v3.3.25+incompatible h1:V1RzkZJj9LqsJRy+TUBgpWSbZXITLB819lstuTFoZOY=
|
||||||
|
go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
|
||||||
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
|
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
|
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
|
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
|
||||||
|
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
|
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
|
||||||
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
|
go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
|
||||||
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
|
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||||
|
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||||
|
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||||
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||||
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||||
|
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||||
|
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||||
|
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||||
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
|
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
|
||||||
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
|
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=
|
||||||
|
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 h1:5/PjkGUjvEU5Gl6BxmvKRPpqo2uNMv4rcHBMwzk/st8=
|
||||||
|
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
|
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
|
||||||
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
|
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||||
|
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||||
|
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||||
|
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||||
|
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||||
|
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||||
|
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
|
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
|
||||||
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
|
google.golang.org/grpc v1.25.1 h1:wdKvqQk7IttEw92GoRyKG2IDrUIpgpj6H6m81yfeMW0=
|
||||||
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||||
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||||
|
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA=
|
||||||
|
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||||
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
|
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||||
|
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
|
||||||
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
|
k8s.io/api v0.19.0/go.mod h1:I1K45XlvTrDjmj5LoM5LuP/KYrhWbjUKT/SoPG0qTjw=
|
||||||
|
k8s.io/apimachinery v0.19.0/go.mod h1:DnPGDnARWFvYa3pMHgSxtbZb7gpzzAZ1pTfaUNDVlmA=
|
||||||
|
k8s.io/client-go v0.19.0/go.mod h1:H9E/VT95blcFQnlyShFgnFT9ZnJOAceiUHM3MlRC+mU=
|
||||||
|
k8s.io/component-base v0.19.0/go.mod h1:dKsY8BxkA+9dZIAh2aWJLL/UdASFDNtGYTCItL4LM7Y=
|
||||||
|
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||||
|
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
|
||||||
|
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
||||||
|
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||||
|
k8s.io/klog/v2 v2.2.0 h1:XRvcwJozkgZ1UQJmfMGpvRthQHOvihEhYtDfAaxMz/A=
|
||||||
|
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||||
|
k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o=
|
||||||
|
k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||||
|
k8s.io/utils v0.0.0-20210305010621-2afb4311ab10 h1:u5rPykqiCpL+LBfjRkXvnK71gOgIdmq3eHUEkPrbeTI=
|
||||||
|
k8s.io/utils v0.0.0-20210305010621-2afb4311ab10/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||||
|
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||||
|
sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||||
|
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||||
|
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||||
|
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
||||||
|
|
||||||
|
package vitastor
|
||||||
|
|
||||||
|
const (
|
||||||
|
vitastorCSIDriverName = "csi.vitastor.io"
|
||||||
|
vitastorCSIDriverVersion = "0.6.10"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config struct fills the parameters of request or user input
|
||||||
|
type Config struct
|
||||||
|
{
|
||||||
|
Endpoint string
|
||||||
|
NodeID string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewConfig returns config struct to initialize new driver
|
||||||
|
func NewConfig() *Config
|
||||||
|
{
|
||||||
|
return &Config{}
|
||||||
|
}
|
|
@ -0,0 +1,530 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
||||||
|
|
||||||
|
package vitastor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
"bytes"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
|
||||||
|
"k8s.io/klog"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
|
"go.etcd.io/etcd/clientv3"
|
||||||
|
|
||||||
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
KB int64 = 1024
|
||||||
|
MB int64 = 1024 * KB
|
||||||
|
GB int64 = 1024 * MB
|
||||||
|
TB int64 = 1024 * GB
|
||||||
|
ETCD_TIMEOUT time.Duration = 15*time.Second
|
||||||
|
)
|
||||||
|
|
||||||
|
type InodeIndex struct
|
||||||
|
{
|
||||||
|
Id uint64 `json:"id"`
|
||||||
|
PoolId uint64 `json:"pool_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type InodeConfig struct
|
||||||
|
{
|
||||||
|
Name string `json:"name"`
|
||||||
|
Size uint64 `json:"size,omitempty"`
|
||||||
|
ParentPool uint64 `json:"parent_pool,omitempty"`
|
||||||
|
ParentId uint64 `json:"parent_id,omitempty"`
|
||||||
|
Readonly bool `json:"readonly,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ControllerServer struct
|
||||||
|
{
|
||||||
|
*Driver
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewControllerServer create new instance controller
|
||||||
|
func NewControllerServer(driver *Driver) *ControllerServer
|
||||||
|
{
|
||||||
|
return &ControllerServer{
|
||||||
|
Driver: driver,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetConnectionParams(params map[string]string) (map[string]string, []string, string)
|
||||||
|
{
|
||||||
|
ctxVars := make(map[string]string)
|
||||||
|
configPath := params["configPath"]
|
||||||
|
if (configPath == "")
|
||||||
|
{
|
||||||
|
configPath = "/etc/vitastor/vitastor.conf"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctxVars["configPath"] = configPath
|
||||||
|
}
|
||||||
|
config := make(map[string]interface{})
|
||||||
|
if configFD, err := os.Open(configPath); err == nil
|
||||||
|
{
|
||||||
|
defer configFD.Close()
|
||||||
|
data, _ := ioutil.ReadAll(configFD)
|
||||||
|
json.Unmarshal(data, &config)
|
||||||
|
}
|
||||||
|
// Try to load prefix & etcd URL from the config
|
||||||
|
var etcdUrl []string
|
||||||
|
if (params["etcdUrl"] != "")
|
||||||
|
{
|
||||||
|
ctxVars["etcdUrl"] = params["etcdUrl"]
|
||||||
|
etcdUrl = strings.Split(params["etcdUrl"], ",")
|
||||||
|
}
|
||||||
|
if (len(etcdUrl) == 0)
|
||||||
|
{
|
||||||
|
switch config["etcd_address"].(type)
|
||||||
|
{
|
||||||
|
case string:
|
||||||
|
etcdUrl = strings.Split(config["etcd_address"].(string), ",")
|
||||||
|
case []string:
|
||||||
|
etcdUrl = config["etcd_address"].([]string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
etcdPrefix := params["etcdPrefix"]
|
||||||
|
if (etcdPrefix == "")
|
||||||
|
{
|
||||||
|
etcdPrefix, _ = config["etcd_prefix"].(string)
|
||||||
|
if (etcdPrefix == "")
|
||||||
|
{
|
||||||
|
etcdPrefix = "/vitastor"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctxVars["etcdPrefix"] = etcdPrefix
|
||||||
|
}
|
||||||
|
return ctxVars, etcdUrl, etcdPrefix
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the volume
|
||||||
|
func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error)
|
||||||
|
{
|
||||||
|
klog.Infof("received controller create volume request %+v", protosanitizer.StripSecrets(req))
|
||||||
|
if (req == nil)
|
||||||
|
{
|
||||||
|
return nil, status.Errorf(codes.InvalidArgument, "request cannot be empty")
|
||||||
|
}
|
||||||
|
if (req.GetName() == "")
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "name is a required field")
|
||||||
|
}
|
||||||
|
volumeCapabilities := req.GetVolumeCapabilities()
|
||||||
|
if (volumeCapabilities == nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "volume capabilities is a required field")
|
||||||
|
}
|
||||||
|
|
||||||
|
etcdVolumePrefix := req.Parameters["etcdVolumePrefix"]
|
||||||
|
poolId, _ := strconv.ParseUint(req.Parameters["poolId"], 10, 64)
|
||||||
|
if (poolId == 0)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "poolId is missing in storage class configuration")
|
||||||
|
}
|
||||||
|
|
||||||
|
volName := etcdVolumePrefix + req.GetName()
|
||||||
|
volSize := 1 * GB
|
||||||
|
if capRange := req.GetCapacityRange(); capRange != nil
|
||||||
|
{
|
||||||
|
volSize = ((capRange.GetRequiredBytes() + MB - 1) / MB) * MB
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: The following should PROBABLY be implemented externally in a management tool
|
||||||
|
|
||||||
|
ctxVars, etcdUrl, etcdPrefix := GetConnectionParams(req.Parameters)
|
||||||
|
if (len(etcdUrl) == 0)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "no etcdUrl in storage class configuration and no etcd_address in vitastor.conf")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect to etcd
|
||||||
|
cli, err := clientv3.New(clientv3.Config{
|
||||||
|
DialTimeout: ETCD_TIMEOUT,
|
||||||
|
Endpoints: etcdUrl,
|
||||||
|
})
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to connect to etcd at "+strings.Join(etcdUrl, ",")+": "+err.Error())
|
||||||
|
}
|
||||||
|
defer cli.Close()
|
||||||
|
|
||||||
|
var imageId uint64 = 0
|
||||||
|
for
|
||||||
|
{
|
||||||
|
// Check if the image exists
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), ETCD_TIMEOUT)
|
||||||
|
resp, err := cli.Get(ctx, etcdPrefix+"/index/image/"+volName)
|
||||||
|
cancel()
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to read key from etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
if (len(resp.Kvs) > 0)
|
||||||
|
{
|
||||||
|
kv := resp.Kvs[0]
|
||||||
|
var v InodeIndex
|
||||||
|
err := json.Unmarshal(kv.Value, &v)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "invalid /index/image/"+volName+" key in etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
poolId = v.PoolId
|
||||||
|
imageId = v.Id
|
||||||
|
inodeCfgKey := fmt.Sprintf("/config/inode/%d/%d", poolId, imageId)
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), ETCD_TIMEOUT)
|
||||||
|
resp, err := cli.Get(ctx, etcdPrefix+inodeCfgKey)
|
||||||
|
cancel()
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to read key from etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
if (len(resp.Kvs) == 0)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "missing "+inodeCfgKey+" key in etcd")
|
||||||
|
}
|
||||||
|
var inodeCfg InodeConfig
|
||||||
|
err = json.Unmarshal(resp.Kvs[0].Value, &inodeCfg)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "invalid "+inodeCfgKey+" key in etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
if (inodeCfg.Size < uint64(volSize))
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "image "+volName+" is already created, but size is less than expected")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Find a free ID
|
||||||
|
// Create image metadata in a transaction verifying that the image doesn't exist yet AND ID is still free
|
||||||
|
maxIdKey := fmt.Sprintf("%s/index/maxid/%d", etcdPrefix, poolId)
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), ETCD_TIMEOUT)
|
||||||
|
resp, err := cli.Get(ctx, maxIdKey)
|
||||||
|
cancel()
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to read key from etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
var modRev int64
|
||||||
|
var nextId uint64
|
||||||
|
if (len(resp.Kvs) > 0)
|
||||||
|
{
|
||||||
|
var err error
|
||||||
|
nextId, err = strconv.ParseUint(string(resp.Kvs[0].Value), 10, 64)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, maxIdKey+" contains invalid ID")
|
||||||
|
}
|
||||||
|
modRev = resp.Kvs[0].ModRevision
|
||||||
|
nextId++
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextId = 1
|
||||||
|
}
|
||||||
|
inodeIdxJson, _ := json.Marshal(InodeIndex{
|
||||||
|
Id: nextId,
|
||||||
|
PoolId: poolId,
|
||||||
|
})
|
||||||
|
inodeCfgJson, _ := json.Marshal(InodeConfig{
|
||||||
|
Name: volName,
|
||||||
|
Size: uint64(volSize),
|
||||||
|
})
|
||||||
|
ctx, cancel = context.WithTimeout(context.Background(), ETCD_TIMEOUT)
|
||||||
|
txnResp, err := cli.Txn(ctx).If(
|
||||||
|
clientv3.Compare(clientv3.ModRevision(fmt.Sprintf("%s/index/maxid/%d", etcdPrefix, poolId)), "=", modRev),
|
||||||
|
clientv3.Compare(clientv3.CreateRevision(fmt.Sprintf("%s/index/image/%s", etcdPrefix, volName)), "=", 0),
|
||||||
|
clientv3.Compare(clientv3.CreateRevision(fmt.Sprintf("%s/config/inode/%d/%d", etcdPrefix, poolId, nextId)), "=", 0),
|
||||||
|
).Then(
|
||||||
|
clientv3.OpPut(fmt.Sprintf("%s/index/maxid/%d", etcdPrefix, poolId), fmt.Sprintf("%d", nextId)),
|
||||||
|
clientv3.OpPut(fmt.Sprintf("%s/index/image/%s", etcdPrefix, volName), string(inodeIdxJson)),
|
||||||
|
clientv3.OpPut(fmt.Sprintf("%s/config/inode/%d/%d", etcdPrefix, poolId, nextId), string(inodeCfgJson)),
|
||||||
|
).Commit()
|
||||||
|
cancel()
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to commit transaction in etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
if (txnResp.Succeeded)
|
||||||
|
{
|
||||||
|
imageId = nextId
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// Start over if the transaction fails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctxVars["name"] = volName
|
||||||
|
volumeIdJson, _ := json.Marshal(ctxVars)
|
||||||
|
return &csi.CreateVolumeResponse{
|
||||||
|
Volume: &csi.Volume{
|
||||||
|
// Ugly, but VolumeContext isn't passed to DeleteVolume :-(
|
||||||
|
VolumeId: string(volumeIdJson),
|
||||||
|
CapacityBytes: volSize,
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteVolume deletes the given volume
|
||||||
|
func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error)
|
||||||
|
{
|
||||||
|
klog.Infof("received controller delete volume request %+v", protosanitizer.StripSecrets(req))
|
||||||
|
if (req == nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "request cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctxVars := make(map[string]string)
|
||||||
|
err := json.Unmarshal([]byte(req.VolumeId), &ctxVars)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "volume ID not in JSON format")
|
||||||
|
}
|
||||||
|
volName := ctxVars["name"]
|
||||||
|
|
||||||
|
_, etcdUrl, etcdPrefix := GetConnectionParams(ctxVars)
|
||||||
|
if (len(etcdUrl) == 0)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "no etcdUrl in storage class configuration and no etcd_address in vitastor.conf")
|
||||||
|
}
|
||||||
|
|
||||||
|
cli, err := clientv3.New(clientv3.Config{
|
||||||
|
DialTimeout: ETCD_TIMEOUT,
|
||||||
|
Endpoints: etcdUrl,
|
||||||
|
})
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to connect to etcd at "+strings.Join(etcdUrl, ",")+": "+err.Error())
|
||||||
|
}
|
||||||
|
defer cli.Close()
|
||||||
|
|
||||||
|
// Find inode by name
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), ETCD_TIMEOUT)
|
||||||
|
resp, err := cli.Get(ctx, etcdPrefix+"/index/image/"+volName)
|
||||||
|
cancel()
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to read key from etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
if (len(resp.Kvs) == 0)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.NotFound, "volume "+volName+" does not exist")
|
||||||
|
}
|
||||||
|
var idx InodeIndex
|
||||||
|
err = json.Unmarshal(resp.Kvs[0].Value, &idx)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "invalid /index/image/"+volName+" key in etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get inode config
|
||||||
|
inodeCfgKey := fmt.Sprintf("%s/config/inode/%d/%d", etcdPrefix, idx.PoolId, idx.Id)
|
||||||
|
ctx, cancel = context.WithTimeout(context.Background(), ETCD_TIMEOUT)
|
||||||
|
resp, err = cli.Get(ctx, inodeCfgKey)
|
||||||
|
cancel()
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to read key from etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
if (len(resp.Kvs) == 0)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.NotFound, "volume "+volName+" does not exist")
|
||||||
|
}
|
||||||
|
var inodeCfg InodeConfig
|
||||||
|
err = json.Unmarshal(resp.Kvs[0].Value, &inodeCfg)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "invalid "+inodeCfgKey+" key in etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete inode data by invoking vitastor-cli
|
||||||
|
args := []string{
|
||||||
|
"rm-data", "--etcd_address", strings.Join(etcdUrl, ","),
|
||||||
|
"--pool", fmt.Sprintf("%d", idx.PoolId),
|
||||||
|
"--inode", fmt.Sprintf("%d", idx.Id),
|
||||||
|
}
|
||||||
|
if (ctxVars["configPath"] != "")
|
||||||
|
{
|
||||||
|
args = append(args, "--config_path", ctxVars["configPath"])
|
||||||
|
}
|
||||||
|
c := exec.Command("/usr/bin/vitastor-cli", args...)
|
||||||
|
var stderr bytes.Buffer
|
||||||
|
c.Stdout = nil
|
||||||
|
c.Stderr = &stderr
|
||||||
|
err = c.Run()
|
||||||
|
stderrStr := string(stderr.Bytes())
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
klog.Errorf("vitastor-cli rm-data failed: %s, status %s\n", stderrStr, err)
|
||||||
|
return nil, status.Error(codes.Internal, stderrStr+" (status "+err.Error()+")")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete inode config in etcd
|
||||||
|
ctx, cancel = context.WithTimeout(context.Background(), ETCD_TIMEOUT)
|
||||||
|
txnResp, err := cli.Txn(ctx).Then(
|
||||||
|
clientv3.OpDelete(fmt.Sprintf("%s/index/image/%s", etcdPrefix, volName)),
|
||||||
|
clientv3.OpDelete(fmt.Sprintf("%s/config/inode/%d/%d", etcdPrefix, idx.PoolId, idx.Id)),
|
||||||
|
).Commit()
|
||||||
|
cancel()
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to delete keys in etcd: "+err.Error())
|
||||||
|
}
|
||||||
|
if (!txnResp.Succeeded)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "failed to delete keys in etcd: transaction failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &csi.DeleteVolumeResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ControllerPublishVolume return Unimplemented error
|
||||||
|
func (cs *ControllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ControllerUnpublishVolume return Unimplemented error
|
||||||
|
func (cs *ControllerServer) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateVolumeCapabilities checks whether the volume capabilities requested are supported.
|
||||||
|
func (cs *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error)
|
||||||
|
{
|
||||||
|
klog.Infof("received controller validate volume capability request %+v", protosanitizer.StripSecrets(req))
|
||||||
|
if (req == nil)
|
||||||
|
{
|
||||||
|
return nil, status.Errorf(codes.InvalidArgument, "request is nil")
|
||||||
|
}
|
||||||
|
volumeID := req.GetVolumeId()
|
||||||
|
if (volumeID == "")
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "volumeId is nil")
|
||||||
|
}
|
||||||
|
volumeCapabilities := req.GetVolumeCapabilities()
|
||||||
|
if (volumeCapabilities == nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "volumeCapabilities is nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
var volumeCapabilityAccessModes []*csi.VolumeCapability_AccessMode
|
||||||
|
for _, mode := range []csi.VolumeCapability_AccessMode_Mode{
|
||||||
|
csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
|
||||||
|
csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
|
||||||
|
} {
|
||||||
|
volumeCapabilityAccessModes = append(volumeCapabilityAccessModes, &csi.VolumeCapability_AccessMode{Mode: mode})
|
||||||
|
}
|
||||||
|
|
||||||
|
capabilitySupport := false
|
||||||
|
for _, capability := range volumeCapabilities
|
||||||
|
{
|
||||||
|
for _, volumeCapabilityAccessMode := range volumeCapabilityAccessModes
|
||||||
|
{
|
||||||
|
if (volumeCapabilityAccessMode.Mode == capability.AccessMode.Mode)
|
||||||
|
{
|
||||||
|
capabilitySupport = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!capabilitySupport)
|
||||||
|
{
|
||||||
|
return nil, status.Errorf(codes.NotFound, "%v not supported", req.GetVolumeCapabilities())
|
||||||
|
}
|
||||||
|
|
||||||
|
return &csi.ValidateVolumeCapabilitiesResponse{
|
||||||
|
Confirmed: &csi.ValidateVolumeCapabilitiesResponse_Confirmed{
|
||||||
|
VolumeCapabilities: req.VolumeCapabilities,
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListVolumes returns a list of volumes
|
||||||
|
func (cs *ControllerServer) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCapacity returns the capacity of the storage pool
|
||||||
|
func (cs *ControllerServer) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ControllerGetCapabilities returns the capabilities of the controller service.
|
||||||
|
func (cs *ControllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error)
|
||||||
|
{
|
||||||
|
functionControllerServerCapabilities := func(cap csi.ControllerServiceCapability_RPC_Type) *csi.ControllerServiceCapability
|
||||||
|
{
|
||||||
|
return &csi.ControllerServiceCapability{
|
||||||
|
Type: &csi.ControllerServiceCapability_Rpc{
|
||||||
|
Rpc: &csi.ControllerServiceCapability_RPC{
|
||||||
|
Type: cap,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var controllerServerCapabilities []*csi.ControllerServiceCapability
|
||||||
|
for _, capability := range []csi.ControllerServiceCapability_RPC_Type{
|
||||||
|
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
|
||||||
|
csi.ControllerServiceCapability_RPC_LIST_VOLUMES,
|
||||||
|
csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
|
||||||
|
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
|
||||||
|
} {
|
||||||
|
controllerServerCapabilities = append(controllerServerCapabilities, functionControllerServerCapabilities(capability))
|
||||||
|
}
|
||||||
|
|
||||||
|
return &csi.ControllerGetCapabilitiesResponse{
|
||||||
|
Capabilities: controllerServerCapabilities,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSnapshot create snapshot of an existing PV
|
||||||
|
func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSnapshot delete provided snapshot of a PV
|
||||||
|
func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSnapshots list the snapshots of a PV
|
||||||
|
func (cs *ControllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ControllerExpandVolume resizes a volume
|
||||||
|
func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ControllerGetVolume get volume info
|
||||||
|
func (cs *ControllerServer) ControllerGetVolume(ctx context.Context, req *csi.ControllerGetVolumeRequest) (*csi.ControllerGetVolumeResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
|
@ -0,0 +1,137 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vitastor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
|
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Defines Non blocking GRPC server interfaces
|
||||||
|
type NonBlockingGRPCServer interface {
|
||||||
|
// Start services at the endpoint
|
||||||
|
Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer)
|
||||||
|
// Waits for the service to stop
|
||||||
|
Wait()
|
||||||
|
// Stops the service gracefully
|
||||||
|
Stop()
|
||||||
|
// Stops the service forcefully
|
||||||
|
ForceStop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNonBlockingGRPCServer() NonBlockingGRPCServer {
|
||||||
|
return &nonBlockingGRPCServer{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NonBlocking server
|
||||||
|
type nonBlockingGRPCServer struct {
|
||||||
|
wg sync.WaitGroup
|
||||||
|
server *grpc.Server
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *nonBlockingGRPCServer) Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) {
|
||||||
|
|
||||||
|
s.wg.Add(1)
|
||||||
|
|
||||||
|
go s.serve(endpoint, ids, cs, ns)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *nonBlockingGRPCServer) Wait() {
|
||||||
|
s.wg.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *nonBlockingGRPCServer) Stop() {
|
||||||
|
s.server.GracefulStop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *nonBlockingGRPCServer) ForceStop() {
|
||||||
|
s.server.Stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) {
|
||||||
|
|
||||||
|
proto, addr, err := ParseEndpoint(endpoint)
|
||||||
|
if err != nil {
|
||||||
|
glog.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if proto == "unix" {
|
||||||
|
addr = "/" + addr
|
||||||
|
if err := os.Remove(addr); err != nil && !os.IsNotExist(err) {
|
||||||
|
glog.Fatalf("Failed to remove %s, error: %s", addr, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
listener, err := net.Listen(proto, addr)
|
||||||
|
if err != nil {
|
||||||
|
glog.Fatalf("Failed to listen: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
opts := []grpc.ServerOption{
|
||||||
|
grpc.UnaryInterceptor(logGRPC),
|
||||||
|
}
|
||||||
|
server := grpc.NewServer(opts...)
|
||||||
|
s.server = server
|
||||||
|
|
||||||
|
if ids != nil {
|
||||||
|
csi.RegisterIdentityServer(server, ids)
|
||||||
|
}
|
||||||
|
if cs != nil {
|
||||||
|
csi.RegisterControllerServer(server, cs)
|
||||||
|
}
|
||||||
|
if ns != nil {
|
||||||
|
csi.RegisterNodeServer(server, ns)
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.Infof("Listening for connections on address: %#v", listener.Addr())
|
||||||
|
|
||||||
|
server.Serve(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseEndpoint(ep string) (string, string, error) {
|
||||||
|
if strings.HasPrefix(strings.ToLower(ep), "unix://") || strings.HasPrefix(strings.ToLower(ep), "tcp://") {
|
||||||
|
s := strings.SplitN(ep, "://", 2)
|
||||||
|
if s[1] != "" {
|
||||||
|
return s[0], s[1], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "", "", fmt.Errorf("Invalid endpoint: %v", ep)
|
||||||
|
}
|
||||||
|
|
||||||
|
func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||||
|
glog.V(3).Infof("GRPC call: %s", info.FullMethod)
|
||||||
|
glog.V(5).Infof("GRPC request: %s", protosanitizer.StripSecrets(req))
|
||||||
|
resp, err := handler(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("GRPC error: %v", err)
|
||||||
|
} else {
|
||||||
|
glog.V(5).Infof("GRPC response: %s", protosanitizer.StripSecrets(resp))
|
||||||
|
}
|
||||||
|
return resp, err
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
||||||
|
|
||||||
|
package vitastor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
|
||||||
|
"k8s.io/klog"
|
||||||
|
|
||||||
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IdentityServer struct of Vitastor CSI driver with supported methods of CSI identity server spec.
|
||||||
|
type IdentityServer struct
|
||||||
|
{
|
||||||
|
*Driver
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewIdentityServer create new instance identity
|
||||||
|
func NewIdentityServer(driver *Driver) *IdentityServer
|
||||||
|
{
|
||||||
|
return &IdentityServer{
|
||||||
|
Driver: driver,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPluginInfo returns metadata of the plugin
|
||||||
|
func (is *IdentityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error)
|
||||||
|
{
|
||||||
|
klog.Infof("received identity plugin info request %+v", protosanitizer.StripSecrets(req))
|
||||||
|
return &csi.GetPluginInfoResponse{
|
||||||
|
Name: vitastorCSIDriverName,
|
||||||
|
VendorVersion: vitastorCSIDriverVersion,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPluginCapabilities returns available capabilities of the plugin
|
||||||
|
func (is *IdentityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error)
|
||||||
|
{
|
||||||
|
klog.Infof("received identity plugin capabilities request %+v", protosanitizer.StripSecrets(req))
|
||||||
|
return &csi.GetPluginCapabilitiesResponse{
|
||||||
|
Capabilities: []*csi.PluginCapability{
|
||||||
|
{
|
||||||
|
Type: &csi.PluginCapability_Service_{
|
||||||
|
Service: &csi.PluginCapability_Service{
|
||||||
|
Type: csi.PluginCapability_Service_CONTROLLER_SERVICE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Probe returns the health and readiness of the plugin
|
||||||
|
func (is *IdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error)
|
||||||
|
{
|
||||||
|
return &csi.ProbeResponse{}, nil
|
||||||
|
}
|
|
@ -0,0 +1,279 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
||||||
|
|
||||||
|
package vitastor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
"bytes"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
"k8s.io/utils/mount"
|
||||||
|
utilexec "k8s.io/utils/exec"
|
||||||
|
|
||||||
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
|
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
|
||||||
|
"k8s.io/klog"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NodeServer struct of Vitastor CSI driver with supported methods of CSI node server spec.
|
||||||
|
type NodeServer struct
|
||||||
|
{
|
||||||
|
*Driver
|
||||||
|
mounter mount.Interface
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewNodeServer create new instance node
|
||||||
|
func NewNodeServer(driver *Driver) *NodeServer
|
||||||
|
{
|
||||||
|
return &NodeServer{
|
||||||
|
Driver: driver,
|
||||||
|
mounter: mount.New(""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeStageVolume mounts the volume to a staging path on the node.
|
||||||
|
func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error)
|
||||||
|
{
|
||||||
|
return &csi.NodeStageVolumeResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeUnstageVolume unstages the volume from the staging path
|
||||||
|
func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error)
|
||||||
|
{
|
||||||
|
return &csi.NodeUnstageVolumeResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Contains(list []string, s string) bool
|
||||||
|
{
|
||||||
|
for i := 0; i < len(list); i++
|
||||||
|
{
|
||||||
|
if (list[i] == s)
|
||||||
|
{
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodePublishVolume mounts the volume mounted to the staging path to the target path
|
||||||
|
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error)
|
||||||
|
{
|
||||||
|
klog.Infof("received node publish volume request %+v", protosanitizer.StripSecrets(req))
|
||||||
|
|
||||||
|
targetPath := req.GetTargetPath()
|
||||||
|
|
||||||
|
// Check that it's not already mounted
|
||||||
|
free, error := mount.IsNotMountPoint(ns.mounter, targetPath)
|
||||||
|
if (error != nil)
|
||||||
|
{
|
||||||
|
if (os.IsNotExist(error))
|
||||||
|
{
|
||||||
|
error := os.MkdirAll(targetPath, 0777)
|
||||||
|
if (error != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, error.Error())
|
||||||
|
}
|
||||||
|
free = true
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, error.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!free)
|
||||||
|
{
|
||||||
|
return &csi.NodePublishVolumeResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ctxVars := make(map[string]string)
|
||||||
|
err := json.Unmarshal([]byte(req.VolumeId), &ctxVars)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, "volume ID not in JSON format")
|
||||||
|
}
|
||||||
|
volName := ctxVars["name"]
|
||||||
|
|
||||||
|
_, etcdUrl, etcdPrefix := GetConnectionParams(ctxVars)
|
||||||
|
if (len(etcdUrl) == 0)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "no etcdUrl in storage class configuration and no etcd_address in vitastor.conf")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map NBD device
|
||||||
|
// FIXME: Check if already mapped
|
||||||
|
args := []string{
|
||||||
|
"map", "--etcd_address", strings.Join(etcdUrl, ","),
|
||||||
|
"--etcd_prefix", etcdPrefix,
|
||||||
|
"--image", volName,
|
||||||
|
};
|
||||||
|
if (ctxVars["configPath"] != "")
|
||||||
|
{
|
||||||
|
args = append(args, "--config_path", ctxVars["configPath"])
|
||||||
|
}
|
||||||
|
if (req.GetReadonly())
|
||||||
|
{
|
||||||
|
args = append(args, "--readonly", "1")
|
||||||
|
}
|
||||||
|
c := exec.Command("/usr/bin/vitastor-nbd", args...)
|
||||||
|
var stdout, stderr bytes.Buffer
|
||||||
|
c.Stdout, c.Stderr = &stdout, &stderr
|
||||||
|
err = c.Run()
|
||||||
|
stdoutStr, stderrStr := string(stdout.Bytes()), string(stderr.Bytes())
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
klog.Errorf("vitastor-nbd map failed: %s, status %s\n", stdoutStr+stderrStr, err)
|
||||||
|
return nil, status.Error(codes.Internal, stdoutStr+stderrStr+" (status "+err.Error()+")")
|
||||||
|
}
|
||||||
|
devicePath := strings.TrimSpace(stdoutStr)
|
||||||
|
|
||||||
|
// Check existing format
|
||||||
|
diskMounter := &mount.SafeFormatAndMount{Interface: ns.mounter, Exec: utilexec.New()}
|
||||||
|
existingFormat, err := diskMounter.GetDiskFormat(devicePath)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
klog.Errorf("failed to get disk format for path %s, error: %v", err)
|
||||||
|
// unmap NBD device
|
||||||
|
unmapOut, unmapErr := exec.Command("/usr/bin/vitastor-nbd", "unmap", devicePath).CombinedOutput()
|
||||||
|
if (unmapErr != nil)
|
||||||
|
{
|
||||||
|
klog.Errorf("failed to unmap NBD device %s: %s, error: %v", devicePath, unmapOut, unmapErr)
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format the device (ext4 or xfs)
|
||||||
|
fsType := req.GetVolumeCapability().GetMount().GetFsType()
|
||||||
|
isBlock := req.GetVolumeCapability().GetBlock() != nil
|
||||||
|
opt := req.GetVolumeCapability().GetMount().GetMountFlags()
|
||||||
|
opt = append(opt, "_netdev")
|
||||||
|
if ((req.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY ||
|
||||||
|
req.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY) &&
|
||||||
|
!Contains(opt, "ro"))
|
||||||
|
{
|
||||||
|
opt = append(opt, "ro")
|
||||||
|
}
|
||||||
|
if (fsType == "xfs")
|
||||||
|
{
|
||||||
|
opt = append(opt, "nouuid")
|
||||||
|
}
|
||||||
|
readOnly := Contains(opt, "ro")
|
||||||
|
if (existingFormat == "" && !readOnly)
|
||||||
|
{
|
||||||
|
args := []string{}
|
||||||
|
switch fsType
|
||||||
|
{
|
||||||
|
case "ext4":
|
||||||
|
args = []string{"-m0", "-Enodiscard,lazy_itable_init=1,lazy_journal_init=1", devicePath}
|
||||||
|
case "xfs":
|
||||||
|
args = []string{"-K", devicePath}
|
||||||
|
}
|
||||||
|
if (len(args) > 0)
|
||||||
|
{
|
||||||
|
cmdOut, cmdErr := diskMounter.Exec.Command("mkfs."+fsType, args...).CombinedOutput()
|
||||||
|
if (cmdErr != nil)
|
||||||
|
{
|
||||||
|
klog.Errorf("failed to run mkfs error: %v, output: %v", cmdErr, string(cmdOut))
|
||||||
|
// unmap NBD device
|
||||||
|
unmapOut, unmapErr := exec.Command("/usr/bin/vitastor-nbd", "unmap", devicePath).CombinedOutput()
|
||||||
|
if (unmapErr != nil)
|
||||||
|
{
|
||||||
|
klog.Errorf("failed to unmap NBD device %s: %s, error: %v", devicePath, unmapOut, unmapErr)
|
||||||
|
}
|
||||||
|
return nil, status.Error(codes.Internal, cmdErr.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isBlock)
|
||||||
|
{
|
||||||
|
opt = append(opt, "bind")
|
||||||
|
err = diskMounter.Mount(devicePath, targetPath, fsType, opt)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = diskMounter.FormatAndMount(devicePath, targetPath, fsType, opt)
|
||||||
|
}
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
klog.Errorf(
|
||||||
|
"failed to mount device path (%s) to path (%s) for volume (%s) error: %s",
|
||||||
|
devicePath, targetPath, volName, err,
|
||||||
|
)
|
||||||
|
// unmap NBD device
|
||||||
|
unmapOut, unmapErr := exec.Command("/usr/bin/vitastor-nbd", "unmap", devicePath).CombinedOutput()
|
||||||
|
if (unmapErr != nil)
|
||||||
|
{
|
||||||
|
klog.Errorf("failed to unmap NBD device %s: %s, error: %v", devicePath, unmapOut, unmapErr)
|
||||||
|
}
|
||||||
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
}
|
||||||
|
return &csi.NodePublishVolumeResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeUnpublishVolume unmounts the volume from the target path
|
||||||
|
func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error)
|
||||||
|
{
|
||||||
|
klog.Infof("received node unpublish volume request %+v", protosanitizer.StripSecrets(req))
|
||||||
|
targetPath := req.GetTargetPath()
|
||||||
|
devicePath, refCount, err := mount.GetDeviceNameFromMount(ns.mounter, targetPath)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
if (os.IsNotExist(err))
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.NotFound, "Target path not found")
|
||||||
|
}
|
||||||
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
}
|
||||||
|
if (devicePath == "")
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.NotFound, "Volume not mounted")
|
||||||
|
}
|
||||||
|
// unmount
|
||||||
|
err = mount.CleanupMountPoint(targetPath, ns.mounter, false)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
}
|
||||||
|
// unmap NBD device
|
||||||
|
if (refCount == 1)
|
||||||
|
{
|
||||||
|
unmapOut, unmapErr := exec.Command("/usr/bin/vitastor-nbd", "unmap", devicePath).CombinedOutput()
|
||||||
|
if (unmapErr != nil)
|
||||||
|
{
|
||||||
|
klog.Errorf("failed to unmap NBD device %s: %s, error: %v", devicePath, unmapOut, unmapErr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &csi.NodeUnpublishVolumeResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeGetVolumeStats returns volume capacity statistics available for the volume
|
||||||
|
func (ns *NodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeExpandVolume expanding the file system on the node
|
||||||
|
func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error)
|
||||||
|
{
|
||||||
|
return nil, status.Error(codes.Unimplemented, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeGetCapabilities returns the supported capabilities of the node server
|
||||||
|
func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error)
|
||||||
|
{
|
||||||
|
return &csi.NodeGetCapabilitiesResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeGetInfo returns NodeGetInfoResponse for CO.
|
||||||
|
func (ns *NodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error)
|
||||||
|
{
|
||||||
|
klog.Infof("received node get info request %+v", protosanitizer.StripSecrets(req))
|
||||||
|
return &csi.NodeGetInfoResponse{
|
||||||
|
NodeId: ns.NodeID,
|
||||||
|
}, nil
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
||||||
|
|
||||||
|
package vitastor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/klog"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Driver struct
|
||||||
|
{
|
||||||
|
*Config
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDriver create new instance driver
|
||||||
|
func NewDriver(config *Config) (*Driver, error)
|
||||||
|
{
|
||||||
|
if (config == nil)
|
||||||
|
{
|
||||||
|
klog.Errorf("Vitastor CSI driver initialization failed")
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
driver := &Driver{
|
||||||
|
Config: config,
|
||||||
|
}
|
||||||
|
klog.Infof("Vitastor CSI driver initialized")
|
||||||
|
return driver, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start server
|
||||||
|
func (driver *Driver) Run()
|
||||||
|
{
|
||||||
|
server := NewNonBlockingGRPCServer()
|
||||||
|
server.Start(driver.Endpoint, NewIdentityServer(driver), NewControllerServer(driver), NewNodeServer(driver))
|
||||||
|
server.Wait()
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"k8s.io/klog"
|
||||||
|
"vitastor.io/csi/src"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main()
|
||||||
|
{
|
||||||
|
var config = vitastor.NewConfig()
|
||||||
|
flag.StringVar(&config.Endpoint, "endpoint", "", "CSI endpoint")
|
||||||
|
flag.StringVar(&config.NodeID, "node", "", "Node ID")
|
||||||
|
flag.Parse()
|
||||||
|
if (config.Endpoint == "")
|
||||||
|
{
|
||||||
|
config.Endpoint = os.Getenv("CSI_ENDPOINT")
|
||||||
|
}
|
||||||
|
if (config.NodeID == "")
|
||||||
|
{
|
||||||
|
config.NodeID = os.Getenv("NODE_ID")
|
||||||
|
}
|
||||||
|
if (config.Endpoint == "" && config.NodeID == "")
|
||||||
|
{
|
||||||
|
fmt.Fprintf(os.Stderr, "Please set -endpoint and -node / CSI_ENDPOINT & NODE_ID env vars\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
drv, err := vitastor.NewDriver(config)
|
||||||
|
if (err != nil)
|
||||||
|
{
|
||||||
|
klog.Fatalln(err)
|
||||||
|
}
|
||||||
|
drv.Run()
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat < vitastor.Dockerfile > ../Dockerfile
|
||||||
|
cd ..
|
||||||
|
mkdir -p packages
|
||||||
|
sudo podman build --build-arg REL=bullseye -v `pwd`/packages:/root/packages -f Dockerfile .
|
||||||
|
rm Dockerfile
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat < vitastor.Dockerfile > ../Dockerfile
|
||||||
|
cd ..
|
||||||
|
mkdir -p packages
|
||||||
|
sudo podman build --build-arg REL=buster -v `pwd`/packages:/root/packages -f Dockerfile .
|
||||||
|
rm Dockerfile
|
|
@ -0,0 +1,27 @@
|
||||||
|
vitastor (0.6.10-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* RDMA support
|
||||||
|
* Bugfixes
|
||||||
|
|
||||||
|
-- Vitaliy Filippov <vitalif@yourcmc.ru> Sat, 01 May 2021 18:46:10 +0300
|
||||||
|
|
||||||
|
vitastor (0.6.0-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Snapshots and Copy-on-Write clones
|
||||||
|
* Image metadata in etcd (name, size)
|
||||||
|
* Image I/O and space statistics in etcd
|
||||||
|
* Write throttling for smoothing random write workloads in SSD+HDD configurations
|
||||||
|
|
||||||
|
-- Vitaliy Filippov <vitalif@yourcmc.ru> Sun, 11 Apr 2021 00:49:18 +0300
|
||||||
|
|
||||||
|
vitastor (0.5.1-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Add jerasure support
|
||||||
|
|
||||||
|
-- Vitaliy Filippov <vitalif@yourcmc.ru> Sat, 05 Dec 2020 17:02:26 +0300
|
||||||
|
|
||||||
|
vitastor (0.5-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* First packaging for Debian
|
||||||
|
|
||||||
|
-- Vitaliy Filippov <vitalif@yourcmc.ru> Thu, 05 Nov 2020 02:20:59 +0300
|
|
@ -0,0 +1 @@
|
||||||
|
13
|
|
@ -0,0 +1,55 @@
|
||||||
|
Source: vitastor
|
||||||
|
Section: admin
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Vitaliy Filippov <vitalif@yourcmc.ru>
|
||||||
|
Build-Depends: debhelper, liburing-dev (>= 0.6), g++ (>= 8), libstdc++6 (>= 8), linux-libc-dev, libgoogle-perftools-dev, libjerasure-dev, libgf-complete-dev, libibverbs-dev
|
||||||
|
Standards-Version: 4.5.0
|
||||||
|
Homepage: https://vitastor.io/
|
||||||
|
Rules-Requires-Root: no
|
||||||
|
|
||||||
|
Package: vitastor
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: vitastor-osd, vitastor-mon, vitastor-client, vitastor-client-dev, vitastor-fio
|
||||||
|
Description: Vitastor, a fast software-defined clustered block storage
|
||||||
|
Vitastor is a small, simple and fast clustered block storage (storage for VM drives),
|
||||||
|
architecturally similar to Ceph which means strong consistency, primary-replication,
|
||||||
|
symmetric clustering and automatic data distribution over any number of drives of any
|
||||||
|
size with configurable redundancy (replication or erasure codes/XOR).
|
||||||
|
|
||||||
|
Package: vitastor-osd
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}, vitastor-client (= ${binary:Version})
|
||||||
|
Description: Vitastor, a fast software-defined clustered block storage - object storage daemon
|
||||||
|
Vitastor object storage daemon, i.e. server program that stores data.
|
||||||
|
|
||||||
|
Package: vitastor-mon
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: ${misc:Depends}, nodejs (>= 10), node-sprintf-js, node-ws (>= 7), lp-solve
|
||||||
|
Description: Vitastor, a fast software-defined clustered block storage - monitor
|
||||||
|
Vitastor monitor, i.e. server program responsible for watching cluster state and
|
||||||
|
scheduling cluster-level operations.
|
||||||
|
|
||||||
|
Package: vitastor-client
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||||
|
Description: Vitastor, a fast software-defined clustered block storage - client
|
||||||
|
Vitastor client library and command-line interface.
|
||||||
|
|
||||||
|
Package: vitastor-client-dev
|
||||||
|
Section: devel
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: ${misc:Depends}, vitastor-client (= ${binary:Version})
|
||||||
|
Description: Vitastor, a fast software-defined clustered block storage - development files
|
||||||
|
Vitastor library headers for development.
|
||||||
|
|
||||||
|
Package: vitastor-fio
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}, vitastor-client (= ${binary:Version}), fio (= ${dep:fio})
|
||||||
|
Description: Vitastor, a fast software-defined clustered block storage - fio drivers
|
||||||
|
Vitastor fio drivers for benchmarking.
|
||||||
|
|
||||||
|
Package: pve-storage-vitastor
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}, vitastor-client (= ${binary:Version})
|
||||||
|
Description: Vitastor Proxmox Virtual Environment storage plugin
|
||||||
|
Vitastor storage plugin for Proxmox Virtual Environment.
|
|
@ -0,0 +1,21 @@
|
||||||
|
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: vitastor
|
||||||
|
Upstream-Contact: Vitaliy Filippov <vitalif@yourcmc.ru>
|
||||||
|
Source: https://vitastor.io
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2019+ Vitaliy Filippov <vitalif@yourcmc.ru>
|
||||||
|
License: Multiple licenses VNPL-1.1 and/or GPL-2.0+
|
||||||
|
All server-side code (OSD, Monitor and so on) is licensed under the terms of
|
||||||
|
Vitastor Network Public License 1.1 (VNPL 1.1), a copyleft license based on
|
||||||
|
GNU GPLv3.0 with the additional "Network Interaction" clause which requires
|
||||||
|
opensourcing all programs directly or indirectly interacting with Vitastor
|
||||||
|
through a computer network and expressly designed to be used in conjunction
|
||||||
|
with it ("Proxy Programs"). Proxy Programs may be made public not only under
|
||||||
|
the terms of the same license, but also under the terms of any GPL-Compatible
|
||||||
|
Free Software License, as listed by the Free Software Foundation.
|
||||||
|
This is a stricter copyleft license than the Affero GPL.
|
||||||
|
.
|
||||||
|
Client libraries (cluster_client and so on) are dual-licensed under the same
|
||||||
|
VNPL 1.1 and also GNU GPL 2.0 or later to allow for compatibility with GPLed
|
||||||
|
software like QEMU and fio.
|
|
@ -0,0 +1 @@
|
||||||
|
dep:fio=3.16-1
|
|
@ -0,0 +1,4 @@
|
||||||
|
VNPL-1.1.txt usr/share/doc/vitastor
|
||||||
|
GPL-2.0.txt usr/share/doc/vitastor
|
||||||
|
README.md usr/share/doc/vitastor
|
||||||
|
README-ru.md usr/share/doc/vitastor
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Build patched libvirt for Debian Buster or Bullseye/Sid inside a container
|
||||||
|
# cd ..; podman build --build-arg REL=bullseye -v `pwd`/packages:/root/packages -f debian/libvirt.Dockerfile .
|
||||||
|
|
||||||
|
ARG REL=
|
||||||
|
FROM debian:$REL
|
||||||
|
ARG REL=
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
RUN if [ "$REL" = "buster" -o "$REL" = "bullseye" ]; then \
|
||||||
|
echo "deb http://deb.debian.org/debian $REL-backports main" >> /etc/apt/sources.list; \
|
||||||
|
echo >> /etc/apt/preferences; \
|
||||||
|
echo 'Package: *' >> /etc/apt/preferences; \
|
||||||
|
echo "Pin: release a=$REL-backports" >> /etc/apt/preferences; \
|
||||||
|
echo 'Pin-Priority: 500' >> /etc/apt/preferences; \
|
||||||
|
fi; \
|
||||||
|
grep '^deb ' /etc/apt/sources.list | perl -pe 's/^deb/deb-src/' >> /etc/apt/sources.list; \
|
||||||
|
echo 'APT::Install-Recommends false;' >> /etc/apt/apt.conf; \
|
||||||
|
echo 'APT::Install-Suggests false;' >> /etc/apt/apt.conf
|
||||||
|
|
||||||
|
RUN apt-get update; apt-get -y install devscripts
|
||||||
|
RUN apt-get -y build-dep libvirt0
|
||||||
|
RUN apt-get -y install libglusterfs-dev
|
||||||
|
RUN apt-get --download-only source libvirt
|
||||||
|
|
||||||
|
ADD patches/libvirt-5.0-vitastor.diff patches/libvirt-7.0-vitastor.diff patches/libvirt-7.5-vitastor.diff patches/libvirt-7.6-vitastor.diff /root
|
||||||
|
RUN set -e; \
|
||||||
|
mkdir -p /root/packages/libvirt-$REL; \
|
||||||
|
rm -rf /root/packages/libvirt-$REL/*; \
|
||||||
|
cd /root/packages/libvirt-$REL; \
|
||||||
|
dpkg-source -x /root/libvirt*.dsc; \
|
||||||
|
D=$(ls -d libvirt-*/); \
|
||||||
|
V=$(ls -d libvirt-*/ | perl -pe 's/libvirt-(\d+\.\d+).*/$1/'); \
|
||||||
|
cp /root/libvirt-$V-vitastor.diff $D/debian/patches; \
|
||||||
|
echo libvirt-$V-vitastor.diff >> $D/debian/patches/series; \
|
||||||
|
cd $D; \
|
||||||
|
V=$(head -n1 debian/changelog | perl -pe 's/^.*\((.*?)(~bpo[\d\+]*)?(\+deb[u\d]+)?\).*$/$1/')+vitastor2; \
|
||||||
|
DEBEMAIL="Vitaliy Filippov <vitalif@yourcmc.ru>" dch -D $REL -v $V 'Add Vitastor support'; \
|
||||||
|
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage --jobs=auto -sa; \
|
||||||
|
rm -rf /root/packages/libvirt-$REL/$D
|
|
@ -0,0 +1,61 @@
|
||||||
|
# Build patched QEMU for Debian Buster or Bullseye/Sid inside a container
|
||||||
|
# cd ..; podman build --build-arg REL=bullseye -v `pwd`/packages:/root/packages -f debian/patched-qemu.Dockerfile .
|
||||||
|
|
||||||
|
ARG REL=
|
||||||
|
FROM debian:$REL
|
||||||
|
ARG REL=
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
RUN if [ "$REL" = "buster" -o "$REL" = "bullseye" ]; then \
|
||||||
|
echo "deb http://deb.debian.org/debian $REL-backports main" >> /etc/apt/sources.list; \
|
||||||
|
echo >> /etc/apt/preferences; \
|
||||||
|
echo 'Package: *' >> /etc/apt/preferences; \
|
||||||
|
echo "Pin: release a=$REL-backports" >> /etc/apt/preferences; \
|
||||||
|
echo 'Pin-Priority: 500' >> /etc/apt/preferences; \
|
||||||
|
fi; \
|
||||||
|
grep '^deb ' /etc/apt/sources.list | perl -pe 's/^deb/deb-src/' >> /etc/apt/sources.list; \
|
||||||
|
echo 'APT::Install-Recommends false;' >> /etc/apt/apt.conf; \
|
||||||
|
echo 'APT::Install-Suggests false;' >> /etc/apt/apt.conf
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get -y install qemu fio liburing1 liburing-dev libgoogle-perftools-dev devscripts
|
||||||
|
RUN apt-get -y build-dep qemu
|
||||||
|
# To build a custom version
|
||||||
|
#RUN cp /root/packages/qemu-orig/* /root
|
||||||
|
RUN apt-get --download-only source qemu
|
||||||
|
|
||||||
|
ADD patches/qemu-5.0-vitastor.patch patches/qemu-5.1-vitastor.patch patches/qemu-6.1-vitastor.patch src/qemu_driver.c /root/vitastor/patches/
|
||||||
|
RUN set -e; \
|
||||||
|
apt-get install -y wget; \
|
||||||
|
wget -q -O /etc/apt/trusted.gpg.d/vitastor.gpg https://vitastor.io/debian/pubkey.gpg; \
|
||||||
|
(echo deb http://vitastor.io/debian $REL main > /etc/apt/sources.list.d/vitastor.list); \
|
||||||
|
(echo "APT::Install-Recommends false;" > /etc/apt/apt.conf) && \
|
||||||
|
apt-get update; \
|
||||||
|
apt-get install -y vitastor-client vitastor-client-dev quilt; \
|
||||||
|
mkdir -p /root/packages/qemu-$REL; \
|
||||||
|
rm -rf /root/packages/qemu-$REL/*; \
|
||||||
|
cd /root/packages/qemu-$REL; \
|
||||||
|
dpkg-source -x /root/qemu*.dsc; \
|
||||||
|
if ls -d /root/packages/qemu-$REL/qemu-5.0*; then \
|
||||||
|
D=$(ls -d /root/packages/qemu-$REL/qemu-5.0*); \
|
||||||
|
cp /root/vitastor/patches/qemu-5.0-vitastor.patch $D/debian/patches; \
|
||||||
|
echo qemu-5.0-vitastor.patch >> $D/debian/patches/series; \
|
||||||
|
elif ls /root/packages/qemu-$REL/qemu-6.1*; then \
|
||||||
|
D=$(ls -d /root/packages/qemu-$REL/qemu-6.1*); \
|
||||||
|
cp /root/vitastor/patches/qemu-6.1-vitastor.patch $D/debian/patches; \
|
||||||
|
echo qemu-6.1-vitastor.patch >> $D/debian/patches/series; \
|
||||||
|
else \
|
||||||
|
cp /root/vitastor/patches/qemu-5.1-vitastor.patch /root/packages/qemu-$REL/qemu-*/debian/patches; \
|
||||||
|
P=`ls -d /root/packages/qemu-$REL/qemu-*/debian/patches`; \
|
||||||
|
echo qemu-5.1-vitastor.patch >> $P/series; \
|
||||||
|
fi; \
|
||||||
|
cd /root/packages/qemu-$REL/qemu-*/; \
|
||||||
|
quilt push -a; \
|
||||||
|
quilt add block/vitastor.c; \
|
||||||
|
cp /root/vitastor/patches/qemu_driver.c block/vitastor.c; \
|
||||||
|
quilt refresh; \
|
||||||
|
V=$(head -n1 debian/changelog | perl -pe 's/^.*\((.*?)(~bpo[\d\+]*)?\).*$/$1/')+vitastor1; \
|
||||||
|
DEBEMAIL="Vitaliy Filippov <vitalif@yourcmc.ru>" dch -D $REL -v $V 'Plug Vitastor block driver'; \
|
||||||
|
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage --jobs=auto -sa; \
|
||||||
|
rm -rf /root/packages/qemu-$REL/qemu-*/
|
|
@ -0,0 +1 @@
|
||||||
|
patches/PVE_VitastorPlugin.pm usr/share/perl5/PVE/Storage/Custom/VitastorPlugin.pm
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* Removed in Linux 5.14 */
|
||||||
|
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||||
|
#ifndef __LINUX_RAW_H
|
||||||
|
#define __LINUX_RAW_H
|
||||||
|
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
|
#define RAW_SETBIND _IO( 0xac, 0 )
|
||||||
|
#define RAW_GETBIND _IO( 0xac, 1 )
|
||||||
|
|
||||||
|
struct raw_config_request
|
||||||
|
{
|
||||||
|
int raw_minor;
|
||||||
|
__u64 block_major;
|
||||||
|
__u64 block_minor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __LINUX_RAW_H */
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/make -f
|
||||||
|
export DH_VERBOSE = 1
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
|
|
||||||
|
override_dh_installdeb:
|
||||||
|
cat debian/fio_version >> debian/vitastor-fio.substvars
|
||||||
|
[ -f debian/qemu_version ] && (cat debian/qemu_version >> debian/vitastor-qemu.substvars) || true
|
||||||
|
dh_installdeb
|
|
@ -0,0 +1 @@
|
||||||
|
3.0 (quilt)
|
|
@ -0,0 +1,2 @@
|
||||||
|
usr/include
|
||||||
|
usr/lib/*/pkgconfig
|
|
@ -0,0 +1,6 @@
|
||||||
|
usr/bin/vita
|
||||||
|
usr/bin/vitastor-cli
|
||||||
|
usr/bin/vitastor-rm
|
||||||
|
usr/bin/vitastor-nbd
|
||||||
|
usr/lib/*/libvitastor*.so*
|
||||||
|
mon/make-osd.sh /usr/lib/vitastor
|
|
@ -0,0 +1 @@
|
||||||
|
usr/lib/*/libfio*.so*
|
|
@ -0,0 +1 @@
|
||||||
|
mon usr/lib/vitastor
|
|
@ -0,0 +1,2 @@
|
||||||
|
usr/bin/vitastor-osd
|
||||||
|
usr/bin/vitastor-dump-journal
|
|
@ -0,0 +1,55 @@
|
||||||
|
# Build Vitastor packages for Debian Buster or Bullseye/Sid inside a container
|
||||||
|
# cd ..; podman build --build-arg REL=bullseye -v `pwd`/packages:/root/packages -f debian/vitastor.Dockerfile .
|
||||||
|
|
||||||
|
ARG REL=
|
||||||
|
FROM debian:$REL
|
||||||
|
ARG REL=
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
RUN if [ "$REL" = "buster" -o "$REL" = "bullseye" ]; then \
|
||||||
|
echo "deb http://deb.debian.org/debian $REL-backports main" >> /etc/apt/sources.list; \
|
||||||
|
echo >> /etc/apt/preferences; \
|
||||||
|
echo 'Package: *' >> /etc/apt/preferences; \
|
||||||
|
echo "Pin: release a=$REL-backports" >> /etc/apt/preferences; \
|
||||||
|
echo 'Pin-Priority: 500' >> /etc/apt/preferences; \
|
||||||
|
fi; \
|
||||||
|
grep '^deb ' /etc/apt/sources.list | perl -pe 's/^deb/deb-src/' >> /etc/apt/sources.list; \
|
||||||
|
echo 'APT::Install-Recommends false;' >> /etc/apt/apt.conf; \
|
||||||
|
echo 'APT::Install-Suggests false;' >> /etc/apt/apt.conf
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get -y install fio liburing1 liburing-dev libgoogle-perftools-dev devscripts
|
||||||
|
RUN apt-get -y build-dep fio
|
||||||
|
RUN apt-get --download-only source fio
|
||||||
|
RUN apt-get update && apt-get -y install libjerasure-dev cmake libibverbs-dev
|
||||||
|
|
||||||
|
ADD . /root/vitastor
|
||||||
|
RUN set -e -x; \
|
||||||
|
mkdir -p /root/fio-build/; \
|
||||||
|
cd /root/fio-build/; \
|
||||||
|
rm -rf /root/fio-build/*; \
|
||||||
|
dpkg-source -x /root/fio*.dsc; \
|
||||||
|
mkdir -p /root/packages/vitastor-$REL; \
|
||||||
|
rm -rf /root/packages/vitastor-$REL/*; \
|
||||||
|
cd /root/packages/vitastor-$REL; \
|
||||||
|
cp -r /root/vitastor vitastor-0.6.10; \
|
||||||
|
cd vitastor-0.6.10; \
|
||||||
|
ln -s /root/fio-build/fio-*/ ./fio; \
|
||||||
|
FIO=$(head -n1 fio/debian/changelog | perl -pe 's/^.*\((.*?)\).*$/$1/'); \
|
||||||
|
ls /usr/include/linux/raw.h || cp ./debian/raw.h /usr/include/linux/raw.h; \
|
||||||
|
sh copy-fio-includes.sh; \
|
||||||
|
rm fio; \
|
||||||
|
mkdir -p a b debian/patches; \
|
||||||
|
mv fio-copy b/fio; \
|
||||||
|
diff -NaurpbB a b > debian/patches/fio-headers.patch || true; \
|
||||||
|
echo fio-headers.patch >> debian/patches/series; \
|
||||||
|
rm -rf a b; \
|
||||||
|
echo "dep:fio=$FIO" > debian/fio_version; \
|
||||||
|
cd /root/packages/vitastor-$REL; \
|
||||||
|
tar --sort=name --mtime='2020-01-01' --owner=0 --group=0 --exclude=debian -cJf vitastor_0.6.10.orig.tar.xz vitastor-0.6.10; \
|
||||||
|
cd vitastor-0.6.10; \
|
||||||
|
V=$(head -n1 debian/changelog | perl -pe 's/^.*\((.*?)\).*$/$1/'); \
|
||||||
|
DEBFULLNAME="Vitaliy Filippov <vitalif@yourcmc.ru>" dch -D $REL -v "$V""$REL" "Rebuild for $REL"; \
|
||||||
|
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage --jobs=auto -sa; \
|
||||||
|
rm -rf /root/packages/vitastor-$REL/vitastor-*/
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Build Docker image with Vitastor packages
|
||||||
|
|
||||||
|
FROM debian:bullseye
|
||||||
|
|
||||||
|
ADD vitastor.list /etc/apt/sources.list.d
|
||||||
|
ADD vitastor.gpg /etc/apt/trusted.gpg.d
|
||||||
|
ADD vitastor.pref /etc/apt/preferences.d
|
||||||
|
ADD apt.conf /etc/apt/
|
||||||
|
RUN apt-get update && apt-get -y install vitastor qemu-system-x86 qemu-system-common && apt-get clean
|
|
@ -0,0 +1 @@
|
||||||
|
APT::Install-Recommends false;
|
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
deb http://vitastor.io/debian bullseye main
|
|
@ -0,0 +1,3 @@
|
||||||
|
Package: *
|
||||||
|
Pin: origin "vitastor.io"
|
||||||
|
Pin-Priority: 1000
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 55363fc2653b8802637a3d2e73a06839a72c585d
|
|
@ -1,48 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include <functional>
|
|
||||||
#include <array>
|
|
||||||
#include <cstdlib> // for malloc() and free()
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
// replace operator new and delete to log allocations
|
|
||||||
void* operator new(std::size_t n)
|
|
||||||
{
|
|
||||||
cout << "Allocating " << n << " bytes" << endl;
|
|
||||||
return malloc(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete(void* p) throw()
|
|
||||||
{
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
class test
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
std::string s;
|
|
||||||
void a(std::function<void()> & f, const char *str)
|
|
||||||
{
|
|
||||||
auto l = [this, str]() { cout << str << " ? " << s << " from this\n"; };
|
|
||||||
cout << "Assigning lambda3 of size " << sizeof(l) << endl;
|
|
||||||
f = l;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
std::array<char, 16> arr1;
|
|
||||||
auto lambda1 = [arr1](){};
|
|
||||||
cout << "Assigning lambda1 of size " << sizeof(lambda1) << endl;
|
|
||||||
std::function<void()> f1 = lambda1;
|
|
||||||
|
|
||||||
std::array<char, 17> arr2;
|
|
||||||
auto lambda2 = [arr2](){};
|
|
||||||
cout << "Assigning lambda2 of size " << sizeof(lambda2) << endl;
|
|
||||||
std::function<void()> f2 = lambda2;
|
|
||||||
|
|
||||||
test t;
|
|
||||||
std::function<void()> f3;
|
|
||||||
t.s = "str";
|
|
||||||
t.a(f3, "huyambda");
|
|
||||||
f3();
|
|
||||||
}
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
scale_pg_count,
|
||||||
|
};
|
||||||
|
|
||||||
|
function add_pg_history(new_pg_history, new_pg, prev_pgs, prev_pg_history, old_pg)
|
||||||
|
{
|
||||||
|
if (!new_pg_history[new_pg])
|
||||||
|
{
|
||||||
|
new_pg_history[new_pg] = {
|
||||||
|
osd_sets: {},
|
||||||
|
all_peers: {},
|
||||||
|
epoch: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const nh = new_pg_history[new_pg], oh = prev_pg_history[old_pg];
|
||||||
|
nh.osd_sets[prev_pgs[old_pg].join(' ')] = prev_pgs[old_pg];
|
||||||
|
if (oh && oh.osd_sets && oh.osd_sets.length)
|
||||||
|
{
|
||||||
|
for (const pg of oh.osd_sets)
|
||||||
|
{
|
||||||
|
nh.osd_sets[pg.join(' ')] = pg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (oh && oh.all_peers && oh.all_peers.length)
|
||||||
|
{
|
||||||
|
for (const osd_num of oh.all_peers)
|
||||||
|
{
|
||||||
|
nh.all_peers[osd_num] = Number(osd_num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (oh && oh.epoch)
|
||||||
|
{
|
||||||
|
nh.epoch = nh.epoch < oh.epoch ? oh.epoch : nh.epoch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function finish_pg_history(merged_history)
|
||||||
|
{
|
||||||
|
merged_history.osd_sets = Object.values(merged_history.osd_sets);
|
||||||
|
merged_history.all_peers = Object.values(merged_history.all_peers);
|
||||||
|
}
|
||||||
|
|
||||||
|
function scale_pg_count(prev_pgs, prev_pg_history, new_pg_history, new_pg_count)
|
||||||
|
{
|
||||||
|
const old_pg_count = prev_pgs.length;
|
||||||
|
// Add all possibly intersecting PGs to the history of new PGs
|
||||||
|
if (!(new_pg_count % old_pg_count))
|
||||||
|
{
|
||||||
|
// New PG count is a multiple of old PG count
|
||||||
|
for (let i = 0; i < new_pg_count; i++)
|
||||||
|
{
|
||||||
|
add_pg_history(new_pg_history, i, prev_pgs, prev_pg_history, i % old_pg_count);
|
||||||
|
finish_pg_history(new_pg_history[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!(old_pg_count % new_pg_count))
|
||||||
|
{
|
||||||
|
// Old PG count is a multiple of the new PG count
|
||||||
|
const mul = (old_pg_count / new_pg_count);
|
||||||
|
for (let i = 0; i < new_pg_count; i++)
|
||||||
|
{
|
||||||
|
for (let j = 0; j < mul; j++)
|
||||||
|
{
|
||||||
|
add_pg_history(new_pg_history, i, prev_pgs, prev_pg_history, i+j*new_pg_count);
|
||||||
|
}
|
||||||
|
finish_pg_history(new_pg_history[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Any PG may intersect with any PG after non-multiple PG count change
|
||||||
|
// So, merge ALL PGs history
|
||||||
|
let merged_history = {};
|
||||||
|
for (let i = 0; i < old_pg_count; i++)
|
||||||
|
{
|
||||||
|
add_pg_history(merged_history, 1, prev_pgs, prev_pg_history, i);
|
||||||
|
}
|
||||||
|
finish_pg_history(merged_history[1]);
|
||||||
|
for (let i = 0; i < new_pg_count; i++)
|
||||||
|
{
|
||||||
|
new_pg_history[i] = { ...merged_history[1] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Mark history keys for removed PGs as removed
|
||||||
|
for (let i = new_pg_count; i < old_pg_count; i++)
|
||||||
|
{
|
||||||
|
new_pg_history[i] = null;
|
||||||
|
}
|
||||||
|
// Just for the lp_solve optimizer - pick a "previous" PG for each "new" one
|
||||||
|
if (old_pg_count < new_pg_count)
|
||||||
|
{
|
||||||
|
for (let i = old_pg_count; i < new_pg_count; i++)
|
||||||
|
{
|
||||||
|
prev_pgs[i] = prev_pgs[i % old_pg_count];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (old_pg_count > new_pg_count)
|
||||||
|
{
|
||||||
|
prev_pgs.splice(new_pg_count, old_pg_count-new_pg_count);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
// Functions to calculate Annualized Failure Rate of your cluster
|
||||||
|
// if you know AFR of your drives, number of drives, expected rebalance time
|
||||||
|
// and replication factor
|
||||||
|
// License: VNPL-1.1 (see https://yourcmc.ru/git/vitalif/vitastor/src/branch/master/README.md for details) or AGPL-3.0
|
||||||
|
// Author: Vitaliy Filippov, 2020+
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
cluster_afr_fullmesh,
|
||||||
|
failure_rate_fullmesh,
|
||||||
|
cluster_afr,
|
||||||
|
c_n_k,
|
||||||
|
};
|
||||||
|
|
||||||
|
/******** "FULL MESH": ASSUME EACH OSD COMMUNICATES WITH ALL OTHER OSDS ********/
|
||||||
|
|
||||||
|
// Estimate AFR of the cluster
|
||||||
|
// n - number of drives
|
||||||
|
// afr - annualized failure rate of a single drive
|
||||||
|
// l - expected rebalance time in days after a single drive failure
|
||||||
|
// k - replication factor / number of drives that must fail at the same time for the cluster to fail
|
||||||
|
function cluster_afr_fullmesh(n, afr, l, k)
|
||||||
|
{
|
||||||
|
return 1 - (1 - afr * failure_rate_fullmesh(n-(k-1), afr*l/365, k-1)) ** (n-(k-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Probability of at least <f> failures in a cluster with <n> drives with AFR=<a>
|
||||||
|
function failure_rate_fullmesh(n, a, f)
|
||||||
|
{
|
||||||
|
if (f <= 0)
|
||||||
|
{
|
||||||
|
return (1-a)**n;
|
||||||
|
}
|
||||||
|
let p = 1;
|
||||||
|
for (let i = 0; i < f; i++)
|
||||||
|
{
|
||||||
|
p -= c_n_k(n, i) * (1-a)**(n-i) * a**i;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******** PGS: EACH OSD ONLY COMMUNICATES WITH <pgs> OTHER OSDs ********/
|
||||||
|
|
||||||
|
// <n> hosts of <m> drives of <capacity> GB, each able to backfill at <speed> GB/s,
|
||||||
|
// <k> replicas, <pgs> unique peer PGs per OSD (~50 for 100 PG-per-OSD in a big cluster)
|
||||||
|
//
|
||||||
|
// For each of n*m drives: P(drive fails in a year) * P(any of its peers fail in <l*365> next days).
|
||||||
|
// More peers per OSD increase rebalance speed (more drives work together to resilver) if you
|
||||||
|
// let them finish rebalance BEFORE replacing the failed drive (degraded_replacement=false).
|
||||||
|
// At the same time, more peers per OSD increase probability of any of them to fail!
|
||||||
|
// osd_rm=true means that failed OSDs' data is rebalanced over all other hosts,
|
||||||
|
// not over the same host as it's in Ceph by default (dead OSDs are marked 'out').
|
||||||
|
//
|
||||||
|
// Probability of all except one drives in a replica group to fail is (AFR^(k-1)).
|
||||||
|
// So with <x> PGs it becomes ~ (x * (AFR*L/365)^(k-1)). Interesting but reasonable consequence
|
||||||
|
// is that, with k=2, total failure rate doesn't depend on number of peers per OSD,
|
||||||
|
// because it gets increased linearly by increased number of peers to fail
|
||||||
|
// and decreased linearly by reduced rebalance time.
|
||||||
|
function cluster_afr({ n_hosts, n_drives, afr_drive, afr_host, capacity, speed, ec, ec_data, ec_parity, replicas, pgs = 1, osd_rm, degraded_replacement, down_out_interval = 600 })
|
||||||
|
{
|
||||||
|
const pg_size = (ec ? ec_data+ec_parity : replicas);
|
||||||
|
pgs = Math.min(pgs, (n_hosts-1)*n_drives/(pg_size-1));
|
||||||
|
const host_pgs = Math.min(pgs*n_drives, (n_hosts-1)*n_drives/(pg_size-1));
|
||||||
|
const resilver_disk = n_drives == 1 || osd_rm ? pgs : (n_drives-1);
|
||||||
|
const disk_heal_time = (down_out_interval + capacity/(degraded_replacement ? 1 : resilver_disk)/speed)/86400/365;
|
||||||
|
const host_heal_time = (down_out_interval + n_drives*capacity/pgs/speed)/86400/365;
|
||||||
|
const disk_heal_fail = ((afr_drive+afr_host/n_drives)*disk_heal_time);
|
||||||
|
const host_heal_fail = ((afr_drive+afr_host/n_drives)*host_heal_time);
|
||||||
|
const disk_pg_fail = ec
|
||||||
|
? failure_rate_fullmesh(ec_data+ec_parity-1, disk_heal_fail, ec_parity)
|
||||||
|
: disk_heal_fail**(replicas-1);
|
||||||
|
const host_pg_fail = ec
|
||||||
|
? failure_rate_fullmesh(ec_data+ec_parity-1, host_heal_fail, ec_parity)
|
||||||
|
: host_heal_fail**(replicas-1);
|
||||||
|
return 1 - ((1 - afr_drive * (1-(1-disk_pg_fail)**pgs)) ** (n_hosts*n_drives))
|
||||||
|
* ((1 - afr_host * (1-(1-host_pg_fail)**host_pgs)) ** n_hosts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******** UTILITY ********/
|
||||||
|
|
||||||
|
// Combination count
|
||||||
|
function c_n_k(n, k)
|
||||||
|
{
|
||||||
|
let r = 1;
|
||||||
|
for (let i = 0; i < k; i++)
|
||||||
|
{
|
||||||
|
r *= (n-i) / (i+1);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
const { sprintf } = require('sprintf-js');
|
||||||
|
const { cluster_afr } = require('./afr.js');
|
||||||
|
|
||||||
|
print_cluster_afr({ n_hosts: 4, n_drives: 6, afr_drive: 0.03, afr_host: 0.05, capacity: 4000, speed: 0.1, replicas: 2 });
|
||||||
|
print_cluster_afr({ n_hosts: 4, n_drives: 3, afr_drive: 0.03, afr_host: 0, capacity: 4000, speed: 0.1, replicas: 2 });
|
||||||
|
print_cluster_afr({ n_hosts: 4, n_drives: 3, afr_drive: 0.03, afr_host: 0.05, capacity: 4000, speed: 0.1, replicas: 2 });
|
||||||
|
print_cluster_afr({ n_hosts: 4, n_drives: 3, afr_drive: 0.03, afr_host: 0, capacity: 4000, speed: 0.1, ec: true, ec_data: 2, ec_parity: 1 });
|
||||||
|
print_cluster_afr({ n_hosts: 4, n_drives: 3, afr_drive: 0.03, afr_host: 0.05, capacity: 4000, speed: 0.1, ec: true, ec_data: 2, ec_parity: 1 });
|
||||||
|
print_cluster_afr({ n_hosts: 10, n_drives: 10, afr_drive: 0.1, afr_host: 0, capacity: 8000, speed: 0.02, replicas: 2 });
|
||||||
|
print_cluster_afr({ n_hosts: 10, n_drives: 10, afr_drive: 0.1, afr_host: 0.05, capacity: 8000, speed: 0.02, replicas: 2 });
|
||||||
|
print_cluster_afr({ n_hosts: 10, n_drives: 10, afr_drive: 0.1, afr_host: 0, capacity: 8000, speed: 0.02, replicas: 3 });
|
||||||
|
print_cluster_afr({ n_hosts: 10, n_drives: 10, afr_drive: 0.1, afr_host: 0.05, capacity: 8000, speed: 0.02, replicas: 3 });
|
||||||
|
print_cluster_afr({ n_hosts: 10, n_drives: 10, afr_drive: 0.1, afr_host: 0, capacity: 8000, speed: 0.02, replicas: 3, pgs: 100 });
|
||||||
|
print_cluster_afr({ n_hosts: 10, n_drives: 10, afr_drive: 0.1, afr_host: 0.05, capacity: 8000, speed: 0.02, replicas: 3, pgs: 100 });
|
||||||
|
print_cluster_afr({ n_hosts: 10, n_drives: 10, afr_drive: 0.1, afr_host: 0.05, capacity: 8000, speed: 0.02, replicas: 3, pgs: 100, degraded_replacement: 1 });
|
||||||
|
|
||||||
|
function print_cluster_afr(config)
|
||||||
|
{
|
||||||
|
console.log(
|
||||||
|
`${config.n_hosts} nodes with ${config.n_drives} ${sprintf("%.1f", config.capacity/1000)}TB drives`+
|
||||||
|
`, capable to backfill at ${sprintf("%.1f", config.speed*1000)} MB/s, drive AFR ${sprintf("%.1f", config.afr_drive*100)}%`+
|
||||||
|
(config.afr_host ? `, host AFR ${sprintf("%.1f", config.afr_host*100)}%` : '')+
|
||||||
|
(config.ec ? `, EC ${config.ec_data}+${config.ec_parity}` : `, ${config.replicas} replicas`)+
|
||||||
|
`, ${config.pgs||1} PG per OSD`+
|
||||||
|
(config.degraded_replacement ? `\n...and you don't let the rebalance finish before replacing drives` : '')
|
||||||
|
);
|
||||||
|
console.log('-> '+sprintf("%.7f%%", 100*cluster_afr(config))+'\n');
|
||||||
|
}
|
|
@ -0,0 +1,729 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
|
|
||||||
|
// Data distribution optimizer using linear programming (lp_solve)
|
||||||
|
|
||||||
|
const child_process = require('child_process');
|
||||||
|
|
||||||
|
const NO_OSD = 'Z';
|
||||||
|
|
||||||
|
async function lp_solve(text)
|
||||||
|
{
|
||||||
|
const cp = child_process.spawn('lp_solve');
|
||||||
|
let stdout = '', stderr = '', finish_cb;
|
||||||
|
cp.stdout.on('data', buf => stdout += buf.toString());
|
||||||
|
cp.stderr.on('data', buf => stderr += buf.toString());
|
||||||
|
cp.on('exit', () => finish_cb && finish_cb());
|
||||||
|
cp.stdin.write(text);
|
||||||
|
cp.stdin.end();
|
||||||
|
if (cp.exitCode == null)
|
||||||
|
{
|
||||||
|
await new Promise(ok => finish_cb = ok);
|
||||||
|
}
|
||||||
|
if (!stdout.trim())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let score = 0;
|
||||||
|
let vars = {};
|
||||||
|
for (const line of stdout.split(/\n/))
|
||||||
|
{
|
||||||
|
let m = /^(^Value of objective function: (-?[\d\.]+)|Actual values of the variables:)\s*$/.exec(line);
|
||||||
|
if (m)
|
||||||
|
{
|
||||||
|
if (m[2])
|
||||||
|
{
|
||||||
|
score = m[2];
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (/This problem is (infeasible|unbounded)/.exec(line))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let [ k, v ] = line.trim().split(/\s+/, 2);
|
||||||
|
if (v)
|
||||||
|
{
|
||||||
|
vars[k] = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { score, vars };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function optimize_initial({ osd_tree, pg_count, pg_size = 3, pg_minsize = 2, max_combinations = 10000, parity_space = 1, round_robin = false })
|
||||||
|
{
|
||||||
|
if (!pg_count || !osd_tree)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const all_weights = Object.assign({}, ...Object.values(osd_tree));
|
||||||
|
const total_weight = Object.values(all_weights).reduce((a, c) => Number(a) + Number(c), 0);
|
||||||
|
const all_pgs = Object.values(random_combinations(osd_tree, pg_size, max_combinations, parity_space > 1));
|
||||||
|
const pg_per_osd = {};
|
||||||
|
for (const pg of all_pgs)
|
||||||
|
{
|
||||||
|
for (let i = 0; i < pg.length; i++)
|
||||||
|
{
|
||||||
|
const osd = pg[i];
|
||||||
|
pg_per_osd[osd] = pg_per_osd[osd] || [];
|
||||||
|
pg_per_osd[osd].push((i >= pg_minsize ? parity_space+'*' : '')+"pg_"+pg.join("_"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const pg_effsize = Math.min(pg_minsize, Object.keys(osd_tree).length)
|
||||||
|
+ Math.max(0, Math.min(pg_size, Object.keys(osd_tree).length) - pg_minsize) * parity_space;
|
||||||
|
let lp = '';
|
||||||
|
lp += "max: "+all_pgs.map(pg => 'pg_'+pg.join('_')).join(' + ')+";\n";
|
||||||
|
for (const osd in pg_per_osd)
|
||||||
|
{
|
||||||
|
if (osd !== NO_OSD)
|
||||||
|
{
|
||||||
|
let osd_pg_count = all_weights[osd]/total_weight*pg_effsize*pg_count;
|
||||||
|
lp += pg_per_osd[osd].join(' + ')+' <= '+osd_pg_count+';\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const pg of all_pgs)
|
||||||
|
{
|
||||||
|
lp += 'pg_'+pg.join('_')+" >= 0;\n";
|
||||||
|
}
|
||||||
|
lp += "sec "+all_pgs.map(pg => 'pg_'+pg.join('_')).join(', ')+";\n";
|
||||||
|
const lp_result = await lp_solve(lp);
|
||||||
|
if (!lp_result)
|
||||||
|
{
|
||||||
|
console.log(lp);
|
||||||
|
throw new Error('Problem is infeasible or unbounded - is it a bug?');
|
||||||
|
}
|
||||||
|
const int_pgs = make_int_pgs(lp_result.vars, pg_count, round_robin);
|
||||||
|
const eff = pg_list_space_efficiency(int_pgs, all_weights, pg_minsize, parity_space);
|
||||||
|
const res = {
|
||||||
|
score: lp_result.score,
|
||||||
|
weights: lp_result.vars,
|
||||||
|
int_pgs,
|
||||||
|
space: eff * pg_effsize,
|
||||||
|
total_space: total_weight,
|
||||||
|
};
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function shuffle(array)
|
||||||
|
{
|
||||||
|
for (let i = array.length - 1, j, x; i > 0; i--)
|
||||||
|
{
|
||||||
|
j = Math.floor(Math.random() * (i + 1));
|
||||||
|
x = array[i];
|
||||||
|
array[i] = array[j];
|
||||||
|
array[j] = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function make_int_pgs(weights, pg_count, round_robin)
|
||||||
|
{
|
||||||
|
const total_weight = Object.values(weights).reduce((a, c) => Number(a) + Number(c), 0);
|
||||||
|
let int_pgs = [];
|
||||||
|
let pg_left = pg_count;
|
||||||
|
let weight_left = total_weight;
|
||||||
|
for (const pg_name in weights)
|
||||||
|
{
|
||||||
|
let cur_pg = pg_name.substr(3).split('_');
|
||||||
|
let n = Math.round(weights[pg_name] / weight_left * pg_left);
|
||||||
|
for (let i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
int_pgs.push([ ...cur_pg ]);
|
||||||
|
if (round_robin)
|
||||||
|
{
|
||||||
|
cur_pg.push(cur_pg.shift());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
weight_left -= weights[pg_name];
|
||||||
|
pg_left -= n;
|
||||||
|
}
|
||||||
|
shuffle(int_pgs);
|
||||||
|
return int_pgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function calc_intersect_weights(pg_size, pg_count, prev_weights, all_pgs)
|
||||||
|
{
|
||||||
|
const move_weights = {};
|
||||||
|
if ((1 << pg_size) < pg_count)
|
||||||
|
{
|
||||||
|
const intersect = {};
|
||||||
|
for (const pg_name in prev_weights)
|
||||||
|
{
|
||||||
|
const pg = pg_name.substr(3).split(/_/);
|
||||||
|
for (let omit = 1; omit < (1 << pg_size); omit++)
|
||||||
|
{
|
||||||
|
let pg_omit = [ ...pg ];
|
||||||
|
let intersect_count = pg_size;
|
||||||
|
for (let i = 0; i < pg_size; i++)
|
||||||
|
{
|
||||||
|
if (omit & (1 << i))
|
||||||
|
{
|
||||||
|
pg_omit[i] = '';
|
||||||
|
intersect_count--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pg_omit = pg_omit.join(':');
|
||||||
|
intersect[pg_omit] = Math.max(intersect[pg_omit] || 0, intersect_count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const pg of all_pgs)
|
||||||
|
{
|
||||||
|
let max_int = 0;
|
||||||
|
for (let omit = 1; omit < (1 << pg_size); omit++)
|
||||||
|
{
|
||||||
|
let pg_omit = [ ...pg ];
|
||||||
|
for (let i = 0; i < pg_size; i++)
|
||||||
|
{
|
||||||
|
if (omit & (1 << i))
|
||||||
|
{
|
||||||
|
pg_omit[i] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pg_omit = pg_omit.join(':');
|
||||||
|
max_int = Math.max(max_int, intersect[pg_omit] || 0);
|
||||||
|
}
|
||||||
|
move_weights['pg_'+pg.join('_')] = pg_size-max_int;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const prev_pg_hashed = Object.keys(prev_weights).map(pg_name => pg_name.substr(3).split(/_/).reduce((a, c) => { a[c] = 1; return a; }, {}));
|
||||||
|
for (const pg of all_pgs)
|
||||||
|
{
|
||||||
|
if (!prev_weights['pg_'+pg.join('_')])
|
||||||
|
{
|
||||||
|
let max_int = 0;
|
||||||
|
for (const prev_hash in prev_pg_hashed)
|
||||||
|
{
|
||||||
|
const intersect_count = pg.reduce((a, osd) => a + (prev_hash[osd] ? 1 : 0), 0);
|
||||||
|
if (max_int < intersect_count)
|
||||||
|
{
|
||||||
|
max_int = intersect_count;
|
||||||
|
if (max_int >= pg_size)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
move_weights['pg_'+pg.join('_')] = pg_size-max_int;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return move_weights;
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_valid_previous(osd_tree, prev_weights, all_pgs)
|
||||||
|
{
|
||||||
|
// Add previous combinations that are still valid
|
||||||
|
const hosts = Object.keys(osd_tree).sort();
|
||||||
|
const host_per_osd = {};
|
||||||
|
for (const host in osd_tree)
|
||||||
|
{
|
||||||
|
for (const osd in osd_tree[host])
|
||||||
|
{
|
||||||
|
host_per_osd[osd] = host;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skip_pg: for (const pg_name in prev_weights)
|
||||||
|
{
|
||||||
|
const seen_hosts = {};
|
||||||
|
const pg = pg_name.substr(3).split(/_/);
|
||||||
|
for (const osd of pg)
|
||||||
|
{
|
||||||
|
if (!host_per_osd[osd] || seen_hosts[host_per_osd[osd]])
|
||||||
|
{
|
||||||
|
continue skip_pg;
|
||||||
|
}
|
||||||
|
seen_hosts[host_per_osd[osd]] = true;
|
||||||
|
}
|
||||||
|
if (!all_pgs[pg_name])
|
||||||
|
{
|
||||||
|
all_pgs[pg_name] = pg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to minimize data movement
|
||||||
|
async function optimize_change({ prev_pgs: prev_int_pgs, osd_tree, pg_size = 3, pg_minsize = 2, max_combinations = 10000, parity_space = 1 })
|
||||||
|
{
|
||||||
|
if (!osd_tree)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// FIXME: use parity_chunks with parity_space instead of pg_minsize
|
||||||
|
const pg_effsize = Math.min(pg_minsize, Object.keys(osd_tree).length)
|
||||||
|
+ Math.max(0, Math.min(pg_size, Object.keys(osd_tree).length) - pg_minsize) * parity_space;
|
||||||
|
const pg_count = prev_int_pgs.length;
|
||||||
|
const prev_weights = {};
|
||||||
|
const prev_pg_per_osd = {};
|
||||||
|
for (const pg of prev_int_pgs)
|
||||||
|
{
|
||||||
|
const pg_name = 'pg_'+pg.join('_');
|
||||||
|
prev_weights[pg_name] = (prev_weights[pg_name]||0) + 1;
|
||||||
|
for (let i = 0; i < pg.length; i++)
|
||||||
|
{
|
||||||
|
const osd = pg[i];
|
||||||
|
prev_pg_per_osd[osd] = prev_pg_per_osd[osd] || [];
|
||||||
|
prev_pg_per_osd[osd].push([ pg_name, (i >= pg_minsize ? parity_space : 1) ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Get all combinations
|
||||||
|
let all_pgs = random_combinations(osd_tree, pg_size, max_combinations, parity_space > 1);
|
||||||
|
add_valid_previous(osd_tree, prev_weights, all_pgs);
|
||||||
|
all_pgs = Object.values(all_pgs);
|
||||||
|
const pg_per_osd = {};
|
||||||
|
for (const pg of all_pgs)
|
||||||
|
{
|
||||||
|
const pg_name = 'pg_'+pg.join('_');
|
||||||
|
for (let i = 0; i < pg.length; i++)
|
||||||
|
{
|
||||||
|
const osd = pg[i];
|
||||||
|
pg_per_osd[osd] = pg_per_osd[osd] || [];
|
||||||
|
pg_per_osd[osd].push([ pg_name, (i >= pg_minsize ? parity_space : 1) ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Penalize PGs based on their similarity to old PGs
|
||||||
|
const move_weights = calc_intersect_weights(pg_size, pg_count, prev_weights, all_pgs);
|
||||||
|
// Calculate total weight - old PG weights
|
||||||
|
const all_pg_names = all_pgs.map(pg => 'pg_'+pg.join('_'));
|
||||||
|
const all_pgs_hash = all_pg_names.reduce((a, c) => { a[c] = true; return a; }, {});
|
||||||
|
const all_weights = Object.assign({}, ...Object.values(osd_tree));
|
||||||
|
const total_weight = Object.values(all_weights).reduce((a, c) => Number(a) + Number(c), 0);
|
||||||
|
// Generate the LP problem
|
||||||
|
let lp = '';
|
||||||
|
lp += 'max: '+all_pg_names.map(pg_name => (
|
||||||
|
prev_weights[pg_name] ? `${pg_size+1}*add_${pg_name} - ${pg_size+1}*del_${pg_name}` : `${pg_size+1-move_weights[pg_name]}*${pg_name}`
|
||||||
|
)).join(' + ')+';\n';
|
||||||
|
for (const osd in pg_per_osd)
|
||||||
|
{
|
||||||
|
if (osd !== NO_OSD)
|
||||||
|
{
|
||||||
|
const osd_sum = (pg_per_osd[osd]||[]).map(([ pg_name, space ]) => (
|
||||||
|
prev_weights[pg_name] ? `${space} * add_${pg_name} - ${space} * del_${pg_name}` : `${space} * ${pg_name}`
|
||||||
|
)).join(' + ');
|
||||||
|
const rm_osd_pg_count = (prev_pg_per_osd[osd]||[])
|
||||||
|
.reduce((a, [ old_pg_name, space ]) => (a + (all_pgs_hash[old_pg_name] ? space : 0)), 0);
|
||||||
|
const osd_pg_count = all_weights[osd]*pg_effsize/total_weight*pg_count - rm_osd_pg_count;
|
||||||
|
lp += osd_sum + ' <= ' + osd_pg_count + ';\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let pg_vars = [];
|
||||||
|
for (const pg_name of all_pg_names)
|
||||||
|
{
|
||||||
|
if (prev_weights[pg_name])
|
||||||
|
{
|
||||||
|
pg_vars.push(`add_${pg_name}`, `del_${pg_name}`);
|
||||||
|
// Can't add or remove less than zero
|
||||||
|
lp += `add_${pg_name} >= 0;\n`;
|
||||||
|
lp += `del_${pg_name} >= 0;\n`;
|
||||||
|
// Can't remove more than the PG already has
|
||||||
|
lp += `add_${pg_name} - del_${pg_name} >= -${prev_weights[pg_name]};\n`;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pg_vars.push(pg_name);
|
||||||
|
lp += `${pg_name} >= 0;\n`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lp += 'sec '+pg_vars.join(', ')+';\n';
|
||||||
|
// Solve it
|
||||||
|
const lp_result = await lp_solve(lp);
|
||||||
|
if (!lp_result)
|
||||||
|
{
|
||||||
|
console.log(lp);
|
||||||
|
throw new Error('Problem is infeasible or unbounded - is it a bug?');
|
||||||
|
}
|
||||||
|
// Generate the new distribution
|
||||||
|
const weights = { ...prev_weights };
|
||||||
|
for (const k in prev_weights)
|
||||||
|
{
|
||||||
|
if (!all_pgs_hash[k])
|
||||||
|
{
|
||||||
|
delete weights[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const k in lp_result.vars)
|
||||||
|
{
|
||||||
|
if (k.substr(0, 4) === 'add_')
|
||||||
|
{
|
||||||
|
weights[k.substr(4)] = (weights[k.substr(4)] || 0) + Number(lp_result.vars[k]);
|
||||||
|
}
|
||||||
|
else if (k.substr(0, 4) === 'del_')
|
||||||
|
{
|
||||||
|
weights[k.substr(4)] = (weights[k.substr(4)] || 0) - Number(lp_result.vars[k]);
|
||||||
|
}
|
||||||
|
else if (k.substr(0, 3) === 'pg_')
|
||||||
|
{
|
||||||
|
weights[k] = Number(lp_result.vars[k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const k in weights)
|
||||||
|
{
|
||||||
|
if (!weights[k])
|
||||||
|
{
|
||||||
|
delete weights[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const int_pgs = make_int_pgs(weights, pg_count);
|
||||||
|
// Align them with most similar previous PGs
|
||||||
|
const new_pgs = align_pgs(prev_int_pgs, int_pgs);
|
||||||
|
let differs = 0, osd_differs = 0;
|
||||||
|
for (let i = 0; i < pg_count; i++)
|
||||||
|
{
|
||||||
|
if (new_pgs[i].join('_') != prev_int_pgs[i].join('_'))
|
||||||
|
{
|
||||||
|
differs++;
|
||||||
|
}
|
||||||
|
for (let j = 0; j < pg_size; j++)
|
||||||
|
{
|
||||||
|
if (new_pgs[i][j] != prev_int_pgs[i][j])
|
||||||
|
{
|
||||||
|
osd_differs++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
prev_pgs: prev_int_pgs,
|
||||||
|
score: lp_result.score,
|
||||||
|
weights,
|
||||||
|
int_pgs: new_pgs,
|
||||||
|
differs,
|
||||||
|
osd_differs,
|
||||||
|
space: pg_effsize * pg_list_space_efficiency(new_pgs, all_weights, pg_minsize, parity_space),
|
||||||
|
total_space: total_weight,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_change_stats(retval, detailed)
|
||||||
|
{
|
||||||
|
const new_pgs = retval.int_pgs;
|
||||||
|
const prev_int_pgs = retval.prev_pgs;
|
||||||
|
if (prev_int_pgs)
|
||||||
|
{
|
||||||
|
if (detailed)
|
||||||
|
{
|
||||||
|
for (let i = 0; i < new_pgs.length; i++)
|
||||||
|
{
|
||||||
|
if (new_pgs[i].join('_') != prev_int_pgs[i].join('_'))
|
||||||
|
{
|
||||||
|
console.log("pg "+i+": "+prev_int_pgs[i].join(' ')+" -> "+new_pgs[i].join(' '));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
"Data movement: "+retval.differs+" pgs, "+
|
||||||
|
retval.osd_differs+" pg*osds = "+Math.round(retval.osd_differs / prev_int_pgs.length / 3 * 10000)/100+" %"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
"Total space (raw): "+Math.round(retval.space*100)/100+" TB, space efficiency: "+
|
||||||
|
Math.round(retval.space/(retval.total_space||1)*10000)/100+" %"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function align_pgs(prev_int_pgs, int_pgs)
|
||||||
|
{
|
||||||
|
const aligned_pgs = [];
|
||||||
|
put_aligned_pgs(aligned_pgs, int_pgs, prev_int_pgs, (pg) => [ pg.join(':') ]);
|
||||||
|
put_aligned_pgs(aligned_pgs, int_pgs, prev_int_pgs, (pg) => [ pg[0]+'::'+pg[2], ':'+pg[1]+':'+pg[2], pg[0]+':'+pg[1]+':' ]);
|
||||||
|
put_aligned_pgs(aligned_pgs, int_pgs, prev_int_pgs, (pg) => [ pg[0]+'::', ':'+pg[1]+':', '::'+pg[2] ]);
|
||||||
|
const free_slots = prev_int_pgs.map((pg, i) => !aligned_pgs[i] ? i : null).filter(i => i != null);
|
||||||
|
for (const pg of int_pgs)
|
||||||
|
{
|
||||||
|
if (!free_slots.length)
|
||||||
|
{
|
||||||
|
throw new Error("Can't place unaligned PG");
|
||||||
|
}
|
||||||
|
aligned_pgs[free_slots.shift()] = pg;
|
||||||
|
}
|
||||||
|
return aligned_pgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function put_aligned_pgs(aligned_pgs, int_pgs, prev_int_pgs, keygen)
|
||||||
|
{
|
||||||
|
let prev_indexes = {};
|
||||||
|
for (let i = 0; i < prev_int_pgs.length; i++)
|
||||||
|
{
|
||||||
|
for (let k of keygen(prev_int_pgs[i]))
|
||||||
|
{
|
||||||
|
prev_indexes[k] = prev_indexes[k] || [];
|
||||||
|
prev_indexes[k].push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PG: for (let i = int_pgs.length-1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
let pg = int_pgs[i];
|
||||||
|
let keys = keygen(int_pgs[i]);
|
||||||
|
for (let k of keys)
|
||||||
|
{
|
||||||
|
while (prev_indexes[k] && prev_indexes[k].length)
|
||||||
|
{
|
||||||
|
let idx = prev_indexes[k].shift();
|
||||||
|
if (!aligned_pgs[idx])
|
||||||
|
{
|
||||||
|
aligned_pgs[idx] = pg;
|
||||||
|
int_pgs.splice(i, 1);
|
||||||
|
continue PG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert multi-level osd_tree = { level: number|string, id?: string, size?: number, children?: osd_tree }[]
|
||||||
|
// levels = { string: number }
|
||||||
|
// to a two-level osd_tree suitable for all_combinations()
|
||||||
|
function flatten_tree(osd_tree, levels, failure_domain_level, osd_level, domains = {}, i = { i: 1 })
|
||||||
|
{
|
||||||
|
osd_level = levels[osd_level] || osd_level;
|
||||||
|
failure_domain_level = levels[failure_domain_level] || failure_domain_level;
|
||||||
|
for (const node of osd_tree)
|
||||||
|
{
|
||||||
|
if ((levels[node.level] || node.level) < failure_domain_level)
|
||||||
|
{
|
||||||
|
flatten_tree(node.children||[], levels, failure_domain_level, osd_level, domains, i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
domains['dom'+(i.i++)] = extract_osds([ node ], levels, osd_level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return domains;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extract_osds(osd_tree, levels, osd_level, osds = {})
|
||||||
|
{
|
||||||
|
for (const node of osd_tree)
|
||||||
|
{
|
||||||
|
if ((levels[node.level] || node.level) >= osd_level)
|
||||||
|
{
|
||||||
|
osds[node.id] = node.size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extract_osds(node.children||[], levels, osd_level, osds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return osds;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ordered = don't treat (x,y) and (y,x) as equal
|
||||||
|
function random_combinations(osd_tree, pg_size, count, ordered)
|
||||||
|
{
|
||||||
|
let seed = 0x5f020e43;
|
||||||
|
let rng = () =>
|
||||||
|
{
|
||||||
|
seed ^= seed << 13;
|
||||||
|
seed ^= seed >> 17;
|
||||||
|
seed ^= seed << 5;
|
||||||
|
return seed + 2147483648;
|
||||||
|
};
|
||||||
|
const hosts = Object.keys(osd_tree).sort();
|
||||||
|
const osds = Object.keys(osd_tree).reduce((a, c) => { a[c] = Object.keys(osd_tree[c]).sort(); return a; }, {});
|
||||||
|
const r = {};
|
||||||
|
// Generate random combinations including each OSD at least once
|
||||||
|
for (let h = 0; h < hosts.length; h++)
|
||||||
|
{
|
||||||
|
for (let o = 0; o < osds[hosts[h]].length; o++)
|
||||||
|
{
|
||||||
|
const pg = [ osds[hosts[h]][o] ];
|
||||||
|
const cur_hosts = [ ...hosts ];
|
||||||
|
cur_hosts.splice(h, 1);
|
||||||
|
for (let i = 1; i < pg_size && i < hosts.length; i++)
|
||||||
|
{
|
||||||
|
const next_host = rng() % cur_hosts.length;
|
||||||
|
const next_osd = rng() % osds[cur_hosts[next_host]].length;
|
||||||
|
pg.push(osds[cur_hosts[next_host]][next_osd]);
|
||||||
|
cur_hosts.splice(next_host, 1);
|
||||||
|
}
|
||||||
|
const cyclic_pgs = [ pg ];
|
||||||
|
if (ordered)
|
||||||
|
{
|
||||||
|
for (let i = 1; i < pg.size; i++)
|
||||||
|
{
|
||||||
|
cyclic_pgs.push([ ...pg.slice(i), ...pg.slice(0, i) ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const pg of cyclic_pgs)
|
||||||
|
{
|
||||||
|
while (pg.length < pg_size)
|
||||||
|
{
|
||||||
|
pg.push(NO_OSD);
|
||||||
|
}
|
||||||
|
r['pg_'+pg.join('_')] = pg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Generate purely random combinations
|
||||||
|
while (count > 0)
|
||||||
|
{
|
||||||
|
let host_idx = [];
|
||||||
|
const cur_hosts = [ ...hosts.map((h, i) => i) ];
|
||||||
|
const max_hosts = pg_size < hosts.length ? pg_size : hosts.length;
|
||||||
|
if (ordered)
|
||||||
|
{
|
||||||
|
for (let i = 0; i < max_hosts; i++)
|
||||||
|
{
|
||||||
|
const r = rng() % cur_hosts.length;
|
||||||
|
host_idx[i] = cur_hosts[r];
|
||||||
|
cur_hosts.splice(r, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (let i = 0; i < max_hosts; i++)
|
||||||
|
{
|
||||||
|
const r = rng() % (cur_hosts.length - (max_hosts - i - 1));
|
||||||
|
host_idx[i] = cur_hosts[r];
|
||||||
|
cur_hosts.splice(0, r+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let pg = host_idx.map(h => osds[hosts[h]][rng() % osds[hosts[h]].length]);
|
||||||
|
while (pg.length < pg_size)
|
||||||
|
{
|
||||||
|
pg.push(NO_OSD);
|
||||||
|
}
|
||||||
|
r['pg_'+pg.join('_')] = pg;
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Super-stupid algorithm. Given the current OSD tree, generate all possible OSD combinations
|
||||||
|
// osd_tree = { failure_domain1: { osd1: size1, ... }, ... }
|
||||||
|
// ordered = return combinations without duplicates having different order
|
||||||
|
function all_combinations(osd_tree, pg_size, ordered, count)
|
||||||
|
{
|
||||||
|
const hosts = Object.keys(osd_tree).sort();
|
||||||
|
const osds = Object.keys(osd_tree).reduce((a, c) => { a[c] = Object.keys(osd_tree[c]).sort(); return a; }, {});
|
||||||
|
while (hosts.length < pg_size)
|
||||||
|
{
|
||||||
|
osds[NO_OSD] = [ NO_OSD ];
|
||||||
|
hosts.push(NO_OSD);
|
||||||
|
}
|
||||||
|
let host_idx = [];
|
||||||
|
let osd_idx = [];
|
||||||
|
for (let i = 0; i < pg_size; i++)
|
||||||
|
{
|
||||||
|
host_idx.push(i);
|
||||||
|
osd_idx.push(0);
|
||||||
|
}
|
||||||
|
const r = [];
|
||||||
|
while (!count || count < 0 || r.length < count)
|
||||||
|
{
|
||||||
|
r.push(host_idx.map((hi, i) => osds[hosts[hi]][osd_idx[i]]));
|
||||||
|
let inc = pg_size-1;
|
||||||
|
while (inc >= 0)
|
||||||
|
{
|
||||||
|
osd_idx[inc]++;
|
||||||
|
if (osd_idx[inc] >= osds[hosts[host_idx[inc]]].length)
|
||||||
|
{
|
||||||
|
osd_idx[inc] = 0;
|
||||||
|
inc--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (inc < 0)
|
||||||
|
{
|
||||||
|
// no osds left in the current host combination, select the next one
|
||||||
|
inc = pg_size-1;
|
||||||
|
same_again: while (inc >= 0)
|
||||||
|
{
|
||||||
|
host_idx[inc]++;
|
||||||
|
for (let prev_host = 0; prev_host < inc; prev_host++)
|
||||||
|
{
|
||||||
|
if (host_idx[prev_host] == host_idx[inc])
|
||||||
|
{
|
||||||
|
continue same_again;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (host_idx[inc] < (ordered ? hosts.length-(pg_size-1-inc) : hosts.length))
|
||||||
|
{
|
||||||
|
while ((++inc) < pg_size)
|
||||||
|
{
|
||||||
|
host_idx[inc] = (ordered ? host_idx[inc-1]+1 : 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (inc < 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pg_weights_space_efficiency(weights, pg_count, osd_sizes)
|
||||||
|
{
|
||||||
|
const per_osd = {};
|
||||||
|
for (const pg_name in weights)
|
||||||
|
{
|
||||||
|
for (const osd of pg_name.substr(3).split(/_/))
|
||||||
|
{
|
||||||
|
per_osd[osd] = (per_osd[osd]||0) + weights[pg_name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pg_per_osd_space_efficiency(per_osd, pg_count, osd_sizes);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pg_list_space_efficiency(pgs, osd_sizes, pg_minsize, parity_space)
|
||||||
|
{
|
||||||
|
const per_osd = {};
|
||||||
|
for (const pg of pgs)
|
||||||
|
{
|
||||||
|
for (let i = 0; i < pg.length; i++)
|
||||||
|
{
|
||||||
|
const osd = pg[i];
|
||||||
|
per_osd[osd] = (per_osd[osd]||0) + (i >= pg_minsize ? (parity_space||1) : 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pg_per_osd_space_efficiency(per_osd, pgs.length, osd_sizes);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pg_per_osd_space_efficiency(per_osd, pg_count, osd_sizes)
|
||||||
|
{
|
||||||
|
// each PG gets randomly selected in 1/N cases
|
||||||
|
// & there are x PGs per OSD
|
||||||
|
// => an OSD is selected in x/N cases
|
||||||
|
// => total space * x/N <= OSD size
|
||||||
|
// => total space <= OSD size * N/x
|
||||||
|
let space;
|
||||||
|
for (let osd in per_osd)
|
||||||
|
{
|
||||||
|
if (osd in osd_sizes)
|
||||||
|
{
|
||||||
|
const space_estimate = osd_sizes[osd] * pg_count / per_osd[osd];
|
||||||
|
if (space == null || space > space_estimate)
|
||||||
|
{
|
||||||
|
space = space_estimate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return space == null ? 0 : space;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
NO_OSD,
|
||||||
|
|
||||||
|
optimize_initial,
|
||||||
|
optimize_change,
|
||||||
|
print_change_stats,
|
||||||
|
pg_weights_space_efficiency,
|
||||||
|
pg_list_space_efficiency,
|
||||||
|
pg_per_osd_space_efficiency,
|
||||||
|
flatten_tree,
|
||||||
|
|
||||||
|
lp_solve,
|
||||||
|
make_int_pgs,
|
||||||
|
align_pgs,
|
||||||
|
random_combinations,
|
||||||
|
all_combinations,
|
||||||
|
};
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Very simple systemd unit generator for vitastor-osd services
|
||||||
|
# Not the final solution yet, mostly for tests
|
||||||
|
# Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
# License: MIT
|
||||||
|
|
||||||
|
# USAGE:
|
||||||
|
# 1) Put etcd_address and osd_network into /etc/vitastor/vitastor.conf. Example:
|
||||||
|
# {
|
||||||
|
# "etcd_address":["http://10.200.1.10:2379/v3","http://10.200.1.11:2379/v3","http://10.200.1.12:2379/v3"],
|
||||||
|
# "osd_network":"10.200.1.0/24"
|
||||||
|
# }
|
||||||
|
# 2) Run ./make-osd.sh /dev/disk/by-partuuid/xxx [ /dev/disk/by-partuuid/yyy]...
|
||||||
|
|
||||||
|
set -e -x
|
||||||
|
|
||||||
|
# Create OSDs on all passed devices
|
||||||
|
for DEV in $*; do
|
||||||
|
|
||||||
|
OSD_NUM=$(vitastor-cli alloc-osd)
|
||||||
|
|
||||||
|
echo Creating OSD $OSD_NUM on $DEV
|
||||||
|
|
||||||
|
OPT=$(vitastor-cli simple-offsets --format options $DEV | tr '\n' ' ')
|
||||||
|
META=$(vitastor-cli simple-offsets --format json $DEV | jq .data_offset)
|
||||||
|
dd if=/dev/zero of=$DEV bs=1048576 count=$(((META+1048575)/1048576)) oflag=direct
|
||||||
|
|
||||||
|
cat >/etc/systemd/system/vitastor-osd$OSD_NUM.service <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Vitastor object storage daemon osd.$OSD_NUM
|
||||||
|
After=network-online.target local-fs.target time-sync.target
|
||||||
|
Wants=network-online.target local-fs.target time-sync.target
|
||||||
|
PartOf=vitastor.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
LimitNOFILE=1048576
|
||||||
|
LimitNPROC=1048576
|
||||||
|
LimitMEMLOCK=infinity
|
||||||
|
ExecStart=/usr/bin/vitastor-osd \\
|
||||||
|
--osd_num $OSD_NUM \\
|
||||||
|
--disable_data_fsync 1 \\
|
||||||
|
--immediate_commit all \\
|
||||||
|
--disk_alignment 4096 --journal_block_size 4096 --meta_block_size 4096 \\
|
||||||
|
--journal_no_same_sector_overwrites true \\
|
||||||
|
--journal_sector_buffer_count 1024 \\
|
||||||
|
$OPT
|
||||||
|
WorkingDirectory=/
|
||||||
|
ExecStartPre=+chown vitastor:vitastor $DEV
|
||||||
|
User=vitastor
|
||||||
|
PrivateTmp=false
|
||||||
|
TasksMax=infinity
|
||||||
|
Restart=always
|
||||||
|
StartLimitInterval=0
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=vitastor.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl enable vitastor-osd$OSD_NUM
|
||||||
|
|
||||||
|
done
|
|
@ -0,0 +1,86 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Very simple systemd unit generator for etcd & vitastor-mon services
|
||||||
|
# Not the final solution yet, mostly for tests
|
||||||
|
# Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
# License: MIT
|
||||||
|
|
||||||
|
# USAGE: ./make-units.sh
|
||||||
|
|
||||||
|
IP_SUBSTR="10.200.1."
|
||||||
|
ETCD_HOSTS="etcd0=http://10.200.1.10:2380,etcd1=http://10.200.1.11:2380,etcd2=http://10.200.1.12:2380"
|
||||||
|
|
||||||
|
# determine IP
|
||||||
|
IP=`ip -json a s | jq -r '.[].addr_info[] | select(.local | startswith("'$IP_SUBSTR'")) | .local'`
|
||||||
|
[ "$IP" != "" ] || exit 1
|
||||||
|
ETCD_NUM=${ETCD_HOSTS/$IP*/}
|
||||||
|
[ "$ETCD_NUM" != "$ETCD_HOSTS" ] || exit 1
|
||||||
|
ETCD_NUM=$(echo $ETCD_NUM | tr -d -c , | wc -c)
|
||||||
|
|
||||||
|
# etcd
|
||||||
|
useradd etcd
|
||||||
|
|
||||||
|
mkdir -p /var/lib/etcd$ETCD_NUM.etcd
|
||||||
|
cat >/etc/systemd/system/etcd.service <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=etcd for vitastor
|
||||||
|
After=network-online.target local-fs.target time-sync.target
|
||||||
|
Wants=network-online.target local-fs.target time-sync.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
ExecStart=/usr/local/bin/etcd -name etcd$ETCD_NUM --data-dir /var/lib/etcd$ETCD_NUM.etcd \\
|
||||||
|
--advertise-client-urls http://$IP:2379 --listen-client-urls http://$IP:2379 \\
|
||||||
|
--initial-advertise-peer-urls http://$IP:2380 --listen-peer-urls http://$IP:2380 \\
|
||||||
|
--initial-cluster-token vitastor-etcd-1 --initial-cluster $ETCD_HOSTS \\
|
||||||
|
--initial-cluster-state new --max-txn-ops=100000 --max-request-bytes=104857600 \\
|
||||||
|
--auto-compaction-retention=10 --auto-compaction-mode=revision
|
||||||
|
WorkingDirectory=/var/lib/etcd$ETCD_NUM.etcd
|
||||||
|
ExecStartPre=+chown -R etcd /var/lib/etcd$ETCD_NUM.etcd
|
||||||
|
User=etcd
|
||||||
|
PrivateTmp=false
|
||||||
|
TasksMax=infinity
|
||||||
|
Restart=always
|
||||||
|
StartLimitInterval=0
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=local.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable etcd
|
||||||
|
systemctl start etcd
|
||||||
|
|
||||||
|
useradd vitastor
|
||||||
|
chmod 755 /root
|
||||||
|
|
||||||
|
# Vitastor target
|
||||||
|
cat >/etc/systemd/system/vitastor.target <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=vitastor target
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Monitor unit
|
||||||
|
ETCD_MON=$(echo $ETCD_HOSTS | perl -pe 's/:2380/:2379/g; s/etcd\d*=//g;')
|
||||||
|
cat >/etc/systemd/system/vitastor-mon.service <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Vitastor monitor
|
||||||
|
After=network-online.target local-fs.target time-sync.target
|
||||||
|
Wants=network-online.target local-fs.target time-sync.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
ExecStart=node /usr/lib/vitastor/mon/mon-main.js --etcd_url '$ETCD_MON' --etcd_prefix '/vitastor' --etcd_start_timeout 5
|
||||||
|
WorkingDirectory=/
|
||||||
|
User=vitastor
|
||||||
|
PrivateTmp=false
|
||||||
|
TasksMax=infinity
|
||||||
|
Restart=always
|
||||||
|
StartLimitInterval=0
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=vitastor.target
|
||||||
|
EOF
|
|
@ -0,0 +1,23 @@
|
||||||
|
const fsp = require('fs').promises;
|
||||||
|
|
||||||
|
async function merge(file1, file2, out)
|
||||||
|
{
|
||||||
|
if (!out)
|
||||||
|
{
|
||||||
|
console.error('USAGE: nodejs merge.js layer1 layer2 output');
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
const layer1 = await fsp.readFile(file1);
|
||||||
|
const layer2 = await fsp.readFile(file2);
|
||||||
|
const zero = Buffer.alloc(4096);
|
||||||
|
for (let i = 0; i < layer2.length; i += 4096)
|
||||||
|
{
|
||||||
|
if (zero.compare(layer2, i, i+4096) != 0)
|
||||||
|
{
|
||||||
|
layer2.copy(layer1, i, i, i+4096);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await fsp.writeFile(out, layer1);
|
||||||
|
}
|
||||||
|
|
||||||
|
merge(process.argv[2], process.argv[3], process.argv[4]);
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/node
|
||||||
|
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
|
|
||||||
|
const Mon = require('./mon.js');
|
||||||
|
|
||||||
|
const options = {};
|
||||||
|
|
||||||
|
for (let i = 2; i < process.argv.length; i++)
|
||||||
|
{
|
||||||
|
if (process.argv[i] === '-h' || process.argv[i] === '--help')
|
||||||
|
{
|
||||||
|
console.error('USAGE: '+process.argv[0]+' '+process.argv[1]+' [--verbose 1]'+
|
||||||
|
' [--etcd_address "http://127.0.0.1:2379,..."] [--config_file /etc/vitastor/vitastor.conf]'+
|
||||||
|
' [--etcd_prefix "/vitastor"] [--etcd_start_timeout 5]');
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
else if (process.argv[i].substr(0, 2) == '--')
|
||||||
|
{
|
||||||
|
options[process.argv[i].substr(2)] = process.argv[i+1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new Mon(options).start().catch(e => { console.error(e); process.exit(1); });
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"name": "vitastor-mon",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Vitastor SDS monitor service",
|
||||||
|
"main": "mon-main.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Vitaliy Filippov",
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"dependencies": {
|
||||||
|
"sprintf-js": "^1.1.2",
|
||||||
|
"ws": "^7.2.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: MIT
|
||||||
|
|
||||||
|
// Simple tool to calculate journal and metadata offsets for a single device
|
||||||
|
// Will be replaced by smarter tools in the future
|
||||||
|
|
||||||
|
const fs = require('fs').promises;
|
||||||
|
const child_process = require('child_process');
|
||||||
|
|
||||||
|
async function run()
|
||||||
|
{
|
||||||
|
const options = {
|
||||||
|
object_size: 128*1024,
|
||||||
|
bitmap_granularity: 4096,
|
||||||
|
journal_size: 16*1024*1024,
|
||||||
|
device_block_size: 4096,
|
||||||
|
journal_offset: 0,
|
||||||
|
device_size: 0,
|
||||||
|
format: 'text',
|
||||||
|
};
|
||||||
|
for (let i = 2; i < process.argv.length; i++)
|
||||||
|
{
|
||||||
|
if (process.argv[i].substr(0, 2) == '--')
|
||||||
|
{
|
||||||
|
options[process.argv[i].substr(2)] = process.argv[i+1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!options.device)
|
||||||
|
{
|
||||||
|
process.stderr.write('USAGE: nodejs '+process.argv[1]+' --device /dev/sdXXX\n');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
options.device_size = Number(options.device_size);
|
||||||
|
let device_size = options.device_size;
|
||||||
|
if (!device_size)
|
||||||
|
{
|
||||||
|
const st = await fs.stat(options.device);
|
||||||
|
options.device_block_size = st.blksize;
|
||||||
|
if (st.isBlockDevice())
|
||||||
|
device_size = Number(await system("/sbin/blockdev --getsize64 "+options.device))
|
||||||
|
else
|
||||||
|
device_size = st.size;
|
||||||
|
}
|
||||||
|
if (!device_size)
|
||||||
|
{
|
||||||
|
process.stderr.write('Failed to get device size\n');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
options.journal_offset = Math.ceil(options.journal_offset/options.device_block_size)*options.device_block_size;
|
||||||
|
const meta_offset = options.journal_offset + Math.ceil(options.journal_size/options.device_block_size)*options.device_block_size;
|
||||||
|
const entries_per_block = Math.floor(options.device_block_size / (24 + 2*options.object_size/options.bitmap_granularity/8));
|
||||||
|
const object_count = Math.floor((device_size-meta_offset)/options.object_size);
|
||||||
|
const meta_size = Math.ceil(1 + object_count / entries_per_block) * options.device_block_size;
|
||||||
|
const data_offset = meta_offset + meta_size;
|
||||||
|
const meta_size_fmt = (meta_size > 1024*1024*1024 ? Math.round(meta_size/1024/1024/1024*100)/100+" GB"
|
||||||
|
: Math.round(meta_size/1024/1024*100)/100+" MB");
|
||||||
|
if (options.format == 'text' || options.format == 'options')
|
||||||
|
{
|
||||||
|
if (options.format == 'text')
|
||||||
|
{
|
||||||
|
process.stderr.write(
|
||||||
|
`Metadata size: ${meta_size_fmt}\n`+
|
||||||
|
`Options for the OSD:\n`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
process.stdout.write(
|
||||||
|
(options.device_block_size != 4096 ?
|
||||||
|
` --meta_block_size ${options.device}\n`+
|
||||||
|
` --journal_block-size ${options.device}\n` : '')+
|
||||||
|
` --data_device ${options.device}\n`+
|
||||||
|
` --journal_offset ${options.journal_offset}\n`+
|
||||||
|
` --meta_offset ${meta_offset}\n`+
|
||||||
|
` --data_offset ${data_offset}\n`+
|
||||||
|
(options.device_size ? ` --data_size ${device_size-data_offset}\n` : '')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (options.format == 'env')
|
||||||
|
{
|
||||||
|
process.stdout.write(
|
||||||
|
`journal_offset=${options.journal_offset}\n`+
|
||||||
|
`meta_offset=${meta_offset}\n`+
|
||||||
|
`data_offset=${data_offset}\n`+
|
||||||
|
`data_size=${device_size-data_offset}\n`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
process.stdout.write('Unknown format: '+options.format);
|
||||||
|
}
|
||||||
|
|
||||||
|
function system(cmd)
|
||||||
|
{
|
||||||
|
return new Promise((ok, no) => child_process.exec(cmd, { maxBuffer: 64*1024*1024 }, (err, stdout, stderr) => (err ? no(err.message) : ok(stdout))));
|
||||||
|
}
|
||||||
|
|
||||||
|
run().catch(err => { console.error(err); process.exit(1); });
|
|
@ -0,0 +1,78 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: MIT
|
||||||
|
|
||||||
|
function stableStringify(obj, opts)
|
||||||
|
{
|
||||||
|
if (!opts)
|
||||||
|
opts = {};
|
||||||
|
if (typeof opts === 'function')
|
||||||
|
opts = { cmp: opts };
|
||||||
|
let space = opts.space || '';
|
||||||
|
if (typeof space === 'number')
|
||||||
|
space = Array(space+1).join(' ');
|
||||||
|
const cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false;
|
||||||
|
const cmp = opts.cmp && (function (f)
|
||||||
|
{
|
||||||
|
return function (node)
|
||||||
|
{
|
||||||
|
return function (a, b)
|
||||||
|
{
|
||||||
|
let aobj = { key: a, value: node[a] };
|
||||||
|
let bobj = { key: b, value: node[b] };
|
||||||
|
return f(aobj, bobj);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})(opts.cmp);
|
||||||
|
const seen = new Map();
|
||||||
|
return (function stringify (parent, key, node, level)
|
||||||
|
{
|
||||||
|
const indent = space ? ('\n' + new Array(level + 1).join(space)) : '';
|
||||||
|
const colonSeparator = space ? ': ' : ':';
|
||||||
|
if (node === undefined)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof node !== 'object' || node === null)
|
||||||
|
{
|
||||||
|
return JSON.stringify(node);
|
||||||
|
}
|
||||||
|
if (node instanceof Array)
|
||||||
|
{
|
||||||
|
const out = [];
|
||||||
|
for (let i = 0; i < node.length; i++)
|
||||||
|
{
|
||||||
|
const item = stringify(node, i, node[i], level+1) || JSON.stringify(null);
|
||||||
|
out.push(indent + space + item);
|
||||||
|
}
|
||||||
|
return '[' + out.join(',') + indent + ']';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (seen.has(node))
|
||||||
|
{
|
||||||
|
if (cycles)
|
||||||
|
return JSON.stringify('__cycle__');
|
||||||
|
throw new TypeError('Converting circular structure to JSON');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
seen.set(node, true);
|
||||||
|
const keys = Object.keys(node).sort(cmp && cmp(node));
|
||||||
|
const out = [];
|
||||||
|
for (let i = 0; i < keys.length; i++)
|
||||||
|
{
|
||||||
|
const key = keys[i];
|
||||||
|
const value = stringify(node, key, node[key], level+1);
|
||||||
|
if (!value)
|
||||||
|
continue;
|
||||||
|
const keyValue = JSON.stringify(key)
|
||||||
|
+ colonSeparator
|
||||||
|
+ value;
|
||||||
|
out.push(indent + space + keyValue);
|
||||||
|
}
|
||||||
|
seen.delete(node);
|
||||||
|
return '{' + out.join(',') + indent + '}';
|
||||||
|
}
|
||||||
|
})({ '': obj }, '', obj, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = stableStringify;
|
|
@ -0,0 +1,130 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
|
|
||||||
|
// Interesting real-world example coming from Ceph with EC and compression enabled.
|
||||||
|
// EC parity chunks can't be compressed as efficiently as data chunks,
|
||||||
|
// thus they occupy more space (2.26x more space) in OSD object stores.
|
||||||
|
// This leads to really uneven OSD fill ratio in Ceph even when PGs are perfectly balanced.
|
||||||
|
// But we support this case with the "parity_space" parameter in optimize_initial()/optimize_change().
|
||||||
|
|
||||||
|
const LPOptimizer = require('./lp-optimizer.js');
|
||||||
|
|
||||||
|
const osd_tree = {
|
||||||
|
ripper5: {
|
||||||
|
osd0: 3.493144989013672,
|
||||||
|
osd1: 3.493144989013672,
|
||||||
|
osd2: 3.454082489013672,
|
||||||
|
osd12: 3.461894989013672,
|
||||||
|
},
|
||||||
|
ripper7: {
|
||||||
|
osd4: 3.638690948486328,
|
||||||
|
osd5: 3.638690948486328,
|
||||||
|
osd6: 3.638690948486328,
|
||||||
|
},
|
||||||
|
ripper4: {
|
||||||
|
osd9: 3.4609375,
|
||||||
|
osd10: 3.4609375,
|
||||||
|
osd11: 3.4609375,
|
||||||
|
},
|
||||||
|
ripper6: {
|
||||||
|
osd3: 3.5849609375,
|
||||||
|
osd7: 3.5859336853027344,
|
||||||
|
osd8: 3.638690948486328,
|
||||||
|
osd13: 3.461894989013672
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const prev_pgs = [[12,7,5],[6,11,12],[3,6,9],[10,0,5],[2,5,13],[9,8,6],[3,4,12],[7,4,12],[12,11,13],[13,6,0],[4,13,10],[9,7,6],[7,10,0],[10,8,0],[3,10,2],[3,0,4],[6,13,0],[13,10,0],[13,10,5],[8,11,6],[3,9,2],[2,8,5],[8,9,5],[3,12,11],[0,7,4],[13,11,1],[11,3,12],[12,8,10],[7,5,12],[2,13,5],[7,11,0],[13,2,6],[0,6,8],[13,1,6],[0,13,4],[0,8,10],[4,10,0],[8,12,4],[8,12,9],[12,7,4],[13,9,5],[3,2,11],[1,9,7],[1,8,5],[5,12,9],[3,5,12],[2,8,10],[0,8,4],[1,4,11],[7,10,2],[12,13,5],[3,1,11],[7,1,4],[4,12,8],[7,0,9],[11,1,8],[3,0,5],[11,13,0],[1,13,5],[12,7,10],[12,8,4],[11,13,5],[0,11,6],[2,11,3],[13,1,11],[2,7,10],[7,10,12],[7,12,10],[12,11,5],[13,12,10],[2,3,9],[4,3,9],[13,2,5],[7,12,6],[12,10,13],[9,8,1],[13,1,5],[9,5,12],[5,11,7],[6,2,9],[8,11,6],[12,5,8],[6,13,1],[7,6,11],[2,3,6],[8,5,9],[1,13,6],[9,3,2],[7,11,1],[3,10,1],[0,11,7],[3,0,5],[1,3,6],[6,0,9],[3,11,4],[8,10,2],[13,1,9],[12,6,9],[3,12,9],[12,8,9],[7,5,0],[8,12,5],[0,11,3],[12,11,13],[0,7,11],[0,3,10],[1,3,11],[2,7,11],[13,2,6],[9,12,13],[8,2,4],[0,7,4],[5,13,0],[13,12,9],[1,9,8],[0,10,3],[3,5,10],[7,12,9],[2,13,4],[12,7,5],[9,2,7],[3,2,9],[6,2,7],[3,1,9],[4,3,2],[5,3,11],[0,7,6],[1,6,13],[7,10,2],[12,4,8],[13,12,6],[7,5,11],[6,2,3],[2,7,6],[2,3,10],[2,7,10],[11,12,6],[0,13,5],[10,2,4],[13,0,11],[7,0,6],[8,9,4],[8,4,11],[7,11,2],[3,4,2],[6,1,3],[7,2,11],[8,9,4],[11,4,8],[10,3,1],[2,10,13],[1,7,11],[13,11,12],[2,6,9],[10,0,13],[7,10,4],[0,11,13],[13,10,1],[7,5,0],[7,12,10],[3,1,4],[7,1,5],[3,11,5],[7,5,0],[1,3,5],[10,5,12],[0,3,9],[7,1,11],[11,8,12],[3,6,2],[7,12,9],[7,11,12],[4,11,3],[0,11,13],[13,2,5],[1,5,8],[0,11,8],[3,5,1],[11,0,6],[3,11,2],[11,8,12],[4,1,3],[10,13,4],[13,9,6],[2,3,10],[12,7,9],[10,0,4],[10,13,2],[3,11,1],[7,2,9],[1,7,4],[13,1,4],[7,0,6],[5,3,9],[10,0,7],[0,7,10],[3,6,10],[13,0,5],[8,4,1],[3,1,10],[2,10,13],[13,0,5],[13,10,2],[12,7,9],[6,8,10],[6,1,8],[10,8,1],[13,5,0],[5,11,3],[7,6,1],[8,5,9],[2,13,11],[10,12,4],[13,4,1],[2,13,4],[11,7,0],[2,9,7],[1,7,6],[8,0,4],[8,1,9],[7,10,12],[13,9,6],[7,6,11],[13,0,4],[1,8,4],[3,12,5],[10,3,1],[10,2,13],[2,4,8],[6,2,3],[3,0,10],[6,7,12],[8,12,5],[3,0,6],[13,12,10],[11,3,6],[9,0,13],[10,0,6],[7,5,2],[1,3,11],[7,10,2],[2,9,8],[11,13,12],[0,8,4],[8,12,11],[6,0,3],[1,13,4],[11,8,2],[12,3,6],[4,7,1],[7,6,12],[3,10,6],[0,10,7],[8,9,1],[0,10,6],[8,10,1]]
|
||||||
|
.map(pg => pg.map(n => 'osd'+n));
|
||||||
|
|
||||||
|
const by_osd = {};
|
||||||
|
|
||||||
|
for (let i = 0; i < prev_pgs.length; i++)
|
||||||
|
{
|
||||||
|
for (let j = 0; j < prev_pgs[i].length; j++)
|
||||||
|
{
|
||||||
|
by_osd[prev_pgs[i][j]] = by_osd[prev_pgs[i][j]] || [];
|
||||||
|
by_osd[prev_pgs[i][j]][j] = (by_osd[prev_pgs[i][j]][j] || 0) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
This set of PGs was balanced by hand, by heavily tuning OSD weights in Ceph:
|
||||||
|
|
||||||
|
{
|
||||||
|
osd0: 4.2,
|
||||||
|
osd1: 3.5,
|
||||||
|
osd2: 3.45409,
|
||||||
|
osd3: 4.5,
|
||||||
|
osd4: 1.4,
|
||||||
|
osd5: 1.4,
|
||||||
|
osd6: 1.75,
|
||||||
|
osd7: 4.5,
|
||||||
|
osd8: 4.4,
|
||||||
|
osd9: 2.2,
|
||||||
|
osd10: 2.7,
|
||||||
|
osd11: 2,
|
||||||
|
osd12: 3.4,
|
||||||
|
osd13: 3.4,
|
||||||
|
}
|
||||||
|
|
||||||
|
EC+compression is a nightmare in Ceph, yeah :))
|
||||||
|
|
||||||
|
To calculate the average ratio between data chunks and parity chunks we
|
||||||
|
calculate the number of PG chunks for each chunk role for each OSD:
|
||||||
|
|
||||||
|
{
|
||||||
|
osd12: [ 18, 22, 17 ],
|
||||||
|
osd7: [ 35, 22, 8 ],
|
||||||
|
osd5: [ 6, 17, 27 ],
|
||||||
|
osd6: [ 13, 12, 28 ],
|
||||||
|
osd11: [ 13, 26, 20 ],
|
||||||
|
osd3: [ 30, 20, 10 ],
|
||||||
|
osd9: [ 8, 12, 26 ],
|
||||||
|
osd10: [ 15, 23, 20 ],
|
||||||
|
osd0: [ 22, 22, 14 ],
|
||||||
|
osd2: [ 22, 16, 16 ],
|
||||||
|
osd13: [ 29, 19, 13 ],
|
||||||
|
osd8: [ 20, 18, 12 ],
|
||||||
|
osd4: [ 8, 10, 28 ],
|
||||||
|
osd1: [ 17, 17, 17 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
And now we can pick a pair of OSDs and determine the ratio by solving the following:
|
||||||
|
|
||||||
|
osd5 = 23*X + 27*Y = 3249728140
|
||||||
|
osd13 = 48*X + 13*Y = 2991675992
|
||||||
|
|
||||||
|
=>
|
||||||
|
|
||||||
|
osd5 - 27/13*osd13 = 23*X - 27/13*48*X = -76.6923076923077*X = -2963752766.46154
|
||||||
|
|
||||||
|
=>
|
||||||
|
|
||||||
|
X = 38644720.1243731
|
||||||
|
Y = (osd5-23*X)/27 = 87440725.0792377
|
||||||
|
Y/X = 2.26268232239284 ~= 2.26
|
||||||
|
|
||||||
|
Which means that parity chunks are compressed ~2.26 times worse than data chunks.
|
||||||
|
|
||||||
|
Fine, let's try to optimize for it.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
async function run()
|
||||||
|
{
|
||||||
|
const all_weights = Object.assign({}, ...Object.values(osd_tree));
|
||||||
|
const total_weight = Object.values(all_weights).reduce((a, c) => Number(a) + Number(c), 0);
|
||||||
|
const eff = LPOptimizer.pg_list_space_efficiency(prev_pgs, all_weights, 2, 2.26);
|
||||||
|
const orig = eff*4.26 / total_weight;
|
||||||
|
console.log('Original efficiency was: '+Math.round(orig*10000)/100+' %');
|
||||||
|
|
||||||
|
let prev = await LPOptimizer.optimize_initial({ osd_tree, pg_size: 3, pg_count: 256, parity_space: 2.26 });
|
||||||
|
LPOptimizer.print_change_stats(prev);
|
||||||
|
|
||||||
|
let next = await LPOptimizer.optimize_change({ prev_pgs, osd_tree, pg_size: 3, max_combinations: 10000, parity_space: 2.26 });
|
||||||
|
LPOptimizer.print_change_stats(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
run().catch(console.error);
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
|
|
||||||
|
const LPOptimizer = require('./lp-optimizer.js');
|
||||||
|
|
||||||
|
async function run()
|
||||||
|
{
|
||||||
|
const osd_tree = { a: { 1: 1 }, b: { 2: 1 }, c: { 3: 1 } };
|
||||||
|
let res;
|
||||||
|
|
||||||
|
console.log('16 PGs, size=3');
|
||||||
|
res = await LPOptimizer.optimize_initial({ osd_tree, pg_size: 3, pg_count: 16 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
|
||||||
|
console.log('\nReduce PG size to 2');
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs.map(pg => pg.slice(0, 2)), osd_tree, pg_size: 2 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
|
||||||
|
console.log('\nRemove OSD 3');
|
||||||
|
delete osd_tree['c'];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree, pg_size: 2 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
run().catch(console.error);
|
|
@ -0,0 +1,74 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
|
|
||||||
|
const LPOptimizer = require('./lp-optimizer.js');
|
||||||
|
|
||||||
|
const crush_tree = [
|
||||||
|
{ level: 1, children: [
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 1, size: 3 },
|
||||||
|
{ level: 3, id: 2, size: 3 },
|
||||||
|
] },
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 3, size: 3 },
|
||||||
|
{ level: 3, id: 4, size: 3 },
|
||||||
|
] },
|
||||||
|
] },
|
||||||
|
{ level: 1, children: [
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 5, size: 3 },
|
||||||
|
{ level: 3, id: 6, size: 3 },
|
||||||
|
] },
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 7, size: 3 },
|
||||||
|
{ level: 3, id: 8, size: 3 },
|
||||||
|
] },
|
||||||
|
] },
|
||||||
|
{ level: 1, children: [
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 9, size: 3 },
|
||||||
|
{ level: 3, id: 10, size: 3 },
|
||||||
|
] },
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 11, size: 3 },
|
||||||
|
{ level: 3, id: 12, size: 3 },
|
||||||
|
] },
|
||||||
|
] },
|
||||||
|
];
|
||||||
|
|
||||||
|
const osd_tree = LPOptimizer.flatten_tree(crush_tree, {}, 1, 3);
|
||||||
|
console.log(osd_tree);
|
||||||
|
|
||||||
|
async function run()
|
||||||
|
{
|
||||||
|
const cur_tree = {};
|
||||||
|
console.log('Empty tree:');
|
||||||
|
let res = await LPOptimizer.optimize_initial({ osd_tree: cur_tree, pg_size: 3, pg_count: 256 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nAdding 1st failure domain:');
|
||||||
|
cur_tree['dom1'] = osd_tree['dom1'];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree: cur_tree, pg_size: 3 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nAdding 2nd failure domain:');
|
||||||
|
cur_tree['dom2'] = osd_tree['dom2'];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree: cur_tree, pg_size: 3 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nAdding 3rd failure domain:');
|
||||||
|
cur_tree['dom3'] = osd_tree['dom3'];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree: cur_tree, pg_size: 3 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nRemoving 3rd failure domain:');
|
||||||
|
delete cur_tree['dom3'];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree: cur_tree, pg_size: 3 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nRemoving 2nd failure domain:');
|
||||||
|
delete cur_tree['dom2'];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree: cur_tree, pg_size: 3 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nRemoving 1st failure domain:');
|
||||||
|
delete cur_tree['dom1'];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree: cur_tree, pg_size: 3 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
run().catch(console.error);
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
|
|
||||||
|
const LPOptimizer = require('./lp-optimizer.js');
|
||||||
|
|
||||||
|
const osd_tree = {
|
||||||
|
100: {
|
||||||
|
1: 0.1,
|
||||||
|
2: 0.1,
|
||||||
|
3: 0.1,
|
||||||
|
},
|
||||||
|
200: {
|
||||||
|
4: 0.1,
|
||||||
|
5: 0.1,
|
||||||
|
6: 0.1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
async function run()
|
||||||
|
{
|
||||||
|
let res;
|
||||||
|
console.log('256 PGs, 3+3 OSDs, size=2');
|
||||||
|
res = await LPOptimizer.optimize_initial({ osd_tree, pg_size: 2, pg_count: 256 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
|
||||||
|
// Should NOT fail with the "unfeasible or unbounded" exception
|
||||||
|
console.log('\nRemoving osd.2');
|
||||||
|
delete osd_tree[100][2];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree, pg_size: 2 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
run().catch(console.error);
|
|
@ -0,0 +1,115 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
|
|
||||||
|
const LPOptimizer = require('./lp-optimizer.js');
|
||||||
|
|
||||||
|
const osd_tree = {
|
||||||
|
100: {
|
||||||
|
7: 3.63869,
|
||||||
|
},
|
||||||
|
300: {
|
||||||
|
10: 3.46089,
|
||||||
|
11: 3.46089,
|
||||||
|
12: 3.46089,
|
||||||
|
},
|
||||||
|
400: {
|
||||||
|
1: 3.49309,
|
||||||
|
2: 3.49309,
|
||||||
|
3: 3.49309,
|
||||||
|
},
|
||||||
|
500: {
|
||||||
|
4: 3.58498,
|
||||||
|
// 8: 3.58589,
|
||||||
|
9: 3.63869,
|
||||||
|
},
|
||||||
|
600: {
|
||||||
|
5: 3.63869,
|
||||||
|
6: 3.63869,
|
||||||
|
},
|
||||||
|
/* 100: {
|
||||||
|
1: 2.72800,
|
||||||
|
},
|
||||||
|
200: {
|
||||||
|
2: 2.72900,
|
||||||
|
},
|
||||||
|
300: {
|
||||||
|
3: 1.87000,
|
||||||
|
},
|
||||||
|
400: {
|
||||||
|
4: 1.87000,
|
||||||
|
},
|
||||||
|
500: {
|
||||||
|
5: 3.63869,
|
||||||
|
},*/
|
||||||
|
};
|
||||||
|
|
||||||
|
const crush_tree = [
|
||||||
|
{ level: 1, children: [
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 1, size: 3 },
|
||||||
|
{ level: 3, id: 2, size: 2 },
|
||||||
|
] },
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 3, size: 4 },
|
||||||
|
{ level: 3, id: 4, size: 4 },
|
||||||
|
] },
|
||||||
|
] },
|
||||||
|
{ level: 1, children: [
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 5, size: 4 },
|
||||||
|
{ level: 3, id: 6, size: 1 },
|
||||||
|
] },
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 7, size: 3 },
|
||||||
|
{ level: 3, id: 8, size: 5 },
|
||||||
|
] },
|
||||||
|
] },
|
||||||
|
{ level: 1, children: [
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 9, size: 5 },
|
||||||
|
{ level: 3, id: 10, size: 2 },
|
||||||
|
] },
|
||||||
|
{ level: 2, children: [
|
||||||
|
{ level: 3, id: 11, size: 3 },
|
||||||
|
{ level: 3, id: 12, size: 3 },
|
||||||
|
] },
|
||||||
|
] },
|
||||||
|
];
|
||||||
|
|
||||||
|
async function run()
|
||||||
|
{
|
||||||
|
let res;
|
||||||
|
|
||||||
|
// Test: add 1 OSD of almost the same size. Ideal data movement could be 1/12 = 8.33%. Actual is ~13%
|
||||||
|
// Space efficiency is ~99% in all cases.
|
||||||
|
|
||||||
|
console.log('256 PGs, size=2');
|
||||||
|
res = await LPOptimizer.optimize_initial({ osd_tree, pg_size: 2, pg_count: 256 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nAdding osd.8');
|
||||||
|
osd_tree[500][8] = 3.58589;
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree, pg_size: 2 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nRemoving osd.8');
|
||||||
|
delete osd_tree[500][8];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree, pg_size: 2 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
|
||||||
|
console.log('\n256 PGs, size=3');
|
||||||
|
res = await LPOptimizer.optimize_initial({ osd_tree, pg_size: 3, pg_count: 256 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nAdding osd.8');
|
||||||
|
osd_tree[500][8] = 3.58589;
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree, pg_size: 3 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
console.log('\nRemoving osd.8');
|
||||||
|
delete osd_tree[500][8];
|
||||||
|
res = await LPOptimizer.optimize_change({ prev_pgs: res.int_pgs, osd_tree, pg_size: 3 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
|
||||||
|
console.log('\n256 PGs, size=3, failure domain=rack');
|
||||||
|
res = await LPOptimizer.optimize_initial({ osd_tree: LPOptimizer.flatten_tree(crush_tree, {}, 1, 3), pg_size: 3, pg_count: 256 });
|
||||||
|
LPOptimizer.print_change_stats(res, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
run().catch(console.error);
|
399
osd.cpp
399
osd.cpp
|
@ -1,399 +0,0 @@
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/epoll.h>
|
|
||||||
#include <sys/poll.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include "osd.h"
|
|
||||||
|
|
||||||
static const char* osd_op_names[] = {
|
|
||||||
"",
|
|
||||||
"read",
|
|
||||||
"write",
|
|
||||||
"sync",
|
|
||||||
"stabilize",
|
|
||||||
"rollback",
|
|
||||||
"delete",
|
|
||||||
"sync_stab_all",
|
|
||||||
"list",
|
|
||||||
"show_config",
|
|
||||||
"primary_read",
|
|
||||||
"primary_write",
|
|
||||||
"primary_sync",
|
|
||||||
};
|
|
||||||
|
|
||||||
osd_t::osd_t(blockstore_config_t & config, blockstore_t *bs, ring_loop_t *ringloop)
|
|
||||||
{
|
|
||||||
this->config = config;
|
|
||||||
this->bs = bs;
|
|
||||||
this->ringloop = ringloop;
|
|
||||||
this->tick_tfd = new timerfd_interval(ringloop, 3, [this]()
|
|
||||||
{
|
|
||||||
for (int i = 0; i <= OSD_OP_MAX; i++)
|
|
||||||
{
|
|
||||||
if (op_stat_count[i] != 0)
|
|
||||||
{
|
|
||||||
printf("avg latency for op %d (%s): %ld us\n", i, osd_op_names[i], op_stat_sum[i]/op_stat_count[i]);
|
|
||||||
op_stat_count[i] = 0;
|
|
||||||
op_stat_sum[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i <= OSD_OP_MAX; i++)
|
|
||||||
{
|
|
||||||
if (subop_stat_count[i] != 0)
|
|
||||||
{
|
|
||||||
printf("avg latency for subop %d (%s): %ld us\n", i, osd_op_names[i], subop_stat_sum[i]/subop_stat_count[i]);
|
|
||||||
subop_stat_count[i] = 0;
|
|
||||||
subop_stat_sum[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (send_stat_count != 0)
|
|
||||||
{
|
|
||||||
printf("avg latency to send subops with data: %ld us\n", send_stat_sum/send_stat_count);
|
|
||||||
send_stat_count = 0;
|
|
||||||
send_stat_sum = 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this->bs_block_size = bs->get_block_size();
|
|
||||||
// FIXME: use bitmap granularity instead
|
|
||||||
this->bs_disk_alignment = bs->get_disk_alignment();
|
|
||||||
|
|
||||||
bind_address = config["bind_address"];
|
|
||||||
if (bind_address == "")
|
|
||||||
bind_address = "0.0.0.0";
|
|
||||||
bind_port = strtoull(config["bind_port"].c_str(), NULL, 10);
|
|
||||||
if (!bind_port || bind_port > 65535)
|
|
||||||
bind_port = 11203;
|
|
||||||
osd_num = strtoull(config["osd_num"].c_str(), NULL, 10);
|
|
||||||
if (!osd_num)
|
|
||||||
throw std::runtime_error("osd_num is required in the configuration");
|
|
||||||
run_primary = config["run_primary"] == "true" || config["run_primary"] == "1" || config["run_primary"] == "yes";
|
|
||||||
if (run_primary)
|
|
||||||
init_primary();
|
|
||||||
|
|
||||||
listen_fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
||||||
if (listen_fd < 0)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(std::string("socket: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
int enable = 1;
|
|
||||||
setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable));
|
|
||||||
|
|
||||||
sockaddr_in addr;
|
|
||||||
int r;
|
|
||||||
if ((r = inet_pton(AF_INET, bind_address.c_str(), &addr.sin_addr)) != 1)
|
|
||||||
{
|
|
||||||
close(listen_fd);
|
|
||||||
throw std::runtime_error("bind address "+bind_address+(r == 0 ? " is not valid" : ": no ipv4 support"));
|
|
||||||
}
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_port = htons(bind_port);
|
|
||||||
|
|
||||||
if (bind(listen_fd, (sockaddr*)&addr, sizeof(addr)) < 0)
|
|
||||||
{
|
|
||||||
close(listen_fd);
|
|
||||||
throw std::runtime_error(std::string("bind: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listen(listen_fd, listen_backlog) < 0)
|
|
||||||
{
|
|
||||||
close(listen_fd);
|
|
||||||
throw std::runtime_error(std::string("listen: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
fcntl(listen_fd, F_SETFL, fcntl(listen_fd, F_GETFL, 0) | O_NONBLOCK);
|
|
||||||
|
|
||||||
epoll_fd = epoll_create(1);
|
|
||||||
if (epoll_fd < 0)
|
|
||||||
{
|
|
||||||
close(listen_fd);
|
|
||||||
throw std::runtime_error(std::string("epoll_create: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
epoll_event ev;
|
|
||||||
ev.data.fd = listen_fd;
|
|
||||||
ev.events = EPOLLIN | EPOLLET;
|
|
||||||
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, listen_fd, &ev) < 0)
|
|
||||||
{
|
|
||||||
close(listen_fd);
|
|
||||||
close(epoll_fd);
|
|
||||||
throw std::runtime_error(std::string("epoll_ctl: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
consumer.loop = [this]() { loop(); };
|
|
||||||
ringloop->register_consumer(consumer);
|
|
||||||
}
|
|
||||||
|
|
||||||
osd_t::~osd_t()
|
|
||||||
{
|
|
||||||
delete tick_tfd;
|
|
||||||
ringloop->unregister_consumer(consumer);
|
|
||||||
close(epoll_fd);
|
|
||||||
close(listen_fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
osd_op_t::~osd_op_t()
|
|
||||||
{
|
|
||||||
if (bs_op)
|
|
||||||
{
|
|
||||||
delete bs_op;
|
|
||||||
}
|
|
||||||
if (op_data)
|
|
||||||
{
|
|
||||||
free(op_data);
|
|
||||||
}
|
|
||||||
if (rmw_buf)
|
|
||||||
{
|
|
||||||
free(rmw_buf);
|
|
||||||
}
|
|
||||||
if (buf)
|
|
||||||
{
|
|
||||||
// Note: reusing osd_op_t WILL currently lead to memory leaks
|
|
||||||
// So we don't reuse it, but free it every time
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool osd_t::shutdown()
|
|
||||||
{
|
|
||||||
stopping = true;
|
|
||||||
if (inflight_ops > 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return bs->is_safe_to_stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::loop()
|
|
||||||
{
|
|
||||||
if (!wait_state)
|
|
||||||
{
|
|
||||||
handle_epoll_events();
|
|
||||||
wait_state = 1;
|
|
||||||
}
|
|
||||||
handle_peers();
|
|
||||||
read_requests();
|
|
||||||
send_replies();
|
|
||||||
ringloop->submit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::handle_epoll_events()
|
|
||||||
{
|
|
||||||
int nfds;
|
|
||||||
epoll_event events[MAX_EPOLL_EVENTS];
|
|
||||||
restart:
|
|
||||||
nfds = epoll_wait(epoll_fd, events, MAX_EPOLL_EVENTS, 0);
|
|
||||||
for (int i = 0; i < nfds; i++)
|
|
||||||
{
|
|
||||||
if (events[i].data.fd == listen_fd)
|
|
||||||
{
|
|
||||||
// Accept new connections
|
|
||||||
sockaddr_in addr;
|
|
||||||
socklen_t peer_addr_size = sizeof(addr);
|
|
||||||
int peer_fd;
|
|
||||||
while ((peer_fd = accept(listen_fd, (sockaddr*)&addr, &peer_addr_size)) >= 0)
|
|
||||||
{
|
|
||||||
char peer_str[256];
|
|
||||||
printf("osd: new client %d: connection from %s port %d\n", peer_fd, inet_ntop(AF_INET, &addr.sin_addr, peer_str, 256), ntohs(addr.sin_port));
|
|
||||||
int one = 1;
|
|
||||||
setsockopt(peer_fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one));
|
|
||||||
clients[peer_fd] = {
|
|
||||||
.peer_addr = addr,
|
|
||||||
.peer_port = ntohs(addr.sin_port),
|
|
||||||
.peer_fd = peer_fd,
|
|
||||||
.peer_state = PEER_CONNECTED,
|
|
||||||
};
|
|
||||||
// Add FD to epoll
|
|
||||||
epoll_event ev;
|
|
||||||
ev.data.fd = peer_fd;
|
|
||||||
ev.events = EPOLLET | EPOLLRDHUP;
|
|
||||||
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, peer_fd, &ev) < 0)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(std::string("epoll_ctl: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
// Try to accept next connection
|
|
||||||
peer_addr_size = sizeof(addr);
|
|
||||||
}
|
|
||||||
if (peer_fd == -1 && errno != EAGAIN)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(std::string("accept: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto & cl = clients[events[i].data.fd];
|
|
||||||
if (cl.peer_state == PEER_CONNECTING)
|
|
||||||
{
|
|
||||||
// Either OUT (connected) or HUP
|
|
||||||
handle_connect_result(cl.peer_fd);
|
|
||||||
}
|
|
||||||
else if (events[i].events & EPOLLRDHUP)
|
|
||||||
{
|
|
||||||
// Stop client
|
|
||||||
printf("osd: client %d disconnected\n", cl.peer_fd);
|
|
||||||
stop_client(cl.peer_fd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Mark client as ready (i.e. some data is available)
|
|
||||||
cl.read_ready++;
|
|
||||||
if (cl.read_ready == 1)
|
|
||||||
{
|
|
||||||
read_ready_clients.push_back(cl.peer_fd);
|
|
||||||
ringloop->wakeup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nfds == MAX_EPOLL_EVENTS)
|
|
||||||
{
|
|
||||||
goto restart;
|
|
||||||
}
|
|
||||||
io_uring_sqe *sqe = ringloop->get_sqe();
|
|
||||||
if (!sqe)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("can't get SQE, will fall out of sync with EPOLLET");
|
|
||||||
}
|
|
||||||
ring_data_t *data = ((ring_data_t*)sqe->user_data);
|
|
||||||
my_uring_prep_poll_add(sqe, epoll_fd, POLLIN);
|
|
||||||
data->callback = [this](ring_data_t *data)
|
|
||||||
{
|
|
||||||
if (data->res < 0)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(std::string("epoll failed: ") + strerror(-data->res));
|
|
||||||
}
|
|
||||||
handle_epoll_events();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::cancel_osd_ops(osd_client_t & cl)
|
|
||||||
{
|
|
||||||
for (auto p: cl.sent_ops)
|
|
||||||
{
|
|
||||||
cancel_op(p.second);
|
|
||||||
}
|
|
||||||
cl.sent_ops.clear();
|
|
||||||
for (auto op: cl.outbox)
|
|
||||||
{
|
|
||||||
cancel_op(op);
|
|
||||||
}
|
|
||||||
cl.outbox.clear();
|
|
||||||
if (cl.write_op)
|
|
||||||
{
|
|
||||||
cancel_op(cl.write_op);
|
|
||||||
cl.write_op = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::cancel_op(osd_op_t *op)
|
|
||||||
{
|
|
||||||
if (op->op_type == OSD_OP_OUT)
|
|
||||||
{
|
|
||||||
op->reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC;
|
|
||||||
op->reply.hdr.id = op->req.hdr.id;
|
|
||||||
op->reply.hdr.opcode = op->req.hdr.opcode;
|
|
||||||
op->reply.hdr.retval = -EPIPE;
|
|
||||||
op->callback(op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete op;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::stop_client(int peer_fd)
|
|
||||||
{
|
|
||||||
auto it = clients.find(peer_fd);
|
|
||||||
if (it == clients.end())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto & cl = it->second;
|
|
||||||
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, peer_fd, NULL) < 0)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(std::string("epoll_ctl: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
if (cl.osd_num)
|
|
||||||
{
|
|
||||||
// Cancel outbound operations
|
|
||||||
cancel_osd_ops(cl);
|
|
||||||
osd_peer_fds.erase(cl.osd_num);
|
|
||||||
repeer_pgs(cl.osd_num, false);
|
|
||||||
peering_state |= OSD_PEERING_PEERS;
|
|
||||||
}
|
|
||||||
if (cl.read_op)
|
|
||||||
{
|
|
||||||
delete cl.read_op;
|
|
||||||
}
|
|
||||||
for (auto rit = read_ready_clients.begin(); rit != read_ready_clients.end(); rit++)
|
|
||||||
{
|
|
||||||
if (*rit == peer_fd)
|
|
||||||
{
|
|
||||||
read_ready_clients.erase(rit);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto wit = write_ready_clients.begin(); wit != write_ready_clients.end(); wit++)
|
|
||||||
{
|
|
||||||
if (*wit == peer_fd)
|
|
||||||
{
|
|
||||||
write_ready_clients.erase(wit);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
clients.erase(it);
|
|
||||||
close(peer_fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::exec_op(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
gettimeofday(&cur_op->tv_begin, NULL);
|
|
||||||
if (stopping)
|
|
||||||
{
|
|
||||||
// Throw operation away
|
|
||||||
delete cur_op;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cur_op->send_list.push_back(cur_op->reply.buf, OSD_PACKET_SIZE);
|
|
||||||
if (cur_op->req.hdr.magic != SECONDARY_OSD_OP_MAGIC ||
|
|
||||||
cur_op->req.hdr.opcode < OSD_OP_MIN || cur_op->req.hdr.opcode > OSD_OP_MAX ||
|
|
||||||
(cur_op->req.hdr.opcode == OSD_OP_SECONDARY_READ || cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE) &&
|
|
||||||
(cur_op->req.sec_rw.len > OSD_RW_MAX || cur_op->req.sec_rw.len % OSD_RW_ALIGN || cur_op->req.sec_rw.offset % OSD_RW_ALIGN) ||
|
|
||||||
(cur_op->req.hdr.opcode == OSD_OP_READ || cur_op->req.hdr.opcode == OSD_OP_WRITE) &&
|
|
||||||
(cur_op->req.rw.len > OSD_RW_MAX || cur_op->req.rw.len % OSD_RW_ALIGN || cur_op->req.rw.offset % OSD_RW_ALIGN))
|
|
||||||
{
|
|
||||||
// Bad command
|
|
||||||
cur_op->reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC;
|
|
||||||
cur_op->reply.hdr.id = cur_op->req.hdr.id;
|
|
||||||
cur_op->reply.hdr.opcode = cur_op->req.hdr.opcode;
|
|
||||||
cur_op->reply.hdr.retval = -EINVAL;
|
|
||||||
outbox_push(this->clients[cur_op->peer_fd], cur_op);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
inflight_ops++;
|
|
||||||
if (cur_op->req.hdr.opcode == OSD_OP_TEST_SYNC_STAB_ALL)
|
|
||||||
{
|
|
||||||
exec_sync_stab_all(cur_op);
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SHOW_CONFIG)
|
|
||||||
{
|
|
||||||
exec_show_config(cur_op);
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_READ)
|
|
||||||
{
|
|
||||||
continue_primary_read(cur_op);
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_WRITE)
|
|
||||||
{
|
|
||||||
continue_primary_write(cur_op);
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SYNC)
|
|
||||||
{
|
|
||||||
continue_primary_sync(cur_op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
exec_secondary(cur_op);
|
|
||||||
}
|
|
||||||
}
|
|
274
osd.h
274
osd.h
|
@ -1,274 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
#include <set>
|
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
#include "blockstore.h"
|
|
||||||
#include "ringloop.h"
|
|
||||||
#include "timerfd_interval.h"
|
|
||||||
#include "osd_ops.h"
|
|
||||||
#include "osd_peering_pg.h"
|
|
||||||
|
|
||||||
#include "sparsepp/sparsepp/spp.h"
|
|
||||||
|
|
||||||
#define OSD_OP_IN 0
|
|
||||||
#define OSD_OP_OUT 1
|
|
||||||
|
|
||||||
#define CL_READ_OP 1
|
|
||||||
#define CL_READ_DATA 2
|
|
||||||
#define CL_READ_REPLY_DATA 3
|
|
||||||
#define CL_WRITE_READY 1
|
|
||||||
#define CL_WRITE_REPLY 2
|
|
||||||
#define MAX_EPOLL_EVENTS 64
|
|
||||||
#define OSD_OP_INLINE_BUF_COUNT 16
|
|
||||||
|
|
||||||
#define PEER_CONNECTING 1
|
|
||||||
#define PEER_CONNECTED 2
|
|
||||||
#define OSD_PEERING_PEERS 1
|
|
||||||
#define OSD_PEERING_PGS 2
|
|
||||||
|
|
||||||
//#define OSD_STUB
|
|
||||||
|
|
||||||
struct osd_op_buf_list_t
|
|
||||||
{
|
|
||||||
int count = 0, alloc = 0, sent = 0;
|
|
||||||
iovec *buf = NULL;
|
|
||||||
iovec inline_buf[OSD_OP_INLINE_BUF_COUNT];
|
|
||||||
|
|
||||||
~osd_op_buf_list_t()
|
|
||||||
{
|
|
||||||
if (buf && buf != inline_buf)
|
|
||||||
{
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline iovec* get_iovec()
|
|
||||||
{
|
|
||||||
return (buf ? buf : inline_buf) + sent;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int get_size()
|
|
||||||
{
|
|
||||||
return count - sent;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void push_back(void *nbuf, size_t len)
|
|
||||||
{
|
|
||||||
if (count >= alloc)
|
|
||||||
{
|
|
||||||
if (!alloc)
|
|
||||||
{
|
|
||||||
alloc = OSD_OP_INLINE_BUF_COUNT;
|
|
||||||
buf = inline_buf;
|
|
||||||
}
|
|
||||||
else if (buf == inline_buf)
|
|
||||||
{
|
|
||||||
int old = alloc;
|
|
||||||
alloc = ((alloc/16)*16 + 1);
|
|
||||||
buf = (iovec*)malloc(sizeof(iovec) * alloc);
|
|
||||||
memcpy(buf, inline_buf, sizeof(iovec)*old);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
alloc = ((alloc/16)*16 + 1);
|
|
||||||
buf = (iovec*)realloc(buf, sizeof(iovec) * alloc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buf[count++] = { .iov_base = nbuf, .iov_len = len };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct osd_primary_op_data_t;
|
|
||||||
|
|
||||||
struct osd_op_t
|
|
||||||
{
|
|
||||||
timeval tv_begin;
|
|
||||||
timeval tv_send;
|
|
||||||
int op_type = OSD_OP_IN;
|
|
||||||
int peer_fd;
|
|
||||||
osd_any_op_t req;
|
|
||||||
osd_any_reply_t reply;
|
|
||||||
blockstore_op_t *bs_op = NULL;
|
|
||||||
void *buf = NULL;
|
|
||||||
void *rmw_buf = NULL;
|
|
||||||
osd_primary_op_data_t* op_data = NULL;
|
|
||||||
std::function<void(osd_op_t*)> callback;
|
|
||||||
|
|
||||||
osd_op_buf_list_t send_list;
|
|
||||||
|
|
||||||
~osd_op_t();
|
|
||||||
};
|
|
||||||
|
|
||||||
struct osd_peer_def_t
|
|
||||||
{
|
|
||||||
osd_num_t osd_num = 0;
|
|
||||||
std::string addr;
|
|
||||||
int port = 0;
|
|
||||||
time_t last_connect_attempt = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct osd_client_t
|
|
||||||
{
|
|
||||||
sockaddr_in peer_addr;
|
|
||||||
int peer_port;
|
|
||||||
int peer_fd;
|
|
||||||
int peer_state;
|
|
||||||
std::function<void(osd_num_t, int)> connect_callback;
|
|
||||||
osd_num_t osd_num = 0;
|
|
||||||
|
|
||||||
// Read state
|
|
||||||
int read_ready = 0;
|
|
||||||
osd_op_t *read_op = NULL;
|
|
||||||
int read_reply_id = 0;
|
|
||||||
iovec read_iov = { 0 };
|
|
||||||
msghdr read_msg = { 0 };
|
|
||||||
void *read_buf = NULL;
|
|
||||||
int read_remaining = 0;
|
|
||||||
int read_state = 0;
|
|
||||||
|
|
||||||
// Outbound operations sent to this client (which is probably an OSD peer)
|
|
||||||
std::map<int, osd_op_t*> sent_ops;
|
|
||||||
|
|
||||||
// Outbound messages (replies or requests)
|
|
||||||
std::deque<osd_op_t*> outbox;
|
|
||||||
|
|
||||||
// PGs dirtied by this client's primary-writes
|
|
||||||
std::set<pg_num_t> dirty_pgs;
|
|
||||||
|
|
||||||
// Write state
|
|
||||||
osd_op_t *write_op = NULL;
|
|
||||||
msghdr write_msg;
|
|
||||||
int write_state = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct osd_rmw_stripe_t;
|
|
||||||
|
|
||||||
struct osd_object_id_t
|
|
||||||
{
|
|
||||||
osd_num_t osd_num;
|
|
||||||
object_id oid;
|
|
||||||
};
|
|
||||||
|
|
||||||
class osd_t
|
|
||||||
{
|
|
||||||
// config
|
|
||||||
|
|
||||||
osd_num_t osd_num = 1; // OSD numbers start with 1
|
|
||||||
bool run_primary = false;
|
|
||||||
std::vector<osd_peer_def_t> peers;
|
|
||||||
blockstore_config_t config;
|
|
||||||
std::string bind_address;
|
|
||||||
int bind_port, listen_backlog;
|
|
||||||
int client_queue_depth = 128;
|
|
||||||
bool allow_test_ops = true;
|
|
||||||
|
|
||||||
// peer OSDs
|
|
||||||
|
|
||||||
std::map<uint64_t, int> osd_peer_fds;
|
|
||||||
std::vector<pg_t> pgs;
|
|
||||||
int peering_state = 0;
|
|
||||||
unsigned pg_count = 0;
|
|
||||||
uint64_t next_subop_id = 1;
|
|
||||||
|
|
||||||
// Unstable writes
|
|
||||||
std::map<osd_object_id_t, uint64_t> unstable_writes;
|
|
||||||
std::deque<osd_op_t*> syncs_in_progress;
|
|
||||||
|
|
||||||
// client & peer I/O
|
|
||||||
|
|
||||||
bool stopping = false;
|
|
||||||
int inflight_ops = 0;
|
|
||||||
blockstore_t *bs;
|
|
||||||
uint32_t bs_block_size, bs_disk_alignment;
|
|
||||||
uint64_t parity_block_size = 4*1024*1024; // 4 MB by default
|
|
||||||
ring_loop_t *ringloop;
|
|
||||||
timerfd_interval *tick_tfd;
|
|
||||||
|
|
||||||
int wait_state = 0;
|
|
||||||
int epoll_fd = 0;
|
|
||||||
int listen_fd = 0;
|
|
||||||
ring_consumer_t consumer;
|
|
||||||
|
|
||||||
std::unordered_map<int,osd_client_t> clients;
|
|
||||||
std::vector<int> read_ready_clients;
|
|
||||||
std::vector<int> write_ready_clients;
|
|
||||||
uint64_t op_stat_sum[OSD_OP_MAX+1] = { 0 };
|
|
||||||
uint64_t op_stat_count[OSD_OP_MAX+1] = { 0 };
|
|
||||||
uint64_t subop_stat_sum[OSD_OP_MAX+1] = { 0 };
|
|
||||||
uint64_t subop_stat_count[OSD_OP_MAX+1] = { 0 };
|
|
||||||
uint64_t send_stat_sum = 0;
|
|
||||||
uint64_t send_stat_count = 0;
|
|
||||||
|
|
||||||
// methods
|
|
||||||
|
|
||||||
// event loop, socket read/write
|
|
||||||
void loop();
|
|
||||||
void handle_epoll_events();
|
|
||||||
bool try_receive(osd_client_t & cl);
|
|
||||||
void read_requests();
|
|
||||||
void handle_read(ring_data_t *data, int peer_fd);
|
|
||||||
void handle_op_hdr(osd_client_t *cl);
|
|
||||||
void handle_reply_hdr(osd_client_t *cl);
|
|
||||||
void send_replies();
|
|
||||||
void handle_send(ring_data_t *data, int peer_fd);
|
|
||||||
void outbox_push(osd_client_t & cl, osd_op_t *op);
|
|
||||||
|
|
||||||
// peer handling (primary OSD logic)
|
|
||||||
void connect_peer(osd_num_t osd_num, const char *peer_host, int peer_port, std::function<void(osd_num_t, int)> callback);
|
|
||||||
void handle_connect_result(int peer_fd);
|
|
||||||
void cancel_osd_ops(osd_client_t & cl);
|
|
||||||
void cancel_op(osd_op_t *op);
|
|
||||||
void stop_client(int peer_fd);
|
|
||||||
osd_peer_def_t parse_peer(std::string peer);
|
|
||||||
void init_primary();
|
|
||||||
void handle_peers();
|
|
||||||
void repeer_pgs(osd_num_t osd_num, bool is_connected);
|
|
||||||
void start_pg_peering(int i);
|
|
||||||
|
|
||||||
// op execution
|
|
||||||
void exec_op(osd_op_t *cur_op);
|
|
||||||
|
|
||||||
// secondary ops
|
|
||||||
void exec_sync_stab_all(osd_op_t *cur_op);
|
|
||||||
void exec_show_config(osd_op_t *cur_op);
|
|
||||||
void exec_secondary(osd_op_t *cur_op);
|
|
||||||
void secondary_op_callback(osd_op_t *cur_op);
|
|
||||||
|
|
||||||
// primary ops
|
|
||||||
bool prepare_primary_rw(osd_op_t *cur_op);
|
|
||||||
void continue_primary_read(osd_op_t *cur_op);
|
|
||||||
void continue_primary_write(osd_op_t *cur_op);
|
|
||||||
void continue_primary_sync(osd_op_t *cur_op);
|
|
||||||
void finish_primary_op(osd_op_t *cur_op, int retval);
|
|
||||||
void handle_primary_subop(osd_op_t *cur_op, int ok, uint64_t version);
|
|
||||||
void submit_primary_subops(int submit_type, int read_pg_size, const uint64_t* osd_set, osd_op_t *cur_op);
|
|
||||||
void submit_primary_sync_subops(osd_op_t *cur_op);
|
|
||||||
void submit_primary_stab_subops(osd_op_t *cur_op);
|
|
||||||
public:
|
|
||||||
osd_t(blockstore_config_t & config, blockstore_t *bs, ring_loop_t *ringloop);
|
|
||||||
~osd_t();
|
|
||||||
bool shutdown();
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool operator == (const osd_object_id_t & a, const osd_object_id_t & b)
|
|
||||||
{
|
|
||||||
return a.osd_num == b.osd_num && a.oid.inode == b.oid.inode && a.oid.stripe == b.oid.stripe;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator < (const osd_object_id_t & a, const osd_object_id_t & b)
|
|
||||||
{
|
|
||||||
return a.osd_num < b.osd_num || a.osd_num == b.osd_num && (
|
|
||||||
a.oid.inode < b.oid.inode || a.oid.inode == b.oid.inode && a.oid.stripe < b.oid.stripe
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
void slice()
|
|
||||||
{
|
|
||||||
// Slice the request into blockstore requests to individual objects
|
|
||||||
// Primary OSD still operates individual stripes, except they're twice the size of the blockstore's stripe.
|
|
||||||
std::vector read_parts;
|
|
||||||
int block = bs->get_block_size();
|
|
||||||
uint64_t stripe1 = cur_op->req.rw.offset / block / 2;
|
|
||||||
uint64_t stripe2 = (cur_op->req.rw.offset + cur_op->req.rw.len + block*2 - 1) / block / 2 - 1;
|
|
||||||
for (uint64_t s = stripe1; s <= stripe2; s++)
|
|
||||||
{
|
|
||||||
uint64_t start = s == stripe1 ? cur_op->req.rw.offset - stripe1*block*2 : 0;
|
|
||||||
uint64_t end = s == stripe2 ? cur_op->req.rw.offset + cur_op->req.rw.len - stripe2*block*2 : block*2;
|
|
||||||
if (start < block)
|
|
||||||
{
|
|
||||||
read_parts.push_back({
|
|
||||||
.role = 1,
|
|
||||||
.oid = {
|
|
||||||
.inode = cur_op->req.rw.inode,
|
|
||||||
.stripe = (s << STRIPE_ROLE_BITS) | 1,
|
|
||||||
},
|
|
||||||
.version = UINT64_MAX,
|
|
||||||
.offset = start,
|
|
||||||
.len = (block < end ? block : end) - start,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (end > block)
|
|
||||||
{
|
|
||||||
read_parts.push_back({
|
|
||||||
.role = 2,
|
|
||||||
.oid = {
|
|
||||||
.inode = cur_op->req.rw.inode,
|
|
||||||
.stripe = (s << STRIPE_ROLE_BITS) | 2,
|
|
||||||
},
|
|
||||||
.version = UINT64_MAX,
|
|
||||||
.offset = (start > block ? start-block : 0),
|
|
||||||
.len = end - (start > block ? start-block : 0),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
4
osd_id.h
4
osd_id.h
|
@ -1,4 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
typedef uint64_t osd_num_t;
|
|
||||||
typedef uint32_t pg_num_t;
|
|
198
osd_ops.h
198
osd_ops.h
|
@ -1,198 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "object_id.h"
|
|
||||||
#include "osd_id.h"
|
|
||||||
|
|
||||||
// Magic numbers
|
|
||||||
#define SECONDARY_OSD_OP_MAGIC 0x2bd7b10325434553l
|
|
||||||
#define SECONDARY_OSD_REPLY_MAGIC 0xbaa699b87b434553l
|
|
||||||
// Operation request / reply headers have fixed size after which comes data
|
|
||||||
#define OSD_PACKET_SIZE 0x80
|
|
||||||
// Opcodes
|
|
||||||
#define OSD_OP_MIN 1
|
|
||||||
#define OSD_OP_SECONDARY_READ 1
|
|
||||||
#define OSD_OP_SECONDARY_WRITE 2
|
|
||||||
#define OSD_OP_SECONDARY_SYNC 3
|
|
||||||
#define OSD_OP_SECONDARY_STABILIZE 4
|
|
||||||
#define OSD_OP_SECONDARY_ROLLBACK 5
|
|
||||||
#define OSD_OP_SECONDARY_DELETE 6
|
|
||||||
#define OSD_OP_TEST_SYNC_STAB_ALL 7
|
|
||||||
#define OSD_OP_SECONDARY_LIST 8
|
|
||||||
#define OSD_OP_SHOW_CONFIG 9
|
|
||||||
#define OSD_OP_READ 10
|
|
||||||
#define OSD_OP_WRITE 11
|
|
||||||
#define OSD_OP_SYNC 12
|
|
||||||
#define OSD_OP_MAX 12
|
|
||||||
// Alignment & limit for read/write operations
|
|
||||||
#define OSD_RW_ALIGN 512
|
|
||||||
#define OSD_RW_MAX 64*1024*1024
|
|
||||||
|
|
||||||
// common request and reply headers
|
|
||||||
struct __attribute__((__packed__)) osd_op_header_t
|
|
||||||
{
|
|
||||||
// magic & protocol version
|
|
||||||
uint64_t magic;
|
|
||||||
// operation id
|
|
||||||
uint64_t id;
|
|
||||||
// operation type
|
|
||||||
uint64_t opcode;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_header_t
|
|
||||||
{
|
|
||||||
// magic & protocol version
|
|
||||||
uint64_t magic;
|
|
||||||
// operation id
|
|
||||||
uint64_t id;
|
|
||||||
// operation type
|
|
||||||
uint64_t opcode;
|
|
||||||
// return value
|
|
||||||
int64_t retval;
|
|
||||||
};
|
|
||||||
|
|
||||||
// read or write to the secondary OSD
|
|
||||||
struct __attribute__((__packed__)) osd_op_secondary_rw_t
|
|
||||||
{
|
|
||||||
osd_op_header_t header;
|
|
||||||
// object
|
|
||||||
object_id oid;
|
|
||||||
// read/write version (automatic or specific)
|
|
||||||
uint64_t version;
|
|
||||||
// offset
|
|
||||||
uint32_t offset;
|
|
||||||
// length
|
|
||||||
uint32_t len;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_secondary_rw_t
|
|
||||||
{
|
|
||||||
osd_reply_header_t header;
|
|
||||||
// for reads and writes: assigned or read version number
|
|
||||||
uint64_t version;
|
|
||||||
};
|
|
||||||
|
|
||||||
// delete object on the secondary OSD
|
|
||||||
struct __attribute__((__packed__)) osd_op_secondary_del_t
|
|
||||||
{
|
|
||||||
osd_op_header_t header;
|
|
||||||
// object
|
|
||||||
object_id oid;
|
|
||||||
// delete version (automatic or specific)
|
|
||||||
uint64_t version;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_secondary_del_t
|
|
||||||
{
|
|
||||||
osd_reply_header_t header;
|
|
||||||
uint64_t version;
|
|
||||||
};
|
|
||||||
|
|
||||||
// sync to the secondary OSD
|
|
||||||
struct __attribute__((__packed__)) osd_op_secondary_sync_t
|
|
||||||
{
|
|
||||||
osd_op_header_t header;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_secondary_sync_t
|
|
||||||
{
|
|
||||||
osd_reply_header_t header;
|
|
||||||
};
|
|
||||||
|
|
||||||
// stabilize or rollback objects on the secondary OSD
|
|
||||||
struct __attribute__((__packed__)) osd_op_secondary_stabilize_t
|
|
||||||
{
|
|
||||||
osd_op_header_t header;
|
|
||||||
// obj_ver_id array length in bytes
|
|
||||||
uint64_t len;
|
|
||||||
};
|
|
||||||
typedef osd_op_secondary_stabilize_t osd_op_secondary_rollback_t;
|
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_secondary_stabilize_t
|
|
||||||
{
|
|
||||||
osd_reply_header_t header;
|
|
||||||
};
|
|
||||||
typedef osd_reply_secondary_stabilize_t osd_reply_secondary_rollback_t;
|
|
||||||
|
|
||||||
// show configuration
|
|
||||||
struct __attribute__((__packed__)) osd_op_show_config_t
|
|
||||||
{
|
|
||||||
osd_op_header_t header;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_show_config_t
|
|
||||||
{
|
|
||||||
osd_reply_header_t header;
|
|
||||||
};
|
|
||||||
|
|
||||||
// list objects on replica
|
|
||||||
struct __attribute__((__packed__)) osd_op_secondary_list_t
|
|
||||||
{
|
|
||||||
osd_op_header_t header;
|
|
||||||
// placement group total number and total count
|
|
||||||
pg_num_t list_pg, pg_count;
|
|
||||||
uint64_t parity_block_size;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_secondary_list_t
|
|
||||||
{
|
|
||||||
osd_reply_header_t header;
|
|
||||||
// stable object version count. header.retval = total object version count
|
|
||||||
// FIXME: maybe change to the number of bytes in the reply...
|
|
||||||
uint64_t stable_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
// read or write to the primary OSD (must be within individual stripe)
|
|
||||||
struct __attribute__((__packed__)) osd_op_rw_t
|
|
||||||
{
|
|
||||||
osd_op_header_t header;
|
|
||||||
// inode
|
|
||||||
uint64_t inode;
|
|
||||||
// offset
|
|
||||||
uint64_t offset;
|
|
||||||
// length
|
|
||||||
uint32_t len;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_rw_t
|
|
||||||
{
|
|
||||||
osd_reply_header_t header;
|
|
||||||
};
|
|
||||||
|
|
||||||
// sync to the primary OSD
|
|
||||||
struct __attribute__((__packed__)) osd_op_sync_t
|
|
||||||
{
|
|
||||||
osd_op_header_t header;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_sync_t
|
|
||||||
{
|
|
||||||
osd_reply_header_t header;
|
|
||||||
};
|
|
||||||
|
|
||||||
union osd_any_op_t
|
|
||||||
{
|
|
||||||
osd_op_header_t hdr;
|
|
||||||
osd_op_secondary_rw_t sec_rw;
|
|
||||||
osd_op_secondary_del_t sec_del;
|
|
||||||
osd_op_secondary_sync_t sec_sync;
|
|
||||||
osd_op_secondary_stabilize_t sec_stab;
|
|
||||||
osd_op_secondary_list_t sec_list;
|
|
||||||
osd_op_show_config_t show_conf;
|
|
||||||
osd_op_rw_t rw;
|
|
||||||
osd_op_sync_t sync;
|
|
||||||
uint8_t buf[OSD_PACKET_SIZE];
|
|
||||||
};
|
|
||||||
|
|
||||||
union osd_any_reply_t
|
|
||||||
{
|
|
||||||
osd_reply_header_t hdr;
|
|
||||||
osd_reply_secondary_rw_t sec_rw;
|
|
||||||
osd_reply_secondary_del_t sec_del;
|
|
||||||
osd_reply_secondary_sync_t sec_sync;
|
|
||||||
osd_reply_secondary_stabilize_t sec_stab;
|
|
||||||
osd_reply_secondary_list_t sec_list;
|
|
||||||
osd_reply_show_config_t show_conf;
|
|
||||||
osd_reply_rw_t rw;
|
|
||||||
osd_reply_sync_t sync;
|
|
||||||
uint8_t buf[OSD_PACKET_SIZE];
|
|
||||||
};
|
|
407
osd_peering.cpp
407
osd_peering.cpp
|
@ -1,407 +0,0 @@
|
||||||
#include <netinet/tcp.h>
|
|
||||||
#include <sys/epoll.h>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "osd.h"
|
|
||||||
|
|
||||||
void osd_t::init_primary()
|
|
||||||
{
|
|
||||||
// Initial test version of clustering code requires exactly 2 peers
|
|
||||||
// FIXME Hardcode
|
|
||||||
std::string peerstr = config["peers"];
|
|
||||||
while (peerstr.size())
|
|
||||||
{
|
|
||||||
int pos = peerstr.find(',');
|
|
||||||
peers.push_back(parse_peer(pos < 0 ? peerstr : peerstr.substr(0, pos)));
|
|
||||||
peerstr = pos < 0 ? std::string("") : peerstr.substr(pos+1);
|
|
||||||
for (int i = 0; i < peers.size()-1; i++)
|
|
||||||
if (peers[i].osd_num == peers[peers.size()-1].osd_num)
|
|
||||||
throw std::runtime_error("same osd number "+std::to_string(peers[i].osd_num)+" specified twice in peers");
|
|
||||||
}
|
|
||||||
if (peers.size() < 2)
|
|
||||||
throw std::runtime_error("run_primary requires at least 2 peers");
|
|
||||||
pgs.push_back((pg_t){
|
|
||||||
.state = PG_OFFLINE,
|
|
||||||
.pg_cursize = 0,
|
|
||||||
.pg_num = 1,
|
|
||||||
.target_set = { 1, 2, 3 },
|
|
||||||
.cur_set = { 1, 0, 0 },
|
|
||||||
});
|
|
||||||
pg_count = 1;
|
|
||||||
peering_state = OSD_PEERING_PEERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
osd_peer_def_t osd_t::parse_peer(std::string peer)
|
|
||||||
{
|
|
||||||
// OSD_NUM:IP:PORT
|
|
||||||
int pos1 = peer.find(':');
|
|
||||||
int pos2 = peer.find(':', pos1+1);
|
|
||||||
if (pos1 < 0 || pos2 < 0)
|
|
||||||
throw new std::runtime_error("OSD peer string must be in the form OSD_NUM:IP:PORT");
|
|
||||||
osd_peer_def_t r;
|
|
||||||
r.addr = peer.substr(pos1+1, pos2-pos1-1);
|
|
||||||
std::string osd_num_str = peer.substr(0, pos1);
|
|
||||||
std::string port_str = peer.substr(pos2+1);
|
|
||||||
r.osd_num = strtoull(osd_num_str.c_str(), NULL, 10);
|
|
||||||
if (!r.osd_num)
|
|
||||||
throw new std::runtime_error("Could not parse OSD peer osd_num");
|
|
||||||
r.port = strtoull(port_str.c_str(), NULL, 10);
|
|
||||||
if (!r.port)
|
|
||||||
throw new std::runtime_error("Could not parse OSD peer port");
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::connect_peer(osd_num_t osd_num, const char *peer_host, int peer_port, std::function<void(osd_num_t, int)> callback)
|
|
||||||
{
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
int r;
|
|
||||||
if ((r = inet_pton(AF_INET, peer_host, &addr.sin_addr)) != 1)
|
|
||||||
{
|
|
||||||
callback(osd_num, -EINVAL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_port = htons(peer_port ? peer_port : 11203);
|
|
||||||
int peer_fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
||||||
if (peer_fd < 0)
|
|
||||||
{
|
|
||||||
callback(osd_num, -errno);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fcntl(peer_fd, F_SETFL, fcntl(peer_fd, F_GETFL, 0) | O_NONBLOCK);
|
|
||||||
r = connect(peer_fd, (sockaddr*)&addr, sizeof(addr));
|
|
||||||
if (r < 0 && errno != EINPROGRESS)
|
|
||||||
{
|
|
||||||
close(peer_fd);
|
|
||||||
callback(osd_num, -errno);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
clients[peer_fd] = (osd_client_t){
|
|
||||||
.peer_addr = addr,
|
|
||||||
.peer_port = peer_port,
|
|
||||||
.peer_fd = peer_fd,
|
|
||||||
.peer_state = PEER_CONNECTING,
|
|
||||||
.connect_callback = callback,
|
|
||||||
.osd_num = osd_num,
|
|
||||||
};
|
|
||||||
osd_peer_fds[osd_num] = peer_fd;
|
|
||||||
// Add FD to epoll (EPOLLOUT for tracking connect() result)
|
|
||||||
epoll_event ev;
|
|
||||||
ev.data.fd = peer_fd;
|
|
||||||
ev.events = EPOLLOUT | EPOLLRDHUP | EPOLLET;
|
|
||||||
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, peer_fd, &ev) < 0)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(std::string("epoll_ctl: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::handle_connect_result(int peer_fd)
|
|
||||||
{
|
|
||||||
auto & cl = clients[peer_fd];
|
|
||||||
osd_num_t osd_num = cl.osd_num;
|
|
||||||
auto callback = cl.connect_callback;
|
|
||||||
int result = 0;
|
|
||||||
socklen_t result_len = sizeof(result);
|
|
||||||
if (getsockopt(peer_fd, SOL_SOCKET, SO_ERROR, &result, &result_len) < 0)
|
|
||||||
{
|
|
||||||
result = errno;
|
|
||||||
}
|
|
||||||
if (result != 0)
|
|
||||||
{
|
|
||||||
stop_client(peer_fd);
|
|
||||||
callback(osd_num, -result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int one = 1;
|
|
||||||
setsockopt(peer_fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one));
|
|
||||||
fcntl(peer_fd, F_SETFL, fcntl(peer_fd, F_GETFL, 0) & ~O_NONBLOCK);
|
|
||||||
// Disable EPOLLOUT on this fd
|
|
||||||
cl.connect_callback = NULL;
|
|
||||||
cl.peer_state = PEER_CONNECTED;
|
|
||||||
epoll_event ev;
|
|
||||||
ev.data.fd = peer_fd;
|
|
||||||
ev.events = EPOLLRDHUP | EPOLLET;
|
|
||||||
if (epoll_ctl(epoll_fd, EPOLL_CTL_MOD, peer_fd, &ev) < 0)
|
|
||||||
{
|
|
||||||
throw std::runtime_error(std::string("epoll_ctl: ") + strerror(errno));
|
|
||||||
}
|
|
||||||
callback(osd_num, peer_fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Peering loop
|
|
||||||
void osd_t::handle_peers()
|
|
||||||
{
|
|
||||||
if (peering_state & OSD_PEERING_PEERS)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < peers.size(); i++)
|
|
||||||
{
|
|
||||||
if (osd_peer_fds.find(peers[i].osd_num) == osd_peer_fds.end() &&
|
|
||||||
time(NULL) - peers[i].last_connect_attempt > 5) // FIXME hardcode 5
|
|
||||||
{
|
|
||||||
peers[i].last_connect_attempt = time(NULL);
|
|
||||||
connect_peer(peers[i].osd_num, peers[i].addr.c_str(), peers[i].port, [this](osd_num_t osd_num, int peer_fd)
|
|
||||||
{
|
|
||||||
// FIXME: Check peer config after connecting
|
|
||||||
if (peer_fd < 0)
|
|
||||||
{
|
|
||||||
printf("Failed to connect to peer OSD %lu: %s\n", osd_num, strerror(-peer_fd));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf("Connected with peer OSD %lu (fd %d)\n", clients[peer_fd].osd_num, peer_fd);
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < peers.size(); i++)
|
|
||||||
{
|
|
||||||
if (osd_peer_fds.find(peers[i].osd_num) == osd_peer_fds.end())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i >= peers.size())
|
|
||||||
{
|
|
||||||
// Connected to all peers
|
|
||||||
peering_state = peering_state & ~OSD_PEERING_PEERS;
|
|
||||||
}
|
|
||||||
repeer_pgs(osd_num, true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (peering_state & OSD_PEERING_PGS)
|
|
||||||
{
|
|
||||||
bool still_doing_pgs = false;
|
|
||||||
for (int i = 0; i < pgs.size(); i++)
|
|
||||||
{
|
|
||||||
if (pgs[i].state == PG_PEERING)
|
|
||||||
{
|
|
||||||
if (!pgs[i].peering_state->list_ops.size())
|
|
||||||
{
|
|
||||||
pgs[i].calc_object_states();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
still_doing_pgs = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!still_doing_pgs)
|
|
||||||
{
|
|
||||||
// Done all PGs
|
|
||||||
peering_state = peering_state & ~OSD_PEERING_PGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::repeer_pgs(osd_num_t osd_num, bool is_connected)
|
|
||||||
{
|
|
||||||
// Re-peer affected PGs
|
|
||||||
// FIXME: We shouldn't rely just on target_set. Other OSDs may also contain PG data.
|
|
||||||
osd_num_t real_osd = (is_connected ? osd_num : 0);
|
|
||||||
for (int i = 0; i < pgs.size(); i++)
|
|
||||||
{
|
|
||||||
bool repeer = false;
|
|
||||||
for (int r = 0; r < pgs[i].target_set.size(); r++)
|
|
||||||
{
|
|
||||||
if (pgs[i].target_set[r] == osd_num &&
|
|
||||||
pgs[i].cur_set[r] != real_osd)
|
|
||||||
{
|
|
||||||
pgs[i].cur_set[r] = real_osd;
|
|
||||||
repeer = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (repeer)
|
|
||||||
{
|
|
||||||
// Repeer this pg
|
|
||||||
printf("Repeer PG %d because of OSD %lu\n", i, osd_num);
|
|
||||||
start_pg_peering(i);
|
|
||||||
peering_state |= OSD_PEERING_PGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Repeer on each connect/disconnect peer event
|
|
||||||
void osd_t::start_pg_peering(int pg_idx)
|
|
||||||
{
|
|
||||||
auto & pg = pgs[pg_idx];
|
|
||||||
pg.state = PG_PEERING;
|
|
||||||
pg.state_dict.clear();
|
|
||||||
pg.obj_states.clear();
|
|
||||||
pg.ver_override.clear();
|
|
||||||
pg.pg_cursize = 0;
|
|
||||||
for (int role = 0; role < pg.cur_set.size(); role++)
|
|
||||||
{
|
|
||||||
if (pg.cur_set[role] != 0)
|
|
||||||
{
|
|
||||||
pg.pg_cursize++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pg.pg_cursize < pg.pg_minsize)
|
|
||||||
{
|
|
||||||
pg.state = PG_INCOMPLETE;
|
|
||||||
}
|
|
||||||
if (pg.peering_state)
|
|
||||||
{
|
|
||||||
// Adjust the peering operation that's still in progress
|
|
||||||
for (auto it = pg.peering_state->list_ops.begin(); it != pg.peering_state->list_ops.end(); it++)
|
|
||||||
{
|
|
||||||
int role;
|
|
||||||
for (role = 0; role < pg.cur_set.size(); role++)
|
|
||||||
{
|
|
||||||
if (pg.cur_set[role] == it->first)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (pg.state == PG_INCOMPLETE || role >= pg.cur_set.size())
|
|
||||||
{
|
|
||||||
// Discard the result after completion, which, chances are, will be unsuccessful
|
|
||||||
auto list_op = it->second;
|
|
||||||
if (list_op->peer_fd == 0)
|
|
||||||
{
|
|
||||||
// Self
|
|
||||||
list_op->bs_op->callback = [list_op](blockstore_op_t *bs_op)
|
|
||||||
{
|
|
||||||
if (list_op->bs_op->buf)
|
|
||||||
free(list_op->bs_op->buf);
|
|
||||||
delete list_op;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Peer
|
|
||||||
list_op->callback = [](osd_op_t *list_op)
|
|
||||||
{
|
|
||||||
delete list_op;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
pg.peering_state->list_ops.erase(it);
|
|
||||||
it = pg.peering_state->list_ops.begin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto it = pg.peering_state->list_results.begin(); it != pg.peering_state->list_results.end(); it++)
|
|
||||||
{
|
|
||||||
int role;
|
|
||||||
for (role = 0; role < pg.cur_set.size(); role++)
|
|
||||||
{
|
|
||||||
if (pg.cur_set[role] == it->first)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (pg.state == PG_INCOMPLETE || role >= pg.cur_set.size())
|
|
||||||
{
|
|
||||||
if (it->second.buf)
|
|
||||||
{
|
|
||||||
free(it->second.buf);
|
|
||||||
}
|
|
||||||
pg.peering_state->list_results.erase(it);
|
|
||||||
it = pg.peering_state->list_results.begin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pg.state == PG_INCOMPLETE)
|
|
||||||
{
|
|
||||||
if (pg.peering_state)
|
|
||||||
{
|
|
||||||
delete pg.peering_state;
|
|
||||||
pg.peering_state = NULL;
|
|
||||||
}
|
|
||||||
printf("PG %d is incomplete\n", pg.pg_num);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!pg.peering_state)
|
|
||||||
{
|
|
||||||
pg.peering_state = new pg_peering_state_t();
|
|
||||||
}
|
|
||||||
auto ps = pg.peering_state;
|
|
||||||
for (int role = 0; role < pg.cur_set.size(); role++)
|
|
||||||
{
|
|
||||||
osd_num_t role_osd = pg.cur_set[role];
|
|
||||||
if (!role_osd)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (ps->list_ops.find(role_osd) != ps->list_ops.end() ||
|
|
||||||
ps->list_results.find(role_osd) != ps->list_results.end())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (role_osd == this->osd_num)
|
|
||||||
{
|
|
||||||
// Self
|
|
||||||
osd_op_t *op = new osd_op_t();
|
|
||||||
op->op_type = 0;
|
|
||||||
op->peer_fd = 0;
|
|
||||||
op->bs_op = new blockstore_op_t();
|
|
||||||
op->bs_op->opcode = BS_OP_LIST;
|
|
||||||
op->bs_op->oid.stripe = parity_block_size;
|
|
||||||
op->bs_op->len = pg_count,
|
|
||||||
op->bs_op->offset = pg.pg_num-1,
|
|
||||||
op->bs_op->callback = [ps, op, role_osd](blockstore_op_t *bs_op)
|
|
||||||
{
|
|
||||||
if (op->bs_op->retval < 0)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("local OP_LIST failed");
|
|
||||||
}
|
|
||||||
printf(
|
|
||||||
"Got object list from OSD %lu (local): %d object versions (%lu of them stable)\n",
|
|
||||||
role_osd, bs_op->retval, bs_op->version
|
|
||||||
);
|
|
||||||
ps->list_results[role_osd] = {
|
|
||||||
.buf = (obj_ver_id*)op->bs_op->buf,
|
|
||||||
.total_count = (uint64_t)op->bs_op->retval,
|
|
||||||
.stable_count = op->bs_op->version,
|
|
||||||
};
|
|
||||||
ps->list_done++;
|
|
||||||
ps->list_ops.erase(role_osd);
|
|
||||||
delete op;
|
|
||||||
};
|
|
||||||
bs->enqueue_op(op->bs_op);
|
|
||||||
ps->list_ops[role_osd] = op;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Peer
|
|
||||||
auto & cl = clients[osd_peer_fds[role_osd]];
|
|
||||||
osd_op_t *op = new osd_op_t();
|
|
||||||
op->op_type = OSD_OP_OUT;
|
|
||||||
op->send_list.push_back(op->req.buf, OSD_PACKET_SIZE);
|
|
||||||
op->peer_fd = cl.peer_fd;
|
|
||||||
op->req = {
|
|
||||||
.sec_list = {
|
|
||||||
.header = {
|
|
||||||
.magic = SECONDARY_OSD_OP_MAGIC,
|
|
||||||
.id = this->next_subop_id++,
|
|
||||||
.opcode = OSD_OP_SECONDARY_LIST,
|
|
||||||
},
|
|
||||||
.list_pg = pg.pg_num,
|
|
||||||
.pg_count = pg_count,
|
|
||||||
.parity_block_size = parity_block_size,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
op->callback = [this, ps, role_osd](osd_op_t *op)
|
|
||||||
{
|
|
||||||
if (op->reply.hdr.retval < 0)
|
|
||||||
{
|
|
||||||
printf("Failed to get object list from OSD %lu (retval=%ld), disconnecting peer\n", role_osd, op->reply.hdr.retval);
|
|
||||||
ps->list_ops.erase(role_osd);
|
|
||||||
stop_client(op->peer_fd);
|
|
||||||
delete op;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf(
|
|
||||||
"Got object list from OSD %lu: %ld object versions (%lu of them stable)\n",
|
|
||||||
role_osd, op->reply.hdr.retval, op->reply.sec_list.stable_count
|
|
||||||
);
|
|
||||||
ps->list_results[role_osd] = {
|
|
||||||
.buf = (obj_ver_id*)op->buf,
|
|
||||||
.total_count = (uint64_t)op->reply.hdr.retval,
|
|
||||||
.stable_count = op->reply.sec_list.stable_count,
|
|
||||||
};
|
|
||||||
// set op->buf to NULL so it doesn't get freed
|
|
||||||
op->buf = NULL;
|
|
||||||
ps->list_done++;
|
|
||||||
ps->list_ops.erase(role_osd);
|
|
||||||
delete op;
|
|
||||||
};
|
|
||||||
outbox_push(cl, op);
|
|
||||||
ps->list_ops[role_osd] = op;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ringloop->wakeup();
|
|
||||||
}
|
|
|
@ -1,265 +0,0 @@
|
||||||
#include "osd_peering_pg.h"
|
|
||||||
|
|
||||||
void pg_t::remember_object(pg_obj_state_check_t &st, std::vector<obj_ver_role> &all)
|
|
||||||
{
|
|
||||||
auto & pg = *this;
|
|
||||||
// Remember the decision
|
|
||||||
uint64_t state = 0;
|
|
||||||
if (st.n_roles == pg.pg_cursize)
|
|
||||||
{
|
|
||||||
if (st.n_matched == pg.pg_cursize)
|
|
||||||
state = OBJ_CLEAN;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
state = OBJ_MISPLACED;
|
|
||||||
pg.state = pg.state | PG_HAS_MISPLACED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (st.n_roles < pg.pg_minsize)
|
|
||||||
{
|
|
||||||
printf("Object is unfound: inode=%lu stripe=%lu version=%lu/%lu\n", st.oid.inode, st.oid.stripe, st.target_ver, st.max_ver);
|
|
||||||
state = OBJ_INCOMPLETE;
|
|
||||||
pg.state = pg.state | PG_HAS_UNFOUND;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Object is degraded: inode=%lu stripe=%lu version=%lu/%lu\n", st.oid.inode, st.oid.stripe, st.target_ver, st.max_ver);
|
|
||||||
state = OBJ_DEGRADED;
|
|
||||||
pg.state = pg.state | PG_HAS_DEGRADED;
|
|
||||||
}
|
|
||||||
if (st.n_copies > pg.pg_size)
|
|
||||||
{
|
|
||||||
state |= OBJ_OVERCOPIED;
|
|
||||||
pg.state = pg.state | PG_HAS_UNCLEAN;
|
|
||||||
}
|
|
||||||
if (st.n_stable < st.n_copies)
|
|
||||||
{
|
|
||||||
state |= OBJ_NEEDS_STABLE;
|
|
||||||
pg.state = pg.state | PG_HAS_UNCLEAN;
|
|
||||||
}
|
|
||||||
if (st.target_ver < st.max_ver || st.has_old_unstable)
|
|
||||||
{
|
|
||||||
state |= OBJ_NEEDS_ROLLBACK;
|
|
||||||
pg.state = pg.state | PG_HAS_UNCLEAN;
|
|
||||||
pg.ver_override[st.oid] = st.target_ver;
|
|
||||||
}
|
|
||||||
if (st.is_buggy)
|
|
||||||
{
|
|
||||||
state |= OBJ_BUGGY;
|
|
||||||
// FIXME: bring pg offline
|
|
||||||
throw std::runtime_error("buggy object state");
|
|
||||||
}
|
|
||||||
if (state != OBJ_CLEAN)
|
|
||||||
{
|
|
||||||
st.osd_set.clear();
|
|
||||||
for (int i = st.ver_start; i < st.ver_end; i++)
|
|
||||||
{
|
|
||||||
st.osd_set.push_back((pg_obj_loc_t){
|
|
||||||
.role = (all[i].oid.stripe & STRIPE_MASK),
|
|
||||||
.osd_num = all[i].osd_num,
|
|
||||||
.stable = all[i].is_stable,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
std::sort(st.osd_set.begin(), st.osd_set.end());
|
|
||||||
auto it = pg.state_dict.find(st.osd_set);
|
|
||||||
if (it == pg.state_dict.end())
|
|
||||||
{
|
|
||||||
std::vector<uint64_t> read_target;
|
|
||||||
read_target.resize(pg.pg_size);
|
|
||||||
for (int i = 0; i < pg.pg_size; i++)
|
|
||||||
{
|
|
||||||
read_target[i] = 0;
|
|
||||||
}
|
|
||||||
for (auto & o: st.osd_set)
|
|
||||||
{
|
|
||||||
read_target[o.role] = o.osd_num;
|
|
||||||
}
|
|
||||||
pg.state_dict[st.osd_set] = {
|
|
||||||
.read_target = read_target,
|
|
||||||
.osd_set = st.osd_set,
|
|
||||||
.state = state,
|
|
||||||
.object_count = 1,
|
|
||||||
};
|
|
||||||
it = pg.state_dict.find(st.osd_set);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
it->second.object_count++;
|
|
||||||
}
|
|
||||||
pg.obj_states[st.oid] = &it->second;
|
|
||||||
if (st.target_ver < st.max_ver)
|
|
||||||
{
|
|
||||||
pg.ver_override[st.oid] = st.target_ver;
|
|
||||||
}
|
|
||||||
if (state & (OBJ_NEEDS_ROLLBACK | OBJ_NEEDS_STABLE))
|
|
||||||
{
|
|
||||||
spp::sparse_hash_map<obj_piece_id_t, obj_piece_ver_t> pieces;
|
|
||||||
for (int i = st.obj_start; i < st.obj_end; i++)
|
|
||||||
{
|
|
||||||
auto & pcs = pieces[(obj_piece_id_t){ .oid = all[i].oid, .osd_num = all[i].osd_num }];
|
|
||||||
if (!pcs.max_ver)
|
|
||||||
{
|
|
||||||
pcs.max_ver = all[i].version;
|
|
||||||
}
|
|
||||||
if (all[i].is_stable && !pcs.stable_ver)
|
|
||||||
{
|
|
||||||
pcs.stable_ver = all[i].version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto pp: pieces)
|
|
||||||
{
|
|
||||||
auto & pcs = pp.second;
|
|
||||||
if (pcs.stable_ver < pcs.max_ver)
|
|
||||||
{
|
|
||||||
auto & act = obj_stab_actions[pp.first];
|
|
||||||
if (pcs.max_ver > st.target_ver)
|
|
||||||
{
|
|
||||||
act.rollback = true;
|
|
||||||
act.rollback_to = st.target_ver;
|
|
||||||
}
|
|
||||||
else if (pcs.max_ver < st.target_ver && pcs.stable_ver < pcs.max_ver)
|
|
||||||
{
|
|
||||||
act.rollback = true;
|
|
||||||
act.rollback_to = pcs.stable_ver;
|
|
||||||
}
|
|
||||||
if (pcs.max_ver >= st.target_ver && pcs.stable_ver < st.target_ver)
|
|
||||||
{
|
|
||||||
act.make_stable = true;
|
|
||||||
act.stable_to = st.target_ver;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pg.clean_count++;
|
|
||||||
pg.total_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Write at least some tests for this function
|
|
||||||
void pg_t::calc_object_states()
|
|
||||||
{
|
|
||||||
auto & pg = *this;
|
|
||||||
// Copy all object lists into one array
|
|
||||||
std::vector<obj_ver_role> all;
|
|
||||||
auto ps = pg.peering_state;
|
|
||||||
for (auto it: ps->list_results)
|
|
||||||
{
|
|
||||||
auto nstab = it.second.stable_count;
|
|
||||||
auto n = it.second.total_count;
|
|
||||||
auto osd_num = it.first;
|
|
||||||
uint64_t start = all.size();
|
|
||||||
all.resize(start + n);
|
|
||||||
obj_ver_id *ov = it.second.buf;
|
|
||||||
for (uint64_t i = 0; i < n; i++, ov++)
|
|
||||||
{
|
|
||||||
all[start+i] = {
|
|
||||||
.oid = ov->oid,
|
|
||||||
.version = ov->version,
|
|
||||||
.osd_num = osd_num,
|
|
||||||
.is_stable = i < nstab,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
free(it.second.buf);
|
|
||||||
it.second.buf = NULL;
|
|
||||||
}
|
|
||||||
ps->list_results.clear();
|
|
||||||
// Sort
|
|
||||||
std::sort(all.begin(), all.end());
|
|
||||||
// Walk over it and check object states
|
|
||||||
pg.clean_count = 0;
|
|
||||||
pg.total_count = 0;
|
|
||||||
pg.state = 0;
|
|
||||||
int replica = 0;
|
|
||||||
pg_obj_state_check_t st;
|
|
||||||
for (int i = 0; i < all.size(); i++)
|
|
||||||
{
|
|
||||||
if (st.oid.inode != all[i].oid.inode ||
|
|
||||||
st.oid.stripe != (all[i].oid.stripe & ~STRIPE_MASK))
|
|
||||||
{
|
|
||||||
if (st.oid.inode != 0)
|
|
||||||
{
|
|
||||||
// Remember object state
|
|
||||||
st.obj_end = st.ver_end = i;
|
|
||||||
remember_object(st, all);
|
|
||||||
}
|
|
||||||
st.obj_start = st.ver_start = i;
|
|
||||||
st.oid = { .inode = all[i].oid.inode, .stripe = all[i].oid.stripe & ~STRIPE_MASK };
|
|
||||||
st.max_ver = st.target_ver = all[i].version;
|
|
||||||
st.has_roles = st.n_copies = st.n_roles = st.n_stable = st.n_matched = 0;
|
|
||||||
st.is_buggy = st.has_old_unstable = false;
|
|
||||||
}
|
|
||||||
else if (st.target_ver != all[i].version)
|
|
||||||
{
|
|
||||||
if (st.n_stable > 0 || st.n_roles >= pg.pg_minsize)
|
|
||||||
{
|
|
||||||
// Last processed version is either recoverable or stable, choose it as target and skip previous versions
|
|
||||||
st.ver_end = i;
|
|
||||||
i++;
|
|
||||||
while (i < all.size() && st.oid.inode == all[i].oid.inode &&
|
|
||||||
st.oid.stripe == (all[i].oid.stripe & ~STRIPE_MASK))
|
|
||||||
{
|
|
||||||
if (!all[i].is_stable)
|
|
||||||
{
|
|
||||||
st.has_old_unstable = true;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
st.obj_end = i;
|
|
||||||
i--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Last processed version is unstable and unrecoverable
|
|
||||||
// We'll know that because target_ver < max_ver
|
|
||||||
st.ver_start = i;
|
|
||||||
st.target_ver = all[i].version;
|
|
||||||
st.has_roles = st.n_copies = st.n_roles = st.n_stable = st.n_matched = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
replica = (all[i].oid.stripe & STRIPE_MASK);
|
|
||||||
st.n_copies++;
|
|
||||||
if (replica >= pg.pg_size)
|
|
||||||
{
|
|
||||||
// FIXME In the future, check it against the PG epoch number to handle replication factor/scheme changes
|
|
||||||
st.is_buggy = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (all[i].is_stable)
|
|
||||||
{
|
|
||||||
st.n_stable++;
|
|
||||||
}
|
|
||||||
if (pg.cur_set[replica] == all[i].osd_num)
|
|
||||||
{
|
|
||||||
st.n_matched++;
|
|
||||||
}
|
|
||||||
if (!(st.has_roles & (1 << replica)))
|
|
||||||
{
|
|
||||||
st.has_roles = st.has_roles | (1 << replica);
|
|
||||||
st.n_roles++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (st.oid.inode != 0)
|
|
||||||
{
|
|
||||||
// Remember object state
|
|
||||||
st.obj_end = st.ver_end = all.size();
|
|
||||||
remember_object(st, all);
|
|
||||||
}
|
|
||||||
if (pg.pg_cursize < pg.pg_size)
|
|
||||||
{
|
|
||||||
pg.state = pg.state | PG_DEGRADED;
|
|
||||||
}
|
|
||||||
printf(
|
|
||||||
"PG %u is active%s%s%s%s%s (%lu objects)\n", pg.pg_num,
|
|
||||||
(pg.state & PG_DEGRADED) ? " + degraded" : "",
|
|
||||||
(pg.state & PG_HAS_UNFOUND) ? " + has_unfound" : "",
|
|
||||||
(pg.state & PG_HAS_DEGRADED) ? " + has_degraded" : "",
|
|
||||||
(pg.state & PG_HAS_MISPLACED) ? " + has_misplaced" : "",
|
|
||||||
(pg.state & PG_HAS_UNCLEAN) ? " + has_unclean" : "",
|
|
||||||
pg.total_count
|
|
||||||
);
|
|
||||||
pg.state = pg.state | PG_ACTIVE;
|
|
||||||
}
|
|
603
osd_primary.cpp
603
osd_primary.cpp
|
@ -1,603 +0,0 @@
|
||||||
#include "osd.h"
|
|
||||||
#include "osd_rmw.h"
|
|
||||||
|
|
||||||
#define SUBMIT_READ 0
|
|
||||||
#define SUBMIT_RMW_READ 1
|
|
||||||
#define SUBMIT_WRITE 2
|
|
||||||
|
|
||||||
// read: read directly or read paired stripe(s), reconstruct, return
|
|
||||||
// write: read paired stripe(s), modify, write
|
|
||||||
//
|
|
||||||
// nuance: take care to read the same version from paired stripes!
|
|
||||||
// to do so, we remember "last readable" version until a write request completes
|
|
||||||
// and we postpone other write requests to the same stripe until completion of previous ones
|
|
||||||
//
|
|
||||||
// sync: sync peers, get unstable versions from somewhere, stabilize them
|
|
||||||
|
|
||||||
struct unstable_osd_num_t
|
|
||||||
{
|
|
||||||
osd_num_t osd_num;
|
|
||||||
int start, len;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct osd_primary_op_data_t
|
|
||||||
{
|
|
||||||
int st = 0;
|
|
||||||
pg_num_t pg_num;
|
|
||||||
object_id oid;
|
|
||||||
uint64_t target_ver;
|
|
||||||
uint64_t fact_ver = 0;
|
|
||||||
int n_subops = 0, done = 0, errors = 0;
|
|
||||||
int degraded = 0, pg_size, pg_minsize;
|
|
||||||
osd_rmw_stripe_t *stripes;
|
|
||||||
osd_op_t *subops = NULL;
|
|
||||||
// for sync. oops, requires freeing
|
|
||||||
std::vector<unstable_osd_num_t> *unstable_write_osds = NULL;
|
|
||||||
obj_ver_id *unstable_writes = NULL;
|
|
||||||
};
|
|
||||||
|
|
||||||
void osd_t::finish_primary_op(osd_op_t *cur_op, int retval)
|
|
||||||
{
|
|
||||||
// FIXME add separate magic number
|
|
||||||
auto cl_it = clients.find(cur_op->peer_fd);
|
|
||||||
if (cl_it != clients.end())
|
|
||||||
{
|
|
||||||
cur_op->reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC;
|
|
||||||
cur_op->reply.hdr.id = cur_op->req.hdr.id;
|
|
||||||
cur_op->reply.hdr.opcode = cur_op->req.hdr.opcode;
|
|
||||||
cur_op->reply.hdr.retval = retval;
|
|
||||||
outbox_push(cl_it->second, cur_op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete cur_op;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
// PG number is calculated from the offset
|
|
||||||
// Our EC scheme stores data in fixed chunks equal to (K*block size)
|
|
||||||
// But we must not use K in the process of calculating the PG number
|
|
||||||
// So we calculate the PG number using a separate setting which should be per-inode (FIXME)
|
|
||||||
// FIXME Real pg_num should equal the below expression + 1
|
|
||||||
pg_num_t pg_num = (cur_op->req.rw.inode + cur_op->req.rw.offset / parity_block_size) % pg_count;
|
|
||||||
// FIXME: Postpone operations in inactive PGs
|
|
||||||
if (pg_num > pgs.size() || !(pgs[pg_num].state & PG_ACTIVE))
|
|
||||||
{
|
|
||||||
finish_primary_op(cur_op, -EINVAL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
uint64_t pg_parity_size = bs_block_size * pgs[pg_num].pg_minsize;
|
|
||||||
object_id oid = {
|
|
||||||
.inode = cur_op->req.rw.inode,
|
|
||||||
// oid.stripe = starting offset of the parity stripe, so it can be mapped back to the PG
|
|
||||||
.stripe = (cur_op->req.rw.offset / parity_block_size) * parity_block_size +
|
|
||||||
((cur_op->req.rw.offset % parity_block_size) / pg_parity_size) * pg_parity_size
|
|
||||||
};
|
|
||||||
if ((cur_op->req.rw.offset + cur_op->req.rw.len) > (oid.stripe + pg_parity_size) ||
|
|
||||||
(cur_op->req.rw.offset % bs_disk_alignment) != 0 ||
|
|
||||||
(cur_op->req.rw.len % bs_disk_alignment) != 0)
|
|
||||||
{
|
|
||||||
finish_primary_op(cur_op, -EINVAL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
osd_primary_op_data_t *op_data = (osd_primary_op_data_t*)calloc(
|
|
||||||
sizeof(osd_primary_op_data_t) + sizeof(osd_rmw_stripe_t) * pgs[pg_num].pg_size, 1
|
|
||||||
);
|
|
||||||
op_data->pg_num = pg_num;
|
|
||||||
op_data->oid = oid;
|
|
||||||
op_data->stripes = ((osd_rmw_stripe_t*)(op_data+1));
|
|
||||||
cur_op->op_data = op_data;
|
|
||||||
split_stripes(pgs[pg_num].pg_minsize, bs_block_size, (uint32_t)(cur_op->req.rw.offset - oid.stripe), cur_op->req.rw.len, op_data->stripes);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::continue_primary_read(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
if (!cur_op->op_data && !prepare_primary_rw(cur_op))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
|
||||||
if (op_data->st == 1) goto resume_1;
|
|
||||||
else if (op_data->st == 2) goto resume_2;
|
|
||||||
{
|
|
||||||
auto & pg = pgs[op_data->pg_num];
|
|
||||||
for (int role = 0; role < pg.pg_minsize; role++)
|
|
||||||
{
|
|
||||||
op_data->stripes[role].read_start = op_data->stripes[role].req_start;
|
|
||||||
op_data->stripes[role].read_end = op_data->stripes[role].req_end;
|
|
||||||
}
|
|
||||||
// Determine version
|
|
||||||
auto vo_it = pg.ver_override.find(op_data->oid);
|
|
||||||
op_data->target_ver = vo_it != pg.ver_override.end() ? vo_it->second : UINT64_MAX;
|
|
||||||
if (pg.state == PG_ACTIVE)
|
|
||||||
{
|
|
||||||
// Fast happy-path
|
|
||||||
cur_op->buf = alloc_read_buffer(op_data->stripes, pg.pg_minsize, 0);
|
|
||||||
submit_primary_subops(SUBMIT_READ, pg.pg_minsize, pg.cur_set.data(), cur_op);
|
|
||||||
cur_op->send_list.push_back(cur_op->buf, cur_op->req.rw.len);
|
|
||||||
op_data->st = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// PG may be degraded or have misplaced objects
|
|
||||||
auto st_it = pg.obj_states.find(op_data->oid);
|
|
||||||
uint64_t* cur_set = (st_it != pg.obj_states.end()
|
|
||||||
? st_it->second->read_target.data()
|
|
||||||
: pg.cur_set.data());
|
|
||||||
if (extend_missing_stripes(op_data->stripes, cur_set, pg.pg_minsize, pg.pg_size) < 0)
|
|
||||||
{
|
|
||||||
free(op_data);
|
|
||||||
finish_primary_op(cur_op, -EIO);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Submit reads
|
|
||||||
op_data->pg_minsize = pg.pg_minsize;
|
|
||||||
op_data->pg_size = pg.pg_size;
|
|
||||||
op_data->degraded = 1;
|
|
||||||
cur_op->buf = alloc_read_buffer(op_data->stripes, pg.pg_size, 0);
|
|
||||||
submit_primary_subops(SUBMIT_READ, pg.pg_size, cur_set, cur_op);
|
|
||||||
op_data->st = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resume_1:
|
|
||||||
return;
|
|
||||||
resume_2:
|
|
||||||
if (op_data->errors > 0)
|
|
||||||
{
|
|
||||||
free(op_data);
|
|
||||||
cur_op->op_data = NULL;
|
|
||||||
finish_primary_op(cur_op, -EIO);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (op_data->degraded)
|
|
||||||
{
|
|
||||||
// Reconstruct missing stripes
|
|
||||||
// FIXME: Always EC(k+1) by now. Add different coding schemes
|
|
||||||
osd_rmw_stripe_t *stripes = op_data->stripes;
|
|
||||||
for (int role = 0; role < op_data->pg_minsize; role++)
|
|
||||||
{
|
|
||||||
if (stripes[role].read_end != 0 && stripes[role].missing)
|
|
||||||
{
|
|
||||||
reconstruct_stripe(stripes, op_data->pg_size, role);
|
|
||||||
}
|
|
||||||
if (stripes[role].req_end != 0)
|
|
||||||
{
|
|
||||||
// Send buffer in parts to avoid copying
|
|
||||||
cur_op->send_list.push_back(
|
|
||||||
stripes[role].read_buf + (stripes[role].req_start - stripes[role].read_start),
|
|
||||||
stripes[role].req_end - stripes[role].req_start
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(op_data);
|
|
||||||
cur_op->op_data = NULL;
|
|
||||||
finish_primary_op(cur_op, cur_op->req.rw.len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::submit_primary_subops(int submit_type, int pg_size, const uint64_t* osd_set, osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
bool w = submit_type == SUBMIT_WRITE;
|
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
|
||||||
osd_rmw_stripe_t *stripes = op_data->stripes;
|
|
||||||
// Allocate subops
|
|
||||||
int n_subops = 0, zero_read = -1;
|
|
||||||
for (int role = 0; role < pg_size; role++)
|
|
||||||
{
|
|
||||||
if (osd_set[role] == this->osd_num || osd_set[role] != 0 && zero_read == -1)
|
|
||||||
{
|
|
||||||
zero_read = role;
|
|
||||||
}
|
|
||||||
if (osd_set[role] != 0 && (w || stripes[role].read_end != 0))
|
|
||||||
{
|
|
||||||
n_subops++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!n_subops && submit_type == SUBMIT_RMW_READ)
|
|
||||||
{
|
|
||||||
n_subops = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
zero_read = -1;
|
|
||||||
}
|
|
||||||
osd_op_t *subops = new osd_op_t[n_subops];
|
|
||||||
op_data->done = op_data->errors = 0;
|
|
||||||
op_data->n_subops = n_subops;
|
|
||||||
op_data->subops = subops;
|
|
||||||
int subop = 0;
|
|
||||||
for (int role = 0; role < pg_size; role++)
|
|
||||||
{
|
|
||||||
// We always submit zero-length writes to all replicas, even if the stripe is not modified
|
|
||||||
if (!(w || stripes[role].read_end != 0 || zero_read == role))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
osd_num_t role_osd_num = osd_set[role];
|
|
||||||
if (role_osd_num != 0)
|
|
||||||
{
|
|
||||||
if (role_osd_num == this->osd_num)
|
|
||||||
{
|
|
||||||
subops[subop].bs_op = new blockstore_op_t({
|
|
||||||
.opcode = (uint64_t)(w ? BS_OP_WRITE : BS_OP_READ),
|
|
||||||
.callback = [cur_op, this](blockstore_op_t *subop)
|
|
||||||
{
|
|
||||||
handle_primary_subop(cur_op, subop->retval == subop->len, subop->version);
|
|
||||||
},
|
|
||||||
.oid = {
|
|
||||||
.inode = op_data->oid.inode,
|
|
||||||
.stripe = op_data->oid.stripe | role,
|
|
||||||
},
|
|
||||||
.version = w ? 0 : (submit_type == SUBMIT_RMW_READ ? UINT64_MAX : op_data->target_ver),
|
|
||||||
.offset = w ? stripes[role].write_start : stripes[role].read_start,
|
|
||||||
.len = w ? stripes[role].write_end - stripes[role].write_start : stripes[role].read_end - stripes[role].read_start,
|
|
||||||
.buf = w ? stripes[role].write_buf : stripes[role].read_buf,
|
|
||||||
});
|
|
||||||
bs->enqueue_op(subops[subop].bs_op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
subops[subop].op_type = OSD_OP_OUT;
|
|
||||||
subops[subop].send_list.push_back(subops[subop].req.buf, OSD_PACKET_SIZE);
|
|
||||||
subops[subop].peer_fd = this->osd_peer_fds.at(role_osd_num);
|
|
||||||
subops[subop].req.sec_rw = {
|
|
||||||
.header = {
|
|
||||||
.magic = SECONDARY_OSD_OP_MAGIC,
|
|
||||||
.id = this->next_subop_id++,
|
|
||||||
.opcode = (uint64_t)(w ? OSD_OP_SECONDARY_WRITE : OSD_OP_SECONDARY_READ),
|
|
||||||
},
|
|
||||||
.oid = {
|
|
||||||
.inode = op_data->oid.inode,
|
|
||||||
.stripe = op_data->oid.stripe | role,
|
|
||||||
},
|
|
||||||
.version = w ? 0 : (submit_type == SUBMIT_RMW_READ ? UINT64_MAX : op_data->target_ver),
|
|
||||||
.offset = w ? stripes[role].write_start : stripes[role].read_start,
|
|
||||||
.len = w ? stripes[role].write_end - stripes[role].write_start : stripes[role].read_end - stripes[role].read_start,
|
|
||||||
};
|
|
||||||
subops[subop].buf = w ? stripes[role].write_buf : stripes[role].read_buf;
|
|
||||||
if (w && stripes[role].write_end > 0)
|
|
||||||
{
|
|
||||||
subops[subop].send_list.push_back(stripes[role].write_buf, stripes[role].write_end - stripes[role].write_start);
|
|
||||||
}
|
|
||||||
subops[subop].callback = [cur_op, this](osd_op_t *subop)
|
|
||||||
{
|
|
||||||
// so it doesn't get freed
|
|
||||||
subop->buf = NULL;
|
|
||||||
handle_primary_subop(cur_op, subop->reply.hdr.retval == subop->req.sec_rw.len, subop->reply.sec_rw.version);
|
|
||||||
};
|
|
||||||
outbox_push(clients[subops[subop].peer_fd], &subops[subop]);
|
|
||||||
}
|
|
||||||
subop++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::handle_primary_subop(osd_op_t *cur_op, int ok, uint64_t version)
|
|
||||||
{
|
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
|
||||||
op_data->fact_ver = version;
|
|
||||||
if (!ok)
|
|
||||||
{
|
|
||||||
// FIXME: Handle errors
|
|
||||||
op_data->errors++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
op_data->done++;
|
|
||||||
}
|
|
||||||
if ((op_data->errors + op_data->done) >= op_data->n_subops)
|
|
||||||
{
|
|
||||||
delete[] op_data->subops;
|
|
||||||
op_data->subops = NULL;
|
|
||||||
op_data->st++;
|
|
||||||
if (cur_op->req.hdr.opcode == OSD_OP_READ)
|
|
||||||
{
|
|
||||||
continue_primary_read(cur_op);
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_WRITE)
|
|
||||||
{
|
|
||||||
continue_primary_write(cur_op);
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SYNC)
|
|
||||||
{
|
|
||||||
continue_primary_sync(cur_op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::runtime_error("BUG: unknown opcode");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::continue_primary_write(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
if (!cur_op->op_data && !prepare_primary_rw(cur_op))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
|
||||||
// FIXME: Handle operation cancel
|
|
||||||
auto & pg = pgs[op_data->pg_num];
|
|
||||||
if (op_data->st == 1) goto resume_1;
|
|
||||||
else if (op_data->st == 2) goto resume_2;
|
|
||||||
else if (op_data->st == 3) goto resume_3;
|
|
||||||
else if (op_data->st == 4) goto resume_4;
|
|
||||||
else if (op_data->st == 5) goto resume_5;
|
|
||||||
assert(op_data->st == 0);
|
|
||||||
// Check if actions are pending for this object
|
|
||||||
{
|
|
||||||
auto act_it = pg.obj_stab_actions.lower_bound((obj_piece_id_t){
|
|
||||||
.oid = op_data->oid,
|
|
||||||
.osd_num = 0,
|
|
||||||
});
|
|
||||||
if (act_it != pg.obj_stab_actions.end() &&
|
|
||||||
act_it->first.oid.inode == op_data->oid.inode &&
|
|
||||||
(act_it->first.oid.stripe & ~STRIPE_MASK) == op_data->oid.stripe)
|
|
||||||
{
|
|
||||||
// FIXME postpone the request until actions are done
|
|
||||||
free(op_data);
|
|
||||||
finish_primary_op(cur_op, -EIO);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check if there are other write requests to the same object
|
|
||||||
{
|
|
||||||
auto vo_it = pg.write_queue.find(op_data->oid);
|
|
||||||
if (vo_it != pg.write_queue.end())
|
|
||||||
{
|
|
||||||
op_data->st = 1;
|
|
||||||
pg.write_queue.emplace(op_data->oid, cur_op);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pg.write_queue.emplace(op_data->oid, cur_op);
|
|
||||||
}
|
|
||||||
resume_1:
|
|
||||||
// Determine blocks to read
|
|
||||||
cur_op->rmw_buf = calc_rmw_reads(cur_op->buf, op_data->stripes, pg.cur_set.data(), pg.pg_size, pg.pg_minsize, pg.pg_cursize);
|
|
||||||
// Read required blocks
|
|
||||||
submit_primary_subops(SUBMIT_RMW_READ, pg.pg_size, pg.cur_set.data(), cur_op);
|
|
||||||
resume_2:
|
|
||||||
op_data->st = 2;
|
|
||||||
return;
|
|
||||||
resume_3:
|
|
||||||
// Save version override for parallel reads
|
|
||||||
pg.ver_override[op_data->oid] = op_data->fact_ver;
|
|
||||||
// Calculate parity
|
|
||||||
calc_rmw_parity(op_data->stripes, pg.pg_size);
|
|
||||||
// Send writes
|
|
||||||
submit_primary_subops(SUBMIT_WRITE, pg.pg_size, pg.cur_set.data(), cur_op);
|
|
||||||
resume_4:
|
|
||||||
op_data->st = 4;
|
|
||||||
return;
|
|
||||||
resume_5:
|
|
||||||
// Remember version as unstable
|
|
||||||
osd_num_t *osd_set = pg.cur_set.data();
|
|
||||||
for (int role = 0; role < pg.pg_size; role++)
|
|
||||||
{
|
|
||||||
if (osd_set[role] != 0)
|
|
||||||
{
|
|
||||||
this->unstable_writes[(osd_object_id_t){
|
|
||||||
.osd_num = osd_set[role],
|
|
||||||
.oid = {
|
|
||||||
.inode = op_data->oid.inode,
|
|
||||||
.stripe = op_data->oid.stripe | role,
|
|
||||||
},
|
|
||||||
}] = op_data->fact_ver;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Remember PG as dirty to drop the connection when PG goes offline
|
|
||||||
// (this is required because of the "lazy sync")
|
|
||||||
this->clients[cur_op->peer_fd].dirty_pgs.insert(op_data->pg_num);
|
|
||||||
// Remove version override
|
|
||||||
pg.ver_override.erase(op_data->oid);
|
|
||||||
finish_primary_op(cur_op, cur_op->req.rw.len);
|
|
||||||
// Continue other write operations to the same object
|
|
||||||
{
|
|
||||||
auto next_it = pg.write_queue.find(op_data->oid);
|
|
||||||
auto this_it = next_it;
|
|
||||||
next_it++;
|
|
||||||
pg.write_queue.erase(this_it);
|
|
||||||
if (next_it != pg.write_queue.end() &&
|
|
||||||
next_it->first == op_data->oid)
|
|
||||||
{
|
|
||||||
osd_op_t *next_op = next_it->second;
|
|
||||||
continue_primary_write(next_op);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save and clear unstable_writes -> SYNC all -> STABLE all
|
|
||||||
// FIXME: Run regular automatic syncs based on the number of unstable writes and/or system time
|
|
||||||
void osd_t::continue_primary_sync(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
if (!cur_op->op_data)
|
|
||||||
{
|
|
||||||
cur_op->op_data = (osd_primary_op_data_t*)calloc(sizeof(osd_primary_op_data_t), 1);
|
|
||||||
}
|
|
||||||
if (cur_op->op_data->st == 1) goto resume_1;
|
|
||||||
else if (cur_op->op_data->st == 2) goto resume_2;
|
|
||||||
else if (cur_op->op_data->st == 3) goto resume_3;
|
|
||||||
else if (cur_op->op_data->st == 4) goto resume_4;
|
|
||||||
else if (cur_op->op_data->st == 5) goto resume_5;
|
|
||||||
else if (cur_op->op_data->st == 6) goto resume_6;
|
|
||||||
assert(cur_op->op_data->st == 0);
|
|
||||||
if (syncs_in_progress.size() > 0)
|
|
||||||
{
|
|
||||||
// Wait for previous syncs, if any
|
|
||||||
// FIXME: We may try to execute the current one in parallel, like in Blockstore, but I'm not sure if it matters at all
|
|
||||||
syncs_in_progress.push_back(cur_op);
|
|
||||||
cur_op->op_data->st = 1;
|
|
||||||
resume_1:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
syncs_in_progress.push_back(cur_op);
|
|
||||||
}
|
|
||||||
resume_2:
|
|
||||||
// FIXME: Handle operation cancel
|
|
||||||
if (unstable_writes.size() == 0)
|
|
||||||
{
|
|
||||||
// Nothing to sync
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
// Save and clear unstable_writes
|
|
||||||
// FIXME: This is possible to do it on a per-client basis
|
|
||||||
// It would be cool not to copy them here at all, but someone has to deduplicate them by object IDs anyway
|
|
||||||
cur_op->op_data->unstable_write_osds = new std::vector<unstable_osd_num_t>();
|
|
||||||
cur_op->op_data->unstable_writes = new obj_ver_id[unstable_writes.size()];
|
|
||||||
{
|
|
||||||
osd_num_t last_osd = 0;
|
|
||||||
int last_start = 0, last_end = 0;
|
|
||||||
for (auto it = unstable_writes.begin(); it != unstable_writes.end(); it++)
|
|
||||||
{
|
|
||||||
if (last_osd != it->first.osd_num)
|
|
||||||
{
|
|
||||||
if (last_osd != 0)
|
|
||||||
{
|
|
||||||
cur_op->op_data->unstable_write_osds->push_back((unstable_osd_num_t){
|
|
||||||
.osd_num = last_osd,
|
|
||||||
.start = last_start,
|
|
||||||
.len = last_end - last_start,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
last_osd = it->first.osd_num;
|
|
||||||
last_start = last_end;
|
|
||||||
}
|
|
||||||
cur_op->op_data->unstable_writes[last_end] = (obj_ver_id){
|
|
||||||
.oid = it->first.oid,
|
|
||||||
.version = it->second,
|
|
||||||
};
|
|
||||||
last_end++;
|
|
||||||
}
|
|
||||||
if (last_osd != 0)
|
|
||||||
{
|
|
||||||
cur_op->op_data->unstable_write_osds->push_back((unstable_osd_num_t){
|
|
||||||
.osd_num = last_osd,
|
|
||||||
.start = last_start,
|
|
||||||
.len = last_end - last_start,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unstable_writes.clear();
|
|
||||||
// SYNC
|
|
||||||
submit_primary_sync_subops(cur_op);
|
|
||||||
resume_3:
|
|
||||||
cur_op->op_data->st = 3;
|
|
||||||
return;
|
|
||||||
resume_4:
|
|
||||||
// Stabilize version sets
|
|
||||||
submit_primary_stab_subops(cur_op);
|
|
||||||
resume_5:
|
|
||||||
cur_op->op_data->st = 5;
|
|
||||||
return;
|
|
||||||
resume_6:
|
|
||||||
// FIXME: Free them correctly (via a destructor or so)
|
|
||||||
delete cur_op->op_data->unstable_write_osds;
|
|
||||||
delete[] cur_op->op_data->unstable_writes;
|
|
||||||
cur_op->op_data->unstable_writes = NULL;
|
|
||||||
cur_op->op_data->unstable_write_osds = NULL;
|
|
||||||
finish:
|
|
||||||
assert(syncs_in_progress.front() == cur_op);
|
|
||||||
syncs_in_progress.pop_front();
|
|
||||||
finish_primary_op(cur_op, 0);
|
|
||||||
if (syncs_in_progress.size() > 0)
|
|
||||||
{
|
|
||||||
cur_op = syncs_in_progress.front();
|
|
||||||
cur_op->op_data->st++;
|
|
||||||
goto resume_2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::submit_primary_sync_subops(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
|
||||||
int n_osds = op_data->unstable_write_osds->size();
|
|
||||||
osd_op_t *subops = new osd_op_t[n_osds];
|
|
||||||
op_data->done = op_data->errors = 0;
|
|
||||||
op_data->n_subops = n_osds;
|
|
||||||
op_data->subops = subops;
|
|
||||||
for (int i = 0; i < n_osds; i++)
|
|
||||||
{
|
|
||||||
osd_num_t sync_osd = (*(op_data->unstable_write_osds))[i].osd_num;
|
|
||||||
if (sync_osd == this->osd_num)
|
|
||||||
{
|
|
||||||
subops[i].bs_op = new blockstore_op_t({
|
|
||||||
.opcode = BS_OP_SYNC,
|
|
||||||
.callback = [cur_op, this](blockstore_op_t *subop)
|
|
||||||
{
|
|
||||||
handle_primary_subop(cur_op, subop->retval == 0, 0);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
bs->enqueue_op(subops[i].bs_op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
subops[i].op_type = OSD_OP_OUT;
|
|
||||||
subops[i].send_list.push_back(subops[i].req.buf, OSD_PACKET_SIZE);
|
|
||||||
subops[i].peer_fd = osd_peer_fds.at(sync_osd);
|
|
||||||
subops[i].req.sec_sync = {
|
|
||||||
.header = {
|
|
||||||
.magic = SECONDARY_OSD_OP_MAGIC,
|
|
||||||
.id = this->next_subop_id++,
|
|
||||||
.opcode = OSD_OP_SECONDARY_SYNC,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
subops[i].callback = [cur_op, this](osd_op_t *subop)
|
|
||||||
{
|
|
||||||
handle_primary_subop(cur_op, subop->reply.hdr.retval == 0, 0);
|
|
||||||
};
|
|
||||||
outbox_push(clients[subops[i].peer_fd], &subops[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::submit_primary_stab_subops(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
|
||||||
int n_osds = op_data->unstable_write_osds->size();
|
|
||||||
osd_op_t *subops = new osd_op_t[n_osds];
|
|
||||||
op_data->done = op_data->errors = 0;
|
|
||||||
op_data->n_subops = n_osds;
|
|
||||||
op_data->subops = subops;
|
|
||||||
for (int i = 0; i < n_osds; i++)
|
|
||||||
{
|
|
||||||
auto & stab_osd = (*(op_data->unstable_write_osds))[i];
|
|
||||||
if (stab_osd.osd_num == this->osd_num)
|
|
||||||
{
|
|
||||||
subops[i].bs_op = new blockstore_op_t({
|
|
||||||
.opcode = BS_OP_STABLE,
|
|
||||||
.callback = [cur_op, this](blockstore_op_t *subop)
|
|
||||||
{
|
|
||||||
handle_primary_subop(cur_op, subop->retval == 0, 0);
|
|
||||||
},
|
|
||||||
.len = (uint32_t)stab_osd.len,
|
|
||||||
.buf = (void*)(op_data->unstable_writes + stab_osd.start),
|
|
||||||
});
|
|
||||||
bs->enqueue_op(subops[i].bs_op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
subops[i].op_type = OSD_OP_OUT;
|
|
||||||
subops[i].send_list.push_back(subops[i].req.buf, OSD_PACKET_SIZE);
|
|
||||||
subops[i].peer_fd = osd_peer_fds.at(stab_osd.osd_num);
|
|
||||||
subops[i].req.sec_stab = {
|
|
||||||
.header = {
|
|
||||||
.magic = SECONDARY_OSD_OP_MAGIC,
|
|
||||||
.id = this->next_subop_id++,
|
|
||||||
.opcode = OSD_OP_SECONDARY_STABILIZE,
|
|
||||||
},
|
|
||||||
.len = (uint64_t)(stab_osd.len * sizeof(obj_ver_id)),
|
|
||||||
};
|
|
||||||
subops[i].send_list.push_back(op_data->unstable_writes + stab_osd.start, stab_osd.len * sizeof(obj_ver_id));
|
|
||||||
subops[i].callback = [cur_op, this](osd_op_t *subop)
|
|
||||||
{
|
|
||||||
handle_primary_subop(cur_op, subop->reply.hdr.retval == 0, 0);
|
|
||||||
};
|
|
||||||
outbox_push(clients[subops[i].peer_fd], &subops[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
207
osd_receive.cpp
207
osd_receive.cpp
|
@ -1,207 +0,0 @@
|
||||||
#include "osd.h"
|
|
||||||
|
|
||||||
bool osd_t::try_receive(osd_client_t & cl)
|
|
||||||
{
|
|
||||||
int peer_fd = cl.peer_fd;
|
|
||||||
io_uring_sqe* sqe = ringloop->get_sqe();
|
|
||||||
if (!sqe)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ring_data_t* data = ((ring_data_t*)sqe->user_data);
|
|
||||||
if (!cl.read_buf)
|
|
||||||
{
|
|
||||||
// no reads in progress
|
|
||||||
// so this is either a new command or a reply to a previously sent command
|
|
||||||
if (!cl.read_op)
|
|
||||||
{
|
|
||||||
cl.read_op = new osd_op_t;
|
|
||||||
cl.read_op->peer_fd = peer_fd;
|
|
||||||
}
|
|
||||||
cl.read_op->op_type = OSD_OP_IN;
|
|
||||||
cl.read_buf = &cl.read_op->req.buf;
|
|
||||||
cl.read_remaining = OSD_PACKET_SIZE;
|
|
||||||
cl.read_state = CL_READ_OP;
|
|
||||||
}
|
|
||||||
cl.read_iov.iov_base = cl.read_buf;
|
|
||||||
cl.read_iov.iov_len = cl.read_remaining;
|
|
||||||
cl.read_msg.msg_iov = &cl.read_iov;
|
|
||||||
cl.read_msg.msg_iovlen = 1;
|
|
||||||
data->callback = [this, peer_fd](ring_data_t *data) { handle_read(data, peer_fd); };
|
|
||||||
my_uring_prep_recvmsg(sqe, peer_fd, &cl.read_msg, 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::read_requests()
|
|
||||||
{
|
|
||||||
for (auto & p: clients)
|
|
||||||
{
|
|
||||||
if (p.second.peer_state == PEER_CONNECTED && p.second.read_iov.iov_len == 0)
|
|
||||||
{
|
|
||||||
try_receive(p.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::handle_read(ring_data_t *data, int peer_fd)
|
|
||||||
{
|
|
||||||
auto cl_it = clients.find(peer_fd);
|
|
||||||
if (cl_it != clients.end())
|
|
||||||
{
|
|
||||||
auto & cl = cl_it->second;
|
|
||||||
cl.read_iov.iov_len = 0;
|
|
||||||
if (data->res == -EAGAIN)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (data->res < 0)
|
|
||||||
{
|
|
||||||
// this is a client socket, so don't panic. just disconnect it
|
|
||||||
printf("Client %d socket read error: %d (%s). Disconnecting client\n", peer_fd, -data->res, strerror(-data->res));
|
|
||||||
stop_client(peer_fd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data->res > 0)
|
|
||||||
{
|
|
||||||
cl.read_remaining -= data->res;
|
|
||||||
cl.read_buf += data->res;
|
|
||||||
if (cl.read_remaining <= 0)
|
|
||||||
{
|
|
||||||
cl.read_buf = NULL;
|
|
||||||
if (cl.read_state == CL_READ_OP)
|
|
||||||
{
|
|
||||||
if (cl.read_op->req.hdr.magic == SECONDARY_OSD_REPLY_MAGIC)
|
|
||||||
{
|
|
||||||
handle_reply_hdr(&cl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
handle_op_hdr(&cl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (cl.read_state == CL_READ_DATA)
|
|
||||||
{
|
|
||||||
// Operation is ready
|
|
||||||
exec_op(cl.read_op);
|
|
||||||
cl.read_op = NULL;
|
|
||||||
cl.read_state = 0;
|
|
||||||
}
|
|
||||||
else if (cl.read_state == CL_READ_REPLY_DATA)
|
|
||||||
{
|
|
||||||
// Reply is ready
|
|
||||||
auto req_it = cl.sent_ops.find(cl.read_reply_id);
|
|
||||||
osd_op_t *request = req_it->second;
|
|
||||||
cl.sent_ops.erase(req_it);
|
|
||||||
cl.read_reply_id = 0;
|
|
||||||
cl.read_state = 0;
|
|
||||||
// Measure subop latency
|
|
||||||
timeval tv_end;
|
|
||||||
gettimeofday(&tv_end, NULL);
|
|
||||||
subop_stat_count[request->req.hdr.opcode]++;
|
|
||||||
subop_stat_sum[request->req.hdr.opcode] += (
|
|
||||||
(tv_end.tv_sec - request->tv_begin.tv_sec)*1000000 +
|
|
||||||
tv_end.tv_usec - request->tv_begin.tv_usec
|
|
||||||
);
|
|
||||||
request->callback(request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::handle_op_hdr(osd_client_t *cl)
|
|
||||||
{
|
|
||||||
osd_op_t *cur_op = cl->read_op;
|
|
||||||
if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_READ)
|
|
||||||
{
|
|
||||||
if (cur_op->req.sec_rw.len > 0)
|
|
||||||
cur_op->buf = memalign(512, cur_op->req.sec_rw.len);
|
|
||||||
cl->read_remaining = 0;
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE)
|
|
||||||
{
|
|
||||||
if (cur_op->req.sec_rw.len > 0)
|
|
||||||
cur_op->buf = memalign(512, cur_op->req.sec_rw.len);
|
|
||||||
cl->read_remaining = cur_op->req.sec_rw.len;
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE ||
|
|
||||||
cur_op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK)
|
|
||||||
{
|
|
||||||
if (cur_op->req.sec_stab.len > 0)
|
|
||||||
cur_op->buf = memalign(512, cur_op->req.sec_stab.len);
|
|
||||||
cl->read_remaining = cur_op->req.sec_stab.len;
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_READ)
|
|
||||||
{
|
|
||||||
if (cur_op->req.rw.len > 0)
|
|
||||||
cur_op->buf = memalign(512, cur_op->req.rw.len);
|
|
||||||
cl->read_remaining = 0;
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_WRITE)
|
|
||||||
{
|
|
||||||
if (cur_op->req.rw.len > 0)
|
|
||||||
cur_op->buf = memalign(512, cur_op->req.rw.len);
|
|
||||||
cl->read_remaining = cur_op->req.rw.len;
|
|
||||||
}
|
|
||||||
if (cl->read_remaining > 0)
|
|
||||||
{
|
|
||||||
// Read data
|
|
||||||
cl->read_buf = cur_op->buf;
|
|
||||||
cl->read_state = CL_READ_DATA;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Operation is ready
|
|
||||||
cl->read_op = NULL;
|
|
||||||
cl->read_state = 0;
|
|
||||||
exec_op(cur_op);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::handle_reply_hdr(osd_client_t *cl)
|
|
||||||
{
|
|
||||||
osd_op_t *cur_op = cl->read_op;
|
|
||||||
auto req_it = cl->sent_ops.find(cur_op->req.hdr.id);
|
|
||||||
if (req_it == cl->sent_ops.end())
|
|
||||||
{
|
|
||||||
// Command out of sync. Drop connection
|
|
||||||
printf("Client %d command out of sync: id %lu\n", cl->peer_fd, cur_op->req.hdr.id);
|
|
||||||
stop_client(cl->peer_fd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
osd_op_t *op = req_it->second;
|
|
||||||
memcpy(op->reply.buf, cur_op->req.buf, OSD_PACKET_SIZE);
|
|
||||||
if (op->reply.hdr.opcode == OSD_OP_SECONDARY_READ &&
|
|
||||||
op->reply.hdr.retval > 0)
|
|
||||||
{
|
|
||||||
// Read data. In this case we assume that the buffer is preallocated by the caller (!)
|
|
||||||
assert(op->buf);
|
|
||||||
cl->read_state = CL_READ_REPLY_DATA;
|
|
||||||
cl->read_reply_id = op->req.hdr.id;
|
|
||||||
cl->read_buf = op->buf;
|
|
||||||
cl->read_remaining = op->reply.hdr.retval;
|
|
||||||
}
|
|
||||||
else if (op->reply.hdr.opcode == OSD_OP_SECONDARY_LIST &&
|
|
||||||
op->reply.hdr.retval > 0)
|
|
||||||
{
|
|
||||||
op->buf = memalign(512, sizeof(obj_ver_id) * op->reply.hdr.retval);
|
|
||||||
cl->read_state = CL_READ_REPLY_DATA;
|
|
||||||
cl->read_reply_id = op->req.hdr.id;
|
|
||||||
cl->read_buf = op->buf;
|
|
||||||
cl->read_remaining = sizeof(obj_ver_id) * op->reply.hdr.retval;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cl->read_state = 0;
|
|
||||||
cl->sent_ops.erase(req_it);
|
|
||||||
// Measure subop latency
|
|
||||||
timeval tv_end;
|
|
||||||
gettimeofday(&tv_end, NULL);
|
|
||||||
subop_stat_count[op->req.hdr.opcode]++;
|
|
||||||
subop_stat_sum[op->req.hdr.opcode] += (
|
|
||||||
(tv_end.tv_sec - op->tv_begin.tv_sec)*1000000 +
|
|
||||||
tv_end.tv_usec - op->tv_begin.tv_usec
|
|
||||||
);
|
|
||||||
op->callback(op);
|
|
||||||
}
|
|
||||||
}
|
|
367
osd_rmw.cpp
367
osd_rmw.cpp
|
@ -1,367 +0,0 @@
|
||||||
#include <malloc.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include "xor.h"
|
|
||||||
#include "osd_rmw.h"
|
|
||||||
|
|
||||||
static inline void extend_read(uint32_t start, uint32_t end, osd_rmw_stripe_t & stripe)
|
|
||||||
{
|
|
||||||
if (stripe.read_end == 0)
|
|
||||||
{
|
|
||||||
stripe.read_start = start;
|
|
||||||
stripe.read_end = end;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (stripe.read_end < end)
|
|
||||||
stripe.read_end = end;
|
|
||||||
if (stripe.read_start > start)
|
|
||||||
stripe.read_start = start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void cover_read(uint32_t start, uint32_t end, osd_rmw_stripe_t & stripe)
|
|
||||||
{
|
|
||||||
// Subtract <to> write request from <from> request
|
|
||||||
if (start >= stripe.req_start &&
|
|
||||||
end <= stripe.req_end)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (start <= stripe.req_start &&
|
|
||||||
end >= stripe.req_start &&
|
|
||||||
end <= stripe.req_end)
|
|
||||||
{
|
|
||||||
end = stripe.req_start;
|
|
||||||
}
|
|
||||||
else if (start >= stripe.req_start &&
|
|
||||||
start <= stripe.req_end &&
|
|
||||||
end >= stripe.req_end)
|
|
||||||
{
|
|
||||||
start = stripe.req_end;
|
|
||||||
}
|
|
||||||
if (stripe.read_end == 0)
|
|
||||||
{
|
|
||||||
stripe.read_start = start;
|
|
||||||
stripe.read_end = end;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (stripe.read_end < end)
|
|
||||||
stripe.read_end = end;
|
|
||||||
if (stripe.read_start > start)
|
|
||||||
stripe.read_start = start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void split_stripes(uint64_t pg_minsize, uint32_t bs_block_size, uint32_t start, uint32_t end, osd_rmw_stripe_t *stripes)
|
|
||||||
{
|
|
||||||
end = start+end;
|
|
||||||
for (int role = 0; role < pg_minsize; role++)
|
|
||||||
{
|
|
||||||
if (start < (1+role)*bs_block_size && end > role*bs_block_size)
|
|
||||||
{
|
|
||||||
stripes[role].req_start = start < role*bs_block_size ? 0 : start-role*bs_block_size;
|
|
||||||
stripes[role].req_end = end > (role+1)*bs_block_size ? bs_block_size : end-role*bs_block_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void reconstruct_stripe(osd_rmw_stripe_t *stripes, int pg_size, int role)
|
|
||||||
{
|
|
||||||
int prev = -2;
|
|
||||||
for (int other = 0; other < pg_size; other++)
|
|
||||||
{
|
|
||||||
if (other != role)
|
|
||||||
{
|
|
||||||
if (prev == -2)
|
|
||||||
{
|
|
||||||
prev = other;
|
|
||||||
}
|
|
||||||
else if (prev >= 0)
|
|
||||||
{
|
|
||||||
memxor(
|
|
||||||
stripes[prev].read_buf + (stripes[prev].read_start - stripes[role].read_start),
|
|
||||||
stripes[other].read_buf + (stripes[other].read_start - stripes[other].read_start),
|
|
||||||
stripes[role].read_buf, stripes[role].read_end - stripes[role].read_start
|
|
||||||
);
|
|
||||||
prev = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memxor(
|
|
||||||
stripes[role].read_buf,
|
|
||||||
stripes[other].read_buf + (stripes[other].read_start - stripes[role].read_start),
|
|
||||||
stripes[role].read_buf, stripes[role].read_end - stripes[role].read_start
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int extend_missing_stripes(osd_rmw_stripe_t *stripes, osd_num_t *osd_set, int minsize, int size)
|
|
||||||
{
|
|
||||||
for (int role = 0; role < minsize; role++)
|
|
||||||
{
|
|
||||||
if (stripes[role].read_end != 0 && osd_set[role] == 0)
|
|
||||||
{
|
|
||||||
stripes[role].missing = true;
|
|
||||||
// Stripe is missing. Extend read to other stripes.
|
|
||||||
// We need at least pg_minsize stripes to recover the lost part.
|
|
||||||
// FIXME: LRC EC and similar don't require to read all other stripes.
|
|
||||||
int exist = 0;
|
|
||||||
for (int j = 0; j < size; j++)
|
|
||||||
{
|
|
||||||
if (osd_set[j] != 0)
|
|
||||||
{
|
|
||||||
extend_read(stripes[role].read_start, stripes[role].read_end, stripes[j]);
|
|
||||||
exist++;
|
|
||||||
if (exist >= minsize)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (exist < minsize)
|
|
||||||
{
|
|
||||||
// Less than minsize stripes are available for this object
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* alloc_read_buffer(osd_rmw_stripe_t *stripes, int read_pg_size, uint64_t add_size)
|
|
||||||
{
|
|
||||||
// Calculate buffer size
|
|
||||||
uint64_t buf_size = add_size;
|
|
||||||
for (int role = 0; role < read_pg_size; role++)
|
|
||||||
{
|
|
||||||
if (stripes[role].read_end != 0)
|
|
||||||
{
|
|
||||||
buf_size += stripes[role].read_end - stripes[role].read_start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Allocate buffer
|
|
||||||
void *buf = memalign(MEM_ALIGNMENT, buf_size);
|
|
||||||
uint64_t buf_pos = add_size;
|
|
||||||
for (int role = 0; role < read_pg_size; role++)
|
|
||||||
{
|
|
||||||
if (stripes[role].read_end != 0)
|
|
||||||
{
|
|
||||||
stripes[role].read_buf = buf + buf_pos;
|
|
||||||
buf_pos += stripes[role].read_end - stripes[role].read_start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* calc_rmw_reads(void *write_buf, osd_rmw_stripe_t *stripes, uint64_t *osd_set, uint64_t pg_size, uint64_t pg_minsize, uint64_t pg_cursize)
|
|
||||||
{
|
|
||||||
// Generic parity modification (read-modify-write) algorithm
|
|
||||||
// Reconstruct -> Read -> Calc parity -> Write
|
|
||||||
// Now we always read continuous ranges. This means that an update of the beginning
|
|
||||||
// of one data stripe and the end of another will lead to a read of full paired stripes.
|
|
||||||
// FIXME: (Maybe) read small individual ranges in that case instead.
|
|
||||||
uint32_t start = 0, end = 0;
|
|
||||||
for (int role = 0; role < pg_minsize; role++)
|
|
||||||
{
|
|
||||||
if (stripes[role].req_end != 0)
|
|
||||||
{
|
|
||||||
start = !end || stripes[role].req_start < start ? stripes[role].req_start : start;
|
|
||||||
end = std::max(stripes[role].req_end, end);
|
|
||||||
stripes[role].write_start = stripes[role].req_start;
|
|
||||||
stripes[role].write_end = stripes[role].req_end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int role = 0; role < pg_minsize; role++)
|
|
||||||
{
|
|
||||||
cover_read(start, end, stripes[role]);
|
|
||||||
}
|
|
||||||
int has_parity = 0;
|
|
||||||
for (int role = pg_minsize; role < pg_size; role++)
|
|
||||||
{
|
|
||||||
if (osd_set[role] != 0)
|
|
||||||
{
|
|
||||||
has_parity++;
|
|
||||||
stripes[role].write_start = start;
|
|
||||||
stripes[role].write_end = end;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
stripes[role].missing = true;
|
|
||||||
}
|
|
||||||
if (pg_cursize < pg_size)
|
|
||||||
{
|
|
||||||
if (has_parity == 0)
|
|
||||||
{
|
|
||||||
// Parity is missing, we don't need to read anything
|
|
||||||
for (int role = 0; role < pg_minsize; role++)
|
|
||||||
{
|
|
||||||
stripes[role].read_end = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Other stripe(s) are missing
|
|
||||||
for (int role = 0; role < pg_minsize; role++)
|
|
||||||
{
|
|
||||||
if (osd_set[role] == 0 && stripes[role].read_end != 0)
|
|
||||||
{
|
|
||||||
stripes[role].missing = true;
|
|
||||||
for (int r2 = 0; r2 < pg_size; r2++)
|
|
||||||
{
|
|
||||||
// Read the non-covered range of <role> from all other stripes to reconstruct it
|
|
||||||
if (r2 != role && osd_set[r2] != 0)
|
|
||||||
{
|
|
||||||
extend_read(stripes[role].read_start, stripes[role].read_end, stripes[r2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Allocate read buffers
|
|
||||||
void *rmw_buf = alloc_read_buffer(stripes, pg_size, has_parity * (end - start));
|
|
||||||
// Position parity & write buffers
|
|
||||||
uint64_t buf_pos = 0, in_pos = 0;
|
|
||||||
for (int role = 0; role < pg_size; role++)
|
|
||||||
{
|
|
||||||
if (stripes[role].req_end != 0)
|
|
||||||
{
|
|
||||||
stripes[role].write_buf = write_buf + in_pos;
|
|
||||||
in_pos += stripes[role].req_end - stripes[role].req_start;
|
|
||||||
}
|
|
||||||
else if (role >= pg_minsize && osd_set[role] != 0)
|
|
||||||
{
|
|
||||||
stripes[role].write_buf = rmw_buf + buf_pos;
|
|
||||||
buf_pos += end - start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rmw_buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void get_old_new_buffers(osd_rmw_stripe_t & stripe, uint32_t wr_start, uint32_t wr_end, buf_len_t *bufs, int & nbufs)
|
|
||||||
{
|
|
||||||
uint32_t ns = 0, ne = 0, os = 0, oe = 0;
|
|
||||||
if (stripe.req_end > wr_start &&
|
|
||||||
stripe.req_start < wr_end)
|
|
||||||
{
|
|
||||||
ns = std::max(stripe.req_start, wr_start);
|
|
||||||
ne = std::min(stripe.req_end, wr_end);
|
|
||||||
}
|
|
||||||
if (stripe.read_end > wr_start &&
|
|
||||||
stripe.read_start < wr_end)
|
|
||||||
{
|
|
||||||
os = std::max(stripe.read_start, wr_start);
|
|
||||||
oe = std::min(stripe.read_end, wr_end);
|
|
||||||
}
|
|
||||||
if (ne && (!oe || ns <= os))
|
|
||||||
{
|
|
||||||
// NEW or NEW->OLD
|
|
||||||
bufs[nbufs++] = { .buf = stripe.write_buf + ns - stripe.req_start, .len = ne-ns };
|
|
||||||
if (os < ne)
|
|
||||||
os = ne;
|
|
||||||
if (oe > os)
|
|
||||||
{
|
|
||||||
// NEW->OLD
|
|
||||||
bufs[nbufs++] = { .buf = stripe.read_buf + os - stripe.read_start, .len = oe-os };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (oe)
|
|
||||||
{
|
|
||||||
// OLD or OLD->NEW or OLD->NEW->OLD
|
|
||||||
if (ne)
|
|
||||||
{
|
|
||||||
// OLD->NEW or OLD->NEW->OLD
|
|
||||||
bufs[nbufs++] = { .buf = stripe.read_buf + os - stripe.read_start, .len = ns-os };
|
|
||||||
bufs[nbufs++] = { .buf = stripe.write_buf + ns - stripe.req_start, .len = ne-ns };
|
|
||||||
if (oe > ne)
|
|
||||||
{
|
|
||||||
// OLD->NEW->OLD
|
|
||||||
bufs[nbufs++] = { .buf = stripe.read_buf + ne - stripe.read_start, .len = oe-ne };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// OLD
|
|
||||||
bufs[nbufs++] = { .buf = stripe.read_buf + os - stripe.read_start, .len = oe-os };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void xor_multiple_buffers(buf_len_t *xor1, int n1, buf_len_t *xor2, int n2, void *dest, uint32_t len)
|
|
||||||
{
|
|
||||||
assert(n1 > 0 && n2 > 0);
|
|
||||||
int i1 = 0, i2 = 0;
|
|
||||||
uint32_t start1 = 0, start2 = 0, end1 = xor1[0].len, end2 = xor2[0].len;
|
|
||||||
uint32_t pos = 0;
|
|
||||||
while (pos < len)
|
|
||||||
{
|
|
||||||
// We know for sure that ranges overlap
|
|
||||||
uint32_t end = std::min(end1, end2);
|
|
||||||
memxor(xor1[i1].buf + pos-start1, xor2[i2].buf + pos-start2, dest+pos, end-pos);
|
|
||||||
pos = end;
|
|
||||||
if (pos >= end1)
|
|
||||||
{
|
|
||||||
i1++;
|
|
||||||
if (i1 >= n1)
|
|
||||||
{
|
|
||||||
assert(pos >= end2);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
start1 = end1;
|
|
||||||
end1 += xor1[i1].len;
|
|
||||||
}
|
|
||||||
if (pos >= end2)
|
|
||||||
{
|
|
||||||
i2++;
|
|
||||||
start2 = end2;
|
|
||||||
end2 += xor2[i2].len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void calc_rmw_parity(osd_rmw_stripe_t *stripes, int pg_size)
|
|
||||||
{
|
|
||||||
if (stripes[pg_size-1].missing)
|
|
||||||
{
|
|
||||||
// Parity OSD is unavailable
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int role = 0; role < pg_size; role++)
|
|
||||||
{
|
|
||||||
if (stripes[role].read_end != 0 && stripes[role].missing)
|
|
||||||
{
|
|
||||||
// Reconstruct missing stripe (EC k+1)
|
|
||||||
reconstruct_stripe(stripes, pg_size, role);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Calculate new parity (EC k+1)
|
|
||||||
int parity = pg_size-1, prev = -2;
|
|
||||||
auto wr_end = stripes[parity].write_end;
|
|
||||||
auto wr_start = stripes[parity].write_start;
|
|
||||||
for (int other = 0; other < pg_size-1; other++)
|
|
||||||
{
|
|
||||||
if (prev == -2)
|
|
||||||
{
|
|
||||||
prev = other;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int n1 = 0, n2 = 0;
|
|
||||||
buf_len_t xor1[3], xor2[3];
|
|
||||||
if (prev == -1)
|
|
||||||
{
|
|
||||||
xor1[n1++] = { .buf = stripes[parity].write_buf, .len = wr_end-wr_start };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
get_old_new_buffers(stripes[prev], wr_start, wr_end, xor1, n1);
|
|
||||||
prev = -1;
|
|
||||||
}
|
|
||||||
get_old_new_buffers(stripes[other], wr_start, wr_end, xor2, n2);
|
|
||||||
xor_multiple_buffers(xor1, n1, xor2, n2, stripes[parity].write_buf, wr_end-wr_start);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
36
osd_rmw.h
36
osd_rmw.h
|
@ -1,36 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "object_id.h"
|
|
||||||
#include "osd_id.h"
|
|
||||||
|
|
||||||
#ifndef MEM_ALIGNMENT
|
|
||||||
#define MEM_ALIGNMENT 512
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct buf_len_t
|
|
||||||
{
|
|
||||||
void *buf;
|
|
||||||
uint64_t len;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct osd_rmw_stripe_t
|
|
||||||
{
|
|
||||||
void *read_buf, *write_buf;
|
|
||||||
uint32_t req_start, req_end;
|
|
||||||
uint32_t read_start, read_end;
|
|
||||||
uint32_t write_start, write_end;
|
|
||||||
bool missing;
|
|
||||||
};
|
|
||||||
|
|
||||||
void split_stripes(uint64_t pg_minsize, uint32_t bs_block_size, uint32_t start, uint32_t len, osd_rmw_stripe_t *stripes);
|
|
||||||
|
|
||||||
void reconstruct_stripe(osd_rmw_stripe_t *stripes, int pg_size, int role);
|
|
||||||
|
|
||||||
int extend_missing_stripes(osd_rmw_stripe_t *stripes, osd_num_t *osd_set, int minsize, int size);
|
|
||||||
|
|
||||||
void* alloc_read_buffer(osd_rmw_stripe_t *stripes, int read_pg_size, uint64_t add_size);
|
|
||||||
|
|
||||||
void* calc_rmw_reads(void *write_buf, osd_rmw_stripe_t *stripes, uint64_t *osd_set, uint64_t pg_size, uint64_t pg_minsize, uint64_t pg_cursize);
|
|
||||||
|
|
||||||
void calc_rmw_parity(osd_rmw_stripe_t *stripes, int pg_size);
|
|
|
@ -1,93 +0,0 @@
|
||||||
#include <string.h>
|
|
||||||
#include "osd_rmw.cpp"
|
|
||||||
#include "test_pattern.h"
|
|
||||||
|
|
||||||
int main(int narg, char *args[])
|
|
||||||
{
|
|
||||||
osd_num_t osd_set[3] = { 1, 0, 3 };
|
|
||||||
osd_rmw_stripe_t stripes[3] = { 0 };
|
|
||||||
// Test 1
|
|
||||||
split_stripes(2, 128*1024, 128*1024-4096, 8192, stripes);
|
|
||||||
assert(stripes[0].req_start == 128*1024-4096 && stripes[0].req_end == 128*1024);
|
|
||||||
assert(stripes[1].req_start == 0 && stripes[1].req_end == 4096);
|
|
||||||
assert(stripes[2].req_end == 0);
|
|
||||||
// Test 2
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
stripes[i].read_start = stripes[i].req_start;
|
|
||||||
stripes[i].read_end = stripes[i].req_end;
|
|
||||||
}
|
|
||||||
assert(extend_missing_stripes(stripes, osd_set, 2, 3) == 0);
|
|
||||||
assert(stripes[0].read_start == 0 && stripes[0].read_end == 128*1024);
|
|
||||||
assert(stripes[2].read_start == 0 && stripes[2].read_end == 4096);
|
|
||||||
// Test 3
|
|
||||||
stripes[0] = { .req_start = 128*1024-4096, .req_end = 128*1024 };
|
|
||||||
cover_read(0, 128*1024, stripes[0]);
|
|
||||||
assert(stripes[0].read_start == 0 && stripes[0].read_end == 128*1024-4096);
|
|
||||||
// Test 4.1
|
|
||||||
memset(stripes, 0, sizeof(stripes));
|
|
||||||
split_stripes(2, 128*1024, 128*1024-4096, 8192, stripes);
|
|
||||||
void* write_buf = malloc(8192);
|
|
||||||
void* rmw_buf = calc_rmw_reads(write_buf, stripes, osd_set, 3, 2, 2);
|
|
||||||
assert(stripes[0].read_start == 0 && stripes[0].read_end == 128*1024);
|
|
||||||
assert(stripes[1].read_start == 4096 && stripes[1].read_end == 128*1024);
|
|
||||||
assert(stripes[2].read_start == 4096 && stripes[2].read_end == 128*1024);
|
|
||||||
assert(stripes[0].read_buf == rmw_buf+128*1024);
|
|
||||||
assert(stripes[1].read_buf == rmw_buf+128*1024*2);
|
|
||||||
assert(stripes[2].read_buf == rmw_buf+128*1024*3-4096);
|
|
||||||
assert(stripes[0].write_buf == write_buf);
|
|
||||||
assert(stripes[1].write_buf == write_buf+4096);
|
|
||||||
assert(stripes[2].write_buf == rmw_buf);
|
|
||||||
// Test 4.2
|
|
||||||
set_pattern(write_buf, 8192, PATTERN0);
|
|
||||||
set_pattern(stripes[0].read_buf, 128*1024, PATTERN1); // old data
|
|
||||||
set_pattern(stripes[1].read_buf, 128*1024-4096, UINT64_MAX); // didn't read it, it's missing
|
|
||||||
set_pattern(stripes[2].read_buf, 128*1024-4096, 0); // old parity = 0
|
|
||||||
calc_rmw_parity(stripes, 3);
|
|
||||||
check_pattern(stripes[2].write_buf, 4096, PATTERN0^PATTERN1); // new parity
|
|
||||||
check_pattern(stripes[2].write_buf+4096, 128*1024-4096*2, 0); // new parity
|
|
||||||
check_pattern(stripes[2].write_buf+128*1024-4096, 4096, PATTERN0^PATTERN1); // new parity
|
|
||||||
free(rmw_buf);
|
|
||||||
free(write_buf);
|
|
||||||
// Test 5.1
|
|
||||||
memset(stripes, 0, sizeof(stripes));
|
|
||||||
split_stripes(2, 128*1024, 0, 64*1024*3, stripes);
|
|
||||||
assert(stripes[0].req_start == 0 && stripes[0].req_end == 128*1024);
|
|
||||||
assert(stripes[1].req_start == 0 && stripes[1].req_end == 64*1024);
|
|
||||||
assert(stripes[2].req_end == 0);
|
|
||||||
// Test 5.2
|
|
||||||
write_buf = malloc(64*1024*3);
|
|
||||||
rmw_buf = calc_rmw_reads(write_buf, stripes, osd_set, 3, 2, 2);
|
|
||||||
assert(stripes[0].read_start == 64*1024 && stripes[0].read_end == 128*1024);
|
|
||||||
assert(stripes[1].read_start == 64*1024 && stripes[1].read_end == 128*1024);
|
|
||||||
assert(stripes[2].read_start == 64*1024 && stripes[2].read_end == 128*1024);
|
|
||||||
assert(stripes[0].read_buf == rmw_buf+128*1024);
|
|
||||||
assert(stripes[1].read_buf == rmw_buf+64*3*1024);
|
|
||||||
assert(stripes[2].read_buf == rmw_buf+64*4*1024);
|
|
||||||
assert(stripes[0].write_buf == write_buf);
|
|
||||||
assert(stripes[1].write_buf == write_buf+128*1024);
|
|
||||||
assert(stripes[2].write_buf == rmw_buf);
|
|
||||||
free(rmw_buf);
|
|
||||||
free(write_buf);
|
|
||||||
// Test 6.1
|
|
||||||
memset(stripes, 0, sizeof(stripes));
|
|
||||||
split_stripes(2, 128*1024, 0, 64*1024*3, stripes);
|
|
||||||
osd_set[1] = 2;
|
|
||||||
write_buf = malloc(64*1024*3);
|
|
||||||
rmw_buf = calc_rmw_reads(write_buf, stripes, osd_set, 3, 2, 3);
|
|
||||||
assert(stripes[0].read_end == 0);
|
|
||||||
assert(stripes[1].read_start == 64*1024 && stripes[1].read_end == 128*1024);
|
|
||||||
assert(stripes[2].read_end == 0);
|
|
||||||
assert(stripes[0].read_buf == 0);
|
|
||||||
assert(stripes[1].read_buf == rmw_buf+128*1024);
|
|
||||||
assert(stripes[2].read_buf == 0);
|
|
||||||
assert(stripes[0].write_buf == write_buf);
|
|
||||||
assert(stripes[1].write_buf == write_buf+128*1024);
|
|
||||||
assert(stripes[2].write_buf == rmw_buf);
|
|
||||||
free(rmw_buf);
|
|
||||||
free(write_buf);
|
|
||||||
osd_set[1] = 0;
|
|
||||||
// End
|
|
||||||
printf("all ok\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,150 +0,0 @@
|
||||||
#include "osd.h"
|
|
||||||
|
|
||||||
#include "json11/json11.hpp"
|
|
||||||
|
|
||||||
void osd_t::secondary_op_callback(osd_op_t *op)
|
|
||||||
{
|
|
||||||
inflight_ops--;
|
|
||||||
auto cl_it = clients.find(op->peer_fd);
|
|
||||||
if (cl_it != clients.end())
|
|
||||||
{
|
|
||||||
op->reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC;
|
|
||||||
op->reply.hdr.id = op->req.hdr.id;
|
|
||||||
op->reply.hdr.opcode = op->req.hdr.opcode;
|
|
||||||
op->reply.hdr.retval = op->bs_op->retval;
|
|
||||||
if (op->req.hdr.opcode == OSD_OP_SECONDARY_READ ||
|
|
||||||
op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE)
|
|
||||||
{
|
|
||||||
op->reply.sec_rw.version = op->bs_op->version;
|
|
||||||
}
|
|
||||||
else if (op->req.hdr.opcode == OSD_OP_SECONDARY_DELETE)
|
|
||||||
{
|
|
||||||
op->reply.sec_del.version = op->bs_op->version;
|
|
||||||
}
|
|
||||||
if (op->req.hdr.opcode == OSD_OP_SECONDARY_READ &&
|
|
||||||
op->reply.hdr.retval > 0)
|
|
||||||
{
|
|
||||||
op->send_list.push_back(op->buf, op->reply.hdr.retval);
|
|
||||||
}
|
|
||||||
else if (op->req.hdr.opcode == OSD_OP_SECONDARY_LIST)
|
|
||||||
{
|
|
||||||
// allocated by blockstore
|
|
||||||
op->buf = op->bs_op->buf;
|
|
||||||
if (op->reply.hdr.retval > 0)
|
|
||||||
{
|
|
||||||
op->send_list.push_back(op->buf, op->reply.hdr.retval * sizeof(obj_ver_id));
|
|
||||||
}
|
|
||||||
op->reply.sec_list.stable_count = op->bs_op->version;
|
|
||||||
}
|
|
||||||
auto & cl = cl_it->second;
|
|
||||||
outbox_push(cl, op);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete op;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::exec_secondary(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
cur_op->bs_op = new blockstore_op_t();
|
|
||||||
cur_op->bs_op->callback = [this, cur_op](blockstore_op_t* bs_op) { secondary_op_callback(cur_op); };
|
|
||||||
cur_op->bs_op->opcode = (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_READ ? BS_OP_READ
|
|
||||||
: (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE ? BS_OP_WRITE
|
|
||||||
: (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_SYNC ? BS_OP_SYNC
|
|
||||||
: (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE ? BS_OP_STABLE
|
|
||||||
: (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK ? BS_OP_ROLLBACK
|
|
||||||
: (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_DELETE ? BS_OP_DELETE
|
|
||||||
: (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_LIST ? BS_OP_LIST
|
|
||||||
: -1)))))));
|
|
||||||
if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_READ ||
|
|
||||||
cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE)
|
|
||||||
{
|
|
||||||
cur_op->bs_op->oid = cur_op->req.sec_rw.oid;
|
|
||||||
cur_op->bs_op->version = cur_op->req.sec_rw.version;
|
|
||||||
cur_op->bs_op->offset = cur_op->req.sec_rw.offset;
|
|
||||||
cur_op->bs_op->len = cur_op->req.sec_rw.len;
|
|
||||||
cur_op->bs_op->buf = cur_op->buf;
|
|
||||||
#ifdef OSD_STUB
|
|
||||||
cur_op->bs_op->retval = cur_op->bs_op->len;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_DELETE)
|
|
||||||
{
|
|
||||||
cur_op->bs_op->oid = cur_op->req.sec_del.oid;
|
|
||||||
cur_op->bs_op->version = cur_op->req.sec_del.version;
|
|
||||||
#ifdef OSD_STUB
|
|
||||||
cur_op->bs_op->retval = 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE ||
|
|
||||||
cur_op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK)
|
|
||||||
{
|
|
||||||
cur_op->bs_op->len = cur_op->req.sec_stab.len/sizeof(obj_ver_id);
|
|
||||||
cur_op->bs_op->buf = cur_op->buf;
|
|
||||||
#ifdef OSD_STUB
|
|
||||||
cur_op->bs_op->retval = 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_LIST)
|
|
||||||
{
|
|
||||||
if (cur_op->req.sec_list.pg_count < cur_op->req.sec_list.list_pg)
|
|
||||||
{
|
|
||||||
// requested pg number is greater than total pg count
|
|
||||||
cur_op->bs_op->retval = -EINVAL;
|
|
||||||
secondary_op_callback(cur_op);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cur_op->bs_op->oid.stripe = cur_op->req.sec_list.parity_block_size;
|
|
||||||
cur_op->bs_op->len = cur_op->req.sec_list.pg_count;
|
|
||||||
cur_op->bs_op->offset = cur_op->req.sec_list.list_pg - 1;
|
|
||||||
#ifdef OSD_STUB
|
|
||||||
cur_op->bs_op->retval = 0;
|
|
||||||
cur_op->bs_op->buf = NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#ifdef OSD_STUB
|
|
||||||
secondary_op_callback(cur_op);
|
|
||||||
#else
|
|
||||||
bs->enqueue_op(cur_op->bs_op);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::exec_show_config(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
// FIXME: Send the real config, not its source
|
|
||||||
std::string cfg_str = json11::Json(config).dump();
|
|
||||||
cur_op->reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC;
|
|
||||||
cur_op->reply.hdr.id = cur_op->req.hdr.id;
|
|
||||||
cur_op->reply.hdr.opcode = cur_op->req.hdr.opcode;
|
|
||||||
cur_op->reply.hdr.retval = cfg_str.size()+1;
|
|
||||||
cur_op->buf = malloc(cfg_str.size()+1);
|
|
||||||
memcpy(cur_op->buf, cfg_str.c_str(), cfg_str.size()+1);
|
|
||||||
auto & cl = clients[cur_op->peer_fd];
|
|
||||||
cur_op->send_list.push_back(cur_op->buf, cur_op->reply.hdr.retval);
|
|
||||||
outbox_push(cl, cur_op);
|
|
||||||
}
|
|
||||||
|
|
||||||
void osd_t::exec_sync_stab_all(osd_op_t *cur_op)
|
|
||||||
{
|
|
||||||
// Sync and stabilize all objects
|
|
||||||
// This command is only valid for tests
|
|
||||||
cur_op->bs_op = new blockstore_op_t();
|
|
||||||
if (!allow_test_ops)
|
|
||||||
{
|
|
||||||
cur_op->bs_op->retval = -EINVAL;
|
|
||||||
secondary_op_callback(cur_op);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cur_op->bs_op->opcode = BS_OP_SYNC_STAB_ALL;
|
|
||||||
cur_op->bs_op->callback = [this, cur_op](blockstore_op_t *bs_op)
|
|
||||||
{
|
|
||||||
secondary_op_callback(cur_op);
|
|
||||||
};
|
|
||||||
#ifdef OSD_STUB
|
|
||||||
cur_op->bs_op->retval = 0;
|
|
||||||
secondary_op_callback(cur_op);
|
|
||||||
#else
|
|
||||||
bs->enqueue_op(cur_op->bs_op);
|
|
||||||
#endif
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue