NFS append COMMIT after synchronous COPY
Subsystems (2)
PATCH 1/1 NFS append COMMIT after synchronous COPY
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.
--- 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(-)
fs/nfs/internal.h +0 -1
@@ -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,
fs/nfs/nfs42proc.c +0 -6
@@ -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);
fs/nfs/nfs42xdr.c +15 -0
@@ -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); }
fs/nfs/write.c +0 -30
@@ -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 */
Signature · 1 line
1.8.3.1
Hi Olga,
Quoted 49 lines · Olga Kornievskaia
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 <[email protected]>--- 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(-)fs/nfs/internal.h +0
-1@@ -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,fs/nfs/nfs42proc.c +0
-6@@ -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);fs/nfs/nfs42xdr.c +0
-0
fs/nfs/nfs42xdr.c line 29
Quoted 5 lines
fs/nfs/nfs42xdr.c +2
-0@@ -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
Quoted 72 lines
fs/nfs/nfs42xdr.c +13
-0#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); }fs/nfs/write.c +0
-30@@ -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 */
Quoted 2 lines
On Apr 18, 2017, at 11:03 AM, Anna Schumaker =
Quoted 5 lines · <[email protected]> wrote:
=20
Hi Olga,
=20Quoted 1 line · Olga Kornievskaia
Instead of messing with the commit path which has been causing =
issues,
Quoted 4 lines
Quoted 4 lines
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
Quoted 7 lines
Quoted 7 lines
anyway.
=20Signed-off-by Olga Kornievskaia <[email protected]>---
fs/nfs/internal.h | 1 - fs/nfs/nfs42proc.c | 6 ------ fs/nfs/nfs42xdr.c | 15 +++++++++++++++
Quoted 8 lines
fs/nfs/internal.h void nfs_mark_request_commit(struct nfs_page =
Quoted 8 lines
fs/nfs/write.c| 30 ------------------------------4 files changed, 15 insertions(+), 37 deletions(-)=20
fs/nfs/internal.h +0
-0@@ -495,7 +495,6 @@ void nfs_mark_request_commit(struct nfs_page =
*req,
Quoted 4 lines
fs/nfs/internal.h void nfs_mark_request_commit(struct nfs_page *req,
Quoted 4 lines
fs/nfs/internal.h +0
-1u32 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);
Quoted 1 line
Quoted 1 line
int nfs_generic_commit_list(struct inode *inode, struct
list_head=
*head,
Quoted 7 lines
fs/nfs/nfs42proc.c static ssize_t _nfs42_proc_copy(struct file =
Quoted 7 lines
int how, struct nfs_commit_info *cinfo);void nfs_retry_commit(struct
list_head*page_list,fs/nfs/nfs42proc.c +0
-0@@ -174,12 +174,6 @@ static ssize_t _nfs42_proc_copy(struct file =
*src,
Quoted 5 lines
fs/nfs/nfs42proc.c
Quoted 5 lines
fs/nfs/nfs42proc.c +0
-0if (status)return status;=20
fs/nfs/nfs42proc.c +0
-2- if (res->write_res.verifier.committed !=3D NFS_FILE_SYNC) { - status =3D nfs_commit_file(dst, =
&res->write_res.verifier.verifier);
Quoted 11 lines
Quoted 11 lines
fs/nfs/nfs42proc.c +0
-4-if (status) -return status; - } -truncate_pagecache_range(dst_inode, pos_dst, pos_dst + res->write_res.count);=20
fs/nfs/nfs42xdr.c +0
-0
Quoted 8 lines
fs/nfs/nfs42xdr.c line 29
Quoted 6 lines
fs/nfs/nfs42xdr.c +2
-0@@ -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.cincludes 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.
Quoted 8 lines
=20
Thanks,
Anna
=20fs/nfs/nfs42xdr.c static void nfs4_xdr_enc_allocate(struct =
Quoted 4 lines
fs/nfs/nfs42xdr.c +0
-0#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,
Quoted 11 lines
Quoted 11 lines
fs/nfs/nfs42xdr.c +0
-0encode_nops (&hdr); }=20
fs/nfs/nfs42xdr.c +8
-0+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);
Quoted 8 lines
fs/nfs/nfs42xdr.c static void nfs4_xdr_enc_copy(struct rpc_rqst =
Quoted 8 lines
fs/nfs/nfs42xdr.c +4
-0+ p =3D xdr_encode_hyper(p, args->dst_pos); + *p =3D cpu_to_be32(args->count); +} +/*
* Encode COPY request
*/fs/nfs/nfs42xdr.c +0
-0@@ -239,6 +253,7 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst =
*req,
Quoted 4 lines
Quoted 4 lines
fs/nfs/nfs42xdr.c +1
-0encode_savefh (xdr, &hdr);encode_putfh (xdr, args->dst_fh, &hdr);encode_copy (xdr, args, &hdr); +encode_copy_commit (xdr, args, &hdr);
Quoted 8 lines
fs/nfs/write.c void nfs_retry_commit(struct list_head =
Quoted 8 lines
fs/nfs/nfs42xdr.c +0
-0encode_nops (&hdr); }=20
fs/nfs/write.c +0
-0@@ -1720,36 +1720,6 @@ void nfs_retry_commit(struct list_head =
*page_list,
Quoted 4 lines
Quoted 4 lines
fs/nfs/write.c +0
-0return -ENOMEM ; }=20
-int nfs_commit_file(struct file *file, structnfs_write_verifier=
*verf)
Quoted 9 lines
fs/nfs/write.c void nfs_retry_commit(struct list_head *page_list,
Quoted 9 lines
fs/nfs/write.c +0
-9-{ - 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));
Quoted 24 lines
Quoted 24 lines
fs/nfs/write.c +0
-20-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
PATCH 1/1 NFS append COMMIT after synchronous COPY
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.
--- 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(-)
fs/nfs/internal.h +0 -1
@@ -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,
fs/nfs/nfs42proc.c +0 -6
@@ -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);
fs/nfs/nfs42xdr.c +17 -2
@@ -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); }
fs/nfs/write.c +0 -30
@@ -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; -}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B2ZXJpZmllcnMgZG9uJ3QNCm1hdGNoPyBPdGhlcndpc2Ug d2Ugd29uJ3Qgbm90aWNlIGlmIHRoZSBmbHVzaCB0byBkaXNrIGZhaWxlZC4NCg0KLS0gDQpUcm9u ZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lciwgUHJpbWFyeURhdGENCnRy b25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg==
Quoted 145 lines · Trond Myklebust
Quoted 144 lines · Olga Kornievskaia
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 <[email protected]>--- 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(-)fs/nfs/internal.h +0
-1@@ -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,fs/nfs/nfs42proc.c +0
-6@@ -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);fs/nfs/nfs42xdr.c +4
-2@@ -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 + \fs/nfs/nfs42xdr.c +12
-0@@ -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 */
fs/nfs/nfs42xdr.c +1
-0@@ -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); }fs/nfs/write.c +0
-18@@ -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));fs/nfs/write.c +0
-11-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);
Quoted 8 lines
Quoted 4 lines
-
/*
* 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.
Quoted 4 lines
--
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]
PATCH v3 1/1 NFS append COMMIT after synchronous COPY
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.
--- 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(-)
fs/nfs/internal.h +0 -1
@@ -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,
fs/nfs/nfs42proc.c +15 -6
@@ -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);
fs/nfs/nfs42xdr.c +20 -2
@@ -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; }
fs/nfs/write.c +0 -30
@@ -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 */
include/linux/nfs_xdr.h +1 -0
@@ -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 {
Signature · 1 line
1.8.3.1