1 // SPDX-License-Identifier: LGPL-2.1
3 * fs/cifs/cache.c - CIFS filesystem cache index structure definitions
5 * Copyright (c) 2010 Novell, Inc.
6 * Authors(s): Suresh Jayaraman (sjayaraman@suse.de>
10 #include "cifs_debug.h"
13 * CIFS filesystem definition for FS-Cache
15 struct fscache_netfs cifs_fscache_netfs = {
21 * Register CIFS for caching with FS-Cache
23 int cifs_fscache_register(void)
25 return fscache_register_netfs(&cifs_fscache_netfs);
29 * Unregister CIFS for caching
31 void cifs_fscache_unregister(void)
33 fscache_unregister_netfs(&cifs_fscache_netfs);
37 * Server object for FS-Cache
39 const struct fscache_cookie_def cifs_fscache_server_index_def = {
40 .name = "CIFS.server",
41 .type = FSCACHE_COOKIE_TYPE_INDEX,
45 fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
50 struct cifs_fscache_super_auxdata auxdata;
51 const struct cifs_tcon *tcon = cookie_netfs_data;
53 if (datalen != sizeof(auxdata))
54 return FSCACHE_CHECKAUX_OBSOLETE;
56 memset(&auxdata, 0, sizeof(auxdata));
57 auxdata.resource_id = tcon->resource_id;
58 auxdata.vol_create_time = tcon->vol_create_time;
59 auxdata.vol_serial_number = tcon->vol_serial_number;
61 if (memcmp(data, &auxdata, datalen) != 0)
62 return FSCACHE_CHECKAUX_OBSOLETE;
64 return FSCACHE_CHECKAUX_OKAY;
68 * Superblock object for FS-Cache
70 const struct fscache_cookie_def cifs_fscache_super_index_def = {
72 .type = FSCACHE_COOKIE_TYPE_INDEX,
73 .check_aux = cifs_fscache_super_check_aux,
77 fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
82 struct cifs_fscache_inode_auxdata auxdata;
83 struct cifsInodeInfo *cifsi = cookie_netfs_data;
85 if (datalen != sizeof(auxdata))
86 return FSCACHE_CHECKAUX_OBSOLETE;
88 memset(&auxdata, 0, sizeof(auxdata));
89 auxdata.eof = cifsi->server_eof;
90 auxdata.last_write_time_sec = cifsi->vfs_inode.i_mtime.tv_sec;
91 auxdata.last_change_time_sec = cifsi->vfs_inode.i_ctime.tv_sec;
92 auxdata.last_write_time_nsec = cifsi->vfs_inode.i_mtime.tv_nsec;
93 auxdata.last_change_time_nsec = cifsi->vfs_inode.i_ctime.tv_nsec;
95 if (memcmp(data, &auxdata, datalen) != 0)
96 return FSCACHE_CHECKAUX_OBSOLETE;
98 return FSCACHE_CHECKAUX_OKAY;
101 const struct fscache_cookie_def cifs_fscache_inode_object_def = {
102 .name = "CIFS.uniqueid",
103 .type = FSCACHE_COOKIE_TYPE_DATAFILE,
104 .check_aux = cifs_fscache_inode_check_aux,