diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -1297,6 +1297,7 @@ { struct g_geom *gp; struct g_provider *pp; + unsigned remn; g_topology_lock(); gp = g_new_geomf(&g_md_class, "md%d", sc->unit); @@ -1305,6 +1306,13 @@ devstat_remove_entry(pp->stat); pp->stat = NULL; pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE; + /* Prune off any residual fractional sector. */ + remn = sc->mediasize % sc->sectorsize; + if (remn != 0) { + printf("md%d: truncating fractional last sector by %u bytes\n", + sc->unit, remn); + sc->mediasize -= remn; + } pp->mediasize = sc->mediasize; pp->sectorsize = sc->sectorsize; switch (sc->type) { @@ -1674,7 +1682,7 @@ { struct md_s *sc; unsigned sectsize; - int error, i; + int error; sx_assert(&md_sx, SA_XLOCKED); @@ -1746,10 +1754,6 @@ return (error); } - /* Prune off any residual fractional sector */ - i = sc->mediasize % sc->sectorsize; - sc->mediasize -= i; - mdinit(sc); return (0); }