From: Naohiro Aota <naohiro.aota@wdc.com>
To: linux-btrfs@vger.kernel.org, David Sterba <dsterba@suse.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
Nikolay Borisov <nborisov@suse.com>,
Damien Le Moal <damien.lemoal@wdc.com>,
Johannes Thumshirn <jthumshirn@suse.de>,
Hannes Reinecke <hare@suse.com>,
Anand Jain <anand.jain@oracle.com>,
linux-fsdevel@vger.kernel.org,
Naohiro Aota <naohiro.aota@wdc.com>
Subject: [PATCH v5 14/15] btrfs-progs: device-add: support HMZONED device
Date: Wed, 4 Dec 2019 17:25:12 +0900 [thread overview]
Message-ID: <20191204082513.857320-15-naohiro.aota@wdc.com> (raw)
In-Reply-To: <20191204082513.857320-1-naohiro.aota@wdc.com>
This patch check if the target file system is flagged as HMZONED. If it is,
the device to be added is flagged PREP_DEVICE_HMZONED. Also add checks to
prevent mixing non-zoned devices and zoned devices.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
cmds/device.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/cmds/device.c b/cmds/device.c
index 24158308a41b..f85820cb1cc0 100644
--- a/cmds/device.c
+++ b/cmds/device.c
@@ -36,6 +36,7 @@
#include "common/path-utils.h"
#include "common/device-utils.h"
#include "common/device-scan.h"
+#include "common/hmzoned.h"
#include "mkfs/common.h"
static const char * const device_cmd_group_usage[] = {
@@ -61,6 +62,9 @@ static int cmd_device_add(const struct cmd_struct *cmd,
int discard = 1;
int force = 0;
int last_dev;
+ int res;
+ int hmzoned;
+ struct btrfs_ioctl_feature_flags feature_flags;
optind = 0;
while (1) {
@@ -96,12 +100,35 @@ static int cmd_device_add(const struct cmd_struct *cmd,
if (fdmnt < 0)
return 1;
+ res = ioctl(fdmnt, BTRFS_IOC_GET_FEATURES, &feature_flags);
+ if (res) {
+ error("error getting feature flags '%s': %m", mntpnt);
+ return 1;
+ }
+ hmzoned = feature_flags.incompat_flags & BTRFS_FEATURE_INCOMPAT_HMZONED;
+
for (i = optind; i < last_dev; i++){
struct btrfs_ioctl_vol_args ioctl_args;
- int devfd, res;
+ int devfd;
u64 dev_block_count = 0;
char *path;
+ if (hmzoned && zoned_model(argv[i]) == ZONED_NONE) {
+ error(
+ "cannot add non-zoned device to HMZONED file system '%s'",
+ argv[i]);
+ ret++;
+ continue;
+ }
+
+ if (!hmzoned && zoned_model(argv[i]) == ZONED_HOST_MANAGED) {
+ error(
+ "cannot add host managed zoned device to non-HMZONED file system '%s'",
+ argv[i]);
+ ret++;
+ continue;
+ }
+
res = test_dev_for_mkfs(argv[i], force);
if (res) {
ret++;
@@ -117,7 +144,8 @@ static int cmd_device_add(const struct cmd_struct *cmd,
res = btrfs_prepare_device(devfd, argv[i], &dev_block_count, 0,
PREP_DEVICE_ZERO_END | PREP_DEVICE_VERBOSE |
- (discard ? PREP_DEVICE_DISCARD : 0));
+ (discard ? PREP_DEVICE_DISCARD : 0) |
+ (hmzoned ? PREP_DEVICE_HMZONED : 0));
close(devfd);
if (res) {
ret++;
--
2.24.0
next prev parent reply other threads:[~2019-12-04 8:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 8:24 [PATCH v5 00/15] btrfs-progs: zoned block device support Naohiro Aota
2019-12-04 8:24 ` [PATCH v5 01/15] btrfs-progs: utils: Introduce queue_param helper function Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 02/15] btrfs-progs: introduce raid parameters variables Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 03/15] btrfs-progs: build: Check zoned block device support Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 04/15] btrfs-progs: add new HMZONED feature flag Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 05/15] btrfs-progs: Introduce zone block device helper functions Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 06/15] btrfs-progs: load and check zone information Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 07/15] btrfs-progs: support discarding zoned device Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 08/15] btrfs-progs: support zero out on zoned block device Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 09/15] btrfs-progs: implement log-structured superblock for HMZONED mode Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 10/15] btrfs-progs: align device extent allocation to zone boundary Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 11/15] btrfs-progs: do sequential allocation in HMZONED mode Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 12/15] btrfs-progs: redirty clean extent buffers in seq Naohiro Aota
2019-12-04 8:25 ` [PATCH v5 13/15] btrfs-progs: mkfs: Zoned block device support Naohiro Aota
2019-12-04 8:25 ` Naohiro Aota [this message]
2019-12-04 8:25 ` [PATCH v5 15/15] btrfs-progs: introduce support for device replace HMZONED device Naohiro Aota
2019-12-04 8:30 ` [PATCH] libblkid: implement zone-aware probing for HMZONED btrfs Naohiro Aota
2019-12-04 12:15 ` Vyacheslav Dubeyko
2019-12-06 7:03 ` Naohiro Aota
2019-12-06 15:22 ` David Sterba
2019-12-05 14:51 ` Karel Zak
2019-12-06 7:06 ` 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=20191204082513.857320-15-naohiro.aota@wdc.com \
--to=naohiro.aota@wdc.com \
--cc=anand.jain@oracle.com \
--cc=clm@fb.com \
--cc=damien.lemoal@wdc.com \
--cc=dsterba@suse.com \
--cc=hare@suse.com \
--cc=josef@toxicpanda.com \
--cc=jthumshirn@suse.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=nborisov@suse.com \
/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).