Compare commits
32
Commits
kv-readahead
...
v2.2.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97bb809b54 | ||
|
|
6022a61329 | ||
|
|
a3c1996101 | ||
|
|
8d2a1f0297 | ||
|
|
91cbc313c2 | ||
|
|
f0a025428e | ||
|
|
67071158bd | ||
|
|
cd028612c8 | ||
|
|
f390e73dae | ||
|
|
de2539c491 | ||
|
|
957a4fce7e | ||
|
|
f201ecdd51 | ||
|
|
4afb617f59 | ||
|
|
d3fde0569f | ||
|
|
438b64f6c3 | ||
|
|
2b0a802ea1 | ||
|
|
0dd49c1d67 | ||
|
|
410170db96 | ||
|
|
7d8523e0e5 | ||
|
|
db915184c6 | ||
|
|
5ae6fea49c | ||
|
|
95ec750b8c | ||
|
|
90b1de307b | ||
|
|
7e6a95c678 | ||
|
|
b2416afb28 | ||
|
|
66dc116f60 | ||
|
|
0cb8629ab6 | ||
|
|
b7322a405a | ||
|
|
5692630005 | ||
|
|
00ced7cea7 | ||
|
|
ebdb75e287 | ||
|
|
f397fe9c6a |
@@ -684,6 +684,24 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
|
||||||
|
test_write_iothreads:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
container: ${{env.TEST_IMAGE}}:${{github.sha}}
|
||||||
|
steps:
|
||||||
|
- name: Run test
|
||||||
|
id: test
|
||||||
|
timeout-minutes: 3
|
||||||
|
run: TEST_NAME=iothreads GLOBAL_CONFIG=',"client_iothread_count":4' /root/vitastor/tests/test_write.sh
|
||||||
|
- name: Print logs
|
||||||
|
if: always() && steps.test.outcome == 'failure'
|
||||||
|
run: |
|
||||||
|
for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do
|
||||||
|
echo "-------- $i --------"
|
||||||
|
cat $i
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
test_write_no_same:
|
test_write_no_same:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
needs: build
|
||||||
@@ -720,6 +738,24 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
|
||||||
|
test_heal_local_read:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
container: ${{env.TEST_IMAGE}}:${{github.sha}}
|
||||||
|
steps:
|
||||||
|
- name: Run test
|
||||||
|
id: test
|
||||||
|
timeout-minutes: 10
|
||||||
|
run: TEST_NAME=local_read POOLCFG='"local_reads":"random",' /root/vitastor/tests/test_heal.sh
|
||||||
|
- name: Print logs
|
||||||
|
if: always() && steps.test.outcome == 'failure'
|
||||||
|
run: |
|
||||||
|
for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do
|
||||||
|
echo "-------- $i --------"
|
||||||
|
cat $i
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
test_heal_ec:
|
test_heal_ec:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
needs: build
|
||||||
|
|||||||
+1
-1
@@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 2.8.12)
|
|||||||
|
|
||||||
project(vitastor)
|
project(vitastor)
|
||||||
|
|
||||||
set(VITASTOR_VERSION "2.1.0")
|
set(VITASTOR_VERSION "2.2.2")
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
VITASTOR_VERSION ?= v2.1.0
|
VITASTOR_VERSION ?= v2.2.2
|
||||||
|
|
||||||
all: build push
|
all: build push
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ spec:
|
|||||||
capabilities:
|
capabilities:
|
||||||
add: ["SYS_ADMIN"]
|
add: ["SYS_ADMIN"]
|
||||||
allowPrivilegeEscalation: true
|
allowPrivilegeEscalation: true
|
||||||
image: vitalif/vitastor-csi:v2.1.0
|
image: vitalif/vitastor-csi:v2.2.2
|
||||||
args:
|
args:
|
||||||
- "--node=$(NODE_ID)"
|
- "--node=$(NODE_ID)"
|
||||||
- "--endpoint=$(CSI_ENDPOINT)"
|
- "--endpoint=$(CSI_ENDPOINT)"
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ spec:
|
|||||||
privileged: true
|
privileged: true
|
||||||
capabilities:
|
capabilities:
|
||||||
add: ["SYS_ADMIN"]
|
add: ["SYS_ADMIN"]
|
||||||
image: vitalif/vitastor-csi:v2.1.0
|
image: vitalif/vitastor-csi:v2.2.2
|
||||||
args:
|
args:
|
||||||
- "--node=$(NODE_ID)"
|
- "--node=$(NODE_ID)"
|
||||||
- "--endpoint=$(CSI_ENDPOINT)"
|
- "--endpoint=$(CSI_ENDPOINT)"
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ package vitastor
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
vitastorCSIDriverName = "csi.vitastor.io"
|
vitastorCSIDriverName = "csi.vitastor.io"
|
||||||
vitastorCSIDriverVersion = "2.1.0"
|
vitastorCSIDriverVersion = "2.2.2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config struct fills the parameters of request or user input
|
// Config struct fills the parameters of request or user input
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
vitastor (2.1.0-1) unstable; urgency=medium
|
vitastor (2.2.2-1) unstable; urgency=medium
|
||||||
|
|
||||||
* Bugfixes
|
* Bugfixes
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
VITASTOR_VERSION ?= v2.1.0
|
VITASTOR_VERSION ?= v2.2.2
|
||||||
|
|
||||||
all: build push
|
all: build push
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Desired Vitastor version
|
# Desired Vitastor version
|
||||||
VITASTOR_VERSION=v2.1.0
|
VITASTOR_VERSION=v2.2.2
|
||||||
|
|
||||||
# Additional arguments for all containers
|
# Additional arguments for all containers
|
||||||
# For example, you may want to specify a custom logging driver here
|
# For example, you may want to specify a custom logging driver here
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ affect their interaction with the cluster.
|
|||||||
- [nbd_max_devices](#nbd_max_devices)
|
- [nbd_max_devices](#nbd_max_devices)
|
||||||
- [nbd_max_part](#nbd_max_part)
|
- [nbd_max_part](#nbd_max_part)
|
||||||
- [osd_nearfull_ratio](#osd_nearfull_ratio)
|
- [osd_nearfull_ratio](#osd_nearfull_ratio)
|
||||||
|
- [hostname](#hostname)
|
||||||
|
|
||||||
## client_iothread_count
|
## client_iothread_count
|
||||||
|
|
||||||
@@ -215,3 +216,12 @@ just one OSD becomes 100 % full!
|
|||||||
However, unlike in Ceph, 100 % full Vitastor OSDs don't crash (in Ceph they're
|
However, unlike in Ceph, 100 % full Vitastor OSDs don't crash (in Ceph they're
|
||||||
unable to start at all), so you'll be able to recover from "out of space" errors
|
unable to start at all), so you'll be able to recover from "out of space" errors
|
||||||
without destroying and recreating OSDs.
|
without destroying and recreating OSDs.
|
||||||
|
|
||||||
|
## hostname
|
||||||
|
|
||||||
|
- Type: string
|
||||||
|
- Can be changed online: yes
|
||||||
|
|
||||||
|
Clients use host name to find their distance to OSDs when [localized reads](pool.en.md#local_reads)
|
||||||
|
are enabled. By default, standard [gethostname](https://man7.org/linux/man-pages/man2/gethostname.2.html)
|
||||||
|
function is used to determine host name, but you can also override it with this parameter.
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
- [nbd_max_devices](#nbd_max_devices)
|
- [nbd_max_devices](#nbd_max_devices)
|
||||||
- [nbd_max_part](#nbd_max_part)
|
- [nbd_max_part](#nbd_max_part)
|
||||||
- [osd_nearfull_ratio](#osd_nearfull_ratio)
|
- [osd_nearfull_ratio](#osd_nearfull_ratio)
|
||||||
|
- [hostname](#hostname)
|
||||||
|
|
||||||
## client_iothread_count
|
## client_iothread_count
|
||||||
|
|
||||||
@@ -219,3 +220,13 @@ RDMA и хотите повысить пиковую производитель
|
|||||||
заполненные на 100% OSD вообще не могут стартовать), так что вы сможете
|
заполненные на 100% OSD вообще не могут стартовать), так что вы сможете
|
||||||
восстановить работу кластера после ошибок отсутствия свободного места
|
восстановить работу кластера после ошибок отсутствия свободного места
|
||||||
без уничтожения и пересоздания OSD.
|
без уничтожения и пересоздания OSD.
|
||||||
|
|
||||||
|
## hostname
|
||||||
|
|
||||||
|
- Тип: строка
|
||||||
|
- Можно менять на лету: да
|
||||||
|
|
||||||
|
Клиенты используют имя хоста для определения расстояния до OSD, когда включены
|
||||||
|
[локальные чтения](pool.ru.md#local_reads). По умолчанию для определения имени
|
||||||
|
хоста используется стандартная функция [gethostname](https://man7.org/linux/man-pages/man2/gethostname.2.html),
|
||||||
|
но вы также можете задать имя хоста вручную данным параметром.
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ with an OSD restart or, for some of them, even without restarting by updating co
|
|||||||
- [discard_on_start](#discard_on_start)
|
- [discard_on_start](#discard_on_start)
|
||||||
- [min_discard_size](#min_discard_size)
|
- [min_discard_size](#min_discard_size)
|
||||||
- [allow_net_split](#allow_net_split)
|
- [allow_net_split](#allow_net_split)
|
||||||
|
- [enable_pg_locks](#enable_pg_locks)
|
||||||
|
- [pg_lock_retry_interval_ms](#pg_lock_retry_interval_ms)
|
||||||
|
|
||||||
## bind_address
|
## bind_address
|
||||||
|
|
||||||
@@ -647,3 +649,20 @@ The downside is that it increases the probability of writing data into just pg_m
|
|||||||
OSDs during failover which can lead to PGs becoming incomplete after additional outages.
|
OSDs during failover which can lead to PGs becoming incomplete after additional outages.
|
||||||
|
|
||||||
The old behaviour in versions up to 2.0.0 was equal to enabled allow_net_split.
|
The old behaviour in versions up to 2.0.0 was equal to enabled allow_net_split.
|
||||||
|
|
||||||
|
## enable_pg_locks
|
||||||
|
|
||||||
|
- Type: boolean
|
||||||
|
|
||||||
|
Vitastor 2.2.0 introduces a new layer of split-brain prevention mechanism in
|
||||||
|
addition to etcd: PG locks. They prevent split-brain even in abnormal theoretical cases
|
||||||
|
when etcd is extremely laggy. As a new feature, by default, PG locks are only enabled
|
||||||
|
for pools where they're required - pools with [localized reads](pool.en.md#local_reads).
|
||||||
|
Use this parameter to enable or disable this function for all pools.
|
||||||
|
|
||||||
|
## pg_lock_retry_interval_ms
|
||||||
|
|
||||||
|
- Type: milliseconds
|
||||||
|
- Default: 100
|
||||||
|
|
||||||
|
Retry interval for failed PG lock attempts.
|
||||||
|
|||||||
@@ -64,6 +64,8 @@
|
|||||||
- [discard_on_start](#discard_on_start)
|
- [discard_on_start](#discard_on_start)
|
||||||
- [min_discard_size](#min_discard_size)
|
- [min_discard_size](#min_discard_size)
|
||||||
- [allow_net_split](#allow_net_split)
|
- [allow_net_split](#allow_net_split)
|
||||||
|
- [enable_pg_locks](#enable_pg_locks)
|
||||||
|
- [pg_lock_retry_interval_ms](#pg_lock_retry_interval_ms)
|
||||||
|
|
||||||
## bind_address
|
## bind_address
|
||||||
|
|
||||||
@@ -679,3 +681,21 @@ pg_minsize OSD во время переключений, что может по
|
|||||||
неполными (incomplete), если упадут ещё какие-то OSD.
|
неполными (incomplete), если упадут ещё какие-то OSD.
|
||||||
|
|
||||||
Старое поведение в версиях до 2.0.0 было идентично включённому allow_net_split.
|
Старое поведение в версиях до 2.0.0 было идентично включённому allow_net_split.
|
||||||
|
|
||||||
|
## enable_pg_locks
|
||||||
|
|
||||||
|
- Тип: булево (да/нет)
|
||||||
|
|
||||||
|
В Vitastor 2.2.0 появился новый слой защиты от сплитбрейна в дополнение к etcd -
|
||||||
|
блокировки PG. Они гарантируют порядок даже в теоретических ненормальных случаях,
|
||||||
|
когда etcd очень сильно тормозит. Так как функция новая, по умолчанию она включается
|
||||||
|
только для пулов, в которых она необходима - а именно, в пулах с включёнными
|
||||||
|
[локальными чтениями](pool.ru.md#local_reads). Ну а с помощью данного параметра
|
||||||
|
можно включить блокировки PG для всех пулов.
|
||||||
|
|
||||||
|
## pg_lock_retry_interval_ms
|
||||||
|
|
||||||
|
- Тип: миллисекунды
|
||||||
|
- Значение по умолчанию: 100
|
||||||
|
|
||||||
|
Интервал повтора неудачных попыток блокировки PG.
|
||||||
|
|||||||
+28
-2
@@ -34,6 +34,7 @@ Parameters:
|
|||||||
- [failure_domain](#failure_domain)
|
- [failure_domain](#failure_domain)
|
||||||
- [level_placement](#level_placement)
|
- [level_placement](#level_placement)
|
||||||
- [raw_placement](#raw_placement)
|
- [raw_placement](#raw_placement)
|
||||||
|
- [local_reads](#local_reads)
|
||||||
- [max_osd_combinations](#max_osd_combinations)
|
- [max_osd_combinations](#max_osd_combinations)
|
||||||
- [block_size](#block_size)
|
- [block_size](#block_size)
|
||||||
- [bitmap_granularity](#bitmap_granularity)
|
- [bitmap_granularity](#bitmap_granularity)
|
||||||
@@ -133,8 +134,8 @@ Pool name.
|
|||||||
## scheme
|
## scheme
|
||||||
|
|
||||||
- Type: string
|
- Type: string
|
||||||
- Required
|
|
||||||
- One of: "replicated", "xor", "ec" or "jerasure"
|
- One of: "replicated", "xor", "ec" or "jerasure"
|
||||||
|
- Required
|
||||||
|
|
||||||
Redundancy scheme used for data in this pool. "jerasure" is an alias for "ec",
|
Redundancy scheme used for data in this pool. "jerasure" is an alias for "ec",
|
||||||
both use Reed-Solomon-Vandermonde codes based on ISA-L or jerasure libraries.
|
both use Reed-Solomon-Vandermonde codes based on ISA-L or jerasure libraries.
|
||||||
@@ -289,6 +290,30 @@ Examples:
|
|||||||
- EC 4+2 in 3 DC: `any, dc=1 host!=1, dc!=1, dc=3 host!=3, dc!=(1,3), dc=5 host!=5`
|
- EC 4+2 in 3 DC: `any, dc=1 host!=1, dc!=1, dc=3 host!=3, dc!=(1,3), dc=5 host!=5`
|
||||||
- 1 replica in fixed DC + 2 in random DCs: `dc?=meow, dc!=1, dc!=(1,2)`
|
- 1 replica in fixed DC + 2 in random DCs: `dc?=meow, dc!=1, dc!=(1,2)`
|
||||||
|
|
||||||
|
## local_reads
|
||||||
|
|
||||||
|
- Type: string
|
||||||
|
- One of: "primary", "nearest" or "random"
|
||||||
|
- Default: primary
|
||||||
|
|
||||||
|
By default, Vitastor serves all read and write requests from the primary OSD of each PG.
|
||||||
|
But it can also serve read requests for replicated pools from secondary OSDs in clean PGs
|
||||||
|
(active or active+left_on_dead) which may be useful if you have OSDs with different network
|
||||||
|
latency to the client - for example, if you have a cross-datacenter setup.
|
||||||
|
|
||||||
|
If you set this parameter to "nearest", clients will try to read from the nearest OSD
|
||||||
|
in the [Placement Tree](#placement-tree), i.e. from an OSD from the same host or datacenter.
|
||||||
|
Distance to different OSDs will be calculated based on client hostname, determined
|
||||||
|
automatically or set manually in the [hostname](client.en.md#hostname) parameter.
|
||||||
|
|
||||||
|
If you set this parameter to "random", clients will try to distribute read requests over
|
||||||
|
all available secondary OSDs. This mode is mainly useful for tests, but, probably, not
|
||||||
|
really required in production setups.
|
||||||
|
|
||||||
|
[PG locks](osd.en.md#enable_pg_locks) are required for local reads to function. However,
|
||||||
|
PG locks are enabled automatically by default for pools with enabled local reads, so you
|
||||||
|
don't have to enable them explicitly.
|
||||||
|
|
||||||
## max_osd_combinations
|
## max_osd_combinations
|
||||||
|
|
||||||
- Type: integer
|
- Type: integer
|
||||||
@@ -324,7 +349,8 @@ Read more about this parameter in [Cluster-Wide Disk Layout Parameters](layout-c
|
|||||||
|
|
||||||
## immediate_commit
|
## immediate_commit
|
||||||
|
|
||||||
- Type: string, one of "all", "small" and "none"
|
- Type: string
|
||||||
|
- One of: "all", "small" or "none"
|
||||||
- Default: none
|
- Default: none
|
||||||
|
|
||||||
Immediate commit setting for this pool. The value from /vitastor/config/global
|
Immediate commit setting for this pool. The value from /vitastor/config/global
|
||||||
|
|||||||
+28
-2
@@ -33,6 +33,7 @@
|
|||||||
- [failure_domain](#failure_domain)
|
- [failure_domain](#failure_domain)
|
||||||
- [level_placement](#level_placement)
|
- [level_placement](#level_placement)
|
||||||
- [raw_placement](#raw_placement)
|
- [raw_placement](#raw_placement)
|
||||||
|
- [local_reads](#local_reads)
|
||||||
- [max_osd_combinations](#max_osd_combinations)
|
- [max_osd_combinations](#max_osd_combinations)
|
||||||
- [block_size](#block_size)
|
- [block_size](#block_size)
|
||||||
- [bitmap_granularity](#bitmap_granularity)
|
- [bitmap_granularity](#bitmap_granularity)
|
||||||
@@ -133,8 +134,8 @@ OSD игнорируется и OSD не удаляется из распред
|
|||||||
## scheme
|
## scheme
|
||||||
|
|
||||||
- Тип: строка
|
- Тип: строка
|
||||||
- Обязательный
|
|
||||||
- Возможные значения: "replicated", "xor", "ec" или "jerasure"
|
- Возможные значения: "replicated", "xor", "ec" или "jerasure"
|
||||||
|
- Обязательный
|
||||||
|
|
||||||
Схема избыточности, используемая в данном пуле. "jerasure" - синоним для "ec",
|
Схема избыточности, используемая в данном пуле. "jerasure" - синоним для "ec",
|
||||||
в обеих схемах используются коды Рида-Соломона-Вандермонда, реализованные на
|
в обеих схемах используются коды Рида-Соломона-Вандермонда, реализованные на
|
||||||
@@ -287,6 +288,30 @@ meow недоступен".
|
|||||||
- EC 4+2 в 3 датацентрах: `any, dc=1 host!=1, dc!=1, dc=3 host!=3, dc!=(1,3), dc=5 host!=5`
|
- EC 4+2 в 3 датацентрах: `any, dc=1 host!=1, dc!=1, dc=3 host!=3, dc!=(1,3), dc=5 host!=5`
|
||||||
- 1 копия в фиксированном ДЦ + 2 в других ДЦ: `dc?=meow, dc!=1, dc!=(1,2)`
|
- 1 копия в фиксированном ДЦ + 2 в других ДЦ: `dc?=meow, dc!=1, dc!=(1,2)`
|
||||||
|
|
||||||
|
## local_reads
|
||||||
|
|
||||||
|
- Тип: строка
|
||||||
|
- Возможные значения: "primary", "nearest" или "random"
|
||||||
|
- По умолчанию: primary
|
||||||
|
|
||||||
|
По умолчанию Vitastor обслуживает все запросы чтения и записи с первичного OSD каждой PG.
|
||||||
|
Однако, в чистых PG (active или active+left_on_dead) реплицированных пулов также есть
|
||||||
|
возможность обслуживать запросы чтения с вторичных OSD, что может быть полезно, если
|
||||||
|
у вас сильно отличается время сетевого обращения от клиента к разным OSD - например,
|
||||||
|
если у вас несколько дата-центров.
|
||||||
|
|
||||||
|
Если данный параметр установлен в значение "nearest", клиенты будут стараться читать с
|
||||||
|
ближайших по [Дереву размещения](#дерево-размещения) OSD, то есть, с OSD с того же хоста
|
||||||
|
или датацентра. Расстояние до разных OSD будет рассчитываться с помощью имени хоста клиента,
|
||||||
|
определяемого автоматически или заданного вручную параметром [hostname](client.ru.md#hostname).
|
||||||
|
|
||||||
|
Если данный параметр установлен в значение "random", клиенты будут стараться распределять
|
||||||
|
запросы чтения по всем доступным вторичным OSD. Этот режим в основном полезен для тестов,
|
||||||
|
но, скорее всего, редко нужен в реальных инсталляциях.
|
||||||
|
|
||||||
|
Для работы локальных чтений требуются [блокировки PG](osd.ru.md#enable_pg_locks). Включать
|
||||||
|
их явно не нужно - они включаются автоматически для пулов с включёнными локальными чтениями.
|
||||||
|
|
||||||
## max_osd_combinations
|
## max_osd_combinations
|
||||||
|
|
||||||
- Тип: целое число
|
- Тип: целое число
|
||||||
@@ -324,7 +349,8 @@ meow недоступен".
|
|||||||
|
|
||||||
## immediate_commit
|
## immediate_commit
|
||||||
|
|
||||||
- Тип: строка "all", "small" или "none"
|
- Тип: строка
|
||||||
|
- Возможные значения: "all", "small" или "none"
|
||||||
- По умолчанию: none
|
- По умолчанию: none
|
||||||
|
|
||||||
Настройка мгновенного коммита для данного пула. Если не задана, используется
|
Настройка мгновенного коммита для данного пула. Если не задана, используется
|
||||||
|
|||||||
@@ -271,3 +271,15 @@
|
|||||||
заполненные на 100% OSD вообще не могут стартовать), так что вы сможете
|
заполненные на 100% OSD вообще не могут стартовать), так что вы сможете
|
||||||
восстановить работу кластера после ошибок отсутствия свободного места
|
восстановить работу кластера после ошибок отсутствия свободного места
|
||||||
без уничтожения и пересоздания OSD.
|
без уничтожения и пересоздания OSD.
|
||||||
|
- name: hostname
|
||||||
|
type: string
|
||||||
|
online: true
|
||||||
|
info: |
|
||||||
|
Clients use host name to find their distance to OSDs when [localized reads](pool.en.md#local_reads)
|
||||||
|
are enabled. By default, standard [gethostname](https://man7.org/linux/man-pages/man2/gethostname.2.html)
|
||||||
|
function is used to determine host name, but you can also override it with this parameter.
|
||||||
|
info_ru: |
|
||||||
|
Клиенты используют имя хоста для определения расстояния до OSD, когда включены
|
||||||
|
[локальные чтения](pool.ru.md#local_reads). По умолчанию для определения имени
|
||||||
|
хоста используется стандартная функция [gethostname](https://man7.org/linux/man-pages/man2/gethostname.2.html),
|
||||||
|
но вы также можете задать имя хоста вручную данным параметром.
|
||||||
|
|||||||
@@ -781,3 +781,23 @@
|
|||||||
неполными (incomplete), если упадут ещё какие-то OSD.
|
неполными (incomplete), если упадут ещё какие-то OSD.
|
||||||
|
|
||||||
Старое поведение в версиях до 2.0.0 было идентично включённому allow_net_split.
|
Старое поведение в версиях до 2.0.0 было идентично включённому allow_net_split.
|
||||||
|
- name: enable_pg_locks
|
||||||
|
type: bool
|
||||||
|
info: |
|
||||||
|
Vitastor 2.2.0 introduces a new layer of split-brain prevention mechanism in
|
||||||
|
addition to etcd: PG locks. They prevent split-brain even in abnormal theoretical cases
|
||||||
|
when etcd is extremely laggy. As a new feature, by default, PG locks are only enabled
|
||||||
|
for pools where they're required - pools with [localized reads](pool.en.md#local_reads).
|
||||||
|
Use this parameter to enable or disable this function for all pools.
|
||||||
|
info_ru: |
|
||||||
|
В Vitastor 2.2.0 появился новый слой защиты от сплитбрейна в дополнение к etcd -
|
||||||
|
блокировки PG. Они гарантируют порядок даже в теоретических ненормальных случаях,
|
||||||
|
когда etcd очень сильно тормозит. Так как функция новая, по умолчанию она включается
|
||||||
|
только для пулов, в которых она необходима - а именно, в пулах с включёнными
|
||||||
|
[локальными чтениями](pool.ru.md#local_reads). Ну а с помощью данного параметра
|
||||||
|
можно включить блокировки PG для всех пулов.
|
||||||
|
- name: pg_lock_retry_interval_ms
|
||||||
|
type: ms
|
||||||
|
default: 100
|
||||||
|
info: Retry interval for failed PG lock attempts.
|
||||||
|
info_ru: Интервал повтора неудачных попыток блокировки PG.
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ at Vitastor Kubernetes operator: https://github.com/Antilles7227/vitastor-operat
|
|||||||
The instruction is very simple.
|
The instruction is very simple.
|
||||||
|
|
||||||
1. Download a Docker image of the desired version: \
|
1. Download a Docker image of the desired version: \
|
||||||
`docker pull vitastor:2.1.0`
|
`docker pull vitastor:v2.2.2`
|
||||||
2. Install scripts to the host system: \
|
2. Install scripts to the host system: \
|
||||||
`docker run --rm -it -v /etc:/host-etc -v /usr/bin:/host-bin vitastor:2.1.0 install.sh`
|
`docker run --rm -it -v /etc:/host-etc -v /usr/bin:/host-bin vitastor:v2.2.2 install.sh`
|
||||||
3. Reload udev rules: \
|
3. Reload udev rules: \
|
||||||
`udevadm control --reload-rules`
|
`udevadm control --reload-rules`
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ Vitastor можно установить в Docker/Podman. При этом etcd,
|
|||||||
Инструкция по установке максимально простая.
|
Инструкция по установке максимально простая.
|
||||||
|
|
||||||
1. Скачайте Docker-образ желаемой версии: \
|
1. Скачайте Docker-образ желаемой версии: \
|
||||||
`docker pull vitastor:2.1.0`
|
`docker pull vitastor:v2.2.2`
|
||||||
2. Установите скрипты в хост-систему командой: \
|
2. Установите скрипты в хост-систему командой: \
|
||||||
`docker run --rm -it -v /etc:/host-etc -v /usr/bin:/host-bin vitastor:2.1.0 install.sh`
|
`docker run --rm -it -v /etc:/host-etc -v /usr/bin:/host-bin vitastor:v2.2.2 install.sh`
|
||||||
3. Перезагрузите правила udev: \
|
3. Перезагрузите правила udev: \
|
||||||
`udevadm control --reload-rules`
|
`udevadm control --reload-rules`
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
# Proxmox VE
|
# Proxmox VE
|
||||||
|
|
||||||
To enable Vitastor support in Proxmox Virtual Environment (6.4-8.1 are supported):
|
To enable Vitastor support in Proxmox Virtual Environment (6.4-8.x are supported):
|
||||||
|
|
||||||
- Add the corresponding Vitastor Debian repository into sources.list on Proxmox hosts:
|
- Add the corresponding Vitastor Debian repository into sources.list on Proxmox hosts:
|
||||||
bookworm for 8.1, pve8.0 for 8.0, bullseye for 7.4, pve7.3 for 7.3, pve7.2 for 7.2, pve7.1 for 7.1, buster for 6.4
|
bookworm for 8.1+, pve8.0 for 8.0, bullseye for 7.4, pve7.3 for 7.3, pve7.2 for 7.2, pve7.1 for 7.1, buster for 6.4
|
||||||
- Install vitastor-client, pve-qemu-kvm, pve-storage-vitastor (* or see note) packages from Vitastor repository
|
- 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)
|
- Define storage in `/etc/pve/storage.cfg` (see below)
|
||||||
- Block network access from VMs to Vitastor network (to OSDs and etcd),
|
- Block network access from VMs to Vitastor network (to OSDs and etcd),
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
# Proxmox VE
|
# Proxmox VE
|
||||||
|
|
||||||
Чтобы подключить Vitastor к Proxmox Virtual Environment (поддерживаются версии 6.4-8.1):
|
Чтобы подключить Vitastor к Proxmox Virtual Environment (поддерживаются версии 6.4-8.x):
|
||||||
|
|
||||||
- Добавьте соответствующий Debian-репозиторий Vitastor в sources.list на хостах Proxmox:
|
- Добавьте соответствующий Debian-репозиторий Vitastor в sources.list на хостах Proxmox:
|
||||||
bookworm для 8.1, pve8.0 для 8.0, bullseye для 7.4, pve7.3 для 7.3, pve7.2 для 7.2, pve7.1 для 7.1, buster для 6.4
|
bookworm для 8.1+, pve8.0 для 8.0, bullseye для 7.4, pve7.3 для 7.3, pve7.2 для 7.2, pve7.1 для 7.1, buster для 6.4
|
||||||
- Установите пакеты vitastor-client, pve-qemu-kvm, pve-storage-vitastor (* или см. сноску) из репозитория Vitastor
|
- Установите пакеты vitastor-client, pve-qemu-kvm, pve-storage-vitastor (* или см. сноску) из репозитория Vitastor
|
||||||
- Определите тип хранилища в `/etc/pve/storage.cfg` (см. ниже)
|
- Определите тип хранилища в `/etc/pve/storage.cfg` (см. ниже)
|
||||||
- Обязательно заблокируйте доступ от виртуальных машин к сети Vitastor (OSD и etcd), т.к. Vitastor (пока) не поддерживает аутентификацию
|
- Обязательно заблокируйте доступ от виртуальных машин к сети Vitastor (OSD и etcd), т.к. Vitastor (пока) не поддерживает аутентификацию
|
||||||
|
|||||||
@@ -125,6 +125,13 @@ All other client-side components are based on the client library:
|
|||||||
all current read/write operations to it fail with EPIPE error and are retried by clients.
|
all current read/write operations to it fail with EPIPE error and are retried by clients.
|
||||||
- After completing all secondary read/write requests, primary OSD sends the response to
|
- After completing all secondary read/write requests, primary OSD sends the response to
|
||||||
the client.
|
the client.
|
||||||
|
- When [localized reads](../config/pool.en.md#local_reads) are enabled for a PG in a
|
||||||
|
replicated pool, and the PG is in an active and clean state (active or
|
||||||
|
active+left_on_dead), the client can send the request to one of secondary OSDs instead
|
||||||
|
of the primary. Secondary OSD checks the [PG lock](../config/osd.en.md#enable_pg_locks)
|
||||||
|
and handles the request locally without communicating to the primary. PG lock is required
|
||||||
|
for the secondary OSD to know for sure that the PG is in clean state and not switching
|
||||||
|
primary at the moment.
|
||||||
|
|
||||||
### Nuances of request handling
|
### Nuances of request handling
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,12 @@
|
|||||||
и если любое из этих соединений отключается, PG перезапускается, а все текущие запросы чтения
|
и если любое из этих соединений отключается, PG перезапускается, а все текущие запросы чтения
|
||||||
и записи в неё завершаются с ошибкой EPIPE, после чего повторяются клиентами.
|
и записи в неё завершаются с ошибкой EPIPE, после чего повторяются клиентами.
|
||||||
- После завершения всех вторичных операций чтения/записи первичный OSD отправляет ответ клиенту.
|
- После завершения всех вторичных операций чтения/записи первичный OSD отправляет ответ клиенту.
|
||||||
|
- Если в реплицированном пуле включены [локализованные чтения](../config/pool.ru.md#local_reads),
|
||||||
|
а PG находится в чистом активном состоянии (active или active+left_on_dead), клиент может
|
||||||
|
послать запрос к одному из вторичных OSD вместо первичного. Вторичный OSD проверяет
|
||||||
|
[блокировку PG](../config/osd.ru.md#enable_pg_locks) и обрабатывает запрос локально, не
|
||||||
|
обращаясь к первичному. Блокировка PG здесь нужна, чтобы вторичный OSD мог точно знать,
|
||||||
|
что PG находится в чистом состоянии и не переключается на другой первичный OSD.
|
||||||
|
|
||||||
### Особенности обработки запросов
|
### Особенности обработки запросов
|
||||||
|
|
||||||
|
|||||||
+84
-10
@@ -10,8 +10,17 @@ Copyright (c) Vitaliy Filippov (vitalif [at] yourcmc.ru), 2019+
|
|||||||
|
|
||||||
Join Vitastor Telegram Chat: https://t.me/vitastor
|
Join Vitastor Telegram Chat: https://t.me/vitastor
|
||||||
|
|
||||||
All server-side code (OSD, Monitor and so on) is licensed under the terms of
|
License: VNPL 1.1 for server-side code and dual VNPL 1.1 + GPL 2.0+ for client tools.
|
||||||
Vitastor Network Public License 1.1 (VNPL 1.1), a copyleft license based on
|
|
||||||
|
Server-side code is licensed only under the terms of VNPL.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## VNPL
|
||||||
|
|
||||||
|
Vitastor Network Public License 1.1 (VNPL 1.1) is a copyleft license based on
|
||||||
GNU GPLv3.0 with the additional "Network Interaction" clause which requires
|
GNU GPLv3.0 with the additional "Network Interaction" clause which requires
|
||||||
opensourcing all programs directly or indirectly interacting with Vitastor
|
opensourcing all programs directly or indirectly interacting with Vitastor
|
||||||
through a computer network and expressly designed to be used in conjunction
|
through a computer network and expressly designed to be used in conjunction
|
||||||
@@ -20,18 +29,83 @@ 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.
|
Free Software License, as listed by the Free Software Foundation.
|
||||||
This is a stricter copyleft license than the Affero GPL.
|
This is a stricter copyleft license than the Affero GPL.
|
||||||
|
|
||||||
Please note that VNPL doesn't require you to open the code of proprietary
|
The idea of VNPL is, in addition to modules linked to Vitastor code in a single
|
||||||
software running inside a VM if it's not specially designed to be used with
|
binary file, to extend copyleft action to micro-service modules only interacting
|
||||||
Vitastor.
|
with it over the network.
|
||||||
|
|
||||||
Basically, you can't use the software in a proprietary environment to provide
|
Basically, you can't use the software in a proprietary environment to provide
|
||||||
its functionality to users without opensourcing all intermediary components
|
its functionality to users without opensourcing all intermediary components
|
||||||
standing between the user and Vitastor or purchasing a commercial license
|
standing between the user and Vitastor or purchasing a commercial license
|
||||||
from the author 😀.
|
from the author 😀.
|
||||||
|
|
||||||
Client libraries (cluster_client and so on) are dual-licensed under the same
|
At the same time, VNPL doesn't impose any restrictions on software *not specially designed*
|
||||||
VNPL 1.1 and also GNU GPL 2.0 or later to allow for compatibility with GPLed
|
to be used with Vitastor, for example, on Windows running inside a VM with a Vitastor disk.
|
||||||
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).
|
## Explanation
|
||||||
GPL 2.0 is also included in this repository as [GPL-2.0.txt](../../GPL-2.0.txt).
|
|
||||||
|
Network copyleft is governed by the clause **13. Remote Network Interaction** of VNPL.
|
||||||
|
|
||||||
|
A program is considered to be a "Proxy Program" if it meets both conditions:
|
||||||
|
- It is specially designed to be used with Vitastor. Basically, it means that the program
|
||||||
|
has any functionality specific to Vitastor and thus "knows" that it works with Vitastor,
|
||||||
|
not with something random.
|
||||||
|
- It interacts with Vitastor directly or indirectly through any programming interface,
|
||||||
|
including API, CLI, network or any wrapper (also considered a Proxy Program itself).
|
||||||
|
|
||||||
|
If, in addition to that:
|
||||||
|
- You give any user an apportunity to interact with Vitastor directly or indirectly through
|
||||||
|
any computer interface including the network or any number of wrappers (Proxy Programs).
|
||||||
|
|
||||||
|
Then VNPL requires you to publish the code of all above Proxy Programs to all above users
|
||||||
|
under the terms of any GPL-compatible license - that is, GPL, LGPL, MIT/BSD or Apache 2,
|
||||||
|
because "GPL compatibility" is treated as an ability to legally include licensed code in
|
||||||
|
a GPL application.
|
||||||
|
|
||||||
|
So, if you have a "Proxy Program", but it's not open to the user who directly or indirectly
|
||||||
|
interacts with Vitastor - you are forbidden to use Vitastor under the terms of VNPL and you
|
||||||
|
need a commercial license which doesn't contain open-source requirements.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
- Vitastor Kubernetes CSI driver which creates PersistentVolumes by calling `vitastor-cli create`.
|
||||||
|
- Yes, it interacts with Vitastor through vitastor-cli.
|
||||||
|
- Yes, it is designed specially for use with Vitastor (it has no sense otherwise).
|
||||||
|
- So, CSI driver **definitely IS** a Proxy Program and must be published under the terms of
|
||||||
|
a free software license.
|
||||||
|
- Windows, installed in a VM with the system disk on Vitastor storage.
|
||||||
|
- Yes, it interacts with Vitastor indirectly - it reads and writes data through the block
|
||||||
|
device interface, emulated by QEMU.
|
||||||
|
- No, it definitely isn't designed specially for use with Vitastor - Windows was created long
|
||||||
|
ago before Vitastor and doesn't know anything about it.
|
||||||
|
- So, Windows **definitely IS NOT** a Proxy Program and VNPL doesn't require to open it.
|
||||||
|
- Cloud control panel which makes requests to Vitastor Kubernetes CSI driver.
|
||||||
|
- Yes, it interacts with Vitastor indirectly through the CSI driver, which is a Proxy Program.
|
||||||
|
- May or may not be designed specially for use with Vitastor. How to determine exactly?
|
||||||
|
Imagine that Vitastor is replaced with any other storage (for example, with a proprietary).
|
||||||
|
Do control panel functions change in any way? If they do (for example, if snapshots stop working),
|
||||||
|
then the panel contains specific functionality and thus is designed specially for use with Vitastor.
|
||||||
|
Otherwise, the panel is universal and isn't designed specially for Vitastor.
|
||||||
|
- So, whether you are required to open-source the panel also **depends** on whether it
|
||||||
|
contains specific functionality or not.
|
||||||
|
|
||||||
|
## Why?
|
||||||
|
|
||||||
|
Because I believe into the spirit of copyleft (Linux wouldn't become so popular without GPL!)
|
||||||
|
and, at the same time, I want to have a way to monetize the product.
|
||||||
|
|
||||||
|
Existing licenses including AGPL are useless for it with an SDS - SDS is a very deeply
|
||||||
|
internal software which is almost definitely invisible to the user and thus AGPL doesn't
|
||||||
|
require anyone to open the code even if they make a proprietary fork.
|
||||||
|
|
||||||
|
And, in fact, the current situation in the world where GPL is though to only restrict direct
|
||||||
|
linking of programs into a single executable file, isn't much correct. Nowadays, programs
|
||||||
|
are more often linked with network API calls, not with /usr/bin/ld, and a software product
|
||||||
|
may consist of dozens of microservices interacting with each other over the network.
|
||||||
|
|
||||||
|
That's why we need VNPL to keep the license sufficiently copyleft.
|
||||||
|
|
||||||
|
## License Texts
|
||||||
|
|
||||||
|
- VNPL 1.1 in English: [VNPL-1.1.txt](../../VNPL-1.1.txt)
|
||||||
|
- VNPL 1.1 in Russian: [VNPL-1.1-RU.txt](../../VNPL-1.1-RU.txt)
|
||||||
|
- GPL 2.0: [GPL-2.0.txt](../../GPL-2.0.txt)
|
||||||
|
|||||||
+74
-5
@@ -12,6 +12,14 @@
|
|||||||
|
|
||||||
Лицензия: VNPL 1.1 на серверный код и двойная VNPL 1.1 + GPL 2.0+ на клиентский.
|
Лицензия: VNPL 1.1 на серверный код и двойная VNPL 1.1 + GPL 2.0+ на клиентский.
|
||||||
|
|
||||||
|
Серверные компоненты распространяются только на условиях VNPL.
|
||||||
|
|
||||||
|
Клиентские библиотеки распространяются на условиях двойной лицензии VNPL 1.0
|
||||||
|
и также на условиях GNU GPL 2.0 или более поздней версии. Так сделано в целях
|
||||||
|
совместимости с таким ПО, как QEMU и fio.
|
||||||
|
|
||||||
|
## VNPL
|
||||||
|
|
||||||
VNPL - "сетевой копилефт", собственная свободная копилефт-лицензия
|
VNPL - "сетевой копилефт", собственная свободная копилефт-лицензия
|
||||||
Vitastor Network Public License 1.1, основанная на GNU GPL 3.0 с дополнительным
|
Vitastor Network Public License 1.1, основанная на GNU GPL 3.0 с дополнительным
|
||||||
условием "Сетевого взаимодействия", требующим распространять все программы,
|
условием "Сетевого взаимодействия", требующим распространять все программы,
|
||||||
@@ -29,9 +37,70 @@ Vitastor Network Public License 1.1, основанная на GNU GPL 3.0 с д
|
|||||||
На Windows и любое другое ПО, не разработанное *специально* для использования
|
На Windows и любое другое ПО, не разработанное *специально* для использования
|
||||||
вместе с Vitastor, никакие ограничения не накладываются.
|
вместе с Vitastor, никакие ограничения не накладываются.
|
||||||
|
|
||||||
Клиентские библиотеки распространяются на условиях двойной лицензии VNPL 1.0
|
## Пояснение
|
||||||
и также на условиях GNU GPL 2.0 или более поздней версии. Так сделано в целях
|
|
||||||
совместимости с таким ПО, как QEMU и fio.
|
|
||||||
|
|
||||||
Вы можете найти полный текст VNPL 1.1 на английском языке в файле [VNPL-1.1.txt](../../VNPL-1.1.txt),
|
Сетевой копилефт регулируется пунктом лицензии **13. Удалённое сетевое взаимодействие**.
|
||||||
VNPL 1.1 на русском языке в файле [VNPL-1.1-RU.txt](../../VNPL-1.1-RU.txt), а GPL 2.0 в файле [GPL-2.0.txt](../../GPL-2.0.txt).
|
|
||||||
|
Программа считается "прокси-программой", если верны оба условия:
|
||||||
|
- Она создана специально для работы вместе с Vitastor. По сути это означает, что программа
|
||||||
|
должна иметь специфичный для Vitastor функционал, то есть, "знать", что она взаимодействует
|
||||||
|
именно с Vitastor.
|
||||||
|
- Она прямо или косвенно взаимодействует с Vitastor через абсолютно любой программный
|
||||||
|
интерфейс, включая любые способы вызова: API, CLI, сеть или через какую-то обёртку (в
|
||||||
|
свою очередь тоже являющуюся прокси-программой).
|
||||||
|
|
||||||
|
Если в дополнение к этому также:
|
||||||
|
- Вы предоставляете любому пользователю возможность взаимодействовать с Vitastor по сети,
|
||||||
|
опять-таки, через любой интерфейс или любую серию "обёрток" (прокси-программ)
|
||||||
|
|
||||||
|
То, согласно VNPL, вы должны открыть код "прокси-программ" **таким пользователям** на условиях
|
||||||
|
любой GPL-совместимой лицензии - то есть, GPL, LGPL, MIT/BSD или Apache 2 - "совместимость с GPL"
|
||||||
|
понимается как возможность включать лицензируемый код в GPL-приложение.
|
||||||
|
|
||||||
|
Соответственно, если у вас есть "прокси-программа", но её код не открыт пользователю,
|
||||||
|
который прямо или косвенно взаимодействует с Vitastor - вам запрещено использовать Vitastor
|
||||||
|
на условиях VNPL и вам нужна коммерческая лицензия, не содержащая требований об открытии кода.
|
||||||
|
|
||||||
|
## Примеры
|
||||||
|
|
||||||
|
- Kubernetes CSI-драйвер Vitastor, создающий PersistentVolume с помощью вызова `vitastor-cli create`.
|
||||||
|
- Да, взаимодействует с Vitastor через vitastor-cli.
|
||||||
|
- Да, создавался специально для работы с Vitastor (иначе в чём же ещё его смысл).
|
||||||
|
- Значит, CSI-драйвер **точно считается** "прокси-программой" и должен быть открыт под свободной
|
||||||
|
лицензией.
|
||||||
|
- Windows, установленный в виртуальную машину на диске Vitastor.
|
||||||
|
- Да, взаимодействует с Vitastor "прямо или косвенно" - пишет и читает данные через интерфейс
|
||||||
|
блочного устройства, эмулируемый QEMU.
|
||||||
|
- Нет, точно не создан *специально для работы с Vitastor* - когда его создавали, никакого
|
||||||
|
Vitastor ещё и в помине не было.
|
||||||
|
- Значит, Windows **точно не считается** "прокси-программой" и на него требования VNPL не распространяются.
|
||||||
|
- Панель управления облака, делающая запросы к Kubernetes CSI-драйверу Vitastor.
|
||||||
|
- Да, взаимодействует с Vitastor косвенно через CSI-драйвер, являющийся "прокси-программой".
|
||||||
|
- Сходу не известно, создавалась ли конкретно для работы с Vitastor. Как понять, да или нет?
|
||||||
|
Представьте, что Vitastor заменён на любую другую систему хранения (например, на проприетарную).
|
||||||
|
Работа панели управления изменится? Если да (например, перестанут работать снапшоты) - значит,
|
||||||
|
панель содержит специфичный функционал и "создана специально для работы с Vitastor".
|
||||||
|
Если нет - значит, специфичного функционала панель не содержит и в принципе она универсальна.
|
||||||
|
- Нужно ли открывать панель - **зависит** от того, содержит она специфичный функционал или нет.
|
||||||
|
|
||||||
|
## Почему так?
|
||||||
|
|
||||||
|
Потому что я одновременно верю в дух копилефт-лицензий (Linux не стал бы так популярен,
|
||||||
|
если бы не GPL!) и хочу иметь возможность монетизации продукта.
|
||||||
|
|
||||||
|
При этом использовать даже AGPL для программной СХД бессмысленно - это глубоко внутреннее
|
||||||
|
ПО, которое пользователь почти наверняка не увидит вообще, поэтому и открывать код никому
|
||||||
|
никогда не придётся, даже при создании производного продукта.
|
||||||
|
|
||||||
|
Да и в целом сложившаяся в мире ситуация, при которой действие GPL ограничивается только
|
||||||
|
прямым связыванием в один исполняемый файл, не очень корректна. В настоящее время программы
|
||||||
|
гораздо чаще интегрируют сетевыми вызовами, а не с помощью /usr/bin/ld, и общий программный
|
||||||
|
продукт может состоять из нескольких десятков микросервисов, взаимодействующих по сети.
|
||||||
|
|
||||||
|
Поэтому для сохранения достаточной "копилефтности" и придумана VNPL.
|
||||||
|
|
||||||
|
## Тексты лицензий
|
||||||
|
|
||||||
|
- VNPL 1.1 на английском языке: [VNPL-1.1.txt](../../VNPL-1.1.txt)
|
||||||
|
- VNPL 1.1 на русском языке: [VNPL-1.1-RU.txt](../../VNPL-1.1-RU.txt)
|
||||||
|
- GPL 2.0: [GPL-2.0.txt](../../GPL-2.0.txt)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
- Recovery of degraded blocks
|
- Recovery of degraded blocks
|
||||||
- Rebalancing (data movement between OSDs)
|
- Rebalancing (data movement between OSDs)
|
||||||
- [Lazy fsync support](../config/layout-cluster.en.md#immediate_commit)
|
- [Lazy fsync support](../config/layout-cluster.en.md#immediate_commit)
|
||||||
|
- [Localized read support](../config/pool.en.md#local_reads) for cross-datacenter setup optimization
|
||||||
- Per-OSD and per-image I/O and space usage statistics in etcd
|
- Per-OSD and per-image I/O and space usage statistics in etcd
|
||||||
- Snapshots and copy-on-write image clones
|
- Snapshots and copy-on-write image clones
|
||||||
- [Write throttling to smooth random write workloads in SSD+HDD configurations](../config/osd.en.md#throttle_small_writes)
|
- [Write throttling to smooth random write workloads in SSD+HDD configurations](../config/osd.en.md#throttle_small_writes)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
- Восстановление деградированных блоков
|
- Восстановление деградированных блоков
|
||||||
- Ребаланс, то есть перемещение данных между OSD (дисками)
|
- Ребаланс, то есть перемещение данных между OSD (дисками)
|
||||||
- [Поддержка "ленивого" fsync (fsync не на каждую операцию)](../config/layout-cluster.ru.md#immediate_commit)
|
- [Поддержка "ленивого" fsync (fsync не на каждую операцию)](../config/layout-cluster.ru.md#immediate_commit)
|
||||||
|
- [Локальные чтения](../config/pool.ru.md#local_reads) для оптимизации при нескольких датацентрах
|
||||||
- Сбор статистики ввода/вывода в etcd
|
- Сбор статистики ввода/вывода в etcd
|
||||||
- Статистика операций ввода/вывода и занятого места в разрезе инодов
|
- Статистика операций ввода/вывода и занятого места в разрезе инодов
|
||||||
- Именование инодов через хранение их метаданных в etcd
|
- Именование инодов через хранение их метаданных в etcd
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
- [Removing a failed disk](#removing-a-failed-disk)
|
- [Removing a failed disk](#removing-a-failed-disk)
|
||||||
- [Adding a disk](#adding-a-disk)
|
- [Adding a disk](#adding-a-disk)
|
||||||
- [Restoring from lost pool configuration](#restoring-from-lost-pool-configuration)
|
- [Restoring from lost pool configuration](#restoring-from-lost-pool-configuration)
|
||||||
|
- [Incompatibility problems](#Incompatibility-problems)
|
||||||
- [Upgrading Vitastor](#upgrading-vitastor)
|
- [Upgrading Vitastor](#upgrading-vitastor)
|
||||||
- [OSD memory usage](#osd-memory-usage)
|
- [OSD memory usage](#osd-memory-usage)
|
||||||
|
|
||||||
@@ -166,6 +167,17 @@ done
|
|||||||
|
|
||||||
After that all PGs should peer and find all previous data.
|
After that all PGs should peer and find all previous data.
|
||||||
|
|
||||||
|
## Incompatibility problems
|
||||||
|
|
||||||
|
### ISA-L 2.31
|
||||||
|
|
||||||
|
⚠ It is FORBIDDEN to use Vitastor 2.1.0 and earlier versions with ISA-L 2.31 and newer if
|
||||||
|
you use EC N+K pools and K > 1 on a CPU with GF-NI instruction support, because it WILL
|
||||||
|
lead to **data loss** during EC recovery.
|
||||||
|
|
||||||
|
If you accidentally upgraded ISA-L to 2.31 but didn't upgrade Vitastor and restarted OSDs,
|
||||||
|
then stop them as soon as possible and either update Vitastor or roll back ISA-L.
|
||||||
|
|
||||||
## Upgrading Vitastor
|
## Upgrading Vitastor
|
||||||
|
|
||||||
Every upcoming Vitastor version is usually compatible with previous both forward
|
Every upcoming Vitastor version is usually compatible with previous both forward
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
- [Удаление неисправного диска](#удаление-неисправного-диска)
|
- [Удаление неисправного диска](#удаление-неисправного-диска)
|
||||||
- [Добавление диска](#добавление-диска)
|
- [Добавление диска](#добавление-диска)
|
||||||
- [Восстановление потерянной конфигурации пулов](#восстановление-потерянной-конфигурации-пулов)
|
- [Восстановление потерянной конфигурации пулов](#восстановление-потерянной-конфигурации-пулов)
|
||||||
|
- [Проблемы несовместимости](#проблемы-несовместимости)
|
||||||
- [Обновление Vitastor](#обновление-vitastor)
|
- [Обновление Vitastor](#обновление-vitastor)
|
||||||
- [Потребление памяти OSD](#потребление-памяти-osd)
|
- [Потребление памяти OSD](#потребление-памяти-osd)
|
||||||
|
|
||||||
@@ -163,6 +164,17 @@ done
|
|||||||
|
|
||||||
После этого все PG должны пройти peering и найти все предыдущие данные.
|
После этого все PG должны пройти peering и найти все предыдущие данные.
|
||||||
|
|
||||||
|
## Проблемы несовместимости
|
||||||
|
|
||||||
|
### ISA-L 2.31
|
||||||
|
|
||||||
|
⚠ ЗАПРЕЩЕНО использовать Vitastor 2.1.0 и более ранних версий с библиотекой ISA-L версии 2.31
|
||||||
|
или более новой, если вы используете EC-пулы N+K и K > 1 на CPU с поддержкой инструкций GF-NI,
|
||||||
|
так как это приведёт к **потере данных** при восстановлении из EC.
|
||||||
|
|
||||||
|
Если вы случайно обновили ISA-L до 2.31, но не обновили Vitastor, и успели перезапустить OSD,
|
||||||
|
то как можно скорее остановите их все и либо обновите Vitastor, либо откатите ISA-L.
|
||||||
|
|
||||||
## Обновление Vitastor
|
## Обновление Vitastor
|
||||||
|
|
||||||
Обычно каждая следующая версия Vitastor совместима с предыдущими и "вперёд", и "назад"
|
Обычно каждая следующая версия Vitastor совместима с предыдущими и "вперёд", и "назад"
|
||||||
|
|||||||
@@ -397,6 +397,7 @@ Optional parameters:
|
|||||||
| `--immediate_commit none` | Put pool only on OSDs with this or larger immediate_commit (none < small < all) |
|
| `--immediate_commit none` | Put pool only on OSDs with this or larger immediate_commit (none < small < all) |
|
||||||
| `--level_placement <rules>` | Use additional failure domain rules (example: "dc=112233") |
|
| `--level_placement <rules>` | Use additional failure domain rules (example: "dc=112233") |
|
||||||
| `--raw_placement <rules>` | Specify raw PG generation rules ([details](../config/pool.en.md#raw_placement)) |
|
| `--raw_placement <rules>` | Specify raw PG generation rules ([details](../config/pool.en.md#raw_placement)) |
|
||||||
|
| `--local_reads primary` | Local read policy for replicated pools: primary, nearest or random |
|
||||||
| `--primary_affinity_tags tags` | Prefer to put primary copies on OSDs with all specified tags |
|
| `--primary_affinity_tags tags` | Prefer to put primary copies on OSDs with all specified tags |
|
||||||
| `--scrub_interval <time>` | Enable regular scrubbing for this pool. Format: number + unit s/m/h/d/M/y |
|
| `--scrub_interval <time>` | Enable regular scrubbing for this pool. Format: number + unit s/m/h/d/M/y |
|
||||||
| `--used_for_app fs:<name>` | Mark pool as used for VitastorFS with metadata in image `<name>` |
|
| `--used_for_app fs:<name>` | Mark pool as used for VitastorFS with metadata in image `<name>` |
|
||||||
|
|||||||
@@ -414,6 +414,7 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
|
|||||||
| `--immediate_commit none` | ...только OSD с этим или большим immediate_commit (none < small < all) |
|
| `--immediate_commit none` | ...только OSD с этим или большим immediate_commit (none < small < all) |
|
||||||
| `--level_placement <rules>` | Задать правила дополнительных доменов отказа (пример: "dc=112233") |
|
| `--level_placement <rules>` | Задать правила дополнительных доменов отказа (пример: "dc=112233") |
|
||||||
| `--raw_placement <rules>` | Задать низкоуровневые правила генерации PG ([детали](../config/pool.ru.md#raw_placement)) |
|
| `--raw_placement <rules>` | Задать низкоуровневые правила генерации PG ([детали](../config/pool.ru.md#raw_placement)) |
|
||||||
|
| `--local_reads primary` | Политика локальных чтений для реплик: primary, nearest или random |
|
||||||
| `--primary_affinity_tags tags` | Предпочитать OSD со всеми данными тегами для роли первичных |
|
| `--primary_affinity_tags tags` | Предпочитать OSD со всеми данными тегами для роли первичных |
|
||||||
| `--scrub_interval <time>` | Включить скрабы с заданным интервалом времени (число + единица s/m/h/d/M/y) |
|
| `--scrub_interval <time>` | Включить скрабы с заданным интервалом времени (число + единица s/m/h/d/M/y) |
|
||||||
| `--pg_stripe_size <number>` | Увеличить блок группировки объектов по PG |
|
| `--pg_stripe_size <number>` | Увеличить блок группировки объектов по PG |
|
||||||
|
|||||||
+1
-1
@@ -110,7 +110,7 @@ function make_hier_tree(global_config, tree)
|
|||||||
if (!(tree[node_id].children||[]).length && (tree[node_id].size||0) <= 0)
|
if (!(tree[node_id].children||[]).length && (tree[node_id].size||0) <= 0)
|
||||||
{
|
{
|
||||||
const parent = tree[node_id].parent;
|
const parent = tree[node_id].parent;
|
||||||
if (parent)
|
if (parent && tree[parent])
|
||||||
{
|
{
|
||||||
tree[parent].children = tree[parent].children.filter(c => c != tree[node_id]);
|
tree[parent].children = tree[parent].children.filter(c => c != tree[node_id]);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vitastor-mon",
|
"name": "vitastor-mon",
|
||||||
"version": "2.1.0",
|
"version": "2.2.2",
|
||||||
"description": "Vitastor SDS monitor service",
|
"description": "Vitastor SDS monitor service",
|
||||||
"main": "mon-main.js",
|
"main": "mon-main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -19,6 +19,6 @@
|
|||||||
"eslint-plugin-node": "^11.1.0"
|
"eslint-plugin-node": "^11.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.1.0"
|
"node": ">=12.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vitastor",
|
"name": "vitastor",
|
||||||
"version": "2.1.0",
|
"version": "2.2.2",
|
||||||
"description": "Low-level native bindings to Vitastor client library",
|
"description": "Low-level native bindings to Vitastor client library",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ from cinder.volume import configuration
|
|||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume import volume_utils
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
VITASTOR_VERSION = '2.1.0'
|
VITASTOR_VERSION = '2.2.2'
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
Name: vitastor
|
Name: vitastor
|
||||||
Version: 2.1.0
|
Version: 2.2.2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: Vitastor, a fast software-defined clustered block storage
|
Summary: Vitastor, a fast software-defined clustered block storage
|
||||||
|
|
||||||
License: Vitastor Network Public License 1.1
|
License: Vitastor Network Public License 1.1
|
||||||
URL: https://vitastor.io/
|
URL: https://vitastor.io/
|
||||||
Source0: vitastor-2.1.0.el7.tar.gz
|
Source0: vitastor-2.2.2.el7.tar.gz
|
||||||
|
|
||||||
BuildRequires: liburing-devel >= 0.6
|
BuildRequires: liburing-devel >= 0.6
|
||||||
BuildRequires: gperftools-devel
|
BuildRequires: gperftools-devel
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
Name: vitastor
|
Name: vitastor
|
||||||
Version: 2.1.0
|
Version: 2.2.2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: Vitastor, a fast software-defined clustered block storage
|
Summary: Vitastor, a fast software-defined clustered block storage
|
||||||
|
|
||||||
License: Vitastor Network Public License 1.1
|
License: Vitastor Network Public License 1.1
|
||||||
URL: https://vitastor.io/
|
URL: https://vitastor.io/
|
||||||
Source0: vitastor-2.1.0.el8.tar.gz
|
Source0: vitastor-2.2.2.el8.tar.gz
|
||||||
|
|
||||||
BuildRequires: liburing-devel >= 0.6
|
BuildRequires: liburing-devel >= 0.6
|
||||||
BuildRequires: gperftools-devel
|
BuildRequires: gperftools-devel
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
Name: vitastor
|
Name: vitastor
|
||||||
Version: 2.1.0
|
Version: 2.2.2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: Vitastor, a fast software-defined clustered block storage
|
Summary: Vitastor, a fast software-defined clustered block storage
|
||||||
|
|
||||||
License: Vitastor Network Public License 1.1
|
License: Vitastor Network Public License 1.1
|
||||||
URL: https://vitastor.io/
|
URL: https://vitastor.io/
|
||||||
Source0: vitastor-2.1.0.el9.tar.gz
|
Source0: vitastor-2.2.2.el9.tar.gz
|
||||||
|
|
||||||
BuildRequires: liburing-devel >= 0.6
|
BuildRequires: liburing-devel >= 0.6
|
||||||
BuildRequires: gperftools-devel
|
BuildRequires: gperftools-devel
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ if("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/local/?$")
|
|||||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DVITASTOR_VERSION="2.1.0")
|
add_definitions(-DVITASTOR_VERSION="2.2.2")
|
||||||
add_definitions(-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wno-sign-compare -Wno-comment -Wno-parentheses -Wno-pointer-arith -fdiagnostics-color=always -fno-omit-frame-pointer -I ${CMAKE_SOURCE_DIR}/src)
|
add_definitions(-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wno-sign-compare -Wno-comment -Wno-parentheses -Wno-pointer-arith -fdiagnostics-color=always -fno-omit-frame-pointer -I ${CMAKE_SOURCE_DIR}/src)
|
||||||
add_link_options(-fno-omit-frame-pointer)
|
add_link_options(-fno-omit-frame-pointer)
|
||||||
if (${WITH_ASAN})
|
if (${WITH_ASAN})
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ add_executable(test_cluster_client
|
|||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
../test/test_cluster_client.cpp
|
../test/test_cluster_client.cpp
|
||||||
pg_states.cpp osd_ops.cpp cluster_client.cpp cluster_client_list.cpp cluster_client_wb.cpp msgr_op.cpp ../test/mock/messenger.cpp msgr_stop.cpp
|
pg_states.cpp osd_ops.cpp cluster_client.cpp cluster_client_list.cpp cluster_client_wb.cpp msgr_op.cpp ../test/mock/messenger.cpp msgr_stop.cpp
|
||||||
etcd_state_client.cpp ../util/timerfd_manager.cpp ../util/str_util.cpp ../util/json_util.cpp ../../json11/json11.cpp
|
etcd_state_client.cpp ../util/timerfd_manager.cpp ../util/addr_util.cpp ../util/str_util.cpp ../util/json_util.cpp ../../json11/json11.cpp
|
||||||
)
|
)
|
||||||
target_compile_definitions(test_cluster_client PUBLIC -D__MOCK__)
|
target_compile_definitions(test_cluster_client PUBLIC -D__MOCK__)
|
||||||
target_include_directories(test_cluster_client BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/src/test/mock)
|
target_include_directories(test_cluster_client BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/src/test/mock)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include "pg_states.h"
|
||||||
#include "cluster_client_impl.h"
|
#include "cluster_client_impl.h"
|
||||||
#include "json_util.h"
|
#include "json_util.h"
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ cluster_client_t::cluster_client_t(ring_loop_t *ringloop, timerfd_manager_t *tfd
|
|||||||
st_cli.on_change_osd_state_hook = [this](uint64_t peer_osd) { on_change_osd_state_hook(peer_osd); };
|
st_cli.on_change_osd_state_hook = [this](uint64_t peer_osd) { on_change_osd_state_hook(peer_osd); };
|
||||||
st_cli.on_change_pool_config_hook = [this]() { on_change_pool_config_hook(); };
|
st_cli.on_change_pool_config_hook = [this]() { on_change_pool_config_hook(); };
|
||||||
st_cli.on_change_pg_state_hook = [this](pool_id_t pool_id, pg_num_t pg_num, osd_num_t prev_primary) { on_change_pg_state_hook(pool_id, pg_num, prev_primary); };
|
st_cli.on_change_pg_state_hook = [this](pool_id_t pool_id, pg_num_t pg_num, osd_num_t prev_primary) { on_change_pg_state_hook(pool_id, pg_num, prev_primary); };
|
||||||
|
st_cli.on_change_node_placement_hook = [this]() { on_change_node_placement_hook(); };
|
||||||
st_cli.on_load_pgs_hook = [this](bool success) { on_load_pgs_hook(success); };
|
st_cli.on_load_pgs_hook = [this](bool success) { on_load_pgs_hook(success); };
|
||||||
st_cli.on_reload_hook = [this]() { st_cli.load_global_config(); };
|
st_cli.on_reload_hook = [this]() { st_cli.load_global_config(); };
|
||||||
|
|
||||||
@@ -470,11 +472,95 @@ void cluster_client_t::on_load_config_hook(json11::Json::object & etcd_global_co
|
|||||||
}
|
}
|
||||||
// log_level
|
// log_level
|
||||||
log_level = config["log_level"].uint64_value();
|
log_level = config["log_level"].uint64_value();
|
||||||
|
// hostname
|
||||||
|
conf_hostname = config["hostname"].string_value();
|
||||||
|
auto new_hostname = conf_hostname != "" ? conf_hostname : gethostname_str();
|
||||||
|
if (new_hostname != client_hostname)
|
||||||
|
{
|
||||||
|
self_tree_metrics.clear();
|
||||||
|
client_hostname = new_hostname;
|
||||||
|
}
|
||||||
msgr.parse_config(config);
|
msgr.parse_config(config);
|
||||||
st_cli.parse_config(config);
|
st_cli.parse_config(config);
|
||||||
st_cli.load_pgs();
|
st_cli.load_pgs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osd_num_t cluster_client_t::select_random_osd(const std::vector<osd_num_t> & osds)
|
||||||
|
{
|
||||||
|
osd_num_t alive_set[osds.size()];
|
||||||
|
int alive_count = 0;
|
||||||
|
for (auto & osd_num: osds)
|
||||||
|
{
|
||||||
|
if (!st_cli.peer_states[osd_num].is_null())
|
||||||
|
alive_set[alive_count++] = osd_num;
|
||||||
|
}
|
||||||
|
if (!alive_count)
|
||||||
|
return 0;
|
||||||
|
return alive_set[lrand48() % alive_count];
|
||||||
|
}
|
||||||
|
|
||||||
|
osd_num_t cluster_client_t::select_nearest_osd(const std::vector<osd_num_t> & osds)
|
||||||
|
{
|
||||||
|
if (!self_tree_metrics.size())
|
||||||
|
{
|
||||||
|
std::string cur_id = client_hostname;
|
||||||
|
int metric = 0;
|
||||||
|
while (self_tree_metrics.find(cur_id) == self_tree_metrics.end())
|
||||||
|
{
|
||||||
|
self_tree_metrics[cur_id] = metric++;
|
||||||
|
json11::Json cur_placement = st_cli.node_placement[cur_id];
|
||||||
|
cur_id = cur_placement["parent"].string_value();
|
||||||
|
}
|
||||||
|
if (cur_id != "")
|
||||||
|
{
|
||||||
|
self_tree_metrics[""] = metric++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
osd_num_t best_osd = 0;
|
||||||
|
int best_metric = -1;
|
||||||
|
for (auto & osd_num: osds)
|
||||||
|
{
|
||||||
|
int metric = -1;
|
||||||
|
auto met_it = osd_tree_metrics.find(osd_num);
|
||||||
|
if (met_it != osd_tree_metrics.end())
|
||||||
|
{
|
||||||
|
metric = met_it->second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto & peer_state = st_cli.peer_states[osd_num];
|
||||||
|
if (!peer_state.is_null())
|
||||||
|
{
|
||||||
|
metric = self_tree_metrics[""];
|
||||||
|
bool first = true;
|
||||||
|
std::string cur_id = std::to_string(osd_num);
|
||||||
|
std::set<std::string> seen;
|
||||||
|
while (seen.find(cur_id) == seen.end())
|
||||||
|
{
|
||||||
|
seen.insert(cur_id);
|
||||||
|
json11::Json cur_placement = st_cli.node_placement[cur_id];
|
||||||
|
std::string cur_parent = cur_placement["parent"].string_value();
|
||||||
|
cur_id = (!first || cur_parent != "" ? cur_parent : peer_state["host"].string_value());
|
||||||
|
first = false;
|
||||||
|
auto self_it = self_tree_metrics.find(cur_id);
|
||||||
|
if (self_it != self_tree_metrics.end())
|
||||||
|
{
|
||||||
|
metric = self_it->second;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
osd_tree_metrics[osd_num] = metric;
|
||||||
|
}
|
||||||
|
if (metric >= 0 && (best_metric < 0 || metric < best_metric))
|
||||||
|
{
|
||||||
|
best_metric = metric;
|
||||||
|
best_osd = osd_num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best_osd;
|
||||||
|
}
|
||||||
|
|
||||||
void cluster_client_t::on_load_pgs_hook(bool success)
|
void cluster_client_t::on_load_pgs_hook(bool success)
|
||||||
{
|
{
|
||||||
for (auto pool_item: st_cli.pool_config)
|
for (auto pool_item: st_cli.pool_config)
|
||||||
@@ -546,6 +632,7 @@ bool cluster_client_t::get_immediate_commit(uint64_t inode)
|
|||||||
|
|
||||||
void cluster_client_t::on_change_osd_state_hook(uint64_t peer_osd)
|
void cluster_client_t::on_change_osd_state_hook(uint64_t peer_osd)
|
||||||
{
|
{
|
||||||
|
osd_tree_metrics.erase(peer_osd);
|
||||||
if (msgr.wanted_peers.find(peer_osd) != msgr.wanted_peers.end())
|
if (msgr.wanted_peers.find(peer_osd) != msgr.wanted_peers.end())
|
||||||
{
|
{
|
||||||
msgr.connect_peer(peer_osd, st_cli.peer_states[peer_osd]);
|
msgr.connect_peer(peer_osd, st_cli.peer_states[peer_osd]);
|
||||||
@@ -553,6 +640,12 @@ void cluster_client_t::on_change_osd_state_hook(uint64_t peer_osd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cluster_client_t::on_change_node_placement_hook()
|
||||||
|
{
|
||||||
|
osd_tree_metrics.clear();
|
||||||
|
self_tree_metrics.clear();
|
||||||
|
}
|
||||||
|
|
||||||
bool cluster_client_t::is_ready()
|
bool cluster_client_t::is_ready()
|
||||||
{
|
{
|
||||||
return pgs_loaded;
|
return pgs_loaded;
|
||||||
@@ -1221,6 +1314,17 @@ int cluster_client_t::try_send(cluster_op_t *op, int i)
|
|||||||
!pg_it->second.pause && pg_it->second.cur_primary)
|
!pg_it->second.pause && pg_it->second.cur_primary)
|
||||||
{
|
{
|
||||||
osd_num_t primary_osd = pg_it->second.cur_primary;
|
osd_num_t primary_osd = pg_it->second.cur_primary;
|
||||||
|
if (pool_cfg.local_reads != POOL_LOCAL_READ_PRIMARY &&
|
||||||
|
pool_cfg.scheme == POOL_SCHEME_REPLICATED &&
|
||||||
|
(op->opcode == OSD_OP_READ || op->opcode == OSD_OP_READ_BITMAP || op->opcode == OSD_OP_READ_CHAIN_BITMAP) &&
|
||||||
|
(pg_it->second.cur_state == PG_ACTIVE || pg_it->second.cur_state == (PG_ACTIVE|PG_LEFT_ON_DEAD)))
|
||||||
|
{
|
||||||
|
osd_num_t nearest_osd = pool_cfg.local_reads == POOL_LOCAL_READ_NEAREST
|
||||||
|
? select_nearest_osd(pg_it->second.target_set)
|
||||||
|
: select_random_osd(pg_it->second.target_set);
|
||||||
|
if (nearest_osd)
|
||||||
|
primary_osd = nearest_osd;
|
||||||
|
}
|
||||||
part->osd_num = primary_osd;
|
part->osd_num = primary_osd;
|
||||||
auto peer_it = msgr.osd_peer_fds.find(primary_osd);
|
auto peer_it = msgr.osd_peer_fds.find(primary_osd);
|
||||||
if (peer_it != msgr.osd_peer_fds.end())
|
if (peer_it != msgr.osd_peer_fds.end())
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public:
|
|||||||
uint64_t client_max_buffered_bytes = 0;
|
uint64_t client_max_buffered_bytes = 0;
|
||||||
uint64_t client_max_buffered_ops = 0;
|
uint64_t client_max_buffered_ops = 0;
|
||||||
uint64_t client_max_writeback_iodepth = 0;
|
uint64_t client_max_writeback_iodepth = 0;
|
||||||
|
std::string conf_hostname;
|
||||||
|
|
||||||
int log_level = 0;
|
int log_level = 0;
|
||||||
int client_retry_interval = 50; // ms
|
int client_retry_interval = 50; // ms
|
||||||
@@ -107,6 +108,10 @@ public:
|
|||||||
bool client_retry_enospc = true;
|
bool client_retry_enospc = true;
|
||||||
int client_wait_up_timeout = 16; // sec (for listings)
|
int client_wait_up_timeout = 16; // sec (for listings)
|
||||||
|
|
||||||
|
std::string client_hostname;
|
||||||
|
std::map<std::string, int> self_tree_metrics;
|
||||||
|
std::map<osd_num_t, int> osd_tree_metrics;
|
||||||
|
|
||||||
int retry_timeout_id = -1;
|
int retry_timeout_id = -1;
|
||||||
int retry_timeout_duration = 0;
|
int retry_timeout_duration = 0;
|
||||||
std::vector<cluster_op_t*> offline_ops;
|
std::vector<cluster_op_t*> offline_ops;
|
||||||
@@ -161,11 +166,14 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
bool affects_osd(uint64_t inode, uint64_t offset, uint64_t len, osd_num_t osd);
|
bool affects_osd(uint64_t inode, uint64_t offset, uint64_t len, osd_num_t osd);
|
||||||
bool affects_pg(uint64_t inode, uint64_t offset, uint64_t len, pool_id_t pool_id, pg_num_t pg_num);
|
bool affects_pg(uint64_t inode, uint64_t offset, uint64_t len, pool_id_t pool_id, pg_num_t pg_num);
|
||||||
|
|
||||||
void on_load_config_hook(json11::Json::object & config);
|
void on_load_config_hook(json11::Json::object & config);
|
||||||
void on_load_pgs_hook(bool success);
|
void on_load_pgs_hook(bool success);
|
||||||
void on_change_pool_config_hook();
|
void on_change_pool_config_hook();
|
||||||
void on_change_pg_state_hook(pool_id_t pool_id, pg_num_t pg_num, osd_num_t prev_primary);
|
void on_change_pg_state_hook(pool_id_t pool_id, pg_num_t pg_num, osd_num_t prev_primary);
|
||||||
void on_change_osd_state_hook(uint64_t peer_osd);
|
void on_change_osd_state_hook(uint64_t peer_osd);
|
||||||
|
void on_change_node_placement_hook();
|
||||||
|
|
||||||
void execute_internal(cluster_op_t *op);
|
void execute_internal(cluster_op_t *op);
|
||||||
void unshift_op(cluster_op_t *op);
|
void unshift_op(cluster_op_t *op);
|
||||||
int continue_rw(cluster_op_t *op);
|
int continue_rw(cluster_op_t *op);
|
||||||
@@ -191,5 +199,8 @@ protected:
|
|||||||
bool check_finish_listing(inode_list_t *lst);
|
bool check_finish_listing(inode_list_t *lst);
|
||||||
void continue_raw_ops(osd_num_t peer_osd);
|
void continue_raw_ops(osd_num_t peer_osd);
|
||||||
|
|
||||||
|
osd_num_t select_random_osd(const std::vector<osd_num_t> & osds);
|
||||||
|
osd_num_t select_nearest_osd(const std::vector<osd_num_t> & osds);
|
||||||
|
|
||||||
friend class writeback_cache_t;
|
friend class writeback_cache_t;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -922,6 +922,19 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
|||||||
pc.used_for_app = "fs:"+pc.used_for_app;
|
pc.used_for_app = "fs:"+pc.used_for_app;
|
||||||
else
|
else
|
||||||
pc.used_for_app = pool_item.second["used_for_app"].as_string();
|
pc.used_for_app = pool_item.second["used_for_app"].as_string();
|
||||||
|
// Local Read Configuration
|
||||||
|
std::string local_reads = pool_item.second["local_reads"].string_value();
|
||||||
|
if (local_reads == "nearest")
|
||||||
|
pc.local_reads = POOL_LOCAL_READ_NEAREST;
|
||||||
|
else if (local_reads == "random")
|
||||||
|
pc.local_reads = POOL_LOCAL_READ_RANDOM;
|
||||||
|
else if (local_reads == "" || local_reads == "primary")
|
||||||
|
pc.local_reads = POOL_LOCAL_READ_PRIMARY;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pc.local_reads = POOL_LOCAL_READ_PRIMARY;
|
||||||
|
fprintf(stderr, "Warning: Pool %u has invalid local_reads, using 'primary'\n", pool_id);
|
||||||
|
}
|
||||||
// Immediate Commit Mode
|
// Immediate Commit Mode
|
||||||
pc.immediate_commit = pool_item.second["immediate_commit"].is_string()
|
pc.immediate_commit = pool_item.second["immediate_commit"].is_string()
|
||||||
? parse_immediate_commit(pool_item.second["immediate_commit"].string_value(), IMMEDIATE_ALL)
|
? parse_immediate_commit(pool_item.second["immediate_commit"].string_value(), IMMEDIATE_ALL)
|
||||||
@@ -1256,6 +1269,13 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (key == etcd_prefix+"/config/node_placement")
|
||||||
|
{
|
||||||
|
// <etcd_prefix>/config/node_placement
|
||||||
|
node_placement = value;
|
||||||
|
if (on_change_node_placement_hook)
|
||||||
|
on_change_node_placement_hook();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t etcd_state_client_t::parse_immediate_commit(const std::string & immediate_commit_str, uint32_t default_value)
|
uint32_t etcd_state_client_t::parse_immediate_commit(const std::string & immediate_commit_str, uint32_t default_value)
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
#define IMMEDIATE_ALL 2
|
#define IMMEDIATE_ALL 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define POOL_LOCAL_READ_PRIMARY 0
|
||||||
|
#define POOL_LOCAL_READ_NEAREST 1
|
||||||
|
#define POOL_LOCAL_READ_RANDOM 2
|
||||||
|
|
||||||
struct etcd_kv_t
|
struct etcd_kv_t
|
||||||
{
|
{
|
||||||
std::string key;
|
std::string key;
|
||||||
@@ -48,21 +52,22 @@ struct pg_config_t
|
|||||||
|
|
||||||
struct pool_config_t
|
struct pool_config_t
|
||||||
{
|
{
|
||||||
bool exists;
|
bool exists = false;
|
||||||
pool_id_t id;
|
pool_id_t id = 0;
|
||||||
std::string name;
|
std::string name;
|
||||||
uint64_t scheme;
|
uint64_t scheme = 0;
|
||||||
uint64_t pg_size, pg_minsize, parity_chunks;
|
uint64_t pg_size = 0, pg_minsize = 0, parity_chunks = 0;
|
||||||
uint32_t data_block_size, bitmap_granularity, immediate_commit;
|
uint32_t data_block_size = 0, bitmap_granularity = 0, immediate_commit = 0;
|
||||||
uint64_t pg_count;
|
uint64_t pg_count = 0;
|
||||||
uint64_t real_pg_count;
|
uint64_t real_pg_count = 0;
|
||||||
std::string failure_domain;
|
std::string failure_domain;
|
||||||
uint64_t max_osd_combinations;
|
uint64_t max_osd_combinations = 0;
|
||||||
uint64_t pg_stripe_size;
|
uint64_t pg_stripe_size = 0;
|
||||||
std::map<pg_num_t, pg_config_t> pg_config;
|
std::map<pg_num_t, pg_config_t> pg_config;
|
||||||
uint64_t scrub_interval;
|
uint64_t scrub_interval = 0;
|
||||||
std::string used_for_app;
|
std::string used_for_app;
|
||||||
int backfillfull;
|
int backfillfull = 0;
|
||||||
|
int local_reads = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct inode_config_t
|
struct inode_config_t
|
||||||
@@ -130,6 +135,7 @@ public:
|
|||||||
std::set<osd_num_t> seen_peers;
|
std::set<osd_num_t> seen_peers;
|
||||||
std::map<inode_t, inode_config_t> inode_config;
|
std::map<inode_t, inode_config_t> inode_config;
|
||||||
std::map<std::string, inode_t> inode_by_name;
|
std::map<std::string, inode_t> inode_by_name;
|
||||||
|
json11::Json node_placement;
|
||||||
|
|
||||||
std::function<void(std::map<std::string, etcd_kv_t> &)> on_change_hook;
|
std::function<void(std::map<std::string, etcd_kv_t> &)> on_change_hook;
|
||||||
std::function<void(json11::Json::object &)> on_load_config_hook;
|
std::function<void(json11::Json::object &)> on_load_config_hook;
|
||||||
@@ -140,6 +146,7 @@ public:
|
|||||||
std::function<void(pool_id_t, pg_num_t, osd_num_t)> on_change_pg_state_hook;
|
std::function<void(pool_id_t, pg_num_t, osd_num_t)> on_change_pg_state_hook;
|
||||||
std::function<void(pool_id_t, pg_num_t)> on_change_pg_history_hook;
|
std::function<void(pool_id_t, pg_num_t)> on_change_pg_history_hook;
|
||||||
std::function<void(osd_num_t)> on_change_osd_state_hook;
|
std::function<void(osd_num_t)> on_change_osd_state_hook;
|
||||||
|
std::function<void()> on_change_node_placement_hook;
|
||||||
std::function<void()> on_reload_hook;
|
std::function<void()> on_reload_hook;
|
||||||
std::function<void(inode_t, bool)> on_inode_change_hook;
|
std::function<void(inode_t, bool)> on_inode_change_hook;
|
||||||
std::function<void(http_co_t *)> on_start_watcher_hook;
|
std::function<void(http_co_t *)> on_start_watcher_hook;
|
||||||
|
|||||||
+13
-10
@@ -188,7 +188,7 @@ void osd_messenger_t::init()
|
|||||||
auto cl = cl_it->second;
|
auto cl = cl_it->second;
|
||||||
cl_it++;
|
cl_it++;
|
||||||
auto peer_fd = cl->peer_fd;
|
auto peer_fd = cl->peer_fd;
|
||||||
if (!cl->osd_num || cl->peer_state != PEER_CONNECTED && cl->peer_state != PEER_RDMA)
|
if (!cl->osd_num && !cl->in_osd_num || cl->peer_state != PEER_CONNECTED && cl->peer_state != PEER_RDMA)
|
||||||
{
|
{
|
||||||
// Do not run keepalive on regular clients
|
// Do not run keepalive on regular clients
|
||||||
continue;
|
continue;
|
||||||
@@ -199,7 +199,7 @@ void osd_messenger_t::init()
|
|||||||
if (!cl->ping_time_remaining)
|
if (!cl->ping_time_remaining)
|
||||||
{
|
{
|
||||||
// Ping timed out, stop the client
|
// Ping timed out, stop the client
|
||||||
fprintf(stderr, "Ping timed out for OSD %ju (client %d), disconnecting peer\n", cl->osd_num, cl->peer_fd);
|
fprintf(stderr, "Ping timed out for OSD %ju (client %d), disconnecting peer\n", cl->in_osd_num ? cl->in_osd_num : cl->osd_num, cl->peer_fd);
|
||||||
stop_client(peer_fd, true);
|
stop_client(peer_fd, true);
|
||||||
// Restart iterator because it may be invalidated
|
// Restart iterator because it may be invalidated
|
||||||
cl_it = clients.upper_bound(peer_fd);
|
cl_it = clients.upper_bound(peer_fd);
|
||||||
@@ -230,7 +230,7 @@ void osd_messenger_t::init()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int fail_fd = (op->reply.hdr.retval != 0 ? op->peer_fd : -1);
|
int fail_fd = (op->reply.hdr.retval != 0 ? op->peer_fd : -1);
|
||||||
auto fail_osd_num = cl->osd_num;
|
auto fail_osd_num = cl->in_osd_num ? cl->in_osd_num : cl->osd_num;
|
||||||
cl->ping_time_remaining = 0;
|
cl->ping_time_remaining = 0;
|
||||||
delete op;
|
delete op;
|
||||||
if (fail_fd >= 0)
|
if (fail_fd >= 0)
|
||||||
@@ -638,7 +638,7 @@ void osd_messenger_t::check_peer_config(osd_client_t *cl)
|
|||||||
// Inform that we're OSD <osd_num>
|
// Inform that we're OSD <osd_num>
|
||||||
payload["osd_num"] = osd_num;
|
payload["osd_num"] = osd_num;
|
||||||
}
|
}
|
||||||
payload["check_sequencing"] = true;
|
payload["features"] = json11::Json::object{ { "check_sequencing", true } };
|
||||||
#ifdef WITH_RDMA
|
#ifdef WITH_RDMA
|
||||||
if (!use_rdmacm && rdma_contexts.size())
|
if (!use_rdmacm && rdma_contexts.size())
|
||||||
{
|
{
|
||||||
@@ -773,12 +773,15 @@ void osd_messenger_t::accept_connections(int listen_fd)
|
|||||||
fcntl(peer_fd, F_SETFL, fcntl(peer_fd, F_GETFL, 0) | O_NONBLOCK);
|
fcntl(peer_fd, F_SETFL, fcntl(peer_fd, F_GETFL, 0) | O_NONBLOCK);
|
||||||
int one = 1;
|
int one = 1;
|
||||||
setsockopt(peer_fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one));
|
setsockopt(peer_fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one));
|
||||||
clients[peer_fd] = new osd_client_t();
|
auto cl = new osd_client_t();
|
||||||
clients[peer_fd]->peer_addr = addr;
|
clients[peer_fd] = cl;
|
||||||
clients[peer_fd]->peer_port = ntohs(((sockaddr_in*)&addr)->sin_port);
|
cl->is_incoming = true;
|
||||||
clients[peer_fd]->peer_fd = peer_fd;
|
cl->peer_addr = addr;
|
||||||
clients[peer_fd]->peer_state = PEER_CONNECTED;
|
cl->peer_addr = addr;
|
||||||
clients[peer_fd]->in_buf = malloc_or_die(receive_buffer_size);
|
cl->peer_port = ntohs(((sockaddr_in*)&addr)->sin_port);
|
||||||
|
cl->peer_fd = peer_fd;
|
||||||
|
cl->peer_state = PEER_CONNECTED;
|
||||||
|
cl->in_buf = malloc_or_die(receive_buffer_size);
|
||||||
// Add FD to epoll
|
// Add FD to epoll
|
||||||
tfd->set_fd_handler(peer_fd, false, [this](int peer_fd, int epoll_events)
|
tfd->set_fd_handler(peer_fd, false, [this](int peer_fd, int epoll_events)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ struct osd_client_t
|
|||||||
int ping_time_remaining = 0;
|
int ping_time_remaining = 0;
|
||||||
int idle_time_remaining = 0;
|
int idle_time_remaining = 0;
|
||||||
osd_num_t osd_num = 0;
|
osd_num_t osd_num = 0;
|
||||||
|
osd_num_t in_osd_num = 0;
|
||||||
|
bool is_incoming = false;
|
||||||
|
|
||||||
void *in_buf = NULL;
|
void *in_buf = NULL;
|
||||||
|
|
||||||
@@ -77,6 +79,7 @@ struct osd_client_t
|
|||||||
osd_op_buf_list_t recv_list;
|
osd_op_buf_list_t recv_list;
|
||||||
uint64_t read_op_id = 1;
|
uint64_t read_op_id = 1;
|
||||||
bool check_sequencing = false;
|
bool check_sequencing = false;
|
||||||
|
bool enable_pg_locks = false;
|
||||||
|
|
||||||
// Incoming operations
|
// Incoming operations
|
||||||
std::vector<osd_op_t*> received_ops;
|
std::vector<osd_op_t*> received_ops;
|
||||||
@@ -96,6 +99,7 @@ struct osd_client_t
|
|||||||
std::vector<osd_op_t*> zc_free_list;
|
std::vector<osd_op_t*> zc_free_list;
|
||||||
|
|
||||||
~osd_client_t();
|
~osd_client_t();
|
||||||
|
void cancel_ops();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct osd_wanted_peer_t
|
struct osd_wanted_peer_t
|
||||||
@@ -233,6 +237,7 @@ public:
|
|||||||
void outbox_push(osd_op_t *cur_op);
|
void outbox_push(osd_op_t *cur_op);
|
||||||
std::function<void(osd_op_t*)> exec_op;
|
std::function<void(osd_op_t*)> exec_op;
|
||||||
std::function<void(osd_num_t)> repeer_pgs;
|
std::function<void(osd_num_t)> repeer_pgs;
|
||||||
|
std::function<void(osd_num_t)> break_pg_locks;
|
||||||
std::function<bool(osd_client_t*, json11::Json)> check_config_hook;
|
std::function<bool(osd_client_t*, json11::Json)> check_config_hook;
|
||||||
void read_requests();
|
void read_requests();
|
||||||
void send_replies();
|
void send_replies();
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ struct osd_op_t
|
|||||||
osd_op_buf_list_t iov;
|
osd_op_buf_list_t iov;
|
||||||
|
|
||||||
~osd_op_t();
|
~osd_op_t();
|
||||||
|
void cancel();
|
||||||
|
|
||||||
bool is_recovery_related();
|
bool is_recovery_related();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ void osd_messenger_t::rdmacm_established(rdma_cm_event *ev)
|
|||||||
cl->peer_fd = conn->peer_fd;
|
cl->peer_fd = conn->peer_fd;
|
||||||
cl->peer_state = PEER_RDMA;
|
cl->peer_state = PEER_RDMA;
|
||||||
cl->connect_timeout_id = -1;
|
cl->connect_timeout_id = -1;
|
||||||
cl->osd_num = peer_osd;
|
cl->in_osd_num = peer_osd;
|
||||||
cl->in_buf = malloc_or_die(receive_buffer_size);
|
cl->in_buf = malloc_or_die(receive_buffer_size);
|
||||||
cl->rdma_conn = rc;
|
cl->rdma_conn = rc;
|
||||||
clients[conn->peer_fd] = cl;
|
clients[conn->peer_fd] = cl;
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ void osd_messenger_t::read_requests()
|
|||||||
for (int i = 0; i < read_ready_clients.size(); i++)
|
for (int i = 0; i < read_ready_clients.size(); i++)
|
||||||
{
|
{
|
||||||
int peer_fd = read_ready_clients[i];
|
int peer_fd = read_ready_clients[i];
|
||||||
osd_client_t *cl = clients[peer_fd];
|
auto cl_it = clients.find(peer_fd);
|
||||||
if (cl->read_msg.msg_iovlen)
|
if (cl_it == clients.end() || !cl_it->second || cl_it->second->read_msg.msg_iovlen)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
auto cl = cl_it->second;
|
||||||
if (cl->read_remaining < receive_buffer_size)
|
if (cl->read_remaining < receive_buffer_size)
|
||||||
{
|
{
|
||||||
cl->read_iov.iov_base = cl->in_buf;
|
cl->read_iov.iov_base = cl->in_buf;
|
||||||
@@ -33,8 +34,12 @@ void osd_messenger_t::read_requests()
|
|||||||
auto iothread = iothreads.size() ? iothreads[peer_fd % iothreads.size()] : NULL;
|
auto iothread = iothreads.size() ? iothreads[peer_fd % iothreads.size()] : NULL;
|
||||||
io_uring_sqe sqe_local;
|
io_uring_sqe sqe_local;
|
||||||
ring_data_t data_local;
|
ring_data_t data_local;
|
||||||
sqe_local.user_data = (uint64_t)&data_local;
|
|
||||||
io_uring_sqe* sqe = (iothread ? &sqe_local : ringloop->get_sqe());
|
io_uring_sqe* sqe = (iothread ? &sqe_local : ringloop->get_sqe());
|
||||||
|
if (iothread)
|
||||||
|
{
|
||||||
|
sqe_local = { .user_data = (uint64_t)&data_local };
|
||||||
|
data_local = {};
|
||||||
|
}
|
||||||
if (!sqe)
|
if (!sqe)
|
||||||
{
|
{
|
||||||
cl->read_msg.msg_iovlen = 0;
|
cl->read_msg.msg_iovlen = 0;
|
||||||
@@ -56,7 +61,8 @@ void osd_messenger_t::read_requests()
|
|||||||
{
|
{
|
||||||
result = -errno;
|
result = -errno;
|
||||||
}
|
}
|
||||||
handle_read(result, cl);
|
// like set_immediate
|
||||||
|
tfd->set_timer_us(0, false, [this, result, cl](int){ handle_read(result, cl); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
read_ready_clients.clear();
|
read_ready_clients.clear();
|
||||||
@@ -228,7 +234,7 @@ bool osd_messenger_t::handle_finished_read(osd_client_t *cl)
|
|||||||
{
|
{
|
||||||
if (cl->read_op->req.hdr.id != cl->read_op_id)
|
if (cl->read_op->req.hdr.id != cl->read_op_id)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Warning: operation sequencing is broken on client %d, stopping client\n", cl->peer_fd);
|
fprintf(stderr, "Warning: operation sequencing is broken on client %d: expected num %ju, got %ju, stopping client\n", cl->peer_fd, cl->read_op_id, cl->read_op->req.hdr.id);
|
||||||
stop_client(cl->peer_fd);
|
stop_client(cl->peer_fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,12 +194,14 @@ bool osd_messenger_t::try_send(osd_client_t *cl)
|
|||||||
auto iothread = iothreads.size() ? iothreads[peer_fd % iothreads.size()] : NULL;
|
auto iothread = iothreads.size() ? iothreads[peer_fd % iothreads.size()] : NULL;
|
||||||
io_uring_sqe sqe_local;
|
io_uring_sqe sqe_local;
|
||||||
ring_data_t data_local;
|
ring_data_t data_local;
|
||||||
sqe_local.user_data = (uint64_t)&data_local;
|
|
||||||
io_uring_sqe* sqe = (iothread ? &sqe_local : ringloop->get_sqe());
|
io_uring_sqe* sqe = (iothread ? &sqe_local : ringloop->get_sqe());
|
||||||
if (!sqe)
|
if (iothread)
|
||||||
{
|
{
|
||||||
return false;
|
sqe_local = { .user_data = (uint64_t)&data_local };
|
||||||
|
data_local = {};
|
||||||
}
|
}
|
||||||
|
if (!sqe)
|
||||||
|
return false;
|
||||||
cl->write_msg.msg_iov = cl->send_list.data();
|
cl->write_msg.msg_iov = cl->send_list.data();
|
||||||
cl->write_msg.msg_iovlen = cl->send_list.size() < IOV_MAX ? cl->send_list.size() : IOV_MAX;
|
cl->write_msg.msg_iovlen = cl->send_list.size() < IOV_MAX ? cl->send_list.size() : IOV_MAX;
|
||||||
cl->refs++;
|
cl->refs++;
|
||||||
@@ -237,7 +239,8 @@ bool osd_messenger_t::try_send(osd_client_t *cl)
|
|||||||
{
|
{
|
||||||
result = -errno;
|
result = -errno;
|
||||||
}
|
}
|
||||||
handle_send(result, false, false, cl);
|
// like set_immediate
|
||||||
|
tfd->set_timer_us(0, false, [this, result, cl](int){ handle_send(result, false, false, cl); });
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-35
@@ -9,38 +9,37 @@
|
|||||||
#include "msgr_rdma.h"
|
#include "msgr_rdma.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void osd_messenger_t::cancel_osd_ops(osd_client_t *cl)
|
void osd_client_t::cancel_ops()
|
||||||
{
|
{
|
||||||
std::vector<osd_op_t*> cancel_ops;
|
std::vector<osd_op_t*> cancel_ops;
|
||||||
cancel_ops.resize(cl->sent_ops.size());
|
cancel_ops.resize(sent_ops.size());
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto p: cl->sent_ops)
|
for (auto p: sent_ops)
|
||||||
{
|
{
|
||||||
cancel_ops[i++] = p.second;
|
cancel_ops[i++] = p.second;
|
||||||
}
|
}
|
||||||
cl->sent_ops.clear();
|
sent_ops.clear();
|
||||||
cl->outbox.clear();
|
|
||||||
for (auto op: cancel_ops)
|
for (auto op: cancel_ops)
|
||||||
{
|
{
|
||||||
cancel_op(op);
|
op->cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void osd_messenger_t::cancel_op(osd_op_t *op)
|
void osd_op_t::cancel()
|
||||||
{
|
{
|
||||||
if (op->op_type == OSD_OP_OUT)
|
if (op_type == OSD_OP_OUT && callback)
|
||||||
{
|
{
|
||||||
op->reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC;
|
reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC;
|
||||||
op->reply.hdr.id = op->req.hdr.id;
|
reply.hdr.id = req.hdr.id;
|
||||||
op->reply.hdr.opcode = op->req.hdr.opcode;
|
reply.hdr.opcode = req.hdr.opcode;
|
||||||
op->reply.hdr.retval = -EPIPE;
|
reply.hdr.retval = -EPIPE;
|
||||||
// Copy lambda to be unaffected by `delete op`
|
// Copy lambda to be unaffected by `delete this`
|
||||||
std::function<void(osd_op_t*)>(op->callback)(op);
|
(std::function<void(osd_op_t*)>(callback))(this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This function is only called in stop_client(), so it's fine to destroy the operation
|
// This function is only called in stop_client(), so it's fine to destroy the operation
|
||||||
delete op;
|
delete this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +62,10 @@ void osd_messenger_t::stop_client(int peer_fd, bool force, bool force_delete)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "[OSD %ju] Stopping client %d (OSD peer %ju)\n", osd_num, peer_fd, cl->osd_num);
|
fprintf(stderr, "[OSD %ju] Stopping client %d (OSD peer %ju)\n", osd_num, peer_fd, cl->osd_num);
|
||||||
}
|
}
|
||||||
|
else if (cl->in_osd_num)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "[OSD %ju] Stopping client %d (incoming OSD peer %ju)\n", osd_num, peer_fd, cl->in_osd_num);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "[OSD %ju] Stopping client %d (regular client)\n", osd_num, peer_fd);
|
fprintf(stderr, "[OSD %ju] Stopping client %d (regular client)\n", osd_num, peer_fd);
|
||||||
@@ -73,8 +76,12 @@ void osd_messenger_t::stop_client(int peer_fd, bool force, bool force_delete)
|
|||||||
cl->peer_state = PEER_STOPPED;
|
cl->peer_state = PEER_STOPPED;
|
||||||
if (cl->osd_num)
|
if (cl->osd_num)
|
||||||
{
|
{
|
||||||
// ...and forget OSD peer
|
auto osd_it = osd_peer_fds.find(cl->osd_num);
|
||||||
osd_peer_fds.erase(cl->osd_num);
|
if (osd_it != osd_peer_fds.end() && osd_it->second == cl->peer_fd)
|
||||||
|
{
|
||||||
|
// ...and forget OSD peer
|
||||||
|
osd_peer_fds.erase(osd_it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifndef __MOCK__
|
#ifndef __MOCK__
|
||||||
// Then remove FD from the eventloop so we don't accidentally read something
|
// Then remove FD from the eventloop so we don't accidentally read something
|
||||||
@@ -101,30 +108,17 @@ void osd_messenger_t::stop_client(int peer_fd, bool force, bool force_delete)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (cl->in_osd_num && break_pg_locks)
|
||||||
|
{
|
||||||
|
// Break PG locks
|
||||||
|
break_pg_locks(cl->in_osd_num);
|
||||||
|
}
|
||||||
if (cl->osd_num)
|
if (cl->osd_num)
|
||||||
{
|
{
|
||||||
// Then repeer PGs because cancel_op() callbacks can try to perform
|
// Then repeer PGs because cancel_op() callbacks can try to perform
|
||||||
// some actions and we need correct PG states to not do something silly
|
// some actions and we need correct PG states to not do something silly
|
||||||
repeer_pgs(cl->osd_num);
|
repeer_pgs(cl->osd_num);
|
||||||
}
|
}
|
||||||
// Then cancel all operations
|
|
||||||
if (cl->read_op)
|
|
||||||
{
|
|
||||||
if (!cl->read_op->callback)
|
|
||||||
{
|
|
||||||
delete cl->read_op;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cancel_op(cl->read_op);
|
|
||||||
}
|
|
||||||
cl->read_op = NULL;
|
|
||||||
}
|
|
||||||
if (cl->osd_num)
|
|
||||||
{
|
|
||||||
// Cancel outbound operations
|
|
||||||
cancel_osd_ops(cl);
|
|
||||||
}
|
|
||||||
// Find the item again because it can be invalidated at this point
|
// Find the item again because it can be invalidated at this point
|
||||||
it = clients.find(peer_fd);
|
it = clients.find(peer_fd);
|
||||||
if (it != clients.end())
|
if (it != clients.end())
|
||||||
@@ -149,6 +143,17 @@ osd_client_t::~osd_client_t()
|
|||||||
close(peer_fd);
|
close(peer_fd);
|
||||||
peer_fd = -1;
|
peer_fd = -1;
|
||||||
}
|
}
|
||||||
|
// Then cancel all operations
|
||||||
|
// Operations have to be canceled only after clearing all references to osd_client_t
|
||||||
|
// because otherwise their buffers may be still present in io_uring asynchronous requests
|
||||||
|
if (read_op)
|
||||||
|
{
|
||||||
|
// read_op may be an incoming op or a continued response for an outbound op
|
||||||
|
read_op->cancel();
|
||||||
|
read_op = NULL;
|
||||||
|
}
|
||||||
|
// Cancel outbound ops
|
||||||
|
cancel_ops();
|
||||||
#ifndef __MOCK__
|
#ifndef __MOCK__
|
||||||
#ifdef WITH_RDMA
|
#ifdef WITH_RDMA
|
||||||
if (rdma_conn)
|
if (rdma_conn)
|
||||||
|
|||||||
@@ -23,4 +23,5 @@ const char* osd_op_names[] = {
|
|||||||
"sec_read_bmp",
|
"sec_read_bmp",
|
||||||
"scrub",
|
"scrub",
|
||||||
"describe",
|
"describe",
|
||||||
|
"sec_lock",
|
||||||
};
|
};
|
||||||
|
|||||||
+35
-6
@@ -31,10 +31,13 @@
|
|||||||
#define OSD_OP_SEC_READ_BMP 16
|
#define OSD_OP_SEC_READ_BMP 16
|
||||||
#define OSD_OP_SCRUB 17
|
#define OSD_OP_SCRUB 17
|
||||||
#define OSD_OP_DESCRIBE 18
|
#define OSD_OP_DESCRIBE 18
|
||||||
#define OSD_OP_MAX 18
|
#define OSD_OP_SEC_LOCK 19
|
||||||
|
#define OSD_OP_MAX 19
|
||||||
#define OSD_RW_MAX 64*1024*1024
|
#define OSD_RW_MAX 64*1024*1024
|
||||||
#define OSD_PROTOCOL_VERSION 1
|
#define OSD_PROTOCOL_VERSION 1
|
||||||
|
|
||||||
#define OSD_OP_RECOVERY_RELATED (uint32_t)1
|
#define OSD_OP_RECOVERY_RELATED (uint32_t)1
|
||||||
|
#define OSD_OP_IGNORE_PG_LOCK (uint32_t)2
|
||||||
|
|
||||||
// Memory alignment for direct I/O (usually 512 bytes)
|
// Memory alignment for direct I/O (usually 512 bytes)
|
||||||
#ifndef DIRECT_IO_ALIGNMENT
|
#ifndef DIRECT_IO_ALIGNMENT
|
||||||
@@ -56,6 +59,9 @@
|
|||||||
#define OSD_DEL_SUPPORT_LEFT_ON_DEAD 1
|
#define OSD_DEL_SUPPORT_LEFT_ON_DEAD 1
|
||||||
#define OSD_DEL_LEFT_ON_DEAD 2
|
#define OSD_DEL_LEFT_ON_DEAD 2
|
||||||
|
|
||||||
|
#define OSD_SEC_LOCK_PG 1
|
||||||
|
#define OSD_SEC_UNLOCK_PG 2
|
||||||
|
|
||||||
// common request and reply headers
|
// common request and reply headers
|
||||||
struct __attribute__((__packed__)) osd_op_header_t
|
struct __attribute__((__packed__)) osd_op_header_t
|
||||||
{
|
{
|
||||||
@@ -94,7 +100,7 @@ struct __attribute__((__packed__)) osd_op_sec_rw_t
|
|||||||
uint32_t len;
|
uint32_t len;
|
||||||
// bitmap/attribute length - bitmap comes after header, but before data
|
// bitmap/attribute length - bitmap comes after header, but before data
|
||||||
uint32_t attr_len;
|
uint32_t attr_len;
|
||||||
// the only possible flag is OSD_OP_RECOVERY_RELATED
|
// OSD_OP_RECOVERY_RELATED, OSD_OP_IGNORE_PG_LOCK
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -116,7 +122,7 @@ struct __attribute__((__packed__)) osd_op_sec_del_t
|
|||||||
object_id oid;
|
object_id oid;
|
||||||
// delete version (automatic or specific)
|
// delete version (automatic or specific)
|
||||||
uint64_t version;
|
uint64_t version;
|
||||||
// the only possible flag is OSD_OP_RECOVERY_RELATED
|
// OSD_OP_RECOVERY_RELATED, OSD_OP_IGNORE_PG_LOCK
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t pad0;
|
uint32_t pad0;
|
||||||
};
|
};
|
||||||
@@ -131,7 +137,7 @@ struct __attribute__((__packed__)) osd_reply_sec_del_t
|
|||||||
struct __attribute__((__packed__)) osd_op_sec_sync_t
|
struct __attribute__((__packed__)) osd_op_sec_sync_t
|
||||||
{
|
{
|
||||||
osd_op_header_t header;
|
osd_op_header_t header;
|
||||||
// the only possible flag is OSD_OP_RECOVERY_RELATED
|
// OSD_OP_RECOVERY_RELATED, OSD_OP_IGNORE_PG_LOCK
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t pad0;
|
uint32_t pad0;
|
||||||
};
|
};
|
||||||
@@ -147,7 +153,7 @@ struct __attribute__((__packed__)) osd_op_sec_stab_t
|
|||||||
osd_op_header_t header;
|
osd_op_header_t header;
|
||||||
// obj_ver_id array length in bytes
|
// obj_ver_id array length in bytes
|
||||||
uint64_t len;
|
uint64_t len;
|
||||||
// the only possible flag is OSD_OP_RECOVERY_RELATED
|
// OSD_OP_RECOVERY_RELATED, OSD_OP_IGNORE_PG_LOCK
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t pad0;
|
uint32_t pad0;
|
||||||
};
|
};
|
||||||
@@ -165,6 +171,8 @@ struct __attribute__((__packed__)) osd_op_sec_read_bmp_t
|
|||||||
osd_op_header_t header;
|
osd_op_header_t header;
|
||||||
// obj_ver_id array length in bytes
|
// obj_ver_id array length in bytes
|
||||||
uint64_t len;
|
uint64_t len;
|
||||||
|
// OSD_OP_RECOVERY_RELATED, OSD_OP_IGNORE_PG_LOCK
|
||||||
|
uint32_t flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __attribute__((__packed__)) osd_reply_sec_read_bmp_t
|
struct __attribute__((__packed__)) osd_reply_sec_read_bmp_t
|
||||||
@@ -173,7 +181,7 @@ struct __attribute__((__packed__)) osd_reply_sec_read_bmp_t
|
|||||||
osd_reply_header_t header;
|
osd_reply_header_t header;
|
||||||
};
|
};
|
||||||
|
|
||||||
// show configuration
|
// show configuration and remember peer information
|
||||||
struct __attribute__((__packed__)) osd_op_show_config_t
|
struct __attribute__((__packed__)) osd_op_show_config_t
|
||||||
{
|
{
|
||||||
osd_op_header_t header;
|
osd_op_header_t header;
|
||||||
@@ -303,6 +311,25 @@ struct __attribute__((__packed__)) osd_reply_describe_item_t
|
|||||||
osd_num_t osd_num; // OSD number
|
osd_num_t osd_num; // OSD number
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// lock/unlock PG for use by a primary OSD
|
||||||
|
struct __attribute__((__packed__)) osd_op_sec_lock_t
|
||||||
|
{
|
||||||
|
osd_op_header_t header;
|
||||||
|
// OSD_SEC_LOCK_PG or OSD_SEC_UNLOCK_PG
|
||||||
|
uint64_t flags;
|
||||||
|
// Pool ID and PG number
|
||||||
|
uint64_t pool_id;
|
||||||
|
uint64_t pg_num;
|
||||||
|
// PG state as calculated by the primary OSD
|
||||||
|
uint64_t pg_state;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct __attribute__((__packed__)) osd_reply_sec_lock_t
|
||||||
|
{
|
||||||
|
osd_reply_header_t header;
|
||||||
|
uint64_t cur_primary;
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME it would be interesting to try to unify blockstore_op and osd_op formats
|
// FIXME it would be interesting to try to unify blockstore_op and osd_op formats
|
||||||
union osd_any_op_t
|
union osd_any_op_t
|
||||||
{
|
{
|
||||||
@@ -313,6 +340,7 @@ union osd_any_op_t
|
|||||||
osd_op_sec_stab_t sec_stab;
|
osd_op_sec_stab_t sec_stab;
|
||||||
osd_op_sec_read_bmp_t sec_read_bmp;
|
osd_op_sec_read_bmp_t sec_read_bmp;
|
||||||
osd_op_sec_list_t sec_list;
|
osd_op_sec_list_t sec_list;
|
||||||
|
osd_op_sec_lock_t sec_lock;
|
||||||
osd_op_show_config_t show_conf;
|
osd_op_show_config_t show_conf;
|
||||||
osd_op_rw_t rw;
|
osd_op_rw_t rw;
|
||||||
osd_op_sync_t sync;
|
osd_op_sync_t sync;
|
||||||
@@ -329,6 +357,7 @@ union osd_any_reply_t
|
|||||||
osd_reply_sec_stab_t sec_stab;
|
osd_reply_sec_stab_t sec_stab;
|
||||||
osd_reply_sec_read_bmp_t sec_read_bmp;
|
osd_reply_sec_read_bmp_t sec_read_bmp;
|
||||||
osd_reply_sec_list_t sec_list;
|
osd_reply_sec_list_t sec_list;
|
||||||
|
osd_reply_sec_lock_t sec_lock;
|
||||||
osd_reply_show_config_t show_conf;
|
osd_reply_show_config_t show_conf;
|
||||||
osd_reply_rw_t rw;
|
osd_reply_rw_t rw;
|
||||||
osd_reply_del_t del;
|
osd_reply_del_t del;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
|||||||
|
|
||||||
Name: Vitastor
|
Name: Vitastor
|
||||||
Description: Vitastor client library
|
Description: Vitastor client library
|
||||||
Version: 2.1.0
|
Version: 2.2.2
|
||||||
Libs: -L${libdir} -lvitastor_client
|
Libs: -L${libdir} -lvitastor_client
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ static const char* help_text =
|
|||||||
" --immediate_commit all Put pool only on OSDs with this or larger immediate_commit (none < small < all)\n"
|
" --immediate_commit all Put pool only on OSDs with this or larger immediate_commit (none < small < all)\n"
|
||||||
" --level_placement <rules> Use additional failure domain rules (example: \"dc=112233\")\n"
|
" --level_placement <rules> Use additional failure domain rules (example: \"dc=112233\")\n"
|
||||||
" --raw_placement <rules> Specify raw PG generation rules (see documentation for details)\n"
|
" --raw_placement <rules> Specify raw PG generation rules (see documentation for details)\n"
|
||||||
|
" --local_reads primary Local read policy for replicated pools: primary, nearest or random\n"
|
||||||
" --primary_affinity_tags tags Prefer to put primary copies on OSDs with all specified tags\n"
|
" --primary_affinity_tags tags Prefer to put primary copies on OSDs with all specified tags\n"
|
||||||
" --scrub_interval <time> Enable regular scrubbing for this pool. Format: number + unit s/m/h/d/M/y\n"
|
" --scrub_interval <time> Enable regular scrubbing for this pool. Format: number + unit s/m/h/d/M/y\n"
|
||||||
" --used_for_app fs:<name> Mark pool as used for VitastorFS with metadata in image <name>\n"
|
" --used_for_app fs:<name> Mark pool as used for VitastorFS with metadata in image <name>\n"
|
||||||
@@ -282,6 +283,7 @@ static json11::Json::object parse_args(int narg, const char *args[])
|
|||||||
!strcmp(opt, "readonly") || !strcmp(opt, "readwrite") ||
|
!strcmp(opt, "readonly") || !strcmp(opt, "readwrite") ||
|
||||||
!strcmp(opt, "force") || !strcmp(opt, "reverse") ||
|
!strcmp(opt, "force") || !strcmp(opt, "reverse") ||
|
||||||
!strcmp(opt, "allow-data-loss") || !strcmp(opt, "allow_data_loss") ||
|
!strcmp(opt, "allow-data-loss") || !strcmp(opt, "allow_data_loss") ||
|
||||||
|
!strcmp(opt, "allow-up") || !strcmp(opt, "allow_up") ||
|
||||||
!strcmp(opt, "down-ok") || !strcmp(opt, "down_ok") ||
|
!strcmp(opt, "down-ok") || !strcmp(opt, "down_ok") ||
|
||||||
!strcmp(opt, "dry-run") || !strcmp(opt, "dry_run") ||
|
!strcmp(opt, "dry-run") || !strcmp(opt, "dry_run") ||
|
||||||
!strcmp(opt, "help") || !strcmp(opt, "all") ||
|
!strcmp(opt, "help") || !strcmp(opt, "all") ||
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ struct cli_fix_t
|
|||||||
.stripe = op->req.describe.min_offset | items[i].role,
|
.stripe = op->req.describe.min_offset | items[i].role,
|
||||||
},
|
},
|
||||||
.version = 0,
|
.version = 0,
|
||||||
|
.flags = OSD_OP_IGNORE_PG_LOCK,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
rm_op->callback = [this, primary_osd, rm_osd_num, rm_count, &obj](osd_op_t *rm_op)
|
rm_op->callback = [this, primary_osd, rm_osd_num, rm_count, &obj](osd_op_t *rm_op)
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
|||||||
}
|
}
|
||||||
else if (key == "name" || key == "scheme" || key == "immediate_commit" ||
|
else if (key == "name" || key == "scheme" || key == "immediate_commit" ||
|
||||||
key == "failure_domain" || key == "root_node" || key == "scrub_interval" || key == "used_for_app" ||
|
key == "failure_domain" || key == "root_node" || key == "scrub_interval" || key == "used_for_app" ||
|
||||||
key == "used_for_fs" || key == "raw_placement")
|
key == "used_for_fs" || key == "raw_placement" || key == "local_reads")
|
||||||
{
|
{
|
||||||
if (!value.is_string())
|
if (!value.is_string())
|
||||||
{
|
{
|
||||||
@@ -165,6 +165,10 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
|||||||
new_cfg["used_for_app"] = "fs:"+new_cfg["used_for_fs"].string_value();
|
new_cfg["used_for_app"] = "fs:"+new_cfg["used_for_fs"].string_value();
|
||||||
new_cfg.erase("used_for_fs");
|
new_cfg.erase("used_for_fs");
|
||||||
}
|
}
|
||||||
|
if (new_cfg.find("local_reads") != new_cfg.end() && new_cfg["local_reads"].string_value() == "primary")
|
||||||
|
{
|
||||||
|
new_cfg.erase("local_reads");
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent autovivification of object keys. Now we don't modify the config, we just check it
|
// Prevent autovivification of object keys. Now we don't modify the config, we just check it
|
||||||
json11::Json cfg = new_cfg;
|
json11::Json cfg = new_cfg;
|
||||||
@@ -340,5 +344,19 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// local_reads
|
||||||
|
if (!cfg["local_reads"].is_null())
|
||||||
|
{
|
||||||
|
auto lr = cfg["local_reads"].string_value();
|
||||||
|
if (lr != "" && lr != "primary" && lr != "nearest" && lr != "random")
|
||||||
|
{
|
||||||
|
return "local_reads must be '', 'primary', 'nearest' or 'random', but it is "+cfg["local_reads"].string_value();
|
||||||
|
}
|
||||||
|
if (lr != "" && lr != "primary" && scheme != POOL_SCHEME_REPLICATED)
|
||||||
|
{
|
||||||
|
return "EC pools don't support localized reads, please clear local_reads or set it to 'primary'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -504,6 +504,7 @@ resume_3:
|
|||||||
{ "failure_domain", "Failure domain" },
|
{ "failure_domain", "Failure domain" },
|
||||||
{ "root_node", "Root node" },
|
{ "root_node", "Root node" },
|
||||||
{ "osd_tags_fmt", "OSD tags" },
|
{ "osd_tags_fmt", "OSD tags" },
|
||||||
|
{ "local_reads", "Local read policy" },
|
||||||
{ "primary_affinity_tags_fmt", "Primary affinity" },
|
{ "primary_affinity_tags_fmt", "Primary affinity" },
|
||||||
{ "block_size_fmt", "Block size" },
|
{ "block_size_fmt", "Block size" },
|
||||||
{ "bitmap_granularity_fmt", "Bitmap granularity" },
|
{ "bitmap_granularity_fmt", "Bitmap granularity" },
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ struct rm_osd_t
|
|||||||
{
|
{
|
||||||
cli_tool_t *parent;
|
cli_tool_t *parent;
|
||||||
|
|
||||||
bool dry_run, force_warning, force_dataloss;
|
bool dry_run, force_warning, force_dataloss, allow_up;
|
||||||
uint64_t etcd_tx_retry_ms = 500;
|
uint64_t etcd_tx_retry_ms = 500;
|
||||||
uint64_t etcd_tx_retries = 10000;
|
uint64_t etcd_tx_retries = 10000;
|
||||||
std::vector<uint64_t> osd_ids;
|
std::vector<uint64_t> osd_ids;
|
||||||
@@ -70,7 +70,7 @@ struct rm_osd_t
|
|||||||
{
|
{
|
||||||
if (parent->cli->st_cli.peer_states.find(osd_id) != parent->cli->st_cli.peer_states.end())
|
if (parent->cli->st_cli.peer_states.find(osd_id) != parent->cli->st_cli.peer_states.end())
|
||||||
{
|
{
|
||||||
is_warning = true;
|
is_warning = !allow_up;
|
||||||
still_up.push_back(osd_id);
|
still_up.push_back(osd_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ struct rm_osd_t
|
|||||||
: strtoupper(e["effect"].string_value())+" PGs"))
|
: strtoupper(e["effect"].string_value())+" PGs"))
|
||||||
)+" after deleting OSD(s).\n";
|
)+" after deleting OSD(s).\n";
|
||||||
}
|
}
|
||||||
if (still_up.size())
|
if (still_up.size() && !allow_up)
|
||||||
error += (still_up.size() == 1 ? "OSD " : "OSDs ") + implode(", ", still_up) +
|
error += (still_up.size() == 1 ? "OSD " : "OSDs ") + implode(", ", still_up) +
|
||||||
(still_up.size() == 1 ? "is" : "are") + " still up. Use `vitastor-disk purge` to delete them.\n";
|
(still_up.size() == 1 ? "is" : "are") + " still up. Use `vitastor-disk purge` to delete them.\n";
|
||||||
if (is_dataloss && !force_dataloss && !dry_run)
|
if (is_dataloss && !force_dataloss && !dry_run)
|
||||||
@@ -476,6 +476,7 @@ std::function<bool(cli_result_t &)> cli_tool_t::start_rm_osd(json11::Json cfg)
|
|||||||
auto rm_osd = new rm_osd_t();
|
auto rm_osd = new rm_osd_t();
|
||||||
rm_osd->parent = this;
|
rm_osd->parent = this;
|
||||||
rm_osd->dry_run = cfg["dry_run"].bool_value();
|
rm_osd->dry_run = cfg["dry_run"].bool_value();
|
||||||
|
rm_osd->allow_up = cfg["allow_up"].bool_value();
|
||||||
rm_osd->force_dataloss = cfg["allow_data_loss"].bool_value();
|
rm_osd->force_dataloss = cfg["allow_data_loss"].bool_value();
|
||||||
rm_osd->force_warning = rm_osd->force_dataloss || cfg["force"].bool_value();
|
rm_osd->force_warning = rm_osd->force_dataloss || cfg["force"].bool_value();
|
||||||
if (!cfg["etcd_tx_retries"].is_null())
|
if (!cfg["etcd_tx_retries"].is_null())
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ int disk_tool_t::purge_devices(const std::vector<std::string> & devices)
|
|||||||
printf("%s\n", json11::Json(result).dump().c_str());
|
printf("%s\n", json11::Json(result).dump().c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::vector<std::string> rm_osd_cli = { "vitastor-cli", "rm-osd" };
|
std::vector<std::string> rm_osd_cli = { "vitastor-cli", "rm-osd", "--allow-up" };
|
||||||
for (auto osd_num: osd_numbers)
|
for (auto osd_num: osd_numbers)
|
||||||
{
|
{
|
||||||
rm_osd_cli.push_back(std::to_string(osd_num));
|
rm_osd_cli.push_back(std::to_string(osd_num));
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ osd_t::osd_t(const json11::Json & config, ring_loop_t *ringloop)
|
|||||||
msgr.ringloop = this->ringloop;
|
msgr.ringloop = this->ringloop;
|
||||||
msgr.exec_op = [this](osd_op_t *op) { exec_op(op); };
|
msgr.exec_op = [this](osd_op_t *op) { exec_op(op); };
|
||||||
msgr.repeer_pgs = [this](osd_num_t peer_osd) { repeer_pgs(peer_osd); };
|
msgr.repeer_pgs = [this](osd_num_t peer_osd) { repeer_pgs(peer_osd); };
|
||||||
|
msgr.break_pg_locks = [this](osd_num_t peer_osd) { break_pg_locks(peer_osd); };
|
||||||
msgr.check_config_hook = [this](osd_client_t *cl, json11::Json conf) { return check_peer_config(cl, conf); };
|
msgr.check_config_hook = [this](osd_client_t *cl, json11::Json conf) { return check_peer_config(cl, conf); };
|
||||||
msgr.init();
|
msgr.init();
|
||||||
|
|
||||||
@@ -271,6 +272,12 @@ void osd_t::parse_config(bool init)
|
|||||||
inode_vanish_time = config["inode_vanish_time"].uint64_value();
|
inode_vanish_time = config["inode_vanish_time"].uint64_value();
|
||||||
if (!inode_vanish_time)
|
if (!inode_vanish_time)
|
||||||
inode_vanish_time = 60;
|
inode_vanish_time = 60;
|
||||||
|
enable_pg_locks = config["enable_pg_locks"].is_null() || json_is_true(config["enable_pg_locks"]);
|
||||||
|
bool old_pg_locks_localize_only = pg_locks_localize_only;
|
||||||
|
pg_locks_localize_only = config["enable_pg_locks"].is_null();
|
||||||
|
pg_lock_retry_interval_ms = config["pg_lock_retry_interval"].uint64_value();
|
||||||
|
if (pg_lock_retry_interval_ms <= 1)
|
||||||
|
pg_lock_retry_interval_ms = 100;
|
||||||
auto old_auto_scrub = auto_scrub;
|
auto old_auto_scrub = auto_scrub;
|
||||||
auto_scrub = json_is_true(config["auto_scrub"]);
|
auto_scrub = json_is_true(config["auto_scrub"]);
|
||||||
global_scrub_interval = parse_time(config["scrub_interval"].string_value());
|
global_scrub_interval = parse_time(config["scrub_interval"].string_value());
|
||||||
@@ -336,6 +343,10 @@ void osd_t::parse_config(bool init)
|
|||||||
{
|
{
|
||||||
apply_recovery_tune_interval();
|
apply_recovery_tune_interval();
|
||||||
}
|
}
|
||||||
|
if (old_pg_locks_localize_only != pg_locks_localize_only)
|
||||||
|
{
|
||||||
|
apply_pg_locks_localize_only();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void osd_t::bind_socket()
|
void osd_t::bind_socket()
|
||||||
@@ -447,6 +458,7 @@ void osd_t::exec_op(osd_op_t *cur_op)
|
|||||||
}
|
}
|
||||||
if (readonly &&
|
if (readonly &&
|
||||||
cur_op->req.hdr.opcode != OSD_OP_SEC_READ &&
|
cur_op->req.hdr.opcode != OSD_OP_SEC_READ &&
|
||||||
|
cur_op->req.hdr.opcode != OSD_OP_SEC_LOCK &&
|
||||||
cur_op->req.hdr.opcode != OSD_OP_SEC_LIST &&
|
cur_op->req.hdr.opcode != OSD_OP_SEC_LIST &&
|
||||||
cur_op->req.hdr.opcode != OSD_OP_READ &&
|
cur_op->req.hdr.opcode != OSD_OP_READ &&
|
||||||
cur_op->req.hdr.opcode != OSD_OP_SEC_READ_BMP &&
|
cur_op->req.hdr.opcode != OSD_OP_SEC_READ_BMP &&
|
||||||
|
|||||||
+26
-3
@@ -92,6 +92,12 @@ struct recovery_stat_t
|
|||||||
uint64_t count, usec, bytes;
|
uint64_t count, usec, bytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct osd_pg_lock_t
|
||||||
|
{
|
||||||
|
osd_num_t primary_osd = 0;
|
||||||
|
uint64_t state = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class osd_t
|
class osd_t
|
||||||
{
|
{
|
||||||
// config
|
// config
|
||||||
@@ -140,6 +146,9 @@ class osd_t
|
|||||||
uint32_t scrub_list_limit = 1000;
|
uint32_t scrub_list_limit = 1000;
|
||||||
bool scrub_find_best = true;
|
bool scrub_find_best = true;
|
||||||
uint64_t scrub_ec_max_bruteforce = 100;
|
uint64_t scrub_ec_max_bruteforce = 100;
|
||||||
|
bool enable_pg_locks = false;
|
||||||
|
bool pg_locks_localize_only = false;
|
||||||
|
uint64_t pg_lock_retry_interval_ms = 100;
|
||||||
|
|
||||||
// cluster state
|
// cluster state
|
||||||
|
|
||||||
@@ -159,6 +168,7 @@ class osd_t
|
|||||||
|
|
||||||
// peers and PGs
|
// peers and PGs
|
||||||
|
|
||||||
|
std::map<pool_pg_num_t, osd_pg_lock_t> pg_locks;
|
||||||
std::map<pool_id_t, pg_num_t> pg_counts;
|
std::map<pool_id_t, pg_num_t> pg_counts;
|
||||||
std::map<pool_pg_num_t, pg_t> pgs;
|
std::map<pool_pg_num_t, pg_t> pgs;
|
||||||
std::set<pool_pg_num_t> dirty_pgs;
|
std::set<pool_pg_num_t> dirty_pgs;
|
||||||
@@ -239,6 +249,8 @@ class osd_t
|
|||||||
void on_change_etcd_state_hook(std::map<std::string, etcd_kv_t> & changes);
|
void on_change_etcd_state_hook(std::map<std::string, etcd_kv_t> & changes);
|
||||||
void on_load_config_hook(json11::Json::object & changes);
|
void on_load_config_hook(json11::Json::object & changes);
|
||||||
void on_reload_config_hook(json11::Json::object & changes);
|
void on_reload_config_hook(json11::Json::object & changes);
|
||||||
|
void on_change_pool_config_hook();
|
||||||
|
void apply_pg_locks_localize_only();
|
||||||
json11::Json on_load_pgs_checks_hook();
|
json11::Json on_load_pgs_checks_hook();
|
||||||
void on_load_pgs_hook(bool success);
|
void on_load_pgs_hook(bool success);
|
||||||
void bind_socket();
|
void bind_socket();
|
||||||
@@ -266,13 +278,20 @@ class osd_t
|
|||||||
void handle_peers();
|
void handle_peers();
|
||||||
bool check_peer_config(osd_client_t *cl, json11::Json conf);
|
bool check_peer_config(osd_client_t *cl, json11::Json conf);
|
||||||
void repeer_pgs(osd_num_t osd_num);
|
void repeer_pgs(osd_num_t osd_num);
|
||||||
|
void repeer_pg(pg_t & pg);
|
||||||
|
void break_pg_locks(osd_num_t osd_num);
|
||||||
void start_pg_peering(pg_t & pg);
|
void start_pg_peering(pg_t & pg);
|
||||||
void drop_dirty_pg_connections(pool_pg_num_t pg);
|
void drop_dirty_pg_connections(pool_pg_num_t pg);
|
||||||
|
void record_pg_lock(pg_t & pg, osd_num_t peer_osd, uint64_t pg_state);
|
||||||
|
void relock_pg(pg_t & pg);
|
||||||
void submit_list_subop(osd_num_t role_osd, pg_peering_state_t *ps);
|
void submit_list_subop(osd_num_t role_osd, pg_peering_state_t *ps);
|
||||||
void discard_list_subop(osd_op_t *list_op);
|
void discard_list_subop(osd_op_t *list_op);
|
||||||
bool stop_pg(pg_t & pg);
|
bool stop_pg(pg_t & pg);
|
||||||
void reset_pg(pg_t & pg);
|
void reset_pg(pg_t & pg);
|
||||||
void finish_stop_pg(pg_t & pg);
|
void finish_stop_pg(pg_t & pg);
|
||||||
|
void rm_inflight(pg_t & pg);
|
||||||
|
void continue_pg(pg_t & pg);
|
||||||
|
bool continue_pg_peering(pg_t & pg);
|
||||||
|
|
||||||
// flushing, recovery and backfill
|
// flushing, recovery and backfill
|
||||||
void submit_pg_flush_ops(pg_t & pg);
|
void submit_pg_flush_ops(pg_t & pg);
|
||||||
@@ -299,10 +318,13 @@ class osd_t
|
|||||||
void finish_op(osd_op_t *cur_op, int retval);
|
void finish_op(osd_op_t *cur_op, int retval);
|
||||||
|
|
||||||
// secondary ops
|
// secondary ops
|
||||||
|
bool sec_check_pg_lock(osd_num_t primary_osd, const object_id &oid);
|
||||||
void exec_sync_stab_all(osd_op_t *cur_op);
|
void exec_sync_stab_all(osd_op_t *cur_op);
|
||||||
void exec_show_config(osd_op_t *cur_op);
|
void exec_show_config(osd_op_t *cur_op);
|
||||||
void exec_secondary(osd_op_t *cur_op);
|
void exec_secondary(osd_op_t *cur_op);
|
||||||
void exec_secondary_real(osd_op_t *cur_op);
|
void exec_secondary_real(osd_op_t *cur_op);
|
||||||
|
void exec_sec_read_bmp(osd_op_t *cur_op);
|
||||||
|
void exec_sec_lock(osd_op_t *cur_op);
|
||||||
void secondary_op_callback(osd_op_t *cur_op);
|
void secondary_op_callback(osd_op_t *cur_op);
|
||||||
|
|
||||||
// primary ops
|
// primary ops
|
||||||
@@ -310,6 +332,7 @@ class osd_t
|
|||||||
bool prepare_primary_rw(osd_op_t *cur_op);
|
bool prepare_primary_rw(osd_op_t *cur_op);
|
||||||
void continue_primary_read(osd_op_t *cur_op);
|
void continue_primary_read(osd_op_t *cur_op);
|
||||||
void continue_primary_scrub(osd_op_t *cur_op);
|
void continue_primary_scrub(osd_op_t *cur_op);
|
||||||
|
void continue_local_secondary_read(osd_op_t *cur_op);
|
||||||
void continue_primary_describe(osd_op_t *cur_op);
|
void continue_primary_describe(osd_op_t *cur_op);
|
||||||
void continue_primary_list(osd_op_t *cur_op);
|
void continue_primary_list(osd_op_t *cur_op);
|
||||||
void continue_primary_write(osd_op_t *cur_op);
|
void continue_primary_write(osd_op_t *cur_op);
|
||||||
@@ -347,13 +370,13 @@ class osd_t
|
|||||||
uint64_t* get_object_osd_set(pg_t &pg, object_id &oid, pg_osd_set_state_t **object_state);
|
uint64_t* get_object_osd_set(pg_t &pg, object_id &oid, pg_osd_set_state_t **object_state);
|
||||||
|
|
||||||
void continue_chained_read(osd_op_t *cur_op);
|
void continue_chained_read(osd_op_t *cur_op);
|
||||||
int submit_chained_read_requests(pg_t & pg, osd_op_t *cur_op);
|
int submit_chained_read_requests(pg_t *pg, osd_op_t *cur_op);
|
||||||
void check_corrupted_chained(pg_t & pg, osd_op_t *cur_op);
|
void check_corrupted_chained(pg_t & pg, osd_op_t *cur_op);
|
||||||
void send_chained_read_results(pg_t & pg, osd_op_t *cur_op);
|
void send_chained_read_results(pg_t *pg, osd_op_t *cur_op);
|
||||||
std::vector<osd_chain_read_t> collect_chained_read_requests(osd_op_t *cur_op);
|
std::vector<osd_chain_read_t> collect_chained_read_requests(osd_op_t *cur_op);
|
||||||
int collect_bitmap_requests(osd_op_t *cur_op, pg_t & pg, std::vector<bitmap_request_t> & bitmap_requests);
|
int collect_bitmap_requests(osd_op_t *cur_op, pg_t & pg, std::vector<bitmap_request_t> & bitmap_requests);
|
||||||
int submit_bitmap_subops(osd_op_t *cur_op, pg_t & pg);
|
int submit_bitmap_subops(osd_op_t *cur_op, pg_t & pg);
|
||||||
int read_bitmaps(osd_op_t *cur_op, pg_t & pg, int base_state);
|
int read_bitmaps(osd_op_t *cur_op, pg_t *pg, int base_state);
|
||||||
|
|
||||||
inline pg_num_t map_to_pg(object_id oid, uint64_t pg_stripe_size)
|
inline pg_num_t map_to_pg(object_id oid, uint64_t pg_stripe_size)
|
||||||
{
|
{
|
||||||
|
|||||||
+61
-27
@@ -65,6 +65,7 @@ void osd_t::init_cluster()
|
|||||||
st_cli.tfd = tfd;
|
st_cli.tfd = tfd;
|
||||||
st_cli.log_level = log_level;
|
st_cli.log_level = log_level;
|
||||||
st_cli.on_change_osd_state_hook = [this](osd_num_t peer_osd) { on_change_osd_state_hook(peer_osd); };
|
st_cli.on_change_osd_state_hook = [this](osd_num_t peer_osd) { on_change_osd_state_hook(peer_osd); };
|
||||||
|
st_cli.on_change_pool_config_hook = [this]() { on_change_pool_config_hook(); };
|
||||||
st_cli.on_change_backfillfull_hook = [this](pool_id_t pool_id) { on_change_backfillfull_hook(pool_id); };
|
st_cli.on_change_backfillfull_hook = [this](pool_id_t pool_id) { on_change_backfillfull_hook(pool_id); };
|
||||||
st_cli.on_change_pg_history_hook = [this](pool_id_t pool_id, pg_num_t pg_num) { on_change_pg_history_hook(pool_id, pg_num); };
|
st_cli.on_change_pg_history_hook = [this](pool_id_t pool_id, pg_num_t pg_num) { on_change_pg_history_hook(pool_id, pg_num); };
|
||||||
st_cli.on_change_hook = [this](std::map<std::string, etcd_kv_t> & changes) { on_change_etcd_state_hook(changes); };
|
st_cli.on_change_hook = [this](std::map<std::string, etcd_kv_t> & changes) { on_change_etcd_state_hook(changes); };
|
||||||
@@ -153,23 +154,19 @@ bool osd_t::check_peer_config(osd_client_t *cl, json11::Json conf)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cl->enable_pg_locks = conf["features"]["pg_locks"].bool_value();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
json11::Json osd_t::get_osd_state()
|
json11::Json osd_t::get_osd_state()
|
||||||
{
|
{
|
||||||
std::vector<char> hostname;
|
|
||||||
hostname.resize(1024);
|
|
||||||
while (gethostname(hostname.data(), hostname.size()) < 0 && errno == ENAMETOOLONG)
|
|
||||||
hostname.resize(hostname.size()+1024);
|
|
||||||
hostname.resize(strnlen(hostname.data(), hostname.size()));
|
|
||||||
json11::Json::object st;
|
json11::Json::object st;
|
||||||
st["state"] = "up";
|
st["state"] = "up";
|
||||||
if (bind_addresses.size() != 1 || bind_addresses[0] != "0.0.0.0")
|
if (bind_addresses.size() != 1 || bind_addresses[0] != "0.0.0.0")
|
||||||
st["addresses"] = bind_addresses;
|
st["addresses"] = bind_addresses;
|
||||||
else
|
else
|
||||||
st["addresses"] = getifaddr_list();
|
st["addresses"] = getifaddr_list();
|
||||||
st["host"] = std::string(hostname.data(), hostname.size());
|
st["host"] = gethostname_str();
|
||||||
st["version"] = VITASTOR_VERSION;
|
st["version"] = VITASTOR_VERSION;
|
||||||
st["port"] = listening_port;
|
st["port"] = listening_port;
|
||||||
#ifdef WITH_RDMACM
|
#ifdef WITH_RDMACM
|
||||||
@@ -419,6 +416,35 @@ void osd_t::on_change_osd_state_hook(osd_num_t peer_osd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void osd_t::on_change_pool_config_hook()
|
||||||
|
{
|
||||||
|
apply_pg_locks_localize_only();
|
||||||
|
}
|
||||||
|
|
||||||
|
void osd_t::apply_pg_locks_localize_only()
|
||||||
|
{
|
||||||
|
for (auto & pp: pgs)
|
||||||
|
{
|
||||||
|
auto pool_it = st_cli.pool_config.find(pp.first.pool_id);
|
||||||
|
if (pool_it == st_cli.pool_config.end())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto & pool_cfg = pool_it->second;
|
||||||
|
auto & pg = pp.second;
|
||||||
|
auto old_disable_pg_locks = pg.disable_pg_locks;
|
||||||
|
pg.disable_pg_locks = pg_locks_localize_only &&
|
||||||
|
(pool_cfg.scheme != POOL_SCHEME_REPLICATED ||
|
||||||
|
pool_cfg.local_reads == POOL_LOCAL_READ_PRIMARY);
|
||||||
|
if (!pg.disable_pg_locks && old_disable_pg_locks)
|
||||||
|
{
|
||||||
|
// Relock PG
|
||||||
|
printf("[PG %u/%u] Repeer to enable PG locks\n", pg.pool_id, pg.pg_num);
|
||||||
|
repeer_pg(pg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void osd_t::on_change_backfillfull_hook(pool_id_t pool_id)
|
void osd_t::on_change_backfillfull_hook(pool_id_t pool_id)
|
||||||
{
|
{
|
||||||
if (!(peering_state & (OSD_RECOVERING | OSD_FLUSHING_PGS)))
|
if (!(peering_state & (OSD_RECOVERING | OSD_FLUSHING_PGS)))
|
||||||
@@ -696,20 +722,27 @@ void osd_t::apply_pg_count()
|
|||||||
// The external tool must wait for all PGs to come down before changing PG count
|
// The external tool must wait for all PGs to come down before changing PG count
|
||||||
// If it doesn't wait, a restarted OSD may apply the new count immediately which will lead to bugs
|
// If it doesn't wait, a restarted OSD may apply the new count immediately which will lead to bugs
|
||||||
// So an OSD just dies if it detects PG count change while there are active PGs
|
// So an OSD just dies if it detects PG count change while there are active PGs
|
||||||
int still_active = 0;
|
int still_active_primary = 0;
|
||||||
for (auto & kv: pgs)
|
for (auto & kv: pgs)
|
||||||
{
|
{
|
||||||
if (kv.first.pool_id == pool_item.first && (kv.second.state & PG_ACTIVE))
|
if (kv.first.pool_id == pool_item.first && (kv.second.state & PG_ACTIVE))
|
||||||
{
|
{
|
||||||
still_active++;
|
still_active_primary++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (still_active > 0)
|
int still_active_secondary = 0;
|
||||||
|
for (auto lock_it = pg_locks.lower_bound((pool_pg_num_t){ .pool_id = pool_item.first, .pg_num = 0 });
|
||||||
|
lock_it != pg_locks.end() && lock_it->first.pool_id == pool_item.first; lock_it++)
|
||||||
|
{
|
||||||
|
still_active_secondary++;
|
||||||
|
}
|
||||||
|
if (still_active_primary > 0 || still_active_secondary > 0)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"[OSD %ju] PG count change detected for pool %u (new is %ju, old is %u),"
|
"[OSD %ju] PG count change detected for pool %u (new is %ju, old is %u),"
|
||||||
" but %u PG(s) are still active. This is not allowed. Exiting\n",
|
" but %u PG(s) are still active as primary and %u as secondary. This is not allowed. Exiting\n",
|
||||||
this->osd_num, pool_item.first, pool_item.second.real_pg_count, pg_counts[pool_item.first], still_active
|
this->osd_num, pool_item.first, pool_item.second.real_pg_count, pg_counts[pool_item.first],
|
||||||
|
still_active_primary, still_active_secondary
|
||||||
);
|
);
|
||||||
force_stop(1);
|
force_stop(1);
|
||||||
return;
|
return;
|
||||||
@@ -836,22 +869,23 @@ void osd_t::apply_pg_config()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto & pg = this->pgs[{ .pool_id = pool_id, .pg_num = pg_num }];
|
auto & pg = this->pgs[{ .pool_id = pool_id, .pg_num = pg_num }];
|
||||||
pg = (pg_t){
|
pg.state = pg_cfg.cur_primary == this->osd_num ? PG_PEERING : PG_STARTING;
|
||||||
.state = pg_cfg.cur_primary == this->osd_num ? PG_PEERING : PG_STARTING,
|
pg.scheme = pool_item.second.scheme;
|
||||||
.scheme = pool_item.second.scheme,
|
pg.pg_cursize = 0;
|
||||||
.pg_cursize = 0,
|
pg.pg_size = pool_item.second.pg_size;
|
||||||
.pg_size = pool_item.second.pg_size,
|
pg.pg_minsize = pool_item.second.pg_minsize;
|
||||||
.pg_minsize = pool_item.second.pg_minsize,
|
pg.pg_data_size = pool_item.second.scheme == POOL_SCHEME_REPLICATED
|
||||||
.pg_data_size = pool_item.second.scheme == POOL_SCHEME_REPLICATED
|
? 1 : pool_item.second.pg_size - pool_item.second.parity_chunks;
|
||||||
? 1 : pool_item.second.pg_size - pool_item.second.parity_chunks,
|
pg.pool_id = pool_id;
|
||||||
.pool_id = pool_id,
|
pg.pg_num = pg_num;
|
||||||
.pg_num = pg_num,
|
pg.reported_epoch = pg_cfg.epoch;
|
||||||
.reported_epoch = pg_cfg.epoch,
|
pg.target_history = pg_cfg.target_history;
|
||||||
.target_history = pg_cfg.target_history,
|
pg.all_peers = vec_all_peers;
|
||||||
.all_peers = vec_all_peers,
|
pg.next_scrub = pg_cfg.next_scrub;
|
||||||
.next_scrub = pg_cfg.next_scrub,
|
pg.target_set = pg_cfg.target_set;
|
||||||
.target_set = pg_cfg.target_set,
|
pg.disable_pg_locks = pg_locks_localize_only &&
|
||||||
};
|
(pool_item.second.scheme != POOL_SCHEME_REPLICATED ||
|
||||||
|
pool_item.second.local_reads == POOL_LOCAL_READ_PRIMARY);
|
||||||
if (pg.scheme == POOL_SCHEME_EC)
|
if (pg.scheme == POOL_SCHEME_EC)
|
||||||
{
|
{
|
||||||
use_ec(pg.pg_size, pg.pg_data_size, true);
|
use_ec(pg.pg_size, pg.pg_data_size, true);
|
||||||
|
|||||||
+3
-11
@@ -150,14 +150,7 @@ void osd_t::handle_flush_op(bool rollback, pool_id_t pool_id, pg_num_t pg_num, p
|
|||||||
{
|
{
|
||||||
continue_primary_write(op);
|
continue_primary_write(op);
|
||||||
}
|
}
|
||||||
if ((pg.state & PG_STOPPING) && pg.inflight == 0 && !pg.flush_batch)
|
continue_pg(pg);
|
||||||
{
|
|
||||||
finish_stop_pg(pg);
|
|
||||||
}
|
|
||||||
else if ((pg.state & PG_REPEERING) && pg.inflight == 0 && !pg.flush_batch)
|
|
||||||
{
|
|
||||||
start_pg_peering(pg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +247,8 @@ bool osd_t::pick_next_recovery(osd_recovery_op_t &op)
|
|||||||
restart:
|
restart:
|
||||||
for (auto pg_it = pgs.lower_bound(recovery_last_pg); pg_it != pgs.end(); pg_it++)
|
for (auto pg_it = pgs.lower_bound(recovery_last_pg); pg_it != pgs.end(); pg_it++)
|
||||||
{
|
{
|
||||||
if ((pg_it->second.state & mask) == check)
|
auto & src = recovery_last_degraded ? pg_it->second.degraded_objects : pg_it->second.misplaced_objects;
|
||||||
|
if ((pg_it->second.state & mask) == check && src.size() > 0)
|
||||||
{
|
{
|
||||||
auto pool_it = st_cli.pool_config.find(pg_it->first.pool_id);
|
auto pool_it = st_cli.pool_config.find(pg_it->first.pool_id);
|
||||||
if (pool_it != st_cli.pool_config.end() && pool_it->second.backfillfull)
|
if (pool_it != st_cli.pool_config.end() && pool_it->second.backfillfull)
|
||||||
@@ -263,8 +257,6 @@ bool osd_t::pick_next_recovery(osd_recovery_op_t &op)
|
|||||||
recovery_last_pg.pool_id++;
|
recovery_last_pg.pool_id++;
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
auto & src = recovery_last_degraded ? pg_it->second.degraded_objects : pg_it->second.misplaced_objects;
|
|
||||||
assert(src.size() > 0);
|
|
||||||
// Restart scanning from the next object
|
// Restart scanning from the next object
|
||||||
for (auto obj_it = src.upper_bound(recovery_last_oid); obj_it != src.end(); obj_it++)
|
for (auto obj_it = src.upper_bound(recovery_last_oid); obj_it != src.end(); obj_it++)
|
||||||
{
|
{
|
||||||
|
|||||||
+261
-51
@@ -21,28 +21,8 @@ void osd_t::handle_peers()
|
|||||||
{
|
{
|
||||||
if (p.second.state == PG_PEERING)
|
if (p.second.state == PG_PEERING)
|
||||||
{
|
{
|
||||||
if (!p.second.peering_state->list_ops.size())
|
if (continue_pg_peering(p.second))
|
||||||
{
|
{
|
||||||
p.second.calc_object_states(log_level);
|
|
||||||
report_pg_state(p.second);
|
|
||||||
schedule_scrub(p.second);
|
|
||||||
incomplete_objects += p.second.incomplete_objects.size();
|
|
||||||
misplaced_objects += p.second.misplaced_objects.size();
|
|
||||||
// FIXME: degraded objects may currently include misplaced, too! Report them separately?
|
|
||||||
degraded_objects += p.second.degraded_objects.size();
|
|
||||||
if (p.second.state & PG_HAS_UNCLEAN)
|
|
||||||
peering_state = peering_state | OSD_FLUSHING_PGS;
|
|
||||||
else if (p.second.state & (PG_HAS_DEGRADED | PG_HAS_MISPLACED))
|
|
||||||
{
|
|
||||||
peering_state = peering_state | OSD_RECOVERING;
|
|
||||||
if (p.second.state & PG_HAS_DEGRADED)
|
|
||||||
{
|
|
||||||
// Restart recovery from degraded objects
|
|
||||||
recovery_last_degraded = true;
|
|
||||||
recovery_last_pg = {};
|
|
||||||
recovery_last_oid = {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ringloop->wakeup();
|
ringloop->wakeup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -93,6 +73,23 @@ void osd_t::handle_peers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void osd_t::break_pg_locks(osd_num_t peer_osd)
|
||||||
|
{
|
||||||
|
for (auto lock_it = pg_locks.begin(); lock_it != pg_locks.end(); )
|
||||||
|
{
|
||||||
|
if (lock_it->second.primary_osd == peer_osd)
|
||||||
|
{
|
||||||
|
if (log_level > 3)
|
||||||
|
{
|
||||||
|
printf("Break PG %u/%u lock on disconnection of OSD %ju\n", lock_it->first.pool_id, lock_it->first.pg_num, peer_osd);
|
||||||
|
}
|
||||||
|
pg_locks.erase(lock_it++);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lock_it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void osd_t::repeer_pgs(osd_num_t peer_osd)
|
void osd_t::repeer_pgs(osd_num_t peer_osd)
|
||||||
{
|
{
|
||||||
// Re-peer affected PGs
|
// Re-peer affected PGs
|
||||||
@@ -114,21 +111,26 @@ void osd_t::repeer_pgs(osd_num_t peer_osd)
|
|||||||
{
|
{
|
||||||
// Repeer this pg
|
// Repeer this pg
|
||||||
printf("[PG %u/%u] Repeer because of OSD %ju\n", pg.pool_id, pg.pg_num, peer_osd);
|
printf("[PG %u/%u] Repeer because of OSD %ju\n", pg.pool_id, pg.pg_num, peer_osd);
|
||||||
if (!(pg.state & (PG_ACTIVE | PG_REPEERING)) || pg.inflight == 0 && !pg.flush_batch)
|
repeer_pg(pg);
|
||||||
{
|
|
||||||
start_pg_peering(pg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Stop accepting new operations, wait for current ones to finish or fail
|
|
||||||
pg.state = pg.state & ~PG_ACTIVE | PG_REPEERING;
|
|
||||||
report_pg_state(pg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void osd_t::repeer_pg(pg_t & pg)
|
||||||
|
{
|
||||||
|
if (!(pg.state & (PG_ACTIVE | PG_REPEERING)) || pg.can_repeer())
|
||||||
|
{
|
||||||
|
start_pg_peering(pg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Stop accepting new operations, wait for current ones to finish or fail
|
||||||
|
pg.state = pg.state & ~PG_ACTIVE | PG_REPEERING;
|
||||||
|
report_pg_state(pg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Reset PG state (when peering or stopping)
|
// Reset PG state (when peering or stopping)
|
||||||
void osd_t::reset_pg(pg_t & pg)
|
void osd_t::reset_pg(pg_t & pg)
|
||||||
{
|
{
|
||||||
@@ -195,7 +197,6 @@ void osd_t::start_pg_peering(pg_t & pg)
|
|||||||
pg.state = PG_PEERING;
|
pg.state = PG_PEERING;
|
||||||
this->peering_state |= OSD_PEERING_PGS;
|
this->peering_state |= OSD_PEERING_PGS;
|
||||||
reset_pg(pg);
|
reset_pg(pg);
|
||||||
report_pg_state(pg);
|
|
||||||
drop_dirty_pg_connections({ .pool_id = pg.pool_id, .pg_num = pg.pg_num });
|
drop_dirty_pg_connections({ .pool_id = pg.pool_id, .pg_num = pg.pg_num });
|
||||||
// Try to connect with current peers if they're up, but we don't have connections to them
|
// Try to connect with current peers if they're up, but we don't have connections to them
|
||||||
// Otherwise we may erroneously decide that the pg is incomplete :-)
|
// Otherwise we may erroneously decide that the pg is incomplete :-)
|
||||||
@@ -215,8 +216,7 @@ void osd_t::start_pg_peering(pg_t & pg)
|
|||||||
{
|
{
|
||||||
// Wait until all OSDs are either connected or their /osd/state disappears from etcd
|
// Wait until all OSDs are either connected or their /osd/state disappears from etcd
|
||||||
pg.state = PG_INCOMPLETE;
|
pg.state = PG_INCOMPLETE;
|
||||||
report_pg_state(pg);
|
// Fall through to cleanup list results
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// Calculate current write OSD set
|
// Calculate current write OSD set
|
||||||
pg.pg_cursize = 0;
|
pg.pg_cursize = 0;
|
||||||
@@ -242,8 +242,6 @@ void osd_t::start_pg_peering(pg_t & pg)
|
|||||||
// because such PGs don't flush unstable entries on secondary OSDs so they can't remove these
|
// because such PGs don't flush unstable entries on secondary OSDs so they can't remove these
|
||||||
// entries from their journals...
|
// entries from their journals...
|
||||||
pg.state = PG_INCOMPLETE;
|
pg.state = PG_INCOMPLETE;
|
||||||
report_pg_state(pg);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
std::set<osd_num_t> cur_peers;
|
std::set<osd_num_t> cur_peers;
|
||||||
std::set<osd_num_t> dead_peers;
|
std::set<osd_num_t> dead_peers;
|
||||||
@@ -278,8 +276,6 @@ void osd_t::start_pg_peering(pg_t & pg)
|
|||||||
if (nonzero >= pg.pg_data_size && found < pg.pg_data_size)
|
if (nonzero >= pg.pg_data_size && found < pg.pg_data_size)
|
||||||
{
|
{
|
||||||
pg.state = PG_INCOMPLETE;
|
pg.state = PG_INCOMPLETE;
|
||||||
report_pg_state(pg);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,6 +314,7 @@ void osd_t::start_pg_peering(pg_t & pg)
|
|||||||
delete pg.peering_state;
|
delete pg.peering_state;
|
||||||
pg.peering_state = NULL;
|
pg.peering_state = NULL;
|
||||||
}
|
}
|
||||||
|
report_pg_state(pg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!pg.peering_state)
|
if (!pg.peering_state)
|
||||||
@@ -326,16 +323,204 @@ void osd_t::start_pg_peering(pg_t & pg)
|
|||||||
pg.peering_state->pool_id = pg.pool_id;
|
pg.peering_state->pool_id = pg.pool_id;
|
||||||
pg.peering_state->pg_num = pg.pg_num;
|
pg.peering_state->pg_num = pg.pg_num;
|
||||||
}
|
}
|
||||||
for (osd_num_t peer_osd: cur_peers)
|
pg.peering_state->locked = false;
|
||||||
|
pg.peering_state->lists_done = false;
|
||||||
|
report_pg_state(pg);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool osd_t::continue_pg_peering(pg_t & pg)
|
||||||
|
{
|
||||||
|
if (pg.peering_state->locked)
|
||||||
{
|
{
|
||||||
if (pg.peering_state->list_ops.find(peer_osd) != pg.peering_state->list_ops.end() ||
|
pg.peering_state->lists_done = true;
|
||||||
pg.peering_state->list_results.find(peer_osd) != pg.peering_state->list_results.end())
|
for (osd_num_t peer_osd: pg.cur_peers)
|
||||||
{
|
{
|
||||||
|
if (pg.peering_state->list_results.find(peer_osd) == pg.peering_state->list_results.end())
|
||||||
|
{
|
||||||
|
pg.peering_state->lists_done = false;
|
||||||
|
}
|
||||||
|
if (pg.peering_state->list_ops.find(peer_osd) != pg.peering_state->list_ops.end() ||
|
||||||
|
pg.peering_state->list_results.find(peer_osd) != pg.peering_state->list_results.end())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
submit_list_subop(peer_osd, pg.peering_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pg.peering_state->lists_done)
|
||||||
|
{
|
||||||
|
pg.calc_object_states(log_level);
|
||||||
|
report_pg_state(pg);
|
||||||
|
schedule_scrub(pg);
|
||||||
|
incomplete_objects += pg.incomplete_objects.size();
|
||||||
|
misplaced_objects += pg.misplaced_objects.size();
|
||||||
|
// FIXME: degraded objects may currently include misplaced, too! Report them separately?
|
||||||
|
degraded_objects += pg.degraded_objects.size();
|
||||||
|
if (pg.state & PG_HAS_UNCLEAN)
|
||||||
|
this->peering_state = peering_state | OSD_FLUSHING_PGS;
|
||||||
|
else if (pg.state & (PG_HAS_DEGRADED | PG_HAS_MISPLACED))
|
||||||
|
{
|
||||||
|
this->peering_state = peering_state | OSD_RECOVERING;
|
||||||
|
if (pg.state & PG_HAS_DEGRADED)
|
||||||
|
{
|
||||||
|
// Restart recovery from degraded objects
|
||||||
|
this->recovery_last_degraded = true;
|
||||||
|
this->recovery_last_pg = {};
|
||||||
|
this->recovery_last_oid = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void osd_t::record_pg_lock(pg_t & pg, osd_num_t peer_osd, uint64_t pg_state)
|
||||||
|
{
|
||||||
|
if (!pg_state)
|
||||||
|
pg.lock_peers.erase(peer_osd);
|
||||||
|
else
|
||||||
|
pg.lock_peers[peer_osd] = pg_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void osd_t::relock_pg(pg_t & pg)
|
||||||
|
{
|
||||||
|
if (!enable_pg_locks || pg.disable_pg_locks && !pg.lock_peers.size())
|
||||||
|
{
|
||||||
|
if (pg.state & PG_PEERING)
|
||||||
|
pg.peering_state->locked = true;
|
||||||
|
continue_pg(pg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pg.inflight_locks > 0 || pg.lock_waiting)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check that lock_peers are equal to cur_peers and correct the difference, if any
|
||||||
|
uint64_t wanted_state = pg.state;
|
||||||
|
std::vector<osd_num_t> diff_osds;
|
||||||
|
if (!(pg.state & (PG_STOPPING | PG_OFFLINE | PG_INCOMPLETE)) && !pg.disable_pg_locks)
|
||||||
|
{
|
||||||
|
for (osd_num_t peer_osd: pg.cur_peers)
|
||||||
|
{
|
||||||
|
if (peer_osd != this->osd_num)
|
||||||
|
{
|
||||||
|
auto lock_it = pg.lock_peers.find(peer_osd);
|
||||||
|
if (lock_it == pg.lock_peers.end())
|
||||||
|
diff_osds.push_back(peer_osd);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (lock_it->second != wanted_state)
|
||||||
|
diff_osds.push_back(peer_osd);
|
||||||
|
lock_it->second |= ((uint64_t)1 << 63);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int relock_osd_count = diff_osds.size();
|
||||||
|
for (auto & lp: pg.lock_peers)
|
||||||
|
{
|
||||||
|
if (!(lp.second & ((uint64_t)1 << 63)))
|
||||||
|
diff_osds.push_back(lp.first);
|
||||||
|
lp.second &= ~((uint64_t)1 << 63);
|
||||||
|
}
|
||||||
|
if (!diff_osds.size())
|
||||||
|
{
|
||||||
|
if (pg.state & PG_PEERING)
|
||||||
|
pg.peering_state->locked = true;
|
||||||
|
continue_pg(pg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pg.inflight_locks++;
|
||||||
|
for (int i = 0; i < diff_osds.size(); i++)
|
||||||
|
{
|
||||||
|
bool unlock_peer = (i >= relock_osd_count);
|
||||||
|
uint64_t new_state = unlock_peer ? 0 : pg.state;
|
||||||
|
auto peer_osd = diff_osds[i];
|
||||||
|
auto peer_fd_it = msgr.osd_peer_fds.find(peer_osd);
|
||||||
|
if (peer_fd_it == msgr.osd_peer_fds.end())
|
||||||
|
{
|
||||||
|
if (unlock_peer)
|
||||||
|
{
|
||||||
|
// Peer is dead - unlocked automatically
|
||||||
|
record_pg_lock(pg, peer_osd, new_state);
|
||||||
|
diff_osds.erase(diff_osds.begin()+(i--));
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
submit_list_subop(peer_osd, pg.peering_state);
|
int peer_fd = peer_fd_it->second;
|
||||||
|
auto cl = msgr.clients.at(peer_fd);
|
||||||
|
if (!cl->enable_pg_locks)
|
||||||
|
{
|
||||||
|
// Peer does not support locking - just instantly remember the lock as successful
|
||||||
|
record_pg_lock(pg, peer_osd, new_state);
|
||||||
|
diff_osds.erase(diff_osds.begin()+(i--));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pg.inflight_locks++;
|
||||||
|
osd_op_t *op = new osd_op_t();
|
||||||
|
op->op_type = OSD_OP_OUT;
|
||||||
|
op->peer_fd = peer_fd;
|
||||||
|
op->req = (osd_any_op_t){
|
||||||
|
.sec_lock = {
|
||||||
|
.header = {
|
||||||
|
.magic = SECONDARY_OSD_OP_MAGIC,
|
||||||
|
.opcode = OSD_OP_SEC_LOCK,
|
||||||
|
},
|
||||||
|
.flags = (uint64_t)(unlock_peer ? OSD_SEC_UNLOCK_PG : OSD_SEC_LOCK_PG),
|
||||||
|
.pool_id = pg.pool_id,
|
||||||
|
.pg_num = pg.pg_num,
|
||||||
|
.pg_state = new_state,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
op->callback = [this, peer_osd](osd_op_t *op)
|
||||||
|
{
|
||||||
|
pool_pg_num_t pg_id = { .pool_id = (pool_id_t)op->req.sec_lock.pool_id, .pg_num = (pg_num_t)op->req.sec_lock.pg_num };
|
||||||
|
auto pg_it = pgs.find(pg_id);
|
||||||
|
if (pg_it == pgs.end())
|
||||||
|
{
|
||||||
|
printf("Warning: PG %u/%u is gone during lock attempt\n", pg_id.pool_id, pg_id.pg_num);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto & pg = pg_it->second;
|
||||||
|
if (op->reply.hdr.retval == 0)
|
||||||
|
{
|
||||||
|
record_pg_lock(pg_it->second, peer_osd, op->req.sec_lock.pg_state);
|
||||||
|
}
|
||||||
|
else if (op->reply.hdr.retval != -EPIPE)
|
||||||
|
{
|
||||||
|
printf(
|
||||||
|
(op->reply.hdr.retval == -ENOENT
|
||||||
|
? "Failed to %1$s PG %2$u/%3$u on OSD %4$ju - peer didn't load PG info yet\n"
|
||||||
|
: (op->reply.sec_lock.cur_primary
|
||||||
|
? "Failed to %1$s PG %2$u/%3$u on OSD %4$ju - taken by OSD %6$ju (retval=%5$jd)\n"
|
||||||
|
: "Failed to %1$s PG %2$u/%3$u on OSD %4$ju - retval=%5$jd\n")),
|
||||||
|
op->req.sec_lock.flags == OSD_SEC_UNLOCK_PG ? "unlock" : "lock",
|
||||||
|
pg_id.pool_id, pg_id.pg_num, peer_osd, op->reply.hdr.retval, op->reply.sec_lock.cur_primary
|
||||||
|
);
|
||||||
|
// Retry relocking/unlocking PG after a short time
|
||||||
|
pg.lock_waiting = true;
|
||||||
|
tfd->set_timer(pg_lock_retry_interval_ms, false, [this, pg_id](int)
|
||||||
|
{
|
||||||
|
auto pg_it = pgs.find(pg_id);
|
||||||
|
if (pg_it != pgs.end())
|
||||||
|
{
|
||||||
|
pg_it->second.lock_waiting = false;
|
||||||
|
relock_pg(pg_it->second);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pg.inflight_locks--;
|
||||||
|
relock_pg(pg);
|
||||||
|
delete op;
|
||||||
|
};
|
||||||
|
msgr.outbox_push(op);
|
||||||
}
|
}
|
||||||
ringloop->wakeup();
|
if (pg.state & PG_PEERING)
|
||||||
|
{
|
||||||
|
pg.peering_state->locked = !diff_osds.size();
|
||||||
|
}
|
||||||
|
pg.inflight_locks--;
|
||||||
|
continue_pg(pg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void osd_t::submit_list_subop(osd_num_t role_osd, pg_peering_state_t *ps)
|
void osd_t::submit_list_subop(osd_num_t role_osd, pg_peering_state_t *ps)
|
||||||
@@ -383,10 +568,16 @@ void osd_t::submit_list_subop(osd_num_t role_osd, pg_peering_state_t *ps)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
auto role_fd_it = msgr.osd_peer_fds.find(role_osd);
|
||||||
|
if (role_fd_it == msgr.osd_peer_fds.end())
|
||||||
|
{
|
||||||
|
printf("Failed to get object list from OSD %ju because it is disconnected\n", role_osd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Peer
|
// Peer
|
||||||
osd_op_t *op = new osd_op_t();
|
osd_op_t *op = new osd_op_t();
|
||||||
op->op_type = OSD_OP_OUT;
|
op->op_type = OSD_OP_OUT;
|
||||||
op->peer_fd = msgr.osd_peer_fds.at(role_osd);
|
op->peer_fd = role_fd_it->second;
|
||||||
op->req = (osd_any_op_t){
|
op->req = (osd_any_op_t){
|
||||||
.sec_list = {
|
.sec_list = {
|
||||||
.header = {
|
.header = {
|
||||||
@@ -478,13 +669,8 @@ bool osd_t::stop_pg(pg_t & pg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
drop_dirty_pg_connections({ .pool_id = pg.pool_id, .pg_num = pg.pg_num });
|
drop_dirty_pg_connections({ .pool_id = pg.pool_id, .pg_num = pg.pg_num });
|
||||||
if (!(pg.state & (PG_ACTIVE | PG_REPEERING)))
|
pg.state = pg.state & ~PG_STARTING & ~PG_PEERING & ~PG_INCOMPLETE & ~PG_ACTIVE & ~PG_REPEERING & ~PG_OFFLINE | PG_STOPPING;
|
||||||
{
|
if (pg.can_stop())
|
||||||
finish_stop_pg(pg);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
pg.state = pg.state & ~PG_ACTIVE & ~PG_REPEERING | PG_STOPPING;
|
|
||||||
if (pg.inflight == 0 && !pg.flush_batch)
|
|
||||||
{
|
{
|
||||||
finish_stop_pg(pg);
|
finish_stop_pg(pg);
|
||||||
}
|
}
|
||||||
@@ -565,9 +751,33 @@ void osd_t::report_pg_state(pg_t & pg)
|
|||||||
pg_cfg.target_history = pg.target_history;
|
pg_cfg.target_history = pg.target_history;
|
||||||
pg_cfg.all_peers = pg.all_peers;
|
pg_cfg.all_peers = pg.all_peers;
|
||||||
}
|
}
|
||||||
|
relock_pg(pg);
|
||||||
if (pg.state == PG_OFFLINE && !this->pg_config_applied)
|
if (pg.state == PG_OFFLINE && !this->pg_config_applied)
|
||||||
{
|
{
|
||||||
apply_pg_config();
|
apply_pg_config();
|
||||||
}
|
}
|
||||||
report_pg_states();
|
report_pg_states();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void osd_t::rm_inflight(pg_t & pg)
|
||||||
|
{
|
||||||
|
pg.inflight--;
|
||||||
|
assert(pg.inflight >= 0);
|
||||||
|
continue_pg(pg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void osd_t::continue_pg(pg_t & pg)
|
||||||
|
{
|
||||||
|
if ((pg.state & PG_STOPPING) && pg.can_stop())
|
||||||
|
{
|
||||||
|
finish_stop_pg(pg);
|
||||||
|
}
|
||||||
|
else if ((pg.state & PG_REPEERING) && pg.can_repeer())
|
||||||
|
{
|
||||||
|
start_pg_peering(pg);
|
||||||
|
}
|
||||||
|
else if ((pg.state & PG_PEERING) && pg.peering_state->locked)
|
||||||
|
{
|
||||||
|
continue_pg_peering(pg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -489,3 +489,13 @@ void pg_t::print_state()
|
|||||||
total_count
|
total_count
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pg_t::can_stop()
|
||||||
|
{
|
||||||
|
return inflight == 0 && inflight_locks == 0 && !lock_peers.size() && !flush_batch;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pg_t::can_repeer()
|
||||||
|
{
|
||||||
|
return inflight == 0 && !flush_batch;
|
||||||
|
}
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ struct pg_peering_state_t
|
|||||||
std::map<osd_num_t, pg_list_result_t> list_results;
|
std::map<osd_num_t, pg_list_result_t> list_results;
|
||||||
pool_id_t pool_id = 0;
|
pool_id_t pool_id = 0;
|
||||||
pg_num_t pg_num = 0;
|
pg_num_t pg_num = 0;
|
||||||
|
bool locked = false;
|
||||||
|
bool lists_done = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct obj_piece_id_t
|
struct obj_piece_id_t
|
||||||
@@ -87,6 +89,7 @@ struct pg_t
|
|||||||
pool_id_t pool_id = 0;
|
pool_id_t pool_id = 0;
|
||||||
pg_num_t pg_num = 0;
|
pg_num_t pg_num = 0;
|
||||||
uint64_t clean_count = 0, total_count = 0;
|
uint64_t clean_count = 0, total_count = 0;
|
||||||
|
bool disable_pg_locks = false;
|
||||||
// epoch number - should increase with each non-clean activation of the PG
|
// epoch number - should increase with each non-clean activation of the PG
|
||||||
uint64_t epoch = 0, reported_epoch = 0;
|
uint64_t epoch = 0, reported_epoch = 0;
|
||||||
// target history and all potential peers
|
// target history and all potential peers
|
||||||
@@ -104,6 +107,10 @@ struct pg_t
|
|||||||
// cur_set is the current set of connected peer OSDs for this PG
|
// cur_set is the current set of connected peer OSDs for this PG
|
||||||
// cur_set = (role => osd_num or UINT64_MAX if missing). role numbers begin with zero
|
// cur_set = (role => osd_num or UINT64_MAX if missing). role numbers begin with zero
|
||||||
std::vector<osd_num_t> cur_set;
|
std::vector<osd_num_t> cur_set;
|
||||||
|
// locked peer list => pg state reported to the peer
|
||||||
|
std::map<osd_num_t, uint64_t> lock_peers;
|
||||||
|
int inflight_locks = 0;
|
||||||
|
bool lock_waiting = false;
|
||||||
// same thing in state_dict-like format
|
// same thing in state_dict-like format
|
||||||
pg_osd_set_t cur_loc_set;
|
pg_osd_set_t cur_loc_set;
|
||||||
// moved object map. by default, each object is considered to reside on cur_set.
|
// moved object map. by default, each object is considered to reside on cur_set.
|
||||||
@@ -125,6 +132,9 @@ struct pg_t
|
|||||||
pg_osd_set_state_t* add_object_to_state(const object_id oid, const uint64_t state, const pg_osd_set_t & osd_set);
|
pg_osd_set_state_t* add_object_to_state(const object_id oid, const uint64_t state, const pg_osd_set_t & osd_set);
|
||||||
void calc_object_states(int log_level);
|
void calc_object_states(int log_level);
|
||||||
void print_state();
|
void print_state();
|
||||||
|
bool can_stop();
|
||||||
|
bool can_repeer();
|
||||||
|
void rm_inflight();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator < (const pg_obj_loc_t &a, const pg_obj_loc_t &b)
|
inline bool operator < (const pg_obj_loc_t &a, const pg_obj_loc_t &b)
|
||||||
|
|||||||
+50
-26
@@ -37,7 +37,20 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
|||||||
};
|
};
|
||||||
pg_num_t pg_num = (oid.stripe/pool_cfg.pg_stripe_size) % pg_counts[pool_id] + 1; // like map_to_pg()
|
pg_num_t pg_num = (oid.stripe/pool_cfg.pg_stripe_size) % pg_counts[pool_id] + 1; // like map_to_pg()
|
||||||
auto pg_it = pgs.find({ .pool_id = pool_id, .pg_num = pg_num });
|
auto pg_it = pgs.find({ .pool_id = pool_id, .pg_num = pg_num });
|
||||||
if (pg_it == pgs.end() || !(pg_it->second.state & PG_ACTIVE))
|
if (pg_it == pgs.end() || pg_it->second.state == PG_OFFLINE)
|
||||||
|
{
|
||||||
|
// Check for a local replicated read from secondary OSD
|
||||||
|
auto lock_it = cur_op->req.hdr.opcode == OSD_OP_READ && pool_cfg.scheme == POOL_SCHEME_REPLICATED
|
||||||
|
? pg_locks.find({ .pool_id = pool_id, .pg_num = pg_num })
|
||||||
|
: pg_locks.end();
|
||||||
|
if (lock_it == pg_locks.end() || lock_it->second.state != PG_ACTIVE && lock_it->second.state != (PG_ACTIVE|PG_LEFT_ON_DEAD))
|
||||||
|
{
|
||||||
|
// FIXME: Change EPIPE to something else
|
||||||
|
finish_op(cur_op, -EPIPE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!(pg_it->second.state & PG_ACTIVE))
|
||||||
{
|
{
|
||||||
// This OSD is not primary for this PG or the PG is inactive
|
// This OSD is not primary for this PG or the PG is inactive
|
||||||
// FIXME: Allow reads from PGs degraded under pg_minsize, but don't allow writes
|
// FIXME: Allow reads from PGs degraded under pg_minsize, but don't allow writes
|
||||||
@@ -69,7 +82,7 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
|||||||
// Find parents from the same pool. Optimized reads only work within pools
|
// Find parents from the same pool. Optimized reads only work within pools
|
||||||
while (inode_it != st_cli.inode_config.end() &&
|
while (inode_it != st_cli.inode_config.end() &&
|
||||||
inode_it->second.parent_id &&
|
inode_it->second.parent_id &&
|
||||||
INODE_POOL(inode_it->second.parent_id) == pg_it->second.pool_id)
|
INODE_POOL(inode_it->second.parent_id) == pool_cfg.id)
|
||||||
{
|
{
|
||||||
// Check for loops - FIXME check it in etcd_state_client
|
// Check for loops - FIXME check it in etcd_state_client
|
||||||
if (inode_it->second.parent_id == cur_op->req.rw.inode ||
|
if (inode_it->second.parent_id == cur_op->req.rw.inode ||
|
||||||
@@ -109,7 +122,7 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
|||||||
);
|
);
|
||||||
void *data_buf = (uint8_t*)op_data + sizeof(osd_primary_op_data_t);
|
void *data_buf = (uint8_t*)op_data + sizeof(osd_primary_op_data_t);
|
||||||
op_data->pg_num = pg_num;
|
op_data->pg_num = pg_num;
|
||||||
op_data->pg = &pg_it->second;
|
op_data->pg = pg_it == pgs.end() ? NULL : &pg_it->second;
|
||||||
op_data->oid = oid;
|
op_data->oid = oid;
|
||||||
op_data->stripes = (osd_rmw_stripe_t*)data_buf;
|
op_data->stripes = (osd_rmw_stripe_t*)data_buf;
|
||||||
op_data->stripe_count = stripe_count;
|
op_data->stripe_count = stripe_count;
|
||||||
@@ -144,7 +157,7 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
|||||||
chain_num++;
|
chain_num++;
|
||||||
auto inode_it = st_cli.inode_config.find(cur_op->req.rw.inode);
|
auto inode_it = st_cli.inode_config.find(cur_op->req.rw.inode);
|
||||||
while (inode_it != st_cli.inode_config.end() && inode_it->second.parent_id &&
|
while (inode_it != st_cli.inode_config.end() && inode_it->second.parent_id &&
|
||||||
INODE_POOL(inode_it->second.parent_id) == pg_it->second.pool_id &&
|
INODE_POOL(inode_it->second.parent_id) == pool_cfg.id &&
|
||||||
// Check for loops
|
// Check for loops
|
||||||
inode_it->second.parent_id != cur_op->req.rw.inode)
|
inode_it->second.parent_id != cur_op->req.rw.inode)
|
||||||
{
|
{
|
||||||
@@ -154,7 +167,10 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
|
|||||||
chain_num++;
|
chain_num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pg_it->second.inflight++;
|
if (op_data->pg)
|
||||||
|
{
|
||||||
|
op_data->pg->inflight++;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +210,7 @@ void osd_t::continue_primary_read(osd_op_t *cur_op)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
|
pg_t *pg = op_data->pg;
|
||||||
if (op_data->chain_size)
|
if (op_data->chain_size)
|
||||||
{
|
{
|
||||||
continue_chained_read(cur_op);
|
continue_chained_read(cur_op);
|
||||||
@@ -206,11 +223,10 @@ void osd_t::continue_primary_read(osd_op_t *cur_op)
|
|||||||
resume_0:
|
resume_0:
|
||||||
cur_op->reply.rw.bitmap_len = 0;
|
cur_op->reply.rw.bitmap_len = 0;
|
||||||
{
|
{
|
||||||
auto & pg = *op_data->pg;
|
|
||||||
if (cur_op->req.rw.len == 0)
|
if (cur_op->req.rw.len == 0)
|
||||||
{
|
{
|
||||||
// len=0 => bitmap read
|
// len=0 => bitmap read
|
||||||
for (int role = 0; role < pg.pg_data_size; role++)
|
for (int role = 0; role < (pg ? pg->pg_data_size : 1); role++)
|
||||||
{
|
{
|
||||||
op_data->stripes[role].read_start = 0;
|
op_data->stripes[role].read_start = 0;
|
||||||
op_data->stripes[role].read_end = UINT32_MAX;
|
op_data->stripes[role].read_end = UINT32_MAX;
|
||||||
@@ -218,40 +234,48 @@ resume_0:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int role = 0; role < pg.pg_data_size; role++)
|
for (int role = 0; role < (pg ? pg->pg_data_size : 1); role++)
|
||||||
{
|
{
|
||||||
op_data->stripes[role].read_start = op_data->stripes[role].req_start;
|
op_data->stripes[role].read_start = op_data->stripes[role].req_start;
|
||||||
op_data->stripes[role].read_end = op_data->stripes[role].req_end;
|
op_data->stripes[role].read_end = op_data->stripes[role].req_end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Determine version
|
// Determine version
|
||||||
auto vo_it = pg.ver_override.find(op_data->oid);
|
if (pg)
|
||||||
op_data->target_ver = vo_it != pg.ver_override.end() ? vo_it->second : UINT64_MAX;
|
{
|
||||||
// PG may have degraded or misplaced objects
|
auto vo_it = pg->ver_override.find(op_data->oid);
|
||||||
op_data->prev_set = get_object_osd_set(pg, op_data->oid, &op_data->object_state);
|
op_data->target_ver = vo_it != pg->ver_override.end() ? vo_it->second : UINT64_MAX;
|
||||||
if (pg.state == PG_ACTIVE || pg.scheme == POOL_SCHEME_REPLICATED)
|
// PG may have degraded or misplaced objects
|
||||||
|
op_data->prev_set = get_object_osd_set(*pg, op_data->oid, &op_data->object_state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
op_data->target_ver = UINT64_MAX;
|
||||||
|
op_data->prev_set = &this->osd_num;
|
||||||
|
}
|
||||||
|
if (!pg || pg->state == PG_ACTIVE || pg->scheme == POOL_SCHEME_REPLICATED)
|
||||||
{
|
{
|
||||||
// Fast happy-path
|
// Fast happy-path
|
||||||
if (pg.scheme == POOL_SCHEME_REPLICATED &&
|
if (pg && pg->scheme == POOL_SCHEME_REPLICATED &&
|
||||||
op_data->object_state && (op_data->object_state->state & OBJ_INCOMPLETE))
|
op_data->object_state && (op_data->object_state->state & OBJ_INCOMPLETE))
|
||||||
{
|
{
|
||||||
finish_op(cur_op, -EIO);
|
finish_op(cur_op, -EIO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur_op->buf = alloc_read_buffer(op_data->stripes, pg.pg_data_size, 0);
|
cur_op->buf = alloc_read_buffer(op_data->stripes, pg ? pg->pg_data_size : 1, 0);
|
||||||
submit_primary_subops(SUBMIT_RMW_READ, op_data->target_ver, op_data->prev_set, cur_op);
|
submit_primary_subops(SUBMIT_RMW_READ, op_data->target_ver, op_data->prev_set, cur_op);
|
||||||
op_data->st = 1;
|
op_data->st = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (extend_missing_stripes(op_data->stripes, op_data->prev_set, pg.pg_data_size, pg.pg_size) < 0)
|
if (extend_missing_stripes(op_data->stripes, op_data->prev_set, pg->pg_data_size, pg->pg_size) < 0)
|
||||||
{
|
{
|
||||||
finish_op(cur_op, -EIO);
|
finish_op(cur_op, -EIO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Submit reads
|
// Submit reads
|
||||||
op_data->degraded = 1;
|
op_data->degraded = 1;
|
||||||
cur_op->buf = alloc_read_buffer(op_data->stripes, pg.pg_size, 0);
|
cur_op->buf = alloc_read_buffer(op_data->stripes, pg->pg_size, 0);
|
||||||
submit_primary_subops(SUBMIT_RMW_READ, op_data->target_ver, op_data->prev_set, cur_op);
|
submit_primary_subops(SUBMIT_RMW_READ, op_data->target_ver, op_data->prev_set, cur_op);
|
||||||
op_data->st = 1;
|
op_data->st = 1;
|
||||||
}
|
}
|
||||||
@@ -261,32 +285,32 @@ resume_1:
|
|||||||
resume_2:
|
resume_2:
|
||||||
if (op_data->errors > 0)
|
if (op_data->errors > 0)
|
||||||
{
|
{
|
||||||
if (op_data->errcode == -EIO || op_data->errcode == -EDOM)
|
if (pg && (op_data->errcode == -EIO || op_data->errcode == -EDOM))
|
||||||
{
|
{
|
||||||
// I/O or checksum error
|
// I/O or checksum error
|
||||||
// FIXME: ref = true ideally... because new_state != state is not necessarily true if it's freed and recreated
|
// FIXME: ref = true ideally... because new_state != state is not necessarily true if it's freed and recreated
|
||||||
op_data->object_state = mark_object_corrupted(*op_data->pg, op_data->oid, op_data->object_state, op_data->stripes, false);
|
op_data->object_state = mark_object_corrupted(*pg, op_data->oid, op_data->object_state, op_data->stripes, false);
|
||||||
goto resume_0;
|
goto resume_0;
|
||||||
}
|
}
|
||||||
finish_op(cur_op, op_data->errcode);
|
finish_op(cur_op, op_data->errcode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur_op->reply.rw.version = op_data->fact_ver;
|
cur_op->reply.rw.version = op_data->fact_ver;
|
||||||
cur_op->reply.rw.bitmap_len = op_data->pg->pg_data_size * clean_entry_bitmap_size;
|
cur_op->reply.rw.bitmap_len = (pg ? pg->pg_data_size : 1) * clean_entry_bitmap_size;
|
||||||
if (op_data->degraded)
|
if (op_data->degraded)
|
||||||
{
|
{
|
||||||
// Reconstruct missing stripes
|
// Reconstruct missing stripes
|
||||||
osd_rmw_stripe_t *stripes = op_data->stripes;
|
osd_rmw_stripe_t *stripes = op_data->stripes;
|
||||||
if (op_data->pg->scheme == POOL_SCHEME_XOR)
|
if (pg->scheme == POOL_SCHEME_XOR)
|
||||||
{
|
{
|
||||||
reconstruct_stripes_xor(stripes, op_data->pg->pg_size, clean_entry_bitmap_size);
|
reconstruct_stripes_xor(stripes, pg->pg_size, clean_entry_bitmap_size);
|
||||||
}
|
}
|
||||||
else if (op_data->pg->scheme == POOL_SCHEME_EC)
|
else if (pg->scheme == POOL_SCHEME_EC)
|
||||||
{
|
{
|
||||||
reconstruct_stripes_ec(stripes, op_data->pg->pg_size, op_data->pg->pg_data_size, clean_entry_bitmap_size);
|
reconstruct_stripes_ec(stripes, pg->pg_size, pg->pg_data_size, clean_entry_bitmap_size);
|
||||||
}
|
}
|
||||||
cur_op->iov.push_back(op_data->stripes[0].bmp_buf, cur_op->reply.rw.bitmap_len);
|
cur_op->iov.push_back(op_data->stripes[0].bmp_buf, cur_op->reply.rw.bitmap_len);
|
||||||
for (int role = 0; role < op_data->pg->pg_size; role++)
|
for (int role = 0; role < pg->pg_size; role++)
|
||||||
{
|
{
|
||||||
if (stripes[role].req_end != 0)
|
if (stripes[role].req_end != 0)
|
||||||
{
|
{
|
||||||
@@ -632,7 +656,7 @@ void osd_t::remove_object_from_state(object_id & oid, pg_osd_set_state_t **objec
|
|||||||
{
|
{
|
||||||
this->misplaced_objects--;
|
this->misplaced_objects--;
|
||||||
pg.misplaced_objects.erase(oid);
|
pg.misplaced_objects.erase(oid);
|
||||||
if (!pg.misplaced_objects.size())
|
if (!pg.misplaced_objects.size() && !pg.copies_to_delete_after_sync.size())
|
||||||
{
|
{
|
||||||
pg.state = pg.state & ~PG_HAS_MISPLACED;
|
pg.state = pg.state & ~PG_HAS_MISPLACED;
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
void osd_t::continue_chained_read(osd_op_t *cur_op)
|
void osd_t::continue_chained_read(osd_op_t *cur_op)
|
||||||
{
|
{
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
auto & pg = *op_data->pg;
|
auto pg = op_data->pg;
|
||||||
if (op_data->st == 1)
|
if (op_data->st == 1)
|
||||||
goto resume_1;
|
goto resume_1;
|
||||||
else if (op_data->st == 2)
|
else if (op_data->st == 2)
|
||||||
@@ -17,7 +17,7 @@ void osd_t::continue_chained_read(osd_op_t *cur_op)
|
|||||||
else if (op_data->st == 4)
|
else if (op_data->st == 4)
|
||||||
goto resume_4;
|
goto resume_4;
|
||||||
cur_op->reply.rw.bitmap_len = 0;
|
cur_op->reply.rw.bitmap_len = 0;
|
||||||
for (int role = 0; role < pg.pg_data_size; role++)
|
for (int role = 0; role < (pg ? pg->pg_data_size : 1); role++)
|
||||||
{
|
{
|
||||||
op_data->stripes[role].read_start = op_data->stripes[role].req_start;
|
op_data->stripes[role].read_start = op_data->stripes[role].req_start;
|
||||||
op_data->stripes[role].read_end = op_data->stripes[role].req_end;
|
op_data->stripes[role].read_end = op_data->stripes[role].req_end;
|
||||||
@@ -40,10 +40,10 @@ resume_3:
|
|||||||
resume_4:
|
resume_4:
|
||||||
if (op_data->errors > 0)
|
if (op_data->errors > 0)
|
||||||
{
|
{
|
||||||
if (op_data->errcode == -EIO || op_data->errcode == -EDOM)
|
if (pg && (op_data->errcode == -EIO || op_data->errcode == -EDOM))
|
||||||
{
|
{
|
||||||
// Handle corrupted reads and retry...
|
// Handle corrupted reads and retry...
|
||||||
check_corrupted_chained(pg, cur_op);
|
check_corrupted_chained(*pg, cur_op);
|
||||||
free(cur_op->buf);
|
free(cur_op->buf);
|
||||||
cur_op->buf = NULL;
|
cur_op->buf = NULL;
|
||||||
free(op_data->chain_reads);
|
free(op_data->chain_reads);
|
||||||
@@ -63,31 +63,30 @@ resume_4:
|
|||||||
finish_op(cur_op, cur_op->req.rw.len);
|
finish_op(cur_op, cur_op->req.rw.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int osd_t::read_bitmaps(osd_op_t *cur_op, pg_t & pg, int base_state)
|
int osd_t::read_bitmaps(osd_op_t *cur_op, pg_t *pg, int base_state)
|
||||||
{
|
{
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
if (op_data->st == base_state)
|
if (op_data->st == base_state)
|
||||||
goto resume_0;
|
goto resume_0;
|
||||||
else if (op_data->st == base_state+1)
|
else if (op_data->st == base_state+1)
|
||||||
goto resume_1;
|
goto resume_1;
|
||||||
if (pg.state == PG_ACTIVE && pg.scheme == POOL_SCHEME_REPLICATED)
|
if (!pg || pg->state == PG_ACTIVE && pg->scheme == POOL_SCHEME_REPLICATED)
|
||||||
{
|
{
|
||||||
// Happy path for clean replicated PGs (all bitmaps are available locally)
|
// Happy path for clean replicated PGs (all bitmaps are available locally)
|
||||||
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
for (int chain_num = 0; chain_num < op_data->chain_size; chain_num++)
|
for (int chain_num = 0; chain_num < op_data->chain_size; chain_num++)
|
||||||
{
|
{
|
||||||
object_id cur_oid = { .inode = op_data->read_chain[chain_num], .stripe = op_data->oid.stripe };
|
object_id cur_oid = { .inode = op_data->read_chain[chain_num], .stripe = op_data->oid.stripe };
|
||||||
auto vo_it = pg.ver_override.find(cur_oid);
|
|
||||||
auto read_version = (vo_it != pg.ver_override.end() ? vo_it->second : UINT64_MAX);
|
|
||||||
// Read bitmap synchronously from the local database
|
// Read bitmap synchronously from the local database
|
||||||
bs->read_bitmap(
|
bs->read_bitmap(
|
||||||
cur_oid, read_version, (uint8_t*)op_data->snapshot_bitmaps + chain_num*clean_entry_bitmap_size,
|
cur_oid, UINT64_MAX, (uint8_t*)op_data->snapshot_bitmaps + chain_num*clean_entry_bitmap_size,
|
||||||
!chain_num ? &cur_op->reply.rw.version : NULL
|
!chain_num ? &cur_op->reply.rw.version : NULL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (submit_bitmap_subops(cur_op, pg) < 0)
|
if (submit_bitmap_subops(cur_op, *pg) < 0)
|
||||||
{
|
{
|
||||||
// Failure
|
// Failure
|
||||||
finish_op(cur_op, -EIO);
|
finish_op(cur_op, -EIO);
|
||||||
@@ -101,32 +100,32 @@ resume_0:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
resume_1:
|
resume_1:
|
||||||
if (pg.scheme != POOL_SCHEME_REPLICATED)
|
if (pg->scheme != POOL_SCHEME_REPLICATED)
|
||||||
{
|
{
|
||||||
for (int chain_num = 0; chain_num < op_data->chain_size; chain_num++)
|
for (int chain_num = 0; chain_num < op_data->chain_size; chain_num++)
|
||||||
{
|
{
|
||||||
// Check if we need to reconstruct any bitmaps
|
// Check if we need to reconstruct any bitmaps
|
||||||
for (int i = 0; i < pg.pg_size; i++)
|
for (int i = 0; i < pg->pg_size; i++)
|
||||||
{
|
{
|
||||||
if (op_data->missing_flags[chain_num*pg.pg_size + i])
|
if (op_data->missing_flags[chain_num*pg->pg_size + i])
|
||||||
{
|
{
|
||||||
osd_rmw_stripe_t local_stripes[pg.pg_size];
|
osd_rmw_stripe_t local_stripes[pg->pg_size];
|
||||||
for (i = 0; i < pg.pg_size; i++)
|
for (i = 0; i < pg->pg_size; i++)
|
||||||
{
|
{
|
||||||
local_stripes[i] = (osd_rmw_stripe_t){
|
local_stripes[i] = (osd_rmw_stripe_t){
|
||||||
.bmp_buf = (uint8_t*)op_data->snapshot_bitmaps + (chain_num*pg.pg_size + i)*clean_entry_bitmap_size,
|
.bmp_buf = (uint8_t*)op_data->snapshot_bitmaps + (chain_num*pg->pg_size + i)*clean_entry_bitmap_size,
|
||||||
.read_start = 1,
|
.read_start = 1,
|
||||||
.read_end = 1,
|
.read_end = 1,
|
||||||
.missing = op_data->missing_flags[chain_num*pg.pg_size + i] && true,
|
.missing = op_data->missing_flags[chain_num*pg->pg_size + i] && true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (pg.scheme == POOL_SCHEME_XOR)
|
if (pg->scheme == POOL_SCHEME_XOR)
|
||||||
{
|
{
|
||||||
reconstruct_stripes_xor(local_stripes, pg.pg_size, clean_entry_bitmap_size);
|
reconstruct_stripes_xor(local_stripes, pg->pg_size, clean_entry_bitmap_size);
|
||||||
}
|
}
|
||||||
else if (pg.scheme == POOL_SCHEME_EC)
|
else if (pg->scheme == POOL_SCHEME_EC)
|
||||||
{
|
{
|
||||||
reconstruct_stripes_ec(local_stripes, pg.pg_size, pg.pg_data_size, clean_entry_bitmap_size);
|
reconstruct_stripes_ec(local_stripes, pg->pg_size, pg->pg_data_size, clean_entry_bitmap_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -139,6 +138,7 @@ resume_1:
|
|||||||
|
|
||||||
int osd_t::collect_bitmap_requests(osd_op_t *cur_op, pg_t & pg, std::vector<bitmap_request_t> & bitmap_requests)
|
int osd_t::collect_bitmap_requests(osd_op_t *cur_op, pg_t & pg, std::vector<bitmap_request_t> & bitmap_requests)
|
||||||
{
|
{
|
||||||
|
assert(&pg);
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
for (int chain_num = 0; chain_num < op_data->chain_size; chain_num++)
|
for (int chain_num = 0; chain_num < op_data->chain_size; chain_num++)
|
||||||
{
|
{
|
||||||
@@ -216,6 +216,7 @@ int osd_t::collect_bitmap_requests(osd_op_t *cur_op, pg_t & pg, std::vector<bitm
|
|||||||
|
|
||||||
int osd_t::submit_bitmap_subops(osd_op_t *cur_op, pg_t & pg)
|
int osd_t::submit_bitmap_subops(osd_op_t *cur_op, pg_t & pg)
|
||||||
{
|
{
|
||||||
|
assert(&pg);
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
std::vector<bitmap_request_t> *bitmap_requests = new std::vector<bitmap_request_t>();
|
std::vector<bitmap_request_t> *bitmap_requests = new std::vector<bitmap_request_t>();
|
||||||
if (collect_bitmap_requests(cur_op, pg, *bitmap_requests) < 0)
|
if (collect_bitmap_requests(cur_op, pg, *bitmap_requests) < 0)
|
||||||
@@ -382,12 +383,12 @@ std::vector<osd_chain_read_t> osd_t::collect_chained_read_requests(osd_op_t *cur
|
|||||||
return chain_reads;
|
return chain_reads;
|
||||||
}
|
}
|
||||||
|
|
||||||
int osd_t::submit_chained_read_requests(pg_t & pg, osd_op_t *cur_op)
|
int osd_t::submit_chained_read_requests(pg_t *pg, osd_op_t *cur_op)
|
||||||
{
|
{
|
||||||
// Decide which parts of which objects we need to read based on bitmaps
|
// Decide which parts of which objects we need to read based on bitmaps
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
auto chain_reads = collect_chained_read_requests(cur_op);
|
auto chain_reads = collect_chained_read_requests(cur_op);
|
||||||
int stripe_count = (pg.scheme == POOL_SCHEME_REPLICATED ? 1 : pg.pg_size);
|
int stripe_count = (!pg || pg->scheme == POOL_SCHEME_REPLICATED ? 1 : pg->pg_size);
|
||||||
op_data->chain_read_count = chain_reads.size();
|
op_data->chain_read_count = chain_reads.size();
|
||||||
op_data->chain_reads = (osd_chain_read_t*)calloc_or_die(
|
op_data->chain_reads = (osd_chain_read_t*)calloc_or_die(
|
||||||
1, sizeof(osd_chain_read_t) * chain_reads.size()
|
1, sizeof(osd_chain_read_t) * chain_reads.size()
|
||||||
@@ -408,23 +409,23 @@ int osd_t::submit_chained_read_requests(pg_t & pg, osd_op_t *cur_op)
|
|||||||
object_id cur_oid = { .inode = chain_reads[cri].inode, .stripe = op_data->oid.stripe };
|
object_id cur_oid = { .inode = chain_reads[cri].inode, .stripe = op_data->oid.stripe };
|
||||||
// FIXME: maybe introduce split_read_stripes to shorten these lines and to remove read_start=req_start
|
// FIXME: maybe introduce split_read_stripes to shorten these lines and to remove read_start=req_start
|
||||||
osd_rmw_stripe_t *stripes = chain_stripes + chain_reads[cri].chain_pos*stripe_count;
|
osd_rmw_stripe_t *stripes = chain_stripes + chain_reads[cri].chain_pos*stripe_count;
|
||||||
split_stripes(pg.pg_data_size, bs_block_size, chain_reads[cri].offset, chain_reads[cri].len, stripes);
|
split_stripes(pg ? pg->pg_data_size : 1, bs_block_size, chain_reads[cri].offset, chain_reads[cri].len, stripes);
|
||||||
if (pg.scheme == POOL_SCHEME_REPLICATED && !stripes[0].req_end)
|
if ((!pg || pg->scheme == POOL_SCHEME_REPLICATED) && !stripes[0].req_end)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int role = 0; role < pg.pg_data_size; role++)
|
for (int role = 0; role < (pg ? pg->pg_data_size : 1); role++)
|
||||||
{
|
{
|
||||||
stripes[role].read_start = stripes[role].req_start;
|
stripes[role].read_start = stripes[role].req_start;
|
||||||
stripes[role].read_end = stripes[role].req_end;
|
stripes[role].read_end = stripes[role].req_end;
|
||||||
}
|
}
|
||||||
uint64_t *cur_set = pg.cur_set.data();
|
uint64_t *cur_set = pg ? pg->cur_set.data() : &this->osd_num;
|
||||||
if (pg.state != PG_ACTIVE)
|
if (pg && pg->state != PG_ACTIVE)
|
||||||
{
|
{
|
||||||
cur_set = get_object_osd_set(pg, cur_oid, &op_data->chain_states[chain_reads[cri].chain_pos]);
|
cur_set = get_object_osd_set(*pg, cur_oid, &op_data->chain_states[chain_reads[cri].chain_pos]);
|
||||||
if (pg.scheme != POOL_SCHEME_REPLICATED)
|
if (pg->scheme != POOL_SCHEME_REPLICATED)
|
||||||
{
|
{
|
||||||
if (extend_missing_stripes(stripes, cur_set, pg.pg_data_size, pg.pg_size) < 0)
|
if (extend_missing_stripes(stripes, cur_set, pg->pg_data_size, pg->pg_size) < 0)
|
||||||
{
|
{
|
||||||
free(op_data->chain_reads);
|
free(op_data->chain_reads);
|
||||||
op_data->chain_reads = NULL;
|
op_data->chain_reads = NULL;
|
||||||
@@ -445,14 +446,14 @@ int osd_t::submit_chained_read_requests(pg_t & pg, osd_op_t *cur_op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pg.scheme == POOL_SCHEME_REPLICATED)
|
if (!pg || pg->scheme == POOL_SCHEME_REPLICATED)
|
||||||
{
|
{
|
||||||
n_subops++;
|
n_subops++;
|
||||||
read_buffer_size += stripes[0].read_end - stripes[0].read_start;
|
read_buffer_size += stripes[0].read_end - stripes[0].read_start;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int role = 0; role < pg.pg_size; role++)
|
for (int role = 0; role < pg->pg_size; role++)
|
||||||
{
|
{
|
||||||
if (stripes[role].read_end > 0 && cur_set[role] != 0)
|
if (stripes[role].read_end > 0 && cur_set[role] != 0)
|
||||||
n_subops++;
|
n_subops++;
|
||||||
@@ -490,19 +491,23 @@ int osd_t::submit_chained_read_requests(pg_t & pg, osd_op_t *cur_op)
|
|||||||
for (int cri = 0; cri < chain_reads.size(); cri++)
|
for (int cri = 0; cri < chain_reads.size(); cri++)
|
||||||
{
|
{
|
||||||
osd_rmw_stripe_t *stripes = chain_stripes + chain_reads[cri].chain_pos*stripe_count;
|
osd_rmw_stripe_t *stripes = chain_stripes + chain_reads[cri].chain_pos*stripe_count;
|
||||||
if (pg.scheme == POOL_SCHEME_REPLICATED && !stripes[0].req_end)
|
if ((!pg || pg->scheme == POOL_SCHEME_REPLICATED) && !stripes[0].req_end)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
object_id cur_oid = { .inode = chain_reads[cri].inode, .stripe = op_data->oid.stripe };
|
object_id cur_oid = { .inode = chain_reads[cri].inode, .stripe = op_data->oid.stripe };
|
||||||
auto vo_it = pg.ver_override.find(cur_oid);
|
uint64_t target_ver = UINT64_MAX;
|
||||||
uint64_t target_ver = vo_it != pg.ver_override.end() ? vo_it->second : UINT64_MAX;
|
if (pg)
|
||||||
auto cur_state = op_data->chain_states[chain_reads[cri].chain_pos];
|
|
||||||
uint64_t *cur_set = (pg.state != PG_ACTIVE && cur_state ? cur_state->read_target.data() : pg.cur_set.data());
|
|
||||||
int zero_read = -1;
|
|
||||||
if (pg.scheme == POOL_SCHEME_REPLICATED)
|
|
||||||
{
|
{
|
||||||
for (int role = 0; role < pg.pg_size; role++)
|
auto vo_it = pg->ver_override.find(cur_oid);
|
||||||
|
target_ver = vo_it != pg->ver_override.end() ? vo_it->second : UINT64_MAX;
|
||||||
|
}
|
||||||
|
auto cur_state = op_data->chain_states[chain_reads[cri].chain_pos];
|
||||||
|
uint64_t *cur_set = (!pg ? &this->osd_num : (pg->state != PG_ACTIVE && cur_state ? cur_state->read_target.data() : pg->cur_set.data()));
|
||||||
|
int zero_read = -1;
|
||||||
|
if (!pg || pg->scheme == POOL_SCHEME_REPLICATED)
|
||||||
|
{
|
||||||
|
for (int role = 0; role < (pg ? pg->pg_size : 1); role++)
|
||||||
if (cur_set[role] == this->osd_num || zero_read == -1)
|
if (cur_set[role] == this->osd_num || zero_read == -1)
|
||||||
zero_read = role;
|
zero_read = role;
|
||||||
}
|
}
|
||||||
@@ -514,6 +519,7 @@ int osd_t::submit_chained_read_requests(pg_t & pg, osd_op_t *cur_op)
|
|||||||
|
|
||||||
void osd_t::check_corrupted_chained(pg_t & pg, osd_op_t *cur_op)
|
void osd_t::check_corrupted_chained(pg_t & pg, osd_op_t *cur_op)
|
||||||
{
|
{
|
||||||
|
assert(&pg);
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
int stripe_count = (pg.scheme == POOL_SCHEME_REPLICATED ? 1 : pg.pg_size);
|
int stripe_count = (pg.scheme == POOL_SCHEME_REPLICATED ? 1 : pg.pg_size);
|
||||||
osd_rmw_stripe_t *chain_stripes = (osd_rmw_stripe_t*)(
|
osd_rmw_stripe_t *chain_stripes = (osd_rmw_stripe_t*)(
|
||||||
@@ -539,33 +545,32 @@ void osd_t::check_corrupted_chained(pg_t & pg, osd_op_t *cur_op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void osd_t::send_chained_read_results(pg_t & pg, osd_op_t *cur_op)
|
void osd_t::send_chained_read_results(pg_t *pg, osd_op_t *cur_op)
|
||||||
{
|
{
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
int stripe_count = (pg.scheme == POOL_SCHEME_REPLICATED ? 1 : pg.pg_size);
|
int stripe_count = (!pg || pg->scheme == POOL_SCHEME_REPLICATED ? 1 : pg->pg_size);
|
||||||
osd_rmw_stripe_t *chain_stripes = (osd_rmw_stripe_t*)(
|
osd_rmw_stripe_t *chain_stripes = (osd_rmw_stripe_t*)(
|
||||||
(uint8_t*)op_data->chain_reads + sizeof(osd_chain_read_t) * op_data->chain_read_count
|
(uint8_t*)op_data->chain_reads + sizeof(osd_chain_read_t) * op_data->chain_read_count
|
||||||
);
|
);
|
||||||
// Reconstruct parts if needed
|
// Reconstruct parts if needed
|
||||||
if (op_data->degraded)
|
if (op_data->degraded)
|
||||||
{
|
{
|
||||||
int stripe_count = (pg.scheme == POOL_SCHEME_REPLICATED ? 1 : pg.pg_size);
|
|
||||||
for (int cri = 0; cri < op_data->chain_read_count; cri++)
|
for (int cri = 0; cri < op_data->chain_read_count; cri++)
|
||||||
{
|
{
|
||||||
// Reconstruct missing stripes
|
// Reconstruct missing stripes
|
||||||
osd_rmw_stripe_t *stripes = chain_stripes + op_data->chain_reads[cri].chain_pos*stripe_count;
|
osd_rmw_stripe_t *stripes = chain_stripes + op_data->chain_reads[cri].chain_pos*stripe_count;
|
||||||
if (pg.scheme == POOL_SCHEME_XOR)
|
if (pg->scheme == POOL_SCHEME_XOR)
|
||||||
{
|
{
|
||||||
reconstruct_stripes_xor(stripes, pg.pg_size, clean_entry_bitmap_size);
|
reconstruct_stripes_xor(stripes, pg->pg_size, clean_entry_bitmap_size);
|
||||||
}
|
}
|
||||||
else if (pg.scheme == POOL_SCHEME_EC)
|
else if (pg->scheme == POOL_SCHEME_EC)
|
||||||
{
|
{
|
||||||
reconstruct_stripes_ec(stripes, pg.pg_size, pg.pg_data_size, clean_entry_bitmap_size);
|
reconstruct_stripes_ec(stripes, pg->pg_size, pg->pg_data_size, clean_entry_bitmap_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Send bitmap
|
// Send bitmap
|
||||||
cur_op->reply.rw.bitmap_len = pg.pg_data_size * clean_entry_bitmap_size;
|
cur_op->reply.rw.bitmap_len = (pg ? pg->pg_data_size : 1) * clean_entry_bitmap_size;
|
||||||
cur_op->iov.push_back(op_data->stripes[0].bmp_buf, cur_op->reply.rw.bitmap_len);
|
cur_op->iov.push_back(op_data->stripes[0].bmp_buf, cur_op->reply.rw.bitmap_len);
|
||||||
// And finally compose the result
|
// And finally compose the result
|
||||||
uint64_t sent = 0;
|
uint64_t sent = 0;
|
||||||
|
|||||||
@@ -67,26 +67,20 @@ void osd_t::finish_op(osd_op_t *cur_op, int retval)
|
|||||||
if (cur_op->req.hdr.opcode == OSD_OP_DELETE)
|
if (cur_op->req.hdr.opcode == OSD_OP_DELETE)
|
||||||
{
|
{
|
||||||
if (cur_op->op_data)
|
if (cur_op->op_data)
|
||||||
inode_stats[cur_op->req.rw.inode].op_bytes[inode_st_op] += cur_op->op_data->pg->pg_data_size * bs_block_size;
|
{
|
||||||
|
inode_stats[cur_op->req.rw.inode].op_bytes[inode_st_op] += (cur_op->op_data->pg
|
||||||
|
? cur_op->op_data->pg->pg_data_size : 1) * bs_block_size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
inode_stats[cur_op->req.rw.inode].op_bytes[inode_st_op] += cur_op->req.rw.len;
|
inode_stats[cur_op->req.rw.inode].op_bytes[inode_st_op] += cur_op->req.rw.len;
|
||||||
}
|
}
|
||||||
if (cur_op->op_data)
|
if (cur_op->op_data)
|
||||||
{
|
{
|
||||||
if (cur_op->op_data->pg_num > 0)
|
if (cur_op->op_data->pg)
|
||||||
{
|
{
|
||||||
auto & pg = *cur_op->op_data->pg;
|
auto & pg = *cur_op->op_data->pg;
|
||||||
pg.inflight--;
|
rm_inflight(pg);
|
||||||
assert(pg.inflight >= 0);
|
|
||||||
if ((pg.state & PG_STOPPING) && pg.inflight == 0 && !pg.flush_batch)
|
|
||||||
{
|
|
||||||
finish_stop_pg(pg);
|
|
||||||
}
|
|
||||||
else if ((pg.state & PG_REPEERING) && pg.inflight == 0 && !pg.flush_batch)
|
|
||||||
{
|
|
||||||
start_pg_peering(pg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
assert(!cur_op->op_data->subops);
|
assert(!cur_op->op_data->subops);
|
||||||
free(cur_op->op_data);
|
free(cur_op->op_data);
|
||||||
@@ -126,10 +120,10 @@ void osd_t::submit_primary_subops(int submit_type, uint64_t op_version, const ui
|
|||||||
bool wr = submit_type == SUBMIT_WRITE;
|
bool wr = submit_type == SUBMIT_WRITE;
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
osd_rmw_stripe_t *stripes = op_data->stripes;
|
osd_rmw_stripe_t *stripes = op_data->stripes;
|
||||||
bool rep = op_data->pg->scheme == POOL_SCHEME_REPLICATED;
|
bool rep = !op_data->pg || op_data->pg->scheme == POOL_SCHEME_REPLICATED;
|
||||||
// Allocate subops
|
// Allocate subops
|
||||||
int n_subops = 0, zero_read = -1;
|
int n_subops = 0, zero_read = -1;
|
||||||
for (int role = 0; role < op_data->pg->pg_size; role++)
|
for (int role = 0; role < (op_data->pg ? op_data->pg->pg_size : 1); role++)
|
||||||
{
|
{
|
||||||
if (osd_set[role] == this->osd_num || osd_set[role] != 0 && zero_read == -1)
|
if (osd_set[role] == this->osd_num || osd_set[role] != 0 && zero_read == -1)
|
||||||
zero_read = role;
|
zero_read = role;
|
||||||
@@ -152,11 +146,11 @@ void osd_t::submit_primary_subops(int submit_type, uint64_t op_version, const ui
|
|||||||
int osd_t::submit_primary_subop_batch(int submit_type, inode_t inode, uint64_t op_version,
|
int osd_t::submit_primary_subop_batch(int submit_type, inode_t inode, uint64_t op_version,
|
||||||
osd_rmw_stripe_t *stripes, const uint64_t* osd_set, osd_op_t *cur_op, int subop_idx, int zero_read)
|
osd_rmw_stripe_t *stripes, const uint64_t* osd_set, osd_op_t *cur_op, int subop_idx, int zero_read)
|
||||||
{
|
{
|
||||||
bool rep = cur_op->op_data->pg->scheme == POOL_SCHEME_REPLICATED;
|
bool rep = !cur_op->op_data->pg || cur_op->op_data->pg->scheme == POOL_SCHEME_REPLICATED;
|
||||||
bool wr = submit_type == SUBMIT_WRITE;
|
bool wr = submit_type == SUBMIT_WRITE;
|
||||||
osd_primary_op_data_t *op_data = cur_op->op_data;
|
osd_primary_op_data_t *op_data = cur_op->op_data;
|
||||||
int i = subop_idx;
|
int i = subop_idx;
|
||||||
for (int role = 0; role < op_data->pg->pg_size; role++)
|
for (int role = 0; role < (op_data->pg ? op_data->pg->pg_size : 1); role++)
|
||||||
{
|
{
|
||||||
// We always submit zero-length writes to all replicas, even if the stripe is not modified
|
// We always submit zero-length writes to all replicas, even if the stripe is not modified
|
||||||
if (!(wr || !rep && stripes[role].read_end != 0 || zero_read == role || submit_type == SUBMIT_SCRUB_READ))
|
if (!(wr || !rep && stripes[role].read_end != 0 || zero_read == role || submit_type == SUBMIT_SCRUB_READ))
|
||||||
@@ -423,15 +417,25 @@ void osd_t::handle_primary_subop(osd_op_t *subop, osd_op_t *cur_op)
|
|||||||
if (retval != expected)
|
if (retval != expected)
|
||||||
{
|
{
|
||||||
int64_t peer_osd = (msgr.clients.find(subop->peer_fd) != msgr.clients.end()
|
int64_t peer_osd = (msgr.clients.find(subop->peer_fd) != msgr.clients.end()
|
||||||
? msgr.clients[subop->peer_fd]->osd_num : -subop->peer_fd);
|
? msgr.clients[subop->peer_fd]->osd_num : 0);
|
||||||
if (opcode == OSD_OP_SEC_READ || opcode == OSD_OP_SEC_WRITE || opcode == OSD_OP_SEC_WRITE_STABLE)
|
if (opcode == OSD_OP_SEC_READ || opcode == OSD_OP_SEC_WRITE || opcode == OSD_OP_SEC_WRITE_STABLE)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
subop->peer_fd >= 0
|
subop->peer_fd >= 0
|
||||||
? "%1$s subop to %2$jx:%3$jx v%4$ju failed on osd %7$jd: retval = %5$d (expected %6$d)\n"
|
? (peer_osd > 0
|
||||||
|
? "%1$s subop to %2$jx:%3$jx v%4$ju failed on osd %7$ju: retval = %5$d (expected %6$d)\n"
|
||||||
|
: "%1$s subop to %2$jx:%3$jx v%4$ju failed on peer %8$d: retval = %5$d (expected %6$d)\n")
|
||||||
: "%1$s subop to %2$jx:%3$jx v%4$ju failed locally: retval = %5$d (expected %6$d)\n",
|
: "%1$s subop to %2$jx:%3$jx v%4$ju failed locally: retval = %5$d (expected %6$d)\n",
|
||||||
osd_op_names[opcode], subop->req.sec_rw.oid.inode, subop->req.sec_rw.oid.stripe, subop->req.sec_rw.version,
|
osd_op_names[opcode], subop->req.sec_rw.oid.inode, subop->req.sec_rw.oid.stripe, subop->req.sec_rw.version,
|
||||||
retval, expected, peer_osd
|
retval, expected, peer_osd, subop->peer_fd
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (opcode == OSD_OP_SEC_DELETE)
|
||||||
|
{
|
||||||
|
printf(
|
||||||
|
"delete subop to %jx:%jx v%ju failed on osd %jd: retval = %d (expected %d)\n",
|
||||||
|
subop->req.sec_del.oid.inode, subop->req.sec_del.oid.stripe, subop->req.sec_del.version,
|
||||||
|
peer_osd, retval, expected
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -80,15 +80,17 @@ resume_2:
|
|||||||
this->unstable_writes.clear();
|
this->unstable_writes.clear();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
op_data->dirty_pg_count = dirty_pgs.size();
|
||||||
|
op_data->dirty_osd_count = dirty_osds.size();
|
||||||
void *dirty_buf = malloc_or_die(
|
void *dirty_buf = malloc_or_die(
|
||||||
sizeof(pool_pg_num_t)*dirty_pgs.size() +
|
sizeof(pool_pg_num_t)*dirty_pgs.size() +
|
||||||
|
sizeof(uint64_t)*dirty_pgs.size() +
|
||||||
sizeof(osd_num_t)*dirty_osds.size() +
|
sizeof(osd_num_t)*dirty_osds.size() +
|
||||||
sizeof(obj_ver_osd_t)*this->copies_to_delete_after_sync_count
|
sizeof(obj_ver_osd_t)*this->copies_to_delete_after_sync_count
|
||||||
);
|
);
|
||||||
op_data->dirty_pgs = (pool_pg_num_t*)dirty_buf;
|
op_data->dirty_pgs = (pool_pg_num_t*)dirty_buf;
|
||||||
op_data->dirty_osds = (osd_num_t*)((uint8_t*)dirty_buf + sizeof(pool_pg_num_t)*dirty_pgs.size());
|
uint64_t *pg_del_counts = (uint64_t*)((uint8_t*)op_data->dirty_pgs + (sizeof(pool_pg_num_t))*op_data->dirty_pg_count);
|
||||||
op_data->dirty_pg_count = dirty_pgs.size();
|
op_data->dirty_osds = (osd_num_t*)((uint8_t*)pg_del_counts + 8*op_data->dirty_pg_count);
|
||||||
op_data->dirty_osd_count = dirty_osds.size();
|
|
||||||
if (this->copies_to_delete_after_sync_count)
|
if (this->copies_to_delete_after_sync_count)
|
||||||
{
|
{
|
||||||
op_data->copies_to_delete_count = 0;
|
op_data->copies_to_delete_count = 0;
|
||||||
@@ -103,16 +105,16 @@ resume_2:
|
|||||||
sizeof(obj_ver_osd_t)*pg.copies_to_delete_after_sync.size()
|
sizeof(obj_ver_osd_t)*pg.copies_to_delete_after_sync.size()
|
||||||
);
|
);
|
||||||
op_data->copies_to_delete_count += pg.copies_to_delete_after_sync.size();
|
op_data->copies_to_delete_count += pg.copies_to_delete_after_sync.size();
|
||||||
this->copies_to_delete_after_sync_count -= pg.copies_to_delete_after_sync.size();
|
|
||||||
pg.copies_to_delete_after_sync.clear();
|
|
||||||
}
|
}
|
||||||
assert(this->copies_to_delete_after_sync_count == 0);
|
|
||||||
}
|
}
|
||||||
int dpg = 0;
|
int dpg = 0;
|
||||||
for (auto dirty_pg_num: dirty_pgs)
|
for (auto dirty_pg_num: dirty_pgs)
|
||||||
{
|
{
|
||||||
pgs.at(dirty_pg_num).inflight++;
|
auto & pg = pgs.at(dirty_pg_num);
|
||||||
op_data->dirty_pgs[dpg++] = dirty_pg_num;
|
pg.inflight++;
|
||||||
|
op_data->dirty_pgs[dpg] = dirty_pg_num;
|
||||||
|
pg_del_counts[dpg] = pg.copies_to_delete_after_sync.size();
|
||||||
|
dpg++;
|
||||||
}
|
}
|
||||||
dirty_pgs.clear();
|
dirty_pgs.clear();
|
||||||
dpg = 0;
|
dpg = 0;
|
||||||
@@ -183,23 +185,6 @@ resume_6:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (op_data->copies_to_delete)
|
|
||||||
{
|
|
||||||
// Return 'copies to delete' back into respective PGs
|
|
||||||
for (int i = 0; i < op_data->copies_to_delete_count; i++)
|
|
||||||
{
|
|
||||||
auto & w = op_data->copies_to_delete[i];
|
|
||||||
auto & pg = pgs.at((pool_pg_num_t){
|
|
||||||
.pool_id = INODE_POOL(w.oid.inode),
|
|
||||||
.pg_num = map_to_pg(w.oid, st_cli.pool_config.at(INODE_POOL(w.oid.inode)).pg_stripe_size),
|
|
||||||
});
|
|
||||||
if (pg.state & PG_ACTIVE)
|
|
||||||
{
|
|
||||||
pg.copies_to_delete_after_sync.push_back(w);
|
|
||||||
copies_to_delete_after_sync_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (op_data->copies_to_delete)
|
else if (op_data->copies_to_delete)
|
||||||
{
|
{
|
||||||
@@ -213,6 +198,22 @@ resume_8:
|
|||||||
{
|
{
|
||||||
goto resume_6;
|
goto resume_6;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
uint64_t *pg_del_counts = (uint64_t*)((uint8_t*)op_data->dirty_pgs + (sizeof(pool_pg_num_t))*op_data->dirty_pg_count);
|
||||||
|
for (int i = 0; i < op_data->dirty_pg_count; i++)
|
||||||
|
{
|
||||||
|
auto & pg = pgs.at(op_data->dirty_pgs[i]);
|
||||||
|
auto n = pg_del_counts[i];
|
||||||
|
assert(copies_to_delete_after_sync_count >= n);
|
||||||
|
copies_to_delete_after_sync_count -= n;
|
||||||
|
pg.copies_to_delete_after_sync.erase(pg.copies_to_delete_after_sync.begin(), pg.copies_to_delete_after_sync.begin()+n);
|
||||||
|
if (!pg.misplaced_objects.size() && !pg.copies_to_delete_after_sync.size() && (pg.state & PG_HAS_MISPLACED))
|
||||||
|
{
|
||||||
|
pg.state = pg.state & ~PG_HAS_MISPLACED;
|
||||||
|
report_pg_state(pg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (immediate_commit == IMMEDIATE_NONE)
|
if (immediate_commit == IMMEDIATE_NONE)
|
||||||
{
|
{
|
||||||
// Mark OSDs as dirty because deletions have to be synced too!
|
// Mark OSDs as dirty because deletions have to be synced too!
|
||||||
@@ -226,15 +227,7 @@ resume_8:
|
|||||||
for (int i = 0; i < op_data->dirty_pg_count; i++)
|
for (int i = 0; i < op_data->dirty_pg_count; i++)
|
||||||
{
|
{
|
||||||
auto & pg = pgs.at(op_data->dirty_pgs[i]);
|
auto & pg = pgs.at(op_data->dirty_pgs[i]);
|
||||||
pg.inflight--;
|
rm_inflight(pg);
|
||||||
if ((pg.state & PG_STOPPING) && pg.inflight == 0 && !pg.flush_batch)
|
|
||||||
{
|
|
||||||
finish_stop_pg(pg);
|
|
||||||
}
|
|
||||||
else if ((pg.state & PG_REPEERING) && pg.inflight == 0 && !pg.flush_batch)
|
|
||||||
{
|
|
||||||
start_pg_peering(pg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// FIXME: Free those in the destructor (not here)?
|
// FIXME: Free those in the destructor (not here)?
|
||||||
free(op_data->dirty_pgs);
|
free(op_data->dirty_pgs);
|
||||||
|
|||||||
@@ -301,6 +301,38 @@ resume_12:
|
|||||||
}
|
}
|
||||||
if (op_data->object_state)
|
if (op_data->object_state)
|
||||||
{
|
{
|
||||||
|
// Any kind of a non-clean object can have extra chunks, because we don't record objects
|
||||||
|
// as degraded & misplaced or incomplete & misplaced at the same time. So try to remove extra chunks
|
||||||
|
if (immediate_commit != IMMEDIATE_ALL)
|
||||||
|
{
|
||||||
|
// We can't remove extra chunks yet if fsyncs are explicit, because
|
||||||
|
// new copies may not be committed to stable storage yet
|
||||||
|
// We can only remove extra chunks after a successful SYNC for this PG
|
||||||
|
for (auto & chunk: op_data->object_state->osd_set)
|
||||||
|
{
|
||||||
|
// Check is the same as in submit_primary_del_subops()
|
||||||
|
if (pg.scheme == POOL_SCHEME_REPLICATED
|
||||||
|
? !contains_osd(pg.cur_set.data(), pg.pg_size, chunk.osd_num)
|
||||||
|
: (chunk.osd_num != pg.cur_set[chunk.role]))
|
||||||
|
{
|
||||||
|
pg.copies_to_delete_after_sync.push_back((obj_ver_osd_t){
|
||||||
|
.osd_num = chunk.osd_num,
|
||||||
|
.oid = {
|
||||||
|
.inode = op_data->oid.inode,
|
||||||
|
.stripe = op_data->oid.stripe | (pg.scheme == POOL_SCHEME_REPLICATED ? 0 : chunk.role),
|
||||||
|
},
|
||||||
|
.version = op_data->fact_ver,
|
||||||
|
});
|
||||||
|
copies_to_delete_after_sync_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pg.copies_to_delete_after_sync.size() && !(pg.state & PG_HAS_MISPLACED))
|
||||||
|
{
|
||||||
|
// PG can't be active+clean until extra copies aren't removed, so mark it as PG_HAS_MISPLACED
|
||||||
|
pg.state |= PG_HAS_MISPLACED;
|
||||||
|
//this->pg_state_dirty.insert({ .pool_id = pg.pool_id, .pg_num = pg.pg_num });
|
||||||
|
}
|
||||||
|
}
|
||||||
// We must forget the unclean state of the object before deleting it
|
// We must forget the unclean state of the object before deleting it
|
||||||
// so the next reads don't accidentally read a deleted version
|
// so the next reads don't accidentally read a deleted version
|
||||||
// And it should be done at the same time as the removal of the version override
|
// And it should be done at the same time as the removal of the version override
|
||||||
@@ -309,6 +341,7 @@ resume_12:
|
|||||||
}
|
}
|
||||||
resume_6:
|
resume_6:
|
||||||
resume_7:
|
resume_7:
|
||||||
|
op_data->n_subops = 0;
|
||||||
if (!remember_unstable_write(cur_op, pg, pg.cur_loc_set, 6))
|
if (!remember_unstable_write(cur_op, pg, pg.cur_loc_set, 6))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -344,48 +377,21 @@ resume_7:
|
|||||||
);
|
);
|
||||||
recovery_stat[recovery_type].usec += usec;
|
recovery_stat[recovery_type].usec += usec;
|
||||||
}
|
}
|
||||||
// Any kind of a non-clean object can have extra chunks, because we don't record objects
|
if (immediate_commit == IMMEDIATE_ALL)
|
||||||
// as degraded & misplaced or incomplete & misplaced at the same time. So try to remove extra chunks
|
|
||||||
if (immediate_commit != IMMEDIATE_ALL)
|
|
||||||
{
|
|
||||||
// We can't remove extra chunks yet if fsyncs are explicit, because
|
|
||||||
// new copies may not be committed to stable storage yet
|
|
||||||
// We can only remove extra chunks after a successful SYNC for this PG
|
|
||||||
for (auto & chunk: op_data->object_state->osd_set)
|
|
||||||
{
|
|
||||||
// Check is the same as in submit_primary_del_subops()
|
|
||||||
if (pg.scheme == POOL_SCHEME_REPLICATED
|
|
||||||
? !contains_osd(pg.cur_set.data(), pg.pg_size, chunk.osd_num)
|
|
||||||
: (chunk.osd_num != pg.cur_set[chunk.role]))
|
|
||||||
{
|
|
||||||
pg.copies_to_delete_after_sync.push_back((obj_ver_osd_t){
|
|
||||||
.osd_num = chunk.osd_num,
|
|
||||||
.oid = {
|
|
||||||
.inode = op_data->oid.inode,
|
|
||||||
.stripe = op_data->oid.stripe | (pg.scheme == POOL_SCHEME_REPLICATED ? 0 : chunk.role),
|
|
||||||
},
|
|
||||||
.version = op_data->fact_ver,
|
|
||||||
});
|
|
||||||
copies_to_delete_after_sync_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
deref_object_state(pg, &op_data->object_state, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
submit_primary_del_subops(cur_op, pg.cur_set.data(), pg.pg_size, op_data->object_state->osd_set);
|
submit_primary_del_subops(cur_op, pg.cur_set.data(), pg.pg_size, op_data->object_state->osd_set);
|
||||||
deref_object_state(pg, &op_data->object_state, true);
|
}
|
||||||
if (op_data->n_subops > 0)
|
deref_object_state(pg, &op_data->object_state, true);
|
||||||
{
|
if (op_data->n_subops > 0)
|
||||||
|
{
|
||||||
resume_8:
|
resume_8:
|
||||||
op_data->st = 8;
|
op_data->st = 8;
|
||||||
return;
|
return;
|
||||||
resume_9:
|
resume_9:
|
||||||
if (op_data->errors > 0)
|
if (op_data->errors > 0)
|
||||||
{
|
{
|
||||||
pg_cancel_write_queue(pg, cur_op, op_data->oid, op_data->errcode);
|
pg_cancel_write_queue(pg, cur_op, op_data->oid, op_data->errcode);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-6
@@ -162,6 +162,7 @@ struct reed_sol_matrix_t
|
|||||||
int refs = 0;
|
int refs = 0;
|
||||||
int *je_data;
|
int *je_data;
|
||||||
uint8_t *isal_data;
|
uint8_t *isal_data;
|
||||||
|
int isal_item_size;
|
||||||
// 32 bytes = 256/8 = max pg_size/8
|
// 32 bytes = 256/8 = max pg_size/8
|
||||||
std::map<std::array<uint8_t, 32>, void*> subdata;
|
std::map<std::array<uint8_t, 32>, void*> subdata;
|
||||||
std::map<reed_sol_erased_t, void*> decodings;
|
std::map<reed_sol_erased_t, void*> decodings;
|
||||||
@@ -181,20 +182,42 @@ void use_ec(int pg_size, int pg_minsize, bool use)
|
|||||||
}
|
}
|
||||||
int *matrix = reed_sol_vandermonde_coding_matrix(pg_minsize, pg_size-pg_minsize, OSD_JERASURE_W);
|
int *matrix = reed_sol_vandermonde_coding_matrix(pg_minsize, pg_size-pg_minsize, OSD_JERASURE_W);
|
||||||
uint8_t *isal_table = NULL;
|
uint8_t *isal_table = NULL;
|
||||||
|
int item_size = 8;
|
||||||
#ifdef WITH_ISAL
|
#ifdef WITH_ISAL
|
||||||
uint8_t *isal_matrix = (uint8_t*)malloc_or_die(pg_minsize*(pg_size-pg_minsize));
|
uint8_t *isal_matrix = (uint8_t*)malloc_or_die(pg_minsize*(pg_size-pg_minsize));
|
||||||
for (int i = 0; i < pg_minsize*(pg_size-pg_minsize); i++)
|
for (int i = 0; i < pg_minsize*(pg_size-pg_minsize); i++)
|
||||||
{
|
{
|
||||||
isal_matrix[i] = matrix[i];
|
isal_matrix[i] = matrix[i];
|
||||||
}
|
}
|
||||||
isal_table = (uint8_t*)malloc_or_die(pg_minsize*(pg_size-pg_minsize)*32);
|
isal_table = (uint8_t*)calloc_or_die(1, pg_minsize*(pg_size-pg_minsize)*32);
|
||||||
ec_init_tables(pg_minsize, pg_size-pg_minsize, isal_matrix, isal_table);
|
ec_init_tables(pg_minsize, pg_size-pg_minsize, isal_matrix, isal_table);
|
||||||
free(isal_matrix);
|
free(isal_matrix);
|
||||||
|
for (int i = pg_minsize*(pg_size-pg_minsize)*8; i < pg_minsize*(pg_size-pg_minsize)*32; i++)
|
||||||
|
{
|
||||||
|
if (isal_table[i] != 0)
|
||||||
|
{
|
||||||
|
// ISA-L GF-NI version uses 8-byte table items
|
||||||
|
item_size = 32;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Sanity check: rows should never consist of all zeroes
|
||||||
|
uint8_t zero_row[pg_minsize*item_size];
|
||||||
|
memset(zero_row, 0, pg_minsize*item_size);
|
||||||
|
for (int i = 0; i < (pg_size-pg_minsize); i++)
|
||||||
|
{
|
||||||
|
if (memcmp(isal_table + i*pg_minsize*item_size, zero_row, pg_minsize*item_size) == 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "BUG or ISA-L incompatibility: EC tables shouldn't have all-zero rows\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
matrices[key] = (reed_sol_matrix_t){
|
matrices[key] = (reed_sol_matrix_t){
|
||||||
.refs = 0,
|
.refs = 0,
|
||||||
.je_data = matrix,
|
.je_data = matrix,
|
||||||
.isal_data = isal_table,
|
.isal_data = isal_table,
|
||||||
|
.isal_item_size = item_size,
|
||||||
};
|
};
|
||||||
rs_it = matrices.find(key);
|
rs_it = matrices.find(key);
|
||||||
}
|
}
|
||||||
@@ -235,7 +258,7 @@ static reed_sol_matrix_t* get_ec_matrix(int pg_size, int pg_minsize)
|
|||||||
// we don't need it. also it makes an extra allocation of int *erased on every call and doesn't cache
|
// we don't need it. also it makes an extra allocation of int *erased on every call and doesn't cache
|
||||||
// the decoding matrix.
|
// the decoding matrix.
|
||||||
// all these flaws are fixed in this function:
|
// all these flaws are fixed in this function:
|
||||||
static void* get_jerasure_decoding_matrix(osd_rmw_stripe_t *stripes, int pg_size, int pg_minsize)
|
static void* get_jerasure_decoding_matrix(osd_rmw_stripe_t *stripes, int pg_size, int pg_minsize, int *item_size)
|
||||||
{
|
{
|
||||||
int edd = 0;
|
int edd = 0;
|
||||||
int erased[pg_size];
|
int erased[pg_size];
|
||||||
@@ -292,6 +315,7 @@ static void* get_jerasure_decoding_matrix(osd_rmw_stripe_t *stripes, int pg_size
|
|||||||
int *erased_copy = (int*)(rectable + 32*smrow*pg_minsize);
|
int *erased_copy = (int*)(rectable + 32*smrow*pg_minsize);
|
||||||
memcpy(erased_copy, erased, pg_size*sizeof(int));
|
memcpy(erased_copy, erased, pg_size*sizeof(int));
|
||||||
matrix->decodings.emplace((reed_sol_erased_t){ .data = erased_copy, .size = pg_size }, rectable);
|
matrix->decodings.emplace((reed_sol_erased_t){ .data = erased_copy, .size = pg_size }, rectable);
|
||||||
|
*item_size = matrix->isal_item_size;
|
||||||
return rectable;
|
return rectable;
|
||||||
#else
|
#else
|
||||||
int *dm_ids = (int*)malloc_or_die(sizeof(int)*(pg_minsize + pg_minsize*pg_minsize + pg_size));
|
int *dm_ids = (int*)malloc_or_die(sizeof(int)*(pg_minsize + pg_minsize*pg_minsize + pg_size));
|
||||||
@@ -355,7 +379,8 @@ static void jerasure_matrix_encode_unaligned(int k, int m, int w, int *matrix, c
|
|||||||
#ifdef WITH_ISAL
|
#ifdef WITH_ISAL
|
||||||
void reconstruct_stripes_ec(osd_rmw_stripe_t *stripes, int pg_size, int pg_minsize, uint32_t bitmap_size)
|
void reconstruct_stripes_ec(osd_rmw_stripe_t *stripes, int pg_size, int pg_minsize, uint32_t bitmap_size)
|
||||||
{
|
{
|
||||||
uint8_t *dectable = (uint8_t*)get_jerasure_decoding_matrix(stripes, pg_size, pg_minsize);
|
int item_size = 0;
|
||||||
|
uint8_t *dectable = (uint8_t*)get_jerasure_decoding_matrix(stripes, pg_size, pg_minsize, &item_size);
|
||||||
if (!dectable)
|
if (!dectable)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -378,7 +403,7 @@ void reconstruct_stripes_ec(osd_rmw_stripe_t *stripes, int pg_size, int pg_minsi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ec_encode_data(
|
ec_encode_data(
|
||||||
read_end-read_start, pg_minsize, wanted, dectable + wanted_base*32*pg_minsize,
|
read_end-read_start, pg_minsize, wanted, dectable + wanted_base*item_size*pg_minsize,
|
||||||
data_ptrs, data_ptrs + pg_minsize
|
data_ptrs, data_ptrs + pg_minsize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -433,7 +458,7 @@ void reconstruct_stripes_ec(osd_rmw_stripe_t *stripes, int pg_size, int pg_minsi
|
|||||||
#else
|
#else
|
||||||
void reconstruct_stripes_ec(osd_rmw_stripe_t *stripes, int pg_size, int pg_minsize, uint32_t bitmap_size)
|
void reconstruct_stripes_ec(osd_rmw_stripe_t *stripes, int pg_size, int pg_minsize, uint32_t bitmap_size)
|
||||||
{
|
{
|
||||||
int *dm_ids = (int*)get_jerasure_decoding_matrix(stripes, pg_size, pg_minsize);
|
int *dm_ids = (int*)get_jerasure_decoding_matrix(stripes, pg_size, pg_minsize, NULL);
|
||||||
if (!dm_ids)
|
if (!dm_ids)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -980,7 +1005,7 @@ void calc_rmw_parity_ec(osd_rmw_stripe_t *stripes, int pg_size, int pg_minsize,
|
|||||||
{
|
{
|
||||||
int item_size =
|
int item_size =
|
||||||
#ifdef WITH_ISAL
|
#ifdef WITH_ISAL
|
||||||
32;
|
matrix->isal_item_size;
|
||||||
#else
|
#else
|
||||||
sizeof(int);
|
sizeof(int);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+153
-18
@@ -79,6 +79,33 @@ void osd_t::exec_secondary(osd_op_t *op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool osd_t::sec_check_pg_lock(osd_num_t primary_osd, const object_id &oid)
|
||||||
|
{
|
||||||
|
if (!enable_pg_locks)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
pool_id_t pool_id = INODE_POOL(oid.inode);
|
||||||
|
auto pool_cfg_it = st_cli.pool_config.find(pool_id);
|
||||||
|
if (pool_cfg_it == st_cli.pool_config.end())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto & pool_cfg = pool_cfg_it->second;
|
||||||
|
if (pg_locks_localize_only && (pool_cfg.scheme != POOL_SCHEME_REPLICATED || pool_cfg.local_reads == POOL_LOCAL_READ_PRIMARY))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto ppg = (pool_pg_num_t){ .pool_id = pool_id, .pg_num = map_to_pg(oid, pool_cfg_it->second.pg_stripe_size) };
|
||||||
|
auto pg_it = pgs.find(ppg);
|
||||||
|
if (pg_it != pgs.end() && pg_it->second.state != PG_OFFLINE)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto lock_it = pg_locks.find(ppg);
|
||||||
|
return lock_it != pg_locks.end() && lock_it->second.primary_osd == primary_osd;
|
||||||
|
}
|
||||||
|
|
||||||
void osd_t::exec_secondary_real(osd_op_t *cur_op)
|
void osd_t::exec_secondary_real(osd_op_t *cur_op)
|
||||||
{
|
{
|
||||||
if (cur_op->req.hdr.opcode == OSD_OP_SEC_LIST &&
|
if (cur_op->req.hdr.opcode == OSD_OP_SEC_LIST &&
|
||||||
@@ -89,23 +116,15 @@ void osd_t::exec_secondary_real(osd_op_t *cur_op)
|
|||||||
}
|
}
|
||||||
if (cur_op->req.hdr.opcode == OSD_OP_SEC_READ_BMP)
|
if (cur_op->req.hdr.opcode == OSD_OP_SEC_READ_BMP)
|
||||||
{
|
{
|
||||||
int n = cur_op->req.sec_read_bmp.len / sizeof(obj_ver_id);
|
exec_sec_read_bmp(cur_op);
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
obj_ver_id *ov = (obj_ver_id*)cur_op->buf;
|
|
||||||
void *reply_buf = malloc_or_die(n * (8 + clean_entry_bitmap_size));
|
|
||||||
void *cur_buf = reply_buf;
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
bs->read_bitmap(ov[i].oid, ov[i].version, (uint8_t*)cur_buf + sizeof(uint64_t), (uint64_t*)cur_buf);
|
|
||||||
cur_buf = (uint8_t*)cur_buf + (8 + clean_entry_bitmap_size);
|
|
||||||
}
|
|
||||||
free(cur_op->buf);
|
|
||||||
cur_op->buf = reply_buf;
|
|
||||||
}
|
|
||||||
finish_op(cur_op, n * (8 + clean_entry_bitmap_size));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (cur_op->req.hdr.opcode == OSD_OP_SEC_LOCK)
|
||||||
|
{
|
||||||
|
exec_sec_lock(cur_op);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto cl = msgr.clients.at(cur_op->peer_fd);
|
||||||
cur_op->bs_op = new blockstore_op_t();
|
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->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_SEC_READ ? BS_OP_READ
|
cur_op->bs_op->opcode = (cur_op->req.hdr.opcode == OSD_OP_SEC_READ ? BS_OP_READ
|
||||||
@@ -121,6 +140,13 @@ void osd_t::exec_secondary_real(osd_op_t *cur_op)
|
|||||||
cur_op->req.hdr.opcode == OSD_OP_SEC_WRITE ||
|
cur_op->req.hdr.opcode == OSD_OP_SEC_WRITE ||
|
||||||
cur_op->req.hdr.opcode == OSD_OP_SEC_WRITE_STABLE)
|
cur_op->req.hdr.opcode == OSD_OP_SEC_WRITE_STABLE)
|
||||||
{
|
{
|
||||||
|
if (!(cur_op->req.sec_rw.flags & OSD_OP_IGNORE_PG_LOCK) &&
|
||||||
|
!sec_check_pg_lock(cl->in_osd_num, cur_op->req.sec_rw.oid))
|
||||||
|
{
|
||||||
|
cur_op->bs_op->retval = -EPIPE;
|
||||||
|
secondary_op_callback(cur_op);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (cur_op->req.hdr.opcode == OSD_OP_SEC_READ)
|
if (cur_op->req.hdr.opcode == OSD_OP_SEC_READ)
|
||||||
{
|
{
|
||||||
// Allocate memory for the read operation
|
// Allocate memory for the read operation
|
||||||
@@ -143,6 +169,13 @@ void osd_t::exec_secondary_real(osd_op_t *cur_op)
|
|||||||
}
|
}
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SEC_DELETE)
|
else if (cur_op->req.hdr.opcode == OSD_OP_SEC_DELETE)
|
||||||
{
|
{
|
||||||
|
if (!(cur_op->req.sec_del.flags & OSD_OP_IGNORE_PG_LOCK) &&
|
||||||
|
!sec_check_pg_lock(cl->in_osd_num, cur_op->req.sec_del.oid))
|
||||||
|
{
|
||||||
|
cur_op->bs_op->retval = -EPIPE;
|
||||||
|
secondary_op_callback(cur_op);
|
||||||
|
return;
|
||||||
|
}
|
||||||
cur_op->bs_op->oid = cur_op->req.sec_del.oid;
|
cur_op->bs_op->oid = cur_op->req.sec_del.oid;
|
||||||
cur_op->bs_op->version = cur_op->req.sec_del.version;
|
cur_op->bs_op->version = cur_op->req.sec_del.version;
|
||||||
#ifdef OSD_STUB
|
#ifdef OSD_STUB
|
||||||
@@ -157,6 +190,18 @@ void osd_t::exec_secondary_real(osd_op_t *cur_op)
|
|||||||
#ifdef OSD_STUB
|
#ifdef OSD_STUB
|
||||||
cur_op->bs_op->retval = 0;
|
cur_op->bs_op->retval = 0;
|
||||||
#endif
|
#endif
|
||||||
|
if (enable_pg_locks && !(cur_op->req.sec_stab.flags & OSD_OP_IGNORE_PG_LOCK))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < cur_op->bs_op->len; i++)
|
||||||
|
{
|
||||||
|
if (!sec_check_pg_lock(cl->in_osd_num, ((obj_ver_id*)cur_op->buf)[i].oid))
|
||||||
|
{
|
||||||
|
cur_op->bs_op->retval = -EPIPE;
|
||||||
|
secondary_op_callback(cur_op);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (cur_op->req.hdr.opcode == OSD_OP_SEC_LIST)
|
else if (cur_op->req.hdr.opcode == OSD_OP_SEC_LIST)
|
||||||
{
|
{
|
||||||
@@ -192,15 +237,104 @@ void osd_t::exec_secondary_real(osd_op_t *cur_op)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void osd_t::exec_sec_read_bmp(osd_op_t *cur_op)
|
||||||
|
{
|
||||||
|
auto cl = msgr.clients.at(cur_op->peer_fd);
|
||||||
|
int n = cur_op->req.sec_read_bmp.len / sizeof(obj_ver_id);
|
||||||
|
if (n > 0)
|
||||||
|
{
|
||||||
|
obj_ver_id *ov = (obj_ver_id*)cur_op->buf;
|
||||||
|
void *reply_buf = malloc_or_die(n * (8 + clean_entry_bitmap_size));
|
||||||
|
void *cur_buf = reply_buf;
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
if (!sec_check_pg_lock(cl->in_osd_num, ov[i].oid) &&
|
||||||
|
!(cur_op->req.sec_read_bmp.flags & OSD_OP_IGNORE_PG_LOCK))
|
||||||
|
{
|
||||||
|
free(reply_buf);
|
||||||
|
cur_op->bs_op->retval = -EPIPE;
|
||||||
|
secondary_op_callback(cur_op);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bs->read_bitmap(ov[i].oid, ov[i].version, (uint8_t*)cur_buf + sizeof(uint64_t), (uint64_t*)cur_buf);
|
||||||
|
cur_buf = (uint8_t*)cur_buf + (8 + clean_entry_bitmap_size);
|
||||||
|
}
|
||||||
|
free(cur_op->buf);
|
||||||
|
cur_op->buf = reply_buf;
|
||||||
|
}
|
||||||
|
finish_op(cur_op, n * (8 + clean_entry_bitmap_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock/Unlock PG
|
||||||
|
void osd_t::exec_sec_lock(osd_op_t *cur_op)
|
||||||
|
{
|
||||||
|
cur_op->reply.sec_lock.cur_primary = 0;
|
||||||
|
auto cl = msgr.clients.at(cur_op->peer_fd);
|
||||||
|
if (!cl->in_osd_num ||
|
||||||
|
cur_op->req.sec_lock.flags != OSD_SEC_LOCK_PG &&
|
||||||
|
cur_op->req.sec_lock.flags != OSD_SEC_UNLOCK_PG ||
|
||||||
|
cur_op->req.sec_lock.pool_id > ((uint64_t)1<<POOL_ID_BITS) ||
|
||||||
|
!cur_op->req.sec_lock.pg_num ||
|
||||||
|
cur_op->req.sec_lock.pg_num > UINT32_MAX)
|
||||||
|
{
|
||||||
|
finish_op(cur_op, -EINVAL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto ppg = (pool_pg_num_t){ .pool_id = (pool_id_t)cur_op->req.sec_lock.pool_id, .pg_num = (pg_num_t)cur_op->req.sec_lock.pg_num };
|
||||||
|
auto pool_cfg_it = st_cli.pool_config.find(ppg.pool_id);
|
||||||
|
if (pool_cfg_it == st_cli.pool_config.end() ||
|
||||||
|
pool_cfg_it->second.real_pg_count < cur_op->req.sec_lock.pg_num)
|
||||||
|
{
|
||||||
|
finish_op(cur_op, -ENOENT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto lock_it = pg_locks.find(ppg);
|
||||||
|
if (cur_op->req.sec_lock.flags == OSD_SEC_LOCK_PG)
|
||||||
|
{
|
||||||
|
if (lock_it != pg_locks.end() && lock_it->second.primary_osd != cl->in_osd_num)
|
||||||
|
{
|
||||||
|
cur_op->reply.sec_lock.cur_primary = lock_it->second.primary_osd;
|
||||||
|
finish_op(cur_op, -EBUSY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto primary_pg_it = pgs.find(ppg);
|
||||||
|
if (primary_pg_it != pgs.end() && primary_pg_it->second.state != PG_OFFLINE)
|
||||||
|
{
|
||||||
|
cur_op->reply.sec_lock.cur_primary = this->osd_num;
|
||||||
|
finish_op(cur_op, -EBUSY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (log_level > 3)
|
||||||
|
{
|
||||||
|
printf("Lock PG %u/%u for OSD %ju\n", ppg.pool_id, ppg.pg_num, cl->in_osd_num);
|
||||||
|
}
|
||||||
|
pg_locks[ppg] = (osd_pg_lock_t){
|
||||||
|
.primary_osd = cl->in_osd_num,
|
||||||
|
.state = cur_op->req.sec_lock.pg_state,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (lock_it != pg_locks.end() && lock_it->second.primary_osd == cl->in_osd_num)
|
||||||
|
{
|
||||||
|
if (log_level > 3)
|
||||||
|
{
|
||||||
|
printf("Unlock PG %u/%u by OSD %ju\n", ppg.pool_id, ppg.pg_num, cl->in_osd_num);
|
||||||
|
}
|
||||||
|
pg_locks.erase(lock_it);
|
||||||
|
}
|
||||||
|
finish_op(cur_op, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void osd_t::exec_show_config(osd_op_t *cur_op)
|
void osd_t::exec_show_config(osd_op_t *cur_op)
|
||||||
{
|
{
|
||||||
std::string json_err;
|
std::string json_err;
|
||||||
json11::Json req_json = cur_op->req.show_conf.json_len > 0
|
json11::Json req_json = cur_op->req.show_conf.json_len > 0
|
||||||
? json11::Json::parse(std::string((char *)cur_op->buf), json_err)
|
? json11::Json::parse(std::string((char *)cur_op->buf), json_err)
|
||||||
: json11::Json();
|
: json11::Json();
|
||||||
if (req_json["check_sequencing"].bool_value())
|
auto peer_osd_num = req_json["osd_num"].uint64_value();
|
||||||
|
auto cl = msgr.clients.at(cur_op->peer_fd);
|
||||||
|
cl->in_osd_num = peer_osd_num;
|
||||||
|
if (req_json["features"]["check_sequencing"].bool_value())
|
||||||
{
|
{
|
||||||
auto cl = msgr.clients.at(cur_op->peer_fd);
|
|
||||||
cl->check_sequencing = true;
|
cl->check_sequencing = true;
|
||||||
cl->read_op_id = cur_op->req.hdr.id + 1;
|
cl->read_op_id = cur_op->req.hdr.id + 1;
|
||||||
}
|
}
|
||||||
@@ -216,6 +350,7 @@ void osd_t::exec_show_config(osd_op_t *cur_op)
|
|||||||
{ "immediate_commit", (immediate_commit == IMMEDIATE_ALL ? "all" :
|
{ "immediate_commit", (immediate_commit == IMMEDIATE_ALL ? "all" :
|
||||||
(immediate_commit == IMMEDIATE_SMALL ? "small" : "none")) },
|
(immediate_commit == IMMEDIATE_SMALL ? "small" : "none")) },
|
||||||
{ "lease_timeout", etcd_report_interval+(st_cli.max_etcd_attempts*(2*st_cli.etcd_quick_timeout)+999)/1000 },
|
{ "lease_timeout", etcd_report_interval+(st_cli.max_etcd_attempts*(2*st_cli.etcd_quick_timeout)+999)/1000 },
|
||||||
|
{ "features", json11::Json::object{ { "pg_locks", true } } },
|
||||||
};
|
};
|
||||||
#ifdef WITH_RDMA
|
#ifdef WITH_RDMA
|
||||||
if (msgr.is_rdma_enabled())
|
if (msgr.is_rdma_enabled())
|
||||||
@@ -228,7 +363,7 @@ void osd_t::exec_show_config(osd_op_t *cur_op)
|
|||||||
bool ok = msgr.connect_rdma(cur_op->peer_fd, req_json["connect_rdma"].string_value(), req_json["rdma_max_msg"].uint64_value());
|
bool ok = msgr.connect_rdma(cur_op->peer_fd, req_json["connect_rdma"].string_value(), req_json["rdma_max_msg"].uint64_value());
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
auto rc = msgr.clients.at(cur_op->peer_fd)->rdma_conn;
|
auto rc = cl->rdma_conn;
|
||||||
wire_config["rdma_address"] = rc->addr.to_string();
|
wire_config["rdma_address"] = rc->addr.to_string();
|
||||||
wire_config["rdma_max_msg"] = rc->max_msg;
|
wire_config["rdma_max_msg"] = rc->max_msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ void pretend_connected(cluster_client_t *cli, osd_num_t osd_num)
|
|||||||
cli->msgr.osd_peer_fds[osd_num] = peer_fd;
|
cli->msgr.osd_peer_fds[osd_num] = peer_fd;
|
||||||
cli->msgr.clients[peer_fd] = new osd_client_t();
|
cli->msgr.clients[peer_fd] = new osd_client_t();
|
||||||
cli->msgr.clients[peer_fd]->osd_num = osd_num;
|
cli->msgr.clients[peer_fd]->osd_num = osd_num;
|
||||||
|
cli->msgr.clients[peer_fd]->peer_fd = peer_fd;
|
||||||
cli->msgr.clients[peer_fd]->peer_state = PEER_CONNECTED;
|
cli->msgr.clients[peer_fd]->peer_state = PEER_CONNECTED;
|
||||||
cli->msgr.wanted_peers.erase(osd_num);
|
cli->msgr.wanted_peers.erase(osd_num);
|
||||||
cli->msgr.repeer_pgs(osd_num);
|
cli->msgr.repeer_pgs(osd_num);
|
||||||
|
|||||||
@@ -245,3 +245,13 @@ int create_and_bind_socket(std::string bind_address, int bind_port, int listen_b
|
|||||||
|
|
||||||
return listen_fd;
|
return listen_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string gethostname_str()
|
||||||
|
{
|
||||||
|
std::string hostname;
|
||||||
|
hostname.resize(1024);
|
||||||
|
while (gethostname((char*)hostname.data(), hostname.size()) < 0 && errno == ENAMETOOLONG)
|
||||||
|
hostname.resize(hostname.size()+1024);
|
||||||
|
hostname.resize(strnlen(hostname.data(), hostname.size()));
|
||||||
|
return hostname;
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,3 +21,4 @@ bool cidr6_match(const in6_addr &address, const in6_addr &network, uint8_t bits)
|
|||||||
bool cidr_sockaddr_match(const sockaddr_storage &addr, const addr_mask_t &mask);
|
bool cidr_sockaddr_match(const sockaddr_storage &addr, const addr_mask_t &mask);
|
||||||
std::vector<std::string> getifaddr_list(const std::vector<addr_mask_t> & masks = std::vector<addr_mask_t>(), bool include_v6 = false);
|
std::vector<std::string> getifaddr_list(const std::vector<addr_mask_t> & masks = std::vector<addr_mask_t>(), bool include_v6 = false);
|
||||||
int create_and_bind_socket(std::string bind_address, int bind_port, int listen_backlog, int *listening_port);
|
int create_and_bind_socket(std::string bind_address, int bind_port, int listen_backlog, int *listening_port);
|
||||||
|
std::string gethostname_str();
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ void ring_loop_t::loop()
|
|||||||
if (cqe->flags & IORING_CQE_F_MORE)
|
if (cqe->flags & IORING_CQE_F_MORE)
|
||||||
{
|
{
|
||||||
// There will be a second notification
|
// There will be a second notification
|
||||||
|
if (mt)
|
||||||
|
mu.unlock();
|
||||||
d->res = cqe->res;
|
d->res = cqe->res;
|
||||||
d->more = true;
|
d->more = true;
|
||||||
if (d->callback)
|
if (d->callback)
|
||||||
|
|||||||
+3
-3
@@ -68,17 +68,17 @@ if [ "$SCHEME" = "ec" ]; then
|
|||||||
PG_SIZE=${PG_SIZE:-5}
|
PG_SIZE=${PG_SIZE:-5}
|
||||||
PG_MINSIZE=${PG_MINSIZE:-4}
|
PG_MINSIZE=${PG_MINSIZE:-4}
|
||||||
PG_DATA_SIZE=${PG_DATA_SIZE:-3}
|
PG_DATA_SIZE=${PG_DATA_SIZE:-3}
|
||||||
POOLCFG='"scheme":"ec","parity_chunks":'$((PG_SIZE-PG_DATA_SIZE))
|
POOLCFG="$POOLCFG"'"scheme":"ec","parity_chunks":'$((PG_SIZE-PG_DATA_SIZE))
|
||||||
elif [ "$SCHEME" = "xor" ]; then
|
elif [ "$SCHEME" = "xor" ]; then
|
||||||
PG_SIZE=${PG_SIZE:-3}
|
PG_SIZE=${PG_SIZE:-3}
|
||||||
PG_MINSIZE=${PG_MINSIZE:-3}
|
PG_MINSIZE=${PG_MINSIZE:-3}
|
||||||
PG_DATA_SIZE=$((PG_SIZE-1))
|
PG_DATA_SIZE=$((PG_SIZE-1))
|
||||||
POOLCFG='"scheme":"xor","parity_chunks":1'
|
POOLCFG="$POOLCFG"'"scheme":"xor","parity_chunks":1'
|
||||||
else
|
else
|
||||||
PG_SIZE=${PG_SIZE:-2}
|
PG_SIZE=${PG_SIZE:-2}
|
||||||
PG_MINSIZE=${PG_MINSIZE:-2}
|
PG_MINSIZE=${PG_MINSIZE:-2}
|
||||||
PG_DATA_SIZE=1
|
PG_DATA_SIZE=1
|
||||||
POOLCFG='"scheme":"replicated"'
|
POOLCFG="$POOLCFG"'"scheme":"replicated"'
|
||||||
fi
|
fi
|
||||||
POOLCFG='"name":"testpool","failure_domain":"osd",'$POOLCFG
|
POOLCFG='"name":"testpool","failure_domain":"osd",'$POOLCFG
|
||||||
$ETCDCTL put /vitastor/config/pools '{"1":{'$POOLCFG',"pg_size":'$PG_SIZE',"pg_minsize":'$PG_MINSIZE',"pg_count":'$PG_COUNT'}}'
|
$ETCDCTL put /vitastor/config/pools '{"1":{'$POOLCFG',"pg_size":'$PG_SIZE',"pg_minsize":'$PG_MINSIZE',"pg_count":'$PG_COUNT'}}'
|
||||||
|
|||||||
@@ -59,10 +59,12 @@ SCHEME=ec IMMEDIATE_COMMIT=1 ./test_rebalance_verify.sh
|
|||||||
|
|
||||||
./test_write.sh
|
./test_write.sh
|
||||||
SCHEME=xor ./test_write.sh
|
SCHEME=xor ./test_write.sh
|
||||||
|
TEST_NAME=iothreads GLOBAL_CONFIG=',"client_iothread_count":4' ./test_write.sh
|
||||||
|
|
||||||
./test_write_no_same.sh
|
./test_write_no_same.sh
|
||||||
|
|
||||||
PG_SIZE=2 ./test_heal.sh
|
PG_SIZE=2 ./test_heal.sh
|
||||||
|
TEST_NAME=local_read POOLCFG='"local_reads":"random",' ./test_heal.sh
|
||||||
SCHEME=ec ./test_heal.sh
|
SCHEME=ec ./test_heal.sh
|
||||||
ANTIETCD=1 ./test_heal.sh
|
ANTIETCD=1 ./test_heal.sh
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user