1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/debugfs.h>
4 
5 #include "nfsd.h"
6 
7 static struct dentry *nfsd_top_dir __read_mostly;
8 
9 /*
10  * /sys/kernel/debug/nfsd/disable-splice-read
11  *
12  * Contents:
13  *   %0: NFS READ is allowed to use page splicing
14  *   %1: NFS READ uses only iov iter read
15  *
16  * The default value of this setting is zero (page splicing is
17  * allowed). This setting takes immediate effect for all NFS
18  * versions, all exports, and in all NFSD net namespaces.
19  */
20 
21 static int nfsd_dsr_get(void *data, u64 *val)
22 {
23 	*val = nfsd_disable_splice_read ? 1 : 0;
24 	return 0;
25 }
26 
27 static int nfsd_dsr_set(void *data, u64 val)
28 {
29 	nfsd_disable_splice_read = (val > 0) ? true : false;
30 	return 0;
31 }
32 
33 DEFINE_DEBUGFS_ATTRIBUTE(nfsd_dsr_fops, nfsd_dsr_get, nfsd_dsr_set, "%llu\n");
34 
35 void nfsd_debugfs_exit(void)
36 {
37 	debugfs_remove_recursive(nfsd_top_dir);
38 	nfsd_top_dir = NULL;
39 }
40 
41 void nfsd_debugfs_init(void)
42 {
43 	nfsd_top_dir = debugfs_create_dir("nfsd", NULL);
44 
45 	debugfs_create_file("disable-splice-read", S_IWUSR | S_IRUGO,
46 			    nfsd_top_dir, NULL, &nfsd_dsr_fops);
47 }
48