1 diff -NurpP --minimal linux-2.6.27.6/arch/alpha/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/alpha/Kconfig
2 --- linux-2.6.27.6/arch/alpha/Kconfig 2008-10-13 14:51:51.000000000 +0200
3 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/alpha/kernel/entry.S linux-2.6.27.6-vs2.3.0.36/arch/alpha/kernel/entry.S
14 --- linux-2.6.27.6/arch/alpha/kernel/entry.S 2008-07-13 23:51:29.000000000 +0200
15 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/alpha/kernel/osf_sys.c linux-2.6.27.6-vs2.3.0.36/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.27.6/arch/alpha/kernel/osf_sys.c 2008-10-13 14:51:51.000000000 +0200
50 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/alpha/kernel/ptrace.c linux-2.6.27.6-vs2.3.0.36/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.27.6/arch/alpha/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
62 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/alpha/kernel/systbls.S linux-2.6.27.6-vs2.3.0.36/arch/alpha/kernel/systbls.S
72 --- linux-2.6.27.6/arch/alpha/kernel/systbls.S 2008-07-13 23:51:29.000000000 +0200
73 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/alpha/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/alpha/kernel/traps.c
84 --- linux-2.6.27.6/arch/alpha/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
85 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/alpha/mm/fault.c linux-2.6.27.6-vs2.3.0.36/arch/alpha/mm/fault.c
97 --- linux-2.6.27.6/arch/alpha/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
98 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/arm/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/arm/Kconfig
111 --- linux-2.6.27.6/arch/arm/Kconfig 2008-10-13 14:51:51.000000000 +0200
112 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/arm/kernel/calls.S linux-2.6.27.6-vs2.3.0.36/arch/arm/kernel/calls.S
123 --- linux-2.6.27.6/arch/arm/kernel/calls.S 2008-10-13 14:51:52.000000000 +0200
124 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/arm/kernel/process.c linux-2.6.27.6-vs2.3.0.36/arch/arm/kernel/process.c
135 --- linux-2.6.27.6/arch/arm/kernel/process.c 2008-10-13 14:51:52.000000000 +0200
136 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/arm/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/arm/kernel/traps.c
148 --- linux-2.6.27.6/arch/arm/kernel/traps.c 2008-10-13 14:51:52.000000000 +0200
149 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/arm/mm/fault.c linux-2.6.27.6-vs2.3.0.36/arch/arm/mm/fault.c
162 --- linux-2.6.27.6/arch/arm/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
163 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/cris/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/cris/Kconfig
175 --- linux-2.6.27.6/arch/cris/Kconfig 2008-07-13 23:51:29.000000000 +0200
176 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/frv/kernel/kernel_thread.S linux-2.6.27.6-vs2.3.0.36/arch/frv/kernel/kernel_thread.S
187 --- linux-2.6.27.6/arch/frv/kernel/kernel_thread.S 2008-07-13 23:51:29.000000000 +0200
188 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/h8300/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/h8300/Kconfig
199 --- linux-2.6.27.6/arch/h8300/Kconfig 2008-10-13 14:51:55.000000000 +0200
200 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/ia64/ia32/ia32_entry.S linux-2.6.27.6-vs2.3.0.36/arch/ia64/ia32/ia32_entry.S
211 --- linux-2.6.27.6/arch/ia64/ia32/ia32_entry.S 2008-10-13 14:51:55.000000000 +0200
212 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/ia64/ia32/sys_ia32.c linux-2.6.27.6-vs2.3.0.36/arch/ia64/ia32/sys_ia32.c
223 --- linux-2.6.27.6/arch/ia64/ia32/sys_ia32.c 2008-10-13 14:51:55.000000000 +0200
224 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/ia64/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/ia64/Kconfig
235 --- linux-2.6.27.6/arch/ia64/Kconfig 2008-10-13 14:51:55.000000000 +0200
236 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/ia64/kernel/entry.S linux-2.6.27.6-vs2.3.0.36/arch/ia64/kernel/entry.S
247 --- linux-2.6.27.6/arch/ia64/kernel/entry.S 2008-10-13 14:51:55.000000000 +0200
248 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/ia64/kernel/perfmon.c linux-2.6.27.6-vs2.3.0.36/arch/ia64/kernel/perfmon.c
259 --- linux-2.6.27.6/arch/ia64/kernel/perfmon.c 2008-10-13 14:51:55.000000000 +0200
260 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/ia64/kernel/process.c linux-2.6.27.6-vs2.3.0.36/arch/ia64/kernel/process.c
279 --- linux-2.6.27.6/arch/ia64/kernel/process.c 2008-10-13 14:51:55.000000000 +0200
280 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/ia64/kernel/ptrace.c linux-2.6.27.6-vs2.3.0.36/arch/ia64/kernel/ptrace.c
293 --- linux-2.6.27.6/arch/ia64/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
294 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/ia64/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/ia64/kernel/traps.c
304 --- linux-2.6.27.6/arch/ia64/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
305 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/ia64/mm/fault.c linux-2.6.27.6-vs2.3.0.36/arch/ia64/mm/fault.c
331 --- linux-2.6.27.6/arch/ia64/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
332 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/m32r/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/m32r/kernel/traps.c
342 --- linux-2.6.27.6/arch/m32r/kernel/traps.c 2008-10-13 14:51:55.000000000 +0200
343 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/m68k/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/m68k/Kconfig
357 --- linux-2.6.27.6/arch/m68k/Kconfig 2008-10-13 14:51:55.000000000 +0200
358 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/m68k/kernel/ptrace.c linux-2.6.27.6-vs2.3.0.36/arch/m68k/kernel/ptrace.c
369 --- linux-2.6.27.6/arch/m68k/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
370 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/m68k/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/m68k/kernel/traps.c
389 --- linux-2.6.27.6/arch/m68k/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
390 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/m68knommu/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/m68knommu/Kconfig
403 --- linux-2.6.27.6/arch/m68knommu/Kconfig 2008-10-13 14:51:55.000000000 +0200
404 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/m68knommu/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/m68knommu/kernel/traps.c
415 --- linux-2.6.27.6/arch/m68knommu/kernel/traps.c 2008-10-13 14:51:55.000000000 +0200
416 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/mips/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/mips/Kconfig
430 --- linux-2.6.27.6/arch/mips/Kconfig 2008-10-13 14:51:55.000000000 +0200
431 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/mips/kernel/linux32.c linux-2.6.27.6-vs2.3.0.36/arch/mips/kernel/linux32.c
442 --- linux-2.6.27.6/arch/mips/kernel/linux32.c 2008-10-13 14:51:56.000000000 +0200
443 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/mips/kernel/ptrace.c linux-2.6.27.6-vs2.3.0.36/arch/mips/kernel/ptrace.c
454 --- linux-2.6.27.6/arch/mips/kernel/ptrace.c 2008-10-13 14:51:56.000000000 +0200
455 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/mips/kernel/scall32-o32.S linux-2.6.27.6-vs2.3.0.36/arch/mips/kernel/scall32-o32.S
475 --- linux-2.6.27.6/arch/mips/kernel/scall32-o32.S 2008-10-13 14:51:56.000000000 +0200
476 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/mips/kernel/scall64-64.S linux-2.6.27.6-vs2.3.0.36/arch/mips/kernel/scall64-64.S
487 --- linux-2.6.27.6/arch/mips/kernel/scall64-64.S 2008-10-13 14:51:56.000000000 +0200
488 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/mips/kernel/scall64-n32.S linux-2.6.27.6-vs2.3.0.36/arch/mips/kernel/scall64-n32.S
499 --- linux-2.6.27.6/arch/mips/kernel/scall64-n32.S 2008-10-13 14:51:56.000000000 +0200
500 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/mips/kernel/scall64-o32.S linux-2.6.27.6-vs2.3.0.36/arch/mips/kernel/scall64-o32.S
511 --- linux-2.6.27.6/arch/mips/kernel/scall64-o32.S 2008-10-13 14:51:56.000000000 +0200
512 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/mips/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/mips/kernel/traps.c
523 --- linux-2.6.27.6/arch/mips/kernel/traps.c 2008-10-13 14:51:56.000000000 +0200
524 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/mips/mm/fault.c linux-2.6.27.6-vs2.3.0.36/arch/mips/mm/fault.c
540 --- linux-2.6.27.6/arch/mips/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
541 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/parisc/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/parisc/Kconfig
553 --- linux-2.6.27.6/arch/parisc/Kconfig 2008-10-13 14:51:56.000000000 +0200
554 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/parisc/kernel/syscall_table.S linux-2.6.27.6-vs2.3.0.36/arch/parisc/kernel/syscall_table.S
565 --- linux-2.6.27.6/arch/parisc/kernel/syscall_table.S 2008-07-13 23:51:29.000000000 +0200
566 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/parisc/kernel/sys_parisc32.c linux-2.6.27.6-vs2.3.0.36/arch/parisc/kernel/sys_parisc32.c
577 --- linux-2.6.27.6/arch/parisc/kernel/sys_parisc32.c 2008-07-13 23:51:29.000000000 +0200
578 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/parisc/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/parisc/kernel/traps.c
594 --- linux-2.6.27.6/arch/parisc/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
595 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/parisc/mm/fault.c linux-2.6.27.6-vs2.3.0.36/arch/parisc/mm/fault.c
620 --- linux-2.6.27.6/arch/parisc/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
621 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/powerpc/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/powerpc/Kconfig
645 --- linux-2.6.27.6/arch/powerpc/Kconfig 2008-10-13 14:51:56.000000000 +0200
646 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/powerpc/kernel/irq.c linux-2.6.27.6-vs2.3.0.36/arch/powerpc/kernel/irq.c
657 --- linux-2.6.27.6/arch/powerpc/kernel/irq.c 2008-10-13 14:51:56.000000000 +0200
658 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/powerpc/kernel/process.c linux-2.6.27.6-vs2.3.0.36/arch/powerpc/kernel/process.c
668 --- linux-2.6.27.6/arch/powerpc/kernel/process.c 2008-10-13 14:51:56.000000000 +0200
669 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/powerpc/kernel/sys_ppc32.c linux-2.6.27.6-vs2.3.0.36/arch/powerpc/kernel/sys_ppc32.c
683 --- linux-2.6.27.6/arch/powerpc/kernel/sys_ppc32.c 2008-10-13 14:51:56.000000000 +0200
684 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/powerpc/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/powerpc/kernel/traps.c
695 --- linux-2.6.27.6/arch/powerpc/kernel/traps.c 2008-10-13 14:51:56.000000000 +0200
696 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/powerpc/kernel/vdso.c linux-2.6.27.6-vs2.3.0.36/arch/powerpc/kernel/vdso.c
710 --- linux-2.6.27.6/arch/powerpc/kernel/vdso.c 2008-10-13 14:51:56.000000000 +0200
711 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/powerpc/mm/fault.c linux-2.6.27.6-vs2.3.0.36/arch/powerpc/mm/fault.c
721 --- linux-2.6.27.6/arch/powerpc/mm/fault.c 2008-10-13 14:51:56.000000000 +0200
722 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/s390/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/s390/Kconfig
734 --- linux-2.6.27.6/arch/s390/Kconfig 2008-10-13 14:51:57.000000000 +0200
735 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/s390/kernel/compat_linux.c linux-2.6.27.6-vs2.3.0.36/arch/s390/kernel/compat_linux.c
746 --- linux-2.6.27.6/arch/s390/kernel/compat_linux.c 2008-07-13 23:51:29.000000000 +0200
747 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/s390/kernel/ptrace.c linux-2.6.27.6-vs2.3.0.36/arch/s390/kernel/ptrace.c
758 --- linux-2.6.27.6/arch/s390/kernel/ptrace.c 2008-10-13 14:51:57.000000000 +0200
759 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/s390/kernel/syscalls.S linux-2.6.27.6-vs2.3.0.36/arch/s390/kernel/syscalls.S
769 --- linux-2.6.27.6/arch/s390/kernel/syscalls.S 2008-10-13 14:51:57.000000000 +0200
770 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/s390/mm/fault.c linux-2.6.27.6-vs2.3.0.36/arch/s390/mm/fault.c
781 --- linux-2.6.27.6/arch/s390/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
782 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sh/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/sh/Kconfig
794 --- linux-2.6.27.6/arch/sh/Kconfig 2008-10-13 14:51:57.000000000 +0200
795 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sh/kernel/irq.c linux-2.6.27.6-vs2.3.0.36/arch/sh/kernel/irq.c
806 --- linux-2.6.27.6/arch/sh/kernel/irq.c 2008-10-13 14:51:57.000000000 +0200
807 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.27.6-vs2.3.0.36/arch/sh/kernel/vsyscall/vsyscall.c
817 --- linux-2.6.27.6/arch/sh/kernel/vsyscall/vsyscall.c 2008-07-13 23:51:29.000000000 +0200
818 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/sparc/Kconfig
828 --- linux-2.6.27.6/arch/sparc/Kconfig 2008-10-13 14:51:58.000000000 +0200
829 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc/kernel/ptrace.c linux-2.6.27.6-vs2.3.0.36/arch/sparc/kernel/ptrace.c
840 --- linux-2.6.27.6/arch/sparc/kernel/ptrace.c 2008-10-13 14:51:58.000000000 +0200
841 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc/kernel/systbls.S linux-2.6.27.6-vs2.3.0.36/arch/sparc/kernel/systbls.S
851 --- linux-2.6.27.6/arch/sparc/kernel/systbls.S 2008-10-13 14:51:58.000000000 +0200
852 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/sparc/kernel/traps.c
863 --- linux-2.6.27.6/arch/sparc/kernel/traps.c 2008-10-13 14:51:58.000000000 +0200
864 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc/mm/fault.c linux-2.6.27.6-vs2.3.0.36/arch/sparc/mm/fault.c
876 --- linux-2.6.27.6/arch/sparc/mm/fault.c 2008-10-13 14:51:58.000000000 +0200
877 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc64/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/sparc64/Kconfig
889 --- linux-2.6.27.6/arch/sparc64/Kconfig 2008-10-13 14:51:58.000000000 +0200
890 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc64/kernel/ptrace.c linux-2.6.27.6-vs2.3.0.36/arch/sparc64/kernel/ptrace.c
901 --- linux-2.6.27.6/arch/sparc64/kernel/ptrace.c 2008-10-13 14:51:58.000000000 +0200
902 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc64/kernel/sys_sparc32.c linux-2.6.27.6-vs2.3.0.36/arch/sparc64/kernel/sys_sparc32.c
912 --- linux-2.6.27.6/arch/sparc64/kernel/sys_sparc32.c 2008-10-13 14:51:58.000000000 +0200
913 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc64/kernel/systbls.S linux-2.6.27.6-vs2.3.0.36/arch/sparc64/kernel/systbls.S
924 --- linux-2.6.27.6/arch/sparc64/kernel/systbls.S 2008-10-13 14:51:58.000000000 +0200
925 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc64/kernel/traps.c linux-2.6.27.6-vs2.3.0.36/arch/sparc64/kernel/traps.c
945 --- linux-2.6.27.6/arch/sparc64/kernel/traps.c 2008-10-13 14:51:58.000000000 +0200
946 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/sparc64/mm/fault.c linux-2.6.27.6-vs2.3.0.36/arch/sparc64/mm/fault.c
958 --- linux-2.6.27.6/arch/sparc64/mm/fault.c 2008-10-13 14:51:58.000000000 +0200
959 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/um/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/um/Kconfig
971 --- linux-2.6.27.6/arch/um/Kconfig 2008-07-13 23:51:29.000000000 +0200
972 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/um/kernel/trap.c linux-2.6.27.6-vs2.3.0.36/arch/um/kernel/trap.c
983 --- linux-2.6.27.6/arch/um/kernel/trap.c 2008-07-13 23:51:29.000000000 +0200
984 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/x86/ia32/ia32entry.S linux-2.6.27.6-vs2.3.0.36/arch/x86/ia32/ia32entry.S
996 --- linux-2.6.27.6/arch/x86/ia32/ia32entry.S 2008-10-13 14:51:58.000000000 +0200
997 +++ linux-2.6.27.6-vs2.3.0.36/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.6/arch/x86/Kconfig linux-2.6.27.6-vs2.3.0.36/arch/x86/Kconfig
1008 --- linux-2.6.27.6/arch/x86/Kconfig 2008-11-17 18:07:30.000000000 +0100
1009 +++ linux-2.6.27.6-vs2.3.0.36/arch/x86/Kconfig 2008-11-17 18:20:40.000000000 +0100
1010 @@ -1808,6 +1808,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.6/arch/x86/kernel/syscall_table_32.S linux-2.6.27.6-vs2.3.0.36/arch/x86/kernel/syscall_table_32.S
1020 --- linux-2.6.27.6/arch/x86/kernel/syscall_table_32.S 2008-10-13 14:51:58.000000000 +0200
1021 +++ linux-2.6.27.6-vs2.3.0.36/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.6/Documentation/vserver/debug.txt linux-2.6.27.6-vs2.3.0.36/Documentation/vserver/debug.txt
1032 --- linux-2.6.27.6/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1033 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/block/Kconfig linux-2.6.27.6-vs2.3.0.36/drivers/block/Kconfig
1190 --- linux-2.6.27.6/drivers/block/Kconfig 2008-10-13 14:51:59.000000000 +0200
1191 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/block/loop.c linux-2.6.27.6-vs2.3.0.36/drivers/block/loop.c
1207 --- linux-2.6.27.6/drivers/block/loop.c 2008-07-13 23:51:29.000000000 +0200
1208 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/block/Makefile linux-2.6.27.6-vs2.3.0.36/drivers/block/Makefile
1263 --- linux-2.6.27.6/drivers/block/Makefile 2008-10-13 14:51:59.000000000 +0200
1264 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/block/vroot.c linux-2.6.27.6-vs2.3.0.36/drivers/block/vroot.c
1273 --- linux-2.6.27.6/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1274 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/char/sysrq.c linux-2.6.27.6-vs2.3.0.36/drivers/char/sysrq.c
1560 --- linux-2.6.27.6/drivers/char/sysrq.c 2008-10-13 14:51:59.000000000 +0200
1561 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/char/tty_io.c linux-2.6.27.6-vs2.3.0.36/drivers/char/tty_io.c
1615 --- linux-2.6.27.6/drivers/char/tty_io.c 2008-11-17 18:07:31.000000000 +0100
1616 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.27.6-vs2.3.0.36/drivers/infiniband/hw/ipath/ipath_user_pages.c
1634 --- linux-2.6.27.6/drivers/infiniband/hw/ipath/ipath_user_pages.c 2008-07-13 23:51:29.000000000 +0200
1635 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/md/dm.c linux-2.6.27.6-vs2.3.0.36/drivers/md/dm.c
1682 --- linux-2.6.27.6/drivers/md/dm.c 2008-10-13 14:52:01.000000000 +0200
1683 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/md/dm.h linux-2.6.27.6-vs2.3.0.36/drivers/md/dm.h
1758 --- linux-2.6.27.6/drivers/md/dm.h 2008-10-13 14:52:01.000000000 +0200
1759 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/md/dm-ioctl.c linux-2.6.27.6-vs2.3.0.36/drivers/md/dm-ioctl.c
1770 --- linux-2.6.27.6/drivers/md/dm-ioctl.c 2008-07-13 23:51:29.000000000 +0200
1771 +++ linux-2.6.27.6-vs2.3.0.36/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.6/drivers/net/tun.c linux-2.6.27.6-vs2.3.0.36/drivers/net/tun.c
1854 --- linux-2.6.27.6/drivers/net/tun.c 2008-10-13 14:52:02.000000000 +0200
1855 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/attr.c linux-2.6.27.6-vs2.3.0.36/fs/attr.c
1926 --- linux-2.6.27.6/fs/attr.c 2008-10-13 14:52:05.000000000 +0200
1927 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/binfmt_aout.c linux-2.6.27.6-vs2.3.0.36/fs/binfmt_aout.c
1969 --- linux-2.6.27.6/fs/binfmt_aout.c 2008-10-13 14:52:05.000000000 +0200
1970 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/binfmt_elf.c linux-2.6.27.6-vs2.3.0.36/fs/binfmt_elf.c
1980 --- linux-2.6.27.6/fs/binfmt_elf.c 2008-10-13 14:52:05.000000000 +0200
1981 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/binfmt_flat.c linux-2.6.27.6-vs2.3.0.36/fs/binfmt_flat.c
1991 --- linux-2.6.27.6/fs/binfmt_flat.c 2008-10-13 14:52:05.000000000 +0200
1992 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/binfmt_som.c linux-2.6.27.6-vs2.3.0.36/fs/binfmt_som.c
2002 --- linux-2.6.27.6/fs/binfmt_som.c 2008-10-13 14:52:05.000000000 +0200
2003 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/block_dev.c linux-2.6.27.6-vs2.3.0.36/fs/block_dev.c
2013 --- linux-2.6.27.6/fs/block_dev.c 2008-10-13 14:52:05.000000000 +0200
2014 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/char_dev.c linux-2.6.27.6-vs2.3.0.36/fs/char_dev.c
2053 --- linux-2.6.27.6/fs/char_dev.c 2008-10-13 14:52:05.000000000 +0200
2054 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/dcache.c linux-2.6.27.6-vs2.3.0.36/fs/dcache.c
2088 --- linux-2.6.27.6/fs/dcache.c 2008-10-13 14:52:05.000000000 +0200
2089 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/devpts/inode.c linux-2.6.27.6-vs2.3.0.36/fs/devpts/inode.c
2142 --- linux-2.6.27.6/fs/devpts/inode.c 2008-10-13 14:52:05.000000000 +0200
2143 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/exec.c linux-2.6.27.6-vs2.3.0.36/fs/exec.c
2225 --- linux-2.6.27.6/fs/exec.c 2008-10-13 14:52:05.000000000 +0200
2226 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/balloc.c linux-2.6.27.6-vs2.3.0.36/fs/ext2/balloc.c
2248 --- linux-2.6.27.6/fs/ext2/balloc.c 2008-07-13 23:51:29.000000000 +0200
2249 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/ext2.h linux-2.6.27.6-vs2.3.0.36/fs/ext2/ext2.h
2308 --- linux-2.6.27.6/fs/ext2/ext2.h 2008-07-13 23:51:29.000000000 +0200
2309 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/file.c linux-2.6.27.6-vs2.3.0.36/fs/ext2/file.c
2319 --- linux-2.6.27.6/fs/ext2/file.c 2008-07-13 23:51:29.000000000 +0200
2320 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/ialloc.c linux-2.6.27.6-vs2.3.0.36/fs/ext2/ialloc.c
2328 --- linux-2.6.27.6/fs/ext2/ialloc.c 2008-07-13 23:51:29.000000000 +0200
2329 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/inode.c linux-2.6.27.6-vs2.3.0.36/fs/ext2/inode.c
2386 --- linux-2.6.27.6/fs/ext2/inode.c 2008-10-13 14:52:05.000000000 +0200
2387 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/ioctl.c linux-2.6.27.6-vs2.3.0.36/fs/ext2/ioctl.c
2548 --- linux-2.6.27.6/fs/ext2/ioctl.c 2008-07-13 23:51:29.000000000 +0200
2549 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/namei.c linux-2.6.27.6-vs2.3.0.36/fs/ext2/namei.c
2582 --- linux-2.6.27.6/fs/ext2/namei.c 2008-07-13 23:51:29.000000000 +0200
2583 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/super.c linux-2.6.27.6-vs2.3.0.36/fs/ext2/super.c
2615 --- linux-2.6.27.6/fs/ext2/super.c 2008-10-13 14:52:05.000000000 +0200
2616 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/symlink.c linux-2.6.27.6-vs2.3.0.36/fs/ext2/symlink.c
2682 --- linux-2.6.27.6/fs/ext2/symlink.c 2008-07-13 23:51:29.000000000 +0200
2683 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext2/xattr.c linux-2.6.27.6-vs2.3.0.36/fs/ext2/xattr.c
2699 --- linux-2.6.27.6/fs/ext2/xattr.c 2008-07-13 23:51:29.000000000 +0200
2700 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext3/balloc.c linux-2.6.27.6-vs2.3.0.36/fs/ext3/balloc.c
2739 --- linux-2.6.27.6/fs/ext3/balloc.c 2008-07-13 23:51:29.000000000 +0200
2740 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext3/file.c linux-2.6.27.6-vs2.3.0.36/fs/ext3/file.c
2848 --- linux-2.6.27.6/fs/ext3/file.c 2008-07-13 23:51:29.000000000 +0200
2849 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext3/ialloc.c linux-2.6.27.6-vs2.3.0.36/fs/ext3/ialloc.c
2858 --- linux-2.6.27.6/fs/ext3/ialloc.c 2008-10-13 14:52:05.000000000 +0200
2859 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext3/inode.c linux-2.6.27.6-vs2.3.0.36/fs/ext3/inode.c
2918 --- linux-2.6.27.6/fs/ext3/inode.c 2008-10-13 14:52:05.000000000 +0200
2919 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext3/ioctl.c linux-2.6.27.6-vs2.3.0.36/fs/ext3/ioctl.c
3128 --- linux-2.6.27.6/fs/ext3/ioctl.c 2008-07-13 23:51:29.000000000 +0200
3129 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext3/namei.c linux-2.6.27.6-vs2.3.0.36/fs/ext3/namei.c
3170 --- linux-2.6.27.6/fs/ext3/namei.c 2008-10-13 14:52:05.000000000 +0200
3171 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext3/super.c linux-2.6.27.6-vs2.3.0.36/fs/ext3/super.c
3203 --- linux-2.6.27.6/fs/ext3/super.c 2008-11-17 18:07:34.000000000 +0100
3204 +++ linux-2.6.27.6-vs2.3.0.36/fs/ext3/super.c 2008-11-17 18:20:41.000000000 +0100
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 @@ -2446,6 +2466,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.6/fs/ext3/symlink.c linux-2.6.27.6-vs2.3.0.36/fs/ext3/symlink.c
3270 --- linux-2.6.27.6/fs/ext3/symlink.c 2008-07-13 23:51:29.000000000 +0200
3271 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext3/xattr.c linux-2.6.27.6-vs2.3.0.36/fs/ext3/xattr.c
3287 --- linux-2.6.27.6/fs/ext3/xattr.c 2008-07-13 23:51:29.000000000 +0200
3288 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext4/balloc.c linux-2.6.27.6-vs2.3.0.36/fs/ext4/balloc.c
3331 --- linux-2.6.27.6/fs/ext4/balloc.c 2008-10-13 14:52:05.000000000 +0200
3332 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext4/ext4.h linux-2.6.27.6-vs2.3.0.36/fs/ext4/ext4.h
3381 --- linux-2.6.27.6/fs/ext4/ext4.h 2008-10-13 14:52:05.000000000 +0200
3382 +++ linux-2.6.27.6-vs2.3.0.36/fs/ext4/ext4.h 2008-10-31 18:15:18.000000000 +0100
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 0x04000000 /* 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.6/fs/ext4/file.c linux-2.6.27.6-vs2.3.0.36/fs/ext4/file.c
3413 --- linux-2.6.27.6/fs/ext4/file.c 2008-10-13 14:52:05.000000000 +0200
3414 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext4/ialloc.c linux-2.6.27.6-vs2.3.0.36/fs/ext4/ialloc.c
3423 --- linux-2.6.27.6/fs/ext4/ialloc.c 2008-10-13 14:52:05.000000000 +0200
3424 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext4/inode.c linux-2.6.27.6-vs2.3.0.36/fs/ext4/inode.c
3483 --- linux-2.6.27.6/fs/ext4/inode.c 2008-10-13 14:52:05.000000000 +0200
3484 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext4/ioctl.c linux-2.6.27.6-vs2.3.0.36/fs/ext4/ioctl.c
3695 --- linux-2.6.27.6/fs/ext4/ioctl.c 2008-07-13 23:51:29.000000000 +0200
3696 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext4/namei.c linux-2.6.27.6-vs2.3.0.36/fs/ext4/namei.c
3736 --- linux-2.6.27.6/fs/ext4/namei.c 2008-10-13 14:52:05.000000000 +0200
3737 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext4/super.c linux-2.6.27.6-vs2.3.0.36/fs/ext4/super.c
3769 --- linux-2.6.27.6/fs/ext4/super.c 2008-10-13 14:52:05.000000000 +0200
3770 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext4/symlink.c linux-2.6.27.6-vs2.3.0.36/fs/ext4/symlink.c
3835 --- linux-2.6.27.6/fs/ext4/symlink.c 2008-07-13 23:51:29.000000000 +0200
3836 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ext4/xattr.c linux-2.6.27.6-vs2.3.0.36/fs/ext4/xattr.c
3852 --- linux-2.6.27.6/fs/ext4/xattr.c 2008-10-13 14:52:05.000000000 +0200
3853 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/fcntl.c linux-2.6.27.6-vs2.3.0.36/fs/fcntl.c
3896 --- linux-2.6.27.6/fs/fcntl.c 2008-10-13 14:52:05.000000000 +0200
3897 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/file.c linux-2.6.27.6-vs2.3.0.36/fs/file.c
3925 --- linux-2.6.27.6/fs/file.c 2008-10-13 14:52:05.000000000 +0200
3926 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/file_table.c linux-2.6.27.6-vs2.3.0.36/fs/file_table.c
3953 --- linux-2.6.27.6/fs/file_table.c 2008-10-13 14:52:05.000000000 +0200
3954 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/hfsplus/ioctl.c linux-2.6.27.6-vs2.3.0.36/fs/hfsplus/ioctl.c
3992 --- linux-2.6.27.6/fs/hfsplus/ioctl.c 2008-07-13 23:51:29.000000000 +0200
3993 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/inode.c linux-2.6.27.6-vs2.3.0.36/fs/inode.c
4003 --- linux-2.6.27.6/fs/inode.c 2008-10-13 14:52:05.000000000 +0200
4004 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ioctl.c linux-2.6.27.6-vs2.3.0.36/fs/ioctl.c
4045 --- linux-2.6.27.6/fs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
4046 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/ioprio.c linux-2.6.27.6-vs2.3.0.36/fs/ioprio.c
4058 --- linux-2.6.27.6/fs/ioprio.c 2008-10-13 14:52:05.000000000 +0200
4059 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/acl.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/acl.c
4087 --- linux-2.6.27.6/fs/jfs/acl.c 2008-10-13 14:52:05.000000000 +0200
4088 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/file.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/file.c
4100 --- linux-2.6.27.6/fs/jfs/file.c 2008-07-13 23:51:29.000000000 +0200
4101 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/inode.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/inode.c
4111 --- linux-2.6.27.6/fs/jfs/inode.c 2008-07-13 23:51:29.000000000 +0200
4112 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/ioctl.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/ioctl.c
4130 --- linux-2.6.27.6/fs/jfs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
4131 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/jfs_dinode.h linux-2.6.27.6-vs2.3.0.36/fs/jfs/jfs_dinode.h
4164 --- linux-2.6.27.6/fs/jfs/jfs_dinode.h 2008-07-13 23:51:29.000000000 +0200
4165 +++ linux-2.6.27.6-vs2.3.0.36/fs/jfs/jfs_dinode.h 2008-10-31 18:15:18.000000000 +0100
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 0x04000000 /* 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.6/fs/jfs/jfs_dtree.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/jfs_dtree.c
4183 --- linux-2.6.27.6/fs/jfs/jfs_dtree.c 2008-07-13 23:51:29.000000000 +0200
4184 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/jfs_extent.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/jfs_extent.c
4297 --- linux-2.6.27.6/fs/jfs/jfs_extent.c 2008-07-13 23:51:29.000000000 +0200
4298 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/jfs_filsys.h linux-2.6.27.6-vs2.3.0.36/fs/jfs/jfs_filsys.h
4361 --- linux-2.6.27.6/fs/jfs/jfs_filsys.h 2008-07-13 23:51:29.000000000 +0200
4362 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/jfs_imap.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/jfs_imap.c
4372 --- linux-2.6.27.6/fs/jfs/jfs_imap.c 2008-10-13 14:52:05.000000000 +0200
4373 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/jfs_inode.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/jfs_inode.c
4434 --- linux-2.6.27.6/fs/jfs/jfs_inode.c 2008-07-13 23:51:29.000000000 +0200
4435 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/jfs_inode.h linux-2.6.27.6-vs2.3.0.36/fs/jfs/jfs_inode.h
4537 --- linux-2.6.27.6/fs/jfs/jfs_inode.h 2008-07-13 23:51:29.000000000 +0200
4538 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/jfs_xtree.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/jfs_xtree.c
4548 --- linux-2.6.27.6/fs/jfs/jfs_xtree.c 2008-10-13 14:52:05.000000000 +0200
4549 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/namei.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/namei.c
4634 --- linux-2.6.27.6/fs/jfs/namei.c 2008-10-13 14:52:05.000000000 +0200
4635 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/super.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/super.c
4661 --- linux-2.6.27.6/fs/jfs/super.c 2008-10-13 14:52:05.000000000 +0200
4662 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/jfs/xattr.c linux-2.6.27.6-vs2.3.0.36/fs/jfs/xattr.c
4730 --- linux-2.6.27.6/fs/jfs/xattr.c 2008-07-13 23:51:29.000000000 +0200
4731 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/libfs.c linux-2.6.27.6-vs2.3.0.36/fs/libfs.c
4810 --- linux-2.6.27.6/fs/libfs.c 2008-10-13 14:52:05.000000000 +0200
4811 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/locks.c linux-2.6.27.6-vs2.3.0.36/fs/locks.c
4859 --- linux-2.6.27.6/fs/locks.c 2008-10-13 14:52:05.000000000 +0200
4860 +++ linux-2.6.27.6-vs2.3.0.36/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.6/fs/namei.c linux-2.6.27.6-vs2.3.0.36/fs/namei.c
5047 --- linux-2.6.27.6/fs/namei.c 2008-10-13 14:52:05.000000000 +0200
5048 +++ linux-2.6.27.6-vs2.3.0.36/fs/namei.c 2008-11-12 18:45:34.000000000 +0100
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,77 @@ 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 +static int __dx_permission(struct inode *inode, int mask)
5079 + if (dx_barrier(inode))
5082 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
5083 + /* devpts is xid tagged */
5084 + if (S_ISDIR(inode->i_mode) ||
5085 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
5088 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
5089 + struct proc_dir_entry *de = PDE(inode);
5091 + if (de && !vx_hide_check(0, de->vx_flags))
5094 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
5096 + struct task_struct *tsk;
5098 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
5099 + vx_flags(VXF_STATE_SETUP, 0))
5102 + pid = PROC_I(inode)->pid;
5106 + tsk = pid_task(pid, PIDTYPE_PID);
5107 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
5108 + tsk, (tsk ? vx_task_xid(tsk) : 0));
5109 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
5113 + /* FIXME: Should we block some entries here? */
5118 + if (dx_notagcheck(inode->i_sb) ||
5119 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
5128 +int dx_permission(struct inode *inode, int mask)
5130 + int ret = __dx_permission(inode, mask);
5131 + if (unlikely(ret)) {
5132 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
5133 + mask, inode->i_sb->s_id, inode, inode->i_tag,
5141 * generic_permission - check for access rights on a Posix-like filesystem
5142 @@ -244,10 +323,14 @@ int inode_permission(struct inode *inode
5144 * Nobody gets write access to an immutable file.
5146 - if (IS_IMMUTABLE(inode))
5147 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5151 + retval = dx_permission(inode, mask);
5155 /* Ordinary permission routines do not understand MAY_APPEND. */
5156 if (inode->i_op && inode->i_op->permission) {
5157 retval = inode->i_op->permission(inode, mask);
5158 @@ -451,6 +534,8 @@ static int exec_permission_lite(struct i
5160 umode_t mode = inode->i_mode;
5162 + if (dx_barrier(inode))
5164 if (inode->i_op && inode->i_op->permission)
5167 @@ -773,7 +858,8 @@ static __always_inline void follow_dotdo
5168 if (nd->path.dentry == fs->root.dentry &&
5169 nd->path.mnt == fs->root.mnt) {
5170 read_unlock(&fs->lock);
5172 + /* for sane '/' avoid follow_mount() */
5175 read_unlock(&fs->lock);
5176 spin_lock(&dcache_lock);
5177 @@ -810,16 +896,30 @@ static int do_lookup(struct nameidata *n
5179 struct vfsmount *mnt = nd->path.mnt;
5180 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
5181 + struct inode *inode;
5185 if (dentry->d_op && dentry->d_op->d_revalidate)
5186 goto need_revalidate;
5187 + inode = dentry->d_inode;
5191 + if (__dx_permission(inode, MAY_ACCESS))
5196 path->dentry = dentry;
5197 __follow_mount(path);
5200 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s«.",
5201 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5202 + vxd_path(&nd->path));
5207 dentry = real_lookup(nd->path.dentry, name, nd);
5208 @@ -1407,7 +1507,7 @@ static int may_delete(struct inode *dir,
5211 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5212 - IS_IMMUTABLE(victim->d_inode))
5213 + IS_IXORUNLINK(victim->d_inode))
5216 if (!S_ISDIR(victim->d_inode->i_mode))
5217 @@ -1551,6 +1651,14 @@ int may_open(struct nameidata *nd, int a
5221 +#ifdef CONFIG_VSERVER_COWBL
5222 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5223 + if (IS_COW_LINK(inode))
5225 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5226 + mark_inode_dirty(inode);
5229 error = vfs_permission(nd, acc_mode);
5232 @@ -1677,6 +1785,11 @@ struct file *do_filp_open(int dfd, const
5234 int flag = open_to_namei_flags(open_flag);
5236 +#ifdef CONFIG_VSERVER_COWBL
5241 acc_mode = MAY_OPEN | ACC_MODE(flag);
5243 /* O_TRUNC implies we need access checks for write permissions */
5244 @@ -1800,6 +1913,25 @@ ok:
5247 error = may_open(&nd, acc_mode, flag);
5248 +#ifdef CONFIG_VSERVER_COWBL
5249 + if (error == -EMLINK) {
5250 + struct dentry *dentry;
5251 + dentry = cow_break_link(pathname);
5252 + if (IS_ERR(dentry)) {
5253 + error = PTR_ERR(dentry);
5258 + mnt_drop_write(nd.path.mnt);
5259 + release_open_intent(&nd);
5260 + path_put(&nd.path);
5269 mnt_drop_write(nd.path.mnt);
5270 @@ -1952,9 +2084,17 @@ int vfs_mknod(struct inode *dir, struct
5274 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5275 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5278 + if (!capable(CAP_MKNOD))
5281 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5283 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5286 if (!dir->i_op || !dir->i_op->mknod)
5289 @@ -2395,7 +2535,7 @@ int vfs_link(struct dentry *old_dentry,
5291 * A link to an append-only or immutable file cannot be created.
5293 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5294 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5296 if (!dir->i_op || !dir->i_op->link)
5298 @@ -2756,6 +2896,217 @@ int vfs_follow_link(struct nameidata *nd
5299 return __vfs_follow_link(nd, link);
5303 +#ifdef CONFIG_VSERVER_COWBL
5305 +#include <linux/file.h>
5308 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5312 + return do_splice_direct(in, &ppos, out, len, 0);
5315 +struct dentry *cow_break_link(const char *pathname)
5317 + int ret, mode, pathlen, redo = 0;
5318 + struct nameidata old_nd, dir_nd;
5319 + struct path old_path, new_path;
5320 + struct dentry *dir, *res = NULL;
5321 + struct file *old_file;
5322 + struct file *new_file;
5323 + char *to, *path, pad='\251';
5326 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5327 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5332 + /* old_nd will have refs to dentry and mnt */
5333 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5334 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5336 + goto out_free_path;
5338 + old_path = old_nd.path;
5339 + mode = old_path.dentry->d_inode->i_mode;
5341 + to = d_path(&old_path, path, PATH_MAX-2);
5342 + pathlen = strlen(to);
5343 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5344 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5345 + old_path.dentry->d_name.len);
5347 + to[pathlen + 1] = 0;
5349 + to[pathlen] = pad--;
5351 + if (pad <= '\240')
5354 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5355 + /* dir_nd will have refs to dentry and mnt */
5356 + ret = path_lookup(to,
5357 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5358 + vxdprintk(VXD_CBIT(misc, 2),
5359 + "path_lookup(new): %d", ret);
5363 + /* this puppy downs the inode mutex */
5364 + new_path.dentry = lookup_create(&dir_nd, 0);
5365 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5366 + vxdprintk(VXD_CBIT(misc, 2),
5367 + "lookup_create(new): %p", new_path.dentry);
5368 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5369 + path_put(&dir_nd.path);
5372 + vxdprintk(VXD_CBIT(misc, 2),
5373 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5374 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5375 + new_path.dentry->d_name.len);
5376 + dir = dir_nd.path.dentry;
5378 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5379 + vxdprintk(VXD_CBIT(misc, 2),
5380 + "vfs_create(new): %d", ret);
5381 + if (ret == -EEXIST) {
5382 + mutex_unlock(&dir->d_inode->i_mutex);
5383 + dput(new_path.dentry);
5384 + path_put(&dir_nd.path);
5388 + goto out_unlock_new;
5390 + /* drop out early, ret passes ENOENT */
5392 + if ((redo = d_unhashed(old_path.dentry)))
5393 + goto out_unlock_new;
5395 + new_path.mnt = dir_nd.path.mnt;
5396 + dget(old_path.dentry);
5397 + mntget(old_path.mnt);
5398 + /* this one cleans up the dentry/mnt in case of failure */
5399 + old_file = dentry_open(old_path.dentry, old_path.mnt, O_RDONLY);
5400 + vxdprintk(VXD_CBIT(misc, 2),
5401 + "dentry_open(old): %p", old_file);
5402 + if (!old_file || IS_ERR(old_file)) {
5403 + res = IS_ERR(old_file) ? (void *) old_file : res;
5404 + goto out_unlock_new;
5407 + dget(new_path.dentry);
5408 + mntget(new_path.mnt);
5409 + /* this one cleans up the dentry/mnt in case of failure */
5410 + new_file = dentry_open(new_path.dentry, new_path.mnt, O_WRONLY);
5411 + vxdprintk(VXD_CBIT(misc, 2),
5412 + "dentry_open(new): %p", new_file);
5414 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5415 + if (!new_file || IS_ERR(new_file))
5416 + goto out_fput_old;
5418 + size = i_size_read(old_file->f_dentry->d_inode);
5419 + ret = do_cow_splice(old_file, new_file, size);
5420 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5422 + goto out_fput_both;
5423 + } else if (ret < size) {
5425 + goto out_fput_both;
5427 + struct inode *old_inode = old_path.dentry->d_inode;
5428 + struct inode *new_inode = new_path.dentry->d_inode;
5429 + struct iattr attr = {
5430 + .ia_uid = old_inode->i_uid,
5431 + .ia_gid = old_inode->i_gid,
5432 + .ia_valid = ATTR_UID | ATTR_GID
5435 + ret = inode_setattr(new_inode, &attr);
5437 + goto out_fput_both;
5440 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5442 + /* drop out late */
5444 + if ((redo = d_unhashed(old_path.dentry)))
5447 + vxdprintk(VXD_CBIT(misc, 2),
5448 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5449 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5450 + new_path.dentry->d_name.len,
5451 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5452 + old_path.dentry->d_name.len);
5453 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5454 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5455 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5456 + res = new_path.dentry;
5459 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5462 + vxdprintk(VXD_CBIT(misc, 3),
5463 + "fput(new_file=%p[#%ld])", new_file,
5464 + atomic_read(&new_file->f_count));
5468 + vxdprintk(VXD_CBIT(misc, 3),
5469 + "fput(old_file=%p[#%ld])", old_file,
5470 + atomic_read(&old_file->f_count));
5474 + mutex_unlock(&dir->d_inode->i_mutex);
5478 + /* error path cleanup */
5479 + vfs_unlink(dir->d_inode, new_path.dentry);
5480 + dput(new_path.dentry);
5484 + goto out_rel_both;
5485 + /* lookup dentry once again */
5486 + path_put(&old_nd.path);
5487 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5489 + goto out_rel_both;
5491 + new_path.dentry = old_nd.path.dentry;
5492 + vxdprintk(VXD_CBIT(misc, 2),
5493 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5494 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5495 + new_path.dentry->d_name.len);
5496 + dget(new_path.dentry);
5497 + res = new_path.dentry;
5500 + path_put(&dir_nd.path);
5502 + path_put(&old_nd.path);
5507 + res = ERR_PTR(ret);
5513 /* get the link contents into pagecache */
5514 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5516 diff -NurpP --minimal linux-2.6.27.6/fs/namespace.c linux-2.6.27.6-vs2.3.0.36/fs/namespace.c
5517 --- linux-2.6.27.6/fs/namespace.c 2008-10-13 14:52:05.000000000 +0200
5518 +++ linux-2.6.27.6-vs2.3.0.36/fs/namespace.c 2008-10-24 03:34:52.000000000 +0200
5520 #include <linux/ramfs.h>
5521 #include <linux/log2.h>
5522 #include <linux/idr.h>
5523 +#include <linux/vs_base.h>
5524 +#include <linux/vs_context.h>
5525 +#include <linux/vs_tag.h>
5526 +#include <linux/vserver/space.h>
5527 +#include <linux/vserver/global.h>
5528 #include <asm/uaccess.h>
5529 #include <asm/unistd.h>
5531 @@ -573,6 +578,7 @@ static struct vfsmount *clone_mnt(struct
5532 mnt->mnt_root = dget(root);
5533 mnt->mnt_mountpoint = mnt->mnt_root;
5534 mnt->mnt_parent = mnt;
5535 + mnt->mnt_tag = old->mnt_tag;
5537 if (flag & CL_SLAVE) {
5538 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5539 @@ -685,6 +691,31 @@ static inline void mangle(struct seq_fil
5540 seq_escape(m, s, " \t\n\\");
5543 +static int mnt_is_reachable(struct vfsmount *mnt)
5546 + struct dentry *point;
5549 + if (mnt == mnt->mnt_ns->root)
5552 + spin_lock(&vfsmount_lock);
5553 + root = current->fs->root;
5554 + point = root.dentry;
5556 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5557 + point = mnt->mnt_mountpoint;
5558 + mnt = mnt->mnt_parent;
5561 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5563 + spin_unlock(&vfsmount_lock);
5569 * Simple .show_options callback for filesystems which don't want to
5570 * implement more complex mount option showing.
5571 @@ -757,6 +788,8 @@ static int show_sb_opts(struct seq_file
5572 { MS_SYNCHRONOUS, ",sync" },
5573 { MS_DIRSYNC, ",dirsync" },
5574 { MS_MANDLOCK, ",mand" },
5575 + { MS_TAGGED, ",tag" },
5576 + { MS_NOTAGCHECK, ",notagcheck" },
5579 const struct proc_fs_info *fs_infop;
5580 @@ -803,10 +836,20 @@ static int show_vfsmnt(struct seq_file *
5582 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5584 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5586 - seq_path(m, &mnt_path, " \t\n\\");
5588 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5590 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5593 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5594 + mnt == current->fs->root.mnt) {
5595 + seq_puts(m, "/dev/root / ");
5597 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5599 + seq_path(m, &mnt_path, " \t\n\\");
5602 show_type(m, mnt->mnt_sb);
5603 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5604 err = show_sb_opts(m, mnt->mnt_sb);
5605 @@ -836,6 +879,11 @@ static int show_mountinfo(struct seq_fil
5606 struct path root = p->root;
5609 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5611 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5614 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5615 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5616 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5617 @@ -894,17 +942,27 @@ static int show_vfsstat(struct seq_file
5618 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5622 - if (mnt->mnt_devname) {
5623 - seq_puts(m, "device ");
5624 - mangle(m, mnt->mnt_devname);
5626 - seq_puts(m, "no device");
5627 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5629 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5633 - seq_puts(m, " mounted on ");
5634 - seq_path(m, &mnt_path, " \t\n\\");
5636 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5637 + mnt == current->fs->root.mnt) {
5638 + seq_puts(m, "device /dev/root mounted on / ");
5641 + if (mnt->mnt_devname) {
5642 + seq_puts(m, "device ");
5643 + mangle(m, mnt->mnt_devname);
5645 + seq_puts(m, "no device");
5648 + seq_puts(m, " mounted on ");
5649 + seq_path(m, &mnt_path, " \t\n\\");
5653 /* file system type */
5654 seq_puts(m, "with fstype ");
5655 @@ -1143,7 +1201,7 @@ asmlinkage long sys_umount(char __user *
5659 - if (!capable(CAP_SYS_ADMIN))
5660 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5663 retval = do_umount(path.mnt, flags);
5664 @@ -1169,7 +1227,7 @@ asmlinkage long sys_oldumount(char __use
5666 static int mount_is_safe(struct nameidata *nd)
5668 - if (capable(CAP_SYS_ADMIN))
5669 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5673 @@ -1462,11 +1520,13 @@ static noinline int do_change_type(struc
5674 * noinline this do_mount helper to save do_mount stack space.
5676 static noinline int do_loopback(struct nameidata *nd, char *old_name,
5678 + tag_t tag, unsigned long flags, int mnt_flags)
5680 struct nameidata old_nd;
5681 struct vfsmount *mnt = NULL;
5682 int err = mount_is_safe(nd);
5683 + int recurse = flags & MS_REC;
5687 if (!old_name || !*old_name)
5688 @@ -1500,6 +1560,7 @@ static noinline int do_loopback(struct n
5689 spin_unlock(&vfsmount_lock);
5690 release_mounts(&umount_list);
5692 + mnt->mnt_flags = mnt_flags;
5695 up_write(&namespace_sem);
5696 @@ -1531,12 +1592,12 @@ static int change_mount_flags(struct vfs
5697 * noinline this do_mount helper to save do_mount stack space.
5699 static noinline int do_remount(struct nameidata *nd, int flags, int mnt_flags,
5701 + void *data, xid_t xid)
5704 struct super_block *sb = nd->path.mnt->mnt_sb;
5706 - if (!capable(CAP_SYS_ADMIN))
5707 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5710 if (!check_mnt(nd->path.mnt))
5711 @@ -1577,7 +1638,7 @@ static noinline int do_move_mount(struct
5712 struct path parent_path;
5715 - if (!capable(CAP_SYS_ADMIN))
5716 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5718 if (!old_name || !*old_name)
5720 @@ -1660,7 +1721,7 @@ static noinline int do_new_mount(struct
5723 /* we need capabilities... */
5724 - if (!capable(CAP_SYS_ADMIN))
5725 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5728 mnt = do_kern_mount(type, flags, name, data);
5729 @@ -1905,6 +1966,7 @@ long do_mount(char *dev_name, char *dir_
5730 struct nameidata nd;
5736 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5737 @@ -1920,6 +1982,12 @@ long do_mount(char *dev_name, char *dir_
5739 ((char *)data_page)[PAGE_SIZE - 1] = 0;
5741 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5742 + /* FIXME: bind and re-mounts get the tag flag? */
5743 + if (flags & (MS_BIND|MS_REMOUNT))
5744 + flags |= MS_TAGID;
5747 /* Separate the per-mountpoint flags */
5748 if (flags & MS_NOSUID)
5749 mnt_flags |= MNT_NOSUID;
5750 @@ -1936,6 +2004,8 @@ long do_mount(char *dev_name, char *dir_
5751 if (flags & MS_RDONLY)
5752 mnt_flags |= MNT_READONLY;
5754 + if (!capable(CAP_SYS_ADMIN))
5755 + mnt_flags |= MNT_NODEV;
5756 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5757 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT);
5759 @@ -1951,9 +2021,9 @@ long do_mount(char *dev_name, char *dir_
5761 if (flags & MS_REMOUNT)
5762 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
5765 else if (flags & MS_BIND)
5766 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
5767 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
5768 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5769 retval = do_change_type(&nd, flags);
5770 else if (flags & MS_MOVE)
5771 @@ -2022,6 +2092,7 @@ static struct mnt_namespace *dup_mnt_ns(
5772 q = next_mnt(q, new_ns->root);
5774 up_write(&namespace_sem);
5775 + atomic_inc(&vs_global_mnt_ns);
5779 @@ -2350,5 +2421,6 @@ void __put_mnt_ns(struct mnt_namespace *
5780 spin_unlock(&vfsmount_lock);
5781 up_write(&namespace_sem);
5782 release_mounts(&umount_list);
5783 + atomic_dec(&vs_global_mnt_ns);
5786 diff -NurpP --minimal linux-2.6.27.6/fs/nfs/client.c linux-2.6.27.6-vs2.3.0.36/fs/nfs/client.c
5787 --- linux-2.6.27.6/fs/nfs/client.c 2008-10-13 14:52:05.000000000 +0200
5788 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfs/client.c 2008-10-13 14:54:20.000000000 +0200
5789 @@ -601,6 +601,9 @@ static int nfs_init_server_rpcclient(str
5790 if (server->flags & NFS_MOUNT_SOFT)
5791 server->client->cl_softrtry = 1;
5793 + server->client->cl_tag = 0;
5794 + if (server->flags & NFS_MOUNT_TAGGED)
5795 + server->client->cl_tag = 1;
5799 @@ -766,6 +769,10 @@ static void nfs_server_set_fsinfo(struct
5800 server->acdirmin = server->acdirmax = 0;
5803 + /* FIXME: needs fsinfo
5804 + if (server->flags & NFS_MOUNT_TAGGED)
5805 + sb->s_flags |= MS_TAGGED; */
5807 server->maxfilesize = fsinfo->maxfilesize;
5809 /* We're airborne Set socket buffersize */
5810 diff -NurpP --minimal linux-2.6.27.6/fs/nfs/dir.c linux-2.6.27.6-vs2.3.0.36/fs/nfs/dir.c
5811 --- linux-2.6.27.6/fs/nfs/dir.c 2008-10-13 14:52:05.000000000 +0200
5812 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfs/dir.c 2008-10-13 14:54:20.000000000 +0200
5814 #include <linux/namei.h>
5815 #include <linux/mount.h>
5816 #include <linux/sched.h>
5817 +#include <linux/vs_tag.h>
5819 #include "nfs4_fs.h"
5820 #include "delegation.h"
5821 @@ -938,6 +939,7 @@ static struct dentry *nfs_lookup(struct
5823 goto out_unblock_sillyrename;
5825 + dx_propagate_tag(nd, inode);
5827 res = d_materialise_unique(dentry, inode);
5829 diff -NurpP --minimal linux-2.6.27.6/fs/nfs/inode.c linux-2.6.27.6-vs2.3.0.36/fs/nfs/inode.c
5830 --- linux-2.6.27.6/fs/nfs/inode.c 2008-10-13 14:52:05.000000000 +0200
5831 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfs/inode.c 2008-10-13 14:54:20.000000000 +0200
5833 #include <linux/vfs.h>
5834 #include <linux/inet.h>
5835 #include <linux/nfs_xdr.h>
5836 +#include <linux/vs_tag.h>
5838 #include <asm/system.h>
5839 #include <asm/uaccess.h>
5840 @@ -314,8 +315,10 @@ nfs_fhget(struct super_block *sb, struct
5841 nfsi->change_attr = fattr->change_attr;
5842 inode->i_size = nfs_size_to_loff_t(fattr->size);
5843 inode->i_nlink = fattr->nlink;
5844 - inode->i_uid = fattr->uid;
5845 - inode->i_gid = fattr->gid;
5846 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5847 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5848 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5849 + /* maybe fattr->xid someday */
5850 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5852 * report the blocks in 512byte units
5853 @@ -462,6 +465,8 @@ void nfs_setattr_update_inode(struct ino
5854 inode->i_uid = attr->ia_uid;
5855 if ((attr->ia_valid & ATTR_GID) != 0)
5856 inode->i_gid = attr->ia_gid;
5857 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5858 + inode->i_tag = attr->ia_tag;
5859 spin_lock(&inode->i_lock);
5860 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5861 spin_unlock(&inode->i_lock);
5862 @@ -900,6 +905,9 @@ static int nfs_check_inode_attributes(st
5863 struct nfs_inode *nfsi = NFS_I(inode);
5864 loff_t cur_size, new_isize;
5865 unsigned long invalid = 0;
5871 /* Has the inode gone and changed behind our back? */
5872 @@ -924,10 +932,15 @@ static int nfs_check_inode_attributes(st
5873 if (cur_size != new_isize && nfsi->npages == 0)
5874 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5876 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5877 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5878 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5880 /* Have any file permissions changed? */
5881 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
5882 - || inode->i_uid != fattr->uid
5883 - || inode->i_gid != fattr->gid)
5884 + || inode->i_uid != uid
5885 + || inode->i_gid != gid
5886 + || inode->i_tag != tag)
5887 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5889 /* Has the link count changed? */
5890 @@ -1048,6 +1061,9 @@ static int nfs_update_inode(struct inode
5891 loff_t cur_isize, new_isize;
5892 unsigned long invalid = 0;
5893 unsigned long now = jiffies;
5898 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5899 __func__, inode->i_sb->s_id, inode->i_ino,
5900 @@ -1121,15 +1137,21 @@ static int nfs_update_inode(struct inode
5901 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5902 nfsi->change_attr = fattr->change_attr;
5904 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5905 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5906 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5908 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
5909 - inode->i_uid != fattr->uid ||
5910 - inode->i_gid != fattr->gid)
5911 + inode->i_uid != uid ||
5912 + inode->i_gid != gid ||
5913 + inode->i_tag != tag)
5914 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5916 inode->i_mode = fattr->mode;
5917 inode->i_nlink = fattr->nlink;
5918 - inode->i_uid = fattr->uid;
5919 - inode->i_gid = fattr->gid;
5920 + inode->i_uid = uid;
5921 + inode->i_gid = gid;
5922 + inode->i_tag = tag;
5924 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5926 diff -NurpP --minimal linux-2.6.27.6/fs/nfs/nfs3xdr.c linux-2.6.27.6-vs2.3.0.36/fs/nfs/nfs3xdr.c
5927 --- linux-2.6.27.6/fs/nfs/nfs3xdr.c 2008-07-13 23:51:29.000000000 +0200
5928 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfs/nfs3xdr.c 2008-10-13 14:54:20.000000000 +0200
5930 #include <linux/nfs3.h>
5931 #include <linux/nfs_fs.h>
5932 #include <linux/nfsacl.h>
5933 +#include <linux/vs_tag.h>
5934 #include "internal.h"
5936 #define NFSDBG_FACILITY NFSDBG_XDR
5937 @@ -180,7 +181,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5940 static inline __be32 *
5941 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5942 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5944 if (attr->ia_valid & ATTR_MODE) {
5946 @@ -188,15 +189,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5950 - if (attr->ia_valid & ATTR_UID) {
5951 + if (attr->ia_valid & ATTR_UID ||
5952 + (tag && (attr->ia_valid & ATTR_TAG))) {
5954 - *p++ = htonl(attr->ia_uid);
5955 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5959 - if (attr->ia_valid & ATTR_GID) {
5960 + if (attr->ia_valid & ATTR_GID ||
5961 + (tag && (attr->ia_valid & ATTR_TAG))) {
5963 - *p++ = htonl(attr->ia_gid);
5964 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5968 @@ -281,7 +284,8 @@ static int
5969 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5971 p = xdr_encode_fhandle(p, args->fh);
5972 - p = xdr_encode_sattr(p, args->sattr);
5973 + p = xdr_encode_sattr(p, args->sattr,
5974 + req->rq_task->tk_client->cl_tag);
5975 *p++ = htonl(args->guard);
5977 p = xdr_encode_time3(p, &args->guardtime);
5978 @@ -386,7 +390,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5979 *p++ = args->verifier[0];
5980 *p++ = args->verifier[1];
5982 - p = xdr_encode_sattr(p, args->sattr);
5983 + p = xdr_encode_sattr(p, args->sattr,
5984 + req->rq_task->tk_client->cl_tag);
5986 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5988 @@ -400,7 +405,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5990 p = xdr_encode_fhandle(p, args->fh);
5991 p = xdr_encode_array(p, args->name, args->len);
5992 - p = xdr_encode_sattr(p, args->sattr);
5993 + p = xdr_encode_sattr(p, args->sattr,
5994 + req->rq_task->tk_client->cl_tag);
5995 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5998 @@ -413,7 +419,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
6000 p = xdr_encode_fhandle(p, args->fromfh);
6001 p = xdr_encode_array(p, args->fromname, args->fromlen);
6002 - p = xdr_encode_sattr(p, args->sattr);
6003 + p = xdr_encode_sattr(p, args->sattr,
6004 + req->rq_task->tk_client->cl_tag);
6005 *p++ = htonl(args->pathlen);
6006 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6008 @@ -431,7 +438,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
6009 p = xdr_encode_fhandle(p, args->fh);
6010 p = xdr_encode_array(p, args->name, args->len);
6011 *p++ = htonl(args->type);
6012 - p = xdr_encode_sattr(p, args->sattr);
6013 + p = xdr_encode_sattr(p, args->sattr,
6014 + req->rq_task->tk_client->cl_tag);
6015 if (args->type == NF3CHR || args->type == NF3BLK) {
6016 *p++ = htonl(MAJOR(args->rdev));
6017 *p++ = htonl(MINOR(args->rdev));
6018 diff -NurpP --minimal linux-2.6.27.6/fs/nfs/nfsroot.c linux-2.6.27.6-vs2.3.0.36/fs/nfs/nfsroot.c
6019 --- linux-2.6.27.6/fs/nfs/nfsroot.c 2008-10-13 14:52:05.000000000 +0200
6020 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfs/nfsroot.c 2008-10-13 14:54:20.000000000 +0200
6021 @@ -117,12 +117,12 @@ static int mount_port __initdata = 0; /
6023 /* Options that take integer arguments */
6024 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
6025 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
6026 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
6027 /* Options that take no arguments */
6028 Opt_soft, Opt_hard, Opt_intr,
6029 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
6030 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
6031 - Opt_acl, Opt_noacl,
6032 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
6036 @@ -159,6 +159,9 @@ static match_table_t __initdata tokens =
6039 {Opt_noacl, "noacl"},
6041 + {Opt_notag, "notag"},
6042 + {Opt_tagid, "tagid=%u"},
6046 @@ -270,6 +273,20 @@ static int __init root_nfs_parse(char *n
6048 nfs_data.flags |= NFS_MOUNT_NOACL;
6050 +#ifndef CONFIG_TAGGING_NONE
6052 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6055 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
6058 +#ifdef CONFIG_PROPAGATE
6061 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6065 printk(KERN_WARNING "Root-NFS: unknown "
6067 diff -NurpP --minimal linux-2.6.27.6/fs/nfs/super.c linux-2.6.27.6-vs2.3.0.36/fs/nfs/super.c
6068 --- linux-2.6.27.6/fs/nfs/super.c 2008-10-13 14:52:05.000000000 +0200
6069 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfs/super.c 2008-10-13 14:54:20.000000000 +0200
6071 #include <linux/nfs_xdr.h>
6072 #include <linux/magic.h>
6073 #include <linux/parser.h>
6074 +#include <linux/vs_tag.h>
6076 #include <asm/system.h>
6077 #include <asm/uaccess.h>
6078 @@ -504,6 +505,7 @@ static void nfs_show_mount_options(struc
6079 { NFS_MOUNT_NOACL, ",noacl", "" },
6080 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6081 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
6082 + { NFS_MOUNT_TAGGED, ",tag", "" },
6085 const struct proc_nfs_info *nfs_infop;
6086 diff -NurpP --minimal linux-2.6.27.6/fs/nfsd/auth.c linux-2.6.27.6-vs2.3.0.36/fs/nfsd/auth.c
6087 --- linux-2.6.27.6/fs/nfsd/auth.c 2008-07-13 23:51:29.000000000 +0200
6088 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfsd/auth.c 2008-10-13 14:54:20.000000000 +0200
6090 #include <linux/sunrpc/svcauth.h>
6091 #include <linux/nfsd/nfsd.h>
6092 #include <linux/nfsd/export.h>
6093 +#include <linux/vs_tag.h>
6096 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
6097 @@ -55,19 +56,23 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6098 get_group_info(cred.cr_group_info);
6100 if (cred.cr_uid != (uid_t) -1)
6101 - current->fsuid = cred.cr_uid;
6102 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6104 current->fsuid = exp->ex_anon_uid;
6105 if (cred.cr_gid != (gid_t) -1)
6106 - current->fsgid = cred.cr_gid;
6107 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6109 current->fsgid = exp->ex_anon_gid;
6111 + /* this desperately needs a tag :) */
6112 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6114 if (!cred.cr_group_info)
6116 ret = set_current_groups(cred.cr_group_info);
6117 put_group_info(cred.cr_group_info);
6118 - if ((cred.cr_uid)) {
6120 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
6121 current->cap_effective =
6122 cap_drop_nfsd_set(current->cap_effective);
6124 diff -NurpP --minimal linux-2.6.27.6/fs/nfsd/nfs3xdr.c linux-2.6.27.6-vs2.3.0.36/fs/nfsd/nfs3xdr.c
6125 --- linux-2.6.27.6/fs/nfsd/nfs3xdr.c 2008-07-13 23:51:29.000000000 +0200
6126 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfsd/nfs3xdr.c 2008-10-13 14:54:20.000000000 +0200
6128 #include <linux/sunrpc/svc.h>
6129 #include <linux/nfsd/nfsd.h>
6130 #include <linux/nfsd/xdr3.h>
6131 +#include <linux/vs_tag.h>
6134 #define NFSDDBG_FACILITY NFSDDBG_XDR
6135 @@ -108,6 +109,8 @@ static __be32 *
6136 decode_sattr3(__be32 *p, struct iattr *iap)
6144 @@ -117,12 +120,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6147 iap->ia_valid |= ATTR_UID;
6148 - iap->ia_uid = ntohl(*p++);
6149 + uid = ntohl(*p++);
6152 iap->ia_valid |= ATTR_GID;
6153 - iap->ia_gid = ntohl(*p++);
6154 + gid = ntohl(*p++);
6156 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6157 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6158 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6162 @@ -178,8 +184,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6163 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6164 *p++ = htonl((u32) stat->mode);
6165 *p++ = htonl((u32) stat->nlink);
6166 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6167 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6168 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6169 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6170 + stat->uid, stat->tag)));
6171 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6172 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6173 + stat->gid, stat->tag)));
6174 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6175 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6177 diff -NurpP --minimal linux-2.6.27.6/fs/nfsd/nfs4xdr.c linux-2.6.27.6-vs2.3.0.36/fs/nfsd/nfs4xdr.c
6178 --- linux-2.6.27.6/fs/nfsd/nfs4xdr.c 2008-10-13 14:52:06.000000000 +0200
6179 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfsd/nfs4xdr.c 2008-10-13 14:54:20.000000000 +0200
6181 #include <linux/nfs4_acl.h>
6182 #include <linux/sunrpc/gss_api.h>
6183 #include <linux/sunrpc/svcauth_gss.h>
6184 +#include <linux/vs_tag.h>
6186 #define NFSDDBG_FACILITY NFSDDBG_XDR
6188 @@ -1704,14 +1705,18 @@ out_acl:
6189 WRITE32(stat.nlink);
6191 if (bmval1 & FATTR4_WORD1_OWNER) {
6192 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6193 + status = nfsd4_encode_user(rqstp,
6194 + TAGINO_UID(DX_TAG(dentry->d_inode),
6195 + stat.uid, stat.tag), &p, &buflen);
6196 if (status == nfserr_resource)
6201 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6202 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6203 + status = nfsd4_encode_group(rqstp,
6204 + TAGINO_GID(DX_TAG(dentry->d_inode),
6205 + stat.gid, stat.tag), &p, &buflen);
6206 if (status == nfserr_resource)
6209 diff -NurpP --minimal linux-2.6.27.6/fs/nfsd/nfsxdr.c linux-2.6.27.6-vs2.3.0.36/fs/nfsd/nfsxdr.c
6210 --- linux-2.6.27.6/fs/nfsd/nfsxdr.c 2008-07-13 23:51:29.000000000 +0200
6211 +++ linux-2.6.27.6-vs2.3.0.36/fs/nfsd/nfsxdr.c 2008-10-13 14:54:20.000000000 +0200
6213 #include <linux/nfsd/nfsd.h>
6214 #include <linux/nfsd/xdr.h>
6215 #include <linux/mm.h>
6216 +#include <linux/vs_tag.h>
6219 #define NFSDDBG_FACILITY NFSDDBG_XDR
6220 @@ -98,6 +99,8 @@ static __be32 *
6221 decode_sattr(__be32 *p, struct iattr *iap)
6229 @@ -111,12 +114,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6231 if ((tmp = ntohl(*p++)) != (u32)-1) {
6232 iap->ia_valid |= ATTR_UID;
6233 - iap->ia_uid = tmp;
6236 if ((tmp = ntohl(*p++)) != (u32)-1) {
6237 iap->ia_valid |= ATTR_GID;
6238 - iap->ia_gid = tmp;
6241 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6242 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6243 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6244 if ((tmp = ntohl(*p++)) != (u32)-1) {
6245 iap->ia_valid |= ATTR_SIZE;
6247 @@ -161,8 +167,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6248 *p++ = htonl(nfs_ftypes[type >> 12]);
6249 *p++ = htonl((u32) stat->mode);
6250 *p++ = htonl((u32) stat->nlink);
6251 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6252 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6253 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6254 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6255 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6256 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6258 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6259 *p++ = htonl(NFS_MAXPATHLEN);
6260 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/dlm/dlmfs.c linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/dlm/dlmfs.c
6261 --- linux-2.6.27.6/fs/ocfs2/dlm/dlmfs.c 2008-10-13 14:52:06.000000000 +0200
6262 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/dlm/dlmfs.c 2008-10-13 14:54:20.000000000 +0200
6264 #include <linux/init.h>
6265 #include <linux/string.h>
6266 #include <linux/backing-dev.h>
6267 +#include <linux/vs_tag.h>
6269 #include <asm/uaccess.h>
6271 @@ -341,6 +342,7 @@ static struct inode *dlmfs_get_root_inod
6272 inode->i_mode = mode;
6273 inode->i_uid = current->fsuid;
6274 inode->i_gid = current->fsgid;
6275 + inode->i_tag = dx_current_fstag(sb);
6276 inode->i_blocks = 0;
6277 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6278 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6279 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
6280 inode->i_mode = mode;
6281 inode->i_uid = current->fsuid;
6282 inode->i_gid = current->fsgid;
6283 + inode->i_tag = dx_current_fstag(sb);
6284 inode->i_blocks = 0;
6285 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6286 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6287 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/dlmglue.c linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/dlmglue.c
6288 --- linux-2.6.27.6/fs/ocfs2/dlmglue.c 2008-10-13 14:52:06.000000000 +0200
6289 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/dlmglue.c 2008-10-13 14:54:20.000000000 +0200
6290 @@ -1846,6 +1846,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6291 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6292 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6293 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6294 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6295 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6296 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6297 lvb->lvb_iatime_packed =
6298 @@ -1900,6 +1901,7 @@ static void ocfs2_refresh_inode_from_lvb
6300 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6301 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6302 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6303 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6304 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6305 ocfs2_unpack_timespec(&inode->i_atime,
6306 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/dlmglue.h linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/dlmglue.h
6307 --- linux-2.6.27.6/fs/ocfs2/dlmglue.h 2008-07-13 23:51:29.000000000 +0200
6308 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/dlmglue.h 2008-10-13 14:54:20.000000000 +0200
6309 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6312 __be32 lvb_igeneration;
6313 - __be32 lvb_reserved2;
6315 + __be16 lvb_reserved2;
6318 /* ocfs2_inode_lock_full() 'arg_flags' flags */
6319 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/file.c linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/file.c
6320 --- linux-2.6.27.6/fs/ocfs2/file.c 2008-10-13 14:52:06.000000000 +0200
6321 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/file.c 2008-10-13 14:54:20.000000000 +0200
6322 @@ -1058,13 +1058,15 @@ int ocfs2_setattr(struct dentry *dentry,
6323 mlog(0, "uid change: %d\n", attr->ia_uid);
6324 if (attr->ia_valid & ATTR_GID)
6325 mlog(0, "gid change: %d\n", attr->ia_gid);
6326 + if (attr->ia_valid & ATTR_TAG)
6327 + mlog(0, "tag change: %d\n", attr->ia_tag);
6328 if (attr->ia_valid & ATTR_SIZE)
6329 mlog(0, "size change...\n");
6330 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6331 mlog(0, "time change...\n");
6333 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6334 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6335 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6336 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6337 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6339 @@ -2227,6 +2229,7 @@ const struct inode_operations ocfs2_file
6340 .setattr = ocfs2_setattr,
6341 .getattr = ocfs2_getattr,
6342 .permission = ocfs2_permission,
6343 + .sync_flags = ocfs2_sync_flags,
6344 .fallocate = ocfs2_fallocate,
6347 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/inode.c linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/inode.c
6348 --- linux-2.6.27.6/fs/ocfs2/inode.c 2008-07-13 23:51:29.000000000 +0200
6349 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/inode.c 2008-10-13 14:54:20.000000000 +0200
6351 #include <linux/slab.h>
6352 #include <linux/highmem.h>
6353 #include <linux/pagemap.h>
6354 +#include <linux/vs_tag.h>
6356 #include <asm/byteorder.h>
6360 #include "heartbeat.h"
6363 #include "journal.h"
6365 #include "suballoc.h"
6366 @@ -74,11 +76,13 @@ void ocfs2_set_inode_flags(struct inode
6368 unsigned int flags = OCFS2_I(inode)->ip_attr;
6370 - inode->i_flags &= ~(S_IMMUTABLE |
6371 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6372 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6374 if (flags & OCFS2_IMMUTABLE_FL)
6375 inode->i_flags |= S_IMMUTABLE;
6376 + if (flags & OCFS2_IXUNLINK_FL)
6377 + inode->i_flags |= S_IXUNLINK;
6379 if (flags & OCFS2_SYNC_FL)
6380 inode->i_flags |= S_SYNC;
6381 @@ -88,25 +92,85 @@ void ocfs2_set_inode_flags(struct inode
6382 inode->i_flags |= S_NOATIME;
6383 if (flags & OCFS2_DIRSYNC_FL)
6384 inode->i_flags |= S_DIRSYNC;
6386 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6388 + if (flags & OCFS2_BARRIER_FL)
6389 + inode->i_vflags |= V_BARRIER;
6390 + if (flags & OCFS2_COW_FL)
6391 + inode->i_vflags |= V_COW;
6394 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6395 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6397 unsigned int flags = oi->vfs_inode.i_flags;
6398 + unsigned int vflags = oi->vfs_inode.i_vflags;
6400 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6401 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6402 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6403 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6405 + if (flags & S_IMMUTABLE)
6406 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6407 + if (flags & S_IXUNLINK)
6408 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6410 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6411 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6413 oi->ip_attr |= OCFS2_SYNC_FL;
6414 if (flags & S_APPEND)
6415 oi->ip_attr |= OCFS2_APPEND_FL;
6416 - if (flags & S_IMMUTABLE)
6417 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6418 if (flags & S_NOATIME)
6419 oi->ip_attr |= OCFS2_NOATIME_FL;
6420 if (flags & S_DIRSYNC)
6421 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6423 + if (vflags & V_BARRIER)
6424 + oi->ip_attr |= OCFS2_BARRIER_FL;
6425 + if (vflags & V_COW)
6426 + oi->ip_attr |= OCFS2_COW_FL;
6429 +int ocfs2_sync_flags(struct inode *inode)
6431 + struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6432 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6433 + handle_t *handle = NULL;
6434 + struct buffer_head *bh = NULL;
6437 + status = ocfs2_inode_lock(inode, &bh, 1);
6439 + mlog_errno(status);
6444 + if (IS_RDONLY(inode))
6447 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6448 + if (IS_ERR(handle)) {
6449 + status = PTR_ERR(handle);
6450 + mlog_errno(status);
6454 + ocfs2_get_inode_flags(ocfs2_inode);
6455 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6457 + mlog_errno(status);
6459 + ocfs2_commit_trans(osb, handle);
6461 + ocfs2_inode_unlock(inode, 1);
6466 + mlog_exit(status);
6470 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
6471 @@ -219,6 +283,8 @@ int ocfs2_populate_inode(struct inode *i
6472 struct super_block *sb;
6473 struct ocfs2_super *osb;
6474 int status = -EINVAL;
6478 mlog_entry("(0x%p, size:%llu)\n", inode,
6479 (unsigned long long)le64_to_cpu(fe->i_size));
6480 @@ -254,8 +320,12 @@ int ocfs2_populate_inode(struct inode *i
6481 inode->i_generation = le32_to_cpu(fe->i_generation);
6482 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6483 inode->i_mode = le16_to_cpu(fe->i_mode);
6484 - inode->i_uid = le32_to_cpu(fe->i_uid);
6485 - inode->i_gid = le32_to_cpu(fe->i_gid);
6486 + uid = le32_to_cpu(fe->i_uid);
6487 + gid = le32_to_cpu(fe->i_gid);
6488 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6489 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6490 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6491 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6493 /* Fast symlinks will have i_size but no allocated clusters. */
6494 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6495 @@ -1230,8 +1300,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
6497 fe->i_size = cpu_to_le64(i_size_read(inode));
6498 fe->i_links_count = cpu_to_le16(inode->i_nlink);
6499 - fe->i_uid = cpu_to_le32(inode->i_uid);
6500 - fe->i_gid = cpu_to_le32(inode->i_gid);
6501 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
6502 + inode->i_uid, inode->i_tag));
6503 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
6504 + inode->i_gid, inode->i_tag));
6505 + /* i_tag = = cpu_to_le16(inode->i_tag); */
6506 fe->i_mode = cpu_to_le16(inode->i_mode);
6507 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
6508 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
6509 @@ -1259,16 +1332,25 @@ leave:
6510 void ocfs2_refresh_inode(struct inode *inode,
6511 struct ocfs2_dinode *fe)
6516 spin_lock(&OCFS2_I(inode)->ip_lock);
6518 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
6519 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
6520 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
6521 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
6522 OCFS2_I(inode)->ip_dyn_features = le16_to_cpu(fe->i_dyn_features);
6523 ocfs2_set_inode_flags(inode);
6524 i_size_write(inode, le64_to_cpu(fe->i_size));
6525 inode->i_nlink = le16_to_cpu(fe->i_links_count);
6526 - inode->i_uid = le32_to_cpu(fe->i_uid);
6527 - inode->i_gid = le32_to_cpu(fe->i_gid);
6528 + uid = le32_to_cpu(fe->i_uid);
6529 + gid = le32_to_cpu(fe->i_gid);
6530 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6531 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6532 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6533 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6534 inode->i_mode = le16_to_cpu(fe->i_mode);
6535 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
6536 inode->i_blocks = 0;
6537 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/inode.h linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/inode.h
6538 --- linux-2.6.27.6/fs/ocfs2/inode.h 2008-07-13 23:51:29.000000000 +0200
6539 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/inode.h 2008-10-13 14:54:20.000000000 +0200
6540 @@ -143,6 +143,7 @@ int ocfs2_aio_write(struct file *file, s
6542 void ocfs2_set_inode_flags(struct inode *inode);
6543 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6544 +int ocfs2_sync_flags(struct inode *inode);
6546 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6548 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/ioctl.c linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/ioctl.c
6549 --- linux-2.6.27.6/fs/ocfs2/ioctl.c 2008-07-13 23:51:29.000000000 +0200
6550 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/ioctl.c 2008-10-13 14:54:20.000000000 +0200
6551 @@ -42,7 +42,7 @@ static int ocfs2_get_inode_attr(struct i
6555 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6556 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6559 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6560 @@ -67,6 +67,11 @@ static int ocfs2_set_inode_attr(struct i
6561 if (!S_ISDIR(inode->i_mode))
6562 flags &= ~OCFS2_DIRSYNC_FL;
6564 + if (IS_BARRIER(inode)) {
6565 + vxwprintk_task(1, "messing with the barrier.");
6569 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6570 if (IS_ERR(handle)) {
6571 status = PTR_ERR(handle);
6572 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/ioctl.h linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/ioctl.h
6573 --- linux-2.6.27.6/fs/ocfs2/ioctl.h 2008-07-13 23:51:29.000000000 +0200
6574 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/ioctl.h 2008-10-13 14:54:20.000000000 +0200
6576 #ifndef OCFS2_IOCTL_H
6577 #define OCFS2_IOCTL_H
6579 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6582 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
6583 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
6585 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/namei.c linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/namei.c
6586 --- linux-2.6.27.6/fs/ocfs2/namei.c 2008-07-13 23:51:29.000000000 +0200
6587 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/namei.c 2008-10-13 14:54:20.000000000 +0200
6589 #include <linux/types.h>
6590 #include <linux/slab.h>
6591 #include <linux/highmem.h>
6592 +#include <linux/vs_tag.h>
6594 #define MLOG_MASK_PREFIX ML_NAMEI
6595 #include <cluster/masklog.h>
6596 @@ -366,6 +367,9 @@ static int ocfs2_mknod_locked(struct ocf
6599 struct inode *inode = NULL;
6604 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
6605 (unsigned long)dev, dentry->d_name.len,
6606 @@ -425,13 +429,19 @@ static int ocfs2_mknod_locked(struct ocf
6607 fe->i_blkno = cpu_to_le64(fe_blkno);
6608 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6609 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6610 - fe->i_uid = cpu_to_le32(current->fsuid);
6612 + tag = dx_current_fstag(osb->sb);
6613 + uid = current->fsuid;
6614 if (dir->i_mode & S_ISGID) {
6615 - fe->i_gid = cpu_to_le32(dir->i_gid);
6620 - fe->i_gid = cpu_to_le32(current->fsgid);
6621 + gid = current->fsgid;
6623 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
6624 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
6625 + inode->i_tag = tag;
6626 fe->i_mode = cpu_to_le16(mode);
6627 if (S_ISCHR(mode) || S_ISBLK(mode))
6628 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6629 @@ -1917,5 +1927,6 @@ const struct inode_operations ocfs2_dir_
6630 .rename = ocfs2_rename,
6631 .setattr = ocfs2_setattr,
6632 .getattr = ocfs2_getattr,
6633 + .sync_flags = ocfs2_sync_flags,
6634 .permission = ocfs2_permission,
6636 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/ocfs2_fs.h linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/ocfs2_fs.h
6637 --- linux-2.6.27.6/fs/ocfs2/ocfs2_fs.h 2008-10-13 14:52:06.000000000 +0200
6638 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/ocfs2_fs.h 2008-10-13 14:54:20.000000000 +0200
6639 @@ -195,18 +195,23 @@
6640 #define OCFS2_INDEXED_DIR_FL (0x0008)
6642 /* Inode attributes, keep in sync with EXT2 */
6643 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6644 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6645 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6646 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6647 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6648 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6649 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6650 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6651 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6652 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6653 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6654 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6655 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6656 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6657 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6658 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6659 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6661 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6662 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6663 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6664 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6666 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6667 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6669 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6670 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6673 * Extent record flags (e_node.leaf.flags)
6674 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/ocfs2.h linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/ocfs2.h
6675 --- linux-2.6.27.6/fs/ocfs2/ocfs2.h 2008-10-13 14:52:06.000000000 +0200
6676 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/ocfs2.h 2008-10-13 14:54:20.000000000 +0200
6677 @@ -184,6 +184,7 @@ enum ocfs2_mount_options
6678 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
6679 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
6680 OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */
6681 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
6684 #define OCFS2_OSB_SOFT_RO 0x0001
6685 diff -NurpP --minimal linux-2.6.27.6/fs/ocfs2/super.c linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/super.c
6686 --- linux-2.6.27.6/fs/ocfs2/super.c 2008-10-13 14:52:06.000000000 +0200
6687 +++ linux-2.6.27.6-vs2.3.0.36/fs/ocfs2/super.c 2008-10-13 14:54:20.000000000 +0200
6688 @@ -154,6 +154,7 @@ enum {
6692 + Opt_tag, Opt_notag, Opt_tagid,
6696 @@ -173,6 +174,9 @@ static match_table_t tokens = {
6697 {Opt_localalloc, "localalloc=%d"},
6698 {Opt_localflocks, "localflocks"},
6699 {Opt_stack, "cluster_stack=%s"},
6701 + {Opt_notag, "notag"},
6702 + {Opt_tagid, "tagid=%u"},
6706 @@ -392,6 +396,13 @@ static int ocfs2_remount(struct super_bl
6710 + if ((parsed_options.mount_opt & OCFS2_MOUNT_TAGGED) &&
6711 + !(sb->s_flags & MS_TAGGED)) {
6713 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6717 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6718 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6720 @@ -725,6 +736,9 @@ static int ocfs2_fill_super(struct super
6722 ocfs2_complete_mount_recovery(osb);
6724 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6725 + sb->s_flags |= MS_TAGGED;
6727 if (ocfs2_mount_local(osb))
6728 snprintf(nodestr, sizeof(nodestr), "local");
6730 @@ -918,6 +932,20 @@ static int ocfs2_parse_options(struct su
6731 OCFS2_STACK_LABEL_LEN);
6732 mopt->cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
6734 +#ifndef CONFIG_TAGGING_NONE
6736 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6739 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6742 +#ifdef CONFIG_PROPAGATE
6745 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6750 "Unrecognized mount option \"%s\" "
6751 diff -NurpP --minimal linux-2.6.27.6/fs/open.c linux-2.6.27.6-vs2.3.0.36/fs/open.c
6752 --- linux-2.6.27.6/fs/open.c 2008-10-13 14:52:06.000000000 +0200
6753 +++ linux-2.6.27.6-vs2.3.0.36/fs/open.c 2008-10-13 14:54:20.000000000 +0200
6755 #include <linux/rcupdate.h>
6756 #include <linux/audit.h>
6757 #include <linux/falloc.h>
6758 +#include <linux/vs_base.h>
6759 +#include <linux/vs_limit.h>
6760 +#include <linux/vs_dlimit.h>
6761 +#include <linux/vs_tag.h>
6762 +#include <linux/vs_cowbl.h>
6764 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
6766 int retval = -ENODEV;
6769 + struct super_block *sb = dentry->d_sb;
6772 - if (dentry->d_sb->s_op->statfs) {
6773 + if (sb->s_op->statfs) {
6774 memset(buf, 0, sizeof(*buf));
6775 retval = security_sb_statfs(dentry);
6778 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6779 + retval = sb->s_op->statfs(dentry, buf);
6780 if (retval == 0 && buf->f_frsize == 0)
6781 buf->f_frsize = buf->f_bsize;
6783 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6784 + vx_vsi_statfs(sb, buf);
6788 @@ -625,6 +634,10 @@ asmlinkage long sys_fchmodat(int dfd, co
6789 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6793 + error = cow_check_and_break(&path);
6795 + goto dput_and_out;
6796 inode = path.dentry->d_inode;
6798 error = mnt_want_write(path.mnt);
6799 @@ -658,11 +671,11 @@ static int chown_common(struct dentry *
6800 newattrs.ia_valid = ATTR_CTIME;
6801 if (user != (uid_t) -1) {
6802 newattrs.ia_valid |= ATTR_UID;
6803 - newattrs.ia_uid = user;
6804 + newattrs.ia_uid = dx_map_uid(user);
6806 if (group != (gid_t) -1) {
6807 newattrs.ia_valid |= ATTR_GID;
6808 - newattrs.ia_gid = group;
6809 + newattrs.ia_gid = dx_map_gid(group);
6811 if (!S_ISDIR(inode->i_mode))
6812 newattrs.ia_valid |=
6813 @@ -685,7 +698,11 @@ asmlinkage long sys_chown(const char __u
6814 error = mnt_want_write(path.mnt);
6817 - error = chown_common(path.dentry, user, group);
6818 +#ifdef CONFIG_VSERVER_COWBL
6819 + error = cow_check_and_break(&path);
6822 + error = chown_common(path.dentry, user, group);
6823 mnt_drop_write(path.mnt);
6826 @@ -710,7 +727,11 @@ asmlinkage long sys_fchownat(int dfd, co
6827 error = mnt_want_write(path.mnt);
6830 - error = chown_common(path.dentry, user, group);
6831 +#ifdef CONFIG_VSERVER_COWBL
6832 + error = cow_check_and_break(&path);
6835 + error = chown_common(path.dentry, user, group);
6836 mnt_drop_write(path.mnt);
6839 @@ -729,7 +750,11 @@ asmlinkage long sys_lchown(const char __
6840 error = mnt_want_write(path.mnt);
6843 - error = chown_common(path.dentry, user, group);
6844 +#ifdef CONFIG_VSERVER_COWBL
6845 + error = cow_check_and_break(&path);
6848 + error = chown_common(path.dentry, user, group);
6849 mnt_drop_write(path.mnt);
6852 @@ -969,6 +994,7 @@ static void __put_unused_fd(struct files
6853 __FD_CLR(fd, fdt->open_fds);
6854 if (fd < files->next_fd)
6855 files->next_fd = fd;
6856 + vx_openfd_dec(fd);
6859 void put_unused_fd(unsigned int fd)
6860 diff -NurpP --minimal linux-2.6.27.6/fs/proc/array.c linux-2.6.27.6-vs2.3.0.36/fs/proc/array.c
6861 --- linux-2.6.27.6/fs/proc/array.c 2008-10-13 14:52:06.000000000 +0200
6862 +++ linux-2.6.27.6-vs2.3.0.36/fs/proc/array.c 2008-10-13 14:54:20.000000000 +0200
6864 #include <linux/seq_file.h>
6865 #include <linux/pid_namespace.h>
6866 #include <linux/tracehook.h>
6867 +#include <linux/vs_context.h>
6868 +#include <linux/vs_network.h>
6870 #include <asm/pgtable.h>
6871 #include <asm/processor.h>
6872 @@ -142,8 +144,9 @@ static const char *task_state_array[] =
6873 "D (disk sleep)", /* 2 */
6874 "T (stopped)", /* 4 */
6875 "T (tracing stop)", /* 8 */
6876 - "Z (zombie)", /* 16 */
6877 - "X (dead)" /* 32 */
6878 + "H (on hold)", /* 16 */
6879 + "Z (zombie)", /* 32 */
6880 + "X (dead)", /* 64 */
6883 static inline const char *get_task_state(struct task_struct *tsk)
6884 @@ -164,6 +167,7 @@ static inline void task_state(struct seq
6885 struct group_info *group_info;
6887 struct fdtable *fdt = NULL;
6888 +/* + pid_t pid, ptgid, tppid, tgid; */
6892 @@ -175,6 +179,12 @@ static inline void task_state(struct seq
6894 tpid = task_pid_nr_ns(tracer, ns);
6896 +/* tgid = vx_map_tgid(p->tgid);
6897 + pid = vx_map_pid(p->pid);
6898 + ptgid = vx_map_pid(pid_alive(p) ?
6899 + rcu_dereference(p->real_parent)->tgid : 0);
6900 + tppid = vx_map_pid(pid_alive(p) && p->ptrace ?
6901 + rcu_dereference(p->parent)->pid : 0); */
6905 @@ -286,7 +296,7 @@ static inline void task_sig(struct seq_f
6908 static void render_cap_t(struct seq_file *m, const char *header,
6910 + struct vx_info *vxi, kernel_cap_t *a)
6914 @@ -300,10 +310,10 @@ static void render_cap_t(struct seq_file
6916 static inline void task_cap(struct seq_file *m, struct task_struct *p)
6918 - render_cap_t(m, "CapInh:\t", &p->cap_inheritable);
6919 - render_cap_t(m, "CapPrm:\t", &p->cap_permitted);
6920 - render_cap_t(m, "CapEff:\t", &p->cap_effective);
6921 - render_cap_t(m, "CapBnd:\t", &p->cap_bset);
6922 + render_cap_t(m, "CapInh:\t", p->vx_info, &p->cap_inheritable);
6923 + render_cap_t(m, "CapPrm:\t", p->vx_info, &p->cap_permitted);
6924 + render_cap_t(m, "CapEff:\t", p->vx_info, &p->cap_effective);
6925 + render_cap_t(m, "CapBnd:\t", p->vx_info, &p->cap_bset);
6928 static inline void task_context_switch_counts(struct seq_file *m,
6929 @@ -315,6 +325,45 @@ static inline void task_context_switch_c
6933 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6934 + struct pid *pid, struct task_struct *task)
6936 + seq_printf(m, "Proxy:\t%p(%c)\n"
6945 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6946 + atomic_read(&task->nsproxy->count),
6947 + task->nsproxy->uts_ns,
6948 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6949 + task->nsproxy->ipc_ns,
6950 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6951 + task->nsproxy->mnt_ns,
6952 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6953 + task->nsproxy->pid_ns,
6954 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6955 + task->nsproxy->user_ns,
6956 + (task->nsproxy->user_ns == init_task.nsproxy->user_ns ? 'I' : '-'),
6957 + task->nsproxy->net_ns,
6958 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6962 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6964 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6967 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6968 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6972 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6973 struct pid *pid, struct task_struct *task)
6975 @@ -330,6 +379,7 @@ int proc_pid_status(struct seq_file *m,
6978 cpuset_task_status_allowed(m, task);
6979 + task_vs_id(m, task);
6980 #if defined(CONFIG_S390)
6981 task_show_regs(m, task);
6983 @@ -442,6 +492,17 @@ static int do_task_stat(struct seq_file
6984 /* convert nsec -> ticks */
6985 start_time = nsec_to_clock_t(start_time);
6987 + /* fixup start time for virt uptime */
6988 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6989 + unsigned long long bias =
6990 + current->vx_info->cvirt.bias_clock;
6992 + if (start_time > bias)
6993 + start_time -= bias;
6998 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6999 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
7000 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
7001 diff -NurpP --minimal linux-2.6.27.6/fs/proc/base.c linux-2.6.27.6-vs2.3.0.36/fs/proc/base.c
7002 --- linux-2.6.27.6/fs/proc/base.c 2008-10-13 14:52:06.000000000 +0200
7003 +++ linux-2.6.27.6-vs2.3.0.36/fs/proc/base.c 2008-10-13 14:54:20.000000000 +0200
7005 #include <linux/oom.h>
7006 #include <linux/elf.h>
7007 #include <linux/pid_namespace.h>
7008 +#include <linux/vs_context.h>
7009 +#include <linux/vs_network.h>
7010 #include "internal.h"
7013 @@ -1439,6 +1441,8 @@ static struct inode *proc_pid_make_inode
7014 inode->i_uid = task->euid;
7015 inode->i_gid = task->egid;
7017 + /* procfs is xid tagged */
7018 + inode->i_tag = (tag_t)vx_task_xid(task);
7019 security_task_to_inode(task, inode);
7022 @@ -1979,6 +1983,13 @@ static struct dentry *proc_pident_lookup
7026 + /* TODO: maybe we can come up with a generic approach? */
7027 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
7028 + (dentry->d_name.len == 5) &&
7029 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
7030 + !memcmp(dentry->d_name.name, "ninfo", 5)))
7034 * Yes, it does not scale. And it should not. Don't add
7035 * new entries into /proc/<tgid>/ without very good reasons.
7036 @@ -2366,7 +2377,7 @@ out_iput:
7037 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
7039 struct dentry *error;
7040 - struct task_struct *task = get_proc_task(dir);
7041 + struct task_struct *task = get_proc_task_real(dir);
7042 const struct pid_entry *p, *last;
7044 error = ERR_PTR(-ENOENT);
7045 @@ -2449,6 +2460,9 @@ static int proc_tgid_io_accounting(struc
7046 static const struct file_operations proc_task_operations;
7047 static const struct inode_operations proc_task_inode_operations;
7049 +extern int proc_pid_vx_info(struct task_struct *, char *);
7050 +extern int proc_pid_nx_info(struct task_struct *, char *);
7052 static const struct pid_entry tgid_base_stuff[] = {
7053 DIR("task", S_IRUGO|S_IXUGO, task),
7054 DIR("fd", S_IRUSR|S_IXUSR, fd),
7055 @@ -2503,6 +2517,8 @@ static const struct pid_entry tgid_base_
7056 #ifdef CONFIG_CGROUPS
7057 REG("cgroup", S_IRUGO, cgroup),
7059 + INF("vinfo", S_IRUGO, pid_vx_info),
7060 + INF("ninfo", S_IRUGO, pid_nx_info),
7061 INF("oom_score", S_IRUGO, oom_score),
7062 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
7063 #ifdef CONFIG_AUDITSYSCALL
7064 @@ -2518,6 +2534,7 @@ static const struct pid_entry tgid_base_
7065 #ifdef CONFIG_TASK_IO_ACCOUNTING
7066 INF("io", S_IRUGO, tgid_io_accounting),
7068 + ONE("nsproxy", S_IRUGO, pid_nsproxy),
7071 static int proc_tgid_base_readdir(struct file * filp,
7072 @@ -2714,7 +2731,7 @@ retry:
7074 pid = find_ge_pid(iter.tgid, ns);
7076 - iter.tgid = pid_nr_ns(pid, ns);
7077 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
7078 iter.task = pid_task(pid, PIDTYPE_PID);
7079 /* What we to know is if the pid we have find is the
7080 * pid of a thread_group_leader. Testing for task
7081 @@ -2744,7 +2761,7 @@ static int proc_pid_fill_cache(struct fi
7082 struct tgid_iter iter)
7084 char name[PROC_NUMBUF];
7085 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
7086 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
7087 return proc_fill_cache(filp, dirent, filldir, name, len,
7088 proc_pid_instantiate, iter.task, NULL);
7090 @@ -2753,7 +2770,7 @@ static int proc_pid_fill_cache(struct fi
7091 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
7093 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
7094 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
7095 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
7096 struct tgid_iter iter;
7097 struct pid_namespace *ns;
7099 @@ -2773,6 +2790,8 @@ int proc_pid_readdir(struct file * filp,
7101 iter.tgid += 1, iter = next_tgid(ns, iter)) {
7102 filp->f_pos = iter.tgid + TGID_OFFSET;
7103 + if (!vx_proc_task_visible(iter.task))
7105 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
7106 put_task_struct(iter.task);
7108 @@ -2915,6 +2934,8 @@ static struct dentry *proc_task_lookup(s
7109 tid = name_to_int(dentry);
7112 + if (vx_current_initpid(tid))
7115 ns = dentry->d_sb->s_fs_info;
7117 diff -NurpP --minimal linux-2.6.27.6/fs/proc/generic.c linux-2.6.27.6-vs2.3.0.36/fs/proc/generic.c
7118 --- linux-2.6.27.6/fs/proc/generic.c 2008-10-13 14:52:06.000000000 +0200
7119 +++ linux-2.6.27.6-vs2.3.0.36/fs/proc/generic.c 2008-10-13 14:54:20.000000000 +0200
7121 #include <linux/bitops.h>
7122 #include <linux/spinlock.h>
7123 #include <linux/completion.h>
7124 +#include <linux/vserver/inode.h>
7125 #include <asm/uaccess.h>
7127 #include "internal.h"
7128 @@ -384,6 +385,8 @@ struct dentry *proc_lookup_de(struct pro
7129 for (de = de->subdir; de ; de = de->next) {
7130 if (de->namelen != dentry->d_name.len)
7132 + if (!vx_hide_check(0, de->vx_flags))
7134 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
7137 @@ -392,6 +395,8 @@ struct dentry *proc_lookup_de(struct pro
7138 spin_unlock(&proc_subdir_lock);
7140 inode = proc_get_inode(dir->i_sb, ino, de);
7141 + /* generic proc entries belong to the host */
7146 @@ -472,6 +477,8 @@ int proc_readdir_de(struct proc_dir_entr
7148 /* filldir passes info to user space */
7150 + if (!vx_hide_check(0, de->vx_flags))
7152 spin_unlock(&proc_subdir_lock);
7153 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
7154 de->low_ino, de->mode >> 12) < 0) {
7155 @@ -479,6 +486,7 @@ int proc_readdir_de(struct proc_dir_entr
7158 spin_lock(&proc_subdir_lock);
7163 @@ -593,6 +601,7 @@ static struct proc_dir_entry *__proc_cre
7165 atomic_set(&ent->count, 1);
7167 + ent->vx_flags = IATTR_PROC_DEFAULT;
7168 spin_lock_init(&ent->pde_unload_lock);
7169 ent->pde_unload_completion = NULL;
7170 INIT_LIST_HEAD(&ent->pde_openers);
7171 @@ -616,7 +625,8 @@ struct proc_dir_entry *proc_symlink(cons
7177 + ent->vx_flags = IATTR_PROC_SYMLINK;
7181 diff -NurpP --minimal linux-2.6.27.6/fs/proc/inode.c linux-2.6.27.6-vs2.3.0.36/fs/proc/inode.c
7182 --- linux-2.6.27.6/fs/proc/inode.c 2008-10-13 14:52:06.000000000 +0200
7183 +++ linux-2.6.27.6-vs2.3.0.36/fs/proc/inode.c 2008-10-13 14:54:20.000000000 +0200
7184 @@ -469,6 +469,8 @@ struct inode *proc_get_inode(struct supe
7185 inode->i_uid = de->uid;
7186 inode->i_gid = de->gid;
7189 + PROC_I(inode)->vx_flags = de->vx_flags;
7191 inode->i_size = de->size;
7193 diff -NurpP --minimal linux-2.6.27.6/fs/proc/internal.h linux-2.6.27.6-vs2.3.0.36/fs/proc/internal.h
7194 --- linux-2.6.27.6/fs/proc/internal.h 2008-10-13 14:52:06.000000000 +0200
7195 +++ linux-2.6.27.6-vs2.3.0.36/fs/proc/internal.h 2008-10-13 14:54:20.000000000 +0200
7199 #include <linux/proc_fs.h>
7200 +#include <linux/vs_pid.h>
7202 extern struct proc_dir_entry proc_root;
7203 #ifdef CONFIG_PROC_SYSCTL
7204 @@ -55,6 +56,9 @@ extern int proc_pid_status(struct seq_fi
7205 struct pid *pid, struct task_struct *task);
7206 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7207 struct pid *pid, struct task_struct *task);
7208 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7209 + struct pid *pid, struct task_struct *task);
7211 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7213 extern const struct file_operations proc_maps_operations;
7214 @@ -75,11 +79,16 @@ static inline struct pid *proc_pid(struc
7215 return PROC_I(inode)->pid;
7218 -static inline struct task_struct *get_proc_task(struct inode *inode)
7219 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7221 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7224 +static inline struct task_struct *get_proc_task(struct inode *inode)
7226 + return vx_get_proc_task(inode, proc_pid(inode));
7229 static inline int proc_fd(struct inode *inode)
7231 return PROC_I(inode)->fd;
7232 diff -NurpP --minimal linux-2.6.27.6/fs/proc/proc_misc.c linux-2.6.27.6-vs2.3.0.36/fs/proc/proc_misc.c
7233 --- linux-2.6.27.6/fs/proc/proc_misc.c 2008-10-13 14:52:06.000000000 +0200
7234 +++ linux-2.6.27.6-vs2.3.0.36/fs/proc/proc_misc.c 2008-10-13 14:54:20.000000000 +0200
7236 #include <asm/div64.h>
7237 #include "internal.h"
7239 +#include <linux/vs_cvirt.h>
7241 #define LOAD_INT(x) ((x) >> FSHIFT)
7242 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
7244 @@ -84,22 +86,38 @@ static int proc_calc_metrics(char *page,
7245 static int loadavg_read_proc(char *page, char **start, off_t off,
7246 int count, int *eof, void *data)
7248 + unsigned long running;
7249 + unsigned int threads;
7255 seq = read_seqbegin(&xtime_lock);
7256 - a = avenrun[0] + (FIXED_1/200);
7257 - b = avenrun[1] + (FIXED_1/200);
7258 - c = avenrun[2] + (FIXED_1/200);
7259 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7260 + struct vx_info *vxi = current->vx_info;
7262 + a = vxi->cvirt.load[0] + (FIXED_1/200);
7263 + b = vxi->cvirt.load[1] + (FIXED_1/200);
7264 + c = vxi->cvirt.load[2] + (FIXED_1/200);
7266 + running = atomic_read(&vxi->cvirt.nr_running);
7267 + threads = atomic_read(&vxi->cvirt.nr_threads);
7269 + a = avenrun[0] + (FIXED_1/200);
7270 + b = avenrun[1] + (FIXED_1/200);
7271 + c = avenrun[2] + (FIXED_1/200);
7273 + running = nr_running();
7274 + threads = nr_threads;
7276 } while (read_seqretry(&xtime_lock, seq));
7278 len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
7279 LOAD_INT(a), LOAD_FRAC(a),
7280 LOAD_INT(b), LOAD_FRAC(b),
7281 LOAD_INT(c), LOAD_FRAC(c),
7282 - nr_running(), nr_threads,
7284 task_active_pid_ns(current)->last_pid);
7285 return proc_calc_metrics(page, start, off, count, eof, len);
7287 @@ -115,6 +133,9 @@ static int uptime_read_proc(char *page,
7288 do_posix_clock_monotonic_gettime(&uptime);
7289 monotonic_to_bootbased(&uptime);
7290 cputime_to_timespec(idletime, &idle);
7291 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7292 + vx_vsi_uptime(&uptime, &idle);
7294 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
7295 (unsigned long) uptime.tv_sec,
7296 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7297 @@ -151,7 +172,7 @@ static int meminfo_read_proc(char *page,
7299 cached = global_page_state(NR_FILE_PAGES) -
7300 total_swapcache_pages - i.bufferram;
7302 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
7305 get_vmalloc_info(&vmi);
7306 diff -NurpP --minimal linux-2.6.27.6/fs/proc/root.c linux-2.6.27.6-vs2.3.0.36/fs/proc/root.c
7307 --- linux-2.6.27.6/fs/proc/root.c 2008-07-13 23:51:29.000000000 +0200
7308 +++ linux-2.6.27.6-vs2.3.0.36/fs/proc/root.c 2008-11-20 00:58:27.000000000 +0100
7310 #include <linux/smp_lock.h>
7311 #include <linux/mount.h>
7312 #include <linux/pid_namespace.h>
7313 +#include <linux/vserver/inode.h>
7315 #include "internal.h"
7317 +struct proc_dir_entry *proc_virtual;
7319 +extern void proc_vx_init(void);
7321 static int proc_test_super(struct super_block *sb, void *data)
7323 return sb->s_fs_info == data;
7324 @@ -137,6 +142,7 @@ void __init proc_root_init(void)
7326 proc_mkdir("bus", NULL);
7331 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7332 @@ -209,6 +215,7 @@ struct proc_dir_entry proc_root = {
7333 .proc_iops = &proc_root_inode_operations,
7334 .proc_fops = &proc_root_operations,
7335 .parent = &proc_root,
7336 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7339 int pid_ns_prepare_proc(struct pid_namespace *ns)
7340 diff -NurpP --minimal linux-2.6.27.6/fs/quota.c linux-2.6.27.6-vs2.3.0.36/fs/quota.c
7341 --- linux-2.6.27.6/fs/quota.c 2008-10-13 14:52:06.000000000 +0200
7342 +++ linux-2.6.27.6-vs2.3.0.36/fs/quota.c 2008-10-13 14:54:20.000000000 +0200
7344 #include <linux/capability.h>
7345 #include <linux/quotaops.h>
7346 #include <linux/types.h>
7347 +#include <linux/vs_context.h>
7349 /* Check validity of generic quotactl commands */
7350 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
7351 @@ -81,11 +82,11 @@ static int generic_quotactl_valid(struct
7352 if (cmd == Q_GETQUOTA) {
7353 if (((type == USRQUOTA && current->euid != id) ||
7354 (type == GRPQUOTA && !in_egroup_p(id))) &&
7355 - !capable(CAP_SYS_ADMIN))
7356 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7359 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7360 - if (!capable(CAP_SYS_ADMIN))
7361 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7365 @@ -132,10 +133,10 @@ static int xqm_quotactl_valid(struct sup
7366 if (cmd == Q_XGETQUOTA) {
7367 if (((type == XQM_USRQUOTA && current->euid != id) ||
7368 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7369 - !capable(CAP_SYS_ADMIN))
7370 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7372 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7373 - if (!capable(CAP_SYS_ADMIN))
7374 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7378 @@ -334,6 +335,46 @@ static int do_quotactl(struct super_bloc
7382 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7384 +#include <linux/vroot.h>
7385 +#include <linux/major.h>
7386 +#include <linux/module.h>
7387 +#include <linux/kallsyms.h>
7388 +#include <linux/vserver/debug.h>
7390 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7392 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7394 +int register_vroot_grb(vroot_grb_func *func) {
7397 + spin_lock(&vroot_grb_lock);
7398 + if (!vroot_get_real_bdev) {
7399 + vroot_get_real_bdev = func;
7402 + spin_unlock(&vroot_grb_lock);
7405 +EXPORT_SYMBOL(register_vroot_grb);
7407 +int unregister_vroot_grb(vroot_grb_func *func) {
7408 + int ret = -EINVAL;
7410 + spin_lock(&vroot_grb_lock);
7411 + if (vroot_get_real_bdev) {
7412 + vroot_get_real_bdev = NULL;
7415 + spin_unlock(&vroot_grb_lock);
7418 +EXPORT_SYMBOL(unregister_vroot_grb);
7423 * look up a superblock on which quota ops will be performed
7424 * - use the name of a block device to find the superblock thereon
7425 @@ -351,6 +392,22 @@ static inline struct super_block *quotac
7428 return ERR_CAST(bdev);
7429 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7430 + if (bdev && bdev->bd_inode &&
7431 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7432 + struct block_device *bdnew = (void *)-EINVAL;
7434 + if (vroot_get_real_bdev)
7435 + bdnew = vroot_get_real_bdev(bdev);
7437 + vxdprintk(VXD_CBIT(misc, 0),
7438 + "vroot_get_real_bdev not set");
7440 + if (IS_ERR(bdnew))
7441 + return ERR_PTR(PTR_ERR(bdnew));
7445 sb = get_super(bdev);
7448 diff -NurpP --minimal linux-2.6.27.6/fs/reiserfs/bitmap.c linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/bitmap.c
7449 --- linux-2.6.27.6/fs/reiserfs/bitmap.c 2008-07-13 23:51:29.000000000 +0200
7450 +++ linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/bitmap.c 2008-10-13 14:54:20.000000000 +0200
7452 #include <linux/reiserfs_fs_sb.h>
7453 #include <linux/reiserfs_fs_i.h>
7454 #include <linux/quotaops.h>
7455 +#include <linux/vs_dlimit.h>
7457 #define PREALLOCATION_SIZE 9
7459 @@ -429,8 +430,10 @@ static void _reiserfs_free_block(struct
7460 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
7462 journal_mark_dirty(th, s, sbh);
7463 - if (for_unformatted)
7464 + if (for_unformatted) {
7465 + DLIMIT_FREE_BLOCK(inode, 1);
7466 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
7470 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
7471 @@ -1045,6 +1048,7 @@ static inline int blocknrs_and_prealloc_
7472 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
7474 int nr_allocated = 0;
7477 determine_prealloc_size(hint);
7478 if (!hint->formatted_node) {
7479 @@ -1054,19 +1058,30 @@ static inline int blocknrs_and_prealloc_
7480 "reiserquota: allocating %d blocks id=%u",
7481 amount_needed, hint->inode->i_uid);
7484 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
7485 - if (quota_ret) /* Quota exceeded? */
7486 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
7489 return QUOTA_EXCEEDED;
7490 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
7491 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7493 + return NO_DISK_SPACE;
7496 if (hint->preallocate && hint->prealloc_size) {
7497 #ifdef REISERQUOTA_DEBUG
7498 reiserfs_debug(s, REISERFS_DEBUG_CODE,
7499 "reiserquota: allocating (prealloc) %d blocks id=%u",
7500 hint->prealloc_size, hint->inode->i_uid);
7503 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7504 - hint->prealloc_size);
7505 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7506 + hint->prealloc_size);
7508 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
7509 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7510 + hint->prealloc_size);
7514 hint->preallocate = hint->prealloc_size = 0;
7516 @@ -1098,7 +1113,10 @@ static inline int blocknrs_and_prealloc_
7518 hint->inode->i_uid);
7520 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
7521 + /* Free not allocated blocks */
7522 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
7523 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7524 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7526 while (nr_allocated--)
7527 reiserfs_free_block(hint->th, hint->inode,
7528 @@ -1129,10 +1147,10 @@ static inline int blocknrs_and_prealloc_
7529 REISERFS_I(hint->inode)->i_prealloc_count,
7530 hint->inode->i_uid);
7532 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
7533 - hint->prealloc_size - nr_allocated -
7534 - REISERFS_I(hint->inode)->
7535 - i_prealloc_count);
7536 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
7537 + REISERFS_I(hint->inode)->i_prealloc_count;
7538 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7539 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7543 diff -NurpP --minimal linux-2.6.27.6/fs/reiserfs/file.c linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/file.c
7544 --- linux-2.6.27.6/fs/reiserfs/file.c 2008-07-13 23:51:29.000000000 +0200
7545 +++ linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/file.c 2008-10-13 14:54:20.000000000 +0200
7546 @@ -306,4 +306,5 @@ const struct inode_operations reiserfs_f
7547 .listxattr = reiserfs_listxattr,
7548 .removexattr = reiserfs_removexattr,
7549 .permission = reiserfs_permission,
7550 + .sync_flags = reiserfs_sync_flags,
7552 diff -NurpP --minimal linux-2.6.27.6/fs/reiserfs/inode.c linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/inode.c
7553 --- linux-2.6.27.6/fs/reiserfs/inode.c 2008-10-13 14:52:06.000000000 +0200
7554 +++ linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/inode.c 2008-10-13 14:54:20.000000000 +0200
7556 #include <linux/writeback.h>
7557 #include <linux/quotaops.h>
7558 #include <linux/swap.h>
7559 +#include <linux/vs_dlimit.h>
7560 +#include <linux/vs_tag.h>
7562 int reiserfs_commit_write(struct file *f, struct page *page,
7563 unsigned from, unsigned to);
7564 @@ -54,6 +56,7 @@ void reiserfs_delete_inode(struct inode
7565 * stat data deletion */
7567 DQUOT_FREE_INODE(inode);
7568 + DLIMIT_FREE_INODE(inode);
7570 if (journal_end(&th, inode->i_sb, jbegin_count))
7572 @@ -1116,6 +1119,8 @@ static void init_inode(struct inode *ino
7573 struct buffer_head *bh;
7574 struct item_head *ih;
7578 //int version = ITEM_VERSION_1;
7580 bh = PATH_PLAST_BUFFER(path);
7581 @@ -1139,12 +1144,13 @@ static void init_inode(struct inode *ino
7582 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7583 unsigned long blocks;
7585 + uid = sd_v1_uid(sd);
7586 + gid = sd_v1_gid(sd);
7588 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7589 set_inode_sd_version(inode, STAT_DATA_V1);
7590 inode->i_mode = sd_v1_mode(sd);
7591 inode->i_nlink = sd_v1_nlink(sd);
7592 - inode->i_uid = sd_v1_uid(sd);
7593 - inode->i_gid = sd_v1_gid(sd);
7594 inode->i_size = sd_v1_size(sd);
7595 inode->i_atime.tv_sec = sd_v1_atime(sd);
7596 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7597 @@ -1186,11 +1192,12 @@ static void init_inode(struct inode *ino
7598 // (directories and symlinks)
7599 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7601 + uid = sd_v2_uid(sd);
7602 + gid = sd_v2_gid(sd);
7604 inode->i_mode = sd_v2_mode(sd);
7605 inode->i_nlink = sd_v2_nlink(sd);
7606 - inode->i_uid = sd_v2_uid(sd);
7607 inode->i_size = sd_v2_size(sd);
7608 - inode->i_gid = sd_v2_gid(sd);
7609 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7610 inode->i_atime.tv_sec = sd_v2_atime(sd);
7611 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7612 @@ -1220,6 +1227,10 @@ static void init_inode(struct inode *ino
7613 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7616 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7617 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7618 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7621 if (S_ISREG(inode->i_mode)) {
7622 inode->i_op = &reiserfs_file_inode_operations;
7623 @@ -1242,13 +1253,15 @@ static void init_inode(struct inode *ino
7624 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7626 struct stat_data *sd_v2 = (struct stat_data *)sd;
7627 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7628 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7631 + set_sd_v2_uid(sd_v2, uid);
7632 + set_sd_v2_gid(sd_v2, gid);
7633 set_sd_v2_mode(sd_v2, inode->i_mode);
7634 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7635 - set_sd_v2_uid(sd_v2, inode->i_uid);
7636 set_sd_v2_size(sd_v2, size);
7637 - set_sd_v2_gid(sd_v2, inode->i_gid);
7638 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7639 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7640 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7641 @@ -1771,6 +1784,10 @@ int reiserfs_new_inode(struct reiserfs_t
7643 BUG_ON(!th->t_trans_id);
7645 + if (DLIMIT_ALLOC_INODE(inode)) {
7647 + goto out_bad_dlimit;
7649 if (DQUOT_ALLOC_INODE(inode)) {
7652 @@ -1956,6 +1973,9 @@ int reiserfs_new_inode(struct reiserfs_t
7653 DQUOT_FREE_INODE(inode);
7656 + DLIMIT_FREE_INODE(inode);
7659 journal_end(th, th->t_super, th->t_blocks_allocated);
7660 /* Drop can be outside and it needs more credits so it's better to have it outside */
7662 @@ -2842,14 +2862,19 @@ int reiserfs_commit_write(struct file *f
7663 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7665 if (reiserfs_attrs(inode->i_sb)) {
7666 - if (sd_attrs & REISERFS_SYNC_FL)
7667 - inode->i_flags |= S_SYNC;
7669 - inode->i_flags &= ~S_SYNC;
7670 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7671 inode->i_flags |= S_IMMUTABLE;
7673 inode->i_flags &= ~S_IMMUTABLE;
7674 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7675 + inode->i_flags |= S_IXUNLINK;
7677 + inode->i_flags &= ~S_IXUNLINK;
7679 + if (sd_attrs & REISERFS_SYNC_FL)
7680 + inode->i_flags |= S_SYNC;
7682 + inode->i_flags &= ~S_SYNC;
7683 if (sd_attrs & REISERFS_APPEND_FL)
7684 inode->i_flags |= S_APPEND;
7686 @@ -2862,6 +2887,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7687 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7689 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7691 + if (sd_attrs & REISERFS_BARRIER_FL)
7692 + inode->i_vflags |= V_BARRIER;
7694 + inode->i_vflags &= ~V_BARRIER;
7695 + if (sd_attrs & REISERFS_COW_FL)
7696 + inode->i_vflags |= V_COW;
7698 + inode->i_vflags &= ~V_COW;
7702 @@ -2872,6 +2906,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7703 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7705 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7706 + if (inode->i_flags & S_IXUNLINK)
7707 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7709 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7711 if (inode->i_flags & S_SYNC)
7712 *sd_attrs |= REISERFS_SYNC_FL;
7714 @@ -2884,6 +2923,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7715 *sd_attrs |= REISERFS_NOTAIL_FL;
7717 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7719 + if (inode->i_vflags & V_BARRIER)
7720 + *sd_attrs |= REISERFS_BARRIER_FL;
7722 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7723 + if (inode->i_vflags & V_COW)
7724 + *sd_attrs |= REISERFS_COW_FL;
7726 + *sd_attrs &= ~REISERFS_COW_FL;
7730 @@ -3051,6 +3099,22 @@ static ssize_t reiserfs_direct_IO(int rw
7731 reiserfs_get_blocks_direct_io, NULL);
7734 +int reiserfs_sync_flags(struct inode *inode)
7736 + u16 oldflags, newflags;
7738 + oldflags = REISERFS_I(inode)->i_attrs;
7739 + newflags = oldflags;
7740 + i_attrs_to_sd_attrs(inode, &newflags);
7742 + if (oldflags ^ newflags) {
7743 + REISERFS_I(inode)->i_attrs = newflags;
7744 + inode->i_ctime = CURRENT_TIME_SEC;
7745 + mark_inode_dirty(inode);
7750 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
7752 struct inode *inode = dentry->d_inode;
7753 @@ -3104,9 +3168,11 @@ int reiserfs_setattr(struct dentry *dent
7756 error = inode_change_ok(inode, attr);
7759 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7760 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7761 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7762 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7763 error = reiserfs_chown_xattrs(inode, attr);
7766 @@ -3136,6 +3202,9 @@ int reiserfs_setattr(struct dentry *dent
7767 inode->i_uid = attr->ia_uid;
7768 if (attr->ia_valid & ATTR_GID)
7769 inode->i_gid = attr->ia_gid;
7770 + if ((attr->ia_valid & ATTR_TAG) &&
7772 + inode->i_tag = attr->ia_tag;
7773 mark_inode_dirty(inode);
7775 journal_end(&th, inode->i_sb, jbegin_count);
7776 diff -NurpP --minimal linux-2.6.27.6/fs/reiserfs/ioctl.c linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/ioctl.c
7777 --- linux-2.6.27.6/fs/reiserfs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
7778 +++ linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/ioctl.c 2008-10-13 14:54:20.000000000 +0200
7780 #include <linux/mount.h>
7781 #include <linux/reiserfs_fs.h>
7782 #include <linux/time.h>
7783 +#include <linux/mount.h>
7784 #include <asm/uaccess.h>
7785 #include <linux/pagemap.h>
7786 #include <linux/smp_lock.h>
7788 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
7791 - unsigned int flags;
7792 + unsigned int flags, oldflags;
7796 @@ -43,6 +44,7 @@ int reiserfs_ioctl(struct inode *inode,
7798 flags = REISERFS_I(inode)->i_attrs;
7799 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7800 + flags &= REISERFS_FL_USER_VISIBLE;
7801 return put_user(flags, (int __user *)arg);
7802 case REISERFS_IOC_SETFLAGS:{
7803 if (!reiserfs_attrs(inode->i_sb))
7804 @@ -60,6 +62,10 @@ int reiserfs_ioctl(struct inode *inode,
7808 + if (IS_BARRIER(inode)) {
7809 + vxwprintk_task(1, "messing with the barrier.");
7813 * Is it quota file? Do not allow user to mess with it
7815 @@ -84,6 +90,10 @@ int reiserfs_ioctl(struct inode *inode,
7820 + oldflags = REISERFS_I(inode)->i_attrs;
7821 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
7822 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7823 sd_attrs_to_i_attrs(flags, inode);
7824 REISERFS_I(inode)->i_attrs = flags;
7825 inode->i_ctime = CURRENT_TIME_SEC;
7826 diff -NurpP --minimal linux-2.6.27.6/fs/reiserfs/namei.c linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/namei.c
7827 --- linux-2.6.27.6/fs/reiserfs/namei.c 2008-07-13 23:51:29.000000000 +0200
7828 +++ linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/namei.c 2008-10-13 14:54:20.000000000 +0200
7830 #include <linux/reiserfs_acl.h>
7831 #include <linux/reiserfs_xattr.h>
7832 #include <linux/quotaops.h>
7833 +#include <linux/vs_tag.h>
7835 #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; }
7836 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7837 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
7838 reiserfs_write_unlock(dir->i_sb);
7839 return ERR_PTR(-EACCES);
7841 + dx_propagate_tag(nd, inode);
7843 /* Propogate the priv_object flag so we know we're in the priv tree */
7844 if (is_reiserfs_priv_object(dir))
7845 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
7847 inode->i_gid = current->fsgid;
7849 + inode->i_tag = dx_current_fstag(inode->i_sb);
7853 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
7854 .listxattr = reiserfs_listxattr,
7855 .removexattr = reiserfs_removexattr,
7856 .permission = reiserfs_permission,
7857 + .sync_flags = reiserfs_sync_flags,
7861 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
7862 .listxattr = reiserfs_listxattr,
7863 .removexattr = reiserfs_removexattr,
7864 .permission = reiserfs_permission,
7865 + .sync_flags = reiserfs_sync_flags,
7869 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
7870 .listxattr = reiserfs_listxattr,
7871 .removexattr = reiserfs_removexattr,
7872 .permission = reiserfs_permission,
7873 + .sync_flags = reiserfs_sync_flags,
7876 diff -NurpP --minimal linux-2.6.27.6/fs/reiserfs/stree.c linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/stree.c
7877 --- linux-2.6.27.6/fs/reiserfs/stree.c 2008-07-13 23:51:29.000000000 +0200
7878 +++ linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/stree.c 2008-10-13 14:54:20.000000000 +0200
7880 #include <linux/reiserfs_fs.h>
7881 #include <linux/buffer_head.h>
7882 #include <linux/quotaops.h>
7883 +#include <linux/vs_dlimit.h>
7885 /* Does the buffer contain a disk block which is in the tree. */
7886 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
7887 @@ -1297,6 +1298,7 @@ int reiserfs_delete_item(struct reiserfs
7888 "reiserquota delete_item(): freeing %u, id=%u type=%c",
7889 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
7891 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7892 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7894 /* Return deleted body length */
7895 @@ -1385,6 +1387,7 @@ void reiserfs_delete_solid_item(struct r
7897 DQUOT_FREE_SPACE_NODIRTY(inode,
7899 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
7903 @@ -1734,6 +1737,7 @@ int reiserfs_cut_from_item(struct reiser
7904 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
7905 quota_cut_bytes, p_s_inode->i_uid, '?');
7907 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7908 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7911 @@ -1975,6 +1979,11 @@ int reiserfs_paste_into_item(struct reis
7912 pathrelse(p_s_search_path);
7915 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
7916 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7917 + pathrelse(p_s_search_path);
7920 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
7922 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
7923 @@ -2027,6 +2036,7 @@ int reiserfs_paste_into_item(struct reis
7924 n_pasted_size, inode->i_uid,
7925 key2type(&(p_s_key->on_disk_key)));
7927 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
7928 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7931 @@ -2064,6 +2074,11 @@ int reiserfs_insert_item(struct reiserfs
7932 pathrelse(p_s_path);
7935 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
7936 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7937 + pathrelse(p_s_path);
7941 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
7942 IH_SIZE + ih_item_len(p_s_ih));
7943 @@ -2111,7 +2126,9 @@ int reiserfs_insert_item(struct reiserfs
7944 "reiserquota insert_item(): freeing %u id=%u type=%c",
7945 quota_bytes, inode->i_uid, head2type(p_s_ih));
7949 + DLIMIT_FREE_SPACE(inode, quota_bytes);
7950 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7954 diff -NurpP --minimal linux-2.6.27.6/fs/reiserfs/super.c linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/super.c
7955 --- linux-2.6.27.6/fs/reiserfs/super.c 2008-10-13 14:52:06.000000000 +0200
7956 +++ linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/super.c 2008-10-13 14:54:20.000000000 +0200
7957 @@ -898,6 +898,14 @@ static int reiserfs_parse_options(struct
7958 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7959 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7961 +#ifndef CONFIG_TAGGING_NONE
7962 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7963 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7964 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7966 +#ifdef CONFIG_PROPAGATE
7967 + {"tag",.arg_required = 'T',.values = NULL},
7969 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7970 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7971 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7972 @@ -1193,6 +1201,12 @@ static int reiserfs_remount(struct super
7973 handle_quota_files(s, qf_names, &qfmt);
7976 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7977 + !(s->s_flags & MS_TAGGED)) {
7978 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
7984 /* Add options that are safe here */
7985 @@ -1657,6 +1671,10 @@ static int reiserfs_fill_super(struct su
7989 + /* map mount option tagxid */
7990 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7991 + s->s_flags |= MS_TAGGED;
7993 rs = SB_DISK_SUPER_BLOCK(s);
7994 /* Let's do basic sanity check to verify that underlying device is not
7995 smaller than the filesystem. If the check fails then abort and scream,
7996 diff -NurpP --minimal linux-2.6.27.6/fs/reiserfs/xattr.c linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/xattr.c
7997 --- linux-2.6.27.6/fs/reiserfs/xattr.c 2008-10-13 14:52:06.000000000 +0200
7998 +++ linux-2.6.27.6-vs2.3.0.36/fs/reiserfs/xattr.c 2008-10-13 14:54:20.000000000 +0200
8000 #include <linux/namei.h>
8001 #include <linux/errno.h>
8002 #include <linux/fs.h>
8003 +#include <linux/mount.h>
8004 #include <linux/file.h>
8005 #include <linux/pagemap.h>
8006 #include <linux/xattr.h>
8007 diff -NurpP --minimal linux-2.6.27.6/fs/stat.c linux-2.6.27.6-vs2.3.0.36/fs/stat.c
8008 --- linux-2.6.27.6/fs/stat.c 2008-10-13 14:52:06.000000000 +0200
8009 +++ linux-2.6.27.6-vs2.3.0.36/fs/stat.c 2008-10-13 14:54:20.000000000 +0200
8010 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
8011 stat->nlink = inode->i_nlink;
8012 stat->uid = inode->i_uid;
8013 stat->gid = inode->i_gid;
8014 + stat->tag = inode->i_tag;
8015 stat->rdev = inode->i_rdev;
8016 stat->atime = inode->i_atime;
8017 stat->mtime = inode->i_mtime;
8018 diff -NurpP --minimal linux-2.6.27.6/fs/super.c linux-2.6.27.6-vs2.3.0.36/fs/super.c
8019 --- linux-2.6.27.6/fs/super.c 2008-10-13 14:52:06.000000000 +0200
8020 +++ linux-2.6.27.6-vs2.3.0.36/fs/super.c 2008-10-13 14:54:20.000000000 +0200
8022 #include <linux/kobject.h>
8023 #include <linux/mutex.h>
8024 #include <linux/file.h>
8025 +#include <linux/devpts_fs.h>
8026 +#include <linux/proc_fs.h>
8027 +#include <linux/vs_context.h>
8028 #include <asm/uaccess.h>
8029 #include "internal.h"
8031 @@ -887,12 +890,18 @@ struct vfsmount *
8032 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
8034 struct vfsmount *mnt;
8035 + struct super_block *sb;
8036 char *secdata = NULL;
8040 return ERR_PTR(-ENODEV);
8043 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
8044 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
8048 mnt = alloc_vfsmnt(name);
8050 @@ -913,7 +922,14 @@ vfs_kern_mount(struct file_system_type *
8051 goto out_free_secdata;
8052 BUG_ON(!mnt->mnt_sb);
8054 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
8057 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
8058 + (sb->s_magic != PROC_SUPER_MAGIC) &&
8059 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
8062 + error = security_sb_kern_mount(sb, secdata);
8066 diff -NurpP --minimal linux-2.6.27.6/fs/sysfs/mount.c linux-2.6.27.6-vs2.3.0.36/fs/sysfs/mount.c
8067 --- linux-2.6.27.6/fs/sysfs/mount.c 2008-07-13 23:51:29.000000000 +0200
8068 +++ linux-2.6.27.6-vs2.3.0.36/fs/sysfs/mount.c 2008-10-13 14:54:20.000000000 +0200
8073 -/* Random magic number */
8074 -#define SYSFS_MAGIC 0x62656572
8076 static struct vfsmount *sysfs_mount;
8077 struct super_block * sysfs_sb = NULL;
8078 @@ -46,7 +44,7 @@ static int sysfs_fill_super(struct super
8080 sb->s_blocksize = PAGE_CACHE_SIZE;
8081 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
8082 - sb->s_magic = SYSFS_MAGIC;
8083 + sb->s_magic = SYSFS_SUPER_MAGIC;
8084 sb->s_op = &sysfs_ops;
8085 sb->s_time_gran = 1;
8087 diff -NurpP --minimal linux-2.6.27.6/fs/utimes.c linux-2.6.27.6-vs2.3.0.36/fs/utimes.c
8088 --- linux-2.6.27.6/fs/utimes.c 2008-10-13 14:52:06.000000000 +0200
8089 +++ linux-2.6.27.6-vs2.3.0.36/fs/utimes.c 2008-10-13 14:54:20.000000000 +0200
8091 #include <linux/stat.h>
8092 #include <linux/utime.h>
8093 #include <linux/syscalls.h>
8094 +#include <linux/mount.h>
8095 +#include <linux/vs_cowbl.h>
8096 #include <asm/uaccess.h>
8097 #include <asm/unistd.h>
8099 diff -NurpP --minimal linux-2.6.27.6/fs/xattr.c linux-2.6.27.6-vs2.3.0.36/fs/xattr.c
8100 --- linux-2.6.27.6/fs/xattr.c 2008-10-13 14:52:06.000000000 +0200
8101 +++ linux-2.6.27.6-vs2.3.0.36/fs/xattr.c 2008-10-13 14:54:20.000000000 +0200
8103 #include <linux/module.h>
8104 #include <linux/fsnotify.h>
8105 #include <linux/audit.h>
8106 +#include <linux/mount.h>
8107 #include <asm/uaccess.h>
8110 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.27.6-vs2.3.0.36/fs/xfs/linux-2.6/xfs_ioctl.c
8111 --- linux-2.6.27.6/fs/xfs/linux-2.6/xfs_ioctl.c 2008-10-13 14:52:06.000000000 +0200
8112 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/linux-2.6/xfs_ioctl.c 2008-11-12 18:41:58.000000000 +0100
8113 @@ -806,6 +806,10 @@ xfs_merge_ioc_xflags(
8114 xflags |= XFS_XFLAG_IMMUTABLE;
8116 xflags &= ~XFS_XFLAG_IMMUTABLE;
8117 + if (flags & FS_IXUNLINK_FL)
8118 + xflags |= XFS_XFLAG_IXUNLINK;
8120 + xflags &= ~XFS_XFLAG_IXUNLINK;
8121 if (flags & FS_APPEND_FL)
8122 xflags |= XFS_XFLAG_APPEND;
8124 @@ -834,6 +838,8 @@ xfs_di2lxflags(
8126 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8127 flags |= FS_IMMUTABLE_FL;
8128 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8129 + flags |= FS_IXUNLINK_FL;
8130 if (di_flags & XFS_DIFLAG_APPEND)
8131 flags |= FS_APPEND_FL;
8132 if (di_flags & XFS_DIFLAG_SYNC)
8133 @@ -892,6 +898,8 @@ xfs_set_diflags(
8134 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
8135 if (xflags & XFS_XFLAG_IMMUTABLE)
8136 di_flags |= XFS_DIFLAG_IMMUTABLE;
8137 + if (xflags & XFS_XFLAG_IXUNLINK)
8138 + di_flags |= XFS_DIFLAG_IXUNLINK;
8139 if (xflags & XFS_XFLAG_APPEND)
8140 di_flags |= XFS_DIFLAG_APPEND;
8141 if (xflags & XFS_XFLAG_SYNC)
8142 @@ -934,6 +942,10 @@ xfs_diflags_to_linux(
8143 inode->i_flags |= S_IMMUTABLE;
8145 inode->i_flags &= ~S_IMMUTABLE;
8146 + if (xflags & XFS_XFLAG_IXUNLINK)
8147 + inode->i_flags |= S_IXUNLINK;
8149 + inode->i_flags &= ~S_IXUNLINK;
8150 if (xflags & XFS_XFLAG_APPEND)
8151 inode->i_flags |= S_APPEND;
8153 @@ -1392,10 +1404,18 @@ xfs_ioctl(
8154 case XFS_IOC_FSGETXATTRA:
8155 return xfs_ioc_fsgetxattr(ip, 1, arg);
8156 case XFS_IOC_FSSETXATTR:
8157 + if (IS_BARRIER(inode)) {
8158 + vxwprintk_task(1, "messing with the barrier.");
8159 + return -XFS_ERROR(EACCES);
8161 return xfs_ioc_fssetxattr(ip, filp, arg);
8162 case XFS_IOC_GETXFLAGS:
8163 return xfs_ioc_getxflags(ip, arg);
8164 case XFS_IOC_SETXFLAGS:
8165 + if (IS_BARRIER(inode)) {
8166 + vxwprintk_task(1, "messing with the barrier.");
8167 + return -XFS_ERROR(EACCES);
8169 return xfs_ioc_setxflags(ip, filp, arg);
8171 case XFS_IOC_FSSETDM: {
8172 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.27.6-vs2.3.0.36/fs/xfs/linux-2.6/xfs_iops.c
8173 --- linux-2.6.27.6/fs/xfs/linux-2.6/xfs_iops.c 2008-10-13 14:52:06.000000000 +0200
8174 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/linux-2.6/xfs_iops.c 2008-11-12 18:41:58.000000000 +0100
8176 #include <linux/namei.h>
8177 #include <linux/security.h>
8178 #include <linux/falloc.h>
8179 +#include <linux/vs_tag.h>
8182 * Bring the atime in the XFS inode uptodate.
8183 @@ -558,6 +559,7 @@ xfs_vn_getattr(
8184 stat->nlink = ip->i_d.di_nlink;
8185 stat->uid = ip->i_d.di_uid;
8186 stat->gid = ip->i_d.di_gid;
8187 + stat->tag = ip->i_d.di_tag;
8188 stat->ino = ip->i_ino;
8190 stat->ino += mp->m_inoadd;
8191 @@ -597,6 +599,12 @@ xfs_vn_getattr(
8195 +xfs_vn_sync_xflags(struct inode *inode)
8197 + return -xfs_sync_xflags(XFS_I(inode));
8202 struct dentry *dentry,
8203 struct iattr *iattr)
8204 @@ -671,6 +679,7 @@ static const struct inode_operations xfs
8205 .removexattr = generic_removexattr,
8206 .listxattr = xfs_vn_listxattr,
8207 .fallocate = xfs_vn_fallocate,
8208 + .sync_flags = xfs_vn_sync_xflags,
8211 static const struct inode_operations xfs_dir_inode_operations = {
8212 @@ -696,6 +705,7 @@ static const struct inode_operations xfs
8213 .getxattr = generic_getxattr,
8214 .removexattr = generic_removexattr,
8215 .listxattr = xfs_vn_listxattr,
8216 + .sync_flags = xfs_vn_sync_xflags,
8219 static const struct inode_operations xfs_dir_ci_inode_operations = {
8220 @@ -745,6 +755,10 @@ xfs_diflags_to_iflags(
8221 inode->i_flags |= S_IMMUTABLE;
8223 inode->i_flags &= ~S_IMMUTABLE;
8224 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
8225 + inode->i_flags |= S_IXUNLINK;
8227 + inode->i_flags &= ~S_IXUNLINK;
8228 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
8229 inode->i_flags |= S_APPEND;
8231 @@ -757,6 +771,15 @@ xfs_diflags_to_iflags(
8232 inode->i_flags |= S_NOATIME;
8234 inode->i_flags &= ~S_NOATIME;
8236 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
8237 + inode->i_vflags |= V_BARRIER;
8239 + inode->i_vflags &= ~V_BARRIER;
8240 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
8241 + inode->i_vflags |= V_COW;
8243 + inode->i_vflags &= ~V_COW;
8247 @@ -777,6 +800,7 @@ xfs_setup_inode(
8248 inode->i_nlink = ip->i_d.di_nlink;
8249 inode->i_uid = ip->i_d.di_uid;
8250 inode->i_gid = ip->i_d.di_gid;
8251 + inode->i_tag = ip->i_d.di_tag;
8253 switch (inode->i_mode & S_IFMT) {
8255 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.27.6-vs2.3.0.36/fs/xfs/linux-2.6/xfs_linux.h
8256 --- linux-2.6.27.6/fs/xfs/linux-2.6/xfs_linux.h 2008-10-13 14:52:06.000000000 +0200
8257 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/linux-2.6/xfs_linux.h 2008-10-13 15:35:26.000000000 +0200
8260 #define current_cpu() (raw_smp_processor_id())
8261 #define current_pid() (current->pid)
8262 +#define current_fstag(cred,vp) (dx_current_fstag(vp->i_sb))
8263 #define current_test_flags(f) (current->flags & (f))
8264 #define current_set_flags_nested(sp, f) \
8265 (*(sp) = current->flags, current->flags |= (f))
8266 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/linux-2.6/xfs_super.c linux-2.6.27.6-vs2.3.0.36/fs/xfs/linux-2.6/xfs_super.c
8267 --- linux-2.6.27.6/fs/xfs/linux-2.6/xfs_super.c 2008-11-17 18:07:34.000000000 +0100
8268 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/linux-2.6/xfs_super.c 2008-11-12 18:41:59.000000000 +0100
8269 @@ -147,6 +147,9 @@ xfs_args_allocate(
8270 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
8271 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
8272 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
8273 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
8274 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
8275 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
8278 * Table driven mount option parser.
8279 @@ -155,10 +158,14 @@ xfs_args_allocate(
8280 * in the future, too.
8283 + Opt_tag, Opt_notag,
8284 Opt_barrier, Opt_nobarrier, Opt_err
8287 static match_table_t tokens = {
8288 + {Opt_tag, "tagxid"},
8290 + {Opt_notag, "notag"},
8291 {Opt_barrier, "barrier"},
8292 {Opt_nobarrier, "nobarrier"},
8294 @@ -383,6 +390,19 @@ xfs_parseargs(
8295 } else if (!strcmp(this_char, "irixsgid")) {
8297 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
8298 +#ifndef CONFIG_TAGGING_NONE
8299 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8300 + args->flags2 |= XFSMNT2_TAGGED;
8301 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
8302 + args->flags2 &= ~XFSMNT2_TAGGED;
8303 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
8304 + args->flags2 |= XFSMNT2_TAGGED;
8306 +#ifdef CONFIG_PROPAGATE
8307 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8309 + args->flags2 |= XFSMNT2_TAGGED;
8313 "XFS: unknown mount option [%s].", this_char);
8314 @@ -1301,6 +1321,16 @@ xfs_fs_remount(
8316 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8319 + if (!(sb->s_flags & MS_TAGGED)) {
8321 + "XFS: %s: tagging not permitted on remount.\n",
8330 * Logically we would return an error here to prevent
8331 @@ -1555,6 +1585,9 @@ xfs_start_flags(
8333 if (ap->flags & XFSMNT_DMAPI)
8334 mp->m_flags |= XFS_MOUNT_DMAPI;
8336 + if (ap->flags2 & XFSMNT2_TAGGED)
8337 + mp->m_flags |= XFS_MOUNT_TAGGED;
8341 @@ -1749,6 +1782,9 @@ xfs_fs_fill_super(
8343 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, args->mtpt, args->fsname);
8345 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8346 + sb->s_flags |= MS_TAGGED;
8349 sb->s_magic = XFS_SB_MAGIC;
8350 sb->s_blocksize = mp->m_sb.sb_blocksize;
8351 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.27.6-vs2.3.0.36/fs/xfs/quota/xfs_qm_syscalls.c
8352 --- linux-2.6.27.6/fs/xfs/quota/xfs_qm_syscalls.c 2008-10-13 14:52:06.000000000 +0200
8353 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/quota/xfs_qm_syscalls.c 2008-10-24 03:47:08.000000000 +0200
8354 @@ -426,7 +426,7 @@ xfs_qm_scall_quotaon(
8358 - if (!capable(CAP_SYS_ADMIN))
8359 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8360 return XFS_ERROR(EPERM);
8362 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
8363 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_clnt.h linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_clnt.h
8364 --- linux-2.6.27.6/fs/xfs/xfs_clnt.h 2008-10-13 14:52:06.000000000 +0200
8365 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_clnt.h 2008-10-13 14:54:20.000000000 +0200
8366 @@ -101,5 +101,6 @@ struct xfs_mount_args {
8367 * I/O size in stat(2) */
8368 #define XFSMNT2_FILESTREAMS 0x00000002 /* enable the filestreams
8370 +#define XFSMNT2_TAGGED 0x10000000 /* context tagging */
8372 #endif /* __XFS_CLNT_H__ */
8373 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_dinode.h linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_dinode.h
8374 --- linux-2.6.27.6/fs/xfs/xfs_dinode.h 2008-07-13 23:51:29.000000000 +0200
8375 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_dinode.h 2008-11-12 18:41:59.000000000 +0100
8376 @@ -53,7 +53,9 @@ typedef struct xfs_dinode_core {
8377 __be32 di_gid; /* owner's group id */
8378 __be32 di_nlink; /* number of links to file */
8379 __be16 di_projid; /* owner's project id */
8380 - __u8 di_pad[8]; /* unused, zeroed space */
8381 + __be16 di_tag; /* context tagging */
8382 + __be16 di_vflags; /* vserver specific flags */
8383 + __u8 di_pad[4]; /* unused, zeroed space */
8384 __be16 di_flushiter; /* incremented on flush */
8385 xfs_timestamp_t di_atime; /* time last accessed */
8386 xfs_timestamp_t di_mtime; /* time last modified */
8387 @@ -136,7 +138,9 @@ typedef struct xfs_dinode
8388 #define XFS_DI_NEXT_UNLINKED 0x1000000
8389 #define XFS_DI_U 0x2000000
8390 #define XFS_DI_A 0x4000000
8391 -#define XFS_DI_NUM_BITS 27
8392 +#define XFS_DI_TAG 0x8000000
8393 +#define XFS_DI_VFLAGS 0x10000000
8394 +#define XFS_DI_NUM_BITS 29
8395 #define XFS_DI_ALL_BITS ((1 << XFS_DI_NUM_BITS) - 1)
8396 #define XFS_DI_CORE_BITS (XFS_DI_ALL_BITS & ~(XFS_DI_U|XFS_DI_A))
8398 @@ -223,6 +227,8 @@ typedef enum xfs_dinode_fmt
8399 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8400 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8401 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8402 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8404 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8405 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8406 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8407 @@ -238,6 +244,7 @@ typedef enum xfs_dinode_fmt
8408 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8409 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8410 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8411 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8413 #ifdef CONFIG_XFS_RT
8414 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8415 @@ -250,6 +257,10 @@ typedef enum xfs_dinode_fmt
8416 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8417 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8418 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8419 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8420 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8421 + XFS_DIFLAG_IXUNLINK)
8423 +#define XFS_DIVFLAG_BARRIER 0x01
8424 +#define XFS_DIVFLAG_COW 0x02
8426 #endif /* __XFS_DINODE_H__ */
8427 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_fs.h linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_fs.h
8428 --- linux-2.6.27.6/fs/xfs/xfs_fs.h 2008-10-13 14:52:06.000000000 +0200
8429 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_fs.h 2008-10-13 14:54:20.000000000 +0200
8430 @@ -67,6 +67,9 @@ struct fsxattr {
8431 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8432 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8433 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8434 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8435 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8436 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8437 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8440 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
8441 __s32 bs_extents; /* number of extents */
8442 __u32 bs_gen; /* generation count */
8443 __u16 bs_projid; /* project id */
8444 - unsigned char bs_pad[14]; /* pad space, unused */
8445 + __u16 bs_tag; /* context tagging */
8446 + unsigned char bs_pad[12]; /* pad space, unused */
8447 __u32 bs_dmevmask; /* DMIG event mask */
8448 __u16 bs_dmstate; /* DMIG state info */
8449 __u16 bs_aextents; /* attribute number of extents */
8450 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_ialloc.c linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_ialloc.c
8451 --- linux-2.6.27.6/fs/xfs/xfs_ialloc.c 2008-07-13 23:51:29.000000000 +0200
8452 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_ialloc.c 2008-11-12 18:41:59.000000000 +0100
8453 @@ -84,6 +84,8 @@ xfs_ialloc_log_di(
8454 offsetof(xfs_dinode_t, di_next_unlinked),
8455 offsetof(xfs_dinode_t, di_u),
8456 offsetof(xfs_dinode_t, di_a),
8457 + offsetof(xfs_dinode_core_t, di_tag),
8458 + offsetof(xfs_dinode_core_t, di_vflags),
8459 sizeof(xfs_dinode_t)
8462 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_inode.c linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_inode.c
8463 --- linux-2.6.27.6/fs/xfs/xfs_inode.c 2008-10-13 14:52:06.000000000 +0200
8464 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_inode.c 2008-11-12 18:42:00.000000000 +0100
8465 @@ -249,6 +249,7 @@ xfs_inotobp(
8469 +#include <linux/vs_tag.h>
8472 * This routine is called to map an inode to the buffer containing
8473 @@ -660,15 +661,25 @@ xfs_iformat_btree(
8475 xfs_dinode_from_disk(
8477 - xfs_dinode_core_t *from)
8478 + xfs_dinode_core_t *from,
8481 + uint32_t uid, gid, tag;
8483 to->di_magic = be16_to_cpu(from->di_magic);
8484 to->di_mode = be16_to_cpu(from->di_mode);
8485 to->di_version = from ->di_version;
8486 to->di_format = from->di_format;
8487 to->di_onlink = be16_to_cpu(from->di_onlink);
8488 - to->di_uid = be32_to_cpu(from->di_uid);
8489 - to->di_gid = be32_to_cpu(from->di_gid);
8491 + uid = be32_to_cpu(from->di_uid);
8492 + gid = be32_to_cpu(from->di_gid);
8493 + tag = be16_to_cpu(from->di_tag);
8495 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8496 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8497 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8499 to->di_nlink = be32_to_cpu(from->di_nlink);
8500 to->di_projid = be16_to_cpu(from->di_projid);
8501 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8502 @@ -689,21 +700,26 @@ xfs_dinode_from_disk(
8503 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8504 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8505 to->di_flags = be16_to_cpu(from->di_flags);
8506 + to->di_vflags = be16_to_cpu(from->di_vflags);
8507 to->di_gen = be32_to_cpu(from->di_gen);
8512 xfs_dinode_core_t *to,
8513 - xfs_icdinode_t *from)
8514 + xfs_icdinode_t *from,
8517 to->di_magic = cpu_to_be16(from->di_magic);
8518 to->di_mode = cpu_to_be16(from->di_mode);
8519 to->di_version = from ->di_version;
8520 to->di_format = from->di_format;
8521 to->di_onlink = cpu_to_be16(from->di_onlink);
8522 - to->di_uid = cpu_to_be32(from->di_uid);
8523 - to->di_gid = cpu_to_be32(from->di_gid);
8525 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8526 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8527 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8529 to->di_nlink = cpu_to_be32(from->di_nlink);
8530 to->di_projid = cpu_to_be16(from->di_projid);
8531 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8532 @@ -724,12 +740,14 @@ xfs_dinode_to_disk(
8533 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8534 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8535 to->di_flags = cpu_to_be16(from->di_flags);
8536 + to->di_vflags = cpu_to_be16(from->di_vflags);
8537 to->di_gen = cpu_to_be32(from->di_gen);
8542 - __uint16_t di_flags)
8543 + __uint16_t di_flags,
8544 + __uint16_t di_vflags)
8548 @@ -740,6 +758,8 @@ _xfs_dic2xflags(
8549 flags |= XFS_XFLAG_PREALLOC;
8550 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8551 flags |= XFS_XFLAG_IMMUTABLE;
8552 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8553 + flags |= XFS_XFLAG_IXUNLINK;
8554 if (di_flags & XFS_DIFLAG_APPEND)
8555 flags |= XFS_XFLAG_APPEND;
8556 if (di_flags & XFS_DIFLAG_SYNC)
8557 @@ -764,6 +784,10 @@ _xfs_dic2xflags(
8558 flags |= XFS_XFLAG_FILESTREAM;
8561 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8562 + flags |= FS_BARRIER_FL;
8563 + if (di_vflags & XFS_DIVFLAG_COW)
8564 + flags |= FS_COW_FL;
8568 @@ -773,7 +797,7 @@ xfs_ip2xflags(
8570 xfs_icdinode_t *dic = &ip->i_d;
8572 - return _xfs_dic2xflags(dic->di_flags) |
8573 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8574 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8577 @@ -783,7 +807,8 @@ xfs_dic2xflags(
8579 xfs_dinode_core_t *dic = &dip->di_core;
8581 - return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) |
8582 + return _xfs_dic2xflags(be16_to_cpu(dic->di_flags),
8583 + be16_to_cpu(dic->di_vflags)) |
8584 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8587 @@ -878,7 +903,8 @@ xfs_iread(
8588 * Otherwise, just get the truly permanent information.
8590 if (dip->di_core.di_mode) {
8591 - xfs_dinode_from_disk(&ip->i_d, &dip->di_core);
8592 + xfs_dinode_from_disk(&ip->i_d, &dip->di_core,
8593 + mp->m_flags & XFS_MOUNT_TAGGED);
8594 error = xfs_iformat(ip, dip);
8596 kmem_zone_free(xfs_inode_zone, ip);
8597 @@ -1083,6 +1109,7 @@ xfs_ialloc(
8598 ASSERT(ip->i_d.di_nlink == nlink);
8599 ip->i_d.di_uid = current_fsuid();
8600 ip->i_d.di_gid = current_fsgid();
8601 + ip->i_d.di_tag = current_fstag(cr, ip->i_vnode);
8602 ip->i_d.di_projid = prid;
8603 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8605 @@ -1143,6 +1170,7 @@ xfs_ialloc(
8606 ip->i_d.di_dmevmask = 0;
8607 ip->i_d.di_dmstate = 0;
8608 ip->i_d.di_flags = 0;
8609 + ip->i_d.di_vflags = 0;
8610 flags = XFS_ILOG_CORE;
8611 switch (mode & S_IFMT) {
8613 @@ -2249,6 +2277,7 @@ xfs_ifree(
8615 ip->i_d.di_mode = 0; /* mark incore inode as free */
8616 ip->i_d.di_flags = 0;
8617 + ip->i_d.di_vflags = 0;
8618 ip->i_d.di_dmevmask = 0;
8619 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8620 ip->i_df.if_ext_max =
8621 @@ -3342,7 +3371,8 @@ xfs_iflush_int(
8622 * because if the inode is dirty at all the core must
8625 - xfs_dinode_to_disk(&dip->di_core, &ip->i_d);
8626 + xfs_dinode_to_disk(&dip->di_core, &ip->i_d,
8627 + mp->m_flags & XFS_MOUNT_TAGGED);
8629 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8630 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8631 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_inode.h linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_inode.h
8632 --- linux-2.6.27.6/fs/xfs/xfs_inode.h 2008-10-13 14:52:06.000000000 +0200
8633 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_inode.h 2008-11-12 18:42:03.000000000 +0100
8634 @@ -173,7 +173,9 @@ typedef struct xfs_icdinode {
8635 __uint32_t di_gid; /* owner's group id */
8636 __uint32_t di_nlink; /* number of links to file */
8637 __uint16_t di_projid; /* owner's project id */
8638 - __uint8_t di_pad[8]; /* unused, zeroed space */
8639 + __uint16_t di_tag; /* context tagging */
8640 + __uint16_t di_vflags; /* vserver specific flags */
8641 + __uint8_t di_pad[4]; /* unused, zeroed space */
8642 __uint16_t di_flushiter; /* incremented on flush */
8643 xfs_ictimestamp_t di_atime; /* time last accessed */
8644 xfs_ictimestamp_t di_mtime; /* time last modified */
8645 @@ -500,9 +502,9 @@ int xfs_ialloc(struct xfs_trans *, xfs_
8646 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
8647 int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
8648 void xfs_dinode_from_disk(struct xfs_icdinode *,
8649 - struct xfs_dinode_core *);
8650 + struct xfs_dinode_core *, int tagged);
8651 void xfs_dinode_to_disk(struct xfs_dinode_core *,
8652 - struct xfs_icdinode *);
8653 + struct xfs_icdinode *, int tagged);
8655 uint xfs_ip2xflags(struct xfs_inode *);
8656 uint xfs_dic2xflags(struct xfs_dinode *);
8657 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_itable.c linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_itable.c
8658 --- linux-2.6.27.6/fs/xfs/xfs_itable.c 2008-10-13 14:52:06.000000000 +0200
8659 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_itable.c 2008-11-12 18:42:03.000000000 +0100
8660 @@ -82,6 +82,7 @@ xfs_bulkstat_one_iget(
8661 buf->bs_mode = dic->di_mode;
8662 buf->bs_uid = dic->di_uid;
8663 buf->bs_gid = dic->di_gid;
8664 + buf->bs_tag = dic->di_tag;
8665 buf->bs_size = dic->di_size;
8666 vn_atime_to_bstime(VFS_I(ip), &buf->bs_atime);
8667 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
8668 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_log_recover.c linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_log_recover.c
8669 --- linux-2.6.27.6/fs/xfs/xfs_log_recover.c 2008-10-13 14:52:06.000000000 +0200
8670 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_log_recover.c 2008-11-12 18:42:03.000000000 +0100
8671 @@ -2417,7 +2417,8 @@ xlog_recover_do_inode_trans(
8673 /* The core is in in-core format */
8674 xfs_dinode_to_disk(&dip->di_core,
8675 - (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8676 + (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8677 + mp->m_flags & XFS_MOUNT_TAGGED);
8679 /* the rest is in on-disk format */
8680 if (item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t)) {
8681 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_mount.h linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_mount.h
8682 --- linux-2.6.27.6/fs/xfs/xfs_mount.h 2008-10-13 14:52:06.000000000 +0200
8683 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_mount.h 2008-10-13 14:54:20.000000000 +0200
8684 @@ -384,6 +384,7 @@ typedef struct xfs_mount {
8686 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8688 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8691 * Default minimum read and write sizes.
8692 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_vnodeops.c linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_vnodeops.c
8693 --- linux-2.6.27.6/fs/xfs/xfs_vnodeops.c 2008-10-13 14:52:06.000000000 +0200
8694 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_vnodeops.c 2008-11-12 18:42:03.000000000 +0100
8695 @@ -75,6 +75,89 @@ xfs_open(
8700 +xfs_get_inode_flags(
8703 + struct inode *inode = VFS_I(ip);
8704 + unsigned int flags = inode->i_flags;
8705 + unsigned int vflags = inode->i_vflags;
8707 + if (flags & S_IMMUTABLE)
8708 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8710 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8711 + if (flags & S_IXUNLINK)
8712 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8714 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8716 + if (vflags & V_BARRIER)
8717 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8719 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8720 + if (vflags & V_COW)
8721 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8723 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8730 + struct xfs_mount *mp = ip->i_mount;
8731 + struct xfs_trans *tp;
8732 + unsigned int lock_flags = 0;
8735 + xfs_itrace_entry(ip);
8737 + if (mp->m_flags & XFS_MOUNT_RDONLY)
8738 + return XFS_ERROR(EROFS);
8741 + * we acquire the inode lock and do an error checking pass.
8743 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8744 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8746 + goto error_return;
8748 + lock_flags = XFS_ILOCK_EXCL;
8749 + xfs_ilock(ip, lock_flags);
8751 + xfs_trans_ijoin(tp, ip, lock_flags);
8752 + xfs_trans_ihold(tp, ip);
8754 + xfs_get_inode_flags(ip);
8755 + // xfs_diflags_to_linux(ip);
8757 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8758 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8760 + XFS_STATS_INC(xs_ig_attrchg);
8763 + * If this is a synchronous mount, make sure that the
8764 + * transaction goes to disk before returning to the user.
8766 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8767 + xfs_trans_set_sync(tp);
8768 + code = xfs_trans_commit(tp, 0);
8769 + xfs_iunlock(ip, lock_flags);
8776 + xfs_trans_cancel(tp, 0);
8778 + xfs_iunlock(ip, lock_flags);
8784 struct xfs_inode *ip,
8785 @@ -91,6 +174,7 @@ xfs_setattr(
8786 uint commit_flags=0;
8787 uid_t uid=0, iuid=0;
8788 gid_t gid=0, igid=0;
8789 + tag_t tag=0, itag=0;
8791 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8793 @@ -238,7 +322,7 @@ xfs_setattr(
8794 * and can change the group id only to a group of which he
8795 * or she is a member.
8797 - if (mask & (ATTR_UID|ATTR_GID)) {
8798 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8800 * These IDs could have changed since we last looked at them.
8801 * But, we're assured that if the ownership did change
8802 @@ -247,8 +331,10 @@ xfs_setattr(
8804 iuid = ip->i_d.di_uid;
8805 igid = ip->i_d.di_gid;
8806 + itag = ip->i_d.di_tag;
8807 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8808 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8809 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8812 * CAP_CHOWN overrides the following restrictions:
8813 @@ -272,7 +358,9 @@ xfs_setattr(
8816 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8817 - (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
8818 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8819 + (XFS_IS_GQUOTA_ON(mp) && itag != tag)) {
8820 + /* TODO: handle tagging? */
8822 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
8823 capable(CAP_FOWNER) ?
8824 @@ -461,7 +549,7 @@ xfs_setattr(
8825 * and can change the group id only to a group of which he
8826 * or she is a member.
8828 - if (mask & (ATTR_UID|ATTR_GID)) {
8829 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8831 * CAP_FSETID overrides the following restrictions:
8833 @@ -477,6 +565,10 @@ xfs_setattr(
8834 * Change the ownerships and register quota modifications
8835 * in the transaction.
8837 + if (itag != tag) {
8838 + ip->i_d.di_tag = tag;
8839 + inode->i_tag = tag;
8842 if (XFS_IS_UQUOTA_ON(mp)) {
8843 ASSERT(mask & ATTR_UID);
8844 diff -NurpP --minimal linux-2.6.27.6/fs/xfs/xfs_vnodeops.h linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_vnodeops.h
8845 --- linux-2.6.27.6/fs/xfs/xfs_vnodeops.h 2008-10-13 14:52:06.000000000 +0200
8846 +++ linux-2.6.27.6-vs2.3.0.36/fs/xfs/xfs_vnodeops.h 2008-11-12 18:42:03.000000000 +0100
8847 @@ -15,6 +15,7 @@ struct xfs_iomap;
8850 int xfs_open(struct xfs_inode *ip);
8851 +int xfs_sync_xflags(struct xfs_inode *ip);
8852 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags,
8853 struct cred *credp);
8854 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8855 diff -NurpP --minimal linux-2.6.27.6/include/asm-generic/tlb.h linux-2.6.27.6-vs2.3.0.36/include/asm-generic/tlb.h
8856 --- linux-2.6.27.6/include/asm-generic/tlb.h 2008-07-13 23:51:29.000000000 +0200
8857 +++ linux-2.6.27.6-vs2.3.0.36/include/asm-generic/tlb.h 2008-10-13 14:54:20.000000000 +0200
8859 #define _ASM_GENERIC__TLB_H
8861 #include <linux/swap.h>
8862 +#include <linux/vs_memory.h>
8863 #include <asm/pgalloc.h>
8864 #include <asm/tlbflush.h>
8866 diff -NurpP --minimal linux-2.6.27.6/include/asm-x86/unistd_64.h linux-2.6.27.6-vs2.3.0.36/include/asm-x86/unistd_64.h
8867 --- linux-2.6.27.6/include/asm-x86/unistd_64.h 2008-10-13 14:52:08.000000000 +0200
8868 +++ linux-2.6.27.6-vs2.3.0.36/include/asm-x86/unistd_64.h 2008-10-13 14:54:20.000000000 +0200
8869 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
8870 #define __NR_utimes 235
8871 __SYSCALL(__NR_utimes, sys_utimes)
8872 #define __NR_vserver 236
8873 -__SYSCALL(__NR_vserver, sys_ni_syscall)
8874 +__SYSCALL(__NR_vserver, sys_vserver)
8875 #define __NR_mbind 237
8876 __SYSCALL(__NR_mbind, sys_mbind)
8877 #define __NR_set_mempolicy 238
8878 diff -NurpP --minimal linux-2.6.27.6/include/linux/capability.h linux-2.6.27.6-vs2.3.0.36/include/linux/capability.h
8879 --- linux-2.6.27.6/include/linux/capability.h 2008-10-13 14:52:09.000000000 +0200
8880 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/capability.h 2008-10-13 14:54:20.000000000 +0200
8881 @@ -274,6 +274,7 @@ typedef struct kernel_cap_struct {
8882 arbitrary SCSI commands */
8883 /* Allow setting encryption key on loopback filesystem */
8884 /* Allow setting zone reclaim policy */
8885 +/* Allow the selection of a security context */
8887 #define CAP_SYS_ADMIN 21
8889 @@ -346,7 +347,13 @@ typedef struct kernel_cap_struct {
8891 #define CAP_MAC_ADMIN 33
8893 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8894 +/* Allow context manipulations */
8895 +/* Allow changing context info on files */
8897 +#define CAP_CONTEXT 34
8900 +#define CAP_LAST_CAP CAP_CONTEXT
8902 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8904 diff -NurpP --minimal linux-2.6.27.6/include/linux/devpts_fs.h linux-2.6.27.6-vs2.3.0.36/include/linux/devpts_fs.h
8905 --- linux-2.6.27.6/include/linux/devpts_fs.h 2008-07-13 23:51:29.000000000 +0200
8906 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/devpts_fs.h 2008-10-13 14:54:20.000000000 +0200
8907 @@ -34,5 +34,4 @@ static inline void devpts_pty_kill(int n
8912 #endif /* _LINUX_DEVPTS_FS_H */
8913 diff -NurpP --minimal linux-2.6.27.6/include/linux/ext2_fs.h linux-2.6.27.6-vs2.3.0.36/include/linux/ext2_fs.h
8914 --- linux-2.6.27.6/include/linux/ext2_fs.h 2008-10-13 14:52:09.000000000 +0200
8915 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/ext2_fs.h 2008-10-13 14:54:20.000000000 +0200
8916 @@ -189,8 +189,12 @@ struct ext2_group_desc
8917 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8918 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8919 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8920 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8921 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8923 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8924 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8926 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8927 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8929 @@ -247,7 +251,7 @@ struct ext2_inode {
8931 __u8 l_i_frag; /* Fragment number */
8932 __u8 l_i_fsize; /* Fragment size */
8934 + __u16 l_i_tag; /* Context Tag */
8935 __le16 l_i_uid_high; /* these 2 fields */
8936 __le16 l_i_gid_high; /* were reserved2[0] */
8937 __u32 l_i_reserved2;
8938 @@ -279,6 +283,7 @@ struct ext2_inode {
8939 #define i_gid_low i_gid
8940 #define i_uid_high osd2.linux2.l_i_uid_high
8941 #define i_gid_high osd2.linux2.l_i_gid_high
8942 +#define i_raw_tag osd2.linux2.l_i_tag
8943 #define i_reserved2 osd2.linux2.l_i_reserved2
8946 @@ -323,6 +328,7 @@ struct ext2_inode {
8947 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8948 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8949 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8950 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8953 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8954 diff -NurpP --minimal linux-2.6.27.6/include/linux/ext3_fs.h linux-2.6.27.6-vs2.3.0.36/include/linux/ext3_fs.h
8955 --- linux-2.6.27.6/include/linux/ext3_fs.h 2008-10-13 14:52:09.000000000 +0200
8956 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/ext3_fs.h 2008-10-31 18:15:18.000000000 +0100
8957 @@ -173,10 +173,14 @@ struct ext3_group_desc
8958 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8959 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8960 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8961 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8962 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8964 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8965 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8966 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8967 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8969 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8970 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8973 * Inode dynamic state flags
8974 @@ -292,7 +296,7 @@ struct ext3_inode {
8976 __u8 l_i_frag; /* Fragment number */
8977 __u8 l_i_fsize; /* Fragment size */
8979 + __u16 l_i_tag; /* Context Tag */
8980 __le16 l_i_uid_high; /* these 2 fields */
8981 __le16 l_i_gid_high; /* were reserved2[0] */
8982 __u32 l_i_reserved2;
8983 @@ -326,6 +330,7 @@ struct ext3_inode {
8984 #define i_gid_low i_gid
8985 #define i_uid_high osd2.linux2.l_i_uid_high
8986 #define i_gid_high osd2.linux2.l_i_gid_high
8987 +#define i_raw_tag osd2.linux2.l_i_tag
8988 #define i_reserved2 osd2.linux2.l_i_reserved2
8990 #elif defined(__GNU__)
8991 @@ -380,6 +385,7 @@ struct ext3_inode {
8992 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
8993 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
8994 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8995 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8997 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8998 #ifndef _LINUX_EXT2_FS_H
8999 @@ -822,6 +828,7 @@ struct buffer_head * ext3_bread (handle_
9000 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
9001 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
9002 int create, int extend_disksize);
9003 +extern int ext3_sync_flags(struct inode *inode);
9005 extern struct inode *ext3_iget(struct super_block *, unsigned long);
9006 extern int ext3_write_inode (struct inode *, int);
9007 diff -NurpP --minimal linux-2.6.27.6/include/linux/fs.h linux-2.6.27.6-vs2.3.0.36/include/linux/fs.h
9008 --- linux-2.6.27.6/include/linux/fs.h 2008-10-13 14:52:09.000000000 +0200
9009 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/fs.h 2008-10-31 18:18:18.000000000 +0100
9010 @@ -128,6 +128,9 @@ extern int dir_notify_enable;
9011 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
9012 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
9013 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
9014 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
9015 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
9016 +#define MS_NOTAGCHECK (1<<26) /* don't check tags */
9017 #define MS_ACTIVE (1<<30)
9018 #define MS_NOUSER (1<<31)
9020 @@ -154,6 +157,14 @@ extern int dir_notify_enable;
9021 #define S_NOCMTIME 128 /* Do not update file c/mtime */
9022 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
9023 #define S_PRIVATE 512 /* Inode is fs-internal */
9024 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
9026 +/* Linux-VServer related Inode flags */
9030 +#define V_BARRIER 4 /* Barrier for chroot() */
9031 +#define V_COW 8 /* Copy on Write */
9034 * Note that nosuid etc flags are inode-specific: setting some file-system
9035 @@ -176,12 +187,15 @@ extern int dir_notify_enable;
9036 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
9037 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
9038 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
9039 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
9040 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
9041 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
9042 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
9043 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
9045 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
9046 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
9047 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
9048 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
9049 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
9050 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
9052 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
9053 @@ -189,6 +203,16 @@ extern int dir_notify_enable;
9054 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
9055 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
9057 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
9059 +#ifdef CONFIG_VSERVER_COWBL
9060 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
9061 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
9063 +# define IS_COW(inode) (0)
9064 +# define IS_COW_LINK(inode) (0)
9067 /* the read-only stuff doesn't really belong here, but any other place is
9068 probably as bad and I don't want to create yet another include file. */
9070 @@ -262,11 +286,14 @@ extern int dir_notify_enable;
9071 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
9072 #define FS_EXTENT_FL 0x00080000 /* Extents */
9073 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
9074 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
9075 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
9077 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
9078 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
9079 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
9080 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
9082 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
9083 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
9085 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
9086 #define SYNC_FILE_RANGE_WRITE 2
9087 @@ -337,6 +364,7 @@ typedef void (dio_iodone_t)(struct kiocb
9088 #define ATTR_KILL_PRIV (1 << 14)
9089 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
9090 #define ATTR_TIMES_SET (1 << 16)
9091 +#define ATTR_TAG (1 << 17)
9094 * This is the Inode Attributes structure, used for notify_change(). It
9095 @@ -352,6 +380,7 @@ struct iattr {
9101 struct timespec ia_atime;
9102 struct timespec ia_mtime;
9103 @@ -365,6 +394,9 @@ struct iattr {
9104 struct file *ia_file;
9107 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
9108 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
9111 * Includes for diskquotas.
9113 @@ -626,7 +658,9 @@ struct inode {
9114 unsigned int i_nlink;
9122 #ifdef __NEED_I_SIZE_ORDERED
9123 @@ -674,7 +708,8 @@ struct inode {
9124 unsigned long i_state;
9125 unsigned long dirtied_when; /* jiffies of first dirtying */
9127 - unsigned int i_flags;
9128 + unsigned short i_flags;
9129 + unsigned short i_vflags;
9131 atomic_t i_writecount;
9132 #ifdef CONFIG_SECURITY
9133 @@ -761,12 +796,12 @@ static inline void i_size_write(struct i
9135 static inline unsigned iminor(const struct inode *inode)
9137 - return MINOR(inode->i_rdev);
9138 + return MINOR(inode->i_mdev);
9141 static inline unsigned imajor(const struct inode *inode)
9143 - return MAJOR(inode->i_rdev);
9144 + return MAJOR(inode->i_mdev);
9147 extern struct block_device *I_BDEV(struct inode *inode);
9148 @@ -824,6 +859,7 @@ struct file {
9150 struct fown_struct f_owner;
9151 unsigned int f_uid, f_gid;
9153 struct file_ra_state f_ra;
9156 @@ -958,6 +994,7 @@ struct file_lock {
9157 struct file *fl_file;
9162 struct fasync_struct * fl_fasync; /* for lease break notifications */
9163 unsigned long fl_break_time; /* for nonblocking lease breaks */
9164 @@ -1287,6 +1324,7 @@ struct inode_operations {
9165 void (*truncate_range)(struct inode *, loff_t, loff_t);
9166 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
9168 + int (*sync_flags) (struct inode *);
9172 @@ -1302,6 +1340,7 @@ extern ssize_t vfs_readv(struct file *,
9173 unsigned long, loff_t *);
9174 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
9175 unsigned long, loff_t *);
9176 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
9178 struct super_operations {
9179 struct inode *(*alloc_inode)(struct super_block *sb);
9180 @@ -1992,6 +2031,7 @@ extern int dcache_dir_open(struct inode
9181 extern int dcache_dir_close(struct inode *, struct file *);
9182 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
9183 extern int dcache_readdir(struct file *, void *, filldir_t);
9184 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
9185 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
9186 extern int simple_statfs(struct dentry *, struct kstatfs *);
9187 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
9188 diff -NurpP --minimal linux-2.6.27.6/include/linux/if_tun.h linux-2.6.27.6-vs2.3.0.36/include/linux/if_tun.h
9189 --- linux-2.6.27.6/include/linux/if_tun.h 2008-10-13 14:52:09.000000000 +0200
9190 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/if_tun.h 2008-10-13 14:54:20.000000000 +0200
9192 #define TUNSETOFFLOAD _IOW('T', 208, unsigned int)
9193 #define TUNSETTXFILTER _IOW('T', 209, unsigned int)
9194 #define TUNGETIFF _IOR('T', 210, unsigned int)
9195 +#define TUNSETNID _IOW('T', 215, int)
9197 /* TUNSETIFF ifr flags */
9198 #define IFF_TUN 0x0001
9199 diff -NurpP --minimal linux-2.6.27.6/include/linux/init_task.h linux-2.6.27.6-vs2.3.0.36/include/linux/init_task.h
9200 --- linux-2.6.27.6/include/linux/init_task.h 2008-10-13 14:52:09.000000000 +0200
9201 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/init_task.h 2008-10-13 14:54:20.000000000 +0200
9202 @@ -179,6 +179,10 @@ extern struct group_info init_groups;
9204 INIT_TRACE_IRQFLAGS \
9207 + .vx_info = NULL, \
9209 + .nx_info = NULL, \
9213 diff -NurpP --minimal linux-2.6.27.6/include/linux/interrupt.h linux-2.6.27.6-vs2.3.0.36/include/linux/interrupt.h
9214 --- linux-2.6.27.6/include/linux/interrupt.h 2008-10-13 14:52:09.000000000 +0200
9215 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/interrupt.h 2008-10-13 14:54:20.000000000 +0200
9217 #include <linux/preempt.h>
9218 #include <linux/cpumask.h>
9219 #include <linux/irqreturn.h>
9220 -#include <linux/hardirq.h>
9221 #include <linux/sched.h>
9222 +#include <linux/hardirq.h>
9223 #include <linux/irqflags.h>
9224 #include <asm/atomic.h>
9225 #include <asm/ptrace.h>
9226 diff -NurpP --minimal linux-2.6.27.6/include/linux/ipc.h linux-2.6.27.6-vs2.3.0.36/include/linux/ipc.h
9227 --- linux-2.6.27.6/include/linux/ipc.h 2008-07-13 23:51:29.000000000 +0200
9228 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/ipc.h 2008-10-13 14:54:20.000000000 +0200
9229 @@ -93,6 +93,7 @@ struct kern_ipc_perm
9237 diff -NurpP --minimal linux-2.6.27.6/include/linux/Kbuild linux-2.6.27.6-vs2.3.0.36/include/linux/Kbuild
9238 --- linux-2.6.27.6/include/linux/Kbuild 2008-10-13 14:52:09.000000000 +0200
9239 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/Kbuild 2008-10-13 14:54:20.000000000 +0200
9240 @@ -369,3 +369,6 @@ unifdef-y += xattr.h
9243 objhdr-y += version.h
9245 +header-y += vserver/
9247 diff -NurpP --minimal linux-2.6.27.6/include/linux/loop.h linux-2.6.27.6-vs2.3.0.36/include/linux/loop.h
9248 --- linux-2.6.27.6/include/linux/loop.h 2008-07-13 23:51:29.000000000 +0200
9249 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/loop.h 2008-10-13 14:54:20.000000000 +0200
9250 @@ -45,6 +45,7 @@ struct loop_device {
9251 struct loop_func_table *lo_encryption;
9253 uid_t lo_key_owner; /* Who set the key */
9255 int (*ioctl)(struct loop_device *, int cmd,
9258 diff -NurpP --minimal linux-2.6.27.6/include/linux/magic.h linux-2.6.27.6-vs2.3.0.36/include/linux/magic.h
9259 --- linux-2.6.27.6/include/linux/magic.h 2008-07-13 23:51:29.000000000 +0200
9260 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/magic.h 2008-10-13 14:54:20.000000000 +0200
9263 #define ADFS_SUPER_MAGIC 0xadf5
9264 #define AFFS_SUPER_MAGIC 0xadff
9265 -#define AFS_SUPER_MAGIC 0x5346414F
9266 +#define AFS_SUPER_MAGIC 0x5346414F
9267 #define AUTOFS_SUPER_MAGIC 0x0187
9268 #define CODA_SUPER_MAGIC 0x73757245
9269 #define EFS_SUPER_MAGIC 0x414A53
9271 #define NFS_SUPER_MAGIC 0x6969
9272 #define OPENPROM_SUPER_MAGIC 0x9fa1
9273 #define PROC_SUPER_MAGIC 0x9fa0
9274 +#define DEVPTS_SUPER_MAGIC 0x1cd1
9275 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
9277 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
9278 diff -NurpP --minimal linux-2.6.27.6/include/linux/major.h linux-2.6.27.6-vs2.3.0.36/include/linux/major.h
9279 --- linux-2.6.27.6/include/linux/major.h 2008-10-13 14:52:09.000000000 +0200
9280 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/major.h 2008-10-13 14:54:20.000000000 +0200
9282 #define HD_MAJOR IDE0_MAJOR
9283 #define PTY_SLAVE_MAJOR 3
9285 +#define VROOT_MAJOR 4
9286 #define TTYAUX_MAJOR 5
9289 diff -NurpP --minimal linux-2.6.27.6/include/linux/mm_types.h linux-2.6.27.6-vs2.3.0.36/include/linux/mm_types.h
9290 --- linux-2.6.27.6/include/linux/mm_types.h 2008-10-13 14:52:09.000000000 +0200
9291 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/mm_types.h 2008-10-13 14:54:20.000000000 +0200
9292 @@ -216,6 +216,7 @@ struct mm_struct {
9294 /* Architecture-specific MM context */
9295 mm_context_t context;
9296 + struct vx_info *mm_vx_info;
9298 /* Swap token stuff */
9300 diff -NurpP --minimal linux-2.6.27.6/include/linux/mount.h linux-2.6.27.6-vs2.3.0.36/include/linux/mount.h
9301 --- linux-2.6.27.6/include/linux/mount.h 2008-10-13 14:52:09.000000000 +0200
9302 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/mount.h 2008-10-24 03:34:52.000000000 +0200
9303 @@ -37,6 +37,9 @@ struct mnt_namespace;
9304 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
9305 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
9307 +#define MNT_TAGID 0x10000
9308 +#define MNT_NOTAG 0x20000
9311 struct list_head mnt_hash;
9312 struct vfsmount *mnt_parent; /* fs we are mounted on */
9313 @@ -71,6 +74,7 @@ struct vfsmount {
9314 * are held, and all mnt_writer[]s on this mount have 0 as their ->count
9316 atomic_t __mnt_writers;
9317 + tag_t mnt_tag; /* tagging used for vfsmount */
9320 static inline struct vfsmount *mntget(struct vfsmount *mnt)
9321 diff -NurpP --minimal linux-2.6.27.6/include/linux/net.h linux-2.6.27.6-vs2.3.0.36/include/linux/net.h
9322 --- linux-2.6.27.6/include/linux/net.h 2008-10-13 14:52:09.000000000 +0200
9323 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/net.h 2008-10-13 14:54:20.000000000 +0200
9324 @@ -68,6 +68,7 @@ struct net;
9325 #define SOCK_NOSPACE 2
9326 #define SOCK_PASSCRED 3
9327 #define SOCK_PASSSEC 4
9328 +#define SOCK_USER_SOCKET 5
9330 #ifndef ARCH_HAS_SOCKET_TYPES
9332 diff -NurpP --minimal linux-2.6.27.6/include/linux/nfs_mount.h linux-2.6.27.6-vs2.3.0.36/include/linux/nfs_mount.h
9333 --- linux-2.6.27.6/include/linux/nfs_mount.h 2008-07-13 23:51:29.000000000 +0200
9334 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/nfs_mount.h 2008-10-13 14:54:20.000000000 +0200
9335 @@ -63,6 +63,7 @@ struct nfs_mount_data {
9336 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9337 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9338 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9339 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9340 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9341 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9344 diff -NurpP --minimal linux-2.6.27.6/include/linux/nsproxy.h linux-2.6.27.6-vs2.3.0.36/include/linux/nsproxy.h
9345 --- linux-2.6.27.6/include/linux/nsproxy.h 2008-10-13 14:52:09.000000000 +0200
9346 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/nsproxy.h 2008-10-13 14:54:20.000000000 +0200
9349 #include <linux/spinlock.h>
9350 #include <linux/sched.h>
9351 +#include <linux/vserver/debug.h>
9353 struct mnt_namespace;
9354 struct uts_namespace;
9355 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9358 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9359 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9360 void exit_task_namespaces(struct task_struct *tsk);
9361 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9362 void free_nsproxy(struct nsproxy *ns);
9363 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9364 struct fs_struct *);
9366 -static inline void put_nsproxy(struct nsproxy *ns)
9367 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9369 +static inline void __get_nsproxy(struct nsproxy *ns,
9370 + const char *_file, int _line)
9372 - if (atomic_dec_and_test(&ns->count)) {
9375 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9376 + ns, atomic_read(&ns->count), _file, _line);
9377 + atomic_inc(&ns->count);
9380 -static inline void get_nsproxy(struct nsproxy *ns)
9381 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9383 +static inline void __put_nsproxy(struct nsproxy *ns,
9384 + const char *_file, int _line)
9386 - atomic_inc(&ns->count);
9387 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9388 + ns, atomic_read(&ns->count), _file, _line);
9389 + if (atomic_dec_and_test(&ns->count)) {
9394 #ifdef CONFIG_CGROUP_NS
9395 diff -NurpP --minimal linux-2.6.27.6/include/linux/pid.h linux-2.6.27.6-vs2.3.0.36/include/linux/pid.h
9396 --- linux-2.6.27.6/include/linux/pid.h 2008-10-13 14:52:09.000000000 +0200
9397 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/pid.h 2008-10-13 14:54:20.000000000 +0200
9398 @@ -8,7 +8,8 @@ enum pid_type
9408 @@ -142,6 +143,7 @@ static inline pid_t pid_nr(struct pid *p
9411 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9412 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9413 pid_t pid_vnr(struct pid *pid);
9415 #define do_each_pid_task(pid, type, task) \
9416 diff -NurpP --minimal linux-2.6.27.6/include/linux/proc_fs.h linux-2.6.27.6-vs2.3.0.36/include/linux/proc_fs.h
9417 --- linux-2.6.27.6/include/linux/proc_fs.h 2008-10-13 14:52:09.000000000 +0200
9418 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/proc_fs.h 2008-10-13 14:54:20.000000000 +0200
9419 @@ -59,6 +59,7 @@ struct proc_dir_entry {
9425 const struct inode_operations *proc_iops;
9427 @@ -274,12 +275,18 @@ static inline void kclist_add(struct kco
9428 extern void kclist_add(struct kcore_list *, void *, size_t);
9435 int (*proc_get_link)(struct inode *, struct path *);
9436 int (*proc_read)(struct task_struct *task, char *page);
9437 int (*proc_show)(struct seq_file *m,
9438 struct pid_namespace *ns, struct pid *pid,
9439 struct task_struct *task);
9440 + int (*proc_vs_read)(char *page);
9441 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9442 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9445 struct ctl_table_header;
9446 @@ -287,6 +294,7 @@ struct ctl_table;
9453 struct proc_dir_entry *pde;
9454 diff -NurpP --minimal linux-2.6.27.6/include/linux/reiserfs_fs.h linux-2.6.27.6-vs2.3.0.36/include/linux/reiserfs_fs.h
9455 --- linux-2.6.27.6/include/linux/reiserfs_fs.h 2008-10-13 14:52:09.000000000 +0200
9456 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/reiserfs_fs.h 2008-10-13 14:54:20.000000000 +0200
9457 @@ -837,6 +837,11 @@ struct stat_data_v1 {
9458 #define REISERFS_COMPR_FL FS_COMPR_FL
9459 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9461 +/* unfortunately reiserfs sdattr is only 16 bit */
9462 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9463 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9464 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9466 /* persistent flags that file inherits from the parent directory */
9467 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9468 REISERFS_SYNC_FL | \
9469 @@ -846,6 +851,9 @@ struct stat_data_v1 {
9470 REISERFS_COMPR_FL | \
9471 REISERFS_NOTAIL_FL )
9473 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9474 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9476 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9479 @@ -1911,6 +1919,7 @@ static inline void reiserfs_update_sd(st
9480 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9481 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9482 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9483 +int reiserfs_sync_flags(struct inode *inode);
9486 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9487 diff -NurpP --minimal linux-2.6.27.6/include/linux/reiserfs_fs_sb.h linux-2.6.27.6-vs2.3.0.36/include/linux/reiserfs_fs_sb.h
9488 --- linux-2.6.27.6/include/linux/reiserfs_fs_sb.h 2008-10-13 14:52:09.000000000 +0200
9489 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/reiserfs_fs_sb.h 2008-10-13 14:54:20.000000000 +0200
9490 @@ -455,6 +455,7 @@ enum reiserfs_mount_options {
9492 REISERFS_BARRIER_NONE,
9493 REISERFS_BARRIER_FLUSH,
9496 /* Actions on error */
9497 REISERFS_ERROR_PANIC,
9498 diff -NurpP --minimal linux-2.6.27.6/include/linux/sched.h linux-2.6.27.6-vs2.3.0.36/include/linux/sched.h
9499 --- linux-2.6.27.6/include/linux/sched.h 2008-11-17 18:07:34.000000000 +0100
9500 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/sched.h 2008-11-17 18:20:41.000000000 +0100
9501 @@ -71,7 +71,6 @@ struct sched_param {
9502 #include <linux/fs_struct.h>
9503 #include <linux/compiler.h>
9504 #include <linux/completion.h>
9505 -#include <linux/pid.h>
9506 #include <linux/percpu.h>
9507 #include <linux/topology.h>
9508 #include <linux/proportions.h>
9509 @@ -88,6 +87,7 @@ struct sched_param {
9510 #include <linux/kobject.h>
9511 #include <linux/latencytop.h>
9512 #include <linux/cred.h>
9513 +#include <linux/pid.h>
9515 #include <asm/processor.h>
9517 @@ -357,25 +357,27 @@ extern void arch_unmap_area_topdown(stru
9518 * The mm counters are not protected by its page_table_lock,
9519 * so must be incremented atomically.
9521 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9522 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9523 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9524 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9525 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9527 +#define __set_mm_counter(mm, member, value) \
9528 + atomic_long_set(&(mm)->_##member, value)
9529 +#define get_mm_counter(mm, member) \
9530 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9531 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
9533 * The mm counters are protected by its page_table_lock,
9534 * so can be incremented directly.
9536 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9537 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9538 #define get_mm_counter(mm, member) ((mm)->_##member)
9539 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9540 -#define inc_mm_counter(mm, member) (mm)->_##member++
9541 -#define dec_mm_counter(mm, member) (mm)->_##member--
9543 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
9545 +#define set_mm_counter(mm, member, value) \
9546 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9547 +#define add_mm_counter(mm, member, value) \
9548 + vx_ ## member ## pages_add((mm), (value))
9549 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9550 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9552 #define get_mm_rss(mm) \
9553 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9554 #define update_hiwater_rss(mm) do { \
9555 @@ -1196,6 +1198,14 @@ struct task_struct {
9559 +/* vserver context data */
9560 + struct vx_info *vx_info;
9561 + struct nx_info *nx_info;
9567 /* Thread group tracking */
9570 @@ -1382,6 +1392,11 @@ struct pid_namespace;
9571 * see also pid_nr() etc in include/linux/pid.h
9574 +#include <linux/vserver/base.h>
9575 +#include <linux/vserver/context.h>
9576 +#include <linux/vserver/debug.h>
9577 +#include <linux/vserver/pid.h>
9579 static inline pid_t task_pid_nr(struct task_struct *tsk)
9582 @@ -1391,7 +1406,7 @@ pid_t task_pid_nr_ns(struct task_struct
9584 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9586 - return pid_vnr(task_pid(tsk));
9587 + return vx_map_pid(pid_vnr(task_pid(tsk)));
9591 @@ -1404,7 +1419,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9593 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9595 - return pid_vnr(task_tgid(tsk));
9596 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9600 diff -NurpP --minimal linux-2.6.27.6/include/linux/shmem_fs.h linux-2.6.27.6-vs2.3.0.36/include/linux/shmem_fs.h
9601 --- linux-2.6.27.6/include/linux/shmem_fs.h 2008-10-13 14:52:09.000000000 +0200
9602 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/shmem_fs.h 2008-10-13 14:54:20.000000000 +0200
9605 #define SHMEM_NR_DIRECT 16
9607 +#define TMPFS_SUPER_MAGIC 0x01021994
9610 struct shmem_inode_info {
9612 unsigned long flags;
9613 diff -NurpP --minimal linux-2.6.27.6/include/linux/stat.h linux-2.6.27.6-vs2.3.0.36/include/linux/stat.h
9614 --- linux-2.6.27.6/include/linux/stat.h 2008-07-13 23:51:29.000000000 +0200
9615 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/stat.h 2008-10-13 14:54:20.000000000 +0200
9616 @@ -66,6 +66,7 @@ struct kstat {
9623 struct timespec atime;
9624 diff -NurpP --minimal linux-2.6.27.6/include/linux/sunrpc/auth.h linux-2.6.27.6-vs2.3.0.36/include/linux/sunrpc/auth.h
9625 --- linux-2.6.27.6/include/linux/sunrpc/auth.h 2008-07-13 23:51:29.000000000 +0200
9626 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/sunrpc/auth.h 2008-10-13 14:54:20.000000000 +0200
9632 struct group_info *group_info;
9633 unsigned char machine_cred : 1;
9635 diff -NurpP --minimal linux-2.6.27.6/include/linux/sunrpc/clnt.h linux-2.6.27.6-vs2.3.0.36/include/linux/sunrpc/clnt.h
9636 --- linux-2.6.27.6/include/linux/sunrpc/clnt.h 2008-10-13 14:52:09.000000000 +0200
9637 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/sunrpc/clnt.h 2008-10-13 14:54:20.000000000 +0200
9638 @@ -43,7 +43,8 @@ struct rpc_clnt {
9639 unsigned int cl_softrtry : 1,/* soft timeouts */
9640 cl_discrtry : 1,/* disconnect before retry */
9641 cl_autobind : 1,/* use getport() */
9642 - cl_chatty : 1;/* be verbose */
9643 + cl_chatty : 1,/* be verbose */
9644 + cl_tag : 1;/* context tagging */
9646 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9647 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9648 diff -NurpP --minimal linux-2.6.27.6/include/linux/syscalls.h linux-2.6.27.6-vs2.3.0.36/include/linux/syscalls.h
9649 --- linux-2.6.27.6/include/linux/syscalls.h 2008-10-13 14:52:09.000000000 +0200
9650 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/syscalls.h 2008-10-13 14:54:20.000000000 +0200
9651 @@ -295,6 +295,8 @@ asmlinkage long sys_symlink(const char _
9652 asmlinkage long sys_unlink(const char __user *pathname);
9653 asmlinkage long sys_rename(const char __user *oldname,
9654 const char __user *newname);
9655 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9657 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9658 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9660 diff -NurpP --minimal linux-2.6.27.6/include/linux/sysctl.h linux-2.6.27.6-vs2.3.0.36/include/linux/sysctl.h
9661 --- linux-2.6.27.6/include/linux/sysctl.h 2008-10-13 14:52:09.000000000 +0200
9662 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/sysctl.h 2008-10-13 14:54:20.000000000 +0200
9663 @@ -70,6 +70,7 @@ enum
9664 CTL_ABI=9, /* Binary emulation */
9665 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9666 CTL_ARLAN=254, /* arlan wireless driver */
9667 + CTL_VSERVER=4242, /* Linux-VServer debug */
9668 CTL_S390DBF=5677, /* s390 debug */
9669 CTL_SUNRPC=7249, /* sunrpc debug */
9670 CTL_PM=9899, /* frv power management */
9671 @@ -104,6 +105,7 @@ enum
9673 KERN_PANIC=15, /* int: panic timeout */
9674 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9675 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9677 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9678 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9679 diff -NurpP --minimal linux-2.6.27.6/include/linux/sysfs.h linux-2.6.27.6-vs2.3.0.36/include/linux/sysfs.h
9680 --- linux-2.6.27.6/include/linux/sysfs.h 2008-10-13 14:52:09.000000000 +0200
9681 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/sysfs.h 2008-10-13 14:54:20.000000000 +0200
9683 #include <linux/list.h>
9684 #include <asm/atomic.h>
9686 +#define SYSFS_SUPER_MAGIC 0x62656572
9691 diff -NurpP --minimal linux-2.6.27.6/include/linux/time.h linux-2.6.27.6-vs2.3.0.36/include/linux/time.h
9692 --- linux-2.6.27.6/include/linux/time.h 2008-07-13 23:51:29.000000000 +0200
9693 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/time.h 2008-10-13 14:54:20.000000000 +0200
9694 @@ -179,6 +179,9 @@ static __always_inline void timespec_add
9695 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9699 +#include <linux/vs_time.h>
9701 #endif /* __KERNEL__ */
9703 #define NFDBITS __NFDBITS
9704 diff -NurpP --minimal linux-2.6.27.6/include/linux/types.h linux-2.6.27.6-vs2.3.0.36/include/linux/types.h
9705 --- linux-2.6.27.6/include/linux/types.h 2008-07-13 23:51:29.000000000 +0200
9706 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/types.h 2008-10-13 14:54:20.000000000 +0200
9707 @@ -36,6 +36,9 @@ typedef __kernel_uid32_t uid_t;
9708 typedef __kernel_gid32_t gid_t;
9709 typedef __kernel_uid16_t uid16_t;
9710 typedef __kernel_gid16_t gid16_t;
9711 +typedef unsigned int xid_t;
9712 +typedef unsigned int nid_t;
9713 +typedef unsigned int tag_t;
9715 typedef unsigned long uintptr_t;
9717 diff -NurpP --minimal linux-2.6.27.6/include/linux/vroot.h linux-2.6.27.6-vs2.3.0.36/include/linux/vroot.h
9718 --- linux-2.6.27.6/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9719 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vroot.h 2008-10-13 14:54:20.000000000 +0200
9723 + * include/linux/vroot.h
9725 + * written by Herbert Pötzl, 9/11/2002
9726 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9728 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9729 + * Redistribution of this file is permitted under the
9730 + * GNU General Public License.
9733 +#ifndef _LINUX_VROOT_H
9734 +#define _LINUX_VROOT_H
9739 +/* Possible states of device */
9745 +struct vroot_device {
9749 + struct semaphore vr_ctl_mutex;
9750 + struct block_device *vr_device;
9755 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9757 +extern int register_vroot_grb(vroot_grb_func *);
9758 +extern int unregister_vroot_grb(vroot_grb_func *);
9760 +#endif /* __KERNEL__ */
9762 +#define MAX_VROOT_DEFAULT 8
9765 + * IOCTL commands --- we will commandeer 0x56 ('V')
9768 +#define VROOT_SET_DEV 0x5600
9769 +#define VROOT_CLR_DEV 0x5601
9771 +#endif /* _LINUX_VROOT_H */
9772 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_base.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_base.h
9773 --- linux-2.6.27.6/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9774 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_base.h 2008-10-13 14:54:20.000000000 +0200
9779 +#include "vserver/base.h"
9780 +#include "vserver/check.h"
9781 +#include "vserver/debug.h"
9784 +#warning duplicate inclusion
9786 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_context.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_context.h
9787 --- linux-2.6.27.6/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9788 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_context.h 2008-10-13 14:54:20.000000000 +0200
9790 +#ifndef _VS_CONTEXT_H
9791 +#define _VS_CONTEXT_H
9793 +#include "vserver/base.h"
9794 +#include "vserver/check.h"
9795 +#include "vserver/context.h"
9796 +#include "vserver/history.h"
9797 +#include "vserver/debug.h"
9799 +#include <linux/sched.h>
9802 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9804 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9805 + const char *_file, int _line, void *_here)
9810 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9811 + vxi, vxi ? vxi->vx_id : 0,
9812 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9814 + __vxh_get_vx_info(vxi, _here);
9816 + atomic_inc(&vxi->vx_usecnt);
9821 +extern void free_vx_info(struct vx_info *);
9823 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9825 +static inline void __put_vx_info(struct vx_info *vxi,
9826 + const char *_file, int _line, void *_here)
9831 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9832 + vxi, vxi ? vxi->vx_id : 0,
9833 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9835 + __vxh_put_vx_info(vxi, _here);
9837 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9838 + free_vx_info(vxi);
9842 +#define init_vx_info(p, i) \
9843 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9845 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9846 + const char *_file, int _line, void *_here)
9849 + vxlprintk(VXD_CBIT(xid, 3),
9850 + "init_vx_info(%p[#%d.%d])",
9851 + vxi, vxi ? vxi->vx_id : 0,
9852 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9854 + __vxh_init_vx_info(vxi, vxp, _here);
9856 + atomic_inc(&vxi->vx_usecnt);
9862 +#define set_vx_info(p, i) \
9863 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9865 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9866 + const char *_file, int _line, void *_here)
9868 + struct vx_info *vxo;
9873 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9874 + vxi, vxi ? vxi->vx_id : 0,
9875 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9877 + __vxh_set_vx_info(vxi, vxp, _here);
9879 + atomic_inc(&vxi->vx_usecnt);
9880 + vxo = xchg(vxp, vxi);
9885 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9887 +static inline void __clr_vx_info(struct vx_info **vxp,
9888 + const char *_file, int _line, void *_here)
9890 + struct vx_info *vxo;
9892 + vxo = xchg(vxp, NULL);
9896 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9897 + vxo, vxo ? vxo->vx_id : 0,
9898 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9900 + __vxh_clr_vx_info(vxo, vxp, _here);
9902 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9903 + free_vx_info(vxo);
9907 +#define claim_vx_info(v, p) \
9908 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9910 +static inline void __claim_vx_info(struct vx_info *vxi,
9911 + struct task_struct *task,
9912 + const char *_file, int _line, void *_here)
9914 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9915 + vxi, vxi ? vxi->vx_id : 0,
9916 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9917 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9918 + task, _file, _line);
9919 + __vxh_claim_vx_info(vxi, task, _here);
9921 + atomic_inc(&vxi->vx_tasks);
9925 +extern void unhash_vx_info(struct vx_info *);
9927 +#define release_vx_info(v, p) \
9928 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9930 +static inline void __release_vx_info(struct vx_info *vxi,
9931 + struct task_struct *task,
9932 + const char *_file, int _line, void *_here)
9934 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9935 + vxi, vxi ? vxi->vx_id : 0,
9936 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9937 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9938 + task, _file, _line);
9939 + __vxh_release_vx_info(vxi, task, _here);
9943 + if (atomic_dec_and_test(&vxi->vx_tasks))
9944 + unhash_vx_info(vxi);
9948 +#define task_get_vx_info(p) \
9949 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9951 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9952 + const char *_file, int _line, void *_here)
9954 + struct vx_info *vxi;
9957 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9959 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9965 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9967 + if (waitqueue_active(&vxi->vx_wait))
9968 + wake_up_interruptible(&vxi->vx_wait);
9972 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9974 +static inline void __enter_vx_info(struct vx_info *vxi,
9975 + struct vx_info_save *vxis, const char *_file, int _line)
9977 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9978 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9979 + current->xid, current->vx_info, _file, _line);
9980 + vxis->vxi = xchg(¤t->vx_info, vxi);
9981 + vxis->xid = current->xid;
9982 + current->xid = vxi ? vxi->vx_id : 0;
9985 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9987 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9988 + const char *_file, int _line)
9990 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9991 + vxis, vxis->xid, vxis->vxi, current,
9992 + current->xid, current->vx_info, _file, _line);
9993 + (void)xchg(¤t->vx_info, vxis->vxi);
9994 + current->xid = vxis->xid;
9998 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
10000 + vxis->vxi = xchg(¤t->vx_info, NULL);
10001 + vxis->xid = xchg(¤t->xid, (xid_t)0);
10004 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
10006 + (void)xchg(¤t->xid, vxis->xid);
10007 + (void)xchg(¤t->vx_info, vxis->vxi);
10010 +extern void exit_vx_info(struct task_struct *, int);
10011 +extern void exit_vx_info_early(struct task_struct *, int);
10015 +#warning duplicate inclusion
10017 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_cowbl.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_cowbl.h
10018 --- linux-2.6.27.6/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
10019 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_cowbl.h 2008-10-13 14:54:20.000000000 +0200
10021 +#ifndef _VS_COWBL_H
10022 +#define _VS_COWBL_H
10024 +#include <linux/fs.h>
10025 +#include <linux/dcache.h>
10026 +#include <linux/namei.h>
10028 +extern struct dentry *cow_break_link(const char *pathname);
10030 +static inline int cow_check_and_break(struct path *path)
10032 + struct inode *inode = path->dentry->d_inode;
10035 + /* do we need this check? */
10036 + if (IS_RDONLY(inode))
10039 + if (IS_COW(inode)) {
10040 + if (IS_COW_LINK(inode)) {
10041 + struct dentry *new_dentry, *old_dentry = path->dentry;
10044 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
10048 + pp = d_path(path, buf, PATH_MAX);
10049 + new_dentry = cow_break_link(pp);
10051 + if (!IS_ERR(new_dentry)) {
10052 + path->dentry = new_dentry;
10053 + dput(old_dentry);
10055 + error = PTR_ERR(new_dentry);
10057 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
10058 + inode->i_ctime = CURRENT_TIME;
10059 + mark_inode_dirty(inode);
10066 +#warning duplicate inclusion
10068 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_cvirt.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_cvirt.h
10069 --- linux-2.6.27.6/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
10070 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_cvirt.h 2008-10-13 14:54:20.000000000 +0200
10072 +#ifndef _VS_CVIRT_H
10073 +#define _VS_CVIRT_H
10075 +#include "vserver/cvirt.h"
10076 +#include "vserver/context.h"
10077 +#include "vserver/base.h"
10078 +#include "vserver/check.h"
10079 +#include "vserver/debug.h"
10082 +static inline void vx_activate_task(struct task_struct *p)
10084 + struct vx_info *vxi;
10086 + if ((vxi = p->vx_info)) {
10087 + vx_update_load(vxi);
10088 + atomic_inc(&vxi->cvirt.nr_running);
10092 +static inline void vx_deactivate_task(struct task_struct *p)
10094 + struct vx_info *vxi;
10096 + if ((vxi = p->vx_info)) {
10097 + vx_update_load(vxi);
10098 + atomic_dec(&vxi->cvirt.nr_running);
10102 +static inline void vx_uninterruptible_inc(struct task_struct *p)
10104 + struct vx_info *vxi;
10106 + if ((vxi = p->vx_info))
10107 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
10110 +static inline void vx_uninterruptible_dec(struct task_struct *p)
10112 + struct vx_info *vxi;
10114 + if ((vxi = p->vx_info))
10115 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
10120 +#warning duplicate inclusion
10122 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_device.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_device.h
10123 --- linux-2.6.27.6/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
10124 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_device.h 2008-10-13 14:54:20.000000000 +0200
10126 +#ifndef _VS_DEVICE_H
10127 +#define _VS_DEVICE_H
10129 +#include "vserver/base.h"
10130 +#include "vserver/device.h"
10131 +#include "vserver/debug.h"
10134 +#ifdef CONFIG_VSERVER_DEVICE
10136 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
10138 +#define vs_device_perm(v, d, m, p) \
10139 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
10144 +int vs_map_device(struct vx_info *vxi,
10145 + dev_t device, dev_t *target, umode_t mode)
10148 + *target = device;
10152 +#define vs_device_perm(v, d, m, p) ((p) == (p))
10157 +#define vs_map_chrdev(d, t, p) \
10158 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
10159 +#define vs_map_blkdev(d, t, p) \
10160 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
10162 +#define vs_chrdev_perm(d, p) \
10163 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
10164 +#define vs_blkdev_perm(d, p) \
10165 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
10169 +#warning duplicate inclusion
10171 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_dlimit.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_dlimit.h
10172 --- linux-2.6.27.6/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
10173 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_dlimit.h 2008-10-13 14:54:20.000000000 +0200
10175 +#ifndef _VS_DLIMIT_H
10176 +#define _VS_DLIMIT_H
10178 +#include <linux/fs.h>
10180 +#include "vserver/dlimit.h"
10181 +#include "vserver/base.h"
10182 +#include "vserver/debug.h"
10185 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
10187 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
10188 + const char *_file, int _line)
10192 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
10193 + dli, dli ? dli->dl_tag : 0,
10194 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10196 + atomic_inc(&dli->dl_usecnt);
10201 +#define free_dl_info(i) \
10202 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
10204 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
10206 +static inline void __put_dl_info(struct dl_info *dli,
10207 + const char *_file, int _line)
10211 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
10212 + dli, dli ? dli->dl_tag : 0,
10213 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10215 + if (atomic_dec_and_test(&dli->dl_usecnt))
10216 + free_dl_info(dli);
10220 +#define __dlimit_char(d) ((d) ? '*' : ' ')
10222 +static inline int __dl_alloc_space(struct super_block *sb,
10223 + tag_t tag, dlsize_t nr, const char *file, int line)
10225 + struct dl_info *dli = NULL;
10230 + dli = locate_dl_info(sb, tag);
10234 + spin_lock(&dli->dl_lock);
10235 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
10237 + dli->dl_space_used += nr;
10238 + spin_unlock(&dli->dl_lock);
10239 + put_dl_info(dli);
10241 + vxlprintk(VXD_CBIT(dlim, 1),
10242 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
10243 + sb, tag, __dlimit_char(dli), (long long)nr,
10244 + ret, file, line);
10248 +static inline void __dl_free_space(struct super_block *sb,
10249 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10251 + struct dl_info *dli = NULL;
10255 + dli = locate_dl_info(sb, tag);
10259 + spin_lock(&dli->dl_lock);
10260 + if (dli->dl_space_used > nr)
10261 + dli->dl_space_used -= nr;
10263 + dli->dl_space_used = 0;
10264 + spin_unlock(&dli->dl_lock);
10265 + put_dl_info(dli);
10267 + vxlprintk(VXD_CBIT(dlim, 1),
10268 + "FREE (%p,#%d)%c %lld bytes",
10269 + sb, tag, __dlimit_char(dli), (long long)nr,
10273 +static inline int __dl_alloc_inode(struct super_block *sb,
10274 + tag_t tag, const char *_file, int _line)
10276 + struct dl_info *dli;
10279 + dli = locate_dl_info(sb, tag);
10283 + spin_lock(&dli->dl_lock);
10284 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
10286 + dli->dl_inodes_used++;
10287 + spin_unlock(&dli->dl_lock);
10288 + put_dl_info(dli);
10290 + vxlprintk(VXD_CBIT(dlim, 0),
10291 + "ALLOC (%p,#%d)%c inode (%d)",
10292 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10296 +static inline void __dl_free_inode(struct super_block *sb,
10297 + tag_t tag, const char *_file, int _line)
10299 + struct dl_info *dli;
10301 + dli = locate_dl_info(sb, tag);
10305 + spin_lock(&dli->dl_lock);
10306 + if (dli->dl_inodes_used > 1)
10307 + dli->dl_inodes_used--;
10309 + dli->dl_inodes_used = 0;
10310 + spin_unlock(&dli->dl_lock);
10311 + put_dl_info(dli);
10313 + vxlprintk(VXD_CBIT(dlim, 0),
10314 + "FREE (%p,#%d)%c inode",
10315 + sb, tag, __dlimit_char(dli), _file, _line);
10318 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10319 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10320 + const char *_file, int _line)
10322 + struct dl_info *dli;
10323 + uint64_t broot, bfree;
10325 + dli = locate_dl_info(sb, tag);
10329 + spin_lock(&dli->dl_lock);
10330 + broot = (dli->dl_space_total -
10331 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10332 + >> sb->s_blocksize_bits;
10333 + bfree = (dli->dl_space_total - dli->dl_space_used)
10334 + >> sb->s_blocksize_bits;
10335 + spin_unlock(&dli->dl_lock);
10337 + vxlprintk(VXD_CBIT(dlim, 2),
10338 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10339 + (long long)bfree, (long long)broot,
10340 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10342 + if (free_blocks) {
10343 + if (*free_blocks > bfree)
10344 + *free_blocks = bfree;
10346 + if (root_blocks) {
10347 + if (*root_blocks > broot)
10348 + *root_blocks = broot;
10350 + put_dl_info(dli);
10353 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
10354 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10355 + __FILE__, __LINE__ )
10357 +#define DLIMIT_FREE_SPACE(in, bytes) \
10358 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10359 + __FILE__, __LINE__ )
10361 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
10362 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
10363 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10364 + __FILE__, __LINE__ )
10366 +#define DLIMIT_FREE_BLOCK(in, nr) \
10367 + __dl_free_space((in)->i_sb, (in)->i_tag, \
10368 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10369 + __FILE__, __LINE__ )
10372 +#define DLIMIT_ALLOC_INODE(in) \
10373 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10375 +#define DLIMIT_FREE_INODE(in) \
10376 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10379 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
10380 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10384 +#warning duplicate inclusion
10386 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/base.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/base.h
10387 --- linux-2.6.27.6/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10388 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/base.h 2008-10-13 14:54:20.000000000 +0200
10390 +#ifndef _VX_BASE_H
10391 +#define _VX_BASE_H
10394 +/* context state changes */
10406 +#define vx_task_xid(t) ((t)->xid)
10408 +#define vx_current_xid() vx_task_xid(current)
10410 +#define current_vx_info() (current->vx_info)
10413 +#define nx_task_nid(t) ((t)->nid)
10415 +#define nx_current_nid() nx_task_nid(current)
10417 +#define current_nx_info() (current->nx_info)
10420 +/* generic flag merging */
10422 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10424 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10426 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10428 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10431 +/* context flags */
10433 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10435 +#define vx_current_flags() __vx_flags(current->vx_info)
10437 +#define vx_info_flags(v, m, f) \
10438 + vs_check_flags(__vx_flags(v), m, f)
10440 +#define task_vx_flags(t, m, f) \
10441 + ((t) && vx_info_flags((t)->vx_info, m, f))
10443 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
10446 +/* context caps */
10448 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10450 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
10452 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10454 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
10458 +/* network flags */
10460 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10462 +#define nx_current_flags() __nx_flags(current->nx_info)
10464 +#define nx_info_flags(n, m, f) \
10465 + vs_check_flags(__nx_flags(n), m, f)
10467 +#define task_nx_flags(t, m, f) \
10468 + ((t) && nx_info_flags((t)->nx_info, m, f))
10470 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
10473 +/* network caps */
10475 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10477 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
10479 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10481 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
10484 +/* context mask capabilities */
10486 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10488 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10490 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
10493 +/* context bcap mask */
10495 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10497 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
10500 +/* mask given bcaps */
10502 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10504 +#define vx_mbcaps(c) vx_info_mbcaps(current->vx_info, c)
10507 +/* masked cap_bset */
10509 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10511 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
10514 +#define vx_info_mbcap(v, b) \
10515 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10516 + vx_info_bcaps(v, b) : (b))
10518 +#define task_vx_mbcap(t, b) \
10519 + vx_info_mbcap((t)->vx_info, (t)->b)
10521 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10524 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10526 +#define vx_capable(b, c) (capable(b) || \
10527 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
10529 +#define nx_capable(b, c) (capable(b) || \
10530 + (cap_raised(current->cap_effective, b) && nx_ncaps(c)))
10532 +#define vx_current_initpid(n) \
10533 + (current->vx_info && \
10534 + (current->vx_info->vx_initpid == (n)))
10537 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10539 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10542 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10544 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10547 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/cacct_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cacct_cmd.h
10548 --- linux-2.6.27.6/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10549 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cacct_cmd.h 2008-10-13 14:54:20.000000000 +0200
10551 +#ifndef _VX_CACCT_CMD_H
10552 +#define _VX_CACCT_CMD_H
10555 +/* virtual host info name commands */
10557 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10559 +struct vcmd_sock_stat_v0 {
10561 + uint32_t count[3];
10562 + uint64_t total[3];
10568 +#include <linux/compiler.h>
10570 +extern int vc_sock_stat(struct vx_info *, void __user *);
10572 +#endif /* __KERNEL__ */
10573 +#endif /* _VX_CACCT_CMD_H */
10574 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/cacct_def.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cacct_def.h
10575 --- linux-2.6.27.6/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10576 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cacct_def.h 2008-10-13 14:54:20.000000000 +0200
10578 +#ifndef _VX_CACCT_DEF_H
10579 +#define _VX_CACCT_DEF_H
10581 +#include <asm/atomic.h>
10582 +#include <linux/vserver/cacct.h>
10585 +struct _vx_sock_acc {
10586 + atomic_long_t count;
10587 + atomic_long_t total;
10590 +/* context sub struct */
10592 +struct _vx_cacct {
10593 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10594 + atomic_t slab[8];
10595 + atomic_t page[6][8];
10598 +#ifdef CONFIG_VSERVER_DEBUG
10600 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10604 + printk("\t_vx_cacct:");
10605 + for (i = 0; i < 6; i++) {
10606 + struct _vx_sock_acc *ptr = cacct->sock[i];
10608 + printk("\t [%d] =", i);
10609 + for (j = 0; j < 3; j++) {
10610 + printk(" [%d] = %8lu, %8lu", j,
10611 + atomic_long_read(&ptr[j].count),
10612 + atomic_long_read(&ptr[j].total));
10620 +#endif /* _VX_CACCT_DEF_H */
10621 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/cacct.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cacct.h
10622 --- linux-2.6.27.6/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10623 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cacct.h 2008-10-13 14:54:20.000000000 +0200
10625 +#ifndef _VX_CACCT_H
10626 +#define _VX_CACCT_H
10629 +enum sock_acc_field {
10630 + VXA_SOCK_UNSPEC = 0,
10636 + VXA_SOCK_SIZE /* array size */
10639 +#endif /* _VX_CACCT_H */
10640 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/cacct_int.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cacct_int.h
10641 --- linux-2.6.27.6/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10642 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cacct_int.h 2008-10-13 14:54:20.000000000 +0200
10644 +#ifndef _VX_CACCT_INT_H
10645 +#define _VX_CACCT_INT_H
10651 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10653 + return atomic_long_read(&cacct->sock[type][pos].count);
10658 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10660 + return atomic_long_read(&cacct->sock[type][pos].total);
10663 +#endif /* __KERNEL__ */
10664 +#endif /* _VX_CACCT_INT_H */
10665 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/check.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/check.h
10666 --- linux-2.6.27.6/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10667 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/check.h 2008-10-13 14:54:20.000000000 +0200
10669 +#ifndef _VS_CHECK_H
10670 +#define _VS_CHECK_H
10673 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10675 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10676 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10678 +#define MIN_D_CONTEXT 65536
10681 +/* check conditions */
10683 +#define VS_ADMIN 0x0001
10684 +#define VS_WATCH 0x0002
10685 +#define VS_HIDE 0x0004
10686 +#define VS_HOSTID 0x0008
10688 +#define VS_IDENT 0x0010
10689 +#define VS_EQUIV 0x0020
10690 +#define VS_PARENT 0x0040
10691 +#define VS_CHILD 0x0080
10693 +#define VS_ARG_MASK 0x00F0
10695 +#define VS_DYNAMIC 0x0100
10696 +#define VS_STATIC 0x0200
10698 +#define VS_ATR_MASK 0x0F00
10700 +#ifdef CONFIG_VSERVER_PRIVACY
10701 +#define VS_ADMIN_P (0)
10702 +#define VS_WATCH_P (0)
10704 +#define VS_ADMIN_P VS_ADMIN
10705 +#define VS_WATCH_P VS_WATCH
10708 +#define VS_HARDIRQ 0x1000
10709 +#define VS_SOFTIRQ 0x2000
10710 +#define VS_IRQ 0x4000
10712 +#define VS_IRQ_MASK 0xF000
10714 +#include <linux/hardirq.h>
10717 + * check current context for ADMIN/WATCH and
10718 + * optionally against supplied argument
10720 +static inline int __vs_check(int cid, int id, unsigned int mode)
10722 + if (mode & VS_ARG_MASK) {
10723 + if ((mode & VS_IDENT) && (id == cid))
10726 + if (mode & VS_ATR_MASK) {
10727 + if ((mode & VS_DYNAMIC) &&
10728 + (id >= MIN_D_CONTEXT) &&
10729 + (id <= MAX_S_CONTEXT))
10731 + if ((mode & VS_STATIC) &&
10732 + (id > 1) && (id < MIN_D_CONTEXT))
10735 + if (mode & VS_IRQ_MASK) {
10736 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10738 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10740 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10743 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10744 + ((mode & VS_WATCH) && (cid == 1)) ||
10745 + ((mode & VS_HOSTID) && (id == 0)));
10748 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10750 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10753 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10755 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10758 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/context_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/context_cmd.h
10759 --- linux-2.6.27.6/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10760 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/context_cmd.h 2008-10-13 14:54:20.000000000 +0200
10762 +#ifndef _VX_CONTEXT_CMD_H
10763 +#define _VX_CONTEXT_CMD_H
10766 +/* vinfo commands */
10768 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10771 +extern int vc_task_xid(uint32_t);
10773 +#endif /* __KERNEL__ */
10775 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10777 +struct vcmd_vx_info_v0 {
10779 + uint32_t initpid;
10780 + /* more to come */
10784 +extern int vc_vx_info(struct vx_info *, void __user *);
10786 +#endif /* __KERNEL__ */
10788 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10790 +struct vcmd_ctx_stat_v0 {
10793 + /* more to come */
10797 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10799 +#endif /* __KERNEL__ */
10801 +/* context commands */
10803 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10804 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10806 +struct vcmd_ctx_create {
10807 + uint64_t flagword;
10810 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10811 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10813 +struct vcmd_ctx_migrate {
10814 + uint64_t flagword;
10818 +extern int vc_ctx_create(uint32_t, void __user *);
10819 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10821 +#endif /* __KERNEL__ */
10824 +/* flag commands */
10826 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10827 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10829 +struct vcmd_ctx_flags_v0 {
10830 + uint64_t flagword;
10835 +extern int vc_get_cflags(struct vx_info *, void __user *);
10836 +extern int vc_set_cflags(struct vx_info *, void __user *);
10838 +#endif /* __KERNEL__ */
10841 +/* context caps commands */
10843 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10844 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10846 +struct vcmd_ctx_caps_v1 {
10852 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10853 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10855 +#endif /* __KERNEL__ */
10858 +/* bcaps commands */
10860 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10861 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10863 +struct vcmd_bcaps {
10869 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10870 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10872 +#endif /* __KERNEL__ */
10877 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10878 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10880 +struct vcmd_badness_v0 {
10885 +extern int vc_get_badness(struct vx_info *, void __user *);
10886 +extern int vc_set_badness(struct vx_info *, void __user *);
10888 +#endif /* __KERNEL__ */
10889 +#endif /* _VX_CONTEXT_CMD_H */
10890 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/context.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/context.h
10891 --- linux-2.6.27.6/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10892 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/context.h 2008-10-31 18:15:28.000000000 +0100
10894 +#ifndef _VX_CONTEXT_H
10895 +#define _VX_CONTEXT_H
10897 +#include <linux/types.h>
10898 +#include <linux/capability.h>
10901 +/* context flags */
10903 +#define VXF_INFO_SCHED 0x00000002
10904 +#define VXF_INFO_NPROC 0x00000004
10905 +#define VXF_INFO_PRIVATE 0x00000008
10907 +#define VXF_INFO_INIT 0x00000010
10908 +#define VXF_INFO_HIDE 0x00000020
10909 +#define VXF_INFO_ULIMIT 0x00000040
10910 +#define VXF_INFO_NSPACE 0x00000080
10912 +#define VXF_SCHED_HARD 0x00000100
10913 +#define VXF_SCHED_PRIO 0x00000200
10914 +#define VXF_SCHED_PAUSE 0x00000400
10916 +#define VXF_VIRT_MEM 0x00010000
10917 +#define VXF_VIRT_UPTIME 0x00020000
10918 +#define VXF_VIRT_CPU 0x00040000
10919 +#define VXF_VIRT_LOAD 0x00080000
10920 +#define VXF_VIRT_TIME 0x00100000
10922 +#define VXF_HIDE_MOUNT 0x01000000
10923 +/* was VXF_HIDE_NETIF 0x02000000 */
10924 +#define VXF_HIDE_VINFO 0x04000000
10926 +#define VXF_STATE_SETUP (1ULL << 32)
10927 +#define VXF_STATE_INIT (1ULL << 33)
10928 +#define VXF_STATE_ADMIN (1ULL << 34)
10930 +#define VXF_SC_HELPER (1ULL << 36)
10931 +#define VXF_REBOOT_KILL (1ULL << 37)
10932 +#define VXF_PERSISTENT (1ULL << 38)
10934 +#define VXF_FORK_RSS (1ULL << 48)
10935 +#define VXF_PROLIFIC (1ULL << 49)
10937 +#define VXF_IGNEG_NICE (1ULL << 52)
10939 +#define VXF_ONE_TIME (0x0007ULL << 32)
10941 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10944 +/* context migration */
10946 +#define VXM_SET_INIT 0x00000001
10947 +#define VXM_SET_REAPER 0x00000002
10949 +/* context caps */
10951 +#define VXC_CAP_MASK 0x00000000
10953 +#define VXC_SET_UTSNAME 0x00000001
10954 +#define VXC_SET_RLIMIT 0x00000002
10956 +/* was VXC_RAW_ICMP 0x00000100 */
10957 +#define VXC_SYSLOG 0x00001000
10959 +#define VXC_SECURE_MOUNT 0x00010000
10960 +#define VXC_SECURE_REMOUNT 0x00020000
10961 +#define VXC_BINARY_MOUNT 0x00040000
10963 +#define VXC_QUOTA_CTL 0x00100000
10964 +#define VXC_ADMIN_MAPPER 0x00200000
10965 +#define VXC_ADMIN_CLOOP 0x00400000
10967 +#define VXC_KTHREAD 0x01000000
10972 +#include <linux/list.h>
10973 +#include <linux/spinlock.h>
10974 +#include <linux/rcupdate.h>
10976 +#include "limit_def.h"
10977 +#include "sched_def.h"
10978 +#include "cvirt_def.h"
10979 +#include "cacct_def.h"
10980 +#include "device_def.h"
10982 +#define VX_SPACES 2
10984 +struct _vx_info_pc {
10985 + struct _vx_sched_pc sched_pc;
10986 + struct _vx_cvirt_pc cvirt_pc;
10990 + struct hlist_node vx_hlist; /* linked list of contexts */
10991 + xid_t vx_id; /* context id */
10992 + atomic_t vx_usecnt; /* usage count */
10993 + atomic_t vx_tasks; /* tasks count */
10994 + struct vx_info *vx_parent; /* parent context */
10995 + int vx_state; /* context state */
10997 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
10998 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
10999 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
11001 + uint64_t vx_flags; /* context flags */
11002 + uint64_t vx_ccaps; /* context caps (vserver) */
11003 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11004 + // kernel_cap_t vx_cap_bset; /* the guest's bset */
11006 + struct task_struct *vx_reaper; /* guest reaper process */
11007 + pid_t vx_initpid; /* PID of guest init */
11008 + int64_t vx_badness_bias; /* OOM points bias */
11010 + struct _vx_limit limit; /* vserver limits */
11011 + struct _vx_sched sched; /* vserver scheduler */
11012 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11013 + struct _vx_cacct cacct; /* context accounting */
11015 + struct _vx_device dmap; /* default device map targets */
11017 +#ifndef CONFIG_SMP
11018 + struct _vx_info_pc info_pc; /* per cpu data */
11020 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11023 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11024 + int reboot_cmd; /* last sys_reboot() cmd */
11025 + int exit_code; /* last process exit code */
11027 + char vx_name[65]; /* vserver name */
11030 +#ifndef CONFIG_SMP
11031 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11032 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11034 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11035 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11038 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11041 +struct vx_info_save {
11042 + struct vx_info *vxi;
11047 +/* status flags */
11049 +#define VXS_HASHED 0x0001
11050 +#define VXS_PAUSED 0x0010
11051 +#define VXS_SHUTDOWN 0x0100
11052 +#define VXS_HELPER 0x1000
11053 +#define VXS_RELEASED 0x8000
11056 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11057 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11059 +extern struct vx_info *lookup_vx_info(int);
11060 +extern struct vx_info *lookup_or_create_vx_info(int);
11062 +extern int get_xid_list(int, unsigned int *, int);
11063 +extern int xid_is_hashed(xid_t);
11065 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11067 +extern long vs_state_change(struct vx_info *, unsigned int);
11070 +#endif /* __KERNEL__ */
11071 +#endif /* _VX_CONTEXT_H */
11072 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/cvirt_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cvirt_cmd.h
11073 --- linux-2.6.27.6/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11074 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cvirt_cmd.h 2008-10-13 14:54:20.000000000 +0200
11076 +#ifndef _VX_CVIRT_CMD_H
11077 +#define _VX_CVIRT_CMD_H
11080 +/* virtual host info name commands */
11082 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11083 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11085 +struct vcmd_vhi_name_v0 {
11091 +enum vhi_name_field {
11092 + VHIN_CONTEXT = 0,
11104 +#include <linux/compiler.h>
11106 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11107 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11109 +#endif /* __KERNEL__ */
11111 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11113 +struct vcmd_virt_stat_v0 {
11116 + uint32_t nr_threads;
11117 + uint32_t nr_running;
11118 + uint32_t nr_uninterruptible;
11119 + uint32_t nr_onhold;
11120 + uint32_t nr_forks;
11121 + uint32_t load[3];
11125 +extern int vc_virt_stat(struct vx_info *, void __user *);
11127 +#endif /* __KERNEL__ */
11128 +#endif /* _VX_CVIRT_CMD_H */
11129 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/cvirt_def.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cvirt_def.h
11130 --- linux-2.6.27.6/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11131 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cvirt_def.h 2008-10-13 14:54:20.000000000 +0200
11133 +#ifndef _VX_CVIRT_DEF_H
11134 +#define _VX_CVIRT_DEF_H
11136 +#include <linux/jiffies.h>
11137 +#include <linux/spinlock.h>
11138 +#include <linux/wait.h>
11139 +#include <linux/time.h>
11140 +#include <asm/atomic.h>
11143 +struct _vx_usage_stat {
11147 + uint64_t softirq;
11153 +struct _vx_syslog {
11154 + wait_queue_head_t log_wait;
11155 + spinlock_t logbuf_lock; /* lock for the log buffer */
11157 + unsigned long log_start; /* next char to be read by syslog() */
11158 + unsigned long con_start; /* next char to be sent to consoles */
11159 + unsigned long log_end; /* most-recently-written-char + 1 */
11160 + unsigned long logged_chars; /* #chars since last read+clear operation */
11162 + char log_buf[1024];
11166 +/* context sub struct */
11168 +struct _vx_cvirt {
11169 + atomic_t nr_threads; /* number of current threads */
11170 + atomic_t nr_running; /* number of running threads */
11171 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11173 + atomic_t nr_onhold; /* processes on hold */
11174 + uint32_t onhold_last; /* jiffies when put on hold */
11176 + struct timeval bias_tv; /* time offset to the host */
11177 + struct timespec bias_idle;
11178 + struct timespec bias_uptime; /* context creation point */
11179 + uint64_t bias_clock; /* offset in clock_t */
11181 + spinlock_t load_lock; /* lock for the load averages */
11182 + atomic_t load_updates; /* nr of load updates done so far */
11183 + uint32_t load_last; /* last time load was calculated */
11184 + uint32_t load[3]; /* load averages 1,5,15 */
11186 + atomic_t total_forks; /* number of forks so far */
11188 + struct _vx_syslog syslog;
11191 +struct _vx_cvirt_pc {
11192 + struct _vx_usage_stat cpustat;
11196 +#ifdef CONFIG_VSERVER_DEBUG
11198 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11200 + printk("\t_vx_cvirt:\n");
11201 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11202 + atomic_read(&cvirt->nr_threads),
11203 + atomic_read(&cvirt->nr_running),
11204 + atomic_read(&cvirt->nr_uninterruptible),
11205 + atomic_read(&cvirt->nr_onhold));
11206 + /* add rest here */
11207 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11212 +#endif /* _VX_CVIRT_DEF_H */
11213 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/cvirt.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cvirt.h
11214 --- linux-2.6.27.6/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11215 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/cvirt.h 2008-10-13 14:54:20.000000000 +0200
11217 +#ifndef _VX_CVIRT_H
11218 +#define _VX_CVIRT_H
11225 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11230 +void vx_update_load(struct vx_info *);
11233 +int vx_do_syslog(int, char __user *, int);
11235 +#endif /* __KERNEL__ */
11236 +#endif /* _VX_CVIRT_H */
11237 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/debug_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/debug_cmd.h
11238 --- linux-2.6.27.6/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11239 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/debug_cmd.h 2008-10-13 14:54:20.000000000 +0200
11241 +#ifndef _VX_DEBUG_CMD_H
11242 +#define _VX_DEBUG_CMD_H
11245 +/* debug commands */
11247 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11249 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11250 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11252 +struct vcmd_read_history_v0 {
11255 + char __user *data;
11258 +struct vcmd_read_monitor_v0 {
11261 + char __user *data;
11267 +#ifdef CONFIG_COMPAT
11269 +#include <asm/compat.h>
11271 +struct vcmd_read_history_v0_x32 {
11274 + compat_uptr_t data_ptr;
11277 +struct vcmd_read_monitor_v0_x32 {
11280 + compat_uptr_t data_ptr;
11283 +#endif /* CONFIG_COMPAT */
11285 +extern int vc_dump_history(uint32_t);
11287 +extern int vc_read_history(uint32_t, void __user *);
11288 +extern int vc_read_monitor(uint32_t, void __user *);
11290 +#ifdef CONFIG_COMPAT
11292 +extern int vc_read_history_x32(uint32_t, void __user *);
11293 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11295 +#endif /* CONFIG_COMPAT */
11297 +#endif /* __KERNEL__ */
11298 +#endif /* _VX_DEBUG_CMD_H */
11299 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/debug.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/debug.h
11300 --- linux-2.6.27.6/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11301 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/debug.h 2008-10-13 14:54:20.000000000 +0200
11303 +#ifndef _VX_DEBUG_H
11304 +#define _VX_DEBUG_H
11307 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11308 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11309 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11311 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11312 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11313 +#define VXF_DEV "%p[%lu,%d:%d]"
11316 +#define vxd_path(p) \
11317 + ({ static char _buffer[PATH_MAX]; \
11318 + d_path(p, _buffer, sizeof(_buffer)); })
11320 +#define vxd_cond_path(n) \
11321 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11324 +#ifdef CONFIG_VSERVER_DEBUG
11326 +extern unsigned int vx_debug_switch;
11327 +extern unsigned int vx_debug_xid;
11328 +extern unsigned int vx_debug_nid;
11329 +extern unsigned int vx_debug_tag;
11330 +extern unsigned int vx_debug_net;
11331 +extern unsigned int vx_debug_limit;
11332 +extern unsigned int vx_debug_cres;
11333 +extern unsigned int vx_debug_dlim;
11334 +extern unsigned int vx_debug_quota;
11335 +extern unsigned int vx_debug_cvirt;
11336 +extern unsigned int vx_debug_space;
11337 +extern unsigned int vx_debug_misc;
11340 +#define VX_LOGLEVEL "vxD: "
11341 +#define VX_PROC_FMT "%p: "
11342 +#define VX_PROCESS current
11344 +#define vxdprintk(c, f, x...) \
11347 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11348 + VX_PROCESS , ##x); \
11351 +#define vxlprintk(c, f, x...) \
11354 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11357 +#define vxfprintk(c, f, x...) \
11360 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11366 +void dump_vx_info(struct vx_info *, int);
11367 +void dump_vx_info_inactive(int);
11369 +#else /* CONFIG_VSERVER_DEBUG */
11371 +#define vx_debug_switch 0
11372 +#define vx_debug_xid 0
11373 +#define vx_debug_nid 0
11374 +#define vx_debug_tag 0
11375 +#define vx_debug_net 0
11376 +#define vx_debug_limit 0
11377 +#define vx_debug_cres 0
11378 +#define vx_debug_dlim 0
11379 +#define vx_debug_cvirt 0
11381 +#define vxdprintk(x...) do { } while (0)
11382 +#define vxlprintk(x...) do { } while (0)
11383 +#define vxfprintk(x...) do { } while (0)
11385 +#endif /* CONFIG_VSERVER_DEBUG */
11388 +#ifdef CONFIG_VSERVER_WARN
11390 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11391 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11392 +#define VX_WARN_XID "[xid #%u] "
11393 +#define VX_WARN_NID "[nid #%u] "
11394 +#define VX_WARN_TAG "[tag #%u] "
11396 +#define vxwprintk(c, f, x...) \
11399 + printk(VX_WARNLEVEL f "\n", ##x); \
11402 +#else /* CONFIG_VSERVER_WARN */
11404 +#define vxwprintk(x...) do { } while (0)
11406 +#endif /* CONFIG_VSERVER_WARN */
11408 +#define vxwprintk_task(c, f, x...) \
11409 + vxwprintk(c, VX_WARN_TASK f, \
11410 + current->comm, current->pid, \
11411 + current->xid, current->nid, current->tag, ##x)
11412 +#define vxwprintk_xid(c, f, x...) \
11413 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11414 +#define vxwprintk_nid(c, f, x...) \
11415 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11416 +#define vxwprintk_tag(c, f, x...) \
11417 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11419 +#ifdef CONFIG_VSERVER_DEBUG
11420 +#define vxd_assert_lock(l) assert_spin_locked(l)
11421 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11422 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11424 +#define vxd_assert_lock(l) do { } while (0)
11425 +#define vxd_assert(c, f, x...) do { } while (0)
11429 +#endif /* _VX_DEBUG_H */
11430 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/device_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/device_cmd.h
11431 --- linux-2.6.27.6/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11432 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/device_cmd.h 2008-10-13 14:54:20.000000000 +0200
11434 +#ifndef _VX_DEVICE_CMD_H
11435 +#define _VX_DEVICE_CMD_H
11438 +/* device vserver commands */
11440 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11441 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11443 +struct vcmd_set_mapping_v0 {
11444 + const char __user *device;
11445 + const char __user *target;
11452 +#ifdef CONFIG_COMPAT
11454 +#include <asm/compat.h>
11456 +struct vcmd_set_mapping_v0_x32 {
11457 + compat_uptr_t device_ptr;
11458 + compat_uptr_t target_ptr;
11462 +#endif /* CONFIG_COMPAT */
11464 +#include <linux/compiler.h>
11466 +extern int vc_set_mapping(struct vx_info *, void __user *);
11467 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11469 +#ifdef CONFIG_COMPAT
11471 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11472 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11474 +#endif /* CONFIG_COMPAT */
11476 +#endif /* __KERNEL__ */
11477 +#endif /* _VX_DEVICE_CMD_H */
11478 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/device_def.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/device_def.h
11479 --- linux-2.6.27.6/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11480 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/device_def.h 2008-10-13 14:54:20.000000000 +0200
11482 +#ifndef _VX_DEVICE_DEF_H
11483 +#define _VX_DEVICE_DEF_H
11485 +#include <linux/types.h>
11487 +struct vx_dmap_target {
11492 +struct _vx_device {
11493 +#ifdef CONFIG_VSERVER_DEVICE
11494 + struct vx_dmap_target targets[2];
11498 +#endif /* _VX_DEVICE_DEF_H */
11499 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/device.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/device.h
11500 --- linux-2.6.27.6/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11501 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/device.h 2008-10-13 14:54:20.000000000 +0200
11503 +#ifndef _VX_DEVICE_H
11504 +#define _VX_DEVICE_H
11507 +#define DATTR_CREATE 0x00000001
11508 +#define DATTR_OPEN 0x00000002
11510 +#define DATTR_REMAP 0x00000010
11512 +#define DATTR_MASK 0x00000013
11515 +#else /* _VX_DEVICE_H */
11516 +#warning duplicate inclusion
11517 +#endif /* _VX_DEVICE_H */
11518 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/dlimit_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/dlimit_cmd.h
11519 --- linux-2.6.27.6/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11520 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/dlimit_cmd.h 2008-10-13 14:54:20.000000000 +0200
11522 +#ifndef _VX_DLIMIT_CMD_H
11523 +#define _VX_DLIMIT_CMD_H
11526 +/* dlimit vserver commands */
11528 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11529 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11531 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11532 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11534 +struct vcmd_ctx_dlimit_base_v0 {
11535 + const char __user *name;
11539 +struct vcmd_ctx_dlimit_v0 {
11540 + const char __user *name;
11541 + uint32_t space_used; /* used space in kbytes */
11542 + uint32_t space_total; /* maximum space in kbytes */
11543 + uint32_t inodes_used; /* used inodes */
11544 + uint32_t inodes_total; /* maximum inodes */
11545 + uint32_t reserved; /* reserved for root in % */
11549 +#define CDLIM_UNSET ((uint32_t)0UL)
11550 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11551 +#define CDLIM_KEEP ((uint32_t)~1UL)
11555 +#ifdef CONFIG_COMPAT
11557 +#include <asm/compat.h>
11559 +struct vcmd_ctx_dlimit_base_v0_x32 {
11560 + compat_uptr_t name_ptr;
11564 +struct vcmd_ctx_dlimit_v0_x32 {
11565 + compat_uptr_t name_ptr;
11566 + uint32_t space_used; /* used space in kbytes */
11567 + uint32_t space_total; /* maximum space in kbytes */
11568 + uint32_t inodes_used; /* used inodes */
11569 + uint32_t inodes_total; /* maximum inodes */
11570 + uint32_t reserved; /* reserved for root in % */
11574 +#endif /* CONFIG_COMPAT */
11576 +#include <linux/compiler.h>
11578 +extern int vc_add_dlimit(uint32_t, void __user *);
11579 +extern int vc_rem_dlimit(uint32_t, void __user *);
11581 +extern int vc_set_dlimit(uint32_t, void __user *);
11582 +extern int vc_get_dlimit(uint32_t, void __user *);
11584 +#ifdef CONFIG_COMPAT
11586 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11587 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11589 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11590 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11592 +#endif /* CONFIG_COMPAT */
11594 +#endif /* __KERNEL__ */
11595 +#endif /* _VX_DLIMIT_CMD_H */
11596 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/dlimit.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/dlimit.h
11597 --- linux-2.6.27.6/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11598 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/dlimit.h 2008-10-13 14:54:20.000000000 +0200
11600 +#ifndef _VX_DLIMIT_H
11601 +#define _VX_DLIMIT_H
11603 +#include "switch.h"
11608 +/* keep in sync with CDLIM_INFINITY */
11610 +#define DLIM_INFINITY (~0ULL)
11612 +#include <linux/spinlock.h>
11613 +#include <linux/rcupdate.h>
11615 +struct super_block;
11618 + struct hlist_node dl_hlist; /* linked list of contexts */
11619 + struct rcu_head dl_rcu; /* the rcu head */
11620 + tag_t dl_tag; /* context tag */
11621 + atomic_t dl_usecnt; /* usage count */
11622 + atomic_t dl_refcnt; /* reference count */
11624 + struct super_block *dl_sb; /* associated superblock */
11626 + spinlock_t dl_lock; /* protect the values */
11628 + unsigned long long dl_space_used; /* used space in bytes */
11629 + unsigned long long dl_space_total; /* maximum space in bytes */
11630 + unsigned long dl_inodes_used; /* used inodes */
11631 + unsigned long dl_inodes_total; /* maximum inodes */
11633 + unsigned int dl_nrlmult; /* non root limit mult */
11638 +extern void rcu_free_dl_info(struct rcu_head *);
11639 +extern void unhash_dl_info(struct dl_info *);
11641 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11646 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11648 +typedef uint64_t dlsize_t;
11650 +#endif /* __KERNEL__ */
11651 +#else /* _VX_DLIMIT_H */
11652 +#warning duplicate inclusion
11653 +#endif /* _VX_DLIMIT_H */
11654 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/global.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/global.h
11655 --- linux-2.6.27.6/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11656 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/global.h 2008-10-13 14:54:20.000000000 +0200
11658 +#ifndef _VX_GLOBAL_H
11659 +#define _VX_GLOBAL_H
11662 +extern atomic_t vx_global_ctotal;
11663 +extern atomic_t vx_global_cactive;
11665 +extern atomic_t nx_global_ctotal;
11666 +extern atomic_t nx_global_cactive;
11668 +extern atomic_t vs_global_nsproxy;
11669 +extern atomic_t vs_global_fs;
11670 +extern atomic_t vs_global_mnt_ns;
11671 +extern atomic_t vs_global_uts_ns;
11672 +extern atomic_t vs_global_ipc_ns;
11673 +extern atomic_t vs_global_user_ns;
11674 +extern atomic_t vs_global_pid_ns;
11677 +#endif /* _VX_GLOBAL_H */
11678 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/history.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/history.h
11679 --- linux-2.6.27.6/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11680 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/history.h 2008-10-13 14:54:20.000000000 +0200
11682 +#ifndef _VX_HISTORY_H
11683 +#define _VX_HISTORY_H
11688 + VXH_THROW_OOPS = 1,
11692 + VXH_INIT_VX_INFO,
11695 + VXH_CLAIM_VX_INFO,
11696 + VXH_RELEASE_VX_INFO,
11697 + VXH_ALLOC_VX_INFO,
11698 + VXH_DEALLOC_VX_INFO,
11699 + VXH_HASH_VX_INFO,
11700 + VXH_UNHASH_VX_INFO,
11702 + VXH_LOOKUP_VX_INFO,
11703 + VXH_CREATE_VX_INFO,
11706 +struct _vxhe_vxi {
11707 + struct vx_info *ptr;
11713 +struct _vxhe_set_clr {
11717 +struct _vxhe_loc_lookup {
11721 +struct _vx_hist_entry {
11723 + unsigned short seq;
11724 + unsigned short type;
11725 + struct _vxhe_vxi vxi;
11727 + struct _vxhe_set_clr sc;
11728 + struct _vxhe_loc_lookup ll;
11732 +#ifdef CONFIG_VSERVER_HISTORY
11734 +extern unsigned volatile int vxh_active;
11736 +struct _vx_hist_entry *vxh_advance(void *loc);
11740 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11742 + entry->vxi.ptr = vxi;
11744 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11745 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11746 + entry->vxi.xid = vxi->vx_id;
11751 +#define __HERE__ current_text_addr()
11753 +#define __VXH_BODY(__type, __data, __here) \
11754 + struct _vx_hist_entry *entry; \
11756 + preempt_disable(); \
11757 + entry = vxh_advance(__here); \
11759 + entry->type = __type; \
11760 + preempt_enable();
11763 + /* pass vxi only */
11765 +#define __VXH_SMPL \
11766 + __vxh_copy_vxi(entry, vxi)
11769 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11771 + __VXH_BODY(__type, __VXH_SMPL, __here)
11774 + /* pass vxi and data (void *) */
11776 +#define __VXH_DATA \
11777 + __vxh_copy_vxi(entry, vxi); \
11778 + entry->sc.data = data
11781 +void __vxh_data(struct vx_info *vxi, void *data,
11782 + int __type, void *__here)
11784 + __VXH_BODY(__type, __VXH_DATA, __here)
11787 + /* pass vxi and arg (long) */
11789 +#define __VXH_LONG \
11790 + __vxh_copy_vxi(entry, vxi); \
11791 + entry->ll.arg = arg
11794 +void __vxh_long(struct vx_info *vxi, long arg,
11795 + int __type, void *__here)
11797 + __VXH_BODY(__type, __VXH_LONG, __here)
11802 +void __vxh_throw_oops(void *__here)
11804 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11805 + /* prevent further acquisition */
11810 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11812 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11813 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11815 +#define __vxh_init_vx_info(v, d, h) \
11816 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11817 +#define __vxh_set_vx_info(v, d, h) \
11818 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11819 +#define __vxh_clr_vx_info(v, d, h) \
11820 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11822 +#define __vxh_claim_vx_info(v, d, h) \
11823 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11824 +#define __vxh_release_vx_info(v, d, h) \
11825 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11827 +#define vxh_alloc_vx_info(v) \
11828 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11829 +#define vxh_dealloc_vx_info(v) \
11830 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11832 +#define vxh_hash_vx_info(v) \
11833 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11834 +#define vxh_unhash_vx_info(v) \
11835 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11837 +#define vxh_loc_vx_info(v, l) \
11838 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11839 +#define vxh_lookup_vx_info(v, l) \
11840 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11841 +#define vxh_create_vx_info(v, l) \
11842 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11844 +extern void vxh_dump_history(void);
11847 +#else /* CONFIG_VSERVER_HISTORY */
11849 +#define __HERE__ 0
11851 +#define vxh_throw_oops() do { } while (0)
11853 +#define __vxh_get_vx_info(v, h) do { } while (0)
11854 +#define __vxh_put_vx_info(v, h) do { } while (0)
11856 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11857 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11858 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11860 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11861 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11863 +#define vxh_alloc_vx_info(v) do { } while (0)
11864 +#define vxh_dealloc_vx_info(v) do { } while (0)
11866 +#define vxh_hash_vx_info(v) do { } while (0)
11867 +#define vxh_unhash_vx_info(v) do { } while (0)
11869 +#define vxh_loc_vx_info(v, l) do { } while (0)
11870 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11871 +#define vxh_create_vx_info(v, l) do { } while (0)
11873 +#define vxh_dump_history() do { } while (0)
11876 +#endif /* CONFIG_VSERVER_HISTORY */
11878 +#endif /* _VX_HISTORY_H */
11879 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/inode_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/inode_cmd.h
11880 --- linux-2.6.27.6/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11881 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/inode_cmd.h 2008-10-13 14:54:20.000000000 +0200
11883 +#ifndef _VX_INODE_CMD_H
11884 +#define _VX_INODE_CMD_H
11887 +/* inode vserver commands */
11889 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11890 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11892 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11893 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11895 +struct vcmd_ctx_iattr_v1 {
11896 + const char __user *name;
11902 +struct vcmd_ctx_fiattr_v0 {
11912 +#ifdef CONFIG_COMPAT
11914 +#include <asm/compat.h>
11916 +struct vcmd_ctx_iattr_v1_x32 {
11917 + compat_uptr_t name_ptr;
11923 +#endif /* CONFIG_COMPAT */
11925 +#include <linux/compiler.h>
11927 +extern int vc_get_iattr(void __user *);
11928 +extern int vc_set_iattr(void __user *);
11930 +extern int vc_fget_iattr(uint32_t, void __user *);
11931 +extern int vc_fset_iattr(uint32_t, void __user *);
11933 +#ifdef CONFIG_COMPAT
11935 +extern int vc_get_iattr_x32(void __user *);
11936 +extern int vc_set_iattr_x32(void __user *);
11938 +#endif /* CONFIG_COMPAT */
11940 +#endif /* __KERNEL__ */
11941 +#endif /* _VX_INODE_CMD_H */
11942 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/inode.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/inode.h
11943 --- linux-2.6.27.6/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11944 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/inode.h 2008-10-13 14:54:20.000000000 +0200
11946 +#ifndef _VX_INODE_H
11947 +#define _VX_INODE_H
11950 +#define IATTR_TAG 0x01000000
11952 +#define IATTR_ADMIN 0x00000001
11953 +#define IATTR_WATCH 0x00000002
11954 +#define IATTR_HIDE 0x00000004
11955 +#define IATTR_FLAGS 0x00000007
11957 +#define IATTR_BARRIER 0x00010000
11958 +#define IATTR_IXUNLINK 0x00020000
11959 +#define IATTR_IMMUTABLE 0x00040000
11964 +#ifdef CONFIG_VSERVER_PROC_SECURE
11965 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11966 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11968 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11969 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11972 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11974 +#endif /* __KERNEL__ */
11976 +/* inode ioctls */
11978 +#define FIOC_GETXFLG _IOR('x', 5, long)
11979 +#define FIOC_SETXFLG _IOW('x', 6, long)
11981 +#else /* _VX_INODE_H */
11982 +#warning duplicate inclusion
11983 +#endif /* _VX_INODE_H */
11984 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/Kbuild linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/Kbuild
11985 --- linux-2.6.27.6/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11986 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/Kbuild 2008-10-13 14:54:20.000000000 +0200
11989 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11990 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11991 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11992 + debug_cmd.h device_cmd.h
11994 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11996 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/limit_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/limit_cmd.h
11997 --- linux-2.6.27.6/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11998 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/limit_cmd.h 2008-10-13 14:54:20.000000000 +0200
12000 +#ifndef _VX_LIMIT_CMD_H
12001 +#define _VX_LIMIT_CMD_H
12004 +/* rlimit vserver commands */
12006 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12007 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12008 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12009 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12011 +struct vcmd_ctx_rlimit_v0 {
12013 + uint64_t minimum;
12014 + uint64_t softlimit;
12015 + uint64_t maximum;
12018 +struct vcmd_ctx_rlimit_mask_v0 {
12019 + uint32_t minimum;
12020 + uint32_t softlimit;
12021 + uint32_t maximum;
12024 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12026 +struct vcmd_rlimit_stat_v0 {
12030 + uint64_t minimum;
12031 + uint64_t maximum;
12034 +#define CRLIM_UNSET (0ULL)
12035 +#define CRLIM_INFINITY (~0ULL)
12036 +#define CRLIM_KEEP (~1ULL)
12040 +#ifdef CONFIG_IA32_EMULATION
12042 +struct vcmd_ctx_rlimit_v0_x32 {
12044 + uint64_t minimum;
12045 + uint64_t softlimit;
12046 + uint64_t maximum;
12047 +} __attribute__ ((aligned (4)));
12049 +#endif /* CONFIG_IA32_EMULATION */
12051 +#include <linux/compiler.h>
12053 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12054 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12055 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12056 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12058 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12060 +#ifdef CONFIG_IA32_EMULATION
12062 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12063 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12065 +#endif /* CONFIG_IA32_EMULATION */
12067 +#endif /* __KERNEL__ */
12068 +#endif /* _VX_LIMIT_CMD_H */
12069 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/limit_def.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/limit_def.h
12070 --- linux-2.6.27.6/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12071 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/limit_def.h 2008-10-13 14:54:20.000000000 +0200
12073 +#ifndef _VX_LIMIT_DEF_H
12074 +#define _VX_LIMIT_DEF_H
12076 +#include <asm/atomic.h>
12077 +#include <asm/resource.h>
12079 +#include "limit.h"
12082 +struct _vx_res_limit {
12083 + rlim_t soft; /* Context soft limit */
12084 + rlim_t hard; /* Context hard limit */
12086 + rlim_atomic_t rcur; /* Current value */
12087 + rlim_t rmin; /* Context minimum */
12088 + rlim_t rmax; /* Context maximum */
12090 + atomic_t lhit; /* Limit hits */
12093 +/* context sub struct */
12095 +struct _vx_limit {
12096 + struct _vx_res_limit res[NUM_LIMITS];
12099 +#ifdef CONFIG_VSERVER_DEBUG
12101 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12105 + printk("\t_vx_limit:");
12106 + for (i = 0; i < NUM_LIMITS; i++) {
12107 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12108 + i, (unsigned long)__rlim_get(limit, i),
12109 + (unsigned long)__rlim_rmin(limit, i),
12110 + (unsigned long)__rlim_rmax(limit, i),
12111 + (long)__rlim_soft(limit, i),
12112 + (long)__rlim_hard(limit, i),
12113 + atomic_read(&__rlim_lhit(limit, i)));
12119 +#endif /* _VX_LIMIT_DEF_H */
12120 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/limit.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/limit.h
12121 --- linux-2.6.27.6/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12122 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/limit.h 2008-10-13 14:54:20.000000000 +0200
12124 +#ifndef _VX_LIMIT_H
12125 +#define _VX_LIMIT_H
12127 +#define VLIMIT_NSOCK 16
12128 +#define VLIMIT_OPENFD 17
12129 +#define VLIMIT_ANON 18
12130 +#define VLIMIT_SHMEM 19
12131 +#define VLIMIT_SEMARY 20
12132 +#define VLIMIT_NSEMS 21
12133 +#define VLIMIT_DENTRY 22
12134 +#define VLIMIT_MAPPED 23
12139 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12141 +/* keep in sync with CRLIM_INFINITY */
12143 +#define VLIM_INFINITY (~0ULL)
12145 +#include <asm/atomic.h>
12146 +#include <asm/resource.h>
12148 +#ifndef RLIM_INFINITY
12149 +#warning RLIM_INFINITY is undefined
12152 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12154 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12155 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12157 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12158 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12159 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12161 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12162 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12164 +typedef atomic_long_t rlim_atomic_t;
12165 +typedef unsigned long rlim_t;
12167 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12168 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12169 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12170 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12171 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12172 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12175 +#if (RLIM_INFINITY == VLIM_INFINITY)
12176 +#define VX_VLIM(r) ((long long)(long)(r))
12177 +#define VX_RLIM(v) ((rlim_t)(v))
12179 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12180 + ? VLIM_INFINITY : (long long)(r))
12181 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12182 + ? RLIM_INFINITY : (rlim_t)(v))
12187 +void vx_vsi_meminfo(struct sysinfo *);
12188 +void vx_vsi_swapinfo(struct sysinfo *);
12190 +#define NUM_LIMITS 24
12192 +#endif /* __KERNEL__ */
12193 +#endif /* _VX_LIMIT_H */
12194 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/limit_int.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/limit_int.h
12195 --- linux-2.6.27.6/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12196 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/limit_int.h 2008-10-13 14:54:20.000000000 +0200
12198 +#ifndef _VX_LIMIT_INT_H
12199 +#define _VX_LIMIT_INT_H
12201 +#include "context.h"
12205 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12206 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12208 +extern const char *vlimit_name[NUM_LIMITS];
12210 +static inline void __vx_acc_cres(struct vx_info *vxi,
12211 + int res, int dir, void *_data, char *_file, int _line)
12213 + if (VXD_RCRES_COND(res))
12214 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12215 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12216 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12217 + (dir > 0) ? "++" : "--", _data, _file, _line);
12222 + __rlim_inc(&vxi->limit, res);
12224 + __rlim_dec(&vxi->limit, res);
12227 +static inline void __vx_add_cres(struct vx_info *vxi,
12228 + int res, int amount, void *_data, char *_file, int _line)
12230 + if (VXD_RCRES_COND(res))
12231 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12232 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12233 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12234 + amount, _data, _file, _line);
12239 + __rlim_add(&vxi->limit, res, amount);
12243 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12245 + int cond = (value > __rlim_rmax(limit, res));
12248 + __rlim_rmax(limit, res) = value;
12253 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12255 + int cond = (value < __rlim_rmin(limit, res));
12258 + __rlim_rmin(limit, res) = value;
12263 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12265 + if (!__vx_cres_adjust_max(limit, res, value))
12266 + __vx_cres_adjust_min(limit, res, value);
12271 + +1 ... no limit hit
12272 + -1 ... over soft limit
12273 + 0 ... over hard limit */
12275 +static inline int __vx_cres_avail(struct vx_info *vxi,
12276 + int res, int num, char *_file, int _line)
12278 + struct _vx_limit *limit;
12281 + if (VXD_RLIMIT_COND(res))
12282 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12283 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12284 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12285 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12286 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12287 + num, _file, _line);
12291 + limit = &vxi->limit;
12292 + value = __rlim_get(limit, res);
12294 + if (!__vx_cres_adjust_max(limit, res, value))
12295 + __vx_cres_adjust_min(limit, res, value);
12300 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12302 + if (value + num <= __rlim_soft(limit, res))
12305 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12307 + if (value + num <= __rlim_hard(limit, res))
12310 + __rlim_hit(limit, res);
12315 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12318 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12320 + rlim_t value, sum = 0;
12323 + while ((res = *array++)) {
12324 + value = __rlim_get(limit, res);
12325 + __vx_cres_fixup(limit, res, value);
12332 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12334 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12335 + int res = *array;
12337 + if (value == __rlim_get(limit, res))
12340 + __rlim_set(limit, res, value);
12341 + /* now adjust min/max */
12342 + if (!__vx_cres_adjust_max(limit, res, value))
12343 + __vx_cres_adjust_min(limit, res, value);
12348 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12349 + const int *array, int num, char *_file, int _line)
12351 + struct _vx_limit *limit;
12352 + rlim_t value = 0;
12360 + limit = &vxi->limit;
12362 + value = __vx_cres_array_sum(limit, array + 1);
12364 + __rlim_set(limit, res, value);
12365 + __vx_cres_fixup(limit, res, value);
12367 + return __vx_cres_avail(vxi, res, num, _file, _line);
12371 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12376 + /* complex resources first */
12377 + if ((id < 0) || (id == RLIMIT_RSS))
12378 + __vx_cres_array_fixup(limit, VLA_RSS);
12380 + for (res = 0; res < NUM_LIMITS; res++) {
12381 + if ((id > 0) && (res != id))
12384 + value = __rlim_get(limit, res);
12385 + __vx_cres_fixup(limit, res, value);
12387 + /* not supposed to happen, maybe warn? */
12388 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12389 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12394 +#endif /* __KERNEL__ */
12395 +#endif /* _VX_LIMIT_INT_H */
12396 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/monitor.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/monitor.h
12397 --- linux-2.6.27.6/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12398 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/monitor.h 2008-10-13 14:54:20.000000000 +0200
12400 +#ifndef _VX_MONITOR_H
12401 +#define _VX_MONITOR_H
12403 +#include <linux/types.h>
12410 + VXM_UPDATE = 0x20,
12414 + VXM_RQINFO_1 = 0x24,
12417 + VXM_ACTIVATE = 0x40,
12424 + VXM_MIGRATE = 0x48,
12427 + /* all other bits are flags */
12428 + VXM_SCHED = 0x80,
12431 +struct _vxm_update_1 {
12432 + uint32_t tokens_max;
12433 + uint32_t fill_rate;
12434 + uint32_t interval;
12437 +struct _vxm_update_2 {
12438 + uint32_t tokens_min;
12439 + uint32_t fill_rate;
12440 + uint32_t interval;
12443 +struct _vxm_rqinfo_1 {
12444 + uint16_t running;
12448 + uint32_t idle_tokens;
12451 +struct _vxm_rqinfo_2 {
12452 + uint32_t norm_time;
12453 + uint32_t idle_time;
12454 + uint32_t idle_skip;
12457 +struct _vxm_sched {
12459 + uint32_t norm_time;
12460 + uint32_t idle_time;
12463 +struct _vxm_task {
12468 +struct _vxm_event {
12477 + struct _vxm_task tsk;
12481 +struct _vx_mon_entry {
12485 + struct _vxm_event ev;
12486 + struct _vxm_sched sd;
12487 + struct _vxm_update_1 u1;
12488 + struct _vxm_update_2 u2;
12489 + struct _vxm_rqinfo_1 q1;
12490 + struct _vxm_rqinfo_2 q2;
12495 +#endif /* _VX_MONITOR_H */
12496 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/network_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/network_cmd.h
12497 --- linux-2.6.27.6/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12498 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/network_cmd.h 2008-10-13 14:54:20.000000000 +0200
12500 +#ifndef _VX_NETWORK_CMD_H
12501 +#define _VX_NETWORK_CMD_H
12504 +/* vinfo commands */
12506 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12509 +extern int vc_task_nid(uint32_t);
12511 +#endif /* __KERNEL__ */
12513 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12515 +struct vcmd_nx_info_v0 {
12517 + /* more to come */
12521 +extern int vc_nx_info(struct nx_info *, void __user *);
12523 +#endif /* __KERNEL__ */
12525 +#include <linux/in.h>
12526 +#include <linux/in6.h>
12528 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12529 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12531 +struct vcmd_net_create {
12532 + uint64_t flagword;
12535 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12537 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12538 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12540 +struct vcmd_net_addr_v0 {
12543 + struct in_addr ip[4];
12544 + struct in_addr mask[4];
12547 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12548 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12550 +struct vcmd_net_addr_ipv4_v1 {
12553 + struct in_addr ip;
12554 + struct in_addr mask;
12557 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12558 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12560 +struct vcmd_net_addr_ipv6_v1 {
12564 + struct in6_addr ip;
12565 + struct in6_addr mask;
12568 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12569 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12571 +struct vcmd_match_ipv4_v0 {
12576 + struct in_addr ip;
12577 + struct in_addr ip2;
12578 + struct in_addr mask;
12581 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12582 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12584 +struct vcmd_match_ipv6_v0 {
12589 + struct in6_addr ip;
12590 + struct in6_addr ip2;
12591 + struct in6_addr mask;
12596 +extern int vc_net_create(uint32_t, void __user *);
12597 +extern int vc_net_migrate(struct nx_info *, void __user *);
12599 +extern int vc_net_add(struct nx_info *, void __user *);
12600 +extern int vc_net_remove(struct nx_info *, void __user *);
12602 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12603 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12605 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12606 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12608 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12609 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12611 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12612 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12614 +#endif /* __KERNEL__ */
12617 +/* flag commands */
12619 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12620 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12622 +struct vcmd_net_flags_v0 {
12623 + uint64_t flagword;
12628 +extern int vc_get_nflags(struct nx_info *, void __user *);
12629 +extern int vc_set_nflags(struct nx_info *, void __user *);
12631 +#endif /* __KERNEL__ */
12634 +/* network caps commands */
12636 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12637 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12639 +struct vcmd_net_caps_v0 {
12645 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12646 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12648 +#endif /* __KERNEL__ */
12649 +#endif /* _VX_CONTEXT_CMD_H */
12650 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/network.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/network.h
12651 --- linux-2.6.27.6/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12652 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/network.h 2008-10-13 14:54:20.000000000 +0200
12654 +#ifndef _VX_NETWORK_H
12655 +#define _VX_NETWORK_H
12657 +#include <linux/types.h>
12660 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12663 +/* network flags */
12665 +#define NXF_INFO_PRIVATE 0x00000008
12667 +#define NXF_SINGLE_IP 0x00000100
12668 +#define NXF_LBACK_REMAP 0x00000200
12669 +#define NXF_LBACK_ALLOW 0x00000400
12671 +#define NXF_HIDE_NETIF 0x02000000
12672 +#define NXF_HIDE_LBACK 0x04000000
12674 +#define NXF_STATE_SETUP (1ULL << 32)
12675 +#define NXF_STATE_ADMIN (1ULL << 34)
12677 +#define NXF_SC_HELPER (1ULL << 36)
12678 +#define NXF_PERSISTENT (1ULL << 38)
12680 +#define NXF_ONE_TIME (0x0005ULL << 32)
12683 +#define NXF_INIT_SET (__nxf_init_set())
12685 +static inline uint64_t __nxf_init_set(void) {
12686 + return NXF_STATE_ADMIN
12687 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12688 + | NXF_LBACK_REMAP
12691 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12694 + | NXF_HIDE_NETIF;
12698 +/* network caps */
12700 +#define NXC_TUN_CREATE 0x00000001
12702 +#define NXC_RAW_ICMP 0x00000100
12705 +/* address types */
12707 +#define NXA_TYPE_IPV4 0x0001
12708 +#define NXA_TYPE_IPV6 0x0002
12710 +#define NXA_TYPE_NONE 0x0000
12711 +#define NXA_TYPE_ANY 0x00FF
12713 +#define NXA_TYPE_ADDR 0x0010
12714 +#define NXA_TYPE_MASK 0x0020
12715 +#define NXA_TYPE_RANGE 0x0040
12717 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12719 +#define NXA_MOD_BCAST 0x0100
12720 +#define NXA_MOD_LBACK 0x0200
12722 +#define NXA_LOOPBACK 0x1000
12724 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12725 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12729 +#include <linux/list.h>
12730 +#include <linux/spinlock.h>
12731 +#include <linux/rcupdate.h>
12732 +#include <linux/in.h>
12733 +#include <linux/in6.h>
12734 +#include <asm/atomic.h>
12736 +struct nx_addr_v4 {
12737 + struct nx_addr_v4 *next;
12738 + struct in_addr ip[2];
12739 + struct in_addr mask;
12744 +struct nx_addr_v6 {
12745 + struct nx_addr_v6 *next;
12746 + struct in6_addr ip;
12747 + struct in6_addr mask;
12754 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12755 + nid_t nx_id; /* vnet id */
12756 + atomic_t nx_usecnt; /* usage count */
12757 + atomic_t nx_tasks; /* tasks count */
12758 + int nx_state; /* context state */
12760 + uint64_t nx_flags; /* network flag word */
12761 + uint64_t nx_ncaps; /* network capabilities */
12763 + struct in_addr v4_lback; /* Loopback address */
12764 + struct in_addr v4_bcast; /* Broadcast address */
12765 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12766 +#ifdef CONFIG_IPV6
12767 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12769 + char nx_name[65]; /* network context name */
12773 +/* status flags */
12775 +#define NXS_HASHED 0x0001
12776 +#define NXS_SHUTDOWN 0x0100
12777 +#define NXS_RELEASED 0x8000
12779 +extern struct nx_info *lookup_nx_info(int);
12781 +extern int get_nid_list(int, unsigned int *, int);
12782 +extern int nid_is_hashed(nid_t);
12784 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12786 +extern long vs_net_change(struct nx_info *, unsigned int);
12791 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12792 +#ifdef CONFIG_IPV6
12793 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12795 +#define NX_IPV6(n) (0)
12798 +#endif /* __KERNEL__ */
12799 +#endif /* _VX_NETWORK_H */
12800 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/percpu.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/percpu.h
12801 --- linux-2.6.27.6/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12802 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/percpu.h 2008-10-13 14:54:20.000000000 +0200
12804 +#ifndef _VX_PERCPU_H
12805 +#define _VX_PERCPU_H
12807 +#include "cvirt_def.h"
12808 +#include "sched_def.h"
12810 +struct _vx_percpu {
12811 + struct _vx_cvirt_pc cvirt;
12812 + struct _vx_sched_pc sched;
12815 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12817 +#endif /* _VX_PERCPU_H */
12818 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/pid.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/pid.h
12819 --- linux-2.6.27.6/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12820 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/pid.h 2008-10-13 14:54:20.000000000 +0200
12822 +#ifndef _VSERVER_PID_H
12823 +#define _VSERVER_PID_H
12825 +/* pid faking stuff */
12827 +#define vx_info_map_pid(v, p) \
12828 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12829 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12830 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
12831 +#define vx_map_tgid(p) vx_map_pid(p)
12833 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12834 + const char *func, const char *file, int line)
12836 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12837 + vxfprintk(VXD_CBIT(cvirt, 2),
12838 + "vx_map_tgid: %p/%llx: %d -> %d",
12839 + vxi, (long long)vxi->vx_flags, pid,
12840 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12841 + func, file, line);
12844 + if (pid == vxi->vx_initpid)
12850 +#define vx_info_rmap_pid(v, p) \
12851 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12852 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
12853 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12855 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12856 + const char *func, const char *file, int line)
12858 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12859 + vxfprintk(VXD_CBIT(cvirt, 2),
12860 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12861 + vxi, (long long)vxi->vx_flags, pid,
12862 + (pid == 1) ? vxi->vx_initpid : pid,
12863 + func, file, line);
12864 + if ((pid == 1) && vxi->vx_initpid)
12865 + return vxi->vx_initpid;
12866 + if (pid == vxi->vx_initpid)
12873 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/sched_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/sched_cmd.h
12874 --- linux-2.6.27.6/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12875 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/sched_cmd.h 2008-10-13 14:54:20.000000000 +0200
12877 +#ifndef _VX_SCHED_CMD_H
12878 +#define _VX_SCHED_CMD_H
12881 +/* sched vserver commands */
12883 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12884 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12885 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12887 +struct vcmd_set_sched_v2 {
12888 + int32_t fill_rate;
12889 + int32_t interval;
12891 + int32_t tokens_min;
12892 + int32_t tokens_max;
12893 + uint64_t cpu_mask;
12896 +struct vcmd_set_sched_v3 {
12897 + uint32_t set_mask;
12898 + int32_t fill_rate;
12899 + int32_t interval;
12901 + int32_t tokens_min;
12902 + int32_t tokens_max;
12903 + int32_t priority_bias;
12906 +struct vcmd_set_sched_v4 {
12907 + uint32_t set_mask;
12908 + int32_t fill_rate;
12909 + int32_t interval;
12911 + int32_t tokens_min;
12912 + int32_t tokens_max;
12913 + int32_t prio_bias;
12915 + int32_t bucket_id;
12918 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12919 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12921 +struct vcmd_sched_v5 {
12924 + int32_t bucket_id;
12925 + int32_t fill_rate[2];
12926 + int32_t interval[2];
12928 + int32_t tokens_min;
12929 + int32_t tokens_max;
12930 + int32_t prio_bias;
12933 +#define VXSM_FILL_RATE 0x0001
12934 +#define VXSM_INTERVAL 0x0002
12935 +#define VXSM_FILL_RATE2 0x0004
12936 +#define VXSM_INTERVAL2 0x0008
12937 +#define VXSM_TOKENS 0x0010
12938 +#define VXSM_TOKENS_MIN 0x0020
12939 +#define VXSM_TOKENS_MAX 0x0040
12940 +#define VXSM_PRIO_BIAS 0x0100
12942 +#define VXSM_IDLE_TIME 0x0200
12943 +#define VXSM_FORCE 0x0400
12945 +#define VXSM_V3_MASK 0x0173
12946 +#define VXSM_SET_MASK 0x01FF
12948 +#define VXSM_CPU_ID 0x1000
12949 +#define VXSM_BUCKET_ID 0x2000
12951 +#define VXSM_MSEC 0x4000
12953 +#define SCHED_KEEP (-2) /* only for v2 */
12957 +#include <linux/compiler.h>
12959 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
12960 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
12961 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
12962 +extern int vc_set_sched(struct vx_info *, void __user *);
12963 +extern int vc_get_sched(struct vx_info *, void __user *);
12965 +#endif /* __KERNEL__ */
12967 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
12969 +struct vcmd_sched_info {
12971 + int32_t bucket_id;
12972 + uint64_t user_msec;
12973 + uint64_t sys_msec;
12974 + uint64_t hold_msec;
12975 + uint32_t token_usec;
12976 + int32_t vavavoom;
12981 +extern int vc_sched_info(struct vx_info *, void __user *);
12983 +#endif /* __KERNEL__ */
12984 +#endif /* _VX_SCHED_CMD_H */
12985 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/sched_def.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/sched_def.h
12986 --- linux-2.6.27.6/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12987 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/sched_def.h 2008-10-13 14:54:20.000000000 +0200
12989 +#ifndef _VX_SCHED_DEF_H
12990 +#define _VX_SCHED_DEF_H
12992 +#include <linux/spinlock.h>
12993 +#include <linux/jiffies.h>
12994 +#include <linux/cpumask.h>
12995 +#include <asm/atomic.h>
12996 +#include <asm/param.h>
12999 +/* context sub struct */
13001 +struct _vx_sched {
13002 + spinlock_t tokens_lock; /* lock for token bucket */
13004 + int tokens; /* number of CPU tokens */
13005 + int fill_rate[2]; /* Fill rate: add X tokens... */
13006 + int interval[2]; /* Divisor: per Y jiffies */
13007 + int tokens_min; /* Limit: minimum for unhold */
13008 + int tokens_max; /* Limit: no more than N tokens */
13010 + int prio_bias; /* bias offset for priority */
13012 + unsigned update_mask; /* which features should be updated */
13013 + cpumask_t update; /* CPUs which should update */
13016 +struct _vx_sched_pc {
13017 + int tokens; /* number of CPU tokens */
13018 + int flags; /* bucket flags */
13020 + int fill_rate[2]; /* Fill rate: add X tokens... */
13021 + int interval[2]; /* Divisor: per Y jiffies */
13022 + int tokens_min; /* Limit: minimum for unhold */
13023 + int tokens_max; /* Limit: no more than N tokens */
13025 + int prio_bias; /* bias offset for priority */
13026 + int vavavoom; /* last calculated vavavoom */
13028 + unsigned long norm_time; /* last time accounted */
13029 + unsigned long idle_time; /* non linear time for fair sched */
13030 + unsigned long token_time; /* token time for accounting */
13031 + unsigned long onhold; /* jiffies when put on hold */
13033 + uint64_t user_ticks; /* token tick events */
13034 + uint64_t sys_ticks; /* token tick events */
13035 + uint64_t hold_ticks; /* token ticks paused */
13039 +#define VXSF_ONHOLD 0x0001
13040 +#define VXSF_IDLE_TIME 0x0100
13042 +#ifdef CONFIG_VSERVER_DEBUG
13044 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13046 + printk("\t_vx_sched:\n");
13047 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
13048 + sched->fill_rate[0], sched->interval[0],
13049 + sched->fill_rate[1], sched->interval[1],
13050 + sched->tokens_min, sched->tokens_max);
13051 + printk("\t priority = %4d\n", sched->prio_bias);
13056 +#endif /* _VX_SCHED_DEF_H */
13057 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/sched.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/sched.h
13058 --- linux-2.6.27.6/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13059 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/sched.h 2008-10-13 14:54:20.000000000 +0200
13061 +#ifndef _VX_SCHED_H
13062 +#define _VX_SCHED_H
13069 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13074 +void vx_update_load(struct vx_info *);
13077 +int vx_tokens_recalc(struct _vx_sched_pc *,
13078 + unsigned long *, unsigned long *, int [2]);
13080 +void vx_update_sched_param(struct _vx_sched *sched,
13081 + struct _vx_sched_pc *sched_pc);
13083 +#endif /* __KERNEL__ */
13084 +#else /* _VX_SCHED_H */
13085 +#warning duplicate inclusion
13086 +#endif /* _VX_SCHED_H */
13087 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/signal_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/signal_cmd.h
13088 --- linux-2.6.27.6/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13089 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/signal_cmd.h 2008-10-13 14:54:20.000000000 +0200
13091 +#ifndef _VX_SIGNAL_CMD_H
13092 +#define _VX_SIGNAL_CMD_H
13095 +/* signalling vserver commands */
13097 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13098 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13100 +struct vcmd_ctx_kill_v0 {
13105 +struct vcmd_wait_exit_v0 {
13106 + int32_t reboot_cmd;
13107 + int32_t exit_code;
13112 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13113 +extern int vc_wait_exit(struct vx_info *, void __user *);
13115 +#endif /* __KERNEL__ */
13117 +/* process alteration commands */
13119 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13120 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13122 +struct vcmd_pflags_v0 {
13123 + uint32_t flagword;
13129 +extern int vc_get_pflags(uint32_t pid, void __user *);
13130 +extern int vc_set_pflags(uint32_t pid, void __user *);
13132 +#endif /* __KERNEL__ */
13133 +#endif /* _VX_SIGNAL_CMD_H */
13134 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/signal.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/signal.h
13135 --- linux-2.6.27.6/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13136 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/signal.h 2008-10-13 14:54:20.000000000 +0200
13138 +#ifndef _VX_SIGNAL_H
13139 +#define _VX_SIGNAL_H
13146 +int vx_info_kill(struct vx_info *, int, int);
13148 +#endif /* __KERNEL__ */
13149 +#else /* _VX_SIGNAL_H */
13150 +#warning duplicate inclusion
13151 +#endif /* _VX_SIGNAL_H */
13152 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/space_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/space_cmd.h
13153 --- linux-2.6.27.6/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13154 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/space_cmd.h 2008-10-31 03:49:36.000000000 +0100
13156 +#ifndef _VX_SPACE_CMD_H
13157 +#define _VX_SPACE_CMD_H
13160 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13161 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13162 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13164 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13165 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13166 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13168 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13170 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13171 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13174 +struct vcmd_space_mask_v1 {
13178 +struct vcmd_space_mask_v2 {
13186 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13187 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13188 +extern int vc_enter_space(struct vx_info *, void __user *);
13189 +extern int vc_set_space(struct vx_info *, void __user *);
13190 +extern int vc_get_space_mask(void __user *, int);
13192 +#endif /* __KERNEL__ */
13193 +#endif /* _VX_SPACE_CMD_H */
13194 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/space.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/space.h
13195 --- linux-2.6.27.6/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13196 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/space.h 2008-10-31 04:02:02.000000000 +0100
13198 +#ifndef _VX_SPACE_H
13199 +#define _VX_SPACE_H
13201 +#include <linux/types.h>
13205 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13207 +#else /* _VX_SPACE_H */
13208 +#warning duplicate inclusion
13209 +#endif /* _VX_SPACE_H */
13210 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/switch.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/switch.h
13211 --- linux-2.6.27.6/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13212 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/switch.h 2008-10-13 14:54:20.000000000 +0200
13214 +#ifndef _VX_SWITCH_H
13215 +#define _VX_SWITCH_H
13217 +#include <linux/types.h>
13220 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13221 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13222 +#define VC_VERSION(c) ((c) & 0xFFF)
13224 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13225 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13229 + Syscall Matrix V2.8
13231 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13232 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13233 + |INFO |SETUP | |MOVE | | | | | |
13234 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13235 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13236 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13237 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13238 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13239 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13240 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13241 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13242 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13243 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13244 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13245 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13246 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13247 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13248 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13249 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13250 + OTHER |VSTAT | | | | | | |VINFO | |
13251 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13252 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13253 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13254 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13255 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13256 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13257 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13258 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13262 +#define VC_CAT_VERSION 0
13264 +#define VC_CAT_VSETUP 1
13265 +#define VC_CAT_VHOST 2
13267 +#define VC_CAT_DEVICE 6
13269 +#define VC_CAT_VPROC 9
13270 +#define VC_CAT_PROCALT 10
13271 +#define VC_CAT_PROCMIG 11
13272 +#define VC_CAT_PROCTRL 12
13274 +#define VC_CAT_SCHED 14
13275 +#define VC_CAT_MEMCTRL 20
13277 +#define VC_CAT_VNET 25
13278 +#define VC_CAT_NETALT 26
13279 +#define VC_CAT_NETMIG 27
13280 +#define VC_CAT_NETCTRL 28
13282 +#define VC_CAT_TAGMIG 35
13283 +#define VC_CAT_DLIMIT 36
13284 +#define VC_CAT_INODE 38
13286 +#define VC_CAT_VSTAT 40
13287 +#define VC_CAT_VINFO 46
13288 +#define VC_CAT_EVENT 48
13290 +#define VC_CAT_FLAGS 52
13291 +#define VC_CAT_VSPACE 54
13292 +#define VC_CAT_DEBUG 56
13293 +#define VC_CAT_RLIMIT 60
13295 +#define VC_CAT_SYSTEST 61
13296 +#define VC_CAT_COMPAT 63
13298 +/* query version */
13300 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13301 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13306 +#include <linux/errno.h>
13309 +#else /* __KERNEL__ */
13311 +#endif /* __KERNEL__ */
13313 +#endif /* _VX_SWITCH_H */
13314 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/tag_cmd.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/tag_cmd.h
13315 --- linux-2.6.27.6/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13316 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/tag_cmd.h 2008-10-13 14:54:20.000000000 +0200
13318 +#ifndef _VX_TAG_CMD_H
13319 +#define _VX_TAG_CMD_H
13322 +/* vinfo commands */
13324 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13327 +extern int vc_task_tag(uint32_t);
13329 +#endif /* __KERNEL__ */
13331 +/* context commands */
13333 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13336 +extern int vc_tag_migrate(uint32_t);
13338 +#endif /* __KERNEL__ */
13339 +#endif /* _VX_TAG_CMD_H */
13340 diff -NurpP --minimal linux-2.6.27.6/include/linux/vserver/tag.h linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/tag.h
13341 --- linux-2.6.27.6/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13342 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vserver/tag.h 2008-10-24 03:34:52.000000000 +0200
13347 +#include <linux/types.h>
13350 +#define DX_TAG(in) (IS_TAGGED(in))
13353 +#ifdef CONFIG_TAG_NFSD
13354 +#define DX_TAG_NFSD 1
13356 +#define DX_TAG_NFSD 0
13360 +#ifdef CONFIG_TAGGING_NONE
13362 +#define MAX_UID 0xFFFFFFFF
13363 +#define MAX_GID 0xFFFFFFFF
13365 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13367 +#define TAGINO_UID(cond, uid, tag) (uid)
13368 +#define TAGINO_GID(cond, gid, tag) (gid)
13373 +#ifdef CONFIG_TAGGING_GID16
13375 +#define MAX_UID 0xFFFFFFFF
13376 +#define MAX_GID 0x0000FFFF
13378 +#define INOTAG_TAG(cond, uid, gid, tag) \
13379 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13381 +#define TAGINO_UID(cond, uid, tag) (uid)
13382 +#define TAGINO_GID(cond, gid, tag) \
13383 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13388 +#ifdef CONFIG_TAGGING_ID24
13390 +#define MAX_UID 0x00FFFFFF
13391 +#define MAX_GID 0x00FFFFFF
13393 +#define INOTAG_TAG(cond, uid, gid, tag) \
13394 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13396 +#define TAGINO_UID(cond, uid, tag) \
13397 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13398 +#define TAGINO_GID(cond, gid, tag) \
13399 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13404 +#ifdef CONFIG_TAGGING_UID16
13406 +#define MAX_UID 0x0000FFFF
13407 +#define MAX_GID 0xFFFFFFFF
13409 +#define INOTAG_TAG(cond, uid, gid, tag) \
13410 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13412 +#define TAGINO_UID(cond, uid, tag) \
13413 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13414 +#define TAGINO_GID(cond, gid, tag) (gid)
13419 +#ifdef CONFIG_TAGGING_INTERN
13421 +#define MAX_UID 0xFFFFFFFF
13422 +#define MAX_GID 0xFFFFFFFF
13424 +#define INOTAG_TAG(cond, uid, gid, tag) \
13425 + ((cond) ? (tag) : 0)
13427 +#define TAGINO_UID(cond, uid, tag) (uid)
13428 +#define TAGINO_GID(cond, gid, tag) (gid)
13433 +#ifndef CONFIG_TAGGING_NONE
13434 +#define dx_current_fstag(sb) \
13435 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13437 +#define dx_current_fstag(sb) (0)
13440 +#ifndef CONFIG_TAGGING_INTERN
13441 +#define TAGINO_TAG(cond, tag) (0)
13443 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13446 +#define INOTAG_UID(cond, uid, gid) \
13447 + ((cond) ? ((uid) & MAX_UID) : (uid))
13448 +#define INOTAG_GID(cond, uid, gid) \
13449 + ((cond) ? ((gid) & MAX_GID) : (gid))
13452 +static inline uid_t dx_map_uid(uid_t uid)
13454 + if ((uid > MAX_UID) && (uid != -1))
13456 + return (uid & MAX_UID);
13459 +static inline gid_t dx_map_gid(gid_t gid)
13461 + if ((gid > MAX_GID) && (gid != -1))
13463 + return (gid & MAX_GID);
13471 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13473 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13474 + unsigned long *flags);
13476 +#ifdef CONFIG_PROPAGATE
13478 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13480 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13483 +#define dx_propagate_tag(n, i) do { } while (0)
13486 +#endif /* _DX_TAG_H */
13487 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_inet6.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_inet6.h
13488 --- linux-2.6.27.6/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13489 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_inet6.h 2008-11-16 17:35:20.000000000 +0100
13491 +#ifndef _VS_INET6_H
13492 +#define _VS_INET6_H
13494 +#include "vserver/base.h"
13495 +#include "vserver/network.h"
13496 +#include "vserver/debug.h"
13498 +#include <net/ipv6.h>
13500 +#define NXAV6(a) NIP6((a)->ip), NIP6((a)->mask), (a)->prefix, (a)->type
13501 +#define NXAV6_FMT "[" NIP6_FMT "/" NIP6_FMT "/%d:%04x]"
13504 +#ifdef CONFIG_IPV6
13507 +int v6_addr_match(struct nx_addr_v6 *nxa,
13508 + const struct in6_addr *addr, uint16_t mask)
13512 + switch (nxa->type & mask) {
13513 + case NXA_TYPE_MASK:
13514 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13516 + case NXA_TYPE_ADDR:
13517 + ret = ipv6_addr_equal(&nxa->ip, addr);
13519 + case NXA_TYPE_ANY:
13523 + vxdprintk(VXD_CBIT(net, 0),
13524 + "v6_addr_match(%p" NXAV6_FMT ", " NIP6_FMT ", %04x) = %d",
13525 + nxa, NXAV6(nxa), NIP6(*addr), mask, ret);
13530 +int v6_addr_in_nx_info(struct nx_info *nxi,
13531 + const struct in6_addr *addr, uint16_t mask)
13533 + struct nx_addr_v6 *nxa;
13538 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13539 + if (v6_addr_match(nxa, addr, mask))
13543 + vxdprintk(VXD_CBIT(net, 0),
13544 + "v6_addr_in_nx_info(%p[#%u]," NIP6_FMT ",%04x) = %d",
13545 + nxi, nxi ? nxi->nx_id : 0, NIP6(*addr), mask, ret);
13550 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13552 + /* FIXME: needs full range checks */
13553 + return v6_addr_match(nxa, &addr->ip, mask);
13557 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13559 + struct nx_addr_v6 *ptr;
13561 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13562 + if (v6_nx_addr_match(ptr, nxa, mask))
13569 + * Check if a given address matches for a socket
13571 + * nxi: the socket's nx_info if any
13572 + * addr: to be verified address
13575 +int v6_sock_addr_match (
13576 + struct nx_info *nxi,
13577 + struct inet_sock *inet,
13578 + struct in6_addr *addr)
13580 + struct sock *sk = &inet->sk;
13581 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13583 + if (!ipv6_addr_any(addr) &&
13584 + ipv6_addr_equal(saddr, addr))
13586 + if (ipv6_addr_any(saddr))
13587 + return v6_addr_in_nx_info(nxi, addr, -1);
13592 + * check if address is covered by socket
13594 + * sk: the socket to check against
13595 + * addr: the address in question (must be != 0)
13599 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13601 + struct nx_info *nxi = sk->sk_nx_info;
13602 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13604 + vxdprintk(VXD_CBIT(net, 5),
13605 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:" NIP6_FMT " %p;%lx",
13606 + sk, NXAV6(nxa), nxi, NIP6(*saddr), sk->sk_socket,
13607 + (sk->sk_socket?sk->sk_socket->flags:0));
13609 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13610 + return v6_addr_match(nxa, saddr, -1);
13611 + } else if (nxi) { /* match against nx_info */
13612 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13613 + } else { /* unrestricted any socket */
13619 +/* inet related checks and helpers */
13623 +struct net_device;
13627 +#include <linux/netdevice.h>
13628 +#include <linux/inetdevice.h>
13629 +#include <net/inet_timewait_sock.h>
13632 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13633 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13634 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13639 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13645 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13649 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13651 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13652 + nxi, nxi ? nxi->nx_id : 0, ifa,
13653 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13655 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13657 + if (v6_ifa_in_nx_info(ifa, nxi))
13663 +struct nx_v6_sock_addr {
13664 + struct in6_addr saddr; /* Address used for validation */
13665 + struct in6_addr baddr; /* Address used for socket bind */
13669 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13670 + struct nx_v6_sock_addr *nsa)
13672 + // struct sock *sk = &inet->sk;
13673 + // struct nx_info *nxi = sk->sk_nx_info;
13674 + struct in6_addr saddr = addr->sin6_addr;
13675 + struct in6_addr baddr = saddr;
13677 + nsa->saddr = saddr;
13678 + nsa->baddr = baddr;
13683 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13685 + // struct sock *sk = &inet->sk;
13686 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13688 + // *saddr = nsa->baddr;
13689 + // inet->saddr = nsa->baddr;
13693 +int nx_info_has_v6(struct nx_info *nxi)
13697 + if (NX_IPV6(nxi))
13702 +#else /* CONFIG_IPV6 */
13705 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13712 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13718 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13724 +int nx_info_has_v6(struct nx_info *nxi)
13729 +#endif /* CONFIG_IPV6 */
13731 +#define current_nx_info_has_v6() \
13732 + nx_info_has_v6(current_nx_info())
13735 +#warning duplicate inclusion
13737 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_inet.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_inet.h
13738 --- linux-2.6.27.6/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13739 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_inet.h 2008-10-13 14:54:20.000000000 +0200
13741 +#ifndef _VS_INET_H
13742 +#define _VS_INET_H
13744 +#include "vserver/base.h"
13745 +#include "vserver/network.h"
13746 +#include "vserver/debug.h"
13748 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13750 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13751 + NIPQUAD((a)->mask), (a)->type
13752 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13756 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13758 + __be32 ip = nxa->ip[0].s_addr;
13759 + __be32 mask = nxa->mask.s_addr;
13760 + __be32 bcast = ip | ~mask;
13763 + switch (nxa->type & tmask) {
13764 + case NXA_TYPE_MASK:
13765 + ret = (ip == (addr & mask));
13767 + case NXA_TYPE_ADDR:
13771 + /* fall through to broadcast */
13772 + case NXA_MOD_BCAST:
13773 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13775 + case NXA_TYPE_RANGE:
13776 + ret = ((nxa->ip[0].s_addr <= addr) &&
13777 + (nxa->ip[1].s_addr > addr));
13779 + case NXA_TYPE_ANY:
13784 + vxdprintk(VXD_CBIT(net, 0),
13785 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13786 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13791 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13793 + struct nx_addr_v4 *nxa;
13800 + /* allow 127.0.0.1 when remapping lback */
13801 + if ((tmask & NXA_LOOPBACK) &&
13802 + (addr == IPI_LOOPBACK) &&
13803 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13806 + /* check for lback address */
13807 + if ((tmask & NXA_MOD_LBACK) &&
13808 + (nxi->v4_lback.s_addr == addr))
13811 + /* check for broadcast address */
13812 + if ((tmask & NXA_MOD_BCAST) &&
13813 + (nxi->v4_bcast.s_addr == addr))
13816 + /* check for v4 addresses */
13817 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13818 + if (v4_addr_match(nxa, addr, tmask))
13822 + vxdprintk(VXD_CBIT(net, 0),
13823 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13824 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13829 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13831 + /* FIXME: needs full range checks */
13832 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13836 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13838 + struct nx_addr_v4 *ptr;
13840 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13841 + if (v4_nx_addr_match(ptr, nxa, mask))
13846 +#include <net/inet_sock.h>
13849 + * Check if a given address matches for a socket
13851 + * nxi: the socket's nx_info if any
13852 + * addr: to be verified address
13855 +int v4_sock_addr_match (
13856 + struct nx_info *nxi,
13857 + struct inet_sock *inet,
13860 + __be32 saddr = inet->rcv_saddr;
13861 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13863 + if (addr && (saddr == addr || bcast == addr))
13866 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13871 +/* inet related checks and helpers */
13875 +struct net_device;
13878 +#ifdef CONFIG_INET
13880 +#include <linux/netdevice.h>
13881 +#include <linux/inetdevice.h>
13882 +#include <net/inet_sock.h>
13883 +#include <net/inet_timewait_sock.h>
13886 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13887 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13888 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13892 + * check if address is covered by socket
13894 + * sk: the socket to check against
13895 + * addr: the address in question (must be != 0)
13899 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13901 + struct nx_info *nxi = sk->sk_nx_info;
13902 + __be32 saddr = inet_rcv_saddr(sk);
13904 + vxdprintk(VXD_CBIT(net, 5),
13905 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13906 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13907 + (sk->sk_socket?sk->sk_socket->flags:0));
13909 + if (saddr) { /* direct address match */
13910 + return v4_addr_match(nxa, saddr, -1);
13911 + } else if (nxi) { /* match against nx_info */
13912 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13913 + } else { /* unrestricted any socket */
13921 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13923 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13924 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13925 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13927 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13929 + if (dev_in_nx_info(dev, nxi))
13936 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13942 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13946 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13948 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13949 + nxi, nxi ? nxi->nx_id : 0, ifa,
13950 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13952 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13954 + if (v4_ifa_in_nx_info(ifa, nxi))
13960 +struct nx_v4_sock_addr {
13961 + __be32 saddr; /* Address used for validation */
13962 + __be32 baddr; /* Address used for socket bind */
13966 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13967 + struct nx_v4_sock_addr *nsa)
13969 + struct sock *sk = &inet->sk;
13970 + struct nx_info *nxi = sk->sk_nx_info;
13971 + __be32 saddr = addr->sin_addr.s_addr;
13972 + __be32 baddr = saddr;
13974 + vxdprintk(VXD_CBIT(net, 3),
13975 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13976 + sk, sk->sk_nx_info, sk->sk_socket,
13977 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13981 + if (saddr == INADDR_ANY) {
13982 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13983 + baddr = nxi->v4.ip[0].s_addr;
13984 + } else if (saddr == IPI_LOOPBACK) {
13985 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13986 + baddr = nxi->v4_lback.s_addr;
13987 + } else { /* normal address bind */
13988 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13989 + return -EADDRNOTAVAIL;
13993 + vxdprintk(VXD_CBIT(net, 3),
13994 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13995 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13997 + nsa->saddr = saddr;
13998 + nsa->baddr = baddr;
14003 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
14005 + inet->saddr = nsa->baddr;
14006 + inet->rcv_saddr = nsa->baddr;
14011 + * helper to simplify inet_lookup_listener
14013 + * nxi: the socket's nx_info if any
14014 + * addr: to be verified address
14015 + * saddr: socket address
14017 +static inline int v4_inet_addr_match (
14018 + struct nx_info *nxi,
14022 + if (addr && (saddr == addr))
14025 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
14029 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
14031 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
14032 + (addr == nxi->v4_lback.s_addr))
14033 + return IPI_LOOPBACK;
14038 +int nx_info_has_v4(struct nx_info *nxi)
14042 + if (NX_IPV4(nxi))
14044 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
14049 +#else /* CONFIG_INET */
14052 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
14058 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14064 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14070 +int nx_info_has_v4(struct nx_info *nxi)
14075 +#endif /* CONFIG_INET */
14077 +#define current_nx_info_has_v4() \
14078 + nx_info_has_v4(current_nx_info())
14081 +// #warning duplicate inclusion
14083 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_limit.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_limit.h
14084 --- linux-2.6.27.6/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
14085 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_limit.h 2008-10-13 14:54:20.000000000 +0200
14087 +#ifndef _VS_LIMIT_H
14088 +#define _VS_LIMIT_H
14090 +#include "vserver/limit.h"
14091 +#include "vserver/base.h"
14092 +#include "vserver/context.h"
14093 +#include "vserver/debug.h"
14094 +#include "vserver/context.h"
14095 +#include "vserver/limit_int.h"
14098 +#define vx_acc_cres(v, d, p, r) \
14099 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
14101 +#define vx_acc_cres_cond(x, d, p, r) \
14102 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
14103 + r, d, p, __FILE__, __LINE__)
14106 +#define vx_add_cres(v, a, p, r) \
14107 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
14108 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
14110 +#define vx_add_cres_cond(x, a, p, r) \
14111 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
14112 + r, a, p, __FILE__, __LINE__)
14113 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
14116 +/* process and file limits */
14118 +#define vx_nproc_inc(p) \
14119 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
14121 +#define vx_nproc_dec(p) \
14122 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
14124 +#define vx_files_inc(f) \
14125 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
14127 +#define vx_files_dec(f) \
14128 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
14130 +#define vx_locks_inc(l) \
14131 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
14133 +#define vx_locks_dec(l) \
14134 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
14136 +#define vx_openfd_inc(f) \
14137 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
14139 +#define vx_openfd_dec(f) \
14140 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
14143 +#define vx_cres_avail(v, n, r) \
14144 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
14147 +#define vx_nproc_avail(n) \
14148 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
14150 +#define vx_files_avail(n) \
14151 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
14153 +#define vx_locks_avail(n) \
14154 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
14156 +#define vx_openfd_avail(n) \
14157 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
14160 +/* dentry limits */
14162 +#define vx_dentry_inc(d) do { \
14163 + if (atomic_read(&d->d_count) == 1) \
14164 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
14167 +#define vx_dentry_dec(d) do { \
14168 + if (atomic_read(&d->d_count) == 0) \
14169 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
14172 +#define vx_dentry_avail(n) \
14173 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
14176 +/* socket limits */
14178 +#define vx_sock_inc(s) \
14179 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
14181 +#define vx_sock_dec(s) \
14182 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
14184 +#define vx_sock_avail(n) \
14185 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
14188 +/* ipc resource limits */
14190 +#define vx_ipcmsg_add(v, u, a) \
14191 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
14193 +#define vx_ipcmsg_sub(v, u, a) \
14194 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
14196 +#define vx_ipcmsg_avail(v, a) \
14197 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
14200 +#define vx_ipcshm_add(v, k, a) \
14201 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14203 +#define vx_ipcshm_sub(v, k, a) \
14204 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14206 +#define vx_ipcshm_avail(v, a) \
14207 + vx_cres_avail(v, a, VLIMIT_SHMEM)
14210 +#define vx_semary_inc(a) \
14211 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
14213 +#define vx_semary_dec(a) \
14214 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
14217 +#define vx_nsems_add(a,n) \
14218 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
14220 +#define vx_nsems_sub(a,n) \
14221 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
14225 +#warning duplicate inclusion
14227 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_memory.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_memory.h
14228 --- linux-2.6.27.6/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
14229 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_memory.h 2008-10-13 14:54:20.000000000 +0200
14231 +#ifndef _VS_MEMORY_H
14232 +#define _VS_MEMORY_H
14234 +#include "vserver/limit.h"
14235 +#include "vserver/base.h"
14236 +#include "vserver/context.h"
14237 +#include "vserver/debug.h"
14238 +#include "vserver/context.h"
14239 +#include "vserver/limit_int.h"
14242 +#define __acc_add_long(a, v) (*(v) += (a))
14243 +#define __acc_inc_long(v) (++*(v))
14244 +#define __acc_dec_long(v) (--*(v))
14246 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
14247 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
14248 +#define __acc_inc_atomic(v) atomic_long_inc(v)
14249 +#define __acc_dec_atomic(v) atomic_long_dec(v)
14250 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14251 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
14252 +#define __acc_inc_atomic(v) __acc_inc_long(v)
14253 +#define __acc_dec_atomic(v) __acc_dec_long(v)
14254 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14257 +#define vx_acc_page(m, d, v, r) do { \
14259 + __acc_inc_long(&(m)->v); \
14261 + __acc_dec_long(&(m)->v); \
14262 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14265 +#define vx_acc_page_atomic(m, d, v, r) do { \
14267 + __acc_inc_atomic(&(m)->v); \
14269 + __acc_dec_atomic(&(m)->v); \
14270 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14274 +#define vx_acc_pages(m, p, v, r) do { \
14275 + unsigned long __p = (p); \
14276 + __acc_add_long(__p, &(m)->v); \
14277 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14280 +#define vx_acc_pages_atomic(m, p, v, r) do { \
14281 + unsigned long __p = (p); \
14282 + __acc_add_atomic(__p, &(m)->v); \
14283 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14288 +#define vx_acc_vmpage(m, d) \
14289 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
14290 +#define vx_acc_vmlpage(m, d) \
14291 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
14292 +#define vx_acc_file_rsspage(m, d) \
14293 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
14294 +#define vx_acc_anon_rsspage(m, d) \
14295 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
14297 +#define vx_acc_vmpages(m, p) \
14298 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
14299 +#define vx_acc_vmlpages(m, p) \
14300 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
14301 +#define vx_acc_file_rsspages(m, p) \
14302 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
14303 +#define vx_acc_anon_rsspages(m, p) \
14304 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
14306 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
14307 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
14309 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
14310 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
14311 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
14312 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
14314 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
14315 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
14316 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
14317 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
14319 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
14320 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
14321 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
14322 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
14324 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
14325 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
14326 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
14327 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
14330 +#define vx_pages_avail(m, p, r) \
14331 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
14333 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
14334 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
14335 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
14336 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
14338 +#define vx_rss_avail(m, p) \
14339 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
14343 + VXPT_UNKNOWN = 0,
14352 +#define vx_page_fault(mm, vma, type, ret)
14356 +void __vx_page_fault(struct mm_struct *mm,
14357 + struct vm_area_struct *vma, int type, int ret)
14359 + struct vx_info *vxi = mm->mm_vx_info;
14362 + static char *page_type[6] =
14363 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14364 + static char *page_what[4] =
14365 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14371 + what = (ret & 0x3);
14373 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14374 + type, what, ret, page_type[type], page_what[what]);
14376 + if (ret & VM_FAULT_WRITE)
14378 + atomic_inc(&vxi->cacct.page[type][what]);
14381 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14385 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14388 +#warning duplicate inclusion
14390 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_network.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_network.h
14391 --- linux-2.6.27.6/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14392 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_network.h 2008-10-13 14:54:20.000000000 +0200
14394 +#ifndef _NX_VS_NETWORK_H
14395 +#define _NX_VS_NETWORK_H
14397 +#include "vserver/context.h"
14398 +#include "vserver/network.h"
14399 +#include "vserver/base.h"
14400 +#include "vserver/check.h"
14401 +#include "vserver/debug.h"
14403 +#include <linux/sched.h>
14406 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14408 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14409 + const char *_file, int _line)
14414 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14415 + nxi, nxi ? nxi->nx_id : 0,
14416 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14419 + atomic_inc(&nxi->nx_usecnt);
14424 +extern void free_nx_info(struct nx_info *);
14426 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14428 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14433 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14434 + nxi, nxi ? nxi->nx_id : 0,
14435 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14438 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14439 + free_nx_info(nxi);
14443 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14445 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14446 + const char *_file, int _line)
14449 + vxlprintk(VXD_CBIT(nid, 3),
14450 + "init_nx_info(%p[#%d.%d])",
14451 + nxi, nxi ? nxi->nx_id : 0,
14452 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14455 + atomic_inc(&nxi->nx_usecnt);
14461 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14463 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14464 + const char *_file, int _line)
14466 + struct nx_info *nxo;
14471 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14472 + nxi, nxi ? nxi->nx_id : 0,
14473 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14476 + atomic_inc(&nxi->nx_usecnt);
14477 + nxo = xchg(nxp, nxi);
14481 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14483 +static inline void __clr_nx_info(struct nx_info **nxp,
14484 + const char *_file, int _line)
14486 + struct nx_info *nxo;
14488 + nxo = xchg(nxp, NULL);
14492 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14493 + nxo, nxo ? nxo->nx_id : 0,
14494 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14497 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14498 + free_nx_info(nxo);
14502 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14504 +static inline void __claim_nx_info(struct nx_info *nxi,
14505 + struct task_struct *task, const char *_file, int _line)
14507 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14508 + nxi, nxi ? nxi->nx_id : 0,
14509 + nxi?atomic_read(&nxi->nx_usecnt):0,
14510 + nxi?atomic_read(&nxi->nx_tasks):0,
14511 + task, _file, _line);
14513 + atomic_inc(&nxi->nx_tasks);
14517 +extern void unhash_nx_info(struct nx_info *);
14519 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14521 +static inline void __release_nx_info(struct nx_info *nxi,
14522 + struct task_struct *task, const char *_file, int _line)
14524 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14525 + nxi, nxi ? nxi->nx_id : 0,
14526 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14527 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14528 + task, _file, _line);
14532 + if (atomic_dec_and_test(&nxi->nx_tasks))
14533 + unhash_nx_info(nxi);
14537 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14539 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14540 + const char *_file, int _line)
14542 + struct nx_info *nxi;
14545 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14546 + p, _file, _line);
14547 + nxi = __get_nx_info(p->nx_info, _file, _line);
14553 +static inline void exit_nx_info(struct task_struct *p)
14556 + release_nx_info(p->nx_info, p);
14561 +#warning duplicate inclusion
14563 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_pid.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_pid.h
14564 --- linux-2.6.27.6/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14565 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_pid.h 2008-10-13 14:54:20.000000000 +0200
14570 +#include "vserver/base.h"
14571 +#include "vserver/check.h"
14572 +#include "vserver/context.h"
14573 +#include "vserver/debug.h"
14574 +#include "vserver/pid.h"
14575 +#include <linux/pid_namespace.h>
14578 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14581 +int vx_proc_task_visible(struct task_struct *task)
14583 + if ((task->pid == 1) &&
14584 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14585 + /* show a blend through init */
14587 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14594 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14599 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14601 + struct task_struct *task = find_task_by_real_pid(pid);
14603 + if (task && !vx_proc_task_visible(task)) {
14604 + vxdprintk(VXD_CBIT(misc, 6),
14605 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14606 + task, task->xid, task->pid,
14607 + current, current->xid, current->pid);
14616 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14618 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14620 + if (task && !vx_proc_task_visible(task)) {
14621 + vxdprintk(VXD_CBIT(misc, 6),
14622 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14623 + task, task->xid, task->pid,
14624 + current, current->xid, current->pid);
14625 + put_task_struct(task);
14634 +struct task_struct *vx_child_reaper(struct task_struct *p)
14636 + struct vx_info *vxi = p->vx_info;
14637 + struct task_struct *reaper = child_reaper(p);
14642 + BUG_ON(!p->vx_info->vx_reaper);
14644 + /* child reaper for the guest reaper */
14645 + if (vxi->vx_reaper == p)
14648 + reaper = vxi->vx_reaper;
14650 + vxdprintk(VXD_CBIT(xid, 7),
14651 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14652 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14660 +#warning duplicate inclusion
14662 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_sched.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_sched.h
14663 --- linux-2.6.27.6/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14664 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_sched.h 2008-10-13 14:54:20.000000000 +0200
14666 +#ifndef _VS_SCHED_H
14667 +#define _VS_SCHED_H
14669 +#include "vserver/base.h"
14670 +#include "vserver/context.h"
14671 +#include "vserver/sched.h"
14674 +#define VAVAVOOM_RATIO 50
14676 +#define MAX_PRIO_BIAS 20
14677 +#define MIN_PRIO_BIAS -20
14680 +#ifdef CONFIG_VSERVER_HARDCPU
14683 + * effective_prio - return the priority that is based on the static
14684 + * priority but is modified by bonuses/penalties.
14686 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14687 + * into a -4 ... 0 ... +4 bonus/penalty range.
14689 + * Additionally, we scale another amount based on the number of
14690 + * CPU tokens currently held by the context, if the process is
14691 + * part of a context (and the appropriate SCHED flag is set).
14692 + * This ranges from -5 ... 0 ... +15, quadratically.
14694 + * So, the total bonus is -9 .. 0 .. +19
14695 + * We use ~50% of the full 0...39 priority range so that:
14697 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14698 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14699 + * unless that context is far exceeding its CPU allocation.
14701 + * Both properties are important to certain workloads.
14704 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14706 + int vavavoom, max;
14708 + /* lots of tokens = lots of vavavoom
14709 + * no tokens = no vavavoom */
14710 + if ((vavavoom = sched_pc->tokens) >= 0) {
14711 + max = sched_pc->tokens_max;
14712 + vavavoom = max - vavavoom;
14714 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14715 + * (vavavoom*vavavoom - (max >> 2)) / max;
14723 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14725 + struct vx_info *vxi = p->vx_info;
14726 + struct _vx_sched_pc *sched_pc;
14731 + sched_pc = &vx_cpu(vxi, sched_pc);
14732 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14733 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14735 + sched_pc->vavavoom = vavavoom;
14736 + prio += vavavoom;
14738 + prio += sched_pc->prio_bias;
14742 +#else /* !CONFIG_VSERVER_HARDCPU */
14745 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14747 + struct vx_info *vxi = p->vx_info;
14750 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14754 +#endif /* CONFIG_VSERVER_HARDCPU */
14757 +static inline void vx_account_user(struct vx_info *vxi,
14758 + cputime_t cputime, int nice)
14762 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14765 +static inline void vx_account_system(struct vx_info *vxi,
14766 + cputime_t cputime, int idle)
14770 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14774 +#warning duplicate inclusion
14776 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_socket.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_socket.h
14777 --- linux-2.6.27.6/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14778 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_socket.h 2008-10-13 14:54:20.000000000 +0200
14780 +#ifndef _VS_SOCKET_H
14781 +#define _VS_SOCKET_H
14783 +#include "vserver/debug.h"
14784 +#include "vserver/base.h"
14785 +#include "vserver/cacct.h"
14786 +#include "vserver/context.h"
14787 +#include "vserver/tag.h"
14790 +/* socket accounting */
14792 +#include <linux/socket.h>
14794 +static inline int vx_sock_type(int family)
14796 + switch (family) {
14798 + return VXA_SOCK_UNSPEC;
14800 + return VXA_SOCK_UNIX;
14802 + return VXA_SOCK_INET;
14804 + return VXA_SOCK_INET6;
14806 + return VXA_SOCK_PACKET;
14808 + return VXA_SOCK_OTHER;
14812 +#define vx_acc_sock(v, f, p, s) \
14813 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14815 +static inline void __vx_acc_sock(struct vx_info *vxi,
14816 + int family, int pos, int size, char *file, int line)
14819 + int type = vx_sock_type(family);
14821 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14822 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14826 +#define vx_sock_recv(sk, s) \
14827 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14828 +#define vx_sock_send(sk, s) \
14829 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14830 +#define vx_sock_fail(sk, s) \
14831 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14834 +#define sock_vx_init(s) do { \
14835 + (s)->sk_xid = 0; \
14836 + (s)->sk_vx_info = NULL; \
14839 +#define sock_nx_init(s) do { \
14840 + (s)->sk_nid = 0; \
14841 + (s)->sk_nx_info = NULL; \
14845 +#warning duplicate inclusion
14847 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_tag.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_tag.h
14848 --- linux-2.6.27.6/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14849 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_tag.h 2008-10-24 03:34:52.000000000 +0200
14854 +#include <linux/vserver/tag.h>
14856 +/* check conditions */
14858 +#define DX_ADMIN 0x0001
14859 +#define DX_WATCH 0x0002
14860 +#define DX_HOSTID 0x0008
14862 +#define DX_IDENT 0x0010
14864 +#define DX_ARG_MASK 0x0010
14867 +#define dx_task_tag(t) ((t)->tag)
14869 +#define dx_current_tag() dx_task_tag(current)
14871 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14873 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14877 + * check current context for ADMIN/WATCH and
14878 + * optionally against supplied argument
14880 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14882 + if (mode & DX_ARG_MASK) {
14883 + if ((mode & DX_IDENT) && (id == cid))
14886 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14887 + ((mode & DX_WATCH) && (cid == 1)) ||
14888 + ((mode & DX_HOSTID) && (id == 0)));
14892 +int dx_permission(struct inode *inode, int mask);
14896 +#warning duplicate inclusion
14898 diff -NurpP --minimal linux-2.6.27.6/include/linux/vs_time.h linux-2.6.27.6-vs2.3.0.36/include/linux/vs_time.h
14899 --- linux-2.6.27.6/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14900 +++ linux-2.6.27.6-vs2.3.0.36/include/linux/vs_time.h 2008-10-13 14:54:20.000000000 +0200
14902 +#ifndef _VS_TIME_H
14903 +#define _VS_TIME_H
14906 +/* time faking stuff */
14908 +#ifdef CONFIG_VSERVER_VTIME
14910 +extern void vx_gettimeofday(struct timeval *tv);
14911 +extern int vx_settimeofday(struct timespec *ts);
14914 +#define vx_gettimeofday(t) do_gettimeofday(t)
14915 +#define vx_settimeofday(t) do_settimeofday(t)
14919 +#warning duplicate inclusion
14921 diff -NurpP --minimal linux-2.6.27.6/include/net/addrconf.h linux-2.6.27.6-vs2.3.0.36/include/net/addrconf.h
14922 --- linux-2.6.27.6/include/net/addrconf.h 2008-10-13 14:52:09.000000000 +0200
14923 +++ linux-2.6.27.6-vs2.3.0.36/include/net/addrconf.h 2008-10-13 14:54:20.000000000 +0200
14924 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14925 struct net_device *dev,
14926 const struct in6_addr *daddr,
14927 unsigned int srcprefs,
14928 - struct in6_addr *saddr);
14929 + struct in6_addr *saddr,
14930 + struct nx_info *nxi);
14931 extern int ipv6_get_lladdr(struct net_device *dev,
14932 struct in6_addr *addr,
14933 unsigned char banned_flags);
14934 diff -NurpP --minimal linux-2.6.27.6/include/net/af_unix.h linux-2.6.27.6-vs2.3.0.36/include/net/af_unix.h
14935 --- linux-2.6.27.6/include/net/af_unix.h 2008-11-17 18:07:34.000000000 +0100
14936 +++ linux-2.6.27.6-vs2.3.0.36/include/net/af_unix.h 2008-11-17 18:20:41.000000000 +0100
14938 #include <linux/socket.h>
14939 #include <linux/un.h>
14940 #include <linux/mutex.h>
14941 +#include <linux/vs_base.h>
14942 #include <net/sock.h>
14944 extern void unix_inflight(struct file *fp);
14945 diff -NurpP --minimal linux-2.6.27.6/include/net/inet_sock.h linux-2.6.27.6-vs2.3.0.36/include/net/inet_sock.h
14946 --- linux-2.6.27.6/include/net/inet_sock.h 2008-10-13 14:52:09.000000000 +0200
14947 +++ linux-2.6.27.6-vs2.3.0.36/include/net/inet_sock.h 2008-10-13 14:54:20.000000000 +0200
14949 #include <net/flow.h>
14950 #include <net/sock.h>
14951 #include <net/request_sock.h>
14952 -#include <net/route.h>
14953 +// #include <net/route.h>
14954 #include <net/netns/hash.h>
14956 /** struct ip_options - IP Options
14957 @@ -195,11 +195,6 @@ static inline int inet_sk_ehashfn(const
14961 -static inline int inet_iif(const struct sk_buff *skb)
14963 - return skb->rtable->rt_iif;
14966 static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops)
14968 struct request_sock *req = reqsk_alloc(ops);
14969 diff -NurpP --minimal linux-2.6.27.6/include/net/inet_timewait_sock.h linux-2.6.27.6-vs2.3.0.36/include/net/inet_timewait_sock.h
14970 --- linux-2.6.27.6/include/net/inet_timewait_sock.h 2008-10-13 14:52:09.000000000 +0200
14971 +++ linux-2.6.27.6-vs2.3.0.36/include/net/inet_timewait_sock.h 2008-10-13 14:54:20.000000000 +0200
14972 @@ -15,15 +15,14 @@
14973 #ifndef _INET_TIMEWAIT_SOCK_
14974 #define _INET_TIMEWAIT_SOCK_
14976 +// #include <net/inet_sock.h>
14977 +#include <net/sock.h>
14979 #include <linux/list.h>
14980 #include <linux/module.h>
14981 #include <linux/timer.h>
14982 #include <linux/types.h>
14983 #include <linux/workqueue.h>
14985 -#include <net/inet_sock.h>
14986 -#include <net/sock.h>
14987 #include <net/tcp_states.h>
14988 #include <net/timewait_sock.h>
14990 @@ -116,6 +115,10 @@ struct inet_timewait_sock {
14991 #define tw_hash __tw_common.skc_hash
14992 #define tw_prot __tw_common.skc_prot
14993 #define tw_net __tw_common.skc_net
14994 +#define tw_xid __tw_common.skc_xid
14995 +#define tw_vx_info __tw_common.skc_vx_info
14996 +#define tw_nid __tw_common.skc_nid
14997 +#define tw_nx_info __tw_common.skc_nx_info
14999 volatile unsigned char tw_substate;
15000 /* 3 bits hole, try to pack */
15001 diff -NurpP --minimal linux-2.6.27.6/include/net/route.h linux-2.6.27.6-vs2.3.0.36/include/net/route.h
15002 --- linux-2.6.27.6/include/net/route.h 2008-10-13 14:52:09.000000000 +0200
15003 +++ linux-2.6.27.6-vs2.3.0.36/include/net/route.h 2008-10-13 14:54:20.000000000 +0200
15005 #include <net/inetpeer.h>
15006 #include <net/flow.h>
15007 #include <net/sock.h>
15008 +// #include <linux/in.h>
15009 #include <linux/in_route.h>
15010 #include <linux/rtnetlink.h>
15011 #include <linux/route.h>
15012 @@ -85,6 +86,11 @@ struct ip_rt_acct
15016 +static inline int inet_iif(const struct sk_buff *skb)
15018 + return skb->rtable->rt_iif;
15021 struct rt_cache_stat
15023 unsigned int in_hit;
15024 @@ -135,6 +141,9 @@ static inline void ip_rt_put(struct rtab
15025 dst_release(&rt->u.dst);
15028 +#include <linux/vs_base.h>
15029 +#include <linux/vs_inet.h>
15031 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
15033 extern const __u8 ip_tos2prio[16];
15034 @@ -144,6 +153,9 @@ static inline char rt_tos2priority(u8 to
15035 return ip_tos2prio[IPTOS_TOS(tos)>>1];
15038 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
15039 + struct rtable **, struct flowi *);
15041 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
15042 __be32 src, u32 tos, int oif, u8 protocol,
15043 __be16 sport, __be16 dport, struct sock *sk,
15044 @@ -161,7 +173,21 @@ static inline int ip_route_connect(struc
15047 struct net *net = sock_net(sk);
15048 - if (!dst || !src) {
15049 + struct nx_info *nx_info = current->nx_info;
15052 + nx_info = sk->sk_nx_info;
15054 + vxdprintk(VXD_CBIT(net, 4),
15055 + "ip_route_connect(%p) %p,%p;%lx",
15056 + sk, nx_info, sk->sk_socket,
15057 + (sk->sk_socket?sk->sk_socket->flags:0));
15059 + err = ip_v4_find_src(net, nx_info, rp, &fl);
15063 + if (!fl.fl4_dst || !fl.fl4_src) {
15064 err = __ip_route_output_key(net, rp, &fl);
15067 diff -NurpP --minimal linux-2.6.27.6/include/net/sock.h linux-2.6.27.6-vs2.3.0.36/include/net/sock.h
15068 --- linux-2.6.27.6/include/net/sock.h 2008-10-13 14:52:09.000000000 +0200
15069 +++ linux-2.6.27.6-vs2.3.0.36/include/net/sock.h 2008-10-13 14:54:20.000000000 +0200
15070 @@ -128,6 +128,10 @@ struct sock_common {
15071 #ifdef CONFIG_NET_NS
15072 struct net *skc_net;
15075 + struct vx_info *skc_vx_info;
15077 + struct nx_info *skc_nx_info;
15081 @@ -211,6 +215,10 @@ struct sock {
15082 #define sk_hash __sk_common.skc_hash
15083 #define sk_prot __sk_common.skc_prot
15084 #define sk_net __sk_common.skc_net
15085 +#define sk_xid __sk_common.skc_xid
15086 +#define sk_vx_info __sk_common.skc_vx_info
15087 +#define sk_nid __sk_common.skc_nid
15088 +#define sk_nx_info __sk_common.skc_nx_info
15089 unsigned char sk_shutdown : 2,
15092 diff -NurpP --minimal linux-2.6.27.6/init/main.c linux-2.6.27.6-vs2.3.0.36/init/main.c
15093 --- linux-2.6.27.6/init/main.c 2008-10-13 14:52:09.000000000 +0200
15094 +++ linux-2.6.27.6-vs2.3.0.36/init/main.c 2008-10-13 14:54:20.000000000 +0200
15096 #include <linux/sched.h>
15097 #include <linux/signal.h>
15098 #include <linux/idr.h>
15099 +#include <linux/vserver/percpu.h>
15101 #include <asm/io.h>
15102 #include <asm/bugs.h>
15103 @@ -391,12 +392,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
15105 static void __init setup_per_cpu_areas(void)
15107 - unsigned long size, i;
15108 + unsigned long size, vspc, i;
15110 unsigned long nr_possible_cpus = num_possible_cpus();
15112 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
15114 /* Copy section for each CPU (we discard the original) */
15115 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
15116 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
15117 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
15119 for_each_possible_cpu(i) {
15120 diff -NurpP --minimal linux-2.6.27.6/ipc/mqueue.c linux-2.6.27.6-vs2.3.0.36/ipc/mqueue.c
15121 --- linux-2.6.27.6/ipc/mqueue.c 2008-10-13 14:52:09.000000000 +0200
15122 +++ linux-2.6.27.6-vs2.3.0.36/ipc/mqueue.c 2008-10-13 14:54:20.000000000 +0200
15124 #include <linux/mutex.h>
15125 #include <linux/nsproxy.h>
15126 #include <linux/pid.h>
15127 +#include <linux/vs_context.h>
15128 +#include <linux/vs_limit.h>
15130 #include <net/sock.h>
15132 @@ -71,6 +73,7 @@ struct mqueue_inode_info {
15133 struct sigevent notify;
15134 struct pid* notify_owner;
15135 struct user_struct *user; /* user who created, for accounting */
15136 + struct vx_info *vxi;
15137 struct sock *notify_sock;
15138 struct sk_buff *notify_cookie;
15140 @@ -119,6 +122,7 @@ static struct inode *mqueue_get_inode(st
15141 struct mqueue_inode_info *info;
15142 struct task_struct *p = current;
15143 struct user_struct *u = p->user;
15144 + struct vx_info *vxi = p->vx_info;
15145 unsigned long mq_bytes, mq_msg_tblsz;
15147 inode->i_fop = &mqueue_file_operations;
15148 @@ -133,6 +137,7 @@ static struct inode *mqueue_get_inode(st
15149 info->notify_owner = NULL;
15151 info->user = NULL; /* set when all is ok */
15152 + info->vxi = NULL;
15153 memset(&info->attr, 0, sizeof(info->attr));
15154 info->attr.mq_maxmsg = DFLT_MSGMAX;
15155 info->attr.mq_msgsize = DFLT_MSGSIZEMAX;
15156 @@ -147,22 +152,26 @@ static struct inode *mqueue_get_inode(st
15157 spin_lock(&mq_lock);
15158 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
15159 u->mq_bytes + mq_bytes >
15160 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
15161 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
15162 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
15163 spin_unlock(&mq_lock);
15166 u->mq_bytes += mq_bytes;
15167 + vx_ipcmsg_add(vxi, u, mq_bytes);
15168 spin_unlock(&mq_lock);
15170 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
15171 if (!info->messages) {
15172 spin_lock(&mq_lock);
15173 u->mq_bytes -= mq_bytes;
15174 + vx_ipcmsg_sub(vxi, u, mq_bytes);
15175 spin_unlock(&mq_lock);
15179 info->user = get_uid(u);
15180 + info->vxi = get_vx_info(vxi);
15181 } else if (S_ISDIR(mode)) {
15183 /* Some things misbehave if size == 0 on a directory */
15184 @@ -253,10 +262,14 @@ static void mqueue_delete_inode(struct i
15185 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
15188 + struct vx_info *vxi = info->vxi;
15190 spin_lock(&mq_lock);
15191 user->mq_bytes -= mq_bytes;
15192 + vx_ipcmsg_sub(vxi, user, mq_bytes);
15194 spin_unlock(&mq_lock);
15195 + put_vx_info(vxi);
15199 diff -NurpP --minimal linux-2.6.27.6/ipc/msg.c linux-2.6.27.6-vs2.3.0.36/ipc/msg.c
15200 --- linux-2.6.27.6/ipc/msg.c 2008-07-13 23:51:29.000000000 +0200
15201 +++ linux-2.6.27.6-vs2.3.0.36/ipc/msg.c 2008-10-13 14:54:20.000000000 +0200
15203 #include <linux/rwsem.h>
15204 #include <linux/nsproxy.h>
15205 #include <linux/ipc_namespace.h>
15206 +#include <linux/vs_base.h>
15208 #include <asm/current.h>
15209 #include <asm/uaccess.h>
15210 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
15212 msq->q_perm.mode = msgflg & S_IRWXUGO;
15213 msq->q_perm.key = key;
15214 + msq->q_perm.xid = vx_current_xid();
15216 msq->q_perm.security = NULL;
15217 retval = security_msg_queue_alloc(msq);
15218 diff -NurpP --minimal linux-2.6.27.6/ipc/namespace.c linux-2.6.27.6-vs2.3.0.36/ipc/namespace.c
15219 --- linux-2.6.27.6/ipc/namespace.c 2008-07-13 23:51:29.000000000 +0200
15220 +++ linux-2.6.27.6-vs2.3.0.36/ipc/namespace.c 2008-10-13 14:54:20.000000000 +0200
15222 #include <linux/rcupdate.h>
15223 #include <linux/nsproxy.h>
15224 #include <linux/slab.h>
15225 +#include <linux/vs_base.h>
15226 +#include <linux/vserver/global.h>
15230 @@ -35,6 +37,7 @@ static struct ipc_namespace *clone_ipc_n
15231 register_ipcns_notifier(ns);
15233 kref_init(&ns->kref);
15234 + atomic_inc(&vs_global_ipc_ns);
15238 @@ -101,6 +104,7 @@ void free_ipc_ns(struct kref *kref)
15242 + atomic_dec(&vs_global_ipc_ns);
15244 atomic_dec(&nr_ipc_ns);
15246 diff -NurpP --minimal linux-2.6.27.6/ipc/sem.c linux-2.6.27.6-vs2.3.0.36/ipc/sem.c
15247 --- linux-2.6.27.6/ipc/sem.c 2008-10-13 14:52:09.000000000 +0200
15248 +++ linux-2.6.27.6-vs2.3.0.36/ipc/sem.c 2008-10-13 14:54:20.000000000 +0200
15250 #include <linux/rwsem.h>
15251 #include <linux/nsproxy.h>
15252 #include <linux/ipc_namespace.h>
15253 +#include <linux/vs_base.h>
15254 +#include <linux/vs_limit.h>
15256 #include <asm/uaccess.h>
15258 @@ -255,6 +257,7 @@ static int newary(struct ipc_namespace *
15260 sma->sem_perm.mode = (semflg & S_IRWXUGO);
15261 sma->sem_perm.key = key;
15262 + sma->sem_perm.xid = vx_current_xid();
15264 sma->sem_perm.security = NULL;
15265 retval = security_sem_alloc(sma);
15266 @@ -270,6 +273,9 @@ static int newary(struct ipc_namespace *
15269 ns->used_sems += nsems;
15270 + /* FIXME: obsoleted? */
15271 + vx_semary_inc(sma);
15272 + vx_nsems_add(sma, nsems);
15274 sma->sem_base = (struct sem *) &sma[1];
15275 INIT_LIST_HEAD(&sma->sem_pending);
15276 diff -NurpP --minimal linux-2.6.27.6/ipc/shm.c linux-2.6.27.6-vs2.3.0.36/ipc/shm.c
15277 --- linux-2.6.27.6/ipc/shm.c 2008-10-13 14:52:09.000000000 +0200
15278 +++ linux-2.6.27.6-vs2.3.0.36/ipc/shm.c 2008-10-13 14:54:20.000000000 +0200
15280 #include <linux/nsproxy.h>
15281 #include <linux/mount.h>
15282 #include <linux/ipc_namespace.h>
15283 +#include <linux/vs_context.h>
15284 +#include <linux/vs_limit.h>
15286 #include <asm/uaccess.h>
15288 @@ -168,7 +170,12 @@ static void shm_open(struct vm_area_stru
15290 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15292 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15293 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15294 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15296 + vx_ipcshm_sub(vxi, shp, numpages);
15297 + ns->shm_tot -= numpages;
15301 if (!is_file_hugepages(shp->shm_file))
15302 @@ -178,6 +185,7 @@ static void shm_destroy(struct ipc_names
15304 fput (shp->shm_file);
15305 security_shm_free(shp);
15306 + put_vx_info(vxi);
15307 ipc_rcu_putref(shp);
15310 @@ -347,11 +355,15 @@ static int newseg(struct ipc_namespace *
15311 if (ns->shm_tot + numpages > ns->shm_ctlall)
15314 + if (!vx_ipcshm_avail(current->vx_info, numpages))
15317 shp = ipc_rcu_alloc(sizeof(*shp));
15321 shp->shm_perm.key = key;
15322 + shp->shm_perm.xid = vx_current_xid();
15323 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15324 shp->mlock_user = NULL;
15326 @@ -404,6 +416,7 @@ static int newseg(struct ipc_namespace *
15327 ns->shm_tot += numpages;
15328 error = shp->shm_perm.id;
15330 + vx_ipcshm_add(current->vx_info, key, numpages);
15334 diff -NurpP --minimal linux-2.6.27.6/kernel/capability.c linux-2.6.27.6-vs2.3.0.36/kernel/capability.c
15335 --- linux-2.6.27.6/kernel/capability.c 2008-10-13 14:52:09.000000000 +0200
15336 +++ linux-2.6.27.6-vs2.3.0.36/kernel/capability.c 2008-10-13 14:54:20.000000000 +0200
15338 #include <linux/security.h>
15339 #include <linux/syscalls.h>
15340 #include <linux/pid_namespace.h>
15341 +#include <linux/vs_context.h>
15342 #include <asm/uaccess.h>
15345 @@ -166,6 +167,8 @@ static inline int cap_set_pg(int pgrp_nr
15347 pgrp = find_vpid(pgrp_nr);
15348 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
15349 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
15352 while_each_thread(g, target) {
15353 if (!security_capset_check(target, effective,
15354 @@ -486,6 +489,8 @@ asmlinkage long sys_capset(cap_user_head
15358 +#include <linux/vserver/base.h>
15361 * capable - Determine if the current task has a superior capability in effect
15362 * @cap: The capability to be tested for
15363 @@ -498,6 +503,9 @@ asmlinkage long sys_capset(cap_user_head
15365 int capable(int cap)
15367 + /* here for now so we don't require task locking */
15368 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15370 if (has_capability(current, cap)) {
15371 current->flags |= PF_SUPERPRIV;
15373 diff -NurpP --minimal linux-2.6.27.6/kernel/compat.c linux-2.6.27.6-vs2.3.0.36/kernel/compat.c
15374 --- linux-2.6.27.6/kernel/compat.c 2008-07-13 23:51:29.000000000 +0200
15375 +++ linux-2.6.27.6-vs2.3.0.36/kernel/compat.c 2008-10-13 14:54:20.000000000 +0200
15376 @@ -845,7 +845,7 @@ asmlinkage long compat_sys_time(compat_t
15380 - do_gettimeofday(&tv);
15381 + vx_gettimeofday(&tv);
15385 @@ -869,7 +869,7 @@ asmlinkage long compat_sys_stime(compat_
15389 - do_settimeofday(&tv);
15390 + vx_settimeofday(&tv);
15394 diff -NurpP --minimal linux-2.6.27.6/kernel/exit.c linux-2.6.27.6-vs2.3.0.36/kernel/exit.c
15395 --- linux-2.6.27.6/kernel/exit.c 2008-10-13 14:52:09.000000000 +0200
15396 +++ linux-2.6.27.6-vs2.3.0.36/kernel/exit.c 2008-10-13 14:54:20.000000000 +0200
15398 #include <linux/blkdev.h>
15399 #include <linux/task_io_accounting_ops.h>
15400 #include <linux/tracehook.h>
15401 +#include <linux/vs_limit.h>
15402 +#include <linux/vs_context.h>
15403 +#include <linux/vs_network.h>
15404 +#include <linux/vs_pid.h>
15405 +#include <linux/vserver/global.h>
15407 #include <asm/uaccess.h>
15408 #include <asm/unistd.h>
15409 @@ -485,9 +490,11 @@ static void close_files(struct files_str
15410 filp_close(file, files);
15413 + vx_openfd_dec(i);
15421 @@ -554,6 +561,7 @@ void put_fs_struct(struct fs_struct *fs)
15422 if (atomic_dec_and_test(&fs->count)) {
15423 path_put(&fs->root);
15424 path_put(&fs->pwd);
15425 + atomic_dec(&vs_global_fs);
15426 kmem_cache_free(fs_cachep, fs);
15429 @@ -1122,6 +1130,10 @@ NORET_TYPE void do_exit(long code)
15430 if (tsk->splice_pipe)
15431 __free_pipe_info(tsk->splice_pipe);
15433 + /* needs to stay after exit_notify() */
15434 + exit_vx_info(tsk, code);
15435 + exit_nx_info(tsk);
15438 /* causes final put_task_struct in finish_task_switch(). */
15439 tsk->state = TASK_DEAD;
15440 diff -NurpP --minimal linux-2.6.27.6/kernel/fork.c linux-2.6.27.6-vs2.3.0.36/kernel/fork.c
15441 --- linux-2.6.27.6/kernel/fork.c 2008-10-13 14:52:09.000000000 +0200
15442 +++ linux-2.6.27.6-vs2.3.0.36/kernel/fork.c 2008-10-13 14:54:20.000000000 +0200
15444 #include <linux/tty.h>
15445 #include <linux/proc_fs.h>
15446 #include <linux/blkdev.h>
15447 +#include <linux/vs_context.h>
15448 +#include <linux/vs_network.h>
15449 +#include <linux/vs_limit.h>
15450 +#include <linux/vs_memory.h>
15451 +#include <linux/vserver/global.h>
15453 #include <asm/pgtable.h>
15454 #include <asm/pgalloc.h>
15455 @@ -135,6 +140,8 @@ void free_task(struct task_struct *tsk)
15456 prop_local_destroy_single(&tsk->dirties);
15457 free_thread_info(tsk->stack);
15458 rt_mutex_debug_task_free(tsk);
15459 + clr_vx_info(&tsk->vx_info);
15460 + clr_nx_info(&tsk->nx_info);
15461 free_task_struct(tsk);
15463 EXPORT_SYMBOL(free_task);
15464 @@ -274,6 +281,8 @@ static int dup_mmap(struct mm_struct *mm
15465 mm->free_area_cache = oldmm->mmap_base;
15466 mm->cached_hole_size = ~0UL;
15468 + __set_mm_counter(mm, file_rss, 0);
15469 + __set_mm_counter(mm, anon_rss, 0);
15470 cpus_clear(mm->cpu_vm_mask);
15471 mm->mm_rb = RB_ROOT;
15472 rb_link = &mm->mm_rb.rb_node;
15473 @@ -285,7 +294,7 @@ static int dup_mmap(struct mm_struct *mm
15475 if (mpnt->vm_flags & VM_DONTCOPY) {
15476 long pages = vma_pages(mpnt);
15477 - mm->total_vm -= pages;
15478 + vx_vmpages_sub(mm, pages);
15479 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15482 @@ -404,8 +413,8 @@ static struct mm_struct * mm_init(struct
15483 : MMF_DUMP_FILTER_DEFAULT;
15484 mm->core_state = NULL;
15486 - set_mm_counter(mm, file_rss, 0);
15487 - set_mm_counter(mm, anon_rss, 0);
15488 + __set_mm_counter(mm, file_rss, 0);
15489 + __set_mm_counter(mm, anon_rss, 0);
15490 spin_lock_init(&mm->page_table_lock);
15491 rwlock_init(&mm->ioctx_list_lock);
15492 mm->ioctx_list = NULL;
15493 @@ -416,6 +425,7 @@ static struct mm_struct * mm_init(struct
15494 if (likely(!mm_alloc_pgd(mm))) {
15496 mmu_notifier_mm_init(mm);
15497 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15501 @@ -449,6 +459,7 @@ void __mmdrop(struct mm_struct *mm)
15503 destroy_context(mm);
15504 mmu_notifier_mm_destroy(mm);
15505 + clr_vx_info(&mm->mm_vx_info);
15508 EXPORT_SYMBOL_GPL(__mmdrop);
15509 @@ -565,6 +576,7 @@ struct mm_struct *dup_mm(struct task_str
15512 memcpy(mm, oldmm, sizeof(*mm));
15513 + mm->mm_vx_info = NULL;
15515 /* Initializing for Swap token stuff */
15516 mm->token_priority = 0;
15517 @@ -598,6 +610,7 @@ fail_nocontext:
15518 * If init_new_context() failed, we cannot use mmput() to free the mm
15519 * because it calls destroy_context()
15521 + clr_vx_info(&mm->mm_vx_info);
15525 @@ -661,6 +674,7 @@ static struct fs_struct *__copy_fs_struc
15526 fs->pwd = old->pwd;
15527 path_get(&old->pwd);
15528 read_unlock(&old->lock);
15529 + atomic_inc(&vs_global_fs);
15533 @@ -904,6 +918,8 @@ static struct task_struct *copy_process(
15535 struct task_struct *p;
15536 int cgroup_callbacks_done = 0;
15537 + struct vx_info *vxi;
15538 + struct nx_info *nxi;
15540 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15541 return ERR_PTR(-EINVAL);
15542 @@ -938,12 +954,28 @@ static struct task_struct *copy_process(
15543 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15544 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15546 + init_vx_info(&p->vx_info, current->vx_info);
15547 + init_nx_info(&p->nx_info, current->nx_info);
15549 + /* check vserver memory */
15550 + if (p->mm && !(clone_flags & CLONE_VM)) {
15551 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15552 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15554 + goto bad_fork_free;
15556 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15557 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15558 + goto bad_fork_cleanup_vm;
15561 + if (!vx_nproc_avail(1))
15562 + goto bad_fork_cleanup_vm;
15563 if (atomic_read(&p->user->processes) >=
15564 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15565 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15566 p->user != current->nsproxy->user_ns->root_user)
15567 - goto bad_fork_free;
15568 + goto bad_fork_cleanup_vm;
15571 atomic_inc(&p->user->__count);
15572 @@ -1241,6 +1273,18 @@ static struct task_struct *copy_process(
15575 spin_unlock(¤t->sighand->siglock);
15577 + /* p is copy of current */
15578 + vxi = p->vx_info;
15580 + claim_vx_info(vxi, p);
15581 + atomic_inc(&vxi->cvirt.nr_threads);
15582 + atomic_inc(&vxi->cvirt.total_forks);
15585 + nxi = p->nx_info;
15587 + claim_nx_info(nxi, p);
15588 write_unlock_irq(&tasklist_lock);
15589 proc_fork_connector(p);
15590 cgroup_post_fork(p);
15591 @@ -1287,6 +1331,9 @@ bad_fork_cleanup_count:
15592 put_group_info(p->group_info);
15593 atomic_dec(&p->user->processes);
15595 +bad_fork_cleanup_vm:
15596 + if (p->mm && !(clone_flags & CLONE_VM))
15597 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15601 diff -NurpP --minimal linux-2.6.27.6/kernel/kthread.c linux-2.6.27.6-vs2.3.0.36/kernel/kthread.c
15602 --- linux-2.6.27.6/kernel/kthread.c 2008-10-13 14:52:09.000000000 +0200
15603 +++ linux-2.6.27.6-vs2.3.0.36/kernel/kthread.c 2008-10-13 14:54:20.000000000 +0200
15605 #include <linux/file.h>
15606 #include <linux/module.h>
15607 #include <linux/mutex.h>
15608 +#include <linux/vs_pid.h>
15610 #define KTHREAD_NICE_LEVEL (-5)
15612 @@ -98,7 +99,7 @@ static void create_kthread(struct kthrea
15613 struct sched_param param = { .sched_priority = 0 };
15614 wait_for_completion(&create->started);
15615 read_lock(&tasklist_lock);
15616 - create->result = find_task_by_pid_ns(pid, &init_pid_ns);
15617 + create->result = find_task_by_real_pid(pid);
15618 read_unlock(&tasklist_lock);
15620 * root may have changed our (kthreadd's) priority or CPU mask.
15621 diff -NurpP --minimal linux-2.6.27.6/kernel/Makefile linux-2.6.27.6-vs2.3.0.36/kernel/Makefile
15622 --- linux-2.6.27.6/kernel/Makefile 2008-10-13 14:52:09.000000000 +0200
15623 +++ linux-2.6.27.6-vs2.3.0.36/kernel/Makefile 2008-10-13 14:54:20.000000000 +0200
15624 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
15625 CFLAGS_REMOVE_sched.o = -mno-spe -pg
15629 obj-$(CONFIG_PROFILING) += profile.o
15630 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15631 obj-$(CONFIG_STACKTRACE) += stacktrace.o
15632 diff -NurpP --minimal linux-2.6.27.6/kernel/nsproxy.c linux-2.6.27.6-vs2.3.0.36/kernel/nsproxy.c
15633 --- linux-2.6.27.6/kernel/nsproxy.c 2008-10-13 14:52:09.000000000 +0200
15634 +++ linux-2.6.27.6-vs2.3.0.36/kernel/nsproxy.c 2008-10-13 14:54:20.000000000 +0200
15636 #include <linux/mnt_namespace.h>
15637 #include <linux/utsname.h>
15638 #include <linux/pid_namespace.h>
15639 +#include <linux/vserver/global.h>
15640 +#include <linux/vserver/debug.h>
15641 #include <net/net_namespace.h>
15642 #include <linux/ipc_namespace.h>
15644 @@ -37,6 +39,9 @@ static inline struct nsproxy *clone_nspr
15646 memcpy(ns, orig, sizeof(struct nsproxy));
15647 atomic_set(&ns->count, 1);
15648 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
15649 + orig, atomic_read(&orig->count), ns);
15650 + atomic_inc(&vs_global_nsproxy);
15654 @@ -46,47 +51,51 @@ static inline struct nsproxy *clone_nspr
15655 * Return the newly created nsproxy. Do not attach this to the task,
15656 * leave it to the caller to do proper locking and attach it to task.
15658 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15659 - struct task_struct *tsk, struct fs_struct *new_fs)
15660 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15661 + struct nsproxy *orig, struct fs_struct *new_fs)
15663 struct nsproxy *new_nsp;
15666 - new_nsp = clone_nsproxy(tsk->nsproxy);
15667 + vxdprintk(VXD_CBIT(space, 4),
15668 + "unshare_namespaces(0x%08lx,%p,%p)",
15669 + flags, orig, new_fs);
15671 + new_nsp = clone_nsproxy(orig);
15673 return ERR_PTR(-ENOMEM);
15675 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15676 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15677 if (IS_ERR(new_nsp->mnt_ns)) {
15678 err = PTR_ERR(new_nsp->mnt_ns);
15682 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15683 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15684 if (IS_ERR(new_nsp->uts_ns)) {
15685 err = PTR_ERR(new_nsp->uts_ns);
15689 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15690 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15691 if (IS_ERR(new_nsp->ipc_ns)) {
15692 err = PTR_ERR(new_nsp->ipc_ns);
15696 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15697 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15698 if (IS_ERR(new_nsp->pid_ns)) {
15699 err = PTR_ERR(new_nsp->pid_ns);
15703 - new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns);
15704 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15705 if (IS_ERR(new_nsp->user_ns)) {
15706 err = PTR_ERR(new_nsp->user_ns);
15710 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15711 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15712 if (IS_ERR(new_nsp->net_ns)) {
15713 err = PTR_ERR(new_nsp->net_ns);
15715 @@ -114,6 +123,37 @@ out_ns:
15716 return ERR_PTR(err);
15719 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15720 + struct fs_struct *new_fs)
15722 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15726 + * copies the nsproxy, setting refcount to 1, and grabbing a
15727 + * reference to all contained namespaces.
15729 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15731 + struct nsproxy *ns = clone_nsproxy(orig);
15735 + get_mnt_ns(ns->mnt_ns);
15737 + get_uts_ns(ns->uts_ns);
15739 + get_ipc_ns(ns->ipc_ns);
15741 + get_pid_ns(ns->pid_ns);
15743 + get_user_ns(ns->user_ns);
15745 + get_net(ns->net_ns);
15751 * called from clone. This now handles copy for nsproxy and all
15752 * namespaces therein.
15753 @@ -121,9 +161,12 @@ out_ns:
15754 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15756 struct nsproxy *old_ns = tsk->nsproxy;
15757 - struct nsproxy *new_ns;
15758 + struct nsproxy *new_ns = NULL;
15761 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15762 + flags, tsk, old_ns);
15767 @@ -160,6 +203,9 @@ int copy_namespaces(unsigned long flags,
15770 put_nsproxy(old_ns);
15771 + vxdprintk(VXD_CBIT(space, 3),
15772 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15773 + flags, tsk, old_ns, err, new_ns);
15777 @@ -175,7 +221,9 @@ void free_nsproxy(struct nsproxy *ns)
15778 put_pid_ns(ns->pid_ns);
15780 put_user_ns(ns->user_ns);
15781 - put_net(ns->net_ns);
15783 + put_net(ns->net_ns);
15784 + atomic_dec(&vs_global_nsproxy);
15785 kmem_cache_free(nsproxy_cachep, ns);
15788 @@ -188,6 +236,10 @@ int unshare_nsproxy_namespaces(unsigned
15792 + vxdprintk(VXD_CBIT(space, 4),
15793 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15794 + unshare_flags, current->nsproxy);
15796 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15797 CLONE_NEWUSER | CLONE_NEWNET)))
15799 diff -NurpP --minimal linux-2.6.27.6/kernel/pid.c linux-2.6.27.6-vs2.3.0.36/kernel/pid.c
15800 --- linux-2.6.27.6/kernel/pid.c 2008-10-13 14:52:09.000000000 +0200
15801 +++ linux-2.6.27.6-vs2.3.0.36/kernel/pid.c 2008-10-13 14:54:20.000000000 +0200
15803 #include <linux/pid_namespace.h>
15804 #include <linux/init_task.h>
15805 #include <linux/syscalls.h>
15806 +#include <linux/vs_pid.h>
15807 +#include <linux/vserver/global.h>
15809 #define pid_hashfn(nr, ns) \
15810 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15811 @@ -305,7 +307,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15813 struct pid *find_vpid(int nr)
15815 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15816 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15818 EXPORT_SYMBOL_GPL(find_vpid);
15820 @@ -365,6 +367,9 @@ void transfer_pid(struct task_struct *ol
15821 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15823 struct task_struct *result = NULL;
15825 + if (type == PIDTYPE_REALPID)
15826 + type = PIDTYPE_PID;
15828 struct hlist_node *first;
15829 first = rcu_dereference(pid->tasks[type].first);
15830 @@ -388,14 +393,14 @@ EXPORT_SYMBOL(find_task_by_pid_type_ns);
15832 struct task_struct *find_task_by_vpid(pid_t vnr)
15834 - return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
15835 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(vnr),
15836 current->nsproxy->pid_ns);
15838 EXPORT_SYMBOL(find_task_by_vpid);
15840 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15842 - return find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns);
15843 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(nr), ns);
15845 EXPORT_SYMBOL(find_task_by_pid_ns);
15847 @@ -431,7 +436,7 @@ struct pid *find_get_pid(pid_t nr)
15849 EXPORT_SYMBOL_GPL(find_get_pid);
15851 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15852 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15856 @@ -444,6 +449,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15860 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15862 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15865 pid_t pid_vnr(struct pid *pid)
15867 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15868 diff -NurpP --minimal linux-2.6.27.6/kernel/pid_namespace.c linux-2.6.27.6-vs2.3.0.36/kernel/pid_namespace.c
15869 --- linux-2.6.27.6/kernel/pid_namespace.c 2008-10-13 14:52:09.000000000 +0200
15870 +++ linux-2.6.27.6-vs2.3.0.36/kernel/pid_namespace.c 2008-10-13 14:54:20.000000000 +0200
15872 #include <linux/syscalls.h>
15873 #include <linux/err.h>
15874 #include <linux/acct.h>
15875 +#include <linux/vserver/global.h>
15877 #define BITS_PER_PAGE (PAGE_SIZE*8)
15879 @@ -85,6 +86,7 @@ static struct pid_namespace *create_pid_
15882 kref_init(&ns->kref);
15883 + atomic_inc(&vs_global_pid_ns);
15886 set_bit(0, ns->pidmap[0].page);
15887 @@ -109,6 +111,7 @@ static void destroy_pid_namespace(struct
15889 for (i = 0; i < PIDMAP_ENTRIES; i++)
15890 kfree(ns->pidmap[i].page);
15891 + atomic_dec(&vs_global_pid_ns);
15892 kmem_cache_free(pid_ns_cachep, ns);
15895 diff -NurpP --minimal linux-2.6.27.6/kernel/posix-timers.c linux-2.6.27.6-vs2.3.0.36/kernel/posix-timers.c
15896 --- linux-2.6.27.6/kernel/posix-timers.c 2008-10-13 14:52:09.000000000 +0200
15897 +++ linux-2.6.27.6-vs2.3.0.36/kernel/posix-timers.c 2008-10-13 14:54:20.000000000 +0200
15899 #include <linux/wait.h>
15900 #include <linux/workqueue.h>
15901 #include <linux/module.h>
15902 +#include <linux/vs_context.h>
15905 * Management arrays for POSIX timers. Timers are kept in slab memory
15906 @@ -298,6 +299,12 @@ void do_schedule_next_timer(struct sigin
15908 int posix_timer_event(struct k_itimer *timr, int si_private)
15910 + struct vx_info_save vxis;
15911 + struct vx_info *vxi;
15914 + vxi = task_get_vx_info(timr->it_process);
15915 + enter_vx_info(vxi, &vxis);
15917 * FIXME: if ->sigq is queued we can race with
15918 * dequeue_signal()->do_schedule_next_timer().
15919 @@ -318,10 +325,11 @@ int posix_timer_event(struct k_itimer *t
15921 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
15922 struct task_struct *leader;
15923 - int ret = send_sigqueue(timr->sigq, timr->it_process, 0);
15925 + ret = send_sigqueue(timr->sigq, timr->it_process, 0);
15927 if (likely(ret >= 0))
15931 timr->it_sigev_notify = SIGEV_SIGNAL;
15932 leader = timr->it_process->group_leader;
15933 @@ -329,7 +337,11 @@ int posix_timer_event(struct k_itimer *t
15934 timr->it_process = leader;
15937 - return send_sigqueue(timr->sigq, timr->it_process, 1);
15938 + ret = send_sigqueue(timr->sigq, timr->it_process, 1);
15940 + leave_vx_info(&vxis);
15941 + put_vx_info(vxi);
15944 EXPORT_SYMBOL_GPL(posix_timer_event);
15946 diff -NurpP --minimal linux-2.6.27.6/kernel/printk.c linux-2.6.27.6-vs2.3.0.36/kernel/printk.c
15947 --- linux-2.6.27.6/kernel/printk.c 2008-10-13 14:52:09.000000000 +0200
15948 +++ linux-2.6.27.6-vs2.3.0.36/kernel/printk.c 2008-10-13 14:54:20.000000000 +0200
15950 #include <linux/security.h>
15951 #include <linux/bootmem.h>
15952 #include <linux/syscalls.h>
15953 +#include <linux/vs_cvirt.h>
15955 #include <asm/uaccess.h>
15957 @@ -291,18 +292,13 @@ int do_syslog(int type, char __user *buf
15958 unsigned i, j, limit, count;
15964 error = security_syslog(type);
15969 - case 0: /* Close log */
15971 - case 1: /* Open log */
15973 - case 2: /* Read from log */
15974 + if ((type >= 2) && (type <= 4)) {
15976 if (!buf || len < 0)
15978 @@ -313,6 +309,16 @@ int do_syslog(int type, char __user *buf
15983 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15984 + return vx_do_syslog(type, buf, len);
15987 + case 0: /* Close log */
15989 + case 1: /* Open log */
15991 + case 2: /* Read from log */
15992 error = wait_event_interruptible(log_wait,
15993 (log_start - log_end));
15995 @@ -337,16 +343,6 @@ int do_syslog(int type, char __user *buf
15998 case 3: /* Read last kernel messages */
16000 - if (!buf || len < 0)
16005 - if (!access_ok(VERIFY_WRITE, buf, len)) {
16010 if (count > log_buf_len)
16011 count = log_buf_len;
16012 diff -NurpP --minimal linux-2.6.27.6/kernel/ptrace.c linux-2.6.27.6-vs2.3.0.36/kernel/ptrace.c
16013 --- linux-2.6.27.6/kernel/ptrace.c 2008-10-13 14:52:09.000000000 +0200
16014 +++ linux-2.6.27.6-vs2.3.0.36/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
16016 #include <linux/audit.h>
16017 #include <linux/pid_namespace.h>
16018 #include <linux/syscalls.h>
16019 +#include <linux/vs_context.h>
16021 #include <asm/pgtable.h>
16022 #include <asm/uaccess.h>
16023 @@ -139,6 +140,11 @@ int __ptrace_may_access(struct task_stru
16024 dumpable = get_dumpable(task->mm);
16025 if (!dumpable && !capable(CAP_SYS_PTRACE))
16027 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
16029 + if (!vx_check(task->xid, VS_IDENT) &&
16030 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16033 return security_ptrace_may_access(task, mode);
16035 @@ -567,6 +573,10 @@ asmlinkage long sys_ptrace(long request,
16040 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
16041 + goto out_put_task_struct;
16043 if (request == PTRACE_ATTACH) {
16044 ret = ptrace_attach(child);
16046 diff -NurpP --minimal linux-2.6.27.6/kernel/sched.c linux-2.6.27.6-vs2.3.0.36/kernel/sched.c
16047 --- linux-2.6.27.6/kernel/sched.c 2008-10-13 14:52:09.000000000 +0200
16048 +++ linux-2.6.27.6-vs2.3.0.36/kernel/sched.c 2008-10-13 14:54:20.000000000 +0200
16050 #include <linux/debugfs.h>
16051 #include <linux/ctype.h>
16052 #include <linux/ftrace.h>
16053 +#include <linux/vs_sched.h>
16054 +#include <linux/vs_cvirt.h>
16056 #include <asm/tlb.h>
16057 #include <asm/irq_regs.h>
16058 @@ -497,6 +499,16 @@ struct root_domain {
16059 static struct root_domain def_root_domain;
16062 + unsigned long norm_time;
16063 + unsigned long idle_time;
16064 +#ifdef CONFIG_VSERVER_IDLETIME
16067 +#ifdef CONFIG_VSERVER_HARDCPU
16068 + struct list_head hold_queue;
16069 + unsigned long nr_onhold;
16074 * This is the main, per-CPU runqueue data structure.
16075 @@ -1640,6 +1652,7 @@ static void update_avg(u64 *avg, u64 sam
16077 static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup)
16079 + // BUG_ON(p->state & TASK_ONHOLD);
16080 sched_info_queued(p);
16081 p->sched_class->enqueue_task(rq, p, wakeup);
16083 @@ -1837,6 +1850,9 @@ struct migration_req {
16084 struct completion done;
16087 +#include "sched_mon.h"
16091 * The task's runqueue lock must be held.
16092 * Returns true if you have to wait for migration thread.
16093 @@ -1846,6 +1862,7 @@ migrate_task(struct task_struct *p, int
16095 struct rq *rq = task_rq(p);
16097 + vxm_migrate_task(p, rq, dest_cpu);
16099 * If the task is not on a runqueue (and not running), then
16100 * it is sufficient to simply update the task's cpu field.
16101 @@ -2242,6 +2259,12 @@ static int try_to_wake_up(struct task_st
16102 /* might preempt at this point */
16103 rq = task_rq_lock(p, &flags);
16104 old_state = p->state;
16106 + /* we need to unhold suspended tasks
16107 + if (old_state & TASK_ONHOLD) {
16108 + vx_unhold_task(p, rq);
16109 + old_state = p->state;
16111 if (!(old_state & state))
16114 @@ -4067,13 +4090,16 @@ unsigned long long task_sched_runtime(st
16115 void account_user_time(struct task_struct *p, cputime_t cputime)
16117 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16118 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16120 + int nice = (TASK_NICE(p) > 0);
16122 p->utime = cputime_add(p->utime, cputime);
16123 + vx_account_user(vxi, cputime, nice);
16125 /* Add user time to cpustat. */
16126 tmp = cputime_to_cputime64(cputime);
16127 - if (TASK_NICE(p) > 0)
16129 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16131 cpustat->user = cputime64_add(cpustat->user, tmp);
16132 @@ -4120,6 +4146,7 @@ void account_system_time(struct task_str
16135 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16136 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16137 struct rq *rq = this_rq();
16140 @@ -4129,6 +4156,7 @@ void account_system_time(struct task_str
16143 p->stime = cputime_add(p->stime, cputime);
16144 + vx_account_system(vxi, cputime, (p == rq->idle));
16146 /* Add system time to cpustat. */
16147 tmp = cputime_to_cputime64(cputime);
16148 @@ -4963,7 +4991,7 @@ asmlinkage long sys_nice(int increment)
16151 if (increment < 0 && !can_nice(current, nice))
16153 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16155 retval = security_task_setnice(current, nice);
16157 diff -NurpP --minimal linux-2.6.27.6/kernel/sched_fair.c linux-2.6.27.6-vs2.3.0.36/kernel/sched_fair.c
16158 --- linux-2.6.27.6/kernel/sched_fair.c 2008-10-13 14:52:09.000000000 +0200
16159 +++ linux-2.6.27.6-vs2.3.0.36/kernel/sched_fair.c 2008-10-13 14:54:20.000000000 +0200
16160 @@ -724,6 +724,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
16161 check_spread(cfs_rq, se);
16162 if (se != cfs_rq->curr)
16163 __enqueue_entity(cfs_rq, se);
16165 + if (entity_is_task(se))
16166 + vx_activate_task(task_of(se));
16170 @@ -750,6 +753,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
16172 if (se != cfs_rq->curr)
16173 __dequeue_entity(cfs_rq, se);
16174 + if (entity_is_task(se))
16175 + vx_deactivate_task(task_of(se));
16176 account_entity_dequeue(cfs_rq, se);
16179 diff -NurpP --minimal linux-2.6.27.6/kernel/sched_hard.h linux-2.6.27.6-vs2.3.0.36/kernel/sched_hard.h
16180 --- linux-2.6.27.6/kernel/sched_hard.h 1970-01-01 01:00:00.000000000 +0100
16181 +++ linux-2.6.27.6-vs2.3.0.36/kernel/sched_hard.h 2008-10-13 14:54:20.000000000 +0200
16184 +#ifdef CONFIG_VSERVER_IDLELIMIT
16187 + * vx_idle_resched - reschedule after maxidle
16190 +void vx_idle_resched(struct rq *rq)
16192 + /* maybe have a better criterion for paused */
16193 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
16194 + set_need_resched();
16197 +#else /* !CONFIG_VSERVER_IDLELIMIT */
16199 +#define vx_idle_resched(rq)
16201 +#endif /* CONFIG_VSERVER_IDLELIMIT */
16205 +#ifdef CONFIG_VSERVER_IDLETIME
16207 +#define vx_set_rq_min_skip(rq, min) \
16208 + (rq)->idle_skip = (min)
16210 +#define vx_save_min_skip(ret, min, val) \
16211 + __vx_save_min_skip(ret, min, val)
16214 +void __vx_save_min_skip(int ret, int *min, int val)
16218 + if ((*min > val) || !*min)
16223 +int vx_try_skip(struct rq *rq, int cpu)
16225 + /* artificially advance time */
16226 + if (rq->idle_skip > 0) {
16227 + vxdprintk(list_empty(&rq->hold_queue),
16228 + "hold queue empty on cpu %d", cpu);
16229 + rq->idle_time += rq->idle_skip;
16230 + vxm_idle_skip(rq, cpu);
16236 +#else /* !CONFIG_VSERVER_IDLETIME */
16238 +#define vx_set_rq_min_skip(rq, min) \
16239 + ({ int dummy = (min); dummy; })
16241 +#define vx_save_min_skip(ret, min, val)
16244 +int vx_try_skip(struct rq *rq, int cpu)
16249 +#endif /* CONFIG_VSERVER_IDLETIME */
16253 +#ifdef CONFIG_VSERVER_HARDCPU
16255 +#define vx_set_rq_max_idle(rq, max) \
16256 + (rq)->idle_tokens = (max)
16258 +#define vx_save_max_idle(ret, min, val) \
16259 + __vx_save_max_idle(ret, min, val)
16262 +void __vx_save_max_idle(int ret, int *min, int val)
16270 + * vx_hold_task - put a task on the hold queue
16273 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16275 + __deactivate_task(p, rq);
16276 + p->state |= TASK_ONHOLD;
16277 + /* a new one on hold */
16279 + vxm_hold_task(p, rq);
16280 + list_add_tail(&p->run_list, &rq->hold_queue);
16284 + * vx_unhold_task - put a task back to the runqueue
16287 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16289 + list_del(&p->run_list);
16290 + /* one less waiting */
16292 + p->state &= ~TASK_ONHOLD;
16293 + enqueue_task(p, rq->expired);
16294 + inc_nr_running(p, rq);
16295 + vxm_unhold_task(p, rq);
16297 + if (p->static_prio < rq->best_expired_prio)
16298 + rq->best_expired_prio = p->static_prio;
16301 +unsigned long nr_onhold(void)
16303 + unsigned long i, sum = 0;
16305 + for_each_online_cpu(i)
16306 + sum += cpu_rq(i)->nr_onhold;
16314 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
16316 + return sched_pc->tokens;
16320 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
16322 + sched_pc->tokens--;
16326 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16328 + struct vx_info *vxi = p->vx_info;
16330 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
16331 + struct _vx_sched_pc *sched_pc =
16332 + &vx_per_cpu(vxi, sched_pc, cpu);
16335 + /* maybe we can simplify that to decrement
16336 + the token counter unconditional? */
16338 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
16339 + __vx_consume_token(sched_pc);
16341 + /* for tokens > 0, one token was consumed */
16345 + vxm_need_resched(p, slice, cpu);
16346 + return (slice == 0);
16350 +#define vx_set_rq_time(rq, time) do { \
16351 + rq->norm_time = time; \
16356 +void vx_try_unhold(struct rq *rq, int cpu)
16358 + struct vx_info *vxi = NULL;
16359 + struct list_head *l, *n;
16360 + int maxidle = HZ;
16363 + /* nothing to do? what about pause? */
16364 + if (list_empty(&rq->hold_queue))
16367 + list_for_each_safe(l, n, &rq->hold_queue) {
16368 + int ret, delta_min[2];
16369 + struct _vx_sched_pc *sched_pc;
16370 + struct task_struct *p;
16372 + p = list_entry(l, struct task_struct, run_list);
16373 + /* don't bother with same context */
16374 + if (vxi == p->vx_info)
16377 + vxi = p->vx_info;
16378 + /* ignore paused contexts */
16379 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
16382 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16384 + /* recalc tokens */
16385 + vxm_sched_info(sched_pc, vxi, cpu);
16386 + ret = vx_tokens_recalc(sched_pc,
16387 + &rq->norm_time, &rq->idle_time, delta_min);
16388 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16391 + /* we found a runable context */
16392 + vx_unhold_task(p, rq);
16395 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
16396 + vx_save_min_skip(ret, &minskip, delta_min[1]);
16398 + vx_set_rq_max_idle(rq, maxidle);
16399 + vx_set_rq_min_skip(rq, minskip);
16400 + vxm_rq_max_min(rq, cpu);
16405 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16407 + struct vx_info *vxi = next->vx_info;
16408 + struct _vx_sched_pc *sched_pc;
16409 + int delta_min[2];
16415 + flags = vxi->vx_flags;
16417 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
16418 + goto put_on_hold;
16419 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
16422 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16424 + /* update scheduler params */
16425 + if (cpu_isset(cpu, vxi->sched.update)) {
16426 + vx_update_sched_param(&vxi->sched, sched_pc);
16427 + vxm_update_sched(sched_pc, vxi, cpu);
16428 + cpu_clear(cpu, vxi->sched.update);
16431 + vxm_sched_info(sched_pc, vxi, cpu);
16432 + ret = vx_tokens_recalc(sched_pc,
16433 + &rq->norm_time, &rq->idle_time, delta_min);
16434 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16436 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
16439 + if (unlikely(ret < 0)) {
16440 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
16441 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
16442 + vxm_rq_max_min(rq, cpu);
16444 + vx_hold_task(next, rq);
16451 +#else /* CONFIG_VSERVER_HARDCPU */
16454 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16460 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16465 +unsigned long nr_onhold(void)
16472 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16474 + return (slice == 0);
16478 +#define vx_set_rq_time(rq, time)
16481 +void vx_try_unhold(struct rq *rq, int cpu)
16487 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16489 + struct vx_info *vxi = next->vx_info;
16490 + struct _vx_sched_pc *sched_pc;
16491 + int delta_min[2];
16494 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
16497 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16498 + vxm_sched_info(sched_pc, vxi, cpu);
16499 + ret = vx_tokens_recalc(sched_pc,
16500 + &rq->norm_time, &rq->idle_time, delta_min);
16501 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16505 +#endif /* CONFIG_VSERVER_HARDCPU */
16507 diff -NurpP --minimal linux-2.6.27.6/kernel/sched_mon.h linux-2.6.27.6-vs2.3.0.36/kernel/sched_mon.h
16508 --- linux-2.6.27.6/kernel/sched_mon.h 1970-01-01 01:00:00.000000000 +0100
16509 +++ linux-2.6.27.6-vs2.3.0.36/kernel/sched_mon.h 2008-10-13 14:54:20.000000000 +0200
16512 +#include <linux/vserver/monitor.h>
16514 +#ifdef CONFIG_VSERVER_MONITOR
16516 +#ifdef CONFIG_VSERVER_HARDCPU
16517 +#define HARDCPU(x) (x)
16519 +#define HARDCPU(x) (0)
16522 +#ifdef CONFIG_VSERVER_IDLETIME
16523 +#define IDLETIME(x) (x)
16525 +#define IDLETIME(x) (0)
16528 +struct _vx_mon_entry *vxm_advance(int cpu);
16532 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
16534 + entry->type = type;
16535 + entry->xid = xid;
16539 +void __vxm_sync(int cpu)
16541 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16543 + __vxm_basic(entry, 0, VXM_SYNC);
16544 + entry->ev.sec = xtime.tv_sec;
16545 + entry->ev.nsec = xtime.tv_nsec;
16549 +void __vxm_task(struct task_struct *p, int type)
16551 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
16553 + __vxm_basic(entry, p->xid, type);
16554 + entry->ev.tsk.pid = p->pid;
16555 + entry->ev.tsk.state = p->state;
16559 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16561 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16563 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
16564 + entry->sd.tokens = s->tokens;
16565 + entry->sd.norm_time = s->norm_time;
16566 + entry->sd.idle_time = s->idle_time;
16570 +void __vxm_rqinfo1(struct rq *q, int cpu)
16572 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16574 + entry->type = VXM_RQINFO_1;
16575 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
16576 + entry->q1.running = q->nr_running;
16577 + entry->q1.onhold = HARDCPU(q->nr_onhold);
16578 + entry->q1.iowait = atomic_read(&q->nr_iowait);
16579 + entry->q1.uintr = q->nr_uninterruptible;
16580 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
16584 +void __vxm_rqinfo2(struct rq *q, int cpu)
16586 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16588 + entry->type = VXM_RQINFO_2;
16589 + entry->xid = (unsigned long)q & 0xffff;
16590 + entry->q2.norm_time = q->norm_time;
16591 + entry->q2.idle_time = q->idle_time;
16592 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
16596 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16598 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16600 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
16601 + entry->ev.tokens = s->tokens;
16605 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16607 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16609 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
16610 + entry->u1.tokens_max = s->tokens_max;
16611 + entry->u1.fill_rate = s->fill_rate[0];
16612 + entry->u1.interval = s->interval[0];
16616 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16618 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16620 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
16621 + entry->u2.tokens_min = s->tokens_min;
16622 + entry->u2.fill_rate = s->fill_rate[1];
16623 + entry->u2.interval = s->interval[1];
16627 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
16628 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
16629 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
16630 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
16631 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
16634 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
16636 + __vxm_task(p, VXM_MIGRATE);
16637 + __vxm_rqinfo1(rq, task_cpu(p));
16638 + __vxm_rqinfo2(rq, task_cpu(p));
16642 +void vxm_idle_skip(struct rq *rq, int cpu)
16644 + __vxm_rqinfo1(rq, cpu);
16645 + __vxm_rqinfo2(rq, cpu);
16649 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
16654 + __vxm_task(p, VXM_RESCHED);
16658 +void vxm_sync(unsigned long now, int cpu)
16660 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
16661 + (now % CONFIG_VSERVER_MONITOR_SYNC))
16667 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
16670 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
16671 + struct vx_info *vxi, int cpu)
16673 + __vxm_sched(s, vxi, cpu);
16674 + __vxm_rqinfo2(rq, cpu);
16678 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16680 + __vxm_sched(s, vxi, cpu);
16681 + __vxm_update(s, vxi, cpu);
16682 + __vxm_update1(s, vxi, cpu);
16683 + __vxm_update2(s, vxi, cpu);
16687 +void vxm_rq_max_min(struct rq *rq, int cpu)
16689 + __vxm_rqinfo1(rq, cpu);
16690 + __vxm_rqinfo2(rq, cpu);
16693 +#else /* CONFIG_VSERVER_MONITOR */
16695 +#define vxm_activate_task(t,q) do { } while (0)
16696 +#define vxm_activate_idle(t,q) do { } while (0)
16697 +#define vxm_deactivate_task(t,q) do { } while (0)
16698 +#define vxm_hold_task(t,q) do { } while (0)
16699 +#define vxm_unhold_task(t,q) do { } while (0)
16700 +#define vxm_migrate_task(t,q,d) do { } while (0)
16701 +#define vxm_idle_skip(q,c) do { } while (0)
16702 +#define vxm_need_resched(t,s,c) do { } while (0)
16703 +#define vxm_sync(s,c) do { } while (0)
16704 +#define vxm_sched_info(s,v,c) do { } while (0)
16705 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
16706 +#define vxm_update_sched(s,v,c) do { } while (0)
16707 +#define vxm_rq_max_min(q,c) do { } while (0)
16709 +#endif /* CONFIG_VSERVER_MONITOR */
16711 diff -NurpP --minimal linux-2.6.27.6/kernel/signal.c linux-2.6.27.6-vs2.3.0.36/kernel/signal.c
16712 --- linux-2.6.27.6/kernel/signal.c 2008-10-13 14:52:09.000000000 +0200
16713 +++ linux-2.6.27.6-vs2.3.0.36/kernel/signal.c 2008-11-20 15:05:42.000000000 +0100
16715 #include <linux/freezer.h>
16716 #include <linux/pid_namespace.h>
16717 #include <linux/nsproxy.h>
16718 +#include <linux/vs_context.h>
16719 +#include <linux/vs_pid.h>
16721 #include <asm/param.h>
16722 #include <asm/uaccess.h>
16723 @@ -571,6 +573,14 @@ static int check_kill_permission(int sig
16724 if (!valid_signal(sig))
16727 + if ((info != SEND_SIG_NOINFO) &&
16728 + (is_si_special(info) || !SI_FROMUSER(info)))
16731 + vxdprintk(VXD_CBIT(misc, 7),
16732 + "check_kill_permission(%d,%p,%p[#%u,%u])",
16733 + sig, info, t, vx_task_xid(t), t->pid);
16735 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
16738 @@ -595,6 +605,18 @@ static int check_kill_permission(int sig
16743 + if (t->pid == 1 && current->xid)
16747 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
16748 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
16749 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
16750 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
16754 return security_task_kill(t, info, sig, 0);
16757 @@ -1051,7 +1073,7 @@ int kill_pid_info(int sig, struct siginf
16760 p = pid_task(pid, PIDTYPE_PID);
16762 + if (p && vx_check(vx_task_xid(p), VS_WATCH | VS_IDENT)) {
16763 error = group_send_sig_info(sig, info, p);
16764 if (unlikely(error == -ESRCH))
16766 @@ -1089,7 +1111,7 @@ int kill_pid_info_as_uid(int sig, struct
16768 read_lock(&tasklist_lock);
16769 p = pid_task(pid, PIDTYPE_PID);
16771 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
16775 @@ -1141,7 +1163,10 @@ static int kill_something_info(int sig,
16776 struct task_struct * p;
16778 for_each_process(p) {
16779 - if (p->pid > 1 && !same_thread_group(p, current)) {
16780 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
16781 + task_pid_vnr(p) > 1 &&
16782 + !same_thread_group(p, current) &&
16783 + !vx_current_initpid(p->pid)) {
16784 int err = group_send_sig_info(sig, info, p);
16787 @@ -1814,6 +1839,11 @@ relock:
16788 !signal_group_exit(signal))
16791 + /* virtual init is protected against user signals */
16792 + if ((info->si_code == SI_USER) &&
16793 + vx_current_initpid(current->pid))
16796 if (sig_kernel_stop(signr)) {
16798 * The default action is to stop all threads in
16799 diff -NurpP --minimal linux-2.6.27.6/kernel/softirq.c linux-2.6.27.6-vs2.3.0.36/kernel/softirq.c
16800 --- linux-2.6.27.6/kernel/softirq.c 2008-10-13 14:52:09.000000000 +0200
16801 +++ linux-2.6.27.6-vs2.3.0.36/kernel/softirq.c 2008-10-13 14:54:20.000000000 +0200
16803 #include <linux/rcupdate.h>
16804 #include <linux/smp.h>
16805 #include <linux/tick.h>
16806 +#include <linux/vs_context.h>
16808 #include <asm/irq.h>
16810 diff -NurpP --minimal linux-2.6.27.6/kernel/sys.c linux-2.6.27.6-vs2.3.0.36/kernel/sys.c
16811 --- linux-2.6.27.6/kernel/sys.c 2008-10-13 14:52:09.000000000 +0200
16812 +++ linux-2.6.27.6-vs2.3.0.36/kernel/sys.c 2008-10-13 14:54:20.000000000 +0200
16814 #include <linux/syscalls.h>
16815 #include <linux/kprobes.h>
16816 #include <linux/user_namespace.h>
16817 +#include <linux/vs_pid.h>
16819 #include <asm/uaccess.h>
16820 #include <asm/io.h>
16821 @@ -122,7 +123,10 @@ static int set_one_prio(struct task_stru
16824 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
16826 + if (vx_flags(VXF_IGNEG_NICE, 0))
16832 no_nice = security_task_setnice(p, niceval);
16833 @@ -170,6 +174,8 @@ asmlinkage long sys_setpriority(int whic
16835 pgrp = task_pgrp(current);
16836 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16837 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16839 error = set_one_prio(p, niceval, error);
16840 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
16842 @@ -230,6 +236,8 @@ asmlinkage long sys_getpriority(int whic
16844 pgrp = task_pgrp(current);
16845 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16846 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16848 niceval = 20 - task_nice(p);
16849 if (niceval > retval)
16851 @@ -339,6 +347,9 @@ void kernel_power_off(void)
16852 machine_power_off();
16854 EXPORT_SYMBOL_GPL(kernel_power_off);
16856 +long vs_reboot(unsigned int, void __user *);
16859 * Reboot system call: for obvious reasons only root may call it,
16860 * and even root needs to set up some magic numbers in the registers
16861 @@ -369,6 +380,9 @@ asmlinkage long sys_reboot(int magic1, i
16862 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
16863 cmd = LINUX_REBOOT_CMD_HALT;
16865 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16866 + return vs_reboot(cmd, arg);
16870 case LINUX_REBOOT_CMD_RESTART:
16871 @@ -1344,7 +1358,7 @@ asmlinkage long sys_sethostname(char __u
16873 char tmp[__NEW_UTS_LEN];
16875 - if (!capable(CAP_SYS_ADMIN))
16876 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16878 if (len < 0 || len > __NEW_UTS_LEN)
16880 @@ -1389,7 +1403,7 @@ asmlinkage long sys_setdomainname(char _
16882 char tmp[__NEW_UTS_LEN];
16884 - if (!capable(CAP_SYS_ADMIN))
16885 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16887 if (len < 0 || len > __NEW_UTS_LEN)
16889 @@ -1456,7 +1470,7 @@ asmlinkage long sys_setrlimit(unsigned i
16891 old_rlim = current->signal->rlim + resource;
16892 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
16893 - !capable(CAP_SYS_RESOURCE))
16894 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
16896 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
16898 diff -NurpP --minimal linux-2.6.27.6/kernel/sysctl.c linux-2.6.27.6-vs2.3.0.36/kernel/sysctl.c
16899 --- linux-2.6.27.6/kernel/sysctl.c 2008-10-13 14:52:09.000000000 +0200
16900 +++ linux-2.6.27.6-vs2.3.0.36/kernel/sysctl.c 2008-10-13 14:54:20.000000000 +0200
16901 @@ -114,6 +114,7 @@ static int ngroups_max = NGROUPS_MAX;
16902 #ifdef CONFIG_MODULES
16903 extern char modprobe_path[];
16905 +extern char vshelper_path[];
16906 #ifdef CONFIG_CHR_DEV_SG
16907 extern int sg_big_buff;
16909 @@ -500,6 +501,15 @@ static struct ctl_table kern_table[] = {
16910 .strategy = &sysctl_string,
16914 + .ctl_name = KERN_VSHELPER,
16915 + .procname = "vshelper",
16916 + .data = &vshelper_path,
16919 + .proc_handler = &proc_dostring,
16920 + .strategy = &sysctl_string,
16922 #ifdef CONFIG_CHR_DEV_SG
16924 .ctl_name = KERN_SG_BIG_BUFF,
16925 diff -NurpP --minimal linux-2.6.27.6/kernel/sysctl_check.c linux-2.6.27.6-vs2.3.0.36/kernel/sysctl_check.c
16926 --- linux-2.6.27.6/kernel/sysctl_check.c 2008-10-13 14:52:09.000000000 +0200
16927 +++ linux-2.6.27.6-vs2.3.0.36/kernel/sysctl_check.c 2008-10-13 14:54:20.000000000 +0200
16928 @@ -39,6 +39,7 @@ static const struct trans_ctl_table tran
16930 { KERN_PANIC, "panic" },
16931 { KERN_REALROOTDEV, "real-root-dev" },
16932 + { KERN_VSHELPER, "vshelper", },
16934 { KERN_SPARC_REBOOT, "reboot-cmd" },
16935 { KERN_CTLALTDEL, "ctrl-alt-del" },
16936 @@ -1217,6 +1218,22 @@ static const struct trans_ctl_table tran
16940 +static struct trans_ctl_table trans_vserver_table[] = {
16941 + { 1, "debug_switch" },
16942 + { 2, "debug_xid" },
16943 + { 3, "debug_nid" },
16944 + { 4, "debug_tag" },
16945 + { 5, "debug_net" },
16946 + { 6, "debug_limit" },
16947 + { 7, "debug_cres" },
16948 + { 8, "debug_dlim" },
16949 + { 9, "debug_quota" },
16950 + { 10, "debug_cvirt" },
16951 + { 11, "debug_space" },
16952 + { 12, "debug_misc" },
16956 static const struct trans_ctl_table trans_root_table[] = {
16957 { CTL_KERN, "kernel", trans_kern_table },
16958 { CTL_VM, "vm", trans_vm_table },
16959 @@ -1233,6 +1250,7 @@ static const struct trans_ctl_table tran
16960 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
16961 { CTL_PM, "pm", trans_pm_table },
16962 { CTL_FRV, "frv", trans_frv_table },
16963 + { CTL_VSERVER, "vserver", trans_vserver_table },
16967 diff -NurpP --minimal linux-2.6.27.6/kernel/time.c linux-2.6.27.6-vs2.3.0.36/kernel/time.c
16968 --- linux-2.6.27.6/kernel/time.c 2008-07-13 23:51:29.000000000 +0200
16969 +++ linux-2.6.27.6-vs2.3.0.36/kernel/time.c 2008-10-13 14:54:20.000000000 +0200
16970 @@ -62,6 +62,7 @@ EXPORT_SYMBOL(sys_tz);
16971 asmlinkage long sys_time(time_t __user * tloc)
16973 time_t i = get_seconds();
16974 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
16977 if (put_user(i,tloc))
16978 @@ -91,7 +92,7 @@ asmlinkage long sys_stime(time_t __user
16982 - do_settimeofday(&tv);
16983 + vx_settimeofday(&tv);
16987 @@ -102,7 +103,7 @@ asmlinkage long sys_gettimeofday(struct
16989 if (likely(tv != NULL)) {
16990 struct timeval ktv;
16991 - do_gettimeofday(&ktv);
16992 + vx_gettimeofday(&ktv);
16993 if (copy_to_user(tv, &ktv, sizeof(ktv)))
16996 @@ -177,7 +178,7 @@ int do_sys_settimeofday(struct timespec
16997 /* SMP safe, again the code in arch/foo/time.c should
16998 * globally block out interrupts when it runs.
17000 - return do_settimeofday(tv);
17001 + return vx_settimeofday(tv);
17005 @@ -309,7 +310,7 @@ void getnstimeofday(struct timespec *tv)
17009 - do_gettimeofday(&x);
17010 + vx_gettimeofday(&x);
17011 tv->tv_sec = x.tv_sec;
17012 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17014 diff -NurpP --minimal linux-2.6.27.6/kernel/timer.c linux-2.6.27.6-vs2.3.0.36/kernel/timer.c
17015 --- linux-2.6.27.6/kernel/timer.c 2008-10-13 14:52:09.000000000 +0200
17016 +++ linux-2.6.27.6-vs2.3.0.36/kernel/timer.c 2008-10-13 14:54:20.000000000 +0200
17018 #include <linux/delay.h>
17019 #include <linux/tick.h>
17020 #include <linux/kallsyms.h>
17021 +#include <linux/vs_base.h>
17022 +#include <linux/vs_cvirt.h>
17023 +#include <linux/vs_pid.h>
17024 +#include <linux/vserver/sched.h>
17026 #include <asm/uaccess.h>
17027 #include <asm/unistd.h>
17028 @@ -1081,12 +1085,6 @@ asmlinkage unsigned long sys_alarm(unsig
17035 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17036 - * should be moved into arch/i386 instead?
17040 * sys_getpid - return the thread group id of the current process
17041 @@ -1115,10 +1113,23 @@ asmlinkage long sys_getppid(void)
17043 pid = task_tgid_vnr(current->real_parent);
17045 + return vx_map_pid(pid);
17052 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17055 +asmlinkage long do_getxpid(long *ppid)
17057 + *ppid = sys_getppid();
17058 + return sys_getpid();
17061 +#else /* _alpha_ */
17063 asmlinkage long sys_getuid(void)
17065 /* Only we change this so SMP safe */
17066 @@ -1289,6 +1300,8 @@ int do_sysinfo(struct sysinfo *info)
17067 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
17070 + if (vx_flags(VXF_VIRT_UPTIME, 0))
17071 + vx_vsi_uptime(&tp, NULL);
17072 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
17074 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
17075 diff -NurpP --minimal linux-2.6.27.6/kernel/user.c linux-2.6.27.6-vs2.3.0.36/kernel/user.c
17076 --- linux-2.6.27.6/kernel/user.c 2008-07-13 23:51:29.000000000 +0200
17077 +++ linux-2.6.27.6-vs2.3.0.36/kernel/user.c 2008-10-13 14:54:20.000000000 +0200
17078 @@ -243,12 +243,15 @@ static struct kobj_type uids_ktype = {
17081 /* create /sys/kernel/uids/<uid>/cpu_share file for this user */
17082 -static int uids_user_create(struct user_struct *up)
17083 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
17085 struct kobject *kobj = &up->kobj;
17089 memset(kobj, 0, sizeof(struct kobject));
17090 + if (ns != &init_user_ns)
17093 kobj->kset = uids_kset;
17094 error = kobject_init_and_add(kobj, &uids_ktype, NULL, "%d", up->uid);
17096 @@ -272,7 +275,7 @@ int __init uids_sysfs_init(void)
17100 - return uids_user_create(&root_user);
17101 + return uids_user_create(NULL, &root_user);
17104 /* work function to remove sysfs directory for a user and free up
17105 @@ -302,9 +305,11 @@ static void remove_user_sysfs_dir(struct
17109 - kobject_uevent(&up->kobj, KOBJ_REMOVE);
17110 - kobject_del(&up->kobj);
17111 - kobject_put(&up->kobj);
17112 + if (up->kobj.name) {
17113 + kobject_uevent(&up->kobj, KOBJ_REMOVE);
17114 + kobject_del(&up->kobj);
17115 + kobject_put(&up->kobj);
17118 sched_destroy_user(up);
17119 key_put(up->uid_keyring);
17120 @@ -332,7 +337,8 @@ static inline void free_user(struct user
17121 #else /* CONFIG_USER_SCHED && CONFIG_SYSFS */
17123 int uids_sysfs_init(void) { return 0; }
17124 -static inline int uids_user_create(struct user_struct *up) { return 0; }
17125 +static inline int uids_user_create(struct user_namespace *ns,
17126 + struct user_struct *up) { return 0; }
17127 static inline void uids_mutex_lock(void) { }
17128 static inline void uids_mutex_unlock(void) { }
17130 @@ -409,7 +415,7 @@ struct user_struct *alloc_uid(struct use
17131 if (sched_create_user(new) < 0)
17132 goto out_free_user;
17134 - if (uids_user_create(new))
17135 + if (uids_user_create(ns, new))
17136 goto out_destoy_sched;
17139 diff -NurpP --minimal linux-2.6.27.6/kernel/user_namespace.c linux-2.6.27.6-vs2.3.0.36/kernel/user_namespace.c
17140 --- linux-2.6.27.6/kernel/user_namespace.c 2008-10-13 14:52:09.000000000 +0200
17141 +++ linux-2.6.27.6-vs2.3.0.36/kernel/user_namespace.c 2008-10-13 14:54:20.000000000 +0200
17143 #include <linux/nsproxy.h>
17144 #include <linux/slab.h>
17145 #include <linux/user_namespace.h>
17146 +#include <linux/vserver/global.h>
17149 * Clone a new ns copying an original user ns, setting refcount to 1
17150 @@ -26,6 +27,7 @@ static struct user_namespace *clone_user
17151 return ERR_PTR(-ENOMEM);
17153 kref_init(&ns->kref);
17154 + atomic_inc(&vs_global_user_ns);
17156 for (n = 0; n < UIDHASH_SZ; ++n)
17157 INIT_HLIST_HEAD(ns->uidhash_table + n);
17158 @@ -71,6 +73,7 @@ void free_user_ns(struct kref *kref)
17160 ns = container_of(kref, struct user_namespace, kref);
17162 + atomic_dec(&vs_global_user_ns);
17165 EXPORT_SYMBOL(free_user_ns);
17166 diff -NurpP --minimal linux-2.6.27.6/kernel/utsname.c linux-2.6.27.6-vs2.3.0.36/kernel/utsname.c
17167 --- linux-2.6.27.6/kernel/utsname.c 2008-10-13 14:52:09.000000000 +0200
17168 +++ linux-2.6.27.6-vs2.3.0.36/kernel/utsname.c 2008-10-13 14:54:20.000000000 +0200
17170 #include <linux/utsname.h>
17171 #include <linux/err.h>
17172 #include <linux/slab.h>
17173 +#include <linux/vserver/global.h>
17176 * Clone a new ns copying an original utsname, setting refcount to 1
17177 @@ -32,6 +33,7 @@ static struct uts_namespace *clone_uts_n
17178 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
17180 kref_init(&ns->kref);
17181 + atomic_inc(&vs_global_uts_ns);
17185 @@ -62,5 +64,6 @@ void free_uts_ns(struct kref *kref)
17186 struct uts_namespace *ns;
17188 ns = container_of(kref, struct uts_namespace, kref);
17189 + atomic_dec(&vs_global_uts_ns);
17192 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/cacct.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cacct.c
17193 --- linux-2.6.27.6/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17194 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cacct.c 2008-10-13 14:54:20.000000000 +0200
17197 + * linux/kernel/vserver/cacct.c
17199 + * Virtual Server: Context Accounting
17201 + * Copyright (C) 2006-2007 Herbert Pötzl
17203 + * V0.01 added accounting stats
17207 +#include <linux/types.h>
17208 +#include <linux/vs_context.h>
17209 +#include <linux/vserver/cacct_cmd.h>
17210 +#include <linux/vserver/cacct_int.h>
17212 +#include <asm/errno.h>
17213 +#include <asm/uaccess.h>
17216 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17218 + struct vcmd_sock_stat_v0 vc_data;
17221 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17224 + field = vc_data.field;
17225 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17228 + for (j = 0; j < 3; j++) {
17229 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17230 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17233 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17238 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/cacct_init.h linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cacct_init.h
17239 --- linux-2.6.27.6/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
17240 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cacct_init.h 2008-10-13 14:54:20.000000000 +0200
17244 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17249 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17250 + for (j = 0; j < 3; j++) {
17251 + atomic_set(&cacct->sock[i][j].count, 0);
17252 + atomic_set(&cacct->sock[i][j].total, 0);
17255 + for (i = 0; i < 8; i++)
17256 + atomic_set(&cacct->slab[i], 0);
17257 + for (i = 0; i < 5; i++)
17258 + for (j = 0; j < 4; j++)
17259 + atomic_set(&cacct->page[i][j], 0);
17262 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17267 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/cacct_proc.h linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cacct_proc.h
17268 --- linux-2.6.27.6/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17269 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cacct_proc.h 2008-10-13 14:54:20.000000000 +0200
17271 +#ifndef _VX_CACCT_PROC_H
17272 +#define _VX_CACCT_PROC_H
17274 +#include <linux/vserver/cacct_int.h>
17277 +#define VX_SOCKA_TOP \
17278 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17280 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17282 + int i, j, length = 0;
17283 + static char *type[VXA_SOCK_SIZE] = {
17284 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17287 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17288 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17289 + length += sprintf(buffer + length, "%s:", type[i]);
17290 + for (j = 0; j < 3; j++) {
17291 + length += sprintf(buffer + length,
17292 + "\t%10lu/%-10lu",
17293 + vx_sock_count(cacct, i, j),
17294 + vx_sock_total(cacct, i, j));
17296 + buffer[length++] = '\n';
17299 + length += sprintf(buffer + length, "\n");
17300 + length += sprintf(buffer + length,
17301 + "slab:\t %8u %8u %8u %8u\n",
17302 + atomic_read(&cacct->slab[1]),
17303 + atomic_read(&cacct->slab[4]),
17304 + atomic_read(&cacct->slab[0]),
17305 + atomic_read(&cacct->slab[2]));
17307 + length += sprintf(buffer + length, "\n");
17308 + for (i = 0; i < 5; i++) {
17309 + length += sprintf(buffer + length,
17310 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17311 + atomic_read(&cacct->page[i][0]),
17312 + atomic_read(&cacct->page[i][1]),
17313 + atomic_read(&cacct->page[i][2]),
17314 + atomic_read(&cacct->page[i][3]),
17315 + atomic_read(&cacct->page[i][4]),
17316 + atomic_read(&cacct->page[i][5]),
17317 + atomic_read(&cacct->page[i][6]),
17318 + atomic_read(&cacct->page[i][7]));
17323 +#endif /* _VX_CACCT_PROC_H */
17324 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/context.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/context.c
17325 --- linux-2.6.27.6/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17326 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/context.c 2008-10-31 03:56:55.000000000 +0100
17329 + * linux/kernel/vserver/context.c
17331 + * Virtual Server: Context Support
17333 + * Copyright (C) 2003-2007 Herbert Pötzl
17335 + * V0.01 context helper
17336 + * V0.02 vx_ctx_kill syscall command
17337 + * V0.03 replaced context_info calls
17338 + * V0.04 redesign of struct (de)alloc
17339 + * V0.05 rlimit basic implementation
17340 + * V0.06 task_xid and info commands
17341 + * V0.07 context flags and caps
17342 + * V0.08 switch to RCU based hash
17343 + * V0.09 revert to non RCU for now
17344 + * V0.10 and back to working RCU hash
17345 + * V0.11 and back to locking again
17346 + * V0.12 referenced context store
17347 + * V0.13 separate per cpu data
17348 + * V0.14 changed vcmds to vxi arg
17349 + * V0.15 added context stat
17350 + * V0.16 have __create claim() the vxi
17351 + * V0.17 removed older and legacy stuff
17355 +#include <linux/slab.h>
17356 +#include <linux/types.h>
17357 +#include <linux/security.h>
17358 +#include <linux/pid_namespace.h>
17360 +#include <linux/vserver/context.h>
17361 +#include <linux/vserver/network.h>
17362 +#include <linux/vserver/debug.h>
17363 +#include <linux/vserver/limit.h>
17364 +#include <linux/vserver/limit_int.h>
17365 +#include <linux/vserver/space.h>
17367 +#include <linux/vs_context.h>
17368 +#include <linux/vs_limit.h>
17369 +#include <linux/vs_pid.h>
17370 +#include <linux/vserver/context_cmd.h>
17372 +#include "cvirt_init.h"
17373 +#include "cacct_init.h"
17374 +#include "limit_init.h"
17375 +#include "sched_init.h"
17378 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17379 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17382 +/* now inactive context structures */
17384 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17386 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17389 +/* __alloc_vx_info()
17391 + * allocate an initialized vx_info struct
17392 + * doesn't make it visible (hash) */
17394 +static struct vx_info *__alloc_vx_info(xid_t xid)
17396 + struct vx_info *new = NULL;
17399 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17401 + /* would this benefit from a slab cache? */
17402 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17406 + memset(new, 0, sizeof(struct vx_info));
17408 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17409 + if (!new->ptr_pc)
17412 + new->vx_id = xid;
17413 + INIT_HLIST_NODE(&new->vx_hlist);
17414 + atomic_set(&new->vx_usecnt, 0);
17415 + atomic_set(&new->vx_tasks, 0);
17416 + new->vx_parent = NULL;
17417 + new->vx_state = 0;
17418 + init_waitqueue_head(&new->vx_wait);
17420 + /* prepare reaper */
17421 + get_task_struct(init_pid_ns.child_reaper);
17422 + new->vx_reaper = init_pid_ns.child_reaper;
17423 + new->vx_badness_bias = 0;
17425 + /* rest of init goes here */
17426 + vx_info_init_limit(&new->limit);
17427 + vx_info_init_sched(&new->sched);
17428 + vx_info_init_cvirt(&new->cvirt);
17429 + vx_info_init_cacct(&new->cacct);
17431 + /* per cpu data structures */
17432 + for_each_possible_cpu(cpu) {
17433 + vx_info_init_sched_pc(
17434 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17435 + vx_info_init_cvirt_pc(
17436 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17439 + new->vx_flags = VXF_INIT_SET;
17440 + cap_set_init_eff(new->vx_bcaps);
17441 + new->vx_ccaps = 0;
17442 + // new->vx_cap_bset = current->cap_bset;
17444 + new->reboot_cmd = 0;
17445 + new->exit_code = 0;
17447 + vxdprintk(VXD_CBIT(xid, 0),
17448 + "alloc_vx_info(%d) = %p", xid, new);
17449 + vxh_alloc_vx_info(new);
17450 + atomic_inc(&vx_global_ctotal);
17459 +/* __dealloc_vx_info()
17461 + * final disposal of vx_info */
17463 +static void __dealloc_vx_info(struct vx_info *vxi)
17465 + struct vx_info_save vxis;
17468 + vxdprintk(VXD_CBIT(xid, 0),
17469 + "dealloc_vx_info(%p)", vxi);
17470 + vxh_dealloc_vx_info(vxi);
17472 +#ifdef CONFIG_VSERVER_WARN
17473 + enter_vx_info(vxi, &vxis);
17474 + vx_info_exit_limit(&vxi->limit);
17475 + vx_info_exit_sched(&vxi->sched);
17476 + vx_info_exit_cvirt(&vxi->cvirt);
17477 + vx_info_exit_cacct(&vxi->cacct);
17479 + for_each_possible_cpu(cpu) {
17480 + vx_info_exit_sched_pc(
17481 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17482 + vx_info_exit_cvirt_pc(
17483 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17485 + leave_vx_info(&vxis);
17489 + vxi->vx_state |= VXS_RELEASED;
17492 + free_percpu(vxi->ptr_pc);
17495 + atomic_dec(&vx_global_ctotal);
17498 +static void __shutdown_vx_info(struct vx_info *vxi)
17500 + struct nsproxy *nsproxy;
17501 + struct fs_struct *fs;
17506 + vxi->vx_state |= VXS_SHUTDOWN;
17507 + vs_state_change(vxi, VSC_SHUTDOWN);
17509 + for (index = 0; index < VX_SPACES; index++) {
17510 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17512 + put_nsproxy(nsproxy);
17514 + fs = xchg(&vxi->vx_fs[index], NULL);
17516 + put_fs_struct(fs);
17520 +/* exported stuff */
17522 +void free_vx_info(struct vx_info *vxi)
17524 + unsigned long flags;
17527 + /* check for reference counts first */
17528 + BUG_ON(atomic_read(&vxi->vx_usecnt));
17529 + BUG_ON(atomic_read(&vxi->vx_tasks));
17531 + /* context must not be hashed */
17532 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17534 + /* context shutdown is mandatory */
17535 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17537 + /* nsproxy and fs check */
17538 + for (index = 0; index < VX_SPACES; index++) {
17539 + BUG_ON(vxi->vx_nsproxy[index]);
17540 + BUG_ON(vxi->vx_fs[index]);
17543 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17544 + hlist_del(&vxi->vx_hlist);
17545 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17547 + __dealloc_vx_info(vxi);
17551 +/* hash table for vx_info hash */
17553 +#define VX_HASH_SIZE 13
17555 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17556 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17558 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17561 +static inline unsigned int __hashval(xid_t xid)
17563 + return (xid % VX_HASH_SIZE);
17568 +/* __hash_vx_info()
17570 + * add the vxi to the global hash table
17571 + * requires the hash_lock to be held */
17573 +static inline void __hash_vx_info(struct vx_info *vxi)
17575 + struct hlist_head *head;
17577 + vxd_assert_lock(&vx_info_hash_lock);
17578 + vxdprintk(VXD_CBIT(xid, 4),
17579 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17580 + vxh_hash_vx_info(vxi);
17582 + /* context must not be hashed */
17583 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17585 + vxi->vx_state |= VXS_HASHED;
17586 + head = &vx_info_hash[__hashval(vxi->vx_id)];
17587 + hlist_add_head(&vxi->vx_hlist, head);
17588 + atomic_inc(&vx_global_cactive);
17591 +/* __unhash_vx_info()
17593 + * remove the vxi from the global hash table
17594 + * requires the hash_lock to be held */
17596 +static inline void __unhash_vx_info(struct vx_info *vxi)
17598 + unsigned long flags;
17600 + vxd_assert_lock(&vx_info_hash_lock);
17601 + vxdprintk(VXD_CBIT(xid, 4),
17602 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17603 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17604 + vxh_unhash_vx_info(vxi);
17606 + /* context must be hashed */
17607 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17608 + /* but without tasks */
17609 + BUG_ON(atomic_read(&vxi->vx_tasks));
17611 + vxi->vx_state &= ~VXS_HASHED;
17612 + hlist_del_init(&vxi->vx_hlist);
17613 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17614 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17615 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17616 + atomic_dec(&vx_global_cactive);
17620 +/* __lookup_vx_info()
17622 + * requires the hash_lock to be held
17623 + * doesn't increment the vx_refcnt */
17625 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17627 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17628 + struct hlist_node *pos;
17629 + struct vx_info *vxi;
17631 + vxd_assert_lock(&vx_info_hash_lock);
17632 + hlist_for_each(pos, head) {
17633 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17635 + if (vxi->vx_id == xid)
17640 + vxdprintk(VXD_CBIT(xid, 0),
17641 + "__lookup_vx_info(#%u): %p[#%u]",
17642 + xid, vxi, vxi ? vxi->vx_id : 0);
17643 + vxh_lookup_vx_info(vxi, xid);
17648 +/* __create_vx_info()
17650 + * create the requested context
17651 + * get(), claim() and hash it */
17653 +static struct vx_info *__create_vx_info(int id)
17655 + struct vx_info *new, *vxi = NULL;
17657 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17659 + if (!(new = __alloc_vx_info(id)))
17660 + return ERR_PTR(-ENOMEM);
17662 + /* required to make dynamic xids unique */
17663 + spin_lock(&vx_info_hash_lock);
17665 + /* static context requested */
17666 + if ((vxi = __lookup_vx_info(id))) {
17667 + vxdprintk(VXD_CBIT(xid, 0),
17668 + "create_vx_info(%d) = %p (already there)", id, vxi);
17669 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17670 + vxi = ERR_PTR(-EBUSY);
17672 + vxi = ERR_PTR(-EEXIST);
17675 + /* new context */
17676 + vxdprintk(VXD_CBIT(xid, 0),
17677 + "create_vx_info(%d) = %p (new)", id, new);
17678 + claim_vx_info(new, NULL);
17679 + __hash_vx_info(get_vx_info(new));
17680 + vxi = new, new = NULL;
17683 + spin_unlock(&vx_info_hash_lock);
17684 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
17686 + __dealloc_vx_info(new);
17691 +/* exported stuff */
17694 +void unhash_vx_info(struct vx_info *vxi)
17696 + __shutdown_vx_info(vxi);
17697 + spin_lock(&vx_info_hash_lock);
17698 + __unhash_vx_info(vxi);
17699 + spin_unlock(&vx_info_hash_lock);
17700 + __wakeup_vx_info(vxi);
17704 +/* lookup_vx_info()
17706 + * search for a vx_info and get() it
17707 + * negative id means current */
17709 +struct vx_info *lookup_vx_info(int id)
17711 + struct vx_info *vxi = NULL;
17714 + vxi = get_vx_info(current->vx_info);
17715 + } else if (id > 1) {
17716 + spin_lock(&vx_info_hash_lock);
17717 + vxi = get_vx_info(__lookup_vx_info(id));
17718 + spin_unlock(&vx_info_hash_lock);
17723 +/* xid_is_hashed()
17725 + * verify that xid is still hashed */
17727 +int xid_is_hashed(xid_t xid)
17731 + spin_lock(&vx_info_hash_lock);
17732 + hashed = (__lookup_vx_info(xid) != NULL);
17733 + spin_unlock(&vx_info_hash_lock);
17737 +#ifdef CONFIG_PROC_FS
17741 + * get a subset of hashed xids for proc
17742 + * assumes size is at least one */
17744 +int get_xid_list(int index, unsigned int *xids, int size)
17746 + int hindex, nr_xids = 0;
17748 + /* only show current and children */
17749 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
17752 + xids[nr_xids] = vx_current_xid();
17756 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
17757 + struct hlist_head *head = &vx_info_hash[hindex];
17758 + struct hlist_node *pos;
17760 + spin_lock(&vx_info_hash_lock);
17761 + hlist_for_each(pos, head) {
17762 + struct vx_info *vxi;
17767 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17768 + xids[nr_xids] = vxi->vx_id;
17769 + if (++nr_xids >= size) {
17770 + spin_unlock(&vx_info_hash_lock);
17774 + /* keep the lock time short */
17775 + spin_unlock(&vx_info_hash_lock);
17782 +#ifdef CONFIG_VSERVER_DEBUG
17784 +void dump_vx_info_inactive(int level)
17786 + struct hlist_node *entry, *next;
17788 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
17789 + struct vx_info *vxi =
17790 + list_entry(entry, struct vx_info, vx_hlist);
17792 + dump_vx_info(vxi, level);
17799 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
17801 + struct user_struct *new_user, *old_user;
17806 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
17809 + new_user = alloc_uid(vxi->vx_id, p->uid);
17813 + old_user = p->user;
17814 + if (new_user != old_user) {
17815 + atomic_inc(&new_user->processes);
17816 + atomic_dec(&old_user->processes);
17817 + p->user = new_user;
17819 + free_uid(old_user);
17825 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
17827 + // p->cap_effective &= vxi->vx_cap_bset;
17828 + p->cap_effective =
17829 + cap_intersect(p->cap_effective, vxi->cap_bset);
17830 + // p->cap_inheritable &= vxi->vx_cap_bset;
17831 + p->cap_inheritable =
17832 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
17833 + // p->cap_permitted &= vxi->vx_cap_bset;
17834 + p->cap_permitted =
17835 + cap_intersect(p->cap_permitted, vxi->cap_bset);
17840 +#include <linux/file.h>
17841 +#include <linux/fdtable.h>
17843 +static int vx_openfd_task(struct task_struct *tsk)
17845 + struct files_struct *files = tsk->files;
17846 + struct fdtable *fdt;
17847 + const unsigned long *bptr;
17848 + int count, total;
17850 + /* no rcu_read_lock() because of spin_lock() */
17851 + spin_lock(&files->file_lock);
17852 + fdt = files_fdtable(files);
17853 + bptr = fdt->open_fds->fds_bits;
17854 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
17855 + for (total = 0; count > 0; count--) {
17857 + total += hweight_long(*bptr);
17860 + spin_unlock(&files->file_lock);
17865 +/* for *space compatibility */
17867 +asmlinkage long sys_unshare(unsigned long);
17870 + * migrate task to new context
17871 + * gets vxi, puts old_vxi on change
17872 + * optionally unshares namespaces (hack)
17875 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
17877 + struct vx_info *old_vxi;
17883 + vxdprintk(VXD_CBIT(xid, 5),
17884 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
17885 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
17887 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
17888 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17891 + if (vx_info_state(vxi, VXS_SHUTDOWN))
17894 + old_vxi = task_get_vx_info(p);
17895 + if (old_vxi == vxi)
17898 +// if (!(ret = vx_migrate_user(p, vxi))) {
17903 + openfd = vx_openfd_task(p);
17906 + atomic_dec(&old_vxi->cvirt.nr_threads);
17907 + atomic_dec(&old_vxi->cvirt.nr_running);
17908 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
17909 + /* FIXME: what about the struct files here? */
17910 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
17911 + /* account for the executable */
17912 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
17914 + atomic_inc(&vxi->cvirt.nr_threads);
17915 + atomic_inc(&vxi->cvirt.nr_running);
17916 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
17917 + /* FIXME: what about the struct files here? */
17918 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
17919 + /* account for the executable */
17920 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
17923 + release_vx_info(old_vxi, p);
17924 + clr_vx_info(&p->vx_info);
17926 + claim_vx_info(vxi, p);
17927 + set_vx_info(&p->vx_info, vxi);
17928 + p->xid = vxi->vx_id;
17930 + vxdprintk(VXD_CBIT(xid, 5),
17931 + "moved task %p into vxi:%p[#%d]",
17932 + p, vxi, vxi->vx_id);
17934 + // vx_mask_cap_bset(vxi, p);
17937 + /* hack for *spaces to provide compatibility */
17939 + struct nsproxy *old_nsp, *new_nsp;
17941 + ret = unshare_nsproxy_namespaces(
17942 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
17947 + old_nsp = xchg(&p->nsproxy, new_nsp);
17948 + vx_set_space(vxi,
17949 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
17950 + put_nsproxy(old_nsp);
17954 + put_vx_info(old_vxi);
17958 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
17960 + struct task_struct *old_reaper;
17965 + vxdprintk(VXD_CBIT(xid, 6),
17966 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
17967 + vxi, vxi->vx_id, p, p->xid, p->pid);
17969 + old_reaper = vxi->vx_reaper;
17970 + if (old_reaper == p)
17973 + /* set new child reaper */
17974 + get_task_struct(p);
17975 + vxi->vx_reaper = p;
17976 + put_task_struct(old_reaper);
17980 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
17985 + vxdprintk(VXD_CBIT(xid, 6),
17986 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
17987 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17989 + vxi->vx_flags &= ~VXF_STATE_INIT;
17990 + vxi->vx_initpid = p->tgid;
17994 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
17996 + vxdprintk(VXD_CBIT(xid, 6),
17997 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
17998 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18000 + vxi->exit_code = code;
18001 + vxi->vx_initpid = 0;
18005 +void vx_set_persistent(struct vx_info *vxi)
18007 + vxdprintk(VXD_CBIT(xid, 6),
18008 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18010 + get_vx_info(vxi);
18011 + claim_vx_info(vxi, NULL);
18014 +void vx_clear_persistent(struct vx_info *vxi)
18016 + vxdprintk(VXD_CBIT(xid, 6),
18017 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18019 + release_vx_info(vxi, NULL);
18020 + put_vx_info(vxi);
18023 +void vx_update_persistent(struct vx_info *vxi)
18025 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18026 + vx_set_persistent(vxi);
18028 + vx_clear_persistent(vxi);
18032 +/* task must be current or locked */
18034 +void exit_vx_info(struct task_struct *p, int code)
18036 + struct vx_info *vxi = p->vx_info;
18039 + atomic_dec(&vxi->cvirt.nr_threads);
18042 + vxi->exit_code = code;
18043 + release_vx_info(vxi, p);
18047 +void exit_vx_info_early(struct task_struct *p, int code)
18049 + struct vx_info *vxi = p->vx_info;
18052 + if (vxi->vx_initpid == p->tgid)
18053 + vx_exit_init(vxi, p, code);
18054 + if (vxi->vx_reaper == p)
18055 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18060 +/* vserver syscall commands below here */
18062 +/* taks xid and vx_info functions */
18064 +#include <asm/uaccess.h>
18067 +int vc_task_xid(uint32_t id)
18072 + struct task_struct *tsk;
18074 + read_lock(&tasklist_lock);
18075 + tsk = find_task_by_real_pid(id);
18076 + xid = (tsk) ? tsk->xid : -ESRCH;
18077 + read_unlock(&tasklist_lock);
18079 + xid = vx_current_xid();
18084 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18086 + struct vcmd_vx_info_v0 vc_data;
18088 + vc_data.xid = vxi->vx_id;
18089 + vc_data.initpid = vxi->vx_initpid;
18091 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18097 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18099 + struct vcmd_ctx_stat_v0 vc_data;
18101 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18102 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18104 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18110 +/* context functions */
18112 +int vc_ctx_create(uint32_t xid, void __user *data)
18114 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18115 + struct vx_info *new_vxi;
18118 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18121 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
18124 + new_vxi = __create_vx_info(xid);
18125 + if (IS_ERR(new_vxi))
18126 + return PTR_ERR(new_vxi);
18128 + /* initial flags */
18129 + new_vxi->vx_flags = vc_data.flagword;
18132 + if (vs_state_change(new_vxi, VSC_STARTUP))
18135 + ret = vx_migrate_task(current, new_vxi, (!data));
18139 + /* return context id on success */
18140 + ret = new_vxi->vx_id;
18142 + /* get a reference for persistent contexts */
18143 + if ((vc_data.flagword & VXF_PERSISTENT))
18144 + vx_set_persistent(new_vxi);
18146 + release_vx_info(new_vxi, NULL);
18147 + put_vx_info(new_vxi);
18152 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18154 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18157 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18160 + ret = vx_migrate_task(current, vxi, 0);
18163 + if (vc_data.flagword & VXM_SET_INIT)
18164 + ret = vx_set_init(vxi, current);
18167 + if (vc_data.flagword & VXM_SET_REAPER)
18168 + ret = vx_set_reaper(vxi, current);
18173 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18175 + struct vcmd_ctx_flags_v0 vc_data;
18177 + vc_data.flagword = vxi->vx_flags;
18179 + /* special STATE flag handling */
18180 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18182 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18187 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18189 + struct vcmd_ctx_flags_v0 vc_data;
18190 + uint64_t mask, trigger;
18192 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18195 + /* special STATE flag handling */
18196 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18197 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18199 + if (vxi == current->vx_info) {
18200 + /* if (trigger & VXF_STATE_SETUP)
18201 + vx_mask_cap_bset(vxi, current); */
18202 + if (trigger & VXF_STATE_INIT) {
18205 + ret = vx_set_init(vxi, current);
18208 + ret = vx_set_reaper(vxi, current);
18214 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18215 + vc_data.flagword, mask);
18216 + if (trigger & VXF_PERSISTENT)
18217 + vx_update_persistent(vxi);
18223 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18225 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18227 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18231 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18233 + kernel_cap_t c = __cap_empty_set;
18235 + c.cap[0] = v & 0xFFFFFFFF;
18236 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18238 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18243 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18246 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18248 + *ccaps = vxi->vx_ccaps;
18253 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18255 + struct vcmd_ctx_caps_v1 vc_data;
18258 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18261 + vc_data.cmask = ~0ULL;
18263 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18268 +static int do_set_caps(struct vx_info *vxi,
18269 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18271 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18274 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18275 + bcaps, bmask, ccaps, cmask);
18277 + vxi->vx_bcaps = cap_t_from_caps(
18278 + vs_mask_flags(bcold, bcaps, bmask));
18279 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18284 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18286 + struct vcmd_ctx_caps_v1 vc_data;
18288 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18291 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18294 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18296 + struct vcmd_bcaps vc_data;
18299 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18302 + vc_data.bmask = ~0ULL;
18304 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18309 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18311 + struct vcmd_bcaps vc_data;
18313 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18316 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18320 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18322 + struct vcmd_badness_v0 vc_data;
18324 + vc_data.bias = vxi->vx_badness_bias;
18326 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18331 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18333 + struct vcmd_badness_v0 vc_data;
18335 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18338 + vxi->vx_badness_bias = vc_data.bias;
18342 +#include <linux/module.h>
18344 +EXPORT_SYMBOL_GPL(free_vx_info);
18346 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/cvirt.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cvirt.c
18347 --- linux-2.6.27.6/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18348 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cvirt.c 2008-10-31 03:49:36.000000000 +0100
18351 + * linux/kernel/vserver/cvirt.c
18353 + * Virtual Server: Context Virtualization
18355 + * Copyright (C) 2004-2007 Herbert Pötzl
18357 + * V0.01 broken out from limit.c
18358 + * V0.02 added utsname stuff
18359 + * V0.03 changed vcmds to vxi arg
18363 +#include <linux/types.h>
18364 +#include <linux/utsname.h>
18365 +#include <linux/vs_cvirt.h>
18366 +#include <linux/vserver/switch.h>
18367 +#include <linux/vserver/cvirt_cmd.h>
18369 +#include <asm/uaccess.h>
18372 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18374 + struct vx_info *vxi = current->vx_info;
18376 + set_normalized_timespec(uptime,
18377 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18378 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18381 + set_normalized_timespec(idle,
18382 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18383 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18387 +uint64_t vx_idle_jiffies(void)
18389 + return init_task.utime + init_task.stime;
18394 +static inline uint32_t __update_loadavg(uint32_t load,
18395 + int wsize, int delta, int n)
18397 + unsigned long long calc, prev;
18399 + /* just set it to n */
18400 + if (unlikely(delta >= wsize))
18401 + return (n << FSHIFT);
18403 + calc = delta * n;
18405 + prev = (wsize - delta);
18408 + do_div(calc, wsize);
18413 +void vx_update_load(struct vx_info *vxi)
18415 + uint32_t now, last, delta;
18416 + unsigned int nr_running, nr_uninterruptible;
18417 + unsigned int total;
18418 + unsigned long flags;
18420 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18423 + last = vxi->cvirt.load_last;
18424 + delta = now - last;
18426 + if (delta < 5*HZ)
18429 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18430 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18431 + total = nr_running + nr_uninterruptible;
18433 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18434 + 60*HZ, delta, total);
18435 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18436 + 5*60*HZ, delta, total);
18437 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18438 + 15*60*HZ, delta, total);
18440 + vxi->cvirt.load_last = now;
18442 + atomic_inc(&vxi->cvirt.load_updates);
18443 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18448 + * Commands to do_syslog:
18450 + * 0 -- Close the log. Currently a NOP.
18451 + * 1 -- Open the log. Currently a NOP.
18452 + * 2 -- Read from the log.
18453 + * 3 -- Read all messages remaining in the ring buffer.
18454 + * 4 -- Read and clear all messages remaining in the ring buffer
18455 + * 5 -- Clear ring buffer.
18456 + * 6 -- Disable printk's to console
18457 + * 7 -- Enable printk's to console
18458 + * 8 -- Set level of messages printed to console
18459 + * 9 -- Return number of unread characters in the log buffer
18460 + * 10 -- Return size of the log buffer
18462 +int vx_do_syslog(int type, char __user *buf, int len)
18465 + int do_clear = 0;
18466 + struct vx_info *vxi = current->vx_info;
18467 + struct _vx_syslog *log;
18471 + log = &vxi->cvirt.syslog;
18474 + case 0: /* Close log */
18475 + case 1: /* Open log */
18477 + case 2: /* Read from log */
18478 + error = wait_event_interruptible(log->log_wait,
18479 + (log->log_start - log->log_end));
18482 + spin_lock_irq(&log->logbuf_lock);
18483 + spin_unlock_irq(&log->logbuf_lock);
18485 + case 4: /* Read/clear last kernel messages */
18487 + /* fall through */
18488 + case 3: /* Read last kernel messages */
18491 + case 5: /* Clear ring buffer */
18494 + case 6: /* Disable logging to console */
18495 + case 7: /* Enable logging to console */
18496 + case 8: /* Set level of messages printed to console */
18499 + case 9: /* Number of chars in the log buffer */
18501 + case 10: /* Size of the log buffer */
18511 +/* virtual host info names */
18513 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18515 + struct nsproxy *nsproxy;
18516 + struct uts_namespace *uts;
18518 + if (id == VHIN_CONTEXT)
18519 + return vxi->vx_name;
18521 + nsproxy = vxi->vx_nsproxy[0];
18525 + uts = nsproxy->uts_ns;
18530 + case VHIN_SYSNAME:
18531 + return uts->name.sysname;
18532 + case VHIN_NODENAME:
18533 + return uts->name.nodename;
18534 + case VHIN_RELEASE:
18535 + return uts->name.release;
18536 + case VHIN_VERSION:
18537 + return uts->name.version;
18538 + case VHIN_MACHINE:
18539 + return uts->name.machine;
18540 + case VHIN_DOMAINNAME:
18541 + return uts->name.domainname;
18548 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18550 + struct vcmd_vhi_name_v0 vc_data;
18553 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18556 + name = vx_vhi_name(vxi, vc_data.field);
18560 + memcpy(name, vc_data.name, 65);
18564 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18566 + struct vcmd_vhi_name_v0 vc_data;
18569 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18572 + name = vx_vhi_name(vxi, vc_data.field);
18576 + memcpy(vc_data.name, name, 65);
18577 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18583 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18585 + struct vcmd_virt_stat_v0 vc_data;
18586 + struct _vx_cvirt *cvirt = &vxi->cvirt;
18587 + struct timespec uptime;
18589 + do_posix_clock_monotonic_gettime(&uptime);
18590 + set_normalized_timespec(&uptime,
18591 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18592 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18594 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18595 + vc_data.uptime = timespec_to_ns(&uptime);
18596 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18597 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
18598 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18599 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18600 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18601 + vc_data.load[0] = cvirt->load[0];
18602 + vc_data.load[1] = cvirt->load[1];
18603 + vc_data.load[2] = cvirt->load[2];
18605 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18611 +#ifdef CONFIG_VSERVER_VTIME
18613 +/* virtualized time base */
18615 +void vx_gettimeofday(struct timeval *tv)
18617 + do_gettimeofday(tv);
18618 + if (!vx_flags(VXF_VIRT_TIME, 0))
18621 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
18622 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
18624 + if (tv->tv_usec >= USEC_PER_SEC) {
18626 + tv->tv_usec -= USEC_PER_SEC;
18627 + } else if (tv->tv_usec < 0) {
18629 + tv->tv_usec += USEC_PER_SEC;
18633 +int vx_settimeofday(struct timespec *ts)
18635 + struct timeval tv;
18637 + if (!vx_flags(VXF_VIRT_TIME, 0))
18638 + return do_settimeofday(ts);
18640 + do_gettimeofday(&tv);
18641 + current->vx_info->cvirt.bias_tv.tv_sec =
18642 + ts->tv_sec - tv.tv_sec;
18643 + current->vx_info->cvirt.bias_tv.tv_usec =
18644 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
18650 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/cvirt_init.h linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cvirt_init.h
18651 --- linux-2.6.27.6/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
18652 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cvirt_init.h 2008-10-13 14:54:20.000000000 +0200
18656 +extern uint64_t vx_idle_jiffies(void);
18658 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
18660 + uint64_t idle_jiffies = vx_idle_jiffies();
18661 + uint64_t nsuptime;
18663 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
18664 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
18665 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
18666 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
18667 + cvirt->bias_tv.tv_sec = 0;
18668 + cvirt->bias_tv.tv_usec = 0;
18670 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
18671 + atomic_set(&cvirt->nr_threads, 0);
18672 + atomic_set(&cvirt->nr_running, 0);
18673 + atomic_set(&cvirt->nr_uninterruptible, 0);
18674 + atomic_set(&cvirt->nr_onhold, 0);
18676 + spin_lock_init(&cvirt->load_lock);
18677 + cvirt->load_last = jiffies;
18678 + atomic_set(&cvirt->load_updates, 0);
18679 + cvirt->load[0] = 0;
18680 + cvirt->load[1] = 0;
18681 + cvirt->load[2] = 0;
18682 + atomic_set(&cvirt->total_forks, 0);
18684 + spin_lock_init(&cvirt->syslog.logbuf_lock);
18685 + init_waitqueue_head(&cvirt->syslog.log_wait);
18686 + cvirt->syslog.log_start = 0;
18687 + cvirt->syslog.log_end = 0;
18688 + cvirt->syslog.con_start = 0;
18689 + cvirt->syslog.logged_chars = 0;
18693 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18695 + // cvirt_pc->cpustat = { 0 };
18698 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
18702 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
18703 + "!!! cvirt: %p[nr_threads] = %d on exit.",
18705 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
18706 + "!!! cvirt: %p[nr_running] = %d on exit.",
18708 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
18709 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
18711 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
18712 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
18718 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18723 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/cvirt_proc.h linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cvirt_proc.h
18724 --- linux-2.6.27.6/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
18725 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/cvirt_proc.h 2008-10-13 14:54:20.000000000 +0200
18727 +#ifndef _VX_CVIRT_PROC_H
18728 +#define _VX_CVIRT_PROC_H
18730 +#include <linux/nsproxy.h>
18731 +#include <linux/mnt_namespace.h>
18732 +#include <linux/ipc_namespace.h>
18733 +#include <linux/utsname.h>
18734 +#include <linux/ipc.h>
18738 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
18740 + struct mnt_namespace *ns;
18741 + struct uts_namespace *uts;
18742 + struct ipc_namespace *ipc;
18743 + struct path path;
18744 + char *pstr, *root;
18750 + length += sprintf(buffer + length,
18751 + "NSProxy:\t%p [%p,%p,%p]\n",
18752 + nsproxy, nsproxy->mnt_ns,
18753 + nsproxy->uts_ns, nsproxy->ipc_ns);
18755 + ns = nsproxy->mnt_ns;
18759 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
18763 + path.mnt = ns->root;
18764 + path.dentry = ns->root->mnt_root;
18765 + root = d_path(&path, pstr, PATH_MAX - 2);
18766 + length += sprintf(buffer + length,
18767 + "Namespace:\t%p [#%u]\n"
18768 + "RootPath:\t%s\n",
18769 + ns, atomic_read(&ns->count),
18774 + uts = nsproxy->uts_ns;
18778 + length += sprintf(buffer + length,
18779 + "SysName:\t%.*s\n"
18780 + "NodeName:\t%.*s\n"
18781 + "Release:\t%.*s\n"
18782 + "Version:\t%.*s\n"
18783 + "Machine:\t%.*s\n"
18784 + "DomainName:\t%.*s\n",
18785 + __NEW_UTS_LEN, uts->name.sysname,
18786 + __NEW_UTS_LEN, uts->name.nodename,
18787 + __NEW_UTS_LEN, uts->name.release,
18788 + __NEW_UTS_LEN, uts->name.version,
18789 + __NEW_UTS_LEN, uts->name.machine,
18790 + __NEW_UTS_LEN, uts->name.domainname);
18793 + ipc = nsproxy->ipc_ns;
18797 + length += sprintf(buffer + length,
18798 + "SEMS:\t\t%d %d %d %d %d\n"
18799 + "MSG:\t\t%d %d %d\n"
18800 + "SHM:\t\t%lu %lu %d %d\n",
18801 + ipc->sem_ctls[0], ipc->sem_ctls[1],
18802 + ipc->sem_ctls[2], ipc->sem_ctls[3],
18804 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
18805 + (unsigned long)ipc->shm_ctlmax,
18806 + (unsigned long)ipc->shm_ctlall,
18807 + ipc->shm_ctlmni, ipc->shm_tot);
18814 +#include <linux/sched.h>
18816 +#define LOAD_INT(x) ((x) >> FSHIFT)
18817 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
18820 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
18825 + length += sprintf(buffer + length,
18826 + "BiasUptime:\t%lu.%02lu\n",
18827 + (unsigned long)cvirt->bias_uptime.tv_sec,
18828 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
18830 + a = cvirt->load[0] + (FIXED_1 / 200);
18831 + b = cvirt->load[1] + (FIXED_1 / 200);
18832 + c = cvirt->load[2] + (FIXED_1 / 200);
18833 + length += sprintf(buffer + length,
18834 + "nr_threads:\t%d\n"
18835 + "nr_running:\t%d\n"
18836 + "nr_unintr:\t%d\n"
18837 + "nr_onhold:\t%d\n"
18838 + "load_updates:\t%d\n"
18839 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
18840 + "total_forks:\t%d\n",
18841 + atomic_read(&cvirt->nr_threads),
18842 + atomic_read(&cvirt->nr_running),
18843 + atomic_read(&cvirt->nr_uninterruptible),
18844 + atomic_read(&cvirt->nr_onhold),
18845 + atomic_read(&cvirt->load_updates),
18846 + LOAD_INT(a), LOAD_FRAC(a),
18847 + LOAD_INT(b), LOAD_FRAC(b),
18848 + LOAD_INT(c), LOAD_FRAC(c),
18849 + atomic_read(&cvirt->total_forks));
18854 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
18855 + char *buffer, int cpu)
18861 +#endif /* _VX_CVIRT_PROC_H */
18862 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/debug.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/debug.c
18863 --- linux-2.6.27.6/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
18864 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/debug.c 2008-10-13 14:54:20.000000000 +0200
18867 + * kernel/vserver/debug.c
18869 + * Copyright (C) 2005-2007 Herbert Pötzl
18871 + * V0.01 vx_info dump support
18875 +#include <linux/module.h>
18877 +#include <linux/vserver/context.h>
18880 +void dump_vx_info(struct vx_info *vxi, int level)
18882 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
18883 + atomic_read(&vxi->vx_usecnt),
18884 + atomic_read(&vxi->vx_tasks),
18887 + __dump_vx_limit(&vxi->limit);
18888 + __dump_vx_sched(&vxi->sched);
18889 + __dump_vx_cvirt(&vxi->cvirt);
18890 + __dump_vx_cacct(&vxi->cacct);
18896 +EXPORT_SYMBOL_GPL(dump_vx_info);
18898 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/device.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/device.c
18899 --- linux-2.6.27.6/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
18900 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/device.c 2008-10-13 14:54:20.000000000 +0200
18903 + * linux/kernel/vserver/device.c
18905 + * Linux-VServer: Device Support
18907 + * Copyright (C) 2006 Herbert Pötzl
18908 + * Copyright (C) 2007 Daniel Hokka Zakrisson
18910 + * V0.01 device mapping basics
18911 + * V0.02 added defaults
18915 +#include <linux/slab.h>
18916 +#include <linux/rcupdate.h>
18917 +#include <linux/fs.h>
18918 +#include <linux/namei.h>
18919 +#include <linux/hash.h>
18921 +#include <asm/errno.h>
18922 +#include <asm/uaccess.h>
18923 +#include <linux/vserver/base.h>
18924 +#include <linux/vserver/debug.h>
18925 +#include <linux/vserver/context.h>
18926 +#include <linux/vserver/device.h>
18927 +#include <linux/vserver/device_cmd.h>
18930 +#define DMAP_HASH_BITS 4
18933 +struct vs_mapping {
18935 + struct hlist_node hlist;
18936 + struct list_head list;
18938 +#define dm_hlist u.hlist
18939 +#define dm_list u.list
18942 + struct vx_dmap_target target;
18946 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
18948 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
18950 +static struct vx_dmap_target dmap_defaults[2] = {
18951 + { .flags = DATTR_OPEN },
18952 + { .flags = DATTR_OPEN },
18956 +struct kmem_cache *dmap_cachep __read_mostly;
18958 +int __init dmap_cache_init(void)
18960 + dmap_cachep = kmem_cache_create("dmap_cache",
18961 + sizeof(struct vs_mapping), 0,
18962 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
18966 +__initcall(dmap_cache_init);
18969 +static inline unsigned int __hashval(dev_t dev, int bits)
18971 + return hash_long((unsigned long)dev, bits);
18975 +/* __hash_mapping()
18976 + * add the mapping to the hash table
18978 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
18980 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18981 + struct hlist_head *head, *hash = dmap_main_hash;
18982 + int device = vdm->device;
18984 + spin_lock(hash_lock);
18985 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
18986 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
18988 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
18989 + hlist_add_head(&vdm->dm_hlist, head);
18990 + spin_unlock(hash_lock);
18994 +static inline int __mode_to_default(umode_t mode)
19007 +/* __set_default()
19010 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19011 + struct vx_dmap_target *vdmt)
19013 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19014 + spin_lock(hash_lock);
19017 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19019 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
19022 + spin_unlock(hash_lock);
19024 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19025 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19029 +/* __remove_default()
19030 + * remove a default
19032 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19034 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19035 + spin_lock(hash_lock);
19038 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19039 + else /* remove == reset */
19040 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19042 + spin_unlock(hash_lock);
19047 +/* __find_mapping()
19048 + * find a mapping in the hash table
19050 + * caller must hold hash_lock
19052 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19053 + struct vs_mapping **local, struct vs_mapping **global)
19055 + struct hlist_head *hash = dmap_main_hash;
19056 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19057 + struct hlist_node *pos;
19058 + struct vs_mapping *vdm;
19064 + hlist_for_each(pos, head) {
19065 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19067 + if ((vdm->device == device) &&
19068 + !((vdm->target.flags ^ mode) & S_IFMT)) {
19069 + if (vdm->xid == xid) {
19072 + } else if (global && vdm->xid == 0)
19077 + if (global && *global)
19084 +/* __lookup_mapping()
19085 + * find a mapping and store the result in target and flags
19087 +static inline int __lookup_mapping(struct vx_info *vxi,
19088 + dev_t device, dev_t *target, int *flags, umode_t mode)
19090 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19091 + struct vs_mapping *vdm, *global;
19092 + struct vx_dmap_target *vdmt;
19094 + xid_t xid = vxi->vx_id;
19097 + spin_lock(hash_lock);
19098 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19100 + vdmt = &vdm->target;
19104 + index = __mode_to_default(mode);
19105 + if (vxi && vxi->dmap.targets[index].flags) {
19107 + vdmt = &vxi->dmap.targets[index];
19108 + } else if (global) {
19110 + vdmt = &global->target;
19114 + vdmt = &dmap_defaults[index];
19118 + if (target && (vdmt->flags & DATTR_REMAP))
19119 + *target = vdmt->target;
19121 + *target = device;
19123 + *flags = vdmt->flags;
19125 + spin_unlock(hash_lock);
19131 +/* __remove_mapping()
19132 + * remove a mapping from the hash table
19134 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19137 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19138 + struct vs_mapping *vdm = NULL;
19141 + spin_lock(hash_lock);
19143 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19145 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19146 + vxi, vxi ? vxi->vx_id : 0, device, mode);
19149 + hlist_del(&vdm->dm_hlist);
19152 + spin_unlock(hash_lock);
19154 + kmem_cache_free(dmap_cachep, vdm);
19160 +int vs_map_device(struct vx_info *vxi,
19161 + dev_t device, dev_t *target, umode_t mode)
19163 + int ret, flags = DATTR_MASK;
19167 + *target = device;
19170 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
19171 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19172 + device, target ? *target : 0, flags, mode, ret);
19174 + return (flags & DATTR_MASK);
19179 +static int do_set_mapping(struct vx_info *vxi,
19180 + dev_t device, dev_t target, int flags, umode_t mode)
19183 + struct vs_mapping *new;
19185 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19189 + INIT_HLIST_NODE(&new->dm_hlist);
19190 + new->device = device;
19191 + new->target.target = target;
19192 + new->target.flags = flags | mode;
19193 + new->xid = (vxi ? vxi->vx_id : 0);
19195 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19196 + __hash_mapping(vxi, new);
19198 + struct vx_dmap_target new = {
19199 + .target = target,
19200 + .flags = flags | mode,
19202 + __set_default(vxi, mode, &new);
19208 +static int do_unset_mapping(struct vx_info *vxi,
19209 + dev_t device, dev_t target, int flags, umode_t mode)
19211 + int ret = -EINVAL;
19214 + ret = __remove_mapping(vxi, device, mode);
19218 + ret = __remove_default(vxi, mode);
19228 +static inline int __user_device(const char __user *name, dev_t *dev,
19231 + struct nameidata nd;
19238 + ret = user_lpath(name, &nd.path);
19241 + if (nd.path.dentry->d_inode) {
19242 + *dev = nd.path.dentry->d_inode->i_rdev;
19243 + *mode = nd.path.dentry->d_inode->i_mode;
19245 + path_put(&nd.path);
19249 +static inline int __mapping_mode(dev_t device, dev_t target,
19250 + umode_t device_mode, umode_t target_mode, umode_t *mode)
19253 + *mode = device_mode & S_IFMT;
19255 + *mode = target_mode & S_IFMT;
19259 + /* if both given, device and target mode have to match */
19260 + if (device && target &&
19261 + ((device_mode ^ target_mode) & S_IFMT))
19267 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19268 + const char __user *target_path, int flags, int set)
19270 + dev_t device = ~0, target = ~0;
19271 + umode_t device_mode = 0, target_mode = 0, mode;
19274 + ret = __user_device(device_path, &device, &device_mode);
19277 + ret = __user_device(target_path, &target, &target_mode);
19281 + ret = __mapping_mode(device, target,
19282 + device_mode, target_mode, &mode);
19287 + return do_set_mapping(vxi, device, target,
19290 + return do_unset_mapping(vxi, device, target,
19295 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19297 + struct vcmd_set_mapping_v0 vc_data;
19299 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19302 + return do_mapping(vxi, vc_data.device, vc_data.target,
19303 + vc_data.flags, 1);
19306 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19308 + struct vcmd_set_mapping_v0 vc_data;
19310 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19313 + return do_mapping(vxi, vc_data.device, vc_data.target,
19314 + vc_data.flags, 0);
19318 +#ifdef CONFIG_COMPAT
19320 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19322 + struct vcmd_set_mapping_v0_x32 vc_data;
19324 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19327 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19328 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19331 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19333 + struct vcmd_set_mapping_v0_x32 vc_data;
19335 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19338 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19339 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19342 +#endif /* CONFIG_COMPAT */
19345 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/dlimit.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/dlimit.c
19346 --- linux-2.6.27.6/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19347 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/dlimit.c 2008-10-13 14:54:20.000000000 +0200
19350 + * linux/kernel/vserver/dlimit.c
19352 + * Virtual Server: Context Disk Limits
19354 + * Copyright (C) 2004-2007 Herbert Pötzl
19356 + * V0.01 initial version
19357 + * V0.02 compat32 splitup
19361 +#include <linux/statfs.h>
19362 +#include <linux/sched.h>
19363 +#include <linux/namei.h>
19364 +#include <linux/vs_tag.h>
19365 +#include <linux/vs_dlimit.h>
19366 +#include <linux/vserver/dlimit_cmd.h>
19368 +#include <asm/uaccess.h>
19370 +/* __alloc_dl_info()
19372 + * allocate an initialized dl_info struct
19373 + * doesn't make it visible (hash) */
19375 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19377 + struct dl_info *new = NULL;
19379 + vxdprintk(VXD_CBIT(dlim, 5),
19380 + "alloc_dl_info(%p,%d)*", sb, tag);
19382 + /* would this benefit from a slab cache? */
19383 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19387 + memset(new, 0, sizeof(struct dl_info));
19388 + new->dl_tag = tag;
19390 + INIT_RCU_HEAD(&new->dl_rcu);
19391 + INIT_HLIST_NODE(&new->dl_hlist);
19392 + spin_lock_init(&new->dl_lock);
19393 + atomic_set(&new->dl_refcnt, 0);
19394 + atomic_set(&new->dl_usecnt, 0);
19396 + /* rest of init goes here */
19398 + vxdprintk(VXD_CBIT(dlim, 4),
19399 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19403 +/* __dealloc_dl_info()
19405 + * final disposal of dl_info */
19407 +static void __dealloc_dl_info(struct dl_info *dli)
19409 + vxdprintk(VXD_CBIT(dlim, 4),
19410 + "dealloc_dl_info(%p)", dli);
19412 + dli->dl_hlist.next = LIST_POISON1;
19413 + dli->dl_tag = -1;
19416 + BUG_ON(atomic_read(&dli->dl_usecnt));
19417 + BUG_ON(atomic_read(&dli->dl_refcnt));
19423 +/* hash table for dl_info hash */
19425 +#define DL_HASH_SIZE 13
19427 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19429 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19432 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19434 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19439 +/* __hash_dl_info()
19441 + * add the dli to the global hash table
19442 + * requires the hash_lock to be held */
19444 +static inline void __hash_dl_info(struct dl_info *dli)
19446 + struct hlist_head *head;
19448 + vxdprintk(VXD_CBIT(dlim, 6),
19449 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19450 + get_dl_info(dli);
19451 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19452 + hlist_add_head_rcu(&dli->dl_hlist, head);
19455 +/* __unhash_dl_info()
19457 + * remove the dli from the global hash table
19458 + * requires the hash_lock to be held */
19460 +static inline void __unhash_dl_info(struct dl_info *dli)
19462 + vxdprintk(VXD_CBIT(dlim, 6),
19463 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19464 + hlist_del_rcu(&dli->dl_hlist);
19465 + put_dl_info(dli);
19469 +/* __lookup_dl_info()
19471 + * requires the rcu_read_lock()
19472 + * doesn't increment the dl_refcnt */
19474 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19476 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19477 + struct hlist_node *pos;
19478 + struct dl_info *dli;
19480 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19482 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19490 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19492 + struct dl_info *dli;
19495 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19496 + vxdprintk(VXD_CBIT(dlim, 7),
19497 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19498 + rcu_read_unlock();
19502 +void rcu_free_dl_info(struct rcu_head *head)
19504 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19505 + int usecnt, refcnt;
19507 + BUG_ON(!dli || !head);
19509 + usecnt = atomic_read(&dli->dl_usecnt);
19510 + BUG_ON(usecnt < 0);
19512 + refcnt = atomic_read(&dli->dl_refcnt);
19513 + BUG_ON(refcnt < 0);
19515 + vxdprintk(VXD_CBIT(dlim, 3),
19516 + "rcu_free_dl_info(%p)", dli);
19518 + __dealloc_dl_info(dli);
19520 + printk("!!! rcu didn't free\n");
19526 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19527 + uint32_t flags, int add)
19529 + struct path path;
19532 + ret = user_lpath(name, &path);
19534 + struct super_block *sb;
19535 + struct dl_info *dli;
19538 + if (!path.dentry->d_inode)
19539 + goto out_release;
19540 + if (!(sb = path.dentry->d_inode->i_sb))
19541 + goto out_release;
19544 + dli = __alloc_dl_info(sb, id);
19545 + spin_lock(&dl_info_hash_lock);
19548 + if (__lookup_dl_info(sb, id))
19550 + __hash_dl_info(dli);
19553 + spin_lock(&dl_info_hash_lock);
19554 + dli = __lookup_dl_info(sb, id);
19559 + __unhash_dl_info(dli);
19563 + spin_unlock(&dl_info_hash_lock);
19565 + __dealloc_dl_info(dli);
19572 +int vc_add_dlimit(uint32_t id, void __user *data)
19574 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19576 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19579 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19582 +int vc_rem_dlimit(uint32_t id, void __user *data)
19584 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19586 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19589 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19592 +#ifdef CONFIG_COMPAT
19594 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19596 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19598 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19601 + return do_addrem_dlimit(id,
19602 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19605 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19607 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19609 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19612 + return do_addrem_dlimit(id,
19613 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19616 +#endif /* CONFIG_COMPAT */
19620 +int do_set_dlimit(uint32_t id, const char __user *name,
19621 + uint32_t space_used, uint32_t space_total,
19622 + uint32_t inodes_used, uint32_t inodes_total,
19623 + uint32_t reserved, uint32_t flags)
19625 + struct path path;
19628 + ret = user_lpath(name, &path);
19630 + struct super_block *sb;
19631 + struct dl_info *dli;
19634 + if (!path.dentry->d_inode)
19635 + goto out_release;
19636 + if (!(sb = path.dentry->d_inode->i_sb))
19637 + goto out_release;
19638 + if ((reserved != CDLIM_KEEP &&
19639 + reserved > 100) ||
19640 + (inodes_used != CDLIM_KEEP &&
19641 + inodes_used > inodes_total) ||
19642 + (space_used != CDLIM_KEEP &&
19643 + space_used > space_total))
19644 + goto out_release;
19647 + dli = locate_dl_info(sb, id);
19649 + goto out_release;
19651 + spin_lock(&dli->dl_lock);
19653 + if (inodes_used != CDLIM_KEEP)
19654 + dli->dl_inodes_used = inodes_used;
19655 + if (inodes_total != CDLIM_KEEP)
19656 + dli->dl_inodes_total = inodes_total;
19657 + if (space_used != CDLIM_KEEP) {
19658 + dli->dl_space_used = space_used;
19659 + dli->dl_space_used <<= 10;
19661 + if (space_total == CDLIM_INFINITY)
19662 + dli->dl_space_total = DLIM_INFINITY;
19663 + else if (space_total != CDLIM_KEEP) {
19664 + dli->dl_space_total = space_total;
19665 + dli->dl_space_total <<= 10;
19667 + if (reserved != CDLIM_KEEP)
19668 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
19670 + spin_unlock(&dli->dl_lock);
19672 + put_dl_info(dli);
19681 +int vc_set_dlimit(uint32_t id, void __user *data)
19683 + struct vcmd_ctx_dlimit_v0 vc_data;
19685 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19688 + return do_set_dlimit(id, vc_data.name,
19689 + vc_data.space_used, vc_data.space_total,
19690 + vc_data.inodes_used, vc_data.inodes_total,
19691 + vc_data.reserved, vc_data.flags);
19694 +#ifdef CONFIG_COMPAT
19696 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
19698 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19700 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19703 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
19704 + vc_data.space_used, vc_data.space_total,
19705 + vc_data.inodes_used, vc_data.inodes_total,
19706 + vc_data.reserved, vc_data.flags);
19709 +#endif /* CONFIG_COMPAT */
19713 +int do_get_dlimit(uint32_t id, const char __user *name,
19714 + uint32_t *space_used, uint32_t *space_total,
19715 + uint32_t *inodes_used, uint32_t *inodes_total,
19716 + uint32_t *reserved, uint32_t *flags)
19718 + struct path path;
19721 + ret = user_lpath(name, &path);
19723 + struct super_block *sb;
19724 + struct dl_info *dli;
19727 + if (!path.dentry->d_inode)
19728 + goto out_release;
19729 + if (!(sb = path.dentry->d_inode->i_sb))
19730 + goto out_release;
19733 + dli = locate_dl_info(sb, id);
19735 + goto out_release;
19737 + spin_lock(&dli->dl_lock);
19738 + *inodes_used = dli->dl_inodes_used;
19739 + *inodes_total = dli->dl_inodes_total;
19740 + *space_used = dli->dl_space_used >> 10;
19741 + if (dli->dl_space_total == DLIM_INFINITY)
19742 + *space_total = CDLIM_INFINITY;
19744 + *space_total = dli->dl_space_total >> 10;
19746 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
19747 + spin_unlock(&dli->dl_lock);
19749 + put_dl_info(dli);
19760 +int vc_get_dlimit(uint32_t id, void __user *data)
19762 + struct vcmd_ctx_dlimit_v0 vc_data;
19765 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19768 + ret = do_get_dlimit(id, vc_data.name,
19769 + &vc_data.space_used, &vc_data.space_total,
19770 + &vc_data.inodes_used, &vc_data.inodes_total,
19771 + &vc_data.reserved, &vc_data.flags);
19775 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19780 +#ifdef CONFIG_COMPAT
19782 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
19784 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19787 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19790 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
19791 + &vc_data.space_used, &vc_data.space_total,
19792 + &vc_data.inodes_used, &vc_data.inodes_total,
19793 + &vc_data.reserved, &vc_data.flags);
19797 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19802 +#endif /* CONFIG_COMPAT */
19805 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
19807 + struct dl_info *dli;
19808 + __u64 blimit, bfree, bavail;
19811 + dli = locate_dl_info(sb, dx_current_tag());
19815 + spin_lock(&dli->dl_lock);
19816 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
19819 + /* reduce max inodes available to limit */
19820 + if (buf->f_files > dli->dl_inodes_total)
19821 + buf->f_files = dli->dl_inodes_total;
19823 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
19824 + /* reduce free inodes to min */
19825 + if (ifree < buf->f_ffree)
19826 + buf->f_ffree = ifree;
19829 + if (dli->dl_space_total == DLIM_INFINITY)
19832 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
19834 + if (dli->dl_space_total < dli->dl_space_used)
19837 + bfree = (dli->dl_space_total - dli->dl_space_used)
19838 + >> sb->s_blocksize_bits;
19840 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
19841 + if (bavail < dli->dl_space_used)
19844 + bavail = (bavail - dli->dl_space_used)
19845 + >> sb->s_blocksize_bits;
19847 + /* reduce max space available to limit */
19848 + if (buf->f_blocks > blimit)
19849 + buf->f_blocks = blimit;
19851 + /* reduce free space to min */
19852 + if (bfree < buf->f_bfree)
19853 + buf->f_bfree = bfree;
19855 + /* reduce avail space to min */
19856 + if (bavail < buf->f_bavail)
19857 + buf->f_bavail = bavail;
19860 + spin_unlock(&dli->dl_lock);
19861 + put_dl_info(dli);
19866 +#include <linux/module.h>
19868 +EXPORT_SYMBOL_GPL(locate_dl_info);
19869 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
19871 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/helper.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/helper.c
19872 --- linux-2.6.27.6/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
19873 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/helper.c 2008-10-13 14:54:20.000000000 +0200
19876 + * linux/kernel/vserver/helper.c
19878 + * Virtual Context Support
19880 + * Copyright (C) 2004-2007 Herbert Pötzl
19882 + * V0.01 basic helper
19886 +#include <linux/kmod.h>
19887 +#include <linux/reboot.h>
19888 +#include <linux/vs_context.h>
19889 +#include <linux/vs_network.h>
19890 +#include <linux/vserver/signal.h>
19893 +char vshelper_path[255] = "/sbin/vshelper";
19896 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
19900 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
19901 + printk( KERN_WARNING
19902 + "%s: (%s %s) returned %s with %d\n",
19903 + name, argv[1], argv[2],
19904 + sync ? "sync" : "async", ret);
19906 + vxdprintk(VXD_CBIT(switch, 4),
19907 + "%s: (%s %s) returned %s with %d",
19908 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
19913 + * vshelper path is set via /proc/sys
19914 + * invoked by vserver sys_reboot(), with
19915 + * the following arguments
19917 + * argv [0] = vshelper_path;
19918 + * argv [1] = action: "restart", "halt", "poweroff", ...
19919 + * argv [2] = context identifier
19921 + * envp [*] = type-specific parameters
19924 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
19926 + char id_buf[8], cmd_buf[16];
19927 + char uid_buf[16], pid_buf[16];
19930 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19931 + char *envp[] = {"HOME=/", "TERM=linux",
19932 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
19933 + uid_buf, pid_buf, cmd_buf, 0};
19935 + if (vx_info_state(vxi, VXS_HELPER))
19937 + vxi->vx_state |= VXS_HELPER;
19939 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19941 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19942 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
19943 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
19946 + case LINUX_REBOOT_CMD_RESTART:
19947 + argv[1] = "restart";
19950 + case LINUX_REBOOT_CMD_HALT:
19951 + argv[1] = "halt";
19954 + case LINUX_REBOOT_CMD_POWER_OFF:
19955 + argv[1] = "poweroff";
19958 + case LINUX_REBOOT_CMD_SW_SUSPEND:
19959 + argv[1] = "swsusp";
19963 + vxi->vx_state &= ~VXS_HELPER;
19967 + ret = do_vshelper(vshelper_path, argv, envp, 0);
19968 + vxi->vx_state &= ~VXS_HELPER;
19969 + __wakeup_vx_info(vxi);
19970 + return (ret) ? -EPERM : 0;
19974 +long vs_reboot(unsigned int cmd, void __user *arg)
19976 + struct vx_info *vxi = current->vx_info;
19979 + vxdprintk(VXD_CBIT(misc, 5),
19980 + "vs_reboot(%p[#%d],%d)",
19981 + vxi, vxi ? vxi->vx_id : 0, cmd);
19983 + ret = vs_reboot_helper(vxi, cmd, arg);
19987 + vxi->reboot_cmd = cmd;
19988 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19990 + case LINUX_REBOOT_CMD_RESTART:
19991 + case LINUX_REBOOT_CMD_HALT:
19992 + case LINUX_REBOOT_CMD_POWER_OFF:
19993 + vx_info_kill(vxi, 0, SIGKILL);
19994 + vx_info_kill(vxi, 1, SIGKILL);
20004 + * argv [0] = vshelper_path;
20005 + * argv [1] = action: "startup", "shutdown"
20006 + * argv [2] = context identifier
20008 + * envp [*] = type-specific parameters
20011 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20013 + char id_buf[8], cmd_buf[16];
20014 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20015 + char *envp[] = {"HOME=/", "TERM=linux",
20016 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20018 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20021 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20022 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20025 + case VSC_STARTUP:
20026 + argv[1] = "startup";
20028 + case VSC_SHUTDOWN:
20029 + argv[1] = "shutdown";
20035 + return do_vshelper(vshelper_path, argv, envp, 1);
20040 + * argv [0] = vshelper_path;
20041 + * argv [1] = action: "netup", "netdown"
20042 + * argv [2] = context identifier
20044 + * envp [*] = type-specific parameters
20047 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20049 + char id_buf[8], cmd_buf[16];
20050 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20051 + char *envp[] = {"HOME=/", "TERM=linux",
20052 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20054 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20057 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20058 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20062 + argv[1] = "netup";
20064 + case VSC_NETDOWN:
20065 + argv[1] = "netdown";
20071 + return do_vshelper(vshelper_path, argv, envp, 1);
20074 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/history.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/history.c
20075 --- linux-2.6.27.6/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
20076 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/history.c 2008-10-13 14:54:20.000000000 +0200
20079 + * kernel/vserver/history.c
20081 + * Virtual Context History Backtrace
20083 + * Copyright (C) 2004-2007 Herbert Pötzl
20085 + * V0.01 basic structure
20086 + * V0.02 hash/unhash and trace
20087 + * V0.03 preemption fixes
20091 +#include <linux/module.h>
20092 +#include <asm/uaccess.h>
20094 +#include <linux/vserver/context.h>
20095 +#include <linux/vserver/debug.h>
20096 +#include <linux/vserver/debug_cmd.h>
20097 +#include <linux/vserver/history.h>
20100 +#ifdef CONFIG_VSERVER_HISTORY
20101 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20103 +#define VXH_SIZE 64
20106 +struct _vx_history {
20107 + unsigned int counter;
20109 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20113 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20115 +unsigned volatile int vxh_active = 1;
20117 +static atomic_t sequence = ATOMIC_INIT(0);
20122 + * requires disabled preemption */
20124 +struct _vx_hist_entry *vxh_advance(void *loc)
20126 + unsigned int cpu = smp_processor_id();
20127 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20128 + struct _vx_hist_entry *entry;
20129 + unsigned int index;
20131 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20132 + entry = &hist->entry[index];
20134 + entry->seq = atomic_inc_return(&sequence);
20135 + entry->loc = loc;
20139 +EXPORT_SYMBOL_GPL(vxh_advance);
20142 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20144 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20147 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20149 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20150 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20151 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20152 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20154 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20156 + switch (e->type) {
20157 + case VXH_THROW_OOPS:
20158 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20161 + case VXH_GET_VX_INFO:
20162 + case VXH_PUT_VX_INFO:
20163 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20165 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20166 + VXH_VXI_ARGS(e));
20169 + case VXH_INIT_VX_INFO:
20170 + case VXH_SET_VX_INFO:
20171 + case VXH_CLR_VX_INFO:
20172 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20174 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20175 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20176 + VXH_VXI_ARGS(e), e->sc.data);
20179 + case VXH_CLAIM_VX_INFO:
20180 + case VXH_RELEASE_VX_INFO:
20181 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20183 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20184 + VXH_VXI_ARGS(e), e->sc.data);
20187 + case VXH_ALLOC_VX_INFO:
20188 + case VXH_DEALLOC_VX_INFO:
20189 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20191 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20192 + VXH_VXI_ARGS(e));
20195 + case VXH_HASH_VX_INFO:
20196 + case VXH_UNHASH_VX_INFO:
20197 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20199 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20200 + VXH_VXI_ARGS(e));
20203 + case VXH_LOC_VX_INFO:
20204 + case VXH_LOOKUP_VX_INFO:
20205 + case VXH_CREATE_VX_INFO:
20206 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20208 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20209 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20210 + e->ll.arg, VXH_VXI_ARGS(e));
20215 +static void __vxh_dump_history(void)
20217 + unsigned int i, cpu;
20219 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20220 + atomic_read(&sequence), NR_CPUS);
20222 + for (i = 0; i < VXH_SIZE; i++) {
20223 + for_each_online_cpu(cpu) {
20224 + struct _vx_history *hist =
20225 + &per_cpu(vx_history_buffer, cpu);
20226 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20227 + struct _vx_hist_entry *entry = &hist->entry[index];
20229 + vxh_dump_entry(entry, cpu);
20234 +void vxh_dump_history(void)
20238 + local_irq_enable();
20240 + local_irq_disable();
20242 + __vxh_dump_history();
20246 +/* vserver syscall commands below here */
20249 +int vc_dump_history(uint32_t id)
20252 + __vxh_dump_history();
20259 +int do_read_history(struct __user _vx_hist_entry *data,
20260 + int cpu, uint32_t *index, uint32_t *count)
20262 + int pos, ret = 0;
20263 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20264 + int end = hist->counter;
20265 + int start = end - VXH_SIZE + 2;
20266 + int idx = *index;
20268 + /* special case: get current pos */
20274 + /* have we lost some data? */
20278 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20279 + struct _vx_hist_entry *entry =
20280 + &hist->entry[idx % VXH_SIZE];
20282 + /* send entry to userspace */
20283 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20287 + /* save new index and count */
20290 + return ret ? ret : (*index < end);
20293 +int vc_read_history(uint32_t id, void __user *data)
20295 + struct vcmd_read_history_v0 vc_data;
20298 + if (id >= NR_CPUS)
20301 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20304 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20305 + id, &vc_data.index, &vc_data.count);
20307 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20312 +#ifdef CONFIG_COMPAT
20314 +int vc_read_history_x32(uint32_t id, void __user *data)
20316 + struct vcmd_read_history_v0_x32 vc_data;
20319 + if (id >= NR_CPUS)
20322 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20325 + ret = do_read_history((struct __user _vx_hist_entry *)
20326 + compat_ptr(vc_data.data_ptr),
20327 + id, &vc_data.index, &vc_data.count);
20329 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20334 +#endif /* CONFIG_COMPAT */
20336 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/inet.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/inet.c
20337 --- linux-2.6.27.6/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20338 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/inet.c 2008-10-13 14:54:20.000000000 +0200
20341 +#include <linux/in.h>
20342 +#include <linux/inetdevice.h>
20343 +#include <linux/vs_inet.h>
20344 +#include <linux/vs_inet6.h>
20345 +#include <linux/vserver/debug.h>
20346 +#include <net/route.h>
20347 +#include <net/addrconf.h>
20350 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20354 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20357 + struct nx_addr_v4 *ptr;
20359 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20360 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20367 + vxdprintk(VXD_CBIT(net, 2),
20368 + "nx_v4_addr_conflict(%p,%p): %d",
20369 + nxi1, nxi2, ret);
20375 +#ifdef CONFIG_IPV6
20377 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20381 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20384 + struct nx_addr_v6 *ptr;
20386 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20387 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20394 + vxdprintk(VXD_CBIT(net, 2),
20395 + "nx_v6_addr_conflict(%p,%p): %d",
20396 + nxi1, nxi2, ret);
20403 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20405 + struct in_device *in_dev;
20406 + struct in_ifaddr **ifap;
20407 + struct in_ifaddr *ifa;
20412 + in_dev = in_dev_get(dev);
20416 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20417 + ifap = &ifa->ifa_next) {
20418 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20423 + in_dev_put(in_dev);
20429 +#ifdef CONFIG_IPV6
20431 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20433 + struct inet6_dev *in_dev;
20434 + struct inet6_ifaddr **ifap;
20435 + struct inet6_ifaddr *ifa;
20440 + in_dev = in6_dev_get(dev);
20444 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20445 + ifap = &ifa->if_next) {
20446 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20451 + in6_dev_put(in_dev);
20458 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20464 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20466 +#ifdef CONFIG_IPV6
20468 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20473 + vxdprintk(VXD_CBIT(net, 3),
20474 + "dev_in_nx_info(%p,%p[#%d]) = %d",
20475 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
20479 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20480 + struct rtable **rp, struct flowi *fl)
20485 + /* FIXME: handle lback only case */
20486 + if (!NX_IPV4(nxi))
20489 + vxdprintk(VXD_CBIT(net, 4),
20490 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20491 + nxi, nxi ? nxi->nx_id : 0,
20492 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20494 + /* single IP is unconditional */
20495 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20496 + (fl->fl4_src == INADDR_ANY))
20497 + fl->fl4_src = nxi->v4.ip[0].s_addr;
20499 + if (fl->fl4_src == INADDR_ANY) {
20500 + struct nx_addr_v4 *ptr;
20501 + __be32 found = 0;
20504 + err = __ip_route_output_key(net, rp, fl);
20506 + found = (*rp)->rt_src;
20508 + vxdprintk(VXD_CBIT(net, 4),
20509 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20510 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20511 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20515 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20516 + __be32 primary = ptr->ip[0].s_addr;
20517 + __be32 mask = ptr->mask.s_addr;
20518 + __be32 neta = primary & mask;
20520 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20521 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20522 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20523 + NIPQUAD(mask), NIPQUAD(neta));
20524 + if ((found & mask) != neta)
20527 + fl->fl4_src = primary;
20528 + err = __ip_route_output_key(net, rp, fl);
20529 + vxdprintk(VXD_CBIT(net, 4),
20530 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20531 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20533 + found = (*rp)->rt_src;
20535 + if (found == primary)
20539 + /* still no source ip? */
20540 + found = ipv4_is_loopback(fl->fl4_dst)
20541 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20543 + /* assign src ip to flow */
20544 + fl->fl4_src = found;
20547 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20551 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20552 + if (ipv4_is_loopback(fl->fl4_dst))
20553 + fl->fl4_dst = nxi->v4_lback.s_addr;
20554 + if (ipv4_is_loopback(fl->fl4_src))
20555 + fl->fl4_src = nxi->v4_lback.s_addr;
20556 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
20557 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20563 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20565 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/init.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/init.c
20566 --- linux-2.6.27.6/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
20567 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/init.c 2008-10-13 14:54:20.000000000 +0200
20570 + * linux/kernel/init.c
20572 + * Virtual Server Init
20574 + * Copyright (C) 2004-2007 Herbert Pötzl
20576 + * V0.01 basic structure
20580 +#include <linux/init.h>
20582 +int vserver_register_sysctl(void);
20583 +void vserver_unregister_sysctl(void);
20586 +static int __init init_vserver(void)
20590 +#ifdef CONFIG_VSERVER_DEBUG
20591 + vserver_register_sysctl();
20597 +static void __exit exit_vserver(void)
20600 +#ifdef CONFIG_VSERVER_DEBUG
20601 + vserver_unregister_sysctl();
20606 +/* FIXME: GFP_ZONETYPES gone
20607 +long vx_slab[GFP_ZONETYPES]; */
20611 +module_init(init_vserver);
20612 +module_exit(exit_vserver);
20614 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/inode.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/inode.c
20615 --- linux-2.6.27.6/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
20616 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/inode.c 2008-10-24 03:34:52.000000000 +0200
20619 + * linux/kernel/vserver/inode.c
20621 + * Virtual Server: File System Support
20623 + * Copyright (C) 2004-2007 Herbert Pötzl
20625 + * V0.01 separated from vcontext V0.05
20626 + * V0.02 moved to tag (instead of xid)
20630 +#include <linux/tty.h>
20631 +#include <linux/proc_fs.h>
20632 +#include <linux/devpts_fs.h>
20633 +#include <linux/fs.h>
20634 +#include <linux/file.h>
20635 +#include <linux/mount.h>
20636 +#include <linux/parser.h>
20637 +#include <linux/namei.h>
20638 +#include <linux/vserver/inode.h>
20639 +#include <linux/vserver/inode_cmd.h>
20640 +#include <linux/vs_base.h>
20641 +#include <linux/vs_tag.h>
20643 +#include <asm/uaccess.h>
20646 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20648 + struct proc_dir_entry *entry;
20650 + if (!in || !in->i_sb)
20653 + *flags = IATTR_TAG
20654 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
20655 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
20656 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
20657 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE;
20659 + if (S_ISDIR(in->i_mode))
20660 + *mask |= IATTR_BARRIER;
20662 + if (IS_TAGGED(in)) {
20663 + *tag = in->i_tag;
20664 + *mask |= IATTR_TAG;
20667 + switch (in->i_sb->s_magic) {
20668 + case PROC_SUPER_MAGIC:
20669 + entry = PROC_I(in)->pde;
20671 + /* check for specific inodes? */
20673 + *mask |= IATTR_FLAGS;
20675 + *flags |= (entry->vx_flags & IATTR_FLAGS);
20677 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
20680 + case DEVPTS_SUPER_MAGIC:
20681 + *tag = in->i_tag;
20682 + *mask |= IATTR_TAG;
20691 +int vc_get_iattr(void __user *data)
20693 + struct path path;
20694 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
20697 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20700 + ret = user_lpath(vc_data.name, &path);
20702 + ret = __vc_get_iattr(path.dentry->d_inode,
20703 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20709 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20714 +#ifdef CONFIG_COMPAT
20716 +int vc_get_iattr_x32(void __user *data)
20718 + struct path path;
20719 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
20722 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20725 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20727 + ret = __vc_get_iattr(path.dentry->d_inode,
20728 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20734 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20739 +#endif /* CONFIG_COMPAT */
20742 +int vc_fget_iattr(uint32_t fd, void __user *data)
20744 + struct file *filp;
20745 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
20748 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20752 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20755 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
20756 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20760 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20766 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20768 + struct inode *in = de->d_inode;
20769 + int error = 0, is_proc = 0, has_tag = 0;
20770 + struct iattr attr = { 0 };
20772 + if (!in || !in->i_sb)
20775 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
20776 + if ((*mask & IATTR_FLAGS) && !is_proc)
20779 + has_tag = IS_TAGGED(in) ||
20780 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
20781 + if ((*mask & IATTR_TAG) && !has_tag)
20784 + mutex_lock(&in->i_mutex);
20785 + if (*mask & IATTR_TAG) {
20786 + attr.ia_tag = *tag;
20787 + attr.ia_valid |= ATTR_TAG;
20790 + if (*mask & IATTR_FLAGS) {
20791 + struct proc_dir_entry *entry = PROC_I(in)->pde;
20792 + unsigned int iflags = PROC_I(in)->vx_flags;
20794 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
20795 + | (*flags & IATTR_FLAGS);
20796 + PROC_I(in)->vx_flags = iflags;
20798 + entry->vx_flags = iflags;
20801 + if (*mask & (IATTR_BARRIER | IATTR_IXUNLINK | IATTR_IMMUTABLE)) {
20802 + if (*mask & IATTR_IMMUTABLE) {
20803 + if (*flags & IATTR_IMMUTABLE)
20804 + in->i_flags |= S_IMMUTABLE;
20806 + in->i_flags &= ~S_IMMUTABLE;
20808 + if (*mask & IATTR_IXUNLINK) {
20809 + if (*flags & IATTR_IXUNLINK)
20810 + in->i_flags |= S_IXUNLINK;
20812 + in->i_flags &= ~S_IXUNLINK;
20814 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
20815 + if (*flags & IATTR_BARRIER)
20816 + in->i_vflags |= V_BARRIER;
20818 + in->i_vflags &= ~V_BARRIER;
20820 + if (in->i_op && in->i_op->sync_flags) {
20821 + error = in->i_op->sync_flags(in);
20827 + if (attr.ia_valid) {
20828 + if (in->i_op && in->i_op->setattr)
20829 + error = in->i_op->setattr(de, &attr);
20831 + error = inode_change_ok(in, &attr);
20833 + error = inode_setattr(in, &attr);
20838 + mutex_unlock(&in->i_mutex);
20842 +int vc_set_iattr(void __user *data)
20844 + struct path path;
20845 + struct vcmd_ctx_iattr_v1 vc_data;
20848 + if (!capable(CAP_LINUX_IMMUTABLE))
20850 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20853 + ret = user_lpath(vc_data.name, &path);
20855 + ret = __vc_set_iattr(path.dentry,
20856 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20860 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20865 +#ifdef CONFIG_COMPAT
20867 +int vc_set_iattr_x32(void __user *data)
20869 + struct path path;
20870 + struct vcmd_ctx_iattr_v1_x32 vc_data;
20873 + if (!capable(CAP_LINUX_IMMUTABLE))
20875 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20878 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20880 + ret = __vc_set_iattr(path.dentry,
20881 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20885 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20890 +#endif /* CONFIG_COMPAT */
20892 +int vc_fset_iattr(uint32_t fd, void __user *data)
20894 + struct file *filp;
20895 + struct vcmd_ctx_fiattr_v0 vc_data;
20898 + if (!capable(CAP_LINUX_IMMUTABLE))
20900 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20904 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20907 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
20908 + &vc_data.flags, &vc_data.mask);
20912 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20918 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
20920 +static match_table_t tokens = {
20921 + {Opt_notagcheck, "notagcheck"},
20922 +#ifdef CONFIG_PROPAGATE
20923 + {Opt_notag, "notag"},
20924 + {Opt_tag, "tag"},
20925 + {Opt_tagid, "tagid=%u"},
20931 +static void __dx_parse_remove(char *string, char *opt)
20933 + char *p = strstr(string, opt);
20937 + while (*q != '\0' && *q != ',')
20946 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
20947 + unsigned long *flags)
20950 + substring_t args[MAX_OPT_ARGS];
20951 + int token, option = 0;
20952 + char *s, *p, *opts;
20956 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20961 + while ((p = strsep(&opts, ",")) != NULL) {
20962 + token = match_token(p, tokens, args);
20964 + vxdprintk(VXD_CBIT(tag, 7),
20965 + "dx_parse_tag(»%s«): %d:#%d",
20966 + p, token, option);
20969 +#ifdef CONFIG_PROPAGATE
20974 + __dx_parse_remove(s, "tag");
20975 + *mnt_flags |= MNT_TAGID;
20976 + set |= MNT_TAGID;
20980 + __dx_parse_remove(s, "notag");
20981 + *mnt_flags |= MNT_NOTAG;
20982 + set |= MNT_NOTAG;
20985 + if (tag && !match_int(args, &option))
20988 + __dx_parse_remove(s, "tagid");
20989 + *mnt_flags |= MNT_TAGID;
20990 + set |= MNT_TAGID;
20993 + case Opt_notagcheck:
20995 + __dx_parse_remove(s, "notagcheck");
20996 + *flags |= MS_NOTAGCHECK;
20997 + set |= MS_NOTAGCHECK;
21002 + strcpy(string, s);
21007 +#ifdef CONFIG_PROPAGATE
21009 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21011 + tag_t new_tag = 0;
21012 + struct vfsmount *mnt;
21017 + mnt = nd->path.mnt;
21021 + propagate = (mnt->mnt_flags & MNT_TAGID);
21023 + new_tag = mnt->mnt_tag;
21025 + vxdprintk(VXD_CBIT(tag, 7),
21026 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21027 + inode, inode->i_ino, inode->i_tag,
21028 + new_tag, (propagate) ? 1 : 0);
21031 + inode->i_tag = new_tag;
21034 +#include <linux/module.h>
21036 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21038 +#endif /* CONFIG_PROPAGATE */
21040 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/Kconfig linux-2.6.27.6-vs2.3.0.36/kernel/vserver/Kconfig
21041 --- linux-2.6.27.6/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
21042 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/Kconfig 2008-10-13 14:54:20.000000000 +0200
21045 +# Linux VServer configuration
21048 +menu "Linux VServer"
21050 +config VSERVER_AUTO_LBACK
21051 + bool "Automatically Assign Loopback IP"
21054 + Automatically assign a guest specific loopback
21055 + IP and add it to the kernel network stack on
21058 +config VSERVER_AUTO_SINGLE
21059 + bool "Automatic Single IP Special Casing"
21060 + depends on EXPERIMENTAL
21063 + This allows network contexts with a single IP to
21064 + automatically remap 0.0.0.0 bindings to that IP,
21065 + avoiding further network checks and improving
21068 + (note: such guests do not allow to change the ip
21069 + on the fly and do not show loopback addresses)
21071 +config VSERVER_COWBL
21072 + bool "Enable COW Immutable Link Breaking"
21075 + This enables the COW (Copy-On-Write) link break code.
21076 + It allows you to treat unified files like normal files
21077 + when writing to them (which will implicitely break the
21078 + link and create a copy of the unified file)
21080 +config VSERVER_VTIME
21081 + bool "Enable Virtualized Guest Time"
21082 + depends on EXPERIMENTAL
21085 + This enables per guest time offsets to allow for
21086 + adjusting the system clock individually per guest.
21087 + this adds some overhead to the time functions and
21088 + therefore should not be enabled without good reason.
21090 +config VSERVER_DEVICE
21091 + bool "Enable Guest Device Mapping"
21092 + depends on EXPERIMENTAL
21095 + This enables generic device remapping.
21097 +config VSERVER_PROC_SECURE
21098 + bool "Enable Proc Security"
21099 + depends on PROC_FS
21102 + This configures ProcFS security to initially hide
21103 + non-process entries for all contexts except the main and
21104 + spectator context (i.e. for all guests), which is a secure
21107 + (note: on 1.2x the entries were visible by default)
21109 +config VSERVER_HARDCPU
21110 + bool "Enable Hard CPU Limits"
21113 + Activate the Hard CPU Limits
21115 + This will compile in code that allows the Token Bucket
21116 + Scheduler to put processes on hold when a context's
21117 + tokens are depleted (provided that its per-context
21118 + sched_hard flag is set).
21120 + Processes belonging to that context will not be able
21121 + to consume CPU resources again until a per-context
21122 + configured minimum of tokens has been reached.
21124 +config VSERVER_IDLETIME
21125 + bool "Avoid idle CPUs by skipping Time"
21126 + depends on VSERVER_HARDCPU
21129 + This option allows the scheduler to artificially
21130 + advance time (per cpu) when otherwise the idle
21131 + task would be scheduled, thus keeping the cpu
21132 + busy and sharing the available resources among
21133 + certain contexts.
21135 +config VSERVER_IDLELIMIT
21136 + bool "Limit the IDLE task"
21137 + depends on VSERVER_HARDCPU
21140 + Limit the idle slices, so the the next context
21141 + will be scheduled as soon as possible.
21143 + This might improve interactivity and latency, but
21144 + will also marginally increase scheduling overhead.
21147 + prompt "Persistent Inode Tagging"
21148 + default TAGGING_ID24
21150 + This adds persistent context information to filesystems
21151 + mounted with the tagxid option. Tagging is a requirement
21152 + for per-context disk limits and per-context quota.
21155 +config TAGGING_NONE
21158 + do not store per-context information in inodes.
21160 +config TAGGING_UID16
21161 + bool "UID16/GID32"
21163 + reduces UID to 16 bit, but leaves GID at 32 bit.
21165 +config TAGGING_GID16
21166 + bool "UID32/GID16"
21168 + reduces GID to 16 bit, but leaves UID at 32 bit.
21170 +config TAGGING_ID24
21171 + bool "UID24/GID24"
21173 + uses the upper 8bit from UID and GID for XID tagging
21174 + which leaves 24bit for UID/GID each, which should be
21175 + more than sufficient for normal use.
21177 +config TAGGING_INTERN
21178 + bool "UID32/GID32"
21180 + this uses otherwise reserved inode fields in the on
21181 + disk representation, which limits the use to a few
21182 + filesystems (currently ext2 and ext3)
21187 + bool "Tag NFSD User Auth and Files"
21190 + Enable this if you do want the in-kernel NFS
21191 + Server to use the tagging specified above.
21192 + (will require patched clients too)
21194 +config VSERVER_PRIVACY
21195 + bool "Honor Privacy Aspects of Guests"
21198 + When enabled, most context checks will disallow
21199 + access to structures assigned to a specific context,
21200 + like ptys or loop devices.
21202 +config VSERVER_CONTEXTS
21203 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
21205 + default "768" if 64BIT
21208 + This setting will optimize certain data structures
21209 + and memory allocations according to the expected
21212 + note: this is not a strict upper limit.
21214 +config VSERVER_WARN
21215 + bool "VServer Warnings"
21218 + This enables various runtime warnings, which will
21219 + notify about potential manipulation attempts or
21220 + resource shortage. It is generally considered to
21221 + be a good idea to have that enabled.
21223 +config VSERVER_DEBUG
21224 + bool "VServer Debugging Code"
21227 + Set this to yes if you want to be able to activate
21228 + debugging output at runtime. It adds a very small
21229 + overhead to all vserver related functions and
21230 + increases the kernel size by about 20k.
21232 +config VSERVER_HISTORY
21233 + bool "VServer History Tracing"
21234 + depends on VSERVER_DEBUG
21237 + Set this to yes if you want to record the history of
21238 + linux-vserver activities, so they can be replayed in
21239 + the event of a kernel panic or oops.
21241 +config VSERVER_HISTORY_SIZE
21242 + int "Per-CPU History Size (32-65536)"
21243 + depends on VSERVER_HISTORY
21247 + This allows you to specify the number of entries in
21248 + the per-CPU history buffer.
21250 +config VSERVER_MONITOR
21251 + bool "VServer Scheduling Monitor"
21252 + depends on VSERVER_DISABLED
21255 + Set this to yes if you want to record the scheduling
21256 + decisions, so that they can be relayed to userspace
21257 + for detailed analysis.
21259 +config VSERVER_MONITOR_SIZE
21260 + int "Per-CPU Monitor Queue Size (32-65536)"
21261 + depends on VSERVER_MONITOR
21265 + This allows you to specify the number of entries in
21266 + the per-CPU scheduling monitor buffer.
21268 +config VSERVER_MONITOR_SYNC
21269 + int "Per-CPU Monitor Sync Interval (0-65536)"
21270 + depends on VSERVER_MONITOR
21274 + This allows you to specify the interval in ticks
21275 + when a time sync entry is inserted.
21283 + select NAMESPACES
21289 +config VSERVER_SECURITY
21291 + depends on SECURITY
21293 + select SECURITY_CAPABILITIES
21295 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/limit.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/limit.c
21296 --- linux-2.6.27.6/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21297 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/limit.c 2008-10-13 14:54:20.000000000 +0200
21300 + * linux/kernel/vserver/limit.c
21302 + * Virtual Server: Context Limits
21304 + * Copyright (C) 2004-2007 Herbert Pötzl
21306 + * V0.01 broken out from vcontext V0.05
21307 + * V0.02 changed vcmds to vxi arg
21311 +#include <linux/sched.h>
21312 +#include <linux/module.h>
21313 +#include <linux/vs_limit.h>
21314 +#include <linux/vserver/limit.h>
21315 +#include <linux/vserver/limit_cmd.h>
21317 +#include <asm/uaccess.h>
21320 +const char *vlimit_name[NUM_LIMITS] = {
21321 + [RLIMIT_CPU] = "CPU",
21322 + [RLIMIT_RSS] = "RSS",
21323 + [RLIMIT_NPROC] = "NPROC",
21324 + [RLIMIT_NOFILE] = "NOFILE",
21325 + [RLIMIT_MEMLOCK] = "VML",
21326 + [RLIMIT_AS] = "VM",
21327 + [RLIMIT_LOCKS] = "LOCKS",
21328 + [RLIMIT_SIGPENDING] = "SIGP",
21329 + [RLIMIT_MSGQUEUE] = "MSGQ",
21331 + [VLIMIT_NSOCK] = "NSOCK",
21332 + [VLIMIT_OPENFD] = "OPENFD",
21333 + [VLIMIT_ANON] = "ANON",
21334 + [VLIMIT_SHMEM] = "SHMEM",
21335 + [VLIMIT_DENTRY] = "DENTRY",
21338 +EXPORT_SYMBOL_GPL(vlimit_name);
21340 +#define MASK_ENTRY(x) (1 << (x))
21342 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21345 + , /* softlimit */
21346 + MASK_ENTRY( RLIMIT_RSS ) |
21347 + MASK_ENTRY( VLIMIT_ANON ) |
21350 + MASK_ENTRY( RLIMIT_RSS ) |
21351 + MASK_ENTRY( RLIMIT_NPROC ) |
21352 + MASK_ENTRY( RLIMIT_NOFILE ) |
21353 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21354 + MASK_ENTRY( RLIMIT_AS ) |
21355 + MASK_ENTRY( RLIMIT_LOCKS ) |
21356 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21358 + MASK_ENTRY( VLIMIT_NSOCK ) |
21359 + MASK_ENTRY( VLIMIT_OPENFD ) |
21360 + MASK_ENTRY( VLIMIT_ANON ) |
21361 + MASK_ENTRY( VLIMIT_SHMEM ) |
21362 + MASK_ENTRY( VLIMIT_DENTRY ) |
21365 + /* accounting only */
21366 +uint32_t account_mask =
21367 + MASK_ENTRY( VLIMIT_SEMARY ) |
21368 + MASK_ENTRY( VLIMIT_NSEMS ) |
21369 + MASK_ENTRY( VLIMIT_MAPPED ) |
21373 +static int is_valid_vlimit(int id)
21375 + uint32_t mask = vlimit_mask.minimum |
21376 + vlimit_mask.softlimit | vlimit_mask.maximum;
21377 + return mask & (1 << id);
21380 +static int is_accounted_vlimit(int id)
21382 + if (is_valid_vlimit(id))
21384 + return account_mask & (1 << id);
21388 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21390 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21391 + return VX_VLIM(limit);
21394 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21396 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21397 + return VX_VLIM(limit);
21400 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21401 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21403 + if (!is_valid_vlimit(id))
21407 + *minimum = CRLIM_UNSET;
21409 + *softlimit = vc_get_soft(vxi, id);
21411 + *maximum = vc_get_hard(vxi, id);
21415 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21417 + struct vcmd_ctx_rlimit_v0 vc_data;
21420 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21423 + ret = do_get_rlimit(vxi, vc_data.id,
21424 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21428 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21433 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21434 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21436 + if (!is_valid_vlimit(id))
21439 + if (maximum != CRLIM_KEEP)
21440 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21441 + if (softlimit != CRLIM_KEEP)
21442 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21444 + /* clamp soft limit */
21445 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21446 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21451 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21453 + struct vcmd_ctx_rlimit_v0 vc_data;
21455 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21458 + return do_set_rlimit(vxi, vc_data.id,
21459 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21462 +#ifdef CONFIG_IA32_EMULATION
21464 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21466 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21468 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21471 + return do_set_rlimit(vxi, vc_data.id,
21472 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21475 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21477 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21480 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21483 + ret = do_get_rlimit(vxi, vc_data.id,
21484 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21488 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21493 +#endif /* CONFIG_IA32_EMULATION */
21496 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21498 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21504 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21509 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21510 + value = __rlim_get(limit, lim);
21511 + __rlim_rmax(limit, lim) = value;
21512 + __rlim_rmin(limit, lim) = value;
21517 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21519 + vx_reset_minmax(&vxi->limit);
21524 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21526 + struct vcmd_rlimit_stat_v0 vc_data;
21527 + struct _vx_limit *limit = &vxi->limit;
21530 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21534 + if (!is_accounted_vlimit(id))
21537 + vx_limit_fixup(limit, id);
21538 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21539 + vc_data.value = __rlim_get(limit, id);
21540 + vc_data.minimum = __rlim_rmin(limit, id);
21541 + vc_data.maximum = __rlim_rmax(limit, id);
21543 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21549 +void vx_vsi_meminfo(struct sysinfo *val)
21551 + struct vx_info *vxi = current->vx_info;
21552 + unsigned long totalram, freeram;
21555 + /* we blindly accept the max */
21556 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21557 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
21559 + /* total minus used equals free */
21560 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21561 + freeram = (v < totalram) ? totalram - v : 0;
21563 + val->totalram = totalram;
21564 + val->freeram = freeram;
21565 + val->bufferram = 0;
21566 + val->totalhigh = 0;
21567 + val->freehigh = 0;
21571 +void vx_vsi_swapinfo(struct sysinfo *val)
21573 + struct vx_info *vxi = current->vx_info;
21574 + unsigned long totalswap, freeswap;
21577 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21578 + if (v == RLIM_INFINITY) {
21579 + val->freeswap = val->totalswap;
21583 + /* we blindly accept the max */
21584 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
21585 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
21587 + /* currently 'used' swap */
21588 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21589 + w -= (w > v) ? v : w;
21591 + /* total minus used equals free */
21592 + freeswap = (w < totalswap) ? totalswap - w : 0;
21594 + val->totalswap = totalswap;
21595 + val->freeswap = freeswap;
21600 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
21602 + struct vx_info *vxi = mm->mm_vx_info;
21603 + unsigned long points;
21609 + points = vxi->vx_badness_bias;
21611 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21612 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21613 + points += (v > w) ? (v - w) : 0;
21618 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/limit_init.h linux-2.6.27.6-vs2.3.0.36/kernel/vserver/limit_init.h
21619 --- linux-2.6.27.6/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
21620 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/limit_init.h 2008-10-13 14:54:20.000000000 +0200
21624 +static inline void vx_info_init_limit(struct _vx_limit *limit)
21628 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21629 + __rlim_soft(limit, lim) = RLIM_INFINITY;
21630 + __rlim_hard(limit, lim) = RLIM_INFINITY;
21631 + __rlim_set(limit, lim, 0);
21632 + atomic_set(&__rlim_lhit(limit, lim), 0);
21633 + __rlim_rmin(limit, lim) = 0;
21634 + __rlim_rmax(limit, lim) = 0;
21638 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
21643 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21644 + if ((1 << lim) & VLIM_NOCHECK)
21646 + value = __rlim_get(limit, lim);
21647 + vxwprintk_xid(value,
21648 + "!!! limit: %p[%s,%d] = %ld on exit.",
21649 + limit, vlimit_name[lim], lim, (long)value);
21653 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/limit_proc.h linux-2.6.27.6-vs2.3.0.36/kernel/vserver/limit_proc.h
21654 --- linux-2.6.27.6/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
21655 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/limit_proc.h 2008-10-13 14:54:20.000000000 +0200
21657 +#ifndef _VX_LIMIT_PROC_H
21658 +#define _VX_LIMIT_PROC_H
21660 +#include <linux/vserver/limit_int.h>
21663 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
21664 +#define VX_LIMIT_TOP \
21665 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
21667 +#define VX_LIMIT_ARG(r) \
21668 + (unsigned long)__rlim_get(limit, r), \
21669 + (unsigned long)__rlim_rmin(limit, r), \
21670 + (unsigned long)__rlim_rmax(limit, r), \
21671 + VX_VLIM(__rlim_soft(limit, r)), \
21672 + VX_VLIM(__rlim_hard(limit, r)), \
21673 + atomic_read(&__rlim_lhit(limit, r))
21675 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
21677 + vx_limit_fixup(limit, -1);
21678 + return sprintf(buffer, VX_LIMIT_TOP
21679 + "PROC" VX_LIMIT_FMT
21680 + "VM" VX_LIMIT_FMT
21681 + "VML" VX_LIMIT_FMT
21682 + "RSS" VX_LIMIT_FMT
21683 + "ANON" VX_LIMIT_FMT
21684 + "RMAP" VX_LIMIT_FMT
21685 + "FILES" VX_LIMIT_FMT
21686 + "OFD" VX_LIMIT_FMT
21687 + "LOCKS" VX_LIMIT_FMT
21688 + "SOCK" VX_LIMIT_FMT
21689 + "MSGQ" VX_LIMIT_FMT
21690 + "SHM" VX_LIMIT_FMT
21691 + "SEMA" VX_LIMIT_FMT
21692 + "SEMS" VX_LIMIT_FMT
21693 + "DENT" VX_LIMIT_FMT,
21694 + VX_LIMIT_ARG(RLIMIT_NPROC),
21695 + VX_LIMIT_ARG(RLIMIT_AS),
21696 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
21697 + VX_LIMIT_ARG(RLIMIT_RSS),
21698 + VX_LIMIT_ARG(VLIMIT_ANON),
21699 + VX_LIMIT_ARG(VLIMIT_MAPPED),
21700 + VX_LIMIT_ARG(RLIMIT_NOFILE),
21701 + VX_LIMIT_ARG(VLIMIT_OPENFD),
21702 + VX_LIMIT_ARG(RLIMIT_LOCKS),
21703 + VX_LIMIT_ARG(VLIMIT_NSOCK),
21704 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
21705 + VX_LIMIT_ARG(VLIMIT_SHMEM),
21706 + VX_LIMIT_ARG(VLIMIT_SEMARY),
21707 + VX_LIMIT_ARG(VLIMIT_NSEMS),
21708 + VX_LIMIT_ARG(VLIMIT_DENTRY));
21711 +#endif /* _VX_LIMIT_PROC_H */
21714 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/Makefile linux-2.6.27.6-vs2.3.0.36/kernel/vserver/Makefile
21715 --- linux-2.6.27.6/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
21716 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/Makefile 2008-10-13 14:54:20.000000000 +0200
21719 +# Makefile for the Linux vserver routines.
21723 +obj-y += vserver.o
21725 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
21726 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
21729 +vserver-$(CONFIG_INET) += inet.o
21730 +vserver-$(CONFIG_PROC_FS) += proc.o
21731 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
21732 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
21733 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
21734 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
21736 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/monitor.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/monitor.c
21737 --- linux-2.6.27.6/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
21738 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/monitor.c 2008-10-13 14:54:20.000000000 +0200
21741 + * kernel/vserver/monitor.c
21743 + * Virtual Context Scheduler Monitor
21745 + * Copyright (C) 2006-2007 Herbert Pötzl
21747 + * V0.01 basic design
21751 +#include <linux/module.h>
21752 +#include <linux/jiffies.h>
21753 +#include <asm/uaccess.h>
21754 +#include <asm/atomic.h>
21756 +#include <linux/vserver/monitor.h>
21757 +#include <linux/vserver/debug_cmd.h>
21760 +#ifdef CONFIG_VSERVER_MONITOR
21761 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
21763 +#define VXM_SIZE 64
21766 +struct _vx_monitor {
21767 + unsigned int counter;
21769 + struct _vx_mon_entry entry[VXM_SIZE+1];
21773 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
21775 +unsigned volatile int vxm_active = 1;
21777 +static atomic_t sequence = ATOMIC_INIT(0);
21782 + * requires disabled preemption */
21784 +struct _vx_mon_entry *vxm_advance(int cpu)
21786 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21787 + struct _vx_mon_entry *entry;
21788 + unsigned int index;
21790 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
21791 + entry = &mon->entry[index];
21793 + entry->ev.seq = atomic_inc_return(&sequence);
21794 + entry->ev.jif = jiffies;
21798 +EXPORT_SYMBOL_GPL(vxm_advance);
21801 +int do_read_monitor(struct __user _vx_mon_entry *data,
21802 + int cpu, uint32_t *index, uint32_t *count)
21804 + int pos, ret = 0;
21805 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21806 + int end = mon->counter;
21807 + int start = end - VXM_SIZE + 2;
21808 + int idx = *index;
21810 + /* special case: get current pos */
21816 + /* have we lost some data? */
21820 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21821 + struct _vx_mon_entry *entry =
21822 + &mon->entry[idx % VXM_SIZE];
21824 + /* send entry to userspace */
21825 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21829 + /* save new index and count */
21832 + return ret ? ret : (*index < end);
21835 +int vc_read_monitor(uint32_t id, void __user *data)
21837 + struct vcmd_read_monitor_v0 vc_data;
21840 + if (id >= NR_CPUS)
21843 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21846 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
21847 + id, &vc_data.index, &vc_data.count);
21849 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21854 +#ifdef CONFIG_COMPAT
21856 +int vc_read_monitor_x32(uint32_t id, void __user *data)
21858 + struct vcmd_read_monitor_v0_x32 vc_data;
21861 + if (id >= NR_CPUS)
21864 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21867 + ret = do_read_monitor((struct __user _vx_mon_entry *)
21868 + compat_ptr(vc_data.data_ptr),
21869 + id, &vc_data.index, &vc_data.count);
21871 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21876 +#endif /* CONFIG_COMPAT */
21878 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/network.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/network.c
21879 --- linux-2.6.27.6/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
21880 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/network.c 2008-10-13 14:54:20.000000000 +0200
21883 + * linux/kernel/vserver/network.c
21885 + * Virtual Server: Network Support
21887 + * Copyright (C) 2003-2007 Herbert Pötzl
21889 + * V0.01 broken out from vcontext V0.05
21890 + * V0.02 cleaned up implementation
21891 + * V0.03 added equiv nx commands
21892 + * V0.04 switch to RCU based hash
21893 + * V0.05 and back to locking again
21894 + * V0.06 changed vcmds to nxi arg
21895 + * V0.07 have __create claim() the nxi
21899 +#include <linux/err.h>
21900 +#include <linux/slab.h>
21901 +#include <linux/rcupdate.h>
21903 +#include <linux/vs_network.h>
21904 +#include <linux/vs_pid.h>
21905 +#include <linux/vserver/network_cmd.h>
21908 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
21909 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
21911 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
21912 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
21915 +static int __init init_network(void)
21917 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
21918 + sizeof(struct nx_addr_v4), 0,
21919 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21920 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
21921 + sizeof(struct nx_addr_v6), 0,
21922 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21927 +/* __alloc_nx_addr_v4() */
21929 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
21931 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
21932 + nx_addr_v4_cachep, GFP_KERNEL);
21934 + if (!IS_ERR(nxa))
21935 + memset(nxa, 0, sizeof(*nxa));
21939 +/* __dealloc_nx_addr_v4() */
21941 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
21943 + kmem_cache_free(nx_addr_v4_cachep, nxa);
21946 +/* __dealloc_nx_addr_v4_all() */
21948 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
21951 + struct nx_addr_v4 *next = nxa->next;
21953 + __dealloc_nx_addr_v4(nxa);
21959 +#ifdef CONFIG_IPV6
21961 +/* __alloc_nx_addr_v6() */
21963 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
21965 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
21966 + nx_addr_v6_cachep, GFP_KERNEL);
21968 + if (!IS_ERR(nxa))
21969 + memset(nxa, 0, sizeof(*nxa));
21973 +/* __dealloc_nx_addr_v6() */
21975 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
21977 + kmem_cache_free(nx_addr_v6_cachep, nxa);
21980 +/* __dealloc_nx_addr_v6_all() */
21982 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
21985 + struct nx_addr_v6 *next = nxa->next;
21987 + __dealloc_nx_addr_v6(nxa);
21992 +#endif /* CONFIG_IPV6 */
21994 +/* __alloc_nx_info()
21996 + * allocate an initialized nx_info struct
21997 + * doesn't make it visible (hash) */
21999 +static struct nx_info *__alloc_nx_info(nid_t nid)
22001 + struct nx_info *new = NULL;
22003 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22005 + /* would this benefit from a slab cache? */
22006 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22010 + memset(new, 0, sizeof(struct nx_info));
22011 + new->nx_id = nid;
22012 + INIT_HLIST_NODE(&new->nx_hlist);
22013 + atomic_set(&new->nx_usecnt, 0);
22014 + atomic_set(&new->nx_tasks, 0);
22015 + new->nx_state = 0;
22017 + new->nx_flags = NXF_INIT_SET;
22019 + /* rest of init goes here */
22021 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22022 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22024 + vxdprintk(VXD_CBIT(nid, 0),
22025 + "alloc_nx_info(%d) = %p", nid, new);
22026 + atomic_inc(&nx_global_ctotal);
22030 +/* __dealloc_nx_info()
22032 + * final disposal of nx_info */
22034 +static void __dealloc_nx_info(struct nx_info *nxi)
22036 + vxdprintk(VXD_CBIT(nid, 0),
22037 + "dealloc_nx_info(%p)", nxi);
22039 + nxi->nx_hlist.next = LIST_POISON1;
22042 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22043 + BUG_ON(atomic_read(&nxi->nx_tasks));
22045 + __dealloc_nx_addr_v4_all(nxi->v4.next);
22047 + nxi->nx_state |= NXS_RELEASED;
22049 + atomic_dec(&nx_global_ctotal);
22052 +static void __shutdown_nx_info(struct nx_info *nxi)
22054 + nxi->nx_state |= NXS_SHUTDOWN;
22055 + vs_net_change(nxi, VSC_NETDOWN);
22058 +/* exported stuff */
22060 +void free_nx_info(struct nx_info *nxi)
22062 + /* context shutdown is mandatory */
22063 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22065 + /* context must not be hashed */
22066 + BUG_ON(nxi->nx_state & NXS_HASHED);
22068 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22069 + BUG_ON(atomic_read(&nxi->nx_tasks));
22071 + __dealloc_nx_info(nxi);
22075 +void __nx_set_lback(struct nx_info *nxi)
22077 + int nid = nxi->nx_id;
22078 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22080 + nxi->v4_lback.s_addr = lback;
22083 +extern int __nx_inet_add_lback(__be32 addr);
22084 +extern int __nx_inet_del_lback(__be32 addr);
22087 +/* hash table for nx_info hash */
22089 +#define NX_HASH_SIZE 13
22091 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22093 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22096 +static inline unsigned int __hashval(nid_t nid)
22098 + return (nid % NX_HASH_SIZE);
22103 +/* __hash_nx_info()
22105 + * add the nxi to the global hash table
22106 + * requires the hash_lock to be held */
22108 +static inline void __hash_nx_info(struct nx_info *nxi)
22110 + struct hlist_head *head;
22112 + vxd_assert_lock(&nx_info_hash_lock);
22113 + vxdprintk(VXD_CBIT(nid, 4),
22114 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22116 + /* context must not be hashed */
22117 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22119 + nxi->nx_state |= NXS_HASHED;
22120 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22121 + hlist_add_head(&nxi->nx_hlist, head);
22122 + atomic_inc(&nx_global_cactive);
22125 +/* __unhash_nx_info()
22127 + * remove the nxi from the global hash table
22128 + * requires the hash_lock to be held */
22130 +static inline void __unhash_nx_info(struct nx_info *nxi)
22132 + vxd_assert_lock(&nx_info_hash_lock);
22133 + vxdprintk(VXD_CBIT(nid, 4),
22134 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22135 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22137 + /* context must be hashed */
22138 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22139 + /* but without tasks */
22140 + BUG_ON(atomic_read(&nxi->nx_tasks));
22142 + nxi->nx_state &= ~NXS_HASHED;
22143 + hlist_del(&nxi->nx_hlist);
22144 + atomic_dec(&nx_global_cactive);
22148 +/* __lookup_nx_info()
22150 + * requires the hash_lock to be held
22151 + * doesn't increment the nx_refcnt */
22153 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22155 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22156 + struct hlist_node *pos;
22157 + struct nx_info *nxi;
22159 + vxd_assert_lock(&nx_info_hash_lock);
22160 + hlist_for_each(pos, head) {
22161 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22163 + if (nxi->nx_id == nid)
22168 + vxdprintk(VXD_CBIT(nid, 0),
22169 + "__lookup_nx_info(#%u): %p[#%u]",
22170 + nid, nxi, nxi ? nxi->nx_id : 0);
22175 +/* __create_nx_info()
22177 + * create the requested context
22178 + * get(), claim() and hash it */
22180 +static struct nx_info *__create_nx_info(int id)
22182 + struct nx_info *new, *nxi = NULL;
22184 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22186 + if (!(new = __alloc_nx_info(id)))
22187 + return ERR_PTR(-ENOMEM);
22189 + /* required to make dynamic xids unique */
22190 + spin_lock(&nx_info_hash_lock);
22192 + /* static context requested */
22193 + if ((nxi = __lookup_nx_info(id))) {
22194 + vxdprintk(VXD_CBIT(nid, 0),
22195 + "create_nx_info(%d) = %p (already there)", id, nxi);
22196 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22197 + nxi = ERR_PTR(-EBUSY);
22199 + nxi = ERR_PTR(-EEXIST);
22202 + /* new context */
22203 + vxdprintk(VXD_CBIT(nid, 0),
22204 + "create_nx_info(%d) = %p (new)", id, new);
22205 + claim_nx_info(new, NULL);
22206 + __nx_set_lback(new);
22207 + __hash_nx_info(get_nx_info(new));
22208 + nxi = new, new = NULL;
22211 + spin_unlock(&nx_info_hash_lock);
22213 + __dealloc_nx_info(new);
22219 +/* exported stuff */
22222 +void unhash_nx_info(struct nx_info *nxi)
22224 + __shutdown_nx_info(nxi);
22225 + spin_lock(&nx_info_hash_lock);
22226 + __unhash_nx_info(nxi);
22227 + spin_unlock(&nx_info_hash_lock);
22230 +/* lookup_nx_info()
22232 + * search for a nx_info and get() it
22233 + * negative id means current */
22235 +struct nx_info *lookup_nx_info(int id)
22237 + struct nx_info *nxi = NULL;
22240 + nxi = get_nx_info(current->nx_info);
22241 + } else if (id > 1) {
22242 + spin_lock(&nx_info_hash_lock);
22243 + nxi = get_nx_info(__lookup_nx_info(id));
22244 + spin_unlock(&nx_info_hash_lock);
22249 +/* nid_is_hashed()
22251 + * verify that nid is still hashed */
22253 +int nid_is_hashed(nid_t nid)
22257 + spin_lock(&nx_info_hash_lock);
22258 + hashed = (__lookup_nx_info(nid) != NULL);
22259 + spin_unlock(&nx_info_hash_lock);
22264 +#ifdef CONFIG_PROC_FS
22268 + * get a subset of hashed nids for proc
22269 + * assumes size is at least one */
22271 +int get_nid_list(int index, unsigned int *nids, int size)
22273 + int hindex, nr_nids = 0;
22275 + /* only show current and children */
22276 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22279 + nids[nr_nids] = nx_current_nid();
22283 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22284 + struct hlist_head *head = &nx_info_hash[hindex];
22285 + struct hlist_node *pos;
22287 + spin_lock(&nx_info_hash_lock);
22288 + hlist_for_each(pos, head) {
22289 + struct nx_info *nxi;
22294 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22295 + nids[nr_nids] = nxi->nx_id;
22296 + if (++nr_nids >= size) {
22297 + spin_unlock(&nx_info_hash_lock);
22301 + /* keep the lock time short */
22302 + spin_unlock(&nx_info_hash_lock);
22311 + * migrate task to new network
22312 + * gets nxi, puts old_nxi on change
22315 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22317 + struct nx_info *old_nxi;
22323 + vxdprintk(VXD_CBIT(nid, 5),
22324 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22325 + p, nxi, nxi->nx_id,
22326 + atomic_read(&nxi->nx_usecnt),
22327 + atomic_read(&nxi->nx_tasks));
22329 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22330 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22333 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22336 + /* maybe disallow this completely? */
22337 + old_nxi = task_get_nx_info(p);
22338 + if (old_nxi == nxi)
22343 + clr_nx_info(&p->nx_info);
22344 + claim_nx_info(nxi, p);
22345 + set_nx_info(&p->nx_info, nxi);
22346 + p->nid = nxi->nx_id;
22349 + vxdprintk(VXD_CBIT(nid, 5),
22350 + "moved task %p into nxi:%p[#%d]",
22351 + p, nxi, nxi->nx_id);
22354 + release_nx_info(old_nxi, p);
22357 + put_nx_info(old_nxi);
22362 +void nx_set_persistent(struct nx_info *nxi)
22364 + vxdprintk(VXD_CBIT(nid, 6),
22365 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22367 + get_nx_info(nxi);
22368 + claim_nx_info(nxi, NULL);
22371 +void nx_clear_persistent(struct nx_info *nxi)
22373 + vxdprintk(VXD_CBIT(nid, 6),
22374 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22376 + release_nx_info(nxi, NULL);
22377 + put_nx_info(nxi);
22380 +void nx_update_persistent(struct nx_info *nxi)
22382 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22383 + nx_set_persistent(nxi);
22385 + nx_clear_persistent(nxi);
22388 +/* vserver syscall commands below here */
22390 +/* taks nid and nx_info functions */
22392 +#include <asm/uaccess.h>
22395 +int vc_task_nid(uint32_t id)
22400 + struct task_struct *tsk;
22402 + read_lock(&tasklist_lock);
22403 + tsk = find_task_by_real_pid(id);
22404 + nid = (tsk) ? tsk->nid : -ESRCH;
22405 + read_unlock(&tasklist_lock);
22407 + nid = nx_current_nid();
22412 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22414 + struct vcmd_nx_info_v0 vc_data;
22416 + vc_data.nid = nxi->nx_id;
22418 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22424 +/* network functions */
22426 +int vc_net_create(uint32_t nid, void __user *data)
22428 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22429 + struct nx_info *new_nxi;
22432 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22435 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22438 + new_nxi = __create_nx_info(nid);
22439 + if (IS_ERR(new_nxi))
22440 + return PTR_ERR(new_nxi);
22442 + /* initial flags */
22443 + new_nxi->nx_flags = vc_data.flagword;
22446 + if (vs_net_change(new_nxi, VSC_NETUP))
22449 + ret = nx_migrate_task(current, new_nxi);
22453 + /* return context id on success */
22454 + ret = new_nxi->nx_id;
22456 + /* get a reference for persistent contexts */
22457 + if ((vc_data.flagword & NXF_PERSISTENT))
22458 + nx_set_persistent(new_nxi);
22460 + release_nx_info(new_nxi, NULL);
22461 + put_nx_info(new_nxi);
22466 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22468 + return nx_migrate_task(current, nxi);
22473 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22474 + uint16_t type, uint16_t flags)
22476 + struct nx_addr_v4 *nxa = &nxi->v4;
22478 + if (NX_IPV4(nxi)) {
22479 + /* locate last entry */
22480 + for (; nxa->next; nxa = nxa->next);
22481 + nxa->next = __alloc_nx_addr_v4();
22485 + return PTR_ERR(nxa);
22488 + if (nxi->v4.next)
22489 + /* remove single ip for ip list */
22490 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22492 + nxa->ip[0].s_addr = ip;
22493 + nxa->ip[1].s_addr = ip2;
22494 + nxa->mask.s_addr = mask;
22495 + nxa->type = type;
22496 + nxa->flags = flags;
22501 +int vc_net_add(struct nx_info *nxi, void __user *data)
22503 + struct vcmd_net_addr_v0 vc_data;
22504 + int index, ret = 0;
22506 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22509 + switch (vc_data.type) {
22510 + case NXA_TYPE_IPV4:
22511 + if ((vc_data.count < 1) || (vc_data.count > 4))
22515 + while (index < vc_data.count) {
22516 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22517 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22525 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22526 + nxi->v4_bcast = vc_data.ip[0];
22530 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22531 + nxi->v4_lback = vc_data.ip[0];
22542 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22544 + struct vcmd_net_addr_v0 vc_data;
22546 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22549 + switch (vc_data.type) {
22550 + case NXA_TYPE_ANY:
22551 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22552 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22562 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22564 + struct vcmd_net_addr_ipv4_v1 vc_data;
22566 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22569 + switch (vc_data.type) {
22570 + case NXA_TYPE_ADDR:
22571 + case NXA_TYPE_RANGE:
22572 + case NXA_TYPE_MASK:
22573 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22574 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22576 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22577 + nxi->v4_bcast = vc_data.ip;
22580 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22581 + nxi->v4_lback = vc_data.ip;
22590 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
22592 + struct vcmd_net_addr_ipv4_v1 vc_data;
22594 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22597 + switch (vc_data.type) {
22598 +/* case NXA_TYPE_ADDR:
22601 + case NXA_TYPE_ANY:
22602 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22603 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22613 +#ifdef CONFIG_IPV6
22615 +int do_add_v6_addr(struct nx_info *nxi,
22616 + struct in6_addr *ip, struct in6_addr *mask,
22617 + uint32_t prefix, uint16_t type, uint16_t flags)
22619 + struct nx_addr_v6 *nxa = &nxi->v6;
22621 + if (NX_IPV6(nxi)) {
22622 + /* locate last entry */
22623 + for (; nxa->next; nxa = nxa->next);
22624 + nxa->next = __alloc_nx_addr_v6();
22628 + return PTR_ERR(nxa);
22632 + nxa->mask = *mask;
22633 + nxa->prefix = prefix;
22634 + nxa->type = type;
22635 + nxa->flags = flags;
22640 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
22642 + struct vcmd_net_addr_ipv6_v1 vc_data;
22644 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22647 + switch (vc_data.type) {
22648 + case NXA_TYPE_ADDR:
22649 + case NXA_TYPE_MASK:
22650 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
22651 + vc_data.prefix, vc_data.type, vc_data.flags);
22658 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
22660 + struct vcmd_net_addr_ipv6_v1 vc_data;
22662 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22665 + switch (vc_data.type) {
22666 + case NXA_TYPE_ANY:
22667 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
22668 + memset(&nxi->v6, 0, sizeof(nxi->v6));
22677 +#endif /* CONFIG_IPV6 */
22680 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
22682 + struct vcmd_net_flags_v0 vc_data;
22684 + vc_data.flagword = nxi->nx_flags;
22686 + /* special STATE flag handling */
22687 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
22689 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22694 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
22696 + struct vcmd_net_flags_v0 vc_data;
22697 + uint64_t mask, trigger;
22699 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22702 + /* special STATE flag handling */
22703 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
22704 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
22706 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
22707 + vc_data.flagword, mask);
22708 + if (trigger & NXF_PERSISTENT)
22709 + nx_update_persistent(nxi);
22714 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
22716 + struct vcmd_net_caps_v0 vc_data;
22718 + vc_data.ncaps = nxi->nx_ncaps;
22719 + vc_data.cmask = ~0ULL;
22721 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22726 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
22728 + struct vcmd_net_caps_v0 vc_data;
22730 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22733 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
22734 + vc_data.ncaps, vc_data.cmask);
22739 +#include <linux/module.h>
22741 +module_init(init_network);
22743 +EXPORT_SYMBOL_GPL(free_nx_info);
22744 +EXPORT_SYMBOL_GPL(unhash_nx_info);
22746 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/proc.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/proc.c
22747 --- linux-2.6.27.6/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
22748 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/proc.c 2008-10-31 18:15:28.000000000 +0100
22751 + * linux/kernel/vserver/proc.c
22753 + * Virtual Context Support
22755 + * Copyright (C) 2003-2007 Herbert Pötzl
22757 + * V0.01 basic structure
22758 + * V0.02 adaptation vs1.3.0
22759 + * V0.03 proc permissions
22760 + * V0.04 locking/generic
22761 + * V0.05 next generation procfs
22762 + * V0.06 inode validation
22763 + * V0.07 generic rewrite vid
22764 + * V0.08 remove inode type
22768 +#include <linux/proc_fs.h>
22769 +#include <asm/unistd.h>
22771 +#include <linux/vs_context.h>
22772 +#include <linux/vs_network.h>
22773 +#include <linux/vs_cvirt.h>
22775 +#include <linux/in.h>
22776 +#include <linux/inetdevice.h>
22777 +#include <linux/vs_inet.h>
22778 +#include <linux/vs_inet6.h>
22780 +#include <linux/vserver/global.h>
22782 +#include "cvirt_proc.h"
22783 +#include "cacct_proc.h"
22784 +#include "limit_proc.h"
22785 +#include "sched_proc.h"
22786 +#include "vci_config.h"
22789 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
22793 + CAP_FOR_EACH_U32(__capi) {
22794 + buffer += sprintf(buffer, "%08x",
22795 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
22801 +static struct proc_dir_entry *proc_virtual;
22803 +static struct proc_dir_entry *proc_virtnet;
22806 +/* first the actual feeds */
22809 +static int proc_vci(char *buffer)
22811 + return sprintf(buffer,
22812 + "VCIVersion:\t%04x:%04x\n"
22813 + "VCISyscall:\t%d\n"
22814 + "VCIKernel:\t%08x\n",
22815 + VCI_VERSION >> 16,
22816 + VCI_VERSION & 0xFFFF,
22818 + vci_kernel_config());
22821 +static int proc_virtual_info(char *buffer)
22823 + return proc_vci(buffer);
22826 +static int proc_virtual_status(char *buffer)
22828 + return sprintf(buffer,
22830 + "#CActive:\t%d\n"
22831 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n",
22832 + atomic_read(&vx_global_ctotal),
22833 + atomic_read(&vx_global_cactive),
22834 + atomic_read(&vs_global_nsproxy),
22835 + atomic_read(&vs_global_fs),
22836 + atomic_read(&vs_global_mnt_ns),
22837 + atomic_read(&vs_global_uts_ns),
22838 + atomic_read(&vs_global_ipc_ns),
22839 + atomic_read(&vs_global_user_ns),
22840 + atomic_read(&vs_global_pid_ns));
22844 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
22848 + length = sprintf(buffer,
22856 + vxi->vx_badness_bias);
22860 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
22862 + char *orig = buffer;
22864 + buffer += sprintf(buffer,
22867 + "Flags:\t%016llx\n",
22868 + atomic_read(&vxi->vx_usecnt),
22869 + atomic_read(&vxi->vx_tasks),
22870 + (unsigned long long)vxi->vx_flags);
22872 + buffer += sprintf(buffer, "BCaps:\t");
22873 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22874 + buffer += sprintf(buffer, "\n");
22876 + buffer += sprintf(buffer,
22877 + "CCaps:\t%016llx\n"
22878 + "Spaces:\t%08lx %08lx\n",
22879 + (unsigned long long)vxi->vx_ccaps,
22880 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
22881 + return buffer - orig;
22884 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
22886 + return vx_info_proc_limit(&vxi->limit, buffer);
22889 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
22893 + length = vx_info_proc_sched(&vxi->sched, buffer);
22894 + for_each_online_cpu(cpu) {
22895 + length += vx_info_proc_sched_pc(
22896 + &vx_per_cpu(vxi, sched_pc, cpu),
22897 + buffer + length, cpu);
22902 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
22904 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
22907 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
22909 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
22912 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
22916 + vx_update_load(vxi);
22917 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
22918 + for_each_online_cpu(cpu) {
22919 + length += vx_info_proc_cvirt_pc(
22920 + &vx_per_cpu(vxi, cvirt_pc, cpu),
22921 + buffer + length, cpu);
22926 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
22928 + return vx_info_proc_cacct(&vxi->cacct, buffer);
22932 +static int proc_virtnet_info(char *buffer)
22934 + return proc_vci(buffer);
22937 +static int proc_virtnet_status(char *buffer)
22939 + return sprintf(buffer,
22941 + "#CActive:\t%d\n",
22942 + atomic_read(&nx_global_ctotal),
22943 + atomic_read(&nx_global_cactive));
22946 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
22948 + struct nx_addr_v4 *v4a;
22949 +#ifdef CONFIG_IPV6
22950 + struct nx_addr_v6 *v6a;
22954 + length = sprintf(buffer,
22957 + "Bcast:\t" NIPQUAD_FMT "\n"
22958 + "Lback:\t" NIPQUAD_FMT "\n",
22961 + NIPQUAD(nxi->v4_bcast.s_addr),
22962 + NIPQUAD(nxi->v4_lback.s_addr));
22964 + if (!NX_IPV4(nxi))
22966 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22967 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
22970 +#ifdef CONFIG_IPV6
22971 + if (!NX_IPV6(nxi))
22973 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22974 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
22981 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
22985 + length = sprintf(buffer,
22988 + "Flags:\t%016llx\n"
22989 + "NCaps:\t%016llx\n",
22990 + atomic_read(&nxi->nx_usecnt),
22991 + atomic_read(&nxi->nx_tasks),
22992 + (unsigned long long)nxi->nx_flags,
22993 + (unsigned long long)nxi->nx_ncaps);
22999 +/* here the inode helpers */
23005 + struct inode_operations *iop;
23006 + struct file_operations *fop;
23007 + union proc_op op;
23010 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23012 + struct inode *inode = new_inode(sb);
23017 + inode->i_mode = p->mode;
23019 + inode->i_op = p->iop;
23021 + inode->i_fop = p->fop;
23023 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23024 + inode->i_flags |= S_IMMUTABLE;
23026 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23028 + inode->i_uid = 0;
23029 + inode->i_gid = 0;
23030 + inode->i_tag = 0;
23035 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23036 + struct dentry *dentry, int id, void *ptr)
23038 + struct vs_entry *p = ptr;
23039 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23040 + struct dentry *error = ERR_PTR(-EINVAL);
23045 + PROC_I(inode)->op = p->op;
23046 + PROC_I(inode)->fd = id;
23047 + d_add(dentry, inode);
23055 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23058 + * Fill a directory entry.
23060 + * If possible create the dcache entry and derive our inode number and
23061 + * file type from dcache entry.
23063 + * Since all of the proc inode numbers are dynamically generated, the inode
23064 + * numbers do not exist until the inode is cache. This means creating the
23065 + * the dcache entry in readdir is necessary to keep the inode numbers
23066 + * reported by readdir in sync with the inode numbers reported
23069 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23070 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23072 + struct dentry *child, *dir = filp->f_dentry;
23073 + struct inode *inode;
23074 + struct qstr qname;
23076 + unsigned type = DT_UNKNOWN;
23078 + qname.name = name;
23080 + qname.hash = full_name_hash(name, len);
23082 + child = d_lookup(dir, &qname);
23084 + struct dentry *new;
23085 + new = d_alloc(dir, &qname);
23087 + child = instantiate(dir->d_inode, new, id, ptr);
23094 + if (!child || IS_ERR(child) || !child->d_inode)
23095 + goto end_instantiate;
23096 + inode = child->d_inode;
23098 + ino = inode->i_ino;
23099 + type = inode->i_mode >> 12;
23104 + ino = find_inode_number(dir, &qname);
23107 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23112 +/* get and revalidate vx_info/xid */
23115 +struct vx_info *get_proc_vx_info(struct inode *inode)
23117 + return lookup_vx_info(PROC_I(inode)->fd);
23120 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23122 + struct inode *inode = dentry->d_inode;
23123 + xid_t xid = PROC_I(inode)->fd;
23125 + if (!xid || xid_is_hashed(xid))
23132 +/* get and revalidate nx_info/nid */
23134 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23136 + struct inode *inode = dentry->d_inode;
23137 + nid_t nid = PROC_I(inode)->fd;
23139 + if (!nid || nid_is_hashed(nid))
23147 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23149 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23150 + size_t count, loff_t *ppos)
23152 + struct inode *inode = file->f_dentry->d_inode;
23153 + unsigned long page;
23154 + ssize_t length = 0;
23156 + if (count > PROC_BLOCK_SIZE)
23157 + count = PROC_BLOCK_SIZE;
23159 + /* fade that out as soon as stable */
23160 + WARN_ON(PROC_I(inode)->fd);
23162 + if (!(page = __get_free_page(GFP_KERNEL)))
23165 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23166 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23169 + length = simple_read_from_buffer(buf, count, ppos,
23170 + (char *)page, length);
23176 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23177 + size_t count, loff_t *ppos)
23179 + struct inode *inode = file->f_dentry->d_inode;
23180 + struct vx_info *vxi = NULL;
23181 + xid_t xid = PROC_I(inode)->fd;
23182 + unsigned long page;
23183 + ssize_t length = 0;
23185 + if (count > PROC_BLOCK_SIZE)
23186 + count = PROC_BLOCK_SIZE;
23188 + /* fade that out as soon as stable */
23190 + vxi = lookup_vx_info(xid);
23194 + length = -ENOMEM;
23195 + if (!(page = __get_free_page(GFP_KERNEL)))
23198 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23199 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23202 + length = simple_read_from_buffer(buf, count, ppos,
23203 + (char *)page, length);
23207 + put_vx_info(vxi);
23212 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23213 + size_t count, loff_t *ppos)
23215 + struct inode *inode = file->f_dentry->d_inode;
23216 + struct nx_info *nxi = NULL;
23217 + nid_t nid = PROC_I(inode)->fd;
23218 + unsigned long page;
23219 + ssize_t length = 0;
23221 + if (count > PROC_BLOCK_SIZE)
23222 + count = PROC_BLOCK_SIZE;
23224 + /* fade that out as soon as stable */
23226 + nxi = lookup_nx_info(nid);
23230 + length = -ENOMEM;
23231 + if (!(page = __get_free_page(GFP_KERNEL)))
23234 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23235 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23238 + length = simple_read_from_buffer(buf, count, ppos,
23239 + (char *)page, length);
23243 + put_nx_info(nxi);
23250 +/* here comes the lower level */
23253 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23254 + .len = sizeof(NAME) - 1, \
23255 + .name = (NAME), \
23263 +#define DIR(NAME, MODE, OTYPE) \
23264 + NOD(NAME, (S_IFDIR | (MODE)), \
23265 + &proc_ ## OTYPE ## _inode_operations, \
23266 + &proc_ ## OTYPE ## _file_operations, { } )
23268 +#define INF(NAME, MODE, OTYPE) \
23269 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23270 + &proc_vs_info_file_operations, \
23271 + { .proc_vs_read = &proc_##OTYPE } )
23273 +#define VINF(NAME, MODE, OTYPE) \
23274 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23275 + &proc_vx_info_file_operations, \
23276 + { .proc_vxi_read = &proc_##OTYPE } )
23278 +#define NINF(NAME, MODE, OTYPE) \
23279 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23280 + &proc_nx_info_file_operations, \
23281 + { .proc_nxi_read = &proc_##OTYPE } )
23284 +static struct file_operations proc_vs_info_file_operations = {
23285 + .read = proc_vs_info_read,
23288 +static struct file_operations proc_vx_info_file_operations = {
23289 + .read = proc_vx_info_read,
23292 +static struct dentry_operations proc_xid_dentry_operations = {
23293 + .d_revalidate = proc_xid_revalidate,
23296 +static struct vs_entry vx_base_stuff[] = {
23297 + VINF("info", S_IRUGO, vxi_info),
23298 + VINF("status", S_IRUGO, vxi_status),
23299 + VINF("limit", S_IRUGO, vxi_limit),
23300 + VINF("sched", S_IRUGO, vxi_sched),
23301 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23302 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23303 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23304 + VINF("cacct", S_IRUGO, vxi_cacct),
23311 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23312 + struct dentry *dentry, int id, void *ptr)
23314 + dentry->d_op = &proc_xid_dentry_operations;
23315 + return vs_proc_instantiate(dir, dentry, id, ptr);
23318 +static struct dentry *proc_xid_lookup(struct inode *dir,
23319 + struct dentry *dentry, struct nameidata *nd)
23321 + struct vs_entry *p = vx_base_stuff;
23322 + struct dentry *error = ERR_PTR(-ENOENT);
23324 + for (; p->name; p++) {
23325 + if (p->len != dentry->d_name.len)
23327 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23333 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23338 +static int proc_xid_readdir(struct file *filp,
23339 + void *dirent, filldir_t filldir)
23341 + struct dentry *dentry = filp->f_dentry;
23342 + struct inode *inode = dentry->d_inode;
23343 + struct vs_entry *p = vx_base_stuff;
23344 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23348 + pos = filp->f_pos;
23351 + ino = inode->i_ino;
23352 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23355 + /* fall through */
23357 + ino = parent_ino(dentry);
23358 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23361 + /* fall through */
23364 + if (index >= size)
23366 + for (p += index; p->name; p++) {
23367 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23368 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23374 + filp->f_pos = pos;
23380 +static struct file_operations proc_nx_info_file_operations = {
23381 + .read = proc_nx_info_read,
23384 +static struct dentry_operations proc_nid_dentry_operations = {
23385 + .d_revalidate = proc_nid_revalidate,
23388 +static struct vs_entry nx_base_stuff[] = {
23389 + NINF("info", S_IRUGO, nxi_info),
23390 + NINF("status", S_IRUGO, nxi_status),
23395 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23396 + struct dentry *dentry, int id, void *ptr)
23398 + dentry->d_op = &proc_nid_dentry_operations;
23399 + return vs_proc_instantiate(dir, dentry, id, ptr);
23402 +static struct dentry *proc_nid_lookup(struct inode *dir,
23403 + struct dentry *dentry, struct nameidata *nd)
23405 + struct vs_entry *p = nx_base_stuff;
23406 + struct dentry *error = ERR_PTR(-ENOENT);
23408 + for (; p->name; p++) {
23409 + if (p->len != dentry->d_name.len)
23411 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23417 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23422 +static int proc_nid_readdir(struct file *filp,
23423 + void *dirent, filldir_t filldir)
23425 + struct dentry *dentry = filp->f_dentry;
23426 + struct inode *inode = dentry->d_inode;
23427 + struct vs_entry *p = nx_base_stuff;
23428 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23432 + pos = filp->f_pos;
23435 + ino = inode->i_ino;
23436 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23439 + /* fall through */
23441 + ino = parent_ino(dentry);
23442 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23445 + /* fall through */
23448 + if (index >= size)
23450 + for (p += index; p->name; p++) {
23451 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23452 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23458 + filp->f_pos = pos;
23463 +#define MAX_MULBY10 ((~0U - 9) / 10)
23465 +static inline int atovid(const char *str, int len)
23470 + while (len-- > 0) {
23475 + if (vid >= MAX_MULBY10)
23485 +/* now the upper level (virtual) */
23488 +static struct file_operations proc_xid_file_operations = {
23489 + .read = generic_read_dir,
23490 + .readdir = proc_xid_readdir,
23493 +static struct inode_operations proc_xid_inode_operations = {
23494 + .lookup = proc_xid_lookup,
23497 +static struct vs_entry vx_virtual_stuff[] = {
23498 + INF("info", S_IRUGO, virtual_info),
23499 + INF("status", S_IRUGO, virtual_status),
23500 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23504 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23505 + struct dentry *dentry, struct nameidata *nd)
23507 + struct vs_entry *p = vx_virtual_stuff;
23508 + struct dentry *error = ERR_PTR(-ENOENT);
23511 + for (; p->name; p++) {
23512 + if (p->len != dentry->d_name.len)
23514 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23518 + goto instantiate;
23520 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23521 + if ((id < 0) || !xid_is_hashed(id))
23525 + error = proc_xid_instantiate(dir, dentry, id, p);
23530 +static struct file_operations proc_nid_file_operations = {
23531 + .read = generic_read_dir,
23532 + .readdir = proc_nid_readdir,
23535 +static struct inode_operations proc_nid_inode_operations = {
23536 + .lookup = proc_nid_lookup,
23539 +static struct vs_entry nx_virtnet_stuff[] = {
23540 + INF("info", S_IRUGO, virtnet_info),
23541 + INF("status", S_IRUGO, virtnet_status),
23542 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23546 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23547 + struct dentry *dentry, struct nameidata *nd)
23549 + struct vs_entry *p = nx_virtnet_stuff;
23550 + struct dentry *error = ERR_PTR(-ENOENT);
23553 + for (; p->name; p++) {
23554 + if (p->len != dentry->d_name.len)
23556 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23560 + goto instantiate;
23562 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23563 + if ((id < 0) || !nid_is_hashed(id))
23567 + error = proc_nid_instantiate(dir, dentry, id, p);
23573 +#define PROC_MAXVIDS 32
23575 +int proc_virtual_readdir(struct file *filp,
23576 + void *dirent, filldir_t filldir)
23578 + struct dentry *dentry = filp->f_dentry;
23579 + struct inode *inode = dentry->d_inode;
23580 + struct vs_entry *p = vx_virtual_stuff;
23581 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
23583 + unsigned int xid_array[PROC_MAXVIDS];
23584 + char buf[PROC_NUMBUF];
23585 + unsigned int nr_xids, i;
23588 + pos = filp->f_pos;
23591 + ino = inode->i_ino;
23592 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23595 + /* fall through */
23597 + ino = parent_ino(dentry);
23598 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23601 + /* fall through */
23604 + if (index >= size)
23606 + for (p += index; p->name; p++) {
23607 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23608 + vs_proc_instantiate, 0, p))
23613 + index = pos - size;
23614 + p = &vx_virtual_stuff[size - 1];
23615 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
23616 + for (i = 0; i < nr_xids; i++) {
23617 + int n, xid = xid_array[i];
23618 + unsigned int j = PROC_NUMBUF;
23622 + buf[--j] = '0' + (n % 10);
23625 + if (proc_fill_cache(filp, dirent, filldir,
23626 + buf + j, PROC_NUMBUF - j,
23627 + vs_proc_instantiate, xid, p))
23633 + filp->f_pos = pos;
23637 +static int proc_virtual_getattr(struct vfsmount *mnt,
23638 + struct dentry *dentry, struct kstat *stat)
23640 + struct inode *inode = dentry->d_inode;
23642 + generic_fillattr(inode, stat);
23643 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
23647 +static struct file_operations proc_virtual_dir_operations = {
23648 + .read = generic_read_dir,
23649 + .readdir = proc_virtual_readdir,
23652 +static struct inode_operations proc_virtual_dir_inode_operations = {
23653 + .getattr = proc_virtual_getattr,
23654 + .lookup = proc_virtual_lookup,
23661 +int proc_virtnet_readdir(struct file *filp,
23662 + void *dirent, filldir_t filldir)
23664 + struct dentry *dentry = filp->f_dentry;
23665 + struct inode *inode = dentry->d_inode;
23666 + struct vs_entry *p = nx_virtnet_stuff;
23667 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
23669 + unsigned int nid_array[PROC_MAXVIDS];
23670 + char buf[PROC_NUMBUF];
23671 + unsigned int nr_nids, i;
23674 + pos = filp->f_pos;
23677 + ino = inode->i_ino;
23678 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23681 + /* fall through */
23683 + ino = parent_ino(dentry);
23684 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23687 + /* fall through */
23690 + if (index >= size)
23692 + for (p += index; p->name; p++) {
23693 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23694 + vs_proc_instantiate, 0, p))
23699 + index = pos - size;
23700 + p = &nx_virtnet_stuff[size - 1];
23701 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
23702 + for (i = 0; i < nr_nids; i++) {
23703 + int n, nid = nid_array[i];
23704 + unsigned int j = PROC_NUMBUF;
23708 + buf[--j] = '0' + (n % 10);
23711 + if (proc_fill_cache(filp, dirent, filldir,
23712 + buf + j, PROC_NUMBUF - j,
23713 + vs_proc_instantiate, nid, p))
23719 + filp->f_pos = pos;
23723 +static int proc_virtnet_getattr(struct vfsmount *mnt,
23724 + struct dentry *dentry, struct kstat *stat)
23726 + struct inode *inode = dentry->d_inode;
23728 + generic_fillattr(inode, stat);
23729 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
23733 +static struct file_operations proc_virtnet_dir_operations = {
23734 + .read = generic_read_dir,
23735 + .readdir = proc_virtnet_readdir,
23738 +static struct inode_operations proc_virtnet_dir_inode_operations = {
23739 + .getattr = proc_virtnet_getattr,
23740 + .lookup = proc_virtnet_lookup,
23745 +void proc_vx_init(void)
23747 + struct proc_dir_entry *ent;
23749 + ent = proc_mkdir("virtual", 0);
23751 + ent->proc_fops = &proc_virtual_dir_operations;
23752 + ent->proc_iops = &proc_virtual_dir_inode_operations;
23754 + proc_virtual = ent;
23756 + ent = proc_mkdir("virtnet", 0);
23758 + ent->proc_fops = &proc_virtnet_dir_operations;
23759 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
23761 + proc_virtnet = ent;
23767 +/* per pid info */
23770 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
23772 + struct vx_info *vxi;
23773 + char *orig = buffer;
23775 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
23777 + vxi = task_get_vx_info(p);
23781 + buffer += sprintf(buffer, "BCaps:\t");
23782 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23783 + buffer += sprintf(buffer, "\n");
23784 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
23785 + (unsigned long long)vxi->vx_ccaps);
23786 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
23787 + (unsigned long long)vxi->vx_flags);
23788 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
23790 + put_vx_info(vxi);
23792 + return buffer - orig;
23796 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
23798 + struct nx_info *nxi;
23799 + struct nx_addr_v4 *v4a;
23800 +#ifdef CONFIG_IPV6
23801 + struct nx_addr_v6 *v6a;
23803 + char *orig = buffer;
23806 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
23808 + nxi = task_get_nx_info(p);
23812 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
23813 + (unsigned long long)nxi->nx_ncaps);
23814 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
23815 + (unsigned long long)nxi->nx_flags);
23817 + buffer += sprintf(buffer,
23818 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
23819 + NIPQUAD(nxi->v4_bcast.s_addr));
23820 + buffer += sprintf (buffer,
23821 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
23822 + NIPQUAD(nxi->v4_lback.s_addr));
23823 + if (!NX_IPV4(nxi))
23825 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23826 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
23829 +#ifdef CONFIG_IPV6
23830 + if (!NX_IPV6(nxi))
23832 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23833 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
23837 + put_nx_info(nxi);
23839 + return buffer - orig;
23842 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/sched.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/sched.c
23843 --- linux-2.6.27.6/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
23844 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/sched.c 2008-10-13 14:54:20.000000000 +0200
23847 + * linux/kernel/vserver/sched.c
23849 + * Virtual Server: Scheduler Support
23851 + * Copyright (C) 2004-2007 Herbert Pötzl
23853 + * V0.01 adapted Sam Vilains version to 2.6.3
23854 + * V0.02 removed legacy interface
23855 + * V0.03 changed vcmds to vxi arg
23856 + * V0.04 removed older and legacy interfaces
23860 +#include <linux/vs_context.h>
23861 +#include <linux/vs_sched.h>
23862 +#include <linux/vserver/sched_cmd.h>
23864 +#include <asm/uaccess.h>
23867 +#define vxd_check_range(val, min, max) do { \
23868 + vxlprintk((val < min) || (val > max), \
23869 + "check_range(%ld,%ld,%ld)", \
23870 + (long)val, (long)min, (long)max, \
23871 + __FILE__, __LINE__); \
23875 +void vx_update_sched_param(struct _vx_sched *sched,
23876 + struct _vx_sched_pc *sched_pc)
23878 + unsigned int set_mask = sched->update_mask;
23880 + if (set_mask & VXSM_FILL_RATE)
23881 + sched_pc->fill_rate[0] = sched->fill_rate[0];
23882 + if (set_mask & VXSM_INTERVAL)
23883 + sched_pc->interval[0] = sched->interval[0];
23884 + if (set_mask & VXSM_FILL_RATE2)
23885 + sched_pc->fill_rate[1] = sched->fill_rate[1];
23886 + if (set_mask & VXSM_INTERVAL2)
23887 + sched_pc->interval[1] = sched->interval[1];
23888 + if (set_mask & VXSM_TOKENS)
23889 + sched_pc->tokens = sched->tokens;
23890 + if (set_mask & VXSM_TOKENS_MIN)
23891 + sched_pc->tokens_min = sched->tokens_min;
23892 + if (set_mask & VXSM_TOKENS_MAX)
23893 + sched_pc->tokens_max = sched->tokens_max;
23894 + if (set_mask & VXSM_PRIO_BIAS)
23895 + sched_pc->prio_bias = sched->prio_bias;
23897 + if (set_mask & VXSM_IDLE_TIME)
23898 + sched_pc->flags |= VXSF_IDLE_TIME;
23900 + sched_pc->flags &= ~VXSF_IDLE_TIME;
23903 + sched_pc->norm_time = jiffies;
23908 + * recalculate the context's scheduling tokens
23910 + * ret > 0 : number of tokens available
23911 + * ret < 0 : on hold, check delta_min[]
23912 + * -1 only jiffies
23913 + * -2 also idle time
23916 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
23917 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
23921 + int flags = sched_pc->flags;
23923 + /* how much time did pass? */
23924 + delta = *norm_time - sched_pc->norm_time;
23925 + vxd_check_range(delta, 0, INT_MAX);
23927 + if (delta >= sched_pc->interval[0]) {
23928 + long tokens, integral;
23930 + /* calc integral token part */
23931 + tokens = delta / sched_pc->interval[0];
23932 + integral = tokens * sched_pc->interval[0];
23933 + tokens *= sched_pc->fill_rate[0];
23934 +#ifdef CONFIG_VSERVER_HARDCPU
23935 + delta_min[0] = delta - integral;
23936 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
23938 + /* advance time */
23939 + sched_pc->norm_time += delta;
23942 + sched_pc->tokens += tokens;
23943 + sched_pc->token_time += tokens;
23945 + delta_min[0] = delta;
23947 +#ifdef CONFIG_VSERVER_IDLETIME
23948 + if (!(flags & VXSF_IDLE_TIME))
23951 + /* how much was the idle skip? */
23952 + delta = *idle_time - sched_pc->idle_time;
23953 + vxd_check_range(delta, 0, INT_MAX);
23955 + if (delta >= sched_pc->interval[1]) {
23956 + long tokens, integral;
23958 + /* calc fair share token part */
23959 + tokens = delta / sched_pc->interval[1];
23960 + integral = tokens * sched_pc->interval[1];
23961 + tokens *= sched_pc->fill_rate[1];
23962 + delta_min[1] = delta - integral;
23963 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
23965 + /* advance idle time */
23966 + sched_pc->idle_time += integral;
23969 + sched_pc->tokens += tokens;
23970 + sched_pc->token_time += tokens;
23972 + delta_min[1] = delta;
23976 + /* clip at maximum */
23977 + if (sched_pc->tokens > sched_pc->tokens_max)
23978 + sched_pc->tokens = sched_pc->tokens_max;
23979 + tokens = sched_pc->tokens;
23981 + if ((flags & VXSF_ONHOLD)) {
23982 + /* can we unhold? */
23983 + if (tokens >= sched_pc->tokens_min) {
23984 + flags &= ~VXSF_ONHOLD;
23985 + sched_pc->hold_ticks +=
23986 + *norm_time - sched_pc->onhold;
23990 + /* put on hold? */
23991 + if (tokens <= 0) {
23992 + flags |= VXSF_ONHOLD;
23993 + sched_pc->onhold = *norm_time;
23997 + sched_pc->flags = flags;
24001 + tokens = sched_pc->tokens_min - tokens;
24002 + sched_pc->flags = flags;
24003 + BUG_ON(tokens < 0);
24005 +#ifdef CONFIG_VSERVER_HARDCPU
24006 + /* next interval? */
24007 + if (!sched_pc->fill_rate[0])
24008 + delta_min[0] = HZ;
24009 + else if (tokens > sched_pc->fill_rate[0])
24010 + delta_min[0] += sched_pc->interval[0] *
24011 + tokens / sched_pc->fill_rate[0];
24013 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
24014 + vxd_check_range(delta_min[0], 0, INT_MAX);
24016 +#ifdef CONFIG_VSERVER_IDLETIME
24017 + if (!(flags & VXSF_IDLE_TIME))
24020 + /* next interval? */
24021 + if (!sched_pc->fill_rate[1])
24022 + delta_min[1] = HZ;
24023 + else if (tokens > sched_pc->fill_rate[1])
24024 + delta_min[1] += sched_pc->interval[1] *
24025 + tokens / sched_pc->fill_rate[1];
24027 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
24028 + vxd_check_range(delta_min[1], 0, INT_MAX);
24033 +#endif /* CONFIG_VSERVER_IDLETIME */
24036 +#endif /* CONFIG_VSERVER_HARDCPU */
24039 +static inline unsigned long msec_to_ticks(unsigned long msec)
24041 + return msecs_to_jiffies(msec);
24044 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24046 + return jiffies_to_msecs(ticks);
24049 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24051 + return jiffies_to_usecs(ticks);
24055 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24057 + unsigned int set_mask = data->mask;
24058 + unsigned int update_mask;
24061 + /* Sanity check data values */
24062 + if (data->tokens_max <= 0)
24063 + data->tokens_max = HZ;
24064 + if (data->tokens_min < 0)
24065 + data->tokens_min = HZ / 3;
24066 + if (data->tokens_min >= data->tokens_max)
24067 + data->tokens_min = data->tokens_max;
24069 + if (data->prio_bias > MAX_PRIO_BIAS)
24070 + data->prio_bias = MAX_PRIO_BIAS;
24071 + if (data->prio_bias < MIN_PRIO_BIAS)
24072 + data->prio_bias = MIN_PRIO_BIAS;
24074 + spin_lock(&vxi->sched.tokens_lock);
24076 + /* sync up on delayed updates */
24077 + for_each_cpu_mask(cpu, vxi->sched.update)
24078 + vx_update_sched_param(&vxi->sched,
24079 + &vx_per_cpu(vxi, sched_pc, cpu));
24081 + if (set_mask & VXSM_FILL_RATE)
24082 + vxi->sched.fill_rate[0] = data->fill_rate[0];
24083 + if (set_mask & VXSM_FILL_RATE2)
24084 + vxi->sched.fill_rate[1] = data->fill_rate[1];
24085 + if (set_mask & VXSM_INTERVAL)
24086 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24087 + msec_to_ticks(data->interval[0]) : data->interval[0];
24088 + if (set_mask & VXSM_INTERVAL2)
24089 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24090 + msec_to_ticks(data->interval[1]) : data->interval[1];
24091 + if (set_mask & VXSM_TOKENS)
24092 + vxi->sched.tokens = data->tokens;
24093 + if (set_mask & VXSM_TOKENS_MIN)
24094 + vxi->sched.tokens_min = data->tokens_min;
24095 + if (set_mask & VXSM_TOKENS_MAX)
24096 + vxi->sched.tokens_max = data->tokens_max;
24097 + if (set_mask & VXSM_PRIO_BIAS)
24098 + vxi->sched.prio_bias = data->prio_bias;
24100 + /* Sanity check rate/interval */
24101 + for (i = 0; i < 2; i++) {
24102 + if (data->fill_rate[i] < 0)
24103 + data->fill_rate[i] = 0;
24104 + if (data->interval[i] <= 0)
24105 + data->interval[i] = HZ;
24108 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24109 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24110 + vxi->sched.update_mask = update_mask;
24114 + if (set_mask & VXSM_CPU_ID) {
24115 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24116 + cpus_and(vxi->sched.update, cpu_online_map,
24117 + vxi->sched.update);
24119 + vxi->sched.update = cpu_online_map;
24121 + /* forced reload? */
24122 + if (set_mask & VXSM_FORCE) {
24123 + for_each_cpu_mask(cpu, vxi->sched.update)
24124 + vx_update_sched_param(&vxi->sched,
24125 + &vx_per_cpu(vxi, sched_pc, cpu));
24126 + vxi->sched.update = CPU_MASK_NONE;
24129 + /* on UP we update immediately */
24130 + vx_update_sched_param(&vxi->sched,
24131 + &vx_per_cpu(vxi, sched_pc, 0));
24134 + spin_unlock(&vxi->sched.tokens_lock);
24139 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24140 +#define COPY_PRI(C) C(prio_bias)
24141 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24142 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24143 + C(fill_rate[1]); C(interval[1]);
24145 +#define COPY_VALUE(name) vc_data.name = data->name
24147 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24149 + struct vcmd_sched_v5 vc_data;
24151 + vc_data.mask = data->set_mask;
24152 + COPY_IDS(COPY_VALUE);
24153 + COPY_PRI(COPY_VALUE);
24154 + COPY_TOK(COPY_VALUE);
24155 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24156 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
24157 + return do_set_sched(vxi, &vc_data);
24160 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24162 + struct vcmd_set_sched_v4 vc_data;
24164 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24167 + return do_set_sched_v4(vxi, &vc_data);
24170 + /* latest interface is v5 */
24172 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24174 + struct vcmd_sched_v5 vc_data;
24176 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24179 + return do_set_sched(vxi, &vc_data);
24183 +#define COPY_PRI(C) C(prio_bias)
24184 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24185 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24186 + C(fill_rate[1]); C(interval[1]);
24188 +#define COPY_VALUE(name) vc_data.name = data->name
24191 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24193 + struct vcmd_sched_v5 vc_data;
24195 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24198 + if (vc_data.mask & VXSM_CPU_ID) {
24199 + int cpu = vc_data.cpu_id;
24200 + struct _vx_sched_pc *data;
24202 + if (!cpu_possible(cpu))
24205 + data = &vx_per_cpu(vxi, sched_pc, cpu);
24206 + COPY_TOK(COPY_VALUE);
24207 + COPY_PRI(COPY_VALUE);
24208 + COPY_FRI(COPY_VALUE);
24210 + if (data->flags & VXSF_IDLE_TIME)
24211 + vc_data.mask |= VXSM_IDLE_TIME;
24213 + struct _vx_sched *data = &vxi->sched;
24215 + COPY_TOK(COPY_VALUE);
24216 + COPY_PRI(COPY_VALUE);
24217 + COPY_FRI(COPY_VALUE);
24220 + if (vc_data.mask & VXSM_MSEC) {
24221 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24222 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24225 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24231 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24233 + struct vcmd_sched_info vc_data;
24236 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24239 + cpu = vc_data.cpu_id;
24240 + if (!cpu_possible(cpu))
24244 + struct _vx_sched_pc *sched_pc =
24245 + &vx_per_cpu(vxi, sched_pc, cpu);
24247 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24248 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24249 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24250 + vc_data.vavavoom = sched_pc->vavavoom;
24252 + vc_data.token_usec = ticks_to_usec(1);
24254 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24259 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/sched_init.h linux-2.6.27.6-vs2.3.0.36/kernel/vserver/sched_init.h
24260 --- linux-2.6.27.6/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24261 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/sched_init.h 2008-10-13 14:54:20.000000000 +0200
24264 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24266 + static struct lock_class_key tokens_lock_key;
24268 + /* scheduling; hard code starting values as constants */
24269 + sched->fill_rate[0] = 1;
24270 + sched->interval[0] = 4;
24271 + sched->fill_rate[1] = 1;
24272 + sched->interval[1] = 8;
24273 + sched->tokens = HZ >> 2;
24274 + sched->tokens_min = HZ >> 4;
24275 + sched->tokens_max = HZ >> 1;
24276 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24277 + sched->prio_bias = 0;
24279 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24283 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24285 + sched_pc->fill_rate[0] = 1;
24286 + sched_pc->interval[0] = 4;
24287 + sched_pc->fill_rate[1] = 1;
24288 + sched_pc->interval[1] = 8;
24289 + sched_pc->tokens = HZ >> 2;
24290 + sched_pc->tokens_min = HZ >> 4;
24291 + sched_pc->tokens_max = HZ >> 1;
24292 + sched_pc->prio_bias = 0;
24293 + sched_pc->vavavoom = 0;
24294 + sched_pc->token_time = 0;
24295 + sched_pc->idle_time = 0;
24296 + sched_pc->norm_time = jiffies;
24298 + sched_pc->user_ticks = 0;
24299 + sched_pc->sys_ticks = 0;
24300 + sched_pc->hold_ticks = 0;
24303 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24309 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24313 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/sched_proc.h linux-2.6.27.6-vs2.3.0.36/kernel/vserver/sched_proc.h
24314 --- linux-2.6.27.6/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24315 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/sched_proc.h 2008-10-13 14:54:20.000000000 +0200
24317 +#ifndef _VX_SCHED_PROC_H
24318 +#define _VX_SCHED_PROC_H
24322 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24326 + length += sprintf(buffer,
24327 + "FillRate:\t%8d,%d\n"
24328 + "Interval:\t%8d,%d\n"
24329 + "TokensMin:\t%8d\n"
24330 + "TokensMax:\t%8d\n"
24331 + "PrioBias:\t%8d\n",
24332 + sched->fill_rate[0],
24333 + sched->fill_rate[1],
24334 + sched->interval[0],
24335 + sched->interval[1],
24336 + sched->tokens_min,
24337 + sched->tokens_max,
24338 + sched->prio_bias);
24343 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24344 + char *buffer, int cpu)
24348 + length += sprintf(buffer + length,
24349 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24350 + (unsigned long long)sched_pc->user_ticks,
24351 + (unsigned long long)sched_pc->sys_ticks,
24352 + (unsigned long long)sched_pc->hold_ticks,
24353 + sched_pc->token_time,
24354 + sched_pc->idle_time);
24355 + length += sprintf(buffer + length,
24356 + " %c%c %d %d %d %d/%d %d/%d",
24357 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24358 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24359 + sched_pc->tokens,
24360 + sched_pc->tokens_min,
24361 + sched_pc->tokens_max,
24362 + sched_pc->fill_rate[0],
24363 + sched_pc->interval[0],
24364 + sched_pc->fill_rate[1],
24365 + sched_pc->interval[1]);
24366 + length += sprintf(buffer + length,
24368 + sched_pc->prio_bias,
24369 + sched_pc->vavavoom);
24373 +#endif /* _VX_SCHED_PROC_H */
24374 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/signal.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/signal.c
24375 --- linux-2.6.27.6/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24376 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/signal.c 2008-10-13 14:54:20.000000000 +0200
24379 + * linux/kernel/vserver/signal.c
24381 + * Virtual Server: Signal Support
24383 + * Copyright (C) 2003-2007 Herbert Pötzl
24385 + * V0.01 broken out from vcontext V0.05
24386 + * V0.02 changed vcmds to vxi arg
24387 + * V0.03 adjusted siginfo for kill
24391 +#include <asm/uaccess.h>
24393 +#include <linux/vs_context.h>
24394 +#include <linux/vs_pid.h>
24395 +#include <linux/vserver/signal_cmd.h>
24398 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24400 + int retval, count = 0;
24401 + struct task_struct *p;
24402 + struct siginfo *sip = SEND_SIG_PRIV;
24405 + vxdprintk(VXD_CBIT(misc, 4),
24406 + "vx_info_kill(%p[#%d],%d,%d)*",
24407 + vxi, vxi->vx_id, pid, sig);
24408 + read_lock(&tasklist_lock);
24412 + for_each_process(p) {
24415 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24416 + (pid && vxi->vx_initpid == p->pid))
24419 + err = group_send_sig_info(sig, sip, p);
24421 + if (err != -EPERM)
24427 + if (vxi->vx_initpid) {
24428 + pid = vxi->vx_initpid;
24429 + /* for now, only SIGINT to private init ... */
24430 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24431 + /* ... as long as there are tasks left */
24432 + (atomic_read(&vxi->vx_tasks) > 1))
24435 + /* fallthrough */
24437 + p = find_task_by_real_pid(pid);
24439 + if (vx_task_xid(p) == vxi->vx_id)
24440 + retval = group_send_sig_info(sig, sip, p);
24444 + read_unlock(&tasklist_lock);
24445 + vxdprintk(VXD_CBIT(misc, 4),
24446 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24447 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24451 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24453 + struct vcmd_ctx_kill_v0 vc_data;
24455 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24458 + /* special check to allow guest shutdown */
24459 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24460 + /* forbid killall pid=0 when init is present */
24461 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24462 + (vc_data.pid > 1)))
24465 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24469 +static int __wait_exit(struct vx_info *vxi)
24471 + DECLARE_WAITQUEUE(wait, current);
24474 + add_wait_queue(&vxi->vx_wait, &wait);
24475 + set_current_state(TASK_INTERRUPTIBLE);
24478 + if (vx_info_state(vxi,
24479 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24481 + if (signal_pending(current)) {
24482 + ret = -ERESTARTSYS;
24489 + set_current_state(TASK_RUNNING);
24490 + remove_wait_queue(&vxi->vx_wait, &wait);
24496 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24498 + struct vcmd_wait_exit_v0 vc_data;
24501 + ret = __wait_exit(vxi);
24502 + vc_data.reboot_cmd = vxi->reboot_cmd;
24503 + vc_data.exit_code = vxi->exit_code;
24505 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24510 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/space.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/space.c
24511 --- linux-2.6.27.6/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24512 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/space.c 2008-10-31 18:15:28.000000000 +0100
24515 + * linux/kernel/vserver/space.c
24517 + * Virtual Server: Context Space Support
24519 + * Copyright (C) 2003-2007 Herbert Pötzl
24521 + * V0.01 broken out from context.c 0.07
24522 + * V0.02 added task locking for namespace
24523 + * V0.03 broken out vx_enter_namespace
24524 + * V0.04 added *space support and commands
24528 +#include <linux/utsname.h>
24529 +#include <linux/nsproxy.h>
24530 +#include <linux/err.h>
24531 +#include <asm/uaccess.h>
24533 +#include <linux/vs_context.h>
24534 +#include <linux/vserver/space.h>
24535 +#include <linux/vserver/space_cmd.h>
24537 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24538 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24539 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24540 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24541 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
24542 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24543 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24546 +/* namespace functions */
24548 +#include <linux/mnt_namespace.h>
24549 +#include <linux/user_namespace.h>
24550 +#include <linux/pid_namespace.h>
24551 +#include <linux/ipc_namespace.h>
24552 +#include <net/net_namespace.h>
24555 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24556 + .mask = CLONE_FS |
24564 +static const struct vcmd_space_mask_v1 space_mask = {
24565 + .mask = CLONE_FS |
24570 +#ifdef CONFIG_PID_NS
24573 +#ifdef CONFIG_NET_NS
24579 +static const struct vcmd_space_mask_v1 default_space_mask = {
24580 + .mask = CLONE_FS |
24585 +#ifdef CONFIG_PID_NS
24592 + * build a new nsproxy mix
24593 + * assumes that both proxies are 'const'
24594 + * does not touch nsproxy refcounts
24595 + * will hold a reference on the result.
24598 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
24599 + struct nsproxy *new_nsproxy, unsigned long mask)
24601 + struct mnt_namespace *old_ns;
24602 + struct uts_namespace *old_uts;
24603 + struct ipc_namespace *old_ipc;
24604 + struct user_namespace *old_user;
24605 +#ifdef CONFIG_PID_NS
24606 + struct pid_namespace *old_pid;
24608 +#ifdef CONFIG_NET_NS
24609 + struct net *old_net;
24611 + struct nsproxy *nsproxy;
24613 + nsproxy = copy_nsproxy(old_nsproxy);
24617 + if (mask & CLONE_NEWNS) {
24618 + old_ns = nsproxy->mnt_ns;
24619 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
24620 + if (nsproxy->mnt_ns)
24621 + get_mnt_ns(nsproxy->mnt_ns);
24625 + if (mask & CLONE_NEWUTS) {
24626 + old_uts = nsproxy->uts_ns;
24627 + nsproxy->uts_ns = new_nsproxy->uts_ns;
24628 + if (nsproxy->uts_ns)
24629 + get_uts_ns(nsproxy->uts_ns);
24633 + if (mask & CLONE_NEWIPC) {
24634 + old_ipc = nsproxy->ipc_ns;
24635 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
24636 + if (nsproxy->ipc_ns)
24637 + get_ipc_ns(nsproxy->ipc_ns);
24641 + if (mask & CLONE_NEWUSER) {
24642 + old_user = nsproxy->user_ns;
24643 + nsproxy->user_ns = new_nsproxy->user_ns;
24644 + if (nsproxy->user_ns)
24645 + get_user_ns(nsproxy->user_ns);
24649 +#ifdef CONFIG_PID_NS
24650 + if (mask & CLONE_NEWPID) {
24651 + old_pid = nsproxy->pid_ns;
24652 + nsproxy->pid_ns = new_nsproxy->pid_ns;
24653 + if (nsproxy->pid_ns)
24654 + get_pid_ns(nsproxy->pid_ns);
24658 +#ifdef CONFIG_NET_NS
24659 + if (mask & CLONE_NEWNET) {
24660 + old_net = nsproxy->net_ns;
24661 + nsproxy->net_ns = new_nsproxy->net_ns;
24662 + if (nsproxy->net_ns)
24663 + get_net(nsproxy->net_ns);
24668 + put_mnt_ns(old_ns);
24670 + put_uts_ns(old_uts);
24672 + put_ipc_ns(old_ipc);
24674 + put_user_ns(old_user);
24675 +#ifdef CONFIG_PID_NS
24677 + put_pid_ns(old_pid);
24679 +#ifdef CONFIG_NET_NS
24681 + put_net(old_net);
24689 + * merge two nsproxy structs into a new one.
24690 + * will hold a reference on the result.
24694 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24695 + struct nsproxy *proxy, unsigned long mask)
24697 + struct nsproxy null_proxy = { .mnt_ns = NULL };
24703 + /* vs_mix_nsproxy returns with reference */
24704 + return vs_mix_nsproxy(old ? old : &null_proxy,
24707 + get_nsproxy(proxy);
24712 + * merge two fs structs into a new one.
24713 + * will take a reference on the result.
24717 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
24718 + struct fs_struct *fs, unsigned long mask)
24720 + if (!(mask & CLONE_FS)) {
24722 + atomic_inc(&old->count);
24729 + return copy_fs_struct(fs);
24733 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24735 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24736 + struct fs_struct *fs, *fs_cur, *fs_new;
24739 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
24740 + vxi, vxi->vx_id, mask, index);
24742 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24746 + mask = vxi->vx_nsmask[index];
24748 + if ((mask & vxi->vx_nsmask[index]) != mask)
24751 + proxy = vxi->vx_nsproxy[index];
24752 + fs = vxi->vx_fs[index];
24754 + task_lock(current);
24755 + fs_cur = current->fs;
24756 + atomic_inc(&fs_cur->count);
24757 + proxy_cur = current->nsproxy;
24758 + get_nsproxy(proxy_cur);
24759 + task_unlock(current);
24761 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
24762 + if (IS_ERR(fs_new)) {
24763 + ret = PTR_ERR(fs_new);
24767 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24768 + if (IS_ERR(proxy_new)) {
24769 + ret = PTR_ERR(proxy_new);
24773 + fs_new = xchg(¤t->fs, fs_new);
24774 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24778 + put_nsproxy(proxy_new);
24781 + put_fs_struct(fs_new);
24784 + put_nsproxy(proxy_cur);
24786 + put_fs_struct(fs_cur);
24791 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24793 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24794 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
24797 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
24798 + vxi, vxi->vx_id, mask, index);
24801 + mask = default_space_mask.mask;
24803 + if ((mask & space_mask.mask) != mask)
24806 + proxy_vxi = vxi->vx_nsproxy[index];
24807 + fs_vxi = vxi->vx_fs[index];
24809 + task_lock(current);
24810 + fs_cur = current->fs;
24811 + atomic_inc(&fs_cur->count);
24812 + proxy_cur = current->nsproxy;
24813 + get_nsproxy(proxy_cur);
24814 + task_unlock(current);
24816 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
24817 + if (IS_ERR(fs_new)) {
24818 + ret = PTR_ERR(fs_new);
24822 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24823 + if (IS_ERR(proxy_new)) {
24824 + ret = PTR_ERR(proxy_new);
24828 + fs_new = xchg(&vxi->vx_fs[index], fs_new);
24829 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
24830 + vxi->vx_nsmask[index] |= mask;
24834 + put_nsproxy(proxy_new);
24837 + put_fs_struct(fs_new);
24840 + put_nsproxy(proxy_cur);
24842 + put_fs_struct(fs_cur);
24847 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
24849 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24851 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24854 + return vx_enter_space(vxi, vc_data.mask, 0);
24857 +int vc_enter_space(struct vx_info *vxi, void __user *data)
24859 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24861 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24864 + if (vc_data.index >= VX_SPACES)
24867 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
24870 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
24872 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24874 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24877 + return vx_set_space(vxi, vc_data.mask, 0);
24880 +int vc_set_space(struct vx_info *vxi, void __user *data)
24882 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24884 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24887 + if (vc_data.index >= VX_SPACES)
24890 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
24893 +int vc_get_space_mask(void __user *data, int type)
24895 + const struct vcmd_space_mask_v1 *mask;
24898 + mask = &space_mask_v0;
24899 + else if (type == 1)
24900 + mask = &space_mask;
24902 + mask = &default_space_mask;
24904 + vxdprintk(VXD_CBIT(space, 10),
24905 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
24907 + if (copy_to_user(data, mask, sizeof(*mask)))
24912 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/switch.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/switch.c
24913 --- linux-2.6.27.6/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
24914 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/switch.c 2008-10-31 04:42:36.000000000 +0100
24917 + * linux/kernel/vserver/switch.c
24919 + * Virtual Server: Syscall Switch
24921 + * Copyright (C) 2003-2007 Herbert Pötzl
24923 + * V0.01 syscall switch
24924 + * V0.02 added signal to context
24925 + * V0.03 added rlimit functions
24926 + * V0.04 added iattr, task/xid functions
24927 + * V0.05 added debug/history stuff
24928 + * V0.06 added compat32 layer
24929 + * V0.07 vcmd args and perms
24930 + * V0.08 added status commands
24931 + * V0.09 added tag commands
24932 + * V0.10 added oom bias
24933 + * V0.11 added device commands
24937 +#include <linux/vs_context.h>
24938 +#include <linux/vs_network.h>
24939 +#include <linux/vserver/switch.h>
24941 +#include "vci_config.h"
24945 +int vc_get_version(uint32_t id)
24947 + return VCI_VERSION;
24951 +int vc_get_vci(uint32_t id)
24953 + return vci_kernel_config();
24956 +#include <linux/vserver/context_cmd.h>
24957 +#include <linux/vserver/cvirt_cmd.h>
24958 +#include <linux/vserver/cacct_cmd.h>
24959 +#include <linux/vserver/limit_cmd.h>
24960 +#include <linux/vserver/network_cmd.h>
24961 +#include <linux/vserver/sched_cmd.h>
24962 +#include <linux/vserver/debug_cmd.h>
24963 +#include <linux/vserver/inode_cmd.h>
24964 +#include <linux/vserver/dlimit_cmd.h>
24965 +#include <linux/vserver/signal_cmd.h>
24966 +#include <linux/vserver/space_cmd.h>
24967 +#include <linux/vserver/tag_cmd.h>
24968 +#include <linux/vserver/device_cmd.h>
24970 +#include <linux/vserver/inode.h>
24971 +#include <linux/vserver/dlimit.h>
24974 +#ifdef CONFIG_COMPAT
24975 +#define __COMPAT(name, id, data, compat) \
24976 + (compat) ? name ## _x32(id, data) : name(id, data)
24977 +#define __COMPAT_NO_ID(name, data, compat) \
24978 + (compat) ? name ## _x32(data) : name(data)
24980 +#define __COMPAT(name, id, data, compat) \
24982 +#define __COMPAT_NO_ID(name, data, compat) \
24988 +long do_vcmd(uint32_t cmd, uint32_t id,
24989 + struct vx_info *vxi, struct nx_info *nxi,
24990 + void __user *data, int compat)
24994 + case VCMD_get_version:
24995 + return vc_get_version(id);
24996 + case VCMD_get_vci:
24997 + return vc_get_vci(id);
24999 + case VCMD_task_xid:
25000 + return vc_task_xid(id);
25001 + case VCMD_vx_info:
25002 + return vc_vx_info(vxi, data);
25004 + case VCMD_task_nid:
25005 + return vc_task_nid(id);
25006 + case VCMD_nx_info:
25007 + return vc_nx_info(nxi, data);
25009 + case VCMD_task_tag:
25010 + return vc_task_tag(id);
25012 + case VCMD_set_space_v1:
25013 + return vc_set_space_v1(vxi, data);
25014 + /* this is version 2 */
25015 + case VCMD_set_space:
25016 + return vc_set_space(vxi, data);
25018 + case VCMD_get_space_mask_v0:
25019 + return vc_get_space_mask(data, 0);
25020 + /* this is version 1 */
25021 + case VCMD_get_space_mask:
25022 + return vc_get_space_mask(data, 1);
25024 + case VCMD_get_space_default:
25025 + return vc_get_space_mask(data, -1);
25027 +#ifdef CONFIG_IA32_EMULATION
25028 + case VCMD_get_rlimit:
25029 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
25030 + case VCMD_set_rlimit:
25031 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
25033 + case VCMD_get_rlimit:
25034 + return vc_get_rlimit(vxi, data);
25035 + case VCMD_set_rlimit:
25036 + return vc_set_rlimit(vxi, data);
25038 + case VCMD_get_rlimit_mask:
25039 + return vc_get_rlimit_mask(id, data);
25040 + case VCMD_reset_minmax:
25041 + return vc_reset_minmax(vxi, data);
25043 + case VCMD_get_vhi_name:
25044 + return vc_get_vhi_name(vxi, data);
25045 + case VCMD_set_vhi_name:
25046 + return vc_set_vhi_name(vxi, data);
25048 + case VCMD_ctx_stat:
25049 + return vc_ctx_stat(vxi, data);
25050 + case VCMD_virt_stat:
25051 + return vc_virt_stat(vxi, data);
25052 + case VCMD_sock_stat:
25053 + return vc_sock_stat(vxi, data);
25054 + case VCMD_rlimit_stat:
25055 + return vc_rlimit_stat(vxi, data);
25057 + case VCMD_set_cflags:
25058 + return vc_set_cflags(vxi, data);
25059 + case VCMD_get_cflags:
25060 + return vc_get_cflags(vxi, data);
25062 + /* this is version 1 */
25063 + case VCMD_set_ccaps:
25064 + return vc_set_ccaps(vxi, data);
25065 + /* this is version 1 */
25066 + case VCMD_get_ccaps:
25067 + return vc_get_ccaps(vxi, data);
25068 + case VCMD_set_bcaps:
25069 + return vc_set_bcaps(vxi, data);
25070 + case VCMD_get_bcaps:
25071 + return vc_get_bcaps(vxi, data);
25073 + case VCMD_set_badness:
25074 + return vc_set_badness(vxi, data);
25075 + case VCMD_get_badness:
25076 + return vc_get_badness(vxi, data);
25078 + case VCMD_set_nflags:
25079 + return vc_set_nflags(nxi, data);
25080 + case VCMD_get_nflags:
25081 + return vc_get_nflags(nxi, data);
25083 + case VCMD_set_ncaps:
25084 + return vc_set_ncaps(nxi, data);
25085 + case VCMD_get_ncaps:
25086 + return vc_get_ncaps(nxi, data);
25088 + case VCMD_set_sched_v4:
25089 + return vc_set_sched_v4(vxi, data);
25090 + /* this is version 5 */
25091 + case VCMD_set_sched:
25092 + return vc_set_sched(vxi, data);
25093 + case VCMD_get_sched:
25094 + return vc_get_sched(vxi, data);
25095 + case VCMD_sched_info:
25096 + return vc_sched_info(vxi, data);
25098 + case VCMD_add_dlimit:
25099 + return __COMPAT(vc_add_dlimit, id, data, compat);
25100 + case VCMD_rem_dlimit:
25101 + return __COMPAT(vc_rem_dlimit, id, data, compat);
25102 + case VCMD_set_dlimit:
25103 + return __COMPAT(vc_set_dlimit, id, data, compat);
25104 + case VCMD_get_dlimit:
25105 + return __COMPAT(vc_get_dlimit, id, data, compat);
25107 + case VCMD_ctx_kill:
25108 + return vc_ctx_kill(vxi, data);
25110 + case VCMD_wait_exit:
25111 + return vc_wait_exit(vxi, data);
25113 + case VCMD_get_iattr:
25114 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25115 + case VCMD_set_iattr:
25116 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25118 + case VCMD_fget_iattr:
25119 + return vc_fget_iattr(id, data);
25120 + case VCMD_fset_iattr:
25121 + return vc_fset_iattr(id, data);
25123 + case VCMD_enter_space_v0:
25124 + return vc_enter_space_v1(vxi, NULL);
25125 + case VCMD_enter_space_v1:
25126 + return vc_enter_space_v1(vxi, data);
25127 + /* this is version 2 */
25128 + case VCMD_enter_space:
25129 + return vc_enter_space(vxi, data);
25131 + case VCMD_ctx_create_v0:
25132 + return vc_ctx_create(id, NULL);
25133 + case VCMD_ctx_create:
25134 + return vc_ctx_create(id, data);
25135 + case VCMD_ctx_migrate_v0:
25136 + return vc_ctx_migrate(vxi, NULL);
25137 + case VCMD_ctx_migrate:
25138 + return vc_ctx_migrate(vxi, data);
25140 + case VCMD_net_create_v0:
25141 + return vc_net_create(id, NULL);
25142 + case VCMD_net_create:
25143 + return vc_net_create(id, data);
25144 + case VCMD_net_migrate:
25145 + return vc_net_migrate(nxi, data);
25147 + case VCMD_tag_migrate:
25148 + return vc_tag_migrate(id);
25150 + case VCMD_net_add:
25151 + return vc_net_add(nxi, data);
25152 + case VCMD_net_remove:
25153 + return vc_net_remove(nxi, data);
25155 + case VCMD_net_add_ipv4:
25156 + return vc_net_add_ipv4(nxi, data);
25157 + case VCMD_net_remove_ipv4:
25158 + return vc_net_remove_ipv4(nxi, data);
25159 +#ifdef CONFIG_IPV6
25160 + case VCMD_net_add_ipv6:
25161 + return vc_net_add_ipv6(nxi, data);
25162 + case VCMD_net_remove_ipv6:
25163 + return vc_net_remove_ipv6(nxi, data);
25165 +/* case VCMD_add_match_ipv4:
25166 + return vc_add_match_ipv4(nxi, data);
25167 + case VCMD_get_match_ipv4:
25168 + return vc_get_match_ipv4(nxi, data);
25169 +#ifdef CONFIG_IPV6
25170 + case VCMD_add_match_ipv6:
25171 + return vc_add_match_ipv6(nxi, data);
25172 + case VCMD_get_match_ipv6:
25173 + return vc_get_match_ipv6(nxi, data);
25176 +#ifdef CONFIG_VSERVER_DEVICE
25177 + case VCMD_set_mapping:
25178 + return __COMPAT(vc_set_mapping, vxi, data, compat);
25179 + case VCMD_unset_mapping:
25180 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
25182 +#ifdef CONFIG_VSERVER_HISTORY
25183 + case VCMD_dump_history:
25184 + return vc_dump_history(id);
25185 + case VCMD_read_history:
25186 + return __COMPAT(vc_read_history, id, data, compat);
25188 +#ifdef CONFIG_VSERVER_MONITOR
25189 + case VCMD_read_monitor:
25190 + return __COMPAT(vc_read_monitor, id, data, compat);
25193 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25194 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25200 +#define __VCMD(vcmd, _perm, _args, _flags) \
25201 + case VCMD_ ## vcmd: perm = _perm; \
25202 + args = _args; flags = _flags; break
25205 +#define VCA_NONE 0x00
25206 +#define VCA_VXI 0x01
25207 +#define VCA_NXI 0x02
25209 +#define VCF_NONE 0x00
25210 +#define VCF_INFO 0x01
25211 +#define VCF_ADMIN 0x02
25212 +#define VCF_ARES 0x06 /* includes admin */
25213 +#define VCF_SETUP 0x08
25215 +#define VCF_ZIDOK 0x10 /* zero id okay */
25219 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25222 + int permit = -1, state = 0;
25223 + int perm = -1, args = 0, flags = 0;
25224 + struct vx_info *vxi = NULL;
25225 + struct nx_info *nxi = NULL;
25228 + /* unpriviledged commands */
25229 + __VCMD(get_version, 0, VCA_NONE, 0);
25230 + __VCMD(get_vci, 0, VCA_NONE, 0);
25231 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25232 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
25233 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25234 + __VCMD(get_space_default,0, VCA_NONE, 0);
25236 + /* info commands */
25237 + __VCMD(task_xid, 2, VCA_NONE, 0);
25238 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25239 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25240 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25241 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25242 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25243 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
25244 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25245 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25247 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25248 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25249 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25250 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25252 + __VCMD(task_nid, 2, VCA_NONE, 0);
25253 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25254 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25255 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25257 + __VCMD(task_tag, 2, VCA_NONE, 0);
25259 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25260 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25261 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25262 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
25263 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
25265 + /* lower admin commands */
25266 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25267 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25268 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25269 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25270 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25271 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25272 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25273 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25275 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25276 + __VCMD(net_create, 5, VCA_NONE, 0);
25277 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25279 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25281 + /* higher admin commands */
25282 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25283 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25284 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25286 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25287 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25288 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25289 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25291 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25292 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25293 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25294 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25296 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25297 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25298 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25299 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25300 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25301 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25302 +#ifdef CONFIG_IPV6
25303 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25304 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25306 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25307 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25308 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25309 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25310 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25312 +#ifdef CONFIG_VSERVER_DEVICE
25313 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25314 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25316 + /* debug level admin commands */
25317 +#ifdef CONFIG_VSERVER_HISTORY
25318 + __VCMD(dump_history, 9, VCA_NONE, 0);
25319 + __VCMD(read_history, 9, VCA_NONE, 0);
25321 +#ifdef CONFIG_VSERVER_MONITOR
25322 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25329 + vxdprintk(VXD_CBIT(switch, 0),
25330 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25331 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25332 + VC_VERSION(cmd), id, data, compat,
25333 + perm, args, flags);
25340 + if (!capable(CAP_CONTEXT))
25344 + /* moved here from the individual commands */
25346 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25350 + /* vcmd involves resource management */
25352 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25356 + /* various legacy exceptions */
25358 + /* will go away when spectator is a cap */
25359 + case VCMD_ctx_migrate_v0:
25360 + case VCMD_ctx_migrate:
25362 + current->xid = 1;
25368 + /* will go away when spectator is a cap */
25369 + case VCMD_net_migrate:
25371 + current->nid = 1;
25378 + /* vcmds are fine by default */
25381 + /* admin type vcmds require admin ... */
25382 + if (flags & VCF_ADMIN)
25383 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25385 + /* ... but setup type vcmds override that */
25386 + if (!permit && (flags & VCF_SETUP))
25387 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25395 + if (!id && (flags & VCF_ZIDOK))
25399 + if (args & VCA_VXI) {
25400 + vxi = lookup_vx_info(id);
25404 + if ((flags & VCF_ADMIN) &&
25405 + /* special case kill for shutdown */
25406 + (cmd != VCMD_ctx_kill) &&
25407 + /* can context be administrated? */
25408 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25414 + if (args & VCA_NXI) {
25415 + nxi = lookup_nx_info(id);
25419 + if ((flags & VCF_ADMIN) &&
25420 + /* can context be administrated? */
25421 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25428 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25431 + if ((args & VCA_NXI) && nxi)
25432 + put_nx_info(nxi);
25434 + if ((args & VCA_VXI) && vxi)
25435 + put_vx_info(vxi);
25437 + vxdprintk(VXD_CBIT(switch, 1),
25438 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25439 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25440 + VC_VERSION(cmd), ret, ret, state, permit);
25445 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25447 + return do_vserver(cmd, id, data, 0);
25450 +#ifdef CONFIG_COMPAT
25453 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25455 + return do_vserver(cmd, id, data, 1);
25458 +#endif /* CONFIG_COMPAT */
25459 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/sysctl.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/sysctl.c
25460 --- linux-2.6.27.6/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25461 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/sysctl.c 2008-10-13 14:54:20.000000000 +0200
25464 + * kernel/vserver/sysctl.c
25466 + * Virtual Context Support
25468 + * Copyright (C) 2004-2007 Herbert Pötzl
25470 + * V0.01 basic structure
25474 +#include <linux/module.h>
25475 +#include <linux/ctype.h>
25476 +#include <linux/sysctl.h>
25477 +#include <linux/parser.h>
25478 +#include <asm/uaccess.h>
25482 + CTL_DEBUG_ERROR = 0,
25483 + CTL_DEBUG_SWITCH = 1,
25498 +unsigned int vx_debug_switch = 0;
25499 +unsigned int vx_debug_xid = 0;
25500 +unsigned int vx_debug_nid = 0;
25501 +unsigned int vx_debug_tag = 0;
25502 +unsigned int vx_debug_net = 0;
25503 +unsigned int vx_debug_limit = 0;
25504 +unsigned int vx_debug_cres = 0;
25505 +unsigned int vx_debug_dlim = 0;
25506 +unsigned int vx_debug_quota = 0;
25507 +unsigned int vx_debug_cvirt = 0;
25508 +unsigned int vx_debug_space = 0;
25509 +unsigned int vx_debug_misc = 0;
25512 +static struct ctl_table_header *vserver_table_header;
25513 +static ctl_table vserver_root_table[];
25516 +void vserver_register_sysctl(void)
25518 + if (!vserver_table_header) {
25519 + vserver_table_header = register_sysctl_table(vserver_root_table);
25524 +void vserver_unregister_sysctl(void)
25526 + if (vserver_table_header) {
25527 + unregister_sysctl_table(vserver_table_header);
25528 + vserver_table_header = NULL;
25533 +static int proc_dodebug(ctl_table *table, int write,
25534 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
25536 + char tmpbuf[20], *p, c;
25537 + unsigned int value;
25538 + size_t left, len;
25540 + if ((*ppos && !write) || !*lenp) {
25548 + if (!access_ok(VERIFY_READ, buffer, left))
25550 + p = (char *)buffer;
25551 + while (left && __get_user(c, p) >= 0 && isspace(c))
25556 + if (left > sizeof(tmpbuf) - 1)
25558 + if (copy_from_user(tmpbuf, p, left))
25560 + tmpbuf[left] = '\0';
25562 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25563 + value = 10 * value + (*p - '0');
25564 + if (*p && !isspace(*p))
25566 + while (left && isspace(*p))
25568 + *(unsigned int *)table->data = value;
25570 + if (!access_ok(VERIFY_WRITE, buffer, left))
25572 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25575 + if (__copy_to_user(buffer, tmpbuf, len))
25577 + if ((left -= len) > 0) {
25578 + if (put_user('\n', (char *)buffer + len))
25592 +#define CTL_ENTRY(ctl, name) \
25594 + .ctl_name = ctl, \
25595 + .procname = #name, \
25596 + .data = &vx_ ## name, \
25597 + .maxlen = sizeof(int), \
25599 + .proc_handler = &proc_dodebug, \
25600 + .strategy = &sysctl_intvec, \
25601 + .extra1 = &zero, \
25604 +static ctl_table vserver_debug_table[] = {
25605 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25606 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25607 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25608 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
25609 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
25610 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
25611 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
25612 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
25613 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
25614 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
25615 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
25616 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
25617 + { .ctl_name = 0 }
25620 +static ctl_table vserver_root_table[] = {
25622 + .ctl_name = CTL_VSERVER,
25623 + .procname = "vserver",
25625 + .child = vserver_debug_table
25627 + { .ctl_name = 0 }
25631 +static match_table_t tokens = {
25632 + { CTL_DEBUG_SWITCH, "switch=%x" },
25633 + { CTL_DEBUG_XID, "xid=%x" },
25634 + { CTL_DEBUG_NID, "nid=%x" },
25635 + { CTL_DEBUG_TAG, "tag=%x" },
25636 + { CTL_DEBUG_NET, "net=%x" },
25637 + { CTL_DEBUG_LIMIT, "limit=%x" },
25638 + { CTL_DEBUG_CRES, "cres=%x" },
25639 + { CTL_DEBUG_DLIM, "dlim=%x" },
25640 + { CTL_DEBUG_QUOTA, "quota=%x" },
25641 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
25642 + { CTL_DEBUG_SPACE, "space=%x" },
25643 + { CTL_DEBUG_MISC, "misc=%x" },
25644 + { CTL_DEBUG_ERROR, NULL }
25647 +#define HANDLE_CASE(id, name, val) \
25648 + case CTL_DEBUG_ ## id: \
25649 + vx_debug_ ## name = val; \
25650 + printk("vs_debug_" #name "=0x%x\n", val); \
25654 +static int __init vs_debug_setup(char *str)
25659 + printk("vs_debug_setup(%s)\n", str);
25660 + while ((p = strsep(&str, ",")) != NULL) {
25661 + substring_t args[MAX_OPT_ARGS];
25662 + unsigned int value;
25667 + token = match_token(p, tokens, args);
25668 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25671 + HANDLE_CASE(SWITCH, switch, value);
25672 + HANDLE_CASE(XID, xid, value);
25673 + HANDLE_CASE(NID, nid, value);
25674 + HANDLE_CASE(TAG, tag, value);
25675 + HANDLE_CASE(NET, net, value);
25676 + HANDLE_CASE(LIMIT, limit, value);
25677 + HANDLE_CASE(CRES, cres, value);
25678 + HANDLE_CASE(DLIM, dlim, value);
25679 + HANDLE_CASE(QUOTA, quota, value);
25680 + HANDLE_CASE(CVIRT, cvirt, value);
25681 + HANDLE_CASE(SPACE, space, value);
25682 + HANDLE_CASE(MISC, misc, value);
25691 +__setup("vsdebug=", vs_debug_setup);
25695 +EXPORT_SYMBOL_GPL(vx_debug_switch);
25696 +EXPORT_SYMBOL_GPL(vx_debug_xid);
25697 +EXPORT_SYMBOL_GPL(vx_debug_nid);
25698 +EXPORT_SYMBOL_GPL(vx_debug_net);
25699 +EXPORT_SYMBOL_GPL(vx_debug_limit);
25700 +EXPORT_SYMBOL_GPL(vx_debug_cres);
25701 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
25702 +EXPORT_SYMBOL_GPL(vx_debug_quota);
25703 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
25704 +EXPORT_SYMBOL_GPL(vx_debug_space);
25705 +EXPORT_SYMBOL_GPL(vx_debug_misc);
25707 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/tag.c linux-2.6.27.6-vs2.3.0.36/kernel/vserver/tag.c
25708 --- linux-2.6.27.6/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
25709 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/tag.c 2008-10-13 14:54:20.000000000 +0200
25712 + * linux/kernel/vserver/tag.c
25714 + * Virtual Server: Shallow Tag Space
25716 + * Copyright (C) 2007 Herbert Pötzl
25718 + * V0.01 basic implementation
25722 +#include <linux/sched.h>
25723 +#include <linux/vserver/debug.h>
25724 +#include <linux/vs_pid.h>
25725 +#include <linux/vs_tag.h>
25727 +#include <linux/vserver/tag_cmd.h>
25730 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25735 + vxdprintk(VXD_CBIT(tag, 5),
25736 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25742 + vxdprintk(VXD_CBIT(tag, 5),
25743 + "moved task %p into [#%d]", p, tag);
25747 +/* vserver syscall commands below here */
25749 +/* taks xid and vx_info functions */
25752 +int vc_task_tag(uint32_t id)
25757 + struct task_struct *tsk;
25758 + read_lock(&tasklist_lock);
25759 + tsk = find_task_by_real_pid(id);
25760 + tag = (tsk) ? tsk->tag : -ESRCH;
25761 + read_unlock(&tasklist_lock);
25763 + tag = dx_current_tag();
25768 +int vc_tag_migrate(uint32_t tag)
25770 + return dx_migrate_task(current, tag & 0xFFFF);
25774 diff -NurpP --minimal linux-2.6.27.6/kernel/vserver/vci_config.h linux-2.6.27.6-vs2.3.0.36/kernel/vserver/vci_config.h
25775 --- linux-2.6.27.6/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
25776 +++ linux-2.6.27.6-vs2.3.0.36/kernel/vserver/vci_config.h 2008-10-31 18:16:04.000000000 +0100
25779 +/* interface version */
25781 +#define VCI_VERSION 0x00020304
25785 + VCI_KCBIT_NO_DYNAMIC = 0,
25787 + VCI_KCBIT_PROC_SECURE = 4,
25788 + VCI_KCBIT_HARDCPU = 5,
25789 + VCI_KCBIT_IDLELIMIT = 6,
25790 + VCI_KCBIT_IDLETIME = 7,
25792 + VCI_KCBIT_COWBL = 8,
25793 + VCI_KCBIT_FULLCOWBL = 9,
25794 + VCI_KCBIT_SPACES = 10,
25795 + VCI_KCBIT_NETV2 = 11,
25797 + VCI_KCBIT_DEBUG = 16,
25798 + VCI_KCBIT_HISTORY = 20,
25799 + VCI_KCBIT_TAGGED = 24,
25800 + VCI_KCBIT_PPTAG = 28,
25802 + VCI_KCBIT_MORE = 31,
25806 +static inline uint32_t vci_kernel_config(void)
25809 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25811 + /* configured features */
25812 +#ifdef CONFIG_VSERVER_PROC_SECURE
25813 + (1 << VCI_KCBIT_PROC_SECURE) |
25815 +#ifdef CONFIG_VSERVER_HARDCPU
25816 + (1 << VCI_KCBIT_HARDCPU) |
25818 +#ifdef CONFIG_VSERVER_IDLELIMIT
25819 + (1 << VCI_KCBIT_IDLELIMIT) |
25821 +#ifdef CONFIG_VSERVER_IDLETIME
25822 + (1 << VCI_KCBIT_IDLETIME) |
25824 +#ifdef CONFIG_VSERVER_COWBL
25825 + (1 << VCI_KCBIT_COWBL) |
25826 + (1 << VCI_KCBIT_FULLCOWBL) |
25828 + (1 << VCI_KCBIT_SPACES) |
25829 + (1 << VCI_KCBIT_NETV2) |
25831 + /* debug options */
25832 +#ifdef CONFIG_VSERVER_DEBUG
25833 + (1 << VCI_KCBIT_DEBUG) |
25835 +#ifdef CONFIG_VSERVER_HISTORY
25836 + (1 << VCI_KCBIT_HISTORY) |
25839 + /* inode context tagging */
25840 +#if defined(CONFIG_TAGGING_NONE)
25841 + (0 << VCI_KCBIT_TAGGED) |
25842 +#elif defined(CONFIG_TAGGING_UID16)
25843 + (1 << VCI_KCBIT_TAGGED) |
25844 +#elif defined(CONFIG_TAGGING_GID16)
25845 + (2 << VCI_KCBIT_TAGGED) |
25846 +#elif defined(CONFIG_TAGGING_ID24)
25847 + (3 << VCI_KCBIT_TAGGED) |
25848 +#elif defined(CONFIG_TAGGING_INTERN)
25849 + (4 << VCI_KCBIT_TAGGED) |
25850 +#elif defined(CONFIG_TAGGING_RUNTIME)
25851 + (5 << VCI_KCBIT_TAGGED) |
25853 + (7 << VCI_KCBIT_TAGGED) |
25855 + (1 << VCI_KCBIT_PPTAG) |
25859 diff -NurpP --minimal linux-2.6.27.6/mm/filemap_xip.c linux-2.6.27.6-vs2.3.0.36/mm/filemap_xip.c
25860 --- linux-2.6.27.6/mm/filemap_xip.c 2008-10-13 14:52:09.000000000 +0200
25861 +++ linux-2.6.27.6-vs2.3.0.36/mm/filemap_xip.c 2008-10-13 14:54:20.000000000 +0200
25863 #include <linux/sched.h>
25864 #include <linux/seqlock.h>
25865 #include <linux/mutex.h>
25866 +#include <linux/vs_memory.h>
25867 #include <asm/tlbflush.h>
25868 #include <asm/io.h>
25870 diff -NurpP --minimal linux-2.6.27.6/mm/fremap.c linux-2.6.27.6-vs2.3.0.36/mm/fremap.c
25871 --- linux-2.6.27.6/mm/fremap.c 2008-10-13 14:52:09.000000000 +0200
25872 +++ linux-2.6.27.6-vs2.3.0.36/mm/fremap.c 2008-10-13 14:54:20.000000000 +0200
25874 #include <linux/module.h>
25875 #include <linux/syscalls.h>
25876 #include <linux/mmu_notifier.h>
25877 +#include <linux/vs_memory.h>
25879 #include <asm/mmu_context.h>
25880 #include <asm/cacheflush.h>
25881 diff -NurpP --minimal linux-2.6.27.6/mm/hugetlb.c linux-2.6.27.6-vs2.3.0.36/mm/hugetlb.c
25882 --- linux-2.6.27.6/mm/hugetlb.c 2008-11-17 18:07:34.000000000 +0100
25883 +++ linux-2.6.27.6-vs2.3.0.36/mm/hugetlb.c 2008-11-17 18:20:41.000000000 +0100
25885 #include <asm/io.h>
25887 #include <linux/hugetlb.h>
25888 +#include <linux/vs_memory.h>
25889 #include "internal.h"
25891 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
25892 diff -NurpP --minimal linux-2.6.27.6/mm/memory.c linux-2.6.27.6-vs2.3.0.36/mm/memory.c
25893 --- linux-2.6.27.6/mm/memory.c 2008-10-13 14:52:09.000000000 +0200
25894 +++ linux-2.6.27.6-vs2.3.0.36/mm/memory.c 2008-10-13 14:54:20.000000000 +0200
25895 @@ -562,6 +562,9 @@ static int copy_pte_range(struct mm_stru
25899 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
25903 rss[1] = rss[0] = 0;
25904 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
25905 @@ -2294,6 +2297,11 @@ static int do_swap_page(struct mm_struct
25909 + if (!vx_rss_avail(mm, 1)) {
25910 + ret = VM_FAULT_OOM;
25914 mark_page_accessed(page);
25916 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
25917 @@ -2365,6 +2373,8 @@ static int do_anonymous_page(struct mm_s
25918 /* Allocate our own private page. */
25919 pte_unmap(page_table);
25921 + if (!vx_rss_avail(mm, 1))
25923 if (unlikely(anon_vma_prepare(vma)))
25925 page = alloc_zeroed_user_highpage_movable(vma, address);
25926 @@ -2626,6 +2636,7 @@ static inline int handle_pte_fault(struc
25930 + int ret = 0, type = VXPT_UNKNOWN;
25933 if (!pte_present(entry)) {
25934 @@ -2650,9 +2661,12 @@ static inline int handle_pte_fault(struc
25935 if (unlikely(!pte_same(*pte, entry)))
25937 if (write_access) {
25938 - if (!pte_write(entry))
25939 - return do_wp_page(mm, vma, address,
25940 + if (!pte_write(entry)) {
25941 + ret = do_wp_page(mm, vma, address,
25942 pte, pmd, ptl, entry);
25943 + type = VXPT_WRITE;
25946 entry = pte_mkdirty(entry);
25948 entry = pte_mkyoung(entry);
25949 @@ -2670,7 +2684,10 @@ static inline int handle_pte_fault(struc
25952 pte_unmap_unlock(pte, ptl);
25956 + vx_page_fault(mm, vma, type, ret);
25961 diff -NurpP --minimal linux-2.6.27.6/mm/mlock.c linux-2.6.27.6-vs2.3.0.36/mm/mlock.c
25962 --- linux-2.6.27.6/mm/mlock.c 2008-10-13 14:52:09.000000000 +0200
25963 +++ linux-2.6.27.6-vs2.3.0.36/mm/mlock.c 2008-10-13 14:54:20.000000000 +0200
25965 #include <linux/syscalls.h>
25966 #include <linux/sched.h>
25967 #include <linux/module.h>
25968 +#include <linux/vs_memory.h>
25970 int can_do_mlock(void)
25972 @@ -76,7 +77,7 @@ success:
25973 ret = make_pages_present(start, end);
25976 - mm->locked_vm -= pages;
25977 + vx_vmlocked_sub(mm, pages);
25981 @@ -132,7 +133,7 @@ static int do_mlock(unsigned long start,
25983 asmlinkage long sys_mlock(unsigned long start, size_t len)
25985 - unsigned long locked;
25986 + unsigned long locked, grow;
25987 unsigned long lock_limit;
25988 int error = -ENOMEM;
25990 @@ -143,8 +144,10 @@ asmlinkage long sys_mlock(unsigned long
25991 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
25992 start &= PAGE_MASK;
25994 - locked = len >> PAGE_SHIFT;
25995 - locked += current->mm->locked_vm;
25996 + grow = len >> PAGE_SHIFT;
25997 + if (!vx_vmlocked_avail(current->mm, grow))
25999 + locked = current->mm->locked_vm + grow;
26001 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
26002 lock_limit >>= PAGE_SHIFT;
26003 @@ -152,6 +155,7 @@ asmlinkage long sys_mlock(unsigned long
26004 /* check against resource limits */
26005 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26006 error = do_mlock(start, len, 1);
26008 up_write(¤t->mm->mmap_sem);
26011 @@ -211,6 +215,8 @@ asmlinkage long sys_mlockall(int flags)
26012 lock_limit >>= PAGE_SHIFT;
26015 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
26017 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
26018 capable(CAP_IPC_LOCK))
26019 ret = do_mlockall(flags);
26020 diff -NurpP --minimal linux-2.6.27.6/mm/mmap.c linux-2.6.27.6-vs2.3.0.36/mm/mmap.c
26021 --- linux-2.6.27.6/mm/mmap.c 2008-10-13 14:52:09.000000000 +0200
26022 +++ linux-2.6.27.6-vs2.3.0.36/mm/mmap.c 2008-10-13 14:54:20.000000000 +0200
26023 @@ -1221,10 +1221,10 @@ munmap_back:
26024 if (correct_wcount)
26025 atomic_inc(&inode->i_writecount);
26027 - mm->total_vm += len >> PAGE_SHIFT;
26028 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26029 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
26030 if (vm_flags & VM_LOCKED) {
26031 - mm->locked_vm += len >> PAGE_SHIFT;
26032 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26033 make_pages_present(addr, addr + len);
26035 if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
26036 @@ -1573,9 +1573,9 @@ static int acct_stack_growth(struct vm_a
26039 /* Ok, everything looks good - let it rip */
26040 - mm->total_vm += grow;
26041 + vx_vmpages_add(mm, grow);
26042 if (vma->vm_flags & VM_LOCKED)
26043 - mm->locked_vm += grow;
26044 + vx_vmlocked_add(mm, grow);
26045 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
26048 @@ -1746,9 +1746,9 @@ static void remove_vma_list(struct mm_st
26050 long nrpages = vma_pages(vma);
26052 - mm->total_vm -= nrpages;
26053 + vx_vmpages_sub(mm, nrpages);
26054 if (vma->vm_flags & VM_LOCKED)
26055 - mm->locked_vm -= nrpages;
26056 + vx_vmlocked_sub(mm, nrpages);
26057 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
26058 vma = remove_vma(vma);
26060 @@ -1995,6 +1995,8 @@ unsigned long do_brk(unsigned long addr,
26061 lock_limit >>= PAGE_SHIFT;
26062 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26064 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
26069 @@ -2021,7 +2023,8 @@ unsigned long do_brk(unsigned long addr,
26070 if (mm->map_count > sysctl_max_map_count)
26073 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
26074 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
26075 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
26078 /* Can we just expand an old private anonymous mapping? */
26079 @@ -2046,9 +2049,9 @@ unsigned long do_brk(unsigned long addr,
26080 vma->vm_page_prot = vm_get_page_prot(flags);
26081 vma_link(mm, vma, prev, rb_link, rb_parent);
26083 - mm->total_vm += len >> PAGE_SHIFT;
26084 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26085 if (flags & VM_LOCKED) {
26086 - mm->locked_vm += len >> PAGE_SHIFT;
26087 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26088 make_pages_present(addr, addr + len);
26091 @@ -2078,6 +2081,11 @@ void exit_mmap(struct mm_struct *mm)
26092 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
26093 tlb_finish_mmu(tlb, 0, end);
26095 + set_mm_counter(mm, file_rss, 0);
26096 + set_mm_counter(mm, anon_rss, 0);
26097 + vx_vmpages_sub(mm, mm->total_vm);
26098 + vx_vmlocked_sub(mm, mm->locked_vm);
26101 * Walk the list again, actually closing and freeing it,
26102 * with preemption enabled, without holding any MM locks.
26103 @@ -2117,7 +2125,8 @@ int insert_vm_struct(struct mm_struct *
26104 if (__vma && __vma->vm_start < vma->vm_end)
26106 if ((vma->vm_flags & VM_ACCOUNT) &&
26107 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
26108 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
26109 + !vx_vmpages_avail(mm, vma_pages(vma))))
26111 vma_link(mm, vma, prev, rb_link, rb_parent);
26113 @@ -2193,6 +2202,8 @@ int may_expand_vm(struct mm_struct *mm,
26115 if (cur + npages > lim)
26117 + if (!vx_vmpages_avail(mm, npages))
26122 @@ -2270,8 +2281,7 @@ int install_special_mapping(struct mm_st
26126 - mm->total_vm += len >> PAGE_SHIFT;
26128 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26132 diff -NurpP --minimal linux-2.6.27.6/mm/mremap.c linux-2.6.27.6-vs2.3.0.36/mm/mremap.c
26133 --- linux-2.6.27.6/mm/mremap.c 2008-10-13 14:52:09.000000000 +0200
26134 +++ linux-2.6.27.6-vs2.3.0.36/mm/mremap.c 2008-10-13 14:54:20.000000000 +0200
26136 #include <linux/security.h>
26137 #include <linux/syscalls.h>
26138 #include <linux/mmu_notifier.h>
26139 +#include <linux/vs_memory.h>
26141 #include <asm/uaccess.h>
26142 #include <asm/cacheflush.h>
26143 @@ -218,7 +219,7 @@ static unsigned long move_vma(struct vm_
26144 * If this were a serious issue, we'd add a flag to do_munmap().
26146 hiwater_vm = mm->hiwater_vm;
26147 - mm->total_vm += new_len >> PAGE_SHIFT;
26148 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
26149 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
26151 if (do_munmap(mm, old_addr, old_len) < 0) {
26152 @@ -236,7 +237,7 @@ static unsigned long move_vma(struct vm_
26155 if (vm_flags & VM_LOCKED) {
26156 - mm->locked_vm += new_len >> PAGE_SHIFT;
26157 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
26158 if (new_len > old_len)
26159 make_pages_present(new_addr + old_len,
26160 new_addr + new_len);
26161 @@ -347,6 +348,9 @@ unsigned long do_mremap(unsigned long ad
26163 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26165 + if (!vx_vmlocked_avail(current->mm,
26166 + (new_len - old_len) >> PAGE_SHIFT))
26169 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
26171 @@ -375,10 +379,10 @@ unsigned long do_mremap(unsigned long ad
26172 vma_adjust(vma, vma->vm_start,
26173 addr + new_len, vma->vm_pgoff, NULL);
26175 - mm->total_vm += pages;
26176 + vx_vmpages_add(mm, pages);
26177 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
26178 if (vma->vm_flags & VM_LOCKED) {
26179 - mm->locked_vm += pages;
26180 + vx_vmlocked_add(mm, pages);
26181 make_pages_present(addr + old_len,
26184 diff -NurpP --minimal linux-2.6.27.6/mm/nommu.c linux-2.6.27.6-vs2.3.0.36/mm/nommu.c
26185 --- linux-2.6.27.6/mm/nommu.c 2008-10-13 14:52:09.000000000 +0200
26186 +++ linux-2.6.27.6-vs2.3.0.36/mm/nommu.c 2008-10-13 14:54:20.000000000 +0200
26187 @@ -1028,7 +1028,7 @@ unsigned long do_mmap_pgoff(struct file
26188 realalloc += kobjsize(vma);
26189 askedalloc += sizeof(*vma);
26191 - current->mm->total_vm += len >> PAGE_SHIFT;
26192 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
26194 add_nommu_vma(vma);
26196 @@ -1160,7 +1160,7 @@ int do_munmap(struct mm_struct *mm, unsi
26199 update_hiwater_vm(mm);
26200 - mm->total_vm -= len >> PAGE_SHIFT;
26201 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
26204 show_process_blocks();
26205 @@ -1193,7 +1193,7 @@ void exit_mmap(struct mm_struct * mm)
26206 printk("Exit_mmap:\n");
26209 - mm->total_vm = 0;
26210 + vx_vmpages_sub(mm, mm->total_vm);
26212 while ((tmp = mm->context.vmlist)) {
26213 mm->context.vmlist = tmp->next;
26214 diff -NurpP --minimal linux-2.6.27.6/mm/oom_kill.c linux-2.6.27.6-vs2.3.0.36/mm/oom_kill.c
26215 --- linux-2.6.27.6/mm/oom_kill.c 2008-10-13 14:52:09.000000000 +0200
26216 +++ linux-2.6.27.6-vs2.3.0.36/mm/oom_kill.c 2008-10-13 14:54:20.000000000 +0200
26218 #include <linux/notifier.h>
26219 #include <linux/memcontrol.h>
26220 #include <linux/security.h>
26221 +#include <linux/vs_memory.h>
26223 int sysctl_panic_on_oom;
26224 int sysctl_oom_kill_allocating_task;
26225 @@ -73,6 +74,12 @@ unsigned long badness(struct task_struct
26226 points = mm->total_vm;
26229 + * add points for context badness
26232 + points += vx_badness(p, mm);
26235 * After this unlock we can no longer dereference local variable `mm'
26238 @@ -163,8 +170,8 @@ unsigned long badness(struct task_struct
26242 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26243 - p->pid, p->comm, points);
26244 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26245 + task_pid_nr(p), p->xid, p->comm, points);
26249 @@ -325,8 +332,8 @@ static void __oom_kill_task(struct task_
26253 - printk(KERN_ERR "Killed process %d (%s)\n",
26254 - task_pid_nr(p), p->comm);
26255 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
26256 + task_pid_nr(p), p->xid, p->comm);
26259 * We give our sacrificial lamb high priority and access to
26260 @@ -406,8 +413,8 @@ static int oom_kill_process(struct task_
26264 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26265 - message, task_pid_nr(p), p->comm, points);
26266 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
26267 + message, task_pid_nr(p), p->xid, p->comm, points);
26269 /* Try to kill a child first */
26270 list_for_each_entry(c, &p->children, sibling) {
26271 diff -NurpP --minimal linux-2.6.27.6/mm/page_alloc.c linux-2.6.27.6-vs2.3.0.36/mm/page_alloc.c
26272 --- linux-2.6.27.6/mm/page_alloc.c 2008-11-17 18:07:34.000000000 +0100
26273 +++ linux-2.6.27.6-vs2.3.0.36/mm/page_alloc.c 2008-11-17 18:20:41.000000000 +0100
26275 #include <linux/page-isolation.h>
26276 #include <linux/memcontrol.h>
26277 #include <linux/debugobjects.h>
26278 +#include <linux/vs_base.h>
26279 +#include <linux/vs_limit.h>
26281 #include <asm/tlbflush.h>
26282 #include <asm/div64.h>
26283 @@ -1823,6 +1825,9 @@ void si_meminfo(struct sysinfo *val)
26284 val->totalhigh = totalhigh_pages;
26285 val->freehigh = nr_free_highpages();
26286 val->mem_unit = PAGE_SIZE;
26288 + if (vx_flags(VXF_VIRT_MEM, 0))
26289 + vx_vsi_meminfo(val);
26292 EXPORT_SYMBOL(si_meminfo);
26293 @@ -1843,6 +1848,9 @@ void si_meminfo_node(struct sysinfo *val
26296 val->mem_unit = PAGE_SIZE;
26298 + if (vx_flags(VXF_VIRT_MEM, 0))
26299 + vx_vsi_meminfo(val);
26303 diff -NurpP --minimal linux-2.6.27.6/mm/rmap.c linux-2.6.27.6-vs2.3.0.36/mm/rmap.c
26304 --- linux-2.6.27.6/mm/rmap.c 2008-11-17 18:07:34.000000000 +0100
26305 +++ linux-2.6.27.6-vs2.3.0.36/mm/rmap.c 2008-10-30 01:17:01.000000000 +0100
26307 #include <linux/kallsyms.h>
26308 #include <linux/memcontrol.h>
26309 #include <linux/mmu_notifier.h>
26310 +#include <linux/vs_memory.h>
26312 #include <asm/tlbflush.h>
26314 diff -NurpP --minimal linux-2.6.27.6/mm/shmem.c linux-2.6.27.6-vs2.3.0.36/mm/shmem.c
26315 --- linux-2.6.27.6/mm/shmem.c 2008-10-13 14:52:09.000000000 +0200
26316 +++ linux-2.6.27.6-vs2.3.0.36/mm/shmem.c 2008-10-13 14:54:20.000000000 +0200
26318 #include <asm/pgtable.h>
26320 /* This magic number is used in glibc for posix shared memory */
26321 -#define TMPFS_MAGIC 0x01021994
26323 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
26324 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
26325 @@ -1738,7 +1737,7 @@ static int shmem_statfs(struct dentry *d
26327 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26329 - buf->f_type = TMPFS_MAGIC;
26330 + buf->f_type = TMPFS_SUPER_MAGIC;
26331 buf->f_bsize = PAGE_CACHE_SIZE;
26332 buf->f_namelen = NAME_MAX;
26333 spin_lock(&sbinfo->stat_lock);
26334 @@ -2306,7 +2305,7 @@ static int shmem_fill_super(struct super
26335 sb->s_maxbytes = SHMEM_MAX_BYTES;
26336 sb->s_blocksize = PAGE_CACHE_SIZE;
26337 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26338 - sb->s_magic = TMPFS_MAGIC;
26339 + sb->s_magic = TMPFS_SUPER_MAGIC;
26340 sb->s_op = &shmem_ops;
26341 sb->s_time_gran = 1;
26342 #ifdef CONFIG_TMPFS_POSIX_ACL
26343 diff -NurpP --minimal linux-2.6.27.6/mm/slab.c linux-2.6.27.6-vs2.3.0.36/mm/slab.c
26344 --- linux-2.6.27.6/mm/slab.c 2008-10-13 14:52:09.000000000 +0200
26345 +++ linux-2.6.27.6-vs2.3.0.36/mm/slab.c 2008-10-13 14:54:20.000000000 +0200
26346 @@ -508,6 +508,8 @@ struct kmem_cache {
26347 #define STATS_INC_FREEMISS(x) do { } while (0)
26350 +#include "slab_vs.h"
26355 @@ -3337,6 +3339,7 @@ retry:
26357 obj = slab_get_obj(cachep, slabp, nodeid);
26358 check_slabp(cachep, slabp);
26359 + vx_slab_alloc(cachep, flags);
26360 l3->free_objects--;
26361 /* move slabp to correct slabp list: */
26362 list_del(&slabp->list);
26363 @@ -3409,6 +3412,7 @@ __cache_alloc_node(struct kmem_cache *ca
26364 /* ___cache_alloc_node can fall back to other nodes */
26365 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26367 + vx_slab_alloc(cachep, flags);
26368 local_irq_restore(save_flags);
26369 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26371 @@ -3580,6 +3584,7 @@ static inline void __cache_free(struct k
26374 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26375 + vx_slab_free(cachep);
26378 * Skip calling cache_free_alien() when the platform is not numa.
26379 diff -NurpP --minimal linux-2.6.27.6/mm/slab_vs.h linux-2.6.27.6-vs2.3.0.36/mm/slab_vs.h
26380 --- linux-2.6.27.6/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26381 +++ linux-2.6.27.6-vs2.3.0.36/mm/slab_vs.h 2008-10-13 14:54:20.000000000 +0200
26384 +#include <linux/vserver/context.h>
26386 +#include <linux/vs_context.h>
26389 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26391 + int what = gfp_zone(cachep->gfpflags);
26393 + if (!current->vx_info)
26396 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26400 +void vx_slab_free(struct kmem_cache *cachep)
26402 + int what = gfp_zone(cachep->gfpflags);
26404 + if (!current->vx_info)
26407 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26410 diff -NurpP --minimal linux-2.6.27.6/mm/swapfile.c linux-2.6.27.6-vs2.3.0.36/mm/swapfile.c
26411 --- linux-2.6.27.6/mm/swapfile.c 2008-10-13 14:52:09.000000000 +0200
26412 +++ linux-2.6.27.6-vs2.3.0.36/mm/swapfile.c 2008-10-13 14:54:20.000000000 +0200
26414 #include <asm/pgtable.h>
26415 #include <asm/tlbflush.h>
26416 #include <linux/swapops.h>
26417 +#include <linux/vs_base.h>
26418 +#include <linux/vs_memory.h>
26420 static DEFINE_SPINLOCK(swap_lock);
26421 static unsigned int nr_swapfiles;
26422 @@ -1748,6 +1750,8 @@ void si_swapinfo(struct sysinfo *val)
26423 val->freeswap = nr_swap_pages + nr_to_be_unused;
26424 val->totalswap = total_swap_pages + nr_to_be_unused;
26425 spin_unlock(&swap_lock);
26426 + if (vx_flags(VXF_VIRT_MEM, 0))
26427 + vx_vsi_swapinfo(val);
26431 diff -NurpP --minimal linux-2.6.27.6/net/core/dev.c linux-2.6.27.6-vs2.3.0.36/net/core/dev.c
26432 --- linux-2.6.27.6/net/core/dev.c 2008-10-13 14:52:09.000000000 +0200
26433 +++ linux-2.6.27.6-vs2.3.0.36/net/core/dev.c 2008-11-20 15:25:30.000000000 +0100
26434 @@ -127,6 +127,7 @@
26435 #include <linux/in.h>
26436 #include <linux/jhash.h>
26437 #include <linux/random.h>
26438 +#include <linux/vs_inet.h>
26440 #include "net-sysfs.h"
26442 @@ -925,10 +926,15 @@ int dev_change_name(struct net_device *d
26443 strlcpy(dev->name, newname, IFNAMSIZ);
26446 - err = device_rename(&dev->dev, dev->name);
26448 - memcpy(dev->name, oldname, IFNAMSIZ);
26450 + /* For now only devices in the initial network namespace
26453 + if (net == &init_net) {
26454 + ret = device_rename(&dev->dev, dev->name);
26456 + memcpy(dev->name, oldname, IFNAMSIZ);
26461 write_lock_bh(&dev_base_lock);
26462 @@ -2515,6 +2521,8 @@ static int dev_ifconf(struct net *net, c
26465 for_each_netdev(net, dev) {
26466 + if (!nx_dev_visible(current->nx_info, dev))
26468 for (i = 0; i < NPROTO; i++) {
26469 if (gifconf_list[i]) {
26471 @@ -2583,6 +2591,9 @@ static void dev_seq_printf_stats(struct
26473 struct net_device_stats *stats = dev->get_stats(dev);
26475 + if (!nx_dev_visible(current->nx_info, dev))
26478 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26479 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26480 dev->name, stats->rx_bytes, stats->rx_packets,
26481 @@ -4385,6 +4396,15 @@ int dev_change_net_namespace(struct net_
26482 if (dev->features & NETIF_F_NETNS_LOCAL)
26485 +#ifdef CONFIG_SYSFS
26486 + /* Don't allow real devices to be moved when sysfs
26490 + if (dev->dev.parent)
26494 /* Ensure the device has been registrered */
26496 if (dev->reg_state != NETREG_REGISTERED)
26497 @@ -4442,6 +4462,8 @@ int dev_change_net_namespace(struct net_
26499 dev_addr_discard(dev);
26501 + netdev_unregister_kobject(dev);
26503 /* Actually switch the network namespace */
26504 dev_net_set(dev, net);
26506 @@ -4458,7 +4480,6 @@ int dev_change_net_namespace(struct net_
26509 /* Fixup kobjects */
26510 - netdev_unregister_kobject(dev);
26511 err = netdev_register_kobject(dev);
26514 diff -NurpP --minimal linux-2.6.27.6/net/core/net-sysfs.c linux-2.6.27.6-vs2.3.0.36/net/core/net-sysfs.c
26515 --- linux-2.6.27.6/net/core/net-sysfs.c 2008-10-13 14:52:09.000000000 +0200
26516 +++ linux-2.6.27.6-vs2.3.0.36/net/core/net-sysfs.c 2008-11-20 15:21:32.000000000 +0100
26517 @@ -440,6 +440,10 @@ void netdev_unregister_kobject(struct ne
26518 struct device *dev = &(net->dev);
26520 kobject_get(&dev->kobj);
26522 + if (dev_net(net) != &init_net)
26528 @@ -465,6 +469,9 @@ int netdev_register_kobject(struct net_d
26530 #endif /* CONFIG_SYSFS */
26532 + if (dev_net(net) != &init_net)
26535 return device_add(dev);
26538 diff -NurpP --minimal linux-2.6.27.6/net/core/rtnetlink.c linux-2.6.27.6-vs2.3.0.36/net/core/rtnetlink.c
26539 --- linux-2.6.27.6/net/core/rtnetlink.c 2008-10-13 14:52:09.000000000 +0200
26540 +++ linux-2.6.27.6-vs2.3.0.36/net/core/rtnetlink.c 2008-10-13 14:54:20.000000000 +0200
26541 @@ -686,6 +686,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26544 for_each_netdev(net, dev) {
26545 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26549 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26550 @@ -1219,6 +1221,9 @@ void rtmsg_ifinfo(int type, struct net_d
26551 struct sk_buff *skb;
26552 int err = -ENOBUFS;
26554 + if (!nx_dev_visible(current->nx_info, dev))
26557 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26560 diff -NurpP --minimal linux-2.6.27.6/net/core/sock.c linux-2.6.27.6-vs2.3.0.36/net/core/sock.c
26561 --- linux-2.6.27.6/net/core/sock.c 2008-10-13 14:52:09.000000000 +0200
26562 +++ linux-2.6.27.6-vs2.3.0.36/net/core/sock.c 2008-10-13 14:54:20.000000000 +0200
26563 @@ -124,6 +124,10 @@
26564 #include <linux/ipsec.h>
26566 #include <linux/filter.h>
26567 +#include <linux/vs_socket.h>
26568 +#include <linux/vs_limit.h>
26569 +#include <linux/vs_context.h>
26570 +#include <linux/vs_network.h>
26573 #include <net/tcp.h>
26574 @@ -897,6 +901,8 @@ static struct sock *sk_prot_alloc(struct
26575 if (!try_module_get(prot->owner))
26578 + sock_vx_init(sk);
26579 + sock_nx_init(sk);
26583 @@ -973,6 +979,11 @@ void sk_free(struct sock *sk)
26584 __func__, atomic_read(&sk->sk_omem_alloc));
26586 put_net(sock_net(sk));
26588 + clr_vx_info(&sk->sk_vx_info);
26590 + clr_nx_info(&sk->sk_nx_info);
26592 sk_prot_free(sk->sk_prot_creator, sk);
26595 @@ -1008,6 +1019,8 @@ struct sock *sk_clone(const struct sock
26598 get_net(sock_net(newsk));
26599 + sock_vx_init(newsk);
26600 + sock_nx_init(newsk);
26601 sk_node_init(&newsk->sk_node);
26602 sock_lock_init(newsk);
26603 bh_lock_sock(newsk);
26604 @@ -1054,6 +1067,12 @@ struct sock *sk_clone(const struct sock
26605 newsk->sk_priority = 0;
26606 atomic_set(&newsk->sk_refcnt, 2);
26608 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26609 + newsk->sk_xid = sk->sk_xid;
26610 + vx_sock_inc(newsk);
26611 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26612 + newsk->sk_nid = sk->sk_nid;
26615 * Increment the counter in the same struct proto as the master
26616 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26617 @@ -1738,6 +1757,11 @@ void sock_init_data(struct socket *sock,
26619 sk->sk_stamp = ktime_set(-1L, 0);
26621 + set_vx_info(&sk->sk_vx_info, current->vx_info);
26622 + sk->sk_xid = vx_current_xid();
26624 + set_nx_info(&sk->sk_nx_info, current->nx_info);
26625 + sk->sk_nid = nx_current_nid();
26626 atomic_set(&sk->sk_refcnt, 1);
26627 atomic_set(&sk->sk_drops, 0);
26629 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/af_inet.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/af_inet.c
26630 --- linux-2.6.27.6/net/ipv4/af_inet.c 2008-10-13 14:52:09.000000000 +0200
26631 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/af_inet.c 2008-10-13 14:54:20.000000000 +0200
26632 @@ -114,6 +114,7 @@
26633 #ifdef CONFIG_IP_MROUTE
26634 #include <linux/mroute.h>
26636 +#include <linux/vs_limit.h>
26638 extern void ip_mc_drop_socket(struct sock *sk);
26640 @@ -325,9 +326,12 @@ lookup_protocol:
26644 + if ((protocol == IPPROTO_ICMP) &&
26645 + nx_capable(answer->capability, NXC_RAW_ICMP))
26647 if (answer->capability > 0 && !capable(answer->capability))
26648 goto out_rcu_unlock;
26651 err = -EAFNOSUPPORT;
26652 if (!inet_netns_ok(net, protocol))
26653 goto out_rcu_unlock;
26654 @@ -445,6 +449,7 @@ int inet_bind(struct socket *sock, struc
26655 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26656 struct sock *sk = sock->sk;
26657 struct inet_sock *inet = inet_sk(sk);
26658 + struct nx_v4_sock_addr nsa;
26659 unsigned short snum;
26662 @@ -458,7 +463,11 @@ int inet_bind(struct socket *sock, struc
26663 if (addr_len < sizeof(struct sockaddr_in))
26666 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26667 + err = v4_map_sock_addr(inet, addr, &nsa);
26671 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26673 /* Not specified by any standard per-se, however it breaks too
26674 * many applications when removed. It is unfortunate since
26675 @@ -470,7 +479,7 @@ int inet_bind(struct socket *sock, struc
26676 err = -EADDRNOTAVAIL;
26677 if (!sysctl_ip_nonlocal_bind &&
26679 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26680 + nsa.saddr != htonl(INADDR_ANY) &&
26681 chk_addr_ret != RTN_LOCAL &&
26682 chk_addr_ret != RTN_MULTICAST &&
26683 chk_addr_ret != RTN_BROADCAST)
26684 @@ -495,7 +504,7 @@ int inet_bind(struct socket *sock, struc
26685 if (sk->sk_state != TCP_CLOSE || inet->num)
26686 goto out_release_sock;
26688 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26689 + v4_set_sock_addr(inet, &nsa);
26690 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26691 inet->saddr = 0; /* Use device */
26693 @@ -688,11 +697,13 @@ int inet_getname(struct socket *sock, st
26696 sin->sin_port = inet->dport;
26697 - sin->sin_addr.s_addr = inet->daddr;
26698 + sin->sin_addr.s_addr =
26699 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26701 __be32 addr = inet->rcv_saddr;
26703 addr = inet->saddr;
26704 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26705 sin->sin_port = inet->sport;
26706 sin->sin_addr.s_addr = addr;
26708 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/devinet.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/devinet.c
26709 --- linux-2.6.27.6/net/ipv4/devinet.c 2008-10-13 14:52:09.000000000 +0200
26710 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/devinet.c 2008-10-13 14:54:20.000000000 +0200
26711 @@ -420,6 +420,7 @@ struct in_device *inetdev_by_index(struc
26716 /* Called only from RTNL semaphored context. No locks. */
26718 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26719 @@ -662,6 +663,8 @@ int devinet_ioctl(struct net *net, unsig
26722 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
26723 + struct nx_info *nxi = current->nx_info;
26725 if (tryaddrmatch) {
26726 /* Matthias Andree */
26727 /* compare label and address (4.4BSD style) */
26728 @@ -670,6 +673,8 @@ int devinet_ioctl(struct net *net, unsig
26729 This is checked above. */
26730 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26731 ifap = &ifa->ifa_next) {
26732 + if (!nx_v4_ifa_visible(nxi, ifa))
26734 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26735 sin_orig.sin_addr.s_addr ==
26736 ifa->ifa_address) {
26737 @@ -682,9 +687,12 @@ int devinet_ioctl(struct net *net, unsig
26738 comparing just the label */
26740 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26741 - ifap = &ifa->ifa_next)
26742 + ifap = &ifa->ifa_next) {
26743 + if (!nx_v4_ifa_visible(nxi, ifa))
26745 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26751 @@ -835,6 +843,8 @@ static int inet_gifconf(struct net_devic
26754 for (; ifa; ifa = ifa->ifa_next) {
26755 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
26758 done += sizeof(ifr);
26760 @@ -1165,6 +1175,7 @@ static int inet_dump_ifaddr(struct sk_bu
26761 struct net_device *dev;
26762 struct in_device *in_dev;
26763 struct in_ifaddr *ifa;
26764 + struct sock *sk = skb->sk;
26765 int s_ip_idx, s_idx = cb->args[0];
26767 s_ip_idx = ip_idx = cb->args[1];
26768 @@ -1179,6 +1190,8 @@ static int inet_dump_ifaddr(struct sk_bu
26770 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26771 ifa = ifa->ifa_next, ip_idx++) {
26772 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
26774 if (ip_idx < s_ip_idx)
26776 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
26777 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/fib_hash.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/fib_hash.c
26778 --- linux-2.6.27.6/net/ipv4/fib_hash.c 2008-10-13 14:52:09.000000000 +0200
26779 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/fib_hash.c 2008-10-13 14:54:20.000000000 +0200
26780 @@ -1022,7 +1022,7 @@ static int fib_seq_show(struct seq_file
26781 prefix = f->fn_key;
26782 mask = FZ_MASK(iter->zone);
26783 flags = fib_flag_trans(fa->fa_type, mask, fi);
26785 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
26787 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
26788 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
26789 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/inet_connection_sock.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/inet_connection_sock.c
26790 --- linux-2.6.27.6/net/ipv4/inet_connection_sock.c 2008-10-13 14:52:09.000000000 +0200
26791 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/inet_connection_sock.c 2008-10-13 14:54:20.000000000 +0200
26792 @@ -47,10 +47,40 @@ void inet_get_local_port_range(int *low,
26794 EXPORT_SYMBOL(inet_get_local_port_range);
26796 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26798 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
26799 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
26801 + if (inet_v6_ipv6only(sk2))
26804 + if (sk1_rcv_saddr &&
26806 + sk1_rcv_saddr == sk2_rcv_saddr)
26809 + if (sk1_rcv_saddr &&
26810 + !sk2_rcv_saddr &&
26811 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26814 + if (sk2_rcv_saddr &&
26815 + !sk1_rcv_saddr &&
26816 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26819 + if (!sk1_rcv_saddr &&
26820 + !sk2_rcv_saddr &&
26821 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26827 int inet_csk_bind_conflict(const struct sock *sk,
26828 const struct inet_bind_bucket *tb)
26830 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
26832 struct hlist_node *node;
26833 int reuse = sk->sk_reuse;
26834 @@ -70,9 +100,7 @@ int inet_csk_bind_conflict(const struct
26835 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26836 if (!reuse || !sk2->sk_reuse ||
26837 sk2->sk_state == TCP_LISTEN) {
26838 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26839 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
26840 - sk2_rcv_saddr == sk_rcv_saddr)
26841 + if (ipv4_rcv_saddr_equal(sk, sk2))
26845 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/inet_diag.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/inet_diag.c
26846 --- linux-2.6.27.6/net/ipv4/inet_diag.c 2008-10-13 14:52:09.000000000 +0200
26847 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/inet_diag.c 2008-10-13 14:54:20.000000000 +0200
26849 #include <linux/stddef.h>
26851 #include <linux/inet_diag.h>
26852 +#include <linux/vs_network.h>
26853 +#include <linux/vs_inet.h>
26855 static const struct inet_diag_handler **inet_diag_table;
26857 @@ -120,8 +122,8 @@ static int inet_csk_diag_fill(struct soc
26859 r->id.idiag_sport = inet->sport;
26860 r->id.idiag_dport = inet->dport;
26861 - r->id.idiag_src[0] = inet->rcv_saddr;
26862 - r->id.idiag_dst[0] = inet->daddr;
26863 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
26864 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26866 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26867 if (r->idiag_family == AF_INET6) {
26868 @@ -208,8 +210,8 @@ static int inet_twsk_diag_fill(struct in
26869 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
26870 r->id.idiag_sport = tw->tw_sport;
26871 r->id.idiag_dport = tw->tw_dport;
26872 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
26873 - r->id.idiag_dst[0] = tw->tw_daddr;
26874 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
26875 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
26876 r->idiag_state = tw->tw_substate;
26877 r->idiag_timer = 3;
26878 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
26879 @@ -266,6 +268,7 @@ static int inet_diag_get_exact(struct sk
26882 if (req->idiag_family == AF_INET) {
26883 + /* TODO: lback */
26884 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
26885 req->id.idiag_dport, req->id.idiag_src[0],
26886 req->id.idiag_sport, req->id.idiag_if);
26887 @@ -508,6 +511,7 @@ static int inet_csk_diag_dump(struct soc
26891 + /* TODO: lback */
26892 entry.saddr = &inet->rcv_saddr;
26893 entry.daddr = &inet->daddr;
26895 @@ -544,6 +548,7 @@ static int inet_twsk_diag_dump(struct in
26899 + /* TODO: lback */
26900 entry.saddr = &tw->tw_rcv_saddr;
26901 entry.daddr = &tw->tw_daddr;
26903 @@ -590,8 +595,8 @@ static int inet_diag_fill_req(struct sk_
26905 r->id.idiag_sport = inet->sport;
26906 r->id.idiag_dport = ireq->rmt_port;
26907 - r->id.idiag_src[0] = ireq->loc_addr;
26908 - r->id.idiag_dst[0] = ireq->rmt_addr;
26909 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
26910 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
26911 r->idiag_expires = jiffies_to_msecs(tmo);
26912 r->idiag_rqueue = 0;
26913 r->idiag_wqueue = 0;
26914 @@ -661,6 +666,7 @@ static int inet_diag_dump_reqs(struct sk
26918 + /* TODO: lback */
26920 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26921 (entry.family == AF_INET6) ?
26922 @@ -729,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
26923 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
26924 struct inet_sock *inet = inet_sk(sk);
26926 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26931 @@ -790,6 +798,8 @@ skip_listen_ht:
26932 sk_for_each(sk, node, &head->chain) {
26933 struct inet_sock *inet = inet_sk(sk);
26935 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26939 if (!(r->idiag_states & (1 << sk->sk_state)))
26940 @@ -814,6 +824,8 @@ next_normal:
26941 inet_twsk_for_each(tw, node,
26944 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26948 if (r->id.idiag_sport != tw->tw_sport &&
26949 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/inet_hashtables.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/inet_hashtables.c
26950 --- linux-2.6.27.6/net/ipv4/inet_hashtables.c 2008-10-13 14:52:09.000000000 +0200
26951 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/inet_hashtables.c 2008-10-13 14:54:20.000000000 +0200
26954 #include <net/inet_connection_sock.h>
26955 #include <net/inet_hashtables.h>
26956 +#include <net/route.h>
26957 #include <net/ip.h>
26960 @@ -163,11 +164,10 @@ static struct sock *inet_lookup_listener
26961 const __be32 rcv_saddr = inet->rcv_saddr;
26962 int score = sk->sk_family == PF_INET ? 1 : 0;
26965 - if (rcv_saddr != daddr)
26967 + if (v4_inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
26972 if (sk->sk_bound_dev_if) {
26973 if (sk->sk_bound_dev_if != dif)
26975 @@ -199,7 +199,7 @@ struct sock *__inet_lookup_listener(stru
26976 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
26978 if (inet->num == hnum && !sk->sk_node.next &&
26979 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
26980 + v4_inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
26981 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
26982 !sk->sk_bound_dev_if && net_eq(sock_net(sk), net))
26984 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/netfilter/nf_nat_helper.c
26985 --- linux-2.6.27.6/net/ipv4/netfilter/nf_nat_helper.c 2008-07-13 23:51:29.000000000 +0200
26986 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/netfilter/nf_nat_helper.c 2008-10-13 14:54:20.000000000 +0200
26988 #include <net/tcp.h>
26990 #include <linux/netfilter_ipv4.h>
26991 +#include <net/route.h>
26992 #include <net/netfilter/nf_conntrack.h>
26993 #include <net/netfilter/nf_conntrack_helper.h>
26994 #include <net/netfilter/nf_conntrack_ecache.h>
26995 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/netfilter.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/netfilter.c
26996 --- linux-2.6.27.6/net/ipv4/netfilter.c 2008-07-13 23:51:29.000000000 +0200
26997 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/netfilter.c 2008-10-13 14:54:20.000000000 +0200
26999 #include <linux/netfilter_ipv4.h>
27000 #include <linux/ip.h>
27001 #include <linux/skbuff.h>
27002 -#include <net/route.h>
27003 +// #include <net/route.h>
27004 #include <net/xfrm.h>
27005 #include <net/ip.h>
27006 #include <net/netfilter/nf_queue.h>
27007 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/raw.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/raw.c
27008 --- linux-2.6.27.6/net/ipv4/raw.c 2008-10-13 14:52:09.000000000 +0200
27009 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/raw.c 2008-10-13 14:54:20.000000000 +0200
27010 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
27012 if (net_eq(sock_net(sk), net) && inet->num == num &&
27013 !(inet->daddr && inet->daddr != raddr) &&
27014 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
27015 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
27016 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27017 goto found; /* gotcha */
27019 @@ -372,6 +372,12 @@ static int raw_send_hdrinc(struct sock *
27020 icmp_out_count(net, ((struct icmphdr *)
27021 skb_transport_header(skb))->type);
27024 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27025 + sk->sk_nx_info &&
27026 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27029 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
27032 @@ -383,6 +389,7 @@ out:
27039 IP_INC_STATS(net, IPSTATS_MIB_OUTDISCARDS);
27040 @@ -550,6 +557,13 @@ static int raw_sendmsg(struct kiocb *ioc
27043 security_sk_classify_flow(sk, &fl);
27044 + if (sk->sk_nx_info) {
27045 + err = ip_v4_find_src(sock_net(sk),
27046 + sk->sk_nx_info, &rt, &fl);
27051 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27054 @@ -619,17 +633,19 @@ static int raw_bind(struct sock *sk, str
27056 struct inet_sock *inet = inet_sk(sk);
27057 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27058 + struct nx_v4_sock_addr nsa = { 0 };
27062 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27064 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27065 + v4_map_sock_addr(inet, addr, &nsa);
27066 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27067 ret = -EADDRNOTAVAIL;
27068 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27069 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27070 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27072 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
27073 + v4_set_sock_addr(inet, &nsa);
27074 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27075 inet->saddr = 0; /* Use device */
27077 @@ -681,7 +697,8 @@ static int raw_recvmsg(struct kiocb *ioc
27078 /* Copy the address. */
27080 sin->sin_family = AF_INET;
27081 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27082 + sin->sin_addr.s_addr =
27083 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27085 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27087 @@ -858,7 +875,8 @@ static struct sock *raw_get_first(struct
27088 struct hlist_node *node;
27090 sk_for_each(sk, node, &state->h->ht[state->bucket])
27091 - if (sock_net(sk) == seq_file_net(seq))
27092 + if ((sock_net(sk) == seq_file_net(seq)) &&
27093 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27097 @@ -874,7 +892,8 @@ static struct sock *raw_get_next(struct
27101 - } while (sk && sock_net(sk) != seq_file_net(seq));
27102 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27103 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27105 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27106 sk = sk_head(&state->h->ht[state->bucket]);
27107 @@ -933,7 +952,10 @@ static void raw_sock_seq_show(struct seq
27109 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27110 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27111 - i, src, srcp, dest, destp, sp->sk_state,
27113 + nx_map_sock_lback(current_nx_info(), src), srcp,
27114 + nx_map_sock_lback(current_nx_info(), dest), destp,
27116 atomic_read(&sp->sk_wmem_alloc),
27117 atomic_read(&sp->sk_rmem_alloc),
27118 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27119 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/syncookies.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/syncookies.c
27120 --- linux-2.6.27.6/net/ipv4/syncookies.c 2008-10-13 14:52:09.000000000 +0200
27121 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/syncookies.c 2008-10-13 14:54:20.000000000 +0200
27123 #include <linux/cryptohash.h>
27124 #include <linux/kernel.h>
27125 #include <net/tcp.h>
27126 +#include <net/route.h>
27128 /* Timestamps: lowest 9 bits store TCP options */
27130 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/tcp.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/tcp.c
27131 --- linux-2.6.27.6/net/ipv4/tcp.c 2008-10-13 14:52:09.000000000 +0200
27132 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/tcp.c 2008-10-13 14:54:20.000000000 +0200
27133 @@ -264,6 +264,7 @@
27134 #include <linux/cache.h>
27135 #include <linux/err.h>
27136 #include <linux/crypto.h>
27137 +#include <linux/in.h>
27139 #include <net/icmp.h>
27140 #include <net/tcp.h>
27141 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/tcp_ipv4.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/tcp_ipv4.c
27142 --- linux-2.6.27.6/net/ipv4/tcp_ipv4.c 2008-10-13 14:52:09.000000000 +0200
27143 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/tcp_ipv4.c 2008-10-13 14:54:20.000000000 +0200
27144 @@ -1886,6 +1886,12 @@ static void *listening_get_next(struct s
27145 req = req->dl_next;
27148 + vxdprintk(VXD_CBIT(net, 6),
27149 + "sk,req: %p [#%d] (from %d)", req->sk,
27150 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27152 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27154 if (req->rsk_ops->family == st->family) {
27157 @@ -1910,6 +1916,10 @@ get_req:
27160 sk_for_each_from(sk, node) {
27161 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27162 + sk, sk->sk_nid, nx_current_nid());
27163 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27165 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27168 @@ -1960,6 +1970,11 @@ static void *established_get_first(struc
27170 read_lock_bh(lock);
27171 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27172 + vxdprintk(VXD_CBIT(net, 6),
27173 + "sk,egf: %p [#%d] (from %d)",
27174 + sk, sk->sk_nid, nx_current_nid());
27175 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27177 if (sk->sk_family != st->family ||
27178 !net_eq(sock_net(sk), net)) {
27180 @@ -1970,6 +1985,11 @@ static void *established_get_first(struc
27181 st->state = TCP_SEQ_STATE_TIME_WAIT;
27182 inet_twsk_for_each(tw, node,
27183 &tcp_hashinfo.ehash[st->bucket].twchain) {
27184 + vxdprintk(VXD_CBIT(net, 6),
27185 + "tw: %p [#%d] (from %d)",
27186 + tw, tw->tw_nid, nx_current_nid());
27187 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27189 if (tw->tw_family != st->family ||
27190 !net_eq(twsk_net(tw), net)) {
27192 @@ -1998,7 +2018,9 @@ static void *established_get_next(struct
27196 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27197 + while (tw && (tw->tw_family != st->family ||
27198 + !net_eq(twsk_net(tw), net) ||
27199 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27203 @@ -2019,6 +2041,11 @@ get_tw:
27206 sk_for_each_from(sk, node) {
27207 + vxdprintk(VXD_CBIT(net, 6),
27208 + "sk,egn: %p [#%d] (from %d)",
27209 + sk, sk->sk_nid, nx_current_nid());
27210 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27212 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27215 @@ -2173,9 +2200,9 @@ static void get_openreq4(struct sock *sk
27216 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27217 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27220 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27221 ntohs(inet_sk(sk)->sport),
27223 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27224 ntohs(ireq->rmt_port),
27226 0, 0, /* could print option size, but that is af dependent. */
27227 @@ -2218,7 +2245,10 @@ static void get_tcp4_sock(struct sock *s
27229 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27230 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27231 - i, src, srcp, dest, destp, sk->sk_state,
27233 + nx_map_sock_lback(current_nx_info(), src), srcp,
27234 + nx_map_sock_lback(current_nx_info(), dest), destp,
27236 tp->write_seq - tp->snd_una,
27237 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
27238 (tp->rcv_nxt - tp->copied_seq),
27239 @@ -2254,7 +2284,10 @@ static void get_timewait4_sock(struct in
27241 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27242 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27243 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27245 + nx_map_sock_lback(current_nx_info(), src), srcp,
27246 + nx_map_sock_lback(current_nx_info(), dest), destp,
27247 + tw->tw_substate, 0, 0,
27248 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27249 atomic_read(&tw->tw_refcnt), tw, len);
27251 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/tcp_minisocks.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/tcp_minisocks.c
27252 --- linux-2.6.27.6/net/ipv4/tcp_minisocks.c 2008-10-13 14:52:09.000000000 +0200
27253 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/tcp_minisocks.c 2008-10-13 14:54:20.000000000 +0200
27255 #include <net/inet_common.h>
27256 #include <net/xfrm.h>
27258 +#include <linux/vs_limit.h>
27259 +#include <linux/vs_socket.h>
27260 +#include <linux/vs_context.h>
27262 #ifdef CONFIG_SYSCTL
27263 #define SYNC_INIT 0 /* let the user enable it */
27265 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
27266 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
27267 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27269 + tw->tw_xid = sk->sk_xid;
27270 + tw->tw_vx_info = NULL;
27271 + tw->tw_nid = sk->sk_nid;
27272 + tw->tw_nx_info = NULL;
27274 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27275 if (tw->tw_family == PF_INET6) {
27276 struct ipv6_pinfo *np = inet6_sk(sk);
27277 diff -NurpP --minimal linux-2.6.27.6/net/ipv4/udp.c linux-2.6.27.6-vs2.3.0.36/net/ipv4/udp.c
27278 --- linux-2.6.27.6/net/ipv4/udp.c 2008-10-13 14:52:09.000000000 +0200
27279 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv4/udp.c 2008-10-13 14:54:20.000000000 +0200
27280 @@ -234,20 +234,14 @@ fail:
27284 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27286 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27288 - return ( !ipv6_only_sock(sk2) &&
27289 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
27290 - inet1->rcv_saddr == inet2->rcv_saddr ));
27292 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27294 int udp_v4_get_port(struct sock *sk, unsigned short snum)
27296 return udp_lib_get_port(sk, snum, ipv4_rcv_saddr_equal);
27300 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27301 * harder than this. -DaveM
27303 @@ -267,10 +261,16 @@ static struct sock *__udp4_lib_lookup(st
27304 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
27305 !ipv6_only_sock(sk)) {
27306 int score = (sk->sk_family == PF_INET ? 1 : 0);
27308 if (inet->rcv_saddr) {
27309 if (inet->rcv_saddr != daddr)
27313 + /* block non nx_info ips */
27314 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27315 + daddr, NXA_MASK_BIND))
27319 if (inet->daddr != saddr)
27320 @@ -296,6 +296,7 @@ static struct sock *__udp4_lib_lookup(st
27327 read_unlock(&udp_hash_lock);
27328 @@ -317,7 +318,7 @@ static inline struct sock *udp_v4_mcast_
27329 if (s->sk_hash != hnum ||
27330 (inet->daddr && inet->daddr != rmt_addr) ||
27331 (inet->dport != rmt_port && inet->dport) ||
27332 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
27333 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27334 ipv6_only_sock(s) ||
27335 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27337 @@ -654,8 +655,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27338 { .sport = inet->sport,
27339 .dport = dport } } };
27340 struct net *net = sock_net(sk);
27341 + struct nx_info *nxi = sk->sk_nx_info;
27343 security_sk_classify_flow(sk, &fl);
27344 + err = ip_v4_find_src(net, nxi, &rt, &fl);
27348 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27350 if (err == -ENETUNREACH)
27351 @@ -900,7 +906,8 @@ try_again:
27353 sin->sin_family = AF_INET;
27354 sin->sin_port = udp_hdr(skb)->source;
27355 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27356 + sin->sin_addr.s_addr = nx_map_sock_lback(
27357 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27358 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27360 if (inet->cmsg_flags)
27361 @@ -1528,6 +1535,8 @@ static struct sock *udp_get_first(struct
27362 sk_for_each(sk, node, state->hashtable + state->bucket) {
27363 if (!net_eq(sock_net(sk), net))
27365 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27367 if (sk->sk_family == state->family)
27370 @@ -1546,7 +1555,9 @@ static struct sock *udp_get_next(struct
27374 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27375 + } while (sk && (!net_eq(sock_net(sk), net) ||
27376 + sk->sk_family != state->family ||
27377 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27379 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
27380 sk = sk_head(state->hashtable + state->bucket);
27381 @@ -1647,7 +1658,10 @@ static void udp4_format_sock(struct sock
27383 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27384 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27385 - bucket, src, srcp, dest, destp, sp->sk_state,
27387 + nx_map_sock_lback(current_nx_info(), src), srcp,
27388 + nx_map_sock_lback(current_nx_info(), dest), destp,
27390 atomic_read(&sp->sk_wmem_alloc),
27391 atomic_read(&sp->sk_rmem_alloc),
27392 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27393 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/addrconf.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/addrconf.c
27394 --- linux-2.6.27.6/net/ipv6/addrconf.c 2008-10-13 14:52:09.000000000 +0200
27395 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/addrconf.c 2008-10-13 14:54:20.000000000 +0200
27398 #include <linux/proc_fs.h>
27399 #include <linux/seq_file.h>
27400 +#include <linux/vs_network.h>
27401 +#include <linux/vs_inet6.h>
27403 /* Set to 3 to get tracing... */
27404 #define ACONF_DEBUG 2
27405 @@ -1108,7 +1110,7 @@ out:
27407 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27408 const struct in6_addr *daddr, unsigned int prefs,
27409 - struct in6_addr *saddr)
27410 + struct in6_addr *saddr, struct nx_info *nxi)
27412 struct ipv6_saddr_score scores[2],
27413 *score = &scores[0], *hiscore = &scores[1];
27414 @@ -1364,35 +1366,46 @@ struct inet6_ifaddr *ipv6_get_ifaddr(str
27418 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
27420 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
27422 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
27423 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
27424 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
27425 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27426 int sk_ipv6only = ipv6_only_sock(sk);
27427 int sk2_ipv6only = inet_v6_ipv6only(sk2);
27428 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
27429 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
27431 - if (!sk2_rcv_saddr && !sk_ipv6only)
27432 + /* FIXME: needs handling for v4 ANY */
27433 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
27436 if (addr_type2 == IPV6_ADDR_ANY &&
27437 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
27438 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
27439 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
27442 if (addr_type == IPV6_ADDR_ANY &&
27443 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27444 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
27445 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
27448 + if (addr_type == IPV6_ADDR_ANY &&
27449 + addr_type2 == IPV6_ADDR_ANY &&
27450 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
27453 if (sk2_rcv_saddr6 &&
27454 + addr_type != IPV6_ADDR_ANY &&
27455 + addr_type != IPV6_ADDR_ANY &&
27456 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
27459 if (addr_type == IPV6_ADDR_MAPPED &&
27461 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
27462 + ipv4_rcv_saddr_equal(sk, sk2))
27466 @@ -2986,7 +2999,10 @@ static void if6_seq_stop(struct seq_file
27467 static int if6_seq_show(struct seq_file *seq, void *v)
27469 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27472 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27473 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27475 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
27477 ifp->idev->dev->ifindex,
27478 @@ -3481,6 +3497,12 @@ static int inet6_dump_addr(struct sk_buf
27479 struct ifmcaddr6 *ifmca;
27480 struct ifacaddr6 *ifaca;
27481 struct net *net = sock_net(skb->sk);
27482 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27484 + /* disable ipv6 on non v6 guests */
27485 + if (nxi && !nx_info_has_v6(nxi))
27489 s_idx = cb->args[0];
27490 s_ip_idx = ip_idx = cb->args[1];
27491 @@ -3502,6 +3524,8 @@ static int inet6_dump_addr(struct sk_buf
27492 ifa = ifa->if_next, ip_idx++) {
27493 if (ip_idx < s_ip_idx)
27495 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27497 err = inet6_fill_ifaddr(skb, ifa,
27498 NETLINK_CB(cb->skb).pid,
27499 cb->nlh->nlmsg_seq,
27500 @@ -3515,6 +3539,8 @@ static int inet6_dump_addr(struct sk_buf
27501 ifmca = ifmca->next, ip_idx++) {
27502 if (ip_idx < s_ip_idx)
27504 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27506 err = inet6_fill_ifmcaddr(skb, ifmca,
27507 NETLINK_CB(cb->skb).pid,
27508 cb->nlh->nlmsg_seq,
27509 @@ -3528,6 +3554,8 @@ static int inet6_dump_addr(struct sk_buf
27510 ifaca = ifaca->aca_next, ip_idx++) {
27511 if (ip_idx < s_ip_idx)
27513 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27515 err = inet6_fill_ifacaddr(skb, ifaca,
27516 NETLINK_CB(cb->skb).pid,
27517 cb->nlh->nlmsg_seq,
27518 @@ -3813,12 +3841,19 @@ static int inet6_dump_ifinfo(struct sk_b
27519 int s_idx = cb->args[0];
27520 struct net_device *dev;
27521 struct inet6_dev *idev;
27522 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27524 + /* FIXME: maybe disable ipv6 on non v6 guests?
27525 + if (skb->sk && skb->sk->sk_vx_info)
27526 + return skb->len; */
27528 read_lock(&dev_base_lock);
27530 for_each_netdev(net, dev) {
27533 + if (!v6_dev_in_nx_info(dev, nxi))
27535 if ((idev = in6_dev_get(dev)) == NULL)
27537 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
27538 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/af_inet6.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/af_inet6.c
27539 --- linux-2.6.27.6/net/ipv6/af_inet6.c 2008-10-13 14:52:09.000000000 +0200
27540 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/af_inet6.c 2008-10-13 14:54:20.000000000 +0200
27542 #include <linux/netdevice.h>
27543 #include <linux/icmpv6.h>
27544 #include <linux/netfilter_ipv6.h>
27545 +#include <linux/vs_inet.h>
27546 +#include <linux/vs_inet6.h>
27548 #include <net/ip.h>
27549 #include <net/ipv6.h>
27551 #include <net/tcp.h>
27552 #include <net/ipip.h>
27553 #include <net/protocol.h>
27554 +#include <net/route.h>
27555 #include <net/inet_common.h>
27556 #include <net/transp_v6.h>
27557 #include <net/ip6_route.h>
27558 @@ -141,9 +144,12 @@ lookup_protocol:
27562 + if ((protocol == IPPROTO_ICMPV6) &&
27563 + nx_capable(answer->capability, NXC_RAW_ICMP))
27565 if (answer->capability > 0 && !capable(answer->capability))
27566 goto out_rcu_unlock;
27569 sock->ops = answer->ops;
27570 answer_prot = answer->prot;
27571 answer_no_check = answer->no_check;
27572 @@ -242,6 +248,7 @@ int inet6_bind(struct socket *sock, stru
27573 struct inet_sock *inet = inet_sk(sk);
27574 struct ipv6_pinfo *np = inet6_sk(sk);
27575 struct net *net = sock_net(sk);
27576 + struct nx_v6_sock_addr nsa;
27578 unsigned short snum;
27580 @@ -253,6 +260,11 @@ int inet6_bind(struct socket *sock, stru
27582 if (addr_len < SIN6_LEN_RFC2133)
27585 + err = v6_map_sock_addr(inet, addr, &nsa);
27589 addr_type = ipv6_addr_type(&addr->sin6_addr);
27590 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27592 @@ -276,6 +288,10 @@ int inet6_bind(struct socket *sock, stru
27593 err = -EADDRNOTAVAIL;
27596 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27597 + err = -EADDRNOTAVAIL;
27601 if (addr_type != IPV6_ADDR_ANY) {
27602 struct net_device *dev = NULL;
27603 @@ -301,6 +317,11 @@ int inet6_bind(struct socket *sock, stru
27607 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27608 + err = -EADDRNOTAVAIL;
27612 /* ipv4 addr of the socket is invalid. Only the
27613 * unspecified and mapped address have a v4 equivalent.
27615 @@ -319,6 +340,8 @@ int inet6_bind(struct socket *sock, stru
27619 + v6_set_sock_addr(inet, &nsa);
27621 inet->rcv_saddr = v4addr;
27622 inet->saddr = v4addr;
27624 @@ -411,9 +434,11 @@ int inet6_getname(struct socket *sock, s
27626 sin->sin6_port = inet->dport;
27627 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27628 + /* FIXME: remap lback? */
27630 sin->sin6_flowinfo = np->flow_label;
27632 + /* FIXME: remap lback? */
27633 if (ipv6_addr_any(&np->rcv_saddr))
27634 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27636 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/fib6_rules.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/fib6_rules.c
27637 --- linux-2.6.27.6/net/ipv6/fib6_rules.c 2008-10-13 14:52:09.000000000 +0200
27638 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/fib6_rules.c 2008-10-13 14:54:20.000000000 +0200
27639 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
27640 if (ipv6_dev_get_saddr(net,
27641 ip6_dst_idev(&rt->u.dst)->dev,
27642 &flp->fl6_dst, srcprefs,
27646 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27648 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/inet6_hashtables.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/inet6_hashtables.c
27649 --- linux-2.6.27.6/net/ipv6/inet6_hashtables.c 2008-10-13 14:52:09.000000000 +0200
27650 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/inet6_hashtables.c 2008-10-13 14:54:20.000000000 +0200
27653 #include <linux/module.h>
27654 #include <linux/random.h>
27655 +#include <linux/vs_inet6.h>
27657 #include <net/inet_connection_sock.h>
27658 #include <net/inet_hashtables.h>
27659 @@ -115,6 +116,9 @@ struct sock *inet6_lookup_listener(struc
27660 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27664 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27667 if (sk->sk_bound_dev_if) {
27668 if (sk->sk_bound_dev_if != dif)
27669 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/ip6_output.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/ip6_output.c
27670 --- linux-2.6.27.6/net/ipv6/ip6_output.c 2008-10-13 14:52:09.000000000 +0200
27671 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/ip6_output.c 2008-10-13 14:54:20.000000000 +0200
27672 @@ -937,7 +937,7 @@ static int ip6_dst_lookup_tail(struct so
27673 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27675 sk ? inet6_sk(sk)->srcprefs : 0,
27677 + &fl->fl6_src, sk->sk_nx_info);
27679 goto out_err_release;
27681 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/Kconfig linux-2.6.27.6-vs2.3.0.36/net/ipv6/Kconfig
27682 --- linux-2.6.27.6/net/ipv6/Kconfig 2008-10-13 14:52:09.000000000 +0200
27683 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/Kconfig 2008-10-13 14:54:20.000000000 +0200
27686 # IPv6 as module will cause a CRASH if you try to unload it
27688 - tristate "The IPv6 protocol"
27690 + bool "The IPv6 protocol"
27693 This is complemental support for the IP version 6.
27694 You will still be able to do traditional IPv4 networking as well.
27695 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/ndisc.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/ndisc.c
27696 --- linux-2.6.27.6/net/ipv6/ndisc.c 2008-10-13 14:52:09.000000000 +0200
27697 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/ndisc.c 2008-10-13 14:54:20.000000000 +0200
27698 @@ -551,7 +551,7 @@ static void ndisc_send_na(struct net_dev
27700 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27701 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27703 + &tmpaddr, NULL /* FIXME: ? */ ))
27705 src_addr = &tmpaddr;
27707 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/route.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/route.c
27708 --- linux-2.6.27.6/net/ipv6/route.c 2008-10-13 14:52:09.000000000 +0200
27709 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/route.c 2008-10-13 14:54:20.000000000 +0200
27710 @@ -2191,7 +2191,8 @@ static int rt6_fill_node(struct net *net
27711 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
27712 struct in6_addr saddr_buf;
27713 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27714 - dst, 0, &saddr_buf) == 0)
27715 + dst, 0, &saddr_buf,
27716 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27717 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27720 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/tcp_ipv6.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/tcp_ipv6.c
27721 --- linux-2.6.27.6/net/ipv6/tcp_ipv6.c 2008-11-17 18:07:35.000000000 +0100
27722 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/tcp_ipv6.c 2008-11-17 18:20:41.000000000 +0100
27725 #include <linux/crypto.h>
27726 #include <linux/scatterlist.h>
27727 +#include <linux/vs_inet6.h>
27729 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27730 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27731 @@ -155,8 +156,15 @@ static int tcp_v6_connect(struct sock *s
27732 * connect() to INADDR_ANY means loopback (BSD'ism).
27735 - if(ipv6_addr_any(&usin->sin6_addr))
27736 - usin->sin6_addr.s6_addr[15] = 0x1;
27737 + if(ipv6_addr_any(&usin->sin6_addr)) {
27738 + struct nx_info *nxi = sk->sk_nx_info;
27740 + if (nxi && nx_info_has_v6(nxi))
27741 + /* FIXME: remap lback? */
27742 + usin->sin6_addr = nxi->v6.ip;
27744 + usin->sin6_addr.s6_addr[15] = 0x1;
27747 addr_type = ipv6_addr_type(&usin->sin6_addr);
27749 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/udp.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/udp.c
27750 --- linux-2.6.27.6/net/ipv6/udp.c 2008-10-13 14:52:09.000000000 +0200
27751 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/udp.c 2008-10-13 14:54:20.000000000 +0200
27754 #include <linux/proc_fs.h>
27755 #include <linux/seq_file.h>
27756 +#include <linux/vs_inet6.h>
27757 #include "udp_impl.h"
27759 int udp_v6_get_port(struct sock *sk, unsigned short snum)
27760 @@ -81,6 +82,10 @@ static struct sock *__udp6_lib_lookup(st
27761 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27765 + /* block non nx_info ips */
27766 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27769 if (!ipv6_addr_any(&np->daddr)) {
27770 if (!ipv6_addr_equal(&np->daddr, saddr))
27771 diff -NurpP --minimal linux-2.6.27.6/net/ipv6/xfrm6_policy.c linux-2.6.27.6-vs2.3.0.36/net/ipv6/xfrm6_policy.c
27772 --- linux-2.6.27.6/net/ipv6/xfrm6_policy.c 2008-10-13 14:52:09.000000000 +0200
27773 +++ linux-2.6.27.6-vs2.3.0.36/net/ipv6/xfrm6_policy.c 2008-10-13 14:54:20.000000000 +0200
27774 @@ -61,7 +61,7 @@ static int xfrm6_get_saddr(xfrm_address_
27775 dev = ip6_dst_idev(dst)->dev;
27776 ipv6_dev_get_saddr(dev_net(dev), dev,
27777 (struct in6_addr *)&daddr->a6, 0,
27778 - (struct in6_addr *)&saddr->a6);
27779 + (struct in6_addr *)&saddr->a6, NULL);
27783 diff -NurpP --minimal linux-2.6.27.6/net/Kconfig linux-2.6.27.6-vs2.3.0.36/net/Kconfig
27784 --- linux-2.6.27.6/net/Kconfig 2008-10-13 14:52:09.000000000 +0200
27785 +++ linux-2.6.27.6-vs2.3.0.36/net/Kconfig 2008-11-20 15:21:32.000000000 +0100
27786 @@ -27,7 +27,7 @@ menu "Networking options"
27788 bool "Network namespace support"
27790 - depends on EXPERIMENTAL && !SYSFS && NAMESPACES
27791 + depends on EXPERIMENTAL && NAMESPACES
27793 Allow user space to create what appear to be multiple instances
27794 of the network stack.
27795 diff -NurpP --minimal linux-2.6.27.6/net/netlink/af_netlink.c linux-2.6.27.6-vs2.3.0.36/net/netlink/af_netlink.c
27796 --- linux-2.6.27.6/net/netlink/af_netlink.c 2008-10-13 14:52:09.000000000 +0200
27797 +++ linux-2.6.27.6-vs2.3.0.36/net/netlink/af_netlink.c 2008-10-13 14:54:20.000000000 +0200
27799 #include <linux/types.h>
27800 #include <linux/audit.h>
27801 #include <linux/mutex.h>
27802 +#include <linux/vs_context.h>
27803 +#include <linux/vs_network.h>
27804 +#include <linux/vs_limit.h>
27806 #include <net/net_namespace.h>
27807 #include <net/sock.h>
27808 @@ -1761,6 +1764,8 @@ static struct sock *netlink_seq_socket_i
27809 sk_for_each(s, node, &hash->table[j]) {
27810 if (sock_net(s) != seq_file_net(seq))
27812 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27816 iter->hash_idx = j;
27817 @@ -1795,7 +1800,8 @@ static void *netlink_seq_next(struct seq
27821 - } while (s && sock_net(s) != seq_file_net(seq));
27822 + } while (s && (sock_net(s) != seq_file_net(seq) ||
27823 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
27827 @@ -1807,7 +1813,8 @@ static void *netlink_seq_next(struct seq
27829 for (; j <= hash->mask; j++) {
27830 s = sk_head(&hash->table[j]);
27831 - while (s && sock_net(s) != seq_file_net(seq))
27832 + while (s && (sock_net(s) != seq_file_net(seq) ||
27833 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
27837 diff -NurpP --minimal linux-2.6.27.6/net/sctp/ipv6.c linux-2.6.27.6-vs2.3.0.36/net/sctp/ipv6.c
27838 --- linux-2.6.27.6/net/sctp/ipv6.c 2008-10-13 14:52:09.000000000 +0200
27839 +++ linux-2.6.27.6-vs2.3.0.36/net/sctp/ipv6.c 2008-10-13 14:54:20.000000000 +0200
27840 @@ -323,7 +323,8 @@ static void sctp_v6_get_saddr(struct sct
27841 dst ? ip6_dst_idev(dst)->dev : NULL,
27842 &daddr->v6.sin6_addr,
27843 inet6_sk(&sk->inet.sk)->srcprefs,
27844 - &saddr->v6.sin6_addr);
27845 + &saddr->v6.sin6_addr,
27846 + asoc->base.sk->sk_nx_info);
27847 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
27848 NIP6(saddr->v6.sin6_addr));
27850 diff -NurpP --minimal linux-2.6.27.6/net/socket.c linux-2.6.27.6-vs2.3.0.36/net/socket.c
27851 --- linux-2.6.27.6/net/socket.c 2008-10-13 14:52:09.000000000 +0200
27852 +++ linux-2.6.27.6-vs2.3.0.36/net/socket.c 2008-10-13 14:54:20.000000000 +0200
27855 #include <net/sock.h>
27856 #include <linux/netfilter.h>
27857 +#include <linux/vs_base.h>
27858 +#include <linux/vs_socket.h>
27859 +#include <linux/vs_inet.h>
27860 +#include <linux/vs_inet6.h>
27862 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
27863 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
27864 @@ -550,7 +554,7 @@ static inline int __sock_sendmsg(struct
27865 struct msghdr *msg, size_t size)
27867 struct sock_iocb *si = kiocb_to_siocb(iocb);
27873 @@ -561,7 +565,22 @@ static inline int __sock_sendmsg(struct
27877 - return sock->ops->sendmsg(iocb, sock, msg, size);
27878 + len = sock->ops->sendmsg(iocb, sock, msg, size);
27881 + vx_sock_send(sock->sk, size);
27883 + vx_sock_fail(sock->sk, size);
27885 + vxdprintk(VXD_CBIT(net, 7),
27886 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27888 + (sock->sk)?sock->sk->sk_nx_info:0,
27889 + (sock->sk)?sock->sk->sk_vx_info:0,
27890 + (sock->sk)?sock->sk->sk_xid:0,
27891 + (sock->sk)?sock->sk->sk_nid:0,
27892 + (unsigned int)size, len);
27896 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
27897 @@ -630,7 +649,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
27898 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
27899 struct msghdr *msg, size_t size, int flags)
27903 struct sock_iocb *si = kiocb_to_siocb(iocb);
27906 @@ -643,7 +662,18 @@ static inline int __sock_recvmsg(struct
27910 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
27911 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
27912 + if ((len >= 0) && sock->sk)
27913 + vx_sock_recv(sock->sk, len);
27914 + vxdprintk(VXD_CBIT(net, 7),
27915 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27917 + (sock->sk)?sock->sk->sk_nx_info:0,
27918 + (sock->sk)?sock->sk->sk_vx_info:0,
27919 + (sock->sk)?sock->sk->sk_xid:0,
27920 + (sock->sk)?sock->sk->sk_nid:0,
27921 + (unsigned int)size, len);
27925 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
27926 @@ -1108,6 +1138,13 @@ static int __sock_create(struct net *net
27927 if (type < 0 || type >= SOCK_MAX)
27930 + if (!nx_check(0, VS_ADMIN)) {
27931 + if (family == PF_INET && !current_nx_info_has_v4())
27932 + return -EAFNOSUPPORT;
27933 + if (family == PF_INET6 && !current_nx_info_has_v6())
27934 + return -EAFNOSUPPORT;
27939 This uglymoron is moved from INET layer to here to avoid
27940 @@ -1240,6 +1277,7 @@ asmlinkage long sys_socket(int family, i
27944 + set_bit(SOCK_USER_SOCKET, &sock->flags);
27945 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
27948 @@ -1281,10 +1319,12 @@ asmlinkage long sys_socketpair(int famil
27949 err = sock_create(family, type, protocol, &sock1);
27952 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
27954 err = sock_create(family, type, protocol, &sock2);
27956 goto out_release_1;
27957 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
27959 err = sock1->ops->socketpair(sock1, sock2);
27961 diff -NurpP --minimal linux-2.6.27.6/net/sunrpc/auth.c linux-2.6.27.6-vs2.3.0.36/net/sunrpc/auth.c
27962 --- linux-2.6.27.6/net/sunrpc/auth.c 2008-07-13 23:51:29.000000000 +0200
27963 +++ linux-2.6.27.6-vs2.3.0.36/net/sunrpc/auth.c 2008-10-13 14:54:20.000000000 +0200
27965 #include <linux/hash.h>
27966 #include <linux/sunrpc/clnt.h>
27967 #include <linux/spinlock.h>
27968 +#include <linux/vs_tag.h>
27971 # define RPCDBG_FACILITY RPCDBG_AUTH
27972 @@ -353,6 +354,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
27973 struct auth_cred acred = {
27974 .uid = current->fsuid,
27975 .gid = current->fsgid,
27976 + .tag = dx_current_tag(),
27977 .group_info = current->group_info,
27979 struct rpc_cred *ret;
27980 @@ -398,6 +400,7 @@ rpcauth_bind_root_cred(struct rpc_task *
27981 struct auth_cred acred = {
27984 + .tag = dx_current_tag(),
27986 struct rpc_cred *ret;
27988 diff -NurpP --minimal linux-2.6.27.6/net/sunrpc/auth_unix.c linux-2.6.27.6-vs2.3.0.36/net/sunrpc/auth_unix.c
27989 --- linux-2.6.27.6/net/sunrpc/auth_unix.c 2008-10-13 14:52:09.000000000 +0200
27990 +++ linux-2.6.27.6-vs2.3.0.36/net/sunrpc/auth_unix.c 2008-10-13 14:54:20.000000000 +0200
27991 @@ -11,12 +11,14 @@
27992 #include <linux/module.h>
27993 #include <linux/sunrpc/clnt.h>
27994 #include <linux/sunrpc/auth.h>
27995 +#include <linux/vs_tag.h>
27997 #define NFS_NGROUPS 16
28000 struct rpc_cred uc_base;
28003 gid_t uc_gids[NFS_NGROUPS];
28005 #define uc_uid uc_base.cr_uid
28006 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
28007 groups = NFS_NGROUPS;
28009 cred->uc_gid = acred->gid;
28010 + cred->uc_tag = acred->tag;
28011 for (i = 0; i < groups; i++)
28012 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28013 if (i < NFS_NGROUPS)
28014 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
28018 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28019 + if (cred->uc_uid != acred->uid ||
28020 + cred->uc_gid != acred->gid ||
28021 + cred->uc_tag != acred->tag)
28024 if (acred->group_info != NULL)
28025 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
28026 struct rpc_clnt *clnt = task->tk_client;
28027 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28028 __be32 *base, *hold;
28032 *p++ = htonl(RPC_AUTH_UNIX);
28034 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
28035 * Copy the UTS nodename captured when the client was created.
28037 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28038 + tag = task->tk_client->cl_tag;
28040 - *p++ = htonl((u32) cred->uc_uid);
28041 - *p++ = htonl((u32) cred->uc_gid);
28042 + *p++ = htonl((u32) TAGINO_UID(tag,
28043 + cred->uc_uid, cred->uc_tag));
28044 + *p++ = htonl((u32) TAGINO_GID(tag,
28045 + cred->uc_gid, cred->uc_tag));
28047 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28048 *p++ = htonl((u32) cred->uc_gids[i]);
28049 diff -NurpP --minimal linux-2.6.27.6/net/sunrpc/clnt.c linux-2.6.27.6-vs2.3.0.36/net/sunrpc/clnt.c
28050 --- linux-2.6.27.6/net/sunrpc/clnt.c 2008-10-13 14:52:09.000000000 +0200
28051 +++ linux-2.6.27.6-vs2.3.0.36/net/sunrpc/clnt.c 2008-10-13 14:54:20.000000000 +0200
28053 #include <linux/utsname.h>
28054 #include <linux/workqueue.h>
28055 #include <linux/in6.h>
28056 +#include <linux/vs_cvirt.h>
28058 #include <linux/sunrpc/clnt.h>
28059 #include <linux/sunrpc/rpc_pipe_fs.h>
28060 @@ -327,6 +328,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28061 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28062 clnt->cl_chatty = 1;
28064 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
28065 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
28066 + clnt->cl_tag = 1; */
28069 EXPORT_SYMBOL_GPL(rpc_create);
28070 diff -NurpP --minimal linux-2.6.27.6/net/unix/af_unix.c linux-2.6.27.6-vs2.3.0.36/net/unix/af_unix.c
28071 --- linux-2.6.27.6/net/unix/af_unix.c 2008-11-17 18:07:35.000000000 +0100
28072 +++ linux-2.6.27.6-vs2.3.0.36/net/unix/af_unix.c 2008-11-17 18:20:42.000000000 +0100
28073 @@ -114,6 +114,8 @@
28074 #include <linux/mount.h>
28075 #include <net/checksum.h>
28076 #include <linux/security.h>
28077 +#include <linux/vs_context.h>
28078 +#include <linux/vs_limit.h>
28080 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28081 static DEFINE_SPINLOCK(unix_table_lock);
28082 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28083 if (!net_eq(sock_net(s), net))
28086 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28088 if (u->addr->len == len &&
28089 !memcmp(u->addr->name, sunname, len))
28091 @@ -2101,6 +2105,8 @@ static struct sock *unix_seq_idx(struct
28092 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28093 if (sock_net(s) != seq_file_net(seq))
28095 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28100 @@ -2126,7 +2132,8 @@ static void *unix_seq_next(struct seq_fi
28101 sk = first_unix_socket(&iter->i);
28103 sk = next_unix_socket(&iter->i, sk);
28104 - while (sk && (sock_net(sk) != seq_file_net(seq)))
28105 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
28106 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28107 sk = next_unix_socket(&iter->i, sk);
28110 diff -NurpP --minimal linux-2.6.27.6/net/x25/af_x25.c linux-2.6.27.6-vs2.3.0.36/net/x25/af_x25.c
28111 --- linux-2.6.27.6/net/x25/af_x25.c 2008-10-13 14:52:10.000000000 +0200
28112 +++ linux-2.6.27.6-vs2.3.0.36/net/x25/af_x25.c 2008-10-13 14:54:20.000000000 +0200
28113 @@ -506,7 +506,10 @@ static int x25_create(struct net *net, s
28117 - sock_init_data(sock, sk);
28118 + sk->sk_socket = sock;
28119 + sk->sk_type = sock->type;
28120 + sk->sk_sleep = &sock->wait;
28123 x25_init_timers(sk);
28125 diff -NurpP --minimal linux-2.6.27.6/scripts/checksyscalls.sh linux-2.6.27.6-vs2.3.0.36/scripts/checksyscalls.sh
28126 --- linux-2.6.27.6/scripts/checksyscalls.sh 2008-07-13 23:51:29.000000000 +0200
28127 +++ linux-2.6.27.6-vs2.3.0.36/scripts/checksyscalls.sh 2008-10-13 14:54:20.000000000 +0200
28128 @@ -108,7 +108,6 @@ cat << EOF
28129 #define __IGNORE_afs_syscall
28130 #define __IGNORE_getpmsg
28131 #define __IGNORE_putpmsg
28132 -#define __IGNORE_vserver
28136 diff -NurpP --minimal linux-2.6.27.6/security/commoncap.c linux-2.6.27.6-vs2.3.0.36/security/commoncap.c
28137 --- linux-2.6.27.6/security/commoncap.c 2008-11-17 18:07:35.000000000 +0100
28138 +++ linux-2.6.27.6-vs2.3.0.36/security/commoncap.c 2008-11-17 18:20:42.000000000 +0100
28139 @@ -26,10 +26,11 @@
28140 #include <linux/sched.h>
28141 #include <linux/prctl.h>
28142 #include <linux/securebits.h>
28143 +#include <linux/vs_context.h>
28145 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28147 - NETLINK_CB(skb).eff_cap = current->cap_effective;
28148 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current->cap_effective);
28152 @@ -50,9 +51,24 @@ EXPORT_SYMBOL(cap_netlink_recv);
28154 int cap_capable (struct task_struct *tsk, int cap)
28156 + struct vx_info *vxi = tsk->vx_info;
28159 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28160 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28161 + cap_raised(tsk->cap_effective, cap),
28162 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28165 + /* special case SETUP */
28166 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28167 + cap_raised(tsk->cap_effective, cap))
28170 /* Derived from include/linux/sched.h:capable. */
28171 - if (cap_raised(tsk->cap_effective, cap))
28172 + if (vx_cap_raised(vxi, tsk->cap_effective, cap))
28178 @@ -696,7 +712,8 @@ void cap_task_reparent_to_init (struct t
28180 int cap_syslog (int type)
28182 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
28183 + if ((type != 3 && type != 10) &&
28184 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28188 diff -NurpP --minimal linux-2.6.27.6/security/selinux/hooks.c linux-2.6.27.6-vs2.3.0.36/security/selinux/hooks.c
28189 --- linux-2.6.27.6/security/selinux/hooks.c 2008-10-13 14:52:10.000000000 +0200
28190 +++ linux-2.6.27.6-vs2.3.0.36/security/selinux/hooks.c 2008-10-13 14:54:20.000000000 +0200
28192 #include <linux/dccp.h>
28193 #include <linux/quota.h>
28194 #include <linux/un.h> /* for Unix socket types */
28195 -#include <net/af_unix.h> /* for Unix socket types */
28196 #include <linux/parser.h>
28197 #include <linux/nfs_mount.h>
28198 #include <net/ipv6.h>