summaryrefslogtreecommitdiff
path: root/fs/fscache/volume.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fscache/volume.c')
-rw-r--r--fs/fscache/volume.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/fscache/volume.c b/fs/fscache/volume.c
index e1a8e92a6adb..a57c6cbee858 100644
--- a/fs/fscache/volume.c
+++ b/fs/fscache/volume.c
@@ -205,15 +205,22 @@ static struct fscache_volume *fscache_alloc_volume(const char *volume_key,
size_t klen, hlen;
char *key;
+ if (!coherency_data)
+ coherency_len = 0;
+
cache = fscache_lookup_cache(cache_name, false);
if (IS_ERR(cache))
return NULL;
- volume = kzalloc(sizeof(*volume), GFP_KERNEL);
+ volume = kzalloc(struct_size(volume, coherency, coherency_len),
+ GFP_KERNEL);
if (!volume)
goto err_cache;
volume->cache = cache;
+ volume->coherency_len = coherency_len;
+ if (coherency_data)
+ memcpy(volume->coherency, coherency_data, coherency_len);
INIT_LIST_HEAD(&volume->proc_link);
INIT_WORK(&volume->work, fscache_create_volume_work);
refcount_set(&volume->ref, 1);
@@ -421,8 +428,11 @@ void __fscache_relinquish_volume(struct fscache_volume *volume,
if (WARN_ON(test_and_set_bit(FSCACHE_VOLUME_RELINQUISHED, &volume->flags)))
return;
- if (invalidate)
+ if (invalidate) {
set_bit(FSCACHE_VOLUME_INVALIDATE, &volume->flags);
+ } else if (coherency_data) {
+ memcpy(volume->coherency, coherency_data, volume->coherency_len);
+ }
fscache_put_volume(volume, fscache_volume_put_relinquish);
}