Linux RAID subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/1] Bug fix for mdadm 3.3 with large md device numbers
@ 2015-02-14  1:08 Mike Lovell
  2015-02-14  1:08 ` [PATCH 1/1] Use dev_t for devnm2devid and devid2devnm Mike Lovell
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Lovell @ 2015-02-14  1:08 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, mlovell

A co-worker discovered a situation were new arrays were not being created on
a system. Invoking mdadm similar to 'mdadm --create /dev/md/array-name ...'
would fail where 'mdadm --create /dev/md999 ...' would not. This system had
previously created 128 arrays successfully. He was able to work around the
problem by reverting from mdadm 3.3 to 3.2. The error reported from mdadm
was "mdadm: unexpected failure opening /dev/md1048575."

Some digging with strace showed that mdadm would try to call
open("/sys/block/md1048575/dev") which would fail and then would fail on a
call to open("-4087:-1"). I tested 'mdadm --create /dev/md1048575 ...' on an
empty test VM which would fail as well. 

The problem was traced to the md device number being used to create a
major:minor pair which would be passed to makedev(). The result, which is a
dev_t or u32, was then being used as a signed int before being passed to
major() and minor() and then into a string as signed ints. This meant that 
the major:minor string had negative numbers in it causing dev_open() to not
recognize it as a valid pair and just calling open() on the string.

The large number was generated because the problem system already had 128
arrays on it. This caused find_free_devnm() to loop from 0 to (1<<20)-1, or
1048575. Triggering the bug is done by specifying a md device number larger
than (1<<19)-1 or by creating a md array by name on a system with 128 already
configured arrays.

Originally, I was going to modify find_free_devnm to loop to (1<<19)-1 but,
since 3.2 works with the larger numbers, I decided to change the signed int
use around devnm2devid and devid2devnm. This patch has been tested against
a number of the tests that weren't already failing on my test system and
didn't cause any more tests to fail. I didn't test all but got the basics.
I am new to the mdadm source and not normally a C developer so this may not
be the best way to fix this but it seems to be working.


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

end of thread, other threads:[~2015-02-14  1:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-14  1:08 [PATCH 0/1] Bug fix for mdadm 3.3 with large md device numbers Mike Lovell
2015-02-14  1:08 ` [PATCH 1/1] Use dev_t for devnm2devid and devid2devnm Mike Lovell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox