From patchwork Wed Oct 11 02:17:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 9998455 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 16C4660230 for ; Wed, 11 Oct 2017 02:17:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 008F5288B0 for ; Wed, 11 Oct 2017 02:17:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7A34288BB; Wed, 11 Oct 2017 02:17:48 +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 4DD0D288B0 for ; Wed, 11 Oct 2017 02:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756502AbdJKCRp (ORCPT ); Tue, 10 Oct 2017 22:17:45 -0400 Received: from mgwym01.jp.fujitsu.com ([211.128.242.40]:30184 "EHLO mgwym01.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755039AbdJKCRp (ORCPT ); Tue, 10 Oct 2017 22:17:45 -0400 Received: from yt-mxoi2.gw.nic.fujitsu.com (unknown [192.168.229.69]) by mgwym01.jp.fujitsu.com with smtp id 632a_ebf0_a26ac962_59b0_469d_a7fc_1034fcd7cce3; Wed, 11 Oct 2017 11:17:42 +0900 Received: from g01jpfmpwkw03.exch.g01.fujitsu.local (g01jpfmpwkw03.exch.g01.fujitsu.local [10.0.193.57]) by yt-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id 64DB7AC010F for ; Wed, 11 Oct 2017 11:17:38 +0900 (JST) Received: from G01JPEXCHKW13.g01.fujitsu.local (G01JPEXCHKW13.g01.fujitsu.local [10.0.194.52]) by g01jpfmpwkw03.exch.g01.fujitsu.local (Postfix) with ESMTP id 97309BD64EF for ; Wed, 11 Oct 2017 11:17:37 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: 769a5b76b46c4b0a94fef62ec236d8ce Subject: [PATCH v2 2/3] btrfs-progs: doc: add description of missing and example of device remove From: "Misono, Tomohiro" To: linux-btrfs References: Message-ID: <287e3f39-4b71-61df-7247-9cbce7c30631@jp.fujitsu.com> Date: Wed, 11 Oct 2017 11:17:34 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable 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 This patch updates help/document of "btrfs device remove" in two points: 1. Add explanation of 'missing' for 'device remove'. This is only written in wikipage currently. (https://btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devices) 2. Add example of device removal in the man document. This is because that explanation of "remove" says "See the example section below", but there is no example of removal currently. Signed-off-by: Tomohiro Misono Reviewed-by: Satoru Takeuchi --- Documentation/btrfs-device.asciidoc | 19 ++++++++++++++++++- cmds-device.c | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Documentation/btrfs-device.asciidoc b/Documentation/btrfs-device.asciidoc index 88822ec..dd60415 100644 --- a/Documentation/btrfs-device.asciidoc +++ b/Documentation/btrfs-device.asciidoc @@ -68,13 +68,17 @@ Remove device(s) from a filesystem identified by Device removal must satisfy the profile constraints, otherwise the command fails. The filesystem must be converted to profile(s) that would allow the removal. This can typically happen when going down from 2 devices to 1 and -using the RAID1 profile. See the example section below. +using the RAID1 profile. See the *TYPICAL USECASES* section below. + The operation can take long as it needs to move all data from the device. + It is possible to delete the device that was used to mount the filesystem. The device entry in mount table will be replaced by another device name with the lowest device id. ++ +If device is mounted as degraded mode (-o degraded), special term "missing" +can be used for . In that case, the first device that is described by +the filesystem metadata, but not preseted at the mount time will be removed. *delete* | [|...] :: Alias of remove kept for backward compatibility @@ -206,6 +210,19 @@ data or the block groups occupy the whole first device. The device size of '/dev/sdb' as seen by the filesystem remains unchanged, but the logical space from 50-100GiB will be unused. +==== REMOVE DEVICE ==== + +Device removal must satisfy the profile constraints, otherwise the command +fails. For example: + + $ btrfs device remove /dev/sda /mnt + ERROR: error removing device '/dev/sda': unable to go below two devices on raid1 + +In order to remove a device, you need to convert the profile in this case: + + $ btrfs balance start -mconvert=dup -dconvert=single /mnt + $ btrfs device remove /dev/sda /mnt + DEVICE STATS ------------ diff --git a/cmds-device.c b/cmds-device.c index 3b6b985..d28ed0f 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -224,9 +224,16 @@ static int _cmd_device_remove(int argc, char **argv, return !!ret; } +#define COMMON_USAGE_REMOVE_DELETE \ + "", \ + "If 'missing' is specified for , the first device that is", \ + "described by the filesystem metadata, but not presented at the", \ + "mount time will be removed." + static const char * const cmd_device_remove_usage[] = { "btrfs device remove | [|...] ", "Remove a device from a filesystem", + COMMON_USAGE_REMOVE_DELETE, NULL }; @@ -238,6 +245,7 @@ static int cmd_device_remove(int argc, char **argv) static const char * const cmd_device_delete_usage[] = { "btrfs device delete | [|...] ", "Remove a device from a filesystem (alias of \"btrfs device remove\")", + COMMON_USAGE_REMOVE_DELETE, NULL };