summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
...
* btrfs-progs: treewide: Replace strerror(errno) with %m.Rosen Penev2018-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As btrfs is specific to Linux, %m can be used instead of strerror(errno) in format strings. This has some size reduction benefits for embedded systems. glibc, musl, and uclibc-ng all support %m as a modifier to printf. A quick glance at the BIONIC libc source indicates that it has support for %m as well. BSDs and Windows do not but I do believe them to be beyond the scope of btrfs-progs. Compiled sizes on Ubuntu 16.04: Before: 3916512 btrfs 233688 libbtrfs.so.0.1 4899 bcp 2367672 btrfs-convert 2208488 btrfs-corrupt-block 13302 btrfs-debugfs 2152160 btrfs-debug-tree 2136024 btrfs-find-root 2287592 btrfs-image 2144600 btrfs-map-logical 2130760 btrfs-select-super 2152608 btrfstune 2131760 btrfs-zero-log 2277752 mkfs.btrfs 9166 show-blocks After: 3908744 btrfs 233256 libbtrfs.so.0.1 4899 bcp 2366560 btrfs-convert 2207432 btrfs-corrupt-block 13302 btrfs-debugfs 2151104 btrfs-debug-tree 2134968 btrfs-find-root 2281864 btrfs-image 2143536 btrfs-map-logical 2129704 btrfs-select-super 2151552 btrfstune 2130696 btrfs-zero-log 2276272 mkfs.btrfs 9166 show-blocks Total savings: 23928 (24 kilo)bytes Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: don't clobber errno in close_file_or_dirDavid Sterba2018-01-31
| | | | | | | | Preserve the errno value for the caller in case closing happens in the middle of eg. an ioctl and reporing the failure. The errors that could happen in close/closedir do not bother us. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: volumes: Remove unnecessary parameters when allocating device ↵Qu Wenruo2018-01-31
| | | | | | | | | | | | | | | extent @chunk_tree and @chunk_objectid of device extent is fixed to BTRFS_CHUNK_TREE_OBJECTID and BTRFS_FIRST_CHUNK_TREE_OBJECTID respectively. There is no need to pass them as parameter explicitly. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: volumes: Remove unnecessary trans parameterQu Wenruo2018-01-31
| | | | | | | | | | | | | Remove @trans parameter for find_free_dev_extent_start() and its callers. The function itself is doing read-only tree search, no use of transaction. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: volumes: Make find_free_dev_extent_start staticQu Wenruo2018-01-31
| | | | | | | | | | The function is not used by anyone else outside of volumes.c, make it static. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Use bool parameter to determine if we're allocating data extentQu Wenruo2018-01-31
| | | | | | | | | | | | | | | btrfs_reserve_extent() uses int @data to determine if we're allocating data extent, while reuse the parameter later to pass it as profile (data/meta/sys). It's a little confusing, this patch will follow kernel parameter to use bool @is_data to replace it. And in btrfs_reserve_extent(), use dedicated u64 @profile. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: truncate test image to 0 firstDavid Sterba2018-01-31
| | | | | | | | We use the prepare_test_dev helper to make sure the image has at least this size. The "at least" part is not desired by some tests as the device might be larger than the test expects. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add more coverage to mkfs-tests/013-reserved-1M-for-singleDavid Sterba2018-01-31
| | | | | | | Though the newly added mkfs profiles should not be affected, let's add the remaining valid single device profiles for better coverage. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: mkfs: don't overwrite first 1M for singleQu Wenruo2018-01-31
| | | | | | | | | Add test case to check if the first device extent is occupying reserved 0~1M range. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests:mkfs/010: Output minimal device sizeQu Wenruo2018-01-31
| | | | | | | To make debugging a little easier. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved ↵Qu Wenruo2018-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1M range When creating btrfs, mkfs.btrfs will firstly create a temporary system chunk as basis, and then created needed trees or new devices. However the layout temporary system chunk is hard-coded and uses reserved [0, 1M) range of devid 1. Change the temporary chunk layout from old: 0 1M 4M 5M |<----------- temp chunk -------------->| And it's 1:1 mapped, which means it's a SINGLE chunk, and stripe offset is also 0. to new layout: 0 1M 4M 5M |<----------- temp chunk -------------->| And still keeps the 1:1 mapping. However this also affects btrfs_min_dev_size() which still assume temporary chunks starts at device offset 0. The problem can only be exposed by "-m single" or "-M" where we reuse the temporary chunk. With other meta profiles, system and meta chunks are allocated by later btrfs_alloc_chunk() call, and old SINGLE chunks are removed, so it will be no such problem for other meta profiles. Reported-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Tested-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> [ folded fix for the minimal device size calculation ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: 029-super-recovery: cleanup the testDavid Sterba2018-01-31
| | | | | | | Transform the test to the common helpers and don't manage the loop devices here. The test category changes from check to misc. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test for super block recoveryNikolay Borisov2018-01-31
| | | | | | | | | This functionality regressed some time ago and it was never caught. Seems no one complained of that, but to be sure add a regression test to prevent future regressions. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: super-recover: fix the broken sb detectionNikolay Borisov2018-01-31
| | | | | | | | | | | | | | | | | | | Commit 3296d058b7ce ("btrfs-progs: super-recover: Reuse btrfs_read_dev_super function") changed the logic when a superblock is added to the bad block list to depend on -EIO. However currently btrfs_read_dev_super doesn't return -EIO when the fist super block is broken. Instead it returns -1. This causes the super-recovery logic to miss the fact that the first super block is completely broken. Fix this by considering any error code from btrfs_read_dev_super other than -ENOENT to mean that the super block is corrupted. -ENOENT means that the superblock copy is not part of the fs i.e. it's smaller than the offset of the block. This can only occur for the 2nd copy at 256gb mark. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Document logic of btrfs_read_dev_superNikolay Borisov2018-01-31
| | | | | | Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Replace usage of list_for_each with list_for_each_entryNikolay Borisov2018-01-31
| | | | | | | | | | | | | There are a couple of places where instead of the more succinct list_for_each_entry the code uses list_for_each. This results in slightly more code with no additional benefit as well as no coherent pattern. This patch makes the code uniform. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> [ remove unused variable in uuid_search ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove recover_get_good_superNikolay Borisov2018-01-31
| | | | | | | | | | Currently getting the good super really consists of just getting the first entry on the linked list, since it's the one with the highest transid. So remove the function and just use list_first_entry directly. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Factor out common print_device_infoNikolay Borisov2018-01-31
| | | | | | | | | This function has been copied twice in chunk-recover and super-recover. Factor it out into utils.c/h and use it. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Explictly state test.sh must be executableNikolay Borisov2018-01-31
| | | | | | Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: simplify version trackingDavid Sterba2018-01-31
| | | | | | | | | | | | There will be a plain file tracking the last released version. The rest will be simplified to print it where needed. The version augmented by the current git status was not working anyway since we've switched to autoconf. The result of version.h with the potential git status was generated at configure time, which does not mean it's accurate regarding the git status. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: bump zstd version in CI to 1.3.3David Sterba2018-01-31
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Print error on invalid extent item format during checkNikolay Borisov2018-01-31
| | | | | | | | | | | While performing normal mode check if the code comes across an invalid extent format it will just BUG() and exit without printing any useful information for debugging. Improve the situation by outputting the key/leaf bytenr/slot which will enable to quickly inspect the tree and see what the corruption is. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: report more specific info about invalid locationSu Yue2018-01-08
| | | | | | | | | | | Previously, it was so useless to print message like "invalid location %d". Let it print objectid and offset of the dir_item too. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fix typo in error messageDavid Sterba2018-01-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: Remove unused variable TESTSGu Jinxiang2018-01-08
| | | | | | | Variable is never used. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove unused parameter transGu Jinxiang2018-01-08
| | | | | | | | Some parameter of trans is not used indeed. Let's remove them. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: cleanup __qgroup_searchLu Fengqi2018-01-08
| | | | | | | | Replace the if statement with the switch statement, and return the appropriate value for the future use rather than directly exit. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: move btrfs_show_qgroups's error handler to __qgroup_searchLu Fengqi2018-01-08
| | | | | | | | | | | | We have to process the return value of BTRFS_IOC_TREE_SEARCH ioctl in advance, so that we can distinguish between the two case where quota is not enabled (ioctl return -ENOENT) and either parent qgroup or child qgroup does not exist (update_qgroup_relation return -ENOENT). Besides this, any error in this routine has been reported, so we don't need to report again in cmd_qgroup_show. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Fix build of btrfs-calc-sizeHans van Kranenburg2018-01-08
| | | | | | | Build would fail because it couldn't find the usage function. Signed-off-by: Hans van Kranenburg <hans@knorrie.org> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Fix progs_extra build dependenciesHans van Kranenburg2018-01-08
| | | | | | | | | | | | | The Makefile does not have a dependency path that builds dependencies for tools listed in progs_extra. E.g. doing make btrfs-show-super in a clean build environment results in: gcc: error: cmds-inspect-dump-super.o: No such file or directory Makefile:389: recipe for target 'btrfs-show-super' failed Signed-off-by: Hans van Kranenburg <hans@knorrie.org> Signed-off-by: Hugo Mills <hugo@carfax.org.uk> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: docs: update manual for mkfs --shrinkDavid Sterba2018-01-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/mkfs: verify that mkfs.btrfs rootdir+shrink behaves correctlyQu Wenruo2018-01-08
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: Use the whole file or block device to mkfs for rootdirQu Wenruo2018-01-08
| | | | | | | | | | | | | | | For --rootdir, even for large existing file or block device, it will always shrink the resulting filesystem. The problem is, mkfs.btrfs will try to calculate the dir size, and use it as @block_count to mkfs, which makes the filesystem shrunk. Fix it by trying to get the original block device or file size as @block_count, so mkfs.btrfs can use the full file/block device for --rootdir option. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/mkfs: Introduce test case to check if mkfs rootdir can ↵Qu Wenruo2018-01-08
| | | | | | | | | | | create a new file To test regression 460e93f25754 ("btrfs-progs: mkfs: check the status of file at mkfs"). Signed-off-by: Qu Wenruo <wqu@suse.com> [ update test to create a out of /tmp ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: fix regression preventing --rootdir to create fileQu Wenruo2018-01-08
| | | | | | | | | | | | | | | | Commit 460e93f25754 ("btrfs-progs: mkfs: check the status of file at mkfs") will try to check the file state before creating fs on it. The check is mostly fine for normal mkfs case, while for --rootdir option, it's allowed to create a new file if the destination file doesn't exist. Fix it by allowing non-existent file if --rootdir is specified. Fixes: 460e93f25754 ("btrfs-progs: mkfs: check the status of file at mkfs") Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: Separate shrink from rootdirQu Wenruo2018-01-08
| | | | | | | | | | | | | Make --shrink a separate option for --rootdir, and change the default to off. The shrinking behaviour is not a commonly used feature but can be useful for creating minimal pre-filled images, in one step, without requiring to mount. Signed-off-by: Qu Wenruo <wqu@suse.com> [ update changelog and error messages ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs/rootdir: Shrink fs for rootdir optionQu Wenruo2018-01-08
| | | | | | | | | | Use the new dev extent based shrink method for rootdir option. This restores the original behaviour when --rootdir will create a minimal filesystem size. Signed-off-by: Qu Wenruo <wqu@suse.com> [ update changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs/rootdir: Use over-reserve method to make size estimate easierQu Wenruo2018-01-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use an easier method to calculate the estimate device size for mkfs.btrfs --rootdir. The new method will over-estimate, but should ensure we won't encounter ENOSPC. It relies on the following data: 1) number of inodes -- for metadata chunk size 2) rounded up data size of each regular inode -- for data chunk size Total meta chunk size = round_up(nr_inode * (PATH_MAX * 3 + sectorsize), min_chunk_size) * profile_multiplier PATH_MAX is the maximum size possible for INODE_REF/DIR_INDEX/DIR_ITEM. Sectorsize is the maximum size possible for inline extent. min_chunk_size is 8M for SINGLE, and 32M for DUP, get from btrfs_alloc_chunk(). profile_multiplier is 1 for Single, 2 for DUP. Total data chunk size is much easier. Total data chunk size = round_up(total_data_usage, min_chunk_size) * profile_multiplier Total_data_usage is the sum of *rounded up* size of each regular inode use. min_chunk_size is 8M for SINGLE, 64M for DUP, get from btrfS_alloc_chunk(). Same profile_multiplier for meta. This over-estimate calculate is, of course inacurrate, but since we will later shrink the fs to its real usage, it doesn't matter much now. Signed-off-by: Qu Wenruo <wqu@suse.com> [ update comments ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: Don't use custom chunk allocator for rootdirQu Wenruo2018-01-08
| | | | | | | | | | | | | | Remove the custom chunk allocator for mkfs. It is buggy in connection to the --rootdir option and puts file data to the reerved 1M area. The feature of the custom allocator was to reserve only minimal amount of blockgroup space. This will temporarily stop working and will need an explicit request by option, added by following patches. Use the generic chunk allocator. Signed-off-by: Qu Wenruo <wqu@suse.com> [ update changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: Cleanup temporary chunks before filling rootdirQu Wenruo2018-01-08
| | | | | | | | | Cleanup of temporary chunks should be done as soon as possible, and it should be especially before doing large tree operations, like filling the filesystem when using --rootdir. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: Update allocation info before verbose outputQu Wenruo2018-01-08
| | | | | | | | | | | Since new --rootdir can allocate chunk, it will modify the chunk allocation result. This patch will update allocation info before verbose output to reflect such info. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs/rootdir: Introduce function to get end position of last ↵Qu Wenruo2018-01-08
| | | | | | | | | device extent Useful for later 'mkfs.btrfs --rootdir' shrink support. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/mkfs: Test if the minimal device size is validQu Wenruo2018-01-08
| | | | | | | | | New test case to test if the minimal device size given by "mkfs.btrfs" failure case is valid. Signed-off-by: Qu Wenruo <wqu@suse.com> [ renamed script ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: move source dir size calculation to its own filesQu Wenruo2018-01-08
| | | | | | | | Also rename the function from size_sourcedir() to mkfs_size_dir(). Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: move image creation of rootdir to its own filesQu Wenruo2018-01-08
| | | | | | | | | | | | In fact, --rootdir option is getting more and more independent from normal mkfs code. So move image creation function, make_image() and its related code to mkfs/rootdir.[ch], and rename the function to btrfs_mkfs_fill_dir(). Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs progs v4.14.1David Sterba2018-01-05
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: update CHANGES for v4.14.1David Sterba2018-01-05
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: docs: annual typo, clarity, & grammar review & fixupsNicholas D Steeves2018-01-03
| | | | | Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/convert: ensure btrfs-convert won't rollback the ↵Qu Wenruo2018-01-03
| | | | | | | | filesystem after balance Signed-off-by: Qu Wenruo <wqu@suse.com> [ add shell quotes, rename test ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Fix a bug in rollback check which overwrite return valueQu Wenruo2018-01-03
| | | | | | | | | | | | | | | | | Commit 1170ac307900 ("btrfs-progs: convert: Introduce function to check if convert image is able to be rolled back") reworked rollback check condition, by checking 1:1 mapping of each file extent. The idea itself has nothing wrong, but error handler is not implemented correctly, which over writes the return value and always try to rollback the fs even it fails to pass the check. Fix it by correctly return the error before rollback the fs. Fixes: 1170ac307900 ("btrfs-progs: convert: Introduce function to check if convert image is able to be rolled back") Reported-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>