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>,
Matias Bjorling <Matias.Bjorling@wdc.com>,
Johannes Thumshirn <jthumshirn@suse.de>,
Hannes Reinecke <hare@suse.com>,
linux-fsdevel@vger.kernel.org,
Naohiro Aota <naohiro.aota@wdc.com>
Subject: [PATCH v3 15/15] btrfs-progs: introduce support for device replace HMZONED device
Date: Tue, 20 Aug 2019 13:52:58 +0900 [thread overview]
Message-ID: <20190820045258.1571640-16-naohiro.aota@wdc.com> (raw)
In-Reply-To: <20190820045258.1571640-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/replace.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/cmds/replace.c b/cmds/replace.c
index 2321aa156fe2..670df68a93f7 100644
--- a/cmds/replace.c
+++ b/cmds/replace.c
@@ -119,6 +119,7 @@ static const char *const cmd_replace_start_usage[] = {
static int cmd_replace_start(const struct cmd_struct *cmd,
int argc, char **argv)
{
+ struct btrfs_ioctl_feature_flags feature_flags;
struct btrfs_ioctl_dev_replace_args start_args = {0};
struct btrfs_ioctl_dev_replace_args status_args = {0};
int ret;
@@ -126,6 +127,7 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
int c;
int fdmnt = -1;
int fddstdev = -1;
+ int hmzoned;
char *path;
char *srcdev;
char *dstdev = NULL;
@@ -166,6 +168,13 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
if (fdmnt < 0)
goto leave_with_error;
+ ret = ioctl(fdmnt, BTRFS_IOC_GET_FEATURES, &feature_flags);
+ if (ret) {
+ error("ioctl(GET_FEATURES) on '%s' returns error: %m", path);
+ goto leave_with_error;
+ }
+ hmzoned = feature_flags.incompat_flags & BTRFS_FEATURE_INCOMPAT_HMZONED;
+
/* check for possible errors before backgrounding */
status_args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS;
status_args.result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT;
@@ -260,7 +269,8 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
strncpy((char *)start_args.start.tgtdev_name, dstdev,
BTRFS_DEVICE_PATH_NAME_MAX);
ret = btrfs_prepare_device(fddstdev, dstdev, &dstdev_block_count, 0,
- PREP_DEVICE_ZERO_END | PREP_DEVICE_VERBOSE);
+ PREP_DEVICE_ZERO_END | PREP_DEVICE_VERBOSE |
+ (hmzoned ? PREP_DEVICE_HMZONED : 0));
if (ret)
goto leave_with_error;
--
2.23.0
prev parent reply other threads:[~2019-08-20 4:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-20 4:52 [PATCH v3 00/15] btrfs-progs: zoned block device support Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 01/15] btrfs-progs: utils: Introduce queue_param helper function Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 02/15] btrfs-progs: introduce raid parameters variables Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 03/15] btrfs-progs: build: Check zoned block device support Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 04/15] btrfs-progs: add new HMZONED feature flag Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 05/15] btrfs-progs: Introduce zone block device helper functions Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 06/15] btrfs-progs: load and check zone information Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 07/15] btrfs-progs: avoid writing super block to sequential zones Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 08/15] btrfs-progs: support discarding zoned device Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 09/15] btrfs-progs: support zero out on zoned block device Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 10/15] btrfs-progs: align device extent allocation to zone boundary Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 11/15] btrfs-progs: do sequential allocation in HMZONED mode Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 12/15] btrfs-progs: redirty clean extent buffers in seq Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 13/15] btrfs-progs: mkfs: Zoned block device support Naohiro Aota
2019-08-20 4:52 ` [PATCH v3 14/15] btrfs-progs: device-add: support HMZONED device Naohiro Aota
2019-08-20 4:52 ` Naohiro Aota [this message]
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=20190820045258.1571640-16-naohiro.aota@wdc.com \
--to=naohiro.aota@wdc.com \
--cc=Matias.Bjorling@wdc.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).