Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 46059
b: refs/heads/master
c: b2e895d
h: refs/heads/master
i:
  46057: 4118afd
  46055: ec70903
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Feb 3, 2007
1 parent b564cf6 commit 0deb254
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8560a10e16faccafdc2e26c4873bf4edfbbf651e
refs/heads/master: b2e895dbd80c420bfc0937c3729b4afe073b3848
41 changes: 41 additions & 0 deletions trunk/fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -323,6 +363,7 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
return PTR_ERR(page);
goto completion;
}
#endif

static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
{
Expand Down

0 comments on commit 0deb254

Please sign in to comment.