Skip to contentSkip to conversation

Btrfs: count the chunks which will be relocated at first

PATCH In review Miao Xie 2 participants 3 messages May 17, 2012 – May 18, 2012 Btrfs file system

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

PATCH 2/5 Btrfs: count the chunks which will be relocated at first

the balance function should count the chunks which will be relocated at first, and then relocate those chunks one by one.

---
 fs/btrfs/volumes.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/btrfs/volumes.c +1 -1
index 759d024..91da8a2 100644
@@ -2580,7 +2580,7 @@ again:
 
 		chunk = btrfs_item_ptr(leaf, slot, struct btrfs_chunk);
 
-		if (!counting) {
+		if (counting) {
 			spin_lock(&fs_info->balance_lock);
 			bctl->stat.considered++;
 			spin_unlock(&fs_info->balance_lock);
Signature · 1 line
1.7.6.5
#1 lore raw
Quoted 13 lines · Miao Xie

the balance function should count the chunks which will be relocated at first, and then relocate those chunks one by one.

---
 fs/btrfs/volumes.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/btrfs/volumes.c +0 -0
index 759d024..91da8a2 100644

fs/btrfs/volumes.c again: · line 2586

Quoted 8 lines
fs/btrfs/volumes.c +1 -1
@@ -2580,7 +2580,7 @@ again:
 
 		chunk = btrfs_item_ptr(leaf, slot, struct btrfs_chunk);
 
-		if (!counting) {
+		if (counting) {
 			spin_lock(&fs_info->balance_lock);
 			bctl->stat.considered++;
 			spin_unlock(&fs_info->balance_lock);

__btrfs_balance() already calculates the approximate number of chunks that will be relocated and stores that value in bctl->stat.expected. The stat.considered counter OTOH is supposed to reflect the number of chunks processed through balance filters and it is meant to be updated at relocation pass, so AFAICS if (!counting) is the right test.

What exactly are you trying to fix here ?

Thanks,

Ilya

author
#2 lore raw
Quoted 29 lines · Ilya Dryomov
Quoted 13 lines · Miao Xie

the balance function should count the chunks which will be relocated at first, and then relocate those chunks one by one.

---
 fs/btrfs/volumes.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/btrfs/volumes.c +0 -0
index 759d024..91da8a2 100644

fs/btrfs/volumes.c again: · line 2586

Quoted 8 lines
fs/btrfs/volumes.c +1 -1
@@ -2580,7 +2580,7 @@ again:
 
 		chunk = btrfs_item_ptr(leaf, slot, struct btrfs_chunk);
 
-		if (!counting) {
+		if (counting) {
 			spin_lock(&fs_info->balance_lock);
 			bctl->stat.considered++;
 			spin_unlock(&fs_info->balance_lock);

__btrfs_balance() already calculates the approximate number of chunks that will be relocated and stores that value in bctl->stat.expected. The stat.considered counter OTOH is supposed to reflect the number of chunks processed through balance filters and it is meant to be updated at relocation pass, so AFAICS if (!counting) is the right test.

Quoted 1 line

What exactly are you trying to fix here ?

In fact this number reflect the number of all the chunks that may be relocated. So since we can know the approximate number of chunks that will be relocated before the relocation start, why can not we know it at the beginning?

And beside that, as a user, I am very strange that this counter is changed every time I get the status of the balance, it should be the fixed number since it reflect the number of all the chunks that may be relocated.

Thanks
Miao