diff -NurpP --minimal linux-2.6.9-rc2-vs1.9.2.27/Makefile linux-2.6.9-rc2-vs1.9.2.27.1/Makefile --- linux-2.6.9-rc2-vs1.9.2.27/Makefile 2004-09-15 19:12:18.000000000 +0200 +++ linux-2.6.9-rc2-vs1.9.2.27.1/Makefile 2004-09-15 19:12:18.000000000 +0200 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 9 -EXTRAVERSION = -rc2-vs1.9.2.27 +EXTRAVERSION = -rc2-vs1.9.2.27.1 NAME=Zonked Quokka # *DOCUMENTATION* diff -NurpP --minimal linux-2.6.9-rc2-vs1.9.2.27/include/linux/fs.h linux-2.6.9-rc2-vs1.9.2.27.1/include/linux/fs.h --- linux-2.6.9-rc2-vs1.9.2.27/include/linux/fs.h 2004-09-13 18:51:02.000000000 +0200 +++ linux-2.6.9-rc2-vs1.9.2.27.1/include/linux/fs.h 2004-09-15 18:26:10.000000000 +0200 @@ -588,7 +588,9 @@ struct file { struct fown_struct f_owner; unsigned int f_uid, f_gid; struct file_ra_state f_ra; + struct vx_info *f_vx_info; + struct list_head f_vx_list; unsigned long f_version; void *f_security; diff -NurpP --minimal linux-2.6.9-rc2-vs1.9.2.27/include/linux/vs_limit.h linux-2.6.9-rc2-vs1.9.2.27.1/include/linux/vs_limit.h --- linux-2.6.9-rc2-vs1.9.2.27/include/linux/vs_limit.h 2004-09-13 18:51:02.000000000 +0200 +++ linux-2.6.9-rc2-vs1.9.2.27.1/include/linux/vs_limit.h 2004-09-15 19:07:56.000000000 +0200 @@ -36,13 +36,27 @@ static inline void __vx_acc_cres(struct #define vx_nproc_inc(p) \ vx_acc_cres((p)->vx_info, 1, (p), RLIMIT_NPROC) -#define vx_nproc_dec(p) \ - vx_acc_cres((p)->vx_info,-1, (p), RLIMIT_NPROC) -#define vx_files_inc(f) \ - vx_acc_cres((f)->f_vx_info, 1, (f), RLIMIT_NOFILE) -#define vx_files_dec(f) \ - vx_acc_cres((f)->f_vx_info,-1, (f), RLIMIT_NOFILE) +extern void __freeup_files(struct vx_info *); + +#define vx_nproc_dec(p) do {\ + struct vx_info *vxi = (p)->vx_info; \ + vx_acc_cres((p)->vx_info,-1, (p), RLIMIT_NPROC); \ + if (vxi && atomic_read(&vxi->limit.rcur[RLIMIT_NPROC]) == 0) \ + __freeup_files(vxi); \ + } while (0) + +#define vx_files_inc(f) do {\ + vx_acc_cres((f)->f_vx_info, 1, (f), RLIMIT_NOFILE); \ + if ((f)->f_vx_info) \ + list_add(&(f)->f_vx_list, &(f)->f_vx_info->vx_files); \ + } while (0) + +#define vx_files_dec(f) do {\ + vx_acc_cres((f)->f_vx_info,-1, (f), RLIMIT_NOFILE); \ + if ((f)->f_vx_info) \ + list_del(&(f)->f_vx_list); \ + } while (0) /* #define vx_openfd_inc(f) do { \ diff -NurpP --minimal linux-2.6.9-rc2-vs1.9.2.27/include/linux/vserver/context.h linux-2.6.9-rc2-vs1.9.2.27.1/include/linux/vserver/context.h --- linux-2.6.9-rc2-vs1.9.2.27/include/linux/vserver/context.h 2004-09-13 18:51:02.000000000 +0200 +++ linux-2.6.9-rc2-vs1.9.2.27.1/include/linux/vserver/context.h 2004-09-15 18:32:22.000000000 +0200 @@ -36,6 +36,7 @@ struct vx_info { uint64_t vx_ccaps; /* context caps (vserver) */ pid_t vx_initpid; /* PID of fake init process */ + struct list_head vx_files; struct _vx_limit limit; /* vserver limits */ struct _vx_sched sched; /* vserver scheduler */ Files linux-2.6.9-rc2-vs1.9.2.27/kernel/vserver/.context.c.swp and linux-2.6.9-rc2-vs1.9.2.27.1/kernel/vserver/.context.c.swp differ diff -NurpP --minimal linux-2.6.9-rc2-vs1.9.2.27/kernel/vserver/context.c linux-2.6.9-rc2-vs1.9.2.27.1/kernel/vserver/context.c --- linux-2.6.9-rc2-vs1.9.2.27/kernel/vserver/context.c 2004-09-13 18:51:02.000000000 +0200 +++ linux-2.6.9-rc2-vs1.9.2.27.1/kernel/vserver/context.c 2004-09-15 18:56:13.000000000 +0200 @@ -60,6 +60,8 @@ static struct vx_info *__alloc_vx_info(x vx_info_init_cvirt(&new->cvirt); vx_info_init_cacct(&new->cacct); + INIT_LIST_HEAD(&new->vx_files); + new->vx_flags = VXF_STATE_SETUP|VXF_STATE_INIT; new->vx_bcaps = CAP_INIT_EFF_SET; new->vx_ccaps = 0; @@ -85,6 +87,7 @@ static void __dealloc_vx_info(struct vx_ vx_info_exit_sched(&vxi->sched); vx_info_exit_cvirt(&vxi->cvirt); vx_info_exit_cacct(&vxi->cacct); + BUG_ON(atomic_read(&vxi->vx_usecnt)); BUG_ON(atomic_read(&vxi->vx_refcnt)); @@ -96,6 +99,25 @@ static void __dealloc_vx_info(struct vx_ kfree(vxi); } +#include +#include + +void __freeup_files(struct vx_info *vxi) +{ + struct list_head *entry, *helper; + char path[256]; + + list_for_each_safe(entry, helper, &vxi->vx_files) { + struct file *fp = list_entry(entry, struct file, f_vx_list); + + d_path(fp->f_dentry, fp->f_vfsmnt, path, sizeof(path)); + printk("file %p: %s\n", fp, path); + + vx_files_dec(fp); + clr_vx_info(&fp->f_vx_info); + } +} + static inline int __free_vx_info(struct vx_info *vxi) { int usecnt, refcnt;