Blame SOURCES/0002-Handle-blk_mq_ctx-member-changes-for-kernels-5.16-rc.patch

52efa0
From 98b417fc63467339b919ef6d322c1893d6d55f86 Mon Sep 17 00:00:00 2001
52efa0
From: Lianbo Jiang <lijiang@redhat.com>
52efa0
Date: Fri, 24 Dec 2021 18:56:35 +0800
52efa0
Subject: [PATCH 2/2] Handle blk_mq_ctx member changes for kernels 5.16-rc1 and
52efa0
 later
52efa0
52efa0
Kernel commit 9a14d6ce4135 ("block: remove debugfs blk_mq_ctx
52efa0
dispatched/merged/completed attributes") removed the member
52efa0
rq_dispatched and rq_completed from struct blk_mq_ctx.  Without
52efa0
the patch, "dev -d|-D" options will fail with the following error:
52efa0
52efa0
crash> dev -d
52efa0
MAJOR GENDISK            NAME       REQUEST_QUEUE      TOTAL ASYNC  SYNC
52efa0
52efa0
dev: invalid structure member offset: blk_mq_ctx_rq_dispatched
52efa0
     FILE: dev.c  LINE: 4229  FUNCTION: get_one_mctx_diskio()
52efa0
52efa0
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
52efa0
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
52efa0
---
52efa0
 dev.c | 57 +++++++++++++++++++++++++++++++++++++++------------------
52efa0
 1 file changed, 39 insertions(+), 18 deletions(-)
52efa0
52efa0
diff --git a/dev.c b/dev.c
52efa0
index effe789f38d8..a493e51ac95c 100644
52efa0
--- a/dev.c
52efa0
+++ b/dev.c
52efa0
@@ -4246,6 +4246,10 @@ get_mq_diskio(unsigned long q, unsigned long *mq_count)
52efa0
 	unsigned long mctx_addr;
52efa0
 	struct diskio tmp;
52efa0
 
52efa0
+	if (INVALID_MEMBER(blk_mq_ctx_rq_dispatched) ||
52efa0
+	    INVALID_MEMBER(blk_mq_ctx_rq_completed))
52efa0
+		return;
52efa0
+
52efa0
 	memset(&tmp, 0x00, sizeof(struct diskio));
52efa0
 
52efa0
 	readmem(q + OFFSET(request_queue_queue_ctx), KVADDR, &queue_ctx,
52efa0
@@ -4475,24 +4479,41 @@ display_one_diskio(struct iter *i, unsigned long gendisk, ulong flags)
52efa0
 		&& (io.read + io.write == 0))
52efa0
 		return;
52efa0
 
52efa0
-	fprintf(fp, "%s%s%s  %s%s%s%s  %s%5d%s%s%s%s%s",
52efa0
-		mkstring(buf0, 5, RJUST|INT_DEC, (char *)(unsigned long)major),
52efa0
-		space(MINSPACE),
52efa0
-		mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, (char *)gendisk),
52efa0
-		space(MINSPACE),
52efa0
-		mkstring(buf2, 10, LJUST, disk_name),
52efa0
-		space(MINSPACE),
52efa0
-		mkstring(buf3, VADDR_PRLEN <= 11 ? 11 : VADDR_PRLEN,
52efa0
-			 LJUST|LONG_HEX, (char *)queue_addr),
52efa0
-		space(MINSPACE),
52efa0
-		io.read + io.write,
52efa0
-		space(MINSPACE),
52efa0
-		mkstring(buf4, 5, RJUST|INT_DEC,
52efa0
-			(char *)(unsigned long)io.read),
52efa0
-		space(MINSPACE),
52efa0
-		mkstring(buf5, 5, RJUST|INT_DEC,
52efa0
-			(char *)(unsigned long)io.write),
52efa0
-		space(MINSPACE));
52efa0
+	if (use_mq_interface(queue_addr) &&
52efa0
+	    (INVALID_MEMBER(blk_mq_ctx_rq_dispatched) ||
52efa0
+	     INVALID_MEMBER(blk_mq_ctx_rq_completed)))
52efa0
+		fprintf(fp, "%s%s%s  %s%s%s%s  %s%s%s",
52efa0
+			mkstring(buf0, 5, RJUST|INT_DEC, (char *)(unsigned long)major),
52efa0
+			space(MINSPACE),
52efa0
+			mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, (char *)gendisk),
52efa0
+			space(MINSPACE),
52efa0
+			mkstring(buf2, 10, LJUST, disk_name),
52efa0
+			space(MINSPACE),
52efa0
+			mkstring(buf3, VADDR_PRLEN <= 11 ? 11 : VADDR_PRLEN,
52efa0
+				 LJUST|LONG_HEX, (char *)queue_addr),
52efa0
+			space(MINSPACE),
52efa0
+			mkstring(buf4, 17, RJUST, "(not supported)"),
52efa0
+			space(MINSPACE));
52efa0
+
52efa0
+	else
52efa0
+		fprintf(fp, "%s%s%s  %s%s%s%s  %s%5d%s%s%s%s%s",
52efa0
+			mkstring(buf0, 5, RJUST|INT_DEC, (char *)(unsigned long)major),
52efa0
+			space(MINSPACE),
52efa0
+			mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, (char *)gendisk),
52efa0
+			space(MINSPACE),
52efa0
+			mkstring(buf2, 10, LJUST, disk_name),
52efa0
+			space(MINSPACE),
52efa0
+			mkstring(buf3, VADDR_PRLEN <= 11 ? 11 : VADDR_PRLEN,
52efa0
+				 LJUST|LONG_HEX, (char *)queue_addr),
52efa0
+			space(MINSPACE),
52efa0
+			io.read + io.write,
52efa0
+			space(MINSPACE),
52efa0
+			mkstring(buf4, 5, RJUST|INT_DEC,
52efa0
+				(char *)(unsigned long)io.read),
52efa0
+			space(MINSPACE),
52efa0
+			mkstring(buf5, 5, RJUST|INT_DEC,
52efa0
+				(char *)(unsigned long)io.write),
52efa0
+			space(MINSPACE));
52efa0
 
52efa0
 	if (VALID_MEMBER(request_queue_in_flight)) {
52efa0
 		if (!use_mq_interface(queue_addr)) {
52efa0
-- 
52efa0
2.20.1
52efa0