From 36046fc79fdc3cb6995cb236a86f994e022e6cf8 Mon Sep 17 00:00:00 2001 From: hannken Date: Sat, 23 Apr 2011 07:36:02 +0000 Subject: [PATCH] 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. --- sys/ufs/ffs/ffs_balloc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index b97dc23e3a81..3683cbb19218 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -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. @@ -41,7 +41,7 @@ */ #include -__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) #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; } 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) pref = ffs_blkpref_ufs1(ip, lbn, 0, flags | B_METAONLY, NULL); @@ -846,6 +850,10 @@ ffs_balloc_ufs2(struct vnode *vp, off_t off, int size, kauth_cred_t cred, goto fail; } 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) pref = ffs_blkpref_ufs2(ip, lbn, 0, flags | B_METAONLY, NULL);