Skip to contentSkip to conversation

md - 0 of 2 - Introduction

PATCH In review NeilBrown 4 participants 7 messages Mar 5, 2004 – Mar 10, 2004

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 md - 0 of 2 - Introduction

Here are two patches for md that I believe are suitable for 2.6.4.

1/ change yield() to schedule_timeout(2) as promised a while back.

2/ Support assembling partitionable raid at boot-time so that it is
possible to boot from a partition of a raid array without needing an initramfs.

Thanks,
NeilBrown

author
#1 lore raw

PATCH 1/1 md - 1 of 2 - Use "shedule_timeout(2)" instead of yield() as it seems to wait for less time.

----------- Diffstat output ------------

 ./drivers/md/raid5.c     |    3 ++-
 ./drivers/md/raid6main.c |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/md/raid5.c renamed from drivers/md/raid5.c~current~ +2 -1
diff ./drivers/md/raid5.c~current~ ./drivers/md/raid5.c
@@ -1409,7 +1409,8 @@ static int sync_request (mddev_t *mddev,
 		/* make sure we don't swamp the stripe cache if someone else
 		 * is trying to get access 
 		 */
-		yield();
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(2);
 	}
 	spin_lock(&sh->lock);	
 	set_bit(STRIPE_SYNCING, &sh->state);
drivers/md/raid6main.c renamed from drivers/md/raid6main.c~current~ +2 -1
diff ./drivers/md/raid6main.c~current~ ./drivers/md/raid6main.c
@@ -1571,7 +1571,8 @@ static int sync_request (mddev_t *mddev,
 		/* make sure we don't swamp the stripe cache if someone else
 		 * is trying to get access
 		 */
-		yield();
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(2);
 	}
 	spin_lock(&sh->lock);
 	set_bit(STRIPE_SYNCING, &sh->state);
#2 lore raw

Re: [PATCH] md - 1 of 2 - Use "shedule_timeout(2)" instead of yield() as it seems to wait for less time.

Review

Quoted 2 lines · NeilBrown
(quoted diff) +1 -0
+		schedule_timeout(2);

Are you sure we want to sleep for 20-30 milliseconds on a 100 Hz machine?

Wouldn't it be better to do

drivers/md/raid5.c renamed from drivers/md/raid5.c~md-use-schedule_timeout +2 -1
diff -puN drivers/md/raid5.c~md-use-schedule_timeout drivers/md/raid5.c
@@ -1409,7 +1409,8 @@ static int sync_request (mddev_t *mddev,
 		/* make sure we don't swamp the stripe cache if someone else
 		 * is trying to get access 
 		 */
-		yield();
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(max(HZ/500, 1));
 	}
 	spin_lock(&sh->lock);	
 	set_bit(STRIPE_SYNCING, &sh->state);
drivers/md/raid6main.c renamed from drivers/md/raid6main.c~md-use-schedule_timeout +2 -1
diff -puN drivers/md/raid6main.c~md-use-schedule_timeout drivers/md/raid6main.c
@@ -1571,7 +1571,8 @@ static int sync_request (mddev_t *mddev,
 		/* make sure we don't swamp the stripe cache if someone else
 		 * is trying to get access
 		 */
-		yield();
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(max(HZ/500, 1));
 	}
 	spin_lock(&sh->lock);
 	set_bit(STRIPE_SYNCING, &sh->state);

_

?

author
#3 lore raw

Re: [PATCH] md - 1 of 2 - Use "shedule_timeout(2)" instead of yield() as it seems to wait for less time.

Quoted 6 lines · On Thursday March 4, [email protected] wrote:

Review

Quoted 2 lines · NeilBrown
(quoted diff) +1 -0
+		schedule_timeout(2);

Are you sure we want to sleep for 20-30 milliseconds on a 100 Hz machine?

I'm not sure it really matters. This bit of code doesn't trigger very often.

I'm not unhappy with your version, but I suspect that just
schedule_timeout(1)
would be ok. I think I used '2' because there is no lower bound on how long schedule_timeout(1) will sleep (until the next tick, which could be anytime - right?).
But on reflection, that doesn't really matter. As long as it pauses for a little while at least once in a while, it will give any non-sync IO a chance, that once that starts happening, resync will automatically wind back and there won't be a problem anymore.

So I think (and some testing seems to demonstrate) that it doesn't really matter. So leave it as it is I guess.

Thank,
NeilBrown

Quoted 33 lines

Wouldn't it be better to do

diff -puN drivers/md/raid5.c~md-use-schedule_timeout drivers/md/raid5.c

drivers/md/raid5.c renamed from drivers/md/raid5.c~md-use-schedule_timeout +2 -1
@@ -1409,7 +1409,8 @@ static int sync_request (mddev_t *mddev,
 		/* make sure we don't swamp the stripe cache if someone else
 		 * is trying to get access 
 		 */
-		yield();
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(max(HZ/500, 1));
 	}
 	spin_lock(&sh->lock);	
 	set_bit(STRIPE_SYNCING, &sh->state);

diff -puN drivers/md/raid6main.c~md-use-schedule_timeout drivers/md/raid6main.c

drivers/md/raid6main.c renamed from drivers/md/raid6main.c~md-use-schedule_timeout +2 -1
@@ -1571,7 +1571,8 @@ static int sync_request (mddev_t *mddev,
 		/* make sure we don't swamp the stripe cache if someone else
 		 * is trying to get access
 		 */
-		yield();
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(max(HZ/500, 1));
 	}
 	spin_lock(&sh->lock);
 	set_bit(STRIPE_SYNCING, &sh->state);

_

?

author
#4 lore raw

PATCH 1/1 md - 2 of 2 - Allow assembling of partitioned arrays at boot time.

In reply to NeilBrown

kernel parameters:
raid=partitionable
will make all auto-detected md arrays partitionable
md=d....
will assemble an array as a partitionable array.

----------- Diffstat output ------------

 ./drivers/md/md.c     |   19 ++++++---
 ./init/do_mounts_md.c |   99 +++++++++++++++++++++++++++++---------------------
 2 files changed, 70 insertions(+), 48 deletions(-)
drivers/md/md.c renamed from drivers/md/md.c~current~ +12 -7
diff ./drivers/md/md.c~current~ ./drivers/md/md.c
@@ -57,7 +57,7 @@
 
 
 #ifndef MODULE
-static void autostart_arrays (void);
+static void autostart_arrays (int part);
 #endif
 
 static mdk_personality_t *pers[MAX_PERSONALITY];
@@ -1792,7 +1792,7 @@ static void autorun_array(mddev_t *mddev
  *
  * If "unit" is allocated, then bump its reference count
  */
-static void autorun_devices(void)
+static void autorun_devices(int part)
 {
 	struct list_head candidates;
 	struct list_head *tmp;
@@ -1825,7 +1825,12 @@ static void autorun_devices(void)
 			       bdevname(rdev0->bdev, b), rdev0->preferred_minor);
 			break;
 		}
-		dev = MKDEV(MD_MAJOR, rdev0->preferred_minor);
+		if (part)
+			dev = MKDEV(mdp_major,
+				    rdev0->preferred_minor << MdpMinorShift);
+		else
+			dev = MKDEV(MD_MAJOR, rdev0->preferred_minor);
+
 		md_probe(dev, NULL, NULL);
 		mddev = mddev_find(dev);
 		if (!mddev) {
@@ -1922,7 +1927,7 @@ static int autostart_array(dev_t startde
 	/*
 	 * possibly return codes
 	 */
-	autorun_devices();
+	autorun_devices(0);
 	return 0;
 
 }
@@ -2407,7 +2412,7 @@ static int md_ioctl(struct inode *inode,
 #ifndef MODULE
 		case RAID_AUTORUN:
 			err = 0;
-			autostart_arrays();
+			autostart_arrays(arg);
 			goto done;
 #endif
 		default:;
@@ -3577,7 +3582,7 @@ void md_autodetect_dev(dev_t dev)
 }
 
 
-static void autostart_arrays(void)
+static void autostart_arrays(int part)
 {
 	char b[BDEVNAME_SIZE];
 	mdk_rdev_t *rdev;
@@ -3602,7 +3607,7 @@ static void autostart_arrays(void)
 	}
 	dev_cnt = 0;
 
-	autorun_devices();
+	autorun_devices(part);
 }
 
 #endif
init/do_mounts_md.c renamed from init/do_mounts_md.c~current~ +58 -41

202 lines not on this page · raw message

#5 lore raw
In reply to NeilBrown

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

NeilBrown wrote:

| Here are two patches for md that I believe are suitable
| for 2.6.4.
|
| 2/ Support assembling partitionable raid at boot-time so that it is
|    possible to boot from a partition of a raid array without needing
|    an initramfs.

I have a RAID 1 here and I boot with grub and I don't need ana initramfs (initrd) ...

- --
Clemens Schwaighofer - IT Engineer & System Administration
==========================================================
Tequila Japan, 6-17-2 Ginza Chuo-ku, Tokyo 104-8167, JAPAN
Tel: +81-(0)3-3545-7703 Fax: +81-(0)3-3545-7343
http://www.tequila.jp
==========================================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFASD1ojBz/yQjBxz8RAq6lAKDdN8hKgdBocQZOqC0yGoYd/Z6MCQCfdaL/ BFv6yTZznpg7wIEWxlQELak=
=Zht7
-----END PGP SIGNATURE-----

#6 lore raw
Quoted 11 lines · Clemens Schwaighofer

NeilBrown wrote:

| Here are two patches for md that I believe are suitable
| for 2.6.4.
|
| 2/ Support assembling partitionable raid at boot-time so that it is
|    possible to boot from a partition of a raid array without needing
|    an initramfs.

I have a RAID 1 here and I boot with grub and I don't need ana initramfs (initrd) ...

The keyword here is "partitionable".

/mjt