Thomas Gleixner | 1f32761 | 2019-05-28 09:57:16 -0700 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 2 | /* |
| 3 | * linux/fs/9p/vfs_addr.c |
| 4 | * |
| 5 | * This file contians vfs address (mmap) ops for 9P2000. |
| 6 | * |
| 7 | * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com> |
| 8 | * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/errno.h> |
| 13 | #include <linux/fs.h> |
| 14 | #include <linux/file.h> |
| 15 | #include <linux/stat.h> |
| 16 | #include <linux/string.h> |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 17 | #include <linux/inet.h> |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 18 | #include <linux/pagemap.h> |
| 19 | #include <linux/idr.h> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 20 | #include <linux/sched.h> |
Christoph Hellwig | e2e40f2 | 2015-02-22 08:58:50 -0800 | [diff] [blame] | 21 | #include <linux/uio.h> |
Christoph Hellwig | 2f8b544 | 2016-11-01 07:40:13 -0600 | [diff] [blame] | 22 | #include <linux/bvec.h> |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 23 | #include <net/9p/9p.h> |
| 24 | #include <net/9p/client.h> |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 25 | |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 26 | #include "v9fs.h" |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 27 | #include "v9fs_vfs.h" |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 28 | #include "cache.h" |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 29 | #include "fid.h" |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 30 | |
| 31 | /** |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 32 | * v9fs_fid_readpage - read an entire page in from 9P |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 33 | * |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 34 | * @fid: fid being read |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 35 | * @page: structure to page |
| 36 | * |
| 37 | */ |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 38 | static int v9fs_fid_readpage(struct p9_fid *fid, struct page *page) |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 39 | { |
Al Viro | e1200fe6 | 2015-04-01 23:42:28 -0400 | [diff] [blame] | 40 | struct inode *inode = page->mapping->host; |
| 41 | struct bio_vec bvec = {.bv_page = page, .bv_len = PAGE_SIZE}; |
| 42 | struct iov_iter to; |
| 43 | int retval, err; |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 44 | |
Joe Perches | 5d38515 | 2011-11-28 10:40:46 -0800 | [diff] [blame] | 45 | p9_debug(P9_DEBUG_VFS, "\n"); |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 46 | |
| 47 | BUG_ON(!PageLocked(page)); |
| 48 | |
| 49 | retval = v9fs_readpage_from_fscache(inode, page); |
| 50 | if (retval == 0) |
| 51 | return retval; |
| 52 | |
David Howells | aa563d7 | 2018-10-20 00:57:56 +0100 | [diff] [blame] | 53 | iov_iter_bvec(&to, READ, &bvec, 1, PAGE_SIZE); |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 54 | |
Al Viro | e1200fe6 | 2015-04-01 23:42:28 -0400 | [diff] [blame] | 55 | retval = p9_client_read(fid, page_offset(page), &to, &err); |
| 56 | if (err) { |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 57 | v9fs_uncache_page(inode, page); |
Al Viro | e1200fe6 | 2015-04-01 23:42:28 -0400 | [diff] [blame] | 58 | retval = err; |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 59 | goto done; |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 60 | } |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 61 | |
Al Viro | e1200fe6 | 2015-04-01 23:42:28 -0400 | [diff] [blame] | 62 | zero_user(page, retval, PAGE_SIZE - retval); |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 63 | flush_dcache_page(page); |
| 64 | SetPageUptodate(page); |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 65 | |
| 66 | v9fs_readpage_to_fscache(inode, page); |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 67 | retval = 0; |
| 68 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 69 | done: |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 70 | unlock_page(page); |
| 71 | return retval; |
| 72 | } |
| 73 | |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 74 | /** |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 75 | * v9fs_vfs_readpage - read an entire page in from 9P |
| 76 | * |
| 77 | * @filp: file being read |
| 78 | * @page: structure to page |
| 79 | * |
| 80 | */ |
| 81 | |
| 82 | static int v9fs_vfs_readpage(struct file *filp, struct page *page) |
| 83 | { |
| 84 | return v9fs_fid_readpage(filp->private_data, page); |
| 85 | } |
| 86 | |
| 87 | /** |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 88 | * v9fs_vfs_readpages - read a set of pages from 9P |
| 89 | * |
| 90 | * @filp: file being read |
| 91 | * @mapping: the address space |
| 92 | * @pages: list of pages to read |
| 93 | * @nr_pages: count of pages to read |
| 94 | * |
| 95 | */ |
| 96 | |
| 97 | static int v9fs_vfs_readpages(struct file *filp, struct address_space *mapping, |
| 98 | struct list_head *pages, unsigned nr_pages) |
| 99 | { |
| 100 | int ret = 0; |
| 101 | struct inode *inode; |
| 102 | |
| 103 | inode = mapping->host; |
Joe Perches | 5d38515 | 2011-11-28 10:40:46 -0800 | [diff] [blame] | 104 | p9_debug(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, filp); |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 105 | |
| 106 | ret = v9fs_readpages_from_fscache(inode, mapping, pages, &nr_pages); |
| 107 | if (ret == 0) |
| 108 | return ret; |
| 109 | |
| 110 | ret = read_cache_pages(mapping, pages, (void *)v9fs_vfs_readpage, filp); |
Joe Perches | 5d38515 | 2011-11-28 10:40:46 -0800 | [diff] [blame] | 111 | p9_debug(P9_DEBUG_VFS, " = %d\n", ret); |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 112 | return ret; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * v9fs_release_page - release the private state associated with a page |
| 117 | * |
| 118 | * Returns 1 if the page can be released, false otherwise. |
| 119 | */ |
| 120 | |
| 121 | static int v9fs_release_page(struct page *page, gfp_t gfp) |
| 122 | { |
| 123 | if (PagePrivate(page)) |
| 124 | return 0; |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 125 | return v9fs_fscache_release_page(page, gfp); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * v9fs_invalidate_page - Invalidate a page completely or partially |
| 130 | * |
| 131 | * @page: structure to page |
| 132 | * @offset: offset in the page |
| 133 | */ |
| 134 | |
Lukas Czerner | d47992f | 2013-05-21 23:17:23 -0400 | [diff] [blame] | 135 | static void v9fs_invalidate_page(struct page *page, unsigned int offset, |
| 136 | unsigned int length) |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 137 | { |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 138 | /* |
| 139 | * If called with zero offset, we should release |
| 140 | * the private state assocated with the page |
| 141 | */ |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 142 | if (offset == 0 && length == PAGE_SIZE) |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 143 | v9fs_fscache_invalidate_page(page); |
| 144 | } |
| 145 | |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 146 | static int v9fs_vfs_writepage_locked(struct page *page) |
| 147 | { |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 148 | struct inode *inode = page->mapping->host; |
Al Viro | 371098c | 2015-04-01 21:54:42 -0400 | [diff] [blame] | 149 | struct v9fs_inode *v9inode = V9FS_I(inode); |
| 150 | loff_t size = i_size_read(inode); |
| 151 | struct iov_iter from; |
| 152 | struct bio_vec bvec; |
| 153 | int err, len; |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 154 | |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 155 | if (page->index == size >> PAGE_SHIFT) |
| 156 | len = size & ~PAGE_MASK; |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 157 | else |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 158 | len = PAGE_SIZE; |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 159 | |
Al Viro | 371098c | 2015-04-01 21:54:42 -0400 | [diff] [blame] | 160 | bvec.bv_page = page; |
| 161 | bvec.bv_offset = 0; |
| 162 | bvec.bv_len = len; |
David Howells | aa563d7 | 2018-10-20 00:57:56 +0100 | [diff] [blame] | 163 | iov_iter_bvec(&from, WRITE, &bvec, 1, len); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 164 | |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 165 | /* We should have writeback_fid always set */ |
| 166 | BUG_ON(!v9inode->writeback_fid); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 167 | |
Al Viro | 371098c | 2015-04-01 21:54:42 -0400 | [diff] [blame] | 168 | set_page_writeback(page); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 169 | |
Al Viro | 371098c | 2015-04-01 21:54:42 -0400 | [diff] [blame] | 170 | p9_client_write(v9inode->writeback_fid, page_offset(page), &from, &err); |
| 171 | |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 172 | end_page_writeback(page); |
Al Viro | 371098c | 2015-04-01 21:54:42 -0400 | [diff] [blame] | 173 | return err; |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | static int v9fs_vfs_writepage(struct page *page, struct writeback_control *wbc) |
| 177 | { |
| 178 | int retval; |
| 179 | |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 180 | p9_debug(P9_DEBUG_VFS, "page %p\n", page); |
| 181 | |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 182 | retval = v9fs_vfs_writepage_locked(page); |
| 183 | if (retval < 0) { |
| 184 | if (retval == -EAGAIN) { |
| 185 | redirty_page_for_writepage(wbc, page); |
| 186 | retval = 0; |
| 187 | } else { |
| 188 | SetPageError(page); |
| 189 | mapping_set_error(page->mapping, retval); |
| 190 | } |
| 191 | } else |
| 192 | retval = 0; |
| 193 | |
| 194 | unlock_page(page); |
| 195 | return retval; |
| 196 | } |
| 197 | |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 198 | /** |
| 199 | * v9fs_launder_page - Writeback a dirty page |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 200 | * Returns 0 on success. |
| 201 | */ |
| 202 | |
| 203 | static int v9fs_launder_page(struct page *page) |
| 204 | { |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 205 | int retval; |
Aneesh Kumar K.V | 2efda79 | 2011-02-28 17:03:56 +0530 | [diff] [blame] | 206 | struct inode *inode = page->mapping->host; |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 207 | |
Aneesh Kumar K.V | 2efda79 | 2011-02-28 17:03:56 +0530 | [diff] [blame] | 208 | v9fs_fscache_wait_on_page_write(inode, page); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 209 | if (clear_page_dirty_for_io(page)) { |
| 210 | retval = v9fs_vfs_writepage_locked(page); |
| 211 | if (retval) |
| 212 | return retval; |
| 213 | } |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 214 | return 0; |
| 215 | } |
| 216 | |
jvrao | 3e24ad2 | 2010-08-24 15:43:28 +0000 | [diff] [blame] | 217 | /** |
| 218 | * v9fs_direct_IO - 9P address space operation for direct I/O |
jvrao | 3e24ad2 | 2010-08-24 15:43:28 +0000 | [diff] [blame] | 219 | * @iocb: target I/O control block |
jvrao | 3e24ad2 | 2010-08-24 15:43:28 +0000 | [diff] [blame] | 220 | * |
| 221 | * The presence of v9fs_direct_IO() in the address space ops vector |
| 222 | * allowes open() O_DIRECT flags which would have failed otherwise. |
| 223 | * |
| 224 | * In the non-cached mode, we shunt off direct read and write requests before |
| 225 | * the VFS gets them, so this method should never be called. |
| 226 | * |
| 227 | * Direct IO is not 'yet' supported in the cached mode. Hence when |
| 228 | * this routine is called through generic_file_aio_read(), the read/write fails |
| 229 | * with an error. |
| 230 | * |
| 231 | */ |
Aneesh Kumar K.V | e959b54 | 2011-02-28 17:04:04 +0530 | [diff] [blame] | 232 | static ssize_t |
Christoph Hellwig | c8b8e32 | 2016-04-07 08:51:58 -0700 | [diff] [blame] | 233 | v9fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) |
jvrao | 3e24ad2 | 2010-08-24 15:43:28 +0000 | [diff] [blame] | 234 | { |
Al Viro | 9565a54 | 2015-04-01 22:32:23 -0400 | [diff] [blame] | 235 | struct file *file = iocb->ki_filp; |
Christoph Hellwig | c8b8e32 | 2016-04-07 08:51:58 -0700 | [diff] [blame] | 236 | loff_t pos = iocb->ki_pos; |
Al Viro | 42b1ab9 | 2015-04-01 23:49:24 -0400 | [diff] [blame] | 237 | ssize_t n; |
| 238 | int err = 0; |
Omar Sandoval | 6f67376 | 2015-03-16 04:33:52 -0700 | [diff] [blame] | 239 | if (iov_iter_rw(iter) == WRITE) { |
Al Viro | 42b1ab9 | 2015-04-01 23:49:24 -0400 | [diff] [blame] | 240 | n = p9_client_write(file->private_data, pos, iter, &err); |
| 241 | if (n) { |
Al Viro | 9565a54 | 2015-04-01 22:32:23 -0400 | [diff] [blame] | 242 | struct inode *inode = file_inode(file); |
| 243 | loff_t i_size = i_size_read(inode); |
Al Viro | 42b1ab9 | 2015-04-01 23:49:24 -0400 | [diff] [blame] | 244 | if (pos + n > i_size) |
| 245 | inode_add_bytes(inode, pos + n - i_size); |
Al Viro | 9565a54 | 2015-04-01 22:32:23 -0400 | [diff] [blame] | 246 | } |
Al Viro | 42b1ab9 | 2015-04-01 23:49:24 -0400 | [diff] [blame] | 247 | } else { |
| 248 | n = p9_client_read(file->private_data, pos, iter, &err); |
Al Viro | 9565a54 | 2015-04-01 22:32:23 -0400 | [diff] [blame] | 249 | } |
Al Viro | 42b1ab9 | 2015-04-01 23:49:24 -0400 | [diff] [blame] | 250 | return n ? n : err; |
jvrao | 3e24ad2 | 2010-08-24 15:43:28 +0000 | [diff] [blame] | 251 | } |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 252 | |
| 253 | static int v9fs_write_begin(struct file *filp, struct address_space *mapping, |
| 254 | loff_t pos, unsigned len, unsigned flags, |
| 255 | struct page **pagep, void **fsdata) |
| 256 | { |
| 257 | int retval = 0; |
| 258 | struct page *page; |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 259 | struct v9fs_inode *v9inode; |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 260 | pgoff_t index = pos >> PAGE_SHIFT; |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 261 | struct inode *inode = mapping->host; |
| 262 | |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 263 | |
| 264 | p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping); |
| 265 | |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 266 | v9inode = V9FS_I(inode); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 267 | start: |
| 268 | page = grab_cache_page_write_begin(mapping, index, flags); |
| 269 | if (!page) { |
| 270 | retval = -ENOMEM; |
| 271 | goto out; |
| 272 | } |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 273 | BUG_ON(!v9inode->writeback_fid); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 274 | if (PageUptodate(page)) |
| 275 | goto out; |
| 276 | |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 277 | if (len == PAGE_SIZE) |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 278 | goto out; |
| 279 | |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 280 | retval = v9fs_fid_readpage(v9inode->writeback_fid, page); |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 281 | put_page(page); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 282 | if (!retval) |
| 283 | goto start; |
| 284 | out: |
| 285 | *pagep = page; |
| 286 | return retval; |
| 287 | } |
| 288 | |
| 289 | static int v9fs_write_end(struct file *filp, struct address_space *mapping, |
| 290 | loff_t pos, unsigned len, unsigned copied, |
| 291 | struct page *page, void *fsdata) |
| 292 | { |
| 293 | loff_t last_pos = pos + copied; |
| 294 | struct inode *inode = page->mapping->host; |
| 295 | |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 296 | p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping); |
| 297 | |
Alexander Levin | 56ae414 | 2017-04-10 18:46:51 +0000 | [diff] [blame] | 298 | if (!PageUptodate(page)) { |
| 299 | if (unlikely(copied < len)) { |
| 300 | copied = 0; |
| 301 | goto out; |
| 302 | } else if (len == PAGE_SIZE) { |
| 303 | SetPageUptodate(page); |
| 304 | } |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 305 | } |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 306 | /* |
| 307 | * No need to use i_size_read() here, the i_size |
| 308 | * cannot change under us because we hold the i_mutex. |
| 309 | */ |
| 310 | if (last_pos > inode->i_size) { |
| 311 | inode_add_bytes(inode, last_pos - inode->i_size); |
| 312 | i_size_write(inode, last_pos); |
| 313 | } |
| 314 | set_page_dirty(page); |
Al Viro | 77469c3 | 2016-08-29 20:56:35 -0400 | [diff] [blame] | 315 | out: |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 316 | unlock_page(page); |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 317 | put_page(page); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 318 | |
| 319 | return copied; |
| 320 | } |
| 321 | |
| 322 | |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 323 | const struct address_space_operations v9fs_addr_operations = { |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 324 | .readpage = v9fs_vfs_readpage, |
| 325 | .readpages = v9fs_vfs_readpages, |
| 326 | .set_page_dirty = __set_page_dirty_nobuffers, |
| 327 | .writepage = v9fs_vfs_writepage, |
| 328 | .write_begin = v9fs_write_begin, |
| 329 | .write_end = v9fs_write_end, |
| 330 | .releasepage = v9fs_release_page, |
| 331 | .invalidatepage = v9fs_invalidate_page, |
| 332 | .launder_page = v9fs_launder_page, |
| 333 | .direct_IO = v9fs_direct_IO, |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 334 | }; |