Home | History | Annotate | Download | only in ext2fs

Lines Matching defs:cg

122 	int cg;
139 cg = ino_to_cg(fs, ip->i_number);
141 cg = dtog(fs, bpref);
142 bno = (daddr_t)ext2fs_hashalloc(ip, cg, bpref, fs->e2fs_bsize,
177 int cg;
185 cg = ext2fs_dirpref(fs);
187 cg = ino_to_cg(fs, pip->i_number);
188 ipref = cg * fs->e2fs.e2fs_ipg + 1;
189 ino = (ino_t)ext2fs_hashalloc(pip, cg, (long)ipref, mode, ext2fs_nodealloccg);
212 int cg, maxspace, mincg, avgifree;
217 for (cg = 0; cg < fs->e2fs_ncg; cg++) {
219 (fs2h16(fs->e2fs_gd[cg].ext2bgd_nifree_hi) << 16)
220 | fs2h16(fs->e2fs_gd[cg].ext2bgd_nifree);
225 (fs2h16(fs->e2fs_gd[cg].ext2bgd_nbfree_hi) << 16)
226 | fs2h16(fs->e2fs_gd[cg].ext2bgd_nbfree);
228 mincg = cg;
251 int cg, i;
278 cg = ino_to_cg(fs, ip->i_number);
279 return fs->e2fs.e2fs_bpg * cg + fs->e2fs.e2fs_first_dblock + 1;
291 ext2fs_hashalloc(struct inode *ip, int cg, long pref, int size,
296 int i, icg = cg;
302 result = (*allocator)(ip, cg, pref, size);
309 cg += i;
310 if (cg >= fs->e2fs_ncg)
311 cg -= fs->e2fs_ncg;
312 result = (*allocator)(ip, cg, 0, size);
321 cg = (icg + 2) % fs->e2fs_ncg;
323 result = (*allocator)(ip, cg, 0, size);
326 cg++;
327 if (cg == fs->e2fs_ncg)
328 cg = 0;
341 ext2fs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
349 if (fs->e2fs_gd[cg].ext2bgd_nbfree == 0 &&
350 fs->e2fs_gd[cg].ext2bgd_nbfree_hi == 0)
353 fs2h32(fs->e2fs_gd[cg].ext2bgd_b_bitmap),
354 fs2h32(fs->e2fs_gd[cg].ext2bgd_b_bitmap_hi)),
361 if (dtog(fs, bpref) != cg)
366 (fs->e2fs_gd[cg].ext2bgd_flags & h2fs16(E2FS_BG_BLOCK_UNINIT)))) {
367 ext2fs_init_bb(fs, cg, &fs->e2fs_gd[cg], bbp);
368 fs->e2fs_gd[cg].ext2bgd_flags &= h2fs16(~E2FS_BG_BLOCK_UNINIT);
417 printf("%s: cg=%d bno=%d fs=%s\n", __func__,
418 cg, bno, fs->e2fs_fsmnt);
424 ext2fs_cg_update(fs, cg, &fs->e2fs_gd[cg], -1, 0, 0, 0);
427 return cg * fs->e2fs.e2fs_fpg + fs->e2fs.e2fs_first_dblock + bno;
440 ext2fs_nodealloccg(struct inode *ip, int cg, daddr_t ipref, int mode)
451 if (fs->e2fs_gd[cg].ext2bgd_nifree == 0 &&
452 fs->e2fs_gd[cg].ext2bgd_nifree_hi == 0)
455 fs2h32(fs->e2fs_gd[cg].ext2bgd_i_bitmap),
456 fs2h32(fs->e2fs_gd[cg].ext2bgd_i_bitmap_hi)),
463 KASSERT(!E2FS_HAS_GD_CSUM(fs) || (fs->e2fs_gd[cg].ext2bgd_flags & h2fs16(E2FS_BG_INODE_ZEROED)) != 0);
467 (fs->e2fs_gd[cg].ext2bgd_flags & h2fs16(E2FS_BG_INODE_UNINIT)))) {
468 KASSERT(fs2h16(fs->e2fs_gd[cg].ext2bgd_nifree) == fs->e2fs.e2fs_ipg);
470 fs->e2fs_gd[cg].ext2bgd_flags &= h2fs16(~E2FS_BG_INODE_UNINIT);
486 printf("%s: cg = %d, ipref = %lld, fs = %s\n", __func__,
487 cg, (long long)ipref, fs->e2fs_fsmnt);
502 ext2fs_cg_update(fs, cg, &fs->e2fs_gd[cg],
506 return cg * fs->e2fs.e2fs_ipg + ipref + 1;
521 int error, cg;
524 cg = dtog(fs, bno);
527 (fs->e2fs_gd[cg].ext2bgd_flags & h2fs16(E2FS_BG_BLOCK_UNINIT)) == 0);
536 fs2h32(fs->e2fs_gd[cg].ext2bgd_b_bitmap),
537 fs2h32(fs->e2fs_gd[cg].ext2bgd_b_bitmap_hi)),
552 ext2fs_cg_update(fs, cg, &fs->e2fs_gd[cg], 1, 0, 0, 0);
569 int error, cg;
579 cg = ino_to_cg(fs, ino);
582 (fs->e2fs_gd[cg].ext2bgd_flags & h2fs16(E2FS_BG_INODE_UNINIT)) == 0);
585 fs2h32(fs->e2fs_gd[cg].ext2bgd_i_bitmap),
586 fs2h32(fs->e2fs_gd[cg].ext2bgd_i_bitmap_hi)),
602 ext2fs_cg_update(fs, cg, &fs->e2fs_gd[cg],
665 ext2fs_cg_update(struct m_ext2fs *fs, int cg, struct ext2_gd *gd, int nbfree, int nifree, int ndirs, daddr_t ioff)
710 gd->ext2bgd_checksum = ext2fs_cg_get_csum(fs, cg, gd);
797 ext2fs_cg_get_csum(struct m_ext2fs *fs, int cg, struct ext2_gd *gd)
801 uint32_t cg_bswapped = h2fs32((uint32_t)cg);
835 ext2fs_init_bb(struct m_ext2fs *fs, int cg, struct ext2_gd *gd, char *bbp)
842 * No block was ever allocated on this cg before, so the only used
861 int cg, i, error;
866 for(cg = 0; cg < fs->e2fs_ncg; cg++) {
867 gd = &fs->e2fs_gd[cg];
870 uint16_t csum = ext2fs_cg_get_csum(fs, cg, gd);
873 __func__, cg, gd->ext2bgd_checksum, csum);
924 gd->ext2bgd_checksum = ext2fs_cg_get_csum(fs, cg, gd);