nfs_fs.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /*
  2. * linux/include/linux/nfs_fs.h
  3. *
  4. * Copyright (C) 1992 Rick Sladkey
  5. *
  6. * OS-specific nfs filesystem definitions and declarations
  7. */
  8. #ifndef _LINUX_NFS_FS_H
  9. #define _LINUX_NFS_FS_H
  10. #include <uapi/linux/nfs_fs.h>
  11. /*
  12. * Enable dprintk() debugging support for nfs client.
  13. */
  14. #ifdef CONFIG_NFS_DEBUG
  15. # define NFS_DEBUG
  16. #endif
  17. #include <linux/in.h>
  18. #include <linux/mm.h>
  19. #include <linux/pagemap.h>
  20. #include <linux/rbtree.h>
  21. #include <linux/rwsem.h>
  22. #include <linux/wait.h>
  23. #include <linux/sunrpc/debug.h>
  24. #include <linux/sunrpc/auth.h>
  25. #include <linux/sunrpc/clnt.h>
  26. #include <linux/nfs.h>
  27. #include <linux/nfs2.h>
  28. #include <linux/nfs3.h>
  29. #include <linux/nfs4.h>
  30. #include <linux/nfs_xdr.h>
  31. #include <linux/nfs_fs_sb.h>
  32. #include <linux/mempool.h>
  33. /*
  34. * These are the default flags for swap requests
  35. */
  36. #define NFS_RPC_SWAPFLAGS (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
  37. /*
  38. * NFSv3/v4 Access mode cache entry
  39. */
  40. struct nfs_access_entry {
  41. struct rb_node rb_node;
  42. struct list_head lru;
  43. unsigned long jiffies;
  44. struct rpc_cred * cred;
  45. int mask;
  46. };
  47. struct nfs_lockowner {
  48. fl_owner_t l_owner;
  49. pid_t l_pid;
  50. };
  51. #define NFS_IO_INPROGRESS 0
  52. struct nfs_io_counter {
  53. unsigned long flags;
  54. atomic_t io_count;
  55. };
  56. struct nfs_lock_context {
  57. atomic_t count;
  58. struct list_head list;
  59. struct nfs_open_context *open_context;
  60. struct nfs_lockowner lockowner;
  61. struct nfs_io_counter io_count;
  62. };
  63. struct nfs4_state;
  64. struct nfs_open_context {
  65. struct nfs_lock_context lock_context;
  66. struct dentry *dentry;
  67. struct rpc_cred *cred;
  68. struct nfs4_state *state;
  69. fmode_t mode;
  70. unsigned long flags;
  71. #define NFS_CONTEXT_ERROR_WRITE (0)
  72. #define NFS_CONTEXT_RESEND_WRITES (1)
  73. #define NFS_CONTEXT_BAD (2)
  74. int error;
  75. struct list_head list;
  76. struct nfs4_threshold *mdsthreshold;
  77. };
  78. struct nfs_open_dir_context {
  79. struct rpc_cred *cred;
  80. unsigned long attr_gencount;
  81. __u64 dir_cookie;
  82. __u64 dup_cookie;
  83. signed char duped;
  84. };
  85. /*
  86. * NFSv4 delegation
  87. */
  88. struct nfs_delegation;
  89. struct posix_acl;
  90. /*
  91. * nfs fs inode data in memory
  92. */
  93. struct nfs_inode {
  94. /*
  95. * The 64bit 'inode number'
  96. */
  97. __u64 fileid;
  98. /*
  99. * NFS file handle
  100. */
  101. struct nfs_fh fh;
  102. /*
  103. * Various flags
  104. */
  105. unsigned long flags; /* atomic bit ops */
  106. unsigned long cache_validity; /* bit mask */
  107. /*
  108. * read_cache_jiffies is when we started read-caching this inode.
  109. * attrtimeo is for how long the cached information is assumed
  110. * to be valid. A successful attribute revalidation doubles
  111. * attrtimeo (up to acregmax/acdirmax), a failure resets it to
  112. * acregmin/acdirmin.
  113. *
  114. * We need to revalidate the cached attrs for this inode if
  115. *
  116. * jiffies - read_cache_jiffies >= attrtimeo
  117. *
  118. * Please note the comparison is greater than or equal
  119. * so that zero timeout values can be specified.
  120. */
  121. unsigned long read_cache_jiffies;
  122. unsigned long attrtimeo;
  123. unsigned long attrtimeo_timestamp;
  124. unsigned long attr_gencount;
  125. /* "Generation counter" for the attribute cache. This is
  126. * bumped whenever we update the metadata on the
  127. * server.
  128. */
  129. unsigned long cache_change_attribute;
  130. struct rb_root access_cache;
  131. struct list_head access_cache_entry_lru;
  132. struct list_head access_cache_inode_lru;
  133. #ifdef CONFIG_NFS_V3_ACL
  134. struct posix_acl *acl_access;
  135. struct posix_acl *acl_default;
  136. #endif
  137. /*
  138. * This is the cookie verifier used for NFSv3 readdir
  139. * operations
  140. */
  141. __be32 cookieverf[2];
  142. unsigned long npages;
  143. struct nfs_mds_commit_info commit_info;
  144. /* Open contexts for shared mmap writes */
  145. struct list_head open_files;
  146. /* Number of in-flight sillydelete RPC calls */
  147. atomic_t silly_count;
  148. /* List of deferred sillydelete requests */
  149. struct hlist_head silly_list;
  150. wait_queue_head_t waitqueue;
  151. #if IS_ENABLED(CONFIG_NFS_V4)
  152. struct nfs4_cached_acl *nfs4_acl;
  153. /* NFSv4 state */
  154. struct list_head open_states;
  155. struct nfs_delegation __rcu *delegation;
  156. fmode_t delegation_state;
  157. struct rw_semaphore rwsem;
  158. /* pNFS layout information */
  159. struct pnfs_layout_hdr *layout;
  160. #endif /* CONFIG_NFS_V4*/
  161. /* how many bytes have been written/read and how many bytes queued up */
  162. __u64 write_io;
  163. __u64 read_io;
  164. #ifdef CONFIG_NFS_FSCACHE
  165. struct fscache_cookie *fscache;
  166. #endif
  167. struct inode vfs_inode;
  168. };
  169. /*
  170. * Cache validity bit flags
  171. */
  172. #define NFS_INO_INVALID_ATTR 0x0001 /* cached attrs are invalid */
  173. #define NFS_INO_INVALID_DATA 0x0002 /* cached data is invalid */
  174. #define NFS_INO_INVALID_ATIME 0x0004 /* cached atime is invalid */
  175. #define NFS_INO_INVALID_ACCESS 0x0008 /* cached access cred invalid */
  176. #define NFS_INO_INVALID_ACL 0x0010 /* cached acls are invalid */
  177. #define NFS_INO_REVAL_PAGECACHE 0x0020 /* must revalidate pagecache */
  178. #define NFS_INO_REVAL_FORCED 0x0040 /* force revalidation ignoring a delegation */
  179. #define NFS_INO_INVALID_LABEL 0x0080 /* cached label is invalid */
  180. /*
  181. * Bit offsets in flags field
  182. */
  183. #define NFS_INO_ADVISE_RDPLUS (0) /* advise readdirplus */
  184. #define NFS_INO_STALE (1) /* possible stale inode */
  185. #define NFS_INO_ACL_LRU_SET (2) /* Inode is on the LRU list */
  186. #define NFS_INO_FLUSHING (4) /* inode is flushing out data */
  187. #define NFS_INO_FSCACHE (5) /* inode can be cached by FS-Cache */
  188. #define NFS_INO_FSCACHE_LOCK (6) /* FS-Cache cookie management lock */
  189. #define NFS_INO_COMMIT (7) /* inode is committing unstable writes */
  190. #define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */
  191. #define NFS_INO_LAYOUTCOMMITTING (10) /* layoutcommit inflight */
  192. static inline struct nfs_inode *NFS_I(const struct inode *inode)
  193. {
  194. return container_of(inode, struct nfs_inode, vfs_inode);
  195. }
  196. static inline struct nfs_server *NFS_SB(const struct super_block *s)
  197. {
  198. return (struct nfs_server *)(s->s_fs_info);
  199. }
  200. static inline struct nfs_fh *NFS_FH(const struct inode *inode)
  201. {
  202. return &NFS_I(inode)->fh;
  203. }
  204. static inline struct nfs_server *NFS_SERVER(const struct inode *inode)
  205. {
  206. return NFS_SB(inode->i_sb);
  207. }
  208. static inline struct rpc_clnt *NFS_CLIENT(const struct inode *inode)
  209. {
  210. return NFS_SERVER(inode)->client;
  211. }
  212. static inline const struct nfs_rpc_ops *NFS_PROTO(const struct inode *inode)
  213. {
  214. return NFS_SERVER(inode)->nfs_client->rpc_ops;
  215. }
  216. static inline unsigned NFS_MINATTRTIMEO(const struct inode *inode)
  217. {
  218. struct nfs_server *nfss = NFS_SERVER(inode);
  219. return S_ISDIR(inode->i_mode) ? nfss->acdirmin : nfss->acregmin;
  220. }
  221. static inline unsigned NFS_MAXATTRTIMEO(const struct inode *inode)
  222. {
  223. struct nfs_server *nfss = NFS_SERVER(inode);
  224. return S_ISDIR(inode->i_mode) ? nfss->acdirmax : nfss->acregmax;
  225. }
  226. static inline int NFS_STALE(const struct inode *inode)
  227. {
  228. return test_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
  229. }
  230. static inline struct fscache_cookie *nfs_i_fscache(struct inode *inode)
  231. {
  232. #ifdef CONFIG_NFS_FSCACHE
  233. return NFS_I(inode)->fscache;
  234. #else
  235. return NULL;
  236. #endif
  237. }
  238. static inline __u64 NFS_FILEID(const struct inode *inode)
  239. {
  240. return NFS_I(inode)->fileid;
  241. }
  242. static inline void set_nfs_fileid(struct inode *inode, __u64 fileid)
  243. {
  244. NFS_I(inode)->fileid = fileid;
  245. }
  246. static inline void nfs_mark_for_revalidate(struct inode *inode)
  247. {
  248. struct nfs_inode *nfsi = NFS_I(inode);
  249. spin_lock(&inode->i_lock);
  250. nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS;
  251. if (S_ISDIR(inode->i_mode))
  252. nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA;
  253. spin_unlock(&inode->i_lock);
  254. }
  255. static inline int nfs_server_capable(struct inode *inode, int cap)
  256. {
  257. return NFS_SERVER(inode)->caps & cap;
  258. }
  259. static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf)
  260. {
  261. dentry->d_time = verf;
  262. }
  263. /**
  264. * nfs_save_change_attribute - Returns the inode attribute change cookie
  265. * @dir - pointer to parent directory inode
  266. * The "change attribute" is updated every time we finish an operation
  267. * that will result in a metadata change on the server.
  268. */
  269. static inline unsigned long nfs_save_change_attribute(struct inode *dir)
  270. {
  271. return NFS_I(dir)->cache_change_attribute;
  272. }
  273. /**
  274. * nfs_verify_change_attribute - Detects NFS remote directory changes
  275. * @dir - pointer to parent directory inode
  276. * @chattr - previously saved change attribute
  277. * Return "false" if the verifiers doesn't match the change attribute.
  278. * This would usually indicate that the directory contents have changed on
  279. * the server, and that any dentries need revalidating.
  280. */
  281. static inline int nfs_verify_change_attribute(struct inode *dir, unsigned long chattr)
  282. {
  283. return chattr == NFS_I(dir)->cache_change_attribute;
  284. }
  285. /*
  286. * linux/fs/nfs/inode.c
  287. */
  288. extern int nfs_sync_mapping(struct address_space *mapping);
  289. extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
  290. extern void nfs_zap_caches(struct inode *);
  291. extern void nfs_invalidate_atime(struct inode *);
  292. extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
  293. struct nfs_fattr *, struct nfs4_label *);
  294. extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
  295. extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
  296. extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
  297. extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
  298. extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *);
  299. extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
  300. extern int nfs_permission(struct inode *, int);
  301. extern int nfs_open(struct inode *, struct file *);
  302. extern int nfs_release(struct inode *, struct file *);
  303. extern int nfs_attribute_timeout(struct inode *inode);
  304. extern int nfs_attribute_cache_expired(struct inode *inode);
  305. extern int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode);
  306. extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
  307. extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping);
  308. extern int nfs_setattr(struct dentry *, struct iattr *);
  309. extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr);
  310. extern void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr,
  311. struct nfs4_label *label);
  312. extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
  313. extern void put_nfs_open_context(struct nfs_open_context *ctx);
  314. extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode);
  315. extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode);
  316. extern void nfs_inode_attach_open_context(struct nfs_open_context *ctx);
  317. extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
  318. extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx);
  319. extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx);
  320. extern u64 nfs_compat_user_ino64(u64 fileid);
  321. extern void nfs_fattr_init(struct nfs_fattr *fattr);
  322. extern unsigned long nfs_inc_attr_generation_counter(void);
  323. extern struct nfs_fattr *nfs_alloc_fattr(void);
  324. static inline void nfs_free_fattr(const struct nfs_fattr *fattr)
  325. {
  326. kfree(fattr);
  327. }
  328. extern struct nfs_fh *nfs_alloc_fhandle(void);
  329. static inline void nfs_free_fhandle(const struct nfs_fh *fh)
  330. {
  331. kfree(fh);
  332. }
  333. #ifdef NFS_DEBUG
  334. extern u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh);
  335. static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
  336. {
  337. return _nfs_display_fhandle_hash(fh);
  338. }
  339. extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
  340. #define nfs_display_fhandle(fh, caption) \
  341. do { \
  342. if (unlikely(nfs_debug & NFSDBG_FACILITY)) \
  343. _nfs_display_fhandle(fh, caption); \
  344. } while (0)
  345. #else
  346. static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
  347. {
  348. return 0;
  349. }
  350. static inline void nfs_display_fhandle(const struct nfs_fh *fh,
  351. const char *caption)
  352. {
  353. }
  354. #endif
  355. /*
  356. * linux/fs/nfs/nfsroot.c
  357. */
  358. extern int nfs_root_data(char **root_device, char **root_data); /*__init*/
  359. /* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
  360. extern __be32 root_nfs_parse_addr(char *name); /*__init*/
  361. /*
  362. * linux/fs/nfs/file.c
  363. */
  364. extern const struct file_operations nfs_file_operations;
  365. #if IS_ENABLED(CONFIG_NFS_V4)
  366. extern const struct file_operations nfs4_file_operations;
  367. #endif /* CONFIG_NFS_V4 */
  368. extern const struct address_space_operations nfs_file_aops;
  369. extern const struct address_space_operations nfs_dir_aops;
  370. static inline struct nfs_open_context *nfs_file_open_context(struct file *filp)
  371. {
  372. return filp->private_data;
  373. }
  374. static inline struct rpc_cred *nfs_file_cred(struct file *file)
  375. {
  376. if (file != NULL) {
  377. struct nfs_open_context *ctx =
  378. nfs_file_open_context(file);
  379. if (ctx)
  380. return ctx->cred;
  381. }
  382. return NULL;
  383. }
  384. /*
  385. * linux/fs/nfs/xattr.c
  386. */
  387. #ifdef CONFIG_NFS_V3_ACL
  388. extern ssize_t nfs3_listxattr(struct dentry *, char *, size_t);
  389. extern ssize_t nfs3_getxattr(struct dentry *, const char *, void *, size_t);
  390. extern int nfs3_setxattr(struct dentry *, const char *,
  391. const void *, size_t, int);
  392. extern int nfs3_removexattr (struct dentry *, const char *name);
  393. #else
  394. # define nfs3_listxattr NULL
  395. # define nfs3_getxattr NULL
  396. # define nfs3_setxattr NULL
  397. # define nfs3_removexattr NULL
  398. #endif
  399. /*
  400. * linux/fs/nfs/direct.c
  401. */
  402. extern ssize_t nfs_direct_IO(int, struct kiocb *, const struct iovec *, loff_t,
  403. unsigned long);
  404. extern ssize_t nfs_file_direct_read(struct kiocb *iocb,
  405. const struct iovec *iov, unsigned long nr_segs,
  406. loff_t pos, bool uio);
  407. extern ssize_t nfs_file_direct_write(struct kiocb *iocb,
  408. const struct iovec *iov, unsigned long nr_segs,
  409. loff_t pos, bool uio);
  410. /*
  411. * linux/fs/nfs/dir.c
  412. */
  413. extern const struct file_operations nfs_dir_operations;
  414. extern const struct dentry_operations nfs_dentry_operations;
  415. extern void nfs_force_lookup_revalidate(struct inode *dir);
  416. extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh,
  417. struct nfs_fattr *fattr, struct nfs4_label *label);
  418. extern int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags);
  419. extern void nfs_access_zap_cache(struct inode *inode);
  420. /*
  421. * linux/fs/nfs/symlink.c
  422. */
  423. extern const struct inode_operations nfs_symlink_inode_operations;
  424. /*
  425. * linux/fs/nfs/sysctl.c
  426. */
  427. #ifdef CONFIG_SYSCTL
  428. extern int nfs_register_sysctl(void);
  429. extern void nfs_unregister_sysctl(void);
  430. #else
  431. #define nfs_register_sysctl() 0
  432. #define nfs_unregister_sysctl() do { } while(0)
  433. #endif
  434. /*
  435. * linux/fs/nfs/namespace.c
  436. */
  437. extern const struct inode_operations nfs_mountpoint_inode_operations;
  438. extern const struct inode_operations nfs_referral_inode_operations;
  439. extern int nfs_mountpoint_expiry_timeout;
  440. extern void nfs_release_automount_timer(void);
  441. /*
  442. * linux/fs/nfs/nfs4proc.c
  443. */
  444. #ifdef CONFIG_NFS_V4_SECURITY_LABEL
  445. extern struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags);
  446. static inline void nfs4_label_free(struct nfs4_label *label)
  447. {
  448. if (label) {
  449. kfree(label->label);
  450. kfree(label);
  451. }
  452. return;
  453. }
  454. #else
  455. static inline struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags) { return NULL; }
  456. static inline void nfs4_label_free(void *label) {}
  457. #endif
  458. /*
  459. * linux/fs/nfs/unlink.c
  460. */
  461. extern void nfs_complete_unlink(struct dentry *dentry, struct inode *);
  462. extern void nfs_wait_on_sillyrename(struct dentry *dentry);
  463. extern void nfs_block_sillyrename(struct dentry *dentry);
  464. extern void nfs_unblock_sillyrename(struct dentry *dentry);
  465. extern int nfs_sillyrename(struct inode *dir, struct dentry *dentry);
  466. /*
  467. * linux/fs/nfs/write.c
  468. */
  469. extern int nfs_congestion_kb;
  470. extern int nfs_writepage(struct page *page, struct writeback_control *wbc);
  471. extern int nfs_writepages(struct address_space *, struct writeback_control *);
  472. extern int nfs_flush_incompatible(struct file *file, struct page *page);
  473. extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
  474. extern void nfs_writeback_done(struct rpc_task *, struct nfs_write_data *);
  475. /*
  476. * Try to write back everything synchronously (but check the
  477. * return value!)
  478. */
  479. extern int nfs_wb_all(struct inode *inode);
  480. extern int nfs_wb_page(struct inode *inode, struct page* page);
  481. extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
  482. #if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
  483. extern int nfs_commit_inode(struct inode *, int);
  484. extern struct nfs_commit_data *nfs_commitdata_alloc(void);
  485. extern void nfs_commit_free(struct nfs_commit_data *data);
  486. #else
  487. static inline int
  488. nfs_commit_inode(struct inode *inode, int how)
  489. {
  490. return 0;
  491. }
  492. #endif
  493. static inline int
  494. nfs_have_writebacks(struct inode *inode)
  495. {
  496. return NFS_I(inode)->npages != 0;
  497. }
  498. /*
  499. * linux/fs/nfs/read.c
  500. */
  501. extern int nfs_readpage(struct file *, struct page *);
  502. extern int nfs_readpages(struct file *, struct address_space *,
  503. struct list_head *, unsigned);
  504. extern int nfs_readpage_result(struct rpc_task *, struct nfs_read_data *);
  505. extern int nfs_readpage_async(struct nfs_open_context *, struct inode *,
  506. struct page *);
  507. /*
  508. * linux/fs/nfs3proc.c
  509. */
  510. #ifdef CONFIG_NFS_V3_ACL
  511. extern struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type);
  512. extern int nfs3_proc_setacl(struct inode *inode, int type,
  513. struct posix_acl *acl);
  514. extern int nfs3_proc_set_default_acl(struct inode *dir, struct inode *inode,
  515. umode_t mode);
  516. extern void nfs3_forget_cached_acls(struct inode *inode);
  517. #else
  518. static inline int nfs3_proc_set_default_acl(struct inode *dir,
  519. struct inode *inode,
  520. umode_t mode)
  521. {
  522. return 0;
  523. }
  524. static inline void nfs3_forget_cached_acls(struct inode *inode)
  525. {
  526. }
  527. #endif /* CONFIG_NFS_V3_ACL */
  528. /*
  529. * inline functions
  530. */
  531. static inline loff_t nfs_size_to_loff_t(__u64 size)
  532. {
  533. if (size > (__u64) OFFSET_MAX - 1)
  534. return OFFSET_MAX - 1;
  535. return (loff_t) size;
  536. }
  537. static inline ino_t
  538. nfs_fileid_to_ino_t(u64 fileid)
  539. {
  540. ino_t ino = (ino_t) fileid;
  541. if (sizeof(ino_t) < sizeof(u64))
  542. ino ^= fileid >> (sizeof(u64)-sizeof(ino_t)) * 8;
  543. return ino;
  544. }
  545. #define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
  546. # undef ifdebug
  547. # ifdef NFS_DEBUG
  548. # define ifdebug(fac) if (unlikely(nfs_debug & NFSDBG_##fac))
  549. # define NFS_IFDEBUG(x) x
  550. # else
  551. # define ifdebug(fac) if (0)
  552. # define NFS_IFDEBUG(x)
  553. # endif
  554. #endif