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