Try to keep snapshot indirect blocks contiguous.

This speeds up snapshot creation by a factor of ~3 and reduces
the file system suspension time by a factor of ~5.
This commit is contained in:
hannken 2011-04-23 07:36:02 +00:00
parent b19ce40796
commit 36046fc79f
1 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_balloc.c,v 1.53 2011/03/06 17:08:38 bouyer Exp $ */ /* $NetBSD: ffs_balloc.c,v 1.54 2011/04/23 07:36:02 hannken Exp $ */
/* /*
* Copyright (c) 2002 Networks Associates Technology, Inc. * Copyright (c) 2002 Networks Associates Technology, Inc.
@ -41,7 +41,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_balloc.c,v 1.53 2011/03/06 17:08:38 bouyer Exp $"); __KERNEL_RCSID(0, "$NetBSD: ffs_balloc.c,v 1.54 2011/04/23 07:36:02 hannken Exp $");
#if defined(_KERNEL_OPT) #if defined(_KERNEL_OPT)
#include "opt_quota.h" #include "opt_quota.h"
@ -320,6 +320,10 @@ ffs_balloc_ufs1(struct vnode *vp, off_t off, int size, kauth_cred_t cred,
goto fail; goto fail;
} }
mutex_enter(&ump->um_lock); mutex_enter(&ump->um_lock);
/* Try to keep snapshot indirect blocks contiguous. */
if (i == num && (ip->i_flags & SF_SNAPSHOT) != 0)
pref = ffs_blkpref_ufs1(ip, lbn, indirs[i-1].in_off,
flags | B_METAONLY, &bap[0]);
if (pref == 0) if (pref == 0)
pref = ffs_blkpref_ufs1(ip, lbn, 0, flags | B_METAONLY, pref = ffs_blkpref_ufs1(ip, lbn, 0, flags | B_METAONLY,
NULL); NULL);
@ -846,6 +850,10 @@ ffs_balloc_ufs2(struct vnode *vp, off_t off, int size, kauth_cred_t cred,
goto fail; goto fail;
} }
mutex_enter(&ump->um_lock); mutex_enter(&ump->um_lock);
/* Try to keep snapshot indirect blocks contiguous. */
if (i == num && (ip->i_flags & SF_SNAPSHOT) != 0)
pref = ffs_blkpref_ufs2(ip, lbn, indirs[i-1].in_off,
flags | B_METAONLY, &bap[0]);
if (pref == 0) if (pref == 0)
pref = ffs_blkpref_ufs2(ip, lbn, 0, flags | B_METAONLY, pref = ffs_blkpref_ufs2(ip, lbn, 0, flags | B_METAONLY,
NULL); NULL);