diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2008-09-13 13:06:18 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-09-13 13:06:18 -0400 |
commit | cf17fea6575cb1739552e1d0cb2b446305ee3d0c (patch) | |
tree | 319e1044e271aeb31ad14847f369776ac5db74db /fs/ext4/extents.c | |
parent | ae4d537211ff250a8c23c4f1227c4276cd2508ab (diff) | |
download | linux-cf17fea6575cb1739552e1d0cb2b446305ee3d0c.tar.bz2 |
ext4: Properly update i_disksize.
With delayed allocation we use i_data_sem to update i_disksize. We need
to update i_disksize only if the new size specified is greater than the
current value and we need to make sure we don't race with other
i_disksize update. With delayed allocation we will switch to the
write_begin function for non-delayed allocation if we are low on free
blocks. This means the write_begin function for non-delayed allocation
also needs to use the same locking.
We also need to check and update i_disksize even if the new size is less
that inode.i_size because of delayed allocation.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 797f0602a68f..e8758df2617b 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2878,10 +2878,11 @@ static void ext4_falloc_update_inode(struct inode *inode, * Update only when preallocation was requested beyond * the file size. */ - if (!(mode & FALLOC_FL_KEEP_SIZE) && - new_size > i_size_read(inode)) { - i_size_write(inode, new_size); - EXT4_I(inode)->i_disksize = new_size; + if (!(mode & FALLOC_FL_KEEP_SIZE)) { + if (new_size > i_size_read(inode)) + i_size_write(inode, new_size); + if (new_size > EXT4_I(inode)->i_disksize) + ext4_update_i_disksize(inode, new_size); } } |