Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2298845ybl; Thu, 19 Dec 2019 11:12:07 -0800 (PST) X-Google-Smtp-Source: APXvYqzm/Gb5vxgKBR0I/L9Tpz+fDNKf41QEqxx5UzEeLsNYMEbFrbagpflal5Glv394xA+PjEO1 X-Received: by 2002:aca:4183:: with SMTP id o125mr2779684oia.125.1576782727822; Thu, 19 Dec 2019 11:12:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576782727; cv=none; d=google.com; s=arc-20160816; b=1EqYGwOe4eOtwd+D57b+QsHpezmTL5dwPs5shDTqALE/9RS9LYX6BR086qg5iuPd/F qYhHoNzpwgQbQPGv763NDwQNV5X5bVdWbXJKEWdYs13LaQJBsmlZBORxojAlTlQpJeaA FUDVgaoX5xubZD9gHUwQjYdA5d35mVDYWeulvxEVyspBZq4gLoBIBDkl4S/3Ay6zmB3S mp2YwVeFvAJo4dPqLsr4T9/FtW2Xf3fqTZGkKQRLEUuppjTzS6m+6edYaFPIy4gKyYnd ENdiikOS5QDnsyoy3NHDICU32G63ATN+gL82hS75X/zpUrO6aOzIBqYq8JV0DcP+/upT 4Byg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6qP3aXEP8WiOPHeMdDZ02duZYhVO659aN+0InV4f7Sk=; b=echwsV5fXDZviT7os5lMftrS1UHMVWxaKTzX8eqtrR5AvXIgMjT2n23tH9TdWsX13P nwlSkOflZckxwH3rxiW3rWWaZtVPSWHS6fW0xowyWY3p2HwmR3rxS6BkAy6YtJGu/B4t TQN6EbR/ppt3Qo1vOSfQFXEf6N4XI1OCBZznu/UY9uyW3XIWIFhXNHDhLBg3SNCyu4vC O1pLtIMnJs+TWKqckfti9rxEdbhb+MsFnC7ubtzNg8Zjk4W47cf39JBevFYURcW3iogU eVoElRdDg+BePMsrm+LJUUzQwE9kmO7lvelh2tCtPo2ZOSseIJp4CGtphUbtNgyX3IIg Hd+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bHFuEOdU; 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 e190si2839791oib.113.2019.12.19.11.11.53; Thu, 19 Dec 2019 11:12:07 -0800 (PST) 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=bHFuEOdU; 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 S1728315AbfLSSj7 (ORCPT + 99 others); Thu, 19 Dec 2019 13:39:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:58538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbfLSSj6 (ORCPT ); Thu, 19 Dec 2019 13:39:58 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 A86EA206D7; Thu, 19 Dec 2019 18:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576780797; bh=BiT/mqY3cYPx4Ex65wi0uSHH0MprkirSenCtSPsYEGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bHFuEOdU+qn6lnX+yQCRIpvJUFWnDJM27+8w/xaD7JBS8cNX0vY+4hOVfWic84RPF iDkrpj5tTqCX8zgqutwmPPeuwhFn3ePO0ACDFTRW602uAU8v5f2mLxQDYgBTuNjCUs 03vtqyLM/u0GdJMUbzuhK2PXRzGeKr4MGOwfi0MM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konstantin Khlebnikov , Dmitry Monakhov , Jan Kara Subject: [PATCH 4.4 122/162] quota: fix livelock in dquot_writeback_dquots Date: Thu, 19 Dec 2019 19:33:50 +0100 Message-Id: <20191219183215.195885197@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183150.477687052@linuxfoundation.org> References: <20191219183150.477687052@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Monakhov commit 6ff33d99fc5c96797103b48b7b0902c296f09c05 upstream. Write only quotas which are dirty at entry. XFSTEST: https://github.com/dmonakhov/xfstests/commit/b10ad23566a5bf75832a6f500e1236084083cddc Link: https://lore.kernel.org/r/20191031103920.3919-1-dmonakhov@openvz.org CC: stable@vger.kernel.org Signed-off-by: Konstantin Khlebnikov Signed-off-by: Dmitry Monakhov Signed-off-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- fs/quota/dquot.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -604,7 +604,7 @@ EXPORT_SYMBOL(dquot_scan_active); /* Write all dquot structures to quota files */ int dquot_writeback_dquots(struct super_block *sb, int type) { - struct list_head *dirty; + struct list_head dirty; struct dquot *dquot; struct quota_info *dqopt = sb_dqopt(sb); int cnt; @@ -617,9 +617,10 @@ int dquot_writeback_dquots(struct super_ if (!sb_has_quota_active(sb, cnt)) continue; spin_lock(&dq_list_lock); - dirty = &dqopt->info[cnt].dqi_dirty_list; - while (!list_empty(dirty)) { - dquot = list_first_entry(dirty, struct dquot, + /* Move list away to avoid livelock. */ + list_replace_init(&dqopt->info[cnt].dqi_dirty_list, &dirty); + while (!list_empty(&dirty)) { + dquot = list_first_entry(&dirty, struct dquot, dq_dirty); /* Dirty and inactive can be only bad dquot... */ if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {