Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/9p/vfs_file.c |
| 3 | * |
| 4 | * This file contians vfs file ops for 9P2000. |
| 5 | * |
| 6 | * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> |
| 7 | * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
Eric Van Hensbergen | 42e8c50 | 2006-03-25 03:07:28 -0800 | [diff] [blame] | 10 | * it under the terms of the GNU General Public License version 2 |
| 11 | * as published by the Free Software Foundation. |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to: |
| 20 | * Free Software Foundation |
| 21 | * 51 Franklin Street, Fifth Floor |
| 22 | * Boston, MA 02111-1301 USA |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/errno.h> |
| 28 | #include <linux/fs.h> |
Al Viro | 914e263 | 2006-10-18 13:55:46 -0400 | [diff] [blame] | 29 | #include <linux/sched.h> |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 30 | #include <linux/file.h> |
| 31 | #include <linux/stat.h> |
| 32 | #include <linux/string.h> |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 33 | #include <linux/inet.h> |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 34 | #include <linux/list.h> |
Abhishek Kulkarni | 637d020 | 2009-09-22 11:34:05 -0500 | [diff] [blame] | 35 | #include <linux/pagemap.h> |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 36 | #include <linux/utsname.h> |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 37 | #include <asm/uaccess.h> |
| 38 | #include <linux/idr.h> |
Al Viro | 070b365 | 2015-04-01 20:17:51 -0400 | [diff] [blame] | 39 | #include <linux/uio.h> |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 40 | #include <net/9p/9p.h> |
| 41 | #include <net/9p/client.h> |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 42 | |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 43 | #include "v9fs.h" |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 44 | #include "v9fs_vfs.h" |
| 45 | #include "fid.h" |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 46 | #include "cache.h" |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 47 | |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 48 | static const struct vm_operations_struct v9fs_file_vm_ops; |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 49 | static const struct vm_operations_struct v9fs_mmap_file_vm_ops; |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 50 | |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 51 | /** |
| 52 | * v9fs_file_open - open a file (or directory) |
| 53 | * @inode: inode to be opened |
| 54 | * @file: file being opened |
| 55 | * |
| 56 | */ |
| 57 | |
| 58 | int v9fs_file_open(struct inode *inode, struct file *file) |
| 59 | { |
Latchesar Ionkov | 6a3124a | 2006-03-02 02:54:30 -0800 | [diff] [blame] | 60 | int err; |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 61 | struct v9fs_inode *v9inode; |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 62 | struct v9fs_session_info *v9ses; |
| 63 | struct p9_fid *fid; |
| 64 | int omode; |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 65 | |
Joe Perches | 5d38515 | 2011-11-28 10:40:46 -0800 | [diff] [blame] | 66 | p9_debug(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file); |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 67 | v9inode = V9FS_I(inode); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 68 | v9ses = v9fs_inode2v9ses(inode); |
M. Mohan Kumar | ef56547 | 2010-06-22 19:47:50 +0530 | [diff] [blame] | 69 | if (v9fs_proto_dotl(v9ses)) |
Aneesh Kumar K.V | f88657c | 2011-08-03 19:55:32 +0530 | [diff] [blame] | 70 | omode = v9fs_open_to_dotl_flags(file->f_flags); |
M. Mohan Kumar | ef56547 | 2010-06-22 19:47:50 +0530 | [diff] [blame] | 71 | else |
| 72 | omode = v9fs_uflags2omode(file->f_flags, |
| 73 | v9fs_proto_dotu(v9ses)); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 74 | fid = file->private_data; |
| 75 | if (!fid) { |
| 76 | fid = v9fs_fid_clone(file->f_path.dentry); |
| 77 | if (IS_ERR(fid)) |
| 78 | return PTR_ERR(fid); |
| 79 | |
| 80 | err = p9_client_open(fid, omode); |
Eric Van Hensbergen | 9523a84 | 2007-07-13 13:01:27 -0500 | [diff] [blame] | 81 | if (err < 0) { |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 82 | p9_client_clunk(fid); |
| 83 | return err; |
| 84 | } |
M. Mohan Kumar | ef56547 | 2010-06-22 19:47:50 +0530 | [diff] [blame] | 85 | if ((file->f_flags & O_APPEND) && |
| 86 | (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses))) |
Eric Van Hensbergen | 2e4bef4 | 2008-06-24 17:39:39 -0500 | [diff] [blame] | 87 | generic_file_llseek(file, 0, SEEK_END); |
Latchesar Ionkov | 6a3124a | 2006-03-02 02:54:30 -0800 | [diff] [blame] | 88 | } |
| 89 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 90 | file->private_data = fid; |
Aneesh Kumar K.V | 5a7e0a8 | 2011-03-08 16:39:46 +0530 | [diff] [blame] | 91 | mutex_lock(&v9inode->v_mutex); |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 92 | if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) && |
| 93 | !v9inode->writeback_fid && |
Aneesh Kumar K.V | 7add697 | 2011-03-08 16:39:49 +0530 | [diff] [blame] | 94 | ((file->f_flags & O_ACCMODE) != O_RDONLY)) { |
Aneesh Kumar K.V | 3cf387d | 2011-02-28 17:03:57 +0530 | [diff] [blame] | 95 | /* |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 96 | * clone a fid and add it to writeback_fid |
Aneesh Kumar K.V | 3cf387d | 2011-02-28 17:03:57 +0530 | [diff] [blame] | 97 | * we do it during open time instead of |
| 98 | * page dirty time via write_begin/page_mkwrite |
| 99 | * because we want write after unlink usecase |
| 100 | * to work. |
| 101 | */ |
| 102 | fid = v9fs_writeback_fid(file->f_path.dentry); |
| 103 | if (IS_ERR(fid)) { |
| 104 | err = PTR_ERR(fid); |
Aneesh Kumar K.V | 5a7e0a8 | 2011-03-08 16:39:46 +0530 | [diff] [blame] | 105 | mutex_unlock(&v9inode->v_mutex); |
Aneesh Kumar K.V | 3cf387d | 2011-02-28 17:03:57 +0530 | [diff] [blame] | 106 | goto out_error; |
| 107 | } |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 108 | v9inode->writeback_fid = (void *) fid; |
Aneesh Kumar K.V | 3cf387d | 2011-02-28 17:03:57 +0530 | [diff] [blame] | 109 | } |
Aneesh Kumar K.V | 5a7e0a8 | 2011-03-08 16:39:46 +0530 | [diff] [blame] | 110 | mutex_unlock(&v9inode->v_mutex); |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 111 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) |
Abhishek Kulkarni | 60e78d2 | 2009-09-23 13:00:27 -0500 | [diff] [blame] | 112 | v9fs_cache_inode_set_cookie(inode, file); |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 113 | return 0; |
Aneesh Kumar K.V | 3cf387d | 2011-02-28 17:03:57 +0530 | [diff] [blame] | 114 | out_error: |
| 115 | p9_client_clunk(file->private_data); |
| 116 | file->private_data = NULL; |
| 117 | return err; |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /** |
| 121 | * v9fs_file_lock - lock a file (or directory) |
Eric Van Hensbergen | ee44399 | 2008-03-05 07:08:09 -0600 | [diff] [blame] | 122 | * @filp: file to be locked |
| 123 | * @cmd: lock command |
| 124 | * @fl: file lock structure |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 125 | * |
Eric Van Hensbergen | ee44399 | 2008-03-05 07:08:09 -0600 | [diff] [blame] | 126 | * Bugs: this looks like a local only lock, we should extend into 9P |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 127 | * by using open exclusive |
| 128 | */ |
| 129 | |
| 130 | static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl) |
| 131 | { |
| 132 | int res = 0; |
Al Viro | 496ad9a | 2013-01-23 17:07:38 -0500 | [diff] [blame] | 133 | struct inode *inode = file_inode(filp); |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 134 | |
Joe Perches | 5d38515 | 2011-11-28 10:40:46 -0800 | [diff] [blame] | 135 | p9_debug(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl); |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 136 | |
| 137 | /* No mandatory locks */ |
Sachin Prabhu | f78233d | 2010-03-13 09:03:55 -0600 | [diff] [blame] | 138 | if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK) |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 139 | return -ENOLCK; |
| 140 | |
| 141 | if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { |
OGAWA Hirofumi | 28fd129 | 2006-01-08 01:02:14 -0800 | [diff] [blame] | 142 | filemap_write_and_wait(inode->i_mapping); |
Andrew Morton | fc0ecff | 2007-02-10 01:45:39 -0800 | [diff] [blame] | 143 | invalidate_mapping_pages(&inode->i_data, 0, -1); |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | return res; |
| 147 | } |
| 148 | |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 149 | static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) |
| 150 | { |
| 151 | struct p9_flock flock; |
| 152 | struct p9_fid *fid; |
| 153 | uint8_t status; |
| 154 | int res = 0; |
| 155 | unsigned char fl_type; |
| 156 | |
| 157 | fid = filp->private_data; |
| 158 | BUG_ON(fid == NULL); |
| 159 | |
| 160 | if ((fl->fl_flags & FL_POSIX) != FL_POSIX) |
| 161 | BUG(); |
| 162 | |
| 163 | res = posix_lock_file_wait(filp, fl); |
| 164 | if (res < 0) |
| 165 | goto out; |
| 166 | |
| 167 | /* convert posix lock to p9 tlock args */ |
| 168 | memset(&flock, 0, sizeof(flock)); |
Jim Garlick | 51b8b4f | 2011-08-21 00:21:18 +0530 | [diff] [blame] | 169 | /* map the lock type */ |
| 170 | switch (fl->fl_type) { |
| 171 | case F_RDLCK: |
| 172 | flock.type = P9_LOCK_TYPE_RDLCK; |
| 173 | break; |
| 174 | case F_WRLCK: |
| 175 | flock.type = P9_LOCK_TYPE_WRLCK; |
| 176 | break; |
| 177 | case F_UNLCK: |
| 178 | flock.type = P9_LOCK_TYPE_UNLCK; |
| 179 | break; |
| 180 | } |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 181 | flock.start = fl->fl_start; |
| 182 | if (fl->fl_end == OFFSET_MAX) |
| 183 | flock.length = 0; |
| 184 | else |
| 185 | flock.length = fl->fl_end - fl->fl_start + 1; |
| 186 | flock.proc_id = fl->fl_pid; |
Will Deacon | 50192ab | 2013-08-21 18:24:47 +0100 | [diff] [blame] | 187 | flock.client_id = fid->clnt->name; |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 188 | if (IS_SETLKW(cmd)) |
| 189 | flock.flags = P9_LOCK_FLAGS_BLOCK; |
| 190 | |
| 191 | /* |
| 192 | * if its a blocked request and we get P9_LOCK_BLOCKED as the status |
| 193 | * for lock request, keep on trying |
| 194 | */ |
| 195 | for (;;) { |
| 196 | res = p9_client_lock_dotl(fid, &flock, &status); |
| 197 | if (res < 0) |
| 198 | break; |
| 199 | |
| 200 | if (status != P9_LOCK_BLOCKED) |
| 201 | break; |
| 202 | if (status == P9_LOCK_BLOCKED && !IS_SETLKW(cmd)) |
| 203 | break; |
Jim Garlick | a0ea787 | 2012-01-03 15:27:50 -0600 | [diff] [blame] | 204 | if (schedule_timeout_interruptible(P9_LOCK_TIMEOUT) != 0) |
| 205 | break; |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | /* map 9p status to VFS status */ |
| 209 | switch (status) { |
| 210 | case P9_LOCK_SUCCESS: |
| 211 | res = 0; |
| 212 | break; |
| 213 | case P9_LOCK_BLOCKED: |
| 214 | res = -EAGAIN; |
| 215 | break; |
| 216 | case P9_LOCK_ERROR: |
| 217 | case P9_LOCK_GRACE: |
| 218 | res = -ENOLCK; |
| 219 | break; |
| 220 | default: |
| 221 | BUG(); |
| 222 | } |
| 223 | |
| 224 | /* |
| 225 | * incase server returned error for lock request, revert |
| 226 | * it locally |
| 227 | */ |
| 228 | if (res < 0 && fl->fl_type != F_UNLCK) { |
| 229 | fl_type = fl->fl_type; |
| 230 | fl->fl_type = F_UNLCK; |
| 231 | res = posix_lock_file_wait(filp, fl); |
| 232 | fl->fl_type = fl_type; |
| 233 | } |
| 234 | out: |
| 235 | return res; |
| 236 | } |
| 237 | |
M. Mohan Kumar | 1d769cd | 2010-09-27 12:22:13 +0530 | [diff] [blame] | 238 | static int v9fs_file_getlock(struct file *filp, struct file_lock *fl) |
| 239 | { |
| 240 | struct p9_getlock glock; |
| 241 | struct p9_fid *fid; |
| 242 | int res = 0; |
| 243 | |
| 244 | fid = filp->private_data; |
| 245 | BUG_ON(fid == NULL); |
| 246 | |
| 247 | posix_test_lock(filp, fl); |
| 248 | /* |
| 249 | * if we have a conflicting lock locally, no need to validate |
| 250 | * with server |
| 251 | */ |
| 252 | if (fl->fl_type != F_UNLCK) |
| 253 | return res; |
| 254 | |
| 255 | /* convert posix lock to p9 tgetlock args */ |
| 256 | memset(&glock, 0, sizeof(glock)); |
Jim Garlick | 51b8b4f | 2011-08-21 00:21:18 +0530 | [diff] [blame] | 257 | glock.type = P9_LOCK_TYPE_UNLCK; |
M. Mohan Kumar | 1d769cd | 2010-09-27 12:22:13 +0530 | [diff] [blame] | 258 | glock.start = fl->fl_start; |
| 259 | if (fl->fl_end == OFFSET_MAX) |
| 260 | glock.length = 0; |
| 261 | else |
| 262 | glock.length = fl->fl_end - fl->fl_start + 1; |
| 263 | glock.proc_id = fl->fl_pid; |
Will Deacon | 50192ab | 2013-08-21 18:24:47 +0100 | [diff] [blame] | 264 | glock.client_id = fid->clnt->name; |
M. Mohan Kumar | 1d769cd | 2010-09-27 12:22:13 +0530 | [diff] [blame] | 265 | |
| 266 | res = p9_client_getlock_dotl(fid, &glock); |
| 267 | if (res < 0) |
| 268 | return res; |
Jim Garlick | 51b8b4f | 2011-08-21 00:21:18 +0530 | [diff] [blame] | 269 | /* map 9p lock type to os lock type */ |
| 270 | switch (glock.type) { |
| 271 | case P9_LOCK_TYPE_RDLCK: |
| 272 | fl->fl_type = F_RDLCK; |
| 273 | break; |
| 274 | case P9_LOCK_TYPE_WRLCK: |
| 275 | fl->fl_type = F_WRLCK; |
| 276 | break; |
| 277 | case P9_LOCK_TYPE_UNLCK: |
| 278 | fl->fl_type = F_UNLCK; |
| 279 | break; |
| 280 | } |
| 281 | if (glock.type != P9_LOCK_TYPE_UNLCK) { |
M. Mohan Kumar | 1d769cd | 2010-09-27 12:22:13 +0530 | [diff] [blame] | 282 | fl->fl_start = glock.start; |
| 283 | if (glock.length == 0) |
| 284 | fl->fl_end = OFFSET_MAX; |
| 285 | else |
| 286 | fl->fl_end = glock.start + glock.length - 1; |
| 287 | fl->fl_pid = glock.proc_id; |
Jim Garlick | 51b8b4f | 2011-08-21 00:21:18 +0530 | [diff] [blame] | 288 | } |
M. Mohan Kumar | 1d769cd | 2010-09-27 12:22:13 +0530 | [diff] [blame] | 289 | return res; |
| 290 | } |
| 291 | |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 292 | /** |
| 293 | * v9fs_file_lock_dotl - lock a file (or directory) |
| 294 | * @filp: file to be locked |
| 295 | * @cmd: lock command |
| 296 | * @fl: file lock structure |
| 297 | * |
| 298 | */ |
| 299 | |
| 300 | static int v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl) |
| 301 | { |
Al Viro | 496ad9a | 2013-01-23 17:07:38 -0500 | [diff] [blame] | 302 | struct inode *inode = file_inode(filp); |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 303 | int ret = -ENOLCK; |
| 304 | |
Al Viro | 4b8e992 | 2014-08-19 20:17:38 -0400 | [diff] [blame] | 305 | p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n", |
| 306 | filp, cmd, fl, filp); |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 307 | |
| 308 | /* No mandatory locks */ |
| 309 | if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK) |
| 310 | goto out_err; |
| 311 | |
| 312 | if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { |
| 313 | filemap_write_and_wait(inode->i_mapping); |
| 314 | invalidate_mapping_pages(&inode->i_data, 0, -1); |
| 315 | } |
| 316 | |
| 317 | if (IS_SETLK(cmd) || IS_SETLKW(cmd)) |
| 318 | ret = v9fs_file_do_lock(filp, cmd, fl); |
M. Mohan Kumar | 1d769cd | 2010-09-27 12:22:13 +0530 | [diff] [blame] | 319 | else if (IS_GETLK(cmd)) |
| 320 | ret = v9fs_file_getlock(filp, fl); |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 321 | else |
| 322 | ret = -EINVAL; |
| 323 | out_err: |
| 324 | return ret; |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * v9fs_file_flock_dotl - lock a file |
| 329 | * @filp: file to be locked |
| 330 | * @cmd: lock command |
| 331 | * @fl: file lock structure |
| 332 | * |
| 333 | */ |
| 334 | |
| 335 | static int v9fs_file_flock_dotl(struct file *filp, int cmd, |
| 336 | struct file_lock *fl) |
| 337 | { |
Al Viro | 496ad9a | 2013-01-23 17:07:38 -0500 | [diff] [blame] | 338 | struct inode *inode = file_inode(filp); |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 339 | int ret = -ENOLCK; |
| 340 | |
Al Viro | 4b8e992 | 2014-08-19 20:17:38 -0400 | [diff] [blame] | 341 | p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n", |
| 342 | filp, cmd, fl, filp); |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 343 | |
| 344 | /* No mandatory locks */ |
| 345 | if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK) |
| 346 | goto out_err; |
| 347 | |
| 348 | if (!(fl->fl_flags & FL_FLOCK)) |
| 349 | goto out_err; |
| 350 | |
| 351 | if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { |
| 352 | filemap_write_and_wait(inode->i_mapping); |
| 353 | invalidate_mapping_pages(&inode->i_data, 0, -1); |
| 354 | } |
| 355 | /* Convert flock to posix lock */ |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 356 | fl->fl_flags |= FL_POSIX; |
| 357 | fl->fl_flags ^= FL_FLOCK; |
| 358 | |
| 359 | if (IS_SETLK(cmd) | IS_SETLKW(cmd)) |
| 360 | ret = v9fs_file_do_lock(filp, cmd, fl); |
| 361 | else |
| 362 | ret = -EINVAL; |
| 363 | out_err: |
| 364 | return ret; |
| 365 | } |
| 366 | |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 367 | /** |
Eric Van Hensbergen | fbedadc | 2008-10-13 20:36:16 -0500 | [diff] [blame] | 368 | * v9fs_file_read - read from a file |
| 369 | * @filp: file pointer to read |
| 370 | * @udata: user data buffer to read data into |
| 371 | * @count: size of buffer |
| 372 | * @offset: offset at which to read data |
| 373 | * |
| 374 | */ |
| 375 | |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 376 | static ssize_t |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 377 | v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 378 | { |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 379 | struct p9_fid *fid = iocb->ki_filp->private_data; |
Al Viro | e1200fe6 | 2015-04-01 23:42:28 -0400 | [diff] [blame] | 380 | int ret, err; |
| 381 | |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 382 | p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n", |
| 383 | iov_iter_count(to), iocb->ki_pos); |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 384 | |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 385 | ret = p9_client_read(fid, iocb->ki_pos, to, &err); |
Al Viro | e1200fe6 | 2015-04-01 23:42:28 -0400 | [diff] [blame] | 386 | if (!ret) |
| 387 | return err; |
Eric Van Hensbergen | fbedadc | 2008-10-13 20:36:16 -0500 | [diff] [blame] | 388 | |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 389 | iocb->ki_pos += ret; |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 390 | return ret; |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | /** |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 394 | * v9fs_file_write - write to a file |
Eric Van Hensbergen | ee44399 | 2008-03-05 07:08:09 -0600 | [diff] [blame] | 395 | * @filp: file pointer to write |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 396 | * @data: data buffer to write data from |
| 397 | * @count: size of buffer |
| 398 | * @offset: offset at which to write data |
| 399 | * |
| 400 | */ |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 401 | static ssize_t |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 402 | v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 403 | { |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 404 | struct file *file = iocb->ki_filp; |
Aneesh Kumar K.V | 1731177 | 2011-02-28 17:03:56 +0530 | [diff] [blame] | 405 | ssize_t retval = 0; |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 406 | loff_t origin = iocb->ki_pos; |
| 407 | size_t count = iov_iter_count(from); |
Al Viro | c711a6b | 2015-04-01 22:04:46 -0400 | [diff] [blame] | 408 | int err = 0; |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 409 | |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 410 | retval = generic_write_checks(file, &origin, &count, 0); |
Harsh Prateek Bora | 3834b12 | 2010-08-03 11:55:40 +0000 | [diff] [blame] | 411 | if (retval) |
Al Viro | c711a6b | 2015-04-01 22:04:46 -0400 | [diff] [blame] | 412 | return retval; |
Harsh Prateek Bora | 3834b12 | 2010-08-03 11:55:40 +0000 | [diff] [blame] | 413 | |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 414 | iov_iter_truncate(from, count); |
Al Viro | c711a6b | 2015-04-01 22:04:46 -0400 | [diff] [blame] | 415 | |
Harsh Prateek Bora | 3834b12 | 2010-08-03 11:55:40 +0000 | [diff] [blame] | 416 | if (!count) |
Al Viro | c711a6b | 2015-04-01 22:04:46 -0400 | [diff] [blame] | 417 | return 0; |
Harsh Prateek Bora | 3834b12 | 2010-08-03 11:55:40 +0000 | [diff] [blame] | 418 | |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 419 | retval = p9_client_write(file->private_data, origin, from, &err); |
Al Viro | c711a6b | 2015-04-01 22:04:46 -0400 | [diff] [blame] | 420 | if (retval > 0) { |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 421 | struct inode *inode = file_inode(file); |
Al Viro | c711a6b | 2015-04-01 22:04:46 -0400 | [diff] [blame] | 422 | loff_t i_size; |
| 423 | unsigned long pg_start, pg_end; |
| 424 | pg_start = origin >> PAGE_CACHE_SHIFT; |
| 425 | pg_end = (origin + retval - 1) >> PAGE_CACHE_SHIFT; |
| 426 | if (inode->i_mapping && inode->i_mapping->nrpages) |
| 427 | invalidate_inode_pages2_range(inode->i_mapping, |
| 428 | pg_start, pg_end); |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 429 | origin += retval; |
Al Viro | c711a6b | 2015-04-01 22:04:46 -0400 | [diff] [blame] | 430 | i_size = i_size_read(inode); |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 431 | iocb->ki_pos = origin; |
| 432 | if (origin > i_size) { |
| 433 | inode_add_bytes(inode, origin - i_size); |
| 434 | i_size_write(inode, origin); |
Al Viro | c711a6b | 2015-04-01 22:04:46 -0400 | [diff] [blame] | 435 | } |
| 436 | return retval; |
| 437 | } |
| 438 | return err; |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 439 | } |
| 440 | |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 441 | static int v9fs_file_fsync(struct file *filp, loff_t start, loff_t end, |
| 442 | int datasync) |
M. Mohan Kumar | 7a4439c | 2010-02-08 15:36:48 -0600 | [diff] [blame] | 443 | { |
| 444 | struct p9_fid *fid; |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 445 | struct inode *inode = filp->f_mapping->host; |
M. Mohan Kumar | 7a4439c | 2010-02-08 15:36:48 -0600 | [diff] [blame] | 446 | struct p9_wstat wstat; |
| 447 | int retval; |
| 448 | |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 449 | retval = filemap_write_and_wait_range(inode->i_mapping, start, end); |
| 450 | if (retval) |
| 451 | return retval; |
| 452 | |
| 453 | mutex_lock(&inode->i_mutex); |
Joe Perches | 5d38515 | 2011-11-28 10:40:46 -0800 | [diff] [blame] | 454 | p9_debug(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync); |
M. Mohan Kumar | 7a4439c | 2010-02-08 15:36:48 -0600 | [diff] [blame] | 455 | |
| 456 | fid = filp->private_data; |
| 457 | v9fs_blank_wstat(&wstat); |
| 458 | |
| 459 | retval = p9_client_wstat(fid, &wstat); |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 460 | mutex_unlock(&inode->i_mutex); |
| 461 | |
M. Mohan Kumar | 7a4439c | 2010-02-08 15:36:48 -0600 | [diff] [blame] | 462 | return retval; |
| 463 | } |
| 464 | |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 465 | int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end, |
| 466 | int datasync) |
Venkateswararao Jujjuri (JV) | 920e65d | 2010-09-22 17:19:19 -0700 | [diff] [blame] | 467 | { |
| 468 | struct p9_fid *fid; |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 469 | struct inode *inode = filp->f_mapping->host; |
Venkateswararao Jujjuri (JV) | 920e65d | 2010-09-22 17:19:19 -0700 | [diff] [blame] | 470 | int retval; |
| 471 | |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 472 | retval = filemap_write_and_wait_range(inode->i_mapping, start, end); |
| 473 | if (retval) |
| 474 | return retval; |
| 475 | |
| 476 | mutex_lock(&inode->i_mutex); |
Joe Perches | 5d38515 | 2011-11-28 10:40:46 -0800 | [diff] [blame] | 477 | p9_debug(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync); |
Venkateswararao Jujjuri (JV) | 920e65d | 2010-09-22 17:19:19 -0700 | [diff] [blame] | 478 | |
| 479 | fid = filp->private_data; |
| 480 | |
Venkateswararao Jujjuri (JV) | b165d60 | 2010-10-22 10:13:12 -0700 | [diff] [blame] | 481 | retval = p9_client_fsync(fid, datasync); |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 482 | mutex_unlock(&inode->i_mutex); |
| 483 | |
Venkateswararao Jujjuri (JV) | 920e65d | 2010-09-22 17:19:19 -0700 | [diff] [blame] | 484 | return retval; |
| 485 | } |
| 486 | |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 487 | static int |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 488 | v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma) |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 489 | { |
| 490 | int retval; |
| 491 | |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 492 | |
| 493 | retval = generic_file_mmap(filp, vma); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 494 | if (!retval) |
| 495 | vma->vm_ops = &v9fs_file_vm_ops; |
| 496 | |
| 497 | return retval; |
| 498 | } |
| 499 | |
| 500 | static int |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 501 | v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma) |
| 502 | { |
| 503 | int retval; |
| 504 | struct inode *inode; |
| 505 | struct v9fs_inode *v9inode; |
| 506 | struct p9_fid *fid; |
| 507 | |
| 508 | inode = file_inode(filp); |
| 509 | v9inode = V9FS_I(inode); |
| 510 | mutex_lock(&v9inode->v_mutex); |
| 511 | if (!v9inode->writeback_fid && |
| 512 | (vma->vm_flags & VM_WRITE)) { |
| 513 | /* |
| 514 | * clone a fid and add it to writeback_fid |
| 515 | * we do it during mmap instead of |
| 516 | * page dirty time via write_begin/page_mkwrite |
| 517 | * because we want write after unlink usecase |
| 518 | * to work. |
| 519 | */ |
| 520 | fid = v9fs_writeback_fid(filp->f_path.dentry); |
| 521 | if (IS_ERR(fid)) { |
| 522 | retval = PTR_ERR(fid); |
| 523 | mutex_unlock(&v9inode->v_mutex); |
| 524 | return retval; |
| 525 | } |
| 526 | v9inode->writeback_fid = (void *) fid; |
| 527 | } |
| 528 | mutex_unlock(&v9inode->v_mutex); |
| 529 | |
| 530 | retval = generic_file_mmap(filp, vma); |
| 531 | if (!retval) |
| 532 | vma->vm_ops = &v9fs_mmap_file_vm_ops; |
| 533 | |
| 534 | return retval; |
| 535 | } |
| 536 | |
| 537 | static int |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 538 | v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) |
| 539 | { |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 540 | struct v9fs_inode *v9inode; |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 541 | struct page *page = vmf->page; |
| 542 | struct file *filp = vma->vm_file; |
Al Viro | 496ad9a | 2013-01-23 17:07:38 -0500 | [diff] [blame] | 543 | struct inode *inode = file_inode(filp); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 544 | |
| 545 | |
Joe Perches | 5d38515 | 2011-11-28 10:40:46 -0800 | [diff] [blame] | 546 | p9_debug(P9_DEBUG_VFS, "page %p fid %lx\n", |
| 547 | page, (unsigned long)filp->private_data); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 548 | |
Jan Kara | 120c2bc | 2012-06-12 16:20:25 +0200 | [diff] [blame] | 549 | /* Update file times before taking page lock */ |
| 550 | file_update_time(filp); |
| 551 | |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 552 | v9inode = V9FS_I(inode); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 553 | /* make sure the cache has finished storing the page */ |
| 554 | v9fs_fscache_wait_on_page_write(inode, page); |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 555 | BUG_ON(!v9inode->writeback_fid); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 556 | lock_page(page); |
| 557 | if (page->mapping != inode->i_mapping) |
| 558 | goto out_unlock; |
Darrick J. Wong | 13575ca | 2013-02-21 16:42:53 -0800 | [diff] [blame] | 559 | wait_for_stable_page(page); |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 560 | |
| 561 | return VM_FAULT_LOCKED; |
| 562 | out_unlock: |
| 563 | unlock_page(page); |
| 564 | return VM_FAULT_NOPAGE; |
| 565 | } |
| 566 | |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 567 | /** |
| 568 | * v9fs_mmap_file_read - read from a file |
| 569 | * @filp: file pointer to read |
Fabian Frederick | fd2916b | 2014-06-04 16:06:26 -0700 | [diff] [blame] | 570 | * @data: user data buffer to read data into |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 571 | * @count: size of buffer |
| 572 | * @offset: offset at which to read data |
| 573 | * |
| 574 | */ |
| 575 | static ssize_t |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 576 | v9fs_mmap_file_read_iter(struct kiocb *iocb, struct iov_iter *to) |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 577 | { |
| 578 | /* TODO: Check if there are dirty pages */ |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 579 | return v9fs_file_read_iter(iocb, to); |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 580 | } |
| 581 | |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 582 | /** |
| 583 | * v9fs_mmap_file_write - write to a file |
| 584 | * @filp: file pointer to write |
| 585 | * @data: data buffer to write data from |
| 586 | * @count: size of buffer |
| 587 | * @offset: offset at which to write data |
| 588 | * |
| 589 | */ |
| 590 | static ssize_t |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 591 | v9fs_mmap_file_write_iter(struct kiocb *iocb, struct iov_iter *from) |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 592 | { |
| 593 | /* |
| 594 | * TODO: invalidate mmaps on filp's inode between |
| 595 | * offset and offset+count |
| 596 | */ |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 597 | return v9fs_file_write_iter(iocb, from); |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | static void v9fs_mmap_vm_close(struct vm_area_struct *vma) |
| 601 | { |
| 602 | struct inode *inode; |
| 603 | |
| 604 | struct writeback_control wbc = { |
| 605 | .nr_to_write = LONG_MAX, |
| 606 | .sync_mode = WB_SYNC_ALL, |
| 607 | .range_start = vma->vm_pgoff * PAGE_SIZE, |
| 608 | /* absolute end, byte at end included */ |
| 609 | .range_end = vma->vm_pgoff * PAGE_SIZE + |
| 610 | (vma->vm_end - vma->vm_start - 1), |
| 611 | }; |
| 612 | |
| 613 | |
| 614 | p9_debug(P9_DEBUG_VFS, "9p VMA close, %p, flushing", vma); |
| 615 | |
| 616 | inode = file_inode(vma->vm_file); |
| 617 | |
| 618 | if (!mapping_cap_writeback_dirty(inode->i_mapping)) |
| 619 | wbc.nr_to_write = 0; |
| 620 | |
| 621 | might_sleep(); |
| 622 | sync_inode(inode, &wbc); |
| 623 | } |
| 624 | |
| 625 | |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 626 | static const struct vm_operations_struct v9fs_file_vm_ops = { |
| 627 | .fault = filemap_fault, |
Kirill A. Shutemov | f182036 | 2014-04-07 15:37:19 -0700 | [diff] [blame] | 628 | .map_pages = filemap_map_pages, |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 629 | .page_mkwrite = v9fs_vm_page_mkwrite, |
| 630 | }; |
| 631 | |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 632 | static const struct vm_operations_struct v9fs_mmap_file_vm_ops = { |
| 633 | .close = v9fs_mmap_vm_close, |
| 634 | .fault = filemap_fault, |
Kirill A. Shutemov | f182036 | 2014-04-07 15:37:19 -0700 | [diff] [blame] | 635 | .map_pages = filemap_map_pages, |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 636 | .page_mkwrite = v9fs_vm_page_mkwrite, |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 637 | }; |
| 638 | |
Aneesh Kumar K.V | e959b54 | 2011-02-28 17:04:04 +0530 | [diff] [blame] | 639 | |
Aneesh Kumar K.V | 29236f4 | 2011-02-28 17:03:54 +0530 | [diff] [blame] | 640 | const struct file_operations v9fs_cached_file_operations = { |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 641 | .llseek = generic_file_llseek, |
Al Viro | 42b1ab9 | 2015-04-01 23:49:24 -0400 | [diff] [blame] | 642 | .read = new_sync_read, |
Al Viro | 9565a54 | 2015-04-01 22:32:23 -0400 | [diff] [blame] | 643 | .write = new_sync_write, |
Al Viro | aad4f8b | 2014-04-02 14:33:16 -0400 | [diff] [blame] | 644 | .read_iter = generic_file_read_iter, |
Al Viro | 8174202 | 2014-04-03 03:17:43 -0400 | [diff] [blame] | 645 | .write_iter = generic_file_write_iter, |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 646 | .open = v9fs_file_open, |
| 647 | .release = v9fs_dir_release, |
| 648 | .lock = v9fs_file_lock, |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 649 | .mmap = v9fs_file_mmap, |
M. Mohan Kumar | 7a4439c | 2010-02-08 15:36:48 -0600 | [diff] [blame] | 650 | .fsync = v9fs_file_fsync, |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 651 | }; |
| 652 | |
Aneesh Kumar K.V | 29236f4 | 2011-02-28 17:03:54 +0530 | [diff] [blame] | 653 | const struct file_operations v9fs_cached_file_operations_dotl = { |
Venkateswararao Jujjuri (JV) | b04faaf | 2010-09-22 16:30:52 -0700 | [diff] [blame] | 654 | .llseek = generic_file_llseek, |
Al Viro | 42b1ab9 | 2015-04-01 23:49:24 -0400 | [diff] [blame] | 655 | .read = new_sync_read, |
Al Viro | 9565a54 | 2015-04-01 22:32:23 -0400 | [diff] [blame] | 656 | .write = new_sync_write, |
Al Viro | aad4f8b | 2014-04-02 14:33:16 -0400 | [diff] [blame] | 657 | .read_iter = generic_file_read_iter, |
Al Viro | 8174202 | 2014-04-03 03:17:43 -0400 | [diff] [blame] | 658 | .write_iter = generic_file_write_iter, |
Venkateswararao Jujjuri (JV) | b04faaf | 2010-09-22 16:30:52 -0700 | [diff] [blame] | 659 | .open = v9fs_file_open, |
| 660 | .release = v9fs_dir_release, |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 661 | .lock = v9fs_file_lock_dotl, |
| 662 | .flock = v9fs_file_flock_dotl, |
Aneesh Kumar K.V | 7263ceb | 2011-02-28 17:03:58 +0530 | [diff] [blame] | 663 | .mmap = v9fs_file_mmap, |
Venkateswararao Jujjuri (JV) | 920e65d | 2010-09-22 17:19:19 -0700 | [diff] [blame] | 664 | .fsync = v9fs_file_fsync_dotl, |
Venkateswararao Jujjuri (JV) | b04faaf | 2010-09-22 16:30:52 -0700 | [diff] [blame] | 665 | }; |
| 666 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 667 | const struct file_operations v9fs_file_operations = { |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 668 | .llseek = generic_file_llseek, |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 669 | .read = new_sync_read, |
| 670 | .write = new_sync_write, |
| 671 | .read_iter = v9fs_file_read_iter, |
| 672 | .write_iter = v9fs_file_write_iter, |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 673 | .open = v9fs_file_open, |
| 674 | .release = v9fs_dir_release, |
| 675 | .lock = v9fs_file_lock, |
Eric Van Hensbergen | 14b8869 | 2008-02-06 19:25:05 -0600 | [diff] [blame] | 676 | .mmap = generic_file_readonly_mmap, |
M. Mohan Kumar | 7a4439c | 2010-02-08 15:36:48 -0600 | [diff] [blame] | 677 | .fsync = v9fs_file_fsync, |
Eric Van Hensbergen | e69e7fe | 2005-09-09 13:04:18 -0700 | [diff] [blame] | 678 | }; |
Sripathi Kodi | 9b6533c | 2010-03-25 12:41:54 +0000 | [diff] [blame] | 679 | |
| 680 | const struct file_operations v9fs_file_operations_dotl = { |
| 681 | .llseek = generic_file_llseek, |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 682 | .read = new_sync_read, |
| 683 | .write = new_sync_write, |
| 684 | .read_iter = v9fs_file_read_iter, |
| 685 | .write_iter = v9fs_file_write_iter, |
Sripathi Kodi | 9b6533c | 2010-03-25 12:41:54 +0000 | [diff] [blame] | 686 | .open = v9fs_file_open, |
| 687 | .release = v9fs_dir_release, |
M. Mohan Kumar | a099027 | 2010-09-27 11:34:24 +0530 | [diff] [blame] | 688 | .lock = v9fs_file_lock_dotl, |
| 689 | .flock = v9fs_file_flock_dotl, |
Sripathi Kodi | 9b6533c | 2010-03-25 12:41:54 +0000 | [diff] [blame] | 690 | .mmap = generic_file_readonly_mmap, |
Venkateswararao Jujjuri (JV) | 920e65d | 2010-09-22 17:19:19 -0700 | [diff] [blame] | 691 | .fsync = v9fs_file_fsync_dotl, |
Sripathi Kodi | 9b6533c | 2010-03-25 12:41:54 +0000 | [diff] [blame] | 692 | }; |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 693 | |
| 694 | const struct file_operations v9fs_mmap_file_operations = { |
| 695 | .llseek = generic_file_llseek, |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 696 | .read = new_sync_read, |
| 697 | .write = new_sync_write, |
| 698 | .read_iter = v9fs_mmap_file_read_iter, |
| 699 | .write_iter = v9fs_mmap_file_write_iter, |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 700 | .open = v9fs_file_open, |
| 701 | .release = v9fs_dir_release, |
| 702 | .lock = v9fs_file_lock, |
| 703 | .mmap = v9fs_mmap_file_mmap, |
| 704 | .fsync = v9fs_file_fsync, |
| 705 | }; |
| 706 | |
| 707 | const struct file_operations v9fs_mmap_file_operations_dotl = { |
| 708 | .llseek = generic_file_llseek, |
Al Viro | e494b6b | 2015-04-01 23:59:57 -0400 | [diff] [blame^] | 709 | .read = new_sync_read, |
| 710 | .write = new_sync_write, |
| 711 | .read_iter = v9fs_mmap_file_read_iter, |
| 712 | .write_iter = v9fs_mmap_file_write_iter, |
Dominique Martinet | fb89b45 | 2014-01-10 13:44:09 +0100 | [diff] [blame] | 713 | .open = v9fs_file_open, |
| 714 | .release = v9fs_dir_release, |
| 715 | .lock = v9fs_file_lock_dotl, |
| 716 | .flock = v9fs_file_flock_dotl, |
| 717 | .mmap = v9fs_mmap_file_mmap, |
| 718 | .fsync = v9fs_file_fsync_dotl, |
| 719 | }; |