Lines Matching +full:ip +full:- +full:block

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) International Business Machines Corp., 2000-2004
57 * ip - the inode of the file.
58 * xlen - requested extent length.
59 * pno - the starting page number with the file.
60 * xp - pointer to an xad. on entry, xad describes an
62 * xaddr of the xad is non-zero. on successful exit,
64 * abnr - bool indicating whether the newly allocated extent
68 * 0 - success
69 * -EIO - i/o error.
70 * -ENOSPC - insufficient disk resources.
73 extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr) in extAlloc() argument
75 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); in extAlloc()
81 txBeginAnon(ip->i_sb); in extAlloc()
84 mutex_lock(&JFS_IP(ip)->commit_mutex); in extAlloc()
91 xoff = pno << sbi->l2nbperpage; in extAlloc()
107 abnr == ((xp->flag & XAD_NOTRECORDED) ? true : false)) in extAlloc()
110 /* adjust the hint to the last block of the extent */ in extAlloc()
111 hint += (nxlen - 1); in extAlloc()
120 * power of 2 number (i.e. 16 -> 8). it'll continue to round down in extAlloc()
125 if ((rc = extBalloc(ip, hint ? hint : INOHINT(ip), &nxlen, &nxaddr))) { in extAlloc()
126 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
131 rc = dquot_alloc_block(ip, nxlen); in extAlloc()
133 dbFree(ip, nxaddr, (s64) nxlen); in extAlloc()
134 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
146 rc = xtExtend(0, ip, xoff, (int) nxlen, 0); in extAlloc()
148 rc = xtInsert(0, ip, xflag, xoff, (int) nxlen, &nxaddr, 0); in extAlloc()
154 dbFree(ip, nxaddr, nxlen); in extAlloc()
155 dquot_free_block(ip, nxlen); in extAlloc()
156 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
164 xp->flag = xflag; in extAlloc()
166 mark_inode_dirty(ip); in extAlloc()
168 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
174 if (test_and_clear_cflag(COMMIT_Synclist,ip)) in extAlloc()
175 jfs_commit_inode(ip, 0); in extAlloc()
189 * ip - the inode of the file.
190 * cp - cbuf for the partial backed last page.
191 * xlen - request size of the resulting extent.
192 * xp - pointer to an xad. on successful exit, the xad
194 * abnr - bool indicating whether the newly allocated extent
198 * 0 - success
199 * -EIO - i/o error.
200 * -ENOSPC - insufficient disk resources.
202 int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr) in extRealloc() argument
204 struct super_block *sb = ip->i_sb; in extRealloc()
207 int rc, nbperpage = JFS_SBI(sb)->nbperpage; in extRealloc()
211 txBeginAnon(ip->i_sb); in extRealloc()
213 mutex_lock(&JFS_IP(ip)->commit_mutex); in extRealloc()
218 /* get the extend (partial) page's disk block address and in extRealloc()
229 if ((xp->flag & XAD_NOTRECORDED) && !abnr) { in extRealloc()
230 xp->flag = 0; in extRealloc()
231 if ((rc = xtUpdate(0, ip, xp))) in extRealloc()
243 if ((rc = extBrealloc(ip, xaddr, xlen, &nxlen, &nxaddr))) in extRealloc()
247 rc = dquot_alloc_block(ip, nxlen); in extRealloc()
249 dbFree(ip, nxaddr, (s64) nxlen); in extRealloc()
250 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extRealloc()
254 delta = nxlen - xlen; in extRealloc()
267 if (abnr && (!(xp->flag & XAD_NOTRECORDED)) && (nxlen > nbperpage)) { in extRealloc()
269 nextend = ntail - xlen; in extRealloc()
270 ninsert = nxlen - nbperpage; in extRealloc()
278 xflag = xp->flag; in extRealloc()
287 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) { in extRealloc()
288 dbFree(ip, xaddr + xlen, delta); in extRealloc()
289 dquot_free_block(ip, nxlen); in extRealloc()
298 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) { in extRealloc()
299 dbFree(ip, nxaddr, nxlen); in extRealloc()
300 dquot_free_block(ip, nxlen); in extRealloc()
313 if (xtInsert (0, ip, xflag, xoff + ntail, (int) ninsert, in extRealloc()
315 dbFree(ip, xaddr, (s64) ninsert); in extRealloc()
326 xp->flag = xflag; in extRealloc()
328 mark_inode_dirty(ip); in extRealloc()
330 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extRealloc()
342 * ip - the inode of the file.
343 * offset - file offset for which the hint is needed.
344 * xp - pointer to the xad that is to be filled in with
348 * 0 - success
349 * -EIO - i/o error.
351 int extHint(struct inode *ip, s64 offset, xad_t * xp) in extHint() argument
353 struct super_block *sb = ip->i_sb; in extHint()
354 int nbperpage = JFS_SBI(sb)->nbperpage; in extHint()
367 prev = ((offset & ~POFFSET) >> JFS_SBI(sb)->l2bsize) - nbperpage; in extHint()
374 rc = xtLookup(ip, prev, nbperpage, &xflag, &xaddr, &xlen, 0); in extHint()
378 jfs_error(ip->i_sb, "corrupt xtree\n"); in extHint()
379 rc = -EIO; in extHint()
388 xp->flag = xflag & XAD_NOTRECORDED; in extHint()
403 * ip - inode of the file.
404 * cp - cbuf of the file page.
407 * 0 - success
408 * -EIO - i/o error.
409 * -ENOSPC - insufficient disk resources.
411 int extRecord(struct inode *ip, xad_t * xp) in extRecord() argument
415 txBeginAnon(ip->i_sb); in extRecord()
417 mutex_lock(&JFS_IP(ip)->commit_mutex); in extRecord()
420 rc = xtUpdate(0, ip, xp); in extRecord()
422 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extRecord()
435 * ip - the inode of the file.
436 * cp - cbuf of the file page represent the hole.
439 * 0 - success
440 * -EIO - i/o error.
441 * -ENOSPC - insufficient disk resources.
443 int extFill(struct inode *ip, xad_t * xp) in extFill() argument
445 int rc, nbperpage = JFS_SBI(ip->i_sb)->nbperpage; in extFill()
446 s64 blkno = offsetXAD(xp) >> ip->i_blkbits; in extFill()
448 // assert(ISSPARSE(ip)); in extFill()
454 if ((rc = extAlloc(ip, nbperpage, blkno, xp, false))) in extFill()
475 * number (i.e. 16 -> 8). we'll continue to round down and
480 * ip - the inode of the file.
481 * hint - disk block number to be used as an allocation hint.
482 * *nblocks - pointer to an s64 value. on entry, this value specifies
483 * the desired number of block to be allocated. on successful
486 * blkno - pointer to a block address that is filled in on successful
487 * return with the starting block number of the newly
488 * allocated block range.
491 * 0 - success
492 * -EIO - i/o error.
493 * -ENOSPC - insufficient disk resources.
496 extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno) in extBalloc() argument
498 struct jfs_inode_info *ji = JFS_IP(ip); in extBalloc()
499 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); in extBalloc()
501 int rc, nbperpage = sbi->nbperpage; in extBalloc()
502 struct bmap *bmp = sbi->bmap; in extBalloc()
511 max = (s64) 1 << bmp->db_maxfreebud; in extBalloc()
518 while ((rc = dbAlloc(ip, hint, nb, &daddr)) != 0) { in extBalloc()
522 if (rc != -ENOSPC) in extBalloc()
536 if (S_ISREG(ip->i_mode) && (ji->fileset == FILESYSTEM_I)) { in extBalloc()
538 spin_lock_irq(&ji->ag_lock); in extBalloc()
539 if (ji->active_ag == -1) { in extBalloc()
540 atomic_inc(&bmp->db_active[ag]); in extBalloc()
541 ji->active_ag = ag; in extBalloc()
542 } else if (ji->active_ag != ag) { in extBalloc()
543 atomic_dec(&bmp->db_active[ji->active_ag]); in extBalloc()
544 atomic_inc(&bmp->db_active[ag]); in extBalloc()
545 ji->active_ag = ag; in extBalloc()
547 spin_unlock_irq(&ji->ag_lock); in extBalloc()
569 * number (i.e. 16 -> 8). We'll continue to round down and
574 * ip - the inode of the file.
575 * blkno - starting block number of the extents current allocation.
576 * nblks - number of blocks within the extents current allocation.
577 * newnblks - pointer to a s64 value. on entry, this value is the
581 * newblkno - the starting block number of the extents new allocation.
584 * 0 - success
585 * -EIO - i/o error.
586 * -ENOSPC - insufficient disk resources.
589 extBrealloc(struct inode *ip, in extBrealloc() argument
595 if ((rc = dbExtend(ip, blkno, nblks, *newnblks - nblks)) == 0) { in extBrealloc()
599 if (rc != -ENOSPC) in extBrealloc()
606 return (extBalloc(ip, blkno, newnblks, newblkno)); in extBrealloc()
618 * nb - the inode of the file.
633 i = 63 - i; in extRoundDown()
635 k = ((k - 1) & nb) ? k : k >> 1; in extRoundDown()