linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about mdadm commit d6508f0cfb60edf07b36f1532eae4d9cddf7178b "be more careful about add attempts"
@ 2011-10-26 17:02 Alexander Lyakas
  2011-10-26 21:51 ` NeilBrown
  0 siblings, 1 reply; 13+ messages in thread
From: Alexander Lyakas @ 2011-10-26 17:02 UTC (permalink / raw)
  To: linux-raid

Greetings everybody,
I have a question about the following code in Manage.c:Manage_subdevs()

disc.number = mdi.disk.number;
if (ioctl(fd, GET_DISK_INFO, &disc) != 0
    || disc.major != 0 || disc.minor != 0
    || !enough_fd(fd))
    goto skip_re_add;

I do not underatand why the checks: disc.major != 0 || disc.minor != 0
are required. This basically means that the kernel already has an
rdev->desc_nr equal to disc.number. But why fail the re-add procedure?

Let's say that enough_fd() returns true, and we go ahead an issue
ioctl(ADD_NEW_DISK). In this case, according to the kernel code in
add_new_disk(), it will not even look at info->number. It will
initialize rdev->desc_nr to -1, and will allocate a free desc_nr for
the rdev later.

Doing this with mdadm 3.1.4, where this check is not present, actually
succeeds. I understand that this code was added for cases when
enough_fd() returns false, which sounds perfectly fine to protect
from.

I was thinking that this code should actually check something like:
if (ioctl(fd, GET_DISK_INFO, &disc) != 0
    || disk.raid_disk != mdi.disk.raid_disk
    || !enough_fd(fd))
    goto skip_re_add;

That is to check that the slot that was being occupied by the drive we
are trying to add, is already occupied by a different drive (need also
to cover cases of raid_disk <0, raid_disk >= raid_disks etc...) and
not the desc_nr, which does not have any persistent meaning.

Perhaps there are some compatibility issues with old kernels? Or
special considerations for ... containers? non-persistent arrays?

Thanks!
Alex.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-11-22  8:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-26 17:02 Question about mdadm commit d6508f0cfb60edf07b36f1532eae4d9cddf7178b "be more careful about add attempts" Alexander Lyakas
2011-10-26 21:51 ` NeilBrown
2011-10-27  9:10   ` Alexander Lyakas
2011-10-30 23:16     ` NeilBrown
2011-10-31  8:57       ` Alexander Lyakas
2011-10-31  9:19         ` NeilBrown
2011-11-01 16:26           ` Alexander Lyakas
2011-11-01 22:52             ` NeilBrown
2011-11-08 16:23               ` Alexander Lyakas
2011-11-08 23:41                 ` NeilBrown
2011-11-17 11:13                   ` Alexander Lyakas
2011-11-21  2:44                     ` NeilBrown
2011-11-22  8:45                       ` Alexander Lyakas

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).