Lines Matching refs:cg
108 int cg; in ext2_alloc() local
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()
391 int error, cg; in ext2_valloc() local
407 cg = ext2_dirpref(pip); 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()
416 ino = (ino_t)ext2_hashalloc(pip, cg, (long)ipref, mode, ext2_nodealloccg); in ext2_valloc()
601 int cg, prefcg, cgsize; in ext2_dirpref() local
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()
627 mincg = cg; in ext2_dirpref()
628 minndir = e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]); in ext2_dirpref()
630 for (cg = 0; cg < prefcg; 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()
634 mincg = cg; in ext2_dirpref()
635 minndir = e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]); 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()
672 return (cg); in ext2_dirpref()
674 for (cg = 0; cg < prefcg; cg++) 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()
679 return (cg); 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()
686 return (cg); in ext2_dirpref()
687 for (cg = 0; cg < prefcg; cg++) in ext2_dirpref()
688 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= avgifree) in ext2_dirpref()
690 return (cg); in ext2_dirpref()
751 ext2_hashalloc(struct inode *ip, int cg, long pref, int size, in ext2_hashalloc() argument
756 int i, icg = cg; in ext2_hashalloc()
763 result = (*allocator)(ip, cg, pref, size); in ext2_hashalloc()
770 cg += i; in ext2_hashalloc()
771 if (cg >= fs->e2fs_gcount) in ext2_hashalloc()
772 cg -= fs->e2fs_gcount; in ext2_hashalloc()
773 result = (*allocator)(ip, cg, 0, size); in ext2_hashalloc()
782 cg = (icg + 2) % fs->e2fs_gcount; in ext2_hashalloc()
784 result = (*allocator)(ip, cg, 0, size); in ext2_hashalloc()
787 cg++; in ext2_hashalloc()
788 if (cg == fs->e2fs_gcount) in ext2_hashalloc()
789 cg = 0; 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()
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()
818 if (cg == first || cg == first + 1 || cg == last) in ext2_cg_number_gdb_meta()
825 ext2_cg_number_gdb(struct m_ext2fs *fs, int cg) in ext2_cg_number_gdb() argument
830 metagroup = cg / EXT2_DESCS_PER_BLOCK(fs); 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()
847 cg < le32toh(fs->e2fs->e3fs_first_meta_bg) * in ext2_number_base_meta_blocks()
850 number += ext2_cg_number_gdb(fs, cg); in ext2_number_base_meta_blocks()
854 number += ext2_cg_number_gdb(fs, cg); in ext2_number_base_meta_blocks()
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()
900 bit_max = ext2_number_base_meta_blocks(fs, cg); in ext2_cg_block_bitmap_init()
907 start = (uint64_t)cg * fs->e2fs_bpg + in ext2_cg_block_bitmap_init()
911 tmp = e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg]); 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()
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()
923 while( tmp < e2fs_gd_get_i_tables(&fs->e2fs_gd[cg]) + in ext2_cg_block_bitmap_init()
926 ext2_block_in_group(fs, tmp, cg)) 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
963 gd = &fs->e2fs_gd[cg]; in ext2_b_bitmap_validate()
965 group_first_block = ((uint64_t)cg) * fs->e2fs_fpg + in ext2_b_bitmap_validate()
972 "bad block bitmap, group", cg); in ext2_b_bitmap_validate()
980 "bad inode bitmap", cg); in ext2_b_bitmap_validate()
988 "bad inode table, group", cg); in ext2_b_bitmap_validate()
1002 ext2_alloccg(struct inode *ip, int cg, daddr_t bpref, int size) in ext2_alloccg() argument
1013 if (e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) == 0) in ext2_alloccg()
1018 e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg])), 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()
1125 cg, (intmax_t)bno, fs->e2fs_fsmnt); in ext2_alloccg()
1131 ext2_clusteracct(fs, bbp, cg, bno, -1); 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()
1137 ext2_gd_b_bitmap_csum_set(fs, cg, bp); in ext2_alloccg()
1139 return (((uint64_t)cg) * fs->e2fs_fpg + in ext2_alloccg()
1152 ext2_clusteralloc(struct inode *ip, int cg, daddr_t bpref, int len) in ext2_clusteralloc() argument
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()
1181 lp = &fs->e2fs_clustersum[cg].cs_sum[len]; 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()
1239 ext2_clusteracct(fs, bbp, cg, bno + i, -1); 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()
1248 return (cg * fs->e2fs_fpg + le32toh(fs->e2fs->e2fs_first_dblock) in ext2_clusteralloc()
1259 ext2_zero_inode_table(struct inode *ip, int cg) in ext2_zero_inode_table() argument
1267 if (le16toh(fs->e2fs_gd[cg].ext4bgd_flags) & EXT2_BG_INODE_ZEROED) in ext2_zero_inode_table()
1274 e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]), in ext2_zero_inode_table()
1279 e2fs_gd_get_i_tables(&fs->e2fs_gd[cg]) + used_blks + i), 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()
1310 ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipref, int mode) in ext2_nodealloccg() argument
1323 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) == 0) in ext2_nodealloccg()
1327 e2fs_gd_get_i_bitmap(&fs->e2fs_gd[cg])), in ext2_nodealloccg()
1335 if (le16toh(fs->e2fs_gd[cg].ext4bgd_flags) & 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()
1346 error = ext2_zero_inode_table(ip, cg); 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()
1383 ext2_nodealloccg_bmap_corrupted, cg, ipref, 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()
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()
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()
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()
1426 int cg, error; in ext2_blkfree() local
1431 cg = dtog(fs, bno); in ext2_blkfree()
1438 fsbtodb(fs, e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg])), in ext2_blkfree()
1451 ext2_clusteracct(fs, bbp, cg, bno, 1); 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()
1457 ext2_gd_b_bitmap_csum_set(fs, cg, bp); in ext2_blkfree()
1472 int error, cg; in ext2_vfree() local
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()
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()
1509 ext2_gd_i_bitmap_csum_set(fs, cg, bp); in ext2_vfree()
1550 ext2_cg_has_sb(struct m_ext2fs *fs, int cg) in ext2_cg_has_sb() argument
1554 if (cg == 0) 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()
1564 if ((cg <= 1) || in ext2_cg_has_sb()
1568 if (!(cg & 1)) in ext2_cg_has_sb()
1572 a3 <= cg || a5 <= cg || a7 <= cg; in ext2_cg_has_sb()
1574 if (cg == a3 || cg == a5 || cg == a7) in ext2_cg_has_sb()