summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
...
* btrfs-progs: use libbtrfsutil for subvol deleteOmar Sandoval2018-03-06
| | | | | | | | Most of the interesting part of this command is the commit mode, so this only saves a little bit of code. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use libbtrfsutil for get-defaultOmar Sandoval2018-03-06
| | | | | | | | | The only thing of note here is the "top level" column. This used to mean something else, but for a long time it has been equal to the parent ID. I preserved this for backwards compatability. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use libbtrfsutil for set-defaultOmar Sandoval2018-03-06
| | | | | Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use libbtrfsutil for sync ioctlsOmar Sandoval2018-03-06
| | | | | Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use libbtrfsutil for read-only propertyOmar Sandoval2018-03-06
| | | | | Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add btrfs_util_deleted_subvolumes()Omar Sandoval2018-03-06
| | | | | Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add btrfs_util_delete_subvolume()Omar Sandoval2018-03-06
| | | | | | | We also support recursive deletion using a subvolume iterator. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add btrfs_util_create_snapshot()Omar Sandoval2018-03-06
| | | | | | | | Thanks to subvolume iterators, we can also implement recursive snapshot fairly easily. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add subvolume iterator helpersOmar Sandoval2018-03-06
| | | | | | | | | | | | This is how we can implement stuff like `btrfs subvol list`. Rather than producing the entire list upfront, the iterator approach uses less memory in the common case where the whole list is not stored (O(max subvolume path length)). It supports both pre-order traversal (useful for, e.g, recursive snapshot) and post-order traversal (useful for recursive delete). Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add stub for reallocarrayDavid Sterba2018-03-06
| | | | | | | This function is new in glibc 2.26 and breaks build in CI and possibly other environments. Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add btrfs_util_[gs]et_default_subvolume()Omar Sandoval2018-03-06
| | | | | | | | set_default_subvolume() is a trivial ioctl(), but there's no ioctl() for get_default_subvolume(), so we need to search the root tree. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add btrfs_util_[gs]et_read_only()Omar Sandoval2018-03-06
| | | | | | | | | In the future, btrfs_util_[gs]et_subvolume_flags() might be useful, but since these are the only subvolume flags we've defined in all this time, this will do for now. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add btrfs_util_subvolume_info()Omar Sandoval2018-03-06
| | | | | | | | This gets the the information in `btrfs subvolume show` from the root item. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add btrfs_util_subvolume_path()Omar Sandoval2018-03-06
| | | | | | | | We can just walk up root backrefs with BTRFS_IOC_TREE_SEARCH and inode paths with BTRFS_IOC_INO_LOOKUP. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add btrfs_util_create_subvolume()Omar Sandoval2018-03-06
| | | | | | | | Doing the ioctl() directly isn't too bad, but passing in a full path is more convenient than opening the parent and passing the path component. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add btrfs_util_is_subvolume() and btrfs_util_subvolume_id()Omar Sandoval2018-03-06
| | | | | | | | These are the most trivial helpers in the library and will be used to implement several of the more involved functions. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: copy in Btrfs UAPI headersOmar Sandoval2018-03-06
| | | | | | | | | Systems with older kernels won't have these available, and the copies in btrfs-progs aren't quite compatible, so for now, let's just copy these in. We can potentially deduplicate some of this in the future. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: fix Python testsOmar Sandoval2018-03-06
| | | | | | | These were broken when the patch series got shuffled around. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Move chunk stripe size calculation function to volumes.hQu Wenruo2018-03-06
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: volumes: Allow find_free_dev_extent() to return maximum hole sizeQu Wenruo2018-02-24
| | | | | | | | Just as kernel find_free_dev_extent(), allow it to return maximum hole size for us to build device list for later chunk allocator rework. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Introduce btrfs_raid_array and related infrastructuresQu Wenruo2018-02-24
| | | | | | | | | | | As part of the effort to unify code and behavior between btrfs-progs and kernel, copy the btrfs_raid_array from kernel to btrfs-progs. So later we can use the btrfs_raid_array[] to get needed raid info other than manually do if-else branches. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Refactor parameter of BTRFS_MAX_DEVS() from root to fs_infoQu Wenruo2018-02-24
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add filesystem sync helpersOmar Sandoval2018-02-24
| | | | | | | Namely, sync, start_sync, and wait_sync. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add qgroup inheritance helpersOmar Sandoval2018-02-24
| | | | | | | | | | We want to hide struct btrfs_qgroup_inherit from the user because that comes from the Btrfs UAPI headers. Instead, wrap it in a struct btrfs_util_qgroup_inherit and provide helpers to manipulate it. This will be used for subvolume and snapshot creation. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* libbtrfsutil: add Python bindingsOmar Sandoval2018-02-24
| | | | | | | | | | | The C libbtrfsutil library isn't very useful for scripting, so we also want bindings for Python. Writing unit tests in Python is also much easier than doing so in C. Only Python 3 is supported; if someone really wants Python 2 support, they can write their own bindings. This commit is just the scaffolding. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: ci: add python dependencies for libbtrfsutilDavid Sterba2018-02-24
| | | | | | | Install the setuptools. Python is not yet in the musl image, so the build is disabled there. Signed-off-by: David Sterba <dsterba@suse.com>
* Add libbtrfsutilOmar Sandoval2018-02-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, users wishing to manage Btrfs filesystems programatically have to shell out to btrfs-progs and parse the output. This isn't ideal. The goal of libbtrfsutil is to provide a library version of as many of the operations of btrfs-progs as possible and to migrate btrfs-progs to use it. Rather than simply refactoring the existing btrfs-progs code, the code has to be written from scratch for a couple of reasons: * A lot of the btrfs-progs code was not designed with a nice library API in mind in terms of reusability, naming, and error reporting. * libbtrfsutil is licensed under the LGPL, whereas btrfs-progs is under the GPL, which makes it dubious to directly copy or move the code. Eventually, most of the low-level btrfs-progs code should either live in libbtrfsutil or the shared kernel/userspace filesystem code, and btrfs-progs will just be the CLI wrapper. This first commit just includes the build system changes, license, README, and error reporting helper. Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add helper to log pipe stdoutDavid Sterba2018-02-19
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add test for send -p on 2 mont pointsDavid Sterba2018-02-19
| | | | | | | Add testcase from issue, use reproducer from Axel Burri. Issue: #96 Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: prevent incorrect use of subvol_strip_mountpointAxel Burri2018-02-19
| | | | | | | | | | | | | | | | | | | Add additional bound checks to prevent memory corruption on incorrect usage of subvol_strip_mountpoint. Assert sane return value by properly comparing the mount point to the full_path before stripping it off. Mitigates issue: "btrfs send -p" fails if source and parent subvolumes are on different mountpoints (memory corruption): https://github.com/kdave/btrfs-progs/issues/96 Note that this does not properly fix this bug, but prevents a possible security issue by unexpected usage of "btrfs send -p". Issue: #96 Pull-request: #98 Signed-off-by: Axel Burri <axel@tty0.ch> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: configure.ac hard-codes the pkg-config commandDavid Sterba2018-02-19
| | | | | | | | | | | | | | | | Right now the pkg-config command is hard-coded in configure.ac, which may result in build errors on system and cross environments that have prefixed toolchains, e.g. /usr/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-pkg-config. Please see the attached patch, it has been written a while ago but it seems it hasn't been submitted for upstream inclusion. 0001-configure.ac-Consistently-use-PKG_CONFIG.txt Submitted by Timo Gurr. Author: Wulf C. Krueger <philantrop@exherbo.org> Issue: #101 Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs progs v4.15.1David Sterba2018-02-16
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: update CHANGES for v4.15.1David Sterba2018-02-16
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: let callers of btrfs_show_qgroups free the buffersDavid Sterba2018-02-16
| | | | | | | | | btrfs_show_qgroups frees the filter and comparer in case it succeeds. This makes the caller slightly more complicated so move the freeing up one level. Issue: #20 Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert/ext2: Fix memory leak caused by handled ext2_filsysQu Wenruo2018-02-14
| | | | | | | | | | | | | Exposed by convert-test with D=asan. Unlike btrfs, ext2fs_close() still leaves its ext2_filsys parameter filled with allocated pointers. It needs ext2fs_free() to free those pointers. Issue: #92 Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs/rootdir: Fix memory leak in traverse_directory()Qu Wenruo2018-02-14
| | | | | | | | | | | | | | | | | The bug is exposed by mkfs test case 009, with D=asan. We are leaking memory of parent_dir_entry->path() which ,except the rootdir, is allocated by strdup(). Before fixing it, unifiy the allocation of parent_dir_entry() to heap allocation. Then fix it by adding "free(parent_dir_entry->path);" in traverse_directory() and error handler. Issue: #92 Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: btrfs-progs: Fix read beyond boundary bug in ↵Qu Wenruo2018-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | build_roots_info_cache() This bug is exposed by fsck-test with D=asan, hit by test case 020, with the following error report: ================================================================= ==10740==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x621000061580 at pc 0x56051f0db6cd bp 0x7ffe170f3e20 sp 0x7ffe170f3e10 READ of size 1 at 0x621000061580 thread T0 #0 0x56051f0db6cc in btrfs_extent_inline_ref_type /home/adam/btrfs/btrfs-progs/ctree.h:1727 #1 0x56051f13b669 in build_roots_info_cache /home/adam/btrfs/btrfs-progs/cmds-check.c:14306 #2 0x56051f13c86a in repair_root_items /home/adam/btrfs/btrfs-progs/cmds-check.c:14450 #3 0x56051f13ea89 in cmd_check /home/adam/btrfs/btrfs-progs/cmds-check.c:14965 #4 0x56051efe75bb in main /home/adam/btrfs/btrfs-progs/btrfs.c:302 #5 0x7f04ddbb0f49 in __libc_start_main (/usr/lib/libc.so.6+0x20f49) #6 0x56051efe68c9 in _start (/home/adam/btrfs/btrfs-progs/btrfs+0x5b8c9) 0x621000061580 is located 0 bytes to the right of 4224-byte region [0x621000060500,0x621000061580) allocated by thread T0 here: #0 0x7f04ded50ce1 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:70 #1 0x56051f04685e in __alloc_extent_buffer /home/adam/btrfs/btrfs-progs/extent_io.c:553 #2 0x56051f047563 in alloc_extent_buffer /home/adam/btrfs/btrfs-progs/extent_io.c:687 #3 0x56051efff1d1 in btrfs_find_create_tree_block /home/adam/btrfs/btrfs-progs/disk-io.c:187 #4 0x56051f000133 in read_tree_block /home/adam/btrfs/btrfs-progs/disk-io.c:327 #5 0x56051efeddb8 in read_node_slot /home/adam/btrfs/btrfs-progs/ctree.c:652 #6 0x56051effb0d9 in btrfs_next_leaf /home/adam/btrfs/btrfs-progs/ctree.c:2853 #7 0x56051f13b343 in build_roots_info_cache /home/adam/btrfs/btrfs-progs/cmds-check.c:14267 #8 0x56051f13c86a in repair_root_items /home/adam/btrfs/btrfs-progs/cmds-check.c:14450 #9 0x56051f13ea89 in cmd_check /home/adam/btrfs/btrfs-progs/cmds-check.c:14965 #10 0x56051efe75bb in main /home/adam/btrfs/btrfs-progs/btrfs.c:302 #11 0x7f04ddbb0f49 in __libc_start_main (/usr/lib/libc.so.6+0x20f49) It's completely possible that one extent/metadata item has no inline reference, while build_roots_info_cache() doesn't have such check. Fix it by checking @iref against item end to avoid such problem. Issue: #92 Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: reorder tests in make targetDavid Sterba2018-02-13
| | | | | | | Run the shorter tests first, convert can take very long, we're more interested in the misc test. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: print-tree: fix INODE_ITEM sequence and flagsAnand Jain2018-02-13
| | | | | | | | dump-tree prints wrong sequence number and the flags numbers, as we misplaced the printf args. This patch fixes it. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: document exported testsuiteDavid Sterba2018-02-13
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test: update clean-test.sh after the TEST_TOP updateDavid Sterba2018-02-13
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: unify test drivers, make ready for extenral testsuiteDavid Sterba2018-02-13
| | | | | | | | | | | Make the TOP variable more configurable, allow to set it to any path where to find binaries when the testsuite is exported, or fallback to system binaries. There's now more code duplication, the logic is now more complex so it's left open coded for clarity. Further cleanups are possible. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: update README.mdDavid Sterba2018-02-13
| | | | | | Irregular proofreading with adjustments and enhancements. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for testsGu Jinxiang2018-02-13
| | | | | | | | | | | | Use TEST_TOP as base for tests to reference any files, this will be used for git and external testsuite. INTERNAL_BIN is needed for referencing binaries that could reside in different paths in git vs external testsuite. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> [ add quotes around sourced files, update changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: rework testsuite exportDavid Sterba2018-02-13
| | | | | | | | | | Move the testsuite to tests/ and make the tarball generation more deterministic. As there could be many random temporary files left in the test directories, we can't just copy them. Use 'git ls-tree' to filter just what we want, this needs a slight extension of the file list specification. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Add make testsuite command for export testsGu Jinxiang2018-02-13
| | | | | | | | | | | | | | | | | Export the testsuite files to a separate tar. Since fsck tests depend on btrfs-corrupt-block, and misc tests depends on both btrfs-corrupt-block and fssum, so set it as prerequisites for package commad. Because, althougth fssum can be generated by source that are all in tests directory, and has no rely on the btrfs's structure. But btrfs-corrupt-block deeply relys on btrfs's structure. For consistency, at the present stage, generete the two when create test tar. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> [ applied without changes, the generated tarball will be different from the one after the follow up commits ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add prerequisite btrfs-convert for test-miscGu Jinxiang2018-02-13
| | | | | | | | Since tests/misc-tests/005-convert-progress-thread-crash/test.sh need the btrfs-convert for prerequisite. So add the dependency in Makefile. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add prerequisite btrfs-image for test-fuzzGu Jinxiang2018-02-13
| | | | | | | | Since tests/fuzz-tests/002-simple-image/test.sh need the btrfs-image for prerequisite. So add the dependency in Makefile. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add prerequisite mkfs.btrfs for test-cliGu Jinxiang2018-02-13
| | | | | | | | | Since tests/cli-tests/002-balance-full-no-filters/test.sh need the mkfs.btrfs for prerequisite. So add the dependency in Makefile. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: ci: replace inline shell commands with scriptsDavid Sterba2018-02-13
| | | | Signed-off-by: David Sterba <dsterba@suse.com>