Package: python3-btrfs
Version: 11-1

In the upstream issue tracker, an issue was reported about a crash when
using the example program 'btrfs-space-calculator' that is shipped
together with the python-btrfs library:

https://github.com/knorrie/python-btrfs/issues/19

bor@bor-Latitude-E5450:~/src/python-btrfs$ ./bin/btrfs-space-calculator
-m raid0 -d raid5 3T 1T 2T
Traceback (most recent call last):
[...]
  File "/home/bor/src/python-btrfs/bin/btrfs/volumes.py", line 192, in
chunk_length_to_dev_extent_length
    dev_extent_length = raw_data_bytes // num_data_stripes
ZeroDivisionError: integer division or modulo by zero

This is not nice, since Debian Buster will be the first Debian release
to include this package, and users should be encouraged to explore
possible use cases for the btrfs filesystem.

After researching this, I came up with a >120 line change that fixes the
involved scenarios and makes it more future-proof. But, to have the
program not crash with a minimal fix for this upstream version, it's
sufficient to just do a 2-line workaround:

diff --git a/bin/btrfs-space-calculator b/bin/btrfs-space-calculator
index cb7f8f6..7586c7d 100755
--- a/bin/btrfs-space-calculator
+++ b/bin/btrfs-space-calculator
@@ -54,8 +54,8 @@ class FakeChunk(object):
     def __init__(self, flags):
         self.type = flags
         self.length = 1
-        self.stripes = [FakeStripe()]
-        self.num_stripes = 1
+        self.stripes = [FakeStripe()] * 4
+        self.num_stripes = 4

Hans

Reply via email to