Improvements to page writeback commit policy
Subsystems (2)
cover Improvements to page writeback commit policy
The following patches are intended to smooth out the page writeback performance by ensuring that we commit the data earlier on the server.
We assume that if something is starting writeback on the pages, then that process wants to commit the data as soon as possible, whether it is an application or just the background flush process.
We also assume that for streaming type processes, we don't want to pause the I/O in order to commit, so we don't want to rely on a counter of in-flight I/O to the entire inode going to zero.
We therefore set up a monitor that counts the number of in-flight writes for each call to nfs_writepages(). Once all the writes to that call to nfs_writepages has completed, we send the commit. Note that this mirrors the behaviour for O_DIRECT writes, where we similarly track the in-flight writes on a per-call basis.
Trond Myklebust (3):
NFS: Remove unused fields in the page I/O structures
NFS: Ensure we commit after writeback is complete
NFS: Fix commit policy for non-blocking calls to nfs_write_inode()
fs/nfs/pagelist.c | 5 ++-- fs/nfs/write.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++- include/linux/nfs_page.h | 2 +- include/linux/nfs_xdr.h | 3 ++- 4 files changed, 64 insertions(+), 5 deletions(-)
Signature · 1 line
2.9.4
PATCH 1/3 NFS: Remove unused fields in the page I/O structures
Remove the 'layout_private' fields that were only used by the pNFS OSD layout driver.
--- fs/nfs/pagelist.c | 2 -- include/linux/nfs_page.h | 1 - include/linux/nfs_xdr.h | 1 - 3 files changed, 4 deletions(-)
fs/nfs/pagelist.c +0 -2
@@ -51,7 +51,6 @@ void nfs_pgheader_init(struct nfs_pageio_descriptor *desc, hdr->io_start =req_offset (hdr->req); hdr->good_bytes = mirror->pg_count; hdr->dreq = desc->pg_dreq; - hdr->layout_private = desc->pg_layout_private; hdr->release = release; hdr->completion_ops = desc->pg_completion_ops;if (hdr->completion_ops->init_hdr)
@@ -711,7 +710,6 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc, desc->pg_error =0 ; desc->pg_lseg =NULL ; desc->pg_dreq =NULL ; - desc->pg_layout_private =NULL ; desc->pg_bsize = bsize; desc->pg_mirror_count =1 ;
include/linux/nfs_page.h +0 -1
@@ -94,7 +94,6 @@ struct nfs_pageio_descriptor {const struct nfs_pgio_completion_ops *pg_completion_ops;struct pnfs_layout_segment *pg_lseg;struct nfs_direct_req *pg_dreq; -void *pg_layout_private;unsigned int pg_bsize;/* default bsize for mirrors */ u32 pg_mirror_count;
include/linux/nfs_xdr.h +0 -1
@@ -1436,7 +1436,6 @@ struct nfs_pgio_header {const struct nfs_pgio_completion_ops *completion_ops;const struct nfs_rw_ops *rw_ops;struct nfs_direct_req *dreq; -void *layout_private;spinlock_t lock;/* fields protected by lock */ int pnfs_error;
Signature · 1 line
2.9.4
PATCH 2/3 NFS: Ensure we commit after writeback is complete
If the page cache is being flushed, then we want to ensure that we do start a commit once the pages are done being flushed. If we just wait until all I/O is done to that file, we can end up livelocking until the balance_dirty_pages() mechanism puts its foot down and forces I/O to stop.
So instead we do more or less the same thing that O_DIRECT does, and set up a counter to tell us when the flush is done,
--- fs/nfs/pagelist.c | 3 +++ fs/nfs/write.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/nfs_page.h | 1 + include/linux/nfs_xdr.h | 2 ++ 4 files changed, 63 insertions(+)
fs/nfs/pagelist.c +3 -0
@@ -50,6 +50,7 @@ void nfs_pgheader_init(struct nfs_pageio_descriptor *desc, hdr->cred = hdr->req->wb_context->cred; hdr->io_start =req_offset (hdr->req); hdr->good_bytes = mirror->pg_count; + hdr->io_completion = desc->pg_io_completion; hdr->dreq = desc->pg_dreq; hdr->release = release; hdr->completion_ops = desc->pg_completion_ops;
@@ -709,6 +710,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc, desc->pg_ioflags = io_flags; desc->pg_error =0 ; desc->pg_lseg =NULL ; + desc->pg_io_completion =NULL ; desc->pg_dreq =NULL ; desc->pg_bsize = bsize;
@@ -1231,6 +1233,7 @@ int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, {LIST_HEAD (failed); + desc->pg_io_completion = hdr->io_completion; desc->pg_dreq = hdr->dreq;while (!list_empty (&hdr->pages)) {struct nfs_page *req =nfs_list_entry (hdr->pages.next);
fs/nfs/write.c +57 -0
105 lines not on this page · raw message
include/linux/nfs_page.h +1 -0
@@ -93,6 +93,7 @@ struct nfs_pageio_descriptor {const struct rpc_call_ops *pg_rpc_callops;const struct nfs_pgio_completion_ops *pg_completion_ops;struct pnfs_layout_segment *pg_lseg; +struct nfs_io_completion *pg_io_completion;struct nfs_direct_req *pg_dreq;unsigned int pg_bsize;/* default bsize for mirrors */
include/linux/nfs_xdr.h +2 -0
@@ -1422,6 +1422,7 @@ enum { NFS_IOHDR_STAT, }; +struct nfs_io_completion ;struct nfs_pgio_header {struct inode *inode;struct rpc_cred *cred;
@@ -1435,6 +1436,7 @@ struct nfs_pgio_header {void (*release) (struct nfs_pgio_header *hdr);const struct nfs_pgio_completion_ops *completion_ops;const struct nfs_rw_ops *rw_ops; +struct nfs_io_completion *io_completion;struct nfs_direct_req *dreq;spinlock_t lock;/* fields protected by lock */
Signature · 1 line
2.9.4
PATCH 3/3 NFS: Fix commit policy for non-blocking calls to nfs_write_inode()
Now that the writes will schedule a commit on their own, we don't need nfs_write_inode() to schedule one if there are outstanding writes, and we're being called in non-blocking mode.
--- fs/nfs/write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/write.c +1 -1
@@ -1941,7 +1941,7 @@ int nfs_write_inode(struct inode *inode, struct writeback_control *wbc)/* Don't commit yet if this is a non-blocking flush and there * are a lot of outstanding writes for this mapping. */ -if (nfsi->commit_info.ncommit <= (nfsi->nrequests >>1 )) +if (mapping_tagged (inode->i_mapping,PAGECACHE_TAG_WRITEBACK )) goto out_mark_dirty;/* don't wait for the COMMIT response */
Signature · 1 line
2.9.4