filecache.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _FS_NFSD_FILECACHE_H
  2. #define _FS_NFSD_FILECACHE_H
  3. #include <linux/fsnotify_backend.h>
  4. /*
  5. * This is the fsnotify_mark container that nfsd attaches to the files that it
  6. * is holding open. Note that we have a separate refcount here aside from the
  7. * one in the fsnotify_mark. We only want a single fsnotify_mark attached to
  8. * the inode, and for each nfsd_file to hold a reference to it.
  9. *
  10. * The fsnotify_mark is itself refcounted, but that's not sufficient to tell us
  11. * how to put that reference. If there are still outstanding nfsd_files that
  12. * reference the mark, then we would want to call fsnotify_put_mark on it.
  13. * If there were not, then we'd need to call fsnotify_destroy_mark. Since we
  14. * can't really tell the difference, we use the nfm_mark to keep track of how
  15. * many nfsd_files hold references to the mark. When that counter goes to zero
  16. * then we know to call fsnotify_destroy_mark on it.
  17. */
  18. struct nfsd_file_mark {
  19. struct fsnotify_mark nfm_mark;
  20. refcount_t nfm_ref;
  21. };
  22. /*
  23. * A representation of a file that has been opened by knfsd. These are hashed
  24. * in the hashtable by inode pointer value. Note that this object doesn't
  25. * hold a reference to the inode by itself, so the nf_inode pointer should
  26. * never be dereferenced, only used for comparison.
  27. */
  28. struct nfsd_file {
  29. struct hlist_node nf_node;
  30. struct list_head nf_lru;
  31. struct rcu_head nf_rcu;
  32. struct file *nf_file;
  33. const struct cred *nf_cred;
  34. struct net *nf_net;
  35. #define NFSD_FILE_HASHED (0)
  36. #define NFSD_FILE_PENDING (1)
  37. #define NFSD_FILE_BREAK_READ (2)
  38. #define NFSD_FILE_BREAK_WRITE (3)
  39. #define NFSD_FILE_REFERENCED (4)
  40. unsigned long nf_flags;
  41. struct inode *nf_inode;
  42. unsigned int nf_hashval;
  43. refcount_t nf_ref;
  44. unsigned char nf_may;
  45. struct nfsd_file_mark *nf_mark;
  46. struct rw_semaphore nf_rwsem;
  47. };
  48. int nfsd_file_cache_init(void);
  49. void nfsd_file_cache_purge(struct net *);
  50. void nfsd_file_cache_shutdown(void);
  51. int nfsd_file_cache_start_net(struct net *net);
  52. void nfsd_file_cache_shutdown_net(struct net *net);
  53. void nfsd_file_put(struct nfsd_file *nf);
  54. struct nfsd_file *nfsd_file_get(struct nfsd_file *nf);
  55. void nfsd_file_close_inode_sync(struct inode *inode);
  56. bool nfsd_file_is_cached(struct inode *inode);
  57. __be32 nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
  58. unsigned int may_flags, struct nfsd_file **nfp);
  59. int nfsd_file_cache_stats_open(struct inode *, struct file *);
  60. #endif /* _FS_NFSD_FILECACHE_H */