Commit e4e4cd48 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix O_DIRECT oops

inode->i_sb->s_bdev is NULL when the inode refers to a blockdev.
Use the get_block() result instead.
parent 42ec8bc1
...@@ -2316,8 +2316,9 @@ int generic_direct_IO(int rw, struct inode *inode, ...@@ -2316,8 +2316,9 @@ int generic_direct_IO(int rw, struct inode *inode,
struct kiobuf *iobuf, unsigned long blocknr, struct kiobuf *iobuf, unsigned long blocknr,
int blocksize, get_block_t *get_block) int blocksize, get_block_t *get_block)
{ {
int i, nr_blocks, retval; int i, nr_blocks, retval = 0;
sector_t *blocks = iobuf->blocks; sector_t *blocks = iobuf->blocks;
struct block_device *bdev = NULL;
nr_blocks = iobuf->length / blocksize; nr_blocks = iobuf->length / blocksize;
/* build the blocklist */ /* build the blocklist */
...@@ -2347,11 +2348,12 @@ int generic_direct_IO(int rw, struct inode *inode, ...@@ -2347,11 +2348,12 @@ int generic_direct_IO(int rw, struct inode *inode,
BUG(); BUG();
} }
blocks[i] = bh.b_blocknr; blocks[i] = bh.b_blocknr;
bdev = bh.b_bdev;
} }
/* This does not understand multi-device filesystems currently */ /* This does not understand multi-device filesystems currently */
retval = brw_kiovec(rw, 1, &iobuf, if (bdev)
inode->i_sb->s_bdev, blocks, blocksize); retval = brw_kiovec(rw, 1, &iobuf, bdev, blocks, blocksize);
out: out:
return retval; return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment