Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nbd.c: sock_xmit: cleanup signal related code

sock_xmit() re-implements sigprocmask() and dequeue_signal_lock().

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Paul Clements <paul.clements@steeleye.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Oleg Nesterov and committed by
Linus Torvalds
be0ef957 3e1ac130

+6 -16
+6 -16
drivers/block/nbd.c
··· 122 122 int result; 123 123 struct msghdr msg; 124 124 struct kvec iov; 125 - unsigned long flags; 126 - sigset_t oldset; 125 + sigset_t blocked, oldset; 127 126 128 127 /* Allow interception of SIGKILL only 129 128 * Don't allow other signals to interrupt the transmission */ 130 - spin_lock_irqsave(&current->sighand->siglock, flags); 131 - oldset = current->blocked; 132 - sigfillset(&current->blocked); 133 - sigdelsetmask(&current->blocked, sigmask(SIGKILL)); 134 - recalc_sigpending(); 135 - spin_unlock_irqrestore(&current->sighand->siglock, flags); 129 + siginitsetinv(&blocked, sigmask(SIGKILL)); 130 + sigprocmask(SIG_SETMASK, &blocked, &oldset); 136 131 137 132 do { 138 133 sock->sk->sk_allocation = GFP_NOIO; ··· 146 151 147 152 if (signal_pending(current)) { 148 153 siginfo_t info; 149 - spin_lock_irqsave(&current->sighand->siglock, flags); 150 154 printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n", 151 - current->pid, current->comm, 152 - dequeue_signal(current, &current->blocked, &info)); 153 - spin_unlock_irqrestore(&current->sighand->siglock, flags); 155 + current->pid, current->comm, 156 + dequeue_signal_lock(current, &current->blocked, &info)); 154 157 result = -EINTR; 155 158 break; 156 159 } ··· 162 169 buf += result; 163 170 } while (size > 0); 164 171 165 - spin_lock_irqsave(&current->sighand->siglock, flags); 166 - current->blocked = oldset; 167 - recalc_sigpending(); 168 - spin_unlock_irqrestore(&current->sighand->siglock, flags); 172 + sigprocmask(SIG_SETMASK, &oldset, NULL); 169 173 170 174 return result; 171 175 }