Skip to content

Commit 9d3d21a

Browse files
ming1axboe
authored andcommitted
blk-mq: bitmap tag: select random tag betweet 0 and (depth - 1)
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 60f2df8 commit 9d3d21a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

block/blk-mq-tag.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,7 @@ void blk_mq_tag_init_last_tag(struct blk_mq_tags *tags, unsigned int *tag)
449449
{
450450
unsigned int depth = tags->nr_tags - tags->nr_reserved_tags;
451451

452-
if (depth > 1)
453-
*tag = prandom_u32() % (depth - 1);
454-
else
455-
*tag = 0;
452+
*tag = prandom_u32() % depth;
456453
}
457454

458455
ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page)

0 commit comments

Comments
 (0)