aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/ext4.h
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2008-09-13 13:06:18 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-09-13 13:06:18 -0400
commitcf17fea6575cb1739552e1d0cb2b446305ee3d0c (patch)
tree319e1044e271aeb31ad14847f369776ac5db74db /fs/ext4/ext4.h
parentae4d537211ff250a8c23c4f1227c4276cd2508ab (diff)
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/ext4.h')
-rw-r--r--fs/ext4/ext4.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index e13b9deee866..3e47b99a763c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1218,6 +1218,17 @@ do { \
1218#define EXT4_FREEBLOCKS_WATERMARK 0 1218#define EXT4_FREEBLOCKS_WATERMARK 0
1219#endif 1219#endif
1220 1220
1221static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
1222{
1223 /*
1224 * XXX: replace with spinlock if seen contended -bzzz
1225 */
1226 down_write(&EXT4_I(inode)->i_data_sem);
1227 if (newsize > EXT4_I(inode)->i_disksize)
1228 EXT4_I(inode)->i_disksize = newsize;
1229 up_write(&EXT4_I(inode)->i_data_sem);
1230 return ;
1231}
1221 1232
1222/* 1233/*
1223 * Inodes and files operations 1234 * Inodes and files operations