diff options
Diffstat (limited to 'mm/memory.c')
| -rw-r--r-- | mm/memory.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/mm/memory.c b/mm/memory.c index d8dde07a3656..e249088908c4 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
| @@ -1770,9 +1770,32 @@ out_big: | |||
| 1770 | out_busy: | 1770 | out_busy: |
| 1771 | return -ETXTBSY; | 1771 | return -ETXTBSY; |
| 1772 | } | 1772 | } |
| 1773 | |||
| 1774 | EXPORT_SYMBOL(vmtruncate); | 1773 | EXPORT_SYMBOL(vmtruncate); |
| 1775 | 1774 | ||
| 1775 | int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end) | ||
| 1776 | { | ||
| 1777 | struct address_space *mapping = inode->i_mapping; | ||
| 1778 | |||
| 1779 | /* | ||
| 1780 | * If the underlying filesystem is not going to provide | ||
| 1781 | * a way to truncate a range of blocks (punch a hole) - | ||
| 1782 | * we should return failure right now. | ||
| 1783 | */ | ||
| 1784 | if (!inode->i_op || !inode->i_op->truncate_range) | ||
| 1785 | return -ENOSYS; | ||
| 1786 | |||
| 1787 | down(&inode->i_sem); | ||
| 1788 | down_write(&inode->i_alloc_sem); | ||
| 1789 | unmap_mapping_range(mapping, offset, (end - offset), 1); | ||
| 1790 | truncate_inode_pages_range(mapping, offset, end); | ||
| 1791 | inode->i_op->truncate_range(inode, offset, end); | ||
| 1792 | up_write(&inode->i_alloc_sem); | ||
| 1793 | up(&inode->i_sem); | ||
| 1794 | |||
| 1795 | return 0; | ||
| 1796 | } | ||
| 1797 | EXPORT_SYMBOL(vmtruncate_range); | ||
| 1798 | |||
| 1776 | /* | 1799 | /* |
| 1777 | * Primitive swap readahead code. We simply read an aligned block of | 1800 | * Primitive swap readahead code. We simply read an aligned block of |
| 1778 | * (1 << page_cluster) entries in the swap area. This method is chosen | 1801 | * (1 << page_cluster) entries in the swap area. This method is chosen |
