Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btrfs-convert reports incorrect free space #487

Open
cmurf opened this issue Jun 29, 2022 · 3 comments
Open

btrfs-convert reports incorrect free space #487

cmurf opened this issue Jun 29, 2022 · 3 comments
Labels
bug convert Changes in btrfs-convert

Comments

@cmurf
Copy link

cmurf commented Jun 29, 2022

btrfs-progs-5.18-1.fc36.x86_64
kernel-5.19.0-0.rc4.20220628git941e3e791269.34.fc37.x86_64

btrfs-convert is reporting wildly incorrect free space in its output, over 200% is free (?) is impossible.

Reproduce steps:

  1. truncate -s 28T test
  2. losetup /dev/loop0 test
  3. mkfs.ext4 /dev/loop0
  4. mount /dev/loop0 /mnt
  5. umount /mnt
  6. btrfs-convert /dev/loop0

Total space: 12412111552512
Free space: 29531792404480 (237.93%)

Downstream bug
https://bugzilla.redhat.com/show_bug.cgi?id=2101045

@cmurf
Copy link
Author

cmurf commented Jun 29, 2022

Doesn't happen with an 8T image. It might be a problem related to the size of the target file system or block device.

@JasonFerrara
Copy link

It looks like the free space is correct. It's the total space that's wrong.

@JasonFerrara
Copy link

JasonFerrara commented Jul 6, 2022

This seems to fix the incorrect total space (and block count) issue.

diff --git a/convert/source-ext2.c b/convert/source-ext2.c
index 9fad4c50..01b630ba 100644
--- a/convert/source-ext2.c
+++ b/convert/source-ext2.c
@@ -92,8 +92,8 @@ static int ext2_open_fs(struct btrfs_convert_context *cctx, const char *name)
 
        cctx->fs_data = ext2_fs;
        cctx->blocksize = ext2_fs->blocksize;
-       cctx->block_count = ext2_fs->super->s_blocks_count;
-       cctx->total_bytes = (u64)ext2_fs->super->s_blocks_count * ext2_fs->blocksize;
+       cctx->block_count = ext2fs_blocks_count(ext2_fs->super);
+       cctx->total_bytes = cctx->block_count * ext2_fs->blocksize;
        cctx->label = strndup((char *)ext2_fs->super->s_volume_name, 16);
        cctx->first_data_block = ext2_fs->super->s_first_data_block;
        cctx->inodes_count = ext2_fs->super->s_inodes_count;

I'm still waiting for the conversion to finish to see if this also fixes the downstream bug. It's been running for 9 hours so far. It might be nice to add some sort of progress for the Create ext2 image file stage.

@kdave kdave added bug convert Changes in btrfs-convert labels Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug convert Changes in btrfs-convert
Projects
None yet
Development

No branches or pull requests

3 participants