Merge branches 'release', 'asus', 'sony-laptop' and 'thinkpad' into release
[pandora-kernel.git] / arch / um / drivers / ubd_kern.c
index 3a8cd3d..be3a279 100644 (file)
@@ -35,6 +35,7 @@
 #include "linux/genhd.h"
 #include "linux/spinlock.h"
 #include "linux/platform_device.h"
+#include "linux/scatterlist.h"
 #include "asm/segment.h"
 #include "asm/uaccess.h"
 #include "asm/irq.h"
@@ -48,6 +49,7 @@
 #include "irq_user.h"
 #include "irq_kern.h"
 #include "ubd_user.h"
+#include "kern_util.h"
 #include "os.h"
 #include "mem.h"
 #include "mem_kern.h"
@@ -228,7 +230,7 @@ static int proc_ide_read_media(char *page, char **start, off_t off, int count,
        return len;
 }
 
-static void make_ide_entries(char *dev_name)
+static void make_ide_entries(const char *dev_name)
 {
        struct proc_dir_entry *dir, *ent;
        char name[64];
@@ -243,7 +245,7 @@ static void make_ide_entries(char *dev_name)
        ent->data = NULL;
        ent->read_proc = proc_ide_read_media;
        ent->write_proc = NULL;
-       sprintf(name,"ide0/%s", dev_name);
+       snprintf(name, sizeof(name), "ide0/%s", dev_name);
        proc_symlink(dev_name, proc_ide_root, name);
 }
 
@@ -436,7 +438,10 @@ __uml_help(ubd_setup,
 "    machine by running 'dd' on the device. <n> must be in the range\n"
 "    0 to 7. Appending an 'r' to the number will cause that device\n"
 "    to be mounted read-only. For example ubd1r=./ext_fs. Appending\n"
-"    an 's' will cause data to be written to disk on the host immediately.\n\n"
+"    an 's' will cause data to be written to disk on the host immediately.\n"
+"    'c' will cause the device to be treated as being shared between multiple\n"
+"    UMLs and file locking will be turned off - this is appropriate for a\n"
+"    cluster filesystem and inappropriate at almost all other times.\n\n"
 );
 
 static int udb_setup(char *str)
@@ -455,36 +460,14 @@ __uml_help(udb_setup,
 "    in the boot output.\n\n"
 );
 
-static int fakehd_set = 0;
-static int fakehd(char *str)
-{
-       printk(KERN_INFO "fakehd : Changing ubd name to \"hd\".\n");
-       fakehd_set = 1;
-       return 1;
-}
-
-__setup("fakehd", fakehd);
-__uml_help(fakehd,
-"fakehd\n"
-"    Change the ubd device name to \"hd\".\n\n"
-);
-
 static void do_ubd_request(struct request_queue * q);
 
 /* Only changed by ubd_init, which is an initcall. */
 int thread_fd = -1;
 
-static void ubd_end_request(struct request *req, int bytes, int uptodate)
+static void ubd_end_request(struct request *req, int bytes, int error)
 {
-       if (!end_that_request_first(req, uptodate, bytes >> 9)) {
-               struct ubd *dev = req->rq_disk->private_data;
-               unsigned long flags;
-
-               add_disk_randomness(req->rq_disk);
-               spin_lock_irqsave(&dev->lock, flags);
-               end_that_request_last(req, uptodate);
-               spin_unlock_irqrestore(&dev->lock, flags);
-       }
+       blk_end_request(req, error, bytes);
 }
 
 /* Callable only from interrupt context - otherwise you need to do
@@ -492,10 +475,10 @@ static void ubd_end_request(struct request *req, int bytes, int uptodate)
 static inline void ubd_finish(struct request *req, int bytes)
 {
        if(bytes < 0){
-               ubd_end_request(req, 0, 0);
+               ubd_end_request(req, 0, -EIO);
                return;
        }
-       ubd_end_request(req, bytes, 1);
+       ubd_end_request(req, bytes, 0);
 }
 
 static LIST_HEAD(restart);
@@ -704,6 +687,7 @@ static int ubd_add(int n, char **error_out)
        ubd_dev->size = ROUND_BLOCK(ubd_dev->size);
 
        INIT_LIST_HEAD(&ubd_dev->restart);
+       sg_init_table(ubd_dev->sg, MAX_SG);
 
        err = -ENOMEM;
        ubd_dev->queue = blk_init_queue(do_ubd_request, &ubd_dev->lock);
@@ -724,8 +708,10 @@ static int ubd_add(int n, char **error_out)
                ubd_disk_register(fake_major, ubd_dev->size, n,
                                  &fake_gendisk[n]);
 
-       /* perhaps this should also be under the "if (fake_major)" above */
-       /* using the fake_disk->disk_name and also the fakehd_set name */
+       /*
+        * Perhaps this should also be under the "if (fake_major)" above
+        * using the fake_disk->disk_name
+        */
        if (fake_ide)
                make_ide_entries(ubd_gendisk[n]->disk_name);
 
@@ -1126,6 +1112,7 @@ static void do_ubd_request(struct request_queue *q)
                                               "errno = %d\n", -n);
                                else if(list_empty(&dev->restart))
                                        list_add(&dev->restart, &restart);
+                               kfree(io_req);
                                return;
                        }