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 7:25 PM
> 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.

> -
> -	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;
>  }
 
Hmm??  I don't think you need to extend the reservation when extending
hugetlb file via ftruncate.  You don't have any vma that pass beyond
current size.  So making a reservation is a wrong thing to do here.

- Ken

-
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