From 8132b0dbf4dbf6e1b743fc68a06b45da6324cf0d Mon Sep 17 00:00:00 2001 From: krw Date: Tue, 26 Apr 2016 13:38:24 +0000 Subject: Do NOT attempt a rebuild using a hot spare with a sector size greater than the sector size of the softraid volume. i.e. 512-byte hot spares should work on 4096-byte volumes but 4096-byte hotspares will not work on 512-byte volumes. Pointed out, errors corrected and ok jsing@ --- sys/dev/softraid.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sys/dev/softraid.c') diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 4c79d9306c9..6ae04dce36d 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.372 2016/04/26 13:22:16 krw Exp $ */ +/* $OpenBSD: softraid.c,v 1.373 2016/04/26 13:38:24 krw Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom * Copyright (c) 2008 Chris Kuethe @@ -3032,7 +3032,8 @@ sr_hotspare_rebuild(struct sr_discipline *sd) rw_enter_write(&sc->sc_hs_lock); cl = &sc->sc_hotspare_list; SLIST_FOREACH(hotspare, cl, src_link) - if (hotspare->src_size >= chunk->src_size) + if (hotspare->src_size >= chunk->src_size && + hotspare->src_secsize <= sd->sd_meta->ssdi.ssd_secsize) break; if (hotspare != NULL) { @@ -3209,6 +3210,11 @@ sr_rebuild_init(struct sr_discipline *sd, dev_t dev, int hotspare) } else if (size > csize) sr_warn(sc, "%s partition too large, wasting %lld bytes", devname, (long long)((size - csize) << DEV_BSHIFT)); + if (label.d_secsize > sd->sd_meta->ssdi.ssd_secsize) { + sr_error(sc, "%s sector size too large, <= %u bytes " + "required", devname, label.d_secsize); + goto done; + } /* Ensure that this chunk is not already in use. */ status = sr_chunk_in_use(sc, dev); -- cgit v1.2.3-59-g8ed1b