From patchwork Sat Oct 3 15:50:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Tygier X-Patchwork-Id: 7321951 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 75538BEEA4 for ; Sat, 3 Oct 2015 15:50:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B98320600 for ; Sat, 3 Oct 2015 15:50:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ACF80205CD for ; Sat, 3 Oct 2015 15:50:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752063AbbJCPut (ORCPT ); Sat, 3 Oct 2015 11:50:49 -0400 Received: from plane.gmane.org ([80.91.229.3]:44496 "EHLO plane.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752047AbbJCPut (ORCPT ); Sat, 3 Oct 2015 11:50:49 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZiP58-0003ly-Cu for linux-btrfs@vger.kernel.org; Sat, 03 Oct 2015 17:50:42 +0200 Received: from host-78-149-212-66.as13285.net ([78.149.212.66]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 03 Oct 2015 17:50:42 +0200 Received: from samtygier by host-78-149-212-66.as13285.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 03 Oct 2015 17:50:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: linux-btrfs@vger.kernel.org From: sam tygier Subject: [PATCH v2] Btrfs: Check metadata redundancy on balance Date: Sat, 03 Oct 2015 16:50:34 +0100 Lines: 57 Message-ID: Mime-Version: 1.0 X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: host-78-149-212-66.as13285.net User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 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.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,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 Currently BTRFS allows you to make bad choices of data and metadata levels. For example -d raid1 -m raid0 means you can only use half your total disk space, but will loose everything if 1 disk fails. It should give a warning in these cases. This patch is a follow up to [PATCH v2] btrfs-progs: check metadata redundancy in order to cover the case of using balance to convert to such a set of raid levels. A simple example to hit this is to create a single device fs, which will default to single:dup, then to add a second device and attempt to convert to raid1 with the command btrfs balance start -dconvert=raid1 /mnt this will result in a filesystem with raid1:dup, which will not survive the loss of one drive. I personally don't see why the tools should allow this, but in the previous thread a warning was considered sufficient. Changes in v2 Use btrfs_get_num_tolerated_disk_barrier_failures() Signed-off-by: Sam Tygier From: Sam Tygier Date: Sat, 3 Oct 2015 16:43:48 +0100 Subject: [PATCH] Btrfs: Check metadata redundancy on balance When converting a filesystem via balance check that metadata mode is at least as redundant as the data mode. For example give warning when: -dconvert=raid1 -mconvert=single --- fs/btrfs/volumes.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 6fc73586..40247e9 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3584,6 +3584,12 @@ int btrfs_balance(struct btrfs_balance_control *bctl, } } while (read_seqretry(&fs_info->profiles_lock, seq)); + if (btrfs_get_num_tolerated_disk_barrier_failures(bctl->meta.target) < + btrfs_get_num_tolerated_disk_barrier_failures(bctl->data.target)) { + btrfs_info(fs_info, + "Warning: metatdata has lower redundancy than data\n"); + } + if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) { fs_info->num_tolerated_disk_barrier_failures = min( btrfs_calc_num_tolerated_disk_barrier_failures(fs_info),