From patchwork Tue Aug 23 10:25:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 9295417 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 C2AD360757 for ; Tue, 23 Aug 2016 10:45:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B239128BBC for ; Tue, 23 Aug 2016 10:45:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A395128BD3; Tue, 23 Aug 2016 10:45:29 +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 5D90F289EA for ; Tue, 23 Aug 2016 10:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757544AbcHWKpV (ORCPT ); Tue, 23 Aug 2016 06:45:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:59397 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755385AbcHWKnn (ORCPT ); Tue, 23 Aug 2016 06:43:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 73FA7AD4D for ; Tue, 23 Aug 2016 10:26:25 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 325AFDA89E; Tue, 23 Aug 2016 12:25:20 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 04/13] btrfs-progs: mkfs: do not scan partially initialized devices Date: Tue, 23 Aug 2016 12:25:08 +0200 Message-Id: <1471947917-5324-5-git-send-email-dsterba@suse.com> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1471947917-5324-1-git-send-email-dsterba@suse.com> References: <1471947917-5324-1-git-send-email-dsterba@suse.com> 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 We call scan ioctl on the devices too early, when most of the filesystem structures are not yet created. Move the registration to the end, after the filesystem gets closed. Signed-off-by: David Sterba --- mkfs.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mkfs.c b/mkfs.c index 1f209b54ff79..0b081dd44457 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1748,9 +1748,6 @@ int main(int argc, char **argv) exit(1); } - if (is_block_device(file) == 1) - btrfs_register_one_device(file); - if (dev_cnt == 0) goto raid_groups; @@ -1796,9 +1793,6 @@ int main(int argc, char **argv) printf("adding device %s id %llu\n", file, (unsigned long long)device->devid); } - - if (is_block_device(file) == 1) - btrfs_register_one_device(file); } raid_groups: @@ -1867,6 +1861,15 @@ int main(int argc, char **argv) out: ret = close_ctree(root); BUG_ON(ret); + + optind = saved_optind; + dev_cnt = argc - optind; + while (dev_cnt-- > 0) { + file = argv[optind++]; + if (is_block_device(file) == 1) + btrfs_register_one_device(file); + } + btrfs_close_all_devices(); free(label); return 0;