Skip to contentSkip to conversation

0/4: Device-Mapper: Minor cleanups and fixes

PATCH New Kevin Corry 3 participants 7 messages Jun 30, 2004 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 0/4: Device-Mapper: Minor cleanups and fixes

Patches against 2.6.7-bk13.

Revision 1:
kcopyd.c: Remove unused #include.

Revision 2:
kcopyd.c: client_add() can return void instead of an int, which will eliminate an unnecessary error path in kcopyd_client_create().

Revision 3:
dm-raid1.c: Since kcopyd can currently only handle 1 source and up to 8 destinations, enforce a max of 9 mirrors when creating a dm-mirror device.

Revision 4:
dm-raid1.c: Declare fixed-sized (instead of variable-sized) arrays on the stack in recover() and do_write().

Signature · 3 lines
Kevin Corry
[email protected]
http://evms.sourceforge.net/
#1 lore raw

PATCH 1/1 1/4: DM: kcopyd.c: Remove unused include

kcopyd.c: Remove unused #include.

drivers/md/kcopyd.c +0 -3
@@ -24,9 +24,6 @@
 
 #include "kcopyd.h"
 
-/* FIXME: this is only needed for the DMERR macros */
-#include "dm.h"
-
 static struct workqueue_struct *_kcopyd_wq;
 static struct work_struct _kcopyd_work;
 
#2 lore raw

PATCH 1/1 2/4: DM: kcopyd.c: make client_add() return void

In reply to Kevin Corry

kcopyd.c: client_add() can return void instead of an int, which will eliminate an unnecessary error path in kcopyd_client_create().

drivers/md/kcopyd.c +2 -11
@@ -573,12 +573,11 @@
 static DECLARE_MUTEX(_client_lock);
 static LIST_HEAD(_clients);
 
-static int client_add(struct kcopyd_client *kc)
+static void client_add(struct kcopyd_client *kc)
 {
 	down(&_client_lock);
 	list_add(&kc->list, &_clients);
 	up(&_client_lock);
-	return 0;
 }
 
 static void client_del(struct kcopyd_client *kc)
@@ -668,15 +667,7 @@
 		return r;
 	}
 
-	r = client_add(kc);
-	if (r) {
-		dm_io_put(nr_pages);
-		client_free_pages(kc);
-		kfree(kc);
-		kcopyd_exit();
-		return r;
-	}
-
+	client_add(kc);
 	*result = kc;
 	return 0;
 }
#3 lore raw

PATCH 1/1 4/4: DM: dm-raid1.c: Use fixed-size arrays

In reply to Kevin Corry

dm-raid1.c: Declare fixed-sized (instead of variable-sized) arrays on the stack in recover() and do_write().

drivers/md/dm-raid1.c +2 -2
@@ -602,7 +602,7 @@
 {
 	int r;
 	unsigned int i;
-	struct io_region from, to[ms->nr_mirrors - 1], *dest;
+	struct io_region from, to[KCOPYD_MAX_REGIONS], *dest;
 	struct mirror *m;
 	unsigned long flags = 0;
 
@@ -757,7 +757,7 @@
 static void do_write(struct mirror_set *ms, struct bio *bio)
 {
 	unsigned int i;
-	struct io_region io[ms->nr_mirrors];
+	struct io_region io[KCOPYD_MAX_REGIONS+1];
 	struct mirror *m;
 
 	for (i = 0; i < ms->nr_mirrors; i++) {
#4 lore raw

Re: [PATCH] 4/4: DM: dm-raid1.c: Use fixed-size arrays

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

Quoting Kevin Corry <[email protected]>:

drivers/md/dm-raid1.c line 605

Quoted 1 line
drivers/md/dm-raid1.c +0 -1
-	struct io_region from, to[ms->nr_mirrors - 1], *dest;

Heh? Could someone please explain how this could compile? Dynamic allocation on the stack? I'm confused.

- --
Regards Michael Buesch [ http://www.tuxsoft.de.vu ]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA4x2ZFGK1OIvVOP4RAnH3AKDhNlOgKWvx/GqWVROutfqEUpnc1QCbBz1j koxiQ/7WtV/QOocbgYTHi4E=
=7Ch5
-----END PGP SIGNATURE-----

#5 lore raw

Re: [PATCH] 4/4: DM: dm-raid1.c: Use fixed-size arrays

Quoted 4 lines · Michael Buesch

Quoting Kevin Corry <[email protected]>:

drivers/md/dm-raid1.c line 605

Quoted 1 line
drivers/md/dm-raid1.c +0 -1
-	struct io_region from, to[ms->nr_mirrors - 1], *dest;

Heh? Could someone please explain how this could compile?

Such a dynamic allocation on the stack is a GCC extension, implemented for
a very long time.

I guess this is not very different from alloca().

#6 lore raw

PATCH 1/1 3/4: DM: dm-raid1.c: Enforce max of 9 mirrors

In reply to Kevin Corry

dm-raid1.c: Since kcopyd can currently only handle 1 source and up to 8 destinations, enforce a max of 9 mirrors when creating a dm-mirror device.

drivers/md/dm-raid1.c +1 -1
@@ -1028,7 +1028,7 @@
 	argc -= args_used;
 
 	if (!argc || sscanf(argv[0], "%u", &nr_mirrors) != 1 ||
-	    nr_mirrors < 2) {
+	    nr_mirrors < 2 || nr_mirrors > KCOPYD_MAX_REGIONS + 1) {
 		ti->error = "dm-mirror: Invalid number of mirrors";
 		dm_destroy_dirty_log(dl);
 		return -EINVAL;