aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
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
commit8ec442ae4c6577ed181682e534d4eef524e30b3c (patch)
tree44fb9013929f7227781525d1904ac16d6723ce6e /fs/nfs
parent3b9ce977b2f31b6c396b6fb620df9881a30fac9d (diff)
NFS: Register NFS for caching and retrieve the top-level index
Register NFS for caching and retrieve the top-level cache index object cookie. 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')
-rw-r--r--fs/nfs/Makefile1
-rw-r--r--fs/nfs/fscache-index.c49
-rw-r--r--fs/nfs/fscache.h35
-rw-r--r--fs/nfs/inode.c8
4 files changed, 93 insertions, 0 deletions
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index ac6170c594a3..0e0bb6c17a86 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -15,3 +15,4 @@ nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
15 callback.o callback_xdr.o callback_proc.o \ 15 callback.o callback_xdr.o callback_proc.o \
16 nfs4namespace.o 16 nfs4namespace.o
17nfs-$(CONFIG_SYSCTL) += sysctl.o 17nfs-$(CONFIG_SYSCTL) += sysctl.o
18nfs-$(CONFIG_NFS_FSCACHE) += fscache-index.o
diff --git a/fs/nfs/fscache-index.c b/fs/nfs/fscache-index.c
new file mode 100644
index 000000000000..6d5bb5c69048
--- /dev/null
+++ b/fs/nfs/fscache-index.c
@@ -0,0 +1,49 @@
1/* NFS FS-Cache index structure definition
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
20#include "internal.h"
21#include "fscache.h"
22
23#define NFSDBG_FACILITY NFSDBG_FSCACHE
24
25/*
26 * Define the NFS filesystem for FS-Cache. Upon registration FS-Cache sticks
27 * the cookie for the top-level index object for NFS into here. The top-level
28 * index can than have other cache objects inserted into it.
29 */
30struct fscache_netfs nfs_fscache_netfs = {
31 .name = "nfs",
32 .version = 0,
33};
34
35/*
36 * Register NFS for caching
37 */
38int nfs_fscache_register(void)
39{
40 return fscache_register_netfs(&nfs_fscache_netfs);
41}
42
43/*
44 * Unregister NFS for caching
45 */
46void nfs_fscache_unregister(void)
47{
48 fscache_unregister_netfs(&nfs_fscache_netfs);
49}
diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h
new file mode 100644
index 000000000000..ccfcdc58066e
--- /dev/null
+++ b/fs/nfs/fscache.h
@@ -0,0 +1,35 @@
1/* NFS filesystem cache interface definitions
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#ifndef _NFS_FSCACHE_H
13#define _NFS_FSCACHE_H
14
15#include <linux/nfs_fs.h>
16#include <linux/nfs_mount.h>
17#include <linux/nfs4_mount.h>
18#include <linux/fscache.h>
19
20#ifdef CONFIG_NFS_FSCACHE
21
22/*
23 * fscache-index.c
24 */
25extern struct fscache_netfs nfs_fscache_netfs;
26
27extern int nfs_fscache_register(void);
28extern void nfs_fscache_unregister(void);
29
30#else /* CONFIG_NFS_FSCACHE */
31static inline int nfs_fscache_register(void) { return 0; }
32static inline void nfs_fscache_unregister(void) {}
33
34#endif /* CONFIG_NFS_FSCACHE */
35#endif /* _NFS_FSCACHE_H */
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index a834d1d850b7..cd29f410e941 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -46,6 +46,7 @@
46#include "delegation.h" 46#include "delegation.h"
47#include "iostat.h" 47#include "iostat.h"
48#include "internal.h" 48#include "internal.h"
49#include "fscache.h"
49 50
50#define NFSDBG_FACILITY NFSDBG_VFS 51#define NFSDBG_FACILITY NFSDBG_VFS
51 52
@@ -1436,6 +1437,10 @@ static int __init init_nfs_fs(void)
1436{ 1437{
1437 int err; 1438 int err;
1438 1439
1440 err = nfs_fscache_register();
1441 if (err < 0)
1442 goto out7;
1443
1439 err = nfsiod_start(); 1444 err = nfsiod_start();
1440 if (err) 1445 if (err)
1441 goto out6; 1446 goto out6;
@@ -1488,6 +1493,8 @@ out4:
1488out5: 1493out5:
1489 nfsiod_stop(); 1494 nfsiod_stop();
1490out6: 1495out6:
1496 nfs_fscache_unregister();
1497out7:
1491 return err; 1498 return err;
1492} 1499}
1493 1500
@@ -1498,6 +1505,7 @@ static void __exit exit_nfs_fs(void)
1498 nfs_destroy_readpagecache(); 1505 nfs_destroy_readpagecache();
1499 nfs_destroy_inodecache(); 1506 nfs_destroy_inodecache();
1500 nfs_destroy_nfspagecache(); 1507 nfs_destroy_nfspagecache();
1508 nfs_fscache_unregister();
1501#ifdef CONFIG_PROC_FS 1509#ifdef CONFIG_PROC_FS
1502 rpc_proc_unregister("nfs"); 1510 rpc_proc_unregister("nfs");
1503#endif 1511#endif