Lines Matching refs:fs
29 * @(#)fs.h 8.13 (Berkeley) 3/21/95
51 * For filesystem fs, the offsets of the various blocks of interest
53 * [fs->fs_sblkno] Super-block
54 * [fs->fs_cblkno] Cylinder group block
55 * [fs->fs_iblkno] Inode blocks
56 * [fs->fs_dblkno] Data blocks
57 * The beginning of cylinder group cg in fs, is given by
58 * the ``cgbase(fs, cg)'' macro.
97 * information in the inode, using the ``blksize(fs, ip, lbn)'' macro.
260 struct fs {
270 int32_t fs_old_size; /* number of blocks in fs */
271 int32_t fs_old_dsize; /* number of data blocks in fs */
273 int32_t fs_bsize; /* size of basic blocks in fs */
274 int32_t fs_fsize; /* size of frag blocks in fs */
275 int32_t fs_frag; /* number of frags in a block in fs */
331 u_int *fs_active; /* (u) used by snapshots to track fs */
341 int64_t fs_size; /* number of blocks in fs */
342 int64_t fs_dsize; /* number of data blocks in fs */
370 CTASSERT(sizeof(struct fs) == 1376);
432 #define ACTIVECGNUM(fs, cg) ((fs)->fs_active[(cg) / (NBBY * sizeof(int))])
434 #define ACTIVESET(fs, cg) do { \
435 if ((fs)->fs_active) \
436 ACTIVECGNUM((fs), (cg)) |= ACTIVECGOFF((cg)); \
438 #define ACTIVECLEAR(fs, cg) do { \
439 if ((fs)->fs_active) \
440 ACTIVECGNUM((fs), (cg)) &= ~ACTIVECGOFF((cg)); \
449 #define CGSIZE(fs) \
451 /* old btotoff */ (fs)->fs_old_cpg * sizeof(int32_t) + \
452 /* old boff */ (fs)->fs_old_cpg * sizeof(u_int16_t) + \
453 /* inode map */ howmany((fs)->fs_ipg, NBBY) + \
454 /* block map */ howmany((fs)->fs_fpg, NBBY) +\
455 /* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \
456 /* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \
457 /* cluster map */ howmany(fragstoblks(fs, (fs)->fs_fpg), NBBY)))
467 #define fs_cs(fs, indx) fs_csp[indx]
521 #define fsbtodb(fs, b) ((daddr_t)(b) << (fs)->fs_fsbtodb)
522 #define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb)
528 #define cgbase(fs, c) (((ufs2_daddr_t)(fs)->fs_fpg) * (c))
529 #define cgdata(fs, c) (cgdmin(fs, c) + (fs)->fs_metaspace) /* data zone */
530 #define cgmeta(fs, c) (cgdmin(fs, c)) /* meta data */
531 #define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */
532 #define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */
533 #define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */
534 #define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */
535 #define cgstart(fs, c) \
536 ((fs)->fs_magic == FS_UFS2_MAGIC ? cgbase(fs, c) : \
537 (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask))))
545 #define ino_to_cg(fs, x) (((ino_t)(x)) / (fs)->fs_ipg)
546 #define ino_to_fsba(fs, x) \
547 ((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, (ino_t)(x))) + \
548 (blkstofrags((fs), ((((ino_t)(x)) % (fs)->fs_ipg) / INOPB(fs))))))
549 #define ino_to_fsbo(fs, x) (((ino_t)(x)) % INOPB(fs))
555 #define dtog(fs, d) ((d) / (fs)->fs_fpg)
556 #define dtogd(fs, d) ((d) % (fs)->fs_fpg)
562 #define blkmap(fs, map, loc) \
563 (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag)))
570 #define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \
571 ((loc) & ~((fs)->fs_bmask))
572 #define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \
573 ((loc) & ~((fs)->fs_fmask))
574 #define lfragtosize(fs, frag) /* calculates ((off_t)frag * fs->fs_fsize) */ \
575 (((off_t)(frag)) << (fs)->fs_fshift)
576 #define lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \
577 (((off_t)(blk)) << (fs)->fs_bshift)
579 #define smalllblktosize(fs, blk) /* calculates (blk * fs->fs_bsize) */ \
580 ((blk) << (fs)->fs_bshift)
581 #define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \
582 ((loc) >> (fs)->fs_bshift)
583 #define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \
584 ((loc) >> (fs)->fs_fshift)
585 #define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \
586 (((size) + (fs)->fs_bsize - 1) & (fs)->fs_bmask)
587 #define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \
588 (((size) + (fs)->fs_fsize - 1) & (fs)->fs_fmask)
589 #define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \
590 ((frags) >> (fs)->fs_fragshift)
591 #define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \
592 ((blks) << (fs)->fs_fragshift)
593 #define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \
594 ((fsb) & ((fs)->fs_frag - 1))
595 #define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \
596 ((fsb) &~ ((fs)->fs_frag - 1))
602 #define freespace(fs, percentreserved) \
603 (blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \
604 (fs)->fs_cstotal.cs_nffree - \
605 (((off_t)((fs)->fs_dsize)) * (percentreserved) / 100))
610 #define blksize(fs, ip, lbn) \
611 (((lbn) >= NDADDR || (ip)->i_size >= smalllblktosize(fs, (lbn) + 1)) \
612 ? (fs)->fs_bsize \
613 : (fragroundup(fs, blkoff(fs, (ip)->i_size))))
614 #define sblksize(fs, size, lbn) \
615 (((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \
616 ? (fs)->fs_bsize \
617 : (fragroundup(fs, blkoff(fs, (size)))))
622 #define NINDIR(fs) ((fs)->fs_nindir)
651 lbn_offset(struct fs *fs, int level)
656 res *= NINDIR(fs);
663 #define INOPB(fs) ((fs)->fs_inopb)
664 #define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift)