Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164482
b: refs/heads/master
c: 6bfde05
h: refs/heads/master
v: v3
  • Loading branch information
Eric B Munson authored and Linus Torvalds committed Sep 22, 2009
1 parent 0d515b0 commit a9026cc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f8dbf0a7a4c5d98e8b70da9f7f4f6a89f3b7a7bb
refs/heads/master: 6bfde05bf5c9682e255c6a2c669dc80f91af6296
21 changes: 17 additions & 4 deletions trunk/fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,13 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
INIT_LIST_HEAD(&inode->i_mapping->private_list);
info = HUGETLBFS_I(inode);
/*
* The policy is initialized here even if we are creating a
* private inode because initialization simply creates an
* an empty rb tree and calls spin_lock_init(), later when we
* call mpol_free_shared_policy() it will just return because
* the rb tree will still be empty.
*/
mpol_shared_policy_init(&info->policy, NULL);
switch (mode & S_IFMT) {
default:
Expand Down Expand Up @@ -931,13 +938,19 @@ static struct file_system_type hugetlbfs_fs_type = {

static struct vfsmount *hugetlbfs_vfsmount;

static int can_do_hugetlb_shm(void)
static int can_do_hugetlb_shm(int creat_flags)
{
return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group);
if (creat_flags != HUGETLB_SHMFS_INODE)
return 0;
if (capable(CAP_IPC_LOCK))
return 1;
if (in_group_p(sysctl_hugetlb_shm_group))
return 1;
return 0;
}

struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
struct user_struct **user)
struct user_struct **user, int creat_flags)
{
int error = -ENOMEM;
struct file *file;
Expand All @@ -949,7 +962,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
if (!hugetlbfs_vfsmount)
return ERR_PTR(-ENOENT);

if (!can_do_hugetlb_shm()) {
if (!can_do_hugetlb_shm(creat_flags)) {
*user = current_user();
if (user_shm_lock(size, *user)) {
WARN_ONCE(1,
Expand Down
12 changes: 10 additions & 2 deletions trunk/include/linux/hugetlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ static inline void hugetlb_report_meminfo(struct seq_file *m)

#endif /* !CONFIG_HUGETLB_PAGE */

enum {
/*
* The file will be used as an shm file so shmfs accounting rules
* apply
*/
HUGETLB_SHMFS_INODE = 1,
};

#ifdef CONFIG_HUGETLBFS
struct hugetlbfs_config {
uid_t uid;
Expand Down Expand Up @@ -150,7 +158,7 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
extern const struct file_operations hugetlbfs_file_operations;
extern struct vm_operations_struct hugetlb_vm_ops;
struct file *hugetlb_file_setup(const char *name, size_t size, int acct,
struct user_struct **user);
struct user_struct **user, int creat_flags);
int hugetlb_get_quota(struct address_space *mapping, long delta);
void hugetlb_put_quota(struct address_space *mapping, long delta);

Expand All @@ -172,7 +180,7 @@ static inline void set_file_hugepages(struct file *file)

#define is_file_hugepages(file) 0
#define set_file_hugepages(file) BUG()
#define hugetlb_file_setup(name,size,acct,user) ERR_PTR(-ENOSYS)
#define hugetlb_file_setup(name,size,acct,user,creat) ERR_PTR(-ENOSYS)

#endif /* !CONFIG_HUGETLBFS */

Expand Down
2 changes: 1 addition & 1 deletion trunk/ipc/shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
if (shmflg & SHM_NORESERVE)
acctflag = VM_NORESERVE;
file = hugetlb_file_setup(name, size, acctflag,
&shp->mlock_user);
&shp->mlock_user, HUGETLB_SHMFS_INODE);
} else {
/*
* Do not allow no accounting for OVERCOMMIT_NEVER, even
Expand Down

0 comments on commit a9026cc

Please sign in to comment.