aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hugetlbfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hugetlbfs/inode.c')
-rw-r--r--fs/hugetlbfs/inode.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 9b800d97a687..c1462d43e721 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -26,7 +26,6 @@
26#include <linux/pagevec.h> 26#include <linux/pagevec.h>
27#include <linux/parser.h> 27#include <linux/parser.h>
28#include <linux/mman.h> 28#include <linux/mman.h>
29#include <linux/quotaops.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
31#include <linux/dnotify.h> 30#include <linux/dnotify.h>
32#include <linux/statfs.h> 31#include <linux/statfs.h>
@@ -313,16 +312,6 @@ out:
313 return retval; 312 return retval;
314} 313}
315 314
316/*
317 * Read a page. Again trivial. If it didn't already exist
318 * in the page cache, it is zero-filled.
319 */
320static int hugetlbfs_readpage(struct file *file, struct page * page)
321{
322 unlock_page(page);
323 return -EINVAL;
324}
325
326static int hugetlbfs_write_begin(struct file *file, 315static int hugetlbfs_write_begin(struct file *file,
327 struct address_space *mapping, 316 struct address_space *mapping,
328 loff_t pos, unsigned len, unsigned flags, 317 loff_t pos, unsigned len, unsigned flags,
@@ -702,7 +691,6 @@ static void hugetlbfs_destroy_inode(struct inode *inode)
702} 691}
703 692
704static const struct address_space_operations hugetlbfs_aops = { 693static const struct address_space_operations hugetlbfs_aops = {
705 .readpage = hugetlbfs_readpage,
706 .write_begin = hugetlbfs_write_begin, 694 .write_begin = hugetlbfs_write_begin,
707 .write_end = hugetlbfs_write_end, 695 .write_end = hugetlbfs_write_end,
708 .set_page_dirty = hugetlbfs_set_page_dirty, 696 .set_page_dirty = hugetlbfs_set_page_dirty,
@@ -842,7 +830,7 @@ hugetlbfs_parse_options(char *options, struct hugetlbfs_config *pconfig)
842bad_val: 830bad_val:
843 printk(KERN_ERR "hugetlbfs: Bad value '%s' for mount option '%s'\n", 831 printk(KERN_ERR "hugetlbfs: Bad value '%s' for mount option '%s'\n",
844 args[0].from, p); 832 args[0].from, p);
845 return 1; 833 return -EINVAL;
846} 834}
847 835
848static int 836static int
@@ -943,14 +931,13 @@ static struct vfsmount *hugetlbfs_vfsmount;
943 931
944static int can_do_hugetlb_shm(void) 932static int can_do_hugetlb_shm(void)
945{ 933{
946 return likely(capable(CAP_IPC_LOCK) || 934 return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group);
947 in_group_p(sysctl_hugetlb_shm_group) ||
948 can_do_mlock());
949} 935}
950 936
951struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) 937struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
952{ 938{
953 int error = -ENOMEM; 939 int error = -ENOMEM;
940 int unlock_shm = 0;
954 struct file *file; 941 struct file *file;
955 struct inode *inode; 942 struct inode *inode;
956 struct dentry *dentry, *root; 943 struct dentry *dentry, *root;
@@ -960,11 +947,14 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
960 if (!hugetlbfs_vfsmount) 947 if (!hugetlbfs_vfsmount)
961 return ERR_PTR(-ENOENT); 948 return ERR_PTR(-ENOENT);
962 949
963 if (!can_do_hugetlb_shm()) 950 if (!can_do_hugetlb_shm()) {
964 return ERR_PTR(-EPERM); 951 if (user_shm_lock(size, user)) {
965 952 unlock_shm = 1;
966 if (!user_shm_lock(size, user)) 953 WARN_ONCE(1,
967 return ERR_PTR(-ENOMEM); 954 "Using mlock ulimits for SHM_HUGETLB deprecated\n");
955 } else
956 return ERR_PTR(-EPERM);
957 }
968 958
969 root = hugetlbfs_vfsmount->mnt_root; 959 root = hugetlbfs_vfsmount->mnt_root;
970 quick_string.name = name; 960 quick_string.name = name;
@@ -1004,7 +994,8 @@ out_inode:
1004out_dentry: 994out_dentry:
1005 dput(dentry); 995 dput(dentry);
1006out_shm_unlock: 996out_shm_unlock:
1007 user_shm_unlock(size, user); 997 if (unlock_shm)
998 user_shm_unlock(size, user);
1008 return ERR_PTR(error); 999 return ERR_PTR(error);
1009} 1000}
1010 1001