RE: [PATCH] ftruncate on huge page couldn't extend hugetlb file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Zhang, Yanmin wrote on Tuesday, March 07, 2006 10:54 PM
> From: Zhang Yanmin <[email protected]>
> 
> Currently, ftruncate on hugetlb files couldn't extend them. My patch
enables it.
> 
> This patch is against 2.6.16-rc5-mm3 and on the top of the patch which
> implements mmap on zero-length hugetlb files with PROT_NONE.

Reservation should be already done at the mmap time.
Like this?


Signed-off-by: Ken Chen <[email protected]>

--- linux-2.6.15/fs/hugetlbfs/inode.c.orig	2006-03-08
11:39:49.782708398 -0800
+++ linux-2.6.15/fs/hugetlbfs/inode.c	2006-03-08 11:51:04.382309509
-0800
@@ -337,20 +337,18 @@ hugetlb_vmtruncate_list(struct prio_tree
 	}
 }
 
-/*
- * Expanding truncates are not allowed.
- */
 static int hugetlb_vmtruncate(struct inode *inode, loff_t offset)
 {
 	unsigned long pgoff;
 	struct address_space *mapping = inode->i_mapping;
 
-	if (offset > inode->i_size)
-		return -EINVAL;
-
 	BUG_ON(offset & ~HPAGE_MASK);
 	pgoff = offset >> HPAGE_SHIFT;
 
+	if (offset > inode->i_size) {
+		inode->i_size = offset;
+		return 0;
+	}
 	inode->i_size = offset;
 	spin_lock(&mapping->i_mmap_lock);
 	if (!prio_tree_empty(&mapping->i_mmap))
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux