[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210421155455.51725-1-wenyang@linux.alibaba.com>
Date: Wed, 21 Apr 2021 23:54:55 +0800
From: Wen Yang <wenyang@...ux.alibaba.com>
To: tytso@....edu, Andreas Dilger <adilger.kernel@...ger.ca>
Cc: Wen Yang <wenyang@...ux.alibaba.com>,
Baoyou Xie <baoyou.xie@...baba-inc.com>,
linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] fs/ext4: remove redundant initialization of variable busy
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 <wenyang@...ux.alibaba.com>
Cc: "Theodore Ts'o" <tytso@....edu>
Cc: Andreas Dilger <adilger.kernel@...ger.ca>
Cc: Baoyou Xie <baoyou.xie@...baba-inc.com>
Cc: linux-ext4@...r.kernel.org
Cc: linux-kernel@...r.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
Powered by blists - more mailing lists