summaryrefslogtreecommitdiff
path: root/cmds-replace.c
Commit message (Collapse)AuthorAge
* btrfs-progs: add new dev replace resultEryu Guan2014-11-25
| | | | | | | | | | | A new dev replace result was introduced by kernel commit Btrfs: return failure if btrfs_dev_replace_finishing() failed Make the userspace know about the new result too. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: only report internal dev replace result if there's a resultEryu Guan2014-11-03
| | | | | | | | | | | | | | | | | | If BTRFS_IOC_DEV_REPLACE ioctl failed, args.result usually won't be updated by the ioctl. And the arg has been initialized with 0, the result is always 0, which is BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR, and the resulting error message looks confusing: ERROR: ioctl(DEV_REPLACE_START) failed on "/mnt/btrfs": No such file or directory, no error But in case there's an internal result returned in future, don't drop the result completely, instead print dev replace result message only if the result is updated by a failed ioctl call. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: return error when canonicalize_path failedEryu Guan2014-10-10
| | | | | | | | Error out cmd_start_replace() if canonicalize_path() dstdev failed, add the missing "goto leave_with_error;" Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: show meaningful msgs for replace cmd upon raid56Gui Hecheng2014-08-22
| | | | | | | | | | | | This depends on the kernel patch: [PATCH] btrfs:replace EINVAL with EOPNOTSUPP for dev_replace This catches the EOPNOTSUPP and output msg that says dev_replace raid56 is not currently supported. Note that the msg will only be shown when run dev_replace not in background. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: canonicalize pathnames for device commandsJeff Mahoney2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mount(8) will canonicalize pathnames before passing them to the kernel. Links to e.g. /dev/sda will be resolved to /dev/sda. Links to /dev/dm-# will be resolved using the name of the device mapper table to /dev/mapper/<name>. Btrfs will use whatever name the user passes to it, regardless of whether it is canonical or not. That means that if a 'btrfs device ready' is issued on any device node pointing to the original device, it will adopt the new name instead of the name that was used during mount. Mounting using /dev/sdb2 will result in df: /dev/sdb2 209715200 39328 207577088 1% /mnt lrwxrwxrwx 1 root root 4 Jun 4 13:36 /dev/whatever-i-like -> sdb2 /dev/whatever-i-like 209715200 39328 207577088 1% /mnt Likewise, mounting with /dev/mapper/whatever and using /dev/dm-0 with a btrfs device command results in df showing /dev/dm-0. This can happen with multipath devices with friendly names enabled and doing something like 'partprobe' which (at least with our version) ends up issuing a 'change' uevent on the sysfs node. That *always* uses the dm-# name, and we get confused users. This patch does the same canonicalization of the paths that mount does so that we don't end up having inconsistent names reported by ->show_devices later. Signed-off-by: Jeff Mahoney <jeffm@suse.com> [use PATH_MAX in canonicalize_dm_name] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Replace the overkill assert with normal error message.Qu Wenruo2014-08-22
| | | | | | | | | When 'btrfs replace status' encounters an unknown dev replace status, it will cause an assert, which is somewhat overkilled and can be replaced with a normal error message. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Improve the errno string about open_path_or_dev_mnt()Qu Wenruo2014-08-22
| | | | | | | | | | | | | | | open_path_or_dev_mnt() is used to on *mounted* btrfs device or mount point, when a unmounted btrfs device is passed, errno is set to EINVAL to info the caller. If ignore the errno and just print "ERROR: can't access '%s'", end users will get confused. This patch will add check for open_path_or_dev_mnt() caller and print more meaningful error message when a unmounted btrfs device path is given. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: switch to arg_strtou64() part3Wang Shilong2014-03-21
| | | | | | | | | Switch to new helper arg_strtou64(), also check if user assign a valid super copy. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: handle error in the btrfs_prepare_deviceAnand Jain2014-01-31
| | | | | | | | | this patch will handle the strerror reporting of the error instead of printing errno, and also replaced the BUG_ON with the error handling Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: fix magic return value in cmds-replace.cWang Shilong2013-10-16
| | | | | | | | | | | | There are 3 kinds of return values in replace cancel: 0: cancel successfully. 1: usage or syntal errors 2: cancel a not started or finished replacing operations. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: use NULL instead of 0Zach Brown2013-09-03
| | | | | | | | | These were mostly in option structs but there were a few gross string pointer arguments given as 0. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: cmd_start_replace() to use test_dev_for_mkfs()Anand Jain2013-09-03
| | | | | | | | | | | | test_dev_for_mkfs() is a common place where we check if a device is fit for the btrfs use. cmd_start_replace() should make use of test_dev_for_mkfs(), and here the test_dev_for_mkfs() is further enhanced to fit the cmd_start_replace() needs. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: let user know that devid can be used if path is missingAnand Jain2013-09-03
| | | | | | | | | | | | | | | | | | | | | When the device disappear the path goes missing, and that will be the one of the reason that user will replace the device. The devid of the missing btrfs device can be obtained using the new cli option btrfs fi show --kernel And which can be used in the replace command. --- btrfs replace start /dev/sdc /dev/sde /btrfs Error: Unable to open device '/dev/sdc' Try using the devid instead of the path --- Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: Update the usage strings of some cmdsQu Wenruo2013-08-09
| | | | | | | | | | | Update the usage strings of some cmds to keep the them consistent with the source. Also some minor changes are done to fit the man page syntax. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: fix closing of opendir()Wang Shilong2013-08-09
| | | | | | | | | | valgrind complains open_file_or_dir() causes a memory leak.That is because if we open a directoy by opendir(), and then we should call closedir() to free memory. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: rework get_fs_info to remove side effectsEric Sandeen2013-03-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_fs_info() has been silently switching from a device to a mounted path as needed; the caller's filehandle was unexpectedly closed & reopened outside the caller's scope. Not so great. The callers do want "fdmnt" to be the filehandle for the mount point in all cases, though - the various ioctls act on this (not on an fd for the device). But switching it in the local scope of get_fs_info is incorrect; it just so happens that *usually* the fd number is unchanged. So - use the new helpers to detect when an argument is a block device, and open the the mounted path more obviously / explicitly for ioctl use, storing the filehandle in fdmnt. Then, in get_fs_info, ignore the fd completely, and use the path on the argument to determine if the caller wanted to act on just that device, or on all devices for the filesystem. Affects those commands which are documented to accept either a block device or a path: * btrfs device stats * btrfs replace start * btrfs scrub start * btrfs scrub status Signed-off-by: Eric Sandeen <sandeen@redhat.com>
* btrfs-progs: Issue warnings if ioctls fail in sigint handlersEric Sandeen2013-03-10
| | | | | | | | | The two sigint handlers issue ioctls to clean up, but if they fail, noone would know. I'm not sure there is any other error handling to be done at this point, but a notification seems wise. Signed-off-by: Eric Sandeen <sandeen@redhat.com>
* btrfs-progs: free allocated di_args in cmd_start_replaceEric Sandeen2013-02-27
| | | | | | | We only freed this allocation in error paths, and leaked a bit when it went out of scope normally. Signed-off-by: Eric Sandeen <sandeen@redhat.com>
* btrfs-progs: fix open error test in cmd_start_replaceEric Sandeen2013-02-27
| | | | | | open() returns a negative fd on failure, not 0. Signed-off-by: Eric Sandeen <sandeen@redhat.com>
* Btrfs-progs: add support for device replace procedureStefan Behrens2013-01-31
This is the user mode part of the device replace patch series. The command group "btrfs replace" is added with three commands: - btrfs replace start srcdev|srcdevid targetdev [-Bfr] mount_point - btrfs replace status mount_point [-1] - btrfs replace cancel mount_point Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>