Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2453445imm; Mon, 28 May 2018 08:21:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoFtMNc1tfi39kRn9We4hJ5+m8yjhL90S+buFW1+2ynodz9gx2917J9LvzA44v7IW84KauG X-Received: by 2002:a65:62c5:: with SMTP id m5-v6mr11019697pgv.13.1527520882447; Mon, 28 May 2018 08:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527520882; cv=none; d=google.com; s=arc-20160816; b=z3GQg4VVqCHgr8ILxxl/jPFjmjWCwtwddkMiT8PmW3ep+R0Oae2RviByjXJf+T7SFg DhYGn3KpRLdtWBb5CFHLFzgmYODxrUaiUCe7blRpQ55Dk1SHQRqlBIZPNu7pgCT4SdDk 9T1JHHLqJSnOrvOD14Q79yKCstE0aKqJXQ77KIXS6dbwpA76ECzW05Gok7Vbo1OEJQAr 0VeFlYyvjzp7IcOSkU5xcMUbIs6qsmyOiP9pTKRbOt+nRUAvTm0Cdj4zW73Q9YaerMf9 Tfj5KjpEryCNkLWhPiRFMyeZHvj+QfA/0bBB71iXfHPqid0LtHnypoG+8+5abKOCRgqR NHdw== 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=AUWUW9fSNagU0YhLzkujFMyRmTBwH4v3PTE29sCx65U=; b=m8fRm16IiDN2bZbWBQPGR0XD/6/iOG8BEeKyeB8ENY5RlEQDa66Fmw+Xf9scXf6a2t g0r/tD6ZiiEgK/GT87dvt/6bzD+Ta3IlqGFgMy6X3fs+O/aepJpJygvZBEyqKjdohzac 7xdt9IbmSTgToP65IhTazOxii/gnq81o7obJN5yJ7svuJOL8UkrIytE+0bN5kHoyjwJS oN/FlaPL7ITnW/JsoEI63xJgIhUBqd1Rvb9XkEDPb3DQxG0z3avpgobm//T6MLat6SSu 1KXVfNH56YdXocLPDn3dwi+kpei3KTcFApXHyPaT0YABiZjsd9QU3boXu+qCtbVphEsH bx/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SEfQcwZX; 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 ay10-v6si30234144plb.120.2018.05.28.08.21.07; Mon, 28 May 2018 08:21:22 -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=SEfQcwZX; 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 S1033445AbeE1PTY (ORCPT + 99 others); Mon, 28 May 2018 11:19:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:41412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033421AbeE1KV6 (ORCPT ); Mon, 28 May 2018 06:21:58 -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 59A6920899; Mon, 28 May 2018 10:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502917; bh=iH4sPE8itHiMC72B3rcRhq7WWpWg4b0TIAMUjdjrftw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SEfQcwZXxH9kz3QNaihu4ndWBGmeMTZMEKdAZfIg6yTFa5FiThQxzg1yxUJNPJpOm 7oysUsrVbG/4BnfhNITkNhOJTdL/bdlkyMhzwNyFQYPcKY/4z0vd2639ZljbIRsKI0 ZJF+cwIYfmLE6fFDLGXKnrNwxVmOAxfHebKrWI/Y= 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.4 175/268] fscache: Fix hanging wait on page discarded by writeback Date: Mon, 28 May 2018 12:02:29 +0200 Message-Id: <20180528100222.193590780@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@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.4-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 */