blob: 6764ca69bc52bca1def17b05d0ad4b4dbf9a4cc1 [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Steven Whitehouse3a8a9a12006-05-18 15:09:15 -04003 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License v.2.
8 */
9
10#include <linux/sched.h>
11#include <linux/slab.h>
12#include <linux/spinlock.h>
13#include <linux/completion.h>
14#include <linux/buffer_head.h>
15#include <linux/pagemap.h>
16#include <linux/uio.h>
17#include <linux/blkdev.h>
18#include <linux/mm.h>
19#include <linux/smp_lock.h>
Steven Whitehouse18ec7d52006-02-08 11:50:51 +000020#include <linux/fs.h>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050021#include <linux/gfs2_ondisk.h>
Steven Whitehouse71b86f52006-03-28 14:14:04 -050022#include <linux/ext2_fs.h>
23#include <linux/crc32.h>
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -050024#include <linux/iflags.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000025#include <asm/uaccess.h>
26
27#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050028#include "lm_interface.h"
29#include "incore.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000030#include "bmap.h"
31#include "dir.h"
32#include "glock.h"
33#include "glops.h"
34#include "inode.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000035#include "lm.h"
36#include "log.h"
37#include "meta_io.h"
38#include "ops_file.h"
39#include "ops_vm.h"
40#include "quota.h"
41#include "rgrp.h"
42#include "trans.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050043#include "util.h"
Steven Whitehouse71b86f52006-03-28 14:14:04 -050044#include "eaops.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000045
46/* "bad" is for NFS support */
47struct filldir_bad_entry {
48 char *fbe_name;
49 unsigned int fbe_length;
50 uint64_t fbe_offset;
51 struct gfs2_inum fbe_inum;
52 unsigned int fbe_type;
53};
54
55struct filldir_bad {
56 struct gfs2_sbd *fdb_sbd;
57
58 struct filldir_bad_entry *fdb_entry;
59 unsigned int fdb_entry_num;
60 unsigned int fdb_entry_off;
61
62 char *fdb_name;
63 unsigned int fdb_name_size;
64 unsigned int fdb_name_off;
65};
66
67/* For regular, non-NFS */
68struct filldir_reg {
69 struct gfs2_sbd *fdr_sbd;
70 int fdr_prefetch;
71
72 filldir_t fdr_filldir;
73 void *fdr_opaque;
74};
75
Steven Whitehouse61a30dc2006-02-15 10:15:18 +000076/*
77 * Most fields left uninitialised to catch anybody who tries to
78 * use them. f_flags set to prevent file_accessed() from touching
79 * any other part of this. Its use is purely as a flag so that we
80 * know (in readpage()) whether or not do to locking.
81 */
82struct file gfs2_internal_file_sentinal = {
83 .f_flags = O_NOATIME|O_RDONLY,
84};
85
Steven Whitehouse18ec7d52006-02-08 11:50:51 +000086static int gfs2_read_actor(read_descriptor_t *desc, struct page *page,
87 unsigned long offset, unsigned long size)
88{
89 char *kaddr;
90 unsigned long count = desc->count;
91
92 if (size > count)
93 size = count;
94
95 kaddr = kmap(page);
96 memcpy(desc->arg.buf, kaddr + offset, size);
97 kunmap(page);
98
99 desc->count = count - size;
100 desc->written += size;
101 desc->arg.buf += size;
102 return size;
103}
104
105int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state,
106 char *buf, loff_t *pos, unsigned size)
107{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400108 struct inode *inode = &ip->i_inode;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000109 read_descriptor_t desc;
110 desc.written = 0;
111 desc.arg.buf = buf;
112 desc.count = size;
113 desc.error = 0;
Steven Whitehouse61a30dc2006-02-15 10:15:18 +0000114 do_generic_mapping_read(inode->i_mapping, ra_state,
115 &gfs2_internal_file_sentinal, pos, &desc,
116 gfs2_read_actor);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000117 return desc.written ? desc.written : desc.error;
118}
David Teiglandb3b94fa2006-01-16 16:50:04 +0000119
120/**
121 * gfs2_llseek - seek to a location in a file
122 * @file: the file
123 * @offset: the offset
124 * @origin: Where to seek from (SEEK_SET, SEEK_CUR, or SEEK_END)
125 *
126 * SEEK_END requires the glock for the file because it references the
127 * file's size.
128 *
129 * Returns: The new offset, or errno
130 */
131
132static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin)
133{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400134 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000135 struct gfs2_holder i_gh;
136 loff_t error;
137
David Teiglandb3b94fa2006-01-16 16:50:04 +0000138 if (origin == 2) {
139 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
140 &i_gh);
141 if (!error) {
142 error = remote_llseek(file, offset, origin);
143 gfs2_glock_dq_uninit(&i_gh);
144 }
145 } else
146 error = remote_llseek(file, offset, origin);
147
148 return error;
149}
150
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000151
152static ssize_t gfs2_direct_IO_read(struct kiocb *iocb, const struct iovec *iov,
153 loff_t offset, unsigned long nr_segs)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000154{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000155 struct file *file = iocb->ki_filp;
156 struct address_space *mapping = file->f_mapping;
157 ssize_t retval;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000158
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000159 retval = filemap_write_and_wait(mapping);
160 if (retval == 0) {
161 retval = mapping->a_ops->direct_IO(READ, iocb, iov, offset,
162 nr_segs);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000163 }
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000164 return retval;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000165}
166
167/**
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000168 * __gfs2_file_aio_read - The main GFS2 read function
169 *
170 * N.B. This is almost, but not quite the same as __generic_file_aio_read()
171 * the important subtle different being that inode->i_size isn't valid
172 * unless we are holding a lock, and we do this _only_ on the O_DIRECT
173 * path since otherwise locking is done entirely at the page cache
174 * layer.
David Teiglandb3b94fa2006-01-16 16:50:04 +0000175 */
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000176static ssize_t __gfs2_file_aio_read(struct kiocb *iocb,
177 const struct iovec *iov,
178 unsigned long nr_segs, loff_t *ppos)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000179{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000180 struct file *filp = iocb->ki_filp;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400181 struct gfs2_inode *ip = GFS2_I(filp->f_mapping->host);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000182 struct gfs2_holder gh;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000183 ssize_t retval;
184 unsigned long seg;
185 size_t count;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000186
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000187 count = 0;
188 for (seg = 0; seg < nr_segs; seg++) {
189 const struct iovec *iv = &iov[seg];
David Teiglandb3b94fa2006-01-16 16:50:04 +0000190
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000191 /*
192 * If any segment has a negative length, or the cumulative
193 * length ever wraps negative then return -EINVAL.
194 */
Steven Whitehoused1665e42006-02-14 11:54:42 +0000195 count += iv->iov_len;
196 if (unlikely((ssize_t)(count|iv->iov_len) < 0))
197 return -EINVAL;
198 if (access_ok(VERIFY_WRITE, iv->iov_base, iv->iov_len))
199 continue;
200 if (seg == 0)
201 return -EFAULT;
202 nr_segs = seg;
203 count -= iv->iov_len; /* This segment is no good */
204 break;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000205 }
206
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000207 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
208 if (filp->f_flags & O_DIRECT) {
209 loff_t pos = *ppos, size;
210 struct address_space *mapping;
211 struct inode *inode;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000212
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000213 mapping = filp->f_mapping;
214 inode = mapping->host;
215 retval = 0;
216 if (!count)
217 goto out; /* skip atime */
David Teiglandb3b94fa2006-01-16 16:50:04 +0000218
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000219 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
220 retval = gfs2_glock_nq_m_atime(1, &gh);
221 if (retval)
222 goto out;
Steven Whitehoused1665e42006-02-14 11:54:42 +0000223 if (gfs2_is_stuffed(ip)) {
224 gfs2_glock_dq_m(1, &gh);
225 gfs2_holder_uninit(&gh);
226 goto fallback_to_normal;
227 }
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000228 size = i_size_read(inode);
229 if (pos < size) {
Steven Whitehoused1665e42006-02-14 11:54:42 +0000230 retval = gfs2_direct_IO_read(iocb, iov, pos, nr_segs);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000231 if (retval > 0 && !is_sync_kiocb(iocb))
232 retval = -EIOCBQUEUED;
233 if (retval > 0)
234 *ppos = pos + retval;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000235 }
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000236 file_accessed(filp);
237 gfs2_glock_dq_m(1, &gh);
238 gfs2_holder_uninit(&gh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000239 goto out;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000240 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000241
Steven Whitehoused1665e42006-02-14 11:54:42 +0000242fallback_to_normal:
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000243 retval = 0;
244 if (count) {
245 for (seg = 0; seg < nr_segs; seg++) {
246 read_descriptor_t desc;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000247
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000248 desc.written = 0;
249 desc.arg.buf = iov[seg].iov_base;
250 desc.count = iov[seg].iov_len;
251 if (desc.count == 0)
252 continue;
253 desc.error = 0;
254 do_generic_file_read(filp,ppos,&desc,file_read_actor);
255 retval += desc.written;
256 if (desc.error) {
257 retval = retval ?: desc.error;
258 break;
259 }
260 }
261 }
262out:
263 return retval;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000264}
265
266/**
267 * gfs2_read - Read bytes from a file
268 * @file: The file to read from
269 * @buf: The buffer to copy into
270 * @size: The amount of data requested
271 * @offset: The current file offset
272 *
273 * Outputs: Offset - updated according to number of bytes read
274 *
275 * Returns: The number of bytes read, errno on failure
276 */
277
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000278static ssize_t gfs2_read(struct file *filp, char __user *buf, size_t size,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000279 loff_t *offset)
280{
David Teiglandb3b94fa2006-01-16 16:50:04 +0000281 struct iovec local_iov = { .iov_base = buf, .iov_len = size };
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000282 struct kiocb kiocb;
283 ssize_t ret;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000284
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000285 init_sync_kiocb(&kiocb, filp);
286 ret = __gfs2_file_aio_read(&kiocb, &local_iov, 1, offset);
287 if (-EIOCBQUEUED == ret)
288 ret = wait_on_sync_kiocb(&kiocb);
289 return ret;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000290}
291
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000292static ssize_t gfs2_file_readv(struct file *filp, const struct iovec *iov,
293 unsigned long nr_segs, loff_t *ppos)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000294{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000295 struct kiocb kiocb;
296 ssize_t ret;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000297
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000298 init_sync_kiocb(&kiocb, filp);
299 ret = __gfs2_file_aio_read(&kiocb, iov, nr_segs, ppos);
300 if (-EIOCBQUEUED == ret)
301 ret = wait_on_sync_kiocb(&kiocb);
302 return ret;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000303}
304
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000305static ssize_t gfs2_file_aio_read(struct kiocb *iocb, char __user *buf,
306 size_t count, loff_t pos)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000307{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000308 struct iovec local_iov = { .iov_base = buf, .iov_len = count };
David Teiglandb3b94fa2006-01-16 16:50:04 +0000309
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000310 BUG_ON(iocb->ki_pos != pos);
311 return __gfs2_file_aio_read(iocb, &local_iov, 1, &iocb->ki_pos);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000312}
313
David Teiglandb3b94fa2006-01-16 16:50:04 +0000314
315/**
316 * filldir_reg_func - Report a directory entry to the caller of gfs2_dir_read()
317 * @opaque: opaque data used by the function
318 * @name: the name of the directory entry
319 * @length: the length of the name
320 * @offset: the entry's offset in the directory
321 * @inum: the inode number the entry points to
322 * @type: the type of inode the entry points to
323 *
324 * Returns: 0 on success, 1 if buffer full
325 */
326
327static int filldir_reg_func(void *opaque, const char *name, unsigned int length,
328 uint64_t offset, struct gfs2_inum *inum,
329 unsigned int type)
330{
331 struct filldir_reg *fdr = (struct filldir_reg *)opaque;
332 struct gfs2_sbd *sdp = fdr->fdr_sbd;
333 int error;
334
335 error = fdr->fdr_filldir(fdr->fdr_opaque, name, length, offset,
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400336 inum->no_addr, type);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000337 if (error)
338 return 1;
339
340 if (fdr->fdr_prefetch && !(length == 1 && *name == '.')) {
341 gfs2_glock_prefetch_num(sdp,
342 inum->no_addr, &gfs2_inode_glops,
343 LM_ST_SHARED, LM_FLAG_TRY | LM_FLAG_ANY);
344 gfs2_glock_prefetch_num(sdp,
345 inum->no_addr, &gfs2_iopen_glops,
346 LM_ST_SHARED, LM_FLAG_TRY);
347 }
348
349 return 0;
350}
351
352/**
353 * readdir_reg - Read directory entries from a directory
354 * @file: The directory to read from
355 * @dirent: Buffer for dirents
356 * @filldir: Function used to do the copying
357 *
358 * Returns: errno
359 */
360
361static int readdir_reg(struct file *file, void *dirent, filldir_t filldir)
362{
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500363 struct inode *dir = file->f_mapping->host;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400364 struct gfs2_inode *dip = GFS2_I(dir);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000365 struct filldir_reg fdr;
366 struct gfs2_holder d_gh;
367 uint64_t offset = file->f_pos;
368 int error;
369
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400370 fdr.fdr_sbd = GFS2_SB(dir);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000371 fdr.fdr_prefetch = 1;
372 fdr.fdr_filldir = filldir;
373 fdr.fdr_opaque = dirent;
374
375 gfs2_holder_init(dip->i_gl, LM_ST_SHARED, GL_ATIME, &d_gh);
376 error = gfs2_glock_nq_atime(&d_gh);
377 if (error) {
378 gfs2_holder_uninit(&d_gh);
379 return error;
380 }
381
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500382 error = gfs2_dir_read(dir, &offset, &fdr, filldir_reg_func);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000383
384 gfs2_glock_dq_uninit(&d_gh);
385
386 file->f_pos = offset;
387
388 return error;
389}
390
391/**
392 * filldir_bad_func - Report a directory entry to the caller of gfs2_dir_read()
393 * @opaque: opaque data used by the function
394 * @name: the name of the directory entry
395 * @length: the length of the name
396 * @offset: the entry's offset in the directory
397 * @inum: the inode number the entry points to
398 * @type: the type of inode the entry points to
399 *
400 * For supporting NFS.
401 *
402 * Returns: 0 on success, 1 if buffer full
403 */
404
405static int filldir_bad_func(void *opaque, const char *name, unsigned int length,
406 uint64_t offset, struct gfs2_inum *inum,
407 unsigned int type)
408{
409 struct filldir_bad *fdb = (struct filldir_bad *)opaque;
410 struct gfs2_sbd *sdp = fdb->fdb_sbd;
411 struct filldir_bad_entry *fbe;
412
413 if (fdb->fdb_entry_off == fdb->fdb_entry_num ||
414 fdb->fdb_name_off + length > fdb->fdb_name_size)
415 return 1;
416
417 fbe = &fdb->fdb_entry[fdb->fdb_entry_off];
418 fbe->fbe_name = fdb->fdb_name + fdb->fdb_name_off;
419 memcpy(fbe->fbe_name, name, length);
420 fbe->fbe_length = length;
421 fbe->fbe_offset = offset;
422 fbe->fbe_inum = *inum;
423 fbe->fbe_type = type;
424
425 fdb->fdb_entry_off++;
426 fdb->fdb_name_off += length;
427
428 if (!(length == 1 && *name == '.')) {
429 gfs2_glock_prefetch_num(sdp,
430 inum->no_addr, &gfs2_inode_glops,
431 LM_ST_SHARED, LM_FLAG_TRY | LM_FLAG_ANY);
432 gfs2_glock_prefetch_num(sdp,
433 inum->no_addr, &gfs2_iopen_glops,
434 LM_ST_SHARED, LM_FLAG_TRY);
435 }
436
437 return 0;
438}
439
440/**
441 * readdir_bad - Read directory entries from a directory
442 * @file: The directory to read from
443 * @dirent: Buffer for dirents
444 * @filldir: Function used to do the copying
445 *
446 * For supporting NFS.
447 *
448 * Returns: errno
449 */
450
451static int readdir_bad(struct file *file, void *dirent, filldir_t filldir)
452{
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500453 struct inode *dir = file->f_mapping->host;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400454 struct gfs2_inode *dip = GFS2_I(dir);
455 struct gfs2_sbd *sdp = GFS2_SB(dir);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000456 struct filldir_reg fdr;
457 unsigned int entries, size;
458 struct filldir_bad *fdb;
459 struct gfs2_holder d_gh;
460 uint64_t offset = file->f_pos;
461 unsigned int x;
462 struct filldir_bad_entry *fbe;
463 int error;
464
465 entries = gfs2_tune_get(sdp, gt_entries_per_readdir);
466 size = sizeof(struct filldir_bad) +
467 entries * (sizeof(struct filldir_bad_entry) + GFS2_FAST_NAME_SIZE);
468
469 fdb = kzalloc(size, GFP_KERNEL);
470 if (!fdb)
471 return -ENOMEM;
472
473 fdb->fdb_sbd = sdp;
474 fdb->fdb_entry = (struct filldir_bad_entry *)(fdb + 1);
475 fdb->fdb_entry_num = entries;
476 fdb->fdb_name = ((char *)fdb) + sizeof(struct filldir_bad) +
477 entries * sizeof(struct filldir_bad_entry);
478 fdb->fdb_name_size = entries * GFS2_FAST_NAME_SIZE;
479
480 gfs2_holder_init(dip->i_gl, LM_ST_SHARED, GL_ATIME, &d_gh);
481 error = gfs2_glock_nq_atime(&d_gh);
482 if (error) {
483 gfs2_holder_uninit(&d_gh);
484 goto out;
485 }
486
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500487 error = gfs2_dir_read(dir, &offset, fdb, filldir_bad_func);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000488
489 gfs2_glock_dq_uninit(&d_gh);
490
491 fdr.fdr_sbd = sdp;
492 fdr.fdr_prefetch = 0;
493 fdr.fdr_filldir = filldir;
494 fdr.fdr_opaque = dirent;
495
496 for (x = 0; x < fdb->fdb_entry_off; x++) {
497 fbe = &fdb->fdb_entry[x];
498
499 error = filldir_reg_func(&fdr,
500 fbe->fbe_name, fbe->fbe_length,
501 fbe->fbe_offset,
502 &fbe->fbe_inum, fbe->fbe_type);
503 if (error) {
504 file->f_pos = fbe->fbe_offset;
505 error = 0;
506 goto out;
507 }
508 }
509
510 file->f_pos = offset;
511
512 out:
513 kfree(fdb);
514
515 return error;
516}
517
518/**
519 * gfs2_readdir - Read directory entries from a directory
520 * @file: The directory to read from
521 * @dirent: Buffer for dirents
522 * @filldir: Function used to do the copying
523 *
524 * Returns: errno
525 */
526
527static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir)
528{
529 int error;
530
David Teiglandb3b94fa2006-01-16 16:50:04 +0000531 if (strcmp(current->comm, "nfsd") != 0)
532 error = readdir_reg(file, dirent, filldir);
533 else
534 error = readdir_bad(file, dirent, filldir);
535
536 return error;
537}
538
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -0500539static const u32 iflags_to_gfs2[32] = {
540 [iflag_Sync] = GFS2_DIF_SYNC,
541 [iflag_Immutable] = GFS2_DIF_IMMUTABLE,
542 [iflag_Append] = GFS2_DIF_APPENDONLY,
543 [iflag_NoAtime] = GFS2_DIF_NOATIME,
544 [iflag_Index] = GFS2_DIF_EXHASH,
545 [iflag_JournalData] = GFS2_DIF_JDATA,
546 [iflag_DirectIO] = GFS2_DIF_DIRECTIO,
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500547};
548
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -0500549static const u32 gfs2_to_iflags[32] = {
550 [gfs2fl_Sync] = IFLAG_SYNC,
551 [gfs2fl_Immutable] = IFLAG_IMMUTABLE,
552 [gfs2fl_AppendOnly] = IFLAG_APPEND,
553 [gfs2fl_NoAtime] = IFLAG_NOATIME,
554 [gfs2fl_ExHash] = IFLAG_INDEX,
555 [gfs2fl_Jdata] = IFLAG_JOURNAL_DATA,
556 [gfs2fl_Directio] = IFLAG_DIRECTIO,
Steven Whitehouse4bcf7092006-04-25 13:20:27 -0400557 [gfs2fl_InheritDirectio] = IFLAG_DIRECTIO,
558 [gfs2fl_InheritJdata] = IFLAG_JOURNAL_DATA,
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -0500559};
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500560
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400561static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500562{
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400563 struct inode *inode = filp->f_dentry->d_inode;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400564 struct gfs2_inode *ip = GFS2_I(inode);
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500565 struct gfs2_holder gh;
566 int error;
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -0500567 u32 iflags;
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500568
569 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
570 error = gfs2_glock_nq_m_atime(1, &gh);
571 if (error)
572 return error;
Steven Whitehouse55eccc62006-04-04 14:29:30 -0400573
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -0500574 iflags = iflags_cvt(gfs2_to_iflags, ip->i_di.di_flags);
575 if (put_user(iflags, ptr))
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500576 error = -EFAULT;
577
578 gfs2_glock_dq_m(1, &gh);
579 gfs2_holder_uninit(&gh);
580 return error;
581}
582
583/* Flags that can be set by user space */
584#define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA| \
585 GFS2_DIF_DIRECTIO| \
586 GFS2_DIF_IMMUTABLE| \
587 GFS2_DIF_APPENDONLY| \
588 GFS2_DIF_NOATIME| \
589 GFS2_DIF_SYNC| \
590 GFS2_DIF_SYSTEM| \
591 GFS2_DIF_INHERIT_DIRECTIO| \
592 GFS2_DIF_INHERIT_JDATA)
593
594/**
595 * gfs2_set_flags - set flags on an inode
596 * @inode: The inode
597 * @flags: The flags to set
598 * @mask: Indicates which flags are valid
599 *
600 */
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400601static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500602{
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400603 struct inode *inode = filp->f_dentry->d_inode;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400604 struct gfs2_inode *ip = GFS2_I(inode);
605 struct gfs2_sbd *sdp = GFS2_SB(inode);
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500606 struct buffer_head *bh;
607 struct gfs2_holder gh;
608 int error;
Steven Whitehouse55eccc62006-04-04 14:29:30 -0400609 u32 new_flags, flags;
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500610
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500611 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
Abhijith Das52f341c2006-07-21 02:03:21 -0400612 if (error)
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500613 return error;
614
Steven Whitehouse55eccc62006-04-04 14:29:30 -0400615 flags = ip->i_di.di_flags;
616 new_flags = (flags & ~mask) | (reqflags & mask);
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500617 if ((new_flags ^ flags) == 0)
618 goto out;
619
Steven Whitehouse4bcf7092006-04-25 13:20:27 -0400620 if (S_ISDIR(inode->i_mode)) {
621 if ((new_flags ^ flags) & GFS2_DIF_JDATA)
622 new_flags ^= (GFS2_DIF_JDATA|GFS2_DIF_INHERIT_JDATA);
623 if ((new_flags ^ flags) & GFS2_DIF_DIRECTIO)
624 new_flags ^= (GFS2_DIF_DIRECTIO|GFS2_DIF_INHERIT_DIRECTIO);
625 }
626
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500627 error = -EINVAL;
628 if ((new_flags ^ flags) & ~GFS2_FLAGS_USER_SET)
629 goto out;
630
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500631 error = -EPERM;
632 if (IS_IMMUTABLE(inode) && (new_flags & GFS2_DIF_IMMUTABLE))
633 goto out;
634 if (IS_APPEND(inode) && (new_flags & GFS2_DIF_APPENDONLY))
635 goto out;
Steven Whitehouseb9cb9812006-05-12 17:07:56 -0400636 if (((new_flags ^ flags) & GFS2_DIF_IMMUTABLE) &&
637 !capable(CAP_LINUX_IMMUTABLE))
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500638 goto out;
Steven Whitehouseb9cb9812006-05-12 17:07:56 -0400639 if (!IS_IMMUTABLE(inode)) {
Steven Whitehousefaf450e2006-06-22 10:59:10 -0400640 error = permission(inode, MAY_WRITE, NULL);
Steven Whitehouseb9cb9812006-05-12 17:07:56 -0400641 if (error)
642 goto out;
643 }
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500644
Steven Whitehouse55eccc62006-04-04 14:29:30 -0400645 error = gfs2_trans_begin(sdp, RES_DINODE, 0);
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500646 if (error)
647 goto out;
Steven Whitehouse55eccc62006-04-04 14:29:30 -0400648 error = gfs2_meta_inode_buffer(ip, &bh);
649 if (error)
650 goto out_trans_end;
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500651 gfs2_trans_add_bh(ip->i_gl, bh, 1);
652 ip->i_di.di_flags = new_flags;
653 gfs2_dinode_out(&ip->i_di, bh->b_data);
654 brelse(bh);
Steven Whitehouse55eccc62006-04-04 14:29:30 -0400655out_trans_end:
656 gfs2_trans_end(sdp);
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500657out:
658 gfs2_glock_dq_uninit(&gh);
659 return error;
660}
661
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400662static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500663{
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -0500664 u32 iflags, gfsflags;
665 if (get_user(iflags, ptr))
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500666 return -EFAULT;
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -0500667 gfsflags = iflags_cvt(iflags_to_gfs2, iflags);
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400668 return do_gfs2_set_flags(filp, gfsflags, ~0);
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500669}
670
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400671static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500672{
673 switch(cmd) {
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -0500674 case IFLAGS_GET_IOC:
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400675 return gfs2_get_flags(filp, (u32 __user *)arg);
Steven Whitehouse7ea9ea82006-03-31 15:01:28 -0500676 case IFLAGS_SET_IOC:
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400677 return gfs2_set_flags(filp, (u32 __user *)arg);
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500678 }
679 return -ENOTTY;
680}
681
682
David Teiglandb3b94fa2006-01-16 16:50:04 +0000683/**
684 * gfs2_mmap -
685 * @file: The file to map
686 * @vma: The VMA which described the mapping
687 *
688 * Returns: 0 or error code
689 */
690
691static int gfs2_mmap(struct file *file, struct vm_area_struct *vma)
692{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400693 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000694 struct gfs2_holder i_gh;
695 int error;
696
David Teiglandb3b94fa2006-01-16 16:50:04 +0000697 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &i_gh);
698 error = gfs2_glock_nq_atime(&i_gh);
699 if (error) {
700 gfs2_holder_uninit(&i_gh);
701 return error;
702 }
703
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000704 /* This is VM_MAYWRITE instead of VM_WRITE because a call
705 to mprotect() can turn on VM_WRITE later. */
David Teiglandb3b94fa2006-01-16 16:50:04 +0000706
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000707 if ((vma->vm_flags & (VM_MAYSHARE | VM_MAYWRITE)) ==
708 (VM_MAYSHARE | VM_MAYWRITE))
709 vma->vm_ops = &gfs2_vm_ops_sharewrite;
710 else
711 vma->vm_ops = &gfs2_vm_ops_private;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000712
713 gfs2_glock_dq_uninit(&i_gh);
714
715 return error;
716}
717
718/**
719 * gfs2_open - open a file
720 * @inode: the inode to open
721 * @file: the struct file for this opening
722 *
723 * Returns: errno
724 */
725
726static int gfs2_open(struct inode *inode, struct file *file)
727{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400728 struct gfs2_inode *ip = GFS2_I(inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000729 struct gfs2_holder i_gh;
730 struct gfs2_file *fp;
731 int error;
732
David Teiglandb3b94fa2006-01-16 16:50:04 +0000733 fp = kzalloc(sizeof(struct gfs2_file), GFP_KERNEL);
734 if (!fp)
735 return -ENOMEM;
736
Steven Whitehousef55ab262006-02-21 12:51:39 +0000737 mutex_init(&fp->f_fl_mutex);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000738
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400739 gfs2_assert_warn(GFS2_SB(inode), !file->private_data);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500740 file->private_data = fp;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000741
742 if (S_ISREG(ip->i_di.di_mode)) {
743 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
744 &i_gh);
745 if (error)
746 goto fail;
747
748 if (!(file->f_flags & O_LARGEFILE) &&
749 ip->i_di.di_size > MAX_NON_LFS) {
750 error = -EFBIG;
751 goto fail_gunlock;
752 }
753
754 /* Listen to the Direct I/O flag */
755
756 if (ip->i_di.di_flags & GFS2_DIF_DIRECTIO)
757 file->f_flags |= O_DIRECT;
758
David Teiglandb3b94fa2006-01-16 16:50:04 +0000759 gfs2_glock_dq_uninit(&i_gh);
760 }
761
762 return 0;
763
764 fail_gunlock:
765 gfs2_glock_dq_uninit(&i_gh);
766
767 fail:
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500768 file->private_data = NULL;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000769 kfree(fp);
770
771 return error;
772}
773
774/**
775 * gfs2_close - called to close a struct file
776 * @inode: the inode the struct file belongs to
777 * @file: the struct file being closed
778 *
779 * Returns: errno
780 */
781
782static int gfs2_close(struct inode *inode, struct file *file)
783{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500784 struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000785 struct gfs2_file *fp;
786
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500787 fp = file->private_data;
788 file->private_data = NULL;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000789
790 if (gfs2_assert_warn(sdp, fp))
791 return -EIO;
792
793 kfree(fp);
794
795 return 0;
796}
797
798/**
799 * gfs2_fsync - sync the dirty data for a file (across the cluster)
800 * @file: the file that points to the dentry (we ignore this)
801 * @dentry: the dentry that points to the inode to sync
802 *
803 * Returns: errno
804 */
805
806static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
807{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400808 struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000809
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400810 gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000811
812 return 0;
813}
814
815/**
816 * gfs2_lock - acquire/release a posix lock on a file
817 * @file: the file pointer
818 * @cmd: either modify or retrieve lock state, possibly wait
819 * @fl: type and range of lock
820 *
821 * Returns: errno
822 */
823
824static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
825{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400826 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
827 struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000828 struct lm_lockname name =
829 { .ln_number = ip->i_num.no_addr,
830 .ln_type = LM_TYPE_PLOCK };
831
David Teiglandb3b94fa2006-01-16 16:50:04 +0000832 if (!(fl->fl_flags & FL_POSIX))
833 return -ENOLCK;
834 if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
835 return -ENOLCK;
836
837 if (sdp->sd_args.ar_localflocks) {
838 if (IS_GETLK(cmd)) {
Steven Whitehouse8628de02006-03-31 16:48:41 -0500839 struct file_lock tmp;
840 int ret;
841 ret = posix_test_lock(file, fl, &tmp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000842 fl->fl_type = F_UNLCK;
Steven Whitehouse8628de02006-03-31 16:48:41 -0500843 if (ret)
844 memcpy(fl, &tmp, sizeof(struct file_lock));
David Teiglandb3b94fa2006-01-16 16:50:04 +0000845 return 0;
846 } else {
Steven Whitehouse8628de02006-03-31 16:48:41 -0500847 return posix_lock_file_wait(file, fl);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000848 }
849 }
850
851 if (IS_GETLK(cmd))
852 return gfs2_lm_plock_get(sdp, &name, file, fl);
853 else if (fl->fl_type == F_UNLCK)
854 return gfs2_lm_punlock(sdp, &name, file, fl);
855 else
856 return gfs2_lm_plock(sdp, &name, file, cmd, fl);
857}
858
David Teiglandb3b94fa2006-01-16 16:50:04 +0000859static int do_flock(struct file *file, int cmd, struct file_lock *fl)
860{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500861 struct gfs2_file *fp = file->private_data;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000862 struct gfs2_holder *fl_gh = &fp->f_fl_gh;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400863 struct gfs2_inode *ip = GFS2_I(file->f_dentry->d_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000864 struct gfs2_glock *gl;
865 unsigned int state;
866 int flags;
867 int error = 0;
868
869 state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
870 flags = ((IS_SETLKW(cmd)) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE;
871
Steven Whitehousef55ab262006-02-21 12:51:39 +0000872 mutex_lock(&fp->f_fl_mutex);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000873
874 gl = fl_gh->gh_gl;
875 if (gl) {
876 if (fl_gh->gh_state == state)
877 goto out;
878 gfs2_glock_hold(gl);
879 flock_lock_file_wait(file,
880 &(struct file_lock){.fl_type = F_UNLCK});
881 gfs2_glock_dq_uninit(fl_gh);
882 } else {
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400883 error = gfs2_glock_get(GFS2_SB(&ip->i_inode),
David Teiglandb3b94fa2006-01-16 16:50:04 +0000884 ip->i_num.no_addr, &gfs2_flock_glops,
885 CREATE, &gl);
886 if (error)
887 goto out;
888 }
889
890 gfs2_holder_init(gl, state, flags, fl_gh);
891 gfs2_glock_put(gl);
892
893 error = gfs2_glock_nq(fl_gh);
894 if (error) {
895 gfs2_holder_uninit(fl_gh);
896 if (error == GLR_TRYFAILED)
897 error = -EAGAIN;
898 } else {
899 error = flock_lock_file_wait(file, fl);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400900 gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000901 }
902
903 out:
Steven Whitehousef55ab262006-02-21 12:51:39 +0000904 mutex_unlock(&fp->f_fl_mutex);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000905
906 return error;
907}
908
909static void do_unflock(struct file *file, struct file_lock *fl)
910{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500911 struct gfs2_file *fp = file->private_data;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000912 struct gfs2_holder *fl_gh = &fp->f_fl_gh;
913
Steven Whitehousef55ab262006-02-21 12:51:39 +0000914 mutex_lock(&fp->f_fl_mutex);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000915 flock_lock_file_wait(file, fl);
916 if (fl_gh->gh_gl)
917 gfs2_glock_dq_uninit(fl_gh);
Steven Whitehousef55ab262006-02-21 12:51:39 +0000918 mutex_unlock(&fp->f_fl_mutex);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000919}
920
921/**
922 * gfs2_flock - acquire/release a flock lock on a file
923 * @file: the file pointer
924 * @cmd: either modify or retrieve lock state, possibly wait
925 * @fl: type and range of lock
926 *
927 * Returns: errno
928 */
929
930static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)
931{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400932 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
933 struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000934
David Teiglandb3b94fa2006-01-16 16:50:04 +0000935 if (!(fl->fl_flags & FL_FLOCK))
936 return -ENOLCK;
937 if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
938 return -ENOLCK;
939
940 if (sdp->sd_args.ar_localflocks)
941 return flock_lock_file_wait(file, fl);
942
943 if (fl->fl_type == F_UNLCK) {
944 do_unflock(file, fl);
945 return 0;
946 } else
947 return do_flock(file, cmd, fl);
948}
949
Steven Whitehouseb0dd9302006-07-03 13:47:02 -0400950const struct file_operations gfs2_file_fops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000951 .llseek = gfs2_llseek,
952 .read = gfs2_read,
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000953 .readv = gfs2_file_readv,
954 .aio_read = gfs2_file_aio_read,
955 .write = generic_file_write,
956 .writev = generic_file_writev,
957 .aio_write = generic_file_aio_write,
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400958 .unlocked_ioctl = gfs2_ioctl,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000959 .mmap = gfs2_mmap,
960 .open = gfs2_open,
961 .release = gfs2_close,
962 .fsync = gfs2_fsync,
963 .lock = gfs2_lock,
Steven Whitehousea53311d2006-06-23 16:16:29 -0400964 .sendfile = generic_file_sendfile,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000965 .flock = gfs2_flock,
Steven Whitehouse8628de02006-03-31 16:48:41 -0500966 .splice_read = generic_file_splice_read,
967 .splice_write = generic_file_splice_write,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000968};
969
Steven Whitehouseb0dd9302006-07-03 13:47:02 -0400970const struct file_operations gfs2_dir_fops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000971 .readdir = gfs2_readdir,
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400972 .unlocked_ioctl = gfs2_ioctl,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000973 .open = gfs2_open,
974 .release = gfs2_close,
975 .fsync = gfs2_fsync,
976 .lock = gfs2_lock,
977 .flock = gfs2_flock,
978};
979