nfs_fs.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /* SPDX-License-Identifier: GPL-2.0 */
  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. */
  9. #ifndef _LINUX_NFS_FS_H
  10. #define _LINUX_NFS_FS_H
  11. #include <uapi/linux/nfs_fs.h>
  12. /*
  13. * Enable dprintk() debugging support for nfs client.
  14. */
  15. #ifdef CONFIG_NFS_DEBUG
  16. # define NFS_DEBUG
  17. #endif
  18. #include <linux/in.h>
  19. #include <linux/mm.h>
  20. #include <linux/pagemap.h>
  21. #include <linux/rbtree.h>
  22. #include <linux/refcount.h>
  23. #include <linux/rwsem.h>
  24. #include <linux/wait.h>
  25. #include <linux/sunrpc/debug.h>
  26. #include <linux/sunrpc/auth.h>
  27. #include <linux/sunrpc/clnt.h>
  28. #include <linux/nfs.h>
  29. #include <linux/nfs2.h>
  30. #include <linux/nfs3.h>
  31. #include <linux/nfs4.h>
  32. #include <linux/nfs_xdr.h>
  33. #include <linux/nfs_fs_sb.h>
  34. #include <linux/mempool.h>
  35. /*
  36. * These are the default for number of transports to different server IPs
  37. */
  38. #define NFS_MAX_TRANSPORTS 16
  39. /*
  40. * Size of the NFS directory verifier
  41. */
  42. #define NFS_DIR_VERIFIER_SIZE 2
  43. /*
  44. * NFSv3/v4 Access mode cache entry
  45. */
  46. struct nfs_access_entry {
  47. struct rb_node rb_node;
  48. struct list_head lru;
  49. kuid_t fsuid;
  50. kgid_t fsgid;
  51. struct group_info *group_info;
  52. __u32 mask;
  53. struct rcu_head rcu_head;
  54. };
  55. struct nfs_lock_context {
  56. refcount_t count;
  57. struct list_head list;
  58. struct nfs_open_context *open_context;
  59. fl_owner_t lockowner;
  60. atomic_t io_count;
  61. struct rcu_head rcu_head;
  62. };
  63. struct nfs4_state;
  64. struct nfs_open_context {
  65. struct nfs_lock_context lock_context;
  66. fl_owner_t flock_owner;
  67. struct dentry *dentry;
  68. const struct cred *cred;
  69. struct rpc_cred __rcu *ll_cred; /* low-level cred - use to check for expiry */
  70. struct nfs4_state *state;
  71. fmode_t mode;
  72. unsigned long flags;
  73. #define NFS_CONTEXT_BAD (2)
  74. #define NFS_CONTEXT_UNLOCK (3)
  75. #define NFS_CONTEXT_FILE_OPEN (4)
  76. int error;
  77. struct list_head list;
  78. struct nfs4_threshold *mdsthreshold;
  79. struct rcu_head rcu_head;
  80. };
  81. struct nfs_open_dir_context {
  82. struct list_head list;
  83. atomic_t cache_hits;
  84. atomic_t cache_misses;
  85. unsigned long attr_gencount;
  86. __be32 verf[NFS_DIR_VERIFIER_SIZE];
  87. __u64 dir_cookie;
  88. __u64 last_cookie;
  89. pgoff_t page_index;
  90. unsigned int dtsize;
  91. bool force_clear;
  92. bool eof;
  93. struct rcu_head rcu_head;
  94. };
  95. /*
  96. * NFSv4 delegation
  97. */
  98. struct nfs_delegation;
  99. struct posix_acl;
  100. struct nfs4_xattr_cache;
  101. /*
  102. * nfs fs inode data in memory
  103. */
  104. struct nfs_inode {
  105. /*
  106. * The 64bit 'inode number'
  107. */
  108. __u64 fileid;
  109. /*
  110. * NFS file handle
  111. */
  112. struct nfs_fh fh;
  113. /*
  114. * Various flags
  115. */
  116. unsigned long flags; /* atomic bit ops */
  117. unsigned long cache_validity; /* bit mask */
  118. /*
  119. * read_cache_jiffies is when we started read-caching this inode.
  120. * attrtimeo is for how long the cached information is assumed
  121. * to be valid. A successful attribute revalidation doubles
  122. * attrtimeo (up to acregmax/acdirmax), a failure resets it to
  123. * acregmin/acdirmin.
  124. *
  125. * We need to revalidate the cached attrs for this inode if
  126. *
  127. * jiffies - read_cache_jiffies >= attrtimeo
  128. *
  129. * Please note the comparison is greater than or equal
  130. * so that zero timeout values can be specified.
  131. */
  132. unsigned long read_cache_jiffies;
  133. unsigned long attrtimeo;
  134. unsigned long attrtimeo_timestamp;
  135. unsigned long attr_gencount;
  136. struct rb_root access_cache;
  137. struct list_head access_cache_entry_lru;
  138. struct list_head access_cache_inode_lru;
  139. union {
  140. /* Directory */
  141. struct {
  142. /* "Generation counter" for the attribute cache.
  143. * This is bumped whenever we update the metadata
  144. * on the server.
  145. */
  146. unsigned long cache_change_attribute;
  147. /*
  148. * This is the cookie verifier used for NFSv3 readdir
  149. * operations
  150. */
  151. __be32 cookieverf[NFS_DIR_VERIFIER_SIZE];
  152. /* Readers: in-flight sillydelete RPC calls */
  153. /* Writers: rmdir */
  154. struct rw_semaphore rmdir_sem;
  155. };
  156. /* Regular file */
  157. struct {
  158. atomic_long_t nrequests;
  159. atomic_long_t redirtied_pages;
  160. struct nfs_mds_commit_info commit_info;
  161. struct mutex commit_mutex;
  162. };
  163. };
  164. /* Open contexts for shared mmap writes */
  165. struct list_head open_files;
  166. #if IS_ENABLED(CONFIG_NFS_V4)
  167. struct nfs4_cached_acl *nfs4_acl;
  168. /* NFSv4 state */
  169. struct list_head open_states;
  170. struct nfs_delegation __rcu *delegation;
  171. struct rw_semaphore rwsem;
  172. /* pNFS layout information */
  173. struct pnfs_layout_hdr *layout;
  174. #endif /* CONFIG_NFS_V4*/
  175. /* how many bytes have been written/read and how many bytes queued up */
  176. __u64 write_io;
  177. __u64 read_io;
  178. #ifdef CONFIG_NFS_FSCACHE
  179. struct fscache_cookie *fscache;
  180. #endif
  181. struct inode vfs_inode;
  182. #ifdef CONFIG_NFS_V4_2
  183. struct nfs4_xattr_cache *xattr_cache;
  184. #endif
  185. };
  186. struct nfs4_copy_state {
  187. struct list_head copies;
  188. struct list_head src_copies;
  189. nfs4_stateid stateid;
  190. struct completion completion;
  191. uint64_t count;
  192. struct nfs_writeverf verf;
  193. int error;
  194. int flags;
  195. struct nfs4_state *parent_src_state;
  196. struct nfs4_state *parent_dst_state;
  197. };
  198. /*
  199. * Access bit flags
  200. */
  201. #define NFS_ACCESS_READ 0x0001
  202. #define NFS_ACCESS_LOOKUP 0x0002
  203. #define NFS_ACCESS_MODIFY 0x0004
  204. #define NFS_ACCESS_EXTEND 0x0008
  205. #define NFS_ACCESS_DELETE 0x0010
  206. #define NFS_ACCESS_EXECUTE 0x0020
  207. #define NFS_ACCESS_XAREAD 0x0040
  208. #define NFS_ACCESS_XAWRITE 0x0080
  209. #define NFS_ACCESS_XALIST 0x0100
  210. /*
  211. * Cache validity bit flags
  212. */
  213. #define NFS_INO_INVALID_DATA BIT(1) /* cached data is invalid */
  214. #define NFS_INO_INVALID_ATIME BIT(2) /* cached atime is invalid */
  215. #define NFS_INO_INVALID_ACCESS BIT(3) /* cached access cred invalid */
  216. #define NFS_INO_INVALID_ACL BIT(4) /* cached acls are invalid */
  217. #define NFS_INO_REVAL_FORCED BIT(6) /* force revalidation ignoring a delegation */
  218. #define NFS_INO_INVALID_LABEL BIT(7) /* cached label is invalid */
  219. #define NFS_INO_INVALID_CHANGE BIT(8) /* cached change is invalid */
  220. #define NFS_INO_INVALID_CTIME BIT(9) /* cached ctime is invalid */
  221. #define NFS_INO_INVALID_MTIME BIT(10) /* cached mtime is invalid */
  222. #define NFS_INO_INVALID_SIZE BIT(11) /* cached size is invalid */
  223. #define NFS_INO_INVALID_OTHER BIT(12) /* other attrs are invalid */
  224. #define NFS_INO_DATA_INVAL_DEFER \
  225. BIT(13) /* Deferred cache invalidation */
  226. #define NFS_INO_INVALID_BLOCKS BIT(14) /* cached blocks are invalid */
  227. #define NFS_INO_INVALID_XATTR BIT(15) /* xattrs are invalid */
  228. #define NFS_INO_INVALID_NLINK BIT(16) /* cached nlinks is invalid */
  229. #define NFS_INO_INVALID_MODE BIT(17) /* cached mode is invalid */
  230. #define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \
  231. | NFS_INO_INVALID_CTIME \
  232. | NFS_INO_INVALID_MTIME \
  233. | NFS_INO_INVALID_SIZE \
  234. | NFS_INO_INVALID_NLINK \
  235. | NFS_INO_INVALID_MODE \
  236. | NFS_INO_INVALID_OTHER) /* inode metadata is invalid */
  237. /*
  238. * Bit offsets in flags field
  239. */
  240. #define NFS_INO_STALE (1) /* possible stale inode */
  241. #define NFS_INO_ACL_LRU_SET (2) /* Inode is on the LRU list */
  242. #define NFS_INO_INVALIDATING (3) /* inode is being invalidated */
  243. #define NFS_INO_PRESERVE_UNLINKED (4) /* preserve file if removed while open */
  244. #define NFS_INO_FSCACHE (5) /* inode can be cached by FS-Cache */
  245. #define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */
  246. #define NFS_INO_LAYOUTCOMMITTING (10) /* layoutcommit inflight */
  247. #define NFS_INO_LAYOUTSTATS (11) /* layoutstats inflight */
  248. #define NFS_INO_ODIRECT (12) /* I/O setting is O_DIRECT */
  249. static inline struct nfs_inode *NFS_I(const struct inode *inode)
  250. {
  251. return container_of(inode, struct nfs_inode, vfs_inode);
  252. }
  253. static inline struct nfs_server *NFS_SB(const struct super_block *s)
  254. {
  255. return (struct nfs_server *)(s->s_fs_info);
  256. }
  257. static inline struct nfs_fh *NFS_FH(const struct inode *inode)
  258. {
  259. return &NFS_I(inode)->fh;
  260. }
  261. static inline struct nfs_server *NFS_SERVER(const struct inode *inode)
  262. {
  263. return NFS_SB(inode->i_sb);
  264. }
  265. static inline struct rpc_clnt *NFS_CLIENT(const struct inode *inode)
  266. {
  267. return NFS_SERVER(inode)->client;
  268. }
  269. static inline const struct nfs_rpc_ops *NFS_PROTO(const struct inode *inode)
  270. {
  271. return NFS_SERVER(inode)->nfs_client->rpc_ops;
  272. }
  273. static inline unsigned NFS_MINATTRTIMEO(const struct inode *inode)
  274. {
  275. struct nfs_server *nfss = NFS_SERVER(inode);
  276. return S_ISDIR(inode->i_mode) ? nfss->acdirmin : nfss->acregmin;
  277. }
  278. static inline unsigned NFS_MAXATTRTIMEO(const struct inode *inode)
  279. {
  280. struct nfs_server *nfss = NFS_SERVER(inode);
  281. return S_ISDIR(inode->i_mode) ? nfss->acdirmax : nfss->acregmax;
  282. }
  283. static inline int NFS_STALE(const struct inode *inode)
  284. {
  285. return test_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
  286. }
  287. static inline struct fscache_cookie *nfs_i_fscache(struct inode *inode)
  288. {
  289. #ifdef CONFIG_NFS_FSCACHE
  290. return NFS_I(inode)->fscache;
  291. #else
  292. return NULL;
  293. #endif
  294. }
  295. static inline __u64 NFS_FILEID(const struct inode *inode)
  296. {
  297. return NFS_I(inode)->fileid;
  298. }
  299. static inline void set_nfs_fileid(struct inode *inode, __u64 fileid)
  300. {
  301. NFS_I(inode)->fileid = fileid;
  302. }
  303. static inline void nfs_mark_for_revalidate(struct inode *inode)
  304. {
  305. struct nfs_inode *nfsi = NFS_I(inode);
  306. spin_lock(&inode->i_lock);
  307. nfsi->cache_validity |= NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL |
  308. NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME |
  309. NFS_INO_INVALID_SIZE;
  310. if (S_ISDIR(inode->i_mode))
  311. nfsi->cache_validity |= NFS_INO_INVALID_DATA;
  312. spin_unlock(&inode->i_lock);
  313. }
  314. static inline int nfs_server_capable(const struct inode *inode, int cap)
  315. {
  316. return NFS_SERVER(inode)->caps & cap;
  317. }
  318. /**
  319. * nfs_save_change_attribute - Returns the inode attribute change cookie
  320. * @dir - pointer to parent directory inode
  321. * The "cache change attribute" is updated when we need to revalidate
  322. * our dentry cache after a directory was seen to change on the server.
  323. */
  324. static inline unsigned long nfs_save_change_attribute(struct inode *dir)
  325. {
  326. return NFS_I(dir)->cache_change_attribute;
  327. }
  328. /*
  329. * linux/fs/nfs/inode.c
  330. */
  331. extern int nfs_sync_mapping(struct address_space *mapping);
  332. extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
  333. extern void nfs_zap_caches(struct inode *);
  334. extern void nfs_set_inode_stale(struct inode *inode);
  335. extern void nfs_invalidate_atime(struct inode *);
  336. extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
  337. struct nfs_fattr *);
  338. struct inode *nfs_ilookup(struct super_block *sb, struct nfs_fattr *, struct nfs_fh *);
  339. extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
  340. extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
  341. extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
  342. extern int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fattr *fattr);
  343. extern int nfs_getattr(struct user_namespace *, const struct path *,
  344. struct kstat *, u32, unsigned int);
  345. extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *, const struct cred *);
  346. extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
  347. extern int nfs_permission(struct user_namespace *, struct inode *, int);
  348. extern int nfs_open(struct inode *, struct file *);
  349. extern int nfs_attribute_cache_expired(struct inode *inode);
  350. extern int nfs_revalidate_inode(struct inode *inode, unsigned long flags);
  351. extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
  352. extern int nfs_clear_invalid_mapping(struct address_space *mapping);
  353. extern bool nfs_mapping_need_revalidate_inode(struct inode *inode);
  354. extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping);
  355. extern int nfs_revalidate_mapping_rcu(struct inode *inode);
  356. extern int nfs_setattr(struct user_namespace *, struct dentry *, struct iattr *);
  357. extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, struct nfs_fattr *);
  358. extern void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr);
  359. extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
  360. extern void put_nfs_open_context(struct nfs_open_context *ctx);
  361. extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct cred *cred, fmode_t mode);
  362. extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode, struct file *filp);
  363. extern void nfs_inode_attach_open_context(struct nfs_open_context *ctx);
  364. extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
  365. extern void nfs_file_clear_open_context(struct file *flip);
  366. extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx);
  367. extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx);
  368. extern u64 nfs_compat_user_ino64(u64 fileid);
  369. extern void nfs_fattr_init(struct nfs_fattr *fattr);
  370. extern void nfs_fattr_set_barrier(struct nfs_fattr *fattr);
  371. extern unsigned long nfs_inc_attr_generation_counter(void);
  372. extern struct nfs_fattr *nfs_alloc_fattr(void);
  373. extern struct nfs_fattr *nfs_alloc_fattr_with_label(struct nfs_server *server);
  374. static inline void nfs4_label_free(struct nfs4_label *label)
  375. {
  376. #ifdef CONFIG_NFS_V4_SECURITY_LABEL
  377. if (label) {
  378. kfree(label->label);
  379. kfree(label);
  380. }
  381. #endif
  382. }
  383. static inline void nfs_free_fattr(const struct nfs_fattr *fattr)
  384. {
  385. if (fattr)
  386. nfs4_label_free(fattr->label);
  387. kfree(fattr);
  388. }
  389. extern struct nfs_fh *nfs_alloc_fhandle(void);
  390. static inline void nfs_free_fhandle(const struct nfs_fh *fh)
  391. {
  392. kfree(fh);
  393. }
  394. #ifdef NFS_DEBUG
  395. extern u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh);
  396. static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
  397. {
  398. return _nfs_display_fhandle_hash(fh);
  399. }
  400. extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
  401. #define nfs_display_fhandle(fh, caption) \
  402. do { \
  403. if (unlikely(nfs_debug & NFSDBG_FACILITY)) \
  404. _nfs_display_fhandle(fh, caption); \
  405. } while (0)
  406. #else
  407. static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
  408. {
  409. return 0;
  410. }
  411. static inline void nfs_display_fhandle(const struct nfs_fh *fh,
  412. const char *caption)
  413. {
  414. }
  415. #endif
  416. /*
  417. * linux/fs/nfs/nfsroot.c
  418. */
  419. extern int nfs_root_data(char **root_device, char **root_data); /*__init*/
  420. /* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
  421. extern __be32 root_nfs_parse_addr(char *name); /*__init*/
  422. /*
  423. * linux/fs/nfs/file.c
  424. */
  425. extern const struct file_operations nfs_file_operations;
  426. #if IS_ENABLED(CONFIG_NFS_V4)
  427. extern const struct file_operations nfs4_file_operations;
  428. #endif /* CONFIG_NFS_V4 */
  429. extern const struct address_space_operations nfs_file_aops;
  430. extern const struct address_space_operations nfs_dir_aops;
  431. static inline struct nfs_open_context *nfs_file_open_context(struct file *filp)
  432. {
  433. return filp->private_data;
  434. }
  435. static inline const struct cred *nfs_file_cred(struct file *file)
  436. {
  437. if (file != NULL) {
  438. struct nfs_open_context *ctx =
  439. nfs_file_open_context(file);
  440. if (ctx)
  441. return ctx->cred;
  442. }
  443. return NULL;
  444. }
  445. /*
  446. * linux/fs/nfs/direct.c
  447. */
  448. int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter);
  449. ssize_t nfs_file_direct_read(struct kiocb *iocb,
  450. struct iov_iter *iter, bool swap);
  451. ssize_t nfs_file_direct_write(struct kiocb *iocb,
  452. struct iov_iter *iter, bool swap);
  453. /*
  454. * linux/fs/nfs/dir.c
  455. */
  456. extern const struct file_operations nfs_dir_operations;
  457. extern const struct dentry_operations nfs_dentry_operations;
  458. extern void nfs_force_lookup_revalidate(struct inode *dir);
  459. extern void nfs_set_verifier(struct dentry * dentry, unsigned long verf);
  460. #if IS_ENABLED(CONFIG_NFS_V4)
  461. extern void nfs_clear_verifier_delegated(struct inode *inode);
  462. #endif /* IS_ENABLED(CONFIG_NFS_V4) */
  463. extern struct dentry *nfs_add_or_obtain(struct dentry *dentry,
  464. struct nfs_fh *fh, struct nfs_fattr *fattr);
  465. extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh,
  466. struct nfs_fattr *fattr);
  467. extern int nfs_may_open(struct inode *inode, const struct cred *cred, int openflags);
  468. extern void nfs_access_zap_cache(struct inode *inode);
  469. extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred,
  470. u32 *mask, bool may_block);
  471. /*
  472. * linux/fs/nfs/symlink.c
  473. */
  474. extern const struct inode_operations nfs_symlink_inode_operations;
  475. /*
  476. * linux/fs/nfs/sysctl.c
  477. */
  478. #ifdef CONFIG_SYSCTL
  479. extern int nfs_register_sysctl(void);
  480. extern void nfs_unregister_sysctl(void);
  481. #else
  482. #define nfs_register_sysctl() 0
  483. #define nfs_unregister_sysctl() do { } while(0)
  484. #endif
  485. /*
  486. * linux/fs/nfs/namespace.c
  487. */
  488. extern const struct inode_operations nfs_mountpoint_inode_operations;
  489. extern const struct inode_operations nfs_referral_inode_operations;
  490. extern int nfs_mountpoint_expiry_timeout;
  491. extern void nfs_release_automount_timer(void);
  492. /*
  493. * linux/fs/nfs/unlink.c
  494. */
  495. extern void nfs_complete_unlink(struct dentry *dentry, struct inode *);
  496. /*
  497. * linux/fs/nfs/write.c
  498. */
  499. extern int nfs_congestion_kb;
  500. extern int nfs_writepage(struct page *page, struct writeback_control *wbc);
  501. extern int nfs_writepages(struct address_space *, struct writeback_control *);
  502. extern int nfs_flush_incompatible(struct file *file, struct page *page);
  503. extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
  504. /*
  505. * Try to write back everything synchronously (but check the
  506. * return value!)
  507. */
  508. extern int nfs_sync_inode(struct inode *inode);
  509. extern int nfs_wb_all(struct inode *inode);
  510. extern int nfs_wb_page(struct inode *inode, struct page *page);
  511. int nfs_wb_folio_cancel(struct inode *inode, struct folio *folio);
  512. extern int nfs_commit_inode(struct inode *, int);
  513. extern struct nfs_commit_data *nfs_commitdata_alloc(void);
  514. extern void nfs_commit_free(struct nfs_commit_data *data);
  515. bool nfs_commit_end(struct nfs_mds_commit_info *cinfo);
  516. static inline bool nfs_have_writebacks(const struct inode *inode)
  517. {
  518. if (S_ISREG(inode->i_mode))
  519. return atomic_long_read(&NFS_I(inode)->nrequests) != 0;
  520. return false;
  521. }
  522. /*
  523. * linux/fs/nfs/read.c
  524. */
  525. int nfs_read_folio(struct file *, struct folio *);
  526. void nfs_readahead(struct readahead_control *);
  527. /*
  528. * inline functions
  529. */
  530. static inline loff_t nfs_size_to_loff_t(__u64 size)
  531. {
  532. return min_t(u64, size, OFFSET_MAX);
  533. }
  534. static inline ino_t
  535. nfs_fileid_to_ino_t(u64 fileid)
  536. {
  537. ino_t ino = (ino_t) fileid;
  538. if (sizeof(ino_t) < sizeof(u64))
  539. ino ^= fileid >> (sizeof(u64)-sizeof(ino_t)) * 8;
  540. return ino;
  541. }
  542. #define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
  543. /* We need to block new opens while a file is being unlinked.
  544. * If it is opened *before* we decide to unlink, we will silly-rename
  545. * instead. If it is opened *after*, then we need to create or will fail.
  546. * If we allow the two to race, we could end up with a file that is open
  547. * but deleted on the server resulting in ESTALE.
  548. * So use ->d_fsdata to record when the unlink is happening
  549. * and block dentry revalidation while it is set.
  550. */
  551. #define NFS_FSDATA_BLOCKED ((void*)1)
  552. # undef ifdebug
  553. # ifdef NFS_DEBUG
  554. # define ifdebug(fac) if (unlikely(nfs_debug & NFSDBG_##fac))
  555. # define NFS_IFDEBUG(x) x
  556. # else
  557. # define ifdebug(fac) if (0)
  558. # define NFS_IFDEBUG(x)
  559. # endif
  560. #endif