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

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