]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd-nbd: map using netlink interface by default
authorRamana Raja <rraja@redhat.com>
Wed, 17 Jan 2024 18:24:36 +0000 (13:24 -0500)
committerIlya Dryomov <idryomov@gmail.com>
Fri, 7 Mar 2025 20:05:56 +0000 (21:05 +0100)
Mapping rbd images to nbd devices using ioctl interface is not
robust. It was discovered that the device size or the md5 checksum
of the nbd device was incorrect immediately after mapping using
ioctl method. When using the nbd netlink interface to map RBD images
the issue was not encountered. Switch to using nbd netlink interface
for mapping.

Fixes: https://tracker.ceph.com/issues/64063
Signed-off-by: Ramana Raja <rraja@redhat.com>
(cherry picked from commit fcbf7367d285629b382e3d9d32ac354319d1cc66)

Conflicts:
PendingReleaseNotes [ moved to >=18.2.5 section ]

PendingReleaseNotes
qa/workunits/rbd/rbd-nbd.sh
src/tools/rbd_nbd/rbd-nbd.cc

index 5f6a16e88f034580c45fd0c1ffcc91243fc63cd2..82755aceeed5888cd966bd39cafdda4861073f73 100644 (file)
@@ -1,3 +1,10 @@
+>=18.2.5
+--------
+
+* 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.2.4
 --------
 
index 8e1b05b3f782de29573fd0cca9780c7c207b1aa8..98b3aff1370d19f1f95e81c66ed7bc028535226a 100755 (executable)
@@ -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})
@@ -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
@@ -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"
@@ -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
index f2dfa1f660e8dd77034b3fe309c6d9544b8cfae6..325dbdb5246bc3dcc8f31aaf8bc44b642c4a9715 100644 (file)
@@ -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;
@@ -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"
@@ -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];
 
@@ -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) {
@@ -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)) {