python-btrfs v15, Apr 11, 2025 * Add the DEFRAG_RANGE ioctl * Add documentation for the COMPRESS_* values * Add logical_ino and logical_ino_v2 to the ioctl module as primary function names for calling the LOGICAL_INO and LOGICAL_INO_V2 ioctls, to more closely resemble the ioctl names. The current logical_to_ino* functions names will stay to provide backwards compatibility. * Fix a bunch of spelling issues, thanks Yaroslav Halchenko for the suggestion about using codespell. * Stuff: - Fix some bad whitespace in the code python-btrfs v14.1, May 7, 2024 * Fixes: - Prevent a "SyntaxWarning: invalid escape sequence" from being displayed when using recent Python versions. - Actually use long_description_content_type in setup.py python-btrfs v14, Apr 28, 2024 * Add Block Group Tree support. * Add a block_groups convenience function to the FileSystem class. * btrfs-search-metadata: Use the new FileSystem block_groups function, so that it also DTRT when the Block Group Tree is being used. * Fixes: - Do not apply the workaround to prevent bogus cross references when building documentation with Sphinx version >= 4. It's not needed any more since that version. Thanks Jorti, for the report. - Fix documentation typo in FeatureFlags: free_space_tree is in compat_ro_flags, not in incompat_flags. - examples/show_file_csum: Fix calculating the vaddr to use when searching for data in the example file. Thanks Cebtenzzre, for the fix! * Stuff: - Add a .flake8 file to set line length to 99 - Add .readthedocs.yaml to fix building html docs at readthedocs.org python-btrfs v13, Apr 26, 2021 * Add new profiles RAID1C3 and RAID1C4. Thanks, Marmotte. * Update setup.py so that the package description is more compact and not rejected by pypi. * Update setup.py so that the example programs in bin/ are included in the pypi upload. Thanks, hexa-. * Some small documentation fixes and improvements. Thanks, endolith. python-btrfs v12, Oct 13, 2020 * Data structures: RootRef, OrphanItem * Add a new useful program for looking up btrfs metadata, btrfs-search-metadata, and add a man page for it. * Add a recursive object printer using the str() function of objects, as an alternative to the existing pretty printer which dumps full objects. * Add the parse_tree_name function in utils, which can convert tree names to their number. E.g. 'FS_TREE' -> 5. * Add parse_key_string in utils, which parses a metadata item key string to a Key object. E.g. '(535 EXTENT_DATA 0)' -> Key(535, 108, 0). * Add a search function to the FileSystem object, to make it a bit simpler to use the search ioctl when already having a FileSystem object in hands. * Add more useful information to the README of the project. It was way too terse and unhelpful. * Allow setting the env.mounts option for the munin plugin, so that we can 1) limit what filesystems are included and 2) influence the paths shown in the graph title. * Fixes: - Fix an unfortunate crash because of a stray underscore in the code of MetaDataItem. - Actually use the data_metadata_ratio argument for btrfs-space-calculator. The option was silently ignored. - Fix a crash in btrfs-space-calculator when using raid5. - Require at least one disk size for btrfs-space-calculator, since without any disk sizes, executing the program is meaningless. - Add a centralized way to store the library version number. After releasing v11, I found out the documentation still showed v10. - Fix the field order of corruption_errs and generation_errs in DevStats in the ioctl module. The two numbers were swapped. - Fix arithmetic behaviour of metadata item key values on underflow or overflow of the 136 bit key space. * Examples added: - show_subvolumes: Show how to use the RootRef metadata item to construct path names of the locations of subvolumes in the filesystem. * Examples removed: - block_group_search_timing * Examples removed, which are replaced by the btrfs-search-metadata program: - dump_tree, show_block_group_contents, show_block_group_free_space_extents, show_block_groups, show_chunk_tree_keys, show_dev_extents, show_directory_contents, show_extent_tree_keys, show_file, show_file_by_inode, show_tree_keys * Various small documentation and bug fixes. python-btrfs v11, Feb 28, 2019 * Promote some useful examples to proper programs, and add a man page for them. Distro package maintainers can ship these in /usr/bin. - btrfs-usage-report - btrfs-balance-least-used - btrfs-space-calculator - btrfs-orphan-cleaner-progress * Add TEMPORARY_ITEM_KEY and PERSISTENT_ITEM_KEY, which have replaced BALANCE_ITEM_KEY and DEV_STATS_KEY in kernel code a while ago. * Various small documentation and bug fixes. python-btrfs v10, Jan 18, 2019 * Switch to LGPL-3.0 license. * Add reference documentation to all code, using sphinx autodoc. An online version of the result in html format is available at: https://python-btrfs.readthedocs.io/en/latest/btrfs.html * All parts of the code that are covered by reference documentation are now considered to be the public API of the library. Effort will be done to not break this API in the future. * The FileSystem class now provides a context manager, to help prevent leaking the open file descriptor used internally. * The mounted_filesystems function in btrfs.utils module has been replaced by mounted_filesystem_paths. It is the responsibility of the caller to create the FileSystem objects for these paths and use the new context manager while doing do. * Add the fs_usage module, containing the FsUsage class, providing detailed usage reporting for a filesystem. This code replaces old similar functions, which were incomplete and buggy. * Adapt munin and nagios plugins to use the new FsUsage object. * IOCTLs: IOC_SYNC, FIDEDUPERANGE, IOC_GET_FEATURES * Data structures: FreeSpaceInfo, FreeSpaceExtent, FreeSpaceBitmap. * Introduce ItemNotFoundError, currently only raised by the block group lookup function in FileSystem. It inherits from IndexError for backwards compatibility. * Many small changes to improve the object pretty printer. * Fixes: - By default the maximum amount of items generated by a single call to search or search_v2 would be limited to 2^32-1. Fix this, so it's unlimited. The search functions return an iterator and call the search ioctl of the linux kernel multiple times internally. * Examples added: - A new show_usage, which shows information from the new usage reporting. - space_calculator: Offline usable space calculator, based on disk sizes and profiles provided on the command line. - file_dedupe_range: Example about using the deduplication ioctl. python-btrfs v9.1, Okt 22, 2018 * Fix compatibility with Python 3.7, which breaks the struct module API. * Change the bad free space fragmentation example to use a minimal score to filter output. The default value (250) now causes only displaying block groups that look really suspicious. python-btrfs v9, Nov 23 2017 * IOCTLs: IOC_SET_RECEIVED_SUBVOL, IOC_LOGICAL_INO_V2 * Add crc32c checksum function for data, thanks Nikolay Borisov * Recognize zstd compression type * Add a tree object pretty printer to dump data for any tree item * Examples added: - Show default subvolume id - Lookup a block checksum in the checksum tree - Determine bad free space fragmentation score for block groups - Set the received_uuid e.a. of a subvolume - Dump an entire metadata tree using the pretty printer * Fixes: - crc32c: add implicit seed truncation to 32 bits value * Small fixes and cosmetic changes python-btrfs v8, Jul 18 2017 * Easier handling of multiple appended data structures of the dir item and inode ref families. (not backwards compatible!) * Don't keep metadata page transid value when retrieving a BlockGroupItem. This was introduced in v4, but it's not technically correct. * Improve architecture dependent ioctl number handling. * Examples added: - Do a custom sorted btrfs balance, working from the least used block group to the most used, stopping at some usage value. - Calculate an inode extref hash from an inode number and file name. * Fixes: - Another unfortunate typo in __str__ methods of an object python-btrfs v7, May 28 2017 * Also unpack bitmaps when showing the free space tree * Fixes: - A few unfortunate typos in __str__ methods of objects * Examples added: - Show background subvolume removal progress. - Show metadata tree sizes in bytes and amount of tree blocks. - Show file info by tree and inode number python-btrfs v6, Mar 24 2017 * Only Python 3 supported from now on * IOCTLs: INO_LOOKUP, LOGICAL_INO, TREE_SEARCH_V2, IOC_BALANCE_V2, IOC_BALANCE_CTL, BALANCE_PROGRESS * Data structures: InodeRef, DirItem, DirIndex, XAttrItem, FileExtentItem, InodeExtref * Add a helper to retrieve free space tree extents * Check device error counters in the nagios plugin * Fixes: - Not loading backreferences for extents was broken - Handle IOCTL differences for different architectures * Examples added: - Show directory contents (both the index and namehash list) - Try to show a filename for data extents - Show file information (inode, xattrs, etc, and list of extents) - Show subvolumes python-btrfs v5, Jan 14 2017 * Revamp and fix loading of extent backreferences. * Explode when detecting a non x86_64 arch. * Add a crc32c implementation and example script to create a dir_item offset hash. python-btrfs v4, Dec 18 2016 * Bump/inverse versioning, there will never be a v1.0, just keep developing and releasing. \:D/ * IOCTLs: LOGICAL_INO * New datastructures: InodeItem, RootItem, DiskKey, TimeSpec * Add all constants to pretty print tree keys * Behaviour change: don't load extent refs by default * Keep transid value when retrieving a BlockGroupItem * Known issue: - SHARED_BLOCK_REF and TREE_BLOCK_REF are missing in extent refs python-btrfs 0.3, Nov 15 2016 * Showing the contents of metadata block groups * Renamed datastructures: DevItem, BlockGroupItem, ExtentItem * New datastructures: TreeBlockInfo, MetaDataItem, TreeBlockRef, SharedBlockRef, DevStats * IOCTLs: IOC_GET_DEV_STATS * Fixes: - Python 3 compatibility, again python-btrfs 0.2, Jun 28 2016 * Datastructures: DevExtent * Python 3 compatibility * Utils: lookup total filesystem usage (incl. unallocatable space) * Example nagios nrpe monitoring plugin * Fixes: - Optimize block group search python-btrfs 0.1, Jun 21 2016 * IOCTLs: IOC_SPACE_INFO, IOC_TREE_SEARCH, IOC_FS_INFO, IOC_DEV_INFO * Datastructures: Device (dev_item), Chunk, Stripe, BlockGroup, Extent, ExtentDataRef, SharedDataRef * btrfs.FileSystem main entry point for usage * Handing of the search Key (objectid, type, offset) * Utils: pretty printing amounts of bytes and block group / chunk types and profiles (like, MetaData, RAID1 etc...), determine wasted (unallocatable) space for RAID0, RAID1 * Example snippets using all functionality * Example munin monitoring plugin