ext2_inode.c (215548) | ext2_inode.c (221166) |
---|---|
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 --- 19 unchanged lines hidden (view full) --- 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)ffs_inode.c 8.5 (Berkeley) 12/30/93 | 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 --- 19 unchanged lines hidden (view full) --- 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)ffs_inode.c 8.5 (Berkeley) 12/30/93 |
36 * $FreeBSD: head/sys/fs/ext2fs/ext2_inode.c 215548 2010-11-19 21:17:34Z kib $ | 36 * $FreeBSD: head/sys/fs/ext2fs/ext2_inode.c 221166 2011-04-28 14:27:17Z jhb $ |
37 */ 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/mount.h> 42#include <sys/bio.h> 43#include <sys/buf.h> 44#include <sys/vnode.h> --- 42 unchanged lines hidden (view full) --- 87 if ((error = bread(ip->i_devvp, 88 fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), 89 (int)fs->e2fs_bsize, NOCRED, &bp)) != 0) { 90 brelse(bp); 91 return (error); 92 } 93 ext2_i2ei(ip, (struct ext2fs_dinode *)((char *)bp->b_data + 94 EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number))); | 37 */ 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/mount.h> 42#include <sys/bio.h> 43#include <sys/buf.h> 44#include <sys/vnode.h> --- 42 unchanged lines hidden (view full) --- 87 if ((error = bread(ip->i_devvp, 88 fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), 89 (int)fs->e2fs_bsize, NOCRED, &bp)) != 0) { 90 brelse(bp); 91 return (error); 92 } 93 ext2_i2ei(ip, (struct ext2fs_dinode *)((char *)bp->b_data + 94 EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number))); |
95 if (waitfor && (vp->v_mount->mnt_kern_flag & MNTK_ASYNC) == 0) | 95 if (waitfor && !DOINGASYNC(vp)) |
96 return (bwrite(bp)); 97 else { 98 bdwrite(bp); 99 return (0); 100 } 101} 102 103#define SINGLE 0 /* index of single indirect block */ --- 16 unchanged lines hidden (view full) --- 120 struct inode *oip; 121 int32_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR]; 122 int32_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR]; 123 struct bufobj *bo; 124 struct m_ext2fs *fs; 125 struct buf *bp; 126 int offset, size, level; 127 long count, nblocks, blocksreleased = 0; | 96 return (bwrite(bp)); 97 else { 98 bdwrite(bp); 99 return (0); 100 } 101} 102 103#define SINGLE 0 /* index of single indirect block */ --- 16 unchanged lines hidden (view full) --- 120 struct inode *oip; 121 int32_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR]; 122 int32_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR]; 123 struct bufobj *bo; 124 struct m_ext2fs *fs; 125 struct buf *bp; 126 int offset, size, level; 127 long count, nblocks, blocksreleased = 0; |
128 int aflags, error, i, allerror; | 128 int error, i, allerror; |
129 off_t osize; 130 131 oip = VTOI(ovp); 132 bo = &ovp->v_bufobj; 133 134 ASSERT_VOP_LOCKED(vp, "ext2_truncate"); 135 136 if (length < 0) --- 22 unchanged lines hidden (view full) --- 159 * value of osize is 0, length will be at least 1. 160 */ 161 if (osize < length) { 162 if (length > oip->i_e2fs->e2fs_maxfilesize) 163 return (EFBIG); 164 vnode_pager_setsize(ovp, length); 165 offset = blkoff(fs, length - 1); 166 lbn = lblkno(fs, length - 1); | 129 off_t osize; 130 131 oip = VTOI(ovp); 132 bo = &ovp->v_bufobj; 133 134 ASSERT_VOP_LOCKED(vp, "ext2_truncate"); 135 136 if (length < 0) --- 22 unchanged lines hidden (view full) --- 159 * value of osize is 0, length will be at least 1. 160 */ 161 if (osize < length) { 162 if (length > oip->i_e2fs->e2fs_maxfilesize) 163 return (EFBIG); 164 vnode_pager_setsize(ovp, length); 165 offset = blkoff(fs, length - 1); 166 lbn = lblkno(fs, length - 1); |
167 aflags = B_CLRBUF; 168 if (flags & IO_SYNC) 169 aflags |= B_SYNC; 170 error = ext2_balloc(oip, lbn, offset + 1, cred, &bp, aflags); | 167 flags |= BA_CLRBUF; 168 error = ext2_balloc(oip, lbn, offset + 1, cred, &bp, flags); |
171 if (error) { 172 vnode_pager_setsize(vp, osize); 173 return (error); 174 } 175 oip->i_size = length; 176 if (bp->b_bufsize == fs->e2fs_bsize) 177 bp->b_flags |= B_CLUSTEROK; | 169 if (error) { 170 vnode_pager_setsize(vp, osize); 171 return (error); 172 } 173 oip->i_size = length; 174 if (bp->b_bufsize == fs->e2fs_bsize) 175 bp->b_flags |= B_CLUSTEROK; |
178 if (aflags & B_SYNC) | 176 if (flags & IO_SYNC) |
179 bwrite(bp); | 177 bwrite(bp); |
180 else if (ovp->v_mount->mnt_flag & MNT_ASYNC) | 178 else if (DOINGASYNC(ovp)) |
181 bdwrite(bp); 182 else 183 bawrite(bp); 184 oip->i_flag |= IN_CHANGE | IN_UPDATE; 185 return (ext2_update(ovp, 1)); 186 } 187 /* 188 * Shorten the size of the file. If the file is not being 189 * truncated to a block boundry, the contents of the 190 * partial block following the end of the file must be 191 * zero'ed in case it ever become accessible again because 192 * of subsequent file growth. 193 */ 194 /* I don't understand the comment above */ 195 offset = blkoff(fs, length); 196 if (offset == 0) { 197 oip->i_size = length; 198 } else { 199 lbn = lblkno(fs, length); | 179 bdwrite(bp); 180 else 181 bawrite(bp); 182 oip->i_flag |= IN_CHANGE | IN_UPDATE; 183 return (ext2_update(ovp, 1)); 184 } 185 /* 186 * Shorten the size of the file. If the file is not being 187 * truncated to a block boundry, the contents of the 188 * partial block following the end of the file must be 189 * zero'ed in case it ever become accessible again because 190 * of subsequent file growth. 191 */ 192 /* I don't understand the comment above */ 193 offset = blkoff(fs, length); 194 if (offset == 0) { 195 oip->i_size = length; 196 } else { 197 lbn = lblkno(fs, length); |
200 aflags = B_CLRBUF; 201 if (flags & IO_SYNC) 202 aflags |= B_SYNC; 203 error = ext2_balloc(oip, lbn, offset, cred, &bp, aflags); | 198 flags |= BA_CLRBUF; 199 error = ext2_balloc(oip, lbn, offset, cred, &bp, flags); |
204 if (error) 205 return (error); 206 oip->i_size = length; 207 size = blksize(fs, oip, lbn); 208 bzero((char *)bp->b_data + offset, (u_int)(size - offset)); 209 allocbuf(bp, size); 210 if (bp->b_bufsize == fs->e2fs_bsize) 211 bp->b_flags |= B_CLUSTEROK; | 200 if (error) 201 return (error); 202 oip->i_size = length; 203 size = blksize(fs, oip, lbn); 204 bzero((char *)bp->b_data + offset, (u_int)(size - offset)); 205 allocbuf(bp, size); 206 if (bp->b_bufsize == fs->e2fs_bsize) 207 bp->b_flags |= B_CLUSTEROK; |
212 if (aflags & B_SYNC) | 208 if (flags & IO_SYNC) |
213 bwrite(bp); | 209 bwrite(bp); |
214 else if (ovp->v_mount->mnt_flag & MNT_ASYNC) | 210 else if (DOINGASYNC(ovp)) |
215 bdwrite(bp); 216 else 217 bawrite(bp); 218 } 219 /* 220 * Calculate index into inode's block list of 221 * last direct and indirect blocks (if any) 222 * which we want to keep. Lastblock is -1 when --- 310 unchanged lines hidden --- | 211 bdwrite(bp); 212 else 213 bawrite(bp); 214 } 215 /* 216 * Calculate index into inode's block list of 217 * last direct and indirect blocks (if any) 218 * which we want to keep. Lastblock is -1 when --- 310 unchanged lines hidden --- |