/* SPDX-License-Identifier: GPL-2.0-or-later */ /* General netfs cache on cache files internal defs * * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com)
*/
enum cachefiles_content { /* These values are saved on disk */
CACHEFILES_CONTENT_NO_DATA = 0, /* No content stored */
CACHEFILES_CONTENT_SINGLE = 1, /* Content is monolithic, all is present */
CACHEFILES_CONTENT_ALL = 2, /* Content is all present, no map */
CACHEFILES_CONTENT_BACKFS_MAP = 3, /* Content is piecemeal, mapped through backing fs */
CACHEFILES_CONTENT_DIRTY = 4, /* Content is dirty (only seen on disk) */
nr__cachefiles_content
};
enum cachefiles_object_state {
CACHEFILES_ONDEMAND_OBJSTATE_CLOSE, /* Anonymous fd closed by daemon or initial state */
CACHEFILES_ONDEMAND_OBJSTATE_OPEN, /* Anonymous fd associated with object is available */
CACHEFILES_ONDEMAND_OBJSTATE_REOPENING, /* Object that was closed and is being reopened. */
CACHEFILES_ONDEMAND_OBJSTATE_DROPPING, /* Object is being dropped. */
};
/* * Backing file state.
*/ struct cachefiles_object { struct fscache_cookie *cookie; /* Netfs data storage object cookie */ struct cachefiles_volume *volume; /* Cache volume that holds this object */ struct list_head cache_link; /* Link in cache->*_list */ struct file *file; /* The file representing this object */ char *d_name; /* Backing file name */ int debug_id;
spinlock_t lock;
refcount_t ref; enum cachefiles_content content_info:8; /* Info about content presence */ unsignedlong flags; #define CACHEFILES_OBJECT_USING_TMPFILE 0/* Have an unlinked tmpfile */ #ifdef CONFIG_CACHEFILES_ONDEMAND struct cachefiles_ondemand_info *ondemand; #endif
};
#define CACHEFILES_ONDEMAND_ID_CLOSED -1
/* * Cache files cache definition
*/ struct cachefiles_cache { struct fscache_cache *cache; /* Cache cookie */ struct vfsmount *mnt; /* mountpoint holding the cache */ struct dentry *store; /* Directory into which live objects go */ struct dentry *graveyard; /* directory into which dead objects go */ struct file *cachefilesd; /* manager daemon handle */ struct list_head volumes; /* List of volume objects */ struct list_head object_list; /* List of active objects */
spinlock_t object_list_lock; /* Lock for volumes and object_list */ conststruct cred *cache_cred; /* security override for accessing cache */ struct mutex daemon_mutex; /* command serialisation mutex */
wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
atomic_t gravecounter; /* graveyard uniquifier */
atomic_t f_released; /* number of objects released lately */
atomic_long_t b_released; /* number of blocks released lately */
atomic_long_t b_writing; /* Number of blocks being written */ unsigned frun_percent; /* when to stop culling (% files) */ unsigned fcull_percent; /* when to start culling (% files) */ unsigned fstop_percent; /* when to stop allocating (% files) */ unsigned brun_percent; /* when to stop culling (% blocks) */ unsigned bcull_percent; /* when to start culling (% blocks) */ unsigned bstop_percent; /* when to stop allocating (% blocks) */ unsigned bsize; /* cache's block size */ unsigned bshift; /* ilog2(bsize) */
uint64_t frun; /* when to stop culling */
uint64_t fcull; /* when to start culling */
uint64_t fstop; /* when to stop allocating */
sector_t brun; /* when to stop culling */
sector_t bcull; /* when to start culling */
sector_t bstop; /* when to stop allocating */ unsignedlong flags; #define CACHEFILES_READY 0/* T if cache prepared */ #define CACHEFILES_DEAD 1/* T if cache dead */ #define CACHEFILES_CULLING 2/* T if cull engaged */ #define CACHEFILES_STATE_CHANGED 3/* T if state changed (poll trigger) */ #define CACHEFILES_ONDEMAND_MODE 4/* T if in on-demand read mode */ char *rootdirname; /* name of cache root directory */ char *tag; /* cache binding tag */
refcount_t unbind_pincount;/* refcount to do daemon unbind */ struct xarray reqs; /* xarray of pending on-demand requests */ unsignedlong req_id_next; struct xarray ondemand_ids; /* xarray for ondemand_id allocation */
u32 ondemand_id_next;
u32 msg_id_next;
u32 secid; /* LSM security id */ bool have_secid; /* whether "secid" was set */
};
#define ASSERT(X) \ do { \ if (unlikely(!(X))) { \
pr_err("\n"); \
pr_err("Assertion failed\n"); \
BUG(); \
} \
} while (0)
#define ASSERTCMP(X, OP, Y) \ do { \ if (unlikely(!((X) OP (Y)))) { \
pr_err("\n"); \
pr_err("Assertion failed\n"); \
pr_err("%lx "#OP" %lx is false\n", \
(unsignedlong)(X), (unsignedlong)(Y)); \
BUG(); \
} \
} while (0)
#define ASSERTIF(C, X) \ do { \ if (unlikely((C) && !(X))) { \
pr_err("\n"); \
pr_err("Assertion failed\n"); \
BUG(); \
} \
} while (0)
#define ASSERTIFCMP(C, X, OP, Y) \ do { \ if (unlikely((C) && !((X) OP (Y)))) { \
pr_err("\n"); \
pr_err("Assertion failed\n"); \
pr_err("%lx "#OP" %lx is false\n", \
(unsignedlong)(X), (unsignedlong)(Y)); \
BUG(); \
} \
} while (0)
#else
#define ASSERT(X) do {} while (0) #define ASSERTCMP(X, OP, Y) do {} while (0) #define ASSERTIF(C, X) do {} while (0) #define ASSERTIFCMP(C, X, OP, Y) do {} while (0)
#endif
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.