linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.com>
To: Naohiro Aota <naota@elisp.net>, David Sterba <dsterba@suse.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <jbacik@fb.com>,
	linux-kernel@vger.kernel.org,
	Damien Le Moal <damien.lemoal@wdc.com>,
	Bart Van Assche <bart.vanassche@wdc.com>,
	Matias Bjorling <mb@lightnvm.io>
Subject: Re: [RFC PATCH 03/17] btrfs: Check and enable HMZONED mode
Date: Fri, 10 Aug 2018 15:41:18 +0200	[thread overview]
Message-ID: <6df03389-5127-28ac-f14b-05846bdd896f@suse.com> (raw)
In-Reply-To: <20180810131558.gadsij5g7tshfg5u@zazie>

On 08/10/2018 03:15 PM, Naohiro Aota wrote:
> On Fri, Aug 10, 2018 at 02:25:33PM +0200, Hannes Reinecke wrote:
>> 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 <damien.lemoal@wdc.com>
>>> Signed-off-by: Naohiro Aota <naota@elisp.net>
>>> ---
>>>  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.
> 
> Ah, I forgot to deel with the normal devices when I convert HMZONED
> mount flag to incompat flag.
> 
>> You need this patch to fix it:
> 
> Thank you for fixing this. It's exactly what I wanted to do. I'll fix
> in the next version.
> 
Thanks.

Other than that it seems to be holding up quite well; did a full 'git
clone && make oldconfig && make -j 16' on the upstream linux kernel with
no problems at all.

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)

  reply	other threads:[~2018-08-10 13:41 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 18:04 [RFC PATCH 00/17] btrfs zoned block device support Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 01/17] btrfs: introduce HMZONED feature flag Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 02/17] btrfs: Get zone information of zoned block devices Naohiro Aota
2018-08-10  7:41   ` Nikolay Borisov
2018-08-09 18:04 ` [RFC PATCH 03/17] btrfs: Check and enable HMZONED mode Naohiro Aota
2018-08-10 12:25   ` Hannes Reinecke
2018-08-10 13:15     ` Naohiro Aota
2018-08-10 13:41       ` Hannes Reinecke [this message]
2018-08-09 18:04 ` [RFC PATCH 04/17] btrfs: limit super block locations in " Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 05/17] btrfs: disable fallocate " Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 06/17] btrfs: disable direct IO " Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 07/17] btrfs: disable device replace " Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 08/17] btrfs: align extent allocation to zone boundary Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 09/17] btrfs: do sequential allocation on HMZONED drives Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 10/17] btrfs: split btrfs_map_bio() Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 11/17] btrfs: introduce submit buffer Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 12/17] btrfs: expire submit buffer on timeout Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 13/17] btrfs: avoid sync IO prioritization on checksum in HMZONED mode Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 14/17] btrfs: redirty released extent buffers in sequential BGs Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 15/17] btrfs: reset zones of unused block groups Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 16/17] btrfs: wait existing extents before truncating Naohiro Aota
2018-08-09 18:04 ` [RFC PATCH 17/17] btrfs: enable to mount HMZONED incompat flag Naohiro Aota
2018-08-09 18:10 ` [RFC PATCH 01/12] btrfs-progs: build: Check zoned block device support Naohiro Aota
2018-08-09 18:10   ` [RFC PATCH 02/12] btrfs-progs: utils: Introduce queue_param Naohiro Aota
2018-08-09 18:10   ` [RFC PATCH 03/12] btrfs-progs: add new HMZONED feature flag Naohiro Aota
2018-08-09 18:10   ` [RFC PATCH 04/12] btrfs-progs: Introduce zone block device helper functions Naohiro Aota
2018-08-09 18:10   ` [RFC PATCH 05/12] btrfs-progs: load and check zone information Naohiro Aota
2018-08-09 18:10   ` [RFC PATCH 06/12] btrfs-progs: avoid writing super block to sequential zones Naohiro Aota
2018-08-09 18:11   ` [RFC PATCH 07/12] btrfs-progs: support discarding zoned device Naohiro Aota
2018-08-09 18:11   ` [RFC PATCH 08/12] btrfs-progs: volume: align chunk allocation to zones Naohiro Aota
2018-08-09 18:11   ` [RFC PATCH 09/12] btrfs-progs: mkfs: Zoned block device support Naohiro Aota
2018-08-09 18:11   ` [RFC PATCH 10/12] btrfs-progs: device-add: support HMZONED device Naohiro Aota
2018-08-09 18:11   ` [RFC PATCH 11/12] btrfs-progs: replace: disable in " Naohiro Aota
2018-08-09 18:11   ` [RFC PATCH 12/12] btrfs-progs: do sequential allocation Naohiro Aota
2018-08-10  7:04 ` [RFC PATCH 00/17] btrfs zoned block device support Hannes Reinecke
2018-08-10 14:24   ` Naohiro Aota
2018-08-10  7:26 ` Hannes Reinecke
2018-08-10  7:28 ` Qu Wenruo
2018-08-16  9:05   ` Naohiro Aota
2018-08-10  7:53 ` Nikolay Borisov
2018-08-10  7:55   ` Nikolay Borisov
2018-08-13 18:42 ` David Sterba
2018-08-13 19:20   ` Hannes Reinecke
2018-08-13 19:29     ` Austin S. Hemmelgarn
2018-08-14  7:41       ` Hannes Reinecke
2018-08-15 11:25         ` Austin S. Hemmelgarn
2018-08-28 10:33   ` Naohiro Aota

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6df03389-5127-28ac-f14b-05846bdd896f@suse.com \
    --to=hare@suse.com \
    --cc=bart.vanassche@wdc.com \
    --cc=clm@fb.com \
    --cc=damien.lemoal@wdc.com \
    --cc=dsterba@suse.com \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@lightnvm.io \
    --cc=naota@elisp.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).