From owner-svn-src-head@FreeBSD.ORG Thu Nov 11 11:35:42 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6BF110656AE; Thu, 11 Nov 2010 11:35:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AB4208FC24; Thu, 11 Nov 2010 11:35:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oABBZgNE065933; Thu, 11 Nov 2010 11:35:42 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oABBZgK9065929; Thu, 11 Nov 2010 11:35:42 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201011111135.oABBZgK9065929@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 11 Nov 2010 11:35:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215113 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Nov 2010 11:35:42 -0000 Author: kib Date: Thu Nov 11 11:35:42 2010 New Revision: 215113 URL: http://svn.freebsd.org/changeset/base/215113 Log: Add function lbn_offset to calculate offset of the indirect block of given level. Reviewed by: jeff Tested by: pho Modified: head/sys/ufs/ffs/ffs_inode.c head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ffs/fs.h Modified: head/sys/ufs/ffs/ffs_inode.c ============================================================================== --- head/sys/ufs/ffs/ffs_inode.c Thu Nov 11 11:26:59 2010 (r215112) +++ head/sys/ufs/ffs/ffs_inode.c Thu Nov 11 11:35:42 2010 (r215113) @@ -582,9 +582,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, lev * block to be kept. -1 indicates the entire * block so we need not calculate the index. */ - factor = 1; - for (i = SINGLE; i < level; i++) - factor *= NINDIR(fs); + factor = lbn_offset(fs, level); last = lastbn; if (lastbn > 0) last /= factor; Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Thu Nov 11 11:26:59 2010 (r215112) +++ head/sys/ufs/ffs/ffs_softdep.c Thu Nov 11 11:35:42 2010 (r215113) @@ -6075,9 +6075,7 @@ indir_trunc(freework, dbn, lbn) fs_pendingblocks = 0; freedeps = 0; needj = UFSTOVFS(ump)->mnt_kern_flag & MNTK_SUJ; - lbnadd = 1; - for (i = level; i > 0; i--) - lbnadd *= NINDIR(fs); + lbnadd = lbn_offset(fs, level); /* * Get buffer of block pointers to be freed. This routine is not * called until the zero'ed inode has been written, so it is safe Modified: head/sys/ufs/ffs/fs.h ============================================================================== --- head/sys/ufs/ffs/fs.h Thu Nov 11 11:26:59 2010 (r215112) +++ head/sys/ufs/ffs/fs.h Thu Nov 11 11:35:42 2010 (r215113) @@ -607,6 +607,11 @@ struct cg { : (fragroundup(fs, blkoff(fs, (size))))) /* + * Number of indirects in a filesystem block. + */ +#define NINDIR(fs) ((fs)->fs_nindir) + +/* * Indirect lbns are aligned on NDADDR addresses where single indirects * are the negated address of the lowest lbn reachable, double indirects * are this lbn - 1 and triple indirects are this lbn - 2. This yields @@ -631,6 +636,17 @@ lbn_level(ufs_lbn_t lbn) } return (-1); } + +static inline ufs_lbn_t +lbn_offset(struct fs *fs, int level) +{ + ufs_lbn_t res; + + for (res = 1; level > 0; level--) + res *= NINDIR(fs); + return (res); +} + /* * Number of inodes in a secondary storage block/fragment. */ @@ -638,11 +654,6 @@ lbn_level(ufs_lbn_t lbn) #define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift) /* - * Number of indirects in a filesystem block. - */ -#define NINDIR(fs) ((fs)->fs_nindir) - -/* * Softdep journal record format. */