NFSv4: use unique client identifiers in network namespaces
[linux-2.6-block.git] / include / linux / nfs_fs.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2/*
3 * linux/include/linux/nfs_fs.h
4 *
5 * Copyright (C) 1992 Rick Sladkey
6 *
7 * OS-specific nfs filesystem definitions and declarations
8 */
1da177e4
LT
9#ifndef _LINUX_NFS_FS_H
10#define _LINUX_NFS_FS_H
11
607ca46e 12#include <uapi/linux/nfs_fs.h>
03bf4b70 13
1da177e4 14
e27d359e
TM
15/*
16 * Enable dprintk() debugging support for nfs client.
17 */
18#ifdef CONFIG_NFS_DEBUG
19# define NFS_DEBUG
20#endif
21
7f1cbe51
DW
22#include <linux/in.h>
23#include <linux/mm.h>
24#include <linux/pagemap.h>
1c3c07e9 25#include <linux/rbtree.h>
2f62b5aa 26#include <linux/refcount.h>
7f1cbe51
DW
27#include <linux/rwsem.h>
28#include <linux/wait.h>
29
30#include <linux/sunrpc/debug.h>
31#include <linux/sunrpc/auth.h>
32#include <linux/sunrpc/clnt.h>
33
34#include <linux/nfs.h>
35#include <linux/nfs2.h>
36#include <linux/nfs3.h>
37#include <linux/nfs4.h>
38#include <linux/nfs_xdr.h>
7f1cbe51
DW
39#include <linux/nfs_fs_sb.h>
40
7f1cbe51
DW
41#include <linux/mempool.h>
42
7e134205
OK
43/*
44 * These are the default for number of transports to different server IPs
45 */
46#define NFS_MAX_TRANSPORTS 16
47
7f1cbe51
DW
48/*
49 * These are the default flags for swap requests
50 */
51#define NFS_RPC_SWAPFLAGS (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
52
b593c09f
TM
53/*
54 * Size of the NFS directory verifier
55 */
56#define NFS_DIR_VERIFIER_SIZE 2
57
1da177e4
LT
58/*
59 * NFSv3/v4 Access mode cache entry
60 */
61struct nfs_access_entry {
1c3c07e9 62 struct rb_node rb_node;
cfcea3e8 63 struct list_head lru;
6238aec8
N
64 kuid_t fsuid;
65 kgid_t fsgid;
66 struct group_info *group_info;
bd8b2441 67 __u32 mask;
f682a398 68 struct rcu_head rcu_head;
1da177e4
LT
69};
70
f11ac8db 71struct nfs_lock_context {
2f62b5aa 72 refcount_t count;
f11ac8db
TM
73 struct list_head list;
74 struct nfs_open_context *open_context;
d51fdb87 75 fl_owner_t lockowner;
210c7c17 76 atomic_t io_count;
1db97eaa 77 struct rcu_head rcu_head;
f11ac8db
TM
78};
79
1da177e4
LT
80struct nfs4_state;
81struct nfs_open_context {
f11ac8db 82 struct nfs_lock_context lock_context;
532d4def 83 fl_owner_t flock_owner;
3d4ff43d 84 struct dentry *dentry;
a52458b4 85 const struct cred *cred;
ca05cbae 86 struct rpc_cred __rcu *ll_cred; /* low-level cred - use to check for expiry */
1da177e4 87 struct nfs4_state *state;
dc0b027d 88 fmode_t mode;
7b159fc1
TM
89
90 unsigned long flags;
05990d1b 91#define NFS_CONTEXT_RESEND_WRITES (1)
c58c8441 92#define NFS_CONTEXT_BAD (2)
7d6ddf88 93#define NFS_CONTEXT_UNLOCK (3)
e97bc663 94#define NFS_CONTEXT_FILE_OPEN (4)
1da177e4
LT
95 int error;
96
97 struct list_head list;
82be417a 98 struct nfs4_threshold *mdsthreshold;
0de43976 99 struct rcu_head rcu_head;
480c2006 100};
00a92642 101
480c2006 102struct nfs_open_dir_context {
311324ad 103 struct list_head list;
0c030806 104 unsigned long attr_gencount;
b593c09f 105 __be32 verf[NFS_DIR_VERIFIER_SIZE];
00a92642 106 __u64 dir_cookie;
8ef2ce3e 107 __u64 dup_cookie;
ff81dfb5 108 pgoff_t page_index;
0c030806 109 signed char duped;
e1d2699b 110 bool eof;
1da177e4
LT
111};
112
113/*
114 * NFSv4 delegation
115 */
116struct nfs_delegation;
117
5c6a9f7d
AG
118struct posix_acl;
119
95ad37f9
FL
120struct nfs4_xattr_cache;
121
1da177e4
LT
122/*
123 * nfs fs inode data in memory
124 */
125struct nfs_inode {
126 /*
127 * The 64bit 'inode number'
128 */
129 __u64 fileid;
130
131 /*
132 * NFS file handle
133 */
134 struct nfs_fh fh;
135
136 /*
137 * Various flags
138 */
412d582e
CL
139 unsigned long flags; /* atomic bit ops */
140 unsigned long cache_validity; /* bit mask */
1da177e4
LT
141
142 /*
24bd68f4 143 * read_cache_jiffies is when we started read-caching this inode.
1da177e4
LT
144 * attrtimeo is for how long the cached information is assumed
145 * to be valid. A successful attribute revalidation doubles
146 * attrtimeo (up to acregmax/acdirmax), a failure resets it to
147 * acregmin/acdirmin.
148 *
149 * We need to revalidate the cached attrs for this inode if
150 *
64672d55
PS
151 * jiffies - read_cache_jiffies >= attrtimeo
152 *
153 * Please note the comparison is greater than or equal
154 * so that zero timeout values can be specified.
1da177e4 155 */
1da177e4
LT
156 unsigned long read_cache_jiffies;
157 unsigned long attrtimeo;
158 unsigned long attrtimeo_timestamp;
1da177e4 159
4704f0e2 160 unsigned long attr_gencount;
1da177e4 161
1c3c07e9 162 struct rb_root access_cache;
cfcea3e8
TM
163 struct list_head access_cache_entry_lru;
164 struct list_head access_cache_inode_lru;
1da177e4 165
e591b298
TM
166 union {
167 /* Directory */
168 struct {
169 /* "Generation counter" for the attribute cache.
170 * This is bumped whenever we update the metadata
171 * on the server.
172 */
173 unsigned long cache_change_attribute;
174 /*
175 * This is the cookie verifier used for NFSv3 readdir
176 * operations
177 */
178 __be32 cookieverf[NFS_DIR_VERIFIER_SIZE];
179 /* Readers: in-flight sillydelete RPC calls */
180 /* Writers: rmdir */
181 struct rw_semaphore rmdir_sem;
182 };
183 /* Regular file */
184 struct {
185 atomic_long_t nrequests;
186 struct nfs_mds_commit_info commit_info;
187 struct mutex commit_mutex;
188 };
189 };
1da177e4
LT
190
191 /* Open contexts for shared mmap writes */
192 struct list_head open_files;
193
89d77c8f 194#if IS_ENABLED(CONFIG_NFS_V4)
e50a1c2e 195 struct nfs4_cached_acl *nfs4_acl;
1da177e4
LT
196 /* NFSv4 state */
197 struct list_head open_states;
5b22216e 198 struct nfs_delegation __rcu *delegation;
1da177e4 199 struct rw_semaphore rwsem;
e5e94017
BH
200
201 /* pNFS layout information */
202 struct pnfs_layout_hdr *layout;
1da177e4 203#endif /* CONFIG_NFS_V4*/
2701d086
AA
204 /* how many bytes have been written/read and how many bytes queued up */
205 __u64 write_io;
206 __u64 read_io;
ef79c097
DH
207#ifdef CONFIG_NFS_FSCACHE
208 struct fscache_cookie *fscache;
209#endif
1da177e4 210 struct inode vfs_inode;
95ad37f9
FL
211
212#ifdef CONFIG_NFS_V4_2
213 struct nfs4_xattr_cache *xattr_cache;
214#endif
1da177e4
LT
215};
216
62164f31
OK
217struct nfs4_copy_state {
218 struct list_head copies;
0e65a32c 219 struct list_head src_copies;
62164f31
OK
220 nfs4_stateid stateid;
221 struct completion completion;
222 uint64_t count;
223 struct nfs_writeverf verf;
224 int error;
e4648aa4 225 int flags;
0e65a32c
OK
226 struct nfs4_state *parent_src_state;
227 struct nfs4_state *parent_dst_state;
62164f31
OK
228};
229
3c181827
AS
230/*
231 * Access bit flags
232 */
233#define NFS_ACCESS_READ 0x0001
234#define NFS_ACCESS_LOOKUP 0x0002
235#define NFS_ACCESS_MODIFY 0x0004
236#define NFS_ACCESS_EXTEND 0x0008
237#define NFS_ACCESS_DELETE 0x0010
238#define NFS_ACCESS_EXECUTE 0x0020
9a67fcc8
FL
239#define NFS_ACCESS_XAREAD 0x0040
240#define NFS_ACCESS_XAWRITE 0x0080
241#define NFS_ACCESS_XALIST 0x0100
3c181827 242
1da177e4 243/*
55296809 244 * Cache validity bit flags
1da177e4 245 */
90972882
TM
246#define NFS_INO_INVALID_DATA BIT(1) /* cached data is invalid */
247#define NFS_INO_INVALID_ATIME BIT(2) /* cached atime is invalid */
248#define NFS_INO_INVALID_ACCESS BIT(3) /* cached access cred invalid */
249#define NFS_INO_INVALID_ACL BIT(4) /* cached acls are invalid */
250#define NFS_INO_REVAL_PAGECACHE BIT(5) /* must revalidate pagecache */
251#define NFS_INO_REVAL_FORCED BIT(6) /* force revalidation ignoring a delegation */
252#define NFS_INO_INVALID_LABEL BIT(7) /* cached label is invalid */
16e14375
TM
253#define NFS_INO_INVALID_CHANGE BIT(8) /* cached change is invalid */
254#define NFS_INO_INVALID_CTIME BIT(9) /* cached ctime is invalid */
255#define NFS_INO_INVALID_MTIME BIT(10) /* cached mtime is invalid */
256#define NFS_INO_INVALID_SIZE BIT(11) /* cached size is invalid */
257#define NFS_INO_INVALID_OTHER BIT(12) /* other attrs are invalid */
1c341b77
TM
258#define NFS_INO_DATA_INVAL_DEFER \
259 BIT(13) /* Deferred cache invalidation */
3a39e778 260#define NFS_INO_INVALID_BLOCKS BIT(14) /* cached blocks are invalid */
0f44da51 261#define NFS_INO_INVALID_XATTR BIT(15) /* xattrs are invalid */
fabf2b34 262#define NFS_INO_INVALID_NLINK BIT(16) /* cached nlinks is invalid */
720869eb 263#define NFS_INO_INVALID_MODE BIT(17) /* cached mode is invalid */
16e14375
TM
264
265#define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \
266 | NFS_INO_INVALID_CTIME \
267 | NFS_INO_INVALID_MTIME \
268 | NFS_INO_INVALID_SIZE \
fabf2b34 269 | NFS_INO_INVALID_NLINK \
720869eb 270 | NFS_INO_INVALID_MODE \
16e14375 271 | NFS_INO_INVALID_OTHER) /* inode metadata is invalid */
55296809
CL
272
273/*
412d582e 274 * Bit offsets in flags field
55296809 275 */
691beb13
TM
276#define NFS_INO_ADVISE_RDPLUS (0) /* advise readdirplus */
277#define NFS_INO_STALE (1) /* possible stale inode */
278#define NFS_INO_ACL_LRU_SET (2) /* Inode is on the LRU list */
d529ef83 279#define NFS_INO_INVALIDATING (3) /* inode is being invalidated */
43245eca 280#define NFS_INO_PRESERVE_UNLINKED (4) /* preserve file if removed while open */
ef79c097 281#define NFS_INO_FSCACHE (5) /* inode can be cached by FS-Cache */
ff81dfb5 282#define NFS_INO_FORCE_READDIR (7) /* force readdirplus */
863a3c6c 283#define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */
92407e75 284#define NFS_INO_LAYOUTCOMMITTING (10) /* layoutcommit inflight */
1bfe3b25 285#define NFS_INO_LAYOUTSTATS (11) /* layoutstats inflight */
a5864c99 286#define NFS_INO_ODIRECT (12) /* I/O setting is O_DIRECT */
1da177e4 287
99fadcd7 288static inline struct nfs_inode *NFS_I(const struct inode *inode)
1da177e4
LT
289{
290 return container_of(inode, struct nfs_inode, vfs_inode);
291}
99fadcd7
BH
292
293static inline struct nfs_server *NFS_SB(const struct super_block *s)
294{
295 return (struct nfs_server *)(s->s_fs_info);
296}
297
298static inline struct nfs_fh *NFS_FH(const struct inode *inode)
299{
300 return &NFS_I(inode)->fh;
301}
302
303static inline struct nfs_server *NFS_SERVER(const struct inode *inode)
304{
305 return NFS_SB(inode->i_sb);
306}
307
308static inline struct rpc_clnt *NFS_CLIENT(const struct inode *inode)
309{
310 return NFS_SERVER(inode)->client;
311}
312
313static inline const struct nfs_rpc_ops *NFS_PROTO(const struct inode *inode)
314{
315 return NFS_SERVER(inode)->nfs_client->rpc_ops;
316}
317
99fadcd7
BH
318static inline unsigned NFS_MINATTRTIMEO(const struct inode *inode)
319{
320 struct nfs_server *nfss = NFS_SERVER(inode);
321 return S_ISDIR(inode->i_mode) ? nfss->acdirmin : nfss->acregmin;
322}
323
324static inline unsigned NFS_MAXATTRTIMEO(const struct inode *inode)
325{
326 struct nfs_server *nfss = NFS_SERVER(inode);
327 return S_ISDIR(inode->i_mode) ? nfss->acdirmax : nfss->acregmax;
328}
329
330static inline int NFS_STALE(const struct inode *inode)
331{
332 return test_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
333}
334
f1fe29b4 335static inline struct fscache_cookie *nfs_i_fscache(struct inode *inode)
ef79c097 336{
f1fe29b4
DH
337#ifdef CONFIG_NFS_FSCACHE
338 return NFS_I(inode)->fscache;
339#else
340 return NULL;
341#endif
ef79c097
DH
342}
343
99fadcd7
BH
344static inline __u64 NFS_FILEID(const struct inode *inode)
345{
346 return NFS_I(inode)->fileid;
347}
348
349static inline void set_nfs_fileid(struct inode *inode, __u64 fileid)
350{
351 NFS_I(inode)->fileid = fileid;
352}
1da177e4 353
decf491f
TM
354static inline void nfs_mark_for_revalidate(struct inode *inode)
355{
38478b24
TM
356 struct nfs_inode *nfsi = NFS_I(inode);
357
decf491f 358 spin_lock(&inode->i_lock);
16e14375
TM
359 nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE
360 | NFS_INO_INVALID_ACCESS
361 | NFS_INO_INVALID_ACL
362 | NFS_INO_INVALID_CHANGE
363 | NFS_INO_INVALID_CTIME;
f3821110 364 if (S_ISDIR(inode->i_mode))
115c48d7 365 nfsi->cache_validity |= NFS_INO_INVALID_DATA;
decf491f
TM
366 spin_unlock(&inode->i_lock);
367}
368
1da177e4
LT
369static inline int nfs_server_capable(struct inode *inode, int cap)
370{
371 return NFS_SERVER(inode)->caps & cap;
372}
373
1da177e4
LT
374/**
375 * nfs_save_change_attribute - Returns the inode attribute change cookie
8edb0182 376 * @dir - pointer to parent directory inode
efeda80d
TM
377 * The "cache change attribute" is updated when we need to revalidate
378 * our dentry cache after a directory was seen to change on the server.
1da177e4 379 */
8edb0182 380static inline unsigned long nfs_save_change_attribute(struct inode *dir)
1da177e4 381{
8edb0182 382 return NFS_I(dir)->cache_change_attribute;
1da177e4
LT
383}
384
1da177e4
LT
385/*
386 * linux/fs/nfs/inode.c
387 */
29884df0 388extern int nfs_sync_mapping(struct address_space *mapping);
cd9ae2b6 389extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
1da177e4 390extern void nfs_zap_caches(struct inode *);
93ce4af7 391extern void nfs_set_inode_stale(struct inode *inode);
c4812998 392extern void nfs_invalidate_atime(struct inode *);
1da177e4 393extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
cf7ab00a 394 struct nfs_fattr *);
f174ff7a 395struct inode *nfs_ilookup(struct super_block *sb, struct nfs_fattr *, struct nfs_fh *);
1da177e4 396extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
decf491f 397extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
70ca8852 398extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
a08a8cd3 399extern int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fattr *fattr);
549c7297
CB
400extern int nfs_getattr(struct user_namespace *, const struct path *,
401 struct kstat *, u32, unsigned int);
73fbb3fa 402extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *, const struct cred *);
6168f62c 403extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
549c7297 404extern int nfs_permission(struct user_namespace *, struct inode *, int);
1da177e4 405extern int nfs_open(struct inode *, struct file *);
43f291cd 406extern int nfs_attribute_cache_expired(struct inode *inode);
1f3208b2 407extern int nfs_revalidate_inode(struct inode *inode, unsigned long flags);
1da177e4 408extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
28aa2f9e 409extern int nfs_clear_invalid_mapping(struct address_space *mapping);
1cd9cb05 410extern bool nfs_mapping_need_revalidate_inode(struct inode *inode);
44b11874 411extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping);
0d0def49 412extern int nfs_revalidate_mapping_rcu(struct inode *inode);
549c7297 413extern int nfs_setattr(struct user_namespace *, struct dentry *, struct iattr *);
f044636d 414extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, struct nfs_fattr *);
dd225cb3 415extern void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr);
1da177e4
LT
416extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
417extern void put_nfs_open_context(struct nfs_open_context *ctx);
a52458b4 418extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct cred *cred, fmode_t mode);
532d4def 419extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode, struct file *filp);
c45ffdd2 420extern void nfs_inode_attach_open_context(struct nfs_open_context *ctx);
cd9a1c0e 421extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
aff8d8dc 422extern void nfs_file_clear_open_context(struct file *flip);
f11ac8db
TM
423extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx);
424extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx);
f43bf0be 425extern u64 nfs_compat_user_ino64(u64 fileid);
4704f0e2 426extern void nfs_fattr_init(struct nfs_fattr *fattr);
140e049c 427extern void nfs_fattr_set_barrier(struct nfs_fattr *fattr);
56463e50 428extern unsigned long nfs_inc_attr_generation_counter(void);
1da177e4 429
2d36bfde 430extern struct nfs_fattr *nfs_alloc_fattr(void);
d755ad8d
AS
431extern struct nfs_fattr *nfs_alloc_fattr_with_label(struct nfs_server *server);
432
433static inline void nfs4_label_free(struct nfs4_label *label)
434{
435#ifdef CONFIG_NFS_V4_SECURITY_LABEL
436 if (label) {
437 kfree(label->label);
438 kfree(label);
439 }
440#endif
441}
2d36bfde
TM
442
443static inline void nfs_free_fattr(const struct nfs_fattr *fattr)
444{
d755ad8d
AS
445 if (fattr)
446 nfs4_label_free(fattr->label);
2d36bfde
TM
447 kfree(fattr);
448}
449
450extern struct nfs_fh *nfs_alloc_fhandle(void);
451
452static inline void nfs_free_fhandle(const struct nfs_fh *fh)
453{
454 kfree(fh);
455}
456
e27d359e 457#ifdef NFS_DEBUG
d8e0539e
WAA
458extern u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh);
459static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
460{
461 return _nfs_display_fhandle_hash(fh);
462}
20d27e92
CL
463extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
464#define nfs_display_fhandle(fh, caption) \
465 do { \
466 if (unlikely(nfs_debug & NFSDBG_FACILITY)) \
467 _nfs_display_fhandle(fh, caption); \
468 } while (0)
469#else
d8e0539e
WAA
470static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
471{
9304a812 472 return 0;
d8e0539e 473}
20d27e92
CL
474static inline void nfs_display_fhandle(const struct nfs_fh *fh,
475 const char *caption)
476{
477}
478#endif
479
56463e50
CL
480/*
481 * linux/fs/nfs/nfsroot.c
482 */
483extern int nfs_root_data(char **root_device, char **root_data); /*__init*/
1da177e4 484/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
5a874db4 485extern __be32 root_nfs_parse_addr(char *name); /*__init*/
0e574af1 486
1da177e4
LT
487/*
488 * linux/fs/nfs/file.c
489 */
4b6f5d20 490extern const struct file_operations nfs_file_operations;
89d77c8f 491#if IS_ENABLED(CONFIG_NFS_V4)
1788ea6e
JL
492extern const struct file_operations nfs4_file_operations;
493#endif /* CONFIG_NFS_V4 */
f5e54d6e 494extern const struct address_space_operations nfs_file_aops;
11de3b11 495extern const struct address_space_operations nfs_dir_aops;
1da177e4 496
c03025d5
TM
497static inline struct nfs_open_context *nfs_file_open_context(struct file *filp)
498{
499 return filp->private_data;
500}
501
a52458b4 502static inline const struct cred *nfs_file_cred(struct file *file)
1da177e4 503{
504e5189
NB
504 if (file != NULL) {
505 struct nfs_open_context *ctx =
506 nfs_file_open_context(file);
507 if (ctx)
508 return ctx->cred;
509 }
1da177e4
LT
510 return NULL;
511}
512
513/*
514 * linux/fs/nfs/direct.c
515 */
c8b8e32d 516extern ssize_t nfs_direct_IO(struct kiocb *, struct iov_iter *);
027445c3 517extern ssize_t nfs_file_direct_read(struct kiocb *iocb,
c8b8e32d 518 struct iov_iter *iter);
027445c3 519extern ssize_t nfs_file_direct_write(struct kiocb *iocb,
65a4a1ca 520 struct iov_iter *iter);
1da177e4
LT
521
522/*
523 * linux/fs/nfs/dir.c
524 */
4b6f5d20 525extern const struct file_operations nfs_dir_operations;
f786aa90 526extern const struct dentry_operations nfs_dentry_operations;
1da177e4 527
bfc69a45 528extern void nfs_force_lookup_revalidate(struct inode *dir);
efeda80d
TM
529extern void nfs_set_verifier(struct dentry * dentry, unsigned long verf);
530#if IS_ENABLED(CONFIG_NFS_V4)
531extern void nfs_clear_verifier_delegated(struct inode *inode);
532#endif /* IS_ENABLED(CONFIG_NFS_V4) */
406cd915 533extern struct dentry *nfs_add_or_obtain(struct dentry *dentry,
cc6f3298 534 struct nfs_fh *fh, struct nfs_fattr *fattr);
1775fd3e 535extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh,
d91bfc46 536 struct nfs_fattr *fattr);
b68572e0 537extern int nfs_may_open(struct inode *inode, const struct cred *cred, int openflags);
af22f94a 538extern void nfs_access_zap_cache(struct inode *inode);
b5e7b59c
N
539extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred,
540 u32 *mask, bool may_block);
1da177e4
LT
541
542/*
543 * linux/fs/nfs/symlink.c
544 */
c5ef1c42 545extern const struct inode_operations nfs_symlink_inode_operations;
1da177e4 546
a72b4422
TM
547/*
548 * linux/fs/nfs/sysctl.c
549 */
550#ifdef CONFIG_SYSCTL
551extern int nfs_register_sysctl(void);
552extern void nfs_unregister_sysctl(void);
553#else
7fd105e7 554#define nfs_register_sysctl() 0
a72b4422
TM
555#define nfs_unregister_sysctl() do { } while(0)
556#endif
557
55a97593
TM
558/*
559 * linux/fs/nfs/namespace.c
560 */
c5ef1c42
AV
561extern const struct inode_operations nfs_mountpoint_inode_operations;
562extern const struct inode_operations nfs_referral_inode_operations;
51d8fa6a
TM
563extern int nfs_mountpoint_expiry_timeout;
564extern void nfs_release_automount_timer(void);
55a97593 565
1da177e4
LT
566/*
567 * linux/fs/nfs/unlink.c
568 */
e4eff1a6 569extern void nfs_complete_unlink(struct dentry *dentry, struct inode *);
1da177e4
LT
570
571/*
572 * linux/fs/nfs/write.c
573 */
89a09141 574extern int nfs_congestion_kb;
1da177e4
LT
575extern int nfs_writepage(struct page *page, struct writeback_control *wbc);
576extern int nfs_writepages(struct address_space *, struct writeback_control *);
577extern int nfs_flush_incompatible(struct file *file, struct page *page);
578extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
1da177e4
LT
579
580/*
581 * Try to write back everything synchronously (but check the
582 * return value!)
583 */
9e1681c2 584extern int nfs_sync_inode(struct inode *inode);
1c75950b 585extern int nfs_wb_all(struct inode *inode);
c373fff7 586extern int nfs_wb_page(struct inode *inode, struct page *page);
1b3b4a1a 587extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
b608b283 588extern int nfs_commit_inode(struct inode *, int);
518662e0 589extern struct nfs_commit_data *nfs_commitdata_alloc(bool never_fail);
0b7c0153 590extern void nfs_commit_free(struct nfs_commit_data *data);
133a48ab 591bool nfs_commit_end(struct nfs_mds_commit_info *cinfo);
1da177e4
LT
592
593static inline int
594nfs_have_writebacks(struct inode *inode)
595{
0ebeebcf
DW
596 if (S_ISREG(inode->i_mode))
597 return atomic_long_read(&NFS_I(inode)->nrequests) != 0;
598 return 0;
1da177e4
LT
599}
600
1da177e4
LT
601/*
602 * linux/fs/nfs/read.c
603 */
604extern int nfs_readpage(struct file *, struct page *);
8786fde8 605void nfs_readahead(struct readahead_control *);
963d8fe5 606
1da177e4
LT
607/*
608 * inline functions
609 */
610
433c9237 611static inline loff_t nfs_size_to_loff_t(__u64 size)
1da177e4 612{
50ab8ec7 613 return min_t(u64, size, OFFSET_MAX);
1da177e4
LT
614}
615
616static inline ino_t
617nfs_fileid_to_ino_t(u64 fileid)
618{
619 ino_t ino = (ino_t) fileid;
620 if (sizeof(ino_t) < sizeof(u64))
621 ino ^= fileid >> (sizeof(u64)-sizeof(ino_t)) * 8;
622 return ino;
623}
624
1da177e4
LT
625#define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
626
4dc2eaec 627
1da177e4
LT
628# undef ifdebug
629# ifdef NFS_DEBUG
630# define ifdebug(fac) if (unlikely(nfs_debug & NFSDBG_##fac))
6f00866d 631# define NFS_IFDEBUG(x) x
1da177e4
LT
632# else
633# define ifdebug(fac) if (0)
6f00866d 634# define NFS_IFDEBUG(x)
1da177e4 635# endif
1da177e4 636#endif