• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/src/linux/linux-2.6/fs/jfs/

Lines Matching defs:bmp

67 #define BMAP_LOCK_INIT(bmp)	mutex_init(&bmp->db_bmaplock)
68 #define BMAP_LOCK(bmp) mutex_lock(&bmp->db_bmaplock)
69 #define BMAP_UNLOCK(bmp) mutex_unlock(&bmp->db_bmaplock)
74 static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
80 static int dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc,
82 static int dbAllocAny(struct bmap * bmp, s64 nblocks, int l2nb, s64 * results);
83 static int dbAllocNext(struct bmap * bmp, struct dmap * dp, s64 blkno,
85 static int dbAllocNear(struct bmap * bmp, struct dmap * dp, s64 blkno,
88 static int dbAllocDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
90 static int dbAllocDmapLev(struct bmap * bmp, struct dmap * dp, int nblocks,
93 static int dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb,
95 static int dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno,
99 static int dbFindCtl(struct bmap * bmp, int l2nb, int level, s64 * blkno);
101 static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
103 static int dbFreeDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
112 static int dbAllocDmapBU(struct bmap * bmp, struct dmap * dp, s64 blkno,
166 struct bmap *bmp;
175 bmp = kmalloc(sizeof(struct bmap), GFP_KERNEL);
176 if (bmp == NULL)
184 kfree(bmp);
190 bmp->db_mapsize = le64_to_cpu(dbmp_le->dn_mapsize);
191 bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
192 bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
193 bmp->db_numag = le32_to_cpu(dbmp_le->dn_numag);
194 bmp->db_maxlevel = le32_to_cpu(dbmp_le->dn_maxlevel);
195 bmp->db_maxag = le32_to_cpu(dbmp_le->dn_maxag);
196 bmp->db_agpref = le32_to_cpu(dbmp_le->dn_agpref);
197 bmp->db_aglevel = le32_to_cpu(dbmp_le->dn_aglevel);
198 bmp->db_agheigth = le32_to_cpu(dbmp_le->dn_agheigth);
199 bmp->db_agwidth = le32_to_cpu(dbmp_le->dn_agwidth);
200 bmp->db_agstart = le32_to_cpu(dbmp_le->dn_agstart);
201 bmp->db_agl2size = le32_to_cpu(dbmp_le->dn_agl2size);
203 bmp->db_agfree[i] = le64_to_cpu(dbmp_le->dn_agfree[i]);
204 bmp->db_agsize = le64_to_cpu(dbmp_le->dn_agsize);
205 bmp->db_maxfreebud = dbmp_le->dn_maxfreebud;
211 bmp->db_ipbmap = ipbmap;
212 JFS_SBI(ipbmap->i_sb)->bmap = bmp;
214 memset(bmp->db_active, 0, sizeof(bmp->db_active));
219 BMAP_LOCK_INIT(bmp);
243 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap;
254 kfree(bmp);
265 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap;
282 dbmp_le->dn_mapsize = cpu_to_le64(bmp->db_mapsize);
283 dbmp_le->dn_nfree = cpu_to_le64(bmp->db_nfree);
284 dbmp_le->dn_l2nbperpage = cpu_to_le32(bmp->db_l2nbperpage);
285 dbmp_le->dn_numag = cpu_to_le32(bmp->db_numag);
286 dbmp_le->dn_maxlevel = cpu_to_le32(bmp->db_maxlevel);
287 dbmp_le->dn_maxag = cpu_to_le32(bmp->db_maxag);
288 dbmp_le->dn_agpref = cpu_to_le32(bmp->db_agpref);
289 dbmp_le->dn_aglevel = cpu_to_le32(bmp->db_aglevel);
290 dbmp_le->dn_agheigth = cpu_to_le32(bmp->db_agheigth);
291 dbmp_le->dn_agwidth = cpu_to_le32(bmp->db_agwidth);
292 dbmp_le->dn_agstart = cpu_to_le32(bmp->db_agstart);
293 dbmp_le->dn_agl2size = cpu_to_le32(bmp->db_agl2size);
295 dbmp_le->dn_agfree[i] = cpu_to_le64(bmp->db_agfree[i]);
296 dbmp_le->dn_agsize = cpu_to_le64(bmp->db_agsize);
297 dbmp_le->dn_maxfreebud = bmp->db_maxfreebud;
338 struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;
343 if (unlikely((blkno == 0) || (blkno + nblocks > bmp->db_mapsize))) {
364 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
378 if ((rc = dbFreeDmap(bmp, dp, blkno, nb))) {
422 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap;
432 if (blkno + nblocks > bmp->db_mapsize) {
453 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
459 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE,
604 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap;
606 BMAP_LOCK(bmp);
609 avgfree = (u32)bmp->db_nfree / bmp->db_numag;
615 agpref = bmp->db_agpref;
616 if ((atomic_read(&bmp->db_active[agpref]) == 0) &&
617 (bmp->db_agfree[agpref] >= avgfree))
623 for (i = 0 ; i < bmp->db_numag; i++, agpref++) {
624 if (agpref == bmp->db_numag)
627 if (atomic_read(&bmp->db_active[agpref]))
630 if (bmp->db_agfree[agpref] >= avgfree) {
632 bmp->db_agpref = agpref;
634 } else if (bmp->db_agfree[agpref] > hwm) {
636 hwm = bmp->db_agfree[agpref];
646 bmp->db_agpref = next_best;
649 BMAP_UNLOCK(bmp);
653 return (bmp->db_agpref);
698 struct bmap *bmp;
721 bmp = JFS_SBI(ip->i_sb)->bmap;
724 mapSize = bmp->db_mapsize;
735 if (l2nb > bmp->db_agl2size) {
738 rc = dbAllocAny(bmp, nblocks, l2nb, results);
755 if (blkno >= bmp->db_mapsize)
758 agno = blkno >> bmp->db_agl2size;
764 if ((blkno & (bmp->db_agsize - 1)) == 0)
769 if (atomic_read(&bmp->db_active[agno]))
782 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
792 if ((rc = dbAllocNext(bmp, dp, blkno, (int) nblocks))
803 writers = atomic_read(&bmp->db_active[agno]);
819 dbAllocNear(bmp, dp, blkno, (int) nblocks, l2nb, results))
831 if ((rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results))
848 if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) != -ENOSPC)
864 if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) == -ENOSPC)
865 rc = dbAllocAny(bmp, nblocks, l2nb, results);
898 struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;
912 if (nblocks <= 0 || nblocks > BPERDMAP || blkno >= bmp->db_mapsize) {
917 if (nblocks > ((s64) 1 << bmp->db_maxfreebud)) {
924 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
933 rc = dbAllocNext(bmp, dp, blkno, nblocks);
1036 struct bmap *bmp;
1056 bmp = sbi->bmap;
1057 if (lastblkno < 0 || lastblkno >= bmp->db_mapsize) {
1072 if (addnblocks > BPERDMAP || extblkno >= bmp->db_mapsize ||
1073 (extblkno & (bmp->db_agsize - 1)) == 0) {
1081 lblkno = BLKTODMAP(extblkno, bmp->db_l2nbperpage);
1093 rc = dbAllocNext(bmp, dp, extblkno, (int) addnblocks);
1116 * bmp - pointer to bmap descriptor
1128 static int dbAllocNext(struct bmap * bmp, struct dmap * dp, s64 blkno,
1137 jfs_error(bmp->db_ipbmap->i_sb,
1229 return (dbAllocDmap(bmp, dp, blkno, nblocks));
1245 * bmp - pointer to bmap descriptor
1261 dbAllocNear(struct bmap * bmp,
1268 jfs_error(bmp->db_ipbmap->i_sb,
1306 if ((rc = dbAllocDmap(bmp, dp, blkno, nblocks)) == 0)
1356 * bmp - pointer to bmap descriptor
1371 dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb, s64 * results)
1382 if (l2nb > bmp->db_agl2size) {
1383 jfs_error(bmp->db_ipbmap->i_sb,
1392 blkno = (s64) agno << bmp->db_agl2size;
1411 if (bmp->db_agsize == BPERDMAP
1412 || bmp->db_agfree[agno] == bmp->db_agsize) {
1413 rc = dbAllocCtl(bmp, nblocks, l2nb, blkno, results);
1415 (bmp->db_agfree[agno] == bmp->db_agsize)) {
1419 jfs_error(bmp->db_ipbmap->i_sb,
1428 lblkno = BLKTOCTL(blkno, bmp->db_l2nbperpage, bmp->db_aglevel);
1429 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0);
1436 jfs_error(bmp->db_ipbmap->i_sb,
1450 (1 << (L2LPERCTL - (bmp->db_agheigth << 1))) / bmp->db_agwidth;
1451 ti = bmp->db_agstart + bmp->db_agwidth * (agno & (agperlev - 1));
1459 for (i = 0; i < bmp->db_agwidth; i++, ti++) {
1469 for (k = bmp->db_agheigth; k > 0; k--) {
1477 jfs_error(bmp->db_ipbmap->i_sb,
1487 if (bmp->db_aglevel == 2)
1489 else if (bmp->db_aglevel == 1)
1491 else /* bmp->db_aglevel == 0 */
1514 dbFindCtl(bmp, l2nb, bmp->db_aglevel - 1,
1517 jfs_error(bmp->db_ipbmap->i_sb,
1528 rc = dbAllocCtl(bmp, nblocks, l2nb, blkno, results);
1530 jfs_error(bmp->db_ipbmap->i_sb,
1559 * bmp - pointer to bmap descriptor
1572 static int dbAllocAny(struct bmap * bmp, s64 nblocks, int l2nb, s64 * results)
1583 if ((rc = dbFindCtl(bmp, l2nb, bmp->db_maxlevel, &blkno)))
1588 rc = dbAllocCtl(bmp, nblocks, l2nb, blkno, results);
1590 jfs_error(bmp->db_ipbmap->i_sb,
1612 * bmp - pointer to bmap descriptor
1626 static int dbFindCtl(struct bmap * bmp, int l2nb, int level, s64 * blkno)
1643 lblkno = BLKTOCTL(b, bmp->db_l2nbperpage, lev);
1644 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0);
1651 jfs_error(bmp->db_ipbmap->i_sb,
1672 jfs_error(bmp->db_ipbmap->i_sb,
1729 * bmp - pointer to bmap descriptor
1745 dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)
1757 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
1758 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0);
1765 rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results);
1784 lblkno = BLKTODMAP(b, bmp->db_l2nbperpage);
1785 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0);
1796 jfs_error(bmp->db_ipbmap->i_sb,
1808 if ((rc = dbAllocDmap(bmp, dp, b, nb))) {
1837 lblkno = BLKTODMAP(b, bmp->db_l2nbperpage);
1838 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0);
1843 jfs_error(bmp->db_ipbmap->i_sb,
1851 if (dbFreeDmap(bmp, dp, b, BPERDMAP)) {
1856 jfs_error(bmp->db_ipbmap->i_sb,
1897 dbAllocDmapLev(struct bmap * bmp,
1926 if ((rc = dbAllocDmap(bmp, dp, blkno, nblocks)) == 0)
1949 * bmp - pointer to bmap descriptor
1960 static int dbAllocDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
1972 dbAllocBits(bmp, dp, blkno, nblocks);
1982 if ((rc = dbAdjCtl(bmp, blkno, dp->tree.stree[ROOT], 1, 0)))
1983 dbFreeBits(bmp, dp, blkno, nblocks);
2004 * bmp - pointer to bmap descriptor
2015 static int dbFreeDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
2027 rc = dbFreeBits(bmp, dp, blkno, nblocks);
2037 if ((rc = dbAdjCtl(bmp, blkno, dp->tree.stree[ROOT], 0, 0))) {
2048 dbAllocBits(bmp, dp, blkno, nblocks);
2068 * bmp - pointer to bmap descriptor
2077 static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
2153 jfs_error(bmp->db_ipbmap->i_sb,
2184 BMAP_LOCK(bmp);
2190 agno = blkno >> bmp->db_agl2size;
2191 if (agno > bmp->db_maxag)
2192 bmp->db_maxag = agno;
2195 bmp->db_agfree[agno] -= nblocks;
2196 bmp->db_nfree -= nblocks;
2198 BMAP_UNLOCK(bmp);
2215 * bmp - pointer to bmap descriptor
2224 static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
2328 BMAP_LOCK(bmp);
2333 agno = blkno >> bmp->db_agl2size;
2334 bmp->db_nfree += nblocks;
2335 bmp->db_agfree[agno] += nblocks;
2342 if ((bmp->db_agfree[agno] == bmp->db_agsize && agno == bmp->db_maxag) ||
2343 (agno == bmp->db_numag - 1 &&
2344 bmp->db_agfree[agno] == (bmp-> db_mapsize & (BPERDMAP - 1)))) {
2345 while (bmp->db_maxag > 0) {
2346 bmp->db_maxag -= 1;
2347 if (bmp->db_agfree[bmp->db_maxag] !=
2348 bmp->db_agsize)
2356 if (bmp->db_agpref > bmp->db_maxag)
2357 bmp->db_agpref = bmp->db_maxag;
2360 BMAP_UNLOCK(bmp);
2391 * bmp - pointer to bmap descriptor
2408 dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level)
2420 lblkno = BLKTOCTL(blkno, bmp->db_l2nbperpage, level);
2421 mp = read_metapage(bmp->db_ipbmap, lblkno, PSIZE, 0);
2427 jfs_error(bmp->db_ipbmap->i_sb,
2488 if (level < bmp->db_maxlevel) {
2493 dbAdjCtl(bmp, blkno, dcp->stree[ROOT], alloc,
2526 assert(level == bmp->db_maxlevel);
2527 if (bmp->db_maxfreebud != oldroot) {
2528 jfs_error(bmp->db_ipbmap->i_sb,
2532 bmp->db_maxfreebud = dcp->stree[ROOT];
3117 struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;
3122 ASSERT(nblocks <= bmp->db_mapsize - blkno);
3135 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
3149 if ((rc = dbAllocDmapBU(bmp, dp, blkno, nb))) {
3165 static int dbAllocDmapBU(struct bmap * bmp, struct dmap * dp, s64 blkno,
3241 BMAP_LOCK(bmp);
3247 agno = blkno >> bmp->db_agl2size;
3248 if (agno > bmp->db_maxag)
3249 bmp->db_maxag = agno;
3252 bmp->db_agfree[agno] -= nblocks;
3253 bmp->db_nfree -= nblocks;
3255 BMAP_UNLOCK(bmp);
3265 if ((rc = dbAdjCtl(bmp, blkno, tp->stree[ROOT], 1, 0)))
3266 dbFreeBits(bmp, dp, blkno, nblocks);
3300 struct bmap *bmp = sbi->bmap;
3317 bmp->db_mapsize = newsize;
3318 bmp->db_maxlevel = BMAPSZTOLEV(bmp->db_mapsize);
3322 oldl2agsize = bmp->db_agl2size;
3324 bmp->db_agl2size = l2agsize;
3325 bmp->db_agsize = 1 << l2agsize;
3328 agno = bmp->db_numag;
3329 bmp->db_numag = newsize >> l2agsize;
3330 bmp->db_numag += ((u32) newsize % (u32) bmp->db_agsize) ? 1 : 0;
3343 ag_rem = bmp->db_agfree[0]; /* save agfree[0] */
3345 bmp->db_agfree[n] = 0; /* init collection point */
3350 bmp->db_agfree[n] += bmp->db_agfree[i];
3353 bmp->db_agfree[0] += ag_rem; /* restore agfree[0] */
3356 bmp->db_agfree[n] = 0;
3362 bmp->db_maxag = bmp->db_maxag / k;
3478 bmp->db_nfree += n;
3480 bmp->db_agfree[agno] += n;
3509 bmp->db_maxfreebud = *l1leaf;
3533 bmp->db_maxfreebud = *l2leaf;
3564 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap;
3579 actags = bmp->db_maxag + 1;
3580 inactags = bmp->db_numag - actags;
3581 ag_rem = bmp->db_mapsize & (bmp->db_agsize - 1); /* ??? */
3589 ((inactags - 1) << bmp->db_agl2size) + ag_rem
3590 : inactags << bmp->db_agl2size;
3596 actfree = bmp->db_nfree - inactfree;
3603 if (bmp->db_agfree[bmp->db_agpref] < avgfree) {
3604 for (bmp->db_agpref = 0; bmp->db_agpref < actags;
3605 bmp->db_agpref++) {
3606 if (bmp->db_agfree[bmp->db_agpref] >= avgfree)
3609 if (bmp->db_agpref >= bmp->db_numag) {
3622 bmp->db_aglevel = BMAPSZTOLEV(bmp->db_agsize);
3624 bmp->db_agl2size - (L2BPERDMAP + bmp->db_aglevel * L2LPERCTL);
3625 bmp->db_agheigth = l2nl >> 1;
3626 bmp->db_agwidth = 1 << (l2nl - (bmp->db_agheigth << 1));
3627 for (i = 5 - bmp->db_agheigth, bmp->db_agstart = 0, n = 1; i > 0;
3629 bmp->db_agstart += n;