aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/mmap.c
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2005-12-15 17:31:24 -0500
committerJoel Becker <joel.becker@oracle.com>2006-01-03 14:45:47 -0500
commitccd979bdbce9fba8412beb3f1de68a9d0171b12c (patch)
treec50ed941849ce06ccadd4ce27599b3ef9fdbe2ae /fs/ocfs2/mmap.c
parent8df08c89c668e1bd922a053fdb5ba1fadbecbb38 (diff)
[PATCH] OCFS2: The Second Oracle Cluster Filesystem
The OCFS2 file system module. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> Signed-off-by: Kurt Hackel <kurt.hackel@oracle.com>
Diffstat (limited to 'fs/ocfs2/mmap.c')
-rw-r--r--fs/ocfs2/mmap.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
new file mode 100644
index 000000000000..afdeec4b0eef
--- /dev/null
+++ b/fs/ocfs2/mmap.c
@@ -0,0 +1,102 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * mmap.c
5 *
6 * Code to deal with the mess that is clustered mmap.
7 *
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
9 *
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.
14 *
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.
19 *
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.
24 */
25
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>
34
35#define MLOG_MASK_PREFIX ML_FILE_IO
36#include <cluster/masklog.h>
37
38#include "ocfs2.h"
39
40#include "dlmglue.h"
41#include "file.h"
42#include "inode.h"
43#include "mmap.h"
44
45static struct page *ocfs2_nopage(struct vm_area_struct * area,
46 unsigned long address,
47 int *type)
48{
49 struct inode *inode = area->vm_file->f_dentry->d_inode;
50 struct page *page = NOPAGE_SIGBUS;
51 sigset_t blocked, oldset;
52 int ret;
53
54 mlog_entry("(inode %lu, address %lu)\n", inode->i_ino, address);
55
56 /* The best way to deal with signals in this path is
57 * to block them upfront, rather than allowing the
58 * locking paths to return -ERESTARTSYS. */
59 sigfillset(&blocked);
60
61 /* We should technically never get a bad ret return
62 * from sigprocmask */
63 ret = sigprocmask(SIG_BLOCK, &blocked, &oldset);
64 if (ret < 0) {
65 mlog_errno(ret);
66 goto out;
67 }
68
69 page = filemap_nopage(area, address, type);
70
71 ret = sigprocmask(SIG_SETMASK, &oldset, NULL);
72 if (ret < 0)
73 mlog_errno(ret);
74out:
75 mlog_exit_ptr(page);
76 return page;
77}
78
79static struct vm_operations_struct ocfs2_file_vm_ops = {
80 .nopage = ocfs2_nopage,
81};
82
83int ocfs2_mmap(struct file *file,
84 struct vm_area_struct *vma)
85{
86 struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
87 struct inode *inode = mapping->host;
88
89 /* We don't want to support shared writable mappings yet. */
90 if (((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;
96 }
97
98 update_atime(inode);
99 vma->vm_ops = &ocfs2_file_vm_ops;
100 return 0;
101}
102