Compare commits
6 Commits
65514c8fa2
...
19eadbce7f
Author | SHA1 | Date |
---|---|---|
|
19eadbce7f | |
|
58af897e73 | |
|
dbf9ecd171 | |
|
8508e78288 | |
|
f32dea02bf | |
|
a103065d12 |
|
@ -74,13 +74,13 @@ Grafana dashboard suitable for this exporter is here: [Vitastor-Grafana-6+.json]
|
|||
- Type: integer
|
||||
- Default: 8060
|
||||
|
||||
HTTP port for monitors to listen on (including metrics exporter)
|
||||
HTTP port for monitors to listen to (including metrics exporter)
|
||||
|
||||
## mon_http_ip
|
||||
|
||||
- Type: string
|
||||
|
||||
IP address for monitors to listen on (all addresses by default)
|
||||
IP address for monitors to listen to (all addresses by default)
|
||||
|
||||
## mon_https_cert
|
||||
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
These parameters apply to clients and OSDs and affect network connection logic
|
||||
between clients, OSDs and etcd.
|
||||
|
||||
- [tcp_header_buffer_size](#tcp_header_buffer_size)
|
||||
- [use_sync_send_recv](#use_sync_send_recv)
|
||||
- [osd_network](#osd_network)
|
||||
- [osd_cluster_network](#osd_cluster_network)
|
||||
- [use_rdma](#use_rdma)
|
||||
- [use_rdmacm](#use_rdmacm)
|
||||
- [disable_tcp](#disable_tcp)
|
||||
- [rdma_device](#rdma_device)
|
||||
- [rdma_port_num](#rdma_port_num)
|
||||
- [rdma_gid_index](#rdma_gid_index)
|
||||
|
@ -31,38 +33,61 @@ between clients, OSDs and etcd.
|
|||
- [etcd_keepalive_timeout](#etcd_keepalive_timeout)
|
||||
- [etcd_ws_keepalive_interval](#etcd_ws_keepalive_interval)
|
||||
- [etcd_min_reload_interval](#etcd_min_reload_interval)
|
||||
- [tcp_header_buffer_size](#tcp_header_buffer_size)
|
||||
- [use_sync_send_recv](#use_sync_send_recv)
|
||||
|
||||
## tcp_header_buffer_size
|
||||
## osd_network
|
||||
|
||||
- Type: integer
|
||||
- Default: 65536
|
||||
- Type: string or array of strings
|
||||
|
||||
Size of the buffer used to read data using an additional copy. Vitastor
|
||||
packet headers are 128 bytes, payload is always at least 4 KB, so it is
|
||||
usually beneficial to try to read multiple packets at once even though
|
||||
it requires to copy the data an additional time. The rest of each packet
|
||||
is received without an additional copy. You can try to play with this
|
||||
parameter and see how it affects random iops and linear bandwidth if you
|
||||
want.
|
||||
Network mask of public OSD network(s) (IPv4 or IPv6). Each OSD listens to all
|
||||
addresses of UP + RUNNING interfaces matching one of these networks, on the
|
||||
same port. Port is auto-selected except if [bind_port](osd.en.md#bind_port) is
|
||||
explicitly specified. Bind address(es) may also be overridden manually by
|
||||
specifying [bind_address](osd.en.md#bind_address). If OSD networks are not specified
|
||||
at all, OSD just listens to a wildcard address (0.0.0.0).
|
||||
|
||||
## use_sync_send_recv
|
||||
## osd_cluster_network
|
||||
|
||||
- Type: boolean
|
||||
- Default: false
|
||||
- Type: string or array of strings
|
||||
|
||||
If true, synchronous send/recv syscalls are used instead of io_uring for
|
||||
socket communication. Useless for OSDs because they require io_uring anyway,
|
||||
but may be required for clients with old kernel versions.
|
||||
Network mask of separate network(s) (IPv4 or IPv6) to use for OSD
|
||||
cluster connections. I.e. OSDs will always attempt to use these networks
|
||||
to connect to other OSDs, while clients will attempt to use networks from
|
||||
[osd_network](#osd_network).
|
||||
|
||||
## use_rdma
|
||||
|
||||
- Type: boolean
|
||||
- Default: true
|
||||
|
||||
Try to use RDMA for communication if it's available. Disable if you don't
|
||||
want Vitastor to use RDMA. TCP-only clients can also talk to an RDMA-enabled
|
||||
cluster, so disabling RDMA may be needed if clients have RDMA devices,
|
||||
but they are not connected to the cluster.
|
||||
Try to use RDMA through libibverbs for communication if it's available.
|
||||
Disable if you don't want Vitastor to use RDMA. TCP-only clients can also
|
||||
talk to an RDMA-enabled cluster, so disabling RDMA may be needed if clients
|
||||
have RDMA devices, but they are not connected to the cluster.
|
||||
|
||||
`use_rdma` works with RoCEv1/RoCEv2 networks, but not with iWARP and,
|
||||
maybe, with some Infiniband configurations which require RDMA-CM.
|
||||
Consider `use_rdmacm` for such networks.
|
||||
|
||||
## use_rdmacm
|
||||
|
||||
- Type: boolean
|
||||
- Default: true
|
||||
|
||||
Use an alternative implementation of RDMA through RDMA-CM (Connection
|
||||
Manager). Works with all RDMA networks: Infiniband, iWARP and
|
||||
RoCEv1/RoCEv2, and even allows to disable TCP and run only with RDMA.
|
||||
When enabled, OSDs listen to the same address(es) and port(s) using
|
||||
TCP and RDMA-CM. `use_rdma` is automatically disabled when `use_rdmacm`
|
||||
is enabled.
|
||||
|
||||
## disable_tcp
|
||||
|
||||
- Type: boolean
|
||||
- Default: true
|
||||
|
||||
Fully disable TCP and only use RDMA-CM for OSD communication.
|
||||
|
||||
## rdma_device
|
||||
|
||||
|
@ -93,12 +118,13 @@ PFC (Priority Flow Control) and ECN (Explicit Congestion Notification).
|
|||
## rdma_port_num
|
||||
|
||||
- Type: integer
|
||||
- Default: 1
|
||||
|
||||
RDMA device port number to use. Only for devices that have more than 1 port.
|
||||
See `phys_port_cnt` in `ibv_devinfo -v` output to determine how many ports
|
||||
your device has.
|
||||
|
||||
Not relevant for RDMA-CM (use_rdmacm).
|
||||
|
||||
## rdma_gid_index
|
||||
|
||||
- Type: integer
|
||||
|
@ -114,13 +140,14 @@ GID auto-selection is unsupported with libibverbs < v32.
|
|||
|
||||
A correct rdma_gid_index for RoCEv2 is usually 1 (IPv6) or 3 (IPv4).
|
||||
|
||||
Not relevant for RDMA-CM (use_rdmacm).
|
||||
|
||||
## rdma_mtu
|
||||
|
||||
- Type: integer
|
||||
- Default: 4096
|
||||
|
||||
RDMA Path MTU to use. Must be 1024, 2048 or 4096. There is usually no
|
||||
sense to change it from the default 4096.
|
||||
RDMA Path MTU to use. Must be 1024, 2048 or 4096. Default is to use the
|
||||
RDMA device's MTU.
|
||||
|
||||
## rdma_max_sge
|
||||
|
||||
|
@ -272,3 +299,25 @@ detect disconnections quickly.
|
|||
Minimum interval for full etcd state reload. Introduced to prevent
|
||||
excessive load on etcd during outages when etcd can't keep up with event
|
||||
streams and cancels them.
|
||||
|
||||
## tcp_header_buffer_size
|
||||
|
||||
- Type: integer
|
||||
- Default: 65536
|
||||
|
||||
Size of the buffer used to read data using an additional copy. Vitastor
|
||||
packet headers are 128 bytes, payload is always at least 4 KB, so it is
|
||||
usually beneficial to try to read multiple packets at once even though
|
||||
it requires to copy the data an additional time. The rest of each packet
|
||||
is received without an additional copy. You can try to play with this
|
||||
parameter and see how it affects random iops and linear bandwidth if you
|
||||
want.
|
||||
|
||||
## use_sync_send_recv
|
||||
|
||||
- Type: boolean
|
||||
- Default: false
|
||||
|
||||
If true, synchronous send/recv syscalls are used instead of io_uring for
|
||||
socket communication. Useless for OSDs because they require io_uring anyway,
|
||||
but may be required for clients with old kernel versions.
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
Данные параметры используются клиентами и OSD и влияют на логику сетевого
|
||||
взаимодействия между клиентами, OSD, а также etcd.
|
||||
|
||||
- [tcp_header_buffer_size](#tcp_header_buffer_size)
|
||||
- [use_sync_send_recv](#use_sync_send_recv)
|
||||
- [osd_network](#osd_network)
|
||||
- [osd_cluster_network](#osd_cluster_network)
|
||||
- [use_rdma](#use_rdma)
|
||||
- [use_rdmacm](#use_rdmacm)
|
||||
- [disable_tcp](#disable_tcp)
|
||||
- [rdma_device](#rdma_device)
|
||||
- [rdma_port_num](#rdma_port_num)
|
||||
- [rdma_gid_index](#rdma_gid_index)
|
||||
|
@ -31,41 +33,61 @@
|
|||
- [etcd_keepalive_timeout](#etcd_keepalive_timeout)
|
||||
- [etcd_ws_keepalive_interval](#etcd_ws_keepalive_interval)
|
||||
- [etcd_min_reload_interval](#etcd_min_reload_interval)
|
||||
- [tcp_header_buffer_size](#tcp_header_buffer_size)
|
||||
- [use_sync_send_recv](#use_sync_send_recv)
|
||||
|
||||
## tcp_header_buffer_size
|
||||
## osd_network
|
||||
|
||||
- Тип: целое число
|
||||
- Значение по умолчанию: 65536
|
||||
- Тип: строка или массив строк
|
||||
|
||||
Размер буфера для чтения данных с дополнительным копированием. Пакеты
|
||||
Vitastor содержат 128-байтные заголовки, за которыми следуют данные размером
|
||||
от 4 КБ и для мелких операций ввода-вывода обычно выгодно за 1 вызов читать
|
||||
сразу несколько пакетов, даже не смотря на то, что это требует лишний раз
|
||||
скопировать данные. Часть каждого пакета за пределами значения данного
|
||||
параметра читается без дополнительного копирования. Вы можете попробовать
|
||||
поменять этот параметр и посмотреть, как он влияет на производительность
|
||||
случайного и линейного доступа.
|
||||
Маски подсетей (IPv4 или IPv6) публичной сети или сетей OSD. Каждый OSD слушает
|
||||
один и тот же порт на всех адресах поднятых (UP + RUNNING) сетевых интерфейсов,
|
||||
соответствующих одной из указанных сетей. Порт выбирается автоматически, если
|
||||
только [bind_port](osd.ru.md#bind_port) не задан явно. Адреса для подключений можно
|
||||
также переопределить явно, задав [bind_address](osd.ru.md#bind_address). Если сети OSD
|
||||
не заданы вообще, OSD слушает все адреса (0.0.0.0).
|
||||
|
||||
## use_sync_send_recv
|
||||
## osd_cluster_network
|
||||
|
||||
- Тип: булево (да/нет)
|
||||
- Значение по умолчанию: false
|
||||
- Тип: строка или массив строк
|
||||
|
||||
Если установлено в истину, то вместо io_uring для передачи данных по сети
|
||||
будут использоваться обычные синхронные системные вызовы send/recv. Для OSD
|
||||
это бессмысленно, так как OSD в любом случае нуждается в io_uring, но, в
|
||||
принципе, это может применяться для клиентов со старыми версиями ядра.
|
||||
Маски подсетей (IPv4 или IPv6) отдельной кластерной сети или сетей OSD.
|
||||
То есть, OSD будут всегда стараться использовать эти сети для соединений
|
||||
с другими OSD, а клиенты будут стараться использовать сети из [osd_network](#osd_network).
|
||||
|
||||
## use_rdma
|
||||
|
||||
- Тип: булево (да/нет)
|
||||
- Значение по умолчанию: true
|
||||
|
||||
Пытаться использовать RDMA для связи при наличии доступных устройств.
|
||||
Отключите, если вы не хотите, чтобы Vitastor использовал RDMA.
|
||||
TCP-клиенты также могут работать с RDMA-кластером, так что отключать
|
||||
RDMA может быть нужно только если у клиентов есть RDMA-устройства,
|
||||
но они не имеют соединения с кластером Vitastor.
|
||||
Попробовать использовать RDMA через libibverbs для связи при наличии
|
||||
доступных устройств. Отключите, если вы не хотите, чтобы Vitastor
|
||||
использовал RDMA. TCP-клиенты также могут работать с RDMA-кластером,
|
||||
так что отключать RDMA может быть нужно, только если у клиентов есть
|
||||
RDMA-устройства, но они не имеют соединения с кластером Vitastor.
|
||||
|
||||
`use_rdma` работает с RoCEv1/RoCEv2 сетями, но не работает с iWARP и
|
||||
может не работать с частью конфигураций Infiniband, требующих RDMA-CM.
|
||||
Рассмотрите включение `use_rdmacm` для таких сетей.
|
||||
|
||||
## use_rdmacm
|
||||
|
||||
- Тип: булево (да/нет)
|
||||
- Значение по умолчанию: true
|
||||
|
||||
Использовать альтернативную реализацию RDMA на основе RDMA-CM (Connection
|
||||
Manager). Работает со всеми типами RDMA-сетей: Infiniband, iWARP и
|
||||
RoCEv1/RoCEv2, и даже позволяет полностью отключить TCP и работать
|
||||
только на RDMA. Когда опция включена, OSD слушают один и тот же порт
|
||||
на одних и тех же адресах через TCP и RDMA-CM. Также при включении
|
||||
автоматически отключается опция `use_rdma`.
|
||||
|
||||
## disable_tcp
|
||||
|
||||
- Тип: булево (да/нет)
|
||||
- Значение по умолчанию: true
|
||||
|
||||
Полностью отключить TCP и использовать только RDMA-CM для соединений с OSD.
|
||||
|
||||
## rdma_device
|
||||
|
||||
|
@ -97,13 +119,14 @@ Control) и ECN (Explicit Congestion Notification).
|
|||
## rdma_port_num
|
||||
|
||||
- Тип: целое число
|
||||
- Значение по умолчанию: 1
|
||||
|
||||
Номер порта RDMA-устройства, который следует использовать. Имеет смысл
|
||||
только для устройств, у которых более 1 порта. Чтобы узнать, сколько портов
|
||||
у вашего адаптера, посмотрите `phys_port_cnt` в выводе команды
|
||||
`ibv_devinfo -v`.
|
||||
|
||||
Опция неприменима к RDMA-CM (use_rdmacm).
|
||||
|
||||
## rdma_gid_index
|
||||
|
||||
- Тип: целое число
|
||||
|
@ -120,13 +143,14 @@ libibverbs < v32.
|
|||
|
||||
Правильный rdma_gid_index для RoCEv2, как правило, 1 (IPv6) или 3 (IPv4).
|
||||
|
||||
Опция неприменима к RDMA-CM (use_rdmacm).
|
||||
|
||||
## rdma_mtu
|
||||
|
||||
- Тип: целое число
|
||||
- Значение по умолчанию: 4096
|
||||
|
||||
Максимальная единица передачи (Path MTU) для RDMA. Должно быть равно 1024,
|
||||
2048 или 4096. Обычно нет смысла менять значение по умолчанию, равное 4096.
|
||||
2048 или 4096. По умолчанию используется значение MTU RDMA-устройства.
|
||||
|
||||
## rdma_max_sge
|
||||
|
||||
|
@ -282,3 +306,27 @@ etcd_report_interval, чтобы keepalive гарантированно рабо
|
|||
Минимальный интервал полной перезагрузки состояния из etcd. Добавлено для
|
||||
предотвращения избыточной нагрузки на etcd во время отказов, когда etcd не
|
||||
успевает рассылать потоки событий и отменяет их.
|
||||
|
||||
## tcp_header_buffer_size
|
||||
|
||||
- Тип: целое число
|
||||
- Значение по умолчанию: 65536
|
||||
|
||||
Размер буфера для чтения данных с дополнительным копированием. Пакеты
|
||||
Vitastor содержат 128-байтные заголовки, за которыми следуют данные размером
|
||||
от 4 КБ и для мелких операций ввода-вывода обычно выгодно за 1 вызов читать
|
||||
сразу несколько пакетов, даже не смотря на то, что это требует лишний раз
|
||||
скопировать данные. Часть каждого пакета за пределами значения данного
|
||||
параметра читается без дополнительного копирования. Вы можете попробовать
|
||||
поменять этот параметр и посмотреть, как он влияет на производительность
|
||||
случайного и линейного доступа.
|
||||
|
||||
## use_sync_send_recv
|
||||
|
||||
- Тип: булево (да/нет)
|
||||
- Значение по умолчанию: false
|
||||
|
||||
Если установлено в истину, то вместо io_uring для передачи данных по сети
|
||||
будут использоваться обычные синхронные системные вызовы send/recv. Для OSD
|
||||
это бессмысленно, так как OSD в любом случае нуждается в io_uring, но, в
|
||||
принципе, это может применяться для клиентов со старыми версиями ядра.
|
||||
|
|
|
@ -10,13 +10,12 @@ These parameters only apply to OSDs, are not fixed at the moment of OSD drive
|
|||
initialization and can be changed - in /etc/vitastor/vitastor.conf or [vitastor-disk update-sb](../usage/disk.en.md#update-sb)
|
||||
with an OSD restart or, for some of them, even without restarting by updating configuration in etcd.
|
||||
|
||||
- [bind_address](#bind_address)
|
||||
- [bind_port](#bind_port)
|
||||
- [osd_iothread_count](#osd_iothread_count)
|
||||
- [etcd_report_interval](#etcd_report_interval)
|
||||
- [etcd_stats_interval](#etcd_stats_interval)
|
||||
- [run_primary](#run_primary)
|
||||
- [osd_network](#osd_network)
|
||||
- [bind_address](#bind_address)
|
||||
- [bind_port](#bind_port)
|
||||
- [autosync_interval](#autosync_interval)
|
||||
- [autosync_writes](#autosync_writes)
|
||||
- [recovery_queue_depth](#recovery_queue_depth)
|
||||
|
@ -65,6 +64,23 @@ with an OSD restart or, for some of them, even without restarting by updating co
|
|||
- [min_discard_size](#min_discard_size)
|
||||
- [allow_net_split](#allow_net_split)
|
||||
|
||||
## bind_address
|
||||
|
||||
- Type: string or array of strings
|
||||
|
||||
Instead of the network masks ([osd_network](network.en.md#osd_network) and
|
||||
[osd_cluster_network](network.en.md#osd_cluster_network)), you can also set
|
||||
OSD listen addresses explicitly using this parameter. May be useful if you
|
||||
want to start OSDs on interfaces that are not UP + RUNNING.
|
||||
|
||||
## bind_port
|
||||
|
||||
- Type: integer
|
||||
|
||||
By default, OSDs pick random ports to use for incoming connections
|
||||
automatically. With this option you can set a specific port for a specific
|
||||
OSD by hand.
|
||||
|
||||
## osd_iothread_count
|
||||
|
||||
- Type: integer
|
||||
|
@ -107,34 +123,6 @@ debugging purposes. It's possible to implement additional feature for the
|
|||
monitor which may allow to separate primary and secondary OSDs, but it's
|
||||
unclear why anyone could need it, so it's not implemented.
|
||||
|
||||
## osd_network
|
||||
|
||||
- Type: string or array of strings
|
||||
|
||||
Network mask of the network (IPv4 or IPv6) to use for OSDs. Note that
|
||||
although it's possible to specify multiple networks here, this does not
|
||||
mean that OSDs will create multiple listening sockets - they'll only
|
||||
pick the first matching address of an UP + RUNNING interface. Separate
|
||||
networks for cluster and client connections are also not implemented, but
|
||||
they are mostly useless anyway, so it's not a big deal.
|
||||
|
||||
## bind_address
|
||||
|
||||
- Type: string
|
||||
- Default: 0.0.0.0
|
||||
|
||||
Instead of the network mask, you can also set OSD listen address explicitly
|
||||
using this parameter. May be useful if you want to start OSDs on interfaces
|
||||
that are not UP + RUNNING.
|
||||
|
||||
## bind_port
|
||||
|
||||
- Type: integer
|
||||
|
||||
By default, OSDs pick random ports to use for incoming connections
|
||||
automatically. With this option you can set a specific port for a specific
|
||||
OSD by hand.
|
||||
|
||||
## autosync_interval
|
||||
|
||||
- Type: seconds
|
||||
|
|
|
@ -11,13 +11,12 @@
|
|||
момент с перезапуском OSD в /etc/vitastor/vitastor.conf или [vitastor-disk update-sb](../usage/disk.ru.md#update-sb),
|
||||
а некоторые и без перезапуска, с помощью изменения конфигурации в etcd.
|
||||
|
||||
- [bind_address](#bind_address)
|
||||
- [bind_port](#bind_port)
|
||||
- [osd_iothread_count](#osd_iothread_count)
|
||||
- [etcd_report_interval](#etcd_report_interval)
|
||||
- [etcd_stats_interval](#etcd_stats_interval)
|
||||
- [run_primary](#run_primary)
|
||||
- [osd_network](#osd_network)
|
||||
- [bind_address](#bind_address)
|
||||
- [bind_port](#bind_port)
|
||||
- [autosync_interval](#autosync_interval)
|
||||
- [autosync_writes](#autosync_writes)
|
||||
- [recovery_queue_depth](#recovery_queue_depth)
|
||||
|
@ -66,6 +65,23 @@
|
|||
- [min_discard_size](#min_discard_size)
|
||||
- [allow_net_split](#allow_net_split)
|
||||
|
||||
## bind_address
|
||||
|
||||
- Тип: строка или массив строк
|
||||
|
||||
Вместо использования масок подсети ([osd_network](network.ru.md#osd_network) и
|
||||
[osd_cluster_network](network.ru.md#osd_cluster_network)), вы также можете явно
|
||||
задать адрес(а), на которых будут ожидать соединений OSD, с помощью данного
|
||||
параметра. Это может быть полезно, например, чтобы запускать OSD на неподнятых
|
||||
интерфейсах (не UP + RUNNING).
|
||||
|
||||
## bind_port
|
||||
|
||||
- Тип: целое число
|
||||
|
||||
По умолчанию OSD сами выбирают случайные порты для входящих подключений.
|
||||
С помощью данной опции вы можете задать порт для отдельного OSD вручную.
|
||||
|
||||
## osd_iothread_count
|
||||
|
||||
- Тип: целое число
|
||||
|
@ -110,34 +126,6 @@ max_etcd_attempts * etcd_quick_timeout.
|
|||
первичные OSD от вторичных, но пока не понятно, зачем это может кому-то
|
||||
понадобиться, поэтому это не реализовано.
|
||||
|
||||
## osd_network
|
||||
|
||||
- Тип: строка или массив строк
|
||||
|
||||
Маска подсети (IPv4 или IPv6) для использования для соединений с OSD.
|
||||
Имейте в виду, что хотя сейчас и можно передать в этот параметр несколько
|
||||
подсетей, это не означает, что OSD будут создавать несколько слушающих
|
||||
сокетов - они лишь будут выбирать адрес первого поднятого (состояние UP +
|
||||
RUNNING), подходящий под заданную маску. Также не реализовано разделение
|
||||
кластерной и публичной сетей OSD. Правда, от него обычно всё равно довольно
|
||||
мало толку, так что особенной проблемы в этом нет.
|
||||
|
||||
## bind_address
|
||||
|
||||
- Тип: строка
|
||||
- Значение по умолчанию: 0.0.0.0
|
||||
|
||||
Этим параметром можно явным образом задать адрес, на котором будет ожидать
|
||||
соединений OSD (вместо использования маски подсети). Может быть полезно,
|
||||
например, чтобы запускать OSD на неподнятых интерфейсах (не UP + RUNNING).
|
||||
|
||||
## bind_port
|
||||
|
||||
- Тип: целое число
|
||||
|
||||
По умолчанию OSD сами выбирают случайные порты для входящих подключений.
|
||||
С помощью данной опции вы можете задать порт для отдельного OSD вручную.
|
||||
|
||||
## autosync_interval
|
||||
|
||||
- Тип: секунды
|
||||
|
|
|
@ -75,11 +75,11 @@
|
|||
- name: mon_http_port
|
||||
type: int
|
||||
default: 8060
|
||||
info: HTTP port for monitors to listen on (including metrics exporter)
|
||||
info: HTTP port for monitors to listen to (including metrics exporter)
|
||||
info_ru: Порт, на котором мониторы принимают HTTP-соединения (в том числе для отдачи метрик)
|
||||
- name: mon_http_ip
|
||||
type: string
|
||||
info: IP address for monitors to listen on (all addresses by default)
|
||||
info: IP address for monitors to listen to (all addresses by default)
|
||||
info_ru: IP-адрес, на котором мониторы принимают HTTP-соединения (по умолчанию все адреса)
|
||||
- name: mon_https_cert
|
||||
type: string
|
||||
|
|
|
@ -1,49 +1,78 @@
|
|||
- name: tcp_header_buffer_size
|
||||
type: int
|
||||
default: 65536
|
||||
- name: osd_network
|
||||
type: string or array of strings
|
||||
type_ru: строка или массив строк
|
||||
info: |
|
||||
Size of the buffer used to read data using an additional copy. Vitastor
|
||||
packet headers are 128 bytes, payload is always at least 4 KB, so it is
|
||||
usually beneficial to try to read multiple packets at once even though
|
||||
it requires to copy the data an additional time. The rest of each packet
|
||||
is received without an additional copy. You can try to play with this
|
||||
parameter and see how it affects random iops and linear bandwidth if you
|
||||
want.
|
||||
Network mask of public OSD network(s) (IPv4 or IPv6). Each OSD listens to all
|
||||
addresses of UP + RUNNING interfaces matching one of these networks, on the
|
||||
same port. Port is auto-selected except if [bind_port](osd.en.md#bind_port) is
|
||||
explicitly specified. Bind address(es) may also be overridden manually by
|
||||
specifying [bind_address](osd.en.md#bind_address). If OSD networks are not specified
|
||||
at all, OSD just listens to a wildcard address (0.0.0.0).
|
||||
info_ru: |
|
||||
Размер буфера для чтения данных с дополнительным копированием. Пакеты
|
||||
Vitastor содержат 128-байтные заголовки, за которыми следуют данные размером
|
||||
от 4 КБ и для мелких операций ввода-вывода обычно выгодно за 1 вызов читать
|
||||
сразу несколько пакетов, даже не смотря на то, что это требует лишний раз
|
||||
скопировать данные. Часть каждого пакета за пределами значения данного
|
||||
параметра читается без дополнительного копирования. Вы можете попробовать
|
||||
поменять этот параметр и посмотреть, как он влияет на производительность
|
||||
случайного и линейного доступа.
|
||||
- name: use_sync_send_recv
|
||||
type: bool
|
||||
default: false
|
||||
Маски подсетей (IPv4 или IPv6) публичной сети или сетей OSD. Каждый OSD слушает
|
||||
один и тот же порт на всех адресах поднятых (UP + RUNNING) сетевых интерфейсов,
|
||||
соответствующих одной из указанных сетей. Порт выбирается автоматически, если
|
||||
только [bind_port](osd.ru.md#bind_port) не задан явно. Адреса для подключений можно
|
||||
также переопределить явно, задав [bind_address](osd.ru.md#bind_address). Если сети OSD
|
||||
не заданы вообще, OSD слушает все адреса (0.0.0.0).
|
||||
- name: osd_cluster_network
|
||||
type: string or array of strings
|
||||
type_ru: строка или массив строк
|
||||
info: |
|
||||
If true, synchronous send/recv syscalls are used instead of io_uring for
|
||||
socket communication. Useless for OSDs because they require io_uring anyway,
|
||||
but may be required for clients with old kernel versions.
|
||||
Network mask of separate network(s) (IPv4 or IPv6) to use for OSD
|
||||
cluster connections. I.e. OSDs will always attempt to use these networks
|
||||
to connect to other OSDs, while clients will attempt to use networks from
|
||||
[osd_network](#osd_network).
|
||||
info_ru: |
|
||||
Если установлено в истину, то вместо io_uring для передачи данных по сети
|
||||
будут использоваться обычные синхронные системные вызовы send/recv. Для OSD
|
||||
это бессмысленно, так как OSD в любом случае нуждается в io_uring, но, в
|
||||
принципе, это может применяться для клиентов со старыми версиями ядра.
|
||||
Маски подсетей (IPv4 или IPv6) отдельной кластерной сети или сетей OSD.
|
||||
То есть, OSD будут всегда стараться использовать эти сети для соединений
|
||||
с другими OSD, а клиенты будут стараться использовать сети из [osd_network](#osd_network).
|
||||
- name: use_rdma
|
||||
type: bool
|
||||
default: true
|
||||
info: |
|
||||
Try to use RDMA for communication if it's available. Disable if you don't
|
||||
want Vitastor to use RDMA. TCP-only clients can also talk to an RDMA-enabled
|
||||
cluster, so disabling RDMA may be needed if clients have RDMA devices,
|
||||
but they are not connected to the cluster.
|
||||
Try to use RDMA through libibverbs for communication if it's available.
|
||||
Disable if you don't want Vitastor to use RDMA. TCP-only clients can also
|
||||
talk to an RDMA-enabled cluster, so disabling RDMA may be needed if clients
|
||||
have RDMA devices, but they are not connected to the cluster.
|
||||
|
||||
`use_rdma` works with RoCEv1/RoCEv2 networks, but not with iWARP and,
|
||||
maybe, with some Infiniband configurations which require RDMA-CM.
|
||||
Consider `use_rdmacm` for such networks.
|
||||
info_ru: |
|
||||
Пытаться использовать RDMA для связи при наличии доступных устройств.
|
||||
Отключите, если вы не хотите, чтобы Vitastor использовал RDMA.
|
||||
TCP-клиенты также могут работать с RDMA-кластером, так что отключать
|
||||
RDMA может быть нужно только если у клиентов есть RDMA-устройства,
|
||||
но они не имеют соединения с кластером Vitastor.
|
||||
Попробовать использовать RDMA через libibverbs для связи при наличии
|
||||
доступных устройств. Отключите, если вы не хотите, чтобы Vitastor
|
||||
использовал RDMA. TCP-клиенты также могут работать с RDMA-кластером,
|
||||
так что отключать RDMA может быть нужно, только если у клиентов есть
|
||||
RDMA-устройства, но они не имеют соединения с кластером Vitastor.
|
||||
|
||||
`use_rdma` работает с RoCEv1/RoCEv2 сетями, но не работает с iWARP и
|
||||
может не работать с частью конфигураций Infiniband, требующих RDMA-CM.
|
||||
Рассмотрите включение `use_rdmacm` для таких сетей.
|
||||
- name: use_rdmacm
|
||||
type: bool
|
||||
default: true
|
||||
info: |
|
||||
Use an alternative implementation of RDMA through RDMA-CM (Connection
|
||||
Manager). Works with all RDMA networks: Infiniband, iWARP and
|
||||
RoCEv1/RoCEv2, and even allows to disable TCP and run only with RDMA.
|
||||
When enabled, OSDs listen to the same address(es) and port(s) using
|
||||
TCP and RDMA-CM. `use_rdma` is automatically disabled when `use_rdmacm`
|
||||
is enabled.
|
||||
info_ru: |
|
||||
Использовать альтернативную реализацию RDMA на основе RDMA-CM (Connection
|
||||
Manager). Работает со всеми типами RDMA-сетей: Infiniband, iWARP и
|
||||
RoCEv1/RoCEv2, и даже позволяет полностью отключить TCP и работать
|
||||
только на RDMA. Когда опция включена, OSD слушают один и тот же порт
|
||||
на одних и тех же адресах через TCP и RDMA-CM. Также при включении
|
||||
автоматически отключается опция `use_rdma`.
|
||||
- name: disable_tcp
|
||||
type: bool
|
||||
default: true
|
||||
info: |
|
||||
Fully disable TCP and only use RDMA-CM for OSD communication.
|
||||
info_ru: |
|
||||
Полностью отключить TCP и использовать только RDMA-CM для соединений с OSD.
|
||||
- name: rdma_device
|
||||
type: string
|
||||
info: |
|
||||
|
@ -93,16 +122,19 @@
|
|||
Control) и ECN (Explicit Congestion Notification).
|
||||
- name: rdma_port_num
|
||||
type: int
|
||||
default: 1
|
||||
info: |
|
||||
RDMA device port number to use. Only for devices that have more than 1 port.
|
||||
See `phys_port_cnt` in `ibv_devinfo -v` output to determine how many ports
|
||||
your device has.
|
||||
|
||||
Not relevant for RDMA-CM (use_rdmacm).
|
||||
info_ru: |
|
||||
Номер порта RDMA-устройства, который следует использовать. Имеет смысл
|
||||
только для устройств, у которых более 1 порта. Чтобы узнать, сколько портов
|
||||
у вашего адаптера, посмотрите `phys_port_cnt` в выводе команды
|
||||
`ibv_devinfo -v`.
|
||||
|
||||
Опция неприменима к RDMA-CM (use_rdmacm).
|
||||
- name: rdma_gid_index
|
||||
type: int
|
||||
info: |
|
||||
|
@ -116,6 +148,8 @@
|
|||
GID auto-selection is unsupported with libibverbs < v32.
|
||||
|
||||
A correct rdma_gid_index for RoCEv2 is usually 1 (IPv6) or 3 (IPv4).
|
||||
|
||||
Not relevant for RDMA-CM (use_rdmacm).
|
||||
info_ru: |
|
||||
Номер глобального идентификатора адреса RDMA-устройства, который следует
|
||||
использовать. Разным gid_index могут соответствовать разные протоколы связи:
|
||||
|
@ -128,15 +162,16 @@
|
|||
libibverbs < v32.
|
||||
|
||||
Правильный rdma_gid_index для RoCEv2, как правило, 1 (IPv6) или 3 (IPv4).
|
||||
|
||||
Опция неприменима к RDMA-CM (use_rdmacm).
|
||||
- name: rdma_mtu
|
||||
type: int
|
||||
default: 4096
|
||||
info: |
|
||||
RDMA Path MTU to use. Must be 1024, 2048 or 4096. There is usually no
|
||||
sense to change it from the default 4096.
|
||||
RDMA Path MTU to use. Must be 1024, 2048 or 4096. Default is to use the
|
||||
RDMA device's MTU.
|
||||
info_ru: |
|
||||
Максимальная единица передачи (Path MTU) для RDMA. Должно быть равно 1024,
|
||||
2048 или 4096. Обычно нет смысла менять значение по умолчанию, равное 4096.
|
||||
2048 или 4096. По умолчанию используется значение MTU RDMA-устройства.
|
||||
- name: rdma_max_sge
|
||||
type: int
|
||||
default: 128
|
||||
|
@ -318,3 +353,35 @@
|
|||
Минимальный интервал полной перезагрузки состояния из etcd. Добавлено для
|
||||
предотвращения избыточной нагрузки на etcd во время отказов, когда etcd не
|
||||
успевает рассылать потоки событий и отменяет их.
|
||||
- name: tcp_header_buffer_size
|
||||
type: int
|
||||
default: 65536
|
||||
info: |
|
||||
Size of the buffer used to read data using an additional copy. Vitastor
|
||||
packet headers are 128 bytes, payload is always at least 4 KB, so it is
|
||||
usually beneficial to try to read multiple packets at once even though
|
||||
it requires to copy the data an additional time. The rest of each packet
|
||||
is received without an additional copy. You can try to play with this
|
||||
parameter and see how it affects random iops and linear bandwidth if you
|
||||
want.
|
||||
info_ru: |
|
||||
Размер буфера для чтения данных с дополнительным копированием. Пакеты
|
||||
Vitastor содержат 128-байтные заголовки, за которыми следуют данные размером
|
||||
от 4 КБ и для мелких операций ввода-вывода обычно выгодно за 1 вызов читать
|
||||
сразу несколько пакетов, даже не смотря на то, что это требует лишний раз
|
||||
скопировать данные. Часть каждого пакета за пределами значения данного
|
||||
параметра читается без дополнительного копирования. Вы можете попробовать
|
||||
поменять этот параметр и посмотреть, как он влияет на производительность
|
||||
случайного и линейного доступа.
|
||||
- name: use_sync_send_recv
|
||||
type: bool
|
||||
default: false
|
||||
info: |
|
||||
If true, synchronous send/recv syscalls are used instead of io_uring for
|
||||
socket communication. Useless for OSDs because they require io_uring anyway,
|
||||
but may be required for clients with old kernel versions.
|
||||
info_ru: |
|
||||
Если установлено в истину, то вместо io_uring для передачи данных по сети
|
||||
будут использоваться обычные синхронные системные вызовы send/recv. Для OSD
|
||||
это бессмысленно, так как OSD в любом случае нуждается в io_uring, но, в
|
||||
принципе, это может применяться для клиентов со старыми версиями ядра.
|
||||
|
|
|
@ -1,3 +1,26 @@
|
|||
- name: bind_address
|
||||
type: string or array of strings
|
||||
type_ru: строка или массив строк
|
||||
info: |
|
||||
Instead of the network masks ([osd_network](network.en.md#osd_network) and
|
||||
[osd_cluster_network](network.en.md#osd_cluster_network)), you can also set
|
||||
OSD listen addresses explicitly using this parameter. May be useful if you
|
||||
want to start OSDs on interfaces that are not UP + RUNNING.
|
||||
info_ru: |
|
||||
Вместо использования масок подсети ([osd_network](network.ru.md#osd_network) и
|
||||
[osd_cluster_network](network.ru.md#osd_cluster_network)), вы также можете явно
|
||||
задать адрес(а), на которых будут ожидать соединений OSD, с помощью данного
|
||||
параметра. Это может быть полезно, например, чтобы запускать OSD на неподнятых
|
||||
интерфейсах (не UP + RUNNING).
|
||||
- name: bind_port
|
||||
type: int
|
||||
info: |
|
||||
By default, OSDs pick random ports to use for incoming connections
|
||||
automatically. With this option you can set a specific port for a specific
|
||||
OSD by hand.
|
||||
info_ru: |
|
||||
По умолчанию OSD сами выбирают случайные порты для входящих подключений.
|
||||
С помощью данной опции вы можете задать порт для отдельного OSD вручную.
|
||||
- name: osd_iothread_count
|
||||
type: int
|
||||
default: 0
|
||||
|
@ -56,44 +79,6 @@
|
|||
реализовать дополнительный режим для монитора, который позволит отделять
|
||||
первичные OSD от вторичных, но пока не понятно, зачем это может кому-то
|
||||
понадобиться, поэтому это не реализовано.
|
||||
- name: osd_network
|
||||
type: string or array of strings
|
||||
type_ru: строка или массив строк
|
||||
info: |
|
||||
Network mask of the network (IPv4 or IPv6) to use for OSDs. Note that
|
||||
although it's possible to specify multiple networks here, this does not
|
||||
mean that OSDs will create multiple listening sockets - they'll only
|
||||
pick the first matching address of an UP + RUNNING interface. Separate
|
||||
networks for cluster and client connections are also not implemented, but
|
||||
they are mostly useless anyway, so it's not a big deal.
|
||||
info_ru: |
|
||||
Маска подсети (IPv4 или IPv6) для использования для соединений с OSD.
|
||||
Имейте в виду, что хотя сейчас и можно передать в этот параметр несколько
|
||||
подсетей, это не означает, что OSD будут создавать несколько слушающих
|
||||
сокетов - они лишь будут выбирать адрес первого поднятого (состояние UP +
|
||||
RUNNING), подходящий под заданную маску. Также не реализовано разделение
|
||||
кластерной и публичной сетей OSD. Правда, от него обычно всё равно довольно
|
||||
мало толку, так что особенной проблемы в этом нет.
|
||||
- name: bind_address
|
||||
type: string
|
||||
default: "0.0.0.0"
|
||||
info: |
|
||||
Instead of the network mask, you can also set OSD listen address explicitly
|
||||
using this parameter. May be useful if you want to start OSDs on interfaces
|
||||
that are not UP + RUNNING.
|
||||
info_ru: |
|
||||
Этим параметром можно явным образом задать адрес, на котором будет ожидать
|
||||
соединений OSD (вместо использования маски подсети). Может быть полезно,
|
||||
например, чтобы запускать OSD на неподнятых интерфейсах (не UP + RUNNING).
|
||||
- name: bind_port
|
||||
type: int
|
||||
info: |
|
||||
By default, OSDs pick random ports to use for incoming connections
|
||||
automatically. With this option you can set a specific port for a specific
|
||||
OSD by hand.
|
||||
info_ru: |
|
||||
По умолчанию OSD сами выбирают случайные порты для входящих подключений.
|
||||
С помощью данной опции вы можете задать порт для отдельного OSD вручную.
|
||||
- name: autosync_interval
|
||||
type: sec
|
||||
default: 5
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
designated initializers support from C++20
|
||||
- CMake
|
||||
- liburing, jerasure headers and libraries
|
||||
- ISA-L, libibverbs headers and libraries (optional)
|
||||
- ISA-L, libibverbs and librdmacm headers and libraries (optional)
|
||||
- tcmalloc (google-perftools-dev)
|
||||
|
||||
## Basic instructions
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
назначенных инициализаторов (designated initializers) из C++20
|
||||
- CMake
|
||||
- Заголовки и библиотеки liburing, jerasure
|
||||
- Опционально - заголовки и библиотеки ISA-L, libibverbs
|
||||
- Опционально - заголовки и библиотеки ISA-L, libibverbs, librdmacm
|
||||
- tcmalloc (google-perftools-dev)
|
||||
|
||||
## Базовая инструкция
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
- Per-OSD and per-image I/O and space usage statistics in etcd
|
||||
- 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)
|
||||
- [RDMA/RoCEv2 support via libibverbs](../config/network.en.md#rdma_device)
|
||||
- RDMA/RoCEv2 support [via libibverbs](../config/network.en.md#use_rdma) or [RDMA-CM](../config/network.en.md#use_rdmacm)
|
||||
- [Scrubbing](../config/osd.en.md#auto_scrub) (verification of copies)
|
||||
- [Checksums](../config/layout-osd.en.md#data_csum_type)
|
||||
- [Client write-back cache](../config/client.en.md#client_enable_writeback)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
- Именование инодов через хранение их метаданных в etcd
|
||||
- Снапшоты и copy-on-write клоны
|
||||
- [Сглаживание производительности случайной записи в SSD+HDD конфигурациях](../config/osd.ru.md#throttle_small_writes)
|
||||
- [Поддержка RDMA/RoCEv2 через libibverbs](../config/network.ru.md#rdma_device)
|
||||
- Поддержка RDMA/RoCEv2 [через libibverbs](../config/network.ru.md#use_rdma) или [RDMA-CM](../config/network.ru.md#use_rdmacm)
|
||||
- [Фоновая проверка целостности](../config/osd.ru.md#auto_scrub) (сверка копий)
|
||||
- [Контрольные суммы](../config/layout-osd.ru.md#data_csum_type)
|
||||
- [Буферизация записи на стороне клиента](../config/client.ru.md#client_enable_writeback)
|
||||
|
|
|
@ -50,7 +50,7 @@ On the monitor hosts:
|
|||
|
||||
## Configure OSDs
|
||||
|
||||
- Put etcd_address and osd_network into `/etc/vitastor/vitastor.conf`. Example:
|
||||
- Put etcd_address and [osd_network](../config/network.en.md#osd_network) into `/etc/vitastor/vitastor.conf`. Example:
|
||||
```
|
||||
{
|
||||
"etcd_address": ["10.200.1.10:2379","10.200.1.11:2379","10.200.1.12:2379"],
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
## Настройте OSD
|
||||
|
||||
- Пропишите etcd_address и osd_network в `/etc/vitastor/vitastor.conf`. Например:
|
||||
- Пропишите etcd_address и [osd_network](../config/network.ru.md#osd_network) в `/etc/vitastor/vitastor.conf`. Например:
|
||||
```
|
||||
{
|
||||
"etcd_address": ["10.200.1.10:2379","10.200.1.11:2379","10.200.1.12:2379"],
|
||||
|
|
|
@ -7,10 +7,14 @@ set(MSGR_RDMA "")
|
|||
if (IBVERBS_LIBRARIES)
|
||||
set(MSGR_RDMA "msgr_rdma.cpp")
|
||||
endif (IBVERBS_LIBRARIES)
|
||||
set(MSGR_RDMACM "")
|
||||
if (RDMACM_LIBRARIES)
|
||||
set(MSGR_RDMACM "msgr_rdmacm.cpp")
|
||||
endif (RDMACM_LIBRARIES)
|
||||
add_library(vitastor_common STATIC
|
||||
../util/epoll_manager.cpp etcd_state_client.cpp messenger.cpp ../util/addr_util.cpp
|
||||
msgr_stop.cpp msgr_op.cpp msgr_send.cpp msgr_receive.cpp ../util/ringloop.cpp ../../json11/json11.cpp
|
||||
http_client.cpp osd_ops.cpp pg_states.cpp ../util/timerfd_manager.cpp ../util/str_util.cpp ../util/json_util.cpp ${MSGR_RDMA}
|
||||
http_client.cpp osd_ops.cpp pg_states.cpp ../util/timerfd_manager.cpp ../util/str_util.cpp ../util/json_util.cpp ${MSGR_RDMA} ${MSGR_RDMACM}
|
||||
)
|
||||
target_link_libraries(vitastor_common pthread)
|
||||
target_compile_options(vitastor_common PUBLIC -fPIC)
|
||||
|
|
|
@ -124,7 +124,9 @@ void osd_messenger_t::init()
|
|||
rdmacm_evch = rdma_create_event_channel();
|
||||
if (!rdmacm_evch)
|
||||
{
|
||||
fprintf(stderr, "Failed to initialize RDMA-CM event channel: %s (code %d)\n", strerror(errno), errno);
|
||||
// ENODEV means that the client doesn't have RDMA devices available
|
||||
if (errno != ENODEV || log_level > 0)
|
||||
fprintf(stderr, "Failed to initialize RDMA-CM event channel: %s (code %d)\n", strerror(errno), errno);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -147,11 +149,6 @@ void osd_messenger_t::init()
|
|||
);
|
||||
if (!rdma_contexts.size())
|
||||
{
|
||||
if (force_rdma)
|
||||
{
|
||||
fprintf(stderr, "[OSD %ju] Couldn't initialize RDMA, force_rdma is enabled, exiting\n", osd_num);
|
||||
exit(1);
|
||||
}
|
||||
if (log_level > 0)
|
||||
fprintf(stderr, "[OSD %ju] Couldn't initialize RDMA, proceeding with TCP only\n", osd_num);
|
||||
}
|
||||
|
@ -299,16 +296,11 @@ void osd_messenger_t::parse_config(const json11::Json & config)
|
|||
this->use_rdma = config["use_rdma"].bool_value() || config["use_rdma"].uint64_value() != 0;
|
||||
}
|
||||
#ifdef WITH_RDMACM
|
||||
if (!config["use_rdmacm"].is_null())
|
||||
{
|
||||
// Use RDMA CM (required for iWARP and may be useful for IB)
|
||||
this->use_rdmacm = config["use_rdmacm"].bool_value() || config["use_rdmacm"].uint64_value() != 0;
|
||||
}
|
||||
// Use RDMA CM? (required for iWARP and may be useful for IB)
|
||||
// FIXME: Only parse during start
|
||||
this->use_rdmacm = config["use_rdmacm"].bool_value() || config["use_rdmacm"].uint64_value() != 0;
|
||||
this->disable_tcp = this->use_rdmacm && (config["disable_tcp"].bool_value() || config["disable_tcp"].uint64_value() != 0);
|
||||
#endif
|
||||
if (!config["force_rdma"].is_null())
|
||||
{
|
||||
this->force_rdma = config["force_rdma"].bool_value() || config["force_rdma"].uint64_value() != 0;
|
||||
}
|
||||
this->rdma_device = config["rdma_device"].string_value();
|
||||
this->rdma_port_num = (uint8_t)config["rdma_port_num"].uint64_value();
|
||||
if (!config["rdma_gid_index"].is_null())
|
||||
|
@ -352,9 +344,7 @@ void osd_messenger_t::parse_config(const json11::Json & config)
|
|||
this->log_level = config["log_level"].uint64_value();
|
||||
// OSD public & cluster networks
|
||||
this->osd_networks.clear();
|
||||
if (config["bind_address"].is_string())
|
||||
this->osd_networks.push_back(config["bind_address"].string_value());
|
||||
else if (config["osd_network"].is_string())
|
||||
if (config["osd_network"].is_string())
|
||||
this->osd_networks.push_back(config["osd_network"].string_value());
|
||||
else
|
||||
for (auto v: config["osd_network"].array_items())
|
||||
|
@ -376,8 +366,12 @@ void osd_messenger_t::parse_config(const json11::Json & config)
|
|||
this->osd_cluster_network_masks.clear();
|
||||
for (auto & netstr: this->osd_cluster_networks)
|
||||
this->osd_cluster_network_masks.push_back(cidr_parse(netstr));
|
||||
this->all_osd_networks.clear();
|
||||
this->all_osd_networks.insert(this->all_osd_networks.end(), this->osd_networks.begin(), this->osd_networks.end());
|
||||
this->all_osd_networks.insert(this->all_osd_networks.end(), this->osd_cluster_networks.begin(), this->osd_cluster_networks.end());
|
||||
this->all_osd_network_masks.clear();
|
||||
this->all_osd_network_masks.insert(this->all_osd_network_masks.end(), this->osd_network_masks.begin(), this->osd_network_masks.end());
|
||||
this->all_osd_network_masks.insert(this->all_osd_network_masks.end(), this->osd_cluster_network_masks.begin(), this->osd_cluster_network_masks.end());
|
||||
if (!this->osd_networks.size())
|
||||
{
|
||||
this->osd_networks = this->osd_cluster_networks;
|
||||
|
@ -390,40 +384,44 @@ void osd_messenger_t::connect_peer(uint64_t peer_osd, json11::Json peer_state)
|
|||
if (wanted_peers[peer_osd].raw_address_list != peer_state["addresses"])
|
||||
{
|
||||
wanted_peers[peer_osd].raw_address_list = peer_state["addresses"];
|
||||
if (osd_cluster_networks.size())
|
||||
// We are an OSD -> try to select a cluster address
|
||||
// We are a client -> try to select a public address
|
||||
// OSD only has 1 address -> don't try anything, it's pointless
|
||||
// FIXME: Maybe support optional fallback from cluster to public network?
|
||||
auto & match_masks = (this->osd_num ? osd_cluster_network_masks : osd_network_masks);
|
||||
if (peer_state["addresses"].array_items().size() > 1 && match_masks.size())
|
||||
{
|
||||
json11::Json::array address_list, cluster_address_list;
|
||||
json11::Json::array address_list;
|
||||
for (auto json_addr: peer_state["addresses"].array_items())
|
||||
{
|
||||
struct sockaddr_storage addr;
|
||||
auto ok = string_to_addr(json_addr.string_value(), false, 0, &addr);
|
||||
if (ok)
|
||||
{
|
||||
bool is_cluster = false;
|
||||
for (auto & mask: osd_cluster_network_masks)
|
||||
bool matches = false;
|
||||
for (auto & mask: match_masks)
|
||||
{
|
||||
if (cidr_sockaddr_match(addr, mask))
|
||||
{
|
||||
is_cluster = true;
|
||||
matches = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_cluster)
|
||||
cluster_address_list.push_back(json_addr);
|
||||
else
|
||||
if (matches)
|
||||
address_list.push_back(json_addr);
|
||||
}
|
||||
}
|
||||
auto n_cluster = this->osd_num ? cluster_address_list.size() : 0;
|
||||
if (this->osd_num)
|
||||
address_list.insert(address_list.begin(), cluster_address_list.begin(), cluster_address_list.end());
|
||||
if (!address_list.size())
|
||||
address_list = peer_state["addresses"].array_items();
|
||||
wanted_peers[peer_osd].address_list = address_list;
|
||||
wanted_peers[peer_osd].n_cluster_addr = n_cluster;
|
||||
}
|
||||
else
|
||||
wanted_peers[peer_osd].address_list = peer_state["addresses"];
|
||||
wanted_peers[peer_osd].address_changed = true;
|
||||
}
|
||||
#ifdef WITH_RDMACM
|
||||
wanted_peers[peer_osd].peer_rdmacm = peer_state["rdmacm"].bool_value();
|
||||
#endif
|
||||
wanted_peers[peer_osd].port = (int)peer_state["port"].int64_value();
|
||||
try_connect_peer(peer_osd);
|
||||
}
|
||||
|
@ -449,12 +447,24 @@ void osd_messenger_t::try_connect_peer(uint64_t peer_osd)
|
|||
wp.cur_addr = wp.address_list[wp.address_index].string_value();
|
||||
wp.cur_port = wp.port;
|
||||
wp.connecting = true;
|
||||
try_connect_peer_addr(peer_osd, wp.cur_addr.c_str(), wp.cur_port);
|
||||
#ifdef WITH_RDMACM
|
||||
if (use_rdmacm && wp.peer_rdmacm)
|
||||
rdmacm_try_connect_peer(peer_osd, wp.cur_addr.c_str(), wp.cur_port);
|
||||
else
|
||||
#endif
|
||||
try_connect_peer_tcp(peer_osd, wp.cur_addr.c_str(), wp.cur_port);
|
||||
}
|
||||
|
||||
void osd_messenger_t::try_connect_peer_addr(osd_num_t peer_osd, const char *peer_host, int peer_port)
|
||||
void osd_messenger_t::try_connect_peer_tcp(osd_num_t peer_osd, const char *peer_host, int peer_port)
|
||||
{
|
||||
assert(peer_osd != this->osd_num);
|
||||
#ifdef WITH_RDMACM
|
||||
if (disable_tcp)
|
||||
{
|
||||
on_connect_peer(peer_osd, -EINVAL);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
struct sockaddr_storage addr;
|
||||
if (!string_to_addr(peer_host, 0, peer_port, &addr))
|
||||
{
|
||||
|
@ -625,7 +635,7 @@ void osd_messenger_t::check_peer_config(osd_client_t *cl)
|
|||
if (!selected_ctx)
|
||||
{
|
||||
if (log_level > 0)
|
||||
fprintf(stderr, "No RDMA context for OSD %lu connection (peer %d), using only TCP\n", cl->osd_num, cl->peer_fd);
|
||||
fprintf(stderr, "No RDMA context for OSD %ju connection (peer %d), using only TCP\n", cl->osd_num, cl->peer_fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -50,10 +50,10 @@ struct osd_client_t
|
|||
{
|
||||
int refs = 0;
|
||||
|
||||
sockaddr_storage peer_addr;
|
||||
int peer_port;
|
||||
sockaddr_storage peer_addr = {};
|
||||
int peer_port = 0;
|
||||
int peer_fd = -1;
|
||||
int peer_state;
|
||||
int peer_state = 0;
|
||||
int connect_timeout_id = -1;
|
||||
int ping_time_remaining = 0;
|
||||
int idle_time_remaining = 0;
|
||||
|
@ -96,7 +96,7 @@ struct osd_wanted_peer_t
|
|||
{
|
||||
json11::Json raw_address_list;
|
||||
json11::Json address_list;
|
||||
int n_cluster_addr = 0;
|
||||
bool peer_rdmacm = false;
|
||||
int port = 0;
|
||||
time_t last_connect_attempt = 0;
|
||||
bool connecting = false, address_changed = false;
|
||||
|
@ -156,6 +156,9 @@ public:
|
|||
struct rdma_event_channel;
|
||||
struct rdma_cm_id;
|
||||
struct rdma_cm_event;
|
||||
struct ibv_context;
|
||||
struct osd_messenger_t;
|
||||
struct rdmacm_connecting_t;
|
||||
#endif
|
||||
|
||||
struct osd_messenger_t
|
||||
|
@ -175,7 +178,7 @@ protected:
|
|||
#ifdef WITH_RDMA
|
||||
bool use_rdma = true;
|
||||
bool use_rdmacm = false;
|
||||
bool force_rdma = false;
|
||||
bool disable_tcp = false;
|
||||
std::string rdma_device;
|
||||
uint64_t rdma_port_num = 1;
|
||||
int rdma_mtu = 0;
|
||||
|
@ -186,6 +189,7 @@ protected:
|
|||
bool rdma_odp = false;
|
||||
rdma_event_channel *rdmacm_evch = NULL;
|
||||
std::map<rdma_cm_id*, osd_client_t*> rdmacm_connections;
|
||||
std::map<rdma_cm_id*, rdmacm_connecting_t*> rdmacm_connecting;
|
||||
#endif
|
||||
|
||||
std::vector<msgr_iothread_t*> iothreads;
|
||||
|
@ -237,7 +241,7 @@ public:
|
|||
#endif
|
||||
#ifdef WITH_RDMACM
|
||||
bool is_use_rdmacm();
|
||||
rdma_cm_id *rdmacm_listen(const std::string & bind_address, int rdmacm_port);
|
||||
rdma_cm_id *rdmacm_listen(const std::string & bind_address, int rdmacm_port, int *bound_port, int log_level);
|
||||
void rdmacm_destroy_listener(rdma_cm_id *listener);
|
||||
#endif
|
||||
|
||||
|
@ -246,7 +250,7 @@ public:
|
|||
|
||||
protected:
|
||||
void try_connect_peer(uint64_t osd_num);
|
||||
void try_connect_peer_addr(osd_num_t peer_osd, const char *peer_host, int peer_port);
|
||||
void try_connect_peer_tcp(osd_num_t peer_osd, const char *peer_host, int peer_port);
|
||||
void handle_peer_epoll(int peer_fd, int epoll_events);
|
||||
void handle_connect_epoll(int peer_fd);
|
||||
void on_connect_peer(osd_num_t peer_osd, int peer_fd);
|
||||
|
@ -276,7 +280,13 @@ protected:
|
|||
#endif
|
||||
#ifdef WITH_RDMACM
|
||||
void handle_rdmacm_events();
|
||||
msgr_rdma_context_t* rdmacm_get_context(ibv_context *verbs);
|
||||
msgr_rdma_context_t* rdmacm_create_qp(rdma_cm_id *cmid);
|
||||
void rdmacm_accept(rdma_cm_event *ev);
|
||||
void rdmacm_try_connect_peer(uint64_t peer_osd, const std::string & addr, int peer_port);
|
||||
void rdmacm_on_connect_peer_error(rdma_cm_id *cmid, int res);
|
||||
void rdmacm_address_resolved(rdma_cm_event *ev);
|
||||
void rdmacm_route_resolved(rdma_cm_event *ev);
|
||||
void rdmacm_established(rdma_cm_event *ev);
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -6,6 +6,32 @@
|
|||
#include "msgr_rdma.h"
|
||||
#include "messenger.h"
|
||||
|
||||
static uint32_t ibv_mtu_to_bytes(ibv_mtu mtu)
|
||||
{
|
||||
switch (mtu)
|
||||
{
|
||||
case IBV_MTU_256: return 256;
|
||||
case IBV_MTU_512: return 512;
|
||||
case IBV_MTU_1024: return 1024;
|
||||
case IBV_MTU_2048: return 2048;
|
||||
case IBV_MTU_4096: return 4096;
|
||||
}
|
||||
return 4096;
|
||||
}
|
||||
|
||||
static ibv_mtu bytes_to_ibv_mtu(uint32_t mtu)
|
||||
{
|
||||
switch (mtu)
|
||||
{
|
||||
case 256: return IBV_MTU_256;
|
||||
case 512: return IBV_MTU_512;
|
||||
case 1024: return IBV_MTU_1024;
|
||||
case 2048: return IBV_MTU_2048;
|
||||
case 4096: return IBV_MTU_4096;
|
||||
}
|
||||
return IBV_MTU_4096;
|
||||
}
|
||||
|
||||
std::string msgr_rdma_address_t::to_string()
|
||||
{
|
||||
char msg[sizeof "0000:00000000:00000000:00000000000000000000000000000000"];
|
||||
|
@ -235,7 +261,7 @@ std::vector<msgr_rdma_context_t*> msgr_rdma_context_t::create_all(const std::vec
|
|||
fprintf(stderr, "RDMA device %s port %d GID %d does not exist\n", ibv_get_device_name(dev), port_num, sel_gid_index);
|
||||
continue;
|
||||
}
|
||||
uint32_t port_mtu = sel_mtu ? sel_mtu : portinfo.active_mtu;
|
||||
uint32_t port_mtu = sel_mtu ? sel_mtu : ibv_mtu_to_bytes(portinfo.active_mtu);
|
||||
#ifdef IBV_ADVISE_MR_ADVICE_PREFETCH_NO_FAULT
|
||||
if (sel_gid_index < 0)
|
||||
{
|
||||
|
@ -302,6 +328,11 @@ msgr_rdma_context_t *msgr_rdma_context_t::create(ibv_device *dev, ibv_port_attr
|
|||
goto cleanup;
|
||||
}
|
||||
ctx->gid_index = gid_index;
|
||||
if (ibv_query_gid(ctx->context, ib_port, gid_index, &ctx->my_gid))
|
||||
{
|
||||
fprintf(stderr, "Couldn't read RDMA device %s GID index %d\n", ibv_get_device_name(dev), gid_index);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ctx->pd = ibv_alloc_pd(ctx->context);
|
||||
if (!ctx->pd)
|
||||
|
@ -310,14 +341,15 @@ msgr_rdma_context_t *msgr_rdma_context_t::create(ibv_device *dev, ibv_port_attr
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if (ibv_query_device_ex(ctx->context, NULL, &ctx->attrx))
|
||||
{
|
||||
fprintf(stderr, "Couldn't query RDMA device for its features\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ctx->odp = odp;
|
||||
if (ctx->odp)
|
||||
{
|
||||
if (ibv_query_device_ex(ctx->context, NULL, &ctx->attrx))
|
||||
{
|
||||
fprintf(stderr, "Couldn't query RDMA device for its features\n");
|
||||
goto cleanup;
|
||||
}
|
||||
if (!(ctx->attrx.odp_caps.general_caps & IBV_ODP_SUPPORT) ||
|
||||
!(ctx->attrx.odp_caps.general_caps & IBV_ODP_SUPPORT_IMPLICIT) ||
|
||||
!(ctx->attrx.odp_caps.per_transport_caps.rc_odp_caps & IBV_ODP_SUPPORT_SEND) ||
|
||||
|
@ -443,25 +475,12 @@ msgr_rdma_connection_t *msgr_rdma_connection_t::create(msgr_rdma_context_t *ctx,
|
|||
return conn;
|
||||
}
|
||||
|
||||
static ibv_mtu mtu_to_ibv_mtu(uint32_t mtu)
|
||||
{
|
||||
switch (mtu)
|
||||
{
|
||||
case 256: return IBV_MTU_256;
|
||||
case 512: return IBV_MTU_512;
|
||||
case 1024: return IBV_MTU_1024;
|
||||
case 2048: return IBV_MTU_2048;
|
||||
case 4096: return IBV_MTU_4096;
|
||||
}
|
||||
return IBV_MTU_4096;
|
||||
}
|
||||
|
||||
int msgr_rdma_connection_t::connect(msgr_rdma_address_t *dest)
|
||||
{
|
||||
auto conn = this;
|
||||
ibv_qp_attr attr = {
|
||||
.qp_state = IBV_QPS_RTR,
|
||||
.path_mtu = mtu_to_ibv_mtu(conn->ctx->mtu),
|
||||
.path_mtu = bytes_to_ibv_mtu(conn->ctx->mtu),
|
||||
.rq_psn = dest->psn,
|
||||
.sq_psn = conn->addr.psn,
|
||||
.dest_qp_num = dest->qpn,
|
||||
|
@ -559,7 +578,7 @@ static void try_send_rdma_wr(osd_client_t *cl, ibv_sge *sge, int op_sge)
|
|||
int err = ibv_post_send(cl->rdma_conn->qp, &wr, &bad_wr);
|
||||
if (err || bad_wr)
|
||||
{
|
||||
fprintf(stderr, "RDMA send failed: %s\n", strerror(err));
|
||||
fprintf(stderr, "RDMA send failed: %s (code %d)\n", strerror(err), err);
|
||||
exit(1);
|
||||
}
|
||||
cl->rdma_conn->cur_send++;
|
||||
|
@ -846,235 +865,3 @@ void osd_messenger_t::handle_rdma_events(msgr_rdma_context_t *rdma_context)
|
|||
} while (event_count > 0);
|
||||
handle_immediate_ops();
|
||||
}
|
||||
|
||||
#ifdef WITH_RDMACM
|
||||
rdma_cm_id *osd_messenger_t::rdmacm_listen(const std::string & bind_address, int rdmacm_port)
|
||||
{
|
||||
rdma_cm_id *listener = NULL;
|
||||
int r = rdma_create_id(rdmacm_evch, &listener, NULL, RDMA_PS_TCP);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to create RDMA-CM ID: %s (code %d)\n", strerror(errno), errno);
|
||||
goto fail;
|
||||
}
|
||||
sockaddr_storage addr;
|
||||
if (!string_to_addr(bind_address, 0, rdmacm_port, &addr))
|
||||
{
|
||||
fprintf(stderr, "Server address: %s is not valid\n", bind_address.c_str());
|
||||
goto fail;
|
||||
}
|
||||
r = rdma_bind_addr(listener, (sockaddr*)&addr);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to bind RDMA-CM to %s:%d: %s (code %d)\n", bind_address.c_str(), rdmacm_port, strerror(errno), errno);
|
||||
goto fail;
|
||||
}
|
||||
r = rdma_listen(listener, 128);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to listen RDMA-CM: %s (code %d)\n", strerror(errno), errno);
|
||||
goto fail;
|
||||
}
|
||||
return listener;
|
||||
fail:
|
||||
rdma_destroy_id(listener);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_destroy_listener(rdma_cm_id *listener)
|
||||
{
|
||||
rdma_destroy_id(listener);
|
||||
}
|
||||
|
||||
void osd_messenger_t::handle_rdmacm_events()
|
||||
{
|
||||
rdma_cm_event *ev = NULL;
|
||||
std::vector<osd_client_t*> stop_clients;
|
||||
while (1)
|
||||
{
|
||||
int r = rdma_get_cm_event(rdmacm_evch, &ev);
|
||||
if (r != 0)
|
||||
{
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
break;
|
||||
fprintf(stderr, "Failed to get RDMA-CM event: %s (code %d)\n", strerror(errno), errno);
|
||||
exit(1);
|
||||
}
|
||||
if (ev->event == RDMA_CM_EVENT_CONNECT_REQUEST)
|
||||
{
|
||||
rdmacm_accept(ev);
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_CONNECT_ERROR ||
|
||||
ev->event == RDMA_CM_EVENT_REJECTED ||
|
||||
ev->event == RDMA_CM_EVENT_DISCONNECTED ||
|
||||
ev->event == RDMA_CM_EVENT_DEVICE_REMOVAL)
|
||||
{
|
||||
auto event_type_name = ev->event == RDMA_CM_EVENT_CONNECT_ERROR ? "RDMA_CM_EVENT_CONNECT_ERROR" : (
|
||||
ev->event == RDMA_CM_EVENT_REJECTED ? "RDMA_CM_EVENT_REJECTED" : (
|
||||
ev->event == RDMA_CM_EVENT_DISCONNECTED ? "RDMA_CM_EVENT_DISCONNECTED" : "RDMA_CM_EVENT_DEVICE_REMOVAL"));
|
||||
auto cli_it = rdmacm_connections.find(ev->id);
|
||||
if (cli_it == rdmacm_connections.end())
|
||||
{
|
||||
fprintf(stderr, "Received %s event for an unknown connection 0x%jx - ignoring\n",
|
||||
event_type_name, (uint64_t)ev->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Received %s event for connection 0x%jx - closing it\n",
|
||||
event_type_name, (uint64_t)ev->id);
|
||||
auto cli = cli_it->second;
|
||||
stop_clients.push_back(cli);
|
||||
}
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_ESTABLISHED)
|
||||
{
|
||||
rdmacm_established(ev);
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_ADDR_CHANGE || ev->event == RDMA_CM_EVENT_TIMEWAIT_EXIT)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
// Other events are unexpected
|
||||
fprintf(stderr, "Unexpected RDMA-CM event type: %d\n", ev->event);
|
||||
}
|
||||
r = rdma_ack_cm_event(ev);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to ack (free) RDMA-CM event: %s (code %d)\n", strerror(errno), errno);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
// Stop only after flushing all events, otherwise rdma_destroy_id infinitely waits for pthread_cond
|
||||
for (auto cli: stop_clients)
|
||||
{
|
||||
stop_client(cli->peer_fd);
|
||||
}
|
||||
}
|
||||
|
||||
msgr_rdma_context_t* msgr_rdma_context_t::create_cm(ibv_context *ctx)
|
||||
{
|
||||
auto rdma_context = new msgr_rdma_context_t;
|
||||
rdma_context->is_cm = true;
|
||||
rdma_context->context = ctx;
|
||||
rdma_context->pd = ibv_alloc_pd(ctx);
|
||||
if (!rdma_context->pd)
|
||||
{
|
||||
fprintf(stderr, "Couldn't allocate RDMA protection domain\n");
|
||||
delete rdma_context;
|
||||
return NULL;
|
||||
}
|
||||
rdma_context->odp = false;
|
||||
rdma_context->channel = ibv_create_comp_channel(rdma_context->context);
|
||||
if (!rdma_context->channel)
|
||||
{
|
||||
fprintf(stderr, "Couldn't create RDMA completion channel\n");
|
||||
delete rdma_context;
|
||||
return NULL;
|
||||
}
|
||||
rdma_context->max_cqe = 4096;
|
||||
rdma_context->cq = ibv_create_cq(rdma_context->context, rdma_context->max_cqe, NULL, rdma_context->channel, 0);
|
||||
if (!rdma_context->cq)
|
||||
{
|
||||
fprintf(stderr, "Couldn't create RDMA completion queue\n");
|
||||
delete rdma_context;
|
||||
return NULL;
|
||||
}
|
||||
if (ibv_query_device_ex(rdma_context->context, NULL, &rdma_context->attrx))
|
||||
{
|
||||
fprintf(stderr, "Couldn't query RDMA device for its features\n");
|
||||
delete rdma_context;
|
||||
return NULL;
|
||||
}
|
||||
return rdma_context;
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_accept(rdma_cm_event *ev)
|
||||
{
|
||||
// Find the context by device
|
||||
// We assume that ev->id->verbs is always the same for the same device (but PD for example isn't)
|
||||
msgr_rdma_context_t *rdma_context = NULL;
|
||||
for (auto ctx: rdma_contexts)
|
||||
{
|
||||
if (ctx->context == ev->id->verbs)
|
||||
{
|
||||
rdma_context = ctx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!rdma_context)
|
||||
{
|
||||
// Wrap into a new msgr_rdma_context_t
|
||||
rdma_context = msgr_rdma_context_t::create_cm(ev->id->verbs);
|
||||
if (!rdma_context)
|
||||
{
|
||||
rdma_destroy_id(ev->id);
|
||||
return;
|
||||
}
|
||||
fcntl(rdma_context->channel->fd, F_SETFL, fcntl(rdma_context->channel->fd, F_GETFL, 0) | O_NONBLOCK);
|
||||
tfd->set_fd_handler(rdma_context->channel->fd, false, [this, rdma_context](int notify_fd, int epoll_events)
|
||||
{
|
||||
handle_rdma_events(rdma_context);
|
||||
});
|
||||
handle_rdma_events(rdma_context);
|
||||
rdma_contexts.push_back(rdma_context);
|
||||
}
|
||||
rdma_context->reserve_cqe(rdma_max_send+rdma_max_recv);
|
||||
ibv_qp_init_attr init_attr = {
|
||||
.send_cq = rdma_context->cq,
|
||||
.recv_cq = rdma_context->cq,
|
||||
.cap = {
|
||||
.max_send_wr = (uint32_t)rdma_max_send,
|
||||
.max_recv_wr = (uint32_t)rdma_max_recv,
|
||||
.max_send_sge = (uint32_t)rdma_max_sge,
|
||||
.max_recv_sge = (uint32_t)rdma_max_sge,
|
||||
},
|
||||
.qp_type = IBV_QPT_RC,
|
||||
};
|
||||
int r = rdma_create_qp(ev->id, rdma_context->pd, &init_attr);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to create a queue pair via RDMA-CM: %s (code %d)\n", strerror(errno), errno);
|
||||
rdma_context->reserve_cqe(-rdma_max_send-rdma_max_recv);
|
||||
rdma_destroy_id(ev->id);
|
||||
return;
|
||||
}
|
||||
// We don't need private_data, RDMA_READ or ATOMIC so leave everything at 0
|
||||
rdma_conn_param conn_params = { .rnr_retry_count = 7 };
|
||||
r = rdma_accept(ev->id, &conn_params);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to accept RDMA-CM connection: %s (code %d)\n", strerror(errno), errno);
|
||||
rdma_context->reserve_cqe(-rdma_max_send-rdma_max_recv);
|
||||
rdma_destroy_qp(ev->id);
|
||||
rdma_destroy_id(ev->id);
|
||||
return;
|
||||
}
|
||||
rdma_context->cm_refs++;
|
||||
// Wrap into a new msgr_rdma_connection_t
|
||||
msgr_rdma_connection_t *conn = new msgr_rdma_connection_t;
|
||||
conn->ctx = rdma_context;
|
||||
conn->max_send = rdma_max_send;
|
||||
conn->max_recv = rdma_max_recv;
|
||||
conn->max_sge = rdma_max_sge > rdma_context->attrx.orig_attr.max_sge
|
||||
? rdma_context->attrx.orig_attr.max_sge : rdma_max_sge;
|
||||
conn->max_msg = rdma_max_msg;
|
||||
conn->cmid = ev->id;
|
||||
conn->qp = ev->id->qp;
|
||||
// Make a fake FD (FIXME: do not use FDs for identifying clients!)
|
||||
int fake_fd = open("/dev/null", O_RDONLY);
|
||||
auto cli = new osd_client_t();
|
||||
cli->peer_fd = fake_fd;
|
||||
cli->peer_state = PEER_RDMA;
|
||||
cli->in_buf = malloc_or_die(receive_buffer_size);
|
||||
cli->rdma_conn = conn;
|
||||
clients[fake_fd] = cli;
|
||||
rdmacm_connections[ev->id] = cli;
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_established(rdma_cm_event *ev)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -67,9 +67,9 @@ struct msgr_rdma_connection_t
|
|||
#endif
|
||||
msgr_rdma_address_t addr;
|
||||
int max_send = 0, max_recv = 0, max_sge = 0;
|
||||
int cur_send = 0, cur_recv = 0;
|
||||
uint64_t max_msg = 0;
|
||||
|
||||
int cur_send = 0, cur_recv = 0;
|
||||
int send_pos = 0, send_buf_pos = 0;
|
||||
int next_recv_buf = 0;
|
||||
std::vector<msgr_rdma_buf_t> recv_buffers;
|
||||
|
|
|
@ -0,0 +1,525 @@
|
|||
// Copyright (c) Vitaliy Filippov, 2019+
|
||||
// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "msgr_rdma.h"
|
||||
#include "messenger.h"
|
||||
|
||||
struct rdmacm_connecting_t
|
||||
{
|
||||
rdma_cm_id *cmid = NULL;
|
||||
int peer_fd = -1;
|
||||
osd_num_t peer_osd = 0;
|
||||
std::string addr;
|
||||
sockaddr_storage parsed_addr = {};
|
||||
int peer_port = 0;
|
||||
int timeout_ms = 0;
|
||||
int timeout_id = -1;
|
||||
msgr_rdma_context_t *rdma_context = NULL;
|
||||
};
|
||||
|
||||
rdma_cm_id *osd_messenger_t::rdmacm_listen(const std::string & bind_address, int rdmacm_port, int *bound_port, int log_level)
|
||||
{
|
||||
sockaddr_storage addr = {};
|
||||
rdma_cm_id *listener = NULL;
|
||||
int r = rdma_create_id(rdmacm_evch, &listener, NULL, RDMA_PS_TCP);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to create RDMA-CM ID: %s (code %d)\n", strerror(errno), errno);
|
||||
goto fail;
|
||||
}
|
||||
if (!string_to_addr(bind_address, 0, rdmacm_port, &addr))
|
||||
{
|
||||
fprintf(stderr, "Server address: %s is not valid\n", bind_address.c_str());
|
||||
goto fail;
|
||||
}
|
||||
r = rdma_bind_addr(listener, (sockaddr*)&addr);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to bind RDMA-CM to %s:%d: %s (code %d)\n", bind_address.c_str(), rdmacm_port, strerror(errno), errno);
|
||||
goto fail;
|
||||
}
|
||||
r = rdma_listen(listener, 128);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to listen to RDMA-CM address %s:%d: %s (code %d)\n", bind_address.c_str(), rdmacm_port, strerror(errno), errno);
|
||||
goto fail;
|
||||
}
|
||||
if (bound_port)
|
||||
{
|
||||
*bound_port = ntohs(rdma_get_src_port(listener));
|
||||
}
|
||||
if (log_level > 0)
|
||||
{
|
||||
fprintf(stderr, "Listening to RDMA-CM address %s port %d\n", bind_address.c_str(), *bound_port);
|
||||
}
|
||||
return listener;
|
||||
fail:
|
||||
rdma_destroy_id(listener);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_destroy_listener(rdma_cm_id *listener)
|
||||
{
|
||||
rdma_destroy_id(listener);
|
||||
}
|
||||
|
||||
void osd_messenger_t::handle_rdmacm_events()
|
||||
{
|
||||
// rdma_destroy_id infinitely waits for pthread_cond if called before all events are acked :-(
|
||||
std::vector<rdma_cm_event> events_copy;
|
||||
while (1)
|
||||
{
|
||||
rdma_cm_event *ev = NULL;
|
||||
int r = rdma_get_cm_event(rdmacm_evch, &ev);
|
||||
if (r != 0)
|
||||
{
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
break;
|
||||
fprintf(stderr, "Failed to get RDMA-CM event: %s (code %d)\n", strerror(errno), errno);
|
||||
exit(1);
|
||||
}
|
||||
events_copy.push_back(*ev);
|
||||
r = rdma_ack_cm_event(ev);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to ack (free) RDMA-CM event: %s (code %d)\n", strerror(errno), errno);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
for (auto & evl: events_copy)
|
||||
{
|
||||
auto ev = &evl;
|
||||
if (ev->event == RDMA_CM_EVENT_CONNECT_REQUEST)
|
||||
{
|
||||
rdmacm_accept(ev);
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_CONNECT_ERROR ||
|
||||
ev->event == RDMA_CM_EVENT_REJECTED ||
|
||||
ev->event == RDMA_CM_EVENT_DISCONNECTED ||
|
||||
ev->event == RDMA_CM_EVENT_DEVICE_REMOVAL)
|
||||
{
|
||||
auto event_type_name = ev->event == RDMA_CM_EVENT_CONNECT_ERROR ? "RDMA_CM_EVENT_CONNECT_ERROR" : (
|
||||
ev->event == RDMA_CM_EVENT_REJECTED ? "RDMA_CM_EVENT_REJECTED" : (
|
||||
ev->event == RDMA_CM_EVENT_DISCONNECTED ? "RDMA_CM_EVENT_DISCONNECTED" : "RDMA_CM_EVENT_DEVICE_REMOVAL"));
|
||||
auto cli_it = rdmacm_connections.find(ev->id);
|
||||
if (cli_it != rdmacm_connections.end())
|
||||
{
|
||||
fprintf(stderr, "Received %s event for peer %d, closing connection\n",
|
||||
event_type_name, cli_it->second->peer_fd);
|
||||
stop_client(cli_it->second->peer_fd);
|
||||
}
|
||||
else if (rdmacm_connecting.find(ev->id) != rdmacm_connecting.end())
|
||||
{
|
||||
fprintf(stderr, "Received %s event for RDMA-CM OSD %ju connection\n",
|
||||
event_type_name, rdmacm_connecting[ev->id]->peer_osd);
|
||||
rdmacm_established(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Received %s event for an unknown RDMA-CM connection 0x%jx - ignoring\n",
|
||||
event_type_name, (uint64_t)ev->id);
|
||||
}
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_ADDR_RESOLVED || ev->event == RDMA_CM_EVENT_ADDR_ERROR)
|
||||
{
|
||||
rdmacm_address_resolved(ev);
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_ROUTE_RESOLVED || ev->event == RDMA_CM_EVENT_ROUTE_ERROR)
|
||||
{
|
||||
rdmacm_route_resolved(ev);
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_CONNECT_RESPONSE)
|
||||
{
|
||||
// Just OK
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_UNREACHABLE || ev->event == RDMA_CM_EVENT_REJECTED)
|
||||
{
|
||||
// Handle error
|
||||
rdmacm_established(ev);
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_ESTABLISHED)
|
||||
{
|
||||
rdmacm_established(ev);
|
||||
}
|
||||
else if (ev->event == RDMA_CM_EVENT_ADDR_CHANGE || ev->event == RDMA_CM_EVENT_TIMEWAIT_EXIT)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
// Other events are unexpected
|
||||
fprintf(stderr, "Unexpected RDMA-CM event type: %d\n", ev->event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msgr_rdma_context_t* msgr_rdma_context_t::create_cm(ibv_context *ctx)
|
||||
{
|
||||
auto rdma_context = new msgr_rdma_context_t;
|
||||
rdma_context->is_cm = true;
|
||||
rdma_context->context = ctx;
|
||||
rdma_context->pd = ibv_alloc_pd(ctx);
|
||||
if (!rdma_context->pd)
|
||||
{
|
||||
fprintf(stderr, "Couldn't allocate RDMA protection domain\n");
|
||||
delete rdma_context;
|
||||
return NULL;
|
||||
}
|
||||
rdma_context->odp = false;
|
||||
rdma_context->channel = ibv_create_comp_channel(rdma_context->context);
|
||||
if (!rdma_context->channel)
|
||||
{
|
||||
fprintf(stderr, "Couldn't create RDMA completion channel\n");
|
||||
delete rdma_context;
|
||||
return NULL;
|
||||
}
|
||||
rdma_context->max_cqe = 4096;
|
||||
rdma_context->cq = ibv_create_cq(rdma_context->context, rdma_context->max_cqe, NULL, rdma_context->channel, 0);
|
||||
if (!rdma_context->cq)
|
||||
{
|
||||
fprintf(stderr, "Couldn't create RDMA completion queue\n");
|
||||
delete rdma_context;
|
||||
return NULL;
|
||||
}
|
||||
if (ibv_query_device_ex(rdma_context->context, NULL, &rdma_context->attrx))
|
||||
{
|
||||
fprintf(stderr, "Couldn't query RDMA device for its features\n");
|
||||
delete rdma_context;
|
||||
return NULL;
|
||||
}
|
||||
return rdma_context;
|
||||
}
|
||||
|
||||
msgr_rdma_context_t* osd_messenger_t::rdmacm_get_context(ibv_context *verbs)
|
||||
{
|
||||
// Find the context by device
|
||||
// We assume that RDMA_CM ev->id->verbs is always the same for the same device (but PD for example isn't)
|
||||
msgr_rdma_context_t *rdma_context = NULL;
|
||||
for (auto ctx: rdma_contexts)
|
||||
{
|
||||
if (ctx->context == verbs)
|
||||
{
|
||||
rdma_context = ctx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!rdma_context)
|
||||
{
|
||||
// Wrap into a new msgr_rdma_context_t
|
||||
rdma_context = msgr_rdma_context_t::create_cm(verbs);
|
||||
if (!rdma_context)
|
||||
return NULL;
|
||||
fcntl(rdma_context->channel->fd, F_SETFL, fcntl(rdma_context->channel->fd, F_GETFL, 0) | O_NONBLOCK);
|
||||
tfd->set_fd_handler(rdma_context->channel->fd, false, [this, rdma_context](int notify_fd, int epoll_events)
|
||||
{
|
||||
handle_rdma_events(rdma_context);
|
||||
});
|
||||
handle_rdma_events(rdma_context);
|
||||
rdma_contexts.push_back(rdma_context);
|
||||
}
|
||||
return rdma_context;
|
||||
}
|
||||
|
||||
msgr_rdma_context_t* osd_messenger_t::rdmacm_create_qp(rdma_cm_id *cmid)
|
||||
{
|
||||
auto rdma_context = rdmacm_get_context(cmid->verbs);
|
||||
if (!rdma_context)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
rdma_context->reserve_cqe(rdma_max_send+rdma_max_recv);
|
||||
auto max_sge = rdma_max_sge > rdma_context->attrx.orig_attr.max_sge
|
||||
? rdma_context->attrx.orig_attr.max_sge : rdma_max_sge;
|
||||
ibv_qp_init_attr init_attr = {
|
||||
.send_cq = rdma_context->cq,
|
||||
.recv_cq = rdma_context->cq,
|
||||
.cap = {
|
||||
.max_send_wr = (uint32_t)rdma_max_send,
|
||||
.max_recv_wr = (uint32_t)rdma_max_recv,
|
||||
.max_send_sge = (uint32_t)max_sge,
|
||||
.max_recv_sge = (uint32_t)max_sge,
|
||||
},
|
||||
.qp_type = IBV_QPT_RC,
|
||||
};
|
||||
int r = rdma_create_qp(cmid, rdma_context->pd, &init_attr);
|
||||
if (r != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to create a queue pair via RDMA-CM: %s (code %d)\n", strerror(errno), errno);
|
||||
rdma_context->reserve_cqe(-rdma_max_send-rdma_max_recv);
|
||||
return NULL;
|
||||
}
|
||||
return rdma_context;
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_accept(rdma_cm_event *ev)
|
||||
{
|
||||
// Make a fake FD (FIXME: do not use FDs for identifying clients!)
|
||||
int fake_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fake_fd < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to allocate a fake socket for RDMA-CM client: %s (code %d)\n", strerror(errno), errno);
|
||||
rdma_destroy_id(ev->id);
|
||||
return;
|
||||
}
|
||||
auto rdma_context = rdmacm_create_qp(ev->id);
|
||||
if (!rdma_context)
|
||||
{
|
||||
rdma_destroy_id(ev->id);
|
||||
return;
|
||||
}
|
||||
// We don't need private_data, RDMA_READ or ATOMIC so use default 1
|
||||
rdma_conn_param conn_params = {
|
||||
.responder_resources = 1,
|
||||
.initiator_depth = 1,
|
||||
.retry_count = 7,
|
||||
.rnr_retry_count = 7,
|
||||
};
|
||||
if (rdma_accept(ev->id, &conn_params) != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to accept RDMA-CM connection: %s (code %d)\n", strerror(errno), errno);
|
||||
rdma_context->reserve_cqe(-rdma_max_send-rdma_max_recv);
|
||||
rdma_destroy_qp(ev->id);
|
||||
rdma_destroy_id(ev->id);
|
||||
return;
|
||||
}
|
||||
rdma_context->cm_refs++;
|
||||
// Wrap into a new msgr_rdma_connection_t
|
||||
msgr_rdma_connection_t *conn = new msgr_rdma_connection_t;
|
||||
conn->ctx = rdma_context;
|
||||
conn->max_send = rdma_max_send;
|
||||
conn->max_recv = rdma_max_recv;
|
||||
conn->max_sge = rdma_max_sge > rdma_context->attrx.orig_attr.max_sge
|
||||
? rdma_context->attrx.orig_attr.max_sge : rdma_max_sge;
|
||||
conn->max_msg = rdma_max_msg;
|
||||
conn->cmid = ev->id;
|
||||
conn->qp = ev->id->qp;
|
||||
auto cl = new osd_client_t();
|
||||
cl->peer_fd = fake_fd;
|
||||
cl->peer_state = PEER_RDMA;
|
||||
cl->peer_addr = *(sockaddr_storage*)rdma_get_peer_addr(ev->id);
|
||||
cl->in_buf = malloc_or_die(receive_buffer_size);
|
||||
cl->rdma_conn = conn;
|
||||
clients[fake_fd] = cl;
|
||||
rdmacm_connections[ev->id] = cl;
|
||||
// Add initial receive request(s)
|
||||
try_recv_rdma(cl);
|
||||
fprintf(stderr, "[OSD %ju] new client %d: connection from %s via RDMA-CM\n", this->osd_num, fake_fd,
|
||||
addr_to_string(cl->peer_addr).c_str());
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_on_connect_peer_error(rdma_cm_id *cmid, int res)
|
||||
{
|
||||
auto conn = rdmacm_connecting.at(cmid);
|
||||
auto addr = conn->addr;
|
||||
auto peer_port = conn->peer_port;
|
||||
auto peer_osd = conn->peer_osd;
|
||||
if (conn->timeout_id >= 0)
|
||||
tfd->clear_timer(conn->timeout_id);
|
||||
if (conn->peer_fd >= 0)
|
||||
close(conn->peer_fd);
|
||||
if (conn->rdma_context)
|
||||
conn->rdma_context->reserve_cqe(-rdma_max_send-rdma_max_recv);
|
||||
if (conn->cmid)
|
||||
{
|
||||
if (conn->cmid->qp)
|
||||
rdma_destroy_qp(conn->cmid);
|
||||
rdma_destroy_id(conn->cmid);
|
||||
}
|
||||
rdmacm_connecting.erase(cmid);
|
||||
delete conn;
|
||||
if (!disable_tcp)
|
||||
{
|
||||
// Fall back to TCP instead of just reporting the error to on_connect_peer()
|
||||
try_connect_peer_tcp(peer_osd, addr.c_str(), peer_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TCP is disabled
|
||||
on_connect_peer(peer_osd, res == 0 ? -EINVAL : (res > 0 ? -res : res));
|
||||
}
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_try_connect_peer(uint64_t peer_osd, const std::string & addr, int peer_port)
|
||||
{
|
||||
struct sockaddr_storage sa = {};
|
||||
if (!string_to_addr(addr, false, peer_port, &sa))
|
||||
{
|
||||
fprintf(stderr, "Address %s is invalid\n", addr.c_str());
|
||||
on_connect_peer(peer_osd, -EINVAL);
|
||||
return;
|
||||
}
|
||||
rdma_cm_id *cmid = NULL;
|
||||
if (rdma_create_id(rdmacm_evch, &cmid, NULL, RDMA_PS_TCP) != 0)
|
||||
{
|
||||
int res = -errno;
|
||||
fprintf(stderr, "Failed to create RDMA-CM ID: %s (code %d), using TCP\n", strerror(errno), errno);
|
||||
if (!disable_tcp)
|
||||
try_connect_peer_tcp(peer_osd, addr.c_str(), peer_port);
|
||||
else
|
||||
on_connect_peer(peer_osd, res);
|
||||
return;
|
||||
}
|
||||
// Make a fake FD (FIXME: do not use FDs for identifying clients!)
|
||||
int fake_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fake_fd < 0)
|
||||
{
|
||||
int res = -errno;
|
||||
rdma_destroy_id(cmid);
|
||||
// Can't create socket, pointless to try TCP
|
||||
on_connect_peer(peer_osd, res);
|
||||
return;
|
||||
}
|
||||
auto conn = new rdmacm_connecting_t;
|
||||
rdmacm_connecting[cmid] = conn;
|
||||
conn->cmid = cmid;
|
||||
conn->peer_fd = fake_fd;
|
||||
conn->peer_osd = peer_osd;
|
||||
conn->addr = addr;
|
||||
conn->parsed_addr = sa;
|
||||
conn->peer_port = peer_port;
|
||||
conn->timeout_ms = peer_connect_timeout*1000;
|
||||
conn->timeout_id = -1;
|
||||
if (peer_connect_timeout > 0)
|
||||
{
|
||||
conn->timeout_id = tfd->set_timer(1000*peer_connect_timeout, false, [this, cmid](int timer_id)
|
||||
{
|
||||
auto conn = rdmacm_connecting.at(cmid);
|
||||
conn->timeout_id = -1;
|
||||
fprintf(stderr, "RDMA-CM connection to %s timed out\n", conn->addr.c_str());
|
||||
rdmacm_on_connect_peer_error(cmid, -EPIPE);
|
||||
return;
|
||||
});
|
||||
}
|
||||
if (rdma_resolve_addr(cmid, NULL, (sockaddr*)&conn->parsed_addr, conn->timeout_ms) != 0)
|
||||
{
|
||||
auto res = -errno;
|
||||
// ENODEV means that the client doesn't have an RDMA device for this address
|
||||
if (res != -ENODEV || log_level > 0)
|
||||
fprintf(stderr, "Failed to resolve address %s via RDMA-CM: %s (code %d)\n", addr.c_str(), strerror(errno), errno);
|
||||
rdmacm_on_connect_peer_error(cmid, res);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_address_resolved(rdma_cm_event *ev)
|
||||
{
|
||||
auto cmid = ev->id;
|
||||
auto conn_it = rdmacm_connecting.find(cmid);
|
||||
if (conn_it == rdmacm_connecting.end())
|
||||
{
|
||||
// Silently ignore unknown IDs
|
||||
return;
|
||||
}
|
||||
auto conn = conn_it->second;
|
||||
if (ev->event != RDMA_CM_EVENT_ADDR_RESOLVED || ev->status != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to resolve address %s via RDMA-CM: %s (code %d)\n", conn->addr.c_str(),
|
||||
ev->status > 0 ? "unknown error" : strerror(-ev->status), ev->status);
|
||||
rdmacm_on_connect_peer_error(cmid, ev->status);
|
||||
return;
|
||||
}
|
||||
auto rdma_context = rdmacm_create_qp(cmid);
|
||||
if (!rdma_context)
|
||||
{
|
||||
rdmacm_on_connect_peer_error(cmid, -EIO);
|
||||
return;
|
||||
}
|
||||
conn->rdma_context = rdma_context;
|
||||
if (rdma_resolve_route(cmid, conn->timeout_ms) != 0)
|
||||
{
|
||||
int res = -errno;
|
||||
fprintf(stderr, "Failed to resolve route to %s via RDMA-CM: %s (code %d)\n", conn->addr.c_str(), strerror(errno), errno);
|
||||
rdmacm_on_connect_peer_error(cmid, res);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_route_resolved(rdma_cm_event *ev)
|
||||
{
|
||||
auto cmid = ev->id;
|
||||
auto conn_it = rdmacm_connecting.find(cmid);
|
||||
if (conn_it == rdmacm_connecting.end())
|
||||
{
|
||||
// Silently ignore unknown IDs
|
||||
return;
|
||||
}
|
||||
auto conn = conn_it->second;
|
||||
if (ev->event != RDMA_CM_EVENT_ROUTE_RESOLVED || ev->status != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to resolve route to %s via RDMA-CM: %s (code %d)\n", conn->addr.c_str(),
|
||||
ev->status > 0 ? "unknown error" : strerror(-ev->status), ev->status);
|
||||
rdmacm_on_connect_peer_error(cmid, ev->status);
|
||||
return;
|
||||
}
|
||||
// We don't need private_data, RDMA_READ or ATOMIC so use default 1
|
||||
rdma_conn_param conn_params = {
|
||||
.responder_resources = 1,
|
||||
.initiator_depth = 1,
|
||||
.retry_count = 7,
|
||||
.rnr_retry_count = 7,
|
||||
};
|
||||
if (rdma_connect(cmid, &conn_params) != 0)
|
||||
{
|
||||
int res = -errno;
|
||||
fprintf(stderr, "Failed to connect to %s:%d via RDMA-CM: %s (code %d)\n", conn->addr.c_str(), conn->peer_port, strerror(errno), errno);
|
||||
rdmacm_on_connect_peer_error(cmid, res);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void osd_messenger_t::rdmacm_established(rdma_cm_event *ev)
|
||||
{
|
||||
auto cmid = ev->id;
|
||||
auto conn_it = rdmacm_connecting.find(cmid);
|
||||
if (conn_it == rdmacm_connecting.end())
|
||||
{
|
||||
// Silently ignore unknown IDs
|
||||
return;
|
||||
}
|
||||
auto conn = conn_it->second;
|
||||
auto peer_osd = conn->peer_osd;
|
||||
if (ev->event != RDMA_CM_EVENT_ESTABLISHED || ev->status != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to connect to %s:%d via RDMA-CM: %s (code %d)\n", conn->addr.c_str(), conn->peer_port,
|
||||
ev->status > 0 ? "unknown error" : strerror(-ev->status), ev->status);
|
||||
rdmacm_on_connect_peer_error(cmid, ev->status);
|
||||
return;
|
||||
}
|
||||
// Wrap into a new msgr_rdma_connection_t
|
||||
msgr_rdma_connection_t *rc = new msgr_rdma_connection_t;
|
||||
rc->ctx = conn->rdma_context;
|
||||
rc->ctx->cm_refs++;
|
||||
rc->max_send = rdma_max_send;
|
||||
rc->max_recv = rdma_max_recv;
|
||||
rc->max_sge = rdma_max_sge > rc->ctx->attrx.orig_attr.max_sge
|
||||
? rc->ctx->attrx.orig_attr.max_sge : rdma_max_sge;
|
||||
rc->max_msg = rdma_max_msg;
|
||||
rc->cmid = conn->cmid;
|
||||
rc->qp = conn->cmid->qp;
|
||||
// And an osd_client_t
|
||||
auto cl = new osd_client_t();
|
||||
cl->peer_addr = conn->parsed_addr;
|
||||
cl->peer_port = conn->peer_port;
|
||||
cl->peer_fd = conn->peer_fd;
|
||||
cl->peer_state = PEER_RDMA;
|
||||
cl->connect_timeout_id = -1;
|
||||
cl->osd_num = peer_osd;
|
||||
cl->in_buf = malloc_or_die(receive_buffer_size);
|
||||
cl->rdma_conn = rc;
|
||||
clients[conn->peer_fd] = cl;
|
||||
if (conn->timeout_id >= 0)
|
||||
tfd->clear_timer(conn->timeout_id);
|
||||
delete conn;
|
||||
rdmacm_connecting.erase(cmid);
|
||||
rdmacm_connections[cmid] = cl;
|
||||
if (log_level > 0)
|
||||
fprintf(stderr, "Successfully connected with OSD %ju using RDMA-CM\n", peer_osd);
|
||||
// Add initial receive request(s)
|
||||
try_recv_rdma(cl);
|
||||
osd_peer_fds[peer_osd] = cl->peer_fd;
|
||||
on_connect_peer(peer_osd, cl->peer_fd);
|
||||
}
|
|
@ -169,9 +169,23 @@ void osd_t::parse_config(bool init)
|
|||
else
|
||||
immediate_commit = IMMEDIATE_NONE;
|
||||
// Bind address
|
||||
cfg_bind_addresses.clear();
|
||||
if (config.find("bind_address") != config.end())
|
||||
{
|
||||
if (config["bind_address"].is_string())
|
||||
cfg_bind_addresses.push_back(config["bind_address"].string_value());
|
||||
else if (config["bind_address"].is_array())
|
||||
for (auto & addr: config["bind_address"].array_items())
|
||||
cfg_bind_addresses.push_back(addr.string_value());
|
||||
}
|
||||
bind_port = config["bind_port"].uint64_value();
|
||||
if (bind_port <= 0 || bind_port > 65535)
|
||||
bind_port = 0;
|
||||
#ifdef WITH_RDMACM
|
||||
// Use RDMA CM? (required for iWARP and may be useful for IB)
|
||||
this->use_rdmacm = config["use_rdmacm"].bool_value() || config["use_rdmacm"].uint64_value() != 0;
|
||||
this->disable_tcp = this->use_rdmacm && (config["disable_tcp"].bool_value() || config["disable_tcp"].uint64_value() != 0);
|
||||
#endif
|
||||
// OSD configuration
|
||||
etcd_report_interval = config["etcd_report_interval"].uint64_value();
|
||||
if (etcd_report_interval <= 0)
|
||||
|
@ -326,7 +340,11 @@ void osd_t::parse_config(bool init)
|
|||
|
||||
void osd_t::bind_socket()
|
||||
{
|
||||
if (msgr.all_osd_network_masks.size())
|
||||
if (cfg_bind_addresses.size())
|
||||
{
|
||||
bind_addresses = cfg_bind_addresses;
|
||||
}
|
||||
else if (msgr.all_osd_network_masks.size())
|
||||
{
|
||||
bind_addresses = getifaddr_list(msgr.all_osd_network_masks);
|
||||
if (!bind_addresses.size())
|
||||
|
@ -340,25 +358,33 @@ void osd_t::bind_socket()
|
|||
{
|
||||
bind_addresses.push_back("0.0.0.0");
|
||||
}
|
||||
for (auto & bind_address: bind_addresses)
|
||||
{
|
||||
int listen_fd = create_and_bind_socket(bind_address, listening_port ? listening_port : bind_port, listen_backlog, &listening_port);
|
||||
fcntl(listen_fd, F_SETFL, fcntl(listen_fd, F_GETFL, 0) | O_NONBLOCK);
|
||||
epmgr->set_fd_handler(listen_fd, false, [this](int fd, int events)
|
||||
{
|
||||
msgr.accept_connections(fd);
|
||||
});
|
||||
listen_fds.push_back(listen_fd);
|
||||
}
|
||||
#ifdef WITH_RDMACM
|
||||
if (msgr.is_use_rdmacm()) // FIXME: use json_is_true and move here
|
||||
if (!disable_tcp)
|
||||
{
|
||||
for (auto & bind_address: bind_addresses)
|
||||
{
|
||||
auto listener = msgr.rdmacm_listen(bind_address, listening_port);
|
||||
int listen_fd = create_and_bind_socket(bind_address, listening_port ? listening_port : bind_port, listen_backlog, &listening_port);
|
||||
fcntl(listen_fd, F_SETFL, fcntl(listen_fd, F_GETFL, 0) | O_NONBLOCK);
|
||||
epmgr->set_fd_handler(listen_fd, false, [this](int fd, int events)
|
||||
{
|
||||
msgr.accept_connections(fd);
|
||||
});
|
||||
listen_fds.push_back(listen_fd);
|
||||
}
|
||||
}
|
||||
#ifdef WITH_RDMACM
|
||||
if (use_rdmacm)
|
||||
{
|
||||
for (auto & bind_address: bind_addresses)
|
||||
{
|
||||
auto listener = msgr.rdmacm_listen(bind_address, listening_port, &listening_port, log_level);
|
||||
if (listener)
|
||||
rdmacm_listeners.push_back(listener);
|
||||
}
|
||||
if (!rdmacm_listeners.size() && disable_tcp)
|
||||
{
|
||||
fprintf(stderr, "Failed to create RDMA-CM listeners, exiting\n");
|
||||
force_stop(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -107,7 +107,10 @@ class osd_t
|
|||
bool no_recovery = false;
|
||||
bool no_scrub = false;
|
||||
bool allow_net_split = false;
|
||||
std::vector<std::string> cfg_bind_addresses;
|
||||
int bind_port, listen_backlog = 128;
|
||||
bool use_rdmacm = false;
|
||||
bool disable_tcp = false;
|
||||
// FIXME: Implement client queue depth limit
|
||||
int client_queue_depth = 128;
|
||||
bool allow_test_ops = false;
|
||||
|
|
|
@ -96,8 +96,8 @@ 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)
|
||||
{
|
||||
return mask.family == addr.ss_family && (mask.family == AF_INET
|
||||
? cidr_match(*(in_addr*)&addr, mask.ipv4, mask.bits)
|
||||
: cidr6_match(*(in6_addr*)&addr, mask.ipv6, mask.bits));
|
||||
? cidr_match(((sockaddr_in*)&addr)->sin_addr, mask.ipv4, mask.bits)
|
||||
: cidr6_match(((sockaddr_in6*)&addr)->sin6_addr, mask.ipv6, mask.bits));
|
||||
}
|
||||
|
||||
addr_mask_t cidr_parse(std::string mask)
|
||||
|
|
Loading…
Reference in New Issue