From: NeilBrown <neilb@suse.de>
To: Adam Kwolek <adam.kwolek@intel.com>
Cc: linux-raid@vger.kernel.org, ed.ciechanowski@intel.com,
marcin.labun@intel.com, Dan Williams <dan.j.williams@intel.com>
Subject: Re: [PATCH] imsm: FIX: Spare disk has wrong serial after takeover
Date: Mon, 19 Sep 2011 13:22:32 +1000 [thread overview]
Message-ID: <20110919132232.5b4de2a8@notabene.brown> (raw)
In-Reply-To: <20110915163839.5674.99218.stgit@gklab-128-013.igk.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3882 bytes --]
On Thu, 15 Sep 2011 18:38:39 +0200 Adam Kwolek <adam.kwolek@intel.com> wrote:
> Takeover marks disk as failed and adds to serial ':0' string and then
> turns it in to spare. This causes that when new spare is about to be used,
> it cannot be found due to different disk serial number.
>
> Restore disk serial number to avoid this problem.
>
> Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
This looks believeable, and I really like the fact that you have factored out
'mark_spare' as a separate function rather having something open-coded at
various points.
I can't really say if it is 'right' as I don't understand all the details of
exactly how serial numbers are supposed to work.
So I'll apply it and hope than Dan will speak up if he sees any problems.
Thanks,
NeilBrown
> ---
>
> super-intel.c | 46 ++++++++++++++++++++++++++++++++++++----------
> 1 files changed, 36 insertions(+), 10 deletions(-)
>
> diff --git a/super-intel.c b/super-intel.c
> index a78d723..f1c924f 100644
> --- a/super-intel.c
> +++ b/super-intel.c
> @@ -4407,6 +4407,37 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
> return 0;
> }
>
> +/* mark_spare()
> + * Function marks disk as spare and restores disk serial
> + * in case it was previously marked as failed by takeover operation
> + * reruns:
> + * -1 : critical error
> + * 0 : disk is marked as spare but serial is not set
> + * 1 : success
> + */
> +int mark_spare(struct dl *disk)
> +{
> + __u8 serial[MAX_RAID_SERIAL_LEN];
> + int ret_val = -1;
> +
> + if (!disk)
> + return ret_val;
> +
> + ret_val = 0;
> + if (!imsm_read_serial(disk->fd, NULL, serial)) {
> + /* Restore disk serial number, because takeover marks disk
> + * as failed and adds to serial ':0' before it becomes
> + * a spare disk.
> + */
> + serialcpy(disk->serial, serial);
> + serialcpy(disk->disk.serial, serial);
> + ret_val = 1;
> + }
> + disk->disk.status = SPARE_DISK;
> + disk->index = -1;
> +
> + return ret_val;
> +}
>
> static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
> int fd, char *devname)
> @@ -4444,7 +4475,6 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
> memset(dd, 0, sizeof(*dd));
> dd->major = major(stb.st_rdev);
> dd->minor = minor(stb.st_rdev);
> - dd->index = -1;
> dd->devname = devname ? strdup(devname) : NULL;
> dd->fd = fd;
> dd->e = NULL;
> @@ -4461,7 +4491,7 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
> size /= 512;
> serialcpy(dd->disk.serial, dd->serial);
> dd->disk.total_blocks = __cpu_to_le32(size);
> - dd->disk.status = SPARE_DISK;
> + mark_spare(dd);
> if (sysfs_disk_to_scsi_id(fd, &id) == 0)
> dd->disk.scsi_id = __cpu_to_le32(id);
> else
> @@ -4504,9 +4534,8 @@ static int remove_from_super_imsm(struct supertype *st, mdu_disk_info_t *dk)
> memset(dd, 0, sizeof(*dd));
> dd->major = dk->major;
> dd->minor = dk->minor;
> - dd->index = -1;
> dd->fd = -1;
> - dd->disk.status = SPARE_DISK;
> + mark_spare(dd);
> dd->action = DISK_REMOVE;
>
> dd->next = super->disk_mgmt_list;
> @@ -5424,10 +5453,8 @@ static int kill_subarray_imsm(struct supertype *st)
> struct dl *d;
>
> for (d = super->disks; d; d = d->next)
> - if (d->index > -2) {
> - d->index = -1;
> - d->disk.status = SPARE_DISK;
> - }
> + if (d->index > -2)
> + mark_spare(d);
> }
>
> super->updates_pending++;
> @@ -7011,8 +7038,7 @@ static int apply_takeover_update(struct imsm_update_takeover *u,
> if (du->index > idx)
> du->index--;
> /* mark as spare disk */
> - dm->disk.status = SPARE_DISK;
> - dm->index = -1;
> + mark_spare(dm);
> }
> }
> /* update map */
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
next prev parent reply other threads:[~2011-09-19 3:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-15 16:38 [PATCH] imsm: FIX: Spare disk has wrong serial after takeover Adam Kwolek
2011-09-19 3:22 ` NeilBrown [this message]
2011-09-21 6:05 ` Williams, Dan J
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=20110919132232.5b4de2a8@notabene.brown \
--to=neilb@suse.de \
--cc=adam.kwolek@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ed.ciechanowski@intel.com \
--cc=linux-raid@vger.kernel.org \
--cc=marcin.labun@intel.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).