1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21c6dcbe5SAnna Schumaker /*
31c6dcbe5SAnna Schumaker * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com>
41c6dcbe5SAnna Schumaker */
51c6dcbe5SAnna Schumaker
61c6dcbe5SAnna Schumaker #ifndef __LINUX_FS_NFS_NFS4_2_H
71c6dcbe5SAnna Schumaker #define __LINUX_FS_NFS_NFS4_2_H
81c6dcbe5SAnna Schumaker
904a5da69SFrank van der Linden #include <linux/xattr.h>
1004a5da69SFrank van der Linden
11be3a5d23STrond Myklebust /*
12be3a5d23STrond Myklebust * FIXME: four LAYOUTSTATS calls per compound at most! Do we need to support
13be3a5d23STrond Myklebust * more? Need to consider not to pre-alloc too much for a compound.
14be3a5d23STrond Myklebust */
15be3a5d23STrond Myklebust #define PNFS_LAYOUTSTATS_MAXDEV (4)
16303a7805SAnna Schumaker #define READ_PLUS_SCRATCH_SIZE (16)
17be3a5d23STrond Myklebust
181c6dcbe5SAnna Schumaker /* nfs4.2proc.c */
190491567bSOlga Kornievskaia #ifdef CONFIG_NFS_V4_2
20f4ac1674SAnna Schumaker int nfs42_proc_allocate(struct file *, loff_t, loff_t);
211d38f3f0SOlga Kornievskaia ssize_t nfs42_proc_copy(struct file *, loff_t, struct file *, loff_t, size_t,
2212751010SOlga Kornievskaia struct nl4_server *, nfs4_stateid *, bool);
23624bd5b7SAnna Schumaker int nfs42_proc_deallocate(struct file *, loff_t, loff_t);
241c6dcbe5SAnna Schumaker loff_t nfs42_proc_llseek(struct file *, loff_t, int);
25be3a5d23STrond Myklebust int nfs42_proc_layoutstats_generic(struct nfs_server *,
26be3a5d23STrond Myklebust struct nfs42_layoutstat_data *);
27e5341f3aSPeng Tao int nfs42_proc_clone(struct file *, struct file *, loff_t, loff_t, loff_t);
283eb86093STrond Myklebust int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg,
293eb86093STrond Myklebust const struct nfs42_layout_error *errors,
303eb86093STrond Myklebust size_t n);
310491567bSOlga Kornievskaia int nfs42_proc_copy_notify(struct file *, struct file *,
320491567bSOlga Kornievskaia struct nfs42_copy_notify_res *);
nfs42_files_from_same_server(struct file * in,struct file * out)330491567bSOlga Kornievskaia static inline bool nfs42_files_from_same_server(struct file *in,
340491567bSOlga Kornievskaia struct file *out)
350491567bSOlga Kornievskaia {
360491567bSOlga Kornievskaia struct nfs_client *c_in = (NFS_SERVER(file_inode(in)))->nfs_client;
370491567bSOlga Kornievskaia struct nfs_client *c_out = (NFS_SERVER(file_inode(out)))->nfs_client;
381c6dcbe5SAnna Schumaker
390491567bSOlga Kornievskaia return nfs4_check_serverowner_major_id(c_in->cl_serverowner,
400491567bSOlga Kornievskaia c_out->cl_serverowner);
410491567bSOlga Kornievskaia }
4204a5da69SFrank van der Linden
43c10a7514SFrank van der Linden ssize_t nfs42_proc_getxattr(struct inode *inode, const char *name,
44c10a7514SFrank van der Linden void *buf, size_t buflen);
45c10a7514SFrank van der Linden int nfs42_proc_setxattr(struct inode *inode, const char *name,
46c10a7514SFrank van der Linden const void *buf, size_t buflen, int flags);
47c10a7514SFrank van der Linden ssize_t nfs42_proc_listxattrs(struct inode *inode, void *buf,
48c10a7514SFrank van der Linden size_t buflen, u64 *cookiep, bool *eofp);
49c10a7514SFrank van der Linden int nfs42_proc_removexattr(struct inode *inode, const char *name);
50c10a7514SFrank van der Linden
5104a5da69SFrank van der Linden /*
5204a5da69SFrank van der Linden * Maximum XDR buffer size needed for a listxattr buffer of buflen size.
5304a5da69SFrank van der Linden *
5404a5da69SFrank van der Linden * The upper boundary is a buffer with all 1-byte sized attribute names.
5504a5da69SFrank van der Linden * They would be 7 bytes long in the eventual buffer ("user.x\0"), and
5604a5da69SFrank van der Linden * 8 bytes long XDR-encoded.
5704a5da69SFrank van der Linden *
58*26e177cfSJorge Mora * Include the trailing eof word as well and make the result a multiple
59*26e177cfSJorge Mora * of 4 bytes.
6004a5da69SFrank van der Linden */
nfs42_listxattr_xdrsize(u32 buflen)6104a5da69SFrank van der Linden static inline u32 nfs42_listxattr_xdrsize(u32 buflen)
6204a5da69SFrank van der Linden {
63*26e177cfSJorge Mora u32 size = 8 * buflen / (XATTR_USER_PREFIX_LEN + 2) + 4;
64*26e177cfSJorge Mora
65*26e177cfSJorge Mora return (size + 3) & ~3;
6604a5da69SFrank van der Linden }
670491567bSOlga Kornievskaia #endif /* CONFIG_NFS_V4_2 */
681c6dcbe5SAnna Schumaker #endif /* __LINUX_FS_NFS_NFS4_2_H */
69