diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-10 14:26:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-10 14:26:52 -0400 |
commit | 5f248c9c251c60af3403902b26e08de43964ea0b (patch) | |
tree | 6d3328e72a7e4015a64017eb30be18095c6a3c64 /mm/truncate.c | |
parent | f6cec0ae58c17522a7bc4e2f39dae19f199ab534 (diff) | |
parent | dca332528bc69e05f67161e1ed59929633d5e63d (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (96 commits)
no need for list_for_each_entry_safe()/resetting with superblock list
Fix sget() race with failing mount
vfs: don't hold s_umount over close_bdev_exclusive() call
sysv: do not mark superblock dirty on remount
sysv: do not mark superblock dirty on mount
btrfs: remove junk sb_dirt change
BFS: clean up the superblock usage
AFFS: wait for sb synchronization when needed
AFFS: clean up dirty flag usage
cifs: truncate fallout
mbcache: fix shrinker function return value
mbcache: Remove unused features
add f_flags to struct statfs(64)
pass a struct path to vfs_statfs
update VFS documentation for method changes.
All filesystems that need invalidate_inode_buffers() are doing that explicitly
convert remaining ->clear_inode() to ->evict_inode()
Make ->drop_inode() just return whether inode needs to be dropped
fs/inode.c:clear_inode() is gone
fs/inode.c:evict() doesn't care about delete vs. non-delete paths now
...
Fix up trivial conflicts in fs/nilfs2/super.c
Diffstat (limited to 'mm/truncate.c')
-rw-r--r-- | mm/truncate.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/mm/truncate.c b/mm/truncate.c index 937571b8b233..ba887bff48c5 100644 --- a/mm/truncate.c +++ b/mm/truncate.c | |||
@@ -541,28 +541,48 @@ void truncate_pagecache(struct inode *inode, loff_t old, loff_t new) | |||
541 | EXPORT_SYMBOL(truncate_pagecache); | 541 | EXPORT_SYMBOL(truncate_pagecache); |
542 | 542 | ||
543 | /** | 543 | /** |
544 | * truncate_setsize - update inode and pagecache for a new file size | ||
545 | * @inode: inode | ||
546 | * @newsize: new file size | ||
547 | * | ||
548 | * truncate_setsize updastes i_size update and performs pagecache | ||
549 | * truncation (if necessary) for a file size updates. It will be | ||
550 | * typically be called from the filesystem's setattr function when | ||
551 | * ATTR_SIZE is passed in. | ||
552 | * | ||
553 | * Must be called with inode_mutex held and after all filesystem | ||
554 | * specific block truncation has been performed. | ||
555 | */ | ||
556 | void truncate_setsize(struct inode *inode, loff_t newsize) | ||
557 | { | ||
558 | loff_t oldsize; | ||
559 | |||
560 | oldsize = inode->i_size; | ||
561 | i_size_write(inode, newsize); | ||
562 | |||
563 | truncate_pagecache(inode, oldsize, newsize); | ||
564 | } | ||
565 | EXPORT_SYMBOL(truncate_setsize); | ||
566 | |||
567 | /** | ||
544 | * vmtruncate - unmap mappings "freed" by truncate() syscall | 568 | * vmtruncate - unmap mappings "freed" by truncate() syscall |
545 | * @inode: inode of the file used | 569 | * @inode: inode of the file used |
546 | * @offset: file offset to start truncating | 570 | * @offset: file offset to start truncating |
547 | * | 571 | * |
548 | * NOTE! We have to be ready to update the memory sharing | 572 | * This function is deprecated and truncate_setsize or truncate_pagecache |
549 | * between the file and the memory map for a potential last | 573 | * should be used instead, together with filesystem specific block truncation. |
550 | * incomplete page. Ugly, but necessary. | ||
551 | * | ||
552 | * This function is deprecated and simple_setsize or truncate_pagecache | ||
553 | * should be used instead. | ||
554 | */ | 574 | */ |
555 | int vmtruncate(struct inode *inode, loff_t offset) | 575 | int vmtruncate(struct inode *inode, loff_t offset) |
556 | { | 576 | { |
557 | int error; | 577 | int error; |
558 | 578 | ||
559 | error = simple_setsize(inode, offset); | 579 | error = inode_newsize_ok(inode, offset); |
560 | if (error) | 580 | if (error) |
561 | return error; | 581 | return error; |
562 | 582 | ||
583 | truncate_setsize(inode, offset); | ||
563 | if (inode->i_op->truncate) | 584 | if (inode->i_op->truncate) |
564 | inode->i_op->truncate(inode); | 585 | inode->i_op->truncate(inode); |
565 | 586 | return 0; | |
566 | return error; | ||
567 | } | 587 | } |
568 | EXPORT_SYMBOL(vmtruncate); | 588 | EXPORT_SYMBOL(vmtruncate); |