Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull third hunk of vfs changes from Al Viro: "This contains the ->direct_IO() changes from Omar + saner generic_write_checks() + dealing with fcntl()/{read,write}() races (mirroring O_APPEND/O_DIRECT into iocb->ki_flags and instead of repeatedly looking at ->f_flags, which can be changed by fcntl(2), check ->ki_flags - which cannot) + infrastructure bits for dhowells' d_inode annotations + Christophs switch of /dev/loop to vfs_iter_write()" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (30 commits) block: loop: switch to VFS ITER_BVEC configfs: Fix inconsistent use of file_inode() vs file->f_path.dentry->d_inode VFS: Make pathwalk use d_is_reg() rather than S_ISREG() VFS: Fix up debugfs to use d_is_dir() in place of S_ISDIR() VFS: Combine inode checks with d_is_negative() and d_is_positive() in pathwalk NFS: Don't use d_inode as a variable name VFS: Impose ordering on accesses of d_inode and d_flags VFS: Add owner-filesystem positive/negative dentry checks nfs: generic_write_checks() shouldn't be done on swapout... ocfs2: use __generic_file_write_iter() mirror O_APPEND and O_DIRECT into iocb->ki_flags switch generic_write_checks() to iocb and iter ocfs2: move generic_write_checks() before the alignment checks ocfs2_file_write_iter: stop messing with ppos udf_file_write_iter: reorder and simplify fuse: ->direct_IO() doesn't need generic_write_checks() ext4_file_write_iter: move generic_write_checks() up xfs_file_aio_write_checks: switch to iocb/iov_iter generic_write_checks(): drop isblk argument blkdev_write_iter: expand generic_file_checks() call in there ...
Šī revīzija ir iekļauta:
@@ -1495,7 +1495,6 @@ xfs_end_io_direct_write(
|
||||
|
||||
STATIC ssize_t
|
||||
xfs_vm_direct_IO(
|
||||
int rw,
|
||||
struct kiocb *iocb,
|
||||
struct iov_iter *iter,
|
||||
loff_t offset)
|
||||
@@ -1503,15 +1502,14 @@ xfs_vm_direct_IO(
|
||||
struct inode *inode = iocb->ki_filp->f_mapping->host;
|
||||
struct block_device *bdev = xfs_find_bdev_for_inode(inode);
|
||||
|
||||
if (rw & WRITE) {
|
||||
return __blockdev_direct_IO(rw, iocb, inode, bdev, iter,
|
||||
offset, xfs_get_blocks_direct,
|
||||
if (iov_iter_rw(iter) == WRITE) {
|
||||
return __blockdev_direct_IO(iocb, inode, bdev, iter, offset,
|
||||
xfs_get_blocks_direct,
|
||||
xfs_end_io_direct_write, NULL,
|
||||
DIO_ASYNC_EXTEND);
|
||||
}
|
||||
return __blockdev_direct_IO(rw, iocb, inode, bdev, iter,
|
||||
offset, xfs_get_blocks_direct,
|
||||
NULL, NULL, 0);
|
||||
return __blockdev_direct_IO(iocb, inode, bdev, iter, offset,
|
||||
xfs_get_blocks_direct, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -279,7 +279,7 @@ xfs_file_read_iter(
|
||||
|
||||
XFS_STATS_INC(xs_read_calls);
|
||||
|
||||
if (unlikely(file->f_flags & O_DIRECT))
|
||||
if (unlikely(iocb->ki_flags & IOCB_DIRECT))
|
||||
ioflags |= XFS_IO_ISDIRECT;
|
||||
if (file->f_mode & FMODE_NOCMTIME)
|
||||
ioflags |= XFS_IO_INVIS;
|
||||
@@ -544,18 +544,19 @@ xfs_zero_eof(
|
||||
*/
|
||||
STATIC ssize_t
|
||||
xfs_file_aio_write_checks(
|
||||
struct file *file,
|
||||
loff_t *pos,
|
||||
size_t *count,
|
||||
struct kiocb *iocb,
|
||||
struct iov_iter *from,
|
||||
int *iolock)
|
||||
{
|
||||
struct file *file = iocb->ki_filp;
|
||||
struct inode *inode = file->f_mapping->host;
|
||||
struct xfs_inode *ip = XFS_I(inode);
|
||||
int error = 0;
|
||||
ssize_t error = 0;
|
||||
size_t count = iov_iter_count(from);
|
||||
|
||||
restart:
|
||||
error = generic_write_checks(file, pos, count, S_ISBLK(inode->i_mode));
|
||||
if (error)
|
||||
error = generic_write_checks(iocb, from);
|
||||
if (error <= 0)
|
||||
return error;
|
||||
|
||||
error = xfs_break_layouts(inode, iolock);
|
||||
@@ -569,16 +570,17 @@ restart:
|
||||
* iolock shared, we need to update it to exclusive which implies
|
||||
* having to redo all checks before.
|
||||
*/
|
||||
if (*pos > i_size_read(inode)) {
|
||||
if (iocb->ki_pos > i_size_read(inode)) {
|
||||
bool zero = false;
|
||||
|
||||
if (*iolock == XFS_IOLOCK_SHARED) {
|
||||
xfs_rw_iunlock(ip, *iolock);
|
||||
*iolock = XFS_IOLOCK_EXCL;
|
||||
xfs_rw_ilock(ip, *iolock);
|
||||
iov_iter_reexpand(from, count);
|
||||
goto restart;
|
||||
}
|
||||
error = xfs_zero_eof(ip, *pos, i_size_read(inode), &zero);
|
||||
error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), &zero);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
@@ -678,10 +680,11 @@ xfs_file_dio_aio_write(
|
||||
xfs_rw_ilock(ip, iolock);
|
||||
}
|
||||
|
||||
ret = xfs_file_aio_write_checks(file, &pos, &count, &iolock);
|
||||
ret = xfs_file_aio_write_checks(iocb, from, &iolock);
|
||||
if (ret)
|
||||
goto out;
|
||||
iov_iter_truncate(from, count);
|
||||
count = iov_iter_count(from);
|
||||
pos = iocb->ki_pos;
|
||||
|
||||
if (mapping->nrpages) {
|
||||
ret = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
|
||||
@@ -734,24 +737,22 @@ xfs_file_buffered_aio_write(
|
||||
ssize_t ret;
|
||||
int enospc = 0;
|
||||
int iolock = XFS_IOLOCK_EXCL;
|
||||
loff_t pos = iocb->ki_pos;
|
||||
size_t count = iov_iter_count(from);
|
||||
|
||||
xfs_rw_ilock(ip, iolock);
|
||||
|
||||
ret = xfs_file_aio_write_checks(file, &pos, &count, &iolock);
|
||||
ret = xfs_file_aio_write_checks(iocb, from, &iolock);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
iov_iter_truncate(from, count);
|
||||
/* We can write back this queue in page reclaim */
|
||||
current->backing_dev_info = inode_to_bdi(inode);
|
||||
|
||||
write_retry:
|
||||
trace_xfs_file_buffered_write(ip, count, iocb->ki_pos, 0);
|
||||
ret = generic_perform_write(file, from, pos);
|
||||
trace_xfs_file_buffered_write(ip, iov_iter_count(from),
|
||||
iocb->ki_pos, 0);
|
||||
ret = generic_perform_write(file, from, iocb->ki_pos);
|
||||
if (likely(ret >= 0))
|
||||
iocb->ki_pos = pos + ret;
|
||||
iocb->ki_pos += ret;
|
||||
|
||||
/*
|
||||
* If we hit a space limit, try to free up some lingering preallocated
|
||||
@@ -803,7 +804,7 @@ xfs_file_write_iter(
|
||||
if (XFS_FORCED_SHUTDOWN(ip->i_mount))
|
||||
return -EIO;
|
||||
|
||||
if (unlikely(file->f_flags & O_DIRECT))
|
||||
if (unlikely(iocb->ki_flags & IOCB_DIRECT))
|
||||
ret = xfs_file_dio_aio_write(iocb, from);
|
||||
else
|
||||
ret = xfs_file_buffered_aio_write(iocb, from);
|
||||
|
Atsaukties uz šo jaunā problēmā
Block a user