From patchwork Sun Feb 5 23:54:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Mamedov X-Patchwork-Id: 9556973 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 B47276021C for ; Sun, 5 Feb 2017 23:54:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98E7722B1F for ; Sun, 5 Feb 2017 23:54:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89D7C26223; Sun, 5 Feb 2017 23:54:42 +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 D163122B1F for ; Sun, 5 Feb 2017 23:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751936AbdBEXy0 (ORCPT ); Sun, 5 Feb 2017 18:54:26 -0500 Received: from len.romanrm.net ([195.154.117.182]:42504 "EHLO len.romanrm.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751686AbdBEXyZ (ORCPT ); Sun, 5 Feb 2017 18:54:25 -0500 Received: from natsu (unknown [IPv6:fd39::e9:9eff:fe8f:1bcf]) by len.romanrm.net (Postfix) with SMTP id 3E0B239FA7; Sun, 5 Feb 2017 23:54:22 +0000 (UTC) Date: Mon, 6 Feb 2017 04:54:21 +0500 From: Roman Mamedov To: Hans van Kranenburg Cc: Alexander Tomokhov , linux-btrfs Subject: Re: Is it possible to have metadata-only device with no data? Message-ID: <20170206045421.02e18d70@natsu> In-Reply-To: <0dbbe15a-59f7-ef0e-1ed6-83fec7ef165a@mendix.com> References: <14453691486330921@web21h.yandex.ru> <0dbbe15a-59f7-ef0e-1ed6-83fec7ef165a@mendix.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 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 On Sun, 5 Feb 2017 22:55:42 +0100 Hans van Kranenburg wrote: > On 02/05/2017 10:42 PM, Alexander Tomokhov wrote: > > Is it possible, having two drives to do raid1 for metadata but keep data on a single drive only? > > Nope. > > Would be a really nice feature though... Putting metadata on SSD and > bulk data on HDD... > You can play around with this hack just to see how that would perform, but it comes with no warranty and untested even by me. I was going to try it, but put it on hold since you'd also need to make sure the SSD is being preferred for metadata reads (and not HDD), but so far have not figured out a simple way of ensuring that. --- linux-amd64-4.4/fs/btrfs/volumes.c.orig 2016-11-01 22:41:41.970978721 +0500 +++ linux-amd64-4.4/fs/btrfs/volumes.c 2016-11-01 22:58:45.958977731 +0500 @@ -4597,6 +4597,14 @@ if (total_avail == 0) continue; + /* If we have two devices and one is less than 25% of the total FS size, then + * presumably it's a small device just for metadata RAID1, don't use it + * for new data chunks. */ + if ((fs_devices->num_devices == 2) && + (device->total_bytes * 4 < fs_devices->total_rw_bytes) && + (type & BTRFS_BLOCK_GROUP_DATA)) + continue; + ret = find_free_dev_extent(trans, device, max_stripe_size * dev_stripes, &dev_offset, &max_avail);