Commit Graph

356 Commits (375714fe1181d1cca400dcfbcdb4fc29c6dfa5d6)
 

Author SHA1 Message Date
Chris Mason 375714fe11 Fix the help text for btrfs-map-logical
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-04-22 14:52:28 -04:00
Chris Mason 1b444cd2e6 btrfs-debug-tree: add -d option to print only the device mapping
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-10-06 09:53:38 -04:00
Chris Mason 0f49c426fb Add rescue command to zero the log
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-10-05 10:14:48 -04:00
Chris Mason 8c43a9adf7 Add btrfsck option to select the super block copy
btrfsck -s 0 uses the defult 0, -s 1 uses copy #1 etc.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-10-04 15:41:10 -04:00
Yan Zheng c301fccdab Fix undefined reference to symbol 'error_message'
defination of error_message was moved into libcom_err.so

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
2010-09-23 20:26:50 -04:00
Yan Zheng d44860cee5 Fix inode link count checks in btrfsck
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
2010-09-23 20:26:50 -04:00
Frederic Weisbecker 7da27f91fc Handle bad extent type case
If we meet a bad extent type, find_updated_files is going
to print random things. Better warn the user about what
happens.

This fixes:

btrfs-list.c: Dans la fonction «find_updated_files» :
btrfs-list.c:668: attention : «disk_offset» may be used uninitialized in this function
btrfs-list.c:668: note: «disk_offset» was declared here
btrfs-list.c:667: attention : «disk_start» may be used uninitialized in this function
btrfs-list.c:667: note: «disk_start» was declared here
btrfs-list.c:666: attention : «len» may be used uninitialized in this function
btrfs-list.c:666: note: «len» was declared here
make: *** [btrfs-list.o] Erreur 1

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
2010-09-23 20:26:50 -04:00
Jeff Mahoney bba632af0e Fix use after free in close_ctree
After the roots are closed, root is freed. Yet close_ctree continues
to use it. It works generally because no new memory is allocated in
the interim, but with glibc malloc perturbing enabled, it crashes
every time. This is because root->fs_info points to garbage.

This patch uses the already-cached fs_info variable for the rest of
the accesses and fixes the crash.

This issue was reported at:
https://bugzilla.novell.com/show_bug.cgi?id=603620

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2010-09-23 20:26:50 -04:00
Zhu Yanhai b227b4dd7c Make csum_tree_block_size complain about the right thing.
It dereferenced a wrong pointer before.

Signed-off-by: Zhu Yanhai <yanhai.zhu@linux.intel.com>
2010-09-23 20:26:49 -04:00
Josef Bacik 944eea95c0 fix incompat flags
I forgot to add BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL to the incompat flags in
btrfs-progs.  This adds it so that our tools don't freak out when touching a fs
with the default subvolume changed.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
2010-09-23 20:26:49 -04:00
Zhao Lei 6ac03d3a28 Avoid uninitialized variant compile warning
When we compile btrfs-progs in RHEL5(with default gcc version 4.1.2 20070626),
we can get following error:

cc1: warnings being treated as errors
btrfs-list.c: In function 'find_updated_files':
btrfs-list.c:668: warning: 'disk_offset' may be used uninitialized in this function
btrfs-list.c:667: warning: 'disk_start' may be used uninitialized in this function
btrfs-list.c:666: warning: 'len' may be used uninitialized in this function
make: *** [btrfs-list.o] Error 1

These varient are always initialized except inconsistent data in file system.
We can set initial value for these variant for this situation.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
2010-09-23 20:26:49 -04:00
Zhao Lei 6c94ed2479 fix a compile fail by strndup in RHEL5 env
When we compile btrfs-progs in RHEL5(with default gcc 4.1.2 and glibc-2.5-18),
we can get following error:

cc1: warnings being treated as errors
btrfs-list.c: In function 'ino_resolve':
btrfs-list.c:511: warning: implicit declaration of function 'strndup'
btrfs-list.c:511: warning: incompatible implicit declaration of built-in function 'strndup'
make: *** [btrfs-list.o] Error 1
...
cc1: warnings being treated as errors
btrfs.c: In function 'split_command':
btrfs.c:168: warning: implicit declaration of function 'strndup'
btrfs.c:168: warning: incompatible implicit declaration of built-in function 'strndup'
make: *** [btrfs-list.o] Error 1

We can add _GNU_SOURCE definition according man strndup.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
2010-09-23 20:26:49 -04:00
Miao Xie 2d428975f2 fix wrong return value
btrfsctl returns 1 if it does something successfully.
this patch fixes this problem.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
2010-09-23 20:26:49 -04:00
Yan Zheng 076de67f5b Remove superfluous WARN_ON in btrfsck
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
2010-09-23 20:26:49 -04:00
Miao Xie ddf85067bb add mounted-checking for btrfs-vol
Adding a mounted device is dangerous because it will destroy the filesystem
on that mounted device. So we add mounted-checking for btrfs-vol.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
2010-09-23 20:26:49 -04:00
Sage Weil 595cb1df15 only print FIRST_CHUNK_TREE for chunk items in debug-tree
Otherwise we print FIRST_CHUNK_TREE for any objectid 256, which e.g. for
the root tree is the first snap/subvol.

Signed-off-by: Sage Weil <sage@newdream.net>
2010-09-23 20:26:49 -04:00
TARUISI Hiroaki 48f16a69d7 check slash in deleting subvolumes
For now, btrfsctl does not check whether subvolume name contains slash
or not. If someone specify subvolume with trailing slash (in case
using shell completion), ioctl returns with EINVAL and this error
may confuse some careless users like me. So, this patch adds check
slashes in subvolume name in deletion same as snapshot/subvolume
creating. But considering shell completion, this fix allows trailing
slash.

Signed-off-by: TARUISI Hiroaki <taruishi.hiroak@jp.fujitsu.com>
2010-09-23 20:26:49 -04:00
Christian Hesse 34915ad27b add missing include for btrfsck.c
compiling btrfs-progs from current git I get an error in btrfsck.c about
undefined references. The attached patch adds an include for sys/stat.h
which fixes the problem for me.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
2010-09-23 20:26:49 -04:00
Andi Drebes 659d37c68d prevent btrfsck to run on mounted filesystems
As recently discussed on the list, btrfsck should only be run on
unmounted filesystems. This patch adds a short check for the mount
status at the beginning of btrfsck. If the FS is mounted, the
program aborts showing an error message.

Signed-off-by: Andi Drebes <lists-receive@programmierforen.de>
2010-09-23 20:26:49 -04:00
Andi Drebes 09559bfe7b multidevice support for check_mounted
Check_mount() should also work with multi device filesystems.
This patch adds checks that allow to detect if a file is a device
file used by a mounted single or multi device btrfs or if it is a
regular file used by a loopback device that is part of a mounted
single or multi device btrfs.

The single device checks also work for non-btrfs filesystems.
This might be helpful to prevent users from running btrfs programs
(e.g. mkfs.btrfs) accidentally on a filesystem used somewhere else.

Signed-off-by: Andi Drebes <lists-receive@programmierforen.de>
2010-09-23 20:26:49 -04:00
Chris Mason 075587c96c Btrfs: add btrfs-debug-tree -b <block number> to print a single block 2010-04-06 09:30:17 -04:00
Chris Mason 8f55b769c7 Add btrfs subvol find-new command
btrfs-subvol find-new <subvol> <id> will search through a given subvol
and print out all the files with extents newer than a given id.

Care must be taken to make sure any pending delalloc is on disk before
running this because that won't show up in the output.
2010-03-18 12:32:32 -04:00
Chris Mason fb3a539c92 Add ioctl-test.c which just prints all the ioctl numbers.
This is used to compare the output on 64 bit and 32 bit machines and
make sure all of our ioctls are compat defined.
2010-03-15 11:24:20 -04:00
Josef Bacik b72e4c4e19 Btrfs-progs: add btrfs filesystem df to print space info
This goes along with the new space info ioctl.  This will spit out the space
info all nice and pretty with the type, it's flags (DUP, RAID) and how much
space is in that group and how much is in use.

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-03-14 08:34:38 -04:00
Goffredo Baroncelli 35401ac190 Update the btrfs man page with the new commands 2010-03-11 22:09:46 -05:00
Goffredo Baroncelli 866539056a Correct the check of the argument number for the "btrfs dev add|rem" commands 2010-03-11 22:09:46 -05:00
Goffredo Baroncelli e584004d3c Avoid the exit(2) function; instead return with an appropriate value; 2010-03-11 22:09:46 -05:00
Goffredo Baroncelli 7ebebb7bb1 Add the program name as the first parameter in the command of the btrfs tool
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-03-11 22:09:38 -05:00
ghigo 6d2cf04247 new util: 'btrfs'
This commit introduces a new command called 'btrfs' for managing
a btrfs filesystem. 'btrfs' handles:
- snapshot/subvolume creation
- adding/removal of volume (ie: disk)
- defragment of a tree
- scan of a device searching a btrfs filesystem
- re-balancing of the chunk on the disks
- listing subvolumes and snapshots

This has also been updated to include the new defrag range ioctl.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-03-11 13:45:47 -05:00
Chris Mason 06cbf62fda Add new defrag range ioctl that can also compress files on demand. 2010-03-11 09:38:52 -05:00
Josef Bacik 7b14bc0f4f Btrfs-progs: add command to set default subvol
This introduces a new btrfsctl option, -m, to allow you to set the default'ly
mounted subvolume.  You can do

btrfsctl -m /your/subvolume

and that will make that subvolume the subvolume that is mounted by default, or
you can do

btrfsctl -m <treeid> /any/subvolume

and this will make the subvolume with tree id <treeid> the default'ly mounted
subvolume.  You can get the treeid by using the listing option.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-02-28 19:24:25 -05:00
Chris Mason 4ff9e2af17 Add btrfs-list for listing subvolumes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-02-28 15:35:38 -05:00
Chris Mason ab8fb4c995 Add btrfs-map-logical program to map and read logical block numbers
This allows us to figure out which physical byte offset on which device
is the real location for a given logical block number.  It can
optionally read the block in and save it to a file for debugging
analysis.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-11-12 14:49:03 -05:00
Yan, Zheng 6f3cf25a4e btrfsck: check root back/forward references
This patch adds semantic checks for links to snapshot/subvolume and
root back/forward references.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-09-21 16:03:57 -04:00
Yan, Zheng 45195b216d btrfsctl: add snapshot/subvolume destroy ioctl
resend Aaron Straus's patch

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-09-21 16:03:57 -04:00
Yan Zheng 4f89b6eb07 used space accounting fix for the converter
remove code that updates the total used space, since
btrfs_update_block_group does that work now.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-12 12:55:50 -04:00
Chris Mason 5e762a371f btrfs-progs v0.19 2009-06-11 12:56:15 -04:00
Yan Zheng 0e3c5d410f Check duplicate backrefs for both data and metadata
lookup_inline_extent_backref only checks for duplicate backref for data extent.
It assumes backrefs for tree block never conflict.  This patch makes
lookup_inline_extent_backref check duplicate backrefs for both data and tree
block, so that we can detect potential bug earlier.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-11 09:27:37 -04:00
Yan Zheng 0030f1d3ae Make sure all dirty blocks are written at commit time
Write dirty block groups may make some block groups dirty.
This patch make btrfs_write_dirty_block_groups properly
handle the recursion.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-08 13:31:10 -04:00
Yan Zheng 50860d6e31 Update converter for the new format
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-08 13:31:10 -04:00
Chris Mason 95d3f20b51 Mixed back reference (FORWARD ROLLING FORMAT CHANGE)
This commit introduces a new kind of back reference for btrfs metadata.
Once a filesystem has been mounted with this commit, IT WILL NO LONGER
BE MOUNTABLE BY OLDER KERNELS.

The new back ref provides information about pointer's key, level and in which
tree the pointer lives. This information allow us to find the pointer by
searching the tree. The shortcoming of the new back ref is that it only works
for pointers in tree blocks referenced by their owner trees.

This is mostly a problem for snapshots, where resolving one of these fuzzy back
references would be O(number_of_snapshots) and quite slow.  The solution used
here is to use the fuzzy back references in the common case where a given tree
block is only referenced by one root, and use the full back references when
multiple roots have a reference
2009-06-08 13:30:36 -04:00
Chris Mason 2d39a83829 Fix man page headers to include the correct program name. 2009-06-03 12:15:40 -04:00
Luca Bruno 6fa19b04d9 Fix printf format casting errors
There are still some warnings of the form:

format '%llu' expects type 'long long unsigned int' but argument has type 'u64'

In conjunction with -Werror, this is causing some build failures.
Now they're properly casted, avoiding compiler warnings.

Signed-off-by: Luca Bruno <lucab@debian.org>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-03 12:15:40 -04:00
nick d 99b6d94018 Fix spelling mistake when running 'btrfsck' when argument doesn't exist.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-03 12:15:40 -04:00
Shen Feng 61907d4e81 Update btrfs-debug-tree to output more readable strings.
output objectid in btrfs_disk_key with human readable strings.
Other updates are included for more readable output.

Thanks Fengguang's fix to this patch.

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-03 12:15:40 -04:00
Peng Tao 0869c0ca7c Add btrfs-show man page
Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-03 12:15:40 -04:00
Luca Bruno 3fb5c031fe Add -V|--version to mkfs.btrfs argument parser
mkfs.btrfs now prints its version when invoked with -V|--version
and exits without error.

All other mkfs.* tools provide this feature and follow this
implicit argument naming convention, as it is commonly used to
check for helper tools presence.

The corrisponding manual already mentions this option, no need to
touch it.

Signed-off-by: Luca Bruno <lucab@debian.org>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-03 12:15:40 -04:00
Peng Tao bf2b9d2ba4 Add btrfs-image man page
Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-03 12:15:40 -04:00
Peng Tao a74f4651c9 Fix typos in btrfsck, btrfsctl, mkfs.btrfs manual
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-03 12:15:40 -04:00
Chris Mason ed20f5fc90 Fix print-tree.c to skip blocks it can't read instead of aborting 2009-05-13 11:27:35 -04:00