2007-04-27 02:55:03 +04:00
|
|
|
/* AFS caching stuff
|
|
|
|
*
|
2009-04-03 19:42:41 +04:00
|
|
|
* Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
|
2007-04-27 02:55:03 +04:00
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2009-04-03 19:42:41 +04: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 15:41:28 +03:00
|
|
|
uint16_t buflen,
|
|
|
|
loff_t object_size);
|
2009-04-03 19:42:41 +04:00
|
|
|
|
|
|
|
struct fscache_netfs afs_cache_netfs = {
|
|
|
|
.name = "afs",
|
2018-04-04 15:41:25 +03:00
|
|
|
.version = 2,
|
2009-04-03 19:42:41 +04: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 15:41:28 +03:00
|
|
|
.name = "AFS.vnode",
|
|
|
|
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
|
|
|
.check_aux = afs_vnode_cache_check_aux,
|
2007-04-27 02:55:03 +04:00
|
|
|
};
|
|
|
|
|
2009-04-03 19:42:41 +04:00
|
|
|
/*
|
2011-03-31 05:57:33 +04:00
|
|
|
* check that the auxiliary data indicates that the entry is still valid
|
2007-04-27 02:55:03 +04:00
|
|
|
*/
|
2009-04-03 19:42:41 +04:00
|
|
|
static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
|
|
|
|
const void *buffer,
|
2018-04-04 15:41:28 +03:00
|
|
|
uint16_t buflen,
|
|
|
|
loff_t object_size)
|
2007-04-27 02:55:03 +04:00
|
|
|
{
|
2009-04-03 19:42:41 +04:00
|
|
|
struct afs_vnode *vnode = cookie_netfs_data;
|
2017-11-02 18:27:47 +03:00
|
|
|
struct afs_vnode_cache_aux aux;
|
2009-04-03 19:42:41 +04:00
|
|
|
|
|
|
|
_enter("{%x,%x,%llx},%p,%u",
|
|
|
|
vnode->fid.vnode, vnode->fid.unique, vnode->status.data_version,
|
|
|
|
buffer, buflen);
|
|
|
|
|
2017-11-02 18:27:47 +03:00
|
|
|
memcpy(&aux, buffer, sizeof(aux));
|
|
|
|
|
2009-04-03 19:42:41 +04:00
|
|
|
/* check the size of the data is what we're expecting */
|
2017-11-02 18:27:47 +03:00
|
|
|
if (buflen != sizeof(aux)) {
|
|
|
|
_leave(" = OBSOLETE [len %hx != %zx]", buflen, sizeof(aux));
|
2009-04-03 19:42:41 +04:00
|
|
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
2007-04-27 02:55:03 +04:00
|
|
|
}
|
|
|
|
|
2017-11-02 18:27:47 +03:00
|
|
|
if (vnode->status.data_version != aux.data_version) {
|
2009-04-03 19:42:41 +04:00
|
|
|
_leave(" = OBSOLETE [vers %llx != %llx]",
|
2017-11-02 18:27:47 +03:00
|
|
|
aux.data_version, vnode->status.data_version);
|
2009-04-03 19:42:41 +04:00
|
|
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
2007-04-27 02:55:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
_leave(" = SUCCESS");
|
2009-04-03 19:42:41 +04:00
|
|
|
return FSCACHE_CHECKAUX_OKAY;
|
2007-04-27 02:55:03 +04:00
|
|
|
}
|