2019-05-27 06:55:01 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2007-04-26 22:55:03 +00:00
|
|
|
/* AFS caching stuff
|
|
|
|
*
|
2009-04-03 15:42:41 +00:00
|
|
|
* Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
|
2007-04-26 22:55:03 +00:00
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*/
|
|
|
|
|
2009-04-03 15:42:41 +00:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
|
|
|
|
const void *buffer,
|
2018-04-04 12:41:28 +00:00
|
|
|
uint16_t buflen,
|
|
|
|
loff_t object_size);
|
2009-04-03 15:42:41 +00:00
|
|
|
|
|
|
|
struct fscache_netfs afs_cache_netfs = {
|
|
|
|
.name = "afs",
|
2018-04-04 12:41:25 +00:00
|
|
|
.version = 2,
|
2009-04-03 15:42:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct fscache_cookie_def afs_cell_cache_index_def = {
|
|
|
|
.name = "AFS.cell",
|
|
|
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fscache_cookie_def afs_volume_cache_index_def = {
|
|
|
|
.name = "AFS.volume",
|
|
|
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fscache_cookie_def afs_vnode_cache_index_def = {
|
2018-04-04 12:41:28 +00:00
|
|
|
.name = "AFS.vnode",
|
|
|
|
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
|
|
|
.check_aux = afs_vnode_cache_check_aux,
|
2007-04-26 22:55:03 +00:00
|
|
|
};
|
|
|
|
|
2009-04-03 15:42:41 +00:00
|
|
|
/*
|
2011-03-31 01:57:33 +00:00
|
|
|
* check that the auxiliary data indicates that the entry is still valid
|
2007-04-26 22:55:03 +00:00
|
|
|
*/
|
2009-04-03 15:42:41 +00:00
|
|
|
static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
|
|
|
|
const void *buffer,
|
2018-04-04 12:41:28 +00:00
|
|
|
uint16_t buflen,
|
|
|
|
loff_t object_size)
|
2007-04-26 22:55:03 +00:00
|
|
|
{
|
2009-04-03 15:42:41 +00:00
|
|
|
struct afs_vnode *vnode = cookie_netfs_data;
|
2017-11-02 15:27:47 +00:00
|
|
|
struct afs_vnode_cache_aux aux;
|
2009-04-03 15:42:41 +00:00
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
_enter("{%llx,%x,%llx},%p,%u",
|
2009-04-03 15:42:41 +00:00
|
|
|
vnode->fid.vnode, vnode->fid.unique, vnode->status.data_version,
|
|
|
|
buffer, buflen);
|
|
|
|
|
2017-11-02 15:27:47 +00:00
|
|
|
memcpy(&aux, buffer, sizeof(aux));
|
|
|
|
|
2009-04-03 15:42:41 +00:00
|
|
|
/* check the size of the data is what we're expecting */
|
2017-11-02 15:27:47 +00:00
|
|
|
if (buflen != sizeof(aux)) {
|
|
|
|
_leave(" = OBSOLETE [len %hx != %zx]", buflen, sizeof(aux));
|
2009-04-03 15:42:41 +00:00
|
|
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
2007-04-26 22:55:03 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 15:27:47 +00:00
|
|
|
if (vnode->status.data_version != aux.data_version) {
|
2009-04-03 15:42:41 +00:00
|
|
|
_leave(" = OBSOLETE [vers %llx != %llx]",
|
2017-11-02 15:27:47 +00:00
|
|
|
aux.data_version, vnode->status.data_version);
|
2009-04-03 15:42:41 +00:00
|
|
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
2007-04-26 22:55:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_leave(" = SUCCESS");
|
2009-04-03 15:42:41 +00:00
|
|
|
return FSCACHE_CHECKAUX_OKAY;
|
2007-04-26 22:55:03 +00:00
|
|
|
}
|