linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Small fix for 2.4 md.c - using device information before lock_dev()
@ 2003-03-12 14:06 Lars Marowsky-Bree
  2003-03-13  0:54 ` Neil Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Lars Marowsky-Bree @ 2003-03-12 14:06 UTC (permalink / raw)
  To: Neil Brown; +Cc: linux-raid


[-- Attachment #1.1: Type: text/plain, Size: 760 bytes --]

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 <lmb@suse.de>

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

[-- Attachment #1.2: md.c.diff --]
[-- Type: text/plain, Size: 978 bytes --]

--- md.c~	Tue Mar 11 15:21:11 2003
+++ md.c	Tue Mar 11 16:54:22 2003
@@ -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);
 
 	/*

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: Small fix for 2.4 md.c - using device information before lock_dev()
  2003-03-12 14:06 Small fix for 2.4 md.c - using device information before lock_dev() Lars Marowsky-Bree
@ 2003-03-13  0:54 ` Neil Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Brown @ 2003-03-13  0:54 UTC (permalink / raw)
  To: Lars Marowsky-Bree; +Cc: linux-raid

On Wednesday March 12, lmb@suse.de 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 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.
> 

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

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

end of thread, other threads:[~2003-03-13  0:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-12 14:06 Small fix for 2.4 md.c - using device information before lock_dev() Lars Marowsky-Bree
2003-03-13  0:54 ` Neil Brown

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