aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/mmap.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2009-09-02 20:17:36 -0400
committerJoel Becker <joel.becker@oracle.com>2010-05-10 14:50:10 -0400
commite4b963f10e9026c83419b5c25b93a0350413cf16 (patch)
treed162595c9f79626d040cb28c84e53fd8b7fe50ff /fs/ocfs2/mmap.c
parent0467ae954d1843de65e7cf8f706f88fe65cd8418 (diff)
ocfs2: Wrap signal blocking in void functions.
ocfs2 sometimes needs to block signals around dlm operations, but it currently does it with sigprocmask(). Even worse, it's checking the error code of sigprocmask(). The in-kernel sigprocmask() can only error if you get the SIG_* argument wrong. We don't. Wrap the sigprocmask() calls with ocfs2_[un]block_signals(). These functions are void, but they will BUG() if somehow sigprocmask() returns an error. Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/mmap.c')
-rw-r--r--fs/ocfs2/mmap.c48
1 files changed, 9 insertions, 39 deletions
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index 39737613424a..a61809f8eab5 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -42,44 +42,20 @@
42#include "file.h" 42#include "file.h"
43#include "inode.h" 43#include "inode.h"
44#include "mmap.h" 44#include "mmap.h"
45#include "super.h"
45 46
46static inline int ocfs2_vm_op_block_sigs(sigset_t *blocked, sigset_t *oldset)
47{
48 /* The best way to deal with signals in the vm path is
49 * to block them upfront, rather than allowing the
50 * locking paths to return -ERESTARTSYS. */
51 sigfillset(blocked);
52
53 /* We should technically never get a bad return value
54 * from sigprocmask */
55 return sigprocmask(SIG_BLOCK, blocked, oldset);
56}
57
58static inline int ocfs2_vm_op_unblock_sigs(sigset_t *oldset)
59{
60 return sigprocmask(SIG_SETMASK, oldset, NULL);
61}
62 47
63static int ocfs2_fault(struct vm_area_struct *area, struct vm_fault *vmf) 48static int ocfs2_fault(struct vm_area_struct *area, struct vm_fault *vmf)
64{ 49{
65 sigset_t blocked, oldset; 50 sigset_t oldset;
66 int error, ret; 51 int ret;
67 52
68 mlog_entry("(area=%p, page offset=%lu)\n", area, vmf->pgoff); 53 mlog_entry("(area=%p, page offset=%lu)\n", area, vmf->pgoff);
69 54
70 error = ocfs2_vm_op_block_sigs(&blocked, &oldset); 55 ocfs2_block_signals(&oldset);
71 if (error < 0) {
72 mlog_errno(error);
73 ret = VM_FAULT_SIGBUS;
74 goto out;
75 }
76
77 ret = filemap_fault(area, vmf); 56 ret = filemap_fault(area, vmf);
57 ocfs2_unblock_signals(&oldset);
78 58
79 error = ocfs2_vm_op_unblock_sigs(&oldset);
80 if (error < 0)
81 mlog_errno(error);
82out:
83 mlog_exit_ptr(vmf->page); 59 mlog_exit_ptr(vmf->page);
84 return ret; 60 return ret;
85} 61}
@@ -159,14 +135,10 @@ static int ocfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
159 struct page *page = vmf->page; 135 struct page *page = vmf->page;
160 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 136 struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
161 struct buffer_head *di_bh = NULL; 137 struct buffer_head *di_bh = NULL;
162 sigset_t blocked, oldset; 138 sigset_t oldset;
163 int ret, ret2; 139 int ret;
164 140
165 ret = ocfs2_vm_op_block_sigs(&blocked, &oldset); 141 ocfs2_block_signals(&oldset);
166 if (ret < 0) {
167 mlog_errno(ret);
168 return ret;
169 }
170 142
171 /* 143 /*
172 * The cluster locks taken will block a truncate from another 144 * The cluster locks taken will block a truncate from another
@@ -194,9 +166,7 @@ static int ocfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
194 ocfs2_inode_unlock(inode, 1); 166 ocfs2_inode_unlock(inode, 1);
195 167
196out: 168out:
197 ret2 = ocfs2_vm_op_unblock_sigs(&oldset); 169 ocfs2_unblock_signals(&oldset);
198 if (ret2 < 0)
199 mlog_errno(ret2);
200 if (ret) 170 if (ret)
201 ret = VM_FAULT_SIGBUS; 171 ret = VM_FAULT_SIGBUS;
202 return ret; 172 return ret;