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

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