Commit Graph

135 Commits

Author SHA1 Message Date
David Sterba
33f07b0d03 btrfs-progs: convert: use on-stack path buffer in link_subvol
We don't need to conserve stack space too much unlike kernel, also
remove one error condition.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:47:31 +01:00
David Sterba
c0807cbfc4 btrfs-progs: convert: use on-stack path buffer in create_image
We don't need to conserve stack space too much unlike kernel, also
remove one error condition.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:47:31 +01:00
David Sterba
aca69c9d39 btrfs-progs: convert: use on-stack path buffer in record_file_blocks
We don't need to conserve stack space too much unlike kernel, also
remove one error condition.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:47:31 +01:00
David Sterba
365c2de3bc btrfs-progs: convert: switch more messages to common helpers
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:13:52 +01:00
Qu Wenruo
8570a0c3a4 btrfs-progs: convert: Convert ext inode flags to btrfs inode flags
Before this patch, btrfs-convert never copy ext* inode flags to
corresponding btrfs inode flags.

This makes common flags like APPEND/SYNC/SYNCDIR/IMMUTABLE not copied to
btrfs inode.

This patch introduces ext2_convert_inode_flags() function to handle the
convert, so btrfs-convert can copy as many inode flags as possible.

Reported-by: Lakshmipathi.G <lakshmipathi.g@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 14:58:07 +02:00
David Sterba
d27c586c5b btrfs-progs: convert: add new callback to check state
Make the hardcoded ext2 call to a generic per-fs callback.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
Nicholas D Steeves
6bdb1cfbc1 btrfs-progs: fix user-facing typos in docs and help strings
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:22 +02:00
Lakshmipathi.G
b56fe16922 btrfs-progs: convert: check source file system state
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
[ add doc note ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 11:35:49 +02:00
David Sterba
890f4a61d7 btrfs-progs: cleanup, kill trivial btrfs_key_type helper
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 11:33:15 +02:00
David Sterba
555743075b btrfs-progs: cleanup, kill trivial btrfs_set_key_type helper
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 11:33:15 +02:00
David Sterba
6733181501 btrfs-progs: convert: improve error handling in do_rollback
Handle transaction errors.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 11:33:15 +02:00
David Sterba
1ed3426d3f btrfs-progs: use standard allocation functions in non-kenrel code
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 11:33:15 +02:00
David Sterba
93a34924e1 btrfs-progs: convert: improve error handling in create_image_file_range
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 14:12:38 +02:00
David Sterba
7aaa1a92f6 btrfs-progs: mkfs: use preallocated buffers for config uuids
No need for dynamic allocation, the buffers are small, remove the
now-useless error conditions.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 13:44:24 +02:00
David Sterba
df1d2918c3 btrfs-progs: convert: switch to common error helpers in do_rollback
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba
9135ee9274 btrfs-progs: convert: reword message when conversion fails
The filesystem will not be finalized, no difference if it's before or
after the chunk mapping fixups.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba
ef0db7e748 btrfs-progs: convert: switch to message helpers in do_convert
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba
7cad06d970 btrfs-progs: convert: remove redundant check
The check for sectorsize is properly done in do_convert, remove the
BUG_ON.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba
d4a6c73aac btrfs-progs: convert: improve error hanling of init_btrfs
Replace BUG_ONs and verbosely report the errors.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba
60e45f8aa3 btrfs-progs: convert: improve error hanling of create_subvol
Replace BUG_ONs and verbosely report the errors.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba
5c2e13f853 btrfs-progs: convert: improve error hanling of link_subvol
Replace BUG_ONs and verbosely report the errors.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba
e0c6cf3c0e btrfs-progs: convert: make ext2 compilation honor the configure options
Now ext2 conversion will be built in iff it's selected by --with-convert
option. Default is yes.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
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
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
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
Qu Wenruo
9aae31f124 btrfs-progs: convert: Fix a bug which fails to insert hole file extent
When copying inode, if there is a file referring part of a hole range,
convert will fail.

The problem is, when calculating real extent bytenr, it doesn't check if
the original extent is a hole.

In case the orinal extent is a hole, we still calculate bytenr using
file_pos - found_extent_file_pos, causing non-zero value, and later
btrfs_record_file_extent() detects that we are pointing to non-exist
extent and aborts convert.

Fix it by checking the disk_bytenr before calculating real disk bytenr.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-07 18:15:19 +02:00
Qu Wenruo
db6f9251e5 btrfs-progs: convert: Insert needed holes for superblock migration
New convert doesn't insert holes for superblock migration range.

Unlike the old design, which only relocates 4K (superblock size) to
other places.
In the new design, to make sure convert can handle different page sizes
and align chunks bytenr, we relocate the whole 64K range.

And if there is only a 4K used block inside 64K superblock migration
range, it will make converted the fs have discontiguous file extents.

This patch will fix it by inserting needed holes to avoid such
discontinuous error.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-07 18:15:19 +02:00