Skip to content

Commit 2b11aa3

Browse files
authored
Merge pull request ceph#55234 from ajarr/wip-64063
rbd-nbd: use netlink interface by default Reviewed-by: Ilya Dryomov <[email protected]>
2 parents d813ce1 + fcbf736 commit 2b11aa3

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

PendingReleaseNotes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ CephFS: Disallow delegating preallocated inode ranges to clients. Config
110110
and valid), diff-iterate is now guaranteed to execute locally if exclusive
111111
lock is available. This brings a dramatic performance improvement for QEMU
112112
live disk synchronization and backup use cases.
113+
* RBD: The ``try-netlink`` mapping option for rbd-nbd has become the default
114+
and is now deprecated. If the NBD netlink interface is not supported by the
115+
kernel, then the mapping is retried using the legacy ioctl interface.
113116

114117
>=18.0.0
115118

qa/workunits/rbd/rbd-nbd.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ used=`rbd -p ${POOL} --format xml du ${IMAGE} |
205205
unmap_device ${DEV} ${PID}
206206

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

393394
# test detach/attach
394-
OUT=`_sudo rbd device --device-type nbd --options try-netlink,show-cookie map ${POOL}/${IMAGE}`
395+
OUT=`_sudo rbd device --device-type nbd --show-cookie map ${POOL}/${IMAGE}`
395396
read DEV COOKIE <<< "${OUT}"
396397
get_pid ${POOL}
397398
_sudo mount ${DEV} ${TEMPDIR}/mnt
@@ -419,7 +420,7 @@ _sudo umount ${TEMPDIR}/mnt
419420
unmap_device ${DEV} ${PID}
420421
# if kernel supports cookies
421422
if [ -n "${COOKIE}" ]; then
422-
OUT=`_sudo rbd device --device-type nbd --show-cookie --cookie "abc de" --options try-netlink map ${POOL}/${IMAGE}`
423+
OUT=`_sudo rbd device --device-type nbd --show-cookie --cookie "abc de" map ${POOL}/${IMAGE}`
423424
read DEV ANOTHER_COOKIE <<< "${OUT}"
424425
get_pid ${POOL}
425426
test "${ANOTHER_COOKIE}" = "abc de"
@@ -429,7 +430,7 @@ DEV=
429430

430431
# test detach/attach with --snap-id
431432
SNAPID=`rbd snap ls ${POOL}/${IMAGE} | awk '$2 == "snap" {print $1}'`
432-
OUT=`_sudo rbd device --device-type nbd --options try-netlink,show-cookie map --snap-id ${SNAPID} ${POOL}/${IMAGE}`
433+
OUT=`_sudo rbd device --device-type nbd --show-cookie map --snap-id ${SNAPID} ${POOL}/${IMAGE}`
433434
read DEV COOKIE <<< "${OUT}"
434435
get_pid ${POOL}
435436
_sudo rbd device detach ${POOL}/${IMAGE} --snap-id ${SNAPID} --device-type nbd

src/tools/rbd_nbd/rbd-nbd.cc

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ struct Config {
106106
bool quiesce = false;
107107
bool readonly = false;
108108
bool set_max_part = false;
109-
bool try_netlink = false;
110109
bool show_cookie = false;
111110

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

16871685
int fd[2];
16881686

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

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

1862-
use_netlink = cfg->try_netlink || reconnect;
1863-
if (use_netlink) {
1864-
// generate when the cookie is not supplied at CLI
1865-
if (!reconnect && cfg->cookie.empty()) {
1866-
uuid_d uuid_gen;
1867-
uuid_gen.generate_random();
1868-
cfg->cookie = uuid_gen.to_string();
1869-
}
1870-
r = try_netlink_setup(cfg, fd[0], size, flags, reconnect);
1871-
if (r < 0) {
1872-
goto free_server;
1873-
} else if (r == 1) {
1874-
use_netlink = false;
1875-
}
1860+
// generate when the cookie is not supplied at CLI
1861+
if (!reconnect && cfg->cookie.empty()) {
1862+
uuid_d uuid_gen;
1863+
uuid_gen.generate_random();
1864+
cfg->cookie = uuid_gen.to_string();
1865+
}
1866+
r = try_netlink_setup(cfg, fd[0], size, flags, reconnect);
1867+
if (r < 0) {
1868+
goto free_server;
1869+
} else if (r == 1) {
1870+
use_netlink = false;
18761871
}
18771872

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

0 commit comments

Comments
 (0)