Skip to content

Commit

Permalink
Merge branch 'work.preadv2' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/viro/vfs

Pull vfs cleanups from Al Viro:
 "More cleanups from Christoph"

* 'work.preadv2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  nfsd: use RWF_SYNC
  fs: add RWF_DSYNC aand RWF_SYNC
  ceph: use generic_write_sync
  fs: simplify the generic_write_sync prototype
  fs: add IOCB_SYNC and IOCB_DSYNC
  direct-io: remove the offset argument to dio_complete
  direct-io: eliminate the offset argument to ->direct_IO
  xfs: eliminate the pos variable in xfs_file_dio_aio_write
  filemap: remove the pos argument to generic_file_direct_write
  filemap: remove pos variables in generic_file_read_iter
  • Loading branch information
torvalds committed May 17, 2016
2 parents c52b761 + 24368aa commit c2e7b20
Show file tree
Hide file tree
Showing 46 changed files with 200 additions and 224 deletions.
2 changes: 1 addition & 1 deletion Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ prototypes:
void (*invalidatepage) (struct page *, unsigned int, unsigned int);
int (*releasepage) (struct page *, int);
void (*freepage)(struct page *);
int (*direct_IO)(struct kiocb *, struct iov_iter *iter, loff_t offset);
int (*direct_IO)(struct kiocb *, struct iov_iter *iter);
int (*migratepage)(struct address_space *, struct page *, struct page *);
int (*launder_page)(struct page *);
int (*is_partially_uptodate)(struct page *, unsigned long, unsigned long);
Expand Down
2 changes: 1 addition & 1 deletion Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,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)(struct kiocb *, struct iov_iter *iter, loff_t offset);
ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter);
/* migrate the contents of a page to the specified target */
int (*migratepage) (struct page *, struct page *);
int (*launder_page) (struct page *);
Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/lustre/lustre/llite/rw26.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,14 @@ static ssize_t ll_direct_IO_26_seg(const struct lu_env *env, struct cl_io *io,
*/
#define MAX_DIO_SIZE ((KMALLOC_MAX_SIZE / sizeof(struct brw_page) * \
PAGE_SIZE) & ~(DT_MAX_BRW_SIZE - 1))
static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter,
loff_t file_offset)
static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter)
{
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);
loff_t file_offset = iocb->ki_pos;
ssize_t count = iov_iter_count(iter);
ssize_t tot_bytes = 0, result = 0;
struct ll_inode_info *lli = ll_i2info(inode);
Expand Down
3 changes: 2 additions & 1 deletion fs/9p/vfs_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,10 @@ static int v9fs_launder_page(struct page *page)
*
*/
static ssize_t
v9fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
v9fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
{
struct file *file = iocb->ki_filp;
loff_t pos = iocb->ki_pos;
ssize_t n;
int err = 0;
if (iov_iter_rw(iter) == WRITE) {
Expand Down
5 changes: 3 additions & 2 deletions fs/affs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,13 @@ static void affs_write_failed(struct address_space *mapping, loff_t to)
}

static ssize_t
affs_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
affs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
{
struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host;
size_t count = iov_iter_count(iter);
loff_t offset = iocb->ki_pos;
ssize_t ret;

if (iov_iter_rw(iter) == WRITE) {
Expand All @@ -404,7 +405,7 @@ affs_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
return 0;
}

ret = blockdev_direct_IO(iocb, inode, iter, offset, affs_get_block);
ret = blockdev_direct_IO(iocb, inode, iter, affs_get_block);
if (ret < 0 && iov_iter_rw(iter) == WRITE)
affs_write_failed(mapping, offset + count);
return ret;
Expand Down
14 changes: 5 additions & 9 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ static struct inode *bdev_file_inode(struct file *file)
}

static ssize_t
blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
{
struct file *file = iocb->ki_filp;
struct inode *inode = bdev_file_inode(file);

if (IS_DAX(inode))
return dax_do_io(iocb, inode, iter, offset, blkdev_get_block,
return dax_do_io(iocb, inode, iter, blkdev_get_block,
NULL, DIO_SKIP_DIO_COUNT);
return __blockdev_direct_IO(iocb, inode, I_BDEV(inode), iter, offset,
return __blockdev_direct_IO(iocb, inode, I_BDEV(inode), iter,
blkdev_get_block, NULL, NULL,
DIO_SKIP_DIO_COUNT);
}
Expand Down Expand Up @@ -1660,12 +1660,8 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)

blk_start_plug(&plug);
ret = __generic_file_write_iter(iocb, from);
if (ret > 0) {
ssize_t err;
err = generic_write_sync(file, iocb->ki_pos - ret, ret);
if (err < 0)
ret = err;
}
if (ret > 0)
ret = generic_write_sync(iocb, ret);
blk_finish_plug(&plug);
return ret;
}
Expand Down
16 changes: 6 additions & 10 deletions fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1703,18 +1703,17 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
return num_written ? num_written : ret;
}

static ssize_t __btrfs_direct_write(struct kiocb *iocb,
struct iov_iter *from,
loff_t pos)
static ssize_t __btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
{
struct file *file = iocb->ki_filp;
struct inode *inode = file_inode(file);
loff_t pos = iocb->ki_pos;
ssize_t written;
ssize_t written_buffered;
loff_t endbyte;
int err;

written = generic_file_direct_write(iocb, from, pos);
written = generic_file_direct_write(iocb, from);

if (written < 0 || !iov_iter_count(from))
return written;
Expand Down Expand Up @@ -1832,7 +1831,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
atomic_inc(&BTRFS_I(inode)->sync_writers);

if (iocb->ki_flags & IOCB_DIRECT) {
num_written = __btrfs_direct_write(iocb, from, pos);
num_written = __btrfs_direct_write(iocb, from);
} else {
num_written = __btrfs_buffered_write(file, from, pos);
if (num_written > 0)
Expand All @@ -1852,11 +1851,8 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
spin_lock(&BTRFS_I(inode)->lock);
BTRFS_I(inode)->last_sub_trans = root->log_transid;
spin_unlock(&BTRFS_I(inode)->lock);
if (num_written > 0) {
err = generic_write_sync(file, pos, num_written);
if (err < 0)
num_written = err;
}
if (num_written > 0)
num_written = generic_write_sync(iocb, num_written);

if (sync)
atomic_dec(&BTRFS_I(inode)->sync_writers);
Expand Down
6 changes: 3 additions & 3 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -8541,13 +8541,13 @@ static ssize_t check_direct_IO(struct btrfs_root *root, struct kiocb *iocb,
return retval;
}

static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
loff_t offset)
static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
{
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_dio_data dio_data = { 0 };
loff_t offset = iocb->ki_pos;
size_t count = 0;
int flags = 0;
bool wakeup = true;
Expand Down Expand Up @@ -8607,7 +8607,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter,

ret = __blockdev_direct_IO(iocb, inode,
BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev,
iter, offset, btrfs_get_blocks_direct, NULL,
iter, btrfs_get_blocks_direct, NULL,
btrfs_submit_direct, flags);
if (iov_iter_rw(iter) == WRITE) {
current->journal_info = NULL;
Expand Down
3 changes: 1 addition & 2 deletions fs/ceph/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,8 +1292,7 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
* intercept O_DIRECT reads and writes early, this function should
* never get called.
*/
static ssize_t ceph_direct_io(struct kiocb *iocb, struct iov_iter *iter,
loff_t pos)
static ssize_t ceph_direct_io(struct kiocb *iocb, struct iov_iter *iter)
{
WARN_ON(1);
return -EINVAL;
Expand Down
11 changes: 5 additions & 6 deletions fs/ceph/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1382,12 +1382,11 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
ceph_cap_string(got));
ceph_put_cap_refs(ci, got);

if (written >= 0 &&
((file->f_flags & O_SYNC) || IS_SYNC(file->f_mapping->host) ||
ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_NEARFULL))) {
err = vfs_fsync_range(file, pos, pos + written - 1, 1);
if (err < 0)
written = err;
if (written >= 0) {
if (ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_NEARFULL))
iocb->ki_flags |= IOCB_DSYNC;

written = generic_write_sync(iocb, written);
}

goto out_unlocked;
Expand Down
9 changes: 3 additions & 6 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2687,11 +2687,8 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
out:
inode_unlock(inode);

if (rc > 0) {
ssize_t err = generic_write_sync(file, iocb->ki_pos - rc, rc);
if (err < 0)
rc = err;
}
if (rc > 0)
rc = generic_write_sync(iocb, rc);
up_read(&cinode->lock_sem);
return rc;
}
Expand Down Expand Up @@ -3854,7 +3851,7 @@ void cifs_oplock_break(struct work_struct *work)
* Direct IO is not yet supported in the cached mode.
*/
static ssize_t
cifs_direct_io(struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
cifs_direct_io(struct kiocb *iocb, struct iov_iter *iter)
{
/*
* FIXME
Expand Down
4 changes: 2 additions & 2 deletions fs/dax.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
* @iocb: The control block for this I/O
* @inode: The file which the I/O is directed at
* @iter: The addresses to do I/O from or to
* @pos: The file offset where the I/O starts
* @get_block: The filesystem method used to translate file offsets to blocks
* @end_io: A filesystem callback for I/O completion
* @flags: See below
Expand All @@ -257,11 +256,12 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
* is in progress.
*/
ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
struct iov_iter *iter, loff_t pos, get_block_t get_block,
struct iov_iter *iter, get_block_t get_block,
dio_iodone_t end_io, int flags)
{
struct buffer_head bh;
ssize_t retval = -EINVAL;
loff_t pos = iocb->ki_pos;
loff_t end = pos + iov_iter_count(iter);

memset(&bh, 0, sizeof(bh));
Expand Down
34 changes: 18 additions & 16 deletions fs/direct-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ static inline struct page *dio_get_page(struct dio *dio,
* filesystems can use it to hold additional state between get_block calls and
* dio_complete.
*/
static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret,
bool is_async)
static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async)
{
loff_t offset = dio->iocb->ki_pos;
ssize_t transferred = 0;

/*
Expand Down Expand Up @@ -256,6 +256,7 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret,
if (dio->end_io) {
int err;

// XXX: ki_pos??
err = dio->end_io(dio->iocb, offset, ret, dio->private);
if (err)
ret = err;
Expand All @@ -265,15 +266,15 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret,
inode_dio_end(dio->inode);

if (is_async) {
if (dio->rw & WRITE) {
int err;

err = generic_write_sync(dio->iocb->ki_filp, offset,
transferred);
if (err < 0 && ret > 0)
ret = err;
}
/*
* generic_write_sync expects ki_pos to have been updated
* already, but the submission path only does this for
* synchronous I/O.
*/
dio->iocb->ki_pos += transferred;

if (dio->rw & WRITE)
ret = generic_write_sync(dio->iocb, transferred);
dio->iocb->ki_complete(dio->iocb, ret, 0);
}

Expand All @@ -285,7 +286,7 @@ static void dio_aio_complete_work(struct work_struct *work)
{
struct dio *dio = container_of(work, struct dio, complete_work);

dio_complete(dio, dio->iocb->ki_pos, 0, true);
dio_complete(dio, 0, true);
}

static int dio_bio_complete(struct dio *dio, struct bio *bio);
Expand Down Expand Up @@ -314,7 +315,7 @@ static void dio_bio_end_aio(struct bio *bio)
queue_work(dio->inode->i_sb->s_dio_done_wq,
&dio->complete_work);
} else {
dio_complete(dio, dio->iocb->ki_pos, 0, true);
dio_complete(dio, 0, true);
}
}
}
Expand Down Expand Up @@ -1113,14 +1114,15 @@ static inline int drop_refcount(struct dio *dio)
static inline ssize_t
do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
struct block_device *bdev, struct iov_iter *iter,
loff_t offset, get_block_t get_block, dio_iodone_t end_io,
get_block_t get_block, dio_iodone_t end_io,
dio_submit_t submit_io, int flags)
{
unsigned i_blkbits = ACCESS_ONCE(inode->i_blkbits);
unsigned blkbits = i_blkbits;
unsigned blocksize_mask = (1 << blkbits) - 1;
ssize_t retval = -EINVAL;
size_t count = iov_iter_count(iter);
loff_t offset = iocb->ki_pos;
loff_t end = offset + count;
struct dio *dio;
struct dio_submit sdio = { 0, };
Expand Down Expand Up @@ -1318,7 +1320,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
dio_await_completion(dio);

if (drop_refcount(dio) == 0) {
retval = dio_complete(dio, offset, retval, false);
retval = dio_complete(dio, retval, false);
} else
BUG_ON(retval != -EIOCBQUEUED);

Expand All @@ -1328,7 +1330,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,

ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
struct block_device *bdev, struct iov_iter *iter,
loff_t offset, get_block_t get_block,
get_block_t get_block,
dio_iodone_t end_io, dio_submit_t submit_io,
int flags)
{
Expand All @@ -1344,7 +1346,7 @@ ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
prefetch(bdev->bd_queue);
prefetch((char *)bdev->bd_queue + SMP_CACHE_BYTES);

return do_blockdev_direct_IO(iocb, inode, bdev, iter, offset, get_block,
return do_blockdev_direct_IO(iocb, inode, bdev, iter, get_block,
end_io, submit_io, flags);
}

Expand Down
3 changes: 1 addition & 2 deletions fs/exofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,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(struct kiocb *iocb, struct iov_iter *iter,
loff_t offset)
static ssize_t exofs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
{
return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,20 +854,20 @@ static sector_t ext2_bmap(struct address_space *mapping, sector_t block)
}

static ssize_t
ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
{
struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host;
size_t count = iov_iter_count(iter);
loff_t offset = iocb->ki_pos;
ssize_t ret;

if (IS_DAX(inode))
ret = dax_do_io(iocb, inode, iter, offset, ext2_get_block, NULL,
ret = dax_do_io(iocb, inode, iter, ext2_get_block, NULL,
DIO_LOCKING);
else
ret = blockdev_direct_IO(iocb, inode, iter, offset,
ext2_get_block);
ret = blockdev_direct_IO(iocb, inode, iter, ext2_get_block);
if (ret < 0 && iov_iter_rw(iter) == WRITE)
ext2_write_failed(mapping, offset + count);
return ret;
Expand Down
3 changes: 1 addition & 2 deletions fs/ext4/ext4.h
Original file line number Diff line number Diff line change
Expand Up @@ -2581,8 +2581,7 @@ extern int ext4_get_next_extent(struct inode *inode, ext4_lblk_t lblk,
/* indirect.c */
extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
struct ext4_map_blocks *map, int flags);
extern ssize_t ext4_ind_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
loff_t offset);
extern ssize_t ext4_ind_direct_IO(struct kiocb *iocb, struct iov_iter *iter);
extern int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock);
extern int ext4_ind_trans_blocks(struct inode *inode, int nrblocks);
extern void ext4_ind_truncate(handle_t *, struct inode *inode);
Expand Down
Loading

0 comments on commit c2e7b20

Please sign in to comment.