Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6015126ybc; Wed, 27 Nov 2019 13:26:01 -0800 (PST) X-Google-Smtp-Source: APXvYqz9TtHELN5TXeEb0VI93IC+JzNCo73PibsXZAcWUYm5VXrCE4jecrCFeaj2Hkpcu2AcuTsG X-Received: by 2002:aa7:d356:: with SMTP id m22mr33696498edr.170.1574889961564; Wed, 27 Nov 2019 13:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574889961; cv=none; d=google.com; s=arc-20160816; b=ozDZsMJHGl5xJsajrqG+irjrQtijVfumNJL0CQSd7JcO6Kx5W1tTWDvfTFVXaVTj7/ z0zUEj6jqgd0Lcw9IGAuveH5V374NfId4d6gW5lTqSrIikvFmmDK++YkYu6w+FT65qmn svfi6diB5rw+7nlpZ5oS7aQt6O071xI1sjEhdertlwtb8YYfWteyKFAeAKwZJHd21q6w GLanzOK7UjpV2rM2rsSyUSrRfEjYeb7VUrLGUrZYg7JirUVh+/syDwRAnoc27Gz4/iC/ +nnmqgxKXRqKtHChmER2WwLRIik5V5tWnitYDyTxrC71VumdALoEj3wrGA4d/x0LnfDd cbOA== 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=4bmdzk5bJfBPB/KIkaGbUABTorz/5wOCcVOwE9gq/nk=; b=XseVN9yBk/pEiDZF02uphLgF3lxwhkiMYvDA5WlwMi1uUnfyB+P3oStpw18kl9QMqT XGBp0ZgbjZ/v27lS0RtN8PTgFf5XBnT7TG/AzyxPPdU88MmK35ZqxB78XLPHJPIhBXVD AoPAfQGmcX3L1FWs6sxtJTqkZo6Ikx2mH++Ebkxk0IMx9gifQXrlvP0CvcTzM+lEC1Ta hznwGxbkT4QvpoBV2lJjlsNC1Basr9h0Q4LmdLEH7v3hwsuExXqecV9r4onZK56brQp1 riNMcBZKVY4eNHPkF7i1wrI+qoRp2p4iFwy02U0R1IYNWG8pkq7XAJNu+Rq4l3l/Z17x NsvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jIxyiYL1; 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 m9si10622180eds.14.2019.11.27.13.25.38; Wed, 27 Nov 2019 13:26:01 -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=jIxyiYL1; 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 S1732248AbfK0VFN (ORCPT + 99 others); Wed, 27 Nov 2019 16:05:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:58818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732249AbfK0VFK (ORCPT ); Wed, 27 Nov 2019 16:05:10 -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 C3ACF2166E; Wed, 27 Nov 2019 21:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888709; bh=9LCI/pUJ619qOl/wn7bYyo2lDa06P71DoVqYJwBe8X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jIxyiYL1MWVI8XG54nZJA01ZbelD6C+fLettgo2TmiSeMvA0GxHOm0O44asNbIGwb nFBG+6lsIoS7kyCEJbOX8+Sx0IqnMSjrao7vdDMHCw7k1Cw/6i9Hlojw0H9BtNIIil CpDrlQIN/Em4cJxDr2v5JHHpI50bF5Bm8XoidN1k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, guozhonghua , Jan Kara , Mark Fasheh , Joel Becker , Junxiao Bi , Joseph Qi , Changwei Ge , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 196/306] ocfs2: without quota support, avoid calling quota recovery Date: Wed, 27 Nov 2019 21:30:46 +0100 Message-Id: <20191127203129.508092540@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@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: Guozhonghua [ Upstream commit 21158ca85b73ddd0088076a5209cfd040513a8b5 ] During one dead node's recovery by other node, quota recovery work will be queued. We should avoid calling quota when it is not supported, so check the quota flags. Link: http://lkml.kernel.org/r/71604351584F6A4EBAE558C676F37CA401071AC9FB@H3CMLB12-EX.srv.huawei-3com.com Signed-off-by: guozhonghua Reviewed-by: Jan Kara Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Joseph Qi Cc: Changwei Ge Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/journal.c | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index c492cbb2410f6..babb0ec76d676 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -1379,15 +1379,23 @@ static int __ocfs2_recovery_thread(void *arg) int rm_quota_used = 0, i; struct ocfs2_quota_recovery *qrec; + /* Whether the quota supported. */ + int quota_enabled = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, + OCFS2_FEATURE_RO_COMPAT_USRQUOTA) + || OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, + OCFS2_FEATURE_RO_COMPAT_GRPQUOTA); + status = ocfs2_wait_on_mount(osb); if (status < 0) { goto bail; } - rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS); - if (!rm_quota) { - status = -ENOMEM; - goto bail; + if (quota_enabled) { + rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS); + if (!rm_quota) { + status = -ENOMEM; + goto bail; + } } restart: status = ocfs2_super_lock(osb, 1); @@ -1423,9 +1431,14 @@ static int __ocfs2_recovery_thread(void *arg) * then quota usage would be out of sync until some node takes * the slot. So we remember which nodes need quota recovery * and when everything else is done, we recover quotas. */ - for (i = 0; i < rm_quota_used && rm_quota[i] != slot_num; i++); - if (i == rm_quota_used) - rm_quota[rm_quota_used++] = slot_num; + if (quota_enabled) { + for (i = 0; i < rm_quota_used + && rm_quota[i] != slot_num; i++) + ; + + if (i == rm_quota_used) + rm_quota[rm_quota_used++] = slot_num; + } status = ocfs2_recover_node(osb, node_num, slot_num); skip_recovery: @@ -1453,16 +1466,19 @@ static int __ocfs2_recovery_thread(void *arg) /* Now it is right time to recover quotas... We have to do this under * superblock lock so that no one can start using the slot (and crash) * before we recover it */ - for (i = 0; i < rm_quota_used; i++) { - qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]); - if (IS_ERR(qrec)) { - status = PTR_ERR(qrec); - mlog_errno(status); - continue; + if (quota_enabled) { + for (i = 0; i < rm_quota_used; i++) { + qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]); + if (IS_ERR(qrec)) { + status = PTR_ERR(qrec); + mlog_errno(status); + continue; + } + ocfs2_queue_recovery_completion(osb->journal, + rm_quota[i], + NULL, NULL, qrec, + ORPHAN_NEED_TRUNCATE); } - ocfs2_queue_recovery_completion(osb->journal, rm_quota[i], - NULL, NULL, qrec, - ORPHAN_NEED_TRUNCATE); } ocfs2_super_unlock(osb, 1); @@ -1484,7 +1500,8 @@ static int __ocfs2_recovery_thread(void *arg) mutex_unlock(&osb->recovery_lock); - kfree(rm_quota); + if (quota_enabled) + kfree(rm_quota); /* no one is callint kthread_stop() for us so the kthread() api * requires that we call do_exit(). And it isn't exported, but -- 2.20.1