Merge to Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.13-vs2...
authorMarc Fiuczynski <mef@cs.princeton.edu>
Mon, 2 Oct 2006 03:32:22 +0000 (03:32 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Mon, 2 Oct 2006 03:32:22 +0000 (03:32 +0000)
34 files changed:
arch/i386/kernel/traps.c
arch/um/kernel/process_kern.c
arch/v850/kernel/ptrace.c
fs/dquot.c
fs/ext2/inode.c
fs/jfs/jfs_dinode.h
fs/jfs/jfs_dtree.c
fs/jfs/jfs_xtree.c
fs/locks.c
fs/namei.c
fs/namespace.c
fs/ocfs2/inode.c
fs/reiserfs/bitmap.c
include/asm-i386/elf.h
include/linux/namespace.h
include/linux/vserver/namespace_cmd.h
include/linux/vserver/network.h
include/linux/vserver/switch.h
include/net/sock.h
kernel/capability.c
kernel/exit.c
kernel/fork.c
kernel/posix-timers.c
kernel/timer.c
kernel/vserver/context.c
kernel/vserver/cvirt.c
kernel/vserver/dlimit.c
kernel/vserver/legacy.c
kernel/vserver/legacynet.c
kernel/vserver/namespace.c
kernel/vserver/network.c
kernel/vserver/switch.c
mm/fremap.c
net/ipv4/udp.c

index 6dfbd46..0b9d741 100644 (file)
@@ -409,7 +409,8 @@ void die(const char * str, struct pt_regs * regs, long err)
                        printk(KERN_EMERG "EIP: [<%08lx>] ", regs->eip);
                        print_symbol("%s", regs->eip);
                        printk(" SS:ESP %04x:%08lx\n", ss, esp);
-               } else
+               }
+               else
                        regs = NULL;
        } else
                printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
index be504a6..f6a5a50 100644 (file)
@@ -23,7 +23,6 @@
 #include "linux/proc_fs.h"
 #include "linux/ptrace.h"
 #include "linux/random.h"
-
 #include "asm/unistd.h"
 #include "asm/mman.h"
 #include "asm/segment.h"
index 061bd4d..6e2adab 100644 (file)
@@ -117,6 +117,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 {
        int rval;
 
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out;
+
        switch (request) {
                unsigned long val, copied;
 
@@ -137,8 +140,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                        break;
                rval = -EIO;
                goto out;
-       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
-               goto out_tsk;
 
        /* Read/write the word at location ADDR in the registers.  */
        case PTRACE_PEEKUSR:
index e3a6db7..81d87a4 100644 (file)
@@ -458,7 +458,6 @@ restart:
        spin_unlock(&dq_list_lock);
 }
 
-
 int vfs_quota_sync(struct super_block *sb, int type)
 {
        struct list_head *dirty;
@@ -668,6 +667,7 @@ we_slept:
 #ifdef __DQUOT_PARANOIA
        BUG_ON(!dquot->dq_sb);  /* Has somebody invalidated entry under us? */
 #endif
+
        return dquot;
 }
 
index 3590642..c6a0128 100644 (file)
@@ -1356,7 +1356,6 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
                if (error)
                        return error;
        }
-
        error = inode_setattr(inode, iattr);
        if (!error && (iattr->ia_valid & ATTR_MODE))
                error = ext2_acl_chmod(inode);
index 6bfab03..79e486d 100644 (file)
@@ -162,8 +162,8 @@ struct dinode {
 #define JFS_APPEND_FL          0x01000000 /* writes to file may only append */
 #define JFS_IMMUTABLE_FL       0x02000000 /* Immutable file */
 
-#define        JFS_BARRIER_FL          0x04000000 /* Barrier for chroot() */
-#define        JFS_IUNLINK_FL          0x08000000 /* Immutable unlink */
+#define JFS_BARRIER_FL         0x04000000 /* Barrier for chroot() */
+#define JFS_IUNLINK_FL         0x08000000 /* Immutable unlink */
 
 #define JFS_FL_USER_VISIBLE    0x0FF80000
 #define JFS_FL_USER_MODIFIABLE 0x03F80000
@@ -173,4 +173,5 @@ struct dinode {
 #define JFS_IOC_GETFLAGS       _IOR('f', 1, long)
 #define JFS_IOC_SETFLAGS       _IOW('f', 2, long)
 
+
 #endif /*_H_JFS_DINODE */
index 5677e80..d10b0ca 100644 (file)
@@ -935,8 +935,7 @@ int dtInsert(tid_t tid, struct inode *ip,
 static int dtSplitUp(tid_t tid,
          struct inode *ip, struct dtsplit * split, struct btstack * btstack)
 {
-       struct super_block *sb = ip->i_sb;
-       struct jfs_sb_info *sbi = JFS_SBI(sb);
+       struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
        int rc = 0;
        struct metapage *smp;
        dtpage_t *sp;           /* split page */
index 677890c..ef53b85 100644 (file)
@@ -1251,7 +1251,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
        rbn = addressPXD(pxd);
 
        /* Allocate blocks to quota. */
-       if (DQUOT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
+       if (DQUOT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
               rc = -EDQUOT;
               goto clean_up;
        }
index 1aead65..7ec121c 100644 (file)
@@ -293,8 +293,6 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock,
        fl->fl_type = type;
        fl->fl_end = OFFSET_MAX;
 
-       vxd_assert(filp->f_xid == vx_current_xid(),
-               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
        fl->fl_xid = filp->f_xid;
        vx_locks_inc(fl);
        
@@ -483,9 +481,6 @@ static int lease_alloc(struct file *filp, int type, struct file_lock **flp)
                goto out;
 
        fl->fl_xid = vx_current_xid();
-       if (filp)
-               vxd_assert(filp->f_xid == fl->fl_xid,
-                       "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
        vx_locks_inc(fl);
        error = lease_init(filp, type, fl);
        if (error) {
@@ -819,8 +814,6 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request
        struct file_lock **before;
        int error, added = 0;
 
-       vxd_assert(xid == vx_current_xid(),
-               "xid(%d) == current(%d)", xid, vx_current_xid());
        /*
         * We may need two file_lock structures for this operation,
         * so we get them in advance to avoid races.
@@ -1678,8 +1671,6 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
        if (file_lock == NULL)
                return -ENOLCK;
 
-       vxd_assert(filp->f_xid == vx_current_xid(),
-               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
        file_lock->fl_xid = filp->f_xid;
        vx_locks_inc(file_lock);
 
@@ -1826,8 +1817,6 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
        if (file_lock == NULL)
                return -ENOLCK;
 
-       vxd_assert(filp->f_xid == vx_current_xid(),
-               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
        file_lock->fl_xid = filp->f_xid;
        vx_locks_inc(file_lock);
 
index 90a0e37..1819223 100644 (file)
@@ -228,13 +228,20 @@ int generic_permission(struct inode *inode, int mask,
        return -EACCES;
 }
 
-static inline int xid_permission(struct inode *inode, int mask, struct nameidata *nd)
+static inline int vx_barrier(struct inode *inode)
 {
        if (IS_BARRIER(inode) && !vx_check(0, VX_ADMIN)) {
                vxwprintk(1, "xid=%d did hit the barrier.",
                        vx_current_xid());
-               return -EACCES;
+               return 1;
        }
+       return 0;
+}
+
+static inline int xid_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+       if (vx_barrier(inode))
+               return -EACCES;
        if (inode->i_xid == 0)
                return 0;
        if (vx_check(inode->i_xid, VX_ADMIN|VX_WATCH|VX_IDENT))
@@ -426,6 +433,8 @@ static int exec_permission_lite(struct inode *inode,
 {
        umode_t mode = inode->i_mode;
 
+       if (vx_barrier(inode))
+               return -EACCES;
        if (inode->i_op && inode->i_op->permission)
                return -EAGAIN;
 
@@ -2637,7 +2646,6 @@ int vfs_follow_link(struct nameidata *nd, const char *link)
        return __vfs_follow_link(nd, link);
 }
 
-
 /* get the link contents into pagecache */
 static char *page_getlink(struct dentry * dentry, struct page **ppage)
 {
index 9454e3c..03f43da 100644 (file)
@@ -449,17 +449,27 @@ static int show_vfsstat(struct seq_file *m, void *v)
        struct vfsmount *mnt = v;
        int err = 0;
 
-       /* device */
-       if (mnt->mnt_devname) {
-               seq_puts(m, "device ");
-               mangle(m, mnt->mnt_devname);
-       } else
-               seq_puts(m, "no device");
-
-       /* mount point */
-       seq_puts(m, " mounted on ");
-       seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
-       seq_putc(m, ' ');
+       if (vx_flags(VXF_HIDE_MOUNT, 0))
+               return 0;
+       if (!mnt_is_reachable(mnt) && !vx_check(0, VX_WATCH))
+               return 0;
+
+       if (!vx_check(0, VX_ADMIN|VX_WATCH) &&
+               mnt == current->fs->rootmnt) {
+               seq_puts(m, "device /dev/root mounted on / ");
+       } else {
+               /* device */
+               if (mnt->mnt_devname) {
+                       seq_puts(m, "device ");
+                       mangle(m, mnt->mnt_devname);
+               } else
+                       seq_puts(m, "no device");
+
+               /* mount point */
+               seq_puts(m, " mounted on ");
+               seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
+               seq_putc(m, ' ');
+       }
 
        /* file system type */
        seq_puts(m, "with fstype ");
@@ -558,11 +568,15 @@ void release_mounts(struct list_head *head)
        }
 }
 
-static inline void __umount_list(struct vfsmount *mnt,
-       int propagate, struct list_head *kill)
+void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
 {
        struct vfsmount *p;
 
+       for (p = mnt; p; p = next_mnt(p, mnt)) {
+               list_del(&p->mnt_hash);
+               list_add(&p->mnt_hash, kill);
+       }
+
        if (propagate)
                propagate_umount(kill);
 
@@ -578,33 +592,6 @@ static inline void __umount_list(struct vfsmount *mnt,
        }
 }
 
-void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
-{
-       struct vfsmount *p;
-
-       for (p = mnt; p; p = next_mnt(p, mnt)) {
-               list_del(&p->mnt_hash);
-               list_add(&p->mnt_hash, kill);
-               // p->mnt_namespace = NULL;
-       }
-       __umount_list(mnt, propagate, kill);
-}
-
-void umount_unused(struct vfsmount *mnt, struct fs_struct *fs)
-{
-       struct vfsmount *p;
-       LIST_HEAD(kill);
-
-       for (p = mnt; p; p = next_mnt(p, mnt)) {
-               if (p == fs->rootmnt || p == fs->pwdmnt)
-                       continue;
-               list_del(&p->mnt_list);
-               list_add(&p->mnt_list, &kill);
-               p->mnt_namespace = NULL;
-       }
-       __umount_list(mnt, 0, &kill);
-}
-
 static int do_umount(struct vfsmount *mnt, int flags)
 {
        struct super_block *sb = mnt->mnt_sb;
@@ -1422,7 +1409,7 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
        if (flags & MS_NODIRATIME)
                mnt_flags |= MNT_NODIRATIME;
 
-       if (vx_ccaps(VXC_SECURE_MOUNT))
+       if (!capable(CAP_SYS_ADMIN))
                mnt_flags |= MNT_NODEV;
        flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
                   MS_NOATIME | MS_NODIRATIME);
index 230bdcf..327a5b7 100644 (file)
@@ -331,7 +331,6 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
                                  OCFS2_LOCK_TYPE_DATA, inode);
 
        status = 0;
-
 bail:
        mlog_exit(status);
        return status;
index 49cd1aa..3e5f39f 100644 (file)
@@ -1061,7 +1061,6 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
                        if (quota_ret)
                                hint->preallocate = hint->prealloc_size = 0;
                }
-
                /* for unformatted nodes, force large allocations */
                bigalloc = amount_needed;
        }
index f1ce568..ffef1f3 100644 (file)
@@ -72,7 +72,7 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
    the loader.  We need to make sure that it is out of the way of the program
    that it will "exec", and that there is sufficient room for the brk.  */
 
-#define ELF_ET_DYN_BASE                ((TASK_UNMAPPED_BASE) * 2)
+#define ELF_ET_DYN_BASE         (TASK_SIZE / 3 * 2)
 
 /* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
    now struct_user_regs, they are different) */
index 4e234d8..3abc8e3 100644 (file)
@@ -16,7 +16,6 @@ struct namespace {
 extern int copy_namespace(int, struct task_struct *);
 extern void __put_namespace(struct namespace *namespace);
 extern struct namespace *dup_namespace(struct task_struct *, struct fs_struct *);
-extern void umount_unused(struct vfsmount *, struct fs_struct *);
 
 static inline void put_namespace(struct namespace *namespace)
 {
index 0b3239a..6229cbc 100644 (file)
@@ -3,7 +3,6 @@
 
 
 #define VCMD_enter_namespace   VC_CMD(PROCALT, 1, 0)
-#define VCMD_cleanup_namespace VC_CMD(PROCALT, 2, 0)
 
 #define VCMD_set_namespace_v0  VC_CMD(PROCALT, 3, 0)
 #define VCMD_set_namespace     VC_CMD(PROCALT, 3, 1)
@@ -12,7 +11,6 @@
 #ifdef __KERNEL__
 
 extern int vc_enter_namespace(uint32_t, void __user *);
-extern int vc_cleanup_namespace(uint32_t, void __user *);
 extern int vc_set_namespace(uint32_t, void __user *);
 
 #endif /* __KERNEL__ */
index 1722b16..0e0253b 100644 (file)
@@ -30,7 +30,7 @@
 
 #define NXA_MOD_BCAST          (1<<8)
 
-#define NXA_TYPE_ANY           (~0)
+#define NXA_TYPE_ANY           ((uint16_t)-1)
 
 
 #ifdef __KERNEL__
index ddfba94..b7e255e 100644 (file)
@@ -78,7 +78,7 @@
 
 /*  interface version */
 
-#define VCI_VERSION            0x00020001
+#define VCI_VERSION            0x00020002
 #define VCI_LEGACY_VERSION     0x000100FF
 
 /*  query version */
index aab07e5..f6e3f99 100644 (file)
@@ -116,9 +116,9 @@ struct sock_common {
        unsigned int            skc_hash;
        struct proto            *skc_prot;
        xid_t                   skc_xid;
-       struct vx_info  *skc_vx_info;
+       struct vx_info          *skc_vx_info;
        nid_t                   skc_nid;
-       struct nx_info  *skc_nx_info;
+       struct nx_info          *skc_nx_info;
 };
 
 /**
index 4e3424e..6b3412f 100644 (file)
@@ -253,4 +253,3 @@ int capable(int cap)
        return __capable(current, cap);
 }
 EXPORT_SYMBOL(capable);
-
index fedcdea..08eee6d 100644 (file)
@@ -294,7 +294,6 @@ static void reparent_to_init(void)
        ptrace_unlink(current);
        /* Reparent to init */
        remove_parent(current);
-       /* FIXME: handle vchild_reaper/initpid */
        current->parent = child_reaper;
        current->real_parent = child_reaper;
        add_parent(current);
@@ -458,6 +457,7 @@ static void close_files(struct files_struct * files)
                        }
                        i++;
                        set >>= 1;
+                       cond_resched();
                }
        }
 }
@@ -728,7 +728,6 @@ static void forget_original_parent(struct task_struct * father,
        }
        list_for_each_safe(_p, _n, &father->ptrace_children) {
                p = list_entry(_p,struct task_struct,ptrace_list);
-               /* check for reaper context */
                choose_new_parent(p, reaper);
                reparent_thread(p, father, 1);
        }
index 995d20a..fcaaa99 100644 (file)
@@ -1361,7 +1361,6 @@ long do_fork(unsigned long clone_flags,
 
        if (!pid)
                return -EAGAIN;
-
        nr = pid->nr;
        if (unlikely(current->ptrace)) {
                trace = fork_traceflag (clone_flags);
index 16c366c..e081fef 100644 (file)
@@ -310,10 +310,9 @@ int posix_timer_event(struct k_itimer *timr,int si_private)
 
        if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
                struct task_struct *leader;
-               int ret;
+               int ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
+                                       timr->it_process);
 
-               ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
-                                   timr->it_process);
                if (likely(ret >= 0))
                        return ret;
 
index 83f06d6..2f8cdbe 100644 (file)
@@ -1025,7 +1025,7 @@ asmlinkage long do_getxpid(long *ppid)
        *ppid = sys_getppid();
        return sys_getpid();
 }
-
+  
 #else /* _alpha_ */
 
 asmlinkage long sys_getuid(void)
index da745b1..55a7062 100644 (file)
@@ -615,6 +615,7 @@ int vx_set_init(struct vx_info *vxi, struct task_struct *p)
                "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
                vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
 
+       vxi->vx_flags &= ~VXF_STATE_INIT;
        vxi->vx_initpid = p->tgid;
        return 0;
 }
@@ -634,13 +635,25 @@ void vx_set_persistent(struct vx_info *vxi)
        vxdprintk(VXD_CBIT(xid, 6),
                "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
 
-       if (vx_info_flags(vxi, VXF_PERSISTENT, 0)) {
-               get_vx_info(vxi);
-               claim_vx_info(vxi, current);
-       } else {
-               release_vx_info(vxi, current);
-               put_vx_info(vxi);
-       }
+       get_vx_info(vxi);
+       claim_vx_info(vxi, current);
+}
+
+void vx_clear_persistent(struct vx_info *vxi)
+{
+       vxdprintk(VXD_CBIT(xid, 6),
+               "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
+
+       release_vx_info(vxi, current);
+       put_vx_info(vxi);
+}
+
+void vx_update_persistent(struct vx_info *vxi)
+{
+       if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
+               vx_set_persistent(vxi);
+       else
+               vx_clear_persistent(vxi);
 }
 
 
@@ -745,10 +758,22 @@ int vc_ctx_create(uint32_t xid, void __user *data)
        if ((vc_data.flagword & VXF_PERSISTENT))
                vx_set_persistent(new_vxi);
 
-       vs_state_change(new_vxi, VSC_STARTUP);
-       ret = new_vxi->vx_id;
-       vx_migrate_task(current, new_vxi);
-       /* if this fails, we might end up with a hashed vx_info */
+       ret = -ENOEXEC;
+       if (vs_state_change(new_vxi, VSC_STARTUP))
+               goto out_unhash;
+       ret = vx_migrate_task(current, new_vxi);
+       if (!ret) {
+               /* return context id on success */
+               ret = new_vxi->vx_id;
+               goto out;
+       }
+out_unhash:
+       /* prepare for context disposal */
+       new_vxi->vx_state |= VXS_SHUTDOWN;
+       if ((vc_data.flagword & VXF_PERSISTENT))
+               vx_clear_persistent(new_vxi);
+       __unhash_vx_info(new_vxi);
+out:
        put_vx_info(new_vxi);
        return ret;
 }
@@ -838,7 +863,7 @@ int vc_set_cflags(uint32_t id, void __user *data)
        vxi->vx_flags = vx_mask_flags(vxi->vx_flags,
                vc_data.flagword, mask);
        if (trigger & VXF_PERSISTENT)
-               vx_set_persistent(vxi);
+               vx_update_persistent(vxi);
 
        put_vx_info(vxi);
        return 0;
index 4805303..fb0684f 100644 (file)
@@ -68,8 +68,9 @@ void vx_update_load(struct vx_info *vxi)
        uint32_t now, last, delta;
        unsigned int nr_running, nr_uninterruptible;
        unsigned int total;
+       unsigned long flags;
 
-       spin_lock(&vxi->cvirt.load_lock);
+       spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
 
        now = jiffies;
        last = vxi->cvirt.load_last;
@@ -92,7 +93,7 @@ void vx_update_load(struct vx_info *vxi)
        vxi->cvirt.load_last = now;
 out:
        atomic_inc(&vxi->cvirt.load_updates);
-       spin_unlock(&vxi->cvirt.load_lock);
+       spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
 }
 
 
index 96ad9a5..ec1a0b2 100644 (file)
@@ -134,9 +134,6 @@ static inline struct dl_info *__lookup_dl_info(struct super_block *sb, xid_t xid
        struct dl_info *dli;
 
        hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
-//     hlist_for_each_rcu(pos, head) {
-//             struct dl_info *dli =
-//                     hlist_entry(pos, struct dl_info, dl_hlist);
 
                if (dli->dl_xid == xid && dli->dl_sb == sb) {
                        return dli;
index 7ab0b1e..f8a657a 100644 (file)
@@ -30,8 +30,6 @@ static int vx_set_initpid(struct vx_info *vxi, int pid)
        init = find_task_by_real_pid(pid);
        if (!init)
                return -ESRCH;
-
-       vxi->vx_flags &= ~VXF_STATE_INIT;
        return vx_set_init(vxi, init);
 }
 
index 2df0af9..de64e40 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/vs_context.h>
 #include <linux/vs_network.h>
 #include <linux/vserver/legacy.h>
-// #include <linux/vserver/namespace.h>
 #include <linux/namespace.h>
 #include <linux/err.h>
 
index 84e58c5..2c46f98 100644 (file)
@@ -85,16 +85,6 @@ out_put:
        return ret;
 }
 
-int vc_cleanup_namespace(uint32_t id, void __user *data)
-{
-       // down_write(&current->namespace->sem);
-       spin_lock(&vfsmount_lock);
-       umount_unused(current->namespace->root, current->fs);
-       spin_unlock(&vfsmount_lock);
-       // up_write(&current->namespace->sem);
-       return 0;
-}
-
 int vc_set_namespace(uint32_t id, void __user *data)
 {
        struct fs_struct *fs;
index 66e09de..1ceb1fc 100644 (file)
@@ -488,13 +488,25 @@ int nx_addr_conflict(struct nx_info *nxi, uint32_t addr, struct sock *sk)
 
 void nx_set_persistent(struct nx_info *nxi)
 {
-       if (nx_info_flags(nxi, NXF_PERSISTENT, 0)) {
-               get_nx_info(nxi);
-               claim_nx_info(nxi, current);
-       } else {
-               release_nx_info(nxi, current);
-               put_nx_info(nxi);
-       }
+       get_nx_info(nxi);
+       claim_nx_info(nxi, current);
+}
+
+void nx_clear_persistent(struct nx_info *nxi)
+{
+       vxdprintk(VXD_CBIT(nid, 6),
+               "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
+
+       release_nx_info(nxi, current);
+       put_nx_info(nxi);
+}
+
+void nx_update_persistent(struct nx_info *nxi)
+{
+       if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
+               nx_set_persistent(nxi);
+       else
+               nx_clear_persistent(nxi);
 }
 
 /* vserver syscall commands below here */
@@ -577,10 +589,22 @@ int vc_net_create(uint32_t nid, void __user *data)
        if ((vc_data.flagword & NXF_PERSISTENT))
                nx_set_persistent(new_nxi);
 
-       vs_net_change(new_nxi, VSC_NETUP);
-       ret = new_nxi->nx_id;
-       nx_migrate_task(current, new_nxi);
-       /* if this fails, we might end up with a hashed nx_info */
+       ret = -ENOEXEC;
+       if (vs_net_change(new_nxi, VSC_NETUP))
+               goto out_unhash;
+       ret = nx_migrate_task(current, new_nxi);
+       if (!ret) {
+               /* return context id on success */
+               ret = new_nxi->nx_id;
+               goto out;
+       }
+out_unhash:
+       /* prepare for context disposal */
+       new_nxi->nx_state |= NXS_SHUTDOWN;
+       if ((vc_data.flagword & NXF_PERSISTENT))
+               nx_clear_persistent(new_nxi);
+       __unhash_nx_info(new_nxi);
+out:
        put_nx_info(new_nxi);
        return ret;
 }
@@ -668,7 +692,7 @@ int vc_net_remove(uint32_t nid, void __user *data)
        if (!nxi)
                return -ESRCH;
 
-       switch ((unsigned)vc_data.type) {
+       switch (vc_data.type) {
        case NXA_TYPE_ANY:
                nxi->nbipv4 = 0;
                break;
@@ -728,7 +752,7 @@ int vc_set_nflags(uint32_t id, void __user *data)
        nxi->nx_flags = vx_mask_flags(nxi->nx_flags,
                vc_data.flagword, mask);
        if (trigger & NXF_PERSISTENT)
-               nx_set_persistent(nxi);
+               nx_update_persistent(nxi);
 
        put_nx_info(nxi);
        return 0;
index ce383a4..841213f 100644 (file)
@@ -111,8 +111,6 @@ long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
                return vc_set_namespace(-1, data);
        case VCMD_set_namespace:
                return vc_set_namespace(id, data);
-       case VCMD_cleanup_namespace:
-               return vc_cleanup_namespace(id, data);
        }
 
        /* those are allowed while in setup too */
index 653b56f..414b5bc 100644 (file)
@@ -36,7 +36,6 @@ static int zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,
                                set_page_dirty(page);
                        page_remove_rmap(page);
                        page_cache_release(page);
-                       // dec_mm_counter(mm, file_rss);
                }
        } else {
                if (!pte_file(pte))
index 895def6..37632d3 100644 (file)
@@ -216,7 +216,6 @@ static void udp_v4_unhash(struct sock *sk)
        write_unlock_bh(&udp_hash_lock);
 }
 
-
 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
  * harder than this. -DaveM
  */