FS-Cache: Add netfs registration
Add functions to register and unregister a network filesystem or other client
of the FS-Cache service. This allocates and releases the cookie representing
the top-level index for a netfs, and makes it available to the netfs.
If the FS-Cache facility is disabled, then the calls are optimised away at
compile time.
Note that whilst this patch may appear to work with FS-Cache enabled and a
netfs attempting to use it, it will leak the cookie it allocates for the netfs
as fscache_relinquish_cookie() is implemented in a later patch. This will
cause the slab code to emit a warning when the module is removed.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Steve Dickson <steved@redhat.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Tested-by: Daire Byrne <Daire.Byrne@framestore.com>
diff --git a/include/linux/fscache.h b/include/linux/fscache.h
index 9584c09..b195c2e 100644
--- a/include/linux/fscache.h
+++ b/include/linux/fscache.h
@@ -173,6 +173,8 @@
* - these are undefined symbols when FS-Cache is not configured and the
* optimiser takes care of not using them
*/
+extern int __fscache_register_netfs(struct fscache_netfs *);
+extern void __fscache_unregister_netfs(struct fscache_netfs *);
extern struct fscache_cache_tag *__fscache_lookup_cache_tag(const char *);
extern void __fscache_release_cache_tag(struct fscache_cache_tag *);
@@ -188,7 +190,10 @@
static inline
int fscache_register_netfs(struct fscache_netfs *netfs)
{
- return 0;
+ if (fscache_available())
+ return __fscache_register_netfs(netfs);
+ else
+ return 0;
}
/**
@@ -205,6 +210,8 @@
static inline
void fscache_unregister_netfs(struct fscache_netfs *netfs)
{
+ if (fscache_available())
+ __fscache_unregister_netfs(netfs);
}
/**