updated to headers from patch-2.6.11.7-vs2.0-pre2
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 28 Apr 2005 11:01:27 +0000 (11:01 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 28 Apr 2005 11:01:27 +0000 (11:01 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2046 94cd875c-1c1d-0410-91d2-eb244daf1a30

23 files changed:
util-vserver/kernel/context.h
util-vserver/kernel/context_cmd.h [new file with mode: 0644]
util-vserver/kernel/cvirt.h
util-vserver/kernel/cvirt_cmd.h [new file with mode: 0644]
util-vserver/kernel/cvirt_def.h [new file with mode: 0644]
util-vserver/kernel/debug.h
util-vserver/kernel/debug_cmd.h [new file with mode: 0644]
util-vserver/kernel/dlimit.h
util-vserver/kernel/dlimit_cmd.h [new file with mode: 0644]
util-vserver/kernel/inode.h
util-vserver/kernel/inode_cmd.h [new file with mode: 0644]
util-vserver/kernel/legacy.h
util-vserver/kernel/limit.h
util-vserver/kernel/limit_cmd.h [new file with mode: 0644]
util-vserver/kernel/limit_def.h [new file with mode: 0644]
util-vserver/kernel/namespace.h
util-vserver/kernel/network.h
util-vserver/kernel/network_cmd.h [new file with mode: 0644]
util-vserver/kernel/sched.h
util-vserver/kernel/sched_cmd.h [new file with mode: 0644]
util-vserver/kernel/sched_def.h [new file with mode: 0644]
util-vserver/kernel/switch.h
util-vserver/kernel/xid.h

index 4061e7b..eae7ec4 100644 (file)
@@ -3,29 +3,85 @@
 
 #include <linux/types.h>
 
+
 #define MAX_S_CONTEXT  65535   /* Arbitrary limit */
 #define MIN_D_CONTEXT  49152   /* dynamic contexts start here */
 
 #define VX_DYNAMIC_ID  ((uint32_t)-1)          /* id for dynamic context */
 
+/* context flags */
+
+#define VXF_INFO_LOCK          0x00000001
+#define VXF_INFO_SCHED         0x00000002
+#define VXF_INFO_NPROC         0x00000004
+#define VXF_INFO_PRIVATE       0x00000008
+
+#define VXF_INFO_INIT          0x00000010
+#define VXF_INFO_HIDE          0x00000020
+#define VXF_INFO_ULIMIT                0x00000040
+#define VXF_INFO_NSPACE                0x00000080
+
+#define VXF_SCHED_HARD         0x00000100
+#define VXF_SCHED_PRIO         0x00000200
+#define VXF_SCHED_PAUSE                0x00000400
+
+#define VXF_VIRT_MEM           0x00010000
+#define VXF_VIRT_UPTIME                0x00020000
+#define VXF_VIRT_CPU           0x00040000
+#define VXF_VIRT_LOAD          0x00080000
+
+#define VXF_HIDE_MOUNT         0x01000000
+#define VXF_HIDE_NETIF         0x02000000
+
+#define VXF_STATE_SETUP                (1ULL<<32)
+#define VXF_STATE_INIT         (1ULL<<33)
+
+#define VXF_FORK_RSS           (1ULL<<48)
+#define VXF_PROLIFIC           (1ULL<<49)
+
+#define VXF_IGNEG_NICE         (1ULL<<52)
+
+#define VXF_ONE_TIME           (0x0003ULL<<32)
+
+
+/* context caps */
+
+#define        VXC_CAP_MASK            0x00000000
+
+#define VXC_SET_UTSNAME                0x00000001
+#define VXC_SET_RLIMIT         0x00000002
+
+#define VXC_RAW_ICMP           0x00000100
+
+#define VXC_SECURE_MOUNT       0x00010000
+#define VXC_SECURE_REMOUNT     0x00020000
+#define VXC_BINARY_MOUNT       0x00040000
+
+#define VXC_QUOTA_CTL          0x00100000
+
+
+/* vshelper sync commands */
+
+#define        VS_CONTEXT_CREATED      1
+#define        VS_CONTEXT_DESTROY      2
+
+
 #ifdef __KERNEL__
 
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/rcupdate.h>
 
-#define _VX_INFO_DEF_
-#include "cvirt.h"
-#include "limit.h"
-#include "sched.h"
-#undef _VX_INFO_DEF_
+#include "limit_def.h"
+#include "sched_def.h"
+#include "cvirt_def.h"
 
 struct vx_info {
        struct hlist_node vx_hlist;             /* linked list of contexts */
        struct rcu_head vx_rcu;                 /* the rcu head */
        xid_t vx_id;                            /* context id */
        atomic_t vx_usecnt;                     /* usage count */
-       atomic_t vx_refcnt;                     /* reference count */
+       atomic_t vx_tasks;                      /* tasks count */
        struct vx_info *vx_parent;              /* parent context */
        int vx_state;                           /* context state */
 
@@ -48,6 +104,7 @@ struct vx_info {
        char vx_name[65];                       /* vserver name */
 };
 
+
 /* status flags */
 
 #define VXS_HASHED     0x0001
@@ -61,7 +118,8 @@ struct vx_info {
 
 #define VX_ADMIN       0x0001
 #define VX_WATCH       0x0002
-#define VX_DUMMY       0x0008
+#define VX_HIDE                0x0004
+#define VX_HOSTID      0x0008
 
 #define VX_IDENT       0x0010
 #define VX_EQUIV       0x0020
@@ -76,124 +134,23 @@ struct vx_info {
 #define VX_ATR_MASK    0x0F00
 
 
-struct rcu_head;
-
-// extern void rcu_free_vx_info(struct rcu_head *);
-extern void unhash_vx_info(struct vx_info *);
+extern void claim_vx_info(struct vx_info *, struct task_struct *);
+extern void release_vx_info(struct vx_info *, struct task_struct *);
 
 extern struct vx_info *locate_vx_info(int);
 extern struct vx_info *locate_or_create_vx_info(int);
 
 extern int get_xid_list(int, unsigned int *, int);
-extern int vx_info_is_hashed(xid_t);
+extern int xid_is_hashed(xid_t);
 
 extern int vx_migrate_task(struct task_struct *, struct vx_info *);
 
-#endif /* __KERNEL__ */
-
-#include "switch.h"
-
-/* vinfo commands */
-
-#define VCMD_task_xid          VC_CMD(VINFO, 1, 0)
-#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
-
-#ifdef __KERNEL__
-extern int vc_task_xid(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_vx_info           VC_CMD(VINFO, 5, 0)
-#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
-
-struct vcmd_vx_info_v0 {
-       uint32_t xid;
-       uint32_t initpid;
-       /* more to come */
-};
-
-#ifdef __KERNEL__
-extern int vc_vx_info(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_ctx_create                VC_CMD(VPROC, 1, 0)
-#define VCMD_ctx_migrate       VC_CMD(PROCMIG, 1, 0)
-
-#ifdef __KERNEL__
-extern int vc_ctx_create(uint32_t, void __user *);
-extern int vc_ctx_migrate(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_get_cflags                VC_CMD(FLAGS, 1, 0)
-#define VCMD_set_cflags                VC_CMD(FLAGS, 2, 0)
-
-struct vcmd_ctx_flags_v0 {
-       uint64_t flagword;
-       uint64_t mask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_cflags(uint32_t, void __user *);
-extern int vc_set_cflags(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VXF_INFO_LOCK          0x00000001
-#define VXF_INFO_SCHED         0x00000002
-#define VXF_INFO_NPROC         0x00000004
-#define VXF_INFO_PRIVATE       0x00000008
-
-#define VXF_INFO_INIT          0x00000010
-#define VXF_INFO_HIDE          0x00000020
-#define VXF_INFO_ULIMIT                0x00000040
-#define VXF_INFO_NSPACE                0x00000080
-
-#define VXF_SCHED_HARD         0x00000100
-#define VXF_SCHED_PRIO         0x00000200
-#define VXF_SCHED_PAUSE                0x00000400
+extern long vs_context_state(struct vx_info *, unsigned int);
 
-#define VXF_VIRT_MEM           0x00010000
-#define VXF_VIRT_UPTIME                0x00020000
-#define VXF_VIRT_CPU           0x00040000
-#define VXF_VIRT_LOAD          0x00080000
-
-#define VXF_HIDE_MOUNT         0x01000000
-#define VXF_HIDE_NETIF         0x02000000
-
-#define VXF_STATE_SETUP                (1ULL<<32)
-#define VXF_STATE_INIT         (1ULL<<33)
-
-#define VXF_FORK_RSS           (1ULL<<48)
-#define VXF_PROLIFIC           (1ULL<<49)
-
-#define VXF_IGNEG_NICE         (1ULL<<52)
+extern void free_vx_info(struct vx_info *);
 
-#define VXF_ONE_TIME           (0x0003ULL<<32)
-
-#define VCMD_get_ccaps         VC_CMD(FLAGS, 3, 0)
-#define VCMD_set_ccaps         VC_CMD(FLAGS, 4, 0)
-
-struct vcmd_ctx_caps_v0 {
-       uint64_t bcaps;
-       uint64_t ccaps;
-       uint64_t cmask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_ccaps(uint32_t, void __user *);
-extern int vc_set_ccaps(uint32_t, void __user *);
 
 #endif /* __KERNEL__ */
-
-#define VXC_SET_UTSNAME                0x00000001
-#define VXC_SET_RLIMIT         0x00000002
-
-#define VXC_RAW_ICMP           0x00000100
-
-#define VXC_SECURE_MOUNT       0x00010000
-#define VXC_SECURE_REMOUNT     0x00020000
-
-
+#else  /* _VX_CONTEXT_H */
+#warning duplicate inclusion
 #endif /* _VX_CONTEXT_H */
diff --git a/util-vserver/kernel/context_cmd.h b/util-vserver/kernel/context_cmd.h
new file mode 100644 (file)
index 0000000..637a0d8
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef _VX_CONTEXT_CMD_H
+#define _VX_CONTEXT_CMD_H
+
+
+/* vinfo commands */
+
+#define VCMD_task_xid          VC_CMD(VINFO, 1, 0)
+
+#ifdef __KERNEL__
+extern int vc_task_xid(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_vx_info           VC_CMD(VINFO, 5, 0)
+
+struct vcmd_vx_info_v0 {
+       uint32_t xid;
+       uint32_t initpid;
+       /* more to come */
+};
+
+#ifdef __KERNEL__
+extern int vc_vx_info(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+
+/* context commands */
+
+#define VCMD_ctx_create                VC_CMD(VPROC, 1, 0)
+#define VCMD_ctx_migrate       VC_CMD(PROCMIG, 1, 0)
+
+#ifdef __KERNEL__
+extern int vc_ctx_create(uint32_t, void __user *);
+extern int vc_ctx_migrate(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+
+/* flag commands */
+
+#define VCMD_get_cflags                VC_CMD(FLAGS, 1, 0)
+#define VCMD_set_cflags                VC_CMD(FLAGS, 2, 0)
+
+struct vcmd_ctx_flags_v0 {
+       uint64_t flagword;
+       uint64_t mask;
+};
+
+#ifdef __KERNEL__
+extern int vc_get_cflags(uint32_t, void __user *);
+extern int vc_set_cflags(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+
+/* context caps commands */
+
+#define VCMD_get_ccaps         VC_CMD(FLAGS, 3, 0)
+#define VCMD_set_ccaps         VC_CMD(FLAGS, 4, 0)
+
+struct vcmd_ctx_caps_v0 {
+       uint64_t bcaps;
+       uint64_t ccaps;
+       uint64_t cmask;
+};
+
+#ifdef __KERNEL__
+extern int vc_get_ccaps(uint32_t, void __user *);
+extern int vc_set_ccaps(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_CONTEXT_CMD_H */
index 1c3e340..a3cadfd 100644 (file)
-/* _VX_CVIRT_H defined below */
-
-#if    defined(__KERNEL__) && defined(_VX_INFO_DEF_)
-
-#include <linux/utsname.h>
-#include <linux/rwsem.h>
-#include <linux/jiffies.h>
-#include <linux/time.h>
-#include <linux/sched.h>
-#include <linux/kernel_stat.h>
-#include <asm/atomic.h>
-
-/* context sub struct */
-
-struct _vx_cvirt {
-       int max_threads;                /* maximum allowed threads */
-       atomic_t nr_threads;            /* number of current threads */
-       atomic_t nr_running;            /* number of running threads */
-
-       atomic_t nr_onhold;             /* processes on hold */
-       uint32_t onhold_last;           /* jiffies when put on hold */
-
-       struct timespec bias_idle;
-       struct timespec bias_uptime;    /* context creation point */
-
-       struct new_utsname utsname;
-
-       spinlock_t load_lock;           /* lock for the load averages */
-       uint32_t load_last;             /* last time load was cacled */
-       uint32_t load[3];               /* load averages 1,5,15 */
-
-       struct cpu_usage_stat cpustat[NR_CPUS];
-};
-
-struct sock_acc {
-       atomic_t count;
-       atomic_t total;
-};
-
-struct _vx_cacct {
-       unsigned long total_forks;
-
-       struct sock_acc sock[5][3];
-};
-
-
-static inline long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
-{
-       return atomic_read(&cacct->sock[type][pos].count);
-}
-
-
-static inline long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
-{
-       return atomic_read(&cacct->sock[type][pos].total);
-}
-
-
-extern uint64_t vx_idle_jiffies(void);
-
-static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
-{
-       uint64_t idle_jiffies = vx_idle_jiffies();
-
-       do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
-       jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
-       atomic_set(&cvirt->nr_threads, 0);
-       atomic_set(&cvirt->nr_running, 0);
-       atomic_set(&cvirt->nr_onhold, 0);
-
-       down_read(&uts_sem);
-       cvirt->utsname = system_utsname;
-       up_read(&uts_sem);
-
-       spin_lock_init(&cvirt->load_lock);
-       cvirt->load_last = jiffies;
-       cvirt->load[0] = 0;
-       cvirt->load[1] = 0;
-       cvirt->load[2] = 0;
-}
-
-static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
-{
-#ifdef CONFIG_VSERVER_DEBUG
-       int value;
-
-       if ((value = atomic_read(&cvirt->nr_threads)))
-               printk("!!! cvirt: %p[nr_threads] = %d on exit.\n",
-                       cvirt, value);
-       if ((value = atomic_read(&cvirt->nr_running)))
-               printk("!!! cvirt: %p[nr_running] = %d on exit.\n",
-                       cvirt, value);
-#endif
-       return;
-}
-
-static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
-{
-       int i,j;
-
-       for (i=0; i<5; i++) {
-               for (j=0; j<3; j++) {
-                       atomic_set(&cacct->sock[i][j].count, 0);
-                       atomic_set(&cacct->sock[i][j].total, 0);
-               }
-       }
-}
-
-static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
-{
-       return;
-}
-
-#define LOAD_INT(x) ((x) >> FSHIFT)
-#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
-
-
-static inline int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
-{
-       int length = 0;
-       int a, b, c;
-
-       length += sprintf(buffer + length,
-               "BiasUptime:\t%lu.%02lu\n", 
-                       (unsigned long)cvirt->bias_uptime.tv_sec,
-                       (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
-       length += sprintf(buffer + length,
-               "SysName:\t%.*s\n"
-               "NodeName:\t%.*s\n"
-               "Release:\t%.*s\n"
-               "Version:\t%.*s\n"
-               "Machine:\t%.*s\n"
-               "DomainName:\t%.*s\n"
-               ,__NEW_UTS_LEN, cvirt->utsname.sysname
-               ,__NEW_UTS_LEN, cvirt->utsname.nodename
-               ,__NEW_UTS_LEN, cvirt->utsname.release
-               ,__NEW_UTS_LEN, cvirt->utsname.version
-               ,__NEW_UTS_LEN, cvirt->utsname.machine
-               ,__NEW_UTS_LEN, cvirt->utsname.domainname
-               );
-
-       a = cvirt->load[0] + (FIXED_1/200);
-       b = cvirt->load[1] + (FIXED_1/200);
-       c = cvirt->load[2] + (FIXED_1/200);
-       length += sprintf(buffer + length,
-               "nr_threads:\t%d\n"
-               "nr_running:\t%d\n"
-               "nr_onhold:\t%d\n"
-               "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
-               ,atomic_read(&cvirt->nr_threads)
-               ,atomic_read(&cvirt->nr_running)
-               ,atomic_read(&cvirt->nr_onhold)
-               ,LOAD_INT(a), LOAD_FRAC(a)
-               ,LOAD_INT(b), LOAD_FRAC(b)
-               ,LOAD_INT(c), LOAD_FRAC(c)
-               );
-       return length;
-}
-
-static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
-{
-       int i,j, length = 0;
-       static char *type[] = { "UNSPEC", "UNIX", "INET", "INET6", "OTHER" };
-
-       for (i=0; i<5; i++) {
-               length += sprintf(buffer + length,
-                       "%s:", type[i]);
-               for (j=0; j<3; j++) {
-                       length += sprintf(buffer + length,
-                               "\t%12lu/%-12lu"
-                               ,vx_sock_count(cacct, i, j)
-                               ,vx_sock_total(cacct, i, j)
-                               );
-               }
-               buffer[length++] = '\n';
-       }
-       length += sprintf(buffer + length,
-               "forks:\t%lu\n", cacct->total_forks);
-       return length;
-}
-
-#else  /* _VX_INFO_DEF_ */
 #ifndef _VX_CVIRT_H
 #define _VX_CVIRT_H
 
-#include "switch.h"
-
-/*  cvirt vserver commands */
-
-
 #ifdef __KERNEL__
 
 struct timespec;
 
 void vx_vsi_uptime(struct timespec *, struct timespec *);
 
+
 struct vx_info;
 
 void vx_update_load(struct vx_info *);
 
 
-#endif /* __KERNEL__ */
+int vx_do_syslog(int, char __user *, int);
 
+#endif /* __KERNEL__ */
+#else  /* _VX_CVIRT_H */
+#warning duplicate inclusion
 #endif /* _VX_CVIRT_H */
-#endif
diff --git a/util-vserver/kernel/cvirt_cmd.h b/util-vserver/kernel/cvirt_cmd.h
new file mode 100644 (file)
index 0000000..368f527
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef _VX_CVIRT_CMD_H
+#define _VX_CVIRT_CMD_H
+
+/*  cvirt vserver commands */
+
+
+#endif /* _VX_CVIRT_CMD_H */
diff --git a/util-vserver/kernel/cvirt_def.h b/util-vserver/kernel/cvirt_def.h
new file mode 100644 (file)
index 0000000..c352890
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef _VX_CVIRT_DEF_H
+#define _VX_CVIRT_DEF_H
+
+#include <linux/jiffies.h>
+#include <linux/utsname.h>
+#include <linux/spinlock.h>
+#include <linux/wait.h>
+#include <linux/time.h>
+#include <asm/atomic.h>
+
+
+struct _vx_usage_stat {
+       uint64_t user;
+       uint64_t nice;
+       uint64_t system;
+       uint64_t softirq;
+       uint64_t irq;
+       uint64_t idle;
+       uint64_t iowait;
+};
+
+struct _vx_syslog {
+       wait_queue_head_t log_wait;
+       spinlock_t logbuf_lock;         /* lock for the log buffer */
+
+       unsigned long log_start;        /* next char to be read by syslog() */
+       unsigned long con_start;        /* next char to be sent to consoles */
+       unsigned long log_end;          /* most-recently-written-char + 1 */
+       unsigned long logged_chars;     /* #chars since last read+clear operation */
+
+       char log_buf[1024];
+};
+
+
+/* context sub struct */
+
+struct _vx_cvirt {
+       int max_threads;                /* maximum allowed threads */
+       atomic_t nr_threads;            /* number of current threads */
+       atomic_t nr_running;            /* number of running threads */
+       atomic_t nr_uninterruptible;    /* number of uninterruptible threads */
+
+       atomic_t nr_onhold;             /* processes on hold */
+       uint32_t onhold_last;           /* jiffies when put on hold */
+
+       struct timespec bias_idle;
+       struct timespec bias_uptime;    /* context creation point */
+       uint64_t bias_clock;            /* offset in clock_t */
+
+       struct new_utsname utsname;
+
+       spinlock_t load_lock;           /* lock for the load averages */
+       atomic_t load_updates;          /* nr of load updates done so far */
+       uint32_t load_last;             /* last time load was cacled */
+       uint32_t load[3];               /* load averages 1,5,15 */
+
+       atomic_t total_forks;           /* number of forks so far */
+
+       struct _vx_usage_stat cpustat[NR_CPUS];
+
+       struct _vx_syslog syslog;
+};
+
+struct _vx_sock_acc {
+       atomic_t count;
+       atomic_t total;
+};
+
+/* context sub struct */
+
+struct _vx_cacct {
+       unsigned long total_forks;
+
+       struct _vx_sock_acc sock[5][3];
+};
+
+#endif /* _VX_CVIRT_DEF_H */
index 9529c3c..1a18fe8 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef _VX_DEBUG_H
 #define _VX_DEBUG_H
 
+#ifndef        CONFIG_VSERVER
+#warning config options missing
+#endif
 
 #define VXD_CBIT(n,m)  (vx_debug_ ## n & (1 << (m)))
 #define VXD_CMIN(n,m)  (vx_debug_ ## n > (m))
@@ -10,8 +13,6 @@
 #define VXD_QUAD(v)    VXD_QPOS(v,0), VXD_QPOS(v,1),           \
                        VXD_QPOS(v,2), VXD_QPOS(v,3)
 
-// #define     VXD_HERE        __FILE__, __LINE__
-
 #define __FUNC__       __func__
 
 
@@ -27,11 +28,12 @@ extern unsigned int vx_debug_cvirt;
 
 
 #define VX_LOGLEVEL    "vxD: "
+#define VX_WARNLEVEL   KERN_WARNING "vxW: "
 
 #define vxdprintk(c,f,x...)                                    \
        do {                                                    \
                if (c)                                          \
-                       printk(VX_LOGLEVEL f "\n", x);          \
+                       printk(VX_LOGLEVEL f "\n" , ##x);       \
        } while (0)
 
 #define vxlprintk(c,f,x...)                                    \
@@ -46,7 +48,19 @@ extern unsigned int vx_debug_cvirt;
                        printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
        } while (0)
 
-#else
+
+#define vxwprintk(c,f,x...)                                    \
+       do {                                                    \
+               if (c)                                          \
+                       printk(VX_WARNLEVEL f "\n" , ##x);      \
+       } while (0)
+
+
+#define vxd_path(d,m)                                          \
+       ({ static char _buffer[PATH_MAX];                       \
+          d_path((d), (m), _buffer, sizeof(_buffer)); })
+
+#else  /* CONFIG_VSERVER_DEBUG */
 
 #define vx_debug_switch 0
 #define vx_debug_xid   0
@@ -59,9 +73,298 @@ extern unsigned int vx_debug_cvirt;
 #define vxdprintk(x...) do { } while (0)
 #define vxlprintk(x...) do { } while (0)
 #define vxfprintk(x...) do { } while (0)
+#define vxwprintk(x...) do { } while (0)
 
-#endif
+#define vxd_path       "<none>"
+
+#endif /* CONFIG_VSERVER_DEBUG */
+
+
+/* history stuff */
+
+#ifdef CONFIG_VSERVER_HISTORY
+
+
+extern unsigned volatile int vxh_active;
+
+struct _vxhe_vxi {
+       struct vx_info *ptr;
+       unsigned xid;
+       unsigned usecnt;
+       unsigned tasks;
+};
+
+struct _vxhe_set_clr {
+       void *data;
+};
+
+struct _vxhe_loc_lookup {
+       unsigned arg;
+};
+
+enum {
+       VXH_UNUSED=0,
+       VXH_THROW_OOPS=1,
+
+       VXH_GET_VX_INFO,
+       VXH_PUT_VX_INFO,
+       VXH_INIT_VX_INFO,
+       VXH_SET_VX_INFO,
+       VXH_CLR_VX_INFO,
+       VXH_CLAIM_VX_INFO,
+       VXH_RELEASE_VX_INFO,
+       VXH_ALLOC_VX_INFO,
+       VXH_DEALLOC_VX_INFO,
+       VXH_HASH_VX_INFO,
+       VXH_UNHASH_VX_INFO,
+       VXH_LOC_VX_INFO,
+       VXH_LOOKUP_VX_INFO,
+       VXH_CREATE_VX_INFO,
+};
+
+struct _vx_hist_entry {
+       void *loc;
+       unsigned short seq;
+       unsigned short type;
+       struct _vxhe_vxi vxi;
+       union {
+               struct _vxhe_set_clr sc;
+               struct _vxhe_loc_lookup ll;
+       };
+};
+
+struct _vx_hist_entry *vxh_advance(void *loc);
+
+#define        VXH_HERE()              \
+       ({ __label__ here;      \
+               here:;          \
+               &&here; })
+
+
+
+static inline void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
+{
+       entry->vxi.ptr = vxi;
+       if (vxi) {
+               entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
+               entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
+               entry->vxi.xid = vxi->vx_id;
+       }
+}
+
+static inline void vxh_throw_oops(void)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       entry->type = VXH_THROW_OOPS;
+       preempt_enable();
+
+       /* prevent further acquisition */
+       vxh_active = 0;
+}
+
+static inline void vxh_get_vx_info(struct vx_info *vxi)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->type = VXH_GET_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_put_vx_info(struct vx_info *vxi)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->type = VXH_PUT_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_init_vx_info(struct vx_info *vxi, void *data)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->sc.data = data;
+       entry->type = VXH_INIT_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_set_vx_info(struct vx_info *vxi, void *data)
+{
+       struct _vx_hist_entry *entry;
 
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->sc.data = data;
+       entry->type = VXH_SET_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_clr_vx_info(struct vx_info *vxi, void *data)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->sc.data = data;
+       entry->type = VXH_CLR_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_claim_vx_info(struct vx_info *vxi, void *data)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->sc.data = data;
+       entry->type = VXH_CLAIM_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_release_vx_info(struct vx_info *vxi, void *data)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->sc.data = data;
+       entry->type = VXH_RELEASE_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_alloc_vx_info(struct vx_info *vxi)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->type = VXH_ALLOC_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_dealloc_vx_info(struct vx_info *vxi)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->type = VXH_DEALLOC_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_hash_vx_info(struct vx_info *vxi)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->type = VXH_HASH_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_unhash_vx_info(struct vx_info *vxi)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->type = VXH_UNHASH_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_loc_vx_info(unsigned arg, struct vx_info *vxi)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->ll.arg = arg;
+       entry->type = VXH_LOC_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_lookup_vx_info(unsigned arg, struct vx_info *vxi)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->ll.arg = arg;
+       entry->type = VXH_LOOKUP_VX_INFO;
+       preempt_enable();
+}
+
+static inline void vxh_create_vx_info(unsigned arg, struct vx_info *vxi)
+{
+       struct _vx_hist_entry *entry;
+
+       preempt_disable();
+       entry = vxh_advance(VXH_HERE());
+       __vxh_copy_vxi(entry, vxi);
+       entry->ll.arg = arg;
+       entry->type = VXH_CREATE_VX_INFO;
+       preempt_enable();
+}
+
+
+extern void vxh_dump_history(void);
+
+#else  /* CONFIG_VSERVER_HISTORY */
+
+#define vxh_throw_oops()               do { } while (0)
+
+#define vxh_get_vx_info(v)             do { } while (0)
+#define vxh_put_vx_info(v)             do { } while (0)
+
+#define vxh_init_vx_info(v,d)          do { } while (0)
+#define vxh_set_vx_info(v,d)           do { } while (0)
+#define vxh_clr_vx_info(v,d)           do { } while (0)
+
+#define vxh_claim_vx_info(v,d)         do { } while (0)
+#define vxh_release_vx_info(v,d)       do { } while (0)
+
+#define vxh_alloc_vx_info(v)           do { } while (0)
+#define vxh_dealloc_vx_info(v)         do { } while (0)
+
+#define vxh_hash_vx_info(v)            do { } while (0)
+#define vxh_unhash_vx_info(v)          do { } while (0)
+
+#define vxh_loc_vx_info(a,v)           do { } while (0)
+#define vxh_lookup_vx_info(a,v)                do { } while (0)
+#define vxh_create_vx_info(a,v)                do { } while (0)
+
+#define vxh_dump_history()             do { } while (0)
+
+
+#endif /* CONFIG_VSERVER_HISTORY */
+
+
+#ifdef CONFIG_VSERVER_DEBUG
+#define vxd_assert_lock(l)     assert_spin_locked(l)
+#else
+#define        vxd_assert_lock(l)      do { } while (0)
+#endif
 
 
 #endif /* _VX_DEBUG_H */
diff --git a/util-vserver/kernel/debug_cmd.h b/util-vserver/kernel/debug_cmd.h
new file mode 100644 (file)
index 0000000..c0cbd08
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef _VX_DEBUG_CMD_H
+#define _VX_DEBUG_CMD_H
+
+
+/* debug commands */
+
+#define VCMD_dump_history      VC_CMD(DEBUG, 1, 0)
+
+#ifdef __KERNEL__
+
+extern int vc_dump_history(uint32_t);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_DEBUG_CMD_H */
index 14a68fd..5bfaee1 100644 (file)
@@ -4,30 +4,6 @@
 #include "switch.h"
 #include <linux/spinlock.h>
 
-/*  inode vserver commands */
-
-#define VCMD_add_dlimit                VC_CMD(DLIMIT, 1, 0)
-#define VCMD_rem_dlimit                VC_CMD(DLIMIT, 2, 0)
-
-#define VCMD_set_dlimit                VC_CMD(DLIMIT, 5, 0)
-#define VCMD_get_dlimit                VC_CMD(DLIMIT, 6, 0)
-
-
-struct vcmd_ctx_dlimit_base_v0 {
-       const char __user *name;
-       uint32_t flags;
-};
-
-struct vcmd_ctx_dlimit_v0 {
-       const char __user *name;
-       uint32_t space_used;                    /* used space in kbytes */
-       uint32_t space_total;                   /* maximum space in kbytes */
-       uint32_t inodes_used;                   /* used inodes */
-       uint32_t inodes_total;                  /* maximum inodes */
-       uint32_t reserved;                      /* reserved for root in % */
-       uint32_t flags;
-};
-
 #define CDLIM_UNSET            (0ULL)
 #define CDLIM_INFINITY         (~0ULL)
 #define CDLIM_KEEP             (~1ULL)
@@ -46,7 +22,6 @@ struct dl_info {
 
        struct super_block *dl_sb;              /* associated superblock */
 
-//     struct rw_semaphore dl_sem;             /* protect the values */
        spinlock_t dl_lock;                     /* protect the values */
 
        uint64_t dl_space_used;                 /* used space in bytes */
@@ -69,17 +44,9 @@ struct kstatfs;
 
 extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
 
-
-extern int vc_add_dlimit(uint32_t, void __user *);
-extern int vc_rem_dlimit(uint32_t, void __user *);
-
-extern int vc_set_dlimit(uint32_t, void __user *);
-extern int vc_get_dlimit(uint32_t, void __user *);
-
-
 typedef uint64_t dlsize_t;
 
-
 #endif /* __KERNEL__ */
-
+#else  /* _VX_DLIMIT_H */
+#warning duplicate inclusion
 #endif /* _VX_DLIMIT_H */
diff --git a/util-vserver/kernel/dlimit_cmd.h b/util-vserver/kernel/dlimit_cmd.h
new file mode 100644 (file)
index 0000000..fe6ccc3
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef _VX_DLIMIT_CMD_H
+#define _VX_DLIMIT_CMD_H
+
+/*  dlimit vserver commands */
+
+#define VCMD_add_dlimit                VC_CMD(DLIMIT, 1, 0)
+#define VCMD_rem_dlimit                VC_CMD(DLIMIT, 2, 0)
+
+#define VCMD_set_dlimit                VC_CMD(DLIMIT, 5, 0)
+#define VCMD_get_dlimit                VC_CMD(DLIMIT, 6, 0)
+
+struct vcmd_ctx_dlimit_base_v0 {
+       const char __user *name;
+       uint32_t flags;
+};
+
+struct vcmd_ctx_dlimit_v0 {
+       const char __user *name;
+       uint32_t space_used;                    /* used space in kbytes */
+       uint32_t space_total;                   /* maximum space in kbytes */
+       uint32_t inodes_used;                   /* used inodes */
+       uint32_t inodes_total;                  /* maximum inodes */
+       uint32_t reserved;                      /* reserved for root in % */
+       uint32_t flags;
+};
+
+
+#ifdef __KERNEL__
+
+struct vcmd_ctx_dlimit_base_v0_x32 {
+       uint32_t __user name_ptr;
+       uint32_t flags;
+};
+
+struct vcmd_ctx_dlimit_v0_x32 {
+       uint32_t __user name_ptr;
+       uint32_t space_used;                    /* used space in kbytes */
+       uint32_t space_total;                   /* maximum space in kbytes */
+       uint32_t inodes_used;                   /* used inodes */
+       uint32_t inodes_total;                  /* maximum inodes */
+       uint32_t reserved;                      /* reserved for root in % */
+       uint32_t flags;
+};
+
+#include <linux/compiler.h>
+
+extern int vc_add_dlimit(uint32_t, void __user *);
+extern int vc_rem_dlimit(uint32_t, void __user *);
+
+extern int vc_set_dlimit(uint32_t, void __user *);
+extern int vc_get_dlimit(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_DLIMIT_CMD_H */
index b8a5e78..89212c2 100644 (file)
@@ -1,31 +1,6 @@
 #ifndef _VX_INODE_H
 #define _VX_INODE_H
 
-#include "switch.h"
-
-/*  inode vserver commands */
-
-#define VCMD_get_iattr_v0      VC_CMD(INODE, 1, 0)
-#define VCMD_set_iattr_v0      VC_CMD(INODE, 2, 0)
-
-#define VCMD_get_iattr         VC_CMD(INODE, 1, 1)
-#define VCMD_set_iattr         VC_CMD(INODE, 2, 1)
-
-struct vcmd_ctx_iattr_v0 {
-       /* device handle in id */
-       uint64_t ino;
-       uint32_t xid;
-       uint32_t flags;
-       uint32_t mask;
-};
-
-struct vcmd_ctx_iattr_v1 {
-       const char __user *name;
-       uint32_t xid;
-       uint32_t flags;
-       uint32_t mask;
-};
-
 
 #define IATTR_XID      0x01000000
 
@@ -38,6 +13,11 @@ struct       vcmd_ctx_iattr_v1 {
 #define IATTR_IUNLINK  0x00020000
 #define IATTR_IMMUTABLE 0x00040000
 
+#ifdef __KERNEL__
+
+#ifndef        CONFIG_VSERVER
+#warning config options missing
+#endif
 
 #ifdef CONFIG_VSERVER_PROC_SECURE
 #define IATTR_PROC_DEFAULT     ( IATTR_ADMIN | IATTR_HIDE )
@@ -47,16 +27,8 @@ struct       vcmd_ctx_iattr_v1 {
 #define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
 #endif
 
-#ifdef __KERNEL__
-
 #define vx_hide_check(c,m)     (((m) & IATTR_HIDE) ? vx_check(c,m) : 1)
 
-extern int vc_get_iattr_v0(uint32_t, void __user *);
-extern int vc_set_iattr_v0(uint32_t, void __user *);
-
-extern int vc_get_iattr(uint32_t, void __user *);
-extern int vc_set_iattr(uint32_t, void __user *);
-
 #endif /* __KERNEL__ */
 
 /* inode ioctls */
@@ -64,4 +36,6 @@ extern int vc_set_iattr(uint32_t, void __user *);
 #define FIOC_GETXFLG   _IOR('x', 5, long)
 #define FIOC_SETXFLG   _IOW('x', 6, long)
 
+#else  /* _VX_INODE_H */
+#warning duplicate inclusion
 #endif /* _VX_INODE_H */
diff --git a/util-vserver/kernel/inode_cmd.h b/util-vserver/kernel/inode_cmd.h
new file mode 100644 (file)
index 0000000..5733aa6
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef _VX_INODE_CMD_H
+#define _VX_INODE_CMD_H
+
+/*  inode vserver commands */
+
+#define VCMD_get_iattr_v0      VC_CMD(INODE, 1, 0)
+#define VCMD_set_iattr_v0      VC_CMD(INODE, 2, 0)
+
+#define VCMD_get_iattr         VC_CMD(INODE, 1, 1)
+#define VCMD_set_iattr         VC_CMD(INODE, 2, 1)
+
+struct vcmd_ctx_iattr_v0 {
+       /* device handle in id */
+       uint64_t ino;
+       uint32_t xid;
+       uint32_t flags;
+       uint32_t mask;
+};
+
+struct vcmd_ctx_iattr_v1 {
+       const char __user *name;
+       uint32_t xid;
+       uint32_t flags;
+       uint32_t mask;
+};
+
+
+#ifdef __KERNEL__
+
+struct vcmd_ctx_iattr_v1_x32 {
+       uint32_t __user name;
+       uint32_t xid;
+       uint32_t flags;
+       uint32_t mask;
+};
+
+#include <linux/compiler.h>
+
+extern int vc_get_iattr_v0(uint32_t, void __user *);
+extern int vc_set_iattr_v0(uint32_t, void __user *);
+
+extern int vc_get_iattr(uint32_t, void __user *);
+extern int vc_set_iattr(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_INODE_CMD_H */
index 877bfb8..d5b8a3f 100644 (file)
@@ -2,7 +2,6 @@
 #define _VX_LEGACY_H
 
 #include "switch.h"
-#include "network.h"
 
 /*  compatibiliy vserver commands */
 
index d9e1eea..449a4fc 100644 (file)
-/* _VX_LIMIT_H defined below */
-
-#if    defined(__KERNEL__) && defined(_VX_INFO_DEF_)
-
-#include <asm/atomic.h>
-#include <asm/resource.h>
-
-/* context sub struct */
-
-#define NUM_LIMITS     20
-
-#define VLIMIT_NSOCK   16
-
-
-extern const char *vlimit_name[NUM_LIMITS];
-
-struct _vx_limit {
-       atomic_t ticks;
-
-       unsigned long rlim[NUM_LIMITS];         /* Context limit */
-       unsigned long rmax[NUM_LIMITS];         /* Context maximum */
-       atomic_t rcur[NUM_LIMITS];              /* Current value */
-       atomic_t lhit[NUM_LIMITS];              /* Limit hits */
-};
-
-static inline void vx_info_init_limit(struct _vx_limit *limit)
-{
-       int lim;
-
-       for (lim=0; lim<NUM_LIMITS; lim++) {
-               limit->rlim[lim] = RLIM_INFINITY;
-               limit->rmax[lim] = 0;
-               atomic_set(&limit->rcur[lim], 0);
-               atomic_set(&limit->lhit[lim], 0);
-       }
-}
-
-static inline void vx_info_exit_limit(struct _vx_limit *limit)
-{
-#ifdef CONFIG_VSERVER_DEBUG
-       unsigned long value;
-       unsigned int lim;
-
-       for (lim=0; lim<NUM_LIMITS; lim++) {
-               value = atomic_read(&limit->rcur[lim]);
-               if (value)
-                       printk("!!! limit: %p[%s,%d] = %ld on exit.\n",
-                               limit, vlimit_name[lim], lim, value);
-       }
-#endif
-}
-
-static inline void vx_limit_fixup(struct _vx_limit *limit)
-{
-       unsigned long value;
-       unsigned int lim;
-
-       for (lim=0; lim<NUM_LIMITS; lim++) {
-               value = atomic_read(&limit->rcur[lim]);
-               if (value > limit->rmax[lim])
-                       limit->rmax[lim] = value;
-               if (limit->rmax[lim] > limit->rlim[lim])
-                       limit->rmax[lim] = limit->rlim[lim];
-       }
-}
-
-#define VX_LIMIT_FMT   ":\t%10d\t%10ld\t%10ld\t%6d\n"
-
-#define VX_LIMIT_ARG(r)                                \
-               ,atomic_read(&limit->rcur[r])   \
-               ,limit->rmax[r]                 \
-               ,limit->rlim[r]                 \
-               ,atomic_read(&limit->lhit[r])
-
-static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
-{
-       vx_limit_fixup(limit);
-       return sprintf(buffer,
-               "PROC"  VX_LIMIT_FMT
-               "VM"    VX_LIMIT_FMT
-               "VML"   VX_LIMIT_FMT
-               "RSS"   VX_LIMIT_FMT
-               "FILES" VX_LIMIT_FMT
-               "SOCK"  VX_LIMIT_FMT
-               VX_LIMIT_ARG(RLIMIT_NPROC)
-               VX_LIMIT_ARG(RLIMIT_AS)
-               VX_LIMIT_ARG(RLIMIT_MEMLOCK)
-               VX_LIMIT_ARG(RLIMIT_RSS)
-               VX_LIMIT_ARG(RLIMIT_NOFILE)
-               VX_LIMIT_ARG(VLIMIT_NSOCK)
-               );
-}
-
-#else  /* _VX_INFO_DEF_ */
 #ifndef _VX_LIMIT_H
 #define _VX_LIMIT_H
 
-#include "switch.h"
-
-#define VXD_RLIMIT(r,l)                (VXD_CBIT(limit, (l)) && ((r) == (l)))
-
-/*  rlimit vserver commands */
-
-#define VCMD_get_rlimit                VC_CMD(RLIMIT, 1, 0)
-#define VCMD_set_rlimit                VC_CMD(RLIMIT, 2, 0)
-#define VCMD_get_rlimit_mask   VC_CMD(RLIMIT, 3, 0)
-
-struct vcmd_ctx_rlimit_v0 {
-       uint32_t id;
-       uint64_t minimum;
-       uint64_t softlimit;
-       uint64_t maximum;
-};
-
-struct vcmd_ctx_rlimit_mask_v0 {
-       uint32_t minimum;
-       uint32_t softlimit;
-       uint32_t maximum;
-};
-
-#define CRLIM_UNSET            (0ULL)
-#define CRLIM_INFINITY         (~0ULL)
-#define CRLIM_KEEP             (~1ULL)
-
 #ifdef __KERNEL__
 
-#include <linux/compiler.h>
-
-extern int vc_get_rlimit(uint32_t, void __user *);
-extern int vc_set_rlimit(uint32_t, void __user *);
-extern int vc_get_rlimit_mask(uint32_t, void __user *);
-
 struct sysinfo;
 
 void vx_vsi_meminfo(struct sysinfo *);
 void vx_vsi_swapinfo(struct sysinfo *);
 
+#define VXD_RLIMIT(r,l)                (VXD_CBIT(limit, (l)) && ((r) == (l)))
 
-#endif /* __KERNEL__ */
+#define NUM_LIMITS     24
 
-#endif /* _VX_LIMIT_H */
-#endif
+#define VLIMIT_NSOCK   16
+#define VLIMIT_OPENFD  17
+#define VLIMIT_ANON    18
+#define VLIMIT_SHMEM   19
 
+extern const char *vlimit_name[NUM_LIMITS];
 
+#endif /* __KERNEL__ */
+#endif /* _VX_LIMIT_H */
diff --git a/util-vserver/kernel/limit_cmd.h b/util-vserver/kernel/limit_cmd.h
new file mode 100644 (file)
index 0000000..a994d02
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef _VX_LIMIT_CMD_H
+#define _VX_LIMIT_CMD_H
+
+/*  rlimit vserver commands */
+
+#define VCMD_get_rlimit                VC_CMD(RLIMIT, 1, 0)
+#define VCMD_set_rlimit                VC_CMD(RLIMIT, 2, 0)
+#define VCMD_get_rlimit_mask   VC_CMD(RLIMIT, 3, 0)
+
+struct vcmd_ctx_rlimit_v0 {
+       uint32_t id;
+       uint64_t minimum;
+       uint64_t softlimit;
+       uint64_t maximum;
+};
+
+struct vcmd_ctx_rlimit_mask_v0 {
+       uint32_t minimum;
+       uint32_t softlimit;
+       uint32_t maximum;
+};
+
+#define CRLIM_UNSET            (0ULL)
+#define CRLIM_INFINITY         (~0ULL)
+#define CRLIM_KEEP             (~1ULL)
+
+#ifdef __KERNEL__
+
+#include <linux/compiler.h>
+
+extern int vc_get_rlimit(uint32_t, void __user *);
+extern int vc_set_rlimit(uint32_t, void __user *);
+extern int vc_get_rlimit_mask(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_LIMIT_CMD_H */
diff --git a/util-vserver/kernel/limit_def.h b/util-vserver/kernel/limit_def.h
new file mode 100644 (file)
index 0000000..bab1def
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef _VX_LIMIT_DEF_H
+#define _VX_LIMIT_DEF_H
+
+#include <asm/atomic.h>
+#include <asm/resource.h>
+
+#include "limit.h"
+
+/* context sub struct */
+
+struct _vx_limit {
+       atomic_t ticks;
+
+       unsigned long rlim[NUM_LIMITS];         /* Context limit */
+       unsigned long rmax[NUM_LIMITS];         /* Context maximum */
+       atomic_t rcur[NUM_LIMITS];              /* Current value */
+       atomic_t lhit[NUM_LIMITS];              /* Limit hits */
+};
+
+
+#endif /* _VX_LIMIT_DEF_H */
index 08167a1..8518a56 100644 (file)
@@ -46,8 +46,6 @@ struct namespace;
 struct fs_struct;
 struct vfsmount;
 
-extern int vx_check_vfsmount(struct vx_info *, struct vfsmount *);
-
 extern int vx_set_namespace(struct vx_info *, struct namespace *, struct fs_struct *);
 
 extern int vc_enter_namespace(uint32_t, void __user *);
@@ -55,4 +53,6 @@ extern int vc_cleanup_namespace(uint32_t, void __user *);
 extern int vc_set_namespace(uint32_t, void __user *);
 
 #endif /* __KERNEL__ */
+#else  /* _VX_NAMESPACE_H */
+#warning duplicate inclusion
 #endif /* _VX_NAMESPACE_H */
index e77866b..591ec21 100644 (file)
@@ -1,19 +1,21 @@
 #ifndef _VX_NETWORK_H
 #define _VX_NETWORK_H
 
+#include <linux/types.h>
+
+
 #define MAX_N_CONTEXT  65535   /* Arbitrary limit */
 
 #define NX_DYNAMIC_ID  ((uint32_t)-1)          /* id for dynamic context */
 
 #define NB_IPV4ROOT    16
 
+
 #ifdef __KERNEL__
 
 #include <linux/list.h>
 #include <linux/spinlock.h>
-#include <linux/utsname.h>
 #include <linux/rcupdate.h>
-#include <asm/resource.h>
 #include <asm/atomic.h>
 
 
@@ -43,14 +45,13 @@ struct nx_info {
 
 struct rcu_head;
 
-extern void rcu_free_nx_info(struct rcu_head *);
 extern void unhash_nx_info(struct nx_info *);
 
 extern struct nx_info *locate_nx_info(int);
 extern struct nx_info *locate_or_create_nx_info(int);
 
 extern int get_nid_list(int, unsigned int *, int);
-extern int nx_info_is_hashed(nid_t);
+extern int nid_is_hashed(nid_t);
 
 extern int nx_migrate_task(struct task_struct *, struct nx_info *);
 
@@ -64,89 +65,7 @@ struct sock;
 
 int nx_addr_conflict(struct nx_info *, uint32_t, struct sock *);
 
-
-#endif /* __KERNEL__ */
-
-#include "switch.h"
-
-/* vinfo commands */
-
-#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
-
-#ifdef __KERNEL__
-extern int vc_task_nid(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
-
-struct vcmd_nx_info_v0 {
-       uint32_t nid;
-       /* more to come */
-};
-
-#ifdef __KERNEL__
-extern int vc_nx_info(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_net_create                VC_CMD(VNET, 1, 0)
-#define VCMD_net_migrate       VC_CMD(NETMIG, 1, 0)
-
-#define VCMD_net_add           VC_CMD(NETALT, 1, 0)
-#define VCMD_net_remove                VC_CMD(NETALT, 2, 0)
-
-struct vcmd_net_nx_v0 {
-       uint16_t type;
-       uint16_t count;
-       uint32_t ip[4];
-       uint32_t mask[4];
-       /* more to come */
-};
-
-//     IPN_TYPE_IPV4
-
-
-#ifdef __KERNEL__
-extern int vc_net_create(uint32_t, void __user *);
-extern int vc_net_migrate(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_get_nflags                VC_CMD(FLAGS, 5, 0)
-#define VCMD_set_nflags                VC_CMD(FLAGS, 6, 0)
-
-struct vcmd_net_flags_v0 {
-       uint64_t flagword;
-       uint64_t mask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_nflags(uint32_t, void __user *);
-extern int vc_set_nflags(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define IPF_STATE_SETUP                (1ULL<<32)
-
-
-#define IPF_ONE_TIME           (0x0001ULL<<32)
-
-#define VCMD_get_ncaps         VC_CMD(FLAGS, 7, 0)
-#define VCMD_set_ncaps         VC_CMD(FLAGS, 8, 0)
-
-struct vcmd_net_caps_v0 {
-       uint64_t ncaps;
-       uint64_t cmask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_ncaps(uint32_t, void __user *);
-extern int vc_set_ncaps(uint32_t, void __user *);
-
 #endif /* __KERNEL__ */
-
-#define IPC_WOSSNAME           0x00000001
-
-
+#else  /* _VX_NETWORK_H */
+#warning duplicate inclusion
 #endif /* _VX_NETWORK_H */
diff --git a/util-vserver/kernel/network_cmd.h b/util-vserver/kernel/network_cmd.h
new file mode 100644 (file)
index 0000000..4403f54
--- /dev/null
@@ -0,0 +1,81 @@
+#ifndef _VX_NETWORK_CMD_H
+#define _VX_NETWORK_CMD_H
+
+
+/* vinfo commands */
+
+#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
+
+#ifdef __KERNEL__
+extern int vc_task_nid(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
+
+struct vcmd_nx_info_v0 {
+       uint32_t nid;
+       /* more to come */
+};
+
+#ifdef __KERNEL__
+extern int vc_nx_info(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_net_create                VC_CMD(VNET, 1, 0)
+#define VCMD_net_migrate       VC_CMD(NETMIG, 1, 0)
+
+#define VCMD_net_add           VC_CMD(NETALT, 1, 0)
+#define VCMD_net_remove                VC_CMD(NETALT, 2, 0)
+
+struct vcmd_net_nx_v0 {
+       uint16_t type;
+       uint16_t count;
+       uint32_t ip[4];
+       uint32_t mask[4];
+       /* more to come */
+};
+
+//     IPN_TYPE_IPV4
+
+
+#ifdef __KERNEL__
+extern int vc_net_create(uint32_t, void __user *);
+extern int vc_net_migrate(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_get_nflags                VC_CMD(FLAGS, 5, 0)
+#define VCMD_set_nflags                VC_CMD(FLAGS, 6, 0)
+
+struct vcmd_net_flags_v0 {
+       uint64_t flagword;
+       uint64_t mask;
+};
+
+#ifdef __KERNEL__
+extern int vc_get_nflags(uint32_t, void __user *);
+extern int vc_set_nflags(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define IPF_STATE_SETUP                (1ULL<<32)
+
+
+#define IPF_ONE_TIME           (0x0001ULL<<32)
+
+#define VCMD_get_ncaps         VC_CMD(FLAGS, 7, 0)
+#define VCMD_set_ncaps         VC_CMD(FLAGS, 8, 0)
+
+struct vcmd_net_caps_v0 {
+       uint64_t ncaps;
+       uint64_t cmask;
+};
+
+#ifdef __KERNEL__
+extern int vc_get_ncaps(uint32_t, void __user *);
+extern int vc_set_ncaps(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_CONTEXT_CMD_H */
index f7ac947..60569ab 100644 (file)
-/* _VX_SCHED_H defined below */
-
-#if    defined(__KERNEL__) && defined(_VX_INFO_DEF_)
-
-#include <linux/spinlock.h>
-#include <linux/jiffies.h>
-#include <linux/cpumask.h>
-#include <asm/atomic.h>
-#include <asm/param.h>
-
-struct _vx_ticks {
-       uint64_t user_ticks;            /* token tick events */
-       uint64_t sys_ticks;             /* token tick events */
-       uint64_t hold_ticks;            /* token ticks paused */
-       uint64_t unused[5];             /* cacheline ? */
-};
-
-/* context sub struct */
-
-struct _vx_sched {
-       atomic_t tokens;                /* number of CPU tokens */
-       spinlock_t tokens_lock;         /* lock for token bucket */
-
-       int fill_rate;                  /* Fill rate: add X tokens... */
-       int interval;                   /* Divisor:   per Y jiffies   */
-       int tokens_min;                 /* Limit:     minimum for unhold */
-       int tokens_max;                 /* Limit:     no more than N tokens */
-       uint32_t jiffies;               /* last time accounted */
-
-       int priority_bias;              /* bias offset for priority */
-       cpumask_t cpus_allowed;         /* cpu mask for context */
-
-       struct _vx_ticks cpu[NR_CPUS];
-};
-
-static inline void vx_info_init_sched(struct _vx_sched *sched)
-{
-       int i;
-
-       /* scheduling; hard code starting values as constants */
-       sched->fill_rate        = 1;
-       sched->interval         = 4;
-       sched->tokens_min       = HZ >> 4;
-       sched->tokens_max       = HZ >> 1;
-       sched->jiffies          = jiffies;
-       sched->tokens_lock      = SPIN_LOCK_UNLOCKED;
-
-       atomic_set(&sched->tokens, HZ >> 2);
-       sched->cpus_allowed     = CPU_MASK_ALL;
-       sched->priority_bias    = 0;
-
-       for_each_cpu(i) {
-               sched->cpu[i].user_ticks        = 0;
-               sched->cpu[i].sys_ticks         = 0;
-               sched->cpu[i].hold_ticks        = 0;
-       }
-}
-
-static inline void vx_info_exit_sched(struct _vx_sched *sched)
-{
-       return;
-}
-
-static inline int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
-{
-       int length = 0;
-       int i;
-
-       length += sprintf(buffer,
-               "Token:\t\t%8d\n"
-               "FillRate:\t%8d\n"
-               "Interval:\t%8d\n"
-               "TokensMin:\t%8d\n"
-               "TokensMax:\t%8d\n"
-               "PrioBias:\t%8d\n"
-               ,atomic_read(&sched->tokens)
-               ,sched->fill_rate
-               ,sched->interval
-               ,sched->tokens_min
-               ,sched->tokens_max
-               ,sched->priority_bias
-               );
-
-       for_each_online_cpu(i) {
-               length += sprintf(buffer + length,
-                       "cpu %d: %lld %lld %lld\n"
-                       ,i
-                       ,sched->cpu[i].user_ticks
-                       ,sched->cpu[i].sys_ticks
-                       ,sched->cpu[i].hold_ticks
-                       );
-       }
-
-       return length;
-}
-
-
-#else  /* _VX_INFO_DEF_ */
 #ifndef _VX_SCHED_H
 #define _VX_SCHED_H
 
-#include "switch.h"
-
-/*  sched vserver commands */
-
-#define VCMD_set_sched_v2      VC_CMD(SCHED, 1, 2)
-#define VCMD_set_sched         VC_CMD(SCHED, 1, 3)
-
-struct vcmd_set_sched_v2 {
-       int32_t fill_rate;
-       int32_t interval;
-       int32_t tokens;
-       int32_t tokens_min;
-       int32_t tokens_max;
-       uint64_t cpu_mask;
-};
-
-struct vcmd_set_sched_v3 {
-       uint32_t set_mask;
-       int32_t fill_rate;
-       int32_t interval;
-       int32_t tokens;
-       int32_t tokens_min;
-       int32_t tokens_max;
-       int32_t priority_bias;
-};
-
-
-#define VXSM_FILL_RATE         0x0001
-#define VXSM_INTERVAL          0x0002
-#define VXSM_TOKENS            0x0010
-#define VXSM_TOKENS_MIN                0x0020
-#define VXSM_TOKENS_MAX                0x0040
-#define VXSM_PRIO_BIAS         0x0100
-
-#define SCHED_KEEP             (-2)
-
 #ifdef __KERNEL__
 
-extern int vc_set_sched_v1(uint32_t, void __user *);
-extern int vc_set_sched_v2(uint32_t, void __user *);
-extern int vc_set_sched(uint32_t, void __user *);
+struct timespec;
 
+void vx_vsi_uptime(struct timespec *, struct timespec *);
 
-#define VAVAVOOM_RATIO         50
 
-#define MAX_PRIO_BIAS          20
-#define MIN_PRIO_BIAS          -20
+struct vx_info;
 
-#include "context.h"
+void vx_update_load(struct vx_info *);
 
 
-/* scheduling stuff */
+struct task_struct;
 
-int effective_vavavoom(struct task_struct *, int);
+int vx_effective_vavavoom(struct vx_info *, int);
 
 int vx_tokens_recalc(struct vx_info *);
 
-/* new stuff ;) */
-
-static inline int vx_tokens_avail(struct vx_info *vxi)
-{
-       return atomic_read(&vxi->sched.tokens);
-}
-
-static inline void vx_consume_token(struct vx_info *vxi)
-{
-       atomic_dec(&vxi->sched.tokens);
-}
-
-static inline int vx_need_resched(struct task_struct *p)
-{
-#ifdef CONFIG_VSERVER_HARDCPU
-       struct vx_info *vxi = p->vx_info;
-#endif
-       int slice = --p->time_slice;
-
-#ifdef CONFIG_VSERVER_HARDCPU
-       if (vxi) {
-               int tokens;
-
-               if ((tokens = vx_tokens_avail(vxi)) > 0)
-                       vx_consume_token(vxi);
-               /* for tokens > 0, one token was consumed */
-               if (tokens < 2)
-                       return 1;
-       }
-#endif
-       return (slice == 0);
-}
-
-
-static inline void vx_onhold_inc(struct vx_info *vxi)
-{
-       int onhold = atomic_read(&vxi->cvirt.nr_onhold);
-
-       atomic_inc(&vxi->cvirt.nr_onhold);
-       if (!onhold)
-               vxi->cvirt.onhold_last = jiffies;
-}
-
-static inline void __vx_onhold_update(struct vx_info *vxi)
-{
-       int cpu = smp_processor_id();
-       uint32_t now = jiffies;
-       uint32_t delta = now - vxi->cvirt.onhold_last;
-
-       vxi->cvirt.onhold_last = now;
-       vxi->sched.cpu[cpu].hold_ticks += delta;
-}
-
-static inline void vx_onhold_dec(struct vx_info *vxi)
-{
-       if (atomic_dec_and_test(&vxi->cvirt.nr_onhold))
-               __vx_onhold_update(vxi);
-}
-
 #endif /* __KERNEL__ */
-
+#else  /* _VX_SCHED_H */
+#warning duplicate inclusion
 #endif /* _VX_SCHED_H */
-#endif
diff --git a/util-vserver/kernel/sched_cmd.h b/util-vserver/kernel/sched_cmd.h
new file mode 100644 (file)
index 0000000..2a6f55b
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef _VX_SCHED_CMD_H
+#define _VX_SCHED_CMD_H
+
+/*  sched vserver commands */
+
+#define VCMD_set_sched_v2      VC_CMD(SCHED, 1, 2)
+#define VCMD_set_sched         VC_CMD(SCHED, 1, 3)
+
+struct vcmd_set_sched_v2 {
+       int32_t fill_rate;
+       int32_t interval;
+       int32_t tokens;
+       int32_t tokens_min;
+       int32_t tokens_max;
+       uint64_t cpu_mask;
+};
+
+struct vcmd_set_sched_v3 {
+       uint32_t set_mask;
+       int32_t fill_rate;
+       int32_t interval;
+       int32_t tokens;
+       int32_t tokens_min;
+       int32_t tokens_max;
+       int32_t priority_bias;
+};
+
+
+#define VXSM_FILL_RATE         0x0001
+#define VXSM_INTERVAL          0x0002
+#define VXSM_TOKENS            0x0010
+#define VXSM_TOKENS_MIN                0x0020
+#define VXSM_TOKENS_MAX                0x0040
+#define VXSM_PRIO_BIAS         0x0100
+
+#define SCHED_KEEP             (-2)
+
+#ifdef __KERNEL__
+
+#include <linux/compiler.h>
+
+extern int vc_set_sched_v1(uint32_t, void __user *);
+extern int vc_set_sched_v2(uint32_t, void __user *);
+extern int vc_set_sched(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_SCHED_CMD_H */
diff --git a/util-vserver/kernel/sched_def.h b/util-vserver/kernel/sched_def.h
new file mode 100644 (file)
index 0000000..3a57761
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef _VX_SCHED_DEF_H
+#define _VX_SCHED_DEF_H
+
+#include <linux/spinlock.h>
+#include <linux/jiffies.h>
+#include <linux/cpumask.h>
+#include <asm/atomic.h>
+#include <asm/param.h>
+
+
+struct _vx_ticks {
+       uint64_t user_ticks;            /* token tick events */
+       uint64_t sys_ticks;             /* token tick events */
+       uint64_t hold_ticks;            /* token ticks paused */
+       uint64_t unused[5];             /* cacheline ? */
+};
+
+/* context sub struct */
+
+struct _vx_sched {
+       atomic_t tokens;                /* number of CPU tokens */
+       spinlock_t tokens_lock;         /* lock for token bucket */
+
+       int fill_rate;                  /* Fill rate: add X tokens... */
+       int interval;                   /* Divisor:   per Y jiffies   */
+       int tokens_min;                 /* Limit:     minimum for unhold */
+       int tokens_max;                 /* Limit:     no more than N tokens */
+       uint32_t jiffies;               /* last time accounted */
+
+       int priority_bias;              /* bias offset for priority */
+       int vavavoom;                   /* last calculated vavavoom */
+
+       cpumask_t cpus_allowed;         /* cpu mask for context */
+
+       struct _vx_ticks cpu[NR_CPUS];
+};
+
+#endif /* _VX_SCHED_DEF_H */
index 5855b05..81f5c23 100644 (file)
@@ -39,7 +39,7 @@
   SPECIAL|EVENT  |       |       |       |FLAGS  |       | |       |       |
         |     48|     49|     50|     51|     52|     53| |     54|     55|
   -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
-  SPECIAL|       |       |       |       |RLIMIT |SYSCALL| |       |COMPAT |
+  SPECIAL|DEBUG  |       |       |       |RLIMIT |SYSCALL| |       |COMPAT |
         |     56|     57|     58|     59|     60|TEST 61| |     62|     63|
   -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
 
@@ -69,6 +69,7 @@
 #define VC_CAT_EVENT           48
 
 #define VC_CAT_FLAGS           52
+#define VC_CAT_DEBUG           56
 #define VC_CAT_RLIMIT          60
 
 #define VC_CAT_SYSTEST         61
@@ -76,7 +77,7 @@
 
 /*  interface version */
 
-#define VCI_VERSION            0x00010022
+#define VCI_VERSION            0x00010025
 
 
 /*  query version */
index 23908fd..5d1c6c1 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef _VX_XID_H
 #define _VX_XID_H
 
+#ifndef        CONFIG_VSERVER
+#warning config options missing
+#endif
 
 #define XID_TAG(in)    (!(in) || \
        (((struct inode *)in)->i_sb && \
@@ -57,7 +60,7 @@
 #define MAX_GID                0xFFFFFFFF
 
 #define INOXID_XID(tag, uid, gid, xid) \
-       ((tag) ? ((uid) >> 16) & 0xFFFF) : 0)
+       ((tag) ? (((uid) >> 16) & 0xFFFF) : 0)
 
 #define XIDINO_UID(tag, uid, xid)      \
        ((tag) ? (((uid) & 0xFFFF) | ((xid) << 16)) : (uid))
@@ -120,4 +123,7 @@ static inline gid_t vx_map_gid(gid_t gid)
 #define FIOC_SETXIDJ   _IOW('x', 3, long)
 #endif
 
+int vx_parse_xid(char *string, xid_t *xid, int remove);
+void vx_propagate_xid(struct nameidata *nd, struct inode *inode);
+
 #endif /* _VX_XID_H */