From a3c8c2e60f7046ce84a9944c18118a6c89ad9fc2 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 10 Sep 2007 19:58:14 +0000 Subject: [PATCH] Reduce the limit of vnodes on i386 when ZFS is loaded to 3/4 of the original value, so we don't run out of KVA. The default vnodes limit fits better for UFS, but ZFS allocated more file system specific memory for a vnode than UFS. Don't touch vnodes limit if we detect it was tuned by system administrator and restore original value when ZFS is unloaded. This isn't final fix, but before we implement something better, this will help to stabilize ZFS under heavy load on i386. Approved by: re (bmah) --- .../uts/common/fs/zfs/zfs_vfsops.c | 41 +++++++++++++++++++ .../uts/common/fs/zfs/zfs_vfsops.c | 41 +++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index 259b77cc7878..e08785a31fe8 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -949,6 +949,39 @@ zfs_freevfs(vfs_t *vfsp) atomic_add_32(&zfs_active_fs_count, -1); } +#ifdef __i386__ +static int desiredvnodes_backup; +#endif + +static void +zfs_vnodes_adjust(void) +{ +#ifdef __i386__ + int val; + + desiredvnodes_backup = desiredvnodes; + + /* + * We calculate newdesiredvnodes the same way it is done in + * vntblinit(). If it is equal to desiredvnodes, it means that + * it wasn't tuned by the administrator and we can tune it down. + */ + val = min(maxproc + cnt.v_page_count / 4, 2 * vm_kmem_size / + (5 * (sizeof(struct vm_object) + sizeof(struct vnode)))); + if (desiredvnodes == val) + desiredvnodes = (3 * desiredvnodes) / 4; +#endif +} + +static void +zfs_vnodes_adjust_back(void) +{ + +#ifdef __i386__ + desiredvnodes = desiredvnodes_backup; +#endif +} + void zfs_init(void) { @@ -964,6 +997,13 @@ zfs_init(void) * Initialize znode cache, vnode ops, etc... */ zfs_znode_init(); + + /* + * Reduce number of vnodes. Originally number of vnodes is calculated + * with UFS inode in mind. We reduce it here, because it's too big for + * ZFS/i386. + */ + zfs_vnodes_adjust(); } void @@ -971,6 +1011,7 @@ zfs_fini(void) { zfsctl_fini(); zfs_znode_fini(); + zfs_vnodes_adjust_back(); } int diff --git a/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index 259b77cc7878..e08785a31fe8 100644 --- a/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -949,6 +949,39 @@ zfs_freevfs(vfs_t *vfsp) atomic_add_32(&zfs_active_fs_count, -1); } +#ifdef __i386__ +static int desiredvnodes_backup; +#endif + +static void +zfs_vnodes_adjust(void) +{ +#ifdef __i386__ + int val; + + desiredvnodes_backup = desiredvnodes; + + /* + * We calculate newdesiredvnodes the same way it is done in + * vntblinit(). If it is equal to desiredvnodes, it means that + * it wasn't tuned by the administrator and we can tune it down. + */ + val = min(maxproc + cnt.v_page_count / 4, 2 * vm_kmem_size / + (5 * (sizeof(struct vm_object) + sizeof(struct vnode)))); + if (desiredvnodes == val) + desiredvnodes = (3 * desiredvnodes) / 4; +#endif +} + +static void +zfs_vnodes_adjust_back(void) +{ + +#ifdef __i386__ + desiredvnodes = desiredvnodes_backup; +#endif +} + void zfs_init(void) { @@ -964,6 +997,13 @@ zfs_init(void) * Initialize znode cache, vnode ops, etc... */ zfs_znode_init(); + + /* + * Reduce number of vnodes. Originally number of vnodes is calculated + * with UFS inode in mind. We reduce it here, because it's too big for + * ZFS/i386. + */ + zfs_vnodes_adjust(); } void @@ -971,6 +1011,7 @@ zfs_fini(void) { zfsctl_fini(); zfs_znode_fini(); + zfs_vnodes_adjust_back(); } int