From patchwork Thu Sep 15 12:08:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lakshmipathi.G" X-Patchwork-Id: 9333529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4E230601C2 for ; Thu, 15 Sep 2016 12:16:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F2C8296AF for ; Thu, 15 Sep 2016 12:16:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33D46296B1; Thu, 15 Sep 2016 12:16:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B88E296AF for ; Thu, 15 Sep 2016 12:16:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934067AbcIOMQ1 (ORCPT ); Thu, 15 Sep 2016 08:16:27 -0400 Received: from smtpq5.tb.mail.iss.as9143.net ([212.54.42.168]:60291 "EHLO smtpq5.tb.mail.iss.as9143.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1765375AbcIOMQ0 (ORCPT ); Thu, 15 Sep 2016 08:16:26 -0400 Received: from [212.54.42.118] (helo=lsmtp4.tb.mail.iss.as9143.net) by smtpq5.tb.mail.iss.as9143.net with esmtp (Exim 4.82) (envelope-from ) id 1bkVaV-0002n7-Sr for linux-btrfs@vger.kernel.org; Thu, 15 Sep 2016 14:16:19 +0200 Received: from 31-151-236-204.dynamic.upc.nl ([31.151.236.204] helo=webminal.org) by lsmtp4.tb.mail.iss.as9143.net with esmtp (Exim 4.82) (envelope-from ) id 1bkVaL-0002rz-Ox for linux-btrfs@vger.kernel.org; Thu, 15 Sep 2016 14:16:19 +0200 Received: from localhost.localdomain (fedori [127.0.0.1]) by webminal.org (8.14.4/8.14.4) with ESMTP id u8FC92kn022720 for ; Thu, 15 Sep 2016 14:09:13 +0200 Received: (from laks@localhost) by localhost.localdomain (8.14.4/8.14.4/Submit) id u8FC8qXa022643 for linux-btrfs@vger.kernel.org; Thu, 15 Sep 2016 14:08:52 +0200 Date: Thu, 15 Sep 2016 14:08:52 +0200 From: "Lakshmipathi.G" To: linux-btrfs@vger.kernel.org Subject: [PATCH]btrfs-progs: btrfs-convert.c : check source file system state Message-ID: <20160915120852.GA22577@fedori> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Ziggo-spambar: / X-Ziggo-spamscore: 0.0 X-Ziggo-spamreport: CMAE Analysis: v=2.1 cv=A4iRRPiG c=1 sm=0 tr=0 a=kj9zAlcOel0A:10 a=MKtGQD3n3ToA:10 a=ZZnuYtJkoWoA:10 a=GW1xBdLrtEIA:10 a=DT0QyOUopAkA:10 a=Ii29zHd6AAAA:8 a=qzJFIt6r8OKQl7ZhryoA:9 a=CjuIK1q_8ugA:10 a=hUl28ISp9AlOTif-od5a:22 xcat=Undefined/Undefined none X-Ziggo-Spam-Status: No Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Lakshmipathi.G --- btrfs-convert.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/btrfs-convert.c b/btrfs-convert.c index c10dc17..27da9ce 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -2171,6 +2171,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 @@ -2340,6 +2351,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 e2fsck is recommended."); ret = convert_read_used_space(&cctx); if (ret) goto fail;