]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
hugetlb: allow extending ftruncate on hugetlbfs
authorKen Chen <kenchen@google.com>
Tue, 16 Oct 2007 08:26:21 +0000 (01:26 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 16 Oct 2007 16:43:02 +0000 (09:43 -0700)
For historical reason, expanding ftruncate that increases file size on
hugetlbfs is not allowed due to pages were pre-faulted and lack of fault
handler.  Now that we have demand faulting on hugetlb since 2.6.15, there
is no reason to hold back that limitation.

This will make hugetlbfs behave more like a normal fs.  I'm writing a user
level code that uses hugetlbfs but will fall back to tmpfs if there are no
hugetlb page available in the system.  Having hugetlbfs specific ftruncate
behavior is a bit quirky and I would like to remove that artificial

Signed-off-by: <kenchen@google.com>
Acked-by: Wiliam Irwin <wli@holomorphy.com>
Cc: Adam Litke <agl@us.ibm.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

index 70fbb29fb202bb38a4e230f42f68792e83db7292..8f8e13385e961809486e401bd17300c4f9a452dc 100644 (file)
@@ -322,21 +322,15 @@ hugetlb_vmtruncate_list(struct prio_tree_root *root, pgoff_t pgoff)
- * Expanding truncates are not allowed.
- */
 static int hugetlb_vmtruncate(struct inode *inode, loff_t offset)
        pgoff_t pgoff;
        struct address_space *mapping = inode->i_mapping;
-       if (offset > inode->i_size)
-               return -EINVAL;
        BUG_ON(offset & ~HPAGE_MASK);
        pgoff = offset >> PAGE_SHIFT;
-       inode->i_size = offset;
+       i_size_write(inode, offset);
        if (!prio_tree_empty(&mapping->i_mmap))
                hugetlb_vmtruncate_list(&mapping->i_mmap, pgoff);