mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 02:19:51 +00:00
btrfs: switch to ->write_iter()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
3ef045c3d8
commit
b30ac0fc41
1 changed files with 10 additions and 14 deletions
|
@ -447,7 +447,7 @@ static noinline int btrfs_copy_from_user(loff_t pos, int num_pages,
|
||||||
write_bytes -= copied;
|
write_bytes -= copied;
|
||||||
total_copied += copied;
|
total_copied += copied;
|
||||||
|
|
||||||
/* Return to btrfs_file_aio_write to fault page */
|
/* Return to btrfs_file_write_iter to fault page */
|
||||||
if (unlikely(copied == 0))
|
if (unlikely(copied == 0))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1708,9 +1708,8 @@ static void update_time_for_write(struct inode *inode)
|
||||||
inode_inc_iversion(inode);
|
inode_inc_iversion(inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
|
static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
|
||||||
const struct iovec *iov,
|
struct iov_iter *from)
|
||||||
unsigned long nr_segs, loff_t pos)
|
|
||||||
{
|
{
|
||||||
struct file *file = iocb->ki_filp;
|
struct file *file = iocb->ki_filp;
|
||||||
struct inode *inode = file_inode(file);
|
struct inode *inode = file_inode(file);
|
||||||
|
@ -1719,15 +1718,12 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
|
||||||
u64 end_pos;
|
u64 end_pos;
|
||||||
ssize_t num_written = 0;
|
ssize_t num_written = 0;
|
||||||
ssize_t err = 0;
|
ssize_t err = 0;
|
||||||
size_t count;
|
size_t count = iov_iter_count(from);
|
||||||
bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host);
|
bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host);
|
||||||
struct iov_iter i;
|
loff_t pos = iocb->ki_pos;
|
||||||
|
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
|
|
||||||
count = iov_length(iov, nr_segs);
|
|
||||||
iov_iter_init(&i, WRITE, iov, nr_segs, count);
|
|
||||||
|
|
||||||
current->backing_dev_info = inode->i_mapping->backing_dev_info;
|
current->backing_dev_info = inode->i_mapping->backing_dev_info;
|
||||||
err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
|
err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -1740,7 +1736,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
iov_iter_truncate(&i, count);
|
iov_iter_truncate(from, count);
|
||||||
|
|
||||||
err = file_remove_suid(file);
|
err = file_remove_suid(file);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -1783,9 +1779,9 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
|
||||||
atomic_inc(&BTRFS_I(inode)->sync_writers);
|
atomic_inc(&BTRFS_I(inode)->sync_writers);
|
||||||
|
|
||||||
if (unlikely(file->f_flags & O_DIRECT)) {
|
if (unlikely(file->f_flags & O_DIRECT)) {
|
||||||
num_written = __btrfs_direct_write(iocb, &i, pos);
|
num_written = __btrfs_direct_write(iocb, from, pos);
|
||||||
} else {
|
} else {
|
||||||
num_written = __btrfs_buffered_write(file, &i, pos);
|
num_written = __btrfs_buffered_write(file, from, pos);
|
||||||
if (num_written > 0)
|
if (num_written > 0)
|
||||||
iocb->ki_pos = pos + num_written;
|
iocb->ki_pos = pos + num_written;
|
||||||
}
|
}
|
||||||
|
@ -2623,10 +2619,10 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
|
||||||
const struct file_operations btrfs_file_operations = {
|
const struct file_operations btrfs_file_operations = {
|
||||||
.llseek = btrfs_file_llseek,
|
.llseek = btrfs_file_llseek,
|
||||||
.read = new_sync_read,
|
.read = new_sync_read,
|
||||||
.write = do_sync_write,
|
.write = new_sync_write,
|
||||||
.read_iter = generic_file_read_iter,
|
.read_iter = generic_file_read_iter,
|
||||||
.splice_read = generic_file_splice_read,
|
.splice_read = generic_file_splice_read,
|
||||||
.aio_write = btrfs_file_aio_write,
|
.write_iter = btrfs_file_write_iter,
|
||||||
.mmap = btrfs_file_mmap,
|
.mmap = btrfs_file_mmap,
|
||||||
.open = generic_file_open,
|
.open = generic_file_open,
|
||||||
.release = btrfs_release_file,
|
.release = btrfs_release_file,
|
||||||
|
|
Loading…
Reference in a new issue