[patch] fix O_DIRECT oops

Andrew Morton (akpm@zip.com.au)
Sun, 07 Jul 2002 16:10:53 -0700


inode->i_sb->s_bdev is NULL when the inode refers to a blockdev.
Use the get_block() result instead.

buffer.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)

--- 2.5.25/fs/buffer.c~direct_io-fix Sun Jul 7 04:00:23 2002
+++ 2.5.25-akpm/fs/buffer.c Sun Jul 7 04:01:38 2002
@@ -2302,8 +2302,9 @@ int generic_direct_IO(int rw, struct ino
struct kiobuf *iobuf, unsigned long blocknr,
int blocksize, get_block_t *get_block)
{
- int i, nr_blocks, retval;
+ int i, nr_blocks, retval = 0;
sector_t *blocks = iobuf->blocks;
+ struct block_device *bdev = NULL;

nr_blocks = iobuf->length / blocksize;
/* build the blocklist */
@@ -2333,11 +2334,12 @@ int generic_direct_IO(int rw, struct ino
BUG();
}
blocks[i] = bh.b_blocknr;
+ bdev = bh.b_bdev;
}

/* This does not understand multi-device filesystems currently */
- retval = brw_kiovec(rw, 1, &iobuf,
- inode->i_sb->s_bdev, blocks, blocksize);
+ if (bdev)
+ retval = brw_kiovec(rw, 1, &iobuf, bdev, blocks, blocksize);

out:
return retval;

-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/