Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2218969imm; Mon, 28 May 2018 04:10:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr4q3zuDLXY3il3LUUCCfSxRV93df1M/jMMTd3xul4PtXagLEVg0aNNF65zTC+/bL4nnjJ+ X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr12895666pla.88.1527505829612; Mon, 28 May 2018 04:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527505829; cv=none; d=google.com; s=arc-20160816; b=diq/tl7NXybiOZsWNFSLwZEFRmbS3BzT2cnrB20bceWsid+fp6G9oAIkheDXyg2A35 RMQL/EqC54U+I1o7bUFyneKzhejPqDhdrQ0vOQ9z3ciaciB99wjQ4nd0D9aSn9T+9ubq FFAftOXYAoqi1tgqpOhPoPneooNndljeGQT4TwNb0985ceKNvgSxbCaKT9G/kYJvN/Xs dRaRPENNfsi5q2Q2eOB/WlobEuaTEI18AgzakZz+PJPPIb8T2u8hVbmEMjC7P3ZSzdmP TUHEwLwzCKb5nOF5VrbZGY4avaegL1kRDLXZGPVWjIgIaIFxEDVA3SB9s5dCZinIrbX+ j/Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=lwOF7MRzoCLhpVNiC4mwLdeCkar4zR5sr28xVpkRwXw=; b=lONPUiWMdjC2bIvSRhfrKSJEJh//L0YhY7Vwc8km43cpZq2AM5Cu3xxdW8FgZ09Znu 7uQULMSx5pnFJuHMzDhYHZel45cBVLx/4qd78Vam/cnmyta4MCV3KU4POmGCJ3jieI3N 2BvaxJdTGOBZBHnj+FvsyQTFrYg/mYTND85D/Xjdtpcggb6V7YnuVX6W4NpBd4UccpOf wFvy2zBA/6CwTSCzlXWPXUnF9tXgrT2YPXO82hTbNRjpaUfxFskQoKSZxNbCFyoQ7Tvd BiODa03TzmjGO2rgYuZG9ZP8sJqnnpnd4kDqVbSxIV2gvmRabq0cHD2IP/jINTLjgUuG rsvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=feBqYCOY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12-v6si29685821pla.194.2018.05.28.04.10.14; Mon, 28 May 2018 04:10:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=feBqYCOY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423569AbeE1LIT (ORCPT + 99 others); Mon, 28 May 2018 07:08:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:55148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423503AbeE1LH5 (ORCPT ); Mon, 28 May 2018 07:07:57 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E2172206B7; Mon, 28 May 2018 11:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505676; bh=cCOc1K0Mr3DXNDfDrrD4ejciSJB0FJyXDqyWF9fDwC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=feBqYCOY10ul5NLwHf+aaDoaRfX43yRzD556IOSMl/9AMwI6KY2wHcYvRYBtiOHGu C/wk6St8i0Y9ztOCkF2g8oYT4zSNSDBvx4mMZiaJPgPnxbODMiuQ2TROabFAJl63yS hI8vFB0OhqpTS2k/lg3DchiZnSV9Bcz0KkVAdC2A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Sasha Levin Subject: [PATCH 4.16 081/272] fscache: Fix hanging wait on page discarded by writeback Date: Mon, 28 May 2018 12:01:54 +0200 Message-Id: <20180528100247.947838077@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Howells [ Upstream commit 2c98425720233ae3e135add0c7e869b32913502f ] If the fscache asynchronous write operation elects to discard a page that's pending storage to the cache because the page would be over the store limit then it needs to wake the page as someone may be waiting on completion of the write. The problem is that the store limit may be updated by a different asynchronous operation - and so may miss the write - and that the store limit may not even get updated until later by the netfs. Fix the kernel hang by making fscache_write_op() mark as written any pages that are over the limit. Signed-off-by: David Howells Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/fscache/page.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/fs/fscache/page.c +++ b/fs/fscache/page.c @@ -776,6 +776,7 @@ static void fscache_write_op(struct fsca _enter("{OP%x,%d}", op->op.debug_id, atomic_read(&op->op.usage)); +again: spin_lock(&object->lock); cookie = object->cookie; @@ -816,10 +817,6 @@ static void fscache_write_op(struct fsca goto superseded; page = results[0]; _debug("gang %d [%lx]", n, page->index); - if (page->index >= op->store_limit) { - fscache_stat(&fscache_n_store_pages_over_limit); - goto superseded; - } radix_tree_tag_set(&cookie->stores, page->index, FSCACHE_COOKIE_STORING_TAG); @@ -829,6 +826,9 @@ static void fscache_write_op(struct fsca spin_unlock(&cookie->stores_lock); spin_unlock(&object->lock); + if (page->index >= op->store_limit) + goto discard_page; + fscache_stat(&fscache_n_store_pages); fscache_stat(&fscache_n_cop_write_page); ret = object->cache->ops->write_page(op, page); @@ -844,6 +844,11 @@ static void fscache_write_op(struct fsca _leave(""); return; +discard_page: + fscache_stat(&fscache_n_store_pages_over_limit); + fscache_end_page_write(object, page); + goto again; + superseded: /* this writer is going away and there aren't any more things to * write */