1 From: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
2 Subject: [RFC][PATCH 03/10] cifs: register CIFS for caching
3 Date: Tue, 22 Jun 2010 20:53:09 +0530
5 Message-ID: <1277220189-3485-1-git-send-email-sjayaraman@suse.de>
7 Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
8 linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
9 To: Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
10 X-From: linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Tue Jun 22 17:43:52 2010
11 Return-path: <linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
12 Envelope-to: glkc-linux-cifs-1dZseelyfdZg9hUCZPvPmw@public.gmane.org
13 Received: from vger.kernel.org ([209.132.180.67])
14 by lo.gmane.org with esmtp (Exim 4.69)
15 (envelope-from <linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>)
17 for glkc-linux-cifs-1dZseelyfdZg9hUCZPvPmw@public.gmane.org; Tue, 22 Jun 2010 17:43:51 +0200
18 Received: (majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org) by vger.kernel.org via listexpand
19 id S1753125Ab0FVPnt (ORCPT <rfc822;glkc-linux-cifs@m.gmane.org>);
20 Tue, 22 Jun 2010 11:43:49 -0400
21 Received: from victor.provo.novell.com ([137.65.250.26]:55866 "EHLO
22 victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
23 with ESMTP id S1751261Ab0FVPnt (ORCPT
24 <rfc822;groupwise-SJayaraman-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org:0:0>);
25 Tue, 22 Jun 2010 11:43:49 -0400
26 Received: from localhost (prv-ext-foundry1int.gns.novell.com [137.65.251.240])
27 by victor.provo.novell.com with ESMTP; Tue, 22 Jun 2010 09:23:11 -0600
28 X-Mailer: git-send-email 1.6.4.2
30 Sender: linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
32 List-ID: <linux-cifs.vger.kernel.org>
33 X-Mailing-List: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
34 Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1001759>
36 Define CIFS for FS-Cache and register for caching. Upon registration the
37 top-level index object cookie will be stuck to the netfs definition by
40 Signed-off-by: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
42 fs/cifs/Makefile | 2 ++
43 fs/cifs/cache.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
44 fs/cifs/cifsfs.c | 8 ++++++++
45 fs/cifs/fscache.h | 40 ++++++++++++++++++++++++++++++++++++++++
46 4 files changed, 103 insertions(+), 0 deletions(-)
47 create mode 100644 fs/cifs/cache.c
48 create mode 100644 fs/cifs/fscache.h
50 diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile
51 index 9948c00..e2de709 100644
52 --- a/fs/cifs/Makefile
53 +++ b/fs/cifs/Makefile
54 @@ -11,3 +11,5 @@ cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \
55 cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
57 cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o
59 +cifs-$(CONFIG_CIFS_FSCACHE) += cache.o
60 diff --git a/fs/cifs/cache.c b/fs/cifs/cache.c
62 index 0000000..1080b96
67 + * fs/cifs/cache.c - CIFS filesystem cache index structure definitions
69 + * Copyright (c) 2010 Novell, Inc.
70 + * Authors(s): Suresh Jayaraman (sjayaraman-l3A5Bk7waGM@public.gmane.org>
72 + * This library is free software; you can redistribute it and/or modify
73 + * it under the terms of the GNU Lesser General Public License as published
74 + * by the Free Software Foundation; either version 2.1 of the License, or
75 + * (at your option) any later version.
77 + * This library is distributed in the hope that it will be useful,
78 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
79 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
80 + * the GNU Lesser General Public License for more details.
82 + * You should have received a copy of the GNU Lesser General Public License
83 + * along with this library; if not, write to the Free Software
84 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
86 +#include <linux/init.h>
87 +#include <linux/kernel.h>
88 +#include <linux/sched.h>
89 +#include <linux/mm.h>
92 +#include "cifsglob.h"
93 +#include "cifs_debug.h"
96 + * CIFS filesystem definition for FS-Cache
98 +struct fscache_netfs cifs_fscache_netfs = {
104 + * Register CIFS for caching with FS-Cache
106 +int cifs_fscache_register(void)
108 + return fscache_register_netfs(&cifs_fscache_netfs);
112 + * Unregister CIFS for caching
114 +void cifs_fscache_unregister(void)
116 + fscache_unregister_netfs(&cifs_fscache_netfs);
119 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
120 index 484e52b..c2a7aa9 100644
121 --- a/fs/cifs/cifsfs.c
122 +++ b/fs/cifs/cifsfs.c
124 #include <linux/key-type.h>
125 #include "dns_resolve.h"
126 #include "cifs_spnego.h"
127 +#include "fscache.h"
128 #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
131 @@ -902,6 +903,10 @@ init_cifs(void)
132 cFYI(1, "cifs_max_pending set to max of 256");
135 + rc = cifs_fscache_register();
139 rc = cifs_init_inodecache();
142 @@ -949,8 +954,10 @@ init_cifs(void)
144 out_destroy_inodecache:
145 cifs_destroy_inodecache();
146 + cifs_fscache_unregister();
153 @@ -959,6 +966,7 @@ exit_cifs(void)
155 cFYI(DBG2, "exit_cifs");
157 + cifs_fscache_unregister();
158 #ifdef CONFIG_CIFS_DFS_UPCALL
159 cifs_dfs_release_automount_timer();
160 unregister_key_type(&key_type_dns_resolver);
161 diff --git a/fs/cifs/fscache.h b/fs/cifs/fscache.h
163 index 0000000..cec9e2b
165 +++ b/fs/cifs/fscache.h
168 + * fs/cifs/fscache.h - CIFS filesystem cache interface definitions
170 + * Copyright (c) 2010 Novell, Inc.
171 + * Authors(s): Suresh Jayaraman (sjayaraman-l3A5Bk7waGM@public.gmane.org>
173 + * This library is free software; you can redistribute it and/or modify
174 + * it under the terms of the GNU Lesser General Public License as published
175 + * by the Free Software Foundation; either version 2.1 of the License, or
176 + * (at your option) any later version.
178 + * This library is distributed in the hope that it will be useful,
179 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
180 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
181 + * the GNU Lesser General Public License for more details.
183 + * You should have received a copy of the GNU Lesser General Public License
184 + * along with this library; if not, write to the Free Software
185 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
187 +#ifndef _CIFS_FSCACHE_H
188 +#define _CIFS_FSCACHE_H
190 +#include <linux/fscache.h>
191 +#include "cifsglob.h"
193 +#ifdef CONFIG_CIFS_FSCACHE
195 +extern struct fscache_netfs cifs_fscache_netfs;
197 +extern int cifs_fscache_register(void);
198 +extern void cifs_fscache_unregister(void);
200 +#else /* CONFIG_CIFS_FSCACHE */
201 +static inline int cifs_fscache_register(void) { return 0; }
202 +static inline void cifs_fscache_unregister(void) {}
204 +#endif /* CONFIG_CIFS_FSCACHE */
206 +#endif /* _CIFS_FSCACHE_H */