mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: David Gibson <david@gibson.dropbear.id.au>,
	"Chen, Kenneth W" <kenneth.w.chen@intel.com>
Subject: [PATCH] ftruncate on huge page couldn't extend hugetlb file
Date: Wed, 08 Mar 2006 11:24:38 +0800	[thread overview]
Message-ID: <1141788278.29825.89.camel@ymzhang-perf.sh.intel.com> (raw)
In-Reply-To: <1141787660.29825.83.camel@ymzhang-perf.sh.intel.com>

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 18:50:40.000000000 +0800
@@ -308,18 +308,22 @@ 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;
 }
 



  reply	other threads:[~2006-03-08  3:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-06  6:21 [PATCH] hugetlb_no_page might break hugetlb quota Zhang, Yanmin
2006-03-06  8:15 ` Chen, Kenneth W
2006-03-06  9:06   ` Zhang, Yanmin
2006-03-08  3:14     ` Zhang, Yanmin
2006-03-08  3:24       ` Zhang, Yanmin [this message]
     [not found]         ` <20060307222148.76e5dc45.akpm@osdl.org>
2006-03-08  6:54           ` [PATCH] ftruncate on huge page couldn't extend hugetlb file Zhang, Yanmin
2006-03-08 18:28         ` Chen, Kenneth W
2006-03-08 23:58           ` David Gibson
2006-03-09  0:12             ` Chen, Kenneth W
2006-03-09  0:22               ` 'David Gibson'
2006-03-09  0:33                 ` Chen, Kenneth W
2006-03-09  1:03                   ` 'David Gibson'
2006-03-08 19:03 Chen, Kenneth W

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=1141788278.29825.89.camel@ymzhang-perf.sh.intel.com \
    --to=yanmin_zhang@linux.intel.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=kenneth.w.chen@intel.com \
    --cc=linux-kernel@vger.kernel.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: link
Be 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

all inboxes | Powered by JetHome®