filecache.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _FS_NFSD_FILECACHE_H
  2. #define _FS_NFSD_FILECACHE_H
  3. #include <linux/fsnotify_backend.h>
  4. /*
  5. * Limit the time that the list_lru_one lock is held during
  6. * an LRU scan.
  7. */
  8. #define NFSD_FILE_GC_BATCH (16UL)
  9. /*
  10. * This is the fsnotify_mark container that nfsd attaches to the files that it
  11. * is holding open. Note that we have a separate refcount here aside from the
  12. * one in the fsnotify_mark. We only want a single fsnotify_mark attached to
  13. * the inode, and for each nfsd_file to hold a reference to it.
  14. *
  15. * The fsnotify_mark is itself refcounted, but that's not sufficient to tell us
  16. * how to put that reference. If there are still outstanding nfsd_files that
  17. * reference the mark, then we would want to call fsnotify_put_mark on it.
  18. * If there were not, then we'd need to call fsnotify_destroy_mark. Since we
  19. * can't really tell the difference, we use the nfm_mark to keep track of how
  20. * many nfsd_files hold references to the mark. When that counter goes to zero
  21. * then we know to call fsnotify_destroy_mark on it.
  22. */
  23. struct nfsd_file_mark {
  24. struct fsnotify_mark nfm_mark;
  25. refcount_t nfm_ref;
  26. };
  27. /*
  28. * A representation of a file that has been opened by knfsd. These are hashed
  29. * in the hashtable by inode pointer value. Note that this object doesn't
  30. * hold a reference to the inode by itself, so the nf_inode pointer should
  31. * never be dereferenced, only used for comparison.
  32. */
  33. struct nfsd_file {
  34. struct rhlist_head nf_rlist;
  35. void *nf_inode;
  36. struct file *nf_file;
  37. const struct cred *nf_cred;
  38. struct net *nf_net;
  39. #define NFSD_FILE_HASHED (0)
  40. #define NFSD_FILE_PENDING (1)
  41. #define NFSD_FILE_REFERENCED (2)
  42. #define NFSD_FILE_GC (3)
  43. #define NFSD_FILE_RECENT (4)
  44. unsigned long nf_flags;
  45. refcount_t nf_ref;
  46. unsigned char nf_may;
  47. struct nfsd_file_mark *nf_mark;
  48. struct list_head nf_lru;
  49. struct list_head nf_gc;
  50. struct rcu_head nf_rcu;
  51. ktime_t nf_birthtime;
  52. u32 nf_dio_mem_align;
  53. u32 nf_dio_offset_align;
  54. u32 nf_dio_read_offset_align;
  55. };
  56. int nfsd_file_cache_init(void);
  57. void nfsd_file_cache_purge(struct net *);
  58. void nfsd_file_cache_shutdown(void);
  59. int nfsd_file_cache_start_net(struct net *net);
  60. void nfsd_file_cache_shutdown_net(struct net *net);
  61. void nfsd_file_put(struct nfsd_file *nf);
  62. struct net *nfsd_file_put_local(struct nfsd_file __rcu **nf);
  63. struct nfsd_file *nfsd_file_get(struct nfsd_file *nf);
  64. struct file *nfsd_file_file(struct nfsd_file *nf);
  65. void nfsd_file_close_inode_sync(struct inode *inode);
  66. void nfsd_file_net_dispose(struct nfsd_net *nn);
  67. bool nfsd_file_is_cached(struct inode *inode);
  68. __be32 nfsd_file_acquire_gc(struct svc_rqst *rqstp, struct svc_fh *fhp,
  69. unsigned int may_flags, struct nfsd_file **nfp);
  70. __be32 nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
  71. unsigned int may_flags, struct nfsd_file **nfp);
  72. __be32 nfsd_file_acquire_opened(struct svc_rqst *rqstp, struct svc_fh *fhp,
  73. unsigned int may_flags, struct file *file,
  74. struct nfsd_file **nfp);
  75. __be32 nfsd_file_acquire_local(struct net *net, struct svc_cred *cred,
  76. struct auth_domain *client, struct svc_fh *fhp,
  77. unsigned int may_flags, struct nfsd_file **pnf);
  78. __be32 nfsd_file_acquire_dir(struct svc_rqst *rqstp, struct svc_fh *fhp,
  79. struct nfsd_file **pnf);
  80. int nfsd_file_cache_stats_show(struct seq_file *m, void *v);
  81. #endif /* _FS_NFSD_FILECACHE_H */