Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1533822 > unrolled thread
| Started by | cuilifei <cuilifei@xiaomi.com> |
|---|---|
| First post | 2016-12-01 06:50 +0100 |
| Last post | 2016-12-02 19:50 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] fuse: freezing abort when use wait_event_killable{,_exclusive}(). cuilifei <cuilifei@xiaomi.com> - 2016-12-01 06:50 +0100
Re: [PATCH] fuse: freezing abort when use wait_event_killable{,_exclusive}(). kbuild test robot <lkp@intel.com> - 2016-12-02 17:20 +0100
Re: [PATCH] fuse: freezing abort when use wait_event_killable{,_exclusive}(). kbuild test robot <lkp@intel.com> - 2016-12-02 19:50 +0100
| From | cuilifei <cuilifei@xiaomi.com> |
|---|---|
| Date | 2016-12-01 06:50 +0100 |
| Subject | [PATCH] fuse: freezing abort when use wait_event_killable{,_exclusive}(). |
| Message-ID | <sJspQ-84b-7@gated-at.bofh.it> |
Freezing process can abort when a client is waiting uninterruptibly
for a response. Add new macro wait_fatal_freezable to try to fix it.
Signed-off-by: cuilifei <cuilifei@xiaomi.com>
---
fs/fuse/dev.c | 47 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 43 insertions(+), 4 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 70ea57c..40aea7d 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -23,6 +23,24 @@
MODULE_ALIAS_MISCDEV(FUSE_MINOR);
MODULE_ALIAS("devname:fuse");
+#define wait_fatal_freezable(wq, condition, exclusive) \
+({ \
+ int __ret = 0; \
+ do { \
+ if (exclusive) \
+ __ret = wait_event_interruptible_exclusive(wq, \
+ condition); \
+ else \
+ __ret = wait_event_interruptible(wq, \
+ condition); \
+ if (!__ret || fatal_signal_pending(current)) \
+ break; \
+ if (!freezing(current)) \
+ continue; \
+ } while (try_to_freeze()); \
+ __ret; \
+})
+
static struct kmem_cache *fuse_req_cachep;
static struct fuse_dev *fuse_get_dev(struct file *file)
@@ -99,6 +117,19 @@ void fuse_request_free(struct fuse_req *req)
kmem_cache_free(fuse_req_cachep, req);
}
+static void block_sigs(sigset_t *oldset)
+{
+ sigset_t mask;
+
+ siginitsetinv(&mask, sigmask(SIGKILL));
+ sigprocmask(SIG_BLOCK, &mask, oldset);
+}
+
+static void restore_sigs(sigset_t *oldset)
+{
+ sigprocmask(SIG_SETMASK, oldset, NULL);
+}
+
void __fuse_get_request(struct fuse_req *req)
{
atomic_inc(&req->count);
@@ -134,13 +165,18 @@ static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages,
bool for_background)
{
struct fuse_req *req;
+ sigset_t oldset;
+ int intr;
int err;
atomic_inc(&fc->num_waiting);
if (fuse_block_alloc(fc, for_background)) {
err = -EINTR;
- if (wait_event_killable_exclusive(fc->blocked_waitq,
- !fuse_block_alloc(fc, for_background)))
+ block_sigs(&oldset);
+ intr = wait_fatal_freezable(fc->blocked_waitq,
+ !fuse_block_alloc(fc, for_background), true);
+ restore_sigs(&oldset);
+ if (intr)
goto out;
}
/* Matches smp_wmb() in fuse_set_initialized() */
@@ -427,9 +463,12 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
}
if (!test_bit(FR_FORCE, &req->flags)) {
+ sigset_t oldset;
/* Only fatal signals may interrupt this */
- err = wait_event_killable(req->waitq,
- test_bit(FR_FINISHED, &req->flags));
+ block_sigs(&oldset);
+ err = wait_fatal_freezable(req->waitq,
+ test_bit(FR_FINISHED, &req->flags), false);
+ restore_sigs(&oldset);
if (!err)
return;
--
1.9.1
[toc] | [next] | [standalone]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2016-12-02 17:20 +0100 |
| Subject | Re: [PATCH] fuse: freezing abort when use wait_event_killable{,_exclusive}(). |
| Message-ID | <sJYJ3-69N-13@gated-at.bofh.it> |
| In reply to | #1533822 |
[Multipart message — attachments visible in raw view] — view raw
Hi cuilifei,
[auto build test WARNING on fuse/for-next]
[also build test WARNING on v4.9-rc7 next-20161202]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/cuilifei/fuse-freezing-abort-when-use-wait_event_killable-_exclusive/20161202-234345
base: https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git for-next
config: x86_64-randconfig-x013-201648 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/uapi/linux/fuse.h:121,
from fs/fuse/fuse_i.h:12,
from fs/fuse/dev.c:9:
fs/fuse/dev.c: In function '__fuse_get_req':
fs/fuse/dev.c:38:8: error: implicit declaration of function 'freezing' [-Werror=implicit-function-declaration]
if (!freezing(current)) \
^
include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> fs/fuse/dev.c:38:3: note: in expansion of macro 'if'
if (!freezing(current)) \
^~
fs/fuse/dev.c:176:10: note: in expansion of macro 'wait_fatal_freezable'
intr = wait_fatal_freezable(fc->blocked_waitq,
^~~~~~~~~~~~~~~~~~~~
fs/fuse/dev.c:40:11: error: implicit declaration of function 'try_to_freeze' [-Werror=implicit-function-declaration]
} while (try_to_freeze()); \
^
fs/fuse/dev.c:176:10: note: in expansion of macro 'wait_fatal_freezable'
intr = wait_fatal_freezable(fc->blocked_waitq,
^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/if +38 fs/fuse/dev.c
3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
4
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7 */
8
> 9 #include "fuse_i.h"
10
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/poll.h>
14 #include <linux/uio.h>
15 #include <linux/miscdevice.h>
16 #include <linux/pagemap.h>
17 #include <linux/file.h>
18 #include <linux/slab.h>
19 #include <linux/pipe_fs_i.h>
20 #include <linux/swap.h>
21 #include <linux/splice.h>
22
23 MODULE_ALIAS_MISCDEV(FUSE_MINOR);
24 MODULE_ALIAS("devname:fuse");
25
26 #define wait_fatal_freezable(wq, condition, exclusive) \
27 ({ \
28 int __ret = 0; \
29 do { \
30 if (exclusive) \
31 __ret = wait_event_interruptible_exclusive(wq, \
32 condition); \
33 else \
34 __ret = wait_event_interruptible(wq, \
35 condition); \
36 if (!__ret || fatal_signal_pending(current)) \
37 break; \
> 38 if (!freezing(current)) \
39 continue; \
40 } while (try_to_freeze()); \
41 __ret; \
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[toc] | [prev] | [next] | [standalone]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2016-12-02 19:50 +0100 |
| Subject | Re: [PATCH] fuse: freezing abort when use wait_event_killable{,_exclusive}(). |
| Message-ID | <sK14d-7tU-11@gated-at.bofh.it> |
| In reply to | #1533822 |
[Multipart message — attachments visible in raw view] — view raw
Hi cuilifei,
[auto build test ERROR on fuse/for-next]
[also build test ERROR on v4.9-rc7 next-20161202]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/cuilifei/fuse-freezing-abort-when-use-wait_event_killable-_exclusive/20161202-234345
base: https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git for-next
config: x86_64-kexec (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
fs/fuse/dev.c: In function '__fuse_get_req':
>> fs/fuse/dev.c:38:8: error: implicit declaration of function 'freezing' [-Werror=implicit-function-declaration]
if (!freezing(current)) \
^
fs/fuse/dev.c:176:10: note: in expansion of macro 'wait_fatal_freezable'
intr = wait_fatal_freezable(fc->blocked_waitq,
^~~~~~~~~~~~~~~~~~~~
>> fs/fuse/dev.c:40:11: error: implicit declaration of function 'try_to_freeze' [-Werror=implicit-function-declaration]
} while (try_to_freeze()); \
^
fs/fuse/dev.c:176:10: note: in expansion of macro 'wait_fatal_freezable'
intr = wait_fatal_freezable(fc->blocked_waitq,
^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/freezing +38 fs/fuse/dev.c
32 condition); \
33 else \
34 __ret = wait_event_interruptible(wq, \
35 condition); \
36 if (!__ret || fatal_signal_pending(current)) \
37 break; \
> 38 if (!freezing(current)) \
39 continue; \
> 40 } while (try_to_freeze()); \
41 __ret; \
42 })
43
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web