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