Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp5295pxy; Wed, 21 Apr 2021 16:42:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn0LoPnMIeC917htO8vS7lXhpHViGw4ulAeMYN/FWw7Oywc8GW8+whnp6xjolbP4eevG9g X-Received: by 2002:a50:c004:: with SMTP id r4mr491726edb.192.1619048558207; Wed, 21 Apr 2021 16:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619048558; cv=none; d=google.com; s=arc-20160816; b=NsZ92VB5JHY99o2m6ALp9srqNykw3VGIQHnIKk2D+UYNvYH50P9eIz2JP9EbVumH9K kW3y/JzzATXOMtIFOGRC9kJY8C2rt55WOQJuXxxAY2gIj+n+xEJY3jPMvnu9101N3RiX k4pOd1JkI4qLYv6ncx/x0BbaijHFLfIAeuWA9G7nfglEawuWvj/MYLrQSyyknE0s6Nop a9TNs4vteCUhtjBZ5x2h+wFWqMsS/DAM6FxOoGrDKczUeShxIRx62zmeZCvIsKgSI2g1 Y8yRrXm8N6vxg7GCQsz1RBQfdxxa4KQxNMusFliyCjF7UZLbIQxcOmpA1IH35T9AvfB+ W/4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=y8u+SoT+9pZ8CC8dxqFvfu2twIVQ6VKqkbIsalZhcoM=; b=NhT3S8MpKUmIe3U7R29BgsJ6uw2iuCsDGKQPC9AjUz5v9Syfg4xoMc8QC29fWEYIi5 WWyHEXKUsAl1a2oCWE9HRWmcudCVfQYdaqi0BnrTeaQ+bk0JwjKkT7/0wUExAvrHxe7f EyTcyXFaVYx5Ng1WvY9wOq5wgp4/Y7L45nPA40X0sv9kru7HN6Gnkic4lqG7cK+vXma9 0G2ZsgNbKAmk1I6tcpsagHKRAxp3o4V9xrFLZLOwbMB7aRVZV8XzS0um/xCl6YkIEaVk VBNFwFJF5APcaA7VGT2whLiBdcoGldMmhNTOLRRm+Q0U/eh51MNUZZ8/s0NjeuNklQls QBnw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r13si670906ejx.27.2021.04.21.16.42.06; Wed, 21 Apr 2021 16:42:38 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235017AbhDUP4R (ORCPT + 99 others); Wed, 21 Apr 2021 11:56:17 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:10242 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235610AbhDUP4R (ORCPT ); Wed, 21 Apr 2021 11:56:17 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R581e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0UWK2NsT_1619020519; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0UWK2NsT_1619020519) by smtp.aliyun-inc.com(127.0.0.1); Wed, 21 Apr 2021 23:55:30 +0800 From: Wen Yang To: tytso@mit.edu, Andreas Dilger Cc: Wen Yang , Baoyou Xie , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs/ext4: remove redundant initialization of variable busy Date: Wed, 21 Apr 2021 23:54:55 +0800 Message-Id: <20210421155455.51725-1-wenyang@linux.alibaba.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org The variable status is being initialized with a value that is never read and it is being updated later with a new value. The initialization is redundant and could be removed. Also put the variable declarations into reverse christmas tree order. Finally, we add the log printing and ext4_mb_show_pa() for troubleshooting, they are enabled only when CONFIG_EXT4_DEBUG is set. Signed-off-by: Wen Yang Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Baoyou Xie Cc: linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs/ext4/mballoc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index a02fadf..1402b14 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -351,6 +351,8 @@ static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap, ext4_group_t group); static void ext4_mb_new_preallocation(struct ext4_allocation_context *ac); +static inline void ext4_mb_show_pa(struct super_block *sb); + /* * The algorithm using this percpu seq counter goes below: * 1. We sample the percpu discard_pa_seq counter before trying for block @@ -4217,9 +4219,9 @@ static void ext4_mb_new_preallocation(struct ext4_allocation_context *ac) struct ext4_prealloc_space *pa, *tmp; struct list_head list; struct ext4_buddy e4b; + int free_total = 0; + int busy, free; int err; - int busy = 0; - int free, free_total = 0; mb_debug(sb, "discard preallocation for group %u\n", group); if (list_empty(&grp->bb_prealloc_list)) @@ -4247,6 +4249,7 @@ static void ext4_mb_new_preallocation(struct ext4_allocation_context *ac) INIT_LIST_HEAD(&list); repeat: + busy = 0; free = 0; ext4_lock_group(sb, group); list_for_each_entry_safe(pa, tmp, @@ -4255,6 +4258,8 @@ static void ext4_mb_new_preallocation(struct ext4_allocation_context *ac) if (atomic_read(&pa->pa_count)) { spin_unlock(&pa->pa_lock); busy = 1; + mb_debug(sb, "used pa while discarding for group %u\n", group); + ext4_mb_show_pa(sb); continue; } if (pa->pa_deleted) { @@ -4300,7 +4305,6 @@ static void ext4_mb_new_preallocation(struct ext4_allocation_context *ac) if (free_total < needed && busy) { ext4_unlock_group(sb, group); cond_resched(); - busy = 0; goto repeat; } ext4_unlock_group(sb, group); -- 1.8.3.1