linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Guoqing Jiang <gqjiang@suse.com>
Cc: linux-raid@vger.kernel.org, rgoldwyn@suse.com
Subject: Re: [PATCH V3 05/11] Add a new clustered disk
Date: Mon, 25 May 2015 14:35:34 +1000	[thread overview]
Message-ID: <20150525143534.3faebbfb@notabene.brown> (raw)
In-Reply-To: <1432092043-24220-6-git-send-email-gqjiang@suse.com>

[-- Attachment #1: Type: text/plain, Size: 3569 bytes --]

On Wed, 20 May 2015 11:20:37 +0800 Guoqing Jiang <gqjiang@suse.com> wrote:

> A clustered disk is added by the traditional --add sequence.
> However, other nodes need to acknowledge that they can "see"
> the device. This is done by --cluster-confirm:
> 
> --cluster-confirm SLOTNUM:/dev/whatever (if disk is found)
> or
> --cluster-confirm SLOTNUM:missing (if disk is not found)
> 
> The node initiating the --add, has the disk state tagged with
> MD_DISK_CLUSTER_ADD and the one confirming tag the disk with
> MD_DISK_CANDIDATE.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
> ---
>  Manage.c   | 33 +++++++++++++++++++++++++++++----
>  ReadMe.c   |  1 +
>  md_p.h     |  7 +++++++
>  md_u.h     |  1 +
>  mdadm.8.in |  9 +++++++++
>  mdadm.c    |  4 ++++
>  mdadm.h    |  2 ++
>  util.c     | 10 ++++++++++
>  8 files changed, 63 insertions(+), 4 deletions(-)
> 
> diff --git a/Manage.c b/Manage.c
> index d3cfb55..4c3d451 100644
> --- a/Manage.c
> +++ b/Manage.c
> @@ -690,7 +690,8 @@ skip_re_add:
>  int Manage_add(int fd, int tfd, struct mddev_dev *dv,
>  	       struct supertype *tst, mdu_array_info_t *array,
>  	       int force, int verbose, char *devname,
> -	       char *update, unsigned long rdev, unsigned long long array_size)
> +	       char *update, unsigned long rdev, unsigned long long array_size,
> +	       int raid_slot)
>  {
>  	unsigned long long ldsize;
>  	struct supertype *dev_st = NULL;
> @@ -879,7 +880,10 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
>  	}
>  	disc.major = major(rdev);
>  	disc.minor = minor(rdev);
> -	disc.number =j;
> +	if (raid_slot < 0)
> +		disc.number = j;
> +	else
> +		disc.number = raid_slot;
>  	disc.state = 0;
>  	if (array->not_persistent==0) {
>  		int dfd;
> @@ -920,6 +924,14 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
>  			}
>  		free(used);
>  	}
> +
> +	if (array->state & (1 << MD_SB_CLUSTERED)) {
> +		if (dv->disposition == 'c')
> +			disc.state |= (1 << MD_DISK_CANDIDATE);
> +		else
> +			disc.state |= (1 << MD_DISK_CLUSTER_ADD);
> +	}
> +
>  	if (dv->writemostly == 1)
>  		disc.state |= (1 << MD_DISK_WRITEMOSTLY);
>  	if (tst->ss->external) {
> @@ -1239,6 +1251,7 @@ int Manage_subdevs(char *devname, int fd,
>  	 *        variant on 'A'
>  	 *  'F' - Another variant of 'A', where the device was faulty
>  	 *        so must be removed from the array first.
> +	 *  'c' - confirm the device as found (for clustered environments)
>  	 *
>  	 * For 'f' and 'r', the device can also be a kernel-internal
>  	 * name such as 'sdb'.
> @@ -1254,6 +1267,7 @@ int Manage_subdevs(char *devname, int fd,
>  	struct mdinfo info;
>  	int frozen = 0;
>  	int busy = 0;
> +	int raid_slot = -1;
>  
>  	if (ioctl(fd, GET_ARRAY_INFO, &array)) {
>  		pr_err("Cannot get array info for %s\n",
> @@ -1282,6 +1296,11 @@ int Manage_subdevs(char *devname, int fd,
>  		int rv;
>  		int mj,mn;
>  
> +		raid_slot = -1;
> +		if (dv->disposition == 'c')
> +			parse_cluster_confirm_arg(dv->devname, &dv->devname,
> +					&raid_slot);
> +

This function returns -1 if it couldn't successfully parse dv->devname, but
you aren't catching that error and reporting it.


NeilBrown


>  
> +int parse_cluster_confirm_arg(char *input, char **devname, int *slot)
> +{
> +	char *dev;
> +	*slot = strtoul(input, &dev, 10);
> +	if (dev == input || dev[0] != ':')
> +		return -1;
> +	*devname = dev+1;
> +	return 0;
> +}
> +

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

  reply	other threads:[~2015-05-25  4:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-20  3:20 [PATCH V3 00/11] mdadm tool: add the support for cluster-md Guoqing Jiang
2015-05-20  3:20 ` [PATCH V3 01/11] Create n bitmaps for clustered mode Guoqing Jiang
2015-05-20  3:20 ` [PATCH V3 02/11] Add nodes option while creating md Guoqing Jiang
2015-05-25  4:13   ` NeilBrown
2015-05-20  3:20 ` [PATCH V3 03/11] home-cluster while creating an array Guoqing Jiang
2015-05-25  4:19   ` NeilBrown
2015-05-20  3:20 ` [PATCH V3 04/11] Show all bitmaps while examining bitmap Guoqing Jiang
2015-05-25  4:23   ` NeilBrown
2015-05-20  3:20 ` [PATCH V3 05/11] Add a new clustered disk Guoqing Jiang
2015-05-25  4:35   ` NeilBrown [this message]
2015-05-20  3:20 ` [PATCH V3 06/11] Convert a bitmap=none device to clustered Guoqing Jiang
2015-05-25  4:40   ` NeilBrown
2015-05-20  3:20 ` [PATCH V3 07/11] Skip clustered devices in incremental Guoqing Jiang
2015-05-20  3:20 ` [PATCH V3 08/11] mdadm: add the ability to change cluster name Guoqing Jiang
2015-05-25  4:53   ` NeilBrown
2015-05-26  8:38     ` Guoqing Jiang
2015-06-01 16:26     ` Goldwyn Rodrigues
2015-05-20  3:20 ` [PATCH V3 09/11] mdadm: change the num of cluster node Guoqing Jiang
2015-05-25  4:56   ` NeilBrown
2015-05-20  3:20 ` [PATCH V3 10/11] Reuse calc_bitmap_size to reduce code size Guoqing Jiang
2015-05-20  3:20 ` [PATCH V3 11/11] Reuse the write_bitmap for update uuid Guoqing Jiang
2015-05-25  4:59   ` NeilBrown
2015-05-25  5:03 ` [PATCH V3 00/11] mdadm tool: add the support for cluster-md NeilBrown

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=20150525143534.3faebbfb@notabene.brown \
    --to=neilb@suse.de \
    --cc=gqjiang@suse.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=rgoldwyn@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).