Skip to content

Commit

Permalink
blk-mq: bitmap tag: select random tag betweet 0 and (depth - 1)
Browse files Browse the repository at this point in the history
The selected tag should be selected at random between 0 and
(depth - 1) with probability 1/depth, instead between 0 and
(depth - 2) with probability 1/(depth - 1).

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Ming Lei authored and Jens Axboe committed May 10, 2014
1 parent 60f2df8 commit 9d3d21a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions block/blk-mq-tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,7 @@ void blk_mq_tag_init_last_tag(struct blk_mq_tags *tags, unsigned int *tag)
{
unsigned int depth = tags->nr_tags - tags->nr_reserved_tags;

if (depth > 1)
*tag = prandom_u32() % (depth - 1);
else
*tag = 0;
*tag = prandom_u32() % depth;
}

ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page)
Expand Down

0 comments on commit 9d3d21a

Please sign in to comment.