From 2701b421aa0569f10556efc6edb62666e86708c5 Mon Sep 17 00:00:00 2001 From: otto Date: Fri, 19 Aug 2016 08:06:25 +0000 Subject: [PATCH] Start with a default fragsize of 2048, double it for large disks and then cap based on sector size. This avoid too large fragments on 4k disks. Problem noted by David Vasek; ok krw@ --- sbin/disklabel/editor.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 4f9207bec40..f52a3139196 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.300 2015/12/10 17:26:59 mmcc Exp $ */ +/* $OpenBSD: editor.c,v 1.301 2016/08/19 08:06:25 otto Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller @@ -667,12 +667,15 @@ cylinderalign: /* Everything seems ok so configure the partition. */ DL_SETPSIZE(pp, secs); DL_SETPOFFSET(pp, chunkstart); - fragsize = (lp->d_secsize == DEV_BSIZE) ? 2048 : - lp->d_secsize; + fragsize = 2048; if (secs * lp->d_secsize > 128ULL * 1024 * 1024 * 1024) fragsize *= 2; if (secs * lp->d_secsize > 512ULL * 1024 * 1024 * 1024) fragsize *= 2; + if (fragsize < lp->d_secsize) + fragsize = lp->d_secsize; + if (fragsize > MAXBSIZE / 8) + fragsize = MAXBSIZE / 8; #if defined (__sparc__) && !defined(__sparc64__) /* can't boot from > 8k boot blocks */ pp->p_fragblock = @@ -891,13 +894,14 @@ editor_add(struct disklabel *lp, char *p) if (get_offset(lp, partno) == 0 && get_size(lp, partno) == 0) { - fragsize = (lp->d_secsize == DEV_BSIZE) ? 2048 : - lp->d_secsize; + fragsize = 2048; new_size = DL_GETPSIZE(pp) * lp->d_secsize; if (new_size > 128ULL * 1024 * 1024 * 1024) fragsize *= 2; if (new_size > 512ULL * 1024 * 1024 * 1024) fragsize *= 2; + if (fragsize < lp->d_secsize) + fragsize = lp->d_secsize; if (fragsize > MAXBSIZE / 8) fragsize = MAXBSIZE / 8; #if defined (__sparc__) && !defined(__sparc64__) -- 2.20.1