Linux Audio

Check our new training course

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