Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3193158imm; Fri, 10 Aug 2018 05:27:09 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy3zJr+6IIImmg+YMKn4W/sRTeOsFKmn1Ar2UafHxDfR8aDPdYRn/etuN7THmmONKwJJrRj X-Received: by 2002:a65:60cd:: with SMTP id r13-v6mr6294326pgv.232.1533904028950; Fri, 10 Aug 2018 05:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533904028; cv=none; d=google.com; s=arc-20160816; b=bWJgVJ2T4th7DJAYbFJE7pb4QJFMxWGqT9VTVDG/alTfsNXWaPb5Gk3kNNc5WZ74aN 3Pm5SZM1Q8hsOQRkWfmW4E+M89PRiYVxlRnt4znB+BOwgm4EwaSrAxCGbgywWuNfU2Vu co65yjFlallyly4rKv+umCeNnMnixNP7DVeghh9nwvNdgZe4wppulfxl79ks432oD4+d xmucaoCUoXfVtoMKYeUb6vKsf0NCOKdCoIRTde7HS0iN184uNCSwPPXxeYBcEm9evaRX ILyGOfoIXMN9/WKuIghtUkxzHXzarOAHc5SVxlaRNaggGYNMdwkPtckI7MeR99lBiLo/ JZCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=RR4PN8VSBAm5Shg1GFEkERJTAQlvzZsiIu+HNiXEFkY=; b=Nz7TOYC3cHxayc3pLcqDC6xBFyuy1vGNd0Z3GzNTiD5EmT7mpYOdvRbMTBQ5zDt+5X 47bNrcp5N+5ty7P+OiSZfd7sKFVcgf0WaYmSf2SzAcaZL/f0EBOvCvBpVVVLqT/wp+0B 3iASc/IT5Vg5Rj8I62Z2C/yTslI++Go2viAtr0QVj87IE9lQ9SXMMPvCN1B7WfBym1GB MPgOcuMEgIcEV2QLqa6AldnkIIU+vfyAaSMm7WNXUrjEjHwim4PD6Yhw1p52tZKMxONg GVmCjb4ojxM6mbPbhAk0LQRG+5G0u3zzybKLvbitQG2hIsYuUFKjUSxOPFFzLOVNkEUz 2aTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5-v6si7767705plk.406.2018.08.10.05.26.53; Fri, 10 Aug 2018 05:27:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728057AbeHJOzT (ORCPT + 99 others); Fri, 10 Aug 2018 10:55:19 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:37448 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727544AbeHJOzT (ORCPT ); Fri, 10 Aug 2018 10:55:19 -0400 Received: from [10.160.4.48] (charybdis-ext.suse.de [195.135.221.2]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Fri, 10 Aug 2018 14:25:35 +0200 Subject: Re: [RFC PATCH 03/17] btrfs: Check and enable HMZONED mode To: Naohiro Aota , David Sterba , linux-btrfs@vger.kernel.org Cc: Chris Mason , Josef Bacik , linux-kernel@vger.kernel.org, Damien Le Moal , Bart Van Assche , Matias Bjorling References: <20180809180450.5091-1-naota@elisp.net> <20180809180450.5091-4-naota@elisp.net> From: Hannes Reinecke Message-ID: <51ed0d0b-7574-b9a9-bae5-2cc8042913e6@suse.com> Date: Fri, 10 Aug 2018 14:25:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180809180450.5091-4-naota@elisp.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/09/2018 08:04 PM, Naohiro Aota wrote: > HMZONED mode cannot be used together with the RAID5/6 profile. Introduce > the function btrfs_check_hmzoned_mode() to check this. This function will > also check if HMZONED flag is enabled on the file system and if the file > system consists of zoned devices with equal zone size. > > Additionally, as updates to the space cache are in-place, the space cache > cannot be located over sequential zones and there is no guarantees that the > device will have enough conventional zones to store this cache. Resolve > this problem by disabling completely the space cache. This does not > introduces any problems with sequential block groups: all the free space is > located after the allocation pointer and no free space before the pointer. > There is no need to have such cache. > > Signed-off-by: Damien Le Moal > Signed-off-by: Naohiro Aota > --- > fs/btrfs/ctree.h | 3 ++ > fs/btrfs/dev-replace.c | 7 ++++ > fs/btrfs/disk-io.c | 7 ++++ > fs/btrfs/super.c | 12 +++--- > fs/btrfs/volumes.c | 87 ++++++++++++++++++++++++++++++++++++++++++ > fs/btrfs/volumes.h | 1 + > 6 files changed, 112 insertions(+), 5 deletions(-) > > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h > index 66f1d3895bca..14f880126532 100644 > --- a/fs/btrfs/ctree.h > +++ b/fs/btrfs/ctree.h > @@ -763,6 +763,9 @@ struct btrfs_fs_info { > struct btrfs_root *uuid_root; > struct btrfs_root *free_space_root; > > + /* Zone size when in HMZONED mode */ > + u64 zone_size; > + > /* the log root tree is a directory of all the other log roots */ > struct btrfs_root *log_root_tree; > > diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c > index dec01970d8c5..839a35008fd8 100644 > --- a/fs/btrfs/dev-replace.c > +++ b/fs/btrfs/dev-replace.c > @@ -202,6 +202,13 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, > return PTR_ERR(bdev); > } > > + if ((bdev_zoned_model(bdev) == BLK_ZONED_HM && > + !btrfs_fs_incompat(fs_info, HMZONED)) || > + (!bdev_is_zoned(bdev) && btrfs_fs_incompat(fs_info, HMZONED))) { > + ret = -EINVAL; > + goto error; > + } > + > filemap_write_and_wait(bdev->bd_inode->i_mapping); > > devices = &fs_info->fs_devices->devices; > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index 5124c15705ce..14f284382ba7 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -3057,6 +3057,13 @@ int open_ctree(struct super_block *sb, > > btrfs_free_extra_devids(fs_devices, 1); > > + ret = btrfs_check_hmzoned_mode(fs_info); > + if (ret) { > + btrfs_err(fs_info, "failed to init hmzoned mode: %d", > + ret); > + goto fail_block_groups; > + } > + > ret = btrfs_sysfs_add_fsid(fs_devices, NULL); > if (ret) { > btrfs_err(fs_info, "failed to init sysfs fsid interface: %d", > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c > index 5fdd95e3de05..cc812e459197 100644 > --- a/fs/btrfs/super.c > +++ b/fs/btrfs/super.c > @@ -435,11 +435,13 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options, > bool saved_compress_force; > int no_compress = 0; > > - cache_gen = btrfs_super_cache_generation(info->super_copy); > - if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE)) > - btrfs_set_opt(info->mount_opt, FREE_SPACE_TREE); > - else if (cache_gen) > - btrfs_set_opt(info->mount_opt, SPACE_CACHE); > + if (!btrfs_fs_incompat(info, HMZONED)) { > + cache_gen = btrfs_super_cache_generation(info->super_copy); > + if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE)) > + btrfs_set_opt(info->mount_opt, FREE_SPACE_TREE); > + else if (cache_gen) > + btrfs_set_opt(info->mount_opt, SPACE_CACHE); > + } > > /* > * Even the options are empty, we still need to do extra check > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index 35b3a2187653..ba7ebb80de4d 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -1293,6 +1293,80 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, > return ret; > } > > +int btrfs_check_hmzoned_mode(struct btrfs_fs_info *fs_info) > +{ > + struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; > + struct btrfs_device *device; > + u64 hmzoned_devices = 0; > + u64 nr_devices = 0; > + u64 zone_size = 0; > + int incompat_hmzoned = btrfs_fs_incompat(fs_info, HMZONED); > + int ret = 0; > + > + /* Count zoned devices */ > + list_for_each_entry(device, &fs_devices->devices, dev_list) { > + if (!device->bdev) > + continue; > + if (bdev_zoned_model(device->bdev) == BLK_ZONED_HM || > + (bdev_zoned_model(device->bdev) == BLK_ZONED_HA && > + incompat_hmzoned)) { > + hmzoned_devices++; > + if (!zone_size) { > + zone_size = device->zone_size; > + } else if (device->zone_size != zone_size) { > + btrfs_err(fs_info, > + "Zoned block devices must have equal zone sizes"); > + ret = -EINVAL; > + goto out; > + } > + } > + nr_devices++; > + } > + > + if (!hmzoned_devices && incompat_hmzoned) { > + /* No zoned block device, disable HMZONED */ > + btrfs_err(fs_info, "HMZONED enabled file system should have zoned devices"); > + ret = -EINVAL; > + goto out; > + } > + > + fs_info->zone_size = zone_size; > + > + if (hmzoned_devices != nr_devices) { > + btrfs_err(fs_info, > + "zoned devices mixed with regular devices"); > + ret = -EINVAL; > + goto out; > + } > + This breaks existing setups; as we're not checking if the device specified by fs_info is a zoned device we'll fail here for normal devices. You need this patch to fix it: diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 43eaf0142062..8609776c9a9e 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1314,6 +1314,9 @@ int btrfs_check_hmzoned_mode(struct btrfs_fs_info *fs_info) int incompat_hmzoned = btrfs_fs_incompat(fs_info, HMZONED); int ret = 0; + if (!incompat_hmzoned) + return 0; + /* Count zoned devices */ list_for_each_entry(device, &fs_devices->devices, dev_list) { if (!device->bdev) Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage hare@suse.com +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)