summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* 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>
* btrfs-progs: inspect: set return value of error caseZhao Lei2015-11-02
| | | | | | | | In case of open_file_or_dir() failed, ret is not set to right value, and the function will return unwanted value(ret of sprintf). Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: inspect: Bypass unnecessary clean function in open_errorZhao Lei2015-11-02
| | | | | | | No need to cleanup fd in open_fail case, because it is not opened. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: balance: use btrfs_open_dir for btrfs balance 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 balance start /mnt/tmp ERROR: error during balancing '/mnt/tmp' - Inappropriate ioctl for device There may be more info in syslog - try dmesg | tail # After patch: # btrfs balance start /mnt/tmp ERROR: not btrfs filesystem: /mnt/tmp # Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: filesystem: use btrfs_open_dir for btrfs filesystem 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: # (/mnt/tmp is not btrfs mountpoint) # # btrfs filesystem df /mnt/tmp ERROR: couldn't get space info - Inappropriate ioctl for device ERROR: get_df failed Inappropriate ioctl for device # After patch: # ./btrfs filesystem df /mnt/tmp ERROR: not btrfs filesystem: /mnt/tmp # Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: subvolume: use btrfs_open_dir for btrfs subvolume 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: # (/mnt/tmp is not btrfs mountpoint) # # btrfs subvolume create /mnt/tmp/123 Create subvolume '/mnt/tmp/123' ERROR: cannot create subvolume - Inappropriate ioctl for device # After patch: # btrfs subvolume create /mnt/tmp/123 ERROR: not btrfs filesystem: /mnt/tmp # Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: print root item's last_snapshot valueLakshmipathi.G2015-11-02
| | | | | | | | Include last_snapshot value in print_root(). With btrfs-debug-tree, it helps to identify whether its a snapshot-ed subvolume or not. Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: docs: add html build targetDavid Sterba2015-11-02
| | | | | | | | | | We can easily build the documentation in html format: $ make html in the Documentation directory. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: make support for static checkers more genericDavid Sterba2015-10-21
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: update help textDavid Sterba2015-10-21
| | | | | | Add some missing options and add a high-level description. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: a bit of makefile documentationDavid Sterba2015-10-21
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: allow to build with various compiler warningsDavid Sterba2015-10-21
| | | | | | | | | | Copied from linux kernel, 'make W=1' will build with various additional warnings turned on. There are 3 levels, combinations are possible. The build is quite noisy, not all warnings need to be fixed. A specific warning can be turned on by 'make EXTRA_CFLAGS=-Wsomething'. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: print commands on terminal if requestedDavid Sterba2015-10-21
| | | | | | | | | Set the variable TEST_LOG=tty (in the enviroment or as parameter to make) to print commands executed by 'run_check' helpers to terminal (ie. /dev/tty). This might be useful to see the test progress beside watching the results file. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: misc tests: add 009-subvolume-sync-must-waitDavid Sterba2015-10-21
| | | | | | | Test to verify that subovolume sync waits until the subvolume is cleaned. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use calloc instead of malloc+memsetSilvio Fricke2015-10-21
| | | | | | | | | | | | | | | | | | | | | | This patch is generated from a coccinelle semantic patch: identifier t; expression e; statement s; @@ -t = malloc(e); +t = calloc(1, e); ( if (!t) s | if (t == NULL) s | ) -memset(t, 0, e); Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com> [squashed patches into one] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use common warning/error for cmds-scrub.cZhao Lei2015-10-21
| | | | | | | | | | Use common warning/error functions in cmds-scrub.c, it can make message format unified and make code simple. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> [removed ending newlines from messages] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Introduce warning and error for common useZhao Lei2015-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current code use fprintf(stderr, "...") to output warnning and error information. The error message have different style, as: # grep fprintf *.c fprintf(stderr, "Open ctree failed\n"); fprintf(stderr, "%s: open ctree failed\n", __func__); fprintf(stderr, "ERROR: cannot open ctree\n"); ... And sometimes, we forgot add tailed '\n', or use printf instead, as in current code: printf("warning, device %llu is missing\n", This patch introduce warning() and error() as common function, to make: 1: Each warning and error information have same format 2: Easy to search/change all error message 3: Easy to modify function's internal for debug or other requirement, for example: print function/linenumber in error() dumpstack in error() add some trace for some style of message add support for -v, -vv, ... support for locales custom output functions support some special device/tty Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> [print newline after the message] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: add progress indicatorSilvio Fricke2015-10-21
| | | | | | Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com> [minor updates] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add more superblock validation checksQu Wenruo2015-10-21
| | | | | | | | | | | | | | Now btrfs-progs will have much more strict superblock checks based on kernel superblock checks. This should prevent crashes or invalid memory access on crafted or fuzzed images. Based on kernel commit c926093ec516f5d316ecdf8c1be11f577ac71b85 . Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [added reference to kernel and comments] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Read the whole superblock instead of struct btrfs_super_blockQu Wenruo2015-10-21
| | | | | | | | | | | Before the patch, btrfs-progs will only read sizeof(struct btrfs_super_block) and restore it into super_copy. This makes checksum check for superblock impossible. Change it to read the whole superblock. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: enhance error message with status from kernel and errnoZhao Lei2015-10-19
| | | | | | | | | | | | | | | Scrub output prints the following error message in my test: ERROR: scrubbing /var/ltf/tester/scratch_mnt failed for device id 5 (Success) It is caused by a broken kernel and fs, but the we need to avoid printing both "error and success" on one line as above. This patch modified above message to: ERROR: scrubbing /var/ltf/tester/scratch_mnt failed for device id 5: ret=1, errno=0 (Success) Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> [minor updates in formatting] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use switch instead of a series of ifs for output error messageZhao Lei2015-10-19
| | | | | Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Avoid printing useless warning in fsck testsZhao Lei2015-10-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 002-bad-transid outout 'transid verify failed' message in screen which is just a warning in btrfs-image in normal condition of this test. This patch move above warning into $RESULTS, to: 1: Avoid trouble screen output 2: Let user known detail if other error happened in btrfs-image Before patch: # ./fsck-tests.sh [TEST] 001-bad-file-extent-bytenr [TEST] 002-bad-transid parent transid verify failed on 29360128 wanted 9 found 755944791 parent transid verify failed on 29360128 wanted 9 found 755944791 Ignoring transid failure [TEST] 003-shift-offsets [TEST] 004-no-dir-index ... After patch: # ./fsck-tests.sh [TEST] 001-bad-file-extent-bytenr [TEST] 002-bad-transid [TEST] 003-shift-offsets [TEST] 004-no-dir-index ... Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck: Add check for extent and parent chunk typeQu Wenruo2015-10-19
| | | | | | | | | | | | | | There is a bug in btrfs-convert in 4.1.2, even we don't allow mixed block group for converted image, btrfs-convert will still create image with data and metadata inside one chunk. And further more, the chunk type is still DATA or METADATA, not DATA|METADATA (not mixed). So add btrfsck check for it right now. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Introduce misc-tests/008-leaf-crossing-stripesZhao Lei2015-10-19
| | | | | | | | | | | | | | | | | | | | | To check is btrfs-convert create bad filesystem with leaf across stripes. It is happened in progs version <=v4.1.2, and fixed by patch titled: btrfs: convert: Avoid allocating metadata extent crossing stripe boundary which was merged in v4.2. Notice thar this testcase can not report error in old version of btrfs-progs, because "btrfs check" can't check this type of error in those version, but we have another testcase in fsck-tests, to check is "btrfs check" support this check. So, the above 2 testcase together can check leaf-crossing-stripes bug in all versions. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> [renamed and other minor changes] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Introduce fsck-tests/018-leaf-crossing-stripesZhao Lei2015-10-19
| | | | | | | | | | | To test if fsck can check detec "leaf crossing stripes". This function was introduced from patch titled: btrfs-progs: fsck: Check if a metadata tree block crossing stripe boundary Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> [renamed and other minor changes] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Move extract_image out of check_all_images for common useZhao Lei2015-10-19
| | | | | | | | | | Move code for extract image file to a function from check_all_images() for common use, so caller can use this function to extrace single image file. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> [minor reformatting and updates] Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs progs v4.2.3David Sterba2015-10-19
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: restore: fix off-by-one len checkVincent Stehlé2015-10-16
| | | | | | | | | Fix a check of len versus PATH_MAX in function copy_symlink(), to account for the terminating null byte. Resolves-Coverity-CID: 1296749 Signed-off-by: Vincent Stehlé <vincent.stehle@freescale.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: subvol sync: fix reversed conditionDavid Sterba2015-10-07
| | | | | | | | | | | In my local change to 07cc891d1d9819d5cf0628af555e7727d289cf7b ("btrfs-progs: Simplify all-subvolumn-clean condition for wait_for_subvolume_cleaning") that reversed the meaning of the variable dirty -> clean, I made a mistake and broke 'subvol sync' that will not wait as expected and ends prematurely. Zhao Lei's original patch worked. CC: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Print different error message if convert partly failed.Qu Wenruo2015-10-07
| | | | | | | | | | | | | When testing under libguestfs, btrfs-convert will never succeed to fix chunk map, and always fails. But in that case, it's already a mountable btrfs. So better to info user with different error message for that case. The root cause of it is still under investigation. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: optimize not to scan repeated fsid mount pointsAnand Jain2015-10-07
| | | | | | | | | | | | | | | | | | | | | | | | fsid can be mounted multiple times, with different subvolid. And we don't have to scan a mount point if we already have that in the scanned list. And thus nicely avoids the following warning with multiple subvol mounts on older kernel like 2.6.32 where BTRFS_IOC_GET_FSLABEL ioctl does not exist. ./btrfs fi show -m Label: none uuid: 31845933-611e-422d-ae6f-386e57ad81aa Total devices 2 FS bytes used 172.00KiB devid 1 size 3.00GiB used 642.38MiB path /dev/sdd devid 2 size 3.00GiB used 622.38MiB path /dev/sde warning, device 2 is missing warning devid 2 not found already warning, device 2 is missing warning devid 2 not found already Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs progs v4.2.2David Sterba2015-10-05
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix error checking in load_device_infoDavid Sterba2015-10-02
| | | | | | | | | | | load_device_info queries the FS_INFO ioctl and this may fail with EPERM on older kernels. The check did not verify the ioctl return value and incorrectly returned EPERM if it was previously stored in errno. This fixes 'btrfs fi usage' that will print the overall summary for all users (provided that the FS_INFO ioctl is already unprivileged). Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix double free during scanningDavid Sterba2015-10-02
| | | | | | | | | | If there are different devices mounted to the same directory we can run into double free issue in the scanning code and this can lead to a crash. The dev_info_arg buffer allocation get_fs_info might be skipped, eg. if the FS_INFO ioctl fails due to EPERM in older kernels. Reset the pointer before each loop starts. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: fix memset rangeSilvio Fricke2015-10-02
| | | | | Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tasks info->id is a pthread_t and should not set to -1Silvio Fricke2015-10-02
| | | | | Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Show detail error message when write sb failed in ↵Zhao Lei2015-10-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | write_dev_supers() fsck-tests.sh failed and show following message in my node: # ./fsck-tests.sh [TEST] 001-bad-file-extent-bytenr disk-io.c:1444: write_dev_supers: Assertion `ret != BTRFS_SUPER_INFO_SIZE` failed. /root/btrfsprogs/btrfs-image(write_all_supers+0x2d2)[0x41031c] /root/btrfsprogs/btrfs-image(write_ctree_super+0xc5)[0x41042e] /root/btrfsprogs/btrfs-image(btrfs_commit_transaction+0x208)[0x410976] /root/btrfsprogs/btrfs-image[0x438780] /root/btrfsprogs/btrfs-image(main+0x3d5)[0x438c5c] /lib64/libc.so.6(__libc_start_main+0xfd)[0x335e01ecdd] /root/btrfsprogs/btrfs-image[0x4074e9] failed to restore image /root/btrfsprogs/tests/fsck-tests/001-bad-file-extent-bytenr/default_case.img # # cat fsck-tests-results.txt === Entering /root/btrfsprogs/tests/fsck-tests/001-bad-file-extent-bytenr restoring image default_case.img failed to restore image /root/btrfsprogs/tests/fsck-tests/001-bad-file-extent-bytenr/default_case.img # Reason: I run above test in a NFS mountpoint, it don't have enouth space to write all superblock to image file, and don't support sparse file. So write_dev_supers() failed in writing sb and output above message. It takes me quite of time to know what happened, we can save these time by output exact information in write-sb-fail case. After patch: # ./fsck-tests.sh [TEST] 001-bad-file-extent-bytenr WARNING: Write sb failed: File too large disk-io.c:1492: write_all_supers: Assertion `ret` failed. ... # Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Increase running state's priority in stat outputZhao Lei2015-10-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Anthony Plack <anthony@plack.net> reported a output bug in maillist: title: btrfs-progs SCRUB reporting aborted but still running - minor btrfs scrub status report it was aborted but still runs to completion. # btrfs scrub status /mnt/data scrub status for f591ac13-1a69-476d-bd30-346f87a491da scrub started at Mon Apr 27 06:48:44 2015 and was aborted after 1089 seconds total bytes scrubbed: 1.02TiB with 0 errors # # btrfs scrub status /mnt/data scrub status for f591ac13-1a69-476d-bd30-346f87a491da scrub started at Mon Apr 27 06:48:44 2015 and was aborted after 1664 seconds total bytes scrubbed: 1.53TiB with 0 errors # ... Reason: When scrub multi-device simultaneously, if some device canceled, and some device is still running, cancel state have higher priority to be outputed in global report. So we can see "scrub aborted" in status line, with running-time keeps increased. Fix: We can increase running state's priority in output, if there is some device in scrub state, we output running state instead of cancelled state. Reported-by: Anthony Plack <anthony@plack.net> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix is_block_device() return checksAnand Jain2015-10-02
| | | | | | | | | | | | | | it was highlighted to me is_block_device(), returns 1 if the file is a block device, < 0 in case of an error (eg: file not found) 0 otherwise This patch makes proper return checks at all the places where is_block_device() is used. Thanks to Goffredo. Signed-off-by: Anand Jain <anand.jain@oracle.com> Suggested-by: Goffredo Baroncelli <kreijack@inwind.it> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: make sure that is_block_device will return only 0/1David Sterba2015-10-02
| | | | | | The macro return nonzero, we'll test against 0/1 (or < 0). Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: utils: Check nodesize against featuresQu Wenruo2015-10-02
| | | | | | | | | | | Check nodesize against features, not only sectorsize. In fact, one of the btrfs-convert and mkfs differs in the nodesize check. This patch also provides the basis for later btrfs-convert fix. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: provide fail safe for BTRFS_IOC_GET_FSLABEL ioctlAnand Jain2015-10-02
| | | | | | | | | | | | | Old kernels before 3.9 do not provide ioctl BTRFS_IOC_GET_FSLABEL. So we need to provide a fail safe logic for btrfs-progs running on those kernel. In this patch when get_label_mounted() fails on the old kernel it will fail back to the old method and uses get_label_unmounted(), where it will read from the disk directly. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs progs v4.2.1David Sterba2015-09-20
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add '-o loop' to mount command line in convert-tests.shZhao Lei2015-09-20
| | | | | | | | | | | | | | | To fix following bug: # ./convert-tests.sh [TEST] ext2 4k nodesize, btrfs defaults failed: mount /root/btrfsprogs/tests/test.img /root/btrfsprogs/tests/mnt # tail convert-tests-results.txt ... ############### mount /root/btrfsprogs/tests/test.img /root/btrfsprogs/tests/mnt mount: /root/btrfsprogs/tests/test.img is not a block device (maybe try `-o loop'?) failed: mount /root/btrfsprogs/tests/test.img /root/btrfsprogs/tests/mnt Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: docs: add option variants, defaults and versions to mount optionsDavid Sterba2015-09-15
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: cleanup, update function definitions to be ANSI conformantDavid Sterba2015-09-14
| | | | | | | | | | Sparse reports: warning: non-ANSI function declaration of function and we're using func(void) elsewhere. Signed-off-by: David Sterba <dsterba@suse.com>