Module Name: src
Committed By: haad
Date: Mon Apr 13 18:51:54 UTC 2009
Modified Files:
src/sys/dev/dm: dm_dev.c dm_ioctl.c
Log Message:
Destroy locks in dm_dev_free, do not allocate struct disk twice.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/dm/dm_dev.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/dm/dm_ioctl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/dm/dm_dev.c
diff -u src/sys/dev/dm/dm_dev.c:1.4 src/sys/dev/dm/dm_dev.c:1.5
--- src/sys/dev/dm/dm_dev.c:1.4 Wed Mar 18 10:22:39 2009
+++ src/sys/dev/dm/dm_dev.c Mon Apr 13 18:51:54 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_dev.c,v 1.4 2009/03/18 10:22:39 cegger Exp $ */
+/* $NetBSD: dm_dev.c,v 1.5 2009/04/13 18:51:54 haad Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -320,6 +320,9 @@
{
KASSERT(dmv != NULL);
+ mutex_destroy(&dmv->dev_mtx);
+ cv_destroy(&dmv->dev_cv);
+
if(dmv->diskp != NULL)
(void)kmem_free(dmv->diskp, sizeof(struct disk));
Index: src/sys/dev/dm/dm_ioctl.c
diff -u src/sys/dev/dm/dm_ioctl.c:1.10 src/sys/dev/dm/dm_ioctl.c:1.11
--- src/sys/dev/dm/dm_ioctl.c:1.10 Mon Apr 6 22:58:10 2009
+++ src/sys/dev/dm/dm_ioctl.c Mon Apr 13 18:51:54 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.10 2009/04/06 22:58:10 haad Exp $ */
+/* $NetBSD: dm_ioctl.c,v 1.11 2009/04/13 18:51:54 haad Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -219,10 +219,7 @@
if ((dmv = dm_dev_alloc()) == NULL)
return ENOMEM;
-
- if ((dmv->diskp = kmem_alloc(sizeof(struct disk), KM_NOSLEEP)) == NULL)
- return ENOMEM;
-
+
if (uuid)
strncpy(dmv->uuid, uuid, DM_UUID_LEN);
else
@@ -251,11 +248,8 @@
disk_init(dmv->diskp, dmv->name, &dmdkdriver);
disk_attach(dmv->diskp);
- if ((r = dm_dev_insert(dmv)) != 0){
- mutex_destroy(&dmv->dev_mtx);
- cv_destroy(&dmv->dev_cv);
+ if ((r = dm_dev_insert(dmv)) != 0)
dm_dev_free(dmv);
- }
DM_ADD_FLAG(flags, DM_EXISTS_FLAG);
DM_REMOVE_FLAG(flags, DM_INACTIVE_PRESENT_FLAG);
@@ -400,9 +394,6 @@
dm_table_head_destroy(&dmv->table_head);
- mutex_destroy(&dmv->dev_mtx);
- cv_destroy(&dmv->dev_cv);
-
/* Destroy disk device structure */
disk_detach(dmv->diskp);
disk_destroy(dmv->diskp);