Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/dm use some size_t, add whitespace between functions...



details:   https://anonhg.NetBSD.org/src/rev/0e8a7eb0259b
branches:  trunk
changeset: 828821:0e8a7eb0259b
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jan 05 14:22:26 2018 +0000

description:
use some size_t, add whitespace between functions, rcsids.

diffstat:

 sys/dev/dm/dm_dev.c           |  20 ++++++++--
 sys/dev/dm/dm_pdev.c          |  78 ++++++++++++++++++++++++------------------
 sys/dev/dm/dm_table.c         |  11 +++++-
 sys/dev/dm/dm_target.c        |  18 +++++++--
 sys/dev/dm/dm_target_error.c  |  10 ++++-
 sys/dev/dm/dm_target_mirror.c |  10 ++++-
 sys/dev/dm/dm_target_stripe.c |  13 ++++++-
 sys/dev/dm/dm_target_zero.c   |  10 ++++-
 8 files changed, 121 insertions(+), 49 deletions(-)

diffs (truncated from 760 to 300 lines):

diff -r 64fa1f9aec65 -r 0e8a7eb0259b sys/dev/dm/dm_dev.c
--- a/sys/dev/dm/dm_dev.c       Fri Jan 05 14:22:05 2018 +0000
+++ b/sys/dev/dm/dm_dev.c       Fri Jan 05 14:22:26 2018 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_dev.c,v 1.10 2017/06/01 02:45:09 chs Exp $      */
+/*        $NetBSD: dm_dev.c,v 1.11 2018/01/05 14:22:26 christos Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,6 +28,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.11 2018/01/05 14:22:26 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -61,6 +63,7 @@
                cv_wait(&dmv->dev_cv, &dmv->dev_mtx);
        mutex_exit(&dmv->dev_mtx);
 }
+
 /*
  * Generic function used to lookup dm_dev_t. Calling with dm_dev_name
  * and dm_dev_uuid NULL is allowed.
@@ -98,7 +101,6 @@
        return NULL;
 }
 
-
 /*
  * Lookup device with its minor number.
  */
@@ -114,6 +116,7 @@
 
        return NULL;
 }
+
 /*
  * Lookup device with its device name.
  */
@@ -121,8 +124,8 @@
 dm_dev_lookup_name(const char *dm_dev_name)
 {
        dm_dev_t *dmv;
-       int dlen;
-       int slen;
+       size_t dlen;
+       size_t slen;
 
        slen = strlen(dm_dev_name);
 
@@ -142,6 +145,7 @@
 
        return NULL;
 }
+
 /*
  * Lookup device with its device uuid. Used mostly by LVM2tools.
  */
@@ -168,6 +172,7 @@
 
        return NULL;
 }
+
 /*
  * Insert new device to the global list of devices.
  */
@@ -194,6 +199,7 @@
        mutex_exit(&dm_dev_mutex);
        return r;
 }
+
 #ifdef notyet
 /*
  * Lookup device with its minor number.
@@ -238,6 +244,7 @@
 
        return NULL;
 }
+
 /*
  * Remove device selected with dm_dev from global list of devices.
  */
@@ -269,6 +276,7 @@
 
        return NULL;
 }
+
 /*
  * Destroy all devices created in device-mapper. Remove all tables
  * free all allocated memmory.
@@ -310,6 +318,7 @@
        mutex_destroy(&dm_dev_mutex);
        return 0;
 }
+
 /*
  * Allocate new device entry.
  */
@@ -322,6 +331,7 @@
        dmv->diskp = kmem_zalloc(sizeof(struct disk), KM_SLEEP);
        return dmv;
 }
+
 /*
  * Freed device entry.
  */
@@ -360,6 +370,7 @@
                cv_broadcast(&dmv->dev_cv);
        mutex_exit(&dmv->dev_mtx);
 }
+
 /*
  * Return prop_array of dm_targer_list dictionaries.
  */
@@ -387,6 +398,7 @@
        mutex_exit(&dm_dev_mutex);
        return dev_array;
 }
+
 /*
  * Initialize global device mutex.
  */
diff -r 64fa1f9aec65 -r 0e8a7eb0259b sys/dev/dm/dm_pdev.c
--- a/sys/dev/dm/dm_pdev.c      Fri Jan 05 14:22:05 2018 +0000
+++ b/sys/dev/dm/dm_pdev.c      Fri Jan 05 14:22:26 2018 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_pdev.c,v 1.9 2017/06/01 02:45:09 chs Exp $      */
+/*        $NetBSD: dm_pdev.c,v 1.10 2018/01/05 14:22:26 christos Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,6 +28,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.10 2018/01/05 14:22:26 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -44,21 +46,21 @@
 
 SLIST_HEAD(dm_pdevs, dm_pdev) dm_pdev_list;
 
-       kmutex_t dm_pdev_mutex;
+kmutex_t dm_pdev_mutex;
 
-       static dm_pdev_t *dm_pdev_alloc(const char *);
-       static int dm_pdev_rem(dm_pdev_t *);
-       static dm_pdev_t *dm_pdev_lookup_name(const char *);
+static dm_pdev_t *dm_pdev_alloc(const char *);
+static int dm_pdev_rem(dm_pdev_t *);
+static dm_pdev_t *dm_pdev_lookup_name(const char *);
 
 /*
- * Find used pdev with name == dm_pdev_name.
- */
-       dm_pdev_t *
-                 dm_pdev_lookup_name(const char *dm_pdev_name)
+* Find used pdev with name == dm_pdev_name.
+*/
+dm_pdev_t *
+dm_pdev_lookup_name(const char *dm_pdev_name)
 {
        dm_pdev_t *dm_pdev;
-       int dlen;
-       int slen;
+       size_t dlen;
+       size_t slen;
 
        KASSERT(dm_pdev_name != NULL);
 
@@ -76,6 +78,7 @@
 
        return NULL;
 }
+
 /*
  * Create entry for device with name dev_name and open vnode for it.
  * If entry already exists in global SLIST I will only increment
@@ -95,7 +98,8 @@
 
        if (dmp != NULL) {
                dmp->ref_cnt++;
-               aprint_debug("dmp_pdev_insert pdev %s already in tree\n", dev_name);
+               aprint_debug("%s: pdev %s already in tree\n",
+                   __func__, dev_name);
                mutex_exit(&dm_pdev_mutex);
                return dmp;
        }
@@ -106,16 +110,16 @@
 
        dev_pb = pathbuf_create(dev_name);
        if (dev_pb == NULL) {
-               aprint_debug("pathbuf_create on device: %s failed!\n",
-                   dev_name);
+               aprint_debug("%s: pathbuf_create on device: %s failed!\n",
+                   __func__, dev_name);
                kmem_free(dmp, sizeof(dm_pdev_t));
                return NULL;
        }
        error = dk_lookup(dev_pb, curlwp, &dmp->pdev_vnode);
        pathbuf_destroy(dev_pb);
        if (error) {
-               aprint_debug("dk_lookup on device: %s failed with error %d!\n",
-                   dev_name, error);
+               aprint_debug("%s: dk_lookup on device: %s (error %d)\n",
+                   __func__, dev_name, error);
                kmem_free(dmp, sizeof(dm_pdev_t));
                return NULL;
        }
@@ -128,6 +132,7 @@
 
        return dmp;
 }
+
 /*
  * Initialize pdev subsystem.
  */
@@ -139,6 +144,7 @@
 
        return 0;
 }
+
 /*
  * Allocat new pdev structure if is not already present and
  * set name.
@@ -148,33 +154,33 @@
 {
        dm_pdev_t *dmp;
 
-       dmp = kmem_zalloc(sizeof(dm_pdev_t), KM_SLEEP);
-       strlcpy(dmp->name, name, MAX_DEV_NAME);
+       dmp = kmem_zalloc(sizeof(*dmp), KM_SLEEP);
+       strlcpy(dmp->name, name, sizeof(dmp->name));
        dmp->ref_cnt = 0;
        dmp->pdev_vnode = NULL;
 
        return dmp;
 }
+
 /*
  * Destroy allocated dm_pdev.
  */
 static int
 dm_pdev_rem(dm_pdev_t * dmp)
 {
-       int err;
 
        KASSERT(dmp != NULL);
 
        if (dmp->pdev_vnode != NULL) {
-               err = vn_close(dmp->pdev_vnode, FREAD | FWRITE, FSCRED);
-               if (err != 0)
-                       return err;
+               int error = vn_close(dmp->pdev_vnode, FREAD | FWRITE, FSCRED);
+               if (error != 0)
+                       return error;
        }
        kmem_free(dmp, sizeof(*dmp));
-       dmp = NULL;
 
        return 0;
 }
+
 /*
  * Destroy all existing pdev's in device-mapper.
  */
@@ -197,6 +203,7 @@
        mutex_destroy(&dm_pdev_mutex);
        return 0;
 }
+
 /*
  * This funcion is called from dm_dev_remove_ioctl.
  * When I'm removing device from list, I have to decrement
@@ -227,18 +234,21 @@
        mutex_exit(&dm_pdev_mutex);
        return 0;
 }
-/*static int
-  dm_pdev_dump_list(void)
-  {
-  dm_pdev_t *dmp;
+
+#if 0
+static int
+dm_pdev_dump_list(void)
+{
+       dm_pdev_t *dmp;
        
-  aprint_verbose("Dumping dm_pdev_list \n");
+       aprint_verbose("Dumping dm_pdev_list\n");
        
-  SLIST_FOREACH(dmp, &dm_pdev_list, next_pdev) {
-  aprint_verbose("dm_pdev_name %s ref_cnt %d list_rf_cnt %d\n",
-  dmp->name, dmp->ref_cnt, dmp->list_ref_cnt);



Home | Main Index | Thread Index | Old Index