1 diff -NurpP --minimal linux-2.6.27.3/arch/alpha/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/Kconfig
2 --- linux-2.6.27.3/arch/alpha/Kconfig 2008-10-13 14:51:51.000000000 +0200
3 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/Kconfig 2008-10-13 14:54:20.000000000 +0200
4 @@ -667,6 +667,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.27.3/arch/alpha/kernel/entry.S linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/entry.S
14 --- linux-2.6.27.3/arch/alpha/kernel/entry.S 2008-07-13 23:51:29.000000000 +0200
15 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/entry.S 2008-10-13 14:54:20.000000000 +0200
16 @@ -872,24 +872,15 @@ sys_getxgid:
25 - /* See linux/kernel/timer.c sys_getppid for discussion
27 - ldq $3, TASK_GROUP_LEADER($2)
28 - ldq $4, TASK_REAL_PARENT($3)
29 - ldl $0, TASK_TGID($2)
30 -1: ldl $1, TASK_TGID($4)
34 - ldq $3, TASK_GROUP_LEADER($2)
35 - ldq $4, TASK_REAL_PARENT($3)
48 diff -NurpP --minimal linux-2.6.27.3/arch/alpha/kernel/osf_sys.c linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.27.3/arch/alpha/kernel/osf_sys.c 2008-10-13 14:51:51.000000000 +0200
50 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/osf_sys.c 2008-10-13 14:54:20.000000000 +0200
51 @@ -888,7 +888,7 @@ osf_gettimeofday(struct timeval32 __user
55 - do_gettimeofday(&ktv);
56 + vx_gettimeofday(&ktv);
57 if (put_tv32(tv, &ktv))
60 diff -NurpP --minimal linux-2.6.27.3/arch/alpha/kernel/ptrace.c linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.27.3/arch/alpha/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
62 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
64 #include <linux/slab.h>
65 #include <linux/security.h>
66 #include <linux/signal.h>
67 +#include <linux/vs_base.h>
69 #include <asm/uaccess.h>
70 #include <asm/pgtable.h>
71 diff -NurpP --minimal linux-2.6.27.3/arch/alpha/kernel/systbls.S linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/systbls.S
72 --- linux-2.6.27.3/arch/alpha/kernel/systbls.S 2008-07-13 23:51:29.000000000 +0200
73 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/systbls.S 2008-10-13 14:54:20.000000000 +0200
74 @@ -446,7 +446,7 @@ sys_call_table:
75 .quad sys_stat64 /* 425 */
78 - .quad sys_ni_syscall /* sys_vserver */
79 + .quad sys_vserver /* sys_vserver */
80 .quad sys_ni_syscall /* sys_mbind */
81 .quad sys_ni_syscall /* sys_get_mempolicy */
82 .quad sys_ni_syscall /* sys_set_mempolicy */
83 diff -NurpP --minimal linux-2.6.27.3/arch/alpha/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/traps.c
84 --- linux-2.6.27.3/arch/alpha/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
85 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
86 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
88 printk("CPU %d ", hard_smp_processor_id());
90 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
91 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
92 + task_pid_nr(current), current->xid, str, err);
93 dik_show_regs(regs, r9_15);
95 dik_show_trace((unsigned long *)(regs+1));
96 diff -NurpP --minimal linux-2.6.27.3/arch/alpha/mm/fault.c linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/mm/fault.c
97 --- linux-2.6.27.3/arch/alpha/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
98 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/alpha/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
99 @@ -193,8 +193,8 @@ do_page_fault(unsigned long address, uns
100 down_read(&mm->mmap_sem);
103 - printk(KERN_ALERT "VM: killing process %s(%d)\n",
104 - current->comm, task_pid_nr(current));
105 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
106 + current->comm, task_pid_nr(current), current->xid);
107 if (!user_mode(regs))
109 do_group_exit(SIGKILL);
110 diff -NurpP --minimal linux-2.6.27.3/arch/arm/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/arm/Kconfig
111 --- linux-2.6.27.3/arch/arm/Kconfig 2008-10-13 14:51:51.000000000 +0200
112 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/arm/Kconfig 2008-10-13 14:54:20.000000000 +0200
113 @@ -1240,6 +1240,8 @@ source "fs/Kconfig"
115 source "arch/arm/Kconfig.debug"
117 +source "kernel/vserver/Kconfig"
119 source "security/Kconfig"
121 source "crypto/Kconfig"
122 diff -NurpP --minimal linux-2.6.27.3/arch/arm/kernel/calls.S linux-2.6.27.3-vs2.3.0.35.7/arch/arm/kernel/calls.S
123 --- linux-2.6.27.3/arch/arm/kernel/calls.S 2008-10-13 14:51:52.000000000 +0200
124 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/arm/kernel/calls.S 2008-10-13 14:54:20.000000000 +0200
126 /* 310 */ CALL(sys_request_key)
128 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
129 -/* vserver */ CALL(sys_ni_syscall)
132 /* 315 */ CALL(sys_ioprio_get)
133 CALL(sys_inotify_init)
134 diff -NurpP --minimal linux-2.6.27.3/arch/arm/kernel/process.c linux-2.6.27.3-vs2.3.0.35.7/arch/arm/kernel/process.c
135 --- linux-2.6.27.3/arch/arm/kernel/process.c 2008-10-13 14:51:52.000000000 +0200
136 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/arm/kernel/process.c 2008-10-13 14:54:20.000000000 +0200
137 @@ -262,7 +262,8 @@ void __show_regs(struct pt_regs *regs)
138 void show_regs(struct pt_regs * regs)
141 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
142 + printk("Pid: %d[#%u], comm: %20s\n",
143 + task_pid_nr(current), current->xid, current->comm);
147 diff -NurpP --minimal linux-2.6.27.3/arch/arm/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/arm/kernel/traps.c
148 --- linux-2.6.27.3/arch/arm/kernel/traps.c 2008-10-13 14:51:52.000000000 +0200
149 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/arm/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
150 @@ -214,8 +214,8 @@ static void __die(const char *str, int e
151 str, err, ++die_counter);
154 - printk("Process %s (pid: %d, stack limit = 0x%p)\n",
155 - tsk->comm, task_pid_nr(tsk), thread + 1);
156 + printk("Process %s (pid: %d:#%u, stack limit = 0x%p)\n",
157 + tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
159 if (!user_mode(regs) || in_interrupt()) {
160 dump_mem("Stack: ", regs->ARM_sp,
161 diff -NurpP --minimal linux-2.6.27.3/arch/arm/mm/fault.c linux-2.6.27.3-vs2.3.0.35.7/arch/arm/mm/fault.c
162 --- linux-2.6.27.3/arch/arm/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
163 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/arm/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
164 @@ -292,7 +292,8 @@ do_page_fault(unsigned long addr, unsign
165 * happened to us that made us unable to handle
166 * the page fault gracefully.
168 - printk("VM: killing process %s\n", tsk->comm);
169 + printk("VM: killing process %s(%d:#%u)\n",
170 + tsk->comm, task_pid_nr(tsk), tsk->xid);
171 do_group_exit(SIGKILL);
174 diff -NurpP --minimal linux-2.6.27.3/arch/cris/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/cris/Kconfig
175 --- linux-2.6.27.3/arch/cris/Kconfig 2008-07-13 23:51:29.000000000 +0200
176 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/cris/Kconfig 2008-10-13 14:54:20.000000000 +0200
177 @@ -679,6 +679,8 @@ source "drivers/usb/Kconfig"
179 source "arch/cris/Kconfig.debug"
181 +source "kernel/vserver/Kconfig"
183 source "security/Kconfig"
185 source "crypto/Kconfig"
186 diff -NurpP --minimal linux-2.6.27.3/arch/frv/kernel/kernel_thread.S linux-2.6.27.3-vs2.3.0.35.7/arch/frv/kernel/kernel_thread.S
187 --- linux-2.6.27.3/arch/frv/kernel/kernel_thread.S 2008-07-13 23:51:29.000000000 +0200
188 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/frv/kernel/kernel_thread.S 2008-10-13 14:54:20.000000000 +0200
189 @@ -37,7 +37,7 @@ kernel_thread:
191 # start by forking the current process, but with shared VM
192 setlos.p #__NR_clone,gr7 ; syscall number
193 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
194 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
195 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
197 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
198 diff -NurpP --minimal linux-2.6.27.3/arch/h8300/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/h8300/Kconfig
199 --- linux-2.6.27.3/arch/h8300/Kconfig 2008-10-13 14:51:55.000000000 +0200
200 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/h8300/Kconfig 2008-10-13 14:54:20.000000000 +0200
201 @@ -219,6 +219,8 @@ source "fs/Kconfig"
203 source "arch/h8300/Kconfig.debug"
205 +source "kernel/vserver/Kconfig"
207 source "security/Kconfig"
209 source "crypto/Kconfig"
210 diff -NurpP --minimal linux-2.6.27.3/arch/ia64/ia32/ia32_entry.S linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/ia32/ia32_entry.S
211 --- linux-2.6.27.3/arch/ia64/ia32/ia32_entry.S 2008-10-13 14:51:55.000000000 +0200
212 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/ia32/ia32_entry.S 2008-10-13 14:54:20.000000000 +0200
213 @@ -446,7 +446,7 @@ ia32_syscall_table:
214 data8 sys_tgkill /* 270 */
215 data8 compat_sys_utimes
216 data8 sys32_fadvise64_64
217 - data8 sys_ni_syscall
218 + data8 sys32_vserver
220 data8 sys_ni_syscall /* 275 */
222 diff -NurpP --minimal linux-2.6.27.3/arch/ia64/ia32/sys_ia32.c linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/ia32/sys_ia32.c
223 --- linux-2.6.27.3/arch/ia64/ia32/sys_ia32.c 2008-10-13 14:51:55.000000000 +0200
224 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/ia32/sys_ia32.c 2008-10-13 14:54:20.000000000 +0200
225 @@ -1178,7 +1178,7 @@ sys32_gettimeofday (struct compat_timeva
229 - do_gettimeofday(&ktv);
230 + vx_gettimeofday(&ktv);
231 if (put_tv32(tv, &ktv))
234 diff -NurpP --minimal linux-2.6.27.3/arch/ia64/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/Kconfig
235 --- linux-2.6.27.3/arch/ia64/Kconfig 2008-10-13 14:51:55.000000000 +0200
236 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/Kconfig 2008-10-13 14:54:20.000000000 +0200
237 @@ -639,6 +639,8 @@ source "arch/ia64/hp/sim/Kconfig"
239 source "arch/ia64/Kconfig.debug"
241 +source "kernel/vserver/Kconfig"
243 source "security/Kconfig"
245 source "crypto/Kconfig"
246 diff -NurpP --minimal linux-2.6.27.3/arch/ia64/kernel/entry.S linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/entry.S
247 --- linux-2.6.27.3/arch/ia64/kernel/entry.S 2008-10-13 14:51:55.000000000 +0200
248 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/entry.S 2008-10-13 14:54:20.000000000 +0200
249 @@ -1647,7 +1647,7 @@ sys_call_table:
251 data8 sys_mq_getsetattr
253 - data8 sys_ni_syscall // reserved for vserver
255 data8 sys_waitid // 1270
257 data8 sys_request_key
258 diff -NurpP --minimal linux-2.6.27.3/arch/ia64/kernel/perfmon.c linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/perfmon.c
259 --- linux-2.6.27.3/arch/ia64/kernel/perfmon.c 2008-10-13 14:51:55.000000000 +0200
260 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/perfmon.c 2008-10-13 14:54:20.000000000 +0200
262 #include <linux/capability.h>
263 #include <linux/rcupdate.h>
264 #include <linux/completion.h>
265 +#include <linux/vs_memory.h>
267 #include <asm/errno.h>
268 #include <asm/intrinsics.h>
269 @@ -2376,7 +2377,7 @@ pfm_smpl_buffer_alloc(struct task_struct
271 insert_vm_struct(mm, vma);
273 - mm->total_vm += size >> PAGE_SHIFT;
274 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
275 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
277 up_write(&task->mm->mmap_sem);
278 diff -NurpP --minimal linux-2.6.27.3/arch/ia64/kernel/process.c linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/process.c
279 --- linux-2.6.27.3/arch/ia64/kernel/process.c 2008-10-13 14:51:55.000000000 +0200
280 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/process.c 2008-10-13 14:54:20.000000000 +0200
281 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
282 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
285 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
286 - smp_processor_id(), current->comm);
287 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
288 + current->xid, smp_processor_id(), current->comm);
289 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
290 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
291 init_utsname()->release);
292 diff -NurpP --minimal linux-2.6.27.3/arch/ia64/kernel/ptrace.c linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/ptrace.c
293 --- linux-2.6.27.3/arch/ia64/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
294 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
296 #include <linux/signal.h>
297 #include <linux/regset.h>
298 #include <linux/elf.h>
299 +#include <linux/vs_base.h>
301 #include <asm/pgtable.h>
302 #include <asm/processor.h>
303 diff -NurpP --minimal linux-2.6.27.3/arch/ia64/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/traps.c
304 --- linux-2.6.27.3/arch/ia64/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
305 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
306 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
309 if (++die.lock_owner_depth < 3) {
310 - printk("%s[%d]: %s %ld [%d]\n",
311 - current->comm, task_pid_nr(current), str, err, ++die_counter);
312 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
313 + current->comm, task_pid_nr(current), current->xid,
314 + str, err, ++die_counter);
315 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
318 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
319 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
320 last.time = current_jiffies + 5 * HZ;
322 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
323 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
324 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
325 + current->comm, task_pid_nr(current), current->xid,
326 + regs->cr_iip + ia64_psr(regs)->ri, isr);
330 diff -NurpP --minimal linux-2.6.27.3/arch/ia64/mm/fault.c linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/mm/fault.c
331 --- linux-2.6.27.3/arch/ia64/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
332 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/ia64/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
334 #include <linux/interrupt.h>
335 #include <linux/kprobes.h>
336 #include <linux/kdebug.h>
337 +#include <linux/vs_memory.h>
339 #include <asm/pgtable.h>
340 #include <asm/processor.h>
341 diff -NurpP --minimal linux-2.6.27.3/arch/m32r/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/m32r/kernel/traps.c
342 --- linux-2.6.27.3/arch/m32r/kernel/traps.c 2008-10-13 14:51:55.000000000 +0200
343 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/m32r/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
344 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
346 printk("SPI: %08lx\n", sp);
348 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
349 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
350 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
351 + current->comm, task_pid_nr(current), current->xid,
352 + 0xffff & i, 4096+(unsigned long)current);
355 * When in-kernel, we also print out the stack and code at the
356 diff -NurpP --minimal linux-2.6.27.3/arch/m68k/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/m68k/Kconfig
357 --- linux-2.6.27.3/arch/m68k/Kconfig 2008-10-13 14:51:55.000000000 +0200
358 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/m68k/Kconfig 2008-10-13 14:54:20.000000000 +0200
359 @@ -633,6 +633,8 @@ source "fs/Kconfig"
361 source "arch/m68k/Kconfig.debug"
363 +source "kernel/vserver/Kconfig"
365 source "security/Kconfig"
367 source "crypto/Kconfig"
368 diff -NurpP --minimal linux-2.6.27.3/arch/m68k/kernel/ptrace.c linux-2.6.27.3-vs2.3.0.35.7/arch/m68k/kernel/ptrace.c
369 --- linux-2.6.27.3/arch/m68k/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
370 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/m68k/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
372 #include <linux/ptrace.h>
373 #include <linux/user.h>
374 #include <linux/signal.h>
375 +#include <linux/vs_base.h>
377 #include <asm/uaccess.h>
378 #include <asm/page.h>
379 @@ -269,6 +270,8 @@ long arch_ptrace(struct task_struct *chi
380 ret = ptrace_request(child, request, addr, data);
383 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
388 diff -NurpP --minimal linux-2.6.27.3/arch/m68k/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/m68k/kernel/traps.c
389 --- linux-2.6.27.3/arch/m68k/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
390 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/m68k/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
391 @@ -909,8 +909,8 @@ void show_registers(struct pt_regs *regs
392 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
393 regs->d4, regs->d5, regs->a0, regs->a1);
395 - printk("Process %s (pid: %d, task=%p)\n",
396 - current->comm, task_pid_nr(current), current);
397 + printk("Process %s (pid: %d[#%u], task=%p)\n",
398 + current->comm, task_pid_nr(current), current->xid, current);
399 addr = (unsigned long)&fp->un;
400 printk("Frame format=%X ", regs->format);
401 switch (regs->format) {
402 diff -NurpP --minimal linux-2.6.27.3/arch/m68knommu/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/m68knommu/Kconfig
403 --- linux-2.6.27.3/arch/m68knommu/Kconfig 2008-10-13 14:51:55.000000000 +0200
404 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/m68knommu/Kconfig 2008-10-13 14:54:20.000000000 +0200
405 @@ -740,6 +740,8 @@ source "fs/Kconfig"
407 source "arch/m68knommu/Kconfig.debug"
409 +source "kernel/vserver/Kconfig"
411 source "security/Kconfig"
413 source "crypto/Kconfig"
414 diff -NurpP --minimal linux-2.6.27.3/arch/m68knommu/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/m68knommu/kernel/traps.c
415 --- linux-2.6.27.3/arch/m68knommu/kernel/traps.c 2008-10-13 14:51:55.000000000 +0200
416 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/m68knommu/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
417 @@ -79,8 +79,9 @@ void die_if_kernel(char *str, struct pt_
418 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
419 fp->d4, fp->d5, fp->a0, fp->a1);
421 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
422 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
423 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
424 + current->comm, task_pid_nr(current), current->xid,
425 + PAGE_SIZE+(unsigned long)current);
426 show_stack(NULL, (unsigned long *)(fp + 1));
427 add_taint(TAINT_DIE);
429 diff -NurpP --minimal linux-2.6.27.3/arch/mips/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/mips/Kconfig
430 --- linux-2.6.27.3/arch/mips/Kconfig 2008-10-13 14:51:55.000000000 +0200
431 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/mips/Kconfig 2008-10-13 14:54:20.000000000 +0200
432 @@ -2031,6 +2031,8 @@ source "fs/Kconfig"
434 source "arch/mips/Kconfig.debug"
436 +source "kernel/vserver/Kconfig"
438 source "security/Kconfig"
440 source "crypto/Kconfig"
441 diff -NurpP --minimal linux-2.6.27.3/arch/mips/kernel/linux32.c linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/linux32.c
442 --- linux-2.6.27.3/arch/mips/kernel/linux32.c 2008-10-13 14:51:56.000000000 +0200
443 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/linux32.c 2008-10-13 14:54:20.000000000 +0200
444 @@ -191,7 +191,7 @@ sys32_gettimeofday(struct compat_timeval
448 - do_gettimeofday(&ktv);
449 + vx_gettimeofday(&ktv);
450 if (put_tv32(tv, &ktv))
453 diff -NurpP --minimal linux-2.6.27.3/arch/mips/kernel/ptrace.c linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/ptrace.c
454 --- linux-2.6.27.3/arch/mips/kernel/ptrace.c 2008-10-13 14:51:56.000000000 +0200
455 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
457 #include <linux/security.h>
458 #include <linux/audit.h>
459 #include <linux/seccomp.h>
460 +#include <linux/vs_base.h>
462 #include <asm/byteorder.h>
464 @@ -171,6 +172,9 @@ long arch_ptrace(struct task_struct *chi
468 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
472 /* when I and D space are separate, these will need to be fixed. */
473 case PTRACE_PEEKTEXT: /* read word at location addr. */
474 diff -NurpP --minimal linux-2.6.27.3/arch/mips/kernel/scall32-o32.S linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/scall32-o32.S
475 --- linux-2.6.27.3/arch/mips/kernel/scall32-o32.S 2008-10-13 14:51:56.000000000 +0200
476 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/scall32-o32.S 2008-10-13 14:54:20.000000000 +0200
477 @@ -600,7 +600,7 @@ einval: li v0, -EINVAL
478 sys sys_mq_timedreceive 5
479 sys sys_mq_notify 2 /* 4275 */
480 sys sys_mq_getsetattr 3
481 - sys sys_ni_syscall 0 /* sys_vserver */
484 sys sys_ni_syscall 0 /* available, was setaltroot */
485 sys sys_add_key 5 /* 4280 */
486 diff -NurpP --minimal linux-2.6.27.3/arch/mips/kernel/scall64-64.S linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/scall64-64.S
487 --- linux-2.6.27.3/arch/mips/kernel/scall64-64.S 2008-10-13 14:51:56.000000000 +0200
488 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/scall64-64.S 2008-10-13 14:54:20.000000000 +0200
489 @@ -434,7 +434,7 @@ sys_call_table:
490 PTR sys_mq_timedreceive
492 PTR sys_mq_getsetattr /* 5235 */
493 - PTR sys_ni_syscall /* sys_vserver */
496 PTR sys_ni_syscall /* available, was setaltroot */
498 diff -NurpP --minimal linux-2.6.27.3/arch/mips/kernel/scall64-n32.S linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/scall64-n32.S
499 --- linux-2.6.27.3/arch/mips/kernel/scall64-n32.S 2008-10-13 14:51:56.000000000 +0200
500 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/scall64-n32.S 2008-10-13 14:54:20.000000000 +0200
501 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
502 PTR compat_sys_mq_timedreceive
503 PTR compat_sys_mq_notify
504 PTR compat_sys_mq_getsetattr
505 - PTR sys_ni_syscall /* 6240, sys_vserver */
506 + PTR sys32_vserver /* 6240 */
507 PTR compat_sys_waitid
508 PTR sys_ni_syscall /* available, was setaltroot */
510 diff -NurpP --minimal linux-2.6.27.3/arch/mips/kernel/scall64-o32.S linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/scall64-o32.S
511 --- linux-2.6.27.3/arch/mips/kernel/scall64-o32.S 2008-10-13 14:51:56.000000000 +0200
512 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/scall64-o32.S 2008-10-13 14:54:20.000000000 +0200
513 @@ -482,7 +482,7 @@ sys_call_table:
514 PTR compat_sys_mq_timedreceive
515 PTR compat_sys_mq_notify /* 4275 */
516 PTR compat_sys_mq_getsetattr
517 - PTR sys_ni_syscall /* sys_vserver */
520 PTR sys_ni_syscall /* available, was setaltroot */
521 PTR sys_add_key /* 4280 */
522 diff -NurpP --minimal linux-2.6.27.3/arch/mips/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/traps.c
523 --- linux-2.6.27.3/arch/mips/kernel/traps.c 2008-10-13 14:51:56.000000000 +0200
524 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/mips/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
525 @@ -328,9 +328,10 @@ void show_registers(const struct pt_regs
529 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
530 - current->comm, current->pid, current_thread_info(), current,
531 - field, current_thread_info()->tp_value);
532 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
533 + current->comm, task_pid_nr(current), current->xid,
534 + current_thread_info(), current,
535 + field, current_thread_info()->tp_value);
536 if (cpu_has_userlocal) {
539 diff -NurpP --minimal linux-2.6.27.3/arch/mips/mm/fault.c linux-2.6.27.3-vs2.3.0.35.7/arch/mips/mm/fault.c
540 --- linux-2.6.27.3/arch/mips/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
541 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/mips/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
542 @@ -178,7 +178,8 @@ out_of_memory:
543 down_read(&mm->mmap_sem);
546 - printk("VM: killing process %s\n", tsk->comm);
547 + printk("VM: killing process %s(%d:#%u)\n",
548 + tsk->comm, tsk->pid, tsk->xid);
550 do_group_exit(SIGKILL);
552 diff -NurpP --minimal linux-2.6.27.3/arch/parisc/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/Kconfig
553 --- linux-2.6.27.3/arch/parisc/Kconfig 2008-10-13 14:51:56.000000000 +0200
554 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/Kconfig 2008-10-13 14:54:20.000000000 +0200
555 @@ -279,6 +279,8 @@ source "fs/Kconfig"
557 source "arch/parisc/Kconfig.debug"
559 +source "kernel/vserver/Kconfig"
561 source "security/Kconfig"
563 source "crypto/Kconfig"
564 diff -NurpP --minimal linux-2.6.27.3/arch/parisc/kernel/syscall_table.S linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/kernel/syscall_table.S
565 --- linux-2.6.27.3/arch/parisc/kernel/syscall_table.S 2008-07-13 23:51:29.000000000 +0200
566 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/kernel/syscall_table.S 2008-10-13 14:54:20.000000000 +0200
568 ENTRY_COMP(mbind) /* 260 */
569 ENTRY_COMP(get_mempolicy)
570 ENTRY_COMP(set_mempolicy)
571 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
572 + ENTRY_DIFF(vserver)
574 ENTRY_SAME(request_key) /* 265 */
576 diff -NurpP --minimal linux-2.6.27.3/arch/parisc/kernel/sys_parisc32.c linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/kernel/sys_parisc32.c
577 --- linux-2.6.27.3/arch/parisc/kernel/sys_parisc32.c 2008-07-13 23:51:29.000000000 +0200
578 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/kernel/sys_parisc32.c 2008-10-13 14:54:20.000000000 +0200
579 @@ -203,11 +203,11 @@ static inline long get_ts32(struct times
581 sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
583 - extern void do_gettimeofday(struct timeval *tv);
584 + extern void vx_gettimeofday(struct timeval *tv);
588 - do_gettimeofday(&ktv);
589 + vx_gettimeofday(&ktv);
590 if (put_compat_timeval(tv, &ktv))
593 diff -NurpP --minimal linux-2.6.27.3/arch/parisc/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/kernel/traps.c
594 --- linux-2.6.27.3/arch/parisc/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
595 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
596 @@ -237,8 +237,9 @@ void die_if_kernel(char *str, struct pt_
600 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
601 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
602 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
603 + current->comm, task_pid_nr(current), current->xid,
604 + str, err, regs->iaoq[0]);
605 #ifdef PRINT_USER_FAULTS
606 /* XXX for debugging only */
608 @@ -270,8 +271,8 @@ KERN_CRIT " || |
609 pdc_console_restart();
612 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
613 - current->comm, task_pid_nr(current), str, err);
614 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
615 + current->comm, task_pid_nr(current), current->xid, str, err);
617 /* Wot's wrong wif bein' racy? */
618 if (current->thread.flags & PARISC_KERNEL_DEATH) {
619 diff -NurpP --minimal linux-2.6.27.3/arch/parisc/mm/fault.c linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/mm/fault.c
620 --- linux-2.6.27.3/arch/parisc/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
621 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/parisc/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
622 @@ -210,8 +210,9 @@ bad_area:
624 #ifdef PRINT_USER_FAULTS
625 printk(KERN_DEBUG "\n");
626 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
627 - task_pid_nr(tsk), tsk->comm, code, address);
628 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
629 + "command='%s' type=%lu address=0x%08lx\n",
630 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
632 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
633 vma->vm_start, vma->vm_end);
634 @@ -261,7 +262,8 @@ no_context:
637 up_read(&mm->mmap_sem);
638 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
639 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
640 + current->comm, current->pid, current->xid);
642 do_group_exit(SIGKILL);
644 diff -NurpP --minimal linux-2.6.27.3/arch/powerpc/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/Kconfig
645 --- linux-2.6.27.3/arch/powerpc/Kconfig 2008-10-13 14:51:56.000000000 +0200
646 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/Kconfig 2008-10-13 14:54:20.000000000 +0200
647 @@ -835,6 +835,8 @@ source "lib/Kconfig"
649 source "arch/powerpc/Kconfig.debug"
651 +source "kernel/vserver/Kconfig"
653 source "security/Kconfig"
656 diff -NurpP --minimal linux-2.6.27.3/arch/powerpc/kernel/irq.c linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/irq.c
657 --- linux-2.6.27.3/arch/powerpc/kernel/irq.c 2008-10-13 14:51:56.000000000 +0200
658 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/irq.c 2008-10-13 14:54:20.000000000 +0200
660 #include <linux/bootmem.h>
661 #include <linux/pci.h>
662 #include <linux/debugfs.h>
663 +#include <linux/vs_context.h>
665 #include <asm/uaccess.h>
666 #include <asm/system.h>
667 diff -NurpP --minimal linux-2.6.27.3/arch/powerpc/kernel/process.c linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/process.c
668 --- linux-2.6.27.3/arch/powerpc/kernel/process.c 2008-10-13 14:51:56.000000000 +0200
669 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/process.c 2008-10-13 14:54:20.000000000 +0200
670 @@ -513,8 +513,9 @@ void show_regs(struct pt_regs * regs)
672 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
674 - printk("TASK = %p[%d] '%s' THREAD: %p",
675 - current, task_pid_nr(current), current->comm, task_thread_info(current));
676 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
677 + current, task_pid_nr(current), current->xid,
678 + current->comm, task_thread_info(current));
681 printk(" CPU: %d", raw_smp_processor_id());
682 diff -NurpP --minimal linux-2.6.27.3/arch/powerpc/kernel/sys_ppc32.c linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/sys_ppc32.c
683 --- linux-2.6.27.3/arch/powerpc/kernel/sys_ppc32.c 2008-10-13 14:51:56.000000000 +0200
684 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/sys_ppc32.c 2008-10-13 14:54:20.000000000 +0200
685 @@ -147,7 +147,7 @@ asmlinkage long compat_sys_gettimeofday(
689 - do_gettimeofday(&ktv);
690 + vx_gettimeofday(&ktv);
691 if (put_tv32(tv, &ktv))
694 diff -NurpP --minimal linux-2.6.27.3/arch/powerpc/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/traps.c
695 --- linux-2.6.27.3/arch/powerpc/kernel/traps.c 2008-10-13 14:51:56.000000000 +0200
696 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
697 @@ -941,8 +941,9 @@ void nonrecoverable_exception(struct pt_
699 void trace_syscall(struct pt_regs *regs)
701 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
702 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
703 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
704 + current, task_pid_nr(current), current->xid,
705 + regs->nip, regs->link, regs->gpr[0],
706 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
709 diff -NurpP --minimal linux-2.6.27.3/arch/powerpc/kernel/vdso.c linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/vdso.c
710 --- linux-2.6.27.3/arch/powerpc/kernel/vdso.c 2008-10-13 14:51:56.000000000 +0200
711 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/kernel/vdso.c 2008-10-13 14:54:20.000000000 +0200
713 #include <linux/security.h>
714 #include <linux/bootmem.h>
715 #include <linux/lmb.h>
716 +#include <linux/vs_memory.h>
718 #include <asm/pgtable.h>
719 #include <asm/system.h>
720 diff -NurpP --minimal linux-2.6.27.3/arch/powerpc/mm/fault.c linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/mm/fault.c
721 --- linux-2.6.27.3/arch/powerpc/mm/fault.c 2008-10-13 14:51:56.000000000 +0200
722 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/powerpc/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
723 @@ -354,7 +354,8 @@ out_of_memory:
724 down_read(&mm->mmap_sem);
727 - printk("VM: killing process %s\n", current->comm);
728 + printk("VM: killing process %s(%d:#%u)\n",
729 + current->comm, current->pid, current->xid);
731 do_group_exit(SIGKILL);
733 diff -NurpP --minimal linux-2.6.27.3/arch/s390/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/s390/Kconfig
734 --- linux-2.6.27.3/arch/s390/Kconfig 2008-10-13 14:51:57.000000000 +0200
735 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/s390/Kconfig 2008-10-13 14:54:20.000000000 +0200
736 @@ -587,6 +587,8 @@ source "fs/Kconfig"
738 source "arch/s390/Kconfig.debug"
740 +source "kernel/vserver/Kconfig"
742 source "security/Kconfig"
744 source "crypto/Kconfig"
745 diff -NurpP --minimal linux-2.6.27.3/arch/s390/kernel/compat_linux.c linux-2.6.27.3-vs2.3.0.35.7/arch/s390/kernel/compat_linux.c
746 --- linux-2.6.27.3/arch/s390/kernel/compat_linux.c 2008-07-13 23:51:29.000000000 +0200
747 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/s390/kernel/compat_linux.c 2008-10-13 14:54:20.000000000 +0200
748 @@ -566,7 +566,7 @@ asmlinkage long sys32_gettimeofday(struc
752 - do_gettimeofday(&ktv);
753 + vx_gettimeofday(&ktv);
754 if (put_tv32(tv, &ktv))
757 diff -NurpP --minimal linux-2.6.27.3/arch/s390/kernel/ptrace.c linux-2.6.27.3-vs2.3.0.35.7/arch/s390/kernel/ptrace.c
758 --- linux-2.6.27.3/arch/s390/kernel/ptrace.c 2008-10-13 14:51:57.000000000 +0200
759 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/s390/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
761 #include <linux/signal.h>
762 #include <linux/elf.h>
763 #include <linux/regset.h>
764 +#include <linux/vs_base.h>
766 #include <asm/segment.h>
767 #include <asm/page.h>
768 diff -NurpP --minimal linux-2.6.27.3/arch/s390/kernel/syscalls.S linux-2.6.27.3-vs2.3.0.35.7/arch/s390/kernel/syscalls.S
769 --- linux-2.6.27.3/arch/s390/kernel/syscalls.S 2008-10-13 14:51:57.000000000 +0200
770 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/s390/kernel/syscalls.S 2008-10-13 14:54:20.000000000 +0200
771 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
772 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
773 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
774 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
775 -NI_SYSCALL /* reserved for vserver */
776 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
777 SYSCALL(s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
778 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
779 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
780 diff -NurpP --minimal linux-2.6.27.3/arch/s390/mm/fault.c linux-2.6.27.3-vs2.3.0.35.7/arch/s390/mm/fault.c
781 --- linux-2.6.27.3/arch/s390/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
782 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/s390/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
783 @@ -216,7 +216,8 @@ static int do_out_of_memory(struct pt_re
784 down_read(&mm->mmap_sem);
787 - printk("VM: killing process %s\n", tsk->comm);
788 + printk("VM: killing process %s(%d:#%u)\n",
789 + tsk->comm, tsk->pid, tsk->xid);
790 if (regs->psw.mask & PSW_MASK_PSTATE)
791 do_group_exit(SIGKILL);
792 do_no_context(regs, error_code, address);
793 diff -NurpP --minimal linux-2.6.27.3/arch/sh/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/sh/Kconfig
794 --- linux-2.6.27.3/arch/sh/Kconfig 2008-10-13 14:51:57.000000000 +0200
795 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sh/Kconfig 2008-10-13 14:54:20.000000000 +0200
796 @@ -747,6 +747,8 @@ source "fs/Kconfig"
798 source "arch/sh/Kconfig.debug"
800 +source "kernel/vserver/Kconfig"
802 source "security/Kconfig"
804 source "crypto/Kconfig"
805 diff -NurpP --minimal linux-2.6.27.3/arch/sh/kernel/irq.c linux-2.6.27.3-vs2.3.0.35.7/arch/sh/kernel/irq.c
806 --- linux-2.6.27.3/arch/sh/kernel/irq.c 2008-10-13 14:51:57.000000000 +0200
807 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sh/kernel/irq.c 2008-10-13 14:54:20.000000000 +0200
809 #include <linux/module.h>
810 #include <linux/kernel_stat.h>
811 #include <linux/seq_file.h>
812 +#include <linux/vs_context.h>
813 #include <asm/processor.h>
814 #include <asm/machvec.h>
815 #include <asm/uaccess.h>
816 diff -NurpP --minimal linux-2.6.27.3/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.27.3-vs2.3.0.35.7/arch/sh/kernel/vsyscall/vsyscall.c
817 --- linux-2.6.27.3/arch/sh/kernel/vsyscall/vsyscall.c 2008-07-13 23:51:29.000000000 +0200
818 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sh/kernel/vsyscall/vsyscall.c 2008-10-13 14:54:20.000000000 +0200
820 #include <linux/elf.h>
821 #include <linux/sched.h>
822 #include <linux/err.h>
823 +#include <linux/vs_memory.h>
826 * Should the kernel map a VDSO page into processes and pass its
827 diff -NurpP --minimal linux-2.6.27.3/arch/sparc/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/Kconfig
828 --- linux-2.6.27.3/arch/sparc/Kconfig 2008-10-13 14:51:58.000000000 +0200
829 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/Kconfig 2008-10-13 14:54:20.000000000 +0200
830 @@ -305,6 +305,8 @@ source "fs/Kconfig"
832 source "arch/sparc/Kconfig.debug"
834 +source "kernel/vserver/Kconfig"
836 source "security/Kconfig"
838 source "crypto/Kconfig"
839 diff -NurpP --minimal linux-2.6.27.3/arch/sparc/kernel/ptrace.c linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/kernel/ptrace.c
840 --- linux-2.6.27.3/arch/sparc/kernel/ptrace.c 2008-10-13 14:51:58.000000000 +0200
841 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
843 #include <linux/regset.h>
844 #include <linux/elf.h>
845 #include <linux/tracehook.h>
846 +#include <linux/vs_base.h>
848 #include <asm/pgtable.h>
849 #include <asm/system.h>
850 diff -NurpP --minimal linux-2.6.27.3/arch/sparc/kernel/systbls.S linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/kernel/systbls.S
851 --- linux-2.6.27.3/arch/sparc/kernel/systbls.S 2008-10-13 14:51:58.000000000 +0200
852 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/kernel/systbls.S 2008-10-13 14:54:20.000000000 +0200
853 @@ -70,7 +70,7 @@ sys_call_table:
854 /*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
855 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
856 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
857 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
858 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
859 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
860 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
861 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
862 diff -NurpP --minimal linux-2.6.27.3/arch/sparc/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/kernel/traps.c
863 --- linux-2.6.27.3/arch/sparc/kernel/traps.c 2008-10-13 14:51:58.000000000 +0200
864 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
865 @@ -95,7 +95,8 @@ void die_if_kernel(char *str, struct pt_
869 - printk("%s(%d): %s [#%d]\n", current->comm, task_pid_nr(current), str, ++die_counter);
870 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
871 + task_pid_nr(current), current->xid, str, ++die_counter);
873 add_taint(TAINT_DIE);
875 diff -NurpP --minimal linux-2.6.27.3/arch/sparc/mm/fault.c linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/mm/fault.c
876 --- linux-2.6.27.3/arch/sparc/mm/fault.c 2008-10-13 14:51:58.000000000 +0200
877 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
878 @@ -318,7 +318,8 @@ no_context:
881 up_read(&mm->mmap_sem);
882 - printk("VM: killing process %s\n", tsk->comm);
883 + printk("VM: killing process %s(%d:#%u)\n",
884 + tsk->comm, tsk->pid, tsk->xid);
886 do_group_exit(SIGKILL);
888 diff -NurpP --minimal linux-2.6.27.3/arch/sparc64/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/Kconfig
889 --- linux-2.6.27.3/arch/sparc64/Kconfig 2008-10-13 14:51:58.000000000 +0200
890 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/Kconfig 2008-10-13 14:54:20.000000000 +0200
891 @@ -403,6 +403,8 @@ source "fs/Kconfig"
893 source "arch/sparc64/Kconfig.debug"
895 +source "kernel/vserver/Kconfig"
897 source "security/Kconfig"
899 source "crypto/Kconfig"
900 diff -NurpP --minimal linux-2.6.27.3/arch/sparc64/kernel/ptrace.c linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/kernel/ptrace.c
901 --- linux-2.6.27.3/arch/sparc64/kernel/ptrace.c 2008-10-13 14:51:58.000000000 +0200
902 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
904 #include <linux/tracehook.h>
905 #include <linux/compat.h>
906 #include <linux/elf.h>
907 +#include <linux/vs_base.h>
910 #include <asm/pgtable.h>
911 diff -NurpP --minimal linux-2.6.27.3/arch/sparc64/kernel/sys_sparc32.c linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/kernel/sys_sparc32.c
912 --- linux-2.6.27.3/arch/sparc64/kernel/sys_sparc32.c 2008-10-13 14:51:58.000000000 +0200
913 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/kernel/sys_sparc32.c 2008-10-13 14:54:20.000000000 +0200
914 @@ -532,7 +532,7 @@ asmlinkage long sys32_gettimeofday(struc
918 - do_gettimeofday(&ktv);
919 + vx_gettimeofday(&ktv);
920 if (put_tv32(tv, &ktv))
923 diff -NurpP --minimal linux-2.6.27.3/arch/sparc64/kernel/systbls.S linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/kernel/systbls.S
924 --- linux-2.6.27.3/arch/sparc64/kernel/systbls.S 2008-10-13 14:51:58.000000000 +0200
925 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/kernel/systbls.S 2008-10-13 14:54:20.000000000 +0200
926 @@ -71,7 +71,7 @@ sys_call_table32:
927 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
928 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
929 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
930 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
931 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
932 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
933 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
934 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
935 @@ -145,7 +145,7 @@ sys_call_table:
936 /*250*/ .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
937 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
938 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
939 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
940 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
941 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
942 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
943 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
944 diff -NurpP --minimal linux-2.6.27.3/arch/sparc64/kernel/traps.c linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/kernel/traps.c
945 --- linux-2.6.27.3/arch/sparc64/kernel/traps.c 2008-10-13 14:51:58.000000000 +0200
946 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
947 @@ -2186,7 +2186,8 @@ void die_if_kernel(char *str, struct pt_
951 - printk("%s(%d): %s [#%d]\n", current->comm, task_pid_nr(current), str, ++die_counter);
952 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
953 + task_pid_nr(current), current->xid, str, ++die_counter);
954 notify_die(DIE_OOPS, str, regs, 0, 255, SIGSEGV);
955 __asm__ __volatile__("flushw");
957 diff -NurpP --minimal linux-2.6.27.3/arch/sparc64/mm/fault.c linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/mm/fault.c
958 --- linux-2.6.27.3/arch/sparc64/mm/fault.c 2008-10-13 14:51:58.000000000 +0200
959 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/sparc64/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
960 @@ -452,7 +452,8 @@ handle_kernel_fault:
962 insn = get_fault_insn(regs, insn);
963 up_read(&mm->mmap_sem);
964 - printk("VM: killing process %s\n", current->comm);
965 + printk("VM: killing process %s(%d:#%u)\n",
966 + current->comm, current->pid, current->xid);
967 if (!(regs->tstate & TSTATE_PRIV))
968 do_group_exit(SIGKILL);
969 goto handle_kernel_fault;
970 diff -NurpP --minimal linux-2.6.27.3/arch/um/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/um/Kconfig
971 --- linux-2.6.27.3/arch/um/Kconfig 2008-07-13 23:51:29.000000000 +0200
972 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/um/Kconfig 2008-10-13 14:54:20.000000000 +0200
973 @@ -245,6 +245,8 @@ source "drivers/connector/Kconfig"
977 +source "kernel/vserver/Kconfig"
979 source "security/Kconfig"
981 source "crypto/Kconfig"
982 diff -NurpP --minimal linux-2.6.27.3/arch/um/kernel/trap.c linux-2.6.27.3-vs2.3.0.35.7/arch/um/kernel/trap.c
983 --- linux-2.6.27.3/arch/um/kernel/trap.c 2008-07-13 23:51:29.000000000 +0200
984 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/um/kernel/trap.c 2008-10-13 14:54:20.000000000 +0200
985 @@ -215,7 +215,8 @@ unsigned long segv(struct faultinfo fi,
986 current->thread.arch.faultinfo = fi;
987 force_sig_info(SIGBUS, &si, current);
988 } else if (err == -ENOMEM) {
989 - printk(KERN_INFO "VM: killing process %s\n", current->comm);
990 + printk(KERN_INFO "VM: killing process %s(%d:#%u)\n",
991 + current->comm, task_pid_nr(current), current->xid);
994 BUG_ON(err != -EFAULT);
995 diff -NurpP --minimal linux-2.6.27.3/arch/x86/ia32/ia32entry.S linux-2.6.27.3-vs2.3.0.35.7/arch/x86/ia32/ia32entry.S
996 --- linux-2.6.27.3/arch/x86/ia32/ia32entry.S 2008-10-13 14:51:58.000000000 +0200
997 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/x86/ia32/ia32entry.S 2008-10-13 14:54:20.000000000 +0200
998 @@ -772,7 +772,7 @@ ia32_sys_call_table:
999 .quad sys_tgkill /* 270 */
1000 .quad compat_sys_utimes
1001 .quad sys32_fadvise64_64
1002 - .quad quiet_ni_syscall /* sys_vserver */
1003 + .quad sys32_vserver
1005 .quad compat_sys_get_mempolicy /* 275 */
1006 .quad sys_set_mempolicy
1007 diff -NurpP --minimal linux-2.6.27.3/arch/x86/Kconfig linux-2.6.27.3-vs2.3.0.35.7/arch/x86/Kconfig
1008 --- linux-2.6.27.3/arch/x86/Kconfig 2008-10-13 14:51:58.000000000 +0200
1009 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/x86/Kconfig 2008-10-13 14:54:20.000000000 +0200
1010 @@ -1788,6 +1788,8 @@ source "fs/Kconfig"
1012 source "arch/x86/Kconfig.debug"
1014 +source "kernel/vserver/Kconfig"
1016 source "security/Kconfig"
1018 source "crypto/Kconfig"
1019 diff -NurpP --minimal linux-2.6.27.3/arch/x86/kernel/syscall_table_32.S linux-2.6.27.3-vs2.3.0.35.7/arch/x86/kernel/syscall_table_32.S
1020 --- linux-2.6.27.3/arch/x86/kernel/syscall_table_32.S 2008-10-13 14:51:58.000000000 +0200
1021 +++ linux-2.6.27.3-vs2.3.0.35.7/arch/x86/kernel/syscall_table_32.S 2008-10-13 14:54:20.000000000 +0200
1022 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
1023 .long sys_tgkill /* 270 */
1025 .long sys_fadvise64_64
1026 - .long sys_ni_syscall /* sys_vserver */
1029 .long sys_get_mempolicy
1030 .long sys_set_mempolicy
1031 diff -NurpP --minimal linux-2.6.27.3/Documentation/vserver/debug.txt linux-2.6.27.3-vs2.3.0.35.7/Documentation/vserver/debug.txt
1032 --- linux-2.6.27.3/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1033 +++ linux-2.6.27.3-vs2.3.0.35.7/Documentation/vserver/debug.txt 2008-10-13 14:54:20.000000000 +0200
1038 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
1039 + "vx_rmap_tgid: %p/%llx: %d -> %d"
1043 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
1044 + "FREE (%p,#%d)%c inode"
1045 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
1046 + "FREE (%p,#%d)%c %lld bytes"
1047 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
1048 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
1049 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
1050 + "rcu_free_dl_info(%p)"
1051 + 4 10 "alloc_dl_info(%p,%d) = %p"
1052 + "dealloc_dl_info(%p)"
1053 + "get_dl_info(%p[#%d.%d])"
1054 + "put_dl_info(%p[#%d.%d])"
1055 + 5 20 "alloc_dl_info(%p,%d)*"
1056 + 6 40 "__hash_dl_info: %p[#%d]"
1057 + "__unhash_dl_info: %p[#%d]"
1058 + 7 80 "locate_dl_info(%p,#%d) = %p"
1062 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
1063 + "new_dqhash: %p [#0x%08x]"
1064 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
1065 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
1066 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
1067 + "vroot_get_real_bdev not set"
1068 + 1 2 "cow_break_link(»%s«)"
1069 + "temp copy »%s«"
1070 + 2 4 "dentry_open(new): %p"
1071 + "dentry_open(old): %p"
1072 + "lookup_create(new): %p"
1074 + "path_lookup(old): %d"
1075 + "vfs_create(new): %d"
1077 + "vfs_sendfile: %d"
1078 + 3 8 "fput(new_file=%p[#%d])"
1079 + "fput(old_file=%p[#%d])"
1080 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
1081 + "vx_info_kill(%p[#%d],%d,%d)*"
1082 + 5 20 "vs_reboot(%p[#%d],%d)"
1083 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
1087 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
1088 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
1089 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
1090 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
1091 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
1092 + 6 40 "sk,egf: %p [#%d] (from %d)"
1093 + "sk,egn: %p [#%d] (from %d)"
1094 + "sk,req: %p [#%d] (from %d)"
1095 + "sk: %p [#%d] (from %d)"
1096 + "tw: %p [#%d] (from %d)"
1097 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
1098 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
1102 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
1103 + "alloc_nx_info(%d) = %p"
1104 + "create_nx_info(%d) (dynamic rejected)"
1105 + "create_nx_info(%d) = %p (already there)"
1106 + "create_nx_info(%d) = %p (new)"
1107 + "dealloc_nx_info(%p)"
1108 + 1 2 "alloc_nx_info(%d)*"
1109 + "create_nx_info(%d)*"
1110 + 2 4 "get_nx_info(%p[#%d.%d])"
1111 + "put_nx_info(%p[#%d.%d])"
1112 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
1113 + "clr_nx_info(%p[#%d.%d])"
1114 + "init_nx_info(%p[#%d.%d])"
1115 + "release_nx_info(%p[#%d.%d.%d]) %p"
1116 + "set_nx_info(%p[#%d.%d])"
1117 + 4 10 "__hash_nx_info: %p[#%d]"
1118 + "__nx_dynamic_id: [#%d]"
1119 + "__unhash_nx_info: %p[#%d.%d.%d]"
1120 + 5 20 "moved task %p into nxi:%p[#%d]"
1121 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
1122 + "task_get_nx_info(%p)"
1123 + 6 40 "nx_clear_persistent(%p[#%d])"
1127 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
1128 + 1 2 "quota_sync_dqh(%p,%d)"
1129 + "sync_dquots(%p,%d)"
1130 + "sync_dquots_dqh(%p,%d)"
1131 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
1135 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
1136 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
1137 + 4 10 "%s: (%s %s) returned %s with %d"
1141 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
1142 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
1146 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
1147 + "alloc_vx_info(%d) = %p"
1148 + "alloc_vx_info(%d)*"
1149 + "create_vx_info(%d) (dynamic rejected)"
1150 + "create_vx_info(%d) = %p (already there)"
1151 + "create_vx_info(%d) = %p (new)"
1152 + "dealloc_vx_info(%p)"
1153 + "loc_vx_info(%d) = %p (found)"
1154 + "loc_vx_info(%d) = %p (new)"
1155 + "loc_vx_info(%d) = %p (not available)"
1156 + 1 2 "create_vx_info(%d)*"
1157 + "loc_vx_info(%d)*"
1158 + 2 4 "get_vx_info(%p[#%d.%d])"
1159 + "put_vx_info(%p[#%d.%d])"
1160 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
1161 + "clr_vx_info(%p[#%d.%d])"
1162 + "init_vx_info(%p[#%d.%d])"
1163 + "release_vx_info(%p[#%d.%d.%d]) %p"
1164 + "set_vx_info(%p[#%d.%d])"
1165 + 4 10 "__hash_vx_info: %p[#%d]"
1166 + "__unhash_vx_info: %p[#%d.%d.%d]"
1167 + "__vx_dynamic_id: [#%d]"
1168 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
1169 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
1170 + "moved task %p into vxi:%p[#%d]"
1171 + "task_get_vx_info(%p)"
1172 + "vx_migrate_task(%p,%p[#%d.%d])"
1173 + 6 40 "vx_clear_persistent(%p[#%d])"
1174 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
1175 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
1176 + "vx_set_persistent(%p[#%d])"
1177 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
1178 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
1183 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
1184 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1186 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
1187 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
1188 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1189 diff -NurpP --minimal linux-2.6.27.3/drivers/block/Kconfig linux-2.6.27.3-vs2.3.0.35.7/drivers/block/Kconfig
1190 --- linux-2.6.27.3/drivers/block/Kconfig 2008-10-13 14:51:59.000000000 +0200
1191 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/block/Kconfig 2008-10-13 14:54:20.000000000 +0200
1192 @@ -263,6 +263,13 @@ config BLK_DEV_CRYPTOLOOP
1193 instead, which can be configured to be on-disk compatible with the
1196 +config BLK_DEV_VROOT
1197 + tristate "Virtual Root device support"
1198 + depends on QUOTACTL
1200 + Saying Y here will allow you to use quota/fs ioctls on a shared
1201 + partition within a virtual server without compromising security.
1204 tristate "Network block device support"
1206 diff -NurpP --minimal linux-2.6.27.3/drivers/block/loop.c linux-2.6.27.3-vs2.3.0.35.7/drivers/block/loop.c
1207 --- linux-2.6.27.3/drivers/block/loop.c 2008-07-13 23:51:29.000000000 +0200
1208 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/block/loop.c 2008-10-13 14:54:20.000000000 +0200
1210 #include <linux/gfp.h>
1211 #include <linux/kthread.h>
1212 #include <linux/splice.h>
1213 +#include <linux/vs_context.h>
1215 #include <asm/uaccess.h>
1217 @@ -794,6 +795,7 @@ static int loop_set_fd(struct loop_devic
1218 lo->lo_blocksize = lo_blocksize;
1219 lo->lo_device = bdev;
1220 lo->lo_flags = lo_flags;
1221 + lo->lo_xid = vx_current_xid();
1222 lo->lo_backing_file = file;
1223 lo->transfer = transfer_none;
1225 @@ -915,6 +917,7 @@ static int loop_clr_fd(struct loop_devic
1226 lo->lo_encrypt_key_size = 0;
1228 lo->lo_thread = NULL;
1230 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1231 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1232 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1233 @@ -938,7 +941,7 @@ loop_set_status(struct loop_device *lo,
1234 struct loop_func_table *xfer;
1236 if (lo->lo_encrypt_key_size && lo->lo_key_owner != current->uid &&
1237 - !capable(CAP_SYS_ADMIN))
1238 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1240 if (lo->lo_state != Lo_bound)
1242 @@ -1022,7 +1025,8 @@ loop_get_status(struct loop_device *lo,
1243 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1244 info->lo_encrypt_type =
1245 lo->lo_encryption ? lo->lo_encryption->number : 0;
1246 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1247 + if (lo->lo_encrypt_key_size &&
1248 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1249 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1250 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1251 lo->lo_encrypt_key_size);
1252 @@ -1331,6 +1335,9 @@ static int lo_open(struct inode *inode,
1254 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
1256 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1259 mutex_lock(&lo->lo_ctl_mutex);
1261 mutex_unlock(&lo->lo_ctl_mutex);
1262 diff -NurpP --minimal linux-2.6.27.3/drivers/block/Makefile linux-2.6.27.3-vs2.3.0.35.7/drivers/block/Makefile
1263 --- linux-2.6.27.3/drivers/block/Makefile 2008-10-13 14:51:59.000000000 +0200
1264 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/block/Makefile 2008-10-13 14:54:20.000000000 +0200
1265 @@ -30,5 +30,6 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1266 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1267 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1268 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1269 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1271 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1272 diff -NurpP --minimal linux-2.6.27.3/drivers/block/vroot.c linux-2.6.27.3-vs2.3.0.35.7/drivers/block/vroot.c
1273 --- linux-2.6.27.3/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1274 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/block/vroot.c 2008-10-13 14:54:20.000000000 +0200
1277 + * linux/drivers/block/vroot.c
1279 + * written by Herbert Pötzl, 9/11/2002
1280 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1282 + * based on the loop.c code by Theodore Ts'o.
1284 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1285 + * Redistribution of this file is permitted under the
1286 + * GNU General Public License.
1290 +#include <linux/module.h>
1291 +#include <linux/moduleparam.h>
1292 +#include <linux/file.h>
1293 +#include <linux/major.h>
1294 +#include <linux/blkdev.h>
1296 +#include <linux/vroot.h>
1297 +#include <linux/vs_context.h>
1300 +static int max_vroot = 8;
1302 +static struct vroot_device *vroot_dev;
1303 +static struct gendisk **disks;
1306 +static int vroot_set_dev(
1307 + struct vroot_device *vr,
1308 + struct file *vr_file,
1309 + struct block_device *bdev,
1312 + struct block_device *real_bdev;
1313 + struct file *file;
1314 + struct inode *inode;
1318 + if (vr->vr_state != Vr_unbound)
1327 + inode = file->f_dentry->d_inode;
1330 + if (S_ISBLK(inode->i_mode)) {
1331 + real_bdev = inode->i_bdev;
1332 + vr->vr_device = real_bdev;
1333 + __iget(real_bdev->bd_inode);
1337 + vxdprintk(VXD_CBIT(misc, 0),
1338 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1339 + vr->vr_number, VXD_DEV(real_bdev));
1341 + vr->vr_state = Vr_bound;
1350 +static int vroot_clr_dev(
1351 + struct vroot_device *vr,
1352 + struct file *vr_file,
1353 + struct block_device *bdev)
1355 + struct block_device *real_bdev;
1357 + if (vr->vr_state != Vr_bound)
1359 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1362 + real_bdev = vr->vr_device;
1364 + vxdprintk(VXD_CBIT(misc, 0),
1365 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1366 + vr->vr_number, VXD_DEV(real_bdev));
1369 + vr->vr_state = Vr_unbound;
1370 + vr->vr_device = NULL;
1375 +static int vr_ioctl(struct inode *inode, struct file *file,
1376 + unsigned int cmd, unsigned long arg)
1378 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
1381 + down(&vr->vr_ctl_mutex);
1383 + case VROOT_SET_DEV:
1384 + err = vroot_set_dev(vr, file, inode->i_bdev, arg);
1386 + case VROOT_CLR_DEV:
1387 + err = vroot_clr_dev(vr, file, inode->i_bdev);
1393 + up(&vr->vr_ctl_mutex);
1397 +static int vr_open(struct inode *inode, struct file *file)
1399 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
1401 + down(&vr->vr_ctl_mutex);
1403 + up(&vr->vr_ctl_mutex);
1407 +static int vr_release(struct inode *inode, struct file *file)
1409 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
1411 + down(&vr->vr_ctl_mutex);
1413 + up(&vr->vr_ctl_mutex);
1417 +static struct block_device_operations vr_fops = {
1418 + .owner = THIS_MODULE,
1420 + .release = vr_release,
1421 + .ioctl = vr_ioctl,
1424 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1426 + struct inode *inode = bdev->bd_inode;
1427 + struct vroot_device *vr;
1428 + struct block_device *real_bdev;
1429 + int minor = iminor(inode);
1431 + vr = &vroot_dev[minor];
1432 + real_bdev = vr->vr_device;
1434 + vxdprintk(VXD_CBIT(misc, 0),
1435 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1436 + vr->vr_number, VXD_DEV(real_bdev));
1438 + if (vr->vr_state != Vr_bound)
1439 + return ERR_PTR(-ENXIO);
1441 + __iget(real_bdev->bd_inode);
1446 + * And now the modules code and kernel interface.
1449 +module_param(max_vroot, int, 0);
1451 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1452 +MODULE_LICENSE("GPL");
1453 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1455 +MODULE_AUTHOR ("Herbert Pötzl");
1456 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1459 +int __init vroot_init(void)
1463 + if (max_vroot < 1 || max_vroot > 256) {
1464 + max_vroot = MAX_VROOT_DEFAULT;
1465 + printk(KERN_WARNING "vroot: invalid max_vroot "
1466 + "(must be between 1 and 256), "
1467 + "using default (%d)\n", max_vroot);
1470 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1474 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1477 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1479 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1483 + for (i = 0; i < max_vroot; i++) {
1484 + disks[i] = alloc_disk(1);
1487 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1488 + if (!disks[i]->queue)
1492 + for (i = 0; i < max_vroot; i++) {
1493 + struct vroot_device *vr = &vroot_dev[i];
1494 + struct gendisk *disk = disks[i];
1496 + memset(vr, 0, sizeof(*vr));
1497 + init_MUTEX(&vr->vr_ctl_mutex);
1498 + vr->vr_number = i;
1499 + disk->major = VROOT_MAJOR;
1500 + disk->first_minor = i;
1501 + disk->fops = &vr_fops;
1502 + sprintf(disk->disk_name, "vroot%d", i);
1503 + disk->private_data = vr;
1506 + err = register_vroot_grb(&__vroot_get_real_bdev);
1510 + for (i = 0; i < max_vroot; i++)
1511 + add_disk(disks[i]);
1512 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1517 + put_disk(disks[i]);
1522 + unregister_blkdev(VROOT_MAJOR, "vroot");
1523 + printk(KERN_ERR "vroot: ran out of memory\n");
1527 +void vroot_exit(void)
1531 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1532 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1534 + for (i = 0; i < max_vroot; i++) {
1535 + del_gendisk(disks[i]);
1536 + put_disk(disks[i]);
1538 + unregister_blkdev(VROOT_MAJOR, "vroot");
1544 +module_init(vroot_init);
1545 +module_exit(vroot_exit);
1549 +static int __init max_vroot_setup(char *str)
1551 + max_vroot = simple_strtol(str, NULL, 0);
1555 +__setup("max_vroot=", max_vroot_setup);
1559 diff -NurpP --minimal linux-2.6.27.3/drivers/char/sysrq.c linux-2.6.27.3-vs2.3.0.35.7/drivers/char/sysrq.c
1560 --- linux-2.6.27.3/drivers/char/sysrq.c 2008-10-13 14:51:59.000000000 +0200
1561 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/char/sysrq.c 2008-10-13 14:54:20.000000000 +0200
1563 #include <linux/irq.h>
1564 #include <linux/hrtimer.h>
1565 #include <linux/oom.h>
1566 +#include <linux/vserver/debug.h>
1568 #include <asm/ptrace.h>
1569 #include <asm/irq_regs.h>
1570 @@ -351,6 +352,21 @@ static struct sysrq_key_op sysrq_unrt_op
1571 .enable_mask = SYSRQ_ENABLE_RTNICE,
1575 +#ifdef CONFIG_VSERVER_DEBUG
1576 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
1578 + dump_vx_info_inactive((key == 'x')?0:1);
1581 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1582 + .handler = sysrq_handle_vxinfo,
1583 + .help_msg = "conteXt",
1584 + .action_msg = "Show Context Info",
1585 + .enable_mask = SYSRQ_ENABLE_DUMP,
1589 /* Key Operations table and lock */
1590 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1592 @@ -404,7 +420,11 @@ static struct sysrq_key_op *sysrq_key_ta
1594 /* y: May be registered on sparc64 for global register dump */
1597 +#ifdef CONFIG_VSERVER_DEBUG
1598 + &sysrq_showvxinfo_op, /* z */
1604 /* key2index calculation, -1 on invalid index */
1605 @@ -416,6 +436,8 @@ static int sysrq_key_table_key2index(int
1607 else if ((key >= 'a') && (key <= 'z'))
1608 retval = key + 10 - 'a';
1609 + else if ((key >= 'A') && (key <= 'Z'))
1610 + retval = key + 10 - 'A';
1614 diff -NurpP --minimal linux-2.6.27.3/drivers/char/tty_io.c linux-2.6.27.3-vs2.3.0.35.7/drivers/char/tty_io.c
1615 --- linux-2.6.27.3/drivers/char/tty_io.c 2008-10-24 02:21:28.000000000 +0200
1616 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/char/tty_io.c 2008-10-24 02:21:46.000000000 +0200
1619 #include <linux/kmod.h>
1620 #include <linux/nsproxy.h>
1621 +#include <linux/vs_pid.h>
1623 #undef TTY_DEBUG_HANGUP
1625 @@ -2770,6 +2771,7 @@ static int tiocspgrp(struct tty_struct *
1627 if (get_user(pgrp_nr, p))
1629 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1633 diff -NurpP --minimal linux-2.6.27.3/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.27.3-vs2.3.0.35.7/drivers/infiniband/hw/ipath/ipath_user_pages.c
1634 --- linux-2.6.27.3/drivers/infiniband/hw/ipath/ipath_user_pages.c 2008-07-13 23:51:29.000000000 +0200
1635 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/infiniband/hw/ipath/ipath_user_pages.c 2008-10-13 14:54:20.000000000 +0200
1638 #include <linux/mm.h>
1639 #include <linux/device.h>
1640 +#include <linux/vs_memory.h>
1642 #include "ipath_kernel.h"
1644 @@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
1645 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
1648 - if (num_pages > lock_limit) {
1649 + if (num_pages > lock_limit ||
1650 + !vx_vmlocked_avail(current->mm, num_pages)) {
1654 @@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
1658 - current->mm->locked_vm += num_pages;
1659 + vx_vmlocked_add(current->mm, num_pages);
1663 @@ -177,7 +179,7 @@ void ipath_release_user_pages(struct pag
1665 __ipath_release_user_pages(p, num_pages, 1);
1667 - current->mm->locked_vm -= num_pages;
1668 + vx_vmlocked_sub(current->mm, num_pages);
1670 up_write(¤t->mm->mmap_sem);
1672 @@ -194,7 +196,7 @@ static void user_pages_account(struct wo
1673 container_of(_work, struct ipath_user_pages_work, work);
1675 down_write(&work->mm->mmap_sem);
1676 - work->mm->locked_vm -= work->num_pages;
1677 + vx_vmlocked_sub(work->mm, work->num_pages);
1678 up_write(&work->mm->mmap_sem);
1681 diff -NurpP --minimal linux-2.6.27.3/drivers/md/dm.c linux-2.6.27.3-vs2.3.0.35.7/drivers/md/dm.c
1682 --- linux-2.6.27.3/drivers/md/dm.c 2008-10-13 14:52:01.000000000 +0200
1683 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/md/dm.c 2008-10-13 14:54:20.000000000 +0200
1685 #include <linux/hdreg.h>
1686 #include <linux/blktrace_api.h>
1687 #include <linux/smp_lock.h>
1688 +#include <linux/vs_base.h>
1690 #define DM_MSG_PREFIX "core"
1692 @@ -91,6 +92,7 @@ struct mapped_device {
1695 atomic_t open_count;
1698 unsigned long flags;
1700 @@ -252,6 +254,7 @@ static void __exit dm_exit(void)
1701 static int dm_blk_open(struct inode *inode, struct file *file)
1703 struct mapped_device *md;
1706 spin_lock(&_minor_lock);
1708 @@ -260,18 +263,19 @@ static int dm_blk_open(struct inode *ino
1711 if (test_bit(DMF_FREEING, &md->flags) ||
1712 - test_bit(DMF_DELETING, &md->flags)) {
1714 + test_bit(DMF_DELETING, &md->flags))
1718 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1723 atomic_inc(&md->open_count);
1727 spin_unlock(&_minor_lock);
1729 - return md ? 0 : -ENXIO;
1733 static int dm_blk_close(struct inode *inode, struct file *file)
1734 @@ -467,6 +471,14 @@ int dm_set_geometry(struct mapped_device
1739 + * Get the xid associated with a dm device
1741 +xid_t dm_get_xid(struct mapped_device *md)
1746 /*-----------------------------------------------------------------
1748 * A more elegant soln is in the works that uses the queue
1749 @@ -1069,6 +1081,7 @@ static struct mapped_device *alloc_dev(i
1750 INIT_LIST_HEAD(&md->uevent_list);
1751 spin_lock_init(&md->uevent_lock);
1753 + md->xid = vx_current_xid();
1754 md->queue = blk_alloc_queue(GFP_KERNEL);
1757 diff -NurpP --minimal linux-2.6.27.3/drivers/md/dm.h linux-2.6.27.3-vs2.3.0.35.7/drivers/md/dm.h
1758 --- linux-2.6.27.3/drivers/md/dm.h 2008-10-13 14:52:01.000000000 +0200
1759 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/md/dm.h 2008-10-13 14:54:20.000000000 +0200
1760 @@ -66,6 +66,8 @@ void dm_put_target_type(struct target_ty
1761 int dm_target_iterate(void (*iter_func)(struct target_type *tt,
1762 void *param), void *param);
1764 +xid_t dm_get_xid(struct mapped_device *md);
1766 /*-----------------------------------------------------------------
1768 *---------------------------------------------------------------*/
1769 diff -NurpP --minimal linux-2.6.27.3/drivers/md/dm-ioctl.c linux-2.6.27.3-vs2.3.0.35.7/drivers/md/dm-ioctl.c
1770 --- linux-2.6.27.3/drivers/md/dm-ioctl.c 2008-07-13 23:51:29.000000000 +0200
1771 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/md/dm-ioctl.c 2008-10-13 14:54:20.000000000 +0200
1773 #include <linux/dm-ioctl.h>
1774 #include <linux/hdreg.h>
1775 #include <linux/compat.h>
1776 +#include <linux/vs_context.h>
1778 #include <asm/uaccess.h>
1780 @@ -101,7 +102,8 @@ static struct hash_cell *__get_name_cell
1781 unsigned int h = hash_str(str);
1783 list_for_each_entry (hc, _name_buckets + h, name_list)
1784 - if (!strcmp(hc->name, str)) {
1785 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1786 + !strcmp(hc->name, str)) {
1790 @@ -115,7 +117,8 @@ static struct hash_cell *__get_uuid_cell
1791 unsigned int h = hash_str(str);
1793 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1794 - if (!strcmp(hc->uuid, str)) {
1795 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1796 + !strcmp(hc->uuid, str)) {
1800 @@ -352,6 +355,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1802 static int remove_all(struct dm_ioctl *param, size_t param_size)
1804 + if (!vx_check(0, VS_ADMIN))
1807 dm_hash_remove_all(1);
1808 param->data_size = 0;
1810 @@ -399,6 +405,8 @@ static int list_devices(struct dm_ioctl
1812 for (i = 0; i < NUM_BUCKETS; i++) {
1813 list_for_each_entry (hc, _name_buckets + i, name_list) {
1814 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1816 needed += sizeof(struct dm_name_list);
1817 needed += strlen(hc->name) + 1;
1818 needed += ALIGN_MASK;
1819 @@ -422,6 +430,8 @@ static int list_devices(struct dm_ioctl
1821 for (i = 0; i < NUM_BUCKETS; i++) {
1822 list_for_each_entry (hc, _name_buckets + i, name_list) {
1823 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1826 old_nl->next = (uint32_t) ((void *) nl -
1828 @@ -612,10 +622,11 @@ static struct hash_cell *__find_device_h
1832 - mdptr = dm_get_mdptr(md);
1833 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1834 + mdptr = dm_get_mdptr(md);
1842 @@ -1406,8 +1417,8 @@ static int ctl_ioctl(uint command, struc
1846 - /* only root can play with this */
1847 - if (!capable(CAP_SYS_ADMIN))
1848 + /* only root and certain contexts can play with this */
1849 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1852 if (_IOC_TYPE(command) != DM_IOCTL)
1853 diff -NurpP --minimal linux-2.6.27.3/drivers/net/tun.c linux-2.6.27.3-vs2.3.0.35.7/drivers/net/tun.c
1854 --- linux-2.6.27.3/drivers/net/tun.c 2008-10-13 14:52:02.000000000 +0200
1855 +++ linux-2.6.27.3-vs2.3.0.35.7/drivers/net/tun.c 2008-10-13 14:54:20.000000000 +0200
1857 #include <linux/crc32.h>
1858 #include <linux/nsproxy.h>
1859 #include <linux/virtio_net.h>
1860 +#include <linux/vs_network.h>
1861 #include <net/net_namespace.h>
1862 #include <net/netns/generic.h>
1864 @@ -93,6 +94,7 @@ struct tun_struct {
1870 wait_queue_head_t read_wait;
1871 struct sk_buff_head readq;
1872 @@ -675,6 +677,7 @@ static void tun_setup(struct net_device
1876 + tun->nid = current->nid;
1878 dev->open = tun_net_open;
1879 dev->hard_start_xmit = tun_net_xmit;
1880 @@ -707,6 +710,9 @@ static int tun_set_iff(struct net *net,
1881 tn = net_generic(net, tun_net_id);
1882 tun = tun_get_by_name(tn, ifr->ifr_name);
1884 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1890 @@ -715,7 +721,7 @@ static int tun_set_iff(struct net *net,
1891 current->euid != tun->owner) ||
1892 (tun->group != -1 &&
1893 current->egid != tun->group)) &&
1894 - !capable(CAP_NET_ADMIN))
1895 + !cap_raised(current->cap_effective, CAP_NET_ADMIN))
1898 else if (__dev_get_by_name(net, ifr->ifr_name))
1899 @@ -726,7 +732,7 @@ static int tun_set_iff(struct net *net,
1903 - if (!capable(CAP_NET_ADMIN))
1904 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1908 @@ -966,6 +972,16 @@ static int tun_chr_ioctl(struct inode *i
1909 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
1913 + if (!capable(CAP_CONTEXT))
1916 + /* Set nid owner of the device */
1917 + tun->nid = (nid_t) arg;
1919 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
1923 /* Only allow setting the type when the interface is down */
1925 diff -NurpP --minimal linux-2.6.27.3/fs/attr.c linux-2.6.27.3-vs2.3.0.35.7/fs/attr.c
1926 --- linux-2.6.27.3/fs/attr.c 2008-10-13 14:52:05.000000000 +0200
1927 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/attr.c 2008-10-24 03:34:52.000000000 +0200
1929 #include <linux/fcntl.h>
1930 #include <linux/quotaops.h>
1931 #include <linux/security.h>
1932 +#include <linux/proc_fs.h>
1933 +#include <linux/devpts_fs.h>
1934 +#include <linux/vs_tag.h>
1936 /* Taken over from the old code... */
1938 @@ -55,6 +58,10 @@ int inode_change_ok(struct inode *inode,
1939 if (!is_owner_or_cap(inode))
1943 + if (dx_permission(inode, MAY_WRITE))
1949 @@ -78,6 +85,8 @@ int inode_setattr(struct inode * inode,
1950 inode->i_uid = attr->ia_uid;
1951 if (ia_valid & ATTR_GID)
1952 inode->i_gid = attr->ia_gid;
1953 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1954 + inode->i_tag = attr->ia_tag;
1955 if (ia_valid & ATTR_ATIME)
1956 inode->i_atime = timespec_trunc(attr->ia_atime,
1957 inode->i_sb->s_time_gran);
1958 @@ -172,7 +181,8 @@ int notify_change(struct dentry * dentry
1959 error = security_inode_setattr(dentry, attr);
1961 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
1962 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
1963 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
1964 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
1965 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
1967 error = inode_setattr(inode, attr);
1968 diff -NurpP --minimal linux-2.6.27.3/fs/binfmt_aout.c linux-2.6.27.3-vs2.3.0.35.7/fs/binfmt_aout.c
1969 --- linux-2.6.27.3/fs/binfmt_aout.c 2008-10-13 14:52:05.000000000 +0200
1970 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/binfmt_aout.c 2008-10-13 14:54:20.000000000 +0200
1972 #include <linux/binfmts.h>
1973 #include <linux/personality.h>
1974 #include <linux/init.h>
1975 +#include <linux/vs_memory.h>
1977 #include <asm/system.h>
1978 #include <asm/uaccess.h>
1979 diff -NurpP --minimal linux-2.6.27.3/fs/binfmt_elf.c linux-2.6.27.3-vs2.3.0.35.7/fs/binfmt_elf.c
1980 --- linux-2.6.27.3/fs/binfmt_elf.c 2008-10-13 14:52:05.000000000 +0200
1981 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/binfmt_elf.c 2008-10-13 14:54:20.000000000 +0200
1983 #include <linux/random.h>
1984 #include <linux/elf.h>
1985 #include <linux/utsname.h>
1986 +#include <linux/vs_memory.h>
1987 #include <asm/uaccess.h>
1988 #include <asm/param.h>
1989 #include <asm/page.h>
1990 diff -NurpP --minimal linux-2.6.27.3/fs/binfmt_flat.c linux-2.6.27.3-vs2.3.0.35.7/fs/binfmt_flat.c
1991 --- linux-2.6.27.3/fs/binfmt_flat.c 2008-10-13 14:52:05.000000000 +0200
1992 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/binfmt_flat.c 2008-10-13 14:54:20.000000000 +0200
1994 #include <linux/init.h>
1995 #include <linux/flat.h>
1996 #include <linux/syscalls.h>
1997 +#include <linux/vs_memory.h>
1999 #include <asm/byteorder.h>
2000 #include <asm/system.h>
2001 diff -NurpP --minimal linux-2.6.27.3/fs/binfmt_som.c linux-2.6.27.3-vs2.3.0.35.7/fs/binfmt_som.c
2002 --- linux-2.6.27.3/fs/binfmt_som.c 2008-10-13 14:52:05.000000000 +0200
2003 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/binfmt_som.c 2008-10-13 14:54:20.000000000 +0200
2005 #include <linux/shm.h>
2006 #include <linux/personality.h>
2007 #include <linux/init.h>
2008 +#include <linux/vs_memory.h>
2010 #include <asm/uaccess.h>
2011 #include <asm/pgtable.h>
2012 diff -NurpP --minimal linux-2.6.27.3/fs/block_dev.c linux-2.6.27.3-vs2.3.0.35.7/fs/block_dev.c
2013 --- linux-2.6.27.3/fs/block_dev.c 2008-10-13 14:52:05.000000000 +0200
2014 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/block_dev.c 2008-10-13 14:54:20.000000000 +0200
2016 #include <linux/uio.h>
2017 #include <linux/namei.h>
2018 #include <linux/log2.h>
2019 +#include <linux/vs_device.h>
2020 #include <asm/uaccess.h>
2021 #include "internal.h"
2023 @@ -389,6 +390,7 @@ struct block_device *bdget(dev_t dev)
2024 bdev->bd_invalidated = 0;
2025 inode->i_mode = S_IFBLK;
2026 inode->i_rdev = dev;
2027 + inode->i_mdev = dev;
2028 inode->i_bdev = bdev;
2029 inode->i_data.a_ops = &def_blk_aops;
2030 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2031 @@ -425,6 +427,11 @@ EXPORT_SYMBOL(bdput);
2032 static struct block_device *bd_acquire(struct inode *inode)
2034 struct block_device *bdev;
2037 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2039 + inode->i_mdev = mdev;
2041 spin_lock(&bdev_lock);
2042 bdev = inode->i_bdev;
2043 @@ -435,7 +442,7 @@ static struct block_device *bd_acquire(s
2045 spin_unlock(&bdev_lock);
2047 - bdev = bdget(inode->i_rdev);
2048 + bdev = bdget(mdev);
2050 spin_lock(&bdev_lock);
2051 if (!inode->i_bdev) {
2052 diff -NurpP --minimal linux-2.6.27.3/fs/char_dev.c linux-2.6.27.3-vs2.3.0.35.7/fs/char_dev.c
2053 --- linux-2.6.27.3/fs/char_dev.c 2008-10-13 14:52:05.000000000 +0200
2054 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/char_dev.c 2008-10-13 14:54:20.000000000 +0200
2056 #include <linux/cdev.h>
2057 #include <linux/mutex.h>
2058 #include <linux/backing-dev.h>
2059 +#include <linux/vs_context.h>
2060 +#include <linux/vs_device.h>
2063 #include <linux/kmod.h>
2064 @@ -361,14 +363,21 @@ static int chrdev_open(struct inode *ino
2066 struct cdev *new = NULL;
2070 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2072 + inode->i_mdev = mdev;
2074 spin_lock(&cdev_lock);
2077 struct kobject *kobj;
2080 spin_unlock(&cdev_lock);
2081 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2083 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2086 new = container_of(kobj, struct cdev, kobj);
2087 diff -NurpP --minimal linux-2.6.27.3/fs/dcache.c linux-2.6.27.3-vs2.3.0.35.7/fs/dcache.c
2088 --- linux-2.6.27.3/fs/dcache.c 2008-10-13 14:52:05.000000000 +0200
2089 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/dcache.c 2008-10-24 03:34:52.000000000 +0200
2091 #include <linux/seqlock.h>
2092 #include <linux/swap.h>
2093 #include <linux/bootmem.h>
2094 +#include <linux/vs_limit.h>
2095 #include "internal.h"
2098 @@ -226,6 +227,8 @@ repeat:
2102 + vx_dentry_dec(dentry);
2105 * AV: ->d_delete() is _NOT_ allowed to block now.
2107 @@ -317,6 +320,7 @@ static inline struct dentry * __dget_loc
2109 atomic_inc(&dentry->d_count);
2110 dentry_lru_del_init(dentry);
2111 + vx_dentry_inc(dentry);
2115 @@ -914,6 +918,9 @@ struct dentry *d_alloc(struct dentry * p
2116 struct dentry *dentry;
2119 + if (!vx_dentry_avail(1))
2122 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2125 @@ -962,6 +969,7 @@ struct dentry *d_alloc(struct dentry * p
2127 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2128 dentry_stat.nr_dentry++;
2129 + vx_dentry_inc(dentry);
2130 spin_unlock(&dcache_lock);
2133 @@ -1415,6 +1423,7 @@ struct dentry * __d_lookup(struct dentry
2136 atomic_inc(&dentry->d_count);
2137 + vx_dentry_inc(dentry);
2139 spin_unlock(&dentry->d_lock);
2141 diff -NurpP --minimal linux-2.6.27.3/fs/devpts/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/devpts/inode.c
2142 --- linux-2.6.27.3/fs/devpts/inode.c 2008-10-13 14:52:05.000000000 +0200
2143 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/devpts/inode.c 2008-10-13 14:54:20.000000000 +0200
2145 #include <linux/tty.h>
2146 #include <linux/mutex.h>
2147 #include <linux/idr.h>
2148 +#include <linux/magic.h>
2149 #include <linux/devpts_fs.h>
2150 #include <linux/parser.h>
2151 #include <linux/fsnotify.h>
2152 #include <linux/seq_file.h>
2154 -#define DEVPTS_SUPER_MAGIC 0x1cd1
2155 +#include <linux/vs_base.h>
2157 #define DEVPTS_DEFAULT_MODE 0600
2159 +static int devpts_permission(struct inode *inode, int mask)
2161 + int ret = -EACCES;
2163 + /* devpts is xid tagged */
2164 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2165 + ret = generic_permission(inode, mask, NULL);
2169 +static struct inode_operations devpts_file_inode_operations = {
2170 + .permission = devpts_permission,
2173 extern int pty_limit; /* Config limit on Unix98 ptys */
2174 static DEFINE_IDA(allocated_ptys);
2175 static DEFINE_MUTEX(allocated_ptys_lock);
2176 @@ -112,6 +126,25 @@ static int devpts_show_options(struct se
2180 +static int devpts_filter(struct dentry *de)
2182 + /* devpts is xid tagged */
2183 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2186 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2188 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2191 +static struct file_operations devpts_dir_operations = {
2192 + .open = dcache_dir_open,
2193 + .release = dcache_dir_close,
2194 + .llseek = dcache_dir_lseek,
2195 + .read = generic_read_dir,
2196 + .readdir = devpts_readdir,
2199 static const struct super_operations devpts_sops = {
2200 .statfs = simple_statfs,
2201 .remount_fs = devpts_remount,
2202 @@ -138,8 +171,10 @@ devpts_fill_super(struct super_block *s,
2203 inode->i_uid = inode->i_gid = 0;
2204 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2205 inode->i_op = &simple_dir_inode_operations;
2206 - inode->i_fop = &simple_dir_operations;
2207 + inode->i_fop = &devpts_dir_operations;
2209 + /* devpts is xid tagged */
2210 + inode->i_tag = (tag_t)vx_current_xid();
2212 devpts_root = s->s_root = d_alloc_root(inode);
2214 @@ -232,6 +267,9 @@ int devpts_pty_new(struct tty_struct *tt
2215 inode->i_gid = config.setgid ? config.gid : current->fsgid;
2216 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2217 init_special_inode(inode, S_IFCHR|config.mode, device);
2218 + /* devpts is xid tagged */
2219 + inode->i_tag = (tag_t)vx_current_xid();
2220 + inode->i_op = &devpts_file_inode_operations;
2221 inode->i_private = tty;
2223 dentry = get_node(number);
2224 diff -NurpP --minimal linux-2.6.27.3/fs/exec.c linux-2.6.27.3-vs2.3.0.35.7/fs/exec.c
2225 --- linux-2.6.27.3/fs/exec.c 2008-10-13 14:52:05.000000000 +0200
2226 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/exec.c 2008-10-13 14:54:20.000000000 +0200
2227 @@ -263,7 +263,9 @@ static int __bprm_mm_init(struct linux_b
2231 - mm->stack_vm = mm->total_vm = 1;
2233 + vx_vmpages_inc(mm);
2235 up_write(&mm->mmap_sem);
2237 bprm->p = vma->vm_end - sizeof(void *);
2238 @@ -1453,7 +1455,7 @@ static int format_corename(char *corenam
2239 /* UNIX time of coredump */
2242 - do_gettimeofday(&tv);
2243 + vx_gettimeofday(&tv);
2244 rc = snprintf(out_ptr, out_end - out_ptr,
2246 if (rc > out_end - out_ptr)
2247 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/balloc.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/balloc.c
2248 --- linux-2.6.27.3/fs/ext2/balloc.c 2008-07-13 23:51:29.000000000 +0200
2249 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/balloc.c 2008-10-13 14:54:20.000000000 +0200
2251 #include <linux/sched.h>
2252 #include <linux/buffer_head.h>
2253 #include <linux/capability.h>
2254 +#include <linux/vs_dlimit.h>
2255 +#include <linux/vs_tag.h>
2258 * balloc.c contains the blocks allocation and deallocation routines
2259 @@ -569,6 +571,7 @@ do_more:
2263 + DLIMIT_FREE_BLOCK(inode, freed);
2264 release_blocks(sb, freed);
2265 DQUOT_FREE_BLOCK(inode, freed);
2267 @@ -701,7 +704,6 @@ ext2_try_to_allocate(struct super_block
2269 end = EXT2_BLOCKS_PER_GROUP(sb);
2272 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2275 @@ -1251,6 +1253,11 @@ ext2_fsblk_t ext2_new_blocks(struct inod
2279 + if (DLIMIT_ALLOC_BLOCK(inode, num)) {
2281 + DQUOT_FREE_BLOCK(inode, num);
2286 es = EXT2_SB(sb)->s_es;
2287 @@ -1408,6 +1415,7 @@ allocated:
2291 + DLIMIT_FREE_BLOCK(inode, *count-num);
2292 DQUOT_FREE_BLOCK(inode, *count-num);
2295 @@ -1418,8 +1426,10 @@ out:
2297 * Undo the block allocation
2299 - if (!performed_allocation)
2300 + if (!performed_allocation) {
2301 + DLIMIT_FREE_BLOCK(inode, *count);
2302 DQUOT_FREE_BLOCK(inode, *count);
2307 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/ext2.h linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/ext2.h
2308 --- linux-2.6.27.3/fs/ext2/ext2.h 2008-07-13 23:51:29.000000000 +0200
2309 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/ext2.h 2008-10-13 14:54:20.000000000 +0200
2310 @@ -168,6 +168,7 @@ extern const struct file_operations ext2
2311 extern const struct address_space_operations ext2_aops;
2312 extern const struct address_space_operations ext2_aops_xip;
2313 extern const struct address_space_operations ext2_nobh_aops;
2314 +extern int ext2_sync_flags(struct inode *inode);
2317 extern const struct inode_operations ext2_dir_inode_operations;
2318 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/file.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/file.c
2319 --- linux-2.6.27.3/fs/ext2/file.c 2008-07-13 23:51:29.000000000 +0200
2320 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/file.c 2008-10-13 14:54:20.000000000 +0200
2321 @@ -86,4 +86,5 @@ const struct inode_operations ext2_file_
2323 .setattr = ext2_setattr,
2324 .permission = ext2_permission,
2325 + .sync_flags = ext2_sync_flags,
2327 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/ialloc.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/ialloc.c
2328 --- linux-2.6.27.3/fs/ext2/ialloc.c 2008-07-13 23:51:29.000000000 +0200
2329 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/ialloc.c 2008-10-13 14:54:20.000000000 +0200
2331 #include <linux/backing-dev.h>
2332 #include <linux/buffer_head.h>
2333 #include <linux/random.h>
2334 +#include <linux/vs_dlimit.h>
2335 +#include <linux/vs_tag.h>
2339 @@ -123,6 +125,7 @@ void ext2_free_inode (struct inode * ino
2340 ext2_xattr_delete_inode(inode);
2341 DQUOT_FREE_INODE(inode);
2343 + DLIMIT_FREE_INODE(inode);
2346 es = EXT2_SB(sb)->s_es;
2347 @@ -454,6 +457,11 @@ struct inode *ext2_new_inode(struct inod
2349 return ERR_PTR(-ENOMEM);
2351 + inode->i_tag = dx_current_fstag(sb);
2352 + if (DLIMIT_ALLOC_INODE(inode)) {
2359 @@ -565,7 +573,8 @@ got:
2360 inode->i_blocks = 0;
2361 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
2362 memset(ei->i_data, 0, sizeof(ei->i_data));
2363 - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
2364 + ei->i_flags = EXT2_I(dir)->i_flags &
2365 + ~(EXT2_BTREE_FL|EXT2_IXUNLINK_FL|EXT2_BARRIER_FL);
2367 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
2368 /* dirsync is only applied to directories */
2369 @@ -610,12 +619,15 @@ fail_free_drop:
2373 + DLIMIT_FREE_INODE(inode);
2374 inode->i_flags |= S_NOQUOTA;
2377 return ERR_PTR(err);
2380 + DLIMIT_FREE_INODE(inode);
2382 make_bad_inode(inode);
2384 return ERR_PTR(err);
2385 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/inode.c
2386 --- linux-2.6.27.3/fs/ext2/inode.c 2008-10-13 14:52:05.000000000 +0200
2387 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/inode.c 2008-10-13 14:54:20.000000000 +0200
2389 #include <linux/writeback.h>
2390 #include <linux/buffer_head.h>
2391 #include <linux/mpage.h>
2392 +#include <linux/vs_tag.h>
2396 @@ -1011,7 +1012,7 @@ void ext2_truncate(struct inode *inode)
2398 if (ext2_inode_is_fast_symlink(inode))
2400 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2401 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2404 blocksize = inode->i_sb->s_blocksize;
2405 @@ -1149,38 +1150,72 @@ void ext2_set_inode_flags(struct inode *
2407 unsigned int flags = EXT2_I(inode)->i_flags;
2409 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2410 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2411 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2414 + if (flags & EXT2_IMMUTABLE_FL)
2415 + inode->i_flags |= S_IMMUTABLE;
2416 + if (flags & EXT2_IXUNLINK_FL)
2417 + inode->i_flags |= S_IXUNLINK;
2419 if (flags & EXT2_SYNC_FL)
2420 inode->i_flags |= S_SYNC;
2421 if (flags & EXT2_APPEND_FL)
2422 inode->i_flags |= S_APPEND;
2423 - if (flags & EXT2_IMMUTABLE_FL)
2424 - inode->i_flags |= S_IMMUTABLE;
2425 if (flags & EXT2_NOATIME_FL)
2426 inode->i_flags |= S_NOATIME;
2427 if (flags & EXT2_DIRSYNC_FL)
2428 inode->i_flags |= S_DIRSYNC;
2430 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2432 + if (flags & EXT2_BARRIER_FL)
2433 + inode->i_vflags |= V_BARRIER;
2434 + if (flags & EXT2_COW_FL)
2435 + inode->i_vflags |= V_COW;
2438 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2439 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2441 unsigned int flags = ei->vfs_inode.i_flags;
2442 + unsigned int vflags = ei->vfs_inode.i_vflags;
2444 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2445 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2446 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2447 + EXT2_BARRIER_FL | EXT2_COW_FL);
2449 + if (flags & S_IMMUTABLE)
2450 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2451 + if (flags & S_IXUNLINK)
2452 + ei->i_flags |= EXT2_IXUNLINK_FL;
2454 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2455 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2457 ei->i_flags |= EXT2_SYNC_FL;
2458 if (flags & S_APPEND)
2459 ei->i_flags |= EXT2_APPEND_FL;
2460 - if (flags & S_IMMUTABLE)
2461 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2462 if (flags & S_NOATIME)
2463 ei->i_flags |= EXT2_NOATIME_FL;
2464 if (flags & S_DIRSYNC)
2465 ei->i_flags |= EXT2_DIRSYNC_FL;
2467 + if (vflags & V_BARRIER)
2468 + ei->i_flags |= EXT2_BARRIER_FL;
2469 + if (vflags & V_COW)
2470 + ei->i_flags |= EXT2_COW_FL;
2473 +int ext2_sync_flags(struct inode *inode)
2475 + ext2_get_inode_flags(EXT2_I(inode));
2476 + inode->i_ctime = CURRENT_TIME;
2477 + mark_inode_dirty(inode);
2482 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2484 struct ext2_inode_info *ei;
2485 @@ -1188,6 +1223,8 @@ struct inode *ext2_iget (struct super_bl
2486 struct ext2_inode *raw_inode;
2487 struct inode *inode;
2493 inode = iget_locked(sb, ino);
2494 @@ -1210,12 +1247,17 @@ struct inode *ext2_iget (struct super_bl
2497 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2498 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2499 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2500 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2501 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2502 if (!(test_opt (inode->i_sb, NO_UID32))) {
2503 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2504 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2505 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2506 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2508 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2509 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2510 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2511 + le16_to_cpu(raw_inode->i_raw_tag));
2513 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2514 inode->i_size = le32_to_cpu(raw_inode->i_size);
2515 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2516 @@ -1311,8 +1353,8 @@ static int ext2_update_inode(struct inod
2517 struct ext2_inode_info *ei = EXT2_I(inode);
2518 struct super_block *sb = inode->i_sb;
2519 ino_t ino = inode->i_ino;
2520 - uid_t uid = inode->i_uid;
2521 - gid_t gid = inode->i_gid;
2522 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2523 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2524 struct buffer_head * bh;
2525 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2527 @@ -1348,6 +1390,9 @@ static int ext2_update_inode(struct inod
2528 raw_inode->i_uid_high = 0;
2529 raw_inode->i_gid_high = 0;
2531 +#ifdef CONFIG_TAGGING_INTERN
2532 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2534 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2535 raw_inode->i_size = cpu_to_le32(inode->i_size);
2536 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2537 @@ -1434,7 +1479,8 @@ int ext2_setattr(struct dentry *dentry,
2540 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2541 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2542 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2543 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2544 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
2547 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/ioctl.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/ioctl.c
2548 --- linux-2.6.27.3/fs/ext2/ioctl.c 2008-07-13 23:51:29.000000000 +0200
2549 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/ioctl.c 2008-10-13 14:54:20.000000000 +0200
2551 #include <linux/compat.h>
2552 #include <linux/mount.h>
2553 #include <linux/smp_lock.h>
2554 +#include <linux/mount.h>
2555 #include <asm/current.h>
2556 #include <asm/uaccess.h>
2558 @@ -53,6 +54,11 @@ long ext2_ioctl(struct file *filp, unsig
2559 if (!S_ISDIR(inode->i_mode))
2560 flags &= ~EXT2_DIRSYNC_FL;
2562 + if (IS_BARRIER(inode)) {
2563 + vxwprintk_task(1, "messing with the barrier.");
2567 mutex_lock(&inode->i_mutex);
2568 /* Is it quota file? Do not allow user to mess with it */
2569 if (IS_NOQUOTA(inode)) {
2570 @@ -68,7 +74,9 @@ long ext2_ioctl(struct file *filp, unsig
2572 * This test looks nicer. Thanks to Pauline Middelink
2574 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2575 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2576 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2577 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2578 if (!capable(CAP_LINUX_IMMUTABLE)) {
2579 mutex_unlock(&inode->i_mutex);
2581 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/namei.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/namei.c
2582 --- linux-2.6.27.3/fs/ext2/namei.c 2008-07-13 23:51:29.000000000 +0200
2583 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/namei.c 2008-10-13 14:54:20.000000000 +0200
2587 #include <linux/pagemap.h>
2588 +#include <linux/vs_tag.h>
2592 @@ -66,6 +67,7 @@ static struct dentry *ext2_lookup(struct
2593 inode = ext2_iget(dir->i_sb, ino);
2595 return ERR_CAST(inode);
2596 + dx_propagate_tag(nd, inode);
2598 return d_splice_alias(inode, dentry);
2600 @@ -391,6 +393,7 @@ const struct inode_operations ext2_dir_i
2602 .setattr = ext2_setattr,
2603 .permission = ext2_permission,
2604 + .sync_flags = ext2_sync_flags,
2607 const struct inode_operations ext2_special_inode_operations = {
2608 @@ -402,4 +405,5 @@ const struct inode_operations ext2_speci
2610 .setattr = ext2_setattr,
2611 .permission = ext2_permission,
2612 + .sync_flags = ext2_sync_flags,
2614 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/super.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/super.c
2615 --- linux-2.6.27.3/fs/ext2/super.c 2008-10-13 14:52:05.000000000 +0200
2616 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/super.c 2008-10-13 14:54:20.000000000 +0200
2617 @@ -390,7 +390,8 @@ enum {
2618 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2619 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2620 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2621 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2622 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2623 + Opt_tag, Opt_notag, Opt_tagid
2626 static match_table_t tokens = {
2627 @@ -418,6 +419,9 @@ static match_table_t tokens = {
2629 {Opt_noacl, "noacl"},
2632 + {Opt_notag, "notag"},
2633 + {Opt_tagid, "tagid=%u"},
2634 {Opt_grpquota, "grpquota"},
2635 {Opt_ignore, "noquota"},
2636 {Opt_quota, "quota"},
2637 @@ -488,6 +492,20 @@ static int parse_options (char * options
2639 set_opt (sbi->s_mount_opt, NO_UID32);
2641 +#ifndef CONFIG_TAGGING_NONE
2643 + set_opt (sbi->s_mount_opt, TAGGED);
2646 + clear_opt (sbi->s_mount_opt, TAGGED);
2649 +#ifdef CONFIG_PROPAGATE
2652 + set_opt (sbi->s_mount_opt, TAGGED);
2656 clear_opt (sbi->s_mount_opt, CHECK);
2658 @@ -830,6 +848,8 @@ static int ext2_fill_super(struct super_
2659 if (!parse_options ((char *) data, sbi))
2662 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2663 + sb->s_flags |= MS_TAGGED;
2664 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2665 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2667 @@ -1162,6 +1182,13 @@ static int ext2_remount (struct super_bl
2671 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2672 + !(sb->s_flags & MS_TAGGED)) {
2673 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2678 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2679 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2681 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/symlink.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/symlink.c
2682 --- linux-2.6.27.3/fs/ext2/symlink.c 2008-07-13 23:51:29.000000000 +0200
2683 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/symlink.c 2008-10-13 14:54:20.000000000 +0200
2684 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
2685 .listxattr = ext2_listxattr,
2686 .removexattr = generic_removexattr,
2688 + .sync_flags = ext2_sync_flags,
2691 const struct inode_operations ext2_fast_symlink_inode_operations = {
2692 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
2693 .listxattr = ext2_listxattr,
2694 .removexattr = generic_removexattr,
2696 + .sync_flags = ext2_sync_flags,
2698 diff -NurpP --minimal linux-2.6.27.3/fs/ext2/xattr.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/xattr.c
2699 --- linux-2.6.27.3/fs/ext2/xattr.c 2008-07-13 23:51:29.000000000 +0200
2700 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext2/xattr.c 2008-10-13 14:54:20.000000000 +0200
2702 #include <linux/mbcache.h>
2703 #include <linux/quotaops.h>
2704 #include <linux/rwsem.h>
2705 +#include <linux/vs_dlimit.h>
2709 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
2711 ea_bdebug(new_bh, "reusing block");
2714 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
2717 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
2718 + DLIMIT_FREE_BLOCK(inode, 1);
2719 unlock_buffer(new_bh);
2722 @@ -731,6 +736,7 @@ ext2_xattr_set2(struct inode *inode, str
2723 le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
2725 mb_cache_entry_release(ce);
2726 + DLIMIT_FREE_BLOCK(inode, 1);
2727 DQUOT_FREE_BLOCK(inode, 1);
2728 mark_buffer_dirty(old_bh);
2729 ea_bdebug(old_bh, "refcount now=%d",
2730 @@ -794,6 +800,7 @@ ext2_xattr_delete_inode(struct inode *in
2731 mark_buffer_dirty(bh);
2733 sync_dirty_buffer(bh);
2734 + DLIMIT_FREE_BLOCK(inode, 1);
2735 DQUOT_FREE_BLOCK(inode, 1);
2737 EXT2_I(inode)->i_file_acl = 0;
2738 diff -NurpP --minimal linux-2.6.27.3/fs/ext3/balloc.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/balloc.c
2739 --- linux-2.6.27.3/fs/ext3/balloc.c 2008-07-13 23:51:29.000000000 +0200
2740 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/balloc.c 2008-10-13 14:54:20.000000000 +0200
2742 #include <linux/ext3_jbd.h>
2743 #include <linux/quotaops.h>
2744 #include <linux/buffer_head.h>
2745 +#include <linux/vs_dlimit.h>
2746 +#include <linux/vs_tag.h>
2749 * balloc.c contains the blocks allocation and deallocation routines
2750 @@ -675,8 +677,10 @@ void ext3_free_blocks(handle_t *handle,
2753 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
2754 - if (dquot_freed_blocks)
2755 + if (dquot_freed_blocks) {
2756 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
2757 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
2762 @@ -1415,18 +1419,33 @@ out:
2764 * Check if filesystem has at least 1 free block available for allocation.
2766 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
2767 +static int ext3_has_free_blocks(struct super_block *sb)
2769 - ext3_fsblk_t free_blocks, root_blocks;
2770 + struct ext3_sb_info *sbi = EXT3_SB(sb);
2771 + unsigned long long free_blocks, root_blocks;
2774 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
2775 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
2776 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
2778 + vxdprintk(VXD_CBIT(dlim, 3),
2779 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
2780 + sb, free_blocks, root_blocks);
2782 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
2784 + cond = (free_blocks < root_blocks + 1 &&
2785 + !capable(CAP_SYS_RESOURCE) &&
2786 sbi->s_resuid != current->fsuid &&
2787 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
2791 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
2793 + vxdprintk(VXD_CBIT(dlim, 3),
2794 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
2795 + sb, free_blocks, root_blocks,
2796 + !capable(CAP_SYS_RESOURCE)?'1':'0',
2797 + sbi->s_resuid, current->fsuid, cond?0:1);
2799 + return (cond ? 0 : 1);
2803 @@ -1443,7 +1462,7 @@ static int ext3_has_free_blocks(struct e
2805 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
2807 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
2808 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
2811 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
2812 @@ -1506,6 +1525,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
2816 + if (DLIMIT_ALLOC_BLOCK(inode, num))
2820 es = EXT3_SB(sb)->s_es;
2821 @@ -1522,7 +1543,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
2822 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
2823 my_rsv = &block_i->rsv_window_node;
2825 - if (!ext3_has_free_blocks(sbi)) {
2826 + if (!ext3_has_free_blocks(sb)) {
2830 @@ -1714,12 +1735,16 @@ allocated:
2833 DQUOT_FREE_BLOCK(inode, *count-num);
2834 + DLIMIT_FREE_BLOCK(inode, *count-num);
2841 + if (!performed_allocation)
2842 + DLIMIT_FREE_BLOCK(inode, *count);
2846 ext3_std_error(sb, fatal);
2847 diff -NurpP --minimal linux-2.6.27.3/fs/ext3/file.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/file.c
2848 --- linux-2.6.27.3/fs/ext3/file.c 2008-07-13 23:51:29.000000000 +0200
2849 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/file.c 2008-10-13 14:54:20.000000000 +0200
2850 @@ -134,5 +134,6 @@ const struct inode_operations ext3_file_
2851 .removexattr = generic_removexattr,
2853 .permission = ext3_permission,
2854 + .sync_flags = ext3_sync_flags,
2857 diff -NurpP --minimal linux-2.6.27.3/fs/ext3/ialloc.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/ialloc.c
2858 --- linux-2.6.27.3/fs/ext3/ialloc.c 2008-10-13 14:52:05.000000000 +0200
2859 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/ialloc.c 2008-10-13 14:54:20.000000000 +0200
2861 #include <linux/buffer_head.h>
2862 #include <linux/random.h>
2863 #include <linux/bitops.h>
2864 +#include <linux/vs_dlimit.h>
2865 +#include <linux/vs_tag.h>
2867 #include <asm/byteorder.h>
2869 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
2870 ext3_xattr_delete_inode(handle, inode);
2871 DQUOT_FREE_INODE(inode);
2873 + DLIMIT_FREE_INODE(inode);
2875 is_directory = S_ISDIR(inode->i_mode);
2877 @@ -440,6 +443,12 @@ struct inode *ext3_new_inode(handle_t *h
2878 inode = new_inode(sb);
2880 return ERR_PTR(-ENOMEM);
2882 + inode->i_tag = dx_current_fstag(sb);
2883 + if (DLIMIT_ALLOC_INODE(inode)) {
2890 @@ -559,7 +568,8 @@ got:
2891 ei->i_dir_start_lookup = 0;
2894 - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
2895 + ei->i_flags = EXT3_I(dir)->i_flags &
2896 + ~(EXT3_INDEX_FL|EXT3_IXUNLINK_FL|EXT3_BARRIER_FL);
2898 ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
2899 /* dirsync only applies to directories */
2900 @@ -614,6 +624,8 @@ got:
2902 ext3_std_error(sb, err);
2904 + DLIMIT_FREE_INODE(inode);
2909 @@ -625,6 +637,7 @@ fail_free_drop:
2913 + DLIMIT_FREE_INODE(inode);
2914 inode->i_flags |= S_NOQUOTA;
2917 diff -NurpP --minimal linux-2.6.27.3/fs/ext3/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/inode.c
2918 --- linux-2.6.27.3/fs/ext3/inode.c 2008-10-13 14:52:05.000000000 +0200
2919 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/inode.c 2008-10-13 14:54:20.000000000 +0200
2921 #include <linux/mpage.h>
2922 #include <linux/uio.h>
2923 #include <linux/bio.h>
2924 +#include <linux/vs_tag.h>
2928 @@ -2272,7 +2273,7 @@ static void ext3_free_branches(handle_t
2930 int ext3_can_truncate(struct inode *inode)
2932 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2933 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2935 if (S_ISREG(inode->i_mode))
2937 @@ -2646,36 +2647,84 @@ void ext3_set_inode_flags(struct inode *
2939 unsigned int flags = EXT3_I(inode)->i_flags;
2941 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2942 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2943 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2945 + if (flags & EXT3_IMMUTABLE_FL)
2946 + inode->i_flags |= S_IMMUTABLE;
2947 + if (flags & EXT3_IXUNLINK_FL)
2948 + inode->i_flags |= S_IXUNLINK;
2950 if (flags & EXT3_SYNC_FL)
2951 inode->i_flags |= S_SYNC;
2952 if (flags & EXT3_APPEND_FL)
2953 inode->i_flags |= S_APPEND;
2954 - if (flags & EXT3_IMMUTABLE_FL)
2955 - inode->i_flags |= S_IMMUTABLE;
2956 if (flags & EXT3_NOATIME_FL)
2957 inode->i_flags |= S_NOATIME;
2958 if (flags & EXT3_DIRSYNC_FL)
2959 inode->i_flags |= S_DIRSYNC;
2961 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2963 + if (flags & EXT3_BARRIER_FL)
2964 + inode->i_vflags |= V_BARRIER;
2965 + if (flags & EXT3_COW_FL)
2966 + inode->i_vflags |= V_COW;
2969 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2970 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2972 unsigned int flags = ei->vfs_inode.i_flags;
2973 + unsigned int vflags = ei->vfs_inode.i_vflags;
2975 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2976 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2977 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2978 + EXT3_BARRIER_FL | EXT3_COW_FL);
2980 + if (flags & S_IMMUTABLE)
2981 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2982 + if (flags & S_IXUNLINK)
2983 + ei->i_flags |= EXT3_IXUNLINK_FL;
2985 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2986 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2988 ei->i_flags |= EXT3_SYNC_FL;
2989 if (flags & S_APPEND)
2990 ei->i_flags |= EXT3_APPEND_FL;
2991 - if (flags & S_IMMUTABLE)
2992 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2993 if (flags & S_NOATIME)
2994 ei->i_flags |= EXT3_NOATIME_FL;
2995 if (flags & S_DIRSYNC)
2996 ei->i_flags |= EXT3_DIRSYNC_FL;
2998 + if (vflags & V_BARRIER)
2999 + ei->i_flags |= EXT3_BARRIER_FL;
3000 + if (vflags & V_COW)
3001 + ei->i_flags |= EXT3_COW_FL;
3004 +int ext3_sync_flags(struct inode *inode)
3006 + struct ext3_iloc iloc;
3010 + handle = ext3_journal_start(inode, 1);
3011 + if (IS_ERR(handle))
3012 + return PTR_ERR(handle);
3013 + if (IS_SYNC(inode))
3014 + handle->h_sync = 1;
3015 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3019 + ext3_get_inode_flags(EXT3_I(inode));
3020 + inode->i_ctime = CURRENT_TIME;
3022 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3024 + ext3_journal_stop(handle);
3028 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3029 @@ -2687,6 +2736,8 @@ struct inode *ext3_iget(struct super_blo
3030 struct inode *inode;
3036 inode = iget_locked(sb, ino);
3038 @@ -2707,12 +2758,17 @@ struct inode *ext3_iget(struct super_blo
3040 raw_inode = ext3_raw_inode(&iloc);
3041 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3042 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3043 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3044 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3045 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3046 if(!(test_opt (inode->i_sb, NO_UID32))) {
3047 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3048 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3049 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3050 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3052 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3053 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3054 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3055 + le16_to_cpu(raw_inode->i_raw_tag));
3057 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3058 inode->i_size = le32_to_cpu(raw_inode->i_size);
3059 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3060 @@ -2841,6 +2897,8 @@ static int ext3_do_update_inode(handle_t
3061 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3062 struct ext3_inode_info *ei = EXT3_I(inode);
3063 struct buffer_head *bh = iloc->bh;
3064 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3065 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3066 int err = 0, rc, block;
3068 /* For fields not not tracking in the in-memory inode,
3069 @@ -2851,29 +2909,32 @@ static int ext3_do_update_inode(handle_t
3070 ext3_get_inode_flags(ei);
3071 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3072 if(!(test_opt(inode->i_sb, NO_UID32))) {
3073 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3074 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3075 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3076 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3078 * Fix up interoperability with old kernels. Otherwise, old inodes get
3079 * re-used with the upper 16 bits of the uid/gid intact
3082 raw_inode->i_uid_high =
3083 - cpu_to_le16(high_16_bits(inode->i_uid));
3084 + cpu_to_le16(high_16_bits(uid));
3085 raw_inode->i_gid_high =
3086 - cpu_to_le16(high_16_bits(inode->i_gid));
3087 + cpu_to_le16(high_16_bits(gid));
3089 raw_inode->i_uid_high = 0;
3090 raw_inode->i_gid_high = 0;
3093 raw_inode->i_uid_low =
3094 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3095 + cpu_to_le16(fs_high2lowuid(uid));
3096 raw_inode->i_gid_low =
3097 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3098 + cpu_to_le16(fs_high2lowgid(gid));
3099 raw_inode->i_uid_high = 0;
3100 raw_inode->i_gid_high = 0;
3102 +#ifdef CONFIG_TAGGING_INTERN
3103 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3105 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3106 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3107 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3108 @@ -3026,7 +3087,8 @@ int ext3_setattr(struct dentry *dentry,
3111 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3112 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3113 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3114 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3117 /* (user+group)*(old+new) structure, inode write (sb,
3118 @@ -3048,6 +3110,8 @@ int ext3_setattr(struct dentry *dentry,
3119 inode->i_uid = attr->ia_uid;
3120 if (attr->ia_valid & ATTR_GID)
3121 inode->i_gid = attr->ia_gid;
3122 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3123 + inode->i_tag = attr->ia_tag;
3124 error = ext3_mark_inode_dirty(handle, inode);
3125 ext3_journal_stop(handle);
3127 diff -NurpP --minimal linux-2.6.27.3/fs/ext3/ioctl.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/ioctl.c
3128 --- linux-2.6.27.3/fs/ext3/ioctl.c 2008-07-13 23:51:29.000000000 +0200
3129 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/ioctl.c 2008-10-13 14:54:20.000000000 +0200
3133 #include <linux/fs.h>
3134 +#include <linux/mount.h>
3135 #include <linux/jbd.h>
3136 #include <linux/capability.h>
3137 #include <linux/ext3_fs.h>
3139 #include <linux/time.h>
3140 #include <linux/compat.h>
3141 #include <linux/smp_lock.h>
3142 +#include <linux/vs_tag.h>
3143 #include <asm/uaccess.h>
3145 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
3146 @@ -56,6 +58,11 @@ int ext3_ioctl (struct inode * inode, st
3147 if (!S_ISDIR(inode->i_mode))
3148 flags &= ~EXT3_DIRSYNC_FL;
3150 + if (IS_BARRIER(inode)) {
3151 + vxwprintk_task(1, "messing with the barrier.");
3155 mutex_lock(&inode->i_mutex);
3156 /* Is it quota file? Do not allow user to mess with it */
3157 if (IS_NOQUOTA(inode)) {
3158 @@ -74,7 +81,9 @@ int ext3_ioctl (struct inode * inode, st
3160 * This test looks nicer. Thanks to Pauline Middelink
3162 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3163 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3164 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3165 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3166 if (!capable(CAP_LINUX_IMMUTABLE)) {
3167 mutex_unlock(&inode->i_mutex);
3169 diff -NurpP --minimal linux-2.6.27.3/fs/ext3/namei.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/namei.c
3170 --- linux-2.6.27.3/fs/ext3/namei.c 2008-10-13 14:52:05.000000000 +0200
3171 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/namei.c 2008-10-13 14:54:20.000000000 +0200
3173 #include <linux/quotaops.h>
3174 #include <linux/buffer_head.h>
3175 #include <linux/bio.h>
3176 +#include <linux/vs_tag.h>
3180 @@ -912,6 +913,7 @@ restart:
3182 ll_rw_block(READ_META, 1, &bh);
3184 + dx_propagate_tag(nd, inode);
3186 if ((bh = bh_use[ra_ptr++]) == NULL)
3188 @@ -2426,6 +2428,7 @@ const struct inode_operations ext3_dir_i
3189 .removexattr = generic_removexattr,
3191 .permission = ext3_permission,
3192 + .sync_flags = ext3_sync_flags,
3195 const struct inode_operations ext3_special_inode_operations = {
3196 @@ -2437,4 +2440,5 @@ const struct inode_operations ext3_speci
3197 .removexattr = generic_removexattr,
3199 .permission = ext3_permission,
3200 + .sync_flags = ext3_sync_flags,
3202 diff -NurpP --minimal linux-2.6.27.3/fs/ext3/super.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/super.c
3203 --- linux-2.6.27.3/fs/ext3/super.c 2008-10-13 14:52:05.000000000 +0200
3204 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/super.c 2008-10-13 14:54:20.000000000 +0200
3205 @@ -757,7 +757,7 @@ enum {
3206 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3207 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
3208 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3210 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3213 static match_table_t tokens = {
3214 @@ -808,6 +808,9 @@ static match_table_t tokens = {
3215 {Opt_usrquota, "usrquota"},
3216 {Opt_barrier, "barrier=%u"},
3217 {Opt_resize, "resize"},
3219 + {Opt_notag, "notag"},
3220 + {Opt_tagid, "tagid=%u"},
3224 @@ -900,6 +903,20 @@ static int parse_options (char *options,
3226 set_opt (sbi->s_mount_opt, NO_UID32);
3228 +#ifndef CONFIG_TAGGING_NONE
3230 + set_opt (sbi->s_mount_opt, TAGGED);
3233 + clear_opt (sbi->s_mount_opt, TAGGED);
3236 +#ifdef CONFIG_PROPAGATE
3239 + set_opt (sbi->s_mount_opt, TAGGED);
3243 clear_opt (sbi->s_mount_opt, CHECK);
3245 @@ -1609,6 +1626,9 @@ static int ext3_fill_super (struct super
3249 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3250 + sb->s_flags |= MS_TAGGED;
3252 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3253 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3255 @@ -2447,6 +2467,13 @@ static int ext3_remount (struct super_bl
3256 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3257 ext3_abort(sb, __func__, "Abort forced by user");
3259 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3260 + !(sb->s_flags & MS_TAGGED)) {
3261 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3266 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3267 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3269 diff -NurpP --minimal linux-2.6.27.3/fs/ext3/symlink.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/symlink.c
3270 --- linux-2.6.27.3/fs/ext3/symlink.c 2008-07-13 23:51:29.000000000 +0200
3271 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/symlink.c 2008-10-13 14:54:20.000000000 +0200
3272 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
3273 .listxattr = ext3_listxattr,
3274 .removexattr = generic_removexattr,
3276 + .sync_flags = ext3_sync_flags,
3279 const struct inode_operations ext3_fast_symlink_inode_operations = {
3280 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
3281 .listxattr = ext3_listxattr,
3282 .removexattr = generic_removexattr,
3284 + .sync_flags = ext3_sync_flags,
3286 diff -NurpP --minimal linux-2.6.27.3/fs/ext3/xattr.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/xattr.c
3287 --- linux-2.6.27.3/fs/ext3/xattr.c 2008-07-13 23:51:29.000000000 +0200
3288 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext3/xattr.c 2008-10-13 14:54:20.000000000 +0200
3290 #include <linux/mbcache.h>
3291 #include <linux/quotaops.h>
3292 #include <linux/rwsem.h>
3293 +#include <linux/vs_dlimit.h>
3297 @@ -498,6 +499,7 @@ ext3_xattr_release_block(handle_t *handl
3298 error = ext3_journal_dirty_metadata(handle, bh);
3301 + DLIMIT_FREE_BLOCK(inode, 1);
3302 DQUOT_FREE_BLOCK(inode, 1);
3303 ea_bdebug(bh, "refcount now=%d; releasing",
3304 le32_to_cpu(BHDR(bh)->h_refcount));
3305 @@ -771,11 +773,14 @@ inserted:
3306 if (new_bh == bs->bh)
3307 ea_bdebug(new_bh, "keeping");
3310 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3312 /* The old block is released after updating
3315 if (DQUOT_ALLOC_BLOCK(inode, 1))
3317 + goto cleanup_dlimit;
3318 error = ext3_journal_get_write_access(handle,
3321 @@ -849,6 +854,8 @@ cleanup:
3324 DQUOT_FREE_BLOCK(inode, 1);
3326 + DLIMIT_FREE_BLOCK(inode, 1);
3330 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/balloc.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/balloc.c
3331 --- linux-2.6.27.3/fs/ext4/balloc.c 2008-10-13 14:52:05.000000000 +0200
3332 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/balloc.c 2008-10-13 14:54:20.000000000 +0200
3334 #include <linux/jbd2.h>
3335 #include <linux/quotaops.h>
3336 #include <linux/buffer_head.h>
3337 +#include <linux/vs_dlimit.h>
3338 +#include <linux/vs_tag.h>
3340 #include "ext4_jbd2.h"
3342 @@ -865,8 +867,10 @@ void ext4_free_blocks(handle_t *handle,
3344 ext4_mb_free_blocks(handle, inode, block, count,
3345 metadata, &dquot_freed_blocks);
3346 - if (dquot_freed_blocks)
3347 + if (dquot_freed_blocks) {
3348 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3349 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3354 @@ -1726,6 +1730,8 @@ ext4_fsblk_t ext4_old_new_blocks(handle_
3358 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3362 es = EXT4_SB(sb)->s_es;
3363 @@ -1935,12 +1941,16 @@ allocated:
3366 DQUOT_FREE_BLOCK(inode, *count-num);
3367 + DLIMIT_FREE_BLOCK(inode, *count-num);
3374 + if (!performed_allocation)
3375 + DLIMIT_FREE_BLOCK(inode, *count);
3379 ext4_std_error(sb, fatal);
3380 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/ext4.h linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/ext4.h
3381 --- linux-2.6.27.3/fs/ext4/ext4.h 2008-10-13 14:52:05.000000000 +0200
3382 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/ext4.h 2008-10-24 03:34:52.000000000 +0200
3383 @@ -242,8 +242,12 @@ struct flex_groups {
3384 #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
3385 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3386 #define EXT4_EXT_MIGRATE 0x00100000 /* Inode is migrating */
3387 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3388 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3390 +#define EXT4_BARRIER_FL 0x10000000 /* Barrier for chroot() */
3391 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3393 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
3394 #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
3396 @@ -540,6 +544,7 @@ do { \
3397 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3398 #define EXT4_MOUNT_MBALLOC 0x4000000 /* Buddy allocation support */
3399 #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
3400 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
3401 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
3402 #ifndef _LINUX_EXT2_FS_H
3403 #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
3404 @@ -1054,6 +1059,7 @@ int ext4_get_blocks_handle(handle_t *han
3405 ext4_lblk_t iblock, unsigned long maxblocks,
3406 struct buffer_head *bh_result,
3407 int create, int extend_disksize);
3408 +extern int ext4_sync_flags(struct inode *inode);
3410 extern struct inode *ext4_iget(struct super_block *, unsigned long);
3411 extern int ext4_write_inode (struct inode *, int);
3412 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/file.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/file.c
3413 --- linux-2.6.27.3/fs/ext4/file.c 2008-10-13 14:52:05.000000000 +0200
3414 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/file.c 2008-10-13 14:54:20.000000000 +0200
3415 @@ -170,5 +170,6 @@ const struct inode_operations ext4_file_
3417 .permission = ext4_permission,
3418 .fallocate = ext4_fallocate,
3419 + .sync_flags = ext4_sync_flags,
3422 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/ialloc.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/ialloc.c
3423 --- linux-2.6.27.3/fs/ext4/ialloc.c 2008-10-13 14:52:05.000000000 +0200
3424 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/ialloc.c 2008-10-13 14:54:20.000000000 +0200
3426 #include <linux/random.h>
3427 #include <linux/bitops.h>
3428 #include <linux/blkdev.h>
3429 +#include <linux/vs_dlimit.h>
3430 +#include <linux/vs_tag.h>
3431 #include <asm/byteorder.h>
3433 #include "ext4_jbd2.h"
3434 @@ -196,6 +198,7 @@ void ext4_free_inode (handle_t *handle,
3435 ext4_xattr_delete_inode(handle, inode);
3436 DQUOT_FREE_INODE(inode);
3438 + DLIMIT_FREE_INODE(inode);
3440 is_directory = S_ISDIR(inode->i_mode);
3442 @@ -602,6 +605,12 @@ struct inode *ext4_new_inode(handle_t *h
3443 inode = new_inode(sb);
3445 return ERR_PTR(-ENOMEM);
3447 + inode->i_tag = dx_current_fstag(sb);
3448 + if (DLIMIT_ALLOC_INODE(inode)) {
3455 @@ -808,7 +817,8 @@ got:
3456 * newly created directory and file only if -o extent mount option is
3459 - ei->i_flags = EXT4_I(dir)->i_flags & ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL);
3460 + ei->i_flags = EXT4_I(dir)->i_flags &
3461 + ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL|EXT4_IXUNLINK_FL|EXT4_BARRIER_FL);
3463 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
3464 /* dirsync only applies to directories */
3465 @@ -864,6 +874,8 @@ got:
3467 ext4_std_error(sb, err);
3469 + DLIMIT_FREE_INODE(inode);
3474 @@ -875,6 +887,7 @@ fail_free_drop:
3478 + DLIMIT_FREE_INODE(inode);
3479 inode->i_flags |= S_NOQUOTA;
3482 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/inode.c
3483 --- linux-2.6.27.3/fs/ext4/inode.c 2008-10-13 14:52:05.000000000 +0200
3484 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/inode.c 2008-10-13 14:54:20.000000000 +0200
3486 #include <linux/mpage.h>
3487 #include <linux/uio.h>
3488 #include <linux/bio.h>
3489 +#include <linux/vs_tag.h>
3490 #include "ext4_jbd2.h"
3493 @@ -3483,7 +3484,7 @@ static void ext4_free_branches(handle_t
3495 int ext4_can_truncate(struct inode *inode)
3497 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3498 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3500 if (S_ISREG(inode->i_mode))
3502 @@ -3842,37 +3843,86 @@ void ext4_set_inode_flags(struct inode *
3504 unsigned int flags = EXT4_I(inode)->i_flags;
3506 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3507 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3508 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3510 + if (flags & EXT4_IMMUTABLE_FL)
3511 + inode->i_flags |= S_IMMUTABLE;
3512 + if (flags & EXT4_IXUNLINK_FL)
3513 + inode->i_flags |= S_IXUNLINK;
3515 if (flags & EXT4_SYNC_FL)
3516 inode->i_flags |= S_SYNC;
3517 if (flags & EXT4_APPEND_FL)
3518 inode->i_flags |= S_APPEND;
3519 - if (flags & EXT4_IMMUTABLE_FL)
3520 - inode->i_flags |= S_IMMUTABLE;
3521 if (flags & EXT4_NOATIME_FL)
3522 inode->i_flags |= S_NOATIME;
3523 if (flags & EXT4_DIRSYNC_FL)
3524 inode->i_flags |= S_DIRSYNC;
3526 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3528 + if (flags & EXT4_BARRIER_FL)
3529 + inode->i_vflags |= V_BARRIER;
3530 + if (flags & EXT4_COW_FL)
3531 + inode->i_vflags |= V_COW;
3534 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3535 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3537 unsigned int flags = ei->vfs_inode.i_flags;
3538 + unsigned int vflags = ei->vfs_inode.i_vflags;
3540 + ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3541 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3542 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3543 + EXT4_BARRIER_FL | EXT4_COW_FL);
3545 + if (flags & S_IMMUTABLE)
3546 + ei->i_flags |= EXT4_IMMUTABLE_FL;
3547 + if (flags & S_IXUNLINK)
3548 + ei->i_flags |= EXT4_IXUNLINK_FL;
3550 - ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3551 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
3553 ei->i_flags |= EXT4_SYNC_FL;
3554 if (flags & S_APPEND)
3555 ei->i_flags |= EXT4_APPEND_FL;
3556 - if (flags & S_IMMUTABLE)
3557 - ei->i_flags |= EXT4_IMMUTABLE_FL;
3558 if (flags & S_NOATIME)
3559 ei->i_flags |= EXT4_NOATIME_FL;
3560 if (flags & S_DIRSYNC)
3561 ei->i_flags |= EXT4_DIRSYNC_FL;
3563 + if (vflags & V_BARRIER)
3564 + ei->i_flags |= EXT4_BARRIER_FL;
3565 + if (vflags & V_COW)
3566 + ei->i_flags |= EXT4_COW_FL;
3569 +int ext4_sync_flags(struct inode *inode)
3571 + struct ext4_iloc iloc;
3575 + handle = ext4_journal_start(inode, 1);
3576 + if (IS_ERR(handle))
3577 + return PTR_ERR(handle);
3578 + if (IS_SYNC(inode))
3579 + handle->h_sync = 1;
3580 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3584 + ext4_get_inode_flags(EXT4_I(inode));
3585 + inode->i_ctime = CURRENT_TIME;
3587 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3589 + ext4_journal_stop(handle);
3593 static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
3594 struct ext4_inode_info *ei)
3596 @@ -3905,6 +3955,8 @@ struct inode *ext4_iget(struct super_blo
3597 struct inode *inode;
3603 inode = iget_locked(sb, ino);
3605 @@ -3925,12 +3977,17 @@ struct inode *ext4_iget(struct super_blo
3607 raw_inode = ext4_raw_inode(&iloc);
3608 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3609 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3610 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3611 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3612 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3613 if(!(test_opt (inode->i_sb, NO_UID32))) {
3614 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3615 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3616 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3617 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3619 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3620 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3621 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3622 + le16_to_cpu(raw_inode->i_raw_tag));
3624 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3627 @@ -4104,6 +4161,8 @@ static int ext4_do_update_inode(handle_t
3628 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3629 struct ext4_inode_info *ei = EXT4_I(inode);
3630 struct buffer_head *bh = iloc->bh;
3631 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3632 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3633 int err = 0, rc, block;
3635 /* For fields not not tracking in the in-memory inode,
3636 @@ -4114,29 +4173,32 @@ static int ext4_do_update_inode(handle_t
3637 ext4_get_inode_flags(ei);
3638 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3639 if(!(test_opt(inode->i_sb, NO_UID32))) {
3640 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3641 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3642 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3643 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3645 * Fix up interoperability with old kernels. Otherwise, old inodes get
3646 * re-used with the upper 16 bits of the uid/gid intact
3649 raw_inode->i_uid_high =
3650 - cpu_to_le16(high_16_bits(inode->i_uid));
3651 + cpu_to_le16(high_16_bits(uid));
3652 raw_inode->i_gid_high =
3653 - cpu_to_le16(high_16_bits(inode->i_gid));
3654 + cpu_to_le16(high_16_bits(gid));
3656 raw_inode->i_uid_high = 0;
3657 raw_inode->i_gid_high = 0;
3660 raw_inode->i_uid_low =
3661 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3662 + cpu_to_le16(fs_high2lowuid(uid));
3663 raw_inode->i_gid_low =
3664 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3665 + cpu_to_le16(fs_high2lowgid(gid));
3666 raw_inode->i_uid_high = 0;
3667 raw_inode->i_gid_high = 0;
3669 +#ifdef CONFIG_TAGGING_INTERN
3670 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3672 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3674 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3675 @@ -4300,7 +4362,8 @@ int ext4_setattr(struct dentry *dentry,
3678 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3679 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3680 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3681 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3684 /* (user+group)*(old+new) structure, inode write (sb,
3685 @@ -4322,6 +4385,8 @@ int ext4_setattr(struct dentry *dentry,
3686 inode->i_uid = attr->ia_uid;
3687 if (attr->ia_valid & ATTR_GID)
3688 inode->i_gid = attr->ia_gid;
3689 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3690 + inode->i_tag = attr->ia_tag;
3691 error = ext4_mark_inode_dirty(handle, inode);
3692 ext4_journal_stop(handle);
3694 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/ioctl.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/ioctl.c
3695 --- linux-2.6.27.3/fs/ext4/ioctl.c 2008-07-13 23:51:29.000000000 +0200
3696 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/ioctl.c 2008-10-13 14:54:20.000000000 +0200
3700 #include <linux/fs.h>
3701 +#include <linux/mount.h>
3702 #include <linux/jbd2.h>
3703 #include <linux/capability.h>
3704 #include <linux/time.h>
3705 #include <linux/compat.h>
3706 #include <linux/smp_lock.h>
3707 #include <linux/mount.h>
3708 +#include <linux/vs_tag.h>
3709 #include <asm/uaccess.h>
3710 #include "ext4_jbd2.h"
3712 @@ -52,6 +54,11 @@ long ext4_ioctl(struct file *filp, unsig
3713 if (!S_ISDIR(inode->i_mode))
3714 flags &= ~EXT4_DIRSYNC_FL;
3716 + if (IS_BARRIER(inode)) {
3717 + vxwprintk_task(1, "messing with the barrier.");
3722 mutex_lock(&inode->i_mutex);
3723 /* Is it quota file? Do not allow user to mess with it */
3724 @@ -69,7 +76,9 @@ long ext4_ioctl(struct file *filp, unsig
3726 * This test looks nicer. Thanks to Pauline Middelink
3728 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3729 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3730 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3731 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3732 if (!capable(CAP_LINUX_IMMUTABLE))
3735 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/namei.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/namei.c
3736 --- linux-2.6.27.3/fs/ext4/namei.c 2008-10-13 14:52:05.000000000 +0200
3737 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/namei.c 2008-10-13 14:54:20.000000000 +0200
3739 #include <linux/quotaops.h>
3740 #include <linux/buffer_head.h>
3741 #include <linux/bio.h>
3742 +#include <linux/vs_tag.h>
3744 #include "ext4_jbd2.h"
3746 @@ -914,6 +915,7 @@ restart:
3748 ll_rw_block(READ_META, 1, &bh);
3750 + dx_propagate_tag(nd, inode);
3752 if ((bh = bh_use[ra_ptr++]) == NULL)
3754 @@ -2461,6 +2463,7 @@ const struct inode_operations ext4_dir_i
3755 .removexattr = generic_removexattr,
3757 .permission = ext4_permission,
3758 + .sync_flags = ext4_sync_flags,
3761 const struct inode_operations ext4_special_inode_operations = {
3762 @@ -2472,4 +2475,5 @@ const struct inode_operations ext4_speci
3763 .removexattr = generic_removexattr,
3765 .permission = ext4_permission,
3766 + .sync_flags = ext4_sync_flags,
3768 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/super.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/super.c
3769 --- linux-2.6.27.3/fs/ext4/super.c 2008-10-13 14:52:05.000000000 +0200
3770 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/super.c 2008-10-13 14:54:20.000000000 +0200
3771 @@ -907,6 +907,7 @@ enum {
3772 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3773 Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
3774 Opt_mballoc, Opt_nomballoc, Opt_stripe, Opt_delalloc, Opt_nodelalloc,
3775 + Opt_tag, Opt_notag, Opt_tagid
3778 static match_table_t tokens = {
3779 @@ -967,6 +968,9 @@ static match_table_t tokens = {
3780 {Opt_resize, "resize"},
3781 {Opt_delalloc, "delalloc"},
3782 {Opt_nodelalloc, "nodelalloc"},
3784 + {Opt_notag, "notag"},
3785 + {Opt_tagid, "tagid=%u"},
3789 @@ -1060,6 +1064,20 @@ static int parse_options(char *options,
3791 set_opt(sbi->s_mount_opt, NO_UID32);
3793 +#ifndef CONFIG_TAGGING_NONE
3795 + set_opt (sbi->s_mount_opt, TAGGED);
3798 + clear_opt (sbi->s_mount_opt, TAGGED);
3801 +#ifdef CONFIG_PROPAGATE
3804 + set_opt (sbi->s_mount_opt, TAGGED);
3808 clear_opt(sbi->s_mount_opt, CHECK);
3810 @@ -2029,6 +2047,9 @@ static int ext4_fill_super(struct super_
3814 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3815 + sb->s_flags |= MS_TAGGED;
3817 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3818 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3820 @@ -2988,6 +3009,13 @@ static int ext4_remount(struct super_blo
3821 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
3822 ext4_abort(sb, __func__, "Abort forced by user");
3824 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3825 + !(sb->s_flags & MS_TAGGED)) {
3826 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3831 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3832 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3834 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/symlink.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/symlink.c
3835 --- linux-2.6.27.3/fs/ext4/symlink.c 2008-07-13 23:51:29.000000000 +0200
3836 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/symlink.c 2008-10-13 14:54:20.000000000 +0200
3837 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
3838 .listxattr = ext4_listxattr,
3839 .removexattr = generic_removexattr,
3841 + .sync_flags = ext4_sync_flags,
3844 const struct inode_operations ext4_fast_symlink_inode_operations = {
3845 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
3846 .listxattr = ext4_listxattr,
3847 .removexattr = generic_removexattr,
3849 + .sync_flags = ext4_sync_flags,
3851 diff -NurpP --minimal linux-2.6.27.3/fs/ext4/xattr.c linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/xattr.c
3852 --- linux-2.6.27.3/fs/ext4/xattr.c 2008-10-13 14:52:05.000000000 +0200
3853 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ext4/xattr.c 2008-10-13 14:54:20.000000000 +0200
3855 #include <linux/mbcache.h>
3856 #include <linux/quotaops.h>
3857 #include <linux/rwsem.h>
3858 +#include <linux/vs_dlimit.h>
3859 #include "ext4_jbd2.h"
3862 @@ -490,6 +491,7 @@ ext4_xattr_release_block(handle_t *handl
3863 error = ext4_journal_dirty_metadata(handle, bh);
3866 + DLIMIT_FREE_BLOCK(inode, 1);
3867 DQUOT_FREE_BLOCK(inode, 1);
3868 ea_bdebug(bh, "refcount now=%d; releasing",
3869 le32_to_cpu(BHDR(bh)->h_refcount));
3870 @@ -780,11 +782,14 @@ inserted:
3871 if (new_bh == bs->bh)
3872 ea_bdebug(new_bh, "keeping");
3875 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3877 /* The old block is released after updating
3880 if (DQUOT_ALLOC_BLOCK(inode, 1))
3882 + goto cleanup_dlimit;
3883 error = ext4_journal_get_write_access(handle,
3886 @@ -858,6 +863,8 @@ cleanup:
3889 DQUOT_FREE_BLOCK(inode, 1);
3891 + DLIMIT_FREE_BLOCK(inode, 1);
3895 diff -NurpP --minimal linux-2.6.27.3/fs/fcntl.c linux-2.6.27.3-vs2.3.0.35.7/fs/fcntl.c
3896 --- linux-2.6.27.3/fs/fcntl.c 2008-10-13 14:52:05.000000000 +0200
3897 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/fcntl.c 2008-10-24 04:44:48.000000000 +0200
3899 #include <linux/signal.h>
3900 #include <linux/rcupdate.h>
3901 #include <linux/pid_namespace.h>
3902 +#include <linux/vs_limit.h>
3904 #include <asm/poll.h>
3905 #include <asm/siginfo.h>
3906 @@ -102,6 +103,8 @@ asmlinkage long sys_dup3(unsigned int ol
3909 filp_close(tofree, files);
3911 + vx_openfd_inc(newfd); /* fd was unused */
3915 @@ -335,6 +338,8 @@ asmlinkage long sys_fcntl(unsigned int f
3919 + if (!vx_files_avail(1))
3922 err = security_file_fcntl(filp, cmd, arg);
3924 diff -NurpP --minimal linux-2.6.27.3/fs/file.c linux-2.6.27.3-vs2.3.0.35.7/fs/file.c
3925 --- linux-2.6.27.3/fs/file.c 2008-10-13 14:52:05.000000000 +0200
3926 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/file.c 2008-10-24 04:44:48.000000000 +0200
3928 #include <linux/spinlock.h>
3929 #include <linux/rcupdate.h>
3930 #include <linux/workqueue.h>
3931 +#include <linux/vs_limit.h>
3933 struct fdtable_defer {
3935 @@ -367,6 +368,8 @@ struct files_struct *dup_fd(struct files
3936 struct file *f = *old_fds++;
3939 + /* TODO: sum it first for check and performance */
3940 + vx_openfd_inc(open_files - i);
3943 * The fd may be claimed in the fd bitmap but not yet
3944 @@ -475,6 +478,7 @@ repeat:
3946 FD_CLR(fd, fdt->close_on_exec);
3948 + vx_openfd_inc(fd);
3951 if (rcu_dereference(fdt->fd[fd]) != NULL) {
3952 diff -NurpP --minimal linux-2.6.27.3/fs/file_table.c linux-2.6.27.3-vs2.3.0.35.7/fs/file_table.c
3953 --- linux-2.6.27.3/fs/file_table.c 2008-10-13 14:52:05.000000000 +0200
3954 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/file_table.c 2008-10-13 14:54:20.000000000 +0200
3956 #include <linux/fsnotify.h>
3957 #include <linux/sysctl.h>
3958 #include <linux/percpu_counter.h>
3959 +#include <linux/vs_limit.h>
3960 +#include <linux/vs_context.h>
3962 #include <asm/atomic.h>
3964 @@ -126,6 +128,8 @@ struct file *get_empty_filp(void)
3965 f->f_gid = tsk->fsgid;
3966 eventpoll_init_file(f);
3967 /* f->f_version: 0 */
3968 + f->f_xid = vx_current_xid();
3973 @@ -276,6 +280,8 @@ void __fput(struct file *file)
3974 cdev_put(inode->i_cdev);
3975 fops_put(file->f_op);
3976 put_pid(file->f_owner.pid);
3977 + vx_files_dec(file);
3980 if (file->f_mode & FMODE_WRITE)
3981 drop_file_write_access(file);
3982 @@ -343,6 +349,8 @@ void put_filp(struct file *file)
3984 if (atomic_long_dec_and_test(&file->f_count)) {
3985 security_file_free(file);
3986 + vx_files_dec(file);
3991 diff -NurpP --minimal linux-2.6.27.3/fs/hfsplus/ioctl.c linux-2.6.27.3-vs2.3.0.35.7/fs/hfsplus/ioctl.c
3992 --- linux-2.6.27.3/fs/hfsplus/ioctl.c 2008-07-13 23:51:29.000000000 +0200
3993 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/hfsplus/ioctl.c 2008-10-13 14:54:20.000000000 +0200
3995 #include <linux/mount.h>
3996 #include <linux/sched.h>
3997 #include <linux/xattr.h>
3998 +#include <linux/mount.h>
3999 #include <asm/uaccess.h>
4000 #include "hfsplus_fs.h"
4002 diff -NurpP --minimal linux-2.6.27.3/fs/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/inode.c
4003 --- linux-2.6.27.3/fs/inode.c 2008-10-13 14:52:05.000000000 +0200
4004 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/inode.c 2008-10-13 14:54:20.000000000 +0200
4005 @@ -124,6 +124,9 @@ static struct inode *alloc_inode(struct
4006 struct address_space * const mapping = &inode->i_data;
4010 + /* essential because of inode slab reuse */
4012 inode->i_blkbits = sb->s_blocksize_bits;
4014 atomic_set(&inode->i_count, 1);
4015 @@ -142,6 +145,7 @@ static struct inode *alloc_inode(struct
4016 inode->i_bdev = NULL;
4017 inode->i_cdev = NULL;
4019 + inode->i_mdev = 0;
4020 inode->dirtied_when = 0;
4021 if (security_inode_alloc(inode)) {
4022 if (inode->i_sb->s_op->destroy_inode)
4023 @@ -247,6 +251,8 @@ void __iget(struct inode * inode)
4024 inodes_stat.nr_unused--;
4027 +EXPORT_SYMBOL_GPL(__iget);
4030 * clear_inode - clear an inode
4031 * @inode: inode to clear
4032 @@ -1427,9 +1433,11 @@ void init_special_inode(struct inode *in
4033 if (S_ISCHR(mode)) {
4034 inode->i_fop = &def_chr_fops;
4035 inode->i_rdev = rdev;
4036 + inode->i_mdev = rdev;
4037 } else if (S_ISBLK(mode)) {
4038 inode->i_fop = &def_blk_fops;
4039 inode->i_rdev = rdev;
4040 + inode->i_mdev = rdev;
4041 } else if (S_ISFIFO(mode))
4042 inode->i_fop = &def_fifo_fops;
4043 else if (S_ISSOCK(mode))
4044 diff -NurpP --minimal linux-2.6.27.3/fs/ioctl.c linux-2.6.27.3-vs2.3.0.35.7/fs/ioctl.c
4045 --- linux-2.6.27.3/fs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
4046 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ioctl.c 2008-10-13 14:54:20.000000000 +0200
4048 #include <linux/security.h>
4049 #include <linux/module.h>
4050 #include <linux/uaccess.h>
4051 +#include <linux/proc_fs.h>
4052 +#include <linux/vserver/inode.h>
4053 +#include <linux/vs_tag.h>
4055 #include <asm/ioctls.h>
4057 diff -NurpP --minimal linux-2.6.27.3/fs/ioprio.c linux-2.6.27.3-vs2.3.0.35.7/fs/ioprio.c
4058 --- linux-2.6.27.3/fs/ioprio.c 2008-10-13 14:52:05.000000000 +0200
4059 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ioprio.c 2008-10-13 14:54:20.000000000 +0200
4061 #include <linux/syscalls.h>
4062 #include <linux/security.h>
4063 #include <linux/pid_namespace.h>
4064 +#include <linux/vs_base.h>
4066 static int set_task_ioprio(struct task_struct *task, int ioprio)
4068 @@ -116,6 +117,8 @@ asmlinkage long sys_ioprio_set(int which
4070 pgrp = find_vpid(who);
4071 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4072 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4074 ret = set_task_ioprio(p, ioprio);
4077 @@ -205,6 +208,8 @@ asmlinkage long sys_ioprio_get(int which
4079 pgrp = find_vpid(who);
4080 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4081 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4083 tmpio = get_task_ioprio(p);
4086 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/acl.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/acl.c
4087 --- linux-2.6.27.3/fs/jfs/acl.c 2008-10-13 14:52:05.000000000 +0200
4088 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/acl.c 2008-10-13 14:54:20.000000000 +0200
4089 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
4092 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4093 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4094 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4095 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4096 if (DQUOT_TRANSFER(inode, iattr))
4099 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/file.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/file.c
4100 --- linux-2.6.27.3/fs/jfs/file.c 2008-07-13 23:51:29.000000000 +0200
4101 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/file.c 2008-10-13 14:54:20.000000000 +0200
4102 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
4103 .setattr = jfs_setattr,
4104 .permission = jfs_permission,
4106 + .sync_flags = jfs_sync_flags,
4109 const struct file_operations jfs_file_operations = {
4110 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/inode.c
4111 --- linux-2.6.27.3/fs/jfs/inode.c 2008-07-13 23:51:29.000000000 +0200
4112 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/inode.c 2008-10-13 14:54:20.000000000 +0200
4114 #include <linux/buffer_head.h>
4115 #include <linux/pagemap.h>
4116 #include <linux/quotaops.h>
4117 +#include <linux/vs_dlimit.h>
4118 #include "jfs_incore.h"
4119 #include "jfs_inode.h"
4120 #include "jfs_filsys.h"
4121 @@ -155,6 +156,7 @@ void jfs_delete_inode(struct inode *inod
4123 DQUOT_FREE_INODE(inode);
4125 + DLIMIT_FREE_INODE(inode);
4129 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/ioctl.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/ioctl.c
4130 --- linux-2.6.27.3/fs/jfs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
4131 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/ioctl.c 2008-10-13 14:54:20.000000000 +0200
4133 #include <linux/mount.h>
4134 #include <linux/time.h>
4135 #include <linux/sched.h>
4136 +#include <linux/mount.h>
4137 #include <asm/current.h>
4138 #include <asm/uaccess.h>
4140 @@ -85,6 +86,11 @@ long jfs_ioctl(struct file *filp, unsign
4141 if (!S_ISDIR(inode->i_mode))
4142 flags &= ~JFS_DIRSYNC_FL;
4144 + if (IS_BARRIER(inode)) {
4145 + vxwprintk_task(1, "messing with the barrier.");
4149 /* Is it quota file? Do not allow user to mess with it */
4150 if (IS_NOQUOTA(inode)) {
4152 @@ -102,8 +108,8 @@ long jfs_ioctl(struct file *filp, unsign
4153 * the relevant capability.
4155 if ((oldflags & JFS_IMMUTABLE_FL) ||
4156 - ((flags ^ oldflags) &
4157 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4158 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4159 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4160 if (!capable(CAP_LINUX_IMMUTABLE)) {
4161 mutex_unlock(&inode->i_mutex);
4163 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/jfs_dinode.h linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_dinode.h
4164 --- linux-2.6.27.3/fs/jfs/jfs_dinode.h 2008-07-13 23:51:29.000000000 +0200
4165 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_dinode.h 2008-10-24 03:34:52.000000000 +0200
4166 @@ -161,9 +161,13 @@ struct dinode {
4168 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4169 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4170 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4172 -#define JFS_FL_USER_VISIBLE 0x03F80000
4173 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4174 +#define JFS_BARRIER_FL 0x10000000 /* Barrier for chroot() */
4175 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4177 +#define JFS_FL_USER_VISIBLE 0x07F80000
4178 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4179 #define JFS_FL_INHERIT 0x03C80000
4181 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4182 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/jfs_dtree.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_dtree.c
4183 --- linux-2.6.27.3/fs/jfs/jfs_dtree.c 2008-07-13 23:51:29.000000000 +0200
4184 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_dtree.c 2008-10-13 14:54:20.000000000 +0200
4187 #include <linux/fs.h>
4188 #include <linux/quotaops.h>
4189 +#include <linux/vs_dlimit.h>
4190 #include "jfs_incore.h"
4191 #include "jfs_superblock.h"
4192 #include "jfs_filsys.h"
4193 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
4195 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
4197 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
4198 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
4201 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
4202 + goto clean_up_dquot;
4203 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
4204 + goto clean_up_dlimit;
4207 * Save the table, we're going to overwrite it with the
4208 @@ -480,6 +481,12 @@ static u32 add_index(tid_t tid, struct i
4213 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
4216 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
4220 jfs_ip->next_index--;
4221 @@ -951,6 +958,7 @@ static int dtSplitUp(tid_t tid,
4224 int quota_allocation = 0;
4225 + int dlimit_allocation = 0;
4227 /* get split page */
4229 @@ -1033,6 +1041,12 @@ static int dtSplitUp(tid_t tid,
4231 quota_allocation += n;
4233 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
4237 + dlimit_allocation += n;
4239 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
4242 @@ -1306,6 +1320,9 @@ static int dtSplitUp(tid_t tid,
4246 + /* Rollback dlimit allocation */
4247 + if (rc && dlimit_allocation)
4248 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
4249 /* Rollback quota allocation */
4250 if (rc && quota_allocation)
4251 DQUOT_FREE_BLOCK(ip, quota_allocation);
4252 @@ -1373,6 +1390,12 @@ static int dtSplitPage(tid_t tid, struct
4253 release_metapage(rmp);
4256 + /* Allocate blocks to dlimit. */
4257 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4258 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4259 + release_metapage(rmp);
4263 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
4265 @@ -1920,6 +1943,12 @@ static int dtSplitRoot(tid_t tid,
4266 release_metapage(rmp);
4269 + /* Allocate blocks to dlimit. */
4270 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4271 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4272 + release_metapage(rmp);
4276 BT_MARK_DIRTY(rmp, ip);
4278 @@ -2286,6 +2315,8 @@ static int dtDeleteUp(tid_t tid, struct
4280 xlen = lengthPXD(&fp->header.self);
4282 + /* Free dlimit allocation. */
4283 + DLIMIT_FREE_BLOCK(ip, xlen);
4284 /* Free quota allocation. */
4285 DQUOT_FREE_BLOCK(ip, xlen);
4287 @@ -2362,6 +2393,8 @@ static int dtDeleteUp(tid_t tid, struct
4289 xlen = lengthPXD(&p->header.self);
4291 + /* Free dlimit allocation */
4292 + DLIMIT_FREE_BLOCK(ip, xlen);
4293 /* Free quota allocation */
4294 DQUOT_FREE_BLOCK(ip, xlen);
4296 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/jfs_extent.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_extent.c
4297 --- linux-2.6.27.3/fs/jfs/jfs_extent.c 2008-07-13 23:51:29.000000000 +0200
4298 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_extent.c 2008-10-13 14:54:20.000000000 +0200
4301 #include <linux/fs.h>
4302 #include <linux/quotaops.h>
4303 +#include <linux/vs_dlimit.h>
4304 #include "jfs_incore.h"
4305 #include "jfs_inode.h"
4306 #include "jfs_superblock.h"
4307 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
4311 + /* Allocate blocks to dlimit. */
4312 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4313 + DQUOT_FREE_BLOCK(ip, nxlen);
4314 + dbFree(ip, nxaddr, (s64) nxlen);
4315 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
4319 /* determine the value of the extent flag */
4320 xflag = abnr ? XAD_NOTRECORDED : 0;
4322 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
4325 dbFree(ip, nxaddr, nxlen);
4326 + DLIMIT_FREE_BLOCK(ip, nxlen);
4327 DQUOT_FREE_BLOCK(ip, nxlen);
4328 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4330 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
4331 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4334 + /* Allocate blocks to dlimit. */
4335 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4336 + DQUOT_FREE_BLOCK(ip, nxlen);
4337 + dbFree(ip, nxaddr, (s64) nxlen);
4338 + up(&JFS_IP(ip)->commit_sem);
4342 delta = nxlen - xlen;
4344 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
4345 /* extend the extent */
4346 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
4347 dbFree(ip, xaddr + xlen, delta);
4348 + DLIMIT_FREE_BLOCK(ip, nxlen);
4349 DQUOT_FREE_BLOCK(ip, nxlen);
4352 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
4354 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
4355 dbFree(ip, nxaddr, nxlen);
4356 + DLIMIT_FREE_BLOCK(ip, nxlen);
4357 DQUOT_FREE_BLOCK(ip, nxlen);
4360 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/jfs_filsys.h linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_filsys.h
4361 --- linux-2.6.27.3/fs/jfs/jfs_filsys.h 2008-07-13 23:51:29.000000000 +0200
4362 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_filsys.h 2008-10-13 14:54:20.000000000 +0200
4364 #define JFS_NAME_MAX 255
4365 #define JFS_PATH_MAX BPSIZE
4367 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4370 * file system state (superblock state)
4371 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/jfs_imap.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_imap.c
4372 --- linux-2.6.27.3/fs/jfs/jfs_imap.c 2008-10-13 14:52:05.000000000 +0200
4373 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_imap.c 2008-10-13 14:54:20.000000000 +0200
4375 #include <linux/buffer_head.h>
4376 #include <linux/pagemap.h>
4377 #include <linux/quotaops.h>
4378 +#include <linux/vs_tag.h>
4380 #include "jfs_incore.h"
4381 #include "jfs_inode.h"
4382 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
4384 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4385 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4389 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4390 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4391 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
4393 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4395 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4396 + uid = le32_to_cpu(dip->di_uid);
4397 + gid = le32_to_cpu(dip->di_gid);
4398 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4400 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4402 ip->i_uid = jfs_ip->saved_uid;
4404 ip->i_uid = sbi->uid;
4407 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4408 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4410 ip->i_gid = jfs_ip->saved_gid;
4412 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
4413 dip->di_size = cpu_to_le64(ip->i_size);
4414 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4415 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4416 - if (sbi->uid == -1)
4417 - dip->di_uid = cpu_to_le32(ip->i_uid);
4419 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4420 - if (sbi->gid == -1)
4421 - dip->di_gid = cpu_to_le32(ip->i_gid);
4423 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4425 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4426 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4427 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4428 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4430 jfs_get_inode_flags(jfs_ip);
4432 * mode2 is only needed for storing the higher order bits.
4433 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/jfs_inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_inode.c
4434 --- linux-2.6.27.3/fs/jfs/jfs_inode.c 2008-07-13 23:51:29.000000000 +0200
4435 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_inode.c 2008-10-13 14:54:20.000000000 +0200
4438 #include <linux/fs.h>
4439 #include <linux/quotaops.h>
4440 +#include <linux/vs_dlimit.h>
4441 +#include <linux/vs_tag.h>
4442 #include "jfs_incore.h"
4443 #include "jfs_inode.h"
4444 #include "jfs_filsys.h"
4445 @@ -30,29 +32,46 @@ void jfs_set_inode_flags(struct inode *i
4447 unsigned int flags = JFS_IP(inode)->mode2;
4449 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4450 - S_NOATIME | S_DIRSYNC | S_SYNC);
4451 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4452 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4454 if (flags & JFS_IMMUTABLE_FL)
4455 inode->i_flags |= S_IMMUTABLE;
4456 + if (flags & JFS_IXUNLINK_FL)
4457 + inode->i_flags |= S_IXUNLINK;
4459 + if (flags & JFS_SYNC_FL)
4460 + inode->i_flags |= S_SYNC;
4461 if (flags & JFS_APPEND_FL)
4462 inode->i_flags |= S_APPEND;
4463 if (flags & JFS_NOATIME_FL)
4464 inode->i_flags |= S_NOATIME;
4465 if (flags & JFS_DIRSYNC_FL)
4466 inode->i_flags |= S_DIRSYNC;
4467 - if (flags & JFS_SYNC_FL)
4468 - inode->i_flags |= S_SYNC;
4470 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4472 + if (flags & JFS_BARRIER_FL)
4473 + inode->i_vflags |= V_BARRIER;
4474 + if (flags & JFS_COW_FL)
4475 + inode->i_vflags |= V_COW;
4478 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4480 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4481 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4483 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4484 + JFS_APPEND_FL | JFS_NOATIME_FL |
4485 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4486 + JFS_BARRIER_FL | JFS_COW_FL);
4488 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4489 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4490 if (flags & S_IMMUTABLE)
4491 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4492 + if (flags & S_IXUNLINK)
4493 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4495 if (flags & S_APPEND)
4496 jfs_ip->mode2 |= JFS_APPEND_FL;
4497 if (flags & S_NOATIME)
4498 @@ -61,6 +80,19 @@ void jfs_get_inode_flags(struct jfs_inod
4499 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4501 jfs_ip->mode2 |= JFS_SYNC_FL;
4503 + if (vflags & V_BARRIER)
4504 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4505 + if (vflags & V_COW)
4506 + jfs_ip->mode2 |= JFS_COW_FL;
4509 +int jfs_sync_flags(struct inode *inode)
4511 + jfs_get_inode_flags(JFS_IP(inode));
4512 + inode->i_ctime = CURRENT_TIME;
4513 + mark_inode_dirty(inode);
4518 @@ -108,10 +140,17 @@ struct inode *ialloc(struct inode *paren
4519 jfs_inode->saved_uid = inode->i_uid;
4520 jfs_inode->saved_gid = inode->i_gid;
4522 + inode->i_tag = dx_current_fstag(sb);
4523 + if (DLIMIT_ALLOC_INODE(inode)) {
4525 + return ERR_PTR(-ENOSPC);
4529 * Allocate inode to quota.
4531 if (DQUOT_ALLOC_INODE(inode)) {
4532 + DLIMIT_FREE_INODE(inode);
4534 inode->i_flags |= S_NOQUOTA;
4536 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/jfs_inode.h linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_inode.h
4537 --- linux-2.6.27.3/fs/jfs/jfs_inode.h 2008-07-13 23:51:29.000000000 +0200
4538 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_inode.h 2008-10-13 14:54:20.000000000 +0200
4539 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4540 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4541 int fh_len, int fh_type);
4542 extern void jfs_set_inode_flags(struct inode *);
4543 +extern int jfs_sync_flags(struct inode *);
4544 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4546 extern const struct address_space_operations jfs_aops;
4547 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/jfs_xtree.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_xtree.c
4548 --- linux-2.6.27.3/fs/jfs/jfs_xtree.c 2008-10-13 14:52:05.000000000 +0200
4549 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/jfs_xtree.c 2008-10-13 14:54:20.000000000 +0200
4551 #include <linux/module.h>
4552 #include <linux/quotaops.h>
4553 #include <linux/seq_file.h>
4554 +#include <linux/vs_dlimit.h>
4555 #include "jfs_incore.h"
4556 #include "jfs_filsys.h"
4557 #include "jfs_metapage.h"
4558 @@ -848,7 +849,12 @@ int xtInsert(tid_t tid, /* transaction
4560 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
4562 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
4563 + DQUOT_FREE_BLOCK(ip, xlen);
4566 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
4567 + DLIMIT_FREE_BLOCK(ip, xlen);
4568 DQUOT_FREE_BLOCK(ip, xlen);
4571 @@ -878,6 +884,7 @@ int xtInsert(tid_t tid, /* transaction
4572 /* undo data extent allocation */
4574 dbFree(ip, xaddr, (s64) xlen);
4575 + DLIMIT_FREE_BLOCK(ip, xlen);
4576 DQUOT_FREE_BLOCK(ip, xlen);
4579 @@ -1234,6 +1241,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
4581 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
4582 int quota_allocation = 0;
4583 + int dlimit_allocation = 0;
4586 sp = XT_PAGE(ip, smp);
4587 @@ -1253,6 +1261,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
4589 quota_allocation += lengthPXD(pxd);
4591 + /* Allocate blocks to dlimit. */
4592 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4596 + dlimit_allocation += lengthPXD(pxd);
4599 * allocate the new right page for the split
4601 @@ -1454,6 +1469,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
4605 + /* Rollback dlimit allocation. */
4606 + if (dlimit_allocation)
4607 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
4608 /* Rollback quota allocation. */
4609 if (quota_allocation)
4610 DQUOT_FREE_BLOCK(ip, quota_allocation);
4611 @@ -1517,6 +1535,12 @@ xtSplitRoot(tid_t tid,
4612 release_metapage(rmp);
4615 + /* Allocate blocks to dlimit. */
4616 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4617 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4618 + release_metapage(rmp);
4622 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
4624 @@ -3940,6 +3964,8 @@ s64 xtTruncate(tid_t tid, struct inode *
4626 ip->i_size = newsize;
4628 + /* update dlimit allocation to reflect freed blocks */
4629 + DLIMIT_FREE_BLOCK(ip, nfreed);
4630 /* update quota allocation to reflect freed blocks */
4631 DQUOT_FREE_BLOCK(ip, nfreed);
4633 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/namei.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/namei.c
4634 --- linux-2.6.27.3/fs/jfs/namei.c 2008-10-13 14:52:05.000000000 +0200
4635 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/namei.c 2008-10-13 14:54:20.000000000 +0200
4637 #include <linux/ctype.h>
4638 #include <linux/quotaops.h>
4639 #include <linux/exportfs.h>
4640 +#include <linux/vs_tag.h>
4641 #include "jfs_incore.h"
4642 #include "jfs_superblock.h"
4643 #include "jfs_inode.h"
4644 @@ -1468,6 +1469,7 @@ static struct dentry *jfs_lookup(struct
4645 return ERR_CAST(ip);
4648 + dx_propagate_tag(nd, ip);
4649 dentry = d_splice_alias(ip, dentry);
4651 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4652 @@ -1550,6 +1552,7 @@ const struct inode_operations jfs_dir_in
4653 .setattr = jfs_setattr,
4654 .permission = jfs_permission,
4656 + .sync_flags = jfs_sync_flags,
4659 const struct file_operations jfs_dir_operations = {
4660 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/super.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/super.c
4661 --- linux-2.6.27.3/fs/jfs/super.c 2008-10-13 14:52:05.000000000 +0200
4662 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/super.c 2008-10-13 14:54:20.000000000 +0200
4663 @@ -196,7 +196,8 @@ static void jfs_put_super(struct super_b
4665 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4666 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4667 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4668 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4669 + Opt_tag, Opt_notag, Opt_tagid
4672 static match_table_t tokens = {
4673 @@ -206,6 +207,10 @@ static match_table_t tokens = {
4674 {Opt_resize, "resize=%u"},
4675 {Opt_resize_nosize, "resize"},
4676 {Opt_errors, "errors=%s"},
4678 + {Opt_notag, "notag"},
4679 + {Opt_tagid, "tagid=%u"},
4680 + {Opt_tag, "tagxid"},
4681 {Opt_ignore, "noquota"},
4682 {Opt_ignore, "quota"},
4683 {Opt_usrquota, "usrquota"},
4684 @@ -340,6 +345,20 @@ static int parse_options(char *options,
4688 +#ifndef CONFIG_TAGGING_NONE
4690 + *flag |= JFS_TAGGED;
4693 + *flag &= JFS_TAGGED;
4696 +#ifdef CONFIG_PROPAGATE
4699 + *flag |= JFS_TAGGED;
4703 printk("jfs: Unrecognized mount option \"%s\" "
4704 " or missing value\n", p);
4705 @@ -370,6 +389,13 @@ static int jfs_remount(struct super_bloc
4706 if (!parse_options(data, sb, &newLVSize, &flag)) {
4710 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4711 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4717 if (sb->s_flags & MS_RDONLY) {
4719 @@ -441,6 +467,9 @@ static int jfs_fill_super(struct super_b
4720 #ifdef CONFIG_JFS_POSIX_ACL
4721 sb->s_flags |= MS_POSIXACL;
4723 + /* map mount option tagxid */
4724 + if (sbi->flag & JFS_TAGGED)
4725 + sb->s_flags |= MS_TAGGED;
4728 printk(KERN_ERR "resize option for remount only\n");
4729 diff -NurpP --minimal linux-2.6.27.3/fs/jfs/xattr.c linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/xattr.c
4730 --- linux-2.6.27.3/fs/jfs/xattr.c 2008-07-13 23:51:29.000000000 +0200
4731 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/jfs/xattr.c 2008-10-13 14:54:20.000000000 +0200
4733 #include <linux/posix_acl_xattr.h>
4734 #include <linux/quotaops.h>
4735 #include <linux/security.h>
4736 +#include <linux/vs_dlimit.h>
4737 #include "jfs_incore.h"
4738 #include "jfs_superblock.h"
4739 #include "jfs_dmap.h"
4740 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
4741 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
4744 + /* Allocate new blocks to dlimit. */
4745 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
4746 + DQUOT_FREE_BLOCK(ip, nblocks);
4750 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
4752 + /*Rollback dlimit allocation. */
4753 + DLIMIT_FREE_BLOCK(ip, nblocks);
4754 /*Rollback quota allocation. */
4755 DQUOT_FREE_BLOCK(ip, nblocks);
4757 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
4760 /* Rollback quota allocation. */
4761 + DLIMIT_FREE_BLOCK(ip, nblocks);
4762 + /* Rollback quota allocation. */
4763 DQUOT_FREE_BLOCK(ip, nblocks);
4765 dbFree(ip, blkno, nblocks);
4766 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
4769 int quota_allocation = 0;
4770 + int dlimit_allocation = 0;
4772 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
4773 if (ji->ea.flag == 0)
4774 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
4776 quota_allocation = blocks_needed;
4778 + /* Allocate new blocks to dlimit. */
4780 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
4782 + dlimit_allocation = blocks_needed;
4784 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
4787 @@ -600,6 +617,9 @@ static int ea_get(struct inode *inode, s
4791 + /* Rollback dlimit allocation */
4792 + if (dlimit_allocation)
4793 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
4794 /* Rollback quota allocation */
4795 if (quota_allocation)
4796 DQUOT_FREE_BLOCK(inode, quota_allocation);
4797 @@ -676,8 +696,10 @@ static int ea_put(tid_t tid, struct inod
4800 /* If old blocks exist, they must be removed from quota allocation. */
4803 + DLIMIT_FREE_BLOCK(inode, old_blocks);
4804 DQUOT_FREE_BLOCK(inode, old_blocks);
4807 inode->i_ctime = CURRENT_TIME;
4809 diff -NurpP --minimal linux-2.6.27.3/fs/libfs.c linux-2.6.27.3-vs2.3.0.35.7/fs/libfs.c
4810 --- linux-2.6.27.3/fs/libfs.c 2008-10-13 14:52:05.000000000 +0200
4811 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/libfs.c 2008-10-13 14:54:20.000000000 +0200
4812 @@ -125,7 +125,8 @@ static inline unsigned char dt_type(stru
4813 * both impossible due to the lock on directory.
4816 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4817 +static inline int do_dcache_readdir_filter(struct file *filp,
4818 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4820 struct dentry *dentry = filp->f_path.dentry;
4821 struct dentry *cursor = filp->private_data;
4822 @@ -158,6 +159,8 @@ int dcache_readdir(struct file * filp, v
4823 next = list_entry(p, struct dentry, d_u.d_child);
4824 if (d_unhashed(next) || !next->d_inode)
4826 + if (filter && !filter(next))
4829 spin_unlock(&dcache_lock);
4830 if (filldir(dirent, next->d_name.name,
4831 @@ -176,6 +179,18 @@ int dcache_readdir(struct file * filp, v
4835 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4837 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4840 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4841 + int (*filter)(struct dentry *))
4843 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4847 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4850 @@ -823,6 +838,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4851 EXPORT_SYMBOL(dcache_dir_lseek);
4852 EXPORT_SYMBOL(dcache_dir_open);
4853 EXPORT_SYMBOL(dcache_readdir);
4854 +EXPORT_SYMBOL(dcache_readdir_filter);
4855 EXPORT_SYMBOL(generic_read_dir);
4856 EXPORT_SYMBOL(get_sb_pseudo);
4857 EXPORT_SYMBOL(simple_write_begin);
4858 diff -NurpP --minimal linux-2.6.27.3/fs/locks.c linux-2.6.27.3-vs2.3.0.35.7/fs/locks.c
4859 --- linux-2.6.27.3/fs/locks.c 2008-10-13 14:52:05.000000000 +0200
4860 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/locks.c 2008-10-13 14:54:20.000000000 +0200
4862 #include <linux/time.h>
4863 #include <linux/rcupdate.h>
4864 #include <linux/pid_namespace.h>
4865 +#include <linux/vs_base.h>
4866 +#include <linux/vs_limit.h>
4868 #include <asm/uaccess.h>
4870 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4871 /* Allocate an empty lock structure. */
4872 static struct file_lock *locks_alloc_lock(void)
4874 + if (!vx_locks_avail(1))
4876 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4879 @@ -173,6 +177,7 @@ static void locks_free_lock(struct file_
4880 BUG_ON(!list_empty(&fl->fl_block));
4881 BUG_ON(!list_empty(&fl->fl_link));
4884 locks_release_private(fl);
4885 kmem_cache_free(filelock_cache, fl);
4887 @@ -193,6 +198,7 @@ void locks_init_lock(struct file_lock *f
4888 fl->fl_start = fl->fl_end = 0;
4890 fl->fl_lmops = NULL;
4894 EXPORT_SYMBOL(locks_init_lock);
4895 @@ -247,6 +253,7 @@ void locks_copy_lock(struct file_lock *n
4896 new->fl_file = fl->fl_file;
4897 new->fl_ops = fl->fl_ops;
4898 new->fl_lmops = fl->fl_lmops;
4899 + new->fl_xid = fl->fl_xid;
4901 locks_copy_private(new, fl);
4903 @@ -285,6 +292,11 @@ static int flock_make_lock(struct file *
4904 fl->fl_flags = FL_FLOCK;
4906 fl->fl_end = OFFSET_MAX;
4908 + vxd_assert(filp->f_xid == vx_current_xid(),
4909 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4910 + fl->fl_xid = filp->f_xid;
4915 @@ -450,6 +462,7 @@ static int lease_init(struct file *filp,
4917 fl->fl_owner = current->files;
4918 fl->fl_pid = current->tgid;
4919 + fl->fl_xid = vx_current_xid();
4922 fl->fl_flags = FL_LEASE;
4923 @@ -469,6 +482,11 @@ static struct file_lock *lease_alloc(str
4925 return ERR_PTR(error);
4927 + fl->fl_xid = vx_current_xid();
4929 + vxd_assert(filp->f_xid == fl->fl_xid,
4930 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4932 error = lease_init(filp, type, fl);
4934 locks_free_lock(fl);
4935 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
4939 + new_fl->fl_xid = -1;
4941 for_each_lock(inode, before) {
4942 struct file_lock *fl = *before;
4943 @@ -789,6 +808,7 @@ find_conflict:
4945 locks_copy_lock(new_fl, request);
4946 locks_insert_lock(before, new_fl);
4947 + vx_locks_inc(new_fl);
4951 @@ -799,7 +819,8 @@ out:
4955 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4956 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4957 + struct file_lock *conflock, xid_t xid)
4959 struct file_lock *fl;
4960 struct file_lock *new_fl = NULL;
4961 @@ -809,6 +830,8 @@ static int __posix_lock_file(struct inod
4962 struct file_lock **before;
4963 int error, added = 0;
4965 + vxd_assert(xid == vx_current_xid(),
4966 + "xid(%d) == current(%d)", xid, vx_current_xid());
4968 * We may need two file_lock structures for this operation,
4969 * so we get them in advance to avoid races.
4970 @@ -819,7 +842,11 @@ static int __posix_lock_file(struct inod
4971 (request->fl_type != F_UNLCK ||
4972 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4973 new_fl = locks_alloc_lock();
4974 + new_fl->fl_xid = xid;
4975 + vx_locks_inc(new_fl);
4976 new_fl2 = locks_alloc_lock();
4977 + new_fl2->fl_xid = xid;
4978 + vx_locks_inc(new_fl2);
4982 @@ -1018,7 +1045,8 @@ static int __posix_lock_file(struct inod
4983 int posix_lock_file(struct file *filp, struct file_lock *fl,
4984 struct file_lock *conflock)
4986 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4987 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4988 + fl, conflock, filp->f_xid);
4990 EXPORT_SYMBOL(posix_lock_file);
4992 @@ -1108,7 +1136,7 @@ int locks_mandatory_area(int read_write,
4993 fl.fl_end = offset + count - 1;
4996 - error = __posix_lock_file(inode, &fl, NULL);
4997 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4998 if (error != FILE_LOCK_DEFERRED)
5000 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
5001 @@ -1423,6 +1451,7 @@ int generic_setlease(struct file *filp,
5003 locks_copy_lock(new_fl, lease);
5004 locks_insert_lock(before, new_fl);
5005 + vx_locks_inc(new_fl);
5009 @@ -1777,6 +1806,11 @@ int fcntl_setlk(unsigned int fd, struct
5010 if (file_lock == NULL)
5013 + vxd_assert(filp->f_xid == vx_current_xid(),
5014 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5015 + file_lock->fl_xid = filp->f_xid;
5016 + vx_locks_inc(file_lock);
5019 * This might block, so we do it before checking the inode.
5021 @@ -1895,6 +1929,11 @@ int fcntl_setlk64(unsigned int fd, struc
5022 if (file_lock == NULL)
5025 + vxd_assert(filp->f_xid == vx_current_xid(),
5026 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5027 + file_lock->fl_xid = filp->f_xid;
5028 + vx_locks_inc(file_lock);
5031 * This might block, so we do it before checking the inode.
5033 @@ -2159,8 +2198,11 @@ static int locks_show(struct seq_file *f
5035 lock_get_status(f, fl, (long)f->private, "");
5037 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
5038 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
5039 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
5041 lock_get_status(f, bfl, (long)f->private, " ->");
5046 diff -NurpP --minimal linux-2.6.27.3/fs/namei.c linux-2.6.27.3-vs2.3.0.35.7/fs/namei.c
5047 --- linux-2.6.27.3/fs/namei.c 2008-10-13 14:52:05.000000000 +0200
5048 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/namei.c 2008-10-24 03:52:44.000000000 +0200
5050 #include <linux/file.h>
5051 #include <linux/fcntl.h>
5052 #include <linux/device_cgroup.h>
5053 +#include <linux/proc_fs.h>
5054 +#include <linux/vserver/inode.h>
5055 +#include <linux/vs_base.h>
5056 +#include <linux/vs_tag.h>
5057 +#include <linux/vs_cowbl.h>
5058 +#include <linux/vs_device.h>
5059 +#include <linux/vs_context.h>
5060 +#include <linux/pid_namespace.h>
5061 #include <asm/uaccess.h>
5063 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
5064 @@ -167,6 +175,59 @@ void putname(const char *name)
5065 EXPORT_SYMBOL(putname);
5068 +static inline int dx_barrier(struct inode *inode)
5070 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
5071 + vxwprintk_task(1, "did hit the barrier.");
5077 +int dx_permission(struct inode *inode, int mask)
5079 + if (vx_check(0, VS_ADMIN | VS_WATCH))
5082 + if (dx_barrier(inode))
5085 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
5086 + /* devpts is xid tagged */
5087 + if (S_ISDIR(inode->i_mode) ||
5088 + vx_check((xid_t)inode->i_tag, VS_IDENT))
5091 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
5092 + struct pid *pid = PROC_I(inode)->pid;
5093 + struct task_struct *tsk;
5094 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
5098 + tsk = pid_task(pid, PIDTYPE_PID);
5099 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
5100 + tsk, (tsk ? vx_task_xid(tsk) : 0));
5101 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT))
5105 + /* FIXME: Should we block some entries here? */
5110 + if (dx_notagcheck(inode->i_sb) ||
5111 + dx_check(inode->i_tag, DX_HOSTID|DX_ADMIN|DX_WATCH|DX_IDENT))
5116 + vxwprintk_task(1, "denied access to %s:%p[#%d,%lu].",
5117 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino);
5123 * generic_permission - check for access rights on a Posix-like filesystem
5124 @@ -244,10 +305,14 @@ int inode_permission(struct inode *inode
5126 * Nobody gets write access to an immutable file.
5128 - if (IS_IMMUTABLE(inode))
5129 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5133 + retval = dx_permission(inode, mask);
5137 /* Ordinary permission routines do not understand MAY_APPEND. */
5138 if (inode->i_op && inode->i_op->permission) {
5139 retval = inode->i_op->permission(inode, mask);
5140 @@ -451,6 +516,8 @@ static int exec_permission_lite(struct i
5142 umode_t mode = inode->i_mode;
5144 + if (dx_barrier(inode))
5146 if (inode->i_op && inode->i_op->permission)
5149 @@ -773,7 +840,8 @@ static __always_inline void follow_dotdo
5150 if (nd->path.dentry == fs->root.dentry &&
5151 nd->path.mnt == fs->root.mnt) {
5152 read_unlock(&fs->lock);
5154 + /* for sane '/' avoid follow_mount() */
5157 read_unlock(&fs->lock);
5158 spin_lock(&dcache_lock);
5159 @@ -810,16 +878,39 @@ static int do_lookup(struct nameidata *n
5161 struct vfsmount *mnt = nd->path.mnt;
5162 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
5163 + struct inode *inode;
5167 if (dentry->d_op && dentry->d_op->d_revalidate)
5168 goto need_revalidate;
5169 + inode = dentry->d_inode;
5173 + if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
5174 + struct proc_dir_entry *de = PDE(inode);
5176 + if (de && !vx_hide_check(0, de->vx_flags))
5178 + } else if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
5179 + if (!vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
5182 + if (!dx_notagcheck(inode->i_sb) && !dx_check(inode->i_tag,
5183 + DX_WATCH | DX_ADMIN | DX_HOSTID | DX_IDENT))
5188 path->dentry = dentry;
5189 __follow_mount(path);
5192 + vxwprintk_task(1, "did lookup hidden %p[#%d,%lu] »%s«.",
5193 + inode, inode->i_tag, inode->i_ino, vxd_path(&nd->path));
5198 dentry = real_lookup(nd->path.dentry, name, nd);
5199 @@ -1407,7 +1498,7 @@ static int may_delete(struct inode *dir,
5202 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5203 - IS_IMMUTABLE(victim->d_inode))
5204 + IS_IXORUNLINK(victim->d_inode))
5207 if (!S_ISDIR(victim->d_inode->i_mode))
5208 @@ -1551,6 +1642,14 @@ int may_open(struct nameidata *nd, int a
5212 +#ifdef CONFIG_VSERVER_COWBL
5213 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5214 + if (IS_COW_LINK(inode))
5216 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5217 + mark_inode_dirty(inode);
5220 error = vfs_permission(nd, acc_mode);
5223 @@ -1677,6 +1776,11 @@ struct file *do_filp_open(int dfd, const
5225 int flag = open_to_namei_flags(open_flag);
5227 +#ifdef CONFIG_VSERVER_COWBL
5232 acc_mode = MAY_OPEN | ACC_MODE(flag);
5234 /* O_TRUNC implies we need access checks for write permissions */
5235 @@ -1800,6 +1904,25 @@ ok:
5238 error = may_open(&nd, acc_mode, flag);
5239 +#ifdef CONFIG_VSERVER_COWBL
5240 + if (error == -EMLINK) {
5241 + struct dentry *dentry;
5242 + dentry = cow_break_link(pathname);
5243 + if (IS_ERR(dentry)) {
5244 + error = PTR_ERR(dentry);
5249 + mnt_drop_write(nd.path.mnt);
5250 + release_open_intent(&nd);
5251 + path_put(&nd.path);
5260 mnt_drop_write(nd.path.mnt);
5261 @@ -1952,9 +2075,17 @@ int vfs_mknod(struct inode *dir, struct
5265 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5266 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5269 + if (!capable(CAP_MKNOD))
5272 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5274 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5277 if (!dir->i_op || !dir->i_op->mknod)
5280 @@ -2395,7 +2526,7 @@ int vfs_link(struct dentry *old_dentry,
5282 * A link to an append-only or immutable file cannot be created.
5284 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5285 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5287 if (!dir->i_op || !dir->i_op->link)
5289 @@ -2756,6 +2887,214 @@ int vfs_follow_link(struct nameidata *nd
5290 return __vfs_follow_link(nd, link);
5294 +#ifdef CONFIG_VSERVER_COWBL
5296 +#include <linux/file.h>
5299 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5303 + return do_splice_direct(in, &ppos, out, len, 0);
5306 +struct dentry *cow_break_link(const char *pathname)
5308 + int ret, mode, pathlen, redo = 0;
5309 + struct nameidata old_nd, dir_nd;
5310 + struct path old_path, new_path;
5311 + struct dentry *dir, *res = NULL;
5312 + struct file *old_file;
5313 + struct file *new_file;
5314 + char *to, *path, pad='\251';
5317 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5318 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5323 + /* old_nd will have refs to dentry and mnt */
5324 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5325 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5327 + goto out_free_path;
5329 + old_path = old_nd.path;
5330 + mode = old_path.dentry->d_inode->i_mode;
5332 + to = d_path(&old_path, path, PATH_MAX-2);
5333 + pathlen = strlen(to);
5334 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5335 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5336 + old_path.dentry->d_name.len);
5338 + to[pathlen + 1] = 0;
5340 + to[pathlen] = pad--;
5342 + if (pad <= '\240')
5345 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5346 + /* dir_nd will have refs to dentry and mnt */
5347 + ret = path_lookup(to,
5348 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5349 + vxdprintk(VXD_CBIT(misc, 2),
5350 + "path_lookup(new): %d", ret);
5354 + /* this puppy downs the inode mutex */
5355 + new_path.dentry = lookup_create(&dir_nd, 0);
5356 + vxdprintk(VXD_CBIT(misc, 2),
5357 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5358 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5359 + new_path.dentry->d_name.len);
5360 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5361 + path_put(&dir_nd.path);
5364 + dir = dir_nd.path.dentry;
5366 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5367 + vxdprintk(VXD_CBIT(misc, 2),
5368 + "vfs_create(new): %d", ret);
5369 + if (ret == -EEXIST) {
5370 + mutex_unlock(&dir->d_inode->i_mutex);
5371 + dput(new_path.dentry);
5372 + path_put(&dir_nd.path);
5376 + goto out_unlock_new;
5378 + /* drop out early, ret passes ENOENT */
5380 + if ((redo = d_unhashed(old_path.dentry)))
5381 + goto out_unlock_new;
5383 + new_path.mnt = dir_nd.path.mnt;
5384 + dget(old_path.dentry);
5385 + mntget(old_path.mnt);
5386 + /* this one cleans up the dentry/mnt in case of failure */
5387 + old_file = dentry_open(old_path.dentry, old_path.mnt, O_RDONLY);
5388 + vxdprintk(VXD_CBIT(misc, 2),
5389 + "dentry_open(old): %p", old_file);
5390 + if (!old_file || IS_ERR(old_file)) {
5391 + res = IS_ERR(old_file) ? (void *) old_file : res;
5392 + goto out_unlock_new;
5395 + dget(new_path.dentry);
5396 + mntget(new_path.mnt);
5397 + /* this one cleans up the dentry/mnt in case of failure */
5398 + new_file = dentry_open(new_path.dentry, new_path.mnt, O_WRONLY);
5399 + vxdprintk(VXD_CBIT(misc, 2),
5400 + "dentry_open(new): %p", new_file);
5402 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5403 + if (!new_file || IS_ERR(new_file))
5404 + goto out_fput_old;
5406 + size = i_size_read(old_file->f_dentry->d_inode);
5407 + ret = do_cow_splice(old_file, new_file, size);
5408 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5410 + goto out_fput_both;
5411 + } else if (ret < size) {
5413 + goto out_fput_both;
5415 + struct inode *old_inode = old_path.dentry->d_inode;
5416 + struct inode *new_inode = new_path.dentry->d_inode;
5417 + struct iattr attr = {
5418 + .ia_uid = old_inode->i_uid,
5419 + .ia_gid = old_inode->i_gid,
5420 + .ia_valid = ATTR_UID | ATTR_GID
5423 + ret = inode_setattr(new_inode, &attr);
5425 + goto out_fput_both;
5428 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5430 + /* drop out late */
5432 + if ((redo = d_unhashed(old_path.dentry)))
5435 + vxdprintk(VXD_CBIT(misc, 2),
5436 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5437 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5438 + new_path.dentry->d_name.len,
5439 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5440 + old_path.dentry->d_name.len);
5441 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5442 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5443 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5444 + res = new_path.dentry;
5447 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5450 + vxdprintk(VXD_CBIT(misc, 3),
5451 + "fput(new_file=%p[#%ld])", new_file,
5452 + atomic_read(&new_file->f_count));
5456 + vxdprintk(VXD_CBIT(misc, 3),
5457 + "fput(old_file=%p[#%ld])", old_file,
5458 + atomic_read(&old_file->f_count));
5462 + mutex_unlock(&dir->d_inode->i_mutex);
5466 + /* error path cleanup */
5467 + vfs_unlink(dir->d_inode, new_path.dentry);
5468 + dput(new_path.dentry);
5472 + goto out_rel_both;
5473 + /* lookup dentry once again */
5474 + path_put(&old_nd.path);
5475 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5477 + goto out_rel_both;
5479 + new_path.dentry = old_nd.path.dentry;
5480 + vxdprintk(VXD_CBIT(misc, 2),
5481 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5482 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5483 + new_path.dentry->d_name.len);
5484 + dget(new_path.dentry);
5485 + res = new_path.dentry;
5488 + path_put(&dir_nd.path);
5490 + path_put(&old_nd.path);
5495 + res = ERR_PTR(ret);
5501 /* get the link contents into pagecache */
5502 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5504 diff -NurpP --minimal linux-2.6.27.3/fs/namespace.c linux-2.6.27.3-vs2.3.0.35.7/fs/namespace.c
5505 --- linux-2.6.27.3/fs/namespace.c 2008-10-13 14:52:05.000000000 +0200
5506 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/namespace.c 2008-10-24 03:34:52.000000000 +0200
5508 #include <linux/ramfs.h>
5509 #include <linux/log2.h>
5510 #include <linux/idr.h>
5511 +#include <linux/vs_base.h>
5512 +#include <linux/vs_context.h>
5513 +#include <linux/vs_tag.h>
5514 +#include <linux/vserver/space.h>
5515 +#include <linux/vserver/global.h>
5516 #include <asm/uaccess.h>
5517 #include <asm/unistd.h>
5519 @@ -573,6 +578,7 @@ static struct vfsmount *clone_mnt(struct
5520 mnt->mnt_root = dget(root);
5521 mnt->mnt_mountpoint = mnt->mnt_root;
5522 mnt->mnt_parent = mnt;
5523 + mnt->mnt_tag = old->mnt_tag;
5525 if (flag & CL_SLAVE) {
5526 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5527 @@ -685,6 +691,31 @@ static inline void mangle(struct seq_fil
5528 seq_escape(m, s, " \t\n\\");
5531 +static int mnt_is_reachable(struct vfsmount *mnt)
5534 + struct dentry *point;
5537 + if (mnt == mnt->mnt_ns->root)
5540 + spin_lock(&vfsmount_lock);
5541 + root = current->fs->root;
5542 + point = root.dentry;
5544 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5545 + point = mnt->mnt_mountpoint;
5546 + mnt = mnt->mnt_parent;
5549 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5551 + spin_unlock(&vfsmount_lock);
5557 * Simple .show_options callback for filesystems which don't want to
5558 * implement more complex mount option showing.
5559 @@ -757,6 +788,8 @@ static int show_sb_opts(struct seq_file
5560 { MS_SYNCHRONOUS, ",sync" },
5561 { MS_DIRSYNC, ",dirsync" },
5562 { MS_MANDLOCK, ",mand" },
5563 + { MS_TAGGED, ",tag" },
5564 + { MS_NOTAGCHECK, ",notagcheck" },
5567 const struct proc_fs_info *fs_infop;
5568 @@ -803,10 +836,20 @@ static int show_vfsmnt(struct seq_file *
5570 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5572 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5574 - seq_path(m, &mnt_path, " \t\n\\");
5576 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5578 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5581 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5582 + mnt == current->fs->root.mnt) {
5583 + seq_puts(m, "/dev/root / ");
5585 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5587 + seq_path(m, &mnt_path, " \t\n\\");
5590 show_type(m, mnt->mnt_sb);
5591 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5592 err = show_sb_opts(m, mnt->mnt_sb);
5593 @@ -836,6 +879,11 @@ static int show_mountinfo(struct seq_fil
5594 struct path root = p->root;
5597 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5599 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5602 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5603 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5604 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5605 @@ -894,17 +942,27 @@ static int show_vfsstat(struct seq_file
5606 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5610 - if (mnt->mnt_devname) {
5611 - seq_puts(m, "device ");
5612 - mangle(m, mnt->mnt_devname);
5614 - seq_puts(m, "no device");
5615 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5617 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5621 - seq_puts(m, " mounted on ");
5622 - seq_path(m, &mnt_path, " \t\n\\");
5624 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5625 + mnt == current->fs->root.mnt) {
5626 + seq_puts(m, "device /dev/root mounted on / ");
5629 + if (mnt->mnt_devname) {
5630 + seq_puts(m, "device ");
5631 + mangle(m, mnt->mnt_devname);
5633 + seq_puts(m, "no device");
5636 + seq_puts(m, " mounted on ");
5637 + seq_path(m, &mnt_path, " \t\n\\");
5641 /* file system type */
5642 seq_puts(m, "with fstype ");
5643 @@ -1143,7 +1201,7 @@ asmlinkage long sys_umount(char __user *
5647 - if (!capable(CAP_SYS_ADMIN))
5648 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5651 retval = do_umount(path.mnt, flags);
5652 @@ -1169,7 +1227,7 @@ asmlinkage long sys_oldumount(char __use
5654 static int mount_is_safe(struct nameidata *nd)
5656 - if (capable(CAP_SYS_ADMIN))
5657 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5661 @@ -1462,11 +1520,13 @@ static noinline int do_change_type(struc
5662 * noinline this do_mount helper to save do_mount stack space.
5664 static noinline int do_loopback(struct nameidata *nd, char *old_name,
5666 + tag_t tag, unsigned long flags, int mnt_flags)
5668 struct nameidata old_nd;
5669 struct vfsmount *mnt = NULL;
5670 int err = mount_is_safe(nd);
5671 + int recurse = flags & MS_REC;
5675 if (!old_name || !*old_name)
5676 @@ -1500,6 +1560,7 @@ static noinline int do_loopback(struct n
5677 spin_unlock(&vfsmount_lock);
5678 release_mounts(&umount_list);
5680 + mnt->mnt_flags = mnt_flags;
5683 up_write(&namespace_sem);
5684 @@ -1531,12 +1592,12 @@ static int change_mount_flags(struct vfs
5685 * noinline this do_mount helper to save do_mount stack space.
5687 static noinline int do_remount(struct nameidata *nd, int flags, int mnt_flags,
5689 + void *data, xid_t xid)
5692 struct super_block *sb = nd->path.mnt->mnt_sb;
5694 - if (!capable(CAP_SYS_ADMIN))
5695 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5698 if (!check_mnt(nd->path.mnt))
5699 @@ -1577,7 +1638,7 @@ static noinline int do_move_mount(struct
5700 struct path parent_path;
5703 - if (!capable(CAP_SYS_ADMIN))
5704 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5706 if (!old_name || !*old_name)
5708 @@ -1660,7 +1721,7 @@ static noinline int do_new_mount(struct
5711 /* we need capabilities... */
5712 - if (!capable(CAP_SYS_ADMIN))
5713 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5716 mnt = do_kern_mount(type, flags, name, data);
5717 @@ -1905,6 +1966,7 @@ long do_mount(char *dev_name, char *dir_
5718 struct nameidata nd;
5724 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5725 @@ -1920,6 +1982,12 @@ long do_mount(char *dev_name, char *dir_
5727 ((char *)data_page)[PAGE_SIZE - 1] = 0;
5729 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5730 + /* FIXME: bind and re-mounts get the tag flag? */
5731 + if (flags & (MS_BIND|MS_REMOUNT))
5732 + flags |= MS_TAGID;
5735 /* Separate the per-mountpoint flags */
5736 if (flags & MS_NOSUID)
5737 mnt_flags |= MNT_NOSUID;
5738 @@ -1936,6 +2004,8 @@ long do_mount(char *dev_name, char *dir_
5739 if (flags & MS_RDONLY)
5740 mnt_flags |= MNT_READONLY;
5742 + if (!capable(CAP_SYS_ADMIN))
5743 + mnt_flags |= MNT_NODEV;
5744 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5745 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT);
5747 @@ -1951,9 +2021,9 @@ long do_mount(char *dev_name, char *dir_
5749 if (flags & MS_REMOUNT)
5750 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
5753 else if (flags & MS_BIND)
5754 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
5755 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
5756 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5757 retval = do_change_type(&nd, flags);
5758 else if (flags & MS_MOVE)
5759 @@ -2022,6 +2092,7 @@ static struct mnt_namespace *dup_mnt_ns(
5760 q = next_mnt(q, new_ns->root);
5762 up_write(&namespace_sem);
5763 + atomic_inc(&vs_global_mnt_ns);
5767 @@ -2350,5 +2421,6 @@ void __put_mnt_ns(struct mnt_namespace *
5768 spin_unlock(&vfsmount_lock);
5769 up_write(&namespace_sem);
5770 release_mounts(&umount_list);
5771 + atomic_dec(&vs_global_mnt_ns);
5774 diff -NurpP --minimal linux-2.6.27.3/fs/nfs/client.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/client.c
5775 --- linux-2.6.27.3/fs/nfs/client.c 2008-10-13 14:52:05.000000000 +0200
5776 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/client.c 2008-10-13 14:54:20.000000000 +0200
5777 @@ -601,6 +601,9 @@ static int nfs_init_server_rpcclient(str
5778 if (server->flags & NFS_MOUNT_SOFT)
5779 server->client->cl_softrtry = 1;
5781 + server->client->cl_tag = 0;
5782 + if (server->flags & NFS_MOUNT_TAGGED)
5783 + server->client->cl_tag = 1;
5787 @@ -766,6 +769,10 @@ static void nfs_server_set_fsinfo(struct
5788 server->acdirmin = server->acdirmax = 0;
5791 + /* FIXME: needs fsinfo
5792 + if (server->flags & NFS_MOUNT_TAGGED)
5793 + sb->s_flags |= MS_TAGGED; */
5795 server->maxfilesize = fsinfo->maxfilesize;
5797 /* We're airborne Set socket buffersize */
5798 diff -NurpP --minimal linux-2.6.27.3/fs/nfs/dir.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/dir.c
5799 --- linux-2.6.27.3/fs/nfs/dir.c 2008-10-13 14:52:05.000000000 +0200
5800 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/dir.c 2008-10-13 14:54:20.000000000 +0200
5802 #include <linux/namei.h>
5803 #include <linux/mount.h>
5804 #include <linux/sched.h>
5805 +#include <linux/vs_tag.h>
5807 #include "nfs4_fs.h"
5808 #include "delegation.h"
5809 @@ -938,6 +939,7 @@ static struct dentry *nfs_lookup(struct
5811 goto out_unblock_sillyrename;
5813 + dx_propagate_tag(nd, inode);
5815 res = d_materialise_unique(dentry, inode);
5817 diff -NurpP --minimal linux-2.6.27.3/fs/nfs/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/inode.c
5818 --- linux-2.6.27.3/fs/nfs/inode.c 2008-10-13 14:52:05.000000000 +0200
5819 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/inode.c 2008-10-13 14:54:20.000000000 +0200
5821 #include <linux/vfs.h>
5822 #include <linux/inet.h>
5823 #include <linux/nfs_xdr.h>
5824 +#include <linux/vs_tag.h>
5826 #include <asm/system.h>
5827 #include <asm/uaccess.h>
5828 @@ -314,8 +315,10 @@ nfs_fhget(struct super_block *sb, struct
5829 nfsi->change_attr = fattr->change_attr;
5830 inode->i_size = nfs_size_to_loff_t(fattr->size);
5831 inode->i_nlink = fattr->nlink;
5832 - inode->i_uid = fattr->uid;
5833 - inode->i_gid = fattr->gid;
5834 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5835 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5836 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5837 + /* maybe fattr->xid someday */
5838 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5840 * report the blocks in 512byte units
5841 @@ -462,6 +465,8 @@ void nfs_setattr_update_inode(struct ino
5842 inode->i_uid = attr->ia_uid;
5843 if ((attr->ia_valid & ATTR_GID) != 0)
5844 inode->i_gid = attr->ia_gid;
5845 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5846 + inode->i_tag = attr->ia_tag;
5847 spin_lock(&inode->i_lock);
5848 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5849 spin_unlock(&inode->i_lock);
5850 @@ -900,6 +905,9 @@ static int nfs_check_inode_attributes(st
5851 struct nfs_inode *nfsi = NFS_I(inode);
5852 loff_t cur_size, new_isize;
5853 unsigned long invalid = 0;
5859 /* Has the inode gone and changed behind our back? */
5860 @@ -924,10 +932,15 @@ static int nfs_check_inode_attributes(st
5861 if (cur_size != new_isize && nfsi->npages == 0)
5862 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5864 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5865 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5866 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5868 /* Have any file permissions changed? */
5869 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
5870 - || inode->i_uid != fattr->uid
5871 - || inode->i_gid != fattr->gid)
5872 + || inode->i_uid != uid
5873 + || inode->i_gid != gid
5874 + || inode->i_tag != tag)
5875 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5877 /* Has the link count changed? */
5878 @@ -1048,6 +1061,9 @@ static int nfs_update_inode(struct inode
5879 loff_t cur_isize, new_isize;
5880 unsigned long invalid = 0;
5881 unsigned long now = jiffies;
5886 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5887 __func__, inode->i_sb->s_id, inode->i_ino,
5888 @@ -1121,15 +1137,21 @@ static int nfs_update_inode(struct inode
5889 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5890 nfsi->change_attr = fattr->change_attr;
5892 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5893 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5894 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5896 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
5897 - inode->i_uid != fattr->uid ||
5898 - inode->i_gid != fattr->gid)
5899 + inode->i_uid != uid ||
5900 + inode->i_gid != gid ||
5901 + inode->i_tag != tag)
5902 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5904 inode->i_mode = fattr->mode;
5905 inode->i_nlink = fattr->nlink;
5906 - inode->i_uid = fattr->uid;
5907 - inode->i_gid = fattr->gid;
5908 + inode->i_uid = uid;
5909 + inode->i_gid = gid;
5910 + inode->i_tag = tag;
5912 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5914 diff -NurpP --minimal linux-2.6.27.3/fs/nfs/nfs3xdr.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/nfs3xdr.c
5915 --- linux-2.6.27.3/fs/nfs/nfs3xdr.c 2008-07-13 23:51:29.000000000 +0200
5916 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/nfs3xdr.c 2008-10-13 14:54:20.000000000 +0200
5918 #include <linux/nfs3.h>
5919 #include <linux/nfs_fs.h>
5920 #include <linux/nfsacl.h>
5921 +#include <linux/vs_tag.h>
5922 #include "internal.h"
5924 #define NFSDBG_FACILITY NFSDBG_XDR
5925 @@ -180,7 +181,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5928 static inline __be32 *
5929 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5930 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5932 if (attr->ia_valid & ATTR_MODE) {
5934 @@ -188,15 +189,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5938 - if (attr->ia_valid & ATTR_UID) {
5939 + if (attr->ia_valid & ATTR_UID ||
5940 + (tag && (attr->ia_valid & ATTR_TAG))) {
5942 - *p++ = htonl(attr->ia_uid);
5943 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5947 - if (attr->ia_valid & ATTR_GID) {
5948 + if (attr->ia_valid & ATTR_GID ||
5949 + (tag && (attr->ia_valid & ATTR_TAG))) {
5951 - *p++ = htonl(attr->ia_gid);
5952 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5956 @@ -281,7 +284,8 @@ static int
5957 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5959 p = xdr_encode_fhandle(p, args->fh);
5960 - p = xdr_encode_sattr(p, args->sattr);
5961 + p = xdr_encode_sattr(p, args->sattr,
5962 + req->rq_task->tk_client->cl_tag);
5963 *p++ = htonl(args->guard);
5965 p = xdr_encode_time3(p, &args->guardtime);
5966 @@ -386,7 +390,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5967 *p++ = args->verifier[0];
5968 *p++ = args->verifier[1];
5970 - p = xdr_encode_sattr(p, args->sattr);
5971 + p = xdr_encode_sattr(p, args->sattr,
5972 + req->rq_task->tk_client->cl_tag);
5974 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5976 @@ -400,7 +405,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5978 p = xdr_encode_fhandle(p, args->fh);
5979 p = xdr_encode_array(p, args->name, args->len);
5980 - p = xdr_encode_sattr(p, args->sattr);
5981 + p = xdr_encode_sattr(p, args->sattr,
5982 + req->rq_task->tk_client->cl_tag);
5983 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5986 @@ -413,7 +419,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
5988 p = xdr_encode_fhandle(p, args->fromfh);
5989 p = xdr_encode_array(p, args->fromname, args->fromlen);
5990 - p = xdr_encode_sattr(p, args->sattr);
5991 + p = xdr_encode_sattr(p, args->sattr,
5992 + req->rq_task->tk_client->cl_tag);
5993 *p++ = htonl(args->pathlen);
5994 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5996 @@ -431,7 +438,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
5997 p = xdr_encode_fhandle(p, args->fh);
5998 p = xdr_encode_array(p, args->name, args->len);
5999 *p++ = htonl(args->type);
6000 - p = xdr_encode_sattr(p, args->sattr);
6001 + p = xdr_encode_sattr(p, args->sattr,
6002 + req->rq_task->tk_client->cl_tag);
6003 if (args->type == NF3CHR || args->type == NF3BLK) {
6004 *p++ = htonl(MAJOR(args->rdev));
6005 *p++ = htonl(MINOR(args->rdev));
6006 diff -NurpP --minimal linux-2.6.27.3/fs/nfs/nfsroot.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/nfsroot.c
6007 --- linux-2.6.27.3/fs/nfs/nfsroot.c 2008-10-13 14:52:05.000000000 +0200
6008 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/nfsroot.c 2008-10-13 14:54:20.000000000 +0200
6009 @@ -117,12 +117,12 @@ static int mount_port __initdata = 0; /
6011 /* Options that take integer arguments */
6012 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
6013 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
6014 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
6015 /* Options that take no arguments */
6016 Opt_soft, Opt_hard, Opt_intr,
6017 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
6018 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
6019 - Opt_acl, Opt_noacl,
6020 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
6024 @@ -159,6 +159,9 @@ static match_table_t __initdata tokens =
6027 {Opt_noacl, "noacl"},
6029 + {Opt_notag, "notag"},
6030 + {Opt_tagid, "tagid=%u"},
6034 @@ -270,6 +273,20 @@ static int __init root_nfs_parse(char *n
6036 nfs_data.flags |= NFS_MOUNT_NOACL;
6038 +#ifndef CONFIG_TAGGING_NONE
6040 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6043 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
6046 +#ifdef CONFIG_PROPAGATE
6049 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6053 printk(KERN_WARNING "Root-NFS: unknown "
6055 diff -NurpP --minimal linux-2.6.27.3/fs/nfs/super.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/super.c
6056 --- linux-2.6.27.3/fs/nfs/super.c 2008-10-13 14:52:05.000000000 +0200
6057 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfs/super.c 2008-10-13 14:54:20.000000000 +0200
6059 #include <linux/nfs_xdr.h>
6060 #include <linux/magic.h>
6061 #include <linux/parser.h>
6062 +#include <linux/vs_tag.h>
6064 #include <asm/system.h>
6065 #include <asm/uaccess.h>
6066 @@ -504,6 +505,7 @@ static void nfs_show_mount_options(struc
6067 { NFS_MOUNT_NOACL, ",noacl", "" },
6068 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6069 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
6070 + { NFS_MOUNT_TAGGED, ",tag", "" },
6073 const struct proc_nfs_info *nfs_infop;
6074 diff -NurpP --minimal linux-2.6.27.3/fs/nfsd/auth.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfsd/auth.c
6075 --- linux-2.6.27.3/fs/nfsd/auth.c 2008-07-13 23:51:29.000000000 +0200
6076 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfsd/auth.c 2008-10-13 14:54:20.000000000 +0200
6078 #include <linux/sunrpc/svcauth.h>
6079 #include <linux/nfsd/nfsd.h>
6080 #include <linux/nfsd/export.h>
6081 +#include <linux/vs_tag.h>
6084 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
6085 @@ -55,19 +56,23 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6086 get_group_info(cred.cr_group_info);
6088 if (cred.cr_uid != (uid_t) -1)
6089 - current->fsuid = cred.cr_uid;
6090 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6092 current->fsuid = exp->ex_anon_uid;
6093 if (cred.cr_gid != (gid_t) -1)
6094 - current->fsgid = cred.cr_gid;
6095 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6097 current->fsgid = exp->ex_anon_gid;
6099 + /* this desperately needs a tag :) */
6100 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6102 if (!cred.cr_group_info)
6104 ret = set_current_groups(cred.cr_group_info);
6105 put_group_info(cred.cr_group_info);
6106 - if ((cred.cr_uid)) {
6108 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
6109 current->cap_effective =
6110 cap_drop_nfsd_set(current->cap_effective);
6112 diff -NurpP --minimal linux-2.6.27.3/fs/nfsd/nfs3xdr.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfsd/nfs3xdr.c
6113 --- linux-2.6.27.3/fs/nfsd/nfs3xdr.c 2008-07-13 23:51:29.000000000 +0200
6114 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfsd/nfs3xdr.c 2008-10-13 14:54:20.000000000 +0200
6116 #include <linux/sunrpc/svc.h>
6117 #include <linux/nfsd/nfsd.h>
6118 #include <linux/nfsd/xdr3.h>
6119 +#include <linux/vs_tag.h>
6122 #define NFSDDBG_FACILITY NFSDDBG_XDR
6123 @@ -108,6 +109,8 @@ static __be32 *
6124 decode_sattr3(__be32 *p, struct iattr *iap)
6132 @@ -117,12 +120,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6135 iap->ia_valid |= ATTR_UID;
6136 - iap->ia_uid = ntohl(*p++);
6137 + uid = ntohl(*p++);
6140 iap->ia_valid |= ATTR_GID;
6141 - iap->ia_gid = ntohl(*p++);
6142 + gid = ntohl(*p++);
6144 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6145 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6146 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6150 @@ -178,8 +184,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6151 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6152 *p++ = htonl((u32) stat->mode);
6153 *p++ = htonl((u32) stat->nlink);
6154 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6155 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6156 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6157 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6158 + stat->uid, stat->tag)));
6159 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6160 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6161 + stat->gid, stat->tag)));
6162 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6163 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6165 diff -NurpP --minimal linux-2.6.27.3/fs/nfsd/nfs4xdr.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfsd/nfs4xdr.c
6166 --- linux-2.6.27.3/fs/nfsd/nfs4xdr.c 2008-10-13 14:52:06.000000000 +0200
6167 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfsd/nfs4xdr.c 2008-10-13 14:54:20.000000000 +0200
6169 #include <linux/nfs4_acl.h>
6170 #include <linux/sunrpc/gss_api.h>
6171 #include <linux/sunrpc/svcauth_gss.h>
6172 +#include <linux/vs_tag.h>
6174 #define NFSDDBG_FACILITY NFSDDBG_XDR
6176 @@ -1704,14 +1705,18 @@ out_acl:
6177 WRITE32(stat.nlink);
6179 if (bmval1 & FATTR4_WORD1_OWNER) {
6180 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6181 + status = nfsd4_encode_user(rqstp,
6182 + TAGINO_UID(DX_TAG(dentry->d_inode),
6183 + stat.uid, stat.tag), &p, &buflen);
6184 if (status == nfserr_resource)
6189 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6190 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6191 + status = nfsd4_encode_group(rqstp,
6192 + TAGINO_GID(DX_TAG(dentry->d_inode),
6193 + stat.gid, stat.tag), &p, &buflen);
6194 if (status == nfserr_resource)
6197 diff -NurpP --minimal linux-2.6.27.3/fs/nfsd/nfsxdr.c linux-2.6.27.3-vs2.3.0.35.7/fs/nfsd/nfsxdr.c
6198 --- linux-2.6.27.3/fs/nfsd/nfsxdr.c 2008-07-13 23:51:29.000000000 +0200
6199 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/nfsd/nfsxdr.c 2008-10-13 14:54:20.000000000 +0200
6201 #include <linux/nfsd/nfsd.h>
6202 #include <linux/nfsd/xdr.h>
6203 #include <linux/mm.h>
6204 +#include <linux/vs_tag.h>
6207 #define NFSDDBG_FACILITY NFSDDBG_XDR
6208 @@ -98,6 +99,8 @@ static __be32 *
6209 decode_sattr(__be32 *p, struct iattr *iap)
6217 @@ -111,12 +114,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6219 if ((tmp = ntohl(*p++)) != (u32)-1) {
6220 iap->ia_valid |= ATTR_UID;
6221 - iap->ia_uid = tmp;
6224 if ((tmp = ntohl(*p++)) != (u32)-1) {
6225 iap->ia_valid |= ATTR_GID;
6226 - iap->ia_gid = tmp;
6229 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6230 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6231 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6232 if ((tmp = ntohl(*p++)) != (u32)-1) {
6233 iap->ia_valid |= ATTR_SIZE;
6235 @@ -161,8 +167,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6236 *p++ = htonl(nfs_ftypes[type >> 12]);
6237 *p++ = htonl((u32) stat->mode);
6238 *p++ = htonl((u32) stat->nlink);
6239 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6240 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6241 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6242 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6243 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6244 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6246 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6247 *p++ = htonl(NFS_MAXPATHLEN);
6248 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/dlm/dlmfs.c linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/dlm/dlmfs.c
6249 --- linux-2.6.27.3/fs/ocfs2/dlm/dlmfs.c 2008-10-13 14:52:06.000000000 +0200
6250 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/dlm/dlmfs.c 2008-10-13 14:54:20.000000000 +0200
6252 #include <linux/init.h>
6253 #include <linux/string.h>
6254 #include <linux/backing-dev.h>
6255 +#include <linux/vs_tag.h>
6257 #include <asm/uaccess.h>
6259 @@ -341,6 +342,7 @@ static struct inode *dlmfs_get_root_inod
6260 inode->i_mode = mode;
6261 inode->i_uid = current->fsuid;
6262 inode->i_gid = current->fsgid;
6263 + inode->i_tag = dx_current_fstag(sb);
6264 inode->i_blocks = 0;
6265 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6266 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6267 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
6268 inode->i_mode = mode;
6269 inode->i_uid = current->fsuid;
6270 inode->i_gid = current->fsgid;
6271 + inode->i_tag = dx_current_fstag(sb);
6272 inode->i_blocks = 0;
6273 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6274 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6275 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/dlmglue.c linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/dlmglue.c
6276 --- linux-2.6.27.3/fs/ocfs2/dlmglue.c 2008-10-13 14:52:06.000000000 +0200
6277 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/dlmglue.c 2008-10-13 14:54:20.000000000 +0200
6278 @@ -1846,6 +1846,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6279 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6280 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6281 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6282 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6283 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6284 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6285 lvb->lvb_iatime_packed =
6286 @@ -1900,6 +1901,7 @@ static void ocfs2_refresh_inode_from_lvb
6288 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6289 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6290 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6291 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6292 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6293 ocfs2_unpack_timespec(&inode->i_atime,
6294 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/dlmglue.h linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/dlmglue.h
6295 --- linux-2.6.27.3/fs/ocfs2/dlmglue.h 2008-07-13 23:51:29.000000000 +0200
6296 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/dlmglue.h 2008-10-13 14:54:20.000000000 +0200
6297 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6300 __be32 lvb_igeneration;
6301 - __be32 lvb_reserved2;
6303 + __be16 lvb_reserved2;
6306 /* ocfs2_inode_lock_full() 'arg_flags' flags */
6307 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/file.c linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/file.c
6308 --- linux-2.6.27.3/fs/ocfs2/file.c 2008-10-13 14:52:06.000000000 +0200
6309 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/file.c 2008-10-13 14:54:20.000000000 +0200
6310 @@ -1058,13 +1058,15 @@ int ocfs2_setattr(struct dentry *dentry,
6311 mlog(0, "uid change: %d\n", attr->ia_uid);
6312 if (attr->ia_valid & ATTR_GID)
6313 mlog(0, "gid change: %d\n", attr->ia_gid);
6314 + if (attr->ia_valid & ATTR_TAG)
6315 + mlog(0, "tag change: %d\n", attr->ia_tag);
6316 if (attr->ia_valid & ATTR_SIZE)
6317 mlog(0, "size change...\n");
6318 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6319 mlog(0, "time change...\n");
6321 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6322 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6323 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6324 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6325 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6327 @@ -2227,6 +2229,7 @@ const struct inode_operations ocfs2_file
6328 .setattr = ocfs2_setattr,
6329 .getattr = ocfs2_getattr,
6330 .permission = ocfs2_permission,
6331 + .sync_flags = ocfs2_sync_flags,
6332 .fallocate = ocfs2_fallocate,
6335 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/inode.c
6336 --- linux-2.6.27.3/fs/ocfs2/inode.c 2008-07-13 23:51:29.000000000 +0200
6337 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/inode.c 2008-10-13 14:54:20.000000000 +0200
6339 #include <linux/slab.h>
6340 #include <linux/highmem.h>
6341 #include <linux/pagemap.h>
6342 +#include <linux/vs_tag.h>
6344 #include <asm/byteorder.h>
6348 #include "heartbeat.h"
6351 #include "journal.h"
6353 #include "suballoc.h"
6354 @@ -74,11 +76,13 @@ void ocfs2_set_inode_flags(struct inode
6356 unsigned int flags = OCFS2_I(inode)->ip_attr;
6358 - inode->i_flags &= ~(S_IMMUTABLE |
6359 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6360 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6362 if (flags & OCFS2_IMMUTABLE_FL)
6363 inode->i_flags |= S_IMMUTABLE;
6364 + if (flags & OCFS2_IXUNLINK_FL)
6365 + inode->i_flags |= S_IXUNLINK;
6367 if (flags & OCFS2_SYNC_FL)
6368 inode->i_flags |= S_SYNC;
6369 @@ -88,25 +92,85 @@ void ocfs2_set_inode_flags(struct inode
6370 inode->i_flags |= S_NOATIME;
6371 if (flags & OCFS2_DIRSYNC_FL)
6372 inode->i_flags |= S_DIRSYNC;
6374 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6376 + if (flags & OCFS2_BARRIER_FL)
6377 + inode->i_vflags |= V_BARRIER;
6378 + if (flags & OCFS2_COW_FL)
6379 + inode->i_vflags |= V_COW;
6382 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6383 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6385 unsigned int flags = oi->vfs_inode.i_flags;
6386 + unsigned int vflags = oi->vfs_inode.i_vflags;
6388 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6389 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6390 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6391 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6393 + if (flags & S_IMMUTABLE)
6394 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6395 + if (flags & S_IXUNLINK)
6396 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6398 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6399 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6401 oi->ip_attr |= OCFS2_SYNC_FL;
6402 if (flags & S_APPEND)
6403 oi->ip_attr |= OCFS2_APPEND_FL;
6404 - if (flags & S_IMMUTABLE)
6405 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6406 if (flags & S_NOATIME)
6407 oi->ip_attr |= OCFS2_NOATIME_FL;
6408 if (flags & S_DIRSYNC)
6409 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6411 + if (vflags & V_BARRIER)
6412 + oi->ip_attr |= OCFS2_BARRIER_FL;
6413 + if (vflags & V_COW)
6414 + oi->ip_attr |= OCFS2_COW_FL;
6417 +int ocfs2_sync_flags(struct inode *inode)
6419 + struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6420 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6421 + handle_t *handle = NULL;
6422 + struct buffer_head *bh = NULL;
6425 + status = ocfs2_inode_lock(inode, &bh, 1);
6427 + mlog_errno(status);
6432 + if (IS_RDONLY(inode))
6435 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6436 + if (IS_ERR(handle)) {
6437 + status = PTR_ERR(handle);
6438 + mlog_errno(status);
6442 + ocfs2_get_inode_flags(ocfs2_inode);
6443 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6445 + mlog_errno(status);
6447 + ocfs2_commit_trans(osb, handle);
6449 + ocfs2_inode_unlock(inode, 1);
6454 + mlog_exit(status);
6458 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
6459 @@ -219,6 +283,8 @@ int ocfs2_populate_inode(struct inode *i
6460 struct super_block *sb;
6461 struct ocfs2_super *osb;
6462 int status = -EINVAL;
6466 mlog_entry("(0x%p, size:%llu)\n", inode,
6467 (unsigned long long)le64_to_cpu(fe->i_size));
6468 @@ -254,8 +320,12 @@ int ocfs2_populate_inode(struct inode *i
6469 inode->i_generation = le32_to_cpu(fe->i_generation);
6470 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6471 inode->i_mode = le16_to_cpu(fe->i_mode);
6472 - inode->i_uid = le32_to_cpu(fe->i_uid);
6473 - inode->i_gid = le32_to_cpu(fe->i_gid);
6474 + uid = le32_to_cpu(fe->i_uid);
6475 + gid = le32_to_cpu(fe->i_gid);
6476 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6477 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6478 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6479 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6481 /* Fast symlinks will have i_size but no allocated clusters. */
6482 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6483 @@ -1230,8 +1300,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
6485 fe->i_size = cpu_to_le64(i_size_read(inode));
6486 fe->i_links_count = cpu_to_le16(inode->i_nlink);
6487 - fe->i_uid = cpu_to_le32(inode->i_uid);
6488 - fe->i_gid = cpu_to_le32(inode->i_gid);
6489 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
6490 + inode->i_uid, inode->i_tag));
6491 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
6492 + inode->i_gid, inode->i_tag));
6493 + /* i_tag = = cpu_to_le16(inode->i_tag); */
6494 fe->i_mode = cpu_to_le16(inode->i_mode);
6495 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
6496 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
6497 @@ -1259,16 +1332,25 @@ leave:
6498 void ocfs2_refresh_inode(struct inode *inode,
6499 struct ocfs2_dinode *fe)
6504 spin_lock(&OCFS2_I(inode)->ip_lock);
6506 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
6507 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
6508 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
6509 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
6510 OCFS2_I(inode)->ip_dyn_features = le16_to_cpu(fe->i_dyn_features);
6511 ocfs2_set_inode_flags(inode);
6512 i_size_write(inode, le64_to_cpu(fe->i_size));
6513 inode->i_nlink = le16_to_cpu(fe->i_links_count);
6514 - inode->i_uid = le32_to_cpu(fe->i_uid);
6515 - inode->i_gid = le32_to_cpu(fe->i_gid);
6516 + uid = le32_to_cpu(fe->i_uid);
6517 + gid = le32_to_cpu(fe->i_gid);
6518 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6519 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6520 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6521 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6522 inode->i_mode = le16_to_cpu(fe->i_mode);
6523 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
6524 inode->i_blocks = 0;
6525 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/inode.h linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/inode.h
6526 --- linux-2.6.27.3/fs/ocfs2/inode.h 2008-07-13 23:51:29.000000000 +0200
6527 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/inode.h 2008-10-13 14:54:20.000000000 +0200
6528 @@ -143,6 +143,7 @@ int ocfs2_aio_write(struct file *file, s
6530 void ocfs2_set_inode_flags(struct inode *inode);
6531 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6532 +int ocfs2_sync_flags(struct inode *inode);
6534 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6536 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/ioctl.c linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/ioctl.c
6537 --- linux-2.6.27.3/fs/ocfs2/ioctl.c 2008-07-13 23:51:29.000000000 +0200
6538 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/ioctl.c 2008-10-13 14:54:20.000000000 +0200
6539 @@ -42,7 +42,7 @@ static int ocfs2_get_inode_attr(struct i
6543 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6544 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6547 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6548 @@ -67,6 +67,11 @@ static int ocfs2_set_inode_attr(struct i
6549 if (!S_ISDIR(inode->i_mode))
6550 flags &= ~OCFS2_DIRSYNC_FL;
6552 + if (IS_BARRIER(inode)) {
6553 + vxwprintk_task(1, "messing with the barrier.");
6557 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6558 if (IS_ERR(handle)) {
6559 status = PTR_ERR(handle);
6560 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/ioctl.h linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/ioctl.h
6561 --- linux-2.6.27.3/fs/ocfs2/ioctl.h 2008-07-13 23:51:29.000000000 +0200
6562 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/ioctl.h 2008-10-13 14:54:20.000000000 +0200
6564 #ifndef OCFS2_IOCTL_H
6565 #define OCFS2_IOCTL_H
6567 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6570 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
6571 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
6573 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/namei.c linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/namei.c
6574 --- linux-2.6.27.3/fs/ocfs2/namei.c 2008-07-13 23:51:29.000000000 +0200
6575 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/namei.c 2008-10-13 14:54:20.000000000 +0200
6577 #include <linux/types.h>
6578 #include <linux/slab.h>
6579 #include <linux/highmem.h>
6580 +#include <linux/vs_tag.h>
6582 #define MLOG_MASK_PREFIX ML_NAMEI
6583 #include <cluster/masklog.h>
6584 @@ -366,6 +367,9 @@ static int ocfs2_mknod_locked(struct ocf
6587 struct inode *inode = NULL;
6592 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
6593 (unsigned long)dev, dentry->d_name.len,
6594 @@ -425,13 +429,19 @@ static int ocfs2_mknod_locked(struct ocf
6595 fe->i_blkno = cpu_to_le64(fe_blkno);
6596 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6597 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6598 - fe->i_uid = cpu_to_le32(current->fsuid);
6600 + tag = dx_current_fstag(osb->sb);
6601 + uid = current->fsuid;
6602 if (dir->i_mode & S_ISGID) {
6603 - fe->i_gid = cpu_to_le32(dir->i_gid);
6608 - fe->i_gid = cpu_to_le32(current->fsgid);
6609 + gid = current->fsgid;
6611 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
6612 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
6613 + inode->i_tag = tag;
6614 fe->i_mode = cpu_to_le16(mode);
6615 if (S_ISCHR(mode) || S_ISBLK(mode))
6616 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6617 @@ -1917,5 +1927,6 @@ const struct inode_operations ocfs2_dir_
6618 .rename = ocfs2_rename,
6619 .setattr = ocfs2_setattr,
6620 .getattr = ocfs2_getattr,
6621 + .sync_flags = ocfs2_sync_flags,
6622 .permission = ocfs2_permission,
6624 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/ocfs2_fs.h linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/ocfs2_fs.h
6625 --- linux-2.6.27.3/fs/ocfs2/ocfs2_fs.h 2008-10-13 14:52:06.000000000 +0200
6626 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/ocfs2_fs.h 2008-10-13 14:54:20.000000000 +0200
6627 @@ -195,18 +195,23 @@
6628 #define OCFS2_INDEXED_DIR_FL (0x0008)
6630 /* Inode attributes, keep in sync with EXT2 */
6631 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6632 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6633 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6634 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6635 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6636 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6637 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6638 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6639 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6640 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6641 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6642 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6643 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6644 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6645 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6646 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6647 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6649 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6650 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6651 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6652 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6654 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6655 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6657 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6658 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6661 * Extent record flags (e_node.leaf.flags)
6662 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/ocfs2.h linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/ocfs2.h
6663 --- linux-2.6.27.3/fs/ocfs2/ocfs2.h 2008-10-13 14:52:06.000000000 +0200
6664 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/ocfs2.h 2008-10-13 14:54:20.000000000 +0200
6665 @@ -184,6 +184,7 @@ enum ocfs2_mount_options
6666 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
6667 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
6668 OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */
6669 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
6672 #define OCFS2_OSB_SOFT_RO 0x0001
6673 diff -NurpP --minimal linux-2.6.27.3/fs/ocfs2/super.c linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/super.c
6674 --- linux-2.6.27.3/fs/ocfs2/super.c 2008-10-13 14:52:06.000000000 +0200
6675 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/ocfs2/super.c 2008-10-13 14:54:20.000000000 +0200
6676 @@ -154,6 +154,7 @@ enum {
6680 + Opt_tag, Opt_notag, Opt_tagid,
6684 @@ -173,6 +174,9 @@ static match_table_t tokens = {
6685 {Opt_localalloc, "localalloc=%d"},
6686 {Opt_localflocks, "localflocks"},
6687 {Opt_stack, "cluster_stack=%s"},
6689 + {Opt_notag, "notag"},
6690 + {Opt_tagid, "tagid=%u"},
6694 @@ -392,6 +396,13 @@ static int ocfs2_remount(struct super_bl
6698 + if ((parsed_options.mount_opt & OCFS2_MOUNT_TAGGED) &&
6699 + !(sb->s_flags & MS_TAGGED)) {
6701 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6705 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6706 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6708 @@ -725,6 +736,9 @@ static int ocfs2_fill_super(struct super
6710 ocfs2_complete_mount_recovery(osb);
6712 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6713 + sb->s_flags |= MS_TAGGED;
6715 if (ocfs2_mount_local(osb))
6716 snprintf(nodestr, sizeof(nodestr), "local");
6718 @@ -918,6 +932,20 @@ static int ocfs2_parse_options(struct su
6719 OCFS2_STACK_LABEL_LEN);
6720 mopt->cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
6722 +#ifndef CONFIG_TAGGING_NONE
6724 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6727 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6730 +#ifdef CONFIG_PROPAGATE
6733 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6738 "Unrecognized mount option \"%s\" "
6739 diff -NurpP --minimal linux-2.6.27.3/fs/open.c linux-2.6.27.3-vs2.3.0.35.7/fs/open.c
6740 --- linux-2.6.27.3/fs/open.c 2008-10-13 14:52:06.000000000 +0200
6741 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/open.c 2008-10-13 14:54:20.000000000 +0200
6743 #include <linux/rcupdate.h>
6744 #include <linux/audit.h>
6745 #include <linux/falloc.h>
6746 +#include <linux/vs_base.h>
6747 +#include <linux/vs_limit.h>
6748 +#include <linux/vs_dlimit.h>
6749 +#include <linux/vs_tag.h>
6750 +#include <linux/vs_cowbl.h>
6752 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
6754 int retval = -ENODEV;
6757 + struct super_block *sb = dentry->d_sb;
6760 - if (dentry->d_sb->s_op->statfs) {
6761 + if (sb->s_op->statfs) {
6762 memset(buf, 0, sizeof(*buf));
6763 retval = security_sb_statfs(dentry);
6766 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6767 + retval = sb->s_op->statfs(dentry, buf);
6768 if (retval == 0 && buf->f_frsize == 0)
6769 buf->f_frsize = buf->f_bsize;
6771 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6772 + vx_vsi_statfs(sb, buf);
6776 @@ -625,6 +634,10 @@ asmlinkage long sys_fchmodat(int dfd, co
6777 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6781 + error = cow_check_and_break(&path);
6783 + goto dput_and_out;
6784 inode = path.dentry->d_inode;
6786 error = mnt_want_write(path.mnt);
6787 @@ -658,11 +671,11 @@ static int chown_common(struct dentry *
6788 newattrs.ia_valid = ATTR_CTIME;
6789 if (user != (uid_t) -1) {
6790 newattrs.ia_valid |= ATTR_UID;
6791 - newattrs.ia_uid = user;
6792 + newattrs.ia_uid = dx_map_uid(user);
6794 if (group != (gid_t) -1) {
6795 newattrs.ia_valid |= ATTR_GID;
6796 - newattrs.ia_gid = group;
6797 + newattrs.ia_gid = dx_map_gid(group);
6799 if (!S_ISDIR(inode->i_mode))
6800 newattrs.ia_valid |=
6801 @@ -685,7 +698,11 @@ asmlinkage long sys_chown(const char __u
6802 error = mnt_want_write(path.mnt);
6805 - error = chown_common(path.dentry, user, group);
6806 +#ifdef CONFIG_VSERVER_COWBL
6807 + error = cow_check_and_break(&path);
6810 + error = chown_common(path.dentry, user, group);
6811 mnt_drop_write(path.mnt);
6814 @@ -710,7 +727,11 @@ asmlinkage long sys_fchownat(int dfd, co
6815 error = mnt_want_write(path.mnt);
6818 - error = chown_common(path.dentry, user, group);
6819 +#ifdef CONFIG_VSERVER_COWBL
6820 + error = cow_check_and_break(&path);
6823 + error = chown_common(path.dentry, user, group);
6824 mnt_drop_write(path.mnt);
6827 @@ -729,7 +750,11 @@ asmlinkage long sys_lchown(const char __
6828 error = mnt_want_write(path.mnt);
6831 - error = chown_common(path.dentry, user, group);
6832 +#ifdef CONFIG_VSERVER_COWBL
6833 + error = cow_check_and_break(&path);
6836 + error = chown_common(path.dentry, user, group);
6837 mnt_drop_write(path.mnt);
6840 @@ -969,6 +994,7 @@ static void __put_unused_fd(struct files
6841 __FD_CLR(fd, fdt->open_fds);
6842 if (fd < files->next_fd)
6843 files->next_fd = fd;
6844 + vx_openfd_dec(fd);
6847 void put_unused_fd(unsigned int fd)
6848 diff -NurpP --minimal linux-2.6.27.3/fs/proc/array.c linux-2.6.27.3-vs2.3.0.35.7/fs/proc/array.c
6849 --- linux-2.6.27.3/fs/proc/array.c 2008-10-13 14:52:06.000000000 +0200
6850 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/proc/array.c 2008-10-13 14:54:20.000000000 +0200
6852 #include <linux/seq_file.h>
6853 #include <linux/pid_namespace.h>
6854 #include <linux/tracehook.h>
6855 +#include <linux/vs_context.h>
6856 +#include <linux/vs_network.h>
6858 #include <asm/pgtable.h>
6859 #include <asm/processor.h>
6860 @@ -142,8 +144,9 @@ static const char *task_state_array[] =
6861 "D (disk sleep)", /* 2 */
6862 "T (stopped)", /* 4 */
6863 "T (tracing stop)", /* 8 */
6864 - "Z (zombie)", /* 16 */
6865 - "X (dead)" /* 32 */
6866 + "H (on hold)", /* 16 */
6867 + "Z (zombie)", /* 32 */
6868 + "X (dead)", /* 64 */
6871 static inline const char *get_task_state(struct task_struct *tsk)
6872 @@ -164,6 +167,7 @@ static inline void task_state(struct seq
6873 struct group_info *group_info;
6875 struct fdtable *fdt = NULL;
6876 +/* + pid_t pid, ptgid, tppid, tgid; */
6880 @@ -175,6 +179,12 @@ static inline void task_state(struct seq
6882 tpid = task_pid_nr_ns(tracer, ns);
6884 +/* tgid = vx_map_tgid(p->tgid);
6885 + pid = vx_map_pid(p->pid);
6886 + ptgid = vx_map_pid(pid_alive(p) ?
6887 + rcu_dereference(p->real_parent)->tgid : 0);
6888 + tppid = vx_map_pid(pid_alive(p) && p->ptrace ?
6889 + rcu_dereference(p->parent)->pid : 0); */
6893 @@ -286,7 +296,7 @@ static inline void task_sig(struct seq_f
6896 static void render_cap_t(struct seq_file *m, const char *header,
6898 + struct vx_info *vxi, kernel_cap_t *a)
6902 @@ -300,10 +310,10 @@ static void render_cap_t(struct seq_file
6904 static inline void task_cap(struct seq_file *m, struct task_struct *p)
6906 - render_cap_t(m, "CapInh:\t", &p->cap_inheritable);
6907 - render_cap_t(m, "CapPrm:\t", &p->cap_permitted);
6908 - render_cap_t(m, "CapEff:\t", &p->cap_effective);
6909 - render_cap_t(m, "CapBnd:\t", &p->cap_bset);
6910 + render_cap_t(m, "CapInh:\t", p->vx_info, &p->cap_inheritable);
6911 + render_cap_t(m, "CapPrm:\t", p->vx_info, &p->cap_permitted);
6912 + render_cap_t(m, "CapEff:\t", p->vx_info, &p->cap_effective);
6913 + render_cap_t(m, "CapBnd:\t", p->vx_info, &p->cap_bset);
6916 static inline void task_context_switch_counts(struct seq_file *m,
6917 @@ -315,6 +325,45 @@ static inline void task_context_switch_c
6921 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6922 + struct pid *pid, struct task_struct *task)
6924 + seq_printf(m, "Proxy:\t%p(%c)\n"
6933 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6934 + atomic_read(&task->nsproxy->count),
6935 + task->nsproxy->uts_ns,
6936 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6937 + task->nsproxy->ipc_ns,
6938 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6939 + task->nsproxy->mnt_ns,
6940 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6941 + task->nsproxy->pid_ns,
6942 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6943 + task->nsproxy->user_ns,
6944 + (task->nsproxy->user_ns == init_task.nsproxy->user_ns ? 'I' : '-'),
6945 + task->nsproxy->net_ns,
6946 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6950 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6952 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6955 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6956 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6960 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6961 struct pid *pid, struct task_struct *task)
6963 @@ -330,6 +379,7 @@ int proc_pid_status(struct seq_file *m,
6966 cpuset_task_status_allowed(m, task);
6967 + task_vs_id(m, task);
6968 #if defined(CONFIG_S390)
6969 task_show_regs(m, task);
6971 @@ -442,6 +492,17 @@ static int do_task_stat(struct seq_file
6972 /* convert nsec -> ticks */
6973 start_time = nsec_to_clock_t(start_time);
6975 + /* fixup start time for virt uptime */
6976 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6977 + unsigned long long bias =
6978 + current->vx_info->cvirt.bias_clock;
6980 + if (start_time > bias)
6981 + start_time -= bias;
6986 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6987 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6988 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6989 diff -NurpP --minimal linux-2.6.27.3/fs/proc/base.c linux-2.6.27.3-vs2.3.0.35.7/fs/proc/base.c
6990 --- linux-2.6.27.3/fs/proc/base.c 2008-10-13 14:52:06.000000000 +0200
6991 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/proc/base.c 2008-10-13 14:54:20.000000000 +0200
6993 #include <linux/oom.h>
6994 #include <linux/elf.h>
6995 #include <linux/pid_namespace.h>
6996 +#include <linux/vs_context.h>
6997 +#include <linux/vs_network.h>
6998 #include "internal.h"
7001 @@ -1439,6 +1441,8 @@ static struct inode *proc_pid_make_inode
7002 inode->i_uid = task->euid;
7003 inode->i_gid = task->egid;
7005 + /* procfs is xid tagged */
7006 + inode->i_tag = (tag_t)vx_task_xid(task);
7007 security_task_to_inode(task, inode);
7010 @@ -1979,6 +1983,13 @@ static struct dentry *proc_pident_lookup
7014 + /* TODO: maybe we can come up with a generic approach? */
7015 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
7016 + (dentry->d_name.len == 5) &&
7017 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
7018 + !memcmp(dentry->d_name.name, "ninfo", 5)))
7022 * Yes, it does not scale. And it should not. Don't add
7023 * new entries into /proc/<tgid>/ without very good reasons.
7024 @@ -2366,7 +2377,7 @@ out_iput:
7025 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
7027 struct dentry *error;
7028 - struct task_struct *task = get_proc_task(dir);
7029 + struct task_struct *task = get_proc_task_real(dir);
7030 const struct pid_entry *p, *last;
7032 error = ERR_PTR(-ENOENT);
7033 @@ -2449,6 +2460,9 @@ static int proc_tgid_io_accounting(struc
7034 static const struct file_operations proc_task_operations;
7035 static const struct inode_operations proc_task_inode_operations;
7037 +extern int proc_pid_vx_info(struct task_struct *, char *);
7038 +extern int proc_pid_nx_info(struct task_struct *, char *);
7040 static const struct pid_entry tgid_base_stuff[] = {
7041 DIR("task", S_IRUGO|S_IXUGO, task),
7042 DIR("fd", S_IRUSR|S_IXUSR, fd),
7043 @@ -2503,6 +2517,8 @@ static const struct pid_entry tgid_base_
7044 #ifdef CONFIG_CGROUPS
7045 REG("cgroup", S_IRUGO, cgroup),
7047 + INF("vinfo", S_IRUGO, pid_vx_info),
7048 + INF("ninfo", S_IRUGO, pid_nx_info),
7049 INF("oom_score", S_IRUGO, oom_score),
7050 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
7051 #ifdef CONFIG_AUDITSYSCALL
7052 @@ -2518,6 +2534,7 @@ static const struct pid_entry tgid_base_
7053 #ifdef CONFIG_TASK_IO_ACCOUNTING
7054 INF("io", S_IRUGO, tgid_io_accounting),
7056 + ONE("nsproxy", S_IRUGO, pid_nsproxy),
7059 static int proc_tgid_base_readdir(struct file * filp,
7060 @@ -2714,7 +2731,7 @@ retry:
7062 pid = find_ge_pid(iter.tgid, ns);
7064 - iter.tgid = pid_nr_ns(pid, ns);
7065 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
7066 iter.task = pid_task(pid, PIDTYPE_PID);
7067 /* What we to know is if the pid we have find is the
7068 * pid of a thread_group_leader. Testing for task
7069 @@ -2744,7 +2761,7 @@ static int proc_pid_fill_cache(struct fi
7070 struct tgid_iter iter)
7072 char name[PROC_NUMBUF];
7073 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
7074 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
7075 return proc_fill_cache(filp, dirent, filldir, name, len,
7076 proc_pid_instantiate, iter.task, NULL);
7078 @@ -2753,7 +2770,7 @@ static int proc_pid_fill_cache(struct fi
7079 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
7081 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
7082 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
7083 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
7084 struct tgid_iter iter;
7085 struct pid_namespace *ns;
7087 @@ -2773,6 +2790,8 @@ int proc_pid_readdir(struct file * filp,
7089 iter.tgid += 1, iter = next_tgid(ns, iter)) {
7090 filp->f_pos = iter.tgid + TGID_OFFSET;
7091 + if (!vx_proc_task_visible(iter.task))
7093 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
7094 put_task_struct(iter.task);
7096 @@ -2915,6 +2934,8 @@ static struct dentry *proc_task_lookup(s
7097 tid = name_to_int(dentry);
7100 + if (vx_current_initpid(tid))
7103 ns = dentry->d_sb->s_fs_info;
7105 diff -NurpP --minimal linux-2.6.27.3/fs/proc/generic.c linux-2.6.27.3-vs2.3.0.35.7/fs/proc/generic.c
7106 --- linux-2.6.27.3/fs/proc/generic.c 2008-10-13 14:52:06.000000000 +0200
7107 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/proc/generic.c 2008-10-13 14:54:20.000000000 +0200
7109 #include <linux/bitops.h>
7110 #include <linux/spinlock.h>
7111 #include <linux/completion.h>
7112 +#include <linux/vserver/inode.h>
7113 #include <asm/uaccess.h>
7115 #include "internal.h"
7116 @@ -384,6 +385,8 @@ struct dentry *proc_lookup_de(struct pro
7117 for (de = de->subdir; de ; de = de->next) {
7118 if (de->namelen != dentry->d_name.len)
7120 + if (!vx_hide_check(0, de->vx_flags))
7122 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
7125 @@ -392,6 +395,8 @@ struct dentry *proc_lookup_de(struct pro
7126 spin_unlock(&proc_subdir_lock);
7128 inode = proc_get_inode(dir->i_sb, ino, de);
7129 + /* generic proc entries belong to the host */
7134 @@ -472,6 +477,8 @@ int proc_readdir_de(struct proc_dir_entr
7136 /* filldir passes info to user space */
7138 + if (!vx_hide_check(0, de->vx_flags))
7140 spin_unlock(&proc_subdir_lock);
7141 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
7142 de->low_ino, de->mode >> 12) < 0) {
7143 @@ -479,6 +486,7 @@ int proc_readdir_de(struct proc_dir_entr
7146 spin_lock(&proc_subdir_lock);
7151 @@ -593,6 +601,7 @@ static struct proc_dir_entry *__proc_cre
7153 atomic_set(&ent->count, 1);
7155 + ent->vx_flags = IATTR_PROC_DEFAULT;
7156 spin_lock_init(&ent->pde_unload_lock);
7157 ent->pde_unload_completion = NULL;
7158 INIT_LIST_HEAD(&ent->pde_openers);
7159 @@ -616,7 +625,8 @@ struct proc_dir_entry *proc_symlink(cons
7165 + ent->vx_flags = IATTR_PROC_SYMLINK;
7169 diff -NurpP --minimal linux-2.6.27.3/fs/proc/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/proc/inode.c
7170 --- linux-2.6.27.3/fs/proc/inode.c 2008-10-13 14:52:06.000000000 +0200
7171 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/proc/inode.c 2008-10-13 14:54:20.000000000 +0200
7172 @@ -469,6 +469,8 @@ struct inode *proc_get_inode(struct supe
7173 inode->i_uid = de->uid;
7174 inode->i_gid = de->gid;
7177 + PROC_I(inode)->vx_flags = de->vx_flags;
7179 inode->i_size = de->size;
7181 diff -NurpP --minimal linux-2.6.27.3/fs/proc/internal.h linux-2.6.27.3-vs2.3.0.35.7/fs/proc/internal.h
7182 --- linux-2.6.27.3/fs/proc/internal.h 2008-10-13 14:52:06.000000000 +0200
7183 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/proc/internal.h 2008-10-13 14:54:20.000000000 +0200
7187 #include <linux/proc_fs.h>
7188 +#include <linux/vs_pid.h>
7190 extern struct proc_dir_entry proc_root;
7191 #ifdef CONFIG_PROC_SYSCTL
7192 @@ -55,6 +56,9 @@ extern int proc_pid_status(struct seq_fi
7193 struct pid *pid, struct task_struct *task);
7194 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7195 struct pid *pid, struct task_struct *task);
7196 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7197 + struct pid *pid, struct task_struct *task);
7199 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7201 extern const struct file_operations proc_maps_operations;
7202 @@ -75,11 +79,16 @@ static inline struct pid *proc_pid(struc
7203 return PROC_I(inode)->pid;
7206 -static inline struct task_struct *get_proc_task(struct inode *inode)
7207 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7209 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7212 +static inline struct task_struct *get_proc_task(struct inode *inode)
7214 + return vx_get_proc_task(inode, proc_pid(inode));
7217 static inline int proc_fd(struct inode *inode)
7219 return PROC_I(inode)->fd;
7220 diff -NurpP --minimal linux-2.6.27.3/fs/proc/proc_misc.c linux-2.6.27.3-vs2.3.0.35.7/fs/proc/proc_misc.c
7221 --- linux-2.6.27.3/fs/proc/proc_misc.c 2008-10-13 14:52:06.000000000 +0200
7222 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/proc/proc_misc.c 2008-10-13 14:54:20.000000000 +0200
7224 #include <asm/div64.h>
7225 #include "internal.h"
7227 +#include <linux/vs_cvirt.h>
7229 #define LOAD_INT(x) ((x) >> FSHIFT)
7230 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
7232 @@ -84,22 +86,38 @@ static int proc_calc_metrics(char *page,
7233 static int loadavg_read_proc(char *page, char **start, off_t off,
7234 int count, int *eof, void *data)
7236 + unsigned long running;
7237 + unsigned int threads;
7243 seq = read_seqbegin(&xtime_lock);
7244 - a = avenrun[0] + (FIXED_1/200);
7245 - b = avenrun[1] + (FIXED_1/200);
7246 - c = avenrun[2] + (FIXED_1/200);
7247 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7248 + struct vx_info *vxi = current->vx_info;
7250 + a = vxi->cvirt.load[0] + (FIXED_1/200);
7251 + b = vxi->cvirt.load[1] + (FIXED_1/200);
7252 + c = vxi->cvirt.load[2] + (FIXED_1/200);
7254 + running = atomic_read(&vxi->cvirt.nr_running);
7255 + threads = atomic_read(&vxi->cvirt.nr_threads);
7257 + a = avenrun[0] + (FIXED_1/200);
7258 + b = avenrun[1] + (FIXED_1/200);
7259 + c = avenrun[2] + (FIXED_1/200);
7261 + running = nr_running();
7262 + threads = nr_threads;
7264 } while (read_seqretry(&xtime_lock, seq));
7266 len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
7267 LOAD_INT(a), LOAD_FRAC(a),
7268 LOAD_INT(b), LOAD_FRAC(b),
7269 LOAD_INT(c), LOAD_FRAC(c),
7270 - nr_running(), nr_threads,
7272 task_active_pid_ns(current)->last_pid);
7273 return proc_calc_metrics(page, start, off, count, eof, len);
7275 @@ -115,6 +133,9 @@ static int uptime_read_proc(char *page,
7276 do_posix_clock_monotonic_gettime(&uptime);
7277 monotonic_to_bootbased(&uptime);
7278 cputime_to_timespec(idletime, &idle);
7279 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7280 + vx_vsi_uptime(&uptime, &idle);
7282 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
7283 (unsigned long) uptime.tv_sec,
7284 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7285 @@ -151,7 +172,7 @@ static int meminfo_read_proc(char *page,
7287 cached = global_page_state(NR_FILE_PAGES) -
7288 total_swapcache_pages - i.bufferram;
7290 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
7293 get_vmalloc_info(&vmi);
7294 diff -NurpP --minimal linux-2.6.27.3/fs/proc/root.c linux-2.6.27.3-vs2.3.0.35.7/fs/proc/root.c
7295 --- linux-2.6.27.3/fs/proc/root.c 2008-07-13 23:51:29.000000000 +0200
7296 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/proc/root.c 2008-10-13 14:54:20.000000000 +0200
7299 #include "internal.h"
7301 +struct proc_dir_entry *proc_virtual;
7303 +extern void proc_vx_init(void);
7305 static int proc_test_super(struct super_block *sb, void *data)
7307 return sb->s_fs_info == data;
7308 @@ -137,6 +141,7 @@ void __init proc_root_init(void)
7310 proc_mkdir("bus", NULL);
7315 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7316 diff -NurpP --minimal linux-2.6.27.3/fs/quota.c linux-2.6.27.3-vs2.3.0.35.7/fs/quota.c
7317 --- linux-2.6.27.3/fs/quota.c 2008-10-13 14:52:06.000000000 +0200
7318 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/quota.c 2008-10-13 14:54:20.000000000 +0200
7320 #include <linux/capability.h>
7321 #include <linux/quotaops.h>
7322 #include <linux/types.h>
7323 +#include <linux/vs_context.h>
7325 /* Check validity of generic quotactl commands */
7326 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
7327 @@ -81,11 +82,11 @@ static int generic_quotactl_valid(struct
7328 if (cmd == Q_GETQUOTA) {
7329 if (((type == USRQUOTA && current->euid != id) ||
7330 (type == GRPQUOTA && !in_egroup_p(id))) &&
7331 - !capable(CAP_SYS_ADMIN))
7332 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7335 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7336 - if (!capable(CAP_SYS_ADMIN))
7337 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7341 @@ -132,10 +133,10 @@ static int xqm_quotactl_valid(struct sup
7342 if (cmd == Q_XGETQUOTA) {
7343 if (((type == XQM_USRQUOTA && current->euid != id) ||
7344 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7345 - !capable(CAP_SYS_ADMIN))
7346 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7348 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7349 - if (!capable(CAP_SYS_ADMIN))
7350 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7354 @@ -334,6 +335,46 @@ static int do_quotactl(struct super_bloc
7358 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7360 +#include <linux/vroot.h>
7361 +#include <linux/major.h>
7362 +#include <linux/module.h>
7363 +#include <linux/kallsyms.h>
7364 +#include <linux/vserver/debug.h>
7366 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7368 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7370 +int register_vroot_grb(vroot_grb_func *func) {
7373 + spin_lock(&vroot_grb_lock);
7374 + if (!vroot_get_real_bdev) {
7375 + vroot_get_real_bdev = func;
7378 + spin_unlock(&vroot_grb_lock);
7381 +EXPORT_SYMBOL(register_vroot_grb);
7383 +int unregister_vroot_grb(vroot_grb_func *func) {
7384 + int ret = -EINVAL;
7386 + spin_lock(&vroot_grb_lock);
7387 + if (vroot_get_real_bdev) {
7388 + vroot_get_real_bdev = NULL;
7391 + spin_unlock(&vroot_grb_lock);
7394 +EXPORT_SYMBOL(unregister_vroot_grb);
7399 * look up a superblock on which quota ops will be performed
7400 * - use the name of a block device to find the superblock thereon
7401 @@ -351,6 +392,22 @@ static inline struct super_block *quotac
7404 return ERR_CAST(bdev);
7405 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7406 + if (bdev && bdev->bd_inode &&
7407 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7408 + struct block_device *bdnew = (void *)-EINVAL;
7410 + if (vroot_get_real_bdev)
7411 + bdnew = vroot_get_real_bdev(bdev);
7413 + vxdprintk(VXD_CBIT(misc, 0),
7414 + "vroot_get_real_bdev not set");
7416 + if (IS_ERR(bdnew))
7417 + return ERR_PTR(PTR_ERR(bdnew));
7421 sb = get_super(bdev);
7424 diff -NurpP --minimal linux-2.6.27.3/fs/reiserfs/bitmap.c linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/bitmap.c
7425 --- linux-2.6.27.3/fs/reiserfs/bitmap.c 2008-07-13 23:51:29.000000000 +0200
7426 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/bitmap.c 2008-10-13 14:54:20.000000000 +0200
7428 #include <linux/reiserfs_fs_sb.h>
7429 #include <linux/reiserfs_fs_i.h>
7430 #include <linux/quotaops.h>
7431 +#include <linux/vs_dlimit.h>
7433 #define PREALLOCATION_SIZE 9
7435 @@ -429,8 +430,10 @@ static void _reiserfs_free_block(struct
7436 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
7438 journal_mark_dirty(th, s, sbh);
7439 - if (for_unformatted)
7440 + if (for_unformatted) {
7441 + DLIMIT_FREE_BLOCK(inode, 1);
7442 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
7446 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
7447 @@ -1045,6 +1048,7 @@ static inline int blocknrs_and_prealloc_
7448 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
7450 int nr_allocated = 0;
7453 determine_prealloc_size(hint);
7454 if (!hint->formatted_node) {
7455 @@ -1054,19 +1058,30 @@ static inline int blocknrs_and_prealloc_
7456 "reiserquota: allocating %d blocks id=%u",
7457 amount_needed, hint->inode->i_uid);
7460 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
7461 - if (quota_ret) /* Quota exceeded? */
7462 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
7465 return QUOTA_EXCEEDED;
7466 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
7467 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7469 + return NO_DISK_SPACE;
7472 if (hint->preallocate && hint->prealloc_size) {
7473 #ifdef REISERQUOTA_DEBUG
7474 reiserfs_debug(s, REISERFS_DEBUG_CODE,
7475 "reiserquota: allocating (prealloc) %d blocks id=%u",
7476 hint->prealloc_size, hint->inode->i_uid);
7479 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7480 - hint->prealloc_size);
7481 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7482 + hint->prealloc_size);
7484 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
7485 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7486 + hint->prealloc_size);
7490 hint->preallocate = hint->prealloc_size = 0;
7492 @@ -1098,7 +1113,10 @@ static inline int blocknrs_and_prealloc_
7494 hint->inode->i_uid);
7496 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
7497 + /* Free not allocated blocks */
7498 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
7499 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7500 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7502 while (nr_allocated--)
7503 reiserfs_free_block(hint->th, hint->inode,
7504 @@ -1129,10 +1147,10 @@ static inline int blocknrs_and_prealloc_
7505 REISERFS_I(hint->inode)->i_prealloc_count,
7506 hint->inode->i_uid);
7508 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
7509 - hint->prealloc_size - nr_allocated -
7510 - REISERFS_I(hint->inode)->
7511 - i_prealloc_count);
7512 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
7513 + REISERFS_I(hint->inode)->i_prealloc_count;
7514 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7515 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7519 diff -NurpP --minimal linux-2.6.27.3/fs/reiserfs/file.c linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/file.c
7520 --- linux-2.6.27.3/fs/reiserfs/file.c 2008-07-13 23:51:29.000000000 +0200
7521 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/file.c 2008-10-13 14:54:20.000000000 +0200
7522 @@ -306,4 +306,5 @@ const struct inode_operations reiserfs_f
7523 .listxattr = reiserfs_listxattr,
7524 .removexattr = reiserfs_removexattr,
7525 .permission = reiserfs_permission,
7526 + .sync_flags = reiserfs_sync_flags,
7528 diff -NurpP --minimal linux-2.6.27.3/fs/reiserfs/inode.c linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/inode.c
7529 --- linux-2.6.27.3/fs/reiserfs/inode.c 2008-10-13 14:52:06.000000000 +0200
7530 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/inode.c 2008-10-13 14:54:20.000000000 +0200
7532 #include <linux/writeback.h>
7533 #include <linux/quotaops.h>
7534 #include <linux/swap.h>
7535 +#include <linux/vs_dlimit.h>
7536 +#include <linux/vs_tag.h>
7538 int reiserfs_commit_write(struct file *f, struct page *page,
7539 unsigned from, unsigned to);
7540 @@ -54,6 +56,7 @@ void reiserfs_delete_inode(struct inode
7541 * stat data deletion */
7543 DQUOT_FREE_INODE(inode);
7544 + DLIMIT_FREE_INODE(inode);
7546 if (journal_end(&th, inode->i_sb, jbegin_count))
7548 @@ -1116,6 +1119,8 @@ static void init_inode(struct inode *ino
7549 struct buffer_head *bh;
7550 struct item_head *ih;
7554 //int version = ITEM_VERSION_1;
7556 bh = PATH_PLAST_BUFFER(path);
7557 @@ -1139,12 +1144,13 @@ static void init_inode(struct inode *ino
7558 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7559 unsigned long blocks;
7561 + uid = sd_v1_uid(sd);
7562 + gid = sd_v1_gid(sd);
7564 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7565 set_inode_sd_version(inode, STAT_DATA_V1);
7566 inode->i_mode = sd_v1_mode(sd);
7567 inode->i_nlink = sd_v1_nlink(sd);
7568 - inode->i_uid = sd_v1_uid(sd);
7569 - inode->i_gid = sd_v1_gid(sd);
7570 inode->i_size = sd_v1_size(sd);
7571 inode->i_atime.tv_sec = sd_v1_atime(sd);
7572 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7573 @@ -1186,11 +1192,12 @@ static void init_inode(struct inode *ino
7574 // (directories and symlinks)
7575 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7577 + uid = sd_v2_uid(sd);
7578 + gid = sd_v2_gid(sd);
7580 inode->i_mode = sd_v2_mode(sd);
7581 inode->i_nlink = sd_v2_nlink(sd);
7582 - inode->i_uid = sd_v2_uid(sd);
7583 inode->i_size = sd_v2_size(sd);
7584 - inode->i_gid = sd_v2_gid(sd);
7585 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7586 inode->i_atime.tv_sec = sd_v2_atime(sd);
7587 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7588 @@ -1220,6 +1227,10 @@ static void init_inode(struct inode *ino
7589 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7592 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7593 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7594 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7597 if (S_ISREG(inode->i_mode)) {
7598 inode->i_op = &reiserfs_file_inode_operations;
7599 @@ -1242,13 +1253,15 @@ static void init_inode(struct inode *ino
7600 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7602 struct stat_data *sd_v2 = (struct stat_data *)sd;
7603 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7604 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7607 + set_sd_v2_uid(sd_v2, uid);
7608 + set_sd_v2_gid(sd_v2, gid);
7609 set_sd_v2_mode(sd_v2, inode->i_mode);
7610 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7611 - set_sd_v2_uid(sd_v2, inode->i_uid);
7612 set_sd_v2_size(sd_v2, size);
7613 - set_sd_v2_gid(sd_v2, inode->i_gid);
7614 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7615 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7616 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7617 @@ -1771,6 +1784,10 @@ int reiserfs_new_inode(struct reiserfs_t
7619 BUG_ON(!th->t_trans_id);
7621 + if (DLIMIT_ALLOC_INODE(inode)) {
7623 + goto out_bad_dlimit;
7625 if (DQUOT_ALLOC_INODE(inode)) {
7628 @@ -1956,6 +1973,9 @@ int reiserfs_new_inode(struct reiserfs_t
7629 DQUOT_FREE_INODE(inode);
7632 + DLIMIT_FREE_INODE(inode);
7635 journal_end(th, th->t_super, th->t_blocks_allocated);
7636 /* Drop can be outside and it needs more credits so it's better to have it outside */
7638 @@ -2842,14 +2862,19 @@ int reiserfs_commit_write(struct file *f
7639 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7641 if (reiserfs_attrs(inode->i_sb)) {
7642 - if (sd_attrs & REISERFS_SYNC_FL)
7643 - inode->i_flags |= S_SYNC;
7645 - inode->i_flags &= ~S_SYNC;
7646 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7647 inode->i_flags |= S_IMMUTABLE;
7649 inode->i_flags &= ~S_IMMUTABLE;
7650 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7651 + inode->i_flags |= S_IXUNLINK;
7653 + inode->i_flags &= ~S_IXUNLINK;
7655 + if (sd_attrs & REISERFS_SYNC_FL)
7656 + inode->i_flags |= S_SYNC;
7658 + inode->i_flags &= ~S_SYNC;
7659 if (sd_attrs & REISERFS_APPEND_FL)
7660 inode->i_flags |= S_APPEND;
7662 @@ -2862,6 +2887,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7663 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7665 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7667 + if (sd_attrs & REISERFS_BARRIER_FL)
7668 + inode->i_vflags |= V_BARRIER;
7670 + inode->i_vflags &= ~V_BARRIER;
7671 + if (sd_attrs & REISERFS_COW_FL)
7672 + inode->i_vflags |= V_COW;
7674 + inode->i_vflags &= ~V_COW;
7678 @@ -2872,6 +2906,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7679 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7681 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7682 + if (inode->i_flags & S_IXUNLINK)
7683 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7685 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7687 if (inode->i_flags & S_SYNC)
7688 *sd_attrs |= REISERFS_SYNC_FL;
7690 @@ -2884,6 +2923,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7691 *sd_attrs |= REISERFS_NOTAIL_FL;
7693 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7695 + if (inode->i_vflags & V_BARRIER)
7696 + *sd_attrs |= REISERFS_BARRIER_FL;
7698 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7699 + if (inode->i_vflags & V_COW)
7700 + *sd_attrs |= REISERFS_COW_FL;
7702 + *sd_attrs &= ~REISERFS_COW_FL;
7706 @@ -3051,6 +3099,22 @@ static ssize_t reiserfs_direct_IO(int rw
7707 reiserfs_get_blocks_direct_io, NULL);
7710 +int reiserfs_sync_flags(struct inode *inode)
7712 + u16 oldflags, newflags;
7714 + oldflags = REISERFS_I(inode)->i_attrs;
7715 + newflags = oldflags;
7716 + i_attrs_to_sd_attrs(inode, &newflags);
7718 + if (oldflags ^ newflags) {
7719 + REISERFS_I(inode)->i_attrs = newflags;
7720 + inode->i_ctime = CURRENT_TIME_SEC;
7721 + mark_inode_dirty(inode);
7726 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
7728 struct inode *inode = dentry->d_inode;
7729 @@ -3104,9 +3168,11 @@ int reiserfs_setattr(struct dentry *dent
7732 error = inode_change_ok(inode, attr);
7735 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7736 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7737 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7738 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7739 error = reiserfs_chown_xattrs(inode, attr);
7742 @@ -3136,6 +3202,9 @@ int reiserfs_setattr(struct dentry *dent
7743 inode->i_uid = attr->ia_uid;
7744 if (attr->ia_valid & ATTR_GID)
7745 inode->i_gid = attr->ia_gid;
7746 + if ((attr->ia_valid & ATTR_TAG) &&
7748 + inode->i_tag = attr->ia_tag;
7749 mark_inode_dirty(inode);
7751 journal_end(&th, inode->i_sb, jbegin_count);
7752 diff -NurpP --minimal linux-2.6.27.3/fs/reiserfs/ioctl.c linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/ioctl.c
7753 --- linux-2.6.27.3/fs/reiserfs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
7754 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/ioctl.c 2008-10-13 14:54:20.000000000 +0200
7756 #include <linux/mount.h>
7757 #include <linux/reiserfs_fs.h>
7758 #include <linux/time.h>
7759 +#include <linux/mount.h>
7760 #include <asm/uaccess.h>
7761 #include <linux/pagemap.h>
7762 #include <linux/smp_lock.h>
7764 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
7767 - unsigned int flags;
7768 + unsigned int flags, oldflags;
7772 @@ -43,6 +44,7 @@ int reiserfs_ioctl(struct inode *inode,
7774 flags = REISERFS_I(inode)->i_attrs;
7775 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7776 + flags &= REISERFS_FL_USER_VISIBLE;
7777 return put_user(flags, (int __user *)arg);
7778 case REISERFS_IOC_SETFLAGS:{
7779 if (!reiserfs_attrs(inode->i_sb))
7780 @@ -60,6 +62,10 @@ int reiserfs_ioctl(struct inode *inode,
7784 + if (IS_BARRIER(inode)) {
7785 + vxwprintk_task(1, "messing with the barrier.");
7789 * Is it quota file? Do not allow user to mess with it
7791 @@ -84,6 +90,10 @@ int reiserfs_ioctl(struct inode *inode,
7796 + oldflags = REISERFS_I(inode)->i_attrs;
7797 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
7798 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7799 sd_attrs_to_i_attrs(flags, inode);
7800 REISERFS_I(inode)->i_attrs = flags;
7801 inode->i_ctime = CURRENT_TIME_SEC;
7802 diff -NurpP --minimal linux-2.6.27.3/fs/reiserfs/namei.c linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/namei.c
7803 --- linux-2.6.27.3/fs/reiserfs/namei.c 2008-07-13 23:51:29.000000000 +0200
7804 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/namei.c 2008-10-13 14:54:20.000000000 +0200
7806 #include <linux/reiserfs_acl.h>
7807 #include <linux/reiserfs_xattr.h>
7808 #include <linux/quotaops.h>
7809 +#include <linux/vs_tag.h>
7811 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
7812 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7813 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
7814 reiserfs_write_unlock(dir->i_sb);
7815 return ERR_PTR(-EACCES);
7817 + dx_propagate_tag(nd, inode);
7819 /* Propogate the priv_object flag so we know we're in the priv tree */
7820 if (is_reiserfs_priv_object(dir))
7821 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
7823 inode->i_gid = current->fsgid;
7825 + inode->i_tag = dx_current_fstag(inode->i_sb);
7829 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
7830 .listxattr = reiserfs_listxattr,
7831 .removexattr = reiserfs_removexattr,
7832 .permission = reiserfs_permission,
7833 + .sync_flags = reiserfs_sync_flags,
7837 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
7838 .listxattr = reiserfs_listxattr,
7839 .removexattr = reiserfs_removexattr,
7840 .permission = reiserfs_permission,
7841 + .sync_flags = reiserfs_sync_flags,
7845 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
7846 .listxattr = reiserfs_listxattr,
7847 .removexattr = reiserfs_removexattr,
7848 .permission = reiserfs_permission,
7849 + .sync_flags = reiserfs_sync_flags,
7852 diff -NurpP --minimal linux-2.6.27.3/fs/reiserfs/stree.c linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/stree.c
7853 --- linux-2.6.27.3/fs/reiserfs/stree.c 2008-07-13 23:51:29.000000000 +0200
7854 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/stree.c 2008-10-13 14:54:20.000000000 +0200
7856 #include <linux/reiserfs_fs.h>
7857 #include <linux/buffer_head.h>
7858 #include <linux/quotaops.h>
7859 +#include <linux/vs_dlimit.h>
7861 /* Does the buffer contain a disk block which is in the tree. */
7862 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
7863 @@ -1297,6 +1298,7 @@ int reiserfs_delete_item(struct reiserfs
7864 "reiserquota delete_item(): freeing %u, id=%u type=%c",
7865 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
7867 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7868 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7870 /* Return deleted body length */
7871 @@ -1385,6 +1387,7 @@ void reiserfs_delete_solid_item(struct r
7873 DQUOT_FREE_SPACE_NODIRTY(inode,
7875 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
7879 @@ -1734,6 +1737,7 @@ int reiserfs_cut_from_item(struct reiser
7880 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
7881 quota_cut_bytes, p_s_inode->i_uid, '?');
7883 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7884 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7887 @@ -1975,6 +1979,11 @@ int reiserfs_paste_into_item(struct reis
7888 pathrelse(p_s_search_path);
7891 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
7892 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7893 + pathrelse(p_s_search_path);
7896 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
7898 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
7899 @@ -2027,6 +2036,7 @@ int reiserfs_paste_into_item(struct reis
7900 n_pasted_size, inode->i_uid,
7901 key2type(&(p_s_key->on_disk_key)));
7903 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
7904 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7907 @@ -2064,6 +2074,11 @@ int reiserfs_insert_item(struct reiserfs
7908 pathrelse(p_s_path);
7911 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
7912 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7913 + pathrelse(p_s_path);
7917 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
7918 IH_SIZE + ih_item_len(p_s_ih));
7919 @@ -2111,7 +2126,9 @@ int reiserfs_insert_item(struct reiserfs
7920 "reiserquota insert_item(): freeing %u id=%u type=%c",
7921 quota_bytes, inode->i_uid, head2type(p_s_ih));
7925 + DLIMIT_FREE_SPACE(inode, quota_bytes);
7926 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7930 diff -NurpP --minimal linux-2.6.27.3/fs/reiserfs/super.c linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/super.c
7931 --- linux-2.6.27.3/fs/reiserfs/super.c 2008-10-13 14:52:06.000000000 +0200
7932 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/super.c 2008-10-13 14:54:20.000000000 +0200
7933 @@ -898,6 +898,14 @@ static int reiserfs_parse_options(struct
7934 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7935 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7937 +#ifndef CONFIG_TAGGING_NONE
7938 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7939 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7940 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7942 +#ifdef CONFIG_PROPAGATE
7943 + {"tag",.arg_required = 'T',.values = NULL},
7945 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7946 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7947 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7948 @@ -1193,6 +1201,12 @@ static int reiserfs_remount(struct super
7949 handle_quota_files(s, qf_names, &qfmt);
7952 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7953 + !(s->s_flags & MS_TAGGED)) {
7954 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
7960 /* Add options that are safe here */
7961 @@ -1657,6 +1671,10 @@ static int reiserfs_fill_super(struct su
7965 + /* map mount option tagxid */
7966 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7967 + s->s_flags |= MS_TAGGED;
7969 rs = SB_DISK_SUPER_BLOCK(s);
7970 /* Let's do basic sanity check to verify that underlying device is not
7971 smaller than the filesystem. If the check fails then abort and scream,
7972 diff -NurpP --minimal linux-2.6.27.3/fs/reiserfs/xattr.c linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/xattr.c
7973 --- linux-2.6.27.3/fs/reiserfs/xattr.c 2008-10-13 14:52:06.000000000 +0200
7974 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/reiserfs/xattr.c 2008-10-13 14:54:20.000000000 +0200
7976 #include <linux/namei.h>
7977 #include <linux/errno.h>
7978 #include <linux/fs.h>
7979 +#include <linux/mount.h>
7980 #include <linux/file.h>
7981 #include <linux/pagemap.h>
7982 #include <linux/xattr.h>
7983 diff -NurpP --minimal linux-2.6.27.3/fs/stat.c linux-2.6.27.3-vs2.3.0.35.7/fs/stat.c
7984 --- linux-2.6.27.3/fs/stat.c 2008-10-13 14:52:06.000000000 +0200
7985 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/stat.c 2008-10-13 14:54:20.000000000 +0200
7986 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7987 stat->nlink = inode->i_nlink;
7988 stat->uid = inode->i_uid;
7989 stat->gid = inode->i_gid;
7990 + stat->tag = inode->i_tag;
7991 stat->rdev = inode->i_rdev;
7992 stat->atime = inode->i_atime;
7993 stat->mtime = inode->i_mtime;
7994 diff -NurpP --minimal linux-2.6.27.3/fs/super.c linux-2.6.27.3-vs2.3.0.35.7/fs/super.c
7995 --- linux-2.6.27.3/fs/super.c 2008-10-13 14:52:06.000000000 +0200
7996 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/super.c 2008-10-13 14:54:20.000000000 +0200
7998 #include <linux/kobject.h>
7999 #include <linux/mutex.h>
8000 #include <linux/file.h>
8001 +#include <linux/devpts_fs.h>
8002 +#include <linux/proc_fs.h>
8003 +#include <linux/vs_context.h>
8004 #include <asm/uaccess.h>
8005 #include "internal.h"
8007 @@ -887,12 +890,18 @@ struct vfsmount *
8008 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
8010 struct vfsmount *mnt;
8011 + struct super_block *sb;
8012 char *secdata = NULL;
8016 return ERR_PTR(-ENODEV);
8019 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
8020 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
8024 mnt = alloc_vfsmnt(name);
8026 @@ -913,7 +922,14 @@ vfs_kern_mount(struct file_system_type *
8027 goto out_free_secdata;
8028 BUG_ON(!mnt->mnt_sb);
8030 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
8033 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
8034 + (sb->s_magic != PROC_SUPER_MAGIC) &&
8035 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
8038 + error = security_sb_kern_mount(sb, secdata);
8042 diff -NurpP --minimal linux-2.6.27.3/fs/sysfs/mount.c linux-2.6.27.3-vs2.3.0.35.7/fs/sysfs/mount.c
8043 --- linux-2.6.27.3/fs/sysfs/mount.c 2008-07-13 23:51:29.000000000 +0200
8044 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/sysfs/mount.c 2008-10-13 14:54:20.000000000 +0200
8049 -/* Random magic number */
8050 -#define SYSFS_MAGIC 0x62656572
8052 static struct vfsmount *sysfs_mount;
8053 struct super_block * sysfs_sb = NULL;
8054 @@ -46,7 +44,7 @@ static int sysfs_fill_super(struct super
8056 sb->s_blocksize = PAGE_CACHE_SIZE;
8057 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
8058 - sb->s_magic = SYSFS_MAGIC;
8059 + sb->s_magic = SYSFS_SUPER_MAGIC;
8060 sb->s_op = &sysfs_ops;
8061 sb->s_time_gran = 1;
8063 diff -NurpP --minimal linux-2.6.27.3/fs/utimes.c linux-2.6.27.3-vs2.3.0.35.7/fs/utimes.c
8064 --- linux-2.6.27.3/fs/utimes.c 2008-10-13 14:52:06.000000000 +0200
8065 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/utimes.c 2008-10-13 14:54:20.000000000 +0200
8067 #include <linux/stat.h>
8068 #include <linux/utime.h>
8069 #include <linux/syscalls.h>
8070 +#include <linux/mount.h>
8071 +#include <linux/vs_cowbl.h>
8072 #include <asm/uaccess.h>
8073 #include <asm/unistd.h>
8075 diff -NurpP --minimal linux-2.6.27.3/fs/xattr.c linux-2.6.27.3-vs2.3.0.35.7/fs/xattr.c
8076 --- linux-2.6.27.3/fs/xattr.c 2008-10-13 14:52:06.000000000 +0200
8077 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/xattr.c 2008-10-13 14:54:20.000000000 +0200
8079 #include <linux/module.h>
8080 #include <linux/fsnotify.h>
8081 #include <linux/audit.h>
8082 +#include <linux/mount.h>
8083 #include <asm/uaccess.h>
8086 diff -NurpP --minimal linux-2.6.27.3/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/linux-2.6/xfs_linux.h
8087 --- linux-2.6.27.3/fs/xfs/linux-2.6/xfs_linux.h 2008-10-13 14:52:06.000000000 +0200
8088 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/linux-2.6/xfs_linux.h 2008-10-13 15:35:26.000000000 +0200
8091 #define current_cpu() (raw_smp_processor_id())
8092 #define current_pid() (current->pid)
8093 +#define current_fstag(cred,vp) (dx_current_fstag(vp->i_sb))
8094 #define current_test_flags(f) (current->flags & (f))
8095 #define current_set_flags_nested(sp, f) \
8096 (*(sp) = current->flags, current->flags |= (f))
8097 diff -NurpP --minimal linux-2.6.27.3/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/quota/xfs_qm_syscalls.c
8098 --- linux-2.6.27.3/fs/xfs/quota/xfs_qm_syscalls.c 2008-10-13 14:52:06.000000000 +0200
8099 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/quota/xfs_qm_syscalls.c 2008-10-24 03:47:08.000000000 +0200
8100 @@ -426,7 +426,7 @@ xfs_qm_scall_quotaon(
8104 - if (!capable(CAP_SYS_ADMIN))
8105 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8106 return XFS_ERROR(EPERM);
8108 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
8109 diff -NurpP --minimal linux-2.6.27.3/fs/xfs/xfs_clnt.h linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/xfs_clnt.h
8110 --- linux-2.6.27.3/fs/xfs/xfs_clnt.h 2008-10-13 14:52:06.000000000 +0200
8111 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/xfs_clnt.h 2008-10-13 14:54:20.000000000 +0200
8112 @@ -101,5 +101,6 @@ struct xfs_mount_args {
8113 * I/O size in stat(2) */
8114 #define XFSMNT2_FILESTREAMS 0x00000002 /* enable the filestreams
8116 +#define XFSMNT2_TAGGED 0x10000000 /* context tagging */
8118 #endif /* __XFS_CLNT_H__ */
8119 diff -NurpP --minimal linux-2.6.27.3/fs/xfs/xfs_dinode.h linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/xfs_dinode.h
8120 --- linux-2.6.27.3/fs/xfs/xfs_dinode.h 2008-07-13 23:51:29.000000000 +0200
8121 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/xfs_dinode.h 2008-10-24 03:47:08.000000000 +0200
8122 @@ -136,7 +136,9 @@ typedef struct xfs_dinode
8123 #define XFS_DI_NEXT_UNLINKED 0x1000000
8124 #define XFS_DI_U 0x2000000
8125 #define XFS_DI_A 0x4000000
8126 -#define XFS_DI_NUM_BITS 27
8127 +#define XFS_DI_TAG 0x8000000
8128 +#define XFS_DI_VFLAGS 0x10000000
8129 +#define XFS_DI_NUM_BITS 29
8130 #define XFS_DI_ALL_BITS ((1 << XFS_DI_NUM_BITS) - 1)
8131 #define XFS_DI_CORE_BITS (XFS_DI_ALL_BITS & ~(XFS_DI_U|XFS_DI_A))
8133 @@ -223,6 +225,8 @@ typedef enum xfs_dinode_fmt
8134 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8135 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8136 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8137 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8139 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8140 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8141 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8142 @@ -238,6 +242,7 @@ typedef enum xfs_dinode_fmt
8143 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8144 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8145 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8146 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8148 #ifdef CONFIG_XFS_RT
8149 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8150 @@ -250,6 +255,10 @@ typedef enum xfs_dinode_fmt
8151 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8152 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8153 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8154 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8155 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8156 + XFS_DIFLAG_IXUNLINK)
8158 +#define XFS_DIVFLAG_BARRIER 0x01
8159 +#define XFS_DIVFLAG_COW 0x02
8161 #endif /* __XFS_DINODE_H__ */
8162 diff -NurpP --minimal linux-2.6.27.3/fs/xfs/xfs_fs.h linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/xfs_fs.h
8163 --- linux-2.6.27.3/fs/xfs/xfs_fs.h 2008-10-13 14:52:06.000000000 +0200
8164 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/xfs_fs.h 2008-10-13 14:54:20.000000000 +0200
8165 @@ -67,6 +67,9 @@ struct fsxattr {
8166 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8167 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8168 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8169 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8170 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8171 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8172 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8175 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
8176 __s32 bs_extents; /* number of extents */
8177 __u32 bs_gen; /* generation count */
8178 __u16 bs_projid; /* project id */
8179 - unsigned char bs_pad[14]; /* pad space, unused */
8180 + __u16 bs_tag; /* context tagging */
8181 + unsigned char bs_pad[12]; /* pad space, unused */
8182 __u32 bs_dmevmask; /* DMIG event mask */
8183 __u16 bs_dmstate; /* DMIG state info */
8184 __u16 bs_aextents; /* attribute number of extents */
8185 diff -NurpP --minimal linux-2.6.27.3/fs/xfs/xfs_mount.h linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/xfs_mount.h
8186 --- linux-2.6.27.3/fs/xfs/xfs_mount.h 2008-10-13 14:52:06.000000000 +0200
8187 +++ linux-2.6.27.3-vs2.3.0.35.7/fs/xfs/xfs_mount.h 2008-10-13 14:54:20.000000000 +0200
8188 @@ -384,6 +384,7 @@ typedef struct xfs_mount {
8190 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8192 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8195 * Default minimum read and write sizes.
8196 diff -NurpP --minimal linux-2.6.27.3/include/asm-generic/tlb.h linux-2.6.27.3-vs2.3.0.35.7/include/asm-generic/tlb.h
8197 --- linux-2.6.27.3/include/asm-generic/tlb.h 2008-07-13 23:51:29.000000000 +0200
8198 +++ linux-2.6.27.3-vs2.3.0.35.7/include/asm-generic/tlb.h 2008-10-13 14:54:20.000000000 +0200
8200 #define _ASM_GENERIC__TLB_H
8202 #include <linux/swap.h>
8203 +#include <linux/vs_memory.h>
8204 #include <asm/pgalloc.h>
8205 #include <asm/tlbflush.h>
8207 diff -NurpP --minimal linux-2.6.27.3/include/asm-x86/unistd_64.h linux-2.6.27.3-vs2.3.0.35.7/include/asm-x86/unistd_64.h
8208 --- linux-2.6.27.3/include/asm-x86/unistd_64.h 2008-10-13 14:52:08.000000000 +0200
8209 +++ linux-2.6.27.3-vs2.3.0.35.7/include/asm-x86/unistd_64.h 2008-10-13 14:54:20.000000000 +0200
8210 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
8211 #define __NR_utimes 235
8212 __SYSCALL(__NR_utimes, sys_utimes)
8213 #define __NR_vserver 236
8214 -__SYSCALL(__NR_vserver, sys_ni_syscall)
8215 +__SYSCALL(__NR_vserver, sys_vserver)
8216 #define __NR_mbind 237
8217 __SYSCALL(__NR_mbind, sys_mbind)
8218 #define __NR_set_mempolicy 238
8219 diff -NurpP --minimal linux-2.6.27.3/include/linux/capability.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/capability.h
8220 --- linux-2.6.27.3/include/linux/capability.h 2008-10-13 14:52:09.000000000 +0200
8221 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/capability.h 2008-10-13 14:54:20.000000000 +0200
8222 @@ -274,6 +274,7 @@ typedef struct kernel_cap_struct {
8223 arbitrary SCSI commands */
8224 /* Allow setting encryption key on loopback filesystem */
8225 /* Allow setting zone reclaim policy */
8226 +/* Allow the selection of a security context */
8228 #define CAP_SYS_ADMIN 21
8230 @@ -346,7 +347,13 @@ typedef struct kernel_cap_struct {
8232 #define CAP_MAC_ADMIN 33
8234 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8235 +/* Allow context manipulations */
8236 +/* Allow changing context info on files */
8238 +#define CAP_CONTEXT 34
8241 +#define CAP_LAST_CAP CAP_CONTEXT
8243 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8245 diff -NurpP --minimal linux-2.6.27.3/include/linux/devpts_fs.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/devpts_fs.h
8246 --- linux-2.6.27.3/include/linux/devpts_fs.h 2008-07-13 23:51:29.000000000 +0200
8247 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/devpts_fs.h 2008-10-13 14:54:20.000000000 +0200
8248 @@ -34,5 +34,4 @@ static inline void devpts_pty_kill(int n
8253 #endif /* _LINUX_DEVPTS_FS_H */
8254 diff -NurpP --minimal linux-2.6.27.3/include/linux/ext2_fs.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/ext2_fs.h
8255 --- linux-2.6.27.3/include/linux/ext2_fs.h 2008-10-13 14:52:09.000000000 +0200
8256 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/ext2_fs.h 2008-10-13 14:54:20.000000000 +0200
8257 @@ -189,8 +189,12 @@ struct ext2_group_desc
8258 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8259 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8260 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8261 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8262 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8264 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8265 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8267 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8268 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8270 @@ -247,7 +251,7 @@ struct ext2_inode {
8272 __u8 l_i_frag; /* Fragment number */
8273 __u8 l_i_fsize; /* Fragment size */
8275 + __u16 l_i_tag; /* Context Tag */
8276 __le16 l_i_uid_high; /* these 2 fields */
8277 __le16 l_i_gid_high; /* were reserved2[0] */
8278 __u32 l_i_reserved2;
8279 @@ -279,6 +283,7 @@ struct ext2_inode {
8280 #define i_gid_low i_gid
8281 #define i_uid_high osd2.linux2.l_i_uid_high
8282 #define i_gid_high osd2.linux2.l_i_gid_high
8283 +#define i_raw_tag osd2.linux2.l_i_tag
8284 #define i_reserved2 osd2.linux2.l_i_reserved2
8287 @@ -323,6 +328,7 @@ struct ext2_inode {
8288 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8289 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8290 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8291 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8294 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8295 diff -NurpP --minimal linux-2.6.27.3/include/linux/ext3_fs.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/ext3_fs.h
8296 --- linux-2.6.27.3/include/linux/ext3_fs.h 2008-10-13 14:52:09.000000000 +0200
8297 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/ext3_fs.h 2008-10-24 03:34:52.000000000 +0200
8298 @@ -173,10 +173,14 @@ struct ext3_group_desc
8299 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8300 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8301 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8302 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8303 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8305 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8306 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8307 +#define EXT3_BARRIER_FL 0x10000000 /* Barrier for chroot() */
8308 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8310 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8311 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8314 * Inode dynamic state flags
8315 @@ -292,7 +296,7 @@ struct ext3_inode {
8317 __u8 l_i_frag; /* Fragment number */
8318 __u8 l_i_fsize; /* Fragment size */
8320 + __u16 l_i_tag; /* Context Tag */
8321 __le16 l_i_uid_high; /* these 2 fields */
8322 __le16 l_i_gid_high; /* were reserved2[0] */
8323 __u32 l_i_reserved2;
8324 @@ -326,6 +330,7 @@ struct ext3_inode {
8325 #define i_gid_low i_gid
8326 #define i_uid_high osd2.linux2.l_i_uid_high
8327 #define i_gid_high osd2.linux2.l_i_gid_high
8328 +#define i_raw_tag osd2.linux2.l_i_tag
8329 #define i_reserved2 osd2.linux2.l_i_reserved2
8331 #elif defined(__GNU__)
8332 @@ -380,6 +385,7 @@ struct ext3_inode {
8333 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
8334 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
8335 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8336 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8338 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8339 #ifndef _LINUX_EXT2_FS_H
8340 @@ -822,6 +828,7 @@ struct buffer_head * ext3_bread (handle_
8341 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
8342 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
8343 int create, int extend_disksize);
8344 +extern int ext3_sync_flags(struct inode *inode);
8346 extern struct inode *ext3_iget(struct super_block *, unsigned long);
8347 extern int ext3_write_inode (struct inode *, int);
8348 diff -NurpP --minimal linux-2.6.27.3/include/linux/fs.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/fs.h
8349 --- linux-2.6.27.3/include/linux/fs.h 2008-10-13 14:52:09.000000000 +0200
8350 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/fs.h 2008-10-24 03:34:52.000000000 +0200
8351 @@ -130,6 +130,9 @@ extern int dir_notify_enable;
8352 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
8353 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8354 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8355 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
8356 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
8357 +#define MS_NOTAGCHECK (1<<26) /* don't check tags */
8358 #define MS_ACTIVE (1<<30)
8359 #define MS_NOUSER (1<<31)
8361 @@ -137,7 +140,7 @@ extern int dir_notify_enable;
8363 * Superblock flags that can be altered by MS_REMOUNT
8365 -#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK)
8366 +#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOTAGCHECK)
8369 * Old magic mount flag and mask
8370 @@ -154,6 +157,14 @@ extern int dir_notify_enable;
8371 #define S_NOCMTIME 128 /* Do not update file c/mtime */
8372 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8373 #define S_PRIVATE 512 /* Inode is fs-internal */
8374 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
8376 +/* Linux-VServer related Inode flags */
8380 +#define V_BARRIER 4 /* Barrier for chroot() */
8381 +#define V_COW 8 /* Copy on Write */
8384 * Note that nosuid etc flags are inode-specific: setting some file-system
8385 @@ -176,12 +187,15 @@ extern int dir_notify_enable;
8386 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8387 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8388 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8389 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8390 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8391 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8392 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8393 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8395 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8396 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8397 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8398 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8399 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8400 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8402 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8403 @@ -189,6 +203,16 @@ extern int dir_notify_enable;
8404 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8405 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8407 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8409 +#ifdef CONFIG_VSERVER_COWBL
8410 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8411 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8413 +# define IS_COW(inode) (0)
8414 +# define IS_COW_LINK(inode) (0)
8417 /* the read-only stuff doesn't really belong here, but any other place is
8418 probably as bad and I don't want to create yet another include file. */
8420 @@ -262,11 +286,14 @@ extern int dir_notify_enable;
8421 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8422 #define FS_EXTENT_FL 0x00080000 /* Extents */
8423 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8424 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8425 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8427 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8428 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8429 +#define FS_BARRIER_FL 0x10000000 /* Barrier for chroot() */
8430 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8432 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8433 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8435 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8436 #define SYNC_FILE_RANGE_WRITE 2
8437 @@ -337,6 +364,7 @@ typedef void (dio_iodone_t)(struct kiocb
8438 #define ATTR_KILL_PRIV (1 << 14)
8439 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8440 #define ATTR_TIMES_SET (1 << 16)
8441 +#define ATTR_TAG (1 << 17)
8444 * This is the Inode Attributes structure, used for notify_change(). It
8445 @@ -352,6 +380,7 @@ struct iattr {
8451 struct timespec ia_atime;
8452 struct timespec ia_mtime;
8453 @@ -365,6 +394,9 @@ struct iattr {
8454 struct file *ia_file;
8457 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8458 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8461 * Includes for diskquotas.
8463 @@ -626,7 +658,9 @@ struct inode {
8464 unsigned int i_nlink;
8472 #ifdef __NEED_I_SIZE_ORDERED
8473 @@ -674,7 +708,8 @@ struct inode {
8474 unsigned long i_state;
8475 unsigned long dirtied_when; /* jiffies of first dirtying */
8477 - unsigned int i_flags;
8478 + unsigned short i_flags;
8479 + unsigned short i_vflags;
8481 atomic_t i_writecount;
8482 #ifdef CONFIG_SECURITY
8483 @@ -761,12 +796,12 @@ static inline void i_size_write(struct i
8485 static inline unsigned iminor(const struct inode *inode)
8487 - return MINOR(inode->i_rdev);
8488 + return MINOR(inode->i_mdev);
8491 static inline unsigned imajor(const struct inode *inode)
8493 - return MAJOR(inode->i_rdev);
8494 + return MAJOR(inode->i_mdev);
8497 extern struct block_device *I_BDEV(struct inode *inode);
8498 @@ -824,6 +859,7 @@ struct file {
8500 struct fown_struct f_owner;
8501 unsigned int f_uid, f_gid;
8503 struct file_ra_state f_ra;
8506 @@ -958,6 +994,7 @@ struct file_lock {
8507 struct file *fl_file;
8512 struct fasync_struct * fl_fasync; /* for lease break notifications */
8513 unsigned long fl_break_time; /* for nonblocking lease breaks */
8514 @@ -1287,6 +1324,7 @@ struct inode_operations {
8515 void (*truncate_range)(struct inode *, loff_t, loff_t);
8516 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
8518 + int (*sync_flags) (struct inode *);
8522 @@ -1302,6 +1340,7 @@ extern ssize_t vfs_readv(struct file *,
8523 unsigned long, loff_t *);
8524 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8525 unsigned long, loff_t *);
8526 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8528 struct super_operations {
8529 struct inode *(*alloc_inode)(struct super_block *sb);
8530 @@ -1992,6 +2031,7 @@ extern int dcache_dir_open(struct inode
8531 extern int dcache_dir_close(struct inode *, struct file *);
8532 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8533 extern int dcache_readdir(struct file *, void *, filldir_t);
8534 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8535 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8536 extern int simple_statfs(struct dentry *, struct kstatfs *);
8537 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
8538 diff -NurpP --minimal linux-2.6.27.3/include/linux/if_tun.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/if_tun.h
8539 --- linux-2.6.27.3/include/linux/if_tun.h 2008-10-13 14:52:09.000000000 +0200
8540 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/if_tun.h 2008-10-13 14:54:20.000000000 +0200
8542 #define TUNSETOFFLOAD _IOW('T', 208, unsigned int)
8543 #define TUNSETTXFILTER _IOW('T', 209, unsigned int)
8544 #define TUNGETIFF _IOR('T', 210, unsigned int)
8545 +#define TUNSETNID _IOW('T', 215, int)
8547 /* TUNSETIFF ifr flags */
8548 #define IFF_TUN 0x0001
8549 diff -NurpP --minimal linux-2.6.27.3/include/linux/init_task.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/init_task.h
8550 --- linux-2.6.27.3/include/linux/init_task.h 2008-10-13 14:52:09.000000000 +0200
8551 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/init_task.h 2008-10-13 14:54:20.000000000 +0200
8552 @@ -179,6 +179,10 @@ extern struct group_info init_groups;
8554 INIT_TRACE_IRQFLAGS \
8557 + .vx_info = NULL, \
8559 + .nx_info = NULL, \
8563 diff -NurpP --minimal linux-2.6.27.3/include/linux/interrupt.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/interrupt.h
8564 --- linux-2.6.27.3/include/linux/interrupt.h 2008-10-13 14:52:09.000000000 +0200
8565 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/interrupt.h 2008-10-13 14:54:20.000000000 +0200
8567 #include <linux/preempt.h>
8568 #include <linux/cpumask.h>
8569 #include <linux/irqreturn.h>
8570 -#include <linux/hardirq.h>
8571 #include <linux/sched.h>
8572 +#include <linux/hardirq.h>
8573 #include <linux/irqflags.h>
8574 #include <asm/atomic.h>
8575 #include <asm/ptrace.h>
8576 diff -NurpP --minimal linux-2.6.27.3/include/linux/ipc.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/ipc.h
8577 --- linux-2.6.27.3/include/linux/ipc.h 2008-07-13 23:51:29.000000000 +0200
8578 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/ipc.h 2008-10-13 14:54:20.000000000 +0200
8579 @@ -93,6 +93,7 @@ struct kern_ipc_perm
8587 diff -NurpP --minimal linux-2.6.27.3/include/linux/Kbuild linux-2.6.27.3-vs2.3.0.35.7/include/linux/Kbuild
8588 --- linux-2.6.27.3/include/linux/Kbuild 2008-10-13 14:52:09.000000000 +0200
8589 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/Kbuild 2008-10-13 14:54:20.000000000 +0200
8590 @@ -369,3 +369,6 @@ unifdef-y += xattr.h
8593 objhdr-y += version.h
8595 +header-y += vserver/
8597 diff -NurpP --minimal linux-2.6.27.3/include/linux/loop.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/loop.h
8598 --- linux-2.6.27.3/include/linux/loop.h 2008-07-13 23:51:29.000000000 +0200
8599 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/loop.h 2008-10-13 14:54:20.000000000 +0200
8600 @@ -45,6 +45,7 @@ struct loop_device {
8601 struct loop_func_table *lo_encryption;
8603 uid_t lo_key_owner; /* Who set the key */
8605 int (*ioctl)(struct loop_device *, int cmd,
8608 diff -NurpP --minimal linux-2.6.27.3/include/linux/magic.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/magic.h
8609 --- linux-2.6.27.3/include/linux/magic.h 2008-07-13 23:51:29.000000000 +0200
8610 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/magic.h 2008-10-13 14:54:20.000000000 +0200
8613 #define ADFS_SUPER_MAGIC 0xadf5
8614 #define AFFS_SUPER_MAGIC 0xadff
8615 -#define AFS_SUPER_MAGIC 0x5346414F
8616 +#define AFS_SUPER_MAGIC 0x5346414F
8617 #define AUTOFS_SUPER_MAGIC 0x0187
8618 #define CODA_SUPER_MAGIC 0x73757245
8619 #define EFS_SUPER_MAGIC 0x414A53
8621 #define NFS_SUPER_MAGIC 0x6969
8622 #define OPENPROM_SUPER_MAGIC 0x9fa1
8623 #define PROC_SUPER_MAGIC 0x9fa0
8624 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8625 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8627 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8628 diff -NurpP --minimal linux-2.6.27.3/include/linux/major.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/major.h
8629 --- linux-2.6.27.3/include/linux/major.h 2008-10-13 14:52:09.000000000 +0200
8630 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/major.h 2008-10-13 14:54:20.000000000 +0200
8632 #define HD_MAJOR IDE0_MAJOR
8633 #define PTY_SLAVE_MAJOR 3
8635 +#define VROOT_MAJOR 4
8636 #define TTYAUX_MAJOR 5
8639 diff -NurpP --minimal linux-2.6.27.3/include/linux/mm_types.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/mm_types.h
8640 --- linux-2.6.27.3/include/linux/mm_types.h 2008-10-13 14:52:09.000000000 +0200
8641 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/mm_types.h 2008-10-13 14:54:20.000000000 +0200
8642 @@ -216,6 +216,7 @@ struct mm_struct {
8644 /* Architecture-specific MM context */
8645 mm_context_t context;
8646 + struct vx_info *mm_vx_info;
8648 /* Swap token stuff */
8650 diff -NurpP --minimal linux-2.6.27.3/include/linux/mount.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/mount.h
8651 --- linux-2.6.27.3/include/linux/mount.h 2008-10-13 14:52:09.000000000 +0200
8652 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/mount.h 2008-10-24 03:34:52.000000000 +0200
8653 @@ -37,6 +37,9 @@ struct mnt_namespace;
8654 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
8655 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
8657 +#define MNT_TAGID 0x10000
8658 +#define MNT_NOTAG 0x20000
8661 struct list_head mnt_hash;
8662 struct vfsmount *mnt_parent; /* fs we are mounted on */
8663 @@ -71,6 +74,7 @@ struct vfsmount {
8664 * are held, and all mnt_writer[]s on this mount have 0 as their ->count
8666 atomic_t __mnt_writers;
8667 + tag_t mnt_tag; /* tagging used for vfsmount */
8670 static inline struct vfsmount *mntget(struct vfsmount *mnt)
8671 diff -NurpP --minimal linux-2.6.27.3/include/linux/net.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/net.h
8672 --- linux-2.6.27.3/include/linux/net.h 2008-10-13 14:52:09.000000000 +0200
8673 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/net.h 2008-10-13 14:54:20.000000000 +0200
8674 @@ -68,6 +68,7 @@ struct net;
8675 #define SOCK_NOSPACE 2
8676 #define SOCK_PASSCRED 3
8677 #define SOCK_PASSSEC 4
8678 +#define SOCK_USER_SOCKET 5
8680 #ifndef ARCH_HAS_SOCKET_TYPES
8682 diff -NurpP --minimal linux-2.6.27.3/include/linux/nfs_mount.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/nfs_mount.h
8683 --- linux-2.6.27.3/include/linux/nfs_mount.h 2008-07-13 23:51:29.000000000 +0200
8684 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/nfs_mount.h 2008-10-13 14:54:20.000000000 +0200
8685 @@ -63,6 +63,7 @@ struct nfs_mount_data {
8686 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8687 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8688 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8689 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8690 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8691 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8694 diff -NurpP --minimal linux-2.6.27.3/include/linux/nsproxy.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/nsproxy.h
8695 --- linux-2.6.27.3/include/linux/nsproxy.h 2008-10-13 14:52:09.000000000 +0200
8696 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/nsproxy.h 2008-10-13 14:54:20.000000000 +0200
8699 #include <linux/spinlock.h>
8700 #include <linux/sched.h>
8701 +#include <linux/vserver/debug.h>
8703 struct mnt_namespace;
8704 struct uts_namespace;
8705 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
8708 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8709 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8710 void exit_task_namespaces(struct task_struct *tsk);
8711 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8712 void free_nsproxy(struct nsproxy *ns);
8713 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
8714 struct fs_struct *);
8716 -static inline void put_nsproxy(struct nsproxy *ns)
8717 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8719 +static inline void __get_nsproxy(struct nsproxy *ns,
8720 + const char *_file, int _line)
8722 - if (atomic_dec_and_test(&ns->count)) {
8725 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8726 + ns, atomic_read(&ns->count), _file, _line);
8727 + atomic_inc(&ns->count);
8730 -static inline void get_nsproxy(struct nsproxy *ns)
8731 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8733 +static inline void __put_nsproxy(struct nsproxy *ns,
8734 + const char *_file, int _line)
8736 - atomic_inc(&ns->count);
8737 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8738 + ns, atomic_read(&ns->count), _file, _line);
8739 + if (atomic_dec_and_test(&ns->count)) {
8744 #ifdef CONFIG_CGROUP_NS
8745 diff -NurpP --minimal linux-2.6.27.3/include/linux/pid.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/pid.h
8746 --- linux-2.6.27.3/include/linux/pid.h 2008-10-13 14:52:09.000000000 +0200
8747 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/pid.h 2008-10-13 14:54:20.000000000 +0200
8748 @@ -8,7 +8,8 @@ enum pid_type
8758 @@ -142,6 +143,7 @@ static inline pid_t pid_nr(struct pid *p
8761 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8762 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8763 pid_t pid_vnr(struct pid *pid);
8765 #define do_each_pid_task(pid, type, task) \
8766 diff -NurpP --minimal linux-2.6.27.3/include/linux/proc_fs.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/proc_fs.h
8767 --- linux-2.6.27.3/include/linux/proc_fs.h 2008-10-13 14:52:09.000000000 +0200
8768 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/proc_fs.h 2008-10-13 14:54:20.000000000 +0200
8769 @@ -59,6 +59,7 @@ struct proc_dir_entry {
8775 const struct inode_operations *proc_iops;
8777 @@ -274,12 +275,18 @@ static inline void kclist_add(struct kco
8778 extern void kclist_add(struct kcore_list *, void *, size_t);
8785 int (*proc_get_link)(struct inode *, struct path *);
8786 int (*proc_read)(struct task_struct *task, char *page);
8787 int (*proc_show)(struct seq_file *m,
8788 struct pid_namespace *ns, struct pid *pid,
8789 struct task_struct *task);
8790 + int (*proc_vs_read)(char *page);
8791 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8792 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8795 struct ctl_table_header;
8796 @@ -287,6 +294,7 @@ struct ctl_table;
8803 struct proc_dir_entry *pde;
8804 diff -NurpP --minimal linux-2.6.27.3/include/linux/reiserfs_fs.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/reiserfs_fs.h
8805 --- linux-2.6.27.3/include/linux/reiserfs_fs.h 2008-10-13 14:52:09.000000000 +0200
8806 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/reiserfs_fs.h 2008-10-13 14:54:20.000000000 +0200
8807 @@ -837,6 +837,11 @@ struct stat_data_v1 {
8808 #define REISERFS_COMPR_FL FS_COMPR_FL
8809 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
8811 +/* unfortunately reiserfs sdattr is only 16 bit */
8812 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
8813 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
8814 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
8816 /* persistent flags that file inherits from the parent directory */
8817 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
8818 REISERFS_SYNC_FL | \
8819 @@ -846,6 +851,9 @@ struct stat_data_v1 {
8820 REISERFS_COMPR_FL | \
8821 REISERFS_NOTAIL_FL )
8823 +#define REISERFS_FL_USER_VISIBLE 0x80FF
8824 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
8826 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
8829 @@ -1911,6 +1919,7 @@ static inline void reiserfs_update_sd(st
8830 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
8831 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
8832 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
8833 +int reiserfs_sync_flags(struct inode *inode);
8836 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
8837 diff -NurpP --minimal linux-2.6.27.3/include/linux/reiserfs_fs_sb.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/reiserfs_fs_sb.h
8838 --- linux-2.6.27.3/include/linux/reiserfs_fs_sb.h 2008-10-13 14:52:09.000000000 +0200
8839 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/reiserfs_fs_sb.h 2008-10-13 14:54:20.000000000 +0200
8840 @@ -455,6 +455,7 @@ enum reiserfs_mount_options {
8842 REISERFS_BARRIER_NONE,
8843 REISERFS_BARRIER_FLUSH,
8846 /* Actions on error */
8847 REISERFS_ERROR_PANIC,
8848 diff -NurpP --minimal linux-2.6.27.3/include/linux/sched.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/sched.h
8849 --- linux-2.6.27.3/include/linux/sched.h 2008-10-13 14:52:09.000000000 +0200
8850 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/sched.h 2008-10-13 14:54:20.000000000 +0200
8851 @@ -71,7 +71,6 @@ struct sched_param {
8852 #include <linux/fs_struct.h>
8853 #include <linux/compiler.h>
8854 #include <linux/completion.h>
8855 -#include <linux/pid.h>
8856 #include <linux/percpu.h>
8857 #include <linux/topology.h>
8858 #include <linux/proportions.h>
8859 @@ -88,6 +87,7 @@ struct sched_param {
8860 #include <linux/kobject.h>
8861 #include <linux/latencytop.h>
8862 #include <linux/cred.h>
8863 +#include <linux/pid.h>
8865 #include <asm/processor.h>
8867 @@ -357,25 +357,27 @@ extern void arch_unmap_area_topdown(stru
8868 * The mm counters are not protected by its page_table_lock,
8869 * so must be incremented atomically.
8871 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
8872 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
8873 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
8874 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
8875 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
8877 +#define __set_mm_counter(mm, member, value) \
8878 + atomic_long_set(&(mm)->_##member, value)
8879 +#define get_mm_counter(mm, member) \
8880 + ((unsigned long)atomic_long_read(&(mm)->_##member))
8881 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
8883 * The mm counters are protected by its page_table_lock,
8884 * so can be incremented directly.
8886 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
8887 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
8888 #define get_mm_counter(mm, member) ((mm)->_##member)
8889 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
8890 -#define inc_mm_counter(mm, member) (mm)->_##member++
8891 -#define dec_mm_counter(mm, member) (mm)->_##member--
8893 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
8895 +#define set_mm_counter(mm, member, value) \
8896 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
8897 +#define add_mm_counter(mm, member, value) \
8898 + vx_ ## member ## pages_add((mm), (value))
8899 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
8900 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
8902 #define get_mm_rss(mm) \
8903 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
8904 #define update_hiwater_rss(mm) do { \
8905 @@ -1196,6 +1198,14 @@ struct task_struct {
8909 +/* vserver context data */
8910 + struct vx_info *vx_info;
8911 + struct nx_info *nx_info;
8917 /* Thread group tracking */
8920 @@ -1380,6 +1390,11 @@ struct pid_namespace;
8921 * see also pid_nr() etc in include/linux/pid.h
8924 +#include <linux/vserver/base.h>
8925 +#include <linux/vserver/context.h>
8926 +#include <linux/vserver/debug.h>
8927 +#include <linux/vserver/pid.h>
8929 static inline pid_t task_pid_nr(struct task_struct *tsk)
8932 @@ -1389,7 +1404,7 @@ pid_t task_pid_nr_ns(struct task_struct
8934 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8936 - return pid_vnr(task_pid(tsk));
8937 + return vx_map_pid(pid_vnr(task_pid(tsk)));
8941 @@ -1402,7 +1417,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8943 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8945 - return pid_vnr(task_tgid(tsk));
8946 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8950 diff -NurpP --minimal linux-2.6.27.3/include/linux/shmem_fs.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/shmem_fs.h
8951 --- linux-2.6.27.3/include/linux/shmem_fs.h 2008-10-13 14:52:09.000000000 +0200
8952 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/shmem_fs.h 2008-10-13 14:54:20.000000000 +0200
8955 #define SHMEM_NR_DIRECT 16
8957 +#define TMPFS_SUPER_MAGIC 0x01021994
8960 struct shmem_inode_info {
8962 unsigned long flags;
8963 diff -NurpP --minimal linux-2.6.27.3/include/linux/stat.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/stat.h
8964 --- linux-2.6.27.3/include/linux/stat.h 2008-07-13 23:51:29.000000000 +0200
8965 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/stat.h 2008-10-13 14:54:20.000000000 +0200
8966 @@ -66,6 +66,7 @@ struct kstat {
8973 struct timespec atime;
8974 diff -NurpP --minimal linux-2.6.27.3/include/linux/sunrpc/auth.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/sunrpc/auth.h
8975 --- linux-2.6.27.3/include/linux/sunrpc/auth.h 2008-07-13 23:51:29.000000000 +0200
8976 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/sunrpc/auth.h 2008-10-13 14:54:20.000000000 +0200
8982 struct group_info *group_info;
8983 unsigned char machine_cred : 1;
8985 diff -NurpP --minimal linux-2.6.27.3/include/linux/sunrpc/clnt.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/sunrpc/clnt.h
8986 --- linux-2.6.27.3/include/linux/sunrpc/clnt.h 2008-10-13 14:52:09.000000000 +0200
8987 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/sunrpc/clnt.h 2008-10-13 14:54:20.000000000 +0200
8988 @@ -43,7 +43,8 @@ struct rpc_clnt {
8989 unsigned int cl_softrtry : 1,/* soft timeouts */
8990 cl_discrtry : 1,/* disconnect before retry */
8991 cl_autobind : 1,/* use getport() */
8992 - cl_chatty : 1;/* be verbose */
8993 + cl_chatty : 1,/* be verbose */
8994 + cl_tag : 1;/* context tagging */
8996 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8997 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8998 diff -NurpP --minimal linux-2.6.27.3/include/linux/syscalls.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/syscalls.h
8999 --- linux-2.6.27.3/include/linux/syscalls.h 2008-10-13 14:52:09.000000000 +0200
9000 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/syscalls.h 2008-10-13 14:54:20.000000000 +0200
9001 @@ -295,6 +295,8 @@ asmlinkage long sys_symlink(const char _
9002 asmlinkage long sys_unlink(const char __user *pathname);
9003 asmlinkage long sys_rename(const char __user *oldname,
9004 const char __user *newname);
9005 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9007 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9008 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9010 diff -NurpP --minimal linux-2.6.27.3/include/linux/sysctl.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/sysctl.h
9011 --- linux-2.6.27.3/include/linux/sysctl.h 2008-10-13 14:52:09.000000000 +0200
9012 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/sysctl.h 2008-10-13 14:54:20.000000000 +0200
9013 @@ -70,6 +70,7 @@ enum
9014 CTL_ABI=9, /* Binary emulation */
9015 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9016 CTL_ARLAN=254, /* arlan wireless driver */
9017 + CTL_VSERVER=4242, /* Linux-VServer debug */
9018 CTL_S390DBF=5677, /* s390 debug */
9019 CTL_SUNRPC=7249, /* sunrpc debug */
9020 CTL_PM=9899, /* frv power management */
9021 @@ -104,6 +105,7 @@ enum
9023 KERN_PANIC=15, /* int: panic timeout */
9024 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9025 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9027 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9028 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9029 diff -NurpP --minimal linux-2.6.27.3/include/linux/sysfs.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/sysfs.h
9030 --- linux-2.6.27.3/include/linux/sysfs.h 2008-10-13 14:52:09.000000000 +0200
9031 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/sysfs.h 2008-10-13 14:54:20.000000000 +0200
9033 #include <linux/list.h>
9034 #include <asm/atomic.h>
9036 +#define SYSFS_SUPER_MAGIC 0x62656572
9041 diff -NurpP --minimal linux-2.6.27.3/include/linux/time.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/time.h
9042 --- linux-2.6.27.3/include/linux/time.h 2008-07-13 23:51:29.000000000 +0200
9043 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/time.h 2008-10-13 14:54:20.000000000 +0200
9044 @@ -179,6 +179,9 @@ static __always_inline void timespec_add
9045 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9049 +#include <linux/vs_time.h>
9051 #endif /* __KERNEL__ */
9053 #define NFDBITS __NFDBITS
9054 diff -NurpP --minimal linux-2.6.27.3/include/linux/types.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/types.h
9055 --- linux-2.6.27.3/include/linux/types.h 2008-07-13 23:51:29.000000000 +0200
9056 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/types.h 2008-10-13 14:54:20.000000000 +0200
9057 @@ -36,6 +36,9 @@ typedef __kernel_uid32_t uid_t;
9058 typedef __kernel_gid32_t gid_t;
9059 typedef __kernel_uid16_t uid16_t;
9060 typedef __kernel_gid16_t gid16_t;
9061 +typedef unsigned int xid_t;
9062 +typedef unsigned int nid_t;
9063 +typedef unsigned int tag_t;
9065 typedef unsigned long uintptr_t;
9067 diff -NurpP --minimal linux-2.6.27.3/include/linux/vroot.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vroot.h
9068 --- linux-2.6.27.3/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9069 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vroot.h 2008-10-13 14:54:20.000000000 +0200
9073 + * include/linux/vroot.h
9075 + * written by Herbert Pötzl, 9/11/2002
9076 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9078 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9079 + * Redistribution of this file is permitted under the
9080 + * GNU General Public License.
9083 +#ifndef _LINUX_VROOT_H
9084 +#define _LINUX_VROOT_H
9089 +/* Possible states of device */
9095 +struct vroot_device {
9099 + struct semaphore vr_ctl_mutex;
9100 + struct block_device *vr_device;
9105 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9107 +extern int register_vroot_grb(vroot_grb_func *);
9108 +extern int unregister_vroot_grb(vroot_grb_func *);
9110 +#endif /* __KERNEL__ */
9112 +#define MAX_VROOT_DEFAULT 8
9115 + * IOCTL commands --- we will commandeer 0x56 ('V')
9118 +#define VROOT_SET_DEV 0x5600
9119 +#define VROOT_CLR_DEV 0x5601
9121 +#endif /* _LINUX_VROOT_H */
9122 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_base.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_base.h
9123 --- linux-2.6.27.3/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9124 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_base.h 2008-10-13 14:54:20.000000000 +0200
9129 +#include "vserver/base.h"
9130 +#include "vserver/check.h"
9131 +#include "vserver/debug.h"
9134 +#warning duplicate inclusion
9136 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_context.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_context.h
9137 --- linux-2.6.27.3/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9138 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_context.h 2008-10-13 14:54:20.000000000 +0200
9140 +#ifndef _VS_CONTEXT_H
9141 +#define _VS_CONTEXT_H
9143 +#include "vserver/base.h"
9144 +#include "vserver/check.h"
9145 +#include "vserver/context.h"
9146 +#include "vserver/history.h"
9147 +#include "vserver/debug.h"
9149 +#include <linux/sched.h>
9152 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9154 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9155 + const char *_file, int _line, void *_here)
9160 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9161 + vxi, vxi ? vxi->vx_id : 0,
9162 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9164 + __vxh_get_vx_info(vxi, _here);
9166 + atomic_inc(&vxi->vx_usecnt);
9171 +extern void free_vx_info(struct vx_info *);
9173 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9175 +static inline void __put_vx_info(struct vx_info *vxi,
9176 + const char *_file, int _line, void *_here)
9181 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9182 + vxi, vxi ? vxi->vx_id : 0,
9183 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9185 + __vxh_put_vx_info(vxi, _here);
9187 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9188 + free_vx_info(vxi);
9192 +#define init_vx_info(p, i) \
9193 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9195 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9196 + const char *_file, int _line, void *_here)
9199 + vxlprintk(VXD_CBIT(xid, 3),
9200 + "init_vx_info(%p[#%d.%d])",
9201 + vxi, vxi ? vxi->vx_id : 0,
9202 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9204 + __vxh_init_vx_info(vxi, vxp, _here);
9206 + atomic_inc(&vxi->vx_usecnt);
9212 +#define set_vx_info(p, i) \
9213 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9215 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9216 + const char *_file, int _line, void *_here)
9218 + struct vx_info *vxo;
9223 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9224 + vxi, vxi ? vxi->vx_id : 0,
9225 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9227 + __vxh_set_vx_info(vxi, vxp, _here);
9229 + atomic_inc(&vxi->vx_usecnt);
9230 + vxo = xchg(vxp, vxi);
9235 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9237 +static inline void __clr_vx_info(struct vx_info **vxp,
9238 + const char *_file, int _line, void *_here)
9240 + struct vx_info *vxo;
9242 + vxo = xchg(vxp, NULL);
9246 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9247 + vxo, vxo ? vxo->vx_id : 0,
9248 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9250 + __vxh_clr_vx_info(vxo, vxp, _here);
9252 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9253 + free_vx_info(vxo);
9257 +#define claim_vx_info(v, p) \
9258 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9260 +static inline void __claim_vx_info(struct vx_info *vxi,
9261 + struct task_struct *task,
9262 + const char *_file, int _line, void *_here)
9264 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9265 + vxi, vxi ? vxi->vx_id : 0,
9266 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9267 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9268 + task, _file, _line);
9269 + __vxh_claim_vx_info(vxi, task, _here);
9271 + atomic_inc(&vxi->vx_tasks);
9275 +extern void unhash_vx_info(struct vx_info *);
9277 +#define release_vx_info(v, p) \
9278 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9280 +static inline void __release_vx_info(struct vx_info *vxi,
9281 + struct task_struct *task,
9282 + const char *_file, int _line, void *_here)
9284 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9285 + vxi, vxi ? vxi->vx_id : 0,
9286 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9287 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9288 + task, _file, _line);
9289 + __vxh_release_vx_info(vxi, task, _here);
9293 + if (atomic_dec_and_test(&vxi->vx_tasks))
9294 + unhash_vx_info(vxi);
9298 +#define task_get_vx_info(p) \
9299 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9301 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9302 + const char *_file, int _line, void *_here)
9304 + struct vx_info *vxi;
9307 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9309 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9315 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9317 + if (waitqueue_active(&vxi->vx_wait))
9318 + wake_up_interruptible(&vxi->vx_wait);
9322 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9324 +static inline void __enter_vx_info(struct vx_info *vxi,
9325 + struct vx_info_save *vxis, const char *_file, int _line)
9327 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9328 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9329 + current->xid, current->vx_info, _file, _line);
9330 + vxis->vxi = xchg(¤t->vx_info, vxi);
9331 + vxis->xid = current->xid;
9332 + current->xid = vxi ? vxi->vx_id : 0;
9335 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9337 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9338 + const char *_file, int _line)
9340 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9341 + vxis, vxis->xid, vxis->vxi, current,
9342 + current->xid, current->vx_info, _file, _line);
9343 + (void)xchg(¤t->vx_info, vxis->vxi);
9344 + current->xid = vxis->xid;
9348 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9350 + vxis->vxi = xchg(¤t->vx_info, NULL);
9351 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9354 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9356 + (void)xchg(¤t->xid, vxis->xid);
9357 + (void)xchg(¤t->vx_info, vxis->vxi);
9360 +extern void exit_vx_info(struct task_struct *, int);
9361 +extern void exit_vx_info_early(struct task_struct *, int);
9365 +#warning duplicate inclusion
9367 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_cowbl.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_cowbl.h
9368 --- linux-2.6.27.3/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9369 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_cowbl.h 2008-10-13 14:54:20.000000000 +0200
9371 +#ifndef _VS_COWBL_H
9372 +#define _VS_COWBL_H
9374 +#include <linux/fs.h>
9375 +#include <linux/dcache.h>
9376 +#include <linux/namei.h>
9378 +extern struct dentry *cow_break_link(const char *pathname);
9380 +static inline int cow_check_and_break(struct path *path)
9382 + struct inode *inode = path->dentry->d_inode;
9385 + /* do we need this check? */
9386 + if (IS_RDONLY(inode))
9389 + if (IS_COW(inode)) {
9390 + if (IS_COW_LINK(inode)) {
9391 + struct dentry *new_dentry, *old_dentry = path->dentry;
9394 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9398 + pp = d_path(path, buf, PATH_MAX);
9399 + new_dentry = cow_break_link(pp);
9401 + if (!IS_ERR(new_dentry)) {
9402 + path->dentry = new_dentry;
9405 + error = PTR_ERR(new_dentry);
9407 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9408 + inode->i_ctime = CURRENT_TIME;
9409 + mark_inode_dirty(inode);
9416 +#warning duplicate inclusion
9418 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_cvirt.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_cvirt.h
9419 --- linux-2.6.27.3/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9420 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_cvirt.h 2008-10-13 14:54:20.000000000 +0200
9422 +#ifndef _VS_CVIRT_H
9423 +#define _VS_CVIRT_H
9425 +#include "vserver/cvirt.h"
9426 +#include "vserver/context.h"
9427 +#include "vserver/base.h"
9428 +#include "vserver/check.h"
9429 +#include "vserver/debug.h"
9432 +static inline void vx_activate_task(struct task_struct *p)
9434 + struct vx_info *vxi;
9436 + if ((vxi = p->vx_info)) {
9437 + vx_update_load(vxi);
9438 + atomic_inc(&vxi->cvirt.nr_running);
9442 +static inline void vx_deactivate_task(struct task_struct *p)
9444 + struct vx_info *vxi;
9446 + if ((vxi = p->vx_info)) {
9447 + vx_update_load(vxi);
9448 + atomic_dec(&vxi->cvirt.nr_running);
9452 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9454 + struct vx_info *vxi;
9456 + if ((vxi = p->vx_info))
9457 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9460 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9462 + struct vx_info *vxi;
9464 + if ((vxi = p->vx_info))
9465 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9470 +#warning duplicate inclusion
9472 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_device.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_device.h
9473 --- linux-2.6.27.3/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9474 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_device.h 2008-10-13 14:54:20.000000000 +0200
9476 +#ifndef _VS_DEVICE_H
9477 +#define _VS_DEVICE_H
9479 +#include "vserver/base.h"
9480 +#include "vserver/device.h"
9481 +#include "vserver/debug.h"
9484 +#ifdef CONFIG_VSERVER_DEVICE
9486 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9488 +#define vs_device_perm(v, d, m, p) \
9489 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9494 +int vs_map_device(struct vx_info *vxi,
9495 + dev_t device, dev_t *target, umode_t mode)
9502 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9507 +#define vs_map_chrdev(d, t, p) \
9508 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9509 +#define vs_map_blkdev(d, t, p) \
9510 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9512 +#define vs_chrdev_perm(d, p) \
9513 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9514 +#define vs_blkdev_perm(d, p) \
9515 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9519 +#warning duplicate inclusion
9521 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_dlimit.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_dlimit.h
9522 --- linux-2.6.27.3/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9523 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_dlimit.h 2008-10-13 14:54:20.000000000 +0200
9525 +#ifndef _VS_DLIMIT_H
9526 +#define _VS_DLIMIT_H
9528 +#include <linux/fs.h>
9530 +#include "vserver/dlimit.h"
9531 +#include "vserver/base.h"
9532 +#include "vserver/debug.h"
9535 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9537 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9538 + const char *_file, int _line)
9542 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9543 + dli, dli ? dli->dl_tag : 0,
9544 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9546 + atomic_inc(&dli->dl_usecnt);
9551 +#define free_dl_info(i) \
9552 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9554 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9556 +static inline void __put_dl_info(struct dl_info *dli,
9557 + const char *_file, int _line)
9561 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9562 + dli, dli ? dli->dl_tag : 0,
9563 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9565 + if (atomic_dec_and_test(&dli->dl_usecnt))
9566 + free_dl_info(dli);
9570 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9572 +static inline int __dl_alloc_space(struct super_block *sb,
9573 + tag_t tag, dlsize_t nr, const char *file, int line)
9575 + struct dl_info *dli = NULL;
9580 + dli = locate_dl_info(sb, tag);
9584 + spin_lock(&dli->dl_lock);
9585 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9587 + dli->dl_space_used += nr;
9588 + spin_unlock(&dli->dl_lock);
9591 + vxlprintk(VXD_CBIT(dlim, 1),
9592 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9593 + sb, tag, __dlimit_char(dli), (long long)nr,
9598 +static inline void __dl_free_space(struct super_block *sb,
9599 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9601 + struct dl_info *dli = NULL;
9605 + dli = locate_dl_info(sb, tag);
9609 + spin_lock(&dli->dl_lock);
9610 + if (dli->dl_space_used > nr)
9611 + dli->dl_space_used -= nr;
9613 + dli->dl_space_used = 0;
9614 + spin_unlock(&dli->dl_lock);
9617 + vxlprintk(VXD_CBIT(dlim, 1),
9618 + "FREE (%p,#%d)%c %lld bytes",
9619 + sb, tag, __dlimit_char(dli), (long long)nr,
9623 +static inline int __dl_alloc_inode(struct super_block *sb,
9624 + tag_t tag, const char *_file, int _line)
9626 + struct dl_info *dli;
9629 + dli = locate_dl_info(sb, tag);
9633 + spin_lock(&dli->dl_lock);
9634 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
9636 + dli->dl_inodes_used++;
9637 + spin_unlock(&dli->dl_lock);
9640 + vxlprintk(VXD_CBIT(dlim, 0),
9641 + "ALLOC (%p,#%d)%c inode (%d)",
9642 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9646 +static inline void __dl_free_inode(struct super_block *sb,
9647 + tag_t tag, const char *_file, int _line)
9649 + struct dl_info *dli;
9651 + dli = locate_dl_info(sb, tag);
9655 + spin_lock(&dli->dl_lock);
9656 + if (dli->dl_inodes_used > 1)
9657 + dli->dl_inodes_used--;
9659 + dli->dl_inodes_used = 0;
9660 + spin_unlock(&dli->dl_lock);
9663 + vxlprintk(VXD_CBIT(dlim, 0),
9664 + "FREE (%p,#%d)%c inode",
9665 + sb, tag, __dlimit_char(dli), _file, _line);
9668 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9669 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9670 + const char *_file, int _line)
9672 + struct dl_info *dli;
9673 + uint64_t broot, bfree;
9675 + dli = locate_dl_info(sb, tag);
9679 + spin_lock(&dli->dl_lock);
9680 + broot = (dli->dl_space_total -
9681 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9682 + >> sb->s_blocksize_bits;
9683 + bfree = (dli->dl_space_total - dli->dl_space_used)
9684 + >> sb->s_blocksize_bits;
9685 + spin_unlock(&dli->dl_lock);
9687 + vxlprintk(VXD_CBIT(dlim, 2),
9688 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9689 + (long long)bfree, (long long)broot,
9690 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9692 + if (free_blocks) {
9693 + if (*free_blocks > bfree)
9694 + *free_blocks = bfree;
9696 + if (root_blocks) {
9697 + if (*root_blocks > broot)
9698 + *root_blocks = broot;
9703 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
9704 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9705 + __FILE__, __LINE__ )
9707 +#define DLIMIT_FREE_SPACE(in, bytes) \
9708 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9709 + __FILE__, __LINE__ )
9711 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
9712 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
9713 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
9714 + __FILE__, __LINE__ )
9716 +#define DLIMIT_FREE_BLOCK(in, nr) \
9717 + __dl_free_space((in)->i_sb, (in)->i_tag, \
9718 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
9719 + __FILE__, __LINE__ )
9722 +#define DLIMIT_ALLOC_INODE(in) \
9723 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9725 +#define DLIMIT_FREE_INODE(in) \
9726 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9729 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
9730 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9734 +#warning duplicate inclusion
9736 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/base.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/base.h
9737 --- linux-2.6.27.3/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
9738 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/base.h 2008-10-13 14:54:20.000000000 +0200
9744 +/* context state changes */
9756 +#define vx_task_xid(t) ((t)->xid)
9758 +#define vx_current_xid() vx_task_xid(current)
9760 +#define current_vx_info() (current->vx_info)
9763 +#define nx_task_nid(t) ((t)->nid)
9765 +#define nx_current_nid() nx_task_nid(current)
9767 +#define current_nx_info() (current->nx_info)
9770 +/* generic flag merging */
9772 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
9774 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
9776 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
9778 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
9781 +/* context flags */
9783 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
9785 +#define vx_current_flags() __vx_flags(current->vx_info)
9787 +#define vx_info_flags(v, m, f) \
9788 + vs_check_flags(__vx_flags(v), m, f)
9790 +#define task_vx_flags(t, m, f) \
9791 + ((t) && vx_info_flags((t)->vx_info, m, f))
9793 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
9798 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
9800 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
9802 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
9804 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
9808 +/* network flags */
9810 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
9812 +#define nx_current_flags() __nx_flags(current->nx_info)
9814 +#define nx_info_flags(n, m, f) \
9815 + vs_check_flags(__nx_flags(n), m, f)
9817 +#define task_nx_flags(t, m, f) \
9818 + ((t) && nx_info_flags((t)->nx_info, m, f))
9820 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
9825 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
9827 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
9829 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
9831 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
9834 +/* context mask capabilities */
9836 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
9838 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
9840 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
9843 +/* context bcap mask */
9845 +#define __vx_bcaps(v) ((v)->vx_bcaps)
9847 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
9850 +/* mask given bcaps */
9852 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
9854 +#define vx_mbcaps(c) vx_info_mbcaps(current->vx_info, c)
9857 +/* masked cap_bset */
9859 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
9861 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
9864 +#define vx_info_mbcap(v, b) \
9865 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
9866 + vx_info_bcaps(v, b) : (b))
9868 +#define task_vx_mbcap(t, b) \
9869 + vx_info_mbcap((t)->vx_info, (t)->b)
9871 +#define vx_mbcap(b) task_vx_mbcap(current, b)
9874 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
9876 +#define vx_capable(b, c) (capable(b) || \
9877 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
9879 +#define nx_capable(b, c) (capable(b) || \
9880 + (cap_raised(current->cap_effective, b) && nx_ncaps(c)))
9882 +#define vx_current_initpid(n) \
9883 + (current->vx_info && \
9884 + (current->vx_info->vx_initpid == (n)))
9887 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
9889 +#define vx_info_state(v, m) (__vx_state(v) & (m))
9892 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
9894 +#define nx_info_state(n, m) (__nx_state(n) & (m))
9897 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/cacct_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cacct_cmd.h
9898 --- linux-2.6.27.3/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
9899 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cacct_cmd.h 2008-10-13 14:54:20.000000000 +0200
9901 +#ifndef _VX_CACCT_CMD_H
9902 +#define _VX_CACCT_CMD_H
9905 +/* virtual host info name commands */
9907 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
9909 +struct vcmd_sock_stat_v0 {
9911 + uint32_t count[3];
9912 + uint64_t total[3];
9918 +#include <linux/compiler.h>
9920 +extern int vc_sock_stat(struct vx_info *, void __user *);
9922 +#endif /* __KERNEL__ */
9923 +#endif /* _VX_CACCT_CMD_H */
9924 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/cacct_def.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cacct_def.h
9925 --- linux-2.6.27.3/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
9926 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cacct_def.h 2008-10-13 14:54:20.000000000 +0200
9928 +#ifndef _VX_CACCT_DEF_H
9929 +#define _VX_CACCT_DEF_H
9931 +#include <asm/atomic.h>
9932 +#include <linux/vserver/cacct.h>
9935 +struct _vx_sock_acc {
9936 + atomic_long_t count;
9937 + atomic_long_t total;
9940 +/* context sub struct */
9943 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
9945 + atomic_t page[6][8];
9948 +#ifdef CONFIG_VSERVER_DEBUG
9950 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
9954 + printk("\t_vx_cacct:");
9955 + for (i = 0; i < 6; i++) {
9956 + struct _vx_sock_acc *ptr = cacct->sock[i];
9958 + printk("\t [%d] =", i);
9959 + for (j = 0; j < 3; j++) {
9960 + printk(" [%d] = %8lu, %8lu", j,
9961 + atomic_long_read(&ptr[j].count),
9962 + atomic_long_read(&ptr[j].total));
9970 +#endif /* _VX_CACCT_DEF_H */
9971 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/cacct.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cacct.h
9972 --- linux-2.6.27.3/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
9973 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cacct.h 2008-10-13 14:54:20.000000000 +0200
9975 +#ifndef _VX_CACCT_H
9976 +#define _VX_CACCT_H
9979 +enum sock_acc_field {
9980 + VXA_SOCK_UNSPEC = 0,
9986 + VXA_SOCK_SIZE /* array size */
9989 +#endif /* _VX_CACCT_H */
9990 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/cacct_int.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cacct_int.h
9991 --- linux-2.6.27.3/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
9992 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cacct_int.h 2008-10-13 14:54:20.000000000 +0200
9994 +#ifndef _VX_CACCT_INT_H
9995 +#define _VX_CACCT_INT_H
10001 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10003 + return atomic_long_read(&cacct->sock[type][pos].count);
10008 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10010 + return atomic_long_read(&cacct->sock[type][pos].total);
10013 +#endif /* __KERNEL__ */
10014 +#endif /* _VX_CACCT_INT_H */
10015 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/check.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/check.h
10016 --- linux-2.6.27.3/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10017 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/check.h 2008-10-13 14:54:20.000000000 +0200
10019 +#ifndef _VS_CHECK_H
10020 +#define _VS_CHECK_H
10023 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10025 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10026 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10028 +#define MIN_D_CONTEXT 65536
10031 +/* check conditions */
10033 +#define VS_ADMIN 0x0001
10034 +#define VS_WATCH 0x0002
10035 +#define VS_HIDE 0x0004
10036 +#define VS_HOSTID 0x0008
10038 +#define VS_IDENT 0x0010
10039 +#define VS_EQUIV 0x0020
10040 +#define VS_PARENT 0x0040
10041 +#define VS_CHILD 0x0080
10043 +#define VS_ARG_MASK 0x00F0
10045 +#define VS_DYNAMIC 0x0100
10046 +#define VS_STATIC 0x0200
10048 +#define VS_ATR_MASK 0x0F00
10050 +#ifdef CONFIG_VSERVER_PRIVACY
10051 +#define VS_ADMIN_P (0)
10052 +#define VS_WATCH_P (0)
10054 +#define VS_ADMIN_P VS_ADMIN
10055 +#define VS_WATCH_P VS_WATCH
10058 +#define VS_HARDIRQ 0x1000
10059 +#define VS_SOFTIRQ 0x2000
10060 +#define VS_IRQ 0x4000
10062 +#define VS_IRQ_MASK 0xF000
10064 +#include <linux/hardirq.h>
10067 + * check current context for ADMIN/WATCH and
10068 + * optionally against supplied argument
10070 +static inline int __vs_check(int cid, int id, unsigned int mode)
10072 + if (mode & VS_ARG_MASK) {
10073 + if ((mode & VS_IDENT) && (id == cid))
10076 + if (mode & VS_ATR_MASK) {
10077 + if ((mode & VS_DYNAMIC) &&
10078 + (id >= MIN_D_CONTEXT) &&
10079 + (id <= MAX_S_CONTEXT))
10081 + if ((mode & VS_STATIC) &&
10082 + (id > 1) && (id < MIN_D_CONTEXT))
10085 + if (mode & VS_IRQ_MASK) {
10086 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10088 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10090 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10093 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10094 + ((mode & VS_WATCH) && (cid == 1)) ||
10095 + ((mode & VS_HOSTID) && (id == 0)));
10098 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10100 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10103 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10105 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10108 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/context_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/context_cmd.h
10109 --- linux-2.6.27.3/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10110 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/context_cmd.h 2008-10-13 14:54:20.000000000 +0200
10112 +#ifndef _VX_CONTEXT_CMD_H
10113 +#define _VX_CONTEXT_CMD_H
10116 +/* vinfo commands */
10118 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10121 +extern int vc_task_xid(uint32_t);
10123 +#endif /* __KERNEL__ */
10125 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10127 +struct vcmd_vx_info_v0 {
10129 + uint32_t initpid;
10130 + /* more to come */
10134 +extern int vc_vx_info(struct vx_info *, void __user *);
10136 +#endif /* __KERNEL__ */
10138 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10140 +struct vcmd_ctx_stat_v0 {
10143 + /* more to come */
10147 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10149 +#endif /* __KERNEL__ */
10151 +/* context commands */
10153 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10154 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10156 +struct vcmd_ctx_create {
10157 + uint64_t flagword;
10160 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10161 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10163 +struct vcmd_ctx_migrate {
10164 + uint64_t flagword;
10168 +extern int vc_ctx_create(uint32_t, void __user *);
10169 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10171 +#endif /* __KERNEL__ */
10174 +/* flag commands */
10176 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10177 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10179 +struct vcmd_ctx_flags_v0 {
10180 + uint64_t flagword;
10185 +extern int vc_get_cflags(struct vx_info *, void __user *);
10186 +extern int vc_set_cflags(struct vx_info *, void __user *);
10188 +#endif /* __KERNEL__ */
10191 +/* context caps commands */
10193 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10194 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10196 +struct vcmd_ctx_caps_v1 {
10202 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10203 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10205 +#endif /* __KERNEL__ */
10208 +/* bcaps commands */
10210 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10211 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10213 +struct vcmd_bcaps {
10219 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10220 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10222 +#endif /* __KERNEL__ */
10227 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10228 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10230 +struct vcmd_badness_v0 {
10235 +extern int vc_get_badness(struct vx_info *, void __user *);
10236 +extern int vc_set_badness(struct vx_info *, void __user *);
10238 +#endif /* __KERNEL__ */
10239 +#endif /* _VX_CONTEXT_CMD_H */
10240 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/context.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/context.h
10241 --- linux-2.6.27.3/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10242 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/context.h 2008-10-13 14:54:20.000000000 +0200
10244 +#ifndef _VX_CONTEXT_H
10245 +#define _VX_CONTEXT_H
10247 +#include <linux/types.h>
10248 +#include <linux/capability.h>
10251 +/* context flags */
10253 +#define VXF_INFO_SCHED 0x00000002
10254 +#define VXF_INFO_NPROC 0x00000004
10255 +#define VXF_INFO_PRIVATE 0x00000008
10257 +#define VXF_INFO_INIT 0x00000010
10258 +#define VXF_INFO_HIDE 0x00000020
10259 +#define VXF_INFO_ULIMIT 0x00000040
10260 +#define VXF_INFO_NSPACE 0x00000080
10262 +#define VXF_SCHED_HARD 0x00000100
10263 +#define VXF_SCHED_PRIO 0x00000200
10264 +#define VXF_SCHED_PAUSE 0x00000400
10266 +#define VXF_VIRT_MEM 0x00010000
10267 +#define VXF_VIRT_UPTIME 0x00020000
10268 +#define VXF_VIRT_CPU 0x00040000
10269 +#define VXF_VIRT_LOAD 0x00080000
10270 +#define VXF_VIRT_TIME 0x00100000
10272 +#define VXF_HIDE_MOUNT 0x01000000
10273 +/* was VXF_HIDE_NETIF 0x02000000 */
10274 +#define VXF_HIDE_VINFO 0x04000000
10276 +#define VXF_STATE_SETUP (1ULL << 32)
10277 +#define VXF_STATE_INIT (1ULL << 33)
10278 +#define VXF_STATE_ADMIN (1ULL << 34)
10280 +#define VXF_SC_HELPER (1ULL << 36)
10281 +#define VXF_REBOOT_KILL (1ULL << 37)
10282 +#define VXF_PERSISTENT (1ULL << 38)
10284 +#define VXF_FORK_RSS (1ULL << 48)
10285 +#define VXF_PROLIFIC (1ULL << 49)
10287 +#define VXF_IGNEG_NICE (1ULL << 52)
10289 +#define VXF_ONE_TIME (0x0007ULL << 32)
10291 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10294 +/* context migration */
10296 +#define VXM_SET_INIT 0x00000001
10297 +#define VXM_SET_REAPER 0x00000002
10299 +/* context caps */
10301 +#define VXC_CAP_MASK 0x00000000
10303 +#define VXC_SET_UTSNAME 0x00000001
10304 +#define VXC_SET_RLIMIT 0x00000002
10306 +/* was VXC_RAW_ICMP 0x00000100 */
10307 +#define VXC_SYSLOG 0x00001000
10309 +#define VXC_SECURE_MOUNT 0x00010000
10310 +#define VXC_SECURE_REMOUNT 0x00020000
10311 +#define VXC_BINARY_MOUNT 0x00040000
10313 +#define VXC_QUOTA_CTL 0x00100000
10314 +#define VXC_ADMIN_MAPPER 0x00200000
10315 +#define VXC_ADMIN_CLOOP 0x00400000
10317 +#define VXC_KTHREAD 0x01000000
10322 +#include <linux/list.h>
10323 +#include <linux/spinlock.h>
10324 +#include <linux/rcupdate.h>
10326 +#include "limit_def.h"
10327 +#include "sched_def.h"
10328 +#include "cvirt_def.h"
10329 +#include "cacct_def.h"
10330 +#include "device_def.h"
10332 +struct _vx_info_pc {
10333 + struct _vx_sched_pc sched_pc;
10334 + struct _vx_cvirt_pc cvirt_pc;
10338 + struct hlist_node vx_hlist; /* linked list of contexts */
10339 + xid_t vx_id; /* context id */
10340 + atomic_t vx_usecnt; /* usage count */
10341 + atomic_t vx_tasks; /* tasks count */
10342 + struct vx_info *vx_parent; /* parent context */
10343 + int vx_state; /* context state */
10345 + unsigned long vx_nsmask; /* assignment mask */
10346 + struct nsproxy *vx_nsproxy; /* private namespace */
10347 + struct fs_struct *vx_fs; /* private namespace fs */
10349 + uint64_t vx_flags; /* context flags */
10350 + uint64_t vx_ccaps; /* context caps (vserver) */
10351 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10352 + // kernel_cap_t vx_cap_bset; /* the guest's bset */
10354 + struct task_struct *vx_reaper; /* guest reaper process */
10355 + pid_t vx_initpid; /* PID of guest init */
10356 + int64_t vx_badness_bias; /* OOM points bias */
10358 + struct _vx_limit limit; /* vserver limits */
10359 + struct _vx_sched sched; /* vserver scheduler */
10360 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10361 + struct _vx_cacct cacct; /* context accounting */
10363 + struct _vx_device dmap; /* default device map targets */
10365 +#ifndef CONFIG_SMP
10366 + struct _vx_info_pc info_pc; /* per cpu data */
10368 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10371 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10372 + int reboot_cmd; /* last sys_reboot() cmd */
10373 + int exit_code; /* last process exit code */
10375 + char vx_name[65]; /* vserver name */
10378 +#ifndef CONFIG_SMP
10379 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10380 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10382 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10383 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10386 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10389 +struct vx_info_save {
10390 + struct vx_info *vxi;
10395 +/* status flags */
10397 +#define VXS_HASHED 0x0001
10398 +#define VXS_PAUSED 0x0010
10399 +#define VXS_SHUTDOWN 0x0100
10400 +#define VXS_HELPER 0x1000
10401 +#define VXS_RELEASED 0x8000
10404 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10405 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10407 +extern struct vx_info *lookup_vx_info(int);
10408 +extern struct vx_info *lookup_or_create_vx_info(int);
10410 +extern int get_xid_list(int, unsigned int *, int);
10411 +extern int xid_is_hashed(xid_t);
10413 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10415 +extern long vs_state_change(struct vx_info *, unsigned int);
10418 +#endif /* __KERNEL__ */
10419 +#endif /* _VX_CONTEXT_H */
10420 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/cvirt_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cvirt_cmd.h
10421 --- linux-2.6.27.3/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
10422 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cvirt_cmd.h 2008-10-13 14:54:20.000000000 +0200
10424 +#ifndef _VX_CVIRT_CMD_H
10425 +#define _VX_CVIRT_CMD_H
10428 +/* virtual host info name commands */
10430 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
10431 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
10433 +struct vcmd_vhi_name_v0 {
10439 +enum vhi_name_field {
10440 + VHIN_CONTEXT = 0,
10452 +#include <linux/compiler.h>
10454 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10455 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10457 +#endif /* __KERNEL__ */
10459 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
10461 +struct vcmd_virt_stat_v0 {
10464 + uint32_t nr_threads;
10465 + uint32_t nr_running;
10466 + uint32_t nr_uninterruptible;
10467 + uint32_t nr_onhold;
10468 + uint32_t nr_forks;
10469 + uint32_t load[3];
10473 +extern int vc_virt_stat(struct vx_info *, void __user *);
10475 +#endif /* __KERNEL__ */
10476 +#endif /* _VX_CVIRT_CMD_H */
10477 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/cvirt_def.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cvirt_def.h
10478 --- linux-2.6.27.3/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
10479 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cvirt_def.h 2008-10-13 14:54:20.000000000 +0200
10481 +#ifndef _VX_CVIRT_DEF_H
10482 +#define _VX_CVIRT_DEF_H
10484 +#include <linux/jiffies.h>
10485 +#include <linux/spinlock.h>
10486 +#include <linux/wait.h>
10487 +#include <linux/time.h>
10488 +#include <asm/atomic.h>
10491 +struct _vx_usage_stat {
10495 + uint64_t softirq;
10501 +struct _vx_syslog {
10502 + wait_queue_head_t log_wait;
10503 + spinlock_t logbuf_lock; /* lock for the log buffer */
10505 + unsigned long log_start; /* next char to be read by syslog() */
10506 + unsigned long con_start; /* next char to be sent to consoles */
10507 + unsigned long log_end; /* most-recently-written-char + 1 */
10508 + unsigned long logged_chars; /* #chars since last read+clear operation */
10510 + char log_buf[1024];
10514 +/* context sub struct */
10516 +struct _vx_cvirt {
10517 + atomic_t nr_threads; /* number of current threads */
10518 + atomic_t nr_running; /* number of running threads */
10519 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10521 + atomic_t nr_onhold; /* processes on hold */
10522 + uint32_t onhold_last; /* jiffies when put on hold */
10524 + struct timeval bias_tv; /* time offset to the host */
10525 + struct timespec bias_idle;
10526 + struct timespec bias_uptime; /* context creation point */
10527 + uint64_t bias_clock; /* offset in clock_t */
10529 + spinlock_t load_lock; /* lock for the load averages */
10530 + atomic_t load_updates; /* nr of load updates done so far */
10531 + uint32_t load_last; /* last time load was calculated */
10532 + uint32_t load[3]; /* load averages 1,5,15 */
10534 + atomic_t total_forks; /* number of forks so far */
10536 + struct _vx_syslog syslog;
10539 +struct _vx_cvirt_pc {
10540 + struct _vx_usage_stat cpustat;
10544 +#ifdef CONFIG_VSERVER_DEBUG
10546 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10548 + printk("\t_vx_cvirt:\n");
10549 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10550 + atomic_read(&cvirt->nr_threads),
10551 + atomic_read(&cvirt->nr_running),
10552 + atomic_read(&cvirt->nr_uninterruptible),
10553 + atomic_read(&cvirt->nr_onhold));
10554 + /* add rest here */
10555 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
10560 +#endif /* _VX_CVIRT_DEF_H */
10561 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/cvirt.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cvirt.h
10562 --- linux-2.6.27.3/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
10563 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/cvirt.h 2008-10-13 14:54:20.000000000 +0200
10565 +#ifndef _VX_CVIRT_H
10566 +#define _VX_CVIRT_H
10573 +void vx_vsi_uptime(struct timespec *, struct timespec *);
10578 +void vx_update_load(struct vx_info *);
10581 +int vx_do_syslog(int, char __user *, int);
10583 +#endif /* __KERNEL__ */
10584 +#endif /* _VX_CVIRT_H */
10585 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/debug_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/debug_cmd.h
10586 --- linux-2.6.27.3/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
10587 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/debug_cmd.h 2008-10-13 14:54:20.000000000 +0200
10589 +#ifndef _VX_DEBUG_CMD_H
10590 +#define _VX_DEBUG_CMD_H
10593 +/* debug commands */
10595 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
10597 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
10598 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
10600 +struct vcmd_read_history_v0 {
10603 + char __user *data;
10606 +struct vcmd_read_monitor_v0 {
10609 + char __user *data;
10615 +#ifdef CONFIG_COMPAT
10617 +#include <asm/compat.h>
10619 +struct vcmd_read_history_v0_x32 {
10622 + compat_uptr_t data_ptr;
10625 +struct vcmd_read_monitor_v0_x32 {
10628 + compat_uptr_t data_ptr;
10631 +#endif /* CONFIG_COMPAT */
10633 +extern int vc_dump_history(uint32_t);
10635 +extern int vc_read_history(uint32_t, void __user *);
10636 +extern int vc_read_monitor(uint32_t, void __user *);
10638 +#ifdef CONFIG_COMPAT
10640 +extern int vc_read_history_x32(uint32_t, void __user *);
10641 +extern int vc_read_monitor_x32(uint32_t, void __user *);
10643 +#endif /* CONFIG_COMPAT */
10645 +#endif /* __KERNEL__ */
10646 +#endif /* _VX_DEBUG_CMD_H */
10647 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/debug.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/debug.h
10648 --- linux-2.6.27.3/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
10649 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/debug.h 2008-10-13 14:54:20.000000000 +0200
10651 +#ifndef _VX_DEBUG_H
10652 +#define _VX_DEBUG_H
10655 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
10656 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
10657 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
10659 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
10660 + imajor((d)->bd_inode), iminor((d)->bd_inode)
10661 +#define VXF_DEV "%p[%lu,%d:%d]"
10664 +#define vxd_path(p) \
10665 + ({ static char _buffer[PATH_MAX]; \
10666 + d_path(p, _buffer, sizeof(_buffer)); })
10668 +#define vxd_cond_path(n) \
10669 + ((n) ? vxd_path(&(n)->path) : "<null>" )
10672 +#ifdef CONFIG_VSERVER_DEBUG
10674 +extern unsigned int vx_debug_switch;
10675 +extern unsigned int vx_debug_xid;
10676 +extern unsigned int vx_debug_nid;
10677 +extern unsigned int vx_debug_tag;
10678 +extern unsigned int vx_debug_net;
10679 +extern unsigned int vx_debug_limit;
10680 +extern unsigned int vx_debug_cres;
10681 +extern unsigned int vx_debug_dlim;
10682 +extern unsigned int vx_debug_quota;
10683 +extern unsigned int vx_debug_cvirt;
10684 +extern unsigned int vx_debug_space;
10685 +extern unsigned int vx_debug_misc;
10688 +#define VX_LOGLEVEL "vxD: "
10689 +#define VX_PROC_FMT "%p: "
10690 +#define VX_PROCESS current
10692 +#define vxdprintk(c, f, x...) \
10695 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
10696 + VX_PROCESS , ##x); \
10699 +#define vxlprintk(c, f, x...) \
10702 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
10705 +#define vxfprintk(c, f, x...) \
10708 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
10714 +void dump_vx_info(struct vx_info *, int);
10715 +void dump_vx_info_inactive(int);
10717 +#else /* CONFIG_VSERVER_DEBUG */
10719 +#define vx_debug_switch 0
10720 +#define vx_debug_xid 0
10721 +#define vx_debug_nid 0
10722 +#define vx_debug_tag 0
10723 +#define vx_debug_net 0
10724 +#define vx_debug_limit 0
10725 +#define vx_debug_cres 0
10726 +#define vx_debug_dlim 0
10727 +#define vx_debug_cvirt 0
10729 +#define vxdprintk(x...) do { } while (0)
10730 +#define vxlprintk(x...) do { } while (0)
10731 +#define vxfprintk(x...) do { } while (0)
10733 +#endif /* CONFIG_VSERVER_DEBUG */
10736 +#ifdef CONFIG_VSERVER_WARN
10738 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
10739 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
10740 +#define VX_WARN_XID "[xid #%u] "
10741 +#define VX_WARN_NID "[nid #%u] "
10742 +#define VX_WARN_TAG "[tag #%u] "
10744 +#define vxwprintk(c, f, x...) \
10747 + printk(VX_WARNLEVEL f "\n", ##x); \
10750 +#else /* CONFIG_VSERVER_WARN */
10752 +#define vxwprintk(x...) do { } while (0)
10754 +#endif /* CONFIG_VSERVER_WARN */
10756 +#define vxwprintk_task(c, f, x...) \
10757 + vxwprintk(c, VX_WARN_TASK f, \
10758 + current->comm, current->pid, \
10759 + current->xid, current->nid, current->tag, ##x)
10760 +#define vxwprintk_xid(c, f, x...) \
10761 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
10762 +#define vxwprintk_nid(c, f, x...) \
10763 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
10764 +#define vxwprintk_tag(c, f, x...) \
10765 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
10767 +#ifdef CONFIG_VSERVER_DEBUG
10768 +#define vxd_assert_lock(l) assert_spin_locked(l)
10769 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
10770 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
10772 +#define vxd_assert_lock(l) do { } while (0)
10773 +#define vxd_assert(c, f, x...) do { } while (0)
10777 +#endif /* _VX_DEBUG_H */
10778 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/device_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/device_cmd.h
10779 --- linux-2.6.27.3/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
10780 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/device_cmd.h 2008-10-13 14:54:20.000000000 +0200
10782 +#ifndef _VX_DEVICE_CMD_H
10783 +#define _VX_DEVICE_CMD_H
10786 +/* device vserver commands */
10788 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
10789 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
10791 +struct vcmd_set_mapping_v0 {
10792 + const char __user *device;
10793 + const char __user *target;
10800 +#ifdef CONFIG_COMPAT
10802 +#include <asm/compat.h>
10804 +struct vcmd_set_mapping_v0_x32 {
10805 + compat_uptr_t device_ptr;
10806 + compat_uptr_t target_ptr;
10810 +#endif /* CONFIG_COMPAT */
10812 +#include <linux/compiler.h>
10814 +extern int vc_set_mapping(struct vx_info *, void __user *);
10815 +extern int vc_unset_mapping(struct vx_info *, void __user *);
10817 +#ifdef CONFIG_COMPAT
10819 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
10820 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
10822 +#endif /* CONFIG_COMPAT */
10824 +#endif /* __KERNEL__ */
10825 +#endif /* _VX_DEVICE_CMD_H */
10826 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/device_def.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/device_def.h
10827 --- linux-2.6.27.3/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
10828 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/device_def.h 2008-10-13 14:54:20.000000000 +0200
10830 +#ifndef _VX_DEVICE_DEF_H
10831 +#define _VX_DEVICE_DEF_H
10833 +#include <linux/types.h>
10835 +struct vx_dmap_target {
10840 +struct _vx_device {
10841 +#ifdef CONFIG_VSERVER_DEVICE
10842 + struct vx_dmap_target targets[2];
10846 +#endif /* _VX_DEVICE_DEF_H */
10847 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/device.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/device.h
10848 --- linux-2.6.27.3/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
10849 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/device.h 2008-10-13 14:54:20.000000000 +0200
10851 +#ifndef _VX_DEVICE_H
10852 +#define _VX_DEVICE_H
10855 +#define DATTR_CREATE 0x00000001
10856 +#define DATTR_OPEN 0x00000002
10858 +#define DATTR_REMAP 0x00000010
10860 +#define DATTR_MASK 0x00000013
10863 +#else /* _VX_DEVICE_H */
10864 +#warning duplicate inclusion
10865 +#endif /* _VX_DEVICE_H */
10866 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/dlimit_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/dlimit_cmd.h
10867 --- linux-2.6.27.3/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
10868 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/dlimit_cmd.h 2008-10-13 14:54:20.000000000 +0200
10870 +#ifndef _VX_DLIMIT_CMD_H
10871 +#define _VX_DLIMIT_CMD_H
10874 +/* dlimit vserver commands */
10876 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
10877 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
10879 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
10880 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
10882 +struct vcmd_ctx_dlimit_base_v0 {
10883 + const char __user *name;
10887 +struct vcmd_ctx_dlimit_v0 {
10888 + const char __user *name;
10889 + uint32_t space_used; /* used space in kbytes */
10890 + uint32_t space_total; /* maximum space in kbytes */
10891 + uint32_t inodes_used; /* used inodes */
10892 + uint32_t inodes_total; /* maximum inodes */
10893 + uint32_t reserved; /* reserved for root in % */
10897 +#define CDLIM_UNSET ((uint32_t)0UL)
10898 +#define CDLIM_INFINITY ((uint32_t)~0UL)
10899 +#define CDLIM_KEEP ((uint32_t)~1UL)
10903 +#ifdef CONFIG_COMPAT
10905 +#include <asm/compat.h>
10907 +struct vcmd_ctx_dlimit_base_v0_x32 {
10908 + compat_uptr_t name_ptr;
10912 +struct vcmd_ctx_dlimit_v0_x32 {
10913 + compat_uptr_t name_ptr;
10914 + uint32_t space_used; /* used space in kbytes */
10915 + uint32_t space_total; /* maximum space in kbytes */
10916 + uint32_t inodes_used; /* used inodes */
10917 + uint32_t inodes_total; /* maximum inodes */
10918 + uint32_t reserved; /* reserved for root in % */
10922 +#endif /* CONFIG_COMPAT */
10924 +#include <linux/compiler.h>
10926 +extern int vc_add_dlimit(uint32_t, void __user *);
10927 +extern int vc_rem_dlimit(uint32_t, void __user *);
10929 +extern int vc_set_dlimit(uint32_t, void __user *);
10930 +extern int vc_get_dlimit(uint32_t, void __user *);
10932 +#ifdef CONFIG_COMPAT
10934 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
10935 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
10937 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
10938 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
10940 +#endif /* CONFIG_COMPAT */
10942 +#endif /* __KERNEL__ */
10943 +#endif /* _VX_DLIMIT_CMD_H */
10944 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/dlimit.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/dlimit.h
10945 --- linux-2.6.27.3/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
10946 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/dlimit.h 2008-10-13 14:54:20.000000000 +0200
10948 +#ifndef _VX_DLIMIT_H
10949 +#define _VX_DLIMIT_H
10951 +#include "switch.h"
10956 +/* keep in sync with CDLIM_INFINITY */
10958 +#define DLIM_INFINITY (~0ULL)
10960 +#include <linux/spinlock.h>
10961 +#include <linux/rcupdate.h>
10963 +struct super_block;
10966 + struct hlist_node dl_hlist; /* linked list of contexts */
10967 + struct rcu_head dl_rcu; /* the rcu head */
10968 + tag_t dl_tag; /* context tag */
10969 + atomic_t dl_usecnt; /* usage count */
10970 + atomic_t dl_refcnt; /* reference count */
10972 + struct super_block *dl_sb; /* associated superblock */
10974 + spinlock_t dl_lock; /* protect the values */
10976 + unsigned long long dl_space_used; /* used space in bytes */
10977 + unsigned long long dl_space_total; /* maximum space in bytes */
10978 + unsigned long dl_inodes_used; /* used inodes */
10979 + unsigned long dl_inodes_total; /* maximum inodes */
10981 + unsigned int dl_nrlmult; /* non root limit mult */
10986 +extern void rcu_free_dl_info(struct rcu_head *);
10987 +extern void unhash_dl_info(struct dl_info *);
10989 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
10994 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
10996 +typedef uint64_t dlsize_t;
10998 +#endif /* __KERNEL__ */
10999 +#else /* _VX_DLIMIT_H */
11000 +#warning duplicate inclusion
11001 +#endif /* _VX_DLIMIT_H */
11002 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/global.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/global.h
11003 --- linux-2.6.27.3/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11004 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/global.h 2008-10-13 14:54:20.000000000 +0200
11006 +#ifndef _VX_GLOBAL_H
11007 +#define _VX_GLOBAL_H
11010 +extern atomic_t vx_global_ctotal;
11011 +extern atomic_t vx_global_cactive;
11013 +extern atomic_t nx_global_ctotal;
11014 +extern atomic_t nx_global_cactive;
11016 +extern atomic_t vs_global_nsproxy;
11017 +extern atomic_t vs_global_fs;
11018 +extern atomic_t vs_global_mnt_ns;
11019 +extern atomic_t vs_global_uts_ns;
11020 +extern atomic_t vs_global_ipc_ns;
11021 +extern atomic_t vs_global_user_ns;
11022 +extern atomic_t vs_global_pid_ns;
11025 +#endif /* _VX_GLOBAL_H */
11026 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/history.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/history.h
11027 --- linux-2.6.27.3/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11028 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/history.h 2008-10-13 14:54:20.000000000 +0200
11030 +#ifndef _VX_HISTORY_H
11031 +#define _VX_HISTORY_H
11036 + VXH_THROW_OOPS = 1,
11040 + VXH_INIT_VX_INFO,
11043 + VXH_CLAIM_VX_INFO,
11044 + VXH_RELEASE_VX_INFO,
11045 + VXH_ALLOC_VX_INFO,
11046 + VXH_DEALLOC_VX_INFO,
11047 + VXH_HASH_VX_INFO,
11048 + VXH_UNHASH_VX_INFO,
11050 + VXH_LOOKUP_VX_INFO,
11051 + VXH_CREATE_VX_INFO,
11054 +struct _vxhe_vxi {
11055 + struct vx_info *ptr;
11061 +struct _vxhe_set_clr {
11065 +struct _vxhe_loc_lookup {
11069 +struct _vx_hist_entry {
11071 + unsigned short seq;
11072 + unsigned short type;
11073 + struct _vxhe_vxi vxi;
11075 + struct _vxhe_set_clr sc;
11076 + struct _vxhe_loc_lookup ll;
11080 +#ifdef CONFIG_VSERVER_HISTORY
11082 +extern unsigned volatile int vxh_active;
11084 +struct _vx_hist_entry *vxh_advance(void *loc);
11088 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11090 + entry->vxi.ptr = vxi;
11092 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11093 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11094 + entry->vxi.xid = vxi->vx_id;
11099 +#define __HERE__ current_text_addr()
11101 +#define __VXH_BODY(__type, __data, __here) \
11102 + struct _vx_hist_entry *entry; \
11104 + preempt_disable(); \
11105 + entry = vxh_advance(__here); \
11107 + entry->type = __type; \
11108 + preempt_enable();
11111 + /* pass vxi only */
11113 +#define __VXH_SMPL \
11114 + __vxh_copy_vxi(entry, vxi)
11117 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11119 + __VXH_BODY(__type, __VXH_SMPL, __here)
11122 + /* pass vxi and data (void *) */
11124 +#define __VXH_DATA \
11125 + __vxh_copy_vxi(entry, vxi); \
11126 + entry->sc.data = data
11129 +void __vxh_data(struct vx_info *vxi, void *data,
11130 + int __type, void *__here)
11132 + __VXH_BODY(__type, __VXH_DATA, __here)
11135 + /* pass vxi and arg (long) */
11137 +#define __VXH_LONG \
11138 + __vxh_copy_vxi(entry, vxi); \
11139 + entry->ll.arg = arg
11142 +void __vxh_long(struct vx_info *vxi, long arg,
11143 + int __type, void *__here)
11145 + __VXH_BODY(__type, __VXH_LONG, __here)
11150 +void __vxh_throw_oops(void *__here)
11152 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11153 + /* prevent further acquisition */
11158 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11160 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11161 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11163 +#define __vxh_init_vx_info(v, d, h) \
11164 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11165 +#define __vxh_set_vx_info(v, d, h) \
11166 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11167 +#define __vxh_clr_vx_info(v, d, h) \
11168 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11170 +#define __vxh_claim_vx_info(v, d, h) \
11171 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11172 +#define __vxh_release_vx_info(v, d, h) \
11173 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11175 +#define vxh_alloc_vx_info(v) \
11176 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11177 +#define vxh_dealloc_vx_info(v) \
11178 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11180 +#define vxh_hash_vx_info(v) \
11181 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11182 +#define vxh_unhash_vx_info(v) \
11183 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11185 +#define vxh_loc_vx_info(v, l) \
11186 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11187 +#define vxh_lookup_vx_info(v, l) \
11188 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11189 +#define vxh_create_vx_info(v, l) \
11190 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11192 +extern void vxh_dump_history(void);
11195 +#else /* CONFIG_VSERVER_HISTORY */
11197 +#define __HERE__ 0
11199 +#define vxh_throw_oops() do { } while (0)
11201 +#define __vxh_get_vx_info(v, h) do { } while (0)
11202 +#define __vxh_put_vx_info(v, h) do { } while (0)
11204 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11205 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11206 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11208 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11209 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11211 +#define vxh_alloc_vx_info(v) do { } while (0)
11212 +#define vxh_dealloc_vx_info(v) do { } while (0)
11214 +#define vxh_hash_vx_info(v) do { } while (0)
11215 +#define vxh_unhash_vx_info(v) do { } while (0)
11217 +#define vxh_loc_vx_info(v, l) do { } while (0)
11218 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11219 +#define vxh_create_vx_info(v, l) do { } while (0)
11221 +#define vxh_dump_history() do { } while (0)
11224 +#endif /* CONFIG_VSERVER_HISTORY */
11226 +#endif /* _VX_HISTORY_H */
11227 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/inode_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/inode_cmd.h
11228 --- linux-2.6.27.3/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11229 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/inode_cmd.h 2008-10-13 14:54:20.000000000 +0200
11231 +#ifndef _VX_INODE_CMD_H
11232 +#define _VX_INODE_CMD_H
11235 +/* inode vserver commands */
11237 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11238 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11240 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11241 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11243 +struct vcmd_ctx_iattr_v1 {
11244 + const char __user *name;
11250 +struct vcmd_ctx_fiattr_v0 {
11260 +#ifdef CONFIG_COMPAT
11262 +#include <asm/compat.h>
11264 +struct vcmd_ctx_iattr_v1_x32 {
11265 + compat_uptr_t name_ptr;
11271 +#endif /* CONFIG_COMPAT */
11273 +#include <linux/compiler.h>
11275 +extern int vc_get_iattr(void __user *);
11276 +extern int vc_set_iattr(void __user *);
11278 +extern int vc_fget_iattr(uint32_t, void __user *);
11279 +extern int vc_fset_iattr(uint32_t, void __user *);
11281 +#ifdef CONFIG_COMPAT
11283 +extern int vc_get_iattr_x32(void __user *);
11284 +extern int vc_set_iattr_x32(void __user *);
11286 +#endif /* CONFIG_COMPAT */
11288 +#endif /* __KERNEL__ */
11289 +#endif /* _VX_INODE_CMD_H */
11290 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/inode.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/inode.h
11291 --- linux-2.6.27.3/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11292 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/inode.h 2008-10-13 14:54:20.000000000 +0200
11294 +#ifndef _VX_INODE_H
11295 +#define _VX_INODE_H
11298 +#define IATTR_TAG 0x01000000
11300 +#define IATTR_ADMIN 0x00000001
11301 +#define IATTR_WATCH 0x00000002
11302 +#define IATTR_HIDE 0x00000004
11303 +#define IATTR_FLAGS 0x00000007
11305 +#define IATTR_BARRIER 0x00010000
11306 +#define IATTR_IXUNLINK 0x00020000
11307 +#define IATTR_IMMUTABLE 0x00040000
11312 +#ifdef CONFIG_VSERVER_PROC_SECURE
11313 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11314 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11316 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11317 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11320 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11322 +#endif /* __KERNEL__ */
11324 +/* inode ioctls */
11326 +#define FIOC_GETXFLG _IOR('x', 5, long)
11327 +#define FIOC_SETXFLG _IOW('x', 6, long)
11329 +#else /* _VX_INODE_H */
11330 +#warning duplicate inclusion
11331 +#endif /* _VX_INODE_H */
11332 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/Kbuild linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/Kbuild
11333 --- linux-2.6.27.3/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11334 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/Kbuild 2008-10-13 14:54:20.000000000 +0200
11337 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11338 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11339 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11340 + debug_cmd.h device_cmd.h
11342 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11344 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/limit_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/limit_cmd.h
11345 --- linux-2.6.27.3/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11346 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/limit_cmd.h 2008-10-13 14:54:20.000000000 +0200
11348 +#ifndef _VX_LIMIT_CMD_H
11349 +#define _VX_LIMIT_CMD_H
11352 +/* rlimit vserver commands */
11354 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
11355 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
11356 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
11357 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
11359 +struct vcmd_ctx_rlimit_v0 {
11361 + uint64_t minimum;
11362 + uint64_t softlimit;
11363 + uint64_t maximum;
11366 +struct vcmd_ctx_rlimit_mask_v0 {
11367 + uint32_t minimum;
11368 + uint32_t softlimit;
11369 + uint32_t maximum;
11372 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
11374 +struct vcmd_rlimit_stat_v0 {
11378 + uint64_t minimum;
11379 + uint64_t maximum;
11382 +#define CRLIM_UNSET (0ULL)
11383 +#define CRLIM_INFINITY (~0ULL)
11384 +#define CRLIM_KEEP (~1ULL)
11388 +#ifdef CONFIG_IA32_EMULATION
11390 +struct vcmd_ctx_rlimit_v0_x32 {
11392 + uint64_t minimum;
11393 + uint64_t softlimit;
11394 + uint64_t maximum;
11395 +} __attribute__ ((aligned (4)));
11397 +#endif /* CONFIG_IA32_EMULATION */
11399 +#include <linux/compiler.h>
11401 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11402 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11403 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11404 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11406 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11408 +#ifdef CONFIG_IA32_EMULATION
11410 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11411 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11413 +#endif /* CONFIG_IA32_EMULATION */
11415 +#endif /* __KERNEL__ */
11416 +#endif /* _VX_LIMIT_CMD_H */
11417 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/limit_def.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/limit_def.h
11418 --- linux-2.6.27.3/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
11419 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/limit_def.h 2008-10-13 14:54:20.000000000 +0200
11421 +#ifndef _VX_LIMIT_DEF_H
11422 +#define _VX_LIMIT_DEF_H
11424 +#include <asm/atomic.h>
11425 +#include <asm/resource.h>
11427 +#include "limit.h"
11430 +struct _vx_res_limit {
11431 + rlim_t soft; /* Context soft limit */
11432 + rlim_t hard; /* Context hard limit */
11434 + rlim_atomic_t rcur; /* Current value */
11435 + rlim_t rmin; /* Context minimum */
11436 + rlim_t rmax; /* Context maximum */
11438 + atomic_t lhit; /* Limit hits */
11441 +/* context sub struct */
11443 +struct _vx_limit {
11444 + struct _vx_res_limit res[NUM_LIMITS];
11447 +#ifdef CONFIG_VSERVER_DEBUG
11449 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11453 + printk("\t_vx_limit:");
11454 + for (i = 0; i < NUM_LIMITS; i++) {
11455 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11456 + i, (unsigned long)__rlim_get(limit, i),
11457 + (unsigned long)__rlim_rmin(limit, i),
11458 + (unsigned long)__rlim_rmax(limit, i),
11459 + (long)__rlim_soft(limit, i),
11460 + (long)__rlim_hard(limit, i),
11461 + atomic_read(&__rlim_lhit(limit, i)));
11467 +#endif /* _VX_LIMIT_DEF_H */
11468 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/limit.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/limit.h
11469 --- linux-2.6.27.3/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
11470 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/limit.h 2008-10-13 14:54:20.000000000 +0200
11472 +#ifndef _VX_LIMIT_H
11473 +#define _VX_LIMIT_H
11475 +#define VLIMIT_NSOCK 16
11476 +#define VLIMIT_OPENFD 17
11477 +#define VLIMIT_ANON 18
11478 +#define VLIMIT_SHMEM 19
11479 +#define VLIMIT_SEMARY 20
11480 +#define VLIMIT_NSEMS 21
11481 +#define VLIMIT_DENTRY 22
11482 +#define VLIMIT_MAPPED 23
11487 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11489 +/* keep in sync with CRLIM_INFINITY */
11491 +#define VLIM_INFINITY (~0ULL)
11493 +#include <asm/atomic.h>
11494 +#include <asm/resource.h>
11496 +#ifndef RLIM_INFINITY
11497 +#warning RLIM_INFINITY is undefined
11500 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11502 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11503 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11505 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11506 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11507 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11509 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11510 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11512 +typedef atomic_long_t rlim_atomic_t;
11513 +typedef unsigned long rlim_t;
11515 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11516 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11517 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11518 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11519 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
11520 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
11523 +#if (RLIM_INFINITY == VLIM_INFINITY)
11524 +#define VX_VLIM(r) ((long long)(long)(r))
11525 +#define VX_RLIM(v) ((rlim_t)(v))
11527 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
11528 + ? VLIM_INFINITY : (long long)(r))
11529 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
11530 + ? RLIM_INFINITY : (rlim_t)(v))
11535 +void vx_vsi_meminfo(struct sysinfo *);
11536 +void vx_vsi_swapinfo(struct sysinfo *);
11538 +#define NUM_LIMITS 24
11540 +#endif /* __KERNEL__ */
11541 +#endif /* _VX_LIMIT_H */
11542 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/limit_int.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/limit_int.h
11543 --- linux-2.6.27.3/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
11544 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/limit_int.h 2008-10-13 14:54:20.000000000 +0200
11546 +#ifndef _VX_LIMIT_INT_H
11547 +#define _VX_LIMIT_INT_H
11549 +#include "context.h"
11553 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
11554 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
11556 +extern const char *vlimit_name[NUM_LIMITS];
11558 +static inline void __vx_acc_cres(struct vx_info *vxi,
11559 + int res, int dir, void *_data, char *_file, int _line)
11561 + if (VXD_RCRES_COND(res))
11562 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
11563 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11564 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11565 + (dir > 0) ? "++" : "--", _data, _file, _line);
11570 + __rlim_inc(&vxi->limit, res);
11572 + __rlim_dec(&vxi->limit, res);
11575 +static inline void __vx_add_cres(struct vx_info *vxi,
11576 + int res, int amount, void *_data, char *_file, int _line)
11578 + if (VXD_RCRES_COND(res))
11579 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
11580 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11581 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11582 + amount, _data, _file, _line);
11587 + __rlim_add(&vxi->limit, res, amount);
11591 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
11593 + int cond = (value > __rlim_rmax(limit, res));
11596 + __rlim_rmax(limit, res) = value;
11601 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
11603 + int cond = (value < __rlim_rmin(limit, res));
11606 + __rlim_rmin(limit, res) = value;
11611 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
11613 + if (!__vx_cres_adjust_max(limit, res, value))
11614 + __vx_cres_adjust_min(limit, res, value);
11619 + +1 ... no limit hit
11620 + -1 ... over soft limit
11621 + 0 ... over hard limit */
11623 +static inline int __vx_cres_avail(struct vx_info *vxi,
11624 + int res, int num, char *_file, int _line)
11626 + struct _vx_limit *limit;
11629 + if (VXD_RLIMIT_COND(res))
11630 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
11631 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11632 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
11633 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
11634 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11635 + num, _file, _line);
11639 + limit = &vxi->limit;
11640 + value = __rlim_get(limit, res);
11642 + if (!__vx_cres_adjust_max(limit, res, value))
11643 + __vx_cres_adjust_min(limit, res, value);
11648 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
11650 + if (value + num <= __rlim_soft(limit, res))
11653 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
11655 + if (value + num <= __rlim_hard(limit, res))
11658 + __rlim_hit(limit, res);
11663 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
11666 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
11668 + rlim_t value, sum = 0;
11671 + while ((res = *array++)) {
11672 + value = __rlim_get(limit, res);
11673 + __vx_cres_fixup(limit, res, value);
11680 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
11682 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
11683 + int res = *array;
11685 + if (value == __rlim_get(limit, res))
11688 + __rlim_set(limit, res, value);
11689 + /* now adjust min/max */
11690 + if (!__vx_cres_adjust_max(limit, res, value))
11691 + __vx_cres_adjust_min(limit, res, value);
11696 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
11697 + const int *array, int num, char *_file, int _line)
11699 + struct _vx_limit *limit;
11700 + rlim_t value = 0;
11708 + limit = &vxi->limit;
11710 + value = __vx_cres_array_sum(limit, array + 1);
11712 + __rlim_set(limit, res, value);
11713 + __vx_cres_fixup(limit, res, value);
11715 + return __vx_cres_avail(vxi, res, num, _file, _line);
11719 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
11724 + /* complex resources first */
11725 + if ((id < 0) || (id == RLIMIT_RSS))
11726 + __vx_cres_array_fixup(limit, VLA_RSS);
11728 + for (res = 0; res < NUM_LIMITS; res++) {
11729 + if ((id > 0) && (res != id))
11732 + value = __rlim_get(limit, res);
11733 + __vx_cres_fixup(limit, res, value);
11735 + /* not supposed to happen, maybe warn? */
11736 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
11737 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
11742 +#endif /* __KERNEL__ */
11743 +#endif /* _VX_LIMIT_INT_H */
11744 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/monitor.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/monitor.h
11745 --- linux-2.6.27.3/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
11746 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/monitor.h 2008-10-13 14:54:20.000000000 +0200
11748 +#ifndef _VX_MONITOR_H
11749 +#define _VX_MONITOR_H
11751 +#include <linux/types.h>
11758 + VXM_UPDATE = 0x20,
11762 + VXM_RQINFO_1 = 0x24,
11765 + VXM_ACTIVATE = 0x40,
11772 + VXM_MIGRATE = 0x48,
11775 + /* all other bits are flags */
11776 + VXM_SCHED = 0x80,
11779 +struct _vxm_update_1 {
11780 + uint32_t tokens_max;
11781 + uint32_t fill_rate;
11782 + uint32_t interval;
11785 +struct _vxm_update_2 {
11786 + uint32_t tokens_min;
11787 + uint32_t fill_rate;
11788 + uint32_t interval;
11791 +struct _vxm_rqinfo_1 {
11792 + uint16_t running;
11796 + uint32_t idle_tokens;
11799 +struct _vxm_rqinfo_2 {
11800 + uint32_t norm_time;
11801 + uint32_t idle_time;
11802 + uint32_t idle_skip;
11805 +struct _vxm_sched {
11807 + uint32_t norm_time;
11808 + uint32_t idle_time;
11811 +struct _vxm_task {
11816 +struct _vxm_event {
11825 + struct _vxm_task tsk;
11829 +struct _vx_mon_entry {
11833 + struct _vxm_event ev;
11834 + struct _vxm_sched sd;
11835 + struct _vxm_update_1 u1;
11836 + struct _vxm_update_2 u2;
11837 + struct _vxm_rqinfo_1 q1;
11838 + struct _vxm_rqinfo_2 q2;
11843 +#endif /* _VX_MONITOR_H */
11844 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/network_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/network_cmd.h
11845 --- linux-2.6.27.3/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
11846 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/network_cmd.h 2008-10-13 14:54:20.000000000 +0200
11848 +#ifndef _VX_NETWORK_CMD_H
11849 +#define _VX_NETWORK_CMD_H
11852 +/* vinfo commands */
11854 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
11857 +extern int vc_task_nid(uint32_t);
11859 +#endif /* __KERNEL__ */
11861 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
11863 +struct vcmd_nx_info_v0 {
11865 + /* more to come */
11869 +extern int vc_nx_info(struct nx_info *, void __user *);
11871 +#endif /* __KERNEL__ */
11873 +#include <linux/in.h>
11874 +#include <linux/in6.h>
11876 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
11877 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
11879 +struct vcmd_net_create {
11880 + uint64_t flagword;
11883 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
11885 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
11886 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
11888 +struct vcmd_net_addr_v0 {
11891 + struct in_addr ip[4];
11892 + struct in_addr mask[4];
11895 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
11896 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
11898 +struct vcmd_net_addr_ipv4_v1 {
11901 + struct in_addr ip;
11902 + struct in_addr mask;
11905 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
11906 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
11908 +struct vcmd_net_addr_ipv6_v1 {
11912 + struct in6_addr ip;
11913 + struct in6_addr mask;
11916 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
11917 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
11919 +struct vcmd_match_ipv4_v0 {
11924 + struct in_addr ip;
11925 + struct in_addr ip2;
11926 + struct in_addr mask;
11929 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
11930 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
11932 +struct vcmd_match_ipv6_v0 {
11937 + struct in6_addr ip;
11938 + struct in6_addr ip2;
11939 + struct in6_addr mask;
11944 +extern int vc_net_create(uint32_t, void __user *);
11945 +extern int vc_net_migrate(struct nx_info *, void __user *);
11947 +extern int vc_net_add(struct nx_info *, void __user *);
11948 +extern int vc_net_remove(struct nx_info *, void __user *);
11950 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
11951 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
11953 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
11954 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
11956 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
11957 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
11959 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
11960 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
11962 +#endif /* __KERNEL__ */
11965 +/* flag commands */
11967 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
11968 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
11970 +struct vcmd_net_flags_v0 {
11971 + uint64_t flagword;
11976 +extern int vc_get_nflags(struct nx_info *, void __user *);
11977 +extern int vc_set_nflags(struct nx_info *, void __user *);
11979 +#endif /* __KERNEL__ */
11982 +/* network caps commands */
11984 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
11985 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
11987 +struct vcmd_net_caps_v0 {
11993 +extern int vc_get_ncaps(struct nx_info *, void __user *);
11994 +extern int vc_set_ncaps(struct nx_info *, void __user *);
11996 +#endif /* __KERNEL__ */
11997 +#endif /* _VX_CONTEXT_CMD_H */
11998 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/network.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/network.h
11999 --- linux-2.6.27.3/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12000 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/network.h 2008-10-13 14:54:20.000000000 +0200
12002 +#ifndef _VX_NETWORK_H
12003 +#define _VX_NETWORK_H
12005 +#include <linux/types.h>
12008 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12011 +/* network flags */
12013 +#define NXF_INFO_PRIVATE 0x00000008
12015 +#define NXF_SINGLE_IP 0x00000100
12016 +#define NXF_LBACK_REMAP 0x00000200
12017 +#define NXF_LBACK_ALLOW 0x00000400
12019 +#define NXF_HIDE_NETIF 0x02000000
12020 +#define NXF_HIDE_LBACK 0x04000000
12022 +#define NXF_STATE_SETUP (1ULL << 32)
12023 +#define NXF_STATE_ADMIN (1ULL << 34)
12025 +#define NXF_SC_HELPER (1ULL << 36)
12026 +#define NXF_PERSISTENT (1ULL << 38)
12028 +#define NXF_ONE_TIME (0x0005ULL << 32)
12031 +#define NXF_INIT_SET (__nxf_init_set())
12033 +static inline uint64_t __nxf_init_set(void) {
12034 + return NXF_STATE_ADMIN
12035 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12036 + | NXF_LBACK_REMAP
12039 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12042 + | NXF_HIDE_NETIF;
12046 +/* network caps */
12048 +#define NXC_TUN_CREATE 0x00000001
12050 +#define NXC_RAW_ICMP 0x00000100
12053 +/* address types */
12055 +#define NXA_TYPE_IPV4 0x0001
12056 +#define NXA_TYPE_IPV6 0x0002
12058 +#define NXA_TYPE_NONE 0x0000
12059 +#define NXA_TYPE_ANY 0x00FF
12061 +#define NXA_TYPE_ADDR 0x0010
12062 +#define NXA_TYPE_MASK 0x0020
12063 +#define NXA_TYPE_RANGE 0x0040
12065 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12067 +#define NXA_MOD_BCAST 0x0100
12068 +#define NXA_MOD_LBACK 0x0200
12070 +#define NXA_LOOPBACK 0x1000
12072 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12073 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12077 +#include <linux/list.h>
12078 +#include <linux/spinlock.h>
12079 +#include <linux/rcupdate.h>
12080 +#include <linux/in.h>
12081 +#include <linux/in6.h>
12082 +#include <asm/atomic.h>
12084 +struct nx_addr_v4 {
12085 + struct nx_addr_v4 *next;
12086 + struct in_addr ip[2];
12087 + struct in_addr mask;
12092 +struct nx_addr_v6 {
12093 + struct nx_addr_v6 *next;
12094 + struct in6_addr ip;
12095 + struct in6_addr mask;
12102 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12103 + nid_t nx_id; /* vnet id */
12104 + atomic_t nx_usecnt; /* usage count */
12105 + atomic_t nx_tasks; /* tasks count */
12106 + int nx_state; /* context state */
12108 + uint64_t nx_flags; /* network flag word */
12109 + uint64_t nx_ncaps; /* network capabilities */
12111 + struct in_addr v4_lback; /* Loopback address */
12112 + struct in_addr v4_bcast; /* Broadcast address */
12113 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12114 +#ifdef CONFIG_IPV6
12115 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12117 + char nx_name[65]; /* network context name */
12121 +/* status flags */
12123 +#define NXS_HASHED 0x0001
12124 +#define NXS_SHUTDOWN 0x0100
12125 +#define NXS_RELEASED 0x8000
12127 +extern struct nx_info *lookup_nx_info(int);
12129 +extern int get_nid_list(int, unsigned int *, int);
12130 +extern int nid_is_hashed(nid_t);
12132 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12134 +extern long vs_net_change(struct nx_info *, unsigned int);
12139 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12140 +#ifdef CONFIG_IPV6
12141 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12143 +#define NX_IPV6(n) (0)
12146 +#endif /* __KERNEL__ */
12147 +#endif /* _VX_NETWORK_H */
12148 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/percpu.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/percpu.h
12149 --- linux-2.6.27.3/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12150 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/percpu.h 2008-10-13 14:54:20.000000000 +0200
12152 +#ifndef _VX_PERCPU_H
12153 +#define _VX_PERCPU_H
12155 +#include "cvirt_def.h"
12156 +#include "sched_def.h"
12158 +struct _vx_percpu {
12159 + struct _vx_cvirt_pc cvirt;
12160 + struct _vx_sched_pc sched;
12163 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12165 +#endif /* _VX_PERCPU_H */
12166 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/pid.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/pid.h
12167 --- linux-2.6.27.3/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12168 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/pid.h 2008-10-13 14:54:20.000000000 +0200
12170 +#ifndef _VSERVER_PID_H
12171 +#define _VSERVER_PID_H
12173 +/* pid faking stuff */
12175 +#define vx_info_map_pid(v, p) \
12176 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12177 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12178 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
12179 +#define vx_map_tgid(p) vx_map_pid(p)
12181 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12182 + const char *func, const char *file, int line)
12184 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12185 + vxfprintk(VXD_CBIT(cvirt, 2),
12186 + "vx_map_tgid: %p/%llx: %d -> %d",
12187 + vxi, (long long)vxi->vx_flags, pid,
12188 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12189 + func, file, line);
12192 + if (pid == vxi->vx_initpid)
12198 +#define vx_info_rmap_pid(v, p) \
12199 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12200 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
12201 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12203 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12204 + const char *func, const char *file, int line)
12206 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12207 + vxfprintk(VXD_CBIT(cvirt, 2),
12208 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12209 + vxi, (long long)vxi->vx_flags, pid,
12210 + (pid == 1) ? vxi->vx_initpid : pid,
12211 + func, file, line);
12212 + if ((pid == 1) && vxi->vx_initpid)
12213 + return vxi->vx_initpid;
12214 + if (pid == vxi->vx_initpid)
12221 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/sched_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/sched_cmd.h
12222 --- linux-2.6.27.3/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12223 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/sched_cmd.h 2008-10-13 14:54:20.000000000 +0200
12225 +#ifndef _VX_SCHED_CMD_H
12226 +#define _VX_SCHED_CMD_H
12229 +/* sched vserver commands */
12231 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12232 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12233 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12235 +struct vcmd_set_sched_v2 {
12236 + int32_t fill_rate;
12237 + int32_t interval;
12239 + int32_t tokens_min;
12240 + int32_t tokens_max;
12241 + uint64_t cpu_mask;
12244 +struct vcmd_set_sched_v3 {
12245 + uint32_t set_mask;
12246 + int32_t fill_rate;
12247 + int32_t interval;
12249 + int32_t tokens_min;
12250 + int32_t tokens_max;
12251 + int32_t priority_bias;
12254 +struct vcmd_set_sched_v4 {
12255 + uint32_t set_mask;
12256 + int32_t fill_rate;
12257 + int32_t interval;
12259 + int32_t tokens_min;
12260 + int32_t tokens_max;
12261 + int32_t prio_bias;
12263 + int32_t bucket_id;
12266 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12267 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12269 +struct vcmd_sched_v5 {
12272 + int32_t bucket_id;
12273 + int32_t fill_rate[2];
12274 + int32_t interval[2];
12276 + int32_t tokens_min;
12277 + int32_t tokens_max;
12278 + int32_t prio_bias;
12281 +#define VXSM_FILL_RATE 0x0001
12282 +#define VXSM_INTERVAL 0x0002
12283 +#define VXSM_FILL_RATE2 0x0004
12284 +#define VXSM_INTERVAL2 0x0008
12285 +#define VXSM_TOKENS 0x0010
12286 +#define VXSM_TOKENS_MIN 0x0020
12287 +#define VXSM_TOKENS_MAX 0x0040
12288 +#define VXSM_PRIO_BIAS 0x0100
12290 +#define VXSM_IDLE_TIME 0x0200
12291 +#define VXSM_FORCE 0x0400
12293 +#define VXSM_V3_MASK 0x0173
12294 +#define VXSM_SET_MASK 0x01FF
12296 +#define VXSM_CPU_ID 0x1000
12297 +#define VXSM_BUCKET_ID 0x2000
12299 +#define VXSM_MSEC 0x4000
12301 +#define SCHED_KEEP (-2) /* only for v2 */
12305 +#include <linux/compiler.h>
12307 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
12308 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
12309 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
12310 +extern int vc_set_sched(struct vx_info *, void __user *);
12311 +extern int vc_get_sched(struct vx_info *, void __user *);
12313 +#endif /* __KERNEL__ */
12315 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
12317 +struct vcmd_sched_info {
12319 + int32_t bucket_id;
12320 + uint64_t user_msec;
12321 + uint64_t sys_msec;
12322 + uint64_t hold_msec;
12323 + uint32_t token_usec;
12324 + int32_t vavavoom;
12329 +extern int vc_sched_info(struct vx_info *, void __user *);
12331 +#endif /* __KERNEL__ */
12332 +#endif /* _VX_SCHED_CMD_H */
12333 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/sched_def.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/sched_def.h
12334 --- linux-2.6.27.3/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12335 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/sched_def.h 2008-10-13 14:54:20.000000000 +0200
12337 +#ifndef _VX_SCHED_DEF_H
12338 +#define _VX_SCHED_DEF_H
12340 +#include <linux/spinlock.h>
12341 +#include <linux/jiffies.h>
12342 +#include <linux/cpumask.h>
12343 +#include <asm/atomic.h>
12344 +#include <asm/param.h>
12347 +/* context sub struct */
12349 +struct _vx_sched {
12350 + spinlock_t tokens_lock; /* lock for token bucket */
12352 + int tokens; /* number of CPU tokens */
12353 + int fill_rate[2]; /* Fill rate: add X tokens... */
12354 + int interval[2]; /* Divisor: per Y jiffies */
12355 + int tokens_min; /* Limit: minimum for unhold */
12356 + int tokens_max; /* Limit: no more than N tokens */
12358 + int prio_bias; /* bias offset for priority */
12360 + unsigned update_mask; /* which features should be updated */
12361 + cpumask_t update; /* CPUs which should update */
12364 +struct _vx_sched_pc {
12365 + int tokens; /* number of CPU tokens */
12366 + int flags; /* bucket flags */
12368 + int fill_rate[2]; /* Fill rate: add X tokens... */
12369 + int interval[2]; /* Divisor: per Y jiffies */
12370 + int tokens_min; /* Limit: minimum for unhold */
12371 + int tokens_max; /* Limit: no more than N tokens */
12373 + int prio_bias; /* bias offset for priority */
12374 + int vavavoom; /* last calculated vavavoom */
12376 + unsigned long norm_time; /* last time accounted */
12377 + unsigned long idle_time; /* non linear time for fair sched */
12378 + unsigned long token_time; /* token time for accounting */
12379 + unsigned long onhold; /* jiffies when put on hold */
12381 + uint64_t user_ticks; /* token tick events */
12382 + uint64_t sys_ticks; /* token tick events */
12383 + uint64_t hold_ticks; /* token ticks paused */
12387 +#define VXSF_ONHOLD 0x0001
12388 +#define VXSF_IDLE_TIME 0x0100
12390 +#ifdef CONFIG_VSERVER_DEBUG
12392 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12394 + printk("\t_vx_sched:\n");
12395 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
12396 + sched->fill_rate[0], sched->interval[0],
12397 + sched->fill_rate[1], sched->interval[1],
12398 + sched->tokens_min, sched->tokens_max);
12399 + printk("\t priority = %4d\n", sched->prio_bias);
12404 +#endif /* _VX_SCHED_DEF_H */
12405 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/sched.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/sched.h
12406 --- linux-2.6.27.3/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
12407 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/sched.h 2008-10-13 14:54:20.000000000 +0200
12409 +#ifndef _VX_SCHED_H
12410 +#define _VX_SCHED_H
12417 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12422 +void vx_update_load(struct vx_info *);
12425 +int vx_tokens_recalc(struct _vx_sched_pc *,
12426 + unsigned long *, unsigned long *, int [2]);
12428 +void vx_update_sched_param(struct _vx_sched *sched,
12429 + struct _vx_sched_pc *sched_pc);
12431 +#endif /* __KERNEL__ */
12432 +#else /* _VX_SCHED_H */
12433 +#warning duplicate inclusion
12434 +#endif /* _VX_SCHED_H */
12435 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/signal_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/signal_cmd.h
12436 --- linux-2.6.27.3/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
12437 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/signal_cmd.h 2008-10-13 14:54:20.000000000 +0200
12439 +#ifndef _VX_SIGNAL_CMD_H
12440 +#define _VX_SIGNAL_CMD_H
12443 +/* signalling vserver commands */
12445 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
12446 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
12448 +struct vcmd_ctx_kill_v0 {
12453 +struct vcmd_wait_exit_v0 {
12454 + int32_t reboot_cmd;
12455 + int32_t exit_code;
12460 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12461 +extern int vc_wait_exit(struct vx_info *, void __user *);
12463 +#endif /* __KERNEL__ */
12465 +/* process alteration commands */
12467 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
12468 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
12470 +struct vcmd_pflags_v0 {
12471 + uint32_t flagword;
12477 +extern int vc_get_pflags(uint32_t pid, void __user *);
12478 +extern int vc_set_pflags(uint32_t pid, void __user *);
12480 +#endif /* __KERNEL__ */
12481 +#endif /* _VX_SIGNAL_CMD_H */
12482 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/signal.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/signal.h
12483 --- linux-2.6.27.3/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
12484 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/signal.h 2008-10-13 14:54:20.000000000 +0200
12486 +#ifndef _VX_SIGNAL_H
12487 +#define _VX_SIGNAL_H
12494 +int vx_info_kill(struct vx_info *, int, int);
12496 +#endif /* __KERNEL__ */
12497 +#else /* _VX_SIGNAL_H */
12498 +#warning duplicate inclusion
12499 +#endif /* _VX_SIGNAL_H */
12500 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/space_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/space_cmd.h
12501 --- linux-2.6.27.3/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
12502 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/space_cmd.h 2008-10-13 14:54:20.000000000 +0200
12504 +#ifndef _VX_SPACE_CMD_H
12505 +#define _VX_SPACE_CMD_H
12508 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
12509 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 1)
12511 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
12512 +#define VCMD_set_space VC_CMD(PROCALT, 3, 1)
12514 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
12516 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
12517 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
12520 +struct vcmd_space_mask {
12527 +extern int vc_enter_space(struct vx_info *, void __user *);
12528 +extern int vc_set_space(struct vx_info *, void __user *);
12529 +extern int vc_get_space_mask(void __user *, int);
12531 +#endif /* __KERNEL__ */
12532 +#endif /* _VX_SPACE_CMD_H */
12533 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/space.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/space.h
12534 --- linux-2.6.27.3/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
12535 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/space.h 2008-10-13 14:54:20.000000000 +0200
12537 +#ifndef _VX_SPACE_H
12538 +#define _VX_SPACE_H
12541 +#include <linux/types.h>
12545 +int vx_set_space(struct vx_info *vxi, unsigned long mask);
12547 +#else /* _VX_SPACE_H */
12548 +#warning duplicate inclusion
12549 +#endif /* _VX_SPACE_H */
12550 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/switch.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/switch.h
12551 --- linux-2.6.27.3/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
12552 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/switch.h 2008-10-13 14:54:20.000000000 +0200
12554 +#ifndef _VX_SWITCH_H
12555 +#define _VX_SWITCH_H
12557 +#include <linux/types.h>
12560 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
12561 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
12562 +#define VC_VERSION(c) ((c) & 0xFFF)
12564 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
12565 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
12569 + Syscall Matrix V2.8
12571 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
12572 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
12573 + |INFO |SETUP | |MOVE | | | | | |
12574 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12575 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
12576 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
12577 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12578 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
12579 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
12580 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12581 + MEMORY | | | | |MEMCTRL| | |SWAP | |
12582 + | 16| 17| 18| 19| 20| 21| | 22| 23|
12583 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12584 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
12585 + | 24| 25| 26| 27| 28| 29| | 30| 31|
12586 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12587 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
12588 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
12589 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12590 + OTHER |VSTAT | | | | | | |VINFO | |
12591 + | 40| 41| 42| 43| 44| 45| | 46| 47|
12592 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
12593 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
12594 + | 48| 49| 50| 51| 52| 53| | 54| 55|
12595 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12596 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
12597 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
12598 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12602 +#define VC_CAT_VERSION 0
12604 +#define VC_CAT_VSETUP 1
12605 +#define VC_CAT_VHOST 2
12607 +#define VC_CAT_DEVICE 6
12609 +#define VC_CAT_VPROC 9
12610 +#define VC_CAT_PROCALT 10
12611 +#define VC_CAT_PROCMIG 11
12612 +#define VC_CAT_PROCTRL 12
12614 +#define VC_CAT_SCHED 14
12615 +#define VC_CAT_MEMCTRL 20
12617 +#define VC_CAT_VNET 25
12618 +#define VC_CAT_NETALT 26
12619 +#define VC_CAT_NETMIG 27
12620 +#define VC_CAT_NETCTRL 28
12622 +#define VC_CAT_TAGMIG 35
12623 +#define VC_CAT_DLIMIT 36
12624 +#define VC_CAT_INODE 38
12626 +#define VC_CAT_VSTAT 40
12627 +#define VC_CAT_VINFO 46
12628 +#define VC_CAT_EVENT 48
12630 +#define VC_CAT_FLAGS 52
12631 +#define VC_CAT_VSPACE 54
12632 +#define VC_CAT_DEBUG 56
12633 +#define VC_CAT_RLIMIT 60
12635 +#define VC_CAT_SYSTEST 61
12636 +#define VC_CAT_COMPAT 63
12638 +/* query version */
12640 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
12641 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
12646 +#include <linux/errno.h>
12649 +#else /* __KERNEL__ */
12651 +#endif /* __KERNEL__ */
12653 +#endif /* _VX_SWITCH_H */
12654 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/tag_cmd.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/tag_cmd.h
12655 --- linux-2.6.27.3/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
12656 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/tag_cmd.h 2008-10-13 14:54:20.000000000 +0200
12658 +#ifndef _VX_TAG_CMD_H
12659 +#define _VX_TAG_CMD_H
12662 +/* vinfo commands */
12664 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
12667 +extern int vc_task_tag(uint32_t);
12669 +#endif /* __KERNEL__ */
12671 +/* context commands */
12673 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
12676 +extern int vc_tag_migrate(uint32_t);
12678 +#endif /* __KERNEL__ */
12679 +#endif /* _VX_TAG_CMD_H */
12680 diff -NurpP --minimal linux-2.6.27.3/include/linux/vserver/tag.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/tag.h
12681 --- linux-2.6.27.3/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
12682 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vserver/tag.h 2008-10-24 03:34:52.000000000 +0200
12687 +#include <linux/types.h>
12690 +#define DX_TAG(in) (IS_TAGGED(in))
12693 +#ifdef CONFIG_TAG_NFSD
12694 +#define DX_TAG_NFSD 1
12696 +#define DX_TAG_NFSD 0
12700 +#ifdef CONFIG_TAGGING_NONE
12702 +#define MAX_UID 0xFFFFFFFF
12703 +#define MAX_GID 0xFFFFFFFF
12705 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
12707 +#define TAGINO_UID(cond, uid, tag) (uid)
12708 +#define TAGINO_GID(cond, gid, tag) (gid)
12713 +#ifdef CONFIG_TAGGING_GID16
12715 +#define MAX_UID 0xFFFFFFFF
12716 +#define MAX_GID 0x0000FFFF
12718 +#define INOTAG_TAG(cond, uid, gid, tag) \
12719 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
12721 +#define TAGINO_UID(cond, uid, tag) (uid)
12722 +#define TAGINO_GID(cond, gid, tag) \
12723 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
12728 +#ifdef CONFIG_TAGGING_ID24
12730 +#define MAX_UID 0x00FFFFFF
12731 +#define MAX_GID 0x00FFFFFF
12733 +#define INOTAG_TAG(cond, uid, gid, tag) \
12734 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
12736 +#define TAGINO_UID(cond, uid, tag) \
12737 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
12738 +#define TAGINO_GID(cond, gid, tag) \
12739 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
12744 +#ifdef CONFIG_TAGGING_UID16
12746 +#define MAX_UID 0x0000FFFF
12747 +#define MAX_GID 0xFFFFFFFF
12749 +#define INOTAG_TAG(cond, uid, gid, tag) \
12750 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
12752 +#define TAGINO_UID(cond, uid, tag) \
12753 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
12754 +#define TAGINO_GID(cond, gid, tag) (gid)
12759 +#ifdef CONFIG_TAGGING_INTERN
12761 +#define MAX_UID 0xFFFFFFFF
12762 +#define MAX_GID 0xFFFFFFFF
12764 +#define INOTAG_TAG(cond, uid, gid, tag) \
12765 + ((cond) ? (tag) : 0)
12767 +#define TAGINO_UID(cond, uid, tag) (uid)
12768 +#define TAGINO_GID(cond, gid, tag) (gid)
12773 +#ifndef CONFIG_TAGGING_NONE
12774 +#define dx_current_fstag(sb) \
12775 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
12777 +#define dx_current_fstag(sb) (0)
12780 +#ifndef CONFIG_TAGGING_INTERN
12781 +#define TAGINO_TAG(cond, tag) (0)
12783 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
12786 +#define INOTAG_UID(cond, uid, gid) \
12787 + ((cond) ? ((uid) & MAX_UID) : (uid))
12788 +#define INOTAG_GID(cond, uid, gid) \
12789 + ((cond) ? ((gid) & MAX_GID) : (gid))
12792 +static inline uid_t dx_map_uid(uid_t uid)
12794 + if ((uid > MAX_UID) && (uid != -1))
12796 + return (uid & MAX_UID);
12799 +static inline gid_t dx_map_gid(gid_t gid)
12801 + if ((gid > MAX_GID) && (gid != -1))
12803 + return (gid & MAX_GID);
12811 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
12813 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
12814 + unsigned long *flags);
12816 +#ifdef CONFIG_PROPAGATE
12818 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
12820 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
12823 +#define dx_propagate_tag(n, i) do { } while (0)
12826 +#endif /* _DX_TAG_H */
12827 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_inet6.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_inet6.h
12828 --- linux-2.6.27.3/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
12829 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_inet6.h 2008-10-13 14:54:20.000000000 +0200
12831 +#ifndef _VS_INET6_H
12832 +#define _VS_INET6_H
12834 +#include "vserver/base.h"
12835 +#include "vserver/network.h"
12836 +#include "vserver/debug.h"
12838 +#include <net/ipv6.h>
12840 +#define NXAV6(a) NIP6((a)->ip), NIP6((a)->mask), (a)->prefix, (a)->type
12841 +#define NXAV6_FMT "[" NIP6_FMT "/" NIP6_FMT "/%d:%04x]"
12844 +#ifdef CONFIG_IPV6
12847 +int v6_addr_match(struct nx_addr_v6 *nxa,
12848 + const struct in6_addr *addr, uint16_t mask)
12850 + switch (nxa->type & mask) {
12851 + case NXA_TYPE_MASK:
12852 + return ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
12853 + case NXA_TYPE_ADDR:
12854 + return ipv6_addr_equal(&nxa->ip, addr);
12855 + case NXA_TYPE_ANY:
12863 +int v6_addr_in_nx_info(struct nx_info *nxi,
12864 + const struct in6_addr *addr, uint16_t mask)
12866 + struct nx_addr_v6 *nxa;
12870 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
12871 + if (v6_addr_match(nxa, addr, mask))
12877 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
12879 + /* FIXME: needs full range checks */
12880 + return v6_addr_match(nxa, &addr->ip, mask);
12884 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
12886 + struct nx_addr_v6 *ptr;
12888 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
12889 + if (v6_nx_addr_match(ptr, nxa, mask))
12896 + * Check if a given address matches for a socket
12898 + * nxi: the socket's nx_info if any
12899 + * addr: to be verified address
12902 +int v6_sock_addr_match (
12903 + struct nx_info *nxi,
12904 + struct inet_sock *inet,
12905 + struct in6_addr *addr)
12907 + struct sock *sk = &inet->sk;
12908 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
12910 + if (!ipv6_addr_any(addr) &&
12911 + ipv6_addr_equal(saddr, addr))
12913 + if (ipv6_addr_any(saddr))
12914 + return v6_addr_in_nx_info(nxi, addr, -1);
12919 + * check if address is covered by socket
12921 + * sk: the socket to check against
12922 + * addr: the address in question (must be != 0)
12926 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
12928 + struct nx_info *nxi = sk->sk_nx_info;
12929 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
12931 + vxdprintk(VXD_CBIT(net, 5),
12932 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:" NIP6_FMT " %p;%lx",
12933 + sk, NXAV6(nxa), nxi, NIP6(*saddr), sk->sk_socket,
12934 + (sk->sk_socket?sk->sk_socket->flags:0));
12936 + if (!ipv6_addr_any(saddr)) { /* direct address match */
12937 + return v6_addr_match(nxa, saddr, -1);
12938 + } else if (nxi) { /* match against nx_info */
12939 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
12940 + } else { /* unrestricted any socket */
12946 +/* inet related checks and helpers */
12950 +struct net_device;
12954 +#include <linux/netdevice.h>
12955 +#include <linux/inetdevice.h>
12956 +#include <net/inet_timewait_sock.h>
12959 +int dev_in_nx_info(struct net_device *, struct nx_info *);
12960 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
12961 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
12966 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
12972 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
12976 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
12978 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
12980 + if (v6_ifa_in_nx_info(ifa, nxi))
12986 +struct nx_v6_sock_addr {
12987 + struct in6_addr saddr; /* Address used for validation */
12988 + struct in6_addr baddr; /* Address used for socket bind */
12992 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
12993 + struct nx_v6_sock_addr *nsa)
12995 + // struct sock *sk = &inet->sk;
12996 + // struct nx_info *nxi = sk->sk_nx_info;
12997 + struct in6_addr saddr = addr->sin6_addr;
12998 + struct in6_addr baddr = saddr;
13000 + nsa->saddr = saddr;
13001 + nsa->baddr = baddr;
13006 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13008 + // struct sock *sk = &inet->sk;
13009 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13011 + // *saddr = nsa->baddr;
13012 + // inet->saddr = nsa->baddr;
13016 +int nx_info_has_v6(struct nx_info *nxi)
13020 + if (NX_IPV6(nxi))
13025 +#else /* CONFIG_IPV6 */
13028 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13035 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13041 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13047 +int nx_info_has_v6(struct nx_info *nxi)
13052 +#endif /* CONFIG_IPV6 */
13054 +#define current_nx_info_has_v6() \
13055 + nx_info_has_v6(current_nx_info())
13058 +#warning duplicate inclusion
13060 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_inet.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_inet.h
13061 --- linux-2.6.27.3/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13062 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_inet.h 2008-10-13 14:54:20.000000000 +0200
13064 +#ifndef _VS_INET_H
13065 +#define _VS_INET_H
13067 +#include "vserver/base.h"
13068 +#include "vserver/network.h"
13069 +#include "vserver/debug.h"
13071 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13073 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13074 + NIPQUAD((a)->mask), (a)->type
13075 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13079 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13081 + __be32 ip = nxa->ip[0].s_addr;
13082 + __be32 mask = nxa->mask.s_addr;
13083 + __be32 bcast = ip | ~mask;
13086 + switch (nxa->type & tmask) {
13087 + case NXA_TYPE_MASK:
13088 + ret = (ip == (addr & mask));
13090 + case NXA_TYPE_ADDR:
13094 + /* fall through to broadcast */
13095 + case NXA_MOD_BCAST:
13096 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13098 + case NXA_TYPE_RANGE:
13099 + ret = ((nxa->ip[0].s_addr <= addr) &&
13100 + (nxa->ip[1].s_addr > addr));
13102 + case NXA_TYPE_ANY:
13107 + vxdprintk(VXD_CBIT(net, 0),
13108 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13109 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13114 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13116 + struct nx_addr_v4 *nxa;
13123 + /* allow 127.0.0.1 when remapping lback */
13124 + if ((tmask & NXA_LOOPBACK) &&
13125 + (addr == IPI_LOOPBACK) &&
13126 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13129 + /* check for lback address */
13130 + if ((tmask & NXA_MOD_LBACK) &&
13131 + (nxi->v4_lback.s_addr == addr))
13134 + /* check for broadcast address */
13135 + if ((tmask & NXA_MOD_BCAST) &&
13136 + (nxi->v4_bcast.s_addr == addr))
13139 + /* check for v4 addresses */
13140 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13141 + if (v4_addr_match(nxa, addr, tmask))
13145 + vxdprintk(VXD_CBIT(net, 0),
13146 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13147 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13152 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13154 + /* FIXME: needs full range checks */
13155 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13159 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13161 + struct nx_addr_v4 *ptr;
13163 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13164 + if (v4_nx_addr_match(ptr, nxa, mask))
13169 +#include <net/inet_sock.h>
13172 + * Check if a given address matches for a socket
13174 + * nxi: the socket's nx_info if any
13175 + * addr: to be verified address
13178 +int v4_sock_addr_match (
13179 + struct nx_info *nxi,
13180 + struct inet_sock *inet,
13183 + __be32 saddr = inet->rcv_saddr;
13184 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13186 + if (addr && (saddr == addr || bcast == addr))
13189 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13194 +/* inet related checks and helpers */
13198 +struct net_device;
13201 +#ifdef CONFIG_INET
13203 +#include <linux/netdevice.h>
13204 +#include <linux/inetdevice.h>
13205 +#include <net/inet_sock.h>
13206 +#include <net/inet_timewait_sock.h>
13209 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13210 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13211 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13215 + * check if address is covered by socket
13217 + * sk: the socket to check against
13218 + * addr: the address in question (must be != 0)
13222 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13224 + struct nx_info *nxi = sk->sk_nx_info;
13225 + __be32 saddr = inet_rcv_saddr(sk);
13227 + vxdprintk(VXD_CBIT(net, 5),
13228 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13229 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13230 + (sk->sk_socket?sk->sk_socket->flags:0));
13232 + if (saddr) { /* direct address match */
13233 + return v4_addr_match(nxa, saddr, -1);
13234 + } else if (nxi) { /* match against nx_info */
13235 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13236 + } else { /* unrestricted any socket */
13244 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13246 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13247 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13248 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13250 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13252 + if (dev_in_nx_info(dev, nxi))
13259 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13265 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13269 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13271 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13272 + nxi, nxi ? nxi->nx_id : 0, ifa,
13273 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13275 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13277 + if (v4_ifa_in_nx_info(ifa, nxi))
13283 +struct nx_v4_sock_addr {
13284 + __be32 saddr; /* Address used for validation */
13285 + __be32 baddr; /* Address used for socket bind */
13289 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13290 + struct nx_v4_sock_addr *nsa)
13292 + struct sock *sk = &inet->sk;
13293 + struct nx_info *nxi = sk->sk_nx_info;
13294 + __be32 saddr = addr->sin_addr.s_addr;
13295 + __be32 baddr = saddr;
13297 + vxdprintk(VXD_CBIT(net, 3),
13298 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13299 + sk, sk->sk_nx_info, sk->sk_socket,
13300 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13304 + if (saddr == INADDR_ANY) {
13305 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13306 + baddr = nxi->v4.ip[0].s_addr;
13307 + } else if (saddr == IPI_LOOPBACK) {
13308 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13309 + baddr = nxi->v4_lback.s_addr;
13310 + } else { /* normal address bind */
13311 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13312 + return -EADDRNOTAVAIL;
13316 + vxdprintk(VXD_CBIT(net, 3),
13317 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13318 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13320 + nsa->saddr = saddr;
13321 + nsa->baddr = baddr;
13326 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
13328 + inet->saddr = nsa->baddr;
13329 + inet->rcv_saddr = nsa->baddr;
13334 + * helper to simplify inet_lookup_listener
13336 + * nxi: the socket's nx_info if any
13337 + * addr: to be verified address
13338 + * saddr: socket address
13340 +static inline int v4_inet_addr_match (
13341 + struct nx_info *nxi,
13345 + if (addr && (saddr == addr))
13348 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
13352 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
13354 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
13355 + (addr == nxi->v4_lback.s_addr))
13356 + return IPI_LOOPBACK;
13361 +int nx_info_has_v4(struct nx_info *nxi)
13365 + if (NX_IPV4(nxi))
13367 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13372 +#else /* CONFIG_INET */
13375 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
13381 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13387 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13393 +int nx_info_has_v4(struct nx_info *nxi)
13398 +#endif /* CONFIG_INET */
13400 +#define current_nx_info_has_v4() \
13401 + nx_info_has_v4(current_nx_info())
13404 +// #warning duplicate inclusion
13406 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_limit.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_limit.h
13407 --- linux-2.6.27.3/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
13408 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_limit.h 2008-10-13 14:54:20.000000000 +0200
13410 +#ifndef _VS_LIMIT_H
13411 +#define _VS_LIMIT_H
13413 +#include "vserver/limit.h"
13414 +#include "vserver/base.h"
13415 +#include "vserver/context.h"
13416 +#include "vserver/debug.h"
13417 +#include "vserver/context.h"
13418 +#include "vserver/limit_int.h"
13421 +#define vx_acc_cres(v, d, p, r) \
13422 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13424 +#define vx_acc_cres_cond(x, d, p, r) \
13425 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13426 + r, d, p, __FILE__, __LINE__)
13429 +#define vx_add_cres(v, a, p, r) \
13430 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13431 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13433 +#define vx_add_cres_cond(x, a, p, r) \
13434 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13435 + r, a, p, __FILE__, __LINE__)
13436 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13439 +/* process and file limits */
13441 +#define vx_nproc_inc(p) \
13442 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13444 +#define vx_nproc_dec(p) \
13445 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13447 +#define vx_files_inc(f) \
13448 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13450 +#define vx_files_dec(f) \
13451 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13453 +#define vx_locks_inc(l) \
13454 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13456 +#define vx_locks_dec(l) \
13457 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13459 +#define vx_openfd_inc(f) \
13460 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
13462 +#define vx_openfd_dec(f) \
13463 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
13466 +#define vx_cres_avail(v, n, r) \
13467 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13470 +#define vx_nproc_avail(n) \
13471 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
13473 +#define vx_files_avail(n) \
13474 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
13476 +#define vx_locks_avail(n) \
13477 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
13479 +#define vx_openfd_avail(n) \
13480 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
13483 +/* dentry limits */
13485 +#define vx_dentry_inc(d) do { \
13486 + if (atomic_read(&d->d_count) == 1) \
13487 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
13490 +#define vx_dentry_dec(d) do { \
13491 + if (atomic_read(&d->d_count) == 0) \
13492 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
13495 +#define vx_dentry_avail(n) \
13496 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
13499 +/* socket limits */
13501 +#define vx_sock_inc(s) \
13502 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
13504 +#define vx_sock_dec(s) \
13505 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
13507 +#define vx_sock_avail(n) \
13508 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
13511 +/* ipc resource limits */
13513 +#define vx_ipcmsg_add(v, u, a) \
13514 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
13516 +#define vx_ipcmsg_sub(v, u, a) \
13517 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
13519 +#define vx_ipcmsg_avail(v, a) \
13520 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
13523 +#define vx_ipcshm_add(v, k, a) \
13524 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13526 +#define vx_ipcshm_sub(v, k, a) \
13527 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13529 +#define vx_ipcshm_avail(v, a) \
13530 + vx_cres_avail(v, a, VLIMIT_SHMEM)
13533 +#define vx_semary_inc(a) \
13534 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
13536 +#define vx_semary_dec(a) \
13537 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
13540 +#define vx_nsems_add(a,n) \
13541 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13543 +#define vx_nsems_sub(a,n) \
13544 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13548 +#warning duplicate inclusion
13550 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_memory.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_memory.h
13551 --- linux-2.6.27.3/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
13552 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_memory.h 2008-10-13 14:54:20.000000000 +0200
13554 +#ifndef _VS_MEMORY_H
13555 +#define _VS_MEMORY_H
13557 +#include "vserver/limit.h"
13558 +#include "vserver/base.h"
13559 +#include "vserver/context.h"
13560 +#include "vserver/debug.h"
13561 +#include "vserver/context.h"
13562 +#include "vserver/limit_int.h"
13565 +#define __acc_add_long(a, v) (*(v) += (a))
13566 +#define __acc_inc_long(v) (++*(v))
13567 +#define __acc_dec_long(v) (--*(v))
13569 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
13570 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
13571 +#define __acc_inc_atomic(v) atomic_long_inc(v)
13572 +#define __acc_dec_atomic(v) atomic_long_dec(v)
13573 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13574 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
13575 +#define __acc_inc_atomic(v) __acc_inc_long(v)
13576 +#define __acc_dec_atomic(v) __acc_dec_long(v)
13577 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13580 +#define vx_acc_page(m, d, v, r) do { \
13582 + __acc_inc_long(&(m)->v); \
13584 + __acc_dec_long(&(m)->v); \
13585 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13588 +#define vx_acc_page_atomic(m, d, v, r) do { \
13590 + __acc_inc_atomic(&(m)->v); \
13592 + __acc_dec_atomic(&(m)->v); \
13593 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13597 +#define vx_acc_pages(m, p, v, r) do { \
13598 + unsigned long __p = (p); \
13599 + __acc_add_long(__p, &(m)->v); \
13600 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13603 +#define vx_acc_pages_atomic(m, p, v, r) do { \
13604 + unsigned long __p = (p); \
13605 + __acc_add_atomic(__p, &(m)->v); \
13606 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13611 +#define vx_acc_vmpage(m, d) \
13612 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
13613 +#define vx_acc_vmlpage(m, d) \
13614 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
13615 +#define vx_acc_file_rsspage(m, d) \
13616 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
13617 +#define vx_acc_anon_rsspage(m, d) \
13618 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
13620 +#define vx_acc_vmpages(m, p) \
13621 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
13622 +#define vx_acc_vmlpages(m, p) \
13623 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
13624 +#define vx_acc_file_rsspages(m, p) \
13625 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
13626 +#define vx_acc_anon_rsspages(m, p) \
13627 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
13629 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
13630 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
13632 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
13633 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
13634 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
13635 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
13637 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
13638 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
13639 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
13640 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
13642 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
13643 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
13644 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
13645 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
13647 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
13648 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
13649 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
13650 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
13653 +#define vx_pages_avail(m, p, r) \
13654 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
13656 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
13657 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
13658 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
13659 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
13661 +#define vx_rss_avail(m, p) \
13662 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
13666 + VXPT_UNKNOWN = 0,
13675 +#define vx_page_fault(mm, vma, type, ret)
13679 +void __vx_page_fault(struct mm_struct *mm,
13680 + struct vm_area_struct *vma, int type, int ret)
13682 + struct vx_info *vxi = mm->mm_vx_info;
13685 + static char *page_type[6] =
13686 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
13687 + static char *page_what[4] =
13688 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
13694 + what = (ret & 0x3);
13696 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
13697 + type, what, ret, page_type[type], page_what[what]);
13699 + if (ret & VM_FAULT_WRITE)
13701 + atomic_inc(&vxi->cacct.page[type][what]);
13704 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
13708 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
13711 +#warning duplicate inclusion
13713 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_network.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_network.h
13714 --- linux-2.6.27.3/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
13715 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_network.h 2008-10-13 14:54:20.000000000 +0200
13717 +#ifndef _NX_VS_NETWORK_H
13718 +#define _NX_VS_NETWORK_H
13720 +#include "vserver/context.h"
13721 +#include "vserver/network.h"
13722 +#include "vserver/base.h"
13723 +#include "vserver/check.h"
13724 +#include "vserver/debug.h"
13726 +#include <linux/sched.h>
13729 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
13731 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
13732 + const char *_file, int _line)
13737 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
13738 + nxi, nxi ? nxi->nx_id : 0,
13739 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13742 + atomic_inc(&nxi->nx_usecnt);
13747 +extern void free_nx_info(struct nx_info *);
13749 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
13751 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
13756 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
13757 + nxi, nxi ? nxi->nx_id : 0,
13758 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13761 + if (atomic_dec_and_test(&nxi->nx_usecnt))
13762 + free_nx_info(nxi);
13766 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
13768 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
13769 + const char *_file, int _line)
13772 + vxlprintk(VXD_CBIT(nid, 3),
13773 + "init_nx_info(%p[#%d.%d])",
13774 + nxi, nxi ? nxi->nx_id : 0,
13775 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13778 + atomic_inc(&nxi->nx_usecnt);
13784 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
13786 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
13787 + const char *_file, int _line)
13789 + struct nx_info *nxo;
13794 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
13795 + nxi, nxi ? nxi->nx_id : 0,
13796 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13799 + atomic_inc(&nxi->nx_usecnt);
13800 + nxo = xchg(nxp, nxi);
13804 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
13806 +static inline void __clr_nx_info(struct nx_info **nxp,
13807 + const char *_file, int _line)
13809 + struct nx_info *nxo;
13811 + nxo = xchg(nxp, NULL);
13815 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
13816 + nxo, nxo ? nxo->nx_id : 0,
13817 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
13820 + if (atomic_dec_and_test(&nxo->nx_usecnt))
13821 + free_nx_info(nxo);
13825 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
13827 +static inline void __claim_nx_info(struct nx_info *nxi,
13828 + struct task_struct *task, const char *_file, int _line)
13830 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
13831 + nxi, nxi ? nxi->nx_id : 0,
13832 + nxi?atomic_read(&nxi->nx_usecnt):0,
13833 + nxi?atomic_read(&nxi->nx_tasks):0,
13834 + task, _file, _line);
13836 + atomic_inc(&nxi->nx_tasks);
13840 +extern void unhash_nx_info(struct nx_info *);
13842 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
13844 +static inline void __release_nx_info(struct nx_info *nxi,
13845 + struct task_struct *task, const char *_file, int _line)
13847 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
13848 + nxi, nxi ? nxi->nx_id : 0,
13849 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13850 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
13851 + task, _file, _line);
13855 + if (atomic_dec_and_test(&nxi->nx_tasks))
13856 + unhash_nx_info(nxi);
13860 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
13862 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
13863 + const char *_file, int _line)
13865 + struct nx_info *nxi;
13868 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
13869 + p, _file, _line);
13870 + nxi = __get_nx_info(p->nx_info, _file, _line);
13876 +static inline void exit_nx_info(struct task_struct *p)
13879 + release_nx_info(p->nx_info, p);
13884 +#warning duplicate inclusion
13886 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_pid.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_pid.h
13887 --- linux-2.6.27.3/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
13888 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_pid.h 2008-10-13 14:54:20.000000000 +0200
13893 +#include "vserver/base.h"
13894 +#include "vserver/check.h"
13895 +#include "vserver/context.h"
13896 +#include "vserver/debug.h"
13897 +#include "vserver/pid.h"
13898 +#include <linux/pid_namespace.h>
13901 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
13904 +int vx_proc_task_visible(struct task_struct *task)
13906 + if ((task->pid == 1) &&
13907 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
13908 + /* show a blend through init */
13910 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
13917 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
13922 +struct task_struct *vx_find_proc_task_by_pid(int pid)
13924 + struct task_struct *task = find_task_by_real_pid(pid);
13926 + if (task && !vx_proc_task_visible(task)) {
13927 + vxdprintk(VXD_CBIT(misc, 6),
13928 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
13929 + task, task->xid, task->pid,
13930 + current, current->xid, current->pid);
13939 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
13941 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
13943 + if (task && !vx_proc_task_visible(task)) {
13944 + vxdprintk(VXD_CBIT(misc, 6),
13945 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
13946 + task, task->xid, task->pid,
13947 + current, current->xid, current->pid);
13948 + put_task_struct(task);
13957 +struct task_struct *vx_child_reaper(struct task_struct *p)
13959 + struct vx_info *vxi = p->vx_info;
13960 + struct task_struct *reaper = child_reaper(p);
13965 + BUG_ON(!p->vx_info->vx_reaper);
13967 + /* child reaper for the guest reaper */
13968 + if (vxi->vx_reaper == p)
13971 + reaper = vxi->vx_reaper;
13973 + vxdprintk(VXD_CBIT(xid, 7),
13974 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
13975 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
13983 +#warning duplicate inclusion
13985 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_sched.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_sched.h
13986 --- linux-2.6.27.3/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
13987 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_sched.h 2008-10-13 14:54:20.000000000 +0200
13989 +#ifndef _VS_SCHED_H
13990 +#define _VS_SCHED_H
13992 +#include "vserver/base.h"
13993 +#include "vserver/context.h"
13994 +#include "vserver/sched.h"
13997 +#define VAVAVOOM_RATIO 50
13999 +#define MAX_PRIO_BIAS 20
14000 +#define MIN_PRIO_BIAS -20
14003 +#ifdef CONFIG_VSERVER_HARDCPU
14006 + * effective_prio - return the priority that is based on the static
14007 + * priority but is modified by bonuses/penalties.
14009 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14010 + * into a -4 ... 0 ... +4 bonus/penalty range.
14012 + * Additionally, we scale another amount based on the number of
14013 + * CPU tokens currently held by the context, if the process is
14014 + * part of a context (and the appropriate SCHED flag is set).
14015 + * This ranges from -5 ... 0 ... +15, quadratically.
14017 + * So, the total bonus is -9 .. 0 .. +19
14018 + * We use ~50% of the full 0...39 priority range so that:
14020 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14021 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14022 + * unless that context is far exceeding its CPU allocation.
14024 + * Both properties are important to certain workloads.
14027 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14029 + int vavavoom, max;
14031 + /* lots of tokens = lots of vavavoom
14032 + * no tokens = no vavavoom */
14033 + if ((vavavoom = sched_pc->tokens) >= 0) {
14034 + max = sched_pc->tokens_max;
14035 + vavavoom = max - vavavoom;
14037 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14038 + * (vavavoom*vavavoom - (max >> 2)) / max;
14046 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14048 + struct vx_info *vxi = p->vx_info;
14049 + struct _vx_sched_pc *sched_pc;
14054 + sched_pc = &vx_cpu(vxi, sched_pc);
14055 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14056 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14058 + sched_pc->vavavoom = vavavoom;
14059 + prio += vavavoom;
14061 + prio += sched_pc->prio_bias;
14065 +#else /* !CONFIG_VSERVER_HARDCPU */
14068 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14070 + struct vx_info *vxi = p->vx_info;
14073 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14077 +#endif /* CONFIG_VSERVER_HARDCPU */
14080 +static inline void vx_account_user(struct vx_info *vxi,
14081 + cputime_t cputime, int nice)
14085 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14088 +static inline void vx_account_system(struct vx_info *vxi,
14089 + cputime_t cputime, int idle)
14093 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14097 +#warning duplicate inclusion
14099 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_socket.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_socket.h
14100 --- linux-2.6.27.3/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14101 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_socket.h 2008-10-13 14:54:20.000000000 +0200
14103 +#ifndef _VS_SOCKET_H
14104 +#define _VS_SOCKET_H
14106 +#include "vserver/debug.h"
14107 +#include "vserver/base.h"
14108 +#include "vserver/cacct.h"
14109 +#include "vserver/context.h"
14110 +#include "vserver/tag.h"
14113 +/* socket accounting */
14115 +#include <linux/socket.h>
14117 +static inline int vx_sock_type(int family)
14119 + switch (family) {
14121 + return VXA_SOCK_UNSPEC;
14123 + return VXA_SOCK_UNIX;
14125 + return VXA_SOCK_INET;
14127 + return VXA_SOCK_INET6;
14129 + return VXA_SOCK_PACKET;
14131 + return VXA_SOCK_OTHER;
14135 +#define vx_acc_sock(v, f, p, s) \
14136 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14138 +static inline void __vx_acc_sock(struct vx_info *vxi,
14139 + int family, int pos, int size, char *file, int line)
14142 + int type = vx_sock_type(family);
14144 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14145 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14149 +#define vx_sock_recv(sk, s) \
14150 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14151 +#define vx_sock_send(sk, s) \
14152 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14153 +#define vx_sock_fail(sk, s) \
14154 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14157 +#define sock_vx_init(s) do { \
14158 + (s)->sk_xid = 0; \
14159 + (s)->sk_vx_info = NULL; \
14162 +#define sock_nx_init(s) do { \
14163 + (s)->sk_nid = 0; \
14164 + (s)->sk_nx_info = NULL; \
14168 +#warning duplicate inclusion
14170 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_tag.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_tag.h
14171 --- linux-2.6.27.3/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14172 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_tag.h 2008-10-24 03:34:52.000000000 +0200
14177 +#include <linux/vserver/tag.h>
14179 +/* check conditions */
14181 +#define DX_ADMIN 0x0001
14182 +#define DX_WATCH 0x0002
14183 +#define DX_HOSTID 0x0008
14185 +#define DX_IDENT 0x0010
14187 +#define DX_ARG_MASK 0x0010
14190 +#define dx_task_tag(t) ((t)->tag)
14192 +#define dx_current_tag() dx_task_tag(current)
14194 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14196 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14200 + * check current context for ADMIN/WATCH and
14201 + * optionally against supplied argument
14203 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14205 + if (mode & DX_ARG_MASK) {
14206 + if ((mode & DX_IDENT) && (id == cid))
14209 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14210 + ((mode & DX_WATCH) && (cid == 1)) ||
14211 + ((mode & DX_HOSTID) && (id == 0)));
14215 +int dx_permission(struct inode *inode, int mask);
14219 +#warning duplicate inclusion
14221 diff -NurpP --minimal linux-2.6.27.3/include/linux/vs_time.h linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_time.h
14222 --- linux-2.6.27.3/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14223 +++ linux-2.6.27.3-vs2.3.0.35.7/include/linux/vs_time.h 2008-10-13 14:54:20.000000000 +0200
14225 +#ifndef _VS_TIME_H
14226 +#define _VS_TIME_H
14229 +/* time faking stuff */
14231 +#ifdef CONFIG_VSERVER_VTIME
14233 +extern void vx_gettimeofday(struct timeval *tv);
14234 +extern int vx_settimeofday(struct timespec *ts);
14237 +#define vx_gettimeofday(t) do_gettimeofday(t)
14238 +#define vx_settimeofday(t) do_settimeofday(t)
14242 +#warning duplicate inclusion
14244 diff -NurpP --minimal linux-2.6.27.3/include/net/addrconf.h linux-2.6.27.3-vs2.3.0.35.7/include/net/addrconf.h
14245 --- linux-2.6.27.3/include/net/addrconf.h 2008-10-13 14:52:09.000000000 +0200
14246 +++ linux-2.6.27.3-vs2.3.0.35.7/include/net/addrconf.h 2008-10-13 14:54:20.000000000 +0200
14247 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14248 struct net_device *dev,
14249 const struct in6_addr *daddr,
14250 unsigned int srcprefs,
14251 - struct in6_addr *saddr);
14252 + struct in6_addr *saddr,
14253 + struct nx_info *nxi);
14254 extern int ipv6_get_lladdr(struct net_device *dev,
14255 struct in6_addr *addr,
14256 unsigned char banned_flags);
14257 diff -NurpP --minimal linux-2.6.27.3/include/net/af_unix.h linux-2.6.27.3-vs2.3.0.35.7/include/net/af_unix.h
14258 --- linux-2.6.27.3/include/net/af_unix.h 2008-10-13 14:52:09.000000000 +0200
14259 +++ linux-2.6.27.3-vs2.3.0.35.7/include/net/af_unix.h 2008-10-13 14:54:20.000000000 +0200
14261 #include <linux/socket.h>
14262 #include <linux/un.h>
14263 #include <linux/mutex.h>
14264 +#include <linux/vs_base.h>
14265 #include <net/sock.h>
14267 extern void unix_inflight(struct file *fp);
14268 diff -NurpP --minimal linux-2.6.27.3/include/net/inet_sock.h linux-2.6.27.3-vs2.3.0.35.7/include/net/inet_sock.h
14269 --- linux-2.6.27.3/include/net/inet_sock.h 2008-10-13 14:52:09.000000000 +0200
14270 +++ linux-2.6.27.3-vs2.3.0.35.7/include/net/inet_sock.h 2008-10-13 14:54:20.000000000 +0200
14272 #include <net/flow.h>
14273 #include <net/sock.h>
14274 #include <net/request_sock.h>
14275 -#include <net/route.h>
14276 +// #include <net/route.h>
14277 #include <net/netns/hash.h>
14279 /** struct ip_options - IP Options
14280 @@ -195,11 +195,6 @@ static inline int inet_sk_ehashfn(const
14284 -static inline int inet_iif(const struct sk_buff *skb)
14286 - return skb->rtable->rt_iif;
14289 static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops)
14291 struct request_sock *req = reqsk_alloc(ops);
14292 diff -NurpP --minimal linux-2.6.27.3/include/net/inet_timewait_sock.h linux-2.6.27.3-vs2.3.0.35.7/include/net/inet_timewait_sock.h
14293 --- linux-2.6.27.3/include/net/inet_timewait_sock.h 2008-10-13 14:52:09.000000000 +0200
14294 +++ linux-2.6.27.3-vs2.3.0.35.7/include/net/inet_timewait_sock.h 2008-10-13 14:54:20.000000000 +0200
14295 @@ -15,15 +15,14 @@
14296 #ifndef _INET_TIMEWAIT_SOCK_
14297 #define _INET_TIMEWAIT_SOCK_
14299 +// #include <net/inet_sock.h>
14300 +#include <net/sock.h>
14302 #include <linux/list.h>
14303 #include <linux/module.h>
14304 #include <linux/timer.h>
14305 #include <linux/types.h>
14306 #include <linux/workqueue.h>
14308 -#include <net/inet_sock.h>
14309 -#include <net/sock.h>
14310 #include <net/tcp_states.h>
14311 #include <net/timewait_sock.h>
14313 @@ -116,6 +115,10 @@ struct inet_timewait_sock {
14314 #define tw_hash __tw_common.skc_hash
14315 #define tw_prot __tw_common.skc_prot
14316 #define tw_net __tw_common.skc_net
14317 +#define tw_xid __tw_common.skc_xid
14318 +#define tw_vx_info __tw_common.skc_vx_info
14319 +#define tw_nid __tw_common.skc_nid
14320 +#define tw_nx_info __tw_common.skc_nx_info
14322 volatile unsigned char tw_substate;
14323 /* 3 bits hole, try to pack */
14324 diff -NurpP --minimal linux-2.6.27.3/include/net/route.h linux-2.6.27.3-vs2.3.0.35.7/include/net/route.h
14325 --- linux-2.6.27.3/include/net/route.h 2008-10-13 14:52:09.000000000 +0200
14326 +++ linux-2.6.27.3-vs2.3.0.35.7/include/net/route.h 2008-10-13 14:54:20.000000000 +0200
14328 #include <net/inetpeer.h>
14329 #include <net/flow.h>
14330 #include <net/sock.h>
14331 +// #include <linux/in.h>
14332 #include <linux/in_route.h>
14333 #include <linux/rtnetlink.h>
14334 #include <linux/route.h>
14335 @@ -85,6 +86,11 @@ struct ip_rt_acct
14339 +static inline int inet_iif(const struct sk_buff *skb)
14341 + return skb->rtable->rt_iif;
14344 struct rt_cache_stat
14346 unsigned int in_hit;
14347 @@ -135,6 +141,9 @@ static inline void ip_rt_put(struct rtab
14348 dst_release(&rt->u.dst);
14351 +#include <linux/vs_base.h>
14352 +#include <linux/vs_inet.h>
14354 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14356 extern const __u8 ip_tos2prio[16];
14357 @@ -144,6 +153,9 @@ static inline char rt_tos2priority(u8 to
14358 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14361 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14362 + struct rtable **, struct flowi *);
14364 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14365 __be32 src, u32 tos, int oif, u8 protocol,
14366 __be16 sport, __be16 dport, struct sock *sk,
14367 @@ -161,7 +173,21 @@ static inline int ip_route_connect(struc
14370 struct net *net = sock_net(sk);
14371 - if (!dst || !src) {
14372 + struct nx_info *nx_info = current->nx_info;
14375 + nx_info = sk->sk_nx_info;
14377 + vxdprintk(VXD_CBIT(net, 4),
14378 + "ip_route_connect(%p) %p,%p;%lx",
14379 + sk, nx_info, sk->sk_socket,
14380 + (sk->sk_socket?sk->sk_socket->flags:0));
14382 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14386 + if (!fl.fl4_dst || !fl.fl4_src) {
14387 err = __ip_route_output_key(net, rp, &fl);
14390 diff -NurpP --minimal linux-2.6.27.3/include/net/sock.h linux-2.6.27.3-vs2.3.0.35.7/include/net/sock.h
14391 --- linux-2.6.27.3/include/net/sock.h 2008-10-13 14:52:09.000000000 +0200
14392 +++ linux-2.6.27.3-vs2.3.0.35.7/include/net/sock.h 2008-10-13 14:54:20.000000000 +0200
14393 @@ -128,6 +128,10 @@ struct sock_common {
14394 #ifdef CONFIG_NET_NS
14395 struct net *skc_net;
14398 + struct vx_info *skc_vx_info;
14400 + struct nx_info *skc_nx_info;
14404 @@ -211,6 +215,10 @@ struct sock {
14405 #define sk_hash __sk_common.skc_hash
14406 #define sk_prot __sk_common.skc_prot
14407 #define sk_net __sk_common.skc_net
14408 +#define sk_xid __sk_common.skc_xid
14409 +#define sk_vx_info __sk_common.skc_vx_info
14410 +#define sk_nid __sk_common.skc_nid
14411 +#define sk_nx_info __sk_common.skc_nx_info
14412 unsigned char sk_shutdown : 2,
14415 diff -NurpP --minimal linux-2.6.27.3/init/main.c linux-2.6.27.3-vs2.3.0.35.7/init/main.c
14416 --- linux-2.6.27.3/init/main.c 2008-10-13 14:52:09.000000000 +0200
14417 +++ linux-2.6.27.3-vs2.3.0.35.7/init/main.c 2008-10-13 14:54:20.000000000 +0200
14419 #include <linux/sched.h>
14420 #include <linux/signal.h>
14421 #include <linux/idr.h>
14422 +#include <linux/vserver/percpu.h>
14424 #include <asm/io.h>
14425 #include <asm/bugs.h>
14426 @@ -391,12 +392,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
14428 static void __init setup_per_cpu_areas(void)
14430 - unsigned long size, i;
14431 + unsigned long size, vspc, i;
14433 unsigned long nr_possible_cpus = num_possible_cpus();
14435 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
14437 /* Copy section for each CPU (we discard the original) */
14438 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
14439 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
14440 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
14442 for_each_possible_cpu(i) {
14443 diff -NurpP --minimal linux-2.6.27.3/ipc/mqueue.c linux-2.6.27.3-vs2.3.0.35.7/ipc/mqueue.c
14444 --- linux-2.6.27.3/ipc/mqueue.c 2008-10-13 14:52:09.000000000 +0200
14445 +++ linux-2.6.27.3-vs2.3.0.35.7/ipc/mqueue.c 2008-10-13 14:54:20.000000000 +0200
14447 #include <linux/mutex.h>
14448 #include <linux/nsproxy.h>
14449 #include <linux/pid.h>
14450 +#include <linux/vs_context.h>
14451 +#include <linux/vs_limit.h>
14453 #include <net/sock.h>
14455 @@ -71,6 +73,7 @@ struct mqueue_inode_info {
14456 struct sigevent notify;
14457 struct pid* notify_owner;
14458 struct user_struct *user; /* user who created, for accounting */
14459 + struct vx_info *vxi;
14460 struct sock *notify_sock;
14461 struct sk_buff *notify_cookie;
14463 @@ -119,6 +122,7 @@ static struct inode *mqueue_get_inode(st
14464 struct mqueue_inode_info *info;
14465 struct task_struct *p = current;
14466 struct user_struct *u = p->user;
14467 + struct vx_info *vxi = p->vx_info;
14468 unsigned long mq_bytes, mq_msg_tblsz;
14470 inode->i_fop = &mqueue_file_operations;
14471 @@ -133,6 +137,7 @@ static struct inode *mqueue_get_inode(st
14472 info->notify_owner = NULL;
14474 info->user = NULL; /* set when all is ok */
14475 + info->vxi = NULL;
14476 memset(&info->attr, 0, sizeof(info->attr));
14477 info->attr.mq_maxmsg = DFLT_MSGMAX;
14478 info->attr.mq_msgsize = DFLT_MSGSIZEMAX;
14479 @@ -147,22 +152,26 @@ static struct inode *mqueue_get_inode(st
14480 spin_lock(&mq_lock);
14481 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14482 u->mq_bytes + mq_bytes >
14483 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
14484 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
14485 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14486 spin_unlock(&mq_lock);
14489 u->mq_bytes += mq_bytes;
14490 + vx_ipcmsg_add(vxi, u, mq_bytes);
14491 spin_unlock(&mq_lock);
14493 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
14494 if (!info->messages) {
14495 spin_lock(&mq_lock);
14496 u->mq_bytes -= mq_bytes;
14497 + vx_ipcmsg_sub(vxi, u, mq_bytes);
14498 spin_unlock(&mq_lock);
14502 info->user = get_uid(u);
14503 + info->vxi = get_vx_info(vxi);
14504 } else if (S_ISDIR(mode)) {
14506 /* Some things misbehave if size == 0 on a directory */
14507 @@ -253,10 +262,14 @@ static void mqueue_delete_inode(struct i
14508 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
14511 + struct vx_info *vxi = info->vxi;
14513 spin_lock(&mq_lock);
14514 user->mq_bytes -= mq_bytes;
14515 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14517 spin_unlock(&mq_lock);
14518 + put_vx_info(vxi);
14522 diff -NurpP --minimal linux-2.6.27.3/ipc/msg.c linux-2.6.27.3-vs2.3.0.35.7/ipc/msg.c
14523 --- linux-2.6.27.3/ipc/msg.c 2008-07-13 23:51:29.000000000 +0200
14524 +++ linux-2.6.27.3-vs2.3.0.35.7/ipc/msg.c 2008-10-13 14:54:20.000000000 +0200
14526 #include <linux/rwsem.h>
14527 #include <linux/nsproxy.h>
14528 #include <linux/ipc_namespace.h>
14529 +#include <linux/vs_base.h>
14531 #include <asm/current.h>
14532 #include <asm/uaccess.h>
14533 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14535 msq->q_perm.mode = msgflg & S_IRWXUGO;
14536 msq->q_perm.key = key;
14537 + msq->q_perm.xid = vx_current_xid();
14539 msq->q_perm.security = NULL;
14540 retval = security_msg_queue_alloc(msq);
14541 diff -NurpP --minimal linux-2.6.27.3/ipc/namespace.c linux-2.6.27.3-vs2.3.0.35.7/ipc/namespace.c
14542 --- linux-2.6.27.3/ipc/namespace.c 2008-07-13 23:51:29.000000000 +0200
14543 +++ linux-2.6.27.3-vs2.3.0.35.7/ipc/namespace.c 2008-10-13 14:54:20.000000000 +0200
14545 #include <linux/rcupdate.h>
14546 #include <linux/nsproxy.h>
14547 #include <linux/slab.h>
14548 +#include <linux/vs_base.h>
14549 +#include <linux/vserver/global.h>
14553 @@ -35,6 +37,7 @@ static struct ipc_namespace *clone_ipc_n
14554 register_ipcns_notifier(ns);
14556 kref_init(&ns->kref);
14557 + atomic_inc(&vs_global_ipc_ns);
14561 @@ -101,6 +104,7 @@ void free_ipc_ns(struct kref *kref)
14565 + atomic_dec(&vs_global_ipc_ns);
14567 atomic_dec(&nr_ipc_ns);
14569 diff -NurpP --minimal linux-2.6.27.3/ipc/sem.c linux-2.6.27.3-vs2.3.0.35.7/ipc/sem.c
14570 --- linux-2.6.27.3/ipc/sem.c 2008-10-13 14:52:09.000000000 +0200
14571 +++ linux-2.6.27.3-vs2.3.0.35.7/ipc/sem.c 2008-10-13 14:54:20.000000000 +0200
14573 #include <linux/rwsem.h>
14574 #include <linux/nsproxy.h>
14575 #include <linux/ipc_namespace.h>
14576 +#include <linux/vs_base.h>
14577 +#include <linux/vs_limit.h>
14579 #include <asm/uaccess.h>
14581 @@ -255,6 +257,7 @@ static int newary(struct ipc_namespace *
14583 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14584 sma->sem_perm.key = key;
14585 + sma->sem_perm.xid = vx_current_xid();
14587 sma->sem_perm.security = NULL;
14588 retval = security_sem_alloc(sma);
14589 @@ -270,6 +273,9 @@ static int newary(struct ipc_namespace *
14592 ns->used_sems += nsems;
14593 + /* FIXME: obsoleted? */
14594 + vx_semary_inc(sma);
14595 + vx_nsems_add(sma, nsems);
14597 sma->sem_base = (struct sem *) &sma[1];
14598 INIT_LIST_HEAD(&sma->sem_pending);
14599 diff -NurpP --minimal linux-2.6.27.3/ipc/shm.c linux-2.6.27.3-vs2.3.0.35.7/ipc/shm.c
14600 --- linux-2.6.27.3/ipc/shm.c 2008-10-13 14:52:09.000000000 +0200
14601 +++ linux-2.6.27.3-vs2.3.0.35.7/ipc/shm.c 2008-10-13 14:54:20.000000000 +0200
14603 #include <linux/nsproxy.h>
14604 #include <linux/mount.h>
14605 #include <linux/ipc_namespace.h>
14606 +#include <linux/vs_context.h>
14607 +#include <linux/vs_limit.h>
14609 #include <asm/uaccess.h>
14611 @@ -168,7 +170,12 @@ static void shm_open(struct vm_area_stru
14613 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14615 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14616 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14617 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14619 + vx_ipcshm_sub(vxi, shp, numpages);
14620 + ns->shm_tot -= numpages;
14624 if (!is_file_hugepages(shp->shm_file))
14625 @@ -178,6 +185,7 @@ static void shm_destroy(struct ipc_names
14627 fput (shp->shm_file);
14628 security_shm_free(shp);
14629 + put_vx_info(vxi);
14630 ipc_rcu_putref(shp);
14633 @@ -347,11 +355,15 @@ static int newseg(struct ipc_namespace *
14634 if (ns->shm_tot + numpages > ns->shm_ctlall)
14637 + if (!vx_ipcshm_avail(current->vx_info, numpages))
14640 shp = ipc_rcu_alloc(sizeof(*shp));
14644 shp->shm_perm.key = key;
14645 + shp->shm_perm.xid = vx_current_xid();
14646 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14647 shp->mlock_user = NULL;
14649 @@ -404,6 +416,7 @@ static int newseg(struct ipc_namespace *
14650 ns->shm_tot += numpages;
14651 error = shp->shm_perm.id;
14653 + vx_ipcshm_add(current->vx_info, key, numpages);
14657 diff -NurpP --minimal linux-2.6.27.3/kernel/capability.c linux-2.6.27.3-vs2.3.0.35.7/kernel/capability.c
14658 --- linux-2.6.27.3/kernel/capability.c 2008-10-13 14:52:09.000000000 +0200
14659 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/capability.c 2008-10-13 14:54:20.000000000 +0200
14661 #include <linux/security.h>
14662 #include <linux/syscalls.h>
14663 #include <linux/pid_namespace.h>
14664 +#include <linux/vs_context.h>
14665 #include <asm/uaccess.h>
14668 @@ -166,6 +167,8 @@ static inline int cap_set_pg(int pgrp_nr
14670 pgrp = find_vpid(pgrp_nr);
14671 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
14672 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
14675 while_each_thread(g, target) {
14676 if (!security_capset_check(target, effective,
14677 @@ -486,6 +489,8 @@ asmlinkage long sys_capset(cap_user_head
14681 +#include <linux/vserver/base.h>
14684 * capable - Determine if the current task has a superior capability in effect
14685 * @cap: The capability to be tested for
14686 @@ -498,6 +503,9 @@ asmlinkage long sys_capset(cap_user_head
14688 int capable(int cap)
14690 + /* here for now so we don't require task locking */
14691 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
14693 if (has_capability(current, cap)) {
14694 current->flags |= PF_SUPERPRIV;
14696 diff -NurpP --minimal linux-2.6.27.3/kernel/compat.c linux-2.6.27.3-vs2.3.0.35.7/kernel/compat.c
14697 --- linux-2.6.27.3/kernel/compat.c 2008-07-13 23:51:29.000000000 +0200
14698 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/compat.c 2008-10-13 14:54:20.000000000 +0200
14699 @@ -845,7 +845,7 @@ asmlinkage long compat_sys_time(compat_t
14703 - do_gettimeofday(&tv);
14704 + vx_gettimeofday(&tv);
14708 @@ -869,7 +869,7 @@ asmlinkage long compat_sys_stime(compat_
14712 - do_settimeofday(&tv);
14713 + vx_settimeofday(&tv);
14717 diff -NurpP --minimal linux-2.6.27.3/kernel/exit.c linux-2.6.27.3-vs2.3.0.35.7/kernel/exit.c
14718 --- linux-2.6.27.3/kernel/exit.c 2008-10-13 14:52:09.000000000 +0200
14719 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/exit.c 2008-10-13 14:54:20.000000000 +0200
14721 #include <linux/blkdev.h>
14722 #include <linux/task_io_accounting_ops.h>
14723 #include <linux/tracehook.h>
14724 +#include <linux/vs_limit.h>
14725 +#include <linux/vs_context.h>
14726 +#include <linux/vs_network.h>
14727 +#include <linux/vs_pid.h>
14728 +#include <linux/vserver/global.h>
14730 #include <asm/uaccess.h>
14731 #include <asm/unistd.h>
14732 @@ -485,9 +490,11 @@ static void close_files(struct files_str
14733 filp_close(file, files);
14736 + vx_openfd_dec(i);
14744 @@ -554,6 +561,7 @@ void put_fs_struct(struct fs_struct *fs)
14745 if (atomic_dec_and_test(&fs->count)) {
14746 path_put(&fs->root);
14747 path_put(&fs->pwd);
14748 + atomic_dec(&vs_global_fs);
14749 kmem_cache_free(fs_cachep, fs);
14752 @@ -1122,6 +1130,10 @@ NORET_TYPE void do_exit(long code)
14753 if (tsk->splice_pipe)
14754 __free_pipe_info(tsk->splice_pipe);
14756 + /* needs to stay after exit_notify() */
14757 + exit_vx_info(tsk, code);
14758 + exit_nx_info(tsk);
14761 /* causes final put_task_struct in finish_task_switch(). */
14762 tsk->state = TASK_DEAD;
14763 diff -NurpP --minimal linux-2.6.27.3/kernel/fork.c linux-2.6.27.3-vs2.3.0.35.7/kernel/fork.c
14764 --- linux-2.6.27.3/kernel/fork.c 2008-10-13 14:52:09.000000000 +0200
14765 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/fork.c 2008-10-13 14:54:20.000000000 +0200
14767 #include <linux/tty.h>
14768 #include <linux/proc_fs.h>
14769 #include <linux/blkdev.h>
14770 +#include <linux/vs_context.h>
14771 +#include <linux/vs_network.h>
14772 +#include <linux/vs_limit.h>
14773 +#include <linux/vs_memory.h>
14774 +#include <linux/vserver/global.h>
14776 #include <asm/pgtable.h>
14777 #include <asm/pgalloc.h>
14778 @@ -135,6 +140,8 @@ void free_task(struct task_struct *tsk)
14779 prop_local_destroy_single(&tsk->dirties);
14780 free_thread_info(tsk->stack);
14781 rt_mutex_debug_task_free(tsk);
14782 + clr_vx_info(&tsk->vx_info);
14783 + clr_nx_info(&tsk->nx_info);
14784 free_task_struct(tsk);
14786 EXPORT_SYMBOL(free_task);
14787 @@ -274,6 +281,8 @@ static int dup_mmap(struct mm_struct *mm
14788 mm->free_area_cache = oldmm->mmap_base;
14789 mm->cached_hole_size = ~0UL;
14791 + __set_mm_counter(mm, file_rss, 0);
14792 + __set_mm_counter(mm, anon_rss, 0);
14793 cpus_clear(mm->cpu_vm_mask);
14794 mm->mm_rb = RB_ROOT;
14795 rb_link = &mm->mm_rb.rb_node;
14796 @@ -285,7 +294,7 @@ static int dup_mmap(struct mm_struct *mm
14798 if (mpnt->vm_flags & VM_DONTCOPY) {
14799 long pages = vma_pages(mpnt);
14800 - mm->total_vm -= pages;
14801 + vx_vmpages_sub(mm, pages);
14802 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
14805 @@ -404,8 +413,8 @@ static struct mm_struct * mm_init(struct
14806 : MMF_DUMP_FILTER_DEFAULT;
14807 mm->core_state = NULL;
14809 - set_mm_counter(mm, file_rss, 0);
14810 - set_mm_counter(mm, anon_rss, 0);
14811 + __set_mm_counter(mm, file_rss, 0);
14812 + __set_mm_counter(mm, anon_rss, 0);
14813 spin_lock_init(&mm->page_table_lock);
14814 rwlock_init(&mm->ioctx_list_lock);
14815 mm->ioctx_list = NULL;
14816 @@ -416,6 +425,7 @@ static struct mm_struct * mm_init(struct
14817 if (likely(!mm_alloc_pgd(mm))) {
14819 mmu_notifier_mm_init(mm);
14820 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14824 @@ -449,6 +459,7 @@ void __mmdrop(struct mm_struct *mm)
14826 destroy_context(mm);
14827 mmu_notifier_mm_destroy(mm);
14828 + clr_vx_info(&mm->mm_vx_info);
14831 EXPORT_SYMBOL_GPL(__mmdrop);
14832 @@ -565,6 +576,7 @@ struct mm_struct *dup_mm(struct task_str
14835 memcpy(mm, oldmm, sizeof(*mm));
14836 + mm->mm_vx_info = NULL;
14838 /* Initializing for Swap token stuff */
14839 mm->token_priority = 0;
14840 @@ -598,6 +610,7 @@ fail_nocontext:
14841 * If init_new_context() failed, we cannot use mmput() to free the mm
14842 * because it calls destroy_context()
14844 + clr_vx_info(&mm->mm_vx_info);
14848 @@ -661,6 +674,7 @@ static struct fs_struct *__copy_fs_struc
14849 fs->pwd = old->pwd;
14850 path_get(&old->pwd);
14851 read_unlock(&old->lock);
14852 + atomic_inc(&vs_global_fs);
14856 @@ -904,6 +918,8 @@ static struct task_struct *copy_process(
14858 struct task_struct *p;
14859 int cgroup_callbacks_done = 0;
14860 + struct vx_info *vxi;
14861 + struct nx_info *nxi;
14863 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14864 return ERR_PTR(-EINVAL);
14865 @@ -938,12 +954,28 @@ static struct task_struct *copy_process(
14866 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14867 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14869 + init_vx_info(&p->vx_info, current->vx_info);
14870 + init_nx_info(&p->nx_info, current->nx_info);
14872 + /* check vserver memory */
14873 + if (p->mm && !(clone_flags & CLONE_VM)) {
14874 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
14875 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
14877 + goto bad_fork_free;
14879 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
14880 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
14881 + goto bad_fork_cleanup_vm;
14884 + if (!vx_nproc_avail(1))
14885 + goto bad_fork_cleanup_vm;
14886 if (atomic_read(&p->user->processes) >=
14887 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
14888 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14889 p->user != current->nsproxy->user_ns->root_user)
14890 - goto bad_fork_free;
14891 + goto bad_fork_cleanup_vm;
14894 atomic_inc(&p->user->__count);
14895 @@ -1241,6 +1273,18 @@ static struct task_struct *copy_process(
14898 spin_unlock(¤t->sighand->siglock);
14900 + /* p is copy of current */
14901 + vxi = p->vx_info;
14903 + claim_vx_info(vxi, p);
14904 + atomic_inc(&vxi->cvirt.nr_threads);
14905 + atomic_inc(&vxi->cvirt.total_forks);
14908 + nxi = p->nx_info;
14910 + claim_nx_info(nxi, p);
14911 write_unlock_irq(&tasklist_lock);
14912 proc_fork_connector(p);
14913 cgroup_post_fork(p);
14914 @@ -1287,6 +1331,9 @@ bad_fork_cleanup_count:
14915 put_group_info(p->group_info);
14916 atomic_dec(&p->user->processes);
14918 +bad_fork_cleanup_vm:
14919 + if (p->mm && !(clone_flags & CLONE_VM))
14920 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
14924 diff -NurpP --minimal linux-2.6.27.3/kernel/kthread.c linux-2.6.27.3-vs2.3.0.35.7/kernel/kthread.c
14925 --- linux-2.6.27.3/kernel/kthread.c 2008-10-13 14:52:09.000000000 +0200
14926 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/kthread.c 2008-10-13 14:54:20.000000000 +0200
14928 #include <linux/file.h>
14929 #include <linux/module.h>
14930 #include <linux/mutex.h>
14931 +#include <linux/vs_pid.h>
14933 #define KTHREAD_NICE_LEVEL (-5)
14935 @@ -98,7 +99,7 @@ static void create_kthread(struct kthrea
14936 struct sched_param param = { .sched_priority = 0 };
14937 wait_for_completion(&create->started);
14938 read_lock(&tasklist_lock);
14939 - create->result = find_task_by_pid_ns(pid, &init_pid_ns);
14940 + create->result = find_task_by_real_pid(pid);
14941 read_unlock(&tasklist_lock);
14943 * root may have changed our (kthreadd's) priority or CPU mask.
14944 diff -NurpP --minimal linux-2.6.27.3/kernel/Makefile linux-2.6.27.3-vs2.3.0.35.7/kernel/Makefile
14945 --- linux-2.6.27.3/kernel/Makefile 2008-10-13 14:52:09.000000000 +0200
14946 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/Makefile 2008-10-13 14:54:20.000000000 +0200
14947 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
14948 CFLAGS_REMOVE_sched.o = -mno-spe -pg
14952 obj-$(CONFIG_PROFILING) += profile.o
14953 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14954 obj-$(CONFIG_STACKTRACE) += stacktrace.o
14955 diff -NurpP --minimal linux-2.6.27.3/kernel/nsproxy.c linux-2.6.27.3-vs2.3.0.35.7/kernel/nsproxy.c
14956 --- linux-2.6.27.3/kernel/nsproxy.c 2008-10-13 14:52:09.000000000 +0200
14957 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/nsproxy.c 2008-10-13 14:54:20.000000000 +0200
14959 #include <linux/mnt_namespace.h>
14960 #include <linux/utsname.h>
14961 #include <linux/pid_namespace.h>
14962 +#include <linux/vserver/global.h>
14963 +#include <linux/vserver/debug.h>
14964 #include <net/net_namespace.h>
14965 #include <linux/ipc_namespace.h>
14967 @@ -37,6 +39,9 @@ static inline struct nsproxy *clone_nspr
14969 memcpy(ns, orig, sizeof(struct nsproxy));
14970 atomic_set(&ns->count, 1);
14971 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
14972 + orig, atomic_read(&orig->count), ns);
14973 + atomic_inc(&vs_global_nsproxy);
14977 @@ -46,47 +51,51 @@ static inline struct nsproxy *clone_nspr
14978 * Return the newly created nsproxy. Do not attach this to the task,
14979 * leave it to the caller to do proper locking and attach it to task.
14981 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14982 - struct task_struct *tsk, struct fs_struct *new_fs)
14983 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14984 + struct nsproxy *orig, struct fs_struct *new_fs)
14986 struct nsproxy *new_nsp;
14989 - new_nsp = clone_nsproxy(tsk->nsproxy);
14990 + vxdprintk(VXD_CBIT(space, 4),
14991 + "unshare_namespaces(0x%08lx,%p,%p)",
14992 + flags, orig, new_fs);
14994 + new_nsp = clone_nsproxy(orig);
14996 return ERR_PTR(-ENOMEM);
14998 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14999 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15000 if (IS_ERR(new_nsp->mnt_ns)) {
15001 err = PTR_ERR(new_nsp->mnt_ns);
15005 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15006 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15007 if (IS_ERR(new_nsp->uts_ns)) {
15008 err = PTR_ERR(new_nsp->uts_ns);
15012 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15013 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15014 if (IS_ERR(new_nsp->ipc_ns)) {
15015 err = PTR_ERR(new_nsp->ipc_ns);
15019 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15020 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15021 if (IS_ERR(new_nsp->pid_ns)) {
15022 err = PTR_ERR(new_nsp->pid_ns);
15026 - new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns);
15027 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15028 if (IS_ERR(new_nsp->user_ns)) {
15029 err = PTR_ERR(new_nsp->user_ns);
15033 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15034 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15035 if (IS_ERR(new_nsp->net_ns)) {
15036 err = PTR_ERR(new_nsp->net_ns);
15038 @@ -114,6 +123,37 @@ out_ns:
15039 return ERR_PTR(err);
15042 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15043 + struct fs_struct *new_fs)
15045 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15049 + * copies the nsproxy, setting refcount to 1, and grabbing a
15050 + * reference to all contained namespaces.
15052 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15054 + struct nsproxy *ns = clone_nsproxy(orig);
15058 + get_mnt_ns(ns->mnt_ns);
15060 + get_uts_ns(ns->uts_ns);
15062 + get_ipc_ns(ns->ipc_ns);
15064 + get_pid_ns(ns->pid_ns);
15066 + get_user_ns(ns->user_ns);
15068 + get_net(ns->net_ns);
15074 * called from clone. This now handles copy for nsproxy and all
15075 * namespaces therein.
15076 @@ -121,9 +161,12 @@ out_ns:
15077 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15079 struct nsproxy *old_ns = tsk->nsproxy;
15080 - struct nsproxy *new_ns;
15081 + struct nsproxy *new_ns = NULL;
15084 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15085 + flags, tsk, old_ns);
15090 @@ -160,6 +203,9 @@ int copy_namespaces(unsigned long flags,
15093 put_nsproxy(old_ns);
15094 + vxdprintk(VXD_CBIT(space, 3),
15095 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15096 + flags, tsk, old_ns, err, new_ns);
15100 @@ -175,7 +221,9 @@ void free_nsproxy(struct nsproxy *ns)
15101 put_pid_ns(ns->pid_ns);
15103 put_user_ns(ns->user_ns);
15104 - put_net(ns->net_ns);
15106 + put_net(ns->net_ns);
15107 + atomic_dec(&vs_global_nsproxy);
15108 kmem_cache_free(nsproxy_cachep, ns);
15111 @@ -188,6 +236,10 @@ int unshare_nsproxy_namespaces(unsigned
15115 + vxdprintk(VXD_CBIT(space, 4),
15116 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15117 + unshare_flags, current->nsproxy);
15119 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15120 CLONE_NEWUSER | CLONE_NEWNET)))
15122 diff -NurpP --minimal linux-2.6.27.3/kernel/pid.c linux-2.6.27.3-vs2.3.0.35.7/kernel/pid.c
15123 --- linux-2.6.27.3/kernel/pid.c 2008-10-13 14:52:09.000000000 +0200
15124 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/pid.c 2008-10-13 14:54:20.000000000 +0200
15126 #include <linux/pid_namespace.h>
15127 #include <linux/init_task.h>
15128 #include <linux/syscalls.h>
15129 +#include <linux/vs_pid.h>
15130 +#include <linux/vserver/global.h>
15132 #define pid_hashfn(nr, ns) \
15133 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15134 @@ -305,7 +307,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15136 struct pid *find_vpid(int nr)
15138 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15139 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15141 EXPORT_SYMBOL_GPL(find_vpid);
15143 @@ -365,6 +367,9 @@ void transfer_pid(struct task_struct *ol
15144 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15146 struct task_struct *result = NULL;
15148 + if (type == PIDTYPE_REALPID)
15149 + type = PIDTYPE_PID;
15151 struct hlist_node *first;
15152 first = rcu_dereference(pid->tasks[type].first);
15153 @@ -388,14 +393,14 @@ EXPORT_SYMBOL(find_task_by_pid_type_ns);
15155 struct task_struct *find_task_by_vpid(pid_t vnr)
15157 - return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
15158 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(vnr),
15159 current->nsproxy->pid_ns);
15161 EXPORT_SYMBOL(find_task_by_vpid);
15163 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15165 - return find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns);
15166 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(nr), ns);
15168 EXPORT_SYMBOL(find_task_by_pid_ns);
15170 @@ -431,7 +436,7 @@ struct pid *find_get_pid(pid_t nr)
15172 EXPORT_SYMBOL_GPL(find_get_pid);
15174 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15175 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15179 @@ -444,6 +449,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15183 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15185 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15188 pid_t pid_vnr(struct pid *pid)
15190 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15191 diff -NurpP --minimal linux-2.6.27.3/kernel/pid_namespace.c linux-2.6.27.3-vs2.3.0.35.7/kernel/pid_namespace.c
15192 --- linux-2.6.27.3/kernel/pid_namespace.c 2008-10-13 14:52:09.000000000 +0200
15193 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/pid_namespace.c 2008-10-13 14:54:20.000000000 +0200
15195 #include <linux/syscalls.h>
15196 #include <linux/err.h>
15197 #include <linux/acct.h>
15198 +#include <linux/vserver/global.h>
15200 #define BITS_PER_PAGE (PAGE_SIZE*8)
15202 @@ -85,6 +86,7 @@ static struct pid_namespace *create_pid_
15205 kref_init(&ns->kref);
15206 + atomic_inc(&vs_global_pid_ns);
15209 set_bit(0, ns->pidmap[0].page);
15210 @@ -109,6 +111,7 @@ static void destroy_pid_namespace(struct
15212 for (i = 0; i < PIDMAP_ENTRIES; i++)
15213 kfree(ns->pidmap[i].page);
15214 + atomic_dec(&vs_global_pid_ns);
15215 kmem_cache_free(pid_ns_cachep, ns);
15218 diff -NurpP --minimal linux-2.6.27.3/kernel/posix-timers.c linux-2.6.27.3-vs2.3.0.35.7/kernel/posix-timers.c
15219 --- linux-2.6.27.3/kernel/posix-timers.c 2008-10-13 14:52:09.000000000 +0200
15220 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/posix-timers.c 2008-10-13 14:54:20.000000000 +0200
15222 #include <linux/wait.h>
15223 #include <linux/workqueue.h>
15224 #include <linux/module.h>
15225 +#include <linux/vs_context.h>
15228 * Management arrays for POSIX timers. Timers are kept in slab memory
15229 @@ -298,6 +299,12 @@ void do_schedule_next_timer(struct sigin
15231 int posix_timer_event(struct k_itimer *timr, int si_private)
15233 + struct vx_info_save vxis;
15234 + struct vx_info *vxi;
15237 + vxi = task_get_vx_info(timr->it_process);
15238 + enter_vx_info(vxi, &vxis);
15240 * FIXME: if ->sigq is queued we can race with
15241 * dequeue_signal()->do_schedule_next_timer().
15242 @@ -318,10 +325,11 @@ int posix_timer_event(struct k_itimer *t
15244 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
15245 struct task_struct *leader;
15246 - int ret = send_sigqueue(timr->sigq, timr->it_process, 0);
15248 + ret = send_sigqueue(timr->sigq, timr->it_process, 0);
15250 if (likely(ret >= 0))
15254 timr->it_sigev_notify = SIGEV_SIGNAL;
15255 leader = timr->it_process->group_leader;
15256 @@ -329,7 +337,11 @@ int posix_timer_event(struct k_itimer *t
15257 timr->it_process = leader;
15260 - return send_sigqueue(timr->sigq, timr->it_process, 1);
15261 + ret = send_sigqueue(timr->sigq, timr->it_process, 1);
15263 + leave_vx_info(&vxis);
15264 + put_vx_info(vxi);
15267 EXPORT_SYMBOL_GPL(posix_timer_event);
15269 diff -NurpP --minimal linux-2.6.27.3/kernel/printk.c linux-2.6.27.3-vs2.3.0.35.7/kernel/printk.c
15270 --- linux-2.6.27.3/kernel/printk.c 2008-10-13 14:52:09.000000000 +0200
15271 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/printk.c 2008-10-13 14:54:20.000000000 +0200
15273 #include <linux/security.h>
15274 #include <linux/bootmem.h>
15275 #include <linux/syscalls.h>
15276 +#include <linux/vs_cvirt.h>
15278 #include <asm/uaccess.h>
15280 @@ -291,18 +292,13 @@ int do_syslog(int type, char __user *buf
15281 unsigned i, j, limit, count;
15287 error = security_syslog(type);
15292 - case 0: /* Close log */
15294 - case 1: /* Open log */
15296 - case 2: /* Read from log */
15297 + if ((type >= 2) && (type <= 4)) {
15299 if (!buf || len < 0)
15301 @@ -313,6 +309,16 @@ int do_syslog(int type, char __user *buf
15306 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15307 + return vx_do_syslog(type, buf, len);
15310 + case 0: /* Close log */
15312 + case 1: /* Open log */
15314 + case 2: /* Read from log */
15315 error = wait_event_interruptible(log_wait,
15316 (log_start - log_end));
15318 @@ -337,16 +343,6 @@ int do_syslog(int type, char __user *buf
15321 case 3: /* Read last kernel messages */
15323 - if (!buf || len < 0)
15328 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15333 if (count > log_buf_len)
15334 count = log_buf_len;
15335 diff -NurpP --minimal linux-2.6.27.3/kernel/ptrace.c linux-2.6.27.3-vs2.3.0.35.7/kernel/ptrace.c
15336 --- linux-2.6.27.3/kernel/ptrace.c 2008-10-13 14:52:09.000000000 +0200
15337 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
15339 #include <linux/audit.h>
15340 #include <linux/pid_namespace.h>
15341 #include <linux/syscalls.h>
15342 +#include <linux/vs_context.h>
15344 #include <asm/pgtable.h>
15345 #include <asm/uaccess.h>
15346 @@ -139,6 +140,11 @@ int __ptrace_may_access(struct task_stru
15347 dumpable = get_dumpable(task->mm);
15348 if (!dumpable && !capable(CAP_SYS_PTRACE))
15350 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15352 + if (!vx_check(task->xid, VS_IDENT) &&
15353 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15356 return security_ptrace_may_access(task, mode);
15358 @@ -567,6 +573,10 @@ asmlinkage long sys_ptrace(long request,
15363 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15364 + goto out_put_task_struct;
15366 if (request == PTRACE_ATTACH) {
15367 ret = ptrace_attach(child);
15369 diff -NurpP --minimal linux-2.6.27.3/kernel/sched.c linux-2.6.27.3-vs2.3.0.35.7/kernel/sched.c
15370 --- linux-2.6.27.3/kernel/sched.c 2008-10-13 14:52:09.000000000 +0200
15371 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/sched.c 2008-10-13 14:54:20.000000000 +0200
15373 #include <linux/debugfs.h>
15374 #include <linux/ctype.h>
15375 #include <linux/ftrace.h>
15376 +#include <linux/vs_sched.h>
15377 +#include <linux/vs_cvirt.h>
15379 #include <asm/tlb.h>
15380 #include <asm/irq_regs.h>
15381 @@ -497,6 +499,16 @@ struct root_domain {
15382 static struct root_domain def_root_domain;
15385 + unsigned long norm_time;
15386 + unsigned long idle_time;
15387 +#ifdef CONFIG_VSERVER_IDLETIME
15390 +#ifdef CONFIG_VSERVER_HARDCPU
15391 + struct list_head hold_queue;
15392 + unsigned long nr_onhold;
15397 * This is the main, per-CPU runqueue data structure.
15398 @@ -1640,6 +1652,7 @@ static void update_avg(u64 *avg, u64 sam
15400 static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup)
15402 + // BUG_ON(p->state & TASK_ONHOLD);
15403 sched_info_queued(p);
15404 p->sched_class->enqueue_task(rq, p, wakeup);
15406 @@ -1837,6 +1850,9 @@ struct migration_req {
15407 struct completion done;
15410 +#include "sched_mon.h"
15414 * The task's runqueue lock must be held.
15415 * Returns true if you have to wait for migration thread.
15416 @@ -1846,6 +1862,7 @@ migrate_task(struct task_struct *p, int
15418 struct rq *rq = task_rq(p);
15420 + vxm_migrate_task(p, rq, dest_cpu);
15422 * If the task is not on a runqueue (and not running), then
15423 * it is sufficient to simply update the task's cpu field.
15424 @@ -2242,6 +2259,12 @@ static int try_to_wake_up(struct task_st
15425 /* might preempt at this point */
15426 rq = task_rq_lock(p, &flags);
15427 old_state = p->state;
15429 + /* we need to unhold suspended tasks
15430 + if (old_state & TASK_ONHOLD) {
15431 + vx_unhold_task(p, rq);
15432 + old_state = p->state;
15434 if (!(old_state & state))
15437 @@ -4067,13 +4090,16 @@ unsigned long long task_sched_runtime(st
15438 void account_user_time(struct task_struct *p, cputime_t cputime)
15440 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15441 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15443 + int nice = (TASK_NICE(p) > 0);
15445 p->utime = cputime_add(p->utime, cputime);
15446 + vx_account_user(vxi, cputime, nice);
15448 /* Add user time to cpustat. */
15449 tmp = cputime_to_cputime64(cputime);
15450 - if (TASK_NICE(p) > 0)
15452 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15454 cpustat->user = cputime64_add(cpustat->user, tmp);
15455 @@ -4120,6 +4146,7 @@ void account_system_time(struct task_str
15458 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15459 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15460 struct rq *rq = this_rq();
15463 @@ -4129,6 +4156,7 @@ void account_system_time(struct task_str
15466 p->stime = cputime_add(p->stime, cputime);
15467 + vx_account_system(vxi, cputime, (p == rq->idle));
15469 /* Add system time to cpustat. */
15470 tmp = cputime_to_cputime64(cputime);
15471 @@ -4963,7 +4991,7 @@ asmlinkage long sys_nice(int increment)
15474 if (increment < 0 && !can_nice(current, nice))
15476 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15478 retval = security_task_setnice(current, nice);
15480 diff -NurpP --minimal linux-2.6.27.3/kernel/sched_fair.c linux-2.6.27.3-vs2.3.0.35.7/kernel/sched_fair.c
15481 --- linux-2.6.27.3/kernel/sched_fair.c 2008-10-13 14:52:09.000000000 +0200
15482 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/sched_fair.c 2008-10-13 14:54:20.000000000 +0200
15483 @@ -724,6 +724,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15484 check_spread(cfs_rq, se);
15485 if (se != cfs_rq->curr)
15486 __enqueue_entity(cfs_rq, se);
15488 + if (entity_is_task(se))
15489 + vx_activate_task(task_of(se));
15493 @@ -750,6 +753,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15495 if (se != cfs_rq->curr)
15496 __dequeue_entity(cfs_rq, se);
15497 + if (entity_is_task(se))
15498 + vx_deactivate_task(task_of(se));
15499 account_entity_dequeue(cfs_rq, se);
15502 diff -NurpP --minimal linux-2.6.27.3/kernel/sched_hard.h linux-2.6.27.3-vs2.3.0.35.7/kernel/sched_hard.h
15503 --- linux-2.6.27.3/kernel/sched_hard.h 1970-01-01 01:00:00.000000000 +0100
15504 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/sched_hard.h 2008-10-13 14:54:20.000000000 +0200
15507 +#ifdef CONFIG_VSERVER_IDLELIMIT
15510 + * vx_idle_resched - reschedule after maxidle
15513 +void vx_idle_resched(struct rq *rq)
15515 + /* maybe have a better criterion for paused */
15516 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
15517 + set_need_resched();
15520 +#else /* !CONFIG_VSERVER_IDLELIMIT */
15522 +#define vx_idle_resched(rq)
15524 +#endif /* CONFIG_VSERVER_IDLELIMIT */
15528 +#ifdef CONFIG_VSERVER_IDLETIME
15530 +#define vx_set_rq_min_skip(rq, min) \
15531 + (rq)->idle_skip = (min)
15533 +#define vx_save_min_skip(ret, min, val) \
15534 + __vx_save_min_skip(ret, min, val)
15537 +void __vx_save_min_skip(int ret, int *min, int val)
15541 + if ((*min > val) || !*min)
15546 +int vx_try_skip(struct rq *rq, int cpu)
15548 + /* artificially advance time */
15549 + if (rq->idle_skip > 0) {
15550 + vxdprintk(list_empty(&rq->hold_queue),
15551 + "hold queue empty on cpu %d", cpu);
15552 + rq->idle_time += rq->idle_skip;
15553 + vxm_idle_skip(rq, cpu);
15559 +#else /* !CONFIG_VSERVER_IDLETIME */
15561 +#define vx_set_rq_min_skip(rq, min) \
15562 + ({ int dummy = (min); dummy; })
15564 +#define vx_save_min_skip(ret, min, val)
15567 +int vx_try_skip(struct rq *rq, int cpu)
15572 +#endif /* CONFIG_VSERVER_IDLETIME */
15576 +#ifdef CONFIG_VSERVER_HARDCPU
15578 +#define vx_set_rq_max_idle(rq, max) \
15579 + (rq)->idle_tokens = (max)
15581 +#define vx_save_max_idle(ret, min, val) \
15582 + __vx_save_max_idle(ret, min, val)
15585 +void __vx_save_max_idle(int ret, int *min, int val)
15593 + * vx_hold_task - put a task on the hold queue
15596 +void vx_hold_task(struct task_struct *p, struct rq *rq)
15598 + __deactivate_task(p, rq);
15599 + p->state |= TASK_ONHOLD;
15600 + /* a new one on hold */
15602 + vxm_hold_task(p, rq);
15603 + list_add_tail(&p->run_list, &rq->hold_queue);
15607 + * vx_unhold_task - put a task back to the runqueue
15610 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
15612 + list_del(&p->run_list);
15613 + /* one less waiting */
15615 + p->state &= ~TASK_ONHOLD;
15616 + enqueue_task(p, rq->expired);
15617 + inc_nr_running(p, rq);
15618 + vxm_unhold_task(p, rq);
15620 + if (p->static_prio < rq->best_expired_prio)
15621 + rq->best_expired_prio = p->static_prio;
15624 +unsigned long nr_onhold(void)
15626 + unsigned long i, sum = 0;
15628 + for_each_online_cpu(i)
15629 + sum += cpu_rq(i)->nr_onhold;
15637 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
15639 + return sched_pc->tokens;
15643 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
15645 + sched_pc->tokens--;
15649 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
15651 + struct vx_info *vxi = p->vx_info;
15653 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
15654 + struct _vx_sched_pc *sched_pc =
15655 + &vx_per_cpu(vxi, sched_pc, cpu);
15658 + /* maybe we can simplify that to decrement
15659 + the token counter unconditional? */
15661 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
15662 + __vx_consume_token(sched_pc);
15664 + /* for tokens > 0, one token was consumed */
15668 + vxm_need_resched(p, slice, cpu);
15669 + return (slice == 0);
15673 +#define vx_set_rq_time(rq, time) do { \
15674 + rq->norm_time = time; \
15679 +void vx_try_unhold(struct rq *rq, int cpu)
15681 + struct vx_info *vxi = NULL;
15682 + struct list_head *l, *n;
15683 + int maxidle = HZ;
15686 + /* nothing to do? what about pause? */
15687 + if (list_empty(&rq->hold_queue))
15690 + list_for_each_safe(l, n, &rq->hold_queue) {
15691 + int ret, delta_min[2];
15692 + struct _vx_sched_pc *sched_pc;
15693 + struct task_struct *p;
15695 + p = list_entry(l, struct task_struct, run_list);
15696 + /* don't bother with same context */
15697 + if (vxi == p->vx_info)
15700 + vxi = p->vx_info;
15701 + /* ignore paused contexts */
15702 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
15705 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
15707 + /* recalc tokens */
15708 + vxm_sched_info(sched_pc, vxi, cpu);
15709 + ret = vx_tokens_recalc(sched_pc,
15710 + &rq->norm_time, &rq->idle_time, delta_min);
15711 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
15714 + /* we found a runable context */
15715 + vx_unhold_task(p, rq);
15718 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
15719 + vx_save_min_skip(ret, &minskip, delta_min[1]);
15721 + vx_set_rq_max_idle(rq, maxidle);
15722 + vx_set_rq_min_skip(rq, minskip);
15723 + vxm_rq_max_min(rq, cpu);
15728 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
15730 + struct vx_info *vxi = next->vx_info;
15731 + struct _vx_sched_pc *sched_pc;
15732 + int delta_min[2];
15738 + flags = vxi->vx_flags;
15740 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
15741 + goto put_on_hold;
15742 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
15745 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
15747 + /* update scheduler params */
15748 + if (cpu_isset(cpu, vxi->sched.update)) {
15749 + vx_update_sched_param(&vxi->sched, sched_pc);
15750 + vxm_update_sched(sched_pc, vxi, cpu);
15751 + cpu_clear(cpu, vxi->sched.update);
15754 + vxm_sched_info(sched_pc, vxi, cpu);
15755 + ret = vx_tokens_recalc(sched_pc,
15756 + &rq->norm_time, &rq->idle_time, delta_min);
15757 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
15759 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
15762 + if (unlikely(ret < 0)) {
15763 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
15764 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
15765 + vxm_rq_max_min(rq, cpu);
15767 + vx_hold_task(next, rq);
15774 +#else /* CONFIG_VSERVER_HARDCPU */
15777 +void vx_hold_task(struct task_struct *p, struct rq *rq)
15783 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
15788 +unsigned long nr_onhold(void)
15795 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
15797 + return (slice == 0);
15801 +#define vx_set_rq_time(rq, time)
15804 +void vx_try_unhold(struct rq *rq, int cpu)
15810 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
15812 + struct vx_info *vxi = next->vx_info;
15813 + struct _vx_sched_pc *sched_pc;
15814 + int delta_min[2];
15817 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
15820 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
15821 + vxm_sched_info(sched_pc, vxi, cpu);
15822 + ret = vx_tokens_recalc(sched_pc,
15823 + &rq->norm_time, &rq->idle_time, delta_min);
15824 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
15828 +#endif /* CONFIG_VSERVER_HARDCPU */
15830 diff -NurpP --minimal linux-2.6.27.3/kernel/sched_mon.h linux-2.6.27.3-vs2.3.0.35.7/kernel/sched_mon.h
15831 --- linux-2.6.27.3/kernel/sched_mon.h 1970-01-01 01:00:00.000000000 +0100
15832 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/sched_mon.h 2008-10-13 14:54:20.000000000 +0200
15835 +#include <linux/vserver/monitor.h>
15837 +#ifdef CONFIG_VSERVER_MONITOR
15839 +#ifdef CONFIG_VSERVER_HARDCPU
15840 +#define HARDCPU(x) (x)
15842 +#define HARDCPU(x) (0)
15845 +#ifdef CONFIG_VSERVER_IDLETIME
15846 +#define IDLETIME(x) (x)
15848 +#define IDLETIME(x) (0)
15851 +struct _vx_mon_entry *vxm_advance(int cpu);
15855 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
15857 + entry->type = type;
15858 + entry->xid = xid;
15862 +void __vxm_sync(int cpu)
15864 + struct _vx_mon_entry *entry = vxm_advance(cpu);
15866 + __vxm_basic(entry, 0, VXM_SYNC);
15867 + entry->ev.sec = xtime.tv_sec;
15868 + entry->ev.nsec = xtime.tv_nsec;
15872 +void __vxm_task(struct task_struct *p, int type)
15874 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
15876 + __vxm_basic(entry, p->xid, type);
15877 + entry->ev.tsk.pid = p->pid;
15878 + entry->ev.tsk.state = p->state;
15882 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
15884 + struct _vx_mon_entry *entry = vxm_advance(cpu);
15886 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
15887 + entry->sd.tokens = s->tokens;
15888 + entry->sd.norm_time = s->norm_time;
15889 + entry->sd.idle_time = s->idle_time;
15893 +void __vxm_rqinfo1(struct rq *q, int cpu)
15895 + struct _vx_mon_entry *entry = vxm_advance(cpu);
15897 + entry->type = VXM_RQINFO_1;
15898 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
15899 + entry->q1.running = q->nr_running;
15900 + entry->q1.onhold = HARDCPU(q->nr_onhold);
15901 + entry->q1.iowait = atomic_read(&q->nr_iowait);
15902 + entry->q1.uintr = q->nr_uninterruptible;
15903 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
15907 +void __vxm_rqinfo2(struct rq *q, int cpu)
15909 + struct _vx_mon_entry *entry = vxm_advance(cpu);
15911 + entry->type = VXM_RQINFO_2;
15912 + entry->xid = (unsigned long)q & 0xffff;
15913 + entry->q2.norm_time = q->norm_time;
15914 + entry->q2.idle_time = q->idle_time;
15915 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
15919 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
15921 + struct _vx_mon_entry *entry = vxm_advance(cpu);
15923 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
15924 + entry->ev.tokens = s->tokens;
15928 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
15930 + struct _vx_mon_entry *entry = vxm_advance(cpu);
15932 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
15933 + entry->u1.tokens_max = s->tokens_max;
15934 + entry->u1.fill_rate = s->fill_rate[0];
15935 + entry->u1.interval = s->interval[0];
15939 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
15941 + struct _vx_mon_entry *entry = vxm_advance(cpu);
15943 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
15944 + entry->u2.tokens_min = s->tokens_min;
15945 + entry->u2.fill_rate = s->fill_rate[1];
15946 + entry->u2.interval = s->interval[1];
15950 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
15951 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
15952 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
15953 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
15954 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
15957 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
15959 + __vxm_task(p, VXM_MIGRATE);
15960 + __vxm_rqinfo1(rq, task_cpu(p));
15961 + __vxm_rqinfo2(rq, task_cpu(p));
15965 +void vxm_idle_skip(struct rq *rq, int cpu)
15967 + __vxm_rqinfo1(rq, cpu);
15968 + __vxm_rqinfo2(rq, cpu);
15972 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
15977 + __vxm_task(p, VXM_RESCHED);
15981 +void vxm_sync(unsigned long now, int cpu)
15983 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
15984 + (now % CONFIG_VSERVER_MONITOR_SYNC))
15990 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
15993 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
15994 + struct vx_info *vxi, int cpu)
15996 + __vxm_sched(s, vxi, cpu);
15997 + __vxm_rqinfo2(rq, cpu);
16001 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16003 + __vxm_sched(s, vxi, cpu);
16004 + __vxm_update(s, vxi, cpu);
16005 + __vxm_update1(s, vxi, cpu);
16006 + __vxm_update2(s, vxi, cpu);
16010 +void vxm_rq_max_min(struct rq *rq, int cpu)
16012 + __vxm_rqinfo1(rq, cpu);
16013 + __vxm_rqinfo2(rq, cpu);
16016 +#else /* CONFIG_VSERVER_MONITOR */
16018 +#define vxm_activate_task(t,q) do { } while (0)
16019 +#define vxm_activate_idle(t,q) do { } while (0)
16020 +#define vxm_deactivate_task(t,q) do { } while (0)
16021 +#define vxm_hold_task(t,q) do { } while (0)
16022 +#define vxm_unhold_task(t,q) do { } while (0)
16023 +#define vxm_migrate_task(t,q,d) do { } while (0)
16024 +#define vxm_idle_skip(q,c) do { } while (0)
16025 +#define vxm_need_resched(t,s,c) do { } while (0)
16026 +#define vxm_sync(s,c) do { } while (0)
16027 +#define vxm_sched_info(s,v,c) do { } while (0)
16028 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
16029 +#define vxm_update_sched(s,v,c) do { } while (0)
16030 +#define vxm_rq_max_min(q,c) do { } while (0)
16032 +#endif /* CONFIG_VSERVER_MONITOR */
16034 diff -NurpP --minimal linux-2.6.27.3/kernel/signal.c linux-2.6.27.3-vs2.3.0.35.7/kernel/signal.c
16035 --- linux-2.6.27.3/kernel/signal.c 2008-10-13 14:52:09.000000000 +0200
16036 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/signal.c 2008-10-13 14:54:20.000000000 +0200
16038 #include <linux/freezer.h>
16039 #include <linux/pid_namespace.h>
16040 #include <linux/nsproxy.h>
16041 +#include <linux/vs_context.h>
16042 +#include <linux/vs_pid.h>
16044 #include <asm/param.h>
16045 #include <asm/uaccess.h>
16046 @@ -571,6 +573,14 @@ static int check_kill_permission(int sig
16047 if (!valid_signal(sig))
16050 + if ((info != SEND_SIG_NOINFO) &&
16051 + (is_si_special(info) || !SI_FROMUSER(info)))
16054 + vxdprintk(VXD_CBIT(misc, 7),
16055 + "check_kill_permission(%d,%p,%p[#%u,%u])",
16056 + sig, info, t, vx_task_xid(t), t->pid);
16058 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
16061 @@ -595,6 +605,18 @@ static int check_kill_permission(int sig
16066 + if (t->pid == 1 && current->xid)
16070 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
16071 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
16072 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
16073 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
16077 return security_task_kill(t, info, sig, 0);
16080 @@ -1051,7 +1073,7 @@ int kill_pid_info(int sig, struct siginf
16083 p = pid_task(pid, PIDTYPE_PID);
16085 + if (p && vx_check(vx_task_xid(p), VS_WATCH | VS_IDENT)) {
16086 error = group_send_sig_info(sig, info, p);
16087 if (unlikely(error == -ESRCH))
16089 @@ -1089,7 +1111,7 @@ int kill_pid_info_as_uid(int sig, struct
16091 read_lock(&tasklist_lock);
16092 p = pid_task(pid, PIDTYPE_PID);
16094 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
16098 @@ -1141,7 +1163,9 @@ static int kill_something_info(int sig,
16099 struct task_struct * p;
16101 for_each_process(p) {
16102 - if (p->pid > 1 && !same_thread_group(p, current)) {
16103 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
16104 + p->pid > 1 && !same_thread_group(p, current) &&
16105 + !vx_current_initpid(p->pid)) {
16106 int err = group_send_sig_info(sig, info, p);
16109 @@ -1814,6 +1838,11 @@ relock:
16110 !signal_group_exit(signal))
16113 + /* virtual init is protected against user signals */
16114 + if ((info->si_code == SI_USER) &&
16115 + vx_current_initpid(current->pid))
16118 if (sig_kernel_stop(signr)) {
16120 * The default action is to stop all threads in
16121 diff -NurpP --minimal linux-2.6.27.3/kernel/softirq.c linux-2.6.27.3-vs2.3.0.35.7/kernel/softirq.c
16122 --- linux-2.6.27.3/kernel/softirq.c 2008-10-13 14:52:09.000000000 +0200
16123 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/softirq.c 2008-10-13 14:54:20.000000000 +0200
16125 #include <linux/rcupdate.h>
16126 #include <linux/smp.h>
16127 #include <linux/tick.h>
16128 +#include <linux/vs_context.h>
16130 #include <asm/irq.h>
16132 diff -NurpP --minimal linux-2.6.27.3/kernel/sys.c linux-2.6.27.3-vs2.3.0.35.7/kernel/sys.c
16133 --- linux-2.6.27.3/kernel/sys.c 2008-10-13 14:52:09.000000000 +0200
16134 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/sys.c 2008-10-13 14:54:20.000000000 +0200
16136 #include <linux/syscalls.h>
16137 #include <linux/kprobes.h>
16138 #include <linux/user_namespace.h>
16139 +#include <linux/vs_pid.h>
16141 #include <asm/uaccess.h>
16142 #include <asm/io.h>
16143 @@ -122,7 +123,10 @@ static int set_one_prio(struct task_stru
16146 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
16148 + if (vx_flags(VXF_IGNEG_NICE, 0))
16154 no_nice = security_task_setnice(p, niceval);
16155 @@ -170,6 +174,8 @@ asmlinkage long sys_setpriority(int whic
16157 pgrp = task_pgrp(current);
16158 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16159 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16161 error = set_one_prio(p, niceval, error);
16162 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
16164 @@ -230,6 +236,8 @@ asmlinkage long sys_getpriority(int whic
16166 pgrp = task_pgrp(current);
16167 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16168 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16170 niceval = 20 - task_nice(p);
16171 if (niceval > retval)
16173 @@ -339,6 +347,9 @@ void kernel_power_off(void)
16174 machine_power_off();
16176 EXPORT_SYMBOL_GPL(kernel_power_off);
16178 +long vs_reboot(unsigned int, void __user *);
16181 * Reboot system call: for obvious reasons only root may call it,
16182 * and even root needs to set up some magic numbers in the registers
16183 @@ -369,6 +380,9 @@ asmlinkage long sys_reboot(int magic1, i
16184 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
16185 cmd = LINUX_REBOOT_CMD_HALT;
16187 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16188 + return vs_reboot(cmd, arg);
16192 case LINUX_REBOOT_CMD_RESTART:
16193 @@ -1344,7 +1358,7 @@ asmlinkage long sys_sethostname(char __u
16195 char tmp[__NEW_UTS_LEN];
16197 - if (!capable(CAP_SYS_ADMIN))
16198 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16200 if (len < 0 || len > __NEW_UTS_LEN)
16202 @@ -1389,7 +1403,7 @@ asmlinkage long sys_setdomainname(char _
16204 char tmp[__NEW_UTS_LEN];
16206 - if (!capable(CAP_SYS_ADMIN))
16207 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16209 if (len < 0 || len > __NEW_UTS_LEN)
16211 @@ -1456,7 +1470,7 @@ asmlinkage long sys_setrlimit(unsigned i
16213 old_rlim = current->signal->rlim + resource;
16214 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
16215 - !capable(CAP_SYS_RESOURCE))
16216 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
16218 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
16220 diff -NurpP --minimal linux-2.6.27.3/kernel/sysctl.c linux-2.6.27.3-vs2.3.0.35.7/kernel/sysctl.c
16221 --- linux-2.6.27.3/kernel/sysctl.c 2008-10-13 14:52:09.000000000 +0200
16222 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/sysctl.c 2008-10-13 14:54:20.000000000 +0200
16223 @@ -114,6 +114,7 @@ static int ngroups_max = NGROUPS_MAX;
16224 #ifdef CONFIG_MODULES
16225 extern char modprobe_path[];
16227 +extern char vshelper_path[];
16228 #ifdef CONFIG_CHR_DEV_SG
16229 extern int sg_big_buff;
16231 @@ -500,6 +501,15 @@ static struct ctl_table kern_table[] = {
16232 .strategy = &sysctl_string,
16236 + .ctl_name = KERN_VSHELPER,
16237 + .procname = "vshelper",
16238 + .data = &vshelper_path,
16241 + .proc_handler = &proc_dostring,
16242 + .strategy = &sysctl_string,
16244 #ifdef CONFIG_CHR_DEV_SG
16246 .ctl_name = KERN_SG_BIG_BUFF,
16247 diff -NurpP --minimal linux-2.6.27.3/kernel/sysctl_check.c linux-2.6.27.3-vs2.3.0.35.7/kernel/sysctl_check.c
16248 --- linux-2.6.27.3/kernel/sysctl_check.c 2008-10-13 14:52:09.000000000 +0200
16249 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/sysctl_check.c 2008-10-13 14:54:20.000000000 +0200
16250 @@ -39,6 +39,7 @@ static const struct trans_ctl_table tran
16252 { KERN_PANIC, "panic" },
16253 { KERN_REALROOTDEV, "real-root-dev" },
16254 + { KERN_VSHELPER, "vshelper", },
16256 { KERN_SPARC_REBOOT, "reboot-cmd" },
16257 { KERN_CTLALTDEL, "ctrl-alt-del" },
16258 @@ -1217,6 +1218,22 @@ static const struct trans_ctl_table tran
16262 +static struct trans_ctl_table trans_vserver_table[] = {
16263 + { 1, "debug_switch" },
16264 + { 2, "debug_xid" },
16265 + { 3, "debug_nid" },
16266 + { 4, "debug_tag" },
16267 + { 5, "debug_net" },
16268 + { 6, "debug_limit" },
16269 + { 7, "debug_cres" },
16270 + { 8, "debug_dlim" },
16271 + { 9, "debug_quota" },
16272 + { 10, "debug_cvirt" },
16273 + { 11, "debug_space" },
16274 + { 12, "debug_misc" },
16278 static const struct trans_ctl_table trans_root_table[] = {
16279 { CTL_KERN, "kernel", trans_kern_table },
16280 { CTL_VM, "vm", trans_vm_table },
16281 @@ -1233,6 +1250,7 @@ static const struct trans_ctl_table tran
16282 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
16283 { CTL_PM, "pm", trans_pm_table },
16284 { CTL_FRV, "frv", trans_frv_table },
16285 + { CTL_VSERVER, "vserver", trans_vserver_table },
16289 diff -NurpP --minimal linux-2.6.27.3/kernel/time.c linux-2.6.27.3-vs2.3.0.35.7/kernel/time.c
16290 --- linux-2.6.27.3/kernel/time.c 2008-07-13 23:51:29.000000000 +0200
16291 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/time.c 2008-10-13 14:54:20.000000000 +0200
16292 @@ -62,6 +62,7 @@ EXPORT_SYMBOL(sys_tz);
16293 asmlinkage long sys_time(time_t __user * tloc)
16295 time_t i = get_seconds();
16296 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
16299 if (put_user(i,tloc))
16300 @@ -91,7 +92,7 @@ asmlinkage long sys_stime(time_t __user
16304 - do_settimeofday(&tv);
16305 + vx_settimeofday(&tv);
16309 @@ -102,7 +103,7 @@ asmlinkage long sys_gettimeofday(struct
16311 if (likely(tv != NULL)) {
16312 struct timeval ktv;
16313 - do_gettimeofday(&ktv);
16314 + vx_gettimeofday(&ktv);
16315 if (copy_to_user(tv, &ktv, sizeof(ktv)))
16318 @@ -177,7 +178,7 @@ int do_sys_settimeofday(struct timespec
16319 /* SMP safe, again the code in arch/foo/time.c should
16320 * globally block out interrupts when it runs.
16322 - return do_settimeofday(tv);
16323 + return vx_settimeofday(tv);
16327 @@ -309,7 +310,7 @@ void getnstimeofday(struct timespec *tv)
16331 - do_gettimeofday(&x);
16332 + vx_gettimeofday(&x);
16333 tv->tv_sec = x.tv_sec;
16334 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
16336 diff -NurpP --minimal linux-2.6.27.3/kernel/timer.c linux-2.6.27.3-vs2.3.0.35.7/kernel/timer.c
16337 --- linux-2.6.27.3/kernel/timer.c 2008-10-13 14:52:09.000000000 +0200
16338 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/timer.c 2008-10-13 14:54:20.000000000 +0200
16340 #include <linux/delay.h>
16341 #include <linux/tick.h>
16342 #include <linux/kallsyms.h>
16343 +#include <linux/vs_base.h>
16344 +#include <linux/vs_cvirt.h>
16345 +#include <linux/vs_pid.h>
16346 +#include <linux/vserver/sched.h>
16348 #include <asm/uaccess.h>
16349 #include <asm/unistd.h>
16350 @@ -1081,12 +1085,6 @@ asmlinkage unsigned long sys_alarm(unsig
16357 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
16358 - * should be moved into arch/i386 instead?
16362 * sys_getpid - return the thread group id of the current process
16363 @@ -1115,10 +1113,23 @@ asmlinkage long sys_getppid(void)
16365 pid = task_tgid_vnr(current->real_parent);
16367 + return vx_map_pid(pid);
16374 + * The Alpha uses getxpid, getxuid, and getxgid instead.
16377 +asmlinkage long do_getxpid(long *ppid)
16379 + *ppid = sys_getppid();
16380 + return sys_getpid();
16383 +#else /* _alpha_ */
16385 asmlinkage long sys_getuid(void)
16387 /* Only we change this so SMP safe */
16388 @@ -1289,6 +1300,8 @@ int do_sysinfo(struct sysinfo *info)
16389 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
16392 + if (vx_flags(VXF_VIRT_UPTIME, 0))
16393 + vx_vsi_uptime(&tp, NULL);
16394 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
16396 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
16397 diff -NurpP --minimal linux-2.6.27.3/kernel/user.c linux-2.6.27.3-vs2.3.0.35.7/kernel/user.c
16398 --- linux-2.6.27.3/kernel/user.c 2008-07-13 23:51:29.000000000 +0200
16399 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/user.c 2008-10-13 14:54:20.000000000 +0200
16400 @@ -243,12 +243,15 @@ static struct kobj_type uids_ktype = {
16403 /* create /sys/kernel/uids/<uid>/cpu_share file for this user */
16404 -static int uids_user_create(struct user_struct *up)
16405 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
16407 struct kobject *kobj = &up->kobj;
16411 memset(kobj, 0, sizeof(struct kobject));
16412 + if (ns != &init_user_ns)
16415 kobj->kset = uids_kset;
16416 error = kobject_init_and_add(kobj, &uids_ktype, NULL, "%d", up->uid);
16418 @@ -272,7 +275,7 @@ int __init uids_sysfs_init(void)
16422 - return uids_user_create(&root_user);
16423 + return uids_user_create(NULL, &root_user);
16426 /* work function to remove sysfs directory for a user and free up
16427 @@ -302,9 +305,11 @@ static void remove_user_sysfs_dir(struct
16431 - kobject_uevent(&up->kobj, KOBJ_REMOVE);
16432 - kobject_del(&up->kobj);
16433 - kobject_put(&up->kobj);
16434 + if (up->kobj.name) {
16435 + kobject_uevent(&up->kobj, KOBJ_REMOVE);
16436 + kobject_del(&up->kobj);
16437 + kobject_put(&up->kobj);
16440 sched_destroy_user(up);
16441 key_put(up->uid_keyring);
16442 @@ -332,7 +337,8 @@ static inline void free_user(struct user
16443 #else /* CONFIG_USER_SCHED && CONFIG_SYSFS */
16445 int uids_sysfs_init(void) { return 0; }
16446 -static inline int uids_user_create(struct user_struct *up) { return 0; }
16447 +static inline int uids_user_create(struct user_namespace *ns,
16448 + struct user_struct *up) { return 0; }
16449 static inline void uids_mutex_lock(void) { }
16450 static inline void uids_mutex_unlock(void) { }
16452 @@ -409,7 +415,7 @@ struct user_struct *alloc_uid(struct use
16453 if (sched_create_user(new) < 0)
16454 goto out_free_user;
16456 - if (uids_user_create(new))
16457 + if (uids_user_create(ns, new))
16458 goto out_destoy_sched;
16461 diff -NurpP --minimal linux-2.6.27.3/kernel/user_namespace.c linux-2.6.27.3-vs2.3.0.35.7/kernel/user_namespace.c
16462 --- linux-2.6.27.3/kernel/user_namespace.c 2008-10-13 14:52:09.000000000 +0200
16463 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/user_namespace.c 2008-10-13 14:54:20.000000000 +0200
16465 #include <linux/nsproxy.h>
16466 #include <linux/slab.h>
16467 #include <linux/user_namespace.h>
16468 +#include <linux/vserver/global.h>
16471 * Clone a new ns copying an original user ns, setting refcount to 1
16472 @@ -26,6 +27,7 @@ static struct user_namespace *clone_user
16473 return ERR_PTR(-ENOMEM);
16475 kref_init(&ns->kref);
16476 + atomic_inc(&vs_global_user_ns);
16478 for (n = 0; n < UIDHASH_SZ; ++n)
16479 INIT_HLIST_HEAD(ns->uidhash_table + n);
16480 @@ -71,6 +73,7 @@ void free_user_ns(struct kref *kref)
16482 ns = container_of(kref, struct user_namespace, kref);
16484 + atomic_dec(&vs_global_user_ns);
16487 EXPORT_SYMBOL(free_user_ns);
16488 diff -NurpP --minimal linux-2.6.27.3/kernel/utsname.c linux-2.6.27.3-vs2.3.0.35.7/kernel/utsname.c
16489 --- linux-2.6.27.3/kernel/utsname.c 2008-10-13 14:52:09.000000000 +0200
16490 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/utsname.c 2008-10-13 14:54:20.000000000 +0200
16492 #include <linux/utsname.h>
16493 #include <linux/err.h>
16494 #include <linux/slab.h>
16495 +#include <linux/vserver/global.h>
16498 * Clone a new ns copying an original utsname, setting refcount to 1
16499 @@ -32,6 +33,7 @@ static struct uts_namespace *clone_uts_n
16500 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
16502 kref_init(&ns->kref);
16503 + atomic_inc(&vs_global_uts_ns);
16507 @@ -62,5 +64,6 @@ void free_uts_ns(struct kref *kref)
16508 struct uts_namespace *ns;
16510 ns = container_of(kref, struct uts_namespace, kref);
16511 + atomic_dec(&vs_global_uts_ns);
16514 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/cacct.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cacct.c
16515 --- linux-2.6.27.3/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16516 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cacct.c 2008-10-13 14:54:20.000000000 +0200
16519 + * linux/kernel/vserver/cacct.c
16521 + * Virtual Server: Context Accounting
16523 + * Copyright (C) 2006-2007 Herbert Pötzl
16525 + * V0.01 added accounting stats
16529 +#include <linux/types.h>
16530 +#include <linux/vs_context.h>
16531 +#include <linux/vserver/cacct_cmd.h>
16532 +#include <linux/vserver/cacct_int.h>
16534 +#include <asm/errno.h>
16535 +#include <asm/uaccess.h>
16538 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16540 + struct vcmd_sock_stat_v0 vc_data;
16543 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16546 + field = vc_data.field;
16547 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16550 + for (j = 0; j < 3; j++) {
16551 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16552 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16555 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16560 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/cacct_init.h linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cacct_init.h
16561 --- linux-2.6.27.3/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16562 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cacct_init.h 2008-10-13 14:54:20.000000000 +0200
16566 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16571 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16572 + for (j = 0; j < 3; j++) {
16573 + atomic_set(&cacct->sock[i][j].count, 0);
16574 + atomic_set(&cacct->sock[i][j].total, 0);
16577 + for (i = 0; i < 8; i++)
16578 + atomic_set(&cacct->slab[i], 0);
16579 + for (i = 0; i < 5; i++)
16580 + for (j = 0; j < 4; j++)
16581 + atomic_set(&cacct->page[i][j], 0);
16584 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16589 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/cacct_proc.h linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cacct_proc.h
16590 --- linux-2.6.27.3/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16591 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cacct_proc.h 2008-10-13 14:54:20.000000000 +0200
16593 +#ifndef _VX_CACCT_PROC_H
16594 +#define _VX_CACCT_PROC_H
16596 +#include <linux/vserver/cacct_int.h>
16599 +#define VX_SOCKA_TOP \
16600 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16602 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16604 + int i, j, length = 0;
16605 + static char *type[VXA_SOCK_SIZE] = {
16606 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16609 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16610 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16611 + length += sprintf(buffer + length, "%s:", type[i]);
16612 + for (j = 0; j < 3; j++) {
16613 + length += sprintf(buffer + length,
16614 + "\t%10lu/%-10lu",
16615 + vx_sock_count(cacct, i, j),
16616 + vx_sock_total(cacct, i, j));
16618 + buffer[length++] = '\n';
16621 + length += sprintf(buffer + length, "\n");
16622 + length += sprintf(buffer + length,
16623 + "slab:\t %8u %8u %8u %8u\n",
16624 + atomic_read(&cacct->slab[1]),
16625 + atomic_read(&cacct->slab[4]),
16626 + atomic_read(&cacct->slab[0]),
16627 + atomic_read(&cacct->slab[2]));
16629 + length += sprintf(buffer + length, "\n");
16630 + for (i = 0; i < 5; i++) {
16631 + length += sprintf(buffer + length,
16632 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16633 + atomic_read(&cacct->page[i][0]),
16634 + atomic_read(&cacct->page[i][1]),
16635 + atomic_read(&cacct->page[i][2]),
16636 + atomic_read(&cacct->page[i][3]),
16637 + atomic_read(&cacct->page[i][4]),
16638 + atomic_read(&cacct->page[i][5]),
16639 + atomic_read(&cacct->page[i][6]),
16640 + atomic_read(&cacct->page[i][7]));
16645 +#endif /* _VX_CACCT_PROC_H */
16646 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/context.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/context.c
16647 --- linux-2.6.27.3/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16648 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/context.c 2008-10-13 14:54:20.000000000 +0200
16651 + * linux/kernel/vserver/context.c
16653 + * Virtual Server: Context Support
16655 + * Copyright (C) 2003-2007 Herbert Pötzl
16657 + * V0.01 context helper
16658 + * V0.02 vx_ctx_kill syscall command
16659 + * V0.03 replaced context_info calls
16660 + * V0.04 redesign of struct (de)alloc
16661 + * V0.05 rlimit basic implementation
16662 + * V0.06 task_xid and info commands
16663 + * V0.07 context flags and caps
16664 + * V0.08 switch to RCU based hash
16665 + * V0.09 revert to non RCU for now
16666 + * V0.10 and back to working RCU hash
16667 + * V0.11 and back to locking again
16668 + * V0.12 referenced context store
16669 + * V0.13 separate per cpu data
16670 + * V0.14 changed vcmds to vxi arg
16671 + * V0.15 added context stat
16672 + * V0.16 have __create claim() the vxi
16673 + * V0.17 removed older and legacy stuff
16677 +#include <linux/slab.h>
16678 +#include <linux/types.h>
16679 +#include <linux/security.h>
16680 +#include <linux/pid_namespace.h>
16682 +#include <linux/vserver/context.h>
16683 +#include <linux/vserver/network.h>
16684 +#include <linux/vserver/debug.h>
16685 +#include <linux/vserver/limit.h>
16686 +#include <linux/vserver/limit_int.h>
16687 +#include <linux/vserver/space.h>
16689 +#include <linux/vs_context.h>
16690 +#include <linux/vs_limit.h>
16691 +#include <linux/vs_pid.h>
16692 +#include <linux/vserver/context_cmd.h>
16694 +#include "cvirt_init.h"
16695 +#include "cacct_init.h"
16696 +#include "limit_init.h"
16697 +#include "sched_init.h"
16700 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16701 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16704 +/* now inactive context structures */
16706 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16708 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
16711 +/* __alloc_vx_info()
16713 + * allocate an initialized vx_info struct
16714 + * doesn't make it visible (hash) */
16716 +static struct vx_info *__alloc_vx_info(xid_t xid)
16718 + struct vx_info *new = NULL;
16721 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16723 + /* would this benefit from a slab cache? */
16724 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16728 + memset(new, 0, sizeof(struct vx_info));
16730 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16731 + if (!new->ptr_pc)
16734 + new->vx_id = xid;
16735 + INIT_HLIST_NODE(&new->vx_hlist);
16736 + atomic_set(&new->vx_usecnt, 0);
16737 + atomic_set(&new->vx_tasks, 0);
16738 + new->vx_parent = NULL;
16739 + new->vx_state = 0;
16740 + init_waitqueue_head(&new->vx_wait);
16742 + /* prepare reaper */
16743 + get_task_struct(init_pid_ns.child_reaper);
16744 + new->vx_reaper = init_pid_ns.child_reaper;
16745 + new->vx_badness_bias = 0;
16747 + /* rest of init goes here */
16748 + vx_info_init_limit(&new->limit);
16749 + vx_info_init_sched(&new->sched);
16750 + vx_info_init_cvirt(&new->cvirt);
16751 + vx_info_init_cacct(&new->cacct);
16753 + /* per cpu data structures */
16754 + for_each_possible_cpu(cpu) {
16755 + vx_info_init_sched_pc(
16756 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16757 + vx_info_init_cvirt_pc(
16758 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16761 + new->vx_flags = VXF_INIT_SET;
16762 + cap_set_init_eff(new->vx_bcaps);
16763 + new->vx_ccaps = 0;
16764 + // new->vx_cap_bset = current->cap_bset;
16766 + new->reboot_cmd = 0;
16767 + new->exit_code = 0;
16769 + vxdprintk(VXD_CBIT(xid, 0),
16770 + "alloc_vx_info(%d) = %p", xid, new);
16771 + vxh_alloc_vx_info(new);
16772 + atomic_inc(&vx_global_ctotal);
16781 +/* __dealloc_vx_info()
16783 + * final disposal of vx_info */
16785 +static void __dealloc_vx_info(struct vx_info *vxi)
16787 + struct vx_info_save vxis;
16790 + vxdprintk(VXD_CBIT(xid, 0),
16791 + "dealloc_vx_info(%p)", vxi);
16792 + vxh_dealloc_vx_info(vxi);
16794 +#ifdef CONFIG_VSERVER_WARN
16795 + enter_vx_info(vxi, &vxis);
16796 + vx_info_exit_limit(&vxi->limit);
16797 + vx_info_exit_sched(&vxi->sched);
16798 + vx_info_exit_cvirt(&vxi->cvirt);
16799 + vx_info_exit_cacct(&vxi->cacct);
16801 + for_each_possible_cpu(cpu) {
16802 + vx_info_exit_sched_pc(
16803 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16804 + vx_info_exit_cvirt_pc(
16805 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16807 + leave_vx_info(&vxis);
16811 + vxi->vx_state |= VXS_RELEASED;
16814 + free_percpu(vxi->ptr_pc);
16817 + atomic_dec(&vx_global_ctotal);
16820 +static void __shutdown_vx_info(struct vx_info *vxi)
16822 + struct nsproxy *nsproxy;
16823 + struct fs_struct *fs;
16827 + vxi->vx_state |= VXS_SHUTDOWN;
16828 + vs_state_change(vxi, VSC_SHUTDOWN);
16830 + nsproxy = xchg(&vxi->vx_nsproxy, NULL);
16831 + fs = xchg(&vxi->vx_fs, NULL);
16834 + put_nsproxy(nsproxy);
16836 + put_fs_struct(fs);
16839 +/* exported stuff */
16841 +void free_vx_info(struct vx_info *vxi)
16843 + unsigned long flags;
16845 + /* check for reference counts first */
16846 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16847 + BUG_ON(atomic_read(&vxi->vx_tasks));
16849 + /* context must not be hashed */
16850 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16852 + /* context shutdown is mandatory */
16853 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16855 + BUG_ON(vxi->vx_nsproxy);
16856 + BUG_ON(vxi->vx_fs);
16858 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16859 + hlist_del(&vxi->vx_hlist);
16860 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16862 + __dealloc_vx_info(vxi);
16866 +/* hash table for vx_info hash */
16868 +#define VX_HASH_SIZE 13
16870 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16871 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16873 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
16876 +static inline unsigned int __hashval(xid_t xid)
16878 + return (xid % VX_HASH_SIZE);
16883 +/* __hash_vx_info()
16885 + * add the vxi to the global hash table
16886 + * requires the hash_lock to be held */
16888 +static inline void __hash_vx_info(struct vx_info *vxi)
16890 + struct hlist_head *head;
16892 + vxd_assert_lock(&vx_info_hash_lock);
16893 + vxdprintk(VXD_CBIT(xid, 4),
16894 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16895 + vxh_hash_vx_info(vxi);
16897 + /* context must not be hashed */
16898 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16900 + vxi->vx_state |= VXS_HASHED;
16901 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16902 + hlist_add_head(&vxi->vx_hlist, head);
16903 + atomic_inc(&vx_global_cactive);
16906 +/* __unhash_vx_info()
16908 + * remove the vxi from the global hash table
16909 + * requires the hash_lock to be held */
16911 +static inline void __unhash_vx_info(struct vx_info *vxi)
16913 + unsigned long flags;
16915 + vxd_assert_lock(&vx_info_hash_lock);
16916 + vxdprintk(VXD_CBIT(xid, 4),
16917 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16918 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16919 + vxh_unhash_vx_info(vxi);
16921 + /* context must be hashed */
16922 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16923 + /* but without tasks */
16924 + BUG_ON(atomic_read(&vxi->vx_tasks));
16926 + vxi->vx_state &= ~VXS_HASHED;
16927 + hlist_del_init(&vxi->vx_hlist);
16928 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16929 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16930 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16931 + atomic_dec(&vx_global_cactive);
16935 +/* __lookup_vx_info()
16937 + * requires the hash_lock to be held
16938 + * doesn't increment the vx_refcnt */
16940 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16942 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16943 + struct hlist_node *pos;
16944 + struct vx_info *vxi;
16946 + vxd_assert_lock(&vx_info_hash_lock);
16947 + hlist_for_each(pos, head) {
16948 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16950 + if (vxi->vx_id == xid)
16955 + vxdprintk(VXD_CBIT(xid, 0),
16956 + "__lookup_vx_info(#%u): %p[#%u]",
16957 + xid, vxi, vxi ? vxi->vx_id : 0);
16958 + vxh_lookup_vx_info(vxi, xid);
16963 +/* __create_vx_info()
16965 + * create the requested context
16966 + * get(), claim() and hash it */
16968 +static struct vx_info *__create_vx_info(int id)
16970 + struct vx_info *new, *vxi = NULL;
16972 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16974 + if (!(new = __alloc_vx_info(id)))
16975 + return ERR_PTR(-ENOMEM);
16977 + /* required to make dynamic xids unique */
16978 + spin_lock(&vx_info_hash_lock);
16980 + /* static context requested */
16981 + if ((vxi = __lookup_vx_info(id))) {
16982 + vxdprintk(VXD_CBIT(xid, 0),
16983 + "create_vx_info(%d) = %p (already there)", id, vxi);
16984 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16985 + vxi = ERR_PTR(-EBUSY);
16987 + vxi = ERR_PTR(-EEXIST);
16990 + /* new context */
16991 + vxdprintk(VXD_CBIT(xid, 0),
16992 + "create_vx_info(%d) = %p (new)", id, new);
16993 + claim_vx_info(new, NULL);
16994 + __hash_vx_info(get_vx_info(new));
16995 + vxi = new, new = NULL;
16998 + spin_unlock(&vx_info_hash_lock);
16999 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
17001 + __dealloc_vx_info(new);
17006 +/* exported stuff */
17009 +void unhash_vx_info(struct vx_info *vxi)
17011 + __shutdown_vx_info(vxi);
17012 + spin_lock(&vx_info_hash_lock);
17013 + __unhash_vx_info(vxi);
17014 + spin_unlock(&vx_info_hash_lock);
17015 + __wakeup_vx_info(vxi);
17019 +/* lookup_vx_info()
17021 + * search for a vx_info and get() it
17022 + * negative id means current */
17024 +struct vx_info *lookup_vx_info(int id)
17026 + struct vx_info *vxi = NULL;
17029 + vxi = get_vx_info(current->vx_info);
17030 + } else if (id > 1) {
17031 + spin_lock(&vx_info_hash_lock);
17032 + vxi = get_vx_info(__lookup_vx_info(id));
17033 + spin_unlock(&vx_info_hash_lock);
17038 +/* xid_is_hashed()
17040 + * verify that xid is still hashed */
17042 +int xid_is_hashed(xid_t xid)
17046 + spin_lock(&vx_info_hash_lock);
17047 + hashed = (__lookup_vx_info(xid) != NULL);
17048 + spin_unlock(&vx_info_hash_lock);
17052 +#ifdef CONFIG_PROC_FS
17056 + * get a subset of hashed xids for proc
17057 + * assumes size is at least one */
17059 +int get_xid_list(int index, unsigned int *xids, int size)
17061 + int hindex, nr_xids = 0;
17063 + /* only show current and children */
17064 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
17067 + xids[nr_xids] = vx_current_xid();
17071 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
17072 + struct hlist_head *head = &vx_info_hash[hindex];
17073 + struct hlist_node *pos;
17075 + spin_lock(&vx_info_hash_lock);
17076 + hlist_for_each(pos, head) {
17077 + struct vx_info *vxi;
17082 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17083 + xids[nr_xids] = vxi->vx_id;
17084 + if (++nr_xids >= size) {
17085 + spin_unlock(&vx_info_hash_lock);
17089 + /* keep the lock time short */
17090 + spin_unlock(&vx_info_hash_lock);
17097 +#ifdef CONFIG_VSERVER_DEBUG
17099 +void dump_vx_info_inactive(int level)
17101 + struct hlist_node *entry, *next;
17103 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
17104 + struct vx_info *vxi =
17105 + list_entry(entry, struct vx_info, vx_hlist);
17107 + dump_vx_info(vxi, level);
17114 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
17116 + struct user_struct *new_user, *old_user;
17121 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
17124 + new_user = alloc_uid(vxi->vx_id, p->uid);
17128 + old_user = p->user;
17129 + if (new_user != old_user) {
17130 + atomic_inc(&new_user->processes);
17131 + atomic_dec(&old_user->processes);
17132 + p->user = new_user;
17134 + free_uid(old_user);
17140 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
17142 + // p->cap_effective &= vxi->vx_cap_bset;
17143 + p->cap_effective =
17144 + cap_intersect(p->cap_effective, vxi->cap_bset);
17145 + // p->cap_inheritable &= vxi->vx_cap_bset;
17146 + p->cap_inheritable =
17147 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
17148 + // p->cap_permitted &= vxi->vx_cap_bset;
17149 + p->cap_permitted =
17150 + cap_intersect(p->cap_permitted, vxi->cap_bset);
17155 +#include <linux/file.h>
17156 +#include <linux/fdtable.h>
17158 +static int vx_openfd_task(struct task_struct *tsk)
17160 + struct files_struct *files = tsk->files;
17161 + struct fdtable *fdt;
17162 + const unsigned long *bptr;
17163 + int count, total;
17165 + /* no rcu_read_lock() because of spin_lock() */
17166 + spin_lock(&files->file_lock);
17167 + fdt = files_fdtable(files);
17168 + bptr = fdt->open_fds->fds_bits;
17169 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
17170 + for (total = 0; count > 0; count--) {
17172 + total += hweight_long(*bptr);
17175 + spin_unlock(&files->file_lock);
17180 +/* for *space compatibility */
17182 +asmlinkage long sys_unshare(unsigned long);
17185 + * migrate task to new context
17186 + * gets vxi, puts old_vxi on change
17187 + * optionally unshares namespaces (hack)
17190 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
17192 + struct vx_info *old_vxi;
17198 + vxdprintk(VXD_CBIT(xid, 5),
17199 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
17200 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
17202 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
17203 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17206 + if (vx_info_state(vxi, VXS_SHUTDOWN))
17209 + old_vxi = task_get_vx_info(p);
17210 + if (old_vxi == vxi)
17213 +// if (!(ret = vx_migrate_user(p, vxi))) {
17218 + openfd = vx_openfd_task(p);
17221 + atomic_dec(&old_vxi->cvirt.nr_threads);
17222 + atomic_dec(&old_vxi->cvirt.nr_running);
17223 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
17224 + /* FIXME: what about the struct files here? */
17225 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
17226 + /* account for the executable */
17227 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
17229 + atomic_inc(&vxi->cvirt.nr_threads);
17230 + atomic_inc(&vxi->cvirt.nr_running);
17231 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
17232 + /* FIXME: what about the struct files here? */
17233 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
17234 + /* account for the executable */
17235 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
17238 + release_vx_info(old_vxi, p);
17239 + clr_vx_info(&p->vx_info);
17241 + claim_vx_info(vxi, p);
17242 + set_vx_info(&p->vx_info, vxi);
17243 + p->xid = vxi->vx_id;
17245 + vxdprintk(VXD_CBIT(xid, 5),
17246 + "moved task %p into vxi:%p[#%d]",
17247 + p, vxi, vxi->vx_id);
17249 + // vx_mask_cap_bset(vxi, p);
17252 + /* hack for *spaces to provide compatibility */
17254 + struct nsproxy *old_nsp, *new_nsp;
17256 + ret = unshare_nsproxy_namespaces(
17257 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
17262 + old_nsp = xchg(&p->nsproxy, new_nsp);
17263 + vx_set_space(vxi, CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER);
17264 + put_nsproxy(old_nsp);
17268 + put_vx_info(old_vxi);
17272 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
17274 + struct task_struct *old_reaper;
17279 + vxdprintk(VXD_CBIT(xid, 6),
17280 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
17281 + vxi, vxi->vx_id, p, p->xid, p->pid);
17283 + old_reaper = vxi->vx_reaper;
17284 + if (old_reaper == p)
17287 + /* set new child reaper */
17288 + get_task_struct(p);
17289 + vxi->vx_reaper = p;
17290 + put_task_struct(old_reaper);
17294 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
17299 + vxdprintk(VXD_CBIT(xid, 6),
17300 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
17301 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17303 + vxi->vx_flags &= ~VXF_STATE_INIT;
17304 + vxi->vx_initpid = p->tgid;
17308 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
17310 + vxdprintk(VXD_CBIT(xid, 6),
17311 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
17312 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17314 + vxi->exit_code = code;
17315 + vxi->vx_initpid = 0;
17319 +void vx_set_persistent(struct vx_info *vxi)
17321 + vxdprintk(VXD_CBIT(xid, 6),
17322 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
17324 + get_vx_info(vxi);
17325 + claim_vx_info(vxi, NULL);
17328 +void vx_clear_persistent(struct vx_info *vxi)
17330 + vxdprintk(VXD_CBIT(xid, 6),
17331 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
17333 + release_vx_info(vxi, NULL);
17334 + put_vx_info(vxi);
17337 +void vx_update_persistent(struct vx_info *vxi)
17339 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
17340 + vx_set_persistent(vxi);
17342 + vx_clear_persistent(vxi);
17346 +/* task must be current or locked */
17348 +void exit_vx_info(struct task_struct *p, int code)
17350 + struct vx_info *vxi = p->vx_info;
17353 + atomic_dec(&vxi->cvirt.nr_threads);
17356 + vxi->exit_code = code;
17357 + release_vx_info(vxi, p);
17361 +void exit_vx_info_early(struct task_struct *p, int code)
17363 + struct vx_info *vxi = p->vx_info;
17366 + if (vxi->vx_initpid == p->tgid)
17367 + vx_exit_init(vxi, p, code);
17368 + if (vxi->vx_reaper == p)
17369 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
17374 +/* vserver syscall commands below here */
17376 +/* taks xid and vx_info functions */
17378 +#include <asm/uaccess.h>
17381 +int vc_task_xid(uint32_t id)
17386 + struct task_struct *tsk;
17388 + read_lock(&tasklist_lock);
17389 + tsk = find_task_by_real_pid(id);
17390 + xid = (tsk) ? tsk->xid : -ESRCH;
17391 + read_unlock(&tasklist_lock);
17393 + xid = vx_current_xid();
17398 +int vc_vx_info(struct vx_info *vxi, void __user *data)
17400 + struct vcmd_vx_info_v0 vc_data;
17402 + vc_data.xid = vxi->vx_id;
17403 + vc_data.initpid = vxi->vx_initpid;
17405 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17411 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
17413 + struct vcmd_ctx_stat_v0 vc_data;
17415 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
17416 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
17418 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17424 +/* context functions */
17426 +int vc_ctx_create(uint32_t xid, void __user *data)
17428 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
17429 + struct vx_info *new_vxi;
17432 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17435 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
17438 + new_vxi = __create_vx_info(xid);
17439 + if (IS_ERR(new_vxi))
17440 + return PTR_ERR(new_vxi);
17442 + /* initial flags */
17443 + new_vxi->vx_flags = vc_data.flagword;
17446 + if (vs_state_change(new_vxi, VSC_STARTUP))
17449 + ret = vx_migrate_task(current, new_vxi, (!data));
17453 + /* return context id on success */
17454 + ret = new_vxi->vx_id;
17456 + /* get a reference for persistent contexts */
17457 + if ((vc_data.flagword & VXF_PERSISTENT))
17458 + vx_set_persistent(new_vxi);
17460 + release_vx_info(new_vxi, NULL);
17461 + put_vx_info(new_vxi);
17466 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17468 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17471 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17474 + ret = vx_migrate_task(current, vxi, 0);
17477 + if (vc_data.flagword & VXM_SET_INIT)
17478 + ret = vx_set_init(vxi, current);
17481 + if (vc_data.flagword & VXM_SET_REAPER)
17482 + ret = vx_set_reaper(vxi, current);
17487 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17489 + struct vcmd_ctx_flags_v0 vc_data;
17491 + vc_data.flagword = vxi->vx_flags;
17493 + /* special STATE flag handling */
17494 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17496 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17501 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17503 + struct vcmd_ctx_flags_v0 vc_data;
17504 + uint64_t mask, trigger;
17506 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17509 + /* special STATE flag handling */
17510 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17511 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17513 + if (vxi == current->vx_info) {
17514 + /* if (trigger & VXF_STATE_SETUP)
17515 + vx_mask_cap_bset(vxi, current); */
17516 + if (trigger & VXF_STATE_INIT) {
17519 + ret = vx_set_init(vxi, current);
17522 + ret = vx_set_reaper(vxi, current);
17528 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17529 + vc_data.flagword, mask);
17530 + if (trigger & VXF_PERSISTENT)
17531 + vx_update_persistent(vxi);
17537 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17539 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17541 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17545 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17547 + kernel_cap_t c = __cap_empty_set;
17549 + c.cap[0] = v & 0xFFFFFFFF;
17550 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17552 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17557 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17560 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17562 + *ccaps = vxi->vx_ccaps;
17567 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17569 + struct vcmd_ctx_caps_v1 vc_data;
17572 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17575 + vc_data.cmask = ~0ULL;
17577 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17582 +static int do_set_caps(struct vx_info *vxi,
17583 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17585 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17588 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17589 + bcaps, bmask, ccaps, cmask);
17591 + vxi->vx_bcaps = cap_t_from_caps(
17592 + vs_mask_flags(bcold, bcaps, bmask));
17593 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17598 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17600 + struct vcmd_ctx_caps_v1 vc_data;
17602 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17605 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17608 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17610 + struct vcmd_bcaps vc_data;
17613 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17616 + vc_data.bmask = ~0ULL;
17618 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17623 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17625 + struct vcmd_bcaps vc_data;
17627 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17630 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17634 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17636 + struct vcmd_badness_v0 vc_data;
17638 + vc_data.bias = vxi->vx_badness_bias;
17640 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17645 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17647 + struct vcmd_badness_v0 vc_data;
17649 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17652 + vxi->vx_badness_bias = vc_data.bias;
17656 +#include <linux/module.h>
17658 +EXPORT_SYMBOL_GPL(free_vx_info);
17660 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/cvirt.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cvirt.c
17661 --- linux-2.6.27.3/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17662 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cvirt.c 2008-10-13 14:54:20.000000000 +0200
17665 + * linux/kernel/vserver/cvirt.c
17667 + * Virtual Server: Context Virtualization
17669 + * Copyright (C) 2004-2007 Herbert Pötzl
17671 + * V0.01 broken out from limit.c
17672 + * V0.02 added utsname stuff
17673 + * V0.03 changed vcmds to vxi arg
17677 +#include <linux/types.h>
17678 +#include <linux/utsname.h>
17679 +#include <linux/vs_cvirt.h>
17680 +#include <linux/vserver/switch.h>
17681 +#include <linux/vserver/cvirt_cmd.h>
17683 +#include <asm/uaccess.h>
17686 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17688 + struct vx_info *vxi = current->vx_info;
17690 + set_normalized_timespec(uptime,
17691 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17692 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17695 + set_normalized_timespec(idle,
17696 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17697 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17701 +uint64_t vx_idle_jiffies(void)
17703 + return init_task.utime + init_task.stime;
17708 +static inline uint32_t __update_loadavg(uint32_t load,
17709 + int wsize, int delta, int n)
17711 + unsigned long long calc, prev;
17713 + /* just set it to n */
17714 + if (unlikely(delta >= wsize))
17715 + return (n << FSHIFT);
17717 + calc = delta * n;
17719 + prev = (wsize - delta);
17722 + do_div(calc, wsize);
17727 +void vx_update_load(struct vx_info *vxi)
17729 + uint32_t now, last, delta;
17730 + unsigned int nr_running, nr_uninterruptible;
17731 + unsigned int total;
17732 + unsigned long flags;
17734 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17737 + last = vxi->cvirt.load_last;
17738 + delta = now - last;
17740 + if (delta < 5*HZ)
17743 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17744 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17745 + total = nr_running + nr_uninterruptible;
17747 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17748 + 60*HZ, delta, total);
17749 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17750 + 5*60*HZ, delta, total);
17751 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17752 + 15*60*HZ, delta, total);
17754 + vxi->cvirt.load_last = now;
17756 + atomic_inc(&vxi->cvirt.load_updates);
17757 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17762 + * Commands to do_syslog:
17764 + * 0 -- Close the log. Currently a NOP.
17765 + * 1 -- Open the log. Currently a NOP.
17766 + * 2 -- Read from the log.
17767 + * 3 -- Read all messages remaining in the ring buffer.
17768 + * 4 -- Read and clear all messages remaining in the ring buffer
17769 + * 5 -- Clear ring buffer.
17770 + * 6 -- Disable printk's to console
17771 + * 7 -- Enable printk's to console
17772 + * 8 -- Set level of messages printed to console
17773 + * 9 -- Return number of unread characters in the log buffer
17774 + * 10 -- Return size of the log buffer
17776 +int vx_do_syslog(int type, char __user *buf, int len)
17779 + int do_clear = 0;
17780 + struct vx_info *vxi = current->vx_info;
17781 + struct _vx_syslog *log;
17785 + log = &vxi->cvirt.syslog;
17788 + case 0: /* Close log */
17789 + case 1: /* Open log */
17791 + case 2: /* Read from log */
17792 + error = wait_event_interruptible(log->log_wait,
17793 + (log->log_start - log->log_end));
17796 + spin_lock_irq(&log->logbuf_lock);
17797 + spin_unlock_irq(&log->logbuf_lock);
17799 + case 4: /* Read/clear last kernel messages */
17801 + /* fall through */
17802 + case 3: /* Read last kernel messages */
17805 + case 5: /* Clear ring buffer */
17808 + case 6: /* Disable logging to console */
17809 + case 7: /* Enable logging to console */
17810 + case 8: /* Set level of messages printed to console */
17813 + case 9: /* Number of chars in the log buffer */
17815 + case 10: /* Size of the log buffer */
17825 +/* virtual host info names */
17827 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17829 + struct nsproxy *nsproxy;
17830 + struct uts_namespace *uts;
17833 + if (id == VHIN_CONTEXT)
17834 + return vxi->vx_name;
17836 + nsproxy = vxi->vx_nsproxy;
17840 + uts = nsproxy->uts_ns;
17845 + case VHIN_SYSNAME:
17846 + return uts->name.sysname;
17847 + case VHIN_NODENAME:
17848 + return uts->name.nodename;
17849 + case VHIN_RELEASE:
17850 + return uts->name.release;
17851 + case VHIN_VERSION:
17852 + return uts->name.version;
17853 + case VHIN_MACHINE:
17854 + return uts->name.machine;
17855 + case VHIN_DOMAINNAME:
17856 + return uts->name.domainname;
17863 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17865 + struct vcmd_vhi_name_v0 vc_data;
17868 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17871 + name = vx_vhi_name(vxi, vc_data.field);
17875 + memcpy(name, vc_data.name, 65);
17879 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17881 + struct vcmd_vhi_name_v0 vc_data;
17884 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17887 + name = vx_vhi_name(vxi, vc_data.field);
17891 + memcpy(vc_data.name, name, 65);
17892 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17898 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17900 + struct vcmd_virt_stat_v0 vc_data;
17901 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17902 + struct timespec uptime;
17904 + do_posix_clock_monotonic_gettime(&uptime);
17905 + set_normalized_timespec(&uptime,
17906 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17907 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17909 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
17910 + vc_data.uptime = timespec_to_ns(&uptime);
17911 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17912 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17913 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17914 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17915 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17916 + vc_data.load[0] = cvirt->load[0];
17917 + vc_data.load[1] = cvirt->load[1];
17918 + vc_data.load[2] = cvirt->load[2];
17920 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17926 +#ifdef CONFIG_VSERVER_VTIME
17928 +/* virtualized time base */
17930 +void vx_gettimeofday(struct timeval *tv)
17932 + do_gettimeofday(tv);
17933 + if (!vx_flags(VXF_VIRT_TIME, 0))
17936 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
17937 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
17939 + if (tv->tv_usec >= USEC_PER_SEC) {
17941 + tv->tv_usec -= USEC_PER_SEC;
17942 + } else if (tv->tv_usec < 0) {
17944 + tv->tv_usec += USEC_PER_SEC;
17948 +int vx_settimeofday(struct timespec *ts)
17950 + struct timeval tv;
17952 + if (!vx_flags(VXF_VIRT_TIME, 0))
17953 + return do_settimeofday(ts);
17955 + do_gettimeofday(&tv);
17956 + current->vx_info->cvirt.bias_tv.tv_sec =
17957 + ts->tv_sec - tv.tv_sec;
17958 + current->vx_info->cvirt.bias_tv.tv_usec =
17959 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
17965 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/cvirt_init.h linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cvirt_init.h
17966 --- linux-2.6.27.3/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17967 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cvirt_init.h 2008-10-13 14:54:20.000000000 +0200
17971 +extern uint64_t vx_idle_jiffies(void);
17973 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17975 + uint64_t idle_jiffies = vx_idle_jiffies();
17976 + uint64_t nsuptime;
17978 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17979 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17980 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17981 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17982 + cvirt->bias_tv.tv_sec = 0;
17983 + cvirt->bias_tv.tv_usec = 0;
17985 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17986 + atomic_set(&cvirt->nr_threads, 0);
17987 + atomic_set(&cvirt->nr_running, 0);
17988 + atomic_set(&cvirt->nr_uninterruptible, 0);
17989 + atomic_set(&cvirt->nr_onhold, 0);
17991 + spin_lock_init(&cvirt->load_lock);
17992 + cvirt->load_last = jiffies;
17993 + atomic_set(&cvirt->load_updates, 0);
17994 + cvirt->load[0] = 0;
17995 + cvirt->load[1] = 0;
17996 + cvirt->load[2] = 0;
17997 + atomic_set(&cvirt->total_forks, 0);
17999 + spin_lock_init(&cvirt->syslog.logbuf_lock);
18000 + init_waitqueue_head(&cvirt->syslog.log_wait);
18001 + cvirt->syslog.log_start = 0;
18002 + cvirt->syslog.log_end = 0;
18003 + cvirt->syslog.con_start = 0;
18004 + cvirt->syslog.logged_chars = 0;
18008 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18010 + // cvirt_pc->cpustat = { 0 };
18013 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
18017 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
18018 + "!!! cvirt: %p[nr_threads] = %d on exit.",
18020 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
18021 + "!!! cvirt: %p[nr_running] = %d on exit.",
18023 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
18024 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
18026 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
18027 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
18033 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18038 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/cvirt_proc.h linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cvirt_proc.h
18039 --- linux-2.6.27.3/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
18040 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/cvirt_proc.h 2008-10-13 14:54:20.000000000 +0200
18042 +#ifndef _VX_CVIRT_PROC_H
18043 +#define _VX_CVIRT_PROC_H
18045 +#include <linux/nsproxy.h>
18046 +#include <linux/mnt_namespace.h>
18047 +#include <linux/ipc_namespace.h>
18048 +#include <linux/utsname.h>
18049 +#include <linux/ipc.h>
18053 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
18055 + struct mnt_namespace *ns;
18056 + struct uts_namespace *uts;
18057 + struct ipc_namespace *ipc;
18058 + struct path path;
18059 + char *pstr, *root;
18065 + length += sprintf(buffer + length,
18066 + "NSProxy:\t%p [%p,%p,%p]\n",
18067 + nsproxy, nsproxy->mnt_ns,
18068 + nsproxy->uts_ns, nsproxy->ipc_ns);
18070 + ns = nsproxy->mnt_ns;
18074 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
18078 + path.mnt = ns->root;
18079 + path.dentry = ns->root->mnt_root;
18080 + root = d_path(&path, pstr, PATH_MAX - 2);
18081 + length += sprintf(buffer + length,
18082 + "Namespace:\t%p [#%u]\n"
18083 + "RootPath:\t%s\n",
18084 + ns, atomic_read(&ns->count),
18089 + uts = nsproxy->uts_ns;
18093 + length += sprintf(buffer + length,
18094 + "SysName:\t%.*s\n"
18095 + "NodeName:\t%.*s\n"
18096 + "Release:\t%.*s\n"
18097 + "Version:\t%.*s\n"
18098 + "Machine:\t%.*s\n"
18099 + "DomainName:\t%.*s\n",
18100 + __NEW_UTS_LEN, uts->name.sysname,
18101 + __NEW_UTS_LEN, uts->name.nodename,
18102 + __NEW_UTS_LEN, uts->name.release,
18103 + __NEW_UTS_LEN, uts->name.version,
18104 + __NEW_UTS_LEN, uts->name.machine,
18105 + __NEW_UTS_LEN, uts->name.domainname);
18108 + ipc = nsproxy->ipc_ns;
18112 + length += sprintf(buffer + length,
18113 + "SEMS:\t\t%d %d %d %d %d\n"
18114 + "MSG:\t\t%d %d %d\n"
18115 + "SHM:\t\t%lu %lu %d %d\n",
18116 + ipc->sem_ctls[0], ipc->sem_ctls[1],
18117 + ipc->sem_ctls[2], ipc->sem_ctls[3],
18119 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
18120 + (unsigned long)ipc->shm_ctlmax,
18121 + (unsigned long)ipc->shm_ctlall,
18122 + ipc->shm_ctlmni, ipc->shm_tot);
18129 +#include <linux/sched.h>
18131 +#define LOAD_INT(x) ((x) >> FSHIFT)
18132 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
18135 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
18140 + length += sprintf(buffer + length,
18141 + "BiasUptime:\t%lu.%02lu\n",
18142 + (unsigned long)cvirt->bias_uptime.tv_sec,
18143 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
18145 + a = cvirt->load[0] + (FIXED_1 / 200);
18146 + b = cvirt->load[1] + (FIXED_1 / 200);
18147 + c = cvirt->load[2] + (FIXED_1 / 200);
18148 + length += sprintf(buffer + length,
18149 + "nr_threads:\t%d\n"
18150 + "nr_running:\t%d\n"
18151 + "nr_unintr:\t%d\n"
18152 + "nr_onhold:\t%d\n"
18153 + "load_updates:\t%d\n"
18154 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
18155 + "total_forks:\t%d\n",
18156 + atomic_read(&cvirt->nr_threads),
18157 + atomic_read(&cvirt->nr_running),
18158 + atomic_read(&cvirt->nr_uninterruptible),
18159 + atomic_read(&cvirt->nr_onhold),
18160 + atomic_read(&cvirt->load_updates),
18161 + LOAD_INT(a), LOAD_FRAC(a),
18162 + LOAD_INT(b), LOAD_FRAC(b),
18163 + LOAD_INT(c), LOAD_FRAC(c),
18164 + atomic_read(&cvirt->total_forks));
18169 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
18170 + char *buffer, int cpu)
18176 +#endif /* _VX_CVIRT_PROC_H */
18177 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/debug.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/debug.c
18178 --- linux-2.6.27.3/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
18179 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/debug.c 2008-10-13 14:54:20.000000000 +0200
18182 + * kernel/vserver/debug.c
18184 + * Copyright (C) 2005-2007 Herbert Pötzl
18186 + * V0.01 vx_info dump support
18190 +#include <linux/module.h>
18192 +#include <linux/vserver/context.h>
18195 +void dump_vx_info(struct vx_info *vxi, int level)
18197 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
18198 + atomic_read(&vxi->vx_usecnt),
18199 + atomic_read(&vxi->vx_tasks),
18202 + __dump_vx_limit(&vxi->limit);
18203 + __dump_vx_sched(&vxi->sched);
18204 + __dump_vx_cvirt(&vxi->cvirt);
18205 + __dump_vx_cacct(&vxi->cacct);
18211 +EXPORT_SYMBOL_GPL(dump_vx_info);
18213 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/device.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/device.c
18214 --- linux-2.6.27.3/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
18215 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/device.c 2008-10-13 14:54:20.000000000 +0200
18218 + * linux/kernel/vserver/device.c
18220 + * Linux-VServer: Device Support
18222 + * Copyright (C) 2006 Herbert Pötzl
18223 + * Copyright (C) 2007 Daniel Hokka Zakrisson
18225 + * V0.01 device mapping basics
18226 + * V0.02 added defaults
18230 +#include <linux/slab.h>
18231 +#include <linux/rcupdate.h>
18232 +#include <linux/fs.h>
18233 +#include <linux/namei.h>
18234 +#include <linux/hash.h>
18236 +#include <asm/errno.h>
18237 +#include <asm/uaccess.h>
18238 +#include <linux/vserver/base.h>
18239 +#include <linux/vserver/debug.h>
18240 +#include <linux/vserver/context.h>
18241 +#include <linux/vserver/device.h>
18242 +#include <linux/vserver/device_cmd.h>
18245 +#define DMAP_HASH_BITS 4
18248 +struct vs_mapping {
18250 + struct hlist_node hlist;
18251 + struct list_head list;
18253 +#define dm_hlist u.hlist
18254 +#define dm_list u.list
18257 + struct vx_dmap_target target;
18261 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
18263 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
18265 +static struct vx_dmap_target dmap_defaults[2] = {
18266 + { .flags = DATTR_OPEN },
18267 + { .flags = DATTR_OPEN },
18271 +struct kmem_cache *dmap_cachep __read_mostly;
18273 +int __init dmap_cache_init(void)
18275 + dmap_cachep = kmem_cache_create("dmap_cache",
18276 + sizeof(struct vs_mapping), 0,
18277 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
18281 +__initcall(dmap_cache_init);
18284 +static inline unsigned int __hashval(dev_t dev, int bits)
18286 + return hash_long((unsigned long)dev, bits);
18290 +/* __hash_mapping()
18291 + * add the mapping to the hash table
18293 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
18295 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18296 + struct hlist_head *head, *hash = dmap_main_hash;
18297 + int device = vdm->device;
18299 + spin_lock(hash_lock);
18300 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
18301 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
18303 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
18304 + hlist_add_head(&vdm->dm_hlist, head);
18305 + spin_unlock(hash_lock);
18309 +static inline int __mode_to_default(umode_t mode)
18322 +/* __set_default()
18325 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
18326 + struct vx_dmap_target *vdmt)
18328 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18329 + spin_lock(hash_lock);
18332 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
18334 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
18337 + spin_unlock(hash_lock);
18339 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
18340 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
18344 +/* __remove_default()
18345 + * remove a default
18347 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
18349 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18350 + spin_lock(hash_lock);
18353 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
18354 + else /* remove == reset */
18355 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
18357 + spin_unlock(hash_lock);
18362 +/* __find_mapping()
18363 + * find a mapping in the hash table
18365 + * caller must hold hash_lock
18367 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
18368 + struct vs_mapping **local, struct vs_mapping **global)
18370 + struct hlist_head *hash = dmap_main_hash;
18371 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
18372 + struct hlist_node *pos;
18373 + struct vs_mapping *vdm;
18379 + hlist_for_each(pos, head) {
18380 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
18382 + if ((vdm->device == device) &&
18383 + !((vdm->target.flags ^ mode) & S_IFMT)) {
18384 + if (vdm->xid == xid) {
18387 + } else if (global && vdm->xid == 0)
18392 + if (global && *global)
18399 +/* __lookup_mapping()
18400 + * find a mapping and store the result in target and flags
18402 +static inline int __lookup_mapping(struct vx_info *vxi,
18403 + dev_t device, dev_t *target, int *flags, umode_t mode)
18405 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18406 + struct vs_mapping *vdm, *global;
18407 + struct vx_dmap_target *vdmt;
18409 + xid_t xid = vxi->vx_id;
18412 + spin_lock(hash_lock);
18413 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18415 + vdmt = &vdm->target;
18419 + index = __mode_to_default(mode);
18420 + if (vxi && vxi->dmap.targets[index].flags) {
18422 + vdmt = &vxi->dmap.targets[index];
18423 + } else if (global) {
18425 + vdmt = &global->target;
18429 + vdmt = &dmap_defaults[index];
18433 + if (target && (vdmt->flags & DATTR_REMAP))
18434 + *target = vdmt->target;
18436 + *target = device;
18438 + *flags = vdmt->flags;
18440 + spin_unlock(hash_lock);
18446 +/* __remove_mapping()
18447 + * remove a mapping from the hash table
18449 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18452 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18453 + struct vs_mapping *vdm = NULL;
18456 + spin_lock(hash_lock);
18458 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18460 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18461 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18464 + hlist_del(&vdm->dm_hlist);
18467 + spin_unlock(hash_lock);
18469 + kmem_cache_free(dmap_cachep, vdm);
18475 +int vs_map_device(struct vx_info *vxi,
18476 + dev_t device, dev_t *target, umode_t mode)
18478 + int ret, flags = DATTR_MASK;
18482 + *target = device;
18485 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18486 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18487 + device, target ? *target : 0, flags, mode, ret);
18489 + return (flags & DATTR_MASK);
18494 +static int do_set_mapping(struct vx_info *vxi,
18495 + dev_t device, dev_t target, int flags, umode_t mode)
18498 + struct vs_mapping *new;
18500 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18504 + INIT_HLIST_NODE(&new->dm_hlist);
18505 + new->device = device;
18506 + new->target.target = target;
18507 + new->target.flags = flags | mode;
18508 + new->xid = (vxi ? vxi->vx_id : 0);
18510 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18511 + __hash_mapping(vxi, new);
18513 + struct vx_dmap_target new = {
18514 + .target = target,
18515 + .flags = flags | mode,
18517 + __set_default(vxi, mode, &new);
18523 +static int do_unset_mapping(struct vx_info *vxi,
18524 + dev_t device, dev_t target, int flags, umode_t mode)
18526 + int ret = -EINVAL;
18529 + ret = __remove_mapping(vxi, device, mode);
18533 + ret = __remove_default(vxi, mode);
18543 +static inline int __user_device(const char __user *name, dev_t *dev,
18546 + struct nameidata nd;
18553 + ret = user_lpath(name, &nd.path);
18556 + if (nd.path.dentry->d_inode) {
18557 + *dev = nd.path.dentry->d_inode->i_rdev;
18558 + *mode = nd.path.dentry->d_inode->i_mode;
18560 + path_put(&nd.path);
18564 +static inline int __mapping_mode(dev_t device, dev_t target,
18565 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18568 + *mode = device_mode & S_IFMT;
18570 + *mode = target_mode & S_IFMT;
18574 + /* if both given, device and target mode have to match */
18575 + if (device && target &&
18576 + ((device_mode ^ target_mode) & S_IFMT))
18582 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18583 + const char __user *target_path, int flags, int set)
18585 + dev_t device = ~0, target = ~0;
18586 + umode_t device_mode = 0, target_mode = 0, mode;
18589 + ret = __user_device(device_path, &device, &device_mode);
18592 + ret = __user_device(target_path, &target, &target_mode);
18596 + ret = __mapping_mode(device, target,
18597 + device_mode, target_mode, &mode);
18602 + return do_set_mapping(vxi, device, target,
18605 + return do_unset_mapping(vxi, device, target,
18610 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18612 + struct vcmd_set_mapping_v0 vc_data;
18614 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18617 + return do_mapping(vxi, vc_data.device, vc_data.target,
18618 + vc_data.flags, 1);
18621 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18623 + struct vcmd_set_mapping_v0 vc_data;
18625 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18628 + return do_mapping(vxi, vc_data.device, vc_data.target,
18629 + vc_data.flags, 0);
18633 +#ifdef CONFIG_COMPAT
18635 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18637 + struct vcmd_set_mapping_v0_x32 vc_data;
18639 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18642 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18643 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18646 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18648 + struct vcmd_set_mapping_v0_x32 vc_data;
18650 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18653 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18654 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18657 +#endif /* CONFIG_COMPAT */
18660 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/dlimit.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/dlimit.c
18661 --- linux-2.6.27.3/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18662 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/dlimit.c 2008-10-13 14:54:20.000000000 +0200
18665 + * linux/kernel/vserver/dlimit.c
18667 + * Virtual Server: Context Disk Limits
18669 + * Copyright (C) 2004-2007 Herbert Pötzl
18671 + * V0.01 initial version
18672 + * V0.02 compat32 splitup
18676 +#include <linux/statfs.h>
18677 +#include <linux/sched.h>
18678 +#include <linux/namei.h>
18679 +#include <linux/vs_tag.h>
18680 +#include <linux/vs_dlimit.h>
18681 +#include <linux/vserver/dlimit_cmd.h>
18683 +#include <asm/uaccess.h>
18685 +/* __alloc_dl_info()
18687 + * allocate an initialized dl_info struct
18688 + * doesn't make it visible (hash) */
18690 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18692 + struct dl_info *new = NULL;
18694 + vxdprintk(VXD_CBIT(dlim, 5),
18695 + "alloc_dl_info(%p,%d)*", sb, tag);
18697 + /* would this benefit from a slab cache? */
18698 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18702 + memset(new, 0, sizeof(struct dl_info));
18703 + new->dl_tag = tag;
18705 + INIT_RCU_HEAD(&new->dl_rcu);
18706 + INIT_HLIST_NODE(&new->dl_hlist);
18707 + spin_lock_init(&new->dl_lock);
18708 + atomic_set(&new->dl_refcnt, 0);
18709 + atomic_set(&new->dl_usecnt, 0);
18711 + /* rest of init goes here */
18713 + vxdprintk(VXD_CBIT(dlim, 4),
18714 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18718 +/* __dealloc_dl_info()
18720 + * final disposal of dl_info */
18722 +static void __dealloc_dl_info(struct dl_info *dli)
18724 + vxdprintk(VXD_CBIT(dlim, 4),
18725 + "dealloc_dl_info(%p)", dli);
18727 + dli->dl_hlist.next = LIST_POISON1;
18728 + dli->dl_tag = -1;
18731 + BUG_ON(atomic_read(&dli->dl_usecnt));
18732 + BUG_ON(atomic_read(&dli->dl_refcnt));
18738 +/* hash table for dl_info hash */
18740 +#define DL_HASH_SIZE 13
18742 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18744 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
18747 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18749 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18754 +/* __hash_dl_info()
18756 + * add the dli to the global hash table
18757 + * requires the hash_lock to be held */
18759 +static inline void __hash_dl_info(struct dl_info *dli)
18761 + struct hlist_head *head;
18763 + vxdprintk(VXD_CBIT(dlim, 6),
18764 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18765 + get_dl_info(dli);
18766 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18767 + hlist_add_head_rcu(&dli->dl_hlist, head);
18770 +/* __unhash_dl_info()
18772 + * remove the dli from the global hash table
18773 + * requires the hash_lock to be held */
18775 +static inline void __unhash_dl_info(struct dl_info *dli)
18777 + vxdprintk(VXD_CBIT(dlim, 6),
18778 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18779 + hlist_del_rcu(&dli->dl_hlist);
18780 + put_dl_info(dli);
18784 +/* __lookup_dl_info()
18786 + * requires the rcu_read_lock()
18787 + * doesn't increment the dl_refcnt */
18789 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18791 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18792 + struct hlist_node *pos;
18793 + struct dl_info *dli;
18795 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18797 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18805 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18807 + struct dl_info *dli;
18810 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18811 + vxdprintk(VXD_CBIT(dlim, 7),
18812 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18813 + rcu_read_unlock();
18817 +void rcu_free_dl_info(struct rcu_head *head)
18819 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18820 + int usecnt, refcnt;
18822 + BUG_ON(!dli || !head);
18824 + usecnt = atomic_read(&dli->dl_usecnt);
18825 + BUG_ON(usecnt < 0);
18827 + refcnt = atomic_read(&dli->dl_refcnt);
18828 + BUG_ON(refcnt < 0);
18830 + vxdprintk(VXD_CBIT(dlim, 3),
18831 + "rcu_free_dl_info(%p)", dli);
18833 + __dealloc_dl_info(dli);
18835 + printk("!!! rcu didn't free\n");
18841 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18842 + uint32_t flags, int add)
18844 + struct path path;
18847 + ret = user_lpath(name, &path);
18849 + struct super_block *sb;
18850 + struct dl_info *dli;
18853 + if (!path.dentry->d_inode)
18854 + goto out_release;
18855 + if (!(sb = path.dentry->d_inode->i_sb))
18856 + goto out_release;
18859 + dli = __alloc_dl_info(sb, id);
18860 + spin_lock(&dl_info_hash_lock);
18863 + if (__lookup_dl_info(sb, id))
18865 + __hash_dl_info(dli);
18868 + spin_lock(&dl_info_hash_lock);
18869 + dli = __lookup_dl_info(sb, id);
18874 + __unhash_dl_info(dli);
18878 + spin_unlock(&dl_info_hash_lock);
18880 + __dealloc_dl_info(dli);
18887 +int vc_add_dlimit(uint32_t id, void __user *data)
18889 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18891 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18894 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18897 +int vc_rem_dlimit(uint32_t id, void __user *data)
18899 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18901 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18904 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18907 +#ifdef CONFIG_COMPAT
18909 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18911 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18913 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18916 + return do_addrem_dlimit(id,
18917 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18920 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18922 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18924 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18927 + return do_addrem_dlimit(id,
18928 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18931 +#endif /* CONFIG_COMPAT */
18935 +int do_set_dlimit(uint32_t id, const char __user *name,
18936 + uint32_t space_used, uint32_t space_total,
18937 + uint32_t inodes_used, uint32_t inodes_total,
18938 + uint32_t reserved, uint32_t flags)
18940 + struct path path;
18943 + ret = user_lpath(name, &path);
18945 + struct super_block *sb;
18946 + struct dl_info *dli;
18949 + if (!path.dentry->d_inode)
18950 + goto out_release;
18951 + if (!(sb = path.dentry->d_inode->i_sb))
18952 + goto out_release;
18953 + if ((reserved != CDLIM_KEEP &&
18954 + reserved > 100) ||
18955 + (inodes_used != CDLIM_KEEP &&
18956 + inodes_used > inodes_total) ||
18957 + (space_used != CDLIM_KEEP &&
18958 + space_used > space_total))
18959 + goto out_release;
18962 + dli = locate_dl_info(sb, id);
18964 + goto out_release;
18966 + spin_lock(&dli->dl_lock);
18968 + if (inodes_used != CDLIM_KEEP)
18969 + dli->dl_inodes_used = inodes_used;
18970 + if (inodes_total != CDLIM_KEEP)
18971 + dli->dl_inodes_total = inodes_total;
18972 + if (space_used != CDLIM_KEEP) {
18973 + dli->dl_space_used = space_used;
18974 + dli->dl_space_used <<= 10;
18976 + if (space_total == CDLIM_INFINITY)
18977 + dli->dl_space_total = DLIM_INFINITY;
18978 + else if (space_total != CDLIM_KEEP) {
18979 + dli->dl_space_total = space_total;
18980 + dli->dl_space_total <<= 10;
18982 + if (reserved != CDLIM_KEEP)
18983 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18985 + spin_unlock(&dli->dl_lock);
18987 + put_dl_info(dli);
18996 +int vc_set_dlimit(uint32_t id, void __user *data)
18998 + struct vcmd_ctx_dlimit_v0 vc_data;
19000 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19003 + return do_set_dlimit(id, vc_data.name,
19004 + vc_data.space_used, vc_data.space_total,
19005 + vc_data.inodes_used, vc_data.inodes_total,
19006 + vc_data.reserved, vc_data.flags);
19009 +#ifdef CONFIG_COMPAT
19011 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
19013 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19015 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19018 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
19019 + vc_data.space_used, vc_data.space_total,
19020 + vc_data.inodes_used, vc_data.inodes_total,
19021 + vc_data.reserved, vc_data.flags);
19024 +#endif /* CONFIG_COMPAT */
19028 +int do_get_dlimit(uint32_t id, const char __user *name,
19029 + uint32_t *space_used, uint32_t *space_total,
19030 + uint32_t *inodes_used, uint32_t *inodes_total,
19031 + uint32_t *reserved, uint32_t *flags)
19033 + struct path path;
19036 + ret = user_lpath(name, &path);
19038 + struct super_block *sb;
19039 + struct dl_info *dli;
19042 + if (!path.dentry->d_inode)
19043 + goto out_release;
19044 + if (!(sb = path.dentry->d_inode->i_sb))
19045 + goto out_release;
19048 + dli = locate_dl_info(sb, id);
19050 + goto out_release;
19052 + spin_lock(&dli->dl_lock);
19053 + *inodes_used = dli->dl_inodes_used;
19054 + *inodes_total = dli->dl_inodes_total;
19055 + *space_used = dli->dl_space_used >> 10;
19056 + if (dli->dl_space_total == DLIM_INFINITY)
19057 + *space_total = CDLIM_INFINITY;
19059 + *space_total = dli->dl_space_total >> 10;
19061 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
19062 + spin_unlock(&dli->dl_lock);
19064 + put_dl_info(dli);
19075 +int vc_get_dlimit(uint32_t id, void __user *data)
19077 + struct vcmd_ctx_dlimit_v0 vc_data;
19080 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19083 + ret = do_get_dlimit(id, vc_data.name,
19084 + &vc_data.space_used, &vc_data.space_total,
19085 + &vc_data.inodes_used, &vc_data.inodes_total,
19086 + &vc_data.reserved, &vc_data.flags);
19090 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19095 +#ifdef CONFIG_COMPAT
19097 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
19099 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19102 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19105 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
19106 + &vc_data.space_used, &vc_data.space_total,
19107 + &vc_data.inodes_used, &vc_data.inodes_total,
19108 + &vc_data.reserved, &vc_data.flags);
19112 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19117 +#endif /* CONFIG_COMPAT */
19120 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
19122 + struct dl_info *dli;
19123 + __u64 blimit, bfree, bavail;
19126 + dli = locate_dl_info(sb, dx_current_tag());
19130 + spin_lock(&dli->dl_lock);
19131 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
19134 + /* reduce max inodes available to limit */
19135 + if (buf->f_files > dli->dl_inodes_total)
19136 + buf->f_files = dli->dl_inodes_total;
19138 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
19139 + /* reduce free inodes to min */
19140 + if (ifree < buf->f_ffree)
19141 + buf->f_ffree = ifree;
19144 + if (dli->dl_space_total == DLIM_INFINITY)
19147 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
19149 + if (dli->dl_space_total < dli->dl_space_used)
19152 + bfree = (dli->dl_space_total - dli->dl_space_used)
19153 + >> sb->s_blocksize_bits;
19155 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
19156 + if (bavail < dli->dl_space_used)
19159 + bavail = (bavail - dli->dl_space_used)
19160 + >> sb->s_blocksize_bits;
19162 + /* reduce max space available to limit */
19163 + if (buf->f_blocks > blimit)
19164 + buf->f_blocks = blimit;
19166 + /* reduce free space to min */
19167 + if (bfree < buf->f_bfree)
19168 + buf->f_bfree = bfree;
19170 + /* reduce avail space to min */
19171 + if (bavail < buf->f_bavail)
19172 + buf->f_bavail = bavail;
19175 + spin_unlock(&dli->dl_lock);
19176 + put_dl_info(dli);
19181 +#include <linux/module.h>
19183 +EXPORT_SYMBOL_GPL(locate_dl_info);
19184 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
19186 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/helper.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/helper.c
19187 --- linux-2.6.27.3/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
19188 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/helper.c 2008-10-13 14:54:20.000000000 +0200
19191 + * linux/kernel/vserver/helper.c
19193 + * Virtual Context Support
19195 + * Copyright (C) 2004-2007 Herbert Pötzl
19197 + * V0.01 basic helper
19201 +#include <linux/kmod.h>
19202 +#include <linux/reboot.h>
19203 +#include <linux/vs_context.h>
19204 +#include <linux/vs_network.h>
19205 +#include <linux/vserver/signal.h>
19208 +char vshelper_path[255] = "/sbin/vshelper";
19211 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
19215 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
19216 + printk( KERN_WARNING
19217 + "%s: (%s %s) returned %s with %d\n",
19218 + name, argv[1], argv[2],
19219 + sync ? "sync" : "async", ret);
19221 + vxdprintk(VXD_CBIT(switch, 4),
19222 + "%s: (%s %s) returned %s with %d",
19223 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
19228 + * vshelper path is set via /proc/sys
19229 + * invoked by vserver sys_reboot(), with
19230 + * the following arguments
19232 + * argv [0] = vshelper_path;
19233 + * argv [1] = action: "restart", "halt", "poweroff", ...
19234 + * argv [2] = context identifier
19236 + * envp [*] = type-specific parameters
19239 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
19241 + char id_buf[8], cmd_buf[16];
19242 + char uid_buf[16], pid_buf[16];
19245 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19246 + char *envp[] = {"HOME=/", "TERM=linux",
19247 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
19248 + uid_buf, pid_buf, cmd_buf, 0};
19250 + if (vx_info_state(vxi, VXS_HELPER))
19252 + vxi->vx_state |= VXS_HELPER;
19254 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19256 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19257 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
19258 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
19261 + case LINUX_REBOOT_CMD_RESTART:
19262 + argv[1] = "restart";
19265 + case LINUX_REBOOT_CMD_HALT:
19266 + argv[1] = "halt";
19269 + case LINUX_REBOOT_CMD_POWER_OFF:
19270 + argv[1] = "poweroff";
19273 + case LINUX_REBOOT_CMD_SW_SUSPEND:
19274 + argv[1] = "swsusp";
19278 + vxi->vx_state &= ~VXS_HELPER;
19282 + ret = do_vshelper(vshelper_path, argv, envp, 0);
19283 + vxi->vx_state &= ~VXS_HELPER;
19284 + __wakeup_vx_info(vxi);
19285 + return (ret) ? -EPERM : 0;
19289 +long vs_reboot(unsigned int cmd, void __user *arg)
19291 + struct vx_info *vxi = current->vx_info;
19294 + vxdprintk(VXD_CBIT(misc, 5),
19295 + "vs_reboot(%p[#%d],%d)",
19296 + vxi, vxi ? vxi->vx_id : 0, cmd);
19298 + ret = vs_reboot_helper(vxi, cmd, arg);
19302 + vxi->reboot_cmd = cmd;
19303 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19305 + case LINUX_REBOOT_CMD_RESTART:
19306 + case LINUX_REBOOT_CMD_HALT:
19307 + case LINUX_REBOOT_CMD_POWER_OFF:
19308 + vx_info_kill(vxi, 0, SIGKILL);
19309 + vx_info_kill(vxi, 1, SIGKILL);
19319 + * argv [0] = vshelper_path;
19320 + * argv [1] = action: "startup", "shutdown"
19321 + * argv [2] = context identifier
19323 + * envp [*] = type-specific parameters
19326 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
19328 + char id_buf[8], cmd_buf[16];
19329 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19330 + char *envp[] = {"HOME=/", "TERM=linux",
19331 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19333 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
19336 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19337 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19340 + case VSC_STARTUP:
19341 + argv[1] = "startup";
19343 + case VSC_SHUTDOWN:
19344 + argv[1] = "shutdown";
19350 + return do_vshelper(vshelper_path, argv, envp, 1);
19355 + * argv [0] = vshelper_path;
19356 + * argv [1] = action: "netup", "netdown"
19357 + * argv [2] = context identifier
19359 + * envp [*] = type-specific parameters
19362 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
19364 + char id_buf[8], cmd_buf[16];
19365 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19366 + char *envp[] = {"HOME=/", "TERM=linux",
19367 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19369 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
19372 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
19373 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19377 + argv[1] = "netup";
19379 + case VSC_NETDOWN:
19380 + argv[1] = "netdown";
19386 + return do_vshelper(vshelper_path, argv, envp, 1);
19389 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/history.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/history.c
19390 --- linux-2.6.27.3/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19391 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/history.c 2008-10-13 14:54:20.000000000 +0200
19394 + * kernel/vserver/history.c
19396 + * Virtual Context History Backtrace
19398 + * Copyright (C) 2004-2007 Herbert Pötzl
19400 + * V0.01 basic structure
19401 + * V0.02 hash/unhash and trace
19402 + * V0.03 preemption fixes
19406 +#include <linux/module.h>
19407 +#include <asm/uaccess.h>
19409 +#include <linux/vserver/context.h>
19410 +#include <linux/vserver/debug.h>
19411 +#include <linux/vserver/debug_cmd.h>
19412 +#include <linux/vserver/history.h>
19415 +#ifdef CONFIG_VSERVER_HISTORY
19416 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19418 +#define VXH_SIZE 64
19421 +struct _vx_history {
19422 + unsigned int counter;
19424 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19428 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19430 +unsigned volatile int vxh_active = 1;
19432 +static atomic_t sequence = ATOMIC_INIT(0);
19437 + * requires disabled preemption */
19439 +struct _vx_hist_entry *vxh_advance(void *loc)
19441 + unsigned int cpu = smp_processor_id();
19442 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19443 + struct _vx_hist_entry *entry;
19444 + unsigned int index;
19446 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19447 + entry = &hist->entry[index];
19449 + entry->seq = atomic_inc_return(&sequence);
19450 + entry->loc = loc;
19454 +EXPORT_SYMBOL_GPL(vxh_advance);
19457 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19459 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19462 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19464 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19465 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19466 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19467 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19469 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19471 + switch (e->type) {
19472 + case VXH_THROW_OOPS:
19473 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19476 + case VXH_GET_VX_INFO:
19477 + case VXH_PUT_VX_INFO:
19478 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19480 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19481 + VXH_VXI_ARGS(e));
19484 + case VXH_INIT_VX_INFO:
19485 + case VXH_SET_VX_INFO:
19486 + case VXH_CLR_VX_INFO:
19487 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19489 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19490 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19491 + VXH_VXI_ARGS(e), e->sc.data);
19494 + case VXH_CLAIM_VX_INFO:
19495 + case VXH_RELEASE_VX_INFO:
19496 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19498 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19499 + VXH_VXI_ARGS(e), e->sc.data);
19502 + case VXH_ALLOC_VX_INFO:
19503 + case VXH_DEALLOC_VX_INFO:
19504 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19506 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19507 + VXH_VXI_ARGS(e));
19510 + case VXH_HASH_VX_INFO:
19511 + case VXH_UNHASH_VX_INFO:
19512 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19514 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19515 + VXH_VXI_ARGS(e));
19518 + case VXH_LOC_VX_INFO:
19519 + case VXH_LOOKUP_VX_INFO:
19520 + case VXH_CREATE_VX_INFO:
19521 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19523 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19524 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19525 + e->ll.arg, VXH_VXI_ARGS(e));
19530 +static void __vxh_dump_history(void)
19532 + unsigned int i, cpu;
19534 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19535 + atomic_read(&sequence), NR_CPUS);
19537 + for (i = 0; i < VXH_SIZE; i++) {
19538 + for_each_online_cpu(cpu) {
19539 + struct _vx_history *hist =
19540 + &per_cpu(vx_history_buffer, cpu);
19541 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19542 + struct _vx_hist_entry *entry = &hist->entry[index];
19544 + vxh_dump_entry(entry, cpu);
19549 +void vxh_dump_history(void)
19553 + local_irq_enable();
19555 + local_irq_disable();
19557 + __vxh_dump_history();
19561 +/* vserver syscall commands below here */
19564 +int vc_dump_history(uint32_t id)
19567 + __vxh_dump_history();
19574 +int do_read_history(struct __user _vx_hist_entry *data,
19575 + int cpu, uint32_t *index, uint32_t *count)
19577 + int pos, ret = 0;
19578 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19579 + int end = hist->counter;
19580 + int start = end - VXH_SIZE + 2;
19581 + int idx = *index;
19583 + /* special case: get current pos */
19589 + /* have we lost some data? */
19593 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19594 + struct _vx_hist_entry *entry =
19595 + &hist->entry[idx % VXH_SIZE];
19597 + /* send entry to userspace */
19598 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19602 + /* save new index and count */
19605 + return ret ? ret : (*index < end);
19608 +int vc_read_history(uint32_t id, void __user *data)
19610 + struct vcmd_read_history_v0 vc_data;
19613 + if (id >= NR_CPUS)
19616 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19619 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19620 + id, &vc_data.index, &vc_data.count);
19622 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19627 +#ifdef CONFIG_COMPAT
19629 +int vc_read_history_x32(uint32_t id, void __user *data)
19631 + struct vcmd_read_history_v0_x32 vc_data;
19634 + if (id >= NR_CPUS)
19637 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19640 + ret = do_read_history((struct __user _vx_hist_entry *)
19641 + compat_ptr(vc_data.data_ptr),
19642 + id, &vc_data.index, &vc_data.count);
19644 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19649 +#endif /* CONFIG_COMPAT */
19651 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/inet.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/inet.c
19652 --- linux-2.6.27.3/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19653 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/inet.c 2008-10-13 14:54:20.000000000 +0200
19656 +#include <linux/in.h>
19657 +#include <linux/inetdevice.h>
19658 +#include <linux/vs_inet.h>
19659 +#include <linux/vs_inet6.h>
19660 +#include <linux/vserver/debug.h>
19661 +#include <net/route.h>
19662 +#include <net/addrconf.h>
19665 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19669 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19672 + struct nx_addr_v4 *ptr;
19674 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19675 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19682 + vxdprintk(VXD_CBIT(net, 2),
19683 + "nx_v4_addr_conflict(%p,%p): %d",
19684 + nxi1, nxi2, ret);
19690 +#ifdef CONFIG_IPV6
19692 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19696 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19699 + struct nx_addr_v6 *ptr;
19701 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19702 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19709 + vxdprintk(VXD_CBIT(net, 2),
19710 + "nx_v6_addr_conflict(%p,%p): %d",
19711 + nxi1, nxi2, ret);
19718 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19720 + struct in_device *in_dev;
19721 + struct in_ifaddr **ifap;
19722 + struct in_ifaddr *ifa;
19727 + in_dev = in_dev_get(dev);
19731 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19732 + ifap = &ifa->ifa_next) {
19733 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19738 + in_dev_put(in_dev);
19744 +#ifdef CONFIG_IPV6
19746 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19748 + struct inet6_dev *in_dev;
19749 + struct inet6_ifaddr **ifap;
19750 + struct inet6_ifaddr *ifa;
19755 + in_dev = in6_dev_get(dev);
19759 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19760 + ifap = &ifa->if_next) {
19761 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19766 + in6_dev_put(in_dev);
19773 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19779 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19781 +#ifdef CONFIG_IPV6
19783 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19788 + vxdprintk(VXD_CBIT(net, 3),
19789 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19790 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19794 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
19795 + struct rtable **rp, struct flowi *fl)
19800 + /* FIXME: handle lback only case */
19801 + if (!NX_IPV4(nxi))
19804 + vxdprintk(VXD_CBIT(net, 4),
19805 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19806 + nxi, nxi ? nxi->nx_id : 0,
19807 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
19809 + /* single IP is unconditional */
19810 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19811 + (fl->fl4_src == INADDR_ANY))
19812 + fl->fl4_src = nxi->v4.ip[0].s_addr;
19814 + if (fl->fl4_src == INADDR_ANY) {
19815 + struct nx_addr_v4 *ptr;
19816 + __be32 found = 0;
19819 + err = __ip_route_output_key(net, rp, fl);
19821 + found = (*rp)->rt_src;
19823 + vxdprintk(VXD_CBIT(net, 4),
19824 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19825 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
19826 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19830 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19831 + __be32 primary = ptr->ip[0].s_addr;
19832 + __be32 mask = ptr->mask.s_addr;
19833 + __be32 neta = primary & mask;
19835 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19836 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19837 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19838 + NIPQUAD(mask), NIPQUAD(neta));
19839 + if ((found & mask) != neta)
19842 + fl->fl4_src = primary;
19843 + err = __ip_route_output_key(net, rp, fl);
19844 + vxdprintk(VXD_CBIT(net, 4),
19845 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19846 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
19848 + found = (*rp)->rt_src;
19850 + if (found == primary)
19854 + /* still no source ip? */
19855 + found = ipv4_is_loopback(fl->fl4_dst)
19856 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19858 + /* assign src ip to flow */
19859 + fl->fl4_src = found;
19862 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
19866 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19867 + if (ipv4_is_loopback(fl->fl4_dst))
19868 + fl->fl4_dst = nxi->v4_lback.s_addr;
19869 + if (ipv4_is_loopback(fl->fl4_src))
19870 + fl->fl4_src = nxi->v4_lback.s_addr;
19871 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
19872 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19878 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19880 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/init.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/init.c
19881 --- linux-2.6.27.3/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19882 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/init.c 2008-10-13 14:54:20.000000000 +0200
19885 + * linux/kernel/init.c
19887 + * Virtual Server Init
19889 + * Copyright (C) 2004-2007 Herbert Pötzl
19891 + * V0.01 basic structure
19895 +#include <linux/init.h>
19897 +int vserver_register_sysctl(void);
19898 +void vserver_unregister_sysctl(void);
19901 +static int __init init_vserver(void)
19905 +#ifdef CONFIG_VSERVER_DEBUG
19906 + vserver_register_sysctl();
19912 +static void __exit exit_vserver(void)
19915 +#ifdef CONFIG_VSERVER_DEBUG
19916 + vserver_unregister_sysctl();
19921 +/* FIXME: GFP_ZONETYPES gone
19922 +long vx_slab[GFP_ZONETYPES]; */
19926 +module_init(init_vserver);
19927 +module_exit(exit_vserver);
19929 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/inode.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/inode.c
19930 --- linux-2.6.27.3/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19931 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/inode.c 2008-10-24 03:34:52.000000000 +0200
19934 + * linux/kernel/vserver/inode.c
19936 + * Virtual Server: File System Support
19938 + * Copyright (C) 2004-2007 Herbert Pötzl
19940 + * V0.01 separated from vcontext V0.05
19941 + * V0.02 moved to tag (instead of xid)
19945 +#include <linux/tty.h>
19946 +#include <linux/proc_fs.h>
19947 +#include <linux/devpts_fs.h>
19948 +#include <linux/fs.h>
19949 +#include <linux/file.h>
19950 +#include <linux/mount.h>
19951 +#include <linux/parser.h>
19952 +#include <linux/namei.h>
19953 +#include <linux/vserver/inode.h>
19954 +#include <linux/vserver/inode_cmd.h>
19955 +#include <linux/vs_base.h>
19956 +#include <linux/vs_tag.h>
19958 +#include <asm/uaccess.h>
19961 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19963 + struct proc_dir_entry *entry;
19965 + if (!in || !in->i_sb)
19968 + *flags = IATTR_TAG
19969 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19970 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19971 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
19972 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE;
19974 + if (S_ISDIR(in->i_mode))
19975 + *mask |= IATTR_BARRIER;
19977 + if (IS_TAGGED(in)) {
19978 + *tag = in->i_tag;
19979 + *mask |= IATTR_TAG;
19982 + switch (in->i_sb->s_magic) {
19983 + case PROC_SUPER_MAGIC:
19984 + entry = PROC_I(in)->pde;
19986 + /* check for specific inodes? */
19988 + *mask |= IATTR_FLAGS;
19990 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19992 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19995 + case DEVPTS_SUPER_MAGIC:
19996 + *tag = in->i_tag;
19997 + *mask |= IATTR_TAG;
20006 +int vc_get_iattr(void __user *data)
20008 + struct path path;
20009 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
20012 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20015 + ret = user_lpath(vc_data.name, &path);
20017 + ret = __vc_get_iattr(path.dentry->d_inode,
20018 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20024 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20029 +#ifdef CONFIG_COMPAT
20031 +int vc_get_iattr_x32(void __user *data)
20033 + struct path path;
20034 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
20037 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20040 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20042 + ret = __vc_get_iattr(path.dentry->d_inode,
20043 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20049 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20054 +#endif /* CONFIG_COMPAT */
20057 +int vc_fget_iattr(uint32_t fd, void __user *data)
20059 + struct file *filp;
20060 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
20063 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20067 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20070 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
20071 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20075 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20081 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20083 + struct inode *in = de->d_inode;
20084 + int error = 0, is_proc = 0, has_tag = 0;
20085 + struct iattr attr = { 0 };
20087 + if (!in || !in->i_sb)
20090 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
20091 + if ((*mask & IATTR_FLAGS) && !is_proc)
20094 + has_tag = IS_TAGGED(in) ||
20095 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
20096 + if ((*mask & IATTR_TAG) && !has_tag)
20099 + mutex_lock(&in->i_mutex);
20100 + if (*mask & IATTR_TAG) {
20101 + attr.ia_tag = *tag;
20102 + attr.ia_valid |= ATTR_TAG;
20105 + if (*mask & IATTR_FLAGS) {
20106 + struct proc_dir_entry *entry = PROC_I(in)->pde;
20107 + unsigned int iflags = PROC_I(in)->vx_flags;
20109 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
20110 + | (*flags & IATTR_FLAGS);
20111 + PROC_I(in)->vx_flags = iflags;
20113 + entry->vx_flags = iflags;
20116 + if (*mask & (IATTR_BARRIER | IATTR_IXUNLINK | IATTR_IMMUTABLE)) {
20117 + if (*mask & IATTR_IMMUTABLE) {
20118 + if (*flags & IATTR_IMMUTABLE)
20119 + in->i_flags |= S_IMMUTABLE;
20121 + in->i_flags &= ~S_IMMUTABLE;
20123 + if (*mask & IATTR_IXUNLINK) {
20124 + if (*flags & IATTR_IXUNLINK)
20125 + in->i_flags |= S_IXUNLINK;
20127 + in->i_flags &= ~S_IXUNLINK;
20129 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
20130 + if (*flags & IATTR_BARRIER)
20131 + in->i_vflags |= V_BARRIER;
20133 + in->i_vflags &= ~V_BARRIER;
20135 + if (in->i_op && in->i_op->sync_flags) {
20136 + error = in->i_op->sync_flags(in);
20142 + if (attr.ia_valid) {
20143 + if (in->i_op && in->i_op->setattr)
20144 + error = in->i_op->setattr(de, &attr);
20146 + error = inode_change_ok(in, &attr);
20148 + error = inode_setattr(in, &attr);
20153 + mutex_unlock(&in->i_mutex);
20157 +int vc_set_iattr(void __user *data)
20159 + struct path path;
20160 + struct vcmd_ctx_iattr_v1 vc_data;
20163 + if (!capable(CAP_LINUX_IMMUTABLE))
20165 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20168 + ret = user_lpath(vc_data.name, &path);
20170 + ret = __vc_set_iattr(path.dentry,
20171 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20175 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20180 +#ifdef CONFIG_COMPAT
20182 +int vc_set_iattr_x32(void __user *data)
20184 + struct path path;
20185 + struct vcmd_ctx_iattr_v1_x32 vc_data;
20188 + if (!capable(CAP_LINUX_IMMUTABLE))
20190 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20193 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20195 + ret = __vc_set_iattr(path.dentry,
20196 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20200 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20205 +#endif /* CONFIG_COMPAT */
20207 +int vc_fset_iattr(uint32_t fd, void __user *data)
20209 + struct file *filp;
20210 + struct vcmd_ctx_fiattr_v0 vc_data;
20213 + if (!capable(CAP_LINUX_IMMUTABLE))
20215 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20219 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20222 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
20223 + &vc_data.flags, &vc_data.mask);
20227 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20233 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
20235 +static match_table_t tokens = {
20236 + {Opt_notagcheck, "notagcheck"},
20237 +#ifdef CONFIG_PROPAGATE
20238 + {Opt_notag, "notag"},
20239 + {Opt_tag, "tag"},
20240 + {Opt_tagid, "tagid=%u"},
20246 +static void __dx_parse_remove(char *string, char *opt)
20248 + char *p = strstr(string, opt);
20252 + while (*q != '\0' && *q != ',')
20261 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
20262 + unsigned long *flags)
20265 + substring_t args[MAX_OPT_ARGS];
20266 + int token, option = 0;
20267 + char *s, *p, *opts;
20271 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20276 + while ((p = strsep(&opts, ",")) != NULL) {
20277 + token = match_token(p, tokens, args);
20279 + vxdprintk(VXD_CBIT(tag, 7),
20280 + "dx_parse_tag(»%s«): %d:#%d",
20281 + p, token, option);
20284 +#ifdef CONFIG_PROPAGATE
20289 + __dx_parse_remove(s, "tag");
20290 + *mnt_flags |= MNT_TAGID;
20291 + set |= MNT_TAGID;
20295 + __dx_parse_remove(s, "notag");
20296 + *mnt_flags |= MNT_NOTAG;
20297 + set |= MNT_NOTAG;
20300 + if (tag && !match_int(args, &option))
20303 + __dx_parse_remove(s, "tagid");
20304 + *mnt_flags |= MNT_TAGID;
20305 + set |= MNT_TAGID;
20308 + case Opt_notagcheck:
20310 + __dx_parse_remove(s, "notagcheck");
20311 + *flags |= MS_NOTAGCHECK;
20312 + set |= MS_NOTAGCHECK;
20317 + strcpy(string, s);
20322 +#ifdef CONFIG_PROPAGATE
20324 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20326 + tag_t new_tag = 0;
20327 + struct vfsmount *mnt;
20332 + mnt = nd->path.mnt;
20336 + propagate = (mnt->mnt_flags & MNT_TAGID);
20338 + new_tag = mnt->mnt_tag;
20340 + vxdprintk(VXD_CBIT(tag, 7),
20341 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20342 + inode, inode->i_ino, inode->i_tag,
20343 + new_tag, (propagate) ? 1 : 0);
20346 + inode->i_tag = new_tag;
20349 +#include <linux/module.h>
20351 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20353 +#endif /* CONFIG_PROPAGATE */
20355 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/Kconfig linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/Kconfig
20356 --- linux-2.6.27.3/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
20357 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/Kconfig 2008-10-13 14:54:20.000000000 +0200
20360 +# Linux VServer configuration
20363 +menu "Linux VServer"
20365 +config VSERVER_AUTO_LBACK
20366 + bool "Automatically Assign Loopback IP"
20369 + Automatically assign a guest specific loopback
20370 + IP and add it to the kernel network stack on
20373 +config VSERVER_AUTO_SINGLE
20374 + bool "Automatic Single IP Special Casing"
20375 + depends on EXPERIMENTAL
20378 + This allows network contexts with a single IP to
20379 + automatically remap 0.0.0.0 bindings to that IP,
20380 + avoiding further network checks and improving
20383 + (note: such guests do not allow to change the ip
20384 + on the fly and do not show loopback addresses)
20386 +config VSERVER_COWBL
20387 + bool "Enable COW Immutable Link Breaking"
20390 + This enables the COW (Copy-On-Write) link break code.
20391 + It allows you to treat unified files like normal files
20392 + when writing to them (which will implicitely break the
20393 + link and create a copy of the unified file)
20395 +config VSERVER_VTIME
20396 + bool "Enable Virtualized Guest Time"
20397 + depends on EXPERIMENTAL
20400 + This enables per guest time offsets to allow for
20401 + adjusting the system clock individually per guest.
20402 + this adds some overhead to the time functions and
20403 + therefore should not be enabled without good reason.
20405 +config VSERVER_DEVICE
20406 + bool "Enable Guest Device Mapping"
20407 + depends on EXPERIMENTAL
20410 + This enables generic device remapping.
20412 +config VSERVER_PROC_SECURE
20413 + bool "Enable Proc Security"
20414 + depends on PROC_FS
20417 + This configures ProcFS security to initially hide
20418 + non-process entries for all contexts except the main and
20419 + spectator context (i.e. for all guests), which is a secure
20422 + (note: on 1.2x the entries were visible by default)
20424 +config VSERVER_HARDCPU
20425 + bool "Enable Hard CPU Limits"
20428 + Activate the Hard CPU Limits
20430 + This will compile in code that allows the Token Bucket
20431 + Scheduler to put processes on hold when a context's
20432 + tokens are depleted (provided that its per-context
20433 + sched_hard flag is set).
20435 + Processes belonging to that context will not be able
20436 + to consume CPU resources again until a per-context
20437 + configured minimum of tokens has been reached.
20439 +config VSERVER_IDLETIME
20440 + bool "Avoid idle CPUs by skipping Time"
20441 + depends on VSERVER_HARDCPU
20444 + This option allows the scheduler to artificially
20445 + advance time (per cpu) when otherwise the idle
20446 + task would be scheduled, thus keeping the cpu
20447 + busy and sharing the available resources among
20448 + certain contexts.
20450 +config VSERVER_IDLELIMIT
20451 + bool "Limit the IDLE task"
20452 + depends on VSERVER_HARDCPU
20455 + Limit the idle slices, so the the next context
20456 + will be scheduled as soon as possible.
20458 + This might improve interactivity and latency, but
20459 + will also marginally increase scheduling overhead.
20462 + prompt "Persistent Inode Tagging"
20463 + default TAGGING_ID24
20465 + This adds persistent context information to filesystems
20466 + mounted with the tagxid option. Tagging is a requirement
20467 + for per-context disk limits and per-context quota.
20470 +config TAGGING_NONE
20473 + do not store per-context information in inodes.
20475 +config TAGGING_UID16
20476 + bool "UID16/GID32"
20478 + reduces UID to 16 bit, but leaves GID at 32 bit.
20480 +config TAGGING_GID16
20481 + bool "UID32/GID16"
20483 + reduces GID to 16 bit, but leaves UID at 32 bit.
20485 +config TAGGING_ID24
20486 + bool "UID24/GID24"
20488 + uses the upper 8bit from UID and GID for XID tagging
20489 + which leaves 24bit for UID/GID each, which should be
20490 + more than sufficient for normal use.
20492 +config TAGGING_INTERN
20493 + bool "UID32/GID32"
20495 + this uses otherwise reserved inode fields in the on
20496 + disk representation, which limits the use to a few
20497 + filesystems (currently ext2 and ext3)
20502 + bool "Tag NFSD User Auth and Files"
20505 + Enable this if you do want the in-kernel NFS
20506 + Server to use the tagging specified above.
20507 + (will require patched clients too)
20509 +config VSERVER_PRIVACY
20510 + bool "Honor Privacy Aspects of Guests"
20513 + When enabled, most context checks will disallow
20514 + access to structures assigned to a specific context,
20515 + like ptys or loop devices.
20517 +config VSERVER_CONTEXTS
20518 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
20520 + default "768" if 64BIT
20523 + This setting will optimize certain data structures
20524 + and memory allocations according to the expected
20527 + note: this is not a strict upper limit.
20529 +config VSERVER_WARN
20530 + bool "VServer Warnings"
20533 + This enables various runtime warnings, which will
20534 + notify about potential manipulation attempts or
20535 + resource shortage. It is generally considered to
20536 + be a good idea to have that enabled.
20538 +config VSERVER_DEBUG
20539 + bool "VServer Debugging Code"
20542 + Set this to yes if you want to be able to activate
20543 + debugging output at runtime. It adds a very small
20544 + overhead to all vserver related functions and
20545 + increases the kernel size by about 20k.
20547 +config VSERVER_HISTORY
20548 + bool "VServer History Tracing"
20549 + depends on VSERVER_DEBUG
20552 + Set this to yes if you want to record the history of
20553 + linux-vserver activities, so they can be replayed in
20554 + the event of a kernel panic or oops.
20556 +config VSERVER_HISTORY_SIZE
20557 + int "Per-CPU History Size (32-65536)"
20558 + depends on VSERVER_HISTORY
20562 + This allows you to specify the number of entries in
20563 + the per-CPU history buffer.
20565 +config VSERVER_MONITOR
20566 + bool "VServer Scheduling Monitor"
20567 + depends on VSERVER_DISABLED
20570 + Set this to yes if you want to record the scheduling
20571 + decisions, so that they can be relayed to userspace
20572 + for detailed analysis.
20574 +config VSERVER_MONITOR_SIZE
20575 + int "Per-CPU Monitor Queue Size (32-65536)"
20576 + depends on VSERVER_MONITOR
20580 + This allows you to specify the number of entries in
20581 + the per-CPU scheduling monitor buffer.
20583 +config VSERVER_MONITOR_SYNC
20584 + int "Per-CPU Monitor Sync Interval (0-65536)"
20585 + depends on VSERVER_MONITOR
20589 + This allows you to specify the interval in ticks
20590 + when a time sync entry is inserted.
20598 + select NAMESPACES
20604 +config VSERVER_SECURITY
20606 + depends on SECURITY
20608 + select SECURITY_CAPABILITIES
20610 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/limit.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/limit.c
20611 --- linux-2.6.27.3/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
20612 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/limit.c 2008-10-13 14:54:20.000000000 +0200
20615 + * linux/kernel/vserver/limit.c
20617 + * Virtual Server: Context Limits
20619 + * Copyright (C) 2004-2007 Herbert Pötzl
20621 + * V0.01 broken out from vcontext V0.05
20622 + * V0.02 changed vcmds to vxi arg
20626 +#include <linux/sched.h>
20627 +#include <linux/module.h>
20628 +#include <linux/vs_limit.h>
20629 +#include <linux/vserver/limit.h>
20630 +#include <linux/vserver/limit_cmd.h>
20632 +#include <asm/uaccess.h>
20635 +const char *vlimit_name[NUM_LIMITS] = {
20636 + [RLIMIT_CPU] = "CPU",
20637 + [RLIMIT_RSS] = "RSS",
20638 + [RLIMIT_NPROC] = "NPROC",
20639 + [RLIMIT_NOFILE] = "NOFILE",
20640 + [RLIMIT_MEMLOCK] = "VML",
20641 + [RLIMIT_AS] = "VM",
20642 + [RLIMIT_LOCKS] = "LOCKS",
20643 + [RLIMIT_SIGPENDING] = "SIGP",
20644 + [RLIMIT_MSGQUEUE] = "MSGQ",
20646 + [VLIMIT_NSOCK] = "NSOCK",
20647 + [VLIMIT_OPENFD] = "OPENFD",
20648 + [VLIMIT_ANON] = "ANON",
20649 + [VLIMIT_SHMEM] = "SHMEM",
20650 + [VLIMIT_DENTRY] = "DENTRY",
20653 +EXPORT_SYMBOL_GPL(vlimit_name);
20655 +#define MASK_ENTRY(x) (1 << (x))
20657 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20660 + , /* softlimit */
20661 + MASK_ENTRY( RLIMIT_RSS ) |
20662 + MASK_ENTRY( VLIMIT_ANON ) |
20665 + MASK_ENTRY( RLIMIT_RSS ) |
20666 + MASK_ENTRY( RLIMIT_NPROC ) |
20667 + MASK_ENTRY( RLIMIT_NOFILE ) |
20668 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
20669 + MASK_ENTRY( RLIMIT_AS ) |
20670 + MASK_ENTRY( RLIMIT_LOCKS ) |
20671 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20673 + MASK_ENTRY( VLIMIT_NSOCK ) |
20674 + MASK_ENTRY( VLIMIT_OPENFD ) |
20675 + MASK_ENTRY( VLIMIT_ANON ) |
20676 + MASK_ENTRY( VLIMIT_SHMEM ) |
20677 + MASK_ENTRY( VLIMIT_DENTRY ) |
20680 + /* accounting only */
20681 +uint32_t account_mask =
20682 + MASK_ENTRY( VLIMIT_SEMARY ) |
20683 + MASK_ENTRY( VLIMIT_NSEMS ) |
20684 + MASK_ENTRY( VLIMIT_MAPPED ) |
20688 +static int is_valid_vlimit(int id)
20690 + uint32_t mask = vlimit_mask.minimum |
20691 + vlimit_mask.softlimit | vlimit_mask.maximum;
20692 + return mask & (1 << id);
20695 +static int is_accounted_vlimit(int id)
20697 + if (is_valid_vlimit(id))
20699 + return account_mask & (1 << id);
20703 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20705 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20706 + return VX_VLIM(limit);
20709 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20711 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20712 + return VX_VLIM(limit);
20715 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20716 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20718 + if (!is_valid_vlimit(id))
20722 + *minimum = CRLIM_UNSET;
20724 + *softlimit = vc_get_soft(vxi, id);
20726 + *maximum = vc_get_hard(vxi, id);
20730 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20732 + struct vcmd_ctx_rlimit_v0 vc_data;
20735 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20738 + ret = do_get_rlimit(vxi, vc_data.id,
20739 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20743 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20748 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20749 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20751 + if (!is_valid_vlimit(id))
20754 + if (maximum != CRLIM_KEEP)
20755 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20756 + if (softlimit != CRLIM_KEEP)
20757 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20759 + /* clamp soft limit */
20760 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20761 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20766 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20768 + struct vcmd_ctx_rlimit_v0 vc_data;
20770 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20773 + return do_set_rlimit(vxi, vc_data.id,
20774 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20777 +#ifdef CONFIG_IA32_EMULATION
20779 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20781 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20783 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20786 + return do_set_rlimit(vxi, vc_data.id,
20787 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20790 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20792 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20795 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20798 + ret = do_get_rlimit(vxi, vc_data.id,
20799 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20803 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20808 +#endif /* CONFIG_IA32_EMULATION */
20811 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20813 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20819 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20824 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20825 + value = __rlim_get(limit, lim);
20826 + __rlim_rmax(limit, lim) = value;
20827 + __rlim_rmin(limit, lim) = value;
20832 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20834 + vx_reset_minmax(&vxi->limit);
20839 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20841 + struct vcmd_rlimit_stat_v0 vc_data;
20842 + struct _vx_limit *limit = &vxi->limit;
20845 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20849 + if (!is_accounted_vlimit(id))
20852 + vx_limit_fixup(limit, id);
20853 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20854 + vc_data.value = __rlim_get(limit, id);
20855 + vc_data.minimum = __rlim_rmin(limit, id);
20856 + vc_data.maximum = __rlim_rmax(limit, id);
20858 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20864 +void vx_vsi_meminfo(struct sysinfo *val)
20866 + struct vx_info *vxi = current->vx_info;
20867 + unsigned long totalram, freeram;
20870 + /* we blindly accept the max */
20871 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20872 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
20874 + /* total minus used equals free */
20875 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20876 + freeram = (v < totalram) ? totalram - v : 0;
20878 + val->totalram = totalram;
20879 + val->freeram = freeram;
20880 + val->bufferram = 0;
20881 + val->totalhigh = 0;
20882 + val->freehigh = 0;
20886 +void vx_vsi_swapinfo(struct sysinfo *val)
20888 + struct vx_info *vxi = current->vx_info;
20889 + unsigned long totalswap, freeswap;
20892 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20893 + if (v == RLIM_INFINITY) {
20894 + val->freeswap = val->totalswap;
20898 + /* we blindly accept the max */
20899 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
20900 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
20902 + /* currently 'used' swap */
20903 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20904 + w -= (w > v) ? v : w;
20906 + /* total minus used equals free */
20907 + freeswap = (w < totalswap) ? totalswap - w : 0;
20909 + val->totalswap = totalswap;
20910 + val->freeswap = freeswap;
20915 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20917 + struct vx_info *vxi = mm->mm_vx_info;
20918 + unsigned long points;
20924 + points = vxi->vx_badness_bias;
20926 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20927 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20928 + points += (v > w) ? (v - w) : 0;
20933 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/limit_init.h linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/limit_init.h
20934 --- linux-2.6.27.3/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20935 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/limit_init.h 2008-10-13 14:54:20.000000000 +0200
20939 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20943 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20944 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20945 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20946 + __rlim_set(limit, lim, 0);
20947 + atomic_set(&__rlim_lhit(limit, lim), 0);
20948 + __rlim_rmin(limit, lim) = 0;
20949 + __rlim_rmax(limit, lim) = 0;
20953 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20958 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20959 + if ((1 << lim) & VLIM_NOCHECK)
20961 + value = __rlim_get(limit, lim);
20962 + vxwprintk_xid(value,
20963 + "!!! limit: %p[%s,%d] = %ld on exit.",
20964 + limit, vlimit_name[lim], lim, (long)value);
20968 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/limit_proc.h linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/limit_proc.h
20969 --- linux-2.6.27.3/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20970 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/limit_proc.h 2008-10-13 14:54:20.000000000 +0200
20972 +#ifndef _VX_LIMIT_PROC_H
20973 +#define _VX_LIMIT_PROC_H
20975 +#include <linux/vserver/limit_int.h>
20978 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20979 +#define VX_LIMIT_TOP \
20980 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20982 +#define VX_LIMIT_ARG(r) \
20983 + (unsigned long)__rlim_get(limit, r), \
20984 + (unsigned long)__rlim_rmin(limit, r), \
20985 + (unsigned long)__rlim_rmax(limit, r), \
20986 + VX_VLIM(__rlim_soft(limit, r)), \
20987 + VX_VLIM(__rlim_hard(limit, r)), \
20988 + atomic_read(&__rlim_lhit(limit, r))
20990 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20992 + vx_limit_fixup(limit, -1);
20993 + return sprintf(buffer, VX_LIMIT_TOP
20994 + "PROC" VX_LIMIT_FMT
20995 + "VM" VX_LIMIT_FMT
20996 + "VML" VX_LIMIT_FMT
20997 + "RSS" VX_LIMIT_FMT
20998 + "ANON" VX_LIMIT_FMT
20999 + "RMAP" VX_LIMIT_FMT
21000 + "FILES" VX_LIMIT_FMT
21001 + "OFD" VX_LIMIT_FMT
21002 + "LOCKS" VX_LIMIT_FMT
21003 + "SOCK" VX_LIMIT_FMT
21004 + "MSGQ" VX_LIMIT_FMT
21005 + "SHM" VX_LIMIT_FMT
21006 + "SEMA" VX_LIMIT_FMT
21007 + "SEMS" VX_LIMIT_FMT
21008 + "DENT" VX_LIMIT_FMT,
21009 + VX_LIMIT_ARG(RLIMIT_NPROC),
21010 + VX_LIMIT_ARG(RLIMIT_AS),
21011 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
21012 + VX_LIMIT_ARG(RLIMIT_RSS),
21013 + VX_LIMIT_ARG(VLIMIT_ANON),
21014 + VX_LIMIT_ARG(VLIMIT_MAPPED),
21015 + VX_LIMIT_ARG(RLIMIT_NOFILE),
21016 + VX_LIMIT_ARG(VLIMIT_OPENFD),
21017 + VX_LIMIT_ARG(RLIMIT_LOCKS),
21018 + VX_LIMIT_ARG(VLIMIT_NSOCK),
21019 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
21020 + VX_LIMIT_ARG(VLIMIT_SHMEM),
21021 + VX_LIMIT_ARG(VLIMIT_SEMARY),
21022 + VX_LIMIT_ARG(VLIMIT_NSEMS),
21023 + VX_LIMIT_ARG(VLIMIT_DENTRY));
21026 +#endif /* _VX_LIMIT_PROC_H */
21029 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/Makefile linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/Makefile
21030 --- linux-2.6.27.3/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
21031 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/Makefile 2008-10-13 14:54:20.000000000 +0200
21034 +# Makefile for the Linux vserver routines.
21038 +obj-y += vserver.o
21040 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
21041 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
21044 +vserver-$(CONFIG_INET) += inet.o
21045 +vserver-$(CONFIG_PROC_FS) += proc.o
21046 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
21047 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
21048 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
21049 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
21051 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/monitor.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/monitor.c
21052 --- linux-2.6.27.3/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
21053 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/monitor.c 2008-10-13 14:54:20.000000000 +0200
21056 + * kernel/vserver/monitor.c
21058 + * Virtual Context Scheduler Monitor
21060 + * Copyright (C) 2006-2007 Herbert Pötzl
21062 + * V0.01 basic design
21066 +#include <linux/module.h>
21067 +#include <linux/jiffies.h>
21068 +#include <asm/uaccess.h>
21069 +#include <asm/atomic.h>
21071 +#include <linux/vserver/monitor.h>
21072 +#include <linux/vserver/debug_cmd.h>
21075 +#ifdef CONFIG_VSERVER_MONITOR
21076 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
21078 +#define VXM_SIZE 64
21081 +struct _vx_monitor {
21082 + unsigned int counter;
21084 + struct _vx_mon_entry entry[VXM_SIZE+1];
21088 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
21090 +unsigned volatile int vxm_active = 1;
21092 +static atomic_t sequence = ATOMIC_INIT(0);
21097 + * requires disabled preemption */
21099 +struct _vx_mon_entry *vxm_advance(int cpu)
21101 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21102 + struct _vx_mon_entry *entry;
21103 + unsigned int index;
21105 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
21106 + entry = &mon->entry[index];
21108 + entry->ev.seq = atomic_inc_return(&sequence);
21109 + entry->ev.jif = jiffies;
21113 +EXPORT_SYMBOL_GPL(vxm_advance);
21116 +int do_read_monitor(struct __user _vx_mon_entry *data,
21117 + int cpu, uint32_t *index, uint32_t *count)
21119 + int pos, ret = 0;
21120 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21121 + int end = mon->counter;
21122 + int start = end - VXM_SIZE + 2;
21123 + int idx = *index;
21125 + /* special case: get current pos */
21131 + /* have we lost some data? */
21135 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21136 + struct _vx_mon_entry *entry =
21137 + &mon->entry[idx % VXM_SIZE];
21139 + /* send entry to userspace */
21140 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21144 + /* save new index and count */
21147 + return ret ? ret : (*index < end);
21150 +int vc_read_monitor(uint32_t id, void __user *data)
21152 + struct vcmd_read_monitor_v0 vc_data;
21155 + if (id >= NR_CPUS)
21158 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21161 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
21162 + id, &vc_data.index, &vc_data.count);
21164 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21169 +#ifdef CONFIG_COMPAT
21171 +int vc_read_monitor_x32(uint32_t id, void __user *data)
21173 + struct vcmd_read_monitor_v0_x32 vc_data;
21176 + if (id >= NR_CPUS)
21179 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21182 + ret = do_read_monitor((struct __user _vx_mon_entry *)
21183 + compat_ptr(vc_data.data_ptr),
21184 + id, &vc_data.index, &vc_data.count);
21186 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21191 +#endif /* CONFIG_COMPAT */
21193 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/network.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/network.c
21194 --- linux-2.6.27.3/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
21195 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/network.c 2008-10-13 14:54:20.000000000 +0200
21198 + * linux/kernel/vserver/network.c
21200 + * Virtual Server: Network Support
21202 + * Copyright (C) 2003-2007 Herbert Pötzl
21204 + * V0.01 broken out from vcontext V0.05
21205 + * V0.02 cleaned up implementation
21206 + * V0.03 added equiv nx commands
21207 + * V0.04 switch to RCU based hash
21208 + * V0.05 and back to locking again
21209 + * V0.06 changed vcmds to nxi arg
21210 + * V0.07 have __create claim() the nxi
21214 +#include <linux/err.h>
21215 +#include <linux/slab.h>
21216 +#include <linux/rcupdate.h>
21218 +#include <linux/vs_network.h>
21219 +#include <linux/vs_pid.h>
21220 +#include <linux/vserver/network_cmd.h>
21223 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
21224 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
21226 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
21227 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
21230 +static int __init init_network(void)
21232 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
21233 + sizeof(struct nx_addr_v4), 0,
21234 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21235 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
21236 + sizeof(struct nx_addr_v6), 0,
21237 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21242 +/* __alloc_nx_addr_v4() */
21244 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
21246 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
21247 + nx_addr_v4_cachep, GFP_KERNEL);
21249 + if (!IS_ERR(nxa))
21250 + memset(nxa, 0, sizeof(*nxa));
21254 +/* __dealloc_nx_addr_v4() */
21256 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
21258 + kmem_cache_free(nx_addr_v4_cachep, nxa);
21261 +/* __dealloc_nx_addr_v4_all() */
21263 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
21266 + struct nx_addr_v4 *next = nxa->next;
21268 + __dealloc_nx_addr_v4(nxa);
21274 +#ifdef CONFIG_IPV6
21276 +/* __alloc_nx_addr_v6() */
21278 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
21280 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
21281 + nx_addr_v6_cachep, GFP_KERNEL);
21283 + if (!IS_ERR(nxa))
21284 + memset(nxa, 0, sizeof(*nxa));
21288 +/* __dealloc_nx_addr_v6() */
21290 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
21292 + kmem_cache_free(nx_addr_v6_cachep, nxa);
21295 +/* __dealloc_nx_addr_v6_all() */
21297 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
21300 + struct nx_addr_v6 *next = nxa->next;
21302 + __dealloc_nx_addr_v6(nxa);
21307 +#endif /* CONFIG_IPV6 */
21309 +/* __alloc_nx_info()
21311 + * allocate an initialized nx_info struct
21312 + * doesn't make it visible (hash) */
21314 +static struct nx_info *__alloc_nx_info(nid_t nid)
21316 + struct nx_info *new = NULL;
21318 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
21320 + /* would this benefit from a slab cache? */
21321 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
21325 + memset(new, 0, sizeof(struct nx_info));
21326 + new->nx_id = nid;
21327 + INIT_HLIST_NODE(&new->nx_hlist);
21328 + atomic_set(&new->nx_usecnt, 0);
21329 + atomic_set(&new->nx_tasks, 0);
21330 + new->nx_state = 0;
21332 + new->nx_flags = NXF_INIT_SET;
21334 + /* rest of init goes here */
21336 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
21337 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
21339 + vxdprintk(VXD_CBIT(nid, 0),
21340 + "alloc_nx_info(%d) = %p", nid, new);
21341 + atomic_inc(&nx_global_ctotal);
21345 +/* __dealloc_nx_info()
21347 + * final disposal of nx_info */
21349 +static void __dealloc_nx_info(struct nx_info *nxi)
21351 + vxdprintk(VXD_CBIT(nid, 0),
21352 + "dealloc_nx_info(%p)", nxi);
21354 + nxi->nx_hlist.next = LIST_POISON1;
21357 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21358 + BUG_ON(atomic_read(&nxi->nx_tasks));
21360 + __dealloc_nx_addr_v4_all(nxi->v4.next);
21362 + nxi->nx_state |= NXS_RELEASED;
21364 + atomic_dec(&nx_global_ctotal);
21367 +static void __shutdown_nx_info(struct nx_info *nxi)
21369 + nxi->nx_state |= NXS_SHUTDOWN;
21370 + vs_net_change(nxi, VSC_NETDOWN);
21373 +/* exported stuff */
21375 +void free_nx_info(struct nx_info *nxi)
21377 + /* context shutdown is mandatory */
21378 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
21380 + /* context must not be hashed */
21381 + BUG_ON(nxi->nx_state & NXS_HASHED);
21383 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21384 + BUG_ON(atomic_read(&nxi->nx_tasks));
21386 + __dealloc_nx_info(nxi);
21390 +void __nx_set_lback(struct nx_info *nxi)
21392 + int nid = nxi->nx_id;
21393 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
21395 + nxi->v4_lback.s_addr = lback;
21398 +extern int __nx_inet_add_lback(__be32 addr);
21399 +extern int __nx_inet_del_lback(__be32 addr);
21402 +/* hash table for nx_info hash */
21404 +#define NX_HASH_SIZE 13
21406 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
21408 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
21411 +static inline unsigned int __hashval(nid_t nid)
21413 + return (nid % NX_HASH_SIZE);
21418 +/* __hash_nx_info()
21420 + * add the nxi to the global hash table
21421 + * requires the hash_lock to be held */
21423 +static inline void __hash_nx_info(struct nx_info *nxi)
21425 + struct hlist_head *head;
21427 + vxd_assert_lock(&nx_info_hash_lock);
21428 + vxdprintk(VXD_CBIT(nid, 4),
21429 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
21431 + /* context must not be hashed */
21432 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
21434 + nxi->nx_state |= NXS_HASHED;
21435 + head = &nx_info_hash[__hashval(nxi->nx_id)];
21436 + hlist_add_head(&nxi->nx_hlist, head);
21437 + atomic_inc(&nx_global_cactive);
21440 +/* __unhash_nx_info()
21442 + * remove the nxi from the global hash table
21443 + * requires the hash_lock to be held */
21445 +static inline void __unhash_nx_info(struct nx_info *nxi)
21447 + vxd_assert_lock(&nx_info_hash_lock);
21448 + vxdprintk(VXD_CBIT(nid, 4),
21449 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
21450 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
21452 + /* context must be hashed */
21453 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
21454 + /* but without tasks */
21455 + BUG_ON(atomic_read(&nxi->nx_tasks));
21457 + nxi->nx_state &= ~NXS_HASHED;
21458 + hlist_del(&nxi->nx_hlist);
21459 + atomic_dec(&nx_global_cactive);
21463 +/* __lookup_nx_info()
21465 + * requires the hash_lock to be held
21466 + * doesn't increment the nx_refcnt */
21468 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
21470 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
21471 + struct hlist_node *pos;
21472 + struct nx_info *nxi;
21474 + vxd_assert_lock(&nx_info_hash_lock);
21475 + hlist_for_each(pos, head) {
21476 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21478 + if (nxi->nx_id == nid)
21483 + vxdprintk(VXD_CBIT(nid, 0),
21484 + "__lookup_nx_info(#%u): %p[#%u]",
21485 + nid, nxi, nxi ? nxi->nx_id : 0);
21490 +/* __create_nx_info()
21492 + * create the requested context
21493 + * get(), claim() and hash it */
21495 +static struct nx_info *__create_nx_info(int id)
21497 + struct nx_info *new, *nxi = NULL;
21499 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
21501 + if (!(new = __alloc_nx_info(id)))
21502 + return ERR_PTR(-ENOMEM);
21504 + /* required to make dynamic xids unique */
21505 + spin_lock(&nx_info_hash_lock);
21507 + /* static context requested */
21508 + if ((nxi = __lookup_nx_info(id))) {
21509 + vxdprintk(VXD_CBIT(nid, 0),
21510 + "create_nx_info(%d) = %p (already there)", id, nxi);
21511 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21512 + nxi = ERR_PTR(-EBUSY);
21514 + nxi = ERR_PTR(-EEXIST);
21517 + /* new context */
21518 + vxdprintk(VXD_CBIT(nid, 0),
21519 + "create_nx_info(%d) = %p (new)", id, new);
21520 + claim_nx_info(new, NULL);
21521 + __nx_set_lback(new);
21522 + __hash_nx_info(get_nx_info(new));
21523 + nxi = new, new = NULL;
21526 + spin_unlock(&nx_info_hash_lock);
21528 + __dealloc_nx_info(new);
21534 +/* exported stuff */
21537 +void unhash_nx_info(struct nx_info *nxi)
21539 + __shutdown_nx_info(nxi);
21540 + spin_lock(&nx_info_hash_lock);
21541 + __unhash_nx_info(nxi);
21542 + spin_unlock(&nx_info_hash_lock);
21545 +/* lookup_nx_info()
21547 + * search for a nx_info and get() it
21548 + * negative id means current */
21550 +struct nx_info *lookup_nx_info(int id)
21552 + struct nx_info *nxi = NULL;
21555 + nxi = get_nx_info(current->nx_info);
21556 + } else if (id > 1) {
21557 + spin_lock(&nx_info_hash_lock);
21558 + nxi = get_nx_info(__lookup_nx_info(id));
21559 + spin_unlock(&nx_info_hash_lock);
21564 +/* nid_is_hashed()
21566 + * verify that nid is still hashed */
21568 +int nid_is_hashed(nid_t nid)
21572 + spin_lock(&nx_info_hash_lock);
21573 + hashed = (__lookup_nx_info(nid) != NULL);
21574 + spin_unlock(&nx_info_hash_lock);
21579 +#ifdef CONFIG_PROC_FS
21583 + * get a subset of hashed nids for proc
21584 + * assumes size is at least one */
21586 +int get_nid_list(int index, unsigned int *nids, int size)
21588 + int hindex, nr_nids = 0;
21590 + /* only show current and children */
21591 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
21594 + nids[nr_nids] = nx_current_nid();
21598 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
21599 + struct hlist_head *head = &nx_info_hash[hindex];
21600 + struct hlist_node *pos;
21602 + spin_lock(&nx_info_hash_lock);
21603 + hlist_for_each(pos, head) {
21604 + struct nx_info *nxi;
21609 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21610 + nids[nr_nids] = nxi->nx_id;
21611 + if (++nr_nids >= size) {
21612 + spin_unlock(&nx_info_hash_lock);
21616 + /* keep the lock time short */
21617 + spin_unlock(&nx_info_hash_lock);
21626 + * migrate task to new network
21627 + * gets nxi, puts old_nxi on change
21630 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
21632 + struct nx_info *old_nxi;
21638 + vxdprintk(VXD_CBIT(nid, 5),
21639 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
21640 + p, nxi, nxi->nx_id,
21641 + atomic_read(&nxi->nx_usecnt),
21642 + atomic_read(&nxi->nx_tasks));
21644 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
21645 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21648 + if (nx_info_state(nxi, NXS_SHUTDOWN))
21651 + /* maybe disallow this completely? */
21652 + old_nxi = task_get_nx_info(p);
21653 + if (old_nxi == nxi)
21658 + clr_nx_info(&p->nx_info);
21659 + claim_nx_info(nxi, p);
21660 + set_nx_info(&p->nx_info, nxi);
21661 + p->nid = nxi->nx_id;
21664 + vxdprintk(VXD_CBIT(nid, 5),
21665 + "moved task %p into nxi:%p[#%d]",
21666 + p, nxi, nxi->nx_id);
21669 + release_nx_info(old_nxi, p);
21672 + put_nx_info(old_nxi);
21677 +void nx_set_persistent(struct nx_info *nxi)
21679 + vxdprintk(VXD_CBIT(nid, 6),
21680 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
21682 + get_nx_info(nxi);
21683 + claim_nx_info(nxi, NULL);
21686 +void nx_clear_persistent(struct nx_info *nxi)
21688 + vxdprintk(VXD_CBIT(nid, 6),
21689 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
21691 + release_nx_info(nxi, NULL);
21692 + put_nx_info(nxi);
21695 +void nx_update_persistent(struct nx_info *nxi)
21697 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
21698 + nx_set_persistent(nxi);
21700 + nx_clear_persistent(nxi);
21703 +/* vserver syscall commands below here */
21705 +/* taks nid and nx_info functions */
21707 +#include <asm/uaccess.h>
21710 +int vc_task_nid(uint32_t id)
21715 + struct task_struct *tsk;
21717 + read_lock(&tasklist_lock);
21718 + tsk = find_task_by_real_pid(id);
21719 + nid = (tsk) ? tsk->nid : -ESRCH;
21720 + read_unlock(&tasklist_lock);
21722 + nid = nx_current_nid();
21727 +int vc_nx_info(struct nx_info *nxi, void __user *data)
21729 + struct vcmd_nx_info_v0 vc_data;
21731 + vc_data.nid = nxi->nx_id;
21733 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21739 +/* network functions */
21741 +int vc_net_create(uint32_t nid, void __user *data)
21743 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21744 + struct nx_info *new_nxi;
21747 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21750 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21753 + new_nxi = __create_nx_info(nid);
21754 + if (IS_ERR(new_nxi))
21755 + return PTR_ERR(new_nxi);
21757 + /* initial flags */
21758 + new_nxi->nx_flags = vc_data.flagword;
21761 + if (vs_net_change(new_nxi, VSC_NETUP))
21764 + ret = nx_migrate_task(current, new_nxi);
21768 + /* return context id on success */
21769 + ret = new_nxi->nx_id;
21771 + /* get a reference for persistent contexts */
21772 + if ((vc_data.flagword & NXF_PERSISTENT))
21773 + nx_set_persistent(new_nxi);
21775 + release_nx_info(new_nxi, NULL);
21776 + put_nx_info(new_nxi);
21781 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21783 + return nx_migrate_task(current, nxi);
21788 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21789 + uint16_t type, uint16_t flags)
21791 + struct nx_addr_v4 *nxa = &nxi->v4;
21793 + if (NX_IPV4(nxi)) {
21794 + /* locate last entry */
21795 + for (; nxa->next; nxa = nxa->next);
21796 + nxa->next = __alloc_nx_addr_v4();
21800 + return PTR_ERR(nxa);
21803 + if (nxi->v4.next)
21804 + /* remove single ip for ip list */
21805 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21807 + nxa->ip[0].s_addr = ip;
21808 + nxa->ip[1].s_addr = ip2;
21809 + nxa->mask.s_addr = mask;
21810 + nxa->type = type;
21811 + nxa->flags = flags;
21816 +int vc_net_add(struct nx_info *nxi, void __user *data)
21818 + struct vcmd_net_addr_v0 vc_data;
21819 + int index, ret = 0;
21821 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21824 + switch (vc_data.type) {
21825 + case NXA_TYPE_IPV4:
21826 + if ((vc_data.count < 1) || (vc_data.count > 4))
21830 + while (index < vc_data.count) {
21831 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21832 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21840 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21841 + nxi->v4_bcast = vc_data.ip[0];
21845 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21846 + nxi->v4_lback = vc_data.ip[0];
21857 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21859 + struct vcmd_net_addr_v0 vc_data;
21861 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21864 + switch (vc_data.type) {
21865 + case NXA_TYPE_ANY:
21866 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21867 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21877 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21879 + struct vcmd_net_addr_ipv4_v1 vc_data;
21881 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21884 + switch (vc_data.type) {
21885 + case NXA_TYPE_ADDR:
21886 + case NXA_TYPE_RANGE:
21887 + case NXA_TYPE_MASK:
21888 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21889 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21891 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21892 + nxi->v4_bcast = vc_data.ip;
21895 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21896 + nxi->v4_lback = vc_data.ip;
21905 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
21907 + struct vcmd_net_addr_ipv4_v1 vc_data;
21909 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21912 + switch (vc_data.type) {
21913 +/* case NXA_TYPE_ADDR:
21916 + case NXA_TYPE_ANY:
21917 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21918 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21928 +#ifdef CONFIG_IPV6
21930 +int do_add_v6_addr(struct nx_info *nxi,
21931 + struct in6_addr *ip, struct in6_addr *mask,
21932 + uint32_t prefix, uint16_t type, uint16_t flags)
21934 + struct nx_addr_v6 *nxa = &nxi->v6;
21936 + if (NX_IPV6(nxi)) {
21937 + /* locate last entry */
21938 + for (; nxa->next; nxa = nxa->next);
21939 + nxa->next = __alloc_nx_addr_v6();
21943 + return PTR_ERR(nxa);
21947 + nxa->mask = *mask;
21948 + nxa->prefix = prefix;
21949 + nxa->type = type;
21950 + nxa->flags = flags;
21955 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21957 + struct vcmd_net_addr_ipv6_v1 vc_data;
21959 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21962 + switch (vc_data.type) {
21963 + case NXA_TYPE_ADDR:
21964 + case NXA_TYPE_MASK:
21965 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21966 + vc_data.prefix, vc_data.type, vc_data.flags);
21973 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21975 + struct vcmd_net_addr_ipv6_v1 vc_data;
21977 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21980 + switch (vc_data.type) {
21981 + case NXA_TYPE_ANY:
21982 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21983 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21992 +#endif /* CONFIG_IPV6 */
21995 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21997 + struct vcmd_net_flags_v0 vc_data;
21999 + vc_data.flagword = nxi->nx_flags;
22001 + /* special STATE flag handling */
22002 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
22004 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22009 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
22011 + struct vcmd_net_flags_v0 vc_data;
22012 + uint64_t mask, trigger;
22014 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22017 + /* special STATE flag handling */
22018 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
22019 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
22021 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
22022 + vc_data.flagword, mask);
22023 + if (trigger & NXF_PERSISTENT)
22024 + nx_update_persistent(nxi);
22029 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
22031 + struct vcmd_net_caps_v0 vc_data;
22033 + vc_data.ncaps = nxi->nx_ncaps;
22034 + vc_data.cmask = ~0ULL;
22036 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22041 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
22043 + struct vcmd_net_caps_v0 vc_data;
22045 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22048 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
22049 + vc_data.ncaps, vc_data.cmask);
22054 +#include <linux/module.h>
22056 +module_init(init_network);
22058 +EXPORT_SYMBOL_GPL(free_nx_info);
22059 +EXPORT_SYMBOL_GPL(unhash_nx_info);
22061 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/proc.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/proc.c
22062 --- linux-2.6.27.3/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
22063 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/proc.c 2008-10-13 14:54:20.000000000 +0200
22066 + * linux/kernel/vserver/proc.c
22068 + * Virtual Context Support
22070 + * Copyright (C) 2003-2007 Herbert Pötzl
22072 + * V0.01 basic structure
22073 + * V0.02 adaptation vs1.3.0
22074 + * V0.03 proc permissions
22075 + * V0.04 locking/generic
22076 + * V0.05 next generation procfs
22077 + * V0.06 inode validation
22078 + * V0.07 generic rewrite vid
22079 + * V0.08 remove inode type
22083 +#include <linux/proc_fs.h>
22084 +#include <asm/unistd.h>
22086 +#include <linux/vs_context.h>
22087 +#include <linux/vs_network.h>
22088 +#include <linux/vs_cvirt.h>
22090 +#include <linux/in.h>
22091 +#include <linux/inetdevice.h>
22092 +#include <linux/vs_inet.h>
22093 +#include <linux/vs_inet6.h>
22095 +#include <linux/vserver/global.h>
22097 +#include "cvirt_proc.h"
22098 +#include "cacct_proc.h"
22099 +#include "limit_proc.h"
22100 +#include "sched_proc.h"
22101 +#include "vci_config.h"
22104 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
22108 + CAP_FOR_EACH_U32(__capi) {
22109 + buffer += sprintf(buffer, "%08x",
22110 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
22116 +static struct proc_dir_entry *proc_virtual;
22118 +static struct proc_dir_entry *proc_virtnet;
22121 +/* first the actual feeds */
22124 +static int proc_vci(char *buffer)
22126 + return sprintf(buffer,
22127 + "VCIVersion:\t%04x:%04x\n"
22128 + "VCISyscall:\t%d\n"
22129 + "VCIKernel:\t%08x\n",
22130 + VCI_VERSION >> 16,
22131 + VCI_VERSION & 0xFFFF,
22133 + vci_kernel_config());
22136 +static int proc_virtual_info(char *buffer)
22138 + return proc_vci(buffer);
22141 +static int proc_virtual_status(char *buffer)
22143 + return sprintf(buffer,
22145 + "#CActive:\t%d\n"
22146 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n",
22147 + atomic_read(&vx_global_ctotal),
22148 + atomic_read(&vx_global_cactive),
22149 + atomic_read(&vs_global_nsproxy),
22150 + atomic_read(&vs_global_fs),
22151 + atomic_read(&vs_global_mnt_ns),
22152 + atomic_read(&vs_global_uts_ns),
22153 + atomic_read(&vs_global_ipc_ns),
22154 + atomic_read(&vs_global_user_ns),
22155 + atomic_read(&vs_global_pid_ns));
22159 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
22163 + length = sprintf(buffer,
22171 + vxi->vx_badness_bias);
22175 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
22177 + char *orig = buffer;
22179 + buffer += sprintf(buffer,
22182 + "Flags:\t%016llx\n",
22183 + atomic_read(&vxi->vx_usecnt),
22184 + atomic_read(&vxi->vx_tasks),
22185 + (unsigned long long)vxi->vx_flags);
22187 + buffer += sprintf(buffer, "BCaps:\t");
22188 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22189 + buffer += sprintf(buffer, "\n");
22191 + buffer += sprintf(buffer,
22192 + "CCaps:\t%016llx\n"
22193 + "Spaces:\t%08lx\n",
22194 + (unsigned long long)vxi->vx_ccaps,
22196 + return buffer - orig;
22199 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
22201 + return vx_info_proc_limit(&vxi->limit, buffer);
22204 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
22208 + length = vx_info_proc_sched(&vxi->sched, buffer);
22209 + for_each_online_cpu(cpu) {
22210 + length += vx_info_proc_sched_pc(
22211 + &vx_per_cpu(vxi, sched_pc, cpu),
22212 + buffer + length, cpu);
22217 +int proc_vxi_nsproxy(struct vx_info *vxi, char *buffer)
22219 + return vx_info_proc_nsproxy(vxi->vx_nsproxy, buffer);
22222 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
22226 + vx_update_load(vxi);
22227 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
22228 + for_each_online_cpu(cpu) {
22229 + length += vx_info_proc_cvirt_pc(
22230 + &vx_per_cpu(vxi, cvirt_pc, cpu),
22231 + buffer + length, cpu);
22236 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
22238 + return vx_info_proc_cacct(&vxi->cacct, buffer);
22242 +static int proc_virtnet_info(char *buffer)
22244 + return proc_vci(buffer);
22247 +static int proc_virtnet_status(char *buffer)
22249 + return sprintf(buffer,
22251 + "#CActive:\t%d\n",
22252 + atomic_read(&nx_global_ctotal),
22253 + atomic_read(&nx_global_cactive));
22256 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
22258 + struct nx_addr_v4 *v4a;
22259 +#ifdef CONFIG_IPV6
22260 + struct nx_addr_v6 *v6a;
22264 + length = sprintf(buffer,
22267 + "Bcast:\t" NIPQUAD_FMT "\n"
22268 + "Lback:\t" NIPQUAD_FMT "\n",
22271 + NIPQUAD(nxi->v4_bcast.s_addr),
22272 + NIPQUAD(nxi->v4_lback.s_addr));
22274 + if (!NX_IPV4(nxi))
22276 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22277 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
22280 +#ifdef CONFIG_IPV6
22281 + if (!NX_IPV6(nxi))
22283 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22284 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
22291 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
22295 + length = sprintf(buffer,
22298 + "Flags:\t%016llx\n"
22299 + "NCaps:\t%016llx\n",
22300 + atomic_read(&nxi->nx_usecnt),
22301 + atomic_read(&nxi->nx_tasks),
22302 + (unsigned long long)nxi->nx_flags,
22303 + (unsigned long long)nxi->nx_ncaps);
22309 +/* here the inode helpers */
22315 + struct inode_operations *iop;
22316 + struct file_operations *fop;
22317 + union proc_op op;
22320 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
22322 + struct inode *inode = new_inode(sb);
22327 + inode->i_mode = p->mode;
22329 + inode->i_op = p->iop;
22331 + inode->i_fop = p->fop;
22333 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
22334 + inode->i_flags |= S_IMMUTABLE;
22336 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
22338 + inode->i_uid = 0;
22339 + inode->i_gid = 0;
22340 + inode->i_tag = 0;
22345 +static struct dentry *vs_proc_instantiate(struct inode *dir,
22346 + struct dentry *dentry, int id, void *ptr)
22348 + struct vs_entry *p = ptr;
22349 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
22350 + struct dentry *error = ERR_PTR(-EINVAL);
22355 + PROC_I(inode)->op = p->op;
22356 + PROC_I(inode)->fd = id;
22357 + d_add(dentry, inode);
22365 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
22368 + * Fill a directory entry.
22370 + * If possible create the dcache entry and derive our inode number and
22371 + * file type from dcache entry.
22373 + * Since all of the proc inode numbers are dynamically generated, the inode
22374 + * numbers do not exist until the inode is cache. This means creating the
22375 + * the dcache entry in readdir is necessary to keep the inode numbers
22376 + * reported by readdir in sync with the inode numbers reported
22379 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
22380 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
22382 + struct dentry *child, *dir = filp->f_dentry;
22383 + struct inode *inode;
22384 + struct qstr qname;
22386 + unsigned type = DT_UNKNOWN;
22388 + qname.name = name;
22390 + qname.hash = full_name_hash(name, len);
22392 + child = d_lookup(dir, &qname);
22394 + struct dentry *new;
22395 + new = d_alloc(dir, &qname);
22397 + child = instantiate(dir->d_inode, new, id, ptr);
22404 + if (!child || IS_ERR(child) || !child->d_inode)
22405 + goto end_instantiate;
22406 + inode = child->d_inode;
22408 + ino = inode->i_ino;
22409 + type = inode->i_mode >> 12;
22414 + ino = find_inode_number(dir, &qname);
22417 + return filldir(dirent, name, len, filp->f_pos, ino, type);
22422 +/* get and revalidate vx_info/xid */
22425 +struct vx_info *get_proc_vx_info(struct inode *inode)
22427 + return lookup_vx_info(PROC_I(inode)->fd);
22430 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
22432 + struct inode *inode = dentry->d_inode;
22433 + xid_t xid = PROC_I(inode)->fd;
22435 + if (!xid || xid_is_hashed(xid))
22442 +/* get and revalidate nx_info/nid */
22444 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
22446 + struct inode *inode = dentry->d_inode;
22447 + nid_t nid = PROC_I(inode)->fd;
22449 + if (!nid || nid_is_hashed(nid))
22457 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
22459 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
22460 + size_t count, loff_t *ppos)
22462 + struct inode *inode = file->f_dentry->d_inode;
22463 + unsigned long page;
22464 + ssize_t length = 0;
22466 + if (count > PROC_BLOCK_SIZE)
22467 + count = PROC_BLOCK_SIZE;
22469 + /* fade that out as soon as stable */
22470 + WARN_ON(PROC_I(inode)->fd);
22472 + if (!(page = __get_free_page(GFP_KERNEL)))
22475 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
22476 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
22479 + length = simple_read_from_buffer(buf, count, ppos,
22480 + (char *)page, length);
22486 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
22487 + size_t count, loff_t *ppos)
22489 + struct inode *inode = file->f_dentry->d_inode;
22490 + struct vx_info *vxi = NULL;
22491 + xid_t xid = PROC_I(inode)->fd;
22492 + unsigned long page;
22493 + ssize_t length = 0;
22495 + if (count > PROC_BLOCK_SIZE)
22496 + count = PROC_BLOCK_SIZE;
22498 + /* fade that out as soon as stable */
22500 + vxi = lookup_vx_info(xid);
22504 + length = -ENOMEM;
22505 + if (!(page = __get_free_page(GFP_KERNEL)))
22508 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
22509 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
22512 + length = simple_read_from_buffer(buf, count, ppos,
22513 + (char *)page, length);
22517 + put_vx_info(vxi);
22522 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
22523 + size_t count, loff_t *ppos)
22525 + struct inode *inode = file->f_dentry->d_inode;
22526 + struct nx_info *nxi = NULL;
22527 + nid_t nid = PROC_I(inode)->fd;
22528 + unsigned long page;
22529 + ssize_t length = 0;
22531 + if (count > PROC_BLOCK_SIZE)
22532 + count = PROC_BLOCK_SIZE;
22534 + /* fade that out as soon as stable */
22536 + nxi = lookup_nx_info(nid);
22540 + length = -ENOMEM;
22541 + if (!(page = __get_free_page(GFP_KERNEL)))
22544 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22545 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22548 + length = simple_read_from_buffer(buf, count, ppos,
22549 + (char *)page, length);
22553 + put_nx_info(nxi);
22560 +/* here comes the lower level */
22563 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22564 + .len = sizeof(NAME) - 1, \
22565 + .name = (NAME), \
22573 +#define DIR(NAME, MODE, OTYPE) \
22574 + NOD(NAME, (S_IFDIR | (MODE)), \
22575 + &proc_ ## OTYPE ## _inode_operations, \
22576 + &proc_ ## OTYPE ## _file_operations, { } )
22578 +#define INF(NAME, MODE, OTYPE) \
22579 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22580 + &proc_vs_info_file_operations, \
22581 + { .proc_vs_read = &proc_##OTYPE } )
22583 +#define VINF(NAME, MODE, OTYPE) \
22584 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22585 + &proc_vx_info_file_operations, \
22586 + { .proc_vxi_read = &proc_##OTYPE } )
22588 +#define NINF(NAME, MODE, OTYPE) \
22589 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22590 + &proc_nx_info_file_operations, \
22591 + { .proc_nxi_read = &proc_##OTYPE } )
22594 +static struct file_operations proc_vs_info_file_operations = {
22595 + .read = proc_vs_info_read,
22598 +static struct file_operations proc_vx_info_file_operations = {
22599 + .read = proc_vx_info_read,
22602 +static struct dentry_operations proc_xid_dentry_operations = {
22603 + .d_revalidate = proc_xid_revalidate,
22606 +static struct vs_entry vx_base_stuff[] = {
22607 + VINF("info", S_IRUGO, vxi_info),
22608 + VINF("status", S_IRUGO, vxi_status),
22609 + VINF("limit", S_IRUGO, vxi_limit),
22610 + VINF("sched", S_IRUGO, vxi_sched),
22611 + VINF("nsproxy", S_IRUGO, vxi_nsproxy),
22612 + VINF("cvirt", S_IRUGO, vxi_cvirt),
22613 + VINF("cacct", S_IRUGO, vxi_cacct),
22620 +static struct dentry *proc_xid_instantiate(struct inode *dir,
22621 + struct dentry *dentry, int id, void *ptr)
22623 + dentry->d_op = &proc_xid_dentry_operations;
22624 + return vs_proc_instantiate(dir, dentry, id, ptr);
22627 +static struct dentry *proc_xid_lookup(struct inode *dir,
22628 + struct dentry *dentry, struct nameidata *nd)
22630 + struct vs_entry *p = vx_base_stuff;
22631 + struct dentry *error = ERR_PTR(-ENOENT);
22633 + for (; p->name; p++) {
22634 + if (p->len != dentry->d_name.len)
22636 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22642 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22647 +static int proc_xid_readdir(struct file *filp,
22648 + void *dirent, filldir_t filldir)
22650 + struct dentry *dentry = filp->f_dentry;
22651 + struct inode *inode = dentry->d_inode;
22652 + struct vs_entry *p = vx_base_stuff;
22653 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
22657 + pos = filp->f_pos;
22660 + ino = inode->i_ino;
22661 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22664 + /* fall through */
22666 + ino = parent_ino(dentry);
22667 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22670 + /* fall through */
22673 + if (index >= size)
22675 + for (p += index; p->name; p++) {
22676 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22677 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22683 + filp->f_pos = pos;
22689 +static struct file_operations proc_nx_info_file_operations = {
22690 + .read = proc_nx_info_read,
22693 +static struct dentry_operations proc_nid_dentry_operations = {
22694 + .d_revalidate = proc_nid_revalidate,
22697 +static struct vs_entry nx_base_stuff[] = {
22698 + NINF("info", S_IRUGO, nxi_info),
22699 + NINF("status", S_IRUGO, nxi_status),
22704 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22705 + struct dentry *dentry, int id, void *ptr)
22707 + dentry->d_op = &proc_nid_dentry_operations;
22708 + return vs_proc_instantiate(dir, dentry, id, ptr);
22711 +static struct dentry *proc_nid_lookup(struct inode *dir,
22712 + struct dentry *dentry, struct nameidata *nd)
22714 + struct vs_entry *p = nx_base_stuff;
22715 + struct dentry *error = ERR_PTR(-ENOENT);
22717 + for (; p->name; p++) {
22718 + if (p->len != dentry->d_name.len)
22720 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22726 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22731 +static int proc_nid_readdir(struct file *filp,
22732 + void *dirent, filldir_t filldir)
22734 + struct dentry *dentry = filp->f_dentry;
22735 + struct inode *inode = dentry->d_inode;
22736 + struct vs_entry *p = nx_base_stuff;
22737 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22741 + pos = filp->f_pos;
22744 + ino = inode->i_ino;
22745 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22748 + /* fall through */
22750 + ino = parent_ino(dentry);
22751 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22754 + /* fall through */
22757 + if (index >= size)
22759 + for (p += index; p->name; p++) {
22760 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22761 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22767 + filp->f_pos = pos;
22772 +#define MAX_MULBY10 ((~0U - 9) / 10)
22774 +static inline int atovid(const char *str, int len)
22779 + while (len-- > 0) {
22784 + if (vid >= MAX_MULBY10)
22794 +/* now the upper level (virtual) */
22797 +static struct file_operations proc_xid_file_operations = {
22798 + .read = generic_read_dir,
22799 + .readdir = proc_xid_readdir,
22802 +static struct inode_operations proc_xid_inode_operations = {
22803 + .lookup = proc_xid_lookup,
22806 +static struct vs_entry vx_virtual_stuff[] = {
22807 + INF("info", S_IRUGO, virtual_info),
22808 + INF("status", S_IRUGO, virtual_status),
22809 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22813 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22814 + struct dentry *dentry, struct nameidata *nd)
22816 + struct vs_entry *p = vx_virtual_stuff;
22817 + struct dentry *error = ERR_PTR(-ENOENT);
22820 + for (; p->name; p++) {
22821 + if (p->len != dentry->d_name.len)
22823 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22827 + goto instantiate;
22829 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22830 + if ((id < 0) || !xid_is_hashed(id))
22834 + error = proc_xid_instantiate(dir, dentry, id, p);
22839 +static struct file_operations proc_nid_file_operations = {
22840 + .read = generic_read_dir,
22841 + .readdir = proc_nid_readdir,
22844 +static struct inode_operations proc_nid_inode_operations = {
22845 + .lookup = proc_nid_lookup,
22848 +static struct vs_entry nx_virtnet_stuff[] = {
22849 + INF("info", S_IRUGO, virtnet_info),
22850 + INF("status", S_IRUGO, virtnet_status),
22851 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22855 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22856 + struct dentry *dentry, struct nameidata *nd)
22858 + struct vs_entry *p = nx_virtnet_stuff;
22859 + struct dentry *error = ERR_PTR(-ENOENT);
22862 + for (; p->name; p++) {
22863 + if (p->len != dentry->d_name.len)
22865 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22869 + goto instantiate;
22871 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22872 + if ((id < 0) || !nid_is_hashed(id))
22876 + error = proc_nid_instantiate(dir, dentry, id, p);
22882 +#define PROC_MAXVIDS 32
22884 +int proc_virtual_readdir(struct file *filp,
22885 + void *dirent, filldir_t filldir)
22887 + struct dentry *dentry = filp->f_dentry;
22888 + struct inode *inode = dentry->d_inode;
22889 + struct vs_entry *p = vx_virtual_stuff;
22890 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22892 + unsigned int xid_array[PROC_MAXVIDS];
22893 + char buf[PROC_NUMBUF];
22894 + unsigned int nr_xids, i;
22897 + pos = filp->f_pos;
22900 + ino = inode->i_ino;
22901 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22904 + /* fall through */
22906 + ino = parent_ino(dentry);
22907 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22910 + /* fall through */
22913 + if (index >= size)
22915 + for (p += index; p->name; p++) {
22916 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22917 + vs_proc_instantiate, 0, p))
22922 + index = pos - size;
22923 + p = &vx_virtual_stuff[size - 1];
22924 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22925 + for (i = 0; i < nr_xids; i++) {
22926 + int n, xid = xid_array[i];
22927 + unsigned int j = PROC_NUMBUF;
22931 + buf[--j] = '0' + (n % 10);
22934 + if (proc_fill_cache(filp, dirent, filldir,
22935 + buf + j, PROC_NUMBUF - j,
22936 + vs_proc_instantiate, xid, p))
22942 + filp->f_pos = pos;
22946 +static int proc_virtual_getattr(struct vfsmount *mnt,
22947 + struct dentry *dentry, struct kstat *stat)
22949 + struct inode *inode = dentry->d_inode;
22951 + generic_fillattr(inode, stat);
22952 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22956 +static struct file_operations proc_virtual_dir_operations = {
22957 + .read = generic_read_dir,
22958 + .readdir = proc_virtual_readdir,
22961 +static struct inode_operations proc_virtual_dir_inode_operations = {
22962 + .getattr = proc_virtual_getattr,
22963 + .lookup = proc_virtual_lookup,
22970 +int proc_virtnet_readdir(struct file *filp,
22971 + void *dirent, filldir_t filldir)
22973 + struct dentry *dentry = filp->f_dentry;
22974 + struct inode *inode = dentry->d_inode;
22975 + struct vs_entry *p = nx_virtnet_stuff;
22976 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22978 + unsigned int nid_array[PROC_MAXVIDS];
22979 + char buf[PROC_NUMBUF];
22980 + unsigned int nr_nids, i;
22983 + pos = filp->f_pos;
22986 + ino = inode->i_ino;
22987 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22990 + /* fall through */
22992 + ino = parent_ino(dentry);
22993 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22996 + /* fall through */
22999 + if (index >= size)
23001 + for (p += index; p->name; p++) {
23002 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23003 + vs_proc_instantiate, 0, p))
23008 + index = pos - size;
23009 + p = &nx_virtnet_stuff[size - 1];
23010 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
23011 + for (i = 0; i < nr_nids; i++) {
23012 + int n, nid = nid_array[i];
23013 + unsigned int j = PROC_NUMBUF;
23017 + buf[--j] = '0' + (n % 10);
23020 + if (proc_fill_cache(filp, dirent, filldir,
23021 + buf + j, PROC_NUMBUF - j,
23022 + vs_proc_instantiate, nid, p))
23028 + filp->f_pos = pos;
23032 +static int proc_virtnet_getattr(struct vfsmount *mnt,
23033 + struct dentry *dentry, struct kstat *stat)
23035 + struct inode *inode = dentry->d_inode;
23037 + generic_fillattr(inode, stat);
23038 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
23042 +static struct file_operations proc_virtnet_dir_operations = {
23043 + .read = generic_read_dir,
23044 + .readdir = proc_virtnet_readdir,
23047 +static struct inode_operations proc_virtnet_dir_inode_operations = {
23048 + .getattr = proc_virtnet_getattr,
23049 + .lookup = proc_virtnet_lookup,
23054 +void proc_vx_init(void)
23056 + struct proc_dir_entry *ent;
23058 + ent = proc_mkdir("virtual", 0);
23060 + ent->proc_fops = &proc_virtual_dir_operations;
23061 + ent->proc_iops = &proc_virtual_dir_inode_operations;
23063 + proc_virtual = ent;
23065 + ent = proc_mkdir("virtnet", 0);
23067 + ent->proc_fops = &proc_virtnet_dir_operations;
23068 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
23070 + proc_virtnet = ent;
23076 +/* per pid info */
23079 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
23081 + struct vx_info *vxi;
23082 + char *orig = buffer;
23084 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
23086 + vxi = task_get_vx_info(p);
23090 + buffer += sprintf(buffer, "BCaps:\t");
23091 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23092 + buffer += sprintf(buffer, "\n");
23093 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
23094 + (unsigned long long)vxi->vx_ccaps);
23095 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
23096 + (unsigned long long)vxi->vx_flags);
23097 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
23099 + put_vx_info(vxi);
23101 + return buffer - orig;
23105 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
23107 + struct nx_info *nxi;
23108 + struct nx_addr_v4 *v4a;
23109 +#ifdef CONFIG_IPV6
23110 + struct nx_addr_v6 *v6a;
23112 + char *orig = buffer;
23115 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
23117 + nxi = task_get_nx_info(p);
23121 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
23122 + (unsigned long long)nxi->nx_ncaps);
23123 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
23124 + (unsigned long long)nxi->nx_flags);
23126 + buffer += sprintf(buffer,
23127 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
23128 + NIPQUAD(nxi->v4_bcast.s_addr));
23129 + buffer += sprintf (buffer,
23130 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
23131 + NIPQUAD(nxi->v4_lback.s_addr));
23132 + if (!NX_IPV4(nxi))
23134 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23135 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
23138 +#ifdef CONFIG_IPV6
23139 + if (!NX_IPV6(nxi))
23141 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23142 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
23146 + put_nx_info(nxi);
23148 + return buffer - orig;
23151 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/sched.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/sched.c
23152 --- linux-2.6.27.3/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
23153 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/sched.c 2008-10-13 14:54:20.000000000 +0200
23156 + * linux/kernel/vserver/sched.c
23158 + * Virtual Server: Scheduler Support
23160 + * Copyright (C) 2004-2007 Herbert Pötzl
23162 + * V0.01 adapted Sam Vilains version to 2.6.3
23163 + * V0.02 removed legacy interface
23164 + * V0.03 changed vcmds to vxi arg
23165 + * V0.04 removed older and legacy interfaces
23169 +#include <linux/vs_context.h>
23170 +#include <linux/vs_sched.h>
23171 +#include <linux/vserver/sched_cmd.h>
23173 +#include <asm/uaccess.h>
23176 +#define vxd_check_range(val, min, max) do { \
23177 + vxlprintk((val < min) || (val > max), \
23178 + "check_range(%ld,%ld,%ld)", \
23179 + (long)val, (long)min, (long)max, \
23180 + __FILE__, __LINE__); \
23184 +void vx_update_sched_param(struct _vx_sched *sched,
23185 + struct _vx_sched_pc *sched_pc)
23187 + unsigned int set_mask = sched->update_mask;
23189 + if (set_mask & VXSM_FILL_RATE)
23190 + sched_pc->fill_rate[0] = sched->fill_rate[0];
23191 + if (set_mask & VXSM_INTERVAL)
23192 + sched_pc->interval[0] = sched->interval[0];
23193 + if (set_mask & VXSM_FILL_RATE2)
23194 + sched_pc->fill_rate[1] = sched->fill_rate[1];
23195 + if (set_mask & VXSM_INTERVAL2)
23196 + sched_pc->interval[1] = sched->interval[1];
23197 + if (set_mask & VXSM_TOKENS)
23198 + sched_pc->tokens = sched->tokens;
23199 + if (set_mask & VXSM_TOKENS_MIN)
23200 + sched_pc->tokens_min = sched->tokens_min;
23201 + if (set_mask & VXSM_TOKENS_MAX)
23202 + sched_pc->tokens_max = sched->tokens_max;
23203 + if (set_mask & VXSM_PRIO_BIAS)
23204 + sched_pc->prio_bias = sched->prio_bias;
23206 + if (set_mask & VXSM_IDLE_TIME)
23207 + sched_pc->flags |= VXSF_IDLE_TIME;
23209 + sched_pc->flags &= ~VXSF_IDLE_TIME;
23212 + sched_pc->norm_time = jiffies;
23217 + * recalculate the context's scheduling tokens
23219 + * ret > 0 : number of tokens available
23220 + * ret < 0 : on hold, check delta_min[]
23221 + * -1 only jiffies
23222 + * -2 also idle time
23225 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
23226 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
23230 + int flags = sched_pc->flags;
23232 + /* how much time did pass? */
23233 + delta = *norm_time - sched_pc->norm_time;
23234 + vxd_check_range(delta, 0, INT_MAX);
23236 + if (delta >= sched_pc->interval[0]) {
23237 + long tokens, integral;
23239 + /* calc integral token part */
23240 + tokens = delta / sched_pc->interval[0];
23241 + integral = tokens * sched_pc->interval[0];
23242 + tokens *= sched_pc->fill_rate[0];
23243 +#ifdef CONFIG_VSERVER_HARDCPU
23244 + delta_min[0] = delta - integral;
23245 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
23247 + /* advance time */
23248 + sched_pc->norm_time += delta;
23251 + sched_pc->tokens += tokens;
23252 + sched_pc->token_time += tokens;
23254 + delta_min[0] = delta;
23256 +#ifdef CONFIG_VSERVER_IDLETIME
23257 + if (!(flags & VXSF_IDLE_TIME))
23260 + /* how much was the idle skip? */
23261 + delta = *idle_time - sched_pc->idle_time;
23262 + vxd_check_range(delta, 0, INT_MAX);
23264 + if (delta >= sched_pc->interval[1]) {
23265 + long tokens, integral;
23267 + /* calc fair share token part */
23268 + tokens = delta / sched_pc->interval[1];
23269 + integral = tokens * sched_pc->interval[1];
23270 + tokens *= sched_pc->fill_rate[1];
23271 + delta_min[1] = delta - integral;
23272 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
23274 + /* advance idle time */
23275 + sched_pc->idle_time += integral;
23278 + sched_pc->tokens += tokens;
23279 + sched_pc->token_time += tokens;
23281 + delta_min[1] = delta;
23285 + /* clip at maximum */
23286 + if (sched_pc->tokens > sched_pc->tokens_max)
23287 + sched_pc->tokens = sched_pc->tokens_max;
23288 + tokens = sched_pc->tokens;
23290 + if ((flags & VXSF_ONHOLD)) {
23291 + /* can we unhold? */
23292 + if (tokens >= sched_pc->tokens_min) {
23293 + flags &= ~VXSF_ONHOLD;
23294 + sched_pc->hold_ticks +=
23295 + *norm_time - sched_pc->onhold;
23299 + /* put on hold? */
23300 + if (tokens <= 0) {
23301 + flags |= VXSF_ONHOLD;
23302 + sched_pc->onhold = *norm_time;
23306 + sched_pc->flags = flags;
23310 + tokens = sched_pc->tokens_min - tokens;
23311 + sched_pc->flags = flags;
23312 + BUG_ON(tokens < 0);
23314 +#ifdef CONFIG_VSERVER_HARDCPU
23315 + /* next interval? */
23316 + if (!sched_pc->fill_rate[0])
23317 + delta_min[0] = HZ;
23318 + else if (tokens > sched_pc->fill_rate[0])
23319 + delta_min[0] += sched_pc->interval[0] *
23320 + tokens / sched_pc->fill_rate[0];
23322 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
23323 + vxd_check_range(delta_min[0], 0, INT_MAX);
23325 +#ifdef CONFIG_VSERVER_IDLETIME
23326 + if (!(flags & VXSF_IDLE_TIME))
23329 + /* next interval? */
23330 + if (!sched_pc->fill_rate[1])
23331 + delta_min[1] = HZ;
23332 + else if (tokens > sched_pc->fill_rate[1])
23333 + delta_min[1] += sched_pc->interval[1] *
23334 + tokens / sched_pc->fill_rate[1];
23336 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
23337 + vxd_check_range(delta_min[1], 0, INT_MAX);
23342 +#endif /* CONFIG_VSERVER_IDLETIME */
23345 +#endif /* CONFIG_VSERVER_HARDCPU */
23348 +static inline unsigned long msec_to_ticks(unsigned long msec)
23350 + return msecs_to_jiffies(msec);
23353 +static inline unsigned long ticks_to_msec(unsigned long ticks)
23355 + return jiffies_to_msecs(ticks);
23358 +static inline unsigned long ticks_to_usec(unsigned long ticks)
23360 + return jiffies_to_usecs(ticks);
23364 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
23366 + unsigned int set_mask = data->mask;
23367 + unsigned int update_mask;
23370 + /* Sanity check data values */
23371 + if (data->tokens_max <= 0)
23372 + data->tokens_max = HZ;
23373 + if (data->tokens_min < 0)
23374 + data->tokens_min = HZ / 3;
23375 + if (data->tokens_min >= data->tokens_max)
23376 + data->tokens_min = data->tokens_max;
23378 + if (data->prio_bias > MAX_PRIO_BIAS)
23379 + data->prio_bias = MAX_PRIO_BIAS;
23380 + if (data->prio_bias < MIN_PRIO_BIAS)
23381 + data->prio_bias = MIN_PRIO_BIAS;
23383 + spin_lock(&vxi->sched.tokens_lock);
23385 + /* sync up on delayed updates */
23386 + for_each_cpu_mask(cpu, vxi->sched.update)
23387 + vx_update_sched_param(&vxi->sched,
23388 + &vx_per_cpu(vxi, sched_pc, cpu));
23390 + if (set_mask & VXSM_FILL_RATE)
23391 + vxi->sched.fill_rate[0] = data->fill_rate[0];
23392 + if (set_mask & VXSM_FILL_RATE2)
23393 + vxi->sched.fill_rate[1] = data->fill_rate[1];
23394 + if (set_mask & VXSM_INTERVAL)
23395 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
23396 + msec_to_ticks(data->interval[0]) : data->interval[0];
23397 + if (set_mask & VXSM_INTERVAL2)
23398 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
23399 + msec_to_ticks(data->interval[1]) : data->interval[1];
23400 + if (set_mask & VXSM_TOKENS)
23401 + vxi->sched.tokens = data->tokens;
23402 + if (set_mask & VXSM_TOKENS_MIN)
23403 + vxi->sched.tokens_min = data->tokens_min;
23404 + if (set_mask & VXSM_TOKENS_MAX)
23405 + vxi->sched.tokens_max = data->tokens_max;
23406 + if (set_mask & VXSM_PRIO_BIAS)
23407 + vxi->sched.prio_bias = data->prio_bias;
23409 + /* Sanity check rate/interval */
23410 + for (i = 0; i < 2; i++) {
23411 + if (data->fill_rate[i] < 0)
23412 + data->fill_rate[i] = 0;
23413 + if (data->interval[i] <= 0)
23414 + data->interval[i] = HZ;
23417 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
23418 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
23419 + vxi->sched.update_mask = update_mask;
23423 + if (set_mask & VXSM_CPU_ID) {
23424 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
23425 + cpus_and(vxi->sched.update, cpu_online_map,
23426 + vxi->sched.update);
23428 + vxi->sched.update = cpu_online_map;
23430 + /* forced reload? */
23431 + if (set_mask & VXSM_FORCE) {
23432 + for_each_cpu_mask(cpu, vxi->sched.update)
23433 + vx_update_sched_param(&vxi->sched,
23434 + &vx_per_cpu(vxi, sched_pc, cpu));
23435 + vxi->sched.update = CPU_MASK_NONE;
23438 + /* on UP we update immediately */
23439 + vx_update_sched_param(&vxi->sched,
23440 + &vx_per_cpu(vxi, sched_pc, 0));
23443 + spin_unlock(&vxi->sched.tokens_lock);
23448 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
23449 +#define COPY_PRI(C) C(prio_bias)
23450 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23451 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23452 + C(fill_rate[1]); C(interval[1]);
23454 +#define COPY_VALUE(name) vc_data.name = data->name
23456 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
23458 + struct vcmd_sched_v5 vc_data;
23460 + vc_data.mask = data->set_mask;
23461 + COPY_IDS(COPY_VALUE);
23462 + COPY_PRI(COPY_VALUE);
23463 + COPY_TOK(COPY_VALUE);
23464 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
23465 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
23466 + return do_set_sched(vxi, &vc_data);
23469 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
23471 + struct vcmd_set_sched_v4 vc_data;
23473 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23476 + return do_set_sched_v4(vxi, &vc_data);
23479 + /* latest interface is v5 */
23481 +int vc_set_sched(struct vx_info *vxi, void __user *data)
23483 + struct vcmd_sched_v5 vc_data;
23485 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23488 + return do_set_sched(vxi, &vc_data);
23492 +#define COPY_PRI(C) C(prio_bias)
23493 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23494 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23495 + C(fill_rate[1]); C(interval[1]);
23497 +#define COPY_VALUE(name) vc_data.name = data->name
23500 +int vc_get_sched(struct vx_info *vxi, void __user *data)
23502 + struct vcmd_sched_v5 vc_data;
23504 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23507 + if (vc_data.mask & VXSM_CPU_ID) {
23508 + int cpu = vc_data.cpu_id;
23509 + struct _vx_sched_pc *data;
23511 + if (!cpu_possible(cpu))
23514 + data = &vx_per_cpu(vxi, sched_pc, cpu);
23515 + COPY_TOK(COPY_VALUE);
23516 + COPY_PRI(COPY_VALUE);
23517 + COPY_FRI(COPY_VALUE);
23519 + if (data->flags & VXSF_IDLE_TIME)
23520 + vc_data.mask |= VXSM_IDLE_TIME;
23522 + struct _vx_sched *data = &vxi->sched;
23524 + COPY_TOK(COPY_VALUE);
23525 + COPY_PRI(COPY_VALUE);
23526 + COPY_FRI(COPY_VALUE);
23529 + if (vc_data.mask & VXSM_MSEC) {
23530 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
23531 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
23534 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23540 +int vc_sched_info(struct vx_info *vxi, void __user *data)
23542 + struct vcmd_sched_info vc_data;
23545 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23548 + cpu = vc_data.cpu_id;
23549 + if (!cpu_possible(cpu))
23553 + struct _vx_sched_pc *sched_pc =
23554 + &vx_per_cpu(vxi, sched_pc, cpu);
23556 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
23557 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
23558 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
23559 + vc_data.vavavoom = sched_pc->vavavoom;
23561 + vc_data.token_usec = ticks_to_usec(1);
23563 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23568 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/sched_init.h linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/sched_init.h
23569 --- linux-2.6.27.3/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
23570 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/sched_init.h 2008-10-13 14:54:20.000000000 +0200
23573 +static inline void vx_info_init_sched(struct _vx_sched *sched)
23575 + static struct lock_class_key tokens_lock_key;
23577 + /* scheduling; hard code starting values as constants */
23578 + sched->fill_rate[0] = 1;
23579 + sched->interval[0] = 4;
23580 + sched->fill_rate[1] = 1;
23581 + sched->interval[1] = 8;
23582 + sched->tokens = HZ >> 2;
23583 + sched->tokens_min = HZ >> 4;
23584 + sched->tokens_max = HZ >> 1;
23585 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
23586 + sched->prio_bias = 0;
23588 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
23592 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
23594 + sched_pc->fill_rate[0] = 1;
23595 + sched_pc->interval[0] = 4;
23596 + sched_pc->fill_rate[1] = 1;
23597 + sched_pc->interval[1] = 8;
23598 + sched_pc->tokens = HZ >> 2;
23599 + sched_pc->tokens_min = HZ >> 4;
23600 + sched_pc->tokens_max = HZ >> 1;
23601 + sched_pc->prio_bias = 0;
23602 + sched_pc->vavavoom = 0;
23603 + sched_pc->token_time = 0;
23604 + sched_pc->idle_time = 0;
23605 + sched_pc->norm_time = jiffies;
23607 + sched_pc->user_ticks = 0;
23608 + sched_pc->sys_ticks = 0;
23609 + sched_pc->hold_ticks = 0;
23612 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
23618 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
23622 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/sched_proc.h linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/sched_proc.h
23623 --- linux-2.6.27.3/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
23624 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/sched_proc.h 2008-10-13 14:54:20.000000000 +0200
23626 +#ifndef _VX_SCHED_PROC_H
23627 +#define _VX_SCHED_PROC_H
23631 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
23635 + length += sprintf(buffer,
23636 + "FillRate:\t%8d,%d\n"
23637 + "Interval:\t%8d,%d\n"
23638 + "TokensMin:\t%8d\n"
23639 + "TokensMax:\t%8d\n"
23640 + "PrioBias:\t%8d\n",
23641 + sched->fill_rate[0],
23642 + sched->fill_rate[1],
23643 + sched->interval[0],
23644 + sched->interval[1],
23645 + sched->tokens_min,
23646 + sched->tokens_max,
23647 + sched->prio_bias);
23652 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
23653 + char *buffer, int cpu)
23657 + length += sprintf(buffer + length,
23658 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
23659 + (unsigned long long)sched_pc->user_ticks,
23660 + (unsigned long long)sched_pc->sys_ticks,
23661 + (unsigned long long)sched_pc->hold_ticks,
23662 + sched_pc->token_time,
23663 + sched_pc->idle_time);
23664 + length += sprintf(buffer + length,
23665 + " %c%c %d %d %d %d/%d %d/%d",
23666 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
23667 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
23668 + sched_pc->tokens,
23669 + sched_pc->tokens_min,
23670 + sched_pc->tokens_max,
23671 + sched_pc->fill_rate[0],
23672 + sched_pc->interval[0],
23673 + sched_pc->fill_rate[1],
23674 + sched_pc->interval[1]);
23675 + length += sprintf(buffer + length,
23677 + sched_pc->prio_bias,
23678 + sched_pc->vavavoom);
23682 +#endif /* _VX_SCHED_PROC_H */
23683 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/signal.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/signal.c
23684 --- linux-2.6.27.3/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
23685 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/signal.c 2008-10-13 14:54:20.000000000 +0200
23688 + * linux/kernel/vserver/signal.c
23690 + * Virtual Server: Signal Support
23692 + * Copyright (C) 2003-2007 Herbert Pötzl
23694 + * V0.01 broken out from vcontext V0.05
23695 + * V0.02 changed vcmds to vxi arg
23696 + * V0.03 adjusted siginfo for kill
23700 +#include <asm/uaccess.h>
23702 +#include <linux/vs_context.h>
23703 +#include <linux/vs_pid.h>
23704 +#include <linux/vserver/signal_cmd.h>
23707 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
23709 + int retval, count = 0;
23710 + struct task_struct *p;
23711 + struct siginfo *sip = SEND_SIG_PRIV;
23714 + vxdprintk(VXD_CBIT(misc, 4),
23715 + "vx_info_kill(%p[#%d],%d,%d)*",
23716 + vxi, vxi->vx_id, pid, sig);
23717 + read_lock(&tasklist_lock);
23721 + for_each_process(p) {
23724 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
23725 + (pid && vxi->vx_initpid == p->pid))
23728 + err = group_send_sig_info(sig, sip, p);
23730 + if (err != -EPERM)
23736 + if (vxi->vx_initpid) {
23737 + pid = vxi->vx_initpid;
23738 + /* for now, only SIGINT to private init ... */
23739 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
23740 + /* ... as long as there are tasks left */
23741 + (atomic_read(&vxi->vx_tasks) > 1))
23744 + /* fallthrough */
23746 + p = find_task_by_real_pid(pid);
23748 + if (vx_task_xid(p) == vxi->vx_id)
23749 + retval = group_send_sig_info(sig, sip, p);
23753 + read_unlock(&tasklist_lock);
23754 + vxdprintk(VXD_CBIT(misc, 4),
23755 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
23756 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
23760 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
23762 + struct vcmd_ctx_kill_v0 vc_data;
23764 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23767 + /* special check to allow guest shutdown */
23768 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
23769 + /* forbid killall pid=0 when init is present */
23770 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
23771 + (vc_data.pid > 1)))
23774 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
23778 +static int __wait_exit(struct vx_info *vxi)
23780 + DECLARE_WAITQUEUE(wait, current);
23783 + add_wait_queue(&vxi->vx_wait, &wait);
23784 + set_current_state(TASK_INTERRUPTIBLE);
23787 + if (vx_info_state(vxi,
23788 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
23790 + if (signal_pending(current)) {
23791 + ret = -ERESTARTSYS;
23798 + set_current_state(TASK_RUNNING);
23799 + remove_wait_queue(&vxi->vx_wait, &wait);
23805 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
23807 + struct vcmd_wait_exit_v0 vc_data;
23810 + ret = __wait_exit(vxi);
23811 + vc_data.reboot_cmd = vxi->reboot_cmd;
23812 + vc_data.exit_code = vxi->exit_code;
23814 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23819 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/space.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/space.c
23820 --- linux-2.6.27.3/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
23821 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/space.c 2008-10-13 14:54:20.000000000 +0200
23824 + * linux/kernel/vserver/space.c
23826 + * Virtual Server: Context Space Support
23828 + * Copyright (C) 2003-2007 Herbert Pötzl
23830 + * V0.01 broken out from context.c 0.07
23831 + * V0.02 added task locking for namespace
23832 + * V0.03 broken out vx_enter_namespace
23833 + * V0.04 added *space support and commands
23837 +#include <linux/utsname.h>
23838 +#include <linux/nsproxy.h>
23839 +#include <linux/err.h>
23840 +#include <asm/uaccess.h>
23842 +#include <linux/vs_context.h>
23843 +#include <linux/vserver/space.h>
23844 +#include <linux/vserver/space_cmd.h>
23846 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
23847 +atomic_t vs_global_fs = ATOMIC_INIT(0);
23848 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
23849 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
23850 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
23851 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
23852 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
23855 +/* namespace functions */
23857 +#include <linux/mnt_namespace.h>
23858 +#include <linux/user_namespace.h>
23859 +#include <linux/pid_namespace.h>
23860 +#include <linux/ipc_namespace.h>
23861 +#include <net/net_namespace.h>
23864 +static const struct vcmd_space_mask space_mask_v0 = {
23865 + .mask = CLONE_FS |
23873 +static const struct vcmd_space_mask space_mask = {
23874 + .mask = CLONE_FS |
23879 +#ifdef CONFIG_PID_NS
23882 +#ifdef CONFIG_NET_NS
23888 +static const struct vcmd_space_mask default_space_mask = {
23889 + .mask = CLONE_FS |
23894 +#ifdef CONFIG_PID_NS
23901 + * build a new nsproxy mix
23902 + * assumes that both proxies are 'const'
23903 + * does not touch nsproxy refcounts
23904 + * will hold a reference on the result.
23907 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
23908 + struct nsproxy *new_nsproxy, unsigned long mask)
23910 + struct mnt_namespace *old_ns;
23911 + struct uts_namespace *old_uts;
23912 + struct ipc_namespace *old_ipc;
23913 + struct user_namespace *old_user;
23914 +#ifdef CONFIG_PID_NS
23915 + struct pid_namespace *old_pid;
23917 +#ifdef CONFIG_NET_NS
23918 + struct net *old_net;
23920 + struct nsproxy *nsproxy;
23922 + nsproxy = copy_nsproxy(old_nsproxy);
23926 + if (mask & CLONE_NEWNS) {
23927 + old_ns = nsproxy->mnt_ns;
23928 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
23929 + if (nsproxy->mnt_ns)
23930 + get_mnt_ns(nsproxy->mnt_ns);
23934 + if (mask & CLONE_NEWUTS) {
23935 + old_uts = nsproxy->uts_ns;
23936 + nsproxy->uts_ns = new_nsproxy->uts_ns;
23937 + if (nsproxy->uts_ns)
23938 + get_uts_ns(nsproxy->uts_ns);
23942 + if (mask & CLONE_NEWIPC) {
23943 + old_ipc = nsproxy->ipc_ns;
23944 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
23945 + if (nsproxy->ipc_ns)
23946 + get_ipc_ns(nsproxy->ipc_ns);
23950 + if (mask & CLONE_NEWUSER) {
23951 + old_user = nsproxy->user_ns;
23952 + nsproxy->user_ns = new_nsproxy->user_ns;
23953 + if (nsproxy->user_ns)
23954 + get_user_ns(nsproxy->user_ns);
23958 +#ifdef CONFIG_PID_NS
23959 + if (mask & CLONE_NEWPID) {
23960 + old_pid = nsproxy->pid_ns;
23961 + nsproxy->pid_ns = new_nsproxy->pid_ns;
23962 + if (nsproxy->pid_ns)
23963 + get_pid_ns(nsproxy->pid_ns);
23967 +#ifdef CONFIG_NET_NS
23968 + if (mask & CLONE_NEWNET) {
23969 + old_net = nsproxy->net_ns;
23970 + nsproxy->net_ns = new_nsproxy->net_ns;
23971 + if (nsproxy->net_ns)
23972 + get_net(nsproxy->net_ns);
23977 + put_mnt_ns(old_ns);
23979 + put_uts_ns(old_uts);
23981 + put_ipc_ns(old_ipc);
23983 + put_user_ns(old_user);
23984 +#ifdef CONFIG_PID_NS
23986 + put_pid_ns(old_pid);
23988 +#ifdef CONFIG_NET_NS
23990 + put_net(old_net);
23998 + * merge two nsproxy structs into a new one.
23999 + * will hold a reference on the result.
24003 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24004 + struct nsproxy *proxy, unsigned long mask)
24006 + struct nsproxy null_proxy = { .mnt_ns = NULL };
24012 + /* vs_mix_nsproxy returns with reference */
24013 + return vs_mix_nsproxy(old ? old : &null_proxy,
24016 + get_nsproxy(proxy);
24021 + * merge two fs structs into a new one.
24022 + * will take a reference on the result.
24026 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
24027 + struct fs_struct *fs, unsigned long mask)
24029 + if (!(mask & CLONE_FS)) {
24031 + atomic_inc(&old->count);
24038 + return copy_fs_struct(fs);
24042 +int vx_enter_space(struct vx_info *vxi, unsigned long mask)
24044 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24045 + struct fs_struct *fs, *fs_cur, *fs_new;
24048 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx)",
24049 + vxi, vxi->vx_id, mask);
24051 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24055 + mask = vxi->vx_nsmask;
24057 + if ((mask & vxi->vx_nsmask) != mask)
24060 + proxy = vxi->vx_nsproxy;
24063 + task_lock(current);
24064 + fs_cur = current->fs;
24065 + atomic_inc(&fs_cur->count);
24066 + proxy_cur = current->nsproxy;
24067 + get_nsproxy(proxy_cur);
24068 + task_unlock(current);
24070 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
24071 + if (IS_ERR(fs_new)) {
24072 + ret = PTR_ERR(fs_new);
24076 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24077 + if (IS_ERR(proxy_new)) {
24078 + ret = PTR_ERR(proxy_new);
24082 + fs_new = xchg(¤t->fs, fs_new);
24083 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24087 + put_nsproxy(proxy_new);
24090 + put_fs_struct(fs_new);
24093 + put_nsproxy(proxy_cur);
24095 + put_fs_struct(fs_cur);
24100 +int vx_set_space(struct vx_info *vxi, unsigned long mask)
24102 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24103 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
24106 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx)",
24107 + vxi, vxi->vx_id, mask);
24110 + mask = default_space_mask.mask;
24112 + if ((mask & space_mask.mask) != mask)
24115 + proxy_vxi = vxi->vx_nsproxy;
24116 + fs_vxi = vxi->vx_fs;
24118 + task_lock(current);
24119 + fs_cur = current->fs;
24120 + atomic_inc(&fs_cur->count);
24121 + proxy_cur = current->nsproxy;
24122 + get_nsproxy(proxy_cur);
24123 + task_unlock(current);
24125 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
24126 + if (IS_ERR(fs_new)) {
24127 + ret = PTR_ERR(fs_new);
24131 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24132 + if (IS_ERR(proxy_new)) {
24133 + ret = PTR_ERR(proxy_new);
24137 + fs_new = xchg(&vxi->vx_fs, fs_new);
24138 + proxy_new = xchg(&vxi->vx_nsproxy, proxy_new);
24139 + vxi->vx_nsmask |= mask;
24143 + put_nsproxy(proxy_new);
24146 + put_fs_struct(fs_new);
24149 + put_nsproxy(proxy_cur);
24151 + put_fs_struct(fs_cur);
24156 +int vc_enter_space(struct vx_info *vxi, void __user *data)
24158 + struct vcmd_space_mask vc_data = { .mask = 0 };
24160 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24163 + return vx_enter_space(vxi, vc_data.mask);
24166 +int vc_set_space(struct vx_info *vxi, void __user *data)
24168 + struct vcmd_space_mask vc_data = { .mask = 0 };
24170 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24173 + return vx_set_space(vxi, vc_data.mask);
24176 +int vc_get_space_mask(void __user *data, int type)
24178 + const struct vcmd_space_mask *mask;
24181 + mask = &space_mask_v0;
24182 + else if (type == 1)
24183 + mask = &space_mask;
24185 + mask = &default_space_mask;
24187 + vxdprintk(VXD_CBIT(space, 10),
24188 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
24190 + if (copy_to_user(data, mask, sizeof(struct vcmd_space_mask)))
24195 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/switch.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/switch.c
24196 --- linux-2.6.27.3/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
24197 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/switch.c 2008-10-13 14:54:20.000000000 +0200
24200 + * linux/kernel/vserver/switch.c
24202 + * Virtual Server: Syscall Switch
24204 + * Copyright (C) 2003-2007 Herbert Pötzl
24206 + * V0.01 syscall switch
24207 + * V0.02 added signal to context
24208 + * V0.03 added rlimit functions
24209 + * V0.04 added iattr, task/xid functions
24210 + * V0.05 added debug/history stuff
24211 + * V0.06 added compat32 layer
24212 + * V0.07 vcmd args and perms
24213 + * V0.08 added status commands
24214 + * V0.09 added tag commands
24215 + * V0.10 added oom bias
24216 + * V0.11 added device commands
24220 +#include <linux/vs_context.h>
24221 +#include <linux/vs_network.h>
24222 +#include <linux/vserver/switch.h>
24224 +#include "vci_config.h"
24228 +int vc_get_version(uint32_t id)
24230 + return VCI_VERSION;
24234 +int vc_get_vci(uint32_t id)
24236 + return vci_kernel_config();
24239 +#include <linux/vserver/context_cmd.h>
24240 +#include <linux/vserver/cvirt_cmd.h>
24241 +#include <linux/vserver/cacct_cmd.h>
24242 +#include <linux/vserver/limit_cmd.h>
24243 +#include <linux/vserver/network_cmd.h>
24244 +#include <linux/vserver/sched_cmd.h>
24245 +#include <linux/vserver/debug_cmd.h>
24246 +#include <linux/vserver/inode_cmd.h>
24247 +#include <linux/vserver/dlimit_cmd.h>
24248 +#include <linux/vserver/signal_cmd.h>
24249 +#include <linux/vserver/space_cmd.h>
24250 +#include <linux/vserver/tag_cmd.h>
24251 +#include <linux/vserver/device_cmd.h>
24253 +#include <linux/vserver/inode.h>
24254 +#include <linux/vserver/dlimit.h>
24257 +#ifdef CONFIG_COMPAT
24258 +#define __COMPAT(name, id, data, compat) \
24259 + (compat) ? name ## _x32(id, data) : name(id, data)
24260 +#define __COMPAT_NO_ID(name, data, compat) \
24261 + (compat) ? name ## _x32(data) : name(data)
24263 +#define __COMPAT(name, id, data, compat) \
24265 +#define __COMPAT_NO_ID(name, data, compat) \
24271 +long do_vcmd(uint32_t cmd, uint32_t id,
24272 + struct vx_info *vxi, struct nx_info *nxi,
24273 + void __user *data, int compat)
24277 + case VCMD_get_version:
24278 + return vc_get_version(id);
24279 + case VCMD_get_vci:
24280 + return vc_get_vci(id);
24282 + case VCMD_task_xid:
24283 + return vc_task_xid(id);
24284 + case VCMD_vx_info:
24285 + return vc_vx_info(vxi, data);
24287 + case VCMD_task_nid:
24288 + return vc_task_nid(id);
24289 + case VCMD_nx_info:
24290 + return vc_nx_info(nxi, data);
24292 + case VCMD_task_tag:
24293 + return vc_task_tag(id);
24295 + /* this is version 1 */
24296 + case VCMD_set_space:
24297 + return vc_set_space(vxi, data);
24299 + case VCMD_get_space_mask_v0:
24300 + return vc_get_space_mask(data, 0);
24301 + /* this is version 1 */
24302 + case VCMD_get_space_mask:
24303 + return vc_get_space_mask(data, 1);
24305 + case VCMD_get_space_default:
24306 + return vc_get_space_mask(data, -1);
24308 +#ifdef CONFIG_IA32_EMULATION
24309 + case VCMD_get_rlimit:
24310 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
24311 + case VCMD_set_rlimit:
24312 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
24314 + case VCMD_get_rlimit:
24315 + return vc_get_rlimit(vxi, data);
24316 + case VCMD_set_rlimit:
24317 + return vc_set_rlimit(vxi, data);
24319 + case VCMD_get_rlimit_mask:
24320 + return vc_get_rlimit_mask(id, data);
24321 + case VCMD_reset_minmax:
24322 + return vc_reset_minmax(vxi, data);
24324 + case VCMD_get_vhi_name:
24325 + return vc_get_vhi_name(vxi, data);
24326 + case VCMD_set_vhi_name:
24327 + return vc_set_vhi_name(vxi, data);
24329 + case VCMD_ctx_stat:
24330 + return vc_ctx_stat(vxi, data);
24331 + case VCMD_virt_stat:
24332 + return vc_virt_stat(vxi, data);
24333 + case VCMD_sock_stat:
24334 + return vc_sock_stat(vxi, data);
24335 + case VCMD_rlimit_stat:
24336 + return vc_rlimit_stat(vxi, data);
24338 + case VCMD_set_cflags:
24339 + return vc_set_cflags(vxi, data);
24340 + case VCMD_get_cflags:
24341 + return vc_get_cflags(vxi, data);
24343 + /* this is version 1 */
24344 + case VCMD_set_ccaps:
24345 + return vc_set_ccaps(vxi, data);
24346 + /* this is version 1 */
24347 + case VCMD_get_ccaps:
24348 + return vc_get_ccaps(vxi, data);
24349 + case VCMD_set_bcaps:
24350 + return vc_set_bcaps(vxi, data);
24351 + case VCMD_get_bcaps:
24352 + return vc_get_bcaps(vxi, data);
24354 + case VCMD_set_badness:
24355 + return vc_set_badness(vxi, data);
24356 + case VCMD_get_badness:
24357 + return vc_get_badness(vxi, data);
24359 + case VCMD_set_nflags:
24360 + return vc_set_nflags(nxi, data);
24361 + case VCMD_get_nflags:
24362 + return vc_get_nflags(nxi, data);
24364 + case VCMD_set_ncaps:
24365 + return vc_set_ncaps(nxi, data);
24366 + case VCMD_get_ncaps:
24367 + return vc_get_ncaps(nxi, data);
24369 + case VCMD_set_sched_v4:
24370 + return vc_set_sched_v4(vxi, data);
24371 + /* this is version 5 */
24372 + case VCMD_set_sched:
24373 + return vc_set_sched(vxi, data);
24374 + case VCMD_get_sched:
24375 + return vc_get_sched(vxi, data);
24376 + case VCMD_sched_info:
24377 + return vc_sched_info(vxi, data);
24379 + case VCMD_add_dlimit:
24380 + return __COMPAT(vc_add_dlimit, id, data, compat);
24381 + case VCMD_rem_dlimit:
24382 + return __COMPAT(vc_rem_dlimit, id, data, compat);
24383 + case VCMD_set_dlimit:
24384 + return __COMPAT(vc_set_dlimit, id, data, compat);
24385 + case VCMD_get_dlimit:
24386 + return __COMPAT(vc_get_dlimit, id, data, compat);
24388 + case VCMD_ctx_kill:
24389 + return vc_ctx_kill(vxi, data);
24391 + case VCMD_wait_exit:
24392 + return vc_wait_exit(vxi, data);
24394 + case VCMD_get_iattr:
24395 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
24396 + case VCMD_set_iattr:
24397 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
24399 + case VCMD_fget_iattr:
24400 + return vc_fget_iattr(id, data);
24401 + case VCMD_fset_iattr:
24402 + return vc_fset_iattr(id, data);
24404 + case VCMD_enter_space_v0:
24405 + return vc_enter_space(vxi, NULL);
24406 + /* this is version 1 */
24407 + case VCMD_enter_space:
24408 + return vc_enter_space(vxi, data);
24410 + case VCMD_ctx_create_v0:
24411 + return vc_ctx_create(id, NULL);
24412 + case VCMD_ctx_create:
24413 + return vc_ctx_create(id, data);
24414 + case VCMD_ctx_migrate_v0:
24415 + return vc_ctx_migrate(vxi, NULL);
24416 + case VCMD_ctx_migrate:
24417 + return vc_ctx_migrate(vxi, data);
24419 + case VCMD_net_create_v0:
24420 + return vc_net_create(id, NULL);
24421 + case VCMD_net_create:
24422 + return vc_net_create(id, data);
24423 + case VCMD_net_migrate:
24424 + return vc_net_migrate(nxi, data);
24426 + case VCMD_tag_migrate:
24427 + return vc_tag_migrate(id);
24429 + case VCMD_net_add:
24430 + return vc_net_add(nxi, data);
24431 + case VCMD_net_remove:
24432 + return vc_net_remove(nxi, data);
24434 + case VCMD_net_add_ipv4:
24435 + return vc_net_add_ipv4(nxi, data);
24436 + case VCMD_net_remove_ipv4:
24437 + return vc_net_remove_ipv4(nxi, data);
24438 +#ifdef CONFIG_IPV6
24439 + case VCMD_net_add_ipv6:
24440 + return vc_net_add_ipv6(nxi, data);
24441 + case VCMD_net_remove_ipv6:
24442 + return vc_net_remove_ipv6(nxi, data);
24444 +/* case VCMD_add_match_ipv4:
24445 + return vc_add_match_ipv4(nxi, data);
24446 + case VCMD_get_match_ipv4:
24447 + return vc_get_match_ipv4(nxi, data);
24448 +#ifdef CONFIG_IPV6
24449 + case VCMD_add_match_ipv6:
24450 + return vc_add_match_ipv6(nxi, data);
24451 + case VCMD_get_match_ipv6:
24452 + return vc_get_match_ipv6(nxi, data);
24455 +#ifdef CONFIG_VSERVER_DEVICE
24456 + case VCMD_set_mapping:
24457 + return __COMPAT(vc_set_mapping, vxi, data, compat);
24458 + case VCMD_unset_mapping:
24459 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
24461 +#ifdef CONFIG_VSERVER_HISTORY
24462 + case VCMD_dump_history:
24463 + return vc_dump_history(id);
24464 + case VCMD_read_history:
24465 + return __COMPAT(vc_read_history, id, data, compat);
24467 +#ifdef CONFIG_VSERVER_MONITOR
24468 + case VCMD_read_monitor:
24469 + return __COMPAT(vc_read_monitor, id, data, compat);
24472 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
24473 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
24479 +#define __VCMD(vcmd, _perm, _args, _flags) \
24480 + case VCMD_ ## vcmd: perm = _perm; \
24481 + args = _args; flags = _flags; break
24484 +#define VCA_NONE 0x00
24485 +#define VCA_VXI 0x01
24486 +#define VCA_NXI 0x02
24488 +#define VCF_NONE 0x00
24489 +#define VCF_INFO 0x01
24490 +#define VCF_ADMIN 0x02
24491 +#define VCF_ARES 0x06 /* includes admin */
24492 +#define VCF_SETUP 0x08
24494 +#define VCF_ZIDOK 0x10 /* zero id okay */
24498 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
24501 + int permit = -1, state = 0;
24502 + int perm = -1, args = 0, flags = 0;
24503 + struct vx_info *vxi = NULL;
24504 + struct nx_info *nxi = NULL;
24507 + /* unpriviledged commands */
24508 + __VCMD(get_version, 0, VCA_NONE, 0);
24509 + __VCMD(get_vci, 0, VCA_NONE, 0);
24510 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
24511 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
24512 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
24513 + __VCMD(get_space_default,0, VCA_NONE, 0);
24515 + /* info commands */
24516 + __VCMD(task_xid, 2, VCA_NONE, 0);
24517 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
24518 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
24519 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
24520 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
24521 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
24522 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
24523 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
24524 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
24526 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
24527 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
24528 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
24529 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
24531 + __VCMD(task_nid, 2, VCA_NONE, 0);
24532 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
24533 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
24534 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
24536 + __VCMD(task_tag, 2, VCA_NONE, 0);
24538 + __VCMD(get_iattr, 2, VCA_NONE, 0);
24539 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
24540 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
24541 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
24542 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
24544 + /* lower admin commands */
24545 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
24546 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
24547 + __VCMD(ctx_create, 5, VCA_NONE, 0);
24548 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
24549 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
24550 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
24551 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
24553 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
24554 + __VCMD(net_create, 5, VCA_NONE, 0);
24555 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
24557 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
24559 + /* higher admin commands */
24560 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
24561 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24563 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24564 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24565 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24566 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24568 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24569 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24570 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24571 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24573 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
24574 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
24575 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24576 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24577 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24578 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24579 +#ifdef CONFIG_IPV6
24580 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24581 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24583 + __VCMD(set_iattr, 7, VCA_NONE, 0);
24584 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
24585 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
24586 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
24587 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
24589 +#ifdef CONFIG_VSERVER_DEVICE
24590 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
24591 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
24593 + /* debug level admin commands */
24594 +#ifdef CONFIG_VSERVER_HISTORY
24595 + __VCMD(dump_history, 9, VCA_NONE, 0);
24596 + __VCMD(read_history, 9, VCA_NONE, 0);
24598 +#ifdef CONFIG_VSERVER_MONITOR
24599 + __VCMD(read_monitor, 9, VCA_NONE, 0);
24606 + vxdprintk(VXD_CBIT(switch, 0),
24607 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
24608 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
24609 + VC_VERSION(cmd), id, data, compat,
24610 + perm, args, flags);
24617 + if (!capable(CAP_CONTEXT))
24621 + /* moved here from the individual commands */
24623 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
24627 + /* vcmd involves resource management */
24629 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
24633 + /* various legacy exceptions */
24635 + /* will go away when spectator is a cap */
24636 + case VCMD_ctx_migrate_v0:
24637 + case VCMD_ctx_migrate:
24639 + current->xid = 1;
24645 + /* will go away when spectator is a cap */
24646 + case VCMD_net_migrate:
24648 + current->nid = 1;
24655 + /* vcmds are fine by default */
24658 + /* admin type vcmds require admin ... */
24659 + if (flags & VCF_ADMIN)
24660 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
24662 + /* ... but setup type vcmds override that */
24663 + if (!permit && (flags & VCF_SETUP))
24664 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
24672 + if (!id && (flags & VCF_ZIDOK))
24676 + if (args & VCA_VXI) {
24677 + vxi = lookup_vx_info(id);
24681 + if ((flags & VCF_ADMIN) &&
24682 + /* special case kill for shutdown */
24683 + (cmd != VCMD_ctx_kill) &&
24684 + /* can context be administrated? */
24685 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
24691 + if (args & VCA_NXI) {
24692 + nxi = lookup_nx_info(id);
24696 + if ((flags & VCF_ADMIN) &&
24697 + /* can context be administrated? */
24698 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
24705 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
24708 + if ((args & VCA_NXI) && nxi)
24709 + put_nx_info(nxi);
24711 + if ((args & VCA_VXI) && vxi)
24712 + put_vx_info(vxi);
24714 + vxdprintk(VXD_CBIT(switch, 1),
24715 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
24716 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
24717 + VC_VERSION(cmd), ret, ret, state, permit);
24722 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
24724 + return do_vserver(cmd, id, data, 0);
24727 +#ifdef CONFIG_COMPAT
24730 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
24732 + return do_vserver(cmd, id, data, 1);
24735 +#endif /* CONFIG_COMPAT */
24736 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/sysctl.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/sysctl.c
24737 --- linux-2.6.27.3/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
24738 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/sysctl.c 2008-10-13 14:54:20.000000000 +0200
24741 + * kernel/vserver/sysctl.c
24743 + * Virtual Context Support
24745 + * Copyright (C) 2004-2007 Herbert Pötzl
24747 + * V0.01 basic structure
24751 +#include <linux/module.h>
24752 +#include <linux/ctype.h>
24753 +#include <linux/sysctl.h>
24754 +#include <linux/parser.h>
24755 +#include <asm/uaccess.h>
24759 + CTL_DEBUG_ERROR = 0,
24760 + CTL_DEBUG_SWITCH = 1,
24775 +unsigned int vx_debug_switch = 0;
24776 +unsigned int vx_debug_xid = 0;
24777 +unsigned int vx_debug_nid = 0;
24778 +unsigned int vx_debug_tag = 0;
24779 +unsigned int vx_debug_net = 0;
24780 +unsigned int vx_debug_limit = 0;
24781 +unsigned int vx_debug_cres = 0;
24782 +unsigned int vx_debug_dlim = 0;
24783 +unsigned int vx_debug_quota = 0;
24784 +unsigned int vx_debug_cvirt = 0;
24785 +unsigned int vx_debug_space = 0;
24786 +unsigned int vx_debug_misc = 0;
24789 +static struct ctl_table_header *vserver_table_header;
24790 +static ctl_table vserver_root_table[];
24793 +void vserver_register_sysctl(void)
24795 + if (!vserver_table_header) {
24796 + vserver_table_header = register_sysctl_table(vserver_root_table);
24801 +void vserver_unregister_sysctl(void)
24803 + if (vserver_table_header) {
24804 + unregister_sysctl_table(vserver_table_header);
24805 + vserver_table_header = NULL;
24810 +static int proc_dodebug(ctl_table *table, int write,
24811 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
24813 + char tmpbuf[20], *p, c;
24814 + unsigned int value;
24815 + size_t left, len;
24817 + if ((*ppos && !write) || !*lenp) {
24825 + if (!access_ok(VERIFY_READ, buffer, left))
24827 + p = (char *)buffer;
24828 + while (left && __get_user(c, p) >= 0 && isspace(c))
24833 + if (left > sizeof(tmpbuf) - 1)
24835 + if (copy_from_user(tmpbuf, p, left))
24837 + tmpbuf[left] = '\0';
24839 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
24840 + value = 10 * value + (*p - '0');
24841 + if (*p && !isspace(*p))
24843 + while (left && isspace(*p))
24845 + *(unsigned int *)table->data = value;
24847 + if (!access_ok(VERIFY_WRITE, buffer, left))
24849 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
24852 + if (__copy_to_user(buffer, tmpbuf, len))
24854 + if ((left -= len) > 0) {
24855 + if (put_user('\n', (char *)buffer + len))
24869 +#define CTL_ENTRY(ctl, name) \
24871 + .ctl_name = ctl, \
24872 + .procname = #name, \
24873 + .data = &vx_ ## name, \
24874 + .maxlen = sizeof(int), \
24876 + .proc_handler = &proc_dodebug, \
24877 + .strategy = &sysctl_intvec, \
24878 + .extra1 = &zero, \
24881 +static ctl_table vserver_debug_table[] = {
24882 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
24883 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
24884 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
24885 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
24886 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
24887 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
24888 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
24889 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
24890 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
24891 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
24892 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
24893 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
24894 + { .ctl_name = 0 }
24897 +static ctl_table vserver_root_table[] = {
24899 + .ctl_name = CTL_VSERVER,
24900 + .procname = "vserver",
24902 + .child = vserver_debug_table
24904 + { .ctl_name = 0 }
24908 +static match_table_t tokens = {
24909 + { CTL_DEBUG_SWITCH, "switch=%x" },
24910 + { CTL_DEBUG_XID, "xid=%x" },
24911 + { CTL_DEBUG_NID, "nid=%x" },
24912 + { CTL_DEBUG_TAG, "tag=%x" },
24913 + { CTL_DEBUG_NET, "net=%x" },
24914 + { CTL_DEBUG_LIMIT, "limit=%x" },
24915 + { CTL_DEBUG_CRES, "cres=%x" },
24916 + { CTL_DEBUG_DLIM, "dlim=%x" },
24917 + { CTL_DEBUG_QUOTA, "quota=%x" },
24918 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
24919 + { CTL_DEBUG_SPACE, "space=%x" },
24920 + { CTL_DEBUG_MISC, "misc=%x" },
24921 + { CTL_DEBUG_ERROR, NULL }
24924 +#define HANDLE_CASE(id, name, val) \
24925 + case CTL_DEBUG_ ## id: \
24926 + vx_debug_ ## name = val; \
24927 + printk("vs_debug_" #name "=0x%x\n", val); \
24931 +static int __init vs_debug_setup(char *str)
24936 + printk("vs_debug_setup(%s)\n", str);
24937 + while ((p = strsep(&str, ",")) != NULL) {
24938 + substring_t args[MAX_OPT_ARGS];
24939 + unsigned int value;
24944 + token = match_token(p, tokens, args);
24945 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
24948 + HANDLE_CASE(SWITCH, switch, value);
24949 + HANDLE_CASE(XID, xid, value);
24950 + HANDLE_CASE(NID, nid, value);
24951 + HANDLE_CASE(TAG, tag, value);
24952 + HANDLE_CASE(NET, net, value);
24953 + HANDLE_CASE(LIMIT, limit, value);
24954 + HANDLE_CASE(CRES, cres, value);
24955 + HANDLE_CASE(DLIM, dlim, value);
24956 + HANDLE_CASE(QUOTA, quota, value);
24957 + HANDLE_CASE(CVIRT, cvirt, value);
24958 + HANDLE_CASE(SPACE, space, value);
24959 + HANDLE_CASE(MISC, misc, value);
24968 +__setup("vsdebug=", vs_debug_setup);
24972 +EXPORT_SYMBOL_GPL(vx_debug_switch);
24973 +EXPORT_SYMBOL_GPL(vx_debug_xid);
24974 +EXPORT_SYMBOL_GPL(vx_debug_nid);
24975 +EXPORT_SYMBOL_GPL(vx_debug_net);
24976 +EXPORT_SYMBOL_GPL(vx_debug_limit);
24977 +EXPORT_SYMBOL_GPL(vx_debug_cres);
24978 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
24979 +EXPORT_SYMBOL_GPL(vx_debug_quota);
24980 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
24981 +EXPORT_SYMBOL_GPL(vx_debug_space);
24982 +EXPORT_SYMBOL_GPL(vx_debug_misc);
24984 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/tag.c linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/tag.c
24985 --- linux-2.6.27.3/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24986 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/tag.c 2008-10-13 14:54:20.000000000 +0200
24989 + * linux/kernel/vserver/tag.c
24991 + * Virtual Server: Shallow Tag Space
24993 + * Copyright (C) 2007 Herbert Pötzl
24995 + * V0.01 basic implementation
24999 +#include <linux/sched.h>
25000 +#include <linux/vserver/debug.h>
25001 +#include <linux/vs_pid.h>
25002 +#include <linux/vs_tag.h>
25004 +#include <linux/vserver/tag_cmd.h>
25007 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25012 + vxdprintk(VXD_CBIT(tag, 5),
25013 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25019 + vxdprintk(VXD_CBIT(tag, 5),
25020 + "moved task %p into [#%d]", p, tag);
25024 +/* vserver syscall commands below here */
25026 +/* taks xid and vx_info functions */
25029 +int vc_task_tag(uint32_t id)
25034 + struct task_struct *tsk;
25035 + read_lock(&tasklist_lock);
25036 + tsk = find_task_by_real_pid(id);
25037 + tag = (tsk) ? tsk->tag : -ESRCH;
25038 + read_unlock(&tasklist_lock);
25040 + tag = dx_current_tag();
25045 +int vc_tag_migrate(uint32_t tag)
25047 + return dx_migrate_task(current, tag & 0xFFFF);
25051 diff -NurpP --minimal linux-2.6.27.3/kernel/vserver/vci_config.h linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/vci_config.h
25052 --- linux-2.6.27.3/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
25053 +++ linux-2.6.27.3-vs2.3.0.35.7/kernel/vserver/vci_config.h 2008-10-13 14:54:20.000000000 +0200
25056 +/* interface version */
25058 +#define VCI_VERSION 0x00020303
25062 + VCI_KCBIT_NO_DYNAMIC = 0,
25064 + VCI_KCBIT_PROC_SECURE = 4,
25065 + VCI_KCBIT_HARDCPU = 5,
25066 + VCI_KCBIT_IDLELIMIT = 6,
25067 + VCI_KCBIT_IDLETIME = 7,
25069 + VCI_KCBIT_COWBL = 8,
25070 + VCI_KCBIT_FULLCOWBL = 9,
25071 + VCI_KCBIT_SPACES = 10,
25072 + VCI_KCBIT_NETV2 = 11,
25074 + VCI_KCBIT_DEBUG = 16,
25075 + VCI_KCBIT_HISTORY = 20,
25076 + VCI_KCBIT_TAGGED = 24,
25077 + VCI_KCBIT_PPTAG = 28,
25079 + VCI_KCBIT_MORE = 31,
25083 +static inline uint32_t vci_kernel_config(void)
25086 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25088 + /* configured features */
25089 +#ifdef CONFIG_VSERVER_PROC_SECURE
25090 + (1 << VCI_KCBIT_PROC_SECURE) |
25092 +#ifdef CONFIG_VSERVER_HARDCPU
25093 + (1 << VCI_KCBIT_HARDCPU) |
25095 +#ifdef CONFIG_VSERVER_IDLELIMIT
25096 + (1 << VCI_KCBIT_IDLELIMIT) |
25098 +#ifdef CONFIG_VSERVER_IDLETIME
25099 + (1 << VCI_KCBIT_IDLETIME) |
25101 +#ifdef CONFIG_VSERVER_COWBL
25102 + (1 << VCI_KCBIT_COWBL) |
25103 + (1 << VCI_KCBIT_FULLCOWBL) |
25105 + (1 << VCI_KCBIT_SPACES) |
25106 + (1 << VCI_KCBIT_NETV2) |
25108 + /* debug options */
25109 +#ifdef CONFIG_VSERVER_DEBUG
25110 + (1 << VCI_KCBIT_DEBUG) |
25112 +#ifdef CONFIG_VSERVER_HISTORY
25113 + (1 << VCI_KCBIT_HISTORY) |
25116 + /* inode context tagging */
25117 +#if defined(CONFIG_TAGGING_NONE)
25118 + (0 << VCI_KCBIT_TAGGED) |
25119 +#elif defined(CONFIG_TAGGING_UID16)
25120 + (1 << VCI_KCBIT_TAGGED) |
25121 +#elif defined(CONFIG_TAGGING_GID16)
25122 + (2 << VCI_KCBIT_TAGGED) |
25123 +#elif defined(CONFIG_TAGGING_ID24)
25124 + (3 << VCI_KCBIT_TAGGED) |
25125 +#elif defined(CONFIG_TAGGING_INTERN)
25126 + (4 << VCI_KCBIT_TAGGED) |
25127 +#elif defined(CONFIG_TAGGING_RUNTIME)
25128 + (5 << VCI_KCBIT_TAGGED) |
25130 + (7 << VCI_KCBIT_TAGGED) |
25132 + (1 << VCI_KCBIT_PPTAG) |
25136 diff -NurpP --minimal linux-2.6.27.3/mm/filemap_xip.c linux-2.6.27.3-vs2.3.0.35.7/mm/filemap_xip.c
25137 --- linux-2.6.27.3/mm/filemap_xip.c 2008-10-13 14:52:09.000000000 +0200
25138 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/filemap_xip.c 2008-10-13 14:54:20.000000000 +0200
25140 #include <linux/sched.h>
25141 #include <linux/seqlock.h>
25142 #include <linux/mutex.h>
25143 +#include <linux/vs_memory.h>
25144 #include <asm/tlbflush.h>
25145 #include <asm/io.h>
25147 diff -NurpP --minimal linux-2.6.27.3/mm/fremap.c linux-2.6.27.3-vs2.3.0.35.7/mm/fremap.c
25148 --- linux-2.6.27.3/mm/fremap.c 2008-10-13 14:52:09.000000000 +0200
25149 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/fremap.c 2008-10-13 14:54:20.000000000 +0200
25151 #include <linux/module.h>
25152 #include <linux/syscalls.h>
25153 #include <linux/mmu_notifier.h>
25154 +#include <linux/vs_memory.h>
25156 #include <asm/mmu_context.h>
25157 #include <asm/cacheflush.h>
25158 diff -NurpP --minimal linux-2.6.27.3/mm/hugetlb.c linux-2.6.27.3-vs2.3.0.35.7/mm/hugetlb.c
25159 --- linux-2.6.27.3/mm/hugetlb.c 2008-10-13 14:52:09.000000000 +0200
25160 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/hugetlb.c 2008-10-13 14:54:20.000000000 +0200
25162 #include <asm/io.h>
25164 #include <linux/hugetlb.h>
25165 +#include <linux/vs_memory.h>
25166 #include "internal.h"
25168 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
25169 diff -NurpP --minimal linux-2.6.27.3/mm/memory.c linux-2.6.27.3-vs2.3.0.35.7/mm/memory.c
25170 --- linux-2.6.27.3/mm/memory.c 2008-10-13 14:52:09.000000000 +0200
25171 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/memory.c 2008-10-13 14:54:20.000000000 +0200
25172 @@ -562,6 +562,9 @@ static int copy_pte_range(struct mm_stru
25176 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
25180 rss[1] = rss[0] = 0;
25181 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
25182 @@ -2294,6 +2297,11 @@ static int do_swap_page(struct mm_struct
25186 + if (!vx_rss_avail(mm, 1)) {
25187 + ret = VM_FAULT_OOM;
25191 mark_page_accessed(page);
25193 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
25194 @@ -2365,6 +2373,8 @@ static int do_anonymous_page(struct mm_s
25195 /* Allocate our own private page. */
25196 pte_unmap(page_table);
25198 + if (!vx_rss_avail(mm, 1))
25200 if (unlikely(anon_vma_prepare(vma)))
25202 page = alloc_zeroed_user_highpage_movable(vma, address);
25203 @@ -2626,6 +2636,7 @@ static inline int handle_pte_fault(struc
25207 + int ret = 0, type = VXPT_UNKNOWN;
25210 if (!pte_present(entry)) {
25211 @@ -2650,9 +2661,12 @@ static inline int handle_pte_fault(struc
25212 if (unlikely(!pte_same(*pte, entry)))
25214 if (write_access) {
25215 - if (!pte_write(entry))
25216 - return do_wp_page(mm, vma, address,
25217 + if (!pte_write(entry)) {
25218 + ret = do_wp_page(mm, vma, address,
25219 pte, pmd, ptl, entry);
25220 + type = VXPT_WRITE;
25223 entry = pte_mkdirty(entry);
25225 entry = pte_mkyoung(entry);
25226 @@ -2670,7 +2684,10 @@ static inline int handle_pte_fault(struc
25229 pte_unmap_unlock(pte, ptl);
25233 + vx_page_fault(mm, vma, type, ret);
25238 diff -NurpP --minimal linux-2.6.27.3/mm/mlock.c linux-2.6.27.3-vs2.3.0.35.7/mm/mlock.c
25239 --- linux-2.6.27.3/mm/mlock.c 2008-10-13 14:52:09.000000000 +0200
25240 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/mlock.c 2008-10-13 14:54:20.000000000 +0200
25242 #include <linux/syscalls.h>
25243 #include <linux/sched.h>
25244 #include <linux/module.h>
25245 +#include <linux/vs_memory.h>
25247 int can_do_mlock(void)
25249 @@ -76,7 +77,7 @@ success:
25250 ret = make_pages_present(start, end);
25253 - mm->locked_vm -= pages;
25254 + vx_vmlocked_sub(mm, pages);
25258 @@ -132,7 +133,7 @@ static int do_mlock(unsigned long start,
25260 asmlinkage long sys_mlock(unsigned long start, size_t len)
25262 - unsigned long locked;
25263 + unsigned long locked, grow;
25264 unsigned long lock_limit;
25265 int error = -ENOMEM;
25267 @@ -143,8 +144,10 @@ asmlinkage long sys_mlock(unsigned long
25268 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
25269 start &= PAGE_MASK;
25271 - locked = len >> PAGE_SHIFT;
25272 - locked += current->mm->locked_vm;
25273 + grow = len >> PAGE_SHIFT;
25274 + if (!vx_vmlocked_avail(current->mm, grow))
25276 + locked = current->mm->locked_vm + grow;
25278 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
25279 lock_limit >>= PAGE_SHIFT;
25280 @@ -152,6 +155,7 @@ asmlinkage long sys_mlock(unsigned long
25281 /* check against resource limits */
25282 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
25283 error = do_mlock(start, len, 1);
25285 up_write(¤t->mm->mmap_sem);
25288 @@ -211,6 +215,8 @@ asmlinkage long sys_mlockall(int flags)
25289 lock_limit >>= PAGE_SHIFT;
25292 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
25294 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
25295 capable(CAP_IPC_LOCK))
25296 ret = do_mlockall(flags);
25297 diff -NurpP --minimal linux-2.6.27.3/mm/mmap.c linux-2.6.27.3-vs2.3.0.35.7/mm/mmap.c
25298 --- linux-2.6.27.3/mm/mmap.c 2008-10-13 14:52:09.000000000 +0200
25299 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/mmap.c 2008-10-13 14:54:20.000000000 +0200
25300 @@ -1221,10 +1221,10 @@ munmap_back:
25301 if (correct_wcount)
25302 atomic_inc(&inode->i_writecount);
25304 - mm->total_vm += len >> PAGE_SHIFT;
25305 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25306 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
25307 if (vm_flags & VM_LOCKED) {
25308 - mm->locked_vm += len >> PAGE_SHIFT;
25309 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
25310 make_pages_present(addr, addr + len);
25312 if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
25313 @@ -1573,9 +1573,9 @@ static int acct_stack_growth(struct vm_a
25316 /* Ok, everything looks good - let it rip */
25317 - mm->total_vm += grow;
25318 + vx_vmpages_add(mm, grow);
25319 if (vma->vm_flags & VM_LOCKED)
25320 - mm->locked_vm += grow;
25321 + vx_vmlocked_add(mm, grow);
25322 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
25325 @@ -1746,9 +1746,9 @@ static void remove_vma_list(struct mm_st
25327 long nrpages = vma_pages(vma);
25329 - mm->total_vm -= nrpages;
25330 + vx_vmpages_sub(mm, nrpages);
25331 if (vma->vm_flags & VM_LOCKED)
25332 - mm->locked_vm -= nrpages;
25333 + vx_vmlocked_sub(mm, nrpages);
25334 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
25335 vma = remove_vma(vma);
25337 @@ -1995,6 +1995,8 @@ unsigned long do_brk(unsigned long addr,
25338 lock_limit >>= PAGE_SHIFT;
25339 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
25341 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
25346 @@ -2021,7 +2023,8 @@ unsigned long do_brk(unsigned long addr,
25347 if (mm->map_count > sysctl_max_map_count)
25350 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
25351 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
25352 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
25355 /* Can we just expand an old private anonymous mapping? */
25356 @@ -2046,9 +2049,9 @@ unsigned long do_brk(unsigned long addr,
25357 vma->vm_page_prot = vm_get_page_prot(flags);
25358 vma_link(mm, vma, prev, rb_link, rb_parent);
25360 - mm->total_vm += len >> PAGE_SHIFT;
25361 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25362 if (flags & VM_LOCKED) {
25363 - mm->locked_vm += len >> PAGE_SHIFT;
25364 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
25365 make_pages_present(addr, addr + len);
25368 @@ -2078,6 +2081,11 @@ void exit_mmap(struct mm_struct *mm)
25369 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
25370 tlb_finish_mmu(tlb, 0, end);
25372 + set_mm_counter(mm, file_rss, 0);
25373 + set_mm_counter(mm, anon_rss, 0);
25374 + vx_vmpages_sub(mm, mm->total_vm);
25375 + vx_vmlocked_sub(mm, mm->locked_vm);
25378 * Walk the list again, actually closing and freeing it,
25379 * with preemption enabled, without holding any MM locks.
25380 @@ -2117,7 +2125,8 @@ int insert_vm_struct(struct mm_struct *
25381 if (__vma && __vma->vm_start < vma->vm_end)
25383 if ((vma->vm_flags & VM_ACCOUNT) &&
25384 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
25385 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
25386 + !vx_vmpages_avail(mm, vma_pages(vma))))
25388 vma_link(mm, vma, prev, rb_link, rb_parent);
25390 @@ -2193,6 +2202,8 @@ int may_expand_vm(struct mm_struct *mm,
25392 if (cur + npages > lim)
25394 + if (!vx_vmpages_avail(mm, npages))
25399 @@ -2270,8 +2281,7 @@ int install_special_mapping(struct mm_st
25403 - mm->total_vm += len >> PAGE_SHIFT;
25405 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25409 diff -NurpP --minimal linux-2.6.27.3/mm/mremap.c linux-2.6.27.3-vs2.3.0.35.7/mm/mremap.c
25410 --- linux-2.6.27.3/mm/mremap.c 2008-10-13 14:52:09.000000000 +0200
25411 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/mremap.c 2008-10-13 14:54:20.000000000 +0200
25413 #include <linux/security.h>
25414 #include <linux/syscalls.h>
25415 #include <linux/mmu_notifier.h>
25416 +#include <linux/vs_memory.h>
25418 #include <asm/uaccess.h>
25419 #include <asm/cacheflush.h>
25420 @@ -218,7 +219,7 @@ static unsigned long move_vma(struct vm_
25421 * If this were a serious issue, we'd add a flag to do_munmap().
25423 hiwater_vm = mm->hiwater_vm;
25424 - mm->total_vm += new_len >> PAGE_SHIFT;
25425 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
25426 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
25428 if (do_munmap(mm, old_addr, old_len) < 0) {
25429 @@ -236,7 +237,7 @@ static unsigned long move_vma(struct vm_
25432 if (vm_flags & VM_LOCKED) {
25433 - mm->locked_vm += new_len >> PAGE_SHIFT;
25434 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
25435 if (new_len > old_len)
25436 make_pages_present(new_addr + old_len,
25437 new_addr + new_len);
25438 @@ -347,6 +348,9 @@ unsigned long do_mremap(unsigned long ad
25440 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
25442 + if (!vx_vmlocked_avail(current->mm,
25443 + (new_len - old_len) >> PAGE_SHIFT))
25446 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
25448 @@ -375,10 +379,10 @@ unsigned long do_mremap(unsigned long ad
25449 vma_adjust(vma, vma->vm_start,
25450 addr + new_len, vma->vm_pgoff, NULL);
25452 - mm->total_vm += pages;
25453 + vx_vmpages_add(mm, pages);
25454 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
25455 if (vma->vm_flags & VM_LOCKED) {
25456 - mm->locked_vm += pages;
25457 + vx_vmlocked_add(mm, pages);
25458 make_pages_present(addr + old_len,
25461 diff -NurpP --minimal linux-2.6.27.3/mm/nommu.c linux-2.6.27.3-vs2.3.0.35.7/mm/nommu.c
25462 --- linux-2.6.27.3/mm/nommu.c 2008-10-13 14:52:09.000000000 +0200
25463 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/nommu.c 2008-10-13 14:54:20.000000000 +0200
25464 @@ -1028,7 +1028,7 @@ unsigned long do_mmap_pgoff(struct file
25465 realalloc += kobjsize(vma);
25466 askedalloc += sizeof(*vma);
25468 - current->mm->total_vm += len >> PAGE_SHIFT;
25469 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
25471 add_nommu_vma(vma);
25473 @@ -1160,7 +1160,7 @@ int do_munmap(struct mm_struct *mm, unsi
25476 update_hiwater_vm(mm);
25477 - mm->total_vm -= len >> PAGE_SHIFT;
25478 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
25481 show_process_blocks();
25482 @@ -1193,7 +1193,7 @@ void exit_mmap(struct mm_struct * mm)
25483 printk("Exit_mmap:\n");
25486 - mm->total_vm = 0;
25487 + vx_vmpages_sub(mm, mm->total_vm);
25489 while ((tmp = mm->context.vmlist)) {
25490 mm->context.vmlist = tmp->next;
25491 diff -NurpP --minimal linux-2.6.27.3/mm/oom_kill.c linux-2.6.27.3-vs2.3.0.35.7/mm/oom_kill.c
25492 --- linux-2.6.27.3/mm/oom_kill.c 2008-10-13 14:52:09.000000000 +0200
25493 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/oom_kill.c 2008-10-13 14:54:20.000000000 +0200
25495 #include <linux/notifier.h>
25496 #include <linux/memcontrol.h>
25497 #include <linux/security.h>
25498 +#include <linux/vs_memory.h>
25500 int sysctl_panic_on_oom;
25501 int sysctl_oom_kill_allocating_task;
25502 @@ -73,6 +74,12 @@ unsigned long badness(struct task_struct
25503 points = mm->total_vm;
25506 + * add points for context badness
25509 + points += vx_badness(p, mm);
25512 * After this unlock we can no longer dereference local variable `mm'
25515 @@ -163,8 +170,8 @@ unsigned long badness(struct task_struct
25519 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
25520 - p->pid, p->comm, points);
25521 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
25522 + task_pid_nr(p), p->xid, p->comm, points);
25526 @@ -325,8 +332,8 @@ static void __oom_kill_task(struct task_
25530 - printk(KERN_ERR "Killed process %d (%s)\n",
25531 - task_pid_nr(p), p->comm);
25532 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
25533 + task_pid_nr(p), p->xid, p->comm);
25536 * We give our sacrificial lamb high priority and access to
25537 @@ -406,8 +413,8 @@ static int oom_kill_process(struct task_
25541 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
25542 - message, task_pid_nr(p), p->comm, points);
25543 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
25544 + message, task_pid_nr(p), p->xid, p->comm, points);
25546 /* Try to kill a child first */
25547 list_for_each_entry(c, &p->children, sibling) {
25548 diff -NurpP --minimal linux-2.6.27.3/mm/page_alloc.c linux-2.6.27.3-vs2.3.0.35.7/mm/page_alloc.c
25549 --- linux-2.6.27.3/mm/page_alloc.c 2008-10-13 14:52:09.000000000 +0200
25550 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/page_alloc.c 2008-10-13 14:54:20.000000000 +0200
25552 #include <linux/page-isolation.h>
25553 #include <linux/memcontrol.h>
25554 #include <linux/debugobjects.h>
25555 +#include <linux/vs_base.h>
25556 +#include <linux/vs_limit.h>
25558 #include <asm/tlbflush.h>
25559 #include <asm/div64.h>
25560 @@ -1809,6 +1811,9 @@ void si_meminfo(struct sysinfo *val)
25561 val->totalhigh = totalhigh_pages;
25562 val->freehigh = nr_free_highpages();
25563 val->mem_unit = PAGE_SIZE;
25565 + if (vx_flags(VXF_VIRT_MEM, 0))
25566 + vx_vsi_meminfo(val);
25569 EXPORT_SYMBOL(si_meminfo);
25570 @@ -1829,6 +1834,9 @@ void si_meminfo_node(struct sysinfo *val
25573 val->mem_unit = PAGE_SIZE;
25575 + if (vx_flags(VXF_VIRT_MEM, 0))
25576 + vx_vsi_meminfo(val);
25580 diff -NurpP --minimal linux-2.6.27.3/mm/rmap.c linux-2.6.27.3-vs2.3.0.35.7/mm/rmap.c
25581 --- linux-2.6.27.3/mm/rmap.c 2008-10-13 14:52:09.000000000 +0200
25582 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/rmap.c 2008-10-13 14:54:20.000000000 +0200
25584 #include <linux/kallsyms.h>
25585 #include <linux/memcontrol.h>
25586 #include <linux/mmu_notifier.h>
25587 +#include <linux/vs_memory.h>
25589 #include <asm/tlbflush.h>
25591 diff -NurpP --minimal linux-2.6.27.3/mm/shmem.c linux-2.6.27.3-vs2.3.0.35.7/mm/shmem.c
25592 --- linux-2.6.27.3/mm/shmem.c 2008-10-13 14:52:09.000000000 +0200
25593 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/shmem.c 2008-10-13 14:54:20.000000000 +0200
25595 #include <asm/pgtable.h>
25597 /* This magic number is used in glibc for posix shared memory */
25598 -#define TMPFS_MAGIC 0x01021994
25600 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
25601 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
25602 @@ -1738,7 +1737,7 @@ static int shmem_statfs(struct dentry *d
25604 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
25606 - buf->f_type = TMPFS_MAGIC;
25607 + buf->f_type = TMPFS_SUPER_MAGIC;
25608 buf->f_bsize = PAGE_CACHE_SIZE;
25609 buf->f_namelen = NAME_MAX;
25610 spin_lock(&sbinfo->stat_lock);
25611 @@ -2306,7 +2305,7 @@ static int shmem_fill_super(struct super
25612 sb->s_maxbytes = SHMEM_MAX_BYTES;
25613 sb->s_blocksize = PAGE_CACHE_SIZE;
25614 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
25615 - sb->s_magic = TMPFS_MAGIC;
25616 + sb->s_magic = TMPFS_SUPER_MAGIC;
25617 sb->s_op = &shmem_ops;
25618 sb->s_time_gran = 1;
25619 #ifdef CONFIG_TMPFS_POSIX_ACL
25620 diff -NurpP --minimal linux-2.6.27.3/mm/slab.c linux-2.6.27.3-vs2.3.0.35.7/mm/slab.c
25621 --- linux-2.6.27.3/mm/slab.c 2008-10-13 14:52:09.000000000 +0200
25622 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/slab.c 2008-10-13 14:54:20.000000000 +0200
25623 @@ -508,6 +508,8 @@ struct kmem_cache {
25624 #define STATS_INC_FREEMISS(x) do { } while (0)
25627 +#include "slab_vs.h"
25632 @@ -3337,6 +3339,7 @@ retry:
25634 obj = slab_get_obj(cachep, slabp, nodeid);
25635 check_slabp(cachep, slabp);
25636 + vx_slab_alloc(cachep, flags);
25637 l3->free_objects--;
25638 /* move slabp to correct slabp list: */
25639 list_del(&slabp->list);
25640 @@ -3409,6 +3412,7 @@ __cache_alloc_node(struct kmem_cache *ca
25641 /* ___cache_alloc_node can fall back to other nodes */
25642 ptr = ____cache_alloc_node(cachep, flags, nodeid);
25644 + vx_slab_alloc(cachep, flags);
25645 local_irq_restore(save_flags);
25646 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
25648 @@ -3580,6 +3584,7 @@ static inline void __cache_free(struct k
25651 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
25652 + vx_slab_free(cachep);
25655 * Skip calling cache_free_alien() when the platform is not numa.
25656 diff -NurpP --minimal linux-2.6.27.3/mm/slab_vs.h linux-2.6.27.3-vs2.3.0.35.7/mm/slab_vs.h
25657 --- linux-2.6.27.3/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
25658 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/slab_vs.h 2008-10-13 14:54:20.000000000 +0200
25661 +#include <linux/vserver/context.h>
25663 +#include <linux/vs_context.h>
25666 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
25668 + int what = gfp_zone(cachep->gfpflags);
25670 + if (!current->vx_info)
25673 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
25677 +void vx_slab_free(struct kmem_cache *cachep)
25679 + int what = gfp_zone(cachep->gfpflags);
25681 + if (!current->vx_info)
25684 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
25687 diff -NurpP --minimal linux-2.6.27.3/mm/swapfile.c linux-2.6.27.3-vs2.3.0.35.7/mm/swapfile.c
25688 --- linux-2.6.27.3/mm/swapfile.c 2008-10-13 14:52:09.000000000 +0200
25689 +++ linux-2.6.27.3-vs2.3.0.35.7/mm/swapfile.c 2008-10-13 14:54:20.000000000 +0200
25691 #include <asm/pgtable.h>
25692 #include <asm/tlbflush.h>
25693 #include <linux/swapops.h>
25694 +#include <linux/vs_base.h>
25695 +#include <linux/vs_memory.h>
25697 static DEFINE_SPINLOCK(swap_lock);
25698 static unsigned int nr_swapfiles;
25699 @@ -1748,6 +1750,8 @@ void si_swapinfo(struct sysinfo *val)
25700 val->freeswap = nr_swap_pages + nr_to_be_unused;
25701 val->totalswap = total_swap_pages + nr_to_be_unused;
25702 spin_unlock(&swap_lock);
25703 + if (vx_flags(VXF_VIRT_MEM, 0))
25704 + vx_vsi_swapinfo(val);
25708 diff -NurpP --minimal linux-2.6.27.3/net/core/dev.c linux-2.6.27.3-vs2.3.0.35.7/net/core/dev.c
25709 --- linux-2.6.27.3/net/core/dev.c 2008-10-13 14:52:09.000000000 +0200
25710 +++ linux-2.6.27.3-vs2.3.0.35.7/net/core/dev.c 2008-10-13 14:54:20.000000000 +0200
25711 @@ -127,6 +127,7 @@
25712 #include <linux/in.h>
25713 #include <linux/jhash.h>
25714 #include <linux/random.h>
25715 +#include <linux/vs_inet.h>
25717 #include "net-sysfs.h"
25719 @@ -2515,6 +2516,8 @@ static int dev_ifconf(struct net *net, c
25722 for_each_netdev(net, dev) {
25723 + if (!nx_dev_visible(current->nx_info, dev))
25725 for (i = 0; i < NPROTO; i++) {
25726 if (gifconf_list[i]) {
25728 @@ -2583,6 +2586,9 @@ static void dev_seq_printf_stats(struct
25730 struct net_device_stats *stats = dev->get_stats(dev);
25732 + if (!nx_dev_visible(current->nx_info, dev))
25735 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
25736 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
25737 dev->name, stats->rx_bytes, stats->rx_packets,
25738 diff -NurpP --minimal linux-2.6.27.3/net/core/rtnetlink.c linux-2.6.27.3-vs2.3.0.35.7/net/core/rtnetlink.c
25739 --- linux-2.6.27.3/net/core/rtnetlink.c 2008-10-13 14:52:09.000000000 +0200
25740 +++ linux-2.6.27.3-vs2.3.0.35.7/net/core/rtnetlink.c 2008-10-13 14:54:20.000000000 +0200
25741 @@ -686,6 +686,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
25744 for_each_netdev(net, dev) {
25745 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
25749 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
25750 @@ -1219,6 +1221,9 @@ void rtmsg_ifinfo(int type, struct net_d
25751 struct sk_buff *skb;
25752 int err = -ENOBUFS;
25754 + if (!nx_dev_visible(current->nx_info, dev))
25757 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
25760 diff -NurpP --minimal linux-2.6.27.3/net/core/sock.c linux-2.6.27.3-vs2.3.0.35.7/net/core/sock.c
25761 --- linux-2.6.27.3/net/core/sock.c 2008-10-13 14:52:09.000000000 +0200
25762 +++ linux-2.6.27.3-vs2.3.0.35.7/net/core/sock.c 2008-10-13 14:54:20.000000000 +0200
25763 @@ -124,6 +124,10 @@
25764 #include <linux/ipsec.h>
25766 #include <linux/filter.h>
25767 +#include <linux/vs_socket.h>
25768 +#include <linux/vs_limit.h>
25769 +#include <linux/vs_context.h>
25770 +#include <linux/vs_network.h>
25773 #include <net/tcp.h>
25774 @@ -897,6 +901,8 @@ static struct sock *sk_prot_alloc(struct
25775 if (!try_module_get(prot->owner))
25778 + sock_vx_init(sk);
25779 + sock_nx_init(sk);
25783 @@ -973,6 +979,11 @@ void sk_free(struct sock *sk)
25784 __func__, atomic_read(&sk->sk_omem_alloc));
25786 put_net(sock_net(sk));
25788 + clr_vx_info(&sk->sk_vx_info);
25790 + clr_nx_info(&sk->sk_nx_info);
25792 sk_prot_free(sk->sk_prot_creator, sk);
25795 @@ -1008,6 +1019,8 @@ struct sock *sk_clone(const struct sock
25798 get_net(sock_net(newsk));
25799 + sock_vx_init(newsk);
25800 + sock_nx_init(newsk);
25801 sk_node_init(&newsk->sk_node);
25802 sock_lock_init(newsk);
25803 bh_lock_sock(newsk);
25804 @@ -1054,6 +1067,12 @@ struct sock *sk_clone(const struct sock
25805 newsk->sk_priority = 0;
25806 atomic_set(&newsk->sk_refcnt, 2);
25808 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
25809 + newsk->sk_xid = sk->sk_xid;
25810 + vx_sock_inc(newsk);
25811 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
25812 + newsk->sk_nid = sk->sk_nid;
25815 * Increment the counter in the same struct proto as the master
25816 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
25817 @@ -1738,6 +1757,11 @@ void sock_init_data(struct socket *sock,
25819 sk->sk_stamp = ktime_set(-1L, 0);
25821 + set_vx_info(&sk->sk_vx_info, current->vx_info);
25822 + sk->sk_xid = vx_current_xid();
25824 + set_nx_info(&sk->sk_nx_info, current->nx_info);
25825 + sk->sk_nid = nx_current_nid();
25826 atomic_set(&sk->sk_refcnt, 1);
25827 atomic_set(&sk->sk_drops, 0);
25829 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/af_inet.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/af_inet.c
25830 --- linux-2.6.27.3/net/ipv4/af_inet.c 2008-10-13 14:52:09.000000000 +0200
25831 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/af_inet.c 2008-10-13 14:54:20.000000000 +0200
25832 @@ -114,6 +114,7 @@
25833 #ifdef CONFIG_IP_MROUTE
25834 #include <linux/mroute.h>
25836 +#include <linux/vs_limit.h>
25838 extern void ip_mc_drop_socket(struct sock *sk);
25840 @@ -325,9 +326,12 @@ lookup_protocol:
25844 + if ((protocol == IPPROTO_ICMP) &&
25845 + nx_capable(answer->capability, NXC_RAW_ICMP))
25847 if (answer->capability > 0 && !capable(answer->capability))
25848 goto out_rcu_unlock;
25851 err = -EAFNOSUPPORT;
25852 if (!inet_netns_ok(net, protocol))
25853 goto out_rcu_unlock;
25854 @@ -445,6 +449,7 @@ int inet_bind(struct socket *sock, struc
25855 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
25856 struct sock *sk = sock->sk;
25857 struct inet_sock *inet = inet_sk(sk);
25858 + struct nx_v4_sock_addr nsa;
25859 unsigned short snum;
25862 @@ -458,7 +463,11 @@ int inet_bind(struct socket *sock, struc
25863 if (addr_len < sizeof(struct sockaddr_in))
25866 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25867 + err = v4_map_sock_addr(inet, addr, &nsa);
25871 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25873 /* Not specified by any standard per-se, however it breaks too
25874 * many applications when removed. It is unfortunate since
25875 @@ -470,7 +479,7 @@ int inet_bind(struct socket *sock, struc
25876 err = -EADDRNOTAVAIL;
25877 if (!sysctl_ip_nonlocal_bind &&
25879 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
25880 + nsa.saddr != htonl(INADDR_ANY) &&
25881 chk_addr_ret != RTN_LOCAL &&
25882 chk_addr_ret != RTN_MULTICAST &&
25883 chk_addr_ret != RTN_BROADCAST)
25884 @@ -495,7 +504,7 @@ int inet_bind(struct socket *sock, struc
25885 if (sk->sk_state != TCP_CLOSE || inet->num)
25886 goto out_release_sock;
25888 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
25889 + v4_set_sock_addr(inet, &nsa);
25890 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25891 inet->saddr = 0; /* Use device */
25893 @@ -688,11 +697,13 @@ int inet_getname(struct socket *sock, st
25896 sin->sin_port = inet->dport;
25897 - sin->sin_addr.s_addr = inet->daddr;
25898 + sin->sin_addr.s_addr =
25899 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
25901 __be32 addr = inet->rcv_saddr;
25903 addr = inet->saddr;
25904 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
25905 sin->sin_port = inet->sport;
25906 sin->sin_addr.s_addr = addr;
25908 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/devinet.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/devinet.c
25909 --- linux-2.6.27.3/net/ipv4/devinet.c 2008-10-13 14:52:09.000000000 +0200
25910 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/devinet.c 2008-10-13 14:54:20.000000000 +0200
25911 @@ -420,6 +420,7 @@ struct in_device *inetdev_by_index(struc
25916 /* Called only from RTNL semaphored context. No locks. */
25918 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
25919 @@ -662,6 +663,8 @@ int devinet_ioctl(struct net *net, unsig
25922 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
25923 + struct nx_info *nxi = current->nx_info;
25925 if (tryaddrmatch) {
25926 /* Matthias Andree */
25927 /* compare label and address (4.4BSD style) */
25928 @@ -670,6 +673,8 @@ int devinet_ioctl(struct net *net, unsig
25929 This is checked above. */
25930 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25931 ifap = &ifa->ifa_next) {
25932 + if (!nx_v4_ifa_visible(nxi, ifa))
25934 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
25935 sin_orig.sin_addr.s_addr ==
25936 ifa->ifa_address) {
25937 @@ -682,9 +687,12 @@ int devinet_ioctl(struct net *net, unsig
25938 comparing just the label */
25940 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25941 - ifap = &ifa->ifa_next)
25942 + ifap = &ifa->ifa_next) {
25943 + if (!nx_v4_ifa_visible(nxi, ifa))
25945 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
25951 @@ -835,6 +843,8 @@ static int inet_gifconf(struct net_devic
25954 for (; ifa; ifa = ifa->ifa_next) {
25955 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
25958 done += sizeof(ifr);
25960 @@ -1165,6 +1175,7 @@ static int inet_dump_ifaddr(struct sk_bu
25961 struct net_device *dev;
25962 struct in_device *in_dev;
25963 struct in_ifaddr *ifa;
25964 + struct sock *sk = skb->sk;
25965 int s_ip_idx, s_idx = cb->args[0];
25967 s_ip_idx = ip_idx = cb->args[1];
25968 @@ -1179,6 +1190,8 @@ static int inet_dump_ifaddr(struct sk_bu
25970 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
25971 ifa = ifa->ifa_next, ip_idx++) {
25972 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
25974 if (ip_idx < s_ip_idx)
25976 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
25977 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/fib_hash.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/fib_hash.c
25978 --- linux-2.6.27.3/net/ipv4/fib_hash.c 2008-10-13 14:52:09.000000000 +0200
25979 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/fib_hash.c 2008-10-13 14:54:20.000000000 +0200
25980 @@ -1022,7 +1022,7 @@ static int fib_seq_show(struct seq_file
25981 prefix = f->fn_key;
25982 mask = FZ_MASK(iter->zone);
25983 flags = fib_flag_trans(fa->fa_type, mask, fi);
25985 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
25987 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
25988 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
25989 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/inet_connection_sock.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/inet_connection_sock.c
25990 --- linux-2.6.27.3/net/ipv4/inet_connection_sock.c 2008-10-13 14:52:09.000000000 +0200
25991 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/inet_connection_sock.c 2008-10-13 14:54:20.000000000 +0200
25992 @@ -47,10 +47,40 @@ void inet_get_local_port_range(int *low,
25994 EXPORT_SYMBOL(inet_get_local_port_range);
25996 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25998 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
25999 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
26001 + if (inet_v6_ipv6only(sk2))
26004 + if (sk1_rcv_saddr &&
26006 + sk1_rcv_saddr == sk2_rcv_saddr)
26009 + if (sk1_rcv_saddr &&
26010 + !sk2_rcv_saddr &&
26011 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26014 + if (sk2_rcv_saddr &&
26015 + !sk1_rcv_saddr &&
26016 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26019 + if (!sk1_rcv_saddr &&
26020 + !sk2_rcv_saddr &&
26021 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26027 int inet_csk_bind_conflict(const struct sock *sk,
26028 const struct inet_bind_bucket *tb)
26030 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
26032 struct hlist_node *node;
26033 int reuse = sk->sk_reuse;
26034 @@ -70,9 +100,7 @@ int inet_csk_bind_conflict(const struct
26035 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26036 if (!reuse || !sk2->sk_reuse ||
26037 sk2->sk_state == TCP_LISTEN) {
26038 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26039 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
26040 - sk2_rcv_saddr == sk_rcv_saddr)
26041 + if (ipv4_rcv_saddr_equal(sk, sk2))
26045 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/inet_diag.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/inet_diag.c
26046 --- linux-2.6.27.3/net/ipv4/inet_diag.c 2008-10-13 14:52:09.000000000 +0200
26047 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/inet_diag.c 2008-10-13 14:54:20.000000000 +0200
26049 #include <linux/stddef.h>
26051 #include <linux/inet_diag.h>
26052 +#include <linux/vs_network.h>
26053 +#include <linux/vs_inet.h>
26055 static const struct inet_diag_handler **inet_diag_table;
26057 @@ -120,8 +122,8 @@ static int inet_csk_diag_fill(struct soc
26059 r->id.idiag_sport = inet->sport;
26060 r->id.idiag_dport = inet->dport;
26061 - r->id.idiag_src[0] = inet->rcv_saddr;
26062 - r->id.idiag_dst[0] = inet->daddr;
26063 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
26064 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26066 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26067 if (r->idiag_family == AF_INET6) {
26068 @@ -208,8 +210,8 @@ static int inet_twsk_diag_fill(struct in
26069 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
26070 r->id.idiag_sport = tw->tw_sport;
26071 r->id.idiag_dport = tw->tw_dport;
26072 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
26073 - r->id.idiag_dst[0] = tw->tw_daddr;
26074 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
26075 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
26076 r->idiag_state = tw->tw_substate;
26077 r->idiag_timer = 3;
26078 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
26079 @@ -266,6 +268,7 @@ static int inet_diag_get_exact(struct sk
26082 if (req->idiag_family == AF_INET) {
26083 + /* TODO: lback */
26084 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
26085 req->id.idiag_dport, req->id.idiag_src[0],
26086 req->id.idiag_sport, req->id.idiag_if);
26087 @@ -508,6 +511,7 @@ static int inet_csk_diag_dump(struct soc
26091 + /* TODO: lback */
26092 entry.saddr = &inet->rcv_saddr;
26093 entry.daddr = &inet->daddr;
26095 @@ -544,6 +548,7 @@ static int inet_twsk_diag_dump(struct in
26099 + /* TODO: lback */
26100 entry.saddr = &tw->tw_rcv_saddr;
26101 entry.daddr = &tw->tw_daddr;
26103 @@ -590,8 +595,8 @@ static int inet_diag_fill_req(struct sk_
26105 r->id.idiag_sport = inet->sport;
26106 r->id.idiag_dport = ireq->rmt_port;
26107 - r->id.idiag_src[0] = ireq->loc_addr;
26108 - r->id.idiag_dst[0] = ireq->rmt_addr;
26109 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
26110 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
26111 r->idiag_expires = jiffies_to_msecs(tmo);
26112 r->idiag_rqueue = 0;
26113 r->idiag_wqueue = 0;
26114 @@ -661,6 +666,7 @@ static int inet_diag_dump_reqs(struct sk
26118 + /* TODO: lback */
26120 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26121 (entry.family == AF_INET6) ?
26122 @@ -729,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
26123 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
26124 struct inet_sock *inet = inet_sk(sk);
26126 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26131 @@ -790,6 +798,8 @@ skip_listen_ht:
26132 sk_for_each(sk, node, &head->chain) {
26133 struct inet_sock *inet = inet_sk(sk);
26135 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26139 if (!(r->idiag_states & (1 << sk->sk_state)))
26140 @@ -814,6 +824,8 @@ next_normal:
26141 inet_twsk_for_each(tw, node,
26144 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26148 if (r->id.idiag_sport != tw->tw_sport &&
26149 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/inet_hashtables.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/inet_hashtables.c
26150 --- linux-2.6.27.3/net/ipv4/inet_hashtables.c 2008-10-13 14:52:09.000000000 +0200
26151 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/inet_hashtables.c 2008-10-13 14:54:20.000000000 +0200
26154 #include <net/inet_connection_sock.h>
26155 #include <net/inet_hashtables.h>
26156 +#include <net/route.h>
26157 #include <net/ip.h>
26160 @@ -163,11 +164,10 @@ static struct sock *inet_lookup_listener
26161 const __be32 rcv_saddr = inet->rcv_saddr;
26162 int score = sk->sk_family == PF_INET ? 1 : 0;
26165 - if (rcv_saddr != daddr)
26167 + if (v4_inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
26172 if (sk->sk_bound_dev_if) {
26173 if (sk->sk_bound_dev_if != dif)
26175 @@ -199,7 +199,7 @@ struct sock *__inet_lookup_listener(stru
26176 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
26178 if (inet->num == hnum && !sk->sk_node.next &&
26179 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
26180 + v4_inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
26181 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
26182 !sk->sk_bound_dev_if && net_eq(sock_net(sk), net))
26184 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/netfilter/nf_nat_helper.c
26185 --- linux-2.6.27.3/net/ipv4/netfilter/nf_nat_helper.c 2008-07-13 23:51:29.000000000 +0200
26186 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/netfilter/nf_nat_helper.c 2008-10-13 14:54:20.000000000 +0200
26188 #include <net/tcp.h>
26190 #include <linux/netfilter_ipv4.h>
26191 +#include <net/route.h>
26192 #include <net/netfilter/nf_conntrack.h>
26193 #include <net/netfilter/nf_conntrack_helper.h>
26194 #include <net/netfilter/nf_conntrack_ecache.h>
26195 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/netfilter.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/netfilter.c
26196 --- linux-2.6.27.3/net/ipv4/netfilter.c 2008-07-13 23:51:29.000000000 +0200
26197 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/netfilter.c 2008-10-13 14:54:20.000000000 +0200
26199 #include <linux/netfilter_ipv4.h>
26200 #include <linux/ip.h>
26201 #include <linux/skbuff.h>
26202 -#include <net/route.h>
26203 +// #include <net/route.h>
26204 #include <net/xfrm.h>
26205 #include <net/ip.h>
26206 #include <net/netfilter/nf_queue.h>
26207 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/raw.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/raw.c
26208 --- linux-2.6.27.3/net/ipv4/raw.c 2008-10-13 14:52:09.000000000 +0200
26209 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/raw.c 2008-10-13 14:54:20.000000000 +0200
26210 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
26212 if (net_eq(sock_net(sk), net) && inet->num == num &&
26213 !(inet->daddr && inet->daddr != raddr) &&
26214 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
26215 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
26216 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
26217 goto found; /* gotcha */
26219 @@ -372,6 +372,12 @@ static int raw_send_hdrinc(struct sock *
26220 icmp_out_count(net, ((struct icmphdr *)
26221 skb_transport_header(skb))->type);
26224 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
26225 + sk->sk_nx_info &&
26226 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
26229 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
26232 @@ -383,6 +389,7 @@ out:
26239 IP_INC_STATS(net, IPSTATS_MIB_OUTDISCARDS);
26240 @@ -550,6 +557,13 @@ static int raw_sendmsg(struct kiocb *ioc
26243 security_sk_classify_flow(sk, &fl);
26244 + if (sk->sk_nx_info) {
26245 + err = ip_v4_find_src(sock_net(sk),
26246 + sk->sk_nx_info, &rt, &fl);
26251 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
26254 @@ -619,17 +633,19 @@ static int raw_bind(struct sock *sk, str
26256 struct inet_sock *inet = inet_sk(sk);
26257 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
26258 + struct nx_v4_sock_addr nsa = { 0 };
26262 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
26264 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26265 + v4_map_sock_addr(inet, addr, &nsa);
26266 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26267 ret = -EADDRNOTAVAIL;
26268 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
26269 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
26270 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
26272 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26273 + v4_set_sock_addr(inet, &nsa);
26274 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26275 inet->saddr = 0; /* Use device */
26277 @@ -681,7 +697,8 @@ static int raw_recvmsg(struct kiocb *ioc
26278 /* Copy the address. */
26280 sin->sin_family = AF_INET;
26281 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
26282 + sin->sin_addr.s_addr =
26283 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
26285 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
26287 @@ -858,7 +875,8 @@ static struct sock *raw_get_first(struct
26288 struct hlist_node *node;
26290 sk_for_each(sk, node, &state->h->ht[state->bucket])
26291 - if (sock_net(sk) == seq_file_net(seq))
26292 + if ((sock_net(sk) == seq_file_net(seq)) &&
26293 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26297 @@ -874,7 +892,8 @@ static struct sock *raw_get_next(struct
26301 - } while (sk && sock_net(sk) != seq_file_net(seq));
26302 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
26303 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26305 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
26306 sk = sk_head(&state->h->ht[state->bucket]);
26307 @@ -933,7 +952,10 @@ static void raw_sock_seq_show(struct seq
26309 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
26310 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
26311 - i, src, srcp, dest, destp, sp->sk_state,
26313 + nx_map_sock_lback(current_nx_info(), src), srcp,
26314 + nx_map_sock_lback(current_nx_info(), dest), destp,
26316 atomic_read(&sp->sk_wmem_alloc),
26317 atomic_read(&sp->sk_rmem_alloc),
26318 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
26319 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/syncookies.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/syncookies.c
26320 --- linux-2.6.27.3/net/ipv4/syncookies.c 2008-10-13 14:52:09.000000000 +0200
26321 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/syncookies.c 2008-10-13 14:54:20.000000000 +0200
26323 #include <linux/cryptohash.h>
26324 #include <linux/kernel.h>
26325 #include <net/tcp.h>
26326 +#include <net/route.h>
26328 /* Timestamps: lowest 9 bits store TCP options */
26330 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/tcp.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/tcp.c
26331 --- linux-2.6.27.3/net/ipv4/tcp.c 2008-10-13 14:52:09.000000000 +0200
26332 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/tcp.c 2008-10-13 14:54:20.000000000 +0200
26333 @@ -264,6 +264,7 @@
26334 #include <linux/cache.h>
26335 #include <linux/err.h>
26336 #include <linux/crypto.h>
26337 +#include <linux/in.h>
26339 #include <net/icmp.h>
26340 #include <net/tcp.h>
26341 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/tcp_ipv4.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/tcp_ipv4.c
26342 --- linux-2.6.27.3/net/ipv4/tcp_ipv4.c 2008-10-13 14:52:09.000000000 +0200
26343 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/tcp_ipv4.c 2008-10-13 14:54:20.000000000 +0200
26344 @@ -1886,6 +1886,12 @@ static void *listening_get_next(struct s
26345 req = req->dl_next;
26348 + vxdprintk(VXD_CBIT(net, 6),
26349 + "sk,req: %p [#%d] (from %d)", req->sk,
26350 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
26352 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
26354 if (req->rsk_ops->family == st->family) {
26357 @@ -1910,6 +1916,10 @@ get_req:
26360 sk_for_each_from(sk, node) {
26361 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
26362 + sk, sk->sk_nid, nx_current_nid());
26363 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26365 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
26368 @@ -1960,6 +1970,11 @@ static void *established_get_first(struc
26370 read_lock_bh(lock);
26371 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
26372 + vxdprintk(VXD_CBIT(net, 6),
26373 + "sk,egf: %p [#%d] (from %d)",
26374 + sk, sk->sk_nid, nx_current_nid());
26375 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26377 if (sk->sk_family != st->family ||
26378 !net_eq(sock_net(sk), net)) {
26380 @@ -1970,6 +1985,11 @@ static void *established_get_first(struc
26381 st->state = TCP_SEQ_STATE_TIME_WAIT;
26382 inet_twsk_for_each(tw, node,
26383 &tcp_hashinfo.ehash[st->bucket].twchain) {
26384 + vxdprintk(VXD_CBIT(net, 6),
26385 + "tw: %p [#%d] (from %d)",
26386 + tw, tw->tw_nid, nx_current_nid());
26387 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26389 if (tw->tw_family != st->family ||
26390 !net_eq(twsk_net(tw), net)) {
26392 @@ -1998,7 +2018,9 @@ static void *established_get_next(struct
26396 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
26397 + while (tw && (tw->tw_family != st->family ||
26398 + !net_eq(twsk_net(tw), net) ||
26399 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
26403 @@ -2019,6 +2041,11 @@ get_tw:
26406 sk_for_each_from(sk, node) {
26407 + vxdprintk(VXD_CBIT(net, 6),
26408 + "sk,egn: %p [#%d] (from %d)",
26409 + sk, sk->sk_nid, nx_current_nid());
26410 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26412 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
26415 @@ -2173,9 +2200,9 @@ static void get_openreq4(struct sock *sk
26416 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26417 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
26420 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
26421 ntohs(inet_sk(sk)->sport),
26423 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
26424 ntohs(ireq->rmt_port),
26426 0, 0, /* could print option size, but that is af dependent. */
26427 @@ -2218,7 +2245,10 @@ static void get_tcp4_sock(struct sock *s
26429 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
26430 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
26431 - i, src, srcp, dest, destp, sk->sk_state,
26433 + nx_map_sock_lback(current_nx_info(), src), srcp,
26434 + nx_map_sock_lback(current_nx_info(), dest), destp,
26436 tp->write_seq - tp->snd_una,
26437 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
26438 (tp->rcv_nxt - tp->copied_seq),
26439 @@ -2254,7 +2284,10 @@ static void get_timewait4_sock(struct in
26441 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26442 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
26443 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
26445 + nx_map_sock_lback(current_nx_info(), src), srcp,
26446 + nx_map_sock_lback(current_nx_info(), dest), destp,
26447 + tw->tw_substate, 0, 0,
26448 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
26449 atomic_read(&tw->tw_refcnt), tw, len);
26451 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/tcp_minisocks.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/tcp_minisocks.c
26452 --- linux-2.6.27.3/net/ipv4/tcp_minisocks.c 2008-10-13 14:52:09.000000000 +0200
26453 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/tcp_minisocks.c 2008-10-13 14:54:20.000000000 +0200
26455 #include <net/inet_common.h>
26456 #include <net/xfrm.h>
26458 +#include <linux/vs_limit.h>
26459 +#include <linux/vs_socket.h>
26460 +#include <linux/vs_context.h>
26462 #ifdef CONFIG_SYSCTL
26463 #define SYNC_INIT 0 /* let the user enable it */
26465 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
26466 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
26467 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
26469 + tw->tw_xid = sk->sk_xid;
26470 + tw->tw_vx_info = NULL;
26471 + tw->tw_nid = sk->sk_nid;
26472 + tw->tw_nx_info = NULL;
26474 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
26475 if (tw->tw_family == PF_INET6) {
26476 struct ipv6_pinfo *np = inet6_sk(sk);
26477 diff -NurpP --minimal linux-2.6.27.3/net/ipv4/udp.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/udp.c
26478 --- linux-2.6.27.3/net/ipv4/udp.c 2008-10-13 14:52:09.000000000 +0200
26479 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv4/udp.c 2008-10-13 14:54:20.000000000 +0200
26480 @@ -234,20 +234,14 @@ fail:
26484 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26486 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
26488 - return ( !ipv6_only_sock(sk2) &&
26489 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
26490 - inet1->rcv_saddr == inet2->rcv_saddr ));
26492 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
26494 int udp_v4_get_port(struct sock *sk, unsigned short snum)
26496 return udp_lib_get_port(sk, snum, ipv4_rcv_saddr_equal);
26500 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
26501 * harder than this. -DaveM
26503 @@ -267,10 +261,16 @@ static struct sock *__udp4_lib_lookup(st
26504 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
26505 !ipv6_only_sock(sk)) {
26506 int score = (sk->sk_family == PF_INET ? 1 : 0);
26508 if (inet->rcv_saddr) {
26509 if (inet->rcv_saddr != daddr)
26513 + /* block non nx_info ips */
26514 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
26515 + daddr, NXA_MASK_BIND))
26519 if (inet->daddr != saddr)
26520 @@ -296,6 +296,7 @@ static struct sock *__udp4_lib_lookup(st
26527 read_unlock(&udp_hash_lock);
26528 @@ -317,7 +318,7 @@ static inline struct sock *udp_v4_mcast_
26529 if (s->sk_hash != hnum ||
26530 (inet->daddr && inet->daddr != rmt_addr) ||
26531 (inet->dport != rmt_port && inet->dport) ||
26532 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
26533 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
26534 ipv6_only_sock(s) ||
26535 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
26537 @@ -654,8 +655,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
26538 { .sport = inet->sport,
26539 .dport = dport } } };
26540 struct net *net = sock_net(sk);
26541 + struct nx_info *nxi = sk->sk_nx_info;
26543 security_sk_classify_flow(sk, &fl);
26544 + err = ip_v4_find_src(net, nxi, &rt, &fl);
26548 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
26550 if (err == -ENETUNREACH)
26551 @@ -900,7 +906,8 @@ try_again:
26553 sin->sin_family = AF_INET;
26554 sin->sin_port = udp_hdr(skb)->source;
26555 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
26556 + sin->sin_addr.s_addr = nx_map_sock_lback(
26557 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
26558 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
26560 if (inet->cmsg_flags)
26561 @@ -1528,6 +1535,8 @@ static struct sock *udp_get_first(struct
26562 sk_for_each(sk, node, state->hashtable + state->bucket) {
26563 if (!net_eq(sock_net(sk), net))
26565 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26567 if (sk->sk_family == state->family)
26570 @@ -1546,7 +1555,9 @@ static struct sock *udp_get_next(struct
26574 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
26575 + } while (sk && (!net_eq(sock_net(sk), net) ||
26576 + sk->sk_family != state->family ||
26577 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26579 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
26580 sk = sk_head(state->hashtable + state->bucket);
26581 @@ -1647,7 +1658,10 @@ static void udp4_format_sock(struct sock
26583 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26584 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
26585 - bucket, src, srcp, dest, destp, sp->sk_state,
26587 + nx_map_sock_lback(current_nx_info(), src), srcp,
26588 + nx_map_sock_lback(current_nx_info(), dest), destp,
26590 atomic_read(&sp->sk_wmem_alloc),
26591 atomic_read(&sp->sk_rmem_alloc),
26592 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
26593 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/addrconf.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/addrconf.c
26594 --- linux-2.6.27.3/net/ipv6/addrconf.c 2008-10-13 14:52:09.000000000 +0200
26595 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/addrconf.c 2008-10-13 14:54:20.000000000 +0200
26598 #include <linux/proc_fs.h>
26599 #include <linux/seq_file.h>
26600 +#include <linux/vs_network.h>
26601 +#include <linux/vs_inet6.h>
26603 /* Set to 3 to get tracing... */
26604 #define ACONF_DEBUG 2
26605 @@ -1108,7 +1110,7 @@ out:
26607 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
26608 const struct in6_addr *daddr, unsigned int prefs,
26609 - struct in6_addr *saddr)
26610 + struct in6_addr *saddr, struct nx_info *nxi)
26612 struct ipv6_saddr_score scores[2],
26613 *score = &scores[0], *hiscore = &scores[1];
26614 @@ -1364,35 +1366,46 @@ struct inet6_ifaddr *ipv6_get_ifaddr(str
26618 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
26620 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
26622 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
26623 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
26624 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
26625 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26626 int sk_ipv6only = ipv6_only_sock(sk);
26627 int sk2_ipv6only = inet_v6_ipv6only(sk2);
26628 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
26629 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
26631 - if (!sk2_rcv_saddr && !sk_ipv6only)
26632 + /* FIXME: needs handling for v4 ANY */
26633 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
26636 if (addr_type2 == IPV6_ADDR_ANY &&
26637 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
26638 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
26639 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
26642 if (addr_type == IPV6_ADDR_ANY &&
26643 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26644 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
26645 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
26648 + if (addr_type == IPV6_ADDR_ANY &&
26649 + addr_type2 == IPV6_ADDR_ANY &&
26650 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
26653 if (sk2_rcv_saddr6 &&
26654 + addr_type != IPV6_ADDR_ANY &&
26655 + addr_type != IPV6_ADDR_ANY &&
26656 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
26659 if (addr_type == IPV6_ADDR_MAPPED &&
26661 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
26662 + ipv4_rcv_saddr_equal(sk, sk2))
26666 @@ -2986,7 +2999,10 @@ static void if6_seq_stop(struct seq_file
26667 static int if6_seq_show(struct seq_file *seq, void *v)
26669 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
26672 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
26673 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
26675 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
26677 ifp->idev->dev->ifindex,
26678 @@ -3481,6 +3497,12 @@ static int inet6_dump_addr(struct sk_buf
26679 struct ifmcaddr6 *ifmca;
26680 struct ifacaddr6 *ifaca;
26681 struct net *net = sock_net(skb->sk);
26682 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
26684 + /* disable ipv6 on non v6 guests */
26685 + if (nxi && !nx_info_has_v6(nxi))
26689 s_idx = cb->args[0];
26690 s_ip_idx = ip_idx = cb->args[1];
26691 @@ -3502,6 +3524,8 @@ static int inet6_dump_addr(struct sk_buf
26692 ifa = ifa->if_next, ip_idx++) {
26693 if (ip_idx < s_ip_idx)
26695 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
26697 err = inet6_fill_ifaddr(skb, ifa,
26698 NETLINK_CB(cb->skb).pid,
26699 cb->nlh->nlmsg_seq,
26700 @@ -3515,6 +3539,8 @@ static int inet6_dump_addr(struct sk_buf
26701 ifmca = ifmca->next, ip_idx++) {
26702 if (ip_idx < s_ip_idx)
26704 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
26706 err = inet6_fill_ifmcaddr(skb, ifmca,
26707 NETLINK_CB(cb->skb).pid,
26708 cb->nlh->nlmsg_seq,
26709 @@ -3528,6 +3554,8 @@ static int inet6_dump_addr(struct sk_buf
26710 ifaca = ifaca->aca_next, ip_idx++) {
26711 if (ip_idx < s_ip_idx)
26713 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
26715 err = inet6_fill_ifacaddr(skb, ifaca,
26716 NETLINK_CB(cb->skb).pid,
26717 cb->nlh->nlmsg_seq,
26718 @@ -3813,12 +3841,19 @@ static int inet6_dump_ifinfo(struct sk_b
26719 int s_idx = cb->args[0];
26720 struct net_device *dev;
26721 struct inet6_dev *idev;
26722 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
26724 + /* FIXME: maybe disable ipv6 on non v6 guests?
26725 + if (skb->sk && skb->sk->sk_vx_info)
26726 + return skb->len; */
26728 read_lock(&dev_base_lock);
26730 for_each_netdev(net, dev) {
26733 + if (!v6_dev_in_nx_info(dev, nxi))
26735 if ((idev = in6_dev_get(dev)) == NULL)
26737 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
26738 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/af_inet6.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/af_inet6.c
26739 --- linux-2.6.27.3/net/ipv6/af_inet6.c 2008-10-13 14:52:09.000000000 +0200
26740 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/af_inet6.c 2008-10-13 14:54:20.000000000 +0200
26742 #include <linux/netdevice.h>
26743 #include <linux/icmpv6.h>
26744 #include <linux/netfilter_ipv6.h>
26745 +#include <linux/vs_inet.h>
26746 +#include <linux/vs_inet6.h>
26748 #include <net/ip.h>
26749 #include <net/ipv6.h>
26751 #include <net/tcp.h>
26752 #include <net/ipip.h>
26753 #include <net/protocol.h>
26754 +#include <net/route.h>
26755 #include <net/inet_common.h>
26756 #include <net/transp_v6.h>
26757 #include <net/ip6_route.h>
26758 @@ -141,9 +144,12 @@ lookup_protocol:
26762 + if ((protocol == IPPROTO_ICMPV6) &&
26763 + nx_capable(answer->capability, NXC_RAW_ICMP))
26765 if (answer->capability > 0 && !capable(answer->capability))
26766 goto out_rcu_unlock;
26769 sock->ops = answer->ops;
26770 answer_prot = answer->prot;
26771 answer_no_check = answer->no_check;
26772 @@ -242,6 +248,7 @@ int inet6_bind(struct socket *sock, stru
26773 struct inet_sock *inet = inet_sk(sk);
26774 struct ipv6_pinfo *np = inet6_sk(sk);
26775 struct net *net = sock_net(sk);
26776 + struct nx_v6_sock_addr nsa;
26778 unsigned short snum;
26780 @@ -253,6 +260,11 @@ int inet6_bind(struct socket *sock, stru
26782 if (addr_len < SIN6_LEN_RFC2133)
26785 + err = v6_map_sock_addr(inet, addr, &nsa);
26789 addr_type = ipv6_addr_type(&addr->sin6_addr);
26790 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
26792 @@ -276,6 +288,10 @@ int inet6_bind(struct socket *sock, stru
26793 err = -EADDRNOTAVAIL;
26796 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
26797 + err = -EADDRNOTAVAIL;
26801 if (addr_type != IPV6_ADDR_ANY) {
26802 struct net_device *dev = NULL;
26803 @@ -301,6 +317,11 @@ int inet6_bind(struct socket *sock, stru
26807 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
26808 + err = -EADDRNOTAVAIL;
26812 /* ipv4 addr of the socket is invalid. Only the
26813 * unspecified and mapped address have a v4 equivalent.
26815 @@ -319,6 +340,8 @@ int inet6_bind(struct socket *sock, stru
26819 + v6_set_sock_addr(inet, &nsa);
26821 inet->rcv_saddr = v4addr;
26822 inet->saddr = v4addr;
26824 @@ -411,9 +434,11 @@ int inet6_getname(struct socket *sock, s
26826 sin->sin6_port = inet->dport;
26827 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
26828 + /* FIXME: remap lback? */
26830 sin->sin6_flowinfo = np->flow_label;
26832 + /* FIXME: remap lback? */
26833 if (ipv6_addr_any(&np->rcv_saddr))
26834 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
26836 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/fib6_rules.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/fib6_rules.c
26837 --- linux-2.6.27.3/net/ipv6/fib6_rules.c 2008-10-13 14:52:09.000000000 +0200
26838 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/fib6_rules.c 2008-10-13 14:54:20.000000000 +0200
26839 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
26840 if (ipv6_dev_get_saddr(net,
26841 ip6_dst_idev(&rt->u.dst)->dev,
26842 &flp->fl6_dst, srcprefs,
26846 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
26848 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/inet6_hashtables.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/inet6_hashtables.c
26849 --- linux-2.6.27.3/net/ipv6/inet6_hashtables.c 2008-10-13 14:52:09.000000000 +0200
26850 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/inet6_hashtables.c 2008-10-13 14:54:20.000000000 +0200
26853 #include <linux/module.h>
26854 #include <linux/random.h>
26855 +#include <linux/vs_inet6.h>
26857 #include <net/inet_connection_sock.h>
26858 #include <net/inet_hashtables.h>
26859 @@ -115,6 +116,9 @@ struct sock *inet6_lookup_listener(struc
26860 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26864 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26867 if (sk->sk_bound_dev_if) {
26868 if (sk->sk_bound_dev_if != dif)
26869 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/ip6_output.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/ip6_output.c
26870 --- linux-2.6.27.3/net/ipv6/ip6_output.c 2008-10-13 14:52:09.000000000 +0200
26871 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/ip6_output.c 2008-10-13 14:54:20.000000000 +0200
26872 @@ -937,7 +937,7 @@ static int ip6_dst_lookup_tail(struct so
26873 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
26875 sk ? inet6_sk(sk)->srcprefs : 0,
26877 + &fl->fl6_src, sk->sk_nx_info);
26879 goto out_err_release;
26881 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/Kconfig linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/Kconfig
26882 --- linux-2.6.27.3/net/ipv6/Kconfig 2008-10-13 14:52:09.000000000 +0200
26883 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/Kconfig 2008-10-13 14:54:20.000000000 +0200
26886 # IPv6 as module will cause a CRASH if you try to unload it
26888 - tristate "The IPv6 protocol"
26890 + bool "The IPv6 protocol"
26893 This is complemental support for the IP version 6.
26894 You will still be able to do traditional IPv4 networking as well.
26895 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/ndisc.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/ndisc.c
26896 --- linux-2.6.27.3/net/ipv6/ndisc.c 2008-10-13 14:52:09.000000000 +0200
26897 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/ndisc.c 2008-10-13 14:54:20.000000000 +0200
26898 @@ -551,7 +551,7 @@ static void ndisc_send_na(struct net_dev
26900 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
26901 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
26903 + &tmpaddr, NULL /* FIXME: ? */ ))
26905 src_addr = &tmpaddr;
26907 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/route.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/route.c
26908 --- linux-2.6.27.3/net/ipv6/route.c 2008-10-13 14:52:09.000000000 +0200
26909 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/route.c 2008-10-13 14:54:20.000000000 +0200
26910 @@ -2191,7 +2191,8 @@ static int rt6_fill_node(struct net *net
26911 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
26912 struct in6_addr saddr_buf;
26913 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
26914 - dst, 0, &saddr_buf) == 0)
26915 + dst, 0, &saddr_buf,
26916 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
26917 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
26920 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/tcp_ipv6.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/tcp_ipv6.c
26921 --- linux-2.6.27.3/net/ipv6/tcp_ipv6.c 2008-10-13 14:52:09.000000000 +0200
26922 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/tcp_ipv6.c 2008-10-13 14:54:20.000000000 +0200
26925 #include <linux/crypto.h>
26926 #include <linux/scatterlist.h>
26927 +#include <linux/vs_inet6.h>
26929 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
26930 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
26931 @@ -155,8 +156,15 @@ static int tcp_v6_connect(struct sock *s
26932 * connect() to INADDR_ANY means loopback (BSD'ism).
26935 - if(ipv6_addr_any(&usin->sin6_addr))
26936 - usin->sin6_addr.s6_addr[15] = 0x1;
26937 + if(ipv6_addr_any(&usin->sin6_addr)) {
26938 + struct nx_info *nxi = sk->sk_nx_info;
26940 + if (nxi && nx_info_has_v6(nxi))
26941 + /* FIXME: remap lback? */
26942 + usin->sin6_addr = nxi->v6.ip;
26944 + usin->sin6_addr.s6_addr[15] = 0x1;
26947 addr_type = ipv6_addr_type(&usin->sin6_addr);
26949 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/udp.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/udp.c
26950 --- linux-2.6.27.3/net/ipv6/udp.c 2008-10-13 14:52:09.000000000 +0200
26951 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/udp.c 2008-10-13 14:54:20.000000000 +0200
26954 #include <linux/proc_fs.h>
26955 #include <linux/seq_file.h>
26956 +#include <linux/vs_inet6.h>
26957 #include "udp_impl.h"
26959 int udp_v6_get_port(struct sock *sk, unsigned short snum)
26960 @@ -81,6 +82,10 @@ static struct sock *__udp6_lib_lookup(st
26961 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26965 + /* block non nx_info ips */
26966 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26969 if (!ipv6_addr_any(&np->daddr)) {
26970 if (!ipv6_addr_equal(&np->daddr, saddr))
26971 diff -NurpP --minimal linux-2.6.27.3/net/ipv6/xfrm6_policy.c linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/xfrm6_policy.c
26972 --- linux-2.6.27.3/net/ipv6/xfrm6_policy.c 2008-10-13 14:52:09.000000000 +0200
26973 +++ linux-2.6.27.3-vs2.3.0.35.7/net/ipv6/xfrm6_policy.c 2008-10-13 14:54:20.000000000 +0200
26974 @@ -61,7 +61,7 @@ static int xfrm6_get_saddr(xfrm_address_
26975 dev = ip6_dst_idev(dst)->dev;
26976 ipv6_dev_get_saddr(dev_net(dev), dev,
26977 (struct in6_addr *)&daddr->a6, 0,
26978 - (struct in6_addr *)&saddr->a6);
26979 + (struct in6_addr *)&saddr->a6, NULL);
26983 diff -NurpP --minimal linux-2.6.27.3/net/netlink/af_netlink.c linux-2.6.27.3-vs2.3.0.35.7/net/netlink/af_netlink.c
26984 --- linux-2.6.27.3/net/netlink/af_netlink.c 2008-10-13 14:52:09.000000000 +0200
26985 +++ linux-2.6.27.3-vs2.3.0.35.7/net/netlink/af_netlink.c 2008-10-13 14:54:20.000000000 +0200
26987 #include <linux/types.h>
26988 #include <linux/audit.h>
26989 #include <linux/mutex.h>
26990 +#include <linux/vs_context.h>
26991 +#include <linux/vs_network.h>
26992 +#include <linux/vs_limit.h>
26994 #include <net/net_namespace.h>
26995 #include <net/sock.h>
26996 @@ -1761,6 +1764,8 @@ static struct sock *netlink_seq_socket_i
26997 sk_for_each(s, node, &hash->table[j]) {
26998 if (sock_net(s) != seq_file_net(seq))
27000 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27004 iter->hash_idx = j;
27005 @@ -1795,7 +1800,8 @@ static void *netlink_seq_next(struct seq
27009 - } while (s && sock_net(s) != seq_file_net(seq));
27010 + } while (s && (sock_net(s) != seq_file_net(seq) ||
27011 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
27015 @@ -1807,7 +1813,8 @@ static void *netlink_seq_next(struct seq
27017 for (; j <= hash->mask; j++) {
27018 s = sk_head(&hash->table[j]);
27019 - while (s && sock_net(s) != seq_file_net(seq))
27020 + while (s && (sock_net(s) != seq_file_net(seq) ||
27021 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
27025 diff -NurpP --minimal linux-2.6.27.3/net/sctp/ipv6.c linux-2.6.27.3-vs2.3.0.35.7/net/sctp/ipv6.c
27026 --- linux-2.6.27.3/net/sctp/ipv6.c 2008-10-13 14:52:09.000000000 +0200
27027 +++ linux-2.6.27.3-vs2.3.0.35.7/net/sctp/ipv6.c 2008-10-13 14:54:20.000000000 +0200
27028 @@ -323,7 +323,8 @@ static void sctp_v6_get_saddr(struct sct
27029 dst ? ip6_dst_idev(dst)->dev : NULL,
27030 &daddr->v6.sin6_addr,
27031 inet6_sk(&sk->inet.sk)->srcprefs,
27032 - &saddr->v6.sin6_addr);
27033 + &saddr->v6.sin6_addr,
27034 + asoc->base.sk->sk_nx_info);
27035 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
27036 NIP6(saddr->v6.sin6_addr));
27038 diff -NurpP --minimal linux-2.6.27.3/net/socket.c linux-2.6.27.3-vs2.3.0.35.7/net/socket.c
27039 --- linux-2.6.27.3/net/socket.c 2008-10-13 14:52:09.000000000 +0200
27040 +++ linux-2.6.27.3-vs2.3.0.35.7/net/socket.c 2008-10-13 14:54:20.000000000 +0200
27043 #include <net/sock.h>
27044 #include <linux/netfilter.h>
27045 +#include <linux/vs_base.h>
27046 +#include <linux/vs_socket.h>
27047 +#include <linux/vs_inet.h>
27048 +#include <linux/vs_inet6.h>
27050 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
27051 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
27052 @@ -550,7 +554,7 @@ static inline int __sock_sendmsg(struct
27053 struct msghdr *msg, size_t size)
27055 struct sock_iocb *si = kiocb_to_siocb(iocb);
27061 @@ -561,7 +565,22 @@ static inline int __sock_sendmsg(struct
27065 - return sock->ops->sendmsg(iocb, sock, msg, size);
27066 + len = sock->ops->sendmsg(iocb, sock, msg, size);
27069 + vx_sock_send(sock->sk, size);
27071 + vx_sock_fail(sock->sk, size);
27073 + vxdprintk(VXD_CBIT(net, 7),
27074 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27076 + (sock->sk)?sock->sk->sk_nx_info:0,
27077 + (sock->sk)?sock->sk->sk_vx_info:0,
27078 + (sock->sk)?sock->sk->sk_xid:0,
27079 + (sock->sk)?sock->sk->sk_nid:0,
27080 + (unsigned int)size, len);
27084 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
27085 @@ -630,7 +649,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
27086 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
27087 struct msghdr *msg, size_t size, int flags)
27091 struct sock_iocb *si = kiocb_to_siocb(iocb);
27094 @@ -643,7 +662,18 @@ static inline int __sock_recvmsg(struct
27098 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
27099 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
27100 + if ((len >= 0) && sock->sk)
27101 + vx_sock_recv(sock->sk, len);
27102 + vxdprintk(VXD_CBIT(net, 7),
27103 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27105 + (sock->sk)?sock->sk->sk_nx_info:0,
27106 + (sock->sk)?sock->sk->sk_vx_info:0,
27107 + (sock->sk)?sock->sk->sk_xid:0,
27108 + (sock->sk)?sock->sk->sk_nid:0,
27109 + (unsigned int)size, len);
27113 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
27114 @@ -1108,6 +1138,13 @@ static int __sock_create(struct net *net
27115 if (type < 0 || type >= SOCK_MAX)
27118 + if (!nx_check(0, VS_ADMIN)) {
27119 + if (family == PF_INET && !current_nx_info_has_v4())
27120 + return -EAFNOSUPPORT;
27121 + if (family == PF_INET6 && !current_nx_info_has_v6())
27122 + return -EAFNOSUPPORT;
27127 This uglymoron is moved from INET layer to here to avoid
27128 @@ -1240,6 +1277,7 @@ asmlinkage long sys_socket(int family, i
27132 + set_bit(SOCK_USER_SOCKET, &sock->flags);
27133 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
27136 @@ -1281,10 +1319,12 @@ asmlinkage long sys_socketpair(int famil
27137 err = sock_create(family, type, protocol, &sock1);
27140 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
27142 err = sock_create(family, type, protocol, &sock2);
27144 goto out_release_1;
27145 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
27147 err = sock1->ops->socketpair(sock1, sock2);
27149 diff -NurpP --minimal linux-2.6.27.3/net/sunrpc/auth.c linux-2.6.27.3-vs2.3.0.35.7/net/sunrpc/auth.c
27150 --- linux-2.6.27.3/net/sunrpc/auth.c 2008-07-13 23:51:29.000000000 +0200
27151 +++ linux-2.6.27.3-vs2.3.0.35.7/net/sunrpc/auth.c 2008-10-13 14:54:20.000000000 +0200
27153 #include <linux/hash.h>
27154 #include <linux/sunrpc/clnt.h>
27155 #include <linux/spinlock.h>
27156 +#include <linux/vs_tag.h>
27159 # define RPCDBG_FACILITY RPCDBG_AUTH
27160 @@ -353,6 +354,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
27161 struct auth_cred acred = {
27162 .uid = current->fsuid,
27163 .gid = current->fsgid,
27164 + .tag = dx_current_tag(),
27165 .group_info = current->group_info,
27167 struct rpc_cred *ret;
27168 @@ -398,6 +400,7 @@ rpcauth_bind_root_cred(struct rpc_task *
27169 struct auth_cred acred = {
27172 + .tag = dx_current_tag(),
27174 struct rpc_cred *ret;
27176 diff -NurpP --minimal linux-2.6.27.3/net/sunrpc/auth_unix.c linux-2.6.27.3-vs2.3.0.35.7/net/sunrpc/auth_unix.c
27177 --- linux-2.6.27.3/net/sunrpc/auth_unix.c 2008-10-13 14:52:09.000000000 +0200
27178 +++ linux-2.6.27.3-vs2.3.0.35.7/net/sunrpc/auth_unix.c 2008-10-13 14:54:20.000000000 +0200
27179 @@ -11,12 +11,14 @@
27180 #include <linux/module.h>
27181 #include <linux/sunrpc/clnt.h>
27182 #include <linux/sunrpc/auth.h>
27183 +#include <linux/vs_tag.h>
27185 #define NFS_NGROUPS 16
27188 struct rpc_cred uc_base;
27191 gid_t uc_gids[NFS_NGROUPS];
27193 #define uc_uid uc_base.cr_uid
27194 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
27195 groups = NFS_NGROUPS;
27197 cred->uc_gid = acred->gid;
27198 + cred->uc_tag = acred->tag;
27199 for (i = 0; i < groups; i++)
27200 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
27201 if (i < NFS_NGROUPS)
27202 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
27206 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
27207 + if (cred->uc_uid != acred->uid ||
27208 + cred->uc_gid != acred->gid ||
27209 + cred->uc_tag != acred->tag)
27212 if (acred->group_info != NULL)
27213 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
27214 struct rpc_clnt *clnt = task->tk_client;
27215 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
27216 __be32 *base, *hold;
27220 *p++ = htonl(RPC_AUTH_UNIX);
27222 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
27223 * Copy the UTS nodename captured when the client was created.
27225 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
27226 + tag = task->tk_client->cl_tag;
27228 - *p++ = htonl((u32) cred->uc_uid);
27229 - *p++ = htonl((u32) cred->uc_gid);
27230 + *p++ = htonl((u32) TAGINO_UID(tag,
27231 + cred->uc_uid, cred->uc_tag));
27232 + *p++ = htonl((u32) TAGINO_GID(tag,
27233 + cred->uc_gid, cred->uc_tag));
27235 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
27236 *p++ = htonl((u32) cred->uc_gids[i]);
27237 diff -NurpP --minimal linux-2.6.27.3/net/sunrpc/clnt.c linux-2.6.27.3-vs2.3.0.35.7/net/sunrpc/clnt.c
27238 --- linux-2.6.27.3/net/sunrpc/clnt.c 2008-10-13 14:52:09.000000000 +0200
27239 +++ linux-2.6.27.3-vs2.3.0.35.7/net/sunrpc/clnt.c 2008-10-13 14:54:20.000000000 +0200
27241 #include <linux/utsname.h>
27242 #include <linux/workqueue.h>
27243 #include <linux/in6.h>
27244 +#include <linux/vs_cvirt.h>
27246 #include <linux/sunrpc/clnt.h>
27247 #include <linux/sunrpc/rpc_pipe_fs.h>
27248 @@ -327,6 +328,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
27249 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
27250 clnt->cl_chatty = 1;
27252 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
27253 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
27254 + clnt->cl_tag = 1; */
27257 EXPORT_SYMBOL_GPL(rpc_create);
27258 diff -NurpP --minimal linux-2.6.27.3/net/unix/af_unix.c linux-2.6.27.3-vs2.3.0.35.7/net/unix/af_unix.c
27259 --- linux-2.6.27.3/net/unix/af_unix.c 2008-10-13 14:52:10.000000000 +0200
27260 +++ linux-2.6.27.3-vs2.3.0.35.7/net/unix/af_unix.c 2008-10-13 14:54:20.000000000 +0200
27261 @@ -114,6 +114,8 @@
27262 #include <linux/mount.h>
27263 #include <net/checksum.h>
27264 #include <linux/security.h>
27265 +#include <linux/vs_context.h>
27266 +#include <linux/vs_limit.h>
27268 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
27269 static DEFINE_SPINLOCK(unix_table_lock);
27270 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
27271 if (!net_eq(sock_net(s), net))
27274 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27276 if (u->addr->len == len &&
27277 !memcmp(u->addr->name, sunname, len))
27279 @@ -2084,6 +2088,8 @@ static struct sock *unix_seq_idx(struct
27280 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
27281 if (sock_net(s) != seq_file_net(seq))
27283 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27288 @@ -2109,7 +2115,8 @@ static void *unix_seq_next(struct seq_fi
27289 sk = first_unix_socket(&iter->i);
27291 sk = next_unix_socket(&iter->i, sk);
27292 - while (sk && (sock_net(sk) != seq_file_net(seq)))
27293 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
27294 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
27295 sk = next_unix_socket(&iter->i, sk);
27298 diff -NurpP --minimal linux-2.6.27.3/net/x25/af_x25.c linux-2.6.27.3-vs2.3.0.35.7/net/x25/af_x25.c
27299 --- linux-2.6.27.3/net/x25/af_x25.c 2008-10-13 14:52:10.000000000 +0200
27300 +++ linux-2.6.27.3-vs2.3.0.35.7/net/x25/af_x25.c 2008-10-13 14:54:20.000000000 +0200
27301 @@ -506,7 +506,10 @@ static int x25_create(struct net *net, s
27305 - sock_init_data(sock, sk);
27306 + sk->sk_socket = sock;
27307 + sk->sk_type = sock->type;
27308 + sk->sk_sleep = &sock->wait;
27311 x25_init_timers(sk);
27313 diff -NurpP --minimal linux-2.6.27.3/scripts/checksyscalls.sh linux-2.6.27.3-vs2.3.0.35.7/scripts/checksyscalls.sh
27314 --- linux-2.6.27.3/scripts/checksyscalls.sh 2008-07-13 23:51:29.000000000 +0200
27315 +++ linux-2.6.27.3-vs2.3.0.35.7/scripts/checksyscalls.sh 2008-10-13 14:54:20.000000000 +0200
27316 @@ -108,7 +108,6 @@ cat << EOF
27317 #define __IGNORE_afs_syscall
27318 #define __IGNORE_getpmsg
27319 #define __IGNORE_putpmsg
27320 -#define __IGNORE_vserver
27324 diff -NurpP --minimal linux-2.6.27.3/security/commoncap.c linux-2.6.27.3-vs2.3.0.35.7/security/commoncap.c
27325 --- linux-2.6.27.3/security/commoncap.c 2008-10-13 14:52:10.000000000 +0200
27326 +++ linux-2.6.27.3-vs2.3.0.35.7/security/commoncap.c 2008-10-13 14:54:20.000000000 +0200
27327 @@ -26,10 +26,11 @@
27328 #include <linux/sched.h>
27329 #include <linux/prctl.h>
27330 #include <linux/securebits.h>
27331 +#include <linux/vs_context.h>
27333 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
27335 - NETLINK_CB(skb).eff_cap = current->cap_effective;
27336 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current->cap_effective);
27340 @@ -50,9 +51,24 @@ EXPORT_SYMBOL(cap_netlink_recv);
27342 int cap_capable (struct task_struct *tsk, int cap)
27344 + struct vx_info *vxi = tsk->vx_info;
27347 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
27348 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
27349 + cap_raised(tsk->cap_effective, cap),
27350 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
27353 + /* special case SETUP */
27354 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
27355 + cap_raised(tsk->cap_effective, cap))
27358 /* Derived from include/linux/sched.h:capable. */
27359 - if (cap_raised(tsk->cap_effective, cap))
27360 + if (vx_cap_raised(vxi, tsk->cap_effective, cap))
27366 @@ -696,7 +712,8 @@ void cap_task_reparent_to_init (struct t
27368 int cap_syslog (int type)
27370 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
27371 + if ((type != 3 && type != 10) &&
27372 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
27376 diff -NurpP --minimal linux-2.6.27.3/security/selinux/hooks.c linux-2.6.27.3-vs2.3.0.35.7/security/selinux/hooks.c
27377 --- linux-2.6.27.3/security/selinux/hooks.c 2008-10-13 14:52:10.000000000 +0200
27378 +++ linux-2.6.27.3-vs2.3.0.35.7/security/selinux/hooks.c 2008-10-13 14:54:20.000000000 +0200
27380 #include <linux/dccp.h>
27381 #include <linux/quota.h>
27382 #include <linux/un.h> /* for Unix socket types */
27383 -#include <net/af_unix.h> /* for Unix socket types */
27384 #include <linux/parser.h>
27385 #include <linux/nfs_mount.h>
27386 #include <net/ipv6.h>