2004-06-30 19:51:44

by Kevin Corry

[permalink] [raw]
Subject: [PATCH] 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().

--
Kevin Corry
[email protected]
http://evms.sourceforge.net/


2004-06-30 19:56:49

by Kevin Corry

[permalink] [raw]
Subject: [PATCH] 1/4: DM: kcopyd.c: Remove unused include

kcopyd.c: Remove unused #include.

Signed-off-by: Kevin Corry <[email protected]>

--- diff/drivers/md/kcopyd.c 2004-06-30 08:45:34.513303448 -0500
+++ source/drivers/md/kcopyd.c 2004-06-30 08:48:15.384847256 -0500
@@ -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;

2004-06-30 19:57:13

by Kevin Corry

[permalink] [raw]
Subject: [PATCH] 2/4: DM: kcopyd.c: make client_add() return void

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

Signed-off-by: Kevin Corry <[email protected]>

--- diff/drivers/md/kcopyd.c 2004-06-30 08:48:15.384847256 -0500
+++ source/drivers/md/kcopyd.c 2004-06-30 08:48:19.528217368 -0500
@@ -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;
}

2004-06-30 19:58:23

by Kevin Corry

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

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

Signed-off-by: Kevin Corry <[email protected]>

--- diff/drivers/md/dm-raid1.c 2004-06-30 08:48:25.247347928 -0500
+++ source/drivers/md/dm-raid1.c 2004-06-30 08:48:30.101609968 -0500
@@ -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++) {

2004-06-30 19:59:40

by Kevin Corry

[permalink] [raw]
Subject: [PATCH] 3/4: DM: dm-raid1.c: Enforce max of 9 mirrors

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.

Signed-off-by: Kevin Corry <[email protected]>

--- diff/drivers/md/dm-raid1.c 2004-06-30 08:45:34.500305424 -0500
+++ source/drivers/md/dm-raid1.c 2004-06-30 08:48:25.247347928 -0500
@@ -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;

2004-06-30 20:10:31

by Michael Buesch

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

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

Quoting Kevin Corry <[email protected]>:
> - 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-----

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

On Wed, Jun 30, 2004 at 10:07:53PM +0200, Michael Buesch wrote:
> Quoting Kevin Corry <[email protected]>:
> > - 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().