Deleted Added
full compact
ffs_inode.c (34266) ffs_inode.c (34611)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95
1/*
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95
34 * $Id: ffs_inode.c,v 1.35 1998/03/07 21:36:33 dyson Exp $
34 * $Id: ffs_inode.c,v 1.36 1998/03/08 09:58:55 julian Exp $
35 */
36
37#include "opt_quota.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/mount.h>
42#include <sys/proc.h>

--- 176 unchanged lines hidden (view full) ---

219 if ((error = VOP_FSYNC(ovp, cred, MNT_WAIT,
220 p)) != 0)
221 return (error);
222 } else {
223#ifdef QUOTA
224 (void) chkdq(oip, -oip->i_blocks, NOCRED, 0);
225#endif
226 softdep_setup_freeblocks(oip, length);
35 */
36
37#include "opt_quota.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/mount.h>
42#include <sys/proc.h>

--- 176 unchanged lines hidden (view full) ---

219 if ((error = VOP_FSYNC(ovp, cred, MNT_WAIT,
220 p)) != 0)
221 return (error);
222 } else {
223#ifdef QUOTA
224 (void) chkdq(oip, -oip->i_blocks, NOCRED, 0);
225#endif
226 softdep_setup_freeblocks(oip, length);
227 (void) vinvalbuf(ovp, 0, cred, p, 0, 0);
227 (void) vtruncbuf(ovp, cred, p, length, fs->fs_bsize);
228 oip->i_flag |= IN_CHANGE | IN_UPDATE;
229 return (ffs_update(ovp, &tv, &tv, 0));
230 }
231 }
232 osize = oip->i_size;
233 /*
234 * Lengthen the size of the file. We must ensure that the
235 * last byte of the file is allocated. Since the smallest
236 * value of osize is 0, length will be at least 1.
237 */
238 if (osize < length) {
239 vnode_pager_setsize(ovp, length);
228 oip->i_flag |= IN_CHANGE | IN_UPDATE;
229 return (ffs_update(ovp, &tv, &tv, 0));
230 }
231 }
232 osize = oip->i_size;
233 /*
234 * Lengthen the size of the file. We must ensure that the
235 * last byte of the file is allocated. Since the smallest
236 * value of osize is 0, length will be at least 1.
237 */
238 if (osize < length) {
239 vnode_pager_setsize(ovp, length);
240#if 0
241 offset = blkoff(fs, length - 1);
242 lbn = lblkno(fs, length - 1);
243#endif
244 aflags = B_CLRBUF;
245 if (flags & IO_SYNC)
246 aflags |= B_SYNC;
247 error = VOP_BALLOC(ovp, length - 1, 1,
248 cred, aflags, &bp);
249 if (error)
250 return (error);
251 oip->i_size = length;

--- 20 unchanged lines hidden (view full) ---

272 oip->i_size = length;
273 } else {
274 lbn = lblkno(fs, length);
275 aflags = B_CLRBUF;
276 if (flags & IO_SYNC)
277 aflags |= B_SYNC;
278 error = VOP_BALLOC(ovp, length - 1, 1, cred, aflags, &bp);
279 if (error) {
240 aflags = B_CLRBUF;
241 if (flags & IO_SYNC)
242 aflags |= B_SYNC;
243 error = VOP_BALLOC(ovp, length - 1, 1,
244 cred, aflags, &bp);
245 if (error)
246 return (error);
247 oip->i_size = length;

--- 20 unchanged lines hidden (view full) ---

268 oip->i_size = length;
269 } else {
270 lbn = lblkno(fs, length);
271 aflags = B_CLRBUF;
272 if (flags & IO_SYNC)
273 aflags |= B_SYNC;
274 error = VOP_BALLOC(ovp, length - 1, 1, cred, aflags, &bp);
275 if (error) {
280#if 0 /* kirk's version had this */
281 vnode_pager_setsize(ovp, (u_long)osize);
282#endif
283 return (error);
284 }
285 oip->i_size = length;
286 size = blksize(fs, oip, lbn);
287 bzero((char *)bp->b_data + offset, (u_int)(size - offset));
288 allocbuf(bp, size);
289 if (bp->b_bufsize == fs->fs_bsize)
290 bp->b_flags |= B_CLUSTEROK;

--- 37 unchanged lines hidden (view full) ---

328 * Having written the new inode to disk, save its new configuration
329 * and put back the old block pointers long enough to process them.
330 * Note that we save the new block configuration so we can check it
331 * when we are done.
332 */
333 bcopy((caddr_t)&oip->i_db[0], (caddr_t)newblks, sizeof newblks);
334 bcopy((caddr_t)oldblks, (caddr_t)&oip->i_db[0], sizeof oldblks);
335 oip->i_size = osize;
276 return (error);
277 }
278 oip->i_size = length;
279 size = blksize(fs, oip, lbn);
280 bzero((char *)bp->b_data + offset, (u_int)(size - offset));
281 allocbuf(bp, size);
282 if (bp->b_bufsize == fs->fs_bsize)
283 bp->b_flags |= B_CLUSTEROK;

--- 37 unchanged lines hidden (view full) ---

321 * Having written the new inode to disk, save its new configuration
322 * and put back the old block pointers long enough to process them.
323 * Note that we save the new block configuration so we can check it
324 * when we are done.
325 */
326 bcopy((caddr_t)&oip->i_db[0], (caddr_t)newblks, sizeof newblks);
327 bcopy((caddr_t)oldblks, (caddr_t)&oip->i_db[0], sizeof oldblks);
328 oip->i_size = osize;
336 vflags = ((length > 0) ? V_SAVE : 0) | V_SAVEMETA;
337 allerror = vinvalbuf(ovp, vflags, cred, p, 0, 0);
338 vnode_pager_setsize(ovp, length);
329 allerror = vtruncbuf(ovp, cred, p, length, fs->fs_bsize);
339
340 /*
341 * Indirect blocks first.
342 */
343 indir_lbn[SINGLE] = -NDADDR;
344 indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
345 indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
346 for (level = TRIPLE; level >= SINGLE; level--) {

--- 74 unchanged lines hidden (view full) ---

421 /*
422 * Put back the real size.
423 */
424 oip->i_size = length;
425 oip->i_blocks -= blocksreleased;
426 if (oip->i_blocks < 0) /* sanity */
427 oip->i_blocks = 0;
428 oip->i_flag |= IN_CHANGE;
330
331 /*
332 * Indirect blocks first.
333 */
334 indir_lbn[SINGLE] = -NDADDR;
335 indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
336 indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
337 for (level = TRIPLE; level >= SINGLE; level--) {

--- 74 unchanged lines hidden (view full) ---

412 /*
413 * Put back the real size.
414 */
415 oip->i_size = length;
416 oip->i_blocks -= blocksreleased;
417 if (oip->i_blocks < 0) /* sanity */
418 oip->i_blocks = 0;
419 oip->i_flag |= IN_CHANGE;
429 vnode_pager_setsize(ovp, length);
430#ifdef QUOTA
431 (void) chkdq(oip, -blocksreleased, NOCRED, 0);
432#endif
433 return (allerror);
434}
435
436/*
437 * Release blocks associated with the inode ip and stored in the indirect

--- 121 unchanged lines hidden ---
420#ifdef QUOTA
421 (void) chkdq(oip, -blocksreleased, NOCRED, 0);
422#endif
423 return (allerror);
424}
425
426/*
427 * Release blocks associated with the inode ip and stored in the indirect

--- 121 unchanged lines hidden ---