Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  linux/fs/nfs/file.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 1992  Rick Sladkey
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/falloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/mount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/nfs_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/nfs_ssc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "delegation.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "iostat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "fscache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include "pnfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include "nfstrace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #ifdef CONFIG_NFS_V4_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "nfs42.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define NFSDBG_FACILITY		NFSDBG_FILE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) nfs4_file_open(struct inode *inode, struct file *filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct nfs_open_context *ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct dentry *dentry = file_dentry(filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct dentry *parent = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	struct inode *dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	unsigned openflags = filp->f_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	struct iattr attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	 * If no cached dentry exists or if it's negative, NFSv4 handled the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	 * opens in ->lookup() or ->create().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	 * We only get this far for a cached positive dentry.  We skipped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	 * revalidation, so handle it here by dropping the dentry and returning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	 * -EOPENSTALE.  The VFS will retry the lookup/create/open.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	dprintk("NFS: open file(%pd2)\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	err = nfs_check_flags(openflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	if ((openflags & O_ACCMODE) == 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		return nfs_open(inode, filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	/* We can't create new files here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	openflags &= ~(O_CREAT|O_EXCL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	parent = dget_parent(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	dir = d_inode(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	ctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode, filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	err = PTR_ERR(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	if (IS_ERR(ctx))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	attr.ia_valid = ATTR_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if (openflags & O_TRUNC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		attr.ia_valid |= ATTR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		attr.ia_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		filemap_write_and_wait(inode->i_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	inode = NFS_PROTO(dir)->open_context(dir, ctx, openflags, &attr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	if (IS_ERR(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		err = PTR_ERR(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		switch (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			goto out_put_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		case -ENOENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		case -ESTALE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		case -EISDIR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		case -ENOTDIR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		case -ELOOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			goto out_drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	if (inode != d_inode(dentry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		goto out_drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	nfs_file_set_open_context(filp, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	nfs_fscache_open_file(inode, filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) out_put_ctx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	put_nfs_open_context(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	dput(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) out_drop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	d_drop(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	err = -EOPENSTALE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	goto out_put_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * Flush all dirty pages, and check for write errors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) nfs4_file_flush(struct file *file, fl_owner_t id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	struct inode	*inode = file_inode(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	errseq_t since;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	dprintk("NFS: flush(%pD2)\n", file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	nfs_inc_stats(inode, NFSIOS_VFSFLUSH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	if ((file->f_mode & FMODE_WRITE) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	 * If we're holding a write delegation, then check if we're required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	 * to flush the i/o on close. If not, then just start the i/o now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (!nfs4_delegation_flush_on_close(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return filemap_fdatawrite(file->f_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	/* Flush writes to the server and return any errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	since = filemap_sample_wb_err(file->f_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	nfs_wb_all(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	return filemap_check_wb_err(file->f_mapping, since);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #ifdef CONFIG_NFS_V4_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 				      struct file *file_out, loff_t pos_out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 				      size_t count, unsigned int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	struct nfs42_copy_notify_res *cn_resp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct nl4_server *nss = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	nfs4_stateid *cnrs = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	bool sync = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	/* Only offload copy if superblock is the same */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	if (file_in->f_op != &nfs4_file_operations)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		return -EXDEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	    !nfs_server_capable(file_inode(file_in), NFS_CAP_COPY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	if (file_inode(file_in) == file_inode(file_out))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	/* if the copy size if smaller than 2 RPC payloads, make it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	 * synchronous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	if (count <= 2 * NFS_SERVER(file_inode(file_in))->rsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		sync = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) retry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	if (!nfs42_files_from_same_server(file_in, file_out)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		/* for inter copy, if copy size if smaller than 12 RPC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		 * payloads, fallback to traditional copy. There are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		 * 14 RPCs during an NFSv4.x mount between source/dest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		 * servers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		if (sync ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 			count <= 14 * NFS_SERVER(file_inode(file_in))->rsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 			return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		cn_resp = kzalloc(sizeof(struct nfs42_copy_notify_res),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 				GFP_NOFS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		if (unlikely(cn_resp == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		ret = nfs42_proc_copy_notify(file_in, file_out, cn_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			ret = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		nss = &cn_resp->cnr_src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		cnrs = &cn_resp->cnr_stateid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 				nss, cnrs, sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	if (!nfs42_files_from_same_server(file_in, file_out))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		kfree(cn_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	if (ret == -EAGAIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		goto retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 				    struct file *file_out, loff_t pos_out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 				    size_t count, unsigned int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	ret = __nfs4_copy_file_range(file_in, pos_in, file_out, pos_out, count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 				     flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	if (ret == -EOPNOTSUPP || ret == -EXDEV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		ret = generic_copy_file_range(file_in, pos_in, file_out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 					      pos_out, count, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) static loff_t nfs4_file_llseek(struct file *filep, loff_t offset, int whence)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	loff_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	switch (whence) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	case SEEK_HOLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	case SEEK_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		ret = nfs42_proc_llseek(filep, offset, whence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		if (ret != -EOPNOTSUPP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		return nfs_file_llseek(filep, offset, whence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	struct inode *inode = file_inode(filep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	if (!S_ISREG(inode->i_mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	if ((mode != 0) && (mode != (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	ret = inode_newsize_ok(inode, offset + len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	if (mode & FALLOC_FL_PUNCH_HOLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		return nfs42_proc_deallocate(filep, offset, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	return nfs42_proc_allocate(filep, offset, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static loff_t nfs42_remap_file_range(struct file *src_file, loff_t src_off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		struct file *dst_file, loff_t dst_off, loff_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		unsigned int remap_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	struct inode *dst_inode = file_inode(dst_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	struct nfs_server *server = NFS_SERVER(dst_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	struct inode *src_inode = file_inode(src_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	unsigned int bs = server->clone_blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	bool same_inode = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	/* NFS does not support deduplication. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	if (remap_flags & REMAP_FILE_DEDUP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	if (remap_flags & ~REMAP_FILE_ADVISORY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	if (IS_SWAPFILE(dst_inode) || IS_SWAPFILE(src_inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		return -ETXTBSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	/* check alignment w.r.t. clone_blksize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	if (bs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		if (!IS_ALIGNED(src_off, bs) || !IS_ALIGNED(dst_off, bs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		if (!IS_ALIGNED(count, bs) && i_size_read(src_inode) != (src_off + count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	if (src_inode == dst_inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		same_inode = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	/* XXX: do we lock at all? what if server needs CB_RECALL_LAYOUT? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	if (same_inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		inode_lock(src_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	} else if (dst_inode < src_inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		inode_lock_nested(dst_inode, I_MUTEX_PARENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		inode_lock_nested(src_inode, I_MUTEX_CHILD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		inode_lock_nested(src_inode, I_MUTEX_PARENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		inode_lock_nested(dst_inode, I_MUTEX_CHILD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	/* flush all pending writes on both src and dst so that server
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	 * has the latest data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	ret = nfs_sync_inode(src_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	ret = nfs_sync_inode(dst_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	ret = nfs42_proc_clone(src_file, dst_file, src_off, dst_off, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	/* truncate inode page cache of the dst range so that future reads can fetch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	 * new data from server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		truncate_inode_pages_range(&dst_inode->i_data, dst_off, dst_off + count - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	if (same_inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		inode_unlock(src_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	} else if (dst_inode < src_inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		inode_unlock(src_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		inode_unlock(dst_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		inode_unlock(dst_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		inode_unlock(src_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	return ret < 0 ? ret : count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) static int read_name_gen = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #define SSC_READ_NAME_BODY "ssc_read_%d"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		struct nfs_fh *src_fh, nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	struct nfs_fattr fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	struct file *filep, *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	struct nfs_server *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	struct inode *r_ino = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	struct nfs_open_context *ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	struct nfs4_state_owner *sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	char *read_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	int len, status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	server = NFS_SERVER(ss_mnt->mnt_root->d_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	nfs_fattr_init(&fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	status = nfs4_proc_getattr(server, src_fh, &fattr, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		res = ERR_PTR(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	res = ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	len = strlen(SSC_READ_NAME_BODY) + 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	read_name = kzalloc(len, GFP_NOFS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	if (read_name == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	snprintf(read_name, len, SSC_READ_NAME_BODY, read_name_gen++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	r_ino = nfs_fhget(ss_mnt->mnt_root->d_inode->i_sb, src_fh, &fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	if (IS_ERR(r_ino)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		res = ERR_CAST(r_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		goto out_free_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	filep = alloc_file_pseudo(r_ino, ss_mnt, read_name, FMODE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 				     r_ino->i_fop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	if (IS_ERR(filep)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		res = ERR_CAST(filep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		goto out_free_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	filep->f_mode |= FMODE_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	ctx = alloc_nfs_open_context(filep->f_path.dentry, filep->f_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 					filep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	if (IS_ERR(ctx)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		res = ERR_CAST(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		goto out_filep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	res = ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	sp = nfs4_get_state_owner(server, ctx->cred, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	if (sp == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		goto out_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	ctx->state = nfs4_get_open_state(r_ino, sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	if (ctx->state == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		goto out_stateowner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	set_bit(NFS_SRV_SSC_COPY_STATE, &ctx->state->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	memcpy(&ctx->state->open_stateid.other, &stateid->other,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	       NFS4_STATEID_OTHER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	update_open_stateid(ctx->state, stateid, NULL, filep->f_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	set_bit(NFS_OPEN_STATE, &ctx->state->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	nfs_file_set_open_context(filep, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	put_nfs_open_context(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	file_ra_state_init(&filep->f_ra, filep->f_mapping->host->i_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	res = filep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) out_free_name:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	kfree(read_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) out_stateowner:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	nfs4_put_state_owner(sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) out_ctx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	put_nfs_open_context(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) out_filep:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	fput(filep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	goto out_free_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) static void __nfs42_ssc_close(struct file *filep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	struct nfs_open_context *ctx = nfs_file_open_context(filep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	ctx->state->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) static const struct nfs4_ssc_client_ops nfs4_ssc_clnt_ops_tbl = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	.sco_open = __nfs42_ssc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	.sco_close = __nfs42_ssc_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)  * nfs42_ssc_register_ops - Wrapper to register NFS_V4 ops in nfs_common
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)  * Return values:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)  *   None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) void nfs42_ssc_register_ops(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	nfs42_ssc_register(&nfs4_ssc_clnt_ops_tbl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)  * nfs42_ssc_unregister_ops - wrapper to un-register NFS_V4 ops in nfs_common
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)  * Return values:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)  *   None.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) void nfs42_ssc_unregister_ops(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	nfs42_ssc_unregister(&nfs4_ssc_clnt_ops_tbl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) #endif /* CONFIG_NFS_V4_2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) const struct file_operations nfs4_file_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	.read_iter	= nfs_file_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	.write_iter	= nfs_file_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	.mmap		= nfs_file_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	.open		= nfs4_file_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	.flush		= nfs4_file_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	.release	= nfs_file_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	.fsync		= nfs_file_fsync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	.lock		= nfs_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	.flock		= nfs_flock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	.splice_read	= generic_file_splice_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	.splice_write	= iter_file_splice_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	.check_flags	= nfs_check_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	.setlease	= simple_nosetlease,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) #ifdef CONFIG_NFS_V4_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	.copy_file_range = nfs4_copy_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	.llseek		= nfs4_file_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	.fallocate	= nfs42_fallocate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	.remap_file_range = nfs42_remap_file_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	.llseek		= nfs_file_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) };