View | Details | Raw Unified | Return to bug 211361
Collapse All | Expand All

(-)usr.sbin/bsdinstall/partedit/gpart_ops.c (-6 / +20 lines)
Lines 795-800 Link Here
795
{
795
{
796
	struct gconfig *gc;
796
	struct gconfig *gc;
797
	struct gprovider *pp, **providers;
797
	struct gprovider *pp, **providers;
798
	intmax_t sectorsize, stripesize, offset;
798
	intmax_t lastend;
799
	intmax_t lastend;
799
	intmax_t start, end;
800
	intmax_t start, end;
800
	intmax_t maxsize, maxstart;
801
	intmax_t maxsize, maxstart;
Lines 845-856 Link Here
845
846
846
	pp = LIST_FIRST(&geom->lg_consumer)->lg_provider;
847
	pp = LIST_FIRST(&geom->lg_consumer)->lg_provider;
847
848
848
	/* Compute beginning of new partition and maximum available space */
849
	/*
849
	if (pp->lg_stripesize > 0 &&
850
	 * Round the start and size of the largest available space up to
850
	    (maxstart*pp->lg_sectorsize % pp->lg_stripesize) != 0) {
851
	 * the nearest multiple of the adjusted stripe size.
851
		intmax_t offset = (pp->lg_stripesize -
852
	 *
852
		    ((maxstart*pp->lg_sectorsize) % pp->lg_stripesize)) /
853
	 * The adjusted stripe size is the least common multiple of the
853
		    pp->lg_sectorsize;
854
	 * actual stripe size, or the sector size if no stripe size was
855
	 * reported, and 4096.  The reason for this is that contemporary
856
	 * disks often have 4096-byte physical sectors but report 512
857
	 * bytes instead for compatibility with older / broken operating
858
	 * systems and BIOSes.  For the same reasons, virtualized storage
859
	 * may also report a 512-byte stripe size, or none at all.
860
	 */
861
	sectorsize = pp->lg_sectorsize;
862
	if ((stripesize = pp->lg_stripesize) == 0)
863
		stripesize = sectorsize;
864
	while (stripesize % 4096 != 0)
865
		stripesize *= 2;
866
	if ((offset = maxstart * sectorsize % stripesize) != 0) {
867
		offset = (stripesize - offset) / sectorsize;
854
		maxstart += offset;
868
		maxstart += offset;
855
		maxsize -= offset;
869
		maxsize -= offset;
856
	}
870
	}

Return to bug 211361