Thread (3 messages) 3 messages, 2 authors, 2012-10-25

Re: [PATCH V2][BTRFS-PROGS] [BUG] Fix Bug to corrupt the img file Reply-To: dave@jikos.cz

From: Rock Lee <hidden>
Date: 2012-10-25 23:37:45

Thanks for your review.

Sorry for the problem line wrapped, I will resend the patch.


Thanks
-Rock

2012/10/26 David Sterba [off-list ref]:
On Fri, Oct 26, 2012 at 12:12:24AM +0800, Rock Lee wrote:
quoted
Fix Bug to corrupt the img file

Reproduce steps:
  > dd if=/dev/zero of=btrfs-small.img bs=1M count=1
  > ls -lh btrfs-small.img
  -rw-rw-r--. 1 rock rock 1.0M Oct 24 09:51 btrfs-small.img
                                      ^^^
  > mkfs.btrfs btrfs-small.img
  -rw-rw-r--. 1 rock rock 2.0M Oct 24 09:53 btrfs-small.img
                                      ^^^

Here you can see the original img file's size goes larger to 2Mb.
Thanks, fixes this particular bug; although it crashes later at

  mkfs.btrfs: volumes.c:796: btrfs_alloc_chunk: Assertion `!(ret)' failed

but this is a separate issue and you've sent patches for that IIRC.
quoted
--- a/utils.c
+++ b/utils.c
@@ -557,6 +557,12 @@ int btrfs_prepare_device(int fd, char *file, int
zero_end, u64 *block_count_ret,
        }
        if (max_block_count)
                block_count = min(block_count, max_block_count);
+
+       if (block_count < 2 * 1024 * 1024) {
+               fprintf(stderr, "size of %s is too small(less than
2Mb)\n", file);
line wrapped, please check your mailer (easy to fix but additional
unnecessary work)
quoted
+               exit(1);
+       }
+
Otherwise ack from me.

david
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help