diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2009-05-07 09:37:36 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-05-11 08:13:10 -0400 |
commit | 6818173bd658439b83896a2a7586f64ab51bf29c (patch) | |
tree | 17d25ee77485af18da1a80cb7f1d8ec581c6abfc /drivers/block | |
parent | 7c77f0b3f9208c339a4b40737bb2cb0f0319bb8d (diff) |
splice: implement default splice_read method
If f_op->splice_read() is not implemented, fall back to a plain read.
Use vfs_readv() to read into previously allocated pages.
This will allow splice and functions using splice, such as the loop
device, to work on all filesystems. This includes "direct_io" files
in fuse which bypass the page cache.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/loop.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 9ca4bb014657..801f4ab83302 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -709,10 +709,6 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, | |||
709 | if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode)) | 709 | if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode)) |
710 | goto out_putf; | 710 | goto out_putf; |
711 | 711 | ||
712 | /* new backing store needs to support loop (eg splice_read) */ | ||
713 | if (!inode->i_fop->splice_read) | ||
714 | goto out_putf; | ||
715 | |||
716 | /* size of the new backing store needs to be the same */ | 712 | /* size of the new backing store needs to be the same */ |
717 | if (get_loop_size(lo, file) != get_loop_size(lo, old_file)) | 713 | if (get_loop_size(lo, file) != get_loop_size(lo, old_file)) |
718 | goto out_putf; | 714 | goto out_putf; |
@@ -788,12 +784,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode, | |||
788 | error = -EINVAL; | 784 | error = -EINVAL; |
789 | if (S_ISREG(inode->i_mode) || S_ISBLK(inode->i_mode)) { | 785 | if (S_ISREG(inode->i_mode) || S_ISBLK(inode->i_mode)) { |
790 | const struct address_space_operations *aops = mapping->a_ops; | 786 | const struct address_space_operations *aops = mapping->a_ops; |
791 | /* | 787 | |
792 | * If we can't read - sorry. If we only can't write - well, | ||
793 | * it's going to be read-only. | ||
794 | */ | ||
795 | if (!file->f_op->splice_read) | ||
796 | goto out_putf; | ||
797 | if (aops->write_begin) | 788 | if (aops->write_begin) |
798 | lo_flags |= LO_FLAGS_USE_AOPS; | 789 | lo_flags |= LO_FLAGS_USE_AOPS; |
799 | if (!(lo_flags & LO_FLAGS_USE_AOPS) && !file->f_op->write) | 790 | if (!(lo_flags & LO_FLAGS_USE_AOPS) && !file->f_op->write) |