nbd.c:sock_xmit: cleanup signal related code
Subsystems (2)
PATCH 1/1 nbd.c:sock_xmit: cleanup signal related code
sock_xmit() re-implements sigprocmask() and dequeue_signal_lock().
Note: I can't understand this dequeue_signal(), it can dequeue SIGKILL for the user-space task doing nbd_ioctl() ?
drivers/block/nbd.c renamed from drivers/block/nbd.c~1_nbd +6 -16
@@ -122,17 +122,12 @@ static int sock_xmit(struct socket *sockint result;struct msghdr msg;struct kvec iov; -unsigned long flags; -sigset_t oldset; +sigset_t blocked, oldset;/* Allow interception of SIGKILL only * Don't allow other signals to interrupt the transmission */ -spin_lock_irqsave (¤t->sighand->siglock, flags); - oldset = current->blocked; -sigfillset (¤t->blocked); -sigdelsetmask (¤t->blocked,sigmask (SIGKILL )); -recalc_sigpending (); -spin_unlock_irqrestore (¤t->sighand->siglock, flags); +siginitsetinv (&blocked,sigmask (SIGKILL )); +sigprocmask (SIG_SETMASK , &blocked, &oldset); do { sock->sk->sk_allocation = GFP_NOIO;
@@ -151,11 +146,9 @@ static int sock_xmit(struct socket *sockif (signal_pending (current)) {siginfo_t info; -spin_lock_irqsave (¤t->sighand->siglock, flags);printk (KERN_WARNING "nbd (pid %d: %s) got signal %d\n" , - current->pid, current->comm, -dequeue_signal (current, ¤t->blocked, &info)); -spin_unlock_irqrestore (¤t->sighand->siglock, flags); + current->pid, current->comm, +dequeue_signal_lock (current, ¤t->blocked, &info)); result = -EINTR ;break ; }
@@ -169,10 +162,7 @@ static int sock_xmit(struct socket *sock buf += result; }while (size >0 ); -spin_lock_irqsave (¤t->sighand->siglock, flags); - current->blocked = oldset; -recalc_sigpending (); -spin_unlock_irqrestore (¤t->sighand->siglock, flags); +sigprocmask (SIG_SETMASK , &oldset,NULL );return result; }
Quoted 1 line · Oleg Nesterov
sock_xmit()re-implementssigprocmask()anddequeue_signal_lock().
Yeah, that code was written before those existed. Thanks for the clean up.
Quoted 2 lines
Note: I can't understand this
dequeue_signal(), it can dequeue SIGKILL for the user-space task doingnbd_ioctl()?
So we can interrupt an nbd transmission without waiting for a TCP timeout (when we know the network is down).
Quoted 1 line
Signed-off-by Oleg Nesterov <[email protected]>
Patch looks good to me.
--
Paul
Quoted 8 lines · Paul Clements
Quoted 2 lines · Oleg Nesterov
Note: I can't understand this
dequeue_signal(), it can dequeue SIGKILL for the user-space task doingnbd_ioctl()?So we can interrupt an nbd transmission without waiting for a TCP timeout (when we know the network is down).
Yes, but that task should not survive after SIGKILL ? Note that SIGNAL_GROUP_EXIT is set, this is not good.
Oleg.