Add function lbn_offset to calculate offset of the indirect block of

given level.

Reviewed by:	jeff
Tested by:	pho
This commit is contained in:
Konstantin Belousov 2010-11-11 11:35:42 +00:00
parent 4e4ff01629
commit fae5c47dd4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=215113
3 changed files with 18 additions and 11 deletions

View file

@ -582,9 +582,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
* 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;

View file

@ -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

View file

@ -606,6 +606,11 @@ struct cg {
? (fs)->fs_bsize \
: (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
@ -631,17 +636,23 @@ 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.
*/
#define INOPB(fs) ((fs)->fs_inopb)
#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.
*/