nfs42.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com>
  4. */
  5. #ifndef __LINUX_FS_NFS_NFS4_2_H
  6. #define __LINUX_FS_NFS_NFS4_2_H
  7. #include <linux/xattr.h>
  8. /*
  9. * FIXME: four LAYOUTSTATS calls per compound at most! Do we need to support
  10. * more? Need to consider not to pre-alloc too much for a compound.
  11. */
  12. #define PNFS_LAYOUTSTATS_MAXDEV (4)
  13. #define READ_PLUS_SCRATCH_SIZE (16)
  14. /* nfs4.2proc.c */
  15. #ifdef CONFIG_NFS_V4_2
  16. int nfs42_proc_allocate(struct file *, loff_t, loff_t);
  17. ssize_t nfs42_proc_copy(struct file *, loff_t, struct file *, loff_t, size_t,
  18. struct nl4_server *, nfs4_stateid *, bool);
  19. int nfs42_proc_deallocate(struct file *, loff_t, loff_t);
  20. int nfs42_proc_zero_range(struct file *, loff_t, loff_t);
  21. loff_t nfs42_proc_llseek(struct file *, loff_t, int);
  22. int nfs42_proc_layoutstats_generic(struct nfs_server *,
  23. struct nfs42_layoutstat_data *);
  24. int nfs42_proc_clone(struct file *, struct file *, loff_t, loff_t, loff_t);
  25. int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg,
  26. const struct nfs42_layout_error *errors,
  27. size_t n);
  28. int nfs42_proc_copy_notify(struct file *, struct file *,
  29. struct nfs42_copy_notify_res *);
  30. static inline bool nfs42_files_from_same_server(struct file *in,
  31. struct file *out)
  32. {
  33. struct nfs_client *c_in = (NFS_SERVER(file_inode(in)))->nfs_client;
  34. struct nfs_client *c_out = (NFS_SERVER(file_inode(out)))->nfs_client;
  35. return nfs4_check_serverowner_major_id(c_in->cl_serverowner,
  36. c_out->cl_serverowner);
  37. }
  38. ssize_t nfs42_proc_getxattr(struct inode *inode, const char *name,
  39. void *buf, size_t buflen);
  40. int nfs42_proc_setxattr(struct inode *inode, const char *name,
  41. const void *buf, size_t buflen, int flags);
  42. ssize_t nfs42_proc_listxattrs(struct inode *inode, void *buf,
  43. size_t buflen, u64 *cookiep, bool *eofp);
  44. int nfs42_proc_removexattr(struct inode *inode, const char *name);
  45. /*
  46. * Maximum XDR buffer size needed for a listxattr buffer of buflen size.
  47. *
  48. * The upper boundary is a buffer with all 1-byte sized attribute names.
  49. * They would be 7 bytes long in the eventual buffer ("user.x\0"), and
  50. * 8 bytes long XDR-encoded.
  51. *
  52. * Include the trailing eof word as well and make the result a multiple
  53. * of 4 bytes.
  54. */
  55. static inline u32 nfs42_listxattr_xdrsize(u32 buflen)
  56. {
  57. u32 size = 8 * buflen / (XATTR_USER_PREFIX_LEN + 2) + 4;
  58. return (size + 3) & ~3;
  59. }
  60. #endif /* CONFIG_NFS_V4_2 */
  61. #endif /* __LINUX_FS_NFS_NFS4_2_H */