Commit 2a9529a0 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: fix I/O hang when multiple devices are in use

Commit 62f96cb0 introduced per-devices
queues and locks, which was fine as far as it went, but left in place a
global which controlled access to submitting requests to the host.  This
should have been made per-device as well, since it causes I/O hangs when
multiple block devices are in use.

This patch fixes that by replacing the global with an activity flag in the
device structure in order to tell whether the queue is currently being run.
Signed-off-by: default avatarJeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent cb3fecc2
...@@ -109,10 +109,6 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data) ...@@ -109,10 +109,6 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
static DEFINE_MUTEX(ubd_lock); static DEFINE_MUTEX(ubd_lock);
/* XXX - this made sense in 2.4 days, now it's only used as a boolean, and
* probably it doesn't make sense even for that. */
static int do_ubd;
static int ubd_open(struct inode * inode, struct file * filp); static int ubd_open(struct inode * inode, struct file * filp);
static int ubd_release(struct inode * inode, struct file * file); static int ubd_release(struct inode * inode, struct file * file);
static int ubd_ioctl(struct inode * inode, struct file * file, static int ubd_ioctl(struct inode * inode, struct file * file,
...@@ -169,6 +165,7 @@ struct ubd { ...@@ -169,6 +165,7 @@ struct ubd {
struct platform_device pdev; struct platform_device pdev;
struct request_queue *queue; struct request_queue *queue;
spinlock_t lock; spinlock_t lock;
int active;
}; };
#define DEFAULT_COW { \ #define DEFAULT_COW { \
...@@ -190,6 +187,7 @@ struct ubd { ...@@ -190,6 +187,7 @@ struct ubd {
.shared = 0, \ .shared = 0, \
.cow = DEFAULT_COW, \ .cow = DEFAULT_COW, \
.lock = SPIN_LOCK_UNLOCKED, \ .lock = SPIN_LOCK_UNLOCKED, \
.active = 0, \
} }
/* Protected by ubd_lock */ /* Protected by ubd_lock */
...@@ -507,7 +505,6 @@ static void ubd_handler(void) ...@@ -507,7 +505,6 @@ static void ubd_handler(void)
struct ubd *dev; struct ubd *dev;
int n; int n;
do_ubd = 0;
n = os_read_file(thread_fd, &req, sizeof(req)); n = os_read_file(thread_fd, &req, sizeof(req));
if(n != sizeof(req)){ if(n != sizeof(req)){
printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, " printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
...@@ -517,6 +514,7 @@ static void ubd_handler(void) ...@@ -517,6 +514,7 @@ static void ubd_handler(void)
rq = req.req; rq = req.req;
dev = rq->rq_disk->private_data; dev = rq->rq_disk->private_data;
dev->active = 0;
ubd_finish(rq, req.error); ubd_finish(rq, req.error);
reactivate_fd(thread_fd, UBD_IRQ); reactivate_fd(thread_fd, UBD_IRQ);
...@@ -1081,11 +1079,12 @@ static void do_ubd_request(request_queue_t *q) ...@@ -1081,11 +1079,12 @@ static void do_ubd_request(request_queue_t *q)
} }
} }
else { else {
if(do_ubd || (req = elv_next_request(q)) == NULL) struct ubd *dev = q->queuedata;
if(dev->active || (req = elv_next_request(q)) == NULL)
return; return;
err = prepare_request(req, &io_req); err = prepare_request(req, &io_req);
if(!err){ if(!err){
do_ubd = 1; dev->active = 1;
n = os_write_file(thread_fd, (char *) &io_req, n = os_write_file(thread_fd, (char *) &io_req,
sizeof(io_req)); sizeof(io_req));
if(n != sizeof(io_req)) if(n != sizeof(io_req))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment