Skip to content

Commit

Permalink
Merge pull request ceph#55234 from ajarr/wip-64063
Browse files Browse the repository at this point in the history
rbd-nbd: use netlink interface by default

Reviewed-by: Ilya Dryomov <[email protected]>
  • Loading branch information
idryomov authored Jan 26, 2024
2 parents d813ce1 + fcbf736 commit 2b11aa3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
3 changes: 3 additions & 0 deletions PendingReleaseNotes
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ CephFS: Disallow delegating preallocated inode ranges to clients. Config
and valid), diff-iterate is now guaranteed to execute locally if exclusive
lock is available. This brings a dramatic performance improvement for QEMU
live disk synchronization and backup use cases.
* RBD: The ``try-netlink`` mapping option for rbd-nbd has become the default
and is now deprecated. If the NBD netlink interface is not supported by the
kernel, then the mapping is retried using the legacy ioctl interface.

>=18.0.0

Expand Down
7 changes: 4 additions & 3 deletions qa/workunits/rbd/rbd-nbd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ used=`rbd -p ${POOL} --format xml du ${IMAGE} |
unmap_device ${DEV} ${PID}

# resize test
# also test that try-netlink option is accepted for compatibility
DEV=`_sudo rbd device -t nbd -o try-netlink map ${POOL}/${IMAGE}`
get_pid ${POOL}
devname=$(basename ${DEV})
Expand Down Expand Up @@ -391,7 +392,7 @@ cat ${LOG_FILE}
expect_false grep 'quiesce failed' ${LOG_FILE}

# test detach/attach
OUT=`_sudo rbd device --device-type nbd --options try-netlink,show-cookie map ${POOL}/${IMAGE}`
OUT=`_sudo rbd device --device-type nbd --show-cookie map ${POOL}/${IMAGE}`
read DEV COOKIE <<< "${OUT}"
get_pid ${POOL}
_sudo mount ${DEV} ${TEMPDIR}/mnt
Expand Down Expand Up @@ -419,7 +420,7 @@ _sudo umount ${TEMPDIR}/mnt
unmap_device ${DEV} ${PID}
# if kernel supports cookies
if [ -n "${COOKIE}" ]; then
OUT=`_sudo rbd device --device-type nbd --show-cookie --cookie "abc de" --options try-netlink map ${POOL}/${IMAGE}`
OUT=`_sudo rbd device --device-type nbd --show-cookie --cookie "abc de" map ${POOL}/${IMAGE}`
read DEV ANOTHER_COOKIE <<< "${OUT}"
get_pid ${POOL}
test "${ANOTHER_COOKIE}" = "abc de"
Expand All @@ -429,7 +430,7 @@ DEV=

# test detach/attach with --snap-id
SNAPID=`rbd snap ls ${POOL}/${IMAGE} | awk '$2 == "snap" {print $1}'`
OUT=`_sudo rbd device --device-type nbd --options try-netlink,show-cookie map --snap-id ${SNAPID} ${POOL}/${IMAGE}`
OUT=`_sudo rbd device --device-type nbd --show-cookie map --snap-id ${SNAPID} ${POOL}/${IMAGE}`
read DEV COOKIE <<< "${OUT}"
get_pid ${POOL}
_sudo rbd device detach ${POOL}/${IMAGE} --snap-id ${SNAPID} --device-type nbd
Expand Down
32 changes: 14 additions & 18 deletions src/tools/rbd_nbd/rbd-nbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ struct Config {
bool quiesce = false;
bool readonly = false;
bool set_max_part = false;
bool try_netlink = false;
bool show_cookie = false;

std::string poolname;
Expand Down Expand Up @@ -166,7 +165,6 @@ static void usage()
<< " --read-only Map read-only\n"
<< " --reattach-timeout <sec> Set nbd re-attach timeout\n"
<< " (default: " << Config().reattach_timeout << ")\n"
<< " --try-netlink Use the nbd netlink interface\n"
<< " --show-cookie Show device cookie\n"
<< " --cookie Specify device cookie\n"
<< " --snap-id <snap-id> Specify snapshot by ID instead of by name\n"
Expand Down Expand Up @@ -1682,7 +1680,7 @@ static int do_map(int argc, const char *argv[], Config *cfg, bool reconnect)
unsigned long flags;
unsigned long size;
unsigned long blksize = RBD_NBD_BLKSIZE;
bool use_netlink;
bool use_netlink = true;

int fd[2];

Expand Down Expand Up @@ -1859,20 +1857,17 @@ static int do_map(int argc, const char *argv[], Config *cfg, bool reconnect)

server = start_server(fd[1], image, cfg);

use_netlink = cfg->try_netlink || reconnect;
if (use_netlink) {
// generate when the cookie is not supplied at CLI
if (!reconnect && cfg->cookie.empty()) {
uuid_d uuid_gen;
uuid_gen.generate_random();
cfg->cookie = uuid_gen.to_string();
}
r = try_netlink_setup(cfg, fd[0], size, flags, reconnect);
if (r < 0) {
goto free_server;
} else if (r == 1) {
use_netlink = false;
}
// generate when the cookie is not supplied at CLI
if (!reconnect && cfg->cookie.empty()) {
uuid_d uuid_gen;
uuid_gen.generate_random();
cfg->cookie = uuid_gen.to_string();
}
r = try_netlink_setup(cfg, fd[0], size, flags, reconnect);
if (r < 0) {
goto free_server;
} else if (r == 1) {
use_netlink = false;
}

if (!use_netlink) {
Expand Down Expand Up @@ -2216,7 +2211,8 @@ static int parse_args(vector<const char*>& args, std::ostream *err_msg,
} else if (ceph_argparse_flag(args, i, "--pretty-format", (char *)NULL)) {
cfg->pretty_format = true;
} else if (ceph_argparse_flag(args, i, "--try-netlink", (char *)NULL)) {
cfg->try_netlink = true;
// netlink used by default. option not required anymore.
// accept for compatibility.
} else if (ceph_argparse_flag(args, i, "--show-cookie", (char *)NULL)) {
cfg->show_cookie = true;
} else if (ceph_argparse_witharg(args, i, &cfg->cookie, "--cookie", (char *)NULL)) {
Expand Down

0 comments on commit 2b11aa3

Please sign in to comment.