diff options
author | David Howells <dhowells@redhat.com> | 2021-12-14 09:51:43 +0000 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2022-01-07 13:43:03 +0000 |
commit | 32e150037dce368d129996ffe5f98217b1974d9e (patch) | |
tree | e9772d127f0b309116bf5009b3eb7a8089b934a5 /fs/fscache | |
parent | 047487c947e8b96b94579c3a33207bd4e266b4c6 (diff) | |
download | linux-stable-32e150037dce368d129996ffe5f98217b1974d9e.tar.gz linux-stable-32e150037dce368d129996ffe5f98217b1974d9e.tar.bz2 linux-stable-32e150037dce368d129996ffe5f98217b1974d9e.zip |
fscache, cachefiles: Store the volume coherency data
Store the volume coherency data in an xattr and check it when we rebind the
volume. If it doesn't match the cache volume is moved to the graveyard and
rebuilt anew.
Changes
=======
ver #4:
- Remove a couple of debugging prints.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/163967164397.1823006.2950539849831291830.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021563138.640689.15851092065380543119.stgit@warthog.procyon.org.uk/ # v4
Diffstat (limited to 'fs/fscache')
-rw-r--r-- | fs/fscache/volume.c | 14 |
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); } |