[rh7,1/2] mm/tcache: Reset index before repeating invalidation

Submitted by Andrey Ryabinin on Feb. 28, 2018, 3:01 p.m.

Details

Message ID 20180228150154.17587-1-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin Feb. 28, 2018, 3:01 p.m.
Commit 25176cdcdcc0 ("tcache: Fix race between tcache_invalidate_node()
	and tcache_attach_page()")
removed reseting index before repeating invalidation. Essentially this
broke repeat logic entirely as we retry invalidation past the end of
the file.

Reset index to zero before invalidation retry.

https://jira.sw.ru/browse/PSBM-81760
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/tcache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/tcache.c b/mm/tcache.c
index 6e0c10dd3339..31a9eb3d1e12 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -918,7 +918,7 @@  tcache_invalidate_node_pages(struct tcache_node *node)
 	bool repeat, synchronize_sched_once = true;
 	pgoff_t indices[TCACHE_PAGEVEC_SIZE];
 	struct page *pages[TCACHE_PAGEVEC_SIZE];
-	pgoff_t index = 0;
+	pgoff_t index;
 	unsigned nr_pages;
 	int i;
 
@@ -926,6 +926,7 @@  tcache_invalidate_node_pages(struct tcache_node *node)
 	 * First forbid new page insertions - see tcache_page_tree_replace.
 	 */
 again:
+	index = 0;
 	repeat = false;
 	while ((nr_pages = tcache_lookup(pages, node, index,
 						TCACHE_PAGEVEC_SIZE, indices))) {

Comments

Kirill Tkhai Feb. 28, 2018, 4:06 p.m.
On 28.02.2018 18:01, Andrey Ryabinin wrote:
> Commit 25176cdcdcc0 ("tcache: Fix race between tcache_invalidate_node()
> 	and tcache_attach_page()")
> removed reseting index before repeating invalidation. Essentially this
> broke repeat logic entirely as we retry invalidation past the end of
> the file.
> 
> Reset index to zero before invalidation retry.
> 
> https://jira.sw.ru/browse/PSBM-81760
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

Acked-by: Kirill Tkhai <ktkhai@virtuozzo.com>

> ---
>  mm/tcache.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/tcache.c b/mm/tcache.c
> index 6e0c10dd3339..31a9eb3d1e12 100644
> --- a/mm/tcache.c
> +++ b/mm/tcache.c
> @@ -918,7 +918,7 @@ tcache_invalidate_node_pages(struct tcache_node *node)
>  	bool repeat, synchronize_sched_once = true;
>  	pgoff_t indices[TCACHE_PAGEVEC_SIZE];
>  	struct page *pages[TCACHE_PAGEVEC_SIZE];
> -	pgoff_t index = 0;
> +	pgoff_t index;
>  	unsigned nr_pages;
>  	int i;
>  
> @@ -926,6 +926,7 @@ tcache_invalidate_node_pages(struct tcache_node *node)
>  	 * First forbid new page insertions - see tcache_page_tree_replace.
>  	 */
>  again:
> +	index = 0;
>  	repeat = false;
>  	while ((nr_pages = tcache_lookup(pages, node, index,
>  						TCACHE_PAGEVEC_SIZE, indices))) {
>