1 diff -NurpP --minimal linux-2.6.29/arch/alpha/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/Kconfig
2 --- linux-2.6.29/arch/alpha/Kconfig 2009-03-24 14:18:07.000000000 +0100
3 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/Kconfig 2009-03-24 14:48:16.000000000 +0100
4 @@ -666,6 +666,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.29/arch/alpha/kernel/entry.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/entry.S
14 --- linux-2.6.29/arch/alpha/kernel/entry.S 2009-03-24 14:18:07.000000000 +0100
15 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/entry.S 2009-03-24 14:48:16.000000000 +0100
16 @@ -874,24 +874,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.29/arch/alpha/kernel/osf_sys.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.29/arch/alpha/kernel/osf_sys.c 2009-03-24 14:18:07.000000000 +0100
50 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/osf_sys.c 2009-03-24 14:48:16.000000000 +0100
51 @@ -877,7 +877,7 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct
55 - do_gettimeofday(&ktv);
56 + vx_gettimeofday(&ktv);
57 if (put_tv32(tv, &ktv))
60 diff -NurpP --minimal linux-2.6.29/arch/alpha/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.29/arch/alpha/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
62 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/ptrace.c 2009-02-22 22:54:24.000000000 +0100
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.29/arch/alpha/kernel/systbls.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/systbls.S
72 --- linux-2.6.29/arch/alpha/kernel/systbls.S 2009-03-24 14:18:08.000000000 +0100
73 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/systbls.S 2009-03-24 14:48:16.000000000 +0100
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.29/arch/alpha/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/traps.c
84 --- linux-2.6.29/arch/alpha/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
85 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/kernel/traps.c 2009-02-22 22:54:24.000000000 +0100
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.29/arch/alpha/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/mm/fault.c
97 --- linux-2.6.29/arch/alpha/mm/fault.c 2008-12-25 00:26:37.000000000 +0100
98 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/alpha/mm/fault.c 2009-02-22 22:54:24.000000000 +0100
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.29/arch/arm/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/Kconfig
111 --- linux-2.6.29/arch/arm/Kconfig 2009-03-24 14:18:08.000000000 +0100
112 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/Kconfig 2009-03-24 14:48:16.000000000 +0100
113 @@ -1333,6 +1333,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.29/arch/arm/kernel/calls.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/kernel/calls.S
123 --- linux-2.6.29/arch/arm/kernel/calls.S 2009-03-24 14:18:09.000000000 +0100
124 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/kernel/calls.S 2009-02-22 22:54:24.000000000 +0100
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.29/arch/arm/kernel/process.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/kernel/process.c
135 --- linux-2.6.29/arch/arm/kernel/process.c 2008-12-25 00:26:37.000000000 +0100
136 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/kernel/process.c 2009-02-22 22:54:24.000000000 +0100
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.29/arch/arm/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/kernel/traps.c
148 --- linux-2.6.29/arch/arm/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
149 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/kernel/traps.c 2009-02-22 22:54:24.000000000 +0100
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.29/arch/arm/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/mm/fault.c
162 --- linux-2.6.29/arch/arm/mm/fault.c 2009-03-24 14:18:17.000000000 +0100
163 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/arm/mm/fault.c 2009-03-24 14:48:17.000000000 +0100
164 @@ -294,7 +294,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.29/arch/cris/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/cris/Kconfig
175 --- linux-2.6.29/arch/cris/Kconfig 2009-03-24 14:18:23.000000000 +0100
176 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/cris/Kconfig 2009-03-24 14:48:19.000000000 +0100
177 @@ -685,6 +685,8 @@ source "drivers/staging/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.29/arch/frv/kernel/kernel_thread.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/frv/kernel/kernel_thread.S
187 --- linux-2.6.29/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
188 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/frv/kernel/kernel_thread.S 2009-02-22 22:54:24.000000000 +0100
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.29/arch/h8300/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/h8300/Kconfig
199 --- linux-2.6.29/arch/h8300/Kconfig 2009-03-24 14:18:24.000000000 +0100
200 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/h8300/Kconfig 2009-03-24 14:48:19.000000000 +0100
201 @@ -226,6 +226,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.29/arch/ia64/ia32/ia32_entry.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/ia32/ia32_entry.S
211 --- linux-2.6.29/arch/ia64/ia32/ia32_entry.S 2009-03-24 14:18:24.000000000 +0100
212 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/ia32/ia32_entry.S 2009-02-22 22:54:24.000000000 +0100
213 @@ -451,7 +451,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.29/arch/ia64/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/Kconfig
223 --- linux-2.6.29/arch/ia64/Kconfig 2009-03-24 14:18:24.000000000 +0100
224 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/Kconfig 2009-03-24 14:48:19.000000000 +0100
225 @@ -672,6 +672,8 @@ source "fs/Kconfig"
227 source "arch/ia64/Kconfig.debug"
229 +source "kernel/vserver/Kconfig"
231 source "security/Kconfig"
233 source "crypto/Kconfig"
234 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/entry.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/entry.S
235 --- linux-2.6.29/arch/ia64/kernel/entry.S 2009-03-24 14:18:25.000000000 +0100
236 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/entry.S 2009-02-22 22:54:24.000000000 +0100
237 @@ -1653,7 +1653,7 @@ sys_call_table:
239 data8 sys_mq_getsetattr
241 - data8 sys_ni_syscall // reserved for vserver
243 data8 sys_waitid // 1270
245 data8 sys_request_key
246 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/perfmon.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/perfmon.c
247 --- linux-2.6.29/arch/ia64/kernel/perfmon.c 2009-03-24 14:18:25.000000000 +0100
248 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/perfmon.c 2009-03-24 14:48:19.000000000 +0100
250 #include <linux/rcupdate.h>
251 #include <linux/completion.h>
252 #include <linux/tracehook.h>
253 +#include <linux/vs_memory.h>
255 #include <asm/errno.h>
256 #include <asm/intrinsics.h>
257 @@ -2372,7 +2373,7 @@ pfm_smpl_buffer_alloc(struct task_struct
259 insert_vm_struct(mm, vma);
261 - mm->total_vm += size >> PAGE_SHIFT;
262 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
263 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
265 up_write(&task->mm->mmap_sem);
266 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/process.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/process.c
267 --- linux-2.6.29/arch/ia64/kernel/process.c 2008-12-25 00:26:37.000000000 +0100
268 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/process.c 2009-02-22 22:54:24.000000000 +0100
269 @@ -110,8 +110,8 @@ show_regs (struct pt_regs *regs)
270 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
273 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
274 - smp_processor_id(), current->comm);
275 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
276 + current->xid, smp_processor_id(), current->comm);
277 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
278 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
279 init_utsname()->release);
280 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/ptrace.c
281 --- linux-2.6.29/arch/ia64/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
282 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/ptrace.c 2009-02-22 22:54:24.000000000 +0100
284 #include <linux/regset.h>
285 #include <linux/elf.h>
286 #include <linux/tracehook.h>
287 +#include <linux/vs_base.h>
289 #include <asm/pgtable.h>
290 #include <asm/processor.h>
291 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/traps.c
292 --- linux-2.6.29/arch/ia64/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
293 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/kernel/traps.c 2009-02-22 22:54:24.000000000 +0100
294 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
297 if (++die.lock_owner_depth < 3) {
298 - printk("%s[%d]: %s %ld [%d]\n",
299 - current->comm, task_pid_nr(current), str, err, ++die_counter);
300 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
301 + current->comm, task_pid_nr(current), current->xid,
302 + str, err, ++die_counter);
303 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
306 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
307 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
308 last.time = current_jiffies + 5 * HZ;
310 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
311 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
312 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
313 + current->comm, task_pid_nr(current), current->xid,
314 + regs->cr_iip + ia64_psr(regs)->ri, isr);
318 diff -NurpP --minimal linux-2.6.29/arch/ia64/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/mm/fault.c
319 --- linux-2.6.29/arch/ia64/mm/fault.c 2008-12-25 00:26:37.000000000 +0100
320 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/ia64/mm/fault.c 2009-02-22 22:54:24.000000000 +0100
322 #include <linux/interrupt.h>
323 #include <linux/kprobes.h>
324 #include <linux/kdebug.h>
325 +#include <linux/vs_memory.h>
327 #include <asm/pgtable.h>
328 #include <asm/processor.h>
329 diff -NurpP --minimal linux-2.6.29/arch/m32r/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/m32r/kernel/traps.c
330 --- linux-2.6.29/arch/m32r/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
331 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/m32r/kernel/traps.c 2009-02-22 22:54:24.000000000 +0100
332 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
334 printk("SPI: %08lx\n", sp);
336 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
337 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
338 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
339 + current->comm, task_pid_nr(current), current->xid,
340 + 0xffff & i, 4096+(unsigned long)current);
343 * When in-kernel, we also print out the stack and code at the
344 diff -NurpP --minimal linux-2.6.29/arch/m68k/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68k/Kconfig
345 --- linux-2.6.29/arch/m68k/Kconfig 2009-03-24 14:18:26.000000000 +0100
346 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68k/Kconfig 2009-03-24 14:48:20.000000000 +0100
347 @@ -616,6 +616,8 @@ source "fs/Kconfig"
349 source "arch/m68k/Kconfig.debug"
351 +source "kernel/vserver/Kconfig"
353 source "security/Kconfig"
355 source "crypto/Kconfig"
356 diff -NurpP --minimal linux-2.6.29/arch/m68k/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68k/kernel/ptrace.c
357 --- linux-2.6.29/arch/m68k/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
358 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68k/kernel/ptrace.c 2009-02-22 22:54:24.000000000 +0100
360 #include <linux/ptrace.h>
361 #include <linux/user.h>
362 #include <linux/signal.h>
363 +#include <linux/vs_base.h>
365 #include <asm/uaccess.h>
366 #include <asm/page.h>
367 @@ -269,6 +270,8 @@ long arch_ptrace(struct task_struct *chi
368 ret = ptrace_request(child, request, addr, data);
371 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
376 diff -NurpP --minimal linux-2.6.29/arch/m68k/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68k/kernel/traps.c
377 --- linux-2.6.29/arch/m68k/kernel/traps.c 2009-03-24 14:18:26.000000000 +0100
378 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68k/kernel/traps.c 2009-03-24 14:48:20.000000000 +0100
379 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
380 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
381 regs->d4, regs->d5, regs->a0, regs->a1);
383 - printk("Process %s (pid: %d, task=%p)\n",
384 - current->comm, task_pid_nr(current), current);
385 + printk("Process %s (pid: %d[#%u], task=%p)\n",
386 + current->comm, task_pid_nr(current), current->xid, current);
387 addr = (unsigned long)&fp->un;
388 printk("Frame format=%X ", regs->format);
389 switch (regs->format) {
390 diff -NurpP --minimal linux-2.6.29/arch/m68knommu/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68knommu/Kconfig
391 --- linux-2.6.29/arch/m68knommu/Kconfig 2009-03-24 14:18:27.000000000 +0100
392 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68knommu/Kconfig 2009-03-24 14:48:20.000000000 +0100
393 @@ -720,6 +720,8 @@ source "fs/Kconfig"
395 source "arch/m68knommu/Kconfig.debug"
397 +source "kernel/vserver/Kconfig"
399 source "security/Kconfig"
401 source "crypto/Kconfig"
402 diff -NurpP --minimal linux-2.6.29/arch/m68knommu/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68knommu/kernel/traps.c
403 --- linux-2.6.29/arch/m68knommu/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
404 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/m68knommu/kernel/traps.c 2009-02-22 22:54:24.000000000 +0100
405 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
406 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
407 fp->d4, fp->d5, fp->a0, fp->a1);
409 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
410 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
411 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
412 + current->comm, task_pid_nr(current), current->xid,
413 + PAGE_SIZE+(unsigned long)current);
414 show_stack(NULL, (unsigned long *)(fp + 1));
415 add_taint(TAINT_DIE);
417 diff -NurpP --minimal linux-2.6.29/arch/mips/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/Kconfig
418 --- linux-2.6.29/arch/mips/Kconfig 2009-03-24 14:18:29.000000000 +0100
419 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/Kconfig 2009-03-24 14:48:21.000000000 +0100
420 @@ -2142,6 +2142,8 @@ source "fs/Kconfig"
422 source "arch/mips/Kconfig.debug"
424 +source "kernel/vserver/Kconfig"
426 source "security/Kconfig"
428 source "crypto/Kconfig"
429 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/ptrace.c
430 --- linux-2.6.29/arch/mips/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
431 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/ptrace.c 2009-02-22 22:54:24.000000000 +0100
433 #include <linux/security.h>
434 #include <linux/audit.h>
435 #include <linux/seccomp.h>
436 +#include <linux/vs_base.h>
438 #include <asm/byteorder.h>
440 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
444 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
448 /* when I and D space are separate, these will need to be fixed. */
449 case PTRACE_PEEKTEXT: /* read word at location addr. */
450 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/scall32-o32.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/scall32-o32.S
451 --- linux-2.6.29/arch/mips/kernel/scall32-o32.S 2009-03-24 14:18:31.000000000 +0100
452 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/scall32-o32.S 2009-03-24 14:48:21.000000000 +0100
453 @@ -597,7 +597,7 @@ einval: li v0, -ENOSYS
454 sys sys_mq_timedreceive 5
455 sys sys_mq_notify 2 /* 4275 */
456 sys sys_mq_getsetattr 3
457 - sys sys_ni_syscall 0 /* sys_vserver */
460 sys sys_ni_syscall 0 /* available, was setaltroot */
461 sys sys_add_key 5 /* 4280 */
462 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/scall64-64.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/scall64-64.S
463 --- linux-2.6.29/arch/mips/kernel/scall64-64.S 2009-03-24 14:18:31.000000000 +0100
464 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/scall64-64.S 2009-03-24 14:48:21.000000000 +0100
465 @@ -434,7 +434,7 @@ sys_call_table:
466 PTR sys_mq_timedreceive
468 PTR sys_mq_getsetattr /* 5235 */
469 - PTR sys_ni_syscall /* sys_vserver */
472 PTR sys_ni_syscall /* available, was setaltroot */
474 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/scall64-n32.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/scall64-n32.S
475 --- linux-2.6.29/arch/mips/kernel/scall64-n32.S 2009-03-24 14:18:31.000000000 +0100
476 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/scall64-n32.S 2009-03-24 14:48:21.000000000 +0100
477 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
478 PTR compat_sys_mq_timedreceive
479 PTR compat_sys_mq_notify
480 PTR compat_sys_mq_getsetattr
481 - PTR sys_ni_syscall /* 6240, sys_vserver */
482 + PTR sys32_vserver /* 6240 */
483 PTR compat_sys_waitid
484 PTR sys_ni_syscall /* available, was setaltroot */
486 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/scall64-o32.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/scall64-o32.S
487 --- linux-2.6.29/arch/mips/kernel/scall64-o32.S 2009-03-24 14:18:31.000000000 +0100
488 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/scall64-o32.S 2009-03-24 14:59:48.000000000 +0100
489 @@ -480,7 +480,7 @@ sys_call_table:
490 PTR compat_sys_mq_timedreceive
491 PTR compat_sys_mq_notify /* 4275 */
492 PTR compat_sys_mq_getsetattr
493 - PTR sys_ni_syscall /* sys_vserver */
496 PTR sys_ni_syscall /* available, was setaltroot */
497 PTR sys_add_key /* 4280 */
498 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/traps.c
499 --- linux-2.6.29/arch/mips/kernel/traps.c 2009-03-24 14:18:31.000000000 +0100
500 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/mips/kernel/traps.c 2009-03-24 14:48:21.000000000 +0100
501 @@ -335,9 +335,10 @@ void show_registers(const struct pt_regs
505 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
506 - current->comm, current->pid, current_thread_info(), current,
507 - field, current_thread_info()->tp_value);
508 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
509 + current->comm, task_pid_nr(current), current->xid,
510 + current_thread_info(), current,
511 + field, current_thread_info()->tp_value);
512 if (cpu_has_userlocal) {
515 diff -NurpP --minimal linux-2.6.29/arch/parisc/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/parisc/Kconfig
516 --- linux-2.6.29/arch/parisc/Kconfig 2009-03-24 14:18:32.000000000 +0100
517 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/parisc/Kconfig 2009-03-24 14:48:21.000000000 +0100
518 @@ -281,6 +281,8 @@ source "fs/Kconfig"
520 source "arch/parisc/Kconfig.debug"
522 +source "kernel/vserver/Kconfig"
524 source "security/Kconfig"
526 source "crypto/Kconfig"
527 diff -NurpP --minimal linux-2.6.29/arch/parisc/kernel/syscall_table.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/parisc/kernel/syscall_table.S
528 --- linux-2.6.29/arch/parisc/kernel/syscall_table.S 2008-12-25 00:26:37.000000000 +0100
529 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/parisc/kernel/syscall_table.S 2009-02-22 22:54:24.000000000 +0100
531 ENTRY_COMP(mbind) /* 260 */
532 ENTRY_COMP(get_mempolicy)
533 ENTRY_COMP(set_mempolicy)
534 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
535 + ENTRY_DIFF(vserver)
537 ENTRY_SAME(request_key) /* 265 */
539 diff -NurpP --minimal linux-2.6.29/arch/parisc/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/parisc/kernel/traps.c
540 --- linux-2.6.29/arch/parisc/kernel/traps.c 2009-03-24 14:18:32.000000000 +0100
541 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/parisc/kernel/traps.c 2009-03-24 14:48:21.000000000 +0100
542 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
546 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
547 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
548 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
549 + current->comm, task_pid_nr(current), current->xid,
550 + str, err, regs->iaoq[0]);
551 #ifdef PRINT_USER_FAULTS
552 /* XXX for debugging only */
554 @@ -269,8 +270,8 @@ KERN_CRIT " || |
555 pdc_console_restart();
558 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
559 - current->comm, task_pid_nr(current), str, err);
560 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
561 + current->comm, task_pid_nr(current), current->xid, str, err);
563 /* Wot's wrong wif bein' racy? */
564 if (current->thread.flags & PARISC_KERNEL_DEATH) {
565 diff -NurpP --minimal linux-2.6.29/arch/parisc/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/parisc/mm/fault.c
566 --- linux-2.6.29/arch/parisc/mm/fault.c 2009-03-24 14:18:33.000000000 +0100
567 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/parisc/mm/fault.c 2009-03-24 14:48:21.000000000 +0100
568 @@ -238,8 +238,9 @@ bad_area:
570 #ifdef PRINT_USER_FAULTS
571 printk(KERN_DEBUG "\n");
572 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
573 - task_pid_nr(tsk), tsk->comm, code, address);
574 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
575 + "command='%s' type=%lu address=0x%08lx\n",
576 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
578 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
579 vma->vm_start, vma->vm_end);
580 @@ -265,7 +266,8 @@ no_context:
583 up_read(&mm->mmap_sem);
584 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
585 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
586 + current->comm, current->pid, current->xid);
588 do_group_exit(SIGKILL);
590 diff -NurpP --minimal linux-2.6.29/arch/powerpc/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/Kconfig
591 --- linux-2.6.29/arch/powerpc/Kconfig 2009-03-24 14:18:33.000000000 +0100
592 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/Kconfig 2009-03-24 14:48:22.000000000 +0100
593 @@ -882,6 +882,8 @@ source "lib/Kconfig"
595 source "arch/powerpc/Kconfig.debug"
597 +source "kernel/vserver/Kconfig"
599 source "security/Kconfig"
602 diff -NurpP --minimal linux-2.6.29/arch/powerpc/kernel/irq.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/kernel/irq.c
603 --- linux-2.6.29/arch/powerpc/kernel/irq.c 2009-03-24 14:18:35.000000000 +0100
604 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/kernel/irq.c 2009-03-24 14:48:22.000000000 +0100
606 #include <linux/bootmem.h>
607 #include <linux/pci.h>
608 #include <linux/debugfs.h>
609 +#include <linux/vs_context.h>
611 #include <asm/uaccess.h>
612 #include <asm/system.h>
613 diff -NurpP --minimal linux-2.6.29/arch/powerpc/kernel/process.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/kernel/process.c
614 --- linux-2.6.29/arch/powerpc/kernel/process.c 2009-03-24 14:18:35.000000000 +0100
615 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/kernel/process.c 2009-03-24 14:48:22.000000000 +0100
616 @@ -516,8 +516,9 @@ void show_regs(struct pt_regs * regs)
618 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
620 - printk("TASK = %p[%d] '%s' THREAD: %p",
621 - current, task_pid_nr(current), current->comm, task_thread_info(current));
622 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
623 + current, task_pid_nr(current), current->xid,
624 + current->comm, task_thread_info(current));
627 printk(" CPU: %d", raw_smp_processor_id());
628 diff -NurpP --minimal linux-2.6.29/arch/powerpc/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/kernel/traps.c
629 --- linux-2.6.29/arch/powerpc/kernel/traps.c 2009-03-24 14:18:35.000000000 +0100
630 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/kernel/traps.c 2009-03-24 14:48:22.000000000 +0100
631 @@ -940,8 +940,9 @@ void nonrecoverable_exception(struct pt_
633 void trace_syscall(struct pt_regs *regs)
635 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
636 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
637 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
638 + current, task_pid_nr(current), current->xid,
639 + regs->nip, regs->link, regs->gpr[0],
640 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
643 diff -NurpP --minimal linux-2.6.29/arch/powerpc/kernel/vdso.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/kernel/vdso.c
644 --- linux-2.6.29/arch/powerpc/kernel/vdso.c 2009-03-24 14:18:35.000000000 +0100
645 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/kernel/vdso.c 2009-03-24 14:48:22.000000000 +0100
647 #include <linux/security.h>
648 #include <linux/bootmem.h>
649 #include <linux/lmb.h>
650 +#include <linux/vs_memory.h>
652 #include <asm/pgtable.h>
653 #include <asm/system.h>
654 diff -NurpP --minimal linux-2.6.29/arch/powerpc/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/mm/fault.c
655 --- linux-2.6.29/arch/powerpc/mm/fault.c 2009-03-24 14:18:36.000000000 +0100
656 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/powerpc/mm/fault.c 2009-03-24 14:48:22.000000000 +0100
657 @@ -362,7 +362,8 @@ out_of_memory:
658 down_read(&mm->mmap_sem);
661 - printk("VM: killing process %s\n", current->comm);
662 + printk("VM: killing process %s(%d:#%u)\n",
663 + current->comm, current->pid, current->xid);
665 do_group_exit(SIGKILL);
667 diff -NurpP --minimal linux-2.6.29/arch/s390/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/s390/Kconfig
668 --- linux-2.6.29/arch/s390/Kconfig 2009-03-24 14:18:38.000000000 +0100
669 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/s390/Kconfig 2009-03-24 14:48:22.000000000 +0100
670 @@ -586,6 +586,8 @@ source "fs/Kconfig"
672 source "arch/s390/Kconfig.debug"
674 +source "kernel/vserver/Kconfig"
676 source "security/Kconfig"
678 source "crypto/Kconfig"
679 diff -NurpP --minimal linux-2.6.29/arch/s390/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/s390/kernel/ptrace.c
680 --- linux-2.6.29/arch/s390/kernel/ptrace.c 2009-03-24 14:18:40.000000000 +0100
681 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/s390/kernel/ptrace.c 2009-03-24 14:48:22.000000000 +0100
683 #include <linux/elf.h>
684 #include <linux/regset.h>
685 #include <linux/tracehook.h>
686 +#include <linux/vs_base.h>
688 #include <asm/segment.h>
689 #include <asm/page.h>
690 diff -NurpP --minimal linux-2.6.29/arch/s390/kernel/syscalls.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/s390/kernel/syscalls.S
691 --- linux-2.6.29/arch/s390/kernel/syscalls.S 2009-03-24 14:18:40.000000000 +0100
692 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/s390/kernel/syscalls.S 2009-03-24 14:48:22.000000000 +0100
693 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
694 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
695 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
696 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
697 -NI_SYSCALL /* reserved for vserver */
698 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
699 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
700 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
701 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
702 diff -NurpP --minimal linux-2.6.29/arch/s390/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/s390/mm/fault.c
703 --- linux-2.6.29/arch/s390/mm/fault.c 2008-12-25 00:26:37.000000000 +0100
704 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/s390/mm/fault.c 2009-02-22 22:54:24.000000000 +0100
705 @@ -216,7 +216,8 @@ static int do_out_of_memory(struct pt_re
706 down_read(&mm->mmap_sem);
709 - printk("VM: killing process %s\n", tsk->comm);
710 + printk("VM: killing process %s(%d:#%u)\n",
711 + tsk->comm, tsk->pid, tsk->xid);
712 if (regs->psw.mask & PSW_MASK_PSTATE)
713 do_group_exit(SIGKILL);
714 do_no_context(regs, error_code, address);
715 diff -NurpP --minimal linux-2.6.29/arch/sh/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/sh/Kconfig
716 --- linux-2.6.29/arch/sh/Kconfig 2009-03-24 14:18:40.000000000 +0100
717 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/sh/Kconfig 2009-03-24 14:48:22.000000000 +0100
718 @@ -694,6 +694,8 @@ source "fs/Kconfig"
720 source "arch/sh/Kconfig.debug"
722 +source "kernel/vserver/Kconfig"
724 source "security/Kconfig"
726 source "crypto/Kconfig"
727 diff -NurpP --minimal linux-2.6.29/arch/sh/kernel/irq.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/sh/kernel/irq.c
728 --- linux-2.6.29/arch/sh/kernel/irq.c 2008-12-25 00:26:37.000000000 +0100
729 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/sh/kernel/irq.c 2009-02-22 22:54:24.000000000 +0100
731 #include <linux/module.h>
732 #include <linux/kernel_stat.h>
733 #include <linux/seq_file.h>
734 +#include <linux/vs_context.h>
735 #include <asm/processor.h>
736 #include <asm/machvec.h>
737 #include <asm/uaccess.h>
738 diff -NurpP --minimal linux-2.6.29/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.29-vs2.3.0.36.9-pre2/arch/sh/kernel/vsyscall/vsyscall.c
739 --- linux-2.6.29/arch/sh/kernel/vsyscall/vsyscall.c 2009-03-24 14:18:42.000000000 +0100
740 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/sh/kernel/vsyscall/vsyscall.c 2009-03-24 14:48:22.000000000 +0100
742 #include <linux/elf.h>
743 #include <linux/sched.h>
744 #include <linux/err.h>
745 +#include <linux/vs_memory.h>
748 * Should the kernel map a VDSO page into processes and pass its
749 diff -NurpP --minimal linux-2.6.29/arch/sparc/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/sparc/Kconfig
750 --- linux-2.6.29/arch/sparc/Kconfig 2009-03-24 14:18:43.000000000 +0100
751 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/sparc/Kconfig 2009-03-24 14:48:22.000000000 +0100
752 @@ -522,6 +522,8 @@ source "fs/Kconfig"
754 source "arch/sparc/Kconfig.debug"
756 +source "kernel/vserver/Kconfig"
758 source "security/Kconfig"
760 source "crypto/Kconfig"
761 diff -NurpP --minimal linux-2.6.29/arch/x86/ia32/ia32entry.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/x86/ia32/ia32entry.S
762 --- linux-2.6.29/arch/x86/ia32/ia32entry.S 2009-03-24 14:18:48.000000000 +0100
763 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/x86/ia32/ia32entry.S 2009-03-22 23:29:11.000000000 +0100
764 @@ -768,7 +768,7 @@ ia32_sys_call_table:
765 .quad sys_tgkill /* 270 */
766 .quad compat_sys_utimes
767 .quad sys32_fadvise64_64
768 - .quad quiet_ni_syscall /* sys_vserver */
769 + .quad sys32_vserver
771 .quad compat_sys_get_mempolicy /* 275 */
772 .quad sys_set_mempolicy
773 diff -NurpP --minimal linux-2.6.29/arch/x86/include/asm/unistd_64.h linux-2.6.29-vs2.3.0.36.9-pre2/arch/x86/include/asm/unistd_64.h
774 --- linux-2.6.29/arch/x86/include/asm/unistd_64.h 2008-12-25 00:26:37.000000000 +0100
775 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/x86/include/asm/unistd_64.h 2009-02-22 22:54:24.000000000 +0100
776 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
777 #define __NR_utimes 235
778 __SYSCALL(__NR_utimes, sys_utimes)
779 #define __NR_vserver 236
780 -__SYSCALL(__NR_vserver, sys_ni_syscall)
781 +__SYSCALL(__NR_vserver, sys_vserver)
782 #define __NR_mbind 237
783 __SYSCALL(__NR_mbind, sys_mbind)
784 #define __NR_set_mempolicy 238
785 diff -NurpP --minimal linux-2.6.29/arch/x86/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/arch/x86/Kconfig
786 --- linux-2.6.29/arch/x86/Kconfig 2009-03-24 14:18:47.000000000 +0100
787 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/x86/Kconfig 2009-03-24 14:48:23.000000000 +0100
788 @@ -1990,6 +1990,8 @@ source "fs/Kconfig"
790 source "arch/x86/Kconfig.debug"
792 +source "kernel/vserver/Kconfig"
794 source "security/Kconfig"
796 source "crypto/Kconfig"
797 diff -NurpP --minimal linux-2.6.29/arch/x86/kernel/syscall_table_32.S linux-2.6.29-vs2.3.0.36.9-pre2/arch/x86/kernel/syscall_table_32.S
798 --- linux-2.6.29/arch/x86/kernel/syscall_table_32.S 2009-03-24 14:18:51.000000000 +0100
799 +++ linux-2.6.29-vs2.3.0.36.9-pre2/arch/x86/kernel/syscall_table_32.S 2009-02-22 22:54:24.000000000 +0100
800 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
801 .long sys_tgkill /* 270 */
803 .long sys_fadvise64_64
804 - .long sys_ni_syscall /* sys_vserver */
807 .long sys_get_mempolicy
808 .long sys_set_mempolicy
809 diff -NurpP --minimal linux-2.6.29/Documentation/vserver/debug.txt linux-2.6.29-vs2.3.0.36.9-pre2/Documentation/vserver/debug.txt
810 --- linux-2.6.29/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
811 +++ linux-2.6.29-vs2.3.0.36.9-pre2/Documentation/vserver/debug.txt 2009-02-22 22:54:24.000000000 +0100
816 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
817 + "vx_rmap_tgid: %p/%llx: %d -> %d"
821 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
822 + "FREE (%p,#%d)%c inode"
823 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
824 + "FREE (%p,#%d)%c %lld bytes"
825 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
826 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
827 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
828 + "rcu_free_dl_info(%p)"
829 + 4 10 "alloc_dl_info(%p,%d) = %p"
830 + "dealloc_dl_info(%p)"
831 + "get_dl_info(%p[#%d.%d])"
832 + "put_dl_info(%p[#%d.%d])"
833 + 5 20 "alloc_dl_info(%p,%d)*"
834 + 6 40 "__hash_dl_info: %p[#%d]"
835 + "__unhash_dl_info: %p[#%d]"
836 + 7 80 "locate_dl_info(%p,#%d) = %p"
840 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
841 + "new_dqhash: %p [#0x%08x]"
842 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
843 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
844 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
845 + "vroot_get_real_bdev not set"
846 + 1 2 "cow_break_link(»%s«)"
848 + 2 4 "dentry_open(new): %p"
849 + "dentry_open(old): %p"
850 + "lookup_create(new): %p"
852 + "path_lookup(old): %d"
853 + "vfs_create(new): %d"
856 + 3 8 "fput(new_file=%p[#%d])"
857 + "fput(old_file=%p[#%d])"
858 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
859 + "vx_info_kill(%p[#%d],%d,%d)*"
860 + 5 20 "vs_reboot(%p[#%d],%d)"
861 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
865 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
866 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
867 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
868 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
869 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
870 + 6 40 "sk,egf: %p [#%d] (from %d)"
871 + "sk,egn: %p [#%d] (from %d)"
872 + "sk,req: %p [#%d] (from %d)"
873 + "sk: %p [#%d] (from %d)"
874 + "tw: %p [#%d] (from %d)"
875 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
876 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
880 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
881 + "alloc_nx_info(%d) = %p"
882 + "create_nx_info(%d) (dynamic rejected)"
883 + "create_nx_info(%d) = %p (already there)"
884 + "create_nx_info(%d) = %p (new)"
885 + "dealloc_nx_info(%p)"
886 + 1 2 "alloc_nx_info(%d)*"
887 + "create_nx_info(%d)*"
888 + 2 4 "get_nx_info(%p[#%d.%d])"
889 + "put_nx_info(%p[#%d.%d])"
890 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
891 + "clr_nx_info(%p[#%d.%d])"
892 + "init_nx_info(%p[#%d.%d])"
893 + "release_nx_info(%p[#%d.%d.%d]) %p"
894 + "set_nx_info(%p[#%d.%d])"
895 + 4 10 "__hash_nx_info: %p[#%d]"
896 + "__nx_dynamic_id: [#%d]"
897 + "__unhash_nx_info: %p[#%d.%d.%d]"
898 + 5 20 "moved task %p into nxi:%p[#%d]"
899 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
900 + "task_get_nx_info(%p)"
901 + 6 40 "nx_clear_persistent(%p[#%d])"
905 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
906 + 1 2 "quota_sync_dqh(%p,%d)"
907 + "sync_dquots(%p,%d)"
908 + "sync_dquots_dqh(%p,%d)"
909 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
913 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
914 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
915 + 4 10 "%s: (%s %s) returned %s with %d"
919 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
920 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
924 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
925 + "alloc_vx_info(%d) = %p"
926 + "alloc_vx_info(%d)*"
927 + "create_vx_info(%d) (dynamic rejected)"
928 + "create_vx_info(%d) = %p (already there)"
929 + "create_vx_info(%d) = %p (new)"
930 + "dealloc_vx_info(%p)"
931 + "loc_vx_info(%d) = %p (found)"
932 + "loc_vx_info(%d) = %p (new)"
933 + "loc_vx_info(%d) = %p (not available)"
934 + 1 2 "create_vx_info(%d)*"
936 + 2 4 "get_vx_info(%p[#%d.%d])"
937 + "put_vx_info(%p[#%d.%d])"
938 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
939 + "clr_vx_info(%p[#%d.%d])"
940 + "init_vx_info(%p[#%d.%d])"
941 + "release_vx_info(%p[#%d.%d.%d]) %p"
942 + "set_vx_info(%p[#%d.%d])"
943 + 4 10 "__hash_vx_info: %p[#%d]"
944 + "__unhash_vx_info: %p[#%d.%d.%d]"
945 + "__vx_dynamic_id: [#%d]"
946 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
947 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
948 + "moved task %p into vxi:%p[#%d]"
949 + "task_get_vx_info(%p)"
950 + "vx_migrate_task(%p,%p[#%d.%d])"
951 + 6 40 "vx_clear_persistent(%p[#%d])"
952 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
953 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
954 + "vx_set_persistent(%p[#%d])"
955 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
956 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
961 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
962 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
964 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
965 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
966 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
967 diff -NurpP --minimal linux-2.6.29/drivers/block/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/drivers/block/Kconfig
968 --- linux-2.6.29/drivers/block/Kconfig 2008-12-25 00:26:37.000000000 +0100
969 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/block/Kconfig 2009-02-22 22:54:24.000000000 +0100
970 @@ -264,6 +264,13 @@ config BLK_DEV_CRYPTOLOOP
971 instead, which can be configured to be on-disk compatible with the
974 +config BLK_DEV_VROOT
975 + tristate "Virtual Root device support"
976 + depends on QUOTACTL
978 + Saying Y here will allow you to use quota/fs ioctls on a shared
979 + partition within a virtual server without compromising security.
982 tristate "Network block device support"
984 diff -NurpP --minimal linux-2.6.29/drivers/block/loop.c linux-2.6.29-vs2.3.0.36.9-pre2/drivers/block/loop.c
985 --- linux-2.6.29/drivers/block/loop.c 2009-03-24 14:18:56.000000000 +0100
986 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/block/loop.c 2009-03-24 15:09:29.000000000 +0100
988 #include <linux/gfp.h>
989 #include <linux/kthread.h>
990 #include <linux/splice.h>
991 +#include <linux/vs_context.h>
993 #include <asm/uaccess.h>
995 @@ -809,6 +810,7 @@ static int loop_set_fd(struct loop_devic
996 lo->lo_blocksize = lo_blocksize;
997 lo->lo_device = bdev;
998 lo->lo_flags = lo_flags;
999 + lo->lo_xid = vx_current_xid();
1000 lo->lo_backing_file = file;
1001 lo->transfer = transfer_none;
1003 @@ -931,6 +933,7 @@ static int loop_clr_fd(struct loop_devic
1004 lo->lo_encrypt_key_size = 0;
1006 lo->lo_thread = NULL;
1008 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1009 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1010 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1011 @@ -958,7 +961,7 @@ loop_set_status(struct loop_device *lo,
1013 if (lo->lo_encrypt_key_size &&
1014 lo->lo_key_owner != uid &&
1015 - !capable(CAP_SYS_ADMIN))
1016 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1018 if (lo->lo_state != Lo_bound)
1020 @@ -1042,7 +1045,8 @@ loop_get_status(struct loop_device *lo,
1021 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1022 info->lo_encrypt_type =
1023 lo->lo_encryption ? lo->lo_encryption->number : 0;
1024 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1025 + if (lo->lo_encrypt_key_size &&
1026 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1027 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1028 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1029 lo->lo_encrypt_key_size);
1030 @@ -1351,6 +1355,9 @@ static int lo_open(struct block_device *
1032 struct loop_device *lo = bdev->bd_disk->private_data;
1034 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1037 mutex_lock(&lo->lo_ctl_mutex);
1039 mutex_unlock(&lo->lo_ctl_mutex);
1040 diff -NurpP --minimal linux-2.6.29/drivers/block/Makefile linux-2.6.29-vs2.3.0.36.9-pre2/drivers/block/Makefile
1041 --- linux-2.6.29/drivers/block/Makefile 2009-03-24 14:18:55.000000000 +0100
1042 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/block/Makefile 2009-03-24 14:48:25.000000000 +0100
1043 @@ -31,5 +31,6 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1044 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1045 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1046 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1047 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1049 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1050 diff -NurpP --minimal linux-2.6.29/drivers/block/vroot.c linux-2.6.29-vs2.3.0.36.9-pre2/drivers/block/vroot.c
1051 --- linux-2.6.29/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1052 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/block/vroot.c 2009-02-22 22:54:24.000000000 +0100
1055 + * linux/drivers/block/vroot.c
1057 + * written by Herbert Pötzl, 9/11/2002
1058 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1060 + * based on the loop.c code by Theodore Ts'o.
1062 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1063 + * Redistribution of this file is permitted under the
1064 + * GNU General Public License.
1068 +#include <linux/module.h>
1069 +#include <linux/moduleparam.h>
1070 +#include <linux/file.h>
1071 +#include <linux/major.h>
1072 +#include <linux/blkdev.h>
1074 +#include <linux/vroot.h>
1075 +#include <linux/vs_context.h>
1078 +static int max_vroot = 8;
1080 +static struct vroot_device *vroot_dev;
1081 +static struct gendisk **disks;
1084 +static int vroot_set_dev(
1085 + struct vroot_device *vr,
1086 + struct block_device *bdev,
1089 + struct block_device *real_bdev;
1090 + struct file *file;
1091 + struct inode *inode;
1095 + if (vr->vr_state != Vr_unbound)
1104 + inode = file->f_dentry->d_inode;
1107 + if (S_ISBLK(inode->i_mode)) {
1108 + real_bdev = inode->i_bdev;
1109 + vr->vr_device = real_bdev;
1110 + __iget(real_bdev->bd_inode);
1114 + vxdprintk(VXD_CBIT(misc, 0),
1115 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1116 + vr->vr_number, VXD_DEV(real_bdev));
1118 + vr->vr_state = Vr_bound;
1127 +static int vroot_clr_dev(
1128 + struct vroot_device *vr,
1129 + struct block_device *bdev)
1131 + struct block_device *real_bdev;
1133 + if (vr->vr_state != Vr_bound)
1135 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1138 + real_bdev = vr->vr_device;
1140 + vxdprintk(VXD_CBIT(misc, 0),
1141 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1142 + vr->vr_number, VXD_DEV(real_bdev));
1145 + vr->vr_state = Vr_unbound;
1146 + vr->vr_device = NULL;
1151 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1152 + unsigned int cmd, unsigned long arg)
1154 + struct vroot_device *vr = bdev->bd_disk->private_data;
1157 + down(&vr->vr_ctl_mutex);
1159 + case VROOT_SET_DEV:
1160 + err = vroot_set_dev(vr, bdev, arg);
1162 + case VROOT_CLR_DEV:
1163 + err = vroot_clr_dev(vr, bdev);
1169 + up(&vr->vr_ctl_mutex);
1173 +static int vr_open(struct block_device *bdev, fmode_t mode)
1175 + struct vroot_device *vr = bdev->bd_disk->private_data;
1177 + down(&vr->vr_ctl_mutex);
1179 + up(&vr->vr_ctl_mutex);
1183 +static int vr_release(struct gendisk *disk, fmode_t mode)
1185 + struct vroot_device *vr = disk->private_data;
1187 + down(&vr->vr_ctl_mutex);
1189 + up(&vr->vr_ctl_mutex);
1193 +static struct block_device_operations vr_fops = {
1194 + .owner = THIS_MODULE,
1196 + .release = vr_release,
1197 + .ioctl = vr_ioctl,
1200 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1202 + struct inode *inode = bdev->bd_inode;
1203 + struct vroot_device *vr;
1204 + struct block_device *real_bdev;
1205 + int minor = iminor(inode);
1207 + vr = &vroot_dev[minor];
1208 + real_bdev = vr->vr_device;
1210 + vxdprintk(VXD_CBIT(misc, 0),
1211 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1212 + vr->vr_number, VXD_DEV(real_bdev));
1214 + if (vr->vr_state != Vr_bound)
1215 + return ERR_PTR(-ENXIO);
1217 + __iget(real_bdev->bd_inode);
1222 + * And now the modules code and kernel interface.
1225 +module_param(max_vroot, int, 0);
1227 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1228 +MODULE_LICENSE("GPL");
1229 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1231 +MODULE_AUTHOR ("Herbert Pötzl");
1232 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1235 +int __init vroot_init(void)
1239 + if (max_vroot < 1 || max_vroot > 256) {
1240 + max_vroot = MAX_VROOT_DEFAULT;
1241 + printk(KERN_WARNING "vroot: invalid max_vroot "
1242 + "(must be between 1 and 256), "
1243 + "using default (%d)\n", max_vroot);
1246 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1250 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1253 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1255 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1259 + for (i = 0; i < max_vroot; i++) {
1260 + disks[i] = alloc_disk(1);
1263 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1264 + if (!disks[i]->queue)
1268 + for (i = 0; i < max_vroot; i++) {
1269 + struct vroot_device *vr = &vroot_dev[i];
1270 + struct gendisk *disk = disks[i];
1272 + memset(vr, 0, sizeof(*vr));
1273 + init_MUTEX(&vr->vr_ctl_mutex);
1274 + vr->vr_number = i;
1275 + disk->major = VROOT_MAJOR;
1276 + disk->first_minor = i;
1277 + disk->fops = &vr_fops;
1278 + sprintf(disk->disk_name, "vroot%d", i);
1279 + disk->private_data = vr;
1282 + err = register_vroot_grb(&__vroot_get_real_bdev);
1286 + for (i = 0; i < max_vroot; i++)
1287 + add_disk(disks[i]);
1288 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1293 + put_disk(disks[i]);
1298 + unregister_blkdev(VROOT_MAJOR, "vroot");
1299 + printk(KERN_ERR "vroot: ran out of memory\n");
1303 +void vroot_exit(void)
1307 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1308 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1310 + for (i = 0; i < max_vroot; i++) {
1311 + del_gendisk(disks[i]);
1312 + put_disk(disks[i]);
1314 + unregister_blkdev(VROOT_MAJOR, "vroot");
1320 +module_init(vroot_init);
1321 +module_exit(vroot_exit);
1325 +static int __init max_vroot_setup(char *str)
1327 + max_vroot = simple_strtol(str, NULL, 0);
1331 +__setup("max_vroot=", max_vroot_setup);
1335 diff -NurpP --minimal linux-2.6.29/drivers/char/sysrq.c linux-2.6.29-vs2.3.0.36.9-pre2/drivers/char/sysrq.c
1336 --- linux-2.6.29/drivers/char/sysrq.c 2009-03-24 14:18:57.000000000 +0100
1337 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/char/sysrq.c 2009-03-24 15:15:27.000000000 +0100
1339 #include <linux/irq.h>
1340 #include <linux/hrtimer.h>
1341 #include <linux/oom.h>
1342 +#include <linux/vserver/debug.h>
1344 #include <asm/ptrace.h>
1345 #include <asm/irq_regs.h>
1346 @@ -369,6 +370,21 @@ static struct sysrq_key_op sysrq_unrt_op
1347 .enable_mask = SYSRQ_ENABLE_RTNICE,
1351 +#ifdef CONFIG_VSERVER_DEBUG
1352 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
1354 + dump_vx_info_inactive((key == 'x')?0:1);
1357 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1358 + .handler = sysrq_handle_vxinfo,
1359 + .help_msg = "conteXt",
1360 + .action_msg = "Show Context Info",
1361 + .enable_mask = SYSRQ_ENABLE_DUMP,
1365 /* Key Operations table and lock */
1366 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1368 @@ -419,7 +435,11 @@ static struct sysrq_key_op *sysrq_key_ta
1370 &sysrq_showstate_blocked_op, /* w */
1371 /* x: May be registered on ppc/powerpc for xmon */
1372 +#ifdef CONFIG_VSERVER_DEBUG
1373 + &sysrq_showvxinfo_op, /* x */
1377 /* y: May be registered on sparc64 for global register dump */
1379 &sysrq_ftrace_dump_op, /* z */
1380 @@ -434,6 +454,8 @@ static int sysrq_key_table_key2index(int
1382 else if ((key >= 'a') && (key <= 'z'))
1383 retval = key + 10 - 'a';
1384 + else if ((key >= 'A') && (key <= 'Z'))
1385 + retval = key + 10 - 'A';
1389 diff -NurpP --minimal linux-2.6.29/drivers/char/tty_io.c linux-2.6.29-vs2.3.0.36.9-pre2/drivers/char/tty_io.c
1390 --- linux-2.6.29/drivers/char/tty_io.c 2009-03-24 14:18:57.000000000 +0100
1391 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/char/tty_io.c 2009-03-24 14:48:25.000000000 +0100
1394 #include <linux/kmod.h>
1395 #include <linux/nsproxy.h>
1396 +#include <linux/vs_pid.h>
1398 #undef TTY_DEBUG_HANGUP
1400 @@ -2303,6 +2304,7 @@ static int tiocspgrp(struct tty_struct *
1402 if (get_user(pgrp_nr, p))
1404 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1408 diff -NurpP --minimal linux-2.6.29/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.29-vs2.3.0.36.9-pre2/drivers/infiniband/hw/ipath/ipath_user_pages.c
1409 --- linux-2.6.29/drivers/infiniband/hw/ipath/ipath_user_pages.c 2008-12-25 00:26:37.000000000 +0100
1410 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/infiniband/hw/ipath/ipath_user_pages.c 2009-02-22 22:54:24.000000000 +0100
1413 #include <linux/mm.h>
1414 #include <linux/device.h>
1415 +#include <linux/vs_memory.h>
1417 #include "ipath_kernel.h"
1419 @@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
1420 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
1423 - if (num_pages > lock_limit) {
1424 + if (num_pages > lock_limit ||
1425 + !vx_vmlocked_avail(current->mm, num_pages)) {
1429 @@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
1433 - current->mm->locked_vm += num_pages;
1434 + vx_vmlocked_add(current->mm, num_pages);
1438 @@ -177,7 +179,7 @@ void ipath_release_user_pages(struct pag
1440 __ipath_release_user_pages(p, num_pages, 1);
1442 - current->mm->locked_vm -= num_pages;
1443 + vx_vmlocked_sub(current->mm, num_pages);
1445 up_write(¤t->mm->mmap_sem);
1447 @@ -194,7 +196,7 @@ static void user_pages_account(struct wo
1448 container_of(_work, struct ipath_user_pages_work, work);
1450 down_write(&work->mm->mmap_sem);
1451 - work->mm->locked_vm -= work->num_pages;
1452 + vx_vmlocked_sub(work->mm, work->num_pages);
1453 up_write(&work->mm->mmap_sem);
1456 diff -NurpP --minimal linux-2.6.29/drivers/md/dm.c linux-2.6.29-vs2.3.0.36.9-pre2/drivers/md/dm.c
1457 --- linux-2.6.29/drivers/md/dm.c 2009-03-24 14:19:05.000000000 +0100
1458 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/md/dm.c 2009-03-24 15:15:57.000000000 +0100
1460 #include <linux/hdreg.h>
1461 #include <linux/blktrace_api.h>
1462 #include <trace/block.h>
1463 +#include <linux/vs_base.h>
1465 #define DM_MSG_PREFIX "core"
1467 @@ -115,6 +116,7 @@ struct mapped_device {
1470 atomic_t open_count;
1473 unsigned long flags;
1475 @@ -295,6 +297,7 @@ static void __exit dm_exit(void)
1476 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1478 struct mapped_device *md;
1481 spin_lock(&_minor_lock);
1483 @@ -303,18 +306,19 @@ static int dm_blk_open(struct block_devi
1486 if (test_bit(DMF_FREEING, &md->flags) ||
1487 - test_bit(DMF_DELETING, &md->flags)) {
1489 + test_bit(DMF_DELETING, &md->flags))
1493 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1498 atomic_inc(&md->open_count);
1502 spin_unlock(&_minor_lock);
1504 - return md ? 0 : -ENXIO;
1508 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1509 @@ -504,6 +508,14 @@ int dm_set_geometry(struct mapped_device
1514 + * Get the xid associated with a dm device
1516 +xid_t dm_get_xid(struct mapped_device *md)
1521 /*-----------------------------------------------------------------
1523 * A more elegant soln is in the works that uses the queue
1524 @@ -1110,6 +1122,7 @@ static struct mapped_device *alloc_dev(i
1525 INIT_LIST_HEAD(&md->uevent_list);
1526 spin_lock_init(&md->uevent_lock);
1528 + md->xid = vx_current_xid();
1529 md->queue = blk_alloc_queue(GFP_KERNEL);
1532 diff -NurpP --minimal linux-2.6.29/drivers/md/dm.h linux-2.6.29-vs2.3.0.36.9-pre2/drivers/md/dm.h
1533 --- linux-2.6.29/drivers/md/dm.h 2009-03-24 14:19:05.000000000 +0100
1534 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/md/dm.h 2009-03-24 14:48:26.000000000 +0100
1535 @@ -54,6 +54,8 @@ int dm_table_any_congested(struct dm_tab
1536 #define dm_target_is_valid(t) ((t)->table)
1537 int dm_table_barrier_ok(struct dm_table *t);
1539 +xid_t dm_get_xid(struct mapped_device *md);
1541 /*-----------------------------------------------------------------
1542 * A registry of target types.
1543 *---------------------------------------------------------------*/
1544 diff -NurpP --minimal linux-2.6.29/drivers/md/dm-ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/drivers/md/dm-ioctl.c
1545 --- linux-2.6.29/drivers/md/dm-ioctl.c 2009-03-24 14:19:05.000000000 +0100
1546 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/md/dm-ioctl.c 2009-03-24 14:48:26.000000000 +0100
1548 #include <linux/dm-ioctl.h>
1549 #include <linux/hdreg.h>
1550 #include <linux/compat.h>
1551 +#include <linux/vs_context.h>
1553 #include <asm/uaccess.h>
1555 @@ -101,7 +102,8 @@ static struct hash_cell *__get_name_cell
1556 unsigned int h = hash_str(str);
1558 list_for_each_entry (hc, _name_buckets + h, name_list)
1559 - if (!strcmp(hc->name, str)) {
1560 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1561 + !strcmp(hc->name, str)) {
1565 @@ -115,7 +117,8 @@ static struct hash_cell *__get_uuid_cell
1566 unsigned int h = hash_str(str);
1568 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1569 - if (!strcmp(hc->uuid, str)) {
1570 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1571 + !strcmp(hc->uuid, str)) {
1575 @@ -352,6 +355,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1577 static int remove_all(struct dm_ioctl *param, size_t param_size)
1579 + if (!vx_check(0, VS_ADMIN))
1582 dm_hash_remove_all(1);
1583 param->data_size = 0;
1585 @@ -399,6 +405,8 @@ static int list_devices(struct dm_ioctl
1587 for (i = 0; i < NUM_BUCKETS; i++) {
1588 list_for_each_entry (hc, _name_buckets + i, name_list) {
1589 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1591 needed += sizeof(struct dm_name_list);
1592 needed += strlen(hc->name) + 1;
1593 needed += ALIGN_MASK;
1594 @@ -422,6 +430,8 @@ static int list_devices(struct dm_ioctl
1596 for (i = 0; i < NUM_BUCKETS; i++) {
1597 list_for_each_entry (hc, _name_buckets + i, name_list) {
1598 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1601 old_nl->next = (uint32_t) ((void *) nl -
1603 @@ -612,10 +622,11 @@ static struct hash_cell *__find_device_h
1607 - mdptr = dm_get_mdptr(md);
1608 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1609 + mdptr = dm_get_mdptr(md);
1617 @@ -1405,8 +1416,8 @@ static int ctl_ioctl(uint command, struc
1621 - /* only root can play with this */
1622 - if (!capable(CAP_SYS_ADMIN))
1623 + /* only root and certain contexts can play with this */
1624 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1627 if (_IOC_TYPE(command) != DM_IOCTL)
1628 diff -NurpP --minimal linux-2.6.29/drivers/net/tun.c linux-2.6.29-vs2.3.0.36.9-pre2/drivers/net/tun.c
1629 --- linux-2.6.29/drivers/net/tun.c 2009-03-24 14:19:23.000000000 +0100
1630 +++ linux-2.6.29-vs2.3.0.36.9-pre2/drivers/net/tun.c 2009-03-25 01:51:59.000000000 +0100
1632 #include <linux/crc32.h>
1633 #include <linux/nsproxy.h>
1634 #include <linux/virtio_net.h>
1635 +#include <linux/vs_network.h>
1636 #include <net/net_namespace.h>
1637 #include <net/netns/generic.h>
1639 @@ -93,6 +94,7 @@ struct tun_struct {
1645 wait_queue_head_t read_wait;
1646 struct sk_buff_head readq;
1647 @@ -697,6 +699,7 @@ static void tun_setup(struct net_device
1651 + tun->nid = current->nid;
1653 dev->ethtool_ops = &tun_ethtool_ops;
1654 dev->destructor = free_netdev;
1655 @@ -727,6 +730,9 @@ static int tun_set_iff(struct net *net,
1656 tn = net_generic(net, tun_net_id);
1657 tun = tun_get_by_name(tn, ifr->ifr_name);
1659 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1665 @@ -735,7 +741,7 @@ static int tun_set_iff(struct net *net,
1666 cred->euid != tun->owner) ||
1667 (tun->group != -1 &&
1668 cred->egid != tun->group)) &&
1669 - !capable(CAP_NET_ADMIN)) {
1670 + !cap_raised(current_cap(), CAP_NET_ADMIN)) {
1674 @@ -747,7 +753,7 @@ static int tun_set_iff(struct net *net,
1678 - if (!capable(CAP_NET_ADMIN))
1679 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1683 @@ -987,6 +993,16 @@ static int tun_chr_ioctl(struct inode *i
1684 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
1688 + if (!capable(CAP_CONTEXT))
1691 + /* Set nid owner of the device */
1692 + tun->nid = (nid_t) arg;
1694 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
1698 /* Only allow setting the type when the interface is down */
1700 diff -NurpP --minimal linux-2.6.29/fs/attr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/attr.c
1701 --- linux-2.6.29/fs/attr.c 2009-03-24 14:22:24.000000000 +0100
1702 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/attr.c 2009-03-24 14:48:34.000000000 +0100
1704 #include <linux/fcntl.h>
1705 #include <linux/quotaops.h>
1706 #include <linux/security.h>
1707 +#include <linux/proc_fs.h>
1708 +#include <linux/devpts_fs.h>
1709 +#include <linux/vs_tag.h>
1711 /* Taken over from the old code... */
1713 @@ -55,6 +58,10 @@ int inode_change_ok(struct inode *inode,
1714 if (!is_owner_or_cap(inode))
1718 + if (dx_permission(inode, MAY_WRITE))
1724 @@ -78,6 +85,8 @@ int inode_setattr(struct inode * inode,
1725 inode->i_uid = attr->ia_uid;
1726 if (ia_valid & ATTR_GID)
1727 inode->i_gid = attr->ia_gid;
1728 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1729 + inode->i_tag = attr->ia_tag;
1730 if (ia_valid & ATTR_ATIME)
1731 inode->i_atime = timespec_trunc(attr->ia_atime,
1732 inode->i_sb->s_time_gran);
1733 @@ -172,7 +181,8 @@ int notify_change(struct dentry * dentry
1734 error = inode_change_ok(inode, attr);
1736 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
1737 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
1738 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
1739 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
1740 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
1742 error = inode_setattr(inode, attr);
1743 diff -NurpP --minimal linux-2.6.29/fs/binfmt_aout.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/binfmt_aout.c
1744 --- linux-2.6.29/fs/binfmt_aout.c 2009-03-24 14:22:24.000000000 +0100
1745 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/binfmt_aout.c 2009-03-24 14:48:34.000000000 +0100
1747 #include <linux/binfmts.h>
1748 #include <linux/personality.h>
1749 #include <linux/init.h>
1750 +#include <linux/vs_memory.h>
1752 #include <asm/system.h>
1753 #include <asm/uaccess.h>
1754 diff -NurpP --minimal linux-2.6.29/fs/binfmt_elf.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/binfmt_elf.c
1755 --- linux-2.6.29/fs/binfmt_elf.c 2009-03-24 14:22:24.000000000 +0100
1756 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/binfmt_elf.c 2009-03-24 14:48:34.000000000 +0100
1758 #include <linux/random.h>
1759 #include <linux/elf.h>
1760 #include <linux/utsname.h>
1761 +#include <linux/vs_memory.h>
1762 #include <asm/uaccess.h>
1763 #include <asm/param.h>
1764 #include <asm/page.h>
1765 diff -NurpP --minimal linux-2.6.29/fs/binfmt_flat.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/binfmt_flat.c
1766 --- linux-2.6.29/fs/binfmt_flat.c 2009-03-24 14:22:24.000000000 +0100
1767 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/binfmt_flat.c 2009-03-24 14:48:34.000000000 +0100
1769 #include <linux/init.h>
1770 #include <linux/flat.h>
1771 #include <linux/syscalls.h>
1772 +#include <linux/vs_memory.h>
1774 #include <asm/byteorder.h>
1775 #include <asm/system.h>
1776 diff -NurpP --minimal linux-2.6.29/fs/binfmt_som.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/binfmt_som.c
1777 --- linux-2.6.29/fs/binfmt_som.c 2009-03-24 14:22:24.000000000 +0100
1778 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/binfmt_som.c 2009-03-24 14:48:34.000000000 +0100
1780 #include <linux/shm.h>
1781 #include <linux/personality.h>
1782 #include <linux/init.h>
1783 +#include <linux/vs_memory.h>
1785 #include <asm/uaccess.h>
1786 #include <asm/pgtable.h>
1787 diff -NurpP --minimal linux-2.6.29/fs/block_dev.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/block_dev.c
1788 --- linux-2.6.29/fs/block_dev.c 2009-03-24 14:22:24.000000000 +0100
1789 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/block_dev.c 2009-03-24 14:48:34.000000000 +0100
1791 #include <linux/uio.h>
1792 #include <linux/namei.h>
1793 #include <linux/log2.h>
1794 +#include <linux/vs_device.h>
1795 #include <asm/uaccess.h>
1796 #include "internal.h"
1798 @@ -392,6 +393,7 @@ struct block_device *bdget(dev_t dev)
1799 bdev->bd_invalidated = 0;
1800 inode->i_mode = S_IFBLK;
1801 inode->i_rdev = dev;
1802 + inode->i_mdev = dev;
1803 inode->i_bdev = bdev;
1804 inode->i_data.a_ops = &def_blk_aops;
1805 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1806 @@ -428,6 +430,11 @@ EXPORT_SYMBOL(bdput);
1807 static struct block_device *bd_acquire(struct inode *inode)
1809 struct block_device *bdev;
1812 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1814 + inode->i_mdev = mdev;
1816 spin_lock(&bdev_lock);
1817 bdev = inode->i_bdev;
1818 @@ -438,7 +445,7 @@ static struct block_device *bd_acquire(s
1820 spin_unlock(&bdev_lock);
1822 - bdev = bdget(inode->i_rdev);
1823 + bdev = bdget(mdev);
1825 spin_lock(&bdev_lock);
1826 if (!inode->i_bdev) {
1827 diff -NurpP --minimal linux-2.6.29/fs/char_dev.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/char_dev.c
1828 --- linux-2.6.29/fs/char_dev.c 2009-03-24 14:22:25.000000000 +0100
1829 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/char_dev.c 2009-03-24 14:48:35.000000000 +0100
1831 #include <linux/cdev.h>
1832 #include <linux/mutex.h>
1833 #include <linux/backing-dev.h>
1834 +#include <linux/vs_context.h>
1835 +#include <linux/vs_device.h>
1837 #include "internal.h"
1839 @@ -358,14 +360,21 @@ static int chrdev_open(struct inode *ino
1841 struct cdev *new = NULL;
1845 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
1847 + inode->i_mdev = mdev;
1849 spin_lock(&cdev_lock);
1852 struct kobject *kobj;
1855 spin_unlock(&cdev_lock);
1856 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
1858 + kobj = kobj_lookup(cdev_map, mdev, &idx);
1861 new = container_of(kobj, struct cdev, kobj);
1862 diff -NurpP --minimal linux-2.6.29/fs/dcache.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/dcache.c
1863 --- linux-2.6.29/fs/dcache.c 2009-03-24 14:22:25.000000000 +0100
1864 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/dcache.c 2009-03-24 14:48:35.000000000 +0100
1866 #include <linux/seqlock.h>
1867 #include <linux/swap.h>
1868 #include <linux/bootmem.h>
1869 +#include <linux/vs_limit.h>
1870 #include "internal.h"
1872 int sysctl_vfs_cache_pressure __read_mostly = 100;
1873 @@ -229,6 +230,8 @@ repeat:
1877 + vx_dentry_dec(dentry);
1880 * AV: ->d_delete() is _NOT_ allowed to block now.
1882 @@ -320,6 +323,7 @@ static inline struct dentry * __dget_loc
1884 atomic_inc(&dentry->d_count);
1885 dentry_lru_del_init(dentry);
1886 + vx_dentry_inc(dentry);
1890 @@ -918,6 +922,9 @@ struct dentry *d_alloc(struct dentry * p
1891 struct dentry *dentry;
1894 + if (!vx_dentry_avail(1))
1897 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
1900 @@ -963,6 +970,7 @@ struct dentry *d_alloc(struct dentry * p
1902 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
1903 dentry_stat.nr_dentry++;
1904 + vx_dentry_inc(dentry);
1905 spin_unlock(&dcache_lock);
1908 @@ -1418,6 +1426,7 @@ struct dentry * __d_lookup(struct dentry
1911 atomic_inc(&dentry->d_count);
1912 + vx_dentry_inc(dentry);
1914 spin_unlock(&dentry->d_lock);
1916 diff -NurpP --minimal linux-2.6.29/fs/devpts/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/devpts/inode.c
1917 --- linux-2.6.29/fs/devpts/inode.c 2009-03-24 14:22:25.000000000 +0100
1918 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/devpts/inode.c 2009-03-24 15:32:47.000000000 +0100
1920 #include <linux/tty.h>
1921 #include <linux/mutex.h>
1922 #include <linux/idr.h>
1923 +#include <linux/magic.h>
1924 #include <linux/devpts_fs.h>
1925 #include <linux/parser.h>
1926 #include <linux/fsnotify.h>
1927 #include <linux/seq_file.h>
1929 -#define DEVPTS_SUPER_MAGIC 0x1cd1
1930 +#include <linux/vs_base.h>
1932 #define DEVPTS_DEFAULT_MODE 0600
1935 #define DEVPTS_DEFAULT_PTMX_MODE 0000
1936 #define PTMX_MINOR 2
1938 +static int devpts_permission(struct inode *inode, int mask)
1940 + int ret = -EACCES;
1942 + /* devpts is xid tagged */
1943 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
1944 + ret = generic_permission(inode, mask, NULL);
1948 +static struct inode_operations devpts_file_inode_operations = {
1949 + .permission = devpts_permission,
1952 extern int pty_limit; /* Config limit on Unix98 ptys */
1953 static DEFINE_MUTEX(allocated_ptys_lock);
1955 @@ -254,6 +268,25 @@ static int devpts_show_options(struct se
1959 +static int devpts_filter(struct dentry *de)
1961 + /* devpts is xid tagged */
1962 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
1965 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
1967 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
1970 +static struct file_operations devpts_dir_operations = {
1971 + .open = dcache_dir_open,
1972 + .release = dcache_dir_close,
1973 + .llseek = dcache_dir_lseek,
1974 + .read = generic_read_dir,
1975 + .readdir = devpts_readdir,
1978 static const struct super_operations devpts_sops = {
1979 .statfs = simple_statfs,
1980 .remount_fs = devpts_remount,
1981 @@ -293,12 +326,15 @@ devpts_fill_super(struct super_block *s,
1982 inode = new_inode(s);
1987 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
1988 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
1989 inode->i_op = &simple_dir_inode_operations;
1990 - inode->i_fop = &simple_dir_operations;
1991 + inode->i_fop = &devpts_dir_operations;
1993 + /* devpts is xid tagged */
1994 + inode->i_tag = (tag_t)vx_current_xid();
1996 s->s_root = d_alloc_root(inode);
1998 @@ -479,6 +515,7 @@ static int init_pts_mount(struct file_sy
2003 static int devpts_get_sb(struct file_system_type *fs_type,
2004 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
2006 @@ -590,6 +627,9 @@ int devpts_pty_new(struct inode *ptmx_in
2007 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2008 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2009 init_special_inode(inode, S_IFCHR|opts->mode, device);
2010 + /* devpts is xid tagged */
2011 + inode->i_tag = (tag_t)vx_current_xid();
2012 + inode->i_op = &devpts_file_inode_operations;
2013 inode->i_private = tty;
2014 tty->driver_data = inode;
2016 diff -NurpP --minimal linux-2.6.29/fs/exec.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/exec.c
2017 --- linux-2.6.29/fs/exec.c 2009-03-24 14:22:25.000000000 +0100
2018 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/exec.c 2009-03-24 15:34:21.000000000 +0100
2019 @@ -257,7 +257,9 @@ static int __bprm_mm_init(struct linux_b
2023 - mm->stack_vm = mm->total_vm = 1;
2025 + vx_vmpages_inc(mm);
2027 up_write(&mm->mmap_sem);
2028 bprm->p = vma->vm_end - sizeof(void *);
2030 @@ -1450,7 +1452,7 @@ static int format_corename(char *corenam
2031 /* UNIX time of coredump */
2034 - do_gettimeofday(&tv);
2035 + vx_gettimeofday(&tv);
2036 rc = snprintf(out_ptr, out_end - out_ptr,
2038 if (rc > out_end - out_ptr)
2039 diff -NurpP --minimal linux-2.6.29/fs/ext2/balloc.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/balloc.c
2040 --- linux-2.6.29/fs/ext2/balloc.c 2009-03-24 14:22:25.000000000 +0100
2041 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/balloc.c 2009-03-24 14:48:35.000000000 +0100
2043 #include <linux/sched.h>
2044 #include <linux/buffer_head.h>
2045 #include <linux/capability.h>
2046 +#include <linux/vs_dlimit.h>
2047 +#include <linux/vs_tag.h>
2050 * balloc.c contains the blocks allocation and deallocation routines
2051 @@ -569,6 +571,7 @@ do_more:
2055 + DLIMIT_FREE_BLOCK(inode, freed);
2056 release_blocks(sb, freed);
2057 DQUOT_FREE_BLOCK(inode, freed);
2059 @@ -701,7 +704,6 @@ ext2_try_to_allocate(struct super_block
2061 end = EXT2_BLOCKS_PER_GROUP(sb);
2064 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2067 @@ -1251,6 +1253,11 @@ ext2_fsblk_t ext2_new_blocks(struct inod
2071 + if (DLIMIT_ALLOC_BLOCK(inode, num)) {
2073 + DQUOT_FREE_BLOCK(inode, num);
2078 es = EXT2_SB(sb)->s_es;
2079 @@ -1409,6 +1416,7 @@ allocated:
2083 + DLIMIT_FREE_BLOCK(inode, *count-num);
2084 DQUOT_FREE_BLOCK(inode, *count-num);
2087 @@ -1419,8 +1427,10 @@ out:
2089 * Undo the block allocation
2091 - if (!performed_allocation)
2092 + if (!performed_allocation) {
2093 + DLIMIT_FREE_BLOCK(inode, *count);
2094 DQUOT_FREE_BLOCK(inode, *count);
2099 diff -NurpP --minimal linux-2.6.29/fs/ext2/ext2.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/ext2.h
2100 --- linux-2.6.29/fs/ext2/ext2.h 2008-12-25 00:26:37.000000000 +0100
2101 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/ext2.h 2009-02-22 22:54:25.000000000 +0100
2102 @@ -170,6 +170,7 @@ extern const struct file_operations ext2
2103 extern const struct address_space_operations ext2_aops;
2104 extern const struct address_space_operations ext2_aops_xip;
2105 extern const struct address_space_operations ext2_nobh_aops;
2106 +extern int ext2_sync_flags(struct inode *inode);
2109 extern const struct inode_operations ext2_dir_inode_operations;
2110 diff -NurpP --minimal linux-2.6.29/fs/ext2/file.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/file.c
2111 --- linux-2.6.29/fs/ext2/file.c 2008-12-25 00:26:37.000000000 +0100
2112 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/file.c 2009-02-22 22:54:25.000000000 +0100
2113 @@ -87,4 +87,5 @@ const struct inode_operations ext2_file_
2114 .setattr = ext2_setattr,
2115 .permission = ext2_permission,
2116 .fiemap = ext2_fiemap,
2117 + .sync_flags = ext2_sync_flags,
2119 diff -NurpP --minimal linux-2.6.29/fs/ext2/ialloc.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/ialloc.c
2120 --- linux-2.6.29/fs/ext2/ialloc.c 2009-03-24 14:22:25.000000000 +0100
2121 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/ialloc.c 2009-03-24 15:36:12.000000000 +0100
2123 #include <linux/backing-dev.h>
2124 #include <linux/buffer_head.h>
2125 #include <linux/random.h>
2126 +#include <linux/vs_dlimit.h>
2127 +#include <linux/vs_tag.h>
2131 @@ -123,6 +125,7 @@ void ext2_free_inode (struct inode * ino
2132 ext2_xattr_delete_inode(inode);
2133 DQUOT_FREE_INODE(inode);
2135 + DLIMIT_FREE_INODE(inode);
2138 es = EXT2_SB(sb)->s_es;
2139 @@ -454,6 +457,11 @@ struct inode *ext2_new_inode(struct inod
2141 return ERR_PTR(-ENOMEM);
2143 + inode->i_tag = dx_current_fstag(sb);
2144 + if (DLIMIT_ALLOC_INODE(inode)) {
2151 @@ -609,6 +617,7 @@ fail_free_drop:
2155 + DLIMIT_FREE_INODE(inode);
2156 inode->i_flags |= S_NOQUOTA;
2158 unlock_new_inode(inode);
2159 @@ -616,6 +625,8 @@ fail_drop:
2160 return ERR_PTR(err);
2163 + DLIMIT_FREE_INODE(inode);
2165 make_bad_inode(inode);
2167 return ERR_PTR(err);
2168 diff -NurpP --minimal linux-2.6.29/fs/ext2/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/inode.c
2169 --- linux-2.6.29/fs/ext2/inode.c 2009-03-24 14:22:25.000000000 +0100
2170 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/inode.c 2009-03-24 15:41:38.000000000 +0100
2172 #include <linux/mpage.h>
2173 #include <linux/fiemap.h>
2174 #include <linux/namei.h>
2175 +#include <linux/vs_tag.h>
2179 @@ -1018,7 +1019,7 @@ void ext2_truncate(struct inode *inode)
2181 if (ext2_inode_is_fast_symlink(inode))
2183 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2184 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2187 blocksize = inode->i_sb->s_blocksize;
2188 @@ -1156,38 +1157,72 @@ void ext2_set_inode_flags(struct inode *
2190 unsigned int flags = EXT2_I(inode)->i_flags;
2192 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2193 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2194 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2197 + if (flags & EXT2_IMMUTABLE_FL)
2198 + inode->i_flags |= S_IMMUTABLE;
2199 + if (flags & EXT2_IXUNLINK_FL)
2200 + inode->i_flags |= S_IXUNLINK;
2202 if (flags & EXT2_SYNC_FL)
2203 inode->i_flags |= S_SYNC;
2204 if (flags & EXT2_APPEND_FL)
2205 inode->i_flags |= S_APPEND;
2206 - if (flags & EXT2_IMMUTABLE_FL)
2207 - inode->i_flags |= S_IMMUTABLE;
2208 if (flags & EXT2_NOATIME_FL)
2209 inode->i_flags |= S_NOATIME;
2210 if (flags & EXT2_DIRSYNC_FL)
2211 inode->i_flags |= S_DIRSYNC;
2213 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2215 + if (flags & EXT2_BARRIER_FL)
2216 + inode->i_vflags |= V_BARRIER;
2217 + if (flags & EXT2_COW_FL)
2218 + inode->i_vflags |= V_COW;
2221 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2222 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2224 unsigned int flags = ei->vfs_inode.i_flags;
2225 + unsigned int vflags = ei->vfs_inode.i_vflags;
2227 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2228 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2229 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2230 + EXT2_BARRIER_FL | EXT2_COW_FL);
2232 + if (flags & S_IMMUTABLE)
2233 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2234 + if (flags & S_IXUNLINK)
2235 + ei->i_flags |= EXT2_IXUNLINK_FL;
2237 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2238 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2240 ei->i_flags |= EXT2_SYNC_FL;
2241 if (flags & S_APPEND)
2242 ei->i_flags |= EXT2_APPEND_FL;
2243 - if (flags & S_IMMUTABLE)
2244 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2245 if (flags & S_NOATIME)
2246 ei->i_flags |= EXT2_NOATIME_FL;
2247 if (flags & S_DIRSYNC)
2248 ei->i_flags |= EXT2_DIRSYNC_FL;
2250 + if (vflags & V_BARRIER)
2251 + ei->i_flags |= EXT2_BARRIER_FL;
2252 + if (vflags & V_COW)
2253 + ei->i_flags |= EXT2_COW_FL;
2256 +int ext2_sync_flags(struct inode *inode)
2258 + ext2_get_inode_flags(EXT2_I(inode));
2259 + inode->i_ctime = CURRENT_TIME;
2260 + mark_inode_dirty(inode);
2265 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2267 struct ext2_inode_info *ei;
2268 @@ -1195,6 +1230,8 @@ struct inode *ext2_iget (struct super_bl
2269 struct ext2_inode *raw_inode;
2270 struct inode *inode;
2276 inode = iget_locked(sb, ino);
2277 @@ -1217,12 +1254,17 @@ struct inode *ext2_iget (struct super_bl
2280 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2281 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2282 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2283 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2284 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2285 if (!(test_opt (inode->i_sb, NO_UID32))) {
2286 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2287 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2288 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2289 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2291 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2292 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2293 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2294 + le16_to_cpu(raw_inode->i_raw_tag));
2296 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2297 inode->i_size = le32_to_cpu(raw_inode->i_size);
2298 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2299 @@ -1320,8 +1362,8 @@ static int ext2_update_inode(struct inod
2300 struct ext2_inode_info *ei = EXT2_I(inode);
2301 struct super_block *sb = inode->i_sb;
2302 ino_t ino = inode->i_ino;
2303 - uid_t uid = inode->i_uid;
2304 - gid_t gid = inode->i_gid;
2305 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2306 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2307 struct buffer_head * bh;
2308 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2310 @@ -1357,6 +1399,9 @@ static int ext2_update_inode(struct inod
2311 raw_inode->i_uid_high = 0;
2312 raw_inode->i_gid_high = 0;
2314 +#ifdef CONFIG_TAGGING_INTERN
2315 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2317 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2318 raw_inode->i_size = cpu_to_le32(inode->i_size);
2319 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2320 @@ -1443,7 +1488,8 @@ int ext2_setattr(struct dentry *dentry,
2323 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2324 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2325 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2326 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2327 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
2330 diff -NurpP --minimal linux-2.6.29/fs/ext2/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/ioctl.c
2331 --- linux-2.6.29/fs/ext2/ioctl.c 2009-03-24 14:22:25.000000000 +0100
2332 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/ioctl.c 2009-03-24 14:48:35.000000000 +0100
2334 #include <linux/compat.h>
2335 #include <linux/mount.h>
2336 #include <linux/smp_lock.h>
2337 +#include <linux/mount.h>
2338 #include <asm/current.h>
2339 #include <asm/uaccess.h>
2341 @@ -52,6 +53,11 @@ long ext2_ioctl(struct file *filp, unsig
2343 flags = ext2_mask_flags(inode->i_mode, flags);
2345 + if (IS_BARRIER(inode)) {
2346 + vxwprintk_task(1, "messing with the barrier.");
2350 mutex_lock(&inode->i_mutex);
2351 /* Is it quota file? Do not allow user to mess with it */
2352 if (IS_NOQUOTA(inode)) {
2353 @@ -67,7 +73,9 @@ long ext2_ioctl(struct file *filp, unsig
2355 * This test looks nicer. Thanks to Pauline Middelink
2357 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2358 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2359 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2360 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2361 if (!capable(CAP_LINUX_IMMUTABLE)) {
2362 mutex_unlock(&inode->i_mutex);
2364 diff -NurpP --minimal linux-2.6.29/fs/ext2/namei.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/namei.c
2365 --- linux-2.6.29/fs/ext2/namei.c 2009-03-24 14:22:25.000000000 +0100
2366 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/namei.c 2009-03-24 14:48:35.000000000 +0100
2370 #include <linux/pagemap.h>
2371 +#include <linux/vs_tag.h>
2375 @@ -68,6 +69,7 @@ static struct dentry *ext2_lookup(struct
2376 inode = ext2_iget(dir->i_sb, ino);
2378 return ERR_CAST(inode);
2379 + dx_propagate_tag(nd, inode);
2381 return d_splice_alias(inode, dentry);
2383 @@ -388,6 +390,7 @@ const struct inode_operations ext2_dir_i
2385 .setattr = ext2_setattr,
2386 .permission = ext2_permission,
2387 + .sync_flags = ext2_sync_flags,
2390 const struct inode_operations ext2_special_inode_operations = {
2391 @@ -399,4 +402,5 @@ const struct inode_operations ext2_speci
2393 .setattr = ext2_setattr,
2394 .permission = ext2_permission,
2395 + .sync_flags = ext2_sync_flags,
2397 diff -NurpP --minimal linux-2.6.29/fs/ext2/super.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/super.c
2398 --- linux-2.6.29/fs/ext2/super.c 2009-03-24 14:22:25.000000000 +0100
2399 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/super.c 2009-03-24 14:48:35.000000000 +0100
2400 @@ -391,7 +391,8 @@ enum {
2401 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2402 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2403 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2404 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2405 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2406 + Opt_tag, Opt_notag, Opt_tagid
2409 static const match_table_t tokens = {
2410 @@ -419,6 +420,9 @@ static const match_table_t tokens = {
2412 {Opt_noacl, "noacl"},
2415 + {Opt_notag, "notag"},
2416 + {Opt_tagid, "tagid=%u"},
2417 {Opt_grpquota, "grpquota"},
2418 {Opt_ignore, "noquota"},
2419 {Opt_quota, "quota"},
2420 @@ -489,6 +493,20 @@ static int parse_options (char * options
2422 set_opt (sbi->s_mount_opt, NO_UID32);
2424 +#ifndef CONFIG_TAGGING_NONE
2426 + set_opt (sbi->s_mount_opt, TAGGED);
2429 + clear_opt (sbi->s_mount_opt, TAGGED);
2432 +#ifdef CONFIG_PROPAGATE
2435 + set_opt (sbi->s_mount_opt, TAGGED);
2439 clear_opt (sbi->s_mount_opt, CHECK);
2441 @@ -838,6 +856,8 @@ static int ext2_fill_super(struct super_
2442 if (!parse_options ((char *) data, sbi))
2445 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2446 + sb->s_flags |= MS_TAGGED;
2447 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2448 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2450 @@ -1170,6 +1190,13 @@ static int ext2_remount (struct super_bl
2454 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2455 + !(sb->s_flags & MS_TAGGED)) {
2456 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2461 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2462 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2464 diff -NurpP --minimal linux-2.6.29/fs/ext2/symlink.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/symlink.c
2465 --- linux-2.6.29/fs/ext2/symlink.c 2008-12-25 00:26:37.000000000 +0100
2466 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/symlink.c 2009-02-22 22:54:25.000000000 +0100
2467 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
2468 .listxattr = ext2_listxattr,
2469 .removexattr = generic_removexattr,
2471 + .sync_flags = ext2_sync_flags,
2474 const struct inode_operations ext2_fast_symlink_inode_operations = {
2475 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
2476 .listxattr = ext2_listxattr,
2477 .removexattr = generic_removexattr,
2479 + .sync_flags = ext2_sync_flags,
2481 diff -NurpP --minimal linux-2.6.29/fs/ext2/xattr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/xattr.c
2482 --- linux-2.6.29/fs/ext2/xattr.c 2008-12-25 00:26:37.000000000 +0100
2483 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext2/xattr.c 2009-02-22 22:54:25.000000000 +0100
2485 #include <linux/mbcache.h>
2486 #include <linux/quotaops.h>
2487 #include <linux/rwsem.h>
2488 +#include <linux/vs_dlimit.h>
2492 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
2494 ea_bdebug(new_bh, "reusing block");
2497 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
2500 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
2501 + DLIMIT_FREE_BLOCK(inode, 1);
2502 unlock_buffer(new_bh);
2505 @@ -731,6 +736,7 @@ ext2_xattr_set2(struct inode *inode, str
2506 le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
2508 mb_cache_entry_release(ce);
2509 + DLIMIT_FREE_BLOCK(inode, 1);
2510 DQUOT_FREE_BLOCK(inode, 1);
2511 mark_buffer_dirty(old_bh);
2512 ea_bdebug(old_bh, "refcount now=%d",
2513 @@ -794,6 +800,7 @@ ext2_xattr_delete_inode(struct inode *in
2514 mark_buffer_dirty(bh);
2516 sync_dirty_buffer(bh);
2517 + DLIMIT_FREE_BLOCK(inode, 1);
2518 DQUOT_FREE_BLOCK(inode, 1);
2520 EXT2_I(inode)->i_file_acl = 0;
2521 diff -NurpP --minimal linux-2.6.29/fs/ext3/balloc.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/balloc.c
2522 --- linux-2.6.29/fs/ext3/balloc.c 2009-03-24 14:22:25.000000000 +0100
2523 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/balloc.c 2009-03-25 00:53:20.000000000 +0100
2525 #include <linux/ext3_jbd.h>
2526 #include <linux/quotaops.h>
2527 #include <linux/buffer_head.h>
2528 +#include <linux/vs_dlimit.h>
2529 +#include <linux/vs_tag.h>
2532 * balloc.c contains the blocks allocation and deallocation routines
2533 @@ -675,8 +677,10 @@ void ext3_free_blocks(handle_t *handle,
2536 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
2537 - if (dquot_freed_blocks)
2538 + if (dquot_freed_blocks) {
2539 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
2540 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
2545 @@ -1415,18 +1419,33 @@ out:
2547 * Check if filesystem has at least 1 free block available for allocation.
2549 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
2550 +static int ext3_has_free_blocks(struct super_block *sb)
2552 - ext3_fsblk_t free_blocks, root_blocks;
2553 + struct ext3_sb_info *sbi = EXT3_SB(sb);
2554 + unsigned long long free_blocks, root_blocks;
2557 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
2558 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
2559 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
2561 + vxdprintk(VXD_CBIT(dlim, 3),
2562 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
2563 + sb, free_blocks, root_blocks);
2565 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
2567 + cond = (free_blocks < root_blocks + 1 &&
2568 + !capable(CAP_SYS_RESOURCE) &&
2569 sbi->s_resuid != current_fsuid() &&
2570 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
2574 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
2576 + vxdprintk(VXD_CBIT(dlim, 3),
2577 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
2578 + sb, free_blocks, root_blocks,
2579 + !capable(CAP_SYS_RESOURCE)?'1':'0',
2580 + sbi->s_resuid, current_fsuid(), cond?0:1);
2582 + return (cond ? 0 : 1);
2586 @@ -1443,7 +1462,7 @@ static int ext3_has_free_blocks(struct e
2588 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
2590 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
2591 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
2594 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
2595 @@ -1506,6 +1525,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
2599 + if (DLIMIT_ALLOC_BLOCK(inode, num))
2603 es = EXT3_SB(sb)->s_es;
2604 @@ -1522,7 +1543,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
2605 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
2606 my_rsv = &block_i->rsv_window_node;
2608 - if (!ext3_has_free_blocks(sbi)) {
2609 + if (!ext3_has_free_blocks(sb)) {
2613 @@ -1715,12 +1736,16 @@ allocated:
2616 DQUOT_FREE_BLOCK(inode, *count-num);
2617 + DLIMIT_FREE_BLOCK(inode, *count-num);
2624 + if (!performed_allocation)
2625 + DLIMIT_FREE_BLOCK(inode, *count);
2629 ext3_std_error(sb, fatal);
2630 diff -NurpP --minimal linux-2.6.29/fs/ext3/file.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/file.c
2631 --- linux-2.6.29/fs/ext3/file.c 2008-12-25 00:26:37.000000000 +0100
2632 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/file.c 2009-02-22 22:54:25.000000000 +0100
2633 @@ -135,5 +135,6 @@ const struct inode_operations ext3_file_
2635 .permission = ext3_permission,
2636 .fiemap = ext3_fiemap,
2637 + .sync_flags = ext3_sync_flags,
2640 diff -NurpP --minimal linux-2.6.29/fs/ext3/ialloc.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/ialloc.c
2641 --- linux-2.6.29/fs/ext3/ialloc.c 2009-03-24 14:22:25.000000000 +0100
2642 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/ialloc.c 2009-03-24 15:44:06.000000000 +0100
2644 #include <linux/buffer_head.h>
2645 #include <linux/random.h>
2646 #include <linux/bitops.h>
2647 +#include <linux/vs_dlimit.h>
2648 +#include <linux/vs_tag.h>
2650 #include <asm/byteorder.h>
2652 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
2653 ext3_xattr_delete_inode(handle, inode);
2654 DQUOT_FREE_INODE(inode);
2656 + DLIMIT_FREE_INODE(inode);
2658 is_directory = S_ISDIR(inode->i_mode);
2660 @@ -440,6 +443,12 @@ struct inode *ext3_new_inode(handle_t *h
2661 inode = new_inode(sb);
2663 return ERR_PTR(-ENOMEM);
2665 + inode->i_tag = dx_current_fstag(sb);
2666 + if (DLIMIT_ALLOC_INODE(inode)) {
2673 @@ -613,6 +622,8 @@ got:
2675 ext3_std_error(sb, err);
2677 + DLIMIT_FREE_INODE(inode);
2682 @@ -624,6 +635,7 @@ fail_free_drop:
2686 + DLIMIT_FREE_INODE(inode);
2687 inode->i_flags |= S_NOQUOTA;
2689 unlock_new_inode(inode);
2690 diff -NurpP --minimal linux-2.6.29/fs/ext3/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/inode.c
2691 --- linux-2.6.29/fs/ext3/inode.c 2009-03-24 14:22:25.000000000 +0100
2692 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/inode.c 2009-03-24 15:44:29.000000000 +0100
2694 #include <linux/bio.h>
2695 #include <linux/fiemap.h>
2696 #include <linux/namei.h>
2697 +#include <linux/vs_tag.h>
2701 @@ -2288,7 +2289,7 @@ static void ext3_free_branches(handle_t
2703 int ext3_can_truncate(struct inode *inode)
2705 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2706 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2708 if (S_ISREG(inode->i_mode))
2710 @@ -2662,36 +2663,84 @@ void ext3_set_inode_flags(struct inode *
2712 unsigned int flags = EXT3_I(inode)->i_flags;
2714 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2715 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2716 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2718 + if (flags & EXT3_IMMUTABLE_FL)
2719 + inode->i_flags |= S_IMMUTABLE;
2720 + if (flags & EXT3_IXUNLINK_FL)
2721 + inode->i_flags |= S_IXUNLINK;
2723 if (flags & EXT3_SYNC_FL)
2724 inode->i_flags |= S_SYNC;
2725 if (flags & EXT3_APPEND_FL)
2726 inode->i_flags |= S_APPEND;
2727 - if (flags & EXT3_IMMUTABLE_FL)
2728 - inode->i_flags |= S_IMMUTABLE;
2729 if (flags & EXT3_NOATIME_FL)
2730 inode->i_flags |= S_NOATIME;
2731 if (flags & EXT3_DIRSYNC_FL)
2732 inode->i_flags |= S_DIRSYNC;
2734 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2736 + if (flags & EXT3_BARRIER_FL)
2737 + inode->i_vflags |= V_BARRIER;
2738 + if (flags & EXT3_COW_FL)
2739 + inode->i_vflags |= V_COW;
2742 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2743 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2745 unsigned int flags = ei->vfs_inode.i_flags;
2746 + unsigned int vflags = ei->vfs_inode.i_vflags;
2748 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2749 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2750 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2751 + EXT3_BARRIER_FL | EXT3_COW_FL);
2753 + if (flags & S_IMMUTABLE)
2754 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2755 + if (flags & S_IXUNLINK)
2756 + ei->i_flags |= EXT3_IXUNLINK_FL;
2758 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2759 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2761 ei->i_flags |= EXT3_SYNC_FL;
2762 if (flags & S_APPEND)
2763 ei->i_flags |= EXT3_APPEND_FL;
2764 - if (flags & S_IMMUTABLE)
2765 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2766 if (flags & S_NOATIME)
2767 ei->i_flags |= EXT3_NOATIME_FL;
2768 if (flags & S_DIRSYNC)
2769 ei->i_flags |= EXT3_DIRSYNC_FL;
2771 + if (vflags & V_BARRIER)
2772 + ei->i_flags |= EXT3_BARRIER_FL;
2773 + if (vflags & V_COW)
2774 + ei->i_flags |= EXT3_COW_FL;
2777 +int ext3_sync_flags(struct inode *inode)
2779 + struct ext3_iloc iloc;
2783 + handle = ext3_journal_start(inode, 1);
2784 + if (IS_ERR(handle))
2785 + return PTR_ERR(handle);
2786 + if (IS_SYNC(inode))
2787 + handle->h_sync = 1;
2788 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2792 + ext3_get_inode_flags(EXT3_I(inode));
2793 + inode->i_ctime = CURRENT_TIME;
2795 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2797 + ext3_journal_stop(handle);
2801 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2802 @@ -2703,6 +2752,8 @@ struct inode *ext3_iget(struct super_blo
2803 struct inode *inode;
2809 inode = iget_locked(sb, ino);
2811 @@ -2723,12 +2774,17 @@ struct inode *ext3_iget(struct super_blo
2813 raw_inode = ext3_raw_inode(&iloc);
2814 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2815 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2816 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2817 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2818 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2819 if(!(test_opt (inode->i_sb, NO_UID32))) {
2820 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2821 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2822 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2823 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2825 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2826 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2827 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2828 + le16_to_cpu(raw_inode->i_raw_tag));
2830 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2831 inode->i_size = le32_to_cpu(raw_inode->i_size);
2832 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2833 @@ -2859,6 +2915,8 @@ static int ext3_do_update_inode(handle_t
2834 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
2835 struct ext3_inode_info *ei = EXT3_I(inode);
2836 struct buffer_head *bh = iloc->bh;
2837 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2838 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2839 int err = 0, rc, block;
2841 /* For fields not not tracking in the in-memory inode,
2842 @@ -2869,29 +2927,32 @@ static int ext3_do_update_inode(handle_t
2843 ext3_get_inode_flags(ei);
2844 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2845 if(!(test_opt(inode->i_sb, NO_UID32))) {
2846 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
2847 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
2848 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
2849 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
2851 * Fix up interoperability with old kernels. Otherwise, old inodes get
2852 * re-used with the upper 16 bits of the uid/gid intact
2855 raw_inode->i_uid_high =
2856 - cpu_to_le16(high_16_bits(inode->i_uid));
2857 + cpu_to_le16(high_16_bits(uid));
2858 raw_inode->i_gid_high =
2859 - cpu_to_le16(high_16_bits(inode->i_gid));
2860 + cpu_to_le16(high_16_bits(gid));
2862 raw_inode->i_uid_high = 0;
2863 raw_inode->i_gid_high = 0;
2866 raw_inode->i_uid_low =
2867 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
2868 + cpu_to_le16(fs_high2lowuid(uid));
2869 raw_inode->i_gid_low =
2870 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
2871 + cpu_to_le16(fs_high2lowgid(gid));
2872 raw_inode->i_uid_high = 0;
2873 raw_inode->i_gid_high = 0;
2875 +#ifdef CONFIG_TAGGING_INTERN
2876 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2878 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2879 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
2880 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2881 @@ -3044,7 +3105,8 @@ int ext3_setattr(struct dentry *dentry,
2884 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2885 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
2886 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2887 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2890 /* (user+group)*(old+new) structure, inode write (sb,
2891 @@ -3066,6 +3128,8 @@ int ext3_setattr(struct dentry *dentry,
2892 inode->i_uid = attr->ia_uid;
2893 if (attr->ia_valid & ATTR_GID)
2894 inode->i_gid = attr->ia_gid;
2895 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2896 + inode->i_tag = attr->ia_tag;
2897 error = ext3_mark_inode_dirty(handle, inode);
2898 ext3_journal_stop(handle);
2900 diff -NurpP --minimal linux-2.6.29/fs/ext3/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/ioctl.c
2901 --- linux-2.6.29/fs/ext3/ioctl.c 2009-03-24 14:22:25.000000000 +0100
2902 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/ioctl.c 2009-03-24 14:48:35.000000000 +0100
2906 #include <linux/fs.h>
2907 +#include <linux/mount.h>
2908 #include <linux/jbd.h>
2909 #include <linux/capability.h>
2910 #include <linux/ext3_fs.h>
2912 #include <linux/time.h>
2913 #include <linux/compat.h>
2914 #include <linux/smp_lock.h>
2915 +#include <linux/vs_tag.h>
2916 #include <asm/uaccess.h>
2918 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
2919 @@ -55,6 +57,11 @@ int ext3_ioctl (struct inode * inode, st
2921 flags = ext3_mask_flags(inode->i_mode, flags);
2923 + if (IS_BARRIER(inode)) {
2924 + vxwprintk_task(1, "messing with the barrier.");
2928 mutex_lock(&inode->i_mutex);
2929 /* Is it quota file? Do not allow user to mess with it */
2930 if (IS_NOQUOTA(inode)) {
2931 @@ -73,7 +80,9 @@ int ext3_ioctl (struct inode * inode, st
2933 * This test looks nicer. Thanks to Pauline Middelink
2935 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2936 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2937 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2938 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2939 if (!capable(CAP_LINUX_IMMUTABLE)) {
2940 mutex_unlock(&inode->i_mutex);
2942 diff -NurpP --minimal linux-2.6.29/fs/ext3/namei.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/namei.c
2943 --- linux-2.6.29/fs/ext3/namei.c 2009-03-24 14:22:25.000000000 +0100
2944 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/namei.c 2009-03-24 14:48:35.000000000 +0100
2946 #include <linux/quotaops.h>
2947 #include <linux/buffer_head.h>
2948 #include <linux/bio.h>
2949 +#include <linux/vs_tag.h>
2953 @@ -912,6 +913,7 @@ restart:
2955 ll_rw_block(READ_META, 1, &bh);
2957 + dx_propagate_tag(nd, inode);
2959 if ((bh = bh_use[ra_ptr++]) == NULL)
2961 @@ -2433,6 +2435,7 @@ const struct inode_operations ext3_dir_i
2962 .removexattr = generic_removexattr,
2964 .permission = ext3_permission,
2965 + .sync_flags = ext3_sync_flags,
2968 const struct inode_operations ext3_special_inode_operations = {
2969 @@ -2444,4 +2447,5 @@ const struct inode_operations ext3_speci
2970 .removexattr = generic_removexattr,
2972 .permission = ext3_permission,
2973 + .sync_flags = ext3_sync_flags,
2975 diff -NurpP --minimal linux-2.6.29/fs/ext3/super.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/super.c
2976 --- linux-2.6.29/fs/ext3/super.c 2009-03-24 14:22:25.000000000 +0100
2977 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/super.c 2009-03-24 14:48:35.000000000 +0100
2978 @@ -790,7 +790,7 @@ enum {
2979 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2980 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
2981 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
2983 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
2986 static const match_table_t tokens = {
2987 @@ -843,6 +843,9 @@ static const match_table_t tokens = {
2988 {Opt_usrquota, "usrquota"},
2989 {Opt_barrier, "barrier=%u"},
2990 {Opt_resize, "resize"},
2992 + {Opt_notag, "notag"},
2993 + {Opt_tagid, "tagid=%u"},
2997 @@ -935,6 +938,20 @@ static int parse_options (char *options,
2999 set_opt (sbi->s_mount_opt, NO_UID32);
3001 +#ifndef CONFIG_TAGGING_NONE
3003 + set_opt (sbi->s_mount_opt, TAGGED);
3006 + clear_opt (sbi->s_mount_opt, TAGGED);
3009 +#ifdef CONFIG_PROPAGATE
3012 + set_opt (sbi->s_mount_opt, TAGGED);
3016 clear_opt (sbi->s_mount_opt, CHECK);
3018 @@ -1653,6 +1670,9 @@ static int ext3_fill_super (struct super
3022 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3023 + sb->s_flags |= MS_TAGGED;
3025 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3026 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3028 @@ -2527,6 +2547,13 @@ static int ext3_remount (struct super_bl
3029 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3030 ext3_abort(sb, __func__, "Abort forced by user");
3032 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3033 + !(sb->s_flags & MS_TAGGED)) {
3034 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3039 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3040 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3042 diff -NurpP --minimal linux-2.6.29/fs/ext3/symlink.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/symlink.c
3043 --- linux-2.6.29/fs/ext3/symlink.c 2008-12-25 00:26:37.000000000 +0100
3044 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/symlink.c 2009-02-22 22:54:25.000000000 +0100
3045 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
3046 .listxattr = ext3_listxattr,
3047 .removexattr = generic_removexattr,
3049 + .sync_flags = ext3_sync_flags,
3052 const struct inode_operations ext3_fast_symlink_inode_operations = {
3053 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
3054 .listxattr = ext3_listxattr,
3055 .removexattr = generic_removexattr,
3057 + .sync_flags = ext3_sync_flags,
3059 diff -NurpP --minimal linux-2.6.29/fs/ext3/xattr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/xattr.c
3060 --- linux-2.6.29/fs/ext3/xattr.c 2008-12-25 00:26:37.000000000 +0100
3061 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext3/xattr.c 2009-02-22 22:54:25.000000000 +0100
3063 #include <linux/mbcache.h>
3064 #include <linux/quotaops.h>
3065 #include <linux/rwsem.h>
3066 +#include <linux/vs_dlimit.h>
3070 @@ -498,6 +499,7 @@ ext3_xattr_release_block(handle_t *handl
3071 error = ext3_journal_dirty_metadata(handle, bh);
3074 + DLIMIT_FREE_BLOCK(inode, 1);
3075 DQUOT_FREE_BLOCK(inode, 1);
3076 ea_bdebug(bh, "refcount now=%d; releasing",
3077 le32_to_cpu(BHDR(bh)->h_refcount));
3078 @@ -771,11 +773,14 @@ inserted:
3079 if (new_bh == bs->bh)
3080 ea_bdebug(new_bh, "keeping");
3083 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3085 /* The old block is released after updating
3088 if (DQUOT_ALLOC_BLOCK(inode, 1))
3090 + goto cleanup_dlimit;
3091 error = ext3_journal_get_write_access(handle,
3094 @@ -849,6 +854,8 @@ cleanup:
3097 DQUOT_FREE_BLOCK(inode, 1);
3099 + DLIMIT_FREE_BLOCK(inode, 1);
3103 diff -NurpP --minimal linux-2.6.29/fs/ext4/balloc.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/balloc.c
3104 --- linux-2.6.29/fs/ext4/balloc.c 2009-03-24 14:22:25.000000000 +0100
3105 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/balloc.c 2009-03-24 14:48:35.000000000 +0100
3107 #include <linux/jbd2.h>
3108 #include <linux/quotaops.h>
3109 #include <linux/buffer_head.h>
3110 +#include <linux/vs_dlimit.h>
3111 +#include <linux/vs_tag.h>
3113 #include "ext4_jbd2.h"
3115 @@ -535,8 +537,10 @@ void ext4_free_blocks(handle_t *handle,
3117 ext4_mb_free_blocks(handle, inode, block, count,
3118 metadata, &dquot_freed_blocks);
3119 - if (dquot_freed_blocks)
3120 + if (dquot_freed_blocks) {
3121 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3122 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3127 diff -NurpP --minimal linux-2.6.29/fs/ext4/ext4.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/ext4.h
3128 --- linux-2.6.29/fs/ext4/ext4.h 2009-03-24 14:22:25.000000000 +0100
3129 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/ext4.h 2009-03-24 15:44:56.000000000 +0100
3130 @@ -243,8 +243,12 @@ struct flex_groups {
3131 #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
3132 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3133 #define EXT4_EXT_MIGRATE 0x00100000 /* Inode is migrating */
3134 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3135 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3137 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3138 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3140 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
3141 #define EXT4_FL_USER_MODIFIABLE 0x000B80FF /* User modifiable flags */
3143 @@ -541,6 +545,7 @@ do { \
3144 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3145 #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
3146 #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
3147 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
3149 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
3150 #ifndef _LINUX_EXT2_FS_H
3151 @@ -1076,6 +1081,7 @@ struct buffer_head *ext4_bread(handle_t
3152 ext4_lblk_t, int, int *);
3153 int ext4_get_block(struct inode *inode, sector_t iblock,
3154 struct buffer_head *bh_result, int create);
3155 +extern int ext4_sync_flags(struct inode *inode);
3157 extern struct inode *ext4_iget(struct super_block *, unsigned long);
3158 extern int ext4_write_inode(struct inode *, int);
3159 diff -NurpP --minimal linux-2.6.29/fs/ext4/file.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/file.c
3160 --- linux-2.6.29/fs/ext4/file.c 2009-03-24 14:22:25.000000000 +0100
3161 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/file.c 2009-03-24 14:48:35.000000000 +0100
3162 @@ -171,5 +171,6 @@ const struct inode_operations ext4_file_
3163 .permission = ext4_permission,
3164 .fallocate = ext4_fallocate,
3165 .fiemap = ext4_fiemap,
3166 + .sync_flags = ext4_sync_flags,
3169 diff -NurpP --minimal linux-2.6.29/fs/ext4/ialloc.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/ialloc.c
3170 --- linux-2.6.29/fs/ext4/ialloc.c 2009-03-24 14:22:25.000000000 +0100
3171 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/ialloc.c 2009-03-24 14:48:35.000000000 +0100
3173 #include <linux/random.h>
3174 #include <linux/bitops.h>
3175 #include <linux/blkdev.h>
3176 +#include <linux/vs_dlimit.h>
3177 +#include <linux/vs_tag.h>
3178 #include <asm/byteorder.h>
3180 #include "ext4_jbd2.h"
3181 @@ -224,6 +226,7 @@ void ext4_free_inode(handle_t *handle, s
3182 ext4_xattr_delete_inode(handle, inode);
3183 DQUOT_FREE_INODE(inode);
3185 + DLIMIT_FREE_INODE(inode);
3187 is_directory = S_ISDIR(inode->i_mode);
3189 @@ -711,6 +714,12 @@ struct inode *ext4_new_inode(handle_t *h
3190 inode = new_inode(sb);
3192 return ERR_PTR(-ENOMEM);
3194 + inode->i_tag = dx_current_fstag(sb);
3195 + if (DLIMIT_ALLOC_INODE(inode)) {
3202 @@ -889,7 +898,8 @@ got:
3203 * newly created directory and file only if -o extent mount option is
3206 - ei->i_flags = EXT4_I(dir)->i_flags & ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL);
3207 + ei->i_flags = EXT4_I(dir)->i_flags &
3208 + ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL|EXT4_IXUNLINK_FL|EXT4_BARRIER_FL);
3210 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
3211 /* dirsync only applies to directories */
3212 @@ -949,6 +959,8 @@ got:
3214 ext4_std_error(sb, err);
3216 + DLIMIT_FREE_INODE(inode);
3221 @@ -960,6 +972,7 @@ fail_free_drop:
3225 + DLIMIT_FREE_INODE(inode);
3226 inode->i_flags |= S_NOQUOTA;
3228 unlock_new_inode(inode);
3229 diff -NurpP --minimal linux-2.6.29/fs/ext4/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/inode.c
3230 --- linux-2.6.29/fs/ext4/inode.c 2009-03-24 14:22:25.000000000 +0100
3231 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/inode.c 2009-03-24 14:48:35.000000000 +0100
3233 #include <linux/namei.h>
3234 #include <linux/uio.h>
3235 #include <linux/bio.h>
3236 +#include <linux/vs_tag.h>
3237 #include "ext4_jbd2.h"
3240 @@ -3781,7 +3782,7 @@ static void ext4_free_branches(handle_t
3242 int ext4_can_truncate(struct inode *inode)
3244 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3245 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3247 if (S_ISREG(inode->i_mode))
3249 @@ -4134,37 +4135,86 @@ void ext4_set_inode_flags(struct inode *
3251 unsigned int flags = EXT4_I(inode)->i_flags;
3253 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3254 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3255 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3257 + if (flags & EXT4_IMMUTABLE_FL)
3258 + inode->i_flags |= S_IMMUTABLE;
3259 + if (flags & EXT4_IXUNLINK_FL)
3260 + inode->i_flags |= S_IXUNLINK;
3262 if (flags & EXT4_SYNC_FL)
3263 inode->i_flags |= S_SYNC;
3264 if (flags & EXT4_APPEND_FL)
3265 inode->i_flags |= S_APPEND;
3266 - if (flags & EXT4_IMMUTABLE_FL)
3267 - inode->i_flags |= S_IMMUTABLE;
3268 if (flags & EXT4_NOATIME_FL)
3269 inode->i_flags |= S_NOATIME;
3270 if (flags & EXT4_DIRSYNC_FL)
3271 inode->i_flags |= S_DIRSYNC;
3273 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3275 + if (flags & EXT4_BARRIER_FL)
3276 + inode->i_vflags |= V_BARRIER;
3277 + if (flags & EXT4_COW_FL)
3278 + inode->i_vflags |= V_COW;
3281 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3282 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3284 unsigned int flags = ei->vfs_inode.i_flags;
3285 + unsigned int vflags = ei->vfs_inode.i_vflags;
3287 + ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3288 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3289 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3290 + EXT4_BARRIER_FL | EXT4_COW_FL);
3292 + if (flags & S_IMMUTABLE)
3293 + ei->i_flags |= EXT4_IMMUTABLE_FL;
3294 + if (flags & S_IXUNLINK)
3295 + ei->i_flags |= EXT4_IXUNLINK_FL;
3297 - ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3298 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
3300 ei->i_flags |= EXT4_SYNC_FL;
3301 if (flags & S_APPEND)
3302 ei->i_flags |= EXT4_APPEND_FL;
3303 - if (flags & S_IMMUTABLE)
3304 - ei->i_flags |= EXT4_IMMUTABLE_FL;
3305 if (flags & S_NOATIME)
3306 ei->i_flags |= EXT4_NOATIME_FL;
3307 if (flags & S_DIRSYNC)
3308 ei->i_flags |= EXT4_DIRSYNC_FL;
3310 + if (vflags & V_BARRIER)
3311 + ei->i_flags |= EXT4_BARRIER_FL;
3312 + if (vflags & V_COW)
3313 + ei->i_flags |= EXT4_COW_FL;
3316 +int ext4_sync_flags(struct inode *inode)
3318 + struct ext4_iloc iloc;
3322 + handle = ext4_journal_start(inode, 1);
3323 + if (IS_ERR(handle))
3324 + return PTR_ERR(handle);
3325 + if (IS_SYNC(inode))
3326 + handle->h_sync = 1;
3327 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3331 + ext4_get_inode_flags(EXT4_I(inode));
3332 + inode->i_ctime = CURRENT_TIME;
3334 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3336 + ext4_journal_stop(handle);
3340 static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
3341 struct ext4_inode_info *ei)
3343 @@ -4197,6 +4247,8 @@ struct inode *ext4_iget(struct super_blo
3344 struct inode *inode;
3350 inode = iget_locked(sb, ino);
3352 @@ -4216,12 +4268,16 @@ struct inode *ext4_iget(struct super_blo
3354 raw_inode = ext4_raw_inode(&iloc);
3355 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3356 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3357 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3358 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3359 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3360 if (!(test_opt(inode->i_sb, NO_UID32))) {
3361 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3362 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3363 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3364 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3366 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3367 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3368 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3369 + le16_to_cpu(raw_inode->i_raw_tag));
3370 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3373 @@ -4387,6 +4443,8 @@ static int ext4_do_update_inode(handle_t
3374 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3375 struct ext4_inode_info *ei = EXT4_I(inode);
3376 struct buffer_head *bh = iloc->bh;
3377 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3378 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3379 int err = 0, rc, block;
3381 /* For fields not not tracking in the in-memory inode,
3382 @@ -4397,29 +4455,32 @@ static int ext4_do_update_inode(handle_t
3383 ext4_get_inode_flags(ei);
3384 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3385 if (!(test_opt(inode->i_sb, NO_UID32))) {
3386 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3387 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3388 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3389 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3391 * Fix up interoperability with old kernels. Otherwise, old inodes get
3392 * re-used with the upper 16 bits of the uid/gid intact
3395 raw_inode->i_uid_high =
3396 - cpu_to_le16(high_16_bits(inode->i_uid));
3397 + cpu_to_le16(high_16_bits(uid));
3398 raw_inode->i_gid_high =
3399 - cpu_to_le16(high_16_bits(inode->i_gid));
3400 + cpu_to_le16(high_16_bits(gid));
3402 raw_inode->i_uid_high = 0;
3403 raw_inode->i_gid_high = 0;
3406 raw_inode->i_uid_low =
3407 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3408 + cpu_to_le16(fs_high2lowuid(uid));
3409 raw_inode->i_gid_low =
3410 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3411 + cpu_to_le16(fs_high2lowgid(gid));
3412 raw_inode->i_uid_high = 0;
3413 raw_inode->i_gid_high = 0;
3415 +#ifdef CONFIG_TAGGING_INTERN
3416 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3418 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3420 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3421 @@ -4601,7 +4662,8 @@ int ext4_setattr(struct dentry *dentry,
3424 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3425 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3426 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3427 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3430 /* (user+group)*(old+new) structure, inode write (sb,
3431 @@ -4623,6 +4685,8 @@ int ext4_setattr(struct dentry *dentry,
3432 inode->i_uid = attr->ia_uid;
3433 if (attr->ia_valid & ATTR_GID)
3434 inode->i_gid = attr->ia_gid;
3435 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3436 + inode->i_tag = attr->ia_tag;
3437 error = ext4_mark_inode_dirty(handle, inode);
3438 ext4_journal_stop(handle);
3440 diff -NurpP --minimal linux-2.6.29/fs/ext4/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/ioctl.c
3441 --- linux-2.6.29/fs/ext4/ioctl.c 2009-03-24 14:22:25.000000000 +0100
3442 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/ioctl.c 2009-03-24 14:48:35.000000000 +0100
3446 #include <linux/fs.h>
3447 +#include <linux/mount.h>
3448 #include <linux/jbd2.h>
3449 #include <linux/capability.h>
3450 #include <linux/time.h>
3451 #include <linux/compat.h>
3452 #include <linux/smp_lock.h>
3453 #include <linux/mount.h>
3454 +#include <linux/vs_tag.h>
3455 #include <asm/uaccess.h>
3456 #include "ext4_jbd2.h"
3458 @@ -51,6 +53,11 @@ long ext4_ioctl(struct file *filp, unsig
3459 if (!S_ISDIR(inode->i_mode))
3460 flags &= ~EXT4_DIRSYNC_FL;
3462 + if (IS_BARRIER(inode)) {
3463 + vxwprintk_task(1, "messing with the barrier.");
3468 mutex_lock(&inode->i_mutex);
3469 /* Is it quota file? Do not allow user to mess with it */
3470 @@ -68,7 +75,9 @@ long ext4_ioctl(struct file *filp, unsig
3472 * This test looks nicer. Thanks to Pauline Middelink
3474 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3475 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3476 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3477 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3478 if (!capable(CAP_LINUX_IMMUTABLE))
3481 diff -NurpP --minimal linux-2.6.29/fs/ext4/namei.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/namei.c
3482 --- linux-2.6.29/fs/ext4/namei.c 2009-03-24 14:22:25.000000000 +0100
3483 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/namei.c 2009-03-24 14:48:35.000000000 +0100
3485 #include <linux/quotaops.h>
3486 #include <linux/buffer_head.h>
3487 #include <linux/bio.h>
3488 +#include <linux/vs_tag.h>
3490 #include "ext4_jbd2.h"
3492 @@ -917,6 +918,7 @@ restart:
3494 ll_rw_block(READ_META, 1, &bh);
3496 + dx_propagate_tag(nd, inode);
3498 if ((bh = bh_use[ra_ptr++]) == NULL)
3500 @@ -2481,6 +2483,7 @@ const struct inode_operations ext4_dir_i
3501 .removexattr = generic_removexattr,
3503 .permission = ext4_permission,
3504 + .sync_flags = ext4_sync_flags,
3507 const struct inode_operations ext4_special_inode_operations = {
3508 @@ -2492,4 +2495,5 @@ const struct inode_operations ext4_speci
3509 .removexattr = generic_removexattr,
3511 .permission = ext4_permission,
3512 + .sync_flags = ext4_sync_flags,
3514 diff -NurpP --minimal linux-2.6.29/fs/ext4/super.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/super.c
3515 --- linux-2.6.29/fs/ext4/super.c 2009-03-24 14:22:25.000000000 +0100
3516 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/super.c 2009-03-24 15:46:48.000000000 +0100
3517 @@ -1013,7 +1013,8 @@ enum {
3518 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3519 Opt_grpquota, Opt_i_version,
3520 Opt_stripe, Opt_delalloc, Opt_nodelalloc,
3521 - Opt_inode_readahead_blks, Opt_journal_ioprio
3522 + Opt_inode_readahead_blks, Opt_journal_ioprio,
3523 + Opt_tag, Opt_notag, Opt_tagid
3526 static const match_table_t tokens = {
3527 @@ -1073,6 +1074,9 @@ static const match_table_t tokens = {
3528 {Opt_nodelalloc, "nodelalloc"},
3529 {Opt_inode_readahead_blks, "inode_readahead_blks=%u"},
3530 {Opt_journal_ioprio, "journal_ioprio=%u"},
3532 + {Opt_notag, "notag"},
3533 + {Opt_tagid, "tagid=%u"},
3537 @@ -1168,6 +1172,20 @@ static int parse_options(char *options,
3539 set_opt(sbi->s_mount_opt, NO_UID32);
3541 +#ifndef CONFIG_TAGGING_NONE
3543 + set_opt (sbi->s_mount_opt, TAGGED);
3546 + clear_opt (sbi->s_mount_opt, TAGGED);
3549 +#ifdef CONFIG_PROPAGATE
3552 + set_opt (sbi->s_mount_opt, TAGGED);
3556 set_opt(sbi->s_mount_opt, DEBUG);
3558 @@ -2113,6 +2131,9 @@ static int ext4_fill_super(struct super_
3559 &journal_ioprio, NULL, 0))
3562 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3563 + sb->s_flags |= MS_TAGGED;
3565 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3566 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3568 @@ -3160,6 +3181,13 @@ static int ext4_remount(struct super_blo
3569 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
3570 ext4_abort(sb, __func__, "Abort forced by user");
3572 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3573 + !(sb->s_flags & MS_TAGGED)) {
3574 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3579 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3580 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3582 diff -NurpP --minimal linux-2.6.29/fs/ext4/symlink.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/symlink.c
3583 --- linux-2.6.29/fs/ext4/symlink.c 2008-12-25 00:26:37.000000000 +0100
3584 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/symlink.c 2009-02-22 22:54:25.000000000 +0100
3585 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
3586 .listxattr = ext4_listxattr,
3587 .removexattr = generic_removexattr,
3589 + .sync_flags = ext4_sync_flags,
3592 const struct inode_operations ext4_fast_symlink_inode_operations = {
3593 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
3594 .listxattr = ext4_listxattr,
3595 .removexattr = generic_removexattr,
3597 + .sync_flags = ext4_sync_flags,
3599 diff -NurpP --minimal linux-2.6.29/fs/ext4/xattr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/xattr.c
3600 --- linux-2.6.29/fs/ext4/xattr.c 2009-03-24 14:22:25.000000000 +0100
3601 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ext4/xattr.c 2009-03-24 15:47:44.000000000 +0100
3603 #include <linux/mbcache.h>
3604 #include <linux/quotaops.h>
3605 #include <linux/rwsem.h>
3606 +#include <linux/vs_dlimit.h>
3607 #include "ext4_jbd2.h"
3610 @@ -490,6 +491,7 @@ ext4_xattr_release_block(handle_t *handl
3611 error = ext4_handle_dirty_metadata(handle, inode, bh);
3613 ext4_handle_sync(handle);
3614 + DLIMIT_FREE_BLOCK(inode, 1);
3615 DQUOT_FREE_BLOCK(inode, 1);
3616 ea_bdebug(bh, "refcount now=%d; releasing",
3617 le32_to_cpu(BHDR(bh)->h_refcount));
3618 @@ -781,11 +783,14 @@ inserted:
3619 if (new_bh == bs->bh)
3620 ea_bdebug(new_bh, "keeping");
3623 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3625 /* The old block is released after updating
3628 if (DQUOT_ALLOC_BLOCK(inode, 1))
3630 + goto cleanup_dlimit;
3631 error = ext4_journal_get_write_access(handle,
3634 @@ -861,6 +866,8 @@ cleanup:
3637 DQUOT_FREE_BLOCK(inode, 1);
3639 + DLIMIT_FREE_BLOCK(inode, 1);
3643 diff -NurpP --minimal linux-2.6.29/fs/fcntl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/fcntl.c
3644 --- linux-2.6.29/fs/fcntl.c 2009-03-24 14:22:25.000000000 +0100
3645 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/fcntl.c 2009-03-24 14:48:35.000000000 +0100
3647 #include <linux/rcupdate.h>
3648 #include <linux/pid_namespace.h>
3649 #include <linux/smp_lock.h>
3650 +#include <linux/vs_limit.h>
3652 #include <asm/poll.h>
3653 #include <asm/siginfo.h>
3654 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3657 filp_close(tofree, files);
3659 + vx_openfd_inc(newfd); /* fd was unused */
3663 @@ -343,6 +346,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3667 + if (!vx_files_avail(1))
3670 err = security_file_fcntl(filp, cmd, arg);
3672 diff -NurpP --minimal linux-2.6.29/fs/file.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/file.c
3673 --- linux-2.6.29/fs/file.c 2008-12-25 00:26:37.000000000 +0100
3674 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/file.c 2009-02-22 22:54:25.000000000 +0100
3676 #include <linux/spinlock.h>
3677 #include <linux/rcupdate.h>
3678 #include <linux/workqueue.h>
3679 +#include <linux/vs_limit.h>
3681 struct fdtable_defer {
3683 @@ -367,6 +368,8 @@ struct files_struct *dup_fd(struct files
3684 struct file *f = *old_fds++;
3687 + /* TODO: sum it first for check and performance */
3688 + vx_openfd_inc(open_files - i);
3691 * The fd may be claimed in the fd bitmap but not yet
3692 @@ -475,6 +478,7 @@ repeat:
3694 FD_CLR(fd, fdt->close_on_exec);
3696 + vx_openfd_inc(fd);
3699 if (rcu_dereference(fdt->fd[fd]) != NULL) {
3700 diff -NurpP --minimal linux-2.6.29/fs/file_table.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/file_table.c
3701 --- linux-2.6.29/fs/file_table.c 2009-03-24 14:22:25.000000000 +0100
3702 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/file_table.c 2009-03-24 14:48:35.000000000 +0100
3704 #include <linux/fsnotify.h>
3705 #include <linux/sysctl.h>
3706 #include <linux/percpu_counter.h>
3707 +#include <linux/vs_limit.h>
3708 +#include <linux/vs_context.h>
3710 #include <asm/atomic.h>
3712 @@ -129,6 +131,8 @@ struct file *get_empty_filp(void)
3713 f->f_cred = get_cred(cred);
3714 eventpoll_init_file(f);
3715 /* f->f_version: 0 */
3716 + f->f_xid = vx_current_xid();
3721 @@ -283,6 +287,8 @@ void __fput(struct file *file)
3722 cdev_put(inode->i_cdev);
3723 fops_put(file->f_op);
3724 put_pid(file->f_owner.pid);
3725 + vx_files_dec(file);
3728 if (file->f_mode & FMODE_WRITE)
3729 drop_file_write_access(file);
3730 @@ -350,6 +356,8 @@ void put_filp(struct file *file)
3732 if (atomic_long_dec_and_test(&file->f_count)) {
3733 security_file_free(file);
3734 + vx_files_dec(file);
3739 diff -NurpP --minimal linux-2.6.29/fs/hfsplus/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/hfsplus/ioctl.c
3740 --- linux-2.6.29/fs/hfsplus/ioctl.c 2008-12-25 00:26:37.000000000 +0100
3741 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/hfsplus/ioctl.c 2009-02-22 22:54:25.000000000 +0100
3743 #include <linux/mount.h>
3744 #include <linux/sched.h>
3745 #include <linux/xattr.h>
3746 +#include <linux/mount.h>
3747 #include <asm/uaccess.h>
3748 #include "hfsplus_fs.h"
3750 diff -NurpP --minimal linux-2.6.29/fs/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/inode.c
3751 --- linux-2.6.29/fs/inode.c 2009-03-24 14:22:26.000000000 +0100
3752 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/inode.c 2009-03-25 00:51:55.000000000 +0100
3753 @@ -126,6 +126,9 @@ struct inode *inode_init_always(struct s
3754 struct address_space * const mapping = &inode->i_data;
3758 + /* essential because of inode slab reuse */
3760 inode->i_blkbits = sb->s_blocksize_bits;
3762 atomic_set(&inode->i_count, 1);
3763 @@ -146,6 +149,7 @@ struct inode *inode_init_always(struct s
3764 inode->i_bdev = NULL;
3765 inode->i_cdev = NULL;
3767 + inode->i_mdev = 0;
3768 inode->dirtied_when = 0;
3769 if (security_inode_alloc(inode)) {
3770 if (inode->i_sb->s_op->destroy_inode)
3771 @@ -267,6 +271,8 @@ void __iget(struct inode * inode)
3772 inodes_stat.nr_unused--;
3775 +EXPORT_SYMBOL_GPL(__iget);
3778 * clear_inode - clear an inode
3779 * @inode: inode to clear
3780 @@ -1539,9 +1545,11 @@ void init_special_inode(struct inode *in
3781 if (S_ISCHR(mode)) {
3782 inode->i_fop = &def_chr_fops;
3783 inode->i_rdev = rdev;
3784 + inode->i_mdev = rdev;
3785 } else if (S_ISBLK(mode)) {
3786 inode->i_fop = &def_blk_fops;
3787 inode->i_rdev = rdev;
3788 + inode->i_mdev = rdev;
3789 } else if (S_ISFIFO(mode))
3790 inode->i_fop = &def_fifo_fops;
3791 else if (S_ISSOCK(mode))
3792 diff -NurpP --minimal linux-2.6.29/fs/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ioctl.c
3793 --- linux-2.6.29/fs/ioctl.c 2009-03-24 14:22:26.000000000 +0100
3794 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ioctl.c 2009-03-24 14:48:35.000000000 +0100
3796 #include <linux/uaccess.h>
3797 #include <linux/writeback.h>
3798 #include <linux/buffer_head.h>
3799 +#include <linux/proc_fs.h>
3800 +#include <linux/vserver/inode.h>
3801 +#include <linux/vs_tag.h>
3803 #include <asm/ioctls.h>
3805 diff -NurpP --minimal linux-2.6.29/fs/ioprio.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ioprio.c
3806 --- linux-2.6.29/fs/ioprio.c 2009-03-24 14:22:26.000000000 +0100
3807 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ioprio.c 2009-03-24 14:48:35.000000000 +0100
3809 #include <linux/syscalls.h>
3810 #include <linux/security.h>
3811 #include <linux/pid_namespace.h>
3812 +#include <linux/vs_base.h>
3814 int set_task_ioprio(struct task_struct *task, int ioprio)
3816 @@ -123,6 +124,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3818 pgrp = find_vpid(who);
3819 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3820 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3822 ret = set_task_ioprio(p, ioprio);
3825 @@ -212,6 +215,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3827 pgrp = find_vpid(who);
3828 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3829 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3831 tmpio = get_task_ioprio(p);
3834 diff -NurpP --minimal linux-2.6.29/fs/jfs/acl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/acl.c
3835 --- linux-2.6.29/fs/jfs/acl.c 2008-12-25 00:26:37.000000000 +0100
3836 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/acl.c 2009-02-22 22:54:25.000000000 +0100
3837 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
3840 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3841 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3842 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3843 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3844 if (DQUOT_TRANSFER(inode, iattr))
3847 diff -NurpP --minimal linux-2.6.29/fs/jfs/file.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/file.c
3848 --- linux-2.6.29/fs/jfs/file.c 2008-12-25 00:26:37.000000000 +0100
3849 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/file.c 2009-02-22 22:54:25.000000000 +0100
3850 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
3851 .setattr = jfs_setattr,
3852 .permission = jfs_permission,
3854 + .sync_flags = jfs_sync_flags,
3857 const struct file_operations jfs_file_operations = {
3858 diff -NurpP --minimal linux-2.6.29/fs/jfs/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/inode.c
3859 --- linux-2.6.29/fs/jfs/inode.c 2009-03-24 14:22:26.000000000 +0100
3860 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/inode.c 2009-03-24 14:48:35.000000000 +0100
3862 #include <linux/buffer_head.h>
3863 #include <linux/pagemap.h>
3864 #include <linux/quotaops.h>
3865 +#include <linux/vs_dlimit.h>
3866 #include "jfs_incore.h"
3867 #include "jfs_inode.h"
3868 #include "jfs_filsys.h"
3869 @@ -161,6 +162,7 @@ void jfs_delete_inode(struct inode *inod
3871 DQUOT_FREE_INODE(inode);
3873 + DLIMIT_FREE_INODE(inode);
3877 diff -NurpP --minimal linux-2.6.29/fs/jfs/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/ioctl.c
3878 --- linux-2.6.29/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
3879 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/ioctl.c 2009-02-22 22:54:25.000000000 +0100
3881 #include <linux/mount.h>
3882 #include <linux/time.h>
3883 #include <linux/sched.h>
3884 +#include <linux/mount.h>
3885 #include <asm/current.h>
3886 #include <asm/uaccess.h>
3888 @@ -85,6 +86,11 @@ long jfs_ioctl(struct file *filp, unsign
3889 if (!S_ISDIR(inode->i_mode))
3890 flags &= ~JFS_DIRSYNC_FL;
3892 + if (IS_BARRIER(inode)) {
3893 + vxwprintk_task(1, "messing with the barrier.");
3897 /* Is it quota file? Do not allow user to mess with it */
3898 if (IS_NOQUOTA(inode)) {
3900 @@ -102,8 +108,8 @@ long jfs_ioctl(struct file *filp, unsign
3901 * the relevant capability.
3903 if ((oldflags & JFS_IMMUTABLE_FL) ||
3904 - ((flags ^ oldflags) &
3905 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3906 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3907 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3908 if (!capable(CAP_LINUX_IMMUTABLE)) {
3909 mutex_unlock(&inode->i_mutex);
3911 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_dinode.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_dinode.h
3912 --- linux-2.6.29/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3913 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_dinode.h 2009-02-22 22:54:25.000000000 +0100
3914 @@ -161,9 +161,13 @@ struct dinode {
3916 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3917 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3918 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3920 -#define JFS_FL_USER_VISIBLE 0x03F80000
3921 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3922 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3923 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3925 +#define JFS_FL_USER_VISIBLE 0x07F80000
3926 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3927 #define JFS_FL_INHERIT 0x03C80000
3929 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3930 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_dtree.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_dtree.c
3931 --- linux-2.6.29/fs/jfs/jfs_dtree.c 2008-12-25 00:26:37.000000000 +0100
3932 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_dtree.c 2009-02-22 22:54:25.000000000 +0100
3935 #include <linux/fs.h>
3936 #include <linux/quotaops.h>
3937 +#include <linux/vs_dlimit.h>
3938 #include "jfs_incore.h"
3939 #include "jfs_superblock.h"
3940 #include "jfs_filsys.h"
3941 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
3943 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
3945 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
3946 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
3949 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
3950 + goto clean_up_dquot;
3951 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
3952 + goto clean_up_dlimit;
3955 * Save the table, we're going to overwrite it with the
3956 @@ -480,6 +481,12 @@ static u32 add_index(tid_t tid, struct i
3961 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
3964 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
3968 jfs_ip->next_index--;
3969 @@ -951,6 +958,7 @@ static int dtSplitUp(tid_t tid,
3972 int quota_allocation = 0;
3973 + int dlimit_allocation = 0;
3975 /* get split page */
3977 @@ -1033,6 +1041,12 @@ static int dtSplitUp(tid_t tid,
3979 quota_allocation += n;
3981 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
3985 + dlimit_allocation += n;
3987 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
3990 @@ -1306,6 +1320,9 @@ static int dtSplitUp(tid_t tid,
3994 + /* Rollback dlimit allocation */
3995 + if (rc && dlimit_allocation)
3996 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
3997 /* Rollback quota allocation */
3998 if (rc && quota_allocation)
3999 DQUOT_FREE_BLOCK(ip, quota_allocation);
4000 @@ -1373,6 +1390,12 @@ static int dtSplitPage(tid_t tid, struct
4001 release_metapage(rmp);
4004 + /* Allocate blocks to dlimit. */
4005 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4006 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4007 + release_metapage(rmp);
4011 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
4013 @@ -1920,6 +1943,12 @@ static int dtSplitRoot(tid_t tid,
4014 release_metapage(rmp);
4017 + /* Allocate blocks to dlimit. */
4018 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4019 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4020 + release_metapage(rmp);
4024 BT_MARK_DIRTY(rmp, ip);
4026 @@ -2286,6 +2315,8 @@ static int dtDeleteUp(tid_t tid, struct
4028 xlen = lengthPXD(&fp->header.self);
4030 + /* Free dlimit allocation. */
4031 + DLIMIT_FREE_BLOCK(ip, xlen);
4032 /* Free quota allocation. */
4033 DQUOT_FREE_BLOCK(ip, xlen);
4035 @@ -2362,6 +2393,8 @@ static int dtDeleteUp(tid_t tid, struct
4037 xlen = lengthPXD(&p->header.self);
4039 + /* Free dlimit allocation */
4040 + DLIMIT_FREE_BLOCK(ip, xlen);
4041 /* Free quota allocation */
4042 DQUOT_FREE_BLOCK(ip, xlen);
4044 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_extent.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_extent.c
4045 --- linux-2.6.29/fs/jfs/jfs_extent.c 2008-12-25 00:26:37.000000000 +0100
4046 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_extent.c 2009-02-22 22:54:25.000000000 +0100
4049 #include <linux/fs.h>
4050 #include <linux/quotaops.h>
4051 +#include <linux/vs_dlimit.h>
4052 #include "jfs_incore.h"
4053 #include "jfs_inode.h"
4054 #include "jfs_superblock.h"
4055 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
4059 + /* Allocate blocks to dlimit. */
4060 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4061 + DQUOT_FREE_BLOCK(ip, nxlen);
4062 + dbFree(ip, nxaddr, (s64) nxlen);
4063 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
4067 /* determine the value of the extent flag */
4068 xflag = abnr ? XAD_NOTRECORDED : 0;
4070 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
4073 dbFree(ip, nxaddr, nxlen);
4074 + DLIMIT_FREE_BLOCK(ip, nxlen);
4075 DQUOT_FREE_BLOCK(ip, nxlen);
4076 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4078 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
4079 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4082 + /* Allocate blocks to dlimit. */
4083 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4084 + DQUOT_FREE_BLOCK(ip, nxlen);
4085 + dbFree(ip, nxaddr, (s64) nxlen);
4086 + up(&JFS_IP(ip)->commit_sem);
4090 delta = nxlen - xlen;
4092 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
4093 /* extend the extent */
4094 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
4095 dbFree(ip, xaddr + xlen, delta);
4096 + DLIMIT_FREE_BLOCK(ip, nxlen);
4097 DQUOT_FREE_BLOCK(ip, nxlen);
4100 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
4102 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
4103 dbFree(ip, nxaddr, nxlen);
4104 + DLIMIT_FREE_BLOCK(ip, nxlen);
4105 DQUOT_FREE_BLOCK(ip, nxlen);
4108 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_filsys.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_filsys.h
4109 --- linux-2.6.29/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4110 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_filsys.h 2009-02-22 22:54:25.000000000 +0100
4112 #define JFS_NAME_MAX 255
4113 #define JFS_PATH_MAX BPSIZE
4115 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4118 * file system state (superblock state)
4119 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_imap.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_imap.c
4120 --- linux-2.6.29/fs/jfs/jfs_imap.c 2009-03-24 14:22:26.000000000 +0100
4121 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_imap.c 2009-03-24 14:48:35.000000000 +0100
4123 #include <linux/buffer_head.h>
4124 #include <linux/pagemap.h>
4125 #include <linux/quotaops.h>
4126 +#include <linux/vs_tag.h>
4128 #include "jfs_incore.h"
4129 #include "jfs_inode.h"
4130 @@ -3062,6 +3063,8 @@ static int copy_from_dinode(struct dinod
4132 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4133 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4137 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4138 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4139 @@ -3082,14 +3085,18 @@ static int copy_from_dinode(struct dinod
4141 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4143 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4144 + uid = le32_to_cpu(dip->di_uid);
4145 + gid = le32_to_cpu(dip->di_gid);
4146 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4148 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4150 ip->i_uid = jfs_ip->saved_uid;
4152 ip->i_uid = sbi->uid;
4155 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4156 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4158 ip->i_gid = jfs_ip->saved_gid;
4160 @@ -3154,14 +3161,12 @@ static void copy_to_dinode(struct dinode
4161 dip->di_size = cpu_to_le64(ip->i_size);
4162 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4163 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4164 - if (sbi->uid == -1)
4165 - dip->di_uid = cpu_to_le32(ip->i_uid);
4167 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4168 - if (sbi->gid == -1)
4169 - dip->di_gid = cpu_to_le32(ip->i_gid);
4171 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4173 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4174 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4175 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4176 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4178 jfs_get_inode_flags(jfs_ip);
4180 * mode2 is only needed for storing the higher order bits.
4181 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_inode.c
4182 --- linux-2.6.29/fs/jfs/jfs_inode.c 2009-03-24 14:22:26.000000000 +0100
4183 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_inode.c 2009-03-24 15:58:01.000000000 +0100
4186 #include <linux/fs.h>
4187 #include <linux/quotaops.h>
4188 +#include <linux/vs_dlimit.h>
4189 +#include <linux/vs_tag.h>
4190 #include "jfs_incore.h"
4191 #include "jfs_inode.h"
4192 #include "jfs_filsys.h"
4193 @@ -30,29 +32,46 @@ void jfs_set_inode_flags(struct inode *i
4195 unsigned int flags = JFS_IP(inode)->mode2;
4197 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4198 - S_NOATIME | S_DIRSYNC | S_SYNC);
4199 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4200 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4202 if (flags & JFS_IMMUTABLE_FL)
4203 inode->i_flags |= S_IMMUTABLE;
4204 + if (flags & JFS_IXUNLINK_FL)
4205 + inode->i_flags |= S_IXUNLINK;
4207 + if (flags & JFS_SYNC_FL)
4208 + inode->i_flags |= S_SYNC;
4209 if (flags & JFS_APPEND_FL)
4210 inode->i_flags |= S_APPEND;
4211 if (flags & JFS_NOATIME_FL)
4212 inode->i_flags |= S_NOATIME;
4213 if (flags & JFS_DIRSYNC_FL)
4214 inode->i_flags |= S_DIRSYNC;
4215 - if (flags & JFS_SYNC_FL)
4216 - inode->i_flags |= S_SYNC;
4218 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4220 + if (flags & JFS_BARRIER_FL)
4221 + inode->i_vflags |= V_BARRIER;
4222 + if (flags & JFS_COW_FL)
4223 + inode->i_vflags |= V_COW;
4226 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4228 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4229 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4231 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4232 + JFS_APPEND_FL | JFS_NOATIME_FL |
4233 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4234 + JFS_BARRIER_FL | JFS_COW_FL);
4236 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4237 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4238 if (flags & S_IMMUTABLE)
4239 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4240 + if (flags & S_IXUNLINK)
4241 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4243 if (flags & S_APPEND)
4244 jfs_ip->mode2 |= JFS_APPEND_FL;
4245 if (flags & S_NOATIME)
4246 @@ -61,6 +80,19 @@ void jfs_get_inode_flags(struct jfs_inod
4247 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4249 jfs_ip->mode2 |= JFS_SYNC_FL;
4251 + if (vflags & V_BARRIER)
4252 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4253 + if (vflags & V_COW)
4254 + jfs_ip->mode2 |= JFS_COW_FL;
4257 +int jfs_sync_flags(struct inode *inode)
4259 + jfs_get_inode_flags(JFS_IP(inode));
4260 + inode->i_ctime = CURRENT_TIME;
4261 + mark_inode_dirty(inode);
4266 @@ -113,6 +145,12 @@ struct inode *ialloc(struct inode *paren
4267 jfs_inode->saved_uid = inode->i_uid;
4268 jfs_inode->saved_gid = inode->i_gid;
4270 + inode->i_tag = dx_current_fstag(sb);
4271 + if (DLIMIT_ALLOC_INODE(inode)) {
4277 * Allocate inode to quota.
4279 @@ -162,6 +200,8 @@ struct inode *ialloc(struct inode *paren
4283 + DLIMIT_FREE_INODE(inode);
4286 inode->i_flags |= S_NOQUOTA;
4288 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_inode.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_inode.h
4289 --- linux-2.6.29/fs/jfs/jfs_inode.h 2008-12-25 00:26:37.000000000 +0100
4290 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_inode.h 2009-02-22 22:54:25.000000000 +0100
4291 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4292 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4293 int fh_len, int fh_type);
4294 extern void jfs_set_inode_flags(struct inode *);
4295 +extern int jfs_sync_flags(struct inode *);
4296 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4298 extern const struct address_space_operations jfs_aops;
4299 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_xtree.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_xtree.c
4300 --- linux-2.6.29/fs/jfs/jfs_xtree.c 2008-12-25 00:26:37.000000000 +0100
4301 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/jfs_xtree.c 2009-02-22 22:54:25.000000000 +0100
4303 #include <linux/module.h>
4304 #include <linux/quotaops.h>
4305 #include <linux/seq_file.h>
4306 +#include <linux/vs_dlimit.h>
4307 #include "jfs_incore.h"
4308 #include "jfs_filsys.h"
4309 #include "jfs_metapage.h"
4310 @@ -848,7 +849,12 @@ int xtInsert(tid_t tid, /* transaction
4312 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
4314 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
4315 + DQUOT_FREE_BLOCK(ip, xlen);
4318 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
4319 + DLIMIT_FREE_BLOCK(ip, xlen);
4320 DQUOT_FREE_BLOCK(ip, xlen);
4323 @@ -878,6 +884,7 @@ int xtInsert(tid_t tid, /* transaction
4324 /* undo data extent allocation */
4326 dbFree(ip, xaddr, (s64) xlen);
4327 + DLIMIT_FREE_BLOCK(ip, xlen);
4328 DQUOT_FREE_BLOCK(ip, xlen);
4331 @@ -1234,6 +1241,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
4333 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
4334 int quota_allocation = 0;
4335 + int dlimit_allocation = 0;
4338 sp = XT_PAGE(ip, smp);
4339 @@ -1253,6 +1261,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
4341 quota_allocation += lengthPXD(pxd);
4343 + /* Allocate blocks to dlimit. */
4344 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4348 + dlimit_allocation += lengthPXD(pxd);
4351 * allocate the new right page for the split
4353 @@ -1454,6 +1469,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
4357 + /* Rollback dlimit allocation. */
4358 + if (dlimit_allocation)
4359 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
4360 /* Rollback quota allocation. */
4361 if (quota_allocation)
4362 DQUOT_FREE_BLOCK(ip, quota_allocation);
4363 @@ -1517,6 +1535,12 @@ xtSplitRoot(tid_t tid,
4364 release_metapage(rmp);
4367 + /* Allocate blocks to dlimit. */
4368 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4369 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4370 + release_metapage(rmp);
4374 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
4376 @@ -3940,6 +3964,8 @@ s64 xtTruncate(tid_t tid, struct inode *
4378 ip->i_size = newsize;
4380 + /* update dlimit allocation to reflect freed blocks */
4381 + DLIMIT_FREE_BLOCK(ip, nfreed);
4382 /* update quota allocation to reflect freed blocks */
4383 DQUOT_FREE_BLOCK(ip, nfreed);
4385 diff -NurpP --minimal linux-2.6.29/fs/jfs/namei.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/namei.c
4386 --- linux-2.6.29/fs/jfs/namei.c 2009-03-24 14:22:26.000000000 +0100
4387 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/namei.c 2009-03-24 14:48:35.000000000 +0100
4389 #include <linux/ctype.h>
4390 #include <linux/quotaops.h>
4391 #include <linux/exportfs.h>
4392 +#include <linux/vs_tag.h>
4393 #include "jfs_incore.h"
4394 #include "jfs_superblock.h"
4395 #include "jfs_inode.h"
4396 @@ -1476,6 +1477,7 @@ static struct dentry *jfs_lookup(struct
4397 return ERR_CAST(ip);
4400 + dx_propagate_tag(nd, ip);
4401 dentry = d_splice_alias(ip, dentry);
4403 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4404 @@ -1545,6 +1547,7 @@ const struct inode_operations jfs_dir_in
4405 .setattr = jfs_setattr,
4406 .permission = jfs_permission,
4408 + .sync_flags = jfs_sync_flags,
4411 const struct file_operations jfs_dir_operations = {
4412 diff -NurpP --minimal linux-2.6.29/fs/jfs/super.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/super.c
4413 --- linux-2.6.29/fs/jfs/super.c 2009-03-24 14:22:26.000000000 +0100
4414 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/super.c 2009-03-24 14:48:35.000000000 +0100
4415 @@ -196,7 +196,8 @@ static void jfs_put_super(struct super_b
4417 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4418 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4419 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4420 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4421 + Opt_tag, Opt_notag, Opt_tagid
4424 static const match_table_t tokens = {
4425 @@ -206,6 +207,10 @@ static const match_table_t tokens = {
4426 {Opt_resize, "resize=%u"},
4427 {Opt_resize_nosize, "resize"},
4428 {Opt_errors, "errors=%s"},
4430 + {Opt_notag, "notag"},
4431 + {Opt_tagid, "tagid=%u"},
4432 + {Opt_tag, "tagxid"},
4433 {Opt_ignore, "noquota"},
4434 {Opt_ignore, "quota"},
4435 {Opt_usrquota, "usrquota"},
4436 @@ -340,6 +345,20 @@ static int parse_options(char *options,
4440 +#ifndef CONFIG_TAGGING_NONE
4442 + *flag |= JFS_TAGGED;
4445 + *flag &= JFS_TAGGED;
4448 +#ifdef CONFIG_PROPAGATE
4451 + *flag |= JFS_TAGGED;
4455 printk("jfs: Unrecognized mount option \"%s\" "
4456 " or missing value\n", p);
4457 @@ -370,6 +389,13 @@ static int jfs_remount(struct super_bloc
4458 if (!parse_options(data, sb, &newLVSize, &flag)) {
4462 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4463 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4469 if (sb->s_flags & MS_RDONLY) {
4471 @@ -441,6 +467,9 @@ static int jfs_fill_super(struct super_b
4472 #ifdef CONFIG_JFS_POSIX_ACL
4473 sb->s_flags |= MS_POSIXACL;
4475 + /* map mount option tagxid */
4476 + if (sbi->flag & JFS_TAGGED)
4477 + sb->s_flags |= MS_TAGGED;
4480 printk(KERN_ERR "resize option for remount only\n");
4481 diff -NurpP --minimal linux-2.6.29/fs/jfs/xattr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/xattr.c
4482 --- linux-2.6.29/fs/jfs/xattr.c 2008-12-25 00:26:37.000000000 +0100
4483 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/jfs/xattr.c 2009-02-22 22:54:25.000000000 +0100
4485 #include <linux/posix_acl_xattr.h>
4486 #include <linux/quotaops.h>
4487 #include <linux/security.h>
4488 +#include <linux/vs_dlimit.h>
4489 #include "jfs_incore.h"
4490 #include "jfs_superblock.h"
4491 #include "jfs_dmap.h"
4492 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
4493 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
4496 + /* Allocate new blocks to dlimit. */
4497 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
4498 + DQUOT_FREE_BLOCK(ip, nblocks);
4502 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
4504 + /*Rollback dlimit allocation. */
4505 + DLIMIT_FREE_BLOCK(ip, nblocks);
4506 /*Rollback quota allocation. */
4507 DQUOT_FREE_BLOCK(ip, nblocks);
4509 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
4512 /* Rollback quota allocation. */
4513 + DLIMIT_FREE_BLOCK(ip, nblocks);
4514 + /* Rollback quota allocation. */
4515 DQUOT_FREE_BLOCK(ip, nblocks);
4517 dbFree(ip, blkno, nblocks);
4518 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
4521 int quota_allocation = 0;
4522 + int dlimit_allocation = 0;
4524 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
4525 if (ji->ea.flag == 0)
4526 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
4528 quota_allocation = blocks_needed;
4530 + /* Allocate new blocks to dlimit. */
4532 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
4534 + dlimit_allocation = blocks_needed;
4536 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
4539 @@ -600,6 +617,9 @@ static int ea_get(struct inode *inode, s
4543 + /* Rollback dlimit allocation */
4544 + if (dlimit_allocation)
4545 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
4546 /* Rollback quota allocation */
4547 if (quota_allocation)
4548 DQUOT_FREE_BLOCK(inode, quota_allocation);
4549 @@ -676,8 +696,10 @@ static int ea_put(tid_t tid, struct inod
4552 /* If old blocks exist, they must be removed from quota allocation. */
4555 + DLIMIT_FREE_BLOCK(inode, old_blocks);
4556 DQUOT_FREE_BLOCK(inode, old_blocks);
4559 inode->i_ctime = CURRENT_TIME;
4561 diff -NurpP --minimal linux-2.6.29/fs/libfs.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/libfs.c
4562 --- linux-2.6.29/fs/libfs.c 2009-03-24 14:22:26.000000000 +0100
4563 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/libfs.c 2009-03-24 14:48:35.000000000 +0100
4564 @@ -125,7 +125,8 @@ static inline unsigned char dt_type(stru
4565 * both impossible due to the lock on directory.
4568 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4569 +static inline int do_dcache_readdir_filter(struct file *filp,
4570 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4572 struct dentry *dentry = filp->f_path.dentry;
4573 struct dentry *cursor = filp->private_data;
4574 @@ -158,6 +159,8 @@ int dcache_readdir(struct file * filp, v
4575 next = list_entry(p, struct dentry, d_u.d_child);
4576 if (d_unhashed(next) || !next->d_inode)
4578 + if (filter && !filter(next))
4581 spin_unlock(&dcache_lock);
4582 if (filldir(dirent, next->d_name.name,
4583 @@ -176,6 +179,18 @@ int dcache_readdir(struct file * filp, v
4587 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4589 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4592 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4593 + int (*filter)(struct dentry *))
4595 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4599 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4602 @@ -796,6 +811,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4603 EXPORT_SYMBOL(dcache_dir_lseek);
4604 EXPORT_SYMBOL(dcache_dir_open);
4605 EXPORT_SYMBOL(dcache_readdir);
4606 +EXPORT_SYMBOL(dcache_readdir_filter);
4607 EXPORT_SYMBOL(generic_read_dir);
4608 EXPORT_SYMBOL(get_sb_pseudo);
4609 EXPORT_SYMBOL(simple_write_begin);
4610 diff -NurpP --minimal linux-2.6.29/fs/locks.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/locks.c
4611 --- linux-2.6.29/fs/locks.c 2009-03-24 14:22:26.000000000 +0100
4612 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/locks.c 2009-03-24 14:48:35.000000000 +0100
4614 #include <linux/time.h>
4615 #include <linux/rcupdate.h>
4616 #include <linux/pid_namespace.h>
4617 +#include <linux/vs_base.h>
4618 +#include <linux/vs_limit.h>
4620 #include <asm/uaccess.h>
4622 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4623 /* Allocate an empty lock structure. */
4624 static struct file_lock *locks_alloc_lock(void)
4626 + if (!vx_locks_avail(1))
4628 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4631 @@ -173,6 +177,7 @@ static void locks_free_lock(struct file_
4632 BUG_ON(!list_empty(&fl->fl_block));
4633 BUG_ON(!list_empty(&fl->fl_link));
4636 locks_release_private(fl);
4637 kmem_cache_free(filelock_cache, fl);
4639 @@ -193,6 +198,7 @@ void locks_init_lock(struct file_lock *f
4640 fl->fl_start = fl->fl_end = 0;
4642 fl->fl_lmops = NULL;
4646 EXPORT_SYMBOL(locks_init_lock);
4647 @@ -247,6 +253,7 @@ void locks_copy_lock(struct file_lock *n
4648 new->fl_file = fl->fl_file;
4649 new->fl_ops = fl->fl_ops;
4650 new->fl_lmops = fl->fl_lmops;
4651 + new->fl_xid = fl->fl_xid;
4653 locks_copy_private(new, fl);
4655 @@ -285,6 +292,11 @@ static int flock_make_lock(struct file *
4656 fl->fl_flags = FL_FLOCK;
4658 fl->fl_end = OFFSET_MAX;
4660 + vxd_assert(filp->f_xid == vx_current_xid(),
4661 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4662 + fl->fl_xid = filp->f_xid;
4667 @@ -450,6 +462,7 @@ static int lease_init(struct file *filp,
4669 fl->fl_owner = current->files;
4670 fl->fl_pid = current->tgid;
4671 + fl->fl_xid = vx_current_xid();
4674 fl->fl_flags = FL_LEASE;
4675 @@ -469,6 +482,11 @@ static struct file_lock *lease_alloc(str
4677 return ERR_PTR(error);
4679 + fl->fl_xid = vx_current_xid();
4681 + vxd_assert(filp->f_xid == fl->fl_xid,
4682 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4684 error = lease_init(filp, type, fl);
4686 locks_free_lock(fl);
4687 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
4691 + new_fl->fl_xid = -1;
4693 for_each_lock(inode, before) {
4694 struct file_lock *fl = *before;
4695 @@ -789,6 +808,7 @@ find_conflict:
4697 locks_copy_lock(new_fl, request);
4698 locks_insert_lock(before, new_fl);
4699 + vx_locks_inc(new_fl);
4703 @@ -799,7 +819,8 @@ out:
4707 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4708 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4709 + struct file_lock *conflock, xid_t xid)
4711 struct file_lock *fl;
4712 struct file_lock *new_fl = NULL;
4713 @@ -809,6 +830,8 @@ static int __posix_lock_file(struct inod
4714 struct file_lock **before;
4715 int error, added = 0;
4717 + vxd_assert(xid == vx_current_xid(),
4718 + "xid(%d) == current(%d)", xid, vx_current_xid());
4720 * We may need two file_lock structures for this operation,
4721 * so we get them in advance to avoid races.
4722 @@ -819,7 +842,11 @@ static int __posix_lock_file(struct inod
4723 (request->fl_type != F_UNLCK ||
4724 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4725 new_fl = locks_alloc_lock();
4726 + new_fl->fl_xid = xid;
4727 + vx_locks_inc(new_fl);
4728 new_fl2 = locks_alloc_lock();
4729 + new_fl2->fl_xid = xid;
4730 + vx_locks_inc(new_fl2);
4734 @@ -1018,7 +1045,8 @@ static int __posix_lock_file(struct inod
4735 int posix_lock_file(struct file *filp, struct file_lock *fl,
4736 struct file_lock *conflock)
4738 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4739 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4740 + fl, conflock, filp->f_xid);
4742 EXPORT_SYMBOL(posix_lock_file);
4744 @@ -1108,7 +1136,7 @@ int locks_mandatory_area(int read_write,
4745 fl.fl_end = offset + count - 1;
4748 - error = __posix_lock_file(inode, &fl, NULL);
4749 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4750 if (error != FILE_LOCK_DEFERRED)
4752 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4753 @@ -1423,6 +1451,7 @@ int generic_setlease(struct file *filp,
4755 locks_copy_lock(new_fl, lease);
4756 locks_insert_lock(before, new_fl);
4757 + vx_locks_inc(new_fl);
4761 @@ -1778,6 +1807,11 @@ int fcntl_setlk(unsigned int fd, struct
4762 if (file_lock == NULL)
4765 + vxd_assert(filp->f_xid == vx_current_xid(),
4766 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4767 + file_lock->fl_xid = filp->f_xid;
4768 + vx_locks_inc(file_lock);
4771 * This might block, so we do it before checking the inode.
4773 @@ -1896,6 +1930,11 @@ int fcntl_setlk64(unsigned int fd, struc
4774 if (file_lock == NULL)
4777 + vxd_assert(filp->f_xid == vx_current_xid(),
4778 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4779 + file_lock->fl_xid = filp->f_xid;
4780 + vx_locks_inc(file_lock);
4783 * This might block, so we do it before checking the inode.
4785 @@ -2161,8 +2200,11 @@ static int locks_show(struct seq_file *f
4787 lock_get_status(f, fl, (long)f->private, "");
4789 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4790 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4791 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4793 lock_get_status(f, bfl, (long)f->private, " ->");
4798 diff -NurpP --minimal linux-2.6.29/fs/namei.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/namei.c
4799 --- linux-2.6.29/fs/namei.c 2009-03-24 14:22:26.000000000 +0100
4800 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/namei.c 2009-03-25 00:50:11.000000000 +0100
4802 #include <linux/file.h>
4803 #include <linux/fcntl.h>
4804 #include <linux/device_cgroup.h>
4805 +#include <linux/proc_fs.h>
4806 +#include <linux/vserver/inode.h>
4807 +#include <linux/vs_base.h>
4808 +#include <linux/vs_tag.h>
4809 +#include <linux/vs_cowbl.h>
4810 +#include <linux/vs_device.h>
4811 +#include <linux/vs_context.h>
4812 +#include <linux/pid_namespace.h>
4813 #include <asm/uaccess.h>
4815 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
4816 @@ -167,6 +175,77 @@ void putname(const char *name)
4817 EXPORT_SYMBOL(putname);
4820 +static inline int dx_barrier(struct inode *inode)
4822 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4823 + vxwprintk_task(1, "did hit the barrier.");
4829 +static int __dx_permission(struct inode *inode, int mask)
4831 + if (dx_barrier(inode))
4834 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4835 + /* devpts is xid tagged */
4836 + if (S_ISDIR(inode->i_mode) ||
4837 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4840 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4841 + struct proc_dir_entry *de = PDE(inode);
4843 + if (de && !vx_hide_check(0, de->vx_flags))
4846 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4848 + struct task_struct *tsk;
4850 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4851 + vx_flags(VXF_STATE_SETUP, 0))
4854 + pid = PROC_I(inode)->pid;
4858 + tsk = pid_task(pid, PIDTYPE_PID);
4859 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4860 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4861 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4865 + /* FIXME: Should we block some entries here? */
4870 + if (dx_notagcheck(inode->i_sb) ||
4871 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4880 +int dx_permission(struct inode *inode, int mask)
4882 + int ret = __dx_permission(inode, mask);
4883 + if (unlikely(ret)) {
4884 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
4885 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4893 * generic_permission - check for access rights on a Posix-like filesystem
4894 @@ -253,10 +332,14 @@ int inode_permission(struct inode *inode
4896 * Nobody gets write access to an immutable file.
4898 - if (IS_IMMUTABLE(inode))
4899 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4903 + retval = dx_permission(inode, mask);
4907 if (inode->i_op->permission)
4908 retval = inode->i_op->permission(inode, mask);
4910 @@ -432,6 +515,8 @@ static int exec_permission_lite(struct i
4912 umode_t mode = inode->i_mode;
4914 + if (dx_barrier(inode))
4916 if (inode->i_op->permission)
4919 @@ -749,7 +834,8 @@ static __always_inline void follow_dotdo
4920 if (nd->path.dentry == fs->root.dentry &&
4921 nd->path.mnt == fs->root.mnt) {
4922 read_unlock(&fs->lock);
4924 + /* for sane '/' avoid follow_mount() */
4927 read_unlock(&fs->lock);
4928 spin_lock(&dcache_lock);
4929 @@ -786,16 +872,30 @@ static int do_lookup(struct nameidata *n
4931 struct vfsmount *mnt = nd->path.mnt;
4932 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
4933 + struct inode *inode;
4937 if (dentry->d_op && dentry->d_op->d_revalidate)
4938 goto need_revalidate;
4939 + inode = dentry->d_inode;
4943 + if (__dx_permission(inode, MAY_ACCESS))
4948 path->dentry = dentry;
4949 __follow_mount(path);
4952 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s«.",
4953 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
4954 + vxd_path(&nd->path));
4959 dentry = real_lookup(nd->path.dentry, name, nd);
4960 @@ -1364,7 +1464,7 @@ static int may_delete(struct inode *dir,
4963 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4964 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4965 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4968 if (!S_ISDIR(victim->d_inode->i_mode))
4969 @@ -1506,6 +1606,14 @@ int may_open(struct path *path, int acc_
4973 +#ifdef CONFIG_VSERVER_COWBL
4974 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
4975 + if (IS_COW_LINK(inode))
4977 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4978 + mark_inode_dirty(inode);
4981 error = inode_permission(inode, acc_mode);
4984 @@ -1639,6 +1747,11 @@ struct file *do_filp_open(int dfd, const
4986 int flag = open_to_namei_flags(open_flag);
4988 +#ifdef CONFIG_VSERVER_COWBL
4993 acc_mode = MAY_OPEN | ACC_MODE(flag);
4995 /* O_TRUNC implies we need access checks for write permissions */
4996 @@ -1771,6 +1884,25 @@ ok:
4999 error = may_open(&nd.path, acc_mode, flag);
5000 +#ifdef CONFIG_VSERVER_COWBL
5001 + if (error == -EMLINK) {
5002 + struct dentry *dentry;
5003 + dentry = cow_break_link(pathname);
5004 + if (IS_ERR(dentry)) {
5005 + error = PTR_ERR(dentry);
5010 + mnt_drop_write(nd.path.mnt);
5011 + release_open_intent(&nd);
5012 + path_put(&nd.path);
5021 mnt_drop_write(nd.path.mnt);
5022 @@ -1924,9 +2056,17 @@ int vfs_mknod(struct inode *dir, struct
5026 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5027 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5030 + if (!capable(CAP_MKNOD))
5033 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5035 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5038 if (!dir->i_op->mknod)
5041 @@ -2393,7 +2533,7 @@ int vfs_link(struct dentry *old_dentry,
5043 * A link to an append-only or immutable file cannot be created.
5045 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5046 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5048 if (!dir->i_op->link)
5050 @@ -2766,6 +2906,219 @@ int vfs_follow_link(struct nameidata *nd
5051 return __vfs_follow_link(nd, link);
5055 +#ifdef CONFIG_VSERVER_COWBL
5057 +#include <linux/file.h>
5060 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5064 + return do_splice_direct(in, &ppos, out, len, 0);
5067 +struct dentry *cow_break_link(const char *pathname)
5069 + int ret, mode, pathlen, redo = 0;
5070 + struct nameidata old_nd, dir_nd;
5071 + struct path old_path, new_path;
5072 + struct dentry *dir, *res = NULL;
5073 + struct file *old_file;
5074 + struct file *new_file;
5075 + char *to, *path, pad='\251';
5078 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5079 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5084 + /* old_nd will have refs to dentry and mnt */
5085 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5086 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5088 + goto out_free_path;
5090 + old_path = old_nd.path;
5091 + mode = old_path.dentry->d_inode->i_mode;
5093 + to = d_path(&old_path, path, PATH_MAX-2);
5094 + pathlen = strlen(to);
5095 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5096 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5097 + old_path.dentry->d_name.len);
5099 + to[pathlen + 1] = 0;
5101 + to[pathlen] = pad--;
5103 + if (pad <= '\240')
5106 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5107 + /* dir_nd will have refs to dentry and mnt */
5108 + ret = path_lookup(to,
5109 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5110 + vxdprintk(VXD_CBIT(misc, 2),
5111 + "path_lookup(new): %d", ret);
5115 + /* this puppy downs the inode mutex */
5116 + new_path.dentry = lookup_create(&dir_nd, 0);
5117 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5118 + vxdprintk(VXD_CBIT(misc, 2),
5119 + "lookup_create(new): %p", new_path.dentry);
5120 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5121 + path_put(&dir_nd.path);
5124 + vxdprintk(VXD_CBIT(misc, 2),
5125 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5126 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5127 + new_path.dentry->d_name.len);
5128 + dir = dir_nd.path.dentry;
5130 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5131 + vxdprintk(VXD_CBIT(misc, 2),
5132 + "vfs_create(new): %d", ret);
5133 + if (ret == -EEXIST) {
5134 + mutex_unlock(&dir->d_inode->i_mutex);
5135 + dput(new_path.dentry);
5136 + path_put(&dir_nd.path);
5140 + goto out_unlock_new;
5142 + /* drop out early, ret passes ENOENT */
5144 + if ((redo = d_unhashed(old_path.dentry)))
5145 + goto out_unlock_new;
5147 + new_path.mnt = dir_nd.path.mnt;
5148 + dget(old_path.dentry);
5149 + mntget(old_path.mnt);
5150 + /* this one cleans up the dentry/mnt in case of failure */
5151 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5152 + O_RDONLY, current_cred());
5153 + vxdprintk(VXD_CBIT(misc, 2),
5154 + "dentry_open(old): %p", old_file);
5155 + if (!old_file || IS_ERR(old_file)) {
5156 + res = IS_ERR(old_file) ? (void *) old_file : res;
5157 + goto out_unlock_new;
5160 + dget(new_path.dentry);
5161 + mntget(new_path.mnt);
5162 + /* this one cleans up the dentry/mnt in case of failure */
5163 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5164 + O_WRONLY, current_cred());
5165 + vxdprintk(VXD_CBIT(misc, 2),
5166 + "dentry_open(new): %p", new_file);
5168 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5169 + if (!new_file || IS_ERR(new_file))
5170 + goto out_fput_old;
5172 + size = i_size_read(old_file->f_dentry->d_inode);
5173 + ret = do_cow_splice(old_file, new_file, size);
5174 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5176 + goto out_fput_both;
5177 + } else if (ret < size) {
5179 + goto out_fput_both;
5181 + struct inode *old_inode = old_path.dentry->d_inode;
5182 + struct inode *new_inode = new_path.dentry->d_inode;
5183 + struct iattr attr = {
5184 + .ia_uid = old_inode->i_uid,
5185 + .ia_gid = old_inode->i_gid,
5186 + .ia_valid = ATTR_UID | ATTR_GID
5189 + ret = inode_setattr(new_inode, &attr);
5191 + goto out_fput_both;
5194 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5196 + /* drop out late */
5198 + if ((redo = d_unhashed(old_path.dentry)))
5201 + vxdprintk(VXD_CBIT(misc, 2),
5202 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5203 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5204 + new_path.dentry->d_name.len,
5205 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5206 + old_path.dentry->d_name.len);
5207 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5208 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5209 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5210 + res = new_path.dentry;
5213 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5216 + vxdprintk(VXD_CBIT(misc, 3),
5217 + "fput(new_file=%p[#%ld])", new_file,
5218 + atomic_read(&new_file->f_count));
5222 + vxdprintk(VXD_CBIT(misc, 3),
5223 + "fput(old_file=%p[#%ld])", old_file,
5224 + atomic_read(&old_file->f_count));
5228 + mutex_unlock(&dir->d_inode->i_mutex);
5232 + /* error path cleanup */
5233 + vfs_unlink(dir->d_inode, new_path.dentry);
5234 + dput(new_path.dentry);
5238 + goto out_rel_both;
5239 + /* lookup dentry once again */
5240 + path_put(&old_nd.path);
5241 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5243 + goto out_rel_both;
5245 + new_path.dentry = old_nd.path.dentry;
5246 + vxdprintk(VXD_CBIT(misc, 2),
5247 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5248 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5249 + new_path.dentry->d_name.len);
5250 + dget(new_path.dentry);
5251 + res = new_path.dentry;
5254 + path_put(&dir_nd.path);
5256 + path_put(&old_nd.path);
5261 + res = ERR_PTR(ret);
5267 /* get the link contents into pagecache */
5268 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5270 diff -NurpP --minimal linux-2.6.29/fs/namespace.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/namespace.c
5271 --- linux-2.6.29/fs/namespace.c 2009-03-24 14:22:26.000000000 +0100
5272 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/namespace.c 2009-03-24 14:48:35.000000000 +0100
5274 #include <linux/ramfs.h>
5275 #include <linux/log2.h>
5276 #include <linux/idr.h>
5277 +#include <linux/vs_base.h>
5278 +#include <linux/vs_context.h>
5279 +#include <linux/vs_tag.h>
5280 +#include <linux/vserver/space.h>
5281 +#include <linux/vserver/global.h>
5282 #include <asm/uaccess.h>
5283 #include <asm/unistd.h>
5285 @@ -573,6 +578,7 @@ static struct vfsmount *clone_mnt(struct
5286 mnt->mnt_root = dget(root);
5287 mnt->mnt_mountpoint = mnt->mnt_root;
5288 mnt->mnt_parent = mnt;
5289 + mnt->mnt_tag = old->mnt_tag;
5291 if (flag & CL_SLAVE) {
5292 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5293 @@ -687,6 +693,31 @@ static inline void mangle(struct seq_fil
5294 seq_escape(m, s, " \t\n\\");
5297 +static int mnt_is_reachable(struct vfsmount *mnt)
5300 + struct dentry *point;
5303 + if (mnt == mnt->mnt_ns->root)
5306 + spin_lock(&vfsmount_lock);
5307 + root = current->fs->root;
5308 + point = root.dentry;
5310 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5311 + point = mnt->mnt_mountpoint;
5312 + mnt = mnt->mnt_parent;
5315 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5317 + spin_unlock(&vfsmount_lock);
5323 * Simple .show_options callback for filesystems which don't want to
5324 * implement more complex mount option showing.
5325 @@ -759,6 +790,8 @@ static int show_sb_opts(struct seq_file
5326 { MS_SYNCHRONOUS, ",sync" },
5327 { MS_DIRSYNC, ",dirsync" },
5328 { MS_MANDLOCK, ",mand" },
5329 + { MS_TAGGED, ",tag" },
5330 + { MS_NOTAGCHECK, ",notagcheck" },
5333 const struct proc_fs_info *fs_infop;
5334 @@ -805,10 +838,20 @@ static int show_vfsmnt(struct seq_file *
5336 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5338 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5340 - seq_path(m, &mnt_path, " \t\n\\");
5342 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5344 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5347 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5348 + mnt == current->fs->root.mnt) {
5349 + seq_puts(m, "/dev/root / ");
5351 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5353 + seq_path(m, &mnt_path, " \t\n\\");
5356 show_type(m, mnt->mnt_sb);
5357 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5358 err = show_sb_opts(m, mnt->mnt_sb);
5359 @@ -838,6 +881,11 @@ static int show_mountinfo(struct seq_fil
5360 struct path root = p->root;
5363 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5365 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5368 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5369 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5370 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5371 @@ -896,17 +944,27 @@ static int show_vfsstat(struct seq_file
5372 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5376 - if (mnt->mnt_devname) {
5377 - seq_puts(m, "device ");
5378 - mangle(m, mnt->mnt_devname);
5380 - seq_puts(m, "no device");
5381 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5383 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5387 - seq_puts(m, " mounted on ");
5388 - seq_path(m, &mnt_path, " \t\n\\");
5390 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5391 + mnt == current->fs->root.mnt) {
5392 + seq_puts(m, "device /dev/root mounted on / ");
5395 + if (mnt->mnt_devname) {
5396 + seq_puts(m, "device ");
5397 + mangle(m, mnt->mnt_devname);
5399 + seq_puts(m, "no device");
5402 + seq_puts(m, " mounted on ");
5403 + seq_path(m, &mnt_path, " \t\n\\");
5407 /* file system type */
5408 seq_puts(m, "with fstype ");
5409 @@ -1145,7 +1203,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5413 - if (!capable(CAP_SYS_ADMIN))
5414 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5417 retval = do_umount(path.mnt, flags);
5418 @@ -1171,7 +1229,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5420 static int mount_is_safe(struct path *path)
5422 - if (capable(CAP_SYS_ADMIN))
5423 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5427 @@ -1462,11 +1520,13 @@ static int do_change_type(struct path *p
5428 * do loopback mount.
5430 static int do_loopback(struct path *path, char *old_name,
5432 + tag_t tag, unsigned long flags, int mnt_flags)
5434 struct path old_path;
5435 struct vfsmount *mnt = NULL;
5436 int err = mount_is_safe(path);
5437 + int recurse = flags & MS_REC;
5441 if (!old_name || !*old_name)
5442 @@ -1500,6 +1560,7 @@ static int do_loopback(struct path *path
5443 spin_unlock(&vfsmount_lock);
5444 release_mounts(&umount_list);
5446 + mnt->mnt_flags = mnt_flags;
5449 up_write(&namespace_sem);
5450 @@ -1530,12 +1591,12 @@ static int change_mount_flags(struct vfs
5451 * on it - tough luck.
5453 static int do_remount(struct path *path, int flags, int mnt_flags,
5455 + void *data, xid_t xid)
5458 struct super_block *sb = path->mnt->mnt_sb;
5460 - if (!capable(CAP_SYS_ADMIN))
5461 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5464 if (!check_mnt(path->mnt))
5465 @@ -1577,7 +1638,7 @@ static int do_move_mount(struct path *pa
5466 struct path old_path, parent_path;
5469 - if (!capable(CAP_SYS_ADMIN))
5470 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5472 if (!old_name || !*old_name)
5474 @@ -1659,7 +1720,7 @@ static int do_new_mount(struct path *pat
5477 /* we need capabilities... */
5478 - if (!capable(CAP_SYS_ADMIN))
5479 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5482 mnt = do_kern_mount(type, flags, name, data);
5483 @@ -1904,6 +1965,7 @@ long do_mount(char *dev_name, char *dir_
5490 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5491 @@ -1919,6 +1981,12 @@ long do_mount(char *dev_name, char *dir_
5493 ((char *)data_page)[PAGE_SIZE - 1] = 0;
5495 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5496 + /* FIXME: bind and re-mounts get the tag flag? */
5497 + if (flags & (MS_BIND|MS_REMOUNT))
5498 + flags |= MS_TAGID;
5501 /* Separate the per-mountpoint flags */
5502 if (flags & MS_NOSUID)
5503 mnt_flags |= MNT_NOSUID;
5504 @@ -1935,6 +2003,8 @@ long do_mount(char *dev_name, char *dir_
5505 if (flags & MS_RDONLY)
5506 mnt_flags |= MNT_READONLY;
5508 + if (!capable(CAP_SYS_ADMIN))
5509 + mnt_flags |= MNT_NODEV;
5510 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5511 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT);
5513 @@ -1950,9 +2020,9 @@ long do_mount(char *dev_name, char *dir_
5515 if (flags & MS_REMOUNT)
5516 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5519 else if (flags & MS_BIND)
5520 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5521 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5522 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5523 retval = do_change_type(&path, flags);
5524 else if (flags & MS_MOVE)
5525 @@ -2021,6 +2091,7 @@ static struct mnt_namespace *dup_mnt_ns(
5526 q = next_mnt(q, new_ns->root);
5528 up_write(&namespace_sem);
5529 + atomic_inc(&vs_global_mnt_ns);
5533 @@ -2348,5 +2419,6 @@ void __put_mnt_ns(struct mnt_namespace *
5534 spin_unlock(&vfsmount_lock);
5535 up_write(&namespace_sem);
5536 release_mounts(&umount_list);
5537 + atomic_dec(&vs_global_mnt_ns);
5540 diff -NurpP --minimal linux-2.6.29/fs/nfs/client.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/client.c
5541 --- linux-2.6.29/fs/nfs/client.c 2009-03-24 14:22:26.000000000 +0100
5542 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/client.c 2009-03-24 14:48:35.000000000 +0100
5543 @@ -696,6 +696,9 @@ static int nfs_init_server_rpcclient(str
5544 if (server->flags & NFS_MOUNT_SOFT)
5545 server->client->cl_softrtry = 1;
5547 + server->client->cl_tag = 0;
5548 + if (server->flags & NFS_MOUNT_TAGGED)
5549 + server->client->cl_tag = 1;
5553 @@ -862,6 +865,10 @@ static void nfs_server_set_fsinfo(struct
5554 server->acdirmin = server->acdirmax = 0;
5557 + /* FIXME: needs fsinfo
5558 + if (server->flags & NFS_MOUNT_TAGGED)
5559 + sb->s_flags |= MS_TAGGED; */
5561 server->maxfilesize = fsinfo->maxfilesize;
5563 /* We're airborne Set socket buffersize */
5564 diff -NurpP --minimal linux-2.6.29/fs/nfs/dir.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/dir.c
5565 --- linux-2.6.29/fs/nfs/dir.c 2009-03-24 14:22:26.000000000 +0100
5566 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/dir.c 2009-03-24 14:48:35.000000000 +0100
5568 #include <linux/namei.h>
5569 #include <linux/mount.h>
5570 #include <linux/sched.h>
5571 +#include <linux/vs_tag.h>
5573 #include "nfs4_fs.h"
5574 #include "delegation.h"
5575 @@ -950,6 +951,7 @@ static struct dentry *nfs_lookup(struct
5577 goto out_unblock_sillyrename;
5579 + dx_propagate_tag(nd, inode);
5581 res = d_materialise_unique(dentry, inode);
5583 diff -NurpP --minimal linux-2.6.29/fs/nfs/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/inode.c
5584 --- linux-2.6.29/fs/nfs/inode.c 2009-03-24 14:22:26.000000000 +0100
5585 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/inode.c 2009-03-24 14:48:35.000000000 +0100
5587 #include <linux/vfs.h>
5588 #include <linux/inet.h>
5589 #include <linux/nfs_xdr.h>
5590 +#include <linux/vs_tag.h>
5592 #include <asm/system.h>
5593 #include <asm/uaccess.h>
5594 @@ -313,8 +314,10 @@ nfs_fhget(struct super_block *sb, struct
5595 nfsi->change_attr = fattr->change_attr;
5596 inode->i_size = nfs_size_to_loff_t(fattr->size);
5597 inode->i_nlink = fattr->nlink;
5598 - inode->i_uid = fattr->uid;
5599 - inode->i_gid = fattr->gid;
5600 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5601 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5602 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5603 + /* maybe fattr->xid someday */
5604 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5606 * report the blocks in 512byte units
5607 @@ -462,6 +465,8 @@ void nfs_setattr_update_inode(struct ino
5608 inode->i_uid = attr->ia_uid;
5609 if ((attr->ia_valid & ATTR_GID) != 0)
5610 inode->i_gid = attr->ia_gid;
5611 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5612 + inode->i_tag = attr->ia_tag;
5613 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5614 spin_unlock(&inode->i_lock);
5616 @@ -850,6 +855,9 @@ static int nfs_check_inode_attributes(st
5617 struct nfs_inode *nfsi = NFS_I(inode);
5618 loff_t cur_size, new_isize;
5619 unsigned long invalid = 0;
5625 /* Has the inode gone and changed behind our back? */
5626 @@ -871,10 +879,15 @@ static int nfs_check_inode_attributes(st
5627 if (cur_size != new_isize && nfsi->npages == 0)
5628 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5630 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5631 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5632 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5634 /* Have any file permissions changed? */
5635 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
5636 - || inode->i_uid != fattr->uid
5637 - || inode->i_gid != fattr->gid)
5638 + || inode->i_uid != uid
5639 + || inode->i_gid != gid
5640 + || inode->i_tag != tag)
5641 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5643 /* Has the link count changed? */
5644 @@ -1073,6 +1086,9 @@ static int nfs_update_inode(struct inode
5645 loff_t cur_isize, new_isize;
5646 unsigned long invalid = 0;
5647 unsigned long now = jiffies;
5652 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5653 __func__, inode->i_sb->s_id, inode->i_ino,
5654 @@ -1146,9 +1162,14 @@ static int nfs_update_inode(struct inode
5655 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5656 nfsi->change_attr = fattr->change_attr;
5658 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5659 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5660 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5662 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
5663 - inode->i_uid != fattr->uid ||
5664 - inode->i_gid != fattr->gid)
5665 + inode->i_uid != uid ||
5666 + inode->i_gid != gid ||
5667 + inode->i_tag != tag)
5668 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5670 if (inode->i_nlink != fattr->nlink)
5671 @@ -1156,8 +1177,9 @@ static int nfs_update_inode(struct inode
5673 inode->i_mode = fattr->mode;
5674 inode->i_nlink = fattr->nlink;
5675 - inode->i_uid = fattr->uid;
5676 - inode->i_gid = fattr->gid;
5677 + inode->i_uid = uid;
5678 + inode->i_gid = gid;
5679 + inode->i_tag = tag;
5681 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5683 diff -NurpP --minimal linux-2.6.29/fs/nfs/nfs3xdr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/nfs3xdr.c
5684 --- linux-2.6.29/fs/nfs/nfs3xdr.c 2009-03-24 14:22:26.000000000 +0100
5685 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/nfs3xdr.c 2009-03-24 14:48:35.000000000 +0100
5687 #include <linux/nfs3.h>
5688 #include <linux/nfs_fs.h>
5689 #include <linux/nfsacl.h>
5690 +#include <linux/vs_tag.h>
5691 #include "internal.h"
5693 #define NFSDBG_FACILITY NFSDBG_XDR
5694 @@ -182,7 +183,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5697 static inline __be32 *
5698 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5699 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5701 if (attr->ia_valid & ATTR_MODE) {
5703 @@ -190,15 +191,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5707 - if (attr->ia_valid & ATTR_UID) {
5708 + if (attr->ia_valid & ATTR_UID ||
5709 + (tag && (attr->ia_valid & ATTR_TAG))) {
5711 - *p++ = htonl(attr->ia_uid);
5712 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5716 - if (attr->ia_valid & ATTR_GID) {
5717 + if (attr->ia_valid & ATTR_GID ||
5718 + (tag && (attr->ia_valid & ATTR_TAG))) {
5720 - *p++ = htonl(attr->ia_gid);
5721 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5725 @@ -283,7 +286,8 @@ static int
5726 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5728 p = xdr_encode_fhandle(p, args->fh);
5729 - p = xdr_encode_sattr(p, args->sattr);
5730 + p = xdr_encode_sattr(p, args->sattr,
5731 + req->rq_task->tk_client->cl_tag);
5732 *p++ = htonl(args->guard);
5734 p = xdr_encode_time3(p, &args->guardtime);
5735 @@ -388,7 +392,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5736 *p++ = args->verifier[0];
5737 *p++ = args->verifier[1];
5739 - p = xdr_encode_sattr(p, args->sattr);
5740 + p = xdr_encode_sattr(p, args->sattr,
5741 + req->rq_task->tk_client->cl_tag);
5743 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5745 @@ -402,7 +407,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5747 p = xdr_encode_fhandle(p, args->fh);
5748 p = xdr_encode_array(p, args->name, args->len);
5749 - p = xdr_encode_sattr(p, args->sattr);
5750 + p = xdr_encode_sattr(p, args->sattr,
5751 + req->rq_task->tk_client->cl_tag);
5752 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5755 @@ -415,7 +421,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
5757 p = xdr_encode_fhandle(p, args->fromfh);
5758 p = xdr_encode_array(p, args->fromname, args->fromlen);
5759 - p = xdr_encode_sattr(p, args->sattr);
5760 + p = xdr_encode_sattr(p, args->sattr,
5761 + req->rq_task->tk_client->cl_tag);
5762 *p++ = htonl(args->pathlen);
5763 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5765 @@ -433,7 +440,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
5766 p = xdr_encode_fhandle(p, args->fh);
5767 p = xdr_encode_array(p, args->name, args->len);
5768 *p++ = htonl(args->type);
5769 - p = xdr_encode_sattr(p, args->sattr);
5770 + p = xdr_encode_sattr(p, args->sattr,
5771 + req->rq_task->tk_client->cl_tag);
5772 if (args->type == NF3CHR || args->type == NF3BLK) {
5773 *p++ = htonl(MAJOR(args->rdev));
5774 *p++ = htonl(MINOR(args->rdev));
5775 diff -NurpP --minimal linux-2.6.29/fs/nfs/nfsroot.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/nfsroot.c
5776 --- linux-2.6.29/fs/nfs/nfsroot.c 2009-03-24 14:22:26.000000000 +0100
5777 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/nfsroot.c 2009-03-24 14:48:35.000000000 +0100
5778 @@ -119,12 +119,12 @@ static int mount_port __initdata = 0; /
5780 /* Options that take integer arguments */
5781 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
5782 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
5783 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
5784 /* Options that take no arguments */
5785 Opt_soft, Opt_hard, Opt_intr,
5786 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
5787 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
5788 - Opt_acl, Opt_noacl,
5789 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
5793 @@ -161,6 +161,9 @@ static match_table_t __initconst tokens
5796 {Opt_noacl, "noacl"},
5798 + {Opt_notag, "notag"},
5799 + {Opt_tagid, "tagid=%u"},
5803 @@ -272,6 +275,20 @@ static int __init root_nfs_parse(char *n
5805 nfs_data.flags |= NFS_MOUNT_NOACL;
5807 +#ifndef CONFIG_TAGGING_NONE
5809 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5812 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
5815 +#ifdef CONFIG_PROPAGATE
5818 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5822 printk(KERN_WARNING "Root-NFS: unknown "
5824 diff -NurpP --minimal linux-2.6.29/fs/nfs/super.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/super.c
5825 --- linux-2.6.29/fs/nfs/super.c 2009-03-24 14:22:26.000000000 +0100
5826 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfs/super.c 2009-03-24 16:02:06.000000000 +0100
5828 #include <linux/nfs_xdr.h>
5829 #include <linux/magic.h>
5830 #include <linux/parser.h>
5831 +#include <linux/vs_tag.h>
5833 #include <asm/system.h>
5834 #include <asm/uaccess.h>
5835 @@ -517,6 +518,7 @@ static void nfs_show_mount_options(struc
5836 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5837 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5838 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5839 + { NFS_MOUNT_TAGGED, ",tag", "" },
5842 const struct proc_nfs_info *nfs_infop;
5843 diff -NurpP --minimal linux-2.6.29/fs/nfsd/auth.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfsd/auth.c
5844 --- linux-2.6.29/fs/nfsd/auth.c 2009-03-24 14:22:26.000000000 +0100
5845 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfsd/auth.c 2009-03-24 16:09:39.000000000 +0100
5847 #include <linux/sunrpc/svcauth.h>
5848 #include <linux/nfsd/nfsd.h>
5849 #include <linux/nfsd/export.h>
5850 +#include <linux/vs_tag.h>
5853 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
5854 @@ -42,6 +43,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5856 new->fsuid = rqstp->rq_cred.cr_uid;
5857 new->fsgid = rqstp->rq_cred.cr_gid;
5858 + /* FIXME: this desperately needs a tag :)
5859 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5862 rqgi = rqstp->rq_cred.cr_group_info;
5864 @@ -69,7 +73,7 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5867 gi = get_group_info(rqgi);
5871 if (new->fsuid == (uid_t) -1)
5872 new->fsuid = exp->ex_anon_uid;
5873 @@ -94,6 +98,6 @@ oom:
5881 diff -NurpP --minimal linux-2.6.29/fs/nfsd/nfs3xdr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfsd/nfs3xdr.c
5882 --- linux-2.6.29/fs/nfsd/nfs3xdr.c 2008-12-25 00:26:37.000000000 +0100
5883 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfsd/nfs3xdr.c 2009-02-22 22:54:25.000000000 +0100
5885 #include <linux/sunrpc/svc.h>
5886 #include <linux/nfsd/nfsd.h>
5887 #include <linux/nfsd/xdr3.h>
5888 +#include <linux/vs_tag.h>
5891 #define NFSDDBG_FACILITY NFSDDBG_XDR
5892 @@ -108,6 +109,8 @@ static __be32 *
5893 decode_sattr3(__be32 *p, struct iattr *iap)
5901 @@ -117,12 +120,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5904 iap->ia_valid |= ATTR_UID;
5905 - iap->ia_uid = ntohl(*p++);
5906 + uid = ntohl(*p++);
5909 iap->ia_valid |= ATTR_GID;
5910 - iap->ia_gid = ntohl(*p++);
5911 + gid = ntohl(*p++);
5913 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5914 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5915 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5919 @@ -178,8 +184,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5920 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5921 *p++ = htonl((u32) stat->mode);
5922 *p++ = htonl((u32) stat->nlink);
5923 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5924 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5925 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5926 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5927 + stat->uid, stat->tag)));
5928 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5929 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5930 + stat->gid, stat->tag)));
5931 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5932 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5934 diff -NurpP --minimal linux-2.6.29/fs/nfsd/nfs4xdr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfsd/nfs4xdr.c
5935 --- linux-2.6.29/fs/nfsd/nfs4xdr.c 2009-03-24 14:22:26.000000000 +0100
5936 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfsd/nfs4xdr.c 2009-03-24 14:48:35.000000000 +0100
5938 #include <linux/nfs4_acl.h>
5939 #include <linux/sunrpc/gss_api.h>
5940 #include <linux/sunrpc/svcauth_gss.h>
5941 +#include <linux/vs_tag.h>
5943 #define NFSDDBG_FACILITY NFSDDBG_XDR
5945 @@ -1714,14 +1715,18 @@ out_acl:
5946 WRITE32(stat.nlink);
5948 if (bmval1 & FATTR4_WORD1_OWNER) {
5949 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5950 + status = nfsd4_encode_user(rqstp,
5951 + TAGINO_UID(DX_TAG(dentry->d_inode),
5952 + stat.uid, stat.tag), &p, &buflen);
5953 if (status == nfserr_resource)
5958 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5959 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5960 + status = nfsd4_encode_group(rqstp,
5961 + TAGINO_GID(DX_TAG(dentry->d_inode),
5962 + stat.gid, stat.tag), &p, &buflen);
5963 if (status == nfserr_resource)
5966 diff -NurpP --minimal linux-2.6.29/fs/nfsd/nfsxdr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfsd/nfsxdr.c
5967 --- linux-2.6.29/fs/nfsd/nfsxdr.c 2008-12-25 00:26:37.000000000 +0100
5968 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/nfsd/nfsxdr.c 2009-02-22 22:54:25.000000000 +0100
5970 #include <linux/nfsd/nfsd.h>
5971 #include <linux/nfsd/xdr.h>
5972 #include <linux/mm.h>
5973 +#include <linux/vs_tag.h>
5976 #define NFSDDBG_FACILITY NFSDDBG_XDR
5977 @@ -98,6 +99,8 @@ static __be32 *
5978 decode_sattr(__be32 *p, struct iattr *iap)
5986 @@ -111,12 +114,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5988 if ((tmp = ntohl(*p++)) != (u32)-1) {
5989 iap->ia_valid |= ATTR_UID;
5990 - iap->ia_uid = tmp;
5993 if ((tmp = ntohl(*p++)) != (u32)-1) {
5994 iap->ia_valid |= ATTR_GID;
5995 - iap->ia_gid = tmp;
5998 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5999 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6000 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6001 if ((tmp = ntohl(*p++)) != (u32)-1) {
6002 iap->ia_valid |= ATTR_SIZE;
6004 @@ -161,8 +167,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6005 *p++ = htonl(nfs_ftypes[type >> 12]);
6006 *p++ = htonl((u32) stat->mode);
6007 *p++ = htonl((u32) stat->nlink);
6008 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6009 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6010 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6011 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6012 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6013 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6015 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6016 *p++ = htonl(NFS_MAXPATHLEN);
6017 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/dlm/dlmfs.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/dlm/dlmfs.c
6018 --- linux-2.6.29/fs/ocfs2/dlm/dlmfs.c 2009-03-24 14:22:27.000000000 +0100
6019 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/dlm/dlmfs.c 2009-03-24 16:10:48.000000000 +0100
6021 #include <linux/init.h>
6022 #include <linux/string.h>
6023 #include <linux/backing-dev.h>
6024 +#include <linux/vs_tag.h>
6026 #include <asm/uaccess.h>
6028 @@ -341,6 +342,7 @@ static struct inode *dlmfs_get_root_inod
6029 inode->i_mode = mode;
6030 inode->i_uid = current_fsuid();
6031 inode->i_gid = current_fsgid();
6032 + inode->i_tag = dx_current_fstag(sb);
6033 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6034 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6036 @@ -366,6 +368,7 @@ static struct inode *dlmfs_get_inode(str
6037 inode->i_mode = mode;
6038 inode->i_uid = current_fsuid();
6039 inode->i_gid = current_fsgid();
6040 + inode->i_tag = dx_current_fstag(sb);
6041 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6042 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6044 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/dlmglue.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/dlmglue.c
6045 --- linux-2.6.29/fs/ocfs2/dlmglue.c 2009-03-24 14:22:27.000000000 +0100
6046 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/dlmglue.c 2009-03-24 14:48:35.000000000 +0100
6047 @@ -1885,6 +1885,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6048 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6049 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6050 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6051 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6052 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6053 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6054 lvb->lvb_iatime_packed =
6055 @@ -1939,6 +1940,7 @@ static void ocfs2_refresh_inode_from_lvb
6057 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6058 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6059 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6060 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6061 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6062 ocfs2_unpack_timespec(&inode->i_atime,
6063 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/dlmglue.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/dlmglue.h
6064 --- linux-2.6.29/fs/ocfs2/dlmglue.h 2009-03-24 14:22:27.000000000 +0100
6065 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/dlmglue.h 2009-03-24 14:48:35.000000000 +0100
6066 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6069 __be32 lvb_igeneration;
6070 - __be32 lvb_reserved2;
6072 + __be16 lvb_reserved2;
6075 #define OCFS2_QINFO_LVB_VERSION 1
6076 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/file.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/file.c
6077 --- linux-2.6.29/fs/ocfs2/file.c 2009-03-24 14:22:27.000000000 +0100
6078 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/file.c 2009-03-24 14:48:35.000000000 +0100
6079 @@ -911,13 +911,15 @@ int ocfs2_setattr(struct dentry *dentry,
6080 mlog(0, "uid change: %d\n", attr->ia_uid);
6081 if (attr->ia_valid & ATTR_GID)
6082 mlog(0, "gid change: %d\n", attr->ia_gid);
6083 + if (attr->ia_valid & ATTR_TAG)
6084 + mlog(0, "tag change: %d\n", attr->ia_tag);
6085 if (attr->ia_valid & ATTR_SIZE)
6086 mlog(0, "size change...\n");
6087 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6088 mlog(0, "time change...\n");
6090 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6091 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6092 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6093 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6094 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6096 @@ -2070,6 +2072,7 @@ const struct inode_operations ocfs2_file
6097 .removexattr = generic_removexattr,
6098 .fallocate = ocfs2_fallocate,
6099 .fiemap = ocfs2_fiemap,
6100 + .sync_flags = ocfs2_sync_flags,
6103 const struct inode_operations ocfs2_special_file_iops = {
6104 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/inode.c
6105 --- linux-2.6.29/fs/ocfs2/inode.c 2009-03-24 14:22:27.000000000 +0100
6106 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/inode.c 2009-03-24 16:11:11.000000000 +0100
6108 #include <linux/highmem.h>
6109 #include <linux/pagemap.h>
6110 #include <linux/quotaops.h>
6111 +#include <linux/vs_tag.h>
6113 #include <asm/byteorder.h>
6117 #include "heartbeat.h"
6120 #include "journal.h"
6122 #include "suballoc.h"
6123 @@ -77,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
6125 unsigned int flags = OCFS2_I(inode)->ip_attr;
6127 - inode->i_flags &= ~(S_IMMUTABLE |
6128 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6129 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6131 if (flags & OCFS2_IMMUTABLE_FL)
6132 inode->i_flags |= S_IMMUTABLE;
6133 + if (flags & OCFS2_IXUNLINK_FL)
6134 + inode->i_flags |= S_IXUNLINK;
6136 if (flags & OCFS2_SYNC_FL)
6137 inode->i_flags |= S_SYNC;
6138 @@ -91,25 +95,85 @@ void ocfs2_set_inode_flags(struct inode
6139 inode->i_flags |= S_NOATIME;
6140 if (flags & OCFS2_DIRSYNC_FL)
6141 inode->i_flags |= S_DIRSYNC;
6143 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6145 + if (flags & OCFS2_BARRIER_FL)
6146 + inode->i_vflags |= V_BARRIER;
6147 + if (flags & OCFS2_COW_FL)
6148 + inode->i_vflags |= V_COW;
6151 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6152 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6154 unsigned int flags = oi->vfs_inode.i_flags;
6155 + unsigned int vflags = oi->vfs_inode.i_vflags;
6157 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6158 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6159 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6160 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6162 + if (flags & S_IMMUTABLE)
6163 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6164 + if (flags & S_IXUNLINK)
6165 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6167 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6168 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6170 oi->ip_attr |= OCFS2_SYNC_FL;
6171 if (flags & S_APPEND)
6172 oi->ip_attr |= OCFS2_APPEND_FL;
6173 - if (flags & S_IMMUTABLE)
6174 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6175 if (flags & S_NOATIME)
6176 oi->ip_attr |= OCFS2_NOATIME_FL;
6177 if (flags & S_DIRSYNC)
6178 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6180 + if (vflags & V_BARRIER)
6181 + oi->ip_attr |= OCFS2_BARRIER_FL;
6182 + if (vflags & V_COW)
6183 + oi->ip_attr |= OCFS2_COW_FL;
6186 +int ocfs2_sync_flags(struct inode *inode)
6188 + struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6189 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6190 + handle_t *handle = NULL;
6191 + struct buffer_head *bh = NULL;
6194 + status = ocfs2_inode_lock(inode, &bh, 1);
6196 + mlog_errno(status);
6201 + if (IS_RDONLY(inode))
6204 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6205 + if (IS_ERR(handle)) {
6206 + status = PTR_ERR(handle);
6207 + mlog_errno(status);
6211 + ocfs2_get_inode_flags(ocfs2_inode);
6212 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6214 + mlog_errno(status);
6216 + ocfs2_commit_trans(osb, handle);
6218 + ocfs2_inode_unlock(inode, 1);
6223 + mlog_exit(status);
6227 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
6228 @@ -222,6 +286,8 @@ void ocfs2_populate_inode(struct inode *
6229 struct super_block *sb;
6230 struct ocfs2_super *osb;
6235 mlog_entry("(0x%p, size:%llu)\n", inode,
6236 (unsigned long long)le64_to_cpu(fe->i_size));
6237 @@ -253,8 +319,12 @@ void ocfs2_populate_inode(struct inode *
6238 inode->i_generation = le32_to_cpu(fe->i_generation);
6239 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6240 inode->i_mode = le16_to_cpu(fe->i_mode);
6241 - inode->i_uid = le32_to_cpu(fe->i_uid);
6242 - inode->i_gid = le32_to_cpu(fe->i_gid);
6243 + uid = le32_to_cpu(fe->i_uid);
6244 + gid = le32_to_cpu(fe->i_gid);
6245 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6246 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6247 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6248 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6250 /* Fast symlinks will have i_size but no allocated clusters. */
6251 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6252 @@ -1206,8 +1276,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
6254 fe->i_size = cpu_to_le64(i_size_read(inode));
6255 fe->i_links_count = cpu_to_le16(inode->i_nlink);
6256 - fe->i_uid = cpu_to_le32(inode->i_uid);
6257 - fe->i_gid = cpu_to_le32(inode->i_gid);
6258 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
6259 + inode->i_uid, inode->i_tag));
6260 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
6261 + inode->i_gid, inode->i_tag));
6262 + /* i_tag = = cpu_to_le16(inode->i_tag); */
6263 fe->i_mode = cpu_to_le16(inode->i_mode);
6264 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
6265 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
6266 @@ -1235,16 +1308,25 @@ leave:
6267 void ocfs2_refresh_inode(struct inode *inode,
6268 struct ocfs2_dinode *fe)
6273 spin_lock(&OCFS2_I(inode)->ip_lock);
6275 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
6276 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
6277 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
6278 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
6279 OCFS2_I(inode)->ip_dyn_features = le16_to_cpu(fe->i_dyn_features);
6280 ocfs2_set_inode_flags(inode);
6281 i_size_write(inode, le64_to_cpu(fe->i_size));
6282 inode->i_nlink = le16_to_cpu(fe->i_links_count);
6283 - inode->i_uid = le32_to_cpu(fe->i_uid);
6284 - inode->i_gid = le32_to_cpu(fe->i_gid);
6285 + uid = le32_to_cpu(fe->i_uid);
6286 + gid = le32_to_cpu(fe->i_gid);
6287 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6288 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6289 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6290 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6291 inode->i_mode = le16_to_cpu(fe->i_mode);
6292 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
6293 inode->i_blocks = 0;
6294 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/inode.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/inode.h
6295 --- linux-2.6.29/fs/ocfs2/inode.h 2009-03-24 14:22:27.000000000 +0100
6296 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/inode.h 2009-03-24 14:48:35.000000000 +0100
6297 @@ -147,6 +147,7 @@ struct buffer_head *ocfs2_bread(struct i
6299 void ocfs2_set_inode_flags(struct inode *inode);
6300 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6301 +int ocfs2_sync_flags(struct inode *inode);
6303 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6305 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/ioctl.c
6306 --- linux-2.6.29/fs/ocfs2/ioctl.c 2008-12-25 00:26:37.000000000 +0100
6307 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/ioctl.c 2009-02-22 22:54:25.000000000 +0100
6308 @@ -42,7 +42,7 @@ static int ocfs2_get_inode_attr(struct i
6312 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6313 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6316 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6317 @@ -67,6 +67,11 @@ static int ocfs2_set_inode_attr(struct i
6318 if (!S_ISDIR(inode->i_mode))
6319 flags &= ~OCFS2_DIRSYNC_FL;
6321 + if (IS_BARRIER(inode)) {
6322 + vxwprintk_task(1, "messing with the barrier.");
6326 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6327 if (IS_ERR(handle)) {
6328 status = PTR_ERR(handle);
6329 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/ioctl.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/ioctl.h
6330 --- linux-2.6.29/fs/ocfs2/ioctl.h 2008-12-25 00:26:37.000000000 +0100
6331 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/ioctl.h 2009-02-22 22:54:25.000000000 +0100
6333 #ifndef OCFS2_IOCTL_H
6334 #define OCFS2_IOCTL_H
6336 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6339 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
6340 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
6342 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/namei.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/namei.c
6343 --- linux-2.6.29/fs/ocfs2/namei.c 2009-03-24 14:22:27.000000000 +0100
6344 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/namei.c 2009-03-25 01:04:31.000000000 +0100
6346 #include <linux/slab.h>
6347 #include <linux/highmem.h>
6348 #include <linux/quotaops.h>
6349 +#include <linux/vs_tag.h>
6351 #define MLOG_MASK_PREFIX ML_NAMEI
6352 #include <cluster/masklog.h>
6353 @@ -462,6 +463,7 @@ static int ocfs2_mknod_locked(struct ocf
6354 struct ocfs2_extent_list *fel;
6359 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry,
6360 inode->i_mode, (unsigned long)dev, dentry->d_name.len,
6361 @@ -508,8 +510,11 @@ static int ocfs2_mknod_locked(struct ocf
6362 fe->i_blkno = cpu_to_le64(fe_blkno);
6363 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6364 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6365 - fe->i_uid = cpu_to_le32(inode->i_uid);
6366 - fe->i_gid = cpu_to_le32(inode->i_gid);
6368 + tag = dx_current_fstag(osb->sb);
6369 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6370 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6371 + inode->i_tag = tag;
6372 fe->i_mode = cpu_to_le16(inode->i_mode);
6373 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6374 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6375 @@ -2025,6 +2030,7 @@ const struct inode_operations ocfs2_dir_
6376 .rename = ocfs2_rename,
6377 .setattr = ocfs2_setattr,
6378 .getattr = ocfs2_getattr,
6379 + .sync_flags = ocfs2_sync_flags,
6380 .permission = ocfs2_permission,
6381 .setxattr = generic_setxattr,
6382 .getxattr = generic_getxattr,
6383 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/ocfs2_fs.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/ocfs2_fs.h
6384 --- linux-2.6.29/fs/ocfs2/ocfs2_fs.h 2009-03-24 14:22:27.000000000 +0100
6385 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/ocfs2_fs.h 2009-03-24 14:48:35.000000000 +0100
6386 @@ -219,18 +219,23 @@
6387 #define OCFS2_INDEXED_DIR_FL (0x0008)
6389 /* Inode attributes, keep in sync with EXT2 */
6390 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6391 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6392 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6393 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6394 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6395 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6396 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6397 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6398 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6399 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6400 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6401 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6402 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6403 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6404 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6405 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6406 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6408 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6409 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6410 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6411 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6413 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6414 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6416 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6417 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6420 * Extent record flags (e_node.leaf.flags)
6421 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/ocfs2.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/ocfs2.h
6422 --- linux-2.6.29/fs/ocfs2/ocfs2.h 2009-03-24 14:22:27.000000000 +0100
6423 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/ocfs2.h 2009-03-24 16:18:22.000000000 +0100
6424 @@ -199,6 +199,7 @@ enum ocfs2_mount_options
6425 OCFS2_MOUNT_POSIX_ACL = 1 << 8, /* POSIX access control lists */
6426 OCFS2_MOUNT_USRQUOTA = 1 << 9, /* We support user quotas */
6427 OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */
6428 + OCFS2_MOUNT_TAGGED = 1 << 11, /* use tagging */
6431 #define OCFS2_OSB_SOFT_RO 0x0001
6432 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/super.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/super.c
6433 --- linux-2.6.29/fs/ocfs2/super.c 2009-03-24 14:22:27.000000000 +0100
6434 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/ocfs2/super.c 2009-03-24 16:19:44.000000000 +0100
6435 @@ -172,6 +172,7 @@ enum {
6439 + Opt_tag, Opt_notag, Opt_tagid,
6443 @@ -198,6 +199,9 @@ static const match_table_t tokens = {
6444 {Opt_noacl, "noacl"},
6445 {Opt_usrquota, "usrquota"},
6446 {Opt_grpquota, "grpquota"},
6448 + {Opt_notag, "notag"},
6449 + {Opt_tagid, "tagid=%u"},
6453 @@ -436,6 +440,13 @@ static int ocfs2_remount(struct super_bl
6457 + if ((parsed_options.mount_opt & OCFS2_MOUNT_TAGGED) &&
6458 + !(sb->s_flags & MS_TAGGED)) {
6460 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6464 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6465 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6467 @@ -950,6 +961,9 @@ static int ocfs2_fill_super(struct super
6469 ocfs2_complete_mount_recovery(osb);
6471 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6472 + sb->s_flags |= MS_TAGGED;
6474 if (ocfs2_mount_local(osb))
6475 snprintf(nodestr, sizeof(nodestr), "local");
6477 @@ -1208,6 +1222,20 @@ static int ocfs2_parse_options(struct su
6478 printk(KERN_INFO "ocfs2 (no)acl options not supported\n");
6481 +#ifndef CONFIG_TAGGING_NONE
6483 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6486 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6489 +#ifdef CONFIG_PROPAGATE
6492 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6497 "Unrecognized mount option \"%s\" "
6498 diff -NurpP --minimal linux-2.6.29/fs/open.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/open.c
6499 --- linux-2.6.29/fs/open.c 2009-03-24 14:22:27.000000000 +0100
6500 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/open.c 2009-03-24 14:48:35.000000000 +0100
6502 #include <linux/rcupdate.h>
6503 #include <linux/audit.h>
6504 #include <linux/falloc.h>
6505 +#include <linux/vs_base.h>
6506 +#include <linux/vs_limit.h>
6507 +#include <linux/vs_dlimit.h>
6508 +#include <linux/vs_tag.h>
6509 +#include <linux/vs_cowbl.h>
6511 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
6513 int retval = -ENODEV;
6516 + struct super_block *sb = dentry->d_sb;
6519 - if (dentry->d_sb->s_op->statfs) {
6520 + if (sb->s_op->statfs) {
6521 memset(buf, 0, sizeof(*buf));
6522 retval = security_sb_statfs(dentry);
6525 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6526 + retval = sb->s_op->statfs(dentry, buf);
6527 if (retval == 0 && buf->f_frsize == 0)
6528 buf->f_frsize = buf->f_bsize;
6530 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6531 + vx_vsi_statfs(sb, buf);
6535 @@ -638,6 +647,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6536 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6540 + error = cow_check_and_break(&path);
6542 + goto dput_and_out;
6543 inode = path.dentry->d_inode;
6545 error = mnt_want_write(path.mnt);
6546 @@ -671,11 +684,11 @@ static int chown_common(struct dentry *
6547 newattrs.ia_valid = ATTR_CTIME;
6548 if (user != (uid_t) -1) {
6549 newattrs.ia_valid |= ATTR_UID;
6550 - newattrs.ia_uid = user;
6551 + newattrs.ia_uid = dx_map_uid(user);
6553 if (group != (gid_t) -1) {
6554 newattrs.ia_valid |= ATTR_GID;
6555 - newattrs.ia_gid = group;
6556 + newattrs.ia_gid = dx_map_gid(group);
6558 if (!S_ISDIR(inode->i_mode))
6559 newattrs.ia_valid |=
6560 @@ -698,7 +711,11 @@ SYSCALL_DEFINE3(chown, const char __user
6561 error = mnt_want_write(path.mnt);
6564 - error = chown_common(path.dentry, user, group);
6565 +#ifdef CONFIG_VSERVER_COWBL
6566 + error = cow_check_and_break(&path);
6569 + error = chown_common(path.dentry, user, group);
6570 mnt_drop_write(path.mnt);
6573 @@ -723,7 +740,11 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6574 error = mnt_want_write(path.mnt);
6577 - error = chown_common(path.dentry, user, group);
6578 +#ifdef CONFIG_VSERVER_COWBL
6579 + error = cow_check_and_break(&path);
6582 + error = chown_common(path.dentry, user, group);
6583 mnt_drop_write(path.mnt);
6586 @@ -742,7 +763,11 @@ SYSCALL_DEFINE3(lchown, const char __use
6587 error = mnt_want_write(path.mnt);
6590 - error = chown_common(path.dentry, user, group);
6591 +#ifdef CONFIG_VSERVER_COWBL
6592 + error = cow_check_and_break(&path);
6595 + error = chown_common(path.dentry, user, group);
6596 mnt_drop_write(path.mnt);
6599 @@ -986,6 +1011,7 @@ static void __put_unused_fd(struct files
6600 __FD_CLR(fd, fdt->open_fds);
6601 if (fd < files->next_fd)
6602 files->next_fd = fd;
6603 + vx_openfd_dec(fd);
6606 void put_unused_fd(unsigned int fd)
6607 diff -NurpP --minimal linux-2.6.29/fs/proc/array.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/array.c
6608 --- linux-2.6.29/fs/proc/array.c 2009-03-24 14:22:27.000000000 +0100
6609 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/array.c 2009-03-25 01:07:51.000000000 +0100
6611 #include <linux/seq_file.h>
6612 #include <linux/pid_namespace.h>
6613 #include <linux/tracehook.h>
6614 +#include <linux/vs_context.h>
6615 +#include <linux/vs_network.h>
6617 #include <asm/pgtable.h>
6618 #include <asm/processor.h>
6619 @@ -137,8 +139,9 @@ static const char *task_state_array[] =
6620 "D (disk sleep)", /* 2 */
6621 "T (stopped)", /* 4 */
6622 "T (tracing stop)", /* 8 */
6623 - "Z (zombie)", /* 16 */
6624 - "X (dead)" /* 32 */
6625 + "H (on hold)", /* 16 */
6626 + "Z (zombie)", /* 32 */
6627 + "X (dead)", /* 64 */
6630 static inline const char *get_task_state(struct task_struct *tsk)
6631 @@ -165,6 +168,9 @@ static inline void task_state(struct seq
6633 ppid = pid_alive(p) ?
6634 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6635 + if (unlikely(vx_current_initpid(p->pid)))
6640 struct task_struct *tracer = tracehook_tracer_task(p);
6641 @@ -280,7 +286,7 @@ static inline void task_sig(struct seq_f
6644 static void render_cap_t(struct seq_file *m, const char *header,
6646 + struct vx_info *vxi, kernel_cap_t *a)
6650 @@ -305,10 +311,11 @@ static inline void task_cap(struct seq_f
6651 cap_bset = cred->cap_bset;
6654 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6655 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6656 - render_cap_t(m, "CapEff:\t", &cap_effective);
6657 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6658 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6659 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6660 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6661 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6662 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6665 static inline void task_context_switch_counts(struct seq_file *m,
6666 @@ -320,6 +327,42 @@ static inline void task_context_switch_c
6670 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6671 + struct pid *pid, struct task_struct *task)
6673 + seq_printf(m, "Proxy:\t%p(%c)\n"
6681 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6682 + atomic_read(&task->nsproxy->count),
6683 + task->nsproxy->uts_ns,
6684 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6685 + task->nsproxy->ipc_ns,
6686 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6687 + task->nsproxy->mnt_ns,
6688 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6689 + task->nsproxy->pid_ns,
6690 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6691 + task->nsproxy->net_ns,
6692 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6696 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6698 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6701 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6702 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6706 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6707 struct pid *pid, struct task_struct *task)
6709 @@ -335,6 +378,7 @@ int proc_pid_status(struct seq_file *m,
6712 cpuset_task_status_allowed(m, task);
6713 + task_vs_id(m, task);
6714 #if defined(CONFIG_S390)
6715 task_show_regs(m, task);
6717 @@ -447,6 +491,17 @@ static int do_task_stat(struct seq_file
6718 /* convert nsec -> ticks */
6719 start_time = nsec_to_clock_t(start_time);
6721 + /* fixup start time for virt uptime */
6722 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6723 + unsigned long long bias =
6724 + current->vx_info->cvirt.bias_clock;
6726 + if (start_time > bias)
6727 + start_time -= bias;
6732 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6733 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6734 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6735 diff -NurpP --minimal linux-2.6.29/fs/proc/base.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/base.c
6736 --- linux-2.6.29/fs/proc/base.c 2009-03-24 14:22:27.000000000 +0100
6737 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/base.c 2009-03-24 16:29:35.000000000 +0100
6739 #include <linux/oom.h>
6740 #include <linux/elf.h>
6741 #include <linux/pid_namespace.h>
6742 +#include <linux/vs_context.h>
6743 +#include <linux/vs_network.h>
6744 #include "internal.h"
6747 @@ -1458,6 +1460,8 @@ static struct inode *proc_pid_make_inode
6748 inode->i_gid = cred->egid;
6751 + /* procfs is xid tagged */
6752 + inode->i_tag = (tag_t)vx_task_xid(task);
6753 security_task_to_inode(task, inode);
6756 @@ -2008,6 +2012,13 @@ static struct dentry *proc_pident_lookup
6760 + /* TODO: maybe we can come up with a generic approach? */
6761 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6762 + (dentry->d_name.len == 5) &&
6763 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6764 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6768 * Yes, it does not scale. And it should not. Don't add
6769 * new entries into /proc/<tgid>/ without very good reasons.
6770 @@ -2393,7 +2404,7 @@ out_iput:
6771 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6773 struct dentry *error;
6774 - struct task_struct *task = get_proc_task(dir);
6775 + struct task_struct *task = get_proc_task_real(dir);
6776 const struct pid_entry *p, *last;
6778 error = ERR_PTR(-ENOENT);
6779 @@ -2483,6 +2494,9 @@ static int proc_pid_personality(struct s
6780 static const struct file_operations proc_task_operations;
6781 static const struct inode_operations proc_task_inode_operations;
6783 +extern int proc_pid_vx_info(struct task_struct *, char *);
6784 +extern int proc_pid_nx_info(struct task_struct *, char *);
6786 static const struct pid_entry tgid_base_stuff[] = {
6787 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6788 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6789 @@ -2541,6 +2555,8 @@ static const struct pid_entry tgid_base_
6790 #ifdef CONFIG_CGROUPS
6791 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6793 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6794 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6795 INF("oom_score", S_IRUGO, proc_oom_score),
6796 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6797 #ifdef CONFIG_AUDITSYSCALL
6798 @@ -2556,6 +2572,7 @@ static const struct pid_entry tgid_base_
6799 #ifdef CONFIG_TASK_IO_ACCOUNTING
6800 INF("io", S_IRUGO, proc_tgid_io_accounting),
6802 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6805 static int proc_tgid_base_readdir(struct file * filp,
6806 @@ -2752,7 +2769,7 @@ retry:
6808 pid = find_ge_pid(iter.tgid, ns);
6810 - iter.tgid = pid_nr_ns(pid, ns);
6811 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6812 iter.task = pid_task(pid, PIDTYPE_PID);
6813 /* What we to know is if the pid we have find is the
6814 * pid of a thread_group_leader. Testing for task
6815 @@ -2782,7 +2799,7 @@ static int proc_pid_fill_cache(struct fi
6816 struct tgid_iter iter)
6818 char name[PROC_NUMBUF];
6819 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6820 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6821 return proc_fill_cache(filp, dirent, filldir, name, len,
6822 proc_pid_instantiate, iter.task, NULL);
6824 @@ -2791,7 +2808,7 @@ static int proc_pid_fill_cache(struct fi
6825 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
6827 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6828 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
6829 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6830 struct tgid_iter iter;
6831 struct pid_namespace *ns;
6833 @@ -2811,6 +2828,8 @@ int proc_pid_readdir(struct file * filp,
6835 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6836 filp->f_pos = iter.tgid + TGID_OFFSET;
6837 + if (!vx_proc_task_visible(iter.task))
6839 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6840 put_task_struct(iter.task);
6842 @@ -2957,6 +2976,8 @@ static struct dentry *proc_task_lookup(s
6843 tid = name_to_int(dentry);
6846 + if (vx_current_initpid(tid))
6849 ns = dentry->d_sb->s_fs_info;
6851 diff -NurpP --minimal linux-2.6.29/fs/proc/generic.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/generic.c
6852 --- linux-2.6.29/fs/proc/generic.c 2009-03-24 14:22:27.000000000 +0100
6853 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/generic.c 2009-03-24 14:48:35.000000000 +0100
6855 #include <linux/bitops.h>
6856 #include <linux/spinlock.h>
6857 #include <linux/completion.h>
6858 +#include <linux/vserver/inode.h>
6859 #include <asm/uaccess.h>
6861 #include "internal.h"
6862 @@ -382,6 +383,8 @@ struct dentry *proc_lookup_de(struct pro
6863 for (de = de->subdir; de ; de = de->next) {
6864 if (de->namelen != dentry->d_name.len)
6866 + if (!vx_hide_check(0, de->vx_flags))
6868 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6871 @@ -390,6 +393,8 @@ struct dentry *proc_lookup_de(struct pro
6872 spin_unlock(&proc_subdir_lock);
6874 inode = proc_get_inode(dir->i_sb, ino, de);
6875 + /* generic proc entries belong to the host */
6880 @@ -467,6 +472,8 @@ int proc_readdir_de(struct proc_dir_entr
6882 /* filldir passes info to user space */
6884 + if (!vx_hide_check(0, de->vx_flags))
6886 spin_unlock(&proc_subdir_lock);
6887 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6888 de->low_ino, de->mode >> 12) < 0) {
6889 @@ -474,6 +481,7 @@ int proc_readdir_de(struct proc_dir_entr
6892 spin_lock(&proc_subdir_lock);
6897 @@ -588,6 +596,7 @@ static struct proc_dir_entry *__proc_cre
6899 atomic_set(&ent->count, 1);
6901 + ent->vx_flags = IATTR_PROC_DEFAULT;
6902 spin_lock_init(&ent->pde_unload_lock);
6903 ent->pde_unload_completion = NULL;
6904 INIT_LIST_HEAD(&ent->pde_openers);
6905 @@ -611,7 +620,8 @@ struct proc_dir_entry *proc_symlink(cons
6911 + ent->vx_flags = IATTR_PROC_SYMLINK;
6915 diff -NurpP --minimal linux-2.6.29/fs/proc/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/inode.c
6916 --- linux-2.6.29/fs/proc/inode.c 2009-03-24 14:22:27.000000000 +0100
6917 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/inode.c 2009-03-24 14:48:35.000000000 +0100
6918 @@ -465,6 +465,8 @@ struct inode *proc_get_inode(struct supe
6919 inode->i_uid = de->uid;
6920 inode->i_gid = de->gid;
6923 + PROC_I(inode)->vx_flags = de->vx_flags;
6925 inode->i_size = de->size;
6927 diff -NurpP --minimal linux-2.6.29/fs/proc/internal.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/internal.h
6928 --- linux-2.6.29/fs/proc/internal.h 2009-03-24 14:22:27.000000000 +0100
6929 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/internal.h 2009-03-24 14:48:35.000000000 +0100
6933 #include <linux/proc_fs.h>
6934 +#include <linux/vs_pid.h>
6936 extern struct proc_dir_entry proc_root;
6937 #ifdef CONFIG_PROC_SYSCTL
6938 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
6939 struct pid *pid, struct task_struct *task);
6940 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6941 struct pid *pid, struct task_struct *task);
6942 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6943 + struct pid *pid, struct task_struct *task);
6945 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6947 extern const struct file_operations proc_maps_operations;
6948 @@ -70,11 +74,16 @@ static inline struct pid *proc_pid(struc
6949 return PROC_I(inode)->pid;
6952 -static inline struct task_struct *get_proc_task(struct inode *inode)
6953 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6955 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6958 +static inline struct task_struct *get_proc_task(struct inode *inode)
6960 + return vx_get_proc_task(inode, proc_pid(inode));
6963 static inline int proc_fd(struct inode *inode)
6965 return PROC_I(inode)->fd;
6966 diff -NurpP --minimal linux-2.6.29/fs/proc/meminfo.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/meminfo.c
6967 --- linux-2.6.29/fs/proc/meminfo.c 2009-03-24 14:22:27.000000000 +0100
6968 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/meminfo.c 2009-03-24 14:48:35.000000000 +0100
6969 @@ -41,7 +41,7 @@ static int meminfo_proc_show(struct seq_
6971 cached = global_page_state(NR_FILE_PAGES) -
6972 total_swapcache_pages - i.bufferram;
6974 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
6977 get_vmalloc_info(&vmi);
6978 diff -NurpP --minimal linux-2.6.29/fs/proc/root.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/root.c
6979 --- linux-2.6.29/fs/proc/root.c 2009-03-24 14:22:27.000000000 +0100
6980 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/root.c 2009-03-24 14:48:35.000000000 +0100
6982 #include <linux/bitops.h>
6983 #include <linux/mount.h>
6984 #include <linux/pid_namespace.h>
6985 +#include <linux/vserver/inode.h>
6987 #include "internal.h"
6989 +struct proc_dir_entry *proc_virtual;
6991 +extern void proc_vx_init(void);
6993 static int proc_test_super(struct super_block *sb, void *data)
6995 return sb->s_fs_info == data;
6996 @@ -136,6 +141,7 @@ void __init proc_root_init(void)
6998 proc_mkdir("bus", NULL);
7003 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7004 @@ -203,6 +209,7 @@ struct proc_dir_entry proc_root = {
7005 .proc_iops = &proc_root_inode_operations,
7006 .proc_fops = &proc_root_operations,
7007 .parent = &proc_root,
7008 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7011 int pid_ns_prepare_proc(struct pid_namespace *ns)
7012 diff -NurpP --minimal linux-2.6.29/fs/proc/uptime.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/uptime.c
7013 --- linux-2.6.29/fs/proc/uptime.c 2008-12-25 00:26:37.000000000 +0100
7014 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/proc/uptime.c 2009-02-22 22:54:25.000000000 +0100
7016 #include <linux/proc_fs.h>
7017 #include <linux/sched.h>
7018 #include <linux/time.h>
7019 +#include <linux/vserver/cvirt.h>
7020 #include <asm/cputime.h>
7022 static int proc_calc_metrics(char *page, char **start, off_t off,
7023 @@ -29,6 +30,10 @@ static int uptime_read_proc(char *page,
7024 do_posix_clock_monotonic_gettime(&uptime);
7025 monotonic_to_bootbased(&uptime);
7026 cputime_to_timespec(idletime, &idle);
7028 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7029 + vx_vsi_uptime(&uptime, &idle);
7031 len = sprintf(page, "%lu.%02lu %lu.%02lu\n",
7032 (unsigned long) uptime.tv_sec,
7033 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7034 diff -NurpP --minimal linux-2.6.29/fs/quota.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/quota.c
7035 --- linux-2.6.29/fs/quota.c 2009-03-24 14:22:27.000000000 +0100
7036 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/quota.c 2009-03-24 14:48:35.000000000 +0100
7038 #include <linux/capability.h>
7039 #include <linux/quotaops.h>
7040 #include <linux/types.h>
7041 +#include <linux/vs_context.h>
7043 /* Check validity of generic quotactl commands */
7044 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
7045 @@ -81,11 +82,11 @@ static int generic_quotactl_valid(struct
7046 if (cmd == Q_GETQUOTA) {
7047 if (((type == USRQUOTA && current_euid() != id) ||
7048 (type == GRPQUOTA && !in_egroup_p(id))) &&
7049 - !capable(CAP_SYS_ADMIN))
7050 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7053 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7054 - if (!capable(CAP_SYS_ADMIN))
7055 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7059 @@ -132,10 +133,10 @@ static int xqm_quotactl_valid(struct sup
7060 if (cmd == Q_XGETQUOTA) {
7061 if (((type == XQM_USRQUOTA && current_euid() != id) ||
7062 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7063 - !capable(CAP_SYS_ADMIN))
7064 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7066 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7067 - if (!capable(CAP_SYS_ADMIN))
7068 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7072 @@ -337,6 +338,46 @@ static int do_quotactl(struct super_bloc
7076 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7078 +#include <linux/vroot.h>
7079 +#include <linux/major.h>
7080 +#include <linux/module.h>
7081 +#include <linux/kallsyms.h>
7082 +#include <linux/vserver/debug.h>
7084 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7086 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7088 +int register_vroot_grb(vroot_grb_func *func) {
7091 + spin_lock(&vroot_grb_lock);
7092 + if (!vroot_get_real_bdev) {
7093 + vroot_get_real_bdev = func;
7096 + spin_unlock(&vroot_grb_lock);
7099 +EXPORT_SYMBOL(register_vroot_grb);
7101 +int unregister_vroot_grb(vroot_grb_func *func) {
7102 + int ret = -EINVAL;
7104 + spin_lock(&vroot_grb_lock);
7105 + if (vroot_get_real_bdev) {
7106 + vroot_get_real_bdev = NULL;
7109 + spin_unlock(&vroot_grb_lock);
7112 +EXPORT_SYMBOL(unregister_vroot_grb);
7117 * look up a superblock on which quota ops will be performed
7118 * - use the name of a block device to find the superblock thereon
7119 @@ -354,6 +395,22 @@ static inline struct super_block *quotac
7122 return ERR_CAST(bdev);
7123 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7124 + if (bdev && bdev->bd_inode &&
7125 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7126 + struct block_device *bdnew = (void *)-EINVAL;
7128 + if (vroot_get_real_bdev)
7129 + bdnew = vroot_get_real_bdev(bdev);
7131 + vxdprintk(VXD_CBIT(misc, 0),
7132 + "vroot_get_real_bdev not set");
7134 + if (IS_ERR(bdnew))
7135 + return ERR_PTR(PTR_ERR(bdnew));
7139 sb = get_super(bdev);
7142 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/bitmap.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/bitmap.c
7143 --- linux-2.6.29/fs/reiserfs/bitmap.c 2008-12-25 00:26:37.000000000 +0100
7144 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/bitmap.c 2009-02-22 22:54:25.000000000 +0100
7146 #include <linux/reiserfs_fs_sb.h>
7147 #include <linux/reiserfs_fs_i.h>
7148 #include <linux/quotaops.h>
7149 +#include <linux/vs_dlimit.h>
7151 #define PREALLOCATION_SIZE 9
7153 @@ -429,8 +430,10 @@ static void _reiserfs_free_block(struct
7154 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
7156 journal_mark_dirty(th, s, sbh);
7157 - if (for_unformatted)
7158 + if (for_unformatted) {
7159 + DLIMIT_FREE_BLOCK(inode, 1);
7160 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
7164 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
7165 @@ -1045,6 +1048,7 @@ static inline int blocknrs_and_prealloc_
7166 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
7168 int nr_allocated = 0;
7171 determine_prealloc_size(hint);
7172 if (!hint->formatted_node) {
7173 @@ -1054,19 +1058,30 @@ static inline int blocknrs_and_prealloc_
7174 "reiserquota: allocating %d blocks id=%u",
7175 amount_needed, hint->inode->i_uid);
7178 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
7179 - if (quota_ret) /* Quota exceeded? */
7180 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
7183 return QUOTA_EXCEEDED;
7184 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
7185 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7187 + return NO_DISK_SPACE;
7190 if (hint->preallocate && hint->prealloc_size) {
7191 #ifdef REISERQUOTA_DEBUG
7192 reiserfs_debug(s, REISERFS_DEBUG_CODE,
7193 "reiserquota: allocating (prealloc) %d blocks id=%u",
7194 hint->prealloc_size, hint->inode->i_uid);
7197 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7198 - hint->prealloc_size);
7199 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7200 + hint->prealloc_size);
7202 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
7203 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7204 + hint->prealloc_size);
7208 hint->preallocate = hint->prealloc_size = 0;
7210 @@ -1098,7 +1113,10 @@ static inline int blocknrs_and_prealloc_
7212 hint->inode->i_uid);
7214 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
7215 + /* Free not allocated blocks */
7216 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
7217 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7218 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7220 while (nr_allocated--)
7221 reiserfs_free_block(hint->th, hint->inode,
7222 @@ -1129,10 +1147,10 @@ static inline int blocknrs_and_prealloc_
7223 REISERFS_I(hint->inode)->i_prealloc_count,
7224 hint->inode->i_uid);
7226 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
7227 - hint->prealloc_size - nr_allocated -
7228 - REISERFS_I(hint->inode)->
7229 - i_prealloc_count);
7230 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
7231 + REISERFS_I(hint->inode)->i_prealloc_count;
7232 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7233 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7237 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/file.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/file.c
7238 --- linux-2.6.29/fs/reiserfs/file.c 2008-12-25 00:26:37.000000000 +0100
7239 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/file.c 2009-02-22 22:54:25.000000000 +0100
7240 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
7241 .listxattr = reiserfs_listxattr,
7242 .removexattr = reiserfs_removexattr,
7243 .permission = reiserfs_permission,
7244 + .sync_flags = reiserfs_sync_flags,
7246 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/inode.c
7247 --- linux-2.6.29/fs/reiserfs/inode.c 2009-03-24 14:22:27.000000000 +0100
7248 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/inode.c 2009-03-24 14:48:35.000000000 +0100
7250 #include <linux/writeback.h>
7251 #include <linux/quotaops.h>
7252 #include <linux/swap.h>
7253 +#include <linux/vs_dlimit.h>
7254 +#include <linux/vs_tag.h>
7256 int reiserfs_commit_write(struct file *f, struct page *page,
7257 unsigned from, unsigned to);
7258 @@ -54,6 +56,7 @@ void reiserfs_delete_inode(struct inode
7259 * stat data deletion */
7261 DQUOT_FREE_INODE(inode);
7262 + DLIMIT_FREE_INODE(inode);
7264 if (journal_end(&th, inode->i_sb, jbegin_count))
7266 @@ -1116,6 +1119,8 @@ static void init_inode(struct inode *ino
7267 struct buffer_head *bh;
7268 struct item_head *ih;
7272 //int version = ITEM_VERSION_1;
7274 bh = PATH_PLAST_BUFFER(path);
7275 @@ -1139,12 +1144,13 @@ static void init_inode(struct inode *ino
7276 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7277 unsigned long blocks;
7279 + uid = sd_v1_uid(sd);
7280 + gid = sd_v1_gid(sd);
7282 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7283 set_inode_sd_version(inode, STAT_DATA_V1);
7284 inode->i_mode = sd_v1_mode(sd);
7285 inode->i_nlink = sd_v1_nlink(sd);
7286 - inode->i_uid = sd_v1_uid(sd);
7287 - inode->i_gid = sd_v1_gid(sd);
7288 inode->i_size = sd_v1_size(sd);
7289 inode->i_atime.tv_sec = sd_v1_atime(sd);
7290 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7291 @@ -1186,11 +1192,12 @@ static void init_inode(struct inode *ino
7292 // (directories and symlinks)
7293 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7295 + uid = sd_v2_uid(sd);
7296 + gid = sd_v2_gid(sd);
7298 inode->i_mode = sd_v2_mode(sd);
7299 inode->i_nlink = sd_v2_nlink(sd);
7300 - inode->i_uid = sd_v2_uid(sd);
7301 inode->i_size = sd_v2_size(sd);
7302 - inode->i_gid = sd_v2_gid(sd);
7303 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7304 inode->i_atime.tv_sec = sd_v2_atime(sd);
7305 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7306 @@ -1220,6 +1227,10 @@ static void init_inode(struct inode *ino
7307 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7310 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7311 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7312 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7315 if (S_ISREG(inode->i_mode)) {
7316 inode->i_op = &reiserfs_file_inode_operations;
7317 @@ -1242,13 +1253,15 @@ static void init_inode(struct inode *ino
7318 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7320 struct stat_data *sd_v2 = (struct stat_data *)sd;
7321 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7322 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7325 + set_sd_v2_uid(sd_v2, uid);
7326 + set_sd_v2_gid(sd_v2, gid);
7327 set_sd_v2_mode(sd_v2, inode->i_mode);
7328 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7329 - set_sd_v2_uid(sd_v2, inode->i_uid);
7330 set_sd_v2_size(sd_v2, size);
7331 - set_sd_v2_gid(sd_v2, inode->i_gid);
7332 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7333 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7334 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7335 @@ -1763,6 +1776,10 @@ int reiserfs_new_inode(struct reiserfs_t
7337 BUG_ON(!th->t_trans_id);
7339 + if (DLIMIT_ALLOC_INODE(inode)) {
7341 + goto out_bad_dlimit;
7343 if (DQUOT_ALLOC_INODE(inode)) {
7346 @@ -1950,6 +1967,9 @@ int reiserfs_new_inode(struct reiserfs_t
7347 DQUOT_FREE_INODE(inode);
7350 + DLIMIT_FREE_INODE(inode);
7353 journal_end(th, th->t_super, th->t_blocks_allocated);
7354 /* Drop can be outside and it needs more credits so it's better to have it outside */
7356 @@ -2837,14 +2857,19 @@ int reiserfs_commit_write(struct file *f
7357 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7359 if (reiserfs_attrs(inode->i_sb)) {
7360 - if (sd_attrs & REISERFS_SYNC_FL)
7361 - inode->i_flags |= S_SYNC;
7363 - inode->i_flags &= ~S_SYNC;
7364 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7365 inode->i_flags |= S_IMMUTABLE;
7367 inode->i_flags &= ~S_IMMUTABLE;
7368 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7369 + inode->i_flags |= S_IXUNLINK;
7371 + inode->i_flags &= ~S_IXUNLINK;
7373 + if (sd_attrs & REISERFS_SYNC_FL)
7374 + inode->i_flags |= S_SYNC;
7376 + inode->i_flags &= ~S_SYNC;
7377 if (sd_attrs & REISERFS_APPEND_FL)
7378 inode->i_flags |= S_APPEND;
7380 @@ -2857,6 +2882,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7381 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7383 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7385 + if (sd_attrs & REISERFS_BARRIER_FL)
7386 + inode->i_vflags |= V_BARRIER;
7388 + inode->i_vflags &= ~V_BARRIER;
7389 + if (sd_attrs & REISERFS_COW_FL)
7390 + inode->i_vflags |= V_COW;
7392 + inode->i_vflags &= ~V_COW;
7396 @@ -2867,6 +2901,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7397 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7399 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7400 + if (inode->i_flags & S_IXUNLINK)
7401 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7403 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7405 if (inode->i_flags & S_SYNC)
7406 *sd_attrs |= REISERFS_SYNC_FL;
7408 @@ -2879,6 +2918,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7409 *sd_attrs |= REISERFS_NOTAIL_FL;
7411 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7413 + if (inode->i_vflags & V_BARRIER)
7414 + *sd_attrs |= REISERFS_BARRIER_FL;
7416 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7417 + if (inode->i_vflags & V_COW)
7418 + *sd_attrs |= REISERFS_COW_FL;
7420 + *sd_attrs &= ~REISERFS_COW_FL;
7424 @@ -3046,6 +3094,22 @@ static ssize_t reiserfs_direct_IO(int rw
7425 reiserfs_get_blocks_direct_io, NULL);
7428 +int reiserfs_sync_flags(struct inode *inode)
7430 + u16 oldflags, newflags;
7432 + oldflags = REISERFS_I(inode)->i_attrs;
7433 + newflags = oldflags;
7434 + i_attrs_to_sd_attrs(inode, &newflags);
7436 + if (oldflags ^ newflags) {
7437 + REISERFS_I(inode)->i_attrs = newflags;
7438 + inode->i_ctime = CURRENT_TIME_SEC;
7439 + mark_inode_dirty(inode);
7444 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
7446 struct inode *inode = dentry->d_inode;
7447 @@ -3099,9 +3163,11 @@ int reiserfs_setattr(struct dentry *dent
7450 error = inode_change_ok(inode, attr);
7453 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7454 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7455 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7456 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7457 error = reiserfs_chown_xattrs(inode, attr);
7460 @@ -3131,6 +3197,9 @@ int reiserfs_setattr(struct dentry *dent
7461 inode->i_uid = attr->ia_uid;
7462 if (attr->ia_valid & ATTR_GID)
7463 inode->i_gid = attr->ia_gid;
7464 + if ((attr->ia_valid & ATTR_TAG) &&
7466 + inode->i_tag = attr->ia_tag;
7467 mark_inode_dirty(inode);
7469 journal_end(&th, inode->i_sb, jbegin_count);
7470 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/ioctl.c
7471 --- linux-2.6.29/fs/reiserfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
7472 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/ioctl.c 2009-02-22 22:54:25.000000000 +0100
7474 #include <linux/mount.h>
7475 #include <linux/reiserfs_fs.h>
7476 #include <linux/time.h>
7477 +#include <linux/mount.h>
7478 #include <asm/uaccess.h>
7479 #include <linux/pagemap.h>
7480 #include <linux/smp_lock.h>
7482 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
7485 - unsigned int flags;
7486 + unsigned int flags, oldflags;
7490 @@ -43,6 +44,7 @@ int reiserfs_ioctl(struct inode *inode,
7492 flags = REISERFS_I(inode)->i_attrs;
7493 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7494 + flags &= REISERFS_FL_USER_VISIBLE;
7495 return put_user(flags, (int __user *)arg);
7496 case REISERFS_IOC_SETFLAGS:{
7497 if (!reiserfs_attrs(inode->i_sb))
7498 @@ -60,6 +62,10 @@ int reiserfs_ioctl(struct inode *inode,
7502 + if (IS_BARRIER(inode)) {
7503 + vxwprintk_task(1, "messing with the barrier.");
7507 * Is it quota file? Do not allow user to mess with it
7509 @@ -84,6 +90,10 @@ int reiserfs_ioctl(struct inode *inode,
7514 + oldflags = REISERFS_I(inode)->i_attrs;
7515 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
7516 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7517 sd_attrs_to_i_attrs(flags, inode);
7518 REISERFS_I(inode)->i_attrs = flags;
7519 inode->i_ctime = CURRENT_TIME_SEC;
7520 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/namei.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/namei.c
7521 --- linux-2.6.29/fs/reiserfs/namei.c 2009-03-24 14:22:27.000000000 +0100
7522 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/namei.c 2009-03-24 14:48:35.000000000 +0100
7524 #include <linux/reiserfs_acl.h>
7525 #include <linux/reiserfs_xattr.h>
7526 #include <linux/quotaops.h>
7527 +#include <linux/vs_tag.h>
7529 #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; }
7530 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7531 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
7532 reiserfs_write_unlock(dir->i_sb);
7533 return ERR_PTR(-EACCES);
7535 + dx_propagate_tag(nd, inode);
7537 /* Propogate the priv_object flag so we know we're in the priv tree */
7538 if (is_reiserfs_priv_object(dir))
7539 @@ -586,6 +588,7 @@ static int new_inode_init(struct inode *
7541 inode->i_gid = current_fsgid();
7543 + inode->i_tag = dx_current_fstag(inode->i_sb);
7547 @@ -1540,6 +1543,7 @@ const struct inode_operations reiserfs_d
7548 .listxattr = reiserfs_listxattr,
7549 .removexattr = reiserfs_removexattr,
7550 .permission = reiserfs_permission,
7551 + .sync_flags = reiserfs_sync_flags,
7555 @@ -1556,6 +1560,7 @@ const struct inode_operations reiserfs_s
7556 .listxattr = reiserfs_listxattr,
7557 .removexattr = reiserfs_removexattr,
7558 .permission = reiserfs_permission,
7559 + .sync_flags = reiserfs_sync_flags,
7563 @@ -1569,5 +1574,6 @@ const struct inode_operations reiserfs_s
7564 .listxattr = reiserfs_listxattr,
7565 .removexattr = reiserfs_removexattr,
7566 .permission = reiserfs_permission,
7567 + .sync_flags = reiserfs_sync_flags,
7570 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/stree.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/stree.c
7571 --- linux-2.6.29/fs/reiserfs/stree.c 2008-12-25 00:26:37.000000000 +0100
7572 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/stree.c 2009-02-22 22:54:25.000000000 +0100
7574 #include <linux/reiserfs_fs.h>
7575 #include <linux/buffer_head.h>
7576 #include <linux/quotaops.h>
7577 +#include <linux/vs_dlimit.h>
7579 /* Does the buffer contain a disk block which is in the tree. */
7580 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
7581 @@ -1297,6 +1298,7 @@ int reiserfs_delete_item(struct reiserfs
7582 "reiserquota delete_item(): freeing %u, id=%u type=%c",
7583 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
7585 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7586 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7588 /* Return deleted body length */
7589 @@ -1385,6 +1387,7 @@ void reiserfs_delete_solid_item(struct r
7591 DQUOT_FREE_SPACE_NODIRTY(inode,
7593 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
7597 @@ -1734,6 +1737,7 @@ int reiserfs_cut_from_item(struct reiser
7598 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
7599 quota_cut_bytes, p_s_inode->i_uid, '?');
7601 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7602 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7605 @@ -1975,6 +1979,11 @@ int reiserfs_paste_into_item(struct reis
7606 pathrelse(p_s_search_path);
7609 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
7610 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7611 + pathrelse(p_s_search_path);
7614 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
7616 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
7617 @@ -2027,6 +2036,7 @@ int reiserfs_paste_into_item(struct reis
7618 n_pasted_size, inode->i_uid,
7619 key2type(&(p_s_key->on_disk_key)));
7621 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
7622 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7625 @@ -2064,6 +2074,11 @@ int reiserfs_insert_item(struct reiserfs
7626 pathrelse(p_s_path);
7629 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
7630 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7631 + pathrelse(p_s_path);
7635 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
7636 IH_SIZE + ih_item_len(p_s_ih));
7637 @@ -2111,7 +2126,9 @@ int reiserfs_insert_item(struct reiserfs
7638 "reiserquota insert_item(): freeing %u id=%u type=%c",
7639 quota_bytes, inode->i_uid, head2type(p_s_ih));
7643 + DLIMIT_FREE_SPACE(inode, quota_bytes);
7644 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7648 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/super.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/super.c
7649 --- linux-2.6.29/fs/reiserfs/super.c 2009-03-24 14:22:27.000000000 +0100
7650 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/super.c 2009-03-24 14:48:35.000000000 +0100
7651 @@ -902,6 +902,14 @@ static int reiserfs_parse_options(struct
7652 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7653 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7655 +#ifndef CONFIG_TAGGING_NONE
7656 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7657 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7658 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7660 +#ifdef CONFIG_PROPAGATE
7661 + {"tag",.arg_required = 'T',.values = NULL},
7663 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7664 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7665 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7666 @@ -1195,6 +1203,12 @@ static int reiserfs_remount(struct super
7667 handle_quota_files(s, qf_names, &qfmt);
7670 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7671 + !(s->s_flags & MS_TAGGED)) {
7672 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
7678 /* Add options that are safe here */
7679 @@ -1659,6 +1673,10 @@ static int reiserfs_fill_super(struct su
7683 + /* map mount option tagxid */
7684 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7685 + s->s_flags |= MS_TAGGED;
7687 rs = SB_DISK_SUPER_BLOCK(s);
7688 /* Let's do basic sanity check to verify that underlying device is not
7689 smaller than the filesystem. If the check fails then abort and scream,
7690 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/xattr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/xattr.c
7691 --- linux-2.6.29/fs/reiserfs/xattr.c 2008-12-25 00:26:37.000000000 +0100
7692 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/reiserfs/xattr.c 2009-02-22 22:54:25.000000000 +0100
7694 #include <linux/namei.h>
7695 #include <linux/errno.h>
7696 #include <linux/fs.h>
7697 +#include <linux/mount.h>
7698 #include <linux/file.h>
7699 #include <linux/pagemap.h>
7700 #include <linux/xattr.h>
7701 diff -NurpP --minimal linux-2.6.29/fs/stat.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/stat.c
7702 --- linux-2.6.29/fs/stat.c 2009-03-24 14:22:36.000000000 +0100
7703 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/stat.c 2009-03-24 14:48:35.000000000 +0100
7704 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7705 stat->nlink = inode->i_nlink;
7706 stat->uid = inode->i_uid;
7707 stat->gid = inode->i_gid;
7708 + stat->tag = inode->i_tag;
7709 stat->rdev = inode->i_rdev;
7710 stat->atime = inode->i_atime;
7711 stat->mtime = inode->i_mtime;
7712 diff -NurpP --minimal linux-2.6.29/fs/super.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/super.c
7713 --- linux-2.6.29/fs/super.c 2009-03-24 14:22:36.000000000 +0100
7714 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/super.c 2009-03-24 16:32:06.000000000 +0100
7716 #include <linux/mutex.h>
7717 #include <linux/file.h>
7718 #include <linux/async.h>
7719 +#include <linux/devpts_fs.h>
7720 +#include <linux/proc_fs.h>
7721 +#include <linux/vs_context.h>
7722 #include <asm/uaccess.h>
7723 #include "internal.h"
7725 @@ -918,12 +921,18 @@ struct vfsmount *
7726 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7728 struct vfsmount *mnt;
7729 + struct super_block *sb;
7730 char *secdata = NULL;
7734 return ERR_PTR(-ENODEV);
7737 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7738 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7742 mnt = alloc_vfsmnt(name);
7744 @@ -942,9 +951,17 @@ vfs_kern_mount(struct file_system_type *
7745 error = type->get_sb(type, flags, name, data, mnt);
7747 goto out_free_secdata;
7748 - BUG_ON(!mnt->mnt_sb);
7750 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7755 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7756 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7757 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7760 + error = security_sb_kern_mount(sb, flags, secdata);
7764 diff -NurpP --minimal linux-2.6.29/fs/sysfs/mount.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/sysfs/mount.c
7765 --- linux-2.6.29/fs/sysfs/mount.c 2008-12-25 00:26:37.000000000 +0100
7766 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/sysfs/mount.c 2009-02-22 22:54:25.000000000 +0100
7771 -/* Random magic number */
7772 -#define SYSFS_MAGIC 0x62656572
7774 static struct vfsmount *sysfs_mount;
7775 struct super_block * sysfs_sb = NULL;
7776 @@ -47,7 +45,7 @@ static int sysfs_fill_super(struct super
7778 sb->s_blocksize = PAGE_CACHE_SIZE;
7779 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7780 - sb->s_magic = SYSFS_MAGIC;
7781 + sb->s_magic = SYSFS_SUPER_MAGIC;
7782 sb->s_op = &sysfs_ops;
7783 sb->s_time_gran = 1;
7785 diff -NurpP --minimal linux-2.6.29/fs/utimes.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/utimes.c
7786 --- linux-2.6.29/fs/utimes.c 2009-03-24 14:22:37.000000000 +0100
7787 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/utimes.c 2009-02-22 22:54:25.000000000 +0100
7789 #include <linux/stat.h>
7790 #include <linux/utime.h>
7791 #include <linux/syscalls.h>
7792 +#include <linux/mount.h>
7793 +#include <linux/vs_cowbl.h>
7794 #include <asm/uaccess.h>
7795 #include <asm/unistd.h>
7797 diff -NurpP --minimal linux-2.6.29/fs/xattr.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xattr.c
7798 --- linux-2.6.29/fs/xattr.c 2009-03-24 14:22:37.000000000 +0100
7799 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xattr.c 2009-03-24 14:48:35.000000000 +0100
7801 #include <linux/module.h>
7802 #include <linux/fsnotify.h>
7803 #include <linux/audit.h>
7804 +#include <linux/mount.h>
7805 #include <asm/uaccess.h>
7808 diff -NurpP --minimal linux-2.6.29/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/linux-2.6/xfs_ioctl.c
7809 --- linux-2.6.29/fs/xfs/linux-2.6/xfs_ioctl.c 2009-03-24 14:22:37.000000000 +0100
7810 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/linux-2.6/xfs_ioctl.c 2009-03-24 14:48:35.000000000 +0100
7811 @@ -769,6 +769,10 @@ xfs_merge_ioc_xflags(
7812 xflags |= XFS_XFLAG_IMMUTABLE;
7814 xflags &= ~XFS_XFLAG_IMMUTABLE;
7815 + if (flags & FS_IXUNLINK_FL)
7816 + xflags |= XFS_XFLAG_IXUNLINK;
7818 + xflags &= ~XFS_XFLAG_IXUNLINK;
7819 if (flags & FS_APPEND_FL)
7820 xflags |= XFS_XFLAG_APPEND;
7822 @@ -797,6 +801,8 @@ xfs_di2lxflags(
7824 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7825 flags |= FS_IMMUTABLE_FL;
7826 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7827 + flags |= FS_IXUNLINK_FL;
7828 if (di_flags & XFS_DIFLAG_APPEND)
7829 flags |= FS_APPEND_FL;
7830 if (di_flags & XFS_DIFLAG_SYNC)
7831 @@ -855,6 +861,8 @@ xfs_set_diflags(
7832 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7833 if (xflags & XFS_XFLAG_IMMUTABLE)
7834 di_flags |= XFS_DIFLAG_IMMUTABLE;
7835 + if (xflags & XFS_XFLAG_IXUNLINK)
7836 + di_flags |= XFS_DIFLAG_IXUNLINK;
7837 if (xflags & XFS_XFLAG_APPEND)
7838 di_flags |= XFS_DIFLAG_APPEND;
7839 if (xflags & XFS_XFLAG_SYNC)
7840 @@ -897,6 +905,10 @@ xfs_diflags_to_linux(
7841 inode->i_flags |= S_IMMUTABLE;
7843 inode->i_flags &= ~S_IMMUTABLE;
7844 + if (xflags & XFS_XFLAG_IXUNLINK)
7845 + inode->i_flags |= S_IXUNLINK;
7847 + inode->i_flags &= ~S_IXUNLINK;
7848 if (xflags & XFS_XFLAG_APPEND)
7849 inode->i_flags |= S_APPEND;
7851 @@ -1371,10 +1383,18 @@ xfs_file_ioctl(
7852 case XFS_IOC_FSGETXATTRA:
7853 return xfs_ioc_fsgetxattr(ip, 1, arg);
7854 case XFS_IOC_FSSETXATTR:
7855 + if (IS_BARRIER(inode)) {
7856 + vxwprintk_task(1, "messing with the barrier.");
7857 + return -XFS_ERROR(EACCES);
7859 return xfs_ioc_fssetxattr(ip, filp, arg);
7860 case XFS_IOC_GETXFLAGS:
7861 return xfs_ioc_getxflags(ip, arg);
7862 case XFS_IOC_SETXFLAGS:
7863 + if (IS_BARRIER(inode)) {
7864 + vxwprintk_task(1, "messing with the barrier.");
7865 + return -XFS_ERROR(EACCES);
7867 return xfs_ioc_setxflags(ip, filp, arg);
7869 case XFS_IOC_FSSETDM: {
7870 diff -NurpP --minimal linux-2.6.29/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/linux-2.6/xfs_iops.c
7871 --- linux-2.6.29/fs/xfs/linux-2.6/xfs_iops.c 2009-03-24 14:22:37.000000000 +0100
7872 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/linux-2.6/xfs_iops.c 2009-03-24 16:33:10.000000000 +0100
7874 #include <linux/security.h>
7875 #include <linux/falloc.h>
7876 #include <linux/fiemap.h>
7877 +#include <linux/vs_tag.h>
7880 * Bring the atime in the XFS inode uptodate.
7881 @@ -552,6 +553,7 @@ xfs_vn_getattr(
7882 stat->nlink = ip->i_d.di_nlink;
7883 stat->uid = ip->i_d.di_uid;
7884 stat->gid = ip->i_d.di_gid;
7885 + stat->tag = ip->i_d.di_tag;
7886 stat->ino = ip->i_ino;
7888 stat->ino += mp->m_inoadd;
7889 @@ -591,6 +593,12 @@ xfs_vn_getattr(
7893 +xfs_vn_sync_xflags(struct inode *inode)
7895 + return -xfs_sync_xflags(XFS_I(inode));
7900 struct dentry *dentry,
7901 struct iattr *iattr)
7902 @@ -748,6 +756,7 @@ static const struct inode_operations xfs
7903 .listxattr = xfs_vn_listxattr,
7904 .fallocate = xfs_vn_fallocate,
7905 .fiemap = xfs_vn_fiemap,
7906 + .sync_flags = xfs_vn_sync_xflags,
7909 static const struct inode_operations xfs_dir_inode_operations = {
7910 @@ -773,6 +782,7 @@ static const struct inode_operations xfs
7911 .getxattr = generic_getxattr,
7912 .removexattr = generic_removexattr,
7913 .listxattr = xfs_vn_listxattr,
7914 + .sync_flags = xfs_vn_sync_xflags,
7917 static const struct inode_operations xfs_dir_ci_inode_operations = {
7918 @@ -822,6 +832,10 @@ xfs_diflags_to_iflags(
7919 inode->i_flags |= S_IMMUTABLE;
7921 inode->i_flags &= ~S_IMMUTABLE;
7922 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7923 + inode->i_flags |= S_IXUNLINK;
7925 + inode->i_flags &= ~S_IXUNLINK;
7926 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7927 inode->i_flags |= S_APPEND;
7929 @@ -834,6 +848,15 @@ xfs_diflags_to_iflags(
7930 inode->i_flags |= S_NOATIME;
7932 inode->i_flags &= ~S_NOATIME;
7934 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7935 + inode->i_vflags |= V_BARRIER;
7937 + inode->i_vflags &= ~V_BARRIER;
7938 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7939 + inode->i_vflags |= V_COW;
7941 + inode->i_vflags &= ~V_COW;
7945 @@ -862,6 +885,7 @@ xfs_setup_inode(
7946 inode->i_nlink = ip->i_d.di_nlink;
7947 inode->i_uid = ip->i_d.di_uid;
7948 inode->i_gid = ip->i_d.di_gid;
7949 + inode->i_tag = ip->i_d.di_tag;
7951 switch (inode->i_mode & S_IFMT) {
7953 diff -NurpP --minimal linux-2.6.29/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/linux-2.6/xfs_linux.h
7954 --- linux-2.6.29/fs/xfs/linux-2.6/xfs_linux.h 2009-03-24 14:22:37.000000000 +0100
7955 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/linux-2.6/xfs_linux.h 2009-03-25 01:26:04.000000000 +0100
7958 #define current_cpu() (raw_smp_processor_id())
7959 #define current_pid() (current->pid)
7960 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
7961 #define current_test_flags(f) (current->flags & (f))
7962 #define current_set_flags_nested(sp, f) \
7963 (*(sp) = current->flags, current->flags |= (f))
7964 diff -NurpP --minimal linux-2.6.29/fs/xfs/linux-2.6/xfs_super.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/linux-2.6/xfs_super.c
7965 --- linux-2.6.29/fs/xfs/linux-2.6/xfs_super.c 2009-03-24 14:22:37.000000000 +0100
7966 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/linux-2.6/xfs_super.c 2009-03-25 01:48:51.000000000 +0100
7967 @@ -120,6 +120,9 @@ mempool_t *xfs_ioend_pool;
7968 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
7969 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
7970 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
7971 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7972 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7973 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7976 * Table driven mount option parser.
7977 @@ -128,10 +131,14 @@ mempool_t *xfs_ioend_pool;
7978 * in the future, too.
7981 + Opt_tag, Opt_notag,
7982 Opt_barrier, Opt_nobarrier, Opt_err
7985 static const match_table_t tokens = {
7986 + {Opt_tag, "tagxid"},
7988 + {Opt_notag, "notag"},
7989 {Opt_barrier, "barrier"},
7990 {Opt_nobarrier, "nobarrier"},
7992 @@ -395,6 +402,19 @@ xfs_parseargs(
7993 } else if (!strcmp(this_char, "irixsgid")) {
7995 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
7996 +#ifndef CONFIG_TAGGING_NONE
7997 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7998 + mp->m_flags |= XFS_MOUNT_TAGGED;
7999 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
8000 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
8001 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
8002 + mp->m_flags |= XFS_MOUNT_TAGGED;
8004 +#ifdef CONFIG_PROPAGATE
8005 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8007 + mp->m_flags |= XFS_MOUNT_TAGGED;
8011 "XFS: unknown mount option [%s].", this_char);
8012 @@ -1221,6 +1241,16 @@ xfs_fs_remount(
8014 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8017 + if (!(sb->s_flags & MS_TAGGED)) {
8019 + "XFS: %s: tagging not permitted on remount.\n",
8028 * Logically we would return an error here to prevent
8029 @@ -1480,6 +1510,9 @@ xfs_fs_fill_super(
8031 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
8033 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8034 + sb->s_flags |= MS_TAGGED;
8037 sb->s_magic = XFS_SB_MAGIC;
8038 sb->s_blocksize = mp->m_sb.sb_blocksize;
8039 diff -NurpP --minimal linux-2.6.29/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/quota/xfs_qm_syscalls.c
8040 --- linux-2.6.29/fs/xfs/quota/xfs_qm_syscalls.c 2009-03-24 14:22:37.000000000 +0100
8041 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/quota/xfs_qm_syscalls.c 2009-03-24 14:48:35.000000000 +0100
8042 @@ -426,7 +426,7 @@ xfs_qm_scall_quotaon(
8046 - if (!capable(CAP_SYS_ADMIN))
8047 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8048 return XFS_ERROR(EPERM);
8050 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
8051 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_dinode.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_dinode.h
8052 --- linux-2.6.29/fs/xfs/xfs_dinode.h 2009-03-24 14:22:37.000000000 +0100
8053 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_dinode.h 2009-03-24 16:38:27.000000000 +0100
8054 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
8055 __be32 di_gid; /* owner's group id */
8056 __be32 di_nlink; /* number of links to file */
8057 __be16 di_projid; /* owner's project id */
8058 - __u8 di_pad[8]; /* unused, zeroed space */
8059 + __be16 di_tag; /* context tagging */
8060 + __be16 di_vflags; /* vserver specific flags */
8061 + __u8 di_pad[4]; /* unused, zeroed space */
8062 __be16 di_flushiter; /* incremented on flush */
8063 xfs_timestamp_t di_atime; /* time last accessed */
8064 xfs_timestamp_t di_mtime; /* time last modified */
8065 @@ -181,6 +183,8 @@ static inline void xfs_dinode_put_rdev(s
8066 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8067 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8068 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8069 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8071 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8072 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8073 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8074 @@ -196,6 +200,7 @@ static inline void xfs_dinode_put_rdev(s
8075 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8076 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8077 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8078 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8080 #ifdef CONFIG_XFS_RT
8081 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8082 @@ -208,6 +213,10 @@ static inline void xfs_dinode_put_rdev(s
8083 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8084 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8085 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8086 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8087 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8088 + XFS_DIFLAG_IXUNLINK)
8090 +#define XFS_DIVFLAG_BARRIER 0x01
8091 +#define XFS_DIVFLAG_COW 0x02
8093 #endif /* __XFS_DINODE_H__ */
8094 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_fs.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_fs.h
8095 --- linux-2.6.29/fs/xfs/xfs_fs.h 2009-03-24 14:22:37.000000000 +0100
8096 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_fs.h 2009-03-24 14:48:35.000000000 +0100
8097 @@ -67,6 +67,9 @@ struct fsxattr {
8098 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8099 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8100 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8101 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8102 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8103 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8104 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8107 @@ -289,7 +292,8 @@ typedef struct xfs_bstat {
8108 __s32 bs_extents; /* number of extents */
8109 __u32 bs_gen; /* generation count */
8110 __u16 bs_projid; /* project id */
8111 - unsigned char bs_pad[14]; /* pad space, unused */
8112 + __u16 bs_tag; /* context tagging */
8113 + unsigned char bs_pad[12]; /* pad space, unused */
8114 __u32 bs_dmevmask; /* DMIG event mask */
8115 __u16 bs_dmstate; /* DMIG state info */
8116 __u16 bs_aextents; /* attribute number of extents */
8117 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_ialloc.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_ialloc.c
8118 --- linux-2.6.29/fs/xfs/xfs_ialloc.c 2009-03-24 14:22:37.000000000 +0100
8119 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_ialloc.c 2009-03-24 17:03:17.000000000 +0100
8121 #include "xfs_error.h"
8122 #include "xfs_bmap.h"
8126 * Allocation group level functions.
8128 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_inode.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_inode.c
8129 --- linux-2.6.29/fs/xfs/xfs_inode.c 2009-03-24 14:22:37.000000000 +0100
8130 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_inode.c 2009-03-25 01:42:50.000000000 +0100
8131 @@ -250,6 +250,7 @@ xfs_inotobp(
8135 +#include <linux/vs_tag.h>
8138 * This routine is called to map an inode to the buffer containing
8139 @@ -645,15 +646,25 @@ xfs_iformat_btree(
8141 xfs_dinode_from_disk(
8143 - xfs_dinode_t *from)
8144 + xfs_dinode_t *from,
8147 + uint32_t uid, gid, tag;
8149 to->di_magic = be16_to_cpu(from->di_magic);
8150 to->di_mode = be16_to_cpu(from->di_mode);
8151 to->di_version = from ->di_version;
8152 to->di_format = from->di_format;
8153 to->di_onlink = be16_to_cpu(from->di_onlink);
8154 - to->di_uid = be32_to_cpu(from->di_uid);
8155 - to->di_gid = be32_to_cpu(from->di_gid);
8157 + uid = be32_to_cpu(from->di_uid);
8158 + gid = be32_to_cpu(from->di_gid);
8159 + tag = be16_to_cpu(from->di_tag);
8161 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8162 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8163 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8165 to->di_nlink = be32_to_cpu(from->di_nlink);
8166 to->di_projid = be16_to_cpu(from->di_projid);
8167 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8168 @@ -674,21 +685,26 @@ xfs_dinode_from_disk(
8169 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8170 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8171 to->di_flags = be16_to_cpu(from->di_flags);
8172 + to->di_vflags = be16_to_cpu(from->di_vflags);
8173 to->di_gen = be32_to_cpu(from->di_gen);
8179 - xfs_icdinode_t *from)
8180 + xfs_icdinode_t *from,
8183 to->di_magic = cpu_to_be16(from->di_magic);
8184 to->di_mode = cpu_to_be16(from->di_mode);
8185 to->di_version = from ->di_version;
8186 to->di_format = from->di_format;
8187 to->di_onlink = cpu_to_be16(from->di_onlink);
8188 - to->di_uid = cpu_to_be32(from->di_uid);
8189 - to->di_gid = cpu_to_be32(from->di_gid);
8191 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8192 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8193 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8195 to->di_nlink = cpu_to_be32(from->di_nlink);
8196 to->di_projid = cpu_to_be16(from->di_projid);
8197 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8198 @@ -709,12 +725,14 @@ xfs_dinode_to_disk(
8199 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8200 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8201 to->di_flags = cpu_to_be16(from->di_flags);
8202 + to->di_vflags = cpu_to_be16(from->di_vflags);
8203 to->di_gen = cpu_to_be32(from->di_gen);
8208 - __uint16_t di_flags)
8209 + __uint16_t di_flags,
8210 + __uint16_t di_vflags)
8214 @@ -725,6 +743,8 @@ _xfs_dic2xflags(
8215 flags |= XFS_XFLAG_PREALLOC;
8216 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8217 flags |= XFS_XFLAG_IMMUTABLE;
8218 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8219 + flags |= XFS_XFLAG_IXUNLINK;
8220 if (di_flags & XFS_DIFLAG_APPEND)
8221 flags |= XFS_XFLAG_APPEND;
8222 if (di_flags & XFS_DIFLAG_SYNC)
8223 @@ -749,6 +769,10 @@ _xfs_dic2xflags(
8224 flags |= XFS_XFLAG_FILESTREAM;
8227 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8228 + flags |= FS_BARRIER_FL;
8229 + if (di_vflags & XFS_DIVFLAG_COW)
8230 + flags |= FS_COW_FL;
8234 @@ -758,7 +782,7 @@ xfs_ip2xflags(
8236 xfs_icdinode_t *dic = &ip->i_d;
8238 - return _xfs_dic2xflags(dic->di_flags) |
8239 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8240 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8243 @@ -766,7 +790,8 @@ uint
8247 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8248 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8249 + be16_to_cpu(dip->di_vflags)) |
8250 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8253 @@ -802,7 +827,6 @@ xfs_iread(
8256 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8259 * If we got something that isn't an inode it means someone
8260 * (nfs or dmi) has a stale handle.
8261 @@ -827,7 +851,8 @@ xfs_iread(
8262 * Otherwise, just get the truly permanent information.
8265 - xfs_dinode_from_disk(&ip->i_d, dip);
8266 + xfs_dinode_from_disk(&ip->i_d, dip,
8267 + mp->m_flags & XFS_MOUNT_TAGGED);
8268 error = xfs_iformat(ip, dip);
8271 @@ -1027,6 +1052,7 @@ xfs_ialloc(
8272 ASSERT(ip->i_d.di_nlink == nlink);
8273 ip->i_d.di_uid = current_fsuid();
8274 ip->i_d.di_gid = current_fsgid();
8275 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
8276 ip->i_d.di_projid = prid;
8277 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8279 @@ -1087,6 +1113,7 @@ xfs_ialloc(
8280 ip->i_d.di_dmevmask = 0;
8281 ip->i_d.di_dmstate = 0;
8282 ip->i_d.di_flags = 0;
8283 + ip->i_d.di_vflags = 0;
8284 flags = XFS_ILOG_CORE;
8285 switch (mode & S_IFMT) {
8287 @@ -2161,6 +2188,7 @@ xfs_ifree(
8289 ip->i_d.di_mode = 0; /* mark incore inode as free */
8290 ip->i_d.di_flags = 0;
8291 + ip->i_d.di_vflags = 0;
8292 ip->i_d.di_dmevmask = 0;
8293 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8294 ip->i_df.if_ext_max =
8295 @@ -3128,7 +3156,8 @@ xfs_iflush_int(
8296 * because if the inode is dirty at all the core must
8299 - xfs_dinode_to_disk(dip, &ip->i_d);
8300 + xfs_dinode_to_disk(dip, &ip->i_d,
8301 + mp->m_flags & XFS_MOUNT_TAGGED);
8303 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8304 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8305 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_inode.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_inode.h
8306 --- linux-2.6.29/fs/xfs/xfs_inode.h 2009-03-24 14:22:37.000000000 +0100
8307 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_inode.h 2009-03-25 01:10:35.000000000 +0100
8308 @@ -134,7 +134,9 @@ typedef struct xfs_icdinode {
8309 __uint32_t di_gid; /* owner's group id */
8310 __uint32_t di_nlink; /* number of links to file */
8311 __uint16_t di_projid; /* owner's project id */
8312 - __uint8_t di_pad[8]; /* unused, zeroed space */
8313 + __uint16_t di_tag; /* context tagging */
8314 + __uint16_t di_vflags; /* vserver specific flags */
8315 + __uint8_t di_pad[4]; /* unused, zeroed space */
8316 __uint16_t di_flushiter; /* incremented on flush */
8317 xfs_ictimestamp_t di_atime; /* time last accessed */
8318 xfs_ictimestamp_t di_mtime; /* time last modified */
8319 @@ -589,9 +591,9 @@ int xfs_itobp(struct xfs_mount *, struc
8320 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8321 struct xfs_inode *, xfs_daddr_t, uint);
8322 void xfs_dinode_from_disk(struct xfs_icdinode *,
8323 - struct xfs_dinode *);
8324 + struct xfs_dinode *, int);
8325 void xfs_dinode_to_disk(struct xfs_dinode *,
8326 - struct xfs_icdinode *);
8327 + struct xfs_icdinode *, int);
8328 void xfs_idestroy_fork(struct xfs_inode *, int);
8329 void xfs_idata_realloc(struct xfs_inode *, int, int);
8330 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8331 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_itable.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_itable.c
8332 --- linux-2.6.29/fs/xfs/xfs_itable.c 2009-03-24 14:22:37.000000000 +0100
8333 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_itable.c 2009-03-24 14:48:35.000000000 +0100
8334 @@ -82,6 +82,7 @@ xfs_bulkstat_one_iget(
8335 buf->bs_mode = dic->di_mode;
8336 buf->bs_uid = dic->di_uid;
8337 buf->bs_gid = dic->di_gid;
8338 + buf->bs_tag = dic->di_tag;
8339 buf->bs_size = dic->di_size;
8340 vn_atime_to_bstime(VFS_I(ip), &buf->bs_atime);
8341 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
8342 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_log_recover.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_log_recover.c
8343 --- linux-2.6.29/fs/xfs/xfs_log_recover.c 2009-03-24 14:22:37.000000000 +0100
8344 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_log_recover.c 2009-03-24 17:17:15.000000000 +0100
8345 @@ -2421,7 +2421,8 @@ xlog_recover_do_inode_trans(
8348 /* The core is in in-core format */
8349 - xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8350 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8351 + mp->m_flags & XFS_MOUNT_TAGGED);
8353 /* the rest is in on-disk format */
8354 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8355 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_mount.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_mount.h
8356 --- linux-2.6.29/fs/xfs/xfs_mount.h 2009-03-24 14:22:37.000000000 +0100
8357 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_mount.h 2009-03-24 14:48:35.000000000 +0100
8358 @@ -371,6 +371,7 @@ typedef struct xfs_mount {
8360 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8362 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8365 * Default minimum read and write sizes.
8366 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_vnodeops.c linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_vnodeops.c
8367 --- linux-2.6.29/fs/xfs/xfs_vnodeops.c 2009-03-24 14:22:37.000000000 +0100
8368 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_vnodeops.c 2009-03-24 17:18:40.000000000 +0100
8370 #include "xfs_filestream.h"
8371 #include "xfs_vnodeops.h"
8375 +xfs_get_inode_flags(
8378 + struct inode *inode = VFS_I(ip);
8379 + unsigned int flags = inode->i_flags;
8380 + unsigned int vflags = inode->i_vflags;
8382 + if (flags & S_IMMUTABLE)
8383 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8385 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8386 + if (flags & S_IXUNLINK)
8387 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8389 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8391 + if (vflags & V_BARRIER)
8392 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8394 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8395 + if (vflags & V_COW)
8396 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8398 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8405 + struct xfs_mount *mp = ip->i_mount;
8406 + struct xfs_trans *tp;
8407 + unsigned int lock_flags = 0;
8410 + xfs_itrace_entry(ip);
8412 + if (mp->m_flags & XFS_MOUNT_RDONLY)
8413 + return XFS_ERROR(EROFS);
8416 + * we acquire the inode lock and do an error checking pass.
8418 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8419 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8421 + goto error_return;
8423 + lock_flags = XFS_ILOCK_EXCL;
8424 + xfs_ilock(ip, lock_flags);
8426 + xfs_trans_ijoin(tp, ip, lock_flags);
8427 + xfs_trans_ihold(tp, ip);
8429 + xfs_get_inode_flags(ip);
8430 + // xfs_diflags_to_linux(ip);
8432 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8433 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8435 + XFS_STATS_INC(xs_ig_attrchg);
8438 + * If this is a synchronous mount, make sure that the
8439 + * transaction goes to disk before returning to the user.
8441 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8442 + xfs_trans_set_sync(tp);
8443 + code = xfs_trans_commit(tp, 0);
8444 + xfs_iunlock(ip, lock_flags);
8451 + xfs_trans_cancel(tp, 0);
8453 + xfs_iunlock(ip, lock_flags);
8459 struct xfs_inode *ip,
8460 @@ -68,6 +152,7 @@ xfs_setattr(
8461 uint commit_flags=0;
8462 uid_t uid=0, iuid=0;
8463 gid_t gid=0, igid=0;
8464 + tag_t tag=0, itag=0;
8466 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8467 int need_iolock = 1;
8468 @@ -164,7 +249,7 @@ xfs_setattr(
8470 * Change file ownership. Must be the owner or privileged.
8472 - if (mask & (ATTR_UID|ATTR_GID)) {
8473 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8475 * These IDs could have changed since we last looked at them.
8476 * But, we're assured that if the ownership did change
8477 @@ -173,15 +258,19 @@ xfs_setattr(
8479 iuid = ip->i_d.di_uid;
8480 igid = ip->i_d.di_gid;
8481 + itag = ip->i_d.di_tag;
8482 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8483 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8484 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8487 * Do a quota reservation only if uid/gid is actually
8490 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8491 - (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
8492 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8493 + (XFS_IS_GQUOTA_ON(mp) && itag != tag)) {
8494 + /* TODO: handle tagging? */
8496 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
8497 capable(CAP_FOWNER) ?
8498 @@ -334,7 +423,7 @@ xfs_setattr(
8500 * Change file ownership. Must be the owner or privileged.
8502 - if (mask & (ATTR_UID|ATTR_GID)) {
8503 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8505 * CAP_FSETID overrides the following restrictions:
8507 @@ -350,6 +439,10 @@ xfs_setattr(
8508 * Change the ownerships and register quota modifications
8509 * in the transaction.
8511 + if (itag != tag) {
8512 + ip->i_d.di_tag = tag;
8513 + inode->i_tag = tag;
8516 if (XFS_IS_UQUOTA_ON(mp)) {
8517 ASSERT(mask & ATTR_UID);
8518 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_vnodeops.h linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_vnodeops.h
8519 --- linux-2.6.29/fs/xfs/xfs_vnodeops.h 2009-03-24 14:22:37.000000000 +0100
8520 +++ linux-2.6.29-vs2.3.0.36.9-pre2/fs/xfs/xfs_vnodeops.h 2009-03-24 17:19:30.000000000 +0100
8521 @@ -14,6 +14,7 @@ struct xfs_inode;
8525 +int xfs_sync_xflags(struct xfs_inode *ip);
8526 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8527 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8528 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8529 diff -NurpP --minimal linux-2.6.29/include/asm-generic/tlb.h linux-2.6.29-vs2.3.0.36.9-pre2/include/asm-generic/tlb.h
8530 --- linux-2.6.29/include/asm-generic/tlb.h 2008-12-25 00:26:37.000000000 +0100
8531 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/asm-generic/tlb.h 2009-02-22 22:54:26.000000000 +0100
8533 #define _ASM_GENERIC__TLB_H
8535 #include <linux/swap.h>
8536 +#include <linux/vs_memory.h>
8537 #include <asm/pgalloc.h>
8538 #include <asm/tlbflush.h>
8540 diff -NurpP --minimal linux-2.6.29/include/linux/capability.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/capability.h
8541 --- linux-2.6.29/include/linux/capability.h 2009-03-24 14:22:41.000000000 +0100
8542 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/capability.h 2009-03-24 14:48:35.000000000 +0100
8543 @@ -285,6 +285,7 @@ struct cpu_vfs_cap_data {
8544 arbitrary SCSI commands */
8545 /* Allow setting encryption key on loopback filesystem */
8546 /* Allow setting zone reclaim policy */
8547 +/* Allow the selection of a security context */
8549 #define CAP_SYS_ADMIN 21
8551 @@ -357,7 +358,13 @@ struct cpu_vfs_cap_data {
8553 #define CAP_MAC_ADMIN 33
8555 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8556 +/* Allow context manipulations */
8557 +/* Allow changing context info on files */
8559 +#define CAP_CONTEXT 34
8562 +#define CAP_LAST_CAP CAP_CONTEXT
8564 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8566 diff -NurpP --minimal linux-2.6.29/include/linux/devpts_fs.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/devpts_fs.h
8567 --- linux-2.6.29/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8568 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/devpts_fs.h 2009-02-22 22:54:26.000000000 +0100
8569 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8574 #endif /* _LINUX_DEVPTS_FS_H */
8575 diff -NurpP --minimal linux-2.6.29/include/linux/ext2_fs.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/ext2_fs.h
8576 --- linux-2.6.29/include/linux/ext2_fs.h 2009-03-24 14:22:41.000000000 +0100
8577 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/ext2_fs.h 2009-03-24 15:39:54.000000000 +0100
8578 @@ -189,8 +189,12 @@ struct ext2_group_desc
8579 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8580 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8581 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8582 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8583 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8585 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8586 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8588 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8589 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8591 @@ -271,7 +275,7 @@ struct ext2_inode {
8593 __u8 l_i_frag; /* Fragment number */
8594 __u8 l_i_fsize; /* Fragment size */
8596 + __u16 l_i_tag; /* Context Tag */
8597 __le16 l_i_uid_high; /* these 2 fields */
8598 __le16 l_i_gid_high; /* were reserved2[0] */
8599 __u32 l_i_reserved2;
8600 @@ -303,6 +307,7 @@ struct ext2_inode {
8601 #define i_gid_low i_gid
8602 #define i_uid_high osd2.linux2.l_i_uid_high
8603 #define i_gid_high osd2.linux2.l_i_gid_high
8604 +#define i_raw_tag osd2.linux2.l_i_tag
8605 #define i_reserved2 osd2.linux2.l_i_reserved2
8608 @@ -347,6 +352,7 @@ struct ext2_inode {
8609 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8610 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8611 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8612 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8615 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8616 diff -NurpP --minimal linux-2.6.29/include/linux/ext3_fs.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/ext3_fs.h
8617 --- linux-2.6.29/include/linux/ext3_fs.h 2009-03-24 14:22:41.000000000 +0100
8618 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/ext3_fs.h 2009-03-24 14:48:36.000000000 +0100
8619 @@ -173,10 +173,14 @@ struct ext3_group_desc
8620 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8621 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8622 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8623 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8624 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8626 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8627 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8628 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8629 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8631 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8632 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8634 /* Flags that should be inherited by new inodes from their parent. */
8635 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8636 @@ -316,7 +320,7 @@ struct ext3_inode {
8638 __u8 l_i_frag; /* Fragment number */
8639 __u8 l_i_fsize; /* Fragment size */
8641 + __u16 l_i_tag; /* Context Tag */
8642 __le16 l_i_uid_high; /* these 2 fields */
8643 __le16 l_i_gid_high; /* were reserved2[0] */
8644 __u32 l_i_reserved2;
8645 @@ -350,6 +354,7 @@ struct ext3_inode {
8646 #define i_gid_low i_gid
8647 #define i_uid_high osd2.linux2.l_i_uid_high
8648 #define i_gid_high osd2.linux2.l_i_gid_high
8649 +#define i_raw_tag osd2.linux2.l_i_tag
8650 #define i_reserved2 osd2.linux2.l_i_reserved2
8652 #elif defined(__GNU__)
8653 @@ -413,6 +418,7 @@ struct ext3_inode {
8654 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8655 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8656 * error in ordered mode */
8657 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8659 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8660 #ifndef _LINUX_EXT2_FS_H
8661 @@ -874,6 +880,7 @@ struct buffer_head * ext3_bread (handle_
8662 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
8663 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
8664 int create, int extend_disksize);
8665 +extern int ext3_sync_flags(struct inode *inode);
8667 extern struct inode *ext3_iget(struct super_block *, unsigned long);
8668 extern int ext3_write_inode (struct inode *, int);
8669 diff -NurpP --minimal linux-2.6.29/include/linux/fs.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/fs.h
8670 --- linux-2.6.29/include/linux/fs.h 2009-03-24 14:22:41.000000000 +0100
8671 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/fs.h 2009-03-24 17:21:20.000000000 +0100
8672 @@ -141,6 +141,9 @@ struct inodes_stat_t {
8673 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
8674 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8675 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8676 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
8677 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
8678 +#define MS_NOTAGCHECK (1<<26) /* don't check tags */
8679 #define MS_ACTIVE (1<<30)
8680 #define MS_NOUSER (1<<31)
8682 @@ -167,6 +170,14 @@ struct inodes_stat_t {
8683 #define S_NOCMTIME 128 /* Do not update file c/mtime */
8684 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8685 #define S_PRIVATE 512 /* Inode is fs-internal */
8686 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
8688 +/* Linux-VServer related Inode flags */
8692 +#define V_BARRIER 4 /* Barrier for chroot() */
8693 +#define V_COW 8 /* Copy on Write */
8696 * Note that nosuid etc flags are inode-specific: setting some file-system
8697 @@ -189,12 +200,15 @@ struct inodes_stat_t {
8698 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8699 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8700 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8701 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8702 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8703 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8704 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8705 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8707 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8708 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8709 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8710 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8711 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8712 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8714 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8715 @@ -202,6 +216,16 @@ struct inodes_stat_t {
8716 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8717 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8719 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8721 +#ifdef CONFIG_VSERVER_COWBL
8722 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8723 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8725 +# define IS_COW(inode) (0)
8726 +# define IS_COW_LINK(inode) (0)
8729 /* the read-only stuff doesn't really belong here, but any other place is
8730 probably as bad and I don't want to create yet another include file. */
8732 @@ -279,11 +303,14 @@ struct inodes_stat_t {
8733 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8734 #define FS_EXTENT_FL 0x00080000 /* Extents */
8735 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8736 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8737 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8739 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8740 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8741 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8742 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8744 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8745 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8747 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8748 #define SYNC_FILE_RANGE_WRITE 2
8749 @@ -365,6 +392,7 @@ typedef void (dio_iodone_t)(struct kiocb
8750 #define ATTR_KILL_PRIV (1 << 14)
8751 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8752 #define ATTR_TIMES_SET (1 << 16)
8753 +#define ATTR_TAG (1 << 17)
8756 * This is the Inode Attributes structure, used for notify_change(). It
8757 @@ -380,6 +408,7 @@ struct iattr {
8763 struct timespec ia_atime;
8764 struct timespec ia_mtime;
8765 @@ -393,6 +422,9 @@ struct iattr {
8766 struct file *ia_file;
8769 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8770 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8773 * Includes for diskquotas.
8775 @@ -656,7 +688,9 @@ struct inode {
8776 unsigned int i_nlink;
8784 #ifdef __NEED_I_SIZE_ORDERED
8785 @@ -704,7 +738,8 @@ struct inode {
8786 unsigned long i_state;
8787 unsigned long dirtied_when; /* jiffies of first dirtying */
8789 - unsigned int i_flags;
8790 + unsigned short i_flags;
8791 + unsigned short i_vflags;
8793 atomic_t i_writecount;
8794 #ifdef CONFIG_SECURITY
8795 @@ -791,12 +826,12 @@ static inline void i_size_write(struct i
8797 static inline unsigned iminor(const struct inode *inode)
8799 - return MINOR(inode->i_rdev);
8800 + return MINOR(inode->i_mdev);
8803 static inline unsigned imajor(const struct inode *inode)
8805 - return MAJOR(inode->i_rdev);
8806 + return MAJOR(inode->i_mdev);
8809 extern struct block_device *I_BDEV(struct inode *inode);
8810 @@ -854,6 +889,7 @@ struct file {
8812 struct fown_struct f_owner;
8813 const struct cred *f_cred;
8815 struct file_ra_state f_ra;
8818 @@ -996,6 +1032,7 @@ struct file_lock {
8819 struct file *fl_file;
8824 struct fasync_struct * fl_fasync; /* for lease break notifications */
8825 unsigned long fl_break_time; /* for nonblocking lease breaks */
8826 @@ -1363,6 +1400,7 @@ struct inode_operations {
8828 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8830 + int (*sync_flags) (struct inode *);
8834 @@ -1378,6 +1416,7 @@ extern ssize_t vfs_readv(struct file *,
8835 unsigned long, loff_t *);
8836 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8837 unsigned long, loff_t *);
8838 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8840 struct super_operations {
8841 struct inode *(*alloc_inode)(struct super_block *sb);
8842 @@ -2096,6 +2135,7 @@ extern int dcache_dir_open(struct inode
8843 extern int dcache_dir_close(struct inode *, struct file *);
8844 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8845 extern int dcache_readdir(struct file *, void *, filldir_t);
8846 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8847 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8848 extern int simple_statfs(struct dentry *, struct kstatfs *);
8849 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
8850 diff -NurpP --minimal linux-2.6.29/include/linux/if_tun.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/if_tun.h
8851 --- linux-2.6.29/include/linux/if_tun.h 2008-12-25 00:26:37.000000000 +0100
8852 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/if_tun.h 2009-02-22 22:54:26.000000000 +0100
8854 #define TUNSETOFFLOAD _IOW('T', 208, unsigned int)
8855 #define TUNSETTXFILTER _IOW('T', 209, unsigned int)
8856 #define TUNGETIFF _IOR('T', 210, unsigned int)
8857 +#define TUNSETNID _IOW('T', 215, int)
8859 /* TUNSETIFF ifr flags */
8860 #define IFF_TUN 0x0001
8861 diff -NurpP --minimal linux-2.6.29/include/linux/init_task.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/init_task.h
8862 --- linux-2.6.29/include/linux/init_task.h 2009-03-24 14:22:41.000000000 +0100
8863 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/init_task.h 2009-03-24 14:48:36.000000000 +0100
8864 @@ -184,6 +184,10 @@ extern struct cred init_cred;
8866 INIT_TRACE_IRQFLAGS \
8869 + .vx_info = NULL, \
8871 + .nx_info = NULL, \
8875 diff -NurpP --minimal linux-2.6.29/include/linux/interrupt.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/interrupt.h
8876 --- linux-2.6.29/include/linux/interrupt.h 2009-03-24 14:22:41.000000000 +0100
8877 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/interrupt.h 2009-03-24 14:48:36.000000000 +0100
8879 #include <linux/cpumask.h>
8880 #include <linux/irqreturn.h>
8881 #include <linux/irqnr.h>
8882 -#include <linux/hardirq.h>
8883 #include <linux/sched.h>
8884 +#include <linux/hardirq.h>
8885 #include <linux/irqflags.h>
8886 #include <linux/smp.h>
8887 #include <linux/percpu.h>
8888 diff -NurpP --minimal linux-2.6.29/include/linux/ipc.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/ipc.h
8889 --- linux-2.6.29/include/linux/ipc.h 2008-12-25 00:26:37.000000000 +0100
8890 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/ipc.h 2009-02-22 22:54:26.000000000 +0100
8891 @@ -93,6 +93,7 @@ struct kern_ipc_perm
8899 diff -NurpP --minimal linux-2.6.29/include/linux/Kbuild linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/Kbuild
8900 --- linux-2.6.29/include/linux/Kbuild 2009-03-24 14:22:40.000000000 +0100
8901 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/Kbuild 2009-03-24 17:22:07.000000000 +0100
8902 @@ -373,5 +373,8 @@ unifdef-y += xattr.h
8905 objhdr-y += version.h
8907 +header-y += vserver/
8911 diff -NurpP --minimal linux-2.6.29/include/linux/loop.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/loop.h
8912 --- linux-2.6.29/include/linux/loop.h 2009-03-24 14:22:42.000000000 +0100
8913 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/loop.h 2009-03-24 14:48:36.000000000 +0100
8914 @@ -45,6 +45,7 @@ struct loop_device {
8915 struct loop_func_table *lo_encryption;
8917 uid_t lo_key_owner; /* Who set the key */
8919 int (*ioctl)(struct loop_device *, int cmd,
8922 diff -NurpP --minimal linux-2.6.29/include/linux/magic.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/magic.h
8923 --- linux-2.6.29/include/linux/magic.h 2009-03-24 14:22:42.000000000 +0100
8924 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/magic.h 2009-03-24 14:48:36.000000000 +0100
8927 #define ADFS_SUPER_MAGIC 0xadf5
8928 #define AFFS_SUPER_MAGIC 0xadff
8929 -#define AFS_SUPER_MAGIC 0x5346414F
8930 +#define AFS_SUPER_MAGIC 0x5346414F
8931 #define AUTOFS_SUPER_MAGIC 0x0187
8932 #define CODA_SUPER_MAGIC 0x73757245
8933 #define DEBUGFS_MAGIC 0x64626720
8935 #define NFS_SUPER_MAGIC 0x6969
8936 #define OPENPROM_SUPER_MAGIC 0x9fa1
8937 #define PROC_SUPER_MAGIC 0x9fa0
8938 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8939 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8941 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8942 diff -NurpP --minimal linux-2.6.29/include/linux/major.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/major.h
8943 --- linux-2.6.29/include/linux/major.h 2008-12-25 00:26:37.000000000 +0100
8944 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/major.h 2009-02-22 22:54:26.000000000 +0100
8946 #define HD_MAJOR IDE0_MAJOR
8947 #define PTY_SLAVE_MAJOR 3
8949 +#define VROOT_MAJOR 4
8950 #define TTYAUX_MAJOR 5
8953 diff -NurpP --minimal linux-2.6.29/include/linux/mm_types.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/mm_types.h
8954 --- linux-2.6.29/include/linux/mm_types.h 2009-03-24 14:22:42.000000000 +0100
8955 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/mm_types.h 2009-03-24 14:48:36.000000000 +0100
8956 @@ -232,6 +232,7 @@ struct mm_struct {
8958 /* Architecture-specific MM context */
8959 mm_context_t context;
8960 + struct vx_info *mm_vx_info;
8962 /* Swap token stuff */
8964 diff -NurpP --minimal linux-2.6.29/include/linux/mount.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/mount.h
8965 --- linux-2.6.29/include/linux/mount.h 2008-12-25 00:26:37.000000000 +0100
8966 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/mount.h 2009-02-22 22:54:26.000000000 +0100
8967 @@ -35,6 +35,9 @@ struct mnt_namespace;
8968 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
8969 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
8971 +#define MNT_TAGID 0x10000
8972 +#define MNT_NOTAG 0x20000
8975 struct list_head mnt_hash;
8976 struct vfsmount *mnt_parent; /* fs we are mounted on */
8977 @@ -69,6 +72,7 @@ struct vfsmount {
8978 * are held, and all mnt_writer[]s on this mount have 0 as their ->count
8980 atomic_t __mnt_writers;
8981 + tag_t mnt_tag; /* tagging used for vfsmount */
8984 static inline struct vfsmount *mntget(struct vfsmount *mnt)
8985 diff -NurpP --minimal linux-2.6.29/include/linux/net.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/net.h
8986 --- linux-2.6.29/include/linux/net.h 2008-12-25 00:26:37.000000000 +0100
8987 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/net.h 2009-02-22 22:54:26.000000000 +0100
8988 @@ -68,6 +68,7 @@ struct net;
8989 #define SOCK_NOSPACE 2
8990 #define SOCK_PASSCRED 3
8991 #define SOCK_PASSSEC 4
8992 +#define SOCK_USER_SOCKET 5
8994 #ifndef ARCH_HAS_SOCKET_TYPES
8996 diff -NurpP --minimal linux-2.6.29/include/linux/nfs_mount.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/nfs_mount.h
8997 --- linux-2.6.29/include/linux/nfs_mount.h 2009-03-24 14:22:43.000000000 +0100
8998 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/nfs_mount.h 2009-03-24 14:48:36.000000000 +0100
8999 @@ -63,7 +63,8 @@ struct nfs_mount_data {
9000 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9001 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9002 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9003 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9004 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9005 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9007 /* The following are for internal use only */
9008 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
9009 diff -NurpP --minimal linux-2.6.29/include/linux/nsproxy.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/nsproxy.h
9010 --- linux-2.6.29/include/linux/nsproxy.h 2009-03-24 14:22:43.000000000 +0100
9011 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/nsproxy.h 2009-03-24 14:48:36.000000000 +0100
9014 #include <linux/spinlock.h>
9015 #include <linux/sched.h>
9016 +#include <linux/vserver/debug.h>
9018 struct mnt_namespace;
9019 struct uts_namespace;
9020 @@ -62,22 +63,33 @@ static inline struct nsproxy *task_nspro
9023 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9024 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9025 void exit_task_namespaces(struct task_struct *tsk);
9026 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9027 void free_nsproxy(struct nsproxy *ns);
9028 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9029 struct fs_struct *);
9031 -static inline void put_nsproxy(struct nsproxy *ns)
9032 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9034 +static inline void __get_nsproxy(struct nsproxy *ns,
9035 + const char *_file, int _line)
9037 - if (atomic_dec_and_test(&ns->count)) {
9040 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9041 + ns, atomic_read(&ns->count), _file, _line);
9042 + atomic_inc(&ns->count);
9045 -static inline void get_nsproxy(struct nsproxy *ns)
9046 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9048 +static inline void __put_nsproxy(struct nsproxy *ns,
9049 + const char *_file, int _line)
9051 - atomic_inc(&ns->count);
9052 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9053 + ns, atomic_read(&ns->count), _file, _line);
9054 + if (atomic_dec_and_test(&ns->count)) {
9059 #ifdef CONFIG_CGROUP_NS
9060 diff -NurpP --minimal linux-2.6.29/include/linux/pid.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/pid.h
9061 --- linux-2.6.29/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
9062 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/pid.h 2009-03-24 14:48:36.000000000 +0100
9063 @@ -8,7 +8,8 @@ enum pid_type
9073 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9076 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9077 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9078 pid_t pid_vnr(struct pid *pid);
9080 #define do_each_pid_task(pid, type, task) \
9081 diff -NurpP --minimal linux-2.6.29/include/linux/proc_fs.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/proc_fs.h
9082 --- linux-2.6.29/include/linux/proc_fs.h 2008-12-25 00:26:37.000000000 +0100
9083 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/proc_fs.h 2009-02-22 22:54:26.000000000 +0100
9084 @@ -59,6 +59,7 @@ struct proc_dir_entry {
9090 const struct inode_operations *proc_iops;
9092 @@ -268,12 +269,18 @@ static inline void kclist_add(struct kco
9093 extern void kclist_add(struct kcore_list *, void *, size_t);
9100 int (*proc_get_link)(struct inode *, struct path *);
9101 int (*proc_read)(struct task_struct *task, char *page);
9102 int (*proc_show)(struct seq_file *m,
9103 struct pid_namespace *ns, struct pid *pid,
9104 struct task_struct *task);
9105 + int (*proc_vs_read)(char *page);
9106 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9107 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9110 struct ctl_table_header;
9111 @@ -281,6 +288,7 @@ struct ctl_table;
9118 struct proc_dir_entry *pde;
9119 diff -NurpP --minimal linux-2.6.29/include/linux/reiserfs_fs.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/reiserfs_fs.h
9120 --- linux-2.6.29/include/linux/reiserfs_fs.h 2008-12-25 00:26:37.000000000 +0100
9121 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/reiserfs_fs.h 2009-02-22 22:54:26.000000000 +0100
9122 @@ -837,6 +837,11 @@ struct stat_data_v1 {
9123 #define REISERFS_COMPR_FL FS_COMPR_FL
9124 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9126 +/* unfortunately reiserfs sdattr is only 16 bit */
9127 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9128 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9129 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9131 /* persistent flags that file inherits from the parent directory */
9132 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9133 REISERFS_SYNC_FL | \
9134 @@ -846,6 +851,9 @@ struct stat_data_v1 {
9135 REISERFS_COMPR_FL | \
9136 REISERFS_NOTAIL_FL )
9138 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9139 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9141 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9144 @@ -1911,6 +1919,7 @@ static inline void reiserfs_update_sd(st
9145 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9146 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9147 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9148 +int reiserfs_sync_flags(struct inode *inode);
9151 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9152 diff -NurpP --minimal linux-2.6.29/include/linux/reiserfs_fs_sb.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/reiserfs_fs_sb.h
9153 --- linux-2.6.29/include/linux/reiserfs_fs_sb.h 2008-12-25 00:26:37.000000000 +0100
9154 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/reiserfs_fs_sb.h 2009-02-22 22:54:26.000000000 +0100
9155 @@ -456,6 +456,7 @@ enum reiserfs_mount_options {
9157 REISERFS_BARRIER_NONE,
9158 REISERFS_BARRIER_FLUSH,
9161 /* Actions on error */
9162 REISERFS_ERROR_PANIC,
9163 diff -NurpP --minimal linux-2.6.29/include/linux/sched.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sched.h
9164 --- linux-2.6.29/include/linux/sched.h 2009-03-24 14:22:43.000000000 +0100
9165 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sched.h 2009-03-24 14:48:36.000000000 +0100
9166 @@ -71,7 +71,6 @@ struct sched_param {
9167 #include <linux/fs_struct.h>
9168 #include <linux/compiler.h>
9169 #include <linux/completion.h>
9170 -#include <linux/pid.h>
9171 #include <linux/percpu.h>
9172 #include <linux/topology.h>
9173 #include <linux/proportions.h>
9174 @@ -88,6 +87,7 @@ struct sched_param {
9175 #include <linux/kobject.h>
9176 #include <linux/latencytop.h>
9177 #include <linux/cred.h>
9178 +#include <linux/pid.h>
9180 #include <asm/processor.h>
9182 @@ -176,12 +176,13 @@ extern unsigned long long time_sync_thre
9183 #define TASK_UNINTERRUPTIBLE 2
9184 #define __TASK_STOPPED 4
9185 #define __TASK_TRACED 8
9186 +#define TASK_ONHOLD 16
9187 /* in tsk->exit_state */
9188 -#define EXIT_ZOMBIE 16
9189 -#define EXIT_DEAD 32
9190 +#define EXIT_ZOMBIE 32
9191 +#define EXIT_DEAD 64
9192 /* in tsk->state again */
9193 -#define TASK_DEAD 64
9194 -#define TASK_WAKEKILL 128
9195 +#define TASK_DEAD 128
9196 +#define TASK_WAKEKILL 256
9198 /* Convenience macros for the sake of set_task_state */
9199 #define TASK_KILLABLE (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
9200 @@ -358,25 +359,28 @@ extern void arch_unmap_area_topdown(stru
9201 * The mm counters are not protected by its page_table_lock,
9202 * so must be incremented atomically.
9204 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9205 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9206 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9207 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9208 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9209 +#define __set_mm_counter(mm, member, value) \
9210 + atomic_long_set(&(mm)->_##member, value)
9211 +#define get_mm_counter(mm, member) \
9212 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9214 #else /* !USE_SPLIT_PTLOCKS */
9216 * The mm counters are protected by its page_table_lock,
9217 * so can be incremented directly.
9219 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9220 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9221 #define get_mm_counter(mm, member) ((mm)->_##member)
9222 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9223 -#define inc_mm_counter(mm, member) (mm)->_##member++
9224 -#define dec_mm_counter(mm, member) (mm)->_##member--
9226 #endif /* !USE_SPLIT_PTLOCKS */
9228 +#define set_mm_counter(mm, member, value) \
9229 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9230 +#define add_mm_counter(mm, member, value) \
9231 + vx_ ## member ## pages_add((mm), (value))
9232 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9233 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9235 #define get_mm_rss(mm) \
9236 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9237 #define update_hiwater_rss(mm) do { \
9238 @@ -1131,7 +1135,9 @@ struct task_struct {
9239 const struct sched_class *sched_class;
9240 struct sched_entity se;
9241 struct sched_rt_entity rt;
9243 +#ifdef CONFIG_VSERVER_HARDCPU
9244 + struct list_head hq;
9246 #ifdef CONFIG_PREEMPT_NOTIFIERS
9247 /* list of struct preempt_notifier: */
9248 struct hlist_head preempt_notifiers;
9249 @@ -1287,6 +1293,14 @@ struct task_struct {
9253 +/* vserver context data */
9254 + struct vx_info *vx_info;
9255 + struct nx_info *nx_info;
9261 /* Thread group tracking */
9264 @@ -1499,6 +1513,11 @@ struct pid_namespace;
9265 * see also pid_nr() etc in include/linux/pid.h
9268 +#include <linux/vserver/base.h>
9269 +#include <linux/vserver/context.h>
9270 +#include <linux/vserver/debug.h>
9271 +#include <linux/vserver/pid.h>
9273 static inline pid_t task_pid_nr(struct task_struct *tsk)
9276 @@ -1508,7 +1527,7 @@ pid_t task_pid_nr_ns(struct task_struct
9278 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9280 - return pid_vnr(task_pid(tsk));
9281 + return vx_map_pid(pid_vnr(task_pid(tsk)));
9285 @@ -1521,7 +1540,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9287 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9289 - return pid_vnr(task_tgid(tsk));
9290 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9294 diff -NurpP --minimal linux-2.6.29/include/linux/shmem_fs.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/shmem_fs.h
9295 --- linux-2.6.29/include/linux/shmem_fs.h 2008-12-25 00:26:37.000000000 +0100
9296 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/shmem_fs.h 2009-02-22 22:54:26.000000000 +0100
9299 #define SHMEM_NR_DIRECT 16
9301 +#define TMPFS_SUPER_MAGIC 0x01021994
9304 struct shmem_inode_info {
9306 unsigned long flags;
9307 diff -NurpP --minimal linux-2.6.29/include/linux/stat.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/stat.h
9308 --- linux-2.6.29/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9309 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/stat.h 2009-02-22 22:54:26.000000000 +0100
9310 @@ -66,6 +66,7 @@ struct kstat {
9317 struct timespec atime;
9318 diff -NurpP --minimal linux-2.6.29/include/linux/sunrpc/auth.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sunrpc/auth.h
9319 --- linux-2.6.29/include/linux/sunrpc/auth.h 2008-12-25 00:26:37.000000000 +0100
9320 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sunrpc/auth.h 2009-02-22 22:54:26.000000000 +0100
9326 struct group_info *group_info;
9327 unsigned char machine_cred : 1;
9329 diff -NurpP --minimal linux-2.6.29/include/linux/sunrpc/clnt.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sunrpc/clnt.h
9330 --- linux-2.6.29/include/linux/sunrpc/clnt.h 2009-03-24 14:22:43.000000000 +0100
9331 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sunrpc/clnt.h 2009-03-24 14:48:36.000000000 +0100
9332 @@ -43,7 +43,8 @@ struct rpc_clnt {
9333 unsigned int cl_softrtry : 1,/* soft timeouts */
9334 cl_discrtry : 1,/* disconnect before retry */
9335 cl_autobind : 1,/* use getport() */
9336 - cl_chatty : 1;/* be verbose */
9337 + cl_chatty : 1,/* be verbose */
9338 + cl_tag : 1;/* context tagging */
9340 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9341 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9342 diff -NurpP --minimal linux-2.6.29/include/linux/syscalls.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/syscalls.h
9343 --- linux-2.6.29/include/linux/syscalls.h 2009-03-24 14:22:43.000000000 +0100
9344 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/syscalls.h 2009-03-24 14:48:36.000000000 +0100
9345 @@ -369,6 +369,8 @@ asmlinkage long sys_symlink(const char _
9346 asmlinkage long sys_unlink(const char __user *pathname);
9347 asmlinkage long sys_rename(const char __user *oldname,
9348 const char __user *newname);
9349 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9351 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9352 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9354 diff -NurpP --minimal linux-2.6.29/include/linux/sysctl.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sysctl.h
9355 --- linux-2.6.29/include/linux/sysctl.h 2008-12-25 00:26:37.000000000 +0100
9356 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sysctl.h 2009-02-22 22:54:26.000000000 +0100
9357 @@ -70,6 +70,7 @@ enum
9358 CTL_ABI=9, /* Binary emulation */
9359 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9360 CTL_ARLAN=254, /* arlan wireless driver */
9361 + CTL_VSERVER=4242, /* Linux-VServer debug */
9362 CTL_S390DBF=5677, /* s390 debug */
9363 CTL_SUNRPC=7249, /* sunrpc debug */
9364 CTL_PM=9899, /* frv power management */
9365 @@ -104,6 +105,7 @@ enum
9367 KERN_PANIC=15, /* int: panic timeout */
9368 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9369 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9371 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9372 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9373 diff -NurpP --minimal linux-2.6.29/include/linux/sysfs.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sysfs.h
9374 --- linux-2.6.29/include/linux/sysfs.h 2008-12-25 00:26:37.000000000 +0100
9375 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/sysfs.h 2009-02-22 22:54:26.000000000 +0100
9377 #include <linux/list.h>
9378 #include <asm/atomic.h>
9380 +#define SYSFS_SUPER_MAGIC 0x62656572
9385 diff -NurpP --minimal linux-2.6.29/include/linux/time.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/time.h
9386 --- linux-2.6.29/include/linux/time.h 2009-03-24 14:22:43.000000000 +0100
9387 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/time.h 2009-02-22 22:54:26.000000000 +0100
9388 @@ -190,6 +190,9 @@ static __always_inline void timespec_add
9389 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9393 +#include <linux/vs_time.h>
9395 #endif /* __KERNEL__ */
9397 #define NFDBITS __NFDBITS
9398 diff -NurpP --minimal linux-2.6.29/include/linux/types.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/types.h
9399 --- linux-2.6.29/include/linux/types.h 2009-03-24 14:22:43.000000000 +0100
9400 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/types.h 2009-03-24 14:48:36.000000000 +0100
9401 @@ -36,6 +36,9 @@ typedef __kernel_uid32_t uid_t;
9402 typedef __kernel_gid32_t gid_t;
9403 typedef __kernel_uid16_t uid16_t;
9404 typedef __kernel_gid16_t gid16_t;
9405 +typedef unsigned int xid_t;
9406 +typedef unsigned int nid_t;
9407 +typedef unsigned int tag_t;
9409 typedef unsigned long uintptr_t;
9411 diff -NurpP --minimal linux-2.6.29/include/linux/vroot.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vroot.h
9412 --- linux-2.6.29/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9413 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vroot.h 2009-02-22 22:54:26.000000000 +0100
9417 + * include/linux/vroot.h
9419 + * written by Herbert Pötzl, 9/11/2002
9420 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9422 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9423 + * Redistribution of this file is permitted under the
9424 + * GNU General Public License.
9427 +#ifndef _LINUX_VROOT_H
9428 +#define _LINUX_VROOT_H
9433 +/* Possible states of device */
9439 +struct vroot_device {
9443 + struct semaphore vr_ctl_mutex;
9444 + struct block_device *vr_device;
9449 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9451 +extern int register_vroot_grb(vroot_grb_func *);
9452 +extern int unregister_vroot_grb(vroot_grb_func *);
9454 +#endif /* __KERNEL__ */
9456 +#define MAX_VROOT_DEFAULT 8
9459 + * IOCTL commands --- we will commandeer 0x56 ('V')
9462 +#define VROOT_SET_DEV 0x5600
9463 +#define VROOT_CLR_DEV 0x5601
9465 +#endif /* _LINUX_VROOT_H */
9466 diff -NurpP --minimal linux-2.6.29/include/linux/vs_base.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_base.h
9467 --- linux-2.6.29/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9468 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_base.h 2009-02-22 22:54:26.000000000 +0100
9473 +#include "vserver/base.h"
9474 +#include "vserver/check.h"
9475 +#include "vserver/debug.h"
9478 +#warning duplicate inclusion
9480 diff -NurpP --minimal linux-2.6.29/include/linux/vs_context.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_context.h
9481 --- linux-2.6.29/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9482 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_context.h 2009-02-22 22:54:26.000000000 +0100
9484 +#ifndef _VS_CONTEXT_H
9485 +#define _VS_CONTEXT_H
9487 +#include "vserver/base.h"
9488 +#include "vserver/check.h"
9489 +#include "vserver/context.h"
9490 +#include "vserver/history.h"
9491 +#include "vserver/debug.h"
9493 +#include <linux/sched.h>
9496 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9498 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9499 + const char *_file, int _line, void *_here)
9504 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9505 + vxi, vxi ? vxi->vx_id : 0,
9506 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9508 + __vxh_get_vx_info(vxi, _here);
9510 + atomic_inc(&vxi->vx_usecnt);
9515 +extern void free_vx_info(struct vx_info *);
9517 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9519 +static inline void __put_vx_info(struct vx_info *vxi,
9520 + const char *_file, int _line, void *_here)
9525 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9526 + vxi, vxi ? vxi->vx_id : 0,
9527 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9529 + __vxh_put_vx_info(vxi, _here);
9531 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9532 + free_vx_info(vxi);
9536 +#define init_vx_info(p, i) \
9537 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9539 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9540 + const char *_file, int _line, void *_here)
9543 + vxlprintk(VXD_CBIT(xid, 3),
9544 + "init_vx_info(%p[#%d.%d])",
9545 + vxi, vxi ? vxi->vx_id : 0,
9546 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9548 + __vxh_init_vx_info(vxi, vxp, _here);
9550 + atomic_inc(&vxi->vx_usecnt);
9556 +#define set_vx_info(p, i) \
9557 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9559 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9560 + const char *_file, int _line, void *_here)
9562 + struct vx_info *vxo;
9567 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9568 + vxi, vxi ? vxi->vx_id : 0,
9569 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9571 + __vxh_set_vx_info(vxi, vxp, _here);
9573 + atomic_inc(&vxi->vx_usecnt);
9574 + vxo = xchg(vxp, vxi);
9579 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9581 +static inline void __clr_vx_info(struct vx_info **vxp,
9582 + const char *_file, int _line, void *_here)
9584 + struct vx_info *vxo;
9586 + vxo = xchg(vxp, NULL);
9590 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9591 + vxo, vxo ? vxo->vx_id : 0,
9592 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9594 + __vxh_clr_vx_info(vxo, vxp, _here);
9596 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9597 + free_vx_info(vxo);
9601 +#define claim_vx_info(v, p) \
9602 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9604 +static inline void __claim_vx_info(struct vx_info *vxi,
9605 + struct task_struct *task,
9606 + const char *_file, int _line, void *_here)
9608 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9609 + vxi, vxi ? vxi->vx_id : 0,
9610 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9611 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9612 + task, _file, _line);
9613 + __vxh_claim_vx_info(vxi, task, _here);
9615 + atomic_inc(&vxi->vx_tasks);
9619 +extern void unhash_vx_info(struct vx_info *);
9621 +#define release_vx_info(v, p) \
9622 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9624 +static inline void __release_vx_info(struct vx_info *vxi,
9625 + struct task_struct *task,
9626 + const char *_file, int _line, void *_here)
9628 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9629 + vxi, vxi ? vxi->vx_id : 0,
9630 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9631 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9632 + task, _file, _line);
9633 + __vxh_release_vx_info(vxi, task, _here);
9637 + if (atomic_dec_and_test(&vxi->vx_tasks))
9638 + unhash_vx_info(vxi);
9642 +#define task_get_vx_info(p) \
9643 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9645 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9646 + const char *_file, int _line, void *_here)
9648 + struct vx_info *vxi;
9651 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9653 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9659 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9661 + if (waitqueue_active(&vxi->vx_wait))
9662 + wake_up_interruptible(&vxi->vx_wait);
9666 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9668 +static inline void __enter_vx_info(struct vx_info *vxi,
9669 + struct vx_info_save *vxis, const char *_file, int _line)
9671 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9672 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9673 + current->xid, current->vx_info, _file, _line);
9674 + vxis->vxi = xchg(¤t->vx_info, vxi);
9675 + vxis->xid = current->xid;
9676 + current->xid = vxi ? vxi->vx_id : 0;
9679 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9681 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9682 + const char *_file, int _line)
9684 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9685 + vxis, vxis->xid, vxis->vxi, current,
9686 + current->xid, current->vx_info, _file, _line);
9687 + (void)xchg(¤t->vx_info, vxis->vxi);
9688 + current->xid = vxis->xid;
9692 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9694 + vxis->vxi = xchg(¤t->vx_info, NULL);
9695 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9698 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9700 + (void)xchg(¤t->xid, vxis->xid);
9701 + (void)xchg(¤t->vx_info, vxis->vxi);
9704 +extern void exit_vx_info(struct task_struct *, int);
9705 +extern void exit_vx_info_early(struct task_struct *, int);
9709 +#warning duplicate inclusion
9711 diff -NurpP --minimal linux-2.6.29/include/linux/vs_cowbl.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_cowbl.h
9712 --- linux-2.6.29/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9713 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_cowbl.h 2009-02-22 22:54:26.000000000 +0100
9715 +#ifndef _VS_COWBL_H
9716 +#define _VS_COWBL_H
9718 +#include <linux/fs.h>
9719 +#include <linux/dcache.h>
9720 +#include <linux/namei.h>
9722 +extern struct dentry *cow_break_link(const char *pathname);
9724 +static inline int cow_check_and_break(struct path *path)
9726 + struct inode *inode = path->dentry->d_inode;
9729 + /* do we need this check? */
9730 + if (IS_RDONLY(inode))
9733 + if (IS_COW(inode)) {
9734 + if (IS_COW_LINK(inode)) {
9735 + struct dentry *new_dentry, *old_dentry = path->dentry;
9738 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9742 + pp = d_path(path, buf, PATH_MAX);
9743 + new_dentry = cow_break_link(pp);
9745 + if (!IS_ERR(new_dentry)) {
9746 + path->dentry = new_dentry;
9749 + error = PTR_ERR(new_dentry);
9751 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9752 + inode->i_ctime = CURRENT_TIME;
9753 + mark_inode_dirty(inode);
9760 +#warning duplicate inclusion
9762 diff -NurpP --minimal linux-2.6.29/include/linux/vs_cvirt.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_cvirt.h
9763 --- linux-2.6.29/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9764 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_cvirt.h 2009-02-22 22:54:26.000000000 +0100
9766 +#ifndef _VS_CVIRT_H
9767 +#define _VS_CVIRT_H
9769 +#include "vserver/cvirt.h"
9770 +#include "vserver/context.h"
9771 +#include "vserver/base.h"
9772 +#include "vserver/check.h"
9773 +#include "vserver/debug.h"
9776 +static inline void vx_activate_task(struct task_struct *p)
9778 + struct vx_info *vxi;
9780 + if ((vxi = p->vx_info)) {
9781 + vx_update_load(vxi);
9782 + atomic_inc(&vxi->cvirt.nr_running);
9786 +static inline void vx_deactivate_task(struct task_struct *p)
9788 + struct vx_info *vxi;
9790 + if ((vxi = p->vx_info)) {
9791 + vx_update_load(vxi);
9792 + atomic_dec(&vxi->cvirt.nr_running);
9796 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9798 + struct vx_info *vxi;
9800 + if ((vxi = p->vx_info))
9801 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9804 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9806 + struct vx_info *vxi;
9808 + if ((vxi = p->vx_info))
9809 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9814 +#warning duplicate inclusion
9816 diff -NurpP --minimal linux-2.6.29/include/linux/vs_device.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_device.h
9817 --- linux-2.6.29/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9818 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_device.h 2009-02-22 22:54:26.000000000 +0100
9820 +#ifndef _VS_DEVICE_H
9821 +#define _VS_DEVICE_H
9823 +#include "vserver/base.h"
9824 +#include "vserver/device.h"
9825 +#include "vserver/debug.h"
9828 +#ifdef CONFIG_VSERVER_DEVICE
9830 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9832 +#define vs_device_perm(v, d, m, p) \
9833 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9838 +int vs_map_device(struct vx_info *vxi,
9839 + dev_t device, dev_t *target, umode_t mode)
9846 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9851 +#define vs_map_chrdev(d, t, p) \
9852 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9853 +#define vs_map_blkdev(d, t, p) \
9854 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9856 +#define vs_chrdev_perm(d, p) \
9857 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9858 +#define vs_blkdev_perm(d, p) \
9859 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9863 +#warning duplicate inclusion
9865 diff -NurpP --minimal linux-2.6.29/include/linux/vs_dlimit.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_dlimit.h
9866 --- linux-2.6.29/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9867 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_dlimit.h 2009-02-22 22:54:26.000000000 +0100
9869 +#ifndef _VS_DLIMIT_H
9870 +#define _VS_DLIMIT_H
9872 +#include <linux/fs.h>
9874 +#include "vserver/dlimit.h"
9875 +#include "vserver/base.h"
9876 +#include "vserver/debug.h"
9879 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9881 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9882 + const char *_file, int _line)
9886 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9887 + dli, dli ? dli->dl_tag : 0,
9888 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9890 + atomic_inc(&dli->dl_usecnt);
9895 +#define free_dl_info(i) \
9896 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9898 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9900 +static inline void __put_dl_info(struct dl_info *dli,
9901 + const char *_file, int _line)
9905 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9906 + dli, dli ? dli->dl_tag : 0,
9907 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9909 + if (atomic_dec_and_test(&dli->dl_usecnt))
9910 + free_dl_info(dli);
9914 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9916 +static inline int __dl_alloc_space(struct super_block *sb,
9917 + tag_t tag, dlsize_t nr, const char *file, int line)
9919 + struct dl_info *dli = NULL;
9924 + dli = locate_dl_info(sb, tag);
9928 + spin_lock(&dli->dl_lock);
9929 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9931 + dli->dl_space_used += nr;
9932 + spin_unlock(&dli->dl_lock);
9935 + vxlprintk(VXD_CBIT(dlim, 1),
9936 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9937 + sb, tag, __dlimit_char(dli), (long long)nr,
9942 +static inline void __dl_free_space(struct super_block *sb,
9943 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9945 + struct dl_info *dli = NULL;
9949 + dli = locate_dl_info(sb, tag);
9953 + spin_lock(&dli->dl_lock);
9954 + if (dli->dl_space_used > nr)
9955 + dli->dl_space_used -= nr;
9957 + dli->dl_space_used = 0;
9958 + spin_unlock(&dli->dl_lock);
9961 + vxlprintk(VXD_CBIT(dlim, 1),
9962 + "FREE (%p,#%d)%c %lld bytes",
9963 + sb, tag, __dlimit_char(dli), (long long)nr,
9967 +static inline int __dl_alloc_inode(struct super_block *sb,
9968 + tag_t tag, const char *_file, int _line)
9970 + struct dl_info *dli;
9973 + dli = locate_dl_info(sb, tag);
9977 + spin_lock(&dli->dl_lock);
9978 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
9980 + dli->dl_inodes_used++;
9981 + spin_unlock(&dli->dl_lock);
9984 + vxlprintk(VXD_CBIT(dlim, 0),
9985 + "ALLOC (%p,#%d)%c inode (%d)",
9986 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9990 +static inline void __dl_free_inode(struct super_block *sb,
9991 + tag_t tag, const char *_file, int _line)
9993 + struct dl_info *dli;
9995 + dli = locate_dl_info(sb, tag);
9999 + spin_lock(&dli->dl_lock);
10000 + if (dli->dl_inodes_used > 1)
10001 + dli->dl_inodes_used--;
10003 + dli->dl_inodes_used = 0;
10004 + spin_unlock(&dli->dl_lock);
10005 + put_dl_info(dli);
10007 + vxlprintk(VXD_CBIT(dlim, 0),
10008 + "FREE (%p,#%d)%c inode",
10009 + sb, tag, __dlimit_char(dli), _file, _line);
10012 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10013 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10014 + const char *_file, int _line)
10016 + struct dl_info *dli;
10017 + uint64_t broot, bfree;
10019 + dli = locate_dl_info(sb, tag);
10023 + spin_lock(&dli->dl_lock);
10024 + broot = (dli->dl_space_total -
10025 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10026 + >> sb->s_blocksize_bits;
10027 + bfree = (dli->dl_space_total - dli->dl_space_used)
10028 + >> sb->s_blocksize_bits;
10029 + spin_unlock(&dli->dl_lock);
10031 + vxlprintk(VXD_CBIT(dlim, 2),
10032 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10033 + (long long)bfree, (long long)broot,
10034 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10036 + if (free_blocks) {
10037 + if (*free_blocks > bfree)
10038 + *free_blocks = bfree;
10040 + if (root_blocks) {
10041 + if (*root_blocks > broot)
10042 + *root_blocks = broot;
10044 + put_dl_info(dli);
10047 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
10048 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10049 + __FILE__, __LINE__ )
10051 +#define DLIMIT_FREE_SPACE(in, bytes) \
10052 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10053 + __FILE__, __LINE__ )
10055 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
10056 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
10057 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10058 + __FILE__, __LINE__ )
10060 +#define DLIMIT_FREE_BLOCK(in, nr) \
10061 + __dl_free_space((in)->i_sb, (in)->i_tag, \
10062 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10063 + __FILE__, __LINE__ )
10066 +#define DLIMIT_ALLOC_INODE(in) \
10067 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10069 +#define DLIMIT_FREE_INODE(in) \
10070 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10073 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
10074 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10078 +#warning duplicate inclusion
10080 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/base.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/base.h
10081 --- linux-2.6.29/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10082 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/base.h 2009-03-25 00:36:15.000000000 +0100
10084 +#ifndef _VX_BASE_H
10085 +#define _VX_BASE_H
10088 +/* context state changes */
10100 +#define vx_task_xid(t) ((t)->xid)
10102 +#define vx_current_xid() vx_task_xid(current)
10104 +#define current_vx_info() (current->vx_info)
10107 +#define nx_task_nid(t) ((t)->nid)
10109 +#define nx_current_nid() nx_task_nid(current)
10111 +#define current_nx_info() (current->nx_info)
10114 +/* generic flag merging */
10116 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10118 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10120 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10122 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10125 +/* context flags */
10127 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10129 +#define vx_current_flags() __vx_flags(current->vx_info)
10131 +#define vx_info_flags(v, m, f) \
10132 + vs_check_flags(__vx_flags(v), m, f)
10134 +#define task_vx_flags(t, m, f) \
10135 + ((t) && vx_info_flags((t)->vx_info, m, f))
10137 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
10140 +/* context caps */
10142 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10144 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
10146 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10148 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
10152 +/* network flags */
10154 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10156 +#define nx_current_flags() __nx_flags(current->nx_info)
10158 +#define nx_info_flags(n, m, f) \
10159 + vs_check_flags(__nx_flags(n), m, f)
10161 +#define task_nx_flags(t, m, f) \
10162 + ((t) && nx_info_flags((t)->nx_info, m, f))
10164 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
10167 +/* network caps */
10169 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10171 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
10173 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10175 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
10178 +/* context mask capabilities */
10180 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10182 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10184 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
10187 +/* context bcap mask */
10189 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10191 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
10194 +/* mask given bcaps */
10196 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10198 +#define vx_mbcaps(c) vx_info_mbcaps(current->vx_info, c)
10201 +/* masked cap_bset */
10203 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10205 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
10208 +#define vx_info_mbcap(v, b) \
10209 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10210 + vx_info_bcaps(v, b) : (b))
10212 +#define task_vx_mbcap(t, b) \
10213 + vx_info_mbcap((t)->vx_info, (t)->b)
10215 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10218 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10220 +#define vx_capable(b, c) (capable(b) || \
10221 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10223 +#define nx_capable(b, c) (capable(b) || \
10224 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10226 +#define vx_current_initpid(n) \
10227 + (current->vx_info && \
10228 + (current->vx_info->vx_initpid == (n)))
10231 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10233 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10236 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10238 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10241 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cacct_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cacct_cmd.h
10242 --- linux-2.6.29/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10243 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cacct_cmd.h 2009-02-22 22:54:26.000000000 +0100
10245 +#ifndef _VX_CACCT_CMD_H
10246 +#define _VX_CACCT_CMD_H
10249 +/* virtual host info name commands */
10251 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10253 +struct vcmd_sock_stat_v0 {
10255 + uint32_t count[3];
10256 + uint64_t total[3];
10262 +#include <linux/compiler.h>
10264 +extern int vc_sock_stat(struct vx_info *, void __user *);
10266 +#endif /* __KERNEL__ */
10267 +#endif /* _VX_CACCT_CMD_H */
10268 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cacct_def.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cacct_def.h
10269 --- linux-2.6.29/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10270 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cacct_def.h 2009-02-22 22:54:26.000000000 +0100
10272 +#ifndef _VX_CACCT_DEF_H
10273 +#define _VX_CACCT_DEF_H
10275 +#include <asm/atomic.h>
10276 +#include <linux/vserver/cacct.h>
10279 +struct _vx_sock_acc {
10280 + atomic_long_t count;
10281 + atomic_long_t total;
10284 +/* context sub struct */
10286 +struct _vx_cacct {
10287 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10288 + atomic_t slab[8];
10289 + atomic_t page[6][8];
10292 +#ifdef CONFIG_VSERVER_DEBUG
10294 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10298 + printk("\t_vx_cacct:");
10299 + for (i = 0; i < 6; i++) {
10300 + struct _vx_sock_acc *ptr = cacct->sock[i];
10302 + printk("\t [%d] =", i);
10303 + for (j = 0; j < 3; j++) {
10304 + printk(" [%d] = %8lu, %8lu", j,
10305 + atomic_long_read(&ptr[j].count),
10306 + atomic_long_read(&ptr[j].total));
10314 +#endif /* _VX_CACCT_DEF_H */
10315 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cacct.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cacct.h
10316 --- linux-2.6.29/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10317 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cacct.h 2009-02-22 22:54:26.000000000 +0100
10319 +#ifndef _VX_CACCT_H
10320 +#define _VX_CACCT_H
10323 +enum sock_acc_field {
10324 + VXA_SOCK_UNSPEC = 0,
10330 + VXA_SOCK_SIZE /* array size */
10333 +#endif /* _VX_CACCT_H */
10334 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cacct_int.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cacct_int.h
10335 --- linux-2.6.29/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10336 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cacct_int.h 2009-02-22 22:54:26.000000000 +0100
10338 +#ifndef _VX_CACCT_INT_H
10339 +#define _VX_CACCT_INT_H
10345 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10347 + return atomic_long_read(&cacct->sock[type][pos].count);
10352 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10354 + return atomic_long_read(&cacct->sock[type][pos].total);
10357 +#endif /* __KERNEL__ */
10358 +#endif /* _VX_CACCT_INT_H */
10359 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/check.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/check.h
10360 --- linux-2.6.29/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10361 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/check.h 2009-02-22 22:54:26.000000000 +0100
10363 +#ifndef _VS_CHECK_H
10364 +#define _VS_CHECK_H
10367 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10369 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10370 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10372 +#define MIN_D_CONTEXT 65536
10375 +/* check conditions */
10377 +#define VS_ADMIN 0x0001
10378 +#define VS_WATCH 0x0002
10379 +#define VS_HIDE 0x0004
10380 +#define VS_HOSTID 0x0008
10382 +#define VS_IDENT 0x0010
10383 +#define VS_EQUIV 0x0020
10384 +#define VS_PARENT 0x0040
10385 +#define VS_CHILD 0x0080
10387 +#define VS_ARG_MASK 0x00F0
10389 +#define VS_DYNAMIC 0x0100
10390 +#define VS_STATIC 0x0200
10392 +#define VS_ATR_MASK 0x0F00
10394 +#ifdef CONFIG_VSERVER_PRIVACY
10395 +#define VS_ADMIN_P (0)
10396 +#define VS_WATCH_P (0)
10398 +#define VS_ADMIN_P VS_ADMIN
10399 +#define VS_WATCH_P VS_WATCH
10402 +#define VS_HARDIRQ 0x1000
10403 +#define VS_SOFTIRQ 0x2000
10404 +#define VS_IRQ 0x4000
10406 +#define VS_IRQ_MASK 0xF000
10408 +#include <linux/hardirq.h>
10411 + * check current context for ADMIN/WATCH and
10412 + * optionally against supplied argument
10414 +static inline int __vs_check(int cid, int id, unsigned int mode)
10416 + if (mode & VS_ARG_MASK) {
10417 + if ((mode & VS_IDENT) && (id == cid))
10420 + if (mode & VS_ATR_MASK) {
10421 + if ((mode & VS_DYNAMIC) &&
10422 + (id >= MIN_D_CONTEXT) &&
10423 + (id <= MAX_S_CONTEXT))
10425 + if ((mode & VS_STATIC) &&
10426 + (id > 1) && (id < MIN_D_CONTEXT))
10429 + if (mode & VS_IRQ_MASK) {
10430 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10432 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10434 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10437 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10438 + ((mode & VS_WATCH) && (cid == 1)) ||
10439 + ((mode & VS_HOSTID) && (id == 0)));
10442 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10444 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10447 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10449 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10452 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/context_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/context_cmd.h
10453 --- linux-2.6.29/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10454 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/context_cmd.h 2009-02-22 22:54:26.000000000 +0100
10456 +#ifndef _VX_CONTEXT_CMD_H
10457 +#define _VX_CONTEXT_CMD_H
10460 +/* vinfo commands */
10462 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10465 +extern int vc_task_xid(uint32_t);
10467 +#endif /* __KERNEL__ */
10469 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10471 +struct vcmd_vx_info_v0 {
10473 + uint32_t initpid;
10474 + /* more to come */
10478 +extern int vc_vx_info(struct vx_info *, void __user *);
10480 +#endif /* __KERNEL__ */
10482 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10484 +struct vcmd_ctx_stat_v0 {
10487 + /* more to come */
10491 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10493 +#endif /* __KERNEL__ */
10495 +/* context commands */
10497 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10498 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10500 +struct vcmd_ctx_create {
10501 + uint64_t flagword;
10504 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10505 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10507 +struct vcmd_ctx_migrate {
10508 + uint64_t flagword;
10512 +extern int vc_ctx_create(uint32_t, void __user *);
10513 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10515 +#endif /* __KERNEL__ */
10518 +/* flag commands */
10520 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10521 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10523 +struct vcmd_ctx_flags_v0 {
10524 + uint64_t flagword;
10529 +extern int vc_get_cflags(struct vx_info *, void __user *);
10530 +extern int vc_set_cflags(struct vx_info *, void __user *);
10532 +#endif /* __KERNEL__ */
10535 +/* context caps commands */
10537 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10538 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10540 +struct vcmd_ctx_caps_v1 {
10546 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10547 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10549 +#endif /* __KERNEL__ */
10552 +/* bcaps commands */
10554 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10555 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10557 +struct vcmd_bcaps {
10563 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10564 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10566 +#endif /* __KERNEL__ */
10571 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10572 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10574 +struct vcmd_badness_v0 {
10579 +extern int vc_get_badness(struct vx_info *, void __user *);
10580 +extern int vc_set_badness(struct vx_info *, void __user *);
10582 +#endif /* __KERNEL__ */
10583 +#endif /* _VX_CONTEXT_CMD_H */
10584 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/context.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/context.h
10585 --- linux-2.6.29/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10586 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/context.h 2009-02-22 22:54:26.000000000 +0100
10588 +#ifndef _VX_CONTEXT_H
10589 +#define _VX_CONTEXT_H
10591 +#include <linux/types.h>
10592 +#include <linux/capability.h>
10595 +/* context flags */
10597 +#define VXF_INFO_SCHED 0x00000002
10598 +#define VXF_INFO_NPROC 0x00000004
10599 +#define VXF_INFO_PRIVATE 0x00000008
10601 +#define VXF_INFO_INIT 0x00000010
10602 +#define VXF_INFO_HIDE 0x00000020
10603 +#define VXF_INFO_ULIMIT 0x00000040
10604 +#define VXF_INFO_NSPACE 0x00000080
10606 +#define VXF_SCHED_HARD 0x00000100
10607 +#define VXF_SCHED_PRIO 0x00000200
10608 +#define VXF_SCHED_PAUSE 0x00000400
10610 +#define VXF_VIRT_MEM 0x00010000
10611 +#define VXF_VIRT_UPTIME 0x00020000
10612 +#define VXF_VIRT_CPU 0x00040000
10613 +#define VXF_VIRT_LOAD 0x00080000
10614 +#define VXF_VIRT_TIME 0x00100000
10616 +#define VXF_HIDE_MOUNT 0x01000000
10617 +/* was VXF_HIDE_NETIF 0x02000000 */
10618 +#define VXF_HIDE_VINFO 0x04000000
10620 +#define VXF_STATE_SETUP (1ULL << 32)
10621 +#define VXF_STATE_INIT (1ULL << 33)
10622 +#define VXF_STATE_ADMIN (1ULL << 34)
10624 +#define VXF_SC_HELPER (1ULL << 36)
10625 +#define VXF_REBOOT_KILL (1ULL << 37)
10626 +#define VXF_PERSISTENT (1ULL << 38)
10628 +#define VXF_FORK_RSS (1ULL << 48)
10629 +#define VXF_PROLIFIC (1ULL << 49)
10631 +#define VXF_IGNEG_NICE (1ULL << 52)
10633 +#define VXF_ONE_TIME (0x0007ULL << 32)
10635 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10638 +/* context migration */
10640 +#define VXM_SET_INIT 0x00000001
10641 +#define VXM_SET_REAPER 0x00000002
10643 +/* context caps */
10645 +#define VXC_CAP_MASK 0x00000000
10647 +#define VXC_SET_UTSNAME 0x00000001
10648 +#define VXC_SET_RLIMIT 0x00000002
10649 +#define VXC_FS_SECURITY 0x00000004
10651 +/* was VXC_RAW_ICMP 0x00000100 */
10652 +#define VXC_SYSLOG 0x00001000
10654 +#define VXC_SECURE_MOUNT 0x00010000
10655 +#define VXC_SECURE_REMOUNT 0x00020000
10656 +#define VXC_BINARY_MOUNT 0x00040000
10658 +#define VXC_QUOTA_CTL 0x00100000
10659 +#define VXC_ADMIN_MAPPER 0x00200000
10660 +#define VXC_ADMIN_CLOOP 0x00400000
10662 +#define VXC_KTHREAD 0x01000000
10667 +#include <linux/list.h>
10668 +#include <linux/spinlock.h>
10669 +#include <linux/rcupdate.h>
10671 +#include "limit_def.h"
10672 +#include "sched_def.h"
10673 +#include "cvirt_def.h"
10674 +#include "cacct_def.h"
10675 +#include "device_def.h"
10677 +#define VX_SPACES 2
10679 +struct _vx_info_pc {
10680 + struct _vx_sched_pc sched_pc;
10681 + struct _vx_cvirt_pc cvirt_pc;
10685 + struct hlist_node vx_hlist; /* linked list of contexts */
10686 + xid_t vx_id; /* context id */
10687 + atomic_t vx_usecnt; /* usage count */
10688 + atomic_t vx_tasks; /* tasks count */
10689 + struct vx_info *vx_parent; /* parent context */
10690 + int vx_state; /* context state */
10692 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
10693 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
10694 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
10696 + uint64_t vx_flags; /* context flags */
10697 + uint64_t vx_ccaps; /* context caps (vserver) */
10698 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10699 + // kernel_cap_t vx_cap_bset; /* the guest's bset */
10701 + struct task_struct *vx_reaper; /* guest reaper process */
10702 + pid_t vx_initpid; /* PID of guest init */
10703 + int64_t vx_badness_bias; /* OOM points bias */
10705 + struct _vx_limit limit; /* vserver limits */
10706 + struct _vx_sched sched; /* vserver scheduler */
10707 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10708 + struct _vx_cacct cacct; /* context accounting */
10710 + struct _vx_device dmap; /* default device map targets */
10712 +#ifndef CONFIG_SMP
10713 + struct _vx_info_pc info_pc; /* per cpu data */
10715 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10718 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10719 + int reboot_cmd; /* last sys_reboot() cmd */
10720 + int exit_code; /* last process exit code */
10722 + char vx_name[65]; /* vserver name */
10725 +#ifndef CONFIG_SMP
10726 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10727 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10729 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10730 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10733 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10736 +struct vx_info_save {
10737 + struct vx_info *vxi;
10742 +/* status flags */
10744 +#define VXS_HASHED 0x0001
10745 +#define VXS_PAUSED 0x0010
10746 +#define VXS_SHUTDOWN 0x0100
10747 +#define VXS_HELPER 0x1000
10748 +#define VXS_RELEASED 0x8000
10751 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10752 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10754 +extern struct vx_info *lookup_vx_info(int);
10755 +extern struct vx_info *lookup_or_create_vx_info(int);
10757 +extern int get_xid_list(int, unsigned int *, int);
10758 +extern int xid_is_hashed(xid_t);
10760 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10762 +extern long vs_state_change(struct vx_info *, unsigned int);
10765 +#endif /* __KERNEL__ */
10766 +#endif /* _VX_CONTEXT_H */
10767 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cvirt_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cvirt_cmd.h
10768 --- linux-2.6.29/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
10769 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cvirt_cmd.h 2009-02-22 22:54:26.000000000 +0100
10771 +#ifndef _VX_CVIRT_CMD_H
10772 +#define _VX_CVIRT_CMD_H
10775 +/* virtual host info name commands */
10777 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
10778 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
10780 +struct vcmd_vhi_name_v0 {
10786 +enum vhi_name_field {
10787 + VHIN_CONTEXT = 0,
10799 +#include <linux/compiler.h>
10801 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10802 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10804 +#endif /* __KERNEL__ */
10806 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
10808 +struct vcmd_virt_stat_v0 {
10811 + uint32_t nr_threads;
10812 + uint32_t nr_running;
10813 + uint32_t nr_uninterruptible;
10814 + uint32_t nr_onhold;
10815 + uint32_t nr_forks;
10816 + uint32_t load[3];
10820 +extern int vc_virt_stat(struct vx_info *, void __user *);
10822 +#endif /* __KERNEL__ */
10823 +#endif /* _VX_CVIRT_CMD_H */
10824 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cvirt_def.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cvirt_def.h
10825 --- linux-2.6.29/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
10826 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cvirt_def.h 2009-02-22 22:54:26.000000000 +0100
10828 +#ifndef _VX_CVIRT_DEF_H
10829 +#define _VX_CVIRT_DEF_H
10831 +#include <linux/jiffies.h>
10832 +#include <linux/spinlock.h>
10833 +#include <linux/wait.h>
10834 +#include <linux/time.h>
10835 +#include <asm/atomic.h>
10838 +struct _vx_usage_stat {
10842 + uint64_t softirq;
10848 +struct _vx_syslog {
10849 + wait_queue_head_t log_wait;
10850 + spinlock_t logbuf_lock; /* lock for the log buffer */
10852 + unsigned long log_start; /* next char to be read by syslog() */
10853 + unsigned long con_start; /* next char to be sent to consoles */
10854 + unsigned long log_end; /* most-recently-written-char + 1 */
10855 + unsigned long logged_chars; /* #chars since last read+clear operation */
10857 + char log_buf[1024];
10861 +/* context sub struct */
10863 +struct _vx_cvirt {
10864 + atomic_t nr_threads; /* number of current threads */
10865 + atomic_t nr_running; /* number of running threads */
10866 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10868 + atomic_t nr_onhold; /* processes on hold */
10869 + uint32_t onhold_last; /* jiffies when put on hold */
10871 + struct timeval bias_tv; /* time offset to the host */
10872 + struct timespec bias_idle;
10873 + struct timespec bias_uptime; /* context creation point */
10874 + uint64_t bias_clock; /* offset in clock_t */
10876 + spinlock_t load_lock; /* lock for the load averages */
10877 + atomic_t load_updates; /* nr of load updates done so far */
10878 + uint32_t load_last; /* last time load was calculated */
10879 + uint32_t load[3]; /* load averages 1,5,15 */
10881 + atomic_t total_forks; /* number of forks so far */
10883 + struct _vx_syslog syslog;
10886 +struct _vx_cvirt_pc {
10887 + struct _vx_usage_stat cpustat;
10891 +#ifdef CONFIG_VSERVER_DEBUG
10893 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10895 + printk("\t_vx_cvirt:\n");
10896 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10897 + atomic_read(&cvirt->nr_threads),
10898 + atomic_read(&cvirt->nr_running),
10899 + atomic_read(&cvirt->nr_uninterruptible),
10900 + atomic_read(&cvirt->nr_onhold));
10901 + /* add rest here */
10902 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
10907 +#endif /* _VX_CVIRT_DEF_H */
10908 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cvirt.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cvirt.h
10909 --- linux-2.6.29/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
10910 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/cvirt.h 2009-02-22 22:54:26.000000000 +0100
10912 +#ifndef _VX_CVIRT_H
10913 +#define _VX_CVIRT_H
10920 +void vx_vsi_uptime(struct timespec *, struct timespec *);
10925 +void vx_update_load(struct vx_info *);
10928 +int vx_do_syslog(int, char __user *, int);
10930 +#endif /* __KERNEL__ */
10931 +#endif /* _VX_CVIRT_H */
10932 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/debug_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/debug_cmd.h
10933 --- linux-2.6.29/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
10934 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/debug_cmd.h 2009-02-22 22:54:26.000000000 +0100
10936 +#ifndef _VX_DEBUG_CMD_H
10937 +#define _VX_DEBUG_CMD_H
10940 +/* debug commands */
10942 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
10944 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
10945 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
10947 +struct vcmd_read_history_v0 {
10950 + char __user *data;
10953 +struct vcmd_read_monitor_v0 {
10956 + char __user *data;
10962 +#ifdef CONFIG_COMPAT
10964 +#include <asm/compat.h>
10966 +struct vcmd_read_history_v0_x32 {
10969 + compat_uptr_t data_ptr;
10972 +struct vcmd_read_monitor_v0_x32 {
10975 + compat_uptr_t data_ptr;
10978 +#endif /* CONFIG_COMPAT */
10980 +extern int vc_dump_history(uint32_t);
10982 +extern int vc_read_history(uint32_t, void __user *);
10983 +extern int vc_read_monitor(uint32_t, void __user *);
10985 +#ifdef CONFIG_COMPAT
10987 +extern int vc_read_history_x32(uint32_t, void __user *);
10988 +extern int vc_read_monitor_x32(uint32_t, void __user *);
10990 +#endif /* CONFIG_COMPAT */
10992 +#endif /* __KERNEL__ */
10993 +#endif /* _VX_DEBUG_CMD_H */
10994 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/debug.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/debug.h
10995 --- linux-2.6.29/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
10996 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/debug.h 2009-02-22 22:54:26.000000000 +0100
10998 +#ifndef _VX_DEBUG_H
10999 +#define _VX_DEBUG_H
11002 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11003 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11004 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11006 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11007 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11008 +#define VXF_DEV "%p[%lu,%d:%d]"
11011 +#define vxd_path(p) \
11012 + ({ static char _buffer[PATH_MAX]; \
11013 + d_path(p, _buffer, sizeof(_buffer)); })
11015 +#define vxd_cond_path(n) \
11016 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11019 +#ifdef CONFIG_VSERVER_DEBUG
11021 +extern unsigned int vx_debug_switch;
11022 +extern unsigned int vx_debug_xid;
11023 +extern unsigned int vx_debug_nid;
11024 +extern unsigned int vx_debug_tag;
11025 +extern unsigned int vx_debug_net;
11026 +extern unsigned int vx_debug_limit;
11027 +extern unsigned int vx_debug_cres;
11028 +extern unsigned int vx_debug_dlim;
11029 +extern unsigned int vx_debug_quota;
11030 +extern unsigned int vx_debug_cvirt;
11031 +extern unsigned int vx_debug_space;
11032 +extern unsigned int vx_debug_misc;
11035 +#define VX_LOGLEVEL "vxD: "
11036 +#define VX_PROC_FMT "%p: "
11037 +#define VX_PROCESS current
11039 +#define vxdprintk(c, f, x...) \
11042 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11043 + VX_PROCESS , ##x); \
11046 +#define vxlprintk(c, f, x...) \
11049 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11052 +#define vxfprintk(c, f, x...) \
11055 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11061 +void dump_vx_info(struct vx_info *, int);
11062 +void dump_vx_info_inactive(int);
11064 +#else /* CONFIG_VSERVER_DEBUG */
11066 +#define vx_debug_switch 0
11067 +#define vx_debug_xid 0
11068 +#define vx_debug_nid 0
11069 +#define vx_debug_tag 0
11070 +#define vx_debug_net 0
11071 +#define vx_debug_limit 0
11072 +#define vx_debug_cres 0
11073 +#define vx_debug_dlim 0
11074 +#define vx_debug_cvirt 0
11076 +#define vxdprintk(x...) do { } while (0)
11077 +#define vxlprintk(x...) do { } while (0)
11078 +#define vxfprintk(x...) do { } while (0)
11080 +#endif /* CONFIG_VSERVER_DEBUG */
11083 +#ifdef CONFIG_VSERVER_WARN
11085 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11086 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11087 +#define VX_WARN_XID "[xid #%u] "
11088 +#define VX_WARN_NID "[nid #%u] "
11089 +#define VX_WARN_TAG "[tag #%u] "
11091 +#define vxwprintk(c, f, x...) \
11094 + printk(VX_WARNLEVEL f "\n", ##x); \
11097 +#else /* CONFIG_VSERVER_WARN */
11099 +#define vxwprintk(x...) do { } while (0)
11101 +#endif /* CONFIG_VSERVER_WARN */
11103 +#define vxwprintk_task(c, f, x...) \
11104 + vxwprintk(c, VX_WARN_TASK f, \
11105 + current->comm, current->pid, \
11106 + current->xid, current->nid, current->tag, ##x)
11107 +#define vxwprintk_xid(c, f, x...) \
11108 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11109 +#define vxwprintk_nid(c, f, x...) \
11110 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11111 +#define vxwprintk_tag(c, f, x...) \
11112 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11114 +#ifdef CONFIG_VSERVER_DEBUG
11115 +#define vxd_assert_lock(l) assert_spin_locked(l)
11116 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11117 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11119 +#define vxd_assert_lock(l) do { } while (0)
11120 +#define vxd_assert(c, f, x...) do { } while (0)
11124 +#endif /* _VX_DEBUG_H */
11125 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/device_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/device_cmd.h
11126 --- linux-2.6.29/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11127 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/device_cmd.h 2009-02-22 22:54:26.000000000 +0100
11129 +#ifndef _VX_DEVICE_CMD_H
11130 +#define _VX_DEVICE_CMD_H
11133 +/* device vserver commands */
11135 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11136 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11138 +struct vcmd_set_mapping_v0 {
11139 + const char __user *device;
11140 + const char __user *target;
11147 +#ifdef CONFIG_COMPAT
11149 +#include <asm/compat.h>
11151 +struct vcmd_set_mapping_v0_x32 {
11152 + compat_uptr_t device_ptr;
11153 + compat_uptr_t target_ptr;
11157 +#endif /* CONFIG_COMPAT */
11159 +#include <linux/compiler.h>
11161 +extern int vc_set_mapping(struct vx_info *, void __user *);
11162 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11164 +#ifdef CONFIG_COMPAT
11166 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11167 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11169 +#endif /* CONFIG_COMPAT */
11171 +#endif /* __KERNEL__ */
11172 +#endif /* _VX_DEVICE_CMD_H */
11173 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/device_def.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/device_def.h
11174 --- linux-2.6.29/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11175 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/device_def.h 2009-02-22 22:54:26.000000000 +0100
11177 +#ifndef _VX_DEVICE_DEF_H
11178 +#define _VX_DEVICE_DEF_H
11180 +#include <linux/types.h>
11182 +struct vx_dmap_target {
11187 +struct _vx_device {
11188 +#ifdef CONFIG_VSERVER_DEVICE
11189 + struct vx_dmap_target targets[2];
11193 +#endif /* _VX_DEVICE_DEF_H */
11194 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/device.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/device.h
11195 --- linux-2.6.29/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11196 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/device.h 2009-02-22 22:54:26.000000000 +0100
11198 +#ifndef _VX_DEVICE_H
11199 +#define _VX_DEVICE_H
11202 +#define DATTR_CREATE 0x00000001
11203 +#define DATTR_OPEN 0x00000002
11205 +#define DATTR_REMAP 0x00000010
11207 +#define DATTR_MASK 0x00000013
11210 +#else /* _VX_DEVICE_H */
11211 +#warning duplicate inclusion
11212 +#endif /* _VX_DEVICE_H */
11213 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/dlimit_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/dlimit_cmd.h
11214 --- linux-2.6.29/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11215 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/dlimit_cmd.h 2009-02-22 22:54:26.000000000 +0100
11217 +#ifndef _VX_DLIMIT_CMD_H
11218 +#define _VX_DLIMIT_CMD_H
11221 +/* dlimit vserver commands */
11223 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11224 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11226 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11227 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11229 +struct vcmd_ctx_dlimit_base_v0 {
11230 + const char __user *name;
11234 +struct vcmd_ctx_dlimit_v0 {
11235 + const char __user *name;
11236 + uint32_t space_used; /* used space in kbytes */
11237 + uint32_t space_total; /* maximum space in kbytes */
11238 + uint32_t inodes_used; /* used inodes */
11239 + uint32_t inodes_total; /* maximum inodes */
11240 + uint32_t reserved; /* reserved for root in % */
11244 +#define CDLIM_UNSET ((uint32_t)0UL)
11245 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11246 +#define CDLIM_KEEP ((uint32_t)~1UL)
11250 +#ifdef CONFIG_COMPAT
11252 +#include <asm/compat.h>
11254 +struct vcmd_ctx_dlimit_base_v0_x32 {
11255 + compat_uptr_t name_ptr;
11259 +struct vcmd_ctx_dlimit_v0_x32 {
11260 + compat_uptr_t name_ptr;
11261 + uint32_t space_used; /* used space in kbytes */
11262 + uint32_t space_total; /* maximum space in kbytes */
11263 + uint32_t inodes_used; /* used inodes */
11264 + uint32_t inodes_total; /* maximum inodes */
11265 + uint32_t reserved; /* reserved for root in % */
11269 +#endif /* CONFIG_COMPAT */
11271 +#include <linux/compiler.h>
11273 +extern int vc_add_dlimit(uint32_t, void __user *);
11274 +extern int vc_rem_dlimit(uint32_t, void __user *);
11276 +extern int vc_set_dlimit(uint32_t, void __user *);
11277 +extern int vc_get_dlimit(uint32_t, void __user *);
11279 +#ifdef CONFIG_COMPAT
11281 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11282 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11284 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11285 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11287 +#endif /* CONFIG_COMPAT */
11289 +#endif /* __KERNEL__ */
11290 +#endif /* _VX_DLIMIT_CMD_H */
11291 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/dlimit.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/dlimit.h
11292 --- linux-2.6.29/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11293 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/dlimit.h 2009-02-22 22:54:26.000000000 +0100
11295 +#ifndef _VX_DLIMIT_H
11296 +#define _VX_DLIMIT_H
11298 +#include "switch.h"
11303 +/* keep in sync with CDLIM_INFINITY */
11305 +#define DLIM_INFINITY (~0ULL)
11307 +#include <linux/spinlock.h>
11308 +#include <linux/rcupdate.h>
11310 +struct super_block;
11313 + struct hlist_node dl_hlist; /* linked list of contexts */
11314 + struct rcu_head dl_rcu; /* the rcu head */
11315 + tag_t dl_tag; /* context tag */
11316 + atomic_t dl_usecnt; /* usage count */
11317 + atomic_t dl_refcnt; /* reference count */
11319 + struct super_block *dl_sb; /* associated superblock */
11321 + spinlock_t dl_lock; /* protect the values */
11323 + unsigned long long dl_space_used; /* used space in bytes */
11324 + unsigned long long dl_space_total; /* maximum space in bytes */
11325 + unsigned long dl_inodes_used; /* used inodes */
11326 + unsigned long dl_inodes_total; /* maximum inodes */
11328 + unsigned int dl_nrlmult; /* non root limit mult */
11333 +extern void rcu_free_dl_info(struct rcu_head *);
11334 +extern void unhash_dl_info(struct dl_info *);
11336 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11341 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11343 +typedef uint64_t dlsize_t;
11345 +#endif /* __KERNEL__ */
11346 +#else /* _VX_DLIMIT_H */
11347 +#warning duplicate inclusion
11348 +#endif /* _VX_DLIMIT_H */
11349 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/global.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/global.h
11350 --- linux-2.6.29/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11351 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/global.h 2009-02-22 22:54:26.000000000 +0100
11353 +#ifndef _VX_GLOBAL_H
11354 +#define _VX_GLOBAL_H
11357 +extern atomic_t vx_global_ctotal;
11358 +extern atomic_t vx_global_cactive;
11360 +extern atomic_t nx_global_ctotal;
11361 +extern atomic_t nx_global_cactive;
11363 +extern atomic_t vs_global_nsproxy;
11364 +extern atomic_t vs_global_fs;
11365 +extern atomic_t vs_global_mnt_ns;
11366 +extern atomic_t vs_global_uts_ns;
11367 +extern atomic_t vs_global_ipc_ns;
11368 +extern atomic_t vs_global_user_ns;
11369 +extern atomic_t vs_global_pid_ns;
11372 +#endif /* _VX_GLOBAL_H */
11373 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/history.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/history.h
11374 --- linux-2.6.29/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11375 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/history.h 2009-02-22 22:54:26.000000000 +0100
11377 +#ifndef _VX_HISTORY_H
11378 +#define _VX_HISTORY_H
11383 + VXH_THROW_OOPS = 1,
11387 + VXH_INIT_VX_INFO,
11390 + VXH_CLAIM_VX_INFO,
11391 + VXH_RELEASE_VX_INFO,
11392 + VXH_ALLOC_VX_INFO,
11393 + VXH_DEALLOC_VX_INFO,
11394 + VXH_HASH_VX_INFO,
11395 + VXH_UNHASH_VX_INFO,
11397 + VXH_LOOKUP_VX_INFO,
11398 + VXH_CREATE_VX_INFO,
11401 +struct _vxhe_vxi {
11402 + struct vx_info *ptr;
11408 +struct _vxhe_set_clr {
11412 +struct _vxhe_loc_lookup {
11416 +struct _vx_hist_entry {
11418 + unsigned short seq;
11419 + unsigned short type;
11420 + struct _vxhe_vxi vxi;
11422 + struct _vxhe_set_clr sc;
11423 + struct _vxhe_loc_lookup ll;
11427 +#ifdef CONFIG_VSERVER_HISTORY
11429 +extern unsigned volatile int vxh_active;
11431 +struct _vx_hist_entry *vxh_advance(void *loc);
11435 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11437 + entry->vxi.ptr = vxi;
11439 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11440 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11441 + entry->vxi.xid = vxi->vx_id;
11446 +#define __HERE__ current_text_addr()
11448 +#define __VXH_BODY(__type, __data, __here) \
11449 + struct _vx_hist_entry *entry; \
11451 + preempt_disable(); \
11452 + entry = vxh_advance(__here); \
11454 + entry->type = __type; \
11455 + preempt_enable();
11458 + /* pass vxi only */
11460 +#define __VXH_SMPL \
11461 + __vxh_copy_vxi(entry, vxi)
11464 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11466 + __VXH_BODY(__type, __VXH_SMPL, __here)
11469 + /* pass vxi and data (void *) */
11471 +#define __VXH_DATA \
11472 + __vxh_copy_vxi(entry, vxi); \
11473 + entry->sc.data = data
11476 +void __vxh_data(struct vx_info *vxi, void *data,
11477 + int __type, void *__here)
11479 + __VXH_BODY(__type, __VXH_DATA, __here)
11482 + /* pass vxi and arg (long) */
11484 +#define __VXH_LONG \
11485 + __vxh_copy_vxi(entry, vxi); \
11486 + entry->ll.arg = arg
11489 +void __vxh_long(struct vx_info *vxi, long arg,
11490 + int __type, void *__here)
11492 + __VXH_BODY(__type, __VXH_LONG, __here)
11497 +void __vxh_throw_oops(void *__here)
11499 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11500 + /* prevent further acquisition */
11505 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11507 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11508 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11510 +#define __vxh_init_vx_info(v, d, h) \
11511 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11512 +#define __vxh_set_vx_info(v, d, h) \
11513 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11514 +#define __vxh_clr_vx_info(v, d, h) \
11515 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11517 +#define __vxh_claim_vx_info(v, d, h) \
11518 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11519 +#define __vxh_release_vx_info(v, d, h) \
11520 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11522 +#define vxh_alloc_vx_info(v) \
11523 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11524 +#define vxh_dealloc_vx_info(v) \
11525 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11527 +#define vxh_hash_vx_info(v) \
11528 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11529 +#define vxh_unhash_vx_info(v) \
11530 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11532 +#define vxh_loc_vx_info(v, l) \
11533 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11534 +#define vxh_lookup_vx_info(v, l) \
11535 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11536 +#define vxh_create_vx_info(v, l) \
11537 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11539 +extern void vxh_dump_history(void);
11542 +#else /* CONFIG_VSERVER_HISTORY */
11544 +#define __HERE__ 0
11546 +#define vxh_throw_oops() do { } while (0)
11548 +#define __vxh_get_vx_info(v, h) do { } while (0)
11549 +#define __vxh_put_vx_info(v, h) do { } while (0)
11551 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11552 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11553 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11555 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11556 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11558 +#define vxh_alloc_vx_info(v) do { } while (0)
11559 +#define vxh_dealloc_vx_info(v) do { } while (0)
11561 +#define vxh_hash_vx_info(v) do { } while (0)
11562 +#define vxh_unhash_vx_info(v) do { } while (0)
11564 +#define vxh_loc_vx_info(v, l) do { } while (0)
11565 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11566 +#define vxh_create_vx_info(v, l) do { } while (0)
11568 +#define vxh_dump_history() do { } while (0)
11571 +#endif /* CONFIG_VSERVER_HISTORY */
11573 +#endif /* _VX_HISTORY_H */
11574 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/inode_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/inode_cmd.h
11575 --- linux-2.6.29/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11576 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/inode_cmd.h 2009-02-22 22:54:26.000000000 +0100
11578 +#ifndef _VX_INODE_CMD_H
11579 +#define _VX_INODE_CMD_H
11582 +/* inode vserver commands */
11584 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11585 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11587 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11588 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11590 +struct vcmd_ctx_iattr_v1 {
11591 + const char __user *name;
11597 +struct vcmd_ctx_fiattr_v0 {
11607 +#ifdef CONFIG_COMPAT
11609 +#include <asm/compat.h>
11611 +struct vcmd_ctx_iattr_v1_x32 {
11612 + compat_uptr_t name_ptr;
11618 +#endif /* CONFIG_COMPAT */
11620 +#include <linux/compiler.h>
11622 +extern int vc_get_iattr(void __user *);
11623 +extern int vc_set_iattr(void __user *);
11625 +extern int vc_fget_iattr(uint32_t, void __user *);
11626 +extern int vc_fset_iattr(uint32_t, void __user *);
11628 +#ifdef CONFIG_COMPAT
11630 +extern int vc_get_iattr_x32(void __user *);
11631 +extern int vc_set_iattr_x32(void __user *);
11633 +#endif /* CONFIG_COMPAT */
11635 +#endif /* __KERNEL__ */
11636 +#endif /* _VX_INODE_CMD_H */
11637 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/inode.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/inode.h
11638 --- linux-2.6.29/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11639 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/inode.h 2009-02-22 22:54:26.000000000 +0100
11641 +#ifndef _VX_INODE_H
11642 +#define _VX_INODE_H
11645 +#define IATTR_TAG 0x01000000
11647 +#define IATTR_ADMIN 0x00000001
11648 +#define IATTR_WATCH 0x00000002
11649 +#define IATTR_HIDE 0x00000004
11650 +#define IATTR_FLAGS 0x00000007
11652 +#define IATTR_BARRIER 0x00010000
11653 +#define IATTR_IXUNLINK 0x00020000
11654 +#define IATTR_IMMUTABLE 0x00040000
11659 +#ifdef CONFIG_VSERVER_PROC_SECURE
11660 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11661 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11663 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11664 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11667 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11669 +#endif /* __KERNEL__ */
11671 +/* inode ioctls */
11673 +#define FIOC_GETXFLG _IOR('x', 5, long)
11674 +#define FIOC_SETXFLG _IOW('x', 6, long)
11676 +#else /* _VX_INODE_H */
11677 +#warning duplicate inclusion
11678 +#endif /* _VX_INODE_H */
11679 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/Kbuild linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/Kbuild
11680 --- linux-2.6.29/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11681 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/Kbuild 2009-02-22 22:54:26.000000000 +0100
11684 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11685 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11686 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11687 + debug_cmd.h device_cmd.h
11689 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11691 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/limit_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/limit_cmd.h
11692 --- linux-2.6.29/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11693 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/limit_cmd.h 2009-02-22 22:54:26.000000000 +0100
11695 +#ifndef _VX_LIMIT_CMD_H
11696 +#define _VX_LIMIT_CMD_H
11699 +/* rlimit vserver commands */
11701 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
11702 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
11703 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
11704 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
11706 +struct vcmd_ctx_rlimit_v0 {
11708 + uint64_t minimum;
11709 + uint64_t softlimit;
11710 + uint64_t maximum;
11713 +struct vcmd_ctx_rlimit_mask_v0 {
11714 + uint32_t minimum;
11715 + uint32_t softlimit;
11716 + uint32_t maximum;
11719 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
11721 +struct vcmd_rlimit_stat_v0 {
11725 + uint64_t minimum;
11726 + uint64_t maximum;
11729 +#define CRLIM_UNSET (0ULL)
11730 +#define CRLIM_INFINITY (~0ULL)
11731 +#define CRLIM_KEEP (~1ULL)
11735 +#ifdef CONFIG_IA32_EMULATION
11737 +struct vcmd_ctx_rlimit_v0_x32 {
11739 + uint64_t minimum;
11740 + uint64_t softlimit;
11741 + uint64_t maximum;
11742 +} __attribute__ ((packed));
11744 +#endif /* CONFIG_IA32_EMULATION */
11746 +#include <linux/compiler.h>
11748 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11749 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11750 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11751 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11753 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11755 +#ifdef CONFIG_IA32_EMULATION
11757 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11758 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11760 +#endif /* CONFIG_IA32_EMULATION */
11762 +#endif /* __KERNEL__ */
11763 +#endif /* _VX_LIMIT_CMD_H */
11764 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/limit_def.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/limit_def.h
11765 --- linux-2.6.29/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
11766 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/limit_def.h 2009-02-22 22:54:26.000000000 +0100
11768 +#ifndef _VX_LIMIT_DEF_H
11769 +#define _VX_LIMIT_DEF_H
11771 +#include <asm/atomic.h>
11772 +#include <asm/resource.h>
11774 +#include "limit.h"
11777 +struct _vx_res_limit {
11778 + rlim_t soft; /* Context soft limit */
11779 + rlim_t hard; /* Context hard limit */
11781 + rlim_atomic_t rcur; /* Current value */
11782 + rlim_t rmin; /* Context minimum */
11783 + rlim_t rmax; /* Context maximum */
11785 + atomic_t lhit; /* Limit hits */
11788 +/* context sub struct */
11790 +struct _vx_limit {
11791 + struct _vx_res_limit res[NUM_LIMITS];
11794 +#ifdef CONFIG_VSERVER_DEBUG
11796 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11800 + printk("\t_vx_limit:");
11801 + for (i = 0; i < NUM_LIMITS; i++) {
11802 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11803 + i, (unsigned long)__rlim_get(limit, i),
11804 + (unsigned long)__rlim_rmin(limit, i),
11805 + (unsigned long)__rlim_rmax(limit, i),
11806 + (long)__rlim_soft(limit, i),
11807 + (long)__rlim_hard(limit, i),
11808 + atomic_read(&__rlim_lhit(limit, i)));
11814 +#endif /* _VX_LIMIT_DEF_H */
11815 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/limit.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/limit.h
11816 --- linux-2.6.29/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
11817 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/limit.h 2009-02-22 22:54:26.000000000 +0100
11819 +#ifndef _VX_LIMIT_H
11820 +#define _VX_LIMIT_H
11822 +#define VLIMIT_NSOCK 16
11823 +#define VLIMIT_OPENFD 17
11824 +#define VLIMIT_ANON 18
11825 +#define VLIMIT_SHMEM 19
11826 +#define VLIMIT_SEMARY 20
11827 +#define VLIMIT_NSEMS 21
11828 +#define VLIMIT_DENTRY 22
11829 +#define VLIMIT_MAPPED 23
11834 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11836 +/* keep in sync with CRLIM_INFINITY */
11838 +#define VLIM_INFINITY (~0ULL)
11840 +#include <asm/atomic.h>
11841 +#include <asm/resource.h>
11843 +#ifndef RLIM_INFINITY
11844 +#warning RLIM_INFINITY is undefined
11847 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11849 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11850 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11852 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11853 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11854 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11856 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11857 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11859 +typedef atomic_long_t rlim_atomic_t;
11860 +typedef unsigned long rlim_t;
11862 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11863 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11864 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11865 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11866 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
11867 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
11870 +#if (RLIM_INFINITY == VLIM_INFINITY)
11871 +#define VX_VLIM(r) ((long long)(long)(r))
11872 +#define VX_RLIM(v) ((rlim_t)(v))
11874 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
11875 + ? VLIM_INFINITY : (long long)(r))
11876 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
11877 + ? RLIM_INFINITY : (rlim_t)(v))
11882 +void vx_vsi_meminfo(struct sysinfo *);
11883 +void vx_vsi_swapinfo(struct sysinfo *);
11885 +#define NUM_LIMITS 24
11887 +#endif /* __KERNEL__ */
11888 +#endif /* _VX_LIMIT_H */
11889 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/limit_int.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/limit_int.h
11890 --- linux-2.6.29/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
11891 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/limit_int.h 2009-02-22 22:54:26.000000000 +0100
11893 +#ifndef _VX_LIMIT_INT_H
11894 +#define _VX_LIMIT_INT_H
11896 +#include "context.h"
11900 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
11901 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
11903 +extern const char *vlimit_name[NUM_LIMITS];
11905 +static inline void __vx_acc_cres(struct vx_info *vxi,
11906 + int res, int dir, void *_data, char *_file, int _line)
11908 + if (VXD_RCRES_COND(res))
11909 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
11910 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11911 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11912 + (dir > 0) ? "++" : "--", _data, _file, _line);
11917 + __rlim_inc(&vxi->limit, res);
11919 + __rlim_dec(&vxi->limit, res);
11922 +static inline void __vx_add_cres(struct vx_info *vxi,
11923 + int res, int amount, void *_data, char *_file, int _line)
11925 + if (VXD_RCRES_COND(res))
11926 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
11927 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11928 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11929 + amount, _data, _file, _line);
11934 + __rlim_add(&vxi->limit, res, amount);
11938 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
11940 + int cond = (value > __rlim_rmax(limit, res));
11943 + __rlim_rmax(limit, res) = value;
11948 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
11950 + int cond = (value < __rlim_rmin(limit, res));
11953 + __rlim_rmin(limit, res) = value;
11958 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
11960 + if (!__vx_cres_adjust_max(limit, res, value))
11961 + __vx_cres_adjust_min(limit, res, value);
11966 + +1 ... no limit hit
11967 + -1 ... over soft limit
11968 + 0 ... over hard limit */
11970 +static inline int __vx_cres_avail(struct vx_info *vxi,
11971 + int res, int num, char *_file, int _line)
11973 + struct _vx_limit *limit;
11976 + if (VXD_RLIMIT_COND(res))
11977 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
11978 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11979 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
11980 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
11981 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11982 + num, _file, _line);
11986 + limit = &vxi->limit;
11987 + value = __rlim_get(limit, res);
11989 + if (!__vx_cres_adjust_max(limit, res, value))
11990 + __vx_cres_adjust_min(limit, res, value);
11995 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
11997 + if (value + num <= __rlim_soft(limit, res))
12000 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12002 + if (value + num <= __rlim_hard(limit, res))
12005 + __rlim_hit(limit, res);
12010 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12013 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12015 + rlim_t value, sum = 0;
12018 + while ((res = *array++)) {
12019 + value = __rlim_get(limit, res);
12020 + __vx_cres_fixup(limit, res, value);
12027 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12029 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12030 + int res = *array;
12032 + if (value == __rlim_get(limit, res))
12035 + __rlim_set(limit, res, value);
12036 + /* now adjust min/max */
12037 + if (!__vx_cres_adjust_max(limit, res, value))
12038 + __vx_cres_adjust_min(limit, res, value);
12043 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12044 + const int *array, int num, char *_file, int _line)
12046 + struct _vx_limit *limit;
12047 + rlim_t value = 0;
12055 + limit = &vxi->limit;
12057 + value = __vx_cres_array_sum(limit, array + 1);
12059 + __rlim_set(limit, res, value);
12060 + __vx_cres_fixup(limit, res, value);
12062 + return __vx_cres_avail(vxi, res, num, _file, _line);
12066 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12071 + /* complex resources first */
12072 + if ((id < 0) || (id == RLIMIT_RSS))
12073 + __vx_cres_array_fixup(limit, VLA_RSS);
12075 + for (res = 0; res < NUM_LIMITS; res++) {
12076 + if ((id > 0) && (res != id))
12079 + value = __rlim_get(limit, res);
12080 + __vx_cres_fixup(limit, res, value);
12082 + /* not supposed to happen, maybe warn? */
12083 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12084 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12089 +#endif /* __KERNEL__ */
12090 +#endif /* _VX_LIMIT_INT_H */
12091 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/monitor.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/monitor.h
12092 --- linux-2.6.29/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12093 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/monitor.h 2009-02-22 22:54:26.000000000 +0100
12095 +#ifndef _VX_MONITOR_H
12096 +#define _VX_MONITOR_H
12098 +#include <linux/types.h>
12105 + VXM_UPDATE = 0x20,
12109 + VXM_RQINFO_1 = 0x24,
12112 + VXM_ACTIVATE = 0x40,
12119 + VXM_MIGRATE = 0x48,
12122 + /* all other bits are flags */
12123 + VXM_SCHED = 0x80,
12126 +struct _vxm_update_1 {
12127 + uint32_t tokens_max;
12128 + uint32_t fill_rate;
12129 + uint32_t interval;
12132 +struct _vxm_update_2 {
12133 + uint32_t tokens_min;
12134 + uint32_t fill_rate;
12135 + uint32_t interval;
12138 +struct _vxm_rqinfo_1 {
12139 + uint16_t running;
12143 + uint32_t idle_tokens;
12146 +struct _vxm_rqinfo_2 {
12147 + uint32_t norm_time;
12148 + uint32_t idle_time;
12149 + uint32_t idle_skip;
12152 +struct _vxm_sched {
12154 + uint32_t norm_time;
12155 + uint32_t idle_time;
12158 +struct _vxm_task {
12163 +struct _vxm_event {
12172 + struct _vxm_task tsk;
12176 +struct _vx_mon_entry {
12180 + struct _vxm_event ev;
12181 + struct _vxm_sched sd;
12182 + struct _vxm_update_1 u1;
12183 + struct _vxm_update_2 u2;
12184 + struct _vxm_rqinfo_1 q1;
12185 + struct _vxm_rqinfo_2 q2;
12190 +#endif /* _VX_MONITOR_H */
12191 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/network_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/network_cmd.h
12192 --- linux-2.6.29/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12193 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/network_cmd.h 2009-02-22 22:54:26.000000000 +0100
12195 +#ifndef _VX_NETWORK_CMD_H
12196 +#define _VX_NETWORK_CMD_H
12199 +/* vinfo commands */
12201 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12204 +extern int vc_task_nid(uint32_t);
12206 +#endif /* __KERNEL__ */
12208 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12210 +struct vcmd_nx_info_v0 {
12212 + /* more to come */
12216 +extern int vc_nx_info(struct nx_info *, void __user *);
12218 +#endif /* __KERNEL__ */
12220 +#include <linux/in.h>
12221 +#include <linux/in6.h>
12223 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12224 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12226 +struct vcmd_net_create {
12227 + uint64_t flagword;
12230 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12232 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12233 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12235 +struct vcmd_net_addr_v0 {
12238 + struct in_addr ip[4];
12239 + struct in_addr mask[4];
12242 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12243 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12245 +struct vcmd_net_addr_ipv4_v1 {
12248 + struct in_addr ip;
12249 + struct in_addr mask;
12252 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12253 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12255 +struct vcmd_net_addr_ipv6_v1 {
12259 + struct in6_addr ip;
12260 + struct in6_addr mask;
12263 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12264 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12266 +struct vcmd_match_ipv4_v0 {
12271 + struct in_addr ip;
12272 + struct in_addr ip2;
12273 + struct in_addr mask;
12276 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12277 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12279 +struct vcmd_match_ipv6_v0 {
12284 + struct in6_addr ip;
12285 + struct in6_addr ip2;
12286 + struct in6_addr mask;
12291 +extern int vc_net_create(uint32_t, void __user *);
12292 +extern int vc_net_migrate(struct nx_info *, void __user *);
12294 +extern int vc_net_add(struct nx_info *, void __user *);
12295 +extern int vc_net_remove(struct nx_info *, void __user *);
12297 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12298 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12300 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12301 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12303 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12304 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12306 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12307 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12309 +#endif /* __KERNEL__ */
12312 +/* flag commands */
12314 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12315 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12317 +struct vcmd_net_flags_v0 {
12318 + uint64_t flagword;
12323 +extern int vc_get_nflags(struct nx_info *, void __user *);
12324 +extern int vc_set_nflags(struct nx_info *, void __user *);
12326 +#endif /* __KERNEL__ */
12329 +/* network caps commands */
12331 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12332 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12334 +struct vcmd_net_caps_v0 {
12340 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12341 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12343 +#endif /* __KERNEL__ */
12344 +#endif /* _VX_CONTEXT_CMD_H */
12345 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/network.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/network.h
12346 --- linux-2.6.29/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12347 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/network.h 2009-02-22 22:54:26.000000000 +0100
12349 +#ifndef _VX_NETWORK_H
12350 +#define _VX_NETWORK_H
12352 +#include <linux/types.h>
12355 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12358 +/* network flags */
12360 +#define NXF_INFO_PRIVATE 0x00000008
12362 +#define NXF_SINGLE_IP 0x00000100
12363 +#define NXF_LBACK_REMAP 0x00000200
12364 +#define NXF_LBACK_ALLOW 0x00000400
12366 +#define NXF_HIDE_NETIF 0x02000000
12367 +#define NXF_HIDE_LBACK 0x04000000
12369 +#define NXF_STATE_SETUP (1ULL << 32)
12370 +#define NXF_STATE_ADMIN (1ULL << 34)
12372 +#define NXF_SC_HELPER (1ULL << 36)
12373 +#define NXF_PERSISTENT (1ULL << 38)
12375 +#define NXF_ONE_TIME (0x0005ULL << 32)
12378 +#define NXF_INIT_SET (__nxf_init_set())
12380 +static inline uint64_t __nxf_init_set(void) {
12381 + return NXF_STATE_ADMIN
12382 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12383 + | NXF_LBACK_REMAP
12386 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12389 + | NXF_HIDE_NETIF;
12393 +/* network caps */
12395 +#define NXC_TUN_CREATE 0x00000001
12397 +#define NXC_RAW_ICMP 0x00000100
12400 +/* address types */
12402 +#define NXA_TYPE_IPV4 0x0001
12403 +#define NXA_TYPE_IPV6 0x0002
12405 +#define NXA_TYPE_NONE 0x0000
12406 +#define NXA_TYPE_ANY 0x00FF
12408 +#define NXA_TYPE_ADDR 0x0010
12409 +#define NXA_TYPE_MASK 0x0020
12410 +#define NXA_TYPE_RANGE 0x0040
12412 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12414 +#define NXA_MOD_BCAST 0x0100
12415 +#define NXA_MOD_LBACK 0x0200
12417 +#define NXA_LOOPBACK 0x1000
12419 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12420 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12424 +#include <linux/list.h>
12425 +#include <linux/spinlock.h>
12426 +#include <linux/rcupdate.h>
12427 +#include <linux/in.h>
12428 +#include <linux/in6.h>
12429 +#include <asm/atomic.h>
12431 +struct nx_addr_v4 {
12432 + struct nx_addr_v4 *next;
12433 + struct in_addr ip[2];
12434 + struct in_addr mask;
12439 +struct nx_addr_v6 {
12440 + struct nx_addr_v6 *next;
12441 + struct in6_addr ip;
12442 + struct in6_addr mask;
12449 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12450 + nid_t nx_id; /* vnet id */
12451 + atomic_t nx_usecnt; /* usage count */
12452 + atomic_t nx_tasks; /* tasks count */
12453 + int nx_state; /* context state */
12455 + uint64_t nx_flags; /* network flag word */
12456 + uint64_t nx_ncaps; /* network capabilities */
12458 + struct in_addr v4_lback; /* Loopback address */
12459 + struct in_addr v4_bcast; /* Broadcast address */
12460 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12461 +#ifdef CONFIG_IPV6
12462 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12464 + char nx_name[65]; /* network context name */
12468 +/* status flags */
12470 +#define NXS_HASHED 0x0001
12471 +#define NXS_SHUTDOWN 0x0100
12472 +#define NXS_RELEASED 0x8000
12474 +extern struct nx_info *lookup_nx_info(int);
12476 +extern int get_nid_list(int, unsigned int *, int);
12477 +extern int nid_is_hashed(nid_t);
12479 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12481 +extern long vs_net_change(struct nx_info *, unsigned int);
12486 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12487 +#ifdef CONFIG_IPV6
12488 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12490 +#define NX_IPV6(n) (0)
12493 +#endif /* __KERNEL__ */
12494 +#endif /* _VX_NETWORK_H */
12495 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/percpu.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/percpu.h
12496 --- linux-2.6.29/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12497 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/percpu.h 2009-02-22 22:54:26.000000000 +0100
12499 +#ifndef _VX_PERCPU_H
12500 +#define _VX_PERCPU_H
12502 +#include "cvirt_def.h"
12503 +#include "sched_def.h"
12505 +struct _vx_percpu {
12506 + struct _vx_cvirt_pc cvirt;
12507 + struct _vx_sched_pc sched;
12510 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12512 +#endif /* _VX_PERCPU_H */
12513 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/pid.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/pid.h
12514 --- linux-2.6.29/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12515 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/pid.h 2009-02-22 22:54:26.000000000 +0100
12517 +#ifndef _VSERVER_PID_H
12518 +#define _VSERVER_PID_H
12520 +/* pid faking stuff */
12522 +#define vx_info_map_pid(v, p) \
12523 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12524 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12525 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
12526 +#define vx_map_tgid(p) vx_map_pid(p)
12528 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12529 + const char *func, const char *file, int line)
12531 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12532 + vxfprintk(VXD_CBIT(cvirt, 2),
12533 + "vx_map_tgid: %p/%llx: %d -> %d",
12534 + vxi, (long long)vxi->vx_flags, pid,
12535 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12536 + func, file, line);
12539 + if (pid == vxi->vx_initpid)
12545 +#define vx_info_rmap_pid(v, p) \
12546 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12547 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
12548 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12550 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12551 + const char *func, const char *file, int line)
12553 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12554 + vxfprintk(VXD_CBIT(cvirt, 2),
12555 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12556 + vxi, (long long)vxi->vx_flags, pid,
12557 + (pid == 1) ? vxi->vx_initpid : pid,
12558 + func, file, line);
12559 + if ((pid == 1) && vxi->vx_initpid)
12560 + return vxi->vx_initpid;
12561 + if (pid == vxi->vx_initpid)
12568 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/sched_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/sched_cmd.h
12569 --- linux-2.6.29/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12570 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/sched_cmd.h 2009-02-22 22:54:26.000000000 +0100
12572 +#ifndef _VX_SCHED_CMD_H
12573 +#define _VX_SCHED_CMD_H
12576 +/* sched vserver commands */
12578 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12579 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12580 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12582 +struct vcmd_set_sched_v2 {
12583 + int32_t fill_rate;
12584 + int32_t interval;
12586 + int32_t tokens_min;
12587 + int32_t tokens_max;
12588 + uint64_t cpu_mask;
12591 +struct vcmd_set_sched_v3 {
12592 + uint32_t set_mask;
12593 + int32_t fill_rate;
12594 + int32_t interval;
12596 + int32_t tokens_min;
12597 + int32_t tokens_max;
12598 + int32_t priority_bias;
12601 +struct vcmd_set_sched_v4 {
12602 + uint32_t set_mask;
12603 + int32_t fill_rate;
12604 + int32_t interval;
12606 + int32_t tokens_min;
12607 + int32_t tokens_max;
12608 + int32_t prio_bias;
12610 + int32_t bucket_id;
12613 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12614 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12616 +struct vcmd_sched_v5 {
12619 + int32_t bucket_id;
12620 + int32_t fill_rate[2];
12621 + int32_t interval[2];
12623 + int32_t tokens_min;
12624 + int32_t tokens_max;
12625 + int32_t prio_bias;
12628 +#define VXSM_FILL_RATE 0x0001
12629 +#define VXSM_INTERVAL 0x0002
12630 +#define VXSM_FILL_RATE2 0x0004
12631 +#define VXSM_INTERVAL2 0x0008
12632 +#define VXSM_TOKENS 0x0010
12633 +#define VXSM_TOKENS_MIN 0x0020
12634 +#define VXSM_TOKENS_MAX 0x0040
12635 +#define VXSM_PRIO_BIAS 0x0100
12637 +#define VXSM_IDLE_TIME 0x0200
12638 +#define VXSM_FORCE 0x0400
12640 +#define VXSM_V3_MASK 0x0173
12641 +#define VXSM_SET_MASK 0x01FF
12643 +#define VXSM_CPU_ID 0x1000
12644 +#define VXSM_BUCKET_ID 0x2000
12646 +#define VXSM_MSEC 0x4000
12648 +#define SCHED_KEEP (-2) /* only for v2 */
12652 +#include <linux/compiler.h>
12654 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
12655 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
12656 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
12657 +extern int vc_set_sched(struct vx_info *, void __user *);
12658 +extern int vc_get_sched(struct vx_info *, void __user *);
12660 +#endif /* __KERNEL__ */
12662 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
12664 +struct vcmd_sched_info {
12666 + int32_t bucket_id;
12667 + uint64_t user_msec;
12668 + uint64_t sys_msec;
12669 + uint64_t hold_msec;
12670 + uint32_t token_usec;
12671 + int32_t vavavoom;
12676 +extern int vc_sched_info(struct vx_info *, void __user *);
12678 +#endif /* __KERNEL__ */
12679 +#endif /* _VX_SCHED_CMD_H */
12680 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/sched_def.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/sched_def.h
12681 --- linux-2.6.29/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12682 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/sched_def.h 2009-02-22 22:54:26.000000000 +0100
12684 +#ifndef _VX_SCHED_DEF_H
12685 +#define _VX_SCHED_DEF_H
12687 +#include <linux/spinlock.h>
12688 +#include <linux/jiffies.h>
12689 +#include <linux/cpumask.h>
12690 +#include <asm/atomic.h>
12691 +#include <asm/param.h>
12694 +/* context sub struct */
12696 +struct _vx_sched {
12697 + spinlock_t tokens_lock; /* lock for token bucket */
12699 + int tokens; /* number of CPU tokens */
12700 + int fill_rate[2]; /* Fill rate: add X tokens... */
12701 + int interval[2]; /* Divisor: per Y jiffies */
12702 + int tokens_min; /* Limit: minimum for unhold */
12703 + int tokens_max; /* Limit: no more than N tokens */
12705 + int prio_bias; /* bias offset for priority */
12707 + unsigned update_mask; /* which features should be updated */
12708 + cpumask_t update; /* CPUs which should update */
12711 +struct _vx_sched_pc {
12712 + int tokens; /* number of CPU tokens */
12713 + int flags; /* bucket flags */
12715 + int fill_rate[2]; /* Fill rate: add X tokens... */
12716 + int interval[2]; /* Divisor: per Y jiffies */
12717 + int tokens_min; /* Limit: minimum for unhold */
12718 + int tokens_max; /* Limit: no more than N tokens */
12720 + int prio_bias; /* bias offset for priority */
12721 + int vavavoom; /* last calculated vavavoom */
12723 + unsigned long norm_time; /* last time accounted */
12724 + unsigned long idle_time; /* non linear time for fair sched */
12725 + unsigned long token_time; /* token time for accounting */
12726 + unsigned long onhold; /* jiffies when put on hold */
12728 + uint64_t user_ticks; /* token tick events */
12729 + uint64_t sys_ticks; /* token tick events */
12730 + uint64_t hold_ticks; /* token ticks paused */
12734 +#define VXSF_ONHOLD 0x0001
12735 +#define VXSF_IDLE_TIME 0x0100
12737 +#ifdef CONFIG_VSERVER_DEBUG
12739 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12741 + printk("\t_vx_sched:\n");
12742 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
12743 + sched->fill_rate[0], sched->interval[0],
12744 + sched->fill_rate[1], sched->interval[1],
12745 + sched->tokens_min, sched->tokens_max);
12746 + printk("\t priority = %4d\n", sched->prio_bias);
12751 +#endif /* _VX_SCHED_DEF_H */
12752 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/sched.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/sched.h
12753 --- linux-2.6.29/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
12754 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/sched.h 2009-02-22 22:54:26.000000000 +0100
12756 +#ifndef _VX_SCHED_H
12757 +#define _VX_SCHED_H
12764 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12769 +void vx_update_load(struct vx_info *);
12772 +int vx_tokens_recalc(struct _vx_sched_pc *,
12773 + unsigned long *, unsigned long *, int [2]);
12775 +void vx_update_sched_param(struct _vx_sched *sched,
12776 + struct _vx_sched_pc *sched_pc);
12778 +#endif /* __KERNEL__ */
12779 +#else /* _VX_SCHED_H */
12780 +#warning duplicate inclusion
12781 +#endif /* _VX_SCHED_H */
12782 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/signal_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/signal_cmd.h
12783 --- linux-2.6.29/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
12784 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/signal_cmd.h 2009-02-22 22:54:26.000000000 +0100
12786 +#ifndef _VX_SIGNAL_CMD_H
12787 +#define _VX_SIGNAL_CMD_H
12790 +/* signalling vserver commands */
12792 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
12793 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
12795 +struct vcmd_ctx_kill_v0 {
12800 +struct vcmd_wait_exit_v0 {
12801 + int32_t reboot_cmd;
12802 + int32_t exit_code;
12807 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12808 +extern int vc_wait_exit(struct vx_info *, void __user *);
12810 +#endif /* __KERNEL__ */
12812 +/* process alteration commands */
12814 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
12815 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
12817 +struct vcmd_pflags_v0 {
12818 + uint32_t flagword;
12824 +extern int vc_get_pflags(uint32_t pid, void __user *);
12825 +extern int vc_set_pflags(uint32_t pid, void __user *);
12827 +#endif /* __KERNEL__ */
12828 +#endif /* _VX_SIGNAL_CMD_H */
12829 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/signal.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/signal.h
12830 --- linux-2.6.29/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
12831 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/signal.h 2009-02-22 22:54:26.000000000 +0100
12833 +#ifndef _VX_SIGNAL_H
12834 +#define _VX_SIGNAL_H
12841 +int vx_info_kill(struct vx_info *, int, int);
12843 +#endif /* __KERNEL__ */
12844 +#else /* _VX_SIGNAL_H */
12845 +#warning duplicate inclusion
12846 +#endif /* _VX_SIGNAL_H */
12847 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/space_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/space_cmd.h
12848 --- linux-2.6.29/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
12849 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/space_cmd.h 2009-02-22 22:54:26.000000000 +0100
12851 +#ifndef _VX_SPACE_CMD_H
12852 +#define _VX_SPACE_CMD_H
12855 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
12856 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
12857 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
12859 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
12860 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
12861 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
12863 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
12865 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
12866 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
12869 +struct vcmd_space_mask_v1 {
12873 +struct vcmd_space_mask_v2 {
12881 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
12882 +extern int vc_set_space_v1(struct vx_info *, void __user *);
12883 +extern int vc_enter_space(struct vx_info *, void __user *);
12884 +extern int vc_set_space(struct vx_info *, void __user *);
12885 +extern int vc_get_space_mask(void __user *, int);
12887 +#endif /* __KERNEL__ */
12888 +#endif /* _VX_SPACE_CMD_H */
12889 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/space.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/space.h
12890 --- linux-2.6.29/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
12891 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/space.h 2009-02-22 22:54:26.000000000 +0100
12893 +#ifndef _VX_SPACE_H
12894 +#define _VX_SPACE_H
12896 +#include <linux/types.h>
12900 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
12902 +#else /* _VX_SPACE_H */
12903 +#warning duplicate inclusion
12904 +#endif /* _VX_SPACE_H */
12905 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/switch.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/switch.h
12906 --- linux-2.6.29/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
12907 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/switch.h 2009-02-22 22:54:26.000000000 +0100
12909 +#ifndef _VX_SWITCH_H
12910 +#define _VX_SWITCH_H
12912 +#include <linux/types.h>
12915 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
12916 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
12917 +#define VC_VERSION(c) ((c) & 0xFFF)
12919 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
12920 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
12924 + Syscall Matrix V2.8
12926 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
12927 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
12928 + |INFO |SETUP | |MOVE | | | | | |
12929 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12930 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
12931 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
12932 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12933 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
12934 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
12935 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12936 + MEMORY | | | | |MEMCTRL| | |SWAP | |
12937 + | 16| 17| 18| 19| 20| 21| | 22| 23|
12938 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12939 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
12940 + | 24| 25| 26| 27| 28| 29| | 30| 31|
12941 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12942 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
12943 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
12944 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12945 + OTHER |VSTAT | | | | | | |VINFO | |
12946 + | 40| 41| 42| 43| 44| 45| | 46| 47|
12947 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
12948 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
12949 + | 48| 49| 50| 51| 52| 53| | 54| 55|
12950 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12951 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
12952 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
12953 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12957 +#define VC_CAT_VERSION 0
12959 +#define VC_CAT_VSETUP 1
12960 +#define VC_CAT_VHOST 2
12962 +#define VC_CAT_DEVICE 6
12964 +#define VC_CAT_VPROC 9
12965 +#define VC_CAT_PROCALT 10
12966 +#define VC_CAT_PROCMIG 11
12967 +#define VC_CAT_PROCTRL 12
12969 +#define VC_CAT_SCHED 14
12970 +#define VC_CAT_MEMCTRL 20
12972 +#define VC_CAT_VNET 25
12973 +#define VC_CAT_NETALT 26
12974 +#define VC_CAT_NETMIG 27
12975 +#define VC_CAT_NETCTRL 28
12977 +#define VC_CAT_TAGMIG 35
12978 +#define VC_CAT_DLIMIT 36
12979 +#define VC_CAT_INODE 38
12981 +#define VC_CAT_VSTAT 40
12982 +#define VC_CAT_VINFO 46
12983 +#define VC_CAT_EVENT 48
12985 +#define VC_CAT_FLAGS 52
12986 +#define VC_CAT_VSPACE 54
12987 +#define VC_CAT_DEBUG 56
12988 +#define VC_CAT_RLIMIT 60
12990 +#define VC_CAT_SYSTEST 61
12991 +#define VC_CAT_COMPAT 63
12993 +/* query version */
12995 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
12996 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13001 +#include <linux/errno.h>
13003 +#endif /* __KERNEL__ */
13005 +#endif /* _VX_SWITCH_H */
13007 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/tag_cmd.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/tag_cmd.h
13008 --- linux-2.6.29/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13009 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/tag_cmd.h 2009-02-22 22:54:26.000000000 +0100
13011 +#ifndef _VX_TAG_CMD_H
13012 +#define _VX_TAG_CMD_H
13015 +/* vinfo commands */
13017 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13020 +extern int vc_task_tag(uint32_t);
13022 +#endif /* __KERNEL__ */
13024 +/* context commands */
13026 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13029 +extern int vc_tag_migrate(uint32_t);
13031 +#endif /* __KERNEL__ */
13032 +#endif /* _VX_TAG_CMD_H */
13033 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/tag.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/tag.h
13034 --- linux-2.6.29/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13035 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vserver/tag.h 2009-02-22 22:54:26.000000000 +0100
13040 +#include <linux/types.h>
13043 +#define DX_TAG(in) (IS_TAGGED(in))
13046 +#ifdef CONFIG_TAG_NFSD
13047 +#define DX_TAG_NFSD 1
13049 +#define DX_TAG_NFSD 0
13053 +#ifdef CONFIG_TAGGING_NONE
13055 +#define MAX_UID 0xFFFFFFFF
13056 +#define MAX_GID 0xFFFFFFFF
13058 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13060 +#define TAGINO_UID(cond, uid, tag) (uid)
13061 +#define TAGINO_GID(cond, gid, tag) (gid)
13066 +#ifdef CONFIG_TAGGING_GID16
13068 +#define MAX_UID 0xFFFFFFFF
13069 +#define MAX_GID 0x0000FFFF
13071 +#define INOTAG_TAG(cond, uid, gid, tag) \
13072 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13074 +#define TAGINO_UID(cond, uid, tag) (uid)
13075 +#define TAGINO_GID(cond, gid, tag) \
13076 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13081 +#ifdef CONFIG_TAGGING_ID24
13083 +#define MAX_UID 0x00FFFFFF
13084 +#define MAX_GID 0x00FFFFFF
13086 +#define INOTAG_TAG(cond, uid, gid, tag) \
13087 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13089 +#define TAGINO_UID(cond, uid, tag) \
13090 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13091 +#define TAGINO_GID(cond, gid, tag) \
13092 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13097 +#ifdef CONFIG_TAGGING_UID16
13099 +#define MAX_UID 0x0000FFFF
13100 +#define MAX_GID 0xFFFFFFFF
13102 +#define INOTAG_TAG(cond, uid, gid, tag) \
13103 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13105 +#define TAGINO_UID(cond, uid, tag) \
13106 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13107 +#define TAGINO_GID(cond, gid, tag) (gid)
13112 +#ifdef CONFIG_TAGGING_INTERN
13114 +#define MAX_UID 0xFFFFFFFF
13115 +#define MAX_GID 0xFFFFFFFF
13117 +#define INOTAG_TAG(cond, uid, gid, tag) \
13118 + ((cond) ? (tag) : 0)
13120 +#define TAGINO_UID(cond, uid, tag) (uid)
13121 +#define TAGINO_GID(cond, gid, tag) (gid)
13126 +#ifndef CONFIG_TAGGING_NONE
13127 +#define dx_current_fstag(sb) \
13128 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13130 +#define dx_current_fstag(sb) (0)
13133 +#ifndef CONFIG_TAGGING_INTERN
13134 +#define TAGINO_TAG(cond, tag) (0)
13136 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13139 +#define INOTAG_UID(cond, uid, gid) \
13140 + ((cond) ? ((uid) & MAX_UID) : (uid))
13141 +#define INOTAG_GID(cond, uid, gid) \
13142 + ((cond) ? ((gid) & MAX_GID) : (gid))
13145 +static inline uid_t dx_map_uid(uid_t uid)
13147 + if ((uid > MAX_UID) && (uid != -1))
13149 + return (uid & MAX_UID);
13152 +static inline gid_t dx_map_gid(gid_t gid)
13154 + if ((gid > MAX_GID) && (gid != -1))
13156 + return (gid & MAX_GID);
13164 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13166 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13167 + unsigned long *flags);
13169 +#ifdef CONFIG_PROPAGATE
13171 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13173 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13176 +#define dx_propagate_tag(n, i) do { } while (0)
13179 +#endif /* _DX_TAG_H */
13180 diff -NurpP --minimal linux-2.6.29/include/linux/vs_inet6.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_inet6.h
13181 --- linux-2.6.29/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13182 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_inet6.h 2009-03-25 00:46:50.000000000 +0100
13184 +#ifndef _VS_INET6_H
13185 +#define _VS_INET6_H
13187 +#include "vserver/base.h"
13188 +#include "vserver/network.h"
13189 +#include "vserver/debug.h"
13191 +#include <net/ipv6.h>
13193 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
13194 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
13197 +#ifdef CONFIG_IPV6
13200 +int v6_addr_match(struct nx_addr_v6 *nxa,
13201 + const struct in6_addr *addr, uint16_t mask)
13205 + switch (nxa->type & mask) {
13206 + case NXA_TYPE_MASK:
13207 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13209 + case NXA_TYPE_ADDR:
13210 + ret = ipv6_addr_equal(&nxa->ip, addr);
13212 + case NXA_TYPE_ANY:
13216 + vxdprintk(VXD_CBIT(net, 0),
13217 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
13218 + nxa, NXAV6(nxa), addr, mask, ret);
13223 +int v6_addr_in_nx_info(struct nx_info *nxi,
13224 + const struct in6_addr *addr, uint16_t mask)
13226 + struct nx_addr_v6 *nxa;
13231 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13232 + if (v6_addr_match(nxa, addr, mask))
13236 + vxdprintk(VXD_CBIT(net, 0),
13237 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
13238 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
13243 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13245 + /* FIXME: needs full range checks */
13246 + return v6_addr_match(nxa, &addr->ip, mask);
13250 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13252 + struct nx_addr_v6 *ptr;
13254 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13255 + if (v6_nx_addr_match(ptr, nxa, mask))
13262 + * Check if a given address matches for a socket
13264 + * nxi: the socket's nx_info if any
13265 + * addr: to be verified address
13268 +int v6_sock_addr_match (
13269 + struct nx_info *nxi,
13270 + struct inet_sock *inet,
13271 + struct in6_addr *addr)
13273 + struct sock *sk = &inet->sk;
13274 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13276 + if (!ipv6_addr_any(addr) &&
13277 + ipv6_addr_equal(saddr, addr))
13279 + if (ipv6_addr_any(saddr))
13280 + return v6_addr_in_nx_info(nxi, addr, -1);
13285 + * check if address is covered by socket
13287 + * sk: the socket to check against
13288 + * addr: the address in question (must be != 0)
13292 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13294 + struct nx_info *nxi = sk->sk_nx_info;
13295 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13297 + vxdprintk(VXD_CBIT(net, 5),
13298 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
13299 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
13300 + (sk->sk_socket?sk->sk_socket->flags:0));
13302 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13303 + return v6_addr_match(nxa, saddr, -1);
13304 + } else if (nxi) { /* match against nx_info */
13305 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13306 + } else { /* unrestricted any socket */
13312 +/* inet related checks and helpers */
13316 +struct net_device;
13320 +#include <linux/netdevice.h>
13321 +#include <linux/inetdevice.h>
13322 +#include <net/inet_timewait_sock.h>
13325 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13326 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13327 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13332 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13338 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13342 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13344 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13345 + nxi, nxi ? nxi->nx_id : 0, ifa,
13346 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13348 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13350 + if (v6_ifa_in_nx_info(ifa, nxi))
13356 +struct nx_v6_sock_addr {
13357 + struct in6_addr saddr; /* Address used for validation */
13358 + struct in6_addr baddr; /* Address used for socket bind */
13362 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13363 + struct nx_v6_sock_addr *nsa)
13365 + // struct sock *sk = &inet->sk;
13366 + // struct nx_info *nxi = sk->sk_nx_info;
13367 + struct in6_addr saddr = addr->sin6_addr;
13368 + struct in6_addr baddr = saddr;
13370 + nsa->saddr = saddr;
13371 + nsa->baddr = baddr;
13376 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13378 + // struct sock *sk = &inet->sk;
13379 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13381 + // *saddr = nsa->baddr;
13382 + // inet->saddr = nsa->baddr;
13386 +int nx_info_has_v6(struct nx_info *nxi)
13390 + if (NX_IPV6(nxi))
13395 +#else /* CONFIG_IPV6 */
13398 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13405 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13411 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13417 +int nx_info_has_v6(struct nx_info *nxi)
13422 +#endif /* CONFIG_IPV6 */
13424 +#define current_nx_info_has_v6() \
13425 + nx_info_has_v6(current_nx_info())
13428 +#warning duplicate inclusion
13430 diff -NurpP --minimal linux-2.6.29/include/linux/vs_inet.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_inet.h
13431 --- linux-2.6.29/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13432 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_inet.h 2009-02-22 22:54:26.000000000 +0100
13434 +#ifndef _VS_INET_H
13435 +#define _VS_INET_H
13437 +#include "vserver/base.h"
13438 +#include "vserver/network.h"
13439 +#include "vserver/debug.h"
13441 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13443 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13444 + NIPQUAD((a)->mask), (a)->type
13445 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13449 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13451 + __be32 ip = nxa->ip[0].s_addr;
13452 + __be32 mask = nxa->mask.s_addr;
13453 + __be32 bcast = ip | ~mask;
13456 + switch (nxa->type & tmask) {
13457 + case NXA_TYPE_MASK:
13458 + ret = (ip == (addr & mask));
13460 + case NXA_TYPE_ADDR:
13464 + /* fall through to broadcast */
13465 + case NXA_MOD_BCAST:
13466 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13468 + case NXA_TYPE_RANGE:
13469 + ret = ((nxa->ip[0].s_addr <= addr) &&
13470 + (nxa->ip[1].s_addr > addr));
13472 + case NXA_TYPE_ANY:
13477 + vxdprintk(VXD_CBIT(net, 0),
13478 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13479 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13484 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13486 + struct nx_addr_v4 *nxa;
13493 + /* allow 127.0.0.1 when remapping lback */
13494 + if ((tmask & NXA_LOOPBACK) &&
13495 + (addr == IPI_LOOPBACK) &&
13496 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13499 + /* check for lback address */
13500 + if ((tmask & NXA_MOD_LBACK) &&
13501 + (nxi->v4_lback.s_addr == addr))
13504 + /* check for broadcast address */
13505 + if ((tmask & NXA_MOD_BCAST) &&
13506 + (nxi->v4_bcast.s_addr == addr))
13509 + /* check for v4 addresses */
13510 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13511 + if (v4_addr_match(nxa, addr, tmask))
13515 + vxdprintk(VXD_CBIT(net, 0),
13516 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13517 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13522 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13524 + /* FIXME: needs full range checks */
13525 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13529 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13531 + struct nx_addr_v4 *ptr;
13533 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13534 + if (v4_nx_addr_match(ptr, nxa, mask))
13539 +#include <net/inet_sock.h>
13542 + * Check if a given address matches for a socket
13544 + * nxi: the socket's nx_info if any
13545 + * addr: to be verified address
13548 +int v4_sock_addr_match (
13549 + struct nx_info *nxi,
13550 + struct inet_sock *inet,
13553 + __be32 saddr = inet->rcv_saddr;
13554 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13556 + if (addr && (saddr == addr || bcast == addr))
13559 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13564 +/* inet related checks and helpers */
13568 +struct net_device;
13571 +#ifdef CONFIG_INET
13573 +#include <linux/netdevice.h>
13574 +#include <linux/inetdevice.h>
13575 +#include <net/inet_sock.h>
13576 +#include <net/inet_timewait_sock.h>
13579 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13580 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13581 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13585 + * check if address is covered by socket
13587 + * sk: the socket to check against
13588 + * addr: the address in question (must be != 0)
13592 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13594 + struct nx_info *nxi = sk->sk_nx_info;
13595 + __be32 saddr = inet_rcv_saddr(sk);
13597 + vxdprintk(VXD_CBIT(net, 5),
13598 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13599 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13600 + (sk->sk_socket?sk->sk_socket->flags:0));
13602 + if (saddr) { /* direct address match */
13603 + return v4_addr_match(nxa, saddr, -1);
13604 + } else if (nxi) { /* match against nx_info */
13605 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13606 + } else { /* unrestricted any socket */
13614 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13616 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13617 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13618 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13620 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13622 + if (dev_in_nx_info(dev, nxi))
13629 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13635 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13639 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13641 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13642 + nxi, nxi ? nxi->nx_id : 0, ifa,
13643 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13645 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13647 + if (v4_ifa_in_nx_info(ifa, nxi))
13653 +struct nx_v4_sock_addr {
13654 + __be32 saddr; /* Address used for validation */
13655 + __be32 baddr; /* Address used for socket bind */
13659 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13660 + struct nx_v4_sock_addr *nsa)
13662 + struct sock *sk = &inet->sk;
13663 + struct nx_info *nxi = sk->sk_nx_info;
13664 + __be32 saddr = addr->sin_addr.s_addr;
13665 + __be32 baddr = saddr;
13667 + vxdprintk(VXD_CBIT(net, 3),
13668 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13669 + sk, sk->sk_nx_info, sk->sk_socket,
13670 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13674 + if (saddr == INADDR_ANY) {
13675 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13676 + baddr = nxi->v4.ip[0].s_addr;
13677 + } else if (saddr == IPI_LOOPBACK) {
13678 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13679 + baddr = nxi->v4_lback.s_addr;
13680 + } else { /* normal address bind */
13681 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13682 + return -EADDRNOTAVAIL;
13686 + vxdprintk(VXD_CBIT(net, 3),
13687 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13688 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13690 + nsa->saddr = saddr;
13691 + nsa->baddr = baddr;
13696 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
13698 + inet->saddr = nsa->baddr;
13699 + inet->rcv_saddr = nsa->baddr;
13704 + * helper to simplify inet_lookup_listener
13706 + * nxi: the socket's nx_info if any
13707 + * addr: to be verified address
13708 + * saddr: socket address
13710 +static inline int v4_inet_addr_match (
13711 + struct nx_info *nxi,
13715 + if (addr && (saddr == addr))
13718 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
13722 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
13724 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
13725 + (addr == nxi->v4_lback.s_addr))
13726 + return IPI_LOOPBACK;
13731 +int nx_info_has_v4(struct nx_info *nxi)
13735 + if (NX_IPV4(nxi))
13737 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13742 +#else /* CONFIG_INET */
13745 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
13751 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13757 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13763 +int nx_info_has_v4(struct nx_info *nxi)
13768 +#endif /* CONFIG_INET */
13770 +#define current_nx_info_has_v4() \
13771 + nx_info_has_v4(current_nx_info())
13774 +// #warning duplicate inclusion
13776 diff -NurpP --minimal linux-2.6.29/include/linux/vs_limit.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_limit.h
13777 --- linux-2.6.29/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
13778 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_limit.h 2009-02-22 22:54:26.000000000 +0100
13780 +#ifndef _VS_LIMIT_H
13781 +#define _VS_LIMIT_H
13783 +#include "vserver/limit.h"
13784 +#include "vserver/base.h"
13785 +#include "vserver/context.h"
13786 +#include "vserver/debug.h"
13787 +#include "vserver/context.h"
13788 +#include "vserver/limit_int.h"
13791 +#define vx_acc_cres(v, d, p, r) \
13792 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13794 +#define vx_acc_cres_cond(x, d, p, r) \
13795 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13796 + r, d, p, __FILE__, __LINE__)
13799 +#define vx_add_cres(v, a, p, r) \
13800 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13801 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13803 +#define vx_add_cres_cond(x, a, p, r) \
13804 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13805 + r, a, p, __FILE__, __LINE__)
13806 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13809 +/* process and file limits */
13811 +#define vx_nproc_inc(p) \
13812 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13814 +#define vx_nproc_dec(p) \
13815 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13817 +#define vx_files_inc(f) \
13818 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13820 +#define vx_files_dec(f) \
13821 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13823 +#define vx_locks_inc(l) \
13824 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13826 +#define vx_locks_dec(l) \
13827 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13829 +#define vx_openfd_inc(f) \
13830 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
13832 +#define vx_openfd_dec(f) \
13833 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
13836 +#define vx_cres_avail(v, n, r) \
13837 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13840 +#define vx_nproc_avail(n) \
13841 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
13843 +#define vx_files_avail(n) \
13844 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
13846 +#define vx_locks_avail(n) \
13847 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
13849 +#define vx_openfd_avail(n) \
13850 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
13853 +/* dentry limits */
13855 +#define vx_dentry_inc(d) do { \
13856 + if (atomic_read(&d->d_count) == 1) \
13857 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
13860 +#define vx_dentry_dec(d) do { \
13861 + if (atomic_read(&d->d_count) == 0) \
13862 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
13865 +#define vx_dentry_avail(n) \
13866 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
13869 +/* socket limits */
13871 +#define vx_sock_inc(s) \
13872 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
13874 +#define vx_sock_dec(s) \
13875 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
13877 +#define vx_sock_avail(n) \
13878 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
13881 +/* ipc resource limits */
13883 +#define vx_ipcmsg_add(v, u, a) \
13884 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
13886 +#define vx_ipcmsg_sub(v, u, a) \
13887 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
13889 +#define vx_ipcmsg_avail(v, a) \
13890 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
13893 +#define vx_ipcshm_add(v, k, a) \
13894 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13896 +#define vx_ipcshm_sub(v, k, a) \
13897 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13899 +#define vx_ipcshm_avail(v, a) \
13900 + vx_cres_avail(v, a, VLIMIT_SHMEM)
13903 +#define vx_semary_inc(a) \
13904 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
13906 +#define vx_semary_dec(a) \
13907 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
13910 +#define vx_nsems_add(a,n) \
13911 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13913 +#define vx_nsems_sub(a,n) \
13914 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13918 +#warning duplicate inclusion
13920 diff -NurpP --minimal linux-2.6.29/include/linux/vs_memory.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_memory.h
13921 --- linux-2.6.29/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
13922 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_memory.h 2009-02-22 22:54:26.000000000 +0100
13924 +#ifndef _VS_MEMORY_H
13925 +#define _VS_MEMORY_H
13927 +#include "vserver/limit.h"
13928 +#include "vserver/base.h"
13929 +#include "vserver/context.h"
13930 +#include "vserver/debug.h"
13931 +#include "vserver/context.h"
13932 +#include "vserver/limit_int.h"
13935 +#define __acc_add_long(a, v) (*(v) += (a))
13936 +#define __acc_inc_long(v) (++*(v))
13937 +#define __acc_dec_long(v) (--*(v))
13939 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
13940 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
13941 +#define __acc_inc_atomic(v) atomic_long_inc(v)
13942 +#define __acc_dec_atomic(v) atomic_long_dec(v)
13943 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13944 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
13945 +#define __acc_inc_atomic(v) __acc_inc_long(v)
13946 +#define __acc_dec_atomic(v) __acc_dec_long(v)
13947 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13950 +#define vx_acc_page(m, d, v, r) do { \
13952 + __acc_inc_long(&(m)->v); \
13954 + __acc_dec_long(&(m)->v); \
13955 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13958 +#define vx_acc_page_atomic(m, d, v, r) do { \
13960 + __acc_inc_atomic(&(m)->v); \
13962 + __acc_dec_atomic(&(m)->v); \
13963 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13967 +#define vx_acc_pages(m, p, v, r) do { \
13968 + unsigned long __p = (p); \
13969 + __acc_add_long(__p, &(m)->v); \
13970 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13973 +#define vx_acc_pages_atomic(m, p, v, r) do { \
13974 + unsigned long __p = (p); \
13975 + __acc_add_atomic(__p, &(m)->v); \
13976 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13981 +#define vx_acc_vmpage(m, d) \
13982 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
13983 +#define vx_acc_vmlpage(m, d) \
13984 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
13985 +#define vx_acc_file_rsspage(m, d) \
13986 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
13987 +#define vx_acc_anon_rsspage(m, d) \
13988 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
13990 +#define vx_acc_vmpages(m, p) \
13991 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
13992 +#define vx_acc_vmlpages(m, p) \
13993 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
13994 +#define vx_acc_file_rsspages(m, p) \
13995 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
13996 +#define vx_acc_anon_rsspages(m, p) \
13997 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
13999 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
14000 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
14002 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
14003 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
14004 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
14005 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
14007 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
14008 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
14009 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
14010 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
14012 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
14013 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
14014 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
14015 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
14017 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
14018 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
14019 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
14020 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
14023 +#define vx_pages_avail(m, p, r) \
14024 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
14026 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
14027 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
14028 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
14029 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
14031 +#define vx_rss_avail(m, p) \
14032 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
14036 + VXPT_UNKNOWN = 0,
14045 +#define vx_page_fault(mm, vma, type, ret)
14049 +void __vx_page_fault(struct mm_struct *mm,
14050 + struct vm_area_struct *vma, int type, int ret)
14052 + struct vx_info *vxi = mm->mm_vx_info;
14055 + static char *page_type[6] =
14056 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14057 + static char *page_what[4] =
14058 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14064 + what = (ret & 0x3);
14066 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14067 + type, what, ret, page_type[type], page_what[what]);
14069 + if (ret & VM_FAULT_WRITE)
14071 + atomic_inc(&vxi->cacct.page[type][what]);
14074 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14078 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14081 +#warning duplicate inclusion
14083 diff -NurpP --minimal linux-2.6.29/include/linux/vs_network.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_network.h
14084 --- linux-2.6.29/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14085 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_network.h 2009-02-22 22:54:26.000000000 +0100
14087 +#ifndef _NX_VS_NETWORK_H
14088 +#define _NX_VS_NETWORK_H
14090 +#include "vserver/context.h"
14091 +#include "vserver/network.h"
14092 +#include "vserver/base.h"
14093 +#include "vserver/check.h"
14094 +#include "vserver/debug.h"
14096 +#include <linux/sched.h>
14099 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14101 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14102 + const char *_file, int _line)
14107 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14108 + nxi, nxi ? nxi->nx_id : 0,
14109 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14112 + atomic_inc(&nxi->nx_usecnt);
14117 +extern void free_nx_info(struct nx_info *);
14119 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14121 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14126 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14127 + nxi, nxi ? nxi->nx_id : 0,
14128 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14131 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14132 + free_nx_info(nxi);
14136 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14138 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14139 + const char *_file, int _line)
14142 + vxlprintk(VXD_CBIT(nid, 3),
14143 + "init_nx_info(%p[#%d.%d])",
14144 + nxi, nxi ? nxi->nx_id : 0,
14145 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14148 + atomic_inc(&nxi->nx_usecnt);
14154 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14156 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14157 + const char *_file, int _line)
14159 + struct nx_info *nxo;
14164 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14165 + nxi, nxi ? nxi->nx_id : 0,
14166 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14169 + atomic_inc(&nxi->nx_usecnt);
14170 + nxo = xchg(nxp, nxi);
14174 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14176 +static inline void __clr_nx_info(struct nx_info **nxp,
14177 + const char *_file, int _line)
14179 + struct nx_info *nxo;
14181 + nxo = xchg(nxp, NULL);
14185 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14186 + nxo, nxo ? nxo->nx_id : 0,
14187 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14190 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14191 + free_nx_info(nxo);
14195 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14197 +static inline void __claim_nx_info(struct nx_info *nxi,
14198 + struct task_struct *task, const char *_file, int _line)
14200 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14201 + nxi, nxi ? nxi->nx_id : 0,
14202 + nxi?atomic_read(&nxi->nx_usecnt):0,
14203 + nxi?atomic_read(&nxi->nx_tasks):0,
14204 + task, _file, _line);
14206 + atomic_inc(&nxi->nx_tasks);
14210 +extern void unhash_nx_info(struct nx_info *);
14212 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14214 +static inline void __release_nx_info(struct nx_info *nxi,
14215 + struct task_struct *task, const char *_file, int _line)
14217 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14218 + nxi, nxi ? nxi->nx_id : 0,
14219 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14220 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14221 + task, _file, _line);
14225 + if (atomic_dec_and_test(&nxi->nx_tasks))
14226 + unhash_nx_info(nxi);
14230 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14232 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14233 + const char *_file, int _line)
14235 + struct nx_info *nxi;
14238 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14239 + p, _file, _line);
14240 + nxi = __get_nx_info(p->nx_info, _file, _line);
14246 +static inline void exit_nx_info(struct task_struct *p)
14249 + release_nx_info(p->nx_info, p);
14254 +#warning duplicate inclusion
14256 diff -NurpP --minimal linux-2.6.29/include/linux/vs_pid.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_pid.h
14257 --- linux-2.6.29/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14258 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_pid.h 2009-02-22 22:54:26.000000000 +0100
14263 +#include "vserver/base.h"
14264 +#include "vserver/check.h"
14265 +#include "vserver/context.h"
14266 +#include "vserver/debug.h"
14267 +#include "vserver/pid.h"
14268 +#include <linux/pid_namespace.h>
14271 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14274 +int vx_proc_task_visible(struct task_struct *task)
14276 + if ((task->pid == 1) &&
14277 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14278 + /* show a blend through init */
14280 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14287 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14292 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14294 + struct task_struct *task = find_task_by_real_pid(pid);
14296 + if (task && !vx_proc_task_visible(task)) {
14297 + vxdprintk(VXD_CBIT(misc, 6),
14298 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14299 + task, task->xid, task->pid,
14300 + current, current->xid, current->pid);
14309 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14311 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14313 + if (task && !vx_proc_task_visible(task)) {
14314 + vxdprintk(VXD_CBIT(misc, 6),
14315 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14316 + task, task->xid, task->pid,
14317 + current, current->xid, current->pid);
14318 + put_task_struct(task);
14327 +struct task_struct *vx_child_reaper(struct task_struct *p)
14329 + struct vx_info *vxi = p->vx_info;
14330 + struct task_struct *reaper = child_reaper(p);
14335 + BUG_ON(!p->vx_info->vx_reaper);
14337 + /* child reaper for the guest reaper */
14338 + if (vxi->vx_reaper == p)
14341 + reaper = vxi->vx_reaper;
14343 + vxdprintk(VXD_CBIT(xid, 7),
14344 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14345 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14353 +#warning duplicate inclusion
14355 diff -NurpP --minimal linux-2.6.29/include/linux/vs_sched.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_sched.h
14356 --- linux-2.6.29/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14357 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_sched.h 2009-02-22 22:54:26.000000000 +0100
14359 +#ifndef _VS_SCHED_H
14360 +#define _VS_SCHED_H
14362 +#include "vserver/base.h"
14363 +#include "vserver/context.h"
14364 +#include "vserver/sched.h"
14367 +#define VAVAVOOM_RATIO 50
14369 +#define MAX_PRIO_BIAS 20
14370 +#define MIN_PRIO_BIAS -20
14373 +#ifdef CONFIG_VSERVER_HARDCPU
14376 + * effective_prio - return the priority that is based on the static
14377 + * priority but is modified by bonuses/penalties.
14379 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14380 + * into a -4 ... 0 ... +4 bonus/penalty range.
14382 + * Additionally, we scale another amount based on the number of
14383 + * CPU tokens currently held by the context, if the process is
14384 + * part of a context (and the appropriate SCHED flag is set).
14385 + * This ranges from -5 ... 0 ... +15, quadratically.
14387 + * So, the total bonus is -9 .. 0 .. +19
14388 + * We use ~50% of the full 0...39 priority range so that:
14390 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14391 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14392 + * unless that context is far exceeding its CPU allocation.
14394 + * Both properties are important to certain workloads.
14397 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14399 + int vavavoom, max;
14401 + /* lots of tokens = lots of vavavoom
14402 + * no tokens = no vavavoom */
14403 + if ((vavavoom = sched_pc->tokens) >= 0) {
14404 + max = sched_pc->tokens_max;
14405 + vavavoom = max - vavavoom;
14407 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14408 + * (vavavoom*vavavoom - (max >> 2)) / max;
14416 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14418 + struct vx_info *vxi = p->vx_info;
14419 + struct _vx_sched_pc *sched_pc;
14424 + sched_pc = &vx_cpu(vxi, sched_pc);
14425 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14426 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14428 + sched_pc->vavavoom = vavavoom;
14429 + prio += vavavoom;
14431 + prio += sched_pc->prio_bias;
14435 +#else /* !CONFIG_VSERVER_HARDCPU */
14438 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14440 + struct vx_info *vxi = p->vx_info;
14443 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14447 +#endif /* CONFIG_VSERVER_HARDCPU */
14450 +static inline void vx_account_user(struct vx_info *vxi,
14451 + cputime_t cputime, int nice)
14455 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14458 +static inline void vx_account_system(struct vx_info *vxi,
14459 + cputime_t cputime, int idle)
14463 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14467 +#warning duplicate inclusion
14469 diff -NurpP --minimal linux-2.6.29/include/linux/vs_socket.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_socket.h
14470 --- linux-2.6.29/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14471 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_socket.h 2009-02-22 22:54:26.000000000 +0100
14473 +#ifndef _VS_SOCKET_H
14474 +#define _VS_SOCKET_H
14476 +#include "vserver/debug.h"
14477 +#include "vserver/base.h"
14478 +#include "vserver/cacct.h"
14479 +#include "vserver/context.h"
14480 +#include "vserver/tag.h"
14483 +/* socket accounting */
14485 +#include <linux/socket.h>
14487 +static inline int vx_sock_type(int family)
14489 + switch (family) {
14491 + return VXA_SOCK_UNSPEC;
14493 + return VXA_SOCK_UNIX;
14495 + return VXA_SOCK_INET;
14497 + return VXA_SOCK_INET6;
14499 + return VXA_SOCK_PACKET;
14501 + return VXA_SOCK_OTHER;
14505 +#define vx_acc_sock(v, f, p, s) \
14506 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14508 +static inline void __vx_acc_sock(struct vx_info *vxi,
14509 + int family, int pos, int size, char *file, int line)
14512 + int type = vx_sock_type(family);
14514 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14515 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14519 +#define vx_sock_recv(sk, s) \
14520 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14521 +#define vx_sock_send(sk, s) \
14522 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14523 +#define vx_sock_fail(sk, s) \
14524 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14527 +#define sock_vx_init(s) do { \
14528 + (s)->sk_xid = 0; \
14529 + (s)->sk_vx_info = NULL; \
14532 +#define sock_nx_init(s) do { \
14533 + (s)->sk_nid = 0; \
14534 + (s)->sk_nx_info = NULL; \
14538 +#warning duplicate inclusion
14540 diff -NurpP --minimal linux-2.6.29/include/linux/vs_tag.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_tag.h
14541 --- linux-2.6.29/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14542 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_tag.h 2009-02-22 22:54:26.000000000 +0100
14547 +#include <linux/vserver/tag.h>
14549 +/* check conditions */
14551 +#define DX_ADMIN 0x0001
14552 +#define DX_WATCH 0x0002
14553 +#define DX_HOSTID 0x0008
14555 +#define DX_IDENT 0x0010
14557 +#define DX_ARG_MASK 0x0010
14560 +#define dx_task_tag(t) ((t)->tag)
14562 +#define dx_current_tag() dx_task_tag(current)
14564 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14566 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14570 + * check current context for ADMIN/WATCH and
14571 + * optionally against supplied argument
14573 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14575 + if (mode & DX_ARG_MASK) {
14576 + if ((mode & DX_IDENT) && (id == cid))
14579 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14580 + ((mode & DX_WATCH) && (cid == 1)) ||
14581 + ((mode & DX_HOSTID) && (id == 0)));
14585 +int dx_permission(struct inode *inode, int mask);
14589 +#warning duplicate inclusion
14591 diff -NurpP --minimal linux-2.6.29/include/linux/vs_time.h linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_time.h
14592 --- linux-2.6.29/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14593 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/linux/vs_time.h 2009-02-22 22:54:26.000000000 +0100
14595 +#ifndef _VS_TIME_H
14596 +#define _VS_TIME_H
14599 +/* time faking stuff */
14601 +#ifdef CONFIG_VSERVER_VTIME
14603 +extern void vx_gettimeofday(struct timeval *tv);
14604 +extern int vx_settimeofday(struct timespec *ts);
14607 +#define vx_gettimeofday(t) do_gettimeofday(t)
14608 +#define vx_settimeofday(t) do_settimeofday(t)
14612 +#warning duplicate inclusion
14614 diff -NurpP --minimal linux-2.6.29/include/net/addrconf.h linux-2.6.29-vs2.3.0.36.9-pre2/include/net/addrconf.h
14615 --- linux-2.6.29/include/net/addrconf.h 2008-12-25 00:26:37.000000000 +0100
14616 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/net/addrconf.h 2009-02-22 22:54:26.000000000 +0100
14617 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14618 struct net_device *dev,
14619 const struct in6_addr *daddr,
14620 unsigned int srcprefs,
14621 - struct in6_addr *saddr);
14622 + struct in6_addr *saddr,
14623 + struct nx_info *nxi);
14624 extern int ipv6_get_lladdr(struct net_device *dev,
14625 struct in6_addr *addr,
14626 unsigned char banned_flags);
14627 diff -NurpP --minimal linux-2.6.29/include/net/af_unix.h linux-2.6.29-vs2.3.0.36.9-pre2/include/net/af_unix.h
14628 --- linux-2.6.29/include/net/af_unix.h 2008-12-25 00:26:37.000000000 +0100
14629 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/net/af_unix.h 2009-02-22 22:54:26.000000000 +0100
14631 #include <linux/socket.h>
14632 #include <linux/un.h>
14633 #include <linux/mutex.h>
14634 +#include <linux/vs_base.h>
14635 #include <net/sock.h>
14637 extern void unix_inflight(struct file *fp);
14638 diff -NurpP --minimal linux-2.6.29/include/net/inet_timewait_sock.h linux-2.6.29-vs2.3.0.36.9-pre2/include/net/inet_timewait_sock.h
14639 --- linux-2.6.29/include/net/inet_timewait_sock.h 2009-03-24 14:22:44.000000000 +0100
14640 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/net/inet_timewait_sock.h 2009-03-24 14:48:36.000000000 +0100
14641 @@ -15,15 +15,14 @@
14642 #ifndef _INET_TIMEWAIT_SOCK_
14643 #define _INET_TIMEWAIT_SOCK_
14645 +// #include <net/inet_sock.h>
14646 +#include <net/sock.h>
14648 #include <linux/list.h>
14649 #include <linux/module.h>
14650 #include <linux/timer.h>
14651 #include <linux/types.h>
14652 #include <linux/workqueue.h>
14654 -#include <net/inet_sock.h>
14655 -#include <net/sock.h>
14656 #include <net/tcp_states.h>
14657 #include <net/timewait_sock.h>
14659 @@ -116,6 +115,10 @@ struct inet_timewait_sock {
14660 #define tw_hash __tw_common.skc_hash
14661 #define tw_prot __tw_common.skc_prot
14662 #define tw_net __tw_common.skc_net
14663 +#define tw_xid __tw_common.skc_xid
14664 +#define tw_vx_info __tw_common.skc_vx_info
14665 +#define tw_nid __tw_common.skc_nid
14666 +#define tw_nx_info __tw_common.skc_nx_info
14668 volatile unsigned char tw_substate;
14669 /* 3 bits hole, try to pack */
14670 diff -NurpP --minimal linux-2.6.29/include/net/route.h linux-2.6.29-vs2.3.0.36.9-pre2/include/net/route.h
14671 --- linux-2.6.29/include/net/route.h 2008-12-25 00:26:37.000000000 +0100
14672 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/net/route.h 2009-02-22 22:54:26.000000000 +0100
14673 @@ -135,6 +135,9 @@ static inline void ip_rt_put(struct rtab
14674 dst_release(&rt->u.dst);
14677 +#include <linux/vs_base.h>
14678 +#include <linux/vs_inet.h>
14680 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14682 extern const __u8 ip_tos2prio[16];
14683 @@ -144,6 +147,9 @@ static inline char rt_tos2priority(u8 to
14684 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14687 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14688 + struct rtable **, struct flowi *);
14690 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14691 __be32 src, u32 tos, int oif, u8 protocol,
14692 __be16 sport, __be16 dport, struct sock *sk,
14693 @@ -161,11 +167,24 @@ static inline int ip_route_connect(struc
14696 struct net *net = sock_net(sk);
14697 + struct nx_info *nx_info = current->nx_info;
14699 if (inet_sk(sk)->transparent)
14700 fl.flags |= FLOWI_FLAG_ANYSRC;
14702 - if (!dst || !src) {
14704 + nx_info = sk->sk_nx_info;
14706 + vxdprintk(VXD_CBIT(net, 4),
14707 + "ip_route_connect(%p) %p,%p;%lx",
14708 + sk, nx_info, sk->sk_socket,
14709 + (sk->sk_socket?sk->sk_socket->flags:0));
14711 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14715 + if (!fl.fl4_dst || !fl.fl4_src) {
14716 err = __ip_route_output_key(net, rp, &fl);
14719 diff -NurpP --minimal linux-2.6.29/include/net/sock.h linux-2.6.29-vs2.3.0.36.9-pre2/include/net/sock.h
14720 --- linux-2.6.29/include/net/sock.h 2009-03-24 14:22:44.000000000 +0100
14721 +++ linux-2.6.29-vs2.3.0.36.9-pre2/include/net/sock.h 2009-03-24 14:48:36.000000000 +0100
14722 @@ -134,6 +134,10 @@ struct sock_common {
14723 #ifdef CONFIG_NET_NS
14724 struct net *skc_net;
14727 + struct vx_info *skc_vx_info;
14729 + struct nx_info *skc_nx_info;
14733 @@ -218,6 +222,10 @@ struct sock {
14734 #define sk_hash __sk_common.skc_hash
14735 #define sk_prot __sk_common.skc_prot
14736 #define sk_net __sk_common.skc_net
14737 +#define sk_xid __sk_common.skc_xid
14738 +#define sk_vx_info __sk_common.skc_vx_info
14739 +#define sk_nid __sk_common.skc_nid
14740 +#define sk_nx_info __sk_common.skc_nx_info
14741 unsigned char sk_shutdown : 2,
14744 diff -NurpP --minimal linux-2.6.29/init/main.c linux-2.6.29-vs2.3.0.36.9-pre2/init/main.c
14745 --- linux-2.6.29/init/main.c 2009-03-24 14:22:44.000000000 +0100
14746 +++ linux-2.6.29-vs2.3.0.36.9-pre2/init/main.c 2009-03-24 17:22:37.000000000 +0100
14748 #include <linux/ftrace.h>
14749 #include <linux/async.h>
14750 #include <trace/boot.h>
14751 +#include <linux/vserver/percpu.h>
14753 #include <asm/io.h>
14754 #include <asm/bugs.h>
14755 @@ -381,12 +382,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
14757 static void __init setup_per_cpu_areas(void)
14759 - unsigned long size, i;
14760 + unsigned long size, vspc, i;
14762 unsigned long nr_possible_cpus = num_possible_cpus();
14764 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
14766 /* Copy section for each CPU (we discard the original) */
14767 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
14768 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
14769 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
14771 for_each_possible_cpu(i) {
14772 diff -NurpP --minimal linux-2.6.29/ipc/mqueue.c linux-2.6.29-vs2.3.0.36.9-pre2/ipc/mqueue.c
14773 --- linux-2.6.29/ipc/mqueue.c 2009-03-24 14:22:44.000000000 +0100
14774 +++ linux-2.6.29-vs2.3.0.36.9-pre2/ipc/mqueue.c 2009-03-24 17:24:19.000000000 +0100
14776 #include <linux/mutex.h>
14777 #include <linux/nsproxy.h>
14778 #include <linux/pid.h>
14779 +#include <linux/vs_context.h>
14780 +#include <linux/vs_limit.h>
14782 #include <net/sock.h>
14784 @@ -79,6 +81,7 @@ struct mqueue_inode_info {
14785 struct sigevent notify;
14786 struct pid* notify_owner;
14787 struct user_struct *user; /* user who created, for accounting */
14788 + struct vx_info *vxi;
14789 struct sock *notify_sock;
14790 struct sk_buff *notify_cookie;
14792 @@ -126,6 +129,7 @@ static struct inode *mqueue_get_inode(st
14793 if (S_ISREG(mode)) {
14794 struct mqueue_inode_info *info;
14795 struct task_struct *p = current;
14796 + struct vx_info *vxi = p->vx_info;
14797 unsigned long mq_bytes, mq_msg_tblsz;
14799 inode->i_fop = &mqueue_file_operations;
14800 @@ -140,6 +144,7 @@ static struct inode *mqueue_get_inode(st
14801 info->notify_owner = NULL;
14803 info->user = NULL; /* set when all is ok */
14804 + info->vxi = NULL;
14805 memset(&info->attr, 0, sizeof(info->attr));
14806 info->attr.mq_maxmsg = msg_max;
14807 info->attr.mq_msgsize = msgsize_max;
14808 @@ -154,22 +159,26 @@ static struct inode *mqueue_get_inode(st
14809 spin_lock(&mq_lock);
14810 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14811 u->mq_bytes + mq_bytes >
14812 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
14813 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
14814 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14815 spin_unlock(&mq_lock);
14818 u->mq_bytes += mq_bytes;
14819 + vx_ipcmsg_add(vxi, u, mq_bytes);
14820 spin_unlock(&mq_lock);
14822 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
14823 if (!info->messages) {
14824 spin_lock(&mq_lock);
14825 u->mq_bytes -= mq_bytes;
14826 + vx_ipcmsg_sub(vxi, u, mq_bytes);
14827 spin_unlock(&mq_lock);
14831 info->user = get_uid(u);
14832 + info->vxi = get_vx_info(vxi);
14833 } else if (S_ISDIR(mode)) {
14835 /* Some things misbehave if size == 0 on a directory */
14836 @@ -260,10 +269,14 @@ static void mqueue_delete_inode(struct i
14837 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
14840 + struct vx_info *vxi = info->vxi;
14842 spin_lock(&mq_lock);
14843 user->mq_bytes -= mq_bytes;
14844 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14846 spin_unlock(&mq_lock);
14847 + put_vx_info(vxi);
14851 diff -NurpP --minimal linux-2.6.29/ipc/msg.c linux-2.6.29-vs2.3.0.36.9-pre2/ipc/msg.c
14852 --- linux-2.6.29/ipc/msg.c 2009-03-24 14:22:44.000000000 +0100
14853 +++ linux-2.6.29-vs2.3.0.36.9-pre2/ipc/msg.c 2009-02-22 22:54:26.000000000 +0100
14855 #include <linux/rwsem.h>
14856 #include <linux/nsproxy.h>
14857 #include <linux/ipc_namespace.h>
14858 +#include <linux/vs_base.h>
14860 #include <asm/current.h>
14861 #include <asm/uaccess.h>
14862 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14864 msq->q_perm.mode = msgflg & S_IRWXUGO;
14865 msq->q_perm.key = key;
14866 + msq->q_perm.xid = vx_current_xid();
14868 msq->q_perm.security = NULL;
14869 retval = security_msg_queue_alloc(msq);
14870 diff -NurpP --minimal linux-2.6.29/ipc/namespace.c linux-2.6.29-vs2.3.0.36.9-pre2/ipc/namespace.c
14871 --- linux-2.6.29/ipc/namespace.c 2008-12-25 00:26:37.000000000 +0100
14872 +++ linux-2.6.29-vs2.3.0.36.9-pre2/ipc/namespace.c 2009-02-22 22:54:26.000000000 +0100
14874 #include <linux/rcupdate.h>
14875 #include <linux/nsproxy.h>
14876 #include <linux/slab.h>
14877 +#include <linux/vs_base.h>
14878 +#include <linux/vserver/global.h>
14882 @@ -35,6 +37,7 @@ static struct ipc_namespace *clone_ipc_n
14883 register_ipcns_notifier(ns);
14885 kref_init(&ns->kref);
14886 + atomic_inc(&vs_global_ipc_ns);
14890 @@ -101,6 +104,7 @@ void free_ipc_ns(struct kref *kref)
14894 + atomic_dec(&vs_global_ipc_ns);
14896 atomic_dec(&nr_ipc_ns);
14898 diff -NurpP --minimal linux-2.6.29/ipc/sem.c linux-2.6.29-vs2.3.0.36.9-pre2/ipc/sem.c
14899 --- linux-2.6.29/ipc/sem.c 2009-03-24 14:22:44.000000000 +0100
14900 +++ linux-2.6.29-vs2.3.0.36.9-pre2/ipc/sem.c 2009-03-24 14:48:36.000000000 +0100
14902 #include <linux/rwsem.h>
14903 #include <linux/nsproxy.h>
14904 #include <linux/ipc_namespace.h>
14905 +#include <linux/vs_base.h>
14906 +#include <linux/vs_limit.h>
14908 #include <asm/uaccess.h>
14910 @@ -255,6 +257,7 @@ static int newary(struct ipc_namespace *
14912 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14913 sma->sem_perm.key = key;
14914 + sma->sem_perm.xid = vx_current_xid();
14916 sma->sem_perm.security = NULL;
14917 retval = security_sem_alloc(sma);
14918 @@ -270,6 +273,9 @@ static int newary(struct ipc_namespace *
14921 ns->used_sems += nsems;
14922 + /* FIXME: obsoleted? */
14923 + vx_semary_inc(sma);
14924 + vx_nsems_add(sma, nsems);
14926 sma->sem_base = (struct sem *) &sma[1];
14927 INIT_LIST_HEAD(&sma->sem_pending);
14928 diff -NurpP --minimal linux-2.6.29/ipc/shm.c linux-2.6.29-vs2.3.0.36.9-pre2/ipc/shm.c
14929 --- linux-2.6.29/ipc/shm.c 2009-03-24 14:22:44.000000000 +0100
14930 +++ linux-2.6.29-vs2.3.0.36.9-pre2/ipc/shm.c 2009-03-24 14:48:36.000000000 +0100
14932 #include <linux/nsproxy.h>
14933 #include <linux/mount.h>
14934 #include <linux/ipc_namespace.h>
14935 +#include <linux/vs_context.h>
14936 +#include <linux/vs_limit.h>
14938 #include <asm/uaccess.h>
14940 @@ -168,7 +170,12 @@ static void shm_open(struct vm_area_stru
14942 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14944 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14945 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14946 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14948 + vx_ipcshm_sub(vxi, shp, numpages);
14949 + ns->shm_tot -= numpages;
14953 if (!is_file_hugepages(shp->shm_file))
14954 @@ -178,6 +185,7 @@ static void shm_destroy(struct ipc_names
14956 fput (shp->shm_file);
14957 security_shm_free(shp);
14958 + put_vx_info(vxi);
14959 ipc_rcu_putref(shp);
14962 @@ -348,11 +356,15 @@ static int newseg(struct ipc_namespace *
14963 if (ns->shm_tot + numpages > ns->shm_ctlall)
14966 + if (!vx_ipcshm_avail(current->vx_info, numpages))
14969 shp = ipc_rcu_alloc(sizeof(*shp));
14973 shp->shm_perm.key = key;
14974 + shp->shm_perm.xid = vx_current_xid();
14975 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14976 shp->mlock_user = NULL;
14978 @@ -406,6 +418,7 @@ static int newseg(struct ipc_namespace *
14979 ns->shm_tot += numpages;
14980 error = shp->shm_perm.id;
14982 + vx_ipcshm_add(current->vx_info, key, numpages);
14986 diff -NurpP --minimal linux-2.6.29/kernel/capability.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/capability.c
14987 --- linux-2.6.29/kernel/capability.c 2009-03-24 14:22:44.000000000 +0100
14988 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/capability.c 2009-03-24 17:27:28.000000000 +0100
14990 #include <linux/security.h>
14991 #include <linux/syscalls.h>
14992 #include <linux/pid_namespace.h>
14993 +#include <linux/vs_context.h>
14994 #include <asm/uaccess.h>
14995 #include "cred-internals.h"
14997 @@ -122,6 +123,7 @@ static int cap_validate_magic(cap_user_h
15003 * The only thing that can change the capabilities of the current
15004 * process is the current process. As such, we can't be in this code
15005 @@ -289,6 +291,8 @@ error:
15009 +#include <linux/vserver/base.h>
15012 * capable - Determine if the current task has a superior capability in effect
15013 * @cap: The capability to be tested for
15014 @@ -301,6 +305,9 @@ error:
15016 int capable(int cap)
15018 + /* here for now so we don't require task locking */
15019 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15021 if (unlikely(!cap_valid(cap))) {
15022 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
15024 diff -NurpP --minimal linux-2.6.29/kernel/compat.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/compat.c
15025 --- linux-2.6.29/kernel/compat.c 2009-03-24 14:22:44.000000000 +0100
15026 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/compat.c 2009-03-24 14:48:36.000000000 +0100
15027 @@ -891,7 +891,7 @@ asmlinkage long compat_sys_time(compat_t
15031 - do_gettimeofday(&tv);
15032 + vx_gettimeofday(&tv);
15036 @@ -916,7 +916,7 @@ asmlinkage long compat_sys_stime(compat_
15040 - do_settimeofday(&tv);
15041 + vx_settimeofday(&tv);
15045 diff -NurpP --minimal linux-2.6.29/kernel/exit.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/exit.c
15046 --- linux-2.6.29/kernel/exit.c 2009-03-24 14:22:44.000000000 +0100
15047 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/exit.c 2009-03-24 17:28:40.000000000 +0100
15049 #include <linux/task_io_accounting_ops.h>
15050 #include <linux/tracehook.h>
15051 #include <linux/init_task.h>
15052 +#include <linux/vs_limit.h>
15053 +#include <linux/vs_context.h>
15054 +#include <linux/vs_network.h>
15055 +#include <linux/vs_pid.h>
15056 +#include <linux/vserver/global.h>
15057 #include <trace/sched.h>
15059 #include <asm/uaccess.h>
15060 @@ -502,9 +507,11 @@ static void close_files(struct files_str
15061 filp_close(file, files);
15064 + vx_openfd_dec(i);
15072 @@ -571,6 +578,7 @@ void put_fs_struct(struct fs_struct *fs)
15073 if (atomic_dec_and_test(&fs->count)) {
15074 path_put(&fs->root);
15075 path_put(&fs->pwd);
15076 + atomic_dec(&vs_global_fs);
15077 kmem_cache_free(fs_cachep, fs);
15080 @@ -1122,10 +1130,15 @@ NORET_TYPE void do_exit(long code)
15081 if (tsk->splice_pipe)
15082 __free_pipe_info(tsk->splice_pipe);
15084 + /* needs to stay after exit_notify() */
15085 + exit_vx_info(tsk, code);
15086 + exit_nx_info(tsk);
15089 /* causes final put_task_struct in finish_task_switch(). */
15090 tsk->state = TASK_DEAD;
15092 + printk("bad task: %p [%lx]\n", current, current->state);
15094 /* Avoid "noreturn function does return". */
15096 diff -NurpP --minimal linux-2.6.29/kernel/fork.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/fork.c
15097 --- linux-2.6.29/kernel/fork.c 2009-03-24 14:22:44.000000000 +0100
15098 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/fork.c 2009-03-24 17:31:42.000000000 +0100
15100 #include <linux/tty.h>
15101 #include <linux/proc_fs.h>
15102 #include <linux/blkdev.h>
15103 +#include <linux/vs_context.h>
15104 +#include <linux/vs_network.h>
15105 +#include <linux/vs_limit.h>
15106 +#include <linux/vs_memory.h>
15107 +#include <linux/vserver/global.h>
15108 #include <trace/sched.h>
15110 #include <asm/pgtable.h>
15111 @@ -140,6 +145,8 @@ void free_task(struct task_struct *tsk)
15112 prop_local_destroy_single(&tsk->dirties);
15113 free_thread_info(tsk->stack);
15114 rt_mutex_debug_task_free(tsk);
15115 + clr_vx_info(&tsk->vx_info);
15116 + clr_nx_info(&tsk->nx_info);
15117 ftrace_graph_exit_task(tsk);
15118 free_task_struct(tsk);
15120 @@ -279,6 +286,8 @@ static int dup_mmap(struct mm_struct *mm
15121 mm->free_area_cache = oldmm->mmap_base;
15122 mm->cached_hole_size = ~0UL;
15124 + __set_mm_counter(mm, file_rss, 0);
15125 + __set_mm_counter(mm, anon_rss, 0);
15126 cpus_clear(mm->cpu_vm_mask);
15127 mm->mm_rb = RB_ROOT;
15128 rb_link = &mm->mm_rb.rb_node;
15129 @@ -290,7 +299,7 @@ static int dup_mmap(struct mm_struct *mm
15131 if (mpnt->vm_flags & VM_DONTCOPY) {
15132 long pages = vma_pages(mpnt);
15133 - mm->total_vm -= pages;
15134 + vx_vmpages_sub(mm, pages);
15135 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15138 @@ -423,8 +432,8 @@ static struct mm_struct * mm_init(struct
15139 mm->flags = (current->mm) ? current->mm->flags : default_dump_filter;
15140 mm->core_state = NULL;
15142 - set_mm_counter(mm, file_rss, 0);
15143 - set_mm_counter(mm, anon_rss, 0);
15144 + __set_mm_counter(mm, file_rss, 0);
15145 + __set_mm_counter(mm, anon_rss, 0);
15146 spin_lock_init(&mm->page_table_lock);
15147 spin_lock_init(&mm->ioctx_lock);
15148 INIT_HLIST_HEAD(&mm->ioctx_list);
15149 @@ -435,6 +444,7 @@ static struct mm_struct * mm_init(struct
15150 if (likely(!mm_alloc_pgd(mm))) {
15152 mmu_notifier_mm_init(mm);
15153 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15157 @@ -468,6 +478,7 @@ void __mmdrop(struct mm_struct *mm)
15159 destroy_context(mm);
15160 mmu_notifier_mm_destroy(mm);
15161 + clr_vx_info(&mm->mm_vx_info);
15164 EXPORT_SYMBOL_GPL(__mmdrop);
15165 @@ -594,6 +605,7 @@ struct mm_struct *dup_mm(struct task_str
15168 memcpy(mm, oldmm, sizeof(*mm));
15169 + mm->mm_vx_info = NULL;
15171 /* Initializing for Swap token stuff */
15172 mm->token_priority = 0;
15173 @@ -627,6 +639,7 @@ fail_nocontext:
15174 * If init_new_context() failed, we cannot use mmput() to free the mm
15175 * because it calls destroy_context()
15177 + clr_vx_info(&mm->mm_vx_info);
15181 @@ -690,6 +703,7 @@ static struct fs_struct *__copy_fs_struc
15182 fs->pwd = old->pwd;
15183 path_get(&old->pwd);
15184 read_unlock(&old->lock);
15185 + atomic_inc(&vs_global_fs);
15189 @@ -955,6 +969,8 @@ static struct task_struct *copy_process(
15191 struct task_struct *p;
15192 int cgroup_callbacks_done = 0;
15193 + struct vx_info *vxi;
15194 + struct nx_info *nxi;
15196 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15197 return ERR_PTR(-EINVAL);
15198 @@ -989,12 +1005,28 @@ static struct task_struct *copy_process(
15199 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15200 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15202 + init_vx_info(&p->vx_info, current->vx_info);
15203 + init_nx_info(&p->nx_info, current->nx_info);
15205 + /* check vserver memory */
15206 + if (p->mm && !(clone_flags & CLONE_VM)) {
15207 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15208 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15210 + goto bad_fork_free;
15212 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15213 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15214 + goto bad_fork_cleanup_vm;
15217 + if (!vx_nproc_avail(1))
15218 + goto bad_fork_cleanup_vm;
15219 if (atomic_read(&p->real_cred->user->processes) >=
15220 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15221 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15222 p->real_cred->user != INIT_USER)
15223 - goto bad_fork_free;
15224 + goto bad_fork_cleanup_vm;
15227 retval = copy_creds(p, clone_flags);
15228 @@ -1271,6 +1303,18 @@ static struct task_struct *copy_process(
15231 spin_unlock(¤t->sighand->siglock);
15233 + /* p is copy of current */
15234 + vxi = p->vx_info;
15236 + claim_vx_info(vxi, p);
15237 + atomic_inc(&vxi->cvirt.nr_threads);
15238 + atomic_inc(&vxi->cvirt.total_forks);
15241 + nxi = p->nx_info;
15243 + claim_nx_info(nxi, p);
15244 write_unlock_irq(&tasklist_lock);
15245 proc_fork_connector(p);
15246 cgroup_post_fork(p);
15247 @@ -1315,6 +1359,9 @@ bad_fork_cleanup_count:
15248 atomic_dec(&p->cred->user->processes);
15249 put_cred(p->real_cred);
15251 +bad_fork_cleanup_vm:
15252 + if (p->mm && !(clone_flags & CLONE_VM))
15253 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15257 diff -NurpP --minimal linux-2.6.29/kernel/kthread.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/kthread.c
15258 --- linux-2.6.29/kernel/kthread.c 2009-03-24 14:22:44.000000000 +0100
15259 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/kthread.c 2009-03-24 14:48:36.000000000 +0100
15261 #include <linux/file.h>
15262 #include <linux/module.h>
15263 #include <linux/mutex.h>
15264 +#include <linux/vs_pid.h>
15265 #include <trace/sched.h>
15267 #define KTHREAD_NICE_LEVEL (-5)
15268 @@ -102,7 +103,7 @@ static void create_kthread(struct kthrea
15269 struct sched_param param = { .sched_priority = 0 };
15270 wait_for_completion(&create->started);
15271 read_lock(&tasklist_lock);
15272 - create->result = find_task_by_pid_ns(pid, &init_pid_ns);
15273 + create->result = find_task_by_real_pid(pid);
15274 read_unlock(&tasklist_lock);
15276 * root may have changed our (kthreadd's) priority or CPU mask.
15277 diff -NurpP --minimal linux-2.6.29/kernel/Makefile linux-2.6.29-vs2.3.0.36.9-pre2/kernel/Makefile
15278 --- linux-2.6.29/kernel/Makefile 2009-03-24 14:22:44.000000000 +0100
15279 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/Makefile 2009-03-24 14:48:36.000000000 +0100
15280 @@ -22,6 +22,7 @@ CFLAGS_REMOVE_cgroup-debug.o = -pg
15281 CFLAGS_REMOVE_sched_clock.o = -pg
15285 obj-$(CONFIG_FREEZER) += freezer.o
15286 obj-$(CONFIG_PROFILING) += profile.o
15287 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15288 diff -NurpP --minimal linux-2.6.29/kernel/nsproxy.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/nsproxy.c
15289 --- linux-2.6.29/kernel/nsproxy.c 2009-03-24 14:22:44.000000000 +0100
15290 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/nsproxy.c 2009-03-25 00:39:02.000000000 +0100
15292 #include <linux/mnt_namespace.h>
15293 #include <linux/utsname.h>
15294 #include <linux/pid_namespace.h>
15295 +#include <linux/vserver/global.h>
15296 +#include <linux/vserver/debug.h>
15297 #include <net/net_namespace.h>
15298 #include <linux/ipc_namespace.h>
15300 @@ -37,6 +39,9 @@ static inline struct nsproxy *clone_nspr
15302 memcpy(ns, orig, sizeof(struct nsproxy));
15303 atomic_set(&ns->count, 1);
15304 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
15305 + orig, atomic_read(&orig->count), ns);
15306 + atomic_inc(&vs_global_nsproxy);
15310 @@ -46,41 +51,52 @@ static inline struct nsproxy *clone_nspr
15311 * Return the newly created nsproxy. Do not attach this to the task,
15312 * leave it to the caller to do proper locking and attach it to task.
15314 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15315 - struct task_struct *tsk, struct fs_struct *new_fs)
15316 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15317 + struct nsproxy *orig, struct fs_struct *new_fs)
15319 struct nsproxy *new_nsp;
15322 - new_nsp = clone_nsproxy(tsk->nsproxy);
15323 + vxdprintk(VXD_CBIT(space, 4),
15324 + "unshare_namespaces(0x%08lx,%p,%p)",
15325 + flags, orig, new_fs);
15327 + new_nsp = clone_nsproxy(orig);
15329 return ERR_PTR(-ENOMEM);
15331 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15332 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15333 if (IS_ERR(new_nsp->mnt_ns)) {
15334 err = PTR_ERR(new_nsp->mnt_ns);
15338 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15339 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15340 if (IS_ERR(new_nsp->uts_ns)) {
15341 err = PTR_ERR(new_nsp->uts_ns);
15345 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15346 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15347 if (IS_ERR(new_nsp->ipc_ns)) {
15348 err = PTR_ERR(new_nsp->ipc_ns);
15352 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15353 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15354 if (IS_ERR(new_nsp->pid_ns)) {
15355 err = PTR_ERR(new_nsp->pid_ns);
15359 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15361 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15362 + if (IS_ERR(new_nsp->user_ns)) {
15363 + err = PTR_ERR(new_nsp->user_ns);
15367 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15368 if (IS_ERR(new_nsp->net_ns)) {
15369 err = PTR_ERR(new_nsp->net_ns);
15371 @@ -105,6 +121,35 @@ out_ns:
15372 return ERR_PTR(err);
15375 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15376 + struct fs_struct *new_fs)
15378 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15382 + * copies the nsproxy, setting refcount to 1, and grabbing a
15383 + * reference to all contained namespaces.
15385 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15387 + struct nsproxy *ns = clone_nsproxy(orig);
15391 + get_mnt_ns(ns->mnt_ns);
15393 + get_uts_ns(ns->uts_ns);
15395 + get_ipc_ns(ns->ipc_ns);
15397 + get_pid_ns(ns->pid_ns);
15399 + get_net(ns->net_ns);
15405 * called from clone. This now handles copy for nsproxy and all
15406 * namespaces therein.
15407 @@ -112,9 +157,12 @@ out_ns:
15408 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15410 struct nsproxy *old_ns = tsk->nsproxy;
15411 - struct nsproxy *new_ns;
15412 + struct nsproxy *new_ns = NULL;
15415 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15416 + flags, tsk, old_ns);
15421 @@ -151,6 +199,9 @@ int copy_namespaces(unsigned long flags,
15424 put_nsproxy(old_ns);
15425 + vxdprintk(VXD_CBIT(space, 3),
15426 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15427 + flags, tsk, old_ns, err, new_ns);
15431 @@ -164,7 +215,9 @@ void free_nsproxy(struct nsproxy *ns)
15432 put_ipc_ns(ns->ipc_ns);
15434 put_pid_ns(ns->pid_ns);
15435 - put_net(ns->net_ns);
15437 + put_net(ns->net_ns);
15438 + atomic_dec(&vs_global_nsproxy);
15439 kmem_cache_free(nsproxy_cachep, ns);
15442 @@ -177,6 +230,10 @@ int unshare_nsproxy_namespaces(unsigned
15446 + vxdprintk(VXD_CBIT(space, 4),
15447 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15448 + unshare_flags, current->nsproxy);
15450 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15453 diff -NurpP --minimal linux-2.6.29/kernel/pid.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/pid.c
15454 --- linux-2.6.29/kernel/pid.c 2009-03-24 14:22:44.000000000 +0100
15455 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/pid.c 2009-03-24 14:48:36.000000000 +0100
15457 #include <linux/pid_namespace.h>
15458 #include <linux/init_task.h>
15459 #include <linux/syscalls.h>
15460 +#include <linux/vs_pid.h>
15461 +#include <linux/vserver/global.h>
15463 #define pid_hashfn(nr, ns) \
15464 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15465 @@ -305,7 +307,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15467 struct pid *find_vpid(int nr)
15469 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15470 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15472 EXPORT_SYMBOL_GPL(find_vpid);
15474 @@ -365,6 +367,9 @@ void transfer_pid(struct task_struct *ol
15475 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15477 struct task_struct *result = NULL;
15479 + if (type == PIDTYPE_REALPID)
15480 + type = PIDTYPE_PID;
15482 struct hlist_node *first;
15483 first = rcu_dereference(pid->tasks[type].first);
15484 @@ -388,14 +393,14 @@ EXPORT_SYMBOL(find_task_by_pid_type_ns);
15486 struct task_struct *find_task_by_vpid(pid_t vnr)
15488 - return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
15489 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(vnr),
15490 current->nsproxy->pid_ns);
15492 EXPORT_SYMBOL(find_task_by_vpid);
15494 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15496 - return find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns);
15497 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(nr), ns);
15499 EXPORT_SYMBOL(find_task_by_pid_ns);
15501 @@ -431,7 +436,7 @@ struct pid *find_get_pid(pid_t nr)
15503 EXPORT_SYMBOL_GPL(find_get_pid);
15505 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15506 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15510 @@ -444,6 +449,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15514 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15516 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15519 pid_t pid_vnr(struct pid *pid)
15521 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15522 diff -NurpP --minimal linux-2.6.29/kernel/pid_namespace.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/pid_namespace.c
15523 --- linux-2.6.29/kernel/pid_namespace.c 2008-12-25 00:26:37.000000000 +0100
15524 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/pid_namespace.c 2009-02-22 22:54:26.000000000 +0100
15526 #include <linux/syscalls.h>
15527 #include <linux/err.h>
15528 #include <linux/acct.h>
15529 +#include <linux/vserver/global.h>
15531 #define BITS_PER_PAGE (PAGE_SIZE*8)
15533 @@ -85,6 +86,7 @@ static struct pid_namespace *create_pid_
15536 kref_init(&ns->kref);
15537 + atomic_inc(&vs_global_pid_ns);
15540 set_bit(0, ns->pidmap[0].page);
15541 @@ -109,6 +111,7 @@ static void destroy_pid_namespace(struct
15543 for (i = 0; i < PIDMAP_ENTRIES; i++)
15544 kfree(ns->pidmap[i].page);
15545 + atomic_dec(&vs_global_pid_ns);
15546 kmem_cache_free(pid_ns_cachep, ns);
15549 diff -NurpP --minimal linux-2.6.29/kernel/posix-timers.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/posix-timers.c
15550 --- linux-2.6.29/kernel/posix-timers.c 2009-03-24 14:22:44.000000000 +0100
15551 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/posix-timers.c 2009-03-24 17:36:18.000000000 +0100
15553 #include <linux/wait.h>
15554 #include <linux/workqueue.h>
15555 #include <linux/module.h>
15556 +#include <linux/vs_context.h>
15559 * Management arrays for POSIX timers. Timers are kept in slab memory
15560 @@ -321,6 +322,12 @@ int posix_timer_event(struct k_itimer *t
15562 struct task_struct *task;
15563 int shared, ret = -1;
15564 + struct vx_info_save vxis;
15565 + struct vx_info *vxi;
15567 + /* FIXME: move that down where we have the task */
15568 + vxi = task_get_vx_info(timr->it_process);
15569 + enter_vx_info(vxi, &vxis);
15571 * FIXME: if ->sigq is queued we can race with
15572 * dequeue_signal()->do_schedule_next_timer().
15573 @@ -341,6 +348,9 @@ int posix_timer_event(struct k_itimer *t
15574 ret = send_sigqueue(timr->sigq, task, shared);
15578 + leave_vx_info(&vxis);
15579 + put_vx_info(vxi);
15580 /* If we failed to send the signal the timer stops. */
15583 diff -NurpP --minimal linux-2.6.29/kernel/printk.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/printk.c
15584 --- linux-2.6.29/kernel/printk.c 2009-03-24 14:22:44.000000000 +0100
15585 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/printk.c 2009-03-24 14:48:36.000000000 +0100
15587 #include <linux/security.h>
15588 #include <linux/bootmem.h>
15589 #include <linux/syscalls.h>
15590 +#include <linux/vs_cvirt.h>
15592 #include <asm/uaccess.h>
15594 @@ -251,18 +252,13 @@ int do_syslog(int type, char __user *buf
15595 unsigned i, j, limit, count;
15601 error = security_syslog(type);
15606 - case 0: /* Close log */
15608 - case 1: /* Open log */
15610 - case 2: /* Read from log */
15611 + if ((type >= 2) && (type <= 4)) {
15613 if (!buf || len < 0)
15615 @@ -273,6 +269,16 @@ int do_syslog(int type, char __user *buf
15620 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15621 + return vx_do_syslog(type, buf, len);
15624 + case 0: /* Close log */
15626 + case 1: /* Open log */
15628 + case 2: /* Read from log */
15629 error = wait_event_interruptible(log_wait,
15630 (log_start - log_end));
15632 @@ -297,16 +303,6 @@ int do_syslog(int type, char __user *buf
15635 case 3: /* Read last kernel messages */
15637 - if (!buf || len < 0)
15642 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15647 if (count > log_buf_len)
15648 count = log_buf_len;
15649 diff -NurpP --minimal linux-2.6.29/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/ptrace.c
15650 --- linux-2.6.29/kernel/ptrace.c 2009-03-24 14:22:44.000000000 +0100
15651 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/ptrace.c 2009-03-24 14:48:36.000000000 +0100
15653 #include <linux/audit.h>
15654 #include <linux/pid_namespace.h>
15655 #include <linux/syscalls.h>
15656 +#include <linux/vs_context.h>
15658 #include <asm/pgtable.h>
15659 #include <asm/uaccess.h>
15660 @@ -159,6 +160,11 @@ int __ptrace_may_access(struct task_stru
15661 dumpable = get_dumpable(task->mm);
15662 if (!dumpable && !capable(CAP_SYS_PTRACE))
15664 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15666 + if (!vx_check(task->xid, VS_IDENT) &&
15667 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15670 return security_ptrace_may_access(task, mode);
15672 @@ -596,6 +602,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15677 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15678 + goto out_put_task_struct;
15680 if (request == PTRACE_ATTACH) {
15681 ret = ptrace_attach(child);
15683 diff -NurpP --minimal linux-2.6.29/kernel/sched.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sched.c
15684 --- linux-2.6.29/kernel/sched.c 2009-03-24 14:22:44.000000000 +0100
15685 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sched.c 2009-03-24 21:52:21.000000000 +0100
15687 #include <linux/debugfs.h>
15688 #include <linux/ctype.h>
15689 #include <linux/ftrace.h>
15690 +#include <linux/vs_sched.h>
15691 +#include <linux/vs_cvirt.h>
15692 #include <trace/sched.h>
15694 #include <asm/tlb.h>
15695 @@ -610,6 +612,16 @@ struct rq {
15697 struct hrtimer hrtick_timer;
15699 + unsigned long norm_time;
15700 + unsigned long idle_time;
15701 +#ifdef CONFIG_VSERVER_IDLETIME
15704 +#ifdef CONFIG_VSERVER_HARDCPU
15705 + struct list_head hold_queue;
15706 + unsigned long nr_onhold;
15710 #ifdef CONFIG_SCHEDSTATS
15711 /* latency stats */
15712 @@ -1705,6 +1717,7 @@ static void update_avg(u64 *avg, u64 sam
15714 static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup)
15716 + // BUG_ON(p->state & TASK_ONHOLD);
15717 sched_info_queued(p);
15718 p->sched_class->enqueue_task(rq, p, wakeup);
15720 @@ -1828,6 +1841,8 @@ static inline void check_class_changed(s
15721 p->sched_class->prio_changed(rq, p, oldprio, running);
15724 +#include "sched_mon.h"
15728 /* Used instead of source_load when we know the type == 0 */
15729 @@ -1915,6 +1930,7 @@ migrate_task(struct task_struct *p, int
15731 struct rq *rq = task_rq(p);
15733 + vxm_migrate_task(p, rq, dest_cpu);
15735 * If the task is not on a runqueue (and not running), then
15736 * it is sufficient to simply update the task's cpu field.
15737 @@ -2242,6 +2258,8 @@ static int sched_balance_self(int cpu, i
15739 #endif /* CONFIG_SMP */
15741 +#include "sched_hard.h"
15744 * try_to_wake_up - wake up a thread
15745 * @p: the to-be-woken-up thread
15746 @@ -2286,6 +2304,13 @@ static int try_to_wake_up(struct task_st
15747 rq = task_rq_lock(p, &flags);
15748 update_rq_clock(rq);
15749 old_state = p->state;
15751 + /* we need to unhold suspended tasks */
15752 + if (old_state & TASK_ONHOLD) {
15753 + vx_unhold_task(p, rq);
15754 + old_state = p->state;
15757 if (!(old_state & state))
15760 @@ -2307,6 +2332,12 @@ static int try_to_wake_up(struct task_st
15761 /* might preempt at this point */
15762 rq = task_rq_lock(p, &flags);
15763 old_state = p->state;
15765 + /* we need to unhold suspended tasks
15766 + if (old_state & TASK_ONHOLD) {
15767 + vx_unhold_task(p, rq);
15768 + old_state = p->state;
15770 if (!(old_state & state))
15773 @@ -4169,16 +4200,19 @@ void account_user_time(struct task_struc
15774 cputime_t cputime_scaled)
15776 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15777 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15779 + int nice = (TASK_NICE(p) > 0);
15781 /* Add user time to process. */
15782 p->utime = cputime_add(p->utime, cputime);
15783 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15784 + vx_account_user(vxi, cputime, nice);
15785 account_group_user_time(p, cputime);
15787 /* Add user time to cpustat. */
15788 tmp = cputime_to_cputime64(cputime);
15789 - if (TASK_NICE(p) > 0)
15791 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15793 cpustat->user = cputime64_add(cpustat->user, tmp);
15794 @@ -4222,6 +4256,7 @@ void account_system_time(struct task_str
15795 cputime_t cputime, cputime_t cputime_scaled)
15797 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15798 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15801 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
15802 @@ -4232,6 +4267,7 @@ void account_system_time(struct task_str
15803 /* Add system time to process. */
15804 p->stime = cputime_add(p->stime, cputime);
15805 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15806 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15807 account_group_system_time(p, cputime);
15809 /* Add system time to cpustat. */
15810 @@ -4587,6 +4623,11 @@ need_resched_nonpreemptible:
15811 idle_balance(cpu, rq);
15813 prev->sched_class->put_prev_task(rq, prev);
15815 + vx_set_rq_time(rq, jiffies); /* update time */
15816 + vx_schedule(prev, rq, cpu); /* hold if over limit */
15817 + vx_try_unhold(rq, cpu); /* unhold if refilled */
15819 next = pick_next_task(rq, prev);
15821 if (likely(prev != next)) {
15822 @@ -5152,7 +5193,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15825 if (increment < 0 && !can_nice(current, nice))
15827 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15829 retval = security_task_setnice(current, nice);
15831 @@ -8428,7 +8469,10 @@ void __init sched_init(void)
15834 #endif /* CONFIG_FAIR_GROUP_SCHED */
15836 +#ifdef CONFIG_VSERVER_HARDCPU
15837 + INIT_LIST_HEAD(&rq->hold_queue);
15838 + rq->nr_onhold = 0;
15840 rq->rt.rt_runtime = def_rt_bandwidth.rt_runtime;
15841 #ifdef CONFIG_RT_GROUP_SCHED
15842 INIT_LIST_HEAD(&rq->leaf_rt_rq_list);
15843 diff -NurpP --minimal linux-2.6.29/kernel/sched_fair.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sched_fair.c
15844 --- linux-2.6.29/kernel/sched_fair.c 2009-03-24 14:22:45.000000000 +0100
15845 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sched_fair.c 2009-03-24 14:48:36.000000000 +0100
15846 @@ -717,6 +717,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15847 check_spread(cfs_rq, se);
15848 if (se != cfs_rq->curr)
15849 __enqueue_entity(cfs_rq, se);
15851 + if (entity_is_task(se))
15852 + vx_activate_task(task_of(se));
15855 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
15856 @@ -760,6 +763,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15858 if (se != cfs_rq->curr)
15859 __dequeue_entity(cfs_rq, se);
15860 + if (entity_is_task(se))
15861 + vx_deactivate_task(task_of(se));
15862 account_entity_dequeue(cfs_rq, se);
15863 update_min_vruntime(cfs_rq);
15865 diff -NurpP --minimal linux-2.6.29/kernel/sched_hard.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sched_hard.h
15866 --- linux-2.6.29/kernel/sched_hard.h 1970-01-01 01:00:00.000000000 +0100
15867 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sched_hard.h 2009-02-22 22:54:26.000000000 +0100
15870 +#ifdef CONFIG_VSERVER_IDLELIMIT
15873 + * vx_idle_resched - reschedule after maxidle
15876 +void vx_idle_resched(struct rq *rq)
15878 + /* maybe have a better criterion for paused */
15879 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
15880 + set_need_resched();
15883 +#else /* !CONFIG_VSERVER_IDLELIMIT */
15885 +#define vx_idle_resched(rq)
15887 +#endif /* CONFIG_VSERVER_IDLELIMIT */
15891 +#ifdef CONFIG_VSERVER_IDLETIME
15893 +#define vx_set_rq_min_skip(rq, min) \
15894 + (rq)->idle_skip = (min)
15896 +#define vx_save_min_skip(ret, min, val) \
15897 + __vx_save_min_skip(ret, min, val)
15900 +void __vx_save_min_skip(int ret, int *min, int val)
15904 + if ((*min > val) || !*min)
15909 +int vx_try_skip(struct rq *rq, int cpu)
15911 + /* artificially advance time */
15912 + if (rq->idle_skip > 0) {
15913 + vxdprintk(list_empty(&rq->hold_queue),
15914 + "hold queue empty on cpu %d", cpu);
15915 + rq->idle_time += rq->idle_skip;
15916 + vxm_idle_skip(rq, cpu);
15922 +#else /* !CONFIG_VSERVER_IDLETIME */
15924 +#define vx_set_rq_min_skip(rq, min) \
15925 + ({ int dummy = (min); dummy; })
15927 +#define vx_save_min_skip(ret, min, val)
15930 +int vx_try_skip(struct rq *rq, int cpu)
15935 +#endif /* CONFIG_VSERVER_IDLETIME */
15939 +#ifdef CONFIG_VSERVER_HARDCPU
15941 +#define vx_set_rq_max_idle(rq, max) \
15942 + (rq)->idle_tokens = (max)
15944 +#define vx_save_max_idle(ret, min, val) \
15945 + __vx_save_max_idle(ret, min, val)
15948 +void __vx_save_max_idle(int ret, int *min, int val)
15956 + * vx_hold_task - put a task on the hold queue
15959 +void vx_hold_task(struct task_struct *p, struct rq *rq)
15961 + // printk("@ hold_task(%p[%lx])\n", p, p->state);
15963 + /* ignore dead/killed tasks */
15964 + if (unlikely(p->state & (TASK_DEAD | TASK_WAKEKILL)))
15967 + /* ignore sleeping tasks */
15968 + if (unlikely(p->state & TASK_NORMAL))
15971 + /* remove task from runqueue */
15972 + if (likely(p->se.on_rq))
15973 + dequeue_task(rq, p, 0);
15975 + printk("@ woops, task %p not on runqueue?\n", p);
15977 + p->state |= TASK_ONHOLD;
15978 + /* a new one on hold */
15980 + vxm_hold_task(p, rq);
15981 + list_add_tail(&p->hq, &rq->hold_queue);
15982 + // list_add_tail(&p->run_list, &rq->hold_queue);
15986 + * vx_unhold_task - put a task back to the runqueue
15989 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
15991 + // printk("@ unhold_task(%p[%lx])\n", p, p->state);
15992 + list_del_init(&p->hq);
15993 + // list_del(&p->run_list);
15994 + /* one less waiting */
15996 + p->state &= ~TASK_ONHOLD;
15997 + enqueue_task(rq, p, 0);
15998 + // ? inc_nr_running(p, rq);
15999 + vxm_unhold_task(p, rq);
16003 + * vx_remove_hold - remove a task from the hold queue
16006 +void vx_remove_hold(struct task_struct *p, struct rq *rq)
16008 + printk("@ remove_hold(%p[%lx])\n", p, p->state);
16009 + list_del_init(&p->hq);
16010 + // list_del(&p->run_list);
16011 + /* one less waiting */
16013 + p->state &= ~TASK_ONHOLD;
16016 +unsigned long nr_onhold(void)
16018 + unsigned long i, sum = 0;
16020 + for_each_online_cpu(i)
16021 + sum += cpu_rq(i)->nr_onhold;
16029 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
16031 + return sched_pc->tokens;
16035 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
16037 + sched_pc->tokens--;
16041 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16043 + struct vx_info *vxi = p->vx_info;
16045 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
16046 + struct _vx_sched_pc *sched_pc =
16047 + &vx_per_cpu(vxi, sched_pc, cpu);
16050 + /* maybe we can simplify that to decrement
16051 + the token counter unconditional? */
16053 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
16054 + __vx_consume_token(sched_pc);
16056 + /* for tokens > 0, one token was consumed */
16060 + vxm_need_resched(p, slice, cpu);
16061 + return (slice == 0);
16065 +#define vx_set_rq_time(rq, time) do { \
16066 + rq->norm_time = time; \
16071 +void vx_try_unhold(struct rq *rq, int cpu)
16073 + struct vx_info *vxi = NULL;
16074 + struct list_head *l, *n;
16075 + int maxidle = HZ;
16078 + /* nothing to do? what about pause? */
16079 + if (list_empty(&rq->hold_queue))
16082 + list_for_each_safe(l, n, &rq->hold_queue) {
16083 + int ret, delta_min[2];
16084 + struct _vx_sched_pc *sched_pc;
16085 + struct task_struct *p;
16087 + p = list_entry(l, struct task_struct, hq);
16088 + /* don't bother with same context */
16089 + if (vxi == p->vx_info)
16092 + vxi = p->vx_info;
16093 + /* ignore paused contexts */
16094 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
16097 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16099 + /* recalc tokens */
16100 + vxm_sched_info(sched_pc, vxi, cpu);
16101 + ret = vx_tokens_recalc(sched_pc,
16102 + &rq->norm_time, &rq->idle_time, delta_min);
16103 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16106 + /* we found a runable context */
16107 + vx_unhold_task(p, rq);
16110 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
16111 + vx_save_min_skip(ret, &minskip, delta_min[1]);
16113 + vx_set_rq_max_idle(rq, maxidle);
16114 + vx_set_rq_min_skip(rq, minskip);
16115 + vxm_rq_max_min(rq, cpu);
16120 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16122 + struct vx_info *vxi = next->vx_info;
16123 + struct _vx_sched_pc *sched_pc;
16124 + int delta_min[2];
16130 + flags = vxi->vx_flags;
16132 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
16133 + goto put_on_hold;
16134 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
16137 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16139 + /* update scheduler params */
16140 + if (cpu_isset(cpu, vxi->sched.update)) {
16141 + vx_update_sched_param(&vxi->sched, sched_pc);
16142 + vxm_update_sched(sched_pc, vxi, cpu);
16143 + cpu_clear(cpu, vxi->sched.update);
16146 + vxm_sched_info(sched_pc, vxi, cpu);
16147 + ret = vx_tokens_recalc(sched_pc,
16148 + &rq->norm_time, &rq->idle_time, delta_min);
16149 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16151 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
16154 + if (unlikely(ret < 0)) {
16155 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
16156 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
16157 + vxm_rq_max_min(rq, cpu);
16159 + vx_hold_task(next, rq);
16166 +#else /* CONFIG_VSERVER_HARDCPU */
16169 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16175 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16180 +unsigned long nr_onhold(void)
16187 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16189 + return (slice == 0);
16193 +#define vx_set_rq_time(rq, time)
16196 +void vx_try_unhold(struct rq *rq, int cpu)
16202 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16204 + struct vx_info *vxi = next->vx_info;
16205 + struct _vx_sched_pc *sched_pc;
16206 + int delta_min[2];
16209 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
16212 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16213 + vxm_sched_info(sched_pc, vxi, cpu);
16214 + ret = vx_tokens_recalc(sched_pc,
16215 + &rq->norm_time, &rq->idle_time, delta_min);
16216 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16220 +#endif /* CONFIG_VSERVER_HARDCPU */
16222 diff -NurpP --minimal linux-2.6.29/kernel/sched_mon.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sched_mon.h
16223 --- linux-2.6.29/kernel/sched_mon.h 1970-01-01 01:00:00.000000000 +0100
16224 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sched_mon.h 2009-02-22 22:54:26.000000000 +0100
16227 +#include <linux/vserver/monitor.h>
16229 +#ifdef CONFIG_VSERVER_MONITOR
16231 +#ifdef CONFIG_VSERVER_HARDCPU
16232 +#define HARDCPU(x) (x)
16234 +#define HARDCPU(x) (0)
16237 +#ifdef CONFIG_VSERVER_IDLETIME
16238 +#define IDLETIME(x) (x)
16240 +#define IDLETIME(x) (0)
16243 +struct _vx_mon_entry *vxm_advance(int cpu);
16247 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
16249 + entry->type = type;
16250 + entry->xid = xid;
16254 +void __vxm_sync(int cpu)
16256 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16258 + __vxm_basic(entry, 0, VXM_SYNC);
16259 + entry->ev.sec = xtime.tv_sec;
16260 + entry->ev.nsec = xtime.tv_nsec;
16264 +void __vxm_task(struct task_struct *p, int type)
16266 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
16268 + __vxm_basic(entry, p->xid, type);
16269 + entry->ev.tsk.pid = p->pid;
16270 + entry->ev.tsk.state = p->state;
16274 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16276 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16278 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
16279 + entry->sd.tokens = s->tokens;
16280 + entry->sd.norm_time = s->norm_time;
16281 + entry->sd.idle_time = s->idle_time;
16285 +void __vxm_rqinfo1(struct rq *q, int cpu)
16287 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16289 + entry->type = VXM_RQINFO_1;
16290 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
16291 + entry->q1.running = q->nr_running;
16292 + entry->q1.onhold = HARDCPU(q->nr_onhold);
16293 + entry->q1.iowait = atomic_read(&q->nr_iowait);
16294 + entry->q1.uintr = q->nr_uninterruptible;
16295 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
16299 +void __vxm_rqinfo2(struct rq *q, int cpu)
16301 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16303 + entry->type = VXM_RQINFO_2;
16304 + entry->xid = (unsigned long)q & 0xffff;
16305 + entry->q2.norm_time = q->norm_time;
16306 + entry->q2.idle_time = q->idle_time;
16307 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
16311 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16313 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16315 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
16316 + entry->ev.tokens = s->tokens;
16320 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16322 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16324 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
16325 + entry->u1.tokens_max = s->tokens_max;
16326 + entry->u1.fill_rate = s->fill_rate[0];
16327 + entry->u1.interval = s->interval[0];
16331 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16333 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16335 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
16336 + entry->u2.tokens_min = s->tokens_min;
16337 + entry->u2.fill_rate = s->fill_rate[1];
16338 + entry->u2.interval = s->interval[1];
16342 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
16343 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
16344 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
16345 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
16346 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
16349 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
16351 + __vxm_task(p, VXM_MIGRATE);
16352 + __vxm_rqinfo1(rq, task_cpu(p));
16353 + __vxm_rqinfo2(rq, task_cpu(p));
16357 +void vxm_idle_skip(struct rq *rq, int cpu)
16359 + __vxm_rqinfo1(rq, cpu);
16360 + __vxm_rqinfo2(rq, cpu);
16364 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
16369 + __vxm_task(p, VXM_RESCHED);
16373 +void vxm_sync(unsigned long now, int cpu)
16375 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
16376 + (now % CONFIG_VSERVER_MONITOR_SYNC))
16382 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
16385 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
16386 + struct vx_info *vxi, int cpu)
16388 + __vxm_sched(s, vxi, cpu);
16389 + __vxm_rqinfo2(rq, cpu);
16393 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16395 + __vxm_sched(s, vxi, cpu);
16396 + __vxm_update(s, vxi, cpu);
16397 + __vxm_update1(s, vxi, cpu);
16398 + __vxm_update2(s, vxi, cpu);
16402 +void vxm_rq_max_min(struct rq *rq, int cpu)
16404 + __vxm_rqinfo1(rq, cpu);
16405 + __vxm_rqinfo2(rq, cpu);
16408 +#else /* CONFIG_VSERVER_MONITOR */
16410 +#define vxm_activate_task(t,q) do { } while (0)
16411 +#define vxm_activate_idle(t,q) do { } while (0)
16412 +#define vxm_deactivate_task(t,q) do { } while (0)
16413 +#define vxm_hold_task(t,q) do { } while (0)
16414 +#define vxm_unhold_task(t,q) do { } while (0)
16415 +#define vxm_migrate_task(t,q,d) do { } while (0)
16416 +#define vxm_idle_skip(q,c) do { } while (0)
16417 +#define vxm_need_resched(t,s,c) do { } while (0)
16418 +#define vxm_sync(s,c) do { } while (0)
16419 +#define vxm_sched_info(s,v,c) do { } while (0)
16420 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
16421 +#define vxm_update_sched(s,v,c) do { } while (0)
16422 +#define vxm_rq_max_min(q,c) do { } while (0)
16424 +#endif /* CONFIG_VSERVER_MONITOR */
16426 diff -NurpP --minimal linux-2.6.29/kernel/signal.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/signal.c
16427 --- linux-2.6.29/kernel/signal.c 2009-03-24 14:22:45.000000000 +0100
16428 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/signal.c 2009-03-24 14:48:36.000000000 +0100
16430 #include <linux/freezer.h>
16431 #include <linux/pid_namespace.h>
16432 #include <linux/nsproxy.h>
16433 +#include <linux/vs_context.h>
16434 +#include <linux/vs_pid.h>
16435 #include <trace/sched.h>
16437 #include <asm/param.h>
16438 @@ -584,6 +586,14 @@ static int check_kill_permission(int sig
16439 if (!valid_signal(sig))
16442 + if ((info != SEND_SIG_NOINFO) &&
16443 + (is_si_special(info) || !SI_FROMUSER(info)))
16446 + vxdprintk(VXD_CBIT(misc, 7),
16447 + "check_kill_permission(%d,%p,%p[#%u,%u])",
16448 + sig, info, t, vx_task_xid(t), t->pid);
16450 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
16453 @@ -611,6 +621,18 @@ static int check_kill_permission(int sig
16458 + if (t->pid == 1 && current->xid)
16462 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
16463 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
16464 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
16465 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
16469 return security_task_kill(t, info, sig, 0);
16472 @@ -1076,7 +1098,7 @@ int kill_pid_info(int sig, struct siginf
16475 p = pid_task(pid, PIDTYPE_PID);
16477 + if (p && vx_check(vx_task_xid(p), VS_ADMIN | VS_IDENT)) {
16478 error = group_send_sig_info(sig, info, p);
16479 if (unlikely(error == -ESRCH))
16481 @@ -1115,7 +1137,7 @@ int kill_pid_info_as_uid(int sig, struct
16483 read_lock(&tasklist_lock);
16484 p = pid_task(pid, PIDTYPE_PID);
16486 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
16490 @@ -1169,8 +1191,10 @@ static int kill_something_info(int sig,
16491 struct task_struct * p;
16493 for_each_process(p) {
16494 - if (task_pid_vnr(p) > 1 &&
16495 - !same_thread_group(p, current)) {
16496 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
16497 + task_pid_vnr(p) > 1 &&
16498 + !same_thread_group(p, current) &&
16499 + !vx_current_initpid(p->pid)) {
16500 int err = group_send_sig_info(sig, info, p);
16503 @@ -1849,6 +1873,11 @@ relock:
16504 !signal_group_exit(signal))
16507 + /* virtual init is protected against user signals */
16508 + if ((info->si_code == SI_USER) &&
16509 + vx_current_initpid(current->pid))
16512 if (sig_kernel_stop(signr)) {
16514 * The default action is to stop all threads in
16515 diff -NurpP --minimal linux-2.6.29/kernel/softirq.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/softirq.c
16516 --- linux-2.6.29/kernel/softirq.c 2009-03-24 14:22:45.000000000 +0100
16517 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/softirq.c 2009-03-24 14:48:36.000000000 +0100
16519 #include <linux/rcupdate.h>
16520 #include <linux/smp.h>
16521 #include <linux/tick.h>
16522 +#include <linux/vs_context.h>
16524 #include <asm/irq.h>
16526 diff -NurpP --minimal linux-2.6.29/kernel/sys.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sys.c
16527 --- linux-2.6.29/kernel/sys.c 2009-03-24 14:22:45.000000000 +0100
16528 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sys.c 2009-03-24 14:48:36.000000000 +0100
16530 #include <linux/syscalls.h>
16531 #include <linux/kprobes.h>
16532 #include <linux/user_namespace.h>
16533 +#include <linux/vs_pid.h>
16535 #include <asm/uaccess.h>
16536 #include <asm/io.h>
16537 @@ -128,7 +129,10 @@ static int set_one_prio(struct task_stru
16540 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
16542 + if (vx_flags(VXF_IGNEG_NICE, 0))
16548 no_nice = security_task_setnice(p, niceval);
16549 @@ -177,6 +181,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
16551 pgrp = task_pgrp(current);
16552 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16553 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16555 error = set_one_prio(p, niceval, error);
16556 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
16558 @@ -238,6 +244,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
16560 pgrp = task_pgrp(current);
16561 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16562 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16564 niceval = 20 - task_nice(p);
16565 if (niceval > retval)
16567 @@ -347,6 +355,9 @@ void kernel_power_off(void)
16568 machine_power_off();
16570 EXPORT_SYMBOL_GPL(kernel_power_off);
16572 +long vs_reboot(unsigned int, void __user *);
16575 * Reboot system call: for obvious reasons only root may call it,
16576 * and even root needs to set up some magic numbers in the registers
16577 @@ -378,6 +389,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
16578 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
16579 cmd = LINUX_REBOOT_CMD_HALT;
16581 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16582 + return vs_reboot(cmd, arg);
16586 case LINUX_REBOOT_CMD_RESTART:
16587 @@ -1420,7 +1434,7 @@ SYSCALL_DEFINE2(sethostname, char __user
16589 char tmp[__NEW_UTS_LEN];
16591 - if (!capable(CAP_SYS_ADMIN))
16592 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16594 if (len < 0 || len > __NEW_UTS_LEN)
16596 @@ -1469,7 +1483,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
16598 char tmp[__NEW_UTS_LEN];
16600 - if (!capable(CAP_SYS_ADMIN))
16601 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16603 if (len < 0 || len > __NEW_UTS_LEN)
16605 @@ -1538,7 +1552,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
16607 old_rlim = current->signal->rlim + resource;
16608 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
16609 - !capable(CAP_SYS_RESOURCE))
16610 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
16612 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
16614 diff -NurpP --minimal linux-2.6.29/kernel/sysctl.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sysctl.c
16615 --- linux-2.6.29/kernel/sysctl.c 2009-03-24 14:22:45.000000000 +0100
16616 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sysctl.c 2009-03-24 14:48:36.000000000 +0100
16617 @@ -114,6 +114,7 @@ static int ngroups_max = NGROUPS_MAX;
16618 #ifdef CONFIG_MODULES
16619 extern char modprobe_path[];
16621 +extern char vshelper_path[];
16622 #ifdef CONFIG_CHR_DEV_SG
16623 extern int sg_big_buff;
16625 @@ -545,6 +546,15 @@ static struct ctl_table kern_table[] = {
16626 .strategy = &sysctl_string,
16630 + .ctl_name = KERN_VSHELPER,
16631 + .procname = "vshelper",
16632 + .data = &vshelper_path,
16635 + .proc_handler = &proc_dostring,
16636 + .strategy = &sysctl_string,
16638 #ifdef CONFIG_CHR_DEV_SG
16640 .ctl_name = KERN_SG_BIG_BUFF,
16641 diff -NurpP --minimal linux-2.6.29/kernel/sysctl_check.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sysctl_check.c
16642 --- linux-2.6.29/kernel/sysctl_check.c 2009-03-24 14:22:45.000000000 +0100
16643 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/sysctl_check.c 2009-03-24 14:48:36.000000000 +0100
16644 @@ -39,6 +39,7 @@ static const struct trans_ctl_table tran
16646 { KERN_PANIC, "panic" },
16647 { KERN_REALROOTDEV, "real-root-dev" },
16648 + { KERN_VSHELPER, "vshelper", },
16650 { KERN_SPARC_REBOOT, "reboot-cmd" },
16651 { KERN_CTLALTDEL, "ctrl-alt-del" },
16652 @@ -1216,6 +1217,22 @@ static const struct trans_ctl_table tran
16656 +static struct trans_ctl_table trans_vserver_table[] = {
16657 + { 1, "debug_switch" },
16658 + { 2, "debug_xid" },
16659 + { 3, "debug_nid" },
16660 + { 4, "debug_tag" },
16661 + { 5, "debug_net" },
16662 + { 6, "debug_limit" },
16663 + { 7, "debug_cres" },
16664 + { 8, "debug_dlim" },
16665 + { 9, "debug_quota" },
16666 + { 10, "debug_cvirt" },
16667 + { 11, "debug_space" },
16668 + { 12, "debug_misc" },
16672 static const struct trans_ctl_table trans_root_table[] = {
16673 { CTL_KERN, "kernel", trans_kern_table },
16674 { CTL_VM, "vm", trans_vm_table },
16675 @@ -1232,6 +1249,7 @@ static const struct trans_ctl_table tran
16676 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
16677 { CTL_PM, "pm", trans_pm_table },
16678 { CTL_FRV, "frv", trans_frv_table },
16679 + { CTL_VSERVER, "vserver", trans_vserver_table },
16683 diff -NurpP --minimal linux-2.6.29/kernel/time.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/time.c
16684 --- linux-2.6.29/kernel/time.c 2009-03-24 14:22:45.000000000 +0100
16685 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/time.c 2009-03-24 14:48:36.000000000 +0100
16686 @@ -63,6 +63,7 @@ EXPORT_SYMBOL(sys_tz);
16687 SYSCALL_DEFINE1(time, time_t __user *, tloc)
16689 time_t i = get_seconds();
16690 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
16693 if (put_user(i,tloc))
16694 @@ -93,7 +94,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
16698 - do_settimeofday(&tv);
16699 + vx_settimeofday(&tv);
16703 @@ -104,7 +105,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
16705 if (likely(tv != NULL)) {
16706 struct timeval ktv;
16707 - do_gettimeofday(&ktv);
16708 + vx_gettimeofday(&ktv);
16709 if (copy_to_user(tv, &ktv, sizeof(ktv)))
16712 @@ -179,7 +180,7 @@ int do_sys_settimeofday(struct timespec
16713 /* SMP safe, again the code in arch/foo/time.c should
16714 * globally block out interrupts when it runs.
16716 - return do_settimeofday(tv);
16717 + return vx_settimeofday(tv);
16721 @@ -311,7 +312,7 @@ void getnstimeofday(struct timespec *tv)
16725 - do_gettimeofday(&x);
16726 + vx_gettimeofday(&x);
16727 tv->tv_sec = x.tv_sec;
16728 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
16730 diff -NurpP --minimal linux-2.6.29/kernel/timer.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/timer.c
16731 --- linux-2.6.29/kernel/timer.c 2009-03-24 14:22:45.000000000 +0100
16732 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/timer.c 2009-03-24 17:41:02.000000000 +0100
16734 #include <linux/delay.h>
16735 #include <linux/tick.h>
16736 #include <linux/kallsyms.h>
16737 +#include <linux/vs_base.h>
16738 +#include <linux/vs_cvirt.h>
16739 +#include <linux/vs_pid.h>
16740 +#include <linux/vserver/sched.h>
16742 #include <asm/uaccess.h>
16743 #include <asm/unistd.h>
16744 @@ -1018,6 +1022,25 @@ unsigned long get_next_timer_interrupt(u
16749 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
16751 + sched_pc->tokens--;
16755 +void vx_hard_tick(struct task_struct *p, int cpu)
16757 + struct vx_info *vxi = p->vx_info;
16759 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
16760 + struct _vx_sched_pc *sched_pc =
16761 + &vx_per_cpu(vxi, sched_pc, cpu);
16763 + __vx_consume_token(sched_pc);
16768 * Called from the timer interrupt handler to charge one tick to the current
16769 * process. user_tick is 1 if the tick is user time, 0 for system.
16770 @@ -1034,6 +1057,7 @@ void update_process_times(int user_tick)
16771 rcu_check_callbacks(cpu, user_tick);
16774 + vx_hard_tick(p, cpu);
16775 run_posix_cpu_timers(p);
16778 @@ -1136,12 +1160,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
16785 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
16786 - * should be moved into arch/i386 instead?
16790 * sys_getpid - return the thread group id of the current process
16791 @@ -1170,10 +1188,23 @@ SYSCALL_DEFINE0(getppid)
16793 pid = task_tgid_vnr(current->real_parent);
16795 + return vx_map_pid(pid);
16802 + * The Alpha uses getxpid, getxuid, and getxgid instead.
16805 +asmlinkage long do_getxpid(long *ppid)
16807 + *ppid = sys_getppid();
16808 + return sys_getpid();
16811 +#else /* _alpha_ */
16813 SYSCALL_DEFINE0(getuid)
16815 /* Only we change this so SMP safe */
16816 @@ -1344,6 +1375,8 @@ int do_sysinfo(struct sysinfo *info)
16817 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
16820 + if (vx_flags(VXF_VIRT_UPTIME, 0))
16821 + vx_vsi_uptime(&tp, NULL);
16822 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
16824 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
16825 diff -NurpP --minimal linux-2.6.29/kernel/user.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/user.c
16826 --- linux-2.6.29/kernel/user.c 2009-03-24 14:22:45.000000000 +0100
16827 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/user.c 2009-03-24 17:47:32.000000000 +0100
16828 @@ -249,10 +249,10 @@ static struct kobj_type uids_ktype = {
16830 * See Documentation/scheduler/sched-design-CFS.txt for ramifications.
16832 -static int uids_user_create(struct user_struct *up)
16833 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
16835 struct kobject *kobj = &up->kobj;
16839 memset(kobj, 0, sizeof(struct kobject));
16840 if (up->user_ns != &init_user_ns)
16841 @@ -280,7 +280,7 @@ int __init uids_sysfs_init(void)
16845 - return uids_user_create(&root_user);
16846 + return uids_user_create(NULL, &root_user);
16849 /* work function to remove sysfs directory for a user and free up
16850 @@ -342,7 +342,8 @@ static void free_user(struct user_struct
16851 #else /* CONFIG_USER_SCHED && CONFIG_SYSFS */
16853 int uids_sysfs_init(void) { return 0; }
16854 -static inline int uids_user_create(struct user_struct *up) { return 0; }
16855 +static inline int uids_user_create(struct user_namespace *ns,
16856 + struct user_struct *up) { return 0; }
16857 static inline void uids_mutex_lock(void) { }
16858 static inline void uids_mutex_unlock(void) { }
16860 @@ -439,7 +440,7 @@ struct user_struct *alloc_uid(struct use
16862 new->user_ns = get_user_ns(ns);
16864 - if (uids_user_create(new))
16865 + if (uids_user_create(ns, new))
16866 goto out_destoy_sched;
16869 diff -NurpP --minimal linux-2.6.29/kernel/user_namespace.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/user_namespace.c
16870 --- linux-2.6.29/kernel/user_namespace.c 2009-03-24 14:22:45.000000000 +0100
16871 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/user_namespace.c 2009-03-24 18:05:19.000000000 +0100
16873 #include <linux/slab.h>
16874 #include <linux/user_namespace.h>
16875 #include <linux/cred.h>
16876 +#include <linux/vserver/global.h>
16879 * Create a new user namespace, deriving the creator from the user in the
16880 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
16883 kref_init(&ns->kref);
16884 + atomic_inc(&vs_global_user_ns);
16886 for (n = 0; n < UIDHASH_SZ; ++n)
16887 INIT_HLIST_HEAD(ns->uidhash_table + n);
16888 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
16889 struct user_namespace *ns =
16890 container_of(kref, struct user_namespace, kref);
16892 + /* FIXME: maybe move into destroyer? */
16893 + atomic_dec(&vs_global_user_ns);
16894 INIT_WORK(&ns->destroyer, free_user_ns_work);
16895 schedule_work(&ns->destroyer);
16897 diff -NurpP --minimal linux-2.6.29/kernel/utsname.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/utsname.c
16898 --- linux-2.6.29/kernel/utsname.c 2008-12-25 00:26:37.000000000 +0100
16899 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/utsname.c 2009-02-22 22:54:26.000000000 +0100
16901 #include <linux/utsname.h>
16902 #include <linux/err.h>
16903 #include <linux/slab.h>
16904 +#include <linux/vserver/global.h>
16907 * Clone a new ns copying an original utsname, setting refcount to 1
16908 @@ -32,6 +33,7 @@ static struct uts_namespace *clone_uts_n
16909 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
16911 kref_init(&ns->kref);
16912 + atomic_inc(&vs_global_uts_ns);
16916 @@ -62,5 +64,6 @@ void free_uts_ns(struct kref *kref)
16917 struct uts_namespace *ns;
16919 ns = container_of(kref, struct uts_namespace, kref);
16920 + atomic_dec(&vs_global_uts_ns);
16923 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cacct.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cacct.c
16924 --- linux-2.6.29/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16925 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cacct.c 2009-02-22 22:54:26.000000000 +0100
16928 + * linux/kernel/vserver/cacct.c
16930 + * Virtual Server: Context Accounting
16932 + * Copyright (C) 2006-2007 Herbert Pötzl
16934 + * V0.01 added accounting stats
16938 +#include <linux/types.h>
16939 +#include <linux/vs_context.h>
16940 +#include <linux/vserver/cacct_cmd.h>
16941 +#include <linux/vserver/cacct_int.h>
16943 +#include <asm/errno.h>
16944 +#include <asm/uaccess.h>
16947 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16949 + struct vcmd_sock_stat_v0 vc_data;
16952 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16955 + field = vc_data.field;
16956 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16959 + for (j = 0; j < 3; j++) {
16960 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16961 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16964 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16969 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cacct_init.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cacct_init.h
16970 --- linux-2.6.29/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16971 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cacct_init.h 2009-02-22 22:54:26.000000000 +0100
16975 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16980 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16981 + for (j = 0; j < 3; j++) {
16982 + atomic_set(&cacct->sock[i][j].count, 0);
16983 + atomic_set(&cacct->sock[i][j].total, 0);
16986 + for (i = 0; i < 8; i++)
16987 + atomic_set(&cacct->slab[i], 0);
16988 + for (i = 0; i < 5; i++)
16989 + for (j = 0; j < 4; j++)
16990 + atomic_set(&cacct->page[i][j], 0);
16993 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16998 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cacct_proc.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cacct_proc.h
16999 --- linux-2.6.29/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17000 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cacct_proc.h 2009-02-22 22:54:26.000000000 +0100
17002 +#ifndef _VX_CACCT_PROC_H
17003 +#define _VX_CACCT_PROC_H
17005 +#include <linux/vserver/cacct_int.h>
17008 +#define VX_SOCKA_TOP \
17009 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17011 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17013 + int i, j, length = 0;
17014 + static char *type[VXA_SOCK_SIZE] = {
17015 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17018 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17019 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17020 + length += sprintf(buffer + length, "%s:", type[i]);
17021 + for (j = 0; j < 3; j++) {
17022 + length += sprintf(buffer + length,
17023 + "\t%10lu/%-10lu",
17024 + vx_sock_count(cacct, i, j),
17025 + vx_sock_total(cacct, i, j));
17027 + buffer[length++] = '\n';
17030 + length += sprintf(buffer + length, "\n");
17031 + length += sprintf(buffer + length,
17032 + "slab:\t %8u %8u %8u %8u\n",
17033 + atomic_read(&cacct->slab[1]),
17034 + atomic_read(&cacct->slab[4]),
17035 + atomic_read(&cacct->slab[0]),
17036 + atomic_read(&cacct->slab[2]));
17038 + length += sprintf(buffer + length, "\n");
17039 + for (i = 0; i < 5; i++) {
17040 + length += sprintf(buffer + length,
17041 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17042 + atomic_read(&cacct->page[i][0]),
17043 + atomic_read(&cacct->page[i][1]),
17044 + atomic_read(&cacct->page[i][2]),
17045 + atomic_read(&cacct->page[i][3]),
17046 + atomic_read(&cacct->page[i][4]),
17047 + atomic_read(&cacct->page[i][5]),
17048 + atomic_read(&cacct->page[i][6]),
17049 + atomic_read(&cacct->page[i][7]));
17054 +#endif /* _VX_CACCT_PROC_H */
17055 diff -NurpP --minimal linux-2.6.29/kernel/vserver/context.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/context.c
17056 --- linux-2.6.29/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17057 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/context.c 2009-02-22 22:54:26.000000000 +0100
17060 + * linux/kernel/vserver/context.c
17062 + * Virtual Server: Context Support
17064 + * Copyright (C) 2003-2007 Herbert Pötzl
17066 + * V0.01 context helper
17067 + * V0.02 vx_ctx_kill syscall command
17068 + * V0.03 replaced context_info calls
17069 + * V0.04 redesign of struct (de)alloc
17070 + * V0.05 rlimit basic implementation
17071 + * V0.06 task_xid and info commands
17072 + * V0.07 context flags and caps
17073 + * V0.08 switch to RCU based hash
17074 + * V0.09 revert to non RCU for now
17075 + * V0.10 and back to working RCU hash
17076 + * V0.11 and back to locking again
17077 + * V0.12 referenced context store
17078 + * V0.13 separate per cpu data
17079 + * V0.14 changed vcmds to vxi arg
17080 + * V0.15 added context stat
17081 + * V0.16 have __create claim() the vxi
17082 + * V0.17 removed older and legacy stuff
17086 +#include <linux/slab.h>
17087 +#include <linux/types.h>
17088 +#include <linux/security.h>
17089 +#include <linux/pid_namespace.h>
17091 +#include <linux/vserver/context.h>
17092 +#include <linux/vserver/network.h>
17093 +#include <linux/vserver/debug.h>
17094 +#include <linux/vserver/limit.h>
17095 +#include <linux/vserver/limit_int.h>
17096 +#include <linux/vserver/space.h>
17098 +#include <linux/vs_context.h>
17099 +#include <linux/vs_limit.h>
17100 +#include <linux/vs_pid.h>
17101 +#include <linux/vserver/context_cmd.h>
17103 +#include "cvirt_init.h"
17104 +#include "cacct_init.h"
17105 +#include "limit_init.h"
17106 +#include "sched_init.h"
17109 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17110 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17113 +/* now inactive context structures */
17115 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17117 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17120 +/* __alloc_vx_info()
17122 + * allocate an initialized vx_info struct
17123 + * doesn't make it visible (hash) */
17125 +static struct vx_info *__alloc_vx_info(xid_t xid)
17127 + struct vx_info *new = NULL;
17130 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17132 + /* would this benefit from a slab cache? */
17133 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17137 + memset(new, 0, sizeof(struct vx_info));
17139 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17140 + if (!new->ptr_pc)
17143 + new->vx_id = xid;
17144 + INIT_HLIST_NODE(&new->vx_hlist);
17145 + atomic_set(&new->vx_usecnt, 0);
17146 + atomic_set(&new->vx_tasks, 0);
17147 + new->vx_parent = NULL;
17148 + new->vx_state = 0;
17149 + init_waitqueue_head(&new->vx_wait);
17151 + /* prepare reaper */
17152 + get_task_struct(init_pid_ns.child_reaper);
17153 + new->vx_reaper = init_pid_ns.child_reaper;
17154 + new->vx_badness_bias = 0;
17156 + /* rest of init goes here */
17157 + vx_info_init_limit(&new->limit);
17158 + vx_info_init_sched(&new->sched);
17159 + vx_info_init_cvirt(&new->cvirt);
17160 + vx_info_init_cacct(&new->cacct);
17162 + /* per cpu data structures */
17163 + for_each_possible_cpu(cpu) {
17164 + vx_info_init_sched_pc(
17165 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17166 + vx_info_init_cvirt_pc(
17167 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17170 + new->vx_flags = VXF_INIT_SET;
17171 + cap_set_init_eff(new->vx_bcaps);
17172 + new->vx_ccaps = 0;
17173 + // new->vx_cap_bset = current->cap_bset;
17175 + new->reboot_cmd = 0;
17176 + new->exit_code = 0;
17178 + vxdprintk(VXD_CBIT(xid, 0),
17179 + "alloc_vx_info(%d) = %p", xid, new);
17180 + vxh_alloc_vx_info(new);
17181 + atomic_inc(&vx_global_ctotal);
17190 +/* __dealloc_vx_info()
17192 + * final disposal of vx_info */
17194 +static void __dealloc_vx_info(struct vx_info *vxi)
17196 + struct vx_info_save vxis;
17199 + vxdprintk(VXD_CBIT(xid, 0),
17200 + "dealloc_vx_info(%p)", vxi);
17201 + vxh_dealloc_vx_info(vxi);
17203 +#ifdef CONFIG_VSERVER_WARN
17204 + enter_vx_info(vxi, &vxis);
17205 + vx_info_exit_limit(&vxi->limit);
17206 + vx_info_exit_sched(&vxi->sched);
17207 + vx_info_exit_cvirt(&vxi->cvirt);
17208 + vx_info_exit_cacct(&vxi->cacct);
17210 + for_each_possible_cpu(cpu) {
17211 + vx_info_exit_sched_pc(
17212 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17213 + vx_info_exit_cvirt_pc(
17214 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17216 + leave_vx_info(&vxis);
17220 + vxi->vx_state |= VXS_RELEASED;
17223 + free_percpu(vxi->ptr_pc);
17226 + atomic_dec(&vx_global_ctotal);
17229 +static void __shutdown_vx_info(struct vx_info *vxi)
17231 + struct nsproxy *nsproxy;
17232 + struct fs_struct *fs;
17237 + vxi->vx_state |= VXS_SHUTDOWN;
17238 + vs_state_change(vxi, VSC_SHUTDOWN);
17240 + for (index = 0; index < VX_SPACES; index++) {
17241 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17243 + put_nsproxy(nsproxy);
17245 + fs = xchg(&vxi->vx_fs[index], NULL);
17247 + put_fs_struct(fs);
17251 +/* exported stuff */
17253 +void free_vx_info(struct vx_info *vxi)
17255 + unsigned long flags;
17258 + /* check for reference counts first */
17259 + BUG_ON(atomic_read(&vxi->vx_usecnt));
17260 + BUG_ON(atomic_read(&vxi->vx_tasks));
17262 + /* context must not be hashed */
17263 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17265 + /* context shutdown is mandatory */
17266 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17268 + /* nsproxy and fs check */
17269 + for (index = 0; index < VX_SPACES; index++) {
17270 + BUG_ON(vxi->vx_nsproxy[index]);
17271 + BUG_ON(vxi->vx_fs[index]);
17274 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17275 + hlist_del(&vxi->vx_hlist);
17276 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17278 + __dealloc_vx_info(vxi);
17282 +/* hash table for vx_info hash */
17284 +#define VX_HASH_SIZE 13
17286 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17287 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17289 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17292 +static inline unsigned int __hashval(xid_t xid)
17294 + return (xid % VX_HASH_SIZE);
17299 +/* __hash_vx_info()
17301 + * add the vxi to the global hash table
17302 + * requires the hash_lock to be held */
17304 +static inline void __hash_vx_info(struct vx_info *vxi)
17306 + struct hlist_head *head;
17308 + vxd_assert_lock(&vx_info_hash_lock);
17309 + vxdprintk(VXD_CBIT(xid, 4),
17310 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17311 + vxh_hash_vx_info(vxi);
17313 + /* context must not be hashed */
17314 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17316 + vxi->vx_state |= VXS_HASHED;
17317 + head = &vx_info_hash[__hashval(vxi->vx_id)];
17318 + hlist_add_head(&vxi->vx_hlist, head);
17319 + atomic_inc(&vx_global_cactive);
17322 +/* __unhash_vx_info()
17324 + * remove the vxi from the global hash table
17325 + * requires the hash_lock to be held */
17327 +static inline void __unhash_vx_info(struct vx_info *vxi)
17329 + unsigned long flags;
17331 + vxd_assert_lock(&vx_info_hash_lock);
17332 + vxdprintk(VXD_CBIT(xid, 4),
17333 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17334 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17335 + vxh_unhash_vx_info(vxi);
17337 + /* context must be hashed */
17338 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17339 + /* but without tasks */
17340 + BUG_ON(atomic_read(&vxi->vx_tasks));
17342 + vxi->vx_state &= ~VXS_HASHED;
17343 + hlist_del_init(&vxi->vx_hlist);
17344 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17345 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17346 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17347 + atomic_dec(&vx_global_cactive);
17351 +/* __lookup_vx_info()
17353 + * requires the hash_lock to be held
17354 + * doesn't increment the vx_refcnt */
17356 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17358 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17359 + struct hlist_node *pos;
17360 + struct vx_info *vxi;
17362 + vxd_assert_lock(&vx_info_hash_lock);
17363 + hlist_for_each(pos, head) {
17364 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17366 + if (vxi->vx_id == xid)
17371 + vxdprintk(VXD_CBIT(xid, 0),
17372 + "__lookup_vx_info(#%u): %p[#%u]",
17373 + xid, vxi, vxi ? vxi->vx_id : 0);
17374 + vxh_lookup_vx_info(vxi, xid);
17379 +/* __create_vx_info()
17381 + * create the requested context
17382 + * get(), claim() and hash it */
17384 +static struct vx_info *__create_vx_info(int id)
17386 + struct vx_info *new, *vxi = NULL;
17388 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17390 + if (!(new = __alloc_vx_info(id)))
17391 + return ERR_PTR(-ENOMEM);
17393 + /* required to make dynamic xids unique */
17394 + spin_lock(&vx_info_hash_lock);
17396 + /* static context requested */
17397 + if ((vxi = __lookup_vx_info(id))) {
17398 + vxdprintk(VXD_CBIT(xid, 0),
17399 + "create_vx_info(%d) = %p (already there)", id, vxi);
17400 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17401 + vxi = ERR_PTR(-EBUSY);
17403 + vxi = ERR_PTR(-EEXIST);
17406 + /* new context */
17407 + vxdprintk(VXD_CBIT(xid, 0),
17408 + "create_vx_info(%d) = %p (new)", id, new);
17409 + claim_vx_info(new, NULL);
17410 + __hash_vx_info(get_vx_info(new));
17411 + vxi = new, new = NULL;
17414 + spin_unlock(&vx_info_hash_lock);
17415 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
17417 + __dealloc_vx_info(new);
17422 +/* exported stuff */
17425 +void unhash_vx_info(struct vx_info *vxi)
17427 + __shutdown_vx_info(vxi);
17428 + spin_lock(&vx_info_hash_lock);
17429 + __unhash_vx_info(vxi);
17430 + spin_unlock(&vx_info_hash_lock);
17431 + __wakeup_vx_info(vxi);
17435 +/* lookup_vx_info()
17437 + * search for a vx_info and get() it
17438 + * negative id means current */
17440 +struct vx_info *lookup_vx_info(int id)
17442 + struct vx_info *vxi = NULL;
17445 + vxi = get_vx_info(current->vx_info);
17446 + } else if (id > 1) {
17447 + spin_lock(&vx_info_hash_lock);
17448 + vxi = get_vx_info(__lookup_vx_info(id));
17449 + spin_unlock(&vx_info_hash_lock);
17454 +/* xid_is_hashed()
17456 + * verify that xid is still hashed */
17458 +int xid_is_hashed(xid_t xid)
17462 + spin_lock(&vx_info_hash_lock);
17463 + hashed = (__lookup_vx_info(xid) != NULL);
17464 + spin_unlock(&vx_info_hash_lock);
17468 +#ifdef CONFIG_PROC_FS
17472 + * get a subset of hashed xids for proc
17473 + * assumes size is at least one */
17475 +int get_xid_list(int index, unsigned int *xids, int size)
17477 + int hindex, nr_xids = 0;
17479 + /* only show current and children */
17480 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
17483 + xids[nr_xids] = vx_current_xid();
17487 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
17488 + struct hlist_head *head = &vx_info_hash[hindex];
17489 + struct hlist_node *pos;
17491 + spin_lock(&vx_info_hash_lock);
17492 + hlist_for_each(pos, head) {
17493 + struct vx_info *vxi;
17498 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17499 + xids[nr_xids] = vxi->vx_id;
17500 + if (++nr_xids >= size) {
17501 + spin_unlock(&vx_info_hash_lock);
17505 + /* keep the lock time short */
17506 + spin_unlock(&vx_info_hash_lock);
17513 +#ifdef CONFIG_VSERVER_DEBUG
17515 +void dump_vx_info_inactive(int level)
17517 + struct hlist_node *entry, *next;
17519 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
17520 + struct vx_info *vxi =
17521 + list_entry(entry, struct vx_info, vx_hlist);
17523 + dump_vx_info(vxi, level);
17530 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
17532 + struct user_struct *new_user, *old_user;
17537 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
17540 + new_user = alloc_uid(vxi->vx_id, p->uid);
17544 + old_user = p->user;
17545 + if (new_user != old_user) {
17546 + atomic_inc(&new_user->processes);
17547 + atomic_dec(&old_user->processes);
17548 + p->user = new_user;
17550 + free_uid(old_user);
17556 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
17558 + // p->cap_effective &= vxi->vx_cap_bset;
17559 + p->cap_effective =
17560 + cap_intersect(p->cap_effective, vxi->cap_bset);
17561 + // p->cap_inheritable &= vxi->vx_cap_bset;
17562 + p->cap_inheritable =
17563 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
17564 + // p->cap_permitted &= vxi->vx_cap_bset;
17565 + p->cap_permitted =
17566 + cap_intersect(p->cap_permitted, vxi->cap_bset);
17571 +#include <linux/file.h>
17572 +#include <linux/fdtable.h>
17574 +static int vx_openfd_task(struct task_struct *tsk)
17576 + struct files_struct *files = tsk->files;
17577 + struct fdtable *fdt;
17578 + const unsigned long *bptr;
17579 + int count, total;
17581 + /* no rcu_read_lock() because of spin_lock() */
17582 + spin_lock(&files->file_lock);
17583 + fdt = files_fdtable(files);
17584 + bptr = fdt->open_fds->fds_bits;
17585 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
17586 + for (total = 0; count > 0; count--) {
17588 + total += hweight_long(*bptr);
17591 + spin_unlock(&files->file_lock);
17596 +/* for *space compatibility */
17598 +asmlinkage long sys_unshare(unsigned long);
17601 + * migrate task to new context
17602 + * gets vxi, puts old_vxi on change
17603 + * optionally unshares namespaces (hack)
17606 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
17608 + struct vx_info *old_vxi;
17614 + vxdprintk(VXD_CBIT(xid, 5),
17615 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
17616 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
17618 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
17619 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17622 + if (vx_info_state(vxi, VXS_SHUTDOWN))
17625 + old_vxi = task_get_vx_info(p);
17626 + if (old_vxi == vxi)
17629 +// if (!(ret = vx_migrate_user(p, vxi))) {
17634 + openfd = vx_openfd_task(p);
17637 + atomic_dec(&old_vxi->cvirt.nr_threads);
17638 + atomic_dec(&old_vxi->cvirt.nr_running);
17639 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
17640 + /* FIXME: what about the struct files here? */
17641 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
17642 + /* account for the executable */
17643 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
17645 + atomic_inc(&vxi->cvirt.nr_threads);
17646 + atomic_inc(&vxi->cvirt.nr_running);
17647 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
17648 + /* FIXME: what about the struct files here? */
17649 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
17650 + /* account for the executable */
17651 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
17654 + release_vx_info(old_vxi, p);
17655 + clr_vx_info(&p->vx_info);
17657 + claim_vx_info(vxi, p);
17658 + set_vx_info(&p->vx_info, vxi);
17659 + p->xid = vxi->vx_id;
17661 + vxdprintk(VXD_CBIT(xid, 5),
17662 + "moved task %p into vxi:%p[#%d]",
17663 + p, vxi, vxi->vx_id);
17665 + // vx_mask_cap_bset(vxi, p);
17668 + /* hack for *spaces to provide compatibility */
17670 + struct nsproxy *old_nsp, *new_nsp;
17672 + ret = unshare_nsproxy_namespaces(
17673 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
17678 + old_nsp = xchg(&p->nsproxy, new_nsp);
17679 + vx_set_space(vxi,
17680 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
17681 + put_nsproxy(old_nsp);
17685 + put_vx_info(old_vxi);
17689 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
17691 + struct task_struct *old_reaper;
17696 + vxdprintk(VXD_CBIT(xid, 6),
17697 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
17698 + vxi, vxi->vx_id, p, p->xid, p->pid);
17700 + old_reaper = vxi->vx_reaper;
17701 + if (old_reaper == p)
17704 + /* set new child reaper */
17705 + get_task_struct(p);
17706 + vxi->vx_reaper = p;
17707 + put_task_struct(old_reaper);
17711 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
17716 + vxdprintk(VXD_CBIT(xid, 6),
17717 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
17718 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17720 + vxi->vx_flags &= ~VXF_STATE_INIT;
17721 + vxi->vx_initpid = p->tgid;
17725 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
17727 + vxdprintk(VXD_CBIT(xid, 6),
17728 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
17729 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17731 + vxi->exit_code = code;
17732 + vxi->vx_initpid = 0;
17736 +void vx_set_persistent(struct vx_info *vxi)
17738 + vxdprintk(VXD_CBIT(xid, 6),
17739 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
17741 + get_vx_info(vxi);
17742 + claim_vx_info(vxi, NULL);
17745 +void vx_clear_persistent(struct vx_info *vxi)
17747 + vxdprintk(VXD_CBIT(xid, 6),
17748 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
17750 + release_vx_info(vxi, NULL);
17751 + put_vx_info(vxi);
17754 +void vx_update_persistent(struct vx_info *vxi)
17756 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
17757 + vx_set_persistent(vxi);
17759 + vx_clear_persistent(vxi);
17763 +/* task must be current or locked */
17765 +void exit_vx_info(struct task_struct *p, int code)
17767 + struct vx_info *vxi = p->vx_info;
17770 + atomic_dec(&vxi->cvirt.nr_threads);
17773 + vxi->exit_code = code;
17774 + release_vx_info(vxi, p);
17778 +void exit_vx_info_early(struct task_struct *p, int code)
17780 + struct vx_info *vxi = p->vx_info;
17783 + if (vxi->vx_initpid == p->tgid)
17784 + vx_exit_init(vxi, p, code);
17785 + if (vxi->vx_reaper == p)
17786 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
17791 +/* vserver syscall commands below here */
17793 +/* taks xid and vx_info functions */
17795 +#include <asm/uaccess.h>
17798 +int vc_task_xid(uint32_t id)
17803 + struct task_struct *tsk;
17805 + read_lock(&tasklist_lock);
17806 + tsk = find_task_by_real_pid(id);
17807 + xid = (tsk) ? tsk->xid : -ESRCH;
17808 + read_unlock(&tasklist_lock);
17810 + xid = vx_current_xid();
17815 +int vc_vx_info(struct vx_info *vxi, void __user *data)
17817 + struct vcmd_vx_info_v0 vc_data;
17819 + vc_data.xid = vxi->vx_id;
17820 + vc_data.initpid = vxi->vx_initpid;
17822 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17828 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
17830 + struct vcmd_ctx_stat_v0 vc_data;
17832 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
17833 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
17835 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17841 +/* context functions */
17843 +int vc_ctx_create(uint32_t xid, void __user *data)
17845 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
17846 + struct vx_info *new_vxi;
17849 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17852 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
17855 + new_vxi = __create_vx_info(xid);
17856 + if (IS_ERR(new_vxi))
17857 + return PTR_ERR(new_vxi);
17859 + /* initial flags */
17860 + new_vxi->vx_flags = vc_data.flagword;
17863 + if (vs_state_change(new_vxi, VSC_STARTUP))
17866 + ret = vx_migrate_task(current, new_vxi, (!data));
17870 + /* return context id on success */
17871 + ret = new_vxi->vx_id;
17873 + /* get a reference for persistent contexts */
17874 + if ((vc_data.flagword & VXF_PERSISTENT))
17875 + vx_set_persistent(new_vxi);
17877 + release_vx_info(new_vxi, NULL);
17878 + put_vx_info(new_vxi);
17883 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17885 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17888 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17891 + ret = vx_migrate_task(current, vxi, 0);
17894 + if (vc_data.flagword & VXM_SET_INIT)
17895 + ret = vx_set_init(vxi, current);
17898 + if (vc_data.flagword & VXM_SET_REAPER)
17899 + ret = vx_set_reaper(vxi, current);
17904 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17906 + struct vcmd_ctx_flags_v0 vc_data;
17908 + vc_data.flagword = vxi->vx_flags;
17910 + /* special STATE flag handling */
17911 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17913 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17918 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17920 + struct vcmd_ctx_flags_v0 vc_data;
17921 + uint64_t mask, trigger;
17923 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17926 + /* special STATE flag handling */
17927 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17928 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17930 + if (vxi == current->vx_info) {
17931 + /* if (trigger & VXF_STATE_SETUP)
17932 + vx_mask_cap_bset(vxi, current); */
17933 + if (trigger & VXF_STATE_INIT) {
17936 + ret = vx_set_init(vxi, current);
17939 + ret = vx_set_reaper(vxi, current);
17945 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17946 + vc_data.flagword, mask);
17947 + if (trigger & VXF_PERSISTENT)
17948 + vx_update_persistent(vxi);
17954 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17956 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17958 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17962 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17964 + kernel_cap_t c = __cap_empty_set;
17966 + c.cap[0] = v & 0xFFFFFFFF;
17967 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17969 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17974 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17977 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17979 + *ccaps = vxi->vx_ccaps;
17984 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17986 + struct vcmd_ctx_caps_v1 vc_data;
17989 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17992 + vc_data.cmask = ~0ULL;
17994 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17999 +static int do_set_caps(struct vx_info *vxi,
18000 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18002 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18005 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18006 + bcaps, bmask, ccaps, cmask);
18008 + vxi->vx_bcaps = cap_t_from_caps(
18009 + vs_mask_flags(bcold, bcaps, bmask));
18010 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18015 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18017 + struct vcmd_ctx_caps_v1 vc_data;
18019 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18022 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18025 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18027 + struct vcmd_bcaps vc_data;
18030 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18033 + vc_data.bmask = ~0ULL;
18035 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18040 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18042 + struct vcmd_bcaps vc_data;
18044 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18047 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18051 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18053 + struct vcmd_badness_v0 vc_data;
18055 + vc_data.bias = vxi->vx_badness_bias;
18057 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18062 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18064 + struct vcmd_badness_v0 vc_data;
18066 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18069 + vxi->vx_badness_bias = vc_data.bias;
18073 +#include <linux/module.h>
18075 +EXPORT_SYMBOL_GPL(free_vx_info);
18077 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cvirt.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cvirt.c
18078 --- linux-2.6.29/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18079 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cvirt.c 2009-02-22 22:54:26.000000000 +0100
18082 + * linux/kernel/vserver/cvirt.c
18084 + * Virtual Server: Context Virtualization
18086 + * Copyright (C) 2004-2007 Herbert Pötzl
18088 + * V0.01 broken out from limit.c
18089 + * V0.02 added utsname stuff
18090 + * V0.03 changed vcmds to vxi arg
18094 +#include <linux/types.h>
18095 +#include <linux/utsname.h>
18096 +#include <linux/vs_cvirt.h>
18097 +#include <linux/vserver/switch.h>
18098 +#include <linux/vserver/cvirt_cmd.h>
18100 +#include <asm/uaccess.h>
18103 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18105 + struct vx_info *vxi = current->vx_info;
18107 + set_normalized_timespec(uptime,
18108 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18109 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18112 + set_normalized_timespec(idle,
18113 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18114 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18118 +uint64_t vx_idle_jiffies(void)
18120 + return init_task.utime + init_task.stime;
18125 +static inline uint32_t __update_loadavg(uint32_t load,
18126 + int wsize, int delta, int n)
18128 + unsigned long long calc, prev;
18130 + /* just set it to n */
18131 + if (unlikely(delta >= wsize))
18132 + return (n << FSHIFT);
18134 + calc = delta * n;
18136 + prev = (wsize - delta);
18139 + do_div(calc, wsize);
18144 +void vx_update_load(struct vx_info *vxi)
18146 + uint32_t now, last, delta;
18147 + unsigned int nr_running, nr_uninterruptible;
18148 + unsigned int total;
18149 + unsigned long flags;
18151 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18154 + last = vxi->cvirt.load_last;
18155 + delta = now - last;
18157 + if (delta < 5*HZ)
18160 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18161 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18162 + total = nr_running + nr_uninterruptible;
18164 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18165 + 60*HZ, delta, total);
18166 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18167 + 5*60*HZ, delta, total);
18168 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18169 + 15*60*HZ, delta, total);
18171 + vxi->cvirt.load_last = now;
18173 + atomic_inc(&vxi->cvirt.load_updates);
18174 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18179 + * Commands to do_syslog:
18181 + * 0 -- Close the log. Currently a NOP.
18182 + * 1 -- Open the log. Currently a NOP.
18183 + * 2 -- Read from the log.
18184 + * 3 -- Read all messages remaining in the ring buffer.
18185 + * 4 -- Read and clear all messages remaining in the ring buffer
18186 + * 5 -- Clear ring buffer.
18187 + * 6 -- Disable printk's to console
18188 + * 7 -- Enable printk's to console
18189 + * 8 -- Set level of messages printed to console
18190 + * 9 -- Return number of unread characters in the log buffer
18191 + * 10 -- Return size of the log buffer
18193 +int vx_do_syslog(int type, char __user *buf, int len)
18196 + int do_clear = 0;
18197 + struct vx_info *vxi = current->vx_info;
18198 + struct _vx_syslog *log;
18202 + log = &vxi->cvirt.syslog;
18205 + case 0: /* Close log */
18206 + case 1: /* Open log */
18208 + case 2: /* Read from log */
18209 + error = wait_event_interruptible(log->log_wait,
18210 + (log->log_start - log->log_end));
18213 + spin_lock_irq(&log->logbuf_lock);
18214 + spin_unlock_irq(&log->logbuf_lock);
18216 + case 4: /* Read/clear last kernel messages */
18218 + /* fall through */
18219 + case 3: /* Read last kernel messages */
18222 + case 5: /* Clear ring buffer */
18225 + case 6: /* Disable logging to console */
18226 + case 7: /* Enable logging to console */
18227 + case 8: /* Set level of messages printed to console */
18230 + case 9: /* Number of chars in the log buffer */
18232 + case 10: /* Size of the log buffer */
18242 +/* virtual host info names */
18244 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18246 + struct nsproxy *nsproxy;
18247 + struct uts_namespace *uts;
18249 + if (id == VHIN_CONTEXT)
18250 + return vxi->vx_name;
18252 + nsproxy = vxi->vx_nsproxy[0];
18256 + uts = nsproxy->uts_ns;
18261 + case VHIN_SYSNAME:
18262 + return uts->name.sysname;
18263 + case VHIN_NODENAME:
18264 + return uts->name.nodename;
18265 + case VHIN_RELEASE:
18266 + return uts->name.release;
18267 + case VHIN_VERSION:
18268 + return uts->name.version;
18269 + case VHIN_MACHINE:
18270 + return uts->name.machine;
18271 + case VHIN_DOMAINNAME:
18272 + return uts->name.domainname;
18279 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18281 + struct vcmd_vhi_name_v0 vc_data;
18284 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18287 + name = vx_vhi_name(vxi, vc_data.field);
18291 + memcpy(name, vc_data.name, 65);
18295 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18297 + struct vcmd_vhi_name_v0 vc_data;
18300 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18303 + name = vx_vhi_name(vxi, vc_data.field);
18307 + memcpy(vc_data.name, name, 65);
18308 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18314 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18316 + struct vcmd_virt_stat_v0 vc_data;
18317 + struct _vx_cvirt *cvirt = &vxi->cvirt;
18318 + struct timespec uptime;
18320 + do_posix_clock_monotonic_gettime(&uptime);
18321 + set_normalized_timespec(&uptime,
18322 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18323 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18325 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18326 + vc_data.uptime = timespec_to_ns(&uptime);
18327 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18328 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
18329 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18330 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18331 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18332 + vc_data.load[0] = cvirt->load[0];
18333 + vc_data.load[1] = cvirt->load[1];
18334 + vc_data.load[2] = cvirt->load[2];
18336 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18342 +#ifdef CONFIG_VSERVER_VTIME
18344 +/* virtualized time base */
18346 +void vx_gettimeofday(struct timeval *tv)
18348 + do_gettimeofday(tv);
18349 + if (!vx_flags(VXF_VIRT_TIME, 0))
18352 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
18353 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
18355 + if (tv->tv_usec >= USEC_PER_SEC) {
18357 + tv->tv_usec -= USEC_PER_SEC;
18358 + } else if (tv->tv_usec < 0) {
18360 + tv->tv_usec += USEC_PER_SEC;
18364 +int vx_settimeofday(struct timespec *ts)
18366 + struct timeval tv;
18368 + if (!vx_flags(VXF_VIRT_TIME, 0))
18369 + return do_settimeofday(ts);
18371 + do_gettimeofday(&tv);
18372 + current->vx_info->cvirt.bias_tv.tv_sec =
18373 + ts->tv_sec - tv.tv_sec;
18374 + current->vx_info->cvirt.bias_tv.tv_usec =
18375 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
18381 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cvirt_init.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cvirt_init.h
18382 --- linux-2.6.29/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
18383 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cvirt_init.h 2009-02-22 22:54:26.000000000 +0100
18387 +extern uint64_t vx_idle_jiffies(void);
18389 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
18391 + uint64_t idle_jiffies = vx_idle_jiffies();
18392 + uint64_t nsuptime;
18394 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
18395 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
18396 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
18397 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
18398 + cvirt->bias_tv.tv_sec = 0;
18399 + cvirt->bias_tv.tv_usec = 0;
18401 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
18402 + atomic_set(&cvirt->nr_threads, 0);
18403 + atomic_set(&cvirt->nr_running, 0);
18404 + atomic_set(&cvirt->nr_uninterruptible, 0);
18405 + atomic_set(&cvirt->nr_onhold, 0);
18407 + spin_lock_init(&cvirt->load_lock);
18408 + cvirt->load_last = jiffies;
18409 + atomic_set(&cvirt->load_updates, 0);
18410 + cvirt->load[0] = 0;
18411 + cvirt->load[1] = 0;
18412 + cvirt->load[2] = 0;
18413 + atomic_set(&cvirt->total_forks, 0);
18415 + spin_lock_init(&cvirt->syslog.logbuf_lock);
18416 + init_waitqueue_head(&cvirt->syslog.log_wait);
18417 + cvirt->syslog.log_start = 0;
18418 + cvirt->syslog.log_end = 0;
18419 + cvirt->syslog.con_start = 0;
18420 + cvirt->syslog.logged_chars = 0;
18424 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18426 + // cvirt_pc->cpustat = { 0 };
18429 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
18433 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
18434 + "!!! cvirt: %p[nr_threads] = %d on exit.",
18436 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
18437 + "!!! cvirt: %p[nr_running] = %d on exit.",
18439 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
18440 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
18442 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
18443 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
18449 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18454 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cvirt_proc.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cvirt_proc.h
18455 --- linux-2.6.29/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
18456 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/cvirt_proc.h 2009-02-22 22:54:26.000000000 +0100
18458 +#ifndef _VX_CVIRT_PROC_H
18459 +#define _VX_CVIRT_PROC_H
18461 +#include <linux/nsproxy.h>
18462 +#include <linux/mnt_namespace.h>
18463 +#include <linux/ipc_namespace.h>
18464 +#include <linux/utsname.h>
18465 +#include <linux/ipc.h>
18469 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
18471 + struct mnt_namespace *ns;
18472 + struct uts_namespace *uts;
18473 + struct ipc_namespace *ipc;
18474 + struct path path;
18475 + char *pstr, *root;
18481 + length += sprintf(buffer + length,
18482 + "NSProxy:\t%p [%p,%p,%p]\n",
18483 + nsproxy, nsproxy->mnt_ns,
18484 + nsproxy->uts_ns, nsproxy->ipc_ns);
18486 + ns = nsproxy->mnt_ns;
18490 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
18494 + path.mnt = ns->root;
18495 + path.dentry = ns->root->mnt_root;
18496 + root = d_path(&path, pstr, PATH_MAX - 2);
18497 + length += sprintf(buffer + length,
18498 + "Namespace:\t%p [#%u]\n"
18499 + "RootPath:\t%s\n",
18500 + ns, atomic_read(&ns->count),
18505 + uts = nsproxy->uts_ns;
18509 + length += sprintf(buffer + length,
18510 + "SysName:\t%.*s\n"
18511 + "NodeName:\t%.*s\n"
18512 + "Release:\t%.*s\n"
18513 + "Version:\t%.*s\n"
18514 + "Machine:\t%.*s\n"
18515 + "DomainName:\t%.*s\n",
18516 + __NEW_UTS_LEN, uts->name.sysname,
18517 + __NEW_UTS_LEN, uts->name.nodename,
18518 + __NEW_UTS_LEN, uts->name.release,
18519 + __NEW_UTS_LEN, uts->name.version,
18520 + __NEW_UTS_LEN, uts->name.machine,
18521 + __NEW_UTS_LEN, uts->name.domainname);
18524 + ipc = nsproxy->ipc_ns;
18528 + length += sprintf(buffer + length,
18529 + "SEMS:\t\t%d %d %d %d %d\n"
18530 + "MSG:\t\t%d %d %d\n"
18531 + "SHM:\t\t%lu %lu %d %d\n",
18532 + ipc->sem_ctls[0], ipc->sem_ctls[1],
18533 + ipc->sem_ctls[2], ipc->sem_ctls[3],
18535 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
18536 + (unsigned long)ipc->shm_ctlmax,
18537 + (unsigned long)ipc->shm_ctlall,
18538 + ipc->shm_ctlmni, ipc->shm_tot);
18545 +#include <linux/sched.h>
18547 +#define LOAD_INT(x) ((x) >> FSHIFT)
18548 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
18551 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
18556 + length += sprintf(buffer + length,
18557 + "BiasUptime:\t%lu.%02lu\n",
18558 + (unsigned long)cvirt->bias_uptime.tv_sec,
18559 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
18561 + a = cvirt->load[0] + (FIXED_1 / 200);
18562 + b = cvirt->load[1] + (FIXED_1 / 200);
18563 + c = cvirt->load[2] + (FIXED_1 / 200);
18564 + length += sprintf(buffer + length,
18565 + "nr_threads:\t%d\n"
18566 + "nr_running:\t%d\n"
18567 + "nr_unintr:\t%d\n"
18568 + "nr_onhold:\t%d\n"
18569 + "load_updates:\t%d\n"
18570 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
18571 + "total_forks:\t%d\n",
18572 + atomic_read(&cvirt->nr_threads),
18573 + atomic_read(&cvirt->nr_running),
18574 + atomic_read(&cvirt->nr_uninterruptible),
18575 + atomic_read(&cvirt->nr_onhold),
18576 + atomic_read(&cvirt->load_updates),
18577 + LOAD_INT(a), LOAD_FRAC(a),
18578 + LOAD_INT(b), LOAD_FRAC(b),
18579 + LOAD_INT(c), LOAD_FRAC(c),
18580 + atomic_read(&cvirt->total_forks));
18585 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
18586 + char *buffer, int cpu)
18592 +#endif /* _VX_CVIRT_PROC_H */
18593 diff -NurpP --minimal linux-2.6.29/kernel/vserver/debug.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/debug.c
18594 --- linux-2.6.29/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
18595 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/debug.c 2009-02-22 22:54:26.000000000 +0100
18598 + * kernel/vserver/debug.c
18600 + * Copyright (C) 2005-2007 Herbert Pötzl
18602 + * V0.01 vx_info dump support
18606 +#include <linux/module.h>
18608 +#include <linux/vserver/context.h>
18611 +void dump_vx_info(struct vx_info *vxi, int level)
18613 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
18614 + atomic_read(&vxi->vx_usecnt),
18615 + atomic_read(&vxi->vx_tasks),
18618 + __dump_vx_limit(&vxi->limit);
18619 + __dump_vx_sched(&vxi->sched);
18620 + __dump_vx_cvirt(&vxi->cvirt);
18621 + __dump_vx_cacct(&vxi->cacct);
18627 +EXPORT_SYMBOL_GPL(dump_vx_info);
18629 diff -NurpP --minimal linux-2.6.29/kernel/vserver/device.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/device.c
18630 --- linux-2.6.29/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
18631 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/device.c 2009-02-22 22:54:26.000000000 +0100
18634 + * linux/kernel/vserver/device.c
18636 + * Linux-VServer: Device Support
18638 + * Copyright (C) 2006 Herbert Pötzl
18639 + * Copyright (C) 2007 Daniel Hokka Zakrisson
18641 + * V0.01 device mapping basics
18642 + * V0.02 added defaults
18646 +#include <linux/slab.h>
18647 +#include <linux/rcupdate.h>
18648 +#include <linux/fs.h>
18649 +#include <linux/namei.h>
18650 +#include <linux/hash.h>
18652 +#include <asm/errno.h>
18653 +#include <asm/uaccess.h>
18654 +#include <linux/vserver/base.h>
18655 +#include <linux/vserver/debug.h>
18656 +#include <linux/vserver/context.h>
18657 +#include <linux/vserver/device.h>
18658 +#include <linux/vserver/device_cmd.h>
18661 +#define DMAP_HASH_BITS 4
18664 +struct vs_mapping {
18666 + struct hlist_node hlist;
18667 + struct list_head list;
18669 +#define dm_hlist u.hlist
18670 +#define dm_list u.list
18673 + struct vx_dmap_target target;
18677 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
18679 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
18681 +static struct vx_dmap_target dmap_defaults[2] = {
18682 + { .flags = DATTR_OPEN },
18683 + { .flags = DATTR_OPEN },
18687 +struct kmem_cache *dmap_cachep __read_mostly;
18689 +int __init dmap_cache_init(void)
18691 + dmap_cachep = kmem_cache_create("dmap_cache",
18692 + sizeof(struct vs_mapping), 0,
18693 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
18697 +__initcall(dmap_cache_init);
18700 +static inline unsigned int __hashval(dev_t dev, int bits)
18702 + return hash_long((unsigned long)dev, bits);
18706 +/* __hash_mapping()
18707 + * add the mapping to the hash table
18709 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
18711 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18712 + struct hlist_head *head, *hash = dmap_main_hash;
18713 + int device = vdm->device;
18715 + spin_lock(hash_lock);
18716 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
18717 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
18719 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
18720 + hlist_add_head(&vdm->dm_hlist, head);
18721 + spin_unlock(hash_lock);
18725 +static inline int __mode_to_default(umode_t mode)
18738 +/* __set_default()
18741 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
18742 + struct vx_dmap_target *vdmt)
18744 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18745 + spin_lock(hash_lock);
18748 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
18750 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
18753 + spin_unlock(hash_lock);
18755 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
18756 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
18760 +/* __remove_default()
18761 + * remove a default
18763 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
18765 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18766 + spin_lock(hash_lock);
18769 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
18770 + else /* remove == reset */
18771 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
18773 + spin_unlock(hash_lock);
18778 +/* __find_mapping()
18779 + * find a mapping in the hash table
18781 + * caller must hold hash_lock
18783 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
18784 + struct vs_mapping **local, struct vs_mapping **global)
18786 + struct hlist_head *hash = dmap_main_hash;
18787 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
18788 + struct hlist_node *pos;
18789 + struct vs_mapping *vdm;
18795 + hlist_for_each(pos, head) {
18796 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
18798 + if ((vdm->device == device) &&
18799 + !((vdm->target.flags ^ mode) & S_IFMT)) {
18800 + if (vdm->xid == xid) {
18803 + } else if (global && vdm->xid == 0)
18808 + if (global && *global)
18815 +/* __lookup_mapping()
18816 + * find a mapping and store the result in target and flags
18818 +static inline int __lookup_mapping(struct vx_info *vxi,
18819 + dev_t device, dev_t *target, int *flags, umode_t mode)
18821 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18822 + struct vs_mapping *vdm, *global;
18823 + struct vx_dmap_target *vdmt;
18825 + xid_t xid = vxi->vx_id;
18828 + spin_lock(hash_lock);
18829 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18831 + vdmt = &vdm->target;
18835 + index = __mode_to_default(mode);
18836 + if (vxi && vxi->dmap.targets[index].flags) {
18838 + vdmt = &vxi->dmap.targets[index];
18839 + } else if (global) {
18841 + vdmt = &global->target;
18845 + vdmt = &dmap_defaults[index];
18849 + if (target && (vdmt->flags & DATTR_REMAP))
18850 + *target = vdmt->target;
18852 + *target = device;
18854 + *flags = vdmt->flags;
18856 + spin_unlock(hash_lock);
18862 +/* __remove_mapping()
18863 + * remove a mapping from the hash table
18865 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18868 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18869 + struct vs_mapping *vdm = NULL;
18872 + spin_lock(hash_lock);
18874 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18876 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18877 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18880 + hlist_del(&vdm->dm_hlist);
18883 + spin_unlock(hash_lock);
18885 + kmem_cache_free(dmap_cachep, vdm);
18891 +int vs_map_device(struct vx_info *vxi,
18892 + dev_t device, dev_t *target, umode_t mode)
18894 + int ret, flags = DATTR_MASK;
18898 + *target = device;
18901 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18902 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18903 + device, target ? *target : 0, flags, mode, ret);
18905 + return (flags & DATTR_MASK);
18910 +static int do_set_mapping(struct vx_info *vxi,
18911 + dev_t device, dev_t target, int flags, umode_t mode)
18914 + struct vs_mapping *new;
18916 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18920 + INIT_HLIST_NODE(&new->dm_hlist);
18921 + new->device = device;
18922 + new->target.target = target;
18923 + new->target.flags = flags | mode;
18924 + new->xid = (vxi ? vxi->vx_id : 0);
18926 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18927 + __hash_mapping(vxi, new);
18929 + struct vx_dmap_target new = {
18930 + .target = target,
18931 + .flags = flags | mode,
18933 + __set_default(vxi, mode, &new);
18939 +static int do_unset_mapping(struct vx_info *vxi,
18940 + dev_t device, dev_t target, int flags, umode_t mode)
18942 + int ret = -EINVAL;
18945 + ret = __remove_mapping(vxi, device, mode);
18949 + ret = __remove_default(vxi, mode);
18959 +static inline int __user_device(const char __user *name, dev_t *dev,
18962 + struct nameidata nd;
18969 + ret = user_lpath(name, &nd.path);
18972 + if (nd.path.dentry->d_inode) {
18973 + *dev = nd.path.dentry->d_inode->i_rdev;
18974 + *mode = nd.path.dentry->d_inode->i_mode;
18976 + path_put(&nd.path);
18980 +static inline int __mapping_mode(dev_t device, dev_t target,
18981 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18984 + *mode = device_mode & S_IFMT;
18986 + *mode = target_mode & S_IFMT;
18990 + /* if both given, device and target mode have to match */
18991 + if (device && target &&
18992 + ((device_mode ^ target_mode) & S_IFMT))
18998 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18999 + const char __user *target_path, int flags, int set)
19001 + dev_t device = ~0, target = ~0;
19002 + umode_t device_mode = 0, target_mode = 0, mode;
19005 + ret = __user_device(device_path, &device, &device_mode);
19008 + ret = __user_device(target_path, &target, &target_mode);
19012 + ret = __mapping_mode(device, target,
19013 + device_mode, target_mode, &mode);
19018 + return do_set_mapping(vxi, device, target,
19021 + return do_unset_mapping(vxi, device, target,
19026 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19028 + struct vcmd_set_mapping_v0 vc_data;
19030 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19033 + return do_mapping(vxi, vc_data.device, vc_data.target,
19034 + vc_data.flags, 1);
19037 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19039 + struct vcmd_set_mapping_v0 vc_data;
19041 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19044 + return do_mapping(vxi, vc_data.device, vc_data.target,
19045 + vc_data.flags, 0);
19049 +#ifdef CONFIG_COMPAT
19051 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19053 + struct vcmd_set_mapping_v0_x32 vc_data;
19055 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19058 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19059 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19062 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19064 + struct vcmd_set_mapping_v0_x32 vc_data;
19066 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19069 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19070 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19073 +#endif /* CONFIG_COMPAT */
19076 diff -NurpP --minimal linux-2.6.29/kernel/vserver/dlimit.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/dlimit.c
19077 --- linux-2.6.29/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19078 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/dlimit.c 2009-02-22 22:54:26.000000000 +0100
19081 + * linux/kernel/vserver/dlimit.c
19083 + * Virtual Server: Context Disk Limits
19085 + * Copyright (C) 2004-2007 Herbert Pötzl
19087 + * V0.01 initial version
19088 + * V0.02 compat32 splitup
19092 +#include <linux/statfs.h>
19093 +#include <linux/sched.h>
19094 +#include <linux/namei.h>
19095 +#include <linux/vs_tag.h>
19096 +#include <linux/vs_dlimit.h>
19097 +#include <linux/vserver/dlimit_cmd.h>
19099 +#include <asm/uaccess.h>
19101 +/* __alloc_dl_info()
19103 + * allocate an initialized dl_info struct
19104 + * doesn't make it visible (hash) */
19106 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19108 + struct dl_info *new = NULL;
19110 + vxdprintk(VXD_CBIT(dlim, 5),
19111 + "alloc_dl_info(%p,%d)*", sb, tag);
19113 + /* would this benefit from a slab cache? */
19114 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19118 + memset(new, 0, sizeof(struct dl_info));
19119 + new->dl_tag = tag;
19121 + INIT_RCU_HEAD(&new->dl_rcu);
19122 + INIT_HLIST_NODE(&new->dl_hlist);
19123 + spin_lock_init(&new->dl_lock);
19124 + atomic_set(&new->dl_refcnt, 0);
19125 + atomic_set(&new->dl_usecnt, 0);
19127 + /* rest of init goes here */
19129 + vxdprintk(VXD_CBIT(dlim, 4),
19130 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19134 +/* __dealloc_dl_info()
19136 + * final disposal of dl_info */
19138 +static void __dealloc_dl_info(struct dl_info *dli)
19140 + vxdprintk(VXD_CBIT(dlim, 4),
19141 + "dealloc_dl_info(%p)", dli);
19143 + dli->dl_hlist.next = LIST_POISON1;
19144 + dli->dl_tag = -1;
19147 + BUG_ON(atomic_read(&dli->dl_usecnt));
19148 + BUG_ON(atomic_read(&dli->dl_refcnt));
19154 +/* hash table for dl_info hash */
19156 +#define DL_HASH_SIZE 13
19158 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19160 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19163 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19165 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19170 +/* __hash_dl_info()
19172 + * add the dli to the global hash table
19173 + * requires the hash_lock to be held */
19175 +static inline void __hash_dl_info(struct dl_info *dli)
19177 + struct hlist_head *head;
19179 + vxdprintk(VXD_CBIT(dlim, 6),
19180 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19181 + get_dl_info(dli);
19182 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19183 + hlist_add_head_rcu(&dli->dl_hlist, head);
19186 +/* __unhash_dl_info()
19188 + * remove the dli from the global hash table
19189 + * requires the hash_lock to be held */
19191 +static inline void __unhash_dl_info(struct dl_info *dli)
19193 + vxdprintk(VXD_CBIT(dlim, 6),
19194 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19195 + hlist_del_rcu(&dli->dl_hlist);
19196 + put_dl_info(dli);
19200 +/* __lookup_dl_info()
19202 + * requires the rcu_read_lock()
19203 + * doesn't increment the dl_refcnt */
19205 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19207 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19208 + struct hlist_node *pos;
19209 + struct dl_info *dli;
19211 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19213 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19221 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19223 + struct dl_info *dli;
19226 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19227 + vxdprintk(VXD_CBIT(dlim, 7),
19228 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19229 + rcu_read_unlock();
19233 +void rcu_free_dl_info(struct rcu_head *head)
19235 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19236 + int usecnt, refcnt;
19238 + BUG_ON(!dli || !head);
19240 + usecnt = atomic_read(&dli->dl_usecnt);
19241 + BUG_ON(usecnt < 0);
19243 + refcnt = atomic_read(&dli->dl_refcnt);
19244 + BUG_ON(refcnt < 0);
19246 + vxdprintk(VXD_CBIT(dlim, 3),
19247 + "rcu_free_dl_info(%p)", dli);
19249 + __dealloc_dl_info(dli);
19251 + printk("!!! rcu didn't free\n");
19257 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19258 + uint32_t flags, int add)
19260 + struct path path;
19263 + ret = user_lpath(name, &path);
19265 + struct super_block *sb;
19266 + struct dl_info *dli;
19269 + if (!path.dentry->d_inode)
19270 + goto out_release;
19271 + if (!(sb = path.dentry->d_inode->i_sb))
19272 + goto out_release;
19275 + dli = __alloc_dl_info(sb, id);
19276 + spin_lock(&dl_info_hash_lock);
19279 + if (__lookup_dl_info(sb, id))
19281 + __hash_dl_info(dli);
19284 + spin_lock(&dl_info_hash_lock);
19285 + dli = __lookup_dl_info(sb, id);
19290 + __unhash_dl_info(dli);
19294 + spin_unlock(&dl_info_hash_lock);
19296 + __dealloc_dl_info(dli);
19303 +int vc_add_dlimit(uint32_t id, void __user *data)
19305 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19307 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19310 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19313 +int vc_rem_dlimit(uint32_t id, void __user *data)
19315 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19317 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19320 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19323 +#ifdef CONFIG_COMPAT
19325 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19327 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19329 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19332 + return do_addrem_dlimit(id,
19333 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19336 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19338 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19340 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19343 + return do_addrem_dlimit(id,
19344 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19347 +#endif /* CONFIG_COMPAT */
19351 +int do_set_dlimit(uint32_t id, const char __user *name,
19352 + uint32_t space_used, uint32_t space_total,
19353 + uint32_t inodes_used, uint32_t inodes_total,
19354 + uint32_t reserved, uint32_t flags)
19356 + struct path path;
19359 + ret = user_lpath(name, &path);
19361 + struct super_block *sb;
19362 + struct dl_info *dli;
19365 + if (!path.dentry->d_inode)
19366 + goto out_release;
19367 + if (!(sb = path.dentry->d_inode->i_sb))
19368 + goto out_release;
19369 + if ((reserved != CDLIM_KEEP &&
19370 + reserved > 100) ||
19371 + (inodes_used != CDLIM_KEEP &&
19372 + inodes_used > inodes_total) ||
19373 + (space_used != CDLIM_KEEP &&
19374 + space_used > space_total))
19375 + goto out_release;
19378 + dli = locate_dl_info(sb, id);
19380 + goto out_release;
19382 + spin_lock(&dli->dl_lock);
19384 + if (inodes_used != CDLIM_KEEP)
19385 + dli->dl_inodes_used = inodes_used;
19386 + if (inodes_total != CDLIM_KEEP)
19387 + dli->dl_inodes_total = inodes_total;
19388 + if (space_used != CDLIM_KEEP) {
19389 + dli->dl_space_used = space_used;
19390 + dli->dl_space_used <<= 10;
19392 + if (space_total == CDLIM_INFINITY)
19393 + dli->dl_space_total = DLIM_INFINITY;
19394 + else if (space_total != CDLIM_KEEP) {
19395 + dli->dl_space_total = space_total;
19396 + dli->dl_space_total <<= 10;
19398 + if (reserved != CDLIM_KEEP)
19399 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
19401 + spin_unlock(&dli->dl_lock);
19403 + put_dl_info(dli);
19412 +int vc_set_dlimit(uint32_t id, void __user *data)
19414 + struct vcmd_ctx_dlimit_v0 vc_data;
19416 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19419 + return do_set_dlimit(id, vc_data.name,
19420 + vc_data.space_used, vc_data.space_total,
19421 + vc_data.inodes_used, vc_data.inodes_total,
19422 + vc_data.reserved, vc_data.flags);
19425 +#ifdef CONFIG_COMPAT
19427 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
19429 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19431 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19434 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
19435 + vc_data.space_used, vc_data.space_total,
19436 + vc_data.inodes_used, vc_data.inodes_total,
19437 + vc_data.reserved, vc_data.flags);
19440 +#endif /* CONFIG_COMPAT */
19444 +int do_get_dlimit(uint32_t id, const char __user *name,
19445 + uint32_t *space_used, uint32_t *space_total,
19446 + uint32_t *inodes_used, uint32_t *inodes_total,
19447 + uint32_t *reserved, uint32_t *flags)
19449 + struct path path;
19452 + ret = user_lpath(name, &path);
19454 + struct super_block *sb;
19455 + struct dl_info *dli;
19458 + if (!path.dentry->d_inode)
19459 + goto out_release;
19460 + if (!(sb = path.dentry->d_inode->i_sb))
19461 + goto out_release;
19464 + dli = locate_dl_info(sb, id);
19466 + goto out_release;
19468 + spin_lock(&dli->dl_lock);
19469 + *inodes_used = dli->dl_inodes_used;
19470 + *inodes_total = dli->dl_inodes_total;
19471 + *space_used = dli->dl_space_used >> 10;
19472 + if (dli->dl_space_total == DLIM_INFINITY)
19473 + *space_total = CDLIM_INFINITY;
19475 + *space_total = dli->dl_space_total >> 10;
19477 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
19478 + spin_unlock(&dli->dl_lock);
19480 + put_dl_info(dli);
19491 +int vc_get_dlimit(uint32_t id, void __user *data)
19493 + struct vcmd_ctx_dlimit_v0 vc_data;
19496 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19499 + ret = do_get_dlimit(id, vc_data.name,
19500 + &vc_data.space_used, &vc_data.space_total,
19501 + &vc_data.inodes_used, &vc_data.inodes_total,
19502 + &vc_data.reserved, &vc_data.flags);
19506 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19511 +#ifdef CONFIG_COMPAT
19513 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
19515 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19518 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19521 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
19522 + &vc_data.space_used, &vc_data.space_total,
19523 + &vc_data.inodes_used, &vc_data.inodes_total,
19524 + &vc_data.reserved, &vc_data.flags);
19528 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19533 +#endif /* CONFIG_COMPAT */
19536 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
19538 + struct dl_info *dli;
19539 + __u64 blimit, bfree, bavail;
19542 + dli = locate_dl_info(sb, dx_current_tag());
19546 + spin_lock(&dli->dl_lock);
19547 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
19550 + /* reduce max inodes available to limit */
19551 + if (buf->f_files > dli->dl_inodes_total)
19552 + buf->f_files = dli->dl_inodes_total;
19554 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
19555 + /* reduce free inodes to min */
19556 + if (ifree < buf->f_ffree)
19557 + buf->f_ffree = ifree;
19560 + if (dli->dl_space_total == DLIM_INFINITY)
19563 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
19565 + if (dli->dl_space_total < dli->dl_space_used)
19568 + bfree = (dli->dl_space_total - dli->dl_space_used)
19569 + >> sb->s_blocksize_bits;
19571 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
19572 + if (bavail < dli->dl_space_used)
19575 + bavail = (bavail - dli->dl_space_used)
19576 + >> sb->s_blocksize_bits;
19578 + /* reduce max space available to limit */
19579 + if (buf->f_blocks > blimit)
19580 + buf->f_blocks = blimit;
19582 + /* reduce free space to min */
19583 + if (bfree < buf->f_bfree)
19584 + buf->f_bfree = bfree;
19586 + /* reduce avail space to min */
19587 + if (bavail < buf->f_bavail)
19588 + buf->f_bavail = bavail;
19591 + spin_unlock(&dli->dl_lock);
19592 + put_dl_info(dli);
19597 +#include <linux/module.h>
19599 +EXPORT_SYMBOL_GPL(locate_dl_info);
19600 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
19602 diff -NurpP --minimal linux-2.6.29/kernel/vserver/helper.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/helper.c
19603 --- linux-2.6.29/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
19604 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/helper.c 2009-03-25 00:40:43.000000000 +0100
19607 + * linux/kernel/vserver/helper.c
19609 + * Virtual Context Support
19611 + * Copyright (C) 2004-2007 Herbert Pötzl
19613 + * V0.01 basic helper
19617 +#include <linux/kmod.h>
19618 +#include <linux/reboot.h>
19619 +#include <linux/vs_context.h>
19620 +#include <linux/vs_network.h>
19621 +#include <linux/vserver/signal.h>
19624 +char vshelper_path[255] = "/sbin/vshelper";
19627 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
19631 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
19632 + printk( KERN_WARNING
19633 + "%s: (%s %s) returned %s with %d\n",
19634 + name, argv[1], argv[2],
19635 + sync ? "sync" : "async", ret);
19637 + vxdprintk(VXD_CBIT(switch, 4),
19638 + "%s: (%s %s) returned %s with %d",
19639 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
19644 + * vshelper path is set via /proc/sys
19645 + * invoked by vserver sys_reboot(), with
19646 + * the following arguments
19648 + * argv [0] = vshelper_path;
19649 + * argv [1] = action: "restart", "halt", "poweroff", ...
19650 + * argv [2] = context identifier
19652 + * envp [*] = type-specific parameters
19655 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
19657 + char id_buf[8], cmd_buf[16];
19658 + char uid_buf[16], pid_buf[16];
19661 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19662 + char *envp[] = {"HOME=/", "TERM=linux",
19663 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
19664 + uid_buf, pid_buf, cmd_buf, 0};
19666 + if (vx_info_state(vxi, VXS_HELPER))
19668 + vxi->vx_state |= VXS_HELPER;
19670 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19672 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19673 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
19674 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
19677 + case LINUX_REBOOT_CMD_RESTART:
19678 + argv[1] = "restart";
19681 + case LINUX_REBOOT_CMD_HALT:
19682 + argv[1] = "halt";
19685 + case LINUX_REBOOT_CMD_POWER_OFF:
19686 + argv[1] = "poweroff";
19689 + case LINUX_REBOOT_CMD_SW_SUSPEND:
19690 + argv[1] = "swsusp";
19694 + vxi->vx_state &= ~VXS_HELPER;
19698 + ret = do_vshelper(vshelper_path, argv, envp, 0);
19699 + vxi->vx_state &= ~VXS_HELPER;
19700 + __wakeup_vx_info(vxi);
19701 + return (ret) ? -EPERM : 0;
19705 +long vs_reboot(unsigned int cmd, void __user *arg)
19707 + struct vx_info *vxi = current->vx_info;
19710 + vxdprintk(VXD_CBIT(misc, 5),
19711 + "vs_reboot(%p[#%d],%d)",
19712 + vxi, vxi ? vxi->vx_id : 0, cmd);
19714 + ret = vs_reboot_helper(vxi, cmd, arg);
19718 + vxi->reboot_cmd = cmd;
19719 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19721 + case LINUX_REBOOT_CMD_RESTART:
19722 + case LINUX_REBOOT_CMD_HALT:
19723 + case LINUX_REBOOT_CMD_POWER_OFF:
19724 + vx_info_kill(vxi, 0, SIGKILL);
19725 + vx_info_kill(vxi, 1, SIGKILL);
19735 + * argv [0] = vshelper_path;
19736 + * argv [1] = action: "startup", "shutdown"
19737 + * argv [2] = context identifier
19739 + * envp [*] = type-specific parameters
19742 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
19744 + char id_buf[8], cmd_buf[16];
19745 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19746 + char *envp[] = {"HOME=/", "TERM=linux",
19747 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19749 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
19752 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19753 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19756 + case VSC_STARTUP:
19757 + argv[1] = "startup";
19759 + case VSC_SHUTDOWN:
19760 + argv[1] = "shutdown";
19766 + return do_vshelper(vshelper_path, argv, envp, 1);
19771 + * argv [0] = vshelper_path;
19772 + * argv [1] = action: "netup", "netdown"
19773 + * argv [2] = context identifier
19775 + * envp [*] = type-specific parameters
19778 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
19780 + char id_buf[8], cmd_buf[16];
19781 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19782 + char *envp[] = {"HOME=/", "TERM=linux",
19783 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19785 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
19788 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
19789 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19793 + argv[1] = "netup";
19795 + case VSC_NETDOWN:
19796 + argv[1] = "netdown";
19802 + return do_vshelper(vshelper_path, argv, envp, 1);
19805 diff -NurpP --minimal linux-2.6.29/kernel/vserver/history.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/history.c
19806 --- linux-2.6.29/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19807 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/history.c 2009-02-22 22:54:26.000000000 +0100
19810 + * kernel/vserver/history.c
19812 + * Virtual Context History Backtrace
19814 + * Copyright (C) 2004-2007 Herbert Pötzl
19816 + * V0.01 basic structure
19817 + * V0.02 hash/unhash and trace
19818 + * V0.03 preemption fixes
19822 +#include <linux/module.h>
19823 +#include <asm/uaccess.h>
19825 +#include <linux/vserver/context.h>
19826 +#include <linux/vserver/debug.h>
19827 +#include <linux/vserver/debug_cmd.h>
19828 +#include <linux/vserver/history.h>
19831 +#ifdef CONFIG_VSERVER_HISTORY
19832 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19834 +#define VXH_SIZE 64
19837 +struct _vx_history {
19838 + unsigned int counter;
19840 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19844 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19846 +unsigned volatile int vxh_active = 1;
19848 +static atomic_t sequence = ATOMIC_INIT(0);
19853 + * requires disabled preemption */
19855 +struct _vx_hist_entry *vxh_advance(void *loc)
19857 + unsigned int cpu = smp_processor_id();
19858 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19859 + struct _vx_hist_entry *entry;
19860 + unsigned int index;
19862 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19863 + entry = &hist->entry[index];
19865 + entry->seq = atomic_inc_return(&sequence);
19866 + entry->loc = loc;
19870 +EXPORT_SYMBOL_GPL(vxh_advance);
19873 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19875 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19878 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19880 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19881 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19882 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19883 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19885 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19887 + switch (e->type) {
19888 + case VXH_THROW_OOPS:
19889 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19892 + case VXH_GET_VX_INFO:
19893 + case VXH_PUT_VX_INFO:
19894 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19896 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19897 + VXH_VXI_ARGS(e));
19900 + case VXH_INIT_VX_INFO:
19901 + case VXH_SET_VX_INFO:
19902 + case VXH_CLR_VX_INFO:
19903 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19905 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19906 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19907 + VXH_VXI_ARGS(e), e->sc.data);
19910 + case VXH_CLAIM_VX_INFO:
19911 + case VXH_RELEASE_VX_INFO:
19912 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19914 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19915 + VXH_VXI_ARGS(e), e->sc.data);
19918 + case VXH_ALLOC_VX_INFO:
19919 + case VXH_DEALLOC_VX_INFO:
19920 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19922 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19923 + VXH_VXI_ARGS(e));
19926 + case VXH_HASH_VX_INFO:
19927 + case VXH_UNHASH_VX_INFO:
19928 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19930 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19931 + VXH_VXI_ARGS(e));
19934 + case VXH_LOC_VX_INFO:
19935 + case VXH_LOOKUP_VX_INFO:
19936 + case VXH_CREATE_VX_INFO:
19937 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19939 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19940 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19941 + e->ll.arg, VXH_VXI_ARGS(e));
19946 +static void __vxh_dump_history(void)
19948 + unsigned int i, cpu;
19950 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19951 + atomic_read(&sequence), NR_CPUS);
19953 + for (i = 0; i < VXH_SIZE; i++) {
19954 + for_each_online_cpu(cpu) {
19955 + struct _vx_history *hist =
19956 + &per_cpu(vx_history_buffer, cpu);
19957 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19958 + struct _vx_hist_entry *entry = &hist->entry[index];
19960 + vxh_dump_entry(entry, cpu);
19965 +void vxh_dump_history(void)
19969 + local_irq_enable();
19971 + local_irq_disable();
19973 + __vxh_dump_history();
19977 +/* vserver syscall commands below here */
19980 +int vc_dump_history(uint32_t id)
19983 + __vxh_dump_history();
19990 +int do_read_history(struct __user _vx_hist_entry *data,
19991 + int cpu, uint32_t *index, uint32_t *count)
19993 + int pos, ret = 0;
19994 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19995 + int end = hist->counter;
19996 + int start = end - VXH_SIZE + 2;
19997 + int idx = *index;
19999 + /* special case: get current pos */
20005 + /* have we lost some data? */
20009 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20010 + struct _vx_hist_entry *entry =
20011 + &hist->entry[idx % VXH_SIZE];
20013 + /* send entry to userspace */
20014 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20018 + /* save new index and count */
20021 + return ret ? ret : (*index < end);
20024 +int vc_read_history(uint32_t id, void __user *data)
20026 + struct vcmd_read_history_v0 vc_data;
20029 + if (id >= NR_CPUS)
20032 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20035 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20036 + id, &vc_data.index, &vc_data.count);
20038 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20043 +#ifdef CONFIG_COMPAT
20045 +int vc_read_history_x32(uint32_t id, void __user *data)
20047 + struct vcmd_read_history_v0_x32 vc_data;
20050 + if (id >= NR_CPUS)
20053 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20056 + ret = do_read_history((struct __user _vx_hist_entry *)
20057 + compat_ptr(vc_data.data_ptr),
20058 + id, &vc_data.index, &vc_data.count);
20060 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20065 +#endif /* CONFIG_COMPAT */
20067 diff -NurpP --minimal linux-2.6.29/kernel/vserver/inet.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/inet.c
20068 --- linux-2.6.29/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20069 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/inet.c 2009-02-22 22:54:26.000000000 +0100
20072 +#include <linux/in.h>
20073 +#include <linux/inetdevice.h>
20074 +#include <linux/vs_inet.h>
20075 +#include <linux/vs_inet6.h>
20076 +#include <linux/vserver/debug.h>
20077 +#include <net/route.h>
20078 +#include <net/addrconf.h>
20081 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20085 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20088 + struct nx_addr_v4 *ptr;
20090 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20091 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20098 + vxdprintk(VXD_CBIT(net, 2),
20099 + "nx_v4_addr_conflict(%p,%p): %d",
20100 + nxi1, nxi2, ret);
20106 +#ifdef CONFIG_IPV6
20108 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20112 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20115 + struct nx_addr_v6 *ptr;
20117 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20118 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20125 + vxdprintk(VXD_CBIT(net, 2),
20126 + "nx_v6_addr_conflict(%p,%p): %d",
20127 + nxi1, nxi2, ret);
20134 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20136 + struct in_device *in_dev;
20137 + struct in_ifaddr **ifap;
20138 + struct in_ifaddr *ifa;
20143 + in_dev = in_dev_get(dev);
20147 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20148 + ifap = &ifa->ifa_next) {
20149 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20154 + in_dev_put(in_dev);
20160 +#ifdef CONFIG_IPV6
20162 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20164 + struct inet6_dev *in_dev;
20165 + struct inet6_ifaddr **ifap;
20166 + struct inet6_ifaddr *ifa;
20171 + in_dev = in6_dev_get(dev);
20175 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20176 + ifap = &ifa->if_next) {
20177 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20182 + in6_dev_put(in_dev);
20189 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20195 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20197 +#ifdef CONFIG_IPV6
20199 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20204 + vxdprintk(VXD_CBIT(net, 3),
20205 + "dev_in_nx_info(%p,%p[#%d]) = %d",
20206 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
20210 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20211 + struct rtable **rp, struct flowi *fl)
20216 + /* FIXME: handle lback only case */
20217 + if (!NX_IPV4(nxi))
20220 + vxdprintk(VXD_CBIT(net, 4),
20221 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20222 + nxi, nxi ? nxi->nx_id : 0,
20223 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20225 + /* single IP is unconditional */
20226 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20227 + (fl->fl4_src == INADDR_ANY))
20228 + fl->fl4_src = nxi->v4.ip[0].s_addr;
20230 + if (fl->fl4_src == INADDR_ANY) {
20231 + struct nx_addr_v4 *ptr;
20232 + __be32 found = 0;
20235 + err = __ip_route_output_key(net, rp, fl);
20237 + found = (*rp)->rt_src;
20239 + vxdprintk(VXD_CBIT(net, 4),
20240 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20241 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20242 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20246 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20247 + __be32 primary = ptr->ip[0].s_addr;
20248 + __be32 mask = ptr->mask.s_addr;
20249 + __be32 neta = primary & mask;
20251 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20252 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20253 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20254 + NIPQUAD(mask), NIPQUAD(neta));
20255 + if ((found & mask) != neta)
20258 + fl->fl4_src = primary;
20259 + err = __ip_route_output_key(net, rp, fl);
20260 + vxdprintk(VXD_CBIT(net, 4),
20261 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20262 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20264 + found = (*rp)->rt_src;
20266 + if (found == primary)
20270 + /* still no source ip? */
20271 + found = ipv4_is_loopback(fl->fl4_dst)
20272 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20274 + /* assign src ip to flow */
20275 + fl->fl4_src = found;
20278 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20282 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20283 + if (ipv4_is_loopback(fl->fl4_dst))
20284 + fl->fl4_dst = nxi->v4_lback.s_addr;
20285 + if (ipv4_is_loopback(fl->fl4_src))
20286 + fl->fl4_src = nxi->v4_lback.s_addr;
20287 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
20288 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20294 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20296 diff -NurpP --minimal linux-2.6.29/kernel/vserver/init.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/init.c
20297 --- linux-2.6.29/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
20298 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/init.c 2009-02-22 22:54:26.000000000 +0100
20301 + * linux/kernel/init.c
20303 + * Virtual Server Init
20305 + * Copyright (C) 2004-2007 Herbert Pötzl
20307 + * V0.01 basic structure
20311 +#include <linux/init.h>
20313 +int vserver_register_sysctl(void);
20314 +void vserver_unregister_sysctl(void);
20317 +static int __init init_vserver(void)
20321 +#ifdef CONFIG_VSERVER_DEBUG
20322 + vserver_register_sysctl();
20328 +static void __exit exit_vserver(void)
20331 +#ifdef CONFIG_VSERVER_DEBUG
20332 + vserver_unregister_sysctl();
20337 +/* FIXME: GFP_ZONETYPES gone
20338 +long vx_slab[GFP_ZONETYPES]; */
20342 +module_init(init_vserver);
20343 +module_exit(exit_vserver);
20345 diff -NurpP --minimal linux-2.6.29/kernel/vserver/inode.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/inode.c
20346 --- linux-2.6.29/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
20347 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/inode.c 2009-02-22 22:54:26.000000000 +0100
20350 + * linux/kernel/vserver/inode.c
20352 + * Virtual Server: File System Support
20354 + * Copyright (C) 2004-2007 Herbert Pötzl
20356 + * V0.01 separated from vcontext V0.05
20357 + * V0.02 moved to tag (instead of xid)
20361 +#include <linux/tty.h>
20362 +#include <linux/proc_fs.h>
20363 +#include <linux/devpts_fs.h>
20364 +#include <linux/fs.h>
20365 +#include <linux/file.h>
20366 +#include <linux/mount.h>
20367 +#include <linux/parser.h>
20368 +#include <linux/namei.h>
20369 +#include <linux/vserver/inode.h>
20370 +#include <linux/vserver/inode_cmd.h>
20371 +#include <linux/vs_base.h>
20372 +#include <linux/vs_tag.h>
20374 +#include <asm/uaccess.h>
20377 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20379 + struct proc_dir_entry *entry;
20381 + if (!in || !in->i_sb)
20384 + *flags = IATTR_TAG
20385 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
20386 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
20387 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
20388 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE;
20390 + if (S_ISDIR(in->i_mode))
20391 + *mask |= IATTR_BARRIER;
20393 + if (IS_TAGGED(in)) {
20394 + *tag = in->i_tag;
20395 + *mask |= IATTR_TAG;
20398 + switch (in->i_sb->s_magic) {
20399 + case PROC_SUPER_MAGIC:
20400 + entry = PROC_I(in)->pde;
20402 + /* check for specific inodes? */
20404 + *mask |= IATTR_FLAGS;
20406 + *flags |= (entry->vx_flags & IATTR_FLAGS);
20408 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
20411 + case DEVPTS_SUPER_MAGIC:
20412 + *tag = in->i_tag;
20413 + *mask |= IATTR_TAG;
20422 +int vc_get_iattr(void __user *data)
20424 + struct path path;
20425 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
20428 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20431 + ret = user_lpath(vc_data.name, &path);
20433 + ret = __vc_get_iattr(path.dentry->d_inode,
20434 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20440 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20445 +#ifdef CONFIG_COMPAT
20447 +int vc_get_iattr_x32(void __user *data)
20449 + struct path path;
20450 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
20453 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20456 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20458 + ret = __vc_get_iattr(path.dentry->d_inode,
20459 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20465 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20470 +#endif /* CONFIG_COMPAT */
20473 +int vc_fget_iattr(uint32_t fd, void __user *data)
20475 + struct file *filp;
20476 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
20479 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20483 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20486 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
20487 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20491 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20497 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20499 + struct inode *in = de->d_inode;
20500 + int error = 0, is_proc = 0, has_tag = 0;
20501 + struct iattr attr = { 0 };
20503 + if (!in || !in->i_sb)
20506 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
20507 + if ((*mask & IATTR_FLAGS) && !is_proc)
20510 + has_tag = IS_TAGGED(in) ||
20511 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
20512 + if ((*mask & IATTR_TAG) && !has_tag)
20515 + mutex_lock(&in->i_mutex);
20516 + if (*mask & IATTR_TAG) {
20517 + attr.ia_tag = *tag;
20518 + attr.ia_valid |= ATTR_TAG;
20521 + if (*mask & IATTR_FLAGS) {
20522 + struct proc_dir_entry *entry = PROC_I(in)->pde;
20523 + unsigned int iflags = PROC_I(in)->vx_flags;
20525 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
20526 + | (*flags & IATTR_FLAGS);
20527 + PROC_I(in)->vx_flags = iflags;
20529 + entry->vx_flags = iflags;
20532 + if (*mask & (IATTR_BARRIER | IATTR_IXUNLINK | IATTR_IMMUTABLE)) {
20533 + if (*mask & IATTR_IMMUTABLE) {
20534 + if (*flags & IATTR_IMMUTABLE)
20535 + in->i_flags |= S_IMMUTABLE;
20537 + in->i_flags &= ~S_IMMUTABLE;
20539 + if (*mask & IATTR_IXUNLINK) {
20540 + if (*flags & IATTR_IXUNLINK)
20541 + in->i_flags |= S_IXUNLINK;
20543 + in->i_flags &= ~S_IXUNLINK;
20545 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
20546 + if (*flags & IATTR_BARRIER)
20547 + in->i_vflags |= V_BARRIER;
20549 + in->i_vflags &= ~V_BARRIER;
20551 + if (in->i_op && in->i_op->sync_flags) {
20552 + error = in->i_op->sync_flags(in);
20558 + if (attr.ia_valid) {
20559 + if (in->i_op && in->i_op->setattr)
20560 + error = in->i_op->setattr(de, &attr);
20562 + error = inode_change_ok(in, &attr);
20564 + error = inode_setattr(in, &attr);
20569 + mutex_unlock(&in->i_mutex);
20573 +int vc_set_iattr(void __user *data)
20575 + struct path path;
20576 + struct vcmd_ctx_iattr_v1 vc_data;
20579 + if (!capable(CAP_LINUX_IMMUTABLE))
20581 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20584 + ret = user_lpath(vc_data.name, &path);
20586 + ret = __vc_set_iattr(path.dentry,
20587 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20591 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20596 +#ifdef CONFIG_COMPAT
20598 +int vc_set_iattr_x32(void __user *data)
20600 + struct path path;
20601 + struct vcmd_ctx_iattr_v1_x32 vc_data;
20604 + if (!capable(CAP_LINUX_IMMUTABLE))
20606 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20609 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20611 + ret = __vc_set_iattr(path.dentry,
20612 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20616 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20621 +#endif /* CONFIG_COMPAT */
20623 +int vc_fset_iattr(uint32_t fd, void __user *data)
20625 + struct file *filp;
20626 + struct vcmd_ctx_fiattr_v0 vc_data;
20629 + if (!capable(CAP_LINUX_IMMUTABLE))
20631 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20635 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20638 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
20639 + &vc_data.flags, &vc_data.mask);
20643 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20649 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
20651 +static match_table_t tokens = {
20652 + {Opt_notagcheck, "notagcheck"},
20653 +#ifdef CONFIG_PROPAGATE
20654 + {Opt_notag, "notag"},
20655 + {Opt_tag, "tag"},
20656 + {Opt_tagid, "tagid=%u"},
20662 +static void __dx_parse_remove(char *string, char *opt)
20664 + char *p = strstr(string, opt);
20668 + while (*q != '\0' && *q != ',')
20677 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
20678 + unsigned long *flags)
20681 + substring_t args[MAX_OPT_ARGS];
20682 + int token, option = 0;
20683 + char *s, *p, *opts;
20687 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20692 + while ((p = strsep(&opts, ",")) != NULL) {
20693 + token = match_token(p, tokens, args);
20695 + vxdprintk(VXD_CBIT(tag, 7),
20696 + "dx_parse_tag(»%s«): %d:#%d",
20697 + p, token, option);
20700 +#ifdef CONFIG_PROPAGATE
20705 + __dx_parse_remove(s, "tag");
20706 + *mnt_flags |= MNT_TAGID;
20707 + set |= MNT_TAGID;
20711 + __dx_parse_remove(s, "notag");
20712 + *mnt_flags |= MNT_NOTAG;
20713 + set |= MNT_NOTAG;
20716 + if (tag && !match_int(args, &option))
20719 + __dx_parse_remove(s, "tagid");
20720 + *mnt_flags |= MNT_TAGID;
20721 + set |= MNT_TAGID;
20724 + case Opt_notagcheck:
20726 + __dx_parse_remove(s, "notagcheck");
20727 + *flags |= MS_NOTAGCHECK;
20728 + set |= MS_NOTAGCHECK;
20733 + strcpy(string, s);
20738 +#ifdef CONFIG_PROPAGATE
20740 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20742 + tag_t new_tag = 0;
20743 + struct vfsmount *mnt;
20748 + mnt = nd->path.mnt;
20752 + propagate = (mnt->mnt_flags & MNT_TAGID);
20754 + new_tag = mnt->mnt_tag;
20756 + vxdprintk(VXD_CBIT(tag, 7),
20757 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20758 + inode, inode->i_ino, inode->i_tag,
20759 + new_tag, (propagate) ? 1 : 0);
20762 + inode->i_tag = new_tag;
20765 +#include <linux/module.h>
20767 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20769 +#endif /* CONFIG_PROPAGATE */
20771 diff -NurpP --minimal linux-2.6.29/kernel/vserver/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/Kconfig
20772 --- linux-2.6.29/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
20773 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/Kconfig 2009-02-22 22:54:26.000000000 +0100
20776 +# Linux VServer configuration
20779 +menu "Linux VServer"
20781 +config VSERVER_AUTO_LBACK
20782 + bool "Automatically Assign Loopback IP"
20785 + Automatically assign a guest specific loopback
20786 + IP and add it to the kernel network stack on
20789 +config VSERVER_AUTO_SINGLE
20790 + bool "Automatic Single IP Special Casing"
20791 + depends on EXPERIMENTAL
20794 + This allows network contexts with a single IP to
20795 + automatically remap 0.0.0.0 bindings to that IP,
20796 + avoiding further network checks and improving
20799 + (note: such guests do not allow to change the ip
20800 + on the fly and do not show loopback addresses)
20802 +config VSERVER_COWBL
20803 + bool "Enable COW Immutable Link Breaking"
20806 + This enables the COW (Copy-On-Write) link break code.
20807 + It allows you to treat unified files like normal files
20808 + when writing to them (which will implicitely break the
20809 + link and create a copy of the unified file)
20811 +config VSERVER_VTIME
20812 + bool "Enable Virtualized Guest Time"
20813 + depends on EXPERIMENTAL
20816 + This enables per guest time offsets to allow for
20817 + adjusting the system clock individually per guest.
20818 + this adds some overhead to the time functions and
20819 + therefore should not be enabled without good reason.
20821 +config VSERVER_DEVICE
20822 + bool "Enable Guest Device Mapping"
20823 + depends on EXPERIMENTAL
20826 + This enables generic device remapping.
20828 +config VSERVER_PROC_SECURE
20829 + bool "Enable Proc Security"
20830 + depends on PROC_FS
20833 + This configures ProcFS security to initially hide
20834 + non-process entries for all contexts except the main and
20835 + spectator context (i.e. for all guests), which is a secure
20838 + (note: on 1.2x the entries were visible by default)
20840 +config VSERVER_HARDCPU
20841 + bool "Enable Hard CPU Limits"
20844 + Activate the Hard CPU Limits
20846 + This will compile in code that allows the Token Bucket
20847 + Scheduler to put processes on hold when a context's
20848 + tokens are depleted (provided that its per-context
20849 + sched_hard flag is set).
20851 + Processes belonging to that context will not be able
20852 + to consume CPU resources again until a per-context
20853 + configured minimum of tokens has been reached.
20855 +config VSERVER_IDLETIME
20856 + bool "Avoid idle CPUs by skipping Time"
20857 + depends on VSERVER_HARDCPU
20860 + This option allows the scheduler to artificially
20861 + advance time (per cpu) when otherwise the idle
20862 + task would be scheduled, thus keeping the cpu
20863 + busy and sharing the available resources among
20864 + certain contexts.
20866 +config VSERVER_IDLELIMIT
20867 + bool "Limit the IDLE task"
20868 + depends on VSERVER_HARDCPU
20871 + Limit the idle slices, so the the next context
20872 + will be scheduled as soon as possible.
20874 + This might improve interactivity and latency, but
20875 + will also marginally increase scheduling overhead.
20878 + prompt "Persistent Inode Tagging"
20879 + default TAGGING_ID24
20881 + This adds persistent context information to filesystems
20882 + mounted with the tagxid option. Tagging is a requirement
20883 + for per-context disk limits and per-context quota.
20886 +config TAGGING_NONE
20889 + do not store per-context information in inodes.
20891 +config TAGGING_UID16
20892 + bool "UID16/GID32"
20894 + reduces UID to 16 bit, but leaves GID at 32 bit.
20896 +config TAGGING_GID16
20897 + bool "UID32/GID16"
20899 + reduces GID to 16 bit, but leaves UID at 32 bit.
20901 +config TAGGING_ID24
20902 + bool "UID24/GID24"
20904 + uses the upper 8bit from UID and GID for XID tagging
20905 + which leaves 24bit for UID/GID each, which should be
20906 + more than sufficient for normal use.
20908 +config TAGGING_INTERN
20909 + bool "UID32/GID32"
20911 + this uses otherwise reserved inode fields in the on
20912 + disk representation, which limits the use to a few
20913 + filesystems (currently ext2 and ext3)
20918 + bool "Tag NFSD User Auth and Files"
20921 + Enable this if you do want the in-kernel NFS
20922 + Server to use the tagging specified above.
20923 + (will require patched clients too)
20925 +config VSERVER_PRIVACY
20926 + bool "Honor Privacy Aspects of Guests"
20929 + When enabled, most context checks will disallow
20930 + access to structures assigned to a specific context,
20931 + like ptys or loop devices.
20933 +config VSERVER_CONTEXTS
20934 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
20936 + default "768" if 64BIT
20939 + This setting will optimize certain data structures
20940 + and memory allocations according to the expected
20943 + note: this is not a strict upper limit.
20945 +config VSERVER_WARN
20946 + bool "VServer Warnings"
20949 + This enables various runtime warnings, which will
20950 + notify about potential manipulation attempts or
20951 + resource shortage. It is generally considered to
20952 + be a good idea to have that enabled.
20954 +config VSERVER_DEBUG
20955 + bool "VServer Debugging Code"
20958 + Set this to yes if you want to be able to activate
20959 + debugging output at runtime. It adds a very small
20960 + overhead to all vserver related functions and
20961 + increases the kernel size by about 20k.
20963 +config VSERVER_HISTORY
20964 + bool "VServer History Tracing"
20965 + depends on VSERVER_DEBUG
20968 + Set this to yes if you want to record the history of
20969 + linux-vserver activities, so they can be replayed in
20970 + the event of a kernel panic or oops.
20972 +config VSERVER_HISTORY_SIZE
20973 + int "Per-CPU History Size (32-65536)"
20974 + depends on VSERVER_HISTORY
20978 + This allows you to specify the number of entries in
20979 + the per-CPU history buffer.
20981 +config VSERVER_MONITOR
20982 + bool "VServer Scheduling Monitor"
20983 + depends on VSERVER_DISABLED
20986 + Set this to yes if you want to record the scheduling
20987 + decisions, so that they can be relayed to userspace
20988 + for detailed analysis.
20990 +config VSERVER_MONITOR_SIZE
20991 + int "Per-CPU Monitor Queue Size (32-65536)"
20992 + depends on VSERVER_MONITOR
20996 + This allows you to specify the number of entries in
20997 + the per-CPU scheduling monitor buffer.
20999 +config VSERVER_MONITOR_SYNC
21000 + int "Per-CPU Monitor Sync Interval (0-65536)"
21001 + depends on VSERVER_MONITOR
21005 + This allows you to specify the interval in ticks
21006 + when a time sync entry is inserted.
21014 + select NAMESPACES
21020 +config VSERVER_SECURITY
21022 + depends on SECURITY
21024 + select SECURITY_CAPABILITIES
21026 diff -NurpP --minimal linux-2.6.29/kernel/vserver/limit.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/limit.c
21027 --- linux-2.6.29/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21028 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/limit.c 2009-02-22 22:54:26.000000000 +0100
21031 + * linux/kernel/vserver/limit.c
21033 + * Virtual Server: Context Limits
21035 + * Copyright (C) 2004-2007 Herbert Pötzl
21037 + * V0.01 broken out from vcontext V0.05
21038 + * V0.02 changed vcmds to vxi arg
21042 +#include <linux/sched.h>
21043 +#include <linux/module.h>
21044 +#include <linux/vs_limit.h>
21045 +#include <linux/vserver/limit.h>
21046 +#include <linux/vserver/limit_cmd.h>
21048 +#include <asm/uaccess.h>
21051 +const char *vlimit_name[NUM_LIMITS] = {
21052 + [RLIMIT_CPU] = "CPU",
21053 + [RLIMIT_RSS] = "RSS",
21054 + [RLIMIT_NPROC] = "NPROC",
21055 + [RLIMIT_NOFILE] = "NOFILE",
21056 + [RLIMIT_MEMLOCK] = "VML",
21057 + [RLIMIT_AS] = "VM",
21058 + [RLIMIT_LOCKS] = "LOCKS",
21059 + [RLIMIT_SIGPENDING] = "SIGP",
21060 + [RLIMIT_MSGQUEUE] = "MSGQ",
21062 + [VLIMIT_NSOCK] = "NSOCK",
21063 + [VLIMIT_OPENFD] = "OPENFD",
21064 + [VLIMIT_ANON] = "ANON",
21065 + [VLIMIT_SHMEM] = "SHMEM",
21066 + [VLIMIT_DENTRY] = "DENTRY",
21069 +EXPORT_SYMBOL_GPL(vlimit_name);
21071 +#define MASK_ENTRY(x) (1 << (x))
21073 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21076 + , /* softlimit */
21077 + MASK_ENTRY( RLIMIT_RSS ) |
21078 + MASK_ENTRY( VLIMIT_ANON ) |
21081 + MASK_ENTRY( RLIMIT_RSS ) |
21082 + MASK_ENTRY( RLIMIT_NPROC ) |
21083 + MASK_ENTRY( RLIMIT_NOFILE ) |
21084 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21085 + MASK_ENTRY( RLIMIT_AS ) |
21086 + MASK_ENTRY( RLIMIT_LOCKS ) |
21087 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21089 + MASK_ENTRY( VLIMIT_NSOCK ) |
21090 + MASK_ENTRY( VLIMIT_OPENFD ) |
21091 + MASK_ENTRY( VLIMIT_ANON ) |
21092 + MASK_ENTRY( VLIMIT_SHMEM ) |
21093 + MASK_ENTRY( VLIMIT_DENTRY ) |
21096 + /* accounting only */
21097 +uint32_t account_mask =
21098 + MASK_ENTRY( VLIMIT_SEMARY ) |
21099 + MASK_ENTRY( VLIMIT_NSEMS ) |
21100 + MASK_ENTRY( VLIMIT_MAPPED ) |
21104 +static int is_valid_vlimit(int id)
21106 + uint32_t mask = vlimit_mask.minimum |
21107 + vlimit_mask.softlimit | vlimit_mask.maximum;
21108 + return mask & (1 << id);
21111 +static int is_accounted_vlimit(int id)
21113 + if (is_valid_vlimit(id))
21115 + return account_mask & (1 << id);
21119 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21121 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21122 + return VX_VLIM(limit);
21125 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21127 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21128 + return VX_VLIM(limit);
21131 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21132 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21134 + if (!is_valid_vlimit(id))
21138 + *minimum = CRLIM_UNSET;
21140 + *softlimit = vc_get_soft(vxi, id);
21142 + *maximum = vc_get_hard(vxi, id);
21146 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21148 + struct vcmd_ctx_rlimit_v0 vc_data;
21151 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21154 + ret = do_get_rlimit(vxi, vc_data.id,
21155 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21159 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21164 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21165 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21167 + if (!is_valid_vlimit(id))
21170 + if (maximum != CRLIM_KEEP)
21171 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21172 + if (softlimit != CRLIM_KEEP)
21173 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21175 + /* clamp soft limit */
21176 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21177 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21182 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21184 + struct vcmd_ctx_rlimit_v0 vc_data;
21186 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21189 + return do_set_rlimit(vxi, vc_data.id,
21190 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21193 +#ifdef CONFIG_IA32_EMULATION
21195 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21197 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21199 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21202 + return do_set_rlimit(vxi, vc_data.id,
21203 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21206 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21208 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21211 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21214 + ret = do_get_rlimit(vxi, vc_data.id,
21215 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21219 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21224 +#endif /* CONFIG_IA32_EMULATION */
21227 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21229 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21235 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21240 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21241 + value = __rlim_get(limit, lim);
21242 + __rlim_rmax(limit, lim) = value;
21243 + __rlim_rmin(limit, lim) = value;
21248 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21250 + vx_reset_minmax(&vxi->limit);
21255 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21257 + struct vcmd_rlimit_stat_v0 vc_data;
21258 + struct _vx_limit *limit = &vxi->limit;
21261 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21265 + if (!is_accounted_vlimit(id))
21268 + vx_limit_fixup(limit, id);
21269 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21270 + vc_data.value = __rlim_get(limit, id);
21271 + vc_data.minimum = __rlim_rmin(limit, id);
21272 + vc_data.maximum = __rlim_rmax(limit, id);
21274 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21280 +void vx_vsi_meminfo(struct sysinfo *val)
21282 + struct vx_info *vxi = current->vx_info;
21283 + unsigned long totalram, freeram;
21286 + /* we blindly accept the max */
21287 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21288 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
21290 + /* total minus used equals free */
21291 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21292 + freeram = (v < totalram) ? totalram - v : 0;
21294 + val->totalram = totalram;
21295 + val->freeram = freeram;
21296 + val->bufferram = 0;
21297 + val->totalhigh = 0;
21298 + val->freehigh = 0;
21302 +void vx_vsi_swapinfo(struct sysinfo *val)
21304 + struct vx_info *vxi = current->vx_info;
21305 + unsigned long totalswap, freeswap;
21308 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21309 + if (v == RLIM_INFINITY) {
21310 + val->freeswap = val->totalswap;
21314 + /* we blindly accept the max */
21315 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
21316 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
21318 + /* currently 'used' swap */
21319 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21320 + w -= (w > v) ? v : w;
21322 + /* total minus used equals free */
21323 + freeswap = (w < totalswap) ? totalswap - w : 0;
21325 + val->totalswap = totalswap;
21326 + val->freeswap = freeswap;
21331 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
21333 + struct vx_info *vxi = mm->mm_vx_info;
21334 + unsigned long points;
21340 + points = vxi->vx_badness_bias;
21342 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21343 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21344 + points += (v > w) ? (v - w) : 0;
21349 diff -NurpP --minimal linux-2.6.29/kernel/vserver/limit_init.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/limit_init.h
21350 --- linux-2.6.29/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
21351 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/limit_init.h 2009-02-22 22:54:26.000000000 +0100
21355 +static inline void vx_info_init_limit(struct _vx_limit *limit)
21359 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21360 + __rlim_soft(limit, lim) = RLIM_INFINITY;
21361 + __rlim_hard(limit, lim) = RLIM_INFINITY;
21362 + __rlim_set(limit, lim, 0);
21363 + atomic_set(&__rlim_lhit(limit, lim), 0);
21364 + __rlim_rmin(limit, lim) = 0;
21365 + __rlim_rmax(limit, lim) = 0;
21369 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
21374 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21375 + if ((1 << lim) & VLIM_NOCHECK)
21377 + value = __rlim_get(limit, lim);
21378 + vxwprintk_xid(value,
21379 + "!!! limit: %p[%s,%d] = %ld on exit.",
21380 + limit, vlimit_name[lim], lim, (long)value);
21384 diff -NurpP --minimal linux-2.6.29/kernel/vserver/limit_proc.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/limit_proc.h
21385 --- linux-2.6.29/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
21386 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/limit_proc.h 2009-02-22 22:54:26.000000000 +0100
21388 +#ifndef _VX_LIMIT_PROC_H
21389 +#define _VX_LIMIT_PROC_H
21391 +#include <linux/vserver/limit_int.h>
21394 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
21395 +#define VX_LIMIT_TOP \
21396 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
21398 +#define VX_LIMIT_ARG(r) \
21399 + (unsigned long)__rlim_get(limit, r), \
21400 + (unsigned long)__rlim_rmin(limit, r), \
21401 + (unsigned long)__rlim_rmax(limit, r), \
21402 + VX_VLIM(__rlim_soft(limit, r)), \
21403 + VX_VLIM(__rlim_hard(limit, r)), \
21404 + atomic_read(&__rlim_lhit(limit, r))
21406 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
21408 + vx_limit_fixup(limit, -1);
21409 + return sprintf(buffer, VX_LIMIT_TOP
21410 + "PROC" VX_LIMIT_FMT
21411 + "VM" VX_LIMIT_FMT
21412 + "VML" VX_LIMIT_FMT
21413 + "RSS" VX_LIMIT_FMT
21414 + "ANON" VX_LIMIT_FMT
21415 + "RMAP" VX_LIMIT_FMT
21416 + "FILES" VX_LIMIT_FMT
21417 + "OFD" VX_LIMIT_FMT
21418 + "LOCKS" VX_LIMIT_FMT
21419 + "SOCK" VX_LIMIT_FMT
21420 + "MSGQ" VX_LIMIT_FMT
21421 + "SHM" VX_LIMIT_FMT
21422 + "SEMA" VX_LIMIT_FMT
21423 + "SEMS" VX_LIMIT_FMT
21424 + "DENT" VX_LIMIT_FMT,
21425 + VX_LIMIT_ARG(RLIMIT_NPROC),
21426 + VX_LIMIT_ARG(RLIMIT_AS),
21427 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
21428 + VX_LIMIT_ARG(RLIMIT_RSS),
21429 + VX_LIMIT_ARG(VLIMIT_ANON),
21430 + VX_LIMIT_ARG(VLIMIT_MAPPED),
21431 + VX_LIMIT_ARG(RLIMIT_NOFILE),
21432 + VX_LIMIT_ARG(VLIMIT_OPENFD),
21433 + VX_LIMIT_ARG(RLIMIT_LOCKS),
21434 + VX_LIMIT_ARG(VLIMIT_NSOCK),
21435 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
21436 + VX_LIMIT_ARG(VLIMIT_SHMEM),
21437 + VX_LIMIT_ARG(VLIMIT_SEMARY),
21438 + VX_LIMIT_ARG(VLIMIT_NSEMS),
21439 + VX_LIMIT_ARG(VLIMIT_DENTRY));
21442 +#endif /* _VX_LIMIT_PROC_H */
21445 diff -NurpP --minimal linux-2.6.29/kernel/vserver/Makefile linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/Makefile
21446 --- linux-2.6.29/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
21447 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/Makefile 2009-02-22 22:54:26.000000000 +0100
21450 +# Makefile for the Linux vserver routines.
21454 +obj-y += vserver.o
21456 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
21457 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
21460 +vserver-$(CONFIG_INET) += inet.o
21461 +vserver-$(CONFIG_PROC_FS) += proc.o
21462 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
21463 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
21464 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
21465 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
21467 diff -NurpP --minimal linux-2.6.29/kernel/vserver/monitor.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/monitor.c
21468 --- linux-2.6.29/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
21469 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/monitor.c 2009-02-22 22:54:26.000000000 +0100
21472 + * kernel/vserver/monitor.c
21474 + * Virtual Context Scheduler Monitor
21476 + * Copyright (C) 2006-2007 Herbert Pötzl
21478 + * V0.01 basic design
21482 +#include <linux/module.h>
21483 +#include <linux/jiffies.h>
21484 +#include <asm/uaccess.h>
21485 +#include <asm/atomic.h>
21487 +#include <linux/vserver/monitor.h>
21488 +#include <linux/vserver/debug_cmd.h>
21491 +#ifdef CONFIG_VSERVER_MONITOR
21492 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
21494 +#define VXM_SIZE 64
21497 +struct _vx_monitor {
21498 + unsigned int counter;
21500 + struct _vx_mon_entry entry[VXM_SIZE+1];
21504 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
21506 +unsigned volatile int vxm_active = 1;
21508 +static atomic_t sequence = ATOMIC_INIT(0);
21513 + * requires disabled preemption */
21515 +struct _vx_mon_entry *vxm_advance(int cpu)
21517 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21518 + struct _vx_mon_entry *entry;
21519 + unsigned int index;
21521 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
21522 + entry = &mon->entry[index];
21524 + entry->ev.seq = atomic_inc_return(&sequence);
21525 + entry->ev.jif = jiffies;
21529 +EXPORT_SYMBOL_GPL(vxm_advance);
21532 +int do_read_monitor(struct __user _vx_mon_entry *data,
21533 + int cpu, uint32_t *index, uint32_t *count)
21535 + int pos, ret = 0;
21536 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21537 + int end = mon->counter;
21538 + int start = end - VXM_SIZE + 2;
21539 + int idx = *index;
21541 + /* special case: get current pos */
21547 + /* have we lost some data? */
21551 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21552 + struct _vx_mon_entry *entry =
21553 + &mon->entry[idx % VXM_SIZE];
21555 + /* send entry to userspace */
21556 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21560 + /* save new index and count */
21563 + return ret ? ret : (*index < end);
21566 +int vc_read_monitor(uint32_t id, void __user *data)
21568 + struct vcmd_read_monitor_v0 vc_data;
21571 + if (id >= NR_CPUS)
21574 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21577 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
21578 + id, &vc_data.index, &vc_data.count);
21580 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21585 +#ifdef CONFIG_COMPAT
21587 +int vc_read_monitor_x32(uint32_t id, void __user *data)
21589 + struct vcmd_read_monitor_v0_x32 vc_data;
21592 + if (id >= NR_CPUS)
21595 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21598 + ret = do_read_monitor((struct __user _vx_mon_entry *)
21599 + compat_ptr(vc_data.data_ptr),
21600 + id, &vc_data.index, &vc_data.count);
21602 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21607 +#endif /* CONFIG_COMPAT */
21609 diff -NurpP --minimal linux-2.6.29/kernel/vserver/network.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/network.c
21610 --- linux-2.6.29/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
21611 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/network.c 2009-02-22 22:54:26.000000000 +0100
21614 + * linux/kernel/vserver/network.c
21616 + * Virtual Server: Network Support
21618 + * Copyright (C) 2003-2007 Herbert Pötzl
21620 + * V0.01 broken out from vcontext V0.05
21621 + * V0.02 cleaned up implementation
21622 + * V0.03 added equiv nx commands
21623 + * V0.04 switch to RCU based hash
21624 + * V0.05 and back to locking again
21625 + * V0.06 changed vcmds to nxi arg
21626 + * V0.07 have __create claim() the nxi
21630 +#include <linux/err.h>
21631 +#include <linux/slab.h>
21632 +#include <linux/rcupdate.h>
21634 +#include <linux/vs_network.h>
21635 +#include <linux/vs_pid.h>
21636 +#include <linux/vserver/network_cmd.h>
21639 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
21640 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
21642 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
21643 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
21646 +static int __init init_network(void)
21648 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
21649 + sizeof(struct nx_addr_v4), 0,
21650 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21651 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
21652 + sizeof(struct nx_addr_v6), 0,
21653 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21658 +/* __alloc_nx_addr_v4() */
21660 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
21662 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
21663 + nx_addr_v4_cachep, GFP_KERNEL);
21665 + if (!IS_ERR(nxa))
21666 + memset(nxa, 0, sizeof(*nxa));
21670 +/* __dealloc_nx_addr_v4() */
21672 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
21674 + kmem_cache_free(nx_addr_v4_cachep, nxa);
21677 +/* __dealloc_nx_addr_v4_all() */
21679 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
21682 + struct nx_addr_v4 *next = nxa->next;
21684 + __dealloc_nx_addr_v4(nxa);
21690 +#ifdef CONFIG_IPV6
21692 +/* __alloc_nx_addr_v6() */
21694 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
21696 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
21697 + nx_addr_v6_cachep, GFP_KERNEL);
21699 + if (!IS_ERR(nxa))
21700 + memset(nxa, 0, sizeof(*nxa));
21704 +/* __dealloc_nx_addr_v6() */
21706 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
21708 + kmem_cache_free(nx_addr_v6_cachep, nxa);
21711 +/* __dealloc_nx_addr_v6_all() */
21713 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
21716 + struct nx_addr_v6 *next = nxa->next;
21718 + __dealloc_nx_addr_v6(nxa);
21723 +#endif /* CONFIG_IPV6 */
21725 +/* __alloc_nx_info()
21727 + * allocate an initialized nx_info struct
21728 + * doesn't make it visible (hash) */
21730 +static struct nx_info *__alloc_nx_info(nid_t nid)
21732 + struct nx_info *new = NULL;
21734 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
21736 + /* would this benefit from a slab cache? */
21737 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
21741 + memset(new, 0, sizeof(struct nx_info));
21742 + new->nx_id = nid;
21743 + INIT_HLIST_NODE(&new->nx_hlist);
21744 + atomic_set(&new->nx_usecnt, 0);
21745 + atomic_set(&new->nx_tasks, 0);
21746 + new->nx_state = 0;
21748 + new->nx_flags = NXF_INIT_SET;
21750 + /* rest of init goes here */
21752 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
21753 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
21755 + vxdprintk(VXD_CBIT(nid, 0),
21756 + "alloc_nx_info(%d) = %p", nid, new);
21757 + atomic_inc(&nx_global_ctotal);
21761 +/* __dealloc_nx_info()
21763 + * final disposal of nx_info */
21765 +static void __dealloc_nx_info(struct nx_info *nxi)
21767 + vxdprintk(VXD_CBIT(nid, 0),
21768 + "dealloc_nx_info(%p)", nxi);
21770 + nxi->nx_hlist.next = LIST_POISON1;
21773 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21774 + BUG_ON(atomic_read(&nxi->nx_tasks));
21776 + __dealloc_nx_addr_v4_all(nxi->v4.next);
21778 + nxi->nx_state |= NXS_RELEASED;
21780 + atomic_dec(&nx_global_ctotal);
21783 +static void __shutdown_nx_info(struct nx_info *nxi)
21785 + nxi->nx_state |= NXS_SHUTDOWN;
21786 + vs_net_change(nxi, VSC_NETDOWN);
21789 +/* exported stuff */
21791 +void free_nx_info(struct nx_info *nxi)
21793 + /* context shutdown is mandatory */
21794 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
21796 + /* context must not be hashed */
21797 + BUG_ON(nxi->nx_state & NXS_HASHED);
21799 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21800 + BUG_ON(atomic_read(&nxi->nx_tasks));
21802 + __dealloc_nx_info(nxi);
21806 +void __nx_set_lback(struct nx_info *nxi)
21808 + int nid = nxi->nx_id;
21809 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
21811 + nxi->v4_lback.s_addr = lback;
21814 +extern int __nx_inet_add_lback(__be32 addr);
21815 +extern int __nx_inet_del_lback(__be32 addr);
21818 +/* hash table for nx_info hash */
21820 +#define NX_HASH_SIZE 13
21822 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
21824 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
21827 +static inline unsigned int __hashval(nid_t nid)
21829 + return (nid % NX_HASH_SIZE);
21834 +/* __hash_nx_info()
21836 + * add the nxi to the global hash table
21837 + * requires the hash_lock to be held */
21839 +static inline void __hash_nx_info(struct nx_info *nxi)
21841 + struct hlist_head *head;
21843 + vxd_assert_lock(&nx_info_hash_lock);
21844 + vxdprintk(VXD_CBIT(nid, 4),
21845 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
21847 + /* context must not be hashed */
21848 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
21850 + nxi->nx_state |= NXS_HASHED;
21851 + head = &nx_info_hash[__hashval(nxi->nx_id)];
21852 + hlist_add_head(&nxi->nx_hlist, head);
21853 + atomic_inc(&nx_global_cactive);
21856 +/* __unhash_nx_info()
21858 + * remove the nxi from the global hash table
21859 + * requires the hash_lock to be held */
21861 +static inline void __unhash_nx_info(struct nx_info *nxi)
21863 + vxd_assert_lock(&nx_info_hash_lock);
21864 + vxdprintk(VXD_CBIT(nid, 4),
21865 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
21866 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
21868 + /* context must be hashed */
21869 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
21870 + /* but without tasks */
21871 + BUG_ON(atomic_read(&nxi->nx_tasks));
21873 + nxi->nx_state &= ~NXS_HASHED;
21874 + hlist_del(&nxi->nx_hlist);
21875 + atomic_dec(&nx_global_cactive);
21879 +/* __lookup_nx_info()
21881 + * requires the hash_lock to be held
21882 + * doesn't increment the nx_refcnt */
21884 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
21886 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
21887 + struct hlist_node *pos;
21888 + struct nx_info *nxi;
21890 + vxd_assert_lock(&nx_info_hash_lock);
21891 + hlist_for_each(pos, head) {
21892 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21894 + if (nxi->nx_id == nid)
21899 + vxdprintk(VXD_CBIT(nid, 0),
21900 + "__lookup_nx_info(#%u): %p[#%u]",
21901 + nid, nxi, nxi ? nxi->nx_id : 0);
21906 +/* __create_nx_info()
21908 + * create the requested context
21909 + * get(), claim() and hash it */
21911 +static struct nx_info *__create_nx_info(int id)
21913 + struct nx_info *new, *nxi = NULL;
21915 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
21917 + if (!(new = __alloc_nx_info(id)))
21918 + return ERR_PTR(-ENOMEM);
21920 + /* required to make dynamic xids unique */
21921 + spin_lock(&nx_info_hash_lock);
21923 + /* static context requested */
21924 + if ((nxi = __lookup_nx_info(id))) {
21925 + vxdprintk(VXD_CBIT(nid, 0),
21926 + "create_nx_info(%d) = %p (already there)", id, nxi);
21927 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21928 + nxi = ERR_PTR(-EBUSY);
21930 + nxi = ERR_PTR(-EEXIST);
21933 + /* new context */
21934 + vxdprintk(VXD_CBIT(nid, 0),
21935 + "create_nx_info(%d) = %p (new)", id, new);
21936 + claim_nx_info(new, NULL);
21937 + __nx_set_lback(new);
21938 + __hash_nx_info(get_nx_info(new));
21939 + nxi = new, new = NULL;
21942 + spin_unlock(&nx_info_hash_lock);
21944 + __dealloc_nx_info(new);
21950 +/* exported stuff */
21953 +void unhash_nx_info(struct nx_info *nxi)
21955 + __shutdown_nx_info(nxi);
21956 + spin_lock(&nx_info_hash_lock);
21957 + __unhash_nx_info(nxi);
21958 + spin_unlock(&nx_info_hash_lock);
21961 +/* lookup_nx_info()
21963 + * search for a nx_info and get() it
21964 + * negative id means current */
21966 +struct nx_info *lookup_nx_info(int id)
21968 + struct nx_info *nxi = NULL;
21971 + nxi = get_nx_info(current->nx_info);
21972 + } else if (id > 1) {
21973 + spin_lock(&nx_info_hash_lock);
21974 + nxi = get_nx_info(__lookup_nx_info(id));
21975 + spin_unlock(&nx_info_hash_lock);
21980 +/* nid_is_hashed()
21982 + * verify that nid is still hashed */
21984 +int nid_is_hashed(nid_t nid)
21988 + spin_lock(&nx_info_hash_lock);
21989 + hashed = (__lookup_nx_info(nid) != NULL);
21990 + spin_unlock(&nx_info_hash_lock);
21995 +#ifdef CONFIG_PROC_FS
21999 + * get a subset of hashed nids for proc
22000 + * assumes size is at least one */
22002 +int get_nid_list(int index, unsigned int *nids, int size)
22004 + int hindex, nr_nids = 0;
22006 + /* only show current and children */
22007 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22010 + nids[nr_nids] = nx_current_nid();
22014 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22015 + struct hlist_head *head = &nx_info_hash[hindex];
22016 + struct hlist_node *pos;
22018 + spin_lock(&nx_info_hash_lock);
22019 + hlist_for_each(pos, head) {
22020 + struct nx_info *nxi;
22025 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22026 + nids[nr_nids] = nxi->nx_id;
22027 + if (++nr_nids >= size) {
22028 + spin_unlock(&nx_info_hash_lock);
22032 + /* keep the lock time short */
22033 + spin_unlock(&nx_info_hash_lock);
22042 + * migrate task to new network
22043 + * gets nxi, puts old_nxi on change
22046 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22048 + struct nx_info *old_nxi;
22054 + vxdprintk(VXD_CBIT(nid, 5),
22055 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22056 + p, nxi, nxi->nx_id,
22057 + atomic_read(&nxi->nx_usecnt),
22058 + atomic_read(&nxi->nx_tasks));
22060 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22061 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22064 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22067 + /* maybe disallow this completely? */
22068 + old_nxi = task_get_nx_info(p);
22069 + if (old_nxi == nxi)
22074 + clr_nx_info(&p->nx_info);
22075 + claim_nx_info(nxi, p);
22076 + set_nx_info(&p->nx_info, nxi);
22077 + p->nid = nxi->nx_id;
22080 + vxdprintk(VXD_CBIT(nid, 5),
22081 + "moved task %p into nxi:%p[#%d]",
22082 + p, nxi, nxi->nx_id);
22085 + release_nx_info(old_nxi, p);
22088 + put_nx_info(old_nxi);
22093 +void nx_set_persistent(struct nx_info *nxi)
22095 + vxdprintk(VXD_CBIT(nid, 6),
22096 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22098 + get_nx_info(nxi);
22099 + claim_nx_info(nxi, NULL);
22102 +void nx_clear_persistent(struct nx_info *nxi)
22104 + vxdprintk(VXD_CBIT(nid, 6),
22105 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22107 + release_nx_info(nxi, NULL);
22108 + put_nx_info(nxi);
22111 +void nx_update_persistent(struct nx_info *nxi)
22113 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22114 + nx_set_persistent(nxi);
22116 + nx_clear_persistent(nxi);
22119 +/* vserver syscall commands below here */
22121 +/* taks nid and nx_info functions */
22123 +#include <asm/uaccess.h>
22126 +int vc_task_nid(uint32_t id)
22131 + struct task_struct *tsk;
22133 + read_lock(&tasklist_lock);
22134 + tsk = find_task_by_real_pid(id);
22135 + nid = (tsk) ? tsk->nid : -ESRCH;
22136 + read_unlock(&tasklist_lock);
22138 + nid = nx_current_nid();
22143 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22145 + struct vcmd_nx_info_v0 vc_data;
22147 + vc_data.nid = nxi->nx_id;
22149 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22155 +/* network functions */
22157 +int vc_net_create(uint32_t nid, void __user *data)
22159 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22160 + struct nx_info *new_nxi;
22163 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22166 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22169 + new_nxi = __create_nx_info(nid);
22170 + if (IS_ERR(new_nxi))
22171 + return PTR_ERR(new_nxi);
22173 + /* initial flags */
22174 + new_nxi->nx_flags = vc_data.flagword;
22177 + if (vs_net_change(new_nxi, VSC_NETUP))
22180 + ret = nx_migrate_task(current, new_nxi);
22184 + /* return context id on success */
22185 + ret = new_nxi->nx_id;
22187 + /* get a reference for persistent contexts */
22188 + if ((vc_data.flagword & NXF_PERSISTENT))
22189 + nx_set_persistent(new_nxi);
22191 + release_nx_info(new_nxi, NULL);
22192 + put_nx_info(new_nxi);
22197 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22199 + return nx_migrate_task(current, nxi);
22204 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22205 + uint16_t type, uint16_t flags)
22207 + struct nx_addr_v4 *nxa = &nxi->v4;
22209 + if (NX_IPV4(nxi)) {
22210 + /* locate last entry */
22211 + for (; nxa->next; nxa = nxa->next);
22212 + nxa->next = __alloc_nx_addr_v4();
22216 + return PTR_ERR(nxa);
22219 + if (nxi->v4.next)
22220 + /* remove single ip for ip list */
22221 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22223 + nxa->ip[0].s_addr = ip;
22224 + nxa->ip[1].s_addr = ip2;
22225 + nxa->mask.s_addr = mask;
22226 + nxa->type = type;
22227 + nxa->flags = flags;
22232 +int vc_net_add(struct nx_info *nxi, void __user *data)
22234 + struct vcmd_net_addr_v0 vc_data;
22235 + int index, ret = 0;
22237 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22240 + switch (vc_data.type) {
22241 + case NXA_TYPE_IPV4:
22242 + if ((vc_data.count < 1) || (vc_data.count > 4))
22246 + while (index < vc_data.count) {
22247 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22248 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22256 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22257 + nxi->v4_bcast = vc_data.ip[0];
22261 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22262 + nxi->v4_lback = vc_data.ip[0];
22273 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22275 + struct vcmd_net_addr_v0 vc_data;
22277 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22280 + switch (vc_data.type) {
22281 + case NXA_TYPE_ANY:
22282 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22283 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22293 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22295 + struct vcmd_net_addr_ipv4_v1 vc_data;
22297 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22300 + switch (vc_data.type) {
22301 + case NXA_TYPE_ADDR:
22302 + case NXA_TYPE_RANGE:
22303 + case NXA_TYPE_MASK:
22304 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22305 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22307 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22308 + nxi->v4_bcast = vc_data.ip;
22311 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22312 + nxi->v4_lback = vc_data.ip;
22321 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
22323 + struct vcmd_net_addr_ipv4_v1 vc_data;
22325 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22328 + switch (vc_data.type) {
22329 +/* case NXA_TYPE_ADDR:
22332 + case NXA_TYPE_ANY:
22333 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22334 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22344 +#ifdef CONFIG_IPV6
22346 +int do_add_v6_addr(struct nx_info *nxi,
22347 + struct in6_addr *ip, struct in6_addr *mask,
22348 + uint32_t prefix, uint16_t type, uint16_t flags)
22350 + struct nx_addr_v6 *nxa = &nxi->v6;
22352 + if (NX_IPV6(nxi)) {
22353 + /* locate last entry */
22354 + for (; nxa->next; nxa = nxa->next);
22355 + nxa->next = __alloc_nx_addr_v6();
22359 + return PTR_ERR(nxa);
22363 + nxa->mask = *mask;
22364 + nxa->prefix = prefix;
22365 + nxa->type = type;
22366 + nxa->flags = flags;
22371 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
22373 + struct vcmd_net_addr_ipv6_v1 vc_data;
22375 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22378 + switch (vc_data.type) {
22379 + case NXA_TYPE_ADDR:
22380 + case NXA_TYPE_MASK:
22381 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
22382 + vc_data.prefix, vc_data.type, vc_data.flags);
22389 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
22391 + struct vcmd_net_addr_ipv6_v1 vc_data;
22393 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22396 + switch (vc_data.type) {
22397 + case NXA_TYPE_ANY:
22398 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
22399 + memset(&nxi->v6, 0, sizeof(nxi->v6));
22408 +#endif /* CONFIG_IPV6 */
22411 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
22413 + struct vcmd_net_flags_v0 vc_data;
22415 + vc_data.flagword = nxi->nx_flags;
22417 + /* special STATE flag handling */
22418 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
22420 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22425 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
22427 + struct vcmd_net_flags_v0 vc_data;
22428 + uint64_t mask, trigger;
22430 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22433 + /* special STATE flag handling */
22434 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
22435 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
22437 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
22438 + vc_data.flagword, mask);
22439 + if (trigger & NXF_PERSISTENT)
22440 + nx_update_persistent(nxi);
22445 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
22447 + struct vcmd_net_caps_v0 vc_data;
22449 + vc_data.ncaps = nxi->nx_ncaps;
22450 + vc_data.cmask = ~0ULL;
22452 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22457 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
22459 + struct vcmd_net_caps_v0 vc_data;
22461 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22464 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
22465 + vc_data.ncaps, vc_data.cmask);
22470 +#include <linux/module.h>
22472 +module_init(init_network);
22474 +EXPORT_SYMBOL_GPL(free_nx_info);
22475 +EXPORT_SYMBOL_GPL(unhash_nx_info);
22477 diff -NurpP --minimal linux-2.6.29/kernel/vserver/proc.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/proc.c
22478 --- linux-2.6.29/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
22479 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/proc.c 2009-02-22 22:54:26.000000000 +0100
22482 + * linux/kernel/vserver/proc.c
22484 + * Virtual Context Support
22486 + * Copyright (C) 2003-2007 Herbert Pötzl
22488 + * V0.01 basic structure
22489 + * V0.02 adaptation vs1.3.0
22490 + * V0.03 proc permissions
22491 + * V0.04 locking/generic
22492 + * V0.05 next generation procfs
22493 + * V0.06 inode validation
22494 + * V0.07 generic rewrite vid
22495 + * V0.08 remove inode type
22499 +#include <linux/proc_fs.h>
22500 +#include <asm/unistd.h>
22502 +#include <linux/vs_context.h>
22503 +#include <linux/vs_network.h>
22504 +#include <linux/vs_cvirt.h>
22506 +#include <linux/in.h>
22507 +#include <linux/inetdevice.h>
22508 +#include <linux/vs_inet.h>
22509 +#include <linux/vs_inet6.h>
22511 +#include <linux/vserver/global.h>
22513 +#include "cvirt_proc.h"
22514 +#include "cacct_proc.h"
22515 +#include "limit_proc.h"
22516 +#include "sched_proc.h"
22517 +#include "vci_config.h"
22520 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
22524 + CAP_FOR_EACH_U32(__capi) {
22525 + buffer += sprintf(buffer, "%08x",
22526 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
22532 +static struct proc_dir_entry *proc_virtual;
22534 +static struct proc_dir_entry *proc_virtnet;
22537 +/* first the actual feeds */
22540 +static int proc_vci(char *buffer)
22542 + return sprintf(buffer,
22543 + "VCIVersion:\t%04x:%04x\n"
22544 + "VCISyscall:\t%d\n"
22545 + "VCIKernel:\t%08x\n",
22546 + VCI_VERSION >> 16,
22547 + VCI_VERSION & 0xFFFF,
22549 + vci_kernel_config());
22552 +static int proc_virtual_info(char *buffer)
22554 + return proc_vci(buffer);
22557 +static int proc_virtual_status(char *buffer)
22559 + return sprintf(buffer,
22561 + "#CActive:\t%d\n"
22562 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n",
22563 + atomic_read(&vx_global_ctotal),
22564 + atomic_read(&vx_global_cactive),
22565 + atomic_read(&vs_global_nsproxy),
22566 + atomic_read(&vs_global_fs),
22567 + atomic_read(&vs_global_mnt_ns),
22568 + atomic_read(&vs_global_uts_ns),
22569 + atomic_read(&vs_global_ipc_ns),
22570 + atomic_read(&vs_global_user_ns),
22571 + atomic_read(&vs_global_pid_ns));
22575 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
22579 + length = sprintf(buffer,
22587 + vxi->vx_badness_bias);
22591 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
22593 + char *orig = buffer;
22595 + buffer += sprintf(buffer,
22598 + "Flags:\t%016llx\n",
22599 + atomic_read(&vxi->vx_usecnt),
22600 + atomic_read(&vxi->vx_tasks),
22601 + (unsigned long long)vxi->vx_flags);
22603 + buffer += sprintf(buffer, "BCaps:\t");
22604 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22605 + buffer += sprintf(buffer, "\n");
22607 + buffer += sprintf(buffer,
22608 + "CCaps:\t%016llx\n"
22609 + "Spaces:\t%08lx %08lx\n",
22610 + (unsigned long long)vxi->vx_ccaps,
22611 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
22612 + return buffer - orig;
22615 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
22617 + return vx_info_proc_limit(&vxi->limit, buffer);
22620 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
22624 + length = vx_info_proc_sched(&vxi->sched, buffer);
22625 + for_each_online_cpu(cpu) {
22626 + length += vx_info_proc_sched_pc(
22627 + &vx_per_cpu(vxi, sched_pc, cpu),
22628 + buffer + length, cpu);
22633 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
22635 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
22638 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
22640 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
22643 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
22647 + vx_update_load(vxi);
22648 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
22649 + for_each_online_cpu(cpu) {
22650 + length += vx_info_proc_cvirt_pc(
22651 + &vx_per_cpu(vxi, cvirt_pc, cpu),
22652 + buffer + length, cpu);
22657 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
22659 + return vx_info_proc_cacct(&vxi->cacct, buffer);
22663 +static int proc_virtnet_info(char *buffer)
22665 + return proc_vci(buffer);
22668 +static int proc_virtnet_status(char *buffer)
22670 + return sprintf(buffer,
22672 + "#CActive:\t%d\n",
22673 + atomic_read(&nx_global_ctotal),
22674 + atomic_read(&nx_global_cactive));
22677 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
22679 + struct nx_addr_v4 *v4a;
22680 +#ifdef CONFIG_IPV6
22681 + struct nx_addr_v6 *v6a;
22685 + length = sprintf(buffer,
22688 + "Bcast:\t" NIPQUAD_FMT "\n"
22689 + "Lback:\t" NIPQUAD_FMT "\n",
22692 + NIPQUAD(nxi->v4_bcast.s_addr),
22693 + NIPQUAD(nxi->v4_lback.s_addr));
22695 + if (!NX_IPV4(nxi))
22697 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22698 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
22701 +#ifdef CONFIG_IPV6
22702 + if (!NX_IPV6(nxi))
22704 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22705 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
22712 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
22716 + length = sprintf(buffer,
22719 + "Flags:\t%016llx\n"
22720 + "NCaps:\t%016llx\n",
22721 + atomic_read(&nxi->nx_usecnt),
22722 + atomic_read(&nxi->nx_tasks),
22723 + (unsigned long long)nxi->nx_flags,
22724 + (unsigned long long)nxi->nx_ncaps);
22730 +/* here the inode helpers */
22736 + struct inode_operations *iop;
22737 + struct file_operations *fop;
22738 + union proc_op op;
22741 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
22743 + struct inode *inode = new_inode(sb);
22748 + inode->i_mode = p->mode;
22750 + inode->i_op = p->iop;
22752 + inode->i_fop = p->fop;
22754 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
22755 + inode->i_flags |= S_IMMUTABLE;
22757 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
22759 + inode->i_uid = 0;
22760 + inode->i_gid = 0;
22761 + inode->i_tag = 0;
22766 +static struct dentry *vs_proc_instantiate(struct inode *dir,
22767 + struct dentry *dentry, int id, void *ptr)
22769 + struct vs_entry *p = ptr;
22770 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
22771 + struct dentry *error = ERR_PTR(-EINVAL);
22776 + PROC_I(inode)->op = p->op;
22777 + PROC_I(inode)->fd = id;
22778 + d_add(dentry, inode);
22786 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
22789 + * Fill a directory entry.
22791 + * If possible create the dcache entry and derive our inode number and
22792 + * file type from dcache entry.
22794 + * Since all of the proc inode numbers are dynamically generated, the inode
22795 + * numbers do not exist until the inode is cache. This means creating the
22796 + * the dcache entry in readdir is necessary to keep the inode numbers
22797 + * reported by readdir in sync with the inode numbers reported
22800 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
22801 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
22803 + struct dentry *child, *dir = filp->f_dentry;
22804 + struct inode *inode;
22805 + struct qstr qname;
22807 + unsigned type = DT_UNKNOWN;
22809 + qname.name = name;
22811 + qname.hash = full_name_hash(name, len);
22813 + child = d_lookup(dir, &qname);
22815 + struct dentry *new;
22816 + new = d_alloc(dir, &qname);
22818 + child = instantiate(dir->d_inode, new, id, ptr);
22825 + if (!child || IS_ERR(child) || !child->d_inode)
22826 + goto end_instantiate;
22827 + inode = child->d_inode;
22829 + ino = inode->i_ino;
22830 + type = inode->i_mode >> 12;
22835 + ino = find_inode_number(dir, &qname);
22838 + return filldir(dirent, name, len, filp->f_pos, ino, type);
22843 +/* get and revalidate vx_info/xid */
22846 +struct vx_info *get_proc_vx_info(struct inode *inode)
22848 + return lookup_vx_info(PROC_I(inode)->fd);
22851 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
22853 + struct inode *inode = dentry->d_inode;
22854 + xid_t xid = PROC_I(inode)->fd;
22856 + if (!xid || xid_is_hashed(xid))
22863 +/* get and revalidate nx_info/nid */
22865 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
22867 + struct inode *inode = dentry->d_inode;
22868 + nid_t nid = PROC_I(inode)->fd;
22870 + if (!nid || nid_is_hashed(nid))
22878 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
22880 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
22881 + size_t count, loff_t *ppos)
22883 + struct inode *inode = file->f_dentry->d_inode;
22884 + unsigned long page;
22885 + ssize_t length = 0;
22887 + if (count > PROC_BLOCK_SIZE)
22888 + count = PROC_BLOCK_SIZE;
22890 + /* fade that out as soon as stable */
22891 + WARN_ON(PROC_I(inode)->fd);
22893 + if (!(page = __get_free_page(GFP_KERNEL)))
22896 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
22897 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
22900 + length = simple_read_from_buffer(buf, count, ppos,
22901 + (char *)page, length);
22907 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
22908 + size_t count, loff_t *ppos)
22910 + struct inode *inode = file->f_dentry->d_inode;
22911 + struct vx_info *vxi = NULL;
22912 + xid_t xid = PROC_I(inode)->fd;
22913 + unsigned long page;
22914 + ssize_t length = 0;
22916 + if (count > PROC_BLOCK_SIZE)
22917 + count = PROC_BLOCK_SIZE;
22919 + /* fade that out as soon as stable */
22921 + vxi = lookup_vx_info(xid);
22925 + length = -ENOMEM;
22926 + if (!(page = __get_free_page(GFP_KERNEL)))
22929 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
22930 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
22933 + length = simple_read_from_buffer(buf, count, ppos,
22934 + (char *)page, length);
22938 + put_vx_info(vxi);
22943 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
22944 + size_t count, loff_t *ppos)
22946 + struct inode *inode = file->f_dentry->d_inode;
22947 + struct nx_info *nxi = NULL;
22948 + nid_t nid = PROC_I(inode)->fd;
22949 + unsigned long page;
22950 + ssize_t length = 0;
22952 + if (count > PROC_BLOCK_SIZE)
22953 + count = PROC_BLOCK_SIZE;
22955 + /* fade that out as soon as stable */
22957 + nxi = lookup_nx_info(nid);
22961 + length = -ENOMEM;
22962 + if (!(page = __get_free_page(GFP_KERNEL)))
22965 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22966 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22969 + length = simple_read_from_buffer(buf, count, ppos,
22970 + (char *)page, length);
22974 + put_nx_info(nxi);
22981 +/* here comes the lower level */
22984 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22985 + .len = sizeof(NAME) - 1, \
22986 + .name = (NAME), \
22994 +#define DIR(NAME, MODE, OTYPE) \
22995 + NOD(NAME, (S_IFDIR | (MODE)), \
22996 + &proc_ ## OTYPE ## _inode_operations, \
22997 + &proc_ ## OTYPE ## _file_operations, { } )
22999 +#define INF(NAME, MODE, OTYPE) \
23000 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23001 + &proc_vs_info_file_operations, \
23002 + { .proc_vs_read = &proc_##OTYPE } )
23004 +#define VINF(NAME, MODE, OTYPE) \
23005 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23006 + &proc_vx_info_file_operations, \
23007 + { .proc_vxi_read = &proc_##OTYPE } )
23009 +#define NINF(NAME, MODE, OTYPE) \
23010 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23011 + &proc_nx_info_file_operations, \
23012 + { .proc_nxi_read = &proc_##OTYPE } )
23015 +static struct file_operations proc_vs_info_file_operations = {
23016 + .read = proc_vs_info_read,
23019 +static struct file_operations proc_vx_info_file_operations = {
23020 + .read = proc_vx_info_read,
23023 +static struct dentry_operations proc_xid_dentry_operations = {
23024 + .d_revalidate = proc_xid_revalidate,
23027 +static struct vs_entry vx_base_stuff[] = {
23028 + VINF("info", S_IRUGO, vxi_info),
23029 + VINF("status", S_IRUGO, vxi_status),
23030 + VINF("limit", S_IRUGO, vxi_limit),
23031 + VINF("sched", S_IRUGO, vxi_sched),
23032 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23033 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23034 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23035 + VINF("cacct", S_IRUGO, vxi_cacct),
23042 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23043 + struct dentry *dentry, int id, void *ptr)
23045 + dentry->d_op = &proc_xid_dentry_operations;
23046 + return vs_proc_instantiate(dir, dentry, id, ptr);
23049 +static struct dentry *proc_xid_lookup(struct inode *dir,
23050 + struct dentry *dentry, struct nameidata *nd)
23052 + struct vs_entry *p = vx_base_stuff;
23053 + struct dentry *error = ERR_PTR(-ENOENT);
23055 + for (; p->name; p++) {
23056 + if (p->len != dentry->d_name.len)
23058 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23064 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23069 +static int proc_xid_readdir(struct file *filp,
23070 + void *dirent, filldir_t filldir)
23072 + struct dentry *dentry = filp->f_dentry;
23073 + struct inode *inode = dentry->d_inode;
23074 + struct vs_entry *p = vx_base_stuff;
23075 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23079 + pos = filp->f_pos;
23082 + ino = inode->i_ino;
23083 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23086 + /* fall through */
23088 + ino = parent_ino(dentry);
23089 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23092 + /* fall through */
23095 + if (index >= size)
23097 + for (p += index; p->name; p++) {
23098 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23099 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23105 + filp->f_pos = pos;
23111 +static struct file_operations proc_nx_info_file_operations = {
23112 + .read = proc_nx_info_read,
23115 +static struct dentry_operations proc_nid_dentry_operations = {
23116 + .d_revalidate = proc_nid_revalidate,
23119 +static struct vs_entry nx_base_stuff[] = {
23120 + NINF("info", S_IRUGO, nxi_info),
23121 + NINF("status", S_IRUGO, nxi_status),
23126 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23127 + struct dentry *dentry, int id, void *ptr)
23129 + dentry->d_op = &proc_nid_dentry_operations;
23130 + return vs_proc_instantiate(dir, dentry, id, ptr);
23133 +static struct dentry *proc_nid_lookup(struct inode *dir,
23134 + struct dentry *dentry, struct nameidata *nd)
23136 + struct vs_entry *p = nx_base_stuff;
23137 + struct dentry *error = ERR_PTR(-ENOENT);
23139 + for (; p->name; p++) {
23140 + if (p->len != dentry->d_name.len)
23142 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23148 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23153 +static int proc_nid_readdir(struct file *filp,
23154 + void *dirent, filldir_t filldir)
23156 + struct dentry *dentry = filp->f_dentry;
23157 + struct inode *inode = dentry->d_inode;
23158 + struct vs_entry *p = nx_base_stuff;
23159 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23163 + pos = filp->f_pos;
23166 + ino = inode->i_ino;
23167 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23170 + /* fall through */
23172 + ino = parent_ino(dentry);
23173 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23176 + /* fall through */
23179 + if (index >= size)
23181 + for (p += index; p->name; p++) {
23182 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23183 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23189 + filp->f_pos = pos;
23194 +#define MAX_MULBY10 ((~0U - 9) / 10)
23196 +static inline int atovid(const char *str, int len)
23201 + while (len-- > 0) {
23206 + if (vid >= MAX_MULBY10)
23216 +/* now the upper level (virtual) */
23219 +static struct file_operations proc_xid_file_operations = {
23220 + .read = generic_read_dir,
23221 + .readdir = proc_xid_readdir,
23224 +static struct inode_operations proc_xid_inode_operations = {
23225 + .lookup = proc_xid_lookup,
23228 +static struct vs_entry vx_virtual_stuff[] = {
23229 + INF("info", S_IRUGO, virtual_info),
23230 + INF("status", S_IRUGO, virtual_status),
23231 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23235 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23236 + struct dentry *dentry, struct nameidata *nd)
23238 + struct vs_entry *p = vx_virtual_stuff;
23239 + struct dentry *error = ERR_PTR(-ENOENT);
23242 + for (; p->name; p++) {
23243 + if (p->len != dentry->d_name.len)
23245 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23249 + goto instantiate;
23251 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23252 + if ((id < 0) || !xid_is_hashed(id))
23256 + error = proc_xid_instantiate(dir, dentry, id, p);
23261 +static struct file_operations proc_nid_file_operations = {
23262 + .read = generic_read_dir,
23263 + .readdir = proc_nid_readdir,
23266 +static struct inode_operations proc_nid_inode_operations = {
23267 + .lookup = proc_nid_lookup,
23270 +static struct vs_entry nx_virtnet_stuff[] = {
23271 + INF("info", S_IRUGO, virtnet_info),
23272 + INF("status", S_IRUGO, virtnet_status),
23273 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23277 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23278 + struct dentry *dentry, struct nameidata *nd)
23280 + struct vs_entry *p = nx_virtnet_stuff;
23281 + struct dentry *error = ERR_PTR(-ENOENT);
23284 + for (; p->name; p++) {
23285 + if (p->len != dentry->d_name.len)
23287 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23291 + goto instantiate;
23293 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23294 + if ((id < 0) || !nid_is_hashed(id))
23298 + error = proc_nid_instantiate(dir, dentry, id, p);
23304 +#define PROC_MAXVIDS 32
23306 +int proc_virtual_readdir(struct file *filp,
23307 + void *dirent, filldir_t filldir)
23309 + struct dentry *dentry = filp->f_dentry;
23310 + struct inode *inode = dentry->d_inode;
23311 + struct vs_entry *p = vx_virtual_stuff;
23312 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
23314 + unsigned int xid_array[PROC_MAXVIDS];
23315 + char buf[PROC_NUMBUF];
23316 + unsigned int nr_xids, i;
23319 + pos = filp->f_pos;
23322 + ino = inode->i_ino;
23323 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23326 + /* fall through */
23328 + ino = parent_ino(dentry);
23329 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23332 + /* fall through */
23335 + if (index >= size)
23337 + for (p += index; p->name; p++) {
23338 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23339 + vs_proc_instantiate, 0, p))
23344 + index = pos - size;
23345 + p = &vx_virtual_stuff[size - 1];
23346 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
23347 + for (i = 0; i < nr_xids; i++) {
23348 + int n, xid = xid_array[i];
23349 + unsigned int j = PROC_NUMBUF;
23353 + buf[--j] = '0' + (n % 10);
23356 + if (proc_fill_cache(filp, dirent, filldir,
23357 + buf + j, PROC_NUMBUF - j,
23358 + vs_proc_instantiate, xid, p))
23364 + filp->f_pos = pos;
23368 +static int proc_virtual_getattr(struct vfsmount *mnt,
23369 + struct dentry *dentry, struct kstat *stat)
23371 + struct inode *inode = dentry->d_inode;
23373 + generic_fillattr(inode, stat);
23374 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
23378 +static struct file_operations proc_virtual_dir_operations = {
23379 + .read = generic_read_dir,
23380 + .readdir = proc_virtual_readdir,
23383 +static struct inode_operations proc_virtual_dir_inode_operations = {
23384 + .getattr = proc_virtual_getattr,
23385 + .lookup = proc_virtual_lookup,
23392 +int proc_virtnet_readdir(struct file *filp,
23393 + void *dirent, filldir_t filldir)
23395 + struct dentry *dentry = filp->f_dentry;
23396 + struct inode *inode = dentry->d_inode;
23397 + struct vs_entry *p = nx_virtnet_stuff;
23398 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
23400 + unsigned int nid_array[PROC_MAXVIDS];
23401 + char buf[PROC_NUMBUF];
23402 + unsigned int nr_nids, i;
23405 + pos = filp->f_pos;
23408 + ino = inode->i_ino;
23409 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23412 + /* fall through */
23414 + ino = parent_ino(dentry);
23415 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23418 + /* fall through */
23421 + if (index >= size)
23423 + for (p += index; p->name; p++) {
23424 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23425 + vs_proc_instantiate, 0, p))
23430 + index = pos - size;
23431 + p = &nx_virtnet_stuff[size - 1];
23432 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
23433 + for (i = 0; i < nr_nids; i++) {
23434 + int n, nid = nid_array[i];
23435 + unsigned int j = PROC_NUMBUF;
23439 + buf[--j] = '0' + (n % 10);
23442 + if (proc_fill_cache(filp, dirent, filldir,
23443 + buf + j, PROC_NUMBUF - j,
23444 + vs_proc_instantiate, nid, p))
23450 + filp->f_pos = pos;
23454 +static int proc_virtnet_getattr(struct vfsmount *mnt,
23455 + struct dentry *dentry, struct kstat *stat)
23457 + struct inode *inode = dentry->d_inode;
23459 + generic_fillattr(inode, stat);
23460 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
23464 +static struct file_operations proc_virtnet_dir_operations = {
23465 + .read = generic_read_dir,
23466 + .readdir = proc_virtnet_readdir,
23469 +static struct inode_operations proc_virtnet_dir_inode_operations = {
23470 + .getattr = proc_virtnet_getattr,
23471 + .lookup = proc_virtnet_lookup,
23476 +void proc_vx_init(void)
23478 + struct proc_dir_entry *ent;
23480 + ent = proc_mkdir("virtual", 0);
23482 + ent->proc_fops = &proc_virtual_dir_operations;
23483 + ent->proc_iops = &proc_virtual_dir_inode_operations;
23485 + proc_virtual = ent;
23487 + ent = proc_mkdir("virtnet", 0);
23489 + ent->proc_fops = &proc_virtnet_dir_operations;
23490 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
23492 + proc_virtnet = ent;
23498 +/* per pid info */
23501 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
23503 + struct vx_info *vxi;
23504 + char *orig = buffer;
23506 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
23508 + vxi = task_get_vx_info(p);
23512 + buffer += sprintf(buffer, "BCaps:\t");
23513 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23514 + buffer += sprintf(buffer, "\n");
23515 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
23516 + (unsigned long long)vxi->vx_ccaps);
23517 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
23518 + (unsigned long long)vxi->vx_flags);
23519 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
23521 + put_vx_info(vxi);
23523 + return buffer - orig;
23527 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
23529 + struct nx_info *nxi;
23530 + struct nx_addr_v4 *v4a;
23531 +#ifdef CONFIG_IPV6
23532 + struct nx_addr_v6 *v6a;
23534 + char *orig = buffer;
23537 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
23539 + nxi = task_get_nx_info(p);
23543 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
23544 + (unsigned long long)nxi->nx_ncaps);
23545 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
23546 + (unsigned long long)nxi->nx_flags);
23548 + buffer += sprintf(buffer,
23549 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
23550 + NIPQUAD(nxi->v4_bcast.s_addr));
23551 + buffer += sprintf (buffer,
23552 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
23553 + NIPQUAD(nxi->v4_lback.s_addr));
23554 + if (!NX_IPV4(nxi))
23556 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23557 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
23560 +#ifdef CONFIG_IPV6
23561 + if (!NX_IPV6(nxi))
23563 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23564 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
23568 + put_nx_info(nxi);
23570 + return buffer - orig;
23573 diff -NurpP --minimal linux-2.6.29/kernel/vserver/sched.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/sched.c
23574 --- linux-2.6.29/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
23575 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/sched.c 2009-02-22 22:54:26.000000000 +0100
23578 + * linux/kernel/vserver/sched.c
23580 + * Virtual Server: Scheduler Support
23582 + * Copyright (C) 2004-2007 Herbert Pötzl
23584 + * V0.01 adapted Sam Vilains version to 2.6.3
23585 + * V0.02 removed legacy interface
23586 + * V0.03 changed vcmds to vxi arg
23587 + * V0.04 removed older and legacy interfaces
23591 +#include <linux/vs_context.h>
23592 +#include <linux/vs_sched.h>
23593 +#include <linux/vserver/sched_cmd.h>
23595 +#include <asm/uaccess.h>
23598 +#define vxd_check_range(val, min, max) do { \
23599 + vxlprintk((val < min) || (val > max), \
23600 + "check_range(%ld,%ld,%ld)", \
23601 + (long)val, (long)min, (long)max, \
23602 + __FILE__, __LINE__); \
23606 +void vx_update_sched_param(struct _vx_sched *sched,
23607 + struct _vx_sched_pc *sched_pc)
23609 + unsigned int set_mask = sched->update_mask;
23611 + if (set_mask & VXSM_FILL_RATE)
23612 + sched_pc->fill_rate[0] = sched->fill_rate[0];
23613 + if (set_mask & VXSM_INTERVAL)
23614 + sched_pc->interval[0] = sched->interval[0];
23615 + if (set_mask & VXSM_FILL_RATE2)
23616 + sched_pc->fill_rate[1] = sched->fill_rate[1];
23617 + if (set_mask & VXSM_INTERVAL2)
23618 + sched_pc->interval[1] = sched->interval[1];
23619 + if (set_mask & VXSM_TOKENS)
23620 + sched_pc->tokens = sched->tokens;
23621 + if (set_mask & VXSM_TOKENS_MIN)
23622 + sched_pc->tokens_min = sched->tokens_min;
23623 + if (set_mask & VXSM_TOKENS_MAX)
23624 + sched_pc->tokens_max = sched->tokens_max;
23625 + if (set_mask & VXSM_PRIO_BIAS)
23626 + sched_pc->prio_bias = sched->prio_bias;
23628 + if (set_mask & VXSM_IDLE_TIME)
23629 + sched_pc->flags |= VXSF_IDLE_TIME;
23631 + sched_pc->flags &= ~VXSF_IDLE_TIME;
23634 + sched_pc->norm_time = jiffies;
23639 + * recalculate the context's scheduling tokens
23641 + * ret > 0 : number of tokens available
23642 + * ret < 0 : on hold, check delta_min[]
23643 + * -1 only jiffies
23644 + * -2 also idle time
23647 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
23648 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
23652 + int flags = sched_pc->flags;
23654 + /* how much time did pass? */
23655 + delta = *norm_time - sched_pc->norm_time;
23656 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
23657 + vxd_check_range(delta, 0, INT_MAX);
23659 + if (delta >= sched_pc->interval[0]) {
23660 + long tokens, integral;
23662 + /* calc integral token part */
23663 + tokens = delta / sched_pc->interval[0];
23664 + integral = tokens * sched_pc->interval[0];
23665 + tokens *= sched_pc->fill_rate[0];
23666 +#ifdef CONFIG_VSERVER_HARDCPU
23667 + delta_min[0] = delta - integral;
23668 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
23670 + /* advance time */
23671 + sched_pc->norm_time += delta;
23674 + sched_pc->tokens += tokens;
23675 + sched_pc->token_time += tokens;
23677 + delta_min[0] = delta;
23679 +#ifdef CONFIG_VSERVER_IDLETIME
23680 + if (!(flags & VXSF_IDLE_TIME))
23683 + /* how much was the idle skip? */
23684 + delta = *idle_time - sched_pc->idle_time;
23685 + vxd_check_range(delta, 0, INT_MAX);
23687 + if (delta >= sched_pc->interval[1]) {
23688 + long tokens, integral;
23690 + /* calc fair share token part */
23691 + tokens = delta / sched_pc->interval[1];
23692 + integral = tokens * sched_pc->interval[1];
23693 + tokens *= sched_pc->fill_rate[1];
23694 + delta_min[1] = delta - integral;
23695 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
23697 + /* advance idle time */
23698 + sched_pc->idle_time += integral;
23701 + sched_pc->tokens += tokens;
23702 + sched_pc->token_time += tokens;
23704 + delta_min[1] = delta;
23708 + /* clip at maximum */
23709 + if (sched_pc->tokens > sched_pc->tokens_max)
23710 + sched_pc->tokens = sched_pc->tokens_max;
23711 + tokens = sched_pc->tokens;
23713 + if ((flags & VXSF_ONHOLD)) {
23714 + /* can we unhold? */
23715 + if (tokens >= sched_pc->tokens_min) {
23716 + flags &= ~VXSF_ONHOLD;
23717 + sched_pc->hold_ticks +=
23718 + *norm_time - sched_pc->onhold;
23722 + /* put on hold? */
23723 + if (tokens <= 0) {
23724 + flags |= VXSF_ONHOLD;
23725 + sched_pc->onhold = *norm_time;
23729 + sched_pc->flags = flags;
23733 + tokens = sched_pc->tokens_min - tokens;
23734 + sched_pc->flags = flags;
23735 + // BUG_ON(tokens < 0); probably doesn't hold anymore
23737 +#ifdef CONFIG_VSERVER_HARDCPU
23738 + /* next interval? */
23739 + if (!sched_pc->fill_rate[0])
23740 + delta_min[0] = HZ;
23741 + else if (tokens > sched_pc->fill_rate[0])
23742 + delta_min[0] += sched_pc->interval[0] *
23743 + tokens / sched_pc->fill_rate[0];
23745 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
23746 + vxd_check_range(delta_min[0], 0, INT_MAX);
23748 +#ifdef CONFIG_VSERVER_IDLETIME
23749 + if (!(flags & VXSF_IDLE_TIME))
23752 + /* next interval? */
23753 + if (!sched_pc->fill_rate[1])
23754 + delta_min[1] = HZ;
23755 + else if (tokens > sched_pc->fill_rate[1])
23756 + delta_min[1] += sched_pc->interval[1] *
23757 + tokens / sched_pc->fill_rate[1];
23759 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
23760 + vxd_check_range(delta_min[1], 0, INT_MAX);
23765 +#endif /* CONFIG_VSERVER_IDLETIME */
23768 +#endif /* CONFIG_VSERVER_HARDCPU */
23771 +static inline unsigned long msec_to_ticks(unsigned long msec)
23773 + return msecs_to_jiffies(msec);
23776 +static inline unsigned long ticks_to_msec(unsigned long ticks)
23778 + return jiffies_to_msecs(ticks);
23781 +static inline unsigned long ticks_to_usec(unsigned long ticks)
23783 + return jiffies_to_usecs(ticks);
23787 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
23789 + unsigned int set_mask = data->mask;
23790 + unsigned int update_mask;
23793 + /* Sanity check data values */
23794 + if (data->tokens_max <= 0)
23795 + data->tokens_max = HZ;
23796 + if (data->tokens_min < 0)
23797 + data->tokens_min = HZ / 3;
23798 + if (data->tokens_min >= data->tokens_max)
23799 + data->tokens_min = data->tokens_max;
23801 + if (data->prio_bias > MAX_PRIO_BIAS)
23802 + data->prio_bias = MAX_PRIO_BIAS;
23803 + if (data->prio_bias < MIN_PRIO_BIAS)
23804 + data->prio_bias = MIN_PRIO_BIAS;
23806 + spin_lock(&vxi->sched.tokens_lock);
23808 + /* sync up on delayed updates */
23809 + for_each_cpu_mask(cpu, vxi->sched.update)
23810 + vx_update_sched_param(&vxi->sched,
23811 + &vx_per_cpu(vxi, sched_pc, cpu));
23813 + if (set_mask & VXSM_FILL_RATE)
23814 + vxi->sched.fill_rate[0] = data->fill_rate[0];
23815 + if (set_mask & VXSM_FILL_RATE2)
23816 + vxi->sched.fill_rate[1] = data->fill_rate[1];
23817 + if (set_mask & VXSM_INTERVAL)
23818 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
23819 + msec_to_ticks(data->interval[0]) : data->interval[0];
23820 + if (set_mask & VXSM_INTERVAL2)
23821 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
23822 + msec_to_ticks(data->interval[1]) : data->interval[1];
23823 + if (set_mask & VXSM_TOKENS)
23824 + vxi->sched.tokens = data->tokens;
23825 + if (set_mask & VXSM_TOKENS_MIN)
23826 + vxi->sched.tokens_min = data->tokens_min;
23827 + if (set_mask & VXSM_TOKENS_MAX)
23828 + vxi->sched.tokens_max = data->tokens_max;
23829 + if (set_mask & VXSM_PRIO_BIAS)
23830 + vxi->sched.prio_bias = data->prio_bias;
23832 + /* Sanity check rate/interval */
23833 + for (i = 0; i < 2; i++) {
23834 + if (data->fill_rate[i] < 0)
23835 + data->fill_rate[i] = 0;
23836 + if (data->interval[i] <= 0)
23837 + data->interval[i] = HZ;
23840 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
23841 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
23842 + vxi->sched.update_mask = update_mask;
23846 + if (set_mask & VXSM_CPU_ID) {
23847 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
23848 + cpus_and(vxi->sched.update, cpu_online_map,
23849 + vxi->sched.update);
23851 + vxi->sched.update = cpu_online_map;
23853 + /* forced reload? */
23854 + if (set_mask & VXSM_FORCE) {
23855 + for_each_cpu_mask(cpu, vxi->sched.update)
23856 + vx_update_sched_param(&vxi->sched,
23857 + &vx_per_cpu(vxi, sched_pc, cpu));
23858 + vxi->sched.update = CPU_MASK_NONE;
23861 + /* on UP we update immediately */
23862 + vx_update_sched_param(&vxi->sched,
23863 + &vx_per_cpu(vxi, sched_pc, 0));
23866 + spin_unlock(&vxi->sched.tokens_lock);
23871 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
23872 +#define COPY_PRI(C) C(prio_bias)
23873 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23874 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23875 + C(fill_rate[1]); C(interval[1]);
23877 +#define COPY_VALUE(name) vc_data.name = data->name
23879 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
23881 + struct vcmd_sched_v5 vc_data;
23883 + vc_data.mask = data->set_mask;
23884 + COPY_IDS(COPY_VALUE);
23885 + COPY_PRI(COPY_VALUE);
23886 + COPY_TOK(COPY_VALUE);
23887 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
23888 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
23889 + return do_set_sched(vxi, &vc_data);
23892 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
23894 + struct vcmd_set_sched_v4 vc_data;
23896 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23899 + return do_set_sched_v4(vxi, &vc_data);
23902 + /* latest interface is v5 */
23904 +int vc_set_sched(struct vx_info *vxi, void __user *data)
23906 + struct vcmd_sched_v5 vc_data;
23908 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23911 + return do_set_sched(vxi, &vc_data);
23915 +#define COPY_PRI(C) C(prio_bias)
23916 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23917 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23918 + C(fill_rate[1]); C(interval[1]);
23920 +#define COPY_VALUE(name) vc_data.name = data->name
23923 +int vc_get_sched(struct vx_info *vxi, void __user *data)
23925 + struct vcmd_sched_v5 vc_data;
23927 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23930 + if (vc_data.mask & VXSM_CPU_ID) {
23931 + int cpu = vc_data.cpu_id;
23932 + struct _vx_sched_pc *data;
23934 + if (!cpu_possible(cpu))
23937 + data = &vx_per_cpu(vxi, sched_pc, cpu);
23938 + COPY_TOK(COPY_VALUE);
23939 + COPY_PRI(COPY_VALUE);
23940 + COPY_FRI(COPY_VALUE);
23942 + if (data->flags & VXSF_IDLE_TIME)
23943 + vc_data.mask |= VXSM_IDLE_TIME;
23945 + struct _vx_sched *data = &vxi->sched;
23947 + COPY_TOK(COPY_VALUE);
23948 + COPY_PRI(COPY_VALUE);
23949 + COPY_FRI(COPY_VALUE);
23952 + if (vc_data.mask & VXSM_MSEC) {
23953 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
23954 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
23957 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23963 +int vc_sched_info(struct vx_info *vxi, void __user *data)
23965 + struct vcmd_sched_info vc_data;
23968 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23971 + cpu = vc_data.cpu_id;
23972 + if (!cpu_possible(cpu))
23976 + struct _vx_sched_pc *sched_pc =
23977 + &vx_per_cpu(vxi, sched_pc, cpu);
23979 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
23980 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
23981 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
23982 + vc_data.vavavoom = sched_pc->vavavoom;
23984 + vc_data.token_usec = ticks_to_usec(1);
23986 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23991 diff -NurpP --minimal linux-2.6.29/kernel/vserver/sched_init.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/sched_init.h
23992 --- linux-2.6.29/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
23993 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/sched_init.h 2009-02-22 22:54:26.000000000 +0100
23996 +static inline void vx_info_init_sched(struct _vx_sched *sched)
23998 + static struct lock_class_key tokens_lock_key;
24000 + /* scheduling; hard code starting values as constants */
24001 + sched->fill_rate[0] = 1;
24002 + sched->interval[0] = 4;
24003 + sched->fill_rate[1] = 1;
24004 + sched->interval[1] = 8;
24005 + sched->tokens = HZ >> 2;
24006 + sched->tokens_min = HZ >> 4;
24007 + sched->tokens_max = HZ >> 1;
24008 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24009 + sched->prio_bias = 0;
24011 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24015 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24017 + sched_pc->fill_rate[0] = 1;
24018 + sched_pc->interval[0] = 4;
24019 + sched_pc->fill_rate[1] = 1;
24020 + sched_pc->interval[1] = 8;
24021 + sched_pc->tokens = HZ >> 2;
24022 + sched_pc->tokens_min = HZ >> 4;
24023 + sched_pc->tokens_max = HZ >> 1;
24024 + sched_pc->prio_bias = 0;
24025 + sched_pc->vavavoom = 0;
24026 + sched_pc->token_time = 0;
24027 + sched_pc->idle_time = 0;
24028 + sched_pc->norm_time = jiffies;
24030 + sched_pc->user_ticks = 0;
24031 + sched_pc->sys_ticks = 0;
24032 + sched_pc->hold_ticks = 0;
24035 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24041 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24045 diff -NurpP --minimal linux-2.6.29/kernel/vserver/sched_proc.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/sched_proc.h
24046 --- linux-2.6.29/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24047 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/sched_proc.h 2009-02-22 22:54:26.000000000 +0100
24049 +#ifndef _VX_SCHED_PROC_H
24050 +#define _VX_SCHED_PROC_H
24054 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24058 + length += sprintf(buffer,
24059 + "FillRate:\t%8d,%d\n"
24060 + "Interval:\t%8d,%d\n"
24061 + "TokensMin:\t%8d\n"
24062 + "TokensMax:\t%8d\n"
24063 + "PrioBias:\t%8d\n",
24064 + sched->fill_rate[0],
24065 + sched->fill_rate[1],
24066 + sched->interval[0],
24067 + sched->interval[1],
24068 + sched->tokens_min,
24069 + sched->tokens_max,
24070 + sched->prio_bias);
24075 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24076 + char *buffer, int cpu)
24080 + length += sprintf(buffer + length,
24081 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24082 + (unsigned long long)sched_pc->user_ticks,
24083 + (unsigned long long)sched_pc->sys_ticks,
24084 + (unsigned long long)sched_pc->hold_ticks,
24085 + sched_pc->token_time,
24086 + sched_pc->idle_time);
24087 + length += sprintf(buffer + length,
24088 + " %c%c %d %d %d %d/%d %d/%d",
24089 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24090 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24091 + sched_pc->tokens,
24092 + sched_pc->tokens_min,
24093 + sched_pc->tokens_max,
24094 + sched_pc->fill_rate[0],
24095 + sched_pc->interval[0],
24096 + sched_pc->fill_rate[1],
24097 + sched_pc->interval[1]);
24098 + length += sprintf(buffer + length,
24100 + sched_pc->prio_bias,
24101 + sched_pc->vavavoom);
24105 +#endif /* _VX_SCHED_PROC_H */
24106 diff -NurpP --minimal linux-2.6.29/kernel/vserver/signal.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/signal.c
24107 --- linux-2.6.29/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24108 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/signal.c 2009-02-22 22:54:26.000000000 +0100
24111 + * linux/kernel/vserver/signal.c
24113 + * Virtual Server: Signal Support
24115 + * Copyright (C) 2003-2007 Herbert Pötzl
24117 + * V0.01 broken out from vcontext V0.05
24118 + * V0.02 changed vcmds to vxi arg
24119 + * V0.03 adjusted siginfo for kill
24123 +#include <asm/uaccess.h>
24125 +#include <linux/vs_context.h>
24126 +#include <linux/vs_pid.h>
24127 +#include <linux/vserver/signal_cmd.h>
24130 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24132 + int retval, count = 0;
24133 + struct task_struct *p;
24134 + struct siginfo *sip = SEND_SIG_PRIV;
24137 + vxdprintk(VXD_CBIT(misc, 4),
24138 + "vx_info_kill(%p[#%d],%d,%d)*",
24139 + vxi, vxi->vx_id, pid, sig);
24140 + read_lock(&tasklist_lock);
24144 + for_each_process(p) {
24147 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24148 + (pid && vxi->vx_initpid == p->pid))
24151 + err = group_send_sig_info(sig, sip, p);
24153 + if (err != -EPERM)
24159 + if (vxi->vx_initpid) {
24160 + pid = vxi->vx_initpid;
24161 + /* for now, only SIGINT to private init ... */
24162 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24163 + /* ... as long as there are tasks left */
24164 + (atomic_read(&vxi->vx_tasks) > 1))
24167 + /* fallthrough */
24169 + p = find_task_by_real_pid(pid);
24171 + if (vx_task_xid(p) == vxi->vx_id)
24172 + retval = group_send_sig_info(sig, sip, p);
24176 + read_unlock(&tasklist_lock);
24177 + vxdprintk(VXD_CBIT(misc, 4),
24178 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24179 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24183 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24185 + struct vcmd_ctx_kill_v0 vc_data;
24187 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24190 + /* special check to allow guest shutdown */
24191 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24192 + /* forbid killall pid=0 when init is present */
24193 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24194 + (vc_data.pid > 1)))
24197 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24201 +static int __wait_exit(struct vx_info *vxi)
24203 + DECLARE_WAITQUEUE(wait, current);
24206 + add_wait_queue(&vxi->vx_wait, &wait);
24207 + set_current_state(TASK_INTERRUPTIBLE);
24210 + if (vx_info_state(vxi,
24211 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24213 + if (signal_pending(current)) {
24214 + ret = -ERESTARTSYS;
24221 + set_current_state(TASK_RUNNING);
24222 + remove_wait_queue(&vxi->vx_wait, &wait);
24228 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24230 + struct vcmd_wait_exit_v0 vc_data;
24233 + ret = __wait_exit(vxi);
24234 + vc_data.reboot_cmd = vxi->reboot_cmd;
24235 + vc_data.exit_code = vxi->exit_code;
24237 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24242 diff -NurpP --minimal linux-2.6.29/kernel/vserver/space.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/space.c
24243 --- linux-2.6.29/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24244 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/space.c 2009-03-25 00:39:55.000000000 +0100
24247 + * linux/kernel/vserver/space.c
24249 + * Virtual Server: Context Space Support
24251 + * Copyright (C) 2003-2007 Herbert Pötzl
24253 + * V0.01 broken out from context.c 0.07
24254 + * V0.02 added task locking for namespace
24255 + * V0.03 broken out vx_enter_namespace
24256 + * V0.04 added *space support and commands
24260 +#include <linux/utsname.h>
24261 +#include <linux/nsproxy.h>
24262 +#include <linux/err.h>
24263 +#include <asm/uaccess.h>
24265 +#include <linux/vs_context.h>
24266 +#include <linux/vserver/space.h>
24267 +#include <linux/vserver/space_cmd.h>
24269 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24270 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24271 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24272 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24273 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
24274 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24275 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24278 +/* namespace functions */
24280 +#include <linux/mnt_namespace.h>
24281 +#include <linux/user_namespace.h>
24282 +#include <linux/pid_namespace.h>
24283 +#include <linux/ipc_namespace.h>
24284 +#include <net/net_namespace.h>
24287 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24288 + .mask = CLONE_FS |
24296 +static const struct vcmd_space_mask_v1 space_mask = {
24297 + .mask = CLONE_FS |
24302 +#ifdef CONFIG_PID_NS
24305 +#ifdef CONFIG_NET_NS
24311 +static const struct vcmd_space_mask_v1 default_space_mask = {
24312 + .mask = CLONE_FS |
24317 +#ifdef CONFIG_PID_NS
24324 + * build a new nsproxy mix
24325 + * assumes that both proxies are 'const'
24326 + * does not touch nsproxy refcounts
24327 + * will hold a reference on the result.
24330 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
24331 + struct nsproxy *new_nsproxy, unsigned long mask)
24333 + struct mnt_namespace *old_ns;
24334 + struct uts_namespace *old_uts;
24335 + struct ipc_namespace *old_ipc;
24336 +#ifdef CONFIG_PID_NS
24337 + struct pid_namespace *old_pid;
24339 +#ifdef CONFIG_NET_NS
24340 + struct net *old_net;
24342 + struct nsproxy *nsproxy;
24344 + nsproxy = copy_nsproxy(old_nsproxy);
24348 + if (mask & CLONE_NEWNS) {
24349 + old_ns = nsproxy->mnt_ns;
24350 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
24351 + if (nsproxy->mnt_ns)
24352 + get_mnt_ns(nsproxy->mnt_ns);
24356 + if (mask & CLONE_NEWUTS) {
24357 + old_uts = nsproxy->uts_ns;
24358 + nsproxy->uts_ns = new_nsproxy->uts_ns;
24359 + if (nsproxy->uts_ns)
24360 + get_uts_ns(nsproxy->uts_ns);
24364 + if (mask & CLONE_NEWIPC) {
24365 + old_ipc = nsproxy->ipc_ns;
24366 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
24367 + if (nsproxy->ipc_ns)
24368 + get_ipc_ns(nsproxy->ipc_ns);
24372 +#ifdef CONFIG_PID_NS
24373 + if (mask & CLONE_NEWPID) {
24374 + old_pid = nsproxy->pid_ns;
24375 + nsproxy->pid_ns = new_nsproxy->pid_ns;
24376 + if (nsproxy->pid_ns)
24377 + get_pid_ns(nsproxy->pid_ns);
24381 +#ifdef CONFIG_NET_NS
24382 + if (mask & CLONE_NEWNET) {
24383 + old_net = nsproxy->net_ns;
24384 + nsproxy->net_ns = new_nsproxy->net_ns;
24385 + if (nsproxy->net_ns)
24386 + get_net(nsproxy->net_ns);
24391 + put_mnt_ns(old_ns);
24393 + put_uts_ns(old_uts);
24395 + put_ipc_ns(old_ipc);
24396 +#ifdef CONFIG_PID_NS
24398 + put_pid_ns(old_pid);
24400 +#ifdef CONFIG_NET_NS
24402 + put_net(old_net);
24410 + * merge two nsproxy structs into a new one.
24411 + * will hold a reference on the result.
24415 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24416 + struct nsproxy *proxy, unsigned long mask)
24418 + struct nsproxy null_proxy = { .mnt_ns = NULL };
24424 + /* vs_mix_nsproxy returns with reference */
24425 + return vs_mix_nsproxy(old ? old : &null_proxy,
24428 + get_nsproxy(proxy);
24433 + * merge two fs structs into a new one.
24434 + * will take a reference on the result.
24438 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
24439 + struct fs_struct *fs, unsigned long mask)
24441 + if (!(mask & CLONE_FS)) {
24443 + atomic_inc(&old->count);
24450 + return copy_fs_struct(fs);
24454 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24456 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24457 + struct fs_struct *fs, *fs_cur, *fs_new;
24460 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
24461 + vxi, vxi->vx_id, mask, index);
24463 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24467 + mask = vxi->vx_nsmask[index];
24469 + if ((mask & vxi->vx_nsmask[index]) != mask)
24472 + proxy = vxi->vx_nsproxy[index];
24473 + fs = vxi->vx_fs[index];
24475 + task_lock(current);
24476 + fs_cur = current->fs;
24477 + atomic_inc(&fs_cur->count);
24478 + proxy_cur = current->nsproxy;
24479 + get_nsproxy(proxy_cur);
24480 + task_unlock(current);
24482 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
24483 + if (IS_ERR(fs_new)) {
24484 + ret = PTR_ERR(fs_new);
24488 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24489 + if (IS_ERR(proxy_new)) {
24490 + ret = PTR_ERR(proxy_new);
24494 + fs_new = xchg(¤t->fs, fs_new);
24495 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24499 + put_nsproxy(proxy_new);
24502 + put_fs_struct(fs_new);
24505 + put_nsproxy(proxy_cur);
24507 + put_fs_struct(fs_cur);
24512 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24514 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24515 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
24518 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
24519 + vxi, vxi->vx_id, mask, index);
24522 + mask = default_space_mask.mask;
24524 + if ((mask & space_mask.mask) != mask)
24527 + proxy_vxi = vxi->vx_nsproxy[index];
24528 + fs_vxi = vxi->vx_fs[index];
24530 + task_lock(current);
24531 + fs_cur = current->fs;
24532 + atomic_inc(&fs_cur->count);
24533 + proxy_cur = current->nsproxy;
24534 + get_nsproxy(proxy_cur);
24535 + task_unlock(current);
24537 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
24538 + if (IS_ERR(fs_new)) {
24539 + ret = PTR_ERR(fs_new);
24543 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24544 + if (IS_ERR(proxy_new)) {
24545 + ret = PTR_ERR(proxy_new);
24549 + fs_new = xchg(&vxi->vx_fs[index], fs_new);
24550 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
24551 + vxi->vx_nsmask[index] |= mask;
24555 + put_nsproxy(proxy_new);
24558 + put_fs_struct(fs_new);
24561 + put_nsproxy(proxy_cur);
24563 + put_fs_struct(fs_cur);
24568 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
24570 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24572 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24575 + return vx_enter_space(vxi, vc_data.mask, 0);
24578 +int vc_enter_space(struct vx_info *vxi, void __user *data)
24580 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24582 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24585 + if (vc_data.index >= VX_SPACES)
24588 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
24591 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
24593 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24595 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24598 + return vx_set_space(vxi, vc_data.mask, 0);
24601 +int vc_set_space(struct vx_info *vxi, void __user *data)
24603 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24605 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24608 + if (vc_data.index >= VX_SPACES)
24611 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
24614 +int vc_get_space_mask(void __user *data, int type)
24616 + const struct vcmd_space_mask_v1 *mask;
24619 + mask = &space_mask_v0;
24620 + else if (type == 1)
24621 + mask = &space_mask;
24623 + mask = &default_space_mask;
24625 + vxdprintk(VXD_CBIT(space, 10),
24626 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
24628 + if (copy_to_user(data, mask, sizeof(*mask)))
24633 diff -NurpP --minimal linux-2.6.29/kernel/vserver/switch.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/switch.c
24634 --- linux-2.6.29/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
24635 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/switch.c 2009-03-24 14:59:18.000000000 +0100
24638 + * linux/kernel/vserver/switch.c
24640 + * Virtual Server: Syscall Switch
24642 + * Copyright (C) 2003-2007 Herbert Pötzl
24644 + * V0.01 syscall switch
24645 + * V0.02 added signal to context
24646 + * V0.03 added rlimit functions
24647 + * V0.04 added iattr, task/xid functions
24648 + * V0.05 added debug/history stuff
24649 + * V0.06 added compat32 layer
24650 + * V0.07 vcmd args and perms
24651 + * V0.08 added status commands
24652 + * V0.09 added tag commands
24653 + * V0.10 added oom bias
24654 + * V0.11 added device commands
24658 +#include <linux/vs_context.h>
24659 +#include <linux/vs_network.h>
24660 +#include <linux/vserver/switch.h>
24662 +#include "vci_config.h"
24666 +int vc_get_version(uint32_t id)
24668 + return VCI_VERSION;
24672 +int vc_get_vci(uint32_t id)
24674 + return vci_kernel_config();
24677 +#include <linux/vserver/context_cmd.h>
24678 +#include <linux/vserver/cvirt_cmd.h>
24679 +#include <linux/vserver/cacct_cmd.h>
24680 +#include <linux/vserver/limit_cmd.h>
24681 +#include <linux/vserver/network_cmd.h>
24682 +#include <linux/vserver/sched_cmd.h>
24683 +#include <linux/vserver/debug_cmd.h>
24684 +#include <linux/vserver/inode_cmd.h>
24685 +#include <linux/vserver/dlimit_cmd.h>
24686 +#include <linux/vserver/signal_cmd.h>
24687 +#include <linux/vserver/space_cmd.h>
24688 +#include <linux/vserver/tag_cmd.h>
24689 +#include <linux/vserver/device_cmd.h>
24691 +#include <linux/vserver/inode.h>
24692 +#include <linux/vserver/dlimit.h>
24695 +#ifdef CONFIG_COMPAT
24696 +#define __COMPAT(name, id, data, compat) \
24697 + (compat) ? name ## _x32(id, data) : name(id, data)
24698 +#define __COMPAT_NO_ID(name, data, compat) \
24699 + (compat) ? name ## _x32(data) : name(data)
24701 +#define __COMPAT(name, id, data, compat) \
24703 +#define __COMPAT_NO_ID(name, data, compat) \
24709 +long do_vcmd(uint32_t cmd, uint32_t id,
24710 + struct vx_info *vxi, struct nx_info *nxi,
24711 + void __user *data, int compat)
24715 + case VCMD_get_version:
24716 + return vc_get_version(id);
24717 + case VCMD_get_vci:
24718 + return vc_get_vci(id);
24720 + case VCMD_task_xid:
24721 + return vc_task_xid(id);
24722 + case VCMD_vx_info:
24723 + return vc_vx_info(vxi, data);
24725 + case VCMD_task_nid:
24726 + return vc_task_nid(id);
24727 + case VCMD_nx_info:
24728 + return vc_nx_info(nxi, data);
24730 + case VCMD_task_tag:
24731 + return vc_task_tag(id);
24733 + case VCMD_set_space_v1:
24734 + return vc_set_space_v1(vxi, data);
24735 + /* this is version 2 */
24736 + case VCMD_set_space:
24737 + return vc_set_space(vxi, data);
24739 + case VCMD_get_space_mask_v0:
24740 + return vc_get_space_mask(data, 0);
24741 + /* this is version 1 */
24742 + case VCMD_get_space_mask:
24743 + return vc_get_space_mask(data, 1);
24745 + case VCMD_get_space_default:
24746 + return vc_get_space_mask(data, -1);
24748 +#ifdef CONFIG_IA32_EMULATION
24749 + case VCMD_get_rlimit:
24750 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
24751 + case VCMD_set_rlimit:
24752 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
24754 + case VCMD_get_rlimit:
24755 + return vc_get_rlimit(vxi, data);
24756 + case VCMD_set_rlimit:
24757 + return vc_set_rlimit(vxi, data);
24759 + case VCMD_get_rlimit_mask:
24760 + return vc_get_rlimit_mask(id, data);
24761 + case VCMD_reset_minmax:
24762 + return vc_reset_minmax(vxi, data);
24764 + case VCMD_get_vhi_name:
24765 + return vc_get_vhi_name(vxi, data);
24766 + case VCMD_set_vhi_name:
24767 + return vc_set_vhi_name(vxi, data);
24769 + case VCMD_ctx_stat:
24770 + return vc_ctx_stat(vxi, data);
24771 + case VCMD_virt_stat:
24772 + return vc_virt_stat(vxi, data);
24773 + case VCMD_sock_stat:
24774 + return vc_sock_stat(vxi, data);
24775 + case VCMD_rlimit_stat:
24776 + return vc_rlimit_stat(vxi, data);
24778 + case VCMD_set_cflags:
24779 + return vc_set_cflags(vxi, data);
24780 + case VCMD_get_cflags:
24781 + return vc_get_cflags(vxi, data);
24783 + /* this is version 1 */
24784 + case VCMD_set_ccaps:
24785 + return vc_set_ccaps(vxi, data);
24786 + /* this is version 1 */
24787 + case VCMD_get_ccaps:
24788 + return vc_get_ccaps(vxi, data);
24789 + case VCMD_set_bcaps:
24790 + return vc_set_bcaps(vxi, data);
24791 + case VCMD_get_bcaps:
24792 + return vc_get_bcaps(vxi, data);
24794 + case VCMD_set_badness:
24795 + return vc_set_badness(vxi, data);
24796 + case VCMD_get_badness:
24797 + return vc_get_badness(vxi, data);
24799 + case VCMD_set_nflags:
24800 + return vc_set_nflags(nxi, data);
24801 + case VCMD_get_nflags:
24802 + return vc_get_nflags(nxi, data);
24804 + case VCMD_set_ncaps:
24805 + return vc_set_ncaps(nxi, data);
24806 + case VCMD_get_ncaps:
24807 + return vc_get_ncaps(nxi, data);
24809 + case VCMD_set_sched_v4:
24810 + return vc_set_sched_v4(vxi, data);
24811 + /* this is version 5 */
24812 + case VCMD_set_sched:
24813 + return vc_set_sched(vxi, data);
24814 + case VCMD_get_sched:
24815 + return vc_get_sched(vxi, data);
24816 + case VCMD_sched_info:
24817 + return vc_sched_info(vxi, data);
24819 + case VCMD_add_dlimit:
24820 + return __COMPAT(vc_add_dlimit, id, data, compat);
24821 + case VCMD_rem_dlimit:
24822 + return __COMPAT(vc_rem_dlimit, id, data, compat);
24823 + case VCMD_set_dlimit:
24824 + return __COMPAT(vc_set_dlimit, id, data, compat);
24825 + case VCMD_get_dlimit:
24826 + return __COMPAT(vc_get_dlimit, id, data, compat);
24828 + case VCMD_ctx_kill:
24829 + return vc_ctx_kill(vxi, data);
24831 + case VCMD_wait_exit:
24832 + return vc_wait_exit(vxi, data);
24834 + case VCMD_get_iattr:
24835 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
24836 + case VCMD_set_iattr:
24837 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
24839 + case VCMD_fget_iattr:
24840 + return vc_fget_iattr(id, data);
24841 + case VCMD_fset_iattr:
24842 + return vc_fset_iattr(id, data);
24844 + case VCMD_enter_space_v0:
24845 + return vc_enter_space_v1(vxi, NULL);
24846 + case VCMD_enter_space_v1:
24847 + return vc_enter_space_v1(vxi, data);
24848 + /* this is version 2 */
24849 + case VCMD_enter_space:
24850 + return vc_enter_space(vxi, data);
24852 + case VCMD_ctx_create_v0:
24853 + return vc_ctx_create(id, NULL);
24854 + case VCMD_ctx_create:
24855 + return vc_ctx_create(id, data);
24856 + case VCMD_ctx_migrate_v0:
24857 + return vc_ctx_migrate(vxi, NULL);
24858 + case VCMD_ctx_migrate:
24859 + return vc_ctx_migrate(vxi, data);
24861 + case VCMD_net_create_v0:
24862 + return vc_net_create(id, NULL);
24863 + case VCMD_net_create:
24864 + return vc_net_create(id, data);
24865 + case VCMD_net_migrate:
24866 + return vc_net_migrate(nxi, data);
24868 + case VCMD_tag_migrate:
24869 + return vc_tag_migrate(id);
24871 + case VCMD_net_add:
24872 + return vc_net_add(nxi, data);
24873 + case VCMD_net_remove:
24874 + return vc_net_remove(nxi, data);
24876 + case VCMD_net_add_ipv4:
24877 + return vc_net_add_ipv4(nxi, data);
24878 + case VCMD_net_remove_ipv4:
24879 + return vc_net_remove_ipv4(nxi, data);
24880 +#ifdef CONFIG_IPV6
24881 + case VCMD_net_add_ipv6:
24882 + return vc_net_add_ipv6(nxi, data);
24883 + case VCMD_net_remove_ipv6:
24884 + return vc_net_remove_ipv6(nxi, data);
24886 +/* case VCMD_add_match_ipv4:
24887 + return vc_add_match_ipv4(nxi, data);
24888 + case VCMD_get_match_ipv4:
24889 + return vc_get_match_ipv4(nxi, data);
24890 +#ifdef CONFIG_IPV6
24891 + case VCMD_add_match_ipv6:
24892 + return vc_add_match_ipv6(nxi, data);
24893 + case VCMD_get_match_ipv6:
24894 + return vc_get_match_ipv6(nxi, data);
24897 +#ifdef CONFIG_VSERVER_DEVICE
24898 + case VCMD_set_mapping:
24899 + return __COMPAT(vc_set_mapping, vxi, data, compat);
24900 + case VCMD_unset_mapping:
24901 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
24903 +#ifdef CONFIG_VSERVER_HISTORY
24904 + case VCMD_dump_history:
24905 + return vc_dump_history(id);
24906 + case VCMD_read_history:
24907 + return __COMPAT(vc_read_history, id, data, compat);
24909 +#ifdef CONFIG_VSERVER_MONITOR
24910 + case VCMD_read_monitor:
24911 + return __COMPAT(vc_read_monitor, id, data, compat);
24914 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
24915 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
24921 +#define __VCMD(vcmd, _perm, _args, _flags) \
24922 + case VCMD_ ## vcmd: perm = _perm; \
24923 + args = _args; flags = _flags; break
24926 +#define VCA_NONE 0x00
24927 +#define VCA_VXI 0x01
24928 +#define VCA_NXI 0x02
24930 +#define VCF_NONE 0x00
24931 +#define VCF_INFO 0x01
24932 +#define VCF_ADMIN 0x02
24933 +#define VCF_ARES 0x06 /* includes admin */
24934 +#define VCF_SETUP 0x08
24936 +#define VCF_ZIDOK 0x10 /* zero id okay */
24940 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
24943 + int permit = -1, state = 0;
24944 + int perm = -1, args = 0, flags = 0;
24945 + struct vx_info *vxi = NULL;
24946 + struct nx_info *nxi = NULL;
24949 + /* unpriviledged commands */
24950 + __VCMD(get_version, 0, VCA_NONE, 0);
24951 + __VCMD(get_vci, 0, VCA_NONE, 0);
24952 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
24953 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
24954 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
24955 + __VCMD(get_space_default,0, VCA_NONE, 0);
24957 + /* info commands */
24958 + __VCMD(task_xid, 2, VCA_NONE, 0);
24959 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
24960 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
24961 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
24962 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
24963 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
24964 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
24965 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
24966 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
24968 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
24969 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
24970 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
24971 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
24973 + __VCMD(task_nid, 2, VCA_NONE, 0);
24974 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
24975 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
24976 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
24978 + __VCMD(task_tag, 2, VCA_NONE, 0);
24980 + __VCMD(get_iattr, 2, VCA_NONE, 0);
24981 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
24982 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
24983 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
24984 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
24986 + /* lower admin commands */
24987 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
24988 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
24989 + __VCMD(ctx_create, 5, VCA_NONE, 0);
24990 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
24991 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
24992 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
24993 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
24994 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
24996 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
24997 + __VCMD(net_create, 5, VCA_NONE, 0);
24998 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25000 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25002 + /* higher admin commands */
25003 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25004 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25005 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25007 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25008 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25009 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25010 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25012 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25013 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25014 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25015 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25017 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25018 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25019 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25020 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25021 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25022 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25023 +#ifdef CONFIG_IPV6
25024 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25025 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25027 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25028 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25029 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25030 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25031 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25033 +#ifdef CONFIG_VSERVER_DEVICE
25034 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25035 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25037 + /* debug level admin commands */
25038 +#ifdef CONFIG_VSERVER_HISTORY
25039 + __VCMD(dump_history, 9, VCA_NONE, 0);
25040 + __VCMD(read_history, 9, VCA_NONE, 0);
25042 +#ifdef CONFIG_VSERVER_MONITOR
25043 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25050 + vxdprintk(VXD_CBIT(switch, 0),
25051 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25052 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25053 + VC_VERSION(cmd), id, data, compat,
25054 + perm, args, flags);
25061 + if (!capable(CAP_CONTEXT))
25065 + /* moved here from the individual commands */
25067 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25071 + /* vcmd involves resource management */
25073 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25077 + /* various legacy exceptions */
25079 + /* will go away when spectator is a cap */
25080 + case VCMD_ctx_migrate_v0:
25081 + case VCMD_ctx_migrate:
25083 + current->xid = 1;
25089 + /* will go away when spectator is a cap */
25090 + case VCMD_net_migrate:
25092 + current->nid = 1;
25099 + /* vcmds are fine by default */
25102 + /* admin type vcmds require admin ... */
25103 + if (flags & VCF_ADMIN)
25104 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25106 + /* ... but setup type vcmds override that */
25107 + if (!permit && (flags & VCF_SETUP))
25108 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25116 + if (!id && (flags & VCF_ZIDOK))
25120 + if (args & VCA_VXI) {
25121 + vxi = lookup_vx_info(id);
25125 + if ((flags & VCF_ADMIN) &&
25126 + /* special case kill for shutdown */
25127 + (cmd != VCMD_ctx_kill) &&
25128 + /* can context be administrated? */
25129 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25135 + if (args & VCA_NXI) {
25136 + nxi = lookup_nx_info(id);
25140 + if ((flags & VCF_ADMIN) &&
25141 + /* can context be administrated? */
25142 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25149 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25152 + if ((args & VCA_NXI) && nxi)
25153 + put_nx_info(nxi);
25155 + if ((args & VCA_VXI) && vxi)
25156 + put_vx_info(vxi);
25158 + vxdprintk(VXD_CBIT(switch, 1),
25159 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25160 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25161 + VC_VERSION(cmd), ret, ret, state, permit);
25166 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25168 + return do_vserver(cmd, id, data, 0);
25171 +#ifdef CONFIG_COMPAT
25174 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25176 + return do_vserver(cmd, id, data, 1);
25179 +#endif /* CONFIG_COMPAT */
25180 diff -NurpP --minimal linux-2.6.29/kernel/vserver/sysctl.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/sysctl.c
25181 --- linux-2.6.29/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25182 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/sysctl.c 2009-02-22 22:54:26.000000000 +0100
25185 + * kernel/vserver/sysctl.c
25187 + * Virtual Context Support
25189 + * Copyright (C) 2004-2007 Herbert Pötzl
25191 + * V0.01 basic structure
25195 +#include <linux/module.h>
25196 +#include <linux/ctype.h>
25197 +#include <linux/sysctl.h>
25198 +#include <linux/parser.h>
25199 +#include <asm/uaccess.h>
25203 + CTL_DEBUG_ERROR = 0,
25204 + CTL_DEBUG_SWITCH = 1,
25219 +unsigned int vx_debug_switch = 0;
25220 +unsigned int vx_debug_xid = 0;
25221 +unsigned int vx_debug_nid = 0;
25222 +unsigned int vx_debug_tag = 0;
25223 +unsigned int vx_debug_net = 0;
25224 +unsigned int vx_debug_limit = 0;
25225 +unsigned int vx_debug_cres = 0;
25226 +unsigned int vx_debug_dlim = 0;
25227 +unsigned int vx_debug_quota = 0;
25228 +unsigned int vx_debug_cvirt = 0;
25229 +unsigned int vx_debug_space = 0;
25230 +unsigned int vx_debug_misc = 0;
25233 +static struct ctl_table_header *vserver_table_header;
25234 +static ctl_table vserver_root_table[];
25237 +void vserver_register_sysctl(void)
25239 + if (!vserver_table_header) {
25240 + vserver_table_header = register_sysctl_table(vserver_root_table);
25245 +void vserver_unregister_sysctl(void)
25247 + if (vserver_table_header) {
25248 + unregister_sysctl_table(vserver_table_header);
25249 + vserver_table_header = NULL;
25254 +static int proc_dodebug(ctl_table *table, int write,
25255 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
25257 + char tmpbuf[20], *p, c;
25258 + unsigned int value;
25259 + size_t left, len;
25261 + if ((*ppos && !write) || !*lenp) {
25269 + if (!access_ok(VERIFY_READ, buffer, left))
25271 + p = (char *)buffer;
25272 + while (left && __get_user(c, p) >= 0 && isspace(c))
25277 + if (left > sizeof(tmpbuf) - 1)
25279 + if (copy_from_user(tmpbuf, p, left))
25281 + tmpbuf[left] = '\0';
25283 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25284 + value = 10 * value + (*p - '0');
25285 + if (*p && !isspace(*p))
25287 + while (left && isspace(*p))
25289 + *(unsigned int *)table->data = value;
25291 + if (!access_ok(VERIFY_WRITE, buffer, left))
25293 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25296 + if (__copy_to_user(buffer, tmpbuf, len))
25298 + if ((left -= len) > 0) {
25299 + if (put_user('\n', (char *)buffer + len))
25313 +#define CTL_ENTRY(ctl, name) \
25315 + .ctl_name = ctl, \
25316 + .procname = #name, \
25317 + .data = &vx_ ## name, \
25318 + .maxlen = sizeof(int), \
25320 + .proc_handler = &proc_dodebug, \
25321 + .strategy = &sysctl_intvec, \
25322 + .extra1 = &zero, \
25325 +static ctl_table vserver_debug_table[] = {
25326 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25327 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25328 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25329 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
25330 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
25331 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
25332 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
25333 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
25334 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
25335 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
25336 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
25337 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
25338 + { .ctl_name = 0 }
25341 +static ctl_table vserver_root_table[] = {
25343 + .ctl_name = CTL_VSERVER,
25344 + .procname = "vserver",
25346 + .child = vserver_debug_table
25348 + { .ctl_name = 0 }
25352 +static match_table_t tokens = {
25353 + { CTL_DEBUG_SWITCH, "switch=%x" },
25354 + { CTL_DEBUG_XID, "xid=%x" },
25355 + { CTL_DEBUG_NID, "nid=%x" },
25356 + { CTL_DEBUG_TAG, "tag=%x" },
25357 + { CTL_DEBUG_NET, "net=%x" },
25358 + { CTL_DEBUG_LIMIT, "limit=%x" },
25359 + { CTL_DEBUG_CRES, "cres=%x" },
25360 + { CTL_DEBUG_DLIM, "dlim=%x" },
25361 + { CTL_DEBUG_QUOTA, "quota=%x" },
25362 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
25363 + { CTL_DEBUG_SPACE, "space=%x" },
25364 + { CTL_DEBUG_MISC, "misc=%x" },
25365 + { CTL_DEBUG_ERROR, NULL }
25368 +#define HANDLE_CASE(id, name, val) \
25369 + case CTL_DEBUG_ ## id: \
25370 + vx_debug_ ## name = val; \
25371 + printk("vs_debug_" #name "=0x%x\n", val); \
25375 +static int __init vs_debug_setup(char *str)
25380 + printk("vs_debug_setup(%s)\n", str);
25381 + while ((p = strsep(&str, ",")) != NULL) {
25382 + substring_t args[MAX_OPT_ARGS];
25383 + unsigned int value;
25388 + token = match_token(p, tokens, args);
25389 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25392 + HANDLE_CASE(SWITCH, switch, value);
25393 + HANDLE_CASE(XID, xid, value);
25394 + HANDLE_CASE(NID, nid, value);
25395 + HANDLE_CASE(TAG, tag, value);
25396 + HANDLE_CASE(NET, net, value);
25397 + HANDLE_CASE(LIMIT, limit, value);
25398 + HANDLE_CASE(CRES, cres, value);
25399 + HANDLE_CASE(DLIM, dlim, value);
25400 + HANDLE_CASE(QUOTA, quota, value);
25401 + HANDLE_CASE(CVIRT, cvirt, value);
25402 + HANDLE_CASE(SPACE, space, value);
25403 + HANDLE_CASE(MISC, misc, value);
25412 +__setup("vsdebug=", vs_debug_setup);
25416 +EXPORT_SYMBOL_GPL(vx_debug_switch);
25417 +EXPORT_SYMBOL_GPL(vx_debug_xid);
25418 +EXPORT_SYMBOL_GPL(vx_debug_nid);
25419 +EXPORT_SYMBOL_GPL(vx_debug_net);
25420 +EXPORT_SYMBOL_GPL(vx_debug_limit);
25421 +EXPORT_SYMBOL_GPL(vx_debug_cres);
25422 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
25423 +EXPORT_SYMBOL_GPL(vx_debug_quota);
25424 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
25425 +EXPORT_SYMBOL_GPL(vx_debug_space);
25426 +EXPORT_SYMBOL_GPL(vx_debug_misc);
25428 diff -NurpP --minimal linux-2.6.29/kernel/vserver/tag.c linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/tag.c
25429 --- linux-2.6.29/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
25430 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/tag.c 2009-02-22 22:54:26.000000000 +0100
25433 + * linux/kernel/vserver/tag.c
25435 + * Virtual Server: Shallow Tag Space
25437 + * Copyright (C) 2007 Herbert Pötzl
25439 + * V0.01 basic implementation
25443 +#include <linux/sched.h>
25444 +#include <linux/vserver/debug.h>
25445 +#include <linux/vs_pid.h>
25446 +#include <linux/vs_tag.h>
25448 +#include <linux/vserver/tag_cmd.h>
25451 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25456 + vxdprintk(VXD_CBIT(tag, 5),
25457 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25463 + vxdprintk(VXD_CBIT(tag, 5),
25464 + "moved task %p into [#%d]", p, tag);
25468 +/* vserver syscall commands below here */
25470 +/* taks xid and vx_info functions */
25473 +int vc_task_tag(uint32_t id)
25478 + struct task_struct *tsk;
25479 + read_lock(&tasklist_lock);
25480 + tsk = find_task_by_real_pid(id);
25481 + tag = (tsk) ? tsk->tag : -ESRCH;
25482 + read_unlock(&tasklist_lock);
25484 + tag = dx_current_tag();
25489 +int vc_tag_migrate(uint32_t tag)
25491 + return dx_migrate_task(current, tag & 0xFFFF);
25495 diff -NurpP --minimal linux-2.6.29/kernel/vserver/vci_config.h linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/vci_config.h
25496 --- linux-2.6.29/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
25497 +++ linux-2.6.29-vs2.3.0.36.9-pre2/kernel/vserver/vci_config.h 2009-02-22 22:54:26.000000000 +0100
25500 +/* interface version */
25502 +#define VCI_VERSION 0x00020304
25506 + VCI_KCBIT_NO_DYNAMIC = 0,
25508 + VCI_KCBIT_PROC_SECURE = 4,
25509 + VCI_KCBIT_HARDCPU = 5,
25510 + VCI_KCBIT_IDLELIMIT = 6,
25511 + VCI_KCBIT_IDLETIME = 7,
25513 + VCI_KCBIT_COWBL = 8,
25514 + VCI_KCBIT_FULLCOWBL = 9,
25515 + VCI_KCBIT_SPACES = 10,
25516 + VCI_KCBIT_NETV2 = 11,
25518 + VCI_KCBIT_DEBUG = 16,
25519 + VCI_KCBIT_HISTORY = 20,
25520 + VCI_KCBIT_TAGGED = 24,
25521 + VCI_KCBIT_PPTAG = 28,
25523 + VCI_KCBIT_MORE = 31,
25527 +static inline uint32_t vci_kernel_config(void)
25530 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25532 + /* configured features */
25533 +#ifdef CONFIG_VSERVER_PROC_SECURE
25534 + (1 << VCI_KCBIT_PROC_SECURE) |
25536 +#ifdef CONFIG_VSERVER_HARDCPU
25537 + (1 << VCI_KCBIT_HARDCPU) |
25539 +#ifdef CONFIG_VSERVER_IDLELIMIT
25540 + (1 << VCI_KCBIT_IDLELIMIT) |
25542 +#ifdef CONFIG_VSERVER_IDLETIME
25543 + (1 << VCI_KCBIT_IDLETIME) |
25545 +#ifdef CONFIG_VSERVER_COWBL
25546 + (1 << VCI_KCBIT_COWBL) |
25547 + (1 << VCI_KCBIT_FULLCOWBL) |
25549 + (1 << VCI_KCBIT_SPACES) |
25550 + (1 << VCI_KCBIT_NETV2) |
25552 + /* debug options */
25553 +#ifdef CONFIG_VSERVER_DEBUG
25554 + (1 << VCI_KCBIT_DEBUG) |
25556 +#ifdef CONFIG_VSERVER_HISTORY
25557 + (1 << VCI_KCBIT_HISTORY) |
25560 + /* inode context tagging */
25561 +#if defined(CONFIG_TAGGING_NONE)
25562 + (0 << VCI_KCBIT_TAGGED) |
25563 +#elif defined(CONFIG_TAGGING_UID16)
25564 + (1 << VCI_KCBIT_TAGGED) |
25565 +#elif defined(CONFIG_TAGGING_GID16)
25566 + (2 << VCI_KCBIT_TAGGED) |
25567 +#elif defined(CONFIG_TAGGING_ID24)
25568 + (3 << VCI_KCBIT_TAGGED) |
25569 +#elif defined(CONFIG_TAGGING_INTERN)
25570 + (4 << VCI_KCBIT_TAGGED) |
25571 +#elif defined(CONFIG_TAGGING_RUNTIME)
25572 + (5 << VCI_KCBIT_TAGGED) |
25574 + (7 << VCI_KCBIT_TAGGED) |
25576 + (1 << VCI_KCBIT_PPTAG) |
25580 diff -NurpP --minimal linux-2.6.29/mm/filemap_xip.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/filemap_xip.c
25581 --- linux-2.6.29/mm/filemap_xip.c 2009-03-24 14:22:45.000000000 +0100
25582 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/filemap_xip.c 2009-03-24 14:48:36.000000000 +0100
25584 #include <linux/sched.h>
25585 #include <linux/seqlock.h>
25586 #include <linux/mutex.h>
25587 +#include <linux/vs_memory.h>
25588 #include <asm/tlbflush.h>
25589 #include <asm/io.h>
25591 diff -NurpP --minimal linux-2.6.29/mm/fremap.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/fremap.c
25592 --- linux-2.6.29/mm/fremap.c 2009-03-24 14:22:45.000000000 +0100
25593 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/fremap.c 2009-03-24 14:48:36.000000000 +0100
25595 #include <linux/module.h>
25596 #include <linux/syscalls.h>
25597 #include <linux/mmu_notifier.h>
25598 +#include <linux/vs_memory.h>
25600 #include <asm/mmu_context.h>
25601 #include <asm/cacheflush.h>
25602 diff -NurpP --minimal linux-2.6.29/mm/hugetlb.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/hugetlb.c
25603 --- linux-2.6.29/mm/hugetlb.c 2009-03-24 14:22:45.000000000 +0100
25604 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/hugetlb.c 2009-03-24 14:48:36.000000000 +0100
25606 #include <asm/io.h>
25608 #include <linux/hugetlb.h>
25609 +#include <linux/vs_memory.h>
25610 #include "internal.h"
25612 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
25613 diff -NurpP --minimal linux-2.6.29/mm/memory.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/memory.c
25614 --- linux-2.6.29/mm/memory.c 2009-03-24 14:22:45.000000000 +0100
25615 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/memory.c 2009-03-24 14:48:36.000000000 +0100
25616 @@ -612,6 +612,9 @@ static int copy_pte_range(struct mm_stru
25620 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
25624 rss[1] = rss[0] = 0;
25625 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
25626 @@ -2433,6 +2436,11 @@ static int do_swap_page(struct mm_struct
25627 count_vm_event(PGMAJFAULT);
25630 + if (!vx_rss_avail(mm, 1)) {
25631 + ret = VM_FAULT_OOM;
25635 mark_page_accessed(page);
25638 @@ -2524,6 +2532,8 @@ static int do_anonymous_page(struct mm_s
25639 /* Allocate our own private page. */
25640 pte_unmap(page_table);
25642 + if (!vx_rss_avail(mm, 1))
25644 if (unlikely(anon_vma_prepare(vma)))
25646 page = alloc_zeroed_user_highpage_movable(vma, address);
25647 @@ -2791,6 +2801,7 @@ static inline int handle_pte_fault(struc
25651 + int ret = 0, type = VXPT_UNKNOWN;
25654 if (!pte_present(entry)) {
25655 @@ -2815,9 +2826,12 @@ static inline int handle_pte_fault(struc
25656 if (unlikely(!pte_same(*pte, entry)))
25658 if (write_access) {
25659 - if (!pte_write(entry))
25660 - return do_wp_page(mm, vma, address,
25661 + if (!pte_write(entry)) {
25662 + ret = do_wp_page(mm, vma, address,
25663 pte, pmd, ptl, entry);
25664 + type = VXPT_WRITE;
25667 entry = pte_mkdirty(entry);
25669 entry = pte_mkyoung(entry);
25670 @@ -2835,7 +2849,10 @@ static inline int handle_pte_fault(struc
25673 pte_unmap_unlock(pte, ptl);
25677 + vx_page_fault(mm, vma, type, ret);
25682 diff -NurpP --minimal linux-2.6.29/mm/mlock.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/mlock.c
25683 --- linux-2.6.29/mm/mlock.c 2009-03-24 14:22:45.000000000 +0100
25684 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/mlock.c 2009-03-28 05:08:26.000000000 +0100
25686 #include <linux/rmap.h>
25687 #include <linux/mmzone.h>
25688 #include <linux/hugetlb.h>
25689 +#include <linux/vs_memory.h>
25691 #include "internal.h"
25693 @@ -415,7 +416,7 @@ success:
25694 nr_pages = (end - start) >> PAGE_SHIFT;
25696 nr_pages = -nr_pages;
25697 - mm->locked_vm += nr_pages;
25698 + vx_vmlocked_add(mm, nr_pages);
25701 * vm_flags is protected by the mmap_sem held in write mode.
25702 @@ -492,7 +493,7 @@ static int do_mlock(unsigned long start,
25704 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
25706 - unsigned long locked;
25707 + unsigned long locked, grow;
25708 unsigned long lock_limit;
25709 int error = -ENOMEM;
25711 @@ -505,8 +506,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
25712 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
25713 start &= PAGE_MASK;
25715 - locked = len >> PAGE_SHIFT;
25716 - locked += current->mm->locked_vm;
25717 + grow = len >> PAGE_SHIFT;
25718 + if (!vx_vmlocked_avail(current->mm, grow))
25720 + locked = current->mm->locked_vm + grow;
25722 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
25723 lock_limit >>= PAGE_SHIFT;
25724 @@ -514,6 +517,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
25725 /* check against resource limits */
25726 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
25727 error = do_mlock(start, len, 1);
25729 up_write(¤t->mm->mmap_sem);
25732 @@ -575,6 +579,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
25733 lock_limit >>= PAGE_SHIFT;
25736 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
25738 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
25739 capable(CAP_IPC_LOCK))
25740 ret = do_mlockall(flags);
25741 @@ -652,8 +658,10 @@ void *alloc_locked_buffer(size_t size)
25745 - current->mm->total_vm += pgsz;
25746 - current->mm->locked_vm += pgsz;
25747 + // current->mm->total_vm += pgsz;
25748 + vx_vmpages_add(current->mm, pgsz);
25749 + // current->mm->locked_vm += pgsz;
25750 + vx_vmlocked_add(current->mm, pgsz);
25753 up_write(¤t->mm->mmap_sem);
25754 @@ -666,8 +674,10 @@ void release_locked_buffer(void *buffer,
25756 down_write(¤t->mm->mmap_sem);
25758 - current->mm->total_vm -= pgsz;
25759 - current->mm->locked_vm -= pgsz;
25760 + // current->mm->total_vm -= pgsz;
25761 + vx_vmpages_sub(current->mm, pgsz);
25762 + // current->mm->locked_vm -= pgsz;
25763 + vx_vmlocked_sub(current->mm, pgsz);
25765 up_write(¤t->mm->mmap_sem);
25767 diff -NurpP --minimal linux-2.6.29/mm/mmap.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/mmap.c
25768 --- linux-2.6.29/mm/mmap.c 2009-03-24 14:22:45.000000000 +0100
25769 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/mmap.c 2009-03-24 14:48:36.000000000 +0100
25770 @@ -1219,7 +1219,8 @@ munmap_back:
25771 if (correct_wcount)
25772 atomic_inc(&inode->i_writecount);
25774 - mm->total_vm += len >> PAGE_SHIFT;
25775 + // mm->total_vm += len >> PAGE_SHIFT;
25776 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25777 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
25778 if (vm_flags & VM_LOCKED) {
25780 @@ -1228,7 +1229,8 @@ out:
25781 long nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
25783 return nr_pages; /* vma gone! */
25784 - mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
25785 + // mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
25786 + vx_vmlocked_add(mm, (len >> PAGE_SHIFT) - nr_pages);
25787 } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
25788 make_pages_present(addr, addr + len);
25790 @@ -1575,9 +1577,9 @@ static int acct_stack_growth(struct vm_a
25793 /* Ok, everything looks good - let it rip */
25794 - mm->total_vm += grow;
25795 + vx_vmpages_add(mm, grow);
25796 if (vma->vm_flags & VM_LOCKED)
25797 - mm->locked_vm += grow;
25798 + vx_vmlocked_add(mm, grow);
25799 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
25802 @@ -1752,7 +1754,8 @@ static void remove_vma_list(struct mm_st
25804 long nrpages = vma_pages(vma);
25806 - mm->total_vm -= nrpages;
25807 + // mm->total_vm -= nrpages;
25808 + vx_vmpages_sub(mm, nrpages);
25809 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
25810 vma = remove_vma(vma);
25812 @@ -1924,7 +1927,8 @@ int do_munmap(struct mm_struct *mm, unsi
25813 struct vm_area_struct *tmp = vma;
25814 while (tmp && tmp->vm_start < end) {
25815 if (tmp->vm_flags & VM_LOCKED) {
25816 - mm->locked_vm -= vma_pages(tmp);
25817 + // mm->locked_vm -= vma_pages(tmp);
25818 + vx_vmlocked_sub(mm, vma_pages(tmp));
25819 munlock_vma_pages_all(tmp);
25821 tmp = tmp->vm_next;
25822 @@ -2013,6 +2017,8 @@ unsigned long do_brk(unsigned long addr,
25823 lock_limit >>= PAGE_SHIFT;
25824 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
25826 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
25831 @@ -2039,7 +2045,8 @@ unsigned long do_brk(unsigned long addr,
25832 if (mm->map_count > sysctl_max_map_count)
25835 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
25836 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
25837 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
25840 /* Can we just expand an old private anonymous mapping? */
25841 @@ -2065,10 +2072,13 @@ unsigned long do_brk(unsigned long addr,
25842 vma->vm_page_prot = vm_get_page_prot(flags);
25843 vma_link(mm, vma, prev, rb_link, rb_parent);
25845 - mm->total_vm += len >> PAGE_SHIFT;
25846 + // mm->total_vm += len >> PAGE_SHIFT;
25847 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25849 if (flags & VM_LOCKED) {
25850 if (!mlock_vma_pages_range(vma, addr, addr + len))
25851 - mm->locked_vm += (len >> PAGE_SHIFT);
25852 + // mm->locked_vm += (len >> PAGE_SHIFT);
25853 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
25857 @@ -2111,6 +2121,11 @@ void exit_mmap(struct mm_struct *mm)
25858 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
25859 tlb_finish_mmu(tlb, 0, end);
25861 + set_mm_counter(mm, file_rss, 0);
25862 + set_mm_counter(mm, anon_rss, 0);
25863 + vx_vmpages_sub(mm, mm->total_vm);
25864 + vx_vmlocked_sub(mm, mm->locked_vm);
25867 * Walk the list again, actually closing and freeing it,
25868 * with preemption enabled, without holding any MM locks.
25869 @@ -2150,7 +2165,8 @@ int insert_vm_struct(struct mm_struct *
25870 if (__vma && __vma->vm_start < vma->vm_end)
25872 if ((vma->vm_flags & VM_ACCOUNT) &&
25873 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
25874 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
25875 + !vx_vmpages_avail(mm, vma_pages(vma))))
25877 vma_link(mm, vma, prev, rb_link, rb_parent);
25879 @@ -2226,6 +2242,8 @@ int may_expand_vm(struct mm_struct *mm,
25881 if (cur + npages > lim)
25883 + if (!vx_vmpages_avail(mm, npages))
25888 @@ -2303,8 +2321,7 @@ int install_special_mapping(struct mm_st
25892 - mm->total_vm += len >> PAGE_SHIFT;
25894 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25898 diff -NurpP --minimal linux-2.6.29/mm/mremap.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/mremap.c
25899 --- linux-2.6.29/mm/mremap.c 2009-03-24 14:22:45.000000000 +0100
25900 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/mremap.c 2009-03-24 14:48:36.000000000 +0100
25902 #include <linux/security.h>
25903 #include <linux/syscalls.h>
25904 #include <linux/mmu_notifier.h>
25905 +#include <linux/vs_memory.h>
25907 #include <asm/uaccess.h>
25908 #include <asm/cacheflush.h>
25909 @@ -220,7 +221,7 @@ static unsigned long move_vma(struct vm_
25910 * If this were a serious issue, we'd add a flag to do_munmap().
25912 hiwater_vm = mm->hiwater_vm;
25913 - mm->total_vm += new_len >> PAGE_SHIFT;
25914 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
25915 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
25917 if (do_munmap(mm, old_addr, old_len) < 0) {
25918 @@ -238,7 +239,7 @@ static unsigned long move_vma(struct vm_
25921 if (vm_flags & VM_LOCKED) {
25922 - mm->locked_vm += new_len >> PAGE_SHIFT;
25923 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
25924 if (new_len > old_len)
25925 mlock_vma_pages_range(new_vma, new_addr + old_len,
25926 new_addr + new_len);
25927 @@ -349,6 +350,9 @@ unsigned long do_mremap(unsigned long ad
25929 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
25931 + if (!vx_vmlocked_avail(current->mm,
25932 + (new_len - old_len) >> PAGE_SHIFT))
25935 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
25937 @@ -377,10 +381,12 @@ unsigned long do_mremap(unsigned long ad
25938 vma_adjust(vma, vma->vm_start,
25939 addr + new_len, vma->vm_pgoff, NULL);
25941 - mm->total_vm += pages;
25942 + // mm->total_vm += pages;
25943 + vx_vmpages_add(mm, pages);
25944 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
25945 if (vma->vm_flags & VM_LOCKED) {
25946 - mm->locked_vm += pages;
25947 + // mm->locked_vm += pages;
25948 + vx_vmlocked_add(mm, pages);
25949 mlock_vma_pages_range(vma, addr + old_len,
25952 diff -NurpP --minimal linux-2.6.29/mm/nommu.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/nommu.c
25953 --- linux-2.6.29/mm/nommu.c 2009-03-24 14:22:45.000000000 +0100
25954 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/nommu.c 2009-03-24 18:25:55.000000000 +0100
25955 @@ -1348,7 +1348,7 @@ unsigned long do_mmap_pgoff(struct file
25956 /* okay... we have a mapping; now we have to register it */
25957 result = vma->vm_start;
25959 - current->mm->total_vm += len >> PAGE_SHIFT;
25960 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
25963 add_vma_to_mm(current->mm, vma);
25964 @@ -1614,7 +1614,7 @@ void exit_mmap(struct mm_struct *mm)
25968 - mm->total_vm = 0;
25969 + vx_vmpages_sub(mm, mm->total_vm);
25971 while ((vma = mm->mmap)) {
25972 mm->mmap = vma->vm_next;
25973 diff -NurpP --minimal linux-2.6.29/mm/oom_kill.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/oom_kill.c
25974 --- linux-2.6.29/mm/oom_kill.c 2009-03-24 14:22:45.000000000 +0100
25975 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/oom_kill.c 2009-03-24 14:48:36.000000000 +0100
25977 #include <linux/notifier.h>
25978 #include <linux/memcontrol.h>
25979 #include <linux/security.h>
25980 +#include <linux/vs_memory.h>
25982 int sysctl_panic_on_oom;
25983 int sysctl_oom_kill_allocating_task;
25984 @@ -72,6 +73,12 @@ unsigned long badness(struct task_struct
25985 points = mm->total_vm;
25988 + * add points for context badness
25991 + points += vx_badness(p, mm);
25994 * After this unlock we can no longer dereference local variable `mm'
25997 @@ -162,8 +169,8 @@ unsigned long badness(struct task_struct
26001 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26002 - p->pid, p->comm, points);
26003 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26004 + task_pid_nr(p), p->xid, p->comm, points);
26008 @@ -326,8 +333,8 @@ static void __oom_kill_task(struct task_
26012 - printk(KERN_ERR "Killed process %d (%s)\n",
26013 - task_pid_nr(p), p->comm);
26014 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
26015 + task_pid_nr(p), p->xid, p->comm);
26018 * We give our sacrificial lamb high priority and access to
26019 @@ -410,8 +417,8 @@ static int oom_kill_process(struct task_
26023 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26024 - message, task_pid_nr(p), p->comm, points);
26025 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
26026 + message, task_pid_nr(p), p->xid, p->comm, points);
26028 /* Try to kill a child first */
26029 list_for_each_entry(c, &p->children, sibling) {
26030 diff -NurpP --minimal linux-2.6.29/mm/page_alloc.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/page_alloc.c
26031 --- linux-2.6.29/mm/page_alloc.c 2009-03-24 14:22:45.000000000 +0100
26032 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/page_alloc.c 2009-03-24 14:48:36.000000000 +0100
26034 #include <linux/page-isolation.h>
26035 #include <linux/page_cgroup.h>
26036 #include <linux/debugobjects.h>
26037 +#include <linux/vs_base.h>
26038 +#include <linux/vs_limit.h>
26040 #include <asm/tlbflush.h>
26041 #include <asm/div64.h>
26042 @@ -1839,6 +1841,9 @@ void si_meminfo(struct sysinfo *val)
26043 val->totalhigh = totalhigh_pages;
26044 val->freehigh = nr_free_highpages();
26045 val->mem_unit = PAGE_SIZE;
26047 + if (vx_flags(VXF_VIRT_MEM, 0))
26048 + vx_vsi_meminfo(val);
26051 EXPORT_SYMBOL(si_meminfo);
26052 @@ -1859,6 +1864,9 @@ void si_meminfo_node(struct sysinfo *val
26055 val->mem_unit = PAGE_SIZE;
26057 + if (vx_flags(VXF_VIRT_MEM, 0))
26058 + vx_vsi_meminfo(val);
26062 diff -NurpP --minimal linux-2.6.29/mm/rmap.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/rmap.c
26063 --- linux-2.6.29/mm/rmap.c 2009-03-24 14:22:45.000000000 +0100
26064 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/rmap.c 2009-03-24 18:26:27.000000000 +0100
26066 #include <linux/memcontrol.h>
26067 #include <linux/mmu_notifier.h>
26068 #include <linux/migrate.h>
26069 +#include <linux/vs_memory.h>
26071 #include <asm/tlbflush.h>
26073 diff -NurpP --minimal linux-2.6.29/mm/shmem.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/shmem.c
26074 --- linux-2.6.29/mm/shmem.c 2009-03-24 14:22:45.000000000 +0100
26075 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/shmem.c 2009-03-24 14:48:36.000000000 +0100
26076 @@ -1757,7 +1757,7 @@ static int shmem_statfs(struct dentry *d
26078 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26080 - buf->f_type = TMPFS_MAGIC;
26081 + buf->f_type = TMPFS_SUPER_MAGIC;
26082 buf->f_bsize = PAGE_CACHE_SIZE;
26083 buf->f_namelen = NAME_MAX;
26084 spin_lock(&sbinfo->stat_lock);
26085 @@ -2326,7 +2326,7 @@ static int shmem_fill_super(struct super
26086 sb->s_maxbytes = SHMEM_MAX_BYTES;
26087 sb->s_blocksize = PAGE_CACHE_SIZE;
26088 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26089 - sb->s_magic = TMPFS_MAGIC;
26090 + sb->s_magic = TMPFS_SUPER_MAGIC;
26091 sb->s_op = &shmem_ops;
26092 sb->s_time_gran = 1;
26093 #ifdef CONFIG_TMPFS_POSIX_ACL
26094 diff -NurpP --minimal linux-2.6.29/mm/slab.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/slab.c
26095 --- linux-2.6.29/mm/slab.c 2009-03-24 14:22:45.000000000 +0100
26096 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/slab.c 2009-03-24 14:48:36.000000000 +0100
26097 @@ -509,6 +509,8 @@ struct kmem_cache {
26098 #define STATS_INC_FREEMISS(x) do { } while (0)
26101 +#include "slab_vs.h"
26106 @@ -3275,6 +3277,7 @@ retry:
26108 obj = slab_get_obj(cachep, slabp, nodeid);
26109 check_slabp(cachep, slabp);
26110 + vx_slab_alloc(cachep, flags);
26111 l3->free_objects--;
26112 /* move slabp to correct slabp list: */
26113 list_del(&slabp->list);
26114 @@ -3347,6 +3350,7 @@ __cache_alloc_node(struct kmem_cache *ca
26115 /* ___cache_alloc_node can fall back to other nodes */
26116 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26118 + vx_slab_alloc(cachep, flags);
26119 local_irq_restore(save_flags);
26120 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26122 @@ -3518,6 +3522,7 @@ static inline void __cache_free(struct k
26125 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26126 + vx_slab_free(cachep);
26129 * Skip calling cache_free_alien() when the platform is not numa.
26130 diff -NurpP --minimal linux-2.6.29/mm/slab_vs.h linux-2.6.29-vs2.3.0.36.9-pre2/mm/slab_vs.h
26131 --- linux-2.6.29/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26132 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/slab_vs.h 2009-02-22 22:54:26.000000000 +0100
26135 +#include <linux/vserver/context.h>
26137 +#include <linux/vs_context.h>
26140 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26142 + int what = gfp_zone(cachep->gfpflags);
26144 + if (!current->vx_info)
26147 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26151 +void vx_slab_free(struct kmem_cache *cachep)
26153 + int what = gfp_zone(cachep->gfpflags);
26155 + if (!current->vx_info)
26158 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26161 diff -NurpP --minimal linux-2.6.29/mm/swapfile.c linux-2.6.29-vs2.3.0.36.9-pre2/mm/swapfile.c
26162 --- linux-2.6.29/mm/swapfile.c 2009-03-24 14:22:45.000000000 +0100
26163 +++ linux-2.6.29-vs2.3.0.36.9-pre2/mm/swapfile.c 2009-03-24 18:27:15.000000000 +0100
26165 #include <asm/tlbflush.h>
26166 #include <linux/swapops.h>
26167 #include <linux/page_cgroup.h>
26168 +#include <linux/vs_base.h>
26169 +#include <linux/vs_memory.h>
26171 static DEFINE_SPINLOCK(swap_lock);
26172 static unsigned int nr_swapfiles;
26173 @@ -1935,6 +1937,8 @@ void si_swapinfo(struct sysinfo *val)
26174 val->freeswap = nr_swap_pages + nr_to_be_unused;
26175 val->totalswap = total_swap_pages + nr_to_be_unused;
26176 spin_unlock(&swap_lock);
26177 + if (vx_flags(VXF_VIRT_MEM, 0))
26178 + vx_vsi_swapinfo(val);
26182 diff -NurpP --minimal linux-2.6.29/net/core/dev.c linux-2.6.29-vs2.3.0.36.9-pre2/net/core/dev.c
26183 --- linux-2.6.29/net/core/dev.c 2009-03-24 14:22:46.000000000 +0100
26184 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/core/dev.c 2009-03-24 18:28:15.000000000 +0100
26185 @@ -126,6 +126,7 @@
26186 #include <linux/in.h>
26187 #include <linux/jhash.h>
26188 #include <linux/random.h>
26189 +#include <linux/vs_inet.h>
26191 #include "net-sysfs.h"
26193 @@ -2856,6 +2857,8 @@ static int dev_ifconf(struct net *net, c
26196 for_each_netdev(net, dev) {
26197 + if (!nx_dev_visible(current->nx_info, dev))
26199 for (i = 0; i < NPROTO; i++) {
26200 if (gifconf_list[i]) {
26202 @@ -2924,6 +2927,9 @@ static void dev_seq_printf_stats(struct
26204 const struct net_device_stats *stats = dev_get_stats(dev);
26206 + if (!nx_dev_visible(current->nx_info, dev))
26209 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26210 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26211 dev->name, stats->rx_bytes, stats->rx_packets,
26212 @@ -4865,6 +4871,15 @@ int dev_change_net_namespace(struct net_
26216 +#ifdef CONFIG_SYSFS
26217 + /* Don't allow real devices to be moved when sysfs
26221 + if (dev->dev.parent)
26225 /* Ensure the device has been registrered */
26227 if (dev->reg_state != NETREG_REGISTERED)
26228 @@ -4924,6 +4939,8 @@ int dev_change_net_namespace(struct net_
26230 netdev_unregister_kobject(dev);
26232 + netdev_unregister_kobject(dev);
26234 /* Actually switch the network namespace */
26235 dev_net_set(dev, net);
26237 diff -NurpP --minimal linux-2.6.29/net/core/net-sysfs.c linux-2.6.29-vs2.3.0.36.9-pre2/net/core/net-sysfs.c
26238 --- linux-2.6.29/net/core/net-sysfs.c 2009-03-24 14:22:46.000000000 +0100
26239 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/core/net-sysfs.c 2009-03-24 18:30:01.000000000 +0100
26240 @@ -512,6 +512,9 @@ int netdev_register_kobject(struct net_d
26241 if (dev_net(net) != &init_net)
26244 + if (dev_net(net) != &init_net)
26247 return device_add(dev);
26250 diff -NurpP --minimal linux-2.6.29/net/core/rtnetlink.c linux-2.6.29-vs2.3.0.36.9-pre2/net/core/rtnetlink.c
26251 --- linux-2.6.29/net/core/rtnetlink.c 2009-03-24 14:22:46.000000000 +0100
26252 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/core/rtnetlink.c 2009-03-24 14:48:36.000000000 +0100
26253 @@ -690,6 +690,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26256 for_each_netdev(net, dev) {
26257 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26261 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26262 @@ -1235,6 +1237,9 @@ void rtmsg_ifinfo(int type, struct net_d
26263 struct sk_buff *skb;
26264 int err = -ENOBUFS;
26266 + if (!nx_dev_visible(current->nx_info, dev))
26269 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26272 diff -NurpP --minimal linux-2.6.29/net/core/sock.c linux-2.6.29-vs2.3.0.36.9-pre2/net/core/sock.c
26273 --- linux-2.6.29/net/core/sock.c 2009-03-24 14:22:46.000000000 +0100
26274 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/core/sock.c 2009-03-24 14:48:36.000000000 +0100
26275 @@ -124,6 +124,10 @@
26276 #include <linux/ipsec.h>
26278 #include <linux/filter.h>
26279 +#include <linux/vs_socket.h>
26280 +#include <linux/vs_limit.h>
26281 +#include <linux/vs_context.h>
26282 +#include <linux/vs_network.h>
26285 #include <net/tcp.h>
26286 @@ -900,6 +904,8 @@ static struct sock *sk_prot_alloc(struct
26287 if (!try_module_get(prot->owner))
26290 + sock_vx_init(sk);
26291 + sock_nx_init(sk);
26295 @@ -976,6 +982,11 @@ void sk_free(struct sock *sk)
26296 __func__, atomic_read(&sk->sk_omem_alloc));
26298 put_net(sock_net(sk));
26300 + clr_vx_info(&sk->sk_vx_info);
26302 + clr_nx_info(&sk->sk_nx_info);
26304 sk_prot_free(sk->sk_prot_creator, sk);
26307 @@ -1011,6 +1022,8 @@ struct sock *sk_clone(const struct sock
26310 get_net(sock_net(newsk));
26311 + sock_vx_init(newsk);
26312 + sock_nx_init(newsk);
26313 sk_node_init(&newsk->sk_node);
26314 sock_lock_init(newsk);
26315 bh_lock_sock(newsk);
26316 @@ -1057,6 +1070,12 @@ struct sock *sk_clone(const struct sock
26317 newsk->sk_priority = 0;
26318 atomic_set(&newsk->sk_refcnt, 2);
26320 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26321 + newsk->sk_xid = sk->sk_xid;
26322 + vx_sock_inc(newsk);
26323 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26324 + newsk->sk_nid = sk->sk_nid;
26327 * Increment the counter in the same struct proto as the master
26328 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26329 @@ -1744,6 +1763,11 @@ void sock_init_data(struct socket *sock,
26331 sk->sk_stamp = ktime_set(-1L, 0);
26333 + set_vx_info(&sk->sk_vx_info, current->vx_info);
26334 + sk->sk_xid = vx_current_xid();
26336 + set_nx_info(&sk->sk_nx_info, current->nx_info);
26337 + sk->sk_nid = nx_current_nid();
26338 atomic_set(&sk->sk_refcnt, 1);
26339 atomic_set(&sk->sk_drops, 0);
26341 diff -NurpP --minimal linux-2.6.29/net/ipv4/af_inet.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/af_inet.c
26342 --- linux-2.6.29/net/ipv4/af_inet.c 2009-03-24 14:22:46.000000000 +0100
26343 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/af_inet.c 2009-03-24 14:48:37.000000000 +0100
26344 @@ -115,6 +115,7 @@
26345 #ifdef CONFIG_IP_MROUTE
26346 #include <linux/mroute.h>
26348 +#include <linux/vs_limit.h>
26350 extern void ip_mc_drop_socket(struct sock *sk);
26352 @@ -325,9 +326,12 @@ lookup_protocol:
26356 + if ((protocol == IPPROTO_ICMP) &&
26357 + nx_capable(answer->capability, NXC_RAW_ICMP))
26359 if (answer->capability > 0 && !capable(answer->capability))
26360 goto out_rcu_unlock;
26363 err = -EAFNOSUPPORT;
26364 if (!inet_netns_ok(net, protocol))
26365 goto out_rcu_unlock;
26366 @@ -445,6 +449,7 @@ int inet_bind(struct socket *sock, struc
26367 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26368 struct sock *sk = sock->sk;
26369 struct inet_sock *inet = inet_sk(sk);
26370 + struct nx_v4_sock_addr nsa;
26371 unsigned short snum;
26374 @@ -458,7 +463,11 @@ int inet_bind(struct socket *sock, struc
26375 if (addr_len < sizeof(struct sockaddr_in))
26378 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26379 + err = v4_map_sock_addr(inet, addr, &nsa);
26383 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26385 /* Not specified by any standard per-se, however it breaks too
26386 * many applications when removed. It is unfortunate since
26387 @@ -470,7 +479,7 @@ int inet_bind(struct socket *sock, struc
26388 err = -EADDRNOTAVAIL;
26389 if (!sysctl_ip_nonlocal_bind &&
26390 !(inet->freebind || inet->transparent) &&
26391 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26392 + nsa.saddr != htonl(INADDR_ANY) &&
26393 chk_addr_ret != RTN_LOCAL &&
26394 chk_addr_ret != RTN_MULTICAST &&
26395 chk_addr_ret != RTN_BROADCAST)
26396 @@ -495,7 +504,7 @@ int inet_bind(struct socket *sock, struc
26397 if (sk->sk_state != TCP_CLOSE || inet->num)
26398 goto out_release_sock;
26400 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26401 + v4_set_sock_addr(inet, &nsa);
26402 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26403 inet->saddr = 0; /* Use device */
26405 @@ -688,11 +697,13 @@ int inet_getname(struct socket *sock, st
26408 sin->sin_port = inet->dport;
26409 - sin->sin_addr.s_addr = inet->daddr;
26410 + sin->sin_addr.s_addr =
26411 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26413 __be32 addr = inet->rcv_saddr;
26415 addr = inet->saddr;
26416 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26417 sin->sin_port = inet->sport;
26418 sin->sin_addr.s_addr = addr;
26420 diff -NurpP --minimal linux-2.6.29/net/ipv4/devinet.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/devinet.c
26421 --- linux-2.6.29/net/ipv4/devinet.c 2009-03-24 14:22:46.000000000 +0100
26422 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/devinet.c 2009-03-24 14:48:37.000000000 +0100
26423 @@ -413,6 +413,7 @@ struct in_device *inetdev_by_index(struc
26428 /* Called only from RTNL semaphored context. No locks. */
26430 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26431 @@ -653,6 +654,8 @@ int devinet_ioctl(struct net *net, unsig
26434 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
26435 + struct nx_info *nxi = current->nx_info;
26437 if (tryaddrmatch) {
26438 /* Matthias Andree */
26439 /* compare label and address (4.4BSD style) */
26440 @@ -661,6 +664,8 @@ int devinet_ioctl(struct net *net, unsig
26441 This is checked above. */
26442 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26443 ifap = &ifa->ifa_next) {
26444 + if (!nx_v4_ifa_visible(nxi, ifa))
26446 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26447 sin_orig.sin_addr.s_addr ==
26448 ifa->ifa_address) {
26449 @@ -673,9 +678,12 @@ int devinet_ioctl(struct net *net, unsig
26450 comparing just the label */
26452 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26453 - ifap = &ifa->ifa_next)
26454 + ifap = &ifa->ifa_next) {
26455 + if (!nx_v4_ifa_visible(nxi, ifa))
26457 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26463 @@ -826,6 +834,8 @@ static int inet_gifconf(struct net_devic
26466 for (; ifa; ifa = ifa->ifa_next) {
26467 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
26470 done += sizeof(ifr);
26472 @@ -1156,6 +1166,7 @@ static int inet_dump_ifaddr(struct sk_bu
26473 struct net_device *dev;
26474 struct in_device *in_dev;
26475 struct in_ifaddr *ifa;
26476 + struct sock *sk = skb->sk;
26477 int s_ip_idx, s_idx = cb->args[0];
26479 s_ip_idx = ip_idx = cb->args[1];
26480 @@ -1170,6 +1181,8 @@ static int inet_dump_ifaddr(struct sk_bu
26482 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26483 ifa = ifa->ifa_next, ip_idx++) {
26484 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
26486 if (ip_idx < s_ip_idx)
26488 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
26489 diff -NurpP --minimal linux-2.6.29/net/ipv4/fib_hash.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/fib_hash.c
26490 --- linux-2.6.29/net/ipv4/fib_hash.c 2009-03-24 14:22:46.000000000 +0100
26491 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/fib_hash.c 2009-03-24 14:48:37.000000000 +0100
26492 @@ -1022,7 +1022,7 @@ static int fib_seq_show(struct seq_file
26493 prefix = f->fn_key;
26494 mask = FZ_MASK(iter->zone);
26495 flags = fib_flag_trans(fa->fa_type, mask, fi);
26497 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
26499 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
26500 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
26501 diff -NurpP --minimal linux-2.6.29/net/ipv4/inet_connection_sock.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/inet_connection_sock.c
26502 --- linux-2.6.29/net/ipv4/inet_connection_sock.c 2009-03-24 14:22:46.000000000 +0100
26503 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/inet_connection_sock.c 2009-03-24 14:48:37.000000000 +0100
26504 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
26506 EXPORT_SYMBOL(inet_get_local_port_range);
26508 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26510 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
26511 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
26513 + if (inet_v6_ipv6only(sk2))
26516 + if (sk1_rcv_saddr &&
26518 + sk1_rcv_saddr == sk2_rcv_saddr)
26521 + if (sk1_rcv_saddr &&
26522 + !sk2_rcv_saddr &&
26523 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26526 + if (sk2_rcv_saddr &&
26527 + !sk1_rcv_saddr &&
26528 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26531 + if (!sk1_rcv_saddr &&
26532 + !sk2_rcv_saddr &&
26533 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26539 int inet_csk_bind_conflict(const struct sock *sk,
26540 const struct inet_bind_bucket *tb)
26542 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
26544 struct hlist_node *node;
26545 int reuse = sk->sk_reuse;
26546 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct
26547 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26548 if (!reuse || !sk2->sk_reuse ||
26549 sk2->sk_state == TCP_LISTEN) {
26550 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26551 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
26552 - sk2_rcv_saddr == sk_rcv_saddr)
26553 + if (ipv4_rcv_saddr_equal(sk, sk2))
26557 diff -NurpP --minimal linux-2.6.29/net/ipv4/inet_diag.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/inet_diag.c
26558 --- linux-2.6.29/net/ipv4/inet_diag.c 2009-03-24 14:22:46.000000000 +0100
26559 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/inet_diag.c 2009-03-24 14:48:37.000000000 +0100
26561 #include <linux/stddef.h>
26563 #include <linux/inet_diag.h>
26564 +#include <linux/vs_network.h>
26565 +#include <linux/vs_inet.h>
26567 static const struct inet_diag_handler **inet_diag_table;
26569 @@ -118,8 +120,8 @@ static int inet_csk_diag_fill(struct soc
26571 r->id.idiag_sport = inet->sport;
26572 r->id.idiag_dport = inet->dport;
26573 - r->id.idiag_src[0] = inet->rcv_saddr;
26574 - r->id.idiag_dst[0] = inet->daddr;
26575 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
26576 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26578 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26579 if (r->idiag_family == AF_INET6) {
26580 @@ -206,8 +208,8 @@ static int inet_twsk_diag_fill(struct in
26581 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
26582 r->id.idiag_sport = tw->tw_sport;
26583 r->id.idiag_dport = tw->tw_dport;
26584 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
26585 - r->id.idiag_dst[0] = tw->tw_daddr;
26586 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
26587 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
26588 r->idiag_state = tw->tw_substate;
26589 r->idiag_timer = 3;
26590 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
26591 @@ -264,6 +266,7 @@ static int inet_diag_get_exact(struct sk
26594 if (req->idiag_family == AF_INET) {
26595 + /* TODO: lback */
26596 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
26597 req->id.idiag_dport, req->id.idiag_src[0],
26598 req->id.idiag_sport, req->id.idiag_if);
26599 @@ -506,6 +509,7 @@ static int inet_csk_diag_dump(struct soc
26603 + /* TODO: lback */
26604 entry.saddr = &inet->rcv_saddr;
26605 entry.daddr = &inet->daddr;
26607 @@ -542,6 +546,7 @@ static int inet_twsk_diag_dump(struct in
26611 + /* TODO: lback */
26612 entry.saddr = &tw->tw_rcv_saddr;
26613 entry.daddr = &tw->tw_daddr;
26615 @@ -588,8 +593,8 @@ static int inet_diag_fill_req(struct sk_
26617 r->id.idiag_sport = inet->sport;
26618 r->id.idiag_dport = ireq->rmt_port;
26619 - r->id.idiag_src[0] = ireq->loc_addr;
26620 - r->id.idiag_dst[0] = ireq->rmt_addr;
26621 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
26622 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
26623 r->idiag_expires = jiffies_to_msecs(tmo);
26624 r->idiag_rqueue = 0;
26625 r->idiag_wqueue = 0;
26626 @@ -659,6 +664,7 @@ static int inet_diag_dump_reqs(struct sk
26630 + /* TODO: lback */
26632 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26633 (entry.family == AF_INET6) ?
26634 @@ -729,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
26635 sk_nulls_for_each(sk, node, &ilb->head) {
26636 struct inet_sock *inet = inet_sk(sk);
26638 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26643 @@ -795,6 +803,8 @@ skip_listen_ht:
26644 sk_nulls_for_each(sk, node, &head->chain) {
26645 struct inet_sock *inet = inet_sk(sk);
26647 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26651 if (!(r->idiag_states & (1 << sk->sk_state)))
26652 @@ -819,6 +829,8 @@ next_normal:
26653 inet_twsk_for_each(tw, node,
26656 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26660 if (r->id.idiag_sport != tw->tw_sport &&
26661 diff -NurpP --minimal linux-2.6.29/net/ipv4/inet_hashtables.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/inet_hashtables.c
26662 --- linux-2.6.29/net/ipv4/inet_hashtables.c 2009-03-24 14:22:46.000000000 +0100
26663 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/inet_hashtables.c 2009-03-24 19:35:10.000000000 +0100
26666 #include <net/inet_connection_sock.h>
26667 #include <net/inet_hashtables.h>
26668 +#include <net/route.h>
26669 #include <net/ip.h>
26672 @@ -142,7 +143,6 @@ static inline int compute_score(struct s
26673 * wildcarded during the search since they can never be otherwise.
26677 struct sock *__inet_lookup_listener(struct net *net,
26678 struct inet_hashinfo *hashinfo,
26679 const __be32 daddr, const unsigned short hnum,
26680 @@ -165,6 +165,7 @@ begin:
26686 * if the nulls value we got at the end of this lookup is
26687 * not the expected one, we must restart lookup.
26688 diff -NurpP --minimal linux-2.6.29/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/netfilter/nf_nat_helper.c
26689 --- linux-2.6.29/net/ipv4/netfilter/nf_nat_helper.c 2008-12-25 00:26:37.000000000 +0100
26690 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/netfilter/nf_nat_helper.c 2009-02-22 22:54:26.000000000 +0100
26692 #include <net/route.h>
26694 #include <linux/netfilter_ipv4.h>
26695 +#include <net/route.h>
26696 #include <net/netfilter/nf_conntrack.h>
26697 #include <net/netfilter/nf_conntrack_helper.h>
26698 #include <net/netfilter/nf_conntrack_ecache.h>
26699 diff -NurpP --minimal linux-2.6.29/net/ipv4/netfilter.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/netfilter.c
26700 --- linux-2.6.29/net/ipv4/netfilter.c 2009-03-24 14:22:46.000000000 +0100
26701 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/netfilter.c 2009-03-24 14:48:37.000000000 +0100
26703 #include <linux/netfilter_ipv4.h>
26704 #include <linux/ip.h>
26705 #include <linux/skbuff.h>
26706 -#include <net/route.h>
26707 +// #include <net/route.h>
26708 #include <net/xfrm.h>
26709 #include <net/ip.h>
26710 #include <net/netfilter/nf_queue.h>
26711 diff -NurpP --minimal linux-2.6.29/net/ipv4/raw.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/raw.c
26712 --- linux-2.6.29/net/ipv4/raw.c 2009-03-24 14:22:46.000000000 +0100
26713 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/raw.c 2009-03-24 14:48:37.000000000 +0100
26714 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
26716 if (net_eq(sock_net(sk), net) && inet->num == num &&
26717 !(inet->daddr && inet->daddr != raddr) &&
26718 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
26719 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
26720 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
26721 goto found; /* gotcha */
26723 @@ -372,6 +372,12 @@ static int raw_send_hdrinc(struct sock *
26724 icmp_out_count(net, ((struct icmphdr *)
26725 skb_transport_header(skb))->type);
26728 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
26729 + sk->sk_nx_info &&
26730 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
26733 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
26736 @@ -383,6 +389,7 @@ out:
26743 IP_INC_STATS(net, IPSTATS_MIB_OUTDISCARDS);
26744 @@ -550,6 +557,13 @@ static int raw_sendmsg(struct kiocb *ioc
26747 security_sk_classify_flow(sk, &fl);
26748 + if (sk->sk_nx_info) {
26749 + err = ip_v4_find_src(sock_net(sk),
26750 + sk->sk_nx_info, &rt, &fl);
26755 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
26758 @@ -619,17 +633,19 @@ static int raw_bind(struct sock *sk, str
26760 struct inet_sock *inet = inet_sk(sk);
26761 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
26762 + struct nx_v4_sock_addr nsa = { 0 };
26766 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
26768 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26769 + v4_map_sock_addr(inet, addr, &nsa);
26770 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26771 ret = -EADDRNOTAVAIL;
26772 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
26773 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
26774 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
26776 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26777 + v4_set_sock_addr(inet, &nsa);
26778 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26779 inet->saddr = 0; /* Use device */
26781 @@ -681,7 +697,8 @@ static int raw_recvmsg(struct kiocb *ioc
26782 /* Copy the address. */
26784 sin->sin_family = AF_INET;
26785 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
26786 + sin->sin_addr.s_addr =
26787 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
26789 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
26791 @@ -858,7 +875,8 @@ static struct sock *raw_get_first(struct
26792 struct hlist_node *node;
26794 sk_for_each(sk, node, &state->h->ht[state->bucket])
26795 - if (sock_net(sk) == seq_file_net(seq))
26796 + if ((sock_net(sk) == seq_file_net(seq)) &&
26797 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26801 @@ -874,7 +892,8 @@ static struct sock *raw_get_next(struct
26805 - } while (sk && sock_net(sk) != seq_file_net(seq));
26806 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
26807 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26809 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
26810 sk = sk_head(&state->h->ht[state->bucket]);
26811 @@ -933,7 +952,10 @@ static void raw_sock_seq_show(struct seq
26813 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
26814 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
26815 - i, src, srcp, dest, destp, sp->sk_state,
26817 + nx_map_sock_lback(current_nx_info(), src), srcp,
26818 + nx_map_sock_lback(current_nx_info(), dest), destp,
26820 atomic_read(&sp->sk_wmem_alloc),
26821 atomic_read(&sp->sk_rmem_alloc),
26822 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
26823 diff -NurpP --minimal linux-2.6.29/net/ipv4/tcp.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/tcp.c
26824 --- linux-2.6.29/net/ipv4/tcp.c 2009-03-24 14:22:46.000000000 +0100
26825 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/tcp.c 2009-03-24 14:48:37.000000000 +0100
26826 @@ -264,6 +264,7 @@
26827 #include <linux/cache.h>
26828 #include <linux/err.h>
26829 #include <linux/crypto.h>
26830 +#include <linux/in.h>
26832 #include <net/icmp.h>
26833 #include <net/tcp.h>
26834 diff -NurpP --minimal linux-2.6.29/net/ipv4/tcp_ipv4.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/tcp_ipv4.c
26835 --- linux-2.6.29/net/ipv4/tcp_ipv4.c 2009-03-24 14:22:46.000000000 +0100
26836 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/tcp_ipv4.c 2009-03-24 19:51:34.000000000 +0100
26837 @@ -1894,6 +1894,12 @@ static void *listening_get_next(struct s
26838 req = req->dl_next;
26841 + vxdprintk(VXD_CBIT(net, 6),
26842 + "sk,req: %p [#%d] (from %d)", req->sk,
26843 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
26845 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
26847 if (req->rsk_ops->family == st->family) {
26850 @@ -1918,6 +1924,10 @@ get_req:
26853 sk_nulls_for_each_from(sk, node) {
26854 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
26855 + sk, sk->sk_nid, nx_current_nid());
26856 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26858 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
26861 @@ -1981,6 +1991,11 @@ static void *established_get_first(struc
26863 spin_lock_bh(lock);
26864 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
26865 + vxdprintk(VXD_CBIT(net, 6),
26866 + "sk,egf: %p [#%d] (from %d)",
26867 + sk, sk->sk_nid, nx_current_nid());
26868 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26870 if (sk->sk_family != st->family ||
26871 !net_eq(sock_net(sk), net)) {
26873 @@ -1991,6 +2006,11 @@ static void *established_get_first(struc
26874 st->state = TCP_SEQ_STATE_TIME_WAIT;
26875 inet_twsk_for_each(tw, node,
26876 &tcp_hashinfo.ehash[st->bucket].twchain) {
26877 + vxdprintk(VXD_CBIT(net, 6),
26878 + "tw: %p [#%d] (from %d)",
26879 + tw, tw->tw_nid, nx_current_nid());
26880 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26882 if (tw->tw_family != st->family ||
26883 !net_eq(twsk_net(tw), net)) {
26885 @@ -2019,7 +2039,9 @@ static void *established_get_next(struct
26889 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
26890 + while (tw && (tw->tw_family != st->family ||
26891 + !net_eq(twsk_net(tw), net) ||
26892 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
26896 @@ -2042,6 +2064,11 @@ get_tw:
26897 sk = sk_nulls_next(sk);
26899 sk_nulls_for_each_from(sk, node) {
26900 + vxdprintk(VXD_CBIT(net, 6),
26901 + "sk,egn: %p [#%d] (from %d)",
26902 + sk, sk->sk_nid, nx_current_nid());
26903 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26905 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
26908 @@ -2193,9 +2220,9 @@ static void get_openreq4(struct sock *sk
26909 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26910 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
26913 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
26914 ntohs(inet_sk(sk)->sport),
26916 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
26917 ntohs(ireq->rmt_port),
26919 0, 0, /* could print option size, but that is af dependent. */
26920 @@ -2238,7 +2265,10 @@ static void get_tcp4_sock(struct sock *s
26922 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
26923 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
26924 - i, src, srcp, dest, destp, sk->sk_state,
26926 + nx_map_sock_lback(current_nx_info(), src), srcp,
26927 + nx_map_sock_lback(current_nx_info(), dest), destp,
26929 tp->write_seq - tp->snd_una,
26930 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
26931 (tp->rcv_nxt - tp->copied_seq),
26932 @@ -2274,7 +2304,10 @@ static void get_timewait4_sock(struct in
26934 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26935 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
26936 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
26938 + nx_map_sock_lback(current_nx_info(), src), srcp,
26939 + nx_map_sock_lback(current_nx_info(), dest), destp,
26940 + tw->tw_substate, 0, 0,
26941 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
26942 atomic_read(&tw->tw_refcnt), tw, len);
26944 diff -NurpP --minimal linux-2.6.29/net/ipv4/tcp_minisocks.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/tcp_minisocks.c
26945 --- linux-2.6.29/net/ipv4/tcp_minisocks.c 2009-03-24 14:22:46.000000000 +0100
26946 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/tcp_minisocks.c 2009-03-24 14:48:37.000000000 +0100
26948 #include <net/inet_common.h>
26949 #include <net/xfrm.h>
26951 +#include <linux/vs_limit.h>
26952 +#include <linux/vs_socket.h>
26953 +#include <linux/vs_context.h>
26955 #ifdef CONFIG_SYSCTL
26956 #define SYNC_INIT 0 /* let the user enable it */
26958 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
26959 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
26960 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
26962 + tw->tw_xid = sk->sk_xid;
26963 + tw->tw_vx_info = NULL;
26964 + tw->tw_nid = sk->sk_nid;
26965 + tw->tw_nx_info = NULL;
26967 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
26968 if (tw->tw_family == PF_INET6) {
26969 struct ipv6_pinfo *np = inet6_sk(sk);
26970 diff -NurpP --minimal linux-2.6.29/net/ipv4/udp.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/udp.c
26971 --- linux-2.6.29/net/ipv4/udp.c 2009-03-24 14:22:46.000000000 +0100
26972 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv4/udp.c 2009-03-25 10:50:13.000000000 +0100
26973 @@ -222,14 +222,7 @@ fail:
26977 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26979 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
26981 - return ( !ipv6_only_sock(sk2) &&
26982 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
26983 - inet1->rcv_saddr == inet2->rcv_saddr ));
26985 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
26987 int udp_v4_get_port(struct sock *sk, unsigned short snum)
26989 @@ -251,6 +244,11 @@ static inline int compute_score(struct s
26990 if (inet->rcv_saddr != daddr)
26994 + /* block non nx_info ips */
26995 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
26996 + daddr, NXA_MASK_BIND))
27000 if (inet->daddr != saddr)
27001 @@ -271,6 +269,7 @@ static inline int compute_score(struct s
27006 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27007 * harder than this. -DaveM
27009 @@ -292,6 +291,11 @@ begin:
27010 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27011 score = compute_score(sk, net, saddr, hnum, sport,
27012 daddr, dport, dif);
27013 + /* FIXME: disabled?
27014 + if (score == 9) {
27018 if (score > badness) {
27021 @@ -305,6 +309,7 @@ begin:
27022 if (get_nulls_value(node) != hash)
27027 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
27029 @@ -314,6 +319,7 @@ begin:
27037 @@ -356,7 +362,7 @@ static inline struct sock *udp_v4_mcast_
27038 s->sk_hash != hnum ||
27039 (inet->daddr && inet->daddr != rmt_addr) ||
27040 (inet->dport != rmt_port && inet->dport) ||
27041 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
27042 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27043 ipv6_only_sock(s) ||
27044 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27046 @@ -694,8 +700,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27047 { .sport = inet->sport,
27048 .dport = dport } } };
27049 struct net *net = sock_net(sk);
27050 + struct nx_info *nxi = sk->sk_nx_info;
27052 security_sk_classify_flow(sk, &fl);
27053 + err = ip_v4_find_src(net, nxi, &rt, &fl);
27057 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27059 if (err == -ENETUNREACH)
27060 @@ -940,7 +951,8 @@ try_again:
27062 sin->sin_family = AF_INET;
27063 sin->sin_port = udp_hdr(skb)->source;
27064 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27065 + sin->sin_addr.s_addr = nx_map_sock_lback(
27066 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27067 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27069 if (inet->cmsg_flags)
27070 @@ -1594,6 +1606,8 @@ static struct sock *udp_get_first(struct
27071 sk_nulls_for_each(sk, node, &hslot->head) {
27072 if (!net_eq(sock_net(sk), net))
27074 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27076 if (sk->sk_family == state->family)
27079 @@ -1611,7 +1625,9 @@ static struct sock *udp_get_next(struct
27082 sk = sk_nulls_next(sk);
27083 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27084 + } while (sk && (!net_eq(sock_net(sk), net) ||
27085 + sk->sk_family != state->family ||
27086 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27089 spin_unlock_bh(&state->udp_table->hash[state->bucket].lock);
27090 @@ -1712,7 +1728,10 @@ static void udp4_format_sock(struct sock
27092 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27093 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27094 - bucket, src, srcp, dest, destp, sp->sk_state,
27096 + nx_map_sock_lback(current_nx_info(), src), srcp,
27097 + nx_map_sock_lback(current_nx_info(), dest), destp,
27099 atomic_read(&sp->sk_wmem_alloc),
27100 atomic_read(&sp->sk_rmem_alloc),
27101 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27102 diff -NurpP --minimal linux-2.6.29/net/ipv6/addrconf.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/addrconf.c
27103 --- linux-2.6.29/net/ipv6/addrconf.c 2009-03-24 14:22:46.000000000 +0100
27104 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/addrconf.c 2009-03-24 20:39:23.000000000 +0100
27107 #include <linux/proc_fs.h>
27108 #include <linux/seq_file.h>
27109 +#include <linux/vs_network.h>
27110 +#include <linux/vs_inet6.h>
27112 /* Set to 3 to get tracing... */
27113 #define ACONF_DEBUG 2
27114 @@ -1111,7 +1113,7 @@ out:
27116 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27117 const struct in6_addr *daddr, unsigned int prefs,
27118 - struct in6_addr *saddr)
27119 + struct in6_addr *saddr, struct nx_info *nxi)
27121 struct ipv6_saddr_score scores[2],
27122 *score = &scores[0], *hiscore = &scores[1];
27123 @@ -1184,6 +1186,8 @@ int ipv6_dev_get_saddr(struct net *net,
27127 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27131 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27132 @@ -1367,35 +1371,46 @@ struct inet6_ifaddr *ipv6_get_ifaddr(str
27136 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
27138 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
27140 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
27141 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
27142 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
27143 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27144 int sk_ipv6only = ipv6_only_sock(sk);
27145 int sk2_ipv6only = inet_v6_ipv6only(sk2);
27146 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
27147 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
27149 - if (!sk2_rcv_saddr && !sk_ipv6only)
27150 + /* FIXME: needs handling for v4 ANY */
27151 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
27154 if (addr_type2 == IPV6_ADDR_ANY &&
27155 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
27156 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
27157 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
27160 if (addr_type == IPV6_ADDR_ANY &&
27161 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27162 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
27163 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
27166 + if (addr_type == IPV6_ADDR_ANY &&
27167 + addr_type2 == IPV6_ADDR_ANY &&
27168 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
27171 if (sk2_rcv_saddr6 &&
27172 + addr_type != IPV6_ADDR_ANY &&
27173 + addr_type != IPV6_ADDR_ANY &&
27174 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
27177 if (addr_type == IPV6_ADDR_MAPPED &&
27179 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
27180 + ipv4_rcv_saddr_equal(sk, sk2))
27184 @@ -2993,7 +3008,10 @@ static void if6_seq_stop(struct seq_file
27185 static int if6_seq_show(struct seq_file *seq, void *v)
27187 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27188 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27190 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27191 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27192 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27194 ifp->idev->dev->ifindex,
27196 @@ -3487,6 +3505,12 @@ static int inet6_dump_addr(struct sk_buf
27197 struct ifmcaddr6 *ifmca;
27198 struct ifacaddr6 *ifaca;
27199 struct net *net = sock_net(skb->sk);
27200 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27202 + /* disable ipv6 on non v6 guests */
27203 + if (nxi && !nx_info_has_v6(nxi))
27207 s_idx = cb->args[0];
27208 s_ip_idx = ip_idx = cb->args[1];
27209 @@ -3508,6 +3532,8 @@ static int inet6_dump_addr(struct sk_buf
27210 ifa = ifa->if_next, ip_idx++) {
27211 if (ip_idx < s_ip_idx)
27213 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27215 err = inet6_fill_ifaddr(skb, ifa,
27216 NETLINK_CB(cb->skb).pid,
27217 cb->nlh->nlmsg_seq,
27218 @@ -3521,6 +3547,8 @@ static int inet6_dump_addr(struct sk_buf
27219 ifmca = ifmca->next, ip_idx++) {
27220 if (ip_idx < s_ip_idx)
27222 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27224 err = inet6_fill_ifmcaddr(skb, ifmca,
27225 NETLINK_CB(cb->skb).pid,
27226 cb->nlh->nlmsg_seq,
27227 @@ -3534,6 +3562,8 @@ static int inet6_dump_addr(struct sk_buf
27228 ifaca = ifaca->aca_next, ip_idx++) {
27229 if (ip_idx < s_ip_idx)
27231 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27233 err = inet6_fill_ifacaddr(skb, ifaca,
27234 NETLINK_CB(cb->skb).pid,
27235 cb->nlh->nlmsg_seq,
27236 @@ -3819,12 +3849,19 @@ static int inet6_dump_ifinfo(struct sk_b
27237 int s_idx = cb->args[0];
27238 struct net_device *dev;
27239 struct inet6_dev *idev;
27240 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27242 + /* FIXME: maybe disable ipv6 on non v6 guests?
27243 + if (skb->sk && skb->sk->sk_vx_info)
27244 + return skb->len; */
27246 read_lock(&dev_base_lock);
27248 for_each_netdev(net, dev) {
27251 + if (!v6_dev_in_nx_info(dev, nxi))
27253 if ((idev = in6_dev_get(dev)) == NULL)
27255 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
27256 diff -NurpP --minimal linux-2.6.29/net/ipv6/af_inet6.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/af_inet6.c
27257 --- linux-2.6.29/net/ipv6/af_inet6.c 2009-03-24 14:22:46.000000000 +0100
27258 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/af_inet6.c 2009-03-24 14:48:37.000000000 +0100
27260 #include <linux/netdevice.h>
27261 #include <linux/icmpv6.h>
27262 #include <linux/netfilter_ipv6.h>
27263 +#include <linux/vs_inet.h>
27264 +#include <linux/vs_inet6.h>
27266 #include <net/ip.h>
27267 #include <net/ipv6.h>
27269 #include <net/tcp.h>
27270 #include <net/ipip.h>
27271 #include <net/protocol.h>
27272 +#include <net/route.h>
27273 #include <net/inet_common.h>
27274 #include <net/route.h>
27275 #include <net/transp_v6.h>
27276 @@ -146,9 +149,12 @@ lookup_protocol:
27280 + if ((protocol == IPPROTO_ICMPV6) &&
27281 + nx_capable(answer->capability, NXC_RAW_ICMP))
27283 if (answer->capability > 0 && !capable(answer->capability))
27284 goto out_rcu_unlock;
27287 sock->ops = answer->ops;
27288 answer_prot = answer->prot;
27289 answer_no_check = answer->no_check;
27290 @@ -247,6 +253,7 @@ int inet6_bind(struct socket *sock, stru
27291 struct inet_sock *inet = inet_sk(sk);
27292 struct ipv6_pinfo *np = inet6_sk(sk);
27293 struct net *net = sock_net(sk);
27294 + struct nx_v6_sock_addr nsa;
27296 unsigned short snum;
27298 @@ -258,6 +265,11 @@ int inet6_bind(struct socket *sock, stru
27300 if (addr_len < SIN6_LEN_RFC2133)
27303 + err = v6_map_sock_addr(inet, addr, &nsa);
27307 addr_type = ipv6_addr_type(&addr->sin6_addr);
27308 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27310 @@ -281,6 +293,10 @@ int inet6_bind(struct socket *sock, stru
27311 err = -EADDRNOTAVAIL;
27314 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27315 + err = -EADDRNOTAVAIL;
27319 if (addr_type != IPV6_ADDR_ANY) {
27320 struct net_device *dev = NULL;
27321 @@ -306,6 +322,11 @@ int inet6_bind(struct socket *sock, stru
27325 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27326 + err = -EADDRNOTAVAIL;
27330 /* ipv4 addr of the socket is invalid. Only the
27331 * unspecified and mapped address have a v4 equivalent.
27333 @@ -324,6 +345,8 @@ int inet6_bind(struct socket *sock, stru
27337 + v6_set_sock_addr(inet, &nsa);
27339 inet->rcv_saddr = v4addr;
27340 inet->saddr = v4addr;
27342 @@ -416,9 +439,11 @@ int inet6_getname(struct socket *sock, s
27344 sin->sin6_port = inet->dport;
27345 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27346 + /* FIXME: remap lback? */
27348 sin->sin6_flowinfo = np->flow_label;
27350 + /* FIXME: remap lback? */
27351 if (ipv6_addr_any(&np->rcv_saddr))
27352 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27354 diff -NurpP --minimal linux-2.6.29/net/ipv6/fib6_rules.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/fib6_rules.c
27355 --- linux-2.6.29/net/ipv6/fib6_rules.c 2008-12-25 00:26:37.000000000 +0100
27356 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/fib6_rules.c 2009-02-22 22:54:26.000000000 +0100
27357 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
27358 if (ipv6_dev_get_saddr(net,
27359 ip6_dst_idev(&rt->u.dst)->dev,
27360 &flp->fl6_dst, srcprefs,
27364 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27366 diff -NurpP --minimal linux-2.6.29/net/ipv6/inet6_hashtables.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/inet6_hashtables.c
27367 --- linux-2.6.29/net/ipv6/inet6_hashtables.c 2009-03-24 14:22:46.000000000 +0100
27368 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/inet6_hashtables.c 2009-03-24 20:50:24.000000000 +0100
27371 #include <linux/module.h>
27372 #include <linux/random.h>
27373 +#include <linux/vs_inet6.h>
27375 #include <net/inet_connection_sock.h>
27376 #include <net/inet_hashtables.h>
27377 @@ -76,7 +77,6 @@ struct sock *__inet6_lookup_established(
27378 unsigned int slot = hash & (hashinfo->ehash_size - 1);
27379 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27384 sk_nulls_for_each_rcu(sk, node, &head->chain) {
27385 @@ -88,7 +88,7 @@ begin:
27393 if (get_nulls_value(node) != slot)
27394 @@ -134,6 +134,9 @@ static int inline compute_score(struct s
27395 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27399 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27402 if (sk->sk_bound_dev_if) {
27403 if (sk->sk_bound_dev_if != dif)
27404 diff -NurpP --minimal linux-2.6.29/net/ipv6/ip6_output.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/ip6_output.c
27405 --- linux-2.6.29/net/ipv6/ip6_output.c 2009-03-24 14:22:47.000000000 +0100
27406 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/ip6_output.c 2009-03-24 14:48:37.000000000 +0100
27407 @@ -951,7 +951,7 @@ static int ip6_dst_lookup_tail(struct so
27408 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27410 sk ? inet6_sk(sk)->srcprefs : 0,
27412 + &fl->fl6_src, sk->sk_nx_info);
27414 goto out_err_release;
27416 diff -NurpP --minimal linux-2.6.29/net/ipv6/Kconfig linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/Kconfig
27417 --- linux-2.6.29/net/ipv6/Kconfig 2008-12-25 00:26:37.000000000 +0100
27418 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/Kconfig 2009-02-22 22:54:26.000000000 +0100
27421 # IPv6 as module will cause a CRASH if you try to unload it
27423 - tristate "The IPv6 protocol"
27425 + bool "The IPv6 protocol"
27428 This is complemental support for the IP version 6.
27429 You will still be able to do traditional IPv4 networking as well.
27430 diff -NurpP --minimal linux-2.6.29/net/ipv6/ndisc.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/ndisc.c
27431 --- linux-2.6.29/net/ipv6/ndisc.c 2009-03-24 14:22:47.000000000 +0100
27432 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/ndisc.c 2009-03-24 14:48:37.000000000 +0100
27433 @@ -589,7 +589,7 @@ static void ndisc_send_na(struct net_dev
27435 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27436 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27438 + &tmpaddr, NULL /* FIXME: ? */ ))
27440 src_addr = &tmpaddr;
27442 diff -NurpP --minimal linux-2.6.29/net/ipv6/raw.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/raw.c
27443 --- linux-2.6.29/net/ipv6/raw.c 2009-03-24 14:22:47.000000000 +0100
27444 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/raw.c 2009-03-24 14:48:37.000000000 +0100
27446 #include <linux/icmpv6.h>
27447 #include <linux/netfilter.h>
27448 #include <linux/netfilter_ipv6.h>
27449 +#include <linux/vs_inet6.h>
27450 #include <linux/skbuff.h>
27451 #include <asm/uaccess.h>
27452 #include <asm/ioctls.h>
27453 @@ -281,6 +282,13 @@ static int rawv6_bind(struct sock *sk, s
27457 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27458 + err = -EADDRNOTAVAIL;
27464 /* ipv4 addr of the socket is invalid. Only the
27465 * unspecified and mapped address have a v4 equivalent.
27467 diff -NurpP --minimal linux-2.6.29/net/ipv6/route.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/route.c
27468 --- linux-2.6.29/net/ipv6/route.c 2009-03-24 14:22:47.000000000 +0100
27469 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/route.c 2009-03-24 14:48:37.000000000 +0100
27470 @@ -2254,7 +2254,8 @@ static int rt6_fill_node(struct net *net
27471 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
27472 struct in6_addr saddr_buf;
27473 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27474 - dst, 0, &saddr_buf) == 0)
27475 + dst, 0, &saddr_buf,
27476 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27477 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27480 diff -NurpP --minimal linux-2.6.29/net/ipv6/tcp_ipv6.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/tcp_ipv6.c
27481 --- linux-2.6.29/net/ipv6/tcp_ipv6.c 2009-03-24 14:22:47.000000000 +0100
27482 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/tcp_ipv6.c 2009-03-24 14:48:37.000000000 +0100
27485 #include <linux/crypto.h>
27486 #include <linux/scatterlist.h>
27487 +#include <linux/vs_inet6.h>
27489 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27490 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27491 @@ -156,8 +157,15 @@ static int tcp_v6_connect(struct sock *s
27492 * connect() to INADDR_ANY means loopback (BSD'ism).
27495 - if(ipv6_addr_any(&usin->sin6_addr))
27496 - usin->sin6_addr.s6_addr[15] = 0x1;
27497 + if(ipv6_addr_any(&usin->sin6_addr)) {
27498 + struct nx_info *nxi = sk->sk_nx_info;
27500 + if (nxi && nx_info_has_v6(nxi))
27501 + /* FIXME: remap lback? */
27502 + usin->sin6_addr = nxi->v6.ip;
27504 + usin->sin6_addr.s6_addr[15] = 0x1;
27507 addr_type = ipv6_addr_type(&usin->sin6_addr);
27509 diff -NurpP --minimal linux-2.6.29/net/ipv6/udp.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/udp.c
27510 --- linux-2.6.29/net/ipv6/udp.c 2009-03-24 14:22:47.000000000 +0100
27511 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/udp.c 2009-03-24 20:56:49.000000000 +0100
27514 #include <linux/proc_fs.h>
27515 #include <linux/seq_file.h>
27516 +#include <linux/vs_inet6.h>
27517 #include "udp_impl.h"
27519 int udp_v6_get_port(struct sock *sk, unsigned short snum)
27520 @@ -77,6 +78,10 @@ static inline int compute_score(struct s
27521 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27525 + /* block non nx_info ips */
27526 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27529 if (!ipv6_addr_any(&np->daddr)) {
27530 if (!ipv6_addr_equal(&np->daddr, saddr))
27531 diff -NurpP --minimal linux-2.6.29/net/ipv6/xfrm6_policy.c linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/xfrm6_policy.c
27532 --- linux-2.6.29/net/ipv6/xfrm6_policy.c 2009-03-24 14:22:47.000000000 +0100
27533 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/ipv6/xfrm6_policy.c 2009-03-24 14:48:37.000000000 +0100
27534 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
27535 dev = ip6_dst_idev(dst)->dev;
27536 ipv6_dev_get_saddr(dev_net(dev), dev,
27537 (struct in6_addr *)&daddr->a6, 0,
27538 - (struct in6_addr *)&saddr->a6);
27539 + (struct in6_addr *)&saddr->a6, NULL);
27543 diff -NurpP --minimal linux-2.6.29/net/netlink/af_netlink.c linux-2.6.29-vs2.3.0.36.9-pre2/net/netlink/af_netlink.c
27544 --- linux-2.6.29/net/netlink/af_netlink.c 2009-03-24 14:22:47.000000000 +0100
27545 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/netlink/af_netlink.c 2009-03-24 14:48:37.000000000 +0100
27547 #include <linux/types.h>
27548 #include <linux/audit.h>
27549 #include <linux/mutex.h>
27550 +#include <linux/vs_context.h>
27551 +#include <linux/vs_network.h>
27552 +#include <linux/vs_limit.h>
27554 #include <net/net_namespace.h>
27555 #include <net/sock.h>
27556 @@ -1776,6 +1779,8 @@ static struct sock *netlink_seq_socket_i
27557 sk_for_each(s, node, &hash->table[j]) {
27558 if (sock_net(s) != seq_file_net(seq))
27560 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27564 iter->hash_idx = j;
27565 @@ -1810,7 +1815,8 @@ static void *netlink_seq_next(struct seq
27569 - } while (s && sock_net(s) != seq_file_net(seq));
27570 + } while (s && (sock_net(s) != seq_file_net(seq) ||
27571 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
27575 @@ -1822,7 +1828,8 @@ static void *netlink_seq_next(struct seq
27577 for (; j <= hash->mask; j++) {
27578 s = sk_head(&hash->table[j]);
27579 - while (s && sock_net(s) != seq_file_net(seq))
27580 + while (s && (sock_net(s) != seq_file_net(seq) ||
27581 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
27585 diff -NurpP --minimal linux-2.6.29/net/sctp/ipv6.c linux-2.6.29-vs2.3.0.36.9-pre2/net/sctp/ipv6.c
27586 --- linux-2.6.29/net/sctp/ipv6.c 2009-03-24 14:22:48.000000000 +0100
27587 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/sctp/ipv6.c 2009-03-24 20:58:14.000000000 +0100
27588 @@ -317,7 +317,8 @@ static void sctp_v6_get_saddr(struct sct
27589 dst ? ip6_dst_idev(dst)->dev : NULL,
27590 &daddr->v6.sin6_addr,
27591 inet6_sk(&sk->inet.sk)->srcprefs,
27592 - &saddr->v6.sin6_addr);
27593 + &saddr->v6.sin6_addr,
27594 + asoc->base.sk->sk_nx_info);
27595 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
27596 &saddr->v6.sin6_addr);
27598 diff -NurpP --minimal linux-2.6.29/net/socket.c linux-2.6.29-vs2.3.0.36.9-pre2/net/socket.c
27599 --- linux-2.6.29/net/socket.c 2009-03-24 14:22:48.000000000 +0100
27600 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/socket.c 2009-03-24 14:48:37.000000000 +0100
27603 #include <net/sock.h>
27604 #include <linux/netfilter.h>
27605 +#include <linux/vs_base.h>
27606 +#include <linux/vs_socket.h>
27607 +#include <linux/vs_inet.h>
27608 +#include <linux/vs_inet6.h>
27610 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
27611 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
27612 @@ -549,7 +553,7 @@ static inline int __sock_sendmsg(struct
27613 struct msghdr *msg, size_t size)
27615 struct sock_iocb *si = kiocb_to_siocb(iocb);
27621 @@ -560,7 +564,22 @@ static inline int __sock_sendmsg(struct
27625 - return sock->ops->sendmsg(iocb, sock, msg, size);
27626 + len = sock->ops->sendmsg(iocb, sock, msg, size);
27629 + vx_sock_send(sock->sk, size);
27631 + vx_sock_fail(sock->sk, size);
27633 + vxdprintk(VXD_CBIT(net, 7),
27634 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27636 + (sock->sk)?sock->sk->sk_nx_info:0,
27637 + (sock->sk)?sock->sk->sk_vx_info:0,
27638 + (sock->sk)?sock->sk->sk_xid:0,
27639 + (sock->sk)?sock->sk->sk_nid:0,
27640 + (unsigned int)size, len);
27644 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
27645 @@ -629,7 +648,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
27646 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
27647 struct msghdr *msg, size_t size, int flags)
27651 struct sock_iocb *si = kiocb_to_siocb(iocb);
27654 @@ -642,7 +661,18 @@ static inline int __sock_recvmsg(struct
27658 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
27659 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
27660 + if ((len >= 0) && sock->sk)
27661 + vx_sock_recv(sock->sk, len);
27662 + vxdprintk(VXD_CBIT(net, 7),
27663 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27665 + (sock->sk)?sock->sk->sk_nx_info:0,
27666 + (sock->sk)?sock->sk->sk_vx_info:0,
27667 + (sock->sk)?sock->sk->sk_xid:0,
27668 + (sock->sk)?sock->sk->sk_nid:0,
27669 + (unsigned int)size, len);
27673 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
27674 @@ -1106,6 +1136,13 @@ static int __sock_create(struct net *net
27675 if (type < 0 || type >= SOCK_MAX)
27678 + if (!nx_check(0, VS_ADMIN)) {
27679 + if (family == PF_INET && !current_nx_info_has_v4())
27680 + return -EAFNOSUPPORT;
27681 + if (family == PF_INET6 && !current_nx_info_has_v6())
27682 + return -EAFNOSUPPORT;
27687 This uglymoron is moved from INET layer to here to avoid
27688 @@ -1238,6 +1275,7 @@ SYSCALL_DEFINE3(socket, int, family, int
27692 + set_bit(SOCK_USER_SOCKET, &sock->flags);
27693 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
27696 @@ -1279,10 +1317,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
27697 err = sock_create(family, type, protocol, &sock1);
27700 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
27702 err = sock_create(family, type, protocol, &sock2);
27704 goto out_release_1;
27705 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
27707 err = sock1->ops->socketpair(sock1, sock2);
27709 diff -NurpP --minimal linux-2.6.29/net/sunrpc/auth.c linux-2.6.29-vs2.3.0.36.9-pre2/net/sunrpc/auth.c
27710 --- linux-2.6.29/net/sunrpc/auth.c 2009-03-24 14:22:48.000000000 +0100
27711 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/sunrpc/auth.c 2009-03-24 21:00:49.000000000 +0100
27713 #include <linux/hash.h>
27714 #include <linux/sunrpc/clnt.h>
27715 #include <linux/spinlock.h>
27716 +#include <linux/vs_tag.h>
27719 # define RPCDBG_FACILITY RPCDBG_AUTH
27720 @@ -360,6 +361,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
27721 memset(&acred, 0, sizeof(acred));
27722 acred.uid = cred->fsuid;
27723 acred.gid = cred->fsgid;
27724 + acred.tag = dx_current_tag();
27725 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
27727 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
27728 @@ -400,6 +402,7 @@ rpcauth_bind_root_cred(struct rpc_task *
27729 struct auth_cred acred = {
27732 + .tag = dx_current_tag(),
27734 struct rpc_cred *ret;
27736 diff -NurpP --minimal linux-2.6.29/net/sunrpc/auth_unix.c linux-2.6.29-vs2.3.0.36.9-pre2/net/sunrpc/auth_unix.c
27737 --- linux-2.6.29/net/sunrpc/auth_unix.c 2008-12-25 00:26:37.000000000 +0100
27738 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/sunrpc/auth_unix.c 2009-02-22 22:54:26.000000000 +0100
27739 @@ -11,12 +11,14 @@
27740 #include <linux/module.h>
27741 #include <linux/sunrpc/clnt.h>
27742 #include <linux/sunrpc/auth.h>
27743 +#include <linux/vs_tag.h>
27745 #define NFS_NGROUPS 16
27748 struct rpc_cred uc_base;
27751 gid_t uc_gids[NFS_NGROUPS];
27753 #define uc_uid uc_base.cr_uid
27754 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
27755 groups = NFS_NGROUPS;
27757 cred->uc_gid = acred->gid;
27758 + cred->uc_tag = acred->tag;
27759 for (i = 0; i < groups; i++)
27760 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
27761 if (i < NFS_NGROUPS)
27762 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
27766 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
27767 + if (cred->uc_uid != acred->uid ||
27768 + cred->uc_gid != acred->gid ||
27769 + cred->uc_tag != acred->tag)
27772 if (acred->group_info != NULL)
27773 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
27774 struct rpc_clnt *clnt = task->tk_client;
27775 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
27776 __be32 *base, *hold;
27780 *p++ = htonl(RPC_AUTH_UNIX);
27782 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
27783 * Copy the UTS nodename captured when the client was created.
27785 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
27786 + tag = task->tk_client->cl_tag;
27788 - *p++ = htonl((u32) cred->uc_uid);
27789 - *p++ = htonl((u32) cred->uc_gid);
27790 + *p++ = htonl((u32) TAGINO_UID(tag,
27791 + cred->uc_uid, cred->uc_tag));
27792 + *p++ = htonl((u32) TAGINO_GID(tag,
27793 + cred->uc_gid, cred->uc_tag));
27795 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
27796 *p++ = htonl((u32) cred->uc_gids[i]);
27797 diff -NurpP --minimal linux-2.6.29/net/sunrpc/clnt.c linux-2.6.29-vs2.3.0.36.9-pre2/net/sunrpc/clnt.c
27798 --- linux-2.6.29/net/sunrpc/clnt.c 2009-03-24 14:22:48.000000000 +0100
27799 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/sunrpc/clnt.c 2009-03-24 14:48:37.000000000 +0100
27801 #include <linux/utsname.h>
27802 #include <linux/workqueue.h>
27803 #include <linux/in6.h>
27804 +#include <linux/vs_cvirt.h>
27806 #include <linux/sunrpc/clnt.h>
27807 #include <linux/sunrpc/rpc_pipe_fs.h>
27808 @@ -335,6 +336,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
27809 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
27810 clnt->cl_chatty = 1;
27812 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
27813 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
27814 + clnt->cl_tag = 1; */
27817 EXPORT_SYMBOL_GPL(rpc_create);
27818 diff -NurpP --minimal linux-2.6.29/net/unix/af_unix.c linux-2.6.29-vs2.3.0.36.9-pre2/net/unix/af_unix.c
27819 --- linux-2.6.29/net/unix/af_unix.c 2009-03-24 14:22:48.000000000 +0100
27820 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/unix/af_unix.c 2009-03-24 14:48:37.000000000 +0100
27821 @@ -114,6 +114,8 @@
27822 #include <linux/mount.h>
27823 #include <net/checksum.h>
27824 #include <linux/security.h>
27825 +#include <linux/vs_context.h>
27826 +#include <linux/vs_limit.h>
27828 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
27829 static DEFINE_SPINLOCK(unix_table_lock);
27830 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
27831 if (!net_eq(sock_net(s), net))
27834 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27836 if (u->addr->len == len &&
27837 !memcmp(u->addr->name, sunname, len))
27839 @@ -2110,6 +2114,8 @@ static struct sock *unix_seq_idx(struct
27840 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
27841 if (sock_net(s) != seq_file_net(seq))
27843 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27848 @@ -2134,7 +2140,8 @@ static void *unix_seq_next(struct seq_fi
27849 sk = first_unix_socket(&iter->i);
27851 sk = next_unix_socket(&iter->i, sk);
27852 - while (sk && (sock_net(sk) != seq_file_net(seq)))
27853 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
27854 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
27855 sk = next_unix_socket(&iter->i, sk);
27858 diff -NurpP --minimal linux-2.6.29/net/x25/af_x25.c linux-2.6.29-vs2.3.0.36.9-pre2/net/x25/af_x25.c
27859 --- linux-2.6.29/net/x25/af_x25.c 2008-12-25 00:26:37.000000000 +0100
27860 +++ linux-2.6.29-vs2.3.0.36.9-pre2/net/x25/af_x25.c 2009-02-22 22:54:26.000000000 +0100
27861 @@ -506,7 +506,10 @@ static int x25_create(struct net *net, s
27865 - sock_init_data(sock, sk);
27866 + sk->sk_socket = sock;
27867 + sk->sk_type = sock->type;
27868 + sk->sk_sleep = &sock->wait;
27871 x25_init_timers(sk);
27873 diff -NurpP --minimal linux-2.6.29/scripts/checksyscalls.sh linux-2.6.29-vs2.3.0.36.9-pre2/scripts/checksyscalls.sh
27874 --- linux-2.6.29/scripts/checksyscalls.sh 2008-12-25 00:26:37.000000000 +0100
27875 +++ linux-2.6.29-vs2.3.0.36.9-pre2/scripts/checksyscalls.sh 2009-02-22 22:54:26.000000000 +0100
27876 @@ -108,7 +108,6 @@ cat << EOF
27877 #define __IGNORE_afs_syscall
27878 #define __IGNORE_getpmsg
27879 #define __IGNORE_putpmsg
27880 -#define __IGNORE_vserver
27884 diff -NurpP --minimal linux-2.6.29/security/commoncap.c linux-2.6.29-vs2.3.0.36.9-pre2/security/commoncap.c
27885 --- linux-2.6.29/security/commoncap.c 2009-03-24 14:23:21.000000000 +0100
27886 +++ linux-2.6.29-vs2.3.0.36.9-pre2/security/commoncap.c 2009-03-25 00:34:48.000000000 +0100
27887 @@ -27,10 +27,11 @@
27888 #include <linux/sched.h>
27889 #include <linux/prctl.h>
27890 #include <linux/securebits.h>
27891 +#include <linux/vs_context.h>
27893 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
27895 - NETLINK_CB(skb).eff_cap = current_cap();
27896 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
27900 @@ -40,6 +41,7 @@ int cap_netlink_recv(struct sk_buff *skb
27905 EXPORT_SYMBOL(cap_netlink_recv);
27908 @@ -60,7 +62,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
27909 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
27912 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
27913 + struct vx_info *vxi = tsk->vx_info;
27916 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
27917 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
27918 + cap_raised(tsk->cap_effective, cap),
27919 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
27922 + /* special case SETUP */
27923 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
27924 + /* FIXME: maybe use cred instead? */
27925 + cap_raised(tsk->cred->cap_effective, cap))
27928 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
27932 @@ -586,7 +603,7 @@ int cap_inode_setxattr(struct dentry *de
27934 if (!strncmp(name, XATTR_SECURITY_PREFIX,
27935 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
27936 - !capable(CAP_SYS_ADMIN))
27937 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
27941 @@ -931,7 +948,8 @@ error:
27943 int cap_syslog(int type)
27945 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
27946 + if ((type != 3 && type != 10) &&
27947 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
27951 @@ -953,3 +971,4 @@ int cap_vm_enough_memory(struct mm_struc
27953 return __vm_enough_memory(mm, pages, cap_sys_admin);
27956 diff -NurpP --minimal linux-2.6.29/security/selinux/hooks.c linux-2.6.29-vs2.3.0.36.9-pre2/security/selinux/hooks.c
27957 --- linux-2.6.29/security/selinux/hooks.c 2009-03-24 14:23:21.000000000 +0100
27958 +++ linux-2.6.29-vs2.3.0.36.9-pre2/security/selinux/hooks.c 2009-03-24 14:48:37.000000000 +0100
27960 #include <linux/dccp.h>
27961 #include <linux/quota.h>
27962 #include <linux/un.h> /* for Unix socket types */
27963 -#include <net/af_unix.h> /* for Unix socket types */
27964 #include <linux/parser.h>
27965 #include <linux/nfs_mount.h>
27966 #include <net/ipv6.h>