1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
8 #include <linux/sched.h>
11 static enum fscache_checkaux
afs_vnode_cache_check_aux(void *cookie_netfs_data
,
16 struct fscache_netfs afs_cache_netfs
= {
21 struct fscache_cookie_def afs_cell_cache_index_def
= {
23 .type
= FSCACHE_COOKIE_TYPE_INDEX
,
26 struct fscache_cookie_def afs_volume_cache_index_def
= {
28 .type
= FSCACHE_COOKIE_TYPE_INDEX
,
31 struct fscache_cookie_def afs_vnode_cache_index_def
= {
33 .type
= FSCACHE_COOKIE_TYPE_DATAFILE
,
34 .check_aux
= afs_vnode_cache_check_aux
,
38 * check that the auxiliary data indicates that the entry is still valid
40 static enum fscache_checkaux
afs_vnode_cache_check_aux(void *cookie_netfs_data
,
45 struct afs_vnode
*vnode
= cookie_netfs_data
;
46 struct afs_vnode_cache_aux aux
;
48 _enter("{%llx,%x,%llx},%p,%u",
49 vnode
->fid
.vnode
, vnode
->fid
.unique
, vnode
->status
.data_version
,
52 memcpy(&aux
, buffer
, sizeof(aux
));
54 /* check the size of the data is what we're expecting */
55 if (buflen
!= sizeof(aux
)) {
56 _leave(" = OBSOLETE [len %hx != %zx]", buflen
, sizeof(aux
));
57 return FSCACHE_CHECKAUX_OBSOLETE
;
60 if (vnode
->status
.data_version
!= aux
.data_version
) {
61 _leave(" = OBSOLETE [vers %llx != %llx]",
62 aux
.data_version
, vnode
->status
.data_version
);
63 return FSCACHE_CHECKAUX_OBSOLETE
;
67 return FSCACHE_CHECKAUX_OKAY
;