35 static s64 extRoundDown(
s64 nb);
37 #define DPD(a) (printk("(a): %d\n",(a)))
38 #define DPC(a) (printk("(a): %c\n",(a)))
42 printk("(a): %x%08x ",(a)); \
44 printk("(a): %x ",(a) << 32); \
49 printk("(a): %x%08x\n",(a)); \
51 printk("(a): %x\n",(a) << 32); \
54 #define DPD1(a) (printk("(a): %d ",(a)))
55 #define DPX(a) (printk("(a): %08x\n",(a)))
56 #define DPX1(a) (printk("(a): %08x ",(a)))
57 #define DPS(a) (printk("%s\n",(a)))
58 #define DPE(a) (printk("\nENTERING: %s\n",(a)))
59 #define DPE1(a) (printk("\nENTERING: %s",(a)))
60 #define DPS1(a) (printk(" %s ",(a)))
89 s64 nxlen, nxaddr,
xoff, hint, xaddr = 0;
121 xaddr = hint + nxlen;
138 if ((rc = extBalloc(ip, hint ? hint :
INOHINT(ip), &nxlen, &nxaddr))) {
144 rc = dquot_alloc_block(ip, nxlen);
158 if (xaddr && xaddr == nxaddr)
159 rc =
xtExtend(0, ip, xoff, (
int) nxlen, 0);
161 rc =
xtInsert(0, ip, xflag, xoff, (
int) nxlen, &nxaddr, 0);
167 dbFree(ip, nxaddr, nxlen);
168 dquot_free_block(ip, nxlen);
179 mark_inode_dirty(ip);
219 s64 ntail, nextend, ninsert;
220 int rc, nbperpage = JFS_SBI(sb)->nbperpage;
256 if ((rc = extBrealloc(ip, xaddr, xlen, &nxlen, &nxaddr)))
260 rc = dquot_alloc_block(ip, nxlen);
267 delta = nxlen - xlen;
282 nextend = ntail - xlen;
283 ninsert = nxlen - nbperpage;
298 if (xaddr == nxaddr) {
300 if ((rc =
xtExtend(0, ip, xoff + xlen, (
int) nextend, 0))) {
301 dbFree(ip, xaddr + xlen, delta);
302 dquot_free_block(ip, nxlen);
311 if ((rc = xtTailgate(0, ip, xoff, (
int) ntail, nxaddr, 0))) {
312 dbFree(ip, nxaddr, nxlen);
313 dquot_free_block(ip, nxlen);
325 xaddr = nxaddr + ntail;
326 if (
xtInsert (0, ip, xflag, xoff + ntail, (
int) ninsert,
341 mark_inode_dirty(ip);
367 int nbperpage = JFS_SBI(sb)->nbperpage;
380 prev = ((offset & ~
POFFSET) >> JFS_SBI(sb)->l2bsize) - nbperpage;
387 rc =
xtLookup(ip, prev, nbperpage, &xflag, &xaddr, &xlen, 0);
389 if ((rc == 0) && xlen) {
390 if (xlen != nbperpage) {
458 int rc, nbperpage = JFS_SBI(ip->
i_sb)->nbperpage;
467 if ((rc =
extAlloc(ip, nbperpage, blkno, xp,
false)))
524 max = (
s64) 1 << bmp->db_maxfreebud;
525 if (*nblocks >= max && *nblocks > nbperpage)
526 nb = nblks = (max > nbperpage) ? max : nbperpage;
528 nb = nblks = *nblocks;
531 while ((rc =
dbAlloc(ip, hint, nb, &daddr)) != 0) {
539 nb =
min(nblks, extRoundDown(nb));
602 extBrealloc(
struct inode *ip,
608 if ((rc = dbExtend(ip, blkno, nblks, *newnblks - nblks)) == 0) {
619 return (extBalloc(ip, blkno, newnblks, newblkno));
636 static s64 extRoundDown(
s64 nb)
641 for (i = 0, m = (
u64) 1 << 63; i < 64; i++, m >>= 1) {
648 k = ((k - 1) & nb) ? k : k >> 1;