|
|
| version 1.253, 2007/01/12 15:07:09 | version 1.254, 2007/02/03 02:54:36 |
|---|---|
| Line 134 STATIC int | Line 134 STATIC int |
| xfs_iozero( | xfs_iozero( |
| struct inode *ip, /* inode */ | struct inode *ip, /* inode */ |
| loff_t pos, /* offset in file */ | loff_t pos, /* offset in file */ |
| size_t count, /* size of data to zero */ | size_t count) /* size of data to zero */ |
| loff_t end_size) /* max file size to set */ | |
| { | { |
| unsigned bytes; | unsigned bytes; |
| struct page *page; | struct page *page; |
| Line 172 xfs_iozero( | Line 171 xfs_iozero( |
| if (!status) { | if (!status) { |
| pos += bytes; | pos += bytes; |
| count -= bytes; | count -= bytes; |
| if (pos > i_size_read(ip)) | |
| i_size_write(ip, pos < end_size ? pos : end_size); | |
| } | } |
| unlock: | unlock: |
| Line 449 STATIC int /* error (positive) */ | Line 446 STATIC int /* error (positive) */ |
| xfs_zero_last_block( | xfs_zero_last_block( |
| struct inode *ip, | struct inode *ip, |
| xfs_iocore_t *io, | xfs_iocore_t *io, |
| xfs_fsize_t isize, | xfs_fsize_t offset, |
| xfs_fsize_t end_size) | xfs_fsize_t isize) |
| { | { |
| xfs_fileoff_t last_fsb; | xfs_fileoff_t last_fsb; |
| xfs_mount_t *mp = io->io_mount; | xfs_mount_t *mp = io->io_mount; |
| Line 459 xfs_zero_last_block( | Line 456 xfs_zero_last_block( |
| int zero_len; | int zero_len; |
| int error = 0; | int error = 0; |
| xfs_bmbt_irec_t imap; | xfs_bmbt_irec_t imap; |
| loff_t loff; | |
| ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0); | ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0); |
| Line 494 xfs_zero_last_block( | Line 490 xfs_zero_last_block( |
| */ | */ |
| XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD); | XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD); |
| loff = XFS_FSB_TO_B(mp, last_fsb); | |
| zero_len = mp->m_sb.sb_blocksize - zero_offset; | zero_len = mp->m_sb.sb_blocksize - zero_offset; |
| error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size); | if (isize + zero_len > offset) |
| zero_len = offset - isize; | |
| error = xfs_iozero(ip, isize, zero_len); | |
| XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); | XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); |
| ASSERT(error >= 0); | ASSERT(error >= 0); |
| Line 519 xfs_zero_eof( | Line 516 xfs_zero_eof( |
| bhv_vnode_t *vp, | bhv_vnode_t *vp, |
| xfs_iocore_t *io, | xfs_iocore_t *io, |
| xfs_off_t offset, /* starting I/O offset */ | xfs_off_t offset, /* starting I/O offset */ |
| xfs_fsize_t isize, /* current inode size */ | xfs_fsize_t isize) /* current inode size */ |
| xfs_fsize_t end_size) /* terminal inode size */ | |
| { | { |
| struct inode *ip = vn_to_inode(vp); | struct inode *ip = vn_to_inode(vp); |
| xfs_fileoff_t start_zero_fsb; | xfs_fileoff_t start_zero_fsb; |
| xfs_fileoff_t end_zero_fsb; | xfs_fileoff_t end_zero_fsb; |
| xfs_fileoff_t zero_count_fsb; | xfs_fileoff_t zero_count_fsb; |
| xfs_fileoff_t last_fsb; | xfs_fileoff_t last_fsb; |
| xfs_fileoff_t zero_off; | |
| xfs_fsize_t zero_len; | |
| xfs_mount_t *mp = io->io_mount; | xfs_mount_t *mp = io->io_mount; |
| int nimaps; | int nimaps; |
| int error = 0; | int error = 0; |
| Line 540 xfs_zero_eof( | Line 538 xfs_zero_eof( |
| * First handle zeroing the block on which isize resides. | * First handle zeroing the block on which isize resides. |
| * We only zero a part of that block so it is handled specially. | * We only zero a part of that block so it is handled specially. |
| */ | */ |
| error = xfs_zero_last_block(ip, io, isize, end_size); | error = xfs_zero_last_block(ip, io, offset, isize); |
| if (error) { | if (error) { |
| ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); | ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); |
| ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); | ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); |
| Line 601 xfs_zero_eof( | Line 599 xfs_zero_eof( |
| */ | */ |
| XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); | XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); |
| error = xfs_iozero(ip, | zero_off = XFS_FSB_TO_B(mp, start_zero_fsb); |
| XFS_FSB_TO_B(mp, start_zero_fsb), | zero_len = XFS_FSB_TO_B(mp, imap.br_blockcount); |
| XFS_FSB_TO_B(mp, imap.br_blockcount), | |
| end_size); | if ((zero_off + zero_len) > offset) |
| zero_len = offset - zero_off; | |
| error = xfs_iozero(ip, zero_off, zero_len); | |
| if (error) { | if (error) { |
| goto out_lock; | goto out_lock; |
| } | } |
| Line 783 start: | Line 784 start: |
| */ | */ |
| if (pos > isize) { | if (pos > isize) { |
| error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, pos, | error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, pos, isize); |
| isize, pos + count); | |
| if (error) { | if (error) { |
| xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); | xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); |
| goto out_unlock_mutex; | goto out_unlock_mutex; |