NFS support for "inter" server-to-server COPY
Subsystems (4)
v4 cover NFS support for "inter" server-to-server COPY
This patch series builds on top of async COPY series.
In case, of the "inter" SSC copy files reside on different servers and thus under different superblocks and require that VFS removes the restriction that src and dst files must be on the same superblock.
NFS's copy_file_range() determines if the copy is "intra" or "inter" and for "inter" it sends the COPY_NOTIFY to the source server. Then, it would send of an asynchronous COPY to the destination server.
A couple of patches are added for the destination server acting as the client when talking to the source server. It's now acting as a client and needs to do a special "open" and "close". Since destination server doesn't do an open on the wire, we "fake" create the needed data structures and that's done in the new function nfs42_ssc_open(). To clean up this open but not trigger the CLOSE on the wire, we have a new function nfs42_ssc_close() that accomplishes that. This is patch "NFS inter ssc open"
Handling reboot of the destination server when client is waiting on the CB_OFFLOAD happens when SEQUENCE discovers that destination server rebooted. The open state initially is marked to be NFS_CLNT_DST_SSC_COPY_STATE during the COPY. Then during the recovery if state is marked as such, then look thru the list of copies for the server and see if any are associated with this recovering open, if so mark the copy rebooted and wake up the waiting copy. Upon wake up the waiting copy, will restart the copy from scratch. This is patch "NFS skip recovery of copy open on dest server".
If the server returned ESTALE or ERR_OFFLOAD_DENIED fallback on the traditional copy.
Olga Kornievskaia (11):
VFS permit cross device vfs_copy_file_range NFS test for intra vs inter COPY
NFS recover from destination server reboot for copies NFS NFSD defining nl4_servers structure needed by both NFS add COPY_NOTIFY operation
NFS add ca_source_server<> to COPY
NFS also send OFFLOAD_CANCEL to source server NFS inter ssc open
NFS skip recovery of copy open on dest server NFS for "inter" copy treat ESTALE as ENOTSUPP NFS COPY handle ERR_OFFLOAD_DENIED
Documentation/filesystems/vfs.txt | 6 ++ fs/nfs/nfs42.h | 14 ++- fs/nfs/nfs42proc.c | 141 +++++++++++++++++++++++++--- fs/nfs/nfs42xdr.c | 193 +++++++++++++++++++++++++++++++++++++- fs/nfs/nfs4_fs.h | 13 +++ fs/nfs/nfs4file.c | 135 +++++++++++++++++++++++++- fs/nfs/nfs4proc.c | 6 +- fs/nfs/nfs4state.c | 31 +++++- fs/nfs/nfs4xdr.c | 1 + fs/read_write.c | 13 ++- include/linux/nfs4.h | 25 +++++ include/linux/nfs_fs.h | 2 + include/linux/nfs_fs_sb.h | 1 + include/linux/nfs_xdr.h | 17 ++++ 14 files changed, 571 insertions(+), 27 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v4 1/11 VFS permit cross device vfs_copy_file_range
Allow copy_file_range to copy between different superblocks but only of the same file system types.
This feature is needed by NFSv4.2 to perform file copy operation on the same server or file copy between different NFSv4.2 servers.
If a file system's fileoperations copy_file_range operation prohibits cross-device copies, fall back to do_splice_direct. This would be needed for the NFS (destination) server side implementation of the file copy and currently for CIFS.
Besides NFS, there is only 1 implementor of the copy_file_range FS operation -- CIFS. CIFS assumes incoming file descriptors are both CIFS but it will check if they are coming from different servers and return error code to fall back to do_splice_direct.
NFS will allow for copies between different NFS servers.
Adding to the vfs.txt documentation to explicitly warn about allowing for different superblocks of the same file type to be passed into the copy_file_range for the future users of copy_file_range method.
--- Documentation/filesystems/vfs.txt | 6 ++++++ fs/read_write.c | 13 ++++++------- 2 files changed, 12 insertions(+), 7 deletions(-)
Documentation/filesystems/vfs.txt +6 -0
@@ -880,6 +880,8 @@ struct file_operations { #ifndef CONFIG_MMU unsigned (*mmap_capabilities)(struct file *); #endif + ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, + loff_t, size_t, unsigned int); }; Again, all methods are called without any locks being held, unless
@@ -949,6 +951,10 @@ otherwise noted. fallocate: called by the VFS to preallocate blocks or punch a hole. + copy_file_range: called by copy_file_range(2) system call. This method + works on two file descriptors that might reside on + different superblocks of the same type of file system. + Note that the file operations are implemented by the specific filesystem in which the inode resides. When opening a device node (character or block special) most filesystems will call special
fs/read_write.c +6 -7
@@ -1571,10 +1571,6 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, (file_out->f_flags & O_APPEND))return -EBADF ; -/* this could be relaxed once a method supports cross-fs copies */ -if (inode_in->i_sb != inode_out->i_sb) -return -EXDEV ; -if (len ==0 )return 0 ;
@@ -1584,7 +1580,8 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in,* Try cloning first, this is supported by more file systems, and * more efficient if both clone and copy are supported (e.g. NFS). */ -if (file_in->f_op->clone_file_range) { +if (inode_in->i_sb == inode_out->i_sb && + file_in->f_op->clone_file_range) { ret = file_in->f_op->clone_file_range (file_in, pos_in, file_out, pos_out, len);if (ret ==0 ) {
@@ -1593,10 +1590,12 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, } } -if (file_out->f_op->copy_file_range) { +if (file_out->f_op->copy_file_range && + (file_in->f_op->copy_file_range == + file_out->f_op->copy_file_range)) { ret = file_out->f_op->copy_file_range (file_in, pos_in, file_out, pos_out, len, flags); -if (ret != -EOPNOTSUPP ) +if (ret != -EOPNOTSUPP && ret != -EXDEV ) goto done; }
Signature · 1 line
1.8.3.1
Re: [PATCH v4 01/11] VFS permit cross device vfs_copy_file_range
NAK, and please just keep my NAK on the patch so that I don't have to repeat it.
PATCH v4 2/11 NFS test for intra vs inter COPY
In reply to Olga Kornievskaia--- fs/nfs/nfs42.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/nfs/nfs42.h +10 -0
@@ -5,6 +5,7 @@#ifndef __LINUX_FS_NFS_NFS4_2_H#define __LINUX_FS_NFS_NFS4_2_H +#include <linux/sunrpc/addr.h> /* * FIXME: four LAYOUTSTATS calls per compound at most! Do we need to support * more? Need to consider not to pre-alloc too much for a compound.
@@ -22,5 +23,14 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *,int nfs42_proc_clone (struct file *,struct file *,loff_t ,loff_t ,loff_t );int nfs42_proc_offload_status (struct file *,nfs4_stateid *,struct nfs42_offload_status_res *); + +static inline bool nfs42_files_from_same_server (struct file *in,struct file *out) +{ +struct nfs_client *c_in = (NFS_SERVER (file_inode (in)))->nfs_client; +struct nfs_client *c_out = (NFS_SERVER (file_inode (out)))->nfs_client; + +return rpc_cmp_addr ((struct sockaddr *)&c_in->cl_addr, + (struct sockaddr *)&c_out->cl_addr); +}#endif /* CONFIG_NFS_V4_2) */ #endif /* __LINUX_FS_NFS_NFS4_2_H */
Signature · 1 line
1.8.3.1
PATCH v4 3/11 NFS recover from destination server reboot for copies
In reply to Olga KornievskaiaMark the destination state to indicate a server-side copy is happening. On detecting a reboot and recovering open state check if any state is engaged in a server-side copy, if so, find the copy and mark it and then signal the waiting thread. Upon wakeup, if copy was marked then propage EAGAIN to the nfsd_copy_file_range and restart the copy from scratch (no partial state is being queried at this point).
--- fs/nfs/nfs42proc.c | 16 +++++++++++++--- fs/nfs/nfs4_fs.h | 4 ++++ fs/nfs/nfs4file.c | 9 +++++++-- fs/nfs/nfs4state.c | 15 +++++++++++++++ include/linux/nfs_fs.h | 2 ++ 5 files changed, 41 insertions(+), 5 deletions(-)
fs/nfs/nfs42proc.c +13 -3
@@ -140,6 +140,7 @@ static int handle_async_copy(struct nfs42_copy_res *res,struct nfs4_copy_state *copy;int status =NFS4_OK ;bool found_pending = false; +struct nfs_open_context *ctx =nfs_file_open_context (dst);spin_lock (&server->nfs_client->cl_lock); list_for_each_entry(copy, &server->nfs_client->pending_cb_stateids,
@@ -163,6 +164,7 @@ static int handle_async_copy(struct nfs42_copy_res *res, }memcpy (©->stateid, &res->write_res.stateid,NFS4_STATEID_SIZE );init_completion (©->completion); + copy->parent_state = ctx->state;list_add_tail (©->copies, &server->ss_copies);spin_unlock (&server->nfs_client->cl_lock);
@@ -172,9 +174,10 @@ static int handle_async_copy(struct nfs42_copy_res *res,list_del_init (©->copies);spin_unlock (&server->nfs_client->cl_lock);if (status == -ERESTARTSYS ) { -nfs42_do_offload_cancel_async (dst, ©->stateid); -kfree (copy); -return status; + goto out_cancel; + }else if (copy->flags) { + status = -EAGAIN ; + goto out_cancel; } out: *ret_count = copy->count;
@@ -184,6 +187,10 @@ static int handle_async_copy(struct nfs42_copy_res *res,kfree (copy);return status; +out_cancel: +nfs42_do_offload_cancel_async (dst, ©->stateid); +kfree (copy); +return status; } static ssize_t _nfs42_proc_copy(struct file *src,
@@ -231,6 +238,9 @@ static ssize_t _nfs42_proc_copy(struct file *src,if (!res->commit_res.verf)return -ENOMEM ; } +set_bit (NFS_CLNT_DST_SSC_COPY_STATE , + &dst_lock->open_context->state->flags); + status =nfs4_call_sync (server->client, server, &msg, &args->seq_args, &res->seq_res,0 );if (status == -ENOTSUPP )
fs/nfs/nfs4_fs.h +4 -0
@@ -161,6 +161,10 @@ enum {NFS_STATE_POSIX_LOCKS ,/* Posix locks are supported */ NFS_STATE_RECOVERY_FAILED ,/* OPEN stateid state recovery failed */ NFS_STATE_MAY_NOTIFY_LOCK ,/* server may CB_NOTIFY_LOCK */ +#ifdef CONFIG_NFS_V4_2 + NFS_CLNT_DST_SSC_COPY_STATE, /* dst server open state on client*/ +#endif /* CONFIG_NFS_V4_2 */ + }; struct nfs4_state {
fs/nfs/nfs4file.c +7 -2
@@ -133,10 +133,15 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, size_t count, unsigned int flags) { + ssize_t ret; +if (file_inode (file_in) ==file_inode (file_out))return -EINVAL ; - -return nfs42_proc_copy (file_in, pos_in, file_out, pos_out, count); +retry: + ret =nfs42_proc_copy (file_in, pos_in, file_out, pos_out, count); +if (ret == -EAGAIN ) + goto retry; +return ret; }static loff_t nfs4_file_llseek (struct file *filep,loff_t offset,int whence)
fs/nfs/nfs4state.c +15 -0
@@ -1546,6 +1546,21 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs &state->flags);nfs4_put_open_state (state);spin_lock (&sp->so_lock); +#ifdef CONFIG_NFS_V4_2 +if (test_bit (NFS_CLNT_DST_SSC_COPY_STATE , &state->flags)) { +struct nfs4_copy_state *copy; + +spin_lock (&sp->so_server->nfs_client->cl_lock); +list_for_each_entry (copy, &sp->so_server->ss_copies, copies) { +if (memcmp (&state->stateid.other, ©->parent_state->stateid.other,NFS4_STATEID_SIZE )) +continue ; + copy->flags =1 ; +complete (©->completion); +break ; + } +spin_unlock (&sp->so_server->nfs_client->cl_lock); + } +#endif /* CONFIG_NFS_V4_2 */ goto restart; } }
include/linux/nfs_fs.h +2 -0
@@ -190,6 +190,8 @@ struct nfs4_copy_state {uint64_t count;struct nfs_writeverf verf;int error; +int flags; +struct nfs4_state *parent_state; };/*
Signature · 1 line
1.8.3.1
PATCH v4 4/11 NFS NFSD defining nl4_servers structure needed by both
In reply to Olga KornievskaiaThese structures are needed by COPY_NOTIFY on the client and needed by the nfsd as well
--- include/linux/nfs4.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
include/linux/nfs4.h +24 -0
@@ -15,6 +15,7 @@#include <linux/list.h> #include <linux/uidgid.h> #include <uapi/linux/nfs4.h> +#include <linux/sunrpc/msg_prot.h> enum nfs4_acl_whotype {NFS4_ACL_WHO_NAMED =0 ,
@@ -660,4 +661,27 @@ struct nfs4_op_map { } u; }; +struct nfs42_netaddr { +char netid[RPCBIND_MAXNETIDLEN ]; +char addr[RPCBIND_MAXUADDRLEN +1 ]; +u32 netid_len; +u32 addr_len; +}; + +enum netloc_type4 { +NL4_NAME =1 , +NL4_URL =2 , +NL4_NETADDR =3 , +}; + +struct nl4_server { +enum netloc_type4 nl4_type; +union { +struct {/* NL4_NAME, NL4_URL */ +int nl4_str_sz; +char nl4_str[NFS4_OPAQUE_LIMIT +1 ]; + }; +struct nfs42_netaddr nl4_addr;/* NL4_NETADDR */ + } u; +};#endif
Signature · 1 line
1.8.3.1
PATCH v4 5/11 NFS add COPY_NOTIFY operation
In reply to Olga KornievskaiaTry using the delegation stateid, then the open stateid.
Only NL4_NETATTR, No support for NL4_NAME and NL4_URL. Allow only one source server address to be returned for now.
--- fs/nfs/nfs42.h | 3 +- fs/nfs/nfs42proc.c | 91 +++++++++++++++++++++++ fs/nfs/nfs42xdr.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4_fs.h | 1 + fs/nfs/nfs4file.c | 17 +++++ fs/nfs/nfs4proc.c | 1 + fs/nfs/nfs4state.c | 2 +- fs/nfs/nfs4xdr.c | 1 + include/linux/nfs4.h | 1 + include/linux/nfs_fs_sb.h | 1 + include/linux/nfs_xdr.h | 16 ++++ 11 files changed, 313 insertions(+), 2 deletions(-)
fs/nfs/nfs42.h +2 -1
@@ -23,7 +23,8 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *,int nfs42_proc_clone (struct file *,struct file *,loff_t ,loff_t ,loff_t );int nfs42_proc_offload_status (struct file *,nfs4_stateid *,struct nfs42_offload_status_res *); - +int nfs42_proc_copy_notify (struct file *,struct file *, +struct nfs42_copy_notify_res *);static inline bool nfs42_files_from_same_server (struct file *in,struct file *out) {struct nfs_client *c_in = (NFS_SERVER (file_inode (in)))->nfs_client;
fs/nfs/nfs42proc.c +91 -0
113 lines not on this page · raw message
fs/nfs/nfs42xdr.c +181 -0
229 lines not on this page · raw message
fs/nfs/nfs4_fs.h +1 -0
@@ -464,6 +464,7 @@ extern void nfs41_handle_server_scope(struct nfs_client *,extern int nfs4_select_rw_stateid (struct nfs4_state *,fmode_t ,const struct nfs_lock_context *,nfs4_stateid *,struct rpc_cred **); +extern void nfs4_copy_open_stateid (nfs4_stateid *,struct nfs4_state *);extern struct nfs_seqid *nfs_alloc_seqid (struct nfs_seqid_counter *counter,gfp_t gfp_mask);extern int nfs_wait_on_sequence (struct nfs_seqid *seqid,struct rpc_task *task);
fs/nfs/nfs4file.c +17 -0
@@ -133,12 +133,29 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, size_t count, unsigned int flags) { + struct nfs42_copy_notify_res *cn_resp = NULL;ssize_t ret;if (file_inode (file_in) ==file_inode (file_out))return -EINVAL ; retry: +if (nfs42_files_from_same_server (file_in, file_out)) {/* Intra-ssc */ +if (file_in->f_op != file_out->f_op) +return -EXDEV ; + }else {/* Inter-ssc */ + cn_resp =kzalloc (sizeof (struct nfs42_copy_notify_res ), +GFP_NOFS ); +if (unlikely (cn_resp ==NULL )) +return -ENOMEM ; + + ret =nfs42_proc_copy_notify (file_in, file_out, cn_resp); +if (ret) + goto out; + } ret =nfs42_proc_copy (file_in, pos_in, file_out, pos_out, count); + +out: +kfree (cn_resp);if (ret == -EAGAIN ) goto retry;return ret;
fs/nfs/nfs4proc.c +1 -0
@@ -9330,6 +9330,7 @@ static bool nfs4_match_stateid(const nfs4_stateid *s1, | NFS_CAP_COPY |NFS_CAP_OFFLOAD_STATUS |NFS_CAP_OFFLOAD_CANCEL + |NFS_CAP_COPY_NOTIFY |NFS_CAP_DEALLOCATE |NFS_CAP_SEEK |NFS_CAP_LAYOUTSTATS
fs/nfs/nfs4state.c +1 -1
@@ -985,7 +985,7 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst,return ret; } -static void nfs4_copy_open_stateid (nfs4_stateid *dst,struct nfs4_state *state) +void nfs4_copy_open_stateid (nfs4_stateid *dst,struct nfs4_state *state) {const nfs4_stateid *src;int seq;
fs/nfs/nfs4xdr.c +1 -0
@@ -7735,6 +7735,7 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,PROC (COPY , enc_copy, dec_copy),PROC (OFFLOAD_STATUS , enc_offload_status, dec_offload_status),PROC (OFFLOAD_CANCEL , enc_offload_cancel, dec_offload_cancel), + PROC(COPY_NOTIFY, enc_copy_notify, dec_copy_notify), #endif /* CONFIG_NFS_V4_2 */ };
include/linux/nfs4.h +1 -0
@@ -527,6 +527,7 @@ enum {NFSPROC4_CLNT_COPY ,NFSPROC4_CLNT_OFFLOAD_STATUS ,NFSPROC4_CLNT_OFFLOAD_CANCEL , + NFSPROC4_CLNT_COPY_NOTIFY, };/* nfs41 types */
include/linux/nfs_fs_sb.h +1 -0
@@ -256,5 +256,6 @@ struct nfs_server {#define NFS_CAP_COPY (1U << 24)#define NFS_CAP_OFFLOAD_STATUS (1U << 25)#define NFS_CAP_OFFLOAD_CANCEL (1U << 26) +#define NFS_CAP_COPY_NOTIFY (1U << 27)#endif
include/linux/nfs_xdr.h +16 -0
@@ -1413,6 +1413,22 @@ struct nfs42_offload_status_res {int osr_status; }; +struct nfs42_copy_notify_args { +struct nfs4_sequence_args cna_seq_args; + +struct nfs_fh *cna_src_fh; +nfs4_stateid cna_src_stateid; +struct nl4_server cna_dst; +}; + +struct nfs42_copy_notify_res { +struct nfs4_sequence_res cnr_seq_res; + +struct nfstime4 cnr_lease_time; +nfs4_stateid cnr_stateid; +struct nl4_server cnr_src; +}; +struct nfs42_seek_args {struct nfs4_sequence_args seq_args;
Signature · 1 line
1.8.3.1
PATCH v4 6/11 NFS add ca_source_server<> to COPY
In reply to Olga KornievskaiaSupport only one source server address: the same address that the client and source server use.
--- fs/nfs/nfs42.h | 3 ++- fs/nfs/nfs42proc.c | 26 +++++++++++++++++--------- fs/nfs/nfs42xdr.c | 12 ++++++++++-- fs/nfs/nfs4file.c | 7 ++++++- include/linux/nfs_xdr.h | 1 + 5 files changed, 36 insertions(+), 13 deletions(-)
fs/nfs/nfs42.h +2 -1
@@ -15,7 +15,8 @@#if defined(CONFIG_NFS_V4_2 )/* nfs4.2proc.c */ int nfs42_proc_allocate (struct file *,loff_t ,loff_t ); -ssize_t nfs42_proc_copy (struct file *,loff_t ,struct file *,loff_t ,size_t ); +ssize_t nfs42_proc_copy (struct file *,loff_t ,struct file *,loff_t ,size_t , +struct nl4_server *,nfs4_stateid *);int nfs42_proc_deallocate (struct file *,loff_t ,loff_t );loff_t nfs42_proc_llseek (struct file *,loff_t ,int ); int nfs42_proc_layoutstats_generic(struct nfs_server *,
fs/nfs/nfs42proc.c +17 -9
@@ -219,7 +219,9 @@ static ssize_t _nfs42_proc_copy(struct file *src, struct file *dst, struct nfs_lock_context *dst_lock, struct nfs42_copy_args *args, - struct nfs42_copy_res *res) + struct nfs42_copy_res *res, + struct nl4_server *nss, + nfs4_stateid *cnr_stateid) { struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY],
@@ -233,11 +235,15 @@ static ssize_t _nfs42_proc_copy(struct file *src,size_t count = args->count;ssize_t status; - status =nfs4_set_rw_stateid (&args->src_stateid, src_lock->open_context, - src_lock,FMODE_READ ); -if (status) -return status; - +if (nss) { + args->cp_src = nss; +nfs4_stateid_copy (&args->src_stateid, cnr_stateid); + }else { + status =nfs4_set_rw_stateid (&args->src_stateid, + src_lock->open_context, src_lock,FMODE_READ ); +if (status) +return status; + } status =nfs_filemap_write_and_wait_range (file_inode (src)->i_mapping, pos_src, pos_src + (loff_t )count -1 );if (status)
@@ -316,8 +322,9 @@ static ssize_t _nfs42_proc_copy(struct file *src, }ssize_t nfs42_proc_copy (struct file *src,loff_t pos_src, -struct file *dst,loff_t pos_dst, -size_t count) +struct file *dst,loff_t pos_dst,size_t count, +struct nl4_server *nss, +nfs4_stateid *cnr_stateid) {struct nfs_server *server =NFS_SERVER (file_inode (dst));struct nfs_lock_context *src_lock;
@@ -362,7 +369,8 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,inode_lock (file_inode (dst)); err =_nfs42_proc_copy (src, src_lock, dst, dst_lock, - &args, &res); + &args, &res, + nss, cnr_stateid);inode_unlock (file_inode (dst));if (err >=0 )
fs/nfs/nfs42xdr.c +10 -2
@@ -20,7 +20,10 @@#define encode_copy_maxsz (op_encode_hdr_maxsz + \ XDR_QUADLEN(NFS4_STATEID_SIZE) + \ XDR_QUADLEN(NFS4_STATEID_SIZE) + \ - 2 + 2 + 2 + 1 + 1 + 1) + 2 + 2 + 2 + 1 + 1 + 1 +\ + 1 +/* One cnr_source_server */ \ + 1 + /* nl4_type */ \ + 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) #define decode_copy_maxsz (op_decode_hdr_maxsz + \ NFS42_WRITE_RES_SIZE + \ 1 /* cr_consecutive */ + \
@@ -196,7 +199,12 @@ static void encode_copy(struct xdr_stream *xdr,encode_uint32 (xdr,1 );/* consecutive = true */ encode_uint32 (xdr, args->sync); -encode_uint32 (xdr,0 );/* src server list */ +if (args->cp_src ==NULL ) {/* intra-ssc */ +encode_uint32 (xdr,0 );/* no src server list */ +return ; + } +encode_uint32 (xdr,1 );/* supporting 1 server */ +encode_nl4_server (xdr, args->cp_src); } static void encode_offload_status(struct xdr_stream *xdr,
fs/nfs/nfs4file.c +6 -1
@@ -134,6 +134,8 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, size_t count, unsigned int flags) {struct nfs42_copy_notify_res *cn_resp =NULL ; +struct nl4_server *nss =NULL ; +nfs4_stateid *cnrs =NULL ;ssize_t ret;if (file_inode (file_in) ==file_inode (file_out))
@@ -151,8 +153,11 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, ret =nfs42_proc_copy_notify (file_in, file_out, cn_resp);if (ret) goto out; + nss = &cn_resp->cnr_src; + cnrs = &cn_resp->cnr_stateid; } - ret =nfs42_proc_copy (file_in, pos_in, file_out, pos_out, count); + ret =nfs42_proc_copy (file_in, pos_in, file_out, pos_out, count, nss, + cnrs); out:kfree (cn_resp);
include/linux/nfs_xdr.h +1 -0
@@ -1385,6 +1385,7 @@ struct nfs42_copy_args {u64 count;bool sync; +struct nl4_server *cp_src; };struct nfs42_write_res {
Signature · 1 line
1.8.3.1
PATCH v4 7/11 NFS also send OFFLOAD_CANCEL to source server
In reply to Olga KornievskaiaIn case of copy is cancelled, also send OFFLOAD_CANCEL to the source server.
--- fs/nfs/nfs42proc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/nfs/nfs42proc.c +4 -2
@@ -206,12 +206,14 @@ static int handle_async_copy(struct nfs42_copy_res *res,if (copy->count <=0 ) status = -copy->error; +out_free:kfree (copy);return status; out_cancel:nfs42_do_offload_cancel_async (dst, ©->stateid); -kfree (copy); -return status; +if (!nfs42_files_from_same_server (src, dst)) +nfs42_do_offload_cancel_async (src, src_stateid); + goto out_free; } static ssize_t _nfs42_proc_copy(struct file *src,
Signature · 1 line
1.8.3.1
PATCH v4 8/11 NFS inter ssc open
In reply to Olga KornievskaiaNFSv4.2 inter server to server copy requires the destination server to READ the data from the source server using the provided stateid and file handle.
Given an NFSv4 stateid and filehandle from the COPY operaion, provide the destination server with an NFS client function to create a struct file suitable for the destiniation server to READ the data to be copied.
--- fs/nfs/nfs4_fs.h | 7 ++++ fs/nfs/nfs4file.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 5 ++- 3 files changed, 115 insertions(+), 3 deletions(-)
fs/nfs/nfs4_fs.h +7 -0
@@ -278,6 +278,13 @@ extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx, fmode_t fmode); +extern int nfs4_proc_getattr (struct nfs_server *server,struct nfs_fh *fhandle, +struct nfs_fattr *fattr, +struct nfs4_label *label); +extern int update_open_stateid (struct nfs4_state *state, +const nfs4_stateid *open_stateid, +const nfs4_stateid *deleg_stateid, +fmode_t fmode);#if defined(CONFIG_NFS_V4_1 )extern int nfs41_sequence_done (struct rpc_task *,struct nfs4_sequence_res *);
fs/nfs/nfs4file.c +106 -0
118 lines not on this page · raw message
fs/nfs/nfs4proc.c +2 -3
@@ -89,7 +89,6 @@static int _nfs4_recover_proc_open (struct nfs4_opendata *data);static int nfs4_do_fsinfo (struct nfs_server *,struct nfs_fh *,struct nfs_fsinfo *);static void nfs_fixup_referral_attributes (struct nfs_fattr *fattr); -static int nfs4_proc_getattr (struct nfs_server *,struct nfs_fh *,struct nfs_fattr *,struct nfs4_label *label);static int _nfs4_proc_getattr (struct nfs_server *server,struct nfs_fh *fhandle,struct nfs_fattr *fattr,struct nfs4_label *label); static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, struct nfs_fattr *fattr, struct iattr *sattr,
@@ -1463,7 +1462,7 @@ static void __update_open_stateid(struct nfs4_state *state,spin_unlock (&state->owner->so_lock); } -static int update_open_stateid (struct nfs4_state *state, +int update_open_stateid (struct nfs4_state *state,const nfs4_stateid *open_stateid,const nfs4_stateid *delegation,fmode_t fmode)
@@ -3646,7 +3645,7 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,return nfs4_call_sync (server->client, server, &msg, &args.seq_args, &res.seq_res,0 ); } -static int nfs4_proc_getattr (struct nfs_server *server,struct nfs_fh *fhandle, +int nfs4_proc_getattr (struct nfs_server *server,struct nfs_fh *fhandle,struct nfs_fattr *fattr,struct nfs4_label *label) {struct nfs4_exception exception = { };
Signature · 1 line
1.8.3.1
PATCH v4 9/11 NFS skip recovery of copy open on dest server
In reply to Olga KornievskaiaMark the open created for the source file on the destination server. Then if this open is going thru a recovery, then fail the recovery as we don't need to be recoving a "fake" open. We need to fail the ongoing READs and vfs_copy_file_range().
--- fs/nfs/nfs4_fs.h | 1 + fs/nfs/nfs4file.c | 2 +- fs/nfs/nfs4state.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-)
fs/nfs/nfs4_fs.h +1 -0
@@ -163,6 +163,7 @@ enum { NFS_STATE_MAY_NOTIFY_LOCK, /* server may CB_NOTIFY_LOCK */#ifdef CONFIG_NFS_V4_2 NFS_CLNT_DST_SSC_COPY_STATE, /* dst server open state on client*/ + NFS_SRV_SSC_COPY_STATE, /* ssc state on the dst server */#endif /* CONFIG_NFS_V4_2 */ };
fs/nfs/nfs4file.c +1 -1
@@ -338,7 +338,7 @@ struct file * ctx->state =nfs4_get_open_state (r_ino, sp);if (ctx->state ==NULL ) goto out_stateowner; - +set_bit (NFS_SRV_SSC_COPY_STATE , &ctx->state->flags);update_open_stateid (ctx->state, stateid,NULL , filep->f_mode);nfs_file_set_open_context (filep, ctx);
fs/nfs/nfs4state.c +14 -0
@@ -1507,6 +1507,9 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfsstruct nfs4_state *state;struct nfs4_lock_state *lock;int status =0 ; +#ifdef CONFIG_NFS_V4_2 +bool found_ssc_copy_state = false; +#endif /* CONFIG_NFS_V4_2 */ /* Note: we rely on the sp->so_states list being ordered * so that we always reclaim open(O_RDWR) and/or open(O_WRITE)
@@ -1526,6 +1529,13 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfscontinue ;if (state->state ==0 )continue ; +#ifdef CONFIG_NFS_V4_2 +if (test_bit (NFS_SRV_SSC_COPY_STATE , &state->flags)) { +nfs4_state_mark_recovery_failed (state, -EIO ); + found_ssc_copy_state = true; +continue ; + } +#endif /* CONFIG_NFS_V4_2 */ atomic_inc (&state->count);spin_unlock (&sp->so_lock); status = ops->recover_open (sp, state);
@@ -1603,6 +1613,10 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs }raw_write_seqcount_end (&sp->so_reclaim_seqcount);spin_unlock (&sp->so_lock); +#ifdef CONFIG_NFS_V4_2 +if (found_ssc_copy_state) +return -EIO ; +#endif /* CONFIG_NFS_V4_2 */ return 0 ; out_err:nfs4_put_open_state (state);
Signature · 1 line
1.8.3.1
PATCH v4 10/11 NFS for "inter" copy treat ESTALE as ENOTSUPP
In reply to Olga KornievskaiaIf the client sends an "inter" copy to the destination server but it only supports "intra" copy, it can return ESTALE (since it doesn't know anything about the file handle from the other server and does not recognize the special case of "inter" copy). Translate this error as ENOTSUPP and also send OFFLOAD_CANCEL to teh source server so that it can clean up state.
--- fs/nfs/nfs42proc.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/nfs/nfs42proc.c +5 -0
@@ -387,6 +387,11 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, args.sync = true; dst_exception.retry =1 ;continue ; + }else if (err == -ESTALE && + !nfs42_files_from_same_server (src, dst)) { +nfs42_do_offload_cancel_async (src, &args.src_stateid); + err = -EOPNOTSUPP ; +break ; } err2 =nfs4_handle_exception (server, err, &src_exception);
Signature · 1 line
1.8.3.1
PATCH v4 11/11 NFS COPY handle ERR_OFFLOAD_DENIED
In reply to Olga KornievskaiaIf server sends ERR_OFFLOAD_DENIED error, the client must fall back on doing copy the normal way. Return ENOTSUPP to the vfs and fallback to regular copy.
--- fs/nfs/nfs42proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/nfs42proc.c +2 -1
@@ -387,7 +387,8 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, args.sync = true; dst_exception.retry =1 ;continue ; - }else if (err == -ESTALE && + }else if ((err == -ESTALE || + err == -NFS4ERR_OFFLOAD_DENIED ) && !nfs42_files_from_same_server (src, dst)) {nfs42_do_offload_cancel_async (src, &args.src_stateid); err = -EOPNOTSUPP ;
Signature · 1 line
1.8.3.1