Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp631859pxk; Wed, 16 Sep 2020 12:47:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT2Aglo6a81ar3iEmXxbybqBRBTpBrAnO2Srdrag4HfJ0MXZ9CsP7iPsniGvi9XDWJM0k4 X-Received: by 2002:a17:906:37c6:: with SMTP id o6mr15768565ejc.404.1600285657424; Wed, 16 Sep 2020 12:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600285657; cv=none; d=google.com; s=arc-20160816; b=e8XwN3bntFOyMGuACqpboeQdYenc3vJmwZEgoFEV64nIK3BZwJoa4Ct6LpEiZqqzTE f4EbDvDnLPk1eI5dZRvSeTp4I4LOD20EKGCsW+BnZ07gOoVbWJZrrZwyeFPcimEKkzjT dE7oqVMzJetWuZ7WGq2vHzpYFIbOdABlyoFvPqMmIoLvFoVuK3XzcHdxZN1bdA/6yxQx UDvqo0YoGjPCNTiB+RoGtZVUoJ/ZFG1ovbW8FT7eZMweg0xPRI9sLjRAmHJFR+K+6ZVd 0QfLQt+0QeII4RkH18SjhFMEDcKmXBomT1KD/XD7Te3xvizne1l6B015sLov+JE5LMNI KJCw== 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; bh=4H8QaSeH7jZg38efTRSeSIlfkZDjWbgUbnDpYbK6+8k=; b=RkaSQ2VKkN8dCNqIbXsh3EzPjPBYjsRG04KirwYDU0kNqKe62VKlLpgI4Qn+pOrkYG 4EDOaDWu3hE66NN+AuszzPyRqgkYjXjsK86Vmp6x5hQY4IV2RRFYcx+IxM9kXdoWo8sn 4dM3Bnaiez9pcJBoTT+LKKuobbc2+oOO7PKjIv5PIjuicD+32zWLzox1QfvfxIlwtI12 GDqtHuPsMr7RaYE1/9aQNAU8EQSO05ysBJAtcTlehRrKnMcCtCuJyCf9yGT9V5WBx3ua U/67Faww7VjCktnCnUYpwASTM+Jb25z+wRevWl26IxdLphkYdVhEgxMu5uQFvZUQIAzd oXEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si13085643edw.559.2020.09.16.12.47.14; Wed, 16 Sep 2020 12:47:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728072AbgIPTrE (ORCPT + 99 others); Wed, 16 Sep 2020 15:47:04 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12764 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727293AbgIPTqg (ORCPT ); Wed, 16 Sep 2020 15:46:36 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 5BD98962B459673E09F4; Wed, 16 Sep 2020 19:37:57 +0800 (CST) Received: from huawei.com (10.175.127.227) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Wed, 16 Sep 2020 19:37:46 +0800 From: Ye Bin To: , , , , , CC: Ye Bin Subject: [PATCH v5 2/2] ext4: Fix dead loop in ext4_mb_new_blocks Date: Wed, 16 Sep 2020 19:38:59 +0800 Message-ID: <20200916113859.1556397-3-yebin10@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200916113859.1556397-1-yebin10@huawei.com> References: <20200916113859.1556397-1-yebin10@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-CFilter-Loop: Reflected Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org As we test disk offline/online with running fsstress, we find fsstress process is keeping running state. kworker/u32:3-262 [004] ...1 140.787471: ext4_mb_discard_preallocations: dev 8,32 needed 114 .... kworker/u32:3-262 [004] ...1 140.787471: ext4_mb_discard_preallocations: dev 8,32 needed 114 ext4_mb_new_blocks repeat: ext4_mb_discard_preallocations_should_retry(sb, ac, &seq) freed = ext4_mb_discard_preallocations ext4_mb_discard_group_preallocations this_cpu_inc(discard_pa_seq); ---> freed == 0 seq_retry = ext4_get_discard_pa_seq_sum for_each_possible_cpu(__cpu) __seq += per_cpu(discard_pa_seq, __cpu); if (seq_retry != *seq) { *seq = seq_retry; ret = true; } As we see seq_retry is sum of discard_pa_seq every cpu, if ext4_mb_discard_group_preallocations return zero discard_pa_seq in this cpu maybe increase one, so condition "seq_retry != *seq" have always been met. Ritesh Harjani suggest to in ext4_mb_discard_group_preallocations function we only increase discard_pa_seq when there is some PA to free. Fixes: 07b5b8e1ac40 ("ext4: mballoc: introduce pcpu seqcnt for freeing PA to improve ENOSPC handling") Signed-off-by: Ye Bin Reviewed-by: Jan Kara Reviewed-by: Ritesh Harjani --- fs/ext4/mballoc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index f736819a381b..4d40d8dc518c 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -4189,7 +4189,6 @@ ext4_mb_discard_group_preallocations(struct super_block *sb, INIT_LIST_HEAD(&list); repeat: ext4_lock_group(sb, group); - this_cpu_inc(discard_pa_seq); list_for_each_entry_safe(pa, tmp, &grp->bb_prealloc_list, pa_group_list) { spin_lock(&pa->pa_lock); @@ -4206,6 +4205,9 @@ ext4_mb_discard_group_preallocations(struct super_block *sb, /* seems this one can be freed ... */ ext4_mb_mark_pa_deleted(sb, pa); + if (!free) + this_cpu_inc(discard_pa_seq); + /* we can trust pa_free ... */ free += pa->pa_free; -- 2.25.4