Deleted Added
full compact
ffs_inode.c (33134) ffs_inode.c (34206)
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.33 1998/02/04 22:33:31 eivind Exp $
34 * $Id: ffs_inode.c,v 1.34 1998/02/06 12:14:14 eivind 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>

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

199#endif
200 osize = oip->i_size;
201 /*
202 * Lengthen the size of the file. We must ensure that the
203 * last byte of the file is allocated. Since the smallest
204 * value of osize is 0, length will be at least 1.
205 */
206 if (osize < 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>

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

199#endif
200 osize = oip->i_size;
201 /*
202 * Lengthen the size of the file. We must ensure that the
203 * last byte of the file is allocated. Since the smallest
204 * value of osize is 0, length will be at least 1.
205 */
206 if (osize < length) {
207 vnode_pager_setsize(ovp, length);
207 offset = blkoff(fs, length - 1);
208 lbn = lblkno(fs, length - 1);
209 aflags = B_CLRBUF;
210 if (flags & IO_SYNC)
211 aflags |= B_SYNC;
212 error = ffs_balloc(oip, lbn, offset + 1, cred,
213 &bp, aflags);
214 if (error)
215 return (error);
216 oip->i_size = length;
208 offset = blkoff(fs, length - 1);
209 lbn = lblkno(fs, length - 1);
210 aflags = B_CLRBUF;
211 if (flags & IO_SYNC)
212 aflags |= B_SYNC;
213 error = ffs_balloc(oip, lbn, offset + 1, cred,
214 &bp, aflags);
215 if (error)
216 return (error);
217 oip->i_size = length;
217 vnode_pager_setsize(ovp, length);
218 if (bp->b_bufsize == fs->fs_bsize)
219 bp->b_flags |= B_CLUSTEROK;
220 if (aflags & B_SYNC)
221 bwrite(bp);
222 else if (ovp->v_mount->mnt_flag & MNT_ASYNC)
223 bdwrite(bp);
224 else
225 bawrite(bp);

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

252 bp->b_flags |= B_CLUSTEROK;
253 if (aflags & B_SYNC)
254 bwrite(bp);
255 else if (ovp->v_mount->mnt_flag & MNT_ASYNC)
256 bdwrite(bp);
257 else
258 bawrite(bp);
259 }
218 if (bp->b_bufsize == fs->fs_bsize)
219 bp->b_flags |= B_CLUSTEROK;
220 if (aflags & B_SYNC)
221 bwrite(bp);
222 else if (ovp->v_mount->mnt_flag & MNT_ASYNC)
223 bdwrite(bp);
224 else
225 bawrite(bp);

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

252 bp->b_flags |= B_CLUSTEROK;
253 if (aflags & B_SYNC)
254 bwrite(bp);
255 else if (ovp->v_mount->mnt_flag & MNT_ASYNC)
256 bdwrite(bp);
257 else
258 bawrite(bp);
259 }
260 vnode_pager_setsize(ovp, length);
261 /*
262 * Calculate index into inode's block list of
263 * last direct and indirect blocks (if any)
264 * which we want to keep. Lastblock is -1 when
265 * the file is truncated to 0.
266 */
267 lastblock = lblkno(fs, length + fs->fs_bsize - 1) - 1;
268 lastiblock[SINGLE] = lastblock - NDADDR;

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

293 * Note that we save the new block configuration so we can check it
294 * when we are done.
295 */
296 bcopy((caddr_t)&oip->i_db[0], (caddr_t)newblks, sizeof newblks);
297 bcopy((caddr_t)oldblks, (caddr_t)&oip->i_db[0], sizeof oldblks);
298 oip->i_size = osize;
299 vflags = ((length > 0) ? V_SAVE : 0) | V_SAVEMETA;
300 allerror = vinvalbuf(ovp, vflags, cred, p, 0, 0);
260 /*
261 * Calculate index into inode's block list of
262 * last direct and indirect blocks (if any)
263 * which we want to keep. Lastblock is -1 when
264 * the file is truncated to 0.
265 */
266 lastblock = lblkno(fs, length + fs->fs_bsize - 1) - 1;
267 lastiblock[SINGLE] = lastblock - NDADDR;

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

292 * Note that we save the new block configuration so we can check it
293 * when we are done.
294 */
295 bcopy((caddr_t)&oip->i_db[0], (caddr_t)newblks, sizeof newblks);
296 bcopy((caddr_t)oldblks, (caddr_t)&oip->i_db[0], sizeof oldblks);
297 oip->i_size = osize;
298 vflags = ((length > 0) ? V_SAVE : 0) | V_SAVEMETA;
299 allerror = vinvalbuf(ovp, vflags, cred, p, 0, 0);
300 vnode_pager_setsize(ovp, length);
301
302 /*
303 * Indirect blocks first.
304 */
305 indir_lbn[SINGLE] = -NDADDR;
306 indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
307 indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
308 for (level = TRIPLE; level >= SINGLE; level--) {

--- 212 unchanged lines hidden ---
301
302 /*
303 * Indirect blocks first.
304 */
305 indir_lbn[SINGLE] = -NDADDR;
306 indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
307 indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
308 for (level = TRIPLE; level >= SINGLE; level--) {

--- 212 unchanged lines hidden ---