Commit Graph

520 Commits (3b4e2d61961f7308885cce98bfecdf07d6c0ed01)
 

Author SHA1 Message Date
Miao Xie 3b4e2d6196 Btrfs-progs: fix several complie warning
This patch fixed the following warning:
cmds-send.c:464:6: warning: ‘ret' may be used uninitialized in this function [-Wuninitialized]
crc32c.c:121:1: warning: control reaches end of non-void function [-Wreturn-type]
send-utils.c:69:11: warning: ‘comp' may be used uninitialized in this function [-Wuninitialized]
send-utils.c:126:6: warning: ‘comp' may be used uninitialized in this function [-Wuninitialized]
send-utils.c:99:22: warning: ‘entry' may be used uninitialized in this function [-Wuninitialized]
btrfs.c:261:2: warning: implicit declaration of function ‘crc32c_optimization_init' [-Wimplicit-function-declaration]
btrfs.c:105:2: warning: ‘cmd' may be used uninitialized in this function [-Wuninitialized]
restore.c:435:12: warning: ignoring return value of ‘ftruncate', declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
2012-10-04 16:26:31 -04:00
Tsutomu Itoh d88f33152f Btrfs-progs: fix arguments check of qgroup limit
Segmentation fault occurred in the following command.

 # btrfs qgroup limit
 Segmentation fault

So, we should check a minimum number of arguments.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
2012-10-02 13:02:51 +02:00
Josef Bacik 605e806166 Btrfs-progs: only enforce a maximum size if we specify one
My patch

04609add88

introduced a regression where if you mkfs'ed a group of disks with different
sizes it limited the disks to the size of the first one that is specified.
This was not the intent of my patch, I only want it to limit the size based
on the -b option, so I've reworked the code to pass in a max block count and
that fixes the issue.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
2012-10-02 13:02:48 +02:00
David Sterba 45e9ec733d btrfs-progs: fsck: understand the -s option
Short options have to be repeated at the getopt_long call.

Signed-off-by: David Sterba <dsterba@suse.cz>
2012-10-02 13:02:41 +02:00
David Sterba 17e6d421a9 btrfs-progs: mkfs: create root directory with 755 permissions
That's what all other mkfs do and there's no reason for 0555.

Signed-off-by: David Sterba <dsterba@suse.cz>
2012-10-02 13:02:39 +02:00
David Sterba 366b9ca593 btrfs-progs: mkfs: rename nodiscard option to K
The original patch named the option -T, mkfs.xfs uses -K let's keep it
same.

Signed-off-by: David Sterba <dsterba@suse.cz>
2012-10-02 13:02:36 +02:00
Arne Jansen 89fe5b5f66 Btrfs progs: quota groups support
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Arne Jansen <sensille@gmx.net>
2012-09-04 11:15:49 +02:00
Jan Schmidt f99b1f1a63 Btrfs-progs: replace find_mount_root from send code
find_mount_root had the problem that it tried to conclude from a file system
path to a mount point, taking the fsid as an indicator. This only works if
no two subvolumes (sharing the same btrfs fsid) are mounted in the same
hierarchy.

Now instead, we're parsing /etc/mtab and look for the longest match.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
2012-08-20 13:40:18 +02:00
Chris Mason 043a63924c Allow relative paths for btrfs send
The initial btrfs send code was easily confused by relative paths and by
anything that wasn't in the root of the FS.  This fixes it to take
relative paths.

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2012-08-09 12:48:29 -04:00
Chris Mason 71687d74d0 Use intel hardware crc32c where available
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2012-07-26 14:51:27 -04:00
Chris Mason c1690a3832 Switch to -O1 for optimizations to enable FORTIFY_SOURCE
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2012-07-26 14:51:27 -04:00
Alexander Block f1c24cd80d Btrfs-progs: add btrfs send/receive commands
Add user space commands for btrfs send/receive.

Signed-off-by: Alexander Block <ablock84@googlemail.com>
Reviewed-by: David Sterba <dave@jikos.cz>
Reviewed-by: Arne Jansen <sensille@gmx.net>
Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Reviewed-by: Alex Lyakas <alex.bolshoy.btrfs@gmail.com>
2012-07-26 14:51:27 -04:00
Alexander Block a55616ee6c Btrfs-progs: update ioctl.h to support btrfs send ioctl
Add btrfs_ioctl_send_args and BTRFS_IOC_SEND to ioctl.h

Signed-off-by: Alexander Block <ablock84@googlemail.com>
2012-07-26 14:51:27 -04:00
Alexander Block 84b9586a89 Btrfs-progs: update btrfs-progs for subvol uuid+times support
Update ctree.h and ioctl.h for the new uuid+times for subvolumes.

Signed-off-by: Alexander Block <ablock84@googlemail.com>
2012-07-26 14:51:17 -04:00
Alexander Block 499316aeda Btrfs-progs: print inode transid and dir item data field in debug-tree
Add printing of inode transid and dir item data field.

Signed-off-by: Alexander Block <ablock84@googlemail.com>
2012-07-26 14:51:16 -04:00
Alexander Block 9cc8f76129 Btrfs-progs: update ioctl.h to support clone range ioctl
Added missing btrfs_ioctl_clone_range_args and BTRFS_IOC_CLONE_RANGE
to ioctl.h

Signed-off-by: Alexander Block <ablock84@googlemail.com>
2012-07-26 14:51:16 -04:00
Alexander Block e998a46d26 Btrfs-progs: add BTRFS_IOC_SUBVOL_GET/SETFLAGS to ioctl.h
Btrfs send/receive and btrfs props needs this ioctl. This patch
requires a recent kernel with the "Btrfs: use _IOR for
BTRFS_IOC_SUBVOL_GETFLAGS" patch applied.

Signed-off-by: Alexander Block <ablock84@googlemail.com>
2012-07-26 14:51:16 -04:00
David Sterba 8935d84361 btrfs-progs: mkfs: add option to skip trim
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2012-07-06 10:11:10 -04:00
Chris Mason 134adafea2 Btrfs: fix off by one in null termination
A recent commit was null terminating the root listing
strings one byte too short.

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2012-07-05 14:58:51 -04:00
Chris Mason 2588b4f8be Merge branch 'for-chris' of git://github.com/idryomov/btrfs-progs into 0.20 2012-07-05 11:35:42 -04:00
Miao Xie 06cf101a28 Btrfs-progs, btrfs-map-logical: Fix typo in usage
The right option is 'o' not 'c'. And this tool is used for the block devices
on which there is a btrfs file system, so change "mount_point" to "device".

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
2012-07-03 16:27:46 -04:00
Miao Xie 596979bee1 Btrfs-progs, btrfs-corrupt-block: fix the wrong usage
The old usage is a copy of btrfs-map-logical, it's wrong, fix it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
2012-07-03 16:27:46 -04:00
Akira Fujita 24c2ac5eb1 Btrfs-progs: Fix manual of btrfs command
Usage of balancing btrfs is "btrfs filesystem balance",
not "btrfs device balance". And remove unneeded
usage of "btrfs filesystem defrag".
Also fix some typos and over 80 columns.

Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
2012-07-03 16:27:46 -04:00
Phillip Susi c65345db54 btrfs-progs: document --rootdir mkfs switch
Signed-off-by: Phillip Susi <psusi@cfl.rr.com>
2012-07-03 16:27:46 -04:00
Phillip Susi f6b6e93ac8 btrfs-progs: removed extraneous whitespace from mkfs man page
There were extra spaces around some of the arguments in the man
page for mkfs.

Signed-off-by: Phillip Susi <psusi@cfl.rr.com>
2012-07-03 16:27:46 -04:00
Goffredo Baroncelli 5ef69ff8ec scrub_fs_info( ) file handle leaking
The function scrub_fs_info( ) closes and reopen a file handle
passed as argument, when a caller uses the file handle even after the
call.
The function scrub_fs_info( ) is updated to remove the file handle
argument, and instead uses a private own file handle.
The callers are updated to not pass the argument.
2012-07-03 16:27:46 -04:00
Shawn Bohrer 6cb6eeb11d btrfs-progs: Update resize documentation
The btrfs filesystem resize command defaults to only resizing the
filesystem for devid 1, and must have a devid passed in to resize the
filesystem for the other devices in the filesystem.

Additionally the documentation lacked information on how to actually
resize the underlying partition so this provides a little more detail.

Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
2012-07-03 16:27:46 -04:00
Chris Samuel dfb2230423 Fix "set-dafault" typo in cmds-subvolume.c
Andrei Popa reported that there were two typos of default as dafault,
this patch fixes those two typos up.

Signed-off-by: Chris Samuel <chris@csamuel.org>
2012-07-03 16:27:46 -04:00
Hubert Kario 8a8e5deb85 man: fix btrfs man page formatting
Signed-off-by: Hubert Kario <kario@wit.edu.pl>
2012-07-03 16:27:46 -04:00
Josef Bacik 04609add88 btrfs-progs: enforce block count on all devices in mkfs
I had a test that creates a 7gig raid1 device but it was ending up wonky
because the second device that gets added is the full size of the disk
instead of the limited size.  So enforce the limited size on all disks
passed in at mkfs time, otherwise our threshold calculations end up wonky
when doing chunk allocations.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
2012-07-03 16:27:46 -04:00
Miao Xie cfdd42686c Btrfs-progs: fix btrfsck's snapshot wrong "unresolved refs"
If the fs/file tree is not the parent of the snapshot, it is reasonable
that we can not find the relative reference and back reference. But btrfsck
doesn't consider this case, and reports "unresolved refs" message, it's wrong,
fix it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
2012-07-03 16:27:46 -04:00
Jan Kara 1ee733a9ca mkfs: Handle creation of filesystem larger than the first device
On Wed 08-02-12 22:05:26, Phillip Susi wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 02/08/2012 06:20 PM, Jan Kara wrote:
> >   Thanks for your reply. I admit I was not sure what exactly size argument
> > should be. So after looking into the code for a while I figured it should
> > be a total size of the filesystem - or differently it should be size of
> > virtual block address space in the filesystem. Thus when filesystem has
> > more devices (or admin wants to add more devices later), it can be larger
> > than the first device. But I'm not really a btrfs developper so I might be
> > wrong and of course feel free to fix the issue as you deem fit.
>
> The size of the fs is the total size of the individual disks.  When you
> limit the size, you limit the size of a disk, not the whole fs.  IIRC,
> mkfs initializes the fs on the first disk, which is why it was using that
> size as the size of the whole fs, and then adds the other disks after (
> which then add their size to the total fs size ).
  OK, I missed that btrfs_add_to_fsid() increases total size of the
filesystem. So now I agree with you. New patch is attached. Thanks for your
review.

> It might be nice if
> mkfs could take sizes for each disk, but it only seems to take one size
> for the initial disk.
  Yes, but I don't see a realistic usecase so I don't think it's really
worth the work.

								Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR

>From e5f46872232520310c56327593c02ef6a7f5ea33 Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Fri, 10 Feb 2012 11:44:44 +0100
Subject: [PATCH] mkfs: Handle creation of filesystem larger than the first device

mkfs does not properly check requested size of the filesystem. Thus if the
requested size is larger than the first device, it happily creates larger
filesystem than a device it resides on which results in 'attemp to access
beyond end of device' messages from the kernel. So verify specified filesystem
size against the size of the first device.

CC: David Sterba <dsterba@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
2012-07-03 16:27:46 -04:00
Hubert Kario ff2b80b460 Fix segmentation fault when opening invalid file system
Signed-off-by: Hubert Kario <kario@wit.edu.pl>
2012-07-03 16:27:46 -04:00
Josef Bacik 3f388b9690 Btrfs-progs: make btrfs filesystem show <uuid> actually work
The btrfs filesystem show command is only actually searching for labels,
it's not searching for UUID's at all.  This patch fixes that problem.
Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
2012-07-03 16:27:46 -04:00
Jim Meyering 8ad8e789fc mkfs: avoid heap-buffer-read-underrun for zero-length "size" arg
* mkfs.c (parse_size): ./mkfs.btrfs -A '' would read and possibly
write the byte before beginning of strdup'd heap buffer.  All other
size-accepting options were similarly affected.

Reviewed-by: Josef Bacik <josef@redhat.com>
2012-06-05 19:56:20 +01:00
Jim Meyering 54e345b5c2 avoid several strncpy-induced buffer overruns
* restore.c (main): Ensure strncpy-copied dir_name is NUL-terminated.
* btrfsctl.c (main): Likewise, for a command-line argument.
* utils.c (multiple functions): Likewise.
* btrfs-list.c (add_root): Likewise.
* btrfslabel.c (change_label_unmounted): Likewise.
* cmds-device.c (cmd_add_dev, cmd_rm_dev, cmd_scan_dev): Likewise.
* cmds-filesystem.c (cmd_resize): Likewise.
* cmds-subvolume.c (cmd_subvol_create, cmd_subvol_delete, cmd_snapshot):
Likewise.

Reviewed-by: Josef Bacik <josef@redhat.com>
2012-06-05 19:56:20 +01:00
Jim Meyering 47f029cc8b restore: don't corrupt stack for a zero-length command-line argument
Given a zero-length directory name, the trailing-slash removal
code would test dir_name[-1], and if it were found to be a slash,
would set it to '\0'.

Reviewed-by: Josef Bacik <josef@redhat.com>
2012-06-05 19:56:20 +01:00
Jim Meyering 6fc24e4a70 mkfs: use strdup in place of strlen,malloc,strcpy sequence
* mkfs.c (traverse_directory): No semantic change.

Reviewed-by: Josef Bacik <josef@redhat.com>
2012-06-05 19:56:20 +01:00
Jim Meyering 0195702a09 btrfs_scan_one_dir: avoid use-after-free on error path
If we iterate the "goto again" loop, we've called "closedir(dirp)",
yet at the top of the loop, upon malloc failure we "goto fail",
where we test dirp and if non-NULL, call closedir(dirp) again.
* utils.c (btrfs_scan_one_dir): Clear "dirp" after closedir to avoid
use-after-free upon failed fullpath = malloc(...

Signed-off-by: Jim Meyering <meyering@redhat.com>
2012-06-05 19:56:20 +01:00
Josef Bacik eda76e4629 Btrfs-progs: make btrfsck aware of free space inodes
The new xfstests will run fsck against the volume to make sure we didn't
introduce any inconsistencies, which is nice except we will error out
immediately if we mount with inode_cache.  We need to make btrfsck skip the
special free space cache items and then just assume that we have a link for
the free space cache inode item.  This makes btrfsck pass with success on a
fs with inode cache items.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
2012-06-05 19:56:19 +01:00
Sergei Trofimovich 996722194f Makefile: use $(MAKE) instead of hardcoded 'make'
CC: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2012-06-05 19:56:19 +01:00
Sergei Trofimovich b0a408ac63 Makefile: use $(CC) as a compilers instead of $(CC)/gcc
CC: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2012-06-05 19:56:19 +01:00
Wang Sheng-Hui f9ffe57844 btrfs-progs: cleanup: remove the redundant BTRFS_CSUM_TYPE_CRC32 macro definition in ctree.h
Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
2012-06-05 13:35:58 +01:00
Chris Mason 1957076ab4 Add incompat flag for big metadata blocks
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2012-03-28 12:05:27 -04:00
Chris Mason 19cf368342 mkfs: make -l and -n an alias for each other
We don't allow different leaf and node blocksizes, so
this just makes the two options mean the same thing

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2012-03-26 16:17:08 -04:00
Ilya Dryomov 35d7b486b3 Btrfs-progs: allow dup for data chunks in mixed mode
Before commit a46e7ff2 was merged it was possible to create dup for
data+metadata chunks (mixed mode) by giving -m raid1 -d raid1 -M to
mkfs.  a46e7ff2 purposefully disabled behind the scenes profile
upgrading/downgrading, so give users a chance to pick dup explicitly and
bail if dup for data is requested in normal mode.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-03-13 22:29:44 +02:00
Ilya Dryomov 842a2fb01b Btrfs-progs: make print-tree.c aware of free space cache
This adds proper formatting for free space and inode cache items in
btrfs-debug-tree output.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-03-13 18:36:56 +02:00
Ilya Dryomov a0bdde58f8 Btrfs-progs: bring 'subvol get-default' back in
Commit bab2c565 accidentally broke 'subvol get-default' command by
removing almost all of the underlying code.  Bring it back with some
fixes and improvements.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-03-12 19:17:39 +02:00
Ilya Dryomov 55bf019ff4 Btrfs-progs: refactor resolve_root() function a bit
Don't pass a pointer to root_id to resolve_root().  It's always the same as
ri->root_id, passing a pointer hints that root_id can somehow change which is
not true.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-03-12 19:17:39 +02:00
Ilya Dryomov 294c1bafd2 Btrfs-progs: nuke redundant zeroing in __list_subvol_search()
There's no need to zero out things twice.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-03-12 19:17:39 +02:00