blob: 6e1e8f43edaceea3a7436b230c6307c90d7f16b1 [file] [log] [blame]
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -07001/*
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 Hensbergen42e8c502006-03-25 03:07:28 -080010 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070012 *
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 Viro914e2632006-10-18 13:55:46 -040029#include <linux/sched.h>
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070030#include <linux/file.h>
31#include <linux/stat.h>
32#include <linux/string.h>
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070033#include <linux/inet.h>
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070034#include <linux/list.h>
Abhishek Kulkarni637d0202009-09-22 11:34:05 -050035#include <linux/pagemap.h>
M. Mohan Kumara0990272010-09-27 11:34:24 +053036#include <linux/utsname.h>
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070037#include <asm/uaccess.h>
38#include <linux/idr.h>
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050039#include <net/9p/9p.h>
40#include <net/9p/client.h>
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070041
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070042#include "v9fs.h"
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070043#include "v9fs_vfs.h"
44#include "fid.h"
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -050045#include "cache.h"
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070046
47/**
48 * v9fs_file_open - open a file (or directory)
49 * @inode: inode to be opened
50 * @file: file being opened
51 *
52 */
53
54int v9fs_file_open(struct inode *inode, struct file *file)
55{
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -080056 int err;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050057 struct v9fs_session_info *v9ses;
58 struct p9_fid *fid;
59 int omode;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070060
M. Mohan Kumaref565472010-06-22 19:47:50 +053061 P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050062 v9ses = v9fs_inode2v9ses(inode);
M. Mohan Kumaref565472010-06-22 19:47:50 +053063 if (v9fs_proto_dotl(v9ses))
64 omode = file->f_flags;
65 else
66 omode = v9fs_uflags2omode(file->f_flags,
67 v9fs_proto_dotu(v9ses));
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050068 fid = file->private_data;
69 if (!fid) {
70 fid = v9fs_fid_clone(file->f_path.dentry);
71 if (IS_ERR(fid))
72 return PTR_ERR(fid);
73
74 err = p9_client_open(fid, omode);
Eric Van Hensbergen9523a842007-07-13 13:01:27 -050075 if (err < 0) {
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050076 p9_client_clunk(fid);
77 return err;
78 }
M. Mohan Kumaref565472010-06-22 19:47:50 +053079 if (file->f_flags & O_TRUNC) {
Abhishek Kulkarni7549ae32009-09-22 11:34:05 -050080 i_size_write(inode, 0);
Eric Van Hensbergen9523a842007-07-13 13:01:27 -050081 inode->i_blocks = 0;
82 }
M. Mohan Kumaref565472010-06-22 19:47:50 +053083 if ((file->f_flags & O_APPEND) &&
84 (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)))
Eric Van Hensbergen2e4bef42008-06-24 17:39:39 -050085 generic_file_llseek(file, 0, SEEK_END);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -080086 }
87
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050088 file->private_data = fid;
Aneesh Kumar K.V29236f42011-02-28 17:03:54 +053089#ifdef CONFIG_9P_FSCACHE
Aneesh Kumar K.V46848de2011-02-28 17:03:55 +053090 if (v9ses->cache)
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -050091 v9fs_cache_inode_set_cookie(inode, file);
Aneesh Kumar K.V29236f42011-02-28 17:03:54 +053092#endif
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070093 return 0;
94}
95
96/**
97 * v9fs_file_lock - lock a file (or directory)
Eric Van Hensbergenee443992008-03-05 07:08:09 -060098 * @filp: file to be locked
99 * @cmd: lock command
100 * @fl: file lock structure
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700101 *
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600102 * Bugs: this looks like a local only lock, we should extend into 9P
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700103 * by using open exclusive
104 */
105
106static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
107{
108 int res = 0;
Josef "Jeff" Sipekd6f787b2006-12-08 02:36:45 -0800109 struct inode *inode = filp->f_path.dentry->d_inode;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700110
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500111 P9_DPRINTK(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl);
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700112
113 /* No mandatory locks */
Sachin Prabhuf78233d2010-03-13 09:03:55 -0600114 if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700115 return -ENOLCK;
116
117 if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
OGAWA Hirofumi28fd1292006-01-08 01:02:14 -0800118 filemap_write_and_wait(inode->i_mapping);
Andrew Mortonfc0ecff2007-02-10 01:45:39 -0800119 invalidate_mapping_pages(&inode->i_data, 0, -1);
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700120 }
121
122 return res;
123}
124
M. Mohan Kumara0990272010-09-27 11:34:24 +0530125static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
126{
127 struct p9_flock flock;
128 struct p9_fid *fid;
129 uint8_t status;
130 int res = 0;
131 unsigned char fl_type;
132
133 fid = filp->private_data;
134 BUG_ON(fid == NULL);
135
136 if ((fl->fl_flags & FL_POSIX) != FL_POSIX)
137 BUG();
138
139 res = posix_lock_file_wait(filp, fl);
140 if (res < 0)
141 goto out;
142
143 /* convert posix lock to p9 tlock args */
144 memset(&flock, 0, sizeof(flock));
145 flock.type = fl->fl_type;
146 flock.start = fl->fl_start;
147 if (fl->fl_end == OFFSET_MAX)
148 flock.length = 0;
149 else
150 flock.length = fl->fl_end - fl->fl_start + 1;
151 flock.proc_id = fl->fl_pid;
152 flock.client_id = utsname()->nodename;
153 if (IS_SETLKW(cmd))
154 flock.flags = P9_LOCK_FLAGS_BLOCK;
155
156 /*
157 * if its a blocked request and we get P9_LOCK_BLOCKED as the status
158 * for lock request, keep on trying
159 */
160 for (;;) {
161 res = p9_client_lock_dotl(fid, &flock, &status);
162 if (res < 0)
163 break;
164
165 if (status != P9_LOCK_BLOCKED)
166 break;
167 if (status == P9_LOCK_BLOCKED && !IS_SETLKW(cmd))
168 break;
169 schedule_timeout_interruptible(P9_LOCK_TIMEOUT);
170 }
171
172 /* map 9p status to VFS status */
173 switch (status) {
174 case P9_LOCK_SUCCESS:
175 res = 0;
176 break;
177 case P9_LOCK_BLOCKED:
178 res = -EAGAIN;
179 break;
180 case P9_LOCK_ERROR:
181 case P9_LOCK_GRACE:
182 res = -ENOLCK;
183 break;
184 default:
185 BUG();
186 }
187
188 /*
189 * incase server returned error for lock request, revert
190 * it locally
191 */
192 if (res < 0 && fl->fl_type != F_UNLCK) {
193 fl_type = fl->fl_type;
194 fl->fl_type = F_UNLCK;
195 res = posix_lock_file_wait(filp, fl);
196 fl->fl_type = fl_type;
197 }
198out:
199 return res;
200}
201
M. Mohan Kumar1d769cd2010-09-27 12:22:13 +0530202static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
203{
204 struct p9_getlock glock;
205 struct p9_fid *fid;
206 int res = 0;
207
208 fid = filp->private_data;
209 BUG_ON(fid == NULL);
210
211 posix_test_lock(filp, fl);
212 /*
213 * if we have a conflicting lock locally, no need to validate
214 * with server
215 */
216 if (fl->fl_type != F_UNLCK)
217 return res;
218
219 /* convert posix lock to p9 tgetlock args */
220 memset(&glock, 0, sizeof(glock));
221 glock.type = fl->fl_type;
222 glock.start = fl->fl_start;
223 if (fl->fl_end == OFFSET_MAX)
224 glock.length = 0;
225 else
226 glock.length = fl->fl_end - fl->fl_start + 1;
227 glock.proc_id = fl->fl_pid;
228 glock.client_id = utsname()->nodename;
229
230 res = p9_client_getlock_dotl(fid, &glock);
231 if (res < 0)
232 return res;
233 if (glock.type != F_UNLCK) {
234 fl->fl_type = glock.type;
235 fl->fl_start = glock.start;
236 if (glock.length == 0)
237 fl->fl_end = OFFSET_MAX;
238 else
239 fl->fl_end = glock.start + glock.length - 1;
240 fl->fl_pid = glock.proc_id;
241 } else
242 fl->fl_type = F_UNLCK;
243
244 return res;
245}
246
M. Mohan Kumara0990272010-09-27 11:34:24 +0530247/**
248 * v9fs_file_lock_dotl - lock a file (or directory)
249 * @filp: file to be locked
250 * @cmd: lock command
251 * @fl: file lock structure
252 *
253 */
254
255static int v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl)
256{
257 struct inode *inode = filp->f_path.dentry->d_inode;
258 int ret = -ENOLCK;
259
260 P9_DPRINTK(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n", filp,
261 cmd, fl, filp->f_path.dentry->d_name.name);
262
263 /* No mandatory locks */
264 if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
265 goto out_err;
266
267 if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
268 filemap_write_and_wait(inode->i_mapping);
269 invalidate_mapping_pages(&inode->i_data, 0, -1);
270 }
271
272 if (IS_SETLK(cmd) || IS_SETLKW(cmd))
273 ret = v9fs_file_do_lock(filp, cmd, fl);
M. Mohan Kumar1d769cd2010-09-27 12:22:13 +0530274 else if (IS_GETLK(cmd))
275 ret = v9fs_file_getlock(filp, fl);
M. Mohan Kumara0990272010-09-27 11:34:24 +0530276 else
277 ret = -EINVAL;
278out_err:
279 return ret;
280}
281
282/**
283 * v9fs_file_flock_dotl - lock a file
284 * @filp: file to be locked
285 * @cmd: lock command
286 * @fl: file lock structure
287 *
288 */
289
290static int v9fs_file_flock_dotl(struct file *filp, int cmd,
291 struct file_lock *fl)
292{
293 struct inode *inode = filp->f_path.dentry->d_inode;
294 int ret = -ENOLCK;
295
296 P9_DPRINTK(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n", filp,
297 cmd, fl, filp->f_path.dentry->d_name.name);
298
299 /* No mandatory locks */
300 if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
301 goto out_err;
302
303 if (!(fl->fl_flags & FL_FLOCK))
304 goto out_err;
305
306 if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
307 filemap_write_and_wait(inode->i_mapping);
308 invalidate_mapping_pages(&inode->i_data, 0, -1);
309 }
310 /* Convert flock to posix lock */
311 fl->fl_owner = (fl_owner_t)filp;
312 fl->fl_start = 0;
313 fl->fl_end = OFFSET_MAX;
314 fl->fl_flags |= FL_POSIX;
315 fl->fl_flags ^= FL_FLOCK;
316
317 if (IS_SETLK(cmd) | IS_SETLKW(cmd))
318 ret = v9fs_file_do_lock(filp, cmd, fl);
319 else
320 ret = -EINVAL;
321out_err:
322 return ret;
323}
324
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700325/**
Aneesh Kumar K.V17311772011-02-28 17:03:56 +0530326 * v9fs_fid_readn - read from a fid
327 * @fid: fid to read
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700328 * @data: data buffer to read data into
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500329 * @udata: user data buffer to read data into
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700330 * @count: size of buffer
331 * @offset: offset at which to read data
332 *
333 */
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500334ssize_t
Aneesh Kumar K.V17311772011-02-28 17:03:56 +0530335v9fs_fid_readn(struct p9_fid *fid, char *data, char __user *udata, u32 count,
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500336 u64 offset)
337{
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000338 int n, total, size;
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500339
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500340 P9_DPRINTK(P9_DEBUG_VFS, "fid %d offset %llu count %d\n", fid->fid,
Aneesh Kumar K.V17311772011-02-28 17:03:56 +0530341 (long long unsigned) offset, count);
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500342 n = 0;
343 total = 0;
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000344 size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ;
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500345 do {
346 n = p9_client_read(fid, data, udata, offset, count);
347 if (n <= 0)
348 break;
349
350 if (data)
351 data += n;
352 if (udata)
353 udata += n;
354
355 offset += n;
356 count -= n;
357 total += n;
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000358 } while (count > 0 && n == size);
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500359
360 if (n < 0)
361 total = n;
362
363 return total;
364}
365
366/**
Aneesh Kumar K.V17311772011-02-28 17:03:56 +0530367 * v9fs_file_readn - read from a file
368 * @filp: file pointer to read
369 * @data: data buffer to read data into
370 * @udata: user data buffer to read data into
371 * @count: size of buffer
372 * @offset: offset at which to read data
373 *
374 */
375ssize_t
376v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
377 u64 offset)
378{
379 return v9fs_fid_readn(filp->private_data, data, udata, count, offset);
380}
381
382/**
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500383 * v9fs_file_read - read from a file
384 * @filp: file pointer to read
385 * @udata: user data buffer to read data into
386 * @count: size of buffer
387 * @offset: offset at which to read data
388 *
389 */
390
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700391static ssize_t
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500392v9fs_file_read(struct file *filp, char __user *udata, size_t count,
Latchesar Ionkov19cba8a2005-10-11 08:29:03 -0700393 loff_t * offset)
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700394{
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500395 int ret;
396 struct p9_fid *fid;
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000397 size_t size;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700398
Eric Van Hensbergenea2e7992008-10-22 18:48:45 -0500399 P9_DPRINTK(P9_DEBUG_VFS, "count %zu offset %lld\n", count, *offset);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500400 fid = filp->private_data;
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500401
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000402 size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ;
403 if (count > size)
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500404 ret = v9fs_file_readn(filp, NULL, udata, count, *offset);
405 else
406 ret = p9_client_read(fid, NULL, udata, *offset, count);
407
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500408 if (ret > 0)
409 *offset += ret;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700410
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500411 return ret;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700412}
413
Aneesh Kumar K.V17311772011-02-28 17:03:56 +0530414ssize_t
415v9fs_file_write_internal(struct inode *inode, struct p9_fid *fid,
416 const char __user *data, size_t count,
417 loff_t *offset, int invalidate)
418{
419 int n;
420 size_t total = 0;
421 struct p9_client *clnt;
422 loff_t origin = *offset;
423 unsigned long pg_start, pg_end;
424
425 P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data,
426 (int)count, (int)*offset);
427
428 clnt = fid->clnt;
429 do {
430 n = p9_client_write(fid, NULL, data+total, origin+total, count);
431 if (n <= 0)
432 break;
433 count -= n;
434 total += n;
435 } while (count > 0);
436
437 if (invalidate && (total > 0)) {
438 pg_start = origin >> PAGE_CACHE_SHIFT;
439 pg_end = (origin + total - 1) >> PAGE_CACHE_SHIFT;
440 if (inode->i_mapping && inode->i_mapping->nrpages)
441 invalidate_inode_pages2_range(inode->i_mapping,
442 pg_start, pg_end);
443 *offset += total;
444 i_size_write(inode, i_size_read(inode) + total);
445 inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
446 }
447 if (n < 0)
448 return n;
449
450 return total;
451}
452
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700453/**
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700454 * v9fs_file_write - write to a file
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600455 * @filp: file pointer to write
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700456 * @data: data buffer to write data from
457 * @count: size of buffer
458 * @offset: offset at which to write data
459 *
460 */
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700461static ssize_t
462v9fs_file_write(struct file *filp, const char __user * data,
Aneesh Kumar K.V17311772011-02-28 17:03:56 +0530463 size_t count, loff_t *offset)
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700464{
Aneesh Kumar K.V17311772011-02-28 17:03:56 +0530465 ssize_t retval = 0;
jvraofc0f2962010-03-08 22:07:02 +0000466 loff_t origin = *offset;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700467
Eric Van Hensbergendfb0ec22008-10-13 20:36:16 -0500468
Harsh Prateek Bora3834b122010-08-03 11:55:40 +0000469 retval = generic_write_checks(filp, &origin, &count, 0);
470 if (retval)
471 goto out;
472
473 retval = -EINVAL;
474 if ((ssize_t) count < 0)
475 goto out;
476 retval = 0;
477 if (!count)
478 goto out;
479
Aneesh Kumar K.V17311772011-02-28 17:03:56 +0530480 return v9fs_file_write_internal(filp->f_path.dentry->d_inode,
481 filp->private_data,
482 data, count, offset, 1);
Harsh Prateek Bora3834b122010-08-03 11:55:40 +0000483out:
484 return retval;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700485}
486
Christoph Hellwig7ea80852010-05-26 17:53:25 +0200487static int v9fs_file_fsync(struct file *filp, int datasync)
M. Mohan Kumar7a4439c2010-02-08 15:36:48 -0600488{
489 struct p9_fid *fid;
490 struct p9_wstat wstat;
491 int retval;
492
Christoph Hellwig7ea80852010-05-26 17:53:25 +0200493 P9_DPRINTK(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);
M. Mohan Kumar7a4439c2010-02-08 15:36:48 -0600494
495 fid = filp->private_data;
496 v9fs_blank_wstat(&wstat);
497
498 retval = p9_client_wstat(fid, &wstat);
499 return retval;
500}
501
Venkateswararao Jujjuri (JV)b165d602010-10-22 10:13:12 -0700502int v9fs_file_fsync_dotl(struct file *filp, int datasync)
Venkateswararao Jujjuri (JV)920e65d2010-09-22 17:19:19 -0700503{
504 struct p9_fid *fid;
505 int retval;
506
507 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_file_fsync_dotl: filp %p datasync %x\n",
508 filp, datasync);
509
510 fid = filp->private_data;
511
Venkateswararao Jujjuri (JV)b165d602010-10-22 10:13:12 -0700512 retval = p9_client_fsync(fid, datasync);
Venkateswararao Jujjuri (JV)920e65d2010-09-22 17:19:19 -0700513 return retval;
514}
515
Aneesh Kumar K.V29236f42011-02-28 17:03:54 +0530516const struct file_operations v9fs_cached_file_operations = {
Eric Van Hensbergene03abc02007-02-11 13:21:39 -0600517 .llseek = generic_file_llseek,
518 .read = do_sync_read,
519 .aio_read = generic_file_aio_read,
520 .write = v9fs_file_write,
521 .open = v9fs_file_open,
522 .release = v9fs_dir_release,
523 .lock = v9fs_file_lock,
Eric Van Hensbergen14b88692008-02-06 19:25:05 -0600524 .mmap = generic_file_readonly_mmap,
M. Mohan Kumar7a4439c2010-02-08 15:36:48 -0600525 .fsync = v9fs_file_fsync,
Eric Van Hensbergene03abc02007-02-11 13:21:39 -0600526};
527
Aneesh Kumar K.V29236f42011-02-28 17:03:54 +0530528const struct file_operations v9fs_cached_file_operations_dotl = {
Venkateswararao Jujjuri (JV)b04faaf2010-09-22 16:30:52 -0700529 .llseek = generic_file_llseek,
530 .read = do_sync_read,
531 .aio_read = generic_file_aio_read,
532 .write = v9fs_file_write,
533 .open = v9fs_file_open,
534 .release = v9fs_dir_release,
M. Mohan Kumara0990272010-09-27 11:34:24 +0530535 .lock = v9fs_file_lock_dotl,
536 .flock = v9fs_file_flock_dotl,
Venkateswararao Jujjuri (JV)b04faaf2010-09-22 16:30:52 -0700537 .mmap = generic_file_readonly_mmap,
Venkateswararao Jujjuri (JV)920e65d2010-09-22 17:19:19 -0700538 .fsync = v9fs_file_fsync_dotl,
Venkateswararao Jujjuri (JV)b04faaf2010-09-22 16:30:52 -0700539};
540
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800541const struct file_operations v9fs_file_operations = {
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700542 .llseek = generic_file_llseek,
543 .read = v9fs_file_read,
544 .write = v9fs_file_write,
545 .open = v9fs_file_open,
546 .release = v9fs_dir_release,
547 .lock = v9fs_file_lock,
Eric Van Hensbergen14b88692008-02-06 19:25:05 -0600548 .mmap = generic_file_readonly_mmap,
M. Mohan Kumar7a4439c2010-02-08 15:36:48 -0600549 .fsync = v9fs_file_fsync,
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700550};
Sripathi Kodi9b6533c2010-03-25 12:41:54 +0000551
552const struct file_operations v9fs_file_operations_dotl = {
553 .llseek = generic_file_llseek,
554 .read = v9fs_file_read,
555 .write = v9fs_file_write,
556 .open = v9fs_file_open,
557 .release = v9fs_dir_release,
M. Mohan Kumara0990272010-09-27 11:34:24 +0530558 .lock = v9fs_file_lock_dotl,
559 .flock = v9fs_file_flock_dotl,
Sripathi Kodi9b6533c2010-03-25 12:41:54 +0000560 .mmap = generic_file_readonly_mmap,
Venkateswararao Jujjuri (JV)920e65d2010-09-22 17:19:19 -0700561 .fsync = v9fs_file_fsync_dotl,
Sripathi Kodi9b6533c2010-03-25 12:41:54 +0000562};