• Home
  • Raw
  • Download

Lines Matching refs:bmp

68 #define BMAP_LOCK_INIT(bmp)	mutex_init(&bmp->db_bmaplock)  argument
69 #define BMAP_LOCK(bmp) mutex_lock(&bmp->db_bmaplock) argument
70 #define BMAP_UNLOCK(bmp) mutex_unlock(&bmp->db_bmaplock) argument
75 static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
81 static int dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc,
83 static int dbAllocAny(struct bmap * bmp, s64 nblocks, int l2nb, s64 * results);
84 static int dbAllocNext(struct bmap * bmp, struct dmap * dp, s64 blkno,
86 static int dbAllocNear(struct bmap * bmp, struct dmap * dp, s64 blkno,
89 static int dbAllocDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
91 static int dbAllocDmapLev(struct bmap * bmp, struct dmap * dp, int nblocks,
94 static int dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb,
96 static int dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno,
100 static int dbFindCtl(struct bmap * bmp, int l2nb, int level, s64 * blkno);
102 static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
104 static int dbFreeDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
113 static int dbAllocDmapBU(struct bmap * bmp, struct dmap * dp, s64 blkno,
167 struct bmap *bmp; in dbMount() local
176 bmp = kmalloc(sizeof(struct bmap), GFP_KERNEL); in dbMount()
177 if (bmp == NULL) in dbMount()
185 kfree(bmp); in dbMount()
191 bmp->db_mapsize = le64_to_cpu(dbmp_le->dn_mapsize); in dbMount()
192 bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree); in dbMount()
193 bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage); in dbMount()
194 bmp->db_numag = le32_to_cpu(dbmp_le->dn_numag); in dbMount()
195 bmp->db_maxlevel = le32_to_cpu(dbmp_le->dn_maxlevel); in dbMount()
196 bmp->db_maxag = le32_to_cpu(dbmp_le->dn_maxag); in dbMount()
197 bmp->db_agpref = le32_to_cpu(dbmp_le->dn_agpref); in dbMount()
198 bmp->db_aglevel = le32_to_cpu(dbmp_le->dn_aglevel); in dbMount()
199 bmp->db_agheight = le32_to_cpu(dbmp_le->dn_agheight); in dbMount()
200 bmp->db_agwidth = le32_to_cpu(dbmp_le->dn_agwidth); in dbMount()
201 bmp->db_agstart = le32_to_cpu(dbmp_le->dn_agstart); in dbMount()
202 bmp->db_agl2size = le32_to_cpu(dbmp_le->dn_agl2size); in dbMount()
204 bmp->db_agfree[i] = le64_to_cpu(dbmp_le->dn_agfree[i]); in dbMount()
205 bmp->db_agsize = le64_to_cpu(dbmp_le->dn_agsize); in dbMount()
206 bmp->db_maxfreebud = dbmp_le->dn_maxfreebud; in dbMount()
212 bmp->db_ipbmap = ipbmap; in dbMount()
213 JFS_SBI(ipbmap->i_sb)->bmap = bmp; in dbMount()
215 memset(bmp->db_active, 0, sizeof(bmp->db_active)); in dbMount()
220 BMAP_LOCK_INIT(bmp); in dbMount()
244 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap; in dbUnmount() local
255 kfree(bmp); in dbUnmount()
266 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap; in dbSync() local
283 dbmp_le->dn_mapsize = cpu_to_le64(bmp->db_mapsize); in dbSync()
284 dbmp_le->dn_nfree = cpu_to_le64(bmp->db_nfree); in dbSync()
285 dbmp_le->dn_l2nbperpage = cpu_to_le32(bmp->db_l2nbperpage); in dbSync()
286 dbmp_le->dn_numag = cpu_to_le32(bmp->db_numag); in dbSync()
287 dbmp_le->dn_maxlevel = cpu_to_le32(bmp->db_maxlevel); in dbSync()
288 dbmp_le->dn_maxag = cpu_to_le32(bmp->db_maxag); in dbSync()
289 dbmp_le->dn_agpref = cpu_to_le32(bmp->db_agpref); in dbSync()
290 dbmp_le->dn_aglevel = cpu_to_le32(bmp->db_aglevel); in dbSync()
291 dbmp_le->dn_agheight = cpu_to_le32(bmp->db_agheight); in dbSync()
292 dbmp_le->dn_agwidth = cpu_to_le32(bmp->db_agwidth); in dbSync()
293 dbmp_le->dn_agstart = cpu_to_le32(bmp->db_agstart); in dbSync()
294 dbmp_le->dn_agl2size = cpu_to_le32(bmp->db_agl2size); in dbSync()
296 dbmp_le->dn_agfree[i] = cpu_to_le64(bmp->db_agfree[i]); in dbSync()
297 dbmp_le->dn_agsize = cpu_to_le64(bmp->db_agsize); in dbSync()
298 dbmp_le->dn_maxfreebud = bmp->db_maxfreebud; in dbSync()
339 struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap; in dbFree() local
344 if (unlikely((blkno == 0) || (blkno + nblocks > bmp->db_mapsize))) { in dbFree()
365 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage); in dbFree()
379 if ((rc = dbFreeDmap(bmp, dp, blkno, nb))) { in dbFree()
423 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap; in dbUpdatePMap() local
433 if (blkno + nblocks > bmp->db_mapsize) { in dbUpdatePMap()
454 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage); in dbUpdatePMap()
460 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, in dbUpdatePMap()
605 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap; in dbNextAG() local
607 BMAP_LOCK(bmp); in dbNextAG()
610 avgfree = (u32)bmp->db_nfree / bmp->db_numag; in dbNextAG()
616 agpref = bmp->db_agpref; in dbNextAG()
617 if ((atomic_read(&bmp->db_active[agpref]) == 0) && in dbNextAG()
618 (bmp->db_agfree[agpref] >= avgfree)) in dbNextAG()
624 for (i = 0 ; i < bmp->db_numag; i++, agpref++) { in dbNextAG()
625 if (agpref == bmp->db_numag) in dbNextAG()
628 if (atomic_read(&bmp->db_active[agpref])) in dbNextAG()
631 if (bmp->db_agfree[agpref] >= avgfree) { in dbNextAG()
633 bmp->db_agpref = agpref; in dbNextAG()
635 } else if (bmp->db_agfree[agpref] > hwm) { in dbNextAG()
637 hwm = bmp->db_agfree[agpref]; in dbNextAG()
647 bmp->db_agpref = next_best; in dbNextAG()
650 BMAP_UNLOCK(bmp); in dbNextAG()
654 return (bmp->db_agpref); in dbNextAG()
699 struct bmap *bmp; in dbAlloc() local
716 bmp = JFS_SBI(ip->i_sb)->bmap; in dbAlloc()
718 mapSize = bmp->db_mapsize; in dbAlloc()
729 if (l2nb > bmp->db_agl2size) { in dbAlloc()
732 rc = dbAllocAny(bmp, nblocks, l2nb, results); in dbAlloc()
749 if (blkno >= bmp->db_mapsize) in dbAlloc()
752 agno = blkno >> bmp->db_agl2size; in dbAlloc()
758 if ((blkno & (bmp->db_agsize - 1)) == 0) in dbAlloc()
763 if (atomic_read(&bmp->db_active[agno])) in dbAlloc()
776 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage); in dbAlloc()
786 if ((rc = dbAllocNext(bmp, dp, blkno, (int) nblocks)) in dbAlloc()
797 writers = atomic_read(&bmp->db_active[agno]); in dbAlloc()
813 dbAllocNear(bmp, dp, blkno, (int) nblocks, l2nb, results)) in dbAlloc()
825 if ((rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results)) in dbAlloc()
842 if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) != -ENOSPC) in dbAlloc()
858 if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) == -ENOSPC) in dbAlloc()
859 rc = dbAllocAny(bmp, nblocks, l2nb, results); in dbAlloc()
892 struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap; in dbAllocExact() local
906 if (nblocks <= 0 || nblocks > BPERDMAP || blkno >= bmp->db_mapsize) { in dbAllocExact()
911 if (nblocks > ((s64) 1 << bmp->db_maxfreebud)) { in dbAllocExact()
918 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage); in dbAllocExact()
927 rc = dbAllocNext(bmp, dp, blkno, nblocks); in dbAllocExact()
1030 struct bmap *bmp; in dbExtend() local
1050 bmp = sbi->bmap; in dbExtend()
1051 if (lastblkno < 0 || lastblkno >= bmp->db_mapsize) { in dbExtend()
1066 if (addnblocks > BPERDMAP || extblkno >= bmp->db_mapsize || in dbExtend()
1067 (extblkno & (bmp->db_agsize - 1)) == 0) { in dbExtend()
1075 lblkno = BLKTODMAP(extblkno, bmp->db_l2nbperpage); in dbExtend()
1087 rc = dbAllocNext(bmp, dp, extblkno, (int) addnblocks); in dbExtend()
1122 static int dbAllocNext(struct bmap * bmp, struct dmap * dp, s64 blkno, in dbAllocNext() argument
1131 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocNext()
1223 return (dbAllocDmap(bmp, dp, blkno, nblocks)); in dbAllocNext()
1255 dbAllocNear(struct bmap * bmp, in dbAllocNear() argument
1262 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocNear()
1300 if ((rc = dbAllocDmap(bmp, dp, blkno, nblocks)) == 0) in dbAllocNear()
1365 dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb, s64 * results) in dbAllocAG() argument
1376 if (l2nb > bmp->db_agl2size) { in dbAllocAG()
1377 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocAG()
1386 blkno = (s64) agno << bmp->db_agl2size; in dbAllocAG()
1405 if (bmp->db_agsize == BPERDMAP in dbAllocAG()
1406 || bmp->db_agfree[agno] == bmp->db_agsize) { in dbAllocAG()
1407 rc = dbAllocCtl(bmp, nblocks, l2nb, blkno, results); in dbAllocAG()
1409 (bmp->db_agfree[agno] == bmp->db_agsize)) { in dbAllocAG()
1413 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocAG()
1422 lblkno = BLKTOCTL(blkno, bmp->db_l2nbperpage, bmp->db_aglevel); in dbAllocAG()
1423 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0); in dbAllocAG()
1430 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocAG()
1444 (1 << (L2LPERCTL - (bmp->db_agheight << 1))) / bmp->db_agwidth; in dbAllocAG()
1445 ti = bmp->db_agstart + bmp->db_agwidth * (agno & (agperlev - 1)); in dbAllocAG()
1453 for (i = 0; i < bmp->db_agwidth; i++, ti++) { in dbAllocAG()
1463 for (k = bmp->db_agheight; k > 0; k--) { in dbAllocAG()
1471 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocAG()
1481 if (bmp->db_aglevel == 2) in dbAllocAG()
1483 else if (bmp->db_aglevel == 1) in dbAllocAG()
1508 dbFindCtl(bmp, l2nb, bmp->db_aglevel - 1, in dbAllocAG()
1511 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocAG()
1522 rc = dbAllocCtl(bmp, nblocks, l2nb, blkno, results); in dbAllocAG()
1524 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocAG()
1566 static int dbAllocAny(struct bmap * bmp, s64 nblocks, int l2nb, s64 * results) in dbAllocAny() argument
1577 if ((rc = dbFindCtl(bmp, l2nb, bmp->db_maxlevel, &blkno))) in dbAllocAny()
1582 rc = dbAllocCtl(bmp, nblocks, l2nb, blkno, results); in dbAllocAny()
1584 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocAny()
1620 static int dbFindCtl(struct bmap * bmp, int l2nb, int level, s64 * blkno) in dbFindCtl() argument
1637 lblkno = BLKTOCTL(b, bmp->db_l2nbperpage, lev); in dbFindCtl()
1638 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0); in dbFindCtl()
1645 jfs_error(bmp->db_ipbmap->i_sb, in dbFindCtl()
1666 jfs_error(bmp->db_ipbmap->i_sb, in dbFindCtl()
1739 dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results) in dbAllocCtl() argument
1751 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage); in dbAllocCtl()
1752 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0); in dbAllocCtl()
1759 rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results); in dbAllocCtl()
1778 lblkno = BLKTODMAP(b, bmp->db_l2nbperpage); in dbAllocCtl()
1779 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0); in dbAllocCtl()
1790 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocCtl()
1802 if ((rc = dbAllocDmap(bmp, dp, b, nb))) { in dbAllocCtl()
1831 lblkno = BLKTODMAP(b, bmp->db_l2nbperpage); in dbAllocCtl()
1832 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0); in dbAllocCtl()
1837 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocCtl()
1845 if (dbFreeDmap(bmp, dp, b, BPERDMAP)) { in dbAllocCtl()
1850 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocCtl()
1891 dbAllocDmapLev(struct bmap * bmp, in dbAllocDmapLev() argument
1920 if ((rc = dbAllocDmap(bmp, dp, blkno, nblocks)) == 0) in dbAllocDmapLev()
1954 static int dbAllocDmap(struct bmap * bmp, struct dmap * dp, s64 blkno, in dbAllocDmap() argument
1966 dbAllocBits(bmp, dp, blkno, nblocks); in dbAllocDmap()
1976 if ((rc = dbAdjCtl(bmp, blkno, dp->tree.stree[ROOT], 1, 0))) in dbAllocDmap()
1977 dbFreeBits(bmp, dp, blkno, nblocks); in dbAllocDmap()
2009 static int dbFreeDmap(struct bmap * bmp, struct dmap * dp, s64 blkno, in dbFreeDmap() argument
2021 rc = dbFreeBits(bmp, dp, blkno, nblocks); in dbFreeDmap()
2031 if ((rc = dbAdjCtl(bmp, blkno, dp->tree.stree[ROOT], 0, 0))) { in dbFreeDmap()
2042 dbAllocBits(bmp, dp, blkno, nblocks); in dbFreeDmap()
2071 static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno, in dbAllocBits() argument
2147 jfs_error(bmp->db_ipbmap->i_sb, in dbAllocBits()
2178 BMAP_LOCK(bmp); in dbAllocBits()
2184 agno = blkno >> bmp->db_agl2size; in dbAllocBits()
2185 if (agno > bmp->db_maxag) in dbAllocBits()
2186 bmp->db_maxag = agno; in dbAllocBits()
2189 bmp->db_agfree[agno] -= nblocks; in dbAllocBits()
2190 bmp->db_nfree -= nblocks; in dbAllocBits()
2192 BMAP_UNLOCK(bmp); in dbAllocBits()
2218 static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno, in dbFreeBits() argument
2322 BMAP_LOCK(bmp); in dbFreeBits()
2327 agno = blkno >> bmp->db_agl2size; in dbFreeBits()
2328 bmp->db_nfree += nblocks; in dbFreeBits()
2329 bmp->db_agfree[agno] += nblocks; in dbFreeBits()
2336 if ((bmp->db_agfree[agno] == bmp->db_agsize && agno == bmp->db_maxag) || in dbFreeBits()
2337 (agno == bmp->db_numag - 1 && in dbFreeBits()
2338 bmp->db_agfree[agno] == (bmp-> db_mapsize & (BPERDMAP - 1)))) { in dbFreeBits()
2339 while (bmp->db_maxag > 0) { in dbFreeBits()
2340 bmp->db_maxag -= 1; in dbFreeBits()
2341 if (bmp->db_agfree[bmp->db_maxag] != in dbFreeBits()
2342 bmp->db_agsize) in dbFreeBits()
2350 if (bmp->db_agpref > bmp->db_maxag) in dbFreeBits()
2351 bmp->db_agpref = bmp->db_maxag; in dbFreeBits()
2354 BMAP_UNLOCK(bmp); in dbFreeBits()
2402 dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level) in dbAdjCtl() argument
2414 lblkno = BLKTOCTL(blkno, bmp->db_l2nbperpage, level); in dbAdjCtl()
2415 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0); in dbAdjCtl()
2421 jfs_error(bmp->db_ipbmap->i_sb, in dbAdjCtl()
2482 if (level < bmp->db_maxlevel) { in dbAdjCtl()
2487 dbAdjCtl(bmp, blkno, dcp->stree[ROOT], alloc, in dbAdjCtl()
2520 assert(level == bmp->db_maxlevel); in dbAdjCtl()
2521 if (bmp->db_maxfreebud != oldroot) { in dbAdjCtl()
2522 jfs_error(bmp->db_ipbmap->i_sb, in dbAdjCtl()
2526 bmp->db_maxfreebud = dcp->stree[ROOT]; in dbAdjCtl()
3111 struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap; in dbAllocBottomUp() local
3116 ASSERT(nblocks <= bmp->db_mapsize - blkno); in dbAllocBottomUp()
3129 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage); in dbAllocBottomUp()
3143 if ((rc = dbAllocDmapBU(bmp, dp, blkno, nb))) { in dbAllocBottomUp()
3159 static int dbAllocDmapBU(struct bmap * bmp, struct dmap * dp, s64 blkno, in dbAllocDmapBU() argument
3232 BMAP_LOCK(bmp); in dbAllocDmapBU()
3238 agno = blkno >> bmp->db_agl2size; in dbAllocDmapBU()
3239 if (agno > bmp->db_maxag) in dbAllocDmapBU()
3240 bmp->db_maxag = agno; in dbAllocDmapBU()
3243 bmp->db_agfree[agno] -= nblocks; in dbAllocDmapBU()
3244 bmp->db_nfree -= nblocks; in dbAllocDmapBU()
3246 BMAP_UNLOCK(bmp); in dbAllocDmapBU()
3256 if ((rc = dbAdjCtl(bmp, blkno, tp->stree[ROOT], 1, 0))) in dbAllocDmapBU()
3257 dbFreeBits(bmp, dp, blkno, nblocks); in dbAllocDmapBU()
3291 struct bmap *bmp = sbi->bmap; in dbExtendFS() local
3308 bmp->db_mapsize = newsize; in dbExtendFS()
3309 bmp->db_maxlevel = BMAPSZTOLEV(bmp->db_mapsize); in dbExtendFS()
3313 oldl2agsize = bmp->db_agl2size; in dbExtendFS()
3315 bmp->db_agl2size = l2agsize; in dbExtendFS()
3316 bmp->db_agsize = 1 << l2agsize; in dbExtendFS()
3319 agno = bmp->db_numag; in dbExtendFS()
3320 bmp->db_numag = newsize >> l2agsize; in dbExtendFS()
3321 bmp->db_numag += ((u32) newsize % (u32) bmp->db_agsize) ? 1 : 0; in dbExtendFS()
3334 ag_rem = bmp->db_agfree[0]; /* save agfree[0] */ in dbExtendFS()
3336 bmp->db_agfree[n] = 0; /* init collection point */ in dbExtendFS()
3341 bmp->db_agfree[n] += bmp->db_agfree[i]; in dbExtendFS()
3344 bmp->db_agfree[0] += ag_rem; /* restore agfree[0] */ in dbExtendFS()
3347 bmp->db_agfree[n] = 0; in dbExtendFS()
3353 bmp->db_maxag = bmp->db_maxag / k; in dbExtendFS()
3469 bmp->db_nfree += n; in dbExtendFS()
3471 bmp->db_agfree[agno] += n; in dbExtendFS()
3500 bmp->db_maxfreebud = *l1leaf; in dbExtendFS()
3524 bmp->db_maxfreebud = *l2leaf; in dbExtendFS()
3555 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap; in dbFinalizeBmap() local
3570 actags = bmp->db_maxag + 1; in dbFinalizeBmap()
3571 inactags = bmp->db_numag - actags; in dbFinalizeBmap()
3572 ag_rem = bmp->db_mapsize & (bmp->db_agsize - 1); /* ??? */ in dbFinalizeBmap()
3580 ((inactags - 1) << bmp->db_agl2size) + ag_rem in dbFinalizeBmap()
3581 : inactags << bmp->db_agl2size; in dbFinalizeBmap()
3587 actfree = bmp->db_nfree - inactfree; in dbFinalizeBmap()
3594 if (bmp->db_agfree[bmp->db_agpref] < avgfree) { in dbFinalizeBmap()
3595 for (bmp->db_agpref = 0; bmp->db_agpref < actags; in dbFinalizeBmap()
3596 bmp->db_agpref++) { in dbFinalizeBmap()
3597 if (bmp->db_agfree[bmp->db_agpref] >= avgfree) in dbFinalizeBmap()
3600 if (bmp->db_agpref >= bmp->db_numag) { in dbFinalizeBmap()
3613 bmp->db_aglevel = BMAPSZTOLEV(bmp->db_agsize); in dbFinalizeBmap()
3615 bmp->db_agl2size - (L2BPERDMAP + bmp->db_aglevel * L2LPERCTL); in dbFinalizeBmap()
3616 bmp->db_agheight = l2nl >> 1; in dbFinalizeBmap()
3617 bmp->db_agwidth = 1 << (l2nl - (bmp->db_agheight << 1)); in dbFinalizeBmap()
3618 for (i = 5 - bmp->db_agheight, bmp->db_agstart = 0, n = 1; i > 0; in dbFinalizeBmap()
3620 bmp->db_agstart += n; in dbFinalizeBmap()