diff options
author | Kent Overstreet <kmo@daterainc.com> | 2014-01-19 03:26:37 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-01-23 15:17:18 -0500 |
commit | 6f6b5d1ec56acdeab0503d2b823f6f88a0af493e (patch) | |
tree | 7a95dca01cc9ddd652ccbfba4df9d5c30abda549 /block | |
parent | 4a4caa29f1abcb14377e05d57c0793d338fb945d (diff) |
percpu_ida: Make percpu_ida_alloc + callers accept task state bitmask
This patch changes percpu_ida_alloc() + callers to accept task state
bitmask for prepare_to_wait() for code like target/iscsi that needs
it for interruptible sleep, that is provided in a subsequent patch.
It now expects TASK_UNINTERRUPTIBLE when the caller is able to sleep
waiting for a new tag, or TASK_RUNNING when the caller cannot sleep,
and is forced to return a negative value when no tags are available.
v2 changes:
- Include blk-mq + tcm_fc + vhost/scsi + target/iscsi changes
- Drop signal_pending_state() call
v3 changes:
- Only call prepare_to_wait() + finish_wait() when != TASK_RUNNING
(PeterZ)
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Cc: <stable@vger.kernel.org> #3.12+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-mq-tag.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index d64a02fb1f73..5d70edc9855f 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c | |||
@@ -36,7 +36,8 @@ static unsigned int __blk_mq_get_tag(struct blk_mq_tags *tags, gfp_t gfp) | |||
36 | { | 36 | { |
37 | int tag; | 37 | int tag; |
38 | 38 | ||
39 | tag = percpu_ida_alloc(&tags->free_tags, gfp); | 39 | tag = percpu_ida_alloc(&tags->free_tags, (gfp & __GFP_WAIT) ? |
40 | TASK_UNINTERRUPTIBLE : TASK_RUNNING); | ||
40 | if (tag < 0) | 41 | if (tag < 0) |
41 | return BLK_MQ_TAG_FAIL; | 42 | return BLK_MQ_TAG_FAIL; |
42 | return tag + tags->nr_reserved_tags; | 43 | return tag + tags->nr_reserved_tags; |
@@ -52,7 +53,8 @@ static unsigned int __blk_mq_get_reserved_tag(struct blk_mq_tags *tags, | |||
52 | return BLK_MQ_TAG_FAIL; | 53 | return BLK_MQ_TAG_FAIL; |
53 | } | 54 | } |
54 | 55 | ||
55 | tag = percpu_ida_alloc(&tags->reserved_tags, gfp); | 56 | tag = percpu_ida_alloc(&tags->reserved_tags, (gfp & __GFP_WAIT) ? |
57 | TASK_UNINTERRUPTIBLE : TASK_RUNNING); | ||
56 | if (tag < 0) | 58 | if (tag < 0) |
57 | return BLK_MQ_TAG_FAIL; | 59 | return BLK_MQ_TAG_FAIL; |
58 | return tag; | 60 | return tag; |