lkml.org 
[lkml]   [2006]   [Mar]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] ftruncate on huge page couldn't extend hugetlb file
From
Date
On Wed, 2006-03-08 at 14:21, Andrew Morton wrote:
> "Zhang, Yanmin" <yanmin_zhang@linux.intel.com> wrote:
> >
> > - if (!prio_tree_empty(&mapping->i_mmap))
> > - hugetlb_vmtruncate_list(&mapping->i_mmap, pgoff);
> > - spin_unlock(&mapping->i_mmap_lock);
> > - truncate_hugepages(inode, offset);
> > + if (offset > inode->i_size) {
>
> whitespace is broken here.
Sorry for the stupid problem.


> } else {
>
> > +
> > + inode->i_size = offset;
>
> i_size_write(), unless i_sem is held. I guess it is, so OK.
Yes.

>
> > + spin_lock(&mapping->i_mmap_lock);
> > + if (!prio_tree_empty(&mapping->i_mmap))
> > + hugetlb_vmtruncate_list(&mapping->i_mmap, pgoff);
> > + spin_unlock(&mapping->i_mmap_lock);
> > + truncate_hugepages(inode, offset);
> > + }
> > return 0;

Here is the new patch.

From: Zhang Yanmin <yanmin.zhang@intel.com>

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.

Thanks for Ken's good idea.

Signed-off-by: Zhang Yanmin <yanmin.zhang@intel.com>

---

diff -Nraup linux-2.6.16-rc5-mm3_huge_check/fs/hugetlbfs/inode.c linux-2.6.16-rc5-mm3_truncate/fs/hugetlbfs/inode.c
--- linux-2.6.16-rc5-mm3_huge_check/fs/hugetlbfs/inode.c 2006-03-08 18:17:15.000000000 +0800
+++ linux-2.6.16-rc5-mm3_truncate/fs/hugetlbfs/inode.c 2006-03-08 22:43:54.000000000 +0800
@@ -308,18 +308,20 @@ static int hugetlb_vmtruncate(struct ino
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;
-
- inode->i_size = offset;
- spin_lock(&mapping->i_mmap_lock);
- if (!prio_tree_empty(&mapping->i_mmap))
- hugetlb_vmtruncate_list(&mapping->i_mmap, pgoff);
- spin_unlock(&mapping->i_mmap_lock);
- truncate_hugepages(inode, offset);
+ if (offset > inode->i_size) {
+ if (hugetlb_extend_reservation(HUGETLBFS_I(inode), pgoff) != 0)
+ return -ENOMEM;
+ inode->i_size = offset;
+ } else {
+ inode->i_size = offset;
+ spin_lock(&mapping->i_mmap_lock);
+ if (!prio_tree_empty(&mapping->i_mmap))
+ hugetlb_vmtruncate_list(&mapping->i_mmap, pgoff);
+ spin_unlock(&mapping->i_mmap_lock);
+ truncate_hugepages(inode, offset);
+ }
return 0;
}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-03-08 08:00    [W:0.072 / U:2.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site