[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4CAD7D98.7080808@fusionio.com>
Date: Thu, 07 Oct 2010 09:58:16 +0200
From: Jens Axboe <jaxboe@...ionio.com>
To: Chris Frey <cdfrey@...rsquare.net>
CC: Tejun Heo <htejun@...il.com>, Richard Weinberger <richard@....at>,
Andrew Morton <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"jdike@...toit.com" <jdike@...toit.com>,
"user-mode-linux-devel@...ts.sourceforge.net"
<user-mode-linux-devel@...ts.sourceforge.net>,
"user-mode-linux-user@...ts.sourceforge.net"
<user-mode-linux-user@...ts.sourceforge.net>,
"janjaap@....nl" <janjaap@....nl>,
"geert@...ux-m68k.org" <geert@...ux-m68k.org>,
"martin.petersen@...cle.com" <martin.petersen@...cle.com>,
"adobriyan@...il.com" <adobriyan@...il.com>,
"syzop@...nscan.org" <syzop@...nscan.org>
Subject: Re: [PATCH 1/1] um: ubd: Fix data corruption
On 2010-10-05 22:31, Chris Frey wrote:
> On Tue, Oct 05, 2010 at 10:23:19AM +0200, Tejun Heo wrote:
>> Hmmmm, can you please give a shot at the following one? Thank you.
>
> I applied this patch on top of stock 2.6.35.5 as usual (no other patches)
> and tested on my maverick image as before. I ran a fsck.ext3 on the
> filesystem image from the host before my test, just to make sure, and
> there were no errors.
>
> Unfortunately, this patch does not fix the issue either. I get errors
> in the guest like the following:
So how about this? Note that I haven't even compiled this. The request
handling logic really should be fixed in there, it's horribly
inefficient.
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 1bcd208..c272cf6 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -163,6 +163,7 @@ struct ubd {
struct scatterlist sg[MAX_SG];
struct request *request;
int start_sg, end_sg;
+ unsigned int rq_offset;
};
#define DEFAULT_COW { \
@@ -187,6 +188,7 @@ struct ubd {
.request = NULL, \
.start_sg = 0, \
.end_sg = 0, \
+ .rq_offset 0, \
}
/* Protected by ubd_lock */
@@ -466,6 +468,8 @@ static void ubd_handler(void)
int n;
while(1){
+ struct ubd *dev;
+
n = os_read_file(thread_fd, &req,
sizeof(struct io_thread_req *));
if(n != sizeof(req)){
@@ -476,6 +480,11 @@ static void ubd_handler(void)
return;
}
+ /*
+ * Clear internal offset, block core will update request state
+ */
+ dev = req->req->q->queuedata;
+ dev->rq_offset = 0;
blk_end_request(req->req, 0, req->length);
kfree(req);
}
@@ -1241,10 +1250,11 @@ static void do_ubd_request(struct request_queue *q)
dev->request = req;
dev->start_sg = 0;
dev->end_sg = blk_rq_map_sg(q, req, dev->sg);
+ dev->rq_offset = 0;
}
req = dev->request;
- sector = blk_rq_pos(req);
+ sector = blk_rq_pos(req) + dev->rq_offset;
while(dev->start_sg < dev->end_sg){
struct scatterlist *sg = &dev->sg[dev->start_sg];
@@ -1272,6 +1282,7 @@ static void do_ubd_request(struct request_queue *q)
return;
}
+ dev->rq_offset += sg->length >> 9;
dev->start_sg++;
}
dev->end_sg = 0;
--
Jens Axboe
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists