]> sourceware.org Git - dm.git/commitdiff
tidying
authorAlasdair Kergon <agk@redhat.com>
Mon, 7 Jan 2002 22:01:39 +0000 (22:01 +0000)
committerAlasdair Kergon <agk@redhat.com>
Mon, 7 Jan 2002 22:01:39 +0000 (22:01 +0000)
kernel/common/dm-table.c
kernel/common/dm.c.in
kernel/common/dm.h
kernel/ioctl/dm-ioctl.c
lib/ioctl/libdevmapper.c

index 6efd73a53223df63ca8933c19844e5f14f0d5ce8..1d9efec08c312acabd1910c778076957d5a00ae6 100644 (file)
@@ -336,7 +336,7 @@ void dm_table_put_device(struct dm_table *t, struct dm_dev *dd)
 /*
  * Adds a target to the map
  */
-int dm_table_add_target(struct dm_table *t, offset_t high,
+int dm_table_add_target(struct dm_table *t, offset_t highs,
                        struct target_type *type, void *private)
 {
        int r, n;
@@ -345,7 +345,7 @@ int dm_table_add_target(struct dm_table *t, offset_t high,
                return r;
 
        n = t->num_targets++;
-       t->highs[n] = high;
+       t->highs[n] = highs;
        t->targets[n].type = type;
        t->targets[n].private = private;
 
index 2884af482df433cf63ba308d8e1239f963f0deb6..596b34231cfb078cef8603a133527d86327feeb0 100644 (file)
@@ -19,6 +19,7 @@ static const char *_name = DM_NAME;
 static const char *_version = @DM_VERSION@;
 static const char *_email = "lvm-devel@lists.sistina.com";
 
+static int major = 0;
 static int _major = 0;
 
 struct io_hook {
@@ -45,6 +46,8 @@ static devfs_handle_t _dev_dir;
 static int request(request_queue_t *q, int rw, struct buffer_head *bh);
 static int dm_user_bmap(struct inode *inode, struct lv_bmap *lvb);
 
+static void __free_dev(struct mapped_device *md);
+
 /*
  * Shortcuts to lock/unlock the global _dev_lock
  */
@@ -81,6 +84,7 @@ static int __init local_init(void)
                                                 0, 0, NULL, NULL)))
                return -ENOMEM;
 
+       _major = major;
        r = devfs_register_blkdev(_major, _name, &dm_blk_dops);
        if (r < 0) {
                DMERR("register_blkdev failed");
@@ -118,6 +122,7 @@ static void local_exit(void)
        blk_size[_major] = NULL;
        blksize_size[_major] = NULL;
        hardsect_size[_major] = NULL;
+       _major = 0;
 
        DMINFO("%s cleaned up", _version);
 }
@@ -593,7 +598,7 @@ static struct mapped_device *alloc_dev(int minor)
        return md;
 }
 
-static void free_dev(struct mapped_device *md)
+static void __free_dev(struct mapped_device *md)
 {
        kfree(md);
 }
@@ -682,7 +687,7 @@ static struct mapped_device *__get_by_name(const char *name)
        return NULL;
 }
 
-static int check_name(const char *name)
+static int __check_name(const char *name)
 {
        if (strchr(name, '/')) {
                DMWARN("invalid device name");
@@ -709,12 +714,13 @@ int dm_create(const char *name, int minor, struct dm_table *table,
        if (minor >= MAX_DEVICES)
                return -ENXIO;
 
-       if (!(md = alloc_dev(minor)))
+       md = alloc_dev(minor);
+       if (!md)
                return -ENXIO;
 
        dm_lock_w();
 
-       if (check_name(name) < 0) {
+       if (__check_name(name) < 0) {
                r = -EINVAL;
                goto err;
        }
@@ -736,8 +742,8 @@ int dm_create(const char *name, int minor, struct dm_table *table,
        return 0;
 
       err:
+       __free_dev(md);
        dm_unlock_w();
-       free_dev(md);
        return r;
 }
 
@@ -754,17 +760,18 @@ int dm_destroy(struct mapped_device *md)
                dm_unlock_r();
                return -EPERM;
        }
+       dm_unlock_r();
 
        fsync_dev(md->dev);
-       dm_unlock_r();
 
        dm_lock_w();
-       if (md->use_count) {
+       if (md->suspended || md->use_count) {
                dm_unlock_w();
                return -EPERM;
        }
 
-       if ((r = unregister_device(md))) {
+       r = unregister_device(md);
+       if (r) {
                dm_unlock_w();
                return r;
        }
@@ -772,11 +779,10 @@ int dm_destroy(struct mapped_device *md)
        minor = MINOR(md->dev);
        _devs[minor] = 0;
        __unbind(md);
+       __free_dev(md);
 
        dm_unlock_w();
 
-       free_dev(md);
-
        return 0;
 }
 
@@ -827,7 +833,8 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *table)
 
        __unbind(md);
 
-       if ((r = __bind(md, table))) {
+       r = __bind(md, table);
+       if (r) {
                dm_unlock_w();
                return r;
        }
@@ -928,8 +935,8 @@ struct block_device_operations dm_blk_dops = {
 module_init(dm_init);
 module_exit(dm_exit);
 
-MODULE_PARM(_major, "i");
-MODULE_PARM_DESC(_major, "The major number of the device mapper");
+MODULE_PARM(major, "i");
+MODULE_PARM_DESC(major, "The major number of the device mapper");
 MODULE_DESCRIPTION(DM_NAME " driver");
 MODULE_AUTHOR("Joe Thornber <thornber@sistina.com>");
 MODULE_LICENSE("GPL");
index f47ceba2b5676b5f760dcedd7d3d335bfd08860d..e7acadbbf429df31bbe3d94d877551ab07d8761d 100644 (file)
@@ -135,7 +135,7 @@ int dm_resume(struct mapped_device *md);
 int dm_table_create(struct dm_table **result);
 void dm_table_destroy(struct dm_table *t);
 
-int dm_table_add_target(struct dm_table *t, offset_t high,
+int dm_table_add_target(struct dm_table *t, offset_t highs,
                        struct target_type *type, void *private);
 int dm_table_complete(struct dm_table *t);
 
index bf36245e609739bfefc747e63a781783c5f1a771..b623fa322d86cce958936f79c9b3d15d3b30edf7 100644 (file)
@@ -21,7 +21,7 @@ static int copy_params(struct dm_ioctl *user, struct dm_ioctl **result)
        if (copy_from_user(&tmp, user, sizeof(tmp)))
                return -EFAULT;
 
-       if (!(dmi = vmalloc(tmp.data_size)))
+       if (!(dmi = (struct dm_ioctl *) vmalloc(tmp.data_size)))
                return -ENOMEM;
 
        if (copy_from_user(dmi, user, tmp.data_size))
@@ -89,7 +89,7 @@ static int populate_table(struct dm_table *table, struct dm_ioctl *args)
        char *params, *argv[MAX_ARGS];
        struct target_type *ttype;
        void *context, *begin, *end;
-       offset_t high = 0;
+       offset_t highs = 0;
 
        if (!args->target_count) {
                DMWARN("populate_table: no targets specified");
@@ -129,8 +129,8 @@ static int populate_table(struct dm_table *table, struct dm_ioctl *args)
                }
 
                /* Add the target to the table */
-               high = spec->sector_start + (spec->length - 1);
-               if (dm_table_add_target(table, high, ttype, context))
+               highs = spec->sector_start + (spec->length - 1);
+               if (dm_table_add_target(table, highs, ttype, context))
                        PARSE_ERROR("internal error adding target to table");
 
                first = 0;
@@ -210,12 +210,14 @@ static int remove(struct dm_ioctl *param)
 
 static int suspend(struct dm_ioctl *param)
 {
+       int r;
        struct mapped_device *md = dm_get(param->name);
 
        if (!md)
                return -ENXIO;
 
-       return param->suspend ? dm_suspend(md) : dm_resume(md);
+       r = param->suspend ? dm_suspend(md) : dm_resume(md);
+       return r;
 }
 
 static int reload(struct dm_ioctl *param)
index e8f165ed72b440d0ce02631f5a2ea7c5b257e85f..ad005548b9cf35046c249b3c171b67c43c4887ce 100644 (file)
@@ -157,6 +157,8 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt)
        if (!(dmi = malloc(len)))
                return NULL;
 
+       memset(dmi, 0, len);
+
        strncpy(dmi->version, DM_IOCTL_VERSION, sizeof(dmi->version));
        dmi->data_size = len;
        strncpy(dmi->name, dmt->dev_name, sizeof(dmi->name));
This page took 0.031981 seconds and 5 git commands to generate.