Add a mount option page_size= to hugetlbfs.
The s_blocksize_bits in hugetlb super block will indicate the huge page size which attached
to this fs.
Signed-off-by: Zou Nan hai <[email protected]>
diff -Nraup a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
--- a/fs/hugetlbfs/inode.c 2006-04-11 08:51:59.000000000 +0800
+++ b/fs/hugetlbfs/inode.c 2006-04-11 10:55:49.000000000 +0800
@@ -63,6 +63,14 @@ static int hugetlbfs_file_mmap(struct fi
loff_t len, vma_len;
int ret;
+#ifdef ARCH_HAS_VARIABLE_HUGEPAGE_SIZE
+ struct super_block *sb = inode->i_sb;
+ unsigned long hpage_shift = sb->s_blocksize_bits;
+
+ if (hpage_shift != vma->vm_mm->hugepage_shift)
+ return -EINVAL;
+#endif
+
if (vma->vm_pgoff & (HPAGE_SIZE / PAGE_SIZE - 1))
return -EINVAL;
@@ -632,7 +640,17 @@ hugetlbfs_parse_options(char *options, s
size &= HPAGE_MASK;
pconfig->nr_blocks = (size >> HPAGE_SHIFT);
value = rest;
- } else if (!strcmp(opt,"nr_inodes")) {
+ }
+#ifdef ARCH_HAS_VARIABLE_HUGEPAGE_SIZE
+ else if (!strcmp(opt, "page_size")) {
+ unsigned long long size = memparse(value, &rest);
+ if (!is_valid_hpage_size(size))
+ return -EINVAL;
+ pconfig->page_shift = __ffs(size);
+ value = rest;
+ }
+#endif
+ else if (!strcmp(opt,"nr_inodes")) {
pconfig->nr_inodes = memparse(value, &rest);
value = rest;
} else
@@ -658,6 +676,7 @@ hugetlbfs_fill_super(struct super_block
config.uid = current->fsuid;
config.gid = current->fsgid;
config.mode = 0755;
+ config.page_shift = HPAGE_SHIFT;
ret = hugetlbfs_parse_options(data, &config);
if (ret)
@@ -673,8 +692,8 @@ hugetlbfs_fill_super(struct super_block
sbinfo->max_inodes = config.nr_inodes;
sbinfo->free_inodes = config.nr_inodes;
sb->s_maxbytes = MAX_LFS_FILESIZE;
- sb->s_blocksize = HPAGE_SIZE;
- sb->s_blocksize_bits = HPAGE_SHIFT;
+ sb->s_blocksize = 1UL << config.page_shift;
+ sb->s_blocksize_bits = config.page_shift;
sb->s_magic = HUGETLBFS_MAGIC;
sb->s_op = &hugetlbfs_ops;
sb->s_time_gran = 1;
diff -Nraup a/include/linux/hugetlb.h b/include/linux/hugetlb.h
--- a/include/linux/hugetlb.h 2006-04-11 08:52:00.000000000 +0800
+++ b/include/linux/hugetlb.h 2006-04-11 10:51:41.000000000 +0800
@@ -124,6 +124,7 @@ struct hugetlbfs_config {
uid_t uid;
gid_t gid;
umode_t mode;
+ int page_shift;
long nr_blocks;
long nr_inodes;
};
-
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]