Diff below adds some debug output to narrow issue down if indeed it was the editor_allocspace() that causes the problem.
Kenneth Westerback <[email protected]> writes: > Anton Lindqvist <[email protected]> writes: > >> On Wed, Jun 28, 2023 at 06:12:48AM -0600, Kenneth R Westerback wrote: >>> CVSROOT: /cvs >>> Module name: src >>> Changes by: [email protected] 2023/06/28 06:12:48 >>> >>> Modified files: >>> sbin/disklabel : editor.c >>> >>> Log message: >>> Refactor editor_allocspace() into easier to follow pieces. >>> >>> editor_allocspace() interates over alloc_tables calling >>> allocate_space(). allocate_space() iterates over >>> space_allocations calling allocate_partition(). >>> allocate_partition() calls allocate_diskchunk() which finds disk >>> space for the partition. >>> >>> No intentional functional change. >>> >>> ok otto@ >>> >> My regress machines failed today during autoinstall with the following >> error: >> >> disklabel: autoalloc failed >> Autopartitioning failed >> >> These machines are using disk templates. I haven't been able to test a >> revert yet but this looks like the prime suspect according to the cvs >> delta. > > Some more data would be helpful. Like, what are the 'template' files you > are using? What is in the autoinstall script? What architecture is this? > > The regress tests in the tree pass with no problems noted. -- .... Ken diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index a84900331dc..8193cbdd315 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -578,8 +578,11 @@ allocate_diskchunk(const struct disklabel *lp, #endif if (maxstop < largest.stop) largest.stop = maxstop; - if (CHUNKSZ(&largest) < DL_BLKTOSEC(lp, sa->minsz)) + if (CHUNKSZ(&largest) < DL_BLKTOSEC(lp, sa->minsz)) { + fprintf(stderr, "CHUNKSZ(&largest) (%llu) < '%s' sa->minsz (%llu)\n", + CHUNKSZ(&largest), sa->mp, sa->minsz); return NULL; + } return &largest; } @@ -598,8 +601,10 @@ allocate_partition(struct disklabel *lp, struct space_allocation *sa) if (DL_GETPSIZE(pp) == 0 || pp->p_fstype == FS_UNUSED) break; } - if (partno >= nitems(lp->d_partitions)) + if (partno >= nitems(lp->d_partitions)) { + fprintf(stderr, "No free partition available\n"); return 1; /* No free partition. */ + } /* Find appropriate chunk of free space. */ chunk = allocate_diskchunk(lp, sa); @@ -612,8 +617,10 @@ allocate_partition(struct disklabel *lp, struct space_allocation *sa) pp->p_fstype = FS_SWAP; else if (sa->mp[0] == '/') pp->p_fstype = FS_BSDFFS; - else + else { + fprintf(stderr, "Invalid mount point '%s'\n", sa->mp); return 1; + } DL_SETPSIZE(pp, chunk->stop - chunk->start); DL_SETPOFFSET(pp, chunk->start); @@ -622,8 +629,10 @@ allocate_partition(struct disklabel *lp, struct space_allocation *sa) mountpoints[partno] = strdup(sa->mp); if (mountpoints[partno] == NULL) err(1, NULL); - if (set_fragblock(lp, partno)) + if (set_fragblock(lp, partno)) { + fprintf(stderr, "set_fragblock() failed\n"); return 1; + } } return 0; @@ -662,8 +671,11 @@ allocate_space(struct disklabel *lp, const struct alloc_table *alloc_table) sa[i] = alloc_table->table[i]; if (alloc_table->table == alloc_big) allocate_physmemincr(&sa[i]); - if (xtrablks < sa[i].minsz) + if (xtrablks < sa[i].minsz) { + fprintf(stderr, "xtrablks (%llu) < sa[%d].minsz (%llu)\n", + xtrablks, i, sa[i].minsz); return 1; /* Too few free blocks. */ + } xtrablks -= sa[i].minsz; } sa[alloc_table->sz - 1].rate = 100; /* Last allocation is greedy. */
