From 29ee92a1512c5407b305c0b7312805c6174a3f80 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Mon, 14 Oct 2019 12:40:43 +0200 Subject: [PATCH] krbd: increase udev netlink socket receive buffer to 2M 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 (cherry picked from commit 1c6cac1acaefdf59c3265d70c8d2191c59f14652) --- src/krbd.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/krbd.cc b/src/krbd.cc index 41eea2e74fb17..e50463e2b4c02 100644 --- a/src/krbd.cc +++ b/src/krbd.cc @@ -44,6 +44,8 @@ #include #include +static const int UDEV_BUF_SIZE = 1 << 20; /* doubled to 2M (SO_RCVBUFFORCE) */ + struct krbd_ctx { CephContext *cct; struct udev *udev; @@ -388,6 +390,13 @@ static int do_map(struct udev *udev, const krbd_spec& spec, 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; @@ -696,6 +705,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; -- 2.39.5