* - 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 *);
+
+extern struct fscache_cookie *__fscache_acquire_cookie(
+ struct fscache_cookie *,
+ const struct fscache_cookie_def *,
+ void *);
+extern void __fscache_relinquish_cookie(struct fscache_cookie *, int);
+extern void __fscache_update_cookie(struct fscache_cookie *);
+extern int __fscache_attr_changed(struct fscache_cookie *);
+extern int __fscache_read_or_alloc_page(struct fscache_cookie *,
+ struct page *,
+ fscache_rw_complete_t,
+ void *,
+ gfp_t);
+extern int __fscache_read_or_alloc_pages(struct fscache_cookie *,
+ struct address_space *,
+ struct list_head *,
+ unsigned *,
+ fscache_rw_complete_t,
+ void *,
+ gfp_t);
+extern int __fscache_alloc_page(struct fscache_cookie *, struct page *, gfp_t);
+extern int __fscache_write_page(struct fscache_cookie *, struct page *, gfp_t);
+extern void __fscache_uncache_page(struct fscache_cookie *, struct page *);
+extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *);
+extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *);
+extern bool __fscache_maybe_release_page(struct fscache_cookie *, struct page *,
+ gfp_t);
/**
* fscache_register_netfs - Register a filesystem as desiring caching services
static inline
int fscache_register_netfs(struct fscache_netfs *netfs)
{
- return 0;
+ if (fscache_available())
+ return __fscache_register_netfs(netfs);
+ else
+ return 0;
}
/**
static inline
void fscache_unregister_netfs(struct fscache_netfs *netfs)
{
+ if (fscache_available())
+ __fscache_unregister_netfs(netfs);
}
/**
static inline
struct fscache_cache_tag *fscache_lookup_cache_tag(const char *name)
{
- return NULL;
+ if (fscache_available())
+ return __fscache_lookup_cache_tag(name);
+ else
+ return NULL;
}
/**
static inline
void fscache_release_cache_tag(struct fscache_cache_tag *tag)
{
+ if (fscache_available())
+ __fscache_release_cache_tag(tag);
}
/**
const struct fscache_cookie_def *def,
void *netfs_data)
{
- return NULL;
+ if (fscache_cookie_valid(parent))
+ return __fscache_acquire_cookie(parent, def, netfs_data);
+ else
+ return NULL;
}
/**
static inline
void fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
{
+ if (fscache_cookie_valid(cookie))
+ __fscache_relinquish_cookie(cookie, retire);
}
/**
static inline
void fscache_update_cookie(struct fscache_cookie *cookie)
{
+ if (fscache_cookie_valid(cookie))
+ __fscache_update_cookie(cookie);
}
/**
static inline
int fscache_attr_changed(struct fscache_cookie *cookie)
{
- return -ENOBUFS;
+ if (fscache_cookie_valid(cookie))
+ return __fscache_attr_changed(cookie);
+ else
+ return -ENOBUFS;
}
/**
void *context,
gfp_t gfp)
{
- return -ENOBUFS;
+ if (fscache_cookie_valid(cookie))
+ return __fscache_read_or_alloc_page(cookie, page, end_io_func,
+ context, gfp);
+ else
+ return -ENOBUFS;
}
/**
void *context,
gfp_t gfp)
{
- return -ENOBUFS;
+ if (fscache_cookie_valid(cookie))
+ return __fscache_read_or_alloc_pages(cookie, mapping, pages,
+ nr_pages, end_io_func,
+ context, gfp);
+ else
+ return -ENOBUFS;
}
/**
struct page *page,
gfp_t gfp)
{
- return -ENOBUFS;
+ if (fscache_cookie_valid(cookie))
+ return __fscache_alloc_page(cookie, page, gfp);
+ else
+ return -ENOBUFS;
}
/**
struct page *page,
gfp_t gfp)
{
- return -ENOBUFS;
+ if (fscache_cookie_valid(cookie))
+ return __fscache_write_page(cookie, page, gfp);
+ else
+ return -ENOBUFS;
}
/**
void fscache_uncache_page(struct fscache_cookie *cookie,
struct page *page)
{
+ if (fscache_cookie_valid(cookie))
+ __fscache_uncache_page(cookie, page);
}
/**
bool fscache_check_page_write(struct fscache_cookie *cookie,
struct page *page)
{
+ if (fscache_cookie_valid(cookie))
+ return __fscache_check_page_write(cookie, page);
return false;
}
void fscache_wait_on_page_write(struct fscache_cookie *cookie,
struct page *page)
{
+ if (fscache_cookie_valid(cookie))
+ __fscache_wait_on_page_write(cookie, page);
+}
+
+/**
+ * fscache_maybe_release_page - Consider releasing a page, cancelling a store
+ * @cookie: The cookie representing the cache object
+ * @page: The netfs page that is being cached.
+ * @gfp: The gfp flags passed to releasepage()
+ *
+ * Consider releasing a page for the vmscan algorithm, on behalf of the netfs's
+ * releasepage() call. A storage request on the page may cancelled if it is
+ * not currently being processed.
+ *
+ * The function returns true if the page no longer has a storage request on it,
+ * and false if a storage request is left in place. If true is returned, the
+ * page will have been passed to fscache_uncache_page(). If false is returned
+ * the page cannot be freed yet.
+ */
+static inline
+bool fscache_maybe_release_page(struct fscache_cookie *cookie,
+ struct page *page,
+ gfp_t gfp)
+{
+ if (fscache_cookie_valid(cookie) && PageFsCache(page))
+ return __fscache_maybe_release_page(cookie, page, gfp);
+ return false;
}
#endif /* _LINUX_FSCACHE_H */