Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102671357
D29492.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D29492.diff
View Options
diff --git a/usr.sbin/makefs/ffs.h b/usr.sbin/makefs/ffs.h
--- a/usr.sbin/makefs/ffs.h
+++ b/usr.sbin/makefs/ffs.h
@@ -44,6 +44,7 @@
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
+#include <stdbool.h>
typedef struct {
char label[MAXVOLLEN]; /* volume name/label */
@@ -52,6 +53,7 @@
int cpg; /* cylinders per group */
int cpgflg; /* cpg was specified by user */
int density; /* bytes per inode */
+ bool min_inodes; /* allocate minimum number of inodes */
int ntracks; /* number of tracks */
int nsectors; /* number of sectors */
int rpm; /* rpm */
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -190,6 +190,7 @@
ffs_opts->fsize= -1;
ffs_opts->cpg= -1;
ffs_opts->density= -1;
+ ffs_opts->min_inodes= false;
ffs_opts->minfree= -1;
ffs_opts->optimization= -1;
ffs_opts->maxcontig= -1;
@@ -266,6 +267,11 @@
printf("ffs_makefs: image %s directory %s root %p\n",
image, dir, root);
+ /* if user wants no free space, use minimum number of inodes */
+ if (fsopts->minsize == 0 && fsopts->freeblockpc == 0 &&
+ fsopts->freeblocks == 0)
+ ((ffs_opt_t *)fsopts->fs_specific)->min_inodes = true;
+
/* validate tree and options */
TIMER_START(start);
ffs_validate(dir, root, fsopts);
@@ -424,7 +430,7 @@
if (fsopts->roundup > 0)
fsopts->size = roundup(fsopts->size, fsopts->roundup);
- /* calculate density if necessary */
+ /* calculate density to just fit inodes if no free space */
if (ffs_opts->density == -1)
ffs_opts->density = fsopts->size / fsopts->inodes + 1;
diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c
--- a/usr.sbin/makefs/ffs/mkfs.c
+++ b/usr.sbin/makefs/ffs/mkfs.c
@@ -117,10 +117,13 @@
struct fs *
ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
{
- int fragsperinode, optimalfpg, origdensity, minfpg, lastminfpg;
+ int fragsperinode, optimalfpg, origdensity, mindensity;
+ int minfpg, lastminfpg;
int32_t csfrags;
uint32_t i, cylno;
long long sizepb;
+ ino_t maxinum;
+ int minfragsperinode; /* minimum ratio of frags to inodes */
void *space;
int size;
int nprintcols, printcolwidth;
@@ -312,7 +315,20 @@
* can put into each cylinder group. If this is too big, we reduce
* the density until it fits.
*/
+ maxinum = (((int64_t)(1)) << 32) - INOPB(&sblock);
+ minfragsperinode = 1 + fssize / maxinum;
+ mindensity = minfragsperinode * fsize;
+ if (density == 0)
+ density = MAX(2, minfragsperinode) * fsize;
+ if (density < mindensity) {
+ origdensity = density;
+ density = mindensity;
+ fprintf(stderr, "density increased from %d to %d\n",
+ origdensity, density);
+ }
origdensity = density;
+ if (!ffs_opts->min_inodes)
+ density = MIN(density, MAX(2, minfragsperinode) * fsize);
for (;;) {
fragsperinode = MAX(numfrags(&sblock, density), 1);
minfpg = fragsperinode * INOPB(&sblock);
diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -312,7 +312,10 @@
.It Sy bsize
Block size.
.It Sy density
-Bytes per inode.
+Bytes per inode. If unset, will allocate the minimum number of inodes to
+represent the filesystem if no free space has been requested (free blocks
+or minimum size set); otherwise the larger of the newfs defaults or what
+is required by the free inode parameters if set.
.It Sy fsize
Fragment size.
.It Sy label
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 3:55 PM (20 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14660954
Default Alt Text
D29492.diff (3 KB)
Attached To
Mode
D29492: Add more inodes to VM images by having makefs allocate extra inodes when making images with free space.
Attached
Detach File
Event Timeline
Log In to Comment