Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / block / vroot.c
index 4587cbf..9ef8302 100644 (file)
@@ -12,7 +12,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/file.h>
@@ -21,6 +20,7 @@
 #include <linux/devfs_fs_kernel.h>
 
 #include <linux/vroot.h>
+#include <linux/vserver/debug.h>
 
 
 static int max_vroot = 8;
@@ -60,9 +60,9 @@ static int vroot_set_dev(
        } else
                goto out_fput;
 
-       printk(KERN_INFO "vroot[%d]_set_dev: dev=%p[%d,%d]\n",
-               vr->vr_number, real_bdev,
-               imajor(real_bdev->bd_inode), iminor(real_bdev->bd_inode));
+       vxdprintk(VXD_CBIT(misc, 0),
+               "vroot[%d]_set_dev: dev=" VXF_DEV,
+               vr->vr_number, VXD_DEV(real_bdev));
 
        vr->vr_state = Vr_bound;
        error = 0;
@@ -87,9 +87,9 @@ static int vroot_clr_dev(
 
        real_bdev = vr->vr_device;
 
-       printk(KERN_INFO "vroot[%d]_clr_dev: dev=%p[%d,%d]\n",
-               vr->vr_number, real_bdev,
-               imajor(real_bdev->bd_inode), iminor(real_bdev->bd_inode));
+       vxdprintk(VXD_CBIT(misc, 0),
+               "vroot[%d]_clr_dev: dev=" VXF_DEV,
+               vr->vr_number, VXD_DEV(real_bdev));
 
        bdput(real_bdev);
        vr->vr_state = Vr_unbound;
@@ -147,7 +147,7 @@ static struct block_device_operations vr_fops = {
        .ioctl =        vr_ioctl,
 };
 
-struct block_device *vroot_get_real_bdev(struct block_device *bdev)
+struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
 {
        struct inode *inode = bdev->bd_inode;
        struct vroot_device *vr;
@@ -157,9 +157,9 @@ struct block_device *vroot_get_real_bdev(struct block_device *bdev)
        vr = &vroot_dev[minor];
        real_bdev = vr->vr_device;
 
-       printk(KERN_INFO "vroot[%d]_get_real_bdev: dev=%p[%p,%d,%d]\n",
-               vr->vr_number, real_bdev, real_bdev->bd_inode,
-               imajor(real_bdev->bd_inode), iminor(real_bdev->bd_inode));
+       vxdprintk(VXD_CBIT(misc, 0),
+               "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
+               vr->vr_number, VXD_DEV(real_bdev));
 
        if (vr->vr_state != Vr_bound)
                return ERR_PTR(-ENXIO);
@@ -184,7 +184,7 @@ MODULE_DESCRIPTION ("Virtual Root Device Mapper");
 
 int __init vroot_init(void)
 {
-       int     i;
+       int err, i;
 
        if (max_vroot < 1 || max_vroot > 256) {
                max_vroot = MAX_VROOT_DEFAULT;
@@ -196,6 +196,7 @@ int __init vroot_init(void)
        if (register_blkdev(VROOT_MAJOR, "vroot"))
                return -EIO;
 
+       err = -ENOMEM;
        vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
        if (!vroot_dev)
                goto out_mem1;
@@ -228,11 +229,17 @@ int __init vroot_init(void)
                disk->private_data = vr;
        }
 
+       err = register_vroot_grb(&__vroot_get_real_bdev);
+       if (err)
+               goto out_reg;
+
        for (i = 0; i < max_vroot; i++)
                add_disk(disks[i]);
        printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
        return 0;
 
+out_reg:
+       devfs_remove("vroot");
 out_mem3:
        while (i--)
                put_disk(disks[i]);
@@ -242,13 +249,16 @@ out_mem2:
 out_mem1:
        unregister_blkdev(VROOT_MAJOR, "vroot");
        printk(KERN_ERR "vroot: ran out of memory\n");
-       return -ENOMEM;
+       return err;
 }
 
 void vroot_exit(void)
 {
        int i;
 
+       if (unregister_vroot_grb(&__vroot_get_real_bdev))
+               printk(KERN_WARNING "vroot: cannot unregister grb\n");
+
        for (i = 0; i < max_vroot; i++) {
                del_gendisk(disks[i]);
                put_disk(disks[i]);
@@ -264,3 +274,15 @@ void vroot_exit(void)
 module_init(vroot_init);
 module_exit(vroot_exit);
 
+#ifndef MODULE
+
+static int __init max_vroot_setup(char *str)
+{
+       max_vroot = simple_strtol(str, NULL, 0);
+       return 1;
+}
+
+__setup("max_vroot=", max_vroot_setup);
+
+#endif
+