* dm: device mapper code cleanup.
@ 2007-07-24 8:51 Dmitry Monakhov
2007-07-24 8:55 ` [PATCH 1/8] dm: Add missing 'kfree' to dm-crypt target constructor Dmitry Monakhov
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Dmitry Monakhov @ 2007-07-24 8:51 UTC (permalink / raw)
To: linux-kernel; +Cc: device-mapper development
I've prepared patch-set which i hope makes dm code safer and better :)
- First tree patches fix various leaks.
- Last five patches just convert kmalloc + memset couple to single kzalloc
(probably it should be folded to one commit).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/8] dm: Add missing 'kfree' to dm-crypt target constructor.
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
@ 2007-07-24 8:55 ` Dmitry Monakhov
2007-07-24 8:56 ` [PATCH 2/8] dm: Fix workqueue leak for raid5 Dmitry Monakhov
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Monakhov @ 2007-07-24 8:55 UTC (permalink / raw)
To: linux-kernel; +Cc: device-mapper development
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
drivers/md/dm-crypt.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index cdd3f2c..1315002 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -175,6 +175,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
if (err) {
ti->error = "Error calculating hash in ESSIV";
+ kfree(salt);
return err;
}
--
1.5.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/8] dm: Fix workqueue leak for raid5
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
2007-07-24 8:55 ` [PATCH 1/8] dm: Add missing 'kfree' to dm-crypt target constructor Dmitry Monakhov
@ 2007-07-24 8:56 ` Dmitry Monakhov
2007-07-24 22:27 ` Dan Williams
2007-07-24 8:57 ` [PATCH 3/8] dm: dm-raid1 resource leaks fixes Dmitry Monakhov
` (5 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Dmitry Monakhov @ 2007-07-24 8:56 UTC (permalink / raw)
To: linux-kernel; +Cc: device-mapper development
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
drivers/md/raid5.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 0f30826..79dd2c7 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -4985,6 +4985,8 @@ static int run(mddev_t *mddev)
abort:
if (conf) {
print_raid5_conf(conf);
+ if (conf->workqueue)
+ destroy_workqueue(conf->workqueue);
safe_put_page(conf->spare_page);
kfree(conf->disks);
kfree(conf->stripe_hashtbl);
--
1.5.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/8] dm: dm-raid1 resource leaks fixes.
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
2007-07-24 8:55 ` [PATCH 1/8] dm: Add missing 'kfree' to dm-crypt target constructor Dmitry Monakhov
2007-07-24 8:56 ` [PATCH 2/8] dm: Fix workqueue leak for raid5 Dmitry Monakhov
@ 2007-07-24 8:57 ` Dmitry Monakhov
2007-07-24 8:58 ` [PATCH 4/8] dm:dm-hw-handler.c Convert kmalloc + memset to kzalloc Dmitry Monakhov
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Monakhov @ 2007-07-24 8:57 UTC (permalink / raw)
To: linux-kernel; +Cc: device-mapper development
- Add missing 'dm_io_client_destroy' to alloc_context error path.
- Reorganize mirror constructor error path in order to prevent
workqueue leakage.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
drivers/md/dm-raid1.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 144071e..58b9f1a 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -974,6 +974,7 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
if (rh_init(&ms->rh, ms, dl, region_size, ms->nr_regions)) {
ti->error = "Error creating dirty region hash";
+ dm_io_client_destroy(ms->io_client);
kfree(ms);
return NULL;
}
@@ -1163,16 +1164,14 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ms->kmirrord_wq = create_singlethread_workqueue("kmirrord");
if (!ms->kmirrord_wq) {
DMERR("couldn't start kmirrord");
- free_context(ms, ti, m);
- return -ENOMEM;
+ r = -ENOMEM;
+ goto out_free_context;
}
INIT_WORK(&ms->kmirrord_work, do_mirror);
r = parse_features(ms, argc, argv, &args_used);
- if (r) {
- free_context(ms, ti, ms->nr_mirrors);
- return r;
- }
+ if (r)
+ goto out_destroy_wq;
argv += args_used;
argc -= args_used;
@@ -1188,19 +1187,22 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (argc) {
ti->error = "Too many mirror arguments";
- free_context(ms, ti, ms->nr_mirrors);
- return -EINVAL;
+ r = -EINVAL;
+ goto out_destroy_wq;
}
r = kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client);
- if (r) {
- destroy_workqueue(ms->kmirrord_wq);
- free_context(ms, ti, ms->nr_mirrors);
- return r;
- }
+ if (r)
+ goto out_destroy_wq;
wake(ms);
return 0;
+
+out_destroy_wq:
+ destroy_workqueue(ms->kmirrord_wq);
+out_free_context:
+ free_context(ms, ti, ms->nr_mirrors);
+ return r;
}
static void mirror_dtr(struct dm_target *ti)
--
1.5.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/8] dm:dm-hw-handler.c Convert kmalloc + memset to kzalloc
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
` (2 preceding siblings ...)
2007-07-24 8:57 ` [PATCH 3/8] dm: dm-raid1 resource leaks fixes Dmitry Monakhov
@ 2007-07-24 8:58 ` Dmitry Monakhov
2007-07-24 8:58 ` [PATCH 5/8] dm: dm-table.c " Dmitry Monakhov
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Monakhov @ 2007-07-24 8:58 UTC (permalink / raw)
To: linux-kernel; +Cc: device-mapper development
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
drivers/md/dm-hw-handler.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-hw-handler.c b/drivers/md/dm-hw-handler.c
index baafaab..2ee84d8 100644
--- a/drivers/md/dm-hw-handler.c
+++ b/drivers/md/dm-hw-handler.c
@@ -91,12 +91,10 @@ void dm_put_hw_handler(struct hw_handler_type *hwht)
static struct hwh_internal *_alloc_hw_handler(struct hw_handler_type *hwht)
{
- struct hwh_internal *hwhi = kmalloc(sizeof(*hwhi), GFP_KERNEL);
+ struct hwh_internal *hwhi = kzalloc(sizeof(*hwhi), GFP_KERNEL);
- if (hwhi) {
- memset(hwhi, 0, sizeof(*hwhi));
+ if (hwhi)
hwhi->hwht = *hwht;
- }
return hwhi;
}
--
1.5.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/8] dm: dm-table.c Convert kmalloc + memset to kzalloc
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
` (3 preceding siblings ...)
2007-07-24 8:58 ` [PATCH 4/8] dm:dm-hw-handler.c Convert kmalloc + memset to kzalloc Dmitry Monakhov
@ 2007-07-24 8:58 ` Dmitry Monakhov
2007-07-24 8:58 ` [PATCH 6/8] dm: dm-emc.c " Dmitry Monakhov
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Monakhov @ 2007-07-24 8:58 UTC (permalink / raw)
To: linux-kernel; +Cc: device-mapper development
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
drivers/md/dm-table.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 2fc199b..17237b1 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -213,12 +213,11 @@ static int alloc_targets(struct dm_table *t, unsigned int num)
int dm_table_create(struct dm_table **result, int mode,
unsigned num_targets, struct mapped_device *md)
{
- struct dm_table *t = kmalloc(sizeof(*t), GFP_KERNEL);
+ struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL);
if (!t)
return -ENOMEM;
- memset(t, 0, sizeof(*t));
INIT_LIST_HEAD(&t->devices);
atomic_set(&t->holders, 1);
--
1.5.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/8] dm: dm-emc.c Convert kmalloc + memset to kzalloc
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
` (4 preceding siblings ...)
2007-07-24 8:58 ` [PATCH 5/8] dm: dm-table.c " Dmitry Monakhov
@ 2007-07-24 8:58 ` Dmitry Monakhov
2007-07-24 8:59 ` [PATCH 7/8] dm: dm-path-selector.c " Dmitry Monakhov
2007-07-24 8:59 ` [PATCH 8/8] dm: dm-target.c " Dmitry Monakhov
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Monakhov @ 2007-07-24 8:58 UTC (permalink / raw)
To: linux-kernel; +Cc: device-mapper development
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
drivers/md/dm-emc.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-emc.c b/drivers/md/dm-emc.c
index 265c467..f04e950 100644
--- a/drivers/md/dm-emc.c
+++ b/drivers/md/dm-emc.c
@@ -224,12 +224,10 @@ fail_path:
static struct emc_handler *alloc_emc_handler(void)
{
- struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
+ struct emc_handler *h = kzalloc(sizeof(*h), GFP_KERNEL);
- if (h) {
- memset(h, 0, sizeof(*h));
+ if (h)
spin_lock_init(&h->lock);
- }
return h;
}
--
1.5.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/8] dm: dm-path-selector.c Convert kmalloc + memset to kzalloc
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
` (5 preceding siblings ...)
2007-07-24 8:58 ` [PATCH 6/8] dm: dm-emc.c " Dmitry Monakhov
@ 2007-07-24 8:59 ` Dmitry Monakhov
2007-07-24 8:59 ` [PATCH 8/8] dm: dm-target.c " Dmitry Monakhov
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Monakhov @ 2007-07-24 8:59 UTC (permalink / raw)
To: linux-kernel; +Cc: device-mapper development
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
drivers/md/dm-path-selector.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-path-selector.c b/drivers/md/dm-path-selector.c
index f10a0c8..ca1bb63 100644
--- a/drivers/md/dm-path-selector.c
+++ b/drivers/md/dm-path-selector.c
@@ -94,12 +94,10 @@ out:
static struct ps_internal *_alloc_path_selector(struct path_selector_type *pst)
{
- struct ps_internal *psi = kmalloc(sizeof(*psi), GFP_KERNEL);
+ struct ps_internal *psi = kzalloc(sizeof(*psi), GFP_KERNEL);
- if (psi) {
- memset(psi, 0, sizeof(*psi));
+ if (psi)
psi->pst = *pst;
- }
return psi;
}
--
1.5.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 8/8] dm: dm-target.c Convert kmalloc + memset to kzalloc
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
` (6 preceding siblings ...)
2007-07-24 8:59 ` [PATCH 7/8] dm: dm-path-selector.c " Dmitry Monakhov
@ 2007-07-24 8:59 ` Dmitry Monakhov
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Monakhov @ 2007-07-24 8:59 UTC (permalink / raw)
To: linux-kernel; +Cc: device-mapper development
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
drivers/md/dm-target.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index 477a041..835cf95 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -88,12 +88,10 @@ void dm_put_target_type(struct target_type *t)
static struct tt_internal *alloc_target(struct target_type *t)
{
- struct tt_internal *ti = kmalloc(sizeof(*ti), GFP_KERNEL);
+ struct tt_internal *ti = kzalloc(sizeof(*ti), GFP_KERNEL);
- if (ti) {
- memset(ti, 0, sizeof(*ti));
+ if (ti)
ti->tt = *t;
- }
return ti;
}
--
1.5.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/8] dm: Fix workqueue leak for raid5
2007-07-24 8:56 ` [PATCH 2/8] dm: Fix workqueue leak for raid5 Dmitry Monakhov
@ 2007-07-24 22:27 ` Dan Williams
0 siblings, 0 replies; 10+ messages in thread
From: Dan Williams @ 2007-07-24 22:27 UTC (permalink / raw)
To: linux-kernel, device-mapper development
On 7/24/07, Dmitry Monakhov <dmonakhov@openvz.org> wrote:
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
> drivers/md/raid5.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 0f30826..79dd2c7 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -4985,6 +4985,8 @@ static int run(mddev_t *mddev)
> abort:
> if (conf) {
> print_raid5_conf(conf);
> + if (conf->workqueue)
> + destroy_workqueue(conf->workqueue);
> safe_put_page(conf->spare_page);
> kfree(conf->disks);
> kfree(conf->stripe_hashtbl);
> --
I assume this patch is against -mm. I will fold it into:
git://lost.foo-projects.org/~dwillia2/git/iop md-for-linus
Thanks,
Dan
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-07-24 22:27 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
2007-07-24 8:55 ` [PATCH 1/8] dm: Add missing 'kfree' to dm-crypt target constructor Dmitry Monakhov
2007-07-24 8:56 ` [PATCH 2/8] dm: Fix workqueue leak for raid5 Dmitry Monakhov
2007-07-24 22:27 ` Dan Williams
2007-07-24 8:57 ` [PATCH 3/8] dm: dm-raid1 resource leaks fixes Dmitry Monakhov
2007-07-24 8:58 ` [PATCH 4/8] dm:dm-hw-handler.c Convert kmalloc + memset to kzalloc Dmitry Monakhov
2007-07-24 8:58 ` [PATCH 5/8] dm: dm-table.c " Dmitry Monakhov
2007-07-24 8:58 ` [PATCH 6/8] dm: dm-emc.c " Dmitry Monakhov
2007-07-24 8:59 ` [PATCH 7/8] dm: dm-path-selector.c " Dmitry Monakhov
2007-07-24 8:59 ` [PATCH 8/8] dm: dm-target.c " Dmitry Monakhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox