Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 258955
b: refs/heads/master
c: 8a549be
h: refs/heads/master
i:
  258953: 558029f
  258951: 0ff37a2
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Jul 26, 2011
1 parent 7493d3d commit ad29cd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 85821aab39b3403a8b5731812a930b78684d1642
refs/heads/master: 8a549bea51138be2126a2cc6aabe8f17ef66b79b
31 changes: 17 additions & 14 deletions trunk/mm/truncate.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
/**
* truncate_pagecache - unmap and remove pagecache that has been truncated
* @inode: inode
* @old: old file offset
* @new: new file offset
* @oldsize: old file size
* @newsize: new file size
*
* inode's new i_size must already be written before truncate_pagecache
* is called.
Expand All @@ -544,9 +544,10 @@ EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
* situations such as writepage being called for a page that has already
* had its underlying blocks deallocated.
*/
void truncate_pagecache(struct inode *inode, loff_t old, loff_t new)
void truncate_pagecache(struct inode *inode, loff_t oldsize, loff_t newsize)
{
struct address_space *mapping = inode->i_mapping;
loff_t holebegin = round_up(newsize, PAGE_SIZE);

/*
* unmap_mapping_range is called twice, first simply for
Expand All @@ -557,9 +558,9 @@ void truncate_pagecache(struct inode *inode, loff_t old, loff_t new)
* truncate_inode_pages finishes, hence the second
* unmap_mapping_range call must be made for correctness.
*/
unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
truncate_inode_pages(mapping, new);
unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
unmap_mapping_range(mapping, holebegin, 0, 1);
truncate_inode_pages(mapping, newsize);
unmap_mapping_range(mapping, holebegin, 0, 1);
}
EXPORT_SYMBOL(truncate_pagecache);

Expand Down Expand Up @@ -589,29 +590,31 @@ EXPORT_SYMBOL(truncate_setsize);
/**
* vmtruncate - unmap mappings "freed" by truncate() syscall
* @inode: inode of the file used
* @offset: file offset to start truncating
* @newsize: file offset to start truncating
*
* This function is deprecated and truncate_setsize or truncate_pagecache
* should be used instead, together with filesystem specific block truncation.
*/
int vmtruncate(struct inode *inode, loff_t offset)
int vmtruncate(struct inode *inode, loff_t newsize)
{
int error;

error = inode_newsize_ok(inode, offset);
error = inode_newsize_ok(inode, newsize);
if (error)
return error;

truncate_setsize(inode, offset);
truncate_setsize(inode, newsize);
if (inode->i_op->truncate)
inode->i_op->truncate(inode);
return 0;
}
EXPORT_SYMBOL(vmtruncate);

int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
int vmtruncate_range(struct inode *inode, loff_t lstart, loff_t lend)
{
struct address_space *mapping = inode->i_mapping;
loff_t holebegin = round_up(lstart, PAGE_SIZE);
loff_t holelen = 1 + lend - holebegin;

/*
* If the underlying filesystem is not going to provide
Expand All @@ -623,10 +626,10 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)

mutex_lock(&inode->i_mutex);
inode_dio_wait(inode);
unmap_mapping_range(mapping, offset, (end - offset), 1);
inode->i_op->truncate_range(inode, offset, end);
unmap_mapping_range(mapping, holebegin, holelen, 1);
inode->i_op->truncate_range(inode, lstart, lend);
/* unmap again to remove racily COWed private pages */
unmap_mapping_range(mapping, offset, (end - offset), 1);
unmap_mapping_range(mapping, holebegin, holelen, 1);
mutex_unlock(&inode->i_mutex);

return 0;
Expand Down

0 comments on commit ad29cd4

Please sign in to comment.