Blame SOURCES/0004-sbitmapq-fix-invalid-offset-for-sbitmap_queue_round_.patch

aefe19
From 530fe6ad7e4d7ff6254596c1219d25ed929e3867 Mon Sep 17 00:00:00 2001
aefe19
From: Lianbo Jiang <lijiang@redhat.com>
aefe19
Date: Mon, 23 May 2022 18:04:15 +0800
aefe19
Subject: [PATCH 04/18] sbitmapq: fix invalid offset for
aefe19
 "sbitmap_queue_round_robin" on Linux v5.13-rc1
aefe19
aefe19
Kernel commit efe1f3a1d583 ("scsi: sbitmap: Maintain allocation
aefe19
round_robin in sbitmap") moved the round_robin member from struct
aefe19
sbitmap_queue to struct sbitmap.  Without the patch, the sbitmapq
aefe19
will fail:
aefe19
aefe19
  crash> sbitmapq 0xffff8e99d0dc8010
aefe19
aefe19
  sbitmapq: invalid structure member offset: sbitmap_queue_round_robin
aefe19
          FILE: sbitmap.c  LINE: 378  FUNCTION: sbitmap_queue_context_load()
aefe19
aefe19
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
aefe19
---
aefe19
 defs.h    |  2 ++
aefe19
 sbitmap.c | 12 ++++++++++--
aefe19
 symbols.c |  2 ++
aefe19
 3 files changed, 14 insertions(+), 2 deletions(-)
aefe19
aefe19
diff --git a/defs.h b/defs.h
aefe19
index 0aeb98c4f654..ecbced24d2e3 100644
aefe19
--- a/defs.h
aefe19
+++ b/defs.h
aefe19
@@ -2169,6 +2169,7 @@ struct offset_table {                    /* stash of commonly-used offsets */
aefe19
 	long sbq_wait_state_wait_cnt;
aefe19
 	long sbq_wait_state_wait;
aefe19
 	long sbitmap_alloc_hint;
aefe19
+	long sbitmap_round_robin;
aefe19
 };
aefe19
 
aefe19
 struct size_table {         /* stash of commonly-used sizes */
aefe19
@@ -5909,6 +5910,7 @@ struct sbitmap_context {
aefe19
 	unsigned map_nr;
aefe19
 	ulong map_addr;
aefe19
 	ulong alloc_hint;
aefe19
+	bool round_robin;
aefe19
 };
aefe19
 
aefe19
 typedef bool (*sbitmap_for_each_fn)(unsigned int idx, void *p);
aefe19
diff --git a/sbitmap.c b/sbitmap.c
aefe19
index 2921d5447c65..7b318b533702 100644
aefe19
--- a/sbitmap.c
aefe19
+++ b/sbitmap.c
aefe19
@@ -352,7 +352,11 @@ static void sbitmap_queue_show(const struct sbitmap_queue_context *sqc,
aefe19
 
aefe19
 	FREEBUF(sbq_wait_state_buf);
aefe19
 
aefe19
-	fprintf(fp, "round_robin = %d\n", sqc->round_robin);
aefe19
+	if (VALID_MEMBER(sbitmap_queue_round_robin))
aefe19
+		fprintf(fp, "round_robin = %d\n", sqc->round_robin);
aefe19
+	else if (VALID_MEMBER(sbitmap_round_robin)) /* 5.13 and later */
aefe19
+		fprintf(fp, "round_robin = %d\n", sc->round_robin);
aefe19
+
aefe19
 	fprintf(fp, "min_shallow_depth = %u\n", sqc->min_shallow_depth);
aefe19
 }
aefe19
 
aefe19
@@ -374,7 +378,8 @@ static void sbitmap_queue_context_load(ulong addr, struct sbitmap_queue_context
aefe19
 	sqc->wake_index = INT(sbitmap_queue_buf + OFFSET(sbitmap_queue_wake_index));
aefe19
 	sqc->ws_addr = ULONG(sbitmap_queue_buf + OFFSET(sbitmap_queue_ws));
aefe19
 	sqc->ws_active = INT(sbitmap_queue_buf + OFFSET(sbitmap_queue_ws_active));
aefe19
-	sqc->round_robin = BOOL(sbitmap_queue_buf + OFFSET(sbitmap_queue_round_robin));
aefe19
+	if (VALID_MEMBER(sbitmap_queue_round_robin))
aefe19
+		sqc->round_robin = BOOL(sbitmap_queue_buf + OFFSET(sbitmap_queue_round_robin));
aefe19
 	sqc->min_shallow_depth = UINT(sbitmap_queue_buf + OFFSET(sbitmap_queue_min_shallow_depth));
aefe19
 
aefe19
 	FREEBUF(sbitmap_queue_buf);
aefe19
@@ -396,6 +401,8 @@ void sbitmap_context_load(ulong addr, struct sbitmap_context *sc)
aefe19
 	sc->map_addr = ULONG(sbitmap_buf + OFFSET(sbitmap_map));
aefe19
 	if (VALID_MEMBER(sbitmap_alloc_hint))
aefe19
 		sc->alloc_hint = ULONG(sbitmap_buf + OFFSET(sbitmap_alloc_hint));
aefe19
+	if (VALID_MEMBER(sbitmap_round_robin))
aefe19
+		sc->round_robin = BOOL(sbitmap_buf + OFFSET(sbitmap_round_robin));
aefe19
 
aefe19
 	FREEBUF(sbitmap_buf);
aefe19
 }
aefe19
@@ -522,6 +529,7 @@ void sbitmapq_init(void)
aefe19
 	MEMBER_OFFSET_INIT(sbitmap_map_nr, "sbitmap", "map_nr");
aefe19
 	MEMBER_OFFSET_INIT(sbitmap_map, "sbitmap", "map");
aefe19
 	MEMBER_OFFSET_INIT(sbitmap_alloc_hint, "sbitmap", "alloc_hint");
aefe19
+	MEMBER_OFFSET_INIT(sbitmap_round_robin, "sbitmap", "round_robin");
aefe19
 
aefe19
 	MEMBER_OFFSET_INIT(sbitmap_queue_sb, "sbitmap_queue", "sb");
aefe19
 	MEMBER_OFFSET_INIT(sbitmap_queue_alloc_hint, "sbitmap_queue", "alloc_hint");
aefe19
diff --git a/symbols.c b/symbols.c
aefe19
index fd0eb06899f0..5d12a021c769 100644
aefe19
--- a/symbols.c
aefe19
+++ b/symbols.c
aefe19
@@ -10710,6 +10710,8 @@ dump_offset_table(char *spec, ulong makestruct)
aefe19
 		OFFSET(sbitmap_map));
aefe19
 	fprintf(fp, "            sbitmap_alloc_hint: %ld\n",
aefe19
 		OFFSET(sbitmap_alloc_hint));
aefe19
+	fprintf(fp, "           sbitmap_round_robin: %ld\n",
aefe19
+		OFFSET(sbitmap_round_robin));
aefe19
 	fprintf(fp, "              sbitmap_queue_sb: %ld\n",
aefe19
 		OFFSET(sbitmap_queue_sb));
aefe19
 	fprintf(fp, "      sbitmap_queue_alloc_hint: %ld\n",
aefe19
-- 
aefe19
2.30.2
aefe19