From 845d411495e59b0206e1f440df8f4d71283539a2 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 11 Nov 2011 12:55:05 +0100 Subject: [PATCH] Move the shortcut logic up so its a real shortcut again. --- bacula/src/lib/mntent_cache.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bacula/src/lib/mntent_cache.c b/bacula/src/lib/mntent_cache.c index 2c68bdcefc..6d76239980 100644 --- a/bacula/src/lib/mntent_cache.c +++ b/bacula/src/lib/mntent_cache.c @@ -108,8 +108,11 @@ static time_t last_rescan = 0; * Add a new entry to the cache. * This function should be called with a write lock on the mntent_cache. */ -static inline void add_mntent_mapping(uint32_t dev, const char *special, const char *mountpoint, - const char *fstype, const char *mntopts) +static inline void add_mntent_mapping(uint32_t dev, + const char *special, + const char *mountpoint, + const char *fstype, + const char *mntopts) { int len; mntent_cache_entry_t *mce; @@ -395,6 +398,13 @@ mntent_cache_entry_t *find_mntent_mapping(uint32_t dev) mntent_cache_entry_t *mce = NULL; time_t now; + /** + * Shortcut when we get a request for the same device again. + */ + if (previous_cache_hit && previous_cache_hit->dev == dev) { + return previous_cache_hit; + } + /** * Initialize the cache if that was not done before. */ @@ -414,13 +424,6 @@ mntent_cache_entry_t *find_mntent_mapping(uint32_t dev) } } - /** - * Shortcut when we get a request for the same device again. - */ - if (previous_cache_hit && previous_cache_hit->dev == dev) { - return previous_cache_hit; - } - /** * Lock the cache while we walk it. */ -- 2.39.5