ext2_balloc.c (34924) | ext2_balloc.c (43301) |
---|---|
1/* 2 * modified for Lites 1.1 3 * 4 * Aug 1995, Godmar Back (gback@cs.utah.edu) 5 * University of Utah, Department of Computer Science 6 */ 7/* 8 * Copyright (c) 1982, 1986, 1989, 1993 --- 146 unchanged lines hidden (view full) --- 155 ip->i_flag |= IN_CHANGE | IN_UPDATE; 156 *bpp = bp; 157 return (0); 158 } 159 /* 160 * Determine the number of levels of indirection. 161 */ 162 pref = 0; | 1/* 2 * modified for Lites 1.1 3 * 4 * Aug 1995, Godmar Back (gback@cs.utah.edu) 5 * University of Utah, Department of Computer Science 6 */ 7/* 8 * Copyright (c) 1982, 1986, 1989, 1993 --- 146 unchanged lines hidden (view full) --- 155 ip->i_flag |= IN_CHANGE | IN_UPDATE; 156 *bpp = bp; 157 return (0); 158 } 159 /* 160 * Determine the number of levels of indirection. 161 */ 162 pref = 0; |
163 if (error = ufs_getlbns(vp, bn, indirs, &num)) | 163 if ((error = ufs_getlbns(vp, bn, indirs, &num)) != 0) |
164 return(error); 165#if DIAGNOSTIC 166 if (num < 1) 167 panic ("ext2_balloc: ufs_bmaparray returned indirect block"); 168#endif 169 /* 170 * Fetch the first indirect block allocating if necessary. 171 */ --- 12 unchanged lines hidden (view full) --- 184 Godmar thinks it make sense to allocate i_ib[0] immediately 185 after i_db[11], but it's not utterly clear whether this also 186 applies to i_ib[1] and i_ib[0] 187 */ 188 189 pref = ext2_blkpref(ip, lbn, indirs[0].in_off + 190 EXT2_NDIR_BLOCKS, &ip->i_db[0], 0); 191#endif | 164 return(error); 165#if DIAGNOSTIC 166 if (num < 1) 167 panic ("ext2_balloc: ufs_bmaparray returned indirect block"); 168#endif 169 /* 170 * Fetch the first indirect block allocating if necessary. 171 */ --- 12 unchanged lines hidden (view full) --- 184 Godmar thinks it make sense to allocate i_ib[0] immediately 185 after i_db[11], but it's not utterly clear whether this also 186 applies to i_ib[1] and i_ib[0] 187 */ 188 189 pref = ext2_blkpref(ip, lbn, indirs[0].in_off + 190 EXT2_NDIR_BLOCKS, &ip->i_db[0], 0); 191#endif |
192 if (error = ext2_alloc(ip, lbn, pref, (int)fs->s_blocksize, 193 cred, &newb)) | 192 if ((error = ext2_alloc(ip, lbn, pref, (int)fs->s_blocksize, 193 cred, &newb)) != 0) |
194 return (error); 195 nb = newb; 196 bp = getblk(vp, indirs[1].in_lbn, fs->s_blocksize, 0, 0); 197 bp->b_blkno = fsbtodb(fs, newb); 198 vfs_bio_clrbuf(bp); 199 /* 200 * Write synchronously so that indirect blocks 201 * never point at garbage. 202 */ | 194 return (error); 195 nb = newb; 196 bp = getblk(vp, indirs[1].in_lbn, fs->s_blocksize, 0, 0); 197 bp->b_blkno = fsbtodb(fs, newb); 198 vfs_bio_clrbuf(bp); 199 /* 200 * Write synchronously so that indirect blocks 201 * never point at garbage. 202 */ |
203 if (error = bwrite(bp)) { | 203 if ((error = bwrite(bp)) != 0) { |
204 ext2_blkfree(ip, nb, fs->s_blocksize); 205 return (error); 206 } 207 ip->i_ib[indirs[0].in_off] = newb; 208 ip->i_flag |= IN_CHANGE | IN_UPDATE; 209 } 210 /* 211 * Fetch through the indirect blocks, allocating as necessary. --- 22 unchanged lines hidden (view full) --- 234 * block containing pointers together ? 235 * Also, will it ever succeed ? 236 */ 237 pref = ext2_blkpref(ip, lbn, indirs[i].in_off, bap, 238 bp->b_lblkno); 239#else 240 pref = ext2_blkpref(ip, lbn, 0, (daddr_t *)0, 0); 241#endif | 204 ext2_blkfree(ip, nb, fs->s_blocksize); 205 return (error); 206 } 207 ip->i_ib[indirs[0].in_off] = newb; 208 ip->i_flag |= IN_CHANGE | IN_UPDATE; 209 } 210 /* 211 * Fetch through the indirect blocks, allocating as necessary. --- 22 unchanged lines hidden (view full) --- 234 * block containing pointers together ? 235 * Also, will it ever succeed ? 236 */ 237 pref = ext2_blkpref(ip, lbn, indirs[i].in_off, bap, 238 bp->b_lblkno); 239#else 240 pref = ext2_blkpref(ip, lbn, 0, (daddr_t *)0, 0); 241#endif |
242 if (error = 243 ext2_alloc(ip, lbn, pref, (int)fs->s_blocksize, cred, &newb)) { | 242 if ((error = 243 ext2_alloc(ip, lbn, pref, (int)fs->s_blocksize, cred, &newb)) != 0) { |
244 brelse(bp); 245 return (error); 246 } 247 nb = newb; 248 nbp = getblk(vp, indirs[i].in_lbn, fs->s_blocksize, 0, 0); 249 nbp->b_blkno = fsbtodb(fs, nb); 250 vfs_bio_clrbuf(nbp); 251 /* 252 * Write synchronously so that indirect blocks 253 * never point at garbage. 254 */ | 244 brelse(bp); 245 return (error); 246 } 247 nb = newb; 248 nbp = getblk(vp, indirs[i].in_lbn, fs->s_blocksize, 0, 0); 249 nbp->b_blkno = fsbtodb(fs, nb); 250 vfs_bio_clrbuf(nbp); 251 /* 252 * Write synchronously so that indirect blocks 253 * never point at garbage. 254 */ |
255 if (error = bwrite(nbp)) { | 255 if ((error = bwrite(nbp)) != 0) { |
256 ext2_blkfree(ip, nb, fs->s_blocksize); 257 brelse(bp); 258 return (error); 259 } 260 bap[indirs[i - 1].in_off] = nb; 261 /* 262 * If required, write synchronously, otherwise use 263 * delayed write. --- 5 unchanged lines hidden (view full) --- 269 } 270 } 271 /* 272 * Get the data block, allocating if necessary. 273 */ 274 if (nb == 0) { 275 pref = ext2_blkpref(ip, lbn, indirs[i].in_off, &bap[0], 276 bp->b_lblkno); | 256 ext2_blkfree(ip, nb, fs->s_blocksize); 257 brelse(bp); 258 return (error); 259 } 260 bap[indirs[i - 1].in_off] = nb; 261 /* 262 * If required, write synchronously, otherwise use 263 * delayed write. --- 5 unchanged lines hidden (view full) --- 269 } 270 } 271 /* 272 * Get the data block, allocating if necessary. 273 */ 274 if (nb == 0) { 275 pref = ext2_blkpref(ip, lbn, indirs[i].in_off, &bap[0], 276 bp->b_lblkno); |
277 if (error = ext2_alloc(ip, 278 lbn, pref, (int)fs->s_blocksize, cred, &newb)) { | 277 if ((error = ext2_alloc(ip, 278 lbn, pref, (int)fs->s_blocksize, cred, &newb)) != 0) { |
279 brelse(bp); 280 return (error); 281 } 282 nb = newb; 283 nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0); 284 nbp->b_blkno = fsbtodb(fs, nb); 285 if (flags & B_CLRBUF) 286 vfs_bio_clrbuf(nbp); --- 27 unchanged lines hidden --- | 279 brelse(bp); 280 return (error); 281 } 282 nb = newb; 283 nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0); 284 nbp->b_blkno = fsbtodb(fs, nb); 285 if (flags & B_CLRBUF) 286 vfs_bio_clrbuf(nbp); --- 27 unchanged lines hidden --- |