Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp769765ybc; Sat, 16 Nov 2019 08:22:37 -0800 (PST) X-Google-Smtp-Source: APXvYqw0RwEMkRN+ZfDU3g5oKcxr3x4n7/e3M83OXKS/CQCN0Ih9Rj60hUYj3EIAy7dhffob8y+U X-Received: by 2002:a17:906:6d05:: with SMTP id m5mr10919438ejr.102.1573921357877; Sat, 16 Nov 2019 08:22:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921357; cv=none; d=google.com; s=arc-20160816; b=R+CbiYu50lrhrtwoOqoze3DZEPdvxVX2UDYPK8hhYRrzBoJDdLEYdf9Jo1A4Ol7jEU MqKEnaOByh0OqUkjK8v4ZzmJcHE4uNg9dH5zXEVtzLuV23y00U3bqvUUtoa99UoSRDai CeCNHXMFObKVFuNYv/sk1ECCJIqbFkunbgrqQgAKpvtN4sZUQ6SUbcC7YuKFxhuj0QKD /sEokSbHrkY6AVgd+x9yLR7ljlNeBOvBCV53E+U8B+Gz1UP3HeEbyXg/jbw751rNThIu EOViH+u0FxKKwpJhBIP5ihCs0QY8Y+VXgXeuyJvEdFh8oGKBpndh3lQ9afTHTSUV1T5J z91g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4bmdzk5bJfBPB/KIkaGbUABTorz/5wOCcVOwE9gq/nk=; b=e8ToemiE4biPqnsRKdjUn/zYAkr2FtBgTSRKgJq3jODZ3VfPeYkbs/bAJufVO4KIC4 l6zqSpBFrjoO1l/3bt6SeaGpdKfmZZ3p3c0k0da6/aKdJkEN6o6s1RWlYVTJpceeLvqr ZTuuZV6AtwSGrxJklG00ry6cuBlORIOeI2RfyDaZFbMgGoECnuYlcPSDJBpAPKysCz4s gOnz7x2jx3pGIYMu/UEXV/csISQEZiOJfMaRrxwsOgBW+136MitZ9WkK9mnMCH/3P9dl gjqVnhnjcDrzxvkP0MTlKTpDXdPfrwxOn7iMQ8/Cs2xDgTyqZljDZJCEZU2C8++7igsC bW+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zTZr9xYN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p21si9216950edc.305.2019.11.16.08.22.13; Sat, 16 Nov 2019 08:22:37 -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=zTZr9xYN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729443AbfKPPqg (ORCPT + 99 others); Sat, 16 Nov 2019 10:46:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:52360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728592AbfKPPqK (ORCPT ); Sat, 16 Nov 2019 10:46:10 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5A4112083B; Sat, 16 Nov 2019 15:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919169; bh=9LCI/pUJ619qOl/wn7bYyo2lDa06P71DoVqYJwBe8X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zTZr9xYNGgbNWFsO3FrBIWd8hxitd0JTSxp2ZvBhBl4EU4u7bz9mTLE1YES3Wwgqa xK2rnfaKsj5CrGE5R+m1ZsmS/OhYsLuCoqD12JCUOJ0r2uYGFJp8Di9huLIYe2Zjp6 Xr+StaHp+hfS3r5P+jYOSE0EJ7vU5fsz3ixjZcA0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Guozhonghua , Jan Kara , Mark Fasheh , Joel Becker , Junxiao Bi , Joseph Qi , Changwei Ge , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL 4.19 179/237] ocfs2: without quota support, avoid calling quota recovery Date: Sat, 16 Nov 2019 10:40:14 -0500 Message-Id: <20191116154113.7417-179-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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