Skip to content

Commit

Permalink
pass iov_iter to ->direct_IO()
Browse files Browse the repository at this point in the history
unmodified, for now

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed May 6, 2014
1 parent cb66a7a commit d8d3d94
Show file tree
Hide file tree
Showing 30 changed files with 117 additions and 126 deletions.
3 changes: 1 addition & 2 deletions Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ prototypes:
void (*invalidatepage) (struct page *, unsigned int, unsigned int);
int (*releasepage) (struct page *, int);
void (*freepage)(struct page *);
int (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
loff_t offset, unsigned long nr_segs);
int (*direct_IO)(int, struct kiocb *, struct iov_iter *iter, loff_t offset);
int (*get_xip_mem)(struct address_space *, pgoff_t, int, void **,
unsigned long *);
int (*migratepage)(struct address_space *, struct page *, struct page *);
Expand Down
3 changes: 1 addition & 2 deletions Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,7 @@ struct address_space_operations {
void (*invalidatepage) (struct page *, unsigned int, unsigned int);
int (*releasepage) (struct page *, int);
void (*freepage)(struct page *);
ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
loff_t offset, unsigned long nr_segs);
ssize_t (*direct_IO)(int, struct kiocb *, struct iov_iter *iter, loff_t offset);
struct page* (*get_xip_page)(struct address_space *, sector_t,
int);
/* migrate the contents of a page to the specified target */
Expand Down
17 changes: 8 additions & 9 deletions drivers/staging/lustre/lustre/llite/rw26.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,14 @@ static ssize_t ll_direct_IO_26_seg(const struct lu_env *env, struct cl_io *io,
#define MAX_DIO_SIZE ((MAX_MALLOC / sizeof(struct brw_page) * PAGE_CACHE_SIZE) & \
~(DT_MAX_BRW_SIZE - 1))
static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
const struct iovec *iov, loff_t file_offset,
unsigned long nr_segs)
struct iov_iter *iter, loff_t file_offset)
{
struct lu_env *env;
struct cl_io *io;
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;
struct ccc_object *obj = cl_inode2ccc(inode);
long count = iov_length(iov, nr_segs);
long count = iov_length(iter->iov, iter->nr_segs);
long tot_bytes = 0, result = 0;
struct ll_inode_info *lli = ll_i2info(inode);
unsigned long seg = 0;
Expand All @@ -392,9 +391,9 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
MAX_DIO_SIZE >> PAGE_CACHE_SHIFT);

/* Check that all user buffers are aligned as well */
for (seg = 0; seg < nr_segs; seg++) {
if (((unsigned long)iov[seg].iov_base & ~CFS_PAGE_MASK) ||
(iov[seg].iov_len & ~CFS_PAGE_MASK))
for (seg = 0; seg < iter->nr_segs; seg++) {
if (((unsigned long)iter->iov[seg].iov_base & ~CFS_PAGE_MASK) ||
(iter->iov[seg].iov_len & ~CFS_PAGE_MASK))
return -EINVAL;
}

Expand All @@ -411,9 +410,9 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
mutex_lock(&inode->i_mutex);

LASSERT(obj->cob_transient_pages == 0);
for (seg = 0; seg < nr_segs; seg++) {
long iov_left = iov[seg].iov_len;
unsigned long user_addr = (unsigned long)iov[seg].iov_base;
for (seg = 0; seg < iter->nr_segs; seg++) {
long iov_left = iter->iov[seg].iov_len;
unsigned long user_addr = (unsigned long)iter->iov[seg].iov_base;

if (rw == READ) {
if (file_offset >= i_size_read(inode))
Expand Down
5 changes: 2 additions & 3 deletions fs/9p/vfs_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ static int v9fs_launder_page(struct page *page)
*
*/
static ssize_t
v9fs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t pos, unsigned long nr_segs)
v9fs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
{
/*
* FIXME
Expand All @@ -269,7 +268,7 @@ v9fs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
*/
p9_debug(P9_DEBUG_VFS, "v9fs_direct_IO: v9fs_direct_IO (%s) off/no(%lld/%lu) EINVAL\n",
iocb->ki_filp->f_path.dentry->d_name.name,
(long long)pos, nr_segs);
(long long)pos, iter->nr_segs);

return -EINVAL;
}
Expand Down
9 changes: 5 additions & 4 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,15 @@ blkdev_get_block(struct inode *inode, sector_t iblock,
}

static ssize_t
blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t offset, unsigned long nr_segs)
blkdev_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
loff_t offset)
{
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;

return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset,
nr_segs, blkdev_get_block, NULL, NULL, 0);
return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iter->iov,
offset, iter->nr_segs, blkdev_get_block,
NULL, NULL, 0);
}

int __sync_blockdev(struct block_device *bdev, int wait)
Expand Down
12 changes: 6 additions & 6 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -7433,8 +7433,7 @@ static ssize_t check_direct_IO(struct btrfs_root *root, int rw, struct kiocb *io
}

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;
Expand All @@ -7444,8 +7443,8 @@ 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->iov,
offset, iter->nr_segs))
return 0;

atomic_inc(&inode->i_dio_count);
Expand All @@ -7457,7 +7456,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_length(iter->iov, iter->nr_segs);
if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
&BTRFS_I(inode)->runtime_flags))
filemap_fdatawrite_range(inode->i_mapping, offset, count);
Expand All @@ -7484,7 +7483,8 @@ 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->iov, offset, iter->nr_segs,
btrfs_get_blocks_direct, NULL,
btrfs_submit_direct, flags);
if (rw & WRITE) {
if (ret < 0 && ret != -EIOCBQUEUED)
Expand Down
4 changes: 2 additions & 2 deletions fs/ceph/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,8 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
* never get called.
*/
static ssize_t ceph_direct_io(int rw, struct kiocb *iocb,
const struct iovec *iov,
loff_t pos, unsigned long nr_segs)
struct iov_iter *iter,
loff_t pos)
{
WARN_ON(1);
return -EINVAL;
Expand Down
4 changes: 2 additions & 2 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3702,8 +3702,8 @@ void cifs_oplock_break(struct work_struct *work)
* Direct IO is not yet supported in the cached mode.
*/
static ssize_t
cifs_direct_io(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t pos, unsigned long nr_segs)
cifs_direct_io(int rw, struct kiocb *iocb, struct iov_iter *iter,
loff_t pos)
{
/*
* FIXME
Expand Down
2 changes: 1 addition & 1 deletion fs/exofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ static void exofs_invalidatepage(struct page *page, unsigned int offset,

/* TODO: Should be easy enough to do proprly */
static ssize_t exofs_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)
{
return 0;
}
Expand Down
11 changes: 6 additions & 5 deletions fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,18 +850,19 @@ static sector_t ext2_bmap(struct address_space *mapping, sector_t block)
}

static ssize_t
ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t offset, unsigned long nr_segs)
ext2_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
loff_t offset)
{
struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host;
ssize_t ret;

ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
ext2_get_block);
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
iter->nr_segs, ext2_get_block);
if (ret < 0 && (rw & WRITE))
ext2_write_failed(mapping, offset + iov_length(iov, nr_segs));
ext2_write_failed(mapping, offset +
iov_length(iter->iov, iter->nr_segs));
return ret;
}

Expand Down
16 changes: 7 additions & 9 deletions fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1820,19 +1820,18 @@ static int ext3_releasepage(struct page *page, gfp_t wait)
* VFS code falls back into buffered path in that case so we are safe.
*/
static ssize_t ext3_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;
struct ext3_inode_info *ei = EXT3_I(inode);
handle_t *handle;
ssize_t ret;
int orphan = 0;
size_t count = iov_length(iov, nr_segs);
size_t count = iov_length(iter->iov, iter->nr_segs);
int retries = 0;

trace_ext3_direct_IO_enter(inode, offset, iov_length(iov, nr_segs), rw);
trace_ext3_direct_IO_enter(inode, offset, count, rw);

if (rw == WRITE) {
loff_t final_size = offset + count;
Expand All @@ -1856,15 +1855,15 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
}

retry:
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
ext3_get_block);
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
iter->nr_segs, ext3_get_block);
/*
* In case of error extending write may have instantiated a few
* blocks outside i_size. Trim these off again.
*/
if (unlikely((rw & WRITE) && ret < 0)) {
loff_t isize = i_size_read(inode);
loff_t end = offset + iov_length(iov, nr_segs);
loff_t end = offset + count;

if (end > isize)
ext3_truncate_failed_direct_write(inode);
Expand Down Expand Up @@ -1909,8 +1908,7 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
ret = err;
}
out:
trace_ext3_direct_IO_exit(inode, offset,
iov_length(iov, nr_segs), rw, ret);
trace_ext3_direct_IO_exit(inode, offset, count, rw, ret);
return ret;
}

Expand Down
11 changes: 5 additions & 6 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3222,8 +3222,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
}

static ssize_t ext4_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;
Expand All @@ -3239,13 +3238,13 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
if (ext4_has_inline_data(inode))
return 0;

trace_ext4_direct_IO_enter(inode, offset, iov_length(iov, nr_segs), rw);
trace_ext4_direct_IO_enter(inode, offset, iov_length(iter->iov, iter->nr_segs), rw);
if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
ret = ext4_ext_direct_IO(rw, iocb, iov, offset, nr_segs);
ret = ext4_ext_direct_IO(rw, iocb, iter->iov, offset, iter->nr_segs);
else
ret = ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs);
ret = ext4_ind_direct_IO(rw, iocb, iter->iov, offset, iter->nr_segs);
trace_ext4_direct_IO_exit(inode, offset,
iov_length(iov, nr_segs), rw, ret);
iov_length(iter->iov, iter->nr_segs), rw, ret);
return ret;
}

Expand Down
8 changes: 4 additions & 4 deletions fs/f2fs/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ static int check_direct_IO(struct inode *inode, int rw,
}

static ssize_t f2fs_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;
Expand All @@ -1019,11 +1019,11 @@ static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb,
if (f2fs_has_inline_data(inode))
return 0;

if (check_direct_IO(inode, rw, iov, offset, nr_segs))
if (check_direct_IO(inode, rw, iter->iov, offset, iter->nr_segs))
return 0;

return blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
get_data_block);
return blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
iter->nr_segs, get_data_block);
}

static void f2fs_invalidate_data_page(struct page *page, unsigned int offset,
Expand Down
13 changes: 7 additions & 6 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ static int fat_write_end(struct file *file, struct address_space *mapping,
}

static ssize_t fat_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 address_space *mapping = file->f_mapping;
Expand All @@ -203,7 +203,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
*
* Return 0, and fallback to normal buffered write.
*/
loff_t size = offset + iov_length(iov, nr_segs);
loff_t size = offset + iov_length(iter->iov, iter->nr_segs);
if (MSDOS_I(inode)->mmu_private < size)
return 0;
}
Expand All @@ -212,10 +212,11 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
* FAT need to use the DIO_LOCKING for avoiding the race
* condition of fat_get_block() and ->truncate().
*/
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
fat_get_block);
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
iter->nr_segs, fat_get_block);
if (ret < 0 && (rw & WRITE))
fat_write_failed(mapping, offset + iov_length(iov, nr_segs));
fat_write_failed(mapping, offset +
iov_length(iter->iov, iter->nr_segs));

return ret;
}
Expand Down
10 changes: 5 additions & 5 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2890,8 +2890,8 @@ static inline loff_t fuse_round_up(loff_t off)
}

static ssize_t
fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t offset, unsigned long nr_segs)
fuse_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
loff_t offset)
{
ssize_t ret = 0;
struct file *file = iocb->ki_filp;
Expand All @@ -2900,7 +2900,7 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t pos = 0;
struct inode *inode;
loff_t i_size;
size_t count = iov_length(iov, nr_segs);
size_t count = iov_length(iter->iov, iter->nr_segs);
struct fuse_io_priv *io;

pos = offset;
Expand Down Expand Up @@ -2944,9 +2944,9 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
io->async = false;

if (rw == WRITE)
ret = __fuse_direct_write(io, iov, nr_segs, &pos);
ret = __fuse_direct_write(io, iter->iov, iter->nr_segs, &pos);
else
ret = __fuse_direct_read(io, iov, nr_segs, &pos, count);
ret = __fuse_direct_read(io, iter->iov, iter->nr_segs, &pos, count);

if (io->async) {
fuse_aio_complete(io, ret < 0 ? ret : 0, -1);
Expand Down
Loading

0 comments on commit d8d3d94

Please sign in to comment.