[Devel,RHEL7,COMMIT] ms/new helper: wait_event_killable_exclusive()

Submitted by Konstantin Khorenko on Oct. 14, 2016, 9:49 p.m.

Details

Message ID 201610142149.u9ELn4sK027798@finist_cl7.x64_64.work.ct
State New
Series "fuse: fix signals handling while processing request"
Headers show

Commit Message

Konstantin Khorenko Oct. 14, 2016, 9:49 p.m.
The commit is pushed to "branch-rh7-3.10.0-327.36.1.vz7.19.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.36.1.vz7.19.1
------>
commit 33cba27d15135e157617e8ae9147baf9925f5e99
Author: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Date:   Sat Oct 15 01:49:04 2016 +0400

    ms/new helper: wait_event_killable_exclusive()
    
    Patchset description:
    
    fuse: fix signals handling while processing request
    
    This patch fixes wrong SIGBUS result in page fault handler for fuse file, when
    process received a signal.
    
    https://jira.sw.ru/browse/PSBM-53581
    
    Stanislav Kinsburskiy (2):
          new helper: wait_event_killable_exclusive()
          fuse: handle only fatal signals while waiting request answer
    =====================================================
    This patch description:
    
    Backport of ms commit 6a0fb306738994d6f091791aeb11a5dc87ad8f4c
    ("new helper: wait_event_killable_exclusive()").
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    
    Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
    Acked-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 include/linux/wait.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Patch hide | download patch | download mbox

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 65da9e3..8475f2d 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -710,6 +710,32 @@  do {									\
 	__ret;								\
 })
 
+#define __wait_event_killable_exclusive(wq, condition, ret)		\
+do {									\
+	DEFINE_WAIT(__wait);						\
+									\
+	for (;;) {							\
+		prepare_to_wait_exclusive(&wq, &__wait, TASK_KILLABLE);	\
+		if (condition)						\
+			break;						\
+		if (!fatal_signal_pending(current)) {			\
+			schedule();					\
+			continue;					\
+		}							\
+		ret = -ERESTARTSYS;					\
+		break;							\
+	}								\
+	finish_wait(&wq, &__wait);					\
+} while (0)
+
+
+#define wait_event_killable_exclusive(wq, condition)			\
+({									\
+	int __ret = 0;							\
+	if (!(condition))						\
+		__wait_event_killable_exclusive(wq, condition, __ret);	\
+	__ret;								\
+})
 
 #define __wait_event_lock_irq(wq, condition, lock, cmd)			\
 do {									\