]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
rgw/posix: start the Inotify thread last, after the rest is built 69233/head
authorKefu Chai <k.chai@proxmox.com>
Tue, 2 Jun 2026 07:48:41 +0000 (15:48 +0800)
committerKefu Chai <k.chai@proxmox.com>
Tue, 2 Jun 2026 08:45:19 +0000 (16:45 +0800)
commit1d6e6b821e56235ffb0f6145160ac7beef67ad27
treee0d8f83e83ede59cfc8a59dc19988456439a4bf7
parent82ff35794af071654368347426879519f3aff266
rgw/posix: start the Inotify thread last, after the rest is built

f62e811f9ef fixed the wfd/efd init-order race but missed a sibling: thrd
was still declared before map_mutex, the watch maps and the shutdown flag.
Members come up in declaration order, so building thrd kicks off ev_loop()
while those are still uninitialized.

That is bad news, because ev_loop() reads shutdown and, when an event
arrives, locks map_mutex and pokes at the maps. Doing any of that before
they are constructed is undefined behavior: reading the shutdown atomic
before its initializer has even stored false, or locking a std::mutex that
does not exist yet. Making shutdown a std::atomic<bool> made concurrent
access well-defined, but that does not help if the load happens before the
object is constructed.

So just declare thrd last, and the thread will not start until everything
it touches is ready. wfd/efd stay ahead of it, so the earlier fix still
holds.

helgrind caught the shutdown read in ev_loop() racing its own initializer
in the constructor.

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