summaryrefslogtreecommitdiff
path: root/convert
Commit message (Collapse)AuthorAge
* btrfs-progs: Refactor write_and_map_eb to use btrfs_fs_infoQu Wenruo2017-07-12
| | | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Refactor sectorsize users in convert/source-ext2.cQu Wenruo2017-07-03
| | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: Refactor sectorsize users in convert/main.cQu Wenruo2017-07-03
| | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: Refactor sectorsize in convert/source-fs.cQu Wenruo2017-07-03
| | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: Remove deprecated leafsize usageQu Wenruo2017-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | Leafsize is deprecated for a long time, and kernel has already updated ctree.h to rename sb->leafsize to sb->__unused_leafsize. This patch will remove normal users of leafsize: 1) Remove leafsize member from btrfs_root structure Now only root->nodesize and root->sectorisze. No longer root->leafsize. 2) Remove @leafsize parameter from btrfs_setup_root() function Since no root->leafsize, no need for @leafsize parameter. The remaining user of leafsize will be: 1) btrfs inspect-internal dump-super Reformat the "leafsize" output to "leafsize (deprecated)" and use le32_to_cpu() to do the cast manually. 2) mkfs We still need to set sb->__unused_leafsize to nodesize. Do the manual cast too. 3) convert Same as mkfs, these two superblock setup should be merged later Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* Btrfs-progs: convert: do not clear header revLiu Bo2017-06-30
| | | | | | | | | | | So btrfs_set_header_flags() vs btrfs_set_header_flag, the difference is sort of similar to "=" vs "|=", when creating and initialising a new extent buffer, convert uses the former one which clears header_rev by accident. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs-progs: convert: do not clear nodatasum flag in inode itemLiu Bo2017-06-30
| | | | | | | | | With the current btrfs-convert, if we convert a ext4 without data checksum, it'd not set nodatasum flag in inode item, nor create csum item, reading file ends up with checksum errors. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Add larger device supportLakshmipathi.G2017-06-26
| | | | | | | | | | | | | | | | With larger file system (in this case its 22TB), ext2fs_open() returns EXT2_ET_CANT_USE_LEGACY_BITMAPS error message with ext2fs_read_block_bitmap(). To overcome this issue, (a) we need pass EXT2_FLAG_64BITS flag with ext2fs_open. (b) use 64-bit functions like ext2fs_get_block_bitmap_range2, ext2fs_inode_data_blocks2,ext2fs_read_ext_attr2 (c) use 64bit types with btrfs_convert_context fields Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=194795 Signed-off-by: Lakshmipathi.G <lakshmipathi.g@giis.co.in> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: widen int types in convert contextLakshmipathi.G2017-06-26
| | | | | | | | The u32 types in the convert context might not be enough for some very large filesytems (20TB). Use 64bit types to be safe. Signed-off-by: Lakshmipathi.G <lakshmipathi.g@giis.co.in> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Add missing return for HOLE mode when checking convert ↵Qu Wenruo2017-03-31
| | | | | | | | | | | | | | image In check_convert_image(), for normal HOLE case, if the file extents are smaller than image size, we set ret to -EINVAL and print error message. But forget to return. This patch adds the missing return to fix it. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Make btrfs_reserved_ranges constQu Wenruo2017-03-16
| | | | | | | | | | | | Since btrfs_reserved_ranges array is just used to store btrfs reserved ranges, no one will nor should modify them at run time, make them static and const will be better. This also eliminates the use of immediate number 3. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ definition stays in source-fs.c ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add missing limits headersBaruch Siach2017-03-16
| | | | | | | Build under musl libc fails because of missing PATH_MAX and XATTR_NAME_MAX macro declarations. Add the required headers. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
* btrfs-progs: convert: Rework rollbackQu Wenruo2017-03-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework rollback to a more easy to understand way. New convert behavior makes us to have a more flex chunk layout, which only data chunk containing old fs data will be at the same physical location, while new chunks (data/meta/sys) can be mapped anywhere else. This behavior makes old rollback behavior can't handle it. As old behavior assumes all data/meta is mapped in a large chunk, which is mapped 1:1 on disk. So rework rollback to handle new convert behavior, enhance the check by only checking all file extents of convert image, only to check if these file extents and therir chunks are mapped 1:1. This new rollback check behavior can handle both new and old convert behavior, as the new behavior is a superset of old behavior. Further more, introduce a simple rollback mechanisim: 1) Read reserved data (offset = file offset) from convert image 2) Write reserved data into disk (offset = physical offset) Since old fs image is a valid fs, and we only need to rollback superblocks (btrfs reserved ranges), then we just read out data in reserved range, and write it back. Due to the fact that all other file extents of converted image is mapped 1:1 on disk, we put the missing piece back, then the fs is as good as old one. Then what we do in btrfs is just another dream. With this new rollback mechanisim, we can open btrfs read-only, so we won't cause any damage to current btrfs, until the final piece (0~1M, containing 1st super block) is put back. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ port to v4.10 ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Introduce function to check if convert image is able ↵Qu Wenruo2017-03-16
| | | | | | | | | | | | | | | | | | | | | | | | | | to be rolled back Introduce a function, check_convert_image() to check if that image is rollback-able. This means all file extents except one of the btrfs reserved ranges, must be mapped 1:1 on disk. 1:1 mapped file extents must match the following conditions: 1) Their file_offset(key.offset) matches its disk_bytenr 2) The corresponding chunk must be mapped 1:1 on disk That's to say, it's a SINGLE chunk, and chunk logical matches with stripe physical. Above 2 conditions ensured that file extent lies the exactly the same position as in the old filesystem. For data in reserved ranges of btrfs, they are relocated to new places, and in that case, we use btrfs_read_file() to read out the content for later rollback use. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: convert: Introduce function to read out btrfs reserved rangeQu Wenruo2017-03-16
| | | | | | | Introduce a new function, read_reserved_ranges(), to allow later rollback to use these data to do rollback. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: convert: Use reserved ranges array to cleanup open codeQu Wenruo2017-03-16
| | | | | | | | | | | Since we have reserved ranges array now, we can use them to skip all these open codes. And add some comment and asciidoc art for related part. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ port to v4.10 ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Introduce simple range structure for convert reserved ↵Qu Wenruo2017-03-16
| | | | | | | | | | | | | | | ranges Introduce a new strucutre, simple_range, to present one contingous range. Also, use such structure to define btrfs_reserved_ranges(), which convert and rollback will use. Suggested-by: David Sterba <dsterba@suse.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ split hunks to new file structure ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Add comment for the overall convert designQu Wenruo2017-03-16
| | | | | | | | | | | | | Convert is now a little complex due to that fact we need to separate metadata and data chunks for different profiles. Add a comment with ascii art explaining the whole design and point out the really complex part, so any newcomers interested in convert can get a quick overview of it before digging into the hard to read code. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ wording and formatting adjustments ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused argument from clear_extent_dirtyDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused argument from set_extent_bitsDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused argument from write_and_map_ebDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused argument from btrfs_csum_dataDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: improve assert in make_convert_btrfsDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: rename members that clash with other functionsDavid Sterba2017-03-08
| | | | | | Rename 'free' and also 'used' for consistency. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: clear whole mkfs_cfg at onceDavid Sterba2017-03-08
| | | | | | Zero out the structure and set only the requested fields. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move internal bg size definitionDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: rename ext2 function to create a symlinkDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: add stub makefile to convertDavid Sterba2017-03-08
| | | | | | A shortcut to compile btrfs-convert from inside the directory. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: use bit field for convert flagsDavid Sterba2017-03-08
| | | | | | | Use one flag field instead of several variables. The change cascades down to the callchain and modifies several functions. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: use helper for special inode number checkDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: better error handling in ext2_read_used_spaceDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: remove unused includesDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: use on-stack buffer for subvol name dirDavid Sterba2017-03-08
| | | | | | Get rid of dynamic allocation. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: use fixed lenght array for source fs nameDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move struct initialization to the init functionDavid Sterba2017-03-08
| | | | | | | The context is zeroed in convert_open_fs after and overwrites the rbtree initialization, which accidentally is the same (NULL). Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: update some forward declarationsDavid Sterba2017-03-08
| | | | | | Add missing and reorder so they come next to the structures using them. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: use wider types types for inode counts for progress ↵David Sterba2017-03-08
| | | | | | reports Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: make list of source fs more visibleDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move implementation for interal conversion API to own fileDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move ext2 conversion out of main.cDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move ext2 definitions out of mainDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move definitions for interal conversion API to own fileDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move fs features declarations to own header from utilsDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move common api implementation to own fileDavid Sterba2017-03-08
| | | | | | Lots of moved code but no actual changes. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move convert definitions to own headerDavid Sterba2017-03-08
| | | | | | | Create a header for filesystem conversion API, the config and the main entry function. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move mkfs definitions to own headerDavid Sterba2017-03-08
| | | | | | | Create a header for filesystem creation API, the config and the main entry function. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move help defines to own headerDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs/convert: separate the convert part from make_btrfsDavid Sterba2017-01-27
| | | | | | | The regulare mkfs_btrfs does not anything special about convert and just passes the arguments. Make that two functions. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: file-item: Fix wrong file extents insertedQu Wenruo2016-12-21
| | | | | | | | | | | | | | | | | | | If we specify NO_HOLES incompat feature when converting, the result image still uses hole file extents. And further more, the hole is incorrect as its disk_num_bytes is not zero. The problem is at btrfs_insert_file_extent() which doesn't check if we are going to insert hole file extent. Modify it to skip hole file extents to allow it follow restrict NO_HOLES flag. And since no_holes flag can be triggered on half-way, so current fsck won't report such error, as it consider it as old file holes. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Fix migrate_super_block() to work with 64k sectorsizeChandan Rajendra2016-12-14
| | | | | | | | | | | | | migrate_super_block() uses sectorsize to refer to the size of the superblock. Hence on 64k sectorsize filesystems, it ends up computing checksum beyond the super block length (i.e. BTRFS_SUPER_INFO_SIZE). This commit fixes the bug by using BTRFS_SUPER_INFO_SIZE instead of sectorsize of the underlying filesystem. Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>