Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48c026bfa0 | ||
|
|
a73b2a26b6 | ||
|
|
f3192b610d | ||
|
|
a950889976 | ||
|
|
ef5194d93c | ||
|
|
f904576ab1 | ||
|
|
4f9b1f2f62 | ||
|
|
1d94afbd51 | ||
|
|
3634f005f1 | ||
|
|
263a3b5ad6 | ||
|
|
b760951aa7 | ||
|
|
c8321b8ed1 | ||
|
|
21066a095b | ||
|
|
a96900b696 | ||
|
|
8a6e461322 | ||
|
|
0b6a0463a4 | ||
|
|
35d4047f46 | ||
|
|
819f1125ae | ||
|
|
108df7329f | ||
|
|
d32edf6cdf | ||
|
|
dca436d7e6 | ||
|
|
8129a0b4e3 | ||
|
|
704c87d512 | ||
|
|
10216a5fb5 | ||
|
|
3932eb7ff6 | ||
|
|
69cbe7bbb2 | ||
|
|
4950a1636c | ||
|
|
2eb20dff28 | ||
|
|
59f0b0427c | ||
|
|
124162ad38 | ||
|
|
391c92af1a | ||
|
|
c3d8fdd855 | ||
|
|
9ccf3af97b | ||
|
|
568a209f0d | ||
|
|
b151013201 | ||
|
|
4a763725fe | ||
|
|
b8d83cd7f4 | ||
|
|
2e9ee2fe20 | ||
|
|
508ae852e4 | ||
|
|
97ee400505 | ||
|
|
5ee4894fab | ||
|
|
125dcafb11 | ||
|
|
9f44cf71df | ||
|
|
df3c63ca7f | ||
|
|
be66edd09f | ||
|
|
ccbc0c5928 | ||
|
|
78ca4538bf | ||
|
|
86b5760ec1 | ||
|
|
27f3803d2f | ||
|
|
2ead06e126 | ||
|
|
a5d5559f8e | ||
|
|
e8e7ba8fde | ||
|
|
6fd831a299 | ||
|
|
069808dfce | ||
|
|
bcefa42bc0 | ||
|
|
4636e02d43 | ||
|
|
e4c7d1c147 | ||
|
|
a4677f3e69 | ||
|
|
7cbf207d65 | ||
|
|
7c9711af20 | ||
|
|
33ef701464 |
+1
-1
@@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 2.8.12)
|
|||||||
|
|
||||||
project(vitastor)
|
project(vitastor)
|
||||||
|
|
||||||
set(VITASTOR_VERSION "1.10.1")
|
set(VITASTOR_VERSION "2.0.0")
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|||||||
+3
-1
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
Вернём былую скорость кластерному блочному хранилищу!
|
Вернём былую скорость кластерному блочному хранилищу!
|
||||||
|
|
||||||
Vitastor - распределённая блочная и файловая SDS (программная СХД), прямой аналог Ceph RBD и CephFS,
|
Vitastor - распределённая блочная, файловая и объектная SDS (программная СХД), прямой аналог Ceph RBD, CephFS и RGW,
|
||||||
а также внутренних СХД популярных облачных провайдеров. Однако, в отличие от них, Vitastor
|
а также внутренних СХД популярных облачных провайдеров. Однако, в отличие от них, Vitastor
|
||||||
быстрый и при этом простой. Только пока маленький :-).
|
быстрый и при этом простой. Только пока маленький :-).
|
||||||
|
|
||||||
@@ -41,10 +41,12 @@ Vitastor поддерживает QEMU-драйвер, протоколы NBD и
|
|||||||
- [Автор и лицензия](docs/intro/author.ru.md)
|
- [Автор и лицензия](docs/intro/author.ru.md)
|
||||||
- Установка
|
- Установка
|
||||||
- [Пакеты](docs/installation/packages.ru.md)
|
- [Пакеты](docs/installation/packages.ru.md)
|
||||||
|
- [Docker](docs/installation/docker.ru.md)
|
||||||
- [Proxmox](docs/installation/proxmox.ru.md)
|
- [Proxmox](docs/installation/proxmox.ru.md)
|
||||||
- [OpenNebula](docs/installation/opennebula.ru.md)
|
- [OpenNebula](docs/installation/opennebula.ru.md)
|
||||||
- [OpenStack](docs/installation/openstack.ru.md)
|
- [OpenStack](docs/installation/openstack.ru.md)
|
||||||
- [Kubernetes CSI](docs/installation/kubernetes.ru.md)
|
- [Kubernetes CSI](docs/installation/kubernetes.ru.md)
|
||||||
|
- [S3](docs/installation/s3.ru.md)
|
||||||
- [Сборка из исходных кодов](docs/installation/source.ru.md)
|
- [Сборка из исходных кодов](docs/installation/source.ru.md)
|
||||||
- Конфигурация
|
- Конфигурация
|
||||||
- [Обзор](docs/config.ru.md)
|
- [Обзор](docs/config.ru.md)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
Make Clustered Block Storage Fast Again.
|
Make Clustered Block Storage Fast Again.
|
||||||
|
|
||||||
Vitastor is a distributed block and file SDS, direct replacement of Ceph RBD and CephFS,
|
Vitastor is a distributed block, file and object SDS, direct replacement of Ceph RBD, CephFS and RGW,
|
||||||
and also internal SDS's of public clouds. However, in contrast to them, Vitastor is fast
|
and also internal SDS's of public clouds. However, in contrast to them, Vitastor is fast
|
||||||
and simple at the same time. The only thing is it's slightly young :-).
|
and simple at the same time. The only thing is it's slightly young :-).
|
||||||
|
|
||||||
@@ -41,10 +41,12 @@ Read more details in the documentation. You can start from here: [Quick Start](d
|
|||||||
- [Author and license](docs/intro/author.en.md)
|
- [Author and license](docs/intro/author.en.md)
|
||||||
- Installation
|
- Installation
|
||||||
- [Packages](docs/installation/packages.en.md)
|
- [Packages](docs/installation/packages.en.md)
|
||||||
|
- [Docker](docs/installation/docker.en.md)
|
||||||
- [Proxmox](docs/installation/proxmox.en.md)
|
- [Proxmox](docs/installation/proxmox.en.md)
|
||||||
- [OpenNebula](docs/installation/opennebula.en.md)
|
- [OpenNebula](docs/installation/opennebula.en.md)
|
||||||
- [OpenStack](docs/installation/openstack.en.md)
|
- [OpenStack](docs/installation/openstack.en.md)
|
||||||
- [Kubernetes CSI](docs/installation/kubernetes.en.md)
|
- [Kubernetes CSI](docs/installation/kubernetes.en.md)
|
||||||
|
- [S3](docs/installation/s3.en.md)
|
||||||
- [Building from Source](docs/installation/source.en.md)
|
- [Building from Source](docs/installation/source.en.md)
|
||||||
- Configuration
|
- Configuration
|
||||||
- [Overview](docs/config.en.md)
|
- [Overview](docs/config.en.md)
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
VITASTOR_VERSION ?= v1.10.1
|
VITASTOR_VERSION ?= v2.0.0
|
||||||
|
|
||||||
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:v1.10.1
|
image: vitalif/vitastor-csi:v2.0.0
|
||||||
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:v1.10.1
|
image: vitalif/vitastor-csi:v2.0.0
|
||||||
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 = "1.10.1"
|
vitastorCSIDriverVersion = "2.0.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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 (1.10.1-1) unstable; urgency=medium
|
vitastor (2.0.0-1) unstable; urgency=medium
|
||||||
|
|
||||||
* Bugfixes
|
* Bugfixes
|
||||||
|
|
||||||
|
|||||||
Vendored
+10
-1
@@ -2,7 +2,10 @@ Source: vitastor
|
|||||||
Section: admin
|
Section: admin
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Maintainer: Vitaliy Filippov <vitalif@yourcmc.ru>
|
Maintainer: Vitaliy Filippov <vitalif@yourcmc.ru>
|
||||||
Build-Depends: debhelper, liburing-dev (>= 0.6), g++ (>= 8), libstdc++6 (>= 8), linux-libc-dev, libgoogle-perftools-dev, libjerasure-dev, libgf-complete-dev, libibverbs-dev, libisal-dev, cmake, pkg-config, libnl-3-dev, libnl-genl-3-dev
|
Build-Depends: debhelper, liburing-dev (>= 0.6), g++ (>= 8), libstdc++6 (>= 8),
|
||||||
|
linux-libc-dev, libgoogle-perftools-dev, libjerasure-dev, libgf-complete-dev,
|
||||||
|
libibverbs-dev, libisal-dev, cmake, pkg-config, libnl-3-dev, libnl-genl-3-dev,
|
||||||
|
node-bindings <!nocheck>, node-gyp, node-nan
|
||||||
Standards-Version: 4.5.0
|
Standards-Version: 4.5.0
|
||||||
Homepage: https://vitastor.io/
|
Homepage: https://vitastor.io/
|
||||||
Rules-Requires-Root: no
|
Rules-Requires-Root: no
|
||||||
@@ -59,3 +62,9 @@ Architecture: amd64
|
|||||||
Depends: ${shlibs:Depends}, ${misc:Depends}, vitastor-client, patch, python3, jq
|
Depends: ${shlibs:Depends}, ${misc:Depends}, vitastor-client, patch, python3, jq
|
||||||
Description: Vitastor OpenNebula storage plugin
|
Description: Vitastor OpenNebula storage plugin
|
||||||
Vitastor storage plugin for OpenNebula.
|
Vitastor storage plugin for OpenNebula.
|
||||||
|
|
||||||
|
Package: node-vitastor
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}, node-bindings
|
||||||
|
Description: Node.js bindings for Vitastor client
|
||||||
|
Node.js native bindings for the Vitastor client library (vitastor-client).
|
||||||
|
|||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
usr/lib/x86_64-linux-gnu/nodejs/vitastor
|
||||||
Vendored
+7
-5
@@ -1,8 +1,10 @@
|
|||||||
# Build patched QEMU for Debian inside a container
|
# Build patched QEMU for Debian inside a container
|
||||||
# cd ..; podman build --build-arg REL=bullseye -v `pwd`/packages:/root/packages -f debian/patched-qemu.Dockerfile .
|
# cd ..; podman build --build-arg REL=bullseye -v `pwd`/packages:/root/packages -f debian/patched-qemu.Dockerfile .
|
||||||
|
|
||||||
|
ARG DISTRO=debian
|
||||||
ARG REL=
|
ARG REL=
|
||||||
FROM debian:$REL
|
FROM $DISTRO:$REL
|
||||||
|
ARG DISTRO=debian
|
||||||
ARG REL=
|
ARG REL=
|
||||||
|
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
@@ -20,8 +22,8 @@ RUN if [ "$REL" = "buster" -o "$REL" = "bullseye" -o "$REL" = "bookworm" ]; then
|
|||||||
echo 'APT::Install-Suggests false;' >> /etc/apt/apt.conf
|
echo 'APT::Install-Suggests false;' >> /etc/apt/apt.conf
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get -y install fio liburing-dev libgoogle-perftools-dev devscripts
|
RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/Moscow apt-get -y install fio liburing-dev libgoogle-perftools-dev devscripts
|
||||||
RUN apt-get -y build-dep qemu
|
RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/Moscow apt-get -y build-dep qemu
|
||||||
# To build a custom version
|
# To build a custom version
|
||||||
#RUN cp /root/packages/qemu-orig/* /root
|
#RUN cp /root/packages/qemu-orig/* /root
|
||||||
RUN apt-get --download-only source qemu
|
RUN apt-get --download-only source qemu
|
||||||
@@ -38,9 +40,9 @@ ADD src/client/qemu_driver.c /root/qemu_driver.c
|
|||||||
# apt-get install -y vitastor-client vitastor-client-dev quilt
|
# apt-get install -y vitastor-client vitastor-client-dev quilt
|
||||||
|
|
||||||
RUN set -e; \
|
RUN set -e; \
|
||||||
dpkg -i /root/packages/vitastor-$REL/vitastor-client_*.deb /root/packages/vitastor-$REL/vitastor-client-dev_*.deb; \
|
DEBIAN_FRONTEND=noninteractive TZ=Europe/Moscow apt-get -y install /root/packages/vitastor-$REL/vitastor-client_*.deb /root/packages/vitastor-$REL/vitastor-client-dev_*.deb; \
|
||||||
apt-get update; \
|
apt-get update; \
|
||||||
apt-get install -y quilt; \
|
DEBIAN_FRONTEND=noninteractive TZ=Europe/Moscow apt-get -y install quilt; \
|
||||||
mkdir -p /root/packages/qemu-$REL; \
|
mkdir -p /root/packages/qemu-$REL; \
|
||||||
rm -rf /root/packages/qemu-$REL/*; \
|
rm -rf /root/packages/qemu-$REL/*; \
|
||||||
cd /root/packages/qemu-$REL; \
|
cd /root/packages/qemu-$REL; \
|
||||||
|
|||||||
Vendored
+8
@@ -4,6 +4,14 @@ export DH_VERBOSE = 1
|
|||||||
%:
|
%:
|
||||||
dh $@
|
dh $@
|
||||||
|
|
||||||
|
override_dh_install:
|
||||||
|
perl -pe 's!prefix=/usr!prefix='`pwd`'/debian/tmp/usr!' < obj-x86_64-linux-gnu/src/client/vitastor.pc > node-binding/vitastor.pc
|
||||||
|
cd node-binding && PKG_CONFIG_PATH=./ PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 npm install --unsafe-perm || exit 1
|
||||||
|
mkdir -p debian/tmp/usr/lib/x86_64-linux-gnu/nodejs/vitastor/build/Release
|
||||||
|
cp -v node-binding/package.json node-binding/index.js node-binding/addon.cc node-binding/addon.h node-binding/client.cc node-binding/client.h debian/tmp/usr/lib/x86_64-linux-gnu/nodejs/vitastor
|
||||||
|
cp -v node-binding/build/Release/addon.node debian/tmp/usr/lib/x86_64-linux-gnu/nodejs/vitastor/build/Release
|
||||||
|
dh_install
|
||||||
|
|
||||||
override_dh_installdeb:
|
override_dh_installdeb:
|
||||||
cat debian/fio_version >> debian/vitastor-fio.substvars
|
cat debian/fio_version >> debian/vitastor-fio.substvars
|
||||||
[ -f debian/qemu_version ] && (cat debian/qemu_version >> debian/vitastor-qemu.substvars) || true
|
[ -f debian/qemu_version ] && (cat debian/qemu_version >> debian/vitastor-qemu.substvars) || true
|
||||||
|
|||||||
Vendored
+2
-1
@@ -22,7 +22,8 @@ RUN set -e -x; \
|
|||||||
echo 'APT::Install-Suggests false;' >> /etc/apt/apt.conf
|
echo 'APT::Install-Suggests false;' >> /etc/apt/apt.conf
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get -y install fio liburing-dev libgoogle-perftools-dev devscripts libjerasure-dev cmake libibverbs-dev librdmacm-dev libisal-dev libnl-3-dev libnl-genl-3-dev curl && \
|
apt-get -y install fio liburing-dev libgoogle-perftools-dev devscripts libjerasure-dev cmake \
|
||||||
|
libibverbs-dev librdmacm-dev libisal-dev libnl-3-dev libnl-genl-3-dev curl nodejs npm node-nan node-bindings && \
|
||||||
apt-get -y build-dep fio && \
|
apt-get -y build-dep fio && \
|
||||||
apt-get --download-only source fio
|
apt-get --download-only source fio
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -1,9 +1,11 @@
|
|||||||
# Build Docker image with Vitastor packages
|
# Build Docker image with Vitastor packages
|
||||||
|
|
||||||
FROM debian:bullseye
|
FROM debian:bookworm
|
||||||
|
|
||||||
ADD vitastor.list /etc/apt/sources.list.d
|
ADD etc/apt /etc/apt/
|
||||||
ADD vitastor.gpg /etc/apt/trusted.gpg.d
|
RUN apt-get update && apt-get -y install vitastor udev systemd qemu-system-x86 qemu-system-common qemu-block-extra qemu-utils jq nfs-common && apt-get clean
|
||||||
ADD vitastor.pref /etc/apt/preferences.d
|
ADD sleep.sh /usr/bin/
|
||||||
ADD apt.conf /etc/apt/
|
ADD install.sh /usr/bin/
|
||||||
RUN apt-get update && apt-get -y install vitastor qemu-system-x86 qemu-system-common && apt-get clean
|
ADD scripts /opt/scripts/
|
||||||
|
ADD etc /etc/
|
||||||
|
RUN ln -s /usr/lib/vitastor/mon/make-etcd /usr/bin/make-etcd
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
VITASTOR_VERSION ?= v2.0.0
|
||||||
|
|
||||||
|
all: build push
|
||||||
|
|
||||||
|
build:
|
||||||
|
@docker build --rm -t vitalif/vitastor:$(VITASTOR_VERSION) .
|
||||||
|
|
||||||
|
push:
|
||||||
|
@docker push vitalif/vitastor:$(VITASTOR_VERSION)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
deb http://vitastor.io/debian bookworm main
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Containerized etcd for Vitastor
|
||||||
|
After=network-online.target local-fs.target time-sync.target docker.service vitastor-host.service
|
||||||
|
Wants=network-online.target local-fs.target time-sync.target docker.service vitastor-host.service
|
||||||
|
PartOf=vitastor.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
Environment=GOGC=50
|
||||||
|
EnvironmentFile=/etc/vitastor/docker.conf
|
||||||
|
EnvironmentFile=/etc/vitastor/etcd.conf
|
||||||
|
SyslogIdentifier=etcd
|
||||||
|
ExecStart=bash -c 'docker run --rm -i -v /var/lib/vitastor/etcd:/data \
|
||||||
|
--log-driver none --network host $CONTAINER_OPTIONS --name vitastor-etcd \
|
||||||
|
$ETCD_IMAGE /usr/local/bin/etcd --name "$ETCD_NAME" --data-dir /data \
|
||||||
|
--snapshot-count 10000 --advertise-client-urls http://$ETCD_IP:2379 --listen-client-urls http://$ETCD_IP:2379 \
|
||||||
|
--initial-advertise-peer-urls http://$ETCD_IP:2380 --listen-peer-urls http://$ETCD_IP:2380 \
|
||||||
|
--initial-cluster-token vitastor-etcd-1 --initial-cluster "$ETCD_INITIAL_CLUSTER" \
|
||||||
|
--initial-cluster-state new --max-txn-ops=100000 --max-request-bytes=104857600 \
|
||||||
|
--auto-compaction-retention=10 --auto-compaction-mode=revision'
|
||||||
|
ExecStop=docker stop vitastor-etcd
|
||||||
|
Restart=always
|
||||||
|
StartLimitInterval=0
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Empty container for running Vitastor commands
|
||||||
|
After=network-online.target local-fs.target time-sync.target docker.service
|
||||||
|
Wants=network-online.target local-fs.target time-sync.target docker.service
|
||||||
|
PartOf=vitastor.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
EnvironmentFile=/etc/vitastor/docker.conf
|
||||||
|
ExecStart=bash -c 'docker run --rm -i -v /etc/vitastor:/etc/vitastor -v /dev:/dev -v /run:/run \
|
||||||
|
--security-opt seccomp=unconfined --privileged --pid=host --log-driver none --network host --name vitastor vitastor:$VITASTOR_VERSION \
|
||||||
|
sleep.sh'
|
||||||
|
ExecStartPost=udevadm trigger
|
||||||
|
ExecStop=docker stop vitastor
|
||||||
|
WorkingDirectory=/
|
||||||
|
PrivateTmp=false
|
||||||
|
TasksMax=infinity
|
||||||
|
Restart=always
|
||||||
|
StartLimitInterval=0
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Containerized Vitastor monitor
|
||||||
|
After=network-online.target local-fs.target time-sync.target docker.service
|
||||||
|
Wants=network-online.target local-fs.target time-sync.target docker.service
|
||||||
|
PartOf=vitastor.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
EnvironmentFile=/etc/vitastor/docker.conf
|
||||||
|
SyslogIdentifier=vitastor-mon
|
||||||
|
ExecStart=bash -c 'docker run --rm -i -v /etc/vitastor:/etc/vitastor -v /var/lib/vitastor:/var/lib/vitastor -v /dev:/dev \
|
||||||
|
--log-driver none --network host $CONTAINER_OPTIONS --name vitastor-mon vitastor:$VITASTOR_VERSION \
|
||||||
|
node /usr/lib/vitastor/mon/mon-main.js'
|
||||||
|
ExecStop=docker stop vitastor-mon
|
||||||
|
WorkingDirectory=/
|
||||||
|
PrivateTmp=false
|
||||||
|
TasksMax=infinity
|
||||||
|
Restart=always
|
||||||
|
StartLimitInterval=0
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Containerized Vitastor object storage daemon osd.%i
|
||||||
|
After=network-online.target local-fs.target time-sync.target docker.service vitastor-host.service
|
||||||
|
Wants=network-online.target local-fs.target time-sync.target docker.service vitastor-host.service
|
||||||
|
PartOf=vitastor.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
LimitNOFILE=1048576
|
||||||
|
LimitNPROC=1048576
|
||||||
|
LimitMEMLOCK=infinity
|
||||||
|
EnvironmentFile=/etc/vitastor/docker.conf
|
||||||
|
SyslogIdentifier=vitastor-osd%i
|
||||||
|
ExecStart=bash -c 'docker run --rm -i -v /etc/vitastor:/etc/vitastor -v /dev:/dev \
|
||||||
|
$(for i in $(ls /dev/vitastor/osd%i-*); do echo --device $i:$i; done) \
|
||||||
|
--log-driver none --network host --ulimit nofile=1048576 --ulimit memlock=-1 \
|
||||||
|
--security-opt seccomp=unconfined $CONTAINER_OPTIONS --name vitastor-osd%i \
|
||||||
|
vitastor:$VITASTOR_VERSION vitastor-disk exec-osd /dev/vitastor/osd%i-data'
|
||||||
|
ExecStartPre=+docker exec vitastor vitastor-disk pre-exec /dev/vitastor/osd%i-data
|
||||||
|
ExecStop=docker stop vitastor-etcd%i
|
||||||
|
WorkingDirectory=/
|
||||||
|
PrivateTmp=false
|
||||||
|
TasksMax=infinity
|
||||||
|
Restart=always
|
||||||
|
StartLimitInterval=0
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=vitastor.target
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=vitastor target
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
SUBSYSTEM=="block", ENV{ID_PART_ENTRY_TYPE}=="e7009fac-a5a1-4d72-af72-53de13059903", \
|
||||||
|
OWNER="vitastor", GROUP="vitastor", \
|
||||||
|
IMPORT{program}="/usr/bin/docker exec vitastor vitastor-disk udev $devnode", \
|
||||||
|
SYMLINK+="vitastor/$env{VITASTOR_ALIAS}"
|
||||||
|
|
||||||
|
ENV{VITASTOR_OSD_NUM}!="", ACTION=="add", RUN{program}+="/usr/bin/systemctl enable --now --no-block vitastor-osd@$env{VITASTOR_OSD_NUM}"
|
||||||
|
ENV{VITASTOR_OSD_NUM}!="", ACTION=="remove", RUN{program}+="/usr/bin/systemctl disable --now --no-block vitastor-osd@$env{VITASTOR_OSD_NUM}"
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#
|
||||||
|
# Configuration file for containerized Vitastor installation
|
||||||
|
# (non-Kubernetes, with systemd and udev-based orchestration)
|
||||||
|
#
|
||||||
|
|
||||||
|
# Desired Vitastor version
|
||||||
|
VITASTOR_VERSION=v2.0.0
|
||||||
|
|
||||||
|
# Additional arguments for all containers
|
||||||
|
# For example, you may want to specify a custom logging driver here
|
||||||
|
CONTAINER_OPTIONS=""
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ETCD_IMAGE=quay.io/coreos/etcd:v3.5.18
|
||||||
|
ETCD_NAME=""
|
||||||
|
ETCD_IP=""
|
||||||
|
ETCD_INITIAL_CLUSTER=""
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
{
|
||||||
|
}
|
||||||
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cp -urv /etc/default /host-etc/
|
||||||
|
cp -urv /etc/systemd /host-etc/
|
||||||
|
cp -urv /etc/udev /host-etc/
|
||||||
|
cp -urnv /etc/vitastor /host-etc/
|
||||||
|
cp -urnv /opt/scripts/* /host-bin/
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker exec -it vitastor vitastor-cli "$@"
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker exec -it vitastor vitastor-disk "$@"
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker exec -it vitastor fio "$@"
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker exec -it vitastor vitastor-nbd "$@"
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while :; do sleep infinity; done
|
||||||
@@ -1 +0,0 @@
|
|||||||
deb http://vitastor.io/debian bullseye main
|
|
||||||
+1
-1
@@ -13,7 +13,7 @@ Vitastor configuration consists of:
|
|||||||
- [Separate OSD settings](config/pool.en.md#osd-settings)
|
- [Separate OSD settings](config/pool.en.md#osd-settings)
|
||||||
- [Inode configuration](config/inode.en.md) i.e. image metadata like name, size and parent reference
|
- [Inode configuration](config/inode.en.md) i.e. image metadata like name, size and parent reference
|
||||||
|
|
||||||
Configuration parameters can be set in 3 places:
|
Configuration parameters can be set in 4 places:
|
||||||
- Configuration file (`/etc/vitastor/vitastor.conf` or other path)
|
- Configuration file (`/etc/vitastor/vitastor.conf` or other path)
|
||||||
- etcd key `/vitastor/config/global`. Most variables can be set there, but etcd
|
- etcd key `/vitastor/config/global`. Most variables can be set there, but etcd
|
||||||
connection parameters should obviously be set in the configuration file.
|
connection parameters should obviously be set in the configuration file.
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
- [Настроек инодов](config/inode.ru.md), т.е. метаданных образов, таких, как имя, размер и ссылки на
|
- [Настроек инодов](config/inode.ru.md), т.е. метаданных образов, таких, как имя, размер и ссылки на
|
||||||
родительский образ
|
родительский образ
|
||||||
|
|
||||||
Параметры конфигурации могут задаваться в 3 местах:
|
Параметры конфигурации могут задаваться в 4 местах:
|
||||||
- Файле конфигурации (`/etc/vitastor/vitastor.conf` или по другому пути)
|
- Файле конфигурации (`/etc/vitastor/vitastor.conf` или по другому пути)
|
||||||
- Ключе в etcd `/vitastor/config/global`. Большая часть параметров может
|
- Ключе в etcd `/vitastor/config/global`. Большая часть параметров может
|
||||||
задаваться там, кроме, естественно, самих параметров соединения с etcd,
|
задаваться там, кроме, естественно, самих параметров соединения с etcd,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ affect their interaction with the cluster.
|
|||||||
- [client_retry_interval](#client_retry_interval)
|
- [client_retry_interval](#client_retry_interval)
|
||||||
- [client_eio_retry_interval](#client_eio_retry_interval)
|
- [client_eio_retry_interval](#client_eio_retry_interval)
|
||||||
- [client_retry_enospc](#client_retry_enospc)
|
- [client_retry_enospc](#client_retry_enospc)
|
||||||
|
- [client_wait_up_timeout](#client_wait_up_timeout)
|
||||||
- [client_max_dirty_bytes](#client_max_dirty_bytes)
|
- [client_max_dirty_bytes](#client_max_dirty_bytes)
|
||||||
- [client_max_dirty_ops](#client_max_dirty_ops)
|
- [client_max_dirty_ops](#client_max_dirty_ops)
|
||||||
- [client_enable_writeback](#client_enable_writeback)
|
- [client_enable_writeback](#client_enable_writeback)
|
||||||
@@ -70,6 +71,19 @@ and clients are not blocked and just get EIO error code instead.
|
|||||||
Retry writes on out of space errors to wait until some space is freed on
|
Retry writes on out of space errors to wait until some space is freed on
|
||||||
OSDs.
|
OSDs.
|
||||||
|
|
||||||
|
## client_wait_up_timeout
|
||||||
|
|
||||||
|
- Type: seconds
|
||||||
|
- Default: 16
|
||||||
|
- Can be changed online: yes
|
||||||
|
|
||||||
|
Wait for this number of seconds until PGs are up when doing operations
|
||||||
|
which require all PGs to be up. Currently only used by object listings
|
||||||
|
in delete and merge-based commands ([vitastor-cli rm](../usage/cli.en.md#rm), merge and so on).
|
||||||
|
|
||||||
|
The default value is calculated as `1 + OSD lease timeout`, which is
|
||||||
|
`1 + etcd_report_interval + max_etcd_attempts*2*etcd_quick_timeout`.
|
||||||
|
|
||||||
## client_max_dirty_bytes
|
## client_max_dirty_bytes
|
||||||
|
|
||||||
- Type: integer
|
- Type: integer
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
- [client_retry_interval](#client_retry_interval)
|
- [client_retry_interval](#client_retry_interval)
|
||||||
- [client_eio_retry_interval](#client_eio_retry_interval)
|
- [client_eio_retry_interval](#client_eio_retry_interval)
|
||||||
- [client_retry_enospc](#client_retry_enospc)
|
- [client_retry_enospc](#client_retry_enospc)
|
||||||
|
- [client_wait_up_timeout](#client_wait_up_timeout)
|
||||||
- [client_max_dirty_bytes](#client_max_dirty_bytes)
|
- [client_max_dirty_bytes](#client_max_dirty_bytes)
|
||||||
- [client_max_dirty_ops](#client_max_dirty_ops)
|
- [client_max_dirty_ops](#client_max_dirty_ops)
|
||||||
- [client_enable_writeback](#client_enable_writeback)
|
- [client_enable_writeback](#client_enable_writeback)
|
||||||
@@ -72,6 +73,19 @@ RDMA и хотите повысить пиковую производитель
|
|||||||
Повторять запросы записи, завершившиеся с ошибками нехватки места, т.е.
|
Повторять запросы записи, завершившиеся с ошибками нехватки места, т.е.
|
||||||
ожидать, пока на OSD не освободится место.
|
ожидать, пока на OSD не освободится место.
|
||||||
|
|
||||||
|
## client_wait_up_timeout
|
||||||
|
|
||||||
|
- Тип: секунды
|
||||||
|
- Значение по умолчанию: 16
|
||||||
|
- Можно менять на лету: да
|
||||||
|
|
||||||
|
Время ожидания поднятия PG при операциях, требующих активности всех PG.
|
||||||
|
В данный момент используется листингами объектов в командах, использующих
|
||||||
|
удаление и слияние ([vitastor-cli rm](../usage/cli.ru.md#rm), merge и подобные).
|
||||||
|
|
||||||
|
Значение по умолчанию вычисляется как `1 + время lease OSD`, равное
|
||||||
|
`1 + etcd_report_interval + max_etcd_attempts*2*etcd_quick_timeout`.
|
||||||
|
|
||||||
## client_max_dirty_bytes
|
## client_max_dirty_bytes
|
||||||
|
|
||||||
- Тип: целое число
|
- Тип: целое число
|
||||||
|
|||||||
+18
-3
@@ -7,8 +7,8 @@
|
|||||||
# Runtime OSD Parameters
|
# Runtime OSD Parameters
|
||||||
|
|
||||||
These parameters only apply to OSDs, are not fixed at the moment of OSD drive
|
These parameters only apply to OSDs, are not fixed at the moment of OSD drive
|
||||||
initialization and can be changed - either with an OSD restart or, for some of
|
initialization and can be changed - in /etc/vitastor/vitastor.conf or [vitastor-disk update-sb](../usage/disk.en.md#update-sb)
|
||||||
them, even without restarting by updating configuration in etcd.
|
with an OSD restart or, for some of them, even without restarting by updating configuration in etcd.
|
||||||
|
|
||||||
- [osd_iothread_count](#osd_iothread_count)
|
- [osd_iothread_count](#osd_iothread_count)
|
||||||
- [etcd_report_interval](#etcd_report_interval)
|
- [etcd_report_interval](#etcd_report_interval)
|
||||||
@@ -61,6 +61,8 @@ them, even without restarting by updating configuration in etcd.
|
|||||||
- [recovery_tune_agg_interval](#recovery_tune_agg_interval)
|
- [recovery_tune_agg_interval](#recovery_tune_agg_interval)
|
||||||
- [recovery_tune_sleep_min_us](#recovery_tune_sleep_min_us)
|
- [recovery_tune_sleep_min_us](#recovery_tune_sleep_min_us)
|
||||||
- [recovery_tune_sleep_cutoff_us](#recovery_tune_sleep_cutoff_us)
|
- [recovery_tune_sleep_cutoff_us](#recovery_tune_sleep_cutoff_us)
|
||||||
|
- [discard_on_start](#discard_on_start)
|
||||||
|
- [min_discard_size](#min_discard_size)
|
||||||
|
|
||||||
## osd_iothread_count
|
## osd_iothread_count
|
||||||
|
|
||||||
@@ -316,7 +318,7 @@ for hot data and slower disks - HDDs and maybe SATA SSDs - but will slightly
|
|||||||
decrease write performance for fast disks because page cache is an overhead
|
decrease write performance for fast disks because page cache is an overhead
|
||||||
itself.
|
itself.
|
||||||
|
|
||||||
Choose "directsync" to use [immediate_commit](layout-cluster.ru.md#immediate_commit)
|
Choose "directsync" to use [immediate_commit](layout-cluster.en.md#immediate_commit)
|
||||||
(which requires disable_data_fsync) with drives having write-back cache
|
(which requires disable_data_fsync) with drives having write-back cache
|
||||||
which can't be turned off, for example, Intel Optane. Also note that *some*
|
which can't be turned off, for example, Intel Optane. Also note that *some*
|
||||||
desktop SSDs (for example, HP EX950) may ignore O_SYNC thus making
|
desktop SSDs (for example, HP EX950) may ignore O_SYNC thus making
|
||||||
@@ -629,3 +631,16 @@ are changed to 0.
|
|||||||
|
|
||||||
Maximum possible value for auto-tuned recovery_sleep_us. Higher values
|
Maximum possible value for auto-tuned recovery_sleep_us. Higher values
|
||||||
are treated as outliers and ignored in aggregation.
|
are treated as outliers and ignored in aggregation.
|
||||||
|
|
||||||
|
## discard_on_start
|
||||||
|
|
||||||
|
- Type: boolean
|
||||||
|
|
||||||
|
Discard (SSD TRIM) unused data device blocks on every OSD startup.
|
||||||
|
|
||||||
|
## min_discard_size
|
||||||
|
|
||||||
|
- Type: integer
|
||||||
|
- Default: 1048576
|
||||||
|
|
||||||
|
Minimum consecutive block size to TRIM it.
|
||||||
|
|||||||
+17
-2
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
Данные параметры используются только OSD, но, в отличие от дисковых параметров,
|
Данные параметры используются только OSD, но, в отличие от дисковых параметров,
|
||||||
не фиксируются в момент инициализации дисков OSD и могут быть изменены в любой
|
не фиксируются в момент инициализации дисков OSD и могут быть изменены в любой
|
||||||
момент с помощью перезапуска OSD, а некоторые и без перезапуска, с помощью
|
момент с перезапуском OSD в /etc/vitastor/vitastor.conf или [vitastor-disk update-sb](../usage/disk.ru.md#update-sb),
|
||||||
изменения конфигурации в etcd.
|
а некоторые и без перезапуска, с помощью изменения конфигурации в etcd.
|
||||||
|
|
||||||
- [osd_iothread_count](#osd_iothread_count)
|
- [osd_iothread_count](#osd_iothread_count)
|
||||||
- [etcd_report_interval](#etcd_report_interval)
|
- [etcd_report_interval](#etcd_report_interval)
|
||||||
@@ -62,6 +62,8 @@
|
|||||||
- [recovery_tune_agg_interval](#recovery_tune_agg_interval)
|
- [recovery_tune_agg_interval](#recovery_tune_agg_interval)
|
||||||
- [recovery_tune_sleep_min_us](#recovery_tune_sleep_min_us)
|
- [recovery_tune_sleep_min_us](#recovery_tune_sleep_min_us)
|
||||||
- [recovery_tune_sleep_cutoff_us](#recovery_tune_sleep_cutoff_us)
|
- [recovery_tune_sleep_cutoff_us](#recovery_tune_sleep_cutoff_us)
|
||||||
|
- [discard_on_start](#discard_on_start)
|
||||||
|
- [min_discard_size](#min_discard_size)
|
||||||
|
|
||||||
## osd_iothread_count
|
## osd_iothread_count
|
||||||
|
|
||||||
@@ -660,3 +662,16 @@ EC (кодов коррекции ошибок) с более, чем 1 диск
|
|||||||
Максимальное возможное значение авто-подстроенного recovery_sleep_us.
|
Максимальное возможное значение авто-подстроенного recovery_sleep_us.
|
||||||
Большие значения считаются случайными выбросами и игнорируются в
|
Большие значения считаются случайными выбросами и игнорируются в
|
||||||
усреднении.
|
усреднении.
|
||||||
|
|
||||||
|
## discard_on_start
|
||||||
|
|
||||||
|
- Тип: булево (да/нет)
|
||||||
|
|
||||||
|
Освобождать (SSD TRIM) неиспользуемые блоки диска данных при каждом запуске OSD.
|
||||||
|
|
||||||
|
## min_discard_size
|
||||||
|
|
||||||
|
- Тип: целое число
|
||||||
|
- Значение по умолчанию: 1048576
|
||||||
|
|
||||||
|
Минимальный размер последовательного блока данных, чтобы освобождать его через TRIM.
|
||||||
|
|||||||
+23
-10
@@ -43,7 +43,7 @@ Parameters:
|
|||||||
- [osd_tags](#osd_tags)
|
- [osd_tags](#osd_tags)
|
||||||
- [primary_affinity_tags](#primary_affinity_tags)
|
- [primary_affinity_tags](#primary_affinity_tags)
|
||||||
- [scrub_interval](#scrub_interval)
|
- [scrub_interval](#scrub_interval)
|
||||||
- [used_for_fs](#used_for_fs)
|
- [used_for_app](#used_for_app)
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
@@ -377,24 +377,37 @@ of the OSDs containing a data chunk for a PG.
|
|||||||
Automatic scrubbing interval for this pool. Overrides
|
Automatic scrubbing interval for this pool. Overrides
|
||||||
[global scrub_interval setting](osd.en.md#scrub_interval).
|
[global scrub_interval setting](osd.en.md#scrub_interval).
|
||||||
|
|
||||||
## used_for_fs
|
## used_for_app
|
||||||
|
|
||||||
- Type: string
|
- Type: string
|
||||||
|
|
||||||
If non-empty, the pool is marked as used for VitastorFS with metadata stored
|
If non-empty, the pool is marked as used for a separate application, for example,
|
||||||
in block image (regular Vitastor volume) named as the value of this pool parameter.
|
VitastorFS or S3, which allocates Vitastor volume IDs by itself and does not use
|
||||||
|
image/inode metadata in etcd.
|
||||||
|
|
||||||
When a pool is marked as used for VitastorFS, regular block volume creation in it
|
When a pool is marked as used for such app, regular block volume creation in it
|
||||||
is disabled (vitastor-cli refuses to create images without --force) to protect
|
is disabled (vitastor-cli refuses to create images without --force) to protect
|
||||||
the user from block volume and FS file ID collisions and data loss.
|
the user from block volume and FS/S3 volume ID collisions and data loss.
|
||||||
|
|
||||||
[vitastor-nfs](../usage/nfs.ru.md), in its turn, refuses to use pools not marked
|
Also such pools do not calculate per-inode space usage statistics in etcd because
|
||||||
|
using it for an external application implies that it may contain a very large
|
||||||
|
number of volumes and their statistics may take too much space in etcd.
|
||||||
|
|
||||||
|
Setting used_for_app to `fs:<name>` tells Vitastor that the pool is used for VitastorFS
|
||||||
|
with VitastorKV metadata base stored in a block image (regular Vitastor volume) named
|
||||||
|
`<name>`.
|
||||||
|
|
||||||
|
[vitastor-nfs](../usage/nfs.en.md), in its turn, refuses to use pools not marked
|
||||||
for the corresponding FS when starting. This also implies that you can use one
|
for the corresponding FS when starting. This also implies that you can use one
|
||||||
pool only for one VitastorFS.
|
pool only for one VitastorFS.
|
||||||
|
|
||||||
The second thing that is disabled for VitastorFS pools is reporting per-inode space
|
If you plan to use the pool for S3, set its used_for_app to `s3:<name>`. `<name>` may
|
||||||
usage statistics in etcd because a FS pool may store a very large number of files
|
be basically anything you want (for example, `s3:standard`) - it's not validated
|
||||||
and statistics for them all would take a lot of space in etcd.
|
by Vitastor S3 components in any way.
|
||||||
|
|
||||||
|
All other values except prefixed with `fs:` or `s3:` may be used freely and don't
|
||||||
|
mean anything special for Vitastor core components. For now, you can use them as
|
||||||
|
you wish.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
|
|||||||
+29
-16
@@ -42,7 +42,7 @@
|
|||||||
- [osd_tags](#osd_tags)
|
- [osd_tags](#osd_tags)
|
||||||
- [primary_affinity_tags](#primary_affinity_tags)
|
- [primary_affinity_tags](#primary_affinity_tags)
|
||||||
- [scrub_interval](#scrub_interval)
|
- [scrub_interval](#scrub_interval)
|
||||||
- [used_for_fs](#used_for_fs)
|
- [used_for_app](#used_for_app)
|
||||||
|
|
||||||
Примеры:
|
Примеры:
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ PG в Vitastor эферемерны, то есть вы можете менят
|
|||||||
|
|
||||||
## raw_placement
|
## raw_placement
|
||||||
|
|
||||||
- Type: string
|
- Тип: строка
|
||||||
|
|
||||||
Низкоуровневые правила генерации PG в форме DSL (доменно-специфичного языка).
|
Низкоуровневые правила генерации PG в форме DSL (доменно-специфичного языка).
|
||||||
Используйте, только если действительно знаете, зачем вам это надо :)
|
Используйте, только если действительно знаете, зачем вам это надо :)
|
||||||
@@ -383,26 +383,39 @@ OSD с "all".
|
|||||||
Интервал скраба, то есть, автоматической фоновой проверки данных для данного пула.
|
Интервал скраба, то есть, автоматической фоновой проверки данных для данного пула.
|
||||||
Переопределяет [глобальную настройку scrub_interval](osd.ru.md#scrub_interval).
|
Переопределяет [глобальную настройку scrub_interval](osd.ru.md#scrub_interval).
|
||||||
|
|
||||||
## used_for_fs
|
## used_for_app
|
||||||
|
|
||||||
- Type: string
|
- Тип: строка
|
||||||
|
|
||||||
Если непусто, пул помечается как используемый для файловой системы VitastorFS с
|
Если непусто, пул помечается как используемый для отдельного приложения, например,
|
||||||
метаданными, хранимыми в блочном образе Vitastor с именем, равным значению
|
для VitastorFS или S3, которое распределяет ID образов в пуле само и не использует
|
||||||
этого параметра.
|
метаданные образов/инодов в etcd.
|
||||||
|
|
||||||
Когда пул помечается как используемый для VitastorFS, создание обычных блочных
|
Когда пул помечается используемым для такого приложения, создание обычных блочных
|
||||||
образов в нём отключается (vitastor-cli отказывается создавать образы без --force),
|
образов в нём запрещается (vitastor-cli отказывается создавать образы без --force),
|
||||||
чтобы защитить пользователя от коллизий ID файлов и блочных образов и, таким
|
чтобы защитить пользователя от коллизий ID блочных образов и томов ФС/S3, и,
|
||||||
образом, от потери данных.
|
таким образом, от потери данных.
|
||||||
|
|
||||||
|
Также для таких пулов отключается передача статистики в etcd по отдельным инодам,
|
||||||
|
так как использование для внешнего приложения подразумевает, что пул может содержать
|
||||||
|
очень много томов и их статистика может занять слишком много места в etcd.
|
||||||
|
|
||||||
|
Установка used_for_app в значение `fs:<name>` сообщает о том, что пул используется
|
||||||
|
для VitastorFS с базой метаданных VitastorKV, хранимой в блочном образе с именем
|
||||||
|
`<name>`.
|
||||||
|
|
||||||
[vitastor-nfs](../usage/nfs.ru.md), в свою очередь, при запуске отказывается
|
[vitastor-nfs](../usage/nfs.ru.md), в свою очередь, при запуске отказывается
|
||||||
использовать для ФС пулы, не выделенные для неё. Это также означает, что один
|
использовать для ФС пулы, не помеченные, как используемые для неё. Это также
|
||||||
пул может использоваться только для одной VitastorFS.
|
означает, что один пул может использоваться только для одной VitastorFS.
|
||||||
|
|
||||||
Также для ФС-пулов отключается передача статистики в etcd по отдельным инодам,
|
Если же вы планируете использовать пул для данных S3, установите его used_for_app
|
||||||
так как ФС-пул может содержать очень много файлов и статистика по ним всем
|
в значение `s3:<name>`, где `<name>` - любое название по вашему усмотрению
|
||||||
заняла бы очень много места в etcd.
|
(например, `s3:standard`) - конкретное содержимое `<name>` пока никак не проверяется
|
||||||
|
компонентами Vitastor S3.
|
||||||
|
|
||||||
|
Все остальные значения used_for_app, кроме начинающихся на `fs:` или `s3:`, не
|
||||||
|
означают ничего особенного для основных компонентов Vitastor. Поэтому сейчас вы
|
||||||
|
можете использовать их свободно любым желаемым способом.
|
||||||
|
|
||||||
# Примеры
|
# Примеры
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,12 @@
|
|||||||
|
|
||||||
{{../../installation/packages.en.md}}
|
{{../../installation/packages.en.md}}
|
||||||
|
|
||||||
|
{{../../installation/docker.en.md}}
|
||||||
|
|
||||||
{{../../installation/proxmox.en.md}}
|
{{../../installation/proxmox.en.md}}
|
||||||
|
|
||||||
|
{{../../installation/opennebula.en.md}}
|
||||||
|
|
||||||
{{../../installation/openstack.en.md}}
|
{{../../installation/openstack.en.md}}
|
||||||
|
|
||||||
{{../../installation/kubernetes.en.md}}
|
{{../../installation/kubernetes.en.md}}
|
||||||
|
|||||||
@@ -14,8 +14,12 @@
|
|||||||
|
|
||||||
{{../../installation/packages.ru.md}}
|
{{../../installation/packages.ru.md}}
|
||||||
|
|
||||||
|
{{../../installation/docker.ru.md}}
|
||||||
|
|
||||||
{{../../installation/proxmox.ru.md}}
|
{{../../installation/proxmox.ru.md}}
|
||||||
|
|
||||||
|
{{../../installation/opennebula.ru.md}}
|
||||||
|
|
||||||
{{../../installation/openstack.ru.md}}
|
{{../../installation/openstack.ru.md}}
|
||||||
|
|
||||||
{{../../installation/kubernetes.ru.md}}
|
{{../../installation/kubernetes.ru.md}}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Runtime OSD Parameters
|
# Runtime OSD Parameters
|
||||||
|
|
||||||
These parameters only apply to OSDs, are not fixed at the moment of OSD drive
|
These parameters only apply to OSDs, are not fixed at the moment of OSD drive
|
||||||
initialization and can be changed - either with an OSD restart or, for some of
|
initialization and can be changed - in /etc/vitastor/vitastor.conf or [vitastor-disk update-sb](../usage/disk.en.md#update-sb)
|
||||||
them, even without restarting by updating configuration in etcd.
|
with an OSD restart or, for some of them, even without restarting by updating configuration in etcd.
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
Данные параметры используются только OSD, но, в отличие от дисковых параметров,
|
Данные параметры используются только OSD, но, в отличие от дисковых параметров,
|
||||||
не фиксируются в момент инициализации дисков OSD и могут быть изменены в любой
|
не фиксируются в момент инициализации дисков OSD и могут быть изменены в любой
|
||||||
момент с помощью перезапуска OSD, а некоторые и без перезапуска, с помощью
|
момент с перезапуском OSD в /etc/vitastor/vitastor.conf или [vitastor-disk update-sb](../usage/disk.ru.md#update-sb),
|
||||||
изменения конфигурации в etcd.
|
а некоторые и без перезапуска, с помощью изменения конфигурации в etcd.
|
||||||
|
|||||||
+10
-1
@@ -315,7 +315,7 @@
|
|||||||
decrease write performance for fast disks because page cache is an overhead
|
decrease write performance for fast disks because page cache is an overhead
|
||||||
itself.
|
itself.
|
||||||
|
|
||||||
Choose "directsync" to use [immediate_commit](layout-cluster.ru.md#immediate_commit)
|
Choose "directsync" to use [immediate_commit](layout-cluster.en.md#immediate_commit)
|
||||||
(which requires disable_data_fsync) with drives having write-back cache
|
(which requires disable_data_fsync) with drives having write-back cache
|
||||||
which can't be turned off, for example, Intel Optane. Also note that *some*
|
which can't be turned off, for example, Intel Optane. Also note that *some*
|
||||||
desktop SSDs (for example, HP EX950) may ignore O_SYNC thus making
|
desktop SSDs (for example, HP EX950) may ignore O_SYNC thus making
|
||||||
@@ -765,3 +765,12 @@
|
|||||||
Максимальное возможное значение авто-подстроенного recovery_sleep_us.
|
Максимальное возможное значение авто-подстроенного recovery_sleep_us.
|
||||||
Большие значения считаются случайными выбросами и игнорируются в
|
Большие значения считаются случайными выбросами и игнорируются в
|
||||||
усреднении.
|
усреднении.
|
||||||
|
- name: discard_on_start
|
||||||
|
type: bool
|
||||||
|
info: Discard (SSD TRIM) unused data device blocks on every OSD startup.
|
||||||
|
info_ru: Освобождать (SSD TRIM) неиспользуемые блоки диска данных при каждом запуске OSD.
|
||||||
|
- name: min_discard_size
|
||||||
|
type: int
|
||||||
|
default: 1048576
|
||||||
|
info: Minimum consecutive block size to TRIM it.
|
||||||
|
info_ru: Минимальный размер последовательного блока данных, чтобы освобождать его через TRIM.
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
[Documentation](../../README.md#documentation) → Installation → Dockerized Installation
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
[Читать на русском](docker.ru.md)
|
||||||
|
|
||||||
|
# Dockerized Installation
|
||||||
|
|
||||||
|
Vitastor may be installed in Docker/Podman. In such setups etcd, monitors and OSD
|
||||||
|
all run in containers, but everything else looks as close as possible to a usual
|
||||||
|
setup with packages:
|
||||||
|
- host network is used
|
||||||
|
- auto-start is implemented through udev and systemd
|
||||||
|
- logs are written to journald (not docker json log files)
|
||||||
|
- command-line wrapper scripts are installed to the host system to call vitastor-disk,
|
||||||
|
vitastor-cli and others through the container
|
||||||
|
|
||||||
|
Such installations may be useful when it's impossible or inconvenient to install
|
||||||
|
Vitastor from packages, for example, in exotic Linux distributions.
|
||||||
|
|
||||||
|
If you don't want just a simple containerized installation, you can also take a look
|
||||||
|
at Vitastor Kubernetes operator: https://github.com/Antilles7227/vitastor-operator
|
||||||
|
|
||||||
|
## Installing Containers
|
||||||
|
|
||||||
|
The instruction is very simple.
|
||||||
|
|
||||||
|
1. Download a Docker image of the desired version: \
|
||||||
|
`docker pull vitastor:1.10.2`
|
||||||
|
2. Install scripts to the host system: \
|
||||||
|
`docker run --rm -it -v /etc:/host-etc -v /usr/bin:/host-bin vitastor:1.10.2 install.sh`
|
||||||
|
3. Reload udev rules: \
|
||||||
|
`udevadm control --reload-rules`
|
||||||
|
|
||||||
|
And you can return to [Quick Start](../intro/quickstart.en.md).
|
||||||
|
|
||||||
|
## Upgrading Containers
|
||||||
|
|
||||||
|
First make sure to check the topic [Upgrading Vitastor](../usage/admin.en.md#upgrading-vitastor)
|
||||||
|
to figure out if you need any additional steps.
|
||||||
|
|
||||||
|
Then, to upgrade a containerized installation, you just need to change the `VITASTOR_VERSION`
|
||||||
|
option in `/etc/vitastor/docker.conf` and restart all Vitastor services:
|
||||||
|
|
||||||
|
`systemctl restart vitastor.target`
|
||||||
|
|
||||||
|
## QEMU
|
||||||
|
|
||||||
|
Vitastor Docker image also contains QEMU, qemu-img and qemu-storage-daemon built with Vitastor support.
|
||||||
|
|
||||||
|
However, running QEMU in Docker is harder to setup and it depends on the used virtualization UI
|
||||||
|
(OpenNebula, Proxmox and so on). Some of them also required patched Libvirt.
|
||||||
|
|
||||||
|
That's why containerized installation of Vitastor doesn't contain a ready-made QEMU setup and it's
|
||||||
|
recommended to install QEMU from packages or build it manually.
|
||||||
|
|
||||||
|
## fio
|
||||||
|
|
||||||
|
Vitastor Docker image also contains fio and installs a wrapper called `vitastor-fio` to use it from
|
||||||
|
the host system.
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
[Документация](../../README-ru.md#документация) → Установка → Установка в Docker
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
[Read in English](docker.en.md)
|
||||||
|
|
||||||
|
# Установка в Docker
|
||||||
|
|
||||||
|
Vitastor можно установить в Docker/Podman. При этом etcd, мониторы и OSD запускаются
|
||||||
|
в контейнерах, но всё остальное выглядит максимально приближенно к установке из пакетов:
|
||||||
|
- используется сеть хост-системы
|
||||||
|
- для автозапуска используются udev и systemd
|
||||||
|
- журналы записываются в journald (не в json-файлы журналов docker)
|
||||||
|
- в хост-систему устанавливаются обёртки для вызова консольных инструментов vitastor-disk,
|
||||||
|
vitastor-cli и других через контейнер
|
||||||
|
|
||||||
|
Такая установка полезна тогда, когда установка из пакетов невозможна или неудобна,
|
||||||
|
например, в нестандартных Linux-дистрибутивах.
|
||||||
|
|
||||||
|
Если вам нужна не просто контейнеризованная инсталляция, вы также можете обратить внимание
|
||||||
|
на Vitastor Kubernetes-оператор: https://github.com/Antilles7227/vitastor-operator
|
||||||
|
|
||||||
|
## Установка контейнеров
|
||||||
|
|
||||||
|
Инструкция по установке максимально простая.
|
||||||
|
|
||||||
|
1. Скачайте Docker-образ желаемой версии: \
|
||||||
|
`docker pull vitastor:1.10.2`
|
||||||
|
2. Установите скрипты в хост-систему командой: \
|
||||||
|
`docker run --rm -it -v /etc:/host-etc -v /usr/bin:/host-bin vitastor:1.10.2 install.sh`
|
||||||
|
3. Перезагрузите правила udev: \
|
||||||
|
`udevadm control --reload-rules`
|
||||||
|
|
||||||
|
После этого вы можете возвращаться к разделу [Быстрый старт](../intro/quickstart.ru.md).
|
||||||
|
|
||||||
|
## Обновление контейнеров
|
||||||
|
|
||||||
|
Сначала обязательно проверьте раздел [Обновление Vitastor](../usage/admin.ru.md#обновление-vitastor),
|
||||||
|
чтобы понять, не требуются ли вам какие-то дополнительные действия.
|
||||||
|
|
||||||
|
После этого для обновления Docker-инсталляции вам нужно просто поменять опцию `VITASTOR_VERSION`
|
||||||
|
в файле `/etc/vitastor/docker.conf` и перезапустить все сервисы Vitastor командой:
|
||||||
|
|
||||||
|
`systemctl restart vitastor.target`
|
||||||
|
|
||||||
|
## QEMU
|
||||||
|
|
||||||
|
В Docker-образ также входят QEMU, qemu-img и qemu-storage-daemon, собранные с поддержкой Vitastor.
|
||||||
|
|
||||||
|
Однако настроить запуск QEMU в Docker сложнее и способ запуска зависит от используемого интерфейса
|
||||||
|
виртуализации (OpenNebula, Proxmox и т.п.). Также для OpenNebula, например, требуется патченый
|
||||||
|
Libvirt.
|
||||||
|
|
||||||
|
Поэтому по умолчанию Docker-сборка пока что не включает в себя готового способа запуска QEMU
|
||||||
|
и QEMU рекомендуется устанавливать из пакетов или собирать самостоятельно.
|
||||||
|
|
||||||
|
## fio
|
||||||
|
|
||||||
|
fio также входит в Docker-контейнер vitastor, и в хост-систему устанавливается обёртка `vitastor-fio`
|
||||||
|
для запуска fio в контейнер.
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
- Debian 12 (Bookworm/Sid): `deb https://vitastor.io/debian bookworm main`
|
- Debian 12 (Bookworm/Sid): `deb https://vitastor.io/debian bookworm main`
|
||||||
- Debian 11 (Bullseye): `deb https://vitastor.io/debian bullseye main`
|
- Debian 11 (Bullseye): `deb https://vitastor.io/debian bullseye main`
|
||||||
- Debian 10 (Buster): `deb https://vitastor.io/debian buster main`
|
- Debian 10 (Buster): `deb https://vitastor.io/debian buster main`
|
||||||
|
- Ubuntu 22.04 (Jammy): `deb https://vitastor.io/debian jammy main`
|
||||||
- Add `-oldstable` to bookworm/bullseye/buster in this line to install the last
|
- Add `-oldstable` to bookworm/bullseye/buster in this line to install the last
|
||||||
stable version from 0.9.x branch instead of 1.x
|
stable version from 0.9.x branch instead of 1.x
|
||||||
- Install packages: `apt update; apt install vitastor lp-solve etcd linux-image-amd64 qemu-system-x86`
|
- Install packages: `apt update; apt install vitastor lp-solve etcd linux-image-amd64 qemu-system-x86`
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
- Debian 12 (Bookworm/Sid): `deb https://vitastor.io/debian bookworm main`
|
- Debian 12 (Bookworm/Sid): `deb https://vitastor.io/debian bookworm main`
|
||||||
- Debian 11 (Bullseye): `deb https://vitastor.io/debian bullseye main`
|
- Debian 11 (Bullseye): `deb https://vitastor.io/debian bullseye main`
|
||||||
- Debian 10 (Buster): `deb https://vitastor.io/debian buster main`
|
- Debian 10 (Buster): `deb https://vitastor.io/debian buster main`
|
||||||
|
- Ubuntu 22.04 (Jammy): `deb https://vitastor.io/debian jammy main`
|
||||||
- Добавьте `-oldstable` к слову bookworm/bullseye/buster в этой строке, чтобы
|
- Добавьте `-oldstable` к слову bookworm/bullseye/buster в этой строке, чтобы
|
||||||
установить последнюю стабильную версию из ветки 0.9.x вместо 1.x
|
установить последнюю стабильную версию из ветки 0.9.x вместо 1.x
|
||||||
- Установите пакеты: `apt update; apt install vitastor lp-solve etcd linux-image-amd64 qemu-system-x86`
|
- Установите пакеты: `apt update; apt install vitastor lp-solve etcd linux-image-amd64 qemu-system-x86`
|
||||||
|
|||||||
@@ -0,0 +1,191 @@
|
|||||||
|
[Documentation](../../README.md#documentation) → Installation → S3 for Vitastor
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
[Читать на русском](s3.ru.md)
|
||||||
|
|
||||||
|
# S3 for Vitastor
|
||||||
|
|
||||||
|
The moment has come - Vitastor S3 implementation based on Zenko CloudServer is released.
|
||||||
|
|
||||||
|
## Highlights
|
||||||
|
|
||||||
|
- Zenko CloudServer is implemented in node.js.
|
||||||
|
- Object metadata is stored in MongoDB.
|
||||||
|
- Modified Zenko CloudServer version is used for Vitastor. It is slightly different from
|
||||||
|
the original, has an optimised build and unneeded dependencies are stripped off.
|
||||||
|
- Object data is stored in Vitastor block volumes, but the volume metadata is stored in
|
||||||
|
the same MongoDB, not in Vitastor etcd.
|
||||||
|
- Objects are written to volumes sequentially one after another. The space is allocated
|
||||||
|
with rounding to the sector size (4 KB), so each object takes at least 4 KB.
|
||||||
|
- An important property of such storage scheme is that small objects aren't chunked into
|
||||||
|
parts in Vitastor EC N+K pools and thus don't require reads from all N disks when
|
||||||
|
downloading.
|
||||||
|
- Deleted objects are marked as deleted, but the space is only actually freed during
|
||||||
|
asynchronously executed "defragmentation" process. Defragmentation runs automatically
|
||||||
|
in the background when a volume reaches configured amount of "garbage" (20% by default).
|
||||||
|
Defragmentation copies actual objects to new volume(s) and then removes the old volume.
|
||||||
|
Defragmentation can be configured in locationConfig.json.
|
||||||
|
|
||||||
|
## Plans for future development
|
||||||
|
|
||||||
|
- User account storage in the DB instead of a static file. Original Zenko uses
|
||||||
|
a separate closed-source "Scality Vault" service for it, that's why we use
|
||||||
|
a static file for now.
|
||||||
|
- More detailed documentation.
|
||||||
|
- Support for other (and faster) key-value DBMS for object metadata storage.
|
||||||
|
- Other performance optimisations, for example, related to the used hash function -
|
||||||
|
MD5 used for Amazon compatibility purposes is relatively slow.
|
||||||
|
- Object Lifecycle support. There is a Lifecycle implementation for Zenko called
|
||||||
|
[Backbeat](https://github.com/scality/backbeat) but it's not adapted for Vitastor yet.
|
||||||
|
- Quota support. Original Zenko uses a separate "SCUBA" service for quotas, but
|
||||||
|
it's also proprietary and not available publicly.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
In a few words:
|
||||||
|
|
||||||
|
- Install MongoDB, create a user for S3 metadata DB.
|
||||||
|
- Create a Vitastor pool for S3 data.
|
||||||
|
- Download and setup the Docker container `vitalif/vitastor-zenko`.
|
||||||
|
|
||||||
|
### Setup MongoDB
|
||||||
|
|
||||||
|
You can setup MongoDB yourself, following the [MongoDB manual](https://www.mongodb.com/docs/manual/installation/).
|
||||||
|
|
||||||
|
Or you can follow the instructions below - it describes a simple example of MongoDB setup
|
||||||
|
in Docker (through docker-compose) with 3 replicas.
|
||||||
|
|
||||||
|
1. On each host, create a file `docker-compose.yml` with the content listed below.
|
||||||
|
Replace `<YOUR_PASSWORD>` with your future mongodb administrator password, and optionally
|
||||||
|
replace `0.0.0.0` with `localhost,<server_IP>`. It's recommended to either use a private IP
|
||||||
|
or [setup TLS](https://www.mongodb.com/docs/manual/tutorial/configure-ssl/) afterwards.
|
||||||
|
|
||||||
|
```
|
||||||
|
version: '3.1'
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
mongo:
|
||||||
|
container_name: mongo
|
||||||
|
image: mongo:7-jammy
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
MONGO_INITDB_ROOT_USERNAME: root
|
||||||
|
MONGO_INITDB_ROOT_PASSWORD: <YOUR_PASSWORD>
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- ./keyfile:/opt/keyfile
|
||||||
|
- ./mongo-data/db:/data/db
|
||||||
|
- ./mongo-data/configdb:/data/configdb
|
||||||
|
entrypoint: /bin/bash -c
|
||||||
|
command: [ "chown mongodb /opt/keyfile && chmod 600 /opt/keyfile && . /usr/local/bin/docker-entrypoint.sh mongod --replSet rs0 --keyFile /opt/keyfile --bind_ip 0.0.0.0" ]
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Generate a shared cluster key using `openssl rand -base64 756 > ./keyfile` and copy
|
||||||
|
that `keyfile` to all hosts.
|
||||||
|
|
||||||
|
3. Start MongoDB on all hosts with `docker compose up -d mongo`.
|
||||||
|
|
||||||
|
4. Enter Mongo Shell with `docker exec -it mongo mongosh -u root -p <YOUR_PASSWORD> localhost/admin`
|
||||||
|
and execute the following command (replace IP addresses `10.10.10.{1,2,3}` with your host IPs):
|
||||||
|
|
||||||
|
`rs.initiate({ _id: 'rs0', members: [
|
||||||
|
{ _id: 1, host: '10.10.10.1:27017' },
|
||||||
|
{ _id: 2, host: '10.10.10.2:27017' },
|
||||||
|
{ _id: 3, host: '10.10.10.3:27017' }
|
||||||
|
] })`
|
||||||
|
|
||||||
|
5. Stay in Mongo Shell and create a user for the future S3 database:
|
||||||
|
|
||||||
|
`db.createUser({ user: 's3', pwd: '<YOUR_S3_PASSWORD>', roles: [
|
||||||
|
{ role: 'readWrite', db: 's3' },
|
||||||
|
{ role: 'dbAdmin', db: 's3' },
|
||||||
|
{ role: 'readWrite', db: 'vitastor' },
|
||||||
|
{ role: 'dbAdmin', db: 'vitastor' }
|
||||||
|
] })`
|
||||||
|
|
||||||
|
### Setup Vitastor
|
||||||
|
|
||||||
|
Create a pool in Vitastor for S3 object data, for example:
|
||||||
|
|
||||||
|
`vitastor-cli create-pool --ec 2+1 -n 512 s3-data --used_for_app s3:standard`
|
||||||
|
|
||||||
|
The `--used_for_app` options works as fool-proofing and prevents you from
|
||||||
|
accidentally creating a regular block volume in the S3 pool and overwriting some S3 data.
|
||||||
|
Also it hides inode space statistics from Vitastor etcd.
|
||||||
|
|
||||||
|
Retrieve the ID of your pool with `vitastor-cli ls-pools s3-data --detail`.
|
||||||
|
|
||||||
|
### Setup Vitastor S3
|
||||||
|
|
||||||
|
1. Add the following lines to `docker-compose.yml` (instead of `network_mode: host`,
|
||||||
|
you can use `ports: [ "8000:8000", "8002:8002" ]`):
|
||||||
|
|
||||||
|
```
|
||||||
|
zenko:
|
||||||
|
container_name: zenko
|
||||||
|
image: vitalif/vitastor-zenko
|
||||||
|
restart: always
|
||||||
|
security_opt:
|
||||||
|
- seccomp:unconfined
|
||||||
|
ulimits:
|
||||||
|
memlock: -1
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- /etc/vitastor:/etc/vitastor
|
||||||
|
- /etc/vitastor/s3:/conf
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Download Docker image: `docker pull vitalif/vitastor-zenko`
|
||||||
|
|
||||||
|
3. Extract configuration file examples from the Docker image:
|
||||||
|
```
|
||||||
|
docker run --rm -it -v /etc/vitastor:/etc/vitastor -v /etc/vitastor/s3:/conf vitalif/vitastor-zenko configure.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Edit configuration files in `/etc/vitastor/s3/`:
|
||||||
|
- `config.json` - common settings.
|
||||||
|
- `authdata.json` - user accounts and access keys.
|
||||||
|
- `locationConfig.json` - S3 storage class list with placement settings.
|
||||||
|
Note: it actually contains storage classes (like STANDARD, COLD, etc)
|
||||||
|
instead of "locations" (zones like us-east-1) as in the original Zenko CloudServer.
|
||||||
|
- Put your MongoDB connection data into `config.json` and `locationConfig.json`.
|
||||||
|
- Put your Vitastor pool ID into `locationConfig.json`.
|
||||||
|
- For now, the complete list of Vitastor backend settings is only available [in the code](https://git.yourcmc.ru/vitalif/zenko-arsenal/src/branch/master/lib/storage/data/vitastor/VitastorBackend.ts#L94).
|
||||||
|
|
||||||
|
### Start Zenko
|
||||||
|
|
||||||
|
Start the S3 server with:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run --restart always --security-opt seccomp:unconfined --ulimit memlock=-1 --network=host \
|
||||||
|
-v /etc/vitastor:/etc/vitastor -v /etc/vitastor/s3:/conf --name zenko vitalif/vitastor-zenko
|
||||||
|
```
|
||||||
|
|
||||||
|
If you use default settings, Zenko CloudServer starts on port 8000.
|
||||||
|
The default access key is `accessKey1` with a secret key of `verySecretKey1`.
|
||||||
|
|
||||||
|
Now you can access your S3 with, for example, [s3cmd](https://s3tools.org/s3cmd):
|
||||||
|
|
||||||
|
```
|
||||||
|
s3cmd --access_key=accessKey1 --secret_key=verySecretKey1 --host=http://localhost:8000 mb s3://testbucket
|
||||||
|
```
|
||||||
|
|
||||||
|
Or even mount it with [GeeseFS](https://github.com/yandex-cloud/geesefs):
|
||||||
|
|
||||||
|
```
|
||||||
|
AWS_ACCESS_KEY_ID=accessKey1 \
|
||||||
|
AWS_SECRET_ACCESS_KEY=verySecretKey1 \
|
||||||
|
geesefs --endpoint http://localhost:8000 testbucket mountdir
|
||||||
|
```
|
||||||
|
|
||||||
|
## Author & License
|
||||||
|
|
||||||
|
- [Zenko CloudServer](https://s3-server.readthedocs.io/en/latest/) author is Scality,
|
||||||
|
licensed under [Apache License, version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
- [Vitastor](https://git.yourcmc.ru/vitalif/vitastor/) and Zenko Vitastor backend author is
|
||||||
|
Vitaliy Filippov, licensed under [VNPL-1.1](https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/VNPL-1.1.txt)
|
||||||
|
(a "network copyleft" license based on AGPL/SSPL, but worded in a better way)
|
||||||
|
- Vitastor S3 repository: https://git.yourcmc.ru/vitalif/zenko-cloudserver-vitastor
|
||||||
|
- Vitastor S3 backend code: https://git.yourcmc.ru/vitalif/zenko-arsenal/src/branch/master/lib/storage/data/vitastor/VitastorBackend.ts
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
[Документация](../../README-ru.md#документация) → Установка → S3 на базе Vitastor
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
[Read in English](s3.en.md)
|
||||||
|
|
||||||
|
# S3 на базе Vitastor
|
||||||
|
|
||||||
|
Итак, свершилось - реализация Vitastor S3 на базе Zenko CloudServer достигла
|
||||||
|
состояния готовности к публикации и использованию.
|
||||||
|
|
||||||
|
## Ключевые особенности
|
||||||
|
|
||||||
|
- Zenko CloudServer реализован на node.js.
|
||||||
|
- Метаданные объектов хранятся в MongoDB.
|
||||||
|
- Поставляется модифицированная версия Zenko CloudServer, отвязанная от лишних зависимостей,
|
||||||
|
с оптимизированной сборкой и немного отличающаяся от оригинала.
|
||||||
|
- Данные объектов хранятся в блочных томах Vitastor, однако информация о самих томах
|
||||||
|
сохраняется не в etcd Vitastor, а тоже в БД на основе MongoDB.
|
||||||
|
- Объекты записываются в тома последовательно друг за другом. Место выделяется с округлением
|
||||||
|
до размера сектора (до 4 килобайт), поэтому каждый объект занимает как минимум 4 КБ.
|
||||||
|
- Благодаря такой схеме записи объектов мелкие объекты не нарезаются на части и поэтому не
|
||||||
|
требуют чтения с N дисков данных в EC N+K пулах Vitastor.
|
||||||
|
- При удалении объекты помечаются удалёнными, но место освобождается не сразу, а при
|
||||||
|
запускаемой асинхронно "дефрагментации". Дефрагментация запускается автоматически в фоне
|
||||||
|
при достижении заданного объёма "мусора" в томе (по умолчанию 20%), копирует актуальные
|
||||||
|
объекты в новые тома, после чего очищает старый том полностью. Дефрагментацию можно
|
||||||
|
настраивать в locationConfig.json.
|
||||||
|
|
||||||
|
## Планы развития
|
||||||
|
|
||||||
|
- Хранение учётных записей в БД, а не в статическом файле (в оригинальном Zenko для
|
||||||
|
этого используется отдельный закрытый сервис "Scality Vault").
|
||||||
|
- Более подробная документация.
|
||||||
|
- Поддержка других (и более производительных) key-value СУБД для хранения метаданных.
|
||||||
|
- Другие оптимизации производительности, например, в области используемой хеш-функции
|
||||||
|
(хеш MD5, используемый в целях совместимости, относительно медленный).
|
||||||
|
- Поддержка Object Lifecycle. Реализация Lifecycle для Zenko существует и называется
|
||||||
|
[Backbeat](https://github.com/scality/backbeat), но она ещё не адаптирована для Vitastor.
|
||||||
|
- Квоты. В оригинальном Zenko для этого используется отдельный сервис "SCUBA", однако
|
||||||
|
он тоже является закрытым и недоступен для публичного использования.
|
||||||
|
|
||||||
|
## Установка
|
||||||
|
|
||||||
|
Кратко:
|
||||||
|
|
||||||
|
- Установите MongoDB, создайте пользователя для БД метаданных S3.
|
||||||
|
- Создайте в Vitastor пул для хранения данных объектов.
|
||||||
|
- Скачайте и настройте Docker-контейнер `vitalif/vitastor-zenko`.
|
||||||
|
|
||||||
|
### Установка MongoDB
|
||||||
|
|
||||||
|
Вы можете установить MongoDB сами, следуя [официальному руководству MongoDB](https://www.mongodb.com/docs/manual/installation/).
|
||||||
|
|
||||||
|
Либо вы можете последовать инструкции, приведённой ниже - здесь описан простейший пример
|
||||||
|
установки MongoDB в Docker (docker-compose) в конфигурации с 3 репликами.
|
||||||
|
|
||||||
|
1. На всех 3 серверах создайте файл `docker-compose.yml`, заменив `<ВАШ_ПАРОЛЬ>`
|
||||||
|
на собственный будущий пароль администратора mongodb, а `0.0.0.0` по желанию
|
||||||
|
заменив на на `localhost,<IP_сервера>` - желательно либо использовать публично не доступный IP,
|
||||||
|
либо потом [настроить TLS](https://www.mongodb.com/docs/manual/tutorial/configure-ssl/).
|
||||||
|
|
||||||
|
```
|
||||||
|
version: '3.1'
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
mongo:
|
||||||
|
container_name: mongo
|
||||||
|
image: mongo:7-jammy
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
MONGO_INITDB_ROOT_USERNAME: root
|
||||||
|
MONGO_INITDB_ROOT_PASSWORD: <ВАШ_ПАРОЛЬ>
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- ./keyfile:/opt/keyfile
|
||||||
|
- ./mongo-data/db:/data/db
|
||||||
|
- ./mongo-data/configdb:/data/configdb
|
||||||
|
entrypoint: /bin/bash -c
|
||||||
|
command: [ "chown mongodb /opt/keyfile && chmod 600 /opt/keyfile && . /usr/local/bin/docker-entrypoint.sh mongod --replSet rs0 --keyFile /opt/keyfile --bind_ip 0.0.0.0" ]
|
||||||
|
```
|
||||||
|
|
||||||
|
2. В той же директории сгенерируйте общий ключ кластера командой `openssl rand -base64 756 > ./keyfile`
|
||||||
|
и скопируйте этот файл на все 3 сервера.
|
||||||
|
|
||||||
|
3. На всех 3 серверах запустите MongoDB командой `docker compose up -d mongo`.
|
||||||
|
|
||||||
|
4. Зайдите в Mongo Shell с помощью команды `docker exec -it mongo mongosh -u root -p <ВАШ_ПАРОЛЬ> localhost/admin`
|
||||||
|
и там выполните команду (заменив IP-адреса `10.10.10.{1,2,3}` на адреса своих серверов):
|
||||||
|
|
||||||
|
`rs.initiate({ _id: 'rs0', members: [
|
||||||
|
{ _id: 1, host: '10.10.10.1:27017' },
|
||||||
|
{ _id: 2, host: '10.10.10.2:27017' },
|
||||||
|
{ _id: 3, host: '10.10.10.3:27017' }
|
||||||
|
] })`
|
||||||
|
|
||||||
|
5. Находясь там же, в Mongo Shell, создайте пользователя с доступом к будущей базе данных S3:
|
||||||
|
|
||||||
|
`db.createUser({ user: 's3', pwd: '<ВАШ_ПАРОЛЬ_S3>', roles: [
|
||||||
|
{ role: 'readWrite', db: 's3' },
|
||||||
|
{ role: 'dbAdmin', db: 's3' },
|
||||||
|
{ role: 'readWrite', db: 'vitastor' },
|
||||||
|
{ role: 'dbAdmin', db: 'vitastor' }
|
||||||
|
] })`
|
||||||
|
|
||||||
|
### Настройка Vitastor
|
||||||
|
|
||||||
|
Создайте в Vitastor отдельный пул для данных объектов S3, например:
|
||||||
|
|
||||||
|
`vitastor-cli create-pool --ec 2+1 -n 512 s3-data --used_for_app s3:standard`
|
||||||
|
|
||||||
|
Опция `--used_for_app` работает как "защита от дурака" и не даёт вам случайно создать
|
||||||
|
в этом пуле обычный блочный том и перезаписать им какие-то данные S3, а также скрывает
|
||||||
|
статистику занятого места по томам S3 из etcd.
|
||||||
|
|
||||||
|
Получите ID своего пула с помощью команды `vitastor-cli ls-pools --detail`.
|
||||||
|
|
||||||
|
### Установка Vitastor S3
|
||||||
|
|
||||||
|
1. Добавьте в `docker-compose.yml` строки (альтернативно вместо `network_mode: host`
|
||||||
|
можно использовать `ports: [ "8000:8000", "8002:8002" ]`):
|
||||||
|
|
||||||
|
```
|
||||||
|
zenko:
|
||||||
|
container_name: zenko
|
||||||
|
image: vitalif/vitastor-zenko
|
||||||
|
restart: always
|
||||||
|
security_opt:
|
||||||
|
- seccomp:unconfined
|
||||||
|
ulimits:
|
||||||
|
memlock: -1
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- /etc/vitastor:/etc/vitastor
|
||||||
|
- /etc/vitastor/s3:/conf
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Извлеките из Docker-образа Vitastor примеры файлов конфигурации:
|
||||||
|
`docker run --rm -it -v /etc/vitastor:/etc/vitastor -v /etc/vitastor/s3:/conf vitalif/vitastor-zenko configure.sh`
|
||||||
|
|
||||||
|
3. Отредактируйте файлы конфигурации в `/etc/vitastor/s3/`:
|
||||||
|
- `config.json` - общие настройки.
|
||||||
|
- `authdata.json` - учётные записи и ключи доступа.
|
||||||
|
- `locationConfig.json` - список классов хранения S3 с настройками расположения.
|
||||||
|
Внимание: в данной версии это именно список S3 storage class-ов (STANDARD, COLD и т.п.),
|
||||||
|
а не зон (подобных us-east-1), как в оригинальном Zenko CloudServer.
|
||||||
|
- В `config.json` и в `locationConfig.json` пропишите свои данные подключения к MongoDB.
|
||||||
|
- В `locationConfig.json` укажите ID пула Vitastor для хранения данных.
|
||||||
|
- Полный перечень настроек Vitastor-бэкенда пока можно посмотреть [в коде](https://git.yourcmc.ru/vitalif/zenko-arsenal/src/branch/master/lib/storage/data/vitastor/VitastorBackend.ts#L94).
|
||||||
|
|
||||||
|
### Запуск
|
||||||
|
|
||||||
|
Запустите S3-сервер: `docker-compose up -d zenko`
|
||||||
|
|
||||||
|
Готово! Вы получили S3-сервер, работающий на порту 8000.
|
||||||
|
|
||||||
|
Можете попробовать обратиться к нему с помощью, например, [s3cmd](https://s3tools.org/s3cmd):
|
||||||
|
|
||||||
|
`s3cmd --host-bucket= --no-ssl --access_key=accessKey1 --secret_key=verySecretKey1 --host=http://localhost:8000 mb s3://testbucket`
|
||||||
|
|
||||||
|
Или смонтировать его с помощью [GeeseFS](https://github.com/yandex-cloud/geesefs):
|
||||||
|
|
||||||
|
`AWS_ACCESS_KEY_ID=accessKey1 AWS_SECRET_ACCESS_KEY=verySecretKey1 geesefs --endpoint http://localhost:8000 testbucket /mnt/geesefs`
|
||||||
|
|
||||||
|
## Лицензия
|
||||||
|
|
||||||
|
- Автор [Zenko CloudServer](https://s3-server.readthedocs.io/en/latest/) - Scality, лицензия [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
- Vitastor-бэкенд для S3, как и сам Vitastor, лицензируется на условиях [VNPL 1.1](https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/VNPL-1.1.txt)
|
||||||
|
- Репозиторий сборки: https://git.yourcmc.ru/vitalif/zenko-cloudserver-vitastor
|
||||||
|
- Бэкенд хранения данных: https://git.yourcmc.ru/vitalif/zenko-arsenal/src/branch/master/lib/storage/data/vitastor/VitastorBackend.ts
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
- [Experimental internal etcd replacement - antietcd](../config/monitor.en.md#use_antietcd)
|
- [Experimental internal etcd replacement - antietcd](../config/monitor.en.md#use_antietcd)
|
||||||
- [Built-in Prometheus metric exporter](../config/monitor.en.md#enable_prometheus)
|
- [Built-in Prometheus metric exporter](../config/monitor.en.md#enable_prometheus)
|
||||||
- [NFS RDMA support](../usage/nfs.en.md#rdma) (probably also usable for GPUDirect)
|
- [NFS RDMA support](../usage/nfs.en.md#rdma) (probably also usable for GPUDirect)
|
||||||
|
- [S3](../installation/s3.en.md)
|
||||||
|
|
||||||
## Plugins and tools
|
## Plugins and tools
|
||||||
|
|
||||||
@@ -63,7 +64,6 @@ The following features are planned for the future:
|
|||||||
- iSCSI and NVMeoF gateways
|
- iSCSI and NVMeoF gateways
|
||||||
- Multi-threaded client
|
- Multi-threaded client
|
||||||
- Faster failover
|
- Faster failover
|
||||||
- S3
|
|
||||||
- Tiered storage (SSD caching)
|
- Tiered storage (SSD caching)
|
||||||
- NVDIMM support
|
- NVDIMM support
|
||||||
- Compression (possibly)
|
- Compression (possibly)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
- [Экспериментальная встроенная замена etcd - antietcd](../config/monitor.ru.md#use_antietcd)
|
- [Экспериментальная встроенная замена etcd - antietcd](../config/monitor.ru.md#use_antietcd)
|
||||||
- [Встроенный Prometheus-экспортер метрик](../config/monitor.ru.md#enable_prometheus)
|
- [Встроенный Prometheus-экспортер метрик](../config/monitor.ru.md#enable_prometheus)
|
||||||
- [Поддержка NFS RDMA](../usage/nfs.ru.md#rdma) (вероятно, также подходящая для GPUDirect)
|
- [Поддержка NFS RDMA](../usage/nfs.ru.md#rdma) (вероятно, также подходящая для GPUDirect)
|
||||||
|
- [S3](../installation/s3.ru.md)
|
||||||
|
|
||||||
## Драйверы и инструменты
|
## Драйверы и инструменты
|
||||||
|
|
||||||
@@ -63,7 +64,6 @@
|
|||||||
- iSCSI и NVMeoF прокси
|
- iSCSI и NVMeoF прокси
|
||||||
- Многопоточный клиент
|
- Многопоточный клиент
|
||||||
- Более быстрое переключение при отказах
|
- Более быстрое переключение при отказах
|
||||||
- S3
|
|
||||||
- Поддержка SSD-кэширования (tiered storage)
|
- Поддержка SSD-кэширования (tiered storage)
|
||||||
- Поддержка NVDIMM
|
- Поддержка NVDIMM
|
||||||
- Возможно, сжатие
|
- Возможно, сжатие
|
||||||
|
|||||||
@@ -26,13 +26,13 @@
|
|||||||
you also need small SSDs for journal and metadata (even 2 GB per 1 TB of HDD space is enough).
|
you also need small SSDs for journal and metadata (even 2 GB per 1 TB of HDD space is enough).
|
||||||
- Get a fast network (at least 10 Gbit/s). Something like Mellanox ConnectX-4 with RoCEv2 is ideal.
|
- Get a fast network (at least 10 Gbit/s). Something like Mellanox ConnectX-4 with RoCEv2 is ideal.
|
||||||
- Disable CPU powersaving: `cpupower idle-set -D 0 && cpupower frequency-set -g performance`.
|
- Disable CPU powersaving: `cpupower idle-set -D 0 && cpupower frequency-set -g performance`.
|
||||||
- [Install Vitastor packages](../installation/packages.en.md).
|
- Either [install Vitastor packages](../installation/packages.en.md) or [install Vitastor in Docker](../installation/docker.en.md).
|
||||||
|
|
||||||
## Recommended drives
|
## Recommended drives
|
||||||
|
|
||||||
- SATA SSD: Micron 5100/5200/5300/5400, Samsung PM863/PM883/PM893, Intel D3-S4510/4520/4610/4620, Kingston DC500M
|
- SATA SSD: Micron 5100/5200/5300/5400, Samsung PM863/PM883/PM893, Intel D3-S4510/4520/4610/4620, Kingston DC500M
|
||||||
- NVMe: Micron 9100/9200/9300/9400, Micron 7300/7450, Samsung PM983/PM9A3, Samsung PM1723/1735/1743,
|
- NVMe: Micron 9100/9200/9300/9400, Micron 7300/7450, Samsung PM983/PM9A3, Samsung PM1723/1735/1743,
|
||||||
Intel DC-P3700/P4500/P4600, Intel D5-P4320, Intel D7-P5500/P5600, Intel Optane, Kingston DC1000B/DC1500M
|
Intel DC-P3700/P4500/P4600, Intel D5-P4320/P5530, Intel D7-P5500/P5600, Intel Optane, Kingston DC1000B/DC1500M
|
||||||
- HDD: HGST Ultrastar, Toshiba MG, Seagate EXOS
|
- HDD: HGST Ultrastar, Toshiba MG, Seagate EXOS
|
||||||
|
|
||||||
## Configure monitors
|
## Configure monitors
|
||||||
@@ -45,7 +45,8 @@ On the monitor hosts:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
- Create systemd units for etcd by running: `/usr/lib/vitastor/mon/make-etcd`
|
- Create systemd units for etcd by running: `/usr/lib/vitastor/mon/make-etcd`
|
||||||
- Start etcd and monitors: `systemctl enable --now etcd vitastor-mon`
|
Or, if you installed Vitastor in Docker, run `systemctl start vitastor-host; docker exec vitastor make-etcd`.
|
||||||
|
- Start etcd and monitors: `systemctl enable --now vitastor-etcd vitastor-mon`
|
||||||
|
|
||||||
## Configure OSDs
|
## Configure OSDs
|
||||||
|
|
||||||
|
|||||||
@@ -26,13 +26,13 @@
|
|||||||
обязательно возьмите SSD под метаданные и журнал (маленькие, буквально 2 ГБ на 1 ТБ HDD-места).
|
обязательно возьмите SSD под метаданные и журнал (маленькие, буквально 2 ГБ на 1 ТБ HDD-места).
|
||||||
- Возьмите быструю сеть, минимум 10 гбит/с. Идеал - что-то вроде Mellanox ConnectX-4 с RoCEv2.
|
- Возьмите быструю сеть, минимум 10 гбит/с. Идеал - что-то вроде Mellanox ConnectX-4 с RoCEv2.
|
||||||
- Для лучшей производительности отключите энергосбережение CPU: `cpupower idle-set -D 0 && cpupower frequency-set -g performance`.
|
- Для лучшей производительности отключите энергосбережение CPU: `cpupower idle-set -D 0 && cpupower frequency-set -g performance`.
|
||||||
- [Установите пакеты Vitastor](../installation/packages.ru.md).
|
- Либо [установите пакеты Vitastor](../installation/packages.ru.md), либо [установите Vitastor в Docker](../installation/docker.ru.md).
|
||||||
|
|
||||||
## Рекомендуемые диски
|
## Рекомендуемые диски
|
||||||
|
|
||||||
- SATA SSD: Micron 5100/5200/5300/5400, Samsung PM863/PM883/PM893, Intel D3-S4510/4520/4610/4620, Kingston DC500M
|
- SATA SSD: Micron 5100/5200/5300/5400, Samsung PM863/PM883/PM893, Intel D3-S4510/4520/4610/4620, Kingston DC500M
|
||||||
- NVMe: Micron 9100/9200/9300/9400, Micron 7300/7450, Samsung PM983/PM9A3, Samsung PM1723/1735/1743,
|
- NVMe: Micron 9100/9200/9300/9400, Micron 7300/7450, Samsung PM983/PM9A3, Samsung PM1723/1735/1743,
|
||||||
Intel DC-P3700/P4500/P4600, Intel D5-P4320, Intel D7-P5500/P5600, Intel Optane, Kingston DC1000B/DC1500M
|
Intel DC-P3700/P4500/P4600, Intel D5-P4320/P5530, Intel D7-P5500/P5600, Intel Optane, Kingston DC1000B/DC1500M
|
||||||
- HDD: HGST Ultrastar, Toshiba MG, Seagate EXOS
|
- HDD: HGST Ultrastar, Toshiba MG, Seagate EXOS
|
||||||
|
|
||||||
## Настройте мониторы
|
## Настройте мониторы
|
||||||
@@ -44,8 +44,9 @@
|
|||||||
"etcd_address": ["10.200.1.10:2379","10.200.1.11:2379","10.200.1.12:2379"]
|
"etcd_address": ["10.200.1.10:2379","10.200.1.11:2379","10.200.1.12:2379"]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
- Инициализируйте сервисы etcd, запустив `/usr/lib/vitastor/mon/make-etcd`
|
- Инициализируйте сервисы etcd, запустив `/usr/lib/vitastor/mon/make-etcd`.\
|
||||||
- Запустите etcd и мониторы: `systemctl enable --now etcd vitastor-mon`
|
Либо, если вы установили Vitastor в Docker, запустите `systemctl start vitastor-host; docker exec vitastor make-etcd`.
|
||||||
|
- Запустите etcd и мониторы: `systemctl enable --now vitastor-etcd vitastor-mon`
|
||||||
|
|
||||||
## Настройте OSD
|
## Настройте OSD
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ It supports the following commands:
|
|||||||
Global options:
|
Global options:
|
||||||
|
|
||||||
```
|
```
|
||||||
--config_file FILE Path to Vitastor configuration file
|
--config_path FILE Path to Vitastor configuration file
|
||||||
--etcd_address URL Etcd connection address
|
--etcd_address URL Etcd connection address
|
||||||
--iodepth N Send N operations in parallel to each OSD when possible (default 32)
|
--iodepth N Send N operations in parallel to each OSD when possible (default 32)
|
||||||
--parallel_osds M Work with M osds in parallel when possible (default 4)
|
--parallel_osds M Work with M osds in parallel when possible (default 4)
|
||||||
@@ -355,7 +355,7 @@ Set OSD reweight, tags or noout flag. See detail description in [OSD config docu
|
|||||||
|
|
||||||
## pg-list
|
## pg-list
|
||||||
|
|
||||||
`vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs [OPTIONS] [state1+state2] [^state3] [...]`
|
`vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs|pgs [OPTIONS] [state1+state2] [^state3] [...]`
|
||||||
|
|
||||||
List PGs with any of listed state filters (^ or ! in the beginning is negation). Options:
|
List PGs with any of listed state filters (^ or ! in the beginning is negation). Options:
|
||||||
|
|
||||||
@@ -363,6 +363,7 @@ List PGs with any of listed state filters (^ or ! in the beginning is negation).
|
|||||||
--pool <pool name or number> Only list PGs of the given pool.
|
--pool <pool name or number> Only list PGs of the given pool.
|
||||||
--min <min pg number> Only list PGs with number >= min.
|
--min <min pg number> Only list PGs with number >= min.
|
||||||
--max <max pg number> Only list PGs with number <= max.
|
--max <max pg number> Only list PGs with number <= max.
|
||||||
|
--osd 1,2,... Only list PGs with some data on specified OSD(s).
|
||||||
```
|
```
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
@@ -398,7 +399,8 @@ Optional parameters:
|
|||||||
| `--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)) |
|
||||||
| `--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_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>` |
|
||||||
|
| `--used_for_app s3:<name>` | Mark pool as used for S3 location with name `<name>` |
|
||||||
| `--pg_stripe_size <number>` | Increase object grouping stripe |
|
| `--pg_stripe_size <number>` | Increase object grouping stripe |
|
||||||
| `--max_osd_combinations 10000` | Maximum number of random combinations for LP solver input |
|
| `--max_osd_combinations 10000` | Maximum number of random combinations for LP solver input |
|
||||||
| `--wait` | Wait for the new pool to come online |
|
| `--wait` | Wait for the new pool to come online |
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ vitastor-cli - интерфейс командной строки для адм
|
|||||||
Глобальные опции:
|
Глобальные опции:
|
||||||
|
|
||||||
```
|
```
|
||||||
--config_file FILE Путь к файлу конфигурации Vitastor
|
--config_path FILE Путь к файлу конфигурации Vitastor
|
||||||
--etcd_address URL Адрес соединения с etcd
|
--etcd_address URL Адрес соединения с etcd
|
||||||
--iodepth N Отправлять параллельно N операций на каждый OSD (по умолчанию 32)
|
--iodepth N Отправлять параллельно N операций на каждый OSD (по умолчанию 32)
|
||||||
--parallel_osds M Работать параллельно с M OSD (по умолчанию 4)
|
--parallel_osds M Работать параллельно с M OSD (по умолчанию 4)
|
||||||
@@ -375,9 +375,10 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
|
|||||||
в начале фильтра означает отрицание). Опции:
|
в начале фильтра означает отрицание). Опции:
|
||||||
|
|
||||||
```
|
```
|
||||||
--pool <pool name or number> Only list PGs of the given pool.
|
--pool <pool name or number> Вывести только PG в заданном пуле.
|
||||||
--min <min pg number> Only list PGs with number >= min.
|
--min <min pg number> Вывести только PG с номерами >= min.
|
||||||
--max <max pg number> Only list PGs with number <= max.
|
--max <max pg number> Вывести только PG с номерами <= max.
|
||||||
|
--osd 1,2,... Вывести только PG с данными на заданных OSD.
|
||||||
```
|
```
|
||||||
|
|
||||||
Примеры:
|
Примеры:
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ It supports the following commands:
|
|||||||
- [upgrade-simple](#upgrade-simple)
|
- [upgrade-simple](#upgrade-simple)
|
||||||
- [resize](#resize)
|
- [resize](#resize)
|
||||||
- [raw-resize](#raw-resize)
|
- [raw-resize](#raw-resize)
|
||||||
|
- [trim](#trim)
|
||||||
- [start/stop/restart/enable/disable](#start/stop/restart/enable/disable)
|
- [start/stop/restart/enable/disable](#start/stop/restart/enable/disable)
|
||||||
- [purge](#purge)
|
- [purge](#purge)
|
||||||
- [read-sb](#read-sb)
|
- [read-sb](#read-sb)
|
||||||
@@ -97,6 +98,9 @@ Options (both modes):
|
|||||||
--data_device_block 4k Override data device block size
|
--data_device_block 4k Override data device block size
|
||||||
--meta_device_block 4k Override metadata device block size
|
--meta_device_block 4k Override metadata device block size
|
||||||
--journal_device_block 4k Override journal device block size
|
--journal_device_block 4k Override journal device block size
|
||||||
|
--discard_on_start 0 TRIM unused data device blocks every OSD start (default off)
|
||||||
|
--min_discard_size 1M Minimum TRIM block size
|
||||||
|
--json Enable JSON output
|
||||||
```
|
```
|
||||||
|
|
||||||
[immediate_commit](../config/layout-cluster.en.md#immediate_commit) setting is
|
[immediate_commit](../config/layout-cluster.en.md#immediate_commit) setting is
|
||||||
@@ -179,6 +183,19 @@ parameters from OSD command line (i.e. from systemd unit or superblock).
|
|||||||
SIZE may include k/m/g/t suffixes. If any of the new layout parameter
|
SIZE may include k/m/g/t suffixes. If any of the new layout parameter
|
||||||
options are not specified, old values will be used.
|
options are not specified, old values will be used.
|
||||||
|
|
||||||
|
## trim
|
||||||
|
|
||||||
|
`vitastor-disk trim <osd_num>|<osd_device> [<osd_num>|<osd_device>...]`
|
||||||
|
|
||||||
|
Try to discard unused blocks (SSD TRIM) on the data device of each of the OSD(s).
|
||||||
|
|
||||||
|
May only be used on stopped OSDs. Options:
|
||||||
|
|
||||||
|
```
|
||||||
|
--min_discard_size 1M Minimum TRIM block size
|
||||||
|
--discard_granularity 0 Override device's discard granularity
|
||||||
|
```
|
||||||
|
|
||||||
## start/stop/restart/enable/disable
|
## start/stop/restart/enable/disable
|
||||||
|
|
||||||
`vitastor-disk start|stop|restart|enable|disable [--now] <device> [device2 device3 ...]`
|
`vitastor-disk start|stop|restart|enable|disable [--now] <device> [device2 device3 ...]`
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ vitastor-disk - инструмент командной строки для уп
|
|||||||
--data_device_block 4k Задать размер блока устройства данных
|
--data_device_block 4k Задать размер блока устройства данных
|
||||||
--meta_device_block 4k Задать размер блока метаданных
|
--meta_device_block 4k Задать размер блока метаданных
|
||||||
--journal_device_block 4k Задать размер блока журнала
|
--journal_device_block 4k Задать размер блока журнала
|
||||||
|
--discard_on_start 0 Выполнять TRIM пустых блоков данных при запуске OSD (по умолчанию нет)
|
||||||
|
--min_discard_size 1M Минимальный размер блока для TRIM
|
||||||
|
--json Включить JSON-вывод
|
||||||
```
|
```
|
||||||
|
|
||||||
Настройка [immediate_commit](../config/layout-cluster.ru.md#immediate_commit)
|
Настройка [immediate_commit](../config/layout-cluster.ru.md#immediate_commit)
|
||||||
@@ -182,6 +185,20 @@ throttle_target_mbs, throttle_target_parallelism, throttle_threshold_us.
|
|||||||
`РАЗМЕР` может быть указан с суффиксами k/m/g/t. Если любой из новых параметров
|
`РАЗМЕР` может быть указан с суффиксами k/m/g/t. Если любой из новых параметров
|
||||||
расположения не указан, он принимается равным старому значению.
|
расположения не указан, он принимается равным старому значению.
|
||||||
|
|
||||||
|
## trim
|
||||||
|
|
||||||
|
`vitastor-disk trim <osd_num>|<osd_device> [<osd_num>|<osd_device>...]`
|
||||||
|
|
||||||
|
Попробовать пометить пустые блоки дисков данных всех указанных OSD неиспользуемыми
|
||||||
|
(выполнить команду SSD TRIM).
|
||||||
|
|
||||||
|
Можно использовать только с остановленными OSD. Опции:
|
||||||
|
|
||||||
|
```
|
||||||
|
--min_discard_size 1M Минимальный размер блока для TRIM
|
||||||
|
--discard_granularity 0 Кратность размера блока для TRIM
|
||||||
|
```
|
||||||
|
|
||||||
## start/stop/restart/enable/disable
|
## start/stop/restart/enable/disable
|
||||||
|
|
||||||
`vitastor-disk start|stop|restart|enable|disable [--now] <device> [device2 device3 ...]`
|
`vitastor-disk start|stop|restart|enable|disable [--now] <device> [device2 device3 ...]`
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ It will output a block device name like /dev/nbd0 which you can then use as a no
|
|||||||
|
|
||||||
You can also use `--pool <POOL> --inode <INODE> --size <SIZE>` instead of `--image <IMAGE>` if you want.
|
You can also use `--pool <POOL> --inode <INODE> --size <SIZE>` instead of `--image <IMAGE>` if you want.
|
||||||
|
|
||||||
vitastor-nbd supports all usual Vitastor configuration options like `--config_file <path_to_config>` plus NBD-specific:
|
vitastor-nbd supports all usual Vitastor configuration options like `--config_path <path_to_config>` plus NBD-specific:
|
||||||
|
|
||||||
* `--nbd_timeout 0` \
|
* `--nbd_timeout 0` \
|
||||||
Timeout for I/O operations in seconds after exceeding which the kernel stops the device.
|
Timeout for I/O operations in seconds after exceeding which the kernel stops the device.
|
||||||
@@ -54,16 +54,18 @@ vitastor-nbd supports all usual Vitastor configuration options like `--config_fi
|
|||||||
Stay in foreground, do not daemonize.
|
Stay in foreground, do not daemonize.
|
||||||
|
|
||||||
Note that `nbd_timeout`, `nbd_max_devices` and `nbd_max_part` options may also be specified
|
Note that `nbd_timeout`, `nbd_max_devices` and `nbd_max_part` options may also be specified
|
||||||
in `/etc/vitastor/vitastor.conf` or in other configuration file specified with `--config_file`.
|
in `/etc/vitastor/vitastor.conf` or in other configuration file specified with `--config_path`.
|
||||||
|
|
||||||
## unmap
|
## unmap
|
||||||
|
|
||||||
To unmap the device run:
|
To unmap the device run:
|
||||||
|
|
||||||
```
|
```
|
||||||
vitastor-nbd unmap /dev/nbd0
|
vitastor-nbd unmap [--force] /dev/nbd0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If `--force` is specified, `vitastor-nbd` doesn't check if the device is actually mapped.
|
||||||
|
|
||||||
## ls
|
## ls
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ vitastor-nbd map [/dev/nbdN] --image testimg
|
|||||||
Для обращения по номеру инода, аналогично другим командам, можно использовать опции
|
Для обращения по номеру инода, аналогично другим командам, можно использовать опции
|
||||||
`--pool <POOL> --inode <INODE> --size <SIZE>` вместо `--image testimg`.
|
`--pool <POOL> --inode <INODE> --size <SIZE>` вместо `--image testimg`.
|
||||||
|
|
||||||
vitastor-nbd поддерживает все обычные опции Vitastor, например, `--config_file <path_to_config>`,
|
vitastor-nbd поддерживает все обычные опции Vitastor, например, `--config_path <path_to_config>`,
|
||||||
плюс специфичные для NBD:
|
плюс специфичные для NBD:
|
||||||
|
|
||||||
* `--nbd_timeout 0` \
|
* `--nbd_timeout 0` \
|
||||||
@@ -62,16 +62,19 @@ vitastor-nbd поддерживает все обычные опции Vitastor,
|
|||||||
|
|
||||||
Обратите внимание, что опции `nbd_timeout`, `nbd_max_devices` и `nbd_max_part` можно
|
Обратите внимание, что опции `nbd_timeout`, `nbd_max_devices` и `nbd_max_part` можно
|
||||||
также задавать в `/etc/vitastor/vitastor.conf` или в другом файле конфигурации,
|
также задавать в `/etc/vitastor/vitastor.conf` или в другом файле конфигурации,
|
||||||
заданном опцией `--config_file`.
|
заданном опцией `--config_path`.
|
||||||
|
|
||||||
## unmap
|
## unmap
|
||||||
|
|
||||||
Для отключения устройства выполните:
|
Для отключения устройства выполните:
|
||||||
|
|
||||||
```
|
```
|
||||||
vitastor-nbd unmap /dev/nbd0
|
vitastor-nbd unmap [--force] /dev/nbd0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Если задана опция `--force`, `vitastor-nbd` не проверяет, подключено ли устройство,
|
||||||
|
перед попыткой его отключить.
|
||||||
|
|
||||||
## ls
|
## ls
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ To use VitastorFS:
|
|||||||
2. Create an image for FS metadata, preferably in a faster (SSD or replica-HDD) pool,
|
2. Create an image for FS metadata, preferably in a faster (SSD or replica-HDD) pool,
|
||||||
but you can create it in the data pool too if you want (image size doesn't matter):
|
but you can create it in the data pool too if you want (image size doesn't matter):
|
||||||
`vitastor-cli create -s 10G -p fastpool testfs`
|
`vitastor-cli create -s 10G -p fastpool testfs`
|
||||||
3. Mark data pool as an FS pool: `vitastor-cli modify-pool --used-for-fs testfs data-pool`
|
3. Mark data pool as an FS pool: `vitastor-cli modify-pool --used-for-app fs:testfs data-pool`
|
||||||
4. Either mount the FS: `vitastor-nfs mount --fs testfs --pool data-pool /mnt/vita`
|
4. Either mount the FS: `vitastor-nfs mount --fs testfs --pool data-pool /mnt/vita`
|
||||||
5. Or start the NFS server: `vitastor-nfs start --fs testfs --pool data-pool`
|
5. Or start the NFS server: `vitastor-nfs start --fs testfs --pool data-pool`
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ JSON-формате :-). Для инспекции содержимого БД
|
|||||||
или по крайней мере на HDD, но без EC), но можно и в том же пуле, что данные
|
или по крайней мере на HDD, но без EC), но можно и в том же пуле, что данные
|
||||||
(размер образа значения не имеет):
|
(размер образа значения не имеет):
|
||||||
`vitastor-cli create -s 10G -p fastpool testfs`
|
`vitastor-cli create -s 10G -p fastpool testfs`
|
||||||
3. Пометьте пул данных как ФС-пул: `vitastor-cli modify-pool --used-for-fs testfs data-pool`
|
3. Пометьте пул данных как ФС-пул: `vitastor-cli modify-pool --used-for-app fs:testfs data-pool`
|
||||||
4. Либо примонтируйте ФС: `vitastor-nfs mount --fs testfs --pool data-pool /mnt/vita`
|
4. Либо примонтируйте ФС: `vitastor-nfs mount --fs testfs --pool data-pool /mnt/vita`
|
||||||
5. Либо запустите сетевой NFS-сервер: `vitastor-nfs start --fs testfs --pool data-pool`
|
5. Либо запустите сетевой NFS-сервер: `vitastor-nfs start --fs testfs --pool data-pool`
|
||||||
|
|
||||||
|
|||||||
+19
-15
@@ -773,23 +773,27 @@ class Mon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const pool_id in this.state.pool.stats)
|
if (!this.recheck_pgs_active)
|
||||||
{
|
{
|
||||||
if (!seen_pools[pool_id])
|
// PG recheck also modifies /pool/stats, so don't touch it here if it's active
|
||||||
|
for (const pool_id in this.state.pool.stats)
|
||||||
{
|
{
|
||||||
txn.push({ requestDeleteRange: {
|
if (!seen_pools[pool_id])
|
||||||
key: b64(this.config.etcd_prefix+'/pool/stats/'+pool_id),
|
{
|
||||||
} });
|
txn.push({ requestDeleteRange: {
|
||||||
delete this.state.pool.stats[pool_id];
|
key: b64(this.config.etcd_prefix+'/pool/stats/'+pool_id),
|
||||||
}
|
} });
|
||||||
else
|
delete this.state.pool.stats[pool_id];
|
||||||
{
|
}
|
||||||
const pool_stats = { ...this.state.pool.stats[pool_id] };
|
else
|
||||||
serialize_bigints(pool_stats);
|
{
|
||||||
txn.push({ requestPut: {
|
const pool_stats = { ...this.state.pool.stats[pool_id] };
|
||||||
key: b64(this.config.etcd_prefix+'/pool/stats/'+pool_id),
|
serialize_bigints(pool_stats);
|
||||||
value: b64(JSON.stringify(pool_stats)),
|
txn.push({ requestPut: {
|
||||||
} });
|
key: b64(this.config.etcd_prefix+'/pool/stats/'+pool_id),
|
||||||
|
value: b64(JSON.stringify(pool_stats)),
|
||||||
|
} });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (txn.length)
|
if (txn.length)
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vitastor-mon",
|
"name": "vitastor-mon",
|
||||||
"version": "1.10.1",
|
"version": "2.0.0",
|
||||||
"description": "Vitastor SDS monitor service",
|
"description": "Vitastor SDS monitor service",
|
||||||
"main": "mon-main.js",
|
"main": "mon-main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
"author": "Vitaliy Filippov",
|
"author": "Vitaliy Filippov",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"antietcd": "^1.1.0",
|
"antietcd": "^1.1.2",
|
||||||
"sprintf-js": "^1.1.2",
|
"sprintf-js": "^1.1.2",
|
||||||
"ws": "^7.2.5"
|
"ws": "^7.2.5"
|
||||||
},
|
},
|
||||||
|
|||||||
+5
-21
@@ -8,23 +8,9 @@ const LPOptimizer = require('./lp_optimizer/lp_optimizer.js');
|
|||||||
const { scale_pg_count } = require('./pg_utils.js');
|
const { scale_pg_count } = require('./pg_utils.js');
|
||||||
const { make_hier_tree, filter_osds_by_root_node,
|
const { make_hier_tree, filter_osds_by_root_node,
|
||||||
filter_osds_by_tags, filter_osds_by_block_layout, get_affinity_osds } = require('./osd_tree.js');
|
filter_osds_by_tags, filter_osds_by_block_layout, get_affinity_osds } = require('./osd_tree.js');
|
||||||
|
const { select_murmur3 } = require('./lp_optimizer/murmur3.js');
|
||||||
|
|
||||||
let seed;
|
function pick_primary(pool_id, pg_num, pool_config, osd_set, up_osds, aff_osds)
|
||||||
|
|
||||||
function reset_rng()
|
|
||||||
{
|
|
||||||
seed = 0x5f020e43;
|
|
||||||
}
|
|
||||||
|
|
||||||
function rng()
|
|
||||||
{
|
|
||||||
seed ^= seed << 13;
|
|
||||||
seed ^= seed >> 17;
|
|
||||||
seed ^= seed << 5;
|
|
||||||
return seed + 2147483648;
|
|
||||||
}
|
|
||||||
|
|
||||||
function pick_primary(pool_config, osd_set, up_osds, aff_osds)
|
|
||||||
{
|
{
|
||||||
let alive_set;
|
let alive_set;
|
||||||
if (pool_config.scheme === 'replicated')
|
if (pool_config.scheme === 'replicated')
|
||||||
@@ -52,7 +38,7 @@ function pick_primary(pool_config, osd_set, up_osds, aff_osds)
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return alive_set[rng() % alive_set.length];
|
return alive_set[select_murmur3(alive_set.length, osd_num => pool_id+'/'+pg_num+'/'+osd_num)];
|
||||||
}
|
}
|
||||||
|
|
||||||
function recheck_primary(state, global_config, up_osds, osd_tree)
|
function recheck_primary(state, global_config, up_osds, osd_tree)
|
||||||
@@ -66,7 +52,6 @@ function recheck_primary(state, global_config, up_osds, osd_tree)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const aff_osds = get_affinity_osds(pool_cfg, up_osds, osd_tree);
|
const aff_osds = get_affinity_osds(pool_cfg, up_osds, osd_tree);
|
||||||
reset_rng();
|
|
||||||
for (let pg_num = 1; pg_num <= pool_cfg.pg_count; pg_num++)
|
for (let pg_num = 1; pg_num <= pool_cfg.pg_count; pg_num++)
|
||||||
{
|
{
|
||||||
if (!state.pg.config.items[pool_id])
|
if (!state.pg.config.items[pool_id])
|
||||||
@@ -76,7 +61,7 @@ function recheck_primary(state, global_config, up_osds, osd_tree)
|
|||||||
const pg_cfg = state.pg.config.items[pool_id][pg_num];
|
const pg_cfg = state.pg.config.items[pool_id][pg_num];
|
||||||
if (pg_cfg)
|
if (pg_cfg)
|
||||||
{
|
{
|
||||||
const new_primary = pick_primary(state.config.pools[pool_id], pg_cfg.osd_set, up_osds, aff_osds);
|
const new_primary = pick_primary(pool_id, pg_num, state.config.pools[pool_id], pg_cfg.osd_set, up_osds, aff_osds);
|
||||||
if (pg_cfg.primary != new_primary)
|
if (pg_cfg.primary != new_primary)
|
||||||
{
|
{
|
||||||
if (!new_pg_config)
|
if (!new_pg_config)
|
||||||
@@ -99,13 +84,12 @@ function save_new_pgs_txn(save_to, request, state, etcd_prefix, etcd_watch_revis
|
|||||||
{
|
{
|
||||||
const aff_osds = get_affinity_osds(state.config.pools[pool_id] || {}, up_osds, osd_tree);
|
const aff_osds = get_affinity_osds(state.config.pools[pool_id] || {}, up_osds, osd_tree);
|
||||||
const pg_items = {};
|
const pg_items = {};
|
||||||
reset_rng();
|
|
||||||
new_pgs.map((osd_set, i) =>
|
new_pgs.map((osd_set, i) =>
|
||||||
{
|
{
|
||||||
osd_set = osd_set.map(osd_num => osd_num === LPOptimizer.NO_OSD ? 0 : osd_num);
|
osd_set = osd_set.map(osd_num => osd_num === LPOptimizer.NO_OSD ? 0 : osd_num);
|
||||||
pg_items[i+1] = {
|
pg_items[i+1] = {
|
||||||
osd_set,
|
osd_set,
|
||||||
primary: pick_primary(state.config.pools[pool_id], osd_set, up_osds, aff_osds),
|
primary: pick_primary(pool_id, i+1, state.config.pools[pool_id], osd_set, up_osds, aff_osds),
|
||||||
};
|
};
|
||||||
if (prev_pgs[i] && prev_pgs[i].join(' ') != osd_set.join(' ') &&
|
if (prev_pgs[i] && prev_pgs[i].join(' ') != osd_set.join(' ') &&
|
||||||
prev_pgs[i].filter(osd_num => osd_num).length > 0)
|
prev_pgs[i].filter(osd_num => osd_num).length > 0)
|
||||||
|
|||||||
+28
-8
@@ -33,9 +33,11 @@ async function run()
|
|||||||
console.log(config_path+' is missing');
|
console.log(config_path+' is missing');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
if (fs.existsSync("/etc/systemd/system/etcd.service"))
|
const in_docker = fs.existsSync("/etc/vitastor/etcd.conf") &&
|
||||||
|
fs.existsSync("/etc/vitastor/docker.conf");
|
||||||
|
if (!in_docker && fs.existsSync("/etc/systemd/system/vitastor-etcd.service"))
|
||||||
{
|
{
|
||||||
console.log("/etc/systemd/system/etcd.service already exists");
|
console.log("/etc/systemd/system/vitastor-etcd.service already exists");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const config = JSON.parse(fs.readFileSync(config_path, { encoding: 'utf-8' }));
|
const config = JSON.parse(fs.readFileSync(config_path, { encoding: 'utf-8' }));
|
||||||
@@ -52,10 +54,21 @@ async function run()
|
|||||||
console.log('No matching IPs in etcd_address from '+config_path);
|
console.log('No matching IPs in etcd_address from '+config_path);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
const etcd_cluster = etcds.map((e, i) => `etcd${i}=http://${e}:2380`).join(',');
|
const etcd_name = 'etcd'+etcds[num].replace(/[^0-9a-z_]/ig, '_');
|
||||||
await system(`mkdir -p /var/lib/etcd${num}.etcd`);
|
const etcd_cluster = etcds.map(e => `etcd${e.replace(/[^0-9a-z_]/ig, '_')}=http://${e}:2380`).join(',');
|
||||||
|
if (in_docker)
|
||||||
|
{
|
||||||
|
let etcd_conf = fs.readFileSync("/etc/vitastor/etcd.conf", { encoding: 'utf-8' });
|
||||||
|
etcd_conf = replace_env(etcd_conf, 'ETCD_NAME', etcd_name);
|
||||||
|
etcd_conf = replace_env(etcd_conf, 'ETCD_IP', etcds[num]);
|
||||||
|
etcd_conf = replace_env(etcd_conf, 'ETCD_INITIAL_CLUSTER', etcd_cluster);
|
||||||
|
fs.writeFileSync("/etc/vitastor/etcd.conf", etcd_conf);
|
||||||
|
console.log('etcd for Vitastor configured. Run `systemctl enable --now vitastor-etcd` to start etcd');
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
await system(`mkdir -p /var/lib/etcd`);
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
"/etc/systemd/system/etcd.service",
|
"/etc/systemd/system/vitastor-etcd.service",
|
||||||
`[Unit]
|
`[Unit]
|
||||||
Description=etcd for vitastor
|
Description=etcd for vitastor
|
||||||
After=network-online.target local-fs.target time-sync.target
|
After=network-online.target local-fs.target time-sync.target
|
||||||
@@ -64,14 +77,14 @@ Wants=network-online.target local-fs.target time-sync.target
|
|||||||
[Service]
|
[Service]
|
||||||
Restart=always
|
Restart=always
|
||||||
Environment=GOGC=50
|
Environment=GOGC=50
|
||||||
ExecStart=etcd -name etcd${num} --data-dir /var/lib/etcd${num}.etcd \\
|
ExecStart=etcd --name ${etcd_name} --data-dir /var/lib/etcd \\
|
||||||
--snapshot-count 10000 --advertise-client-urls http://${etcds[num]}:2379 --listen-client-urls http://${etcds[num]}:2379 \\
|
--snapshot-count 10000 --advertise-client-urls http://${etcds[num]}:2379 --listen-client-urls http://${etcds[num]}:2379 \\
|
||||||
--initial-advertise-peer-urls http://${etcds[num]}:2380 --listen-peer-urls http://${etcds[num]}:2380 \\
|
--initial-advertise-peer-urls http://${etcds[num]}:2380 --listen-peer-urls http://${etcds[num]}:2380 \\
|
||||||
--initial-cluster-token vitastor-etcd-1 --initial-cluster ${etcd_cluster} \\
|
--initial-cluster-token vitastor-etcd-1 --initial-cluster ${etcd_cluster} \\
|
||||||
--initial-cluster-state new --max-txn-ops=100000 --max-request-bytes=104857600 \\
|
--initial-cluster-state new --max-txn-ops=100000 --max-request-bytes=104857600 \\
|
||||||
--auto-compaction-retention=10 --auto-compaction-mode=revision
|
--auto-compaction-retention=10 --auto-compaction-mode=revision
|
||||||
WorkingDirectory=/var/lib/etcd${num}.etcd
|
WorkingDirectory=/var/lib/etcd
|
||||||
ExecStartPre=+chown -R etcd /var/lib/etcd${num}.etcd
|
ExecStartPre=+chown -R etcd /var/lib/etcd
|
||||||
User=etcd
|
User=etcd
|
||||||
PrivateTmp=false
|
PrivateTmp=false
|
||||||
TasksMax=infinity
|
TasksMax=infinity
|
||||||
@@ -89,6 +102,13 @@ WantedBy=multi-user.target
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replace_env(text, key, value)
|
||||||
|
{
|
||||||
|
let found = false;
|
||||||
|
text = text.replace(new RegExp('^'+key+'\\s*=.*', 'm'), () => { found = true; return key+'='+value; });
|
||||||
|
return found ? text : text.replace(/\s*$/, '\n')+key+'='+value+'\n';
|
||||||
|
}
|
||||||
|
|
||||||
function select_local_etcd(etcds)
|
function select_local_etcd(etcds)
|
||||||
{
|
{
|
||||||
const ifaces = os.networkInterfaces();
|
const ifaces = os.networkInterfaces();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Wants=network-online.target local-fs.target time-sync.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Restart=always
|
Restart=always
|
||||||
|
SyslogIdentifier=vitastor-mon
|
||||||
ExecStart=node /usr/lib/vitastor/mon/mon-main.js
|
ExecStart=node /usr/lib/vitastor/mon/mon-main.js
|
||||||
WorkingDirectory=/
|
WorkingDirectory=/
|
||||||
User=vitastor
|
User=vitastor
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ PartOf=vitastor.target
|
|||||||
LimitNOFILE=1048576
|
LimitNOFILE=1048576
|
||||||
LimitNPROC=1048576
|
LimitNPROC=1048576
|
||||||
LimitMEMLOCK=infinity
|
LimitMEMLOCK=infinity
|
||||||
|
SyslogIdentifier=vitastor-osd%i
|
||||||
# Use the following for direct logs to files
|
# Use the following for direct logs to files
|
||||||
#ExecStart=bash -c 'exec vitastor-disk exec-osd /dev/vitastor/osd%i-data >>/var/log/vitastor/osd%i.log 2>&1'
|
#ExecStart=bash -c 'exec vitastor-disk exec-osd /dev/vitastor/osd%i-data >>/var/log/vitastor/osd%i.log 2>&1'
|
||||||
ExecStart=vitastor-disk exec-osd /dev/vitastor/osd%i-data
|
ExecStart=vitastor-disk exec-osd /dev/vitastor/osd%i-data
|
||||||
|
|||||||
@@ -14,8 +14,13 @@ NAN_MODULE_INIT(InitAddon)
|
|||||||
|
|
||||||
Nan::SetPrototypeMethod(tpl, "read", NodeVitastor::Read);
|
Nan::SetPrototypeMethod(tpl, "read", NodeVitastor::Read);
|
||||||
Nan::SetPrototypeMethod(tpl, "write", NodeVitastor::Write);
|
Nan::SetPrototypeMethod(tpl, "write", NodeVitastor::Write);
|
||||||
|
Nan::SetPrototypeMethod(tpl, "delete", NodeVitastor::Delete);
|
||||||
Nan::SetPrototypeMethod(tpl, "sync", NodeVitastor::Sync);
|
Nan::SetPrototypeMethod(tpl, "sync", NodeVitastor::Sync);
|
||||||
Nan::SetPrototypeMethod(tpl, "read_bitmap", NodeVitastor::ReadBitmap);
|
Nan::SetPrototypeMethod(tpl, "read_bitmap", NodeVitastor::ReadBitmap);
|
||||||
|
Nan::SetPrototypeMethod(tpl, "on_ready", NodeVitastor::OnReady);
|
||||||
|
Nan::SetPrototypeMethod(tpl, "get_min_io_size", NodeVitastor::GetMinIoSize);
|
||||||
|
Nan::SetPrototypeMethod(tpl, "get_max_atomic_write_size", NodeVitastor::GetMaxAtomicWriteSize);
|
||||||
|
Nan::SetPrototypeMethod(tpl, "get_immediate_commit", NodeVitastor::GetImmediateCommit);
|
||||||
//Nan::SetPrototypeMethod(tpl, "destroy", NodeVitastor::Destroy);
|
//Nan::SetPrototypeMethod(tpl, "destroy", NodeVitastor::Destroy);
|
||||||
|
|
||||||
Nan::Set(target, Nan::New("Client").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
|
Nan::Set(target, Nan::New("Client").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
|
||||||
@@ -63,6 +68,10 @@ NAN_MODULE_INIT(InitAddon)
|
|||||||
Nan::Set(target, Nan::New("ENOSYS").ToLocalChecked(), Nan::New<v8::Int32>(-ENOSYS));
|
Nan::Set(target, Nan::New("ENOSYS").ToLocalChecked(), Nan::New<v8::Int32>(-ENOSYS));
|
||||||
Nan::Set(target, Nan::New("EAGAIN").ToLocalChecked(), Nan::New<v8::Int32>(-EAGAIN));
|
Nan::Set(target, Nan::New("EAGAIN").ToLocalChecked(), Nan::New<v8::Int32>(-EAGAIN));
|
||||||
|
|
||||||
|
Nan::Set(target, Nan::New("IMMEDIATE_NONE").ToLocalChecked(), Nan::New<v8::Int32>(IMMEDIATE_NONE));
|
||||||
|
Nan::Set(target, Nan::New("IMMEDIATE_SMALL").ToLocalChecked(), Nan::New<v8::Int32>(IMMEDIATE_SMALL));
|
||||||
|
Nan::Set(target, Nan::New("IMMEDIATE_ALL").ToLocalChecked(), Nan::New<v8::Int32>(IMMEDIATE_ALL));
|
||||||
|
|
||||||
// Listing handle
|
// Listing handle
|
||||||
|
|
||||||
tpl = Nan::New<v8::FunctionTemplate>(NodeVitastorKVListing::Create);
|
tpl = Nan::New<v8::FunctionTemplate>(NodeVitastorKVListing::Create);
|
||||||
|
|||||||
+223
-45
@@ -5,9 +5,10 @@
|
|||||||
|
|
||||||
#define NODE_VITASTOR_READ 1
|
#define NODE_VITASTOR_READ 1
|
||||||
#define NODE_VITASTOR_WRITE 2
|
#define NODE_VITASTOR_WRITE 2
|
||||||
#define NODE_VITASTOR_SYNC 3
|
#define NODE_VITASTOR_DELETE 3
|
||||||
#define NODE_VITASTOR_READ_BITMAP 4
|
#define NODE_VITASTOR_SYNC 4
|
||||||
#define NODE_VITASTOR_GET_INFO 5
|
#define NODE_VITASTOR_READ_BITMAP 5
|
||||||
|
#define NODE_VITASTOR_GET_INFO 6
|
||||||
|
|
||||||
#ifndef INODE_POOL
|
#ifndef INODE_POOL
|
||||||
#define INODE_POOL(inode) (uint32_t)((inode) >> (64 - POOL_ID_BITS))
|
#define INODE_POOL(inode) (uint32_t)((inode) >> (64 - POOL_ID_BITS))
|
||||||
@@ -18,11 +19,16 @@
|
|||||||
class NodeVitastorRequest: public Nan::AsyncResource
|
class NodeVitastorRequest: public Nan::AsyncResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NodeVitastorRequest(NodeVitastor *cli, v8::Local<v8::Function> cb): Nan::AsyncResource("NodeVitastorRequest")
|
NodeVitastorRequest(NodeVitastor *cli, const v8::Local<v8::Function> & cb): Nan::AsyncResource("NodeVitastorRequest")
|
||||||
{
|
{
|
||||||
this->cli = cli;
|
this->cli = cli;
|
||||||
callback.Reset(cb);
|
callback.Reset(cb);
|
||||||
}
|
}
|
||||||
|
~NodeVitastorRequest()
|
||||||
|
{
|
||||||
|
callback.Reset();
|
||||||
|
buffer_ref.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
iovec iov;
|
iovec iov;
|
||||||
std::vector<iovec> iov_list;
|
std::vector<iovec> iov_list;
|
||||||
@@ -32,6 +38,7 @@ public:
|
|||||||
uint64_t offset = 0, len = 0, version = 0;
|
uint64_t offset = 0, len = 0, version = 0;
|
||||||
bool with_parents = false;
|
bool with_parents = false;
|
||||||
Nan::Persistent<v8::Function> callback;
|
Nan::Persistent<v8::Function> callback;
|
||||||
|
Nan::Persistent<v8::Value> buffer_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint64_t get_ui64(const v8::Local<v8::Value> & val)
|
static uint64_t get_ui64(const v8::Local<v8::Value> & val)
|
||||||
@@ -80,6 +87,11 @@ NAN_METHOD(NodeVitastor::Create)
|
|||||||
NodeVitastor* cli = new NodeVitastor();
|
NodeVitastor* cli = new NodeVitastor();
|
||||||
cli->c = vitastor_c_create_uring_json(c_cfg, cfg.size());
|
cli->c = vitastor_c_create_uring_json(c_cfg, cfg.size());
|
||||||
delete[] c_cfg;
|
delete[] c_cfg;
|
||||||
|
if (!cli->c)
|
||||||
|
{
|
||||||
|
Nan::ThrowError("failed to initialize io_uring (old kernel or insufficient ulimit -l?)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int res = vitastor_c_uring_register_eventfd(cli->c);
|
int res = vitastor_c_uring_register_eventfd(cli->c);
|
||||||
if (res >= 0)
|
if (res >= 0)
|
||||||
@@ -123,8 +135,8 @@ NodeVitastorRequest* NodeVitastor::get_read_request(const Nan::FunctionCallbackI
|
|||||||
Nan::ThrowError("failed to allocate memory");
|
Nan::ThrowError("failed to allocate memory");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
v8::Local<v8::Function> callback = info[argpos+2].As<v8::Function>();
|
|
||||||
auto req = new NodeVitastorRequest(this, callback);
|
auto req = new NodeVitastorRequest(this, info[argpos+2].As<v8::Function>());
|
||||||
|
|
||||||
req->offset = offset;
|
req->offset = offset;
|
||||||
req->len = len;
|
req->len = len;
|
||||||
@@ -133,12 +145,12 @@ NodeVitastorRequest* NodeVitastor::get_read_request(const Nan::FunctionCallbackI
|
|||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read(pool, inode, offset, len, callback(err, buffer, version))
|
// read(pool, inode, offset, length, callback(err, buffer, version))
|
||||||
NAN_METHOD(NodeVitastor::Read)
|
NAN_METHOD(NodeVitastor::Read)
|
||||||
{
|
{
|
||||||
TRACE("NodeVitastor::Read");
|
TRACE("NodeVitastor::Read");
|
||||||
if (info.Length() < 5)
|
if (info.Length() < 5)
|
||||||
Nan::ThrowError("Not enough arguments to read(pool, inode, offset, len, callback(err, buffer, version))");
|
Nan::ThrowError("Not enough arguments to read(pool, inode, offset, length, callback(err, buffer, version))");
|
||||||
|
|
||||||
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
||||||
|
|
||||||
@@ -149,6 +161,9 @@ NAN_METHOD(NodeVitastor::Read)
|
|||||||
|
|
||||||
self->Ref();
|
self->Ref();
|
||||||
vitastor_c_read(self->c, ((pool << (64-POOL_ID_BITS)) | inode), req->offset, req->len, &req->iov, 1, on_read_finish, req);
|
vitastor_c_read(self->c, ((pool << (64-POOL_ID_BITS)) | inode), req->offset, req->len, &req->iov, 1, on_read_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(self->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeVitastorRequest* NodeVitastor::get_write_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos)
|
NodeVitastorRequest* NodeVitastor::get_write_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos)
|
||||||
@@ -168,11 +183,11 @@ NodeVitastorRequest* NodeVitastor::get_write_request(const Nan::FunctionCallback
|
|||||||
argpos++;
|
argpos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Function> callback = info[argpos+2].As<v8::Function>();
|
auto req = new NodeVitastorRequest(this, info[argpos+2].As<v8::Function>());
|
||||||
auto req = new NodeVitastorRequest(this, callback);
|
|
||||||
|
|
||||||
req->offset = offset;
|
req->offset = offset;
|
||||||
req->version = version;
|
req->version = version;
|
||||||
|
req->buffer_ref.Reset(bufarg);
|
||||||
|
|
||||||
if (bufarg->IsArray())
|
if (bufarg->IsArray())
|
||||||
{
|
{
|
||||||
@@ -217,6 +232,57 @@ NAN_METHOD(NodeVitastor::Write)
|
|||||||
req->iov_list.size() ? req->iov_list.data() : &req->iov,
|
req->iov_list.size() ? req->iov_list.data() : &req->iov,
|
||||||
req->iov_list.size() ? req->iov_list.size() : 1,
|
req->iov_list.size() ? req->iov_list.size() : 1,
|
||||||
on_write_finish, req);
|
on_write_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(self->c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeVitastorRequest* NodeVitastor::get_delete_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos)
|
||||||
|
{
|
||||||
|
uint64_t offset = get_ui64(info[argpos+0]);
|
||||||
|
uint64_t len = get_ui64(info[argpos+1]);
|
||||||
|
uint64_t version = 0;
|
||||||
|
if (!info[argpos+2].IsEmpty() &&
|
||||||
|
!info[argpos+2]->IsFunction() &&
|
||||||
|
info[argpos+2]->IsObject())
|
||||||
|
{
|
||||||
|
auto key = Nan::New<v8::String>("version").ToLocalChecked();
|
||||||
|
auto params = info[argpos+2].As<v8::Object>();
|
||||||
|
auto versionObj = Nan::Get(params, key).ToLocalChecked();
|
||||||
|
if (!versionObj.IsEmpty())
|
||||||
|
version = get_ui64(versionObj);
|
||||||
|
argpos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto req = new NodeVitastorRequest(this, info[argpos+2].As<v8::Function>());
|
||||||
|
|
||||||
|
req->offset = offset;
|
||||||
|
req->len = len;
|
||||||
|
req->version = version;
|
||||||
|
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete(pool, inode, offset, length, { version }?, callback(err))
|
||||||
|
NAN_METHOD(NodeVitastor::Delete)
|
||||||
|
{
|
||||||
|
TRACE("NodeVitastor::Delete");
|
||||||
|
if (info.Length() < 5)
|
||||||
|
Nan::ThrowError("Not enough arguments to delete(pool, inode, offset, length, { version }?, callback(err))");
|
||||||
|
|
||||||
|
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
||||||
|
|
||||||
|
uint64_t pool = get_ui64(info[0]);
|
||||||
|
uint64_t inode = get_ui64(info[1]);
|
||||||
|
|
||||||
|
auto req = self->get_delete_request(info, 2);
|
||||||
|
|
||||||
|
self->Ref();
|
||||||
|
vitastor_c_delete(self->c, ((pool << (64-POOL_ID_BITS)) | inode), req->offset, req->len, req->version,
|
||||||
|
on_write_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(self->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync(callback(err))
|
// sync(callback(err))
|
||||||
@@ -228,19 +294,21 @@ NAN_METHOD(NodeVitastor::Sync)
|
|||||||
|
|
||||||
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
||||||
|
|
||||||
v8::Local<v8::Function> callback = info[0].As<v8::Function>();
|
auto req = new NodeVitastorRequest(self, info[0].As<v8::Function>());
|
||||||
auto req = new NodeVitastorRequest(self, callback);
|
|
||||||
|
|
||||||
self->Ref();
|
self->Ref();
|
||||||
vitastor_c_sync(self->c, on_write_finish, req);
|
vitastor_c_sync(self->c, on_write_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(self->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// read_bitmap(pool, inode, offset, len, with_parents, callback(err, bitmap_buffer))
|
// read_bitmap(pool, inode, offset, length, with_parents, callback(err, bitmap_buffer))
|
||||||
NAN_METHOD(NodeVitastor::ReadBitmap)
|
NAN_METHOD(NodeVitastor::ReadBitmap)
|
||||||
{
|
{
|
||||||
TRACE("NodeVitastor::ReadBitmap");
|
TRACE("NodeVitastor::ReadBitmap");
|
||||||
if (info.Length() < 6)
|
if (info.Length() < 6)
|
||||||
Nan::ThrowError("Not enough arguments to read_bitmap(pool, inode, offset, len, with_parents, callback(err, bitmap_buffer))");
|
Nan::ThrowError("Not enough arguments to read_bitmap(pool, inode, offset, length, with_parents, callback(err, bitmap_buffer))");
|
||||||
|
|
||||||
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
||||||
|
|
||||||
@@ -249,11 +317,13 @@ NAN_METHOD(NodeVitastor::ReadBitmap)
|
|||||||
uint64_t offset = get_ui64(info[2]);
|
uint64_t offset = get_ui64(info[2]);
|
||||||
uint64_t len = get_ui64(info[3]);
|
uint64_t len = get_ui64(info[3]);
|
||||||
bool with_parents = Nan::To<bool>(info[4]).FromJust();
|
bool with_parents = Nan::To<bool>(info[4]).FromJust();
|
||||||
v8::Local<v8::Function> callback = info[5].As<v8::Function>();
|
|
||||||
|
|
||||||
auto req = new NodeVitastorRequest(self, callback);
|
auto req = new NodeVitastorRequest(self, info[5].As<v8::Function>());
|
||||||
self->Ref();
|
self->Ref();
|
||||||
vitastor_c_read_bitmap(self->c, ((pool << (64-POOL_ID_BITS)) | inode), offset, len, with_parents, on_read_bitmap_finish, req);
|
vitastor_c_read_bitmap(self->c, ((pool << (64-POOL_ID_BITS)) | inode), offset, len, with_parents, on_read_bitmap_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(self->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_error(NodeVitastorRequest *req, Nan::Callback & nanCallback, long retval)
|
static void on_error(NodeVitastorRequest *req, Nan::Callback & nanCallback, long retval)
|
||||||
@@ -267,6 +337,66 @@ static void on_error(NodeVitastorRequest *req, Nan::Callback & nanCallback, long
|
|||||||
nanCallback.Call(1, args, req);
|
nanCallback.Call(1, args, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// on_ready(callback(err))
|
||||||
|
NAN_METHOD(NodeVitastor::OnReady)
|
||||||
|
{
|
||||||
|
TRACE("NodeVitastor::OnReady");
|
||||||
|
if (info.Length() < 1)
|
||||||
|
Nan::ThrowError("Not enough arguments to on_ready(callback(err))");
|
||||||
|
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
||||||
|
auto req = new NodeVitastorRequest(self, info[0].As<v8::Function>());
|
||||||
|
self->Ref();
|
||||||
|
vitastor_c_on_ready(self->c, on_ready_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(self->c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeVitastor::on_ready_finish(void *opaque, long retval)
|
||||||
|
{
|
||||||
|
TRACE("NodeVitastor::on_ready_finish");
|
||||||
|
auto req = (NodeVitastorRequest*)opaque;
|
||||||
|
auto self = req->cli;
|
||||||
|
Nan::HandleScope scope;
|
||||||
|
Nan::Callback nanCallback(Nan::New(req->callback));
|
||||||
|
nanCallback.Call(0, NULL, req);
|
||||||
|
self->Unref();
|
||||||
|
delete req;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get_min_io_size(pool_id)
|
||||||
|
NAN_METHOD(NodeVitastor::GetMinIoSize)
|
||||||
|
{
|
||||||
|
TRACE("NodeVitastor::GetMinIoSize");
|
||||||
|
if (info.Length() < 1)
|
||||||
|
Nan::ThrowError("Not enough arguments to get_min_io_size(pool_id)");
|
||||||
|
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
||||||
|
uint64_t pool = get_ui64(info[0]);
|
||||||
|
info.GetReturnValue().Set(Nan::New<v8::Number>(vitastor_c_inode_get_bitmap_granularity(self->c, INODE_WITH_POOL(pool, 1))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// get_max_atomic_write_size(pool_id)
|
||||||
|
NAN_METHOD(NodeVitastor::GetMaxAtomicWriteSize)
|
||||||
|
{
|
||||||
|
TRACE("NodeVitastor::GetMaxAtomicWriteSize");
|
||||||
|
if (info.Length() < 1)
|
||||||
|
Nan::ThrowError("Not enough arguments to get_max_atomic_write_size(pool_id)");
|
||||||
|
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
||||||
|
uint64_t pool = get_ui64(info[0]);
|
||||||
|
info.GetReturnValue().Set(Nan::New<v8::Number>(vitastor_c_inode_get_block_size(self->c, INODE_WITH_POOL(pool, 1))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// get_immediate_commit(pool_id)
|
||||||
|
NAN_METHOD(NodeVitastor::GetImmediateCommit)
|
||||||
|
{
|
||||||
|
TRACE("NodeVitastor::GetImmediateCommit");
|
||||||
|
if (info.Length() < 1)
|
||||||
|
Nan::ThrowError("Not enough arguments to get_immediate_commit(pool_id)");
|
||||||
|
NodeVitastor* self = Nan::ObjectWrap::Unwrap<NodeVitastor>(info.This());
|
||||||
|
uint64_t pool = get_ui64(info[0]);
|
||||||
|
info.GetReturnValue().Set(Nan::New<v8::Number>(vitastor_c_inode_get_immediate_commit(self->c, INODE_WITH_POOL(pool, 1))));
|
||||||
|
}
|
||||||
|
|
||||||
void NodeVitastor::on_read_finish(void *opaque, long retval, uint64_t version)
|
void NodeVitastor::on_read_finish(void *opaque, long retval, uint64_t version)
|
||||||
{
|
{
|
||||||
TRACE("NodeVitastor::on_read_finish");
|
TRACE("NodeVitastor::on_read_finish");
|
||||||
@@ -364,6 +494,9 @@ NAN_METHOD(NodeVitastorImage::Create)
|
|||||||
img->Ref();
|
img->Ref();
|
||||||
cli->Ref();
|
cli->Ref();
|
||||||
vitastor_c_watch_inode(cli->c, (char*)img->name.c_str(), on_watch_start, img);
|
vitastor_c_watch_inode(cli->c, (char*)img->name.c_str(), on_watch_start, img);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(cli->c);
|
||||||
|
#endif
|
||||||
|
|
||||||
info.GetReturnValue().Set(info.This());
|
info.GetReturnValue().Set(info.This());
|
||||||
}
|
}
|
||||||
@@ -378,12 +511,12 @@ NodeVitastorImage::~NodeVitastorImage()
|
|||||||
cli->Unref();
|
cli->Unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
// read(offset, len, callback(err, buffer, version))
|
// read(offset, length, callback(err, buffer, version))
|
||||||
NAN_METHOD(NodeVitastorImage::Read)
|
NAN_METHOD(NodeVitastorImage::Read)
|
||||||
{
|
{
|
||||||
TRACE("NodeVitastorImage::Read");
|
TRACE("NodeVitastorImage::Read");
|
||||||
if (info.Length() < 3)
|
if (info.Length() < 3)
|
||||||
Nan::ThrowError("Not enough arguments to read(offset, len, callback(err, buffer, version))");
|
Nan::ThrowError("Not enough arguments to read(offset, length, callback(err, buffer, version))");
|
||||||
|
|
||||||
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
||||||
|
|
||||||
@@ -394,12 +527,12 @@ NAN_METHOD(NodeVitastorImage::Read)
|
|||||||
img->exec_or_wait(req);
|
img->exec_or_wait(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write(offset, buffer, { version }?, callback(err))
|
// write(offset, buf: Buffer | Buffer[], { version }?, callback(err))
|
||||||
NAN_METHOD(NodeVitastorImage::Write)
|
NAN_METHOD(NodeVitastorImage::Write)
|
||||||
{
|
{
|
||||||
TRACE("NodeVitastorImage::Write");
|
TRACE("NodeVitastorImage::Write");
|
||||||
if (info.Length() < 3)
|
if (info.Length() < 3)
|
||||||
Nan::ThrowError("Not enough arguments to write(offset, buffer, { version }?, callback(err))");
|
Nan::ThrowError("Not enough arguments to write(offset, buf: Buffer | Buffer[], { version }?, callback(err))");
|
||||||
|
|
||||||
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
||||||
|
|
||||||
@@ -410,6 +543,22 @@ NAN_METHOD(NodeVitastorImage::Write)
|
|||||||
img->exec_or_wait(req);
|
img->exec_or_wait(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete(offset, length, { version }?, callback(err))
|
||||||
|
NAN_METHOD(NodeVitastorImage::Delete)
|
||||||
|
{
|
||||||
|
TRACE("NodeVitastorImage::Delete");
|
||||||
|
if (info.Length() < 3)
|
||||||
|
Nan::ThrowError("Not enough arguments to delete(offset, length, { version }?, callback(err))");
|
||||||
|
|
||||||
|
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
||||||
|
|
||||||
|
auto req = img->cli->get_delete_request(info, 0);
|
||||||
|
req->img = img;
|
||||||
|
req->op = NODE_VITASTOR_DELETE;
|
||||||
|
|
||||||
|
img->exec_or_wait(req);
|
||||||
|
}
|
||||||
|
|
||||||
// sync(callback(err))
|
// sync(callback(err))
|
||||||
NAN_METHOD(NodeVitastorImage::Sync)
|
NAN_METHOD(NodeVitastorImage::Sync)
|
||||||
{
|
{
|
||||||
@@ -419,29 +568,27 @@ NAN_METHOD(NodeVitastorImage::Sync)
|
|||||||
|
|
||||||
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
||||||
|
|
||||||
v8::Local<v8::Function> callback = info[0].As<v8::Function>();
|
auto req = new NodeVitastorRequest(img->cli, info[0].As<v8::Function>());
|
||||||
auto req = new NodeVitastorRequest(img->cli, callback);
|
|
||||||
req->img = img;
|
req->img = img;
|
||||||
req->op = NODE_VITASTOR_SYNC;
|
req->op = NODE_VITASTOR_SYNC;
|
||||||
|
|
||||||
img->exec_or_wait(req);
|
img->exec_or_wait(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read_bitmap(offset, len, with_parents, callback(err, bitmap_buffer))
|
// read_bitmap(offset, length, with_parents, callback(err, bitmap_buffer))
|
||||||
NAN_METHOD(NodeVitastorImage::ReadBitmap)
|
NAN_METHOD(NodeVitastorImage::ReadBitmap)
|
||||||
{
|
{
|
||||||
TRACE("NodeVitastorImage::ReadBitmap");
|
TRACE("NodeVitastorImage::ReadBitmap");
|
||||||
if (info.Length() < 4)
|
if (info.Length() < 4)
|
||||||
Nan::ThrowError("Not enough arguments to read_bitmap(offset, len, with_parents, callback(err, bitmap_buffer))");
|
Nan::ThrowError("Not enough arguments to read_bitmap(offset, length, with_parents, callback(err, bitmap_buffer))");
|
||||||
|
|
||||||
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
||||||
|
|
||||||
uint64_t offset = get_ui64(info[0]);
|
uint64_t offset = get_ui64(info[0]);
|
||||||
uint64_t len = get_ui64(info[1]);
|
uint64_t len = get_ui64(info[1]);
|
||||||
bool with_parents = Nan::To<bool>(info[2]).FromJust();
|
bool with_parents = Nan::To<bool>(info[2]).FromJust();
|
||||||
v8::Local<v8::Function> callback = info[3].As<v8::Function>();
|
|
||||||
|
|
||||||
auto req = new NodeVitastorRequest(img->cli, callback);
|
auto req = new NodeVitastorRequest(img->cli, info[3].As<v8::Function>());
|
||||||
req->img = img;
|
req->img = img;
|
||||||
req->op = NODE_VITASTOR_READ_BITMAP;
|
req->op = NODE_VITASTOR_READ_BITMAP;
|
||||||
req->offset = offset;
|
req->offset = offset;
|
||||||
@@ -460,8 +607,7 @@ NAN_METHOD(NodeVitastorImage::GetInfo)
|
|||||||
|
|
||||||
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
NodeVitastorImage* img = Nan::ObjectWrap::Unwrap<NodeVitastorImage>(info.This());
|
||||||
|
|
||||||
v8::Local<v8::Function> callback = info[0].As<v8::Function>();
|
auto req = new NodeVitastorRequest(img->cli, info[0].As<v8::Function>());
|
||||||
auto req = new NodeVitastorRequest(img->cli, callback);
|
|
||||||
req->img = img;
|
req->img = img;
|
||||||
req->op = NODE_VITASTOR_GET_INFO;
|
req->op = NODE_VITASTOR_GET_INFO;
|
||||||
|
|
||||||
@@ -488,6 +634,9 @@ void NodeVitastorImage::exec_request(NodeVitastorRequest *req)
|
|||||||
uint64_t ino = vitastor_c_inode_get_num(watch);
|
uint64_t ino = vitastor_c_inode_get_num(watch);
|
||||||
cli->Ref();
|
cli->Ref();
|
||||||
vitastor_c_read(cli->c, ino, req->offset, req->len, &req->iov, 1, NodeVitastor::on_read_finish, req);
|
vitastor_c_read(cli->c, ino, req->offset, req->len, &req->iov, 1, NodeVitastor::on_read_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (req->op == NODE_VITASTOR_WRITE)
|
else if (req->op == NODE_VITASTOR_WRITE)
|
||||||
{
|
{
|
||||||
@@ -497,6 +646,19 @@ void NodeVitastorImage::exec_request(NodeVitastorRequest *req)
|
|||||||
req->iov_list.size() ? req->iov_list.data() : &req->iov,
|
req->iov_list.size() ? req->iov_list.data() : &req->iov,
|
||||||
req->iov_list.size() ? req->iov_list.size() : 1,
|
req->iov_list.size() ? req->iov_list.size() : 1,
|
||||||
NodeVitastor::on_write_finish, req);
|
NodeVitastor::on_write_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(cli->c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (req->op == NODE_VITASTOR_DELETE)
|
||||||
|
{
|
||||||
|
uint64_t ino = vitastor_c_inode_get_num(watch);
|
||||||
|
cli->Ref();
|
||||||
|
vitastor_c_delete(cli->c, ino, req->offset, req->len, req->version,
|
||||||
|
NodeVitastor::on_write_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (req->op == NODE_VITASTOR_SYNC)
|
else if (req->op == NODE_VITASTOR_SYNC)
|
||||||
{
|
{
|
||||||
@@ -506,6 +668,9 @@ void NodeVitastorImage::exec_request(NodeVitastorRequest *req)
|
|||||||
if (imm != IMMEDIATE_ALL)
|
if (imm != IMMEDIATE_ALL)
|
||||||
{
|
{
|
||||||
vitastor_c_sync(cli->c, NodeVitastor::on_write_finish, req);
|
vitastor_c_sync(cli->c, NodeVitastor::on_write_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -517,6 +682,9 @@ void NodeVitastorImage::exec_request(NodeVitastorRequest *req)
|
|||||||
uint64_t ino = vitastor_c_inode_get_num(watch);
|
uint64_t ino = vitastor_c_inode_get_num(watch);
|
||||||
cli->Ref();
|
cli->Ref();
|
||||||
vitastor_c_read_bitmap(cli->c, ino, req->offset, req->len, req->with_parents, NodeVitastor::on_read_bitmap_finish, req);
|
vitastor_c_read_bitmap(cli->c, ino, req->offset, req->len, req->with_parents, NodeVitastor::on_read_bitmap_finish, req);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (req->op == NODE_VITASTOR_GET_INFO)
|
else if (req->op == NODE_VITASTOR_GET_INFO)
|
||||||
{
|
{
|
||||||
@@ -634,8 +802,7 @@ NAN_METHOD(NodeVitastorKV::Open)
|
|||||||
cfg[std::string(*Nan::Utf8String(key))] = std::string(*Nan::Utf8String(Nan::Get(jsParams, key).ToLocalChecked()));
|
cfg[std::string(*Nan::Utf8String(key))] = std::string(*Nan::Utf8String(Nan::Get(jsParams, key).ToLocalChecked()));
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Function> callback = info[3].As<v8::Function>();
|
auto req = new NodeVitastorRequest(kv->cli, info[3].As<v8::Function>());
|
||||||
auto req = new NodeVitastorRequest(kv->cli, callback);
|
|
||||||
|
|
||||||
kv->Ref();
|
kv->Ref();
|
||||||
kv->dbw->open(inode_id, cfg, [kv, req](int res)
|
kv->dbw->open(inode_id, cfg, [kv, req](int res)
|
||||||
@@ -648,6 +815,9 @@ NAN_METHOD(NodeVitastorKV::Open)
|
|||||||
delete req;
|
delete req;
|
||||||
kv->Unref();
|
kv->Unref();
|
||||||
});
|
});
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(kv->cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// close(callback(err))
|
// close(callback(err))
|
||||||
@@ -659,8 +829,7 @@ NAN_METHOD(NodeVitastorKV::Close)
|
|||||||
|
|
||||||
NodeVitastorKV* kv = Nan::ObjectWrap::Unwrap<NodeVitastorKV>(info.This());
|
NodeVitastorKV* kv = Nan::ObjectWrap::Unwrap<NodeVitastorKV>(info.This());
|
||||||
|
|
||||||
v8::Local<v8::Function> callback = info[0].As<v8::Function>();
|
auto req = new NodeVitastorRequest(kv->cli, info[0].As<v8::Function>());
|
||||||
auto req = new NodeVitastorRequest(kv->cli, callback);
|
|
||||||
|
|
||||||
kv->Ref();
|
kv->Ref();
|
||||||
kv->dbw->close([kv, req]()
|
kv->dbw->close([kv, req]()
|
||||||
@@ -671,6 +840,9 @@ NAN_METHOD(NodeVitastorKV::Close)
|
|||||||
delete req;
|
delete req;
|
||||||
kv->Unref();
|
kv->Unref();
|
||||||
});
|
});
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(kv->cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// set_config({ ...config })
|
// set_config({ ...config })
|
||||||
@@ -714,8 +886,7 @@ void NodeVitastorKV::get_impl(const Nan::FunctionCallbackInfo<v8::Value> & info,
|
|||||||
// FIXME: Handle Buffer too
|
// FIXME: Handle Buffer too
|
||||||
std::string key(*Nan::Utf8String(info[0].As<v8::String>()));
|
std::string key(*Nan::Utf8String(info[0].As<v8::String>()));
|
||||||
|
|
||||||
v8::Local<v8::Function> callback = info[1].As<v8::Function>();
|
auto req = new NodeVitastorRequest(kv->cli, info[1].As<v8::Function>());
|
||||||
auto req = new NodeVitastorRequest(kv->cli, callback);
|
|
||||||
|
|
||||||
kv->Ref();
|
kv->Ref();
|
||||||
kv->dbw->get(key, [kv, req](int res, const std::string & value)
|
kv->dbw->get(key, [kv, req](int res, const std::string & value)
|
||||||
@@ -729,6 +900,9 @@ void NodeVitastorKV::get_impl(const Nan::FunctionCallbackInfo<v8::Value> & info,
|
|||||||
delete req;
|
delete req;
|
||||||
kv->Unref();
|
kv->Unref();
|
||||||
}, allow_cache);
|
}, allow_cache);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(kv->cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// get(key, callback(err, value))
|
// get(key, callback(err, value))
|
||||||
@@ -777,14 +951,12 @@ NAN_METHOD(NodeVitastorKV::Set)
|
|||||||
std::string key(*Nan::Utf8String(info[0].As<v8::String>()));
|
std::string key(*Nan::Utf8String(info[0].As<v8::String>()));
|
||||||
std::string value(*Nan::Utf8String(info[1].As<v8::String>()));
|
std::string value(*Nan::Utf8String(info[1].As<v8::String>()));
|
||||||
|
|
||||||
v8::Local<v8::Function> callback = info[2].As<v8::Function>();
|
NodeVitastorRequest *req = new NodeVitastorRequest(kv->cli, info[2].As<v8::Function>()), *cas_req = NULL;
|
||||||
NodeVitastorRequest *req = new NodeVitastorRequest(kv->cli, callback), *cas_req = NULL;
|
|
||||||
|
|
||||||
std::function<bool(int, const std::string &)> cas_cb;
|
std::function<bool(int, const std::string &)> cas_cb;
|
||||||
if (info.Length() > 3 && info[3]->IsObject())
|
if (info.Length() > 3 && info[3]->IsObject())
|
||||||
{
|
{
|
||||||
v8::Local<v8::Function> cas_callback = info[3].As<v8::Function>();
|
cas_req = new NodeVitastorRequest(kv->cli, info[3].As<v8::Function>());
|
||||||
cas_req = new NodeVitastorRequest(kv->cli, cas_callback);
|
|
||||||
cas_cb = make_cas_callback(cas_req);
|
cas_cb = make_cas_callback(cas_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,6 +973,9 @@ NAN_METHOD(NodeVitastorKV::Set)
|
|||||||
delete cas_req;
|
delete cas_req;
|
||||||
kv->Unref();
|
kv->Unref();
|
||||||
}, cas_cb);
|
}, cas_cb);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(kv->cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// del(key, callback(err), cas_compare(old_value)?)
|
// del(key, callback(err), cas_compare(old_value)?)
|
||||||
@@ -815,14 +990,12 @@ NAN_METHOD(NodeVitastorKV::Del)
|
|||||||
// FIXME: Handle Buffer too
|
// FIXME: Handle Buffer too
|
||||||
std::string key(*Nan::Utf8String(info[0].As<v8::String>()));
|
std::string key(*Nan::Utf8String(info[0].As<v8::String>()));
|
||||||
|
|
||||||
v8::Local<v8::Function> callback = info[1].As<v8::Function>();
|
NodeVitastorRequest *req = new NodeVitastorRequest(kv->cli, info[1].As<v8::Function>()), *cas_req = NULL;
|
||||||
NodeVitastorRequest *req = new NodeVitastorRequest(kv->cli, callback), *cas_req = NULL;
|
|
||||||
|
|
||||||
std::function<bool(int, const std::string &)> cas_cb;
|
std::function<bool(int, const std::string &)> cas_cb;
|
||||||
if (info.Length() > 2 && info[2]->IsObject())
|
if (info.Length() > 2 && info[2]->IsObject())
|
||||||
{
|
{
|
||||||
v8::Local<v8::Function> cas_callback = info[2].As<v8::Function>();
|
cas_req = new NodeVitastorRequest(kv->cli, info[2].As<v8::Function>());
|
||||||
cas_req = new NodeVitastorRequest(kv->cli, cas_callback);
|
|
||||||
cas_cb = make_cas_callback(cas_req);
|
cas_cb = make_cas_callback(cas_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,6 +1012,9 @@ NAN_METHOD(NodeVitastorKV::Del)
|
|||||||
delete cas_req;
|
delete cas_req;
|
||||||
kv->Unref();
|
kv->Unref();
|
||||||
}, cas_cb);
|
}, cas_cb);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(kv->cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// list(start_key?)
|
// list(start_key?)
|
||||||
@@ -909,7 +1085,7 @@ NodeVitastorKVListing::~NodeVitastorKVListing()
|
|||||||
kv->Unref();
|
kv->Unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
// next(callback(err, value)?)
|
// next(callback(err, key, value)?)
|
||||||
NAN_METHOD(NodeVitastorKVListing::Next)
|
NAN_METHOD(NodeVitastorKVListing::Next)
|
||||||
{
|
{
|
||||||
TRACE("NodeVitastorKVListing::Next");
|
TRACE("NodeVitastorKVListing::Next");
|
||||||
@@ -918,12 +1094,11 @@ NAN_METHOD(NodeVitastorKVListing::Next)
|
|||||||
|
|
||||||
if (info.Length() > 0)
|
if (info.Length() > 0)
|
||||||
{
|
{
|
||||||
v8::Local<v8::Function> callback = info[0].As<v8::Function>();
|
|
||||||
if (list->iter)
|
if (list->iter)
|
||||||
{
|
{
|
||||||
delete list->iter;
|
delete list->iter;
|
||||||
}
|
}
|
||||||
list->iter = new NodeVitastorRequest(list->kv->cli, callback);
|
list->iter = new NodeVitastorRequest(list->kv->cli, info[0].As<v8::Function>());
|
||||||
}
|
}
|
||||||
if (!list->handle)
|
if (!list->handle)
|
||||||
{
|
{
|
||||||
@@ -959,6 +1134,9 @@ NAN_METHOD(NodeVitastorKVListing::Next)
|
|||||||
list->iter = req;
|
list->iter = req;
|
||||||
list->kv->Unref();
|
list->kv->Unref();
|
||||||
});
|
});
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
|
vitastor_c_uring_handle_events(list->kv->cli->c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// close()
|
// close()
|
||||||
|
|||||||
+20
-6
@@ -15,14 +15,24 @@ class NodeVitastor: public Nan::ObjectWrap
|
|||||||
public:
|
public:
|
||||||
// constructor({ ...config })
|
// constructor({ ...config })
|
||||||
static NAN_METHOD(Create);
|
static NAN_METHOD(Create);
|
||||||
// read(pool, inode, offset, len, callback(err, buffer, version))
|
// read(pool_id, inode, offset, length, callback(err, buffer, version))
|
||||||
static NAN_METHOD(Read);
|
static NAN_METHOD(Read);
|
||||||
// write(pool, inode, offset, buf: Buffer | Buffer[], { version }?, callback(err))
|
// write(pool_id, inode, offset, buf: Buffer | Buffer[], { version }?, callback(err))
|
||||||
static NAN_METHOD(Write);
|
static NAN_METHOD(Write);
|
||||||
|
// delete(pool_id, inode, offset, length, { version }?, callback(err))
|
||||||
|
static NAN_METHOD(Delete);
|
||||||
// sync(callback(err))
|
// sync(callback(err))
|
||||||
static NAN_METHOD(Sync);
|
static NAN_METHOD(Sync);
|
||||||
// read_bitmap(pool, inode, offset, len, with_parents, callback(err, bitmap_buffer))
|
// read_bitmap(pool_id, inode, offset, length, with_parents, callback(err, bitmap_buffer))
|
||||||
static NAN_METHOD(ReadBitmap);
|
static NAN_METHOD(ReadBitmap);
|
||||||
|
// on_ready(callback(err))
|
||||||
|
static NAN_METHOD(OnReady);
|
||||||
|
// get_min_io_size(pool_id)
|
||||||
|
static NAN_METHOD(GetMinIoSize);
|
||||||
|
// get_max_atomic_write_size(pool_id)
|
||||||
|
static NAN_METHOD(GetMaxAtomicWriteSize);
|
||||||
|
// get_immediate_commit(pool_id)
|
||||||
|
static NAN_METHOD(GetImmediateCommit);
|
||||||
// // destroy()
|
// // destroy()
|
||||||
// static NAN_METHOD(Destroy);
|
// static NAN_METHOD(Destroy);
|
||||||
|
|
||||||
@@ -37,11 +47,13 @@ private:
|
|||||||
|
|
||||||
static void on_io_readable(uv_poll_t* handle, int status, int revents);
|
static void on_io_readable(uv_poll_t* handle, int status, int revents);
|
||||||
static void on_read_finish(void *opaque, long retval, uint64_t version);
|
static void on_read_finish(void *opaque, long retval, uint64_t version);
|
||||||
|
static void on_ready_finish(void *opaque, long retval);
|
||||||
static void on_write_finish(void *opaque, long retval);
|
static void on_write_finish(void *opaque, long retval);
|
||||||
static void on_read_bitmap_finish(void *opaque, long retval, uint8_t *bitmap);
|
static void on_read_bitmap_finish(void *opaque, long retval, uint8_t *bitmap);
|
||||||
|
|
||||||
NodeVitastorRequest* get_read_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos);
|
NodeVitastorRequest* get_read_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos);
|
||||||
NodeVitastorRequest* get_write_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos);
|
NodeVitastorRequest* get_write_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos);
|
||||||
|
NodeVitastorRequest* get_delete_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos);
|
||||||
|
|
||||||
friend class NodeVitastorImage;
|
friend class NodeVitastorImage;
|
||||||
friend class NodeVitastorKV;
|
friend class NodeVitastorKV;
|
||||||
@@ -53,13 +65,15 @@ class NodeVitastorImage: public Nan::ObjectWrap
|
|||||||
public:
|
public:
|
||||||
// constructor(node_vitastor, name)
|
// constructor(node_vitastor, name)
|
||||||
static NAN_METHOD(Create);
|
static NAN_METHOD(Create);
|
||||||
// read(offset, len, callback(err, buffer, version))
|
// read(offset, length, callback(err, buffer, version))
|
||||||
static NAN_METHOD(Read);
|
static NAN_METHOD(Read);
|
||||||
// write(offset, buf: Buffer | Buffer[], { version }?, callback(err))
|
// write(offset, buf: Buffer | Buffer[], { version }?, callback(err))
|
||||||
static NAN_METHOD(Write);
|
static NAN_METHOD(Write);
|
||||||
|
// delete(offset, length, { version }?, callback(err))
|
||||||
|
static NAN_METHOD(Delete);
|
||||||
// sync(callback(err))
|
// sync(callback(err))
|
||||||
static NAN_METHOD(Sync);
|
static NAN_METHOD(Sync);
|
||||||
// read_bitmap(offset, len, with_parents, callback(err, bitmap_buffer))
|
// read_bitmap(offset, length, with_parents, callback(err, bitmap_buffer))
|
||||||
static NAN_METHOD(ReadBitmap);
|
static NAN_METHOD(ReadBitmap);
|
||||||
// get_info(callback({ num, name, size, parent_id?, readonly?, meta?, mod_revision, block_size, bitmap_granularity, immediate_commit }))
|
// get_info(callback({ num, name, size, parent_id?, readonly?, meta?, mod_revision, block_size, bitmap_granularity, immediate_commit }))
|
||||||
static NAN_METHOD(GetInfo);
|
static NAN_METHOD(GetInfo);
|
||||||
@@ -120,7 +134,7 @@ class NodeVitastorKVListing: public Nan::ObjectWrap
|
|||||||
public:
|
public:
|
||||||
// constructor(node_vitastor_kv, start_key?)
|
// constructor(node_vitastor_kv, start_key?)
|
||||||
static NAN_METHOD(Create);
|
static NAN_METHOD(Create);
|
||||||
// next(callback(err, value)?)
|
// next(callback(err, key, value)?)
|
||||||
static NAN_METHOD(Next);
|
static NAN_METHOD(Next);
|
||||||
// close()
|
// close()
|
||||||
static NAN_METHOD(Close);
|
static NAN_METHOD(Close);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vitastor",
|
"name": "vitastor",
|
||||||
"version": "1.7.0",
|
"version": "2.0.0",
|
||||||
"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": [
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
"build": "node-gyp rebuild"
|
"build": "node-gyp rebuild"
|
||||||
},
|
},
|
||||||
"author": "Vitaliy Filippov",
|
"author": "Vitaliy Filippov",
|
||||||
"license": "VNPL-2.0",
|
"license": "VNPL-1.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bindings": "1.5.0",
|
"bindings": "1.5.0",
|
||||||
"nan": "^2.19.0"
|
"nan": "^2.19.0"
|
||||||
|
|||||||
@@ -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 = '1.10.1'
|
VITASTOR_VERSION = '2.0.0'
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
Name: vitastor
|
Name: vitastor
|
||||||
Version: 1.10.1
|
Version: 2.0.0
|
||||||
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-1.10.1.el7.tar.gz
|
Source0: vitastor-2.0.0.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: 1.10.1
|
Version: 2.0.0
|
||||||
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-1.10.1.el8.tar.gz
|
Source0: vitastor-2.0.0.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: 1.10.1
|
Version: 2.0.0
|
||||||
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-1.10.1.el9.tar.gz
|
Source0: vitastor-2.0.0.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="1.10.1")
|
add_definitions(-DVITASTOR_VERSION="2.0.0")
|
||||||
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})
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "blockstore_impl.h"
|
#include "blockstore_impl.h"
|
||||||
#include "blockstore_disk.h"
|
#include "blockstore_disk.h"
|
||||||
#include "str_util.h"
|
#include "str_util.h"
|
||||||
|
#include "allocator.h"
|
||||||
|
|
||||||
static uint32_t is_power_of_two(uint64_t value)
|
static uint32_t is_power_of_two(uint64_t value)
|
||||||
{
|
{
|
||||||
@@ -83,6 +84,12 @@ void blockstore_disk_t::parse_config(std::map<std::string, std::string> & config
|
|||||||
throw std::runtime_error("data_csum_type="+config["data_csum_type"]+" is unsupported, only \"crc32c\" and \"none\" are supported");
|
throw std::runtime_error("data_csum_type="+config["data_csum_type"]+" is unsupported, only \"crc32c\" and \"none\" are supported");
|
||||||
}
|
}
|
||||||
csum_block_size = parse_size(config["csum_block_size"]);
|
csum_block_size = parse_size(config["csum_block_size"]);
|
||||||
|
discard_on_start = config.find("discard_on_start") != config.end() &&
|
||||||
|
(config["discard_on_start"] == "true" || config["discard_on_start"] == "1" || config["discard_on_start"] == "yes");
|
||||||
|
min_discard_size = parse_size(config["min_discard_size"]);
|
||||||
|
if (!min_discard_size)
|
||||||
|
min_discard_size = 1024*1024;
|
||||||
|
discard_granularity = parse_size(config["discard_granularity"]);
|
||||||
// Validate
|
// Validate
|
||||||
if (!data_block_size)
|
if (!data_block_size)
|
||||||
{
|
{
|
||||||
@@ -172,10 +179,6 @@ void blockstore_disk_t::parse_config(std::map<std::string, std::string> & config
|
|||||||
{
|
{
|
||||||
throw std::runtime_error("journal_offset must be a multiple of journal_block_size = "+std::to_string(journal_block_size));
|
throw std::runtime_error("journal_offset must be a multiple of journal_block_size = "+std::to_string(journal_block_size));
|
||||||
}
|
}
|
||||||
clean_entry_bitmap_size = data_block_size / bitmap_granularity / 8;
|
|
||||||
clean_dyn_size = clean_entry_bitmap_size*2 + (csum_block_size
|
|
||||||
? data_block_size/csum_block_size*(data_csum_type & 0xFF) : 0);
|
|
||||||
clean_entry_size = sizeof(clean_disk_entry) + clean_dyn_size + 4 /*entry_csum*/;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockstore_disk_t::calc_lengths(bool skip_meta_check)
|
void blockstore_disk_t::calc_lengths(bool skip_meta_check)
|
||||||
@@ -224,9 +227,13 @@ void blockstore_disk_t::calc_lengths(bool skip_meta_check)
|
|||||||
}
|
}
|
||||||
// required metadata size
|
// required metadata size
|
||||||
block_count = data_len / data_block_size;
|
block_count = data_len / data_block_size;
|
||||||
|
clean_entry_bitmap_size = data_block_size / bitmap_granularity / 8;
|
||||||
|
clean_dyn_size = clean_entry_bitmap_size*2 + (csum_block_size
|
||||||
|
? data_block_size/csum_block_size*(data_csum_type & 0xFF) : 0);
|
||||||
|
clean_entry_size = sizeof(clean_disk_entry) + clean_dyn_size + 4 /*entry_csum*/;
|
||||||
meta_len = (1 + (block_count - 1 + meta_block_size / clean_entry_size) / (meta_block_size / clean_entry_size)) * meta_block_size;
|
meta_len = (1 + (block_count - 1 + meta_block_size / clean_entry_size) / (meta_block_size / clean_entry_size)) * meta_block_size;
|
||||||
if (meta_format == BLOCKSTORE_META_FORMAT_V1 ||
|
bool new_doesnt_fit = (!meta_format && !skip_meta_check && meta_area_size < meta_len && !data_csum_type);
|
||||||
!meta_format && !skip_meta_check && meta_area_size < meta_len && !data_csum_type)
|
if (meta_format == BLOCKSTORE_META_FORMAT_V1 || new_doesnt_fit)
|
||||||
{
|
{
|
||||||
uint64_t clean_entry_v0_size = sizeof(clean_disk_entry) + 2*clean_entry_bitmap_size;
|
uint64_t clean_entry_v0_size = sizeof(clean_disk_entry) + 2*clean_entry_bitmap_size;
|
||||||
uint64_t meta_v0_len = (1 + (block_count - 1 + meta_block_size / clean_entry_v0_size)
|
uint64_t meta_v0_len = (1 + (block_count - 1 + meta_block_size / clean_entry_v0_size)
|
||||||
@@ -234,7 +241,11 @@ void blockstore_disk_t::calc_lengths(bool skip_meta_check)
|
|||||||
if (meta_format == BLOCKSTORE_META_FORMAT_V1 || meta_area_size >= meta_v0_len)
|
if (meta_format == BLOCKSTORE_META_FORMAT_V1 || meta_area_size >= meta_v0_len)
|
||||||
{
|
{
|
||||||
// Old metadata fits.
|
// Old metadata fits.
|
||||||
printf("Warning: Using old metadata format without checksums because the new format doesn't fit into provided area\n");
|
if (new_doesnt_fit)
|
||||||
|
{
|
||||||
|
printf("Warning: Using old metadata format without checksums because the new format"
|
||||||
|
" doesn't fit into provided area (%lu bytes required, %lu bytes available)\n", meta_len, meta_area_size);
|
||||||
|
}
|
||||||
clean_entry_size = clean_entry_v0_size;
|
clean_entry_size = clean_entry_v0_size;
|
||||||
meta_len = meta_v0_len;
|
meta_len = meta_v0_len;
|
||||||
meta_format = BLOCKSTORE_META_FORMAT_V1;
|
meta_format = BLOCKSTORE_META_FORMAT_V1;
|
||||||
@@ -246,7 +257,7 @@ void blockstore_disk_t::calc_lengths(bool skip_meta_check)
|
|||||||
meta_format = BLOCKSTORE_META_FORMAT_V2;
|
meta_format = BLOCKSTORE_META_FORMAT_V2;
|
||||||
if (!skip_meta_check && meta_area_size < meta_len)
|
if (!skip_meta_check && meta_area_size < meta_len)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Metadata area is too small, need at least "+std::to_string(meta_len)+" bytes");
|
throw std::runtime_error("Metadata area is too small, need at least "+std::to_string(meta_len)+" bytes, have only "+std::to_string(meta_area_size)+" bytes");
|
||||||
}
|
}
|
||||||
// requested journal size
|
// requested journal size
|
||||||
if (!skip_meta_check && cfg_journal_size > journal_len)
|
if (!skip_meta_check && cfg_journal_size > journal_len)
|
||||||
@@ -415,3 +426,44 @@ void blockstore_disk_t::close_all()
|
|||||||
close(journal_fd);
|
close(journal_fd);
|
||||||
data_fd = meta_fd = journal_fd = -1;
|
data_fd = meta_fd = journal_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sadly DISCARD only works through ioctl(), but it seems to always block the device queue,
|
||||||
|
// so it's not a big deal that we can only run it synchronously.
|
||||||
|
int blockstore_disk_t::trim_data(allocator_t *alloc)
|
||||||
|
{
|
||||||
|
int r = 0;
|
||||||
|
uint64_t j = 0, i = 0;
|
||||||
|
uint64_t discarded = 0;
|
||||||
|
for (; i <= block_count; i++)
|
||||||
|
{
|
||||||
|
if (i >= block_count || alloc->get(i))
|
||||||
|
{
|
||||||
|
if (i > j && (i-j)*data_block_size >= min_discard_size)
|
||||||
|
{
|
||||||
|
uint64_t range[2] = { data_offset + j*data_block_size, (i-j)*data_block_size };
|
||||||
|
if (discard_granularity)
|
||||||
|
{
|
||||||
|
range[1] += range[0];
|
||||||
|
if (range[1] % discard_granularity)
|
||||||
|
range[1] = range[1] - (range[1] % discard_granularity);
|
||||||
|
if (range[0] % discard_granularity)
|
||||||
|
range[0] = range[0] + discard_granularity - (range[0] % discard_granularity);
|
||||||
|
if (range[0] >= range[1])
|
||||||
|
continue;
|
||||||
|
range[1] -= range[0];
|
||||||
|
}
|
||||||
|
r = ioctl(data_fd, BLKDISCARD, &range);
|
||||||
|
if (r != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to execute BLKDISCARD %ju+%ju on %s: %s (code %d)\n",
|
||||||
|
range[0], range[1], data_device.c_str(), strerror(-r), r);
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
|
discarded += range[1];
|
||||||
|
}
|
||||||
|
j = i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stderr, "%s (%ju bytes) of unused data discarded on %s\n", format_size(discarded).c_str(), discarded, data_device.c_str());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
// Lower byte of checksum type is its length
|
// Lower byte of checksum type is its length
|
||||||
#define BLOCKSTORE_CSUM_CRC32C 0x104
|
#define BLOCKSTORE_CSUM_CRC32C 0x104
|
||||||
|
|
||||||
|
class allocator_t;
|
||||||
|
|
||||||
struct blockstore_disk_t
|
struct blockstore_disk_t
|
||||||
{
|
{
|
||||||
std::string data_device, meta_device, journal_device;
|
std::string data_device, meta_device, journal_device;
|
||||||
@@ -34,14 +36,18 @@ struct blockstore_disk_t
|
|||||||
// I/O modes for data, metadata and journal: direct or "" = O_DIRECT, cached = O_SYNC, directsync = O_DIRECT|O_SYNC
|
// I/O modes for data, metadata and journal: direct or "" = O_DIRECT, cached = O_SYNC, directsync = O_DIRECT|O_SYNC
|
||||||
// O_SYNC without O_DIRECT = use Linux page cache for reads and writes
|
// O_SYNC without O_DIRECT = use Linux page cache for reads and writes
|
||||||
std::string data_io, meta_io, journal_io;
|
std::string data_io, meta_io, journal_io;
|
||||||
|
// Data discard granularity and minimum size (for the sake of performance)
|
||||||
|
bool discard_on_start = false;
|
||||||
|
uint64_t min_discard_size = 1024*1024;
|
||||||
|
uint64_t discard_granularity = 0;
|
||||||
|
|
||||||
int meta_fd = -1, data_fd = -1, journal_fd = -1;
|
int meta_fd = -1, data_fd = -1, journal_fd = -1;
|
||||||
uint64_t meta_offset, meta_device_sect, meta_device_size, meta_len, meta_format = 0;
|
uint64_t meta_offset, meta_device_sect, meta_device_size, meta_len, meta_format = 0;
|
||||||
uint64_t data_offset, data_device_sect, data_device_size, data_len;
|
uint64_t data_offset, data_device_sect, data_device_size, data_len;
|
||||||
uint64_t journal_offset, journal_device_sect, journal_device_size, journal_len;
|
uint64_t journal_offset, journal_device_sect, journal_device_size, journal_len;
|
||||||
|
|
||||||
uint32_t block_order;
|
uint32_t block_order = 0;
|
||||||
uint64_t block_count;
|
uint64_t block_count = 0;
|
||||||
uint32_t clean_entry_bitmap_size = 0, clean_entry_size = 0, clean_dyn_size = 0;
|
uint32_t clean_entry_bitmap_size = 0, clean_entry_size = 0, clean_dyn_size = 0;
|
||||||
|
|
||||||
void parse_config(std::map<std::string, std::string> & config);
|
void parse_config(std::map<std::string, std::string> & config);
|
||||||
@@ -50,6 +56,7 @@ struct blockstore_disk_t
|
|||||||
void open_journal();
|
void open_journal();
|
||||||
void calc_lengths(bool skip_meta_check = false);
|
void calc_lengths(bool skip_meta_check = false);
|
||||||
void close_all();
|
void close_all();
|
||||||
|
int trim_data(allocator_t *alloc);
|
||||||
|
|
||||||
inline uint64_t dirty_dyn_size(uint64_t offset, uint64_t len)
|
inline uint64_t dirty_dyn_size(uint64_t offset, uint64_t len)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ blockstore_impl_t::blockstore_impl_t(blockstore_config_t & config, ring_loop_t *
|
|||||||
ringloop->register_consumer(&ring_consumer);
|
ringloop->register_consumer(&ring_consumer);
|
||||||
initialized = 0;
|
initialized = 0;
|
||||||
parse_config(config, true);
|
parse_config(config, true);
|
||||||
zero_object = (uint8_t*)memalign_or_die(MEM_ALIGNMENT, dsk.data_block_size);
|
|
||||||
alloc_dyn_data = dsk.clean_dyn_size > sizeof(void*) || dsk.csum_block_size > 0;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dsk.open_data();
|
dsk.open_data();
|
||||||
dsk.open_meta();
|
dsk.open_meta();
|
||||||
dsk.open_journal();
|
dsk.open_journal();
|
||||||
calc_lengths();
|
calc_lengths();
|
||||||
data_alloc = new allocator(dsk.block_count);
|
alloc_dyn_data = dsk.clean_dyn_size > sizeof(void*) || dsk.csum_block_size > 0;
|
||||||
|
zero_object = (uint8_t*)memalign_or_die(MEM_ALIGNMENT, dsk.data_block_size);
|
||||||
|
data_alloc = new allocator_t(dsk.block_count);
|
||||||
}
|
}
|
||||||
catch (std::exception & e)
|
catch (std::exception & e)
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,8 @@ blockstore_impl_t::~blockstore_impl_t()
|
|||||||
{
|
{
|
||||||
delete data_alloc;
|
delete data_alloc;
|
||||||
delete flusher;
|
delete flusher;
|
||||||
free(zero_object);
|
if (zero_object)
|
||||||
|
free(zero_object);
|
||||||
ringloop->unregister_consumer(&ring_consumer);
|
ringloop->unregister_consumer(&ring_consumer);
|
||||||
dsk.close_all();
|
dsk.close_all();
|
||||||
if (metadata_buffer)
|
if (metadata_buffer)
|
||||||
@@ -83,14 +84,20 @@ void blockstore_impl_t::loop()
|
|||||||
{
|
{
|
||||||
delete journal_init_reader;
|
delete journal_init_reader;
|
||||||
journal_init_reader = NULL;
|
journal_init_reader = NULL;
|
||||||
if (journal.flush_journal)
|
initialized = 3;
|
||||||
initialized = 3;
|
|
||||||
else
|
|
||||||
initialized = 10;
|
|
||||||
ringloop->wakeup();
|
ringloop->wakeup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (initialized == 3)
|
if (initialized == 3)
|
||||||
|
{
|
||||||
|
if (!readonly && dsk.discard_on_start)
|
||||||
|
dsk.trim_data(data_alloc);
|
||||||
|
if (journal.flush_journal)
|
||||||
|
initialized = 4;
|
||||||
|
else
|
||||||
|
initialized = 10;
|
||||||
|
}
|
||||||
|
if (initialized == 4)
|
||||||
{
|
{
|
||||||
if (readonly)
|
if (readonly)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -279,9 +279,9 @@ class blockstore_impl_t
|
|||||||
std::vector<obj_ver_id> unsynced_big_writes, unsynced_small_writes;
|
std::vector<obj_ver_id> unsynced_big_writes, unsynced_small_writes;
|
||||||
int unsynced_big_write_count = 0, unstable_unsynced = 0;
|
int unsynced_big_write_count = 0, unstable_unsynced = 0;
|
||||||
int unsynced_queued_ops = 0;
|
int unsynced_queued_ops = 0;
|
||||||
allocator *data_alloc = NULL;
|
allocator_t *data_alloc = NULL;
|
||||||
uint64_t used_blocks = 0;
|
uint64_t used_blocks = 0;
|
||||||
uint8_t *zero_object;
|
uint8_t *zero_object = NULL;
|
||||||
|
|
||||||
void *metadata_buffer = NULL;
|
void *metadata_buffer = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,11 @@ resume_1:
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
hdr->header_csum = csum;
|
hdr->header_csum = csum;
|
||||||
bs->dsk.meta_format = BLOCKSTORE_META_FORMAT_V2;
|
if (bs->dsk.meta_format != BLOCKSTORE_META_FORMAT_V2)
|
||||||
|
{
|
||||||
|
bs->dsk.meta_format = BLOCKSTORE_META_FORMAT_V2;
|
||||||
|
bs->dsk.calc_lengths();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (hdr->version == BLOCKSTORE_META_FORMAT_V1)
|
else if (hdr->version == BLOCKSTORE_META_FORMAT_V1)
|
||||||
{
|
{
|
||||||
@@ -146,11 +150,15 @@ resume_1:
|
|||||||
hdr->csum_block_size = 0;
|
hdr->csum_block_size = 0;
|
||||||
hdr->header_csum = 0;
|
hdr->header_csum = 0;
|
||||||
// Enable compatibility mode - entries without checksums
|
// Enable compatibility mode - entries without checksums
|
||||||
bs->dsk.clean_entry_size = sizeof(clean_disk_entry) + bs->dsk.clean_entry_bitmap_size*2;
|
if (bs->dsk.meta_format != BLOCKSTORE_META_FORMAT_V1 ||
|
||||||
bs->dsk.meta_len = (1 + (bs->dsk.block_count - 1 + bs->dsk.meta_block_size / bs->dsk.clean_entry_size)
|
bs->dsk.data_csum_type != 0 || bs->dsk.csum_block_size != 0)
|
||||||
/ (bs->dsk.meta_block_size / bs->dsk.clean_entry_size)) * bs->dsk.meta_block_size;
|
{
|
||||||
bs->dsk.meta_format = BLOCKSTORE_META_FORMAT_V1;
|
bs->dsk.data_csum_type = 0;
|
||||||
printf("Warning: Starting with metadata in the old format without checksums, as stored on disk\n");
|
bs->dsk.csum_block_size = 0;
|
||||||
|
bs->dsk.meta_format = BLOCKSTORE_META_FORMAT_V1;
|
||||||
|
bs->dsk.calc_lengths();
|
||||||
|
printf("Warning: Starting with metadata in the old format without checksums, as stored on disk\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (hdr->version > BLOCKSTORE_META_FORMAT_V2)
|
else if (hdr->version > BLOCKSTORE_META_FORMAT_V2)
|
||||||
{
|
{
|
||||||
@@ -256,6 +264,7 @@ resume_2:
|
|||||||
}
|
}
|
||||||
if (entries_to_zero.size() && !bs->inmemory_meta && !bs->readonly)
|
if (entries_to_zero.size() && !bs->inmemory_meta && !bs->readonly)
|
||||||
{
|
{
|
||||||
|
std::sort(entries_to_zero.begin(), entries_to_zero.end());
|
||||||
// we have to zero out additional entries
|
// we have to zero out additional entries
|
||||||
for (i = 0; i < entries_to_zero.size(); )
|
for (i = 0; i < entries_to_zero.size(); )
|
||||||
{
|
{
|
||||||
@@ -337,7 +346,16 @@ bool blockstore_init_meta::handle_meta_block(uint8_t *buf, uint64_t entries_per_
|
|||||||
uint32_t *entry_csum = (uint32_t*)((uint8_t*)entry + bs->dsk.clean_entry_size - 4);
|
uint32_t *entry_csum = (uint32_t*)((uint8_t*)entry + bs->dsk.clean_entry_size - 4);
|
||||||
if (*entry_csum != crc32c(0, entry, bs->dsk.clean_entry_size - 4))
|
if (*entry_csum != crc32c(0, entry, bs->dsk.clean_entry_size - 4))
|
||||||
{
|
{
|
||||||
printf("Metadata entry %ju is corrupt (checksum mismatch), skipping\n", done_cnt+i);
|
printf("Metadata entry %ju is corrupt (checksum mismatch: %08x vs %08x), skipping\n", done_cnt+i, *entry_csum, crc32c(0, entry, bs->dsk.clean_entry_size - 4));
|
||||||
|
// zero out the invalid entry, otherwise we'll hit "tried to overwrite non-zero metadata entry" later
|
||||||
|
if (bs->inmemory_meta)
|
||||||
|
{
|
||||||
|
memset(entry, 0, bs->dsk.clean_entry_size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entries_to_zero.push_back(done_cnt+i);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ cluster_client_t::cluster_client_t(ring_loop_t *ringloop, timerfd_manager_t *tfd
|
|||||||
|
|
||||||
st_cli.parse_config(config);
|
st_cli.parse_config(config);
|
||||||
st_cli.infinite_start = false;
|
st_cli.infinite_start = false;
|
||||||
|
if (!config["client_infinite_start"].is_null())
|
||||||
|
{
|
||||||
|
st_cli.infinite_start = config["client_infinite_start"].bool_value();
|
||||||
|
}
|
||||||
st_cli.load_global_config();
|
st_cli.load_global_config();
|
||||||
|
|
||||||
scrap_buffer_size = SCRAP_BUFFER_SIZE;
|
scrap_buffer_size = SCRAP_BUFFER_SIZE;
|
||||||
@@ -309,16 +313,17 @@ void cluster_client_t::erase_op(cluster_op_t *op)
|
|||||||
}
|
}
|
||||||
if (flags & OP_FLUSH_BUFFER)
|
if (flags & OP_FLUSH_BUFFER)
|
||||||
{
|
{
|
||||||
|
auto overflow = std::move(wb->writeback_overflow);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < wb->writeback_overflow.size() && wb->writebacks_active < client_max_writeback_iodepth)
|
while (i < overflow.size() && wb->writebacks_active < client_max_writeback_iodepth)
|
||||||
{
|
{
|
||||||
execute_internal(wb->writeback_overflow[i]);
|
execute_internal(overflow[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
overflow.erase(overflow.begin(), overflow.begin()+i);
|
||||||
wb->writeback_overflow.erase(wb->writeback_overflow.begin(), wb->writeback_overflow.begin()+i);
|
assert(!wb->writeback_overflow.size());
|
||||||
}
|
wb->writeback_overflow.swap(overflow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,7 +678,7 @@ void cluster_client_t::execute_internal(cluster_op_t *op)
|
|||||||
}
|
}
|
||||||
// Just copy and acknowledge the operation
|
// Just copy and acknowledge the operation
|
||||||
wb->copy_write(op, CACHE_DIRTY);
|
wb->copy_write(op, CACHE_DIRTY);
|
||||||
while (wb->writeback_bytes + op->len > client_max_buffered_bytes || wb->writeback_queue_size > client_max_buffered_ops)
|
while (wb->writeback_bytes > client_max_buffered_bytes || wb->writeback_queue_size > client_max_buffered_ops)
|
||||||
{
|
{
|
||||||
// Initiate some writeback (asynchronously)
|
// Initiate some writeback (asynchronously)
|
||||||
wb->start_writebacks(this, 1);
|
wb->start_writebacks(this, 1);
|
||||||
@@ -791,6 +796,36 @@ bool cluster_client_t::check_rw(cluster_op_t *op)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
op->deoptimise_snapshot = false;
|
||||||
|
if (enable_writeback && (op->opcode == OSD_OP_READ || op->opcode == OSD_OP_READ_BITMAP || op->opcode == OSD_OP_READ_CHAIN_BITMAP))
|
||||||
|
{
|
||||||
|
auto ino_it = st_cli.inode_config.find(op->inode);
|
||||||
|
if (ino_it != st_cli.inode_config.end())
|
||||||
|
{
|
||||||
|
int chain_size = 0;
|
||||||
|
while (ino_it != st_cli.inode_config.end() && ino_it->second.parent_id)
|
||||||
|
{
|
||||||
|
// Check for loops - FIXME check it in etcd_state_client
|
||||||
|
if (ino_it->second.parent_id == op->inode ||
|
||||||
|
chain_size > st_cli.inode_config.size())
|
||||||
|
{
|
||||||
|
op->retval = -EINVAL;
|
||||||
|
auto cb = std::move(op->callback);
|
||||||
|
cb(op);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (INODE_POOL(ino_it->second.parent_id) == INODE_POOL(ino_it->first) &&
|
||||||
|
wb->has_inode(ino_it->second.parent_id))
|
||||||
|
{
|
||||||
|
// Deoptimise reads - we have dirty data for one of the parent layer(s).
|
||||||
|
op->deoptimise_snapshot = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
chain_size++;
|
||||||
|
ino_it = st_cli.inode_config.find(ino_it->second.parent_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,12 +957,21 @@ resume_2:
|
|||||||
{
|
{
|
||||||
// Check parent inode
|
// Check parent inode
|
||||||
auto ino_it = st_cli.inode_config.find(op->cur_inode);
|
auto ino_it = st_cli.inode_config.find(op->cur_inode);
|
||||||
while (ino_it != st_cli.inode_config.end() && ino_it->second.parent_id &&
|
// Skip parents from the same pool
|
||||||
INODE_POOL(ino_it->second.parent_id) == INODE_POOL(op->cur_inode) &&
|
int skipped = 0;
|
||||||
// Check for loops
|
while (!op->deoptimise_snapshot &&
|
||||||
ino_it->second.parent_id != op->inode)
|
ino_it != st_cli.inode_config.end() && ino_it->second.parent_id &&
|
||||||
|
INODE_POOL(ino_it->second.parent_id) == INODE_POOL(op->cur_inode))
|
||||||
{
|
{
|
||||||
// Skip parents from the same pool
|
// Check for loops - FIXME check it in etcd_state_client
|
||||||
|
if (ino_it->second.parent_id == op->inode ||
|
||||||
|
skipped > st_cli.inode_config.size())
|
||||||
|
{
|
||||||
|
op->retval = -EINVAL;
|
||||||
|
erase_op(op);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
skipped++;
|
||||||
ino_it = st_cli.inode_config.find(ino_it->second.parent_id);
|
ino_it = st_cli.inode_config.find(ino_it->second.parent_id);
|
||||||
}
|
}
|
||||||
if (ino_it != st_cli.inode_config.end() &&
|
if (ino_it != st_cli.inode_config.end() &&
|
||||||
@@ -1106,7 +1150,7 @@ void cluster_client_t::slice_rw(cluster_op_t *op)
|
|||||||
if (end == begin)
|
if (end == begin)
|
||||||
{
|
{
|
||||||
op->done_count++;
|
op->done_count++;
|
||||||
op->parts[i].flags = PART_DONE;
|
op->parts[i].flags = PART_SENT|PART_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (op->opcode != OSD_OP_READ_BITMAP && op->opcode != OSD_OP_READ_CHAIN_BITMAP && op->opcode != OSD_OP_DELETE)
|
else if (op->opcode != OSD_OP_READ_BITMAP && op->opcode != OSD_OP_READ_CHAIN_BITMAP && op->opcode != OSD_OP_DELETE)
|
||||||
@@ -1189,7 +1233,7 @@ int cluster_client_t::try_send(cluster_op_t *op, int i)
|
|||||||
pool_cfg.scheme == POOL_SCHEME_REPLICATED ? 1 : pool_cfg.pg_size-pool_cfg.parity_chunks
|
pool_cfg.scheme == POOL_SCHEME_REPLICATED ? 1 : pool_cfg.pg_size-pool_cfg.parity_chunks
|
||||||
);
|
);
|
||||||
uint64_t meta_rev = 0;
|
uint64_t meta_rev = 0;
|
||||||
if (op->opcode != OSD_OP_READ_BITMAP && op->opcode != OSD_OP_DELETE)
|
if (op->opcode != OSD_OP_READ_BITMAP && op->opcode != OSD_OP_DELETE && !op->deoptimise_snapshot)
|
||||||
{
|
{
|
||||||
auto ino_it = st_cli.inode_config.find(op->cur_inode);
|
auto ino_it = st_cli.inode_config.find(op->cur_inode);
|
||||||
if (ino_it != st_cli.inode_config.end())
|
if (ino_it != st_cli.inode_config.end())
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ struct cluster_op_t
|
|||||||
protected:
|
protected:
|
||||||
int state = 0;
|
int state = 0;
|
||||||
uint64_t cur_inode; // for snapshot reads
|
uint64_t cur_inode; // for snapshot reads
|
||||||
bool needs_reslice = false;
|
bool needs_reslice: 1;
|
||||||
|
bool deoptimise_snapshot: 1;
|
||||||
int retry_after = 0;
|
int retry_after = 0;
|
||||||
int inflight_count = 0, done_count = 0;
|
int inflight_count = 0, done_count = 0;
|
||||||
timespec wait_up_until = {};
|
timespec wait_up_until = {};
|
||||||
|
|||||||
@@ -42,16 +42,17 @@ public:
|
|||||||
std::multimap<uint64_t, uint64_t*> flushed_buffers; // flush_id => refcnt
|
std::multimap<uint64_t, uint64_t*> flushed_buffers; // flush_id => refcnt
|
||||||
|
|
||||||
~writeback_cache_t();
|
~writeback_cache_t();
|
||||||
|
bool has_inode(uint64_t inode);
|
||||||
dirty_buf_it_t find_dirty(uint64_t inode, uint64_t offset);
|
dirty_buf_it_t find_dirty(uint64_t inode, uint64_t offset);
|
||||||
bool is_left_merged(dirty_buf_it_t dirty_it);
|
bool is_left_merged(dirty_buf_it_t dirty_it);
|
||||||
bool is_right_merged(dirty_buf_it_t dirty_it);
|
bool is_right_merged(dirty_buf_it_t dirty_it);
|
||||||
bool is_merged(const dirty_buf_it_t & dirty_it);
|
|
||||||
void copy_write(cluster_op_t *op, int state, uint64_t new_flush_id = 0);
|
void copy_write(cluster_op_t *op, int state, uint64_t new_flush_id = 0);
|
||||||
int repeat_ops_for(cluster_client_t *cli, osd_num_t peer_osd, pool_id_t pool_id, pg_num_t pg_num);
|
int repeat_ops_for(cluster_client_t *cli, osd_num_t peer_osd, pool_id_t pool_id, pg_num_t pg_num);
|
||||||
void start_writebacks(cluster_client_t *cli, int count);
|
void start_writebacks(cluster_client_t *cli, int count);
|
||||||
bool read_from_cache(cluster_op_t *op, uint32_t bitmap_granularity);
|
bool read_from_cache(cluster_op_t *op, uint32_t bitmap_granularity);
|
||||||
void flush_buffers(cluster_client_t *cli, dirty_buf_it_t from_it, dirty_buf_it_t to_it);
|
void flush_buffers(cluster_client_t *cli, dirty_buf_it_t from_it, dirty_buf_it_t to_it);
|
||||||
void mark_flush_written(uint64_t inode, uint64_t offset, uint64_t len, uint64_t flush_id);
|
void mark_flush_written(uint64_t inode, uint64_t offset, uint64_t len, uint64_t flush_id);
|
||||||
|
void delete_flush(uint64_t inode, uint64_t offset, uint64_t len, uint64_t flush_id);
|
||||||
void fsync_start();
|
void fsync_start();
|
||||||
void fsync_error();
|
void fsync_error();
|
||||||
void fsync_ok();
|
void fsync_ok();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ writeback_cache_t::~writeback_cache_t()
|
|||||||
{
|
{
|
||||||
for (auto & bp: dirty_buffers)
|
for (auto & bp: dirty_buffers)
|
||||||
{
|
{
|
||||||
if (!--(*bp.second.refcnt))
|
if (bp.second.buf && !--(*bp.second.refcnt))
|
||||||
{
|
{
|
||||||
free(bp.second.refcnt); // refcnt is allocated with the buffer
|
free(bp.second.refcnt); // refcnt is allocated with the buffer
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,15 @@ writeback_cache_t::~writeback_cache_t()
|
|||||||
dirty_buffers.clear();
|
dirty_buffers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool writeback_cache_t::has_inode(uint64_t inode)
|
||||||
|
{
|
||||||
|
auto dirty_it = dirty_buffers.lower_bound((object_id){
|
||||||
|
.inode = inode,
|
||||||
|
.stripe = 0,
|
||||||
|
});
|
||||||
|
return dirty_it != dirty_buffers.end() && dirty_it->first.inode == inode;
|
||||||
|
}
|
||||||
|
|
||||||
dirty_buf_it_t writeback_cache_t::find_dirty(uint64_t inode, uint64_t offset)
|
dirty_buf_it_t writeback_cache_t::find_dirty(uint64_t inode, uint64_t offset)
|
||||||
{
|
{
|
||||||
auto dirty_it = dirty_buffers.lower_bound((object_id){
|
auto dirty_it = dirty_buffers.lower_bound((object_id){
|
||||||
@@ -33,7 +42,11 @@ dirty_buf_it_t writeback_cache_t::find_dirty(uint64_t inode, uint64_t offset)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dirty_it;
|
if (dirty_it != dirty_buffers.end() && dirty_it->first.inode == inode)
|
||||||
|
{
|
||||||
|
return dirty_it;
|
||||||
|
}
|
||||||
|
return dirty_buffers.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeback_cache_t::is_left_merged(dirty_buf_it_t dirty_it)
|
bool writeback_cache_t::is_left_merged(dirty_buf_it_t dirty_it)
|
||||||
@@ -68,11 +81,6 @@ bool writeback_cache_t::is_right_merged(dirty_buf_it_t dirty_it)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeback_cache_t::is_merged(const dirty_buf_it_t & dirty_it)
|
|
||||||
{
|
|
||||||
return is_left_merged(dirty_it) || is_right_merged(dirty_it);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flush_id)
|
void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flush_id)
|
||||||
{
|
{
|
||||||
// Save operation for replay when one of PGs goes out of sync
|
// Save operation for replay when one of PGs goes out of sync
|
||||||
@@ -107,10 +115,16 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
|
|||||||
.flush_id = dirty_it->second.flush_id,
|
.flush_id = dirty_it->second.flush_id,
|
||||||
.refcnt = dirty_it->second.refcnt,
|
.refcnt = dirty_it->second.refcnt,
|
||||||
});
|
});
|
||||||
(*dirty_it->second.refcnt)++;
|
if (dirty_it->second.buf)
|
||||||
|
{
|
||||||
|
(*dirty_it->second.refcnt)++;
|
||||||
|
}
|
||||||
if (dirty_it->second.state == CACHE_DIRTY)
|
if (dirty_it->second.state == CACHE_DIRTY)
|
||||||
{
|
{
|
||||||
writeback_bytes -= op->len;
|
if (dirty_it->second.buf)
|
||||||
|
{
|
||||||
|
writeback_bytes -= op->len;
|
||||||
|
}
|
||||||
writeback_queue_size++;
|
writeback_queue_size++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -120,8 +134,11 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
|
|||||||
// Only leave the beginning
|
// Only leave the beginning
|
||||||
if (dirty_it->second.state == CACHE_DIRTY)
|
if (dirty_it->second.state == CACHE_DIRTY)
|
||||||
{
|
{
|
||||||
writeback_bytes -= old_end - op->offset;
|
if (dirty_it->second.buf)
|
||||||
if (is_left_merged(dirty_it) && !is_right_merged(dirty_it))
|
{
|
||||||
|
writeback_bytes -= old_end - op->offset;
|
||||||
|
}
|
||||||
|
if (is_right_merged(dirty_it))
|
||||||
{
|
{
|
||||||
writeback_queue_size++;
|
writeback_queue_size++;
|
||||||
}
|
}
|
||||||
@@ -135,8 +152,11 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
|
|||||||
// Only leave the end
|
// Only leave the end
|
||||||
if (dirty_it->second.state == CACHE_DIRTY)
|
if (dirty_it->second.state == CACHE_DIRTY)
|
||||||
{
|
{
|
||||||
writeback_bytes -= new_end - dirty_it->first.stripe;
|
if (dirty_it->second.buf)
|
||||||
if (!is_left_merged(dirty_it) && is_right_merged(dirty_it))
|
{
|
||||||
|
writeback_bytes -= new_end - dirty_it->first.stripe;
|
||||||
|
}
|
||||||
|
if (is_left_merged(dirty_it))
|
||||||
{
|
{
|
||||||
writeback_queue_size++;
|
writeback_queue_size++;
|
||||||
}
|
}
|
||||||
@@ -158,13 +178,25 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Remove the whole buffer
|
// Remove the whole buffer
|
||||||
if (dirty_it->second.state == CACHE_DIRTY && !is_merged(dirty_it))
|
if (dirty_it->second.state == CACHE_DIRTY)
|
||||||
{
|
{
|
||||||
writeback_bytes -= dirty_it->second.len;
|
if (dirty_it->second.buf)
|
||||||
assert(writeback_queue_size > 0);
|
{
|
||||||
writeback_queue_size--;
|
writeback_bytes -= dirty_it->second.len;
|
||||||
|
}
|
||||||
|
bool lm = is_left_merged(dirty_it);
|
||||||
|
bool rm = is_right_merged(dirty_it);
|
||||||
|
if (!lm && !rm)
|
||||||
|
{
|
||||||
|
assert(writeback_queue_size > 0);
|
||||||
|
writeback_queue_size--;
|
||||||
|
}
|
||||||
|
else if (lm && rm)
|
||||||
|
{
|
||||||
|
writeback_queue_size++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!--(*dirty_it->second.refcnt))
|
if (dirty_it->second.buf && !--(*dirty_it->second.refcnt))
|
||||||
{
|
{
|
||||||
free(dirty_it->second.refcnt);
|
free(dirty_it->second.refcnt);
|
||||||
}
|
}
|
||||||
@@ -175,7 +207,10 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
|
|||||||
bool is_del = op->opcode == OSD_OP_DELETE;
|
bool is_del = op->opcode == OSD_OP_DELETE;
|
||||||
uint64_t *refcnt = is_del ? NULL : (uint64_t*)malloc_or_die(sizeof(uint64_t) + op->len);
|
uint64_t *refcnt = is_del ? NULL : (uint64_t*)malloc_or_die(sizeof(uint64_t) + op->len);
|
||||||
uint8_t *buf = is_del ? NULL : ((uint8_t*)refcnt + sizeof(uint64_t));
|
uint8_t *buf = is_del ? NULL : ((uint8_t*)refcnt + sizeof(uint64_t));
|
||||||
*refcnt = 1;
|
if (!is_del)
|
||||||
|
{
|
||||||
|
*refcnt = 1;
|
||||||
|
}
|
||||||
dirty_it = dirty_buffers.emplace_hint(dirty_it, (object_id){
|
dirty_it = dirty_buffers.emplace_hint(dirty_it, (object_id){
|
||||||
.inode = op->inode,
|
.inode = op->inode,
|
||||||
.stripe = op->offset,
|
.stripe = op->offset,
|
||||||
@@ -190,7 +225,9 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
|
|||||||
{
|
{
|
||||||
writeback_bytes += is_del ? 0 : op->len;
|
writeback_bytes += is_del ? 0 : op->len;
|
||||||
// Track consecutive write-back operations
|
// Track consecutive write-back operations
|
||||||
if (!is_merged(dirty_it))
|
bool lm = is_left_merged(dirty_it);
|
||||||
|
bool rm = is_right_merged(dirty_it);
|
||||||
|
if (!lm && !rm)
|
||||||
{
|
{
|
||||||
// <writeback_queue> is OK to contain more than actual number of consecutive
|
// <writeback_queue> is OK to contain more than actual number of consecutive
|
||||||
// requests as long as it doesn't miss anything. But <writeback_queue_size>
|
// requests as long as it doesn't miss anything. But <writeback_queue_size>
|
||||||
@@ -201,6 +238,11 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
|
|||||||
.stripe = op->offset,
|
.stripe = op->offset,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if (lm && rm)
|
||||||
|
{
|
||||||
|
assert(writeback_queue_size > 0);
|
||||||
|
writeback_queue_size--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!is_del)
|
if (!is_del)
|
||||||
{
|
{
|
||||||
@@ -225,7 +267,7 @@ int writeback_cache_t::repeat_ops_for(cluster_client_t *cli, osd_num_t peer_osd,
|
|||||||
for (auto wr_it = dirty_buffers.begin(), flush_it = wr_it, last_it = wr_it; ; )
|
for (auto wr_it = dirty_buffers.begin(), flush_it = wr_it, last_it = wr_it; ; )
|
||||||
{
|
{
|
||||||
bool end = wr_it == dirty_buffers.end();
|
bool end = wr_it == dirty_buffers.end();
|
||||||
bool flush_this = !end && wr_it->second.state != CACHE_REPEATING;
|
bool flush_this = !end && wr_it->second.state != CACHE_REPEATING && wr_it->second.state != CACHE_DIRTY;
|
||||||
if (peer_osd)
|
if (peer_osd)
|
||||||
flush_this = flush_this && cli->affects_osd(wr_it->first.inode, wr_it->first.stripe, wr_it->second.len, peer_osd);
|
flush_this = flush_this && cli->affects_osd(wr_it->first.inode, wr_it->first.stripe, wr_it->second.len, peer_osd);
|
||||||
if (pool_id && pg_num)
|
if (pool_id && pg_num)
|
||||||
@@ -290,7 +332,14 @@ void writeback_cache_t::flush_buffers(cluster_client_t *cli, dirty_buf_it_t from
|
|||||||
}
|
}
|
||||||
flushed_buffers.erase(fl_it++);
|
flushed_buffers.erase(fl_it++);
|
||||||
}
|
}
|
||||||
mark_flush_written(op->inode, op->offset, op->len, flush_id);
|
if (op->flags & OP_IMMEDIATE_COMMIT)
|
||||||
|
{
|
||||||
|
delete_flush(op->inode, op->offset, op->len, flush_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mark_flush_written(op->inode, op->offset, op->len, flush_id);
|
||||||
|
}
|
||||||
delete op;
|
delete op;
|
||||||
writebacks_active--;
|
writebacks_active--;
|
||||||
// We can't call execute_internal because it affects an invalid copy of the list here
|
// We can't call execute_internal because it affects an invalid copy of the list here
|
||||||
@@ -308,6 +357,25 @@ void writeback_cache_t::flush_buffers(cluster_client_t *cli, dirty_buf_it_t from
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeback_cache_t::delete_flush(uint64_t inode, uint64_t offset, uint64_t len, uint64_t flush_id)
|
||||||
|
{
|
||||||
|
for (auto dirty_it = find_dirty(inode, offset);
|
||||||
|
dirty_it != dirty_buffers.end() && dirty_it->first.inode == inode &&
|
||||||
|
dirty_it->first.stripe < offset+len; )
|
||||||
|
{
|
||||||
|
if (dirty_it->second.flush_id == flush_id && dirty_it->second.state == CACHE_REPEATING)
|
||||||
|
{
|
||||||
|
if (dirty_it->second.buf && !--(*dirty_it->second.refcnt))
|
||||||
|
{
|
||||||
|
free(dirty_it->second.refcnt);
|
||||||
|
}
|
||||||
|
dirty_buffers.erase(dirty_it++);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dirty_it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void writeback_cache_t::mark_flush_written(uint64_t inode, uint64_t offset, uint64_t len, uint64_t flush_id)
|
void writeback_cache_t::mark_flush_written(uint64_t inode, uint64_t offset, uint64_t len, uint64_t flush_id)
|
||||||
{
|
{
|
||||||
for (auto dirty_it = find_dirty(inode, offset);
|
for (auto dirty_it = find_dirty(inode, offset);
|
||||||
@@ -376,6 +444,7 @@ void writeback_cache_t::start_writebacks(cluster_client_t *cli, int count)
|
|||||||
assert(writeback_queue_size > 0);
|
assert(writeback_queue_size > 0);
|
||||||
writeback_queue_size--;
|
writeback_queue_size--;
|
||||||
writeback_bytes -= off - from_it->first.stripe;
|
writeback_bytes -= off - from_it->first.stripe;
|
||||||
|
assert(writeback_queue_size > 0 || !writeback_bytes);
|
||||||
flush_buffers(cli, from_it, to_it);
|
flush_buffers(cli, from_it, to_it);
|
||||||
}
|
}
|
||||||
queue_copy.erase(queue_copy.begin(), queue_copy.begin()+i);
|
queue_copy.erase(queue_copy.begin(), queue_copy.begin()+i);
|
||||||
@@ -523,8 +592,10 @@ void writeback_cache_t::fsync_ok()
|
|||||||
{
|
{
|
||||||
if (uw_it->second.state == CACHE_FLUSHING)
|
if (uw_it->second.state == CACHE_FLUSHING)
|
||||||
{
|
{
|
||||||
if (!--(*uw_it->second.refcnt))
|
if (uw_it->second.buf && !--(*uw_it->second.refcnt))
|
||||||
|
{
|
||||||
free(uw_it->second.refcnt);
|
free(uw_it->second.refcnt);
|
||||||
|
}
|
||||||
dirty_buffers.erase(uw_it++);
|
dirty_buffers.erase(uw_it++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -889,7 +889,11 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
|||||||
if (!pc.scrub_interval)
|
if (!pc.scrub_interval)
|
||||||
pc.scrub_interval = 0;
|
pc.scrub_interval = 0;
|
||||||
// Mark pool as VitastorFS pool (disable per-inode stats and block volume creation)
|
// Mark pool as VitastorFS pool (disable per-inode stats and block volume creation)
|
||||||
pc.used_for_fs = pool_item.second["used_for_fs"].as_string();
|
pc.used_for_app = pool_item.second["used_for_fs"].as_string();
|
||||||
|
if (pc.used_for_app != "")
|
||||||
|
pc.used_for_app = "fs:"+pc.used_for_app;
|
||||||
|
else
|
||||||
|
pc.used_for_app = pool_item.second["used_for_app"].as_string();
|
||||||
// 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)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ struct pool_config_t
|
|||||||
uint64_t pg_stripe_size;
|
uint64_t pg_stripe_size;
|
||||||
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;
|
||||||
std::string used_for_fs;
|
std::string used_for_app;
|
||||||
int backfillfull;
|
int backfillfull;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+121
-74
@@ -275,8 +275,8 @@ const char *help_text =
|
|||||||
" --foreground 1\n"
|
" --foreground 1\n"
|
||||||
" Stay in foreground, do not daemonize.\n"
|
" Stay in foreground, do not daemonize.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"vitastor-nbd unmap /dev/nbdN\n"
|
"vitastor-nbd unmap [--force] /dev/nbdN\n"
|
||||||
" Unmap an ioctl-mapped NBD device.\n"
|
" Unmap an ioctl-mapped NBD device. Do not check if it's actually mapped if --force is specified.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"vitastor-nbd ls [--json]\n"
|
"vitastor-nbd ls [--json]\n"
|
||||||
" List ioctl-mapped Vitastor NBD devices, optionally in JSON format.\n"
|
" List ioctl-mapped Vitastor NBD devices, optionally in JSON format.\n"
|
||||||
@@ -313,7 +313,7 @@ const char *help_text =
|
|||||||
#endif
|
#endif
|
||||||
"Use vitastor-nbd --help <command> for command details or vitastor-nbd --help --all for all details.\n"
|
"Use vitastor-nbd --help <command> for command details or vitastor-nbd --help --all for all details.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"All usual Vitastor config options like --config_file <path_to_config> may also be specified in CLI.\n"
|
"All usual Vitastor config options like --config_path <path_to_config> may also be specified in CLI.\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
class nbd_proxy
|
class nbd_proxy
|
||||||
@@ -372,7 +372,8 @@ public:
|
|||||||
else if (args[i][0] == '-' && args[i][1] == '-')
|
else if (args[i][0] == '-' && args[i][1] == '-')
|
||||||
{
|
{
|
||||||
const char *opt = args[i]+2;
|
const char *opt = args[i]+2;
|
||||||
cfg[opt] = !strcmp(opt, "json") || !strcmp(opt, "all") || i == narg-1 ? "1" : args[++i];
|
cfg[opt] = !strcmp(opt, "json") || !strcmp(opt, "all") ||
|
||||||
|
!strcmp(opt, "force") || i == narg-1 ? "1" : args[++i];
|
||||||
}
|
}
|
||||||
else if (pos == 0)
|
else if (pos == 0)
|
||||||
{
|
{
|
||||||
@@ -381,8 +382,9 @@ public:
|
|||||||
}
|
}
|
||||||
else if (pos == 1)
|
else if (pos == 1)
|
||||||
{
|
{
|
||||||
|
char c = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
if (sscanf(args[i], "/dev/nbd%d", &n) > 0)
|
if (sscanf(args[i], "/dev/nbd%d%c", &n, &c) == 1)
|
||||||
cfg["dev_num"] = n;
|
cfg["dev_num"] = n;
|
||||||
else
|
else
|
||||||
cfg["dev_num"] = args[i];
|
cfg["dev_num"] = args[i];
|
||||||
@@ -404,18 +406,14 @@ public:
|
|||||||
}
|
}
|
||||||
else if (cfg["command"] == "unmap")
|
else if (cfg["command"] == "unmap")
|
||||||
{
|
{
|
||||||
if (cfg["dev_num"].is_null())
|
if (!cfg["dev_num"].is_number() &&
|
||||||
|
cfg["dev_num"].string_value() != "0" &&
|
||||||
|
!cfg["dev_num"].uint64_value())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "device name or number is missing\n");
|
fprintf(stderr, "device name or number is missing\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (cfg["netlink"].is_null())
|
ioctl_unmap(cfg["dev_num"].uint64_value(), cfg["force"].bool_value());
|
||||||
{
|
|
||||||
ioctl_unmap(cfg["dev_num"].uint64_value());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#ifdef HAVE_NBD_NETLINK_H
|
#ifdef HAVE_NBD_NETLINK_H
|
||||||
else if (cfg["command"] == "netlink-map")
|
else if (cfg["command"] == "netlink-map")
|
||||||
@@ -444,9 +442,18 @@ help:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ioctl_unmap(int dev_num)
|
void ioctl_unmap(int dev_num, bool force)
|
||||||
{
|
{
|
||||||
char path[64] = { 0 };
|
char path[64] = { 0 };
|
||||||
|
// Check if mapped
|
||||||
|
sprintf(path, "/sys/block/nbd%d/pid", dev_num);
|
||||||
|
if (access(path, F_OK) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "/dev/nbd%d is not mapped: /sys/block/nbd%d/pid does not exist\n", dev_num, dev_num);
|
||||||
|
if (!force)
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// Run unmap
|
||||||
sprintf(path, "/dev/nbd%d", dev_num);
|
sprintf(path, "/dev/nbd%d", dev_num);
|
||||||
int r, nbd = open(path, O_RDWR);
|
int r, nbd = open(path, O_RDWR);
|
||||||
if (nbd < 0)
|
if (nbd < 0)
|
||||||
@@ -610,36 +617,43 @@ help:
|
|||||||
{
|
{
|
||||||
if (!cfg["dev_num"].is_null())
|
if (!cfg["dev_num"].is_null())
|
||||||
{
|
{
|
||||||
if (run_nbd(sockfd, cfg["dev_num"].int64_value(), device_size, NBD_FLAG_SEND_FLUSH, nbd_timeout, bg) < 0)
|
int r;
|
||||||
|
if ((r = run_nbd(sockfd, cfg["dev_num"].int64_value(), device_size, NBD_FLAG_SEND_FLUSH, nbd_timeout, bg)) != 0)
|
||||||
{
|
{
|
||||||
perror("run_nbd");
|
fprintf(stderr, "run_nbd: %s\n", strerror(-r));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Find an unused device
|
// Find an unused device
|
||||||
|
auto mapped = list_mapped();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
if (mapped.find("/dev/nbd"+std::to_string(i)) != mapped.end())
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int r = run_nbd(sockfd, i, device_size, NBD_FLAG_SEND_FLUSH, nbd_timeout, bg);
|
int r = run_nbd(sockfd, i, device_size, NBD_FLAG_SEND_FLUSH, nbd_timeout, bg);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
{
|
{
|
||||||
printf("/dev/nbd%d\n", i);
|
printf("/dev/nbd%d\n", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (r == -1 && errno == ENOENT)
|
else if (r == -ENOENT)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No free NBD devices found\n");
|
fprintf(stderr, "No free NBD devices found\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
else if (r == -2 && errno == EBUSY)
|
else if (r == -EBUSY)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
perror("run_nbd");
|
fprintf(stderr, "run_nbd: %s\n", strerror(-r));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -869,81 +883,114 @@ protected:
|
|||||||
// Check handle size
|
// Check handle size
|
||||||
assert(sizeof(cur_req.handle) == 8);
|
assert(sizeof(cur_req.handle) == 8);
|
||||||
char path[64] = { 0 };
|
char path[64] = { 0 };
|
||||||
sprintf(path, "/dev/nbd%d", dev_num);
|
int notifyfd[2] = { 0 };
|
||||||
int r, nbd = open(path, O_RDWR), qd_fd;
|
if (socketpair(AF_UNIX, SOCK_STREAM, 0, notifyfd) < 0)
|
||||||
if (nbd < 0)
|
|
||||||
{
|
{
|
||||||
return -1;
|
return -errno;
|
||||||
}
|
}
|
||||||
r = ioctl(nbd, NBD_SET_SOCK, sockfd[1]);
|
if (!fork())
|
||||||
if (r < 0)
|
|
||||||
{
|
{
|
||||||
goto end_close;
|
// Do all NBD configuration in the child process, after the last fork.
|
||||||
}
|
// Why? It's needed because there is a race condition in the Linux kernel nbd driver
|
||||||
r = ioctl(nbd, NBD_SET_BLKSIZE, 4096);
|
// in nbd_add_socket() - it saves `current` task pointer as `nbd->task_setup` and
|
||||||
if (r < 0)
|
// then rechecks if the new `current` is the same. Problem is that if that process
|
||||||
{
|
// is already dead, `current` may be freed and then replaced by another process
|
||||||
goto end_unmap;
|
// with the same pointer value. So the check passes and NBD allows a different process
|
||||||
}
|
// to set up a device which is already set up. Proper fix would have to be done in the
|
||||||
r = ioctl(nbd, NBD_SET_SIZE, size);
|
// kernel code, but the workaround is obviously to perform NBD setup from the process
|
||||||
if (r < 0)
|
// which will then actually call NBD_DO_IT. That process stays alive during the whole
|
||||||
{
|
// time of NBD device execution and the (nbd->task_setup != current) check always
|
||||||
goto end_unmap;
|
// works correctly, and we don't accidentally break previous NBD devices while setting
|
||||||
}
|
// up a new device. Forking to check every device is of course rather slow, so we also
|
||||||
ioctl(nbd, NBD_SET_FLAGS, flags);
|
// do an additional check by calling list_mapped() before searching for a free NBD device.
|
||||||
if (timeout > 0)
|
if (bg)
|
||||||
{
|
{
|
||||||
r = ioctl(nbd, NBD_SET_TIMEOUT, (unsigned long)timeout);
|
daemonize_fork();
|
||||||
|
}
|
||||||
|
close(notifyfd[0]);
|
||||||
|
sprintf(path, "/dev/nbd%d", dev_num);
|
||||||
|
int r, nbd = open(path, O_RDWR), qd_fd;
|
||||||
|
if (nbd < 0)
|
||||||
|
{
|
||||||
|
write(notifyfd[1], &errno, sizeof(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
r = ioctl(nbd, NBD_SET_SOCK, sockfd[1]);
|
||||||
|
if (r < 0)
|
||||||
|
{
|
||||||
|
goto end_close;
|
||||||
|
}
|
||||||
|
r = ioctl(nbd, NBD_SET_BLKSIZE, 4096);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
{
|
{
|
||||||
goto end_unmap;
|
goto end_unmap;
|
||||||
}
|
}
|
||||||
}
|
r = ioctl(nbd, NBD_SET_SIZE, size);
|
||||||
// Configure request size
|
if (r < 0)
|
||||||
sprintf(path, "/sys/block/nbd%d/queue/max_sectors_kb", dev_num);
|
{
|
||||||
qd_fd = open(path, O_WRONLY);
|
goto end_unmap;
|
||||||
if (qd_fd < 0)
|
}
|
||||||
{
|
ioctl(nbd, NBD_SET_FLAGS, flags);
|
||||||
goto end_unmap;
|
if (timeout > 0)
|
||||||
}
|
{
|
||||||
r = write(qd_fd, "32768", 5);
|
r = ioctl(nbd, NBD_SET_TIMEOUT, (unsigned long)timeout);
|
||||||
if (r != 5)
|
if (r < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Warning: Failed to configure max_sectors_kb\n");
|
goto end_unmap;
|
||||||
}
|
}
|
||||||
close(qd_fd);
|
}
|
||||||
if (!fork())
|
// Configure request size
|
||||||
{
|
sprintf(path, "/sys/block/nbd%d/queue/max_sectors_kb", dev_num);
|
||||||
// Run in child
|
qd_fd = open(path, O_WRONLY);
|
||||||
|
if (qd_fd < 0)
|
||||||
|
{
|
||||||
|
goto end_unmap;
|
||||||
|
}
|
||||||
|
r = write(qd_fd, "32768", 5);
|
||||||
|
if (r != 5)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Warning: Failed to configure max_sectors_kb\n");
|
||||||
|
}
|
||||||
|
close(qd_fd);
|
||||||
|
// Notify parent
|
||||||
|
errno = 0;
|
||||||
|
write(notifyfd[1], &errno, sizeof(errno));
|
||||||
|
close(notifyfd[1]);
|
||||||
close(sockfd[0]);
|
close(sockfd[0]);
|
||||||
if (bg)
|
if (bg)
|
||||||
{
|
{
|
||||||
daemonize();
|
daemonize_reopen_stdio();
|
||||||
}
|
}
|
||||||
r = ioctl(nbd, NBD_DO_IT);
|
r = ioctl(nbd, NBD_DO_IT);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "NBD device terminated with error: %s\n", strerror(errno));
|
fprintf(stderr, "NBD device /dev/nbd%d terminated with error: %s\n", dev_num, strerror(errno));
|
||||||
}
|
}
|
||||||
close(sockfd[1]);
|
close(sockfd[1]);
|
||||||
ioctl(nbd, NBD_CLEAR_QUE);
|
ioctl(nbd, NBD_CLEAR_QUE);
|
||||||
ioctl(nbd, NBD_CLEAR_SOCK);
|
ioctl(nbd, NBD_CLEAR_SOCK);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
|
||||||
close(sockfd[1]);
|
|
||||||
close(nbd);
|
|
||||||
return 0;
|
|
||||||
end_close:
|
end_close:
|
||||||
r = errno;
|
write(notifyfd[1], &errno, sizeof(errno));
|
||||||
close(nbd);
|
close(nbd);
|
||||||
errno = r;
|
exit(2);
|
||||||
return -2;
|
|
||||||
end_unmap:
|
end_unmap:
|
||||||
r = errno;
|
write(notifyfd[1], &errno, sizeof(errno));
|
||||||
ioctl(nbd, NBD_CLEAR_SOCK);
|
ioctl(nbd, NBD_CLEAR_SOCK);
|
||||||
close(nbd);
|
close(nbd);
|
||||||
errno = r;
|
exit(3);
|
||||||
return -3;
|
}
|
||||||
|
// Parent - check status
|
||||||
|
close(notifyfd[1]);
|
||||||
|
int child_errno = 0;
|
||||||
|
int ok = read(notifyfd[0], &child_errno, sizeof(child_errno));
|
||||||
|
close(notifyfd[0]);
|
||||||
|
if (ok && !child_errno)
|
||||||
|
{
|
||||||
|
close(sockfd[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -child_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void submit_send()
|
void submit_send()
|
||||||
@@ -1147,7 +1194,7 @@ protected:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cur_op->opcode == OSD_OP_WRITE && watch->cfg.readonly)
|
if (cur_op->opcode == OSD_OP_WRITE && !inode && watch->cfg.readonly)
|
||||||
{
|
{
|
||||||
cur_op->retval = -EROFS;
|
cur_op->retval = -EROFS;
|
||||||
std::function<void(cluster_op_t*)>(cur_op->callback)(cur_op);
|
std::function<void(cluster_op_t*)>(cur_op->callback)(cur_op);
|
||||||
|
|||||||
@@ -294,7 +294,9 @@ static void coroutine_fn vitastor_co_get_metadata(VitastorRPC *task)
|
|||||||
|
|
||||||
qemu_mutex_lock(&client->mutex);
|
qemu_mutex_lock(&client->mutex);
|
||||||
vitastor_c_watch_inode(client->proxy, client->image, vitastor_co_generic_cb, task);
|
vitastor_c_watch_inode(client->proxy, client->image, vitastor_co_generic_cb, task);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
vitastor_schedule_uring_handler(client);
|
vitastor_schedule_uring_handler(client);
|
||||||
|
#endif
|
||||||
qemu_mutex_unlock(&client->mutex);
|
qemu_mutex_unlock(&client->mutex);
|
||||||
|
|
||||||
while (!task->complete)
|
while (!task->complete)
|
||||||
@@ -749,7 +751,9 @@ static int coroutine_fn vitastor_co_preadv(BlockDriverState *bs,
|
|||||||
uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
|
uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
|
||||||
qemu_mutex_lock(&client->mutex);
|
qemu_mutex_lock(&client->mutex);
|
||||||
vitastor_c_read(client->proxy, inode, offset, bytes, iov->iov, iov->niov, vitastor_co_read_cb, &task);
|
vitastor_c_read(client->proxy, inode, offset, bytes, iov->iov, iov->niov, vitastor_co_read_cb, &task);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
vitastor_schedule_uring_handler(client);
|
vitastor_schedule_uring_handler(client);
|
||||||
|
#endif
|
||||||
qemu_mutex_unlock(&client->mutex);
|
qemu_mutex_unlock(&client->mutex);
|
||||||
|
|
||||||
while (!task.complete)
|
while (!task.complete)
|
||||||
@@ -783,7 +787,9 @@ static int coroutine_fn vitastor_co_pwritev(BlockDriverState *bs,
|
|||||||
uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
|
uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
|
||||||
qemu_mutex_lock(&client->mutex);
|
qemu_mutex_lock(&client->mutex);
|
||||||
vitastor_c_write(client->proxy, inode, offset, bytes, 0, iov->iov, iov->niov, vitastor_co_generic_cb, &task);
|
vitastor_c_write(client->proxy, inode, offset, bytes, 0, iov->iov, iov->niov, vitastor_co_generic_cb, &task);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
vitastor_schedule_uring_handler(client);
|
vitastor_schedule_uring_handler(client);
|
||||||
|
#endif
|
||||||
qemu_mutex_unlock(&client->mutex);
|
qemu_mutex_unlock(&client->mutex);
|
||||||
|
|
||||||
while (!task.complete)
|
while (!task.complete)
|
||||||
@@ -863,7 +869,9 @@ static int coroutine_fn vitastor_co_block_status(
|
|||||||
task.bitmap = client->last_bitmap = NULL;
|
task.bitmap = client->last_bitmap = NULL;
|
||||||
qemu_mutex_lock(&client->mutex);
|
qemu_mutex_lock(&client->mutex);
|
||||||
vitastor_c_read_bitmap(client->proxy, task.inode, task.offset, task.len, !client->skip_parents, vitastor_co_read_bitmap_cb, &task);
|
vitastor_c_read_bitmap(client->proxy, task.inode, task.offset, task.len, !client->skip_parents, vitastor_co_read_bitmap_cb, &task);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
vitastor_schedule_uring_handler(client);
|
vitastor_schedule_uring_handler(client);
|
||||||
|
#endif
|
||||||
qemu_mutex_unlock(&client->mutex);
|
qemu_mutex_unlock(&client->mutex);
|
||||||
while (!task.complete)
|
while (!task.complete)
|
||||||
{
|
{
|
||||||
@@ -950,7 +958,9 @@ static int coroutine_fn vitastor_co_flush(BlockDriverState *bs)
|
|||||||
|
|
||||||
qemu_mutex_lock(&client->mutex);
|
qemu_mutex_lock(&client->mutex);
|
||||||
vitastor_c_sync(client->proxy, vitastor_co_generic_cb, &task);
|
vitastor_c_sync(client->proxy, vitastor_co_generic_cb, &task);
|
||||||
|
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||||
vitastor_schedule_uring_handler(client);
|
vitastor_schedule_uring_handler(client);
|
||||||
|
#endif
|
||||||
qemu_mutex_unlock(&client->mutex);
|
qemu_mutex_unlock(&client->mutex);
|
||||||
|
|
||||||
while (!task.complete)
|
while (!task.complete)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
|||||||
|
|
||||||
Name: Vitastor
|
Name: Vitastor
|
||||||
Description: Vitastor client library
|
Description: Vitastor client library
|
||||||
Version: 1.10.1
|
Version: 2.0.0
|
||||||
Libs: -L${libdir} -lvitastor_client
|
Libs: -L${libdir} -lvitastor_client
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ vitastor_c *vitastor_c_create_qemu_uring(QEMUSetFDHandler *aio_set_fd_handler, v
|
|||||||
auto self = vitastor_c_create_qemu_common(aio_set_fd_handler, aio_context);
|
auto self = vitastor_c_create_qemu_common(aio_set_fd_handler, aio_context);
|
||||||
self->ringloop = ringloop;
|
self->ringloop = ringloop;
|
||||||
self->cli = new cluster_client_t(self->ringloop, self->tfd, cfg_json);
|
self->cli = new cluster_client_t(self->ringloop, self->tfd, cfg_json);
|
||||||
|
ringloop->loop();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +151,7 @@ vitastor_c *vitastor_c_create_uring(const char *config_path, const char *etcd_ho
|
|||||||
self->ringloop = ringloop;
|
self->ringloop = ringloop;
|
||||||
self->epmgr = new epoll_manager_t(self->ringloop);
|
self->epmgr = new epoll_manager_t(self->ringloop);
|
||||||
self->cli = new cluster_client_t(self->ringloop, self->epmgr->tfd, cfg_json);
|
self->cli = new cluster_client_t(self->ringloop, self->epmgr->tfd, cfg_json);
|
||||||
|
ringloop->loop();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +185,7 @@ vitastor_c *vitastor_c_create_uring_json(const char **options, int options_len)
|
|||||||
self->ringloop = ringloop;
|
self->ringloop = ringloop;
|
||||||
self->epmgr = new epoll_manager_t(self->ringloop);
|
self->epmgr = new epoll_manager_t(self->ringloop);
|
||||||
self->cli = new cluster_client_t(self->ringloop, self->epmgr->tfd, cfg_json);
|
self->cli = new cluster_client_t(self->ringloop, self->epmgr->tfd, cfg_json);
|
||||||
|
ringloop->loop();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +225,18 @@ int vitastor_c_is_ready(vitastor_c *client)
|
|||||||
return client->cli->is_ready();
|
return client->cli->is_ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vitastor_c_on_ready(vitastor_c *client, VitastorIOHandler cb, void *opaque)
|
||||||
|
{
|
||||||
|
client->cli->on_ready([=]()
|
||||||
|
{
|
||||||
|
cb(opaque, 0);
|
||||||
|
});
|
||||||
|
if (client->ringloop)
|
||||||
|
{
|
||||||
|
client->ringloop->loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void vitastor_c_uring_wait_ready(vitastor_c *client)
|
void vitastor_c_uring_wait_ready(vitastor_c *client)
|
||||||
{
|
{
|
||||||
while (!client->cli->is_ready())
|
while (!client->cli->is_ready())
|
||||||
@@ -276,6 +291,10 @@ void vitastor_c_read(vitastor_c *client, uint64_t inode, uint64_t offset, uint64
|
|||||||
delete op;
|
delete op;
|
||||||
};
|
};
|
||||||
client->cli->execute(op);
|
client->cli->execute(op);
|
||||||
|
if (client->ringloop)
|
||||||
|
{
|
||||||
|
client->ringloop->loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vitastor_c_write(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len, uint64_t check_version,
|
void vitastor_c_write(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len, uint64_t check_version,
|
||||||
@@ -297,6 +316,31 @@ void vitastor_c_write(vitastor_c *client, uint64_t inode, uint64_t offset, uint6
|
|||||||
delete op;
|
delete op;
|
||||||
};
|
};
|
||||||
client->cli->execute(op);
|
client->cli->execute(op);
|
||||||
|
if (client->ringloop)
|
||||||
|
{
|
||||||
|
client->ringloop->loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vitastor_c_delete(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len, uint64_t check_version,
|
||||||
|
VitastorIOHandler cb, void *opaque)
|
||||||
|
{
|
||||||
|
cluster_op_t *op = new cluster_op_t;
|
||||||
|
op->opcode = OSD_OP_DELETE;
|
||||||
|
op->inode = inode;
|
||||||
|
op->offset = offset;
|
||||||
|
op->len = len;
|
||||||
|
op->version = check_version;
|
||||||
|
op->callback = [cb, opaque](cluster_op_t *op)
|
||||||
|
{
|
||||||
|
cb(opaque, op->retval);
|
||||||
|
delete op;
|
||||||
|
};
|
||||||
|
client->cli->execute(op);
|
||||||
|
if (client->ringloop)
|
||||||
|
{
|
||||||
|
client->ringloop->loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vitastor_c_read_bitmap(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len,
|
void vitastor_c_read_bitmap(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len,
|
||||||
@@ -319,6 +363,10 @@ void vitastor_c_read_bitmap(vitastor_c *client, uint64_t inode, uint64_t offset,
|
|||||||
delete op;
|
delete op;
|
||||||
};
|
};
|
||||||
client->cli->execute(op);
|
client->cli->execute(op);
|
||||||
|
if (client->ringloop)
|
||||||
|
{
|
||||||
|
client->ringloop->loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vitastor_c_sync(vitastor_c *client, VitastorIOHandler cb, void *opaque)
|
void vitastor_c_sync(vitastor_c *client, VitastorIOHandler cb, void *opaque)
|
||||||
@@ -331,6 +379,10 @@ void vitastor_c_sync(vitastor_c *client, VitastorIOHandler cb, void *opaque)
|
|||||||
delete op;
|
delete op;
|
||||||
};
|
};
|
||||||
client->cli->execute(op);
|
client->cli->execute(op);
|
||||||
|
if (client->ringloop)
|
||||||
|
{
|
||||||
|
client->ringloop->loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vitastor_c_watch_inode(vitastor_c *client, char *image, VitastorIOHandler cb, void *opaque)
|
void vitastor_c_watch_inode(vitastor_c *client, char *image, VitastorIOHandler cb, void *opaque)
|
||||||
@@ -340,6 +392,10 @@ void vitastor_c_watch_inode(vitastor_c *client, char *image, VitastorIOHandler c
|
|||||||
auto watch = client->cli->st_cli.watch_inode(std::string(image));
|
auto watch = client->cli->st_cli.watch_inode(std::string(image));
|
||||||
cb(opaque, (long)watch);
|
cb(opaque, (long)watch);
|
||||||
});
|
});
|
||||||
|
if (client->ringloop)
|
||||||
|
{
|
||||||
|
client->ringloop->loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vitastor_c_close_watch(vitastor_c *client, void *handle)
|
void vitastor_c_close_watch(vitastor_c *client, void *handle)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#define VITASTOR_QEMU_PROXY_H
|
#define VITASTOR_QEMU_PROXY_H
|
||||||
|
|
||||||
// C API wrapper version
|
// C API wrapper version
|
||||||
#define VITASTOR_C_API_VERSION 4
|
#define VITASTOR_C_API_VERSION 5
|
||||||
|
|
||||||
#ifndef POOL_ID_BITS
|
#ifndef POOL_ID_BITS
|
||||||
#define POOL_ID_BITS 16
|
#define POOL_ID_BITS 16
|
||||||
@@ -51,6 +51,7 @@ vitastor_c *vitastor_c_create_epoll_json(const char **options, int options_len);
|
|||||||
void* vitastor_c_get_internal_client(vitastor_c *client);
|
void* vitastor_c_get_internal_client(vitastor_c *client);
|
||||||
void vitastor_c_destroy(vitastor_c *client);
|
void vitastor_c_destroy(vitastor_c *client);
|
||||||
int vitastor_c_is_ready(vitastor_c *client);
|
int vitastor_c_is_ready(vitastor_c *client);
|
||||||
|
void vitastor_c_on_ready(vitastor_c *client, VitastorIOHandler cb, void *opaque);
|
||||||
int vitastor_c_uring_register_eventfd(vitastor_c *client);
|
int vitastor_c_uring_register_eventfd(vitastor_c *client);
|
||||||
void vitastor_c_uring_wait_ready(vitastor_c *client);
|
void vitastor_c_uring_wait_ready(vitastor_c *client);
|
||||||
void vitastor_c_uring_handle_events(vitastor_c *client);
|
void vitastor_c_uring_handle_events(vitastor_c *client);
|
||||||
@@ -62,6 +63,8 @@ void vitastor_c_read(vitastor_c *client, uint64_t inode, uint64_t offset, uint64
|
|||||||
struct iovec *iov, int iovcnt, VitastorReadHandler cb, void *opaque);
|
struct iovec *iov, int iovcnt, VitastorReadHandler cb, void *opaque);
|
||||||
void vitastor_c_write(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len, uint64_t check_version,
|
void vitastor_c_write(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len, uint64_t check_version,
|
||||||
struct iovec *iov, int iovcnt, VitastorIOHandler cb, void *opaque);
|
struct iovec *iov, int iovcnt, VitastorIOHandler cb, void *opaque);
|
||||||
|
void vitastor_c_delete(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len, uint64_t check_version,
|
||||||
|
VitastorIOHandler cb, void *opaque);
|
||||||
void vitastor_c_read_bitmap(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len,
|
void vitastor_c_read_bitmap(vitastor_c *client, uint64_t inode, uint64_t offset, uint64_t len,
|
||||||
int with_parents, VitastorReadBitmapHandler cb, void *opaque);
|
int with_parents, VitastorReadBitmapHandler cb, void *opaque);
|
||||||
void vitastor_c_sync(vitastor_c *client, VitastorIOHandler cb, void *opaque);
|
void vitastor_c_sync(vitastor_c *client, VitastorIOHandler cb, void *opaque);
|
||||||
|
|||||||
+7
-5
@@ -160,11 +160,12 @@ static const char* help_text =
|
|||||||
"vitastor-cli modify-osd [--tags tag1,tag2,...] [--reweight <number>] [--noout true/false] <osd_number>\n"
|
"vitastor-cli modify-osd [--tags tag1,tag2,...] [--reweight <number>] [--noout true/false] <osd_number>\n"
|
||||||
" Set OSD reweight, tags or noout flag.\n"
|
" Set OSD reweight, tags or noout flag.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs [OPTIONS] [state1+state2] [^state3] [...]\n"
|
"vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs|pgs [OPTIONS] [state1+state2] [^state3] [...]\n"
|
||||||
" List PGs with any of listed state filters (^ or ! in the beginning is negation). Options:\n"
|
" List PGs with any of listed state filters (^ or ! in the beginning is negation). Options:\n"
|
||||||
" --pool <pool name or number> Only list PGs of the given pool.\n"
|
" --pool <pool name or number> Only list PGs of the given pool.\n"
|
||||||
" --min <min pg number> Only list PGs with number >= min.\n"
|
" --min <min pg number> Only list PGs with number >= min.\n"
|
||||||
" --max <max pg number> Only list PGs with number <= max.\n"
|
" --max <max pg number> Only list PGs with number <= max.\n"
|
||||||
|
" --osd 1,2,... Only list PGs with some data on specified OSD(s).\n"
|
||||||
" Examples:\n"
|
" Examples:\n"
|
||||||
" vitastor-cli pg-list active+degraded\n"
|
" vitastor-cli pg-list active+degraded\n"
|
||||||
" vitastor-cli pg-list ^active\n"
|
" vitastor-cli pg-list ^active\n"
|
||||||
@@ -186,7 +187,8 @@ static const char* help_text =
|
|||||||
" --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"
|
||||||
" --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_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"
|
||||||
|
" --used_for_app s3:<name> Mark pool as used for S3 location with name <name>\n"
|
||||||
" --pg_stripe_size <number> Increase object grouping stripe\n"
|
" --pg_stripe_size <number> Increase object grouping stripe\n"
|
||||||
" --max_osd_combinations 10000 Maximum number of random combinations for LP solver input\n"
|
" --max_osd_combinations 10000 Maximum number of random combinations for LP solver input\n"
|
||||||
" --wait Wait for the new pool to come online\n"
|
" --wait Wait for the new pool to come online\n"
|
||||||
@@ -198,7 +200,7 @@ static const char* help_text =
|
|||||||
"vitastor-cli modify-pool|pool-modify <id|name> [--name <new_name>] [PARAMETERS...]\n"
|
"vitastor-cli modify-pool|pool-modify <id|name> [--name <new_name>] [PARAMETERS...]\n"
|
||||||
" Modify an existing pool. Modifiable parameters:\n"
|
" Modify an existing pool. Modifiable parameters:\n"
|
||||||
" [-s|--pg_size <number>] [--pg_minsize <number>] [-n|--pg_count <count>]\n"
|
" [-s|--pg_size <number>] [--pg_minsize <number>] [-n|--pg_count <count>]\n"
|
||||||
" [--failure_domain <level>] [--root_node <node>] [--osd_tags <tags>] [--used_for_fs <name>]\n"
|
" [--failure_domain <level>] [--root_node <node>] [--osd_tags <tags>] [--used_for_app <type>:<name>]\n"
|
||||||
" [--max_osd_combinations <number>] [--primary_affinity_tags <tags>] [--scrub_interval <time>]\n"
|
" [--max_osd_combinations <number>] [--primary_affinity_tags <tags>] [--scrub_interval <time>]\n"
|
||||||
" [--level_placement <rules>] [--raw_placement <rules>]\n"
|
" [--level_placement <rules>] [--raw_placement <rules>]\n"
|
||||||
" Non-modifiable parameters (changing them WILL lead to data loss):\n"
|
" Non-modifiable parameters (changing them WILL lead to data loss):\n"
|
||||||
@@ -224,7 +226,7 @@ static const char* help_text =
|
|||||||
"Use vitastor-cli --help <command> for command details or vitastor-cli --help --all for all details.\n"
|
"Use vitastor-cli --help <command> for command details or vitastor-cli --help --all for all details.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"GLOBAL OPTIONS:\n"
|
"GLOBAL OPTIONS:\n"
|
||||||
" --config_file FILE Path to Vitastor configuration file\n"
|
" --config_path FILE Path to Vitastor configuration file\n"
|
||||||
" --etcd_address URL Etcd connection address\n"
|
" --etcd_address URL Etcd connection address\n"
|
||||||
" --iodepth N Send N operations in parallel to each OSD when possible (default 32)\n"
|
" --iodepth N Send N operations in parallel to each OSD when possible (default 32)\n"
|
||||||
" --parallel_osds M Work with M osds in parallel when possible (default 4)\n"
|
" --parallel_osds M Work with M osds in parallel when possible (default 4)\n"
|
||||||
@@ -482,7 +484,7 @@ static int run(cli_tool_t *p, json11::Json::object cfg)
|
|||||||
cfg["osd_num"] = cmd[1];
|
cfg["osd_num"] = cmd[1];
|
||||||
action_cb = p->start_modify_osd(cfg);
|
action_cb = p->start_modify_osd(cfg);
|
||||||
}
|
}
|
||||||
else if (cmd[0] == "pg-list" || cmd[0] == "pg-ls" || cmd[0] == "list-pg" || cmd[0] == "ls-pg" || cmd[0] == "ls-pgs")
|
else if (cmd[0] == "pg-list" || cmd[0] == "pg-ls" || cmd[0] == "list-pg" || cmd[0] == "ls-pg" || cmd[0] == "ls-pgs" || cmd[0] == "pgs")
|
||||||
{
|
{
|
||||||
// Modify OSD configuration
|
// Modify OSD configuration
|
||||||
if (cmd.size() > 1)
|
if (cmd.size() > 1)
|
||||||
|
|||||||
+15
-2
@@ -92,12 +92,12 @@ struct image_creator_t
|
|||||||
{
|
{
|
||||||
new_pool_id = pools.begin()->first;
|
new_pool_id = pools.begin()->first;
|
||||||
}
|
}
|
||||||
if (new_pool_id && !pools.at(new_pool_id).used_for_fs.empty() && !force)
|
if (new_pool_id && !pools.at(new_pool_id).used_for_app.empty() && !force)
|
||||||
{
|
{
|
||||||
result = (cli_result_t){
|
result = (cli_result_t){
|
||||||
.err = EINVAL,
|
.err = EINVAL,
|
||||||
.text = "Pool "+pools.at(new_pool_id).name+
|
.text = "Pool "+pools.at(new_pool_id).name+
|
||||||
" is used for VitastorFS "+pools.at(new_pool_id).used_for_fs+
|
" is used for application "+pools.at(new_pool_id).used_for_app+
|
||||||
". Use --force if you really know what you are doing",
|
". Use --force if you really know what you are doing",
|
||||||
};
|
};
|
||||||
state = 100;
|
state = 100;
|
||||||
@@ -215,6 +215,7 @@ resume_3:
|
|||||||
goto resume_3;
|
goto resume_3;
|
||||||
else if (state == 4)
|
else if (state == 4)
|
||||||
goto resume_4;
|
goto resume_4;
|
||||||
|
// FIXME: take all info from etcd requests, not mixed with st_cli.inode_config
|
||||||
for (auto & ic: parent->cli->st_cli.inode_config)
|
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||||
{
|
{
|
||||||
if (ic.second.name == image_name+"@"+new_snap)
|
if (ic.second.name == image_name+"@"+new_snap)
|
||||||
@@ -286,6 +287,7 @@ resume_4:
|
|||||||
|
|
||||||
json11::Json::object get_next_id()
|
json11::Json::object get_next_id()
|
||||||
{
|
{
|
||||||
|
assert(new_pool_id);
|
||||||
return json11::Json::object {
|
return json11::Json::object {
|
||||||
{ "request_range", json11::Json::object {
|
{ "request_range", json11::Json::object {
|
||||||
{ "key", base64_encode(
|
{ "key", base64_encode(
|
||||||
@@ -321,6 +323,17 @@ resume_4:
|
|||||||
goto resume_2;
|
goto resume_2;
|
||||||
else if (state == 3)
|
else if (state == 3)
|
||||||
goto resume_3;
|
goto resume_3;
|
||||||
|
if (!new_pool_id)
|
||||||
|
{
|
||||||
|
for (auto & ic: parent->cli->st_cli.inode_config)
|
||||||
|
{
|
||||||
|
if (ic.second.name == image_name)
|
||||||
|
{
|
||||||
|
new_pool_id = INODE_POOL(ic.first);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
parent->etcd_txn(json11::Json::object { { "success", json11::Json::array {
|
parent->etcd_txn(json11::Json::object { { "success", json11::Json::array {
|
||||||
get_next_id(),
|
get_next_id(),
|
||||||
json11::Json::object {
|
json11::Json::object {
|
||||||
|
|||||||
+1
-1
@@ -546,7 +546,7 @@ std::function<bool(cli_result_t &)> cli_tool_t::start_ls(json11::Json cfg)
|
|||||||
lister->list_pool_name = lister->list_pool_id ? "" : cfg["pool"].as_string();
|
lister->list_pool_name = lister->list_pool_id ? "" : cfg["pool"].as_string();
|
||||||
lister->show_stats = cfg["long"].bool_value();
|
lister->show_stats = cfg["long"].bool_value();
|
||||||
lister->show_delete = cfg["del"].bool_value();
|
lister->show_delete = cfg["del"].bool_value();
|
||||||
lister->sort_field = cfg["sort"].string_value();
|
lister->sort_field = cfg["sort"].string_value() != "" ? cfg["sort"].string_value() : "name";
|
||||||
lister->reverse = cfg["reverse"].bool_value();
|
lister->reverse = cfg["reverse"].bool_value();
|
||||||
lister->max_count = cfg["count"].uint64_value();
|
lister->max_count = cfg["count"].uint64_value();
|
||||||
for (auto & item: cfg["names"].array_items())
|
for (auto & item: cfg["names"].array_items())
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user