Skip to content

Commit f579cf3

Browse files
Suresh JayaramanSteve French
authored andcommitted
cifs: register CIFS for caching
Define CIFS for FS-Cache and register for caching. Upon registration the top-level index object cookie will be stuck to the netfs definition by FS-Cache. Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
1 parent c21dfb6 commit f579cf3

4 files changed

Lines changed: 95 additions & 0 deletions

File tree

‎fs/cifs/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \
1111
cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
1212

1313
cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o
14+
15+
cifs-$(CONFIG_CIFS_FSCACHE) += cache.o

‎fs/cifs/cache.c‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* fs/cifs/cache.c - CIFS filesystem cache index structure definitions
3+
*
4+
* Copyright (c) 2010 Novell, Inc.
5+
* Authors(s): Suresh Jayaraman (sjayaraman@suse.de>
6+
*
7+
* This library is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as published
9+
* by the Free Software Foundation; either version 2.1 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15+
* the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License
18+
* along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20+
*/
21+
#include "fscache.h"
22+
23+
/*
24+
* CIFS filesystem definition for FS-Cache
25+
*/
26+
struct fscache_netfs cifs_fscache_netfs = {
27+
.name = "cifs",
28+
.version = 0,
29+
};
30+
31+
/*
32+
* Register CIFS for caching with FS-Cache
33+
*/
34+
int cifs_fscache_register(void)
35+
{
36+
return fscache_register_netfs(&cifs_fscache_netfs);
37+
}
38+
39+
/*
40+
* Unregister CIFS for caching
41+
*/
42+
void cifs_fscache_unregister(void)
43+
{
44+
fscache_unregister_netfs(&cifs_fscache_netfs);
45+
}
46+

‎fs/cifs/cifsfs.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <linux/key-type.h>
4848
#include "dns_resolve.h"
4949
#include "cifs_spnego.h"
50+
#include "fscache.h"
5051
#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
5152

5253
int cifsFYI = 0;
@@ -902,6 +903,10 @@ init_cifs(void)
902903
cFYI(1, "cifs_max_pending set to max of 256");
903904
}
904905

906+
rc = cifs_fscache_register();
907+
if (rc)
908+
goto out;
909+
905910
rc = cifs_init_inodecache();
906911
if (rc)
907912
goto out_clean_proc;
@@ -951,6 +956,8 @@ init_cifs(void)
951956
cifs_destroy_inodecache();
952957
out_clean_proc:
953958
cifs_proc_clean();
959+
cifs_fscache_unregister();
960+
out:
954961
return rc;
955962
}
956963

@@ -959,6 +966,7 @@ exit_cifs(void)
959966
{
960967
cFYI(DBG2, "exit_cifs");
961968
cifs_proc_clean();
969+
cifs_fscache_unregister();
962970
#ifdef CONFIG_CIFS_DFS_UPCALL
963971
cifs_dfs_release_automount_timer();
964972
cifs_exit_dns_resolver();

‎fs/cifs/fscache.h‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* fs/cifs/fscache.h - CIFS filesystem cache interface definitions
3+
*
4+
* Copyright (c) 2010 Novell, Inc.
5+
* Authors(s): Suresh Jayaraman (sjayaraman@suse.de>
6+
*
7+
* This library is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as published
9+
* by the Free Software Foundation; either version 2.1 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15+
* the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License
18+
* along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20+
*/
21+
#ifndef _CIFS_FSCACHE_H
22+
#define _CIFS_FSCACHE_H
23+
24+
#include <linux/fscache.h>
25+
26+
#ifdef CONFIG_CIFS_FSCACHE
27+
28+
extern struct fscache_netfs cifs_fscache_netfs;
29+
30+
extern int cifs_fscache_register(void);
31+
extern void cifs_fscache_unregister(void);
32+
33+
#else /* CONFIG_CIFS_FSCACHE */
34+
static inline int cifs_fscache_register(void) { return 0; }
35+
static inline void cifs_fscache_unregister(void) {}
36+
37+
#endif /* CONFIG_CIFS_FSCACHE */
38+
39+
#endif /* _CIFS_FSCACHE_H */

0 commit comments

Comments
 (0)