Skip to contentSkip to conversation

lguest: the block driver

PATCH In review [email protected] 4 participants 7 messages May 9, 2007 – May 11, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 8/9 lguest: the block driver

From: Rusty Russell <[email protected]>

Lguest block driver

A simple block driver for lguest.

---

 drivers/block/Makefile     |    1 
 drivers/block/lguest_blk.c |  271 +++++++++++++++++++++++++++++++++++
 2 files changed, 272 insertions(+)
drivers/block/Makefile renamed from drivers/block/Makefile~lguest-the-block-driver +1 -0
diff -puN drivers/block/Makefile~lguest-the-block-driver drivers/block/Makefile
@@ -28,4 +28,5 @@ obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryp
 obj-$(CONFIG_VIODASD)		+= viodasd.o
 obj-$(CONFIG_BLK_DEV_SX8)	+= sx8.o
 obj-$(CONFIG_BLK_DEV_UB)	+= ub.o
+obj-$(CONFIG_LGUEST_GUEST)	+= lguest_blk.o
 
drivers/block/lguest_blk.c new file +271 -0

271 lines not on this page · raw message

_

#1 lore raw

drivers/block/lguest_blk.c line 56

Quoted 9 lines · On 5/9/07, [email protected] <[email protected]> wrote:
drivers/block/lguest_blk.c new file +9 -0
+/* Jens gave me this nice helper to end all chunks of a request. */
+static void end_entire_request(struct request *req, int uptodate)
+{
+       if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
+               BUG();
+       add_disk_randomness(req->rq_disk);
+       blkdev_dequeue_request(req);
+       end_that_request_last(req, uptodate);
+}

Again, I would prefer this went straight into block/ll_rw_blk.c. Rene and I am using something similar in the new Mitsumi driver although one of us has a bug already, we're using req->nr_sectors for this...

#2 lore raw
Quoted 14 lines · Pekka Enberg

drivers/block/lguest_blk.c line 56

Quoted 9 lines · On 5/9/07, [email protected] <[email protected]> wrote:
drivers/block/lguest_blk.c new file +9 -0
+/* Jens gave me this nice helper to end all chunks of a request. */
+static void end_entire_request(struct request *req, int uptodate)
+{
+       if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
+               BUG();
+       add_disk_randomness(req->rq_disk);
+       blkdev_dequeue_request(req);
+       end_that_request_last(req, uptodate);
+}

Again, I would prefer this went straight into block/ll_rw_blk.c. Rene and I am using something similar in the new Mitsumi driver although one of us has a bug already, we're using req->nr_sectors for this...

Lets do it after it is merged, as not to create a hold-up point for lguest. Once it's in, I'll fix it up.

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 2 lines · Jens Axboe

Lets do it after it is merged, as not to create a hold-up point for lguest. Once it's in, I'll fix it up.

Ok. Seems pointless, though, as it's only a matter of:

Pekka

From: Jens Axboe <[email protected]>

Add a new end_entire_request() function that ends the whole request, not just the first segment.

---
 block/ll_rw_blk.c      |   11 +++++++++++
 include/linux/blkdev.h |    1 +
 2 files changed, 12 insertions(+)
block/ll_rw_blk.c +11 -0
Index: 2.6/block/ll_rw_blk.c
===================================================================
@@ -3606,6 +3606,17 @@ void end_request(struct request *req, in
 
 EXPORT_SYMBOL(end_request);
 
+void end_entire_request(struct request *req, int uptodate)
+{
+	if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
+		BUG();
+	add_disk_randomness(req->rq_disk);
+	blkdev_dequeue_request(req);
+	end_that_request_last(req, uptodate);
+}
+
+EXPORT_SYMBOL(end_entire_request);
+
 void blk_rq_bio_prep(request_queue_t *q, struct request *rq, struct bio *bio)
 {
 	/* first two bits are identical in rq->cmd_flags and bio->bi_rw */
include/linux/blkdev.h +1 -0
Index: 2.6/include/linux/blkdev.h
===================================================================
@@ -712,6 +712,7 @@ extern int end_that_request_first(struct
 extern int end_that_request_chunk(struct request *, int, int);
 extern void end_that_request_last(struct request *, int);
 extern void end_request(struct request *req, int uptodate);
+extern void end_entire_request(struct request *req, int uptodate);
 extern void blk_complete_request(struct request *);
 
 /*
#4 lore raw
Quoted 5 lines · Pekka J Enberg
Quoted 2 lines · Jens Axboe

Lets do it after it is merged, as not to create a hold-up point for lguest. Once it's in, I'll fix it up.

Ok. Seems pointless, though, as it's only a matter of:

Yes I'm very well aware of that, my point is just that I'll do it once lguest is merged since then

a) it has a user, and
b) I don't want lguest to wait for me to get that update pulled

Can we please let this rest?

Signature · 1 line
Jens Axboe
#5 lore raw
In reply to Pekka Enberg
Quoted 4 lines · Pekka Enberg
Quoted 4 lines
drivers/block/lguest_blk.c new file +4 -0
+static void end_entire_request(struct request *req, int uptodate)
+{
+       if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
+               BUG();
Quoted 8 lines

drivers/block/lguest_blk.c line 56

Quoted 4 lines
drivers/block/lguest_blk.c new file +4 -0
+       add_disk_randomness(req->rq_disk);
+       blkdev_dequeue_request(req);
+       end_that_request_last(req, uptodate);
+}

Again, I would prefer this went straight into block/ll_rw_blk.c. Rene and I am using something similar in the new Mitsumi driver although one of us has a bug already, we're using req->nr_sectors for this...

The req->hard_nr_sectors is specifically marked block layer internal and since nr_sectors is what we're requesting and reading (we can't deal with partial transfers anyway since the drive won't tell us where it failed as far as I've been able to see and we do want to make read requests for as many sectors as possible at a time for speed) I believe that in our case the nr_sectors is fine.

Rene.

#6 lore raw
Quoted 15 lines · Rene Herman
Quoted 4 lines · Pekka Enberg
Quoted 4 lines
drivers/block/lguest_blk.c new file +4 -0
+static void end_entire_request(struct request *req, int uptodate)
+{
+       if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
+               BUG();
Quoted 8 lines

drivers/block/lguest_blk.c line 56

Quoted 4 lines
drivers/block/lguest_blk.c new file +4 -0
+       add_disk_randomness(req->rq_disk);
+       blkdev_dequeue_request(req);
+       end_that_request_last(req, uptodate);
+}

Again, I would prefer this went straight into block/ll_rw_blk.c. Rene and I am using something similar in the new Mitsumi driver although one of us has a bug already, we're using req->nr_sectors for this...

Quoted 6 lines

The req->hard_nr_sectors is specifically marked block layer internal and since nr_sectors is what we're requesting and reading (we can't deal with partial transfers anyway since the drive won't tell us where it failed as far as I've been able to see and we do want to make read requests for as many sectors as possible at a time for speed) I believe that in our case the nr_sectors is fine.

Using ->nr_sectors is fine, IFF you don't modify ->nr_sectors in the driver. The generic helper will use ->hard_nr_sectors.

Signature · 1 line
Jens Axboe