summaryrefslogtreecommitdiff
path: root/btrfs-convert.c
Commit message (Collapse)AuthorAge
* btrfs-progs: typo review of strings and commentsNicholas D Steeves2016-06-01
| | | | | Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: fix typo in original image subvolume nameDavid Sterba2016-05-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use safe copy for label buffer everywhereDavid Sterba2016-03-30
| | | | | | | | There's a mix of opencoded strncpy + null termination, strncpy, memcppy without termination etc. Unify them and use the helper. Resolves-coverity-id: 1357105 Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: unify argc min/max checkingDavid Sterba2016-03-14
| | | | | | We don't want to modify argc. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Introduce new members for btrfs_convert_contextQu Wenruo2016-01-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce 3 new members for btrfs_convert_context: 1) struct cache_tree used Records accurate byte ranges which are used by old filesystem. This will be used to create old filesystem image. 2) struct cache_tree data_chunks Records batched ranges which must be covered by data chunks. The bytenr range is optimized to meet all the chunk requirement. 3) u64 total_bytenr Records how large the filesystem is in bytenr. Yes, we can calculate it easy, but that's for old blocks based filesystem. This will make it more friendly for extent based filesystem. And later cctx->block_counts and may be removed And 2 for mkfs_config: 1) char *chunk_uuid. Used as temporary chunk_uuid (unparsed) string for later make_convert_btrfs() 2) u64 super_bytenr Records the new temporary super bytenr after make_btrfs(). Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: add context and operations struct to allow different ↵Jeff Mahoney2015-11-26
| | | | | | | | | | | file systems Push out common convert operations into function pointers that we can ultimately allow other file systems to use to provide their own conversions. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: simplify empty stirngs checkDavid Sterba2015-11-06
| | | | | | We can do a strlen(str) == 0 in a simpler way. Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs-progs: fix btrfs-convert rollback to check ROOT_BACKREFLiu Bo2015-11-02
| | | | | | | | | | | | | | | Btrfs has changed to delete subvolume/snapshot asynchronously, which means that after umount itself, if we've already deleted 'ext2_saved', rollback can still be completed. So this adds a check for ROOT_BACKREF before checking ROOT_ITEM since ROOT_BACKREF is immediately not in the btree after ioctl(BTRFS_IOC_SNAP_DESTROY) returns. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ updated error messages ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Print different error message if convert partly failed.Qu Wenruo2015-10-07
| | | | | | | | | | | | | When testing under libguestfs, btrfs-convert will never succeed to fix chunk map, and always fails. But in that case, it's already a mountable btrfs. So better to info user with different error message for that case. The root cause of it is still under investigation. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: utils: Check nodesize against featuresQu Wenruo2015-10-02
| | | | | | | | | | | Check nodesize against features, not only sectorsize. In fact, one of the btrfs-convert and mkfs differs in the nodesize check. This patch also provides the basis for later btrfs-convert fix. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: close inode scan in copy_inodesZhao Lei2015-09-09
| | | | | | | | We need to call ext2fs_close_inode_scan to release resources from ext2fs_open_inode_scan. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Avoid uninitialized data in output of btrfs-convertZhao Lei2015-09-09
| | | | | | | | The sequence, transid and reserved fields of inode were writen to disk with uninitizlized value, this patch fixes it. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: rework checks of label sizeDavid Sterba2015-09-02
| | | | | | | | | | | Coverity complains that the fslabel might be longer than the superblock buffer, down in do_convert. The label is at most 255 bytes, terminated by zero. Use buffers of the right size. Resolves-coverity-id: 1320911 Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix memory leak in btrfs-convert main()Byongho Lee2015-09-01
| | | | | | | | | | | | | | | | In btrfs-convert main(), strdup() allocates memory to fslabel but that memory is not freed. We could fix it by adding free() calls to every return point, but that would make the code messy because there are several return paths. So I fix it by changing the code using strdup() with local array and strncpy(). And btrfs-convert main() guarantees that string length of fslabel is not to exceed 'BTRFS_LABEL_SIZE', so it's enough to use strcpy() instead of strncpy() to copy fslabel in do_convert(). Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove cleanup-timer code for btrfs-convertZhao Lei2015-08-31
| | | | | | | | | | No need to close timer handle afain in subthread-close-callback, it is closed by task_stop() automatically. This patch also add a fflush() to make log output on time. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Avoid allocating metadata extent crossing stripe boundaryQu Wenruo2015-08-31
| | | | | | | | | | | As convert implement its own alloc extent, avoid such metadata problem too. Reported-by: Chris Murphy <lists@colorremedies.com> Reported-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: drop unused parameter from make_btrfsDavid Sterba2015-07-01
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move make_btrfs arguments to a structDavid Sterba2015-07-01
| | | | | | | No functional change, just introduce the structure and switch current users. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: accept --help as option in the standalone utilitiesDavid Sterba2015-06-11
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: factor out block iteration callbackJeff Mahoney2015-06-05
| | | | | | | | | block_iterate_proc uses the libext2fs error return codes when it doesn't need them to return the error. We can push this out to __block_iterate_proc and allow the reiserfs converter to share the code. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: factor out adding dirent into convert_insert_direntJeff Mahoney2015-06-05
| | | | | | | | Adding a dirent consists of multiple steps that will need to be taken by any converter. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: fix typo in btrfs_insert_dir_item callJeff Mahoney2015-06-05
| | | | | | | | EXT2_FT_REG_FILE and BTRFS_FT_REG_FILE happen to share the same value, but btrfs_insert_dir_item expects the btrfs version. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: rename ext2_root to image_rootJeff Mahoney2015-06-05
| | | | | | | | In preparation to extend to other file systems, rename ext2_root to image_root. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: remove unused inode_key in copy_single_inodeJeff Mahoney2015-06-05
| | | | | Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: remove unused fs argument from block_iterate_procJeff Mahoney2015-06-05
| | | | | | | The fs argument is unused, so let's not pass it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: clean up blk_iterate_data handling wrt record_file_blocksJeff Mahoney2015-06-05
| | | | | | | | Hand off initialization of blk_iterate_data to init_blk_iterate_data and pass the structure when the elements are the only values passed anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: allow to set filesystem featuresDavid Sterba2015-06-04
| | | | | | | | | | | | | | | Curretnly there are no features set for the converted filesystem and it's not possible to request it like in mkfs. Add new option -O|--features, use -O list-all to show all that are supported for convert. Note: from now on, convert without any -O option will use the same defaults as mkfs. The original behaviour was rather confusing. Convert is now more verbose about the parameters of the btrfs filesytem. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: drop dependency on sys/acl.hDavid Sterba2015-05-14
| | | | | | | | | | | | | | The file sys/acl.h is part of libacl and if the development package is not installed, build of btrfs-convert fails. We do not link against libacl nor use the functions provided by libacl. The ACL_* values are directly read from the extN data, so it's more part of the on-disk format rather than an interface to libacl. The dependency on libacl is completely dropped. Reported-by: Hugo Mills <hugo@carfax.org.uk> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: cleanup option index argument from getopt_longDavid Sterba2015-04-08
| | | | | | | We're not using it anywhere. The best practice is to add enums with values > 255 for the long options, option index counting is error prone. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: mkfs, deprecate leafsize and clean up the codeDavid Sterba2015-04-07
| | | | | | | Using the --leafsize will issue a warning. Replace leafsize with nodesize in the mkfs-related code. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: use exact size for reading superblockDavid Sterba2015-04-07
| | | | | | | | | We've passed blocksize to prepare_system_chunk and used it to read and write superblock. While this does not cause a bug (SUPER_INFO is blocksize ie. page size on most arches), we should really use the correct size. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: Make ext*_image file obey datacsum setting.Qu Wenruo2015-04-02
| | | | | | | | | | | | | | | | | | Before this patch, ext*_image is always set NODATACSUM inode flag. However btrfs-convert will set normal file with DATACUSM flag by default, and generate checksum for regular file extent. Now, a regular file extent is shared by a btrfs file inode with DATACSUM and ext*_image with NODATACSUM, and it has checksum in csum tree. This will cause btrfsck complain about odd checksum, since ext*_image is set NODATACSUM but has checksum generated from regular file extent. This patch makes convert completely obey datacsum setting, meaning btrfs-convert will generate csum for every file extent by default. 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.cz>
* btrfs-progs: convert, add long options for all short optionsDavid Sterba2015-03-24
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert, fix typo in getopt valueDavid Sterba2015-03-23
| | | | | | | Unfortunatelly GETOPT_VAL_IEC is not equal to GETOPT_VAL_NO_PROGRESS so --no-progress had no effect. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfs-convert: Allow setting nodesizeSebastian Thorarensen2015-03-23
| | | | | | | | Allow btrfs-convert to use nodesizes other than 4096. It defaults to max(16384, pagesize), like mkfs. Signed-off-by: Sebastian Thorarensen <sebth@naju.se> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert, adjust help text formattingDavid Sterba2015-03-09
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert, add option to disable progressDavid Sterba2015-03-09
| | | | | | | | With progress turned on by default we should be able to disable it as well. Reported-by: Jérôme Poulin <jeromepoulin@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: show progress by defaultDavid Sterba2015-02-27
| | | | | | | Agreed by several people, showing progress by default makes sense as conversion is a one-time and long running action. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: drop feature defines from C files, in favour of CFLAGS definesDimitri John Ledkov2015-01-27
| | | | | | | | | | | | | | | | | | | | | | glibc 2.10+ (5+ years old) enables all the desired features: _XOPEN_SOURCE 700, __XOPEN2K8, POSIX_C_SOURCE, DEFAULT_SOURCE; with a single _GNU_SOURCE define in the makefile alone. For portability to other libc implementations (e.g. dietlibc) _XOPEN_SOURCE=700 is also defined. This also resolves Debian bug report filed by Michael Tautschnig - "Inconsistent use of _XOPEN_SOURCE results in conflicting declarations". Whilst I was not able to reproduce the results, the reported fact is that _XOPEN_SOURCE set to 500 in one set of files (e.g. cmds-filesystem.c) generates/defines different struct stat from other files (cmds-replace.c). This patch thus cleans up all feature defines, and sets them at a consistent level. Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747969 Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert, handle pwrite error in do_rollbackDavid Sterba2015-01-06
| | | | | Resolves-coverity-id: 1242984 Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: include headers required for musl-libcMerlijn Wajer2014-12-18
| | | | | | | | This fixes various compilation errors where PATH_MAX and XATTR_SIZE_MAX were missing. To my knowledge, this should have no bad side effects. Signed-off-by: Merlijn Wajer <merlijn@wizzup.org> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: fix unable to rollback case with removed empty block ↵Gui Hecheng2014-12-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | groups Run fstests: btrfs/012 will fail with message: unable to do rollback It is because the rollback function checks sequentially each piece of space to map to a certain block group. If some piece doesn't, rollback refuses to continue. After kernel commit: commit 47ab2a6c689913db23ccae38349714edf8365e0a Btrfs: remove empty block groups automatically Empty block groups are removed, so there are possible gaps: |--block group 1--| |--block group 2--| ^ | gap So the piece of space of the gap belongs to a removed empty block group, and rollback should detect this case, and feel free to continue. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: use task for progress indication of metadata creationSilvio Fricke2014-12-04
| | | | | Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: fix a bug of converting sparse ext2/3/4Liu Bo2014-11-25
| | | | | | | | | | | | When converting a sparse ext* filesystem, btrfs-convert adds checksum extents for empty extents, whose disk_bytenr = 0, and this can end up with some weird problems, one of them is the failure of reading free space cache inode on mounting converted btrfs. The fix is simple, just to skip making checksum on empty extents. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: convert: set label or copy from originDavid Sterba2014-10-10
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Properly cast to avoid compiler warnings, fixes FTBFS on alpha ↵Dimitri John Ledkov2014-10-01
| | | | | | | | | | | | | | and ia64 Bug-Debian: http://bugs.debian.org/539433 Bug-Debian: http://bugs.debian.org/583768 Authors: Luca Bruno <lucab@debian.org> Alexander Kurtz <kurtz.alex@googlemail.com> Daniel Baumann <daniel.baumann@progress-technologies.net> Signed-off-by: Dimitri John Ledkov <xnox@debian.org> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: fix typosHolger Hoffstätte2014-09-02
| | | | | | | Fix (at least one user-visible) typos: it's its, not it's. Signed-off-by: Holger Hoffstätte <holger.hoffstaette@googlemail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: remove unused parameter in rollback for btrfs-convertGui Hecheng2014-08-22
| | | | | | | | The @force parameter for function @do_rollback is never checked or used, remove it. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: check option conflict for btrfs-convertGui Hecheng2014-08-22
| | | | | | | | | The -d, -i, -n options make no sense to rollback. Check the improper usages such as: # btrfs-convert -r -d <dev> Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: use check_argc_* to check arg number for all toolsGui Hecheng2014-08-22
| | | | | | | | | | | | Since this patch: btrfs-progs: move the check_argc_* functions into utils.c All tools including the independent tools(e.g. btrfs-image, btrfs-convert) can share the convenience of the check_argc_* functions, so this patch adopt the argc check functions globally. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>