13 #include <linux/kernel.h>
14 #include <linux/sched.h>
16 #include <linux/nfs_fs.h>
18 #include <linux/in6.h>
23 #define NFSDBG_FACILITY NFSDBG_FSCACHE
40 return fscache_register_netfs(&nfs_fscache_netfs);
48 fscache_unregister_netfs(&nfs_fscache_netfs);
68 static uint16_t nfs_server_get_key(
const void *cookie_netfs_data,
71 const struct nfs_client *clp = cookie_netfs_data;
82 switch (clp->
cl_addr.ss_family) {
84 key->
port = sin->sin_port;
111 .name =
"NFS.server",
113 .get_key = nfs_server_get_key,
119 static uint16_t nfs_super_get_key(
const void *cookie_netfs_data,
122 const struct nfs_fscache_key *
key;
123 const struct nfs_server *nfss = cookie_netfs_data;
126 key = nfss->fscache_key;
127 len =
sizeof(key->key) + key->key.uniq_len;
131 memcpy(buffer, &key->key,
sizeof(key->key));
132 memcpy(buffer +
sizeof(key->key),
133 key->key.uniquifier, key->key.uniq_len);
147 .get_key = nfs_super_get_key,
169 static uint16_t nfs_fscache_inode_get_key(
const void *cookie_netfs_data,
172 const struct nfs_inode *nfsi = cookie_netfs_data;
176 nsize = nfsi->
fh.size;
177 memcpy(buffer, nfsi->
fh.data, nsize);
187 static void nfs_fscache_inode_get_attr(
const void *cookie_netfs_data,
190 const struct nfs_inode *nfsi = cookie_netfs_data;
203 static uint16_t nfs_fscache_inode_get_aux(
const void *cookie_netfs_data,
207 const struct nfs_inode *nfsi = cookie_netfs_data;
209 memset(&auxdata, 0,
sizeof(auxdata));
214 if (NFS_SERVER(&nfsi->
vfs_inode)->nfs_client->rpc_ops->version == 4)
215 auxdata.change_attr = nfsi->
vfs_inode.i_version;
217 if (bufmax >
sizeof(auxdata))
218 bufmax =
sizeof(auxdata);
220 memcpy(buffer, &auxdata, bufmax);
236 struct nfs_inode *nfsi = cookie_netfs_data;
238 if (datalen !=
sizeof(auxdata))
241 memset(&auxdata, 0,
sizeof(auxdata));
246 if (NFS_SERVER(&nfsi->
vfs_inode)->nfs_client->rpc_ops->version == 4)
247 auxdata.change_attr = nfsi->
vfs_inode.i_version;
249 if (
memcmp(data, &auxdata, datalen) != 0)
262 static void nfs_fscache_inode_now_uncached(
void *cookie_netfs_data)
264 struct nfs_inode *nfsi = cookie_netfs_data;
269 pagevec_init(&pvec, 0);
272 dprintk(
"NFS: nfs_inode_now_uncached: nfs_inode 0x%p\n", nfsi);
283 for (loop = 0; loop < nr_pages; loop++)
286 first = pvec.pages[nr_pages - 1]->index + 1;
289 pagevec_release(&pvec);
302 static void nfs_fh_get_context(
void *cookie_netfs_data,
void *
context)
312 static void nfs_fh_put_context(
void *cookie_netfs_data,
void *
context)
330 .get_key = nfs_fscache_inode_get_key,
331 .get_attr = nfs_fscache_inode_get_attr,
332 .get_aux = nfs_fscache_inode_get_aux,
333 .check_aux = nfs_fscache_inode_check_aux,
334 .now_uncached = nfs_fscache_inode_now_uncached,
335 .get_context = nfs_fh_get_context,
336 .put_context = nfs_fh_put_context,