Skip to content

Commit be0ef95

Browse files
Oleg NesterovLinus Torvalds
authored andcommitted
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>
1 parent 3e1ac13 commit be0ef95

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

‎drivers/block/nbd.c‎

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,12 @@ static int sock_xmit(struct socket *sock, int send, void *buf, int size,
122122
int result;
123123
struct msghdr msg;
124124
struct kvec iov;
125-
unsigned long flags;
126-
sigset_t oldset;
125+
sigset_t blocked, oldset;
127126

128127
/* Allow interception of SIGKILL only
129128
* 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);
136131

137132
do {
138133
sock->sk->sk_allocation = GFP_NOIO;
@@ -151,11 +146,9 @@ static int sock_xmit(struct socket *sock, int send, void *buf, int size,
151146

152147
if (signal_pending(current)) {
153148
siginfo_t info;
154-
spin_lock_irqsave(&current->sighand->siglock, flags);
155149
printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n",
156-
current->pid, current->comm,
157-
dequeue_signal(current, &current->blocked, &info));
158-
spin_unlock_irqrestore(&current->sighand->siglock, flags);
150+
current->pid, current->comm,
151+
dequeue_signal_lock(current, &current->blocked, &info));
159152
result = -EINTR;
160153
break;
161154
}
@@ -169,10 +162,7 @@ static int sock_xmit(struct socket *sock, int send, void *buf, int size,
169162
buf += result;
170163
} while (size > 0);
171164

172-
spin_lock_irqsave(&current->sighand->siglock, flags);
173-
current->blocked = oldset;
174-
recalc_sigpending();
175-
spin_unlock_irqrestore(&current->sighand->siglock, flags);
165+
sigprocmask(SIG_SETMASK, &oldset, NULL);
176166

177167
return result;
178168
}

0 commit comments

Comments
 (0)