diff options
author | Grigoriy Orlov <gluk@cvs.openbsd.org> | 2001-04-19 16:22:19 +0000 |
---|---|---|
committer | Grigoriy Orlov <gluk@cvs.openbsd.org> | 2001-04-19 16:22:19 +0000 |
commit | e6b97ebf903a720407574154e9d255be05af6a78 (patch) | |
tree | f73bf1383c88151e3e7918ff10a5893bf89ee82d /sys | |
parent | 41d17e79c339aa7b59c1b00e6d2603868d348f2e (diff) |
Cleanup dirpref and synhronize superblock with freebsd.
From FreeBSD with little changes.
art@ ok.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 26 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/fs.h | 24 |
3 files changed, 32 insertions, 24 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index c323def393f..c473c617942 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_alloc.c,v 1.27 2001/04/06 20:43:31 gluk Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.28 2001/04/19 16:22:16 gluk Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -636,13 +636,15 @@ noinodes: /* * Find a cylinder group to place a directory. * - * The policy implemented by this algorithm is to allocate inode - * in the same cylinder group as a parent directory in, but also - * reserve space for file's data and inodes. Restrict number of - * directories which may be allocated one after another in a same - * cg without intervening by files. + * The policy implemented by this algorithm is to allocate a + * directory inode in the same cylinder group as its parent + * directory, but also to reserve space for its files inodes + * and data. Restrict the number of directories which may be + * allocated one after another in the same cylinder group + * without intervening allocation of files. + * * If we allocate a first level directory then force allocation - * in another cg. + * in another cylinder group. */ static ino_t ffs_dirpref(pip) @@ -710,8 +712,6 @@ ffs_dirpref(pip) #endif cgsize = fs->fs_fsize * fs->fs_fpg; dirsize = fs->fs_avgfilesize * fs->fs_avgfpdir; - if (dirsize <= 0) - dirsize = 16384 * 64; curdirsize = avgndir ? (cgsize - avgbfree * fs->fs_bsize) / avgndir : 0; if (dirsize < curdirsize) dirsize = curdirsize; @@ -733,8 +733,6 @@ ffs_dirpref(pip) fs->fs_cs(fs, cg).cs_nbfree >= minbfree) { if (fs->fs_contigdirs[cg] < maxcontigdirs) goto end; - else - continue; } for (cg = 0; cg < prefcg; cg++) if (fs->fs_cs(fs, cg).cs_ndir < maxndir && @@ -742,10 +740,10 @@ ffs_dirpref(pip) fs->fs_cs(fs, cg).cs_nbfree >= minbfree) { if (fs->fs_contigdirs[cg] < maxcontigdirs) goto end; - else - continue; } - /* This work when we have deficit in space */ + /* + * This is a backstop when we have deficit in space. + */ for (cg = prefcg; cg < fs->fs_ncg; cg++) if (fs->fs_cs(fs, cg).cs_nifree >= avgifree) goto end; diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index cbeee670a6c..88fcc43e0fd 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.39 2001/04/15 23:46:29 gluk Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.40 2001/04/19 16:22:17 gluk Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -807,6 +807,10 @@ ffs_oldfscompat(fs) fs->fs_qbmask = ~fs->fs_bmask; /* XXX */ fs->fs_qfmask = ~fs->fs_fmask; /* XXX */ } /* XXX */ + if (fs->fs_avgfilesize <= 0) /* XXX */ + fs->fs_avgfilesize = AVFILESIZ; /* XXX */ + if (fs->fs_avgfpdir <= 0) /* XXX */ + fs->fs_avgfpdir = AFPDIR; /* XXX */ return (0); } diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h index e8e9f0bf3c1..2d8ed8abdc0 100644 --- a/sys/ufs/ffs/fs.h +++ b/sys/ufs/ffs/fs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fs.h,v 1.11 2001/04/13 02:39:04 gluk Exp $ */ +/* $OpenBSD: fs.h,v 1.12 2001/04/19 16:22:16 gluk Exp $ */ /* $NetBSD: fs.h,v 1.6 1995/04/12 21:21:02 mycroft Exp $ */ /* @@ -117,7 +117,7 @@ * and the third points to an array that tracks the creation of new * directories. */ -#define NOCSPTRS ((128 / sizeof(void *)) - 2) +#define NOCSPTRS ((128 / sizeof(void *)) - 3) /* * A summary of contiguous blocks of various sizes is maintained @@ -143,6 +143,16 @@ #define DEFAULTOPT FS_OPTTIME /* + * The directory preference algorithm(dirpref) can be tuned by adjusting + * the following parameters which tell the system the average file size + * and the average number of files per directory. These defaults are well + * selected for typical filesystems, but may need to be tuned for odd + * cases like filesystems being used for sqiud caches or news spools. + */ +#define AVFILESIZ 16384 /* expected average file size */ +#define AFPDIR 64 /* expected number of files per directory */ + +/* * Per cylinder group information; summarized in blocks allocated * from first cylinder group data blocks. These blocks have to be * read in from fs_csaddr (size fs_cssize) in addition to the @@ -228,19 +238,15 @@ struct fs { /* these fields retain the current block allocation info */ int32_t fs_cgrotor; /* last cg searched */ void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */ + u_int8_t *fs_contigdirs; /* # of contiguously allocated dirs */ struct csum *fs_csp; /* cg summary info buffer for fs_cs */ int32_t *fs_maxcluster; /* max cluster in each cyl group */ int32_t fs_cpc; /* cyl per cycle in postbl */ int16_t fs_opostbl[16][8]; /* old rotation block list head */ -#if LONG_BIT == 64 - int32_t fs_sparecon[45]; /* reserved for future constants */ -#else - int32_t fs_sparecon[46]; /* reserved for future constants */ -#endif -/* these fields used in dirpref routine for optimization */ - u_int8_t *fs_contigdirs; /* # of contiguously allocated dirs */ + int32_t fs_snapinum[20]; /* reserved for snapshot inode nums */ int32_t fs_avgfilesize; /* expected average file size */ int32_t fs_avgfpdir; /* expected # of files per directory */ + int32_t fs_sparecon[27]; /* reserved for future constants */ time_t fs_fscktime; /* last time fsck(8)ed */ int32_t fs_contigsumsize; /* size of cluster summary array */ int32_t fs_maxsymlinklen; /* max length of an internal symlink */ |