X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fafs%2Fvolume.c;h=0bd557825a32350a0ae28fe7c9f31a59db255f76;hb=38177f0d626d937b43898550494220fe2b044289;hp=4ebdb2d50b769455d2086e934dc4bb4859de7e72;hpb=daddc0d38b3571bed170afa273a49a0eba090c1e;p=linux-2.6.git diff --git a/fs/afs/volume.c b/fs/afs/volume.c index 4ebdb2d50..0bd557825 100644 --- a/fs/afs/volume.c +++ b/fs/afs/volume.c @@ -15,29 +15,27 @@ #include #include #include +#include #include "volume.h" #include "vnode.h" #include "cell.h" -#include "cache.h" #include "cmservice.h" #include "fsclient.h" #include "vlclient.h" #include "internal.h" -const char *afs_voltypes[] = { "R/W", "R/O", "BAK" }; +#ifdef __KDEBUG +static const char *afs_voltypes[] = { "R/W", "R/O", "BAK" }; +#endif -#ifdef AFS_CACHING_SUPPORT -static cachefs_match_val_t afs_volume_cache_match(void *target, - const void *entry); -static void afs_volume_cache_update(void *source, void *entry); +#ifdef CONFIG_AFS_FSCACHE +static uint16_t afs_volume_cache_get_key(const void *cookie_netfs_data, + void *buffer, uint16_t buflen); -struct cachefs_index_def afs_volume_cache_index_def = { - .name = "volume", - .data_size = sizeof(struct afs_cache_vhash), - .keys[0] = { CACHEFS_INDEX_KEYS_BIN, 1 }, - .keys[1] = { CACHEFS_INDEX_KEYS_BIN, 1 }, - .match = afs_volume_cache_match, - .update = afs_volume_cache_update, +static struct fscache_cookie_def afs_volume_cache_index_def = { + .name = "AFS.volume", + .type = FSCACHE_COOKIE_TYPE_INDEX, + .get_key = afs_volume_cache_get_key, }; #endif @@ -212,11 +210,10 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, } /* attach the cache and volume location */ -#ifdef AFS_CACHING_SUPPORT - cachefs_acquire_cookie(vlocation->cache, - &afs_vnode_cache_index_def, - volume, - &volume->cache); +#ifdef CONFIG_AFS_FSCACHE + volume->cache = fscache_acquire_cookie(vlocation->cache, + &afs_volume_cache_index_def, + volume); #endif afs_get_vlocation(vlocation); @@ -284,8 +281,8 @@ void afs_put_volume(struct afs_volume *volume) up_write(&vlocation->cell->vl_sem); /* finish cleaning up the volume */ -#ifdef AFS_CACHING_SUPPORT - cachefs_relinquish_cookie(volume->cache, 0); +#ifdef CONFIG_AFS_FSCACHE + fscache_relinquish_cookie(volume->cache, 0); #endif afs_put_vlocation(vlocation); @@ -479,40 +476,25 @@ int afs_volume_release_fileserver(struct afs_volume *volume, /*****************************************************************************/ /* - * match a volume hash record stored in the cache + * set the key for the index entry */ -#ifdef AFS_CACHING_SUPPORT -static cachefs_match_val_t afs_volume_cache_match(void *target, - const void *entry) +#ifdef CONFIG_AFS_FSCACHE +static uint16_t afs_volume_cache_get_key(const void *cookie_netfs_data, + void *buffer, uint16_t bufmax) { - const struct afs_cache_vhash *vhash = entry; - struct afs_volume *volume = target; - - _enter("{%u},{%u}", volume->type, vhash->vtype); + const struct afs_volume *volume = cookie_netfs_data; + uint16_t klen; - if (volume->type == vhash->vtype) { - _leave(" = SUCCESS"); - return CACHEFS_MATCH_SUCCESS; - } - - _leave(" = FAILED"); - return CACHEFS_MATCH_FAILED; -} /* end afs_volume_cache_match() */ -#endif + _enter("{%u},%p,%u", volume->type, buffer, bufmax); -/*****************************************************************************/ -/* - * update a volume hash record stored in the cache - */ -#ifdef AFS_CACHING_SUPPORT -static void afs_volume_cache_update(void *source, void *entry) -{ - struct afs_cache_vhash *vhash = entry; - struct afs_volume *volume = source; + klen = sizeof(volume->type); + if (klen > bufmax) + return 0; - _enter(""); + memcpy(buffer, &volume->type, sizeof(volume->type)); - vhash->vtype = volume->type; + _leave(" = %u", klen); + return klen; -} /* end afs_volume_cache_update() */ +} /* end afs_volume_cache_get_key() */ #endif