blk-mq: bitmap tag: use clear_bit_unlock in bt_clear_tag()

This change “blk-mq: bitmap tag: use clear_bit_unlock in bt_clear_tag()” (commit 0289b2e) in Linux kernel is authored by Ming Lei <tom.leiming [at] gmail.com> on Sun May 11 01:01:48 2014 +0800.

Description of "blk-mq: bitmap tag: use clear_bit_unlock in bt_clear_tag()"

The change “blk-mq: bitmap tag: use clear_bit_unlock in bt_clear_tag()” introduces changes as follows.

blk-mq: bitmap tag: use clear_bit_unlock in bt_clear_tag()

The unlock memory barrier need to order access to req in free
path and clearing tag bit, otherwise either request free path
may see a allocated request, or initialized request in allocate
path might be modified by the ongoing free path.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>

Linux kernel releases containing commit 0289b2e

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "blk-mq: bitmap tag: use clear_bit_unlock in bt_clear_tag()"

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 block/blk-mq-tag.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
 
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 6c78c08865e3..a81b138e89fe 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -236,7 +236,11 @@ static void bt_clear_tag(struct blk_mq_bitmap_tags *bt, unsigned int tag)
 	const int index = TAG_TO_INDEX(bt, tag);
 	struct bt_wait_state *bs;
 
-	clear_bit(TAG_TO_BIT(bt, tag), &bt->map[index].word);
+	/*
+	 * The unlock memory barrier need to order access to req in free
+	 * path and clearing tag bit
+	 */
+	clear_bit_unlock(TAG_TO_BIT(bt, tag), &bt->map[index].word);
 
 	bs = bt_wake_ptr(bt);
 	if (bs && atomic_dec_and_test(&bs->wait_cnt)) {

The commit for this change in Linux stable tree is 0289b2e (patch).

Last modified: 2020/02/10