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

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