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() ...
This commit is contained in:
@@ -7445,39 +7445,30 @@ free_ordered:
|
||||
}
|
||||
|
||||
static ssize_t check_direct_IO(struct btrfs_root *root, int rw, struct kiocb *iocb,
|
||||
const struct iovec *iov, loff_t offset,
|
||||
unsigned long nr_segs)
|
||||
const struct iov_iter *iter, loff_t offset)
|
||||
{
|
||||
int seg;
|
||||
int i;
|
||||
size_t size;
|
||||
unsigned long addr;
|
||||
unsigned blocksize_mask = root->sectorsize - 1;
|
||||
ssize_t retval = -EINVAL;
|
||||
loff_t end = offset;
|
||||
|
||||
if (offset & blocksize_mask)
|
||||
goto out;
|
||||
|
||||
/* Check the memory alignment. Blocks cannot straddle pages */
|
||||
for (seg = 0; seg < nr_segs; seg++) {
|
||||
addr = (unsigned long)iov[seg].iov_base;
|
||||
size = iov[seg].iov_len;
|
||||
end += size;
|
||||
if ((addr & blocksize_mask) || (size & blocksize_mask))
|
||||
goto out;
|
||||
if (iov_iter_alignment(iter) & blocksize_mask)
|
||||
goto out;
|
||||
|
||||
/* If this is a write we don't need to check anymore */
|
||||
if (rw & WRITE)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Check to make sure we don't have duplicate iov_base's in this
|
||||
* iovec, if so return EINVAL, otherwise we'll get csum errors
|
||||
* when reading back.
|
||||
*/
|
||||
for (i = seg + 1; i < nr_segs; i++) {
|
||||
if (iov[seg].iov_base == iov[i].iov_base)
|
||||
/* If this is a write we don't need to check anymore */
|
||||
if (rw & WRITE)
|
||||
return 0;
|
||||
/*
|
||||
* Check to make sure we don't have duplicate iov_base's in this
|
||||
* iovec, if so return EINVAL, otherwise we'll get csum errors
|
||||
* when reading back.
|
||||
*/
|
||||
for (seg = 0; seg < iter->nr_segs; seg++) {
|
||||
for (i = seg + 1; i < iter->nr_segs; i++) {
|
||||
if (iter->iov[seg].iov_base == iter->iov[i].iov_base)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -7487,8 +7478,7 @@ out:
|
||||
}
|
||||
|
||||
static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
|
||||
const struct iovec *iov, loff_t offset,
|
||||
unsigned long nr_segs)
|
||||
struct iov_iter *iter, loff_t offset)
|
||||
{
|
||||
struct file *file = iocb->ki_filp;
|
||||
struct inode *inode = file->f_mapping->host;
|
||||
@@ -7498,8 +7488,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
|
||||
bool relock = false;
|
||||
ssize_t ret;
|
||||
|
||||
if (check_direct_IO(BTRFS_I(inode)->root, rw, iocb, iov,
|
||||
offset, nr_segs))
|
||||
if (check_direct_IO(BTRFS_I(inode)->root, rw, iocb, iter, offset))
|
||||
return 0;
|
||||
|
||||
atomic_inc(&inode->i_dio_count);
|
||||
@@ -7511,7 +7500,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
|
||||
* we need to flush the dirty pages again to make absolutely sure
|
||||
* that any outstanding dirty pages are on disk.
|
||||
*/
|
||||
count = iov_length(iov, nr_segs);
|
||||
count = iov_iter_count(iter);
|
||||
if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
|
||||
&BTRFS_I(inode)->runtime_flags))
|
||||
filemap_fdatawrite_range(inode->i_mapping, offset, count);
|
||||
@@ -7538,7 +7527,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
|
||||
|
||||
ret = __blockdev_direct_IO(rw, iocb, inode,
|
||||
BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev,
|
||||
iov, offset, nr_segs, btrfs_get_blocks_direct, NULL,
|
||||
iter, offset, btrfs_get_blocks_direct, NULL,
|
||||
btrfs_submit_direct, flags);
|
||||
if (rw & WRITE) {
|
||||
if (ret < 0 && ret != -EIOCBQUEUED)
|
||||
|
Reference in New Issue
Block a user