1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
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.
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>
45 static struct page
*ocfs2_nopage(struct vm_area_struct
* area
,
46 unsigned long address
,
49 struct page
*page
= NOPAGE_SIGBUS
;
50 sigset_t blocked
, oldset
;
53 mlog_entry("(area=%p, address=%lu, type=%p)\n", area
, address
,
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. */
61 /* We should technically never get a bad ret return
63 ret
= sigprocmask(SIG_BLOCK
, &blocked
, &oldset
);
69 page
= filemap_nopage(area
, address
, type
);
71 ret
= sigprocmask(SIG_SETMASK
, &oldset
, NULL
);
79 static struct vm_operations_struct ocfs2_file_vm_ops
= {
80 .nopage
= ocfs2_nopage
,
83 int ocfs2_mmap(struct file
*file
, struct vm_area_struct
*vma
)
85 /* We don't want to support shared writable mappings yet. */
86 if (((vma
->vm_flags
& VM_SHARED
) || (vma
->vm_flags
& VM_MAYSHARE
))
87 && ((vma
->vm_flags
& VM_WRITE
) || (vma
->vm_flags
& VM_MAYWRITE
))) {
88 mlog(0, "disallow shared writable mmaps %lx\n", vma
->vm_flags
);
89 /* This is -EINVAL because generic_file_readonly_mmap
90 * returns it in a similar situation. */
95 vma
->vm_ops
= &ocfs2_file_vm_ops
;