From patchwork Thu Dec 4 18:24:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goffredo Baroncelli X-Patchwork-Id: 5439681 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0D1B4BEEBA for ; Thu, 4 Dec 2014 18:24:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 369AB20272 for ; Thu, 4 Dec 2014 18:24:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F09E20253 for ; Thu, 4 Dec 2014 18:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932792AbaLDSYq (ORCPT ); Thu, 4 Dec 2014 13:24:46 -0500 Received: from mail-wi0-f176.google.com ([209.85.212.176]:32871 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932455AbaLDSYp (ORCPT ); Thu, 4 Dec 2014 13:24:45 -0500 Received: by mail-wi0-f176.google.com with SMTP id ex7so35665456wid.3 for ; Thu, 04 Dec 2014 10:24:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YBc59UcOxYhkqEf+QZUapFG20aNt28+VbVVxgeQAYnk=; b=xbqfw2BVcNRvlG/ypl9DEeSL3SJEbQKPYrvFJz4c2bVVlSrsvz9ZbPUotfeqFk6MDc Sakp1OcAWL2q325oBOhi11rswIDB9K0EvmQ1dFPfgrotoGHN/Bb482Z6cch0SopLRJME yHE6UZ3ALMmNN9zE4S/meRnLYeWPrm8pM7AZccHYR2JXEY+Aw4S0QmEECL2b8UQ7pOwV Ahs7Q88yJ3mcEa7T9A/VnRKhjyinCd8RfJjwfJv+CXTQuhc3h7clPY03bvdMowWBaiHT wVWcASuB8nGDEVaAcECGFP3w04zDRhZyJ2J8Kn4Kf/Ulh9/YvJ93sSRmbRNRLTMdC22r YrHA== X-Received: by 10.194.2.105 with SMTP id 9mr18242187wjt.115.1417717482656; Thu, 04 Dec 2014 10:24:42 -0800 (PST) Received: from venice.bhome (ppp-252-95.24-151.libero.it. [151.24.95.252]) by mx.google.com with ESMTPSA id wa5sm15767794wjc.8.2014.12.04.10.24.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Dec 2014 10:24:42 -0800 (PST) From: Goffredo Baroncelli X-Google-Original-From: Goffredo Baroncelli To: linux-btrfs@vger.kernel.org Cc: Goffredo Baroncelli Subject: [PATCH 2/5] 'btrfs device scan' skips lvm snapshots. Date: Thu, 4 Dec 2014 19:24:27 +0100 Message-Id: <1417717470-6298-3-git-send-email-kreijack@inwind.it> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1417717470-6298-1-git-send-email-kreijack@inwind.it> References: <1417717470-6298-1-git-send-email-kreijack@inwind.it> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP LVM snapshots create a problem to the btrfs devices management. BTRFS assumes that each device has an unique 'device UUID'. A LVM snapshot breaks this assumption. With this patch, 'btrfs device scan' skips LVM snapshot. If you need to consider a LVM snapshot you have to pass the '-s' switch ot set the environment variable BTRFS_SKIP_LVM_SNAPSHOT to "no". Signed-off-by: Goffredo Baroncelli --- cmds-device.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmds-device.c b/cmds-device.c index 6cd41e1..580879c 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -197,9 +197,10 @@ static int cmd_rm_dev(int argc, char **argv) } static const char * const cmd_scan_dev_usage[] = { - "btrfs device scan [(-d|--all-devices)| [...]]", + "btrfs device scan [-s][(-d|--all-devices)| [...]]", "Scan devices for a btrfs filesystem", " -d|--all-devices (deprecated)", + " -s don't skip lvm snapshot\n", NULL }; @@ -209,6 +210,7 @@ static int cmd_scan_dev(int argc, char **argv) int devstart = 1; int all = 0; int ret = 0; + int skip_snapshot = btrfs_scan_get_skip_lvm_snapshot(); optind = 1; while (1) { @@ -217,7 +219,7 @@ static int cmd_scan_dev(int argc, char **argv) { "all-devices", no_argument, NULL, 'd'}, { 0, 0, 0, 0 }, }; - int c = getopt_long(argc, argv, "d", long_options, + int c = getopt_long(argc, argv, "sd", long_options, &long_index); if (c < 0) break; @@ -225,6 +227,9 @@ static int cmd_scan_dev(int argc, char **argv) case 'd': all = 1; break; + case 's': + skip_snapshot = 0; + break; default: usage(cmd_scan_dev_usage); } @@ -261,6 +266,12 @@ static int cmd_scan_dev(int argc, char **argv) ret = 1; goto out; } + + if (skip_snapshot && is_low_priority_device(path)) { + fprintf(stderr, "WARNING: skip device '%s' because it is a snapshot\n", + argv[i]); + continue; + } printf("Scanning for Btrfs filesystems in '%s'\n", path); if (btrfs_register_one_device(path) != 0) { ret = 1;