From 97c34b3071a2a88e089f3123f01865b6e4d07fdd Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 5 Jul 2018 22:43:33 -0400 Subject: [PATCH] fd-tracker: add an optimization note to the fd-tracker MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/common/fd-tracker/fd-tracker.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/common/fd-tracker/fd-tracker.c b/src/common/fd-tracker/fd-tracker.c index 2f743be94..e26ff2185 100644 --- a/src/common/fd-tracker/fd-tracker.c +++ b/src/common/fd-tracker/fd-tracker.c @@ -754,6 +754,17 @@ int fs_handle_get_fd(struct fs_handle *handle) { int ret; + /* + * TODO This should be optimized as it is a fairly hot path. + * The fd-tracker's lock should only be taken when a fs_handle is + * restored (slow path). On the fast path (fs_handle is active), + * the only effect on the fd_tracker is marking the handle as the + * most recently used. Currently, it is done by a call to the + * track/untrack helpers, but it should be done atomically. + * + * Note that the lock's nesting order must still be respected here. + * The handle's lock nests inside the tracker's lock. + */ pthread_mutex_lock(&handle->tracker->lock); pthread_mutex_lock(&handle->lock); assert(!handle->in_use); -- 2.34.1