Commit 8d71db4f authored by Al Viro's avatar Al Viro

lift sb_start_write/sb_end_write out of ->aio_write()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 5f2e354f
...@@ -1324,6 +1324,8 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb) ...@@ -1324,6 +1324,8 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb)
if (iocb->ki_pos < 0) if (iocb->ki_pos < 0)
return -EINVAL; return -EINVAL;
if (opcode == IOCB_CMD_PWRITEV)
file_start_write(file);
do { do {
ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg], ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg],
iocb->ki_nr_segs - iocb->ki_cur_seg, iocb->ki_nr_segs - iocb->ki_cur_seg,
...@@ -1336,6 +1338,8 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb) ...@@ -1336,6 +1338,8 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb)
} while (ret > 0 && iocb->ki_left > 0 && } while (ret > 0 && iocb->ki_left > 0 &&
(opcode == IOCB_CMD_PWRITEV || (opcode == IOCB_CMD_PWRITEV ||
(!S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode)))); (!S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode))));
if (opcode == IOCB_CMD_PWRITEV)
file_end_write(file);
/* This means we must have transferred all that we could */ /* This means we must have transferred all that we could */
/* No need to retry anymore */ /* No need to retry anymore */
......
...@@ -1514,8 +1514,6 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, ...@@ -1514,8 +1514,6 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
size_t count, ocount; size_t count, ocount;
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);
sb_start_write(inode->i_sb);
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
err = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_READ); err = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_READ);
...@@ -1617,7 +1615,6 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, ...@@ -1617,7 +1615,6 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
if (sync) if (sync)
atomic_dec(&BTRFS_I(inode)->sync_writers); atomic_dec(&BTRFS_I(inode)->sync_writers);
out: out:
sb_end_write(inode->i_sb);
current->backing_dev_info = NULL; current->backing_dev_info = NULL;
return num_written ? num_written : err; return num_written ? num_written : err;
} }
......
...@@ -2520,8 +2520,6 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov, ...@@ -2520,8 +2520,6 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
BUG_ON(iocb->ki_pos != pos); BUG_ON(iocb->ki_pos != pos);
sb_start_write(inode->i_sb);
/* /*
* We need to hold the sem to be sure nobody modifies lock list * We need to hold the sem to be sure nobody modifies lock list
* with a brlock that prevents writing. * with a brlock that prevents writing.
...@@ -2545,7 +2543,6 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov, ...@@ -2545,7 +2543,6 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
} }
up_read(&cinode->lock_sem); up_read(&cinode->lock_sem);
sb_end_write(inode->i_sb);
return rc; return rc;
} }
......
...@@ -1103,10 +1103,12 @@ static ssize_t compat_do_readv_writev(int type, struct file *file, ...@@ -1103,10 +1103,12 @@ static ssize_t compat_do_readv_writev(int type, struct file *file,
fnv = file->f_op->aio_write; fnv = file->f_op->aio_write;
} }
if (fnv) if (fnv) {
file_start_write(file);
ret = do_sync_readv_writev(file, iov, nr_segs, tot_len, ret = do_sync_readv_writev(file, iov, nr_segs, tot_len,
pos, fnv); pos, fnv);
else file_end_write(file);
} else
ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn); ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn);
out: out:
......
...@@ -971,7 +971,6 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -971,7 +971,6 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
return err; return err;
count = ocount; count = ocount;
sb_start_write(inode->i_sb);
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
/* We can write back this queue in page reclaim */ /* We can write back this queue in page reclaim */
...@@ -1030,7 +1029,6 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -1030,7 +1029,6 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
out: out:
current->backing_dev_info = NULL; current->backing_dev_info = NULL;
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
sb_end_write(inode->i_sb);
return written ? written : err; return written ? written : err;
} }
......
...@@ -2129,7 +2129,6 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -2129,7 +2129,6 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
BUG_ON(iocb->ki_pos != pos); BUG_ON(iocb->ki_pos != pos);
sb_start_write(inode->i_sb);
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
ret = ntfs_file_aio_write_nolock(iocb, iov, nr_segs, &iocb->ki_pos); ret = ntfs_file_aio_write_nolock(iocb, iov, nr_segs, &iocb->ki_pos);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
...@@ -2138,7 +2137,6 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -2138,7 +2137,6 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
if (err < 0) if (err < 0)
ret = err; ret = err;
} }
sb_end_write(inode->i_sb);
return ret; return ret;
} }
......
...@@ -2248,8 +2248,6 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, ...@@ -2248,8 +2248,6 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
if (iocb->ki_left == 0) if (iocb->ki_left == 0)
return 0; return 0;
sb_start_write(inode->i_sb);
appending = file->f_flags & O_APPEND ? 1 : 0; appending = file->f_flags & O_APPEND ? 1 : 0;
direct_io = file->f_flags & O_DIRECT ? 1 : 0; direct_io = file->f_flags & O_DIRECT ? 1 : 0;
...@@ -2423,7 +2421,6 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, ...@@ -2423,7 +2421,6 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
ocfs2_iocb_clear_sem_locked(iocb); ocfs2_iocb_clear_sem_locked(iocb);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
sb_end_write(inode->i_sb);
if (written) if (written)
ret = written; ret = written;
......
...@@ -398,6 +398,7 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof ...@@ -398,6 +398,7 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof
struct kiocb kiocb; struct kiocb kiocb;
ssize_t ret; ssize_t ret;
file_start_write(filp);
init_sync_kiocb(&kiocb, filp); init_sync_kiocb(&kiocb, filp);
kiocb.ki_pos = *ppos; kiocb.ki_pos = *ppos;
kiocb.ki_left = len; kiocb.ki_left = len;
...@@ -413,6 +414,7 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof ...@@ -413,6 +414,7 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof
if (-EIOCBQUEUED == ret) if (-EIOCBQUEUED == ret)
ret = wait_on_sync_kiocb(&kiocb); ret = wait_on_sync_kiocb(&kiocb);
*ppos = kiocb.ki_pos; *ppos = kiocb.ki_pos;
file_end_write(filp);
return ret; return ret;
} }
...@@ -758,10 +760,12 @@ static ssize_t do_readv_writev(int type, struct file *file, ...@@ -758,10 +760,12 @@ static ssize_t do_readv_writev(int type, struct file *file,
fnv = file->f_op->aio_write; fnv = file->f_op->aio_write;
} }
if (fnv) if (fnv) {
file_start_write(file);
ret = do_sync_readv_writev(file, iov, nr_segs, tot_len, ret = do_sync_readv_writev(file, iov, nr_segs, tot_len,
pos, fnv); pos, fnv);
else file_end_write(file);
} else
ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn); ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn);
out: out:
......
...@@ -775,8 +775,6 @@ xfs_file_aio_write( ...@@ -775,8 +775,6 @@ xfs_file_aio_write(
if (ocount == 0) if (ocount == 0)
return 0; return 0;
sb_start_write(inode->i_sb);
if (XFS_FORCED_SHUTDOWN(ip->i_mount)) { if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {
ret = -EIO; ret = -EIO;
goto out; goto out;
...@@ -800,7 +798,6 @@ xfs_file_aio_write( ...@@ -800,7 +798,6 @@ xfs_file_aio_write(
} }
out: out:
sb_end_write(inode->i_sb);
return ret; return ret;
} }
......
...@@ -2223,6 +2223,20 @@ static inline struct inode *file_inode(struct file *f) ...@@ -2223,6 +2223,20 @@ static inline struct inode *file_inode(struct file *f)
return f->f_inode; return f->f_inode;
} }
static inline void file_start_write(struct file *file)
{
if (!S_ISREG(file_inode(file)->i_mode))
return;
__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
}
static inline void file_end_write(struct file *file)
{
if (!S_ISREG(file_inode(file)->i_mode))
return;
__sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE);
}
/* /*
* get_write_access() gets write permission for a file. * get_write_access() gets write permission for a file.
* put_write_access() releases this write permission. * put_write_access() releases this write permission.
......
...@@ -2528,7 +2528,6 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -2528,7 +2528,6 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
BUG_ON(iocb->ki_pos != pos); BUG_ON(iocb->ki_pos != pos);
sb_start_write(inode->i_sb);
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
...@@ -2540,7 +2539,6 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -2540,7 +2539,6 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
if (err < 0 && ret > 0) if (err < 0 && ret > 0)
ret = err; ret = err;
} }
sb_end_write(inode->i_sb);
return ret; return ret;
} }
EXPORT_SYMBOL(generic_file_aio_write); EXPORT_SYMBOL(generic_file_aio_write);
......
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