public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@suse.de>
To: Jeff Garzik <jgarzik@mandrakesoft.com>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	Linux-Kernel list <linux-kernel@vger.kernel.org>
Subject: Re: PATCH 2.5.1.4: fix rd.c build
Date: Fri, 30 Nov 2001 08:18:04 +0100	[thread overview]
Message-ID: <20011130081804.D16796@suse.de> (raw)
In-Reply-To: <3C06DE6F.746DA60A@mandrakesoft.com>
In-Reply-To: <3C06DE6F.746DA60A@mandrakesoft.com>

On Thu, Nov 29 2001, Jeff Garzik wrote:
> ...just a missed s/bio_size/foo->bi_size/ conversion. please apply.
> -- 
> Jeff Garzik      | Only so many songs can be sung
> Building 1024    | with two lips, two lungs, and one tongue.
> MandrakeSoft     |         - nomeansno
> Index: drivers/block/rd.c
> ===================================================================
> RCS file: /cvsroot/gkernel/linux_2_5/drivers/block/rd.c,v
> retrieving revision 1.3
> diff -u -r1.3 rd.c
> --- drivers/block/rd.c	2001/11/30 01:10:57	1.3
> +++ drivers/block/rd.c	2001/11/30 01:17:24
> @@ -239,7 +239,7 @@
>  
>  	index = sbh->bi_sector >> (PAGE_CACHE_SHIFT - 9);
>  	offset = (sbh->bi_sector << 9) & ~PAGE_CACHE_MASK;
> -	size = bio_size(sbh);
> +	size = sbh->bi_size;
>  
>  	do {
>  		int count;
> @@ -323,7 +323,7 @@
>  		goto fail;
>  
>  	offset = sbh->bi_sector << 9;
> -	len = bio_size(sbh);
> +	len = sbh->bi_size;
>  
>  	if ((offset + len) > rd_length[minor])
>  		goto fail;

Actually, this is not even enough if rd receives a multi page bio.
Something like this should work, untested.

--- /opt/kernel/linux-2.5.1-pre4/drivers/block/rd.c	Fri Nov 30 01:59:45 2001
+++ linux/drivers/block/rd.c	Fri Nov 30 02:14:06 2001
@@ -228,7 +228,8 @@
 	commit_write: ramdisk_commit_write,
 };
 
-static int rd_blkdev_pagecache_IO(int rw, struct bio *sbh, int minor)
+static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec,
+				  sector_t sector, int minor)
 {
 	struct address_space * mapping;
 	unsigned long index;
@@ -237,9 +238,9 @@
 	err = -EIO;
 	mapping = rd_bdev[minor]->bd_inode->i_mapping;
 
-	index = sbh->bi_sector >> (PAGE_CACHE_SHIFT - 9);
-	offset = (sbh->bi_sector << 9) & ~PAGE_CACHE_MASK;
-	size = bio_size(sbh);
+	index = sector >> (PAGE_CACHE_SHIFT - 9);
+	offset = (sector << 9) & ~PAGE_CACHE_MASK;
+	size = vec->bv_len;
 
 	do {
 		int count;
@@ -276,18 +277,18 @@
 		if (rw == READ) {
 			src = kmap(page);
 			src += offset;
-			dst = bio_kmap(sbh);
+			dst = kmap(vec->bv_page) + vec->bv_offset;
 		} else {
 			dst = kmap(page);
 			dst += offset;
-			src = bio_kmap(sbh);
+			src = kmap(vec->bv_page) + vec->bv_offset;
 		}
 		offset = 0;
 
 		memcpy(dst, src, count);
 
 		kunmap(page);
-		bio_kunmap(sbh);
+		kunmap(vec->bv_page);
 
 		if (rw == READ) {
 			flush_dcache_page(page);
@@ -303,6 +304,22 @@
 	return err;
 }
 
+static int rd_blkdev_bio_IO(struct bio *bio, unsigned int minor)
+{
+	struct bio_vec *bvec;
+	sector_t sector;
+	int ret = 0, i, rw;
+
+	sector = bio->bi_sector;
+	rw = bio_data_dir(bio);
+	bio_for_each_segment(bvec, bio, i) {
+		ret |= rd_blkdev_pagecache_IO(rw, bvec, sector, minor);
+		sector += bvec->bv_len >> 9;
+	}
+
+	return ret;
+}
+
 /*
  *  Basically, my strategy here is to set up a buffer-head which can't be
  *  deleted, and make that my Ramdisk.  If the request is outside of the
@@ -323,7 +340,7 @@
 		goto fail;
 
 	offset = sbh->bi_sector << 9;
-	len = bio_size(sbh);
+	len = sbh->bi_size;
 
 	if ((offset + len) > rd_length[minor])
 		goto fail;
@@ -335,7 +352,7 @@
 		goto fail;
 	}
 
-	if (rd_blkdev_pagecache_IO(rw, sbh, minor))
+	if (rd_blkdev_bio_IO(sbh, minor))
 		goto fail;
 
 	set_bit(BIO_UPTODATE, &sbh->bi_flags);
@@ -437,10 +454,11 @@
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	if (unit == INITRD_MINOR) {
-		if (!initrd_start) return -ENODEV;
-		spin_lock( &initrd_users_lock );
+		spin_lock(&initrd_users_lock);
 		initrd_users++;
-		spin_unlock( &initrd_users_lock );
+		spin_unlock(&initrd_users_lock);
+		if (!initrd_start) 
+			return -ENODEV;
 		filp->f_op = &initrd_fops;
 		return 0;
 	}

-- 
Jens Axboe


  reply	other threads:[~2001-11-30  7:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-30  1:18 PATCH 2.5.1.4: fix rd.c build Jeff Garzik
2001-11-30  7:18 ` Jens Axboe [this message]
2001-11-30  7:24   ` Alexander Viro
2001-11-30  7:28     ` Jens Axboe
2001-11-30  7:37       ` Alexander Viro
2001-11-30  7:44         ` Jens Axboe

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=20011130081804.D16796@suse.de \
    --to=axboe@suse.de \
    --cc=jgarzik@mandrakesoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox