nfs_ssc.h 2.0 KB

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