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