allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / fs / ocfs2 / mmap.c
blobe1321f0665d75ec807302395cdf9240524a34ca9
1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
4 * mmap.c
6 * Code to deal with the mess that is clustered mmap.
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public
21 * License along with this program; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 021110-1307, USA.
26 #include <linux/fs.h>
27 #include <linux/types.h>
28 #include <linux/slab.h>
29 #include <linux/highmem.h>
30 #include <linux/pagemap.h>
31 #include <linux/uio.h>
32 #include <linux/signal.h>
33 #include <linux/rbtree.h>
35 #define MLOG_MASK_PREFIX ML_FILE_IO
36 #include <cluster/masklog.h>
38 #include "ocfs2.h"
40 #include "dlmglue.h"
41 #include "file.h"
42 #include "inode.h"
43 #include "mmap.h"
45 static int ocfs2_fault(struct vm_area_struct *area, struct vm_fault *vmf)
47 sigset_t blocked, oldset;
48 int error, ret;
50 mlog_entry("(area=%p, page offset=%lu)\n", area, vmf->pgoff);
52 /* The best way to deal with signals in this path is
53 * to block them upfront, rather than allowing the
54 * locking paths to return -ERESTARTSYS. */
55 sigfillset(&blocked);
57 /* We should technically never get a bad ret return
58 * from sigprocmask */
59 error = sigprocmask(SIG_BLOCK, &blocked, &oldset);
60 if (ret < 0) {
61 mlog_errno(error);
62 ret = VM_FAULT_SIGBUS;
63 goto out;
66 ret = filemap_fault(area, vmf);
68 error = sigprocmask(SIG_SETMASK, &oldset, NULL);
69 if (error < 0)
70 mlog_errno(error);
71 out:
72 mlog_exit_ptr(vmf->page);
73 return ret;
76 static struct vm_operations_struct ocfs2_file_vm_ops = {
77 .fault = ocfs2_fault,
80 int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
82 int ret = 0, lock_level = 0;
83 struct ocfs2_super *osb = OCFS2_SB(file->f_dentry->d_inode->i_sb);
86 * Only support shared writeable mmap for local mounts which
87 * don't know about holes.
89 if ((!ocfs2_mount_local(osb) || ocfs2_sparse_alloc(osb)) &&
90 ((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) &&
91 ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) {
92 mlog(0, "disallow shared writable mmaps %lx\n", vma->vm_flags);
93 /* This is -EINVAL because generic_file_readonly_mmap
94 * returns it in a similar situation. */
95 return -EINVAL;
98 ret = ocfs2_meta_lock_atime(file->f_dentry->d_inode,
99 file->f_vfsmnt, &lock_level);
100 if (ret < 0) {
101 mlog_errno(ret);
102 goto out;
104 ocfs2_meta_unlock(file->f_dentry->d_inode, lock_level);
105 out:
106 vma->vm_ops = &ocfs2_file_vm_ops;
107 vma->vm_flags |= VM_CAN_NONLINEAR;
108 return 0;