xref: /linux/fs/nfs_common/nfs_ssc.c (revision 87c9c16317882dd6dbbc07e349bc3223e14f3244)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Helper for knfsd's SSC to access ops in NFS client modules
4  *
5  * Author: Dai Ngo <dai.ngo@oracle.com>
6  *
7  * Copyright (c) 2020, Oracle and/or its affiliates.
8  */
9 
10 #include <linux/module.h>
11 #include <linux/fs.h>
12 #include <linux/nfs_ssc.h>
13 #include "../nfs/nfs4_fs.h"
14 
15 MODULE_LICENSE("GPL");
16 
17 struct nfs_ssc_client_ops_tbl nfs_ssc_client_tbl;
18 EXPORT_SYMBOL_GPL(nfs_ssc_client_tbl);
19 
20 #ifdef CONFIG_NFS_V4_2
21 /**
22  * nfs42_ssc_register - install the NFS_V4 client ops in the nfs_ssc_client_tbl
23  * @ops: NFS_V4 ops to be installed
24  *
25  * Return values:
26  *   None
27  */
28 void nfs42_ssc_register(const struct nfs4_ssc_client_ops *ops)
29 {
30 	nfs_ssc_client_tbl.ssc_nfs4_ops = ops;
31 }
32 EXPORT_SYMBOL_GPL(nfs42_ssc_register);
33 
34 /**
35  * nfs42_ssc_unregister - uninstall the NFS_V4 client ops from
36  *				the nfs_ssc_client_tbl
37  * @ops: ops to be uninstalled
38  *
39  * Return values:
40  *   None
41  */
42 void nfs42_ssc_unregister(const struct nfs4_ssc_client_ops *ops)
43 {
44 	if (nfs_ssc_client_tbl.ssc_nfs4_ops != ops)
45 		return;
46 
47 	nfs_ssc_client_tbl.ssc_nfs4_ops = NULL;
48 }
49 EXPORT_SYMBOL_GPL(nfs42_ssc_unregister);
50 #endif /* CONFIG_NFS_V4_2 */
51 
52 #ifdef CONFIG_NFS_V4_2
53 /**
54  * nfs_ssc_register - install the NFS_FS client ops in the nfs_ssc_client_tbl
55  * @ops: NFS_FS ops to be installed
56  *
57  * Return values:
58  *   None
59  */
60 void nfs_ssc_register(const struct nfs_ssc_client_ops *ops)
61 {
62 	nfs_ssc_client_tbl.ssc_nfs_ops = ops;
63 }
64 EXPORT_SYMBOL_GPL(nfs_ssc_register);
65 
66 /**
67  * nfs_ssc_unregister - uninstall the NFS_FS client ops from
68  *				the nfs_ssc_client_tbl
69  * @ops: ops to be uninstalled
70  *
71  * Return values:
72  *   None
73  */
74 void nfs_ssc_unregister(const struct nfs_ssc_client_ops *ops)
75 {
76 	if (nfs_ssc_client_tbl.ssc_nfs_ops != ops)
77 		return;
78 	nfs_ssc_client_tbl.ssc_nfs_ops = NULL;
79 }
80 EXPORT_SYMBOL_GPL(nfs_ssc_unregister);
81 
82 #else
83 void nfs_ssc_register(const struct nfs_ssc_client_ops *ops)
84 {
85 }
86 EXPORT_SYMBOL_GPL(nfs_ssc_register);
87 
88 void nfs_ssc_unregister(const struct nfs_ssc_client_ops *ops)
89 {
90 }
91 EXPORT_SYMBOL_GPL(nfs_ssc_unregister);
92 #endif /* CONFIG_NFS_V4_2 */
93