Skip to contentSkip to conversation

Btrfs: fix wrong calculation of the available space when reserving the space

PATCH In review Miao Xie 2 participants 3 messages Sep 27, 2012 Btrfs file system

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

PATCH 1/1 Btrfs: fix wrong calculation of the available space when reserving the space

According to the comment, we can overcommit the space up to 1/2 of the total disk space, or we just can overcommit up to 1/8. But the code was written reversedly. Fix it.

---
This is based on btrfs-next tree.

---
 fs/btrfs/extent-tree.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/extent-tree.c +2 -2
index a010234..8a01087 100644
@@ -3962,9 +3962,9 @@ again:
 		 * 1/2 of the space.
 		 */
 		if (flush)
-			avail >>= 3;
-		else
 			avail >>= 1;
+		else
+			avail >>= 3;
 		 spin_unlock(&root->fs_info->free_chunk_lock);
 
 		if (used + num_bytes < space_info->total_bytes + avail) {
Signature · 1 line
1.6.5.2
author
#1 lore raw

Please ignore this patch, it is not based on the new btrfs-next tree. I'll send the right one as soon as possible.

Thanks
Miao

Quoted 28 lines · Miao Xie

According to the comment, we can overcommit the space up to 1/2 of the total disk space, or we just can overcommit up to 1/8. But the code was written reversedly. Fix it.

---
This is based on btrfs-next tree.

---
 fs/btrfs/extent-tree.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/extent-tree.c +2 -2
index a010234..8a01087 100644
@@ -3962,9 +3962,9 @@ again:
 		 * 1/2 of the space.
 		 */
 		if (flush)
-			avail >>= 3;
-		else
 			avail >>= 1;
+		else
+			avail >>= 3;
 		 spin_unlock(&root->fs_info->free_chunk_lock);
 
 		if (used + num_bytes < space_info->total_bytes + avail) {
#2 lore raw
In reply to Miao Xie
Quoted 4 lines · Miao Xie

According to the comment, we can overcommit the space up to 1/2 of the total disk space, or we just can overcommit up to 1/8. But the code was written reversedly. Fix it.

Sorry the comment is wrong, I was actually just looking at this the other day :). Basically we want non-flushers to be able to overcommit more to give those guys more of a chance of being able to make an allocation, but we want flushers to not be able to overcommit too much since they are allowed to make more headroom, so the logic is right, the comment is wrong. Thanks,

Josef