This patch introduces new option <devid> for the command
btrfs device delete <device_path|devid>[..] <mnt>
In a user reported issue on a 3-disk-RAID1, one disk failed with its
SB unreadable. Now with this patch user will have a choice to delete
the device using devid.
The other method we could do, is to match the input device_path
to the available device_paths with in the kernel. But that won't
work in all the cases, like what if user provided mapper path
when the path within the kernel is a non-mapper path.
This patch depends on the below kernel patch for the new feature to work,
however it will fail-back to the old interface for the kernel without the
patch
Btrfs: Introduce device delete by devid
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
The number of arguments which is allowed to pass became wrong
from the following commit.
commit 176aeca9a148c5e29de0 ("btrfs-progs: add getopt stubs where needed")
* actual result
===========================================================
# ./btrfs prop get /btrfs label
label=foo
# ./btrfs fi label /btrfs
btrfs filesystem label: too few arguments
usage: btrfs filesystem label [<device>|<mount_point>] [<newlabel>]
Get or change the label of a filesystem
With one argument, get the label of filesystem on <device>.
If <newlabel> is passed, set the filesystem label to <newlabel>.
# ./btrfs fi label /btrfs bar
foo
# ./btrfs prop get /btrfs label
label=foo
===========================================================
* expected result
===========================================================
# ./btrfs prop get /btrfs label
label=foo
# ./btrfs fi label /btrfs
foo
# ./btrfs fi label /btrfs bar
# ./btrfs prop get /btrfs label
label=bar
===========================================================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Fix the following bug.
================================
# btrfs device scan -- /dev/sdb
ERROR: not a block device: --
================================
It should work as follow.
================================
# ./btrfs device scan -- /dev/sdb
Scanning for Btrfs filesystems in '/dev/sdb'
================================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
When 'btrfs device scan' command is invoked, it scans all devices,
check them for btrfs superblock and add devices with btrfs to a list.
Next, each device from the list is passed to kernel where it is handled
in the btrfs_scan_one_device() function. This function can, for example,
return -EBUSY when device contains superblock matched to existing and
mounted filesystem (if this device was pulled out from RAID and
connected again after some time).
btrfs tool stops device scan if any device has been failed to add, so
other existing devices with (possibly) valid FS will never be reached.
Fix this by remove stopping at any failure in the btrfs_register_all_devices(),
just return error count. btrfs_scan_one_device() reports any kind of
error already.
Signed-off-by: Yauhen Kharuzhy <yauhen.kharuzhy@zavadatar.com>
[ initialize err to 0 ]
Signed-off-by: David Sterba <dsterba@suse.com>
For practical purposes teach -t about the human readable names of the
trees in addition to the numerical id. The name syntax is flexible.
Signed-off-by: David Sterba <dsterba@suse.com>
The version information could be useful addition to the dump, print it
before we attempt to open the filesystem.
Signed-off-by: David Sterba <dsterba@suse.com>
PAGE_CACHE_SIZE is hardcoded to 4K in cmds-restore.c. Correct
value should be sector size. Fix this through replacing
hardcoded 4K to sectorsize.
Signed-off-by: Feifei Xu <xufeifei@linux.vnet.ibm.com>
Signed-off-by: David Sterba <dsterba@suse.com>
The need to specify the chunk root is not that common, we will reserve
the short option -c for later use.
Signed-off-by: David Sterba <dsterba@suse.com>
Add new btrfsck option, '--chunk-root', to specify chunk root bytenr.
And allow open_ctree_fs_info() function accept chunk_root_bytenr to
override the bytenr in superblock. This will be mainly used when chunk
tree corruption.
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
If parameter for pretty_size is smaller than default base(1024),
pretty_size() will output wrong unit.
For example, pretty_size(1008) will output '0.98B' not '1008B' or
'0.98KiB'.
The cause is, for default base and auto-detect unit, base will be 1024
but num_divs is still 0, last result will still be divided by base,
causing the bug.
Fix it by checking num_divs in default case, and if num_divs is 0,
change base to 1.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
kerncompat.h header file is part of libbtrfs API. min/max macros cause
conflict while building projects dependant on libbtrfs. Moving those
macros to btrfs-progs internal header file fixes the conflict.
Signed-off-by: Ondrej Kozina <okozina@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Copy-pasted description found at mkfs.btrfs. I did not bother with
feature list as it seemed to be incomplete.
Signed-off-by: David Sterba <dsterba@suse.com>
The message
"warning devid %llu not found already\n",
does not seem to be too useful, it appears during several commands and
sometimes repeatedly.
Signed-off-by: David Sterba <dsterba@suse.com>
We use a device mapper device on top of a loop device, the change in
rotational status does not always propagate if change it at the loop
device sysfs node.
Signed-off-by: David Sterba <dsterba@suse.com>
Commands that do not take any options do not use getopt, which means the
standard option separator "--" does not work. Update all command
handlers that need it, argv needs to be referenced using the optind that
is correctly pointed after the separator.
Signed-off-by: David Sterba <dsterba@suse.com>
Here we define each file set as those found by a recursive search of a
single directory argument to btrfs fi du.
This isn't as simple as adding up shared extents - they may be shared with
each other, and may also overlap. This patch uses an interval tree to store
shared extents we find while fiemapping files. After collecting them, a 'set
shared' count is calculated by summing (without overlap) each shared region
discovered. This is then displayed to the user as 'set shared'.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
'btrfs du' differs from regular du in that it will work to resolve which
blocks are shared between files in its list. This gives the user a more
accurate bytecount from which they can make decisions regarding management
of their file space.
We still print a total number of bytes counted (like regular du), but also
print the number of bytes which were found to have been shared amongst the
file set provided. From there it becomes trivial to calculate how much space
is exclusively owned.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
[ rename files to reflect the filesystem command group, add GPL v2
file headers ]
Signed-off-by: David Sterba <dsterba@suse.com>
The standalone utilities could share object files with the main utility,
add a way to specify additional object files in a similar way to the
extra libs. The variable name must match the binary plus _objects
suffix and s/-/_/ .
Signed-off-by: David Sterba <dsterba@suse.com>
The long-term plan is to merge the features of standalone tools
into the btrfs binary, reducing the number of shipped binaries.
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
The long-term plan is to merge the features of standalone tools
into the btrfs binary, reducing the number of shipped binaries.
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
While I had the chance, I compared the rbtre code in btrfs-progs to that of
the latest kernel. No new bug fixes need importing, however rbtree.h and
rbtree_augmented.h get documentation updates
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>