2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
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.
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>
19 #include <linux/smp_lock.h>
20 #include <linux/gfs2_ioctl.h>
22 #include <asm/semaphore.h>
23 #include <asm/uaccess.h>
40 /* "bad" is for NFS support */
41 struct filldir_bad_entry {
43 unsigned int fbe_length;
45 struct gfs2_inum fbe_inum;
46 unsigned int fbe_type;
50 struct gfs2_sbd *fdb_sbd;
52 struct filldir_bad_entry *fdb_entry;
53 unsigned int fdb_entry_num;
54 unsigned int fdb_entry_off;
57 unsigned int fdb_name_size;
58 unsigned int fdb_name_off;
61 /* For regular, non-NFS */
63 struct gfs2_sbd *fdr_sbd;
66 filldir_t fdr_filldir;
71 * Most fields left uninitialised to catch anybody who tries to
72 * use them. f_flags set to prevent file_accessed() from touching
73 * any other part of this. Its use is purely as a flag so that we
74 * know (in readpage()) whether or not do to locking.
76 struct file gfs2_internal_file_sentinal = {
77 .f_flags = O_NOATIME|O_RDONLY,
80 static int gfs2_read_actor(read_descriptor_t *desc, struct page *page,
81 unsigned long offset, unsigned long size)
84 unsigned long count = desc->count;
90 memcpy(desc->arg.buf, kaddr + offset, size);
93 desc->count = count - size;
94 desc->written += size;
95 desc->arg.buf += size;
99 int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state,
100 char *buf, loff_t *pos, unsigned size)
102 struct inode *inode = ip->i_vnode;
103 read_descriptor_t desc;
108 do_generic_mapping_read(inode->i_mapping, ra_state,
109 &gfs2_internal_file_sentinal, pos, &desc,
111 return desc.written ? desc.written : desc.error;
115 * gfs2_llseek - seek to a location in a file
117 * @offset: the offset
118 * @origin: Where to seek from (SEEK_SET, SEEK_CUR, or SEEK_END)
120 * SEEK_END requires the glock for the file because it references the
123 * Returns: The new offset, or errno
126 static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin)
128 struct gfs2_inode *ip = get_v2ip(file->f_mapping->host);
129 struct gfs2_holder i_gh;
132 atomic_inc(&ip->i_sbd->sd_ops_file);
135 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
138 error = remote_llseek(file, offset, origin);
139 gfs2_glock_dq_uninit(&i_gh);
142 error = remote_llseek(file, offset, origin);
148 static ssize_t gfs2_direct_IO_read(struct kiocb *iocb, const struct iovec *iov,
149 loff_t offset, unsigned long nr_segs)
151 struct file *file = iocb->ki_filp;
152 struct address_space *mapping = file->f_mapping;
155 retval = filemap_write_and_wait(mapping);
157 retval = mapping->a_ops->direct_IO(READ, iocb, iov, offset,
164 * __gfs2_file_aio_read - The main GFS2 read function
166 * N.B. This is almost, but not quite the same as __generic_file_aio_read()
167 * the important subtle different being that inode->i_size isn't valid
168 * unless we are holding a lock, and we do this _only_ on the O_DIRECT
169 * path since otherwise locking is done entirely at the page cache
172 static ssize_t __gfs2_file_aio_read(struct kiocb *iocb,
173 const struct iovec *iov,
174 unsigned long nr_segs, loff_t *ppos)
176 struct file *filp = iocb->ki_filp;
177 struct gfs2_inode *ip = get_v2ip(filp->f_mapping->host);
178 struct gfs2_holder gh;
184 for (seg = 0; seg < nr_segs; seg++) {
185 const struct iovec *iv = &iov[seg];
188 * If any segment has a negative length, or the cumulative
189 * length ever wraps negative then return -EINVAL.
191 count += iv->iov_len;
192 if (unlikely((ssize_t)(count|iv->iov_len) < 0))
194 if (access_ok(VERIFY_WRITE, iv->iov_base, iv->iov_len))
199 count -= iv->iov_len; /* This segment is no good */
203 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
204 if (filp->f_flags & O_DIRECT) {
205 loff_t pos = *ppos, size;
206 struct address_space *mapping;
209 mapping = filp->f_mapping;
210 inode = mapping->host;
213 goto out; /* skip atime */
215 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
216 retval = gfs2_glock_nq_m_atime(1, &gh);
219 if (gfs2_is_stuffed(ip)) {
220 gfs2_glock_dq_m(1, &gh);
221 gfs2_holder_uninit(&gh);
222 goto fallback_to_normal;
224 size = i_size_read(inode);
226 retval = gfs2_direct_IO_read(iocb, iov, pos, nr_segs);
227 if (retval > 0 && !is_sync_kiocb(iocb))
228 retval = -EIOCBQUEUED;
230 *ppos = pos + retval;
233 gfs2_glock_dq_m(1, &gh);
234 gfs2_holder_uninit(&gh);
241 for (seg = 0; seg < nr_segs; seg++) {
242 read_descriptor_t desc;
245 desc.arg.buf = iov[seg].iov_base;
246 desc.count = iov[seg].iov_len;
250 do_generic_file_read(filp,ppos,&desc,file_read_actor);
251 retval += desc.written;
253 retval = retval ?: desc.error;
263 * gfs2_read - Read bytes from a file
264 * @file: The file to read from
265 * @buf: The buffer to copy into
266 * @size: The amount of data requested
267 * @offset: The current file offset
269 * Outputs: Offset - updated according to number of bytes read
271 * Returns: The number of bytes read, errno on failure
274 static ssize_t gfs2_read(struct file *filp, char __user *buf, size_t size,
277 struct iovec local_iov = { .iov_base = buf, .iov_len = size };
281 atomic_inc(&get_v2sdp(filp->f_mapping->host->i_sb)->sd_ops_file);
283 init_sync_kiocb(&kiocb, filp);
284 ret = __gfs2_file_aio_read(&kiocb, &local_iov, 1, offset);
285 if (-EIOCBQUEUED == ret)
286 ret = wait_on_sync_kiocb(&kiocb);
290 static ssize_t gfs2_file_readv(struct file *filp, const struct iovec *iov,
291 unsigned long nr_segs, loff_t *ppos)
296 atomic_inc(&get_v2sdp(filp->f_mapping->host->i_sb)->sd_ops_file);
298 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);
305 static ssize_t gfs2_file_aio_read(struct kiocb *iocb, char __user *buf,
306 size_t count, loff_t pos)
308 struct file *filp = iocb->ki_filp;
309 struct iovec local_iov = { .iov_base = buf, .iov_len = count };
311 atomic_inc(&get_v2sdp(filp->f_mapping->host->i_sb)->sd_ops_file);
313 BUG_ON(iocb->ki_pos != pos);
314 return __gfs2_file_aio_read(iocb, &local_iov, 1, &iocb->ki_pos);
319 * filldir_reg_func - Report a directory entry to the caller of gfs2_dir_read()
320 * @opaque: opaque data used by the function
321 * @name: the name of the directory entry
322 * @length: the length of the name
323 * @offset: the entry's offset in the directory
324 * @inum: the inode number the entry points to
325 * @type: the type of inode the entry points to
327 * Returns: 0 on success, 1 if buffer full
330 static int filldir_reg_func(void *opaque, const char *name, unsigned int length,
331 uint64_t offset, struct gfs2_inum *inum,
334 struct filldir_reg *fdr = (struct filldir_reg *)opaque;
335 struct gfs2_sbd *sdp = fdr->fdr_sbd;
338 error = fdr->fdr_filldir(fdr->fdr_opaque, name, length, offset,
339 inum->no_formal_ino, type);
343 if (fdr->fdr_prefetch && !(length == 1 && *name == '.')) {
344 gfs2_glock_prefetch_num(sdp,
345 inum->no_addr, &gfs2_inode_glops,
346 LM_ST_SHARED, LM_FLAG_TRY | LM_FLAG_ANY);
347 gfs2_glock_prefetch_num(sdp,
348 inum->no_addr, &gfs2_iopen_glops,
349 LM_ST_SHARED, LM_FLAG_TRY);
356 * readdir_reg - Read directory entries from a directory
357 * @file: The directory to read from
358 * @dirent: Buffer for dirents
359 * @filldir: Function used to do the copying
364 static int readdir_reg(struct file *file, void *dirent, filldir_t filldir)
366 struct gfs2_inode *dip = get_v2ip(file->f_mapping->host);
367 struct filldir_reg fdr;
368 struct gfs2_holder d_gh;
369 uint64_t offset = file->f_pos;
372 fdr.fdr_sbd = dip->i_sbd;
373 fdr.fdr_prefetch = 1;
374 fdr.fdr_filldir = filldir;
375 fdr.fdr_opaque = dirent;
377 gfs2_holder_init(dip->i_gl, LM_ST_SHARED, GL_ATIME, &d_gh);
378 error = gfs2_glock_nq_atime(&d_gh);
380 gfs2_holder_uninit(&d_gh);
384 error = gfs2_dir_read(dip, &offset, &fdr, filldir_reg_func);
386 gfs2_glock_dq_uninit(&d_gh);
388 file->f_pos = offset;
394 * filldir_bad_func - Report a directory entry to the caller of gfs2_dir_read()
395 * @opaque: opaque data used by the function
396 * @name: the name of the directory entry
397 * @length: the length of the name
398 * @offset: the entry's offset in the directory
399 * @inum: the inode number the entry points to
400 * @type: the type of inode the entry points to
402 * For supporting NFS.
404 * Returns: 0 on success, 1 if buffer full
407 static int filldir_bad_func(void *opaque, const char *name, unsigned int length,
408 uint64_t offset, struct gfs2_inum *inum,
411 struct filldir_bad *fdb = (struct filldir_bad *)opaque;
412 struct gfs2_sbd *sdp = fdb->fdb_sbd;
413 struct filldir_bad_entry *fbe;
415 if (fdb->fdb_entry_off == fdb->fdb_entry_num ||
416 fdb->fdb_name_off + length > fdb->fdb_name_size)
419 fbe = &fdb->fdb_entry[fdb->fdb_entry_off];
420 fbe->fbe_name = fdb->fdb_name + fdb->fdb_name_off;
421 memcpy(fbe->fbe_name, name, length);
422 fbe->fbe_length = length;
423 fbe->fbe_offset = offset;
424 fbe->fbe_inum = *inum;
425 fbe->fbe_type = type;
427 fdb->fdb_entry_off++;
428 fdb->fdb_name_off += length;
430 if (!(length == 1 && *name == '.')) {
431 gfs2_glock_prefetch_num(sdp,
432 inum->no_addr, &gfs2_inode_glops,
433 LM_ST_SHARED, LM_FLAG_TRY | LM_FLAG_ANY);
434 gfs2_glock_prefetch_num(sdp,
435 inum->no_addr, &gfs2_iopen_glops,
436 LM_ST_SHARED, LM_FLAG_TRY);
443 * readdir_bad - Read directory entries from a directory
444 * @file: The directory to read from
445 * @dirent: Buffer for dirents
446 * @filldir: Function used to do the copying
448 * For supporting NFS.
453 static int readdir_bad(struct file *file, void *dirent, filldir_t filldir)
455 struct gfs2_inode *dip = get_v2ip(file->f_mapping->host);
456 struct gfs2_sbd *sdp = dip->i_sbd;
457 struct filldir_reg fdr;
458 unsigned int entries, size;
459 struct filldir_bad *fdb;
460 struct gfs2_holder d_gh;
461 uint64_t offset = file->f_pos;
463 struct filldir_bad_entry *fbe;
466 entries = gfs2_tune_get(sdp, gt_entries_per_readdir);
467 size = sizeof(struct filldir_bad) +
468 entries * (sizeof(struct filldir_bad_entry) + GFS2_FAST_NAME_SIZE);
470 fdb = kzalloc(size, GFP_KERNEL);
475 fdb->fdb_entry = (struct filldir_bad_entry *)(fdb + 1);
476 fdb->fdb_entry_num = entries;
477 fdb->fdb_name = ((char *)fdb) + sizeof(struct filldir_bad) +
478 entries * sizeof(struct filldir_bad_entry);
479 fdb->fdb_name_size = entries * GFS2_FAST_NAME_SIZE;
481 gfs2_holder_init(dip->i_gl, LM_ST_SHARED, GL_ATIME, &d_gh);
482 error = gfs2_glock_nq_atime(&d_gh);
484 gfs2_holder_uninit(&d_gh);
488 error = gfs2_dir_read(dip, &offset, fdb, filldir_bad_func);
490 gfs2_glock_dq_uninit(&d_gh);
493 fdr.fdr_prefetch = 0;
494 fdr.fdr_filldir = filldir;
495 fdr.fdr_opaque = dirent;
497 for (x = 0; x < fdb->fdb_entry_off; x++) {
498 fbe = &fdb->fdb_entry[x];
500 error = filldir_reg_func(&fdr,
501 fbe->fbe_name, fbe->fbe_length,
503 &fbe->fbe_inum, fbe->fbe_type);
505 file->f_pos = fbe->fbe_offset;
511 file->f_pos = offset;
520 * gfs2_readdir - Read directory entries from a directory
521 * @file: The directory to read from
522 * @dirent: Buffer for dirents
523 * @filldir: Function used to do the copying
528 static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir)
532 atomic_inc(&get_v2sdp(file->f_mapping->host->i_sb)->sd_ops_file);
534 if (strcmp(current->comm, "nfsd") != 0)
535 error = readdir_reg(file, dirent, filldir);
537 error = readdir_bad(file, dirent, filldir);
542 static int gfs2_ioctl_flags(struct gfs2_inode *ip, unsigned int cmd, unsigned long arg)
544 unsigned int lmode = (cmd == GFS2_IOCTL_SETFLAGS) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
545 struct buffer_head *dibh;
546 struct gfs2_holder i_gh;
548 __u32 flags = 0, change;
550 if (cmd == GFS2_IOCTL_SETFLAGS) {
551 error = get_user(flags, (__u32 __user *)arg);
556 error = gfs2_glock_nq_init(ip->i_gl, lmode, 0, &i_gh);
560 if (cmd == GFS2_IOCTL_SETFLAGS) {
561 change = flags ^ ip->i_di.di_flags;
563 if (change & (GFS2_DIF_IMMUTABLE|GFS2_DIF_APPENDONLY)) {
564 if (!capable(CAP_LINUX_IMMUTABLE))
568 if (flags & (GFS2_DIF_JDATA|GFS2_DIF_DIRECTIO)) {
569 if (!S_ISREG(ip->i_di.di_mode))
572 if (flags & (GFS2_DIF_INHERIT_JDATA|GFS2_DIF_INHERIT_DIRECTIO)) {
573 if (!S_ISDIR(ip->i_di.di_mode))
577 error = gfs2_trans_begin(ip->i_sbd, RES_DINODE, 0);
581 error = gfs2_meta_inode_buffer(ip, &dibh);
585 ip->i_di.di_flags = flags;
587 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
588 gfs2_dinode_out(&ip->i_di, dibh->b_data);
593 gfs2_trans_end(ip->i_sbd);
595 flags = ip->i_di.di_flags;
598 gfs2_glock_dq_uninit(&i_gh);
599 if (cmd == GFS2_IOCTL_GETFLAGS) {
600 if (put_user(flags, (__u32 __user *)arg))
607 * gfs2_ioctl - do an ioctl on a file
609 * @file: the file pointer
610 * @cmd: the ioctl command
616 static int gfs2_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
619 struct gfs2_inode *ip = get_v2ip(inode);
621 atomic_inc(&ip->i_sbd->sd_ops_file);
624 case GFS2_IOCTL_SETFLAGS:
625 case GFS2_IOCTL_GETFLAGS:
626 return gfs2_ioctl_flags(ip, cmd, arg);
635 * @file: The file to map
636 * @vma: The VMA which described the mapping
638 * Returns: 0 or error code
641 static int gfs2_mmap(struct file *file, struct vm_area_struct *vma)
643 struct gfs2_inode *ip = get_v2ip(file->f_mapping->host);
644 struct gfs2_holder i_gh;
647 atomic_inc(&ip->i_sbd->sd_ops_file);
649 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &i_gh);
650 error = gfs2_glock_nq_atime(&i_gh);
652 gfs2_holder_uninit(&i_gh);
656 /* This is VM_MAYWRITE instead of VM_WRITE because a call
657 to mprotect() can turn on VM_WRITE later. */
659 if ((vma->vm_flags & (VM_MAYSHARE | VM_MAYWRITE)) ==
660 (VM_MAYSHARE | VM_MAYWRITE))
661 vma->vm_ops = &gfs2_vm_ops_sharewrite;
663 vma->vm_ops = &gfs2_vm_ops_private;
665 gfs2_glock_dq_uninit(&i_gh);
671 * gfs2_open - open a file
672 * @inode: the inode to open
673 * @file: the struct file for this opening
678 static int gfs2_open(struct inode *inode, struct file *file)
680 struct gfs2_inode *ip = get_v2ip(inode);
681 struct gfs2_holder i_gh;
682 struct gfs2_file *fp;
685 atomic_inc(&ip->i_sbd->sd_ops_file);
687 fp = kzalloc(sizeof(struct gfs2_file), GFP_KERNEL);
691 mutex_init(&fp->f_fl_mutex);
696 gfs2_assert_warn(ip->i_sbd, !get_v2fp(file));
699 if (S_ISREG(ip->i_di.di_mode)) {
700 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
705 if (!(file->f_flags & O_LARGEFILE) &&
706 ip->i_di.di_size > MAX_NON_LFS) {
711 /* Listen to the Direct I/O flag */
713 if (ip->i_di.di_flags & GFS2_DIF_DIRECTIO)
714 file->f_flags |= O_DIRECT;
716 gfs2_glock_dq_uninit(&i_gh);
722 gfs2_glock_dq_uninit(&i_gh);
725 set_v2fp(file, NULL);
732 * gfs2_close - called to close a struct file
733 * @inode: the inode the struct file belongs to
734 * @file: the struct file being closed
739 static int gfs2_close(struct inode *inode, struct file *file)
741 struct gfs2_sbd *sdp = get_v2sdp(inode->i_sb);
742 struct gfs2_file *fp;
744 atomic_inc(&sdp->sd_ops_file);
747 set_v2fp(file, NULL);
749 if (gfs2_assert_warn(sdp, fp))
758 * gfs2_fsync - sync the dirty data for a file (across the cluster)
759 * @file: the file that points to the dentry (we ignore this)
760 * @dentry: the dentry that points to the inode to sync
765 static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
767 struct gfs2_inode *ip = get_v2ip(dentry->d_inode);
769 atomic_inc(&ip->i_sbd->sd_ops_file);
770 gfs2_log_flush_glock(ip->i_gl);
776 * gfs2_lock - acquire/release a posix lock on a file
777 * @file: the file pointer
778 * @cmd: either modify or retrieve lock state, possibly wait
779 * @fl: type and range of lock
784 static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
786 struct gfs2_inode *ip = get_v2ip(file->f_mapping->host);
787 struct gfs2_sbd *sdp = ip->i_sbd;
788 struct lm_lockname name =
789 { .ln_number = ip->i_num.no_addr,
790 .ln_type = LM_TYPE_PLOCK };
792 atomic_inc(&sdp->sd_ops_file);
794 if (!(fl->fl_flags & FL_POSIX))
796 if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
799 if (sdp->sd_args.ar_localflocks) {
801 struct file_lock *tmp;
803 tmp = posix_test_lock(file, fl);
804 fl->fl_type = F_UNLCK;
806 memcpy(fl, tmp, sizeof(struct file_lock));
812 error = posix_lock_file_wait(file, fl);
819 return gfs2_lm_plock_get(sdp, &name, file, fl);
820 else if (fl->fl_type == F_UNLCK)
821 return gfs2_lm_punlock(sdp, &name, file, fl);
823 return gfs2_lm_plock(sdp, &name, file, cmd, fl);
827 * gfs2_sendfile - Send bytes to a file or socket
828 * @in_file: The file to read from
829 * @out_file: The file to write to
830 * @count: The amount of data
831 * @offset: The beginning file offset
833 * Outputs: offset - updated according to number of bytes read
835 * Returns: The number of bytes sent, errno on failure
838 static ssize_t gfs2_sendfile(struct file *in_file, loff_t *offset, size_t count,
839 read_actor_t actor, void *target)
841 struct gfs2_inode *ip = get_v2ip(in_file->f_mapping->host);
843 atomic_inc(&ip->i_sbd->sd_ops_file);
845 return generic_file_sendfile(in_file, offset, count, actor, target);
848 static int do_flock(struct file *file, int cmd, struct file_lock *fl)
850 struct gfs2_file *fp = get_v2fp(file);
851 struct gfs2_holder *fl_gh = &fp->f_fl_gh;
852 struct gfs2_inode *ip = fp->f_inode;
853 struct gfs2_glock *gl;
858 state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
859 flags = ((IS_SETLKW(cmd)) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE;
861 mutex_lock(&fp->f_fl_mutex);
865 if (fl_gh->gh_state == state)
868 flock_lock_file_wait(file,
869 &(struct file_lock){.fl_type = F_UNLCK});
870 gfs2_glock_dq_uninit(fl_gh);
872 error = gfs2_glock_get(ip->i_sbd,
873 ip->i_num.no_addr, &gfs2_flock_glops,
879 gfs2_holder_init(gl, state, flags, fl_gh);
882 error = gfs2_glock_nq(fl_gh);
884 gfs2_holder_uninit(fl_gh);
885 if (error == GLR_TRYFAILED)
888 error = flock_lock_file_wait(file, fl);
889 gfs2_assert_warn(ip->i_sbd, !error);
893 mutex_unlock(&fp->f_fl_mutex);
898 static void do_unflock(struct file *file, struct file_lock *fl)
900 struct gfs2_file *fp = get_v2fp(file);
901 struct gfs2_holder *fl_gh = &fp->f_fl_gh;
903 mutex_lock(&fp->f_fl_mutex);
904 flock_lock_file_wait(file, fl);
906 gfs2_glock_dq_uninit(fl_gh);
907 mutex_unlock(&fp->f_fl_mutex);
911 * gfs2_flock - acquire/release a flock lock on a file
912 * @file: the file pointer
913 * @cmd: either modify or retrieve lock state, possibly wait
914 * @fl: type and range of lock
919 static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)
921 struct gfs2_inode *ip = get_v2ip(file->f_mapping->host);
922 struct gfs2_sbd *sdp = ip->i_sbd;
924 atomic_inc(&ip->i_sbd->sd_ops_file);
926 if (!(fl->fl_flags & FL_FLOCK))
928 if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
931 if (sdp->sd_args.ar_localflocks)
932 return flock_lock_file_wait(file, fl);
934 if (fl->fl_type == F_UNLCK) {
935 do_unflock(file, fl);
938 return do_flock(file, cmd, fl);
941 struct file_operations gfs2_file_fops = {
942 .llseek = gfs2_llseek,
944 .readv = gfs2_file_readv,
945 .aio_read = gfs2_file_aio_read,
946 .write = generic_file_write,
947 .writev = generic_file_writev,
948 .aio_write = generic_file_aio_write,
952 .release = gfs2_close,
955 .sendfile = gfs2_sendfile,
959 struct file_operations gfs2_dir_fops = {
960 .readdir = gfs2_readdir,
963 .release = gfs2_close,