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

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