linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: wuzhouhui <wuzhouhui14@mails.ucas.ac.cn>, linux-raid@vger.kernel.org
Subject: Re: mdadm: using ioctl to set disk faulty instead of sysfs
Date: Mon, 04 Dec 2017 11:34:42 +1100	[thread overview]
Message-ID: <87shcrtjod.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <33BB30F4-F2A1-437B-ABFE-6A03E9563F01@mails.ucas.ac.cn>

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

On Tue, Nov 21 2017, wuzhouhui wrote:

> Hi, I have a suggest about mdadm to set disk faulty. Since commit 1ca69c4bc4b1ef
> (md: avoid taking the mutex on some ioctls) removes lock when set disk faulty,
> so we'd better using ioctl(SET_DISK_FAULTY) to set disk faulty, instead of 
> echo faulty > /sys/block/<md>/md/dev-<disk>/state, because caller of state's
> handler would lock mddev. Like following:
>
> Index: mdadm-4.0/Manage.c
> ===================================================================
> --- mdadm-4.0.orig/Manage.c
> +++ mdadm-4.0/Manage.c
> @@ -1662,9 +1662,7 @@ int Manage_subdevs(char *devname, int fd
>  
>  		case 'f': /* set faulty */
>  			/* FIXME check current member */
> -			if ((sysfd >= 0 && write(sysfd, "faulty", 6) != 6) ||
> -			    (sysfd < 0 && ioctl(fd, SET_DISK_FAULTY,
> -						rdev))) {
> +			if (ioctl(fd, SET_DISK_FAULTY, rdev)) {
>  				if (errno == EBUSY)
>  					busy = 1;
>  				pr_err("set device faulty failed for %s:  %s\n",
>

This isn't just a debatable optimization.  It is wrong and would
introduce a regression.
Please make sure you understand code *before* trying to change it.

Please look at the git history for this code and find the patch where
writing "faulty" was added as an alternative.  That might help you to
understand what is happening here.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

      parent reply	other threads:[~2017-12-04  0:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 13:09 mdadm: using ioctl to set disk faulty instead of sysfs wuzhouhui
2017-12-01 20:28 ` Shaohua Li
2017-12-04  0:34 ` NeilBrown [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=87shcrtjod.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=wuzhouhui14@mails.ucas.ac.cn \
    /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).