diff options
Diffstat (limited to 'fs/hugetlbfs/inode.c')
| -rw-r--r-- | fs/hugetlbfs/inode.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index e6410d8edd0e..f5b8f329aca6 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
| @@ -34,7 +34,7 @@ | |||
| 34 | #define HUGETLBFS_MAGIC 0x958458f6 | 34 | #define HUGETLBFS_MAGIC 0x958458f6 |
| 35 | 35 | ||
| 36 | static struct super_operations hugetlbfs_ops; | 36 | static struct super_operations hugetlbfs_ops; |
| 37 | static struct address_space_operations hugetlbfs_aops; | 37 | static const struct address_space_operations hugetlbfs_aops; |
| 38 | const struct file_operations hugetlbfs_file_operations; | 38 | const struct file_operations hugetlbfs_file_operations; |
| 39 | static struct inode_operations hugetlbfs_dir_inode_operations; | 39 | static struct inode_operations hugetlbfs_dir_inode_operations; |
| 40 | static struct inode_operations hugetlbfs_inode_operations; | 40 | static struct inode_operations hugetlbfs_inode_operations; |
| @@ -83,8 +83,6 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) | |||
| 83 | 83 | ||
| 84 | ret = -ENOMEM; | 84 | ret = -ENOMEM; |
| 85 | len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); | 85 | len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); |
| 86 | if (!(vma->vm_flags & VM_WRITE) && len > inode->i_size) | ||
| 87 | goto out; | ||
| 88 | 86 | ||
| 89 | if (vma->vm_flags & VM_MAYSHARE && | 87 | if (vma->vm_flags & VM_MAYSHARE && |
| 90 | hugetlb_reserve_pages(inode, vma->vm_pgoff >> (HPAGE_SHIFT-PAGE_SHIFT), | 88 | hugetlb_reserve_pages(inode, vma->vm_pgoff >> (HPAGE_SHIFT-PAGE_SHIFT), |
| @@ -93,7 +91,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) | |||
| 93 | 91 | ||
| 94 | ret = 0; | 92 | ret = 0; |
| 95 | hugetlb_prefault_arch_hook(vma->vm_mm); | 93 | hugetlb_prefault_arch_hook(vma->vm_mm); |
| 96 | if (inode->i_size < len) | 94 | if (vma->vm_flags & VM_WRITE && inode->i_size < len) |
| 97 | inode->i_size = len; | 95 | inode->i_size = len; |
| 98 | out: | 96 | out: |
| 99 | mutex_unlock(&inode->i_mutex); | 97 | mutex_unlock(&inode->i_mutex); |
| @@ -231,7 +229,7 @@ static void hugetlbfs_delete_inode(struct inode *inode) | |||
| 231 | clear_inode(inode); | 229 | clear_inode(inode); |
| 232 | } | 230 | } |
| 233 | 231 | ||
| 234 | static void hugetlbfs_forget_inode(struct inode *inode) | 232 | static void hugetlbfs_forget_inode(struct inode *inode) __releases(inode_lock) |
| 235 | { | 233 | { |
| 236 | struct super_block *sb = inode->i_sb; | 234 | struct super_block *sb = inode->i_sb; |
| 237 | 235 | ||
| @@ -359,7 +357,6 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, | |||
| 359 | inode->i_mode = mode; | 357 | inode->i_mode = mode; |
| 360 | inode->i_uid = uid; | 358 | inode->i_uid = uid; |
| 361 | inode->i_gid = gid; | 359 | inode->i_gid = gid; |
| 362 | inode->i_blksize = HPAGE_SIZE; | ||
| 363 | inode->i_blocks = 0; | 360 | inode->i_blocks = 0; |
| 364 | inode->i_mapping->a_ops = &hugetlbfs_aops; | 361 | inode->i_mapping->a_ops = &hugetlbfs_aops; |
| 365 | inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; | 362 | inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; |
| @@ -547,7 +544,7 @@ static void hugetlbfs_destroy_inode(struct inode *inode) | |||
| 547 | kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode)); | 544 | kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode)); |
| 548 | } | 545 | } |
| 549 | 546 | ||
| 550 | static struct address_space_operations hugetlbfs_aops = { | 547 | static const struct address_space_operations hugetlbfs_aops = { |
| 551 | .readpage = hugetlbfs_readpage, | 548 | .readpage = hugetlbfs_readpage, |
| 552 | .prepare_write = hugetlbfs_prepare_write, | 549 | .prepare_write = hugetlbfs_prepare_write, |
| 553 | .commit_write = hugetlbfs_commit_write, | 550 | .commit_write = hugetlbfs_commit_write, |
