xref: /linux/fs/nfs_common/nfs_ssc.c (revision 4b132aacb0768ac1e652cf517097ea6f237214b9)
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 
16 struct nfs_ssc_client_ops_tbl nfs_ssc_client_tbl;
17 EXPORT_SYMBOL_GPL(nfs_ssc_client_tbl);
18 
19 #ifdef CONFIG_NFS_V4_2
20 /**
21  * nfs42_ssc_register - install the NFS_V4 client ops in the nfs_ssc_client_tbl
22  * @ops: NFS_V4 ops to be installed
23  *
24  * Return values:
25  *   None
26  */
27 void nfs42_ssc_register(const struct nfs4_ssc_client_ops *ops)
28 {
29 	nfs_ssc_client_tbl.ssc_nfs4_ops = ops;
30 }
31 EXPORT_SYMBOL_GPL(nfs42_ssc_register);
32 
33 /**
34  * nfs42_ssc_unregister - uninstall the NFS_V4 client ops from
35  *				the nfs_ssc_client_tbl
36  * @ops: ops to be uninstalled
37  *
38  * Return values:
39  *   None
40  */
41 void nfs42_ssc_unregister(const struct nfs4_ssc_client_ops *ops)
42 {
43 	if (nfs_ssc_client_tbl.ssc_nfs4_ops != ops)
44 		return;
45 
46 	nfs_ssc_client_tbl.ssc_nfs4_ops = NULL;
47 }
48 EXPORT_SYMBOL_GPL(nfs42_ssc_unregister);
49 #endif /* CONFIG_NFS_V4_2 */
50 
51 #ifdef CONFIG_NFS_V4_2
52 /**
53  * nfs_ssc_register - install the NFS_FS client ops in the nfs_ssc_client_tbl
54  * @ops: NFS_FS ops to be installed
55  *
56  * Return values:
57  *   None
58  */
59 void nfs_ssc_register(const struct nfs_ssc_client_ops *ops)
60 {
61 	nfs_ssc_client_tbl.ssc_nfs_ops = ops;
62 }
63 EXPORT_SYMBOL_GPL(nfs_ssc_register);
64 
65 /**
66  * nfs_ssc_unregister - uninstall the NFS_FS client ops from
67  *				the nfs_ssc_client_tbl
68  * @ops: ops to be uninstalled
69  *
70  * Return values:
71  *   None
72  */
73 void nfs_ssc_unregister(const struct nfs_ssc_client_ops *ops)
74 {
75 	if (nfs_ssc_client_tbl.ssc_nfs_ops != ops)
76 		return;
77 	nfs_ssc_client_tbl.ssc_nfs_ops = NULL;
78 }
79 EXPORT_SYMBOL_GPL(nfs_ssc_unregister);
80 
81 #else
82 void nfs_ssc_register(const struct nfs_ssc_client_ops *ops)
83 {
84 }
85 EXPORT_SYMBOL_GPL(nfs_ssc_register);
86 
87 void nfs_ssc_unregister(const struct nfs_ssc_client_ops *ops)
88 {
89 }
90 EXPORT_SYMBOL_GPL(nfs_ssc_unregister);
91 #endif /* CONFIG_NFS_V4_2 */
92