Skip to contentSkip to conversation

block: avoid clearing blk_mq_alloc_data unnecessarily

PATCH In review Jens Axboe 2 participants 3 messages Dec 3, 2021 – Dec 6, 2021 Block layer

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 block: avoid clearing blk_mq_alloc_data unnecessarily

We already set almost all of what we need here, just the non-plug path needs to set nr_tags and clear cached.

---

block/blk-mq.c +4 -1
index 4dc0837f874d..eba34af1c5eb 100644
@@ -2664,7 +2664,7 @@ static struct request *blk_mq_get_new_requests(struct request_queue *q,
 {
 	struct blk_mq_alloc_data data = {
 		.q		= q,
-		.nr_tags	= 1,
+		.shallow_depth	= 0
 	};
 	struct request *rq;
 
@@ -2683,6 +2683,9 @@ static struct request *blk_mq_get_new_requests(struct request_queue *q,
 		data.nr_tags = plug->nr_ios;
 		plug->nr_ios = 1;
 		data.cached_rq = &plug->cached_rq;
+	} else {
+		data.nr_tags = 1;
+		data.cached_rq = NULL;
 	}
 
 	rq = __blk_mq_alloc_requests(&data);
Signature · 1 line
Jens Axboe
#1 lore raw
Quoted 2 lines · Jens Axboe

We already set almost all of what we need here, just the non-plug path needs to set nr_tags and clear cached.

How does this avoid clearing? All partial initializers zero the rest of the structure.

author maintainer
#2 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Jens Axboe

We already set almost all of what we need here, just the non-plug path needs to set nr_tags and clear cached.

How does this avoid clearing? All partial initializers zero the rest of the structure.

Yep this is garbage, I'll just drop it.

Signature · 1 line
Jens Axboe