linux/include/linux/fscache-cache.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/* General filesystem caching backing cache interface
 *
 * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells ([email protected])
 *
 * NOTE!!! See:
 *
 *	Documentation/filesystems/caching/backend-api.rst
 *
 * for a description of the cache backend interface declared here.
 */

#ifndef _LINUX_FSCACHE_CACHE_H
#define _LINUX_FSCACHE_CACHE_H

#include <linux/fscache.h>

enum fscache_cache_trace;
enum fscache_cookie_trace;
enum fscache_access_trace;
enum fscache_volume_trace;

enum fscache_cache_state {};

/*
 * Cache cookie.
 */
struct fscache_cache {};

/*
 * cache operations
 */
struct fscache_cache_ops {};

extern struct workqueue_struct *fscache_wq;
extern wait_queue_head_t fscache_clearance_waiters;

/*
 * out-of-line cache backend functions
 */
extern struct rw_semaphore fscache_addremove_sem;
extern struct fscache_cache *fscache_acquire_cache(const char *name);
extern void fscache_relinquish_cache(struct fscache_cache *cache);
extern int fscache_add_cache(struct fscache_cache *cache,
			     const struct fscache_cache_ops *ops,
			     void *cache_priv);
extern void fscache_withdraw_cache(struct fscache_cache *cache);
extern void fscache_withdraw_volume(struct fscache_volume *volume);
extern void fscache_withdraw_cookie(struct fscache_cookie *cookie);

extern void fscache_io_error(struct fscache_cache *cache);

extern struct fscache_volume *
fscache_try_get_volume(struct fscache_volume *volume,
		       enum fscache_volume_trace where);
extern void fscache_put_volume(struct fscache_volume *volume,
			       enum fscache_volume_trace where);
extern void fscache_end_volume_access(struct fscache_volume *volume,
				      struct fscache_cookie *cookie,
				      enum fscache_access_trace why);

extern struct fscache_cookie *fscache_get_cookie(struct fscache_cookie *cookie,
						 enum fscache_cookie_trace where);
extern void fscache_put_cookie(struct fscache_cookie *cookie,
			       enum fscache_cookie_trace where);
extern void fscache_end_cookie_access(struct fscache_cookie *cookie,
				      enum fscache_access_trace why);
extern void fscache_cookie_lookup_negative(struct fscache_cookie *cookie);
extern void fscache_resume_after_invalidation(struct fscache_cookie *cookie);
extern void fscache_caching_failed(struct fscache_cookie *cookie);
extern bool fscache_wait_for_operation(struct netfs_cache_resources *cred,
				       enum fscache_want_state state);

/**
 * fscache_cookie_state - Read the state of a cookie
 * @cookie: The cookie to query
 *
 * Get the state of a cookie, imposing an ordering between the cookie contents
 * and the state value.  Paired with fscache_set_cookie_state().
 */
static inline
enum fscache_cookie_state fscache_cookie_state(struct fscache_cookie *cookie)
{}

/**
 * fscache_get_key - Get a pointer to the cookie key
 * @cookie: The cookie to query
 *
 * Return a pointer to the where a cookie's key is stored.
 */
static inline void *fscache_get_key(struct fscache_cookie *cookie)
{}

static inline struct fscache_cookie *fscache_cres_cookie(struct netfs_cache_resources *cres)
{}

/**
 * fscache_count_object - Tell fscache that an object has been added
 * @cache: The cache to account to
 *
 * Tell fscache that an object has been added to the cache.  This prevents the
 * cache from tearing down the cache structure until the object is uncounted.
 */
static inline void fscache_count_object(struct fscache_cache *cache)
{}

/**
 * fscache_uncount_object - Tell fscache that an object has been removed
 * @cache: The cache to account to
 *
 * Tell fscache that an object has been removed from the cache and will no
 * longer be accessed.  After this point, the cache cookie may be destroyed.
 */
static inline void fscache_uncount_object(struct fscache_cache *cache)
{}

/**
 * fscache_wait_for_objects - Wait for all objects to be withdrawn
 * @cache: The cache to query
 *
 * Wait for all extant objects in a cache to finish being withdrawn
 * and go away.
 */
static inline void fscache_wait_for_objects(struct fscache_cache *cache)
{}

#ifdef CONFIG_FSCACHE_STATS
extern atomic_t fscache_n_read;
extern atomic_t fscache_n_write;
extern atomic_t fscache_n_no_write_space;
extern atomic_t fscache_n_no_create_space;
extern atomic_t fscache_n_culled;
extern atomic_t fscache_n_dio_misfit;
#define fscache_count_read()
#define fscache_count_write()
#define fscache_count_no_write_space()
#define fscache_count_no_create_space()
#define fscache_count_culled()
#define fscache_count_dio_misfit()
#else
#define fscache_count_read
#define fscache_count_write
#define fscache_count_no_write_space
#define fscache_count_no_create_space
#define fscache_count_culled
#define fscache_count_dio_misfit
#endif

#endif /* _LINUX_FSCACHE_CACHE_H */