Linux RAID subsystem development
 help / color / mirror / Atom feed
* [PATCH] mdadm: handle super == NULL case in avail_size1
@ 2017-08-31 17:37 Song Liu
  2017-08-31 23:36 ` NeilBrown
  0 siblings, 1 reply; 4+ messages in thread
From: Song Liu @ 2017-08-31 17:37 UTC (permalink / raw)
  To: linux-raid
  Cc: Song Liu, shli, neilb, kernel-team, dan.j.williams, hch,
	jes.sorensen

Summary:

Handling super == NULL case in avail_size1() was removed a while
back. However, it is still useful in the following stack:

avail_size1() with st->sb == NULL
array_try_spare() with st == NULL
try_spare() with st == NULL
Incremental() with st == NULL

This patch adds the handling of super == NULL back to avail_size1().

Signed-off-by: Song Liu <songliubraving@fb.com>
---
 super1.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/super1.c b/super1.c
index f6a1045..5e8d967 100644
--- a/super1.c
+++ b/super1.c
@@ -2340,7 +2340,9 @@ static __u64 avail_size1(struct supertype *st, __u64 devsize,
 	if (devsize < 24)
 		return 0;
 
-	if (__le32_to_cpu(super->feature_map) & MD_FEATURE_BITMAP_OFFSET) {
+	if (!super)
+		bmspace = choose_bm_space(devsize);
+	else if (__le32_to_cpu(super->feature_map) & MD_FEATURE_BITMAP_OFFSET) {
 		/* hot-add. allow for actual size of bitmap */
 		struct bitmap_super_s *bsb;
 		bsb = (struct bitmap_super_s *)(((char*)super)+MAX_SB_SIZE);
@@ -2350,7 +2352,7 @@ static __u64 avail_size1(struct supertype *st, __u64 devsize,
 	}
 
 	/* Allow space for bad block log */
-	if (super->bblog_size)
+	if (super && super->bblog_size)
 		bbspace = __le16_to_cpu(super->bblog_size);
 
 	if (st->minor_version < 0)
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-01  0:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-31 17:37 [PATCH] mdadm: handle super == NULL case in avail_size1 Song Liu
2017-08-31 23:36 ` NeilBrown
2017-08-31 23:46   ` Song Liu
2017-09-01  0:21     ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox