Lines Matching defs:blkno

64 static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
70 static int dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc,
73 static int dbAllocNext(struct bmap * bmp, struct dmap * dp, s64 blkno,
75 static int dbAllocNear(struct bmap * bmp, struct dmap * dp, s64 blkno,
78 static int dbAllocDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
85 static int dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno,
87 static int dbExtend(struct inode *ip, s64 blkno, s64 nblocks, s64 addnblocks);
89 static int dbFindCtl(struct bmap * bmp, int l2nb, int level, s64 * blkno);
91 static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
93 static int dbFreeDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
101 static int dbAllocDmapBU(struct bmap * bmp, struct dmap * dp, s64 blkno,
103 static int dbInitDmap(struct dmap * dp, s64 blkno, int nblocks);
348 * blkno - starting block number to be freed.
355 int dbFree(struct inode *ip, s64 blkno, s64 nblocks)
368 if (unlikely((blkno == 0) || (blkno + nblocks > bmp->db_mapsize))) {
370 printk(KERN_ERR "blkno = %Lx, nblocks = %Lx\n",
371 (unsigned long long) blkno,
382 jfs_issue_discard(ipbmap, blkno, nblocks);
388 for (rem = nblocks; rem > 0; rem -= nb, blkno += nb) {
395 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
406 nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1)));
409 if ((rc = dbFreeDmap(bmp, dp, blkno, nb))) {
440 * blkno - starting block number of the range.
450 int free, s64 blkno, s64 nblocks, struct tblock * tblk)
464 if (blkno + nblocks > bmp->db_mapsize) {
465 printk(KERN_ERR "blkno = %Lx, nblocks = %Lx\n",
466 (unsigned long long) blkno,
482 for (rem = nblocks; rem > 0; rem -= nblks, blkno += nblks) {
484 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
502 dbitno = blkno & (BPERDMAP - 1);
731 s64 lblkno, blkno;
777 blkno = hint + 1;
779 if (blkno >= bmp->db_mapsize)
782 agno = blkno >> bmp->db_agl2size;
784 /* check if blkno crosses over into a new allocation group.
788 if ((blkno & (bmp->db_agsize - 1)) == 0)
806 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
816 if ((rc = dbAllocNext(bmp, dp, blkno, (int) nblocks))
819 *results = blkno;
843 dbAllocNear(bmp, dp, blkno, (int) nblocks, l2nb, results))
910 * blkno - extent address;
918 int dbAllocExact(struct inode *ip, s64 blkno, int nblocks)
936 if (nblocks <= 0 || nblocks > BPERDMAP || blkno >= bmp->db_mapsize) {
948 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
957 rc = dbAllocNext(bmp, dp, blkno, nblocks);
987 * blkno - starting block of the current allocation.
1004 s64 blkno, s64 nblocks, s64 addnblocks, s64 * results)
1010 if ((rc = dbExtend(ip, blkno, nblocks, addnblocks)) == 0) {
1011 *results = blkno;
1024 (ip, blkno + nblocks - 1, addnblocks + nblocks, results));
1041 * blkno - starting block of the current allocation.
1051 static int dbExtend(struct inode *ip, s64 blkno, s64 nblocks, s64 addnblocks)
1065 if (((rel_block = blkno & (sbi->nbperpage - 1))) &&
1070 lastblkno = blkno + nblocks - 1;
1140 * blkno - starting block number of the range.
1150 static int dbAllocNext(struct bmap * bmp, struct dmap * dp, s64 blkno,
1170 dbitno = blkno & (BPERDMAP - 1);
1250 return (dbAllocDmap(bmp, dp, blkno, nblocks));
1268 * blkno - block number to allocate near.
1283 struct dmap * dp, s64 blkno, int nblocks, int l2nb, s64 * results)
1296 * (i.e. blkno). also, determine the last word in the dmap
1299 word = (blkno & (BPERDMAP - 1)) >> L2DBWORD;
1313 blkno = le64_to_cpu(dp->start) + (word << L2DBWORD);
1321 blkno +=
1326 if ((rc = dbAllocDmap(bmp, dp, blkno, nblocks)) == 0)
1327 *results = blkno;
1396 s64 blkno, lblkno;
1411 blkno = (s64) agno << bmp->db_agl2size;
1432 rc = dbAllocCtl(bmp, nblocks, l2nb, blkno, results);
1435 printk(KERN_ERR "blkno = %Lx, blocks = %Lx\n",
1436 (unsigned long long) blkno,
1447 lblkno = BLKTOCTL(blkno, bmp->db_l2nbperpage, bmp->db_aglevel);
1506 blkno = 0;
1508 blkno &= ~(MAXL1SIZE - 1);
1510 blkno &= ~(MAXL0SIZE - 1);
1512 blkno +=
1533 &blkno))) {
1545 rc = dbAllocCtl(bmp, nblocks, l2nb, blkno, results);
1592 s64 blkno = 0;
1600 if ((rc = dbFindCtl(bmp, l2nb, bmp->db_maxlevel, &blkno)))
1605 rc = dbAllocCtl(bmp, nblocks, l2nb, blkno, results);
1648 s64 nblocks, blkno;
1654 u64 blkno;
1658 /* max blkno / nblocks pairs to trim */
1681 rc = dbAllocAG(bmp, agno, nblocks, l2nb, &blkno);
1683 tt->blkno = blkno;
1715 jfs_issue_discard(ip, tt->blkno, tt->nblocks);
1716 dbFree(ip, tt->blkno, tt->nblocks);
1741 * *blkno - on entry, starting block number for conducting the search.
1752 static int dbFindCtl(struct bmap * bmp, int l2nb, int level, s64 * blkno)
1765 for (lev = level, b = *blkno; lev >= 0; lev--) {
1820 *blkno = b;
1852 * first dmap (i.e. blkno).
1858 * blkno - starting block number of the dmap to start the allocation
1871 dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)
1883 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
1903 assert((blkno & (BPERDMAP - 1)) == 0);
1907 for (n = nblocks, b = blkno; n > 0; n -= nb, b += nb) {
1946 *results = blkno;
1959 for (n = nblocks - n, b = blkno; n > 0;
2025 s64 blkno;
2044 blkno = le64_to_cpu(dp->start) + (leafidx << L2DBWORD);
2051 blkno += dbFindBits(le32_to_cpu(dp->wmap[leafidx]), l2nb);
2054 if ((rc = dbAllocDmap(bmp, dp, blkno, nblocks)) == 0)
2055 *results = blkno;
2079 * blkno - starting block number of the block to be allocated.
2088 static int dbAllocDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
2100 dbAllocBits(bmp, dp, blkno, nblocks);
2110 if ((rc = dbAdjCtl(bmp, blkno, dp->tree.stree[ROOT], 1, 0)))
2111 dbFreeBits(bmp, dp, blkno, nblocks);
2134 * blkno - starting block number of the block to be freed.
2143 static int dbFreeDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
2155 rc = dbFreeBits(bmp, dp, blkno, nblocks);
2165 if ((rc = dbAdjCtl(bmp, blkno, dp->tree.stree[ROOT], 0, 0))) {
2166 word = (blkno & (BPERDMAP - 1)) >> L2DBWORD;
2176 dbAllocBits(bmp, dp, blkno, nblocks);
2198 * blkno - starting block number of the bits to be allocated.
2205 static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
2219 dbitno = blkno & (BPERDMAP - 1);
2318 agno = blkno >> bmp->db_agl2size;
2345 * blkno - starting block number of the bits to be freed.
2352 static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
2363 dbitno = blkno & (BPERDMAP - 1);
2461 agno = blkno >> bmp->db_agl2size;
2520 * blkno - the first block of a block range within a dmap. it is
2536 dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level)
2548 lblkno = BLKTOCTL(blkno, bmp->db_l2nbperpage, level);
2563 leafno = BLKTOCTLLEAF(blkno, dcp->budmin);
2620 dbAdjCtl(bmp, blkno, dcp->stree[ROOT], alloc,
3240 * blkno - starting block number to be freed.
3247 int dbAllocBottomUp(struct inode *ip, s64 blkno, s64 nblocks)
3259 ASSERT(nblocks <= bmp->db_mapsize - blkno);
3265 for (rem = nblocks; rem > 0; rem -= nb, blkno += nb) {
3272 lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
3283 nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1)));
3286 if ((rc = dbAllocDmapBU(bmp, dp, blkno, nb))) {
3302 static int dbAllocDmapBU(struct bmap * bmp, struct dmap * dp, s64 blkno,
3318 dbitno = blkno & (BPERDMAP - 1);
3381 agno = blkno >> bmp->db_agl2size;
3399 if ((rc = dbAdjCtl(bmp, blkno, tp->stree[ROOT], 1, 0)))
3400 dbFreeBits(bmp, dp, blkno, nblocks);
3409 * FUNCTION: extend bmap from blkno for nblocks;
3423 int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks)
3438 newsize = blkno + nblocks;
3440 jfs_info("dbExtendFS: blkno:%Ld nblocks:%Ld newsize:%Ld",
3441 (long long) blkno, (long long) nblocks, (long long) newsize);
3515 k = blkno >> L2MAXL1SIZE;
3517 p = BLKTOL1(blkno, sbi->l2nbperpage); /* L1 page */
3525 /* read in L1 page: (blkno & (MAXL1SIZE - 1)) */
3532 j = (blkno & (MAXL1SIZE - 1)) >> L2MAXL0SIZE;
3534 p = BLKTOL0(blkno, sbi->l2nbperpage);
3556 /* read in L0 page: (blkno & (MAXL0SIZE - 1)) */
3564 i = (blkno & (MAXL0SIZE - 1)) >>
3567 p = BLKTODMAP(blkno,
3592 if ((n = blkno & (BPERDMAP - 1))) {
3610 *l0leaf = dbInitDmap(dp, blkno, n);
3621 blkno += n;
3788 int blkno, w, b, r, nw, nb, i;
3791 blkno = Blkno & (BPERDMAP - 1);
3793 if (blkno == 0) {
3808 w = blkno >> L2DBWORD;
3815 for (r = nblocks; r > 0; r -= nb, blkno += nb) {
3817 b = blkno & (DBWORD - 1);
3848 if (blkno == BPERDMAP)
3852 w = blkno >> L2DBWORD;
3855 b = blkno & (DBWORD - 1);
3883 * blkno - starting block number for this dmap