2010-07-05 16:41:50 +04:00
|
|
|
/*
|
|
|
|
* fs/cifs/cache.c - CIFS filesystem cache index structure definitions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 Novell, Inc.
|
|
|
|
* Authors(s): Suresh Jayaraman (sjayaraman@suse.de>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published
|
|
|
|
* by the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
|
|
|
* the GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
#include "fscache.h"
|
2010-07-05 16:42:15 +04:00
|
|
|
#include "cifs_debug.h"
|
2010-07-05 16:41:50 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CIFS filesystem definition for FS-Cache
|
|
|
|
*/
|
|
|
|
struct fscache_netfs cifs_fscache_netfs = {
|
|
|
|
.name = "cifs",
|
|
|
|
.version = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register CIFS for caching with FS-Cache
|
|
|
|
*/
|
|
|
|
int cifs_fscache_register(void)
|
|
|
|
{
|
|
|
|
return fscache_register_netfs(&cifs_fscache_netfs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unregister CIFS for caching
|
|
|
|
*/
|
|
|
|
void cifs_fscache_unregister(void)
|
|
|
|
{
|
|
|
|
fscache_unregister_netfs(&cifs_fscache_netfs);
|
|
|
|
}
|
|
|
|
|
2010-07-05 16:42:15 +04:00
|
|
|
/*
|
|
|
|
* Server object for FS-Cache
|
|
|
|
*/
|
|
|
|
const struct fscache_cookie_def cifs_fscache_server_index_def = {
|
|
|
|
.name = "CIFS.server",
|
|
|
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
|
|
|
};
|
2010-07-05 16:42:27 +04:00
|
|
|
|
|
|
|
static enum
|
|
|
|
fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
|
|
|
|
const void *data,
|
2018-04-04 15:41:28 +03:00
|
|
|
uint16_t datalen,
|
|
|
|
loff_t object_size)
|
2010-07-05 16:42:27 +04:00
|
|
|
{
|
|
|
|
struct cifs_fscache_super_auxdata auxdata;
|
2011-05-27 08:34:02 +04:00
|
|
|
const struct cifs_tcon *tcon = cookie_netfs_data;
|
2010-07-05 16:42:27 +04:00
|
|
|
|
|
|
|
if (datalen != sizeof(auxdata))
|
|
|
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
|
|
|
|
|
|
|
memset(&auxdata, 0, sizeof(auxdata));
|
|
|
|
auxdata.resource_id = tcon->resource_id;
|
2020-06-06 01:19:46 +03:00
|
|
|
auxdata.vol_create_time = tcon->vol_create_time;
|
|
|
|
auxdata.vol_serial_number = tcon->vol_serial_number;
|
2010-07-05 16:42:27 +04:00
|
|
|
|
|
|
|
if (memcmp(data, &auxdata, datalen) != 0)
|
|
|
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
|
|
|
|
|
|
|
return FSCACHE_CHECKAUX_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Superblock object for FS-Cache
|
|
|
|
*/
|
|
|
|
const struct fscache_cookie_def cifs_fscache_super_index_def = {
|
|
|
|
.name = "CIFS.super",
|
|
|
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
|
|
|
.check_aux = cifs_fscache_super_check_aux,
|
|
|
|
};
|
|
|
|
|
2010-07-05 16:42:45 +04:00
|
|
|
static enum
|
|
|
|
fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
|
|
|
|
const void *data,
|
2018-04-04 15:41:28 +03:00
|
|
|
uint16_t datalen,
|
|
|
|
loff_t object_size)
|
2010-07-05 16:42:45 +04:00
|
|
|
{
|
|
|
|
struct cifs_fscache_inode_auxdata auxdata;
|
|
|
|
struct cifsInodeInfo *cifsi = cookie_netfs_data;
|
|
|
|
|
|
|
|
if (datalen != sizeof(auxdata))
|
|
|
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
|
|
|
|
|
|
|
memset(&auxdata, 0, sizeof(auxdata));
|
|
|
|
auxdata.eof = cifsi->server_eof;
|
2018-06-19 18:27:59 +03:00
|
|
|
auxdata.last_write_time_sec = cifsi->vfs_inode.i_mtime.tv_sec;
|
|
|
|
auxdata.last_change_time_sec = cifsi->vfs_inode.i_ctime.tv_sec;
|
|
|
|
auxdata.last_write_time_nsec = cifsi->vfs_inode.i_mtime.tv_nsec;
|
|
|
|
auxdata.last_change_time_nsec = cifsi->vfs_inode.i_ctime.tv_nsec;
|
2010-07-05 16:42:45 +04:00
|
|
|
|
|
|
|
if (memcmp(data, &auxdata, datalen) != 0)
|
|
|
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
|
|
|
|
|
|
|
return FSCACHE_CHECKAUX_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct fscache_cookie_def cifs_fscache_inode_object_def = {
|
|
|
|
.name = "CIFS.uniqueid",
|
|
|
|
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
|
|
|
.check_aux = cifs_fscache_inode_check_aux,
|
|
|
|
};
|