Blame view

fs/afs/cache.c 1.79 KB
2874c5fd2   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
2
3
  /* AFS caching stuff
   *
9b3f26c91   David Howells   FS-Cache: Make kA...
4
   * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
5
   * Written by David Howells (dhowells@redhat.com)
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
6
   */
9b3f26c91   David Howells   FS-Cache: Make kA...
7
8
  #include <linux/sched.h>
  #include "internal.h"
9b3f26c91   David Howells   FS-Cache: Make kA...
9
10
  static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
  						       const void *buffer,
ee1235a9a   David Howells   fscache: Pass obj...
11
12
  						       uint16_t buflen,
  						       loff_t object_size);
9b3f26c91   David Howells   FS-Cache: Make kA...
13
14
15
  
  struct fscache_netfs afs_cache_netfs = {
  	.name			= "afs",
27a3ee3a0   David Howells   afs: Use the vnod...
16
  	.version		= 2,
9b3f26c91   David Howells   FS-Cache: Make kA...
17
18
19
20
21
  };
  
  struct fscache_cookie_def afs_cell_cache_index_def = {
  	.name		= "AFS.cell",
  	.type		= FSCACHE_COOKIE_TYPE_INDEX,
9b3f26c91   David Howells   FS-Cache: Make kA...
22
23
24
25
26
  };
  
  struct fscache_cookie_def afs_volume_cache_index_def = {
  	.name		= "AFS.volume",
  	.type		= FSCACHE_COOKIE_TYPE_INDEX,
9b3f26c91   David Howells   FS-Cache: Make kA...
27
28
29
  };
  
  struct fscache_cookie_def afs_vnode_cache_index_def = {
402cb8dda   David Howells   fscache: Attach t...
30
31
  	.name		= "AFS.vnode",
  	.type		= FSCACHE_COOKIE_TYPE_DATAFILE,
402cb8dda   David Howells   fscache: Attach t...
32
  	.check_aux	= afs_vnode_cache_check_aux,
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
33
  };
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
34
35
  
  /*
25985edce   Lucas De Marchi   Fix common misspe...
36
   * check that the auxiliary data indicates that the entry is still valid
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
37
   */
9b3f26c91   David Howells   FS-Cache: Make kA...
38
39
  static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
  						       const void *buffer,
ee1235a9a   David Howells   fscache: Pass obj...
40
41
  						       uint16_t buflen,
  						       loff_t object_size)
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
42
  {
9b3f26c91   David Howells   FS-Cache: Make kA...
43
  	struct afs_vnode *vnode = cookie_netfs_data;
ad6a942a9   David Howells   afs: Update the c...
44
  	struct afs_vnode_cache_aux aux;
9b3f26c91   David Howells   FS-Cache: Make kA...
45

3b6492df4   David Howells   afs: Increase to ...
46
  	_enter("{%llx,%x,%llx},%p,%u",
9b3f26c91   David Howells   FS-Cache: Make kA...
47
48
  	       vnode->fid.vnode, vnode->fid.unique, vnode->status.data_version,
  	       buffer, buflen);
ad6a942a9   David Howells   afs: Update the c...
49
  	memcpy(&aux, buffer, sizeof(aux));
9b3f26c91   David Howells   FS-Cache: Make kA...
50
  	/* check the size of the data is what we're expecting */
ad6a942a9   David Howells   afs: Update the c...
51
52
  	if (buflen != sizeof(aux)) {
  		_leave(" = OBSOLETE [len %hx != %zx]", buflen, sizeof(aux));
9b3f26c91   David Howells   FS-Cache: Make kA...
53
  		return FSCACHE_CHECKAUX_OBSOLETE;
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
54
  	}
ad6a942a9   David Howells   afs: Update the c...
55
  	if (vnode->status.data_version != aux.data_version) {
9b3f26c91   David Howells   FS-Cache: Make kA...
56
  		_leave(" = OBSOLETE [vers %llx != %llx]",
ad6a942a9   David Howells   afs: Update the c...
57
  		       aux.data_version, vnode->status.data_version);
9b3f26c91   David Howells   FS-Cache: Make kA...
58
  		return FSCACHE_CHECKAUX_OBSOLETE;
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
59
60
61
  	}
  
  	_leave(" = SUCCESS");
9b3f26c91   David Howells   FS-Cache: Make kA...
62
  	return FSCACHE_CHECKAUX_OKAY;
08e0e7c82   David Howells   [AF_RXRPC]: Make ...
63
  }