Blame view

fs/nfs/fscache.h 6.49 KB
8ec442ae4   David Howells   NFS: Register NFS...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  /* NFS filesystem cache interface definitions
   *
   * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
   * Written by David Howells (dhowells@redhat.com)
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public Licence
   * as published by the Free Software Foundation; either version
   * 2 of the Licence, or (at your option) any later version.
   */
  
  #ifndef _NFS_FSCACHE_H
  #define _NFS_FSCACHE_H
  
  #include <linux/nfs_fs.h>
  #include <linux/nfs_mount.h>
  #include <linux/nfs4_mount.h>
  #include <linux/fscache.h>
  
  #ifdef CONFIG_NFS_FSCACHE
  
  /*
08734048b   David Howells   NFS: Define and c...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
   * set of NFS FS-Cache objects that form a superblock key
   */
  struct nfs_fscache_key {
  	struct rb_node		node;
  	struct nfs_client	*nfs_client;	/* the server */
  
  	/* the elements of the unique key - as used by nfs_compare_super() and
  	 * nfs_compare_mount_options() to distinguish superblocks */
  	struct {
  		struct {
  			unsigned long	s_flags;	/* various flags
  							 * (& NFS_MS_MASK) */
  		} super;
  
  		struct {
  			struct nfs_fsid fsid;
  			int		flags;
  			unsigned int	rsize;		/* read size */
  			unsigned int	wsize;		/* write size */
  			unsigned int	acregmin;	/* attr cache timeouts */
  			unsigned int	acregmax;
  			unsigned int	acdirmin;
  			unsigned int	acdirmax;
  		} nfs_server;
  
  		struct {
  			rpc_authflavor_t au_flavor;
  		} rpc_auth;
  
  		/* uniquifier - can be used if nfs_server.flags includes
  		 * NFS_MOUNT_UNSHARED  */
  		u8 uniq_len;
  		char uniquifier[0];
  	} key;
  };
  
  /*
8ec442ae4   David Howells   NFS: Register NFS...
60
61
62
   * fscache-index.c
   */
  extern struct fscache_netfs nfs_fscache_netfs;
147272813   David Howells   NFS: Define and c...
63
  extern const struct fscache_cookie_def nfs_fscache_server_index_def;
08734048b   David Howells   NFS: Define and c...
64
  extern const struct fscache_cookie_def nfs_fscache_super_index_def;
10329a5d4   David Howells   NFS: Define and c...
65
  extern const struct fscache_cookie_def nfs_fscache_inode_object_def;
8ec442ae4   David Howells   NFS: Register NFS...
66
67
68
  
  extern int nfs_fscache_register(void);
  extern void nfs_fscache_unregister(void);
147272813   David Howells   NFS: Define and c...
69
70
71
72
73
  /*
   * fscache.c
   */
  extern void nfs_fscache_get_client_cookie(struct nfs_client *);
  extern void nfs_fscache_release_client_cookie(struct nfs_client *);
2311b9439   Bryan Schumaker   NFS: Don't pass m...
74
  extern void nfs_fscache_get_super_cookie(struct super_block *, const char *, int);
08734048b   David Howells   NFS: Define and c...
75
  extern void nfs_fscache_release_super_cookie(struct super_block *);
f1fe29b4a   David Howells   NFS: Use i_writec...
76
77
78
  extern void nfs_fscache_init_inode(struct inode *);
  extern void nfs_fscache_clear_inode(struct inode *);
  extern void nfs_fscache_open_file(struct inode *, struct file *);
ef79c097b   David Howells   NFS: Use local di...
79

545db45f0   David Howells   NFS: FS-Cache pag...
80
81
  extern void __nfs_fscache_invalidate_page(struct page *, struct inode *);
  extern int nfs_fscache_release_page(struct page *, gfp_t);
9a9fc1c03   David Howells   NFS: Read pages f...
82
83
84
85
86
  extern int __nfs_readpage_from_fscache(struct nfs_open_context *,
  				       struct inode *, struct page *);
  extern int __nfs_readpages_from_fscache(struct nfs_open_context *,
  					struct inode *, struct address_space *,
  					struct list_head *, unsigned *);
7f8e05f60   David Howells   NFS: Store pages ...
87
  extern void __nfs_readpage_to_fscache(struct inode *, struct page *, int);
9a9fc1c03   David Howells   NFS: Read pages f...
88

545db45f0   David Howells   NFS: FS-Cache pag...
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  /*
   * wait for a page to complete writing to the cache
   */
  static inline void nfs_fscache_wait_on_page_write(struct nfs_inode *nfsi,
  						  struct page *page)
  {
  	if (PageFsCache(page))
  		fscache_wait_on_page_write(nfsi->fscache, page);
  }
  
  /*
   * release the caching state associated with a page if undergoing complete page
   * invalidation
   */
  static inline void nfs_fscache_invalidate_page(struct page *page,
  					       struct inode *inode)
  {
  	if (PageFsCache(page))
  		__nfs_fscache_invalidate_page(page, inode);
  }
9a9fc1c03   David Howells   NFS: Read pages f...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  /*
   * Retrieve a page from an inode data storage object.
   */
  static inline int nfs_readpage_from_fscache(struct nfs_open_context *ctx,
  					    struct inode *inode,
  					    struct page *page)
  {
  	if (NFS_I(inode)->fscache)
  		return __nfs_readpage_from_fscache(ctx, inode, page);
  	return -ENOBUFS;
  }
  
  /*
   * Retrieve a set of pages from an inode data storage object.
   */
  static inline int nfs_readpages_from_fscache(struct nfs_open_context *ctx,
  					     struct inode *inode,
  					     struct address_space *mapping,
  					     struct list_head *pages,
  					     unsigned *nr_pages)
  {
  	if (NFS_I(inode)->fscache)
  		return __nfs_readpages_from_fscache(ctx, inode, mapping, pages,
  						    nr_pages);
  	return -ENOBUFS;
  }
545db45f0   David Howells   NFS: FS-Cache pag...
135

7f8e05f60   David Howells   NFS: Store pages ...
136
137
138
139
140
141
142
143
144
145
146
  /*
   * Store a page newly fetched from the server in an inode data storage object
   * in the cache.
   */
  static inline void nfs_readpage_to_fscache(struct inode *inode,
  					   struct page *page,
  					   int sync)
  {
  	if (PageFsCache(page))
  		__nfs_readpage_to_fscache(inode, page, sync);
  }
5d1acff15   David Howells   NFS: Display loca...
147
  /*
de242c0b8   David Howells   NFS: Use FS-Cache...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
   * Invalidate the contents of fscache for this inode.  This will not sleep.
   */
  static inline void nfs_fscache_invalidate(struct inode *inode)
  {
  	fscache_invalidate(NFS_I(inode)->fscache);
  }
  
  /*
   * Wait for an object to finish being invalidated.
   */
  static inline void nfs_fscache_wait_on_invalidate(struct inode *inode)
  {
  	fscache_wait_on_invalidate(NFS_I(inode)->fscache);
  }
  
  /*
5d1acff15   David Howells   NFS: Display loca...
164
165
166
167
168
169
170
171
   * indicate the client caching state as readable text
   */
  static inline const char *nfs_server_fscache_state(struct nfs_server *server)
  {
  	if (server->fscache && (server->options & NFS_OPTION_FSCACHE))
  		return "yes";
  	return "no ";
  }
8ec442ae4   David Howells   NFS: Register NFS...
172
173
174
  #else /* CONFIG_NFS_FSCACHE */
  static inline int nfs_fscache_register(void) { return 0; }
  static inline void nfs_fscache_unregister(void) {}
147272813   David Howells   NFS: Define and c...
175
176
  static inline void nfs_fscache_get_client_cookie(struct nfs_client *clp) {}
  static inline void nfs_fscache_release_client_cookie(struct nfs_client *clp) {}
08734048b   David Howells   NFS: Define and c...
177
  static inline void nfs_fscache_release_super_cookie(struct super_block *sb) {}
f1fe29b4a   David Howells   NFS: Use i_writec...
178
179
180
181
  static inline void nfs_fscache_init_inode(struct inode *inode) {}
  static inline void nfs_fscache_clear_inode(struct inode *inode) {}
  static inline void nfs_fscache_open_file(struct inode *inode,
  					 struct file *filp) {}
ef79c097b   David Howells   NFS: Use local di...
182

545db45f0   David Howells   NFS: FS-Cache pag...
183
184
185
186
187
188
189
190
  static inline int nfs_fscache_release_page(struct page *page, gfp_t gfp)
  {
  	return 1; /* True: may release page */
  }
  static inline void nfs_fscache_invalidate_page(struct page *page,
  					       struct inode *inode) {}
  static inline void nfs_fscache_wait_on_page_write(struct nfs_inode *nfsi,
  						  struct page *page) {}
9a9fc1c03   David Howells   NFS: Read pages f...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  static inline int nfs_readpage_from_fscache(struct nfs_open_context *ctx,
  					    struct inode *inode,
  					    struct page *page)
  {
  	return -ENOBUFS;
  }
  static inline int nfs_readpages_from_fscache(struct nfs_open_context *ctx,
  					     struct inode *inode,
  					     struct address_space *mapping,
  					     struct list_head *pages,
  					     unsigned *nr_pages)
  {
  	return -ENOBUFS;
  }
7f8e05f60   David Howells   NFS: Store pages ...
205
206
  static inline void nfs_readpage_to_fscache(struct inode *inode,
  					   struct page *page, int sync) {}
9a9fc1c03   David Howells   NFS: Read pages f...
207

de242c0b8   David Howells   NFS: Use FS-Cache...
208
209
  
  static inline void nfs_fscache_invalidate(struct inode *inode) {}
c129c2934   David Howells   NFS: Provide stub...
210
  static inline void nfs_fscache_wait_on_invalidate(struct inode *inode) {}
de242c0b8   David Howells   NFS: Use FS-Cache...
211

5d1acff15   David Howells   NFS: Display loca...
212
213
214
215
  static inline const char *nfs_server_fscache_state(struct nfs_server *server)
  {
  	return "no ";
  }
8ec442ae4   David Howells   NFS: Register NFS...
216
217
  #endif /* CONFIG_NFS_FSCACHE */
  #endif /* _NFS_FSCACHE_H */