aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dax.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dax.c')
-rw-r--r--fs/dax.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/fs/dax.c b/fs/dax.c
index d0bd1f4f81b3..0bb0aecb556c 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -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
101static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, 101static 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 */
192ssize_t dax_do_io(int rw, struct kiocb *iocb, struct inode *inode, 191ssize_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)