/**
* Initialize the cache for use.
+ * This function should be called with a write lock on the mntent_cache.
*/
static void initialize_mntent_cache(void)
{
- /**
- * Lock the cache while we update it.
- */
- P(mntent_cache_lock);
-
/**
* Make sure the cache is empty (either by flushing it or by initializing it.)
*/
* Refresh the cache.
*/
refresh_mount_cache();
-
- /**
- * We are done updating the cache.
- */
- V(mntent_cache_lock);
}
-void flush_mntent_cache(void)
+/**
+ * Flush the current content from the cache.
+ * This function should be called with a write lock on the mntent_cache.
+ */
+static void flush_mntent_cache(void)
{
- /**
- * Lock the cache while we update it.
- */
- P(mntent_cache_lock);
-
/**
* Make sure the cache is empty (either by flushing it or by initializing it.)
*/
clear_mount_cache();
-
- /**
- * We are done updating the cache.
- */
- V(mntent_cache_lock);
}
/**
mntent_cache_entry_t *mce = NULL;
time_t now;
+ /**
+ * Lock the cache.
+ */
+ P(mntent_cache_lock);
+
/**
* Shortcut when we get a request for the same device again.
*/
if (previous_cache_hit && previous_cache_hit->dev == dev) {
- return previous_cache_hit;
+ mce = previous_cache_hit;
+ goto ok_out;
}
/**
}
}
- /**
- * Lock the cache while we walk it.
- */
- P(mntent_cache_lock);
-
mce = (mntent_cache_entry_t *)mntent_cache_entry_hashtable->lookup(dev);
/**
previous_cache_hit = mce;
}
- /**
- * We are done walking the cache.
- */
+ok_out:
V(mntent_cache_lock);
return mce;
}