]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
krbd: increase udev netlink socket receive buffer to 2M
authorIlya Dryomov <idryomov@gmail.com>
Mon, 14 Oct 2019 10:40:43 +0000 (12:40 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Fri, 1 Nov 2019 16:01:37 +0000 (17:01 +0100)
Even though with the previous commit we no longer block between binding
the socket and starting handling events, we still want a larger receive
buffer to accommodate for scheduling delays.  Since the filtering is
done in the listener, an estimate focused on just rbd is not accurate,
but anyway: a pair of "rbd" and "block" events for "rbd map" take 2048
bytes in the receive buffer.  This allows for roughly a thousand of
them ("rbd map" and "rbd unmap" require root and libudev makes use of
SO_RCVBUFFORCE so rmem_max limit is ignored).

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 1c6cac1acaefdf59c3265d70c8d2191c59f14652)

src/krbd.cc

index edec61020c7dab454ab42c28ebcd98d044e7cbc7..4fd4ced441640284d4061e1ac3a68ecd51f71d77 100644 (file)
@@ -44,6 +44,8 @@
 #include <blkid/blkid.h>
 #include <libudev.h>
 
+static const int UDEV_BUF_SIZE = 1 << 20;  /* doubled to 2M (SO_RCVBUFFORCE) */
+
 struct krbd_ctx {
   CephContext *cct;
   struct udev *udev;
@@ -345,6 +347,13 @@ static int do_map(struct udev *udev, const char *pool, const char *image,
   if (r < 0)
     goto out_mon;
 
+  r = udev_monitor_set_receive_buffer_size(mon, UDEV_BUF_SIZE);
+  if (r < 0) {
+    std::cerr << "rbd: failed to set udev buffer size: " << cpp_strerror(r)
+              << std::endl;
+    /* not fatal */
+  }
+
   r = udev_monitor_enable_receiving(mon);
   if (r < 0)
     goto out_mon;
@@ -612,6 +621,13 @@ static int do_unmap(struct udev *udev, dev_t devno, const string& buf)
   if (r < 0)
     goto out_mon;
 
+  r = udev_monitor_set_receive_buffer_size(mon, UDEV_BUF_SIZE);
+  if (r < 0) {
+    std::cerr << "rbd: failed to set udev buffer size: " << cpp_strerror(r)
+              << std::endl;
+    /* not fatal */
+  }
+
   r = udev_monitor_enable_receiving(mon);
   if (r < 0)
     goto out_mon;