LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Dave McCracken <dave.mccracken@oracle.com> To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org> Cc: Adam Litke <agl@us.ibm.com>, Dave McCracken <dave.mccracken@oracle.com> Subject: [PATCH 1/1] Enable fully functional truncate for hugetlbfs Date: Mon, 12 Feb 2007 08:28:02 -0600 [thread overview] Message-ID: <20070212142802.15738.80487.sendpatchset@wildcat.int.mccr.org> (raw) This patch enables the full functionality of truncate for hugetlbfs files. Truncate was originally limited to reducing the file size because page faults were not supported for hugetlbfs. Now that page faults have been implemented it is now possible to fully support truncate. Signed-off-by: Dave McCracken <dave.mccracken@oracle.com> --- inode.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) --- 2.6.20/./fs/hugetlbfs/inode.c 2007-02-04 12:44:54.000000000 -0600 +++ 2.6.20-htrunc/./fs/hugetlbfs/inode.c 2007-02-05 13:02:00.000000000 -0600 @@ -298,9 +298,10 @@ static int hugetlb_vmtruncate(struct ino { pgoff_t pgoff; struct address_space *mapping = inode->i_mapping; + unsigned long limit; if (offset > inode->i_size) - return -EINVAL; + goto do_expand; BUG_ON(offset & ~HPAGE_MASK); pgoff = offset >> PAGE_SHIFT; @@ -312,6 +313,24 @@ static int hugetlb_vmtruncate(struct ino spin_unlock(&mapping->i_mmap_lock); truncate_hugepages(inode, offset); return 0; + +do_expand: + limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; + if (limit != RLIM_INFINITY && offset > limit) + goto out_sig; + if (offset > inode->i_sb->s_maxbytes) + goto out_big; + if (hugetlb_reserve_pages(inode, inode->i_size >> HPAGE_SHIFT, + offset >> HPAGE_SHIFT)) + goto out_mem; + i_size_write(inode, offset); + return 0; +out_sig: + send_sig(SIGXFSZ, current, 0); +out_big: + return -EFBIG; +out_mem: + return -ENOMEM; } static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
next reply other threads:[~2007-02-12 14:30 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-02-12 14:28 Dave McCracken [this message] 2007-02-12 22:14 ` [PATCH 1/1] Enable fully functional truncate for hugetlbfs Ken Chen
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20070212142802.15738.80487.sendpatchset@wildcat.int.mccr.org \ --to=dave.mccracken@oracle.com \ --cc=agl@us.ibm.com \ --cc=akpm@linux-foundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).