[Devel,RHEL7,COMMIT] fs: avoid writeback busy-loop if redirty

Submitted by Konstantin Khorenko on Dec. 20, 2016, 10:43 a.m.

Details

Message ID 201612201043.uBKAhLBd032362@finist_cl7.x64_64.work.ct
State New
Series "fs: avoid writeback busy-loop if redirty"
Headers show

Commit Message

Konstantin Khorenko Dec. 20, 2016, 10:43 a.m.
The commit is pushed to "branch-rh7-3.10.0-327.36.1.vz7.20.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.36.1.vz7.20.17
------>
commit 800275212f6dc5447ceb8023ce3b7ec663d45b20
Author: Maxim Patlasov <mpatlasov@virtuozzo.com>
Date:   Tue Dec 20 14:43:21 2016 +0400

    fs: avoid writeback busy-loop if redirty
    
    wb_writeback() bails out only if either nr_pages comes to zero or
    "progress" (as reported by writeback_sb_inodes or __writeback_inodes_wb)
    is zero.
    
    If a page is temporarily unavailable (is under fuse-writeback),
    fuse_writepages_fill calls redirty_page_for_writepage, unlock the page
    and returns OK. This OK results in progress=1. So wb_writeback
    loops over writeback_sb_inodes/__writeback_inodes_wb again and again
    until all nr_pages are exhausted.
    
    The patch ensures that progress=0 if fuse_writepages_fill did nothing.
    
    Might be in charge of https://jira.sw.ru/browse/PSBM-55919
    
    Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
    
    khorenko@: s/BUG_ON/WARN_ON/
    If we face this warn_on, we enable "kernel.panic_on_warn" on
    nodes which trigger it.
---
 fs/fs-writeback.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 5c9a082..5948ce4 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -774,6 +774,9 @@  static long writeback_sb_inodes(struct super_block *sb,
 			if (work->nr_pages <= 0)
 				break;
 		}
+
+		WARN_ON(wbc.pages_skipped > write_chunk - wbc.nr_to_write);
+		wrote -= wbc.pages_skipped;
 	}
 	return wrote;
 }

Comments

Konstantin Khorenko Dec. 20, 2016, 10:49 a.m.
Please consider to release a ReadyKernel live patch for it.

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 12/20/2016 01:43 PM, Konstantin Khorenko wrote:
> The commit is pushed to "branch-rh7-3.10.0-327.36.1.vz7.20.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
> after rh7-3.10.0-327.36.1.vz7.20.17
> ------>
> commit 800275212f6dc5447ceb8023ce3b7ec663d45b20
> Author: Maxim Patlasov <mpatlasov@virtuozzo.com>
> Date:   Tue Dec 20 14:43:21 2016 +0400
>
>     fs: avoid writeback busy-loop if redirty
>
>     wb_writeback() bails out only if either nr_pages comes to zero or
>     "progress" (as reported by writeback_sb_inodes or __writeback_inodes_wb)
>     is zero.
>
>     If a page is temporarily unavailable (is under fuse-writeback),
>     fuse_writepages_fill calls redirty_page_for_writepage, unlock the page
>     and returns OK. This OK results in progress=1. So wb_writeback
>     loops over writeback_sb_inodes/__writeback_inodes_wb again and again
>     until all nr_pages are exhausted.
>
>     The patch ensures that progress=0 if fuse_writepages_fill did nothing.
>
>     Might be in charge of https://jira.sw.ru/browse/PSBM-55919
>
>     Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
>
>     khorenko@: s/BUG_ON/WARN_ON/
>     If we face this warn_on, we enable "kernel.panic_on_warn" on
>     nodes which trigger it.
> ---
>  fs/fs-writeback.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 5c9a082..5948ce4 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -774,6 +774,9 @@ static long writeback_sb_inodes(struct super_block *sb,
>  			if (work->nr_pages <= 0)
>  				break;
>  		}
> +
> +		WARN_ON(wbc.pages_skipped > write_chunk - wbc.nr_to_write);
> +		wrote -= wbc.pages_skipped;
>  	}
>  	return wrote;
>  }
> .
>