blob: 6a671000263f05a9f5923d66e772cbb43c227b83 [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
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050090 if ((fid->qid.version) && (v9ses->cache)) {
91 P9_DPRINTK(P9_DEBUG_VFS, "cached");
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -050092 v9fs_cache_inode_set_cookie(inode, file);
Eric Van Hensbergene03abc02007-02-11 13:21:39 -060093 }
Aneesh Kumar K.V29236f42011-02-28 17:03:54 +053094#endif
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -070095 return 0;
96}
97
98/**
99 * v9fs_file_lock - lock a file (or directory)
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600100 * @filp: file to be locked
101 * @cmd: lock command
102 * @fl: file lock structure
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700103 *
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600104 * Bugs: this looks like a local only lock, we should extend into 9P
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700105 * by using open exclusive
106 */
107
108static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
109{
110 int res = 0;
Josef "Jeff" Sipekd6f787b2006-12-08 02:36:45 -0800111 struct inode *inode = filp->f_path.dentry->d_inode;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700112
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500113 P9_DPRINTK(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl);
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700114
115 /* No mandatory locks */
Sachin Prabhuf78233d2010-03-13 09:03:55 -0600116 if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700117 return -ENOLCK;
118
119 if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
OGAWA Hirofumi28fd1292006-01-08 01:02:14 -0800120 filemap_write_and_wait(inode->i_mapping);
Andrew Mortonfc0ecff2007-02-10 01:45:39 -0800121 invalidate_mapping_pages(&inode->i_data, 0, -1);
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700122 }
123
124 return res;
125}
126
M. Mohan Kumara0990272010-09-27 11:34:24 +0530127static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
128{
129 struct p9_flock flock;
130 struct p9_fid *fid;
131 uint8_t status;
132 int res = 0;
133 unsigned char fl_type;
134
135 fid = filp->private_data;
136 BUG_ON(fid == NULL);
137
138 if ((fl->fl_flags & FL_POSIX) != FL_POSIX)
139 BUG();
140
141 res = posix_lock_file_wait(filp, fl);
142 if (res < 0)
143 goto out;
144
145 /* convert posix lock to p9 tlock args */
146 memset(&flock, 0, sizeof(flock));
147 flock.type = fl->fl_type;
148 flock.start = fl->fl_start;
149 if (fl->fl_end == OFFSET_MAX)
150 flock.length = 0;
151 else
152 flock.length = fl->fl_end - fl->fl_start + 1;
153 flock.proc_id = fl->fl_pid;
154 flock.client_id = utsname()->nodename;
155 if (IS_SETLKW(cmd))
156 flock.flags = P9_LOCK_FLAGS_BLOCK;
157
158 /*
159 * if its a blocked request and we get P9_LOCK_BLOCKED as the status
160 * for lock request, keep on trying
161 */
162 for (;;) {
163 res = p9_client_lock_dotl(fid, &flock, &status);
164 if (res < 0)
165 break;
166
167 if (status != P9_LOCK_BLOCKED)
168 break;
169 if (status == P9_LOCK_BLOCKED && !IS_SETLKW(cmd))
170 break;
171 schedule_timeout_interruptible(P9_LOCK_TIMEOUT);
172 }
173
174 /* map 9p status to VFS status */
175 switch (status) {
176 case P9_LOCK_SUCCESS:
177 res = 0;
178 break;
179 case P9_LOCK_BLOCKED:
180 res = -EAGAIN;
181 break;
182 case P9_LOCK_ERROR:
183 case P9_LOCK_GRACE:
184 res = -ENOLCK;
185 break;
186 default:
187 BUG();
188 }
189
190 /*
191 * incase server returned error for lock request, revert
192 * it locally
193 */
194 if (res < 0 && fl->fl_type != F_UNLCK) {
195 fl_type = fl->fl_type;
196 fl->fl_type = F_UNLCK;
197 res = posix_lock_file_wait(filp, fl);
198 fl->fl_type = fl_type;
199 }
200out:
201 return res;
202}
203
M. Mohan Kumar1d769cd2010-09-27 12:22:13 +0530204static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
205{
206 struct p9_getlock glock;
207 struct p9_fid *fid;
208 int res = 0;
209
210 fid = filp->private_data;
211 BUG_ON(fid == NULL);
212
213 posix_test_lock(filp, fl);
214 /*
215 * if we have a conflicting lock locally, no need to validate
216 * with server
217 */
218 if (fl->fl_type != F_UNLCK)
219 return res;
220
221 /* convert posix lock to p9 tgetlock args */
222 memset(&glock, 0, sizeof(glock));
223 glock.type = fl->fl_type;
224 glock.start = fl->fl_start;
225 if (fl->fl_end == OFFSET_MAX)
226 glock.length = 0;
227 else
228 glock.length = fl->fl_end - fl->fl_start + 1;
229 glock.proc_id = fl->fl_pid;
230 glock.client_id = utsname()->nodename;
231
232 res = p9_client_getlock_dotl(fid, &glock);
233 if (res < 0)
234 return res;
235 if (glock.type != F_UNLCK) {
236 fl->fl_type = glock.type;
237 fl->fl_start = glock.start;
238 if (glock.length == 0)
239 fl->fl_end = OFFSET_MAX;
240 else
241 fl->fl_end = glock.start + glock.length - 1;
242 fl->fl_pid = glock.proc_id;
243 } else
244 fl->fl_type = F_UNLCK;
245
246 return res;
247}
248
M. Mohan Kumara0990272010-09-27 11:34:24 +0530249/**
250 * v9fs_file_lock_dotl - lock a file (or directory)
251 * @filp: file to be locked
252 * @cmd: lock command
253 * @fl: file lock structure
254 *
255 */
256
257static int v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl)
258{
259 struct inode *inode = filp->f_path.dentry->d_inode;
260 int ret = -ENOLCK;
261
262 P9_DPRINTK(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n", filp,
263 cmd, fl, filp->f_path.dentry->d_name.name);
264
265 /* No mandatory locks */
266 if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
267 goto out_err;
268
269 if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
270 filemap_write_and_wait(inode->i_mapping);
271 invalidate_mapping_pages(&inode->i_data, 0, -1);
272 }
273
274 if (IS_SETLK(cmd) || IS_SETLKW(cmd))
275 ret = v9fs_file_do_lock(filp, cmd, fl);
M. Mohan Kumar1d769cd2010-09-27 12:22:13 +0530276 else if (IS_GETLK(cmd))
277 ret = v9fs_file_getlock(filp, fl);
M. Mohan Kumara0990272010-09-27 11:34:24 +0530278 else
279 ret = -EINVAL;
280out_err:
281 return ret;
282}
283
284/**
285 * v9fs_file_flock_dotl - lock a file
286 * @filp: file to be locked
287 * @cmd: lock command
288 * @fl: file lock structure
289 *
290 */
291
292static int v9fs_file_flock_dotl(struct file *filp, int cmd,
293 struct file_lock *fl)
294{
295 struct inode *inode = filp->f_path.dentry->d_inode;
296 int ret = -ENOLCK;
297
298 P9_DPRINTK(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n", filp,
299 cmd, fl, filp->f_path.dentry->d_name.name);
300
301 /* No mandatory locks */
302 if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
303 goto out_err;
304
305 if (!(fl->fl_flags & FL_FLOCK))
306 goto out_err;
307
308 if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
309 filemap_write_and_wait(inode->i_mapping);
310 invalidate_mapping_pages(&inode->i_data, 0, -1);
311 }
312 /* Convert flock to posix lock */
313 fl->fl_owner = (fl_owner_t)filp;
314 fl->fl_start = 0;
315 fl->fl_end = OFFSET_MAX;
316 fl->fl_flags |= FL_POSIX;
317 fl->fl_flags ^= FL_FLOCK;
318
319 if (IS_SETLK(cmd) | IS_SETLKW(cmd))
320 ret = v9fs_file_do_lock(filp, cmd, fl);
321 else
322 ret = -EINVAL;
323out_err:
324 return ret;
325}
326
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700327/**
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500328 * v9fs_file_readn - read from a file
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600329 * @filp: file pointer to read
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700330 * @data: data buffer to read data into
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500331 * @udata: user data buffer to read data into
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700332 * @count: size of buffer
333 * @offset: offset at which to read data
334 *
335 */
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500336
337ssize_t
338v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
339 u64 offset)
340{
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000341 int n, total, size;
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500342 struct p9_fid *fid = filp->private_data;
343
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500344 P9_DPRINTK(P9_DEBUG_VFS, "fid %d offset %llu count %d\n", fid->fid,
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500345 (long long unsigned) offset, count);
346
347 n = 0;
348 total = 0;
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000349 size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ;
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500350 do {
351 n = p9_client_read(fid, data, udata, offset, count);
352 if (n <= 0)
353 break;
354
355 if (data)
356 data += n;
357 if (udata)
358 udata += n;
359
360 offset += n;
361 count -= n;
362 total += n;
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000363 } while (count > 0 && n == size);
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500364
365 if (n < 0)
366 total = n;
367
368 return total;
369}
370
371/**
372 * v9fs_file_read - read from a file
373 * @filp: file pointer to read
374 * @udata: user data buffer to read data into
375 * @count: size of buffer
376 * @offset: offset at which to read data
377 *
378 */
379
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700380static ssize_t
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500381v9fs_file_read(struct file *filp, char __user *udata, size_t count,
Latchesar Ionkov19cba8a2005-10-11 08:29:03 -0700382 loff_t * offset)
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700383{
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500384 int ret;
385 struct p9_fid *fid;
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000386 size_t size;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700387
Eric Van Hensbergenea2e7992008-10-22 18:48:45 -0500388 P9_DPRINTK(P9_DEBUG_VFS, "count %zu offset %lld\n", count, *offset);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500389 fid = filp->private_data;
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500390
M. Mohan Kumar97e84422010-06-04 11:59:07 +0000391 size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ;
392 if (count > size)
Eric Van Hensbergenfbedadc2008-10-13 20:36:16 -0500393 ret = v9fs_file_readn(filp, NULL, udata, count, *offset);
394 else
395 ret = p9_client_read(fid, NULL, udata, *offset, count);
396
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500397 if (ret > 0)
398 *offset += ret;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700399
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500400 return ret;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700401}
402
403/**
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700404 * v9fs_file_write - write to a file
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600405 * @filp: file pointer to write
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700406 * @data: data buffer to write data from
407 * @count: size of buffer
408 * @offset: offset at which to write data
409 *
410 */
411
412static ssize_t
413v9fs_file_write(struct file *filp, const char __user * data,
414 size_t count, loff_t * offset)
415{
Harsh Prateek Bora3834b122010-08-03 11:55:40 +0000416 ssize_t retval;
417 size_t total = 0;
jvrao8d40fa22010-08-30 13:23:20 -0500418 int n;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500419 struct p9_fid *fid;
Eric Van Hensbergendfb0ec22008-10-13 20:36:16 -0500420 struct p9_client *clnt;
Eric Van Hensbergen9523a842007-07-13 13:01:27 -0500421 struct inode *inode = filp->f_path.dentry->d_inode;
jvraofc0f2962010-03-08 22:07:02 +0000422 loff_t origin = *offset;
Abhishek Kulkarni637d0202009-09-22 11:34:05 -0500423 unsigned long pg_start, pg_end;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700424
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500425 P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data,
426 (int)count, (int)*offset);
Latchesar Ionkov19cba8a2005-10-11 08:29:03 -0700427
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500428 fid = filp->private_data;
Eric Van Hensbergendfb0ec22008-10-13 20:36:16 -0500429 clnt = fid->clnt;
430
Harsh Prateek Bora3834b122010-08-03 11:55:40 +0000431 retval = generic_write_checks(filp, &origin, &count, 0);
432 if (retval)
433 goto out;
434
435 retval = -EINVAL;
436 if ((ssize_t) count < 0)
437 goto out;
438 retval = 0;
439 if (!count)
440 goto out;
441
Eric Van Hensbergendfb0ec22008-10-13 20:36:16 -0500442 do {
jvrao8d40fa22010-08-30 13:23:20 -0500443 n = p9_client_write(fid, NULL, data+total, origin+total, count);
Eric Van Hensbergendfb0ec22008-10-13 20:36:16 -0500444 if (n <= 0)
445 break;
446 count -= n;
447 total += n;
448 } while (count > 0);
449
450 if (total > 0) {
Abhishek Kulkarni637d0202009-09-22 11:34:05 -0500451 pg_start = origin >> PAGE_CACHE_SHIFT;
452 pg_end = (origin + total - 1) >> PAGE_CACHE_SHIFT;
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -0500453 if (inode->i_mapping && inode->i_mapping->nrpages)
454 invalidate_inode_pages2_range(inode->i_mapping,
455 pg_start, pg_end);
Eric Van Hensbergendfb0ec22008-10-13 20:36:16 -0500456 *offset += total;
Abhishek Kulkarni637d0202009-09-22 11:34:05 -0500457 i_size_write(inode, i_size_read(inode) + total);
Abhishek Kulkarni7549ae32009-09-22 11:34:05 -0500458 inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
Eric Van Hensbergen9523a842007-07-13 13:01:27 -0500459 }
460
Eric Van Hensbergendfb0ec22008-10-13 20:36:16 -0500461 if (n < 0)
Harsh Prateek Bora3834b122010-08-03 11:55:40 +0000462 retval = n;
463 else
464 retval = total;
465out:
466 return retval;
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700467}
468
Christoph Hellwig7ea80852010-05-26 17:53:25 +0200469static int v9fs_file_fsync(struct file *filp, int datasync)
M. Mohan Kumar7a4439c2010-02-08 15:36:48 -0600470{
471 struct p9_fid *fid;
472 struct p9_wstat wstat;
473 int retval;
474
Christoph Hellwig7ea80852010-05-26 17:53:25 +0200475 P9_DPRINTK(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);
M. Mohan Kumar7a4439c2010-02-08 15:36:48 -0600476
477 fid = filp->private_data;
478 v9fs_blank_wstat(&wstat);
479
480 retval = p9_client_wstat(fid, &wstat);
481 return retval;
482}
483
Venkateswararao Jujjuri (JV)b165d602010-10-22 10:13:12 -0700484int v9fs_file_fsync_dotl(struct file *filp, int datasync)
Venkateswararao Jujjuri (JV)920e65d2010-09-22 17:19:19 -0700485{
486 struct p9_fid *fid;
487 int retval;
488
489 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_file_fsync_dotl: filp %p datasync %x\n",
490 filp, datasync);
491
492 fid = filp->private_data;
493
Venkateswararao Jujjuri (JV)b165d602010-10-22 10:13:12 -0700494 retval = p9_client_fsync(fid, datasync);
Venkateswararao Jujjuri (JV)920e65d2010-09-22 17:19:19 -0700495 return retval;
496}
497
Aneesh Kumar K.V29236f42011-02-28 17:03:54 +0530498const struct file_operations v9fs_cached_file_operations = {
Eric Van Hensbergene03abc02007-02-11 13:21:39 -0600499 .llseek = generic_file_llseek,
500 .read = do_sync_read,
501 .aio_read = generic_file_aio_read,
502 .write = v9fs_file_write,
503 .open = v9fs_file_open,
504 .release = v9fs_dir_release,
505 .lock = v9fs_file_lock,
Eric Van Hensbergen14b88692008-02-06 19:25:05 -0600506 .mmap = generic_file_readonly_mmap,
M. Mohan Kumar7a4439c2010-02-08 15:36:48 -0600507 .fsync = v9fs_file_fsync,
Eric Van Hensbergene03abc02007-02-11 13:21:39 -0600508};
509
Aneesh Kumar K.V29236f42011-02-28 17:03:54 +0530510const struct file_operations v9fs_cached_file_operations_dotl = {
Venkateswararao Jujjuri (JV)b04faaf2010-09-22 16:30:52 -0700511 .llseek = generic_file_llseek,
512 .read = do_sync_read,
513 .aio_read = generic_file_aio_read,
514 .write = v9fs_file_write,
515 .open = v9fs_file_open,
516 .release = v9fs_dir_release,
M. Mohan Kumara0990272010-09-27 11:34:24 +0530517 .lock = v9fs_file_lock_dotl,
518 .flock = v9fs_file_flock_dotl,
Venkateswararao Jujjuri (JV)b04faaf2010-09-22 16:30:52 -0700519 .mmap = generic_file_readonly_mmap,
Venkateswararao Jujjuri (JV)920e65d2010-09-22 17:19:19 -0700520 .fsync = v9fs_file_fsync_dotl,
Venkateswararao Jujjuri (JV)b04faaf2010-09-22 16:30:52 -0700521};
522
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800523const struct file_operations v9fs_file_operations = {
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700524 .llseek = generic_file_llseek,
525 .read = v9fs_file_read,
526 .write = v9fs_file_write,
527 .open = v9fs_file_open,
528 .release = v9fs_dir_release,
529 .lock = v9fs_file_lock,
Eric Van Hensbergen14b88692008-02-06 19:25:05 -0600530 .mmap = generic_file_readonly_mmap,
M. Mohan Kumar7a4439c2010-02-08 15:36:48 -0600531 .fsync = v9fs_file_fsync,
Eric Van Hensbergene69e7fe2005-09-09 13:04:18 -0700532};
Sripathi Kodi9b6533c2010-03-25 12:41:54 +0000533
534const struct file_operations v9fs_file_operations_dotl = {
535 .llseek = generic_file_llseek,
536 .read = v9fs_file_read,
537 .write = v9fs_file_write,
538 .open = v9fs_file_open,
539 .release = v9fs_dir_release,
M. Mohan Kumara0990272010-09-27 11:34:24 +0530540 .lock = v9fs_file_lock_dotl,
541 .flock = v9fs_file_flock_dotl,
Sripathi Kodi9b6533c2010-03-25 12:41:54 +0000542 .mmap = generic_file_readonly_mmap,
Venkateswararao Jujjuri (JV)920e65d2010-09-22 17:19:19 -0700543 .fsync = v9fs_file_fsync_dotl,
Sripathi Kodi9b6533c2010-03-25 12:41:54 +0000544};