mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-18 06:14:27 +00:00
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:
parent
4e4ff01629
commit
fae5c47dd4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=215113
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue