]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
rgw/posix: fix Inotify member initialization order race 68298/head
authorKefu Chai <k.chai@proxmox.com>
Thu, 9 Apr 2026 05:15:26 +0000 (13:15 +0800)
committerKefu Chai <k.chai@proxmox.com>
Fri, 10 Apr 2026 05:11:04 +0000 (13:11 +0800)
commitf62e811f9ef1b2139cca4066d9d136cc141d9c8a
treebbbdac637ded01e7217fcfbcd40f1ec9768d71c4
parentbb2f9c653cfabedd2c80e3f0e94436da7f168f30
rgw/posix: fix Inotify member initialization order race

wfd and efd were initialized in the Inotify constructor body, but
the inotify thread was started in the member initializer list via
thrd(&Inotify::ev_loop, this). Since C++ initializes members in
declaration order (wfd, efd, thrd), the thread could start before
the constructor body ran, causing ev_loop() to capture indeterminate
fd values into its local pollfd array.

When the destructor later signaled shutdown via the real efd, the
thread never woke because it was polling the wrong fd, causing
thrd.join() to block indefinitely. This predominantly affected arm64
builds due to the weaker memory model widening the race window.

Fix by moving wfd/efd initialization into the member initializer
list so they are set before the thread starts. Also make shutdown
std::atomic<bool> to eliminate the data race, close wfd/efd in the
destructor to fix the fd leak, and add error checking for eventfd().

Fixes: https://tracker.ceph.com/issues/75601
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/rgw/driver/posix/notify.h