Lines Matching defs:cg
93 static ufs_daddr_t ffs_alloccgblk(struct fs *, struct cg *, ufs_daddr_t);
101 static ufs_daddr_t ffs_mapsearch(struct fs *, struct cg *, ufs_daddr_t, int);
103 (struct fs *fs, struct cg *cgp, ufs_daddr_t blkno, int cnt);
133 int cg, error;
158 cg = ino_to_cg(fs, ip->i_number);
160 cg = dtog(fs, bpref);
161 bno = (ufs_daddr_t)ffs_hashalloc(ip, cg, (long)bpref, size,
199 int cg, request, error;
242 cg = dtog(fs, bprev);
243 if (bno = ffs_fragextend(ip, cg, (long)bprev, osize, nsize)) {
302 bno = (ufs_daddr_t)ffs_hashalloc(ip, cg, (long)bpref, request,
382 int cg, error;
396 cg = ino_to_cg(fs, ipref);
399 * in a cg without intervening files.
402 if (fs->fs_contigdirs[cg] < 255)
403 fs->fs_contigdirs[cg]++;
405 if (fs->fs_contigdirs[cg] > 0)
406 fs->fs_contigdirs[cg]--;
408 ino = (ino_t)ffs_hashalloc(pip, cg, (long)ipref, mode, ffs_nodealloccg);
459 int cg, prefcg, dirsize, cgsize;
471 * Force allocation in another cg if creating a first level dir.
481 for (cg = prefcg; cg < fs->fs_ncg; cg++)
482 if (fs->fs_cs(fs, cg).cs_ndir < minndir &&
483 fs->fs_cs(fs, cg).cs_nifree >= avgifree &&
484 fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
485 mincg = cg;
486 minndir = fs->fs_cs(fs, cg).cs_ndir;
488 for (cg = 0; cg < prefcg; cg++)
489 if (fs->fs_cs(fs, cg).cs_ndir < minndir &&
490 fs->fs_cs(fs, cg).cs_nifree >= avgifree &&
491 fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
492 mincg = cg;
493 minndir = fs->fs_cs(fs, cg).cs_ndir;
522 * Limit number of dirs in one cg and reserve space for
527 for (cg = prefcg; cg < fs->fs_ncg; cg++)
528 if (fs->fs_cs(fs, cg).cs_ndir < maxndir &&
529 fs->fs_cs(fs, cg).cs_nifree >= minifree &&
530 fs->fs_cs(fs, cg).cs_nbfree >= minbfree) {
531 if (fs->fs_contigdirs[cg] < maxcontigdirs)
532 return ((ino_t)(fs->fs_ipg * cg));
534 for (cg = 0; cg < prefcg; cg++)
535 if (fs->fs_cs(fs, cg).cs_ndir < maxndir &&
536 fs->fs_cs(fs, cg).cs_nifree >= minifree &&
537 fs->fs_cs(fs, cg).cs_nbfree >= minbfree) {
538 if (fs->fs_contigdirs[cg] < maxcontigdirs)
539 return ((ino_t)(fs->fs_ipg * cg));
544 for (cg = prefcg; cg < fs->fs_ncg; cg++)
545 if (fs->fs_cs(fs, cg).cs_nifree >= avgifree)
546 return ((ino_t)(fs->fs_ipg * cg));
547 for (cg = 0; cg < prefcg; cg++)
548 if (fs->fs_cs(fs, cg).cs_nifree >= avgifree)
550 return ((ino_t)(fs->fs_ipg * cg));
587 register int cg;
613 cg = ino_to_cg(fs, ip->i_number);
614 return (fs->fs_fpg * cg + fs->fs_frag);
635 for (cg = startcg; cg < fs->fs_ncg; cg++)
636 if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
637 fs->fs_cgrotor = cg;
638 return (fs->fs_fpg * cg + fs->fs_frag);
640 for (cg = 0; cg <= startcg; cg++)
641 if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
642 fs->fs_cgrotor = cg;
643 return (fs->fs_fpg * cg + fs->fs_frag);
696 ffs_hashalloc(ip, cg, pref, size, allocator)
698 int cg;
705 int i, icg = cg;
711 result = (*allocator)(ip, cg, pref, size);
718 cg += i;
719 if (cg >= fs->fs_ncg)
720 cg -= fs->fs_ncg;
721 result = (*allocator)(ip, cg, 0, size);
730 cg = (icg + 2) % fs->fs_ncg;
732 result = (*allocator)(ip, cg, 0, size);
735 cg++;
736 if (cg == fs->fs_ncg)
737 cg = 0;
749 ffs_fragextend(ip, cg, bprev, osize, nsize)
751 int cg;
756 register struct cg *cgp;
769 if (fs->fs_cs(fs, cg).cs_nffree < numfrags(fs, nsize - osize))
778 error = (int)buf_bread(ip->i_devvp, (daddr64_t)((unsigned)fsbtodb(fs, cgtod(fs, cg))),
784 cgp = (struct cg *)buf_dataptr(bp);
827 fs->fs_cs(fs, cg).cs_nffree--;
845 ffs_alloccg(ip, cg, bpref, size)
847 int cg;
852 register struct cg *cgp;
864 if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
866 error = (int)buf_bread(ip->i_devvp, (daddr64_t)((unsigned)fsbtodb(fs, cgtod(fs, cg))),
872 cgp = (struct cg *)buf_dataptr(bp);
926 fs->fs_cs(fs, cg).cs_nffree += i;
949 fs->fs_cs(fs, cg).cs_nffree -= frags;
959 return (cg * fs->fs_fpg + bno);
976 register struct cg *cgp;
1085 ffs_clusteralloc(ip, cg, bpref, len)
1087 int cg;
1092 register struct cg *cgp;
1104 if (fs->fs_maxcluster[cg] < len)
1106 if (buf_bread(ip->i_devvp, (daddr64_t)((unsigned)fsbtodb(fs, cgtod(fs, cg))), (int)fs->fs_cgsize,
1109 cgp = (struct cg *)buf_dataptr(bp);
1141 fs->fs_maxcluster[cg] = i;
1159 if (dtog(fs, bpref) != cg)
1194 bno = cg * fs->fs_fpg + blkstofrags(fs, got - run + 1);
1195 if (dtog(fs, bno) != cg)
1223 ffs_nodealloccg(ip, cg, ipref, mode)
1225 int cg;
1230 register struct cg *cgp;
1241 if (fs->fs_cs(fs, cg).cs_nifree == 0)
1243 error = (int)buf_bread(ip->i_devvp, (daddr64_t)((unsigned)fsbtodb(fs, cgtod(fs, cg))),
1249 cgp = (struct cg *)buf_dataptr(bp);
1278 printf("cg = %d, irotor = %d, fs = %s\n",
1279 cg, cgp->cg_irotor, fs->fs_fsmnt);
1300 fs->fs_cs(fs, cg).cs_nifree--;
1305 fs->fs_cs(fs, cg).cs_ndir++;
1312 return (cg * fs->fs_ipg + ipref);
1329 register struct cg *cgp;
1333 int i, error, cg, blk, frags, bbase;
1346 cg = dtog(fs, bno);
1352 error = (int)buf_bread(ip->i_devvp, (daddr64_t)((unsigned)fsbtodb(fs, cgtod(fs, cg))),
1358 cgp = (struct cg *)buf_dataptr(bp);
1385 fs->fs_cs(fs, cg).cs_nbfree++;
1410 fs->fs_cs(fs, cg).cs_nffree += i;
1423 fs->fs_cs(fs, cg).cs_nffree -= fs->fs_frag;
1427 fs->fs_cs(fs, cg).cs_nbfree++;
1452 struct cg *cgp;
1475 cgp = (struct cg *)buf_dataptr(bp);
1517 register struct cg *cgp;
1521 int error, cg;
1532 cg = ino_to_cg(fs, ino);
1533 error = (int)buf_bread(pip->i_devvp, (daddr64_t)((unsigned)fsbtodb(fs, cgtod(fs, cg))),
1539 cgp = (struct cg *)buf_dataptr(bp);
1566 fs->fs_cs(fs, cg).cs_nifree++;
1570 fs->fs_cs(fs, cg).cs_ndir--;
1590 register struct cg *cgp;
1652 ffs_clusteracct(struct fs *fs, struct cg *cgp, ufs_daddr_t blkno, int cnt)