1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* General filesystem caching backing cache interface 3 * 4 * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells ([email protected]) 6 * 7 * NOTE!!! See: 8 * 9 * Documentation/filesystems/caching/backend-api.rst 10 * 11 * for a description of the cache backend interface declared here. 12 */ 13 14 #ifndef _LINUX_FSCACHE_CACHE_H 15 #define _LINUX_FSCACHE_CACHE_H 16 17 #include <linux/fscache.h> 18 19 enum fscache_cache_trace; 20 enum fscache_access_trace; 21 22 enum fscache_cache_state { 23 FSCACHE_CACHE_IS_NOT_PRESENT, /* No cache is present for this name */ 24 FSCACHE_CACHE_IS_PREPARING, /* A cache is preparing to come live */ 25 FSCACHE_CACHE_IS_ACTIVE, /* Attached cache is active and can be used */ 26 FSCACHE_CACHE_GOT_IOERROR, /* Attached cache stopped on I/O error */ 27 FSCACHE_CACHE_IS_WITHDRAWN, /* Attached cache is being withdrawn */ 28 #define NR__FSCACHE_CACHE_STATE (FSCACHE_CACHE_IS_WITHDRAWN + 1) 29 }; 30 31 /* 32 * Cache cookie. 33 */ 34 struct fscache_cache { 35 struct list_head cache_link; /* Link in cache list */ 36 void *cache_priv; /* Private cache data (or NULL) */ 37 refcount_t ref; 38 atomic_t n_volumes; /* Number of active volumes; */ 39 atomic_t n_accesses; /* Number of in-progress accesses on the cache */ 40 atomic_t object_count; /* no. of live objects in this cache */ 41 unsigned int debug_id; 42 enum fscache_cache_state state; 43 char *name; 44 }; 45 46 extern struct workqueue_struct *fscache_wq; 47 48 /* 49 * out-of-line cache backend functions 50 */ 51 extern struct rw_semaphore fscache_addremove_sem; 52 extern struct fscache_cache *fscache_acquire_cache(const char *name); 53 extern void fscache_relinquish_cache(struct fscache_cache *cache); 54 55 #endif /* _LINUX_FSCACHE_CACHE_H */ 56