Lines Matching +full:ip +full:- +full:blocks
2 * Copyright (C) International Business Machines Corp., 2000-2004
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
70 * ip - the inode of the file.
71 * xlen - requested extent length.
72 * pno - the starting page number with the file.
73 * xp - pointer to an xad. on entry, xad describes an
75 * xaddr of the xad is non-zero. on successful exit,
77 * abnr - bool indicating whether the newly allocated extent
81 * 0 - success
82 * -EIO - i/o error.
83 * -ENOSPC - insufficient disk resources.
86 extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr) in extAlloc() argument
88 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); in extAlloc()
93 /* This blocks if we are low on resources */ in extAlloc()
94 txBeginAnon(ip->i_sb); in extAlloc()
97 mutex_lock(&JFS_IP(ip)->commit_mutex); in extAlloc()
104 xoff = pno << sbi->l2nbperpage; in extAlloc()
116 * extent if we can allocate the blocks immediately in extAlloc()
120 abnr == ((xp->flag & XAD_NOTRECORDED) ? true : false)) in extAlloc()
124 hint += (nxlen - 1); in extAlloc()
127 /* allocate the disk blocks for the extent. initially, extBalloc() in extAlloc()
128 * will try to allocate disk blocks for the requested size (xlen). in extAlloc()
129 * if this fails (xlen contiguous free blocks not available), it'll in extAlloc()
130 * try to allocate a smaller number of blocks (producing a smaller in extAlloc()
131 * extent), with this smaller number of blocks consisting of the in extAlloc()
132 * requested number of blocks rounded down to the next smaller in extAlloc()
133 * power of 2 number (i.e. 16 -> 8). it'll continue to round down in extAlloc()
134 * and retry the allocation until the number of blocks to allocate in extAlloc()
135 * is smaller than the number of blocks per page. in extAlloc()
138 if ((rc = extBalloc(ip, hint ? hint : INOHINT(ip), &nxlen, &nxaddr))) { in extAlloc()
139 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
143 /* Allocate blocks to quota. */ in extAlloc()
144 rc = dquot_alloc_block(ip, nxlen); in extAlloc()
146 dbFree(ip, nxaddr, (s64) nxlen); in extAlloc()
147 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
159 rc = xtExtend(0, ip, xoff, (int) nxlen, 0); in extAlloc()
161 rc = xtInsert(0, ip, xflag, xoff, (int) nxlen, &nxaddr, 0); in extAlloc()
164 * free the newly allocated blocks and return the error. in extAlloc()
167 dbFree(ip, nxaddr, nxlen); in extAlloc()
168 dquot_free_block(ip, nxlen); in extAlloc()
169 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
177 xp->flag = xflag; in extAlloc()
179 mark_inode_dirty(ip); in extAlloc()
181 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
187 if (test_and_clear_cflag(COMMIT_Synclist,ip)) in extAlloc()
188 jfs_commit_inode(ip, 0); in extAlloc()
202 * ip - the inode of the file.
203 * cp - cbuf for the partial backed last page.
204 * xlen - request size of the resulting extent.
205 * xp - pointer to an xad. on successful exit, the xad
207 * abnr - bool indicating whether the newly allocated extent
211 * 0 - success
212 * -EIO - i/o error.
213 * -ENOSPC - insufficient disk resources.
215 int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr) in extRealloc() argument
217 struct super_block *sb = ip->i_sb; in extRealloc()
220 int rc, nbperpage = JFS_SBI(sb)->nbperpage; in extRealloc()
223 /* This blocks if we are low on resources */ in extRealloc()
224 txBeginAnon(ip->i_sb); in extRealloc()
226 mutex_lock(&JFS_IP(ip)->commit_mutex); in extRealloc()
232 * number of blocks. in extRealloc()
242 if ((xp->flag & XAD_NOTRECORDED) && !abnr) { in extRealloc()
243 xp->flag = 0; in extRealloc()
244 if ((rc = xtUpdate(0, ip, xp))) in extRealloc()
248 /* try to allocated the request number of blocks for the in extRealloc()
251 * try to allocate a new set of blocks large enough for the in extRealloc()
256 if ((rc = extBrealloc(ip, xaddr, xlen, &nxlen, &nxaddr))) in extRealloc()
259 /* Allocat blocks to quota. */ in extRealloc()
260 rc = dquot_alloc_block(ip, nxlen); in extRealloc()
262 dbFree(ip, nxaddr, (s64) nxlen); in extRealloc()
263 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extRealloc()
267 delta = nxlen - xlen; in extRealloc()
280 if (abnr && (!(xp->flag & XAD_NOTRECORDED)) && (nxlen > nbperpage)) { in extRealloc()
282 nextend = ntail - xlen; in extRealloc()
283 ninsert = nxlen - nbperpage; in extRealloc()
291 xflag = xp->flag; in extRealloc()
300 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) { in extRealloc()
301 dbFree(ip, xaddr + xlen, delta); in extRealloc()
302 dquot_free_block(ip, nxlen); in extRealloc()
311 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) { in extRealloc()
312 dbFree(ip, nxaddr, nxlen); in extRealloc()
313 dquot_free_block(ip, nxlen); in extRealloc()
321 /* perform the insert. if it fails, free the blocks in extRealloc()
326 if (xtInsert (0, ip, xflag, xoff + ntail, (int) ninsert, in extRealloc()
328 dbFree(ip, xaddr, (s64) ninsert); in extRealloc()
339 xp->flag = xflag; in extRealloc()
341 mark_inode_dirty(ip); in extRealloc()
343 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extRealloc()
355 * ip - the inode of the file.
356 * offset - file offset for which the hint is needed.
357 * xp - pointer to the xad that is to be filled in with
361 * 0 - success
362 * -EIO - i/o error.
364 int extHint(struct inode *ip, s64 offset, xad_t * xp) in extHint() argument
366 struct super_block *sb = ip->i_sb; in extHint()
367 int nbperpage = JFS_SBI(sb)->nbperpage; in extHint()
380 prev = ((offset & ~POFFSET) >> JFS_SBI(sb)->l2bsize) - nbperpage; in extHint()
387 rc = xtLookup(ip, prev, nbperpage, &xflag, &xaddr, &xlen, 0); in extHint()
391 jfs_error(ip->i_sb, "corrupt xtree\n"); in extHint()
392 rc = -EIO; in extHint()
401 xp->flag = xflag & XAD_NOTRECORDED; in extHint()
416 * ip - inode of the file.
417 * cp - cbuf of the file page.
420 * 0 - success
421 * -EIO - i/o error.
422 * -ENOSPC - insufficient disk resources.
424 int extRecord(struct inode *ip, xad_t * xp) in extRecord() argument
428 txBeginAnon(ip->i_sb); in extRecord()
430 mutex_lock(&JFS_IP(ip)->commit_mutex); in extRecord()
433 rc = xtUpdate(0, ip, xp); in extRecord()
435 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extRecord()
448 * ip - the inode of the file.
449 * cp - cbuf of the file page represent the hole.
452 * 0 - success
453 * -EIO - i/o error.
454 * -ENOSPC - insufficient disk resources.
456 int extFill(struct inode *ip, xad_t * xp) in extFill() argument
458 int rc, nbperpage = JFS_SBI(ip->i_sb)->nbperpage; in extFill()
459 s64 blkno = offsetXAD(xp) >> ip->i_blkbits; in extFill()
461 // assert(ISSPARSE(ip)); in extFill()
467 if ((rc = extAlloc(ip, nbperpage, blkno, xp, false))) in extFill()
480 * FUNCTION: allocate disk blocks to form an extent.
482 * initially, we will try to allocate disk blocks for the
484 * contiguous free blocks not available), we'll try to allocate
485 * a smaller number of blocks (producing a smaller extent), with
486 * this smaller number of blocks consisting of the requested
487 * number of blocks rounded down to the next smaller power of 2
488 * number (i.e. 16 -> 8). we'll continue to round down and
489 * retry the allocation until the number of blocks to allocate
490 * is smaller than the number of blocks per page.
493 * ip - the inode of the file.
494 * hint - disk block number to be used as an allocation hint.
495 * *nblocks - pointer to an s64 value. on entry, this value specifies
497 * exit, this value is set to the number of blocks actually
499 * blkno - pointer to a block address that is filled in on successful
504 * 0 - success
505 * -EIO - i/o error.
506 * -ENOSPC - insufficient disk resources.
509 extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno) in extBalloc() argument
511 struct jfs_inode_info *ji = JFS_IP(ip); in extBalloc()
512 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); in extBalloc()
514 int rc, nbperpage = sbi->nbperpage; in extBalloc()
515 struct bmap *bmp = sbi->bmap; in extBalloc()
518 /* get the number of blocks to initially attempt to allocate. in extBalloc()
519 * we'll first try the number of blocks requested unless this in extBalloc()
521 * blocks in the map. in that case, we'll start off with the in extBalloc()
524 max = (s64) 1 << bmp->db_maxfreebud; in extBalloc()
530 /* try to allocate blocks */ in extBalloc()
531 while ((rc = dbAlloc(ip, hint, nb, &daddr)) != 0) { in extBalloc()
535 if (rc != -ENOSPC) in extBalloc()
549 if (S_ISREG(ip->i_mode) && (ji->fileset == FILESYSTEM_I)) { in extBalloc()
551 spin_lock_irq(&ji->ag_lock); in extBalloc()
552 if (ji->active_ag == -1) { in extBalloc()
553 atomic_inc(&bmp->db_active[ag]); in extBalloc()
554 ji->active_ag = ag; in extBalloc()
555 } else if (ji->active_ag != ag) { in extBalloc()
556 atomic_dec(&bmp->db_active[ji->active_ag]); in extBalloc()
557 atomic_inc(&bmp->db_active[ag]); in extBalloc()
558 ji->active_ag = ag; in extBalloc()
560 spin_unlock_irq(&ji->ag_lock); in extBalloc()
575 * to a new set of blocks. If moving the extent, we initially
576 * will try to allocate disk blocks for the requested size
577 * (newnblks). if this fails (new contiguous free blocks not
579 * blocks (producing a smaller extent), with this smaller
580 * number of blocks consisting of the requested number of
581 * blocks rounded down to the next smaller power of 2
582 * number (i.e. 16 -> 8). We'll continue to round down and
583 * retry the allocation until the number of blocks to allocate
584 * is smaller than the number of blocks per page.
587 * ip - the inode of the file.
588 * blkno - starting block number of the extents current allocation.
589 * nblks - number of blocks within the extents current allocation.
590 * newnblks - pointer to a s64 value. on entry, this value is the
591 * the new desired extent size (number of blocks). on
593 * new size (new number of blocks).
594 * newblkno - the starting block number of the extents new allocation.
597 * 0 - success
598 * -EIO - i/o error.
599 * -ENOSPC - insufficient disk resources.
602 extBrealloc(struct inode *ip, in extBrealloc() argument
608 if ((rc = dbExtend(ip, blkno, nblks, *newnblks - nblks)) == 0) { in extBrealloc()
612 if (rc != -ENOSPC) in extBrealloc()
617 * try to move the extent to a new set of blocks. in extBrealloc()
619 return (extBalloc(ip, blkno, newnblks, newblkno)); in extBrealloc()
627 * FUNCTION: round down a specified number of blocks to the next
631 * nb - the inode of the file.
646 i = 63 - i; in extRoundDown()
648 k = ((k - 1) & nb) ? k : k >> 1; in extRoundDown()