From: Lakshmipathi.G Date: Thu, 15 Sep 2016 12:08:52 +0000 (+0200) Subject: btrfs-progs: convert: check source file system state X-Git-Tag: upstream/4.16.1~1246 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b56fe169227a17bc92dea2fa399d1fb77e7cd233;p=platform%2Fupstream%2Fbtrfs-progs.git btrfs-progs: convert: check source file system state Signed-off-by: Lakshmipathi.G [ add doc note ] Signed-off-by: David Sterba --- diff --git a/Documentation/btrfs-convert.asciidoc b/Documentation/btrfs-convert.asciidoc index ecc157c..cbc1c73 100644 --- a/Documentation/btrfs-convert.asciidoc +++ b/Documentation/btrfs-convert.asciidoc @@ -33,6 +33,9 @@ have supported data block size (ie. the same that would be valid for 'mkfs.btrfs'). This is typically the system page size (4KiB on x86_64 machines). +NOTE: The source filesystem should be clean, you are encouraged to run the +'fsck' tool if you're not sure. + **REMOVE THE ORIGINAL FILESYSTEM METADATA** By removing the 'ext2_saved' subvolume, all metadata of the original filesystem diff --git a/btrfs-convert.c b/btrfs-convert.c index 727bfea..a62d2f0 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -2183,6 +2183,17 @@ static void ext2_copy_inode_item(struct btrfs_inode_item *dst, } memset(&dst->reserved, 0, sizeof(dst->reserved)); } +static int check_filesystem_state(struct btrfs_convert_context *cctx) +{ + ext2_filsys fs = cctx->fs_data; + + if (!(fs->super->s_state & EXT2_VALID_FS)) + return 1; + else if (fs->super->s_state & EXT2_ERROR_FS) + return 1; + else + return 0; +} /* * copy a single inode. do all the required works, such as cloning @@ -2352,6 +2363,10 @@ static int do_convert(const char *devname, int datacsum, int packing, ret = convert_open_fs(devname, &cctx); if (ret) goto fail; + ret = check_filesystem_state(&cctx); + if (ret) + warning( + "source filesystem is not clean, running filesystem check is recommended"); ret = convert_read_used_space(&cctx); if (ret) goto fail;