Lines Matching refs:cg
106 int cg; in ext2_alloc() local
129 cg = ino_to_cg(fs, ip->i_number); in ext2_alloc()
131 cg = dtog(fs, bpref); in ext2_alloc()
132 bno = (daddr_t)ext2_hashalloc(ip, cg, bpref, fs->e2fs_bsize, in ext2_alloc()
389 int error, cg; in ext2_valloc() local
405 cg = ext2_dirpref(pip); in ext2_valloc()
406 if (fs->e2fs_contigdirs[cg] < 255) in ext2_valloc()
407 fs->e2fs_contigdirs[cg]++; in ext2_valloc()
409 cg = ino_to_cg(fs, pip->i_number); in ext2_valloc()
410 if (fs->e2fs_contigdirs[cg] > 0) in ext2_valloc()
411 fs->e2fs_contigdirs[cg]--; in ext2_valloc()
413 ipref = cg * fs->e2fs_ipg + 1; in ext2_valloc()
414 ino = (ino_t)ext2_hashalloc(pip, cg, (long)ipref, mode, ext2_nodealloccg); in ext2_valloc()
599 int cg, prefcg, cgsize; in ext2_dirpref() local
621 for (cg = prefcg; cg < fs->e2fs_gcount; cg++) in ext2_dirpref()
622 if (e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) < minndir && in ext2_dirpref()
623 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= avgifree && in ext2_dirpref()
624 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) >= avgbfree) { in ext2_dirpref()
625 mincg = cg; in ext2_dirpref()
626 minndir = e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]); in ext2_dirpref()
628 for (cg = 0; cg < prefcg; cg++) in ext2_dirpref()
629 if (e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) < minndir && in ext2_dirpref()
630 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= avgifree && in ext2_dirpref()
631 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) >= avgbfree) { in ext2_dirpref()
632 mincg = cg; in ext2_dirpref()
633 minndir = e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]); in ext2_dirpref()
665 for (cg = prefcg; cg < fs->e2fs_gcount; cg++) in ext2_dirpref()
666 if (e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) < maxndir && in ext2_dirpref()
667 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= minifree && in ext2_dirpref()
668 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) >= minbfree) { in ext2_dirpref()
669 if (fs->e2fs_contigdirs[cg] < maxcontigdirs) in ext2_dirpref()
670 return (cg); in ext2_dirpref()
672 for (cg = 0; cg < prefcg; cg++) in ext2_dirpref()
673 if (e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) < maxndir && in ext2_dirpref()
674 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= minifree && in ext2_dirpref()
675 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) >= minbfree) { in ext2_dirpref()
676 if (fs->e2fs_contigdirs[cg] < maxcontigdirs) in ext2_dirpref()
677 return (cg); in ext2_dirpref()
682 for (cg = prefcg; cg < fs->e2fs_gcount; cg++) in ext2_dirpref()
683 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= avgifree) in ext2_dirpref()
684 return (cg); in ext2_dirpref()
685 for (cg = 0; cg < prefcg; cg++) in ext2_dirpref()
686 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) >= avgifree) in ext2_dirpref()
688 return (cg); in ext2_dirpref()
749 ext2_hashalloc(struct inode *ip, int cg, long pref, int size, in ext2_hashalloc() argument
754 int i, icg = cg; in ext2_hashalloc()
761 result = (*allocator)(ip, cg, pref, size); in ext2_hashalloc()
768 cg += i; in ext2_hashalloc()
769 if (cg >= fs->e2fs_gcount) in ext2_hashalloc()
770 cg -= fs->e2fs_gcount; in ext2_hashalloc()
771 result = (*allocator)(ip, cg, 0, size); in ext2_hashalloc()
780 cg = (icg + 2) % fs->e2fs_gcount; in ext2_hashalloc()
782 result = (*allocator)(ip, cg, 0, size); in ext2_hashalloc()
785 cg++; in ext2_hashalloc()
786 if (cg == fs->e2fs_gcount) in ext2_hashalloc()
787 cg = 0; in ext2_hashalloc()
793 ext2_cg_number_gdb_nometa(struct m_ext2fs *fs, int cg) in ext2_cg_number_gdb_nometa() argument
796 if (!ext2_cg_has_sb(fs, cg)) in ext2_cg_number_gdb_nometa()
807 ext2_cg_number_gdb_meta(struct m_ext2fs *fs, int cg) in ext2_cg_number_gdb_meta() argument
812 metagroup = cg / EXT2_DESCS_PER_BLOCK(fs); in ext2_cg_number_gdb_meta()
816 if (cg == first || cg == first + 1 || cg == last) in ext2_cg_number_gdb_meta()
823 ext2_cg_number_gdb(struct m_ext2fs *fs, int cg) in ext2_cg_number_gdb() argument
828 metagroup = cg / EXT2_DESCS_PER_BLOCK(fs); in ext2_cg_number_gdb()
832 return (ext2_cg_number_gdb_nometa(fs, cg)); in ext2_cg_number_gdb()
834 return ext2_cg_number_gdb_meta(fs, cg); in ext2_cg_number_gdb()
838 ext2_number_base_meta_blocks(struct m_ext2fs *fs, int cg) in ext2_number_base_meta_blocks() argument
842 number = ext2_cg_has_sb(fs, cg); in ext2_number_base_meta_blocks()
845 cg < le32toh(fs->e2fs->e3fs_first_meta_bg) * in ext2_number_base_meta_blocks()
848 number += ext2_cg_number_gdb(fs, cg); in ext2_number_base_meta_blocks()
852 number += ext2_cg_number_gdb(fs, cg); in ext2_number_base_meta_blocks()
881 ext2_block_in_group(struct m_ext2fs *fs, e4fs_daddr_t block, int cg) in ext2_block_in_group() argument
884 return ((ext2_get_group_number(fs, block) == cg) ? 1 : 0); in ext2_block_in_group()
888 ext2_cg_block_bitmap_init(struct m_ext2fs *fs, int cg, struct buf *bp) in ext2_cg_block_bitmap_init() argument
893 if (!(le16toh(fs->e2fs_gd[cg].ext4bgd_flags) & EXT2_BG_BLOCK_UNINIT)) in ext2_cg_block_bitmap_init()
898 bit_max = ext2_number_base_meta_blocks(fs, cg); in ext2_cg_block_bitmap_init()
905 start = (uint64_t)cg * fs->e2fs_bpg + in ext2_cg_block_bitmap_init()
909 tmp = e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg]); in ext2_cg_block_bitmap_init()
911 ext2_block_in_group(fs, tmp, cg)) in ext2_cg_block_bitmap_init()
914 tmp = e2fs_gd_get_i_bitmap(&fs->e2fs_gd[cg]); in ext2_cg_block_bitmap_init()
916 ext2_block_in_group(fs, tmp, cg)) in ext2_cg_block_bitmap_init()
919 tmp = e2fs_gd_get_i_tables(&fs->e2fs_gd[cg]); in ext2_cg_block_bitmap_init()
921 while( tmp < e2fs_gd_get_i_tables(&fs->e2fs_gd[cg]) + in ext2_cg_block_bitmap_init()
924 ext2_block_in_group(fs, tmp, cg)) in ext2_cg_block_bitmap_init()
938 fs->e2fs_gd[cg].ext4bgd_flags = htole16(le16toh( in ext2_cg_block_bitmap_init()
939 fs->e2fs_gd[cg].ext4bgd_flags) & ~EXT2_BG_BLOCK_UNINIT); in ext2_cg_block_bitmap_init()
945 ext2_b_bitmap_validate(struct m_ext2fs *fs, struct buf *bp, int cg) in ext2_b_bitmap_validate() argument
961 gd = &fs->e2fs_gd[cg]; in ext2_b_bitmap_validate()
963 group_first_block = ((uint64_t)cg) * fs->e2fs_fpg + in ext2_b_bitmap_validate()
970 "bad block bitmap, group", cg); in ext2_b_bitmap_validate()
978 "bad inode bitmap", cg); in ext2_b_bitmap_validate()
986 "bad inode table, group", cg); in ext2_b_bitmap_validate()
1000 ext2_alloccg(struct inode *ip, int cg, daddr_t bpref, int size) in ext2_alloccg() argument
1011 if (e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) == 0) in ext2_alloccg()
1016 e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg])), in ext2_alloccg()
1023 error = ext2_cg_block_bitmap_init(fs, cg, bp); in ext2_alloccg()
1027 ext2_gd_b_bitmap_csum_set(fs, cg, bp); in ext2_alloccg()
1029 error = ext2_gd_b_bitmap_csum_verify(fs, cg, bp); in ext2_alloccg()
1033 error = ext2_b_bitmap_validate(fs,bp, cg); in ext2_alloccg()
1041 if (e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) == 0) in ext2_alloccg()
1046 if (dtog(fs, bpref) != cg) in ext2_alloccg()
1123 cg, (intmax_t)bno, fs->e2fs_fsmnt); in ext2_alloccg()
1129 ext2_clusteracct(fs, bbp, cg, bno, -1); in ext2_alloccg()
1131 e2fs_gd_set_nbfree(&fs->e2fs_gd[cg], in ext2_alloccg()
1132 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) - 1); in ext2_alloccg()
1135 ext2_gd_b_bitmap_csum_set(fs, cg, bp); in ext2_alloccg()
1137 return (((uint64_t)cg) * fs->e2fs_fpg + in ext2_alloccg()
1150 ext2_clusteralloc(struct inode *ip, int cg, daddr_t bpref, int len) in ext2_clusteralloc() argument
1163 if (fs->e2fs_maxcluster[cg] < len) in ext2_clusteralloc()
1168 fsbtodb(fs, e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg])), in ext2_clusteralloc()
1179 lp = &fs->e2fs_clustersum[cg].cs_sum[len]; in ext2_clusteralloc()
1190 lp = &fs->e2fs_clustersum[cg].cs_sum[len - 1]; in ext2_clusteralloc()
1194 fs->e2fs_maxcluster[cg] = i; in ext2_clusteralloc()
1200 if (dtog(fs, bpref) != cg) in ext2_clusteralloc()
1237 ext2_clusteracct(fs, bbp, cg, bno + i, -1); in ext2_clusteralloc()
1239 e2fs_gd_set_nbfree(&fs->e2fs_gd[cg], in ext2_clusteralloc()
1240 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) - 1); in ext2_clusteralloc()
1246 return (cg * fs->e2fs_fpg + le32toh(fs->e2fs->e2fs_first_dblock) in ext2_clusteralloc()
1257 ext2_zero_inode_table(struct inode *ip, int cg) in ext2_zero_inode_table() argument
1265 if (le16toh(fs->e2fs_gd[cg].ext4bgd_flags) & EXT2_BG_INODE_ZEROED) in ext2_zero_inode_table()
1272 e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]), in ext2_zero_inode_table()
1277 e2fs_gd_get_i_tables(&fs->e2fs_gd[cg]) + used_blks + i), in ext2_zero_inode_table()
1286 fs->e2fs_gd[cg].ext4bgd_flags = htole16(le16toh( in ext2_zero_inode_table()
1287 fs->e2fs_gd[cg].ext4bgd_flags) | EXT2_BG_INODE_ZEROED); in ext2_zero_inode_table()
1308 ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipref, int mode) in ext2_nodealloccg() argument
1321 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) == 0) in ext2_nodealloccg()
1325 e2fs_gd_get_i_bitmap(&fs->e2fs_gd[cg])), in ext2_nodealloccg()
1333 if (le16toh(fs->e2fs_gd[cg].ext4bgd_flags) & in ext2_nodealloccg()
1339 fs->e2fs_gd[cg].ext4bgd_flags = htole16(le16toh( in ext2_nodealloccg()
1340 fs->e2fs_gd[cg].ext4bgd_flags) & in ext2_nodealloccg()
1343 ext2_gd_i_bitmap_csum_set(fs, cg, bp); in ext2_nodealloccg()
1344 error = ext2_zero_inode_table(ip, cg); in ext2_nodealloccg()
1351 error = ext2_gd_i_bitmap_csum_verify(fs, cg, bp); in ext2_nodealloccg()
1357 if (e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) == 0) { in ext2_nodealloccg()
1381 ext2_nodealloccg_bmap_corrupted, cg, ipref, in ext2_nodealloccg()
1392 e2fs_gd_set_nifree(&fs->e2fs_gd[cg], in ext2_nodealloccg()
1393 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) - 1); in ext2_nodealloccg()
1396 ifree = fs->e2fs_ipg - e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]); in ext2_nodealloccg()
1398 e2fs_gd_set_i_unused(&fs->e2fs_gd[cg], in ext2_nodealloccg()
1404 e2fs_gd_set_ndirs(&fs->e2fs_gd[cg], in ext2_nodealloccg()
1405 e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) + 1); in ext2_nodealloccg()
1409 ext2_gd_i_bitmap_csum_set(fs, cg, bp); in ext2_nodealloccg()
1411 return ((uint64_t)cg * fs->e2fs_ipg + ipref + 1); in ext2_nodealloccg()
1424 int cg, error; in ext2_blkfree() local
1429 cg = dtog(fs, bno); in ext2_blkfree()
1436 fsbtodb(fs, e2fs_gd_get_b_bitmap(&fs->e2fs_gd[cg])), in ext2_blkfree()
1449 ext2_clusteracct(fs, bbp, cg, bno, 1); in ext2_blkfree()
1451 e2fs_gd_set_nbfree(&fs->e2fs_gd[cg], in ext2_blkfree()
1452 e2fs_gd_get_nbfree(&fs->e2fs_gd[cg]) + 1); in ext2_blkfree()
1455 ext2_gd_b_bitmap_csum_set(fs, cg, bp); in ext2_blkfree()
1470 int error, cg; in ext2_vfree() local
1480 cg = ino_to_cg(fs, ino); in ext2_vfree()
1482 fsbtodb(fs, e2fs_gd_get_i_bitmap(&fs->e2fs_gd[cg])), in ext2_vfree()
1498 e2fs_gd_set_nifree(&fs->e2fs_gd[cg], in ext2_vfree()
1499 e2fs_gd_get_nifree(&fs->e2fs_gd[cg]) + 1); in ext2_vfree()
1501 e2fs_gd_set_ndirs(&fs->e2fs_gd[cg], in ext2_vfree()
1502 e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) - 1); in ext2_vfree()
1507 ext2_gd_i_bitmap_csum_set(fs, cg, bp); in ext2_vfree()
1548 ext2_cg_has_sb(struct m_ext2fs *fs, int cg) in ext2_cg_has_sb() argument
1552 if (cg == 0) in ext2_cg_has_sb()
1556 if (cg == le32toh(fs->e2fs->e4fs_backup_bgs[0]) || in ext2_cg_has_sb()
1557 cg == le32toh(fs->e2fs->e4fs_backup_bgs[1])) in ext2_cg_has_sb()
1562 if ((cg <= 1) || in ext2_cg_has_sb()
1566 if (!(cg & 1)) in ext2_cg_has_sb()
1570 a3 <= cg || a5 <= cg || a7 <= cg; in ext2_cg_has_sb()
1572 if (cg == a3 || cg == a5 || cg == a7) in ext2_cg_has_sb()