diff options
author | Ravikiran G Thirumalai <kiran@scalex86.org> | 2009-03-31 18:21:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-01 11:59:12 -0400 |
commit | 2584e517320bd48dc8d20e38a2621a2dbe58fade (patch) | |
tree | 3b94b6c4cc10ab16ab106464e8d32e2e77ad8634 /fs/hugetlbfs/inode.c | |
parent | 8a0bdec194c21c8fdef840989d0d7b742bb5d4bc (diff) |
mm: reintroduce and deprecate rlimit based access for SHM_HUGETLB
Allow non root users with sufficient mlock rlimits to be able to allocate
hugetlb backed shm for now. Deprecate this though. This is being
deprecated because the mlock based rlimit checks for SHM_HUGETLB is not
consistent with mmap based huge page allocations.
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Reviewed-by: Mel Gorman <mel@csn.ul.ie>
Cc: William Lee Irwin III <wli@holomorphy.com>
Cc: Adam Litke <agl@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hugetlbfs/inode.c')
-rw-r--r-- | fs/hugetlbfs/inode.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index bc56df8ce001..23a3c76711e0 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -949,6 +949,7 @@ static int can_do_hugetlb_shm(void) | |||
949 | struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) | 949 | struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) |
950 | { | 950 | { |
951 | int error = -ENOMEM; | 951 | int error = -ENOMEM; |
952 | int unlock_shm = 0; | ||
952 | struct file *file; | 953 | struct file *file; |
953 | struct inode *inode; | 954 | struct inode *inode; |
954 | struct dentry *dentry, *root; | 955 | struct dentry *dentry, *root; |
@@ -958,8 +959,14 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) | |||
958 | if (!hugetlbfs_vfsmount) | 959 | if (!hugetlbfs_vfsmount) |
959 | return ERR_PTR(-ENOENT); | 960 | return ERR_PTR(-ENOENT); |
960 | 961 | ||
961 | if (!can_do_hugetlb_shm()) | 962 | if (!can_do_hugetlb_shm()) { |
962 | return ERR_PTR(-EPERM); | 963 | if (user_shm_lock(size, user)) { |
964 | unlock_shm = 1; | ||
965 | WARN_ONCE(1, | ||
966 | "Using mlock ulimits for SHM_HUGETLB deprecated\n"); | ||
967 | } else | ||
968 | return ERR_PTR(-EPERM); | ||
969 | } | ||
963 | 970 | ||
964 | root = hugetlbfs_vfsmount->mnt_root; | 971 | root = hugetlbfs_vfsmount->mnt_root; |
965 | quick_string.name = name; | 972 | quick_string.name = name; |
@@ -999,6 +1006,8 @@ out_inode: | |||
999 | out_dentry: | 1006 | out_dentry: |
1000 | dput(dentry); | 1007 | dput(dentry); |
1001 | out_shm_unlock: | 1008 | out_shm_unlock: |
1009 | if (unlock_shm) | ||
1010 | user_shm_unlock(size, user); | ||
1002 | return ERR_PTR(error); | 1011 | return ERR_PTR(error); |
1003 | } | 1012 | } |
1004 | 1013 | ||