summaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-16 23:27:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-16 23:27:56 -0400
commit4fc8adcfec3da639da76e8314c9ccefe5bf9a045 (patch)
treee07a2dea8acf04d8bbbecd4fd3a571653ecdd953 /fs/ext4/inode.c
parent84588e7a5d8220446d677d7b909a20ee7a4496b9 (diff)
parentaa4d86163e4e91a1ac560954a554bab417e338f4 (diff)
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 ...
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 035b7a06f1c3..b49cf6e59953 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2952,8 +2952,8 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
2952 * if the machine crashes during the write. 2952 * if the machine crashes during the write.
2953 * 2953 *
2954 */ 2954 */
2955static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, 2955static ssize_t ext4_ext_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
2956 struct iov_iter *iter, loff_t offset) 2956 loff_t offset)
2957{ 2957{
2958 struct file *file = iocb->ki_filp; 2958 struct file *file = iocb->ki_filp;
2959 struct inode *inode = file->f_mapping->host; 2959 struct inode *inode = file->f_mapping->host;
@@ -2966,8 +2966,8 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
2966 ext4_io_end_t *io_end = NULL; 2966 ext4_io_end_t *io_end = NULL;
2967 2967
2968 /* Use the old path for reads and writes beyond i_size. */ 2968 /* Use the old path for reads and writes beyond i_size. */
2969 if (rw != WRITE || final_size > inode->i_size) 2969 if (iov_iter_rw(iter) != WRITE || final_size > inode->i_size)
2970 return ext4_ind_direct_IO(rw, iocb, iter, offset); 2970 return ext4_ind_direct_IO(iocb, iter, offset);
2971 2971
2972 BUG_ON(iocb->private == NULL); 2972 BUG_ON(iocb->private == NULL);
2973 2973
@@ -2976,7 +2976,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
2976 * conversion. This also disallows race between truncate() and 2976 * conversion. This also disallows race between truncate() and
2977 * overwrite DIO as i_dio_count needs to be incremented under i_mutex. 2977 * overwrite DIO as i_dio_count needs to be incremented under i_mutex.
2978 */ 2978 */
2979 if (rw == WRITE) 2979 if (iov_iter_rw(iter) == WRITE)
2980 atomic_inc(&inode->i_dio_count); 2980 atomic_inc(&inode->i_dio_count);
2981 2981
2982 /* If we do a overwrite dio, i_mutex locking can be released */ 2982 /* If we do a overwrite dio, i_mutex locking can be released */
@@ -3034,10 +3034,10 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3034 dio_flags = DIO_LOCKING; 3034 dio_flags = DIO_LOCKING;
3035 } 3035 }
3036 if (IS_DAX(inode)) 3036 if (IS_DAX(inode))
3037 ret = dax_do_io(rw, iocb, inode, iter, offset, get_block_func, 3037 ret = dax_do_io(iocb, inode, iter, offset, get_block_func,
3038 ext4_end_io_dio, dio_flags); 3038 ext4_end_io_dio, dio_flags);
3039 else 3039 else
3040 ret = __blockdev_direct_IO(rw, iocb, inode, 3040 ret = __blockdev_direct_IO(iocb, inode,
3041 inode->i_sb->s_bdev, iter, offset, 3041 inode->i_sb->s_bdev, iter, offset,
3042 get_block_func, 3042 get_block_func,
3043 ext4_end_io_dio, NULL, dio_flags); 3043 ext4_end_io_dio, NULL, dio_flags);
@@ -3078,7 +3078,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3078 } 3078 }
3079 3079
3080retake_lock: 3080retake_lock:
3081 if (rw == WRITE) 3081 if (iov_iter_rw(iter) == WRITE)
3082 inode_dio_done(inode); 3082 inode_dio_done(inode);
3083 /* take i_mutex locking again if we do a ovewrite dio */ 3083 /* take i_mutex locking again if we do a ovewrite dio */
3084 if (overwrite) { 3084 if (overwrite) {
@@ -3089,8 +3089,8 @@ retake_lock:
3089 return ret; 3089 return ret;
3090} 3090}
3091 3091
3092static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, 3092static ssize_t ext4_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
3093 struct iov_iter *iter, loff_t offset) 3093 loff_t offset)
3094{ 3094{
3095 struct file *file = iocb->ki_filp; 3095 struct file *file = iocb->ki_filp;
3096 struct inode *inode = file->f_mapping->host; 3096 struct inode *inode = file->f_mapping->host;
@@ -3107,12 +3107,12 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
3107 if (ext4_has_inline_data(inode)) 3107 if (ext4_has_inline_data(inode))
3108 return 0; 3108 return 0;
3109 3109
3110 trace_ext4_direct_IO_enter(inode, offset, count, rw); 3110 trace_ext4_direct_IO_enter(inode, offset, count, iov_iter_rw(iter));
3111 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) 3111 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
3112 ret = ext4_ext_direct_IO(rw, iocb, iter, offset); 3112 ret = ext4_ext_direct_IO(iocb, iter, offset);
3113 else 3113 else
3114 ret = ext4_ind_direct_IO(rw, iocb, iter, offset); 3114 ret = ext4_ind_direct_IO(iocb, iter, offset);
3115 trace_ext4_direct_IO_exit(inode, offset, count, rw, ret); 3115 trace_ext4_direct_IO_exit(inode, offset, count, iov_iter_rw(iter), ret);
3116 return ret; 3116 return ret;
3117} 3117}
3118 3118