summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* btrfs-progs: mkfs: print version info firstDavid Sterba2015-11-02
| | | | | | The version info should not be preceded by any messages. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: image: fix bogus check after cpu on-line detectionDavid Sterba2015-11-02
| | | | | | | | Comparing unsigned type for <= 0 does not make much sense, we should really check the signed value returned by sysconf. Resolves-coverity-id: 1324536 Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Avoid use pointer in handle_optionsZhao Lei2015-11-02
| | | | | | | | | | | | | | We use pointer of argc and argv in handle_options() because they are necessary in very old code which are not exist now. This patch move to use argc and argv directly in handle_options(), alone with following update: 1: rename handle_options() to check_options() to fit its function. 2: cleanup for condition in handle_options() to make line short. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Fix uninitialized key.type for btrfs_find_free_objectidZhao Lei2015-11-02
| | | | | | | To avoid using uninitialized value in btrfs_search_slot(). Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Fix negative eb's ref_cnt in btrfs-calc-sizeZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | btrfs-calc-size show following warning: # btrfs-calc-size /dev/sda6 Calculating size of root tree ... extent_io.c:582: free_extent_buffer: Assertion `eb->refs < 0` failed. ./btrfs-calc-size[0x41d642] ./btrfs-calc-size(free_extent_buffer+0x70)[0x41e1c1] ./btrfs-calc-size(btrfs_free_fs_root+0x11)[0x40e1e8] ./btrfs-calc-size[0x40e215] ./btrfs-calc-size(rb_free_nodes+0x1d)[0x4326fe] ./btrfs-calc-size(close_ctree+0x3f3)[0x40f9ea] ./btrfs-calc-size(main+0x200)[0x431b4e] /lib64/libc.so.6(__libc_start_main+0xf5)[0x3858621d65] ./btrfs-calc-size[0x407009] Reason: path in calc_root_size() is only used to save node data, it don't hold ref_cnt for each eb in. Using btrfs_free_path() to free path will reduce these eb again, and cause many problems, as negative ref_cnt or invalid memory access. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix floating point exception for btrfs-calc-sizeZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | Current code exit with floating point exception on a blank fs: # btrfs-calc-size -b /dev/sda6 Calculating size of root tree Total size: 16384 Inline data: 0 Total seeks: 0 Forward seeks: 0 Backward seeks: 0 Floating point exception This patch add a condition check for above case. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add initial tests/READMEDavid Sterba2015-11-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add an initial READMEDavid Sterba2015-11-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: remove stray message about forced mixed-bgDavid Sterba2015-11-02
| | | | | | | | We no longer force mixed-bg mode since "Btrfs-progs: Do not force mixed block group creation unless '-M' option is specified", the message is not relevant anymore. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add 003-mixed-with-wrong-nodesizeDavid Sterba2015-11-02
| | | | | | | | | Mixed mode needs equal sectorsize and nodesize. This was fixed by "Btrfs-progs: Prevent creation of filesystem with 'mixed bgs' and having differing sectorsize and nodesize" Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: do not log output of run_mayfail to terminalDavid Sterba2015-11-02
| | | | | | | No need to log expected failures to the terminal, the results file is fine; pass the return value of the command. Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs-progs: Prevent creation of filesystem with 'mixed bgs' and having ↵Chandan Rajendra2015-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | differing sectorsize and nodesize. mkfs.btrfs allows creation of Btrfs filesystem instances with mixed block group feature enabled and having a sectorsize different from nodesize. For e.g: [root@localhost btrfs-progs]# mkfs.btrfs -f -M -s 4096 -n 16384 /dev/loop0 Forcing mixed metadata/data groups btrfs-progs v3.19-rc2-404-gbbbd18e-dirty See http://btrfs.wiki.kernel.org for more information. Performing full device TRIM (4.00GiB) ... Label: (null) UUID: c82b5720-6d88-4fa1-ac05-d0d4cb797fd5 Node size: 16384 Sector size: 4096 Filesystem size: 4.00GiB Block group profiles: Data+Metadata: single 8.00MiB System: single 4.00MiB SSD detected: no Incompat features: mixed-bg, extref, skinny-metadata Number of devices: 1 Devices: ID SIZE PATH 1 4.00GiB /dev/loop6 This commit fixes the issue by setting BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS feature bit before checking the validity of nodesize that was specified on the command line. Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use system's default path for math.hZhao Lei2015-11-02
| | | | | | | | | | | | Line of #include "math.h" in extent-tree.c using quotas is historical reason, (we had custom math.h before). Use "<>" instead of quotes in this header file. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Add missing close_ctree to btrfs-select-super.cZhao Lei2015-11-02
| | | | | | | Add missing close_ctree() to btrfs-select-super.c to avoid memory leak. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Add all missing btrfs_close_all_devices to standalone toolsZhao Lei2015-11-02
| | | | | | | | This patch add all missing btrfs_close_all_devices() to standalone tools in btrfs progs, to avoid memory leak. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove all btrfs_close_all_devices in sub-commandZhao Lei2015-11-02
| | | | | | | | | Since we have btrfs_close_all_devices() in btrfs's main entrance, it is not necessary to call btrfs_close_all_devices() separately in each sub-command. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: btrfs: Add missing btrfs_close_all_devices for btrfs commandZhao Lei2015-11-02
| | | | | | | | | | Adding a btrfs_close_all_devices() after command callback in btrfs.c can force-close all opened device before program exit, to avoid memory leak in all btrfs sub-command. Suggested-by: David Sterba <dsterba@suse.cz> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add support for command instrumentationDavid Sterba2015-11-02
| | | | | | | | | | | | | | | | | | Add a way to wrap commands executed by the tests. This means the common wrappers: run_check, run_check_stdout and run_mayfail , with the exception of the use root_helper. The contents of the shell variable INSTRUMENT are prepended to the command, without quotes. Use with care. Example: this has been tested with valgrind, the output goes to the RESULTS file. $ INSTRUMENT=valgrind make test-misc Any use of root_helper/SUDO_HELPER will skip the instrumentation. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: 001-simple-unmounted: iterate over fuzzed images and run ↵David Sterba2015-11-02
| | | | | | check Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add test driver for fuzzed imagesDavid Sterba2015-11-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix missing initialization of list head for dev_listAnand Jain2015-11-02
| | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix uninitialized copy of btrfs_fs_devices listAnand Jain2015-11-02
| | | | | | | | | | | | | Noticed that at print_one_uuid() some of the members of btrfs_fs_devices contained some junk values. It took a while to dig this further, and found that we make a local copy of the btrfs_fs_devices list at search_umounted_fs_uuids() and wasn't initialized properly. Fixed using using calloc instead of malloc. Signed-off-by: Anand Jain <anand.jain@oracle.com> [ switched to calloc ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: do not run sudo helper tests if not necessaryDavid Sterba2015-11-02
| | | | | | | | We use setup_root_helper in some helpers to make sure that the sudo helper is set up, and adding that to each test. Make the real test run only once. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: set default test image size to 2GDavid Sterba2015-11-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add 010-convert-delete-ext2-subvolDavid Sterba2015-11-02
| | | | | | | | Testcase for "Btrfs-progs: fix btrfs-convert rollback to check ROOT_BACKREF", make sure we don't try a rollback if the ext2_subvol is half-deleted. Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs-progs: fix btrfs-convert rollback to check ROOT_BACKREFLiu Bo2015-11-02
| | | | | | | | | | | | | | | Btrfs has changed to delete subvolume/snapshot asynchronously, which means that after umount itself, if we've already deleted 'ext2_saved', rollback can still be completed. So this adds a check for ROOT_BACKREF before checking ROOT_ITEM since ROOT_BACKREF is immediately not in the btree after ioctl(BTRFS_IOC_SNAP_DESTROY) returns. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ updated error messages ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mute coverity warnings about deadcodeEryu Guan2015-11-02
| | | | | | | | Coverity reports execution cannot reach this statements. So put WARN_ON in if-else conditions. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add 002-no-force-mixed-on-small-volumeDavid Sterba2015-11-02
| | | | | | Verify that we do not force mixed block groups on small volumes anymore. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add 001-basic-profiles mkfs testsDavid Sterba2015-11-02
| | | | | | Basic test to cover block group profile combinations. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add mkfs testsDavid Sterba2015-11-02
| | | | | | Mkfs deserves it's own. Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs-progs: Do not force mixed block group creation unless '-M' option is ↵Chandan Rajendra2015-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | specified When creating small Btrfs filesystem instances (i.e. filesystem size <= 1GiB), mkfs.btrfs fails if both sectorsize and nodesize are specified on the command line and sectorsize != nodesize, since mixed block groups involves both data and metadata blocks sharing the same block group. This is an incorrect behavior when '-M' option isn't specified on the command line. This commit makes optional the creation of mixed block groups i.e. Mixed block groups are created only when -M option is specified on the command line. Since we now allow small filesystem instances with sectorsize != nodesize to be created, we can end up in the following situation, [root@localhost ~]# mkfs.btrfs -f -n 65536 /dev/loop0 btrfs-progs v3.19-rc2-405-g976307c See http://btrfs.wiki.kernel.org for more information. Performing full device TRIM (512.00MiB) ... Label: (null) UUID: 49fab72e-0c8b-466b-a3ca-d1bfe56475f0 Node size: 65536 Sector size: 4096 Filesystem size: 512.00MiB Block group profiles: Data: single 8.00MiB Metadata: DUP 40.00MiB System: DUP 12.00MiB SSD detected: no Incompat features: extref, skinny-metadata Number of devices: 1 Devices: ID SIZE PATH 1 512.00MiB /dev/loop0 [root@localhost ~]# mount /dev/loop0 /mnt/ mount: mount /dev/loop0 on /mnt failed: No space left on device The ENOSPC occurs during the creation of the UUID tree. This is because of things like large metadata block size, DUP mode used for metadata and global reservation consuming space. Also, large nodesize does not make sense on small filesystems, hence this should not be an issue. Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add helpers to print rangesDavid Sterba2015-11-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add helpers for parsing 32bit rangesDavid Sterba2015-11-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: extend parse_range API to accept a relaxed rangeDavid Sterba2015-11-02
| | | | | | | In some cases we want to accept a range of type [a..a]. Add a new function to do the 'a < b' check for the caller and use it. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: do not modify the string in parse_rangeDavid Sterba2015-11-02
| | | | | | | It's passed as const but we modify it through 'dots'. This would break parsing the string multiple times. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: cleanup and comment parse_rangeDavid Sterba2015-11-02
| | | | | | Simplify a check and unindent some code. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: device add: cleanup argument handlingAnand Jain2015-11-02
| | | | | | | | This is needed by the patch which introduces new devid option for the btrfs device delete. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move is_numerical() helper to utils and renameAnand Jain2015-11-02
| | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> [ moved to util.c and renamed ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: return -ENOMEM properly in btrfs_read_block_groups()Eryu Guan2015-11-02
| | | | | | | | Breaking from the while loop makes ret overwritten to zero, goto error label directly and return -ENOMEM. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix memory leak in cmd_qgroup_show()Eryu Guan2015-11-02
| | | | | | | filter_set and comparer_set should be freed on return. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove identical branch in record_extent()Eryu Guan2015-11-02
| | | | | | | | | The same code is executed when the condition "ret" is true or false, because the code in the if-then branch and after the if statement is identical. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix memory leak on error pathEryu Guan2015-11-02
| | | | | | | dev_scans and t_scans should be freed on malloc error. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: save and return error number correctly in check_chunks_and_extentsEryu Guan2015-11-02
| | | | | | | | The variable "err" is assigned to "ret" then "ret" gets overwritten by check_extent_refs() before "ret" can be used. Reported by Coverity. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix leak of "path" in btrfs_find_item() error pathsEryu Guan2015-11-02
| | | | | | | path needs to be freed before return. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fragments: use btrfs_open_dir for btrfs-fragments commandZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | We can use btrfs_open_dir() to check whether target dir is in btrfs's mount point before open, instead of checking it in deeper code, and return fuzzy error message. Before patch: ./btrfs-fragments -o 123 /mnt/tmp1 ERROR: can't perform the search After patch: # ./btrfs-fragments -o 123 /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: replace: use btrfs_open_dir for btrfs replace commandZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | | | | | We can use btrfs_open_dir() to check whether target dir is in btrfs's mount point before open, instead of checking it in kernel space of ioctl, and return fuzzy error message. Before patch: # ./btrfs replace cancel /mnt/tmp1 ERROR: ioctl(DEV_REPLACE_CANCEL) failed on "/mnt/tmp1": Inappropriate ioctl for device # ./btrfs replace status /mnt/tmp1 ERROR: ioctl(DEV_REPLACE_STATUS) failed on "/mnt/tmp1": Inappropriate ioctl for device After patch: # ./btrfs replace cancel /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs replace status /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use btrfs_open_dir in open_path_or_dev_mntZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | | | | | | | Use btrfs_open_dir() in open_path_or_dev_mnt() to make the function return error when target is neither block device nor btrfs mount point. Also add "verbose" argument to let function output common error message instead of putting duplicated lines in caller. Before patch: # ./btrfs device stats /mnt/tmp1 ERROR: getting dev info for devstats failed: Inappropriate ioctl for device # ./btrfs replace start /dev/vdd /dev/vde /mnt/tmp1 ERROR: ioctl(DEV_REPLACE_STATUS) failed on "/mnt/tmp1": Inappropriate ioctl for device After patch: # ./btrfs device stats /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs replace start /dev/vdd /dev/vde /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: quota: use btrfs_open_dir for btrfs quota commandZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | We can use btrfs_open_dir() to check whether target dir is in btrfs's mount point before open, instead of checking it in kernel space of ioctl, and return fuzzy error message. Before patch: # ./btrfs quota enable /mnt/tmp1 ERROR: quota command failed: Inappropriate ioctl for device # ./btrfs quota disable /mnt/tmp1 ERROR: quota command failed: Inappropriate ioctl for device # ./btrfs quota rescan /mnt/tmp1 ERROR: quota rescan failed: Inappropriate ioctl for device # After patch: # ./btrfs quota enable /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs quota disable /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs quota rescan /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: use btrfs_open_dir for btrfs qgroup commandZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can use btrfs_open_dir() to check whether target dir is in btrfs's mount point before open, instead of checking it in kernel space of ioctl, and return fuzzy error message. Before patch: # ./btrfs qgroup create 1/5 /mnt/tmp1 ERROR: unable to create quota group: Inappropriate ioctl for device # # ./btrfs qgroup assign 1/5 2/5 /mnt/tmp1 ERROR: unable to assign quota group: Inappropriate ioctl for device # # ./btrfs qgroup show /mnt/tmp1 ERROR: can't perform the search - Inappropriate ioctl for device ERROR: can't list qgroups: Inappropriate ioctl for device # # ./btrfs qgroup limit 1G 1/5 /mnt/tmp1 ERROR: unable to limit requested quota group: Inappropriate ioctl for device After patch: # ./btrfs qgroup create 1/5 /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs qgroup assign 1/5 2/5 /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs qgroup show /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs qgroup limit 1G 1/5 /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: inspect: use btrfs_open_dir for btrfs inspect commandZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | We can use btrfs_open_dir() to check whether target dir is in btrfs's mount point before open, instead of checking it in kernel space of ioctl, and return fuzzy error message. Before patch: # ./btrfs inspect-internal rootid /mnt/tmp1 ERROR: Failed to lookup root id - Inappropriate ioctl for device btrfs inspect-internal rootid: rootid failed with ret=-1 # ./btrfs inspect-internal inode-resolve 256 /mnt/tmp1 ioctl ret=-1, error: Inappropriate ioctl for device # ./btrfs inspect-internal min-dev-size /mnt/tmp1 Error invoking tree search ioctl: Inappropriate ioctl for device After patch: # ./btrfs inspect-internal rootid /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs inspect-internal inode-resolve 256 /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs inspect-internal min-dev-size /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>