On 6/19/19 1:30 PM, David Sterba wrote:
> On Wed, Jun 19, 2019 at 12:21:34PM +0200, Hans van Kranenburg wrote:
>> On 6/19/19 12:13 PM, Holger Hoffstätte wrote:
>>> On 6/19/19 5:20 AM, Chris Murphy wrote:
>>>> This is on Fedora Rawhide (which is planned to become Fedora 31 due in
>>>> October), which no longer provides python2.
>>>>
>>>> $ ./btrfs-debugfs -b /
>>>> /usr/bin/env: ‘python2’: No such file or directory
>>>> $
>>>>
>>>> I expect other distros are going to follow as Python 2.7 EOL is coming
>>>> up fast, in 6 months.
>>>> https://pythonclock.org/
>>>
>>> I just ran it through 2to3-3.7 with -w and the new version seems to work
>>> just fine for me, so it seems there is not much porting required.
>>
>> I don't think you want to ship that program at all, for end users.
> 
> Agreed, it was probably just some helper script for developers but it
> never got enough features to be useful.
> 
>> It's
>> quite horrible, and the -b option even downloads the *entire* extent
>> tree to userspace in a very naive way.
>>
>> There are way simpler, better performing alternatives...
> 
> There are, so let's use them!

This does the same as btrfs-debugfs -b / :

import btrfs
with btrfs.FileSystem('/') as fs:
  for chunk in fs.chunks():
    print(fs.block_group(chunk.vaddr))

Something like this is in examples/ in python-btrfs, there's no tool in
the collection of nice programs in bin/ in there yet to do this.

I have been thinking about this, and didn't want to hurry it, earlier.

There are quite a lot of those kind of simple searches for information
possible:

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

This would be the online equivalent of doing things with
btrfs-debug-tree, which reads info directly from disk. Processing of the
command line input arguments will be about 95% of all the code of it.

It's also really nice to be able to compare output of both (online,
offline) when your kernel gets into some weird state. I ran into a
situation in the past (rogue parent transid verify failed during balance
/ subvol delete with a btrfs_commit_transaction:2227: errno=-5 IO
failure (Error while writing out transaction)) and then I could see the
corrupted metadata in memory.

K

Reply via email to