From: NeilBrown <neilb@suse.de>
To: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: linux-raid@vger.kernel.org, GQJiang@suse.com
Subject: Re: [PATCH 2/4] md-cluster: remove capabilities
Date: Thu, 9 Apr 2015 09:24:34 +1000 [thread overview]
Message-ID: <20150409092434.7d0759f1@notabene.brown> (raw)
In-Reply-To: <20150408192247.GA9682@shrek.lan>
[-- Attachment #1: Type: text/plain, Size: 5181 bytes --]
On Wed, 8 Apr 2015 14:22:47 -0500 Goldwyn Rodrigues <rgoldwyn@suse.de> wrote:
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Hi Goldwyn,
where really need to be more words here. What is the purpose of this
"remove capabilities"? How are they used?
> ---
> drivers/md/md-cluster.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> drivers/md/md-cluster.h | 1 +
> drivers/md/md.c | 24 +++++++++++++++---------
> drivers/md/md.h | 1 +
> 4 files changed, 64 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
> index 96679b2..d036c83 100644
> --- a/drivers/md/md-cluster.c
> +++ b/drivers/md/md-cluster.c
> @@ -72,6 +72,7 @@ enum msg_type {
> METADATA_UPDATED = 0,
> RESYNCING,
> NEWDISK,
> + REMOVE,
> };
>
> struct cluster_msg {
> @@ -186,6 +187,20 @@ static char *pretty_uuid(char *dest, char *src)
> return dest;
> }
>
> +static struct md_rdev *find_rdev_uuid(struct mddev *mddev, char *uuid)
> +{
> + struct md_rdev *rdev;
> + struct mdp_superblock_1 *sb;
> +
> + rdev_for_each_rcu(rdev, mddev) {
> + sb = page_address(rdev->sb_page);
> + if (!strncmp(uuid, sb->device_uuid, 16)) {
> + return rdev;
> + }
> + }
> + return NULL;
> +}
I'm not at all comfortable about this.
Any code that "knows" about a particular metadata format should be accessed
through the super_types[] array.
I think I would rather you used 'desc_nr' to identify the device to be
removed. This number is determined from the metadata so every node will see
the same number for the same device. And it is independent of metadata type.
> +
> static void add_resync_info(struct mddev *mddev, struct dlm_lock_resource *lockres,
> sector_t lo, sector_t hi)
> {
> @@ -401,6 +416,17 @@ static void process_metadata_update(struct mddev *mddev, struct cluster_msg *msg
> dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR);
> }
>
> +static void process_remove_disk(struct mddev *mddev, struct cluster_msg *msg)
> +{
> + struct md_rdev *rdev = find_rdev_uuid(mddev, msg->uuid);
> + char uuid[32];
> +
> + if (rdev)
> + md_kick_rdev_from_array(rdev);
> + else
> + pr_warn("%s: %d Could not find disk with uuid: %s", __func__, __LINE__, pretty_uuid(uuid, msg->uuid));
> +}
> +
> static void process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
> {
> switch (msg->type) {
> @@ -419,6 +445,15 @@ static void process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
> pr_info("%s: %d Received message: NEWDISK from %d\n",
> __func__, __LINE__, msg->slot);
> process_add_new_disk(mddev, msg);
> + break;
> + case REMOVE:
> + pr_info("%s: %d Received REMOVE from %d\n",
> + __func__, __LINE__, msg->slot);
> + process_remove_disk(mddev, msg);
> + break;
> + default:
> + pr_warn("%s:%d Received unknown message from %d\n",
> + __func__, __LINE__, msg->slot);
> };
> }
>
> @@ -854,6 +889,17 @@ static int new_disk_ack(struct mddev *mddev, bool ack)
> return 0;
> }
>
> +static int remove_disk(struct mddev *mddev, struct md_rdev *rdev)
> +{
> + struct cluster_msg cmsg;
> + struct md_cluster_info *cinfo = mddev->cluster_info;
> + struct mdp_superblock_1 *sb = page_address(rdev->sb_page);
> + char *uuid = sb->device_uuid;
> + cmsg.type = REMOVE;
> + memcpy(cmsg.uuid, uuid, 16);
> + return __sendmsg(cinfo, &cmsg);
> +}
> +
> static struct md_cluster_operations cluster_ops = {
> .join = join,
> .leave = leave,
> @@ -868,6 +914,7 @@ static struct md_cluster_operations cluster_ops = {
> .add_new_disk_start = add_new_disk_start,
> .add_new_disk_finish = add_new_disk_finish,
> .new_disk_ack = new_disk_ack,
> + .remove_disk = remove_disk,
> };
>
> static int __init cluster_init(void)
> diff --git a/drivers/md/md-cluster.h b/drivers/md/md-cluster.h
> index 7417133..71e5143 100644
> --- a/drivers/md/md-cluster.h
> +++ b/drivers/md/md-cluster.h
> @@ -22,6 +22,7 @@ struct md_cluster_operations {
> int (*add_new_disk_start)(struct mddev *mddev, struct md_rdev *rdev);
> int (*add_new_disk_finish)(struct mddev *mddev);
> int (*new_disk_ack)(struct mddev *mddev, bool ack);
> + int (*remove_disk)(struct mddev *mddev, struct md_rdev *rdev);
> };
>
> #endif /* _MD_CLUSTER_H */
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index bc11551..0c65e51 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2291,11 +2291,12 @@ static void export_rdev(struct md_rdev * rdev)
> kobject_put(&rdev->kobj);
> }
>
> -static void kick_rdev_from_array(struct md_rdev * rdev)
> +void md_kick_rdev_from_array(struct md_rdev * rdev)
> {
> unbind_rdev_from_array(rdev);
> export_rdev(rdev);
> }
> +EXPORT_SYMBOL_GPL(md_kick_rdev_from_array);
You didn't create this patch against upstream code did you? The space
between '*' and 'rdev' disappeared in 3.18.
I think I would prefer a separate patch which renames and exports
kick_rdev_from_array, and then a much smaller (easier to review) patch which
adds the 'remove capabilities'.
Thanks,
NeilBrown
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
next prev parent reply other threads:[~2015-04-08 23:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 19:22 [PATCH 2/4] md-cluster: remove capabilities Goldwyn Rodrigues
2015-04-08 23:24 ` NeilBrown [this message]
2015-04-13 2:27 ` Guoqing Jiang
2015-04-14 11:26 ` Goldwyn Rodrigues
2015-04-15 2:24 ` gary
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=20150409092434.7d0759f1@notabene.brown \
--to=neilb@suse.de \
--cc=GQJiang@suse.com \
--cc=linux-raid@vger.kernel.org \
--cc=rgoldwyn@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.