Commit Graph

443 Commits (888b7005ca03316ac930ad762fa86b04d9f28a5a)
 

Author SHA1 Message Date
Ilya Dryomov 888b7005ca Btrfs-progs: add 'balance' command group infrastructure
Add balance command group under both 'btrfs' and 'btrfs filesystem'.
Preserve the old 'btrfs filesystem balance <path>' behaviour.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-03 21:02:30 +02:00
Ilya Dryomov 4f3a15d09a Btrfs-progs: add restriper headers
Add restriper headers and update print-tree.c

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-03 21:02:29 +02:00
Ilya Dryomov d675085a67 Btrfs-progs: switch all existing commands to a new parser
The new infrastructure offloads checking number of arguments passed to a
command to individual command handlers.  Fix them up accordingly.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-03 21:00:17 +02:00
Ilya Dryomov 8b4e3d8b5b Btrfs-progs: implement new subcommand parser
This completely replaces the existing subcommand infrastructure, which
is not flexible enough to accomodate our needs.  Instead of a global
command table we now have per-level tables and command group handlers,
which allows command-group-specific handling of options and subcommands.
The new parser exports a clear interface and gets out of the way - all
control over how matching is done is passed to commands and command
group handlers.

One side effect of this is that command implementors have to check the
number of arguments themselves - patch to fix up all existing commands
follows.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-03 21:00:17 +02:00
Ilya Dryomov 4f26833193 Btrfs-progs: rearrange files in the repo
Separate every command group into its own file (cmds_<group>.c) and
rearrange includes.  Remove btrfs_cmds.c.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-03 21:00:17 +02:00
Arnd Hannemann fdb6c04023 Btrfs-progs: Relocate -lpthread in makefile
This patch fixes the following compile error when compiled with
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3):

gcc -lpthread -g -O0 -o btrfs btrfs.o btrfs_cmds.o scrub.o \
		ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o root-tree.o dir-item.o file-item.o inode-item.o inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o volumes.o utils.o btrfs-list.o btrfslabel.o  -luuid
scrub.o: In function `scrub_start':
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1342: undefined reference to `pthread_create'
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1360: undefined reference to `pthread_create'
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1374: undefined reference to `pthread_join'
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1430: undefined reference to `pthread_cancel'
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1432: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
make: *** [btrfs] Error 1

The gcc man page says: "[...] the placement of the -l option is significant." so lets include -lpthread together with the usual $(LIBS)

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-12-01 11:33:21 -05:00
Chris Mason 6da41f2a74 btrfs-progs: make sure btrfs-zero-log writes something
The close_ctree code does a check to see if the FS has
changed before it does any IO.  This forces the commit.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-11-21 10:27:17 -05:00
Chris Mason 13eced9a0c Btrfs: add the tree history log to btrfs-progs
This also adds btrfs-debug-tree -R to print the history

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-11-05 14:58:41 -04:00
Chris Mason 882895d411 Btrfs: fix raid10 reading math
The btrfs-progs raid10 code has been silently reading the wrong
raid10 block forever.  We didn't notice because it was always fixed
up by the retry code.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-11-03 12:17:49 -04:00
Jan Schmidt 6055e73604 Btrfs-progs: added ioctls and commands to resolve inodes and logical addrs
two new commands that make use of the new path resolving functions
implemented for scrub, doing the resolving in-kernel. the result for both
commands is a list of files belonging to that inode / logical address.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-11-02 15:46:10 -04:00
Jan Schmidt dcdbc1ce18 Btrfs-progs: added resolve commands to man page
Added "inspect-internal inode-resolve" and "inspect-internal
logical-resolve" to the btrfs(8) man page.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
2011-11-02 15:45:45 -04:00
Li Zefan d260078696 Fix missing entries in listing of subvolumes
Stephane Chazelas <stephane.chazelas@gmail.com> writes:
> I've got a btrfs FS with 84 subvolumes in it (some created with
> "btrfs sub create", some with "btrfs sub snap" of the other
> ones). There's no nesting of subvolumes at all (all direct children
> of the root subvolume).
>
> The "btrfs subvolume list" is only showing 80 subvolumes. The 4
> missing ones (1 original volume, 3 snapshots) do exist on disk and
> files in there have different st_devs from any other subvolume.
>
> I found
> http://thread.gmane.org/gmane.comp.file-systems.btrfs/8123/focus=8208
>
> which looks like the same issue, with Li Zefan saying he had a
> fix, but I couldn't find any mention that it was actually fixed.

Li Zefan <lizf@cn.fujitsu.com> replied:
> After that, I posted a patch to fix btrfs-progs, which Chris aggreed
> on:
>
> http://marc.info/?l=linux-btrfs&m=129238454714319&w=2

So this btrfs-progs patch should fix missing subvolumes in the output of
"subvolume list":

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-11-02 11:36:30 -04:00
Chris Mason bab2c565cc Btrfs-progs: btrfs-list: split list_subvols
split list_subvols to separate functions and allow printing only in the
containing function. lets us make use of those functions when resolving
logical addresses.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-11-02 11:36:30 -04:00
Chris Mason bb42e12554 Merge branch 'recovery-beta' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs 2011-10-31 14:05:03 -04:00
Chris Mason f25e1d16a5 btrfs-progs: remove old debugging statement
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-27 23:48:47 -04:00
Chris Mason 18c970767f btrfs-progs: add a utility to corrupt a single block 2011-10-27 22:38:02 -04:00
Chris Mason b670b9285e btrfs-debug-tree: add -r option to print only the roots
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-27 17:42:26 -04:00
Chris Mason ff91b185f7 restore: deal with holes and set i_size correctly
This changes restore to set the i_size of the files it
copies out based on the size in the inode.  It also changes
it to skip over holes.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-27 16:25:12 -04:00
Chris Mason ba1aa28496 btrfs-progs: fixup is_mounted checks
/proc/mounts contains device names that don't exist,
we end up erroring out because we're not able to stat
the device (that doesn't exist).

Fix this by allowing the mkfs when the target device doesn't exist.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-27 16:23:14 -04:00
Josef Bacik be826706b5 btrfs-progs: add a recovery utility to pull files from damanged filesystems
Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-27 12:49:54 -04:00
Chris Mason bed7475d77 Print the root generation in btrfs-debug-tree
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-27 11:44:54 -04:00
Chris Mason 24825392b3 Print the root generation in btrfs-debug-tree
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-25 09:51:11 -04:00
Ilya Dryomov 0758da29a6 Btrfs-progs: make btrfs df report profiles for mixed block groups
Profiles other than SINGLE for mixed chunks might sound a bit strange,
but there is nothing in the filesystem that prevents a crazy user from
doing it.  So make "btrfs fi df" report them properly.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2011-10-25 09:19:00 -04:00
Zhong, Xin bd7d6d45d4 btrfs-progs: Improvement for making btrfs image from source directory.
* Initialize ret in btrfs_csum_file_block
* Do not abort when xattr is not supported in the source directory
* Remove size limitation of 256M
* Alloc data chunk in a smaller size (8M) to make btrfs image smaller
* Let user specify the btrfs image name
Depends on below patch from samsung guys:
http://marc.info/?l=linux-btrfs&m=127858068226025&w=2

Signed-off-by: Zhong, Xin <xin.zhong@intel.com>
2011-10-25 09:19:00 -04:00
Goffredo Baroncelli 0dbd99fb3e Scan the devices listed in /proc/partitions
During the commands:
	- btrfs filesystem show
	- btrfs device scan
the devices "scanned" are extracted from /proc/partitions. This
should avoid to scan devices not suitable for a btrfs filesystem like cdrom
and floppy or to scan not existant devices.
The old behavior (scan all the block devices under /dev) may be
forced passing the "--all-devices" switch.
2011-10-25 09:19:00 -04:00
Jeff Liu 521770b7a9 Btrfs-progs: specify label length larger than 255 bytes cause mkfs.btrfs buffer overflow
Hello,

While going through the mkfs.c, I noticed there is an issue for label
length checking, mkfs.btrfs will crashed if the label length exceeding
255 bytes, it's easy to triggered that out as below:

jeff@pibroch:~/opensource/btrfs-progs$ sudo ./mkfs.btrfs -L `perl -e
'print "A"x256'` /usr/src/linux-3.0/img0

WARNING! - Btrfs v0.19-35-g1b444cd IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using

*** buffer overflow detected ***: ./mkfs.btrfs terminated
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(__fortify_fail+0x50)[0xb7774df0]
/lib/i386-linux-gnu/libc.so.6(+0xe4cca)[0xb7773cca]
/lib/i386-linux-gnu/libc.so.6(__strcpy_chk+0x3f)[0xb777305f]
./mkfs.btrfs[0x805acc4]
./mkfs.btrfs[0x805def6]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0xb76a5e37]
./mkfs.btrfs[0x8048ef1]
======= Memory map: ========
......

a tiny patch could fix it.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
2011-10-25 09:18:59 -04:00
Sergei Trofimovich 3d7c94cfec btrfsck: decode error properly
check_mounted() returns kernel-style negative errors.
Patch drops sign for strerror().

Before the patch:
check_mounted(): Could not open /dev/sdb2
Could not check mount status: Unknown error 18446744073709551603

After the patch:
check_mounted(): Could not open /dev/sdb2
Could not check mount status: Permission denied

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2011-10-25 09:18:59 -04:00
Andreas Philipp a8b624eae7 check number of args for btrfs sub snap correctly
Check whether there are the right number of arguments (exatly 2 without
the flag -r) in the subcommand handler for the btrfs subvolume snapshot
command.

Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
2011-10-25 09:18:59 -04:00
Zhong, Xin a70b0b2bba Btrfs-progs: add "btrfs subvolume get-default" subcommand
Add subcommand to get the default subvolume of btrfs filesystem

V2->V3:
* add man page
* based on http://git.darksatanic.net/repo/btrfs-progs-unstable.git
  integration-20110705

Reviewed-by: Andreas Philipp <philipp.andreas@gmail.com>
Reviewed-by: Goffredo Baroncelli <kreijack@libero.it>
Reported-by: Yang, Yi <yi.y.yang@intel.com>
Signed-off-by: Zhong, Xin <xin.zhong@intel.com>
2011-10-25 09:18:59 -04:00
Wang Sheng-Hui fdbebea13b btrfs-progs-unstable: replace debug-tree to btrfs-debug-tree in INSTALL
From c04da1655df6d75db834ddbd3a3b4a58a0d9a0c9 Mon Sep 17 00:00:00 2001
From: Wang Sheng-Hui <shhuiw@gmail.com>
Date: Mon, 18 Jul 2011 02:17:31 -0500
Subject: [PATCH] btrfs-progs-unstable: replace debug-tree to btrfs-debug-tree in INSTALL

debug-tree doesn't exist after btrfs-progs installed.
Use btrfs-debug-tree to print FS metadata in text form,
not debug-tree.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
2011-10-25 09:18:59 -04:00
Hugo Mills ae62acb3c9 fix incorrect argument checking for "btrfs sub snap -r"
Stephane Chazelas and Andreas Philipp spotted that the earlier patch
fixing this issue was incomplete, and should also update the argument-
count checking code as well.

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Jan Schmidt 25439670a6 btrfs-progs: scrub added to manpage
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Jan Schmidt 4ba1653187 btrfs-progs: scrub userland implementation
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Jan Schmidt 828f2b30df btrfs-progs: added check_mounted_where
new version of check_mounted() returning more information gathered while
searching. check_mounted() is now a wrapper for check_mounted_where(). the
new version is needed by scrub.c

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Jan Schmidt eecfba1d34 btrfs-progs: scrub ioctls
- scrub structs added
- ioctls for scrub
- BTRFS_FSID_SIZE moved

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Jan Schmidt 19011f9ab6 btrfs-progs: commands added
- scrub commands added
- open_file_or_dir no longer static (needed by scrub.c)

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Andreas Philipp d8e974fb4c remove unused include "version.h"
In the file btrfs-list.c version.h was included but not used. So just
drop it.

Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Andreas Philipp be1c3b1fda update manpage entries for btrfs subvolume list
Update the manpage entries for the btrfs subvolume list command to
reflect the newly created additional option '-p'.

Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Andreas Philipp 97a3182fbf print parent ID in btrfs suvolume list
There was some discussion on "where" subvolumes live in. Why do we not
simply print the parent ID for each subvolume in btrfs subvolume list?
This patch adds this functionality when called with parameter "-p".

Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Andreas Philipp fd635cdc2d some style/layout changes
Just do a few simple style/layout changes to make the makefile look
better.

Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Andreas Philipp 3aa511e7ed add all targets to clean target
When issuing 'make clean' not all files generated by the individual
targets have been deleted since some files have been missing in the
definition of the 'make clean' target.

Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Hubert Kario 3c3a13bf3f remove unused variables
fixes compilation warnings with gcc 4.6.0 20110429

Signed-off-by: Hubert Kario <kario@wit.edu.pl>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Hugo Mills db9831e4f4 gcc 4.6: fix potentially unused variable
Fix a complaint by gcc 4.6 that "ret" may be unused in
process_one_leaf of btrfsck.

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:59 -04:00
Kamble, Nitin A 3516e6b56e make btrfs cross compilation friendly
Attached is a patch to fix a cross compilation issue I observed with btrfs-tools.

Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>

Nitin A Kamble
Yocto Project
www.yoctoproject.org

Avoid these kinds of errors while doing cross build:

| ccache i586-poky-linux-gcc -march=i586 --sysroot=/disk0/pokybuild/build0/tmp/sysroots/qemux86 -Wp,-MMD,./.btrfsctl.o.d,-MT,btrfsctl.o -Wall -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O2 -pipe -g -feliminate-unused-debug-types -c btrfsctl.c
| gcc -O2 -pipe -g -feliminate-unused-debug-types -o btrfsctl btrfsctl.o ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o root-tree.o dir-item.o file-item.o inode-item.o inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o volumes.o utils.o btrfs-list.o -Wl,-O1  -Wl,--as-needed -luuid
| /usr/bin/ld: i386 architecture of input file `btrfsctl.o' is incompatible with i386:x86-64 output
| /usr/bin/ld: i386 architecture of input file `ctree.o' is incompatible with i386:x86-64 output
2011-10-25 09:18:58 -04:00
Hugo Mills acee5809c1 mkfs.btrfs: Fix compilation errors with gcc 4.6
gcc 4.6 complains about several possible use-before-initialise cases
in mkfs, and stops. Fix these by initialising one of the variables in
question, and using the correct error-handling paths for the
remainder.

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:58 -04:00
cwillu 796a0e9cc4 Btrfs-progs: Correct path munging in bcp
Bcp was assuming that a path on the command line would never have a slash after
it, which is silly, and would cause the first letter of everything in the root
of the source to be truncated.  Instead, use os.path.relpath to handle
it properly.

Signed-off-by: Carey Underwood <cwillu@cwillu.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:58 -04:00
Arne Jansen 48d29930ed btrfs-map-logical: segfaults when no output file is given
when no output file is given, info_file stays NULL and the following
fprintf segfaults. Default to stdout.

Signed-off-by: Arne Jansen <sensille@gmx.net>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:58 -04:00
Sergei Trofimovich 925ac32518 mkfs.btrfs: fix error text in '-r' mode
Smart gcc noticed use of uninitialized warning when compiled
with -O0 flags:

    mkfs.c:1291: error: 'file' may be used uninitialized in this function

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:58 -04:00
Sergei Trofimovich d69c30808c mkfs.btrfs: fix memory leak caused by 'scandir()' calls
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:58 -04:00
Sergei Trofimovich e06947319c mkfs.btrfs: free buffers allocated by pretty_sizes
found by valgrind:
==2559== 16 bytes in 1 blocks are definitely lost in loss record 3 of 19
==2559==    at 0x4C2720E: malloc (vg_replace_malloc.c:236)
==2559==    by 0x412F7E: pretty_sizes (utils.c:1054)
==2559==    by 0x4179E9: main (mkfs.c:1395)

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:58 -04:00