This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / ipc / shm.c
index f763a02..598f1c8 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -117,9 +117,6 @@ static void shm_destroy (struct shmid_kernel *shp)
        shm_unlock(shp);
        if (!is_file_hugepages(shp->shm_file))
                shmem_lock(shp->shm_file, 0, shp->mlock_user);
-       else
-               user_shm_unlock(shp->shm_file->f_dentry->d_inode->i_size,
-                                               shp->mlock_user);
        fput (shp->shm_file);
        security_shm_free(shp);
        ipc_rcu_free(shp, sizeof(struct shmid_kernel));
@@ -196,7 +193,6 @@ static int newseg (key_t key, int shmflg, size_t size)
        shp->shm_perm.key = key;
        shp->shm_perm.xid = current->xid;
        shp->shm_flags = (shmflg & S_IRWXUGO);
-       shp->mlock_user = NULL;
 
        shp->shm_perm.security = NULL;
        error = security_shm_alloc(shp);
@@ -205,11 +201,9 @@ static int newseg (key_t key, int shmflg, size_t size)
                return error;
        }
 
-       if (shmflg & SHM_HUGETLB) {
-               /* hugetlb_zero_setup takes care of mlock user accounting */
+       if (shmflg & SHM_HUGETLB)
                file = hugetlb_zero_setup(size);
-               shp->mlock_user = current->user;
-       } else {
+       else {
                sprintf (name, "SYSV%08x", key);
                file = shmem_file_setup(name, size, VM_ACCOUNT);
        }
@@ -230,6 +224,7 @@ static int newseg (key_t key, int shmflg, size_t size)
        shp->shm_nattch = 0;
        shp->id = shm_buildid(id,shp->shm_perm.seq);
        shp->shm_file = file;
+       shp->mlock_user = NULL;
        file->f_dentry->d_inode->i_ino = shp->id;
        if (shmflg & SHM_HUGETLB)
                set_file_hugepages(file);
@@ -514,7 +509,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
        case SHM_UNLOCK:
        {
                /* Allow superuser to lock segment in memory */
-               if (!can_do_mlock() && cmd == SHM_LOCK) {
+               if (!can_do_mlock()) {
                        err = -EPERM;
                        goto out;
                }
@@ -532,18 +527,15 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
                        goto out_unlock;
                
                if(cmd==SHM_LOCK) {
-                       struct user_struct * user = current->user;
                        if (!is_file_hugepages(shp->shm_file)) {
-                               err = shmem_lock(shp->shm_file, 1, user);
-                               if (!err) {
+                               err = shmem_lock(shp->shm_file, 1, current->user);
+                               if (!err)
                                        shp->shm_flags |= SHM_LOCKED;
-                                       shp->mlock_user = user;
-                               }
                        }
-               } else if (!is_file_hugepages(shp->shm_file)) {
-                       shmem_lock(shp->shm_file, 0, shp->mlock_user);
+               } else {
+                       if (!is_file_hugepages(shp->shm_file))
+                               shmem_lock(shp->shm_file, 0, shp->mlock_user);
                        shp->shm_flags &= ~SHM_LOCKED;
-                       shp->mlock_user = NULL;
                }
                shm_unlock(shp);
                goto out;