diff options
-rw-r--r-- | fs/fat/fat.h | 1 | ||||
-rw-r--r-- | fs/fat/file.c | 3 | ||||
-rw-r--r-- | fs/fat/inode.c | 12 |
3 files changed, 16 insertions, 0 deletions
diff --git a/fs/fat/fat.h b/fs/fat/fat.h index e0c4ba39a377..64e295e8ff38 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
@@ -370,6 +370,7 @@ extern int fat_file_fsync(struct file *file, loff_t start, loff_t end, | |||
370 | int datasync); | 370 | int datasync); |
371 | 371 | ||
372 | /* fat/inode.c */ | 372 | /* fat/inode.c */ |
373 | extern int fat_block_truncate_page(struct inode *inode, loff_t from); | ||
373 | extern void fat_attach(struct inode *inode, loff_t i_pos); | 374 | extern void fat_attach(struct inode *inode, loff_t i_pos); |
374 | extern void fat_detach(struct inode *inode); | 375 | extern void fat_detach(struct inode *inode); |
375 | extern struct inode *fat_iget(struct super_block *sb, loff_t i_pos); | 376 | extern struct inode *fat_iget(struct super_block *sb, loff_t i_pos); |
diff --git a/fs/fat/file.c b/fs/fat/file.c index 85f79a89e747..8429c68e3057 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
@@ -443,6 +443,9 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
443 | } | 443 | } |
444 | 444 | ||
445 | if (attr->ia_valid & ATTR_SIZE) { | 445 | if (attr->ia_valid & ATTR_SIZE) { |
446 | error = fat_block_truncate_page(inode, attr->ia_size); | ||
447 | if (error) | ||
448 | goto out; | ||
446 | down_write(&MSDOS_I(inode)->truncate_lock); | 449 | down_write(&MSDOS_I(inode)->truncate_lock); |
447 | truncate_setsize(inode, attr->ia_size); | 450 | truncate_setsize(inode, attr->ia_size); |
448 | fat_truncate_blocks(inode, attr->ia_size); | 451 | fat_truncate_blocks(inode, attr->ia_size); |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 756aead10d96..7b41a2dcdd76 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -294,6 +294,18 @@ static sector_t _fat_bmap(struct address_space *mapping, sector_t block) | |||
294 | return blocknr; | 294 | return blocknr; |
295 | } | 295 | } |
296 | 296 | ||
297 | /* | ||
298 | * fat_block_truncate_page() zeroes out a mapping from file offset `from' | ||
299 | * up to the end of the block which corresponds to `from'. | ||
300 | * This is required during truncate to physically zeroout the tail end | ||
301 | * of that block so it doesn't yield old data if the file is later grown. | ||
302 | * Also, avoid causing failure from fsx for cases of "data past EOF" | ||
303 | */ | ||
304 | int fat_block_truncate_page(struct inode *inode, loff_t from) | ||
305 | { | ||
306 | return block_truncate_page(inode->i_mapping, from, fat_get_block); | ||
307 | } | ||
308 | |||
297 | static const struct address_space_operations fat_aops = { | 309 | static const struct address_space_operations fat_aops = { |
298 | .readpage = fat_readpage, | 310 | .readpage = fat_readpage, |
299 | .readpages = fat_readpages, | 311 | .readpages = fat_readpages, |