Skip to contentSkip to conversation

Btrfs-progs: init free space ctl with proper unit

PATCH New Josef Bacik 1 participant 1 message May 3, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs-progs: init free space ctl with proper unit

btrfsck was blowing up when checking the free space cache when we ran xfstests with -l 64k. That is because I was init'ing the free space ctl to whatever the leafsize was, which isn't right for data block groups. With this patch btrfsck no longer complains. This also fixes a tiny little typo in free-space-cache.c I noticed while figuring this problem out. Thanks,

---
 cmds-check.c       |   11 +++++++++--
 free-space-cache.c |    2 --
 2 files changed, 9 insertions(+), 4 deletions(-)
cmds-check.c +9 -2
index 030ab77..02bfedd 100644
@@ -3001,8 +3001,15 @@ static int check_space_cache(struct btrfs_root *root)
 
 		start = cache->key.objectid + cache->key.offset;
 		if (!cache->free_space_ctl) {
-			if (btrfs_init_free_space_ctl(cache,
-						      root->leafsize)) {
+			int sectorsize;
+
+			if (cache->flags & (BTRFS_BLOCK_GROUP_METADATA |
+					    BTRFS_BLOCK_GROUP_SYSTEM))
+				sectorsize = root->leafsize;
+			else
+				sectorsize = root->sectorsize;
+
+			if (btrfs_init_free_space_ctl(cache, sectorsize)) {
 				ret = -ENOMEM;
 				break;
 			}
free-space-cache.c +0 -2
index 8a77a32..5fb8ece 100644
@@ -808,8 +808,6 @@ int btrfs_add_free_space(struct btrfs_free_space_ctl *ctl, u64 offset,
 	try_merge_free_space(ctl, info);
 
 	ret = link_free_space(ctl, info);
-	if (ret)
-
 	if (ret) {
 		printk(KERN_CRIT "btrfs: unable to add free space :%d\n", ret);
 		BUG_ON(ret == -EEXIST);
Signature · 1 line
1.7.7.6