Commit 7608e610 authored by Theodore Ts'o's avatar Theodore Ts'o

ext4: inline generic_file_aio_write() into ext4_file_write()

Copy generic_file_aio_write() into ext4_file_write().  This is part of
a patch series which allows us to simplify ext4_file_write() and
ext4_file_dio_write(), by calling __generic_file_aio_write() directly.
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
parent 556615dc
...@@ -113,8 +113,6 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -113,8 +113,6 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov,
ext4_unwritten_wait(inode); ext4_unwritten_wait(inode);
} }
BUG_ON(iocb->ki_pos != pos);
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
blk_start_plug(&plug); blk_start_plug(&plug);
...@@ -168,9 +166,12 @@ static ssize_t ...@@ -168,9 +166,12 @@ static ssize_t
ext4_file_write(struct kiocb *iocb, const struct iovec *iov, ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos) unsigned long nr_segs, loff_t pos)
{ {
struct file *file = iocb->ki_filp;
struct inode *inode = file_inode(iocb->ki_filp); struct inode *inode = file_inode(iocb->ki_filp);
ssize_t ret; ssize_t ret;
BUG_ON(iocb->ki_pos != pos);
/* /*
* If we have encountered a bitmap-format file, the size limit * If we have encountered a bitmap-format file, the size limit
* is smaller than s_maxbytes, which is for extent-mapped files. * is smaller than s_maxbytes, which is for extent-mapped files.
...@@ -192,8 +193,19 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -192,8 +193,19 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
if (unlikely(iocb->ki_filp->f_flags & O_DIRECT)) if (unlikely(iocb->ki_filp->f_flags & O_DIRECT))
ret = ext4_file_dio_write(iocb, iov, nr_segs, pos); ret = ext4_file_dio_write(iocb, iov, nr_segs, pos);
else else {
ret = generic_file_aio_write(iocb, iov, nr_segs, pos); mutex_lock(&inode->i_mutex);
ret = __generic_file_aio_write(iocb, iov, nr_segs);
mutex_unlock(&inode->i_mutex);
if (ret > 0) {
ssize_t err;
err = generic_write_sync(file, iocb->ki_pos - ret, ret);
if (err < 0)
ret = err;
}
}
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment