NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Very slow filesystem



On Fri, Oct 25, 2013 at 10:40:36AM +0100, Stephen Borrill wrote:
> I've a machine which has a filesysmte that is extremely slow to
> create dirs and files. Look at the time to run mkdir below:

> backup 1# time mkdir /data/backup/previous4
> 0.000u 0.131s 1:31.95 0.1%      0+0k 7912+5io 0pf+0w

Please test the attached patch. It is FreeBSD ffs_alloc.c r121784.
I think it describes your situation accurately and explains the effects you
are seeing.

--chris

http://svnweb.freebsd.org/base?view=revision&revision=121785

Index: ufs/ffs/ffs_alloc.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_alloc.c,v
retrieving revision 1.130
diff -u -r1.130 ffs_alloc.c
--- ufs/ffs/ffs_alloc.c 28 Nov 2011 08:05:07 -0000      1.130
+++ ufs/ffs/ffs_alloc.c 26 Oct 2013 18:52:14 -0000
@@ -723,12 +723,12 @@
         * optimal allocation of a directory inode.
         */
        maxndir = min(avgndir + fs->fs_ipg / 16, fs->fs_ipg);
-       minifree = avgifree - fs->fs_ipg / 4;
-       if (minifree < 0)
-               minifree = 0;
-       minbfree = avgbfree - fragstoblks(fs, fs->fs_fpg) / 4;
-       if (minbfree < 0)
-               minbfree = 0;
+       minifree = avgifree - avgifree / 4;
+       if (minifree < 1)
+               minifree = 1;
+       minbfree = avgbfree - avgbfree / 4;
+       if (minbfree < 1)
+               minbfree = 1;
        cgsize = (int64_t)fs->fs_fsize * fs->fs_fpg;
        dirsize = (int64_t)fs->fs_avgfilesize * fs->fs_avgfpdir;
        if (avgndir != 0) {
@@ -737,7 +737,7 @@
                        dirsize = curdsz;
        }
        if (cgsize < dirsize * 255)
-               maxcontigdirs = cgsize / dirsize;
+               maxcontigdirs = (avgbfree * fs->fs_bsize) / dirsize;
        else
                maxcontigdirs = 255;
        if (fs->fs_avgfpdir > 0)



Home | Main Index | Thread Index | Old Index