diff -NurpP linux-2.6.22.2-vs2.3.0.17.1/include/linux/sched.h linux-2.6.22.2-vs2.3.0.17.2/include/linux/sched.h --- linux-2.6.22.2-vs2.3.0.17.1/include/linux/sched.h 2007-08-05 20:53:13 +0200 +++ linux-2.6.22.2-vs2.3.0.17.2/include/linux/sched.h 2007-08-15 19:35:27 +0200 @@ -983,6 +983,7 @@ struct task_struct { xid_t xid; nid_t nid; + tag_t tag; seccomp_t seccomp; diff -NurpP linux-2.6.22.2-vs2.3.0.17.1/include/linux/vs_tag.h linux-2.6.22.2-vs2.3.0.17.2/include/linux/vs_tag.h --- linux-2.6.22.2-vs2.3.0.17.1/include/linux/vs_tag.h 2007-08-05 20:53:13 +0200 +++ linux-2.6.22.2-vs2.3.0.17.2/include/linux/vs_tag.h 2007-08-15 19:11:32 +0200 @@ -14,7 +14,7 @@ #define DX_ARG_MASK 0x0010 -#define dx_task_tag(t) ((t)->xid) +#define dx_task_tag(t) ((t)->tag) #define dx_current_tag() dx_task_tag(current) diff -NurpP linux-2.6.22.2-vs2.3.0.17.1/include/linux/vserver/switch.h linux-2.6.22.2-vs2.3.0.17.2/include/linux/vserver/switch.h --- linux-2.6.22.2-vs2.3.0.17.1/include/linux/vserver/switch.h 2007-08-05 20:53:13 +0200 +++ linux-2.6.22.2-vs2.3.0.17.2/include/linux/vserver/switch.h 2007-08-15 18:39:33 +0200 @@ -31,7 +31,7 @@ NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | | | 24| 25| 26| 27| 28| 29| | 30| 31| -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ - DISK | | | | |DLIMIT | | |INODE | | + DISK | | | |TAGMIG |DLIMIT | | |INODE | | VFS | 32| 33| 34| 35| 36| 37| | 38| 39| -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ OTHER |VSTAT | | | | | | |VINFO | | @@ -63,6 +63,7 @@ #define VC_CAT_NETMIG 27 #define VC_CAT_NETCTRL 28 +#define VC_CAT_TAGMIG 35 #define VC_CAT_DLIMIT 36 #define VC_CAT_INODE 38 diff -NurpP linux-2.6.22.2-vs2.3.0.17.1/include/linux/vserver/tag_cmd.h linux-2.6.22.2-vs2.3.0.17.2/include/linux/vserver/tag_cmd.h --- linux-2.6.22.2-vs2.3.0.17.1/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00 +0100 +++ linux-2.6.22.2-vs2.3.0.17.2/include/linux/vserver/tag_cmd.h 2007-08-15 20:16:43 +0200 @@ -0,0 +1,22 @@ +#ifndef _VX_TAG_CMD_H +#define _VX_TAG_CMD_H + + +/* vinfo commands */ + +#define VCMD_task_tag VC_CMD(VINFO, 3, 0) + +#ifdef __KERNEL__ +extern int vc_task_tag(uint32_t); + +#endif /* __KERNEL__ */ + +/* context commands */ + +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0) + +#ifdef __KERNEL__ +extern int vc_tag_migrate(uint32_t); + +#endif /* __KERNEL__ */ +#endif /* _VX_TAG_CMD_H */ diff -NurpP linux-2.6.22.2-vs2.3.0.17.1/kernel/vserver/Makefile linux-2.6.22.2-vs2.3.0.17.2/kernel/vserver/Makefile --- linux-2.6.22.2-vs2.3.0.17.1/kernel/vserver/Makefile 2007-08-05 20:53:13 +0200 +++ linux-2.6.22.2-vs2.3.0.17.2/kernel/vserver/Makefile 2007-08-15 20:47:26 +0200 @@ -6,7 +6,8 @@ obj-y += vserver.o vserver-y := switch.o context.o space.o sched.o network.o inode.o \ - limit.o cvirt.o cacct.o signal.o helper.o init.o dlimit.o + limit.o cvirt.o cacct.o signal.o helper.o init.o \ + dlimit.o tag.o vserver-$(CONFIG_INET) += inet.o vserver-$(CONFIG_PROC_FS) += proc.o diff -NurpP linux-2.6.22.2-vs2.3.0.17.1/kernel/vserver/switch.c linux-2.6.22.2-vs2.3.0.17.2/kernel/vserver/switch.c --- linux-2.6.22.2-vs2.3.0.17.1/kernel/vserver/switch.c 2007-08-05 20:53:13 +0200 +++ linux-2.6.22.2-vs2.3.0.17.2/kernel/vserver/switch.c 2007-08-15 20:15:05 +0200 @@ -13,6 +13,7 @@ * V0.06 added compat32 layer * V0.07 vcmd args and perms * V0.08 added status commands + * V0.09 added tag commands * */ @@ -50,6 +51,7 @@ int vc_get_vci(uint32_t id) #include #include #include +#include #include #include @@ -81,6 +83,9 @@ long do_vcmd(uint32_t cmd, uint32_t id, case VCMD_nx_info: return vc_nx_info(nxi, data); + case VCMD_task_tag: + return vc_task_tag(id); + /* this is version 1 */ case VCMD_set_space: return vc_set_space(vxi, data); @@ -210,6 +215,9 @@ long do_vcmd(uint32_t cmd, uint32_t id, case VCMD_net_migrate: return vc_net_migrate(nxi, data); + case VCMD_tag_migrate: + return vc_tag_migrate(id); + case VCMD_net_add: return vc_net_add(nxi, data); case VCMD_net_remove: diff -NurpP linux-2.6.22.2-vs2.3.0.17.1/kernel/vserver/tag.c linux-2.6.22.2-vs2.3.0.17.2/kernel/vserver/tag.c --- linux-2.6.22.2-vs2.3.0.17.1/kernel/vserver/tag.c 1970-01-01 01:00:00 +0100 +++ linux-2.6.22.2-vs2.3.0.17.2/kernel/vserver/tag.c 2007-08-15 20:48:24 +0200 @@ -0,0 +1,70 @@ +/* + * linux/kernel/vserver/tag.c + * + * Virtual Server: Shallow Tag Space + * + * Copyright (C) 2007 Herbert Pötzl + * + * V0.01 basic implementation + * + */ + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + + +int dx_migrate_task(struct task_struct *p, tag_t tag) +{ + if (!p) + BUG(); + + vxdprintk(VXD_CBIT(tag, 5), + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag); + + task_lock(p); + p->tag = tag; + task_unlock(p); + + vxdprintk(VXD_CBIT(tag, 5), + "moved task %p into [#%d]", p, tag); + return 0; +} + +/* vserver syscall commands below here */ + +/* taks xid and vx_info functions */ + + +int vc_task_tag(uint32_t id) +{ + tag_t tag; + + if (id) { + struct task_struct *tsk; + read_lock(&tasklist_lock); + tsk = find_task_by_real_pid(id); + tag = (tsk) ? tsk->tag : -ESRCH; + read_unlock(&tasklist_lock); + } else + tag = dx_current_tag(); + return tag; +} + + +int vc_tag_migrate(uint32_t tag) +{ + return dx_migrate_task(current, tag & 0xFFFF); +} + +