summaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2007-02-07 00:30:38 +0000
committerSteve French <sfrench@us.ibm.com>2007-02-07 00:30:38 +0000
commit1d9564ea0ac72ef7c4068d66fe42ad23af4ff53f (patch)
treefa63b4c1bbd775252f71d05fef4de6a904eb4448 /fs/block_dev.c
parent87f440e70e07dace7db130f2f9fcea3f132aad8f (diff)
parentdda2ac15d23b38e4335e858848aa8c9a6710304f (diff)
downloadlinux-1d9564ea0ac72ef7c4068d66fe42ad23af4ff53f.tar.gz
linux-1d9564ea0ac72ef7c4068d66fe42ad23af4ff53f.tar.bz2
linux-1d9564ea0ac72ef7c4068d66fe42ad23af4ff53f.zip
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index d9bdf2b3ade2..fc7028b685f2 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -129,6 +129,46 @@ blkdev_get_block(struct inode *inode, sector_t iblock,
return 0;
}
+static int
+blkdev_get_blocks(struct inode *inode, sector_t iblock,
+ struct buffer_head *bh, int create)
+{
+ sector_t end_block = max_block(I_BDEV(inode));
+ unsigned long max_blocks = bh->b_size >> inode->i_blkbits;
+
+ if ((iblock + max_blocks) > end_block) {
+ max_blocks = end_block - iblock;
+ if ((long)max_blocks <= 0) {
+ if (create)
+ return -EIO; /* write fully beyond EOF */
+ /*
+ * It is a read which is fully beyond EOF. We return
+ * a !buffer_mapped buffer
+ */
+ max_blocks = 0;
+ }
+ }
+
+ bh->b_bdev = I_BDEV(inode);
+ bh->b_blocknr = iblock;
+ bh->b_size = max_blocks << inode->i_blkbits;
+ if (max_blocks)
+ set_buffer_mapped(bh);
+ return 0;
+}
+
+static ssize_t
+blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
+ loff_t offset, unsigned long nr_segs)
+{
+ struct file *file = iocb->ki_filp;
+ struct inode *inode = file->f_mapping->host;
+
+ return blockdev_direct_IO_no_locking(rw, iocb, inode, I_BDEV(inode),
+ iov, offset, nr_segs, blkdev_get_blocks, NULL);
+}
+
+#if 0
static int blk_end_aio(struct bio *bio, unsigned int bytes_done, int error)
{
struct kiocb *iocb = bio->bi_private;
@@ -323,6 +363,7 @@ backout:
return PTR_ERR(page);
goto completion;
}
+#endif
static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
{