Small fix for 2.4 md.c - using device information before lock_dev()
Good morning,
I've been testing md under UML. It appears that UML is exposing a minor bug in md.c: it is trying to use information about the device (in particular, blk_sizes[]) before having imported it (which calls lock_dev() and thus makes the information available in the first place).
This was exposed because UML resets the blk_sizes[] information to zero on ubd_release().
Working patch attached; it just reorders the function calls. Please apply to 2.4 if appropriate.
Sincerely,
Lars Marowsky-Brée <[email protected]>
Signature · 5 lines
Principal Squirrel SuSE Labs - Research & Development, SuSE Linux AG "If anything can go wrong, it will." "Chance favors the prepared (mind)." -- Capt. Edward A. Murphy -- Louis Pasteur
md.c renamed from md.c~ +10 -7
@@ -2456,13 +2456,6 @@ } persistent = !mddev->sb->not_persistent; - size =calc_dev_size (dev, mddev, persistent); - -if (size < mddev->sb->size) { -printk (KERN_WARNING "md%d: disk size %d blocks < array size %d\n" , -mdidx (mddev), size, mddev->sb->size); -return -ENOSPC ; - } rdev =find_rdev (mddev, dev);if (rdev)
@@ -2473,6 +2466,7 @@printk (KERN_WARNING "md: error, md_import_device() returned %d\n" , err);return -EINVAL ; } + rdev =find_rdev_all (dev);if (!rdev) {MD_BUG ();
@@ -2484,6 +2478,15 @@ err = -EINVAL ; goto abort_export; } + + size =calc_dev_size (dev, mddev, persistent); +if (size < mddev->sb->size) { +printk (KERN_WARNING "md%d: disk size %d blocks < array size %d\n" , +mdidx (mddev), size, mddev->sb->size); + err = -ENOSPC ; + goto abort_export; + } +bind_rdev_to_array (rdev, mddev);/*
Quoted 7 lines · On Wednesday March 12, [email protected] wrote:
Good morning,
I've been testing md under UML. It appears that UML is exposing a minor bug in
md.c: it is trying to use information about the device (in particular, blk_sizes[]) before having imported it (which callslock_dev()and thus makes the information available in the first place).
Quoted 6 lines
This was exposed because UML resets the blk_sizes[] information to zero on
ubd_release().Working patch attached; it just reorders the function calls. Please apply to 2.4 if appropriate.
Thanks ... that's a subtle one.
It appears not be be an issue with 2.5 as you cannot even get at the size before doing the bdget - which is good.
I'll send it to Marcelo.
NeilBrown