aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/fscache.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2009-04-03 11:42:42 -0400
committerDavid Howells <dhowells@redhat.com>2009-04-03 11:42:42 -0400
commit147272813e043fb44bd112527951da70c1e663de (patch)
tree4b67df2bb809c7b661e7c6f4b1692ab8af41a996 /fs/nfs/fscache.c
parent8ec442ae4c6577ed181682e534d4eef524e30b3c (diff)
NFS: Define and create server-level objects
Define and create server-level cache index objects (as managed by nfs_client structs). Each server object is created in the NFS top-level index object and is itself an index into which superblock-level objects are inserted. Ideally there would be one superblock-level object per server, and the former would be folded into the latter; however, since the "nosharecache" option exists this isn't possible. The server object key is a sequence consisting of: (1) NFS version (2) Server address family (eg: AF_INET or AF_INET6) (3) Server port. (4) Server IP address. The key blob is of variable length, depending on the length of (4). The server object is given no coherency data to carry in the auxiliary data permitted by the cache. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com> Acked-by: Al Viro <viro@zeniv.linux.org.uk> Tested-by: Daire Byrne <Daire.Byrne@framestore.com>
Diffstat (limited to 'fs/nfs/fscache.c')
-rw-r--r--fs/nfs/fscache.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c
new file mode 100644
index 000000000000..c3f056f89477
--- /dev/null
+++ b/fs/nfs/fscache.c
@@ -0,0 +1,52 @@
1/* NFS filesystem cache interface
2 *
3 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/sched.h>
15#include <linux/mm.h>
16#include <linux/nfs_fs.h>
17#include <linux/nfs_fs_sb.h>
18#include <linux/in6.h>
19#include <linux/seq_file.h>
20
21#include "internal.h"
22#include "fscache.h"
23
24#define NFSDBG_FACILITY NFSDBG_FSCACHE
25
26/*
27 * Get the per-client index cookie for an NFS client if the appropriate mount
28 * flag was set
29 * - We always try and get an index cookie for the client, but get filehandle
30 * cookies on a per-superblock basis, depending on the mount flags
31 */
32void nfs_fscache_get_client_cookie(struct nfs_client *clp)
33{
34 /* create a cache index for looking up filehandles */
35 clp->fscache = fscache_acquire_cookie(nfs_fscache_netfs.primary_index,
36 &nfs_fscache_server_index_def,
37 clp);
38 dfprintk(FSCACHE, "NFS: get client cookie (0x%p/0x%p)\n",
39 clp, clp->fscache);
40}
41
42/*
43 * Dispose of a per-client cookie
44 */
45void nfs_fscache_release_client_cookie(struct nfs_client *clp)
46{
47 dfprintk(FSCACHE, "NFS: releasing client cookie (0x%p/0x%p)\n",
48 clp, clp->fscache);
49
50 fscache_relinquish_cookie(clp->fscache, 0);
51 clp->fscache = NULL;
52}