NFS/pNFS: Fix up pNFS write reschedule layering violations and bugs
Subsystems (2)
PATCH 1/4 NFS/pNFS: Fix up pNFS write reschedule layering violations and bugs
The flexfiles layout in particular, seems to want to poke around in the O_DIRECT flags when retransmitting.
This patch sets up an interface to allow it to call back into O_DIRECT to handle retransmission correctly. It also fixes a potential bug whereby we could change the behaviour of O_DIRECT if an error is already pending.
--- fs/nfs/direct.c | 21 +++++++++++++++------ fs/nfs/flexfilelayout/flexfilelayout.c | 13 +------------ fs/nfs/internal.h | 1 - fs/nfs/write.c | 6 ++++++ include/linux/nfs_xdr.h | 1 + 5 files changed, 23 insertions(+), 19 deletions(-)
fs/nfs/direct.c +15 -6
@@ -117,12 +117,6 @@ static inline int put_dreq(struct nfs_direct_req *dreq)return atomic_dec_and_test (&dreq->io_count); } -void nfs_direct_set_resched_writes (struct nfs_direct_req *dreq) -{ - dreq->flags =NFS_ODIRECT_RESCHED_WRITES ; -} -EXPORT_SYMBOL_GPL (nfs_direct_set_resched_writes); -static void nfs_direct_good_bytes (struct nfs_direct_req *dreq,struct nfs_pgio_header *hdr) {
@@ -839,10 +833,25 @@ static void nfs_write_sync_pgio_error(struct list_head *head) } } +static void nfs_direct_write_reschedule_io (struct nfs_pgio_header *hdr) +{ +struct nfs_direct_req *dreq = hdr->dreq; + +spin_lock (&dreq->lock); +if (dreq->error ==0 ) { + dreq->flags =NFS_ODIRECT_RESCHED_WRITES ; +/* fake unstable write to let common nfs resend pages */ + hdr->verf.committed =NFS_UNSTABLE ; + hdr->good_bytes = hdr->args.count; + } +spin_unlock (&dreq->lock); +} +static const struct nfs_pgio_completion_ops nfs_direct_write_completion_ops = { .error_cleanup = nfs_write_sync_pgio_error, .init_hdr = nfs_direct_pgio_init, .completion = nfs_direct_write_completion, + .reschedule_io = nfs_direct_write_reschedule_io, };
fs/nfs/flexfilelayout/flexfilelayout.c +1 -12
@@ -912,18 +912,7 @@ static void ff_layout_reset_write(struct nfs_pgio_header *hdr, bool retry_pnfs) hdr->args.count, (unsigned long long)hdr->args.offset); -if (!hdr->dreq) { -struct nfs_open_context *ctx; - - ctx =nfs_list_entry (hdr->pages.next)->wb_context; -set_bit (NFS_CONTEXT_RESEND_WRITES , &ctx->flags); - hdr->completion_ops->error_cleanup (&hdr->pages); - }else { -nfs_direct_set_resched_writes (hdr->dreq); -/* fake unstable write to let common nfs resend pages */ - hdr->verf.committed =NFS_UNSTABLE ; - hdr->good_bytes = hdr->args.count; - } + hdr->completion_ops->reschedule_io (hdr);return ; }
fs/nfs/internal.h +0 -1
@@ -519,7 +519,6 @@ static inline void nfs_inode_dio_wait(struct inode *inode)inode_dio_wait (inode); }extern ssize_t nfs_dreq_bytes_left (struct nfs_direct_req *dreq); -extern void nfs_direct_set_resched_writes (struct nfs_direct_req *dreq);/* nfs4proc.c */ extern void __nfs4_read_done_cb (struct nfs_pgio_header *);
fs/nfs/write.c +6 -0
@@ -1326,9 +1326,15 @@ static void nfs_async_write_error(struct list_head *head) } } +static void nfs_async_write_reschedule_io (struct nfs_pgio_header *hdr) +{ +nfs_async_write_error (&hdr->pages); +} +static const struct nfs_pgio_completion_ops nfs_async_write_completion_ops = { .error_cleanup = nfs_async_write_error, .completion = nfs_write_completion, + .reschedule_io = nfs_async_write_reschedule_io, }; void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
include/linux/nfs_xdr.h +1 -0
@@ -1460,6 +1460,7 @@ struct nfs_pgio_completion_ops {void (*error_cleanup)(struct list_head *head);void (*init_hdr)(struct nfs_pgio_header *hdr);void (*completion)(struct nfs_pgio_header *hdr); +void (*reschedule_io)(struct nfs_pgio_header *hdr); };struct nfs_unlinkdata {
Signature · 1 line
2.5.0
PATCH 2/4 NFS: Allow multiple commit requests in flight per file
Allow synchronous RPC calls to wait for pending RPC calls to finish, but also allow asynchronous ones to just fire off another commit.
With this patch, the xfstests generic/074 test completes in 226s instead of 242s
--- fs/nfs/direct.c | 6 ----- fs/nfs/file.c | 2 +- fs/nfs/nfstrace.h | 1 - fs/nfs/pnfs_nfs.c | 5 +--- fs/nfs/write.c | 70 +++++++++++++++++++++++-------------------------- include/linux/nfs_fs.h | 1 - include/linux/nfs_xdr.h | 1 - 7 files changed, 35 insertions(+), 51 deletions(-)
fs/nfs/direct.c +0 -6
@@ -721,14 +721,8 @@ static void nfs_direct_commit_complete(struct nfs_commit_data *data)nfs_direct_write_complete (dreq, data->inode); } -static void nfs_direct_error_cleanup (struct nfs_inode *nfsi) -{ -/* There is no lock to clear */ -} -static const struct nfs_commit_completion_ops nfs_direct_commit_completion_ops = { .completion = nfs_direct_commit_complete, - .error_cleanup = nfs_direct_error_cleanup, };static void nfs_direct_commit_schedule (struct nfs_direct_req *dreq)
fs/nfs/file.c +1 -1
@@ -514,7 +514,7 @@ static void nfs_check_dirty_writeback(struct page *page,* so it will not block due to pages that will shortly be freeable. */ nfsi =NFS_I (mapping->host); -if (test_bit (NFS_INO_COMMIT , &nfsi->flags)) { +if (atomic_read (&nfsi->commit_info.rpcs_out)) { *writeback = true;return ; }
fs/nfs/nfstrace.h +0 -1
@@ -39,7 +39,6 @@ { 1 << NFS_INO_INVALIDATING, "INVALIDATING" }, \ { 1 << NFS_INO_FLUSHING, "FLUSHING" }, \ { 1 << NFS_INO_FSCACHE, "FSCACHE" }, \ - { 1 << NFS_INO_COMMIT, "COMMIT" }, \ { 1 << NFS_INO_LAYOUTCOMMIT, "NEED_LAYOUTCOMMIT" }, \ { 1 << NFS_INO_LAYOUTCOMMITTING, "LAYOUTCOMMIT" })
fs/nfs/pnfs_nfs.c +1 -4
@@ -266,17 +266,14 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages, }else {nfs_retry_commit (mds_pages,NULL , cinfo,0 );pnfs_generic_retry_commit (cinfo,0 ); - cinfo->completion_ops->error_cleanup (NFS_I (inode));return -ENOMEM ; } } nreq +=pnfs_generic_alloc_ds_commits (cinfo, &list); -if (nreq ==0 ) { - cinfo->completion_ops->error_cleanup (NFS_I (inode)); +if (nreq ==0 ) goto out; - }atomic_add (nreq, &cinfo->mds->rpcs_out);
fs/nfs/write.c +33 -37
118 lines not on this page · raw message
include/linux/nfs_fs.h +0 -1
@@ -216,7 +216,6 @@ struct nfs_inode {#define NFS_INO_FLUSHING (4)/* inode is flushing out data */ #define NFS_INO_FSCACHE (5)/* inode can be cached by FS-Cache */ #define NFS_INO_FSCACHE_LOCK (6)/* FS-Cache cookie management lock */ -#define NFS_INO_COMMIT (7)/* inode is committing unstable writes */ #define NFS_INO_LAYOUTCOMMIT (9)/* layoutcommit required */ #define NFS_INO_LAYOUTCOMMITTING (10)/* layoutcommit inflight */ #define NFS_INO_LAYOUTSTATS (11)/* layoutstats inflight */
include/linux/nfs_xdr.h +0 -1
@@ -1423,7 +1423,6 @@ struct nfs_mds_commit_info {struct nfs_commit_data ;struct nfs_inode ;struct nfs_commit_completion_ops { -void (*error_cleanup) (struct nfs_inode *nfsi);void (*completion) (struct nfs_commit_data *data); };
Signature · 1 line
2.5.0
PATCH 3/4 NFSv4.1/pNFS: Don't queue up a new commit if the layout segment is invalid
If the layout segment is invalid, then we should not be adding more write requests to the commit list. Instead, those writes should be replayed after requesting a new layout.
--- fs/nfs/callback_proc.c | 2 ++ fs/nfs/direct.c | 12 ++++++++++++ fs/nfs/pnfs.c | 3 +++ fs/nfs/pnfs.h | 6 ++++++ fs/nfs/pnfs_nfs.c | 5 +++++ fs/nfs/write.c | 8 ++++++++ include/linux/nfs_xdr.h | 2 ++ 7 files changed, 38 insertions(+)
fs/nfs/callback_proc.c +2 -0
@@ -233,6 +233,8 @@ static u32 initiate_file_draining(struct nfs_client *clp, unlock:spin_unlock (&ino->i_lock);pnfs_free_lseg_list (&free_me_list); +/* Free all lsegs that are attached to commit buckets */ +nfs_commit_inode (ino,0 );pnfs_put_layout_hdr (lo);trace_nfs4_cb_layoutrecall_file (clp, &args->cbl_fh, ino, &args->cbl_stateid, -rv);
fs/nfs/direct.c +12 -0
@@ -721,8 +721,20 @@ static void nfs_direct_commit_complete(struct nfs_commit_data *data)nfs_direct_write_complete (dreq, data->inode); } +static void nfs_direct_resched_write (struct nfs_commit_info *cinfo, +struct nfs_page *req) +{ +struct nfs_direct_req *dreq = cinfo->dreq; + +spin_lock (&dreq->lock); + dreq->flags =NFS_ODIRECT_RESCHED_WRITES ; +spin_unlock (&dreq->lock); +nfs_mark_request_commit (req,NULL , cinfo,0 ); +} +static const struct nfs_commit_completion_ops nfs_direct_commit_completion_ops = { .completion = nfs_direct_commit_complete, + .resched_write = nfs_direct_resched_write, };static void nfs_direct_commit_schedule (struct nfs_direct_req *dreq)
fs/nfs/pnfs.c +3 -0
@@ -703,6 +703,8 @@ pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list, ret = -EAGAIN ;spin_unlock (&inode->i_lock);pnfs_free_lseg_list (&lseg_list); +/* Free all lsegs that are attached to commit buckets */ +nfs_commit_inode (inode,0 );pnfs_put_layout_hdr (lo);iput (inode); }
@@ -1811,6 +1813,7 @@ void pnfs_error_mark_layout_for_return(struct inode *inode,pnfs_mark_matching_lsegs_return (lo, &free_me, &range);spin_unlock (&inode->i_lock);pnfs_free_lseg_list (&free_me); +nfs_commit_inode (inode,0 ); }EXPORT_SYMBOL_GPL (pnfs_error_mark_layout_for_return);
fs/nfs/pnfs.h +6 -0
@@ -412,6 +412,12 @@ pnfs_get_lseg(struct pnfs_layout_segment *lseg)return lseg; } +static inline bool +pnfs_is_valid_lseg (struct pnfs_layout_segment *lseg) +{ +return test_bit (NFS_LSEG_VALID , &lseg->pls_flags) !=0 ; +} +/* Return true if a layout driver is being used for this mountpoint */ static inline int pnfs_enabled_sb (struct nfs_server *nfss) {
fs/nfs/pnfs_nfs.c +5 -0
@@ -868,6 +868,11 @@ pnfs_layout_mark_request_commit(struct nfs_page *req, buckets = cinfo->ds->buckets; list = &buckets[ds_commit_idx].written;if (list_empty (list)) { +if (!pnfs_is_valid_lseg (lseg)) { +spin_unlock (cinfo->lock); + cinfo->completion_ops->resched_write (cinfo, req); +return ; + }/* Non-empty buckets hold a reference on the lseg. That ref * is normally transferred to the COMMIT call and released * there. It could also be released if the last req is pulled
fs/nfs/write.c +8 -0
@@ -1676,6 +1676,13 @@ void nfs_retry_commit(struct list_head *page_list, }EXPORT_SYMBOL_GPL (nfs_retry_commit); +static void +nfs_commit_resched_write (struct nfs_commit_info *cinfo, +struct nfs_page *req) +{ +__set_page_dirty_nobuffers (req->wb_page); +} +/* * Commit dirty pages */
@@ -1777,6 +1784,7 @@ static const struct rpc_call_ops nfs_commit_ops = {static const struct nfs_commit_completion_ops nfs_commit_completion_ops = { .completion = nfs_commit_release_pages, + .resched_write = nfs_commit_resched_write, }; int nfs_generic_commit_list(struct inode *inode, struct list_head *head,
include/linux/nfs_xdr.h +2 -0
@@ -1420,10 +1420,12 @@ struct nfs_mds_commit_info {struct list_head list; }; +struct nfs_commit_info ;struct nfs_commit_data ;struct nfs_inode ;struct nfs_commit_completion_ops {void (*completion) (struct nfs_commit_data *data); +void (*resched_write) (struct nfs_commit_info *,struct nfs_page *); };struct nfs_commit_info {
Signature · 1 line
2.5.0
PATCH 4/4 NFS: Relax requirements in nfs_flush_incompatible
If two processes share the same credentials and NFSv4 open stateid, then allow them both to dirty the same page, even if their nfs_open_context differs.
--- fs/nfs/internal.h | 6 ++++++ fs/nfs/pagelist.c | 6 ------ fs/nfs/write.c | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-)
fs/nfs/internal.h +6 -0
@@ -264,6 +264,12 @@ static inline bool nfs_pgio_has_mirroring(struct nfs_pageio_descriptor *desc)return desc->pg_mirror_count >1 ; } +static inline bool nfs_match_open_context (const struct nfs_open_context *ctx1, +const struct nfs_open_context *ctx2) +{ +return ctx1->cred == ctx2->cred && ctx1->state == ctx2->state; +} +/* nfs2xdr.c */ extern struct rpc_procinfo nfs_procedures[]; extern int nfs2_decode_dirent(struct xdr_stream *,
fs/nfs/pagelist.c +0 -6
@@ -903,12 +903,6 @@ static void nfs_pageio_cleanup_mirroring(struct nfs_pageio_descriptor *pgio) pgio->pg_mirrors_dynamic =NULL ; } -static bool nfs_match_open_context (const struct nfs_open_context *ctx1, -const struct nfs_open_context *ctx2) -{ -return ctx1->cred == ctx2->cred && ctx1->state == ctx2->state; -} -static bool nfs_match_lock_context (const struct nfs_lock_context *l1,const struct nfs_lock_context *l2) {
fs/nfs/write.c +2 -1
@@ -1130,7 +1130,8 @@ int nfs_flush_incompatible(struct file *file, struct page *page)if (req ==NULL )return 0 ; l_ctx = req->wb_lock_context; - do_flush = req->wb_page != page || req->wb_context != ctx; + do_flush = req->wb_page != page || + !nfs_match_open_context (req->wb_context, ctx);/* for now, flush if more than 1 request in page_group */ do_flush |= req->wb_this_page != req; if (l_ctx && flctx &&
Signature · 1 line
2.5.0