1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * include/linux/nfs_ssc.h
4 *
5 * Author: Dai Ngo <dai.ngo@oracle.com>
6 *
7 * Copyright (c) 2020, Oracle and/or its affiliates.
8 */
9
10 #include <linux/nfs_fs.h>
11 #include <linux/sunrpc/svc.h>
12
13 extern struct nfs_ssc_client_ops_tbl nfs_ssc_client_tbl;
14
15 /*
16 * NFS_V4
17 */
18 struct nfs4_ssc_client_ops {
19 struct file *(*sco_open)(struct vfsmount *ss_mnt,
20 struct nfs_fh *src_fh, nfs4_stateid *stateid);
21 void (*sco_close)(struct file *filep);
22 };
23
24 /*
25 * NFS_FS
26 */
27 struct nfs_ssc_client_ops {
28 void (*sco_sb_deactive)(struct super_block *sb);
29 };
30
31 struct nfs_ssc_client_ops_tbl {
32 const struct nfs4_ssc_client_ops *ssc_nfs4_ops;
33 const struct nfs_ssc_client_ops *ssc_nfs_ops;
34 };
35
36 extern void nfs42_ssc_register_ops(void);
37 extern void nfs42_ssc_unregister_ops(void);
38
39 extern void nfs42_ssc_register(const struct nfs4_ssc_client_ops *ops);
40 extern void nfs42_ssc_unregister(const struct nfs4_ssc_client_ops *ops);
41
42 #ifdef CONFIG_NFSD_V4_2_INTER_SSC
nfs42_ssc_open(struct vfsmount * ss_mnt,struct nfs_fh * src_fh,nfs4_stateid * stateid)43 static inline struct file *nfs42_ssc_open(struct vfsmount *ss_mnt,
44 struct nfs_fh *src_fh, nfs4_stateid *stateid)
45 {
46 if (nfs_ssc_client_tbl.ssc_nfs4_ops)
47 return (*nfs_ssc_client_tbl.ssc_nfs4_ops->sco_open)(ss_mnt, src_fh, stateid);
48 return ERR_PTR(-EIO);
49 }
50
nfs42_ssc_close(struct file * filep)51 static inline void nfs42_ssc_close(struct file *filep)
52 {
53 if (nfs_ssc_client_tbl.ssc_nfs4_ops)
54 (*nfs_ssc_client_tbl.ssc_nfs4_ops->sco_close)(filep);
55 }
56 #endif
57
58 struct nfsd4_ssc_umount_item {
59 struct list_head nsui_list;
60 bool nsui_busy;
61 /*
62 * nsui_refcnt inited to 2, 1 on list and 1 for consumer. Entry
63 * is removed when refcnt drops to 1 and nsui_expire expires.
64 */
65 refcount_t nsui_refcnt;
66 unsigned long nsui_expire;
67 struct vfsmount *nsui_vfsmount;
68 char nsui_ipaddr[RPC_MAX_ADDRBUFLEN + 1];
69 };
70
71 /*
72 * NFS_FS
73 */
74 extern void nfs_ssc_register(const struct nfs_ssc_client_ops *ops);
75 extern void nfs_ssc_unregister(const struct nfs_ssc_client_ops *ops);
76
nfs_do_sb_deactive(struct super_block * sb)77 static inline void nfs_do_sb_deactive(struct super_block *sb)
78 {
79 if (nfs_ssc_client_tbl.ssc_nfs_ops)
80 (*nfs_ssc_client_tbl.ssc_nfs_ops->sco_sb_deactive)(sb);
81 }
82