Make netlink optional
Test / buildenv (push) Successful in 12s Details
Test / build (push) Successful in 2m42s Details
Test / test_cas (push) Successful in 13s Details
Test / make_test (push) Successful in 37s Details
Test / test_change_pg_count (push) Successful in 37s Details
Test / test_change_pg_size (push) Successful in 11s Details
Test / test_change_pg_count_ec (push) Successful in 35s Details
Test / test_create_nomaxid (push) Successful in 9s Details
Test / test_etcd_fail (push) Successful in 55s Details
Test / test_add_osd (push) Successful in 2m40s Details
Test / test_interrupted_rebalance_imm (push) Successful in 2m37s Details
Test / test_interrupted_rebalance_ec (push) Successful in 1m58s Details
Test / test_failure_domain (push) Successful in 11s Details
Test / test_interrupted_rebalance (push) Successful in 2m53s Details
Test / test_minsize_1 (push) Successful in 14s Details
Test / test_interrupted_rebalance_ec_imm (push) Successful in 1m26s Details
Test / test_snapshot (push) Successful in 30s Details
Test / test_snapshot_ec (push) Successful in 30s Details
Test / test_move_reappear (push) Successful in 24s Details
Test / test_rm (push) Successful in 17s Details
Test / test_snapshot_down (push) Successful in 31s Details
Test / test_snapshot_down_ec (push) Successful in 29s Details
Test / test_splitbrain (push) Successful in 24s Details
Test / test_snapshot_chain (push) Successful in 2m10s Details
Test / test_snapshot_chain_ec (push) Successful in 2m41s Details
Test / test_rebalance_verify_imm (push) Successful in 5m14s Details
Test / test_rebalance_verify (push) Successful in 5m55s Details
Test / test_rebalance_verify_ec_imm (push) Successful in 4m14s Details
Test / test_switch_primary (push) Successful in 38s Details
Test / test_write_no_same (push) Successful in 23s Details
Test / test_write (push) Successful in 1m14s Details
Test / test_write_xor (push) Successful in 1m51s Details
Test / test_rebalance_verify_ec (push) Successful in 7m36s Details
Test / test_heal_pg_size_2 (push) Successful in 3m44s Details
Test / test_heal_ec (push) Successful in 4m21s Details
Test / test_heal_csum_32k_dmj (push) Successful in 5m22s Details
Test / test_heal_csum_32k_dj (push) Successful in 6m47s Details
Test / test_heal_csum_32k (push) Successful in 6m47s Details
Test / test_scrub (push) Successful in 1m28s Details
Test / test_heal_csum_4k_dmj (push) Successful in 7m11s Details
Test / test_scrub_xor (push) Successful in 1m7s Details
Test / test_scrub_zero_osd_2 (push) Successful in 1m10s Details
Test / test_heal_csum_4k_dj (push) Successful in 7m1s Details
Test / test_scrub_pg_size_6_pg_minsize_4_osd_count_6_ec (push) Successful in 1m20s Details
Test / test_scrub_ec (push) Successful in 54s Details
Test / test_scrub_pg_size_3 (push) Successful in 1m39s Details
Test / test_heal_csum_4k (push) Successful in 6m9s Details

Vitaliy Filippov 2024-02-24 02:06:45 +03:00
parent 9d54af1e34
commit 7994b5fdb8
2 changed files with 24 additions and 48 deletions

View File

@ -179,15 +179,15 @@ if (${WITH_FIO})
endif (${WITH_FIO})
# vitastor-nbd
pkg_check_modules(NL3 REQUIRED libnl-3.0 libnl-genl-3.0)
add_executable(vitastor-nbd
nbd_proxy.cpp
pkg_check_modules(NL3 libnl-3.0 libnl-genl-3.0)
add_executable(vitastor-nbd
nbd_proxy.cpp
)
target_include_directories(vitastor-nbd PUBLIC ${NL3_INCLUDE_DIRS})
target_link_libraries(vitastor-nbd vitastor_client ${NL3_LIBRARIES})
if(HAVE_NBD_NETLINK_H)
if (HAVE_NBD_NETLINK_H AND "${NL3_LIBRARIES}")
target_compile_definitions(vitastor-nbd PUBLIC HAVE_NBD_NETLINK_H)
endif()
endif (HAVE_NBD_NETLINK_H AND "${NL3_LIBRARIES}")
# vitastor-nfs
add_executable(vitastor-nfs

View File

@ -23,6 +23,7 @@
#include "cluster_client.h"
#include "epoll_manager.h"
#ifdef HAVE_NBD_NETLINK_H
#include <netlink/attr.h>
#include <netlink/genl/ctrl.h>
#include <netlink/genl/genl.h>
@ -31,9 +32,6 @@
#include <netlink/netlink.h>
#include <netlink/socket.h>
#include <netlink/errno.h>
#ifdef HAVE_NBD_NETLINK_H
#include <linux/nbd-netlink.h>
#define fail(...) { fprintf(stderr, __VA_ARGS__); exit(1); }
@ -226,22 +224,6 @@ nla_put_failure:
#undef fail
#else
static int netlink_configure(const int *sockfd, int sock_size, int dev_num, uint64_t size,
uint64_t blocksize, uint64_t flags, uint64_t cflags, uint64_t timeout, uint64_t conn_timeout)
{
fprintf(stderr, "netlink is not supported\n");
exit(1);
return 0;
}
static void netlink_disconnect(uint32_t dev_num)
{
fprintf(stderr, "netlink is not supported\n");
exit(1);
}
#endif
#ifndef MSG_ZEROCOPY
@ -339,14 +321,18 @@ public:
fprintf(stderr, "device name or number is missing\n");
exit(1);
}
if (cfg["netlink"].is_null())
{
unmap(cfg["dev_num"].uint64_value());
}
else
{
#ifdef HAVE_NBD_NETLINK_H
netlink_disconnect(cfg["dev_num"].uint64_value());
#else
fprintf(stderr, "netlink support is disabled in this build\n");
exit(1);
#endif
}
}
else if (cfg["command"] == "ls" || cfg["command"] == "list" || cfg["command"] == "list-mapped")
@ -518,48 +504,38 @@ public:
if (!cfg["netlink"].is_null())
{
#ifdef HAVE_NBD_NETLINK_H
int devnum = -1;
if (!cfg["dev_num"].is_null())
{
devnum = (int)cfg["dev_num"].uint64_value();
}
uint64_t flags = NBD_FLAG_SEND_FLUSH;
uint64_t cflags = 0;
#ifdef NBD_FLAG_READ_ONLY
#ifdef NBD_FLAG_READ_ONLY
if (!cfg["nbd_ro"].is_null())
{
flags |= NBD_FLAG_READ_ONLY;
}
#endif
#ifdef NBD_CFLAG_DESTROY_ON_DISCONNECT
#endif
#ifdef NBD_CFLAG_DESTROY_ON_DISCONNECT
if (!cfg["nbd_destroy_on_disconnect"].is_null())
{
cflags |= NBD_CFLAG_DESTROY_ON_DISCONNECT;
}
#endif
#ifdef NBD_CFLAG_DISCONNECT_ON_CLOSE
#endif
#ifdef NBD_CFLAG_DISCONNECT_ON_CLOSE
if (!cfg["nbd_disconnect_on_close"].is_null())
{
cflags |= NBD_CFLAG_DISCONNECT_ON_CLOSE;
}
#endif
#endif
int err = netlink_configure(sockfd + 1, 1, devnum, device_size, 4096, flags, cflags, nbd_timeout, nbd_lease);
if (err < 0)
{
if (err == -NLE_BUSY)
errno = EBUSY;
else
errno = EIO;
perror("netlink_configure");
errno = (err == -NLE_BUSY ? EBUSY : EIO);
fprintf(stderr, "netlink_configure failed: %s (code %d)\n", nl_geterror(err), err);
exit(1);
}
printf("/dev/nbd%d\n", err);
#else
fprintf(stderr, "netlink support is disabled in this build\n");
exit(1);
#endif
}
else
{