PATCH 2.5.1.4: fix rd.c build
...just a missed s/bio_size/foo->bi_size/ conversion. please apply.
Signature · 3 lines
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
block/rd.c +2 -2
@@ -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;
Quoted 22 lines · Jeff Garzik
...just a missed s/bio_size/foo->bi_size/ conversion. please apply.
Signature · 8 lines
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.cblock/rd.c +1
-1@@ -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;
block/rd.c line 329
Quoted 8 lines
block/rd.c +1
-1@@ -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.
drivers/block/rd.c renamed from opt/kernel/linux-2.5.1-pre4/drivers/block/rd.c +30 -12
@@ -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 ; }
Signature · 1 line
Jens Axboe
drivers/block/rd.c line 238
Quoted 5 lines · Jens Axboe
Actually, this is not even enough if rd receives a multi page bio. Something like this should work, untested.
drivers/block/rd.c renamed from opt/kernel/linux-2.5.1-pre4/drivers/block/rd.c +0
-0@@ -237,9 +238,9 @@ err = -EIO ;
Make it err = 0...
Another thing being, if you remove explicit call of rd_init() from ll_rw_blk.c making module_init() unconditional looks like a good idea...
Quoted 11 lines · Alexander Viro
drivers/block/rd.c line 238
Quoted 5 lines · Jens Axboe
Actually, this is not even enough if rd receives a multi page bio. Something like this should work, untested.
drivers/block/rd.c renamed from opt/kernel/linux-2.5.1-pre4/drivers/block/rd.c +0
-0@@ -237,9 +238,9 @@ err = -EIO ;Make it err = 0...
Explain
Quoted 3 lines
Another thing being, if you remove explicit call of
rd_init()fromll_rw_blk.cmakingmodule_init()unconditional looks like a good idea...
Indeed, done.
Signature · 1 line
Jens Axboe
Quoted 8 lines · Jens Axboe
Quoted 7 lines · Alexander Viro
Quoted 3 lines · Jens Axboe
Actually, this is not even enough if rd receives a multi page bio. Something like this should work, untested.
Quoted 6 lines
Quoted 4 lines
drivers/block/rd.c line 238
Quoted 2 lines
drivers/block/rd.c renamed from opt/kernel/linux-2.5.1-pre4/drivers/block/rd.c +0
-0@@ -237,9 +238,9 @@ err = -EIO ;Make it err = 0...
Explain
Think what happens if you have all these pages in page cache. Already. Returning -EIO is hardly a good idea in that case. Look through the loop - we assign err in the body only if we have to allocate a new page.
Notice that any bh brings the page in. I.e. for smaller-than-page ones you are going to have a lot of fun...
Quoted 1 line
From -pre2:
@@ -227,19 +227,18 @@
commit_write: ramdisk_commit_write,
};
-static int rd_blkdev_pagecache_IO(int rw, struct buffer_head * sbh, int minor) +static int rd_blkdev_pagecache_IO(int rw, struct bio *sbh, int minor)
{
struct address_space * mapping;
unsigned long index;
int offset, size, err;
err = -EIO;
- err = 0;
mapping = rd_bdev[minor]->bd_inode->i_mapping;Sure, one of these assignments had to go away. You'd picked the wrong one, though...
Quoted 17 lines · Alexander Viro
Quoted 13 lines · Jens Axboe
Quoted 11 lines · Alexander Viro
drivers/block/rd.c line 238
Quoted 5 lines · Jens Axboe
Actually, this is not even enough if rd receives a multi page bio. Something like this should work, untested.
drivers/block/rd.c renamed from opt/kernel/linux-2.5.1-pre4/drivers/block/rd.c +0
-0@@ -237,9 +238,9 @@ err = -EIO ;Make it err = 0...
Quoted 6 lines
Quoted 1 line
Explain
Think what happens if you have all these pages in page cache. Already. Returning
-EIOis hardly a good idea in that case. Look through the loop - we assign err in the body only if we have to allocate a new page.
Ah ok.
Quoted 11 lines
(quoted diff) +1
-2-static int rd_blkdev_pagecache_IO(int rw, struct buffer_head * sbh, int minor) +static int rd_blkdev_pagecache_IO(int rw, struct bio *sbh, int minor) { struct address_space * mapping; unsigned long index; int offset, size, err; err = -EIO; - err = 0; mapping = rd_bdev[minor]->bd_inode->i_mapping;
Quoted 2 lines
Sure, one of these assignments had to go away. You'd picked the wrong one, though...
Duh, merge error, don't even remembering making that change. Ok
kernel.org/pub/linux/kernel/people/axboe/patches/v2.5/2.5.1-pre4/bio-pre4-2
should be ok.
Signature · 1 line
Jens Axboe