Skip to content

Commit 7eb5b3e

Browse files
committed
netfs, fscache: Move /proc/fs/fscache to /proc/fs/netfs and put in a symlink
Rename /proc/fs/fscache to "netfs" and make a symlink from fscache to that. Signed-off-by: David Howells <[email protected]> Reviewed-by: Jeff Layton <[email protected]> cc: Christian Brauner <[email protected]> cc: [email protected] cc: [email protected]
1 parent 4498a8e commit 7eb5b3e

File tree

7 files changed

+62
-32
lines changed

7 files changed

+62
-32
lines changed

fs/netfs/fscache_main.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ unsigned int fscache_hash(unsigned int salt, const void *data, size_t len)
6262
/*
6363
* initialise the fs caching module
6464
*/
65-
static int __init fscache_init(void)
65+
int __init fscache_init(void)
6666
{
6767
int ret = -ENOMEM;
6868

@@ -94,12 +94,10 @@ static int __init fscache_init(void)
9494
return ret;
9595
}
9696

97-
fs_initcall(fscache_init);
98-
9997
/*
10098
* clean up on module removal
10199
*/
102-
static void __exit fscache_exit(void)
100+
void __exit fscache_exit(void)
103101
{
104102
_enter("");
105103

@@ -108,5 +106,3 @@ static void __exit fscache_exit(void)
108106
destroy_workqueue(fscache_wq);
109107
pr_notice("FS-Cache unloaded\n");
110108
}
111-
112-
module_exit(fscache_exit);

fs/netfs/fscache_proc.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,34 @@
1212
#include "internal.h"
1313

1414
/*
15-
* initialise the /proc/fs/fscache/ directory
15+
* Add files to /proc/fs/netfs/.
1616
*/
1717
int __init fscache_proc_init(void)
1818
{
19-
if (!proc_mkdir("fs/fscache", NULL))
20-
goto error_dir;
19+
if (!proc_symlink("fs/fscache", NULL, "../netfs"))
20+
goto error_sym;
2121

22-
if (!proc_create_seq("fs/fscache/caches", S_IFREG | 0444, NULL,
22+
if (!proc_create_seq("fs/netfs/caches", S_IFREG | 0444, NULL,
2323
&fscache_caches_seq_ops))
2424
goto error;
2525

26-
if (!proc_create_seq("fs/fscache/volumes", S_IFREG | 0444, NULL,
26+
if (!proc_create_seq("fs/netfs/volumes", S_IFREG | 0444, NULL,
2727
&fscache_volumes_seq_ops))
2828
goto error;
2929

30-
if (!proc_create_seq("fs/fscache/cookies", S_IFREG | 0444, NULL,
30+
if (!proc_create_seq("fs/netfs/cookies", S_IFREG | 0444, NULL,
3131
&fscache_cookies_seq_ops))
3232
goto error;
33-
34-
#ifdef CONFIG_FSCACHE_STATS
35-
if (!proc_create_single("fs/fscache/stats", S_IFREG | 0444, NULL,
36-
fscache_stats_show))
37-
goto error;
38-
#endif
39-
4033
return 0;
4134

4235
error:
4336
remove_proc_entry("fs/fscache", NULL);
44-
error_dir:
37+
error_sym:
4538
return -ENOMEM;
4639
}
4740

4841
/*
49-
* clean up the /proc/fs/fscache/ directory
42+
* Clean up the /proc/fs/fscache symlink.
5043
*/
5144
void fscache_proc_cleanup(void)
5245
{

fs/netfs/fscache_stats.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ EXPORT_SYMBOL(fscache_n_culled);
5252
/*
5353
* display the general statistics
5454
*/
55-
int fscache_stats_show(struct seq_file *m, void *v)
55+
int fscache_stats_show(struct seq_file *m)
5656
{
5757
seq_puts(m, "FS-Cache statistics\n");
5858
seq_printf(m, "Cookies: n=%d v=%d vcol=%u voom=%u\n",
@@ -96,7 +96,5 @@ int fscache_stats_show(struct seq_file *m, void *v)
9696
seq_printf(m, "IO : rd=%u wr=%u\n",
9797
atomic_read(&fscache_n_read),
9898
atomic_read(&fscache_n_write));
99-
100-
netfs_stats_show(m);
10199
return 0;
102100
}

fs/netfs/internal.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ extern atomic_t netfs_n_rh_write_done;
7676
extern atomic_t netfs_n_rh_write_failed;
7777
extern atomic_t netfs_n_rh_write_zskip;
7878

79+
int netfs_stats_show(struct seq_file *m, void *v);
7980

8081
static inline void netfs_stat(atomic_t *stat)
8182
{
@@ -166,6 +167,13 @@ static inline void fscache_see_cookie(struct fscache_cookie *cookie,
166167
* fscache-main.c
167168
*/
168169
extern unsigned int fscache_hash(unsigned int salt, const void *data, size_t len);
170+
#ifdef CONFIG_FSCACHE
171+
int __init fscache_init(void);
172+
void __exit fscache_exit(void);
173+
#else
174+
static inline int fscache_init(void) { return 0; }
175+
static inline void fscache_exit(void) {}
176+
#endif
169177

170178
/*
171179
* fscache-proc.c
@@ -216,12 +224,14 @@ static inline void fscache_stat_d(atomic_t *stat)
216224

217225
#define __fscache_stat(stat) (stat)
218226

219-
int fscache_stats_show(struct seq_file *m, void *v);
227+
int fscache_stats_show(struct seq_file *m);
220228
#else
221229

222230
#define __fscache_stat(stat) (NULL)
223231
#define fscache_stat(stat) do {} while (0)
224232
#define fscache_stat_d(stat) do {} while (0)
233+
234+
static inline int fscache_stats_show(struct seq_file *m) { return 0; }
225235
#endif
226236

227237
/*

fs/netfs/main.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <linux/module.h>
99
#include <linux/export.h>
10+
#include <linux/proc_fs.h>
11+
#include <linux/seq_file.h>
1012
#include "internal.h"
1113
#define CREATE_TRACE_POINTS
1214
#include <trace/events/netfs.h>
@@ -19,3 +21,34 @@ unsigned netfs_debug;
1921
module_param_named(debug, netfs_debug, uint, S_IWUSR | S_IRUGO);
2022
MODULE_PARM_DESC(netfs_debug, "Netfs support debugging mask");
2123

24+
static int __init netfs_init(void)
25+
{
26+
int ret = -ENOMEM;
27+
28+
if (!proc_mkdir("fs/netfs", NULL))
29+
goto error;
30+
31+
#ifdef CONFIG_FSCACHE_STATS
32+
if (!proc_create_single("fs/netfs/stats", S_IFREG | 0444, NULL,
33+
netfs_stats_show))
34+
goto error_proc;
35+
#endif
36+
37+
ret = fscache_init();
38+
if (ret < 0)
39+
goto error_proc;
40+
return 0;
41+
42+
error_proc:
43+
remove_proc_entry("fs/netfs", NULL);
44+
error:
45+
return ret;
46+
}
47+
fs_initcall(netfs_init);
48+
49+
static void __exit netfs_exit(void)
50+
{
51+
fscache_exit();
52+
remove_proc_entry("fs/netfs", NULL);
53+
}
54+
module_exit(netfs_exit);

fs/netfs/stats.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,32 @@ atomic_t netfs_n_rh_write_done;
2828
atomic_t netfs_n_rh_write_failed;
2929
atomic_t netfs_n_rh_write_zskip;
3030

31-
void netfs_stats_show(struct seq_file *m)
31+
int netfs_stats_show(struct seq_file *m, void *v)
3232
{
33-
seq_printf(m, "RdHelp : RA=%u RP=%u WB=%u WBZ=%u rr=%u sr=%u\n",
33+
seq_printf(m, "Netfs : RA=%u RP=%u WB=%u WBZ=%u rr=%u sr=%u\n",
3434
atomic_read(&netfs_n_rh_readahead),
3535
atomic_read(&netfs_n_rh_readpage),
3636
atomic_read(&netfs_n_rh_write_begin),
3737
atomic_read(&netfs_n_rh_write_zskip),
3838
atomic_read(&netfs_n_rh_rreq),
3939
atomic_read(&netfs_n_rh_sreq));
40-
seq_printf(m, "RdHelp : ZR=%u sh=%u sk=%u\n",
40+
seq_printf(m, "Netfs : ZR=%u sh=%u sk=%u\n",
4141
atomic_read(&netfs_n_rh_zero),
4242
atomic_read(&netfs_n_rh_short_read),
4343
atomic_read(&netfs_n_rh_write_zskip));
44-
seq_printf(m, "RdHelp : DL=%u ds=%u df=%u di=%u\n",
44+
seq_printf(m, "Netfs : DL=%u ds=%u df=%u di=%u\n",
4545
atomic_read(&netfs_n_rh_download),
4646
atomic_read(&netfs_n_rh_download_done),
4747
atomic_read(&netfs_n_rh_download_failed),
4848
atomic_read(&netfs_n_rh_download_instead));
49-
seq_printf(m, "RdHelp : RD=%u rs=%u rf=%u\n",
49+
seq_printf(m, "Netfs : RD=%u rs=%u rf=%u\n",
5050
atomic_read(&netfs_n_rh_read),
5151
atomic_read(&netfs_n_rh_read_done),
5252
atomic_read(&netfs_n_rh_read_failed));
53-
seq_printf(m, "RdHelp : WR=%u ws=%u wf=%u\n",
53+
seq_printf(m, "Netfs : WR=%u ws=%u wf=%u\n",
5454
atomic_read(&netfs_n_rh_write),
5555
atomic_read(&netfs_n_rh_write_done),
5656
atomic_read(&netfs_n_rh_write_failed));
57+
return fscache_stats_show(m);
5758
}
5859
EXPORT_SYMBOL(netfs_stats_show);

include/linux/netfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ void netfs_get_subrequest(struct netfs_io_subrequest *subreq,
294294
enum netfs_sreq_ref_trace what);
295295
void netfs_put_subrequest(struct netfs_io_subrequest *subreq,
296296
bool was_async, enum netfs_sreq_ref_trace what);
297-
void netfs_stats_show(struct seq_file *);
298297
ssize_t netfs_extract_user_iter(struct iov_iter *orig, size_t orig_len,
299298
struct iov_iter *new,
300299
iov_iter_extraction_t extraction_flags);

0 commit comments

Comments
 (0)