linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] NFS append COMMIT after synchronous COPY
@ 2017-04-17 21:15 Olga Kornievskaia
  2017-04-18 15:03 ` Anna Schumaker
  0 siblings, 1 reply; 7+ messages in thread
From: Olga Kornievskaia @ 2017-04-17 21:15 UTC (permalink / raw)
  To: Trond.Myklebust, anna.schumaker; +Cc: linux-nfs

Instead of messing with the commit path which has been causing issues,
add a COMMIT op after the COPY and ask for stable copies in the first
space.

It saves a round trip, since after the COPY, the client sends a COMMIT
anyway.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
---
 fs/nfs/internal.h  |  1 -
 fs/nfs/nfs42proc.c |  6 ------
 fs/nfs/nfs42xdr.c  | 15 +++++++++++++++
 fs/nfs/write.c     | 30 ------------------------------
 4 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 7b38fed..2989418 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -495,7 +495,6 @@ void nfs_mark_request_commit(struct nfs_page *req,
 			     u32 ds_commit_idx);
 int nfs_write_need_commit(struct nfs_pgio_header *);
 void nfs_writeback_update_inode(struct nfs_pgio_header *hdr);
-int nfs_commit_file(struct file *file, struct nfs_write_verifier *verf);
 int nfs_generic_commit_list(struct inode *inode, struct list_head *head,
 			    int how, struct nfs_commit_info *cinfo);
 void nfs_retry_commit(struct list_head *page_list,
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 1e486c7..9fee48d 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -174,12 +174,6 @@ static ssize_t _nfs42_proc_copy(struct file *src,
 	if (status)
 		return status;
 
-	if (res->write_res.verifier.committed != NFS_FILE_SYNC) {
-		status = nfs_commit_file(dst, &res->write_res.verifier.verifier);
-		if (status)
-			return status;
-	}
-
 	truncate_pagecache_range(dst_inode, pos_dst,
 				 pos_dst + res->write_res.count);
 
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
index 6c72964..03f3c9e 100644
--- a/fs/nfs/nfs42xdr.c
+++ b/fs/nfs/nfs42xdr.c
@@ -25,6 +25,8 @@
 					 NFS42_WRITE_RES_SIZE + \
 					 1 /* cr_consecutive */ + \
 					 1 /* cr_synchronous */)
+#define decode_commit_maxsz		(op_decode_hdr_maxsz + \
+					 decode_verifier_maxsz)
 #define encode_deallocate_maxsz		(op_encode_hdr_maxsz + \
 					 encode_fallocate_maxsz)
 #define decode_deallocate_maxsz		(op_decode_hdr_maxsz)
@@ -222,6 +224,18 @@ static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
 	encode_nops(&hdr);
 }
 
+static void encode_copy_commit(struct xdr_stream *xdr,
+			  struct nfs42_copy_args *args,
+			  struct compound_hdr *hdr)
+{
+	__be32 *p;
+
+	encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
+	p = reserve_space(xdr, 12);
+	p = xdr_encode_hyper(p, args->dst_pos);
+	*p = cpu_to_be32(args->count);
+}
+
 /*
  * Encode COPY request
  */
@@ -239,6 +253,7 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
 	encode_savefh(xdr, &hdr);
 	encode_putfh(xdr, args->dst_fh, &hdr);
 	encode_copy(xdr, args, &hdr);
+	encode_copy_commit(xdr, args, &hdr);
 	encode_nops(&hdr);
 }
 
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index abb2c8a..8d65d88 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1720,36 +1720,6 @@ void nfs_retry_commit(struct list_head *page_list,
 	return -ENOMEM;
 }
 
-int nfs_commit_file(struct file *file, struct nfs_write_verifier *verf)
-{
-	struct inode *inode = file_inode(file);
-	struct nfs_open_context *open;
-	struct nfs_commit_info cinfo;
-	struct nfs_page *req;
-	int ret;
-
-	open = get_nfs_open_context(nfs_file_open_context(file));
-	req  = nfs_create_request(open, NULL, NULL, 0, i_size_read(inode));
-	if (IS_ERR(req)) {
-		ret = PTR_ERR(req);
-		goto out_put;
-	}
-
-	nfs_init_cinfo_from_inode(&cinfo, inode);
-
-	memcpy(&req->wb_verf, verf, sizeof(struct nfs_write_verifier));
-	nfs_request_add_commit_list(req, &cinfo);
-	ret = nfs_commit_inode(inode, FLUSH_SYNC);
-	if (ret > 0)
-		ret = 0;
-
-	nfs_free_request(req);
-out_put:
-	put_nfs_open_context(open);
-	return ret;
-}
-EXPORT_SYMBOL_GPL(nfs_commit_file);
-
 /*
  * COMMIT call returned
  */
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] NFS append COMMIT after synchronous COPY
  2017-04-17 21:15 [PATCH 1/1] NFS append COMMIT after synchronous COPY Olga Kornievskaia
@ 2017-04-18 15:03 ` Anna Schumaker
  2017-04-18 16:06   ` Olga Kornievskaia
  0 siblings, 1 reply; 7+ messages in thread
From: Anna Schumaker @ 2017-04-18 15:03 UTC (permalink / raw)
  To: Olga Kornievskaia, Trond.Myklebust, anna.schumaker; +Cc: linux-nfs

Hi Olga,

On 04/17/2017 05:15 PM, Olga Kornievskaia wrote:
> Instead of messing with the commit path which has been causing issues,
> add a COMMIT op after the COPY and ask for stable copies in the first
> space.
> 
> It saves a round trip, since after the COPY, the client sends a COMMIT
> anyway.
> 
> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> ---
>  fs/nfs/internal.h  |  1 -
>  fs/nfs/nfs42proc.c |  6 ------
>  fs/nfs/nfs42xdr.c  | 15 +++++++++++++++
>  fs/nfs/write.c     | 30 ------------------------------
>  4 files changed, 15 insertions(+), 37 deletions(-)
> 
> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
> index 7b38fed..2989418 100644
> --- a/fs/nfs/internal.h
> +++ b/fs/nfs/internal.h
> @@ -495,7 +495,6 @@ void nfs_mark_request_commit(struct nfs_page *req,
>  			     u32 ds_commit_idx);
>  int nfs_write_need_commit(struct nfs_pgio_header *);
>  void nfs_writeback_update_inode(struct nfs_pgio_header *hdr);
> -int nfs_commit_file(struct file *file, struct nfs_write_verifier *verf);
>  int nfs_generic_commit_list(struct inode *inode, struct list_head *head,
>  			    int how, struct nfs_commit_info *cinfo);
>  void nfs_retry_commit(struct list_head *page_list,
> diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
> index 1e486c7..9fee48d 100644
> --- a/fs/nfs/nfs42proc.c
> +++ b/fs/nfs/nfs42proc.c
> @@ -174,12 +174,6 @@ static ssize_t _nfs42_proc_copy(struct file *src,
>  	if (status)
>  		return status;
>  
> -	if (res->write_res.verifier.committed != NFS_FILE_SYNC) {
> -		status = nfs_commit_file(dst, &res->write_res.verifier.verifier);
> -		if (status)
> -			return status;
> -	}
> -
>  	truncate_pagecache_range(dst_inode, pos_dst,
>  				 pos_dst + res->write_res.count);
>  
> diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
> index 6c72964..03f3c9e 100644
> --- a/fs/nfs/nfs42xdr.c
> +++ b/fs/nfs/nfs42xdr.c
> @@ -25,6 +25,8 @@
>  					 NFS42_WRITE_RES_SIZE + \
>  					 1 /* cr_consecutive */ + \
>  					 1 /* cr_synchronous */)
> +#define decode_commit_maxsz		(op_decode_hdr_maxsz + \
> +					 decode_verifier_maxsz)e

nfs4xdr.c includes this file (it's a weird setup, I know), so this and the corresponding encode size should already be declared and available to us.  Can you add them to the NFS4_enc_copy_sz and NFS4_dec_copy_size values?

Thanks,
Anna

>  #define encode_deallocate_maxsz		(op_encode_hdr_maxsz + \
>  					 encode_fallocate_maxsz)
>  #define decode_deallocate_maxsz		(op_decode_hdr_maxsz)
> @@ -222,6 +224,18 @@ static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
>  	encode_nops(&hdr);
>  }
>  
> +static void encode_copy_commit(struct xdr_stream *xdr,
> +			  struct nfs42_copy_args *args,
> +			  struct compound_hdr *hdr)
> +{
> +	__be32 *p;
> +
> +	encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
> +	p = reserve_space(xdr, 12);
> +	p = xdr_encode_hyper(p, args->dst_pos);
> +	*p = cpu_to_be32(args->count);
> +}
> +
>  /*
>   * Encode COPY request
>   */
> @@ -239,6 +253,7 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
>  	encode_savefh(xdr, &hdr);
>  	encode_putfh(xdr, args->dst_fh, &hdr);
>  	encode_copy(xdr, args, &hdr);
> +	encode_copy_commit(xdr, args, &hdr);
>  	encode_nops(&hdr);
>  }
>  
> diff --git a/fs/nfs/write.c b/fs/nfs/write.c
> index abb2c8a..8d65d88 100644
> --- a/fs/nfs/write.c
> +++ b/fs/nfs/write.c
> @@ -1720,36 +1720,6 @@ void nfs_retry_commit(struct list_head *page_list,
>  	return -ENOMEM;
>  }
>  
> -int nfs_commit_file(struct file *file, struct nfs_write_verifier *verf)
> -{
> -	struct inode *inode = file_inode(file);
> -	struct nfs_open_context *open;
> -	struct nfs_commit_info cinfo;
> -	struct nfs_page *req;
> -	int ret;
> -
> -	open = get_nfs_open_context(nfs_file_open_context(file));
> -	req  = nfs_create_request(open, NULL, NULL, 0, i_size_read(inode));
> -	if (IS_ERR(req)) {
> -		ret = PTR_ERR(req);
> -		goto out_put;
> -	}
> -
> -	nfs_init_cinfo_from_inode(&cinfo, inode);
> -
> -	memcpy(&req->wb_verf, verf, sizeof(struct nfs_write_verifier));
> -	nfs_request_add_commit_list(req, &cinfo);
> -	ret = nfs_commit_inode(inode, FLUSH_SYNC);
> -	if (ret > 0)
> -		ret = 0;
> -
> -	nfs_free_request(req);
> -out_put:
> -	put_nfs_open_context(open);
> -	return ret;
> -}
> -EXPORT_SYMBOL_GPL(nfs_commit_file);
> -
>  /*
>   * COMMIT call returned
>   */
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] NFS append COMMIT after synchronous COPY
  2017-04-18 15:03 ` Anna Schumaker
@ 2017-04-18 16:06   ` Olga Kornievskaia
  2017-04-18 16:09     ` Olga Kornievskaia
  0 siblings, 1 reply; 7+ messages in thread
From: Olga Kornievskaia @ 2017-04-18 16:06 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: Trond.Myklebust, linux-nfs


> On Apr 18, 2017, at 11:03 AM, Anna Schumaker =
<Anna.Schumaker@Netapp.com> wrote:
>=20
> Hi Olga,
>=20
> On 04/17/2017 05:15 PM, Olga Kornievskaia wrote:
>> Instead of messing with the commit path which has been causing =
issues,
>> add a COMMIT op after the COPY and ask for stable copies in the first
>> space.
>>=20
>> It saves a round trip, since after the COPY, the client sends a =
COMMIT
>> anyway.
>>=20
>> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
>> ---
>> fs/nfs/internal.h  |  1 -
>> fs/nfs/nfs42proc.c |  6 ------
>> fs/nfs/nfs42xdr.c  | 15 +++++++++++++++
>> fs/nfs/write.c     | 30 ------------------------------
>> 4 files changed, 15 insertions(+), 37 deletions(-)
>>=20
>> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
>> index 7b38fed..2989418 100644
>> --- a/fs/nfs/internal.h
>> +++ b/fs/nfs/internal.h
>> @@ -495,7 +495,6 @@ void nfs_mark_request_commit(struct nfs_page =
*req,
>> 			     u32 ds_commit_idx);
>> int nfs_write_need_commit(struct nfs_pgio_header *);
>> void nfs_writeback_update_inode(struct nfs_pgio_header *hdr);
>> -int nfs_commit_file(struct file *file, struct nfs_write_verifier =
*verf);
>> int nfs_generic_commit_list(struct inode *inode, struct list_head =
*head,
>> 			    int how, struct nfs_commit_info *cinfo);
>> void nfs_retry_commit(struct list_head *page_list,
>> diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
>> index 1e486c7..9fee48d 100644
>> --- a/fs/nfs/nfs42proc.c
>> +++ b/fs/nfs/nfs42proc.c
>> @@ -174,12 +174,6 @@ static ssize_t _nfs42_proc_copy(struct file =
*src,
>> 	if (status)
>> 		return status;
>>=20
>> -	if (res->write_res.verifier.committed !=3D NFS_FILE_SYNC) {
>> -		status =3D nfs_commit_file(dst, =
&res->write_res.verifier.verifier);
>> -		if (status)
>> -			return status;
>> -	}
>> -
>> 	truncate_pagecache_range(dst_inode, pos_dst,
>> 				 pos_dst + res->write_res.count);
>>=20
>> diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
>> index 6c72964..03f3c9e 100644
>> --- a/fs/nfs/nfs42xdr.c
>> +++ b/fs/nfs/nfs42xdr.c
>> @@ -25,6 +25,8 @@
>> 					 NFS42_WRITE_RES_SIZE + \
>> 					 1 /* cr_consecutive */ + \
>> 					 1 /* cr_synchronous */)
>> +#define decode_commit_maxsz		(op_decode_hdr_maxsz + \
>> +					 decode_verifier_maxsz)e
>=20
> nfs4xdr.c includes this file (it's a weird setup, I know), so this and =
the corresponding encode size should already be declared and available =
to us.  Can you add them to the NFS4_enc_copy_sz and NFS4_dec_copy_size =
values?

Got it. Thanks. Another version commit up.

>=20
> Thanks,
> Anna
>=20
>> #define encode_deallocate_maxsz		(op_encode_hdr_maxsz + \
>> 					 encode_fallocate_maxsz)
>> #define decode_deallocate_maxsz		(op_decode_hdr_maxsz)
>> @@ -222,6 +224,18 @@ static void nfs4_xdr_enc_allocate(struct =
rpc_rqst *req,
>> 	encode_nops(&hdr);
>> }
>>=20
>> +static void encode_copy_commit(struct xdr_stream *xdr,
>> +			  struct nfs42_copy_args *args,
>> +			  struct compound_hdr *hdr)
>> +{
>> +	__be32 *p;
>> +
>> +	encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
>> +	p =3D reserve_space(xdr, 12);
>> +	p =3D xdr_encode_hyper(p, args->dst_pos);
>> +	*p =3D cpu_to_be32(args->count);
>> +}
>> +
>> /*
>>  * Encode COPY request
>>  */
>> @@ -239,6 +253,7 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst =
*req,
>> 	encode_savefh(xdr, &hdr);
>> 	encode_putfh(xdr, args->dst_fh, &hdr);
>> 	encode_copy(xdr, args, &hdr);
>> +	encode_copy_commit(xdr, args, &hdr);
>> 	encode_nops(&hdr);
>> }
>>=20
>> diff --git a/fs/nfs/write.c b/fs/nfs/write.c
>> index abb2c8a..8d65d88 100644
>> --- a/fs/nfs/write.c
>> +++ b/fs/nfs/write.c
>> @@ -1720,36 +1720,6 @@ void nfs_retry_commit(struct list_head =
*page_list,
>> 	return -ENOMEM;
>> }
>>=20
>> -int nfs_commit_file(struct file *file, struct nfs_write_verifier =
*verf)
>> -{
>> -	struct inode *inode =3D file_inode(file);
>> -	struct nfs_open_context *open;
>> -	struct nfs_commit_info cinfo;
>> -	struct nfs_page *req;
>> -	int ret;
>> -
>> -	open =3D get_nfs_open_context(nfs_file_open_context(file));
>> -	req  =3D nfs_create_request(open, NULL, NULL, 0, =
i_size_read(inode));
>> -	if (IS_ERR(req)) {
>> -		ret =3D PTR_ERR(req);
>> -		goto out_put;
>> -	}
>> -
>> -	nfs_init_cinfo_from_inode(&cinfo, inode);
>> -
>> -	memcpy(&req->wb_verf, verf, sizeof(struct nfs_write_verifier));
>> -	nfs_request_add_commit_list(req, &cinfo);
>> -	ret =3D nfs_commit_inode(inode, FLUSH_SYNC);
>> -	if (ret > 0)
>> -		ret =3D 0;
>> -
>> -	nfs_free_request(req);
>> -out_put:
>> -	put_nfs_open_context(open);
>> -	return ret;
>> -}
>> -EXPORT_SYMBOL_GPL(nfs_commit_file);
>> -
>> /*
>>  * COMMIT call returned
>>  */
>>=20


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] NFS append COMMIT after synchronous COPY
  2017-04-18 16:06   ` Olga Kornievskaia
@ 2017-04-18 16:09     ` Olga Kornievskaia
  2017-05-08 20:31       ` Trond Myklebust
  0 siblings, 1 reply; 7+ messages in thread
From: Olga Kornievskaia @ 2017-04-18 16:09 UTC (permalink / raw)
  To: Trond.Myklebust, anna.schumaker; +Cc: linux-nfs

Instead of messing with the commit path which has been causing issues,
add a COMMIT op after the COPY and ask for stable copies in the first
space.

It saves a round trip, since after the COPY, the client sends a COMMIT
anyway.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
---
 fs/nfs/internal.h  |  1 -
 fs/nfs/nfs42proc.c |  6 ------
 fs/nfs/nfs42xdr.c  | 19 +++++++++++++++++--
 fs/nfs/write.c     | 30 ------------------------------
 4 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 7b38fed..2989418 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -495,7 +495,6 @@ void nfs_mark_request_commit(struct nfs_page *req,
 			     u32 ds_commit_idx);
 int nfs_write_need_commit(struct nfs_pgio_header *);
 void nfs_writeback_update_inode(struct nfs_pgio_header *hdr);
-int nfs_commit_file(struct file *file, struct nfs_write_verifier *verf);
 int nfs_generic_commit_list(struct inode *inode, struct list_head *head,
 			    int how, struct nfs_commit_info *cinfo);
 void nfs_retry_commit(struct list_head *page_list,
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 1e486c7..9fee48d 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -174,12 +174,6 @@ static ssize_t _nfs42_proc_copy(struct file *src,
 	if (status)
 		return status;
 
-	if (res->write_res.verifier.committed != NFS_FILE_SYNC) {
-		status = nfs_commit_file(dst, &res->write_res.verifier.verifier);
-		if (status)
-			return status;
-	}
-
 	truncate_pagecache_range(dst_inode, pos_dst,
 				 pos_dst + res->write_res.count);
 
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
index 6c72964..8bdf1d5 100644
--- a/fs/nfs/nfs42xdr.c
+++ b/fs/nfs/nfs42xdr.c
@@ -66,12 +66,14 @@
 					 encode_putfh_maxsz + \
 					 encode_savefh_maxsz + \
 					 encode_putfh_maxsz + \
-					 encode_copy_maxsz)
+					 encode_copy_maxsz + \
+					 encode_commit_maxsz)
 #define NFS4_dec_copy_sz		(compound_decode_hdr_maxsz + \
 					 decode_putfh_maxsz + \
 					 decode_savefh_maxsz + \
 					 decode_putfh_maxsz + \
-					 decode_copy_maxsz)
+					 decode_copy_maxsz + \
+					 decode_commit_maxsz)
 #define NFS4_enc_deallocate_sz		(compound_encode_hdr_maxsz + \
 					 encode_putfh_maxsz + \
 					 encode_deallocate_maxsz + \
@@ -222,6 +224,18 @@ static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
 	encode_nops(&hdr);
 }
 
+static void encode_copy_commit(struct xdr_stream *xdr,
+			  struct nfs42_copy_args *args,
+			  struct compound_hdr *hdr)
+{
+	__be32 *p;
+
+	encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
+	p = reserve_space(xdr, 12);
+	p = xdr_encode_hyper(p, args->dst_pos);
+	*p = cpu_to_be32(args->count);
+}
+
 /*
  * Encode COPY request
  */
@@ -239,6 +253,7 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
 	encode_savefh(xdr, &hdr);
 	encode_putfh(xdr, args->dst_fh, &hdr);
 	encode_copy(xdr, args, &hdr);
+	encode_copy_commit(xdr, args, &hdr);
 	encode_nops(&hdr);
 }
 
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index abb2c8a..8d65d88 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1720,36 +1720,6 @@ void nfs_retry_commit(struct list_head *page_list,
 	return -ENOMEM;
 }
 
-int nfs_commit_file(struct file *file, struct nfs_write_verifier *verf)
-{
-	struct inode *inode = file_inode(file);
-	struct nfs_open_context *open;
-	struct nfs_commit_info cinfo;
-	struct nfs_page *req;
-	int ret;
-
-	open = get_nfs_open_context(nfs_file_open_context(file));
-	req  = nfs_create_request(open, NULL, NULL, 0, i_size_read(inode));
-	if (IS_ERR(req)) {
-		ret = PTR_ERR(req);
-		goto out_put;
-	}
-
-	nfs_init_cinfo_from_inode(&cinfo, inode);
-
-	memcpy(&req->wb_verf, verf, sizeof(struct nfs_write_verifier));
-	nfs_request_add_commit_list(req, &cinfo);
-	ret = nfs_commit_inode(inode, FLUSH_SYNC);
-	if (ret > 0)
-		ret = 0;
-
-	nfs_free_request(req);
-out_put:
-	put_nfs_open_context(open);
-	return ret;
-}
-EXPORT_SYMBOL_GPL(nfs_commit_file);
-
 /*
  * COMMIT call returned
  */
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] NFS append COMMIT after synchronous COPY
  2017-04-18 16:09     ` Olga Kornievskaia
@ 2017-05-08 20:31       ` Trond Myklebust
  2017-05-08 20:48         ` Olga Kornievskaia
  0 siblings, 1 reply; 7+ messages in thread
From: Trond Myklebust @ 2017-05-08 20:31 UTC (permalink / raw)
  To: anna.schumaker@netapp.com, kolga@netapp.com; +Cc: linux-nfs@vger.kernel.org

T24gVHVlLCAyMDE3LTA0LTE4IGF0IDEyOjA5IC0wNDAwLCBPbGdhIEtvcm5pZXZza2FpYSB3cm90
ZToNCj4gSW5zdGVhZCBvZiBtZXNzaW5nIHdpdGggdGhlIGNvbW1pdCBwYXRoIHdoaWNoIGhhcyBi
ZWVuIGNhdXNpbmcNCj4gaXNzdWVzLA0KPiBhZGQgYSBDT01NSVQgb3AgYWZ0ZXIgdGhlIENPUFkg
YW5kIGFzayBmb3Igc3RhYmxlIGNvcGllcyBpbiB0aGUgZmlyc3QNCj4gc3BhY2UuDQo+IA0KPiBJ
dCBzYXZlcyBhIHJvdW5kIHRyaXAsIHNpbmNlIGFmdGVyIHRoZSBDT1BZLCB0aGUgY2xpZW50IHNl
bmRzIGENCj4gQ09NTUlUDQo+IGFueXdheS4NCj4gDQo+IFNpZ25lZC1vZmYtYnk6IE9sZ2EgS29y
bmlldnNrYWlhIDxrb2xnYUBuZXRhcHAuY29tPg0KPiAtLS0NCj4gwqBmcy9uZnMvaW50ZXJuYWwu
aMKgwqB8wqDCoDEgLQ0KPiDCoGZzL25mcy9uZnM0MnByb2MuYyB8wqDCoDYgLS0tLS0tDQo+IMKg
ZnMvbmZzL25mczQye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0KPiAtCW5mc19m
cmVlX3JlcXVlc3QocmVxKTsNCj4gLW91dF9wdXQ6DQo+IC0JcHV0X25mc19vcGVuX2NvbnRleHQo
b3Blbik7DQo+IC0JcmV0dXJuIHJldDsNCj4gLX0NCj4gLUVYUE9SVF9TWU1CT0xfR1BMKG5mc19j
b21taXRfZmlsZSk7DQo+IC0NCj4gwqAvKg0KPiDCoCAqIENPTU1JVCBjYWxsIHJldHVybmVkDQo+
IMKgICovDQoNClNob3VsZG4ndCB3ZSBkZWNvZGUgdGhlIHJlcGx5IGZyb20gdGhlIHNlcnZlciBz
byB0aGF0IHdlIGNhbiByZXR1cm4gYW4NCmVycm9yIG1lc3NhZ2Ugb3IgcmV0cnkgaWYgdGhlIGNv
bW1pdCBmYWlsZWQgYW5kL29yIHRoZSB2ZXJpZmllcnMgZG9uJ3QNCm1hdGNoPyBPdGhlcndpc2Ug
d2Ugd29uJ3Qgbm90aWNlIGlmIHRoZSBmbHVzaCB0byBkaXNrIGZhaWxlZC4NCg0KLS0gDQpUcm9u
ZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lciwgUHJpbWFyeURhdGENCnRy
b25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg==


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] NFS append COMMIT after synchronous COPY
  2017-05-08 20:31       ` Trond Myklebust
@ 2017-05-08 20:48         ` Olga Kornievskaia
  2017-05-08 22:02           ` [PATCH v3 " Olga Kornievskaia
  0 siblings, 1 reply; 7+ messages in thread
From: Olga Kornievskaia @ 2017-05-08 20:48 UTC (permalink / raw)
  To: Trond Myklebust
  Cc: anna.schumaker@netapp.com, kolga@netapp.com,
	linux-nfs@vger.kernel.org

On Mon, May 8, 2017 at 4:31 PM, Trond Myklebust <trondmy@primarydata.com> wrote:
> On Tue, 2017-04-18 at 12:09 -0400, Olga Kornievskaia wrote:
>> Instead of messing with the commit path which has been causing
>> issues,
>> add a COMMIT op after the COPY and ask for stable copies in the first
>> space.
>>
>> It saves a round trip, since after the COPY, the client sends a
>> COMMIT
>> anyway.
>>
>> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
>> ---
>>  fs/nfs/internal.h  |  1 -
>>  fs/nfs/nfs42proc.c |  6 ------
>>  fs/nfs/nfs42xdr.c  | 19 +++++++++++++++++--
>>  fs/nfs/write.c     | 30 ------------------------------
>>  4 files changed, 17 insertions(+), 39 deletions(-)
>>
>> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
>> index 7b38fed..2989418 100644
>> --- a/fs/nfs/internal.h
>> +++ b/fs/nfs/internal.h
>> @@ -495,7 +495,6 @@ void nfs_mark_request_commit(struct nfs_page
>> *req,
>>                            u32 ds_commit_idx);
>>  int nfs_write_need_commit(struct nfs_pgio_header *);
>>  void nfs_writeback_update_inode(struct nfs_pgio_header *hdr);
>> -int nfs_commit_file(struct file *file, struct nfs_write_verifier
>> *verf);
>>  int nfs_generic_commit_list(struct inode *inode, struct list_head
>> *head,
>>                           int how, struct nfs_commit_info *cinfo);
>>  void nfs_retry_commit(struct list_head *page_list,
>> diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
>> index 1e486c7..9fee48d 100644
>> --- a/fs/nfs/nfs42proc.c
>> +++ b/fs/nfs/nfs42proc.c
>> @@ -174,12 +174,6 @@ static ssize_t _nfs42_proc_copy(struct file
>> *src,
>>       if (status)
>>               return status;
>>
>> -     if (res->write_res.verifier.committed != NFS_FILE_SYNC) {
>> -             status = nfs_commit_file(dst, &res-
>> >write_res.verifier.verifier);
>> -             if (status)
>> -                     return status;
>> -     }
>> -
>>       truncate_pagecache_range(dst_inode, pos_dst,
>>                                pos_dst + res->write_res.count);
>>
>> diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
>> index 6c72964..8bdf1d5 100644
>> --- a/fs/nfs/nfs42xdr.c
>> +++ b/fs/nfs/nfs42xdr.c
>> @@ -66,12 +66,14 @@
>>                                        encode_putfh_maxsz + \
>>                                        encode_savefh_maxsz + \
>>                                        encode_putfh_maxsz + \
>> -                                      encode_copy_maxsz)
>> +                                      encode_copy_maxsz + \
>> +                                      encode_commit_maxsz)
>>  #define NFS4_dec_copy_sz             (compound_decode_hdr_maxsz +
>> \
>>                                        decode_putfh_maxsz + \
>>                                        decode_savefh_maxsz + \
>>                                        decode_putfh_maxsz + \
>> -                                      decode_copy_maxsz)
>> +                                      decode_copy_maxsz + \
>> +                                      decode_commit_maxsz)
>>  #define NFS4_enc_deallocate_sz               (compound_encode_hdr_m
>> axsz + \
>>                                        encode_putfh_maxsz + \
>>                                        encode_deallocate_maxsz + \
>> @@ -222,6 +224,18 @@ static void nfs4_xdr_enc_allocate(struct
>> rpc_rqst *req,
>>       encode_nops(&hdr);
>>  }
>>
>> +static void encode_copy_commit(struct xdr_stream *xdr,
>> +                       struct nfs42_copy_args *args,
>> +                       struct compound_hdr *hdr)
>> +{
>> +     __be32 *p;
>> +
>> +     encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
>> +     p = reserve_space(xdr, 12);
>> +     p = xdr_encode_hyper(p, args->dst_pos);
>> +     *p = cpu_to_be32(args->count);
>> +}
>> +
>>  /*
>>   * Encode COPY request
>>   */
>> @@ -239,6 +253,7 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst
>> *req,
>>       encode_savefh(xdr, &hdr);
>>       encode_putfh(xdr, args->dst_fh, &hdr);
>>       encode_copy(xdr, args, &hdr);
>> +     encode_copy_commit(xdr, args, &hdr);
>>       encode_nops(&hdr);
>>  }
>>
>> diff --git a/fs/nfs/write.c b/fs/nfs/write.c
>> index abb2c8a..8d65d88 100644
>> --- a/fs/nfs/write.c
>> +++ b/fs/nfs/write.c
>> @@ -1720,36 +1720,6 @@ void nfs_retry_commit(struct list_head
>> *page_list,
>>       return -ENOMEM;
>>  }
>>
>> -int nfs_commit_file(struct file *file, struct nfs_write_verifier
>> *verf)
>> -{
>> -     struct inode *inode = file_inode(file);
>> -     struct nfs_open_context *open;
>> -     struct nfs_commit_info cinfo;
>> -     struct nfs_page *req;
>> -     int ret;
>> -
>> -     open = get_nfs_open_context(nfs_file_open_context(file));
>> -     req  = nfs_create_request(open, NULL, NULL, 0,
>> i_size_read(inode));
>> -     if (IS_ERR(req)) {
>> -             ret = PTR_ERR(req);
>> -             goto out_put;
>> -     }
>> -
>> -     nfs_init_cinfo_from_inode(&cinfo, inode);
>> -
>> -     memcpy(&req->wb_verf, verf, sizeof(struct
>> nfs_write_verifier));
>> -     nfs_request_add_commit_list(req, &cinfo);
>> -     ret = nfs_commit_inode(inode, FLUSH_SYNC);
>> -     if (ret > 0)
>> -             ret = 0;
>> -
>> -     nfs_free_request(req);
>> -out_put:
>> -     put_nfs_open_context(open);
>> -     return ret;
>> -}
>> -EXPORT_SYMBOL_GPL(nfs_commit_file);
>> -
>>  /*
>>   * COMMIT call returned
>>   */
>
> Shouldn't we decode the reply from the server so that we can return an
> error message or retry if the commit failed and/or the verifiers don't
> match? Otherwise we won't notice if the flush to disk failed.

Good point. Let me see what I can come up with.

> --
> Trond Myklebust
> Linux NFS client maintainer, PrimaryData
> trond.myklebust@primarydata.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/1] NFS append COMMIT after synchronous COPY
  2017-05-08 20:48         ` Olga Kornievskaia
@ 2017-05-08 22:02           ` Olga Kornievskaia
  0 siblings, 0 replies; 7+ messages in thread
From: Olga Kornievskaia @ 2017-05-08 22:02 UTC (permalink / raw)
  To: Trond.Myklebust, anna.schumaker; +Cc: linux-nfs

Instead of messing with the commit path which has been causing issues,
add a COMMIT op after the COPY and ask for stable copies in the first
space.

It saves a round trip, since after the COPY, the client sends a COMMIT
anyway.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
---
 fs/nfs/internal.h       |  1 -
 fs/nfs/nfs42proc.c      | 21 +++++++++++++++------
 fs/nfs/nfs42xdr.c       | 22 ++++++++++++++++++++--
 fs/nfs/write.c          | 30 ------------------------------
 include/linux/nfs_xdr.h |  1 +
 5 files changed, 36 insertions(+), 39 deletions(-)

diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 31b26cf..e9b4c33 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -495,7 +495,6 @@ void nfs_mark_request_commit(struct nfs_page *req,
 			     u32 ds_commit_idx);
 int nfs_write_need_commit(struct nfs_pgio_header *);
 void nfs_writeback_update_inode(struct nfs_pgio_header *hdr);
-int nfs_commit_file(struct file *file, struct nfs_write_verifier *verf);
 int nfs_generic_commit_list(struct inode *inode, struct list_head *head,
 			    int how, struct nfs_commit_info *cinfo);
 void nfs_retry_commit(struct list_head *page_list,
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 87f5b7b..929d09a 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -167,23 +167,29 @@ static ssize_t _nfs42_proc_copy(struct file *src,
 	if (status)
 		return status;
 
+	res->commit_res.verf = kzalloc(sizeof(struct nfs_writeverf), GFP_NOFS);
+	if (!res->commit_res.verf)
+		return -ENOMEM;
 	status = nfs4_call_sync(server->client, server, &msg,
 				&args->seq_args, &res->seq_res, 0);
 	if (status == -ENOTSUPP)
 		server->caps &= ~NFS_CAP_COPY;
 	if (status)
-		return status;
+		goto out;
 
-	if (res->write_res.verifier.committed != NFS_FILE_SYNC) {
-		status = nfs_commit_file(dst, &res->write_res.verifier.verifier);
-		if (status)
-			return status;
+	if (!nfs_write_verifier_cmp(&res->write_res.verifier.verifier,
+				    &res->commit_res.verf->verifier)) {
+		status = -EAGAIN;
+		goto out;
 	}
 
 	truncate_pagecache_range(dst_inode, pos_dst,
 				 pos_dst + res->write_res.count);
 
-	return res->write_res.count;
+	status = res->write_res.count;
+out:
+	kfree(res->commit_res.verf);
+	return status;
 }
 
 ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
@@ -240,6 +246,9 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
 		if (err == -ENOTSUPP) {
 			err = -EOPNOTSUPP;
 			break;
+		} if (err == -EAGAIN) {
+			dst_exception.retry = 1;
+			continue;
 		}
 
 		err2 = nfs4_handle_exception(server, err, &src_exception);
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
index 6c72964..528362f 100644
--- a/fs/nfs/nfs42xdr.c
+++ b/fs/nfs/nfs42xdr.c
@@ -66,12 +66,14 @@
 					 encode_putfh_maxsz + \
 					 encode_savefh_maxsz + \
 					 encode_putfh_maxsz + \
-					 encode_copy_maxsz)
+					 encode_copy_maxsz + \
+					 encode_commit_maxsz)
 #define NFS4_dec_copy_sz		(compound_decode_hdr_maxsz + \
 					 decode_putfh_maxsz + \
 					 decode_savefh_maxsz + \
 					 decode_putfh_maxsz + \
-					 decode_copy_maxsz)
+					 decode_copy_maxsz + \
+					 decode_commit_maxsz)
 #define NFS4_enc_deallocate_sz		(compound_encode_hdr_maxsz + \
 					 encode_putfh_maxsz + \
 					 encode_deallocate_maxsz + \
@@ -222,6 +224,18 @@ static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
 	encode_nops(&hdr);
 }
 
+static void encode_copy_commit(struct xdr_stream *xdr,
+			  struct nfs42_copy_args *args,
+			  struct compound_hdr *hdr)
+{
+	__be32 *p;
+
+	encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
+	p = reserve_space(xdr, 12);
+	p = xdr_encode_hyper(p, args->dst_pos);
+	*p = cpu_to_be32(args->count);
+}
+
 /*
  * Encode COPY request
  */
@@ -239,6 +253,7 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
 	encode_savefh(xdr, &hdr);
 	encode_putfh(xdr, args->dst_fh, &hdr);
 	encode_copy(xdr, args, &hdr);
+	encode_copy_commit(xdr, args, &hdr);
 	encode_nops(&hdr);
 }
 
@@ -481,6 +496,9 @@ static int nfs4_xdr_dec_copy(struct rpc_rqst *rqstp,
 	if (status)
 		goto out;
 	status = decode_copy(xdr, res);
+	if (status)
+		goto out;
+	status = decode_commit(xdr, &res->commit_res);
 out:
 	return status;
 }
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 59e21cc..85bfa41 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1742,36 +1742,6 @@ void nfs_retry_commit(struct list_head *page_list,
 				   data->mds_ops, how, 0);
 }
 
-int nfs_commit_file(struct file *file, struct nfs_write_verifier *verf)
-{
-	struct inode *inode = file_inode(file);
-	struct nfs_open_context *open;
-	struct nfs_commit_info cinfo;
-	struct nfs_page *req;
-	int ret;
-
-	open = get_nfs_open_context(nfs_file_open_context(file));
-	req  = nfs_create_request(open, NULL, NULL, 0, i_size_read(inode));
-	if (IS_ERR(req)) {
-		ret = PTR_ERR(req);
-		goto out_put;
-	}
-
-	nfs_init_cinfo_from_inode(&cinfo, inode);
-
-	memcpy(&req->wb_verf, verf, sizeof(struct nfs_write_verifier));
-	nfs_request_add_commit_list(req, &cinfo);
-	ret = nfs_commit_inode(inode, FLUSH_SYNC);
-	if (ret > 0)
-		ret = 0;
-
-	nfs_free_request(req);
-out_put:
-	put_nfs_open_context(open);
-	return ret;
-}
-EXPORT_SYMBOL_GPL(nfs_commit_file);
-
 /*
  * COMMIT call returned
  */
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 677c6b9..b28c834 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1383,6 +1383,7 @@ struct nfs42_copy_res {
 	struct nfs42_write_res		write_res;
 	bool				consecutive;
 	bool				synchronous;
+	struct nfs_commitres		commit_res;
 };
 
 struct nfs42_seek_args {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-05-08 22:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-17 21:15 [PATCH 1/1] NFS append COMMIT after synchronous COPY Olga Kornievskaia
2017-04-18 15:03 ` Anna Schumaker
2017-04-18 16:06   ` Olga Kornievskaia
2017-04-18 16:09     ` Olga Kornievskaia
2017-05-08 20:31       ` Trond Myklebust
2017-05-08 20:48         ` Olga Kornievskaia
2017-05-08 22:02           ` [PATCH v3 " Olga Kornievskaia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).