Commit graph

2963 commits

Author SHA1 Message Date
David Sterba d7244f9582 btrfs-progs: convert: move prepare_system_chunk_sb
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 9e89a1cd42 btrfs-progs: convert: move migrate_super_block
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba a1177242d8 btrfs-progs: convert: move init_btrfs
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba c4c17f4c52 btrfs-progs: convert: move make_convert_data_block_groups
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 65eca20739 btrfs-progs: convert: move create_subvol
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 6ffb89577f btrfs-progs: convert: move link_subvol
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba c946c415dd btrfs-progs: convert: move create_image
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 3c3c59f077 btrfs-progs: convert: move convert_read_used_space
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 52df1d80a3 btrfs-progs: convert: move calculate_available_space
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 0baa7a7e68 btrfs-progs: convert: move wipe_reserved_ranges
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba f7318e2509 btrfs-progs: convert: move wipe_one_reserved_range
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 1a7ee0c296 btrfs-progs: convert: move _expand_extent_cache
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 0e4cabc479 btrfs-progs: convert: move migrate_reserved_ranges
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba d44d9fb4f0 btrfs-progs: convert: move migrate_one_reserved_range
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 3a62c6845b btrfs-progs: convert: move create_image_file_range
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 14e6cbe973 btrfs-progs: convert: move block_iterate_proc
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 58e58ab38c btrfs-progs: convert: move record_file_blocks
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 09dac60638 btrfs-progs: convert: move init_blk_iterate_data
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 70b5221bfb btrfs-progs: convert: move csum_disk_extent
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 3ec64ddf00 btrfs-progs: convert: move read_disk_extent
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 411de0cf4a btrfs-progs: convert: move convert_insert_dirent
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba f507d20d2f btrfs-progs: convert: move intersect_with_sb
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba a1e8a8739c btrfs-progs: convert: prefix all ext2-related helpers
Add ext2_ prefix to all functions that seem to be ext2-specific.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 73071f0ce4 btrfs-progs: build: extend convert options
Add --with-convert[=VALUE] option to configure. Accepts ext2, auto, yes,
or no, but will be extended to more in the future. The configure-time
defines are not used in the code, ext2 is built-in unconditionally.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba aa07e4be00 btrfs-progs: build: add per-tool cflags variable
The standalone tools are built from pattern rules, add support for
per-tool cflaags, like btrfs_something_clfags.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba b762b78a60 btrfs-progs: mkfs: cleanup, open_ctree to fs_info and use directly
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 2060b682df btrfs-progs: mkfs: kill print_version
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba e44415f713 btrfs-progs: mkfs: clean up make_image
The exact errors are printed, the removed message does not seem to be
necessary. Return proper errors.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba e1c8514705 btrfs-progs: mkfs: help and usage now to to stdout
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba b1ebc6df7b btrfs-progs: mkfs: handle and report transaction commit failures
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 33a9723066 btrfs-progs: mkfs: switch BUG_ON to error handling in traverse_directory
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 4fd93da3cf btrfs-progs: document all btrfs_open_ctree_flags
Document and add unsigned type to the values.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba fa4559e424 btrfs-progs: mkfs: improve error handling in recow_roots
Return and handle errors in the callchain.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 0408296c7a btrfs-progs: mkfs: improve error handling in main()
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 7b6c4bb33f btrfs-progs: mkfs: return errors from block group creation functions
No more BUG_ONs, we don't care about cleanup as the filesystem is
supposed to be marked as partial.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 2ff04db5f4 btrfs-progs: two staged filesystem creation
The filesystem existence on a device is manifested by the signature,
during the mkfs process we write it first and then create other
structures. Such filesystem is not valid and should not be registered
during device scan nor listed among devices from blkid.

This patch will introduce two staged creation. In the first phase, the
signature is wrong, but recognized as a partially created filesystem (by
open or scan helpers). Once we successfully create and write everything,
we fixup the signature. At this point automated scanning should find
a valid filesystem on all devices.

We can also rely on the partially created filesystem to do better error
handling during creation. We can just bail out and do not need to clean
up.

The partial signature is '!BHRfS_M', can be shown by

  btrfs inspect-internal dump-super -F image

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:31 +02:00
David Sterba 974cfeeebb btrfs-progs: mkfs: do not scan partially initialized devices
We call scan ioctl on the devices too early, when most of the filesystem
structures are not yet created. Move the registration to the end, after
the filesystem gets closed.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:36:58 +02:00
David Sterba 3c350dec06 btrfs-progs: introduce signature for a partially set up filesystem
Currently the superblock is created first, with a valid signaure, but
the rest of the filesystem is missing. When the creation process is
interrupted, the filesystem still might be considered as valid.

To prevent that, create the filesytem with an invalid signature that
would be still recognized during the mkfs process, and finalize at the
end.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:36:58 +02:00
David Sterba 059832da5f btrfs-progs: make superblock reading/scanning api more generic
We'll add more modes that affect scanning.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:36:58 +02:00
David Sterba c11bd9cfd2 btrfs-progs: pass OPEN_CTREE flags as unsigned
As we're passing a set of flags, the enum type is not appropriate.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:36:54 +02:00
David Sterba 4241e27ee1 btrfs-progs: build: add more debugging features
Add options to show file and line or stack trace for error/warning
messages that use the common helpers. Possible to let any error stop
execution for ease of analysis and debugging.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-22 16:44:22 +02:00
David Sterba 49184a737b btrfs-progs: switch ternary op to an if in cmd_subvol_show
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-19 15:45:04 +02:00
Qu Wenruo 1c202eb06d btrfs-progs: print-tree: Print hex and human readable root flags
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-19 13:54:05 +02:00
Qu Wenruo 44e2b7a7e5 btrfs-progs: print-tree: Print human readable inode flags
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-19 13:53:52 +02:00
Qu Wenruo 4f3ccdd518 btrfs-progs: convert-test: Check if the ext2_save/image is read only
Old convert codes uses both 0400 permission and INODE_READONLY flag to
make the converted ext2 image readonly.

While new convert treat the inode just as normal inode, with no special
inode flag and uses 0600 permission.
This makes user able to modify converted image unintentionally and make
rollback fails.

This test case will test the regression.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-19 13:53:28 +02:00
Qu Wenruo bdadea75e4 btrfs-progs: convert: Fix a regression that ext2_save/image is not readonly
The new convert treats the convert image as a normal file, without any
special flags and permissions.

This is different from original code:
1) Permission changed from 0400 to 0600
2) Inode lacks READONLY flag

This makes we can read-write mount the ext2 image and cause rollback
failure.

Follow old code behavior, use 0400 permission and add back READONLY
flag to fix it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-19 13:52:43 +02:00
David Sterba 55aa862ea2 btrfs-progs: docs: refer to btrfs(5) from btrfs(8)
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-18 19:50:43 +02:00
David Sterba 637c005ac8 btrfs-progs: docs: update btrfs-quota manual page, more sections
Add more overall sections.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-18 19:50:43 +02:00
David Sterba c7f8852296 btrfs-progs: docs: update btrfs-quota manual page
Copy the intoductory and usecases from the text written by Arne Jansen,

https://git.kernel.org/cgit/linux/kernel/git/arne/qgroups-doc.git/

The graphics missing for now.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-18 19:50:43 +02:00
David Sterba 4351c8fe3f btrfs-progs: mkfs: switch to new error message helpers
Do not use fprintf, adjust messages, add verbose errno or at least the
errorr code if there's no clear mapping to a string.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-18 18:38:34 +02:00