diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-16 23:27:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-16 23:27:56 -0400 |
commit | 4fc8adcfec3da639da76e8314c9ccefe5bf9a045 (patch) | |
tree | e07a2dea8acf04d8bbbecd4fd3a571653ecdd953 /fs/dax.c | |
parent | 84588e7a5d8220446d677d7b909a20ee7a4496b9 (diff) | |
parent | aa4d86163e4e91a1ac560954a554bab417e338f4 (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/dax.c')
-rw-r--r-- | fs/dax.c | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -98,9 +98,9 @@ static bool buffer_size_valid(struct buffer_head *bh) | |||
98 | return bh->b_state != 0; | 98 | return bh->b_state != 0; |
99 | } | 99 | } |
100 | 100 | ||
101 | static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, | 101 | static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, |
102 | loff_t start, loff_t end, get_block_t get_block, | 102 | loff_t start, loff_t end, get_block_t get_block, |
103 | struct buffer_head *bh) | 103 | struct buffer_head *bh) |
104 | { | 104 | { |
105 | ssize_t retval = 0; | 105 | ssize_t retval = 0; |
106 | loff_t pos = start; | 106 | loff_t pos = start; |
@@ -109,7 +109,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, | |||
109 | void *addr; | 109 | void *addr; |
110 | bool hole = false; | 110 | bool hole = false; |
111 | 111 | ||
112 | if (rw != WRITE) | 112 | if (iov_iter_rw(iter) != WRITE) |
113 | end = min(end, i_size_read(inode)); | 113 | end = min(end, i_size_read(inode)); |
114 | 114 | ||
115 | while (pos < end) { | 115 | while (pos < end) { |
@@ -124,7 +124,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, | |||
124 | bh->b_size = PAGE_ALIGN(end - pos); | 124 | bh->b_size = PAGE_ALIGN(end - pos); |
125 | bh->b_state = 0; | 125 | bh->b_state = 0; |
126 | retval = get_block(inode, block, bh, | 126 | retval = get_block(inode, block, bh, |
127 | rw == WRITE); | 127 | iov_iter_rw(iter) == WRITE); |
128 | if (retval) | 128 | if (retval) |
129 | break; | 129 | break; |
130 | if (!buffer_size_valid(bh)) | 130 | if (!buffer_size_valid(bh)) |
@@ -137,7 +137,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, | |||
137 | bh->b_size -= done; | 137 | bh->b_size -= done; |
138 | } | 138 | } |
139 | 139 | ||
140 | hole = (rw != WRITE) && !buffer_written(bh); | 140 | hole = iov_iter_rw(iter) != WRITE && !buffer_written(bh); |
141 | if (hole) { | 141 | if (hole) { |
142 | addr = NULL; | 142 | addr = NULL; |
143 | size = bh->b_size - first; | 143 | size = bh->b_size - first; |
@@ -154,7 +154,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, | |||
154 | max = min(pos + size, end); | 154 | max = min(pos + size, end); |
155 | } | 155 | } |
156 | 156 | ||
157 | if (rw == WRITE) | 157 | if (iov_iter_rw(iter) == WRITE) |
158 | len = copy_from_iter(addr, max - pos, iter); | 158 | len = copy_from_iter(addr, max - pos, iter); |
159 | else if (!hole) | 159 | else if (!hole) |
160 | len = copy_to_iter(addr, max - pos, iter); | 160 | len = copy_to_iter(addr, max - pos, iter); |
@@ -173,7 +173,6 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, | |||
173 | 173 | ||
174 | /** | 174 | /** |
175 | * dax_do_io - Perform I/O to a DAX file | 175 | * dax_do_io - Perform I/O to a DAX file |
176 | * @rw: READ to read or WRITE to write | ||
177 | * @iocb: The control block for this I/O | 176 | * @iocb: The control block for this I/O |
178 | * @inode: The file which the I/O is directed at | 177 | * @inode: The file which the I/O is directed at |
179 | * @iter: The addresses to do I/O from or to | 178 | * @iter: The addresses to do I/O from or to |
@@ -189,9 +188,9 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, | |||
189 | * As with do_blockdev_direct_IO(), we increment i_dio_count while the I/O | 188 | * As with do_blockdev_direct_IO(), we increment i_dio_count while the I/O |
190 | * is in progress. | 189 | * is in progress. |
191 | */ | 190 | */ |
192 | ssize_t dax_do_io(int rw, struct kiocb *iocb, struct inode *inode, | 191 | ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode, |
193 | struct iov_iter *iter, loff_t pos, | 192 | struct iov_iter *iter, loff_t pos, get_block_t get_block, |
194 | get_block_t get_block, dio_iodone_t end_io, int flags) | 193 | dio_iodone_t end_io, int flags) |
195 | { | 194 | { |
196 | struct buffer_head bh; | 195 | struct buffer_head bh; |
197 | ssize_t retval = -EINVAL; | 196 | ssize_t retval = -EINVAL; |
@@ -199,7 +198,7 @@ ssize_t dax_do_io(int rw, struct kiocb *iocb, struct inode *inode, | |||
199 | 198 | ||
200 | memset(&bh, 0, sizeof(bh)); | 199 | memset(&bh, 0, sizeof(bh)); |
201 | 200 | ||
202 | if ((flags & DIO_LOCKING) && (rw == READ)) { | 201 | if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ) { |
203 | struct address_space *mapping = inode->i_mapping; | 202 | struct address_space *mapping = inode->i_mapping; |
204 | mutex_lock(&inode->i_mutex); | 203 | mutex_lock(&inode->i_mutex); |
205 | retval = filemap_write_and_wait_range(mapping, pos, end - 1); | 204 | retval = filemap_write_and_wait_range(mapping, pos, end - 1); |
@@ -212,9 +211,9 @@ ssize_t dax_do_io(int rw, struct kiocb *iocb, struct inode *inode, | |||
212 | /* Protects against truncate */ | 211 | /* Protects against truncate */ |
213 | atomic_inc(&inode->i_dio_count); | 212 | atomic_inc(&inode->i_dio_count); |
214 | 213 | ||
215 | retval = dax_io(rw, inode, iter, pos, end, get_block, &bh); | 214 | retval = dax_io(inode, iter, pos, end, get_block, &bh); |
216 | 215 | ||
217 | if ((flags & DIO_LOCKING) && (rw == READ)) | 216 | if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ) |
218 | mutex_unlock(&inode->i_mutex); | 217 | mutex_unlock(&inode->i_mutex); |
219 | 218 | ||
220 | if ((retval > 0) && end_io) | 219 | if ((retval > 0) && end_io) |