Lines Matching +full:ip +full:- +full:blocks

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) International Business Machines Corp., 2000-2004
54 * ip - the inode of the file.
55 * xlen - requested extent length.
56 * pno - the starting page number with the file.
57 * xp - pointer to an xad. on entry, xad describes an
59 * xaddr of the xad is non-zero. on successful exit,
61 * abnr - bool indicating whether the newly allocated extent
65 * 0 - success
66 * -EIO - i/o error.
67 * -ENOSPC - insufficient disk resources.
70 extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr) in extAlloc() argument
72 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); in extAlloc()
77 /* This blocks if we are low on resources */ in extAlloc()
78 txBeginAnon(ip->i_sb); in extAlloc()
81 mutex_lock(&JFS_IP(ip)->commit_mutex); in extAlloc()
88 xoff = pno << sbi->l2nbperpage; in extAlloc()
100 * extent if we can allocate the blocks immediately in extAlloc()
104 abnr == ((xp->flag & XAD_NOTRECORDED) ? true : false)) in extAlloc()
108 hint += (nxlen - 1); in extAlloc()
111 /* allocate the disk blocks for the extent. initially, extBalloc() in extAlloc()
112 * will try to allocate disk blocks for the requested size (xlen). in extAlloc()
113 * if this fails (xlen contiguous free blocks not available), it'll in extAlloc()
114 * try to allocate a smaller number of blocks (producing a smaller in extAlloc()
115 * extent), with this smaller number of blocks consisting of the in extAlloc()
116 * requested number of blocks rounded down to the next smaller in extAlloc()
117 * power of 2 number (i.e. 16 -> 8). it'll continue to round down in extAlloc()
118 * and retry the allocation until the number of blocks to allocate in extAlloc()
119 * is smaller than the number of blocks per page. in extAlloc()
122 if ((rc = extBalloc(ip, hint ? hint : INOHINT(ip), &nxlen, &nxaddr))) { in extAlloc()
123 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
127 /* Allocate blocks to quota. */ in extAlloc()
128 rc = dquot_alloc_block(ip, nxlen); in extAlloc()
130 dbFree(ip, nxaddr, (s64) nxlen); in extAlloc()
131 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
143 rc = xtExtend(0, ip, xoff, (int) nxlen, 0); in extAlloc()
145 rc = xtInsert(0, ip, xflag, xoff, (int) nxlen, &nxaddr, 0); in extAlloc()
148 * free the newly allocated blocks and return the error. in extAlloc()
151 dbFree(ip, nxaddr, nxlen); in extAlloc()
152 dquot_free_block(ip, nxlen); in extAlloc()
153 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
161 xp->flag = xflag; in extAlloc()
163 mark_inode_dirty(ip); in extAlloc()
165 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extAlloc()
171 if (test_and_clear_cflag(COMMIT_Synclist,ip)) in extAlloc()
172 jfs_commit_inode(ip, 0); in extAlloc()
183 * ip - the inode of the file.
184 * offset - file offset for which the hint is needed.
185 * xp - pointer to the xad that is to be filled in with
189 * 0 - success
190 * -EIO - i/o error.
192 int extHint(struct inode *ip, s64 offset, xad_t * xp) in extHint() argument
194 struct super_block *sb = ip->i_sb; in extHint()
195 int nbperpage = JFS_SBI(sb)->nbperpage; in extHint()
208 prev = ((offset & ~POFFSET) >> JFS_SBI(sb)->l2bsize) - nbperpage; in extHint()
215 rc = xtLookup(ip, prev, nbperpage, &xflag, &xaddr, &xlen, 0); in extHint()
219 jfs_error(ip->i_sb, "corrupt xtree\n"); in extHint()
220 rc = -EIO; in extHint()
229 xp->flag = xflag & XAD_NOTRECORDED; in extHint()
244 * ip - inode of the file.
245 * cp - cbuf of the file page.
248 * 0 - success
249 * -EIO - i/o error.
250 * -ENOSPC - insufficient disk resources.
252 int extRecord(struct inode *ip, xad_t * xp) in extRecord() argument
256 txBeginAnon(ip->i_sb); in extRecord()
258 mutex_lock(&JFS_IP(ip)->commit_mutex); in extRecord()
261 rc = xtUpdate(0, ip, xp); in extRecord()
263 mutex_unlock(&JFS_IP(ip)->commit_mutex); in extRecord()
270 * FUNCTION: allocate disk blocks to form an extent.
272 * initially, we will try to allocate disk blocks for the
274 * contiguous free blocks not available), we'll try to allocate
275 * a smaller number of blocks (producing a smaller extent), with
276 * this smaller number of blocks consisting of the requested
277 * number of blocks rounded down to the next smaller power of 2
278 * number (i.e. 16 -> 8). we'll continue to round down and
279 * retry the allocation until the number of blocks to allocate
280 * is smaller than the number of blocks per page.
283 * ip - the inode of the file.
284 * hint - disk block number to be used as an allocation hint.
285 * *nblocks - pointer to an s64 value. on entry, this value specifies
287 * exit, this value is set to the number of blocks actually
289 * blkno - pointer to a block address that is filled in on successful
294 * 0 - success
295 * -EIO - i/o error.
296 * -ENOSPC - insufficient disk resources.
299 extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno) in extBalloc() argument
301 struct jfs_inode_info *ji = JFS_IP(ip); in extBalloc()
302 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); in extBalloc()
304 int rc, nbperpage = sbi->nbperpage; in extBalloc()
305 struct bmap *bmp = sbi->bmap; in extBalloc()
308 /* get the number of blocks to initially attempt to allocate. in extBalloc()
309 * we'll first try the number of blocks requested unless this in extBalloc()
311 * blocks in the map. in that case, we'll start off with the in extBalloc()
316 if (bmp->db_maxfreebud == -1) in extBalloc()
317 return -ENOSPC; in extBalloc()
319 max = (s64) 1 << bmp->db_maxfreebud; in extBalloc()
325 /* try to allocate blocks */ in extBalloc()
326 while ((rc = dbAlloc(ip, hint, nb, &daddr)) != 0) { in extBalloc()
330 if (rc != -ENOSPC) in extBalloc()
344 if (S_ISREG(ip->i_mode) && (ji->fileset == FILESYSTEM_I)) { in extBalloc()
346 spin_lock_irq(&ji->ag_lock); in extBalloc()
347 if (ji->active_ag == -1) { in extBalloc()
348 atomic_inc(&bmp->db_active[ag]); in extBalloc()
349 ji->active_ag = ag; in extBalloc()
350 } else if (ji->active_ag != ag) { in extBalloc()
351 atomic_dec(&bmp->db_active[ji->active_ag]); in extBalloc()
352 atomic_inc(&bmp->db_active[ag]); in extBalloc()
353 ji->active_ag = ag; in extBalloc()
355 spin_unlock_irq(&ji->ag_lock); in extBalloc()
364 * FUNCTION: round down a specified number of blocks to the next
368 * nb - the inode of the file.
383 i = 63 - i; in extRoundDown()
385 k = ((k - 1) & nb) ? k : k >> 1; in extRoundDown()