Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[pandora-kernel.git] / ipc / shm.c
index 4fefbad..242c3f6 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -77,7 +77,7 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
 #endif
 
-static void __ipc_init __shm_init_ns(struct ipc_namespace *ns, struct ipc_ids *ids)
+static void __shm_init_ns(struct ipc_namespace *ns, struct ipc_ids *ids)
 {
        ns->ids[IPC_SHM_IDS] = ids;
        ns->shm_ctlmax = SHMMAX;
@@ -98,7 +98,6 @@ static void do_shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *shp)
                shm_destroy(ns, shp);
 }
 
-#ifdef CONFIG_IPC_NS
 int shm_init_ns(struct ipc_namespace *ns)
 {
        struct ipc_ids *ids;
@@ -130,7 +129,6 @@ void shm_exit_ns(struct ipc_namespace *ns)
        kfree(ns->ids[IPC_SHM_IDS]);
        ns->ids[IPC_SHM_IDS] = NULL;
 }
-#endif
 
 void __init shm_init (void)
 {
@@ -254,8 +252,10 @@ struct mempolicy *shm_get_policy(struct vm_area_struct *vma, unsigned long addr)
 
        if (sfd->vm_ops->get_policy)
                pol = sfd->vm_ops->get_policy(vma, addr);
-       else
+       else if (vma->vm_policy)
                pol = vma->vm_policy;
+       else
+               pol = current->mempolicy;
        return pol;
 }
 #endif
@@ -364,9 +364,10 @@ static int newseg (struct ipc_namespace *ns, key_t key, int shmflg, size_t size)
                return error;
        }
 
+       sprintf (name, "SYSV%08x", key);
        if (shmflg & SHM_HUGETLB) {
-               /* hugetlb_zero_setup takes care of mlock user accounting */
-               file = hugetlb_zero_setup(size);
+               /* hugetlb_file_setup takes care of mlock user accounting */
+               file = hugetlb_file_setup(name, size);
                shp->mlock_user = current->user;
        } else {
                int acctflag = VM_ACCOUNT;
@@ -377,7 +378,6 @@ static int newseg (struct ipc_namespace *ns, key_t key, int shmflg, size_t size)
                if  ((shmflg & SHM_NORESERVE) &&
                                sysctl_overcommit_memory != OVERCOMMIT_NEVER)
                        acctflag = 0;
-               sprintf (name, "SYSV%08x", key);
                file = shmem_file_setup(name, size, acctflag);
        }
        error = PTR_ERR(file);
@@ -397,6 +397,11 @@ static int newseg (struct ipc_namespace *ns, key_t key, int shmflg, size_t size)
        shp->shm_nattch = 0;
        shp->id = shm_buildid(ns, id, shp->shm_perm.seq);
        shp->shm_file = file;
+       /*
+        * shmid gets reported as "inode#" in /proc/pid/maps.
+        * proc-ps tools use this. Changing this will break them.
+        */
+       file->f_dentry->d_inode->i_ino = shp->id;
 
        ns->shm_tot += numpages;
        shm_unlock(shp);