All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Osterlund <petero2@telia.com>
To: Jens Axboe <axboe@suse.de>
Cc: arjanv@redhat.com, Andrew Morton <akpm@osdl.org>,
	packet-writing@suse.com, linux-kernel@vger.kernel.org
Subject: Re: ext2 on a CD-RW
Date: 02 Jan 2004 17:12:43 +0100	[thread overview]
Message-ID: <m2n09672is.fsf@telia.com> (raw)
In-Reply-To: <20040102105915.GO5523@suse.de>

Jens Axboe <axboe@suse.de> writes:

> On Fri, Jan 02 2004, Peter Osterlund wrote:
> > 
> > Old versions of the packet writing code did just that, but Jens told
> > me that bio splitting was evil, so when the merge_bvec_fn
> > functionality was added to the kernel, I started to use it.
> > 
> >         http://lists.suse.com/archive/packet-writing/2002-Aug/0044.html
> 
> Splitting is evil, but unfortunately it's a necessary evil... There are
> a few kernel helpers to make supporting it easier (see bio_split()). Not
> so sure how well that'll work for you, you may have to do the grunt work
> yourself.

It seems like bio_split() does exactly what I need. The patch below
makes 2kb blocksize ext2 work and also fixes the performance problem
compared to 4kb blocksize ext2. Thanks to everyone involved for their
help.

--- linux/drivers/block/pktcdvd.c.old	2004-01-02 16:58:52.000000000 +0100
+++ linux/drivers/block/pktcdvd.c	2004-01-02 16:59:26.000000000 +0100
@@ -2083,11 +2083,23 @@
 		(unsigned long long)bio->bi_sector,
 		(unsigned long long)(bio->bi_sector + bio_sectors(bio)));
 
-	/* Some debug code to make sure the merge_bvec_fn function is working. */
+	/* Check if we have to split the bio */
 	{
+		struct bio_pair *bp;
 		sector_t last_zone;
+		int first_sectors;
+
 		last_zone = ZONE(bio->bi_sector + bio_sectors(bio) - 1, pd);
-		BUG_ON(last_zone != zone);
+		if (last_zone != zone) {
+			BUG_ON(last_zone != zone + pd->settings.size);
+			first_sectors = last_zone - bio->bi_sector;
+			bp = bio_split(bio, bio_split_pool, first_sectors);
+			BUG_ON(!bp);
+			pkt_make_request(q, &bp->bio1);
+			pkt_make_request(q, &bp->bio2);
+			bio_pair_release(bp);
+			return 0;
+		}
 	}
 
 	/*
@@ -2153,6 +2165,15 @@
 	sector_t zone = ZONE(bio->bi_sector, pd);
 	int used = ((bio->bi_sector - zone) << 9) + bio->bi_size;
 	int remaining = (pd->settings.size << 9) - used;
+	int remaining2;
+
+	/*
+	 * A bio <= PAGE_SIZE must be allowed. If it crosses a packet
+	 * boundary, pkt_make_request() will split the bio.
+	 */
+	remaining2 = PAGE_SIZE - bio->bi_size;
+	remaining = max_t(int, remaining, remaining2);
+
 	BUG_ON(remaining < 0);
 	return remaining;
 }

-- 
Peter Osterlund - petero2@telia.com
http://w1.894.telia.com/~u89404340

  parent reply	other threads:[~2004-01-02 16:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-01 23:47 ext2 on a CD-RW Peter Osterlund
2004-01-02  0:24 ` Andrew Morton
2004-01-02  1:30   ` Peter Osterlund
2004-01-02  9:06     ` Arjan van de Ven
2004-01-02 10:09       ` Jens Axboe
2004-01-02 10:51       ` Peter Osterlund
2004-01-02 10:59         ` Jens Axboe
2004-01-02 12:09           ` Peter Osterlund
2004-01-02 12:19             ` Jens Axboe
2004-01-02 13:38               ` Peter Osterlund
2004-01-02 13:59                 ` Jens Axboe
2004-01-02 16:12           ` Peter Osterlund [this message]
2004-03-29 15:38           ` Peter Osterlund
2004-01-02 10:08     ` Jens Axboe
2004-01-03 19:14 ` Pavel Machek
2004-01-03 20:32   ` Peter Osterlund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2n09672is.fsf@telia.com \
    --to=petero2@telia.com \
    --cc=akpm@osdl.org \
    --cc=arjanv@redhat.com \
    --cc=axboe@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=packet-writing@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.