aboutsummaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-12 13:30:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-12 13:30:18 -0400
commit16b9057804c02e2d351e9c8f606e909b43cbd9e7 (patch)
treea3ac6e1d9d57a8abf4267e5ead3f2de1309335eb /fs/block_dev.c
parent5c02c392cd2320e8d612376d6b72b6548a680923 (diff)
parentc2338f2dc7c1e9f6202f370c64ffd7f44f3d4b51 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: "This the bunch that sat in -next + lock_parent() fix. This is the minimal set; there's more pending stuff. In particular, I really hope to get acct.c fixes merged this cycle - we need that to deal sanely with delayed-mntput stuff. In the next pile, hopefully - that series is fairly short and localized (kernel/acct.c, fs/super.c and fs/namespace.c). In this pile: more iov_iter work. Most of prereqs for ->splice_write with sane locking order are there and Kent's dio rewrite would also fit nicely on top of this pile" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (70 commits) lock_parent: don't step on stale ->d_parent of all-but-freed one kill generic_file_splice_write() ceph: switch to iter_file_splice_write() shmem: switch to iter_file_splice_write() nfs: switch to iter_splice_write_file() fs/splice.c: remove unneeded exports ocfs2: switch to iter_file_splice_write() ->splice_write() via ->write_iter() bio_vec-backed iov_iter optimize copy_page_{to,from}_iter() bury generic_file_aio_{read,write} lustre: get rid of messing with iovecs ceph: switch to ->write_iter() ceph_sync_direct_write: stop poking into iov_iter guts ceph_sync_read: stop poking into iov_iter guts new helper: copy_page_from_iter() fuse: switch to ->write_iter() btrfs: switch to ->write_iter() ocfs2: switch to ->write_iter() xfs: switch to ->write_iter() ...
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 83fba15cc394..6d7274619bf9 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -165,14 +165,15 @@ blkdev_get_block(struct inode *inode, sector_t iblock,
165} 165}
166 166
167static ssize_t 167static ssize_t
168blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, 168blkdev_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
169 loff_t offset, unsigned long nr_segs) 169 loff_t offset)
170{ 170{
171 struct file *file = iocb->ki_filp; 171 struct file *file = iocb->ki_filp;
172 struct inode *inode = file->f_mapping->host; 172 struct inode *inode = file->f_mapping->host;
173 173
174 return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset, 174 return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iter,
175 nr_segs, blkdev_get_block, NULL, NULL, 0); 175 offset, blkdev_get_block,
176 NULL, NULL, 0);
176} 177}
177 178
178int __sync_blockdev(struct block_device *bdev, int wait) 179int __sync_blockdev(struct block_device *bdev, int wait)
@@ -1571,43 +1572,38 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
1571 * Does not take i_mutex for the write and thus is not for general purpose 1572 * Does not take i_mutex for the write and thus is not for general purpose
1572 * use. 1573 * use.
1573 */ 1574 */
1574ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, 1575ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
1575 unsigned long nr_segs, loff_t pos)
1576{ 1576{
1577 struct file *file = iocb->ki_filp; 1577 struct file *file = iocb->ki_filp;
1578 struct blk_plug plug; 1578 struct blk_plug plug;
1579 ssize_t ret; 1579 ssize_t ret;
1580 1580
1581 BUG_ON(iocb->ki_pos != pos);
1582
1583 blk_start_plug(&plug); 1581 blk_start_plug(&plug);
1584 ret = __generic_file_aio_write(iocb, iov, nr_segs); 1582 ret = __generic_file_write_iter(iocb, from);
1585 if (ret > 0) { 1583 if (ret > 0) {
1586 ssize_t err; 1584 ssize_t err;
1587 1585 err = generic_write_sync(file, iocb->ki_pos - ret, ret);
1588 err = generic_write_sync(file, pos, ret);
1589 if (err < 0) 1586 if (err < 0)
1590 ret = err; 1587 ret = err;
1591 } 1588 }
1592 blk_finish_plug(&plug); 1589 blk_finish_plug(&plug);
1593 return ret; 1590 return ret;
1594} 1591}
1595EXPORT_SYMBOL_GPL(blkdev_aio_write); 1592EXPORT_SYMBOL_GPL(blkdev_write_iter);
1596 1593
1597static ssize_t blkdev_aio_read(struct kiocb *iocb, const struct iovec *iov, 1594static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
1598 unsigned long nr_segs, loff_t pos)
1599{ 1595{
1600 struct file *file = iocb->ki_filp; 1596 struct file *file = iocb->ki_filp;
1601 struct inode *bd_inode = file->f_mapping->host; 1597 struct inode *bd_inode = file->f_mapping->host;
1602 loff_t size = i_size_read(bd_inode); 1598 loff_t size = i_size_read(bd_inode);
1599 loff_t pos = iocb->ki_pos;
1603 1600
1604 if (pos >= size) 1601 if (pos >= size)
1605 return 0; 1602 return 0;
1606 1603
1607 size -= pos; 1604 size -= pos;
1608 if (size < iocb->ki_nbytes) 1605 iov_iter_truncate(to, size);
1609 nr_segs = iov_shorten((struct iovec *)iov, nr_segs, size); 1606 return generic_file_read_iter(iocb, to);
1610 return generic_file_aio_read(iocb, iov, nr_segs, pos);
1611} 1607}
1612 1608
1613/* 1609/*
@@ -1639,10 +1635,10 @@ const struct file_operations def_blk_fops = {
1639 .open = blkdev_open, 1635 .open = blkdev_open,
1640 .release = blkdev_close, 1636 .release = blkdev_close,
1641 .llseek = block_llseek, 1637 .llseek = block_llseek,
1642 .read = do_sync_read, 1638 .read = new_sync_read,
1643 .write = do_sync_write, 1639 .write = new_sync_write,
1644 .aio_read = blkdev_aio_read, 1640 .read_iter = blkdev_read_iter,
1645 .aio_write = blkdev_aio_write, 1641 .write_iter = blkdev_write_iter,
1646 .mmap = generic_file_mmap, 1642 .mmap = generic_file_mmap,
1647 .fsync = blkdev_fsync, 1643 .fsync = blkdev_fsync,
1648 .unlocked_ioctl = block_ioctl, 1644 .unlocked_ioctl = block_ioctl,
@@ -1650,7 +1646,7 @@ const struct file_operations def_blk_fops = {
1650 .compat_ioctl = compat_blkdev_ioctl, 1646 .compat_ioctl = compat_blkdev_ioctl,
1651#endif 1647#endif
1652 .splice_read = generic_file_splice_read, 1648 .splice_read = generic_file_splice_read,
1653 .splice_write = generic_file_splice_write, 1649 .splice_write = iter_file_splice_write,
1654}; 1650};
1655 1651
1656int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg) 1652int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg)