Lines Matching refs:fs
105 struct m_ext2fs *fs; in ext2_alloc() local
111 fs = ip->i_e2fs; in ext2_alloc()
115 if ((u_int)size > fs->e2fs_bsize || blkoff(fs, size) != 0) { in ext2_alloc()
117 (long unsigned int)fs->e2fs_bsize, size, fs->e2fs_fsmnt); in ext2_alloc()
123 if (size == fs->e2fs_bsize && fs->e2fs_fbcount == 0) in ext2_alloc()
126 fs->e2fs_fbcount < fs->e2fs_rbcount) in ext2_alloc()
128 if (bpref >= fs->e2fs_bcount) in ext2_alloc()
131 cg = ino_to_cg(fs, ip->i_number); in ext2_alloc()
133 cg = dtog(fs, bpref); in ext2_alloc()
134 bno = (daddr_t)ext2_hashalloc(ip, cg, bpref, fs->e2fs_bsize, in ext2_alloc()
141 ip->i_blocks += btodb(fs->e2fs_bsize); in ext2_alloc()
158 struct m_ext2fs *fs; in ext2_alloc_meta() local
161 fs = ip->i_e2fs; in ext2_alloc_meta()
164 blk = ext2_hashalloc(ip, ino_to_cg(fs, ip->i_number), 0, fs->e2fs_bsize, in ext2_alloc_meta()
204 struct m_ext2fs *fs; in ext2_reallocblks() local
222 fs = ip->i_e2fs; in ext2_reallocblks()
225 if (fs->e2fs_contigsumsize <= 0 || ip->i_flag & IN_E4EXTENTS) in ext2_reallocblks()
254 if (dtog(fs, dbtofsb(fs, buflist->bs_children[0]->b_blkno)) != in ext2_reallocblks()
255 dtog(fs, dbtofsb(fs, buflist->bs_children[len - 1]->b_blkno))) in ext2_reallocblks()
268 if (bread(vp, idp->in_lbn, (int)fs->e2fs_bsize, NOCRED, &sbp)) { in ext2_reallocblks()
287 if (bread(vp, idp->in_lbn, (int)fs->e2fs_bsize, NOCRED, &ebp)) in ext2_reallocblks()
299 if ((newblk = (e2fs_daddr_t)ext2_hashalloc(ip, dtog(fs, pref), pref, in ext2_reallocblks()
314 for (bap = &sbap[soff], i = 0; i < len; i++, blkno += fs->e2fs_fpb) { in ext2_reallocblks()
320 if (buflist->bs_children[i]->b_blkno != fsbtodb(fs, *bap)) in ext2_reallocblks()
359 for (blkno = newblk, i = 0; i < len; i++, blkno += fs->e2fs_fpb) { in ext2_reallocblks()
360 ext2_blkfree(ip, dbtofsb(fs, buflist->bs_children[i]->b_blkno), in ext2_reallocblks()
361 fs->e2fs_bsize); in ext2_reallocblks()
362 buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno); in ext2_reallocblks()
384 struct m_ext2fs *fs; in ext2_valloc() local
395 fs = pip->i_e2fs; in ext2_valloc()
399 if (fs->e2fs_ficount == 0) in ext2_valloc()
408 if (fs->e2fs_contigdirs[cg] < 255) in ext2_valloc()
409 fs->e2fs_contigdirs[cg]++; in ext2_valloc()
411 cg = ino_to_cg(fs, pip->i_number); in ext2_valloc()
412 if (fs->e2fs_contigdirs[cg] > 0) in ext2_valloc()
413 fs->e2fs_contigdirs[cg]--; in ext2_valloc()
415 ipref = cg * fs->e2fs_ipg + 1; in ext2_valloc()
437 ip->i_e2fs = fs = ump->um_e2fs; in ext2_valloc()
440 ip->i_block_group = ino_to_cg(fs, ino); in ext2_valloc()
464 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_EXTENTS) in ext2_valloc()
600 struct m_ext2fs *fs; in ext2_dirpref() local
609 fs = pip->i_e2fs; in ext2_dirpref()
611 avgifree = fs->e2fs_ficount / fs->e2fs_gcount; in ext2_dirpref()
612 avgbfree = fs->e2fs_fbcount / fs->e2fs_gcount; in ext2_dirpref()
613 avgndir = fs->e2fs_total_dir / fs->e2fs_gcount; in ext2_dirpref()
620 prefcg = arc4random() % fs->e2fs_gcount; in ext2_dirpref()
622 minndir = fs->e2fs_ipg; in ext2_dirpref()
623 for (cg = prefcg; cg < fs->e2fs_gcount; cg++) in ext2_dirpref()
624 if (e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) < minndir && in ext2_dirpref()
625 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= avgifree && in ext2_dirpref()
626 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) >= avgbfree) { in ext2_dirpref()
628 minndir = e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]); in ext2_dirpref()
631 if (e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) < minndir && in ext2_dirpref()
632 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= avgifree && in ext2_dirpref()
633 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) >= avgbfree) { in ext2_dirpref()
635 minndir = e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]); in ext2_dirpref()
643 maxndir = min(avgndir + fs->e2fs_ipg / 16, fs->e2fs_ipg); in ext2_dirpref()
650 cgsize = fs->e2fs_fsize * fs->e2fs_fpg; in ext2_dirpref()
653 (cgsize - avgbfree * fs->e2fs_bsize) / avgndir : 0; in ext2_dirpref()
656 maxcontigdirs = min((avgbfree * fs->e2fs_bsize) / dirsize, 255); in ext2_dirpref()
657 maxcontigdirs = min(maxcontigdirs, fs->e2fs_ipg / AFPDIR); in ext2_dirpref()
666 prefcg = ino_to_cg(fs, pip->i_number); in ext2_dirpref()
667 for (cg = prefcg; cg < fs->e2fs_gcount; cg++) in ext2_dirpref()
668 if (e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) < maxndir && in ext2_dirpref()
669 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= minifree && in ext2_dirpref()
670 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) >= minbfree) { in ext2_dirpref()
671 if (fs->e2fs_contigdirs[cg] < maxcontigdirs) in ext2_dirpref()
675 if (e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) < maxndir && in ext2_dirpref()
676 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= minifree && in ext2_dirpref()
677 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) >= minbfree) { in ext2_dirpref()
678 if (fs->e2fs_contigdirs[cg] < maxcontigdirs) in ext2_dirpref()
684 for (cg = prefcg; cg < fs->e2fs_gcount; cg++) in ext2_dirpref()
685 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= avgifree) in ext2_dirpref()
688 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= avgifree) in ext2_dirpref()
710 struct m_ext2fs *fs; in ext2_blkpref() local
713 fs = ip->i_e2fs; in ext2_blkpref()
739 EXT2_BLOCKS_PER_GROUP(fs)) + le32toh(fs->e2fs->e2fs_first_dblock)); in ext2_blkpref()
754 struct m_ext2fs *fs; in ext2_hashalloc() local
759 fs = ip->i_e2fs; in ext2_hashalloc()
769 for (i = 1; i < fs->e2fs_gcount; i *= 2) { in ext2_hashalloc()
771 if (cg >= fs->e2fs_gcount) in ext2_hashalloc()
772 cg -= fs->e2fs_gcount; in ext2_hashalloc()
782 cg = (icg + 2) % fs->e2fs_gcount; in ext2_hashalloc()
783 for (i = 2; i < fs->e2fs_gcount; i++) { in ext2_hashalloc()
788 if (cg == fs->e2fs_gcount) in ext2_hashalloc()
795 ext2_cg_number_gdb_nometa(struct m_ext2fs *fs, int cg) in ext2_cg_number_gdb_nometa() argument
798 if (!ext2_cg_has_sb(fs, cg)) in ext2_cg_number_gdb_nometa()
801 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG)) in ext2_cg_number_gdb_nometa()
802 return (le32toh(fs->e2fs->e3fs_first_meta_bg)); in ext2_cg_number_gdb_nometa()
804 return ((fs->e2fs_gcount + EXT2_DESCS_PER_BLOCK(fs) - 1) / in ext2_cg_number_gdb_nometa()
805 EXT2_DESCS_PER_BLOCK(fs)); in ext2_cg_number_gdb_nometa()
809 ext2_cg_number_gdb_meta(struct m_ext2fs *fs, int cg) in ext2_cg_number_gdb_meta() argument
814 metagroup = cg / EXT2_DESCS_PER_BLOCK(fs); in ext2_cg_number_gdb_meta()
815 first = metagroup * EXT2_DESCS_PER_BLOCK(fs); in ext2_cg_number_gdb_meta()
816 last = first + EXT2_DESCS_PER_BLOCK(fs) - 1; in ext2_cg_number_gdb_meta()
825 ext2_cg_number_gdb(struct m_ext2fs *fs, int cg) in ext2_cg_number_gdb() argument
829 first_meta_bg = le32toh(fs->e2fs->e3fs_first_meta_bg); in ext2_cg_number_gdb()
830 metagroup = cg / EXT2_DESCS_PER_BLOCK(fs); in ext2_cg_number_gdb()
832 if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG) || in ext2_cg_number_gdb()
834 return (ext2_cg_number_gdb_nometa(fs, cg)); in ext2_cg_number_gdb()
836 return ext2_cg_number_gdb_meta(fs, cg); in ext2_cg_number_gdb()
840 ext2_number_base_meta_blocks(struct m_ext2fs *fs, int cg) in ext2_number_base_meta_blocks() argument
844 number = ext2_cg_has_sb(fs, cg); in ext2_number_base_meta_blocks()
846 if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG) || in ext2_number_base_meta_blocks()
847 cg < le32toh(fs->e2fs->e3fs_first_meta_bg) * in ext2_number_base_meta_blocks()
848 EXT2_DESCS_PER_BLOCK(fs)) { in ext2_number_base_meta_blocks()
850 number += ext2_cg_number_gdb(fs, cg); in ext2_number_base_meta_blocks()
851 number += le16toh(fs->e2fs->e2fs_reserved_ngdb); in ext2_number_base_meta_blocks()
854 number += ext2_cg_number_gdb(fs, cg); in ext2_number_base_meta_blocks()
875 ext2_get_group_number(struct m_ext2fs *fs, e4fs_daddr_t block) in ext2_get_group_number() argument
878 return ((block - le32toh(fs->e2fs->e2fs_first_dblock)) / in ext2_get_group_number()
879 fs->e2fs_bsize); in ext2_get_group_number()
883 ext2_block_in_group(struct m_ext2fs *fs, e4fs_daddr_t block, int cg) in ext2_block_in_group() argument
886 return ((ext2_get_group_number(fs, block) == cg) ? 1 : 0); in ext2_block_in_group()
890 ext2_cg_block_bitmap_init(struct m_ext2fs *fs, int cg, struct buf *bp) in ext2_cg_block_bitmap_init() argument
895 if (!(le16toh(fs->e2fs_gd[cg].ext4bgd_flags) & EXT2_BG_BLOCK_UNINIT)) in ext2_cg_block_bitmap_init()
898 memset(bp->b_data, 0, fs->e2fs_bsize); in ext2_cg_block_bitmap_init()
900 bit_max = ext2_number_base_meta_blocks(fs, cg); in ext2_cg_block_bitmap_init()
901 if ((bit_max >> 3) >= fs->e2fs_bsize) in ext2_cg_block_bitmap_init()
907 start = (uint64_t)cg * fs->e2fs_bpg + in ext2_cg_block_bitmap_init()
908 le32toh(fs->e2fs->e2fs_first_dblock); in ext2_cg_block_bitmap_init()
911 tmp = e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg]); in ext2_cg_block_bitmap_init()
912 if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) || in ext2_cg_block_bitmap_init()
913 ext2_block_in_group(fs, tmp, cg)) in ext2_cg_block_bitmap_init()
916 tmp = e2fs_gd_get_i_bitmap(&fs->e2fs_gd[cg]); in ext2_cg_block_bitmap_init()
917 if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) || in ext2_cg_block_bitmap_init()
918 ext2_block_in_group(fs, tmp, cg)) in ext2_cg_block_bitmap_init()
921 tmp = e2fs_gd_get_i_tables(&fs->e2fs_gd[cg]); in ext2_cg_block_bitmap_init()
922 inodes_per_block = fs->e2fs_bsize/EXT2_INODE_SIZE(fs); in ext2_cg_block_bitmap_init()
923 while( tmp < e2fs_gd_get_i_tables(&fs->e2fs_gd[cg]) + in ext2_cg_block_bitmap_init()
924 fs->e2fs_ipg / inodes_per_block ) { in ext2_cg_block_bitmap_init()
925 if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) || in ext2_cg_block_bitmap_init()
926 ext2_block_in_group(fs, tmp, cg)) in ext2_cg_block_bitmap_init()
936 ext2_mark_bitmap_end(fs->e2fs_bpg, fs->e2fs_bsize * 8, in ext2_cg_block_bitmap_init()
940 fs->e2fs_gd[cg].ext4bgd_flags = htole16(le16toh( in ext2_cg_block_bitmap_init()
941 fs->e2fs_gd[cg].ext4bgd_flags) & ~EXT2_BG_BLOCK_UNINIT); in ext2_cg_block_bitmap_init()
947 ext2_b_bitmap_validate(struct m_ext2fs *fs, struct buf *bp, int cg) in ext2_b_bitmap_validate() argument
953 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG)) { in ext2_b_bitmap_validate()
963 gd = &fs->e2fs_gd[cg]; in ext2_b_bitmap_validate()
964 max_bit = fs->e2fs_fpg; in ext2_b_bitmap_validate()
965 group_first_block = ((uint64_t)cg) * fs->e2fs_fpg + in ext2_b_bitmap_validate()
966 le32toh(fs->e2fs->e2fs_first_dblock); in ext2_b_bitmap_validate()
986 if (offset >= max_bit || offset + fs->e2fs_itpg >= max_bit) { in ext2_b_bitmap_validate()
1004 struct m_ext2fs *fs; in ext2_alloccg() local
1011 fs = ip->i_e2fs; in ext2_alloccg()
1013 if (e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) == 0) in ext2_alloccg()
1017 error = bread(ip->i_devvp, fsbtodb(fs, in ext2_alloccg()
1018 e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg])), in ext2_alloccg()
1019 (int)fs->e2fs_bsize, NOCRED, &bp); in ext2_alloccg()
1023 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || in ext2_alloccg()
1024 EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { in ext2_alloccg()
1025 error = ext2_cg_block_bitmap_init(fs, cg, bp); in ext2_alloccg()
1029 ext2_gd_b_bitmap_csum_set(fs, cg, bp); in ext2_alloccg()
1031 error = ext2_gd_b_bitmap_csum_verify(fs, cg, bp); in ext2_alloccg()
1035 error = ext2_b_bitmap_validate(fs,bp, cg); in ext2_alloccg()
1043 if (e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) == 0) in ext2_alloccg()
1048 if (dtog(fs, bpref) != cg) in ext2_alloccg()
1051 bpref = dtogd(fs, bpref); in ext2_alloccg()
1067 start = dtogd(fs, bpref) / NBBY; in ext2_alloccg()
1070 end = howmany(fs->e2fs_fpg, NBBY); in ext2_alloccg()
1117 bno = ext2_mapsearch(fs, bbp, bpref); in ext2_alloccg()
1125 cg, (intmax_t)bno, fs->e2fs_fsmnt); in ext2_alloccg()
1131 ext2_clusteracct(fs, bbp, cg, bno, -1); in ext2_alloccg()
1132 fs->e2fs_fbcount--; in ext2_alloccg()
1133 e2fs_gd_set_nbfree(&fs->e2fs_gd[cg], in ext2_alloccg()
1134 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) - 1); in ext2_alloccg()
1135 fs->e2fs_fmod = 1; in ext2_alloccg()
1137 ext2_gd_b_bitmap_csum_set(fs, cg, bp); in ext2_alloccg()
1139 return (((uint64_t)cg) * fs->e2fs_fpg + in ext2_alloccg()
1140 le32toh(fs->e2fs->e2fs_first_dblock) + bno); in ext2_alloccg()
1154 struct m_ext2fs *fs; in ext2_clusteralloc() local
1162 fs = ip->i_e2fs; in ext2_clusteralloc()
1165 if (fs->e2fs_maxcluster[cg] < len) in ext2_clusteralloc()
1170 fsbtodb(fs, e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg])), in ext2_clusteralloc()
1171 (int)fs->e2fs_bsize, NOCRED, &bp); in ext2_clusteralloc()
1181 lp = &fs->e2fs_clustersum[cg].cs_sum[len]; in ext2_clusteralloc()
1182 for (i = len; i <= fs->e2fs_contigsumsize; i++) in ext2_clusteralloc()
1185 if (i > fs->e2fs_contigsumsize) { in ext2_clusteralloc()
1192 lp = &fs->e2fs_clustersum[cg].cs_sum[len - 1]; in ext2_clusteralloc()
1196 fs->e2fs_maxcluster[cg] = i; in ext2_clusteralloc()
1202 if (dtog(fs, bpref) != cg) in ext2_clusteralloc()
1205 bpref = dtogd(fs, bpref); in ext2_clusteralloc()
1208 for (run = 0, got = bpref; got < fs->e2fs_fpg; got++) { in ext2_clusteralloc()
1224 if (got >= fs->e2fs_fpg) in ext2_clusteralloc()
1233 if (bno >= fs->e2fs_fpg) in ext2_clusteralloc()
1237 for (i = 0; i < len; i += fs->e2fs_fpb) { in ext2_clusteralloc()
1239 ext2_clusteracct(fs, bbp, cg, bno + i, -1); in ext2_clusteralloc()
1240 fs->e2fs_fbcount--; in ext2_clusteralloc()
1241 e2fs_gd_set_nbfree(&fs->e2fs_gd[cg], in ext2_clusteralloc()
1242 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) - 1); in ext2_clusteralloc()
1244 fs->e2fs_fmod = 1; in ext2_clusteralloc()
1248 return (cg * fs->e2fs_fpg + le32toh(fs->e2fs->e2fs_first_dblock) in ext2_clusteralloc()
1261 struct m_ext2fs *fs; in ext2_zero_inode_table() local
1265 fs = ip->i_e2fs; in ext2_zero_inode_table()
1267 if (le16toh(fs->e2fs_gd[cg].ext4bgd_flags) & EXT2_BG_INODE_ZEROED) in ext2_zero_inode_table()
1270 all_blks = le16toh(fs->e2fs->e2fs_inode_size) * fs->e2fs_ipg / in ext2_zero_inode_table()
1271 fs->e2fs_bsize; in ext2_zero_inode_table()
1273 used_blks = howmany(fs->e2fs_ipg - in ext2_zero_inode_table()
1274 e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]), in ext2_zero_inode_table()
1275 fs->e2fs_bsize / EXT2_INODE_SIZE(fs)); in ext2_zero_inode_table()
1278 bp = getblk(ip->i_devvp, fsbtodb(fs, in ext2_zero_inode_table()
1279 e2fs_gd_get_i_tables(&fs->e2fs_gd[cg]) + used_blks + i), in ext2_zero_inode_table()
1280 fs->e2fs_bsize, 0, 0, 0); in ext2_zero_inode_table()
1284 vfs_bio_bzero_buf(bp, 0, fs->e2fs_bsize); in ext2_zero_inode_table()
1288 fs->e2fs_gd[cg].ext4bgd_flags = htole16(le16toh( in ext2_zero_inode_table()
1289 fs->e2fs_gd[cg].ext4bgd_flags) | EXT2_BG_INODE_ZEROED); in ext2_zero_inode_table()
1312 struct m_ext2fs *fs; in ext2_nodealloccg() local
1321 fs = ip->i_e2fs; in ext2_nodealloccg()
1323 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) == 0) in ext2_nodealloccg()
1326 error = bread(ip->i_devvp, fsbtodb(fs, in ext2_nodealloccg()
1327 e2fs_gd_get_i_bitmap(&fs->e2fs_gd[cg])), in ext2_nodealloccg()
1328 (int)fs->e2fs_bsize, NOCRED, &bp); in ext2_nodealloccg()
1333 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || in ext2_nodealloccg()
1334 EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { in ext2_nodealloccg()
1335 if (le16toh(fs->e2fs_gd[cg].ext4bgd_flags) & in ext2_nodealloccg()
1337 ibytes = fs->e2fs_ipg / 8; in ext2_nodealloccg()
1340 fs->e2fs_bsize - 1); in ext2_nodealloccg()
1341 fs->e2fs_gd[cg].ext4bgd_flags = htole16(le16toh( in ext2_nodealloccg()
1342 fs->e2fs_gd[cg].ext4bgd_flags) & in ext2_nodealloccg()
1345 ext2_gd_i_bitmap_csum_set(fs, cg, bp); in ext2_nodealloccg()
1353 error = ext2_gd_i_bitmap_csum_verify(fs, cg, bp); in ext2_nodealloccg()
1359 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) == 0) { in ext2_nodealloccg()
1370 ipref %= fs->e2fs_ipg; in ext2_nodealloccg()
1375 len = howmany(fs->e2fs_ipg - ipref, NBBY); in ext2_nodealloccg()
1384 fs->e2fs_fsmnt); in ext2_nodealloccg()
1394 e2fs_gd_set_nifree(&fs->e2fs_gd[cg], in ext2_nodealloccg()
1395 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) - 1); in ext2_nodealloccg()
1396 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || in ext2_nodealloccg()
1397 EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { in ext2_nodealloccg()
1398 ifree = fs->e2fs_ipg - e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]); in ext2_nodealloccg()
1400 e2fs_gd_set_i_unused(&fs->e2fs_gd[cg], in ext2_nodealloccg()
1401 fs->e2fs_ipg - (ipref + 1)); in ext2_nodealloccg()
1403 fs->e2fs_ficount--; in ext2_nodealloccg()
1404 fs->e2fs_fmod = 1; in ext2_nodealloccg()
1406 e2fs_gd_set_ndirs(&fs->e2fs_gd[cg], in ext2_nodealloccg()
1407 e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) + 1); in ext2_nodealloccg()
1408 fs->e2fs_total_dir++; in ext2_nodealloccg()
1411 ext2_gd_i_bitmap_csum_set(fs, cg, bp); in ext2_nodealloccg()
1413 return ((uint64_t)cg * fs->e2fs_ipg + ipref + 1); in ext2_nodealloccg()
1423 struct m_ext2fs *fs; in ext2_blkfree() local
1429 fs = ip->i_e2fs; in ext2_blkfree()
1431 cg = dtog(fs, bno); in ext2_blkfree()
1432 if (bno >= fs->e2fs_bcount) { in ext2_blkfree()
1438 fsbtodb(fs, e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg])), in ext2_blkfree()
1439 (int)fs->e2fs_bsize, NOCRED, &bp); in ext2_blkfree()
1444 bno = dtogd(fs, bno); in ext2_blkfree()
1447 (long long)bno, fs->e2fs_fsmnt); in ext2_blkfree()
1451 ext2_clusteracct(fs, bbp, cg, bno, 1); in ext2_blkfree()
1452 fs->e2fs_fbcount++; in ext2_blkfree()
1453 e2fs_gd_set_nbfree(&fs->e2fs_gd[cg], in ext2_blkfree()
1454 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) + 1); in ext2_blkfree()
1455 fs->e2fs_fmod = 1; in ext2_blkfree()
1457 ext2_gd_b_bitmap_csum_set(fs, cg, bp); in ext2_blkfree()
1468 struct m_ext2fs *fs; in ext2_vfree() local
1476 fs = pip->i_e2fs; in ext2_vfree()
1478 if ((u_int)ino > fs->e2fs_ipg * fs->e2fs_gcount) in ext2_vfree()
1480 pip->i_devvp, (uintmax_t)ino, fs->e2fs_fsmnt); in ext2_vfree()
1482 cg = ino_to_cg(fs, ino); in ext2_vfree()
1484 fsbtodb(fs, e2fs_gd_get_i_bitmap(&fs->e2fs_gd[cg])), in ext2_vfree()
1485 (int)fs->e2fs_bsize, NOCRED, &bp); in ext2_vfree()
1490 ino = (ino - 1) % fs->e2fs_ipg; in ext2_vfree()
1493 fs->e2fs_fsmnt, ino); in ext2_vfree()
1494 if (fs->e2fs_ronly == 0) in ext2_vfree()
1499 fs->e2fs_ficount++; in ext2_vfree()
1500 e2fs_gd_set_nifree(&fs->e2fs_gd[cg], in ext2_vfree()
1501 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) + 1); in ext2_vfree()
1503 e2fs_gd_set_ndirs(&fs->e2fs_gd[cg], in ext2_vfree()
1504 e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) - 1); in ext2_vfree()
1505 fs->e2fs_total_dir--; in ext2_vfree()
1507 fs->e2fs_fmod = 1; in ext2_vfree()
1509 ext2_gd_i_bitmap_csum_set(fs, cg, bp); in ext2_vfree()
1521 ext2_mapsearch(struct m_ext2fs *fs, char *bbp, daddr_t bpref) in ext2_mapsearch() argument
1531 start = dtogd(fs, bpref) / NBBY; in ext2_mapsearch()
1534 len = howmany(fs->e2fs_fpg, NBBY) - start; in ext2_mapsearch()
1542 "fs=%s", start, len, fs->e2fs_fsmnt); in ext2_mapsearch()
1550 ext2_cg_has_sb(struct m_ext2fs *fs, int cg) in ext2_cg_has_sb() argument
1557 if (EXT2_HAS_COMPAT_FEATURE(fs, EXT2F_COMPAT_SPARSESUPER2)) { in ext2_cg_has_sb()
1558 if (cg == le32toh(fs->e2fs->e4fs_backup_bgs[0]) || in ext2_cg_has_sb()
1559 cg == le32toh(fs->e2fs->e4fs_backup_bgs[1])) in ext2_cg_has_sb()
1565 !EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_SPARSESUPER)) in ext2_cg_has_sb()