123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #define FSCACHE_DEBUG_LEVEL CACHE
- #include <linux/module.h>
- #include "internal.h"
- static uint16_t fscache_fsdef_netfs_get_key(const void *cookie_netfs_data,
- void *buffer, uint16_t bufmax);
- static uint16_t fscache_fsdef_netfs_get_aux(const void *cookie_netfs_data,
- void *buffer, uint16_t bufmax);
- static
- enum fscache_checkaux fscache_fsdef_netfs_check_aux(void *cookie_netfs_data,
- const void *data,
- uint16_t datalen);
- static struct fscache_cookie_def fscache_fsdef_index_def = {
- .name = ".FS-Cache",
- .type = FSCACHE_COOKIE_TYPE_INDEX,
- };
- struct fscache_cookie fscache_fsdef_index = {
- .usage = ATOMIC_INIT(1),
- .n_active = ATOMIC_INIT(1),
- .lock = __SPIN_LOCK_UNLOCKED(fscache_fsdef_index.lock),
- .backing_objects = HLIST_HEAD_INIT,
- .def = &fscache_fsdef_index_def,
- .flags = 1 << FSCACHE_COOKIE_ENABLED,
- };
- EXPORT_SYMBOL(fscache_fsdef_index);
- struct fscache_cookie_def fscache_fsdef_netfs_def = {
- .name = "FSDEF.netfs",
- .type = FSCACHE_COOKIE_TYPE_INDEX,
- .get_key = fscache_fsdef_netfs_get_key,
- .get_aux = fscache_fsdef_netfs_get_aux,
- .check_aux = fscache_fsdef_netfs_check_aux,
- };
- static uint16_t fscache_fsdef_netfs_get_key(const void *cookie_netfs_data,
- void *buffer, uint16_t bufmax)
- {
- const struct fscache_netfs *netfs = cookie_netfs_data;
- unsigned klen;
- _enter("{%s.%u},", netfs->name, netfs->version);
- klen = strlen(netfs->name);
- if (klen > bufmax)
- return 0;
- memcpy(buffer, netfs->name, klen);
- return klen;
- }
- static uint16_t fscache_fsdef_netfs_get_aux(const void *cookie_netfs_data,
- void *buffer, uint16_t bufmax)
- {
- const struct fscache_netfs *netfs = cookie_netfs_data;
- unsigned dlen;
- _enter("{%s.%u},", netfs->name, netfs->version);
- dlen = sizeof(uint32_t);
- if (dlen > bufmax)
- return 0;
- memcpy(buffer, &netfs->version, dlen);
- return dlen;
- }
- static enum fscache_checkaux fscache_fsdef_netfs_check_aux(
- void *cookie_netfs_data,
- const void *data,
- uint16_t datalen)
- {
- struct fscache_netfs *netfs = cookie_netfs_data;
- uint32_t version;
- _enter("{%s},,%hu", netfs->name, datalen);
- if (datalen != sizeof(version)) {
- _leave(" = OBSOLETE [dl=%d v=%zu]", datalen, sizeof(version));
- return FSCACHE_CHECKAUX_OBSOLETE;
- }
- memcpy(&version, data, sizeof(version));
- if (version != netfs->version) {
- _leave(" = OBSOLETE [ver=%x net=%x]", version, netfs->version);
- return FSCACHE_CHECKAUX_OBSOLETE;
- }
- _leave(" = OKAY");
- return FSCACHE_CHECKAUX_OKAY;
- }
|