* [PATCH] io-wq: ensure work->task_pid is cleared on init
@ 2020-02-25 18:55 Jens Axboe
2020-02-25 19:38 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2020-02-25 18:55 UTC (permalink / raw)
To: io-uring
We use ->task_pid for exit cancellation, but we need to ensure it's
cleared to zero for io_req_work_grab_env() to do the right thing.
Fixes: 36282881a795 ("io-wq: add io_wq_cancel_pid() to cancel based on a specific pid")
Signed-off-by: Jens Axboe <[email protected]>
---
diff --git a/fs/io-wq.h b/fs/io-wq.h
index ccc7d84af57d..9e9419c08bc1 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -88,6 +88,7 @@ struct io_wq_work {
(work)->creds = NULL; \
(work)->fs = NULL; \
(work)->flags = 0; \
+ (work)->task_pid = 0; \
} while (0) \
typedef void (get_work_fn)(struct io_wq_work *);
--
Jens Axboe
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] io-wq: ensure work->task_pid is cleared on init
2020-02-25 18:55 [PATCH] io-wq: ensure work->task_pid is cleared on init Jens Axboe
@ 2020-02-25 19:38 ` Bart Van Assche
2020-02-25 19:56 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2020-02-25 19:38 UTC (permalink / raw)
To: Jens Axboe, io-uring
On 2/25/20 10:55 AM, Jens Axboe wrote:
> We use ->task_pid for exit cancellation, but we need to ensure it's
> cleared to zero for io_req_work_grab_env() to do the right thing.
How about initializing .task_pid with this (totally untested) patch?
diff --git a/fs/io-wq.h b/fs/io-wq.h
index ccc7d84af57d..b8d3287cec57 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -80,15 +80,7 @@ struct io_wq_work {
};
#define INIT_IO_WORK(work, _func) \
- do { \
- (work)->list.next = NULL; \
- (work)->func = _func; \
- (work)->files = NULL; \
- (work)->mm = NULL; \
- (work)->creds = NULL; \
- (work)->fs = NULL; \
- (work)->flags = 0; \
- } while (0) \
+ do { *(work) = (struct io_wq_work){ .func = _func }; } while (0)
typedef void (get_work_fn)(struct io_wq_work *);
typedef void (put_work_fn)(struct io_wq_work *);
Thanks,
Bart.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] io-wq: ensure work->task_pid is cleared on init
2020-02-25 19:38 ` Bart Van Assche
@ 2020-02-25 19:56 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2020-02-25 19:56 UTC (permalink / raw)
To: Bart Van Assche, io-uring
On 2/25/20 12:38 PM, Bart Van Assche wrote:
> On 2/25/20 10:55 AM, Jens Axboe wrote:
>> We use ->task_pid for exit cancellation, but we need to ensure it's
>> cleared to zero for io_req_work_grab_env() to do the right thing.
>
> How about initializing .task_pid with this (totally untested) patch?
>
> diff --git a/fs/io-wq.h b/fs/io-wq.h
> index ccc7d84af57d..b8d3287cec57 100644
> --- a/fs/io-wq.h
> +++ b/fs/io-wq.h
> @@ -80,15 +80,7 @@ struct io_wq_work {
> };
>
> #define INIT_IO_WORK(work, _func) \
> - do { \
> - (work)->list.next = NULL; \
> - (work)->func = _func; \
> - (work)->files = NULL; \
> - (work)->mm = NULL; \
> - (work)->creds = NULL; \
> - (work)->fs = NULL; \
> - (work)->flags = 0; \
> - } while (0) \
> + do { *(work) = (struct io_wq_work){ .func = _func }; } while (0)
>
> typedef void (get_work_fn)(struct io_wq_work *);
> typedef void (put_work_fn)(struct io_wq_work *);
That's not a bad idea and would be more future proof, in case more fields
are added at a later date.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-25 19:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-25 18:55 [PATCH] io-wq: ensure work->task_pid is cleared on init Jens Axboe
2020-02-25 19:38 ` Bart Van Assche
2020-02-25 19:56 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox