Hugetlb FS quota bug fix
Here is a bug fix patch relative to latest Bjorn's 2.4 ia64 kernel tree. Mainly sync up hugetlbfs code w.r.t latest 2.6.
Hugetlb file system quota was incorrectly taken on every mmap even for the case that huge pages has been already allocated on the file inode. This results in taxing the same hugepage multiple times and causing mmap to fail on existing file when quota mistakenly runs out. This patch also fixes file size to account holes.
Bjorn, since you are still carrying hugetlbfs for ia64, would you please merge this? (bug fix for 2.6 has been taken care already) Thanks.
- Ken
arch/ia64/mm/hugetlbpage.c +6 -5
@@ -262,18 +262,19 @@ int hugetlb_prefault(struct address_spac + (vma->vm_pgoff >> (HPAGE_SHIFT -PAGE_SHIFT )); page =find_get_page (mapping, idx);if (!page) { -loff_t i_size; +/* charge the fs quota first */ +if (hugetlb_get_quota (mapping)) { + ret = -ENOMEM ; + goto out; + } page =alloc_hugetlb_page ();if (!page) { +hugetlb_put_quota (mapping); ret = -ENOMEM ; goto out; }add_to_page_cache (page, mapping, idx);unlock_page (page); - i_size = (loff_t)(idx +1 ) *HPAGE_SIZE ; -if (i_size > inode->i_size) - inode->i_size = i_size; - }set_huge_pte (mm, vma, page, pte, vma->vm_flags &VM_WRITE ); }
fs/hugetlbfs/inode.c +36 -27
102 lines not on this page · raw message
include/linux/hugetlb.h +4 -0
@@ -74,6 +74,8 @@ static inline struct hugetlbfs_sb_info *extern struct file_operations hugetlbfs_file_operations;extern struct vm_operations_struct hugetlb_vm_ops;struct file *hugetlb_zero_setup (size_t ); +int hugetlb_get_quota (struct address_space *mapping); +void hugetlb_put_quota (struct address_space *mapping);static inline int is_file_hugepages (struct file *file) {
@@ -89,6 +91,8 @@ static inline void set_file_hugepages(st#define is_file_hugepages (file) 0#define set_file_hugepages (file) BUG()#define hugetlb_zero_setup (size) ERR_PTR(-ENOSYS) +#define hugetlb_get_quota (mapping) 0 +#define hugetlb_put_quota (mapping) 0#endif /* !CONFIG_HUGETLBFS */