platform/upstream/btrfs-progs.git
12 years agoBtrfs-progs: add support for mixed data+metadata block groups
Josef Bacik [Thu, 9 Dec 2010 18:31:08 +0000 (18:31 +0000)]
Btrfs-progs: add support for mixed data+metadata block groups

So alot of crazy people (I'm looking at you Meego) want to use btrfs on phones
and such with small devices.  Unfortunately the way we split out metadata/data
chunks it makes space usage inefficient for volumes that are smaller than
1gigabyte.  So add a -M option for mixing metadata+data, and default to this
mixed mode if the filesystem is less than or equal to 1 gigabyte.  I've tested
this with xfstests on a 100mb filesystem and everything is a-ok.

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
12 years agoBtrfs-progs: update super fields for space cache
Josef Bacik [Thu, 9 Dec 2010 18:27:03 +0000 (18:27 +0000)]
Btrfs-progs: update super fields for space cache

This patch updates the super field to add the cache_generation member.  It also
makes us set it to -1 on mkfs so any new filesystem will get the space cache
stuff turned on.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
12 years agoImprove error handling in the btrfs command
Goffredo Baroncelli [Mon, 20 Dec 2010 20:06:19 +0000 (20:06 +0000)]
Improve error handling in the btrfs command

Hi Chris,

below is enclosed a trivial patch, which has the aim to improve the error
reporting of the "btrfs" command.

You can pull from

http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git

branch

strerror

I changed every printf("some-error") to something like:

e = errno;
fprintf(stderr, "ERROR: .... - %s", strerror(e));

so:

1) all the error are reported to standard error
2) At the end of the message is printed the error as returned by the system.

The change is quite simple, I replaced every printf("some-error") to the line
above. I don't touched anything other.
I also integrated a missing "printf" on the basis of the Ben patch.

This patch leads the btrfs command to be more "user friendly" :-)

Regards
G.Baroncelli

 btrfs-list.c |   40 ++++++++++++++++++++++--------
 btrfs_cmds.c |   77 ++++++++++++++++++++++++++++++++++++++++-----------------
 utils.c      |    6 ++++
 3 files changed, 89 insertions(+), 34 deletions(-)

Signed-off-by: Chris Mason <chris.mason@oracle.com>
12 years agoupdate man page to new defragment command interface
Hubert Kario [Sun, 23 Jan 2011 15:31:07 +0000 (15:31 +0000)]
update man page to new defragment command interface

Update

        btrfs filesystem defragment

command explanation. Add explanation of advanced parameters and notes
about general usage.

Add few notes about the

        btrfs <command> --help

usage, fix related grammar.

Signed-off-by: Hubert Kario <kario@wit.edu.pl>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
12 years agoBtrfs-progs utils Informative errors
Goldwyn Rodrigues [Mon, 7 Feb 2011 07:34:36 +0000 (07:34 +0000)]
Btrfs-progs utils Informative errors

Signed-off-by: Chris Mason <chris.mason@oracle.com>
12 years agoBtrfs-progs use safe string manipulation functions
Eduardo Silva [Mon, 7 Feb 2011 11:55:04 +0000 (08:55 -0300)]
Btrfs-progs use safe string manipulation functions

Signed-off-by: Eduardo Silva <eduardo.silva@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
12 years agoBtrfs-progs: add a btrfs-select-super command to overwrite the super
Chris Mason [Thu, 9 Dec 2010 21:36:29 +0000 (16:36 -0500)]
Btrfs-progs: add a btrfs-select-super command to overwrite the super

Btrfs stores multiple copies of the superblock, and for common power-failure
crashes where barriers were not in use, one of the super copies is often
valid while the first copy is not.

This adds a btrfs-select-super -s N /dev/xxx command, which can
overwrite all the super blocks with a copy that you have already
determined is valid with btrfsck -s

Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoCheck for RAID10 in set_avail_alloc_bits
Chris Mason [Wed, 15 Dec 2010 21:02:45 +0000 (16:02 -0500)]
Check for RAID10 in set_avail_alloc_bits

When raid is setup with mkfs, it is supposed to cow the initial filesystem
it creates up to the desired raid level.  RAID10 was not in the list
of RAID levels it checked for, so the initial FS created for RAID10
actually only lived on the first disk.

This works well enough because all the roots get quickly cowed during the
first mount.  The exception is the data relocation tree, which only gets
cowed when we do a balance.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoFill missing devices so degraded filesystems can be read
Chris Mason [Wed, 15 Dec 2010 21:00:23 +0000 (16:00 -0500)]
Fill missing devices so degraded filesystems can be read

When a device is missing, the btrfs tools need to be able to read alternate
copies from the remaining devices.  This creates placeholder devices
that always return -EIO so the tools can limp along.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoFix the help text for btrfs-map-logical
Chris Mason [Wed, 15 Dec 2010 20:58:19 +0000 (15:58 -0500)]
Fix the help text for btrfs-map-logical

Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agobtrfs-debug-tree: add -d option to print only the device mapping
Chris Mason [Wed, 6 Oct 2010 13:53:38 +0000 (09:53 -0400)]
btrfs-debug-tree: add -d option to print only the device mapping

Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoAdd rescue command to zero the log
Chris Mason [Tue, 5 Oct 2010 14:14:48 +0000 (10:14 -0400)]
Add rescue command to zero the log

Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoAdd btrfsck option to select the super block copy
Chris Mason [Mon, 4 Oct 2010 19:41:10 +0000 (15:41 -0400)]
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>
13 years agoFix undefined reference to symbol 'error_message'
Yan Zheng [Thu, 9 Sep 2010 13:42:42 +0000 (21:42 +0800)]
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>
13 years agoFix inode link count checks in btrfsck
Yan Zheng [Thu, 9 Sep 2010 13:41:48 +0000 (21:41 +0800)]
Fix inode link count checks in btrfsck

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
13 years agoHandle bad extent type case
Frederic Weisbecker [Thu, 9 Sep 2010 06:10:28 +0000 (14:10 +0800)]
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>
13 years agoFix use after free in close_ctree
Jeff Mahoney [Thu, 9 Sep 2010 06:06:09 +0000 (14:06 +0800)]
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>
13 years agoMake csum_tree_block_size complain about the right thing.
Zhu Yanhai [Thu, 9 Sep 2010 06:02:57 +0000 (14:02 +0800)]
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>
13 years agofix incompat flags
Josef Bacik [Thu, 9 Sep 2010 05:51:49 +0000 (13:51 +0800)]
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>
13 years agoAvoid uninitialized variant compile warning
Zhao Lei [Thu, 9 Sep 2010 05:50:26 +0000 (13:50 +0800)]
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>
13 years agofix a compile fail by strndup in RHEL5 env
Zhao Lei [Thu, 9 Sep 2010 05:49:14 +0000 (13:49 +0800)]
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>
13 years agofix wrong return value
Miao Xie [Thu, 9 Sep 2010 05:47:32 +0000 (13:47 +0800)]
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>
13 years agoRemove superfluous WARN_ON in btrfsck
Yan Zheng [Thu, 9 Sep 2010 05:42:49 +0000 (13:42 +0800)]
Remove superfluous WARN_ON in btrfsck

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
13 years agoadd mounted-checking for btrfs-vol
Miao Xie [Thu, 9 Sep 2010 05:41:47 +0000 (13:41 +0800)]
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>
13 years agoonly print FIRST_CHUNK_TREE for chunk items in debug-tree
Sage Weil [Thu, 9 Sep 2010 03:46:22 +0000 (11:46 +0800)]
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>
13 years agocheck slash in deleting subvolumes
TARUISI Hiroaki [Thu, 9 Sep 2010 03:19:25 +0000 (11:19 +0800)]
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>
13 years agoadd missing include for btrfsck.c
Christian Hesse [Thu, 9 Sep 2010 03:05:12 +0000 (11:05 +0800)]
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>
13 years agoprevent btrfsck to run on mounted filesystems
Andi Drebes [Thu, 9 Sep 2010 02:58:43 +0000 (10:58 +0800)]
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>
13 years agomultidevice support for check_mounted
Andi Drebes [Thu, 9 Sep 2010 02:57:02 +0000 (10:57 +0800)]
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>
14 years agoBtrfs: add btrfs-debug-tree -b <block number> to print a single block
Chris Mason [Tue, 6 Apr 2010 13:30:17 +0000 (09:30 -0400)]
Btrfs: add btrfs-debug-tree -b <block number> to print a single block

14 years agoAdd btrfs subvol find-new command
Chris Mason [Thu, 18 Mar 2010 16:32:32 +0000 (12:32 -0400)]
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.

14 years agoAdd ioctl-test.c which just prints all the ioctl numbers.
Chris Mason [Mon, 15 Mar 2010 15:24:20 +0000 (11:24 -0400)]
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.

14 years agoBtrfs-progs: add btrfs filesystem df to print space info
Josef Bacik [Wed, 13 Jan 2010 18:21:23 +0000 (18:21 +0000)]
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>
14 years agoUpdate the btrfs man page with the new commands
Goffredo Baroncelli [Thu, 11 Mar 2010 21:32:50 +0000 (22:32 +0100)]
Update the btrfs man page with the new commands

14 years agoCorrect the check of the argument number for the "btrfs dev add|rem" commands
Goffredo Baroncelli [Thu, 11 Mar 2010 21:07:10 +0000 (22:07 +0100)]
Correct the check of the argument number for the "btrfs dev add|rem" commands

14 years agoAvoid the exit(2) function; instead return with an appropriate value;
Goffredo Baroncelli [Thu, 11 Mar 2010 20:51:36 +0000 (21:51 +0100)]
Avoid the exit(2) function; instead return with an appropriate value;

14 years agoAdd the program name as the first parameter in the command of the btrfs tool
Goffredo Baroncelli [Thu, 11 Mar 2010 20:08:22 +0000 (21:08 +0100)]
Add the program name as the first parameter in the command of the btrfs tool

Signed-off-by: Chris Mason <chris.mason@oracle.com>
14 years agonew util: 'btrfs'
ghigo [Sun, 24 Jan 2010 17:00:05 +0000 (18:00 +0100)]
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>
14 years agoAdd new defrag range ioctl that can also compress files on demand.
Chris Mason [Thu, 11 Mar 2010 14:38:52 +0000 (09:38 -0500)]
Add new defrag range ioctl that can also compress files on demand.

14 years agoBtrfs-progs: add command to set default subvol
Josef Bacik [Fri, 11 Dec 2009 21:12:07 +0000 (21:12 +0000)]
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>
14 years agoAdd btrfs-list for listing subvolumes
Chris Mason [Sun, 28 Feb 2010 20:29:47 +0000 (15:29 -0500)]
Add btrfs-list for listing subvolumes

Signed-off-by: Chris Mason <chris.mason@oracle.com>
14 years agoAdd btrfs-map-logical program to map and read logical block numbers
Chris Mason [Thu, 12 Nov 2009 19:34:09 +0000 (14:34 -0500)]
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>
14 years agobtrfsck: check root back/forward references
Yan, Zheng [Mon, 21 Sep 2009 20:03:57 +0000 (16:03 -0400)]
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>
14 years agobtrfsctl: add snapshot/subvolume destroy ioctl
Yan, Zheng [Mon, 21 Sep 2009 20:03:57 +0000 (16:03 -0400)]
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>
15 years agoused space accounting fix for the converter
Yan Zheng [Fri, 12 Jun 2009 16:55:50 +0000 (12:55 -0400)]
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>
15 years agobtrfs-progs v0.19
Chris Mason [Thu, 11 Jun 2009 16:56:15 +0000 (12:56 -0400)]
btrfs-progs v0.19

15 years agoCheck duplicate backrefs for both data and metadata
Yan Zheng [Thu, 11 Jun 2009 13:27:31 +0000 (09:27 -0400)]
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>
15 years agoMake sure all dirty blocks are written at commit time
Yan Zheng [Wed, 3 Jun 2009 15:59:47 +0000 (11:59 -0400)]
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>
15 years agoUpdate converter for the new format
Yan Zheng [Wed, 3 Jun 2009 15:59:47 +0000 (11:59 -0400)]
Update converter for the new format

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoMixed back reference (FORWARD ROLLING FORMAT CHANGE)
Chris Mason [Fri, 29 May 2009 20:35:30 +0000 (16:35 -0400)]
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

15 years agoFix man page headers to include the correct program name.
Chris Mason [Wed, 3 Jun 2009 16:13:01 +0000 (12:13 -0400)]
Fix man page headers to include the correct program name.

15 years agoFix printf format casting errors
Luca Bruno [Wed, 3 Jun 2009 16:04:41 +0000 (12:04 -0400)]
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>
15 years agoFix spelling mistake when running 'btrfsck' when argument doesn't exist.
nick d [Wed, 3 Jun 2009 16:04:41 +0000 (12:04 -0400)]
Fix spelling mistake when running 'btrfsck' when argument doesn't exist.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoUpdate btrfs-debug-tree to output more readable strings.
Shen Feng [Wed, 3 Jun 2009 16:02:23 +0000 (12:02 -0400)]
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>
15 years agoAdd btrfs-show man page
Peng Tao [Wed, 3 Jun 2009 16:00:20 +0000 (12:00 -0400)]
Add btrfs-show man page

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoAdd -V|--version to mkfs.btrfs argument parser
Luca Bruno [Wed, 3 Jun 2009 16:00:20 +0000 (12:00 -0400)]
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>
15 years agoAdd btrfs-image man page
Peng Tao [Wed, 3 Jun 2009 16:00:20 +0000 (12:00 -0400)]
Add btrfs-image man page

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoFix typos in btrfsck, btrfsctl, mkfs.btrfs manual
Peng Tao [Wed, 3 Jun 2009 16:00:20 +0000 (12:00 -0400)]
Fix typos in btrfsck, btrfsctl, mkfs.btrfs manual

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoFix print-tree.c to skip blocks it can't read instead of aborting
Chris Mason [Wed, 13 May 2009 15:27:35 +0000 (11:27 -0400)]
Fix print-tree.c to skip blocks it can't read instead of aborting

15 years agoAdd scan of the btrfs log tree to btrfs-debug-tree
Chris Mason [Wed, 15 Apr 2009 18:30:14 +0000 (14:30 -0400)]
Add scan of the btrfs log tree to btrfs-debug-tree

15 years agoFix showblocks to display different colors for different metadata roots
Chris Mason [Mon, 9 Mar 2009 17:00:44 +0000 (13:00 -0400)]
Fix showblocks to display different colors for different metadata roots

15 years agoAdd man/btrfsck.8.in and Makefile for man pages
Goldwyn Rodrigues [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
Add man/btrfsck.8.in and Makefile for man pages

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@gmail.com>
15 years agoAdd man/btrfsctl.8.in
Goldwyn Rodrigues [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
Add man/btrfsctl.8.in

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@gmail.com>
15 years agoAdd man/mkfs.btrfs.8.in
Goldwyn Rodrigues [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
Add man/mkfs.btrfs.8.in

Kept the name with the name in, so that further processing such as
BUILD_DATE BUILD_VERSION etc. could be included later.

All man pages included in the man directory to avoid file cluttering.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.de>
15 years agobtrfsck.c: bit-fields should be unsigned
Wang Cong [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
btrfsck.c: bit-fields should be unsigned

Signed-off-by: WANG Cong <wangcong@zeuux.org>
15 years agobtrfsck: Exit and print error message when not able to open a device
Thadeu Lima de Souza Cascardo [Wed, 21 Jan 2009 18:59:36 +0000 (13:59 -0500)]
btrfsck: Exit and print error message when not able to open a device

If btrfsck is not able to open a device, it segfaults. This fixes it and
prints an error message too.

15 years agobtrfs-image.c: fix return values
Wang Cong [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
btrfs-image.c: fix return values

- Exit with non-zero when fail;
- Don't exit in non-main functions, return.

Signed-off-by: WANG Cong <wangcong@zeuux.org>
15 years agobtrfs-progs: make several functions static
Wang Cong [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
btrfs-progs: make several functions static

Make several functions static, and make one argument const.

Signed-off-by: WANG Cong <wangcong@zeuux.org>
15 years agoFix misleading error message in btrfsctl
Calvin Walton [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
Fix misleading error message in btrfsctl

This updates Peter Klotz's original patch to use perror instead of fprintf
when it fails to open /dev/btrfs-control

15 years agoMention minimum size on devices that are considered too small
Jan Engelhardt [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
Mention minimum size on devices that are considered too small

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
15 years agoModify Makefile to include man directory
Goldwyn Rodrigues [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
Modify Makefile to include man directory

15 years agoUpdate convert for uninitialized block groups
Yan Zheng [Wed, 21 Jan 2009 18:22:49 +0000 (13:22 -0500)]
Update convert for uninitialized block groups

There is a new feature 'uninitialized block groups' in ext4.
Block and inode bitmaps in uninitialized block groups are
uninitialized. This confuses the converter. The fix is call
ext2fs_new_inode for each block group at open time. It set
up uninitialized block and inode bitmaps appropriately.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
15 years agoDrop bit-radix.[ch] files
Chris Mason [Wed, 21 Jan 2009 19:00:24 +0000 (14:00 -0500)]
Drop bit-radix.[ch] files

These are no longer in use

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoUpdate version.sh to 0.18
Chris Mason [Sat, 17 Jan 2009 01:08:19 +0000 (20:08 -0500)]
Update version.sh to 0.18

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoFix ioctl arg size (userland incompatible change!)
Chris Mason [Fri, 16 Jan 2009 17:05:01 +0000 (12:05 -0500)]
Fix ioctl arg size (userland incompatible change!)

The structure used to send device in btrfs ioctl calls was not
properly aligned, and so 32 bit ioctls would not work properly on
64 bit kernels.

We could fix this with compat ioctls, but we're just one byte away
and it doesn't make sense at this stage to carry about the compat ioctls
forever at this stage in the project.

This patch brings the ioctl arg up to an evenly aligned 4k.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoUpdate version.sh to v0.17
Chris Mason [Mon, 12 Jan 2009 17:56:34 +0000 (12:56 -0500)]
Update version.sh to v0.17

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoFix isize/nbytes update bugs in btrfs-convert
Yan Zheng [Mon, 12 Jan 2009 17:47:06 +0000 (12:47 -0500)]
Fix isize/nbytes update bugs in btrfs-convert

These fix a few converter problems found by the new btrfsck code.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
15 years agoFix mispatch of the experimental warnings
Chris Mason [Sun, 11 Jan 2009 12:58:35 +0000 (07:58 -0500)]
Fix mispatch of the experimental warnings

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoWarn user that this release is experimental
Jim Owens [Fri, 9 Jan 2009 20:06:28 +0000 (15:06 -0500)]
Warn user that this release is experimental

Post wiki pointer message for getting version
status, limitations, and known problems.

Signed-off-by: jim owens <jowens@hp.com>
15 years agoFix an accessing freed memory bug in btrfsck
Yan Zheng [Fri, 9 Jan 2009 19:39:33 +0000 (14:39 -0500)]
Fix an accessing freed memory bug in btrfsck

15 years agoRename debug-tree to btrfs-debug-tree
Chris Mason [Wed, 7 Jan 2009 20:12:15 +0000 (15:12 -0500)]
Rename debug-tree to btrfs-debug-tree

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoAdd error processing for btrfsctl -a
Shen Feng [Wed, 7 Jan 2009 19:57:11 +0000 (14:57 -0500)]
Add error processing for btrfsctl -a

brfsctl -a will do nothing and no error is output
if btrfs.ko is not inserted.

Since no caller do error processing for btrfs_register_one_device,
make its return void and do error processing inside.

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
15 years agodebug-tree output tree/key type instead of id
Shen Feng [Wed, 7 Jan 2009 19:57:12 +0000 (14:57 -0500)]
debug-tree output tree/key type instead of id

This makes the tree name and key type output more readable.

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
15 years agoUpdate BUG_ON and WARN_ON
Shen Feng [Wed, 7 Jan 2009 19:57:12 +0000 (14:57 -0500)]
Update BUG_ON and WARN_ON

Define BUG_ON and WARN_ON as assert for easy debugging.

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
15 years agoAdd semantic checks to btrfsck for files and directories
Yan Zheng [Wed, 7 Jan 2009 19:57:12 +0000 (14:57 -0500)]
Add semantic checks to btrfsck for files and directories

This patch makes btrfsck check more things, including
directory items, file extents, checksumming, inode link
counts etc.

The code for these checks is similar to the code verifies
extent back references. The main difference is that
shared tree blocks are treated specially. The partial
checking results(unresolved references and/or errors)
of shared sub-trees are cached. This avoids scanning
the shared blocks several times. Thank you,

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
15 years agoFix compile error in quick-test.c of btrfs progs
Liu Hui [Wed, 7 Jan 2009 19:57:12 +0000 (14:57 -0500)]
Fix compile error in quick-test.c of btrfs progs

15 years agoFix mkfs.btrfs usage help to match the current args
Shen Feng [Wed, 7 Jan 2009 19:57:12 +0000 (14:57 -0500)]
Fix mkfs.btrfs usage help to match the current args

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
15 years agoMake the minimum filesystem size error message more clear
Shen Feng [Wed, 7 Jan 2009 19:57:12 +0000 (14:57 -0500)]
Make the minimum filesystem size error message more clear

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
15 years agoBtrfs: update converter for the new disk format
Yan Zheng [Wed, 17 Dec 2008 21:10:07 +0000 (16:10 -0500)]
Btrfs: update converter for the new disk format

This patch updates the ext3 to btrfs converter for the new
disk format. This mainly involves changing the convert's
data relocation and free space management code. This patch
also ports some functions from kernel module to btrfs-progs.
Thank you,

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
15 years agoBtrfs: Add inode sequence number for NFS and reserved space in a few structs
Chris Mason [Mon, 8 Dec 2008 22:01:14 +0000 (17:01 -0500)]
Btrfs: Add inode sequence number for NFS and reserved space in a few structs

This adds a sequence number to the btrfs inode that is increased on
every update.  NFS will be able to use that to detect when an inode has
changed, without relying on inaccurate time fields.

While we're here, this also:

Puts reserved space into the super block and inode

Adds a log root transid to the super so we can pick the newest super
based on the fsync log as well as the main transaction ID.  For now
the log root transid is always zero, but that'll get fixed.

Adds a starting offset to the dev_item.  This will let us do better
alignment calculations if we know the start of a partition on the disk.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agosuperblock duplication
Yan Zheng [Fri, 5 Dec 2008 17:21:31 +0000 (12:21 -0500)]
superblock duplication

This patch updates btrfs-progs for superblock duplication.
Note: I didn't make this patch as complete as the one for
kernel since updating the converter requires changing the
code again. Thank you,

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
15 years agoBtrfs: move data checksumming into a dedicated tree
Chris Mason [Mon, 8 Dec 2008 22:00:31 +0000 (17:00 -0500)]
Btrfs: move data checksumming into a dedicated tree

Btrfs stores checksums for each data block.  Until now, they have
been stored in the subvolume trees, indexed by the inode that is
referencing the data block.  This means that when we read the inode,
we've probably read in at least some checksums as well.

But, this has a few problems:

* The checksums are indexed by logical offset in the file.  When
compression is on, this means we have to do the expensive checksumming
on the uncompressed data.  It would be faster if we could checksum
the compressed data instead.

* If we implement encryption, we'll be checksumming the plain text and
storing that on disk.  This is significantly less secure.

* For either compression or encryption, we have to get the plain text
back before we can verify the checksum as correct.  This makes the raid
layer balancing and extent moving much more expensive.

* It makes the front end caching code more complex, as we have touch
the subvolume and inodes as we cache extents.

* There is potentitally one copy of the checksum in each subvolume
referencing an extent.

The solution used here is to store the extent checksums in a dedicated
tree.  This allows us to index the checksums by phyiscal extent
start and length.  It means:

* The checksum is against the data stored on disk, after any compression
or encryption is done.

* The checksum is stored in a central location, and can be verified without
following back references, or reading inodes.

This makes compression significantly faster by reducing the amount of
data that needs to be checksummed.  It will also allow much faster
raid management code in general.

The checksums are indexed by a key with a fixed objectid (a magic value
in ctree.h) and offset set to the starting byte of the extent.  This
allows us to copy the checksum items into the fsync log tree directly (or
any other tree), without having to invent a second format for them.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agoRev the disk format for the compat code and the csum selection
Chris Mason [Tue, 2 Dec 2008 15:20:36 +0000 (10:20 -0500)]
Rev the disk format for the compat code and the csum selection

Signed-off-by: Chris Mason <chris.mason@oracle.com>
15 years agobtrfs-progs: support for different csum algorithims
Josef Bacik [Tue, 2 Dec 2008 14:58:23 +0000 (09:58 -0500)]
btrfs-progs: support for different csum algorithims

This is the btrfs-progs version of the patch to add the ability to have
different csum algorithims.  Note I didn't change the image maker since it
seemed a bit more complicated than just changing some stuff around so I will let
Yan take care of that.

Everything else was converted and for now a mkfs just
sets the type to be BTRFS_CSUM_TYPE_CRC32.

Signed-off-by: Josef Bacik <jbacik@redhat.com>
15 years agobtrfs-progs: add support for compat flags
Josef Bacik [Tue, 2 Dec 2008 12:18:36 +0000 (07:18 -0500)]
btrfs-progs: add support for compat flags

This patch updates btrfs-progs with the disk format changes for the
compatability flags.

Signed-off-by: Josef Bacik <jbacik@redhat.com>
15 years agoFix image tool compile warnings
yanhai zhu [Tue, 2 Dec 2008 12:19:08 +0000 (07:19 -0500)]
Fix image tool compile warnings

15 years agoBtrfs image tool
Yan Zheng [Thu, 20 Nov 2008 14:52:48 +0000 (09:52 -0500)]
Btrfs image tool

This patch adds btrfs image tool. The image tool is
a debugging tool that creates/restores btrfs metadump
image.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
15 years agoUpdate the super magic string to match the seed and root format changes
Chris Mason [Tue, 18 Nov 2008 19:13:44 +0000 (14:13 -0500)]
Update the super magic string to match the seed and root format changes

15 years agoAdd disk format requirements for subvol backward and forward refs
Chris Mason [Tue, 18 Nov 2008 15:34:08 +0000 (10:34 -0500)]
Add disk format requirements for subvol backward and forward refs

15 years agoModify the subvol and snapshot creation ioctls to work anywhere in the tree
Chris Mason [Tue, 18 Nov 2008 16:26:35 +0000 (11:26 -0500)]
Modify the subvol and snapshot creation ioctls to work anywhere in the tree

This changes the snapshot and subvol ioctl API and command lines so
that new snapshots and subvols can be created anywhere.

Subvolume creation hasn't changed much:

btrfsctl -S subvol_name directory

This creates a new subvolume under 'directory'

Snapshot creation looks the same, but is actually different:

btrfsctl -s full_path_to_new_snapshot file_or_dir

For example: btrfsctl -s /mnt/new_snap /mnt/subvol

Will create a new snapshot named new_snap under /mnt of the root
found in /mnt/subvol.  It always snapshots the entire root regardless of
which file or directory inside the root you give it.

Signed-off-by: Chris Mason <chris.mason@oracle.com>