1 diff -NurpP --minimal linux-2.6.32.24/arch/alpha/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/Kconfig
2 --- linux-2.6.32.24/arch/alpha/Kconfig 2009-12-03 20:01:49.000000000 +0100
3 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/Kconfig 2009-12-03 20:04:56.000000000 +0100
4 @@ -674,6 +674,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.32.24/arch/alpha/kernel/entry.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/entry.S
14 --- linux-2.6.32.24/arch/alpha/kernel/entry.S 2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/entry.S 2009-12-03 20:04:56.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.32.24/arch/alpha/kernel/osf_sys.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.32.24/arch/alpha/kernel/osf_sys.c 2010-10-04 08:55:48.000000000 +0200
50 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/osf_sys.c 2010-01-20 04:21:33.000000000 +0100
51 @@ -865,7 +865,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.32.24/arch/alpha/kernel/ptrace.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.32.24/arch/alpha/kernel/ptrace.c 2009-09-10 15:25:14.000000000 +0200
62 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/ptrace.c 2009-12-03 20:04:56.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.32.24/arch/alpha/kernel/systbls.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/systbls.S
72 --- linux-2.6.32.24/arch/alpha/kernel/systbls.S 2009-03-24 14:18:08.000000000 +0100
73 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/systbls.S 2009-12-03 20:04:56.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.32.24/arch/alpha/kernel/traps.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/traps.c
84 --- linux-2.6.32.24/arch/alpha/kernel/traps.c 2009-06-11 17:11:46.000000000 +0200
85 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/kernel/traps.c 2009-12-03 20:04:56.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.32.24/arch/alpha/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/mm/fault.c
97 --- linux-2.6.32.24/arch/alpha/mm/fault.c 2009-09-10 15:25:14.000000000 +0200
98 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/alpha/mm/fault.c 2009-12-03 20:04:56.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.32.24/arch/arm/include/asm/tlb.h linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/include/asm/tlb.h
111 --- linux-2.6.32.24/arch/arm/include/asm/tlb.h 2009-09-10 15:25:15.000000000 +0200
112 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/include/asm/tlb.h 2010-02-19 16:17:49.000000000 +0100
115 #else /* !CONFIG_MMU */
117 +#include <linux/vs_memory.h>
118 #include <asm/pgalloc.h>
121 diff -NurpP --minimal linux-2.6.32.24/arch/arm/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/Kconfig
122 --- linux-2.6.32.24/arch/arm/Kconfig 2010-10-04 08:55:48.000000000 +0200
123 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/Kconfig 2010-08-19 17:35:34.000000000 +0200
124 @@ -1524,6 +1524,8 @@ source "fs/Kconfig"
126 source "arch/arm/Kconfig.debug"
128 +source "kernel/vserver/Kconfig"
130 source "security/Kconfig"
132 source "crypto/Kconfig"
133 diff -NurpP --minimal linux-2.6.32.24/arch/arm/kernel/calls.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/kernel/calls.S
134 --- linux-2.6.32.24/arch/arm/kernel/calls.S 2010-10-04 08:55:49.000000000 +0200
135 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/kernel/calls.S 2010-01-20 04:21:33.000000000 +0100
137 /* 310 */ CALL(sys_request_key)
139 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
140 -/* vserver */ CALL(sys_ni_syscall)
143 /* 315 */ CALL(sys_ioprio_get)
144 CALL(sys_inotify_init)
145 diff -NurpP --minimal linux-2.6.32.24/arch/arm/kernel/process.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/kernel/process.c
146 --- linux-2.6.32.24/arch/arm/kernel/process.c 2009-12-03 20:01:50.000000000 +0100
147 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/kernel/process.c 2009-12-03 20:04:56.000000000 +0100
148 @@ -269,7 +269,8 @@ void __show_regs(struct pt_regs *regs)
149 void show_regs(struct pt_regs * regs)
152 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
153 + printk("Pid: %d[#%u], comm: %20s\n",
154 + task_pid_nr(current), current->xid, current->comm);
158 diff -NurpP --minimal linux-2.6.32.24/arch/arm/kernel/traps.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/kernel/traps.c
159 --- linux-2.6.32.24/arch/arm/kernel/traps.c 2009-12-03 20:01:50.000000000 +0100
160 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/arm/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
161 @@ -234,8 +234,8 @@ static void __die(const char *str, int e
162 sysfs_printk_last_file();
165 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
166 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
167 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
168 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
170 if (!user_mode(regs) || in_interrupt()) {
171 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
172 diff -NurpP --minimal linux-2.6.32.24/arch/avr32/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/avr32/mm/fault.c
173 --- linux-2.6.32.24/arch/avr32/mm/fault.c 2009-09-10 15:25:20.000000000 +0200
174 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/avr32/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
175 @@ -216,7 +216,8 @@ out_of_memory:
176 down_read(&mm->mmap_sem);
179 - printk("VM: Killing process %s\n", tsk->comm);
180 + printk("VM: Killing process %s(%d:#%u)\n",
181 + tsk->comm, task_pid_nr(tsk), tsk->xid);
183 do_group_exit(SIGKILL);
185 diff -NurpP --minimal linux-2.6.32.24/arch/cris/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/cris/Kconfig
186 --- linux-2.6.32.24/arch/cris/Kconfig 2009-06-11 17:11:56.000000000 +0200
187 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/cris/Kconfig 2009-12-03 20:04:56.000000000 +0100
188 @@ -685,6 +685,8 @@ source "drivers/staging/Kconfig"
190 source "arch/cris/Kconfig.debug"
192 +source "kernel/vserver/Kconfig"
194 source "security/Kconfig"
196 source "crypto/Kconfig"
197 diff -NurpP --minimal linux-2.6.32.24/arch/cris/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/cris/mm/fault.c
198 --- linux-2.6.32.24/arch/cris/mm/fault.c 2009-12-03 20:01:56.000000000 +0100
199 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/cris/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
200 @@ -245,7 +245,8 @@ do_page_fault(unsigned long address, str
203 up_read(&mm->mmap_sem);
204 - printk("VM: killing process %s\n", tsk->comm);
205 + printk("VM: killing process %s(%d:#%u)\n",
206 + tsk->comm, task_pid_nr(tsk), tsk->xid);
210 diff -NurpP --minimal linux-2.6.32.24/arch/frv/kernel/kernel_thread.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/frv/kernel/kernel_thread.S
211 --- linux-2.6.32.24/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
212 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/frv/kernel/kernel_thread.S 2009-12-03 20:04:56.000000000 +0100
213 @@ -37,7 +37,7 @@ kernel_thread:
215 # start by forking the current process, but with shared VM
216 setlos.p #__NR_clone,gr7 ; syscall number
217 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
218 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
219 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
221 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
222 diff -NurpP --minimal linux-2.6.32.24/arch/frv/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/frv/mm/fault.c
223 --- linux-2.6.32.24/arch/frv/mm/fault.c 2009-09-10 15:25:22.000000000 +0200
224 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/frv/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
225 @@ -257,7 +257,8 @@ asmlinkage void do_page_fault(int datamm
228 up_read(&mm->mmap_sem);
229 - printk("VM: killing process %s\n", current->comm);
230 + printk("VM: killing process %s(%d:#%u)\n",
231 + current->comm, task_pid_nr(current), current->xid);
232 if (user_mode(__frame))
233 do_group_exit(SIGKILL);
235 diff -NurpP --minimal linux-2.6.32.24/arch/h8300/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/h8300/Kconfig
236 --- linux-2.6.32.24/arch/h8300/Kconfig 2009-03-24 14:18:24.000000000 +0100
237 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/h8300/Kconfig 2009-12-03 20:04:56.000000000 +0100
238 @@ -226,6 +226,8 @@ source "fs/Kconfig"
240 source "arch/h8300/Kconfig.debug"
242 +source "kernel/vserver/Kconfig"
244 source "security/Kconfig"
246 source "crypto/Kconfig"
247 diff -NurpP --minimal linux-2.6.32.24/arch/ia64/ia32/ia32_entry.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/ia32/ia32_entry.S
248 --- linux-2.6.32.24/arch/ia64/ia32/ia32_entry.S 2009-06-11 17:11:57.000000000 +0200
249 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/ia32/ia32_entry.S 2009-12-03 20:04:56.000000000 +0100
250 @@ -451,7 +451,7 @@ ia32_syscall_table:
251 data8 sys_tgkill /* 270 */
252 data8 compat_sys_utimes
253 data8 sys32_fadvise64_64
254 - data8 sys_ni_syscall
255 + data8 sys32_vserver
257 data8 sys_ni_syscall /* 275 */
259 diff -NurpP --minimal linux-2.6.32.24/arch/ia64/include/asm/tlb.h linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/include/asm/tlb.h
260 --- linux-2.6.32.24/arch/ia64/include/asm/tlb.h 2009-09-10 15:25:22.000000000 +0200
261 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/include/asm/tlb.h 2009-12-31 14:37:34.000000000 +0100
263 #include <linux/mm.h>
264 #include <linux/pagemap.h>
265 #include <linux/swap.h>
266 +#include <linux/vs_memory.h>
268 #include <asm/pgalloc.h>
269 #include <asm/processor.h>
270 diff -NurpP --minimal linux-2.6.32.24/arch/ia64/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/Kconfig
271 --- linux-2.6.32.24/arch/ia64/Kconfig 2009-12-03 20:01:56.000000000 +0100
272 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/Kconfig 2009-12-03 20:04:56.000000000 +0100
273 @@ -685,6 +685,8 @@ source "fs/Kconfig"
275 source "arch/ia64/Kconfig.debug"
277 +source "kernel/vserver/Kconfig"
279 source "security/Kconfig"
281 source "crypto/Kconfig"
282 diff -NurpP --minimal linux-2.6.32.24/arch/ia64/kernel/entry.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/entry.S
283 --- linux-2.6.32.24/arch/ia64/kernel/entry.S 2009-09-10 15:25:22.000000000 +0200
284 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/entry.S 2009-12-03 20:04:56.000000000 +0100
285 @@ -1753,7 +1753,7 @@ sys_call_table:
287 data8 sys_mq_getsetattr
289 - data8 sys_ni_syscall // reserved for vserver
291 data8 sys_waitid // 1270
293 data8 sys_request_key
294 diff -NurpP --minimal linux-2.6.32.24/arch/ia64/kernel/perfmon.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/perfmon.c
295 --- linux-2.6.32.24/arch/ia64/kernel/perfmon.c 2009-09-10 15:25:22.000000000 +0200
296 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/perfmon.c 2009-12-03 20:04:56.000000000 +0100
298 #include <linux/rcupdate.h>
299 #include <linux/completion.h>
300 #include <linux/tracehook.h>
301 +#include <linux/vs_memory.h>
303 #include <asm/errno.h>
304 #include <asm/intrinsics.h>
305 @@ -2372,7 +2373,7 @@ pfm_smpl_buffer_alloc(struct task_struct
307 insert_vm_struct(mm, vma);
309 - mm->total_vm += size >> PAGE_SHIFT;
310 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
311 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
313 up_write(&task->mm->mmap_sem);
314 diff -NurpP --minimal linux-2.6.32.24/arch/ia64/kernel/process.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/process.c
315 --- linux-2.6.32.24/arch/ia64/kernel/process.c 2009-12-03 20:01:56.000000000 +0100
316 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/process.c 2009-12-03 20:04:56.000000000 +0100
317 @@ -110,8 +110,8 @@ show_regs (struct pt_regs *regs)
318 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
321 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
322 - smp_processor_id(), current->comm);
323 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
324 + current->xid, smp_processor_id(), current->comm);
325 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
326 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
327 init_utsname()->release);
328 diff -NurpP --minimal linux-2.6.32.24/arch/ia64/kernel/ptrace.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/ptrace.c
329 --- linux-2.6.32.24/arch/ia64/kernel/ptrace.c 2009-09-10 15:25:22.000000000 +0200
330 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
332 #include <linux/regset.h>
333 #include <linux/elf.h>
334 #include <linux/tracehook.h>
335 +#include <linux/vs_base.h>
337 #include <asm/pgtable.h>
338 #include <asm/processor.h>
339 diff -NurpP --minimal linux-2.6.32.24/arch/ia64/kernel/traps.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/traps.c
340 --- linux-2.6.32.24/arch/ia64/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
341 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
342 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
345 if (++die.lock_owner_depth < 3) {
346 - printk("%s[%d]: %s %ld [%d]\n",
347 - current->comm, task_pid_nr(current), str, err, ++die_counter);
348 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
349 + current->comm, task_pid_nr(current), current->xid,
350 + str, err, ++die_counter);
351 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
354 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
355 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
356 last.time = current_jiffies + 5 * HZ;
358 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
359 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
360 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
361 + current->comm, task_pid_nr(current), current->xid,
362 + regs->cr_iip + ia64_psr(regs)->ri, isr);
366 diff -NurpP --minimal linux-2.6.32.24/arch/ia64/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/mm/fault.c
367 --- linux-2.6.32.24/arch/ia64/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
368 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/ia64/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
370 #include <linux/interrupt.h>
371 #include <linux/kprobes.h>
372 #include <linux/kdebug.h>
373 +#include <linux/vs_memory.h>
375 #include <asm/pgtable.h>
376 #include <asm/processor.h>
377 @@ -281,7 +282,8 @@ ia64_do_page_fault (unsigned long addres
378 down_read(&mm->mmap_sem);
381 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
382 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
383 + current->comm, task_pid_nr(current), current->xid);
385 do_group_exit(SIGKILL);
387 diff -NurpP --minimal linux-2.6.32.24/arch/m32r/kernel/traps.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/m32r/kernel/traps.c
388 --- linux-2.6.32.24/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
389 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/m32r/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
390 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
392 printk("SPI: %08lx\n", sp);
394 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
395 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
396 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
397 + current->comm, task_pid_nr(current), current->xid,
398 + 0xffff & i, 4096+(unsigned long)current);
401 * When in-kernel, we also print out the stack and code at the
402 diff -NurpP --minimal linux-2.6.32.24/arch/m32r/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/m32r/mm/fault.c
403 --- linux-2.6.32.24/arch/m32r/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
404 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/m32r/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
405 @@ -276,7 +276,8 @@ out_of_memory:
406 down_read(&mm->mmap_sem);
409 - printk("VM: killing process %s\n", tsk->comm);
410 + printk("VM: killing process %s(%d:#%u)\n",
411 + tsk->comm, task_pid_nr(tsk), tsk->xid);
412 if (error_code & ACE_USERMODE)
413 do_group_exit(SIGKILL);
415 diff -NurpP --minimal linux-2.6.32.24/arch/m68k/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68k/Kconfig
416 --- linux-2.6.32.24/arch/m68k/Kconfig 2009-12-03 20:01:57.000000000 +0100
417 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68k/Kconfig 2009-12-03 20:04:56.000000000 +0100
418 @@ -622,6 +622,8 @@ source "fs/Kconfig"
420 source "arch/m68k/Kconfig.debug"
422 +source "kernel/vserver/Kconfig"
424 source "security/Kconfig"
426 source "crypto/Kconfig"
427 diff -NurpP --minimal linux-2.6.32.24/arch/m68k/kernel/ptrace.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68k/kernel/ptrace.c
428 --- linux-2.6.32.24/arch/m68k/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
429 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68k/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
431 #include <linux/ptrace.h>
432 #include <linux/user.h>
433 #include <linux/signal.h>
434 +#include <linux/vs_base.h>
436 #include <asm/uaccess.h>
437 #include <asm/page.h>
438 @@ -269,6 +270,8 @@ long arch_ptrace(struct task_struct *chi
439 ret = ptrace_request(child, request, addr, data);
442 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
447 diff -NurpP --minimal linux-2.6.32.24/arch/m68k/kernel/traps.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68k/kernel/traps.c
448 --- linux-2.6.32.24/arch/m68k/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
449 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68k/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
450 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
451 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
452 regs->d4, regs->d5, regs->a0, regs->a1);
454 - printk("Process %s (pid: %d, task=%p)\n",
455 - current->comm, task_pid_nr(current), current);
456 + printk("Process %s (pid: %d[#%u], task=%p)\n",
457 + current->comm, task_pid_nr(current), current->xid, current);
458 addr = (unsigned long)&fp->un;
459 printk("Frame format=%X ", regs->format);
460 switch (regs->format) {
461 diff -NurpP --minimal linux-2.6.32.24/arch/m68k/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68k/mm/fault.c
462 --- linux-2.6.32.24/arch/m68k/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
463 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68k/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
464 @@ -186,7 +186,8 @@ out_of_memory:
468 - printk("VM: killing process %s\n", current->comm);
469 + printk("VM: killing process %s(%d:#%u)\n",
470 + current->comm, task_pid_nr(current), current->xid);
472 do_group_exit(SIGKILL);
474 diff -NurpP --minimal linux-2.6.32.24/arch/m68knommu/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68knommu/Kconfig
475 --- linux-2.6.32.24/arch/m68knommu/Kconfig 2009-12-03 20:01:57.000000000 +0100
476 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68knommu/Kconfig 2009-12-03 20:04:56.000000000 +0100
477 @@ -727,6 +727,8 @@ source "fs/Kconfig"
479 source "arch/m68knommu/Kconfig.debug"
481 +source "kernel/vserver/Kconfig"
483 source "security/Kconfig"
485 source "crypto/Kconfig"
486 diff -NurpP --minimal linux-2.6.32.24/arch/m68knommu/kernel/traps.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68knommu/kernel/traps.c
487 --- linux-2.6.32.24/arch/m68knommu/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
488 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/m68knommu/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
489 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
490 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
491 fp->d4, fp->d5, fp->a0, fp->a1);
493 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
494 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
495 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
496 + current->comm, task_pid_nr(current), current->xid,
497 + PAGE_SIZE+(unsigned long)current);
498 show_stack(NULL, (unsigned long *)(fp + 1));
499 add_taint(TAINT_DIE);
501 diff -NurpP --minimal linux-2.6.32.24/arch/microblaze/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/microblaze/mm/fault.c
502 --- linux-2.6.32.24/arch/microblaze/mm/fault.c 2009-09-10 15:25:24.000000000 +0200
503 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/microblaze/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
504 @@ -279,7 +279,8 @@ out_of_memory:
507 up_read(&mm->mmap_sem);
508 - printk(KERN_WARNING "VM: killing process %s\n", current->comm);
509 + printk(KERN_WARNING "VM: killing process %s(%d:#%u)\n",
510 + current->comm, task_pid_nr(current), current->xid);
513 bad_page_fault(regs, address, SIGKILL);
514 diff -NurpP --minimal linux-2.6.32.24/arch/mips/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/Kconfig
515 --- linux-2.6.32.24/arch/mips/Kconfig 2009-12-03 20:01:58.000000000 +0100
516 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/Kconfig 2009-12-03 20:04:56.000000000 +0100
517 @@ -2188,6 +2188,8 @@ source "fs/Kconfig"
519 source "arch/mips/Kconfig.debug"
521 +source "kernel/vserver/Kconfig"
523 source "security/Kconfig"
525 source "crypto/Kconfig"
526 diff -NurpP --minimal linux-2.6.32.24/arch/mips/kernel/ptrace.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/ptrace.c
527 --- linux-2.6.32.24/arch/mips/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
528 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
530 #include <linux/security.h>
531 #include <linux/audit.h>
532 #include <linux/seccomp.h>
533 +#include <linux/vs_base.h>
535 #include <asm/byteorder.h>
537 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
541 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
545 /* when I and D space are separate, these will need to be fixed. */
546 case PTRACE_PEEKTEXT: /* read word at location addr. */
547 diff -NurpP --minimal linux-2.6.32.24/arch/mips/kernel/scall32-o32.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/scall32-o32.S
548 --- linux-2.6.32.24/arch/mips/kernel/scall32-o32.S 2009-12-03 20:01:59.000000000 +0100
549 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/scall32-o32.S 2009-12-03 20:04:56.000000000 +0100
550 @@ -525,7 +525,7 @@ einval: li v0, -ENOSYS
551 sys sys_mq_timedreceive 5
552 sys sys_mq_notify 2 /* 4275 */
553 sys sys_mq_getsetattr 3
554 - sys sys_ni_syscall 0 /* sys_vserver */
557 sys sys_ni_syscall 0 /* available, was setaltroot */
558 sys sys_add_key 5 /* 4280 */
559 diff -NurpP --minimal linux-2.6.32.24/arch/mips/kernel/scall64-64.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/scall64-64.S
560 --- linux-2.6.32.24/arch/mips/kernel/scall64-64.S 2009-12-03 20:01:59.000000000 +0100
561 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/scall64-64.S 2009-12-03 20:04:56.000000000 +0100
562 @@ -362,7 +362,7 @@ sys_call_table:
563 PTR sys_mq_timedreceive
565 PTR sys_mq_getsetattr /* 5235 */
566 - PTR sys_ni_syscall /* sys_vserver */
569 PTR sys_ni_syscall /* available, was setaltroot */
571 diff -NurpP --minimal linux-2.6.32.24/arch/mips/kernel/scall64-n32.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/scall64-n32.S
572 --- linux-2.6.32.24/arch/mips/kernel/scall64-n32.S 2009-12-03 20:01:59.000000000 +0100
573 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/scall64-n32.S 2009-12-03 20:04:56.000000000 +0100
574 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
575 PTR compat_sys_mq_timedreceive
576 PTR compat_sys_mq_notify
577 PTR compat_sys_mq_getsetattr
578 - PTR sys_ni_syscall /* 6240, sys_vserver */
579 + PTR sys32_vserver /* 6240 */
580 PTR compat_sys_waitid
581 PTR sys_ni_syscall /* available, was setaltroot */
583 diff -NurpP --minimal linux-2.6.32.24/arch/mips/kernel/scall64-o32.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/scall64-o32.S
584 --- linux-2.6.32.24/arch/mips/kernel/scall64-o32.S 2009-12-03 20:01:59.000000000 +0100
585 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/scall64-o32.S 2009-12-03 20:04:56.000000000 +0100
586 @@ -480,7 +480,7 @@ sys_call_table:
587 PTR compat_sys_mq_timedreceive
588 PTR compat_sys_mq_notify /* 4275 */
589 PTR compat_sys_mq_getsetattr
590 - PTR sys_ni_syscall /* sys_vserver */
593 PTR sys_ni_syscall /* available, was setaltroot */
594 PTR sys_add_key /* 4280 */
595 diff -NurpP --minimal linux-2.6.32.24/arch/mips/kernel/traps.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/traps.c
596 --- linux-2.6.32.24/arch/mips/kernel/traps.c 2009-12-03 20:01:59.000000000 +0100
597 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/mips/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
598 @@ -335,9 +335,10 @@ void show_registers(const struct pt_regs
602 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
603 - current->comm, current->pid, current_thread_info(), current,
604 - field, current_thread_info()->tp_value);
605 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
606 + current->comm, task_pid_nr(current), current->xid,
607 + current_thread_info(), current,
608 + field, current_thread_info()->tp_value);
609 if (cpu_has_userlocal) {
612 diff -NurpP --minimal linux-2.6.32.24/arch/mn10300/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/mn10300/mm/fault.c
613 --- linux-2.6.32.24/arch/mn10300/mm/fault.c 2009-09-10 15:25:39.000000000 +0200
614 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/mn10300/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
615 @@ -339,7 +339,8 @@ no_context:
617 up_read(&mm->mmap_sem);
618 monitor_signal(regs);
619 - printk(KERN_ALERT "VM: killing process %s\n", tsk->comm);
620 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
621 + tsk->comm, task_pid_nr(tsk), tsk->xid);
622 if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR)
625 diff -NurpP --minimal linux-2.6.32.24/arch/parisc/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/parisc/Kconfig
626 --- linux-2.6.32.24/arch/parisc/Kconfig 2009-12-03 20:02:00.000000000 +0100
627 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/parisc/Kconfig 2009-12-03 20:04:56.000000000 +0100
628 @@ -294,6 +294,8 @@ source "fs/Kconfig"
630 source "arch/parisc/Kconfig.debug"
632 +source "kernel/vserver/Kconfig"
634 source "security/Kconfig"
636 source "crypto/Kconfig"
637 diff -NurpP --minimal linux-2.6.32.24/arch/parisc/kernel/syscall_table.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/parisc/kernel/syscall_table.S
638 --- linux-2.6.32.24/arch/parisc/kernel/syscall_table.S 2009-12-03 20:02:00.000000000 +0100
639 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/parisc/kernel/syscall_table.S 2009-12-03 20:04:56.000000000 +0100
641 ENTRY_COMP(mbind) /* 260 */
642 ENTRY_COMP(get_mempolicy)
643 ENTRY_COMP(set_mempolicy)
644 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
645 + ENTRY_DIFF(vserver)
647 ENTRY_SAME(request_key) /* 265 */
649 diff -NurpP --minimal linux-2.6.32.24/arch/parisc/kernel/traps.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/parisc/kernel/traps.c
650 --- linux-2.6.32.24/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
651 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/parisc/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
652 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
656 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
657 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
658 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
659 + current->comm, task_pid_nr(current), current->xid,
660 + str, err, regs->iaoq[0]);
661 #ifdef PRINT_USER_FAULTS
662 /* XXX for debugging only */
664 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
665 pdc_console_restart();
668 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
669 - current->comm, task_pid_nr(current), str, err);
670 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
671 + current->comm, task_pid_nr(current), current->xid, str, err);
673 /* Wot's wrong wif bein' racy? */
674 if (current->thread.flags & PARISC_KERNEL_DEATH) {
675 diff -NurpP --minimal linux-2.6.32.24/arch/parisc/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/parisc/mm/fault.c
676 --- linux-2.6.32.24/arch/parisc/mm/fault.c 2009-09-10 15:25:40.000000000 +0200
677 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/parisc/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
678 @@ -237,8 +237,9 @@ bad_area:
680 #ifdef PRINT_USER_FAULTS
681 printk(KERN_DEBUG "\n");
682 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
683 - task_pid_nr(tsk), tsk->comm, code, address);
684 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
685 + "command='%s' type=%lu address=0x%08lx\n",
686 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
688 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
689 vma->vm_start, vma->vm_end);
690 @@ -264,7 +265,8 @@ no_context:
693 up_read(&mm->mmap_sem);
694 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
695 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
696 + current->comm, current->pid, current->xid);
698 do_group_exit(SIGKILL);
700 diff -NurpP --minimal linux-2.6.32.24/arch/powerpc/include/asm/unistd.h linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/include/asm/unistd.h
701 --- linux-2.6.32.24/arch/powerpc/include/asm/unistd.h 2009-12-03 20:02:01.000000000 +0100
702 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/include/asm/unistd.h 2009-12-03 20:04:56.000000000 +0100
705 #define __NR_rtas 255
706 #define __NR_sys_debug_setcontext 256
707 -/* Number 257 is reserved for vserver */
708 +#define __NR_vserver 257
709 #define __NR_migrate_pages 258
710 #define __NR_mbind 259
711 #define __NR_get_mempolicy 260
712 diff -NurpP --minimal linux-2.6.32.24/arch/powerpc/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/Kconfig
713 --- linux-2.6.32.24/arch/powerpc/Kconfig 2009-12-03 20:02:00.000000000 +0100
714 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/Kconfig 2009-12-03 20:04:56.000000000 +0100
715 @@ -943,6 +943,8 @@ source "lib/Kconfig"
717 source "arch/powerpc/Kconfig.debug"
719 +source "kernel/vserver/Kconfig"
721 source "security/Kconfig"
724 diff -NurpP --minimal linux-2.6.32.24/arch/powerpc/kernel/process.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/kernel/process.c
725 --- linux-2.6.32.24/arch/powerpc/kernel/process.c 2010-10-04 08:55:52.000000000 +0200
726 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/kernel/process.c 2010-02-12 10:59:55.000000000 +0100
727 @@ -519,8 +519,9 @@ void show_regs(struct pt_regs * regs)
729 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
731 - printk("TASK = %p[%d] '%s' THREAD: %p",
732 - current, task_pid_nr(current), current->comm, task_thread_info(current));
733 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
734 + current, task_pid_nr(current), current->xid,
735 + current->comm, task_thread_info(current));
738 printk(" CPU: %d", raw_smp_processor_id());
739 diff -NurpP --minimal linux-2.6.32.24/arch/powerpc/kernel/traps.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/kernel/traps.c
740 --- linux-2.6.32.24/arch/powerpc/kernel/traps.c 2009-09-10 15:25:41.000000000 +0200
741 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
742 @@ -931,8 +931,9 @@ void nonrecoverable_exception(struct pt_
744 void trace_syscall(struct pt_regs *regs)
746 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
747 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
748 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
749 + current, task_pid_nr(current), current->xid,
750 + regs->nip, regs->link, regs->gpr[0],
751 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
754 diff -NurpP --minimal linux-2.6.32.24/arch/powerpc/kernel/vdso.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/kernel/vdso.c
755 --- linux-2.6.32.24/arch/powerpc/kernel/vdso.c 2009-12-03 20:02:02.000000000 +0100
756 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/kernel/vdso.c 2009-12-03 20:04:56.000000000 +0100
758 #include <linux/security.h>
759 #include <linux/bootmem.h>
760 #include <linux/lmb.h>
761 +#include <linux/vs_memory.h>
763 #include <asm/pgtable.h>
764 #include <asm/system.h>
765 diff -NurpP --minimal linux-2.6.32.24/arch/powerpc/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/mm/fault.c
766 --- linux-2.6.32.24/arch/powerpc/mm/fault.c 2009-12-03 20:02:02.000000000 +0100
767 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/powerpc/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
768 @@ -358,7 +358,8 @@ out_of_memory:
769 down_read(&mm->mmap_sem);
772 - printk("VM: killing process %s\n", current->comm);
773 + printk("VM: killing process %s(%d:#%u)\n",
774 + current->comm, current->pid, current->xid);
776 do_group_exit(SIGKILL);
778 diff -NurpP --minimal linux-2.6.32.24/arch/s390/include/asm/tlb.h linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/include/asm/tlb.h
779 --- linux-2.6.32.24/arch/s390/include/asm/tlb.h 2009-09-10 15:25:43.000000000 +0200
780 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/include/asm/tlb.h 2009-12-31 14:37:21.000000000 +0100
783 #include <linux/mm.h>
784 #include <linux/swap.h>
785 +#include <linux/vs_memory.h>
787 #include <asm/processor.h>
788 #include <asm/pgalloc.h>
790 diff -NurpP --minimal linux-2.6.32.24/arch/s390/include/asm/unistd.h linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/include/asm/unistd.h
791 --- linux-2.6.32.24/arch/s390/include/asm/unistd.h 2009-12-03 20:02:03.000000000 +0100
792 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/include/asm/unistd.h 2009-12-30 00:58:47.000000000 +0100
794 #define __NR_clock_gettime (__NR_timer_create+6)
795 #define __NR_clock_getres (__NR_timer_create+7)
796 #define __NR_clock_nanosleep (__NR_timer_create+8)
797 -/* Number 263 is reserved for vserver */
798 +#define __NR_vserver 263
799 #define __NR_statfs64 265
800 #define __NR_fstatfs64 266
801 #define __NR_remap_file_pages 267
802 diff -NurpP --minimal linux-2.6.32.24/arch/s390/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/Kconfig
803 --- linux-2.6.32.24/arch/s390/Kconfig 2009-12-03 20:02:03.000000000 +0100
804 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/Kconfig 2009-12-03 20:04:56.000000000 +0100
805 @@ -616,6 +616,8 @@ source "fs/Kconfig"
807 source "arch/s390/Kconfig.debug"
809 +source "kernel/vserver/Kconfig"
811 source "security/Kconfig"
813 source "crypto/Kconfig"
814 diff -NurpP --minimal linux-2.6.32.24/arch/s390/kernel/ptrace.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/kernel/ptrace.c
815 --- linux-2.6.32.24/arch/s390/kernel/ptrace.c 2010-10-04 08:55:53.000000000 +0200
816 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/kernel/ptrace.c 2010-05-27 19:21:36.000000000 +0200
818 #include <linux/regset.h>
819 #include <linux/tracehook.h>
820 #include <linux/seccomp.h>
821 +#include <linux/vs_base.h>
822 #include <trace/syscall.h>
823 #include <asm/compat.h>
824 #include <asm/segment.h>
825 diff -NurpP --minimal linux-2.6.32.24/arch/s390/kernel/syscalls.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/kernel/syscalls.S
826 --- linux-2.6.32.24/arch/s390/kernel/syscalls.S 2009-12-03 20:02:03.000000000 +0100
827 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/kernel/syscalls.S 2009-12-03 20:04:56.000000000 +0100
828 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
829 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
830 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
831 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
832 -NI_SYSCALL /* reserved for vserver */
833 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
834 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
835 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
836 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
837 diff -NurpP --minimal linux-2.6.32.24/arch/s390/lib/uaccess_pt.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/lib/uaccess_pt.c
838 --- linux-2.6.32.24/arch/s390/lib/uaccess_pt.c 2009-09-10 15:25:43.000000000 +0200
839 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/s390/lib/uaccess_pt.c 2009-12-03 20:04:56.000000000 +0100
840 @@ -90,7 +90,8 @@ out_of_memory:
841 down_read(&mm->mmap_sem);
844 - printk("VM: killing process %s\n", current->comm);
845 + printk("VM: killing process %s(%d:#%u)\n",
846 + current->comm, task_pid_nr(current), current->xid);
850 diff -NurpP --minimal linux-2.6.32.24/arch/sh/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/Kconfig
851 --- linux-2.6.32.24/arch/sh/Kconfig 2009-12-03 20:02:03.000000000 +0100
852 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/Kconfig 2009-12-03 20:04:56.000000000 +0100
853 @@ -853,6 +853,8 @@ source "fs/Kconfig"
855 source "arch/sh/Kconfig.debug"
857 +source "kernel/vserver/Kconfig"
859 source "security/Kconfig"
861 source "crypto/Kconfig"
862 diff -NurpP --minimal linux-2.6.32.24/arch/sh/kernel/irq.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/kernel/irq.c
863 --- linux-2.6.32.24/arch/sh/kernel/irq.c 2009-12-03 20:02:10.000000000 +0100
864 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/kernel/irq.c 2009-12-03 20:04:56.000000000 +0100
866 #include <linux/kernel_stat.h>
867 #include <linux/seq_file.h>
868 #include <linux/ftrace.h>
869 +// #include <linux/vs_context.h>
870 #include <asm/processor.h>
871 #include <asm/machvec.h>
872 #include <asm/uaccess.h>
873 diff -NurpP --minimal linux-2.6.32.24/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/kernel/vsyscall/vsyscall.c
874 --- linux-2.6.32.24/arch/sh/kernel/vsyscall/vsyscall.c 2009-03-24 14:18:42.000000000 +0100
875 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/kernel/vsyscall/vsyscall.c 2009-12-03 20:04:56.000000000 +0100
877 #include <linux/elf.h>
878 #include <linux/sched.h>
879 #include <linux/err.h>
880 +#include <linux/vs_memory.h>
883 * Should the kernel map a VDSO page into processes and pass its
884 diff -NurpP --minimal linux-2.6.32.24/arch/sh/mm/fault_32.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/mm/fault_32.c
885 --- linux-2.6.32.24/arch/sh/mm/fault_32.c 2009-12-03 20:02:14.000000000 +0100
886 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/mm/fault_32.c 2009-12-03 20:04:56.000000000 +0100
887 @@ -292,7 +292,8 @@ out_of_memory:
888 down_read(&mm->mmap_sem);
891 - printk("VM: killing process %s\n", tsk->comm);
892 + printk("VM: killing process %s(%d:#%u)\n",
893 + tsk->comm, task_pid_nr(tsk), tsk->xid);
895 do_group_exit(SIGKILL);
897 diff -NurpP --minimal linux-2.6.32.24/arch/sh/mm/tlbflush_64.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/mm/tlbflush_64.c
898 --- linux-2.6.32.24/arch/sh/mm/tlbflush_64.c 2009-12-03 20:02:14.000000000 +0100
899 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sh/mm/tlbflush_64.c 2009-12-03 20:04:56.000000000 +0100
900 @@ -306,7 +306,8 @@ out_of_memory:
901 down_read(&mm->mmap_sem);
904 - printk("VM: killing process %s\n", tsk->comm);
905 + printk("VM: killing process %s(%d:#%u)\n",
906 + tsk->comm, task_pid_nr(tsk), tsk->xid);
908 do_group_exit(SIGKILL);
910 diff -NurpP --minimal linux-2.6.32.24/arch/sparc/include/asm/tlb_64.h linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/include/asm/tlb_64.h
911 --- linux-2.6.32.24/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
912 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/include/asm/tlb_64.h 2009-12-03 20:04:56.000000000 +0100
915 #include <linux/swap.h>
916 #include <linux/pagemap.h>
917 +#include <linux/vs_memory.h>
918 #include <asm/pgalloc.h>
919 #include <asm/tlbflush.h>
920 #include <asm/mmu_context.h>
921 diff -NurpP --minimal linux-2.6.32.24/arch/sparc/include/asm/unistd.h linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/include/asm/unistd.h
922 --- linux-2.6.32.24/arch/sparc/include/asm/unistd.h 2009-12-03 20:02:15.000000000 +0100
923 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/include/asm/unistd.h 2009-12-03 20:04:56.000000000 +0100
925 #define __NR_timer_getoverrun 264
926 #define __NR_timer_delete 265
927 #define __NR_timer_create 266
928 -/* #define __NR_vserver 267 Reserved for VSERVER */
929 +#define __NR_vserver 267
930 #define __NR_io_setup 268
931 #define __NR_io_destroy 269
932 #define __NR_io_submit 270
933 diff -NurpP --minimal linux-2.6.32.24/arch/sparc/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/Kconfig
934 --- linux-2.6.32.24/arch/sparc/Kconfig 2009-12-03 20:02:14.000000000 +0100
935 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/Kconfig 2009-12-03 20:04:56.000000000 +0100
936 @@ -550,6 +550,8 @@ source "fs/Kconfig"
938 source "arch/sparc/Kconfig.debug"
940 +source "kernel/vserver/Kconfig"
942 source "security/Kconfig"
944 source "crypto/Kconfig"
945 diff -NurpP --minimal linux-2.6.32.24/arch/sparc/kernel/systbls_32.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/kernel/systbls_32.S
946 --- linux-2.6.32.24/arch/sparc/kernel/systbls_32.S 2010-10-04 08:55:54.000000000 +0200
947 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/kernel/systbls_32.S 2010-01-20 04:21:33.000000000 +0100
948 @@ -70,7 +70,7 @@ sys_call_table:
949 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
950 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
951 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
952 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
953 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
954 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
955 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
956 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
957 diff -NurpP --minimal linux-2.6.32.24/arch/sparc/kernel/systbls_64.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/kernel/systbls_64.S
958 --- linux-2.6.32.24/arch/sparc/kernel/systbls_64.S 2010-10-04 08:55:54.000000000 +0200
959 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/sparc/kernel/systbls_64.S 2010-01-20 04:21:33.000000000 +0100
960 @@ -71,7 +71,7 @@ sys_call_table32:
961 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
962 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
963 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
964 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
965 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
966 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
967 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
968 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
969 @@ -146,7 +146,7 @@ sys_call_table:
970 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
971 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
972 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
973 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
974 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
975 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
976 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
977 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
978 diff -NurpP --minimal linux-2.6.32.24/arch/um/include/asm/tlb.h linux-2.6.32.24-vs2.3.0.36.29.6/arch/um/include/asm/tlb.h
979 --- linux-2.6.32.24/arch/um/include/asm/tlb.h 2009-09-10 15:25:46.000000000 +0200
980 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/um/include/asm/tlb.h 2010-03-13 21:49:04.000000000 +0100
983 #include <linux/pagemap.h>
984 #include <linux/swap.h>
985 +#include <linux/vs_memory.h>
986 #include <asm/percpu.h>
987 #include <asm/pgalloc.h>
988 #include <asm/tlbflush.h>
989 diff -NurpP --minimal linux-2.6.32.24/arch/um/Kconfig.rest linux-2.6.32.24-vs2.3.0.36.29.6/arch/um/Kconfig.rest
990 --- linux-2.6.32.24/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
991 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/um/Kconfig.rest 2010-03-13 21:49:04.000000000 +0100
992 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
996 +source "kernel/vserver/Kconfig"
998 source "security/Kconfig"
1000 source "crypto/Kconfig"
1001 diff -NurpP --minimal linux-2.6.32.24/arch/x86/ia32/ia32entry.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/x86/ia32/ia32entry.S
1002 --- linux-2.6.32.24/arch/x86/ia32/ia32entry.S 2010-10-04 08:55:54.000000000 +0200
1003 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/x86/ia32/ia32entry.S 2010-09-22 00:48:38.000000000 +0200
1004 @@ -783,7 +783,7 @@ ia32_sys_call_table:
1005 .quad sys_tgkill /* 270 */
1006 .quad compat_sys_utimes
1007 .quad sys32_fadvise64_64
1008 - .quad quiet_ni_syscall /* sys_vserver */
1009 + .quad sys32_vserver
1011 .quad compat_sys_get_mempolicy /* 275 */
1012 .quad sys_set_mempolicy
1013 diff -NurpP --minimal linux-2.6.32.24/arch/x86/include/asm/unistd_64.h linux-2.6.32.24-vs2.3.0.36.29.6/arch/x86/include/asm/unistd_64.h
1014 --- linux-2.6.32.24/arch/x86/include/asm/unistd_64.h 2009-12-03 20:02:16.000000000 +0100
1015 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/x86/include/asm/unistd_64.h 2009-12-03 20:04:56.000000000 +0100
1016 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
1017 #define __NR_utimes 235
1018 __SYSCALL(__NR_utimes, sys_utimes)
1019 #define __NR_vserver 236
1020 -__SYSCALL(__NR_vserver, sys_ni_syscall)
1021 +__SYSCALL(__NR_vserver, sys_vserver)
1022 #define __NR_mbind 237
1023 __SYSCALL(__NR_mbind, sys_mbind)
1024 #define __NR_set_mempolicy 238
1025 diff -NurpP --minimal linux-2.6.32.24/arch/x86/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/arch/x86/Kconfig
1026 --- linux-2.6.32.24/arch/x86/Kconfig 2010-10-04 08:55:54.000000000 +0200
1027 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/x86/Kconfig 2010-09-05 21:24:17.000000000 +0200
1028 @@ -2089,6 +2089,8 @@ source "fs/Kconfig"
1030 source "arch/x86/Kconfig.debug"
1032 +source "kernel/vserver/Kconfig"
1034 source "security/Kconfig"
1036 source "crypto/Kconfig"
1037 diff -NurpP --minimal linux-2.6.32.24/arch/x86/kernel/syscall_table_32.S linux-2.6.32.24-vs2.3.0.36.29.6/arch/x86/kernel/syscall_table_32.S
1038 --- linux-2.6.32.24/arch/x86/kernel/syscall_table_32.S 2010-10-04 08:55:55.000000000 +0200
1039 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/x86/kernel/syscall_table_32.S 2010-01-20 04:21:33.000000000 +0100
1040 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
1041 .long sys_tgkill /* 270 */
1043 .long sys_fadvise64_64
1044 - .long sys_ni_syscall /* sys_vserver */
1047 .long sys_get_mempolicy
1048 .long sys_set_mempolicy
1049 diff -NurpP --minimal linux-2.6.32.24/arch/xtensa/mm/fault.c linux-2.6.32.24-vs2.3.0.36.29.6/arch/xtensa/mm/fault.c
1050 --- linux-2.6.32.24/arch/xtensa/mm/fault.c 2009-09-10 15:25:48.000000000 +0200
1051 +++ linux-2.6.32.24-vs2.3.0.36.29.6/arch/xtensa/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
1052 @@ -151,7 +151,8 @@ out_of_memory:
1053 down_read(&mm->mmap_sem);
1056 - printk("VM: killing process %s\n", current->comm);
1057 + printk("VM: killing process %s(%d:#%u)\n",
1058 + current->comm, task_pid_nr(current), current->xid);
1059 if (user_mode(regs))
1060 do_group_exit(SIGKILL);
1061 bad_page_fault(regs, address, SIGKILL);
1062 diff -NurpP --minimal linux-2.6.32.24/Documentation/scheduler/sched-cfs-hard-limits.txt linux-2.6.32.24-vs2.3.0.36.29.6/Documentation/scheduler/sched-cfs-hard-limits.txt
1063 --- linux-2.6.32.24/Documentation/scheduler/sched-cfs-hard-limits.txt 1970-01-01 01:00:00.000000000 +0100
1064 +++ linux-2.6.32.24-vs2.3.0.36.29.6/Documentation/scheduler/sched-cfs-hard-limits.txt 2009-12-03 20:04:56.000000000 +0100
1066 +CPU HARD LIMITS FOR CFS GROUPS
1067 +==============================
1076 +CFS is a proportional share scheduler which tries to divide the CPU time
1077 +proportionately between tasks or groups of tasks (task group/cgroup) depending
1078 +on the priority/weight of the task or shares assigned to groups of tasks.
1079 +In CFS, a task/task group can get more than its share of CPU if there are
1080 +enough idle CPU cycles available in the system, due to the work conserving
1081 +nature of the scheduler. However in certain scenarios (like pay-per-use),
1082 +it is desirable not to provide extra time to a group even in the presence
1083 +of idle CPU cycles. This is where hard limiting can be of use.
1085 +Hard limits for task groups can be set by specifying how much CPU runtime a
1086 +group can consume within a given period. If the group consumes more CPU time
1087 +than the runtime in a given period, it gets throttled. None of the tasks of
1088 +the throttled group gets to run until the runtime of the group gets refreshed
1089 +at the beginning of the next period.
1094 +Hard limit feature adds 2 cgroup files for CFS group scheduler:
1096 +cfs_runtime_us: Hard limit for the group in microseconds.
1098 +cfs_period_us: Time period in microseconds within which hard limits is
1101 +A group gets created with default values for runtime (infinite runtime which
1102 +means hard limits disabled) and period (0.5s). Each group can set its own
1103 +values for runtime and period independent of other groups in the system.
1108 +# mount -t cgroup -ocpu none /cgroups/
1112 +# echo 250000 > cfs_runtime_us /* set a 250ms runtime or limit */
1113 +# echo 500000 > cfs_period_us /* set a 500ms period */
1114 diff -NurpP --minimal linux-2.6.32.24/Documentation/vserver/debug.txt linux-2.6.32.24-vs2.3.0.36.29.6/Documentation/vserver/debug.txt
1115 --- linux-2.6.32.24/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1116 +++ linux-2.6.32.24-vs2.3.0.36.29.6/Documentation/vserver/debug.txt 2009-12-03 20:04:56.000000000 +0100
1121 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
1122 + "vx_rmap_tgid: %p/%llx: %d -> %d"
1126 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
1127 + "FREE (%p,#%d)%c inode"
1128 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
1129 + "FREE (%p,#%d)%c %lld bytes"
1130 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
1131 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
1132 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
1133 + "rcu_free_dl_info(%p)"
1134 + 4 10 "alloc_dl_info(%p,%d) = %p"
1135 + "dealloc_dl_info(%p)"
1136 + "get_dl_info(%p[#%d.%d])"
1137 + "put_dl_info(%p[#%d.%d])"
1138 + 5 20 "alloc_dl_info(%p,%d)*"
1139 + 6 40 "__hash_dl_info: %p[#%d]"
1140 + "__unhash_dl_info: %p[#%d]"
1141 + 7 80 "locate_dl_info(%p,#%d) = %p"
1145 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
1146 + "new_dqhash: %p [#0x%08x]"
1147 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
1148 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
1149 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
1150 + "vroot_get_real_bdev not set"
1151 + 1 2 "cow_break_link(»%s«)"
1152 + "temp copy »%s«"
1153 + 2 4 "dentry_open(new): %p"
1154 + "dentry_open(old): %p"
1155 + "lookup_create(new): %p"
1157 + "path_lookup(old): %d"
1158 + "vfs_create(new): %d"
1160 + "vfs_sendfile: %d"
1161 + 3 8 "fput(new_file=%p[#%d])"
1162 + "fput(old_file=%p[#%d])"
1163 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
1164 + "vx_info_kill(%p[#%d],%d,%d)*"
1165 + 5 20 "vs_reboot(%p[#%d],%d)"
1166 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
1170 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
1171 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
1172 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
1173 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
1174 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
1175 + 6 40 "sk,egf: %p [#%d] (from %d)"
1176 + "sk,egn: %p [#%d] (from %d)"
1177 + "sk,req: %p [#%d] (from %d)"
1178 + "sk: %p [#%d] (from %d)"
1179 + "tw: %p [#%d] (from %d)"
1180 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
1181 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
1185 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
1186 + "alloc_nx_info(%d) = %p"
1187 + "create_nx_info(%d) (dynamic rejected)"
1188 + "create_nx_info(%d) = %p (already there)"
1189 + "create_nx_info(%d) = %p (new)"
1190 + "dealloc_nx_info(%p)"
1191 + 1 2 "alloc_nx_info(%d)*"
1192 + "create_nx_info(%d)*"
1193 + 2 4 "get_nx_info(%p[#%d.%d])"
1194 + "put_nx_info(%p[#%d.%d])"
1195 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
1196 + "clr_nx_info(%p[#%d.%d])"
1197 + "init_nx_info(%p[#%d.%d])"
1198 + "release_nx_info(%p[#%d.%d.%d]) %p"
1199 + "set_nx_info(%p[#%d.%d])"
1200 + 4 10 "__hash_nx_info: %p[#%d]"
1201 + "__nx_dynamic_id: [#%d]"
1202 + "__unhash_nx_info: %p[#%d.%d.%d]"
1203 + 5 20 "moved task %p into nxi:%p[#%d]"
1204 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
1205 + "task_get_nx_info(%p)"
1206 + 6 40 "nx_clear_persistent(%p[#%d])"
1210 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
1211 + 1 2 "quota_sync_dqh(%p,%d)"
1212 + "sync_dquots(%p,%d)"
1213 + "sync_dquots_dqh(%p,%d)"
1214 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
1218 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
1219 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
1220 + 4 10 "%s: (%s %s) returned %s with %d"
1224 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
1225 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
1229 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
1230 + "alloc_vx_info(%d) = %p"
1231 + "alloc_vx_info(%d)*"
1232 + "create_vx_info(%d) (dynamic rejected)"
1233 + "create_vx_info(%d) = %p (already there)"
1234 + "create_vx_info(%d) = %p (new)"
1235 + "dealloc_vx_info(%p)"
1236 + "loc_vx_info(%d) = %p (found)"
1237 + "loc_vx_info(%d) = %p (new)"
1238 + "loc_vx_info(%d) = %p (not available)"
1239 + 1 2 "create_vx_info(%d)*"
1240 + "loc_vx_info(%d)*"
1241 + 2 4 "get_vx_info(%p[#%d.%d])"
1242 + "put_vx_info(%p[#%d.%d])"
1243 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
1244 + "clr_vx_info(%p[#%d.%d])"
1245 + "init_vx_info(%p[#%d.%d])"
1246 + "release_vx_info(%p[#%d.%d.%d]) %p"
1247 + "set_vx_info(%p[#%d.%d])"
1248 + 4 10 "__hash_vx_info: %p[#%d]"
1249 + "__unhash_vx_info: %p[#%d.%d.%d]"
1250 + "__vx_dynamic_id: [#%d]"
1251 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
1252 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
1253 + "moved task %p into vxi:%p[#%d]"
1254 + "task_get_vx_info(%p)"
1255 + "vx_migrate_task(%p,%p[#%d.%d])"
1256 + 6 40 "vx_clear_persistent(%p[#%d])"
1257 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
1258 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
1259 + "vx_set_persistent(%p[#%d])"
1260 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
1261 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
1266 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
1267 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1269 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
1270 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
1271 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1272 diff -NurpP --minimal linux-2.6.32.24/drivers/block/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/drivers/block/Kconfig
1273 --- linux-2.6.32.24/drivers/block/Kconfig 2009-09-10 15:25:49.000000000 +0200
1274 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/block/Kconfig 2009-12-03 20:04:56.000000000 +0100
1275 @@ -271,6 +271,13 @@ config BLK_DEV_CRYPTOLOOP
1276 instead, which can be configured to be on-disk compatible with the
1279 +config BLK_DEV_VROOT
1280 + tristate "Virtual Root device support"
1281 + depends on QUOTACTL
1283 + Saying Y here will allow you to use quota/fs ioctls on a shared
1284 + partition within a virtual server without compromising security.
1287 tristate "Network block device support"
1289 diff -NurpP --minimal linux-2.6.32.24/drivers/block/loop.c linux-2.6.32.24-vs2.3.0.36.29.6/drivers/block/loop.c
1290 --- linux-2.6.32.24/drivers/block/loop.c 2010-10-04 08:55:57.000000000 +0200
1291 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/block/loop.c 2010-08-19 17:35:34.000000000 +0200
1293 #include <linux/gfp.h>
1294 #include <linux/kthread.h>
1295 #include <linux/splice.h>
1296 +#include <linux/vs_context.h>
1298 #include <asm/uaccess.h>
1300 @@ -814,6 +815,7 @@ static int loop_set_fd(struct loop_devic
1301 lo->lo_blocksize = lo_blocksize;
1302 lo->lo_device = bdev;
1303 lo->lo_flags = lo_flags;
1304 + lo->lo_xid = vx_current_xid();
1305 lo->lo_backing_file = file;
1306 lo->transfer = transfer_none;
1308 @@ -939,6 +941,7 @@ static int loop_clr_fd(struct loop_devic
1309 lo->lo_encrypt_key_size = 0;
1311 lo->lo_thread = NULL;
1313 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1314 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1315 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1316 @@ -973,7 +976,7 @@ loop_set_status(struct loop_device *lo,
1318 if (lo->lo_encrypt_key_size &&
1319 lo->lo_key_owner != uid &&
1320 - !capable(CAP_SYS_ADMIN))
1321 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1323 if (lo->lo_state != Lo_bound)
1325 @@ -1057,7 +1060,8 @@ loop_get_status(struct loop_device *lo,
1326 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1327 info->lo_encrypt_type =
1328 lo->lo_encryption ? lo->lo_encryption->number : 0;
1329 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1330 + if (lo->lo_encrypt_key_size &&
1331 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1332 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1333 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1334 lo->lo_encrypt_key_size);
1335 @@ -1401,6 +1405,9 @@ static int lo_open(struct block_device *
1337 struct loop_device *lo = bdev->bd_disk->private_data;
1339 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1342 mutex_lock(&lo->lo_ctl_mutex);
1344 mutex_unlock(&lo->lo_ctl_mutex);
1345 diff -NurpP --minimal linux-2.6.32.24/drivers/block/Makefile linux-2.6.32.24-vs2.3.0.36.29.6/drivers/block/Makefile
1346 --- linux-2.6.32.24/drivers/block/Makefile 2009-09-10 15:25:49.000000000 +0200
1347 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/block/Makefile 2009-12-03 20:04:56.000000000 +0100
1348 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1349 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1350 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1351 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1352 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1354 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1356 diff -NurpP --minimal linux-2.6.32.24/drivers/block/vroot.c linux-2.6.32.24-vs2.3.0.36.29.6/drivers/block/vroot.c
1357 --- linux-2.6.32.24/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1358 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/block/vroot.c 2009-12-03 20:04:56.000000000 +0100
1361 + * linux/drivers/block/vroot.c
1363 + * written by Herbert Pötzl, 9/11/2002
1364 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1366 + * based on the loop.c code by Theodore Ts'o.
1368 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1369 + * Redistribution of this file is permitted under the
1370 + * GNU General Public License.
1374 +#include <linux/module.h>
1375 +#include <linux/moduleparam.h>
1376 +#include <linux/file.h>
1377 +#include <linux/major.h>
1378 +#include <linux/blkdev.h>
1380 +#include <linux/vroot.h>
1381 +#include <linux/vs_context.h>
1384 +static int max_vroot = 8;
1386 +static struct vroot_device *vroot_dev;
1387 +static struct gendisk **disks;
1390 +static int vroot_set_dev(
1391 + struct vroot_device *vr,
1392 + struct block_device *bdev,
1395 + struct block_device *real_bdev;
1396 + struct file *file;
1397 + struct inode *inode;
1401 + if (vr->vr_state != Vr_unbound)
1410 + inode = file->f_dentry->d_inode;
1413 + if (S_ISBLK(inode->i_mode)) {
1414 + real_bdev = inode->i_bdev;
1415 + vr->vr_device = real_bdev;
1416 + __iget(real_bdev->bd_inode);
1420 + vxdprintk(VXD_CBIT(misc, 0),
1421 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1422 + vr->vr_number, VXD_DEV(real_bdev));
1424 + vr->vr_state = Vr_bound;
1433 +static int vroot_clr_dev(
1434 + struct vroot_device *vr,
1435 + struct block_device *bdev)
1437 + struct block_device *real_bdev;
1439 + if (vr->vr_state != Vr_bound)
1441 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1444 + real_bdev = vr->vr_device;
1446 + vxdprintk(VXD_CBIT(misc, 0),
1447 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1448 + vr->vr_number, VXD_DEV(real_bdev));
1451 + vr->vr_state = Vr_unbound;
1452 + vr->vr_device = NULL;
1457 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1458 + unsigned int cmd, unsigned long arg)
1460 + struct vroot_device *vr = bdev->bd_disk->private_data;
1463 + down(&vr->vr_ctl_mutex);
1465 + case VROOT_SET_DEV:
1466 + err = vroot_set_dev(vr, bdev, arg);
1468 + case VROOT_CLR_DEV:
1469 + err = vroot_clr_dev(vr, bdev);
1475 + up(&vr->vr_ctl_mutex);
1479 +static int vr_open(struct block_device *bdev, fmode_t mode)
1481 + struct vroot_device *vr = bdev->bd_disk->private_data;
1483 + down(&vr->vr_ctl_mutex);
1485 + up(&vr->vr_ctl_mutex);
1489 +static int vr_release(struct gendisk *disk, fmode_t mode)
1491 + struct vroot_device *vr = disk->private_data;
1493 + down(&vr->vr_ctl_mutex);
1495 + up(&vr->vr_ctl_mutex);
1499 +static struct block_device_operations vr_fops = {
1500 + .owner = THIS_MODULE,
1502 + .release = vr_release,
1503 + .ioctl = vr_ioctl,
1506 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1508 + struct inode *inode = bdev->bd_inode;
1509 + struct vroot_device *vr;
1510 + struct block_device *real_bdev;
1511 + int minor = iminor(inode);
1513 + vr = &vroot_dev[minor];
1514 + real_bdev = vr->vr_device;
1516 + vxdprintk(VXD_CBIT(misc, 0),
1517 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1518 + vr->vr_number, VXD_DEV(real_bdev));
1520 + if (vr->vr_state != Vr_bound)
1521 + return ERR_PTR(-ENXIO);
1523 + __iget(real_bdev->bd_inode);
1528 + * And now the modules code and kernel interface.
1531 +module_param(max_vroot, int, 0);
1533 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1534 +MODULE_LICENSE("GPL");
1535 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1537 +MODULE_AUTHOR ("Herbert Pötzl");
1538 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1541 +int __init vroot_init(void)
1545 + if (max_vroot < 1 || max_vroot > 256) {
1546 + max_vroot = MAX_VROOT_DEFAULT;
1547 + printk(KERN_WARNING "vroot: invalid max_vroot "
1548 + "(must be between 1 and 256), "
1549 + "using default (%d)\n", max_vroot);
1552 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1556 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1559 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1561 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1565 + for (i = 0; i < max_vroot; i++) {
1566 + disks[i] = alloc_disk(1);
1569 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1570 + if (!disks[i]->queue)
1574 + for (i = 0; i < max_vroot; i++) {
1575 + struct vroot_device *vr = &vroot_dev[i];
1576 + struct gendisk *disk = disks[i];
1578 + memset(vr, 0, sizeof(*vr));
1579 + init_MUTEX(&vr->vr_ctl_mutex);
1580 + vr->vr_number = i;
1581 + disk->major = VROOT_MAJOR;
1582 + disk->first_minor = i;
1583 + disk->fops = &vr_fops;
1584 + sprintf(disk->disk_name, "vroot%d", i);
1585 + disk->private_data = vr;
1588 + err = register_vroot_grb(&__vroot_get_real_bdev);
1592 + for (i = 0; i < max_vroot; i++)
1593 + add_disk(disks[i]);
1594 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1599 + put_disk(disks[i]);
1604 + unregister_blkdev(VROOT_MAJOR, "vroot");
1605 + printk(KERN_ERR "vroot: ran out of memory\n");
1609 +void vroot_exit(void)
1613 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1614 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1616 + for (i = 0; i < max_vroot; i++) {
1617 + del_gendisk(disks[i]);
1618 + put_disk(disks[i]);
1620 + unregister_blkdev(VROOT_MAJOR, "vroot");
1626 +module_init(vroot_init);
1627 +module_exit(vroot_exit);
1631 +static int __init max_vroot_setup(char *str)
1633 + max_vroot = simple_strtol(str, NULL, 0);
1637 +__setup("max_vroot=", max_vroot_setup);
1641 diff -NurpP --minimal linux-2.6.32.24/drivers/char/sysrq.c linux-2.6.32.24-vs2.3.0.36.29.6/drivers/char/sysrq.c
1642 --- linux-2.6.32.24/drivers/char/sysrq.c 2009-12-03 20:02:20.000000000 +0100
1643 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/char/sysrq.c 2009-12-03 20:04:56.000000000 +0100
1645 #include <linux/workqueue.h>
1646 #include <linux/hrtimer.h>
1647 #include <linux/oom.h>
1648 +#include <linux/vserver/debug.h>
1650 #include <asm/ptrace.h>
1651 #include <asm/irq_regs.h>
1652 @@ -391,6 +392,21 @@ static struct sysrq_key_op sysrq_unrt_op
1653 .enable_mask = SYSRQ_ENABLE_RTNICE,
1657 +#ifdef CONFIG_VSERVER_DEBUG
1658 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
1660 + dump_vx_info_inactive((key == 'x')?0:1);
1663 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1664 + .handler = sysrq_handle_vxinfo,
1665 + .help_msg = "conteXt",
1666 + .action_msg = "Show Context Info",
1667 + .enable_mask = SYSRQ_ENABLE_DUMP,
1671 /* Key Operations table and lock */
1672 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1674 @@ -445,7 +461,11 @@ static struct sysrq_key_op *sysrq_key_ta
1676 &sysrq_showstate_blocked_op, /* w */
1677 /* x: May be registered on ppc/powerpc for xmon */
1678 +#ifdef CONFIG_VSERVER_DEBUG
1679 + &sysrq_showvxinfo_op, /* x */
1683 /* y: May be registered on sparc64 for global register dump */
1685 &sysrq_ftrace_dump_op, /* z */
1686 @@ -460,6 +480,8 @@ static int sysrq_key_table_key2index(int
1688 else if ((key >= 'a') && (key <= 'z'))
1689 retval = key + 10 - 'a';
1690 + else if ((key >= 'A') && (key <= 'Z'))
1691 + retval = key + 10 - 'A';
1695 diff -NurpP --minimal linux-2.6.32.24/drivers/char/tty_io.c linux-2.6.32.24-vs2.3.0.36.29.6/drivers/char/tty_io.c
1696 --- linux-2.6.32.24/drivers/char/tty_io.c 2010-10-04 08:55:58.000000000 +0200
1697 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/char/tty_io.c 2010-08-19 17:41:20.000000000 +0200
1700 #include <linux/kmod.h>
1701 #include <linux/nsproxy.h>
1702 +#include <linux/vs_pid.h>
1704 #undef TTY_DEBUG_HANGUP
1706 @@ -1970,7 +1971,8 @@ static int tiocsti(struct tty_struct *tt
1708 struct tty_ldisc *ld;
1710 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1711 + if (((current->signal->tty != tty) &&
1712 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1714 if (get_user(ch, p))
1716 @@ -2258,6 +2260,7 @@ static int tiocspgrp(struct tty_struct *
1718 if (get_user(pgrp_nr, p))
1720 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1724 diff -NurpP --minimal linux-2.6.32.24/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.32.24-vs2.3.0.36.29.6/drivers/infiniband/hw/ipath/ipath_user_pages.c
1725 --- linux-2.6.32.24/drivers/infiniband/hw/ipath/ipath_user_pages.c 2009-12-03 20:02:23.000000000 +0100
1726 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/infiniband/hw/ipath/ipath_user_pages.c 2009-12-04 23:31:17.000000000 +0100
1728 #include <linux/mm.h>
1729 #include <linux/device.h>
1730 #include <linux/sched.h>
1731 +#include <linux/vs_memory.h>
1733 #include "ipath_kernel.h"
1735 @@ -62,7 +63,8 @@ static int __get_user_pages(unsigned lon
1736 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
1739 - if (num_pages > lock_limit) {
1740 + if (num_pages > lock_limit ||
1741 + !vx_vmlocked_avail(current->mm, num_pages)) {
1745 @@ -79,7 +81,7 @@ static int __get_user_pages(unsigned lon
1749 - current->mm->locked_vm += num_pages;
1750 + vx_vmlocked_add(current->mm, num_pages);
1754 @@ -178,7 +180,7 @@ void ipath_release_user_pages(struct pag
1756 __ipath_release_user_pages(p, num_pages, 1);
1758 - current->mm->locked_vm -= num_pages;
1759 + vx_vmlocked_sub(current->mm, num_pages);
1761 up_write(¤t->mm->mmap_sem);
1763 @@ -195,7 +197,7 @@ static void user_pages_account(struct wo
1764 container_of(_work, struct ipath_user_pages_work, work);
1766 down_write(&work->mm->mmap_sem);
1767 - work->mm->locked_vm -= work->num_pages;
1768 + vx_vmlocked_sub(work->mm, work->num_pages);
1769 up_write(&work->mm->mmap_sem);
1772 diff -NurpP --minimal linux-2.6.32.24/drivers/md/dm.c linux-2.6.32.24-vs2.3.0.36.29.6/drivers/md/dm.c
1773 --- linux-2.6.32.24/drivers/md/dm.c 2010-10-04 08:56:01.000000000 +0200
1774 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/md/dm.c 2010-04-28 10:19:30.000000000 +0200
1776 #include <linux/slab.h>
1777 #include <linux/idr.h>
1778 #include <linux/hdreg.h>
1779 +#include <linux/vs_base.h>
1781 #include <trace/events/block.h>
1783 @@ -119,6 +120,7 @@ struct mapped_device {
1786 atomic_t open_count;
1789 unsigned long flags;
1791 @@ -323,6 +325,7 @@ static void __exit dm_exit(void)
1792 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1794 struct mapped_device *md;
1797 spin_lock(&_minor_lock);
1799 @@ -331,18 +334,19 @@ static int dm_blk_open(struct block_devi
1802 if (test_bit(DMF_FREEING, &md->flags) ||
1803 - test_bit(DMF_DELETING, &md->flags)) {
1805 + test_bit(DMF_DELETING, &md->flags))
1809 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1814 atomic_inc(&md->open_count);
1818 spin_unlock(&_minor_lock);
1820 - return md ? 0 : -ENXIO;
1824 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1825 @@ -553,6 +557,14 @@ int dm_set_geometry(struct mapped_device
1830 + * Get the xid associated with a dm device
1832 +xid_t dm_get_xid(struct mapped_device *md)
1837 /*-----------------------------------------------------------------
1839 * A more elegant soln is in the works that uses the queue
1840 @@ -1775,6 +1787,7 @@ static struct mapped_device *alloc_dev(i
1841 INIT_LIST_HEAD(&md->uevent_list);
1842 spin_lock_init(&md->uevent_lock);
1844 + md->xid = vx_current_xid();
1845 md->queue = blk_init_queue(dm_request_fn, NULL);
1848 diff -NurpP --minimal linux-2.6.32.24/drivers/md/dm.h linux-2.6.32.24-vs2.3.0.36.29.6/drivers/md/dm.h
1849 --- linux-2.6.32.24/drivers/md/dm.h 2009-09-10 15:25:55.000000000 +0200
1850 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/md/dm.h 2009-12-03 20:04:56.000000000 +0100
1851 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1853 struct dm_md_mempools;
1855 +xid_t dm_get_xid(struct mapped_device *md);
1857 /*-----------------------------------------------------------------
1858 * Internal table functions.
1859 *---------------------------------------------------------------*/
1860 diff -NurpP --minimal linux-2.6.32.24/drivers/md/dm-ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/drivers/md/dm-ioctl.c
1861 --- linux-2.6.32.24/drivers/md/dm-ioctl.c 2010-10-04 08:56:01.000000000 +0200
1862 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/md/dm-ioctl.c 2010-09-05 21:24:17.000000000 +0200
1864 #include <linux/dm-ioctl.h>
1865 #include <linux/hdreg.h>
1866 #include <linux/compat.h>
1867 +#include <linux/vs_context.h>
1869 #include <asm/uaccess.h>
1871 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1872 unsigned int h = hash_str(str);
1874 list_for_each_entry (hc, _name_buckets + h, name_list)
1875 - if (!strcmp(hc->name, str)) {
1876 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1877 + !strcmp(hc->name, str)) {
1881 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1882 unsigned int h = hash_str(str);
1884 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1885 - if (!strcmp(hc->uuid, str)) {
1886 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1887 + !strcmp(hc->uuid, str)) {
1891 @@ -369,6 +372,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1893 static int remove_all(struct dm_ioctl *param, size_t param_size)
1895 + if (!vx_check(0, VS_ADMIN))
1898 dm_hash_remove_all(1);
1899 param->data_size = 0;
1901 @@ -416,6 +422,8 @@ static int list_devices(struct dm_ioctl
1903 for (i = 0; i < NUM_BUCKETS; i++) {
1904 list_for_each_entry (hc, _name_buckets + i, name_list) {
1905 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1907 needed += sizeof(struct dm_name_list);
1908 needed += strlen(hc->name) + 1;
1909 needed += ALIGN_MASK;
1910 @@ -439,6 +447,8 @@ static int list_devices(struct dm_ioctl
1912 for (i = 0; i < NUM_BUCKETS; i++) {
1913 list_for_each_entry (hc, _name_buckets + i, name_list) {
1914 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1917 old_nl->next = (uint32_t) ((void *) nl -
1919 @@ -629,10 +639,11 @@ static struct hash_cell *__find_device_h
1923 - mdptr = dm_get_mdptr(md);
1924 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1925 + mdptr = dm_get_mdptr(md);
1933 @@ -1462,8 +1473,8 @@ static int ctl_ioctl(uint command, struc
1937 - /* only root can play with this */
1938 - if (!capable(CAP_SYS_ADMIN))
1939 + /* only root and certain contexts can play with this */
1940 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1943 if (_IOC_TYPE(command) != DM_IOCTL)
1944 diff -NurpP --minimal linux-2.6.32.24/drivers/net/tun.c linux-2.6.32.24-vs2.3.0.36.29.6/drivers/net/tun.c
1945 --- linux-2.6.32.24/drivers/net/tun.c 2010-10-04 08:56:04.000000000 +0200
1946 +++ linux-2.6.32.24-vs2.3.0.36.29.6/drivers/net/tun.c 2010-09-22 00:48:38.000000000 +0200
1948 #include <linux/crc32.h>
1949 #include <linux/nsproxy.h>
1950 #include <linux/virtio_net.h>
1951 +#include <linux/vs_network.h>
1952 #include <net/net_namespace.h>
1953 #include <net/netns/generic.h>
1954 #include <net/rtnetlink.h>
1955 @@ -102,6 +103,7 @@ struct tun_struct {
1961 struct net_device *dev;
1962 struct fasync_struct *fasync;
1963 @@ -816,6 +818,7 @@ static void tun_setup(struct net_device
1967 + tun->nid = current->nid;
1969 dev->ethtool_ops = &tun_ethtool_ops;
1970 dev->destructor = tun_free_netdev;
1971 @@ -932,7 +935,7 @@ static int tun_set_iff(struct net *net,
1973 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1974 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1975 - !capable(CAP_NET_ADMIN))
1976 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1978 err = security_tun_dev_attach(tun->socket.sk);
1980 @@ -946,7 +949,7 @@ static int tun_set_iff(struct net *net,
1982 unsigned long flags = 0;
1984 - if (!capable(CAP_NET_ADMIN))
1985 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1987 err = security_tun_dev_create();
1989 @@ -1014,6 +1017,9 @@ static int tun_set_iff(struct net *net,
1991 sk->sk_destruct = tun_sock_destruct;
1993 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1996 err = tun_attach(tun, file);
1999 @@ -1203,6 +1209,16 @@ static long tun_chr_ioctl(struct file *f
2000 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
2004 + if (!capable(CAP_CONTEXT))
2007 + /* Set nid owner of the device */
2008 + tun->nid = (nid_t) arg;
2010 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
2014 /* Only allow setting the type when the interface is down */
2015 if (tun->dev->flags & IFF_UP) {
2016 diff -NurpP --minimal linux-2.6.32.24/fs/attr.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/attr.c
2017 --- linux-2.6.32.24/fs/attr.c 2009-12-03 20:02:51.000000000 +0100
2018 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/attr.c 2009-12-03 20:04:56.000000000 +0100
2020 #include <linux/fcntl.h>
2021 #include <linux/quotaops.h>
2022 #include <linux/security.h>
2023 +#include <linux/proc_fs.h>
2024 +#include <linux/devpts_fs.h>
2025 +#include <linux/vs_tag.h>
2027 /* Taken over from the old code... */
2029 @@ -55,6 +58,10 @@ int inode_change_ok(const struct inode *
2030 if (!is_owner_or_cap(inode))
2034 + if (dx_permission(inode, MAY_WRITE))
2040 @@ -120,6 +127,8 @@ int inode_setattr(struct inode * inode,
2041 inode->i_uid = attr->ia_uid;
2042 if (ia_valid & ATTR_GID)
2043 inode->i_gid = attr->ia_gid;
2044 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2045 + inode->i_tag = attr->ia_tag;
2046 if (ia_valid & ATTR_ATIME)
2047 inode->i_atime = timespec_trunc(attr->ia_atime,
2048 inode->i_sb->s_time_gran);
2049 @@ -214,7 +223,8 @@ int notify_change(struct dentry * dentry
2050 error = inode_change_ok(inode, attr);
2052 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2053 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2054 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2055 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2056 error = vfs_dq_transfer(inode, attr) ?
2059 diff -NurpP --minimal linux-2.6.32.24/fs/binfmt_aout.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/binfmt_aout.c
2060 --- linux-2.6.32.24/fs/binfmt_aout.c 2010-10-04 08:56:11.000000000 +0200
2061 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/binfmt_aout.c 2010-02-12 10:59:55.000000000 +0100
2063 #include <linux/binfmts.h>
2064 #include <linux/personality.h>
2065 #include <linux/init.h>
2066 +#include <linux/vs_memory.h>
2068 #include <asm/system.h>
2069 #include <asm/uaccess.h>
2070 diff -NurpP --minimal linux-2.6.32.24/fs/binfmt_elf.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/binfmt_elf.c
2071 --- linux-2.6.32.24/fs/binfmt_elf.c 2010-10-04 08:56:11.000000000 +0200
2072 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/binfmt_elf.c 2010-02-12 10:59:55.000000000 +0100
2074 #include <linux/random.h>
2075 #include <linux/elf.h>
2076 #include <linux/utsname.h>
2077 +#include <linux/vs_memory.h>
2078 #include <asm/uaccess.h>
2079 #include <asm/param.h>
2080 #include <asm/page.h>
2081 diff -NurpP --minimal linux-2.6.32.24/fs/binfmt_flat.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/binfmt_flat.c
2082 --- linux-2.6.32.24/fs/binfmt_flat.c 2010-10-04 08:56:11.000000000 +0200
2083 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/binfmt_flat.c 2010-02-12 10:59:55.000000000 +0100
2085 #include <linux/init.h>
2086 #include <linux/flat.h>
2087 #include <linux/syscalls.h>
2088 +#include <linux/vs_memory.h>
2090 #include <asm/byteorder.h>
2091 #include <asm/system.h>
2092 diff -NurpP --minimal linux-2.6.32.24/fs/binfmt_som.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/binfmt_som.c
2093 --- linux-2.6.32.24/fs/binfmt_som.c 2010-10-04 08:56:11.000000000 +0200
2094 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/binfmt_som.c 2010-02-12 10:59:55.000000000 +0100
2096 #include <linux/shm.h>
2097 #include <linux/personality.h>
2098 #include <linux/init.h>
2099 +#include <linux/vs_memory.h>
2101 #include <asm/uaccess.h>
2102 #include <asm/pgtable.h>
2103 diff -NurpP --minimal linux-2.6.32.24/fs/block_dev.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/block_dev.c
2104 --- linux-2.6.32.24/fs/block_dev.c 2010-10-04 08:56:11.000000000 +0200
2105 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/block_dev.c 2010-08-19 17:35:34.000000000 +0200
2107 #include <linux/namei.h>
2108 #include <linux/log2.h>
2109 #include <linux/kmemleak.h>
2110 +#include <linux/vs_device.h>
2111 #include <asm/uaccess.h>
2112 #include "internal.h"
2114 @@ -557,6 +558,7 @@ struct block_device *bdget(dev_t dev)
2115 bdev->bd_invalidated = 0;
2116 inode->i_mode = S_IFBLK;
2117 inode->i_rdev = dev;
2118 + inode->i_mdev = dev;
2119 inode->i_bdev = bdev;
2120 inode->i_data.a_ops = &def_blk_aops;
2121 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2122 @@ -603,6 +605,11 @@ EXPORT_SYMBOL(bdput);
2123 static struct block_device *bd_acquire(struct inode *inode)
2125 struct block_device *bdev;
2128 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2130 + inode->i_mdev = mdev;
2132 spin_lock(&bdev_lock);
2133 bdev = inode->i_bdev;
2134 @@ -613,7 +620,7 @@ static struct block_device *bd_acquire(s
2136 spin_unlock(&bdev_lock);
2138 - bdev = bdget(inode->i_rdev);
2139 + bdev = bdget(mdev);
2141 spin_lock(&bdev_lock);
2142 if (!inode->i_bdev) {
2143 diff -NurpP --minimal linux-2.6.32.24/fs/btrfs/ctree.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/ctree.h
2144 --- linux-2.6.32.24/fs/btrfs/ctree.h 2010-10-04 08:56:11.000000000 +0200
2145 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/ctree.h 2010-08-19 17:35:34.000000000 +0200
2146 @@ -547,11 +547,14 @@ struct btrfs_inode_item {
2147 /* modification sequence number for NFS */
2152 * a little future expansion, for more than this we can
2153 * just grow the inode item and version it
2155 - __le64 reserved[4];
2156 + __le16 reserved16;
2157 + __le32 reserved32;
2158 + __le64 reserved[3];
2159 struct btrfs_timespec atime;
2160 struct btrfs_timespec ctime;
2161 struct btrfs_timespec mtime;
2162 @@ -1162,6 +1165,8 @@ struct btrfs_root {
2163 #define BTRFS_MOUNT_NOSSD (1 << 9)
2164 #define BTRFS_MOUNT_DISCARD (1 << 10)
2166 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2168 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2169 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2170 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2171 @@ -1181,6 +1186,10 @@ struct btrfs_root {
2172 #define BTRFS_INODE_NOATIME (1 << 9)
2173 #define BTRFS_INODE_DIRSYNC (1 << 10)
2175 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2176 +#define BTRFS_INODE_BARRIER (1 << 25)
2177 +#define BTRFS_INODE_COW (1 << 26)
2180 /* some macros to generate set/get funcs for the struct fields. This
2181 * assumes there is a lefoo_to_cpu for every type, so lets make a simple
2182 @@ -1383,6 +1392,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2183 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2184 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2185 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2186 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2187 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2188 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2189 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2190 @@ -2356,6 +2366,7 @@ extern const struct dentry_operations bt
2191 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2192 void btrfs_update_iflags(struct inode *inode);
2193 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2194 +int btrfs_sync_flags(struct inode *inode, int, int);
2197 int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
2198 diff -NurpP --minimal linux-2.6.32.24/fs/btrfs/disk-io.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/disk-io.c
2199 --- linux-2.6.32.24/fs/btrfs/disk-io.c 2010-10-04 08:56:11.000000000 +0200
2200 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/disk-io.c 2010-08-19 17:35:34.000000000 +0200
2201 @@ -1726,6 +1726,9 @@ struct btrfs_root *open_ctree(struct sup
2205 + if (btrfs_test_opt(tree_root, TAGGED))
2206 + sb->s_flags |= MS_TAGGED;
2208 features = btrfs_super_incompat_flags(disk_super) &
2209 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2211 diff -NurpP --minimal linux-2.6.32.24/fs/btrfs/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/inode.c
2212 --- linux-2.6.32.24/fs/btrfs/inode.c 2010-10-04 08:56:11.000000000 +0200
2213 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/inode.c 2010-08-19 17:35:34.000000000 +0200
2215 #include <linux/xattr.h>
2216 #include <linux/posix_acl.h>
2217 #include <linux/falloc.h>
2218 +#include <linux/vs_tag.h>
2222 #include "disk-io.h"
2223 @@ -2263,6 +2265,8 @@ static void btrfs_read_locked_inode(stru
2225 u64 alloc_group_block;
2231 path = btrfs_alloc_path();
2232 @@ -2279,8 +2283,13 @@ static void btrfs_read_locked_inode(stru
2234 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2235 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2236 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2237 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2239 + uid = btrfs_inode_uid(leaf, inode_item);
2240 + gid = btrfs_inode_gid(leaf, inode_item);
2241 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2242 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2243 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2244 + btrfs_inode_tag(leaf, inode_item));
2245 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2247 tspec = btrfs_inode_atime(inode_item);
2248 @@ -2362,8 +2371,15 @@ static void fill_inode_item(struct btrfs
2249 struct btrfs_inode_item *item,
2250 struct inode *inode)
2252 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2253 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2254 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2255 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2257 + btrfs_set_inode_uid(leaf, item, uid);
2258 + btrfs_set_inode_gid(leaf, item, gid);
2259 +#ifdef CONFIG_TAGGING_INTERN
2260 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2263 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2264 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2265 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2266 @@ -4153,6 +4169,7 @@ static struct inode *btrfs_new_inode(str
2268 inode->i_gid = current_fsgid();
2270 + inode->i_tag = dx_current_fstag(root->fs_info->sb);
2271 inode->i_mode = mode;
2272 inode->i_ino = objectid;
2273 inode_set_bytes(inode, 0);
2274 @@ -5954,6 +5971,7 @@ static const struct inode_operations btr
2275 .listxattr = btrfs_listxattr,
2276 .removexattr = btrfs_removexattr,
2277 .permission = btrfs_permission,
2278 + .sync_flags = btrfs_sync_flags,
2280 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2281 .lookup = btrfs_lookup,
2282 @@ -6029,6 +6047,7 @@ static const struct inode_operations btr
2283 .permission = btrfs_permission,
2284 .fallocate = btrfs_fallocate,
2285 .fiemap = btrfs_fiemap,
2286 + .sync_flags = btrfs_sync_flags,
2288 static const struct inode_operations btrfs_special_inode_operations = {
2289 .getattr = btrfs_getattr,
2290 diff -NurpP --minimal linux-2.6.32.24/fs/btrfs/ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/ioctl.c
2291 --- linux-2.6.32.24/fs/btrfs/ioctl.c 2010-10-04 08:56:11.000000000 +0200
2292 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/ioctl.c 2010-08-19 17:35:34.000000000 +0200
2293 @@ -67,10 +67,13 @@ static unsigned int btrfs_flags_to_ioctl
2295 unsigned int iflags = 0;
2297 - if (flags & BTRFS_INODE_SYNC)
2298 - iflags |= FS_SYNC_FL;
2299 if (flags & BTRFS_INODE_IMMUTABLE)
2300 iflags |= FS_IMMUTABLE_FL;
2301 + if (flags & BTRFS_INODE_IXUNLINK)
2302 + iflags |= FS_IXUNLINK_FL;
2304 + if (flags & BTRFS_INODE_SYNC)
2305 + iflags |= FS_SYNC_FL;
2306 if (flags & BTRFS_INODE_APPEND)
2307 iflags |= FS_APPEND_FL;
2308 if (flags & BTRFS_INODE_NODUMP)
2309 @@ -80,28 +83,78 @@ static unsigned int btrfs_flags_to_ioctl
2310 if (flags & BTRFS_INODE_DIRSYNC)
2311 iflags |= FS_DIRSYNC_FL;
2313 + if (flags & BTRFS_INODE_BARRIER)
2314 + iflags |= FS_BARRIER_FL;
2315 + if (flags & BTRFS_INODE_COW)
2316 + iflags |= FS_COW_FL;
2321 - * Update inode->i_flags based on the btrfs internal flags.
2322 + * Update inode->i_(v)flags based on the btrfs internal flags.
2324 void btrfs_update_iflags(struct inode *inode)
2326 struct btrfs_inode *ip = BTRFS_I(inode);
2328 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2329 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2330 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2332 - if (ip->flags & BTRFS_INODE_SYNC)
2333 - inode->i_flags |= S_SYNC;
2334 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2335 inode->i_flags |= S_IMMUTABLE;
2336 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2337 + inode->i_flags |= S_IXUNLINK;
2339 + if (ip->flags & BTRFS_INODE_SYNC)
2340 + inode->i_flags |= S_SYNC;
2341 if (ip->flags & BTRFS_INODE_APPEND)
2342 inode->i_flags |= S_APPEND;
2343 if (ip->flags & BTRFS_INODE_NOATIME)
2344 inode->i_flags |= S_NOATIME;
2345 if (ip->flags & BTRFS_INODE_DIRSYNC)
2346 inode->i_flags |= S_DIRSYNC;
2348 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2350 + if (ip->flags & BTRFS_INODE_BARRIER)
2351 + inode->i_vflags |= V_BARRIER;
2352 + if (ip->flags & BTRFS_INODE_COW)
2353 + inode->i_vflags |= V_COW;
2357 + * Update btrfs internal flags from inode->i_(v)flags.
2359 +void btrfs_update_flags(struct inode *inode)
2361 + struct btrfs_inode *ip = BTRFS_I(inode);
2363 + unsigned int flags = inode->i_flags;
2364 + unsigned int vflags = inode->i_vflags;
2366 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2367 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2368 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2369 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2371 + if (flags & S_IMMUTABLE)
2372 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2373 + if (flags & S_IXUNLINK)
2374 + ip->flags |= BTRFS_INODE_IXUNLINK;
2376 + if (flags & S_SYNC)
2377 + ip->flags |= BTRFS_INODE_SYNC;
2378 + if (flags & S_APPEND)
2379 + ip->flags |= BTRFS_INODE_APPEND;
2380 + if (flags & S_NOATIME)
2381 + ip->flags |= BTRFS_INODE_NOATIME;
2382 + if (flags & S_DIRSYNC)
2383 + ip->flags |= BTRFS_INODE_DIRSYNC;
2385 + if (vflags & V_BARRIER)
2386 + ip->flags |= BTRFS_INODE_BARRIER;
2387 + if (vflags & V_COW)
2388 + ip->flags |= BTRFS_INODE_COW;
2392 @@ -119,7 +172,7 @@ void btrfs_inherit_iflags(struct inode *
2393 flags = BTRFS_I(dir)->flags;
2395 if (S_ISREG(inode->i_mode))
2396 - flags &= ~BTRFS_INODE_DIRSYNC;
2397 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2398 else if (!S_ISDIR(inode->i_mode))
2399 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2401 @@ -127,6 +180,30 @@ void btrfs_inherit_iflags(struct inode *
2402 btrfs_update_iflags(inode);
2405 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2407 + struct btrfs_inode *ip = BTRFS_I(inode);
2408 + struct btrfs_root *root = ip->root;
2409 + struct btrfs_trans_handle *trans;
2412 + trans = btrfs_join_transaction(root, 1);
2415 + inode->i_flags = flags;
2416 + inode->i_vflags = vflags;
2417 + btrfs_update_flags(inode);
2419 + ret = btrfs_update_inode(trans, root, inode);
2422 + btrfs_update_iflags(inode);
2423 + inode->i_ctime = CURRENT_TIME;
2424 + btrfs_end_transaction(trans, root);
2429 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2431 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2432 @@ -149,6 +226,7 @@ static int btrfs_ioctl_setflags(struct f
2433 if (copy_from_user(&flags, arg, sizeof(flags)))
2436 + /* maybe add FS_IXUNLINK_FL ? */
2437 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2438 FS_NOATIME_FL | FS_NODUMP_FL | \
2439 FS_SYNC_FL | FS_DIRSYNC_FL))
2440 @@ -161,7 +239,8 @@ static int btrfs_ioctl_setflags(struct f
2442 flags = btrfs_mask_flags(inode->i_mode, flags);
2443 oldflags = btrfs_flags_to_ioctl(ip->flags);
2444 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2445 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2446 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2447 if (!capable(CAP_LINUX_IMMUTABLE)) {
2450 @@ -172,14 +251,19 @@ static int btrfs_ioctl_setflags(struct f
2454 - if (flags & FS_SYNC_FL)
2455 - ip->flags |= BTRFS_INODE_SYNC;
2457 - ip->flags &= ~BTRFS_INODE_SYNC;
2458 if (flags & FS_IMMUTABLE_FL)
2459 ip->flags |= BTRFS_INODE_IMMUTABLE;
2461 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2462 + if (flags & FS_IXUNLINK_FL)
2463 + ip->flags |= BTRFS_INODE_IXUNLINK;
2465 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2467 + if (flags & FS_SYNC_FL)
2468 + ip->flags |= BTRFS_INODE_SYNC;
2470 + ip->flags &= ~BTRFS_INODE_SYNC;
2471 if (flags & FS_APPEND_FL)
2472 ip->flags |= BTRFS_INODE_APPEND;
2474 diff -NurpP --minimal linux-2.6.32.24/fs/btrfs/super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/super.c
2475 --- linux-2.6.32.24/fs/btrfs/super.c 2010-10-04 08:56:12.000000000 +0200
2476 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/btrfs/super.c 2010-08-19 17:38:42.000000000 +0200
2477 @@ -67,7 +67,7 @@ enum {
2478 Opt_max_extent, Opt_max_inline, Opt_alloc_start, Opt_nobarrier,
2479 Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl,
2480 Opt_compress, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
2481 - Opt_discard, Opt_err,
2482 + Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
2485 static match_table_t tokens = {
2486 @@ -90,6 +90,9 @@ static match_table_t tokens = {
2487 {Opt_flushoncommit, "flushoncommit"},
2488 {Opt_ratio, "metadata_ratio=%d"},
2489 {Opt_discard, "discard"},
2491 + {Opt_notag, "notag"},
2492 + {Opt_tagid, "tagid=%u"},
2496 @@ -264,6 +267,22 @@ int btrfs_parse_options(struct btrfs_roo
2498 btrfs_set_opt(info->mount_opt, DISCARD);
2500 +#ifndef CONFIG_TAGGING_NONE
2502 + printk(KERN_INFO "btrfs: use tagging\n");
2503 + btrfs_set_opt(info->mount_opt, TAGGED);
2506 + printk(KERN_INFO "btrfs: disabled tagging\n");
2507 + btrfs_clear_opt(info->mount_opt, TAGGED);
2510 +#ifdef CONFIG_PROPAGATE
2513 + btrfs_set_opt(info->mount_opt, TAGGED);
2517 printk(KERN_INFO "btrfs: unrecognized mount option "
2519 @@ -585,6 +604,12 @@ static int btrfs_remount(struct super_bl
2523 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2524 + printk("btrfs: %s: tagging not permitted on remount.\n",
2529 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2532 diff -NurpP --minimal linux-2.6.32.24/fs/char_dev.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/char_dev.c
2533 --- linux-2.6.32.24/fs/char_dev.c 2010-10-04 08:56:12.000000000 +0200
2534 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/char_dev.c 2010-10-04 10:04:57.000000000 +0200
2536 #include <linux/cdev.h>
2537 #include <linux/mutex.h>
2538 #include <linux/backing-dev.h>
2539 +#include <linux/vs_context.h>
2540 +#include <linux/vs_device.h>
2542 #include "internal.h"
2544 @@ -370,14 +372,21 @@ static int chrdev_open(struct inode *ino
2546 struct cdev *new = NULL;
2550 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2552 + inode->i_mdev = mdev;
2554 spin_lock(&cdev_lock);
2557 struct kobject *kobj;
2560 spin_unlock(&cdev_lock);
2561 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2563 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2566 new = container_of(kobj, struct cdev, kobj);
2567 diff -NurpP --minimal linux-2.6.32.24/fs/dcache.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/dcache.c
2568 --- linux-2.6.32.24/fs/dcache.c 2009-12-03 20:02:51.000000000 +0100
2569 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/dcache.c 2009-12-03 20:04:56.000000000 +0100
2571 #include <linux/bootmem.h>
2572 #include <linux/fs_struct.h>
2573 #include <linux/hardirq.h>
2574 +#include <linux/vs_limit.h>
2575 #include "internal.h"
2577 int sysctl_vfs_cache_pressure __read_mostly = 100;
2578 @@ -230,6 +231,8 @@ repeat:
2582 + vx_dentry_dec(dentry);
2585 * AV: ->d_delete() is _NOT_ allowed to block now.
2587 @@ -321,6 +324,7 @@ static inline struct dentry * __dget_loc
2589 atomic_inc(&dentry->d_count);
2590 dentry_lru_del_init(dentry);
2591 + vx_dentry_inc(dentry);
2595 @@ -919,6 +923,9 @@ struct dentry *d_alloc(struct dentry * p
2596 struct dentry *dentry;
2599 + if (!vx_dentry_avail(1))
2602 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2605 @@ -964,6 +971,7 @@ struct dentry *d_alloc(struct dentry * p
2607 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2608 dentry_stat.nr_dentry++;
2609 + vx_dentry_inc(dentry);
2610 spin_unlock(&dcache_lock);
2613 @@ -1407,6 +1415,7 @@ struct dentry * __d_lookup(struct dentry
2616 atomic_inc(&dentry->d_count);
2617 + vx_dentry_inc(dentry);
2619 spin_unlock(&dentry->d_lock);
2621 diff -NurpP --minimal linux-2.6.32.24/fs/devpts/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/devpts/inode.c
2622 --- linux-2.6.32.24/fs/devpts/inode.c 2010-10-04 08:56:12.000000000 +0200
2623 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/devpts/inode.c 2009-12-29 00:36:26.000000000 +0100
2625 #include <linux/parser.h>
2626 #include <linux/fsnotify.h>
2627 #include <linux/seq_file.h>
2628 +#include <linux/vs_base.h>
2630 #define DEVPTS_DEFAULT_MODE 0600
2633 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2634 #define PTMX_MINOR 2
2636 +static int devpts_permission(struct inode *inode, int mask)
2638 + int ret = -EACCES;
2640 + /* devpts is xid tagged */
2641 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2642 + ret = generic_permission(inode, mask, NULL);
2646 +static struct inode_operations devpts_file_inode_operations = {
2647 + .permission = devpts_permission,
2650 extern int pty_limit; /* Config limit on Unix98 ptys */
2651 static DEFINE_MUTEX(allocated_ptys_lock);
2653 @@ -262,6 +277,25 @@ static int devpts_show_options(struct se
2657 +static int devpts_filter(struct dentry *de)
2659 + /* devpts is xid tagged */
2660 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2663 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2665 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2668 +static struct file_operations devpts_dir_operations = {
2669 + .open = dcache_dir_open,
2670 + .release = dcache_dir_close,
2671 + .llseek = dcache_dir_lseek,
2672 + .read = generic_read_dir,
2673 + .readdir = devpts_readdir,
2676 static const struct super_operations devpts_sops = {
2677 .statfs = simple_statfs,
2678 .remount_fs = devpts_remount,
2679 @@ -301,12 +335,15 @@ devpts_fill_super(struct super_block *s,
2680 inode = new_inode(s);
2685 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2686 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2687 inode->i_op = &simple_dir_inode_operations;
2688 - inode->i_fop = &simple_dir_operations;
2689 + inode->i_fop = &devpts_dir_operations;
2691 + /* devpts is xid tagged */
2692 + inode->i_tag = (tag_t)vx_current_xid();
2694 s->s_root = d_alloc_root(inode);
2696 @@ -497,6 +534,9 @@ int devpts_pty_new(struct inode *ptmx_in
2697 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2698 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2699 init_special_inode(inode, S_IFCHR|opts->mode, device);
2700 + /* devpts is xid tagged */
2701 + inode->i_tag = (tag_t)vx_current_xid();
2702 + inode->i_op = &devpts_file_inode_operations;
2703 inode->i_private = tty;
2704 tty->driver_data = inode;
2706 diff -NurpP --minimal linux-2.6.32.24/fs/exec.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/exec.c
2707 --- linux-2.6.32.24/fs/exec.c 2010-10-04 08:56:12.000000000 +0200
2708 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/exec.c 2010-05-27 19:21:36.000000000 +0200
2709 @@ -251,7 +251,9 @@ static int __bprm_mm_init(struct linux_b
2713 - mm->stack_vm = mm->total_vm = 1;
2715 + vx_vmpages_inc(mm);
2717 up_write(&mm->mmap_sem);
2718 bprm->p = vma->vm_end - sizeof(void *);
2720 @@ -1494,7 +1496,7 @@ static int format_corename(char *corenam
2721 /* UNIX time of coredump */
2724 - do_gettimeofday(&tv);
2725 + vx_gettimeofday(&tv);
2726 rc = snprintf(out_ptr, out_end - out_ptr,
2728 if (rc > out_end - out_ptr)
2729 diff -NurpP --minimal linux-2.6.32.24/fs/ext2/balloc.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/balloc.c
2730 --- linux-2.6.32.24/fs/ext2/balloc.c 2009-06-11 17:13:03.000000000 +0200
2731 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/balloc.c 2009-12-03 20:04:56.000000000 +0100
2732 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2734 end = EXT2_BLOCKS_PER_GROUP(sb);
2737 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2740 diff -NurpP --minimal linux-2.6.32.24/fs/ext2/ext2.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/ext2.h
2741 --- linux-2.6.32.24/fs/ext2/ext2.h 2009-09-10 15:26:21.000000000 +0200
2742 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/ext2.h 2009-12-03 20:04:56.000000000 +0100
2743 @@ -131,6 +131,7 @@ extern int ext2_fiemap(struct inode *ino
2744 int __ext2_write_begin(struct file *file, struct address_space *mapping,
2745 loff_t pos, unsigned len, unsigned flags,
2746 struct page **pagep, void **fsdata);
2747 +extern int ext2_sync_flags(struct inode *, int, int);
2750 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2751 diff -NurpP --minimal linux-2.6.32.24/fs/ext2/file.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/file.c
2752 --- linux-2.6.32.24/fs/ext2/file.c 2009-12-03 20:02:51.000000000 +0100
2753 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/file.c 2009-12-03 20:04:56.000000000 +0100
2754 @@ -87,4 +87,5 @@ const struct inode_operations ext2_file_
2755 .setattr = ext2_setattr,
2756 .check_acl = ext2_check_acl,
2757 .fiemap = ext2_fiemap,
2758 + .sync_flags = ext2_sync_flags,
2760 diff -NurpP --minimal linux-2.6.32.24/fs/ext2/ialloc.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/ialloc.c
2761 --- linux-2.6.32.24/fs/ext2/ialloc.c 2009-06-11 17:13:03.000000000 +0200
2762 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/ialloc.c 2009-12-03 20:04:56.000000000 +0100
2764 #include <linux/backing-dev.h>
2765 #include <linux/buffer_head.h>
2766 #include <linux/random.h>
2767 +#include <linux/vs_tag.h>
2771 @@ -560,6 +561,7 @@ got:
2773 inode->i_gid = current_fsgid();
2774 inode->i_mode = mode;
2775 + inode->i_tag = dx_current_fstag(sb);
2778 inode->i_blocks = 0;
2779 diff -NurpP --minimal linux-2.6.32.24/fs/ext2/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/inode.c
2780 --- linux-2.6.32.24/fs/ext2/inode.c 2009-12-03 20:02:51.000000000 +0100
2781 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/inode.c 2009-12-03 20:04:56.000000000 +0100
2783 #include <linux/mpage.h>
2784 #include <linux/fiemap.h>
2785 #include <linux/namei.h>
2786 +#include <linux/vs_tag.h>
2790 @@ -1040,7 +1041,7 @@ void ext2_truncate(struct inode *inode)
2792 if (ext2_inode_is_fast_symlink(inode))
2794 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2795 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2798 blocksize = inode->i_sb->s_blocksize;
2799 @@ -1178,36 +1179,61 @@ void ext2_set_inode_flags(struct inode *
2801 unsigned int flags = EXT2_I(inode)->i_flags;
2803 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2804 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2805 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2808 + if (flags & EXT2_IMMUTABLE_FL)
2809 + inode->i_flags |= S_IMMUTABLE;
2810 + if (flags & EXT2_IXUNLINK_FL)
2811 + inode->i_flags |= S_IXUNLINK;
2813 if (flags & EXT2_SYNC_FL)
2814 inode->i_flags |= S_SYNC;
2815 if (flags & EXT2_APPEND_FL)
2816 inode->i_flags |= S_APPEND;
2817 - if (flags & EXT2_IMMUTABLE_FL)
2818 - inode->i_flags |= S_IMMUTABLE;
2819 if (flags & EXT2_NOATIME_FL)
2820 inode->i_flags |= S_NOATIME;
2821 if (flags & EXT2_DIRSYNC_FL)
2822 inode->i_flags |= S_DIRSYNC;
2824 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2826 + if (flags & EXT2_BARRIER_FL)
2827 + inode->i_vflags |= V_BARRIER;
2828 + if (flags & EXT2_COW_FL)
2829 + inode->i_vflags |= V_COW;
2832 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2833 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2835 unsigned int flags = ei->vfs_inode.i_flags;
2836 + unsigned int vflags = ei->vfs_inode.i_vflags;
2838 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2839 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2840 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2841 + EXT2_BARRIER_FL | EXT2_COW_FL);
2843 + if (flags & S_IMMUTABLE)
2844 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2845 + if (flags & S_IXUNLINK)
2846 + ei->i_flags |= EXT2_IXUNLINK_FL;
2848 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2849 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2851 ei->i_flags |= EXT2_SYNC_FL;
2852 if (flags & S_APPEND)
2853 ei->i_flags |= EXT2_APPEND_FL;
2854 - if (flags & S_IMMUTABLE)
2855 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2856 if (flags & S_NOATIME)
2857 ei->i_flags |= EXT2_NOATIME_FL;
2858 if (flags & S_DIRSYNC)
2859 ei->i_flags |= EXT2_DIRSYNC_FL;
2861 + if (vflags & V_BARRIER)
2862 + ei->i_flags |= EXT2_BARRIER_FL;
2863 + if (vflags & V_COW)
2864 + ei->i_flags |= EXT2_COW_FL;
2867 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2868 @@ -1217,6 +1243,8 @@ struct inode *ext2_iget (struct super_bl
2869 struct ext2_inode *raw_inode;
2870 struct inode *inode;
2876 inode = iget_locked(sb, ino);
2877 @@ -1235,12 +1263,17 @@ struct inode *ext2_iget (struct super_bl
2880 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2881 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2882 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2883 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2884 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2885 if (!(test_opt (inode->i_sb, NO_UID32))) {
2886 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2887 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2888 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2889 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2891 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2892 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2893 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2894 + le16_to_cpu(raw_inode->i_raw_tag));
2896 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2897 inode->i_size = le32_to_cpu(raw_inode->i_size);
2898 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2899 @@ -1338,8 +1371,8 @@ int ext2_write_inode(struct inode *inode
2900 struct ext2_inode_info *ei = EXT2_I(inode);
2901 struct super_block *sb = inode->i_sb;
2902 ino_t ino = inode->i_ino;
2903 - uid_t uid = inode->i_uid;
2904 - gid_t gid = inode->i_gid;
2905 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2906 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2907 struct buffer_head * bh;
2908 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2910 @@ -1375,6 +1408,9 @@ int ext2_write_inode(struct inode *inode
2911 raw_inode->i_uid_high = 0;
2912 raw_inode->i_gid_high = 0;
2914 +#ifdef CONFIG_TAGGING_INTERN
2915 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2917 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2918 raw_inode->i_size = cpu_to_le32(inode->i_size);
2919 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2920 @@ -1456,7 +1492,8 @@ int ext2_setattr(struct dentry *dentry,
2923 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2924 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2925 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2926 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2927 error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0;
2930 diff -NurpP --minimal linux-2.6.32.24/fs/ext2/ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/ioctl.c
2931 --- linux-2.6.32.24/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
2932 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/ioctl.c 2009-12-03 20:04:56.000000000 +0100
2934 #include <asm/uaccess.h>
2937 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2939 + inode->i_flags = flags;
2940 + inode->i_vflags = vflags;
2941 + ext2_get_inode_flags(EXT2_I(inode));
2942 + inode->i_ctime = CURRENT_TIME_SEC;
2943 + mark_inode_dirty(inode);
2947 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2949 struct inode *inode = filp->f_dentry->d_inode;
2950 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2952 flags = ext2_mask_flags(inode->i_mode, flags);
2954 + if (IS_BARRIER(inode)) {
2955 + vxwprintk_task(1, "messing with the barrier.");
2959 mutex_lock(&inode->i_mutex);
2960 /* Is it quota file? Do not allow user to mess with it */
2961 if (IS_NOQUOTA(inode)) {
2962 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2964 * This test looks nicer. Thanks to Pauline Middelink
2966 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2967 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2968 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2969 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2970 if (!capable(CAP_LINUX_IMMUTABLE)) {
2971 mutex_unlock(&inode->i_mutex);
2973 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2977 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2978 + flags &= EXT2_FL_USER_MODIFIABLE;
2979 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2980 ei->i_flags = flags;
2981 mutex_unlock(&inode->i_mutex);
2982 diff -NurpP --minimal linux-2.6.32.24/fs/ext2/namei.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/namei.c
2983 --- linux-2.6.32.24/fs/ext2/namei.c 2009-12-03 20:02:51.000000000 +0100
2984 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/namei.c 2009-12-03 20:04:56.000000000 +0100
2988 #include <linux/pagemap.h>
2989 +#include <linux/vs_tag.h>
2993 @@ -74,6 +75,7 @@ static struct dentry *ext2_lookup(struct
2994 return ERR_PTR(-EIO);
2996 return ERR_CAST(inode);
2997 + dx_propagate_tag(nd, inode);
3001 @@ -401,6 +403,7 @@ const struct inode_operations ext2_dir_i
3003 .setattr = ext2_setattr,
3004 .check_acl = ext2_check_acl,
3005 + .sync_flags = ext2_sync_flags,
3008 const struct inode_operations ext2_special_inode_operations = {
3009 diff -NurpP --minimal linux-2.6.32.24/fs/ext2/super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/super.c
3010 --- linux-2.6.32.24/fs/ext2/super.c 2009-09-10 15:26:21.000000000 +0200
3011 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext2/super.c 2009-12-03 20:04:56.000000000 +0100
3012 @@ -382,7 +382,8 @@ enum {
3013 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3014 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3015 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3016 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3017 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3018 + Opt_tag, Opt_notag, Opt_tagid
3021 static const match_table_t tokens = {
3022 @@ -410,6 +411,9 @@ static const match_table_t tokens = {
3024 {Opt_noacl, "noacl"},
3027 + {Opt_notag, "notag"},
3028 + {Opt_tagid, "tagid=%u"},
3029 {Opt_grpquota, "grpquota"},
3030 {Opt_ignore, "noquota"},
3031 {Opt_quota, "quota"},
3032 @@ -480,6 +484,20 @@ static int parse_options (char * options
3034 set_opt (sbi->s_mount_opt, NO_UID32);
3036 +#ifndef CONFIG_TAGGING_NONE
3038 + set_opt (sbi->s_mount_opt, TAGGED);
3041 + clear_opt (sbi->s_mount_opt, TAGGED);
3044 +#ifdef CONFIG_PROPAGATE
3047 + set_opt (sbi->s_mount_opt, TAGGED);
3051 clear_opt (sbi->s_mount_opt, CHECK);
3053 @@ -829,6 +847,8 @@ static int ext2_fill_super(struct super_
3054 if (!parse_options ((char *) data, sbi))
3057 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3058 + sb->s_flags |= MS_TAGGED;
3059 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3060 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3062 @@ -1175,6 +1195,14 @@ static int ext2_remount (struct super_bl
3066 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3067 + !(sb->s_flags & MS_TAGGED)) {
3068 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3071 + goto restore_opts;
3074 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3075 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3077 diff -NurpP --minimal linux-2.6.32.24/fs/ext3/file.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/file.c
3078 --- linux-2.6.32.24/fs/ext3/file.c 2009-12-03 20:02:51.000000000 +0100
3079 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/file.c 2009-12-03 20:04:56.000000000 +0100
3080 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
3082 .check_acl = ext3_check_acl,
3083 .fiemap = ext3_fiemap,
3084 + .sync_flags = ext3_sync_flags,
3087 diff -NurpP --minimal linux-2.6.32.24/fs/ext3/ialloc.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/ialloc.c
3088 --- linux-2.6.32.24/fs/ext3/ialloc.c 2009-09-10 15:26:21.000000000 +0200
3089 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/ialloc.c 2009-12-03 20:04:56.000000000 +0100
3091 #include <linux/buffer_head.h>
3092 #include <linux/random.h>
3093 #include <linux/bitops.h>
3094 +#include <linux/vs_tag.h>
3096 #include <asm/byteorder.h>
3098 @@ -548,6 +549,7 @@ got:
3100 inode->i_gid = current_fsgid();
3101 inode->i_mode = mode;
3102 + inode->i_tag = dx_current_fstag(sb);
3105 /* This is the optimal IO size (for stat), not the fs block size */
3106 diff -NurpP --minimal linux-2.6.32.24/fs/ext3/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/inode.c
3107 --- linux-2.6.32.24/fs/ext3/inode.c 2010-10-04 08:56:12.000000000 +0200
3108 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/inode.c 2009-12-29 00:36:26.000000000 +0100
3110 #include <linux/bio.h>
3111 #include <linux/fiemap.h>
3112 #include <linux/namei.h>
3113 +#include <linux/vs_tag.h>
3117 @@ -2343,7 +2344,7 @@ static void ext3_free_branches(handle_t
3119 int ext3_can_truncate(struct inode *inode)
3121 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3122 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3124 if (S_ISREG(inode->i_mode))
3126 @@ -2728,36 +2729,60 @@ void ext3_set_inode_flags(struct inode *
3128 unsigned int flags = EXT3_I(inode)->i_flags;
3130 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3131 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3132 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3134 + if (flags & EXT3_IMMUTABLE_FL)
3135 + inode->i_flags |= S_IMMUTABLE;
3136 + if (flags & EXT3_IXUNLINK_FL)
3137 + inode->i_flags |= S_IXUNLINK;
3139 if (flags & EXT3_SYNC_FL)
3140 inode->i_flags |= S_SYNC;
3141 if (flags & EXT3_APPEND_FL)
3142 inode->i_flags |= S_APPEND;
3143 - if (flags & EXT3_IMMUTABLE_FL)
3144 - inode->i_flags |= S_IMMUTABLE;
3145 if (flags & EXT3_NOATIME_FL)
3146 inode->i_flags |= S_NOATIME;
3147 if (flags & EXT3_DIRSYNC_FL)
3148 inode->i_flags |= S_DIRSYNC;
3150 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3152 + if (flags & EXT3_BARRIER_FL)
3153 + inode->i_vflags |= V_BARRIER;
3154 + if (flags & EXT3_COW_FL)
3155 + inode->i_vflags |= V_COW;
3158 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3159 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3161 unsigned int flags = ei->vfs_inode.i_flags;
3162 + unsigned int vflags = ei->vfs_inode.i_vflags;
3164 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3165 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3166 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3167 + EXT3_BARRIER_FL | EXT3_COW_FL);
3169 + if (flags & S_IMMUTABLE)
3170 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3171 + if (flags & S_IXUNLINK)
3172 + ei->i_flags |= EXT3_IXUNLINK_FL;
3174 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3175 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3177 ei->i_flags |= EXT3_SYNC_FL;
3178 if (flags & S_APPEND)
3179 ei->i_flags |= EXT3_APPEND_FL;
3180 - if (flags & S_IMMUTABLE)
3181 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3182 if (flags & S_NOATIME)
3183 ei->i_flags |= EXT3_NOATIME_FL;
3184 if (flags & S_DIRSYNC)
3185 ei->i_flags |= EXT3_DIRSYNC_FL;
3187 + if (vflags & V_BARRIER)
3188 + ei->i_flags |= EXT3_BARRIER_FL;
3189 + if (vflags & V_COW)
3190 + ei->i_flags |= EXT3_COW_FL;
3193 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3194 @@ -2771,6 +2796,8 @@ struct inode *ext3_iget(struct super_blo
3195 transaction_t *transaction;
3201 inode = iget_locked(sb, ino);
3203 @@ -2787,12 +2814,17 @@ struct inode *ext3_iget(struct super_blo
3205 raw_inode = ext3_raw_inode(&iloc);
3206 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3207 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3208 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3209 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3210 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3211 if(!(test_opt (inode->i_sb, NO_UID32))) {
3212 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3213 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3214 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3215 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3217 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3218 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3219 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3220 + le16_to_cpu(raw_inode->i_raw_tag));
3222 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3223 inode->i_size = le32_to_cpu(raw_inode->i_size);
3224 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3225 @@ -2947,6 +2979,8 @@ static int ext3_do_update_inode(handle_t
3226 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3227 struct ext3_inode_info *ei = EXT3_I(inode);
3228 struct buffer_head *bh = iloc->bh;
3229 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3230 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3231 int err = 0, rc, block;
3234 @@ -2961,29 +2995,32 @@ again:
3235 ext3_get_inode_flags(ei);
3236 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3237 if(!(test_opt(inode->i_sb, NO_UID32))) {
3238 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3239 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3240 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3241 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3243 * Fix up interoperability with old kernels. Otherwise, old inodes get
3244 * re-used with the upper 16 bits of the uid/gid intact
3247 raw_inode->i_uid_high =
3248 - cpu_to_le16(high_16_bits(inode->i_uid));
3249 + cpu_to_le16(high_16_bits(uid));
3250 raw_inode->i_gid_high =
3251 - cpu_to_le16(high_16_bits(inode->i_gid));
3252 + cpu_to_le16(high_16_bits(gid));
3254 raw_inode->i_uid_high = 0;
3255 raw_inode->i_gid_high = 0;
3258 raw_inode->i_uid_low =
3259 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3260 + cpu_to_le16(fs_high2lowuid(uid));
3261 raw_inode->i_gid_low =
3262 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3263 + cpu_to_le16(fs_high2lowgid(gid));
3264 raw_inode->i_uid_high = 0;
3265 raw_inode->i_gid_high = 0;
3267 +#ifdef CONFIG_TAGGING_INTERN
3268 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3270 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3271 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3272 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3273 @@ -3141,7 +3178,8 @@ int ext3_setattr(struct dentry *dentry,
3276 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3277 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3278 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3279 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3282 /* (user+group)*(old+new) structure, inode write (sb,
3283 @@ -3163,6 +3201,8 @@ int ext3_setattr(struct dentry *dentry,
3284 inode->i_uid = attr->ia_uid;
3285 if (attr->ia_valid & ATTR_GID)
3286 inode->i_gid = attr->ia_gid;
3287 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3288 + inode->i_tag = attr->ia_tag;
3289 error = ext3_mark_inode_dirty(handle, inode);
3290 ext3_journal_stop(handle);
3292 diff -NurpP --minimal linux-2.6.32.24/fs/ext3/ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/ioctl.c
3293 --- linux-2.6.32.24/fs/ext3/ioctl.c 2009-06-11 17:13:03.000000000 +0200
3294 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/ioctl.c 2009-12-03 20:04:56.000000000 +0100
3298 #include <linux/fs.h>
3299 +#include <linux/mount.h>
3300 #include <linux/jbd.h>
3301 #include <linux/capability.h>
3302 #include <linux/ext3_fs.h>
3304 #include <linux/compat.h>
3305 #include <asm/uaccess.h>
3308 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3310 + handle_t *handle = NULL;
3311 + struct ext3_iloc iloc;
3314 + handle = ext3_journal_start(inode, 1);
3315 + if (IS_ERR(handle))
3316 + return PTR_ERR(handle);
3318 + if (IS_SYNC(inode))
3319 + handle->h_sync = 1;
3320 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3324 + inode->i_flags = flags;
3325 + inode->i_vflags = vflags;
3326 + ext3_get_inode_flags(EXT3_I(inode));
3327 + inode->i_ctime = CURRENT_TIME_SEC;
3329 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3331 + ext3_journal_stop(handle);
3335 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3337 struct inode *inode = filp->f_dentry->d_inode;
3338 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3340 flags = ext3_mask_flags(inode->i_mode, flags);
3342 + if (IS_BARRIER(inode)) {
3343 + vxwprintk_task(1, "messing with the barrier.");
3347 mutex_lock(&inode->i_mutex);
3349 /* Is it quota file? Do not allow user to mess with it */
3350 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3352 * This test looks nicer. Thanks to Pauline Middelink
3354 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3355 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3356 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3357 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3358 if (!capable(CAP_LINUX_IMMUTABLE))
3361 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3365 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3366 + flags &= EXT3_FL_USER_MODIFIABLE;
3367 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3368 ei->i_flags = flags;
3370 diff -NurpP --minimal linux-2.6.32.24/fs/ext3/namei.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/namei.c
3371 --- linux-2.6.32.24/fs/ext3/namei.c 2009-12-03 20:02:51.000000000 +0100
3372 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/namei.c 2009-12-03 20:04:56.000000000 +0100
3374 #include <linux/quotaops.h>
3375 #include <linux/buffer_head.h>
3376 #include <linux/bio.h>
3377 +#include <linux/vs_tag.h>
3381 @@ -912,6 +913,7 @@ restart:
3383 ll_rw_block(READ_META, 1, &bh);
3385 + dx_propagate_tag(nd, inode);
3387 if ((bh = bh_use[ra_ptr++]) == NULL)
3389 @@ -2446,6 +2448,7 @@ const struct inode_operations ext3_dir_i
3390 .removexattr = generic_removexattr,
3392 .check_acl = ext3_check_acl,
3393 + .sync_flags = ext3_sync_flags,
3396 const struct inode_operations ext3_special_inode_operations = {
3397 diff -NurpP --minimal linux-2.6.32.24/fs/ext3/super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/super.c
3398 --- linux-2.6.32.24/fs/ext3/super.c 2010-10-04 08:56:12.000000000 +0200
3399 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext3/super.c 2010-04-28 10:19:32.000000000 +0200
3400 @@ -789,7 +789,7 @@ enum {
3401 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3402 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
3403 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3405 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3408 static const match_table_t tokens = {
3409 @@ -842,6 +842,9 @@ static const match_table_t tokens = {
3410 {Opt_usrquota, "usrquota"},
3411 {Opt_barrier, "barrier=%u"},
3412 {Opt_resize, "resize"},
3414 + {Opt_notag, "notag"},
3415 + {Opt_tagid, "tagid=%u"},
3419 @@ -934,6 +937,20 @@ static int parse_options (char *options,
3421 set_opt (sbi->s_mount_opt, NO_UID32);
3423 +#ifndef CONFIG_TAGGING_NONE
3425 + set_opt (sbi->s_mount_opt, TAGGED);
3428 + clear_opt (sbi->s_mount_opt, TAGGED);
3431 +#ifdef CONFIG_PROPAGATE
3434 + set_opt (sbi->s_mount_opt, TAGGED);
3438 clear_opt (sbi->s_mount_opt, CHECK);
3440 @@ -1658,6 +1675,9 @@ static int ext3_fill_super (struct super
3444 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3445 + sb->s_flags |= MS_TAGGED;
3447 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3448 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3450 @@ -2527,6 +2547,14 @@ static int ext3_remount (struct super_bl
3451 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3452 ext3_abort(sb, __func__, "Abort forced by user");
3454 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3455 + !(sb->s_flags & MS_TAGGED)) {
3456 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3459 + goto restore_opts;
3462 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3463 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3465 diff -NurpP --minimal linux-2.6.32.24/fs/ext4/ext4.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/ext4.h
3466 --- linux-2.6.32.24/fs/ext4/ext4.h 2010-10-04 08:56:12.000000000 +0200
3467 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/ext4.h 2010-09-05 21:24:17.000000000 +0200
3468 @@ -289,8 +289,12 @@ struct flex_groups {
3469 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3470 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3471 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3472 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3473 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3475 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3476 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3478 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3479 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3481 @@ -552,7 +556,8 @@ struct ext4_inode {
3482 __le16 l_i_file_acl_high;
3483 __le16 l_i_uid_high; /* these 2 fields */
3484 __le16 l_i_gid_high; /* were reserved2[0] */
3485 - __u32 l_i_reserved2;
3486 + __le16 l_i_tag; /* Context Tag */
3487 + __u16 l_i_reserved2;
3490 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3491 @@ -666,6 +671,7 @@ do { \
3492 #define i_gid_low i_gid
3493 #define i_uid_high osd2.linux2.l_i_uid_high
3494 #define i_gid_high osd2.linux2.l_i_gid_high
3495 +#define i_raw_tag osd2.linux2.l_i_tag
3496 #define i_reserved2 osd2.linux2.l_i_reserved2
3498 #elif defined(__GNU__)
3499 @@ -840,6 +846,7 @@ struct ext4_inode_info {
3500 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3501 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3502 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3503 +#define EXT4_MOUNT_TAGGED 0x400000 /* Enable Context Tags */
3504 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
3505 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
3506 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3507 @@ -1865,6 +1872,7 @@ extern int ext4_get_blocks(handle_t *han
3508 struct buffer_head *bh, int flags);
3509 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3510 __u64 start, __u64 len);
3511 +extern int ext4_sync_flags(struct inode *, int, int);
3513 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3514 __u64 start_orig, __u64 start_donor,
3515 diff -NurpP --minimal linux-2.6.32.24/fs/ext4/file.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/file.c
3516 --- linux-2.6.32.24/fs/ext4/file.c 2010-10-04 08:56:12.000000000 +0200
3517 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/file.c 2010-08-09 18:06:32.000000000 +0200
3518 @@ -161,5 +161,6 @@ const struct inode_operations ext4_file_
3519 .check_acl = ext4_check_acl,
3520 .fallocate = ext4_fallocate,
3521 .fiemap = ext4_fiemap,
3522 + .sync_flags = ext4_sync_flags,
3525 diff -NurpP --minimal linux-2.6.32.24/fs/ext4/ialloc.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/ialloc.c
3526 --- linux-2.6.32.24/fs/ext4/ialloc.c 2010-10-04 08:56:12.000000000 +0200
3527 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/ialloc.c 2010-08-09 18:06:32.000000000 +0200
3529 #include <linux/random.h>
3530 #include <linux/bitops.h>
3531 #include <linux/blkdev.h>
3532 +#include <linux/vs_tag.h>
3533 #include <asm/byteorder.h>
3536 @@ -988,6 +989,7 @@ got:
3538 inode->i_gid = current_fsgid();
3539 inode->i_mode = mode;
3540 + inode->i_tag = dx_current_fstag(sb);
3542 inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb);
3543 /* This is the optimal IO size (for stat), not the fs block size */
3544 diff -NurpP --minimal linux-2.6.32.24/fs/ext4/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/inode.c
3545 --- linux-2.6.32.24/fs/ext4/inode.c 2010-10-04 08:56:13.000000000 +0200
3546 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/inode.c 2010-10-04 10:16:00.000000000 +0200
3548 #include <linux/uio.h>
3549 #include <linux/bio.h>
3550 #include <linux/workqueue.h>
3551 +#include <linux/vs_tag.h>
3553 #include "ext4_jbd2.h"
3555 @@ -4446,7 +4447,7 @@ static void ext4_free_branches(handle_t
3557 int ext4_can_truncate(struct inode *inode)
3559 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3560 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3562 if (S_ISREG(inode->i_mode))
3564 @@ -4799,41 +4800,64 @@ void ext4_set_inode_flags(struct inode *
3566 unsigned int flags = EXT4_I(inode)->i_flags;
3568 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3569 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3570 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3572 + if (flags & EXT4_IMMUTABLE_FL)
3573 + inode->i_flags |= S_IMMUTABLE;
3574 + if (flags & EXT4_IXUNLINK_FL)
3575 + inode->i_flags |= S_IXUNLINK;
3577 if (flags & EXT4_SYNC_FL)
3578 inode->i_flags |= S_SYNC;
3579 if (flags & EXT4_APPEND_FL)
3580 inode->i_flags |= S_APPEND;
3581 - if (flags & EXT4_IMMUTABLE_FL)
3582 - inode->i_flags |= S_IMMUTABLE;
3583 if (flags & EXT4_NOATIME_FL)
3584 inode->i_flags |= S_NOATIME;
3585 if (flags & EXT4_DIRSYNC_FL)
3586 inode->i_flags |= S_DIRSYNC;
3588 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3590 + if (flags & EXT4_BARRIER_FL)
3591 + inode->i_vflags |= V_BARRIER;
3592 + if (flags & EXT4_COW_FL)
3593 + inode->i_vflags |= V_COW;
3596 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3597 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3599 - unsigned int vfs_fl;
3600 + unsigned int vfs_fl, vflags;
3601 unsigned long old_fl, new_fl;
3604 vfs_fl = ei->vfs_inode.i_flags;
3605 + vflags = ei->vfs_inode.i_vflags;
3606 old_fl = ei->i_flags;
3607 - new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3608 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3610 + new_fl = old_fl & ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3611 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3612 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3613 + EXT4_BARRIER_FL | EXT4_COW_FL);
3615 + if (vfs_fl & S_IMMUTABLE)
3616 + new_fl |= EXT4_IMMUTABLE_FL;
3617 + if (vfs_fl & S_IXUNLINK)
3618 + new_fl |= EXT4_IXUNLINK_FL;
3620 if (vfs_fl & S_SYNC)
3621 new_fl |= EXT4_SYNC_FL;
3622 if (vfs_fl & S_APPEND)
3623 new_fl |= EXT4_APPEND_FL;
3624 - if (vfs_fl & S_IMMUTABLE)
3625 - new_fl |= EXT4_IMMUTABLE_FL;
3626 if (vfs_fl & S_NOATIME)
3627 new_fl |= EXT4_NOATIME_FL;
3628 if (vfs_fl & S_DIRSYNC)
3629 new_fl |= EXT4_DIRSYNC_FL;
3631 + if (vflags & V_BARRIER)
3632 + new_fl |= EXT4_BARRIER_FL;
3633 + if (vflags & V_COW)
3634 + new_fl |= EXT4_COW_FL;
3635 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3638 @@ -4869,6 +4893,8 @@ struct inode *ext4_iget(struct super_blo
3639 journal_t *journal = EXT4_SB(sb)->s_journal;
3645 inode = iget_locked(sb, ino);
3647 @@ -4884,12 +4910,16 @@ struct inode *ext4_iget(struct super_blo
3649 raw_inode = ext4_raw_inode(&iloc);
3650 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3651 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3652 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3653 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3654 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3655 if (!(test_opt(inode->i_sb, NO_UID32))) {
3656 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3657 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3658 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3659 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3661 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3662 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3663 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3664 + le16_to_cpu(raw_inode->i_raw_tag));
3665 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3667 ei->i_state_flags = 0;
3668 @@ -5111,6 +5141,8 @@ static int ext4_do_update_inode(handle_t
3669 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3670 struct ext4_inode_info *ei = EXT4_I(inode);
3671 struct buffer_head *bh = iloc->bh;
3672 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3673 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3674 int err = 0, rc, block;
3676 /* For fields not not tracking in the in-memory inode,
3677 @@ -5121,29 +5153,32 @@ static int ext4_do_update_inode(handle_t
3678 ext4_get_inode_flags(ei);
3679 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3680 if (!(test_opt(inode->i_sb, NO_UID32))) {
3681 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3682 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3683 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3684 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3686 * Fix up interoperability with old kernels. Otherwise, old inodes get
3687 * re-used with the upper 16 bits of the uid/gid intact
3690 raw_inode->i_uid_high =
3691 - cpu_to_le16(high_16_bits(inode->i_uid));
3692 + cpu_to_le16(high_16_bits(uid));
3693 raw_inode->i_gid_high =
3694 - cpu_to_le16(high_16_bits(inode->i_gid));
3695 + cpu_to_le16(high_16_bits(gid));
3697 raw_inode->i_uid_high = 0;
3698 raw_inode->i_gid_high = 0;
3701 raw_inode->i_uid_low =
3702 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3703 + cpu_to_le16(fs_high2lowuid(uid));
3704 raw_inode->i_gid_low =
3705 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3706 + cpu_to_le16(fs_high2lowgid(gid));
3707 raw_inode->i_uid_high = 0;
3708 raw_inode->i_gid_high = 0;
3710 +#ifdef CONFIG_TAGGING_INTERN
3711 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3713 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3715 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3716 @@ -5329,7 +5364,8 @@ int ext4_setattr(struct dentry *dentry,
3719 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3720 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3721 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3722 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3725 /* (user+group)*(old+new) structure, inode write (sb,
3726 @@ -5351,6 +5387,8 @@ int ext4_setattr(struct dentry *dentry,
3727 inode->i_uid = attr->ia_uid;
3728 if (attr->ia_valid & ATTR_GID)
3729 inode->i_gid = attr->ia_gid;
3730 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3731 + inode->i_tag = attr->ia_tag;
3732 error = ext4_mark_inode_dirty(handle, inode);
3733 ext4_journal_stop(handle);
3735 diff -NurpP --minimal linux-2.6.32.24/fs/ext4/ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/ioctl.c
3736 --- linux-2.6.32.24/fs/ext4/ioctl.c 2010-10-04 08:56:13.000000000 +0200
3737 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/ioctl.c 2010-08-09 18:06:32.000000000 +0200
3739 #include <linux/compat.h>
3740 #include <linux/mount.h>
3741 #include <linux/file.h>
3742 +#include <linux/vs_tag.h>
3743 #include <asm/uaccess.h>
3744 #include "ext4_jbd2.h"
3748 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3750 + handle_t *handle = NULL;
3751 + struct ext4_iloc iloc;
3754 + handle = ext4_journal_start(inode, 1);
3755 + if (IS_ERR(handle))
3756 + return PTR_ERR(handle);
3758 + if (IS_SYNC(inode))
3759 + ext4_handle_sync(handle);
3760 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3764 + inode->i_flags = flags;
3765 + inode->i_vflags = vflags;
3766 + ext4_get_inode_flags(EXT4_I(inode));
3767 + inode->i_ctime = ext4_current_time(inode);
3769 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3771 + ext4_journal_stop(handle);
3775 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3777 struct inode *inode = filp->f_dentry->d_inode;
3778 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3780 flags = ext4_mask_flags(inode->i_mode, flags);
3782 + if (IS_BARRIER(inode)) {
3783 + vxwprintk_task(1, "messing with the barrier.");
3788 mutex_lock(&inode->i_mutex);
3789 /* Is it quota file? Do not allow user to mess with it */
3790 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3792 * This test looks nicer. Thanks to Pauline Middelink
3794 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3795 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3796 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3797 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3798 if (!capable(CAP_LINUX_IMMUTABLE))
3801 diff -NurpP --minimal linux-2.6.32.24/fs/ext4/namei.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/namei.c
3802 --- linux-2.6.32.24/fs/ext4/namei.c 2010-10-04 08:56:13.000000000 +0200
3803 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/namei.c 2010-08-09 18:06:32.000000000 +0200
3805 #include <linux/quotaops.h>
3806 #include <linux/buffer_head.h>
3807 #include <linux/bio.h>
3808 +#include <linux/vs_tag.h>
3810 #include "ext4_jbd2.h"
3812 @@ -941,6 +942,7 @@ restart:
3814 ll_rw_block(READ_META, 1, &bh);
3816 + dx_propagate_tag(nd, inode);
3818 if ((bh = bh_use[ra_ptr++]) == NULL)
3820 @@ -2543,6 +2545,7 @@ const struct inode_operations ext4_dir_i
3822 .check_acl = ext4_check_acl,
3823 .fiemap = ext4_fiemap,
3824 + .sync_flags = ext4_sync_flags,
3827 const struct inode_operations ext4_special_inode_operations = {
3828 diff -NurpP --minimal linux-2.6.32.24/fs/ext4/super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/super.c
3829 --- linux-2.6.32.24/fs/ext4/super.c 2010-10-04 08:56:13.000000000 +0200
3830 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ext4/super.c 2010-08-19 17:35:34.000000000 +0200
3831 @@ -1100,6 +1100,7 @@ enum {
3832 Opt_block_validity, Opt_noblock_validity,
3833 Opt_inode_readahead_blks, Opt_journal_ioprio,
3834 Opt_discard, Opt_nodiscard,
3835 + Opt_tag, Opt_notag, Opt_tagid
3838 static const match_table_t tokens = {
3839 @@ -1167,6 +1168,9 @@ static const match_table_t tokens = {
3840 {Opt_noauto_da_alloc, "noauto_da_alloc"},
3841 {Opt_discard, "discard"},
3842 {Opt_nodiscard, "nodiscard"},
3844 + {Opt_notag, "notag"},
3845 + {Opt_tagid, "tagid=%u"},
3849 @@ -1269,6 +1273,20 @@ static int parse_options(char *options,
3851 set_opt(sbi->s_mount_opt, NO_UID32);
3853 +#ifndef CONFIG_TAGGING_NONE
3855 + set_opt (sbi->s_mount_opt, TAGGED);
3858 + clear_opt (sbi->s_mount_opt, TAGGED);
3861 +#ifdef CONFIG_PROPAGATE
3864 + set_opt (sbi->s_mount_opt, TAGGED);
3868 set_opt(sbi->s_mount_opt, DEBUG);
3870 @@ -2471,6 +2489,9 @@ static int ext4_fill_super(struct super_
3871 &journal_ioprio, NULL, 0))
3874 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3875 + sb->s_flags |= MS_TAGGED;
3877 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3878 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3880 @@ -3522,6 +3543,14 @@ static int ext4_remount(struct super_blo
3881 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3882 ext4_abort(sb, __func__, "Abort forced by user");
3884 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3885 + !(sb->s_flags & MS_TAGGED)) {
3886 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3889 + goto restore_opts;
3892 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3893 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3895 diff -NurpP --minimal linux-2.6.32.24/fs/fcntl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/fcntl.c
3896 --- linux-2.6.32.24/fs/fcntl.c 2010-10-04 08:56:13.000000000 +0200
3897 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/fcntl.c 2010-02-24 12:32:54.000000000 +0100
3899 #include <linux/signal.h>
3900 #include <linux/rcupdate.h>
3901 #include <linux/pid_namespace.h>
3902 +#include <linux/vs_limit.h>
3904 #include <asm/poll.h>
3905 #include <asm/siginfo.h>
3906 @@ -102,6 +103,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3909 filp_close(tofree, files);
3911 + vx_openfd_inc(newfd); /* fd was unused */
3915 @@ -426,6 +429,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3919 + if (!vx_files_avail(1))
3922 err = security_file_fcntl(filp, cmd, arg);
3924 diff -NurpP --minimal linux-2.6.32.24/fs/file.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/file.c
3925 --- linux-2.6.32.24/fs/file.c 2009-12-03 20:02:51.000000000 +0100
3926 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/file.c 2009-12-03 20:04:56.000000000 +0100
3928 #include <linux/spinlock.h>
3929 #include <linux/rcupdate.h>
3930 #include <linux/workqueue.h>
3931 +#include <linux/vs_limit.h>
3933 struct fdtable_defer {
3935 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
3936 struct file *f = *old_fds++;
3939 + /* TODO: sum it first for check and performance */
3940 + vx_openfd_inc(open_files - i);
3943 * The fd may be claimed in the fd bitmap but not yet
3944 @@ -476,6 +479,7 @@ repeat:
3946 FD_CLR(fd, fdt->close_on_exec);
3948 + vx_openfd_inc(fd);
3951 if (rcu_dereference(fdt->fd[fd]) != NULL) {
3952 diff -NurpP --minimal linux-2.6.32.24/fs/file_table.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/file_table.c
3953 --- linux-2.6.32.24/fs/file_table.c 2010-10-04 08:56:13.000000000 +0200
3954 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/file_table.c 2010-03-18 16:53:06.000000000 +0100
3956 #include <linux/fsnotify.h>
3957 #include <linux/sysctl.h>
3958 #include <linux/percpu_counter.h>
3959 +#include <linux/vs_limit.h>
3960 +#include <linux/vs_context.h>
3962 #include <asm/atomic.h>
3964 @@ -131,6 +133,8 @@ struct file *get_empty_filp(void)
3965 spin_lock_init(&f->f_lock);
3966 eventpoll_init_file(f);
3967 /* f->f_version: 0 */
3968 + f->f_xid = vx_current_xid();
3973 @@ -285,6 +289,8 @@ void __fput(struct file *file)
3974 cdev_put(inode->i_cdev);
3975 fops_put(file->f_op);
3976 put_pid(file->f_owner.pid);
3977 + vx_files_dec(file);
3980 if (file->f_mode & FMODE_WRITE)
3981 drop_file_write_access(file);
3982 @@ -352,6 +358,8 @@ void put_filp(struct file *file)
3984 if (atomic_long_dec_and_test(&file->f_count)) {
3985 security_file_free(file);
3986 + vx_files_dec(file);
3991 diff -NurpP --minimal linux-2.6.32.24/fs/fs_struct.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/fs_struct.c
3992 --- linux-2.6.32.24/fs/fs_struct.c 2009-06-11 17:13:04.000000000 +0200
3993 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/fs_struct.c 2009-12-03 20:04:56.000000000 +0100
3995 #include <linux/path.h>
3996 #include <linux/slab.h>
3997 #include <linux/fs_struct.h>
3998 +#include <linux/vserver/global.h>
4001 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
4002 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
4004 path_put(&fs->root);
4006 + atomic_dec(&vs_global_fs);
4007 kmem_cache_free(fs_cachep, fs);
4010 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct
4012 path_get(&old->pwd);
4013 read_unlock(&old->lock);
4014 + atomic_inc(&vs_global_fs);
4018 diff -NurpP --minimal linux-2.6.32.24/fs/gfs2/file.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/gfs2/file.c
4019 --- linux-2.6.32.24/fs/gfs2/file.c 2010-10-04 08:56:13.000000000 +0200
4020 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/gfs2/file.c 2010-07-08 02:22:31.000000000 +0200
4021 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
4022 [7] = GFS2_DIF_NOATIME,
4023 [12] = GFS2_DIF_EXHASH,
4024 [14] = GFS2_DIF_INHERIT_JDATA,
4025 + [27] = GFS2_DIF_IXUNLINK,
4026 + [26] = GFS2_DIF_BARRIER,
4027 + [29] = GFS2_DIF_COW,
4030 static const u32 gfs2_to_fsflags[32] = {
4031 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
4032 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4033 [gfs2fl_ExHash] = FS_INDEX_FL,
4034 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4035 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4036 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4037 + [gfs2fl_Cow] = FS_COW_FL,
4040 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4041 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
4043 struct gfs2_inode *ip = GFS2_I(inode);
4044 unsigned int flags = inode->i_flags;
4045 + unsigned int vflags = inode->i_vflags;
4047 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4048 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4050 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4051 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4052 flags |= S_IMMUTABLE;
4053 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4054 + flags |= S_IXUNLINK;
4056 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4058 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4059 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
4060 if (ip->i_diskflags & GFS2_DIF_SYNC)
4062 inode->i_flags = flags;
4064 + vflags &= ~(V_BARRIER | V_COW);
4066 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4067 + vflags |= V_BARRIER;
4068 + if (ip->i_diskflags & GFS2_DIF_COW)
4070 + inode->i_vflags = vflags;
4073 +void gfs2_get_inode_flags(struct inode *inode)
4075 + struct gfs2_inode *ip = GFS2_I(inode);
4076 + unsigned int flags = inode->i_flags;
4077 + unsigned int vflags = inode->i_vflags;
4079 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4080 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4081 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4082 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4084 + if (flags & S_IMMUTABLE)
4085 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4086 + if (flags & S_IXUNLINK)
4087 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4089 + if (flags & S_APPEND)
4090 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4091 + if (flags & S_NOATIME)
4092 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4093 + if (flags & S_SYNC)
4094 + ip->i_diskflags |= GFS2_DIF_SYNC;
4096 + if (vflags & V_BARRIER)
4097 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4098 + if (vflags & V_COW)
4099 + ip->i_diskflags |= GFS2_DIF_COW;
4102 /* Flags that can be set by user space */
4103 @@ -293,6 +342,37 @@ static int gfs2_set_flags(struct file *f
4104 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4107 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4109 + struct gfs2_inode *ip = GFS2_I(inode);
4110 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4111 + struct buffer_head *bh;
4112 + struct gfs2_holder gh;
4115 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4118 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4121 + error = gfs2_meta_inode_buffer(ip, &bh);
4123 + goto out_trans_end;
4124 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4125 + inode->i_flags = flags;
4126 + inode->i_vflags = vflags;
4127 + gfs2_get_inode_flags(inode);
4128 + gfs2_dinode_out(ip, bh->b_data);
4130 + gfs2_set_aops(inode);
4132 + gfs2_trans_end(sdp);
4134 + gfs2_glock_dq_uninit(&gh);
4138 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4141 diff -NurpP --minimal linux-2.6.32.24/fs/gfs2/inode.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/gfs2/inode.h
4142 --- linux-2.6.32.24/fs/gfs2/inode.h 2009-09-10 15:26:22.000000000 +0200
4143 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/gfs2/inode.h 2009-12-03 20:04:56.000000000 +0100
4144 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
4145 extern const struct file_operations gfs2_dir_fops_nolock;
4147 extern void gfs2_set_inode_flags(struct inode *inode);
4148 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4150 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4151 extern const struct file_operations gfs2_file_fops;
4152 diff -NurpP --minimal linux-2.6.32.24/fs/gfs2/ops_inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/gfs2/ops_inode.c
4153 --- linux-2.6.32.24/fs/gfs2/ops_inode.c 2009-12-03 20:02:52.000000000 +0100
4154 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/gfs2/ops_inode.c 2009-12-03 20:04:56.000000000 +0100
4155 @@ -1400,6 +1400,7 @@ const struct inode_operations gfs2_file_
4156 .listxattr = gfs2_listxattr,
4157 .removexattr = gfs2_removexattr,
4158 .fiemap = gfs2_fiemap,
4159 + .sync_flags = gfs2_sync_flags,
4162 const struct inode_operations gfs2_dir_iops = {
4163 @@ -1420,6 +1421,7 @@ const struct inode_operations gfs2_dir_i
4164 .listxattr = gfs2_listxattr,
4165 .removexattr = gfs2_removexattr,
4166 .fiemap = gfs2_fiemap,
4167 + .sync_flags = gfs2_sync_flags,
4170 const struct inode_operations gfs2_symlink_iops = {
4171 diff -NurpP --minimal linux-2.6.32.24/fs/hfsplus/ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/hfsplus/ioctl.c
4172 --- linux-2.6.32.24/fs/hfsplus/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4173 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/hfsplus/ioctl.c 2009-12-03 20:04:56.000000000 +0100
4175 #include <linux/mount.h>
4176 #include <linux/sched.h>
4177 #include <linux/xattr.h>
4178 +#include <linux/mount.h>
4179 #include <asm/uaccess.h>
4180 #include "hfsplus_fs.h"
4182 diff -NurpP --minimal linux-2.6.32.24/fs/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/inode.c
4183 --- linux-2.6.32.24/fs/inode.c 2009-12-03 20:02:52.000000000 +0100
4184 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/inode.c 2009-12-03 20:04:56.000000000 +0100
4185 @@ -133,6 +133,9 @@ int inode_init_always(struct super_block
4186 struct address_space *const mapping = &inode->i_data;
4190 + /* essential because of inode slab reuse */
4192 inode->i_blkbits = sb->s_blocksize_bits;
4194 atomic_set(&inode->i_count, 1);
4195 @@ -153,6 +156,7 @@ int inode_init_always(struct super_block
4196 inode->i_bdev = NULL;
4197 inode->i_cdev = NULL;
4199 + inode->i_mdev = 0;
4200 inode->dirtied_when = 0;
4202 if (security_inode_alloc(inode))
4203 @@ -307,6 +311,8 @@ void __iget(struct inode *inode)
4204 inodes_stat.nr_unused--;
4207 +EXPORT_SYMBOL_GPL(__iget);
4210 * clear_inode - clear an inode
4211 * @inode: inode to clear
4212 @@ -1611,9 +1617,11 @@ void init_special_inode(struct inode *in
4213 if (S_ISCHR(mode)) {
4214 inode->i_fop = &def_chr_fops;
4215 inode->i_rdev = rdev;
4216 + inode->i_mdev = rdev;
4217 } else if (S_ISBLK(mode)) {
4218 inode->i_fop = &def_blk_fops;
4219 inode->i_rdev = rdev;
4220 + inode->i_mdev = rdev;
4221 } else if (S_ISFIFO(mode))
4222 inode->i_fop = &def_fifo_fops;
4223 else if (S_ISSOCK(mode))
4224 diff -NurpP --minimal linux-2.6.32.24/fs/ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ioctl.c
4225 --- linux-2.6.32.24/fs/ioctl.c 2009-12-03 20:02:52.000000000 +0100
4226 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ioctl.c 2009-12-03 20:04:56.000000000 +0100
4228 #include <linux/writeback.h>
4229 #include <linux/buffer_head.h>
4230 #include <linux/falloc.h>
4231 +#include <linux/proc_fs.h>
4232 +#include <linux/vserver/inode.h>
4233 +#include <linux/vs_tag.h>
4235 #include <asm/ioctls.h>
4237 diff -NurpP --minimal linux-2.6.32.24/fs/ioprio.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ioprio.c
4238 --- linux-2.6.32.24/fs/ioprio.c 2009-03-24 14:22:26.000000000 +0100
4239 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ioprio.c 2009-12-03 20:04:56.000000000 +0100
4241 #include <linux/syscalls.h>
4242 #include <linux/security.h>
4243 #include <linux/pid_namespace.h>
4244 +#include <linux/vs_base.h>
4246 int set_task_ioprio(struct task_struct *task, int ioprio)
4248 @@ -123,6 +124,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4250 pgrp = find_vpid(who);
4251 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4252 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4254 ret = set_task_ioprio(p, ioprio);
4257 @@ -212,6 +215,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4259 pgrp = find_vpid(who);
4260 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4261 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4263 tmpio = get_task_ioprio(p);
4266 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/acl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/acl.c
4267 --- linux-2.6.32.24/fs/jfs/acl.c 2009-12-03 20:02:52.000000000 +0100
4268 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/acl.c 2009-12-03 20:04:56.000000000 +0100
4269 @@ -216,7 +216,8 @@ int jfs_setattr(struct dentry *dentry, s
4272 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4273 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4274 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4275 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4276 if (vfs_dq_transfer(inode, iattr))
4279 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/file.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/file.c
4280 --- linux-2.6.32.24/fs/jfs/file.c 2009-12-03 20:02:52.000000000 +0100
4281 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/file.c 2009-12-03 20:04:56.000000000 +0100
4282 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
4283 .setattr = jfs_setattr,
4284 .check_acl = jfs_check_acl,
4286 + .sync_flags = jfs_sync_flags,
4289 const struct file_operations jfs_file_operations = {
4290 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/ioctl.c
4291 --- linux-2.6.32.24/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4292 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/ioctl.c 2009-12-03 20:04:56.000000000 +0100
4294 #include <linux/mount.h>
4295 #include <linux/time.h>
4296 #include <linux/sched.h>
4297 +#include <linux/mount.h>
4298 #include <asm/current.h>
4299 #include <asm/uaccess.h>
4301 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4305 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4307 + inode->i_flags = flags;
4308 + inode->i_vflags = vflags;
4309 + jfs_get_inode_flags(JFS_IP(inode));
4310 + inode->i_ctime = CURRENT_TIME_SEC;
4311 + mark_inode_dirty(inode);
4315 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4317 struct inode *inode = filp->f_dentry->d_inode;
4318 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4319 if (!S_ISDIR(inode->i_mode))
4320 flags &= ~JFS_DIRSYNC_FL;
4322 + if (IS_BARRIER(inode)) {
4323 + vxwprintk_task(1, "messing with the barrier.");
4327 /* Is it quota file? Do not allow user to mess with it */
4328 if (IS_NOQUOTA(inode)) {
4330 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4331 * the relevant capability.
4333 if ((oldflags & JFS_IMMUTABLE_FL) ||
4334 - ((flags ^ oldflags) &
4335 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4336 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4337 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4338 if (!capable(CAP_LINUX_IMMUTABLE)) {
4339 mutex_unlock(&inode->i_mutex);
4341 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4345 - flags = flags & JFS_FL_USER_MODIFIABLE;
4346 + flags &= JFS_FL_USER_MODIFIABLE;
4347 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4348 jfs_inode->mode2 = flags;
4350 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/jfs_dinode.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_dinode.h
4351 --- linux-2.6.32.24/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4352 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_dinode.h 2009-12-03 20:04:56.000000000 +0100
4353 @@ -161,9 +161,13 @@ struct dinode {
4355 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4356 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4357 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4359 -#define JFS_FL_USER_VISIBLE 0x03F80000
4360 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4361 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4362 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4364 +#define JFS_FL_USER_VISIBLE 0x07F80000
4365 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4366 #define JFS_FL_INHERIT 0x03C80000
4368 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4369 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/jfs_filsys.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_filsys.h
4370 --- linux-2.6.32.24/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4371 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_filsys.h 2009-12-03 20:04:56.000000000 +0100
4373 #define JFS_NAME_MAX 255
4374 #define JFS_PATH_MAX BPSIZE
4376 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4379 * file system state (superblock state)
4380 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/jfs_imap.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_imap.c
4381 --- linux-2.6.32.24/fs/jfs/jfs_imap.c 2009-09-10 15:26:22.000000000 +0200
4382 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_imap.c 2009-12-03 20:04:56.000000000 +0100
4384 #include <linux/buffer_head.h>
4385 #include <linux/pagemap.h>
4386 #include <linux/quotaops.h>
4387 +#include <linux/vs_tag.h>
4389 #include "jfs_incore.h"
4390 #include "jfs_inode.h"
4391 @@ -3059,6 +3060,8 @@ static int copy_from_dinode(struct dinod
4393 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4394 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4398 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4399 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4400 @@ -3079,14 +3082,18 @@ static int copy_from_dinode(struct dinod
4402 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4404 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4405 + uid = le32_to_cpu(dip->di_uid);
4406 + gid = le32_to_cpu(dip->di_gid);
4407 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4409 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4411 ip->i_uid = jfs_ip->saved_uid;
4413 ip->i_uid = sbi->uid;
4416 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4417 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4419 ip->i_gid = jfs_ip->saved_gid;
4421 @@ -3151,14 +3158,12 @@ static void copy_to_dinode(struct dinode
4422 dip->di_size = cpu_to_le64(ip->i_size);
4423 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4424 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4425 - if (sbi->uid == -1)
4426 - dip->di_uid = cpu_to_le32(ip->i_uid);
4428 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4429 - if (sbi->gid == -1)
4430 - dip->di_gid = cpu_to_le32(ip->i_gid);
4432 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4434 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4435 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4436 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4437 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4439 jfs_get_inode_flags(jfs_ip);
4441 * mode2 is only needed for storing the higher order bits.
4442 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/jfs_inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_inode.c
4443 --- linux-2.6.32.24/fs/jfs/jfs_inode.c 2009-06-11 17:13:05.000000000 +0200
4444 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_inode.c 2009-12-03 20:04:56.000000000 +0100
4447 #include <linux/fs.h>
4448 #include <linux/quotaops.h>
4449 +#include <linux/vs_tag.h>
4450 #include "jfs_incore.h"
4451 #include "jfs_inode.h"
4452 #include "jfs_filsys.h"
4453 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4455 unsigned int flags = JFS_IP(inode)->mode2;
4457 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4458 - S_NOATIME | S_DIRSYNC | S_SYNC);
4459 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4460 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4462 if (flags & JFS_IMMUTABLE_FL)
4463 inode->i_flags |= S_IMMUTABLE;
4464 + if (flags & JFS_IXUNLINK_FL)
4465 + inode->i_flags |= S_IXUNLINK;
4467 + if (flags & JFS_SYNC_FL)
4468 + inode->i_flags |= S_SYNC;
4469 if (flags & JFS_APPEND_FL)
4470 inode->i_flags |= S_APPEND;
4471 if (flags & JFS_NOATIME_FL)
4472 inode->i_flags |= S_NOATIME;
4473 if (flags & JFS_DIRSYNC_FL)
4474 inode->i_flags |= S_DIRSYNC;
4475 - if (flags & JFS_SYNC_FL)
4476 - inode->i_flags |= S_SYNC;
4478 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4480 + if (flags & JFS_BARRIER_FL)
4481 + inode->i_vflags |= V_BARRIER;
4482 + if (flags & JFS_COW_FL)
4483 + inode->i_vflags |= V_COW;
4486 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4488 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4489 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4491 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4492 + JFS_APPEND_FL | JFS_NOATIME_FL |
4493 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4494 + JFS_BARRIER_FL | JFS_COW_FL);
4496 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4497 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4498 if (flags & S_IMMUTABLE)
4499 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4500 + if (flags & S_IXUNLINK)
4501 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4503 if (flags & S_APPEND)
4504 jfs_ip->mode2 |= JFS_APPEND_FL;
4505 if (flags & S_NOATIME)
4506 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4507 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4509 jfs_ip->mode2 |= JFS_SYNC_FL;
4511 + if (vflags & V_BARRIER)
4512 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4513 + if (vflags & V_COW)
4514 + jfs_ip->mode2 |= JFS_COW_FL;
4518 @@ -105,6 +128,7 @@ struct inode *ialloc(struct inode *paren
4521 inode->i_gid = current_fsgid();
4522 + inode->i_tag = dx_current_fstag(sb);
4525 * New inodes need to save sane values on disk when
4526 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/jfs_inode.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_inode.h
4527 --- linux-2.6.32.24/fs/jfs/jfs_inode.h 2009-06-11 17:13:05.000000000 +0200
4528 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/jfs_inode.h 2009-12-03 20:04:56.000000000 +0100
4529 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4530 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4531 int fh_len, int fh_type);
4532 extern void jfs_set_inode_flags(struct inode *);
4533 +extern int jfs_sync_flags(struct inode *, int, int);
4534 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4536 extern const struct address_space_operations jfs_aops;
4537 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/namei.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/namei.c
4538 --- linux-2.6.32.24/fs/jfs/namei.c 2009-12-03 20:02:52.000000000 +0100
4539 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/namei.c 2009-12-03 20:04:56.000000000 +0100
4541 #include <linux/ctype.h>
4542 #include <linux/quotaops.h>
4543 #include <linux/exportfs.h>
4544 +#include <linux/vs_tag.h>
4545 #include "jfs_incore.h"
4546 #include "jfs_superblock.h"
4547 #include "jfs_inode.h"
4548 @@ -1476,6 +1477,7 @@ static struct dentry *jfs_lookup(struct
4549 return ERR_CAST(ip);
4552 + dx_propagate_tag(nd, ip);
4553 dentry = d_splice_alias(ip, dentry);
4555 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4556 @@ -1545,6 +1547,7 @@ const struct inode_operations jfs_dir_in
4557 .setattr = jfs_setattr,
4558 .check_acl = jfs_check_acl,
4560 + .sync_flags = jfs_sync_flags,
4563 const struct file_operations jfs_dir_operations = {
4564 diff -NurpP --minimal linux-2.6.32.24/fs/jfs/super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/super.c
4565 --- linux-2.6.32.24/fs/jfs/super.c 2009-12-03 20:02:52.000000000 +0100
4566 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/jfs/super.c 2009-12-03 20:04:56.000000000 +0100
4567 @@ -192,7 +192,8 @@ static void jfs_put_super(struct super_b
4569 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4570 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4571 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4572 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4573 + Opt_tag, Opt_notag, Opt_tagid
4576 static const match_table_t tokens = {
4577 @@ -202,6 +203,10 @@ static const match_table_t tokens = {
4578 {Opt_resize, "resize=%u"},
4579 {Opt_resize_nosize, "resize"},
4580 {Opt_errors, "errors=%s"},
4582 + {Opt_notag, "notag"},
4583 + {Opt_tagid, "tagid=%u"},
4584 + {Opt_tag, "tagxid"},
4585 {Opt_ignore, "noquota"},
4586 {Opt_ignore, "quota"},
4587 {Opt_usrquota, "usrquota"},
4588 @@ -336,6 +341,20 @@ static int parse_options(char *options,
4592 +#ifndef CONFIG_TAGGING_NONE
4594 + *flag |= JFS_TAGGED;
4597 + *flag &= JFS_TAGGED;
4600 +#ifdef CONFIG_PROPAGATE
4603 + *flag |= JFS_TAGGED;
4607 printk("jfs: Unrecognized mount option \"%s\" "
4608 " or missing value\n", p);
4609 @@ -366,6 +385,12 @@ static int jfs_remount(struct super_bloc
4610 if (!parse_options(data, sb, &newLVSize, &flag)) {
4613 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4614 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4621 if (sb->s_flags & MS_RDONLY) {
4622 @@ -449,6 +474,9 @@ static int jfs_fill_super(struct super_b
4623 #ifdef CONFIG_JFS_POSIX_ACL
4624 sb->s_flags |= MS_POSIXACL;
4626 + /* map mount option tagxid */
4627 + if (sbi->flag & JFS_TAGGED)
4628 + sb->s_flags |= MS_TAGGED;
4631 printk(KERN_ERR "resize option for remount only\n");
4632 diff -NurpP --minimal linux-2.6.32.24/fs/libfs.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/libfs.c
4633 --- linux-2.6.32.24/fs/libfs.c 2010-10-04 08:56:13.000000000 +0200
4634 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/libfs.c 2010-07-08 02:22:31.000000000 +0200
4635 @@ -127,7 +127,8 @@ static inline unsigned char dt_type(stru
4636 * both impossible due to the lock on directory.
4639 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4640 +static inline int do_dcache_readdir_filter(struct file *filp,
4641 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4643 struct dentry *dentry = filp->f_path.dentry;
4644 struct dentry *cursor = filp->private_data;
4645 @@ -160,6 +161,8 @@ int dcache_readdir(struct file * filp, v
4646 next = list_entry(p, struct dentry, d_u.d_child);
4647 if (d_unhashed(next) || !next->d_inode)
4649 + if (filter && !filter(next))
4652 spin_unlock(&dcache_lock);
4653 if (filldir(dirent, next->d_name.name,
4654 @@ -178,6 +181,18 @@ int dcache_readdir(struct file * filp, v
4658 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4660 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4663 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4664 + int (*filter)(struct dentry *))
4666 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4670 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4673 @@ -842,6 +857,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4674 EXPORT_SYMBOL(dcache_dir_lseek);
4675 EXPORT_SYMBOL(dcache_dir_open);
4676 EXPORT_SYMBOL(dcache_readdir);
4677 +EXPORT_SYMBOL(dcache_readdir_filter);
4678 EXPORT_SYMBOL(generic_read_dir);
4679 EXPORT_SYMBOL(get_sb_pseudo);
4680 EXPORT_SYMBOL(simple_write_begin);
4681 diff -NurpP --minimal linux-2.6.32.24/fs/locks.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/locks.c
4682 --- linux-2.6.32.24/fs/locks.c 2009-12-03 20:02:52.000000000 +0100
4683 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/locks.c 2009-12-03 20:04:56.000000000 +0100
4685 #include <linux/time.h>
4686 #include <linux/rcupdate.h>
4687 #include <linux/pid_namespace.h>
4688 +#include <linux/vs_base.h>
4689 +#include <linux/vs_limit.h>
4691 #include <asm/uaccess.h>
4693 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4694 /* Allocate an empty lock structure. */
4695 static struct file_lock *locks_alloc_lock(void)
4697 + if (!vx_locks_avail(1))
4699 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4702 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
4703 BUG_ON(!list_empty(&fl->fl_block));
4704 BUG_ON(!list_empty(&fl->fl_link));
4707 locks_release_private(fl);
4708 kmem_cache_free(filelock_cache, fl);
4710 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
4711 fl->fl_start = fl->fl_end = 0;
4713 fl->fl_lmops = NULL;
4717 EXPORT_SYMBOL(locks_init_lock);
4718 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
4719 new->fl_file = fl->fl_file;
4720 new->fl_ops = fl->fl_ops;
4721 new->fl_lmops = fl->fl_lmops;
4722 + new->fl_xid = fl->fl_xid;
4724 locks_copy_private(new, fl);
4726 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
4727 fl->fl_flags = FL_FLOCK;
4729 fl->fl_end = OFFSET_MAX;
4731 + vxd_assert(filp->f_xid == vx_current_xid(),
4732 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4733 + fl->fl_xid = filp->f_xid;
4738 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
4740 fl->fl_owner = current->files;
4741 fl->fl_pid = current->tgid;
4742 + fl->fl_xid = vx_current_xid();
4745 fl->fl_flags = FL_LEASE;
4746 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
4748 return ERR_PTR(error);
4750 + fl->fl_xid = vx_current_xid();
4752 + vxd_assert(filp->f_xid == fl->fl_xid,
4753 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4755 error = lease_init(filp, type, fl);
4757 locks_free_lock(fl);
4758 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
4762 + new_fl->fl_xid = -1;
4764 for_each_lock(inode, before) {
4765 struct file_lock *fl = *before;
4766 @@ -790,6 +809,7 @@ find_conflict:
4768 locks_copy_lock(new_fl, request);
4769 locks_insert_lock(before, new_fl);
4770 + vx_locks_inc(new_fl);
4774 @@ -800,7 +820,8 @@ out:
4778 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4779 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4780 + struct file_lock *conflock, xid_t xid)
4782 struct file_lock *fl;
4783 struct file_lock *new_fl = NULL;
4784 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
4785 struct file_lock **before;
4786 int error, added = 0;
4788 + vxd_assert(xid == vx_current_xid(),
4789 + "xid(%d) == current(%d)", xid, vx_current_xid());
4791 * We may need two file_lock structures for this operation,
4792 * so we get them in advance to avoid races.
4793 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
4794 (request->fl_type != F_UNLCK ||
4795 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4796 new_fl = locks_alloc_lock();
4797 + new_fl->fl_xid = xid;
4798 + vx_locks_inc(new_fl);
4799 new_fl2 = locks_alloc_lock();
4800 + new_fl2->fl_xid = xid;
4801 + vx_locks_inc(new_fl2);
4805 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
4806 int posix_lock_file(struct file *filp, struct file_lock *fl,
4807 struct file_lock *conflock)
4809 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4810 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4811 + fl, conflock, filp->f_xid);
4813 EXPORT_SYMBOL(posix_lock_file);
4815 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
4816 fl.fl_end = offset + count - 1;
4819 - error = __posix_lock_file(inode, &fl, NULL);
4820 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4821 if (error != FILE_LOCK_DEFERRED)
4823 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4824 @@ -1424,6 +1452,7 @@ int generic_setlease(struct file *filp,
4826 locks_copy_lock(new_fl, lease);
4827 locks_insert_lock(before, new_fl);
4828 + vx_locks_inc(new_fl);
4832 @@ -1779,6 +1808,11 @@ int fcntl_setlk(unsigned int fd, struct
4833 if (file_lock == NULL)
4836 + vxd_assert(filp->f_xid == vx_current_xid(),
4837 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4838 + file_lock->fl_xid = filp->f_xid;
4839 + vx_locks_inc(file_lock);
4842 * This might block, so we do it before checking the inode.
4844 @@ -1897,6 +1931,11 @@ int fcntl_setlk64(unsigned int fd, struc
4845 if (file_lock == NULL)
4848 + vxd_assert(filp->f_xid == vx_current_xid(),
4849 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4850 + file_lock->fl_xid = filp->f_xid;
4851 + vx_locks_inc(file_lock);
4854 * This might block, so we do it before checking the inode.
4856 @@ -2162,8 +2201,11 @@ static int locks_show(struct seq_file *f
4858 lock_get_status(f, fl, (long)f->private, "");
4860 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4861 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4862 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4864 lock_get_status(f, bfl, (long)f->private, " ->");
4869 diff -NurpP --minimal linux-2.6.32.24/fs/namei.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/namei.c
4870 --- linux-2.6.32.24/fs/namei.c 2010-10-04 08:56:13.000000000 +0200
4871 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/namei.c 2010-03-18 16:53:06.000000000 +0100
4873 #include <linux/fcntl.h>
4874 #include <linux/device_cgroup.h>
4875 #include <linux/fs_struct.h>
4876 +#include <linux/proc_fs.h>
4877 +#include <linux/vserver/inode.h>
4878 +#include <linux/vs_base.h>
4879 +#include <linux/vs_tag.h>
4880 +#include <linux/vs_cowbl.h>
4881 +#include <linux/vs_device.h>
4882 +#include <linux/vs_context.h>
4883 +#include <linux/pid_namespace.h>
4884 #include <asm/uaccess.h>
4886 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
4887 @@ -169,6 +177,77 @@ void putname(const char *name)
4888 EXPORT_SYMBOL(putname);
4891 +static inline int dx_barrier(const struct inode *inode)
4893 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4894 + vxwprintk_task(1, "did hit the barrier.");
4900 +static int __dx_permission(const struct inode *inode, int mask)
4902 + if (dx_barrier(inode))
4905 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4906 + /* devpts is xid tagged */
4907 + if (S_ISDIR(inode->i_mode) ||
4908 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4911 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4912 + struct proc_dir_entry *de = PDE(inode);
4914 + if (de && !vx_hide_check(0, de->vx_flags))
4917 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4919 + struct task_struct *tsk;
4921 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4922 + vx_flags(VXF_STATE_SETUP, 0))
4925 + pid = PROC_I(inode)->pid;
4929 + tsk = pid_task(pid, PIDTYPE_PID);
4930 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4931 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4932 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4936 + /* FIXME: Should we block some entries here? */
4941 + if (dx_notagcheck(inode->i_sb) ||
4942 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4951 +int dx_permission(const struct inode *inode, int mask)
4953 + int ret = __dx_permission(inode, mask);
4954 + if (unlikely(ret)) {
4955 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
4956 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4963 * This does basic POSIX ACL permission checking
4965 @@ -269,10 +348,14 @@ int inode_permission(struct inode *inode
4967 * Nobody gets write access to an immutable file.
4969 - if (IS_IMMUTABLE(inode))
4970 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4974 + retval = dx_permission(inode, mask);
4978 if (inode->i_op->permission)
4979 retval = inode->i_op->permission(inode, mask);
4981 @@ -448,6 +531,9 @@ static int exec_permission_lite(struct i
4985 + if (dx_barrier(inode))
4988 if (inode->i_op->permission) {
4989 ret = inode->i_op->permission(inode, MAY_EXEC);
4991 @@ -763,7 +849,8 @@ static __always_inline void follow_dotdo
4993 if (nd->path.dentry == nd->root.dentry &&
4994 nd->path.mnt == nd->root.mnt) {
4996 + /* for sane '/' avoid follow_mount() */
4999 spin_lock(&dcache_lock);
5000 if (nd->path.dentry != nd->path.mnt->mnt_root) {
5001 @@ -799,16 +886,30 @@ static int do_lookup(struct nameidata *n
5003 struct vfsmount *mnt = nd->path.mnt;
5004 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
5005 + struct inode *inode;
5009 if (dentry->d_op && dentry->d_op->d_revalidate)
5010 goto need_revalidate;
5011 + inode = dentry->d_inode;
5015 + if (__dx_permission(inode, MAY_ACCESS))
5020 path->dentry = dentry;
5021 __follow_mount(path);
5024 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s/%.*s«.",
5025 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5026 + vxd_path(&nd->path), name->len, name->name);
5031 dentry = real_lookup(nd->path.dentry, name, nd);
5032 @@ -1400,7 +1501,7 @@ static int may_delete(struct inode *dir,
5035 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5036 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5037 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5040 if (!S_ISDIR(victim->d_inode->i_mode))
5041 @@ -1540,6 +1641,14 @@ int may_open(struct path *path, int acc_
5045 +#ifdef CONFIG_VSERVER_COWBL
5046 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5047 + if (IS_COW_LINK(inode))
5049 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5050 + mark_inode_dirty(inode);
5053 error = inode_permission(inode, acc_mode);
5056 @@ -1688,7 +1797,11 @@ struct file *do_filp_open(int dfd, const
5059 int flag = open_to_namei_flags(open_flag);
5061 +#ifdef CONFIG_VSERVER_COWBL
5067 acc_mode = MAY_OPEN | ACC_MODE(flag);
5069 @@ -1836,6 +1949,25 @@ ok:
5072 error = may_open(&nd.path, acc_mode, flag);
5073 +#ifdef CONFIG_VSERVER_COWBL
5074 + if (error == -EMLINK) {
5075 + struct dentry *dentry;
5076 + dentry = cow_break_link(pathname);
5077 + if (IS_ERR(dentry)) {
5078 + error = PTR_ERR(dentry);
5083 + mnt_drop_write(nd.path.mnt);
5084 + release_open_intent(&nd);
5085 + path_put(&nd.path);
5094 mnt_drop_write(nd.path.mnt);
5095 @@ -1998,9 +2130,17 @@ int vfs_mknod(struct inode *dir, struct
5099 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5100 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5103 + if (!capable(CAP_MKNOD))
5106 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5108 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5111 if (!dir->i_op->mknod)
5114 @@ -2467,7 +2607,7 @@ int vfs_link(struct dentry *old_dentry,
5116 * A link to an append-only or immutable file cannot be created.
5118 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5119 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5121 if (!dir->i_op->link)
5123 @@ -2840,6 +2980,219 @@ int vfs_follow_link(struct nameidata *nd
5124 return __vfs_follow_link(nd, link);
5128 +#ifdef CONFIG_VSERVER_COWBL
5130 +#include <linux/file.h>
5133 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5137 + return do_splice_direct(in, &ppos, out, len, 0);
5140 +struct dentry *cow_break_link(const char *pathname)
5142 + int ret, mode, pathlen, redo = 0;
5143 + struct nameidata old_nd, dir_nd;
5144 + struct path old_path, new_path;
5145 + struct dentry *dir, *res = NULL;
5146 + struct file *old_file;
5147 + struct file *new_file;
5148 + char *to, *path, pad='\251';
5151 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5152 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5157 + /* old_nd will have refs to dentry and mnt */
5158 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5159 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5161 + goto out_free_path;
5163 + old_path = old_nd.path;
5164 + mode = old_path.dentry->d_inode->i_mode;
5166 + to = d_path(&old_path, path, PATH_MAX-2);
5167 + pathlen = strlen(to);
5168 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5169 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5170 + old_path.dentry->d_name.len);
5172 + to[pathlen + 1] = 0;
5174 + to[pathlen] = pad--;
5176 + if (pad <= '\240')
5179 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5180 + /* dir_nd will have refs to dentry and mnt */
5181 + ret = path_lookup(to,
5182 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5183 + vxdprintk(VXD_CBIT(misc, 2),
5184 + "path_lookup(new): %d", ret);
5188 + /* this puppy downs the inode mutex */
5189 + new_path.dentry = lookup_create(&dir_nd, 0);
5190 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5191 + vxdprintk(VXD_CBIT(misc, 2),
5192 + "lookup_create(new): %p", new_path.dentry);
5193 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5194 + path_put(&dir_nd.path);
5197 + vxdprintk(VXD_CBIT(misc, 2),
5198 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5199 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5200 + new_path.dentry->d_name.len);
5201 + dir = dir_nd.path.dentry;
5203 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5204 + vxdprintk(VXD_CBIT(misc, 2),
5205 + "vfs_create(new): %d", ret);
5206 + if (ret == -EEXIST) {
5207 + mutex_unlock(&dir->d_inode->i_mutex);
5208 + dput(new_path.dentry);
5209 + path_put(&dir_nd.path);
5213 + goto out_unlock_new;
5215 + /* drop out early, ret passes ENOENT */
5217 + if ((redo = d_unhashed(old_path.dentry)))
5218 + goto out_unlock_new;
5220 + new_path.mnt = dir_nd.path.mnt;
5221 + dget(old_path.dentry);
5222 + mntget(old_path.mnt);
5223 + /* this one cleans up the dentry/mnt in case of failure */
5224 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5225 + O_RDONLY, current_cred());
5226 + vxdprintk(VXD_CBIT(misc, 2),
5227 + "dentry_open(old): %p", old_file);
5228 + if (!old_file || IS_ERR(old_file)) {
5229 + res = IS_ERR(old_file) ? (void *) old_file : res;
5230 + goto out_unlock_new;
5233 + dget(new_path.dentry);
5234 + mntget(new_path.mnt);
5235 + /* this one cleans up the dentry/mnt in case of failure */
5236 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5237 + O_WRONLY, current_cred());
5238 + vxdprintk(VXD_CBIT(misc, 2),
5239 + "dentry_open(new): %p", new_file);
5241 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5242 + if (!new_file || IS_ERR(new_file))
5243 + goto out_fput_old;
5245 + size = i_size_read(old_file->f_dentry->d_inode);
5246 + ret = do_cow_splice(old_file, new_file, size);
5247 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5249 + goto out_fput_both;
5250 + } else if (ret < size) {
5252 + goto out_fput_both;
5254 + struct inode *old_inode = old_path.dentry->d_inode;
5255 + struct inode *new_inode = new_path.dentry->d_inode;
5256 + struct iattr attr = {
5257 + .ia_uid = old_inode->i_uid,
5258 + .ia_gid = old_inode->i_gid,
5259 + .ia_valid = ATTR_UID | ATTR_GID
5262 + ret = inode_setattr(new_inode, &attr);
5264 + goto out_fput_both;
5267 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5269 + /* drop out late */
5271 + if ((redo = d_unhashed(old_path.dentry)))
5274 + vxdprintk(VXD_CBIT(misc, 2),
5275 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5276 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5277 + new_path.dentry->d_name.len,
5278 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5279 + old_path.dentry->d_name.len);
5280 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5281 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5282 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5283 + res = new_path.dentry;
5286 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5289 + vxdprintk(VXD_CBIT(misc, 3),
5290 + "fput(new_file=%p[#%ld])", new_file,
5291 + atomic_long_read(&new_file->f_count));
5295 + vxdprintk(VXD_CBIT(misc, 3),
5296 + "fput(old_file=%p[#%ld])", old_file,
5297 + atomic_long_read(&old_file->f_count));
5301 + mutex_unlock(&dir->d_inode->i_mutex);
5305 + /* error path cleanup */
5306 + vfs_unlink(dir->d_inode, new_path.dentry);
5307 + dput(new_path.dentry);
5311 + goto out_rel_both;
5312 + /* lookup dentry once again */
5313 + path_put(&old_nd.path);
5314 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5316 + goto out_rel_both;
5318 + new_path.dentry = old_nd.path.dentry;
5319 + vxdprintk(VXD_CBIT(misc, 2),
5320 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5321 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5322 + new_path.dentry->d_name.len);
5323 + dget(new_path.dentry);
5324 + res = new_path.dentry;
5327 + path_put(&dir_nd.path);
5329 + path_put(&old_nd.path);
5334 + res = ERR_PTR(ret);
5340 /* get the link contents into pagecache */
5341 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5343 diff -NurpP --minimal linux-2.6.32.24/fs/namespace.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/namespace.c
5344 --- linux-2.6.32.24/fs/namespace.c 2010-10-04 08:56:13.000000000 +0200
5345 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/namespace.c 2010-07-08 02:22:31.000000000 +0200
5347 #include <linux/log2.h>
5348 #include <linux/idr.h>
5349 #include <linux/fs_struct.h>
5350 +#include <linux/vs_base.h>
5351 +#include <linux/vs_context.h>
5352 +#include <linux/vs_tag.h>
5353 +#include <linux/vserver/space.h>
5354 +#include <linux/vserver/global.h>
5355 #include <asm/uaccess.h>
5356 #include <asm/unistd.h>
5358 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
5359 mnt->mnt_root = dget(root);
5360 mnt->mnt_mountpoint = mnt->mnt_root;
5361 mnt->mnt_parent = mnt;
5362 + mnt->mnt_tag = old->mnt_tag;
5364 if (flag & CL_SLAVE) {
5365 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5366 @@ -661,6 +667,31 @@ static inline void mangle(struct seq_fil
5367 seq_escape(m, s, " \t\n\\");
5370 +static int mnt_is_reachable(struct vfsmount *mnt)
5373 + struct dentry *point;
5376 + if (mnt == mnt->mnt_ns->root)
5379 + spin_lock(&vfsmount_lock);
5380 + root = current->fs->root;
5381 + point = root.dentry;
5383 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5384 + point = mnt->mnt_mountpoint;
5385 + mnt = mnt->mnt_parent;
5388 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5390 + spin_unlock(&vfsmount_lock);
5396 * Simple .show_options callback for filesystems which don't want to
5397 * implement more complex mount option showing.
5398 @@ -748,6 +779,8 @@ static int show_sb_opts(struct seq_file
5399 { MS_SYNCHRONOUS, ",sync" },
5400 { MS_DIRSYNC, ",dirsync" },
5401 { MS_MANDLOCK, ",mand" },
5402 + { MS_TAGGED, ",tag" },
5403 + { MS_NOTAGCHECK, ",notagcheck" },
5406 const struct proc_fs_info *fs_infop;
5407 @@ -795,10 +828,20 @@ static int show_vfsmnt(struct seq_file *
5409 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5411 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5413 - seq_path(m, &mnt_path, " \t\n\\");
5415 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5417 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5420 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5421 + mnt == current->fs->root.mnt) {
5422 + seq_puts(m, "/dev/root / ");
5424 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5426 + seq_path(m, &mnt_path, " \t\n\\");
5429 show_type(m, mnt->mnt_sb);
5430 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5431 err = show_sb_opts(m, mnt->mnt_sb);
5432 @@ -828,6 +871,11 @@ static int show_mountinfo(struct seq_fil
5433 struct path root = p->root;
5436 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5438 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5441 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5442 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5443 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5444 @@ -886,17 +934,27 @@ static int show_vfsstat(struct seq_file
5445 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5449 - if (mnt->mnt_devname) {
5450 - seq_puts(m, "device ");
5451 - mangle(m, mnt->mnt_devname);
5453 - seq_puts(m, "no device");
5454 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5456 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5460 - seq_puts(m, " mounted on ");
5461 - seq_path(m, &mnt_path, " \t\n\\");
5463 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5464 + mnt == current->fs->root.mnt) {
5465 + seq_puts(m, "device /dev/root mounted on / ");
5468 + if (mnt->mnt_devname) {
5469 + seq_puts(m, "device ");
5470 + mangle(m, mnt->mnt_devname);
5472 + seq_puts(m, "no device");
5475 + seq_puts(m, " mounted on ");
5476 + seq_path(m, &mnt_path, " \t\n\\");
5480 /* file system type */
5481 seq_puts(m, "with fstype ");
5482 @@ -1137,7 +1195,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5486 - if (!capable(CAP_SYS_ADMIN))
5487 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5490 retval = do_umount(path.mnt, flags);
5491 @@ -1163,7 +1221,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5493 static int mount_is_safe(struct path *path)
5495 - if (capable(CAP_SYS_ADMIN))
5496 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5500 @@ -1427,7 +1485,7 @@ static int do_change_type(struct path *p
5501 int type = flag & ~MS_REC;
5504 - if (!capable(CAP_SYS_ADMIN))
5505 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5508 if (path->dentry != path->mnt->mnt_root)
5509 @@ -1454,11 +1512,13 @@ static int do_change_type(struct path *p
5510 * do loopback mount.
5512 static int do_loopback(struct path *path, char *old_name,
5514 + tag_t tag, unsigned long flags, int mnt_flags)
5516 struct path old_path;
5517 struct vfsmount *mnt = NULL;
5518 int err = mount_is_safe(path);
5519 + int recurse = flags & MS_REC;
5523 if (!old_name || !*old_name)
5524 @@ -1492,6 +1552,7 @@ static int do_loopback(struct path *path
5525 spin_unlock(&vfsmount_lock);
5526 release_mounts(&umount_list);
5528 + mnt->mnt_flags = mnt_flags;
5531 up_write(&namespace_sem);
5532 @@ -1522,12 +1583,12 @@ static int change_mount_flags(struct vfs
5533 * on it - tough luck.
5535 static int do_remount(struct path *path, int flags, int mnt_flags,
5537 + void *data, xid_t xid)
5540 struct super_block *sb = path->mnt->mnt_sb;
5542 - if (!capable(CAP_SYS_ADMIN))
5543 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5546 if (!check_mnt(path->mnt))
5547 @@ -1569,7 +1630,7 @@ static int do_move_mount(struct path *pa
5548 struct path old_path, parent_path;
5551 - if (!capable(CAP_SYS_ADMIN))
5552 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5554 if (!old_name || !*old_name)
5556 @@ -1651,7 +1712,7 @@ static int do_new_mount(struct path *pat
5559 /* we need capabilities... */
5560 - if (!capable(CAP_SYS_ADMIN))
5561 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5565 @@ -1915,6 +1976,7 @@ long do_mount(char *dev_name, char *dir_
5572 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5573 @@ -1932,6 +1994,12 @@ long do_mount(char *dev_name, char *dir_
5574 if (!(flags & MS_NOATIME))
5575 mnt_flags |= MNT_RELATIME;
5577 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5578 + /* FIXME: bind and re-mounts get the tag flag? */
5579 + if (flags & (MS_BIND|MS_REMOUNT))
5580 + flags |= MS_TAGID;
5583 /* Separate the per-mountpoint flags */
5584 if (flags & MS_NOSUID)
5585 mnt_flags |= MNT_NOSUID;
5586 @@ -1948,6 +2016,8 @@ long do_mount(char *dev_name, char *dir_
5587 if (flags & MS_RDONLY)
5588 mnt_flags |= MNT_READONLY;
5590 + if (!capable(CAP_SYS_ADMIN))
5591 + mnt_flags |= MNT_NODEV;
5592 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5593 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5595 @@ -1964,9 +2034,9 @@ long do_mount(char *dev_name, char *dir_
5597 if (flags & MS_REMOUNT)
5598 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5601 else if (flags & MS_BIND)
5602 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5603 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5604 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5605 retval = do_change_type(&path, flags);
5606 else if (flags & MS_MOVE)
5607 @@ -2045,6 +2115,7 @@ static struct mnt_namespace *dup_mnt_ns(
5608 q = next_mnt(q, new_ns->root);
5610 up_write(&namespace_sem);
5611 + atomic_inc(&vs_global_mnt_ns);
5615 @@ -2189,9 +2260,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5616 down_write(&namespace_sem);
5617 mutex_lock(&old.dentry->d_inode->i_mutex);
5619 - if (IS_MNT_SHARED(old.mnt) ||
5620 + if ((IS_MNT_SHARED(old.mnt) ||
5621 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5622 - IS_MNT_SHARED(root.mnt->mnt_parent))
5623 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5624 + !vx_flags(VXF_STATE_SETUP, 0))
5626 if (!check_mnt(root.mnt))
5628 @@ -2327,6 +2399,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5629 spin_unlock(&vfsmount_lock);
5630 up_write(&namespace_sem);
5631 release_mounts(&umount_list);
5632 + atomic_dec(&vs_global_mnt_ns);
5635 EXPORT_SYMBOL(put_mnt_ns);
5636 diff -NurpP --minimal linux-2.6.32.24/fs/nfs/client.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/client.c
5637 --- linux-2.6.32.24/fs/nfs/client.c 2010-10-04 08:56:13.000000000 +0200
5638 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/client.c 2010-09-22 00:48:38.000000000 +0200
5639 @@ -738,6 +738,9 @@ static int nfs_init_server_rpcclient(str
5640 if (server->flags & NFS_MOUNT_SOFT)
5641 server->client->cl_softrtry = 1;
5643 + server->client->cl_tag = 0;
5644 + if (server->flags & NFS_MOUNT_TAGGED)
5645 + server->client->cl_tag = 1;
5649 @@ -909,6 +912,10 @@ static void nfs_server_set_fsinfo(struct
5650 server->acdirmin = server->acdirmax = 0;
5653 + /* FIXME: needs fsinfo
5654 + if (server->flags & NFS_MOUNT_TAGGED)
5655 + sb->s_flags |= MS_TAGGED; */
5657 server->maxfilesize = fsinfo->maxfilesize;
5659 /* We're airborne Set socket buffersize */
5660 diff -NurpP --minimal linux-2.6.32.24/fs/nfs/dir.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/dir.c
5661 --- linux-2.6.32.24/fs/nfs/dir.c 2010-10-04 08:56:13.000000000 +0200
5662 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/dir.c 2010-05-21 13:20:19.000000000 +0200
5664 #include <linux/namei.h>
5665 #include <linux/mount.h>
5666 #include <linux/sched.h>
5667 +#include <linux/vs_tag.h>
5669 #include "nfs4_fs.h"
5670 #include "delegation.h"
5671 @@ -951,6 +952,7 @@ static struct dentry *nfs_lookup(struct
5673 goto out_unblock_sillyrename;
5675 + dx_propagate_tag(nd, inode);
5677 res = d_materialise_unique(dentry, inode);
5679 diff -NurpP --minimal linux-2.6.32.24/fs/nfs/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/inode.c
5680 --- linux-2.6.32.24/fs/nfs/inode.c 2010-10-04 08:56:13.000000000 +0200
5681 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/inode.c 2010-04-05 20:56:22.000000000 +0200
5683 #include <linux/vfs.h>
5684 #include <linux/inet.h>
5685 #include <linux/nfs_xdr.h>
5686 +#include <linux/vs_tag.h>
5688 #include <asm/system.h>
5689 #include <asm/uaccess.h>
5690 @@ -279,6 +280,8 @@ nfs_fhget(struct super_block *sb, struct
5691 if (inode->i_state & I_NEW) {
5692 struct nfs_inode *nfsi = NFS_I(inode);
5693 unsigned long now = jiffies;
5697 /* We set i_ino for the few things that still rely on it,
5698 * such as stat(2) */
5699 @@ -327,8 +330,8 @@ nfs_fhget(struct super_block *sb, struct
5700 nfsi->change_attr = 0;
5703 - inode->i_uid = -2;
5704 - inode->i_gid = -2;
5707 inode->i_blocks = 0;
5708 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5710 @@ -365,13 +368,13 @@ nfs_fhget(struct super_block *sb, struct
5711 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5712 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5713 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5714 - inode->i_uid = fattr->uid;
5716 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5717 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5718 | NFS_INO_INVALID_ACCESS
5719 | NFS_INO_INVALID_ACL;
5720 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5721 - inode->i_gid = fattr->gid;
5723 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5724 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5725 | NFS_INO_INVALID_ACCESS
5726 @@ -384,6 +387,11 @@ nfs_fhget(struct super_block *sb, struct
5728 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5730 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5731 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5732 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5733 + /* maybe fattr->xid someday */
5735 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5736 nfsi->attrtimeo_timestamp = now;
5737 nfsi->access_cache = RB_ROOT;
5738 @@ -496,6 +504,8 @@ void nfs_setattr_update_inode(struct ino
5739 inode->i_uid = attr->ia_uid;
5740 if ((attr->ia_valid & ATTR_GID) != 0)
5741 inode->i_gid = attr->ia_gid;
5742 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5743 + inode->i_tag = attr->ia_tag;
5744 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5745 spin_unlock(&inode->i_lock);
5747 @@ -906,6 +916,9 @@ static int nfs_check_inode_attributes(st
5748 struct nfs_inode *nfsi = NFS_I(inode);
5749 loff_t cur_size, new_isize;
5750 unsigned long invalid = 0;
5756 /* Has the inode gone and changed behind our back? */
5757 @@ -929,13 +942,18 @@ static int nfs_check_inode_attributes(st
5758 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5761 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5762 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5763 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5765 /* Have any file permissions changed? */
5766 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5767 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5768 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5769 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5770 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5771 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5772 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5773 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5774 + /* maybe check for tag too? */
5776 /* Has the link count changed? */
5777 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5778 @@ -1150,6 +1168,9 @@ static int nfs_update_inode(struct inode
5779 unsigned long invalid = 0;
5780 unsigned long now = jiffies;
5781 unsigned long save_cache_validity;
5786 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5787 __func__, inode->i_sb->s_id, inode->i_ino,
5788 @@ -1252,6 +1273,9 @@ static int nfs_update_inode(struct inode
5789 | NFS_INO_REVAL_PAGECACHE
5790 | NFS_INO_REVAL_FORCED);
5792 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5793 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5794 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5796 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5797 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5798 @@ -1271,9 +1295,9 @@ static int nfs_update_inode(struct inode
5799 | NFS_INO_REVAL_FORCED);
5801 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5802 - if (inode->i_uid != fattr->uid) {
5803 + if (uid != fattr->uid) {
5804 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5805 - inode->i_uid = fattr->uid;
5808 } else if (server->caps & NFS_CAP_OWNER)
5809 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5810 @@ -1282,9 +1306,9 @@ static int nfs_update_inode(struct inode
5811 | NFS_INO_REVAL_FORCED);
5813 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5814 - if (inode->i_gid != fattr->gid) {
5815 + if (gid != fattr->gid) {
5816 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5817 - inode->i_gid = fattr->gid;
5820 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5821 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5822 @@ -1292,6 +1316,10 @@ static int nfs_update_inode(struct inode
5823 | NFS_INO_INVALID_ACL
5824 | NFS_INO_REVAL_FORCED);
5826 + inode->i_uid = uid;
5827 + inode->i_gid = gid;
5828 + inode->i_tag = tag;
5830 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5831 if (inode->i_nlink != fattr->nlink) {
5832 invalid |= NFS_INO_INVALID_ATTR;
5833 diff -NurpP --minimal linux-2.6.32.24/fs/nfs/nfs3xdr.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/nfs3xdr.c
5834 --- linux-2.6.32.24/fs/nfs/nfs3xdr.c 2009-12-03 20:02:52.000000000 +0100
5835 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/nfs3xdr.c 2009-12-03 20:04:56.000000000 +0100
5837 #include <linux/nfs3.h>
5838 #include <linux/nfs_fs.h>
5839 #include <linux/nfsacl.h>
5840 +#include <linux/vs_tag.h>
5841 #include "internal.h"
5843 #define NFSDBG_FACILITY NFSDBG_XDR
5844 @@ -176,7 +177,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5847 static inline __be32 *
5848 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5849 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5851 if (attr->ia_valid & ATTR_MODE) {
5853 @@ -184,15 +185,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5857 - if (attr->ia_valid & ATTR_UID) {
5858 + if (attr->ia_valid & ATTR_UID ||
5859 + (tag && (attr->ia_valid & ATTR_TAG))) {
5861 - *p++ = htonl(attr->ia_uid);
5862 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5866 - if (attr->ia_valid & ATTR_GID) {
5867 + if (attr->ia_valid & ATTR_GID ||
5868 + (tag && (attr->ia_valid & ATTR_TAG))) {
5870 - *p++ = htonl(attr->ia_gid);
5871 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5875 @@ -279,7 +282,8 @@ static int
5876 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5878 p = xdr_encode_fhandle(p, args->fh);
5879 - p = xdr_encode_sattr(p, args->sattr);
5880 + p = xdr_encode_sattr(p, args->sattr,
5881 + req->rq_task->tk_client->cl_tag);
5882 *p++ = htonl(args->guard);
5884 p = xdr_encode_time3(p, &args->guardtime);
5885 @@ -384,7 +388,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5886 *p++ = args->verifier[0];
5887 *p++ = args->verifier[1];
5889 - p = xdr_encode_sattr(p, args->sattr);
5890 + p = xdr_encode_sattr(p, args->sattr,
5891 + req->rq_task->tk_client->cl_tag);
5893 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5895 @@ -398,7 +403,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5897 p = xdr_encode_fhandle(p, args->fh);
5898 p = xdr_encode_array(p, args->name, args->len);
5899 - p = xdr_encode_sattr(p, args->sattr);
5900 + p = xdr_encode_sattr(p, args->sattr,
5901 + req->rq_task->tk_client->cl_tag);
5902 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5905 @@ -411,7 +417,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
5907 p = xdr_encode_fhandle(p, args->fromfh);
5908 p = xdr_encode_array(p, args->fromname, args->fromlen);
5909 - p = xdr_encode_sattr(p, args->sattr);
5910 + p = xdr_encode_sattr(p, args->sattr,
5911 + req->rq_task->tk_client->cl_tag);
5912 *p++ = htonl(args->pathlen);
5913 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5915 @@ -429,7 +436,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
5916 p = xdr_encode_fhandle(p, args->fh);
5917 p = xdr_encode_array(p, args->name, args->len);
5918 *p++ = htonl(args->type);
5919 - p = xdr_encode_sattr(p, args->sattr);
5920 + p = xdr_encode_sattr(p, args->sattr,
5921 + req->rq_task->tk_client->cl_tag);
5922 if (args->type == NF3CHR || args->type == NF3BLK) {
5923 *p++ = htonl(MAJOR(args->rdev));
5924 *p++ = htonl(MINOR(args->rdev));
5925 diff -NurpP --minimal linux-2.6.32.24/fs/nfs/nfsroot.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/nfsroot.c
5926 --- linux-2.6.32.24/fs/nfs/nfsroot.c 2009-09-10 15:26:23.000000000 +0200
5927 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/nfsroot.c 2009-12-03 20:04:56.000000000 +0100
5928 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0; /
5930 /* Options that take integer arguments */
5931 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
5932 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
5933 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
5934 /* Options that take no arguments */
5935 Opt_soft, Opt_hard, Opt_intr,
5936 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
5937 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
5938 - Opt_acl, Opt_noacl,
5939 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
5943 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
5946 {Opt_noacl, "noacl"},
5948 + {Opt_notag, "notag"},
5949 + {Opt_tagid, "tagid=%u"},
5953 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
5955 nfs_data.flags |= NFS_MOUNT_NOACL;
5957 +#ifndef CONFIG_TAGGING_NONE
5959 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5962 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
5965 +#ifdef CONFIG_PROPAGATE
5968 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5972 printk(KERN_WARNING "Root-NFS: unknown "
5974 diff -NurpP --minimal linux-2.6.32.24/fs/nfs/super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/super.c
5975 --- linux-2.6.32.24/fs/nfs/super.c 2010-10-04 08:56:14.000000000 +0200
5976 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfs/super.c 2010-09-05 21:24:17.000000000 +0200
5978 #include <linux/nfs_xdr.h>
5979 #include <linux/magic.h>
5980 #include <linux/parser.h>
5981 +#include <linux/vs_tag.h>
5983 #include <asm/system.h>
5984 #include <asm/uaccess.h>
5985 @@ -570,6 +571,7 @@ static void nfs_show_mount_options(struc
5986 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5987 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5988 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5989 + { NFS_MOUNT_TAGGED, ",tag", "" },
5992 const struct proc_nfs_info *nfs_infop;
5993 diff -NurpP --minimal linux-2.6.32.24/fs/nfsd/auth.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfsd/auth.c
5994 --- linux-2.6.32.24/fs/nfsd/auth.c 2009-12-03 20:02:52.000000000 +0100
5995 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfsd/auth.c 2009-12-03 20:04:56.000000000 +0100
5997 #include <linux/sunrpc/svcauth.h>
5998 #include <linux/nfsd/nfsd.h>
5999 #include <linux/nfsd/export.h>
6000 +#include <linux/vs_tag.h>
6003 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
6004 @@ -44,6 +45,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6006 new->fsuid = rqstp->rq_cred.cr_uid;
6007 new->fsgid = rqstp->rq_cred.cr_gid;
6008 + /* FIXME: this desperately needs a tag :)
6009 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6012 rqgi = rqstp->rq_cred.cr_group_info;
6014 diff -NurpP --minimal linux-2.6.32.24/fs/nfsd/nfs3xdr.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfsd/nfs3xdr.c
6015 --- linux-2.6.32.24/fs/nfsd/nfs3xdr.c 2009-12-03 20:02:52.000000000 +0100
6016 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfsd/nfs3xdr.c 2009-12-03 20:04:56.000000000 +0100
6018 #include <linux/sunrpc/svc.h>
6019 #include <linux/nfsd/nfsd.h>
6020 #include <linux/nfsd/xdr3.h>
6021 +#include <linux/vs_tag.h>
6024 #define NFSDDBG_FACILITY NFSDDBG_XDR
6025 @@ -108,6 +109,8 @@ static __be32 *
6026 decode_sattr3(__be32 *p, struct iattr *iap)
6034 @@ -117,12 +120,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6037 iap->ia_valid |= ATTR_UID;
6038 - iap->ia_uid = ntohl(*p++);
6039 + uid = ntohl(*p++);
6042 iap->ia_valid |= ATTR_GID;
6043 - iap->ia_gid = ntohl(*p++);
6044 + gid = ntohl(*p++);
6046 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6047 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6048 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6052 @@ -178,8 +184,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6053 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6054 *p++ = htonl((u32) stat->mode);
6055 *p++ = htonl((u32) stat->nlink);
6056 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6057 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6058 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6059 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6060 + stat->uid, stat->tag)));
6061 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6062 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6063 + stat->gid, stat->tag)));
6064 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6065 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6067 diff -NurpP --minimal linux-2.6.32.24/fs/nfsd/nfs4xdr.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfsd/nfs4xdr.c
6068 --- linux-2.6.32.24/fs/nfsd/nfs4xdr.c 2010-10-04 08:56:14.000000000 +0200
6069 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfsd/nfs4xdr.c 2010-05-21 13:20:19.000000000 +0200
6071 #include <linux/nfs4_acl.h>
6072 #include <linux/sunrpc/gss_api.h>
6073 #include <linux/sunrpc/svcauth_gss.h>
6074 +#include <linux/vs_tag.h>
6076 #define NFSDDBG_FACILITY NFSDDBG_XDR
6078 @@ -2050,14 +2051,18 @@ out_acl:
6079 WRITE32(stat.nlink);
6081 if (bmval1 & FATTR4_WORD1_OWNER) {
6082 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6083 + status = nfsd4_encode_user(rqstp,
6084 + TAGINO_UID(DX_TAG(dentry->d_inode),
6085 + stat.uid, stat.tag), &p, &buflen);
6086 if (status == nfserr_resource)
6091 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6092 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6093 + status = nfsd4_encode_group(rqstp,
6094 + TAGINO_GID(DX_TAG(dentry->d_inode),
6095 + stat.gid, stat.tag), &p, &buflen);
6096 if (status == nfserr_resource)
6099 diff -NurpP --minimal linux-2.6.32.24/fs/nfsd/nfsxdr.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfsd/nfsxdr.c
6100 --- linux-2.6.32.24/fs/nfsd/nfsxdr.c 2008-12-25 00:26:37.000000000 +0100
6101 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/nfsd/nfsxdr.c 2009-12-03 20:04:56.000000000 +0100
6103 #include <linux/nfsd/nfsd.h>
6104 #include <linux/nfsd/xdr.h>
6105 #include <linux/mm.h>
6106 +#include <linux/vs_tag.h>
6109 #define NFSDDBG_FACILITY NFSDDBG_XDR
6110 @@ -98,6 +99,8 @@ static __be32 *
6111 decode_sattr(__be32 *p, struct iattr *iap)
6119 @@ -111,12 +114,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6121 if ((tmp = ntohl(*p++)) != (u32)-1) {
6122 iap->ia_valid |= ATTR_UID;
6123 - iap->ia_uid = tmp;
6126 if ((tmp = ntohl(*p++)) != (u32)-1) {
6127 iap->ia_valid |= ATTR_GID;
6128 - iap->ia_gid = tmp;
6131 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6132 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6133 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6134 if ((tmp = ntohl(*p++)) != (u32)-1) {
6135 iap->ia_valid |= ATTR_SIZE;
6137 @@ -161,8 +167,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6138 *p++ = htonl(nfs_ftypes[type >> 12]);
6139 *p++ = htonl((u32) stat->mode);
6140 *p++ = htonl((u32) stat->nlink);
6141 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6142 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6143 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6144 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6145 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6146 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6148 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6149 *p++ = htonl(NFS_MAXPATHLEN);
6150 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/dlm/dlmfs.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/dlm/dlmfs.c
6151 --- linux-2.6.32.24/fs/ocfs2/dlm/dlmfs.c 2010-10-04 08:56:14.000000000 +0200
6152 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/dlm/dlmfs.c 2010-05-21 13:20:19.000000000 +0200
6154 #include <linux/init.h>
6155 #include <linux/string.h>
6156 #include <linux/backing-dev.h>
6157 +#include <linux/vs_tag.h>
6159 #include <asm/uaccess.h>
6161 @@ -342,6 +343,7 @@ static struct inode *dlmfs_get_root_inod
6162 inode->i_mode = mode;
6163 inode->i_uid = current_fsuid();
6164 inode->i_gid = current_fsgid();
6165 + inode->i_tag = dx_current_fstag(sb);
6166 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6167 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6169 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
6170 inode->i_mode = mode;
6171 inode->i_uid = current_fsuid();
6172 inode->i_gid = current_fsgid();
6173 + inode->i_tag = dx_current_fstag(sb);
6174 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6175 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6177 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/dlmglue.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/dlmglue.c
6178 --- linux-2.6.32.24/fs/ocfs2/dlmglue.c 2009-12-03 20:02:53.000000000 +0100
6179 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/dlmglue.c 2009-12-03 20:04:56.000000000 +0100
6180 @@ -1991,6 +1991,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6181 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6182 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6183 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6184 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6185 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6186 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6187 lvb->lvb_iatime_packed =
6188 @@ -2045,6 +2046,7 @@ static void ocfs2_refresh_inode_from_lvb
6190 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6191 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6192 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6193 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6194 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6195 ocfs2_unpack_timespec(&inode->i_atime,
6196 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/dlmglue.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/dlmglue.h
6197 --- linux-2.6.32.24/fs/ocfs2/dlmglue.h 2009-12-03 20:02:53.000000000 +0100
6198 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/dlmglue.h 2009-12-03 20:04:56.000000000 +0100
6199 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6202 __be32 lvb_igeneration;
6203 - __be32 lvb_reserved2;
6205 + __be16 lvb_reserved2;
6208 #define OCFS2_QINFO_LVB_VERSION 1
6209 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/file.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/file.c
6210 --- linux-2.6.32.24/fs/ocfs2/file.c 2009-12-03 20:02:53.000000000 +0100
6211 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/file.c 2009-12-03 20:04:56.000000000 +0100
6212 @@ -960,13 +960,15 @@ int ocfs2_setattr(struct dentry *dentry,
6213 mlog(0, "uid change: %d\n", attr->ia_uid);
6214 if (attr->ia_valid & ATTR_GID)
6215 mlog(0, "gid change: %d\n", attr->ia_gid);
6216 + if (attr->ia_valid & ATTR_TAG)
6217 + mlog(0, "tag change: %d\n", attr->ia_tag);
6218 if (attr->ia_valid & ATTR_SIZE)
6219 mlog(0, "size change...\n");
6220 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6221 mlog(0, "time change...\n");
6223 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6224 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6225 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6226 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6227 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6229 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/inode.c
6230 --- linux-2.6.32.24/fs/ocfs2/inode.c 2010-10-04 08:56:14.000000000 +0200
6231 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/inode.c 2010-09-22 00:48:38.000000000 +0200
6233 #include <linux/highmem.h>
6234 #include <linux/pagemap.h>
6235 #include <linux/quotaops.h>
6236 +#include <linux/vs_tag.h>
6238 #include <asm/byteorder.h>
6240 @@ -79,11 +80,13 @@ void ocfs2_set_inode_flags(struct inode
6242 unsigned int flags = OCFS2_I(inode)->ip_attr;
6244 - inode->i_flags &= ~(S_IMMUTABLE |
6245 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6246 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6248 if (flags & OCFS2_IMMUTABLE_FL)
6249 inode->i_flags |= S_IMMUTABLE;
6250 + if (flags & OCFS2_IXUNLINK_FL)
6251 + inode->i_flags |= S_IXUNLINK;
6253 if (flags & OCFS2_SYNC_FL)
6254 inode->i_flags |= S_SYNC;
6255 @@ -93,25 +96,44 @@ void ocfs2_set_inode_flags(struct inode
6256 inode->i_flags |= S_NOATIME;
6257 if (flags & OCFS2_DIRSYNC_FL)
6258 inode->i_flags |= S_DIRSYNC;
6260 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6262 + if (flags & OCFS2_BARRIER_FL)
6263 + inode->i_vflags |= V_BARRIER;
6264 + if (flags & OCFS2_COW_FL)
6265 + inode->i_vflags |= V_COW;
6268 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6269 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6271 unsigned int flags = oi->vfs_inode.i_flags;
6272 + unsigned int vflags = oi->vfs_inode.i_vflags;
6274 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6275 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6276 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6277 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6279 + if (flags & S_IMMUTABLE)
6280 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6281 + if (flags & S_IXUNLINK)
6282 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6284 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6285 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6287 oi->ip_attr |= OCFS2_SYNC_FL;
6288 if (flags & S_APPEND)
6289 oi->ip_attr |= OCFS2_APPEND_FL;
6290 - if (flags & S_IMMUTABLE)
6291 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6292 if (flags & S_NOATIME)
6293 oi->ip_attr |= OCFS2_NOATIME_FL;
6294 if (flags & S_DIRSYNC)
6295 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6297 + if (vflags & V_BARRIER)
6298 + oi->ip_attr |= OCFS2_BARRIER_FL;
6299 + if (vflags & V_COW)
6300 + oi->ip_attr |= OCFS2_COW_FL;
6303 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6304 @@ -246,6 +268,8 @@ void ocfs2_populate_inode(struct inode *
6305 struct super_block *sb;
6306 struct ocfs2_super *osb;
6311 mlog_entry("(0x%p, size:%llu)\n", inode,
6312 (unsigned long long)le64_to_cpu(fe->i_size));
6313 @@ -277,8 +301,12 @@ void ocfs2_populate_inode(struct inode *
6314 inode->i_generation = le32_to_cpu(fe->i_generation);
6315 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6316 inode->i_mode = le16_to_cpu(fe->i_mode);
6317 - inode->i_uid = le32_to_cpu(fe->i_uid);
6318 - inode->i_gid = le32_to_cpu(fe->i_gid);
6319 + uid = le32_to_cpu(fe->i_uid);
6320 + gid = le32_to_cpu(fe->i_gid);
6321 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6322 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6323 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6324 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6326 /* Fast symlinks will have i_size but no allocated clusters. */
6327 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6328 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/inode.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/inode.h
6329 --- linux-2.6.32.24/fs/ocfs2/inode.h 2009-12-03 20:02:53.000000000 +0100
6330 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/inode.h 2009-12-03 20:04:56.000000000 +0100
6331 @@ -150,6 +150,7 @@ struct buffer_head *ocfs2_bread(struct i
6333 void ocfs2_set_inode_flags(struct inode *inode);
6334 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6335 +int ocfs2_sync_flags(struct inode *inode, int, int);
6337 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6339 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/ioctl.c
6340 --- linux-2.6.32.24/fs/ocfs2/ioctl.c 2009-12-03 20:02:53.000000000 +0100
6341 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/ioctl.c 2009-12-03 20:04:56.000000000 +0100
6342 @@ -42,7 +42,41 @@ static int ocfs2_get_inode_attr(struct i
6346 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6347 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6349 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6350 + struct buffer_head *bh = NULL;
6351 + handle_t *handle = NULL;
6354 + status = ocfs2_inode_lock(inode, &bh, 1);
6356 + mlog_errno(status);
6359 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6360 + if (IS_ERR(handle)) {
6361 + status = PTR_ERR(handle);
6362 + mlog_errno(status);
6366 + inode->i_flags = flags;
6367 + inode->i_vflags = vflags;
6368 + ocfs2_get_inode_flags(OCFS2_I(inode));
6370 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6372 + mlog_errno(status);
6374 + ocfs2_commit_trans(osb, handle);
6376 + ocfs2_inode_unlock(inode, 1);
6381 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6384 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6385 @@ -67,6 +101,11 @@ static int ocfs2_set_inode_attr(struct i
6386 if (!S_ISDIR(inode->i_mode))
6387 flags &= ~OCFS2_DIRSYNC_FL;
6389 + if (IS_BARRIER(inode)) {
6390 + vxwprintk_task(1, "messing with the barrier.");
6394 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6395 if (IS_ERR(handle)) {
6396 status = PTR_ERR(handle);
6397 @@ -108,6 +147,7 @@ bail:
6402 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6404 struct inode *inode = filp->f_path.dentry->d_inode;
6405 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/namei.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/namei.c
6406 --- linux-2.6.32.24/fs/ocfs2/namei.c 2009-12-03 20:02:53.000000000 +0100
6407 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/namei.c 2009-12-03 20:04:56.000000000 +0100
6409 #include <linux/slab.h>
6410 #include <linux/highmem.h>
6411 #include <linux/quotaops.h>
6412 +#include <linux/vs_tag.h>
6414 #define MLOG_MASK_PREFIX ML_NAMEI
6415 #include <cluster/masklog.h>
6416 @@ -481,6 +482,7 @@ static int ocfs2_mknod_locked(struct ocf
6424 @@ -524,8 +526,11 @@ static int ocfs2_mknod_locked(struct ocf
6425 fe->i_blkno = cpu_to_le64(fe_blkno);
6426 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6427 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6428 - fe->i_uid = cpu_to_le32(inode->i_uid);
6429 - fe->i_gid = cpu_to_le32(inode->i_gid);
6431 + tag = dx_current_fstag(osb->sb);
6432 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6433 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6434 + inode->i_tag = tag;
6435 fe->i_mode = cpu_to_le16(inode->i_mode);
6436 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6437 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6438 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/ocfs2_fs.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/ocfs2_fs.h
6439 --- linux-2.6.32.24/fs/ocfs2/ocfs2_fs.h 2009-12-03 20:02:53.000000000 +0100
6440 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/ocfs2_fs.h 2009-12-03 20:04:56.000000000 +0100
6441 @@ -231,18 +231,23 @@
6442 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
6444 /* Inode attributes, keep in sync with EXT2 */
6445 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6446 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6447 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6448 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6449 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6450 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6451 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6452 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6453 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6454 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6455 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6456 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6457 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6458 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6459 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6460 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6461 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6463 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6464 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6465 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6466 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6468 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6469 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6471 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6472 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6475 * Extent record flags (e_node.leaf.flags)
6476 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/ocfs2.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/ocfs2.h
6477 --- linux-2.6.32.24/fs/ocfs2/ocfs2.h 2009-12-03 20:02:53.000000000 +0100
6478 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/ocfs2.h 2009-12-03 20:04:56.000000000 +0100
6479 @@ -248,6 +248,7 @@ enum ocfs2_mount_options
6480 OCFS2_MOUNT_POSIX_ACL = 1 << 8, /* POSIX access control lists */
6481 OCFS2_MOUNT_USRQUOTA = 1 << 9, /* We support user quotas */
6482 OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */
6483 + OCFS2_MOUNT_TAGGED = 1 << 11, /* use tagging */
6486 #define OCFS2_OSB_SOFT_RO 0x0001
6487 diff -NurpP --minimal linux-2.6.32.24/fs/ocfs2/super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/super.c
6488 --- linux-2.6.32.24/fs/ocfs2/super.c 2010-10-04 08:56:14.000000000 +0200
6489 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/ocfs2/super.c 2010-08-19 17:35:34.000000000 +0200
6490 @@ -173,6 +173,7 @@ enum {
6494 + Opt_tag, Opt_notag, Opt_tagid,
6498 @@ -199,6 +200,9 @@ static const match_table_t tokens = {
6499 {Opt_noacl, "noacl"},
6500 {Opt_usrquota, "usrquota"},
6501 {Opt_grpquota, "grpquota"},
6503 + {Opt_notag, "notag"},
6504 + {Opt_tagid, "tagid=%u"},
6508 @@ -605,6 +609,13 @@ static int ocfs2_remount(struct super_bl
6512 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6513 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6515 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6519 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6520 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6522 @@ -1152,6 +1163,9 @@ static int ocfs2_fill_super(struct super
6524 ocfs2_complete_mount_recovery(osb);
6526 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6527 + sb->s_flags |= MS_TAGGED;
6529 if (ocfs2_mount_local(osb))
6530 snprintf(nodestr, sizeof(nodestr), "local");
6532 @@ -1430,6 +1444,20 @@ static int ocfs2_parse_options(struct su
6533 printk(KERN_INFO "ocfs2 (no)acl options not supported\n");
6536 +#ifndef CONFIG_TAGGING_NONE
6538 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6541 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6544 +#ifdef CONFIG_PROPAGATE
6547 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6552 "Unrecognized mount option \"%s\" "
6553 diff -NurpP --minimal linux-2.6.32.24/fs/open.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/open.c
6554 --- linux-2.6.32.24/fs/open.c 2009-12-03 20:02:53.000000000 +0100
6555 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/open.c 2009-12-03 20:04:56.000000000 +0100
6557 #include <linux/audit.h>
6558 #include <linux/falloc.h>
6559 #include <linux/fs_struct.h>
6560 +#include <linux/vs_base.h>
6561 +#include <linux/vs_limit.h>
6562 +#include <linux/vs_tag.h>
6563 +#include <linux/vs_cowbl.h>
6565 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
6567 int retval = -ENODEV;
6570 + struct super_block *sb = dentry->d_sb;
6573 - if (dentry->d_sb->s_op->statfs) {
6574 + if (sb->s_op->statfs) {
6575 memset(buf, 0, sizeof(*buf));
6576 retval = security_sb_statfs(dentry);
6579 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6580 + retval = sb->s_op->statfs(dentry, buf);
6581 if (retval == 0 && buf->f_frsize == 0)
6582 buf->f_frsize = buf->f_bsize;
6584 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6585 + vx_vsi_statfs(sb, buf);
6589 @@ -640,6 +648,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6590 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6594 + error = cow_check_and_break(&path);
6596 + goto dput_and_out;
6597 inode = path.dentry->d_inode;
6599 error = mnt_want_write(path.mnt);
6600 @@ -673,11 +685,11 @@ static int chown_common(struct dentry *
6601 newattrs.ia_valid = ATTR_CTIME;
6602 if (user != (uid_t) -1) {
6603 newattrs.ia_valid |= ATTR_UID;
6604 - newattrs.ia_uid = user;
6605 + newattrs.ia_uid = dx_map_uid(user);
6607 if (group != (gid_t) -1) {
6608 newattrs.ia_valid |= ATTR_GID;
6609 - newattrs.ia_gid = group;
6610 + newattrs.ia_gid = dx_map_gid(group);
6612 if (!S_ISDIR(inode->i_mode))
6613 newattrs.ia_valid |=
6614 @@ -700,7 +712,11 @@ SYSCALL_DEFINE3(chown, const char __user
6615 error = mnt_want_write(path.mnt);
6618 - error = chown_common(path.dentry, user, group);
6619 +#ifdef CONFIG_VSERVER_COWBL
6620 + error = cow_check_and_break(&path);
6623 + error = chown_common(path.dentry, user, group);
6624 mnt_drop_write(path.mnt);
6627 @@ -725,7 +741,11 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6628 error = mnt_want_write(path.mnt);
6631 - error = chown_common(path.dentry, user, group);
6632 +#ifdef CONFIG_VSERVER_COWBL
6633 + error = cow_check_and_break(&path);
6636 + error = chown_common(path.dentry, user, group);
6637 mnt_drop_write(path.mnt);
6640 @@ -744,7 +764,11 @@ SYSCALL_DEFINE3(lchown, const char __use
6641 error = mnt_want_write(path.mnt);
6644 - error = chown_common(path.dentry, user, group);
6645 +#ifdef CONFIG_VSERVER_COWBL
6646 + error = cow_check_and_break(&path);
6649 + error = chown_common(path.dentry, user, group);
6650 mnt_drop_write(path.mnt);
6653 @@ -990,6 +1014,7 @@ static void __put_unused_fd(struct files
6654 __FD_CLR(fd, fdt->open_fds);
6655 if (fd < files->next_fd)
6656 files->next_fd = fd;
6657 + vx_openfd_dec(fd);
6660 void put_unused_fd(unsigned int fd)
6661 diff -NurpP --minimal linux-2.6.32.24/fs/proc/array.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/array.c
6662 --- linux-2.6.32.24/fs/proc/array.c 2010-10-04 08:56:14.000000000 +0200
6663 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/array.c 2010-08-19 17:35:34.000000000 +0200
6665 #include <linux/pid_namespace.h>
6666 #include <linux/ptrace.h>
6667 #include <linux/tracehook.h>
6668 +#include <linux/vs_context.h>
6669 +#include <linux/vs_network.h>
6671 #include <asm/pgtable.h>
6672 #include <asm/processor.h>
6673 @@ -166,6 +168,9 @@ static inline void task_state(struct seq
6675 ppid = pid_alive(p) ?
6676 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6677 + if (unlikely(vx_current_initpid(p->pid)))
6682 struct task_struct *tracer = tracehook_tracer_task(p);
6683 @@ -281,7 +286,7 @@ static inline void task_sig(struct seq_f
6686 static void render_cap_t(struct seq_file *m, const char *header,
6688 + struct vx_info *vxi, kernel_cap_t *a)
6692 @@ -306,10 +311,11 @@ static inline void task_cap(struct seq_f
6693 cap_bset = cred->cap_bset;
6696 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6697 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6698 - render_cap_t(m, "CapEff:\t", &cap_effective);
6699 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6700 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6701 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6702 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6703 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6704 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6707 static inline void task_context_switch_counts(struct seq_file *m,
6708 @@ -321,6 +327,43 @@ static inline void task_context_switch_c
6713 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6714 + struct pid *pid, struct task_struct *task)
6716 + seq_printf(m, "Proxy:\t%p(%c)\n"
6724 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6725 + atomic_read(&task->nsproxy->count),
6726 + task->nsproxy->uts_ns,
6727 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6728 + task->nsproxy->ipc_ns,
6729 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6730 + task->nsproxy->mnt_ns,
6731 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6732 + task->nsproxy->pid_ns,
6733 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6734 + task->nsproxy->net_ns,
6735 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6739 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6741 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6744 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6745 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6749 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6750 struct pid *pid, struct task_struct *task)
6752 @@ -336,6 +379,7 @@ int proc_pid_status(struct seq_file *m,
6755 cpuset_task_status_allowed(m, task);
6756 + task_vs_id(m, task);
6757 #if defined(CONFIG_S390)
6758 task_show_regs(m, task);
6760 @@ -449,6 +493,17 @@ static int do_task_stat(struct seq_file
6761 /* convert nsec -> ticks */
6762 start_time = nsec_to_clock_t(start_time);
6764 + /* fixup start time for virt uptime */
6765 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6766 + unsigned long long bias =
6767 + current->vx_info->cvirt.bias_clock;
6769 + if (start_time > bias)
6770 + start_time -= bias;
6775 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6776 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6777 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6778 diff -NurpP --minimal linux-2.6.32.24/fs/proc/base.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/base.c
6779 --- linux-2.6.32.24/fs/proc/base.c 2010-10-04 08:56:14.000000000 +0200
6780 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/base.c 2010-05-21 13:20:19.000000000 +0200
6782 #include <linux/elf.h>
6783 #include <linux/pid_namespace.h>
6784 #include <linux/fs_struct.h>
6785 +#include <linux/vs_context.h>
6786 +#include <linux/vs_network.h>
6787 #include "internal.h"
6790 @@ -1048,12 +1050,17 @@ static ssize_t oom_adjust_write(struct f
6794 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6795 + if (oom_adjust < task->signal->oom_adj &&
6796 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6797 unlock_task_sighand(task, &flags);
6798 put_task_struct(task);
6802 + /* prevent guest processes from circumventing the oom killer */
6803 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6804 + oom_adjust = OOM_ADJUST_MIN;
6806 task->signal->oom_adj = oom_adjust;
6808 unlock_task_sighand(task, &flags);
6809 @@ -1093,7 +1100,7 @@ static ssize_t proc_loginuid_write(struc
6813 - if (!capable(CAP_AUDIT_CONTROL))
6814 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6817 if (current != pid_task(proc_pid(inode), PIDTYPE_PID))
6818 @@ -1459,6 +1466,8 @@ static struct inode *proc_pid_make_inode
6819 inode->i_gid = cred->egid;
6822 + /* procfs is xid tagged */
6823 + inode->i_tag = (tag_t)vx_task_xid(task);
6824 security_task_to_inode(task, inode);
6827 @@ -2009,6 +2018,13 @@ static struct dentry *proc_pident_lookup
6831 + /* TODO: maybe we can come up with a generic approach? */
6832 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6833 + (dentry->d_name.len == 5) &&
6834 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6835 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6839 * Yes, it does not scale. And it should not. Don't add
6840 * new entries into /proc/<tgid>/ without very good reasons.
6841 @@ -2414,7 +2430,7 @@ out_iput:
6842 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6844 struct dentry *error;
6845 - struct task_struct *task = get_proc_task(dir);
6846 + struct task_struct *task = get_proc_task_real(dir);
6847 const struct pid_entry *p, *last;
6849 error = ERR_PTR(-ENOENT);
6850 @@ -2504,6 +2520,9 @@ static int proc_pid_personality(struct s
6851 static const struct file_operations proc_task_operations;
6852 static const struct inode_operations proc_task_inode_operations;
6854 +extern int proc_pid_vx_info(struct task_struct *, char *);
6855 +extern int proc_pid_nx_info(struct task_struct *, char *);
6857 static const struct pid_entry tgid_base_stuff[] = {
6858 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6859 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6860 @@ -2562,6 +2581,8 @@ static const struct pid_entry tgid_base_
6861 #ifdef CONFIG_CGROUPS
6862 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6864 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6865 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6866 INF("oom_score", S_IRUGO, proc_oom_score),
6867 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6868 #ifdef CONFIG_AUDITSYSCALL
6869 @@ -2577,6 +2598,7 @@ static const struct pid_entry tgid_base_
6870 #ifdef CONFIG_TASK_IO_ACCOUNTING
6871 INF("io", S_IRUGO, proc_tgid_io_accounting),
6873 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6876 static int proc_tgid_base_readdir(struct file * filp,
6877 @@ -2768,7 +2790,7 @@ retry:
6879 pid = find_ge_pid(iter.tgid, ns);
6881 - iter.tgid = pid_nr_ns(pid, ns);
6882 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6883 iter.task = pid_task(pid, PIDTYPE_PID);
6884 /* What we to know is if the pid we have find is the
6885 * pid of a thread_group_leader. Testing for task
6886 @@ -2798,7 +2820,7 @@ static int proc_pid_fill_cache(struct fi
6887 struct tgid_iter iter)
6889 char name[PROC_NUMBUF];
6890 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6891 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6892 return proc_fill_cache(filp, dirent, filldir, name, len,
6893 proc_pid_instantiate, iter.task, NULL);
6895 @@ -2807,7 +2829,7 @@ static int proc_pid_fill_cache(struct fi
6896 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
6898 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6899 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
6900 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6901 struct tgid_iter iter;
6902 struct pid_namespace *ns;
6904 @@ -2827,6 +2849,8 @@ int proc_pid_readdir(struct file * filp,
6906 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6907 filp->f_pos = iter.tgid + TGID_OFFSET;
6908 + if (!vx_proc_task_visible(iter.task))
6910 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6911 put_task_struct(iter.task);
6913 @@ -2973,6 +2997,8 @@ static struct dentry *proc_task_lookup(s
6914 tid = name_to_int(dentry);
6917 + if (vx_current_initpid(tid))
6920 ns = dentry->d_sb->s_fs_info;
6922 diff -NurpP --minimal linux-2.6.32.24/fs/proc/generic.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/generic.c
6923 --- linux-2.6.32.24/fs/proc/generic.c 2009-06-11 17:13:07.000000000 +0200
6924 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/generic.c 2009-12-03 20:04:56.000000000 +0100
6926 #include <linux/bitops.h>
6927 #include <linux/spinlock.h>
6928 #include <linux/completion.h>
6929 +#include <linux/vserver/inode.h>
6930 #include <asm/uaccess.h>
6932 #include "internal.h"
6933 @@ -425,6 +426,8 @@ struct dentry *proc_lookup_de(struct pro
6934 for (de = de->subdir; de ; de = de->next) {
6935 if (de->namelen != dentry->d_name.len)
6937 + if (!vx_hide_check(0, de->vx_flags))
6939 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6942 @@ -433,6 +436,8 @@ struct dentry *proc_lookup_de(struct pro
6943 spin_unlock(&proc_subdir_lock);
6945 inode = proc_get_inode(dir->i_sb, ino, de);
6946 + /* generic proc entries belong to the host */
6951 @@ -510,6 +515,8 @@ int proc_readdir_de(struct proc_dir_entr
6953 /* filldir passes info to user space */
6955 + if (!vx_hide_check(0, de->vx_flags))
6957 spin_unlock(&proc_subdir_lock);
6958 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6959 de->low_ino, de->mode >> 12) < 0) {
6960 @@ -517,6 +524,7 @@ int proc_readdir_de(struct proc_dir_entr
6963 spin_lock(&proc_subdir_lock);
6968 @@ -631,6 +639,7 @@ static struct proc_dir_entry *__proc_cre
6970 atomic_set(&ent->count, 1);
6972 + ent->vx_flags = IATTR_PROC_DEFAULT;
6973 spin_lock_init(&ent->pde_unload_lock);
6974 ent->pde_unload_completion = NULL;
6975 INIT_LIST_HEAD(&ent->pde_openers);
6976 @@ -654,7 +663,8 @@ struct proc_dir_entry *proc_symlink(cons
6982 + ent->vx_flags = IATTR_PROC_SYMLINK;
6986 diff -NurpP --minimal linux-2.6.32.24/fs/proc/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/inode.c
6987 --- linux-2.6.32.24/fs/proc/inode.c 2009-06-11 17:13:07.000000000 +0200
6988 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/inode.c 2009-12-03 20:04:56.000000000 +0100
6989 @@ -459,6 +459,8 @@ struct inode *proc_get_inode(struct supe
6990 inode->i_uid = de->uid;
6991 inode->i_gid = de->gid;
6994 + PROC_I(inode)->vx_flags = de->vx_flags;
6996 inode->i_size = de->size;
6998 diff -NurpP --minimal linux-2.6.32.24/fs/proc/internal.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/internal.h
6999 --- linux-2.6.32.24/fs/proc/internal.h 2009-09-10 15:26:23.000000000 +0200
7000 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/internal.h 2009-12-03 20:04:56.000000000 +0100
7004 #include <linux/proc_fs.h>
7005 +#include <linux/vs_pid.h>
7007 extern struct proc_dir_entry proc_root;
7008 #ifdef CONFIG_PROC_SYSCTL
7009 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
7010 struct pid *pid, struct task_struct *task);
7011 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7012 struct pid *pid, struct task_struct *task);
7013 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7014 + struct pid *pid, struct task_struct *task);
7016 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7018 extern const struct file_operations proc_maps_operations;
7019 @@ -70,11 +74,16 @@ static inline struct pid *proc_pid(struc
7020 return PROC_I(inode)->pid;
7023 -static inline struct task_struct *get_proc_task(struct inode *inode)
7024 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7026 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7029 +static inline struct task_struct *get_proc_task(struct inode *inode)
7031 + return vx_get_proc_task(inode, proc_pid(inode));
7034 static inline int proc_fd(struct inode *inode)
7036 return PROC_I(inode)->fd;
7037 diff -NurpP --minimal linux-2.6.32.24/fs/proc/loadavg.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/loadavg.c
7038 --- linux-2.6.32.24/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7039 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/loadavg.c 2009-12-03 20:04:56.000000000 +0100
7042 static int loadavg_proc_show(struct seq_file *m, void *v)
7044 + unsigned long running;
7045 + unsigned int threads;
7046 unsigned long avnrun[3];
7048 get_avenrun(avnrun, FIXED_1/200, 0);
7050 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7051 + struct vx_info *vxi = current_vx_info();
7053 + running = atomic_read(&vxi->cvirt.nr_running);
7054 + threads = atomic_read(&vxi->cvirt.nr_threads);
7056 + running = nr_running();
7057 + threads = nr_threads;
7060 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7061 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7062 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7063 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7064 - nr_running(), nr_threads,
7066 task_active_pid_ns(current)->last_pid);
7069 diff -NurpP --minimal linux-2.6.32.24/fs/proc/meminfo.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/meminfo.c
7070 --- linux-2.6.32.24/fs/proc/meminfo.c 2009-12-03 20:02:53.000000000 +0100
7071 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/meminfo.c 2010-02-05 00:31:48.000000000 +0100
7072 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7073 allowed = ((totalram_pages - hugetlb_total_pages())
7074 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7076 - cached = global_page_state(NR_FILE_PAGES) -
7077 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7078 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7079 total_swapcache_pages - i.bufferram;
7082 diff -NurpP --minimal linux-2.6.32.24/fs/proc/root.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/root.c
7083 --- linux-2.6.32.24/fs/proc/root.c 2009-06-11 17:13:07.000000000 +0200
7084 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/root.c 2009-12-03 20:04:56.000000000 +0100
7086 #include <linux/bitops.h>
7087 #include <linux/mount.h>
7088 #include <linux/pid_namespace.h>
7089 +#include <linux/vserver/inode.h>
7091 #include "internal.h"
7093 +struct proc_dir_entry *proc_virtual;
7095 +extern void proc_vx_init(void);
7097 static int proc_test_super(struct super_block *sb, void *data)
7099 return sb->s_fs_info == data;
7100 @@ -136,6 +141,7 @@ void __init proc_root_init(void)
7102 proc_mkdir("bus", NULL);
7107 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7108 @@ -203,6 +209,7 @@ struct proc_dir_entry proc_root = {
7109 .proc_iops = &proc_root_inode_operations,
7110 .proc_fops = &proc_root_operations,
7111 .parent = &proc_root,
7112 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7115 int pid_ns_prepare_proc(struct pid_namespace *ns)
7116 diff -NurpP --minimal linux-2.6.32.24/fs/proc/uptime.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/uptime.c
7117 --- linux-2.6.32.24/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7118 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/proc/uptime.c 2009-12-03 20:04:56.000000000 +0100
7120 #include <linux/sched.h>
7121 #include <linux/seq_file.h>
7122 #include <linux/time.h>
7123 -#include <linux/kernel_stat.h>
7124 +#include <linux/vserver/cvirt.h>
7125 #include <asm/cputime.h>
7127 static int uptime_proc_show(struct seq_file *m, void *v)
7129 struct timespec uptime;
7130 struct timespec idle;
7132 - cputime_t idletime = cputime_zero;
7134 - for_each_possible_cpu(i)
7135 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7136 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7138 do_posix_clock_monotonic_gettime(&uptime);
7139 monotonic_to_bootbased(&uptime);
7140 cputime_to_timespec(idletime, &idle);
7142 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7143 + vx_vsi_uptime(&uptime, &idle);
7145 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7146 (unsigned long) uptime.tv_sec,
7147 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7148 diff -NurpP --minimal linux-2.6.32.24/fs/quota/quota.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/quota/quota.c
7149 --- linux-2.6.32.24/fs/quota/quota.c 2009-09-10 15:26:24.000000000 +0200
7150 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/quota/quota.c 2009-12-03 20:04:56.000000000 +0100
7152 #include <linux/capability.h>
7153 #include <linux/quotaops.h>
7154 #include <linux/types.h>
7155 +#include <linux/vs_context.h>
7157 /* Check validity of generic quotactl commands */
7158 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd,
7159 @@ -83,11 +84,11 @@ static int generic_quotactl_valid(struct
7160 if (cmd == Q_GETQUOTA) {
7161 if (((type == USRQUOTA && current_euid() != id) ||
7162 (type == GRPQUOTA && !in_egroup_p(id))) &&
7163 - !capable(CAP_SYS_ADMIN))
7164 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7167 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7168 - if (!capable(CAP_SYS_ADMIN))
7169 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7173 @@ -135,10 +136,10 @@ static int xqm_quotactl_valid(struct sup
7174 if (cmd == Q_XGETQUOTA) {
7175 if (((type == XQM_USRQUOTA && current_euid() != id) ||
7176 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7177 - !capable(CAP_SYS_ADMIN))
7178 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7180 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7181 - if (!capable(CAP_SYS_ADMIN))
7182 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7186 @@ -351,6 +352,46 @@ static int do_quotactl(struct super_bloc
7190 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7192 +#include <linux/vroot.h>
7193 +#include <linux/major.h>
7194 +#include <linux/module.h>
7195 +#include <linux/kallsyms.h>
7196 +#include <linux/vserver/debug.h>
7198 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7200 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7202 +int register_vroot_grb(vroot_grb_func *func) {
7205 + spin_lock(&vroot_grb_lock);
7206 + if (!vroot_get_real_bdev) {
7207 + vroot_get_real_bdev = func;
7210 + spin_unlock(&vroot_grb_lock);
7213 +EXPORT_SYMBOL(register_vroot_grb);
7215 +int unregister_vroot_grb(vroot_grb_func *func) {
7216 + int ret = -EINVAL;
7218 + spin_lock(&vroot_grb_lock);
7219 + if (vroot_get_real_bdev) {
7220 + vroot_get_real_bdev = NULL;
7223 + spin_unlock(&vroot_grb_lock);
7226 +EXPORT_SYMBOL(unregister_vroot_grb);
7231 * look up a superblock on which quota ops will be performed
7232 * - use the name of a block device to find the superblock thereon
7233 @@ -368,6 +409,22 @@ static struct super_block *quotactl_bloc
7236 return ERR_CAST(bdev);
7237 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7238 + if (bdev && bdev->bd_inode &&
7239 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7240 + struct block_device *bdnew = (void *)-EINVAL;
7242 + if (vroot_get_real_bdev)
7243 + bdnew = vroot_get_real_bdev(bdev);
7245 + vxdprintk(VXD_CBIT(misc, 0),
7246 + "vroot_get_real_bdev not set");
7248 + if (IS_ERR(bdnew))
7249 + return ERR_PTR(PTR_ERR(bdnew));
7253 sb = get_super(bdev);
7256 diff -NurpP --minimal linux-2.6.32.24/fs/reiserfs/file.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/file.c
7257 --- linux-2.6.32.24/fs/reiserfs/file.c 2009-06-11 17:13:08.000000000 +0200
7258 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/file.c 2009-12-03 20:04:56.000000000 +0100
7259 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
7260 .listxattr = reiserfs_listxattr,
7261 .removexattr = reiserfs_removexattr,
7262 .permission = reiserfs_permission,
7263 + .sync_flags = reiserfs_sync_flags,
7265 diff -NurpP --minimal linux-2.6.32.24/fs/reiserfs/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/inode.c
7266 --- linux-2.6.32.24/fs/reiserfs/inode.c 2010-10-04 08:56:14.000000000 +0200
7267 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/inode.c 2010-01-26 20:35:35.000000000 +0100
7269 #include <linux/writeback.h>
7270 #include <linux/quotaops.h>
7271 #include <linux/swap.h>
7272 +#include <linux/vs_tag.h>
7274 int reiserfs_commit_write(struct file *f, struct page *page,
7275 unsigned from, unsigned to);
7276 @@ -1117,6 +1118,8 @@ static void init_inode(struct inode *ino
7277 struct buffer_head *bh;
7278 struct item_head *ih;
7282 //int version = ITEM_VERSION_1;
7284 bh = PATH_PLAST_BUFFER(path);
7285 @@ -1138,12 +1141,13 @@ static void init_inode(struct inode *ino
7286 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7287 unsigned long blocks;
7289 + uid = sd_v1_uid(sd);
7290 + gid = sd_v1_gid(sd);
7292 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7293 set_inode_sd_version(inode, STAT_DATA_V1);
7294 inode->i_mode = sd_v1_mode(sd);
7295 inode->i_nlink = sd_v1_nlink(sd);
7296 - inode->i_uid = sd_v1_uid(sd);
7297 - inode->i_gid = sd_v1_gid(sd);
7298 inode->i_size = sd_v1_size(sd);
7299 inode->i_atime.tv_sec = sd_v1_atime(sd);
7300 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7301 @@ -1185,11 +1189,12 @@ static void init_inode(struct inode *ino
7302 // (directories and symlinks)
7303 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7305 + uid = sd_v2_uid(sd);
7306 + gid = sd_v2_gid(sd);
7308 inode->i_mode = sd_v2_mode(sd);
7309 inode->i_nlink = sd_v2_nlink(sd);
7310 - inode->i_uid = sd_v2_uid(sd);
7311 inode->i_size = sd_v2_size(sd);
7312 - inode->i_gid = sd_v2_gid(sd);
7313 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7314 inode->i_atime.tv_sec = sd_v2_atime(sd);
7315 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7316 @@ -1219,6 +1224,10 @@ static void init_inode(struct inode *ino
7317 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7320 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7321 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7322 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7325 if (S_ISREG(inode->i_mode)) {
7326 inode->i_op = &reiserfs_file_inode_operations;
7327 @@ -1241,13 +1250,15 @@ static void init_inode(struct inode *ino
7328 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7330 struct stat_data *sd_v2 = (struct stat_data *)sd;
7331 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7332 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7335 + set_sd_v2_uid(sd_v2, uid);
7336 + set_sd_v2_gid(sd_v2, gid);
7337 set_sd_v2_mode(sd_v2, inode->i_mode);
7338 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7339 - set_sd_v2_uid(sd_v2, inode->i_uid);
7340 set_sd_v2_size(sd_v2, size);
7341 - set_sd_v2_gid(sd_v2, inode->i_gid);
7342 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7343 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7344 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7345 @@ -2839,14 +2850,19 @@ int reiserfs_commit_write(struct file *f
7346 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7348 if (reiserfs_attrs(inode->i_sb)) {
7349 - if (sd_attrs & REISERFS_SYNC_FL)
7350 - inode->i_flags |= S_SYNC;
7352 - inode->i_flags &= ~S_SYNC;
7353 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7354 inode->i_flags |= S_IMMUTABLE;
7356 inode->i_flags &= ~S_IMMUTABLE;
7357 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7358 + inode->i_flags |= S_IXUNLINK;
7360 + inode->i_flags &= ~S_IXUNLINK;
7362 + if (sd_attrs & REISERFS_SYNC_FL)
7363 + inode->i_flags |= S_SYNC;
7365 + inode->i_flags &= ~S_SYNC;
7366 if (sd_attrs & REISERFS_APPEND_FL)
7367 inode->i_flags |= S_APPEND;
7369 @@ -2859,6 +2875,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7370 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7372 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7374 + if (sd_attrs & REISERFS_BARRIER_FL)
7375 + inode->i_vflags |= V_BARRIER;
7377 + inode->i_vflags &= ~V_BARRIER;
7378 + if (sd_attrs & REISERFS_COW_FL)
7379 + inode->i_vflags |= V_COW;
7381 + inode->i_vflags &= ~V_COW;
7385 @@ -2869,6 +2894,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7386 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7388 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7389 + if (inode->i_flags & S_IXUNLINK)
7390 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7392 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7394 if (inode->i_flags & S_SYNC)
7395 *sd_attrs |= REISERFS_SYNC_FL;
7397 @@ -2881,6 +2911,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7398 *sd_attrs |= REISERFS_NOTAIL_FL;
7400 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7402 + if (inode->i_vflags & V_BARRIER)
7403 + *sd_attrs |= REISERFS_BARRIER_FL;
7405 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7406 + if (inode->i_vflags & V_COW)
7407 + *sd_attrs |= REISERFS_COW_FL;
7409 + *sd_attrs &= ~REISERFS_COW_FL;
7413 @@ -3101,9 +3140,11 @@ int reiserfs_setattr(struct dentry *dent
7416 error = inode_change_ok(inode, attr);
7419 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7420 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7421 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7422 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7423 error = reiserfs_chown_xattrs(inode, attr);
7426 @@ -3133,6 +3174,9 @@ int reiserfs_setattr(struct dentry *dent
7427 inode->i_uid = attr->ia_uid;
7428 if (attr->ia_valid & ATTR_GID)
7429 inode->i_gid = attr->ia_gid;
7430 + if ((attr->ia_valid & ATTR_TAG) &&
7432 + inode->i_tag = attr->ia_tag;
7433 mark_inode_dirty(inode);
7435 journal_end(&th, inode->i_sb, jbegin_count);
7436 diff -NurpP --minimal linux-2.6.32.24/fs/reiserfs/ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/ioctl.c
7437 --- linux-2.6.32.24/fs/reiserfs/ioctl.c 2009-06-11 17:13:08.000000000 +0200
7438 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/ioctl.c 2009-12-03 20:04:56.000000000 +0100
7440 #include <linux/mount.h>
7441 #include <linux/reiserfs_fs.h>
7442 #include <linux/time.h>
7443 +#include <linux/mount.h>
7444 #include <asm/uaccess.h>
7445 #include <linux/pagemap.h>
7446 #include <linux/smp_lock.h>
7447 #include <linux/compat.h>
7450 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7452 + __u16 sd_attrs = 0;
7454 + inode->i_flags = flags;
7455 + inode->i_vflags = vflags;
7457 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7458 + REISERFS_I(inode)->i_attrs = sd_attrs;
7459 + inode->i_ctime = CURRENT_TIME_SEC;
7460 + mark_inode_dirty(inode);
7465 ** reiserfs_ioctl - handler for ioctl for inode
7466 ** supported commands:
7468 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
7471 - unsigned int flags;
7472 + unsigned int flags, oldflags;
7476 @@ -43,6 +59,7 @@ int reiserfs_ioctl(struct inode *inode,
7478 flags = REISERFS_I(inode)->i_attrs;
7479 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7480 + flags &= REISERFS_FL_USER_VISIBLE;
7481 return put_user(flags, (int __user *)arg);
7482 case REISERFS_IOC_SETFLAGS:{
7483 if (!reiserfs_attrs(inode->i_sb))
7484 @@ -60,6 +77,10 @@ int reiserfs_ioctl(struct inode *inode,
7488 + if (IS_BARRIER(inode)) {
7489 + vxwprintk_task(1, "messing with the barrier.");
7493 * Is it quota file? Do not allow user to mess with it
7495 @@ -84,6 +105,10 @@ int reiserfs_ioctl(struct inode *inode,
7500 + oldflags = REISERFS_I(inode)->i_attrs;
7501 + flags &= REISERFS_FL_USER_MODIFIABLE;
7502 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7503 sd_attrs_to_i_attrs(flags, inode);
7504 REISERFS_I(inode)->i_attrs = flags;
7505 inode->i_ctime = CURRENT_TIME_SEC;
7506 diff -NurpP --minimal linux-2.6.32.24/fs/reiserfs/namei.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/namei.c
7507 --- linux-2.6.32.24/fs/reiserfs/namei.c 2009-06-11 17:13:08.000000000 +0200
7508 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/namei.c 2009-12-03 20:04:56.000000000 +0100
7510 #include <linux/reiserfs_acl.h>
7511 #include <linux/reiserfs_xattr.h>
7512 #include <linux/quotaops.h>
7513 +#include <linux/vs_tag.h>
7515 #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; }
7516 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7517 @@ -354,6 +355,7 @@ static struct dentry *reiserfs_lookup(st
7518 if (retval == IO_ERROR) {
7519 return ERR_PTR(-EIO);
7521 + dx_propagate_tag(nd, inode);
7523 return d_splice_alias(inode, dentry);
7525 @@ -570,6 +572,7 @@ static int new_inode_init(struct inode *
7527 inode->i_gid = current_fsgid();
7529 + inode->i_tag = dx_current_fstag(inode->i_sb);
7533 @@ -1515,6 +1518,7 @@ const struct inode_operations reiserfs_d
7534 .listxattr = reiserfs_listxattr,
7535 .removexattr = reiserfs_removexattr,
7536 .permission = reiserfs_permission,
7537 + .sync_flags = reiserfs_sync_flags,
7541 diff -NurpP --minimal linux-2.6.32.24/fs/reiserfs/super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/super.c
7542 --- linux-2.6.32.24/fs/reiserfs/super.c 2009-12-03 20:02:53.000000000 +0100
7543 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/super.c 2009-12-03 20:04:56.000000000 +0100
7544 @@ -884,6 +884,14 @@ static int reiserfs_parse_options(struct
7545 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7546 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7548 +#ifndef CONFIG_TAGGING_NONE
7549 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7550 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7551 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7553 +#ifdef CONFIG_PROPAGATE
7554 + {"tag",.arg_required = 'T',.values = NULL},
7556 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7557 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7558 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7559 @@ -1190,6 +1198,14 @@ static int reiserfs_remount(struct super
7560 handle_quota_files(s, qf_names, &qfmt);
7563 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7564 + !(s->s_flags & MS_TAGGED)) {
7565 + reiserfs_warning(s, "super-vs01",
7566 + "reiserfs: tagging not permitted on remount.");
7573 /* Add options that are safe here */
7574 @@ -1652,6 +1668,10 @@ static int reiserfs_fill_super(struct su
7578 + /* map mount option tagxid */
7579 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7580 + s->s_flags |= MS_TAGGED;
7582 rs = SB_DISK_SUPER_BLOCK(s);
7583 /* Let's do basic sanity check to verify that underlying device is not
7584 smaller than the filesystem. If the check fails then abort and scream,
7585 diff -NurpP --minimal linux-2.6.32.24/fs/reiserfs/xattr.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/xattr.c
7586 --- linux-2.6.32.24/fs/reiserfs/xattr.c 2010-10-04 08:56:14.000000000 +0200
7587 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/reiserfs/xattr.c 2010-05-21 13:20:19.000000000 +0200
7589 #include <linux/namei.h>
7590 #include <linux/errno.h>
7591 #include <linux/fs.h>
7592 +#include <linux/mount.h>
7593 #include <linux/file.h>
7594 #include <linux/pagemap.h>
7595 #include <linux/xattr.h>
7596 diff -NurpP --minimal linux-2.6.32.24/fs/stat.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/stat.c
7597 --- linux-2.6.32.24/fs/stat.c 2010-10-04 08:56:14.000000000 +0200
7598 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/stat.c 2010-01-13 14:33:47.000000000 +0100
7599 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7600 stat->nlink = inode->i_nlink;
7601 stat->uid = inode->i_uid;
7602 stat->gid = inode->i_gid;
7603 + stat->tag = inode->i_tag;
7604 stat->rdev = inode->i_rdev;
7605 stat->atime = inode->i_atime;
7606 stat->mtime = inode->i_mtime;
7607 diff -NurpP --minimal linux-2.6.32.24/fs/super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/super.c
7608 --- linux-2.6.32.24/fs/super.c 2010-10-04 08:56:14.000000000 +0200
7609 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/super.c 2010-02-12 10:59:55.000000000 +0100
7611 #include <linux/kobject.h>
7612 #include <linux/mutex.h>
7613 #include <linux/file.h>
7614 +#include <linux/devpts_fs.h>
7615 +#include <linux/proc_fs.h>
7616 +#include <linux/vs_context.h>
7617 #include <asm/uaccess.h>
7618 #include "internal.h"
7620 @@ -914,12 +917,18 @@ struct vfsmount *
7621 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7623 struct vfsmount *mnt;
7624 + struct super_block *sb;
7625 char *secdata = NULL;
7629 return ERR_PTR(-ENODEV);
7632 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7633 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7637 mnt = alloc_vfsmnt(name);
7639 @@ -938,9 +947,17 @@ vfs_kern_mount(struct file_system_type *
7640 error = type->get_sb(type, flags, name, data, mnt);
7642 goto out_free_secdata;
7643 - BUG_ON(!mnt->mnt_sb);
7645 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7650 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7651 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7652 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7655 + error = security_sb_kern_mount(sb, flags, secdata);
7659 diff -NurpP --minimal linux-2.6.32.24/fs/sysfs/mount.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/sysfs/mount.c
7660 --- linux-2.6.32.24/fs/sysfs/mount.c 2009-06-11 17:13:08.000000000 +0200
7661 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/sysfs/mount.c 2009-12-03 20:04:56.000000000 +0100
7662 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7664 sb->s_blocksize = PAGE_CACHE_SIZE;
7665 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7666 - sb->s_magic = SYSFS_MAGIC;
7667 + sb->s_magic = SYSFS_SUPER_MAGIC;
7668 sb->s_op = &sysfs_ops;
7669 sb->s_time_gran = 1;
7671 diff -NurpP --minimal linux-2.6.32.24/fs/utimes.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/utimes.c
7672 --- linux-2.6.32.24/fs/utimes.c 2009-03-24 14:22:37.000000000 +0100
7673 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/utimes.c 2009-12-03 20:04:56.000000000 +0100
7675 #include <linux/stat.h>
7676 #include <linux/utime.h>
7677 #include <linux/syscalls.h>
7678 +#include <linux/mount.h>
7679 +#include <linux/vs_cowbl.h>
7680 #include <asm/uaccess.h>
7681 #include <asm/unistd.h>
7683 diff -NurpP --minimal linux-2.6.32.24/fs/xattr.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/xattr.c
7684 --- linux-2.6.32.24/fs/xattr.c 2009-12-03 20:02:53.000000000 +0100
7685 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xattr.c 2010-03-13 21:50:00.000000000 +0100
7687 #include <linux/module.h>
7688 #include <linux/fsnotify.h>
7689 #include <linux/audit.h>
7690 +#include <linux/mount.h>
7691 #include <asm/uaccess.h>
7694 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7695 * The trusted.* namespace can only be accessed by a privileged user.
7697 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
7698 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
7699 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
7701 /* In user.* namespace, only regular files and directories can have
7702 * extended attributes. For sticky directories, only the owner and
7703 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_ioctl.c
7704 --- linux-2.6.32.24/fs/xfs/linux-2.6/xfs_ioctl.c 2010-10-04 08:56:15.000000000 +0200
7705 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_ioctl.c 2010-10-04 10:04:57.000000000 +0200
7707 #include "xfs_dir2_sf.h"
7708 #include "xfs_dinode.h"
7709 #include "xfs_inode.h"
7710 -#include "xfs_ioctl.h"
7711 #include "xfs_btree.h"
7712 #include "xfs_ialloc.h"
7713 #include "xfs_rtalloc.h"
7714 @@ -742,6 +741,10 @@ xfs_merge_ioc_xflags(
7715 xflags |= XFS_XFLAG_IMMUTABLE;
7717 xflags &= ~XFS_XFLAG_IMMUTABLE;
7718 + if (flags & FS_IXUNLINK_FL)
7719 + xflags |= XFS_XFLAG_IXUNLINK;
7721 + xflags &= ~XFS_XFLAG_IXUNLINK;
7722 if (flags & FS_APPEND_FL)
7723 xflags |= XFS_XFLAG_APPEND;
7725 @@ -770,6 +773,8 @@ xfs_di2lxflags(
7727 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7728 flags |= FS_IMMUTABLE_FL;
7729 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7730 + flags |= FS_IXUNLINK_FL;
7731 if (di_flags & XFS_DIFLAG_APPEND)
7732 flags |= FS_APPEND_FL;
7733 if (di_flags & XFS_DIFLAG_SYNC)
7734 @@ -830,6 +835,8 @@ xfs_set_diflags(
7735 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7736 if (xflags & XFS_XFLAG_IMMUTABLE)
7737 di_flags |= XFS_DIFLAG_IMMUTABLE;
7738 + if (xflags & XFS_XFLAG_IXUNLINK)
7739 + di_flags |= XFS_DIFLAG_IXUNLINK;
7740 if (xflags & XFS_XFLAG_APPEND)
7741 di_flags |= XFS_DIFLAG_APPEND;
7742 if (xflags & XFS_XFLAG_SYNC)
7743 @@ -872,6 +879,10 @@ xfs_diflags_to_linux(
7744 inode->i_flags |= S_IMMUTABLE;
7746 inode->i_flags &= ~S_IMMUTABLE;
7747 + if (xflags & XFS_XFLAG_IXUNLINK)
7748 + inode->i_flags |= S_IXUNLINK;
7750 + inode->i_flags &= ~S_IXUNLINK;
7751 if (xflags & XFS_XFLAG_APPEND)
7752 inode->i_flags |= S_APPEND;
7754 @@ -1348,10 +1359,18 @@ xfs_file_ioctl(
7755 case XFS_IOC_FSGETXATTRA:
7756 return xfs_ioc_fsgetxattr(ip, 1, arg);
7757 case XFS_IOC_FSSETXATTR:
7758 + if (IS_BARRIER(inode)) {
7759 + vxwprintk_task(1, "messing with the barrier.");
7760 + return -XFS_ERROR(EACCES);
7762 return xfs_ioc_fssetxattr(ip, filp, arg);
7763 case XFS_IOC_GETXFLAGS:
7764 return xfs_ioc_getxflags(ip, arg);
7765 case XFS_IOC_SETXFLAGS:
7766 + if (IS_BARRIER(inode)) {
7767 + vxwprintk_task(1, "messing with the barrier.");
7768 + return -XFS_ERROR(EACCES);
7770 return xfs_ioc_setxflags(ip, filp, arg);
7772 case XFS_IOC_FSSETDM: {
7773 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_ioctl.h
7774 --- linux-2.6.32.24/fs/xfs/linux-2.6/xfs_ioctl.h 2009-03-24 14:22:37.000000000 +0100
7775 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_ioctl.h 2009-12-03 20:04:56.000000000 +0100
7776 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7777 void __user *uhandle,
7782 + struct inode *inode,
7789 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_iops.c
7790 --- linux-2.6.32.24/fs/xfs/linux-2.6/xfs_iops.c 2010-10-04 08:56:15.000000000 +0200
7791 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_iops.c 2010-04-28 10:19:35.000000000 +0200
7793 #include "xfs_attr_sf.h"
7794 #include "xfs_dinode.h"
7795 #include "xfs_inode.h"
7796 +#include "xfs_ioctl.h"
7797 #include "xfs_bmap.h"
7798 #include "xfs_btree.h"
7799 #include "xfs_ialloc.h"
7801 #include <linux/security.h>
7802 #include <linux/falloc.h>
7803 #include <linux/fiemap.h>
7804 +#include <linux/vs_tag.h>
7807 * Bring the timestamps in the XFS inode uptodate.
7808 @@ -495,6 +497,7 @@ xfs_vn_getattr(
7809 stat->nlink = ip->i_d.di_nlink;
7810 stat->uid = ip->i_d.di_uid;
7811 stat->gid = ip->i_d.di_gid;
7812 + stat->tag = ip->i_d.di_tag;
7813 stat->ino = ip->i_ino;
7814 stat->atime = inode->i_atime;
7815 stat->mtime = inode->i_mtime;
7816 @@ -686,6 +689,7 @@ static const struct inode_operations xfs
7817 .listxattr = xfs_vn_listxattr,
7818 .fallocate = xfs_vn_fallocate,
7819 .fiemap = xfs_vn_fiemap,
7820 + .sync_flags = xfs_sync_flags,
7823 static const struct inode_operations xfs_dir_inode_operations = {
7824 @@ -711,6 +715,7 @@ static const struct inode_operations xfs
7825 .getxattr = generic_getxattr,
7826 .removexattr = generic_removexattr,
7827 .listxattr = xfs_vn_listxattr,
7828 + .sync_flags = xfs_sync_flags,
7831 static const struct inode_operations xfs_dir_ci_inode_operations = {
7832 @@ -760,6 +765,10 @@ xfs_diflags_to_iflags(
7833 inode->i_flags |= S_IMMUTABLE;
7835 inode->i_flags &= ~S_IMMUTABLE;
7836 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7837 + inode->i_flags |= S_IXUNLINK;
7839 + inode->i_flags &= ~S_IXUNLINK;
7840 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7841 inode->i_flags |= S_APPEND;
7843 @@ -772,6 +781,15 @@ xfs_diflags_to_iflags(
7844 inode->i_flags |= S_NOATIME;
7846 inode->i_flags &= ~S_NOATIME;
7848 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7849 + inode->i_vflags |= V_BARRIER;
7851 + inode->i_vflags &= ~V_BARRIER;
7852 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7853 + inode->i_vflags |= V_COW;
7855 + inode->i_vflags &= ~V_COW;
7859 @@ -800,6 +818,7 @@ xfs_setup_inode(
7860 inode->i_nlink = ip->i_d.di_nlink;
7861 inode->i_uid = ip->i_d.di_uid;
7862 inode->i_gid = ip->i_d.di_gid;
7863 + inode->i_tag = ip->i_d.di_tag;
7865 switch (inode->i_mode & S_IFMT) {
7867 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_linux.h
7868 --- linux-2.6.32.24/fs/xfs/linux-2.6/xfs_linux.h 2009-09-10 15:26:24.000000000 +0200
7869 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_linux.h 2009-12-03 20:04:56.000000000 +0100
7872 #define current_cpu() (raw_smp_processor_id())
7873 #define current_pid() (current->pid)
7874 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
7875 #define current_test_flags(f) (current->flags & (f))
7876 #define current_set_flags_nested(sp, f) \
7877 (*(sp) = current->flags, current->flags |= (f))
7878 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/linux-2.6/xfs_super.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_super.c
7879 --- linux-2.6.32.24/fs/xfs/linux-2.6/xfs_super.c 2010-10-04 08:56:15.000000000 +0200
7880 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/linux-2.6/xfs_super.c 2010-05-21 13:20:19.000000000 +0200
7881 @@ -117,6 +117,9 @@ mempool_t *xfs_ioend_pool;
7882 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
7883 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
7884 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
7885 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7886 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7887 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7890 * Table driven mount option parser.
7891 @@ -125,10 +128,14 @@ mempool_t *xfs_ioend_pool;
7892 * in the future, too.
7895 + Opt_tag, Opt_notag,
7896 Opt_barrier, Opt_nobarrier, Opt_err
7899 static const match_table_t tokens = {
7900 + {Opt_tag, "tagxid"},
7902 + {Opt_notag, "notag"},
7903 {Opt_barrier, "barrier"},
7904 {Opt_nobarrier, "nobarrier"},
7906 @@ -382,6 +389,19 @@ xfs_parseargs(
7907 } else if (!strcmp(this_char, "irixsgid")) {
7909 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
7910 +#ifndef CONFIG_TAGGING_NONE
7911 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7912 + mp->m_flags |= XFS_MOUNT_TAGGED;
7913 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7914 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7915 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7916 + mp->m_flags |= XFS_MOUNT_TAGGED;
7918 +#ifdef CONFIG_PROPAGATE
7919 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7921 + mp->m_flags |= XFS_MOUNT_TAGGED;
7925 "XFS: unknown mount option [%s].", this_char);
7926 @@ -1295,6 +1315,16 @@ xfs_fs_remount(
7928 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7931 + if (!(sb->s_flags & MS_TAGGED)) {
7933 + "XFS: %s: tagging not permitted on remount.\n",
7942 * Logically we would return an error here to prevent
7943 @@ -1530,6 +1560,9 @@ xfs_fs_fill_super(
7945 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
7947 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7948 + sb->s_flags |= MS_TAGGED;
7950 sb->s_magic = XFS_SB_MAGIC;
7951 sb->s_blocksize = mp->m_sb.sb_blocksize;
7952 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
7953 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_dinode.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_dinode.h
7954 --- linux-2.6.32.24/fs/xfs/xfs_dinode.h 2009-06-11 17:13:09.000000000 +0200
7955 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_dinode.h 2009-12-03 20:04:56.000000000 +0100
7956 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
7957 __be32 di_gid; /* owner's group id */
7958 __be32 di_nlink; /* number of links to file */
7959 __be16 di_projid; /* owner's project id */
7960 - __u8 di_pad[8]; /* unused, zeroed space */
7961 + __be16 di_tag; /* context tagging */
7962 + __be16 di_vflags; /* vserver specific flags */
7963 + __u8 di_pad[4]; /* unused, zeroed space */
7964 __be16 di_flushiter; /* incremented on flush */
7965 xfs_timestamp_t di_atime; /* time last accessed */
7966 xfs_timestamp_t di_mtime; /* time last modified */
7967 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
7968 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7969 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7970 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7971 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7973 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7974 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7975 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7976 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
7977 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7978 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7979 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7980 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7982 #ifdef CONFIG_XFS_RT
7983 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7984 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
7985 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7986 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7987 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7988 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7989 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7990 + XFS_DIFLAG_IXUNLINK)
7992 +#define XFS_DIVFLAG_BARRIER 0x01
7993 +#define XFS_DIVFLAG_COW 0x02
7995 #endif /* __XFS_DINODE_H__ */
7996 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_fs.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_fs.h
7997 --- linux-2.6.32.24/fs/xfs/xfs_fs.h 2009-12-03 20:02:53.000000000 +0100
7998 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_fs.h 2009-12-03 20:04:56.000000000 +0100
7999 @@ -67,6 +67,9 @@ struct fsxattr {
8000 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8001 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8002 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8003 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8004 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8005 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8006 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8009 @@ -292,7 +295,8 @@ typedef struct xfs_bstat {
8010 __s32 bs_extents; /* number of extents */
8011 __u32 bs_gen; /* generation count */
8012 __u16 bs_projid; /* project id */
8013 - unsigned char bs_pad[14]; /* pad space, unused */
8014 + __u16 bs_tag; /* context tagging */
8015 + unsigned char bs_pad[12]; /* pad space, unused */
8016 __u32 bs_dmevmask; /* DMIG event mask */
8017 __u16 bs_dmstate; /* DMIG state info */
8018 __u16 bs_aextents; /* attribute number of extents */
8019 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_ialloc.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_ialloc.c
8020 --- linux-2.6.32.24/fs/xfs/xfs_ialloc.c 2009-12-03 20:02:53.000000000 +0100
8021 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_ialloc.c 2009-12-03 20:04:56.000000000 +0100
8023 #include "xfs_error.h"
8024 #include "xfs_bmap.h"
8028 * Allocation group level functions.
8030 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_inode.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_inode.c
8031 --- linux-2.6.32.24/fs/xfs/xfs_inode.c 2010-10-04 08:56:15.000000000 +0200
8032 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_inode.c 2010-04-28 10:19:35.000000000 +0200
8033 @@ -249,6 +249,7 @@ xfs_inotobp(
8037 +#include <linux/vs_tag.h>
8040 * This routine is called to map an inode to the buffer containing
8041 @@ -654,15 +655,25 @@ xfs_iformat_btree(
8043 xfs_dinode_from_disk(
8045 - xfs_dinode_t *from)
8046 + xfs_dinode_t *from,
8049 + uint32_t uid, gid, tag;
8051 to->di_magic = be16_to_cpu(from->di_magic);
8052 to->di_mode = be16_to_cpu(from->di_mode);
8053 to->di_version = from ->di_version;
8054 to->di_format = from->di_format;
8055 to->di_onlink = be16_to_cpu(from->di_onlink);
8056 - to->di_uid = be32_to_cpu(from->di_uid);
8057 - to->di_gid = be32_to_cpu(from->di_gid);
8059 + uid = be32_to_cpu(from->di_uid);
8060 + gid = be32_to_cpu(from->di_gid);
8061 + tag = be16_to_cpu(from->di_tag);
8063 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8064 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8065 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8067 to->di_nlink = be32_to_cpu(from->di_nlink);
8068 to->di_projid = be16_to_cpu(from->di_projid);
8069 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8070 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
8071 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8072 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8073 to->di_flags = be16_to_cpu(from->di_flags);
8074 + to->di_vflags = be16_to_cpu(from->di_vflags);
8075 to->di_gen = be32_to_cpu(from->di_gen);
8081 - xfs_icdinode_t *from)
8082 + xfs_icdinode_t *from,
8085 to->di_magic = cpu_to_be16(from->di_magic);
8086 to->di_mode = cpu_to_be16(from->di_mode);
8087 to->di_version = from ->di_version;
8088 to->di_format = from->di_format;
8089 to->di_onlink = cpu_to_be16(from->di_onlink);
8090 - to->di_uid = cpu_to_be32(from->di_uid);
8091 - to->di_gid = cpu_to_be32(from->di_gid);
8093 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8094 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8095 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8097 to->di_nlink = cpu_to_be32(from->di_nlink);
8098 to->di_projid = cpu_to_be16(from->di_projid);
8099 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8100 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
8101 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8102 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8103 to->di_flags = cpu_to_be16(from->di_flags);
8104 + to->di_vflags = cpu_to_be16(from->di_vflags);
8105 to->di_gen = cpu_to_be32(from->di_gen);
8110 - __uint16_t di_flags)
8111 + __uint16_t di_flags,
8112 + __uint16_t di_vflags)
8116 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
8117 flags |= XFS_XFLAG_PREALLOC;
8118 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8119 flags |= XFS_XFLAG_IMMUTABLE;
8120 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8121 + flags |= XFS_XFLAG_IXUNLINK;
8122 if (di_flags & XFS_DIFLAG_APPEND)
8123 flags |= XFS_XFLAG_APPEND;
8124 if (di_flags & XFS_DIFLAG_SYNC)
8125 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
8126 flags |= XFS_XFLAG_FILESTREAM;
8129 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8130 + flags |= FS_BARRIER_FL;
8131 + if (di_vflags & XFS_DIVFLAG_COW)
8132 + flags |= FS_COW_FL;
8136 @@ -767,7 +791,7 @@ xfs_ip2xflags(
8138 xfs_icdinode_t *dic = &ip->i_d;
8140 - return _xfs_dic2xflags(dic->di_flags) |
8141 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8142 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8145 @@ -775,7 +799,8 @@ uint
8149 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8150 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8151 + be16_to_cpu(dip->di_vflags)) |
8152 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8155 @@ -811,7 +836,6 @@ xfs_iread(
8158 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8161 * If we got something that isn't an inode it means someone
8162 * (nfs or dmi) has a stale handle.
8163 @@ -836,7 +860,8 @@ xfs_iread(
8164 * Otherwise, just get the truly permanent information.
8167 - xfs_dinode_from_disk(&ip->i_d, dip);
8168 + xfs_dinode_from_disk(&ip->i_d, dip,
8169 + mp->m_flags & XFS_MOUNT_TAGGED);
8170 error = xfs_iformat(ip, dip);
8173 @@ -1036,6 +1061,7 @@ xfs_ialloc(
8174 ASSERT(ip->i_d.di_nlink == nlink);
8175 ip->i_d.di_uid = current_fsuid();
8176 ip->i_d.di_gid = current_fsgid();
8177 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
8178 ip->i_d.di_projid = prid;
8179 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8181 @@ -1096,6 +1122,7 @@ xfs_ialloc(
8182 ip->i_d.di_dmevmask = 0;
8183 ip->i_d.di_dmstate = 0;
8184 ip->i_d.di_flags = 0;
8185 + ip->i_d.di_vflags = 0;
8186 flags = XFS_ILOG_CORE;
8187 switch (mode & S_IFMT) {
8189 @@ -2172,6 +2199,7 @@ xfs_ifree(
8191 ip->i_d.di_mode = 0; /* mark incore inode as free */
8192 ip->i_d.di_flags = 0;
8193 + ip->i_d.di_vflags = 0;
8194 ip->i_d.di_dmevmask = 0;
8195 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8196 ip->i_df.if_ext_max =
8197 @@ -3152,7 +3180,8 @@ xfs_iflush_int(
8198 * because if the inode is dirty at all the core must
8201 - xfs_dinode_to_disk(dip, &ip->i_d);
8202 + xfs_dinode_to_disk(dip, &ip->i_d,
8203 + mp->m_flags & XFS_MOUNT_TAGGED);
8205 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8206 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8207 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_inode.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_inode.h
8208 --- linux-2.6.32.24/fs/xfs/xfs_inode.h 2009-12-03 20:02:54.000000000 +0100
8209 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_inode.h 2009-12-03 20:04:56.000000000 +0100
8210 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
8211 __uint32_t di_gid; /* owner's group id */
8212 __uint32_t di_nlink; /* number of links to file */
8213 __uint16_t di_projid; /* owner's project id */
8214 - __uint8_t di_pad[8]; /* unused, zeroed space */
8215 + __uint16_t di_tag; /* context tagging */
8216 + __uint16_t di_vflags; /* vserver specific flags */
8217 + __uint8_t di_pad[4]; /* unused, zeroed space */
8218 __uint16_t di_flushiter; /* incremented on flush */
8219 xfs_ictimestamp_t di_atime; /* time last accessed */
8220 xfs_ictimestamp_t di_mtime; /* time last modified */
8221 @@ -569,7 +571,7 @@ int xfs_itobp(struct xfs_mount *, struc
8222 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8223 struct xfs_inode *, xfs_daddr_t, uint);
8224 void xfs_dinode_to_disk(struct xfs_dinode *,
8225 - struct xfs_icdinode *);
8226 + struct xfs_icdinode *, int);
8227 void xfs_idestroy_fork(struct xfs_inode *, int);
8228 void xfs_idata_realloc(struct xfs_inode *, int, int);
8229 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8230 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_itable.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_itable.c
8231 --- linux-2.6.32.24/fs/xfs/xfs_itable.c 2009-12-03 20:02:54.000000000 +0100
8232 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_itable.c 2009-12-03 20:04:56.000000000 +0100
8233 @@ -84,6 +84,7 @@ xfs_bulkstat_one_iget(
8234 buf->bs_mode = dic->di_mode;
8235 buf->bs_uid = dic->di_uid;
8236 buf->bs_gid = dic->di_gid;
8237 + buf->bs_tag = dic->di_tag;
8238 buf->bs_size = dic->di_size;
8241 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_log_recover.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_log_recover.c
8242 --- linux-2.6.32.24/fs/xfs/xfs_log_recover.c 2010-10-04 08:56:15.000000000 +0200
8243 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_log_recover.c 2010-04-28 10:19:35.000000000 +0200
8244 @@ -2467,7 +2467,8 @@ xlog_recover_do_inode_trans(
8247 /* The core is in in-core format */
8248 - xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8249 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8250 + mp->m_flags & XFS_MOUNT_TAGGED);
8252 /* the rest is in on-disk format */
8253 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8254 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_mount.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_mount.h
8255 --- linux-2.6.32.24/fs/xfs/xfs_mount.h 2010-10-04 08:56:15.000000000 +0200
8256 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_mount.h 2010-05-21 13:20:19.000000000 +0200
8257 @@ -285,6 +285,7 @@ typedef struct xfs_mount {
8259 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8261 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8264 * Default minimum read and write sizes.
8265 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_vnodeops.c linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_vnodeops.c
8266 --- linux-2.6.32.24/fs/xfs/xfs_vnodeops.c 2010-10-04 08:56:15.000000000 +0200
8267 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_vnodeops.c 2010-04-28 10:20:09.000000000 +0200
8269 #include "xfs_filestream.h"
8270 #include "xfs_vnodeops.h"
8274 +xfs_get_inode_flags(
8277 + struct inode *inode = VFS_I(ip);
8278 + unsigned int flags = inode->i_flags;
8279 + unsigned int vflags = inode->i_vflags;
8281 + if (flags & S_IMMUTABLE)
8282 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8284 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8285 + if (flags & S_IXUNLINK)
8286 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8288 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8290 + if (vflags & V_BARRIER)
8291 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8293 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8294 + if (vflags & V_COW)
8295 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8297 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8302 + struct inode *inode,
8306 + struct xfs_inode *ip = XFS_I(inode);
8307 + struct xfs_mount *mp = ip->i_mount;
8308 + struct xfs_trans *tp;
8309 + unsigned int lock_flags = 0;
8312 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8313 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8317 + lock_flags = XFS_ILOCK_EXCL;
8318 + xfs_ilock(ip, lock_flags);
8320 + xfs_trans_ijoin(tp, ip, lock_flags);
8321 + xfs_trans_ihold(tp, ip);
8323 + inode->i_flags = flags;
8324 + inode->i_vflags = vflags;
8325 + xfs_get_inode_flags(ip);
8327 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8328 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8330 + XFS_STATS_INC(xs_ig_attrchg);
8332 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8333 + xfs_trans_set_sync(tp);
8334 + code = xfs_trans_commit(tp, 0);
8335 + xfs_iunlock(ip, lock_flags);
8339 + xfs_trans_cancel(tp, 0);
8341 + xfs_iunlock(ip, lock_flags);
8348 struct xfs_inode *ip,
8349 @@ -69,6 +143,7 @@ xfs_setattr(
8350 uint commit_flags=0;
8351 uid_t uid=0, iuid=0;
8352 gid_t gid=0, igid=0;
8353 + tag_t tag=0, itag=0;
8354 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8355 int need_iolock = 1;
8357 @@ -161,7 +236,7 @@ xfs_setattr(
8359 * Change file ownership. Must be the owner or privileged.
8361 - if (mask & (ATTR_UID|ATTR_GID)) {
8362 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8364 * These IDs could have changed since we last looked at them.
8365 * But, we're assured that if the ownership did change
8366 @@ -170,8 +245,10 @@ xfs_setattr(
8368 iuid = ip->i_d.di_uid;
8369 igid = ip->i_d.di_gid;
8370 + itag = ip->i_d.di_tag;
8371 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8372 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8373 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8376 * Do a quota reservation only if uid/gid is actually
8377 @@ -179,7 +256,8 @@ xfs_setattr(
8379 if (XFS_IS_QUOTA_RUNNING(mp) &&
8380 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8381 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8382 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8383 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8385 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8386 capable(CAP_FOWNER) ?
8387 @@ -340,7 +418,7 @@ xfs_setattr(
8389 * Change file ownership. Must be the owner or privileged.
8391 - if (mask & (ATTR_UID|ATTR_GID)) {
8392 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8394 * CAP_FSETID overrides the following restrictions:
8396 @@ -356,6 +434,10 @@ xfs_setattr(
8397 * Change the ownerships and register quota modifications
8398 * in the transaction.
8400 + if (itag != tag) {
8401 + ip->i_d.di_tag = tag;
8402 + inode->i_tag = tag;
8405 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8406 ASSERT(mask & ATTR_UID);
8407 diff -NurpP --minimal linux-2.6.32.24/fs/xfs/xfs_vnodeops.h linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_vnodeops.h
8408 --- linux-2.6.32.24/fs/xfs/xfs_vnodeops.h 2010-10-04 08:56:15.000000000 +0200
8409 +++ linux-2.6.32.24-vs2.3.0.36.29.6/fs/xfs/xfs_vnodeops.h 2010-04-28 10:19:38.000000000 +0200
8410 @@ -14,6 +14,7 @@ struct xfs_inode;
8414 +int xfs_sync_xflags(struct xfs_inode *ip);
8415 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8416 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8417 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8418 diff -NurpP --minimal linux-2.6.32.24/include/asm-generic/tlb.h linux-2.6.32.24-vs2.3.0.36.29.6/include/asm-generic/tlb.h
8419 --- linux-2.6.32.24/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8420 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/asm-generic/tlb.h 2009-12-03 20:04:56.000000000 +0100
8422 #define _ASM_GENERIC__TLB_H
8424 #include <linux/swap.h>
8425 +#include <linux/vs_memory.h>
8426 #include <asm/pgalloc.h>
8427 #include <asm/tlbflush.h>
8429 diff -NurpP --minimal linux-2.6.32.24/include/linux/capability.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/capability.h
8430 --- linux-2.6.32.24/include/linux/capability.h 2009-12-03 20:02:54.000000000 +0100
8431 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/capability.h 2009-12-03 20:04:56.000000000 +0100
8432 @@ -285,6 +285,7 @@ struct cpu_vfs_cap_data {
8433 arbitrary SCSI commands */
8434 /* Allow setting encryption key on loopback filesystem */
8435 /* Allow setting zone reclaim policy */
8436 +/* Allow the selection of a security context */
8438 #define CAP_SYS_ADMIN 21
8440 @@ -357,7 +358,13 @@ struct cpu_vfs_cap_data {
8442 #define CAP_MAC_ADMIN 33
8444 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8445 +/* Allow context manipulations */
8446 +/* Allow changing context info on files */
8448 +#define CAP_CONTEXT 34
8451 +#define CAP_LAST_CAP CAP_CONTEXT
8453 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8455 diff -NurpP --minimal linux-2.6.32.24/include/linux/devpts_fs.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/devpts_fs.h
8456 --- linux-2.6.32.24/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8457 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/devpts_fs.h 2009-12-03 20:04:56.000000000 +0100
8458 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8463 #endif /* _LINUX_DEVPTS_FS_H */
8464 diff -NurpP --minimal linux-2.6.32.24/include/linux/ext2_fs.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/ext2_fs.h
8465 --- linux-2.6.32.24/include/linux/ext2_fs.h 2009-03-24 14:22:41.000000000 +0100
8466 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/ext2_fs.h 2009-12-03 20:04:56.000000000 +0100
8467 @@ -189,8 +189,12 @@ struct ext2_group_desc
8468 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8469 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8470 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8471 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8472 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8474 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8475 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8477 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8478 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8480 @@ -274,7 +278,8 @@ struct ext2_inode {
8482 __le16 l_i_uid_high; /* these 2 fields */
8483 __le16 l_i_gid_high; /* were reserved2[0] */
8484 - __u32 l_i_reserved2;
8485 + __le16 l_i_tag; /* Context Tag */
8486 + __u16 l_i_reserved2;
8489 __u8 h_i_frag; /* Fragment number */
8490 @@ -303,6 +308,7 @@ struct ext2_inode {
8491 #define i_gid_low i_gid
8492 #define i_uid_high osd2.linux2.l_i_uid_high
8493 #define i_gid_high osd2.linux2.l_i_gid_high
8494 +#define i_raw_tag osd2.linux2.l_i_tag
8495 #define i_reserved2 osd2.linux2.l_i_reserved2
8498 @@ -347,6 +353,7 @@ struct ext2_inode {
8499 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8500 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8501 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8502 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8505 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8506 diff -NurpP --minimal linux-2.6.32.24/include/linux/ext3_fs.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/ext3_fs.h
8507 --- linux-2.6.32.24/include/linux/ext3_fs.h 2009-09-10 15:26:25.000000000 +0200
8508 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/ext3_fs.h 2009-12-03 20:04:56.000000000 +0100
8509 @@ -173,10 +173,14 @@ struct ext3_group_desc
8510 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8511 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8512 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8513 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8514 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8516 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8517 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8518 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8519 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8521 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8522 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8524 /* Flags that should be inherited by new inodes from their parent. */
8525 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8526 @@ -320,7 +324,8 @@ struct ext3_inode {
8528 __le16 l_i_uid_high; /* these 2 fields */
8529 __le16 l_i_gid_high; /* were reserved2[0] */
8530 - __u32 l_i_reserved2;
8531 + __le16 l_i_tag; /* Context Tag */
8532 + __u16 l_i_reserved2;
8535 __u8 h_i_frag; /* Fragment number */
8536 @@ -351,6 +356,7 @@ struct ext3_inode {
8537 #define i_gid_low i_gid
8538 #define i_uid_high osd2.linux2.l_i_uid_high
8539 #define i_gid_high osd2.linux2.l_i_gid_high
8540 +#define i_raw_tag osd2.linux2.l_i_tag
8541 #define i_reserved2 osd2.linux2.l_i_reserved2
8543 #elif defined(__GNU__)
8544 @@ -414,6 +420,7 @@ struct ext3_inode {
8545 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8546 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8547 * error in ordered mode */
8548 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8550 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8551 #ifndef _LINUX_EXT2_FS_H
8552 @@ -892,6 +899,7 @@ extern void ext3_get_inode_flags(struct
8553 extern void ext3_set_aops(struct inode *inode);
8554 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8555 u64 start, u64 len);
8556 +extern int ext3_sync_flags(struct inode *, int, int);
8559 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8560 diff -NurpP --minimal linux-2.6.32.24/include/linux/fs.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/fs.h
8561 --- linux-2.6.32.24/include/linux/fs.h 2010-10-04 08:56:16.000000000 +0200
8562 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/fs.h 2010-08-19 17:35:34.000000000 +0200
8563 @@ -208,6 +208,9 @@ struct inodes_stat_t {
8564 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8565 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8566 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8567 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8568 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8569 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8570 #define MS_ACTIVE (1<<30)
8571 #define MS_NOUSER (1<<31)
8573 @@ -234,6 +237,14 @@ struct inodes_stat_t {
8574 #define S_NOCMTIME 128 /* Do not update file c/mtime */
8575 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8576 #define S_PRIVATE 512 /* Inode is fs-internal */
8577 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
8579 +/* Linux-VServer related Inode flags */
8583 +#define V_BARRIER 4 /* Barrier for chroot() */
8584 +#define V_COW 8 /* Copy on Write */
8587 * Note that nosuid etc flags are inode-specific: setting some file-system
8588 @@ -256,12 +267,15 @@ struct inodes_stat_t {
8589 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8590 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8591 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8592 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8593 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8594 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8595 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8596 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8598 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8599 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8600 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8601 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8602 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8603 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8605 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8606 @@ -269,6 +283,16 @@ struct inodes_stat_t {
8607 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8608 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8610 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8612 +#ifdef CONFIG_VSERVER_COWBL
8613 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8614 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8616 +# define IS_COW(inode) (0)
8617 +# define IS_COW_LINK(inode) (0)
8620 /* the read-only stuff doesn't really belong here, but any other place is
8621 probably as bad and I don't want to create yet another include file. */
8623 @@ -350,11 +374,14 @@ struct inodes_stat_t {
8624 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8625 #define FS_EXTENT_FL 0x00080000 /* Extents */
8626 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8627 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8628 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8630 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8631 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8632 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8633 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8635 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8636 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8638 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8639 #define SYNC_FILE_RANGE_WRITE 2
8640 @@ -436,6 +463,7 @@ typedef void (dio_iodone_t)(struct kiocb
8641 #define ATTR_KILL_PRIV (1 << 14)
8642 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8643 #define ATTR_TIMES_SET (1 << 16)
8644 +#define ATTR_TAG (1 << 17)
8647 * This is the Inode Attributes structure, used for notify_change(). It
8648 @@ -451,6 +479,7 @@ struct iattr {
8654 struct timespec ia_atime;
8655 struct timespec ia_mtime;
8656 @@ -464,6 +493,9 @@ struct iattr {
8657 struct file *ia_file;
8660 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8661 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8664 * Includes for diskquotas.
8666 @@ -729,7 +761,9 @@ struct inode {
8667 unsigned int i_nlink;
8675 #ifdef __NEED_I_SIZE_ORDERED
8676 @@ -776,7 +810,8 @@ struct inode {
8677 unsigned long i_state;
8678 unsigned long dirtied_when; /* jiffies of first dirtying */
8680 - unsigned int i_flags;
8681 + unsigned short i_flags;
8682 + unsigned short i_vflags;
8684 atomic_t i_writecount;
8685 #ifdef CONFIG_SECURITY
8686 @@ -864,12 +899,12 @@ static inline void i_size_write(struct i
8688 static inline unsigned iminor(const struct inode *inode)
8690 - return MINOR(inode->i_rdev);
8691 + return MINOR(inode->i_mdev);
8694 static inline unsigned imajor(const struct inode *inode)
8696 - return MAJOR(inode->i_rdev);
8697 + return MAJOR(inode->i_mdev);
8700 extern struct block_device *I_BDEV(struct inode *inode);
8701 @@ -928,6 +963,7 @@ struct file {
8703 struct fown_struct f_owner;
8704 const struct cred *f_cred;
8706 struct file_ra_state f_ra;
8709 @@ -1069,6 +1105,7 @@ struct file_lock {
8710 struct file *fl_file;
8715 struct fasync_struct * fl_fasync; /* for lease break notifications */
8716 unsigned long fl_break_time; /* for nonblocking lease breaks */
8717 @@ -1536,6 +1573,7 @@ struct inode_operations {
8718 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8719 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8720 int (*removexattr) (struct dentry *, const char *);
8721 + int (*sync_flags) (struct inode *, int, int);
8722 void (*truncate_range)(struct inode *, loff_t, loff_t);
8723 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
8725 @@ -1556,6 +1594,7 @@ extern ssize_t vfs_readv(struct file *,
8726 unsigned long, loff_t *);
8727 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8728 unsigned long, loff_t *);
8729 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8731 struct super_operations {
8732 struct inode *(*alloc_inode)(struct super_block *sb);
8733 @@ -2354,6 +2393,7 @@ extern int dcache_dir_open(struct inode
8734 extern int dcache_dir_close(struct inode *, struct file *);
8735 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8736 extern int dcache_readdir(struct file *, void *, filldir_t);
8737 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8738 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8739 extern int simple_statfs(struct dentry *, struct kstatfs *);
8740 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
8741 diff -NurpP --minimal linux-2.6.32.24/include/linux/gfs2_ondisk.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/gfs2_ondisk.h
8742 --- linux-2.6.32.24/include/linux/gfs2_ondisk.h 2009-12-03 20:02:55.000000000 +0100
8743 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/gfs2_ondisk.h 2009-12-03 20:04:56.000000000 +0100
8744 @@ -235,6 +235,9 @@ enum {
8748 + gfs2fl_IXUnlink = 16,
8749 + gfs2fl_Barrier = 17,
8751 gfs2fl_TruncInProg = 29,
8752 gfs2fl_InheritDirectio = 30,
8753 gfs2fl_InheritJdata = 31,
8754 @@ -251,6 +254,9 @@ enum {
8755 #define GFS2_DIF_NOATIME 0x00000080
8756 #define GFS2_DIF_SYNC 0x00000100
8757 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8758 +#define GFS2_DIF_IXUNLINK 0x00010000
8759 +#define GFS2_DIF_BARRIER 0x00020000
8760 +#define GFS2_DIF_COW 0x00040000
8761 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8762 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8763 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8764 diff -NurpP --minimal linux-2.6.32.24/include/linux/if_tun.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/if_tun.h
8765 --- linux-2.6.32.24/include/linux/if_tun.h 2009-12-03 20:02:55.000000000 +0100
8766 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/if_tun.h 2009-12-03 20:04:56.000000000 +0100
8768 #define TUNGETIFF _IOR('T', 210, unsigned int)
8769 #define TUNGETSNDBUF _IOR('T', 211, int)
8770 #define TUNSETSNDBUF _IOW('T', 212, int)
8771 +#define TUNSETNID _IOW('T', 215, int)
8773 /* TUNSETIFF ifr flags */
8774 #define IFF_TUN 0x0001
8775 diff -NurpP --minimal linux-2.6.32.24/include/linux/init_task.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/init_task.h
8776 --- linux-2.6.32.24/include/linux/init_task.h 2009-12-03 20:02:55.000000000 +0100
8777 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/init_task.h 2009-12-03 20:04:56.000000000 +0100
8778 @@ -184,6 +184,10 @@ extern struct cred init_cred;
8780 INIT_TRACE_RECURSION \
8781 INIT_TASK_RCU_PREEMPT(tsk) \
8783 + .vx_info = NULL, \
8785 + .nx_info = NULL, \
8789 diff -NurpP --minimal linux-2.6.32.24/include/linux/ipc.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/ipc.h
8790 --- linux-2.6.32.24/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8791 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/ipc.h 2009-12-03 20:04:56.000000000 +0100
8792 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8800 diff -NurpP --minimal linux-2.6.32.24/include/linux/Kbuild linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/Kbuild
8801 --- linux-2.6.32.24/include/linux/Kbuild 2009-12-03 20:02:54.000000000 +0100
8802 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/Kbuild 2009-12-03 20:04:56.000000000 +0100
8803 @@ -382,5 +382,8 @@ unifdef-y += xattr.h
8806 objhdr-y += version.h
8808 +header-y += vserver/
8812 diff -NurpP --minimal linux-2.6.32.24/include/linux/loop.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/loop.h
8813 --- linux-2.6.32.24/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8814 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/loop.h 2009-12-03 20:04:56.000000000 +0100
8815 @@ -45,6 +45,7 @@ struct loop_device {
8816 struct loop_func_table *lo_encryption;
8818 uid_t lo_key_owner; /* Who set the key */
8820 int (*ioctl)(struct loop_device *, int cmd,
8823 diff -NurpP --minimal linux-2.6.32.24/include/linux/magic.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/magic.h
8824 --- linux-2.6.32.24/include/linux/magic.h 2009-12-03 20:02:55.000000000 +0100
8825 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/magic.h 2009-12-03 20:04:56.000000000 +0100
8828 #define ADFS_SUPER_MAGIC 0xadf5
8829 #define AFFS_SUPER_MAGIC 0xadff
8830 -#define AFS_SUPER_MAGIC 0x5346414F
8831 +#define AFS_SUPER_MAGIC 0x5346414F
8832 #define AUTOFS_SUPER_MAGIC 0x0187
8833 #define CODA_SUPER_MAGIC 0x73757245
8834 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8836 #define NFS_SUPER_MAGIC 0x6969
8837 #define OPENPROM_SUPER_MAGIC 0x9fa1
8838 #define PROC_SUPER_MAGIC 0x9fa0
8839 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8840 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8842 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8843 diff -NurpP --minimal linux-2.6.32.24/include/linux/major.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/major.h
8844 --- linux-2.6.32.24/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8845 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/major.h 2009-12-03 20:04:56.000000000 +0100
8847 #define HD_MAJOR IDE0_MAJOR
8848 #define PTY_SLAVE_MAJOR 3
8850 +#define VROOT_MAJOR 4
8851 #define TTYAUX_MAJOR 5
8854 diff -NurpP --minimal linux-2.6.32.24/include/linux/memcontrol.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/memcontrol.h
8855 --- linux-2.6.32.24/include/linux/memcontrol.h 2009-12-03 20:02:55.000000000 +0100
8856 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/memcontrol.h 2010-02-05 00:15:49.000000000 +0100
8857 @@ -70,6 +70,13 @@ int task_in_mem_cgroup(struct task_struc
8859 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8861 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8862 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8864 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8865 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8866 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8869 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8871 diff -NurpP --minimal linux-2.6.32.24/include/linux/mm_types.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/mm_types.h
8872 --- linux-2.6.32.24/include/linux/mm_types.h 2010-10-04 08:56:16.000000000 +0200
8873 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/mm_types.h 2010-09-05 21:24:17.000000000 +0200
8874 @@ -246,6 +246,7 @@ struct mm_struct {
8876 /* Architecture-specific MM context */
8877 mm_context_t context;
8878 + struct vx_info *mm_vx_info;
8880 /* Swap token stuff */
8882 diff -NurpP --minimal linux-2.6.32.24/include/linux/mount.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/mount.h
8883 --- linux-2.6.32.24/include/linux/mount.h 2009-09-10 15:26:25.000000000 +0200
8884 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/mount.h 2009-12-03 20:04:56.000000000 +0100
8885 @@ -36,6 +36,9 @@ struct mnt_namespace;
8886 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
8887 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
8889 +#define MNT_TAGID 0x10000
8890 +#define MNT_NOTAG 0x20000
8893 struct list_head mnt_hash;
8894 struct vfsmount *mnt_parent; /* fs we are mounted on */
8895 @@ -70,6 +73,7 @@ struct vfsmount {
8899 + tag_t mnt_tag; /* tagging used for vfsmount */
8902 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
8903 diff -NurpP --minimal linux-2.6.32.24/include/linux/net.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/net.h
8904 --- linux-2.6.32.24/include/linux/net.h 2009-12-03 20:02:55.000000000 +0100
8905 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/net.h 2009-12-03 20:04:56.000000000 +0100
8906 @@ -69,6 +69,7 @@ struct net;
8907 #define SOCK_NOSPACE 2
8908 #define SOCK_PASSCRED 3
8909 #define SOCK_PASSSEC 4
8910 +#define SOCK_USER_SOCKET 5
8912 #ifndef ARCH_HAS_SOCKET_TYPES
8914 diff -NurpP --minimal linux-2.6.32.24/include/linux/nfs_mount.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/nfs_mount.h
8915 --- linux-2.6.32.24/include/linux/nfs_mount.h 2009-03-24 14:22:43.000000000 +0100
8916 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/nfs_mount.h 2009-12-03 20:04:56.000000000 +0100
8917 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8918 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8919 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8920 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8921 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8922 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8923 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8925 /* The following are for internal use only */
8926 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8927 diff -NurpP --minimal linux-2.6.32.24/include/linux/nsproxy.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/nsproxy.h
8928 --- linux-2.6.32.24/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
8929 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/nsproxy.h 2009-12-03 20:04:56.000000000 +0100
8932 #include <linux/spinlock.h>
8933 #include <linux/sched.h>
8934 +#include <linux/vserver/debug.h>
8936 struct mnt_namespace;
8937 struct uts_namespace;
8938 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
8941 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8942 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8943 void exit_task_namespaces(struct task_struct *tsk);
8944 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8945 void free_nsproxy(struct nsproxy *ns);
8946 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
8947 struct fs_struct *);
8949 -static inline void put_nsproxy(struct nsproxy *ns)
8950 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8952 +static inline void __get_nsproxy(struct nsproxy *ns,
8953 + const char *_file, int _line)
8955 - if (atomic_dec_and_test(&ns->count)) {
8958 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8959 + ns, atomic_read(&ns->count), _file, _line);
8960 + atomic_inc(&ns->count);
8963 -static inline void get_nsproxy(struct nsproxy *ns)
8964 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8966 +static inline void __put_nsproxy(struct nsproxy *ns,
8967 + const char *_file, int _line)
8969 - atomic_inc(&ns->count);
8970 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8971 + ns, atomic_read(&ns->count), _file, _line);
8972 + if (atomic_dec_and_test(&ns->count)) {
8977 #ifdef CONFIG_CGROUP_NS
8978 diff -NurpP --minimal linux-2.6.32.24/include/linux/pid.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/pid.h
8979 --- linux-2.6.32.24/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
8980 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/pid.h 2009-12-03 20:04:56.000000000 +0100
8981 @@ -8,7 +8,8 @@ enum pid_type
8991 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
8994 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8995 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8996 pid_t pid_vnr(struct pid *pid);
8998 #define do_each_pid_task(pid, type, task) \
8999 diff -NurpP --minimal linux-2.6.32.24/include/linux/proc_fs.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/proc_fs.h
9000 --- linux-2.6.32.24/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9001 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/proc_fs.h 2009-12-03 20:04:56.000000000 +0100
9002 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9008 const struct inode_operations *proc_iops;
9010 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9011 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9018 int (*proc_get_link)(struct inode *, struct path *);
9019 int (*proc_read)(struct task_struct *task, char *page);
9020 int (*proc_show)(struct seq_file *m,
9021 struct pid_namespace *ns, struct pid *pid,
9022 struct task_struct *task);
9023 + int (*proc_vs_read)(char *page);
9024 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9025 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9028 struct ctl_table_header;
9029 @@ -263,6 +270,7 @@ struct ctl_table;
9036 struct proc_dir_entry *pde;
9037 diff -NurpP --minimal linux-2.6.32.24/include/linux/quotaops.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/quotaops.h
9038 --- linux-2.6.32.24/include/linux/quotaops.h 2010-10-04 08:56:16.000000000 +0200
9039 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/quotaops.h 2010-04-05 20:57:19.000000000 +0200
9041 #define _LINUX_QUOTAOPS_
9043 #include <linux/fs.h>
9044 +#include <linux/vs_dlimit.h>
9046 static inline struct quota_info *sb_dqopt(struct super_block *sb)
9048 @@ -157,10 +158,14 @@ static inline void vfs_dq_init(struct in
9049 * a transaction (deadlocks possible otherwise) */
9050 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9052 + if (dl_alloc_space(inode, nr))
9054 if (sb_any_quota_active(inode->i_sb)) {
9055 /* Used space is updated in alloc_space() */
9056 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
9057 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) {
9058 + dl_free_space(inode, nr);
9063 inode_add_bytes(inode, nr);
9064 @@ -177,10 +182,14 @@ static inline int vfs_dq_prealloc_space(
9066 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9068 + if (dl_alloc_space(inode, nr))
9070 if (sb_any_quota_active(inode->i_sb)) {
9071 /* Used space is updated in alloc_space() */
9072 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
9073 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) {
9074 + dl_free_space(inode, nr);
9079 inode_add_bytes(inode, nr);
9080 @@ -197,10 +206,14 @@ static inline int vfs_dq_alloc_space(str
9082 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9084 + if (dl_reserve_space(inode, nr))
9086 if (sb_any_quota_active(inode->i_sb)) {
9087 /* Used space is updated in alloc_space() */
9088 - if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
9089 + if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) {
9090 + dl_release_space(inode, nr);
9095 inode_add_rsv_space(inode, nr);
9096 @@ -209,10 +222,14 @@ static inline int vfs_dq_reserve_space(s
9098 static inline int vfs_dq_alloc_inode(struct inode *inode)
9100 + if (dl_alloc_inode(inode))
9102 if (sb_any_quota_active(inode->i_sb)) {
9104 - if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
9105 + if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
9106 + dl_free_inode(inode);
9112 @@ -222,9 +239,13 @@ static inline int vfs_dq_alloc_inode(str
9114 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9116 + if (dl_claim_space(inode, nr))
9118 if (sb_any_quota_active(inode->i_sb)) {
9119 - if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
9120 + if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) {
9121 + dl_release_space(inode, nr);
9125 inode_claim_rsv_space(inode, nr);
9127 @@ -242,6 +263,7 @@ void vfs_dq_release_reservation_space(st
9128 inode->i_sb->dq_op->release_rsv(inode, nr);
9130 inode_sub_rsv_space(inode, nr);
9131 + dl_release_space(inode, nr);
9134 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9135 @@ -250,6 +272,7 @@ static inline void vfs_dq_free_space_nod
9136 inode->i_sb->dq_op->free_space(inode, nr);
9138 inode_sub_bytes(inode, nr);
9139 + dl_free_space(inode, nr);
9142 static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
9143 @@ -262,6 +285,7 @@ static inline void vfs_dq_free_inode(str
9145 if (sb_any_quota_active(inode->i_sb))
9146 inode->i_sb->dq_op->free_inode(inode, 1);
9147 + dl_free_inode(inode);
9150 /* Cannot be called inside a transaction */
9151 @@ -365,6 +389,8 @@ static inline int vfs_dq_transfer(struct
9153 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9155 + if (dl_alloc_space(inode, nr))
9157 inode_add_bytes(inode, nr);
9160 @@ -378,6 +404,8 @@ static inline int vfs_dq_prealloc_space(
9162 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9164 + if (dl_alloc_space(inode, nr))
9166 inode_add_bytes(inode, nr);
9169 @@ -391,22 +419,28 @@ static inline int vfs_dq_alloc_space(str
9171 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9173 + if (dl_reserve_space(inode, nr))
9178 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9180 + if (dl_claim_space(inode, nr))
9182 return vfs_dq_alloc_space(inode, nr);
9186 int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
9188 + dl_release_space(inode, nr);
9192 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9194 + dl_free_space(inode, nr);
9195 inode_sub_bytes(inode, nr);
9198 diff -NurpP --minimal linux-2.6.32.24/include/linux/reboot.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/reboot.h
9199 --- linux-2.6.32.24/include/linux/reboot.h 2008-12-25 00:26:37.000000000 +0100
9200 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/reboot.h 2009-12-03 22:06:59.000000000 +0100
9202 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9203 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9204 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9205 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9209 diff -NurpP --minimal linux-2.6.32.24/include/linux/reiserfs_fs.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/reiserfs_fs.h
9210 --- linux-2.6.32.24/include/linux/reiserfs_fs.h 2009-09-10 15:26:26.000000000 +0200
9211 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/reiserfs_fs.h 2009-12-03 20:04:56.000000000 +0100
9212 @@ -899,6 +899,11 @@ struct stat_data_v1 {
9213 #define REISERFS_COMPR_FL FS_COMPR_FL
9214 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9216 +/* unfortunately reiserfs sdattr is only 16 bit */
9217 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9218 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9219 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9221 /* persistent flags that file inherits from the parent directory */
9222 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9223 REISERFS_SYNC_FL | \
9224 @@ -908,6 +913,9 @@ struct stat_data_v1 {
9225 REISERFS_COMPR_FL | \
9226 REISERFS_NOTAIL_FL )
9228 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9229 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9231 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9234 @@ -1989,6 +1997,7 @@ static inline void reiserfs_update_sd(st
9235 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9236 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9237 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9238 +int reiserfs_sync_flags(struct inode *inode, int, int);
9241 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9242 diff -NurpP --minimal linux-2.6.32.24/include/linux/reiserfs_fs_sb.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/reiserfs_fs_sb.h
9243 --- linux-2.6.32.24/include/linux/reiserfs_fs_sb.h 2009-09-10 15:26:26.000000000 +0200
9244 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/reiserfs_fs_sb.h 2009-12-03 20:04:56.000000000 +0100
9245 @@ -456,6 +456,7 @@ enum reiserfs_mount_options {
9246 REISERFS_EXPOSE_PRIVROOT,
9247 REISERFS_BARRIER_NONE,
9248 REISERFS_BARRIER_FLUSH,
9251 /* Actions on error */
9252 REISERFS_ERROR_PANIC,
9253 diff -NurpP --minimal linux-2.6.32.24/include/linux/sched.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sched.h
9254 --- linux-2.6.32.24/include/linux/sched.h 2010-10-04 08:56:16.000000000 +0200
9255 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sched.h 2010-09-22 00:48:38.000000000 +0200
9256 @@ -389,25 +389,28 @@ extern void arch_unmap_area_topdown(stru
9257 * The mm counters are not protected by its page_table_lock,
9258 * so must be incremented atomically.
9260 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9261 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9262 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9263 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9264 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9265 +#define __set_mm_counter(mm, member, value) \
9266 + atomic_long_set(&(mm)->_##member, value)
9267 +#define get_mm_counter(mm, member) \
9268 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9270 #else /* !USE_SPLIT_PTLOCKS */
9272 * The mm counters are protected by its page_table_lock,
9273 * so can be incremented directly.
9275 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9276 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9277 #define get_mm_counter(mm, member) ((mm)->_##member)
9278 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9279 -#define inc_mm_counter(mm, member) (mm)->_##member++
9280 -#define dec_mm_counter(mm, member) (mm)->_##member--
9282 #endif /* !USE_SPLIT_PTLOCKS */
9284 +#define set_mm_counter(mm, member, value) \
9285 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9286 +#define add_mm_counter(mm, member, value) \
9287 + vx_ ## member ## pages_add((mm), (value))
9288 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9289 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9291 #define get_mm_rss(mm) \
9292 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9293 #define update_hiwater_rss(mm) do { \
9294 @@ -1192,6 +1195,12 @@ struct sched_entity {
9295 u64 nr_wakeups_affine_attempts;
9296 u64 nr_wakeups_passive;
9297 u64 nr_wakeups_idle;
9298 +#ifdef CONFIG_CFS_HARD_LIMITS
9299 + u64 throttle_start;
9301 + u64 throttle_count;
9306 #ifdef CONFIG_FAIR_GROUP_SCHED
9307 @@ -1402,6 +1411,14 @@ struct task_struct {
9311 +/* vserver context data */
9312 + struct vx_info *vx_info;
9313 + struct nx_info *nx_info;
9319 /* Thread group tracking */
9322 @@ -1626,6 +1643,11 @@ struct pid_namespace;
9323 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9324 struct pid_namespace *ns);
9326 +#include <linux/vserver/base.h>
9327 +#include <linux/vserver/context.h>
9328 +#include <linux/vserver/debug.h>
9329 +#include <linux/vserver/pid.h>
9331 static inline pid_t task_pid_nr(struct task_struct *tsk)
9334 @@ -1639,7 +1661,8 @@ static inline pid_t task_pid_nr_ns(struc
9336 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9338 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9339 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9340 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9344 @@ -1652,7 +1675,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9346 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9348 - return pid_vnr(task_tgid(tsk));
9349 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9353 diff -NurpP --minimal linux-2.6.32.24/include/linux/shmem_fs.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/shmem_fs.h
9354 --- linux-2.6.32.24/include/linux/shmem_fs.h 2009-12-03 20:02:56.000000000 +0100
9355 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/shmem_fs.h 2009-12-03 20:04:56.000000000 +0100
9358 #define SHMEM_NR_DIRECT 16
9360 +#define TMPFS_SUPER_MAGIC 0x01021994
9363 struct shmem_inode_info {
9365 unsigned long flags;
9366 diff -NurpP --minimal linux-2.6.32.24/include/linux/stat.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/stat.h
9367 --- linux-2.6.32.24/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9368 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/stat.h 2009-12-03 20:04:56.000000000 +0100
9369 @@ -66,6 +66,7 @@ struct kstat {
9376 struct timespec atime;
9377 diff -NurpP --minimal linux-2.6.32.24/include/linux/sunrpc/auth.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sunrpc/auth.h
9378 --- linux-2.6.32.24/include/linux/sunrpc/auth.h 2009-12-03 20:02:56.000000000 +0100
9379 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sunrpc/auth.h 2009-12-03 20:04:56.000000000 +0100
9385 struct group_info *group_info;
9386 unsigned char machine_cred : 1;
9388 diff -NurpP --minimal linux-2.6.32.24/include/linux/sunrpc/clnt.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sunrpc/clnt.h
9389 --- linux-2.6.32.24/include/linux/sunrpc/clnt.h 2009-12-03 20:02:56.000000000 +0100
9390 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sunrpc/clnt.h 2009-12-03 20:04:56.000000000 +0100
9391 @@ -49,7 +49,8 @@ struct rpc_clnt {
9392 unsigned int cl_softrtry : 1,/* soft timeouts */
9393 cl_discrtry : 1,/* disconnect before retry */
9394 cl_autobind : 1,/* use getport() */
9395 - cl_chatty : 1;/* be verbose */
9396 + cl_chatty : 1,/* be verbose */
9397 + cl_tag : 1;/* context tagging */
9399 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9400 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9401 diff -NurpP --minimal linux-2.6.32.24/include/linux/syscalls.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/syscalls.h
9402 --- linux-2.6.32.24/include/linux/syscalls.h 2010-10-04 08:56:16.000000000 +0200
9403 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/syscalls.h 2010-05-21 13:20:19.000000000 +0200
9404 @@ -548,6 +548,8 @@ asmlinkage long sys_symlink(const char _
9405 asmlinkage long sys_unlink(const char __user *pathname);
9406 asmlinkage long sys_rename(const char __user *oldname,
9407 const char __user *newname);
9408 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9410 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9411 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9413 diff -NurpP --minimal linux-2.6.32.24/include/linux/sysctl.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sysctl.h
9414 --- linux-2.6.32.24/include/linux/sysctl.h 2010-10-04 08:56:16.000000000 +0200
9415 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sysctl.h 2010-02-12 10:59:55.000000000 +0100
9416 @@ -69,6 +69,7 @@ enum
9417 CTL_ABI=9, /* Binary emulation */
9418 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9419 CTL_ARLAN=254, /* arlan wireless driver */
9420 + CTL_VSERVER=4242, /* Linux-VServer debug */
9421 CTL_S390DBF=5677, /* s390 debug */
9422 CTL_SUNRPC=7249, /* sunrpc debug */
9423 CTL_PM=9899, /* frv power management */
9424 @@ -103,6 +104,7 @@ enum
9426 KERN_PANIC=15, /* int: panic timeout */
9427 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9428 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9430 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9431 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9432 diff -NurpP --minimal linux-2.6.32.24/include/linux/sysfs.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sysfs.h
9433 --- linux-2.6.32.24/include/linux/sysfs.h 2008-12-25 00:26:37.000000000 +0100
9434 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/sysfs.h 2009-12-03 20:04:56.000000000 +0100
9436 #include <linux/list.h>
9437 #include <asm/atomic.h>
9439 +#define SYSFS_SUPER_MAGIC 0x62656572
9444 diff -NurpP --minimal linux-2.6.32.24/include/linux/time.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/time.h
9445 --- linux-2.6.32.24/include/linux/time.h 2010-10-04 08:56:16.000000000 +0200
9446 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/time.h 2010-02-12 10:59:55.000000000 +0100
9447 @@ -238,6 +238,9 @@ static __always_inline void timespec_add
9448 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9452 +#include <linux/vs_time.h>
9454 #endif /* __KERNEL__ */
9456 #define NFDBITS __NFDBITS
9457 diff -NurpP --minimal linux-2.6.32.24/include/linux/types.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/types.h
9458 --- linux-2.6.32.24/include/linux/types.h 2009-09-10 15:26:26.000000000 +0200
9459 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/types.h 2009-12-03 20:04:56.000000000 +0100
9460 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t uid_t;
9461 typedef __kernel_gid32_t gid_t;
9462 typedef __kernel_uid16_t uid16_t;
9463 typedef __kernel_gid16_t gid16_t;
9464 +typedef unsigned int xid_t;
9465 +typedef unsigned int nid_t;
9466 +typedef unsigned int tag_t;
9468 typedef unsigned long uintptr_t;
9470 diff -NurpP --minimal linux-2.6.32.24/include/linux/vroot.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vroot.h
9471 --- linux-2.6.32.24/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9472 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vroot.h 2009-12-03 20:04:56.000000000 +0100
9476 + * include/linux/vroot.h
9478 + * written by Herbert Pötzl, 9/11/2002
9479 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9481 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9482 + * Redistribution of this file is permitted under the
9483 + * GNU General Public License.
9486 +#ifndef _LINUX_VROOT_H
9487 +#define _LINUX_VROOT_H
9492 +/* Possible states of device */
9498 +struct vroot_device {
9502 + struct semaphore vr_ctl_mutex;
9503 + struct block_device *vr_device;
9508 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9510 +extern int register_vroot_grb(vroot_grb_func *);
9511 +extern int unregister_vroot_grb(vroot_grb_func *);
9513 +#endif /* __KERNEL__ */
9515 +#define MAX_VROOT_DEFAULT 8
9518 + * IOCTL commands --- we will commandeer 0x56 ('V')
9521 +#define VROOT_SET_DEV 0x5600
9522 +#define VROOT_CLR_DEV 0x5601
9524 +#endif /* _LINUX_VROOT_H */
9525 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_base.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_base.h
9526 --- linux-2.6.32.24/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9527 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_base.h 2009-12-03 20:04:56.000000000 +0100
9532 +#include "vserver/base.h"
9533 +#include "vserver/check.h"
9534 +#include "vserver/debug.h"
9537 +#warning duplicate inclusion
9539 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_context.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_context.h
9540 --- linux-2.6.32.24/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9541 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_context.h 2009-12-03 20:04:56.000000000 +0100
9543 +#ifndef _VS_CONTEXT_H
9544 +#define _VS_CONTEXT_H
9546 +#include "vserver/base.h"
9547 +#include "vserver/check.h"
9548 +#include "vserver/context.h"
9549 +#include "vserver/history.h"
9550 +#include "vserver/debug.h"
9552 +#include <linux/sched.h>
9555 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9557 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9558 + const char *_file, int _line, void *_here)
9563 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9564 + vxi, vxi ? vxi->vx_id : 0,
9565 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9567 + __vxh_get_vx_info(vxi, _here);
9569 + atomic_inc(&vxi->vx_usecnt);
9574 +extern void free_vx_info(struct vx_info *);
9576 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9578 +static inline void __put_vx_info(struct vx_info *vxi,
9579 + const char *_file, int _line, void *_here)
9584 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9585 + vxi, vxi ? vxi->vx_id : 0,
9586 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9588 + __vxh_put_vx_info(vxi, _here);
9590 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9591 + free_vx_info(vxi);
9595 +#define init_vx_info(p, i) \
9596 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9598 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9599 + const char *_file, int _line, void *_here)
9602 + vxlprintk(VXD_CBIT(xid, 3),
9603 + "init_vx_info(%p[#%d.%d])",
9604 + vxi, vxi ? vxi->vx_id : 0,
9605 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9607 + __vxh_init_vx_info(vxi, vxp, _here);
9609 + atomic_inc(&vxi->vx_usecnt);
9615 +#define set_vx_info(p, i) \
9616 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9618 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9619 + const char *_file, int _line, void *_here)
9621 + struct vx_info *vxo;
9626 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9627 + vxi, vxi ? vxi->vx_id : 0,
9628 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9630 + __vxh_set_vx_info(vxi, vxp, _here);
9632 + atomic_inc(&vxi->vx_usecnt);
9633 + vxo = xchg(vxp, vxi);
9638 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9640 +static inline void __clr_vx_info(struct vx_info **vxp,
9641 + const char *_file, int _line, void *_here)
9643 + struct vx_info *vxo;
9645 + vxo = xchg(vxp, NULL);
9649 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9650 + vxo, vxo ? vxo->vx_id : 0,
9651 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9653 + __vxh_clr_vx_info(vxo, vxp, _here);
9655 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9656 + free_vx_info(vxo);
9660 +#define claim_vx_info(v, p) \
9661 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9663 +static inline void __claim_vx_info(struct vx_info *vxi,
9664 + struct task_struct *task,
9665 + const char *_file, int _line, void *_here)
9667 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9668 + vxi, vxi ? vxi->vx_id : 0,
9669 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9670 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9671 + task, _file, _line);
9672 + __vxh_claim_vx_info(vxi, task, _here);
9674 + atomic_inc(&vxi->vx_tasks);
9678 +extern void unhash_vx_info(struct vx_info *);
9680 +#define release_vx_info(v, p) \
9681 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9683 +static inline void __release_vx_info(struct vx_info *vxi,
9684 + struct task_struct *task,
9685 + const char *_file, int _line, void *_here)
9687 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9688 + vxi, vxi ? vxi->vx_id : 0,
9689 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9690 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9691 + task, _file, _line);
9692 + __vxh_release_vx_info(vxi, task, _here);
9696 + if (atomic_dec_and_test(&vxi->vx_tasks))
9697 + unhash_vx_info(vxi);
9701 +#define task_get_vx_info(p) \
9702 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9704 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9705 + const char *_file, int _line, void *_here)
9707 + struct vx_info *vxi;
9710 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9712 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9718 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9720 + if (waitqueue_active(&vxi->vx_wait))
9721 + wake_up_interruptible(&vxi->vx_wait);
9725 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9727 +static inline void __enter_vx_info(struct vx_info *vxi,
9728 + struct vx_info_save *vxis, const char *_file, int _line)
9730 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9731 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9732 + current->xid, current->vx_info, _file, _line);
9733 + vxis->vxi = xchg(¤t->vx_info, vxi);
9734 + vxis->xid = current->xid;
9735 + current->xid = vxi ? vxi->vx_id : 0;
9738 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9740 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9741 + const char *_file, int _line)
9743 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9744 + vxis, vxis->xid, vxis->vxi, current,
9745 + current->xid, current->vx_info, _file, _line);
9746 + (void)xchg(¤t->vx_info, vxis->vxi);
9747 + current->xid = vxis->xid;
9751 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9753 + vxis->vxi = xchg(¤t->vx_info, NULL);
9754 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9757 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9759 + (void)xchg(¤t->xid, vxis->xid);
9760 + (void)xchg(¤t->vx_info, vxis->vxi);
9763 +#define task_is_init(p) \
9764 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9766 +static inline int __task_is_init(struct task_struct *p,
9767 + const char *_file, int _line, void *_here)
9769 + int is_init = is_global_init(p);
9773 + is_init = p->vx_info->vx_initpid == p->pid;
9778 +extern void exit_vx_info(struct task_struct *, int);
9779 +extern void exit_vx_info_early(struct task_struct *, int);
9783 +#warning duplicate inclusion
9785 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_cowbl.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_cowbl.h
9786 --- linux-2.6.32.24/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9787 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_cowbl.h 2009-12-03 20:04:56.000000000 +0100
9789 +#ifndef _VS_COWBL_H
9790 +#define _VS_COWBL_H
9792 +#include <linux/fs.h>
9793 +#include <linux/dcache.h>
9794 +#include <linux/namei.h>
9796 +extern struct dentry *cow_break_link(const char *pathname);
9798 +static inline int cow_check_and_break(struct path *path)
9800 + struct inode *inode = path->dentry->d_inode;
9803 + /* do we need this check? */
9804 + if (IS_RDONLY(inode))
9807 + if (IS_COW(inode)) {
9808 + if (IS_COW_LINK(inode)) {
9809 + struct dentry *new_dentry, *old_dentry = path->dentry;
9812 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9816 + pp = d_path(path, buf, PATH_MAX);
9817 + new_dentry = cow_break_link(pp);
9819 + if (!IS_ERR(new_dentry)) {
9820 + path->dentry = new_dentry;
9823 + error = PTR_ERR(new_dentry);
9825 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9826 + inode->i_ctime = CURRENT_TIME;
9827 + mark_inode_dirty(inode);
9834 +#warning duplicate inclusion
9836 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_cvirt.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_cvirt.h
9837 --- linux-2.6.32.24/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9838 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_cvirt.h 2009-12-03 20:04:56.000000000 +0100
9840 +#ifndef _VS_CVIRT_H
9841 +#define _VS_CVIRT_H
9843 +#include "vserver/cvirt.h"
9844 +#include "vserver/context.h"
9845 +#include "vserver/base.h"
9846 +#include "vserver/check.h"
9847 +#include "vserver/debug.h"
9850 +static inline void vx_activate_task(struct task_struct *p)
9852 + struct vx_info *vxi;
9854 + if ((vxi = p->vx_info)) {
9855 + vx_update_load(vxi);
9856 + atomic_inc(&vxi->cvirt.nr_running);
9860 +static inline void vx_deactivate_task(struct task_struct *p)
9862 + struct vx_info *vxi;
9864 + if ((vxi = p->vx_info)) {
9865 + vx_update_load(vxi);
9866 + atomic_dec(&vxi->cvirt.nr_running);
9870 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9872 + struct vx_info *vxi;
9874 + if ((vxi = p->vx_info))
9875 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9878 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9880 + struct vx_info *vxi;
9882 + if ((vxi = p->vx_info))
9883 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9888 +#warning duplicate inclusion
9890 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_device.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_device.h
9891 --- linux-2.6.32.24/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9892 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_device.h 2009-12-03 20:04:56.000000000 +0100
9894 +#ifndef _VS_DEVICE_H
9895 +#define _VS_DEVICE_H
9897 +#include "vserver/base.h"
9898 +#include "vserver/device.h"
9899 +#include "vserver/debug.h"
9902 +#ifdef CONFIG_VSERVER_DEVICE
9904 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9906 +#define vs_device_perm(v, d, m, p) \
9907 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9912 +int vs_map_device(struct vx_info *vxi,
9913 + dev_t device, dev_t *target, umode_t mode)
9920 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9925 +#define vs_map_chrdev(d, t, p) \
9926 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9927 +#define vs_map_blkdev(d, t, p) \
9928 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9930 +#define vs_chrdev_perm(d, p) \
9931 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9932 +#define vs_blkdev_perm(d, p) \
9933 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9937 +#warning duplicate inclusion
9939 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_dlimit.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_dlimit.h
9940 --- linux-2.6.32.24/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9941 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_dlimit.h 2010-03-21 06:19:38.000000000 +0100
9943 +#ifndef _VS_DLIMIT_H
9944 +#define _VS_DLIMIT_H
9946 +#include <linux/fs.h>
9948 +#include "vserver/dlimit.h"
9949 +#include "vserver/base.h"
9950 +#include "vserver/debug.h"
9953 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9955 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9956 + const char *_file, int _line)
9960 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9961 + dli, dli ? dli->dl_tag : 0,
9962 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9964 + atomic_inc(&dli->dl_usecnt);
9969 +#define free_dl_info(i) \
9970 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9972 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9974 +static inline void __put_dl_info(struct dl_info *dli,
9975 + const char *_file, int _line)
9979 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9980 + dli, dli ? dli->dl_tag : 0,
9981 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9983 + if (atomic_dec_and_test(&dli->dl_usecnt))
9984 + free_dl_info(dli);
9988 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9990 +static inline int __dl_alloc_space(struct super_block *sb,
9991 + tag_t tag, dlsize_t nr, const char *file, int line)
9993 + struct dl_info *dli = NULL;
9998 + dli = locate_dl_info(sb, tag);
10002 + spin_lock(&dli->dl_lock);
10003 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
10005 + dli->dl_space_used += nr;
10006 + spin_unlock(&dli->dl_lock);
10007 + put_dl_info(dli);
10009 + vxlprintk(VXD_CBIT(dlim, 1),
10010 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
10011 + sb, tag, __dlimit_char(dli), (long long)nr,
10012 + ret, file, line);
10016 +static inline void __dl_free_space(struct super_block *sb,
10017 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10019 + struct dl_info *dli = NULL;
10023 + dli = locate_dl_info(sb, tag);
10027 + spin_lock(&dli->dl_lock);
10028 + if (dli->dl_space_used > nr)
10029 + dli->dl_space_used -= nr;
10031 + dli->dl_space_used = 0;
10032 + spin_unlock(&dli->dl_lock);
10033 + put_dl_info(dli);
10035 + vxlprintk(VXD_CBIT(dlim, 1),
10036 + "FREE (%p,#%d)%c %lld bytes",
10037 + sb, tag, __dlimit_char(dli), (long long)nr,
10041 +static inline int __dl_alloc_inode(struct super_block *sb,
10042 + tag_t tag, const char *_file, int _line)
10044 + struct dl_info *dli;
10047 + dli = locate_dl_info(sb, tag);
10051 + spin_lock(&dli->dl_lock);
10052 + dli->dl_inodes_used++;
10053 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
10054 + spin_unlock(&dli->dl_lock);
10055 + put_dl_info(dli);
10057 + vxlprintk(VXD_CBIT(dlim, 0),
10058 + "ALLOC (%p,#%d)%c inode (%d)",
10059 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10063 +static inline void __dl_free_inode(struct super_block *sb,
10064 + tag_t tag, const char *_file, int _line)
10066 + struct dl_info *dli;
10068 + dli = locate_dl_info(sb, tag);
10072 + spin_lock(&dli->dl_lock);
10073 + if (dli->dl_inodes_used > 1)
10074 + dli->dl_inodes_used--;
10076 + dli->dl_inodes_used = 0;
10077 + spin_unlock(&dli->dl_lock);
10078 + put_dl_info(dli);
10080 + vxlprintk(VXD_CBIT(dlim, 0),
10081 + "FREE (%p,#%d)%c inode",
10082 + sb, tag, __dlimit_char(dli), _file, _line);
10085 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10086 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10087 + const char *_file, int _line)
10089 + struct dl_info *dli;
10090 + uint64_t broot, bfree;
10092 + dli = locate_dl_info(sb, tag);
10096 + spin_lock(&dli->dl_lock);
10097 + broot = (dli->dl_space_total -
10098 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10099 + >> sb->s_blocksize_bits;
10100 + bfree = (dli->dl_space_total - dli->dl_space_used)
10101 + >> sb->s_blocksize_bits;
10102 + spin_unlock(&dli->dl_lock);
10104 + vxlprintk(VXD_CBIT(dlim, 2),
10105 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10106 + (long long)bfree, (long long)broot,
10107 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10109 + if (free_blocks) {
10110 + if (*free_blocks > bfree)
10111 + *free_blocks = bfree;
10113 + if (root_blocks) {
10114 + if (*root_blocks > broot)
10115 + *root_blocks = broot;
10117 + put_dl_info(dli);
10120 +#define dl_prealloc_space(in, bytes) \
10121 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10122 + __FILE__, __LINE__ )
10124 +#define dl_alloc_space(in, bytes) \
10125 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10126 + __FILE__, __LINE__ )
10128 +#define dl_reserve_space(in, bytes) \
10129 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10130 + __FILE__, __LINE__ )
10132 +#define dl_claim_space(in, bytes) (0)
10134 +#define dl_release_space(in, bytes) \
10135 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10136 + __FILE__, __LINE__ )
10138 +#define dl_free_space(in, bytes) \
10139 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10140 + __FILE__, __LINE__ )
10144 +#define dl_alloc_inode(in) \
10145 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10147 +#define dl_free_inode(in) \
10148 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10151 +#define dl_adjust_block(sb, tag, fb, rb) \
10152 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10156 +#warning duplicate inclusion
10158 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/base.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/base.h
10159 --- linux-2.6.32.24/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10160 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/base.h 2009-12-03 20:04:56.000000000 +0100
10162 +#ifndef _VX_BASE_H
10163 +#define _VX_BASE_H
10166 +/* context state changes */
10178 +#define vx_task_xid(t) ((t)->xid)
10180 +#define vx_current_xid() vx_task_xid(current)
10182 +#define current_vx_info() (current->vx_info)
10185 +#define nx_task_nid(t) ((t)->nid)
10187 +#define nx_current_nid() nx_task_nid(current)
10189 +#define current_nx_info() (current->nx_info)
10192 +/* generic flag merging */
10194 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10196 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10198 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10200 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10203 +/* context flags */
10205 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10207 +#define vx_current_flags() __vx_flags(current_vx_info())
10209 +#define vx_info_flags(v, m, f) \
10210 + vs_check_flags(__vx_flags(v), m, f)
10212 +#define task_vx_flags(t, m, f) \
10213 + ((t) && vx_info_flags((t)->vx_info, m, f))
10215 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10218 +/* context caps */
10220 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10222 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10224 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10226 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10230 +/* network flags */
10232 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10234 +#define nx_current_flags() __nx_flags(current_nx_info())
10236 +#define nx_info_flags(n, m, f) \
10237 + vs_check_flags(__nx_flags(n), m, f)
10239 +#define task_nx_flags(t, m, f) \
10240 + ((t) && nx_info_flags((t)->nx_info, m, f))
10242 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10245 +/* network caps */
10247 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10249 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10251 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10253 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10256 +/* context mask capabilities */
10258 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10260 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10262 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10265 +/* context bcap mask */
10267 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10269 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10272 +/* mask given bcaps */
10274 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10276 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10279 +/* masked cap_bset */
10281 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10283 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10286 +#define vx_info_mbcap(v, b) \
10287 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10288 + vx_info_bcaps(v, b) : (b))
10290 +#define task_vx_mbcap(t, b) \
10291 + vx_info_mbcap((t)->vx_info, (t)->b)
10293 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10296 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10298 +#define vx_capable(b, c) (capable(b) || \
10299 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10301 +#define nx_capable(b, c) (capable(b) || \
10302 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10304 +#define vx_task_initpid(t, n) \
10305 + ((t)->vx_info && \
10306 + ((t)->vx_info->vx_initpid == (n)))
10308 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10311 +/* context unshare mask */
10313 +#define __vx_umask(v) ((v)->vx_umask)
10315 +#define vx_current_umask() __vx_umask(current_vx_info())
10317 +#define vx_can_unshare(b, f) (capable(b) || \
10318 + (cap_raised(current_cap(), b) && \
10319 + !((f) & ~vx_current_umask())))
10322 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10324 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10327 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10329 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10332 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/cacct_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cacct_cmd.h
10333 --- linux-2.6.32.24/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10334 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cacct_cmd.h 2009-12-03 20:04:56.000000000 +0100
10336 +#ifndef _VX_CACCT_CMD_H
10337 +#define _VX_CACCT_CMD_H
10340 +/* virtual host info name commands */
10342 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10344 +struct vcmd_sock_stat_v0 {
10346 + uint32_t count[3];
10347 + uint64_t total[3];
10353 +#include <linux/compiler.h>
10355 +extern int vc_sock_stat(struct vx_info *, void __user *);
10357 +#endif /* __KERNEL__ */
10358 +#endif /* _VX_CACCT_CMD_H */
10359 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/cacct_def.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cacct_def.h
10360 --- linux-2.6.32.24/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10361 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cacct_def.h 2009-12-03 20:04:56.000000000 +0100
10363 +#ifndef _VX_CACCT_DEF_H
10364 +#define _VX_CACCT_DEF_H
10366 +#include <asm/atomic.h>
10367 +#include <linux/vserver/cacct.h>
10370 +struct _vx_sock_acc {
10371 + atomic_long_t count;
10372 + atomic_long_t total;
10375 +/* context sub struct */
10377 +struct _vx_cacct {
10378 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10379 + atomic_t slab[8];
10380 + atomic_t page[6][8];
10383 +#ifdef CONFIG_VSERVER_DEBUG
10385 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10389 + printk("\t_vx_cacct:");
10390 + for (i = 0; i < 6; i++) {
10391 + struct _vx_sock_acc *ptr = cacct->sock[i];
10393 + printk("\t [%d] =", i);
10394 + for (j = 0; j < 3; j++) {
10395 + printk(" [%d] = %8lu, %8lu", j,
10396 + atomic_long_read(&ptr[j].count),
10397 + atomic_long_read(&ptr[j].total));
10405 +#endif /* _VX_CACCT_DEF_H */
10406 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/cacct.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cacct.h
10407 --- linux-2.6.32.24/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10408 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cacct.h 2009-12-03 20:04:56.000000000 +0100
10410 +#ifndef _VX_CACCT_H
10411 +#define _VX_CACCT_H
10414 +enum sock_acc_field {
10415 + VXA_SOCK_UNSPEC = 0,
10421 + VXA_SOCK_SIZE /* array size */
10424 +#endif /* _VX_CACCT_H */
10425 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/cacct_int.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cacct_int.h
10426 --- linux-2.6.32.24/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10427 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cacct_int.h 2009-12-03 20:04:56.000000000 +0100
10429 +#ifndef _VX_CACCT_INT_H
10430 +#define _VX_CACCT_INT_H
10436 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10438 + return atomic_long_read(&cacct->sock[type][pos].count);
10443 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10445 + return atomic_long_read(&cacct->sock[type][pos].total);
10448 +#endif /* __KERNEL__ */
10449 +#endif /* _VX_CACCT_INT_H */
10450 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/check.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/check.h
10451 --- linux-2.6.32.24/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10452 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/check.h 2009-12-03 20:04:56.000000000 +0100
10454 +#ifndef _VS_CHECK_H
10455 +#define _VS_CHECK_H
10458 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10460 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10461 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10463 +#define MIN_D_CONTEXT 65536
10466 +/* check conditions */
10468 +#define VS_ADMIN 0x0001
10469 +#define VS_WATCH 0x0002
10470 +#define VS_HIDE 0x0004
10471 +#define VS_HOSTID 0x0008
10473 +#define VS_IDENT 0x0010
10474 +#define VS_EQUIV 0x0020
10475 +#define VS_PARENT 0x0040
10476 +#define VS_CHILD 0x0080
10478 +#define VS_ARG_MASK 0x00F0
10480 +#define VS_DYNAMIC 0x0100
10481 +#define VS_STATIC 0x0200
10483 +#define VS_ATR_MASK 0x0F00
10485 +#ifdef CONFIG_VSERVER_PRIVACY
10486 +#define VS_ADMIN_P (0)
10487 +#define VS_WATCH_P (0)
10489 +#define VS_ADMIN_P VS_ADMIN
10490 +#define VS_WATCH_P VS_WATCH
10493 +#define VS_HARDIRQ 0x1000
10494 +#define VS_SOFTIRQ 0x2000
10495 +#define VS_IRQ 0x4000
10497 +#define VS_IRQ_MASK 0xF000
10499 +#include <linux/hardirq.h>
10502 + * check current context for ADMIN/WATCH and
10503 + * optionally against supplied argument
10505 +static inline int __vs_check(int cid, int id, unsigned int mode)
10507 + if (mode & VS_ARG_MASK) {
10508 + if ((mode & VS_IDENT) && (id == cid))
10511 + if (mode & VS_ATR_MASK) {
10512 + if ((mode & VS_DYNAMIC) &&
10513 + (id >= MIN_D_CONTEXT) &&
10514 + (id <= MAX_S_CONTEXT))
10516 + if ((mode & VS_STATIC) &&
10517 + (id > 1) && (id < MIN_D_CONTEXT))
10520 + if (mode & VS_IRQ_MASK) {
10521 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10523 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10525 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10528 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10529 + ((mode & VS_WATCH) && (cid == 1)) ||
10530 + ((mode & VS_HOSTID) && (id == 0)));
10533 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10535 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10538 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10540 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10543 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/context_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/context_cmd.h
10544 --- linux-2.6.32.24/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10545 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/context_cmd.h 2009-12-03 20:04:56.000000000 +0100
10547 +#ifndef _VX_CONTEXT_CMD_H
10548 +#define _VX_CONTEXT_CMD_H
10551 +/* vinfo commands */
10553 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10556 +extern int vc_task_xid(uint32_t);
10558 +#endif /* __KERNEL__ */
10560 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10562 +struct vcmd_vx_info_v0 {
10564 + uint32_t initpid;
10565 + /* more to come */
10569 +extern int vc_vx_info(struct vx_info *, void __user *);
10571 +#endif /* __KERNEL__ */
10573 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10575 +struct vcmd_ctx_stat_v0 {
10578 + /* more to come */
10582 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10584 +#endif /* __KERNEL__ */
10586 +/* context commands */
10588 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10589 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10591 +struct vcmd_ctx_create {
10592 + uint64_t flagword;
10595 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10596 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10598 +struct vcmd_ctx_migrate {
10599 + uint64_t flagword;
10603 +extern int vc_ctx_create(uint32_t, void __user *);
10604 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10606 +#endif /* __KERNEL__ */
10609 +/* flag commands */
10611 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10612 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10614 +struct vcmd_ctx_flags_v0 {
10615 + uint64_t flagword;
10620 +extern int vc_get_cflags(struct vx_info *, void __user *);
10621 +extern int vc_set_cflags(struct vx_info *, void __user *);
10623 +#endif /* __KERNEL__ */
10626 +/* context caps commands */
10628 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10629 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10631 +struct vcmd_ctx_caps_v1 {
10637 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10638 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10640 +#endif /* __KERNEL__ */
10643 +/* bcaps commands */
10645 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10646 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10648 +struct vcmd_bcaps {
10654 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10655 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10657 +#endif /* __KERNEL__ */
10660 +/* umask commands */
10662 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
10663 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
10665 +struct vcmd_umask {
10671 +extern int vc_get_umask(struct vx_info *, void __user *);
10672 +extern int vc_set_umask(struct vx_info *, void __user *);
10674 +#endif /* __KERNEL__ */
10679 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10680 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10682 +struct vcmd_badness_v0 {
10687 +extern int vc_get_badness(struct vx_info *, void __user *);
10688 +extern int vc_set_badness(struct vx_info *, void __user *);
10690 +#endif /* __KERNEL__ */
10691 +#endif /* _VX_CONTEXT_CMD_H */
10692 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/context.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/context.h
10693 --- linux-2.6.32.24/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10694 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/context.h 2010-03-13 21:50:00.000000000 +0100
10696 +#ifndef _VX_CONTEXT_H
10697 +#define _VX_CONTEXT_H
10699 +#include <linux/types.h>
10700 +#include <linux/capability.h>
10703 +/* context flags */
10705 +#define VXF_INFO_SCHED 0x00000002
10706 +#define VXF_INFO_NPROC 0x00000004
10707 +#define VXF_INFO_PRIVATE 0x00000008
10709 +#define VXF_INFO_INIT 0x00000010
10710 +#define VXF_INFO_HIDE 0x00000020
10711 +#define VXF_INFO_ULIMIT 0x00000040
10712 +#define VXF_INFO_NSPACE 0x00000080
10714 +#define VXF_SCHED_HARD 0x00000100
10715 +#define VXF_SCHED_PRIO 0x00000200
10716 +#define VXF_SCHED_PAUSE 0x00000400
10718 +#define VXF_VIRT_MEM 0x00010000
10719 +#define VXF_VIRT_UPTIME 0x00020000
10720 +#define VXF_VIRT_CPU 0x00040000
10721 +#define VXF_VIRT_LOAD 0x00080000
10722 +#define VXF_VIRT_TIME 0x00100000
10724 +#define VXF_HIDE_MOUNT 0x01000000
10725 +/* was VXF_HIDE_NETIF 0x02000000 */
10726 +#define VXF_HIDE_VINFO 0x04000000
10728 +#define VXF_STATE_SETUP (1ULL << 32)
10729 +#define VXF_STATE_INIT (1ULL << 33)
10730 +#define VXF_STATE_ADMIN (1ULL << 34)
10732 +#define VXF_SC_HELPER (1ULL << 36)
10733 +#define VXF_REBOOT_KILL (1ULL << 37)
10734 +#define VXF_PERSISTENT (1ULL << 38)
10736 +#define VXF_FORK_RSS (1ULL << 48)
10737 +#define VXF_PROLIFIC (1ULL << 49)
10739 +#define VXF_IGNEG_NICE (1ULL << 52)
10741 +#define VXF_ONE_TIME (0x0007ULL << 32)
10743 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10746 +/* context migration */
10748 +#define VXM_SET_INIT 0x00000001
10749 +#define VXM_SET_REAPER 0x00000002
10751 +/* context caps */
10753 +#define VXC_CAP_MASK 0x00000000
10755 +#define VXC_SET_UTSNAME 0x00000001
10756 +#define VXC_SET_RLIMIT 0x00000002
10757 +#define VXC_FS_SECURITY 0x00000004
10758 +#define VXC_FS_TRUSTED 0x00000008
10759 +#define VXC_TIOCSTI 0x00000010
10761 +/* was VXC_RAW_ICMP 0x00000100 */
10762 +#define VXC_SYSLOG 0x00001000
10763 +#define VXC_OOM_ADJUST 0x00002000
10764 +#define VXC_AUDIT_CONTROL 0x00004000
10766 +#define VXC_SECURE_MOUNT 0x00010000
10767 +#define VXC_SECURE_REMOUNT 0x00020000
10768 +#define VXC_BINARY_MOUNT 0x00040000
10770 +#define VXC_QUOTA_CTL 0x00100000
10771 +#define VXC_ADMIN_MAPPER 0x00200000
10772 +#define VXC_ADMIN_CLOOP 0x00400000
10774 +#define VXC_KTHREAD 0x01000000
10775 +#define VXC_NAMESPACE 0x02000000
10780 +#include <linux/list.h>
10781 +#include <linux/spinlock.h>
10782 +#include <linux/rcupdate.h>
10784 +#include "limit_def.h"
10785 +#include "sched_def.h"
10786 +#include "cvirt_def.h"
10787 +#include "cacct_def.h"
10788 +#include "device_def.h"
10790 +#define VX_SPACES 2
10792 +struct _vx_info_pc {
10793 + struct _vx_sched_pc sched_pc;
10794 + struct _vx_cvirt_pc cvirt_pc;
10798 + struct hlist_node vx_hlist; /* linked list of contexts */
10799 + xid_t vx_id; /* context id */
10800 + atomic_t vx_usecnt; /* usage count */
10801 + atomic_t vx_tasks; /* tasks count */
10802 + struct vx_info *vx_parent; /* parent context */
10803 + int vx_state; /* context state */
10805 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
10806 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
10807 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
10809 + uint64_t vx_flags; /* context flags */
10810 + uint64_t vx_ccaps; /* context caps (vserver) */
10811 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10812 + unsigned long vx_umask; /* unshare mask (guest) */
10814 + struct task_struct *vx_reaper; /* guest reaper process */
10815 + pid_t vx_initpid; /* PID of guest init */
10816 + int64_t vx_badness_bias; /* OOM points bias */
10818 + struct _vx_limit limit; /* vserver limits */
10819 + struct _vx_sched sched; /* vserver scheduler */
10820 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10821 + struct _vx_cacct cacct; /* context accounting */
10823 + struct _vx_device dmap; /* default device map targets */
10825 +#ifndef CONFIG_SMP
10826 + struct _vx_info_pc info_pc; /* per cpu data */
10828 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10831 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10832 + int reboot_cmd; /* last sys_reboot() cmd */
10833 + int exit_code; /* last process exit code */
10835 + char vx_name[65]; /* vserver name */
10838 +#ifndef CONFIG_SMP
10839 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10840 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10842 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10843 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10846 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10849 +struct vx_info_save {
10850 + struct vx_info *vxi;
10855 +/* status flags */
10857 +#define VXS_HASHED 0x0001
10858 +#define VXS_PAUSED 0x0010
10859 +#define VXS_SHUTDOWN 0x0100
10860 +#define VXS_HELPER 0x1000
10861 +#define VXS_RELEASED 0x8000
10864 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10865 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10867 +extern struct vx_info *lookup_vx_info(int);
10868 +extern struct vx_info *lookup_or_create_vx_info(int);
10870 +extern int get_xid_list(int, unsigned int *, int);
10871 +extern int xid_is_hashed(xid_t);
10873 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10875 +extern long vs_state_change(struct vx_info *, unsigned int);
10878 +#endif /* __KERNEL__ */
10879 +#endif /* _VX_CONTEXT_H */
10880 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/cvirt_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cvirt_cmd.h
10881 --- linux-2.6.32.24/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
10882 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cvirt_cmd.h 2009-12-03 20:04:56.000000000 +0100
10884 +#ifndef _VX_CVIRT_CMD_H
10885 +#define _VX_CVIRT_CMD_H
10888 +/* virtual host info name commands */
10890 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
10891 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
10893 +struct vcmd_vhi_name_v0 {
10899 +enum vhi_name_field {
10900 + VHIN_CONTEXT = 0,
10912 +#include <linux/compiler.h>
10914 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10915 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10917 +#endif /* __KERNEL__ */
10919 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
10921 +struct vcmd_virt_stat_v0 {
10924 + uint32_t nr_threads;
10925 + uint32_t nr_running;
10926 + uint32_t nr_uninterruptible;
10927 + uint32_t nr_onhold;
10928 + uint32_t nr_forks;
10929 + uint32_t load[3];
10933 +extern int vc_virt_stat(struct vx_info *, void __user *);
10935 +#endif /* __KERNEL__ */
10936 +#endif /* _VX_CVIRT_CMD_H */
10937 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/cvirt_def.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cvirt_def.h
10938 --- linux-2.6.32.24/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
10939 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cvirt_def.h 2009-12-03 20:04:56.000000000 +0100
10941 +#ifndef _VX_CVIRT_DEF_H
10942 +#define _VX_CVIRT_DEF_H
10944 +#include <linux/jiffies.h>
10945 +#include <linux/spinlock.h>
10946 +#include <linux/wait.h>
10947 +#include <linux/time.h>
10948 +#include <asm/atomic.h>
10951 +struct _vx_usage_stat {
10955 + uint64_t softirq;
10961 +struct _vx_syslog {
10962 + wait_queue_head_t log_wait;
10963 + spinlock_t logbuf_lock; /* lock for the log buffer */
10965 + unsigned long log_start; /* next char to be read by syslog() */
10966 + unsigned long con_start; /* next char to be sent to consoles */
10967 + unsigned long log_end; /* most-recently-written-char + 1 */
10968 + unsigned long logged_chars; /* #chars since last read+clear operation */
10970 + char log_buf[1024];
10974 +/* context sub struct */
10976 +struct _vx_cvirt {
10977 + atomic_t nr_threads; /* number of current threads */
10978 + atomic_t nr_running; /* number of running threads */
10979 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10981 + atomic_t nr_onhold; /* processes on hold */
10982 + uint32_t onhold_last; /* jiffies when put on hold */
10984 + struct timeval bias_tv; /* time offset to the host */
10985 + struct timespec bias_idle;
10986 + struct timespec bias_uptime; /* context creation point */
10987 + uint64_t bias_clock; /* offset in clock_t */
10989 + spinlock_t load_lock; /* lock for the load averages */
10990 + atomic_t load_updates; /* nr of load updates done so far */
10991 + uint32_t load_last; /* last time load was calculated */
10992 + uint32_t load[3]; /* load averages 1,5,15 */
10994 + atomic_t total_forks; /* number of forks so far */
10996 + struct _vx_syslog syslog;
10999 +struct _vx_cvirt_pc {
11000 + struct _vx_usage_stat cpustat;
11004 +#ifdef CONFIG_VSERVER_DEBUG
11006 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11008 + printk("\t_vx_cvirt:\n");
11009 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11010 + atomic_read(&cvirt->nr_threads),
11011 + atomic_read(&cvirt->nr_running),
11012 + atomic_read(&cvirt->nr_uninterruptible),
11013 + atomic_read(&cvirt->nr_onhold));
11014 + /* add rest here */
11015 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11020 +#endif /* _VX_CVIRT_DEF_H */
11021 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/cvirt.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cvirt.h
11022 --- linux-2.6.32.24/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11023 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/cvirt.h 2009-12-03 20:04:56.000000000 +0100
11025 +#ifndef _VX_CVIRT_H
11026 +#define _VX_CVIRT_H
11033 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11038 +void vx_update_load(struct vx_info *);
11041 +int vx_do_syslog(int, char __user *, int);
11043 +#endif /* __KERNEL__ */
11044 +#endif /* _VX_CVIRT_H */
11045 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/debug_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/debug_cmd.h
11046 --- linux-2.6.32.24/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11047 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/debug_cmd.h 2009-12-03 20:04:56.000000000 +0100
11049 +#ifndef _VX_DEBUG_CMD_H
11050 +#define _VX_DEBUG_CMD_H
11053 +/* debug commands */
11055 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11057 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11058 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11060 +struct vcmd_read_history_v0 {
11063 + char __user *data;
11066 +struct vcmd_read_monitor_v0 {
11069 + char __user *data;
11075 +#ifdef CONFIG_COMPAT
11077 +#include <asm/compat.h>
11079 +struct vcmd_read_history_v0_x32 {
11082 + compat_uptr_t data_ptr;
11085 +struct vcmd_read_monitor_v0_x32 {
11088 + compat_uptr_t data_ptr;
11091 +#endif /* CONFIG_COMPAT */
11093 +extern int vc_dump_history(uint32_t);
11095 +extern int vc_read_history(uint32_t, void __user *);
11096 +extern int vc_read_monitor(uint32_t, void __user *);
11098 +#ifdef CONFIG_COMPAT
11100 +extern int vc_read_history_x32(uint32_t, void __user *);
11101 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11103 +#endif /* CONFIG_COMPAT */
11105 +#endif /* __KERNEL__ */
11106 +#endif /* _VX_DEBUG_CMD_H */
11107 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/debug.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/debug.h
11108 --- linux-2.6.32.24/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11109 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/debug.h 2009-12-03 20:04:56.000000000 +0100
11111 +#ifndef _VX_DEBUG_H
11112 +#define _VX_DEBUG_H
11115 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11116 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11117 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11119 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11120 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11121 +#define VXF_DEV "%p[%lu,%d:%d]"
11124 +#define vxd_path(p) \
11125 + ({ static char _buffer[PATH_MAX]; \
11126 + d_path(p, _buffer, sizeof(_buffer)); })
11128 +#define vxd_cond_path(n) \
11129 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11132 +#ifdef CONFIG_VSERVER_DEBUG
11134 +extern unsigned int vx_debug_switch;
11135 +extern unsigned int vx_debug_xid;
11136 +extern unsigned int vx_debug_nid;
11137 +extern unsigned int vx_debug_tag;
11138 +extern unsigned int vx_debug_net;
11139 +extern unsigned int vx_debug_limit;
11140 +extern unsigned int vx_debug_cres;
11141 +extern unsigned int vx_debug_dlim;
11142 +extern unsigned int vx_debug_quota;
11143 +extern unsigned int vx_debug_cvirt;
11144 +extern unsigned int vx_debug_space;
11145 +extern unsigned int vx_debug_misc;
11148 +#define VX_LOGLEVEL "vxD: "
11149 +#define VX_PROC_FMT "%p: "
11150 +#define VX_PROCESS current
11152 +#define vxdprintk(c, f, x...) \
11155 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11156 + VX_PROCESS , ##x); \
11159 +#define vxlprintk(c, f, x...) \
11162 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11165 +#define vxfprintk(c, f, x...) \
11168 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11174 +void dump_vx_info(struct vx_info *, int);
11175 +void dump_vx_info_inactive(int);
11177 +#else /* CONFIG_VSERVER_DEBUG */
11179 +#define vx_debug_switch 0
11180 +#define vx_debug_xid 0
11181 +#define vx_debug_nid 0
11182 +#define vx_debug_tag 0
11183 +#define vx_debug_net 0
11184 +#define vx_debug_limit 0
11185 +#define vx_debug_cres 0
11186 +#define vx_debug_dlim 0
11187 +#define vx_debug_cvirt 0
11189 +#define vxdprintk(x...) do { } while (0)
11190 +#define vxlprintk(x...) do { } while (0)
11191 +#define vxfprintk(x...) do { } while (0)
11193 +#endif /* CONFIG_VSERVER_DEBUG */
11196 +#ifdef CONFIG_VSERVER_WARN
11198 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11199 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11200 +#define VX_WARN_XID "[xid #%u] "
11201 +#define VX_WARN_NID "[nid #%u] "
11202 +#define VX_WARN_TAG "[tag #%u] "
11204 +#define vxwprintk(c, f, x...) \
11207 + printk(VX_WARNLEVEL f "\n", ##x); \
11210 +#else /* CONFIG_VSERVER_WARN */
11212 +#define vxwprintk(x...) do { } while (0)
11214 +#endif /* CONFIG_VSERVER_WARN */
11216 +#define vxwprintk_task(c, f, x...) \
11217 + vxwprintk(c, VX_WARN_TASK f, \
11218 + current->comm, current->pid, \
11219 + current->xid, current->nid, current->tag, ##x)
11220 +#define vxwprintk_xid(c, f, x...) \
11221 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11222 +#define vxwprintk_nid(c, f, x...) \
11223 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11224 +#define vxwprintk_tag(c, f, x...) \
11225 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11227 +#ifdef CONFIG_VSERVER_DEBUG
11228 +#define vxd_assert_lock(l) assert_spin_locked(l)
11229 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11230 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11232 +#define vxd_assert_lock(l) do { } while (0)
11233 +#define vxd_assert(c, f, x...) do { } while (0)
11237 +#endif /* _VX_DEBUG_H */
11238 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/device_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/device_cmd.h
11239 --- linux-2.6.32.24/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11240 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/device_cmd.h 2009-12-03 20:04:56.000000000 +0100
11242 +#ifndef _VX_DEVICE_CMD_H
11243 +#define _VX_DEVICE_CMD_H
11246 +/* device vserver commands */
11248 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11249 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11251 +struct vcmd_set_mapping_v0 {
11252 + const char __user *device;
11253 + const char __user *target;
11260 +#ifdef CONFIG_COMPAT
11262 +#include <asm/compat.h>
11264 +struct vcmd_set_mapping_v0_x32 {
11265 + compat_uptr_t device_ptr;
11266 + compat_uptr_t target_ptr;
11270 +#endif /* CONFIG_COMPAT */
11272 +#include <linux/compiler.h>
11274 +extern int vc_set_mapping(struct vx_info *, void __user *);
11275 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11277 +#ifdef CONFIG_COMPAT
11279 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11280 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11282 +#endif /* CONFIG_COMPAT */
11284 +#endif /* __KERNEL__ */
11285 +#endif /* _VX_DEVICE_CMD_H */
11286 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/device_def.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/device_def.h
11287 --- linux-2.6.32.24/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11288 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/device_def.h 2009-12-03 20:04:56.000000000 +0100
11290 +#ifndef _VX_DEVICE_DEF_H
11291 +#define _VX_DEVICE_DEF_H
11293 +#include <linux/types.h>
11295 +struct vx_dmap_target {
11300 +struct _vx_device {
11301 +#ifdef CONFIG_VSERVER_DEVICE
11302 + struct vx_dmap_target targets[2];
11306 +#endif /* _VX_DEVICE_DEF_H */
11307 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/device.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/device.h
11308 --- linux-2.6.32.24/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11309 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/device.h 2009-12-03 20:04:56.000000000 +0100
11311 +#ifndef _VX_DEVICE_H
11312 +#define _VX_DEVICE_H
11315 +#define DATTR_CREATE 0x00000001
11316 +#define DATTR_OPEN 0x00000002
11318 +#define DATTR_REMAP 0x00000010
11320 +#define DATTR_MASK 0x00000013
11323 +#else /* _VX_DEVICE_H */
11324 +#warning duplicate inclusion
11325 +#endif /* _VX_DEVICE_H */
11326 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/dlimit_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/dlimit_cmd.h
11327 --- linux-2.6.32.24/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11328 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/dlimit_cmd.h 2009-12-10 16:43:43.000000000 +0100
11330 +#ifndef _VX_DLIMIT_CMD_H
11331 +#define _VX_DLIMIT_CMD_H
11334 +/* dlimit vserver commands */
11336 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11337 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11339 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11340 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11342 +struct vcmd_ctx_dlimit_base_v0 {
11343 + const char __user *name;
11347 +struct vcmd_ctx_dlimit_v0 {
11348 + const char __user *name;
11349 + uint32_t space_used; /* used space in kbytes */
11350 + uint32_t space_total; /* maximum space in kbytes */
11351 + uint32_t inodes_used; /* used inodes */
11352 + uint32_t inodes_total; /* maximum inodes */
11353 + uint32_t reserved; /* reserved for root in % */
11357 +#define CDLIM_UNSET ((uint32_t)0UL)
11358 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11359 +#define CDLIM_KEEP ((uint32_t)~1UL)
11361 +#define DLIME_UNIT 0
11362 +#define DLIME_KILO 1
11363 +#define DLIME_MEGA 2
11364 +#define DLIME_GIGA 3
11366 +#define DLIMF_SHIFT 0x10
11368 +#define DLIMS_USED 0
11369 +#define DLIMS_TOTAL 2
11372 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
11374 + int exp = (flags & DLIMF_SHIFT) ?
11375 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
11376 + return ((uint64_t)val) << (10 * exp);
11380 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
11384 + if (*flags & DLIMF_SHIFT) {
11385 + while (val > (1LL << 32) && (exp < 3)) {
11389 + *flags &= ~(DLIME_GIGA << shift);
11390 + *flags |= exp << shift;
11398 +#ifdef CONFIG_COMPAT
11400 +#include <asm/compat.h>
11402 +struct vcmd_ctx_dlimit_base_v0_x32 {
11403 + compat_uptr_t name_ptr;
11407 +struct vcmd_ctx_dlimit_v0_x32 {
11408 + compat_uptr_t name_ptr;
11409 + uint32_t space_used; /* used space in kbytes */
11410 + uint32_t space_total; /* maximum space in kbytes */
11411 + uint32_t inodes_used; /* used inodes */
11412 + uint32_t inodes_total; /* maximum inodes */
11413 + uint32_t reserved; /* reserved for root in % */
11417 +#endif /* CONFIG_COMPAT */
11419 +#include <linux/compiler.h>
11421 +extern int vc_add_dlimit(uint32_t, void __user *);
11422 +extern int vc_rem_dlimit(uint32_t, void __user *);
11424 +extern int vc_set_dlimit(uint32_t, void __user *);
11425 +extern int vc_get_dlimit(uint32_t, void __user *);
11427 +#ifdef CONFIG_COMPAT
11429 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11430 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11432 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11433 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11435 +#endif /* CONFIG_COMPAT */
11437 +#endif /* __KERNEL__ */
11438 +#endif /* _VX_DLIMIT_CMD_H */
11439 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/dlimit.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/dlimit.h
11440 --- linux-2.6.32.24/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11441 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/dlimit.h 2009-12-03 20:04:56.000000000 +0100
11443 +#ifndef _VX_DLIMIT_H
11444 +#define _VX_DLIMIT_H
11446 +#include "switch.h"
11451 +/* keep in sync with CDLIM_INFINITY */
11453 +#define DLIM_INFINITY (~0ULL)
11455 +#include <linux/spinlock.h>
11456 +#include <linux/rcupdate.h>
11458 +struct super_block;
11461 + struct hlist_node dl_hlist; /* linked list of contexts */
11462 + struct rcu_head dl_rcu; /* the rcu head */
11463 + tag_t dl_tag; /* context tag */
11464 + atomic_t dl_usecnt; /* usage count */
11465 + atomic_t dl_refcnt; /* reference count */
11467 + struct super_block *dl_sb; /* associated superblock */
11469 + spinlock_t dl_lock; /* protect the values */
11471 + unsigned long long dl_space_used; /* used space in bytes */
11472 + unsigned long long dl_space_total; /* maximum space in bytes */
11473 + unsigned long dl_inodes_used; /* used inodes */
11474 + unsigned long dl_inodes_total; /* maximum inodes */
11476 + unsigned int dl_nrlmult; /* non root limit mult */
11481 +extern void rcu_free_dl_info(struct rcu_head *);
11482 +extern void unhash_dl_info(struct dl_info *);
11484 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11489 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11491 +typedef uint64_t dlsize_t;
11493 +#endif /* __KERNEL__ */
11494 +#else /* _VX_DLIMIT_H */
11495 +#warning duplicate inclusion
11496 +#endif /* _VX_DLIMIT_H */
11497 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/global.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/global.h
11498 --- linux-2.6.32.24/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11499 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/global.h 2009-12-03 20:04:56.000000000 +0100
11501 +#ifndef _VX_GLOBAL_H
11502 +#define _VX_GLOBAL_H
11505 +extern atomic_t vx_global_ctotal;
11506 +extern atomic_t vx_global_cactive;
11508 +extern atomic_t nx_global_ctotal;
11509 +extern atomic_t nx_global_cactive;
11511 +extern atomic_t vs_global_nsproxy;
11512 +extern atomic_t vs_global_fs;
11513 +extern atomic_t vs_global_mnt_ns;
11514 +extern atomic_t vs_global_uts_ns;
11515 +extern atomic_t vs_global_user_ns;
11516 +extern atomic_t vs_global_pid_ns;
11519 +#endif /* _VX_GLOBAL_H */
11520 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/history.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/history.h
11521 --- linux-2.6.32.24/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11522 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/history.h 2009-12-03 20:04:56.000000000 +0100
11524 +#ifndef _VX_HISTORY_H
11525 +#define _VX_HISTORY_H
11530 + VXH_THROW_OOPS = 1,
11534 + VXH_INIT_VX_INFO,
11537 + VXH_CLAIM_VX_INFO,
11538 + VXH_RELEASE_VX_INFO,
11539 + VXH_ALLOC_VX_INFO,
11540 + VXH_DEALLOC_VX_INFO,
11541 + VXH_HASH_VX_INFO,
11542 + VXH_UNHASH_VX_INFO,
11544 + VXH_LOOKUP_VX_INFO,
11545 + VXH_CREATE_VX_INFO,
11548 +struct _vxhe_vxi {
11549 + struct vx_info *ptr;
11555 +struct _vxhe_set_clr {
11559 +struct _vxhe_loc_lookup {
11563 +struct _vx_hist_entry {
11565 + unsigned short seq;
11566 + unsigned short type;
11567 + struct _vxhe_vxi vxi;
11569 + struct _vxhe_set_clr sc;
11570 + struct _vxhe_loc_lookup ll;
11574 +#ifdef CONFIG_VSERVER_HISTORY
11576 +extern unsigned volatile int vxh_active;
11578 +struct _vx_hist_entry *vxh_advance(void *loc);
11582 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11584 + entry->vxi.ptr = vxi;
11586 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11587 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11588 + entry->vxi.xid = vxi->vx_id;
11593 +#define __HERE__ current_text_addr()
11595 +#define __VXH_BODY(__type, __data, __here) \
11596 + struct _vx_hist_entry *entry; \
11598 + preempt_disable(); \
11599 + entry = vxh_advance(__here); \
11601 + entry->type = __type; \
11602 + preempt_enable();
11605 + /* pass vxi only */
11607 +#define __VXH_SMPL \
11608 + __vxh_copy_vxi(entry, vxi)
11611 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11613 + __VXH_BODY(__type, __VXH_SMPL, __here)
11616 + /* pass vxi and data (void *) */
11618 +#define __VXH_DATA \
11619 + __vxh_copy_vxi(entry, vxi); \
11620 + entry->sc.data = data
11623 +void __vxh_data(struct vx_info *vxi, void *data,
11624 + int __type, void *__here)
11626 + __VXH_BODY(__type, __VXH_DATA, __here)
11629 + /* pass vxi and arg (long) */
11631 +#define __VXH_LONG \
11632 + __vxh_copy_vxi(entry, vxi); \
11633 + entry->ll.arg = arg
11636 +void __vxh_long(struct vx_info *vxi, long arg,
11637 + int __type, void *__here)
11639 + __VXH_BODY(__type, __VXH_LONG, __here)
11644 +void __vxh_throw_oops(void *__here)
11646 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11647 + /* prevent further acquisition */
11652 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11654 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11655 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11657 +#define __vxh_init_vx_info(v, d, h) \
11658 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11659 +#define __vxh_set_vx_info(v, d, h) \
11660 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11661 +#define __vxh_clr_vx_info(v, d, h) \
11662 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11664 +#define __vxh_claim_vx_info(v, d, h) \
11665 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11666 +#define __vxh_release_vx_info(v, d, h) \
11667 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11669 +#define vxh_alloc_vx_info(v) \
11670 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11671 +#define vxh_dealloc_vx_info(v) \
11672 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11674 +#define vxh_hash_vx_info(v) \
11675 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11676 +#define vxh_unhash_vx_info(v) \
11677 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11679 +#define vxh_loc_vx_info(v, l) \
11680 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11681 +#define vxh_lookup_vx_info(v, l) \
11682 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11683 +#define vxh_create_vx_info(v, l) \
11684 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11686 +extern void vxh_dump_history(void);
11689 +#else /* CONFIG_VSERVER_HISTORY */
11691 +#define __HERE__ 0
11693 +#define vxh_throw_oops() do { } while (0)
11695 +#define __vxh_get_vx_info(v, h) do { } while (0)
11696 +#define __vxh_put_vx_info(v, h) do { } while (0)
11698 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11699 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11700 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11702 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11703 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11705 +#define vxh_alloc_vx_info(v) do { } while (0)
11706 +#define vxh_dealloc_vx_info(v) do { } while (0)
11708 +#define vxh_hash_vx_info(v) do { } while (0)
11709 +#define vxh_unhash_vx_info(v) do { } while (0)
11711 +#define vxh_loc_vx_info(v, l) do { } while (0)
11712 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11713 +#define vxh_create_vx_info(v, l) do { } while (0)
11715 +#define vxh_dump_history() do { } while (0)
11718 +#endif /* CONFIG_VSERVER_HISTORY */
11720 +#endif /* _VX_HISTORY_H */
11721 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/inode_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/inode_cmd.h
11722 --- linux-2.6.32.24/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11723 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/inode_cmd.h 2009-12-03 20:04:56.000000000 +0100
11725 +#ifndef _VX_INODE_CMD_H
11726 +#define _VX_INODE_CMD_H
11729 +/* inode vserver commands */
11731 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11732 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11734 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11735 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11737 +struct vcmd_ctx_iattr_v1 {
11738 + const char __user *name;
11744 +struct vcmd_ctx_fiattr_v0 {
11754 +#ifdef CONFIG_COMPAT
11756 +#include <asm/compat.h>
11758 +struct vcmd_ctx_iattr_v1_x32 {
11759 + compat_uptr_t name_ptr;
11765 +#endif /* CONFIG_COMPAT */
11767 +#include <linux/compiler.h>
11769 +extern int vc_get_iattr(void __user *);
11770 +extern int vc_set_iattr(void __user *);
11772 +extern int vc_fget_iattr(uint32_t, void __user *);
11773 +extern int vc_fset_iattr(uint32_t, void __user *);
11775 +#ifdef CONFIG_COMPAT
11777 +extern int vc_get_iattr_x32(void __user *);
11778 +extern int vc_set_iattr_x32(void __user *);
11780 +#endif /* CONFIG_COMPAT */
11782 +#endif /* __KERNEL__ */
11783 +#endif /* _VX_INODE_CMD_H */
11784 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/inode.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/inode.h
11785 --- linux-2.6.32.24/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11786 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/inode.h 2009-12-03 20:04:56.000000000 +0100
11788 +#ifndef _VX_INODE_H
11789 +#define _VX_INODE_H
11792 +#define IATTR_TAG 0x01000000
11794 +#define IATTR_ADMIN 0x00000001
11795 +#define IATTR_WATCH 0x00000002
11796 +#define IATTR_HIDE 0x00000004
11797 +#define IATTR_FLAGS 0x00000007
11799 +#define IATTR_BARRIER 0x00010000
11800 +#define IATTR_IXUNLINK 0x00020000
11801 +#define IATTR_IMMUTABLE 0x00040000
11802 +#define IATTR_COW 0x00080000
11807 +#ifdef CONFIG_VSERVER_PROC_SECURE
11808 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11809 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11811 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11812 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11815 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11817 +#endif /* __KERNEL__ */
11819 +/* inode ioctls */
11821 +#define FIOC_GETXFLG _IOR('x', 5, long)
11822 +#define FIOC_SETXFLG _IOW('x', 6, long)
11824 +#else /* _VX_INODE_H */
11825 +#warning duplicate inclusion
11826 +#endif /* _VX_INODE_H */
11827 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/Kbuild linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/Kbuild
11828 --- linux-2.6.32.24/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11829 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/Kbuild 2009-12-03 20:04:56.000000000 +0100
11832 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11833 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11834 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11835 + debug_cmd.h device_cmd.h
11837 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11839 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/limit_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/limit_cmd.h
11840 --- linux-2.6.32.24/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11841 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/limit_cmd.h 2009-12-03 20:04:56.000000000 +0100
11843 +#ifndef _VX_LIMIT_CMD_H
11844 +#define _VX_LIMIT_CMD_H
11847 +/* rlimit vserver commands */
11849 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
11850 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
11851 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
11852 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
11853 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
11855 +struct vcmd_ctx_rlimit_v0 {
11857 + uint64_t minimum;
11858 + uint64_t softlimit;
11859 + uint64_t maximum;
11862 +struct vcmd_ctx_rlimit_mask_v0 {
11863 + uint32_t minimum;
11864 + uint32_t softlimit;
11865 + uint32_t maximum;
11868 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
11870 +struct vcmd_rlimit_stat_v0 {
11874 + uint64_t minimum;
11875 + uint64_t maximum;
11878 +#define CRLIM_UNSET (0ULL)
11879 +#define CRLIM_INFINITY (~0ULL)
11880 +#define CRLIM_KEEP (~1ULL)
11884 +#ifdef CONFIG_IA32_EMULATION
11886 +struct vcmd_ctx_rlimit_v0_x32 {
11888 + uint64_t minimum;
11889 + uint64_t softlimit;
11890 + uint64_t maximum;
11891 +} __attribute__ ((packed));
11893 +#endif /* CONFIG_IA32_EMULATION */
11895 +#include <linux/compiler.h>
11897 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11898 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11899 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11900 +extern int vc_reset_hits(struct vx_info *, void __user *);
11901 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11903 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11905 +#ifdef CONFIG_IA32_EMULATION
11907 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11908 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11910 +#endif /* CONFIG_IA32_EMULATION */
11912 +#endif /* __KERNEL__ */
11913 +#endif /* _VX_LIMIT_CMD_H */
11914 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/limit_def.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/limit_def.h
11915 --- linux-2.6.32.24/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
11916 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/limit_def.h 2009-12-03 20:04:56.000000000 +0100
11918 +#ifndef _VX_LIMIT_DEF_H
11919 +#define _VX_LIMIT_DEF_H
11921 +#include <asm/atomic.h>
11922 +#include <asm/resource.h>
11924 +#include "limit.h"
11927 +struct _vx_res_limit {
11928 + rlim_t soft; /* Context soft limit */
11929 + rlim_t hard; /* Context hard limit */
11931 + rlim_atomic_t rcur; /* Current value */
11932 + rlim_t rmin; /* Context minimum */
11933 + rlim_t rmax; /* Context maximum */
11935 + atomic_t lhit; /* Limit hits */
11938 +/* context sub struct */
11940 +struct _vx_limit {
11941 + struct _vx_res_limit res[NUM_LIMITS];
11944 +#ifdef CONFIG_VSERVER_DEBUG
11946 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11950 + printk("\t_vx_limit:");
11951 + for (i = 0; i < NUM_LIMITS; i++) {
11952 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11953 + i, (unsigned long)__rlim_get(limit, i),
11954 + (unsigned long)__rlim_rmin(limit, i),
11955 + (unsigned long)__rlim_rmax(limit, i),
11956 + (long)__rlim_soft(limit, i),
11957 + (long)__rlim_hard(limit, i),
11958 + atomic_read(&__rlim_lhit(limit, i)));
11964 +#endif /* _VX_LIMIT_DEF_H */
11965 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/limit.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/limit.h
11966 --- linux-2.6.32.24/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
11967 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/limit.h 2010-02-05 00:34:02.000000000 +0100
11969 +#ifndef _VX_LIMIT_H
11970 +#define _VX_LIMIT_H
11972 +#define VLIMIT_NSOCK 16
11973 +#define VLIMIT_OPENFD 17
11974 +#define VLIMIT_ANON 18
11975 +#define VLIMIT_SHMEM 19
11976 +#define VLIMIT_SEMARY 20
11977 +#define VLIMIT_NSEMS 21
11978 +#define VLIMIT_DENTRY 22
11979 +#define VLIMIT_MAPPED 23
11984 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11986 +/* keep in sync with CRLIM_INFINITY */
11988 +#define VLIM_INFINITY (~0ULL)
11990 +#include <asm/atomic.h>
11991 +#include <asm/resource.h>
11993 +#ifndef RLIM_INFINITY
11994 +#warning RLIM_INFINITY is undefined
11997 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11999 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12000 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12002 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12003 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12004 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12006 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12007 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12009 +typedef atomic_long_t rlim_atomic_t;
12010 +typedef unsigned long rlim_t;
12012 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12013 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12014 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12015 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12016 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12017 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12020 +#if (RLIM_INFINITY == VLIM_INFINITY)
12021 +#define VX_VLIM(r) ((long long)(long)(r))
12022 +#define VX_RLIM(v) ((rlim_t)(v))
12024 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12025 + ? VLIM_INFINITY : (long long)(r))
12026 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12027 + ? RLIM_INFINITY : (rlim_t)(v))
12032 +void vx_vsi_meminfo(struct sysinfo *);
12033 +void vx_vsi_swapinfo(struct sysinfo *);
12034 +long vx_vsi_cached(struct sysinfo *);
12036 +#define NUM_LIMITS 24
12038 +#endif /* __KERNEL__ */
12039 +#endif /* _VX_LIMIT_H */
12040 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/limit_int.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/limit_int.h
12041 --- linux-2.6.32.24/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12042 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/limit_int.h 2009-12-03 20:04:56.000000000 +0100
12044 +#ifndef _VX_LIMIT_INT_H
12045 +#define _VX_LIMIT_INT_H
12047 +#include "context.h"
12051 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12052 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12054 +extern const char *vlimit_name[NUM_LIMITS];
12056 +static inline void __vx_acc_cres(struct vx_info *vxi,
12057 + int res, int dir, void *_data, char *_file, int _line)
12059 + if (VXD_RCRES_COND(res))
12060 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12061 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12062 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12063 + (dir > 0) ? "++" : "--", _data, _file, _line);
12068 + __rlim_inc(&vxi->limit, res);
12070 + __rlim_dec(&vxi->limit, res);
12073 +static inline void __vx_add_cres(struct vx_info *vxi,
12074 + int res, int amount, void *_data, char *_file, int _line)
12076 + if (VXD_RCRES_COND(res))
12077 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12078 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12079 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12080 + amount, _data, _file, _line);
12085 + __rlim_add(&vxi->limit, res, amount);
12089 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12091 + int cond = (value > __rlim_rmax(limit, res));
12094 + __rlim_rmax(limit, res) = value;
12099 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12101 + int cond = (value < __rlim_rmin(limit, res));
12104 + __rlim_rmin(limit, res) = value;
12109 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12111 + if (!__vx_cres_adjust_max(limit, res, value))
12112 + __vx_cres_adjust_min(limit, res, value);
12117 + +1 ... no limit hit
12118 + -1 ... over soft limit
12119 + 0 ... over hard limit */
12121 +static inline int __vx_cres_avail(struct vx_info *vxi,
12122 + int res, int num, char *_file, int _line)
12124 + struct _vx_limit *limit;
12127 + if (VXD_RLIMIT_COND(res))
12128 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12129 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12130 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12131 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12132 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12133 + num, _file, _line);
12137 + limit = &vxi->limit;
12138 + value = __rlim_get(limit, res);
12140 + if (!__vx_cres_adjust_max(limit, res, value))
12141 + __vx_cres_adjust_min(limit, res, value);
12146 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12148 + if (value + num <= __rlim_soft(limit, res))
12151 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12153 + if (value + num <= __rlim_hard(limit, res))
12156 + __rlim_hit(limit, res);
12161 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12164 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12166 + rlim_t value, sum = 0;
12169 + while ((res = *array++)) {
12170 + value = __rlim_get(limit, res);
12171 + __vx_cres_fixup(limit, res, value);
12178 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12180 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12181 + int res = *array;
12183 + if (value == __rlim_get(limit, res))
12186 + __rlim_set(limit, res, value);
12187 + /* now adjust min/max */
12188 + if (!__vx_cres_adjust_max(limit, res, value))
12189 + __vx_cres_adjust_min(limit, res, value);
12194 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12195 + const int *array, int num, char *_file, int _line)
12197 + struct _vx_limit *limit;
12198 + rlim_t value = 0;
12206 + limit = &vxi->limit;
12208 + value = __vx_cres_array_sum(limit, array + 1);
12210 + __rlim_set(limit, res, value);
12211 + __vx_cres_fixup(limit, res, value);
12213 + return __vx_cres_avail(vxi, res, num, _file, _line);
12217 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12222 + /* complex resources first */
12223 + if ((id < 0) || (id == RLIMIT_RSS))
12224 + __vx_cres_array_fixup(limit, VLA_RSS);
12226 + for (res = 0; res < NUM_LIMITS; res++) {
12227 + if ((id > 0) && (res != id))
12230 + value = __rlim_get(limit, res);
12231 + __vx_cres_fixup(limit, res, value);
12233 + /* not supposed to happen, maybe warn? */
12234 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12235 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12240 +#endif /* __KERNEL__ */
12241 +#endif /* _VX_LIMIT_INT_H */
12242 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/monitor.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/monitor.h
12243 --- linux-2.6.32.24/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12244 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/monitor.h 2009-12-03 20:04:56.000000000 +0100
12246 +#ifndef _VX_MONITOR_H
12247 +#define _VX_MONITOR_H
12249 +#include <linux/types.h>
12256 + VXM_UPDATE = 0x20,
12260 + VXM_RQINFO_1 = 0x24,
12263 + VXM_ACTIVATE = 0x40,
12270 + VXM_MIGRATE = 0x48,
12273 + /* all other bits are flags */
12274 + VXM_SCHED = 0x80,
12277 +struct _vxm_update_1 {
12278 + uint32_t tokens_max;
12279 + uint32_t fill_rate;
12280 + uint32_t interval;
12283 +struct _vxm_update_2 {
12284 + uint32_t tokens_min;
12285 + uint32_t fill_rate;
12286 + uint32_t interval;
12289 +struct _vxm_rqinfo_1 {
12290 + uint16_t running;
12294 + uint32_t idle_tokens;
12297 +struct _vxm_rqinfo_2 {
12298 + uint32_t norm_time;
12299 + uint32_t idle_time;
12300 + uint32_t idle_skip;
12303 +struct _vxm_sched {
12305 + uint32_t norm_time;
12306 + uint32_t idle_time;
12309 +struct _vxm_task {
12314 +struct _vxm_event {
12323 + struct _vxm_task tsk;
12327 +struct _vx_mon_entry {
12331 + struct _vxm_event ev;
12332 + struct _vxm_sched sd;
12333 + struct _vxm_update_1 u1;
12334 + struct _vxm_update_2 u2;
12335 + struct _vxm_rqinfo_1 q1;
12336 + struct _vxm_rqinfo_2 q2;
12341 +#endif /* _VX_MONITOR_H */
12342 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/network_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/network_cmd.h
12343 --- linux-2.6.32.24/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12344 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/network_cmd.h 2009-12-03 20:04:56.000000000 +0100
12346 +#ifndef _VX_NETWORK_CMD_H
12347 +#define _VX_NETWORK_CMD_H
12350 +/* vinfo commands */
12352 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12355 +extern int vc_task_nid(uint32_t);
12357 +#endif /* __KERNEL__ */
12359 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12361 +struct vcmd_nx_info_v0 {
12363 + /* more to come */
12367 +extern int vc_nx_info(struct nx_info *, void __user *);
12369 +#endif /* __KERNEL__ */
12371 +#include <linux/in.h>
12372 +#include <linux/in6.h>
12374 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12375 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12377 +struct vcmd_net_create {
12378 + uint64_t flagword;
12381 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12383 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12384 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12386 +struct vcmd_net_addr_v0 {
12389 + struct in_addr ip[4];
12390 + struct in_addr mask[4];
12393 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12394 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12396 +struct vcmd_net_addr_ipv4_v1 {
12399 + struct in_addr ip;
12400 + struct in_addr mask;
12403 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12404 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12406 +struct vcmd_net_addr_ipv6_v1 {
12410 + struct in6_addr ip;
12411 + struct in6_addr mask;
12414 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12415 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12417 +struct vcmd_match_ipv4_v0 {
12422 + struct in_addr ip;
12423 + struct in_addr ip2;
12424 + struct in_addr mask;
12427 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12428 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12430 +struct vcmd_match_ipv6_v0 {
12435 + struct in6_addr ip;
12436 + struct in6_addr ip2;
12437 + struct in6_addr mask;
12442 +extern int vc_net_create(uint32_t, void __user *);
12443 +extern int vc_net_migrate(struct nx_info *, void __user *);
12445 +extern int vc_net_add(struct nx_info *, void __user *);
12446 +extern int vc_net_remove(struct nx_info *, void __user *);
12448 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12449 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12451 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12452 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12454 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12455 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12457 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12458 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12460 +#endif /* __KERNEL__ */
12463 +/* flag commands */
12465 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12466 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12468 +struct vcmd_net_flags_v0 {
12469 + uint64_t flagword;
12474 +extern int vc_get_nflags(struct nx_info *, void __user *);
12475 +extern int vc_set_nflags(struct nx_info *, void __user *);
12477 +#endif /* __KERNEL__ */
12480 +/* network caps commands */
12482 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12483 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12485 +struct vcmd_net_caps_v0 {
12491 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12492 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12494 +#endif /* __KERNEL__ */
12495 +#endif /* _VX_CONTEXT_CMD_H */
12496 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/network.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/network.h
12497 --- linux-2.6.32.24/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12498 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/network.h 2009-12-03 20:04:56.000000000 +0100
12500 +#ifndef _VX_NETWORK_H
12501 +#define _VX_NETWORK_H
12503 +#include <linux/types.h>
12506 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12509 +/* network flags */
12511 +#define NXF_INFO_PRIVATE 0x00000008
12513 +#define NXF_SINGLE_IP 0x00000100
12514 +#define NXF_LBACK_REMAP 0x00000200
12515 +#define NXF_LBACK_ALLOW 0x00000400
12517 +#define NXF_HIDE_NETIF 0x02000000
12518 +#define NXF_HIDE_LBACK 0x04000000
12520 +#define NXF_STATE_SETUP (1ULL << 32)
12521 +#define NXF_STATE_ADMIN (1ULL << 34)
12523 +#define NXF_SC_HELPER (1ULL << 36)
12524 +#define NXF_PERSISTENT (1ULL << 38)
12526 +#define NXF_ONE_TIME (0x0005ULL << 32)
12529 +#define NXF_INIT_SET (__nxf_init_set())
12531 +static inline uint64_t __nxf_init_set(void) {
12532 + return NXF_STATE_ADMIN
12533 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12534 + | NXF_LBACK_REMAP
12537 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12540 + | NXF_HIDE_NETIF;
12544 +/* network caps */
12546 +#define NXC_TUN_CREATE 0x00000001
12548 +#define NXC_RAW_ICMP 0x00000100
12551 +/* address types */
12553 +#define NXA_TYPE_IPV4 0x0001
12554 +#define NXA_TYPE_IPV6 0x0002
12556 +#define NXA_TYPE_NONE 0x0000
12557 +#define NXA_TYPE_ANY 0x00FF
12559 +#define NXA_TYPE_ADDR 0x0010
12560 +#define NXA_TYPE_MASK 0x0020
12561 +#define NXA_TYPE_RANGE 0x0040
12563 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12565 +#define NXA_MOD_BCAST 0x0100
12566 +#define NXA_MOD_LBACK 0x0200
12568 +#define NXA_LOOPBACK 0x1000
12570 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12571 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12575 +#include <linux/list.h>
12576 +#include <linux/spinlock.h>
12577 +#include <linux/rcupdate.h>
12578 +#include <linux/in.h>
12579 +#include <linux/in6.h>
12580 +#include <asm/atomic.h>
12582 +struct nx_addr_v4 {
12583 + struct nx_addr_v4 *next;
12584 + struct in_addr ip[2];
12585 + struct in_addr mask;
12590 +struct nx_addr_v6 {
12591 + struct nx_addr_v6 *next;
12592 + struct in6_addr ip;
12593 + struct in6_addr mask;
12600 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12601 + nid_t nx_id; /* vnet id */
12602 + atomic_t nx_usecnt; /* usage count */
12603 + atomic_t nx_tasks; /* tasks count */
12604 + int nx_state; /* context state */
12606 + uint64_t nx_flags; /* network flag word */
12607 + uint64_t nx_ncaps; /* network capabilities */
12609 + struct in_addr v4_lback; /* Loopback address */
12610 + struct in_addr v4_bcast; /* Broadcast address */
12611 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12612 +#ifdef CONFIG_IPV6
12613 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12615 + char nx_name[65]; /* network context name */
12619 +/* status flags */
12621 +#define NXS_HASHED 0x0001
12622 +#define NXS_SHUTDOWN 0x0100
12623 +#define NXS_RELEASED 0x8000
12625 +extern struct nx_info *lookup_nx_info(int);
12627 +extern int get_nid_list(int, unsigned int *, int);
12628 +extern int nid_is_hashed(nid_t);
12630 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12632 +extern long vs_net_change(struct nx_info *, unsigned int);
12637 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12638 +#ifdef CONFIG_IPV6
12639 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12641 +#define NX_IPV6(n) (0)
12644 +#endif /* __KERNEL__ */
12645 +#endif /* _VX_NETWORK_H */
12646 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/percpu.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/percpu.h
12647 --- linux-2.6.32.24/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12648 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/percpu.h 2009-12-03 20:04:56.000000000 +0100
12650 +#ifndef _VX_PERCPU_H
12651 +#define _VX_PERCPU_H
12653 +#include "cvirt_def.h"
12654 +#include "sched_def.h"
12656 +struct _vx_percpu {
12657 + struct _vx_cvirt_pc cvirt;
12658 + struct _vx_sched_pc sched;
12661 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12663 +#endif /* _VX_PERCPU_H */
12664 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/pid.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/pid.h
12665 --- linux-2.6.32.24/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12666 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/pid.h 2009-12-03 20:04:56.000000000 +0100
12668 +#ifndef _VSERVER_PID_H
12669 +#define _VSERVER_PID_H
12671 +/* pid faking stuff */
12673 +#define vx_info_map_pid(v, p) \
12674 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12675 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12676 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
12677 +#define vx_map_tgid(p) vx_map_pid(p)
12679 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12680 + const char *func, const char *file, int line)
12682 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12683 + vxfprintk(VXD_CBIT(cvirt, 2),
12684 + "vx_map_tgid: %p/%llx: %d -> %d",
12685 + vxi, (long long)vxi->vx_flags, pid,
12686 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12687 + func, file, line);
12690 + if (pid == vxi->vx_initpid)
12696 +#define vx_info_rmap_pid(v, p) \
12697 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12698 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
12699 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12701 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12702 + const char *func, const char *file, int line)
12704 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12705 + vxfprintk(VXD_CBIT(cvirt, 2),
12706 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12707 + vxi, (long long)vxi->vx_flags, pid,
12708 + (pid == 1) ? vxi->vx_initpid : pid,
12709 + func, file, line);
12710 + if ((pid == 1) && vxi->vx_initpid)
12711 + return vxi->vx_initpid;
12712 + if (pid == vxi->vx_initpid)
12719 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/sched_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/sched_cmd.h
12720 --- linux-2.6.32.24/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12721 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/sched_cmd.h 2009-12-03 20:04:56.000000000 +0100
12723 +#ifndef _VX_SCHED_CMD_H
12724 +#define _VX_SCHED_CMD_H
12727 +/* sched vserver commands */
12729 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12730 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12731 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12733 +struct vcmd_set_sched_v2 {
12734 + int32_t fill_rate;
12735 + int32_t interval;
12737 + int32_t tokens_min;
12738 + int32_t tokens_max;
12739 + uint64_t cpu_mask;
12742 +struct vcmd_set_sched_v3 {
12743 + uint32_t set_mask;
12744 + int32_t fill_rate;
12745 + int32_t interval;
12747 + int32_t tokens_min;
12748 + int32_t tokens_max;
12749 + int32_t priority_bias;
12752 +struct vcmd_set_sched_v4 {
12753 + uint32_t set_mask;
12754 + int32_t fill_rate;
12755 + int32_t interval;
12757 + int32_t tokens_min;
12758 + int32_t tokens_max;
12759 + int32_t prio_bias;
12761 + int32_t bucket_id;
12764 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12765 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12767 +struct vcmd_sched_v5 {
12770 + int32_t bucket_id;
12771 + int32_t fill_rate[2];
12772 + int32_t interval[2];
12774 + int32_t tokens_min;
12775 + int32_t tokens_max;
12776 + int32_t prio_bias;
12779 +#define VXSM_FILL_RATE 0x0001
12780 +#define VXSM_INTERVAL 0x0002
12781 +#define VXSM_FILL_RATE2 0x0004
12782 +#define VXSM_INTERVAL2 0x0008
12783 +#define VXSM_TOKENS 0x0010
12784 +#define VXSM_TOKENS_MIN 0x0020
12785 +#define VXSM_TOKENS_MAX 0x0040
12786 +#define VXSM_PRIO_BIAS 0x0100
12788 +#define VXSM_IDLE_TIME 0x0200
12789 +#define VXSM_FORCE 0x0400
12791 +#define VXSM_V3_MASK 0x0173
12792 +#define VXSM_SET_MASK 0x01FF
12794 +#define VXSM_CPU_ID 0x1000
12795 +#define VXSM_BUCKET_ID 0x2000
12797 +#define VXSM_MSEC 0x4000
12799 +#define SCHED_KEEP (-2) /* only for v2 */
12803 +#include <linux/compiler.h>
12805 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
12806 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
12807 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
12808 +extern int vc_set_sched(struct vx_info *, void __user *);
12809 +extern int vc_get_sched(struct vx_info *, void __user *);
12811 +#endif /* __KERNEL__ */
12813 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
12815 +struct vcmd_sched_info {
12817 + int32_t bucket_id;
12818 + uint64_t user_msec;
12819 + uint64_t sys_msec;
12820 + uint64_t hold_msec;
12821 + uint32_t token_usec;
12822 + int32_t vavavoom;
12827 +extern int vc_sched_info(struct vx_info *, void __user *);
12829 +#endif /* __KERNEL__ */
12830 +#endif /* _VX_SCHED_CMD_H */
12831 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/sched_def.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/sched_def.h
12832 --- linux-2.6.32.24/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12833 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/sched_def.h 2009-12-03 20:04:56.000000000 +0100
12835 +#ifndef _VX_SCHED_DEF_H
12836 +#define _VX_SCHED_DEF_H
12838 +#include <linux/spinlock.h>
12839 +#include <linux/jiffies.h>
12840 +#include <linux/cpumask.h>
12841 +#include <asm/atomic.h>
12842 +#include <asm/param.h>
12845 +/* context sub struct */
12847 +struct _vx_sched {
12848 + spinlock_t tokens_lock; /* lock for token bucket */
12850 + int tokens; /* number of CPU tokens */
12851 + int fill_rate[2]; /* Fill rate: add X tokens... */
12852 + int interval[2]; /* Divisor: per Y jiffies */
12853 + int tokens_min; /* Limit: minimum for unhold */
12854 + int tokens_max; /* Limit: no more than N tokens */
12856 + int prio_bias; /* bias offset for priority */
12858 + unsigned update_mask; /* which features should be updated */
12859 + cpumask_t update; /* CPUs which should update */
12862 +struct _vx_sched_pc {
12863 + int tokens; /* number of CPU tokens */
12864 + int flags; /* bucket flags */
12866 + int fill_rate[2]; /* Fill rate: add X tokens... */
12867 + int interval[2]; /* Divisor: per Y jiffies */
12868 + int tokens_min; /* Limit: minimum for unhold */
12869 + int tokens_max; /* Limit: no more than N tokens */
12871 + int prio_bias; /* bias offset for priority */
12872 + int vavavoom; /* last calculated vavavoom */
12874 + unsigned long norm_time; /* last time accounted */
12875 + unsigned long idle_time; /* non linear time for fair sched */
12876 + unsigned long token_time; /* token time for accounting */
12877 + unsigned long onhold; /* jiffies when put on hold */
12879 + uint64_t user_ticks; /* token tick events */
12880 + uint64_t sys_ticks; /* token tick events */
12881 + uint64_t hold_ticks; /* token ticks paused */
12885 +#define VXSF_ONHOLD 0x0001
12886 +#define VXSF_IDLE_TIME 0x0100
12888 +#ifdef CONFIG_VSERVER_DEBUG
12890 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12892 + printk("\t_vx_sched:\n");
12893 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
12894 + sched->fill_rate[0], sched->interval[0],
12895 + sched->fill_rate[1], sched->interval[1],
12896 + sched->tokens_min, sched->tokens_max);
12897 + printk("\t priority = %4d\n", sched->prio_bias);
12902 +#endif /* _VX_SCHED_DEF_H */
12903 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/sched.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/sched.h
12904 --- linux-2.6.32.24/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
12905 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/sched.h 2009-12-03 20:04:56.000000000 +0100
12907 +#ifndef _VX_SCHED_H
12908 +#define _VX_SCHED_H
12915 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12920 +void vx_update_load(struct vx_info *);
12923 +int vx_tokens_recalc(struct _vx_sched_pc *,
12924 + unsigned long *, unsigned long *, int [2]);
12926 +void vx_update_sched_param(struct _vx_sched *sched,
12927 + struct _vx_sched_pc *sched_pc);
12929 +#endif /* __KERNEL__ */
12930 +#else /* _VX_SCHED_H */
12931 +#warning duplicate inclusion
12932 +#endif /* _VX_SCHED_H */
12933 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/signal_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/signal_cmd.h
12934 --- linux-2.6.32.24/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
12935 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/signal_cmd.h 2009-12-03 20:04:56.000000000 +0100
12937 +#ifndef _VX_SIGNAL_CMD_H
12938 +#define _VX_SIGNAL_CMD_H
12941 +/* signalling vserver commands */
12943 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
12944 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
12946 +struct vcmd_ctx_kill_v0 {
12951 +struct vcmd_wait_exit_v0 {
12952 + int32_t reboot_cmd;
12953 + int32_t exit_code;
12958 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12959 +extern int vc_wait_exit(struct vx_info *, void __user *);
12961 +#endif /* __KERNEL__ */
12963 +/* process alteration commands */
12965 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
12966 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
12968 +struct vcmd_pflags_v0 {
12969 + uint32_t flagword;
12975 +extern int vc_get_pflags(uint32_t pid, void __user *);
12976 +extern int vc_set_pflags(uint32_t pid, void __user *);
12978 +#endif /* __KERNEL__ */
12979 +#endif /* _VX_SIGNAL_CMD_H */
12980 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/signal.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/signal.h
12981 --- linux-2.6.32.24/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
12982 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/signal.h 2009-12-03 20:04:56.000000000 +0100
12984 +#ifndef _VX_SIGNAL_H
12985 +#define _VX_SIGNAL_H
12992 +int vx_info_kill(struct vx_info *, int, int);
12994 +#endif /* __KERNEL__ */
12995 +#else /* _VX_SIGNAL_H */
12996 +#warning duplicate inclusion
12997 +#endif /* _VX_SIGNAL_H */
12998 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/space_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/space_cmd.h
12999 --- linux-2.6.32.24/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13000 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/space_cmd.h 2009-12-03 20:04:56.000000000 +0100
13002 +#ifndef _VX_SPACE_CMD_H
13003 +#define _VX_SPACE_CMD_H
13006 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13007 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13008 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13010 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13011 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13012 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13014 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13016 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13017 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13020 +struct vcmd_space_mask_v1 {
13024 +struct vcmd_space_mask_v2 {
13032 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13033 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13034 +extern int vc_enter_space(struct vx_info *, void __user *);
13035 +extern int vc_set_space(struct vx_info *, void __user *);
13036 +extern int vc_get_space_mask(void __user *, int);
13038 +#endif /* __KERNEL__ */
13039 +#endif /* _VX_SPACE_CMD_H */
13040 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/space.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/space.h
13041 --- linux-2.6.32.24/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13042 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/space.h 2009-12-03 20:04:56.000000000 +0100
13044 +#ifndef _VX_SPACE_H
13045 +#define _VX_SPACE_H
13047 +#include <linux/types.h>
13051 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13053 +#else /* _VX_SPACE_H */
13054 +#warning duplicate inclusion
13055 +#endif /* _VX_SPACE_H */
13056 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/switch.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/switch.h
13057 --- linux-2.6.32.24/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13058 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/switch.h 2009-12-03 20:04:56.000000000 +0100
13060 +#ifndef _VX_SWITCH_H
13061 +#define _VX_SWITCH_H
13063 +#include <linux/types.h>
13066 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13067 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13068 +#define VC_VERSION(c) ((c) & 0xFFF)
13070 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13071 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13075 + Syscall Matrix V2.8
13077 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13078 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13079 + |INFO |SETUP | |MOVE | | | | | |
13080 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13081 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13082 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13083 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13084 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13085 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13086 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13087 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13088 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13089 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13090 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13091 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13092 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13093 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13094 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13095 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13096 + OTHER |VSTAT | | | | | | |VINFO | |
13097 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13098 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13099 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13100 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13101 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13102 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13103 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13104 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13108 +#define VC_CAT_VERSION 0
13110 +#define VC_CAT_VSETUP 1
13111 +#define VC_CAT_VHOST 2
13113 +#define VC_CAT_DEVICE 6
13115 +#define VC_CAT_VPROC 9
13116 +#define VC_CAT_PROCALT 10
13117 +#define VC_CAT_PROCMIG 11
13118 +#define VC_CAT_PROCTRL 12
13120 +#define VC_CAT_SCHED 14
13121 +#define VC_CAT_MEMCTRL 20
13123 +#define VC_CAT_VNET 25
13124 +#define VC_CAT_NETALT 26
13125 +#define VC_CAT_NETMIG 27
13126 +#define VC_CAT_NETCTRL 28
13128 +#define VC_CAT_TAGMIG 35
13129 +#define VC_CAT_DLIMIT 36
13130 +#define VC_CAT_INODE 38
13132 +#define VC_CAT_VSTAT 40
13133 +#define VC_CAT_VINFO 46
13134 +#define VC_CAT_EVENT 48
13136 +#define VC_CAT_FLAGS 52
13137 +#define VC_CAT_VSPACE 54
13138 +#define VC_CAT_DEBUG 56
13139 +#define VC_CAT_RLIMIT 60
13141 +#define VC_CAT_SYSTEST 61
13142 +#define VC_CAT_COMPAT 63
13144 +/* query version */
13146 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13147 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13152 +#include <linux/errno.h>
13154 +#endif /* __KERNEL__ */
13156 +#endif /* _VX_SWITCH_H */
13158 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/tag_cmd.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/tag_cmd.h
13159 --- linux-2.6.32.24/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13160 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/tag_cmd.h 2009-12-03 20:04:56.000000000 +0100
13162 +#ifndef _VX_TAG_CMD_H
13163 +#define _VX_TAG_CMD_H
13166 +/* vinfo commands */
13168 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13171 +extern int vc_task_tag(uint32_t);
13173 +#endif /* __KERNEL__ */
13175 +/* context commands */
13177 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13180 +extern int vc_tag_migrate(uint32_t);
13182 +#endif /* __KERNEL__ */
13183 +#endif /* _VX_TAG_CMD_H */
13184 diff -NurpP --minimal linux-2.6.32.24/include/linux/vserver/tag.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/tag.h
13185 --- linux-2.6.32.24/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13186 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vserver/tag.h 2009-12-03 20:04:56.000000000 +0100
13191 +#include <linux/types.h>
13194 +#define DX_TAG(in) (IS_TAGGED(in))
13197 +#ifdef CONFIG_TAG_NFSD
13198 +#define DX_TAG_NFSD 1
13200 +#define DX_TAG_NFSD 0
13204 +#ifdef CONFIG_TAGGING_NONE
13206 +#define MAX_UID 0xFFFFFFFF
13207 +#define MAX_GID 0xFFFFFFFF
13209 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13211 +#define TAGINO_UID(cond, uid, tag) (uid)
13212 +#define TAGINO_GID(cond, gid, tag) (gid)
13217 +#ifdef CONFIG_TAGGING_GID16
13219 +#define MAX_UID 0xFFFFFFFF
13220 +#define MAX_GID 0x0000FFFF
13222 +#define INOTAG_TAG(cond, uid, gid, tag) \
13223 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13225 +#define TAGINO_UID(cond, uid, tag) (uid)
13226 +#define TAGINO_GID(cond, gid, tag) \
13227 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13232 +#ifdef CONFIG_TAGGING_ID24
13234 +#define MAX_UID 0x00FFFFFF
13235 +#define MAX_GID 0x00FFFFFF
13237 +#define INOTAG_TAG(cond, uid, gid, tag) \
13238 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13240 +#define TAGINO_UID(cond, uid, tag) \
13241 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13242 +#define TAGINO_GID(cond, gid, tag) \
13243 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13248 +#ifdef CONFIG_TAGGING_UID16
13250 +#define MAX_UID 0x0000FFFF
13251 +#define MAX_GID 0xFFFFFFFF
13253 +#define INOTAG_TAG(cond, uid, gid, tag) \
13254 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13256 +#define TAGINO_UID(cond, uid, tag) \
13257 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13258 +#define TAGINO_GID(cond, gid, tag) (gid)
13263 +#ifdef CONFIG_TAGGING_INTERN
13265 +#define MAX_UID 0xFFFFFFFF
13266 +#define MAX_GID 0xFFFFFFFF
13268 +#define INOTAG_TAG(cond, uid, gid, tag) \
13269 + ((cond) ? (tag) : 0)
13271 +#define TAGINO_UID(cond, uid, tag) (uid)
13272 +#define TAGINO_GID(cond, gid, tag) (gid)
13277 +#ifndef CONFIG_TAGGING_NONE
13278 +#define dx_current_fstag(sb) \
13279 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13281 +#define dx_current_fstag(sb) (0)
13284 +#ifndef CONFIG_TAGGING_INTERN
13285 +#define TAGINO_TAG(cond, tag) (0)
13287 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13290 +#define INOTAG_UID(cond, uid, gid) \
13291 + ((cond) ? ((uid) & MAX_UID) : (uid))
13292 +#define INOTAG_GID(cond, uid, gid) \
13293 + ((cond) ? ((gid) & MAX_GID) : (gid))
13296 +static inline uid_t dx_map_uid(uid_t uid)
13298 + if ((uid > MAX_UID) && (uid != -1))
13300 + return (uid & MAX_UID);
13303 +static inline gid_t dx_map_gid(gid_t gid)
13305 + if ((gid > MAX_GID) && (gid != -1))
13307 + return (gid & MAX_GID);
13315 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13317 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13318 + unsigned long *flags);
13320 +#ifdef CONFIG_PROPAGATE
13322 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13324 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13327 +#define dx_propagate_tag(n, i) do { } while (0)
13330 +#endif /* _DX_TAG_H */
13331 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_inet6.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_inet6.h
13332 --- linux-2.6.32.24/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13333 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_inet6.h 2009-12-03 20:04:56.000000000 +0100
13335 +#ifndef _VS_INET6_H
13336 +#define _VS_INET6_H
13338 +#include "vserver/base.h"
13339 +#include "vserver/network.h"
13340 +#include "vserver/debug.h"
13342 +#include <net/ipv6.h>
13344 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
13345 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
13348 +#ifdef CONFIG_IPV6
13351 +int v6_addr_match(struct nx_addr_v6 *nxa,
13352 + const struct in6_addr *addr, uint16_t mask)
13356 + switch (nxa->type & mask) {
13357 + case NXA_TYPE_MASK:
13358 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13360 + case NXA_TYPE_ADDR:
13361 + ret = ipv6_addr_equal(&nxa->ip, addr);
13363 + case NXA_TYPE_ANY:
13367 + vxdprintk(VXD_CBIT(net, 0),
13368 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
13369 + nxa, NXAV6(nxa), addr, mask, ret);
13374 +int v6_addr_in_nx_info(struct nx_info *nxi,
13375 + const struct in6_addr *addr, uint16_t mask)
13377 + struct nx_addr_v6 *nxa;
13382 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13383 + if (v6_addr_match(nxa, addr, mask))
13387 + vxdprintk(VXD_CBIT(net, 0),
13388 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
13389 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
13394 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13396 + /* FIXME: needs full range checks */
13397 + return v6_addr_match(nxa, &addr->ip, mask);
13401 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13403 + struct nx_addr_v6 *ptr;
13405 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13406 + if (v6_nx_addr_match(ptr, nxa, mask))
13413 + * Check if a given address matches for a socket
13415 + * nxi: the socket's nx_info if any
13416 + * addr: to be verified address
13419 +int v6_sock_addr_match (
13420 + struct nx_info *nxi,
13421 + struct inet_sock *inet,
13422 + struct in6_addr *addr)
13424 + struct sock *sk = &inet->sk;
13425 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13427 + if (!ipv6_addr_any(addr) &&
13428 + ipv6_addr_equal(saddr, addr))
13430 + if (ipv6_addr_any(saddr))
13431 + return v6_addr_in_nx_info(nxi, addr, -1);
13436 + * check if address is covered by socket
13438 + * sk: the socket to check against
13439 + * addr: the address in question (must be != 0)
13443 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13445 + struct nx_info *nxi = sk->sk_nx_info;
13446 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13448 + vxdprintk(VXD_CBIT(net, 5),
13449 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
13450 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
13451 + (sk->sk_socket?sk->sk_socket->flags:0));
13453 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13454 + return v6_addr_match(nxa, saddr, -1);
13455 + } else if (nxi) { /* match against nx_info */
13456 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13457 + } else { /* unrestricted any socket */
13463 +/* inet related checks and helpers */
13467 +struct net_device;
13471 +#include <linux/netdevice.h>
13472 +#include <linux/inetdevice.h>
13473 +#include <net/inet_timewait_sock.h>
13476 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13477 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13478 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13483 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13489 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13493 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13495 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13496 + nxi, nxi ? nxi->nx_id : 0, ifa,
13497 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13499 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13501 + if (v6_ifa_in_nx_info(ifa, nxi))
13507 +struct nx_v6_sock_addr {
13508 + struct in6_addr saddr; /* Address used for validation */
13509 + struct in6_addr baddr; /* Address used for socket bind */
13513 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13514 + struct nx_v6_sock_addr *nsa)
13516 + // struct sock *sk = &inet->sk;
13517 + // struct nx_info *nxi = sk->sk_nx_info;
13518 + struct in6_addr saddr = addr->sin6_addr;
13519 + struct in6_addr baddr = saddr;
13521 + nsa->saddr = saddr;
13522 + nsa->baddr = baddr;
13527 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13529 + // struct sock *sk = &inet->sk;
13530 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13532 + // *saddr = nsa->baddr;
13533 + // inet->saddr = nsa->baddr;
13537 +int nx_info_has_v6(struct nx_info *nxi)
13541 + if (NX_IPV6(nxi))
13546 +#else /* CONFIG_IPV6 */
13549 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13556 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13562 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13568 +int nx_info_has_v6(struct nx_info *nxi)
13573 +#endif /* CONFIG_IPV6 */
13575 +#define current_nx_info_has_v6() \
13576 + nx_info_has_v6(current_nx_info())
13579 +#warning duplicate inclusion
13581 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_inet.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_inet.h
13582 --- linux-2.6.32.24/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13583 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_inet.h 2009-12-03 20:04:56.000000000 +0100
13585 +#ifndef _VS_INET_H
13586 +#define _VS_INET_H
13588 +#include "vserver/base.h"
13589 +#include "vserver/network.h"
13590 +#include "vserver/debug.h"
13592 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13594 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13595 + NIPQUAD((a)->mask), (a)->type
13596 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13600 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13602 + __be32 ip = nxa->ip[0].s_addr;
13603 + __be32 mask = nxa->mask.s_addr;
13604 + __be32 bcast = ip | ~mask;
13607 + switch (nxa->type & tmask) {
13608 + case NXA_TYPE_MASK:
13609 + ret = (ip == (addr & mask));
13611 + case NXA_TYPE_ADDR:
13615 + /* fall through to broadcast */
13616 + case NXA_MOD_BCAST:
13617 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13619 + case NXA_TYPE_RANGE:
13620 + ret = ((nxa->ip[0].s_addr <= addr) &&
13621 + (nxa->ip[1].s_addr > addr));
13623 + case NXA_TYPE_ANY:
13628 + vxdprintk(VXD_CBIT(net, 0),
13629 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13630 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13635 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13637 + struct nx_addr_v4 *nxa;
13644 + /* allow 127.0.0.1 when remapping lback */
13645 + if ((tmask & NXA_LOOPBACK) &&
13646 + (addr == IPI_LOOPBACK) &&
13647 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13650 + /* check for lback address */
13651 + if ((tmask & NXA_MOD_LBACK) &&
13652 + (nxi->v4_lback.s_addr == addr))
13655 + /* check for broadcast address */
13656 + if ((tmask & NXA_MOD_BCAST) &&
13657 + (nxi->v4_bcast.s_addr == addr))
13660 + /* check for v4 addresses */
13661 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13662 + if (v4_addr_match(nxa, addr, tmask))
13666 + vxdprintk(VXD_CBIT(net, 0),
13667 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13668 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13673 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13675 + /* FIXME: needs full range checks */
13676 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13680 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13682 + struct nx_addr_v4 *ptr;
13684 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13685 + if (v4_nx_addr_match(ptr, nxa, mask))
13690 +#include <net/inet_sock.h>
13693 + * Check if a given address matches for a socket
13695 + * nxi: the socket's nx_info if any
13696 + * addr: to be verified address
13699 +int v4_sock_addr_match (
13700 + struct nx_info *nxi,
13701 + struct inet_sock *inet,
13704 + __be32 saddr = inet->rcv_saddr;
13705 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13707 + if (addr && (saddr == addr || bcast == addr))
13710 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13715 +/* inet related checks and helpers */
13719 +struct net_device;
13722 +#ifdef CONFIG_INET
13724 +#include <linux/netdevice.h>
13725 +#include <linux/inetdevice.h>
13726 +#include <net/inet_sock.h>
13727 +#include <net/inet_timewait_sock.h>
13730 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13731 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13732 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13736 + * check if address is covered by socket
13738 + * sk: the socket to check against
13739 + * addr: the address in question (must be != 0)
13743 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13745 + struct nx_info *nxi = sk->sk_nx_info;
13746 + __be32 saddr = inet_rcv_saddr(sk);
13748 + vxdprintk(VXD_CBIT(net, 5),
13749 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13750 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13751 + (sk->sk_socket?sk->sk_socket->flags:0));
13753 + if (saddr) { /* direct address match */
13754 + return v4_addr_match(nxa, saddr, -1);
13755 + } else if (nxi) { /* match against nx_info */
13756 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13757 + } else { /* unrestricted any socket */
13765 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13767 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13768 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13769 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13771 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13773 + if (dev_in_nx_info(dev, nxi))
13780 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13786 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13790 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13792 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13793 + nxi, nxi ? nxi->nx_id : 0, ifa,
13794 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13796 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13798 + if (v4_ifa_in_nx_info(ifa, nxi))
13804 +struct nx_v4_sock_addr {
13805 + __be32 saddr; /* Address used for validation */
13806 + __be32 baddr; /* Address used for socket bind */
13810 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13811 + struct nx_v4_sock_addr *nsa)
13813 + struct sock *sk = &inet->sk;
13814 + struct nx_info *nxi = sk->sk_nx_info;
13815 + __be32 saddr = addr->sin_addr.s_addr;
13816 + __be32 baddr = saddr;
13818 + vxdprintk(VXD_CBIT(net, 3),
13819 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13820 + sk, sk->sk_nx_info, sk->sk_socket,
13821 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13825 + if (saddr == INADDR_ANY) {
13826 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13827 + baddr = nxi->v4.ip[0].s_addr;
13828 + } else if (saddr == IPI_LOOPBACK) {
13829 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13830 + baddr = nxi->v4_lback.s_addr;
13831 + } else { /* normal address bind */
13832 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13833 + return -EADDRNOTAVAIL;
13837 + vxdprintk(VXD_CBIT(net, 3),
13838 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13839 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13841 + nsa->saddr = saddr;
13842 + nsa->baddr = baddr;
13847 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
13849 + inet->saddr = nsa->baddr;
13850 + inet->rcv_saddr = nsa->baddr;
13855 + * helper to simplify inet_lookup_listener
13857 + * nxi: the socket's nx_info if any
13858 + * addr: to be verified address
13859 + * saddr: socket address
13861 +static inline int v4_inet_addr_match (
13862 + struct nx_info *nxi,
13866 + if (addr && (saddr == addr))
13869 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
13873 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
13875 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
13876 + (addr == nxi->v4_lback.s_addr))
13877 + return IPI_LOOPBACK;
13882 +int nx_info_has_v4(struct nx_info *nxi)
13886 + if (NX_IPV4(nxi))
13888 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13893 +#else /* CONFIG_INET */
13896 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
13902 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13908 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13914 +int nx_info_has_v4(struct nx_info *nxi)
13919 +#endif /* CONFIG_INET */
13921 +#define current_nx_info_has_v4() \
13922 + nx_info_has_v4(current_nx_info())
13925 +// #warning duplicate inclusion
13927 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_limit.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_limit.h
13928 --- linux-2.6.32.24/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
13929 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_limit.h 2009-12-03 20:04:56.000000000 +0100
13931 +#ifndef _VS_LIMIT_H
13932 +#define _VS_LIMIT_H
13934 +#include "vserver/limit.h"
13935 +#include "vserver/base.h"
13936 +#include "vserver/context.h"
13937 +#include "vserver/debug.h"
13938 +#include "vserver/context.h"
13939 +#include "vserver/limit_int.h"
13942 +#define vx_acc_cres(v, d, p, r) \
13943 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13945 +#define vx_acc_cres_cond(x, d, p, r) \
13946 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13947 + r, d, p, __FILE__, __LINE__)
13950 +#define vx_add_cres(v, a, p, r) \
13951 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13952 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13954 +#define vx_add_cres_cond(x, a, p, r) \
13955 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13956 + r, a, p, __FILE__, __LINE__)
13957 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13960 +/* process and file limits */
13962 +#define vx_nproc_inc(p) \
13963 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13965 +#define vx_nproc_dec(p) \
13966 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13968 +#define vx_files_inc(f) \
13969 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13971 +#define vx_files_dec(f) \
13972 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13974 +#define vx_locks_inc(l) \
13975 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13977 +#define vx_locks_dec(l) \
13978 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13980 +#define vx_openfd_inc(f) \
13981 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
13983 +#define vx_openfd_dec(f) \
13984 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
13987 +#define vx_cres_avail(v, n, r) \
13988 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13991 +#define vx_nproc_avail(n) \
13992 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
13994 +#define vx_files_avail(n) \
13995 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
13997 +#define vx_locks_avail(n) \
13998 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
14000 +#define vx_openfd_avail(n) \
14001 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
14004 +/* dentry limits */
14006 +#define vx_dentry_inc(d) do { \
14007 + if (atomic_read(&d->d_count) == 1) \
14008 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
14011 +#define vx_dentry_dec(d) do { \
14012 + if (atomic_read(&d->d_count) == 0) \
14013 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
14016 +#define vx_dentry_avail(n) \
14017 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
14020 +/* socket limits */
14022 +#define vx_sock_inc(s) \
14023 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
14025 +#define vx_sock_dec(s) \
14026 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
14028 +#define vx_sock_avail(n) \
14029 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
14032 +/* ipc resource limits */
14034 +#define vx_ipcmsg_add(v, u, a) \
14035 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
14037 +#define vx_ipcmsg_sub(v, u, a) \
14038 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
14040 +#define vx_ipcmsg_avail(v, a) \
14041 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
14044 +#define vx_ipcshm_add(v, k, a) \
14045 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14047 +#define vx_ipcshm_sub(v, k, a) \
14048 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14050 +#define vx_ipcshm_avail(v, a) \
14051 + vx_cres_avail(v, a, VLIMIT_SHMEM)
14054 +#define vx_semary_inc(a) \
14055 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
14057 +#define vx_semary_dec(a) \
14058 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
14061 +#define vx_nsems_add(a,n) \
14062 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14064 +#define vx_nsems_sub(a,n) \
14065 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14069 +#warning duplicate inclusion
14071 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_memory.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_memory.h
14072 --- linux-2.6.32.24/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
14073 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_memory.h 2009-12-03 20:04:56.000000000 +0100
14075 +#ifndef _VS_MEMORY_H
14076 +#define _VS_MEMORY_H
14078 +#include "vserver/limit.h"
14079 +#include "vserver/base.h"
14080 +#include "vserver/context.h"
14081 +#include "vserver/debug.h"
14082 +#include "vserver/context.h"
14083 +#include "vserver/limit_int.h"
14086 +#define __acc_add_long(a, v) (*(v) += (a))
14087 +#define __acc_inc_long(v) (++*(v))
14088 +#define __acc_dec_long(v) (--*(v))
14090 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
14091 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
14092 +#define __acc_inc_atomic(v) atomic_long_inc(v)
14093 +#define __acc_dec_atomic(v) atomic_long_dec(v)
14094 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14095 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
14096 +#define __acc_inc_atomic(v) __acc_inc_long(v)
14097 +#define __acc_dec_atomic(v) __acc_dec_long(v)
14098 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14101 +#define vx_acc_page(m, d, v, r) do { \
14103 + __acc_inc_long(&(m)->v); \
14105 + __acc_dec_long(&(m)->v); \
14106 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14109 +#define vx_acc_page_atomic(m, d, v, r) do { \
14111 + __acc_inc_atomic(&(m)->v); \
14113 + __acc_dec_atomic(&(m)->v); \
14114 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14118 +#define vx_acc_pages(m, p, v, r) do { \
14119 + unsigned long __p = (p); \
14120 + __acc_add_long(__p, &(m)->v); \
14121 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14124 +#define vx_acc_pages_atomic(m, p, v, r) do { \
14125 + unsigned long __p = (p); \
14126 + __acc_add_atomic(__p, &(m)->v); \
14127 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14132 +#define vx_acc_vmpage(m, d) \
14133 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
14134 +#define vx_acc_vmlpage(m, d) \
14135 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
14136 +#define vx_acc_file_rsspage(m, d) \
14137 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
14138 +#define vx_acc_anon_rsspage(m, d) \
14139 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
14141 +#define vx_acc_vmpages(m, p) \
14142 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
14143 +#define vx_acc_vmlpages(m, p) \
14144 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
14145 +#define vx_acc_file_rsspages(m, p) \
14146 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
14147 +#define vx_acc_anon_rsspages(m, p) \
14148 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
14150 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
14151 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
14153 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
14154 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
14155 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
14156 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
14158 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
14159 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
14160 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
14161 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
14163 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
14164 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
14165 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
14166 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
14168 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
14169 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
14170 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
14171 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
14174 +#define vx_pages_avail(m, p, r) \
14175 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
14177 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
14178 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
14179 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
14180 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
14182 +#define vx_rss_avail(m, p) \
14183 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
14187 + VXPT_UNKNOWN = 0,
14196 +#define vx_page_fault(mm, vma, type, ret)
14200 +void __vx_page_fault(struct mm_struct *mm,
14201 + struct vm_area_struct *vma, int type, int ret)
14203 + struct vx_info *vxi = mm->mm_vx_info;
14206 + static char *page_type[6] =
14207 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14208 + static char *page_what[4] =
14209 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14215 + what = (ret & 0x3);
14217 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14218 + type, what, ret, page_type[type], page_what[what]);
14220 + if (ret & VM_FAULT_WRITE)
14222 + atomic_inc(&vxi->cacct.page[type][what]);
14225 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14229 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14232 +#warning duplicate inclusion
14234 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_network.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_network.h
14235 --- linux-2.6.32.24/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14236 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_network.h 2009-12-03 20:04:56.000000000 +0100
14238 +#ifndef _NX_VS_NETWORK_H
14239 +#define _NX_VS_NETWORK_H
14241 +#include "vserver/context.h"
14242 +#include "vserver/network.h"
14243 +#include "vserver/base.h"
14244 +#include "vserver/check.h"
14245 +#include "vserver/debug.h"
14247 +#include <linux/sched.h>
14250 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14252 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14253 + const char *_file, int _line)
14258 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14259 + nxi, nxi ? nxi->nx_id : 0,
14260 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14263 + atomic_inc(&nxi->nx_usecnt);
14268 +extern void free_nx_info(struct nx_info *);
14270 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14272 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14277 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14278 + nxi, nxi ? nxi->nx_id : 0,
14279 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14282 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14283 + free_nx_info(nxi);
14287 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14289 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14290 + const char *_file, int _line)
14293 + vxlprintk(VXD_CBIT(nid, 3),
14294 + "init_nx_info(%p[#%d.%d])",
14295 + nxi, nxi ? nxi->nx_id : 0,
14296 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14299 + atomic_inc(&nxi->nx_usecnt);
14305 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14307 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14308 + const char *_file, int _line)
14310 + struct nx_info *nxo;
14315 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14316 + nxi, nxi ? nxi->nx_id : 0,
14317 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14320 + atomic_inc(&nxi->nx_usecnt);
14321 + nxo = xchg(nxp, nxi);
14325 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14327 +static inline void __clr_nx_info(struct nx_info **nxp,
14328 + const char *_file, int _line)
14330 + struct nx_info *nxo;
14332 + nxo = xchg(nxp, NULL);
14336 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14337 + nxo, nxo ? nxo->nx_id : 0,
14338 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14341 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14342 + free_nx_info(nxo);
14346 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14348 +static inline void __claim_nx_info(struct nx_info *nxi,
14349 + struct task_struct *task, const char *_file, int _line)
14351 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14352 + nxi, nxi ? nxi->nx_id : 0,
14353 + nxi?atomic_read(&nxi->nx_usecnt):0,
14354 + nxi?atomic_read(&nxi->nx_tasks):0,
14355 + task, _file, _line);
14357 + atomic_inc(&nxi->nx_tasks);
14361 +extern void unhash_nx_info(struct nx_info *);
14363 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14365 +static inline void __release_nx_info(struct nx_info *nxi,
14366 + struct task_struct *task, const char *_file, int _line)
14368 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14369 + nxi, nxi ? nxi->nx_id : 0,
14370 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14371 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14372 + task, _file, _line);
14376 + if (atomic_dec_and_test(&nxi->nx_tasks))
14377 + unhash_nx_info(nxi);
14381 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14383 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14384 + const char *_file, int _line)
14386 + struct nx_info *nxi;
14389 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14390 + p, _file, _line);
14391 + nxi = __get_nx_info(p->nx_info, _file, _line);
14397 +static inline void exit_nx_info(struct task_struct *p)
14400 + release_nx_info(p->nx_info, p);
14405 +#warning duplicate inclusion
14407 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_pid.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_pid.h
14408 --- linux-2.6.32.24/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14409 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_pid.h 2009-12-03 20:04:56.000000000 +0100
14414 +#include "vserver/base.h"
14415 +#include "vserver/check.h"
14416 +#include "vserver/context.h"
14417 +#include "vserver/debug.h"
14418 +#include "vserver/pid.h"
14419 +#include <linux/pid_namespace.h>
14422 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14425 +int vx_proc_task_visible(struct task_struct *task)
14427 + if ((task->pid == 1) &&
14428 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14429 + /* show a blend through init */
14431 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14438 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14443 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14445 + struct task_struct *task = find_task_by_real_pid(pid);
14447 + if (task && !vx_proc_task_visible(task)) {
14448 + vxdprintk(VXD_CBIT(misc, 6),
14449 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14450 + task, task->xid, task->pid,
14451 + current, current->xid, current->pid);
14460 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14462 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14464 + if (task && !vx_proc_task_visible(task)) {
14465 + vxdprintk(VXD_CBIT(misc, 6),
14466 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14467 + task, task->xid, task->pid,
14468 + current, current->xid, current->pid);
14469 + put_task_struct(task);
14478 +struct task_struct *vx_child_reaper(struct task_struct *p)
14480 + struct vx_info *vxi = p->vx_info;
14481 + struct task_struct *reaper = child_reaper(p);
14486 + BUG_ON(!p->vx_info->vx_reaper);
14488 + /* child reaper for the guest reaper */
14489 + if (vxi->vx_reaper == p)
14492 + reaper = vxi->vx_reaper;
14494 + vxdprintk(VXD_CBIT(xid, 7),
14495 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14496 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14504 +#warning duplicate inclusion
14506 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_sched.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_sched.h
14507 --- linux-2.6.32.24/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14508 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_sched.h 2009-12-03 20:04:56.000000000 +0100
14510 +#ifndef _VS_SCHED_H
14511 +#define _VS_SCHED_H
14513 +#include "vserver/base.h"
14514 +#include "vserver/context.h"
14515 +#include "vserver/sched.h"
14518 +#define VAVAVOOM_RATIO 50
14520 +#define MAX_PRIO_BIAS 20
14521 +#define MIN_PRIO_BIAS -20
14524 +#ifdef CONFIG_VSERVER_HARDCPU
14527 + * effective_prio - return the priority that is based on the static
14528 + * priority but is modified by bonuses/penalties.
14530 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14531 + * into a -4 ... 0 ... +4 bonus/penalty range.
14533 + * Additionally, we scale another amount based on the number of
14534 + * CPU tokens currently held by the context, if the process is
14535 + * part of a context (and the appropriate SCHED flag is set).
14536 + * This ranges from -5 ... 0 ... +15, quadratically.
14538 + * So, the total bonus is -9 .. 0 .. +19
14539 + * We use ~50% of the full 0...39 priority range so that:
14541 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14542 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14543 + * unless that context is far exceeding its CPU allocation.
14545 + * Both properties are important to certain workloads.
14548 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14550 + int vavavoom, max;
14552 + /* lots of tokens = lots of vavavoom
14553 + * no tokens = no vavavoom */
14554 + if ((vavavoom = sched_pc->tokens) >= 0) {
14555 + max = sched_pc->tokens_max;
14556 + vavavoom = max - vavavoom;
14558 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14559 + * (vavavoom*vavavoom - (max >> 2)) / max;
14567 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14569 + struct vx_info *vxi = p->vx_info;
14570 + struct _vx_sched_pc *sched_pc;
14575 + sched_pc = &vx_cpu(vxi, sched_pc);
14576 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14577 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14579 + sched_pc->vavavoom = vavavoom;
14580 + prio += vavavoom;
14582 + prio += sched_pc->prio_bias;
14586 +#else /* !CONFIG_VSERVER_HARDCPU */
14589 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14591 + struct vx_info *vxi = p->vx_info;
14594 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14598 +#endif /* CONFIG_VSERVER_HARDCPU */
14601 +static inline void vx_account_user(struct vx_info *vxi,
14602 + cputime_t cputime, int nice)
14606 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14609 +static inline void vx_account_system(struct vx_info *vxi,
14610 + cputime_t cputime, int idle)
14614 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14618 +#warning duplicate inclusion
14620 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_socket.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_socket.h
14621 --- linux-2.6.32.24/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14622 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_socket.h 2009-12-03 20:04:56.000000000 +0100
14624 +#ifndef _VS_SOCKET_H
14625 +#define _VS_SOCKET_H
14627 +#include "vserver/debug.h"
14628 +#include "vserver/base.h"
14629 +#include "vserver/cacct.h"
14630 +#include "vserver/context.h"
14631 +#include "vserver/tag.h"
14634 +/* socket accounting */
14636 +#include <linux/socket.h>
14638 +static inline int vx_sock_type(int family)
14640 + switch (family) {
14642 + return VXA_SOCK_UNSPEC;
14644 + return VXA_SOCK_UNIX;
14646 + return VXA_SOCK_INET;
14648 + return VXA_SOCK_INET6;
14650 + return VXA_SOCK_PACKET;
14652 + return VXA_SOCK_OTHER;
14656 +#define vx_acc_sock(v, f, p, s) \
14657 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14659 +static inline void __vx_acc_sock(struct vx_info *vxi,
14660 + int family, int pos, int size, char *file, int line)
14663 + int type = vx_sock_type(family);
14665 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14666 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14670 +#define vx_sock_recv(sk, s) \
14671 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14672 +#define vx_sock_send(sk, s) \
14673 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14674 +#define vx_sock_fail(sk, s) \
14675 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14678 +#define sock_vx_init(s) do { \
14679 + (s)->sk_xid = 0; \
14680 + (s)->sk_vx_info = NULL; \
14683 +#define sock_nx_init(s) do { \
14684 + (s)->sk_nid = 0; \
14685 + (s)->sk_nx_info = NULL; \
14689 +#warning duplicate inclusion
14691 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_tag.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_tag.h
14692 --- linux-2.6.32.24/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14693 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_tag.h 2009-12-03 20:04:56.000000000 +0100
14698 +#include <linux/vserver/tag.h>
14700 +/* check conditions */
14702 +#define DX_ADMIN 0x0001
14703 +#define DX_WATCH 0x0002
14704 +#define DX_HOSTID 0x0008
14706 +#define DX_IDENT 0x0010
14708 +#define DX_ARG_MASK 0x0010
14711 +#define dx_task_tag(t) ((t)->tag)
14713 +#define dx_current_tag() dx_task_tag(current)
14715 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14717 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14721 + * check current context for ADMIN/WATCH and
14722 + * optionally against supplied argument
14724 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14726 + if (mode & DX_ARG_MASK) {
14727 + if ((mode & DX_IDENT) && (id == cid))
14730 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14731 + ((mode & DX_WATCH) && (cid == 1)) ||
14732 + ((mode & DX_HOSTID) && (id == 0)));
14736 +int dx_permission(const struct inode *inode, int mask);
14740 +#warning duplicate inclusion
14742 diff -NurpP --minimal linux-2.6.32.24/include/linux/vs_time.h linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_time.h
14743 --- linux-2.6.32.24/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14744 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/linux/vs_time.h 2009-12-03 20:04:56.000000000 +0100
14746 +#ifndef _VS_TIME_H
14747 +#define _VS_TIME_H
14750 +/* time faking stuff */
14752 +#ifdef CONFIG_VSERVER_VTIME
14754 +extern void vx_gettimeofday(struct timeval *tv);
14755 +extern int vx_settimeofday(struct timespec *ts);
14758 +#define vx_gettimeofday(t) do_gettimeofday(t)
14759 +#define vx_settimeofday(t) do_settimeofday(t)
14763 +#warning duplicate inclusion
14765 diff -NurpP --minimal linux-2.6.32.24/include/net/addrconf.h linux-2.6.32.24-vs2.3.0.36.29.6/include/net/addrconf.h
14766 --- linux-2.6.32.24/include/net/addrconf.h 2009-12-03 20:02:57.000000000 +0100
14767 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/net/addrconf.h 2009-12-03 20:04:56.000000000 +0100
14768 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14769 struct net_device *dev,
14770 const struct in6_addr *daddr,
14771 unsigned int srcprefs,
14772 - struct in6_addr *saddr);
14773 + struct in6_addr *saddr,
14774 + struct nx_info *nxi);
14775 extern int ipv6_get_lladdr(struct net_device *dev,
14776 struct in6_addr *addr,
14777 unsigned char banned_flags);
14778 diff -NurpP --minimal linux-2.6.32.24/include/net/af_unix.h linux-2.6.32.24-vs2.3.0.36.29.6/include/net/af_unix.h
14779 --- linux-2.6.32.24/include/net/af_unix.h 2008-12-25 00:26:37.000000000 +0100
14780 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/net/af_unix.h 2009-12-03 20:04:56.000000000 +0100
14782 #include <linux/socket.h>
14783 #include <linux/un.h>
14784 #include <linux/mutex.h>
14785 +#include <linux/vs_base.h>
14786 #include <net/sock.h>
14788 extern void unix_inflight(struct file *fp);
14789 diff -NurpP --minimal linux-2.6.32.24/include/net/inet_timewait_sock.h linux-2.6.32.24-vs2.3.0.36.29.6/include/net/inet_timewait_sock.h
14790 --- linux-2.6.32.24/include/net/inet_timewait_sock.h 2009-12-03 20:02:57.000000000 +0100
14791 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/net/inet_timewait_sock.h 2009-12-03 20:04:56.000000000 +0100
14792 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
14793 #define tw_hash __tw_common.skc_hash
14794 #define tw_prot __tw_common.skc_prot
14795 #define tw_net __tw_common.skc_net
14796 +#define tw_xid __tw_common.skc_xid
14797 +#define tw_vx_info __tw_common.skc_vx_info
14798 +#define tw_nid __tw_common.skc_nid
14799 +#define tw_nx_info __tw_common.skc_nx_info
14801 volatile unsigned char tw_substate;
14802 /* 3 bits hole, try to pack */
14803 diff -NurpP --minimal linux-2.6.32.24/include/net/route.h linux-2.6.32.24-vs2.3.0.36.29.6/include/net/route.h
14804 --- linux-2.6.32.24/include/net/route.h 2009-09-10 15:26:27.000000000 +0200
14805 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/net/route.h 2009-12-03 20:04:56.000000000 +0100
14806 @@ -135,6 +135,9 @@ static inline void ip_rt_put(struct rtab
14807 dst_release(&rt->u.dst);
14810 +#include <linux/vs_base.h>
14811 +#include <linux/vs_inet.h>
14813 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14815 extern const __u8 ip_tos2prio[16];
14816 @@ -144,6 +147,9 @@ static inline char rt_tos2priority(u8 to
14817 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14820 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14821 + struct rtable **, struct flowi *);
14823 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14824 __be32 src, u32 tos, int oif, u8 protocol,
14825 __be16 sport, __be16 dport, struct sock *sk,
14826 @@ -161,11 +167,24 @@ static inline int ip_route_connect(struc
14829 struct net *net = sock_net(sk);
14830 + struct nx_info *nx_info = current_nx_info();
14832 if (inet_sk(sk)->transparent)
14833 fl.flags |= FLOWI_FLAG_ANYSRC;
14835 - if (!dst || !src) {
14837 + nx_info = sk->sk_nx_info;
14839 + vxdprintk(VXD_CBIT(net, 4),
14840 + "ip_route_connect(%p) %p,%p;%lx",
14841 + sk, nx_info, sk->sk_socket,
14842 + (sk->sk_socket?sk->sk_socket->flags:0));
14844 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14848 + if (!fl.fl4_dst || !fl.fl4_src) {
14849 err = __ip_route_output_key(net, rp, &fl);
14852 diff -NurpP --minimal linux-2.6.32.24/include/net/sock.h linux-2.6.32.24-vs2.3.0.36.29.6/include/net/sock.h
14853 --- linux-2.6.32.24/include/net/sock.h 2009-12-03 20:02:57.000000000 +0100
14854 +++ linux-2.6.32.24-vs2.3.0.36.29.6/include/net/sock.h 2009-12-03 20:04:56.000000000 +0100
14855 @@ -139,6 +139,10 @@ struct sock_common {
14856 #ifdef CONFIG_NET_NS
14857 struct net *skc_net;
14860 + struct vx_info *skc_vx_info;
14862 + struct nx_info *skc_nx_info;
14866 @@ -225,6 +229,10 @@ struct sock {
14867 #define sk_bind_node __sk_common.skc_bind_node
14868 #define sk_prot __sk_common.skc_prot
14869 #define sk_net __sk_common.skc_net
14870 +#define sk_xid __sk_common.skc_xid
14871 +#define sk_vx_info __sk_common.skc_vx_info
14872 +#define sk_nid __sk_common.skc_nid
14873 +#define sk_nx_info __sk_common.skc_nx_info
14874 kmemcheck_bitfield_begin(flags);
14875 unsigned int sk_shutdown : 2,
14877 diff -NurpP --minimal linux-2.6.32.24/init/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/init/Kconfig
14878 --- linux-2.6.32.24/init/Kconfig 2009-12-03 20:02:57.000000000 +0100
14879 +++ linux-2.6.32.24-vs2.3.0.36.29.6/init/Kconfig 2009-12-03 20:04:56.000000000 +0100
14880 @@ -477,6 +477,19 @@ config CGROUP_SCHED
14884 +config CFS_HARD_LIMITS
14885 + bool "Hard Limits for CFS Group Scheduler"
14886 + depends on EXPERIMENTAL
14887 + depends on FAIR_GROUP_SCHED && CGROUP_SCHED
14890 + This option enables hard limiting of CPU time obtained by
14891 + a fair task group. Use this if you want to throttle a group of tasks
14892 + based on its CPU usage. For more details refer to
14893 + Documentation/scheduler/sched-cfs-hard-limits.txt
14898 boolean "Control Group support"
14900 diff -NurpP --minimal linux-2.6.32.24/init/main.c linux-2.6.32.24-vs2.3.0.36.29.6/init/main.c
14901 --- linux-2.6.32.24/init/main.c 2010-10-04 08:56:17.000000000 +0200
14902 +++ linux-2.6.32.24-vs2.3.0.36.29.6/init/main.c 2010-04-05 20:56:22.000000000 +0200
14904 #include <linux/sfi.h>
14905 #include <linux/shmem_fs.h>
14906 #include <trace/boot.h>
14907 +#include <linux/vserver/percpu.h>
14909 #include <asm/io.h>
14910 #include <asm/bugs.h>
14911 diff -NurpP --minimal linux-2.6.32.24/ipc/mqueue.c linux-2.6.32.24-vs2.3.0.36.29.6/ipc/mqueue.c
14912 --- linux-2.6.32.24/ipc/mqueue.c 2010-10-04 08:56:17.000000000 +0200
14913 +++ linux-2.6.32.24-vs2.3.0.36.29.6/ipc/mqueue.c 2010-04-05 20:56:22.000000000 +0200
14915 #include <linux/pid.h>
14916 #include <linux/ipc_namespace.h>
14917 #include <linux/ima.h>
14918 +#include <linux/vs_context.h>
14919 +#include <linux/vs_limit.h>
14921 #include <net/sock.h>
14923 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14924 struct sigevent notify;
14925 struct pid* notify_owner;
14926 struct user_struct *user; /* user who created, for accounting */
14927 + struct vx_info *vxi;
14928 struct sock *notify_sock;
14929 struct sk_buff *notify_cookie;
14931 @@ -125,6 +128,7 @@ static struct inode *mqueue_get_inode(st
14932 if (S_ISREG(mode)) {
14933 struct mqueue_inode_info *info;
14934 struct task_struct *p = current;
14935 + struct vx_info *vxi = p->vx_info;
14936 unsigned long mq_bytes, mq_msg_tblsz;
14938 inode->i_fop = &mqueue_file_operations;
14939 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
14940 info->notify_owner = NULL;
14942 info->user = NULL; /* set when all is ok */
14943 + info->vxi = NULL;
14944 memset(&info->attr, 0, sizeof(info->attr));
14945 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14946 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14947 @@ -153,22 +158,26 @@ static struct inode *mqueue_get_inode(st
14948 spin_lock(&mq_lock);
14949 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14950 u->mq_bytes + mq_bytes >
14951 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
14952 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
14953 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14954 spin_unlock(&mq_lock);
14957 u->mq_bytes += mq_bytes;
14958 + vx_ipcmsg_add(vxi, u, mq_bytes);
14959 spin_unlock(&mq_lock);
14961 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
14962 if (!info->messages) {
14963 spin_lock(&mq_lock);
14964 u->mq_bytes -= mq_bytes;
14965 + vx_ipcmsg_sub(vxi, u, mq_bytes);
14966 spin_unlock(&mq_lock);
14970 info->user = get_uid(u);
14971 + info->vxi = get_vx_info(vxi);
14972 } else if (S_ISDIR(mode)) {
14974 /* Some things misbehave if size == 0 on a directory */
14975 @@ -269,8 +278,11 @@ static void mqueue_delete_inode(struct i
14976 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
14979 + struct vx_info *vxi = info->vxi;
14981 spin_lock(&mq_lock);
14982 user->mq_bytes -= mq_bytes;
14983 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14985 * get_ns_from_inode() ensures that the
14986 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14987 @@ -280,6 +292,7 @@ static void mqueue_delete_inode(struct i
14989 ipc_ns->mq_queues_count--;
14990 spin_unlock(&mq_lock);
14991 + put_vx_info(vxi);
14995 diff -NurpP --minimal linux-2.6.32.24/ipc/msg.c linux-2.6.32.24-vs2.3.0.36.29.6/ipc/msg.c
14996 --- linux-2.6.32.24/ipc/msg.c 2010-10-04 08:56:17.000000000 +0200
14997 +++ linux-2.6.32.24-vs2.3.0.36.29.6/ipc/msg.c 2010-02-12 10:59:55.000000000 +0100
14999 #include <linux/rwsem.h>
15000 #include <linux/nsproxy.h>
15001 #include <linux/ipc_namespace.h>
15002 +#include <linux/vs_base.h>
15004 #include <asm/current.h>
15005 #include <asm/uaccess.h>
15006 @@ -191,6 +192,7 @@ static int newque(struct ipc_namespace *
15008 msq->q_perm.mode = msgflg & S_IRWXUGO;
15009 msq->q_perm.key = key;
15010 + msq->q_perm.xid = vx_current_xid();
15012 msq->q_perm.security = NULL;
15013 retval = security_msg_queue_alloc(msq);
15014 diff -NurpP --minimal linux-2.6.32.24/ipc/namespace.c linux-2.6.32.24-vs2.3.0.36.29.6/ipc/namespace.c
15015 --- linux-2.6.32.24/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
15016 +++ linux-2.6.32.24-vs2.3.0.36.29.6/ipc/namespace.c 2009-12-03 20:04:56.000000000 +0100
15018 #include <linux/slab.h>
15019 #include <linux/fs.h>
15020 #include <linux/mount.h>
15021 +#include <linux/vs_base.h>
15022 +#include <linux/vserver/global.h>
15026 diff -NurpP --minimal linux-2.6.32.24/ipc/sem.c linux-2.6.32.24-vs2.3.0.36.29.6/ipc/sem.c
15027 --- linux-2.6.32.24/ipc/sem.c 2010-10-04 08:56:17.000000000 +0200
15028 +++ linux-2.6.32.24-vs2.3.0.36.29.6/ipc/sem.c 2010-02-12 10:59:55.000000000 +0100
15030 #include <linux/rwsem.h>
15031 #include <linux/nsproxy.h>
15032 #include <linux/ipc_namespace.h>
15033 +#include <linux/vs_base.h>
15034 +#include <linux/vs_limit.h>
15036 #include <asm/uaccess.h>
15038 @@ -256,6 +258,7 @@ static int newary(struct ipc_namespace *
15040 sma->sem_perm.mode = (semflg & S_IRWXUGO);
15041 sma->sem_perm.key = key;
15042 + sma->sem_perm.xid = vx_current_xid();
15044 sma->sem_perm.security = NULL;
15045 retval = security_sem_alloc(sma);
15046 @@ -271,6 +274,9 @@ static int newary(struct ipc_namespace *
15049 ns->used_sems += nsems;
15050 + /* FIXME: obsoleted? */
15051 + vx_semary_inc(sma);
15052 + vx_nsems_add(sma, nsems);
15054 sma->sem_base = (struct sem *) &sma[1];
15055 INIT_LIST_HEAD(&sma->sem_pending);
15056 @@ -547,6 +553,9 @@ static void freeary(struct ipc_namespace
15059 ns->used_sems -= sma->sem_nsems;
15060 + /* FIXME: obsoleted? */
15061 + vx_nsems_sub(sma, sma->sem_nsems);
15062 + vx_semary_dec(sma);
15063 security_sem_free(sma);
15064 ipc_rcu_putref(sma);
15066 diff -NurpP --minimal linux-2.6.32.24/ipc/shm.c linux-2.6.32.24-vs2.3.0.36.29.6/ipc/shm.c
15067 --- linux-2.6.32.24/ipc/shm.c 2010-10-04 08:56:17.000000000 +0200
15068 +++ linux-2.6.32.24-vs2.3.0.36.29.6/ipc/shm.c 2010-02-12 10:59:55.000000000 +0100
15070 #include <linux/mount.h>
15071 #include <linux/ipc_namespace.h>
15072 #include <linux/ima.h>
15073 +#include <linux/vs_context.h>
15074 +#include <linux/vs_limit.h>
15076 #include <asm/uaccess.h>
15078 @@ -170,7 +172,12 @@ static void shm_open(struct vm_area_stru
15080 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15082 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15083 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15084 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15086 + vx_ipcshm_sub(vxi, shp, numpages);
15087 + ns->shm_tot -= numpages;
15091 if (!is_file_hugepages(shp->shm_file))
15092 @@ -180,6 +187,7 @@ static void shm_destroy(struct ipc_names
15094 fput (shp->shm_file);
15095 security_shm_free(shp);
15096 + put_vx_info(vxi);
15097 ipc_rcu_putref(shp);
15100 @@ -350,11 +358,15 @@ static int newseg(struct ipc_namespace *
15101 if (ns->shm_tot + numpages > ns->shm_ctlall)
15104 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
15107 shp = ipc_rcu_alloc(sizeof(*shp));
15111 shp->shm_perm.key = key;
15112 + shp->shm_perm.xid = vx_current_xid();
15113 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15114 shp->mlock_user = NULL;
15116 @@ -408,6 +420,7 @@ static int newseg(struct ipc_namespace *
15117 ns->shm_tot += numpages;
15118 error = shp->shm_perm.id;
15120 + vx_ipcshm_add(current_vx_info(), key, numpages);
15124 diff -NurpP --minimal linux-2.6.32.24/kernel/capability.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/capability.c
15125 --- linux-2.6.32.24/kernel/capability.c 2009-03-24 14:22:44.000000000 +0100
15126 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/capability.c 2009-12-03 20:04:56.000000000 +0100
15128 #include <linux/security.h>
15129 #include <linux/syscalls.h>
15130 #include <linux/pid_namespace.h>
15131 +#include <linux/vs_context.h>
15132 #include <asm/uaccess.h>
15133 #include "cred-internals.h"
15135 @@ -122,6 +123,7 @@ static int cap_validate_magic(cap_user_h
15141 * The only thing that can change the capabilities of the current
15142 * process is the current process. As such, we can't be in this code
15143 @@ -289,6 +291,8 @@ error:
15147 +#include <linux/vserver/base.h>
15150 * capable - Determine if the current task has a superior capability in effect
15151 * @cap: The capability to be tested for
15152 @@ -301,6 +305,9 @@ error:
15154 int capable(int cap)
15156 + /* here for now so we don't require task locking */
15157 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15159 if (unlikely(!cap_valid(cap))) {
15160 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
15162 diff -NurpP --minimal linux-2.6.32.24/kernel/compat.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/compat.c
15163 --- linux-2.6.32.24/kernel/compat.c 2010-10-04 08:56:18.000000000 +0200
15164 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/compat.c 2010-09-22 00:48:38.000000000 +0200
15165 @@ -900,7 +900,7 @@ asmlinkage long compat_sys_time(compat_t
15169 - do_gettimeofday(&tv);
15170 + vx_gettimeofday(&tv);
15174 @@ -925,7 +925,7 @@ asmlinkage long compat_sys_stime(compat_
15178 - do_settimeofday(&tv);
15179 + vx_settimeofday(&tv);
15183 diff -NurpP --minimal linux-2.6.32.24/kernel/exit.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/exit.c
15184 --- linux-2.6.32.24/kernel/exit.c 2010-10-04 08:56:18.000000000 +0200
15185 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/exit.c 2010-10-04 10:04:57.000000000 +0200
15187 #include <linux/fs_struct.h>
15188 #include <linux/init_task.h>
15189 #include <linux/perf_event.h>
15190 +#include <linux/vs_limit.h>
15191 +#include <linux/vs_context.h>
15192 +#include <linux/vs_network.h>
15193 +#include <linux/vs_pid.h>
15194 #include <trace/events/sched.h>
15196 #include <asm/uaccess.h>
15197 @@ -488,9 +492,11 @@ static void close_files(struct files_str
15198 filp_close(file, files);
15201 + vx_openfd_dec(i);
15209 @@ -1011,11 +1017,16 @@ NORET_TYPE void do_exit(long code)
15211 validate_creds_for_do_exit(tsk);
15213 + /* needs to stay after exit_notify() */
15214 + exit_vx_info(tsk, code);
15215 + exit_nx_info(tsk);
15219 /* causes final put_task_struct in finish_task_switch(). */
15220 tsk->state = TASK_DEAD;
15222 + printk("bad task: %p [%lx]\n", current, current->state);
15224 /* Avoid "noreturn function does return". */
15226 diff -NurpP --minimal linux-2.6.32.24/kernel/fork.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/fork.c
15227 --- linux-2.6.32.24/kernel/fork.c 2010-10-04 08:56:18.000000000 +0200
15228 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/fork.c 2010-09-22 00:48:38.000000000 +0200
15230 #include <linux/magic.h>
15231 #include <linux/perf_event.h>
15232 #include <linux/posix-timers.h>
15233 +#include <linux/vs_context.h>
15234 +#include <linux/vs_network.h>
15235 +#include <linux/vs_limit.h>
15236 +#include <linux/vs_memory.h>
15238 #include <asm/pgtable.h>
15239 #include <asm/pgalloc.h>
15240 @@ -151,6 +155,8 @@ void free_task(struct task_struct *tsk)
15241 account_kernel_stack(tsk->stack, -1);
15242 free_thread_info(tsk->stack);
15243 rt_mutex_debug_task_free(tsk);
15244 + clr_vx_info(&tsk->vx_info);
15245 + clr_nx_info(&tsk->nx_info);
15246 ftrace_graph_exit_task(tsk);
15247 free_task_struct(tsk);
15249 @@ -296,6 +302,8 @@ static int dup_mmap(struct mm_struct *mm
15250 mm->free_area_cache = oldmm->mmap_base;
15251 mm->cached_hole_size = ~0UL;
15253 + __set_mm_counter(mm, file_rss, 0);
15254 + __set_mm_counter(mm, anon_rss, 0);
15255 cpumask_clear(mm_cpumask(mm));
15256 mm->mm_rb = RB_ROOT;
15257 rb_link = &mm->mm_rb.rb_node;
15258 @@ -311,7 +319,7 @@ static int dup_mmap(struct mm_struct *mm
15260 if (mpnt->vm_flags & VM_DONTCOPY) {
15261 long pages = vma_pages(mpnt);
15262 - mm->total_vm -= pages;
15263 + vx_vmpages_sub(mm, pages);
15264 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15267 @@ -455,8 +463,8 @@ static struct mm_struct * mm_init(struct
15268 (current->mm->flags & MMF_INIT_MASK) : default_dump_filter;
15269 mm->core_state = NULL;
15271 - set_mm_counter(mm, file_rss, 0);
15272 - set_mm_counter(mm, anon_rss, 0);
15273 + __set_mm_counter(mm, file_rss, 0);
15274 + __set_mm_counter(mm, anon_rss, 0);
15275 spin_lock_init(&mm->page_table_lock);
15276 mm->free_area_cache = TASK_UNMAPPED_BASE;
15277 mm->cached_hole_size = ~0UL;
15278 @@ -466,6 +474,7 @@ static struct mm_struct * mm_init(struct
15279 if (likely(!mm_alloc_pgd(mm))) {
15281 mmu_notifier_mm_init(mm);
15282 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15286 @@ -499,6 +508,7 @@ void __mmdrop(struct mm_struct *mm)
15288 destroy_context(mm);
15289 mmu_notifier_mm_destroy(mm);
15290 + clr_vx_info(&mm->mm_vx_info);
15293 EXPORT_SYMBOL_GPL(__mmdrop);
15294 @@ -634,6 +644,7 @@ struct mm_struct *dup_mm(struct task_str
15297 memcpy(mm, oldmm, sizeof(*mm));
15298 + mm->mm_vx_info = NULL;
15300 /* Initializing for Swap token stuff */
15301 mm->token_priority = 0;
15302 @@ -672,6 +683,7 @@ fail_nocontext:
15303 * If init_new_context() failed, we cannot use mmput() to free the mm
15304 * because it calls destroy_context()
15306 + clr_vx_info(&mm->mm_vx_info);
15310 @@ -986,6 +998,8 @@ static struct task_struct *copy_process(
15312 struct task_struct *p;
15313 int cgroup_callbacks_done = 0;
15314 + struct vx_info *vxi;
15315 + struct nx_info *nxi;
15317 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15318 return ERR_PTR(-EINVAL);
15319 @@ -1032,12 +1046,28 @@ static struct task_struct *copy_process(
15320 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15321 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15323 + init_vx_info(&p->vx_info, current_vx_info());
15324 + init_nx_info(&p->nx_info, current_nx_info());
15326 + /* check vserver memory */
15327 + if (p->mm && !(clone_flags & CLONE_VM)) {
15328 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15329 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15331 + goto bad_fork_free;
15333 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15334 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15335 + goto bad_fork_cleanup_vm;
15338 + if (!vx_nproc_avail(1))
15339 + goto bad_fork_cleanup_vm;
15340 if (atomic_read(&p->real_cred->user->processes) >=
15341 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15342 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15343 p->real_cred->user != INIT_USER)
15344 - goto bad_fork_free;
15345 + goto bad_fork_cleanup_vm;
15348 retval = copy_creds(p, clone_flags);
15349 @@ -1289,6 +1319,18 @@ static struct task_struct *copy_process(
15352 spin_unlock(¤t->sighand->siglock);
15354 + /* p is copy of current */
15355 + vxi = p->vx_info;
15357 + claim_vx_info(vxi, p);
15358 + atomic_inc(&vxi->cvirt.nr_threads);
15359 + atomic_inc(&vxi->cvirt.total_forks);
15362 + nxi = p->nx_info;
15364 + claim_nx_info(nxi, p);
15365 write_unlock_irq(&tasklist_lock);
15366 proc_fork_connector(p);
15367 cgroup_post_fork(p);
15368 @@ -1330,6 +1372,9 @@ bad_fork_cleanup_cgroup:
15369 bad_fork_cleanup_count:
15370 atomic_dec(&p->cred->user->processes);
15372 +bad_fork_cleanup_vm:
15373 + if (p->mm && !(clone_flags & CLONE_VM))
15374 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15378 diff -NurpP --minimal linux-2.6.32.24/kernel/kthread.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/kthread.c
15379 --- linux-2.6.32.24/kernel/kthread.c 2010-10-04 08:56:18.000000000 +0200
15380 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/kthread.c 2010-04-05 20:56:22.000000000 +0200
15382 #include <linux/file.h>
15383 #include <linux/module.h>
15384 #include <linux/mutex.h>
15385 +#include <linux/vs_pid.h>
15386 #include <trace/events/sched.h>
15388 static DEFINE_SPINLOCK(kthread_create_lock);
15389 diff -NurpP --minimal linux-2.6.32.24/kernel/Makefile linux-2.6.32.24-vs2.3.0.36.29.6/kernel/Makefile
15390 --- linux-2.6.32.24/kernel/Makefile 2009-12-03 20:02:57.000000000 +0100
15391 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/Makefile 2009-12-03 20:04:56.000000000 +0100
15392 @@ -23,6 +23,7 @@ CFLAGS_REMOVE_cgroup-debug.o = -pg
15393 CFLAGS_REMOVE_sched_clock.o = -pg
15397 obj-$(CONFIG_FREEZER) += freezer.o
15398 obj-$(CONFIG_PROFILING) += profile.o
15399 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15400 diff -NurpP --minimal linux-2.6.32.24/kernel/nsproxy.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/nsproxy.c
15401 --- linux-2.6.32.24/kernel/nsproxy.c 2009-09-10 15:26:28.000000000 +0200
15402 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/nsproxy.c 2009-12-03 20:04:56.000000000 +0100
15404 #include <linux/mnt_namespace.h>
15405 #include <linux/utsname.h>
15406 #include <linux/pid_namespace.h>
15407 +#include <linux/vserver/global.h>
15408 +#include <linux/vserver/debug.h>
15409 #include <net/net_namespace.h>
15410 #include <linux/ipc_namespace.h>
15412 @@ -31,8 +33,11 @@ static inline struct nsproxy *create_nsp
15413 struct nsproxy *nsproxy;
15415 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15418 atomic_set(&nsproxy->count, 1);
15419 + atomic_inc(&vs_global_nsproxy);
15421 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15425 @@ -41,41 +46,52 @@ static inline struct nsproxy *create_nsp
15426 * Return the newly created nsproxy. Do not attach this to the task,
15427 * leave it to the caller to do proper locking and attach it to task.
15429 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15430 - struct task_struct *tsk, struct fs_struct *new_fs)
15431 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15432 + struct nsproxy *orig, struct fs_struct *new_fs)
15434 struct nsproxy *new_nsp;
15437 + vxdprintk(VXD_CBIT(space, 4),
15438 + "unshare_namespaces(0x%08lx,%p,%p)",
15439 + flags, orig, new_fs);
15441 new_nsp = create_nsproxy();
15443 return ERR_PTR(-ENOMEM);
15445 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15446 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15447 if (IS_ERR(new_nsp->mnt_ns)) {
15448 err = PTR_ERR(new_nsp->mnt_ns);
15452 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15453 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15454 if (IS_ERR(new_nsp->uts_ns)) {
15455 err = PTR_ERR(new_nsp->uts_ns);
15459 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15460 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15461 if (IS_ERR(new_nsp->ipc_ns)) {
15462 err = PTR_ERR(new_nsp->ipc_ns);
15466 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15467 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15468 if (IS_ERR(new_nsp->pid_ns)) {
15469 err = PTR_ERR(new_nsp->pid_ns);
15473 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15475 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15476 + if (IS_ERR(new_nsp->user_ns)) {
15477 + err = PTR_ERR(new_nsp->user_ns);
15481 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15482 if (IS_ERR(new_nsp->net_ns)) {
15483 err = PTR_ERR(new_nsp->net_ns);
15485 @@ -100,6 +116,38 @@ out_ns:
15486 return ERR_PTR(err);
15489 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15490 + struct fs_struct *new_fs)
15492 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15496 + * copies the nsproxy, setting refcount to 1, and grabbing a
15497 + * reference to all contained namespaces.
15499 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15501 + struct nsproxy *ns = create_nsproxy();
15504 + memcpy(ns, orig, sizeof(struct nsproxy));
15505 + atomic_set(&ns->count, 1);
15508 + get_mnt_ns(ns->mnt_ns);
15510 + get_uts_ns(ns->uts_ns);
15512 + get_ipc_ns(ns->ipc_ns);
15514 + get_pid_ns(ns->pid_ns);
15516 + get_net(ns->net_ns);
15522 * called from clone. This now handles copy for nsproxy and all
15523 * namespaces therein.
15524 @@ -107,9 +155,12 @@ out_ns:
15525 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15527 struct nsproxy *old_ns = tsk->nsproxy;
15528 - struct nsproxy *new_ns;
15529 + struct nsproxy *new_ns = NULL;
15532 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15533 + flags, tsk, old_ns);
15538 @@ -119,7 +170,7 @@ int copy_namespaces(unsigned long flags,
15539 CLONE_NEWPID | CLONE_NEWNET)))
15542 - if (!capable(CAP_SYS_ADMIN)) {
15543 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15547 @@ -146,6 +197,9 @@ int copy_namespaces(unsigned long flags,
15550 put_nsproxy(old_ns);
15551 + vxdprintk(VXD_CBIT(space, 3),
15552 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15553 + flags, tsk, old_ns, err, new_ns);
15557 @@ -159,7 +213,9 @@ void free_nsproxy(struct nsproxy *ns)
15558 put_ipc_ns(ns->ipc_ns);
15560 put_pid_ns(ns->pid_ns);
15561 - put_net(ns->net_ns);
15563 + put_net(ns->net_ns);
15564 + atomic_dec(&vs_global_nsproxy);
15565 kmem_cache_free(nsproxy_cachep, ns);
15568 @@ -172,11 +228,15 @@ int unshare_nsproxy_namespaces(unsigned
15572 + vxdprintk(VXD_CBIT(space, 4),
15573 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15574 + unshare_flags, current->nsproxy);
15576 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15580 - if (!capable(CAP_SYS_ADMIN))
15581 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15584 *new_nsp = create_new_namespaces(unshare_flags, current,
15585 diff -NurpP --minimal linux-2.6.32.24/kernel/pid.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/pid.c
15586 --- linux-2.6.32.24/kernel/pid.c 2009-12-03 20:02:58.000000000 +0100
15587 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/pid.c 2009-12-03 20:04:56.000000000 +0100
15589 #include <linux/pid_namespace.h>
15590 #include <linux/init_task.h>
15591 #include <linux/syscalls.h>
15592 +#include <linux/vs_pid.h>
15594 #define pid_hashfn(nr, ns) \
15595 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15596 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15598 struct pid *find_vpid(int nr)
15600 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15601 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15603 EXPORT_SYMBOL_GPL(find_vpid);
15605 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
15606 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15608 struct task_struct *result = NULL;
15610 + if (type == PIDTYPE_REALPID)
15611 + type = PIDTYPE_PID;
15613 struct hlist_node *first;
15614 first = rcu_dereference(pid->tasks[type].first);
15615 @@ -380,7 +384,7 @@ EXPORT_SYMBOL(pid_task);
15617 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15619 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15620 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15623 struct task_struct *find_task_by_vpid(pid_t vnr)
15624 @@ -422,7 +426,7 @@ struct pid *find_get_pid(pid_t nr)
15626 EXPORT_SYMBOL_GPL(find_get_pid);
15628 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15629 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15633 @@ -435,6 +439,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15637 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15639 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15642 pid_t pid_vnr(struct pid *pid)
15644 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15645 diff -NurpP --minimal linux-2.6.32.24/kernel/pid_namespace.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/pid_namespace.c
15646 --- linux-2.6.32.24/kernel/pid_namespace.c 2009-12-03 20:02:58.000000000 +0100
15647 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/pid_namespace.c 2009-12-03 20:04:56.000000000 +0100
15649 #include <linux/syscalls.h>
15650 #include <linux/err.h>
15651 #include <linux/acct.h>
15652 +#include <linux/vserver/global.h>
15654 #define BITS_PER_PAGE (PAGE_SIZE*8)
15656 @@ -86,6 +87,7 @@ static struct pid_namespace *create_pid_
15659 kref_init(&ns->kref);
15660 + atomic_inc(&vs_global_pid_ns);
15662 ns->parent = get_pid_ns(parent_pid_ns);
15664 @@ -111,6 +113,7 @@ static void destroy_pid_namespace(struct
15666 for (i = 0; i < PIDMAP_ENTRIES; i++)
15667 kfree(ns->pidmap[i].page);
15668 + atomic_dec(&vs_global_pid_ns);
15669 kmem_cache_free(pid_ns_cachep, ns);
15672 diff -NurpP --minimal linux-2.6.32.24/kernel/posix-timers.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/posix-timers.c
15673 --- linux-2.6.32.24/kernel/posix-timers.c 2010-10-04 08:56:18.000000000 +0200
15674 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/posix-timers.c 2010-07-08 02:22:31.000000000 +0200
15676 #include <linux/wait.h>
15677 #include <linux/workqueue.h>
15678 #include <linux/module.h>
15679 +#include <linux/vs_context.h>
15682 * Management arrays for POSIX timers. Timers are kept in slab memory
15683 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
15685 struct task_struct *task;
15686 int shared, ret = -1;
15689 * FIXME: if ->sigq is queued we can race with
15690 * dequeue_signal()->do_schedule_next_timer().
15691 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
15693 task = pid_task(timr->it_pid, PIDTYPE_PID);
15695 + struct vx_info_save vxis;
15696 + struct vx_info *vxi;
15698 + vxi = get_vx_info(task->vx_info);
15699 + enter_vx_info(vxi, &vxis);
15700 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15701 ret = send_sigqueue(timr->sigq, task, shared);
15702 + leave_vx_info(&vxis);
15703 + put_vx_info(vxi);
15707 /* If we failed to send the signal the timer stops. */
15710 diff -NurpP --minimal linux-2.6.32.24/kernel/printk.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/printk.c
15711 --- linux-2.6.32.24/kernel/printk.c 2009-12-03 20:02:58.000000000 +0100
15712 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/printk.c 2009-12-03 20:04:56.000000000 +0100
15714 #include <linux/bootmem.h>
15715 #include <linux/syscalls.h>
15716 #include <linux/kexec.h>
15717 +#include <linux/vs_cvirt.h>
15719 #include <asm/uaccess.h>
15721 @@ -276,18 +277,13 @@ int do_syslog(int type, char __user *buf
15722 unsigned i, j, limit, count;
15728 error = security_syslog(type);
15733 - case 0: /* Close log */
15735 - case 1: /* Open log */
15737 - case 2: /* Read from log */
15738 + if ((type >= 2) && (type <= 4)) {
15740 if (!buf || len < 0)
15742 @@ -298,6 +294,16 @@ int do_syslog(int type, char __user *buf
15747 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15748 + return vx_do_syslog(type, buf, len);
15751 + case 0: /* Close log */
15753 + case 1: /* Open log */
15755 + case 2: /* Read from log */
15756 error = wait_event_interruptible(log_wait,
15757 (log_start - log_end));
15759 @@ -322,16 +328,6 @@ int do_syslog(int type, char __user *buf
15762 case 3: /* Read last kernel messages */
15764 - if (!buf || len < 0)
15769 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15774 if (count > log_buf_len)
15775 count = log_buf_len;
15776 diff -NurpP --minimal linux-2.6.32.24/kernel/ptrace.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/ptrace.c
15777 --- linux-2.6.32.24/kernel/ptrace.c 2009-12-03 20:02:58.000000000 +0100
15778 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
15780 #include <linux/pid_namespace.h>
15781 #include <linux/syscalls.h>
15782 #include <linux/uaccess.h>
15783 +#include <linux/vs_context.h>
15787 @@ -151,6 +152,11 @@ int __ptrace_may_access(struct task_stru
15788 dumpable = get_dumpable(task->mm);
15789 if (!dumpable && !capable(CAP_SYS_PTRACE))
15791 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15793 + if (!vx_check(task->xid, VS_IDENT) &&
15794 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15797 return security_ptrace_access_check(task, mode);
15799 @@ -621,6 +627,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15804 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15805 + goto out_put_task_struct;
15807 if (request == PTRACE_ATTACH) {
15808 ret = ptrace_attach(child);
15810 diff -NurpP --minimal linux-2.6.32.24/kernel/sched.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sched.c
15811 --- linux-2.6.32.24/kernel/sched.c 2010-10-04 08:56:18.000000000 +0200
15812 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sched.c 2010-10-04 10:04:57.000000000 +0200
15814 #include <linux/debugfs.h>
15815 #include <linux/ctype.h>
15816 #include <linux/ftrace.h>
15817 +#include <linux/vs_sched.h>
15818 +#include <linux/vs_cvirt.h>
15820 #include <asm/tlb.h>
15821 #include <asm/irq_regs.h>
15822 @@ -237,6 +239,15 @@ static DEFINE_MUTEX(sched_domains_mutex)
15824 #include <linux/cgroup.h>
15826 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
15827 +struct cfs_bandwidth {
15828 + spinlock_t cfs_runtime_lock;
15829 + ktime_t cfs_period;
15831 + struct hrtimer cfs_period_timer;
15837 static LIST_HEAD(task_groups);
15838 @@ -257,6 +268,9 @@ struct task_group {
15839 /* runqueue "owned" by this group on each cpu */
15840 struct cfs_rq **cfs_rq;
15841 unsigned long shares;
15842 +#ifdef CONFIG_CFS_HARD_LIMITS
15843 + struct cfs_bandwidth cfs_bandwidth;
15847 #ifdef CONFIG_RT_GROUP_SCHED
15848 @@ -446,6 +460,19 @@ struct cfs_rq {
15849 unsigned long rq_weight;
15852 +#ifdef CONFIG_CFS_HARD_LIMITS
15853 + /* set when the group is throttled on this cpu */
15854 + int cfs_throttled;
15856 + /* runtime currently consumed by the group on this rq */
15859 + /* runtime available to the group on this rq */
15862 + /* Protects the cfs runtime related fields of this cfs_rq */
15863 + spinlock_t cfs_runtime_lock;
15867 /* Real-Time classes' related field in a runqueue: */
15868 @@ -1626,6 +1653,7 @@ static void update_group_shares_cpu(stru
15872 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq);
15874 * Re-compute the task group their per cpu shares over the given domain.
15875 * This needs to be done in a bottom-up fashion because the rq weight of a
15876 @@ -1654,8 +1682,10 @@ static int tg_shares_up(struct task_grou
15877 * If there are currently no tasks on the cpu pretend there
15878 * is one of average load so that when a new task gets to
15879 * run here it will not get delayed by group starvation.
15880 + * Also if the group is throttled on this cpu, pretend that
15881 + * it has no tasks.
15884 + if (!weight || cfs_rq_throttled(tg->cfs_rq[i]))
15885 weight = NICE_0_LOAD;
15887 sum_weight += weight;
15888 @@ -1832,6 +1862,175 @@ static void cfs_rq_set_shares(struct cfs
15889 static void calc_load_account_active(struct rq *this_rq);
15890 static void update_sysctl(void);
15893 +#if defined(CONFIG_RT_GROUP_SCHED) || defined(CONFIG_FAIR_GROUP_SCHED)
15896 +static inline const struct cpumask *sched_bw_period_mask(void)
15898 + return cpu_rq(smp_processor_id())->rd->span;
15900 +#else /* !CONFIG_SMP */
15901 +static inline const struct cpumask *sched_bw_period_mask(void)
15903 + return cpu_online_mask;
15905 +#endif /* CONFIG_SMP */
15908 +static inline const struct cpumask *sched_bw_period_mask(void)
15910 + return cpu_online_mask;
15915 +#ifdef CONFIG_FAIR_GROUP_SCHED
15916 +#ifdef CONFIG_CFS_HARD_LIMITS
15919 + * Runtime allowed for a cfs group before it is hard limited.
15920 + * default: Infinite which means no hard limiting.
15922 +u64 sched_cfs_runtime = RUNTIME_INF;
15925 + * period over which we hard limit the cfs group's bandwidth.
15928 +u64 sched_cfs_period = 500000;
15930 +static inline u64 global_cfs_period(void)
15932 + return sched_cfs_period * NSEC_PER_USEC;
15935 +static inline u64 global_cfs_runtime(void)
15937 + return RUNTIME_INF;
15940 +void do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b);
15942 +static inline void cfs_rq_runtime_lock(struct cfs_rq *cfs_rq)
15944 + spin_lock(&cfs_rq->cfs_runtime_lock);
15947 +static inline void cfs_rq_runtime_unlock(struct cfs_rq *cfs_rq)
15949 + spin_unlock(&cfs_rq->cfs_runtime_lock);
15953 + * Refresh the runtimes of the throttled groups.
15954 + * But nothing much to do now, will populate this in later patches.
15956 +static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)
15958 + struct cfs_bandwidth *cfs_b =
15959 + container_of(timer, struct cfs_bandwidth, cfs_period_timer);
15961 + do_sched_cfs_period_timer(cfs_b);
15962 + hrtimer_add_expires_ns(timer, ktime_to_ns(cfs_b->cfs_period));
15963 + return HRTIMER_RESTART;
15967 + * TODO: Check if this kind of timer setup is sufficient for cfs or
15968 + * should we do what rt is doing.
15970 +static void start_cfs_bandwidth(struct task_group *tg)
15972 + struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
15975 + * Timer isn't setup for groups with infinite runtime
15977 + if (cfs_b->cfs_runtime == RUNTIME_INF)
15980 + if (hrtimer_active(&cfs_b->cfs_period_timer))
15983 + hrtimer_start_range_ns(&cfs_b->cfs_period_timer, cfs_b->cfs_period,
15984 + 0, HRTIMER_MODE_REL);
15987 +static void init_cfs_bandwidth(struct task_group *tg)
15989 + struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
15991 + cfs_b->cfs_period = ns_to_ktime(global_cfs_period());
15992 + cfs_b->cfs_runtime = global_cfs_runtime();
15994 + spin_lock_init(&cfs_b->cfs_runtime_lock);
15996 + hrtimer_init(&cfs_b->cfs_period_timer,
15997 + CLOCK_MONOTONIC, HRTIMER_MODE_REL);
15998 + cfs_b->cfs_period_timer.function = &sched_cfs_period_timer;
16001 +static inline void destroy_cfs_bandwidth(struct task_group *tg)
16003 + hrtimer_cancel(&tg->cfs_bandwidth.cfs_period_timer);
16006 +static void init_cfs_hard_limits(struct cfs_rq *cfs_rq, struct task_group *tg)
16008 + cfs_rq->cfs_time = 0;
16009 + cfs_rq->cfs_throttled = 0;
16010 + cfs_rq->cfs_runtime = tg->cfs_bandwidth.cfs_runtime;
16011 + spin_lock_init(&cfs_rq->cfs_runtime_lock);
16014 +#else /* !CONFIG_CFS_HARD_LIMITS */
16016 +static void init_cfs_bandwidth(struct task_group *tg)
16021 +static inline void destroy_cfs_bandwidth(struct task_group *tg)
16026 +static void init_cfs_hard_limits(struct cfs_rq *cfs_rq, struct task_group *tg)
16031 +static inline void cfs_rq_runtime_lock(struct cfs_rq *cfs_rq)
16036 +static inline void cfs_rq_runtime_unlock(struct cfs_rq *cfs_rq)
16041 +#endif /* CONFIG_CFS_HARD_LIMITS */
16042 +#else /* !CONFIG_FAIR_GROUP_SCHED */
16044 +static inline void cfs_rq_runtime_lock(struct cfs_rq *cfs_rq)
16049 +static inline void cfs_rq_runtime_unlock(struct cfs_rq *cfs_rq)
16054 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
16059 +#endif /* CONFIG_FAIR_GROUP_SCHED */
16061 static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
16063 set_task_rq(p, cpu);
16064 @@ -3060,9 +3259,17 @@ EXPORT_SYMBOL(avenrun);
16066 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
16068 - loads[0] = (avenrun[0] + offset) << shift;
16069 - loads[1] = (avenrun[1] + offset) << shift;
16070 - loads[2] = (avenrun[2] + offset) << shift;
16071 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
16072 + struct vx_info *vxi = current_vx_info();
16074 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
16075 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
16076 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
16078 + loads[0] = (avenrun[0] + offset) << shift;
16079 + loads[1] = (avenrun[1] + offset) << shift;
16080 + loads[2] = (avenrun[2] + offset) << shift;
16084 static unsigned long
16085 @@ -5107,16 +5314,19 @@ void account_user_time(struct task_struc
16086 cputime_t cputime_scaled)
16088 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16089 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16091 + int nice = (TASK_NICE(p) > 0);
16093 /* Add user time to process. */
16094 p->utime = cputime_add(p->utime, cputime);
16095 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
16096 + vx_account_user(vxi, cputime, nice);
16097 account_group_user_time(p, cputime);
16099 /* Add user time to cpustat. */
16100 tmp = cputime_to_cputime64(cputime);
16101 - if (TASK_NICE(p) > 0)
16103 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16105 cpustat->user = cputime64_add(cpustat->user, tmp);
16106 @@ -5162,6 +5372,7 @@ void account_system_time(struct task_str
16107 cputime_t cputime, cputime_t cputime_scaled)
16109 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16110 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16113 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
16114 @@ -5172,6 +5383,7 @@ void account_system_time(struct task_str
16115 /* Add system time to process. */
16116 p->stime = cputime_add(p->stime, cputime);
16117 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
16118 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
16119 account_group_system_time(p, cputime);
16121 /* Add system time to cpustat. */
16122 @@ -6255,7 +6467,7 @@ SYSCALL_DEFINE1(nice, int, increment)
16125 if (increment < 0 && !can_nice(current, nice))
16127 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16129 retval = security_task_setnice(current, nice);
16131 @@ -9323,6 +9535,32 @@ static int update_sched_domains(struct n
16136 +static void disable_runtime(struct rq *rq)
16138 + unsigned long flags;
16140 + spin_lock_irqsave(&rq->lock, flags);
16141 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
16142 + disable_runtime_cfs(rq);
16144 + disable_runtime_rt(rq);
16145 + spin_unlock_irqrestore(&rq->lock, flags);
16148 +static void enable_runtime(struct rq *rq)
16150 + unsigned long flags;
16152 + spin_lock_irqsave(&rq->lock, flags);
16153 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
16154 + enable_runtime_cfs(rq);
16156 + enable_runtime_rt(rq);
16157 + spin_unlock_irqrestore(&rq->lock, flags);
16161 static int update_runtime(struct notifier_block *nfb,
16162 unsigned long action, void *hcpu)
16164 @@ -9455,6 +9693,7 @@ static void init_tg_cfs_entry(struct tas
16165 struct rq *rq = cpu_rq(cpu);
16166 tg->cfs_rq[cpu] = cfs_rq;
16167 init_cfs_rq(cfs_rq, rq);
16168 + init_cfs_hard_limits(cfs_rq, tg);
16171 list_add(&cfs_rq->leaf_cfs_rq_list, &rq->leaf_cfs_rq_list);
16172 @@ -9584,6 +9823,10 @@ void __init sched_init(void)
16173 #endif /* CONFIG_USER_SCHED */
16174 #endif /* CONFIG_RT_GROUP_SCHED */
16176 +#ifdef CONFIG_FAIR_GROUP_SCHED
16177 + init_cfs_bandwidth(&init_task_group);
16180 #ifdef CONFIG_GROUP_SCHED
16181 list_add(&init_task_group.list, &task_groups);
16182 INIT_LIST_HEAD(&init_task_group.children);
16183 @@ -9610,6 +9853,7 @@ void __init sched_init(void)
16184 init_cfs_rq(&rq->cfs, rq);
16185 init_rt_rq(&rq->rt, rq);
16186 #ifdef CONFIG_FAIR_GROUP_SCHED
16187 + init_cfs_hard_limits(&rq->cfs, &init_task_group);
16188 init_task_group.shares = init_task_group_load;
16189 INIT_LIST_HEAD(&rq->leaf_cfs_rq_list);
16190 #ifdef CONFIG_CGROUP_SCHED
16191 @@ -9889,6 +10133,7 @@ static void free_fair_sched_group(struct
16195 + destroy_cfs_bandwidth(tg);
16196 for_each_possible_cpu(i) {
16198 kfree(tg->cfs_rq[i]);
16199 @@ -9915,6 +10160,7 @@ int alloc_fair_sched_group(struct task_g
16203 + init_cfs_bandwidth(tg);
16204 tg->shares = NICE_0_LOAD;
16206 for_each_possible_cpu(i) {
16207 @@ -10638,6 +10884,100 @@ static u64 cpu_shares_read_u64(struct cg
16209 return (u64) tg->shares;
16212 +#ifdef CONFIG_CFS_HARD_LIMITS
16214 +static int tg_set_cfs_bandwidth(struct task_group *tg,
16215 + u64 cfs_period, u64 cfs_runtime)
16219 + spin_lock_irq(&tg->cfs_bandwidth.cfs_runtime_lock);
16220 + tg->cfs_bandwidth.cfs_period = ns_to_ktime(cfs_period);
16221 + tg->cfs_bandwidth.cfs_runtime = cfs_runtime;
16223 + for_each_possible_cpu(i) {
16224 + struct cfs_rq *cfs_rq = tg->cfs_rq[i];
16226 + cfs_rq_runtime_lock(cfs_rq);
16227 + cfs_rq->cfs_runtime = cfs_runtime;
16228 + cfs_rq_runtime_unlock(cfs_rq);
16231 + start_cfs_bandwidth(tg);
16232 + spin_unlock_irq(&tg->cfs_bandwidth.cfs_runtime_lock);
16236 +int tg_set_cfs_runtime(struct task_group *tg, long cfs_runtime_us)
16238 + u64 cfs_runtime, cfs_period;
16240 + cfs_period = ktime_to_ns(tg->cfs_bandwidth.cfs_period);
16241 + cfs_runtime = (u64)cfs_runtime_us * NSEC_PER_USEC;
16242 + if (cfs_runtime_us < 0)
16243 + cfs_runtime = RUNTIME_INF;
16245 + return tg_set_cfs_bandwidth(tg, cfs_period, cfs_runtime);
16248 +long tg_get_cfs_runtime(struct task_group *tg)
16250 + u64 cfs_runtime_us;
16252 + if (tg->cfs_bandwidth.cfs_runtime == RUNTIME_INF)
16255 + cfs_runtime_us = tg->cfs_bandwidth.cfs_runtime;
16256 + do_div(cfs_runtime_us, NSEC_PER_USEC);
16257 + return cfs_runtime_us;
16260 +int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
16262 + u64 cfs_runtime, cfs_period;
16264 + cfs_period = (u64)cfs_period_us * NSEC_PER_USEC;
16265 + cfs_runtime = tg->cfs_bandwidth.cfs_runtime;
16267 + if (cfs_period == 0)
16270 + return tg_set_cfs_bandwidth(tg, cfs_period, cfs_runtime);
16273 +long tg_get_cfs_period(struct task_group *tg)
16275 + u64 cfs_period_us;
16277 + cfs_period_us = ktime_to_ns(tg->cfs_bandwidth.cfs_period);
16278 + do_div(cfs_period_us, NSEC_PER_USEC);
16279 + return cfs_period_us;
16282 +static s64 cpu_cfs_runtime_read_s64(struct cgroup *cgrp, struct cftype *cft)
16284 + return tg_get_cfs_runtime(cgroup_tg(cgrp));
16287 +static int cpu_cfs_runtime_write_s64(struct cgroup *cgrp, struct cftype *cftype,
16288 + s64 cfs_runtime_us)
16290 + return tg_set_cfs_runtime(cgroup_tg(cgrp), cfs_runtime_us);
16293 +static u64 cpu_cfs_period_read_u64(struct cgroup *cgrp, struct cftype *cft)
16295 + return tg_get_cfs_period(cgroup_tg(cgrp));
16298 +static int cpu_cfs_period_write_u64(struct cgroup *cgrp, struct cftype *cftype,
16299 + u64 cfs_period_us)
16301 + return tg_set_cfs_period(cgroup_tg(cgrp), cfs_period_us);
16304 +#endif /* CONFIG_CFS_HARD_LIMITS */
16305 #endif /* CONFIG_FAIR_GROUP_SCHED */
16307 #ifdef CONFIG_RT_GROUP_SCHED
16308 @@ -10671,6 +11011,18 @@ static struct cftype cpu_files[] = {
16309 .read_u64 = cpu_shares_read_u64,
16310 .write_u64 = cpu_shares_write_u64,
16312 +#ifdef CONFIG_CFS_HARD_LIMITS
16314 + .name = "cfs_runtime_us",
16315 + .read_s64 = cpu_cfs_runtime_read_s64,
16316 + .write_s64 = cpu_cfs_runtime_write_s64,
16319 + .name = "cfs_period_us",
16320 + .read_u64 = cpu_cfs_period_read_u64,
16321 + .write_u64 = cpu_cfs_period_write_u64,
16323 +#endif /* CONFIG_CFS_HARD_LIMITS */
16325 #ifdef CONFIG_RT_GROUP_SCHED
16327 diff -NurpP --minimal linux-2.6.32.24/kernel/sched_debug.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sched_debug.c
16328 --- linux-2.6.32.24/kernel/sched_debug.c 2010-10-04 08:56:18.000000000 +0200
16329 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sched_debug.c 2010-09-22 00:48:38.000000000 +0200
16330 @@ -80,6 +80,11 @@ static void print_cfs_group_stats(struct
16334 +#ifdef CONFIG_CFS_HARD_LIMITS
16335 + PN(se->throttle_max);
16336 + PN(se->throttle_sum);
16337 + P(se->throttle_count);
16340 P(se->load.weight);
16342 @@ -214,6 +219,16 @@ void print_cfs_rq(struct seq_file *m, in
16344 SEQ_printf(m, " .%-30s: %lu\n", "shares", cfs_rq->shares);
16346 +#ifdef CONFIG_CFS_HARD_LIMITS
16347 + spin_lock_irqsave(&rq->lock, flags);
16348 + SEQ_printf(m, " .%-30s: %d\n", "cfs_throttled",
16349 + cfs_rq->cfs_throttled);
16350 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "cfs_time",
16351 + SPLIT_NS(cfs_rq->cfs_time));
16352 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "cfs_runtime",
16353 + SPLIT_NS(cfs_rq->cfs_runtime));
16354 + spin_unlock_irqrestore(&rq->lock, flags);
16355 +#endif /* CONFIG_CFS_HARD_LIMITS */
16356 print_cfs_group_stats(m, cpu, cfs_rq->tg);
16359 @@ -314,7 +329,7 @@ static int sched_debug_show(struct seq_f
16360 u64 now = ktime_to_ns(ktime_get());
16363 - SEQ_printf(m, "Sched Debug Version: v0.09, %s %.*s\n",
16364 + SEQ_printf(m, "Sched Debug Version: v0.10, %s %.*s\n",
16365 init_utsname()->release,
16366 (int)strcspn(init_utsname()->version, " "),
16367 init_utsname()->version);
16368 diff -NurpP --minimal linux-2.6.32.24/kernel/sched_fair.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sched_fair.c
16369 --- linux-2.6.32.24/kernel/sched_fair.c 2010-10-04 08:56:18.000000000 +0200
16370 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sched_fair.c 2010-09-22 01:14:22.000000000 +0200
16371 @@ -192,7 +192,308 @@ find_matching_se(struct sched_entity **s
16375 -#else /* !CONFIG_FAIR_GROUP_SCHED */
16376 +#ifdef CONFIG_CFS_HARD_LIMITS
16378 +static inline void update_stats_throttle_start(struct cfs_rq *cfs_rq,
16379 + struct sched_entity *se)
16381 + schedstat_set(se->throttle_start, rq_of(cfs_rq)->clock);
16384 +static inline void update_stats_throttle_end(struct cfs_rq *cfs_rq,
16385 + struct sched_entity *se)
16387 + schedstat_set(se->throttle_max, max(se->throttle_max,
16388 + rq_of(cfs_rq)->clock - se->throttle_start));
16389 + schedstat_set(se->throttle_count, se->throttle_count + 1);
16390 + schedstat_set(se->throttle_sum, se->throttle_sum +
16391 + rq_of(cfs_rq)->clock - se->throttle_start);
16392 + schedstat_set(se->throttle_start, 0);
16396 +struct cfs_rq *sched_cfs_period_cfs_rq(struct cfs_bandwidth *cfs_b, int cpu)
16398 + return container_of(cfs_b, struct task_group,
16399 + cfs_bandwidth)->cfs_rq[cpu];
16402 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
16404 + return cfs_rq->cfs_throttled;
16409 + * Ensure this RQ takes back all the runtime it lend to its neighbours.
16411 +static void disable_runtime_cfs(struct rq *rq)
16413 + struct root_domain *rd = rq->rd;
16414 + struct cfs_rq *cfs_rq;
16416 + if (unlikely(!scheduler_running))
16419 + for_each_leaf_cfs_rq(rq, cfs_rq) {
16420 + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth;
16424 + spin_lock(&cfs_b->cfs_runtime_lock);
16425 + spin_lock(&cfs_rq->cfs_runtime_lock);
16428 + * Either we're all are infinity and nobody needs to borrow,
16429 + * or we're already disabled and this have nothing to do, or
16430 + * we have exactly the right amount of runtime to take out.
16432 + if (cfs_rq->cfs_runtime == RUNTIME_INF ||
16433 + cfs_rq->cfs_runtime == cfs_b->cfs_runtime)
16435 + spin_unlock(&cfs_rq->cfs_runtime_lock);
16438 + * Calculate the difference between what we started out with
16439 + * and what we current have, that's the amount of runtime
16440 + * we lend and now have to reclaim.
16442 + want = cfs_b->cfs_runtime - cfs_rq->cfs_runtime;
16445 + * Greedy reclaim, take back as much as possible.
16447 + for_each_cpu(i, rd->span) {
16448 + struct cfs_rq *iter = sched_cfs_period_cfs_rq(cfs_b, i);
16452 + * Can't reclaim from ourselves or disabled runqueues.
16454 + if (iter == cfs_rq || iter->cfs_runtime == RUNTIME_INF)
16457 + spin_lock(&iter->cfs_runtime_lock);
16459 + diff = min_t(s64, iter->cfs_runtime, want);
16460 + iter->cfs_runtime -= diff;
16463 + iter->cfs_runtime -= want;
16467 + spin_unlock(&iter->cfs_runtime_lock);
16472 + spin_lock(&cfs_rq->cfs_runtime_lock);
16474 + * We cannot be left wanting - that would mean some
16475 + * runtime leaked out of the system.
16480 + * Disable all the borrow logic by pretending we have infinite
16481 + * runtime - in which case borrowing doesn't make sense.
16483 + cfs_rq->cfs_runtime = RUNTIME_INF;
16484 + spin_unlock(&cfs_rq->cfs_runtime_lock);
16485 + spin_unlock(&cfs_b->cfs_runtime_lock);
16489 +static void enable_runtime_cfs(struct rq *rq)
16491 + struct cfs_rq *cfs_rq;
16493 + if (unlikely(!scheduler_running))
16497 + * Reset each runqueue's bandwidth settings
16499 + for_each_leaf_cfs_rq(rq, cfs_rq) {
16500 + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth;
16502 + spin_lock(&cfs_b->cfs_runtime_lock);
16503 + spin_lock(&cfs_rq->cfs_runtime_lock);
16504 + cfs_rq->cfs_runtime = cfs_b->cfs_runtime;
16505 + cfs_rq->cfs_time = 0;
16506 + cfs_rq->cfs_throttled = 0;
16507 + spin_unlock(&cfs_rq->cfs_runtime_lock);
16508 + spin_unlock(&cfs_b->cfs_runtime_lock);
16513 + * Ran out of runtime, check if we can borrow some from others
16514 + * instead of getting throttled right away.
16516 +static void do_cfs_balance_runtime(struct cfs_rq *cfs_rq)
16518 + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth;
16519 + const struct cpumask *span = sched_bw_period_mask();
16523 + weight = cpumask_weight(span);
16524 + spin_lock(&cfs_b->cfs_runtime_lock);
16525 + cfs_period = ktime_to_ns(cfs_b->cfs_period);
16527 + for_each_cpu(i, span) {
16528 + struct cfs_rq *borrow_cfs_rq =
16529 + sched_cfs_period_cfs_rq(cfs_b, i);
16532 + if (borrow_cfs_rq == cfs_rq)
16535 + cfs_rq_runtime_lock(borrow_cfs_rq);
16536 + if (borrow_cfs_rq->cfs_runtime == RUNTIME_INF) {
16537 + cfs_rq_runtime_unlock(borrow_cfs_rq);
16541 + diff = borrow_cfs_rq->cfs_runtime - borrow_cfs_rq->cfs_time;
16543 + diff = div_u64((u64)diff, weight);
16544 + if (cfs_rq->cfs_runtime + diff > cfs_period)
16545 + diff = cfs_period - cfs_rq->cfs_runtime;
16546 + borrow_cfs_rq->cfs_runtime -= diff;
16547 + cfs_rq->cfs_runtime += diff;
16548 + if (cfs_rq->cfs_runtime == cfs_period) {
16549 + cfs_rq_runtime_unlock(borrow_cfs_rq);
16553 + cfs_rq_runtime_unlock(borrow_cfs_rq);
16555 + spin_unlock(&cfs_b->cfs_runtime_lock);
16559 + * Called with rq->runtime_lock held.
16561 +static void cfs_balance_runtime(struct cfs_rq *cfs_rq)
16563 + cfs_rq_runtime_unlock(cfs_rq);
16564 + do_cfs_balance_runtime(cfs_rq);
16565 + cfs_rq_runtime_lock(cfs_rq);
16568 +#else /* !CONFIG_SMP */
16570 +static void cfs_balance_runtime(struct cfs_rq *cfs_rq)
16574 +#endif /* CONFIG_SMP */
16577 + * Check if group entity exceeded its runtime. If so, mark the cfs_rq as
16578 + * throttled mark the current task for reschedling.
16580 +static void sched_cfs_runtime_exceeded(struct sched_entity *se,
16581 + struct task_struct *tsk_curr, unsigned long delta_exec)
16583 + struct cfs_rq *cfs_rq;
16585 + cfs_rq = group_cfs_rq(se);
16587 + if (cfs_rq->cfs_runtime == RUNTIME_INF)
16590 + cfs_rq->cfs_time += delta_exec;
16592 + if (cfs_rq_throttled(cfs_rq))
16595 + if (cfs_rq->cfs_time > cfs_rq->cfs_runtime)
16596 + cfs_balance_runtime(cfs_rq);
16598 + if (cfs_rq->cfs_time > cfs_rq->cfs_runtime) {
16599 + cfs_rq->cfs_throttled = 1;
16600 + update_stats_throttle_start(cfs_rq, se);
16601 + resched_task(tsk_curr);
16605 +static inline void update_curr_group(struct sched_entity *curr,
16606 + unsigned long delta_exec, struct task_struct *tsk_curr)
16608 + sched_cfs_runtime_exceeded(curr, tsk_curr, delta_exec);
16611 +static void enqueue_entity_locked(struct cfs_rq *cfs_rq,
16612 + struct sched_entity *se, int flags);
16614 +static void enqueue_throttled_entity(struct rq *rq, struct sched_entity *se)
16616 + for_each_sched_entity(se) {
16617 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
16619 + if (se->on_rq || cfs_rq_throttled(gcfs_rq) ||
16620 + !gcfs_rq->nr_running)
16622 + enqueue_entity_locked(cfs_rq_of(se), se, 0);
16627 + * Refresh runtimes of all cfs_rqs in this group, i,e.,
16628 + * refresh runtimes of the representative cfs_rq of this
16629 + * tg on all cpus. Enqueue any throttled entity back.
16631 +void do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b)
16634 + const struct cpumask *span = sched_bw_period_mask();
16635 + unsigned long flags;
16637 + for_each_cpu(i, span) {
16638 + struct rq *rq = cpu_rq(i);
16639 + struct cfs_rq *cfs_rq = sched_cfs_period_cfs_rq(cfs_b, i);
16640 + struct sched_entity *se = cfs_rq->tg->se[i];
16642 + spin_lock_irqsave(&rq->lock, flags);
16643 + cfs_rq_runtime_lock(cfs_rq);
16644 + cfs_rq->cfs_time = 0;
16645 + if (cfs_rq_throttled(cfs_rq)) {
16646 + update_rq_clock(rq);
16647 + update_stats_throttle_end(cfs_rq, se);
16648 + cfs_rq->cfs_throttled = 0;
16649 + enqueue_throttled_entity(rq, se);
16651 + cfs_rq_runtime_unlock(cfs_rq);
16652 + spin_unlock_irqrestore(&rq->lock, flags);
16658 +static inline void update_curr_group(struct sched_entity *curr,
16659 + unsigned long delta_exec, struct task_struct *tsk_curr)
16664 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
16669 +#endif /* CONFIG_CFS_HARD_LIMITS */
16671 +#else /* CONFIG_FAIR_GROUP_SCHED */
16673 +static inline void update_curr_group(struct sched_entity *curr,
16674 + unsigned long delta_exec, struct task_struct *tsk_curr)
16679 static inline struct task_struct *task_of(struct sched_entity *se)
16681 @@ -254,7 +555,6 @@ find_matching_se(struct sched_entity **s
16683 #endif /* CONFIG_FAIR_GROUP_SCHED */
16686 /**************************************************************
16687 * Scheduling class tree data structure manipulation methods:
16689 @@ -493,14 +793,25 @@ __update_curr(struct cfs_rq *cfs_rq, str
16690 update_min_vruntime(cfs_rq);
16693 -static void update_curr(struct cfs_rq *cfs_rq)
16694 +static void update_curr_task(struct sched_entity *curr,
16695 + unsigned long delta_exec)
16697 + struct task_struct *curtask = task_of(curr);
16699 + trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
16700 + cpuacct_charge(curtask, delta_exec);
16701 + account_group_exec_runtime(curtask, delta_exec);
16704 +static int update_curr_common(struct cfs_rq *cfs_rq, unsigned long *delta)
16706 struct sched_entity *curr = cfs_rq->curr;
16707 - u64 now = rq_of(cfs_rq)->clock;
16708 + struct rq *rq = rq_of(cfs_rq);
16709 + u64 now = rq->clock;
16710 unsigned long delta_exec;
16712 if (unlikely(!curr))
16717 * Get the amount of time the current task was running
16718 @@ -509,17 +820,29 @@ static void update_curr(struct cfs_rq *c
16720 delta_exec = (unsigned long)(now - curr->exec_start);
16725 __update_curr(cfs_rq, curr, delta_exec);
16726 curr->exec_start = now;
16727 + *delta = delta_exec;
16731 - if (entity_is_task(curr)) {
16732 - struct task_struct *curtask = task_of(curr);
16733 +static void update_curr(struct cfs_rq *cfs_rq)
16735 + struct sched_entity *curr = cfs_rq->curr;
16736 + struct rq *rq = rq_of(cfs_rq);
16737 + unsigned long delta_exec;
16739 - trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
16740 - cpuacct_charge(curtask, delta_exec);
16741 - account_group_exec_runtime(curtask, delta_exec);
16742 + if (update_curr_common(cfs_rq, &delta_exec))
16745 + if (entity_is_task(curr))
16746 + update_curr_task(curr, delta_exec);
16748 + cfs_rq_runtime_lock(group_cfs_rq(curr));
16749 + update_curr_group(curr, delta_exec, rq->curr);
16750 + cfs_rq_runtime_unlock(group_cfs_rq(curr));
16754 @@ -747,7 +1070,26 @@ place_entity(struct cfs_rq *cfs_rq, stru
16755 #define ENQUEUE_WAKEUP 1
16756 #define ENQUEUE_MIGRATE 2
16760 +enqueue_entity_common(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
16762 + account_entity_enqueue(cfs_rq, se);
16764 + if (flags & ENQUEUE_WAKEUP) {
16765 + place_entity(cfs_rq, se, 0);
16766 + enqueue_sleeper(cfs_rq, se);
16769 + update_stats_enqueue(cfs_rq, se);
16770 + check_spread(cfs_rq, se);
16771 + if (se != cfs_rq->curr)
16772 + __enqueue_entity(cfs_rq, se);
16774 + if (entity_is_task(se))
16775 + vx_activate_task(task_of(se));
16779 enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
16782 @@ -761,17 +1103,17 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
16783 * Update run-time statistics of the 'current'.
16785 update_curr(cfs_rq);
16786 - account_entity_enqueue(cfs_rq, se);
16788 - if (flags & ENQUEUE_WAKEUP) {
16789 - place_entity(cfs_rq, se, 0);
16790 - enqueue_sleeper(cfs_rq, se);
16792 + enqueue_entity_common(cfs_rq, se, flags);
16795 - update_stats_enqueue(cfs_rq, se);
16796 - check_spread(cfs_rq, se);
16797 - if (se != cfs_rq->curr)
16798 - __enqueue_entity(cfs_rq, se);
16799 +static void enqueue_entity_locked(struct cfs_rq *cfs_rq,
16800 + struct sched_entity *se, int flags)
16803 + * Update run-time statistics of the 'current'.
16805 + // update_curr_locked(cfs_rq);
16806 + enqueue_entity_common(cfs_rq, se, flags);
16809 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
16810 @@ -815,6 +1157,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
16812 if (se != cfs_rq->curr)
16813 __dequeue_entity(cfs_rq, se);
16814 + if (entity_is_task(se))
16815 + vx_deactivate_task(task_of(se));
16816 account_entity_dequeue(cfs_rq, se);
16817 update_min_vruntime(cfs_rq);
16819 @@ -919,6 +1263,32 @@ static struct sched_entity *pick_next_en
16824 + * Called from put_prev_entity()
16825 + * If a group entity (@se) is found to be throttled, it will not be put back
16826 + * on @cfs_rq, which is equivalent to dequeing it.
16828 +static int dequeue_throttled_entity(struct cfs_rq *cfs_rq,
16829 + struct sched_entity *se)
16831 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
16833 + if (entity_is_task(se))
16836 + cfs_rq_runtime_lock(gcfs_rq);
16837 + if (!cfs_rq_throttled(gcfs_rq) && gcfs_rq->nr_running) {
16838 + cfs_rq_runtime_unlock(gcfs_rq);
16842 + __clear_buddies(cfs_rq, se);
16843 + account_entity_dequeue(cfs_rq, se);
16844 + cfs_rq->curr = NULL;
16845 + cfs_rq_runtime_unlock(gcfs_rq);
16849 static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)
16852 @@ -930,6 +1300,8 @@ static void put_prev_entity(struct cfs_r
16854 check_spread(cfs_rq, prev);
16856 + if (dequeue_throttled_entity(cfs_rq, prev))
16858 update_stats_wait_start(cfs_rq, prev);
16859 /* Put 'current' back into the tree. */
16860 __enqueue_entity(cfs_rq, prev);
16861 @@ -1026,10 +1398,28 @@ static inline void hrtick_update(struct
16865 +static int enqueue_group_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
16868 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
16871 + cfs_rq_runtime_lock(gcfs_rq);
16872 + if (cfs_rq_throttled(gcfs_rq)) {
16876 + enqueue_entity_locked(cfs_rq, se, flags);
16878 + cfs_rq_runtime_unlock(gcfs_rq);
16883 * The enqueue_task method is called before nr_running is
16884 * increased. Here we update the fair scheduling stats and
16885 * then put the task into the rbtree:
16886 + * Don't enqueue a throttled entity further into the hierarchy.
16889 enqueue_task_fair(struct rq *rq, struct task_struct *p, int wakeup, bool head)
16890 @@ -1046,11 +1436,15 @@ enqueue_task_fair(struct rq *rq, struct
16891 for_each_sched_entity(se) {
16895 cfs_rq = cfs_rq_of(se);
16896 - enqueue_entity(cfs_rq, se, flags);
16897 + if (entity_is_task(se))
16898 + enqueue_entity(cfs_rq, se, flags);
16900 + if (enqueue_group_entity(cfs_rq, se, flags))
16902 flags = ENQUEUE_WAKEUP;
16908 @@ -1070,6 +1464,17 @@ static void dequeue_task_fair(struct rq
16909 /* Don't dequeue parent if it has other entities besides us */
16910 if (cfs_rq->load.weight)
16914 + * If this cfs_rq is throttled, then it is already
16917 + cfs_rq_runtime_lock(cfs_rq);
16918 + if (cfs_rq_throttled(cfs_rq)) {
16919 + cfs_rq_runtime_unlock(cfs_rq);
16922 + cfs_rq_runtime_unlock(cfs_rq);
16926 @@ -1886,9 +2291,10 @@ load_balance_fair(struct rq *this_rq, in
16927 u64 rem_load, moved_load;
16931 + * empty group or throttled group
16933 - if (!busiest_cfs_rq->task_weight)
16934 + if (!busiest_cfs_rq->task_weight ||
16935 + cfs_rq_throttled(busiest_cfs_rq))
16938 rem_load = (u64)rem_load_move * busiest_weight;
16939 @@ -1937,6 +2343,12 @@ move_one_task_fair(struct rq *this_rq, i
16941 for_each_leaf_cfs_rq(busiest, busy_cfs_rq) {
16943 + * Don't move task from a throttled cfs_rq
16945 + if (cfs_rq_throttled(busy_cfs_rq))
16949 * pass busy_cfs_rq argument into
16950 * load_balance_[start|next]_fair iterators
16952 diff -NurpP --minimal linux-2.6.32.24/kernel/sched_rt.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sched_rt.c
16953 --- linux-2.6.32.24/kernel/sched_rt.c 2010-10-04 08:56:18.000000000 +0200
16954 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sched_rt.c 2010-09-22 00:48:38.000000000 +0200
16955 @@ -235,18 +235,6 @@ static int rt_se_boosted(struct sched_rt
16956 return p->prio != p->normal_prio;
16960 -static inline const struct cpumask *sched_rt_period_mask(void)
16962 - return cpu_rq(smp_processor_id())->rd->span;
16965 -static inline const struct cpumask *sched_rt_period_mask(void)
16967 - return cpu_online_mask;
16972 struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
16974 @@ -296,11 +284,6 @@ static inline int rt_rq_throttled(struct
16975 return rt_rq->rt_throttled;
16978 -static inline const struct cpumask *sched_rt_period_mask(void)
16980 - return cpu_online_mask;
16984 struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
16986 @@ -373,7 +356,7 @@ next:
16988 * Ensure this RQ takes back all the runtime it lend to its neighbours.
16990 -static void __disable_runtime(struct rq *rq)
16991 +static void disable_runtime_rt(struct rq *rq)
16993 struct root_domain *rd = rq->rd;
16994 struct rt_rq *rt_rq;
16995 @@ -450,16 +433,7 @@ balanced:
16999 -static void disable_runtime(struct rq *rq)
17001 - unsigned long flags;
17003 - spin_lock_irqsave(&rq->lock, flags);
17004 - __disable_runtime(rq);
17005 - spin_unlock_irqrestore(&rq->lock, flags);
17008 -static void __enable_runtime(struct rq *rq)
17009 +static void enable_runtime_rt(struct rq *rq)
17011 struct rt_rq *rt_rq;
17013 @@ -482,15 +456,6 @@ static void __enable_runtime(struct rq *
17017 -static void enable_runtime(struct rq *rq)
17019 - unsigned long flags;
17021 - spin_lock_irqsave(&rq->lock, flags);
17022 - __enable_runtime(rq);
17023 - spin_unlock_irqrestore(&rq->lock, flags);
17026 static int balance_runtime(struct rt_rq *rt_rq)
17029 @@ -518,7 +483,7 @@ static int do_sched_rt_period_timer(stru
17030 if (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF)
17033 - span = sched_rt_period_mask();
17034 + span = sched_bw_period_mask();
17035 for_each_cpu(i, span) {
17037 struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i);
17038 @@ -1567,7 +1532,7 @@ static void rq_online_rt(struct rq *rq)
17039 if (rq->rt.overloaded)
17040 rt_set_overload(rq);
17042 - __enable_runtime(rq);
17043 + enable_runtime_rt(rq);
17045 cpupri_set(&rq->rd->cpupri, rq->cpu, rq->rt.highest_prio.curr);
17047 @@ -1578,7 +1543,7 @@ static void rq_offline_rt(struct rq *rq)
17048 if (rq->rt.overloaded)
17049 rt_clear_overload(rq);
17051 - __disable_runtime(rq);
17052 + disable_runtime_rt(rq);
17054 cpupri_set(&rq->rd->cpupri, rq->cpu, CPUPRI_INVALID);
17056 diff -NurpP --minimal linux-2.6.32.24/kernel/signal.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/signal.c
17057 --- linux-2.6.32.24/kernel/signal.c 2010-10-04 08:56:18.000000000 +0200
17058 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/signal.c 2010-07-08 02:22:31.000000000 +0200
17060 #include <linux/freezer.h>
17061 #include <linux/pid_namespace.h>
17062 #include <linux/nsproxy.h>
17063 +#include <linux/vs_context.h>
17064 +#include <linux/vs_pid.h>
17065 #include <trace/events/sched.h>
17067 #include <asm/param.h>
17068 @@ -598,6 +600,14 @@ static int check_kill_permission(int sig
17069 if (!valid_signal(sig))
17072 + if ((info != SEND_SIG_NOINFO) &&
17073 + (is_si_special(info) || !SI_FROMUSER(info)))
17076 + vxdprintk(VXD_CBIT(misc, 7),
17077 + "check_kill_permission(%d,%p,%p[#%u,%u])",
17078 + sig, info, t, vx_task_xid(t), t->pid);
17080 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
17083 @@ -627,6 +637,20 @@ static int check_kill_permission(int sig
17088 + if (t->pid == 1 && current->xid)
17092 + /* FIXME: we shouldn't return ESRCH ever, to avoid
17093 + loops, maybe ENOENT or EACCES? */
17094 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17095 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
17096 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17097 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
17101 return security_task_kill(t, info, sig, 0);
17104 @@ -1115,7 +1139,7 @@ int kill_pid_info(int sig, struct siginf
17107 p = pid_task(pid, PIDTYPE_PID);
17109 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17110 error = group_send_sig_info(sig, info, p);
17111 if (unlikely(error == -ESRCH))
17113 @@ -1154,7 +1178,7 @@ int kill_pid_info_as_uid(int sig, struct
17115 read_lock(&tasklist_lock);
17116 p = pid_task(pid, PIDTYPE_PID);
17118 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17122 @@ -1208,8 +1232,10 @@ static int kill_something_info(int sig,
17123 struct task_struct * p;
17125 for_each_process(p) {
17126 - if (task_pid_vnr(p) > 1 &&
17127 - !same_thread_group(p, current)) {
17128 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17129 + task_pid_vnr(p) > 1 &&
17130 + !same_thread_group(p, current) &&
17131 + !vx_current_initpid(p->pid)) {
17132 int err = group_send_sig_info(sig, info, p);
17135 @@ -1874,6 +1900,11 @@ relock:
17136 !sig_kernel_only(signr))
17139 + /* virtual init is protected against user signals */
17140 + if ((info->si_code == SI_USER) &&
17141 + vx_current_initpid(current->pid))
17144 if (sig_kernel_stop(signr)) {
17146 * The default action is to stop all threads in
17147 diff -NurpP --minimal linux-2.6.32.24/kernel/softirq.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/softirq.c
17148 --- linux-2.6.32.24/kernel/softirq.c 2009-12-03 20:02:58.000000000 +0100
17149 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/softirq.c 2009-12-03 20:04:56.000000000 +0100
17151 #include <linux/ftrace.h>
17152 #include <linux/smp.h>
17153 #include <linux/tick.h>
17154 +#include <linux/vs_context.h>
17156 #define CREATE_TRACE_POINTS
17157 #include <trace/events/irq.h>
17158 diff -NurpP --minimal linux-2.6.32.24/kernel/sys.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sys.c
17159 --- linux-2.6.32.24/kernel/sys.c 2010-10-04 08:56:18.000000000 +0200
17160 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sys.c 2010-10-04 10:04:57.000000000 +0200
17162 #include <linux/syscalls.h>
17163 #include <linux/kprobes.h>
17164 #include <linux/user_namespace.h>
17165 +#include <linux/vs_pid.h>
17167 #include <asm/uaccess.h>
17168 #include <asm/io.h>
17169 @@ -130,7 +131,10 @@ static int set_one_prio(struct task_stru
17172 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17174 + if (vx_flags(VXF_IGNEG_NICE, 0))
17180 no_nice = security_task_setnice(p, niceval);
17181 @@ -179,6 +183,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17183 pgrp = task_pgrp(current);
17184 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17185 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17187 error = set_one_prio(p, niceval, error);
17188 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17190 @@ -240,6 +246,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17192 pgrp = task_pgrp(current);
17193 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17194 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17196 niceval = 20 - task_nice(p);
17197 if (niceval > retval)
17199 @@ -349,6 +357,9 @@ void kernel_power_off(void)
17200 machine_power_off();
17202 EXPORT_SYMBOL_GPL(kernel_power_off);
17204 +long vs_reboot(unsigned int, void __user *);
17207 * Reboot system call: for obvious reasons only root may call it,
17208 * and even root needs to set up some magic numbers in the registers
17209 @@ -381,6 +392,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17210 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17211 cmd = LINUX_REBOOT_CMD_HALT;
17213 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17214 + return vs_reboot(cmd, arg);
17218 case LINUX_REBOOT_CMD_RESTART:
17219 @@ -1134,7 +1148,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17221 char tmp[__NEW_UTS_LEN];
17223 - if (!capable(CAP_SYS_ADMIN))
17224 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17226 if (len < 0 || len > __NEW_UTS_LEN)
17228 @@ -1183,7 +1197,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17230 char tmp[__NEW_UTS_LEN];
17232 - if (!capable(CAP_SYS_ADMIN))
17233 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17235 if (len < 0 || len > __NEW_UTS_LEN)
17237 @@ -1252,7 +1266,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17239 old_rlim = current->signal->rlim + resource;
17240 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17241 - !capable(CAP_SYS_RESOURCE))
17242 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17244 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17246 diff -NurpP --minimal linux-2.6.32.24/kernel/sysctl.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sysctl.c
17247 --- linux-2.6.32.24/kernel/sysctl.c 2010-10-04 08:56:18.000000000 +0200
17248 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sysctl.c 2010-01-20 04:21:33.000000000 +0100
17249 @@ -124,6 +124,7 @@ static int ngroups_max = NGROUPS_MAX;
17250 extern char modprobe_path[];
17251 extern int modules_disabled;
17253 +extern char vshelper_path[];
17254 #ifdef CONFIG_CHR_DEV_SG
17255 extern int sg_big_buff;
17257 @@ -593,6 +594,15 @@ static struct ctl_table kern_table[] = {
17258 .strategy = &sysctl_string,
17262 + .ctl_name = KERN_VSHELPER,
17263 + .procname = "vshelper",
17264 + .data = &vshelper_path,
17267 + .proc_handler = &proc_dostring,
17268 + .strategy = &sysctl_string,
17270 #ifdef CONFIG_CHR_DEV_SG
17272 .ctl_name = KERN_SG_BIG_BUFF,
17273 diff -NurpP --minimal linux-2.6.32.24/kernel/sysctl_check.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sysctl_check.c
17274 --- linux-2.6.32.24/kernel/sysctl_check.c 2010-10-04 08:56:18.000000000 +0200
17275 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/sysctl_check.c 2010-02-12 10:59:55.000000000 +0100
17276 @@ -39,6 +39,7 @@ static const struct trans_ctl_table tran
17278 { KERN_PANIC, "panic" },
17279 { KERN_REALROOTDEV, "real-root-dev" },
17280 + { KERN_VSHELPER, "vshelper", },
17282 { KERN_SPARC_REBOOT, "reboot-cmd" },
17283 { KERN_CTLALTDEL, "ctrl-alt-del" },
17284 @@ -1218,6 +1219,22 @@ static const struct trans_ctl_table tran
17288 +static struct trans_ctl_table trans_vserver_table[] = {
17289 + { 1, "debug_switch" },
17290 + { 2, "debug_xid" },
17291 + { 3, "debug_nid" },
17292 + { 4, "debug_tag" },
17293 + { 5, "debug_net" },
17294 + { 6, "debug_limit" },
17295 + { 7, "debug_cres" },
17296 + { 8, "debug_dlim" },
17297 + { 9, "debug_quota" },
17298 + { 10, "debug_cvirt" },
17299 + { 11, "debug_space" },
17300 + { 12, "debug_misc" },
17304 static const struct trans_ctl_table trans_root_table[] = {
17305 { CTL_KERN, "kernel", trans_kern_table },
17306 { CTL_VM, "vm", trans_vm_table },
17307 @@ -1234,6 +1251,7 @@ static const struct trans_ctl_table tran
17308 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
17309 { CTL_PM, "pm", trans_pm_table },
17310 { CTL_FRV, "frv", trans_frv_table },
17311 + { CTL_VSERVER, "vserver", trans_vserver_table },
17315 diff -NurpP --minimal linux-2.6.32.24/kernel/time.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/time.c
17316 --- linux-2.6.32.24/kernel/time.c 2009-12-03 20:02:58.000000000 +0100
17317 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/time.c 2009-12-03 20:04:56.000000000 +0100
17318 @@ -63,6 +63,7 @@ EXPORT_SYMBOL(sys_tz);
17319 SYSCALL_DEFINE1(time, time_t __user *, tloc)
17321 time_t i = get_seconds();
17322 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17325 if (put_user(i,tloc))
17326 @@ -93,7 +94,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
17330 - do_settimeofday(&tv);
17331 + vx_settimeofday(&tv);
17335 @@ -104,7 +105,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17337 if (likely(tv != NULL)) {
17338 struct timeval ktv;
17339 - do_gettimeofday(&ktv);
17340 + vx_gettimeofday(&ktv);
17341 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17344 @@ -179,7 +180,7 @@ int do_sys_settimeofday(struct timespec
17345 /* SMP safe, again the code in arch/foo/time.c should
17346 * globally block out interrupts when it runs.
17348 - return do_settimeofday(tv);
17349 + return vx_settimeofday(tv);
17353 @@ -311,7 +312,7 @@ void getnstimeofday(struct timespec *tv)
17357 - do_gettimeofday(&x);
17358 + vx_gettimeofday(&x);
17359 tv->tv_sec = x.tv_sec;
17360 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17362 diff -NurpP --minimal linux-2.6.32.24/kernel/timer.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/timer.c
17363 --- linux-2.6.32.24/kernel/timer.c 2009-12-03 20:02:58.000000000 +0100
17364 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/timer.c 2009-12-03 20:04:56.000000000 +0100
17366 #include <linux/kallsyms.h>
17367 #include <linux/perf_event.h>
17368 #include <linux/sched.h>
17369 +#include <linux/vs_base.h>
17370 +#include <linux/vs_cvirt.h>
17371 +#include <linux/vs_pid.h>
17372 +#include <linux/vserver/sched.h>
17374 #include <asm/uaccess.h>
17375 #include <asm/unistd.h>
17376 @@ -1255,12 +1259,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17383 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17384 - * should be moved into arch/i386 instead?
17388 * sys_getpid - return the thread group id of the current process
17389 @@ -1289,10 +1287,23 @@ SYSCALL_DEFINE0(getppid)
17391 pid = task_tgid_vnr(current->real_parent);
17393 + return vx_map_pid(pid);
17400 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17403 +asmlinkage long do_getxpid(long *ppid)
17405 + *ppid = sys_getppid();
17406 + return sys_getpid();
17409 +#else /* _alpha_ */
17411 SYSCALL_DEFINE0(getuid)
17413 /* Only we change this so SMP safe */
17414 diff -NurpP --minimal linux-2.6.32.24/kernel/user.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/user.c
17415 --- linux-2.6.32.24/kernel/user.c 2009-12-03 20:02:58.000000000 +0100
17416 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/user.c 2009-12-03 20:04:56.000000000 +0100
17417 @@ -251,10 +251,10 @@ static struct kobj_type uids_ktype = {
17419 * See Documentation/scheduler/sched-design-CFS.txt for ramifications.
17421 -static int uids_user_create(struct user_struct *up)
17422 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
17424 struct kobject *kobj = &up->kobj;
17428 memset(kobj, 0, sizeof(struct kobject));
17429 if (up->user_ns != &init_user_ns)
17430 @@ -282,7 +282,7 @@ int __init uids_sysfs_init(void)
17434 - return uids_user_create(&root_user);
17435 + return uids_user_create(NULL, &root_user);
17438 /* delayed work function to remove sysfs directory for a user and free up
17439 @@ -353,7 +353,8 @@ static struct user_struct *uid_hash_find
17442 int uids_sysfs_init(void) { return 0; }
17443 -static inline int uids_user_create(struct user_struct *up) { return 0; }
17444 +static inline int uids_user_create(struct user_namespace *ns,
17445 + struct user_struct *up) { return 0; }
17446 static inline void uids_mutex_lock(void) { }
17447 static inline void uids_mutex_unlock(void) { }
17449 @@ -450,7 +451,7 @@ struct user_struct *alloc_uid(struct use
17451 new->user_ns = get_user_ns(ns);
17453 - if (uids_user_create(new))
17454 + if (uids_user_create(ns, new))
17455 goto out_destoy_sched;
17458 diff -NurpP --minimal linux-2.6.32.24/kernel/user_namespace.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/user_namespace.c
17459 --- linux-2.6.32.24/kernel/user_namespace.c 2009-03-24 14:22:45.000000000 +0100
17460 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/user_namespace.c 2009-12-03 20:04:56.000000000 +0100
17462 #include <linux/slab.h>
17463 #include <linux/user_namespace.h>
17464 #include <linux/cred.h>
17465 +#include <linux/vserver/global.h>
17468 * Create a new user namespace, deriving the creator from the user in the
17469 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
17472 kref_init(&ns->kref);
17473 + atomic_inc(&vs_global_user_ns);
17475 for (n = 0; n < UIDHASH_SZ; ++n)
17476 INIT_HLIST_HEAD(ns->uidhash_table + n);
17477 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
17478 struct user_namespace *ns =
17479 container_of(kref, struct user_namespace, kref);
17481 + /* FIXME: maybe move into destroyer? */
17482 + atomic_dec(&vs_global_user_ns);
17483 INIT_WORK(&ns->destroyer, free_user_ns_work);
17484 schedule_work(&ns->destroyer);
17486 diff -NurpP --minimal linux-2.6.32.24/kernel/utsname.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/utsname.c
17487 --- linux-2.6.32.24/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
17488 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/utsname.c 2009-12-03 20:04:56.000000000 +0100
17489 @@ -14,14 +14,17 @@
17490 #include <linux/utsname.h>
17491 #include <linux/err.h>
17492 #include <linux/slab.h>
17493 +#include <linux/vserver/global.h>
17495 static struct uts_namespace *create_uts_ns(void)
17497 struct uts_namespace *uts_ns;
17499 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17502 kref_init(&uts_ns->kref);
17503 + atomic_inc(&vs_global_uts_ns);
17508 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
17509 struct uts_namespace *ns;
17511 ns = container_of(kref, struct uts_namespace, kref);
17512 + atomic_dec(&vs_global_uts_ns);
17515 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/cacct.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cacct.c
17516 --- linux-2.6.32.24/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17517 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cacct.c 2009-12-03 20:04:56.000000000 +0100
17520 + * linux/kernel/vserver/cacct.c
17522 + * Virtual Server: Context Accounting
17524 + * Copyright (C) 2006-2007 Herbert Pötzl
17526 + * V0.01 added accounting stats
17530 +#include <linux/types.h>
17531 +#include <linux/vs_context.h>
17532 +#include <linux/vserver/cacct_cmd.h>
17533 +#include <linux/vserver/cacct_int.h>
17535 +#include <asm/errno.h>
17536 +#include <asm/uaccess.h>
17539 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17541 + struct vcmd_sock_stat_v0 vc_data;
17544 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17547 + field = vc_data.field;
17548 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17551 + for (j = 0; j < 3; j++) {
17552 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17553 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17556 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17561 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/cacct_init.h linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cacct_init.h
17562 --- linux-2.6.32.24/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
17563 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cacct_init.h 2009-12-03 20:04:56.000000000 +0100
17567 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17572 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17573 + for (j = 0; j < 3; j++) {
17574 + atomic_long_set(&cacct->sock[i][j].count, 0);
17575 + atomic_long_set(&cacct->sock[i][j].total, 0);
17578 + for (i = 0; i < 8; i++)
17579 + atomic_set(&cacct->slab[i], 0);
17580 + for (i = 0; i < 5; i++)
17581 + for (j = 0; j < 4; j++)
17582 + atomic_set(&cacct->page[i][j], 0);
17585 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17590 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/cacct_proc.h linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cacct_proc.h
17591 --- linux-2.6.32.24/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17592 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cacct_proc.h 2009-12-03 20:04:56.000000000 +0100
17594 +#ifndef _VX_CACCT_PROC_H
17595 +#define _VX_CACCT_PROC_H
17597 +#include <linux/vserver/cacct_int.h>
17600 +#define VX_SOCKA_TOP \
17601 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17603 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17605 + int i, j, length = 0;
17606 + static char *type[VXA_SOCK_SIZE] = {
17607 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17610 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17611 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17612 + length += sprintf(buffer + length, "%s:", type[i]);
17613 + for (j = 0; j < 3; j++) {
17614 + length += sprintf(buffer + length,
17615 + "\t%10lu/%-10lu",
17616 + vx_sock_count(cacct, i, j),
17617 + vx_sock_total(cacct, i, j));
17619 + buffer[length++] = '\n';
17622 + length += sprintf(buffer + length, "\n");
17623 + length += sprintf(buffer + length,
17624 + "slab:\t %8u %8u %8u %8u\n",
17625 + atomic_read(&cacct->slab[1]),
17626 + atomic_read(&cacct->slab[4]),
17627 + atomic_read(&cacct->slab[0]),
17628 + atomic_read(&cacct->slab[2]));
17630 + length += sprintf(buffer + length, "\n");
17631 + for (i = 0; i < 5; i++) {
17632 + length += sprintf(buffer + length,
17633 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17634 + atomic_read(&cacct->page[i][0]),
17635 + atomic_read(&cacct->page[i][1]),
17636 + atomic_read(&cacct->page[i][2]),
17637 + atomic_read(&cacct->page[i][3]),
17638 + atomic_read(&cacct->page[i][4]),
17639 + atomic_read(&cacct->page[i][5]),
17640 + atomic_read(&cacct->page[i][6]),
17641 + atomic_read(&cacct->page[i][7]));
17646 +#endif /* _VX_CACCT_PROC_H */
17647 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/context.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/context.c
17648 --- linux-2.6.32.24/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17649 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/context.c 2010-03-13 21:49:35.000000000 +0100
17652 + * linux/kernel/vserver/context.c
17654 + * Virtual Server: Context Support
17656 + * Copyright (C) 2003-2007 Herbert Pötzl
17658 + * V0.01 context helper
17659 + * V0.02 vx_ctx_kill syscall command
17660 + * V0.03 replaced context_info calls
17661 + * V0.04 redesign of struct (de)alloc
17662 + * V0.05 rlimit basic implementation
17663 + * V0.06 task_xid and info commands
17664 + * V0.07 context flags and caps
17665 + * V0.08 switch to RCU based hash
17666 + * V0.09 revert to non RCU for now
17667 + * V0.10 and back to working RCU hash
17668 + * V0.11 and back to locking again
17669 + * V0.12 referenced context store
17670 + * V0.13 separate per cpu data
17671 + * V0.14 changed vcmds to vxi arg
17672 + * V0.15 added context stat
17673 + * V0.16 have __create claim() the vxi
17674 + * V0.17 removed older and legacy stuff
17678 +#include <linux/slab.h>
17679 +#include <linux/types.h>
17680 +#include <linux/security.h>
17681 +#include <linux/pid_namespace.h>
17683 +#include <linux/vserver/context.h>
17684 +#include <linux/vserver/network.h>
17685 +#include <linux/vserver/debug.h>
17686 +#include <linux/vserver/limit.h>
17687 +#include <linux/vserver/limit_int.h>
17688 +#include <linux/vserver/space.h>
17689 +#include <linux/init_task.h>
17690 +#include <linux/fs_struct.h>
17692 +#include <linux/vs_context.h>
17693 +#include <linux/vs_limit.h>
17694 +#include <linux/vs_pid.h>
17695 +#include <linux/vserver/context_cmd.h>
17697 +#include "cvirt_init.h"
17698 +#include "cacct_init.h"
17699 +#include "limit_init.h"
17700 +#include "sched_init.h"
17703 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17704 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17707 +/* now inactive context structures */
17709 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17711 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17714 +/* __alloc_vx_info()
17716 + * allocate an initialized vx_info struct
17717 + * doesn't make it visible (hash) */
17719 +static struct vx_info *__alloc_vx_info(xid_t xid)
17721 + struct vx_info *new = NULL;
17724 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17726 + /* would this benefit from a slab cache? */
17727 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17731 + memset(new, 0, sizeof(struct vx_info));
17733 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17734 + if (!new->ptr_pc)
17737 + new->vx_id = xid;
17738 + INIT_HLIST_NODE(&new->vx_hlist);
17739 + atomic_set(&new->vx_usecnt, 0);
17740 + atomic_set(&new->vx_tasks, 0);
17741 + new->vx_parent = NULL;
17742 + new->vx_state = 0;
17743 + init_waitqueue_head(&new->vx_wait);
17745 + /* prepare reaper */
17746 + get_task_struct(init_pid_ns.child_reaper);
17747 + new->vx_reaper = init_pid_ns.child_reaper;
17748 + new->vx_badness_bias = 0;
17750 + /* rest of init goes here */
17751 + vx_info_init_limit(&new->limit);
17752 + vx_info_init_sched(&new->sched);
17753 + vx_info_init_cvirt(&new->cvirt);
17754 + vx_info_init_cacct(&new->cacct);
17756 + /* per cpu data structures */
17757 + for_each_possible_cpu(cpu) {
17758 + vx_info_init_sched_pc(
17759 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17760 + vx_info_init_cvirt_pc(
17761 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17764 + new->vx_flags = VXF_INIT_SET;
17765 + cap_set_init_eff(new->vx_bcaps);
17766 + new->vx_ccaps = 0;
17767 + new->vx_umask = 0;
17769 + new->reboot_cmd = 0;
17770 + new->exit_code = 0;
17772 + // preconfig fs entries
17773 + for (index = 0; index < VX_SPACES; index++) {
17774 + write_lock(&init_fs.lock);
17776 + write_unlock(&init_fs.lock);
17777 + new->vx_fs[index] = &init_fs;
17780 + vxdprintk(VXD_CBIT(xid, 0),
17781 + "alloc_vx_info(%d) = %p", xid, new);
17782 + vxh_alloc_vx_info(new);
17783 + atomic_inc(&vx_global_ctotal);
17792 +/* __dealloc_vx_info()
17794 + * final disposal of vx_info */
17796 +static void __dealloc_vx_info(struct vx_info *vxi)
17798 +#ifdef CONFIG_VSERVER_WARN
17799 + struct vx_info_save vxis;
17802 + vxdprintk(VXD_CBIT(xid, 0),
17803 + "dealloc_vx_info(%p)", vxi);
17804 + vxh_dealloc_vx_info(vxi);
17806 +#ifdef CONFIG_VSERVER_WARN
17807 + enter_vx_info(vxi, &vxis);
17808 + vx_info_exit_limit(&vxi->limit);
17809 + vx_info_exit_sched(&vxi->sched);
17810 + vx_info_exit_cvirt(&vxi->cvirt);
17811 + vx_info_exit_cacct(&vxi->cacct);
17813 + for_each_possible_cpu(cpu) {
17814 + vx_info_exit_sched_pc(
17815 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17816 + vx_info_exit_cvirt_pc(
17817 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17819 + leave_vx_info(&vxis);
17823 + vxi->vx_state |= VXS_RELEASED;
17826 + free_percpu(vxi->ptr_pc);
17829 + atomic_dec(&vx_global_ctotal);
17832 +static void __shutdown_vx_info(struct vx_info *vxi)
17834 + struct nsproxy *nsproxy;
17835 + struct fs_struct *fs;
17840 + vxi->vx_state |= VXS_SHUTDOWN;
17841 + vs_state_change(vxi, VSC_SHUTDOWN);
17843 + for (index = 0; index < VX_SPACES; index++) {
17844 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17846 + put_nsproxy(nsproxy);
17848 + fs = xchg(&vxi->vx_fs[index], NULL);
17849 + write_lock(&fs->lock);
17850 + kill = !--fs->users;
17851 + write_unlock(&fs->lock);
17853 + free_fs_struct(fs);
17857 +/* exported stuff */
17859 +void free_vx_info(struct vx_info *vxi)
17861 + unsigned long flags;
17864 + /* check for reference counts first */
17865 + BUG_ON(atomic_read(&vxi->vx_usecnt));
17866 + BUG_ON(atomic_read(&vxi->vx_tasks));
17868 + /* context must not be hashed */
17869 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17871 + /* context shutdown is mandatory */
17872 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17874 + /* nsproxy and fs check */
17875 + for (index = 0; index < VX_SPACES; index++) {
17876 + BUG_ON(vxi->vx_nsproxy[index]);
17877 + BUG_ON(vxi->vx_fs[index]);
17880 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17881 + hlist_del(&vxi->vx_hlist);
17882 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17884 + __dealloc_vx_info(vxi);
17888 +/* hash table for vx_info hash */
17890 +#define VX_HASH_SIZE 13
17892 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17893 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17895 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17898 +static inline unsigned int __hashval(xid_t xid)
17900 + return (xid % VX_HASH_SIZE);
17905 +/* __hash_vx_info()
17907 + * add the vxi to the global hash table
17908 + * requires the hash_lock to be held */
17910 +static inline void __hash_vx_info(struct vx_info *vxi)
17912 + struct hlist_head *head;
17914 + vxd_assert_lock(&vx_info_hash_lock);
17915 + vxdprintk(VXD_CBIT(xid, 4),
17916 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17917 + vxh_hash_vx_info(vxi);
17919 + /* context must not be hashed */
17920 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17922 + vxi->vx_state |= VXS_HASHED;
17923 + head = &vx_info_hash[__hashval(vxi->vx_id)];
17924 + hlist_add_head(&vxi->vx_hlist, head);
17925 + atomic_inc(&vx_global_cactive);
17928 +/* __unhash_vx_info()
17930 + * remove the vxi from the global hash table
17931 + * requires the hash_lock to be held */
17933 +static inline void __unhash_vx_info(struct vx_info *vxi)
17935 + unsigned long flags;
17937 + vxd_assert_lock(&vx_info_hash_lock);
17938 + vxdprintk(VXD_CBIT(xid, 4),
17939 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17940 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17941 + vxh_unhash_vx_info(vxi);
17943 + /* context must be hashed */
17944 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17945 + /* but without tasks */
17946 + BUG_ON(atomic_read(&vxi->vx_tasks));
17948 + vxi->vx_state &= ~VXS_HASHED;
17949 + hlist_del_init(&vxi->vx_hlist);
17950 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17951 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17952 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17953 + atomic_dec(&vx_global_cactive);
17957 +/* __lookup_vx_info()
17959 + * requires the hash_lock to be held
17960 + * doesn't increment the vx_refcnt */
17962 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17964 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17965 + struct hlist_node *pos;
17966 + struct vx_info *vxi;
17968 + vxd_assert_lock(&vx_info_hash_lock);
17969 + hlist_for_each(pos, head) {
17970 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17972 + if (vxi->vx_id == xid)
17977 + vxdprintk(VXD_CBIT(xid, 0),
17978 + "__lookup_vx_info(#%u): %p[#%u]",
17979 + xid, vxi, vxi ? vxi->vx_id : 0);
17980 + vxh_lookup_vx_info(vxi, xid);
17985 +/* __create_vx_info()
17987 + * create the requested context
17988 + * get(), claim() and hash it */
17990 +static struct vx_info *__create_vx_info(int id)
17992 + struct vx_info *new, *vxi = NULL;
17994 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17996 + if (!(new = __alloc_vx_info(id)))
17997 + return ERR_PTR(-ENOMEM);
17999 + /* required to make dynamic xids unique */
18000 + spin_lock(&vx_info_hash_lock);
18002 + /* static context requested */
18003 + if ((vxi = __lookup_vx_info(id))) {
18004 + vxdprintk(VXD_CBIT(xid, 0),
18005 + "create_vx_info(%d) = %p (already there)", id, vxi);
18006 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18007 + vxi = ERR_PTR(-EBUSY);
18009 + vxi = ERR_PTR(-EEXIST);
18012 + /* new context */
18013 + vxdprintk(VXD_CBIT(xid, 0),
18014 + "create_vx_info(%d) = %p (new)", id, new);
18015 + claim_vx_info(new, NULL);
18016 + __hash_vx_info(get_vx_info(new));
18017 + vxi = new, new = NULL;
18020 + spin_unlock(&vx_info_hash_lock);
18021 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18023 + __dealloc_vx_info(new);
18028 +/* exported stuff */
18031 +void unhash_vx_info(struct vx_info *vxi)
18033 + __shutdown_vx_info(vxi);
18034 + spin_lock(&vx_info_hash_lock);
18035 + __unhash_vx_info(vxi);
18036 + spin_unlock(&vx_info_hash_lock);
18037 + __wakeup_vx_info(vxi);
18041 +/* lookup_vx_info()
18043 + * search for a vx_info and get() it
18044 + * negative id means current */
18046 +struct vx_info *lookup_vx_info(int id)
18048 + struct vx_info *vxi = NULL;
18051 + vxi = get_vx_info(current_vx_info());
18052 + } else if (id > 1) {
18053 + spin_lock(&vx_info_hash_lock);
18054 + vxi = get_vx_info(__lookup_vx_info(id));
18055 + spin_unlock(&vx_info_hash_lock);
18060 +/* xid_is_hashed()
18062 + * verify that xid is still hashed */
18064 +int xid_is_hashed(xid_t xid)
18068 + spin_lock(&vx_info_hash_lock);
18069 + hashed = (__lookup_vx_info(xid) != NULL);
18070 + spin_unlock(&vx_info_hash_lock);
18074 +#ifdef CONFIG_PROC_FS
18078 + * get a subset of hashed xids for proc
18079 + * assumes size is at least one */
18081 +int get_xid_list(int index, unsigned int *xids, int size)
18083 + int hindex, nr_xids = 0;
18085 + /* only show current and children */
18086 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18089 + xids[nr_xids] = vx_current_xid();
18093 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18094 + struct hlist_head *head = &vx_info_hash[hindex];
18095 + struct hlist_node *pos;
18097 + spin_lock(&vx_info_hash_lock);
18098 + hlist_for_each(pos, head) {
18099 + struct vx_info *vxi;
18104 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18105 + xids[nr_xids] = vxi->vx_id;
18106 + if (++nr_xids >= size) {
18107 + spin_unlock(&vx_info_hash_lock);
18111 + /* keep the lock time short */
18112 + spin_unlock(&vx_info_hash_lock);
18119 +#ifdef CONFIG_VSERVER_DEBUG
18121 +void dump_vx_info_inactive(int level)
18123 + struct hlist_node *entry, *next;
18125 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
18126 + struct vx_info *vxi =
18127 + list_entry(entry, struct vx_info, vx_hlist);
18129 + dump_vx_info(vxi, level);
18136 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18138 + struct user_struct *new_user, *old_user;
18143 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18146 + new_user = alloc_uid(vxi->vx_id, p->uid);
18150 + old_user = p->user;
18151 + if (new_user != old_user) {
18152 + atomic_inc(&new_user->processes);
18153 + atomic_dec(&old_user->processes);
18154 + p->user = new_user;
18156 + free_uid(old_user);
18162 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18164 + // p->cap_effective &= vxi->vx_cap_bset;
18165 + p->cap_effective =
18166 + cap_intersect(p->cap_effective, vxi->cap_bset);
18167 + // p->cap_inheritable &= vxi->vx_cap_bset;
18168 + p->cap_inheritable =
18169 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
18170 + // p->cap_permitted &= vxi->vx_cap_bset;
18171 + p->cap_permitted =
18172 + cap_intersect(p->cap_permitted, vxi->cap_bset);
18177 +#include <linux/file.h>
18178 +#include <linux/fdtable.h>
18180 +static int vx_openfd_task(struct task_struct *tsk)
18182 + struct files_struct *files = tsk->files;
18183 + struct fdtable *fdt;
18184 + const unsigned long *bptr;
18185 + int count, total;
18187 + /* no rcu_read_lock() because of spin_lock() */
18188 + spin_lock(&files->file_lock);
18189 + fdt = files_fdtable(files);
18190 + bptr = fdt->open_fds->fds_bits;
18191 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
18192 + for (total = 0; count > 0; count--) {
18194 + total += hweight_long(*bptr);
18197 + spin_unlock(&files->file_lock);
18202 +/* for *space compatibility */
18204 +asmlinkage long sys_unshare(unsigned long);
18207 + * migrate task to new context
18208 + * gets vxi, puts old_vxi on change
18209 + * optionally unshares namespaces (hack)
18212 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18214 + struct vx_info *old_vxi;
18220 + vxdprintk(VXD_CBIT(xid, 5),
18221 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18222 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18224 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18225 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18228 + if (vx_info_state(vxi, VXS_SHUTDOWN))
18231 + old_vxi = task_get_vx_info(p);
18232 + if (old_vxi == vxi)
18235 +// if (!(ret = vx_migrate_user(p, vxi))) {
18240 + openfd = vx_openfd_task(p);
18243 + atomic_dec(&old_vxi->cvirt.nr_threads);
18244 + atomic_dec(&old_vxi->cvirt.nr_running);
18245 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18246 + /* FIXME: what about the struct files here? */
18247 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18248 + /* account for the executable */
18249 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18251 + atomic_inc(&vxi->cvirt.nr_threads);
18252 + atomic_inc(&vxi->cvirt.nr_running);
18253 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18254 + /* FIXME: what about the struct files here? */
18255 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18256 + /* account for the executable */
18257 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18260 + release_vx_info(old_vxi, p);
18261 + clr_vx_info(&p->vx_info);
18263 + claim_vx_info(vxi, p);
18264 + set_vx_info(&p->vx_info, vxi);
18265 + p->xid = vxi->vx_id;
18267 + vxdprintk(VXD_CBIT(xid, 5),
18268 + "moved task %p into vxi:%p[#%d]",
18269 + p, vxi, vxi->vx_id);
18271 + // vx_mask_cap_bset(vxi, p);
18274 + /* hack for *spaces to provide compatibility */
18276 + struct nsproxy *old_nsp, *new_nsp;
18278 + ret = unshare_nsproxy_namespaces(
18279 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18284 + old_nsp = xchg(&p->nsproxy, new_nsp);
18285 + vx_set_space(vxi,
18286 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18287 + put_nsproxy(old_nsp);
18291 + put_vx_info(old_vxi);
18295 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18297 + struct task_struct *old_reaper;
18302 + vxdprintk(VXD_CBIT(xid, 6),
18303 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18304 + vxi, vxi->vx_id, p, p->xid, p->pid);
18306 + old_reaper = vxi->vx_reaper;
18307 + if (old_reaper == p)
18310 + /* set new child reaper */
18311 + get_task_struct(p);
18312 + vxi->vx_reaper = p;
18313 + put_task_struct(old_reaper);
18317 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18322 + vxdprintk(VXD_CBIT(xid, 6),
18323 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18324 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18326 + vxi->vx_flags &= ~VXF_STATE_INIT;
18327 + // vxi->vx_initpid = p->tgid;
18328 + vxi->vx_initpid = p->pid;
18332 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18334 + vxdprintk(VXD_CBIT(xid, 6),
18335 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18336 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18338 + vxi->exit_code = code;
18339 + vxi->vx_initpid = 0;
18343 +void vx_set_persistent(struct vx_info *vxi)
18345 + vxdprintk(VXD_CBIT(xid, 6),
18346 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18348 + get_vx_info(vxi);
18349 + claim_vx_info(vxi, NULL);
18352 +void vx_clear_persistent(struct vx_info *vxi)
18354 + vxdprintk(VXD_CBIT(xid, 6),
18355 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18357 + release_vx_info(vxi, NULL);
18358 + put_vx_info(vxi);
18361 +void vx_update_persistent(struct vx_info *vxi)
18363 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18364 + vx_set_persistent(vxi);
18366 + vx_clear_persistent(vxi);
18370 +/* task must be current or locked */
18372 +void exit_vx_info(struct task_struct *p, int code)
18374 + struct vx_info *vxi = p->vx_info;
18377 + atomic_dec(&vxi->cvirt.nr_threads);
18380 + vxi->exit_code = code;
18381 + release_vx_info(vxi, p);
18385 +void exit_vx_info_early(struct task_struct *p, int code)
18387 + struct vx_info *vxi = p->vx_info;
18390 + if (vxi->vx_initpid == p->pid)
18391 + vx_exit_init(vxi, p, code);
18392 + if (vxi->vx_reaper == p)
18393 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18398 +/* vserver syscall commands below here */
18400 +/* taks xid and vx_info functions */
18402 +#include <asm/uaccess.h>
18405 +int vc_task_xid(uint32_t id)
18410 + struct task_struct *tsk;
18412 + read_lock(&tasklist_lock);
18413 + tsk = find_task_by_real_pid(id);
18414 + xid = (tsk) ? tsk->xid : -ESRCH;
18415 + read_unlock(&tasklist_lock);
18417 + xid = vx_current_xid();
18422 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18424 + struct vcmd_vx_info_v0 vc_data;
18426 + vc_data.xid = vxi->vx_id;
18427 + vc_data.initpid = vxi->vx_initpid;
18429 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18435 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18437 + struct vcmd_ctx_stat_v0 vc_data;
18439 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18440 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18442 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18448 +/* context functions */
18450 +int vc_ctx_create(uint32_t xid, void __user *data)
18452 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18453 + struct vx_info *new_vxi;
18456 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18459 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
18462 + new_vxi = __create_vx_info(xid);
18463 + if (IS_ERR(new_vxi))
18464 + return PTR_ERR(new_vxi);
18466 + /* initial flags */
18467 + new_vxi->vx_flags = vc_data.flagword;
18470 + if (vs_state_change(new_vxi, VSC_STARTUP))
18473 + ret = vx_migrate_task(current, new_vxi, (!data));
18477 + /* return context id on success */
18478 + ret = new_vxi->vx_id;
18480 + /* get a reference for persistent contexts */
18481 + if ((vc_data.flagword & VXF_PERSISTENT))
18482 + vx_set_persistent(new_vxi);
18484 + release_vx_info(new_vxi, NULL);
18485 + put_vx_info(new_vxi);
18490 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18492 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18495 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18498 + ret = vx_migrate_task(current, vxi, 0);
18501 + if (vc_data.flagword & VXM_SET_INIT)
18502 + ret = vx_set_init(vxi, current);
18505 + if (vc_data.flagword & VXM_SET_REAPER)
18506 + ret = vx_set_reaper(vxi, current);
18511 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18513 + struct vcmd_ctx_flags_v0 vc_data;
18515 + vc_data.flagword = vxi->vx_flags;
18517 + /* special STATE flag handling */
18518 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18520 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18525 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18527 + struct vcmd_ctx_flags_v0 vc_data;
18528 + uint64_t mask, trigger;
18530 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18533 + /* special STATE flag handling */
18534 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18535 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18537 + if (vxi == current_vx_info()) {
18538 + /* if (trigger & VXF_STATE_SETUP)
18539 + vx_mask_cap_bset(vxi, current); */
18540 + if (trigger & VXF_STATE_INIT) {
18543 + ret = vx_set_init(vxi, current);
18546 + ret = vx_set_reaper(vxi, current);
18552 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18553 + vc_data.flagword, mask);
18554 + if (trigger & VXF_PERSISTENT)
18555 + vx_update_persistent(vxi);
18561 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18563 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18565 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18569 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18571 + kernel_cap_t c = __cap_empty_set;
18573 + c.cap[0] = v & 0xFFFFFFFF;
18574 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18576 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18581 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18584 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18586 + *ccaps = vxi->vx_ccaps;
18591 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18593 + struct vcmd_ctx_caps_v1 vc_data;
18596 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18599 + vc_data.cmask = ~0ULL;
18601 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18606 +static int do_set_caps(struct vx_info *vxi,
18607 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18609 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18612 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18613 + bcaps, bmask, ccaps, cmask);
18615 + vxi->vx_bcaps = cap_t_from_caps(
18616 + vs_mask_flags(bcold, bcaps, bmask));
18617 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18622 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18624 + struct vcmd_ctx_caps_v1 vc_data;
18626 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18629 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18632 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18634 + struct vcmd_bcaps vc_data;
18637 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18640 + vc_data.bmask = ~0ULL;
18642 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18647 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18649 + struct vcmd_bcaps vc_data;
18651 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18654 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18658 +int vc_get_umask(struct vx_info *vxi, void __user *data)
18660 + struct vcmd_umask vc_data;
18662 + vc_data.umask = vxi->vx_umask;
18663 + vc_data.mask = ~0ULL;
18665 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18670 +int vc_set_umask(struct vx_info *vxi, void __user *data)
18672 + struct vcmd_umask vc_data;
18674 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18677 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
18678 + vc_data.umask, vc_data.mask);
18683 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18685 + struct vcmd_badness_v0 vc_data;
18687 + vc_data.bias = vxi->vx_badness_bias;
18689 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18694 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18696 + struct vcmd_badness_v0 vc_data;
18698 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18701 + vxi->vx_badness_bias = vc_data.bias;
18705 +#include <linux/module.h>
18707 +EXPORT_SYMBOL_GPL(free_vx_info);
18709 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/cvirt.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cvirt.c
18710 --- linux-2.6.32.24/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18711 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cvirt.c 2009-12-03 20:04:56.000000000 +0100
18714 + * linux/kernel/vserver/cvirt.c
18716 + * Virtual Server: Context Virtualization
18718 + * Copyright (C) 2004-2007 Herbert Pötzl
18720 + * V0.01 broken out from limit.c
18721 + * V0.02 added utsname stuff
18722 + * V0.03 changed vcmds to vxi arg
18726 +#include <linux/types.h>
18727 +#include <linux/utsname.h>
18728 +#include <linux/vs_cvirt.h>
18729 +#include <linux/vserver/switch.h>
18730 +#include <linux/vserver/cvirt_cmd.h>
18732 +#include <asm/uaccess.h>
18735 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18737 + struct vx_info *vxi = current_vx_info();
18739 + set_normalized_timespec(uptime,
18740 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18741 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18744 + set_normalized_timespec(idle,
18745 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18746 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18750 +uint64_t vx_idle_jiffies(void)
18752 + return init_task.utime + init_task.stime;
18757 +static inline uint32_t __update_loadavg(uint32_t load,
18758 + int wsize, int delta, int n)
18760 + unsigned long long calc, prev;
18762 + /* just set it to n */
18763 + if (unlikely(delta >= wsize))
18764 + return (n << FSHIFT);
18766 + calc = delta * n;
18768 + prev = (wsize - delta);
18771 + do_div(calc, wsize);
18776 +void vx_update_load(struct vx_info *vxi)
18778 + uint32_t now, last, delta;
18779 + unsigned int nr_running, nr_uninterruptible;
18780 + unsigned int total;
18781 + unsigned long flags;
18783 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18786 + last = vxi->cvirt.load_last;
18787 + delta = now - last;
18789 + if (delta < 5*HZ)
18792 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18793 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18794 + total = nr_running + nr_uninterruptible;
18796 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18797 + 60*HZ, delta, total);
18798 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18799 + 5*60*HZ, delta, total);
18800 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18801 + 15*60*HZ, delta, total);
18803 + vxi->cvirt.load_last = now;
18805 + atomic_inc(&vxi->cvirt.load_updates);
18806 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18811 + * Commands to do_syslog:
18813 + * 0 -- Close the log. Currently a NOP.
18814 + * 1 -- Open the log. Currently a NOP.
18815 + * 2 -- Read from the log.
18816 + * 3 -- Read all messages remaining in the ring buffer.
18817 + * 4 -- Read and clear all messages remaining in the ring buffer
18818 + * 5 -- Clear ring buffer.
18819 + * 6 -- Disable printk's to console
18820 + * 7 -- Enable printk's to console
18821 + * 8 -- Set level of messages printed to console
18822 + * 9 -- Return number of unread characters in the log buffer
18823 + * 10 -- Return size of the log buffer
18825 +int vx_do_syslog(int type, char __user *buf, int len)
18828 + int do_clear = 0;
18829 + struct vx_info *vxi = current_vx_info();
18830 + struct _vx_syslog *log;
18834 + log = &vxi->cvirt.syslog;
18837 + case 0: /* Close log */
18838 + case 1: /* Open log */
18840 + case 2: /* Read from log */
18841 + error = wait_event_interruptible(log->log_wait,
18842 + (log->log_start - log->log_end));
18845 + spin_lock_irq(&log->logbuf_lock);
18846 + spin_unlock_irq(&log->logbuf_lock);
18848 + case 4: /* Read/clear last kernel messages */
18850 + /* fall through */
18851 + case 3: /* Read last kernel messages */
18854 + case 5: /* Clear ring buffer */
18857 + case 6: /* Disable logging to console */
18858 + case 7: /* Enable logging to console */
18859 + case 8: /* Set level of messages printed to console */
18862 + case 9: /* Number of chars in the log buffer */
18864 + case 10: /* Size of the log buffer */
18874 +/* virtual host info names */
18876 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18878 + struct nsproxy *nsproxy;
18879 + struct uts_namespace *uts;
18881 + if (id == VHIN_CONTEXT)
18882 + return vxi->vx_name;
18884 + nsproxy = vxi->vx_nsproxy[0];
18888 + uts = nsproxy->uts_ns;
18893 + case VHIN_SYSNAME:
18894 + return uts->name.sysname;
18895 + case VHIN_NODENAME:
18896 + return uts->name.nodename;
18897 + case VHIN_RELEASE:
18898 + return uts->name.release;
18899 + case VHIN_VERSION:
18900 + return uts->name.version;
18901 + case VHIN_MACHINE:
18902 + return uts->name.machine;
18903 + case VHIN_DOMAINNAME:
18904 + return uts->name.domainname;
18911 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18913 + struct vcmd_vhi_name_v0 vc_data;
18916 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18919 + name = vx_vhi_name(vxi, vc_data.field);
18923 + memcpy(name, vc_data.name, 65);
18927 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18929 + struct vcmd_vhi_name_v0 vc_data;
18932 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18935 + name = vx_vhi_name(vxi, vc_data.field);
18939 + memcpy(vc_data.name, name, 65);
18940 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18946 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18948 + struct vcmd_virt_stat_v0 vc_data;
18949 + struct _vx_cvirt *cvirt = &vxi->cvirt;
18950 + struct timespec uptime;
18952 + do_posix_clock_monotonic_gettime(&uptime);
18953 + set_normalized_timespec(&uptime,
18954 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18955 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18957 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18958 + vc_data.uptime = timespec_to_ns(&uptime);
18959 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18960 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
18961 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18962 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18963 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18964 + vc_data.load[0] = cvirt->load[0];
18965 + vc_data.load[1] = cvirt->load[1];
18966 + vc_data.load[2] = cvirt->load[2];
18968 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18974 +#ifdef CONFIG_VSERVER_VTIME
18976 +/* virtualized time base */
18978 +void vx_gettimeofday(struct timeval *tv)
18980 + struct vx_info *vxi;
18982 + do_gettimeofday(tv);
18983 + if (!vx_flags(VXF_VIRT_TIME, 0))
18986 + vxi = current_vx_info();
18987 + tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
18988 + tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
18990 + if (tv->tv_usec >= USEC_PER_SEC) {
18992 + tv->tv_usec -= USEC_PER_SEC;
18993 + } else if (tv->tv_usec < 0) {
18995 + tv->tv_usec += USEC_PER_SEC;
18999 +int vx_settimeofday(struct timespec *ts)
19001 + struct timeval tv;
19002 + struct vx_info *vxi;
19004 + if (!vx_flags(VXF_VIRT_TIME, 0))
19005 + return do_settimeofday(ts);
19007 + do_gettimeofday(&tv);
19008 + vxi = current_vx_info();
19009 + vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
19010 + vxi->cvirt.bias_tv.tv_usec =
19011 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
19017 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/cvirt_init.h linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cvirt_init.h
19018 --- linux-2.6.32.24/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
19019 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cvirt_init.h 2009-12-03 20:04:56.000000000 +0100
19023 +extern uint64_t vx_idle_jiffies(void);
19025 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19027 + uint64_t idle_jiffies = vx_idle_jiffies();
19028 + uint64_t nsuptime;
19030 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19031 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19032 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19033 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19034 + cvirt->bias_tv.tv_sec = 0;
19035 + cvirt->bias_tv.tv_usec = 0;
19037 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19038 + atomic_set(&cvirt->nr_threads, 0);
19039 + atomic_set(&cvirt->nr_running, 0);
19040 + atomic_set(&cvirt->nr_uninterruptible, 0);
19041 + atomic_set(&cvirt->nr_onhold, 0);
19043 + spin_lock_init(&cvirt->load_lock);
19044 + cvirt->load_last = jiffies;
19045 + atomic_set(&cvirt->load_updates, 0);
19046 + cvirt->load[0] = 0;
19047 + cvirt->load[1] = 0;
19048 + cvirt->load[2] = 0;
19049 + atomic_set(&cvirt->total_forks, 0);
19051 + spin_lock_init(&cvirt->syslog.logbuf_lock);
19052 + init_waitqueue_head(&cvirt->syslog.log_wait);
19053 + cvirt->syslog.log_start = 0;
19054 + cvirt->syslog.log_end = 0;
19055 + cvirt->syslog.con_start = 0;
19056 + cvirt->syslog.logged_chars = 0;
19060 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19062 + // cvirt_pc->cpustat = { 0 };
19065 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19069 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19070 + "!!! cvirt: %p[nr_threads] = %d on exit.",
19072 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19073 + "!!! cvirt: %p[nr_running] = %d on exit.",
19075 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19076 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19078 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19079 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
19085 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19090 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/cvirt_proc.h linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cvirt_proc.h
19091 --- linux-2.6.32.24/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
19092 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/cvirt_proc.h 2009-12-03 20:04:56.000000000 +0100
19094 +#ifndef _VX_CVIRT_PROC_H
19095 +#define _VX_CVIRT_PROC_H
19097 +#include <linux/nsproxy.h>
19098 +#include <linux/mnt_namespace.h>
19099 +#include <linux/ipc_namespace.h>
19100 +#include <linux/utsname.h>
19101 +#include <linux/ipc.h>
19105 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19107 + struct mnt_namespace *ns;
19108 + struct uts_namespace *uts;
19109 + struct ipc_namespace *ipc;
19110 + struct path path;
19111 + char *pstr, *root;
19117 + length += sprintf(buffer + length,
19118 + "NSProxy:\t%p [%p,%p,%p]\n",
19119 + nsproxy, nsproxy->mnt_ns,
19120 + nsproxy->uts_ns, nsproxy->ipc_ns);
19122 + ns = nsproxy->mnt_ns;
19126 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19130 + path.mnt = ns->root;
19131 + path.dentry = ns->root->mnt_root;
19132 + root = d_path(&path, pstr, PATH_MAX - 2);
19133 + length += sprintf(buffer + length,
19134 + "Namespace:\t%p [#%u]\n"
19135 + "RootPath:\t%s\n",
19136 + ns, atomic_read(&ns->count),
19141 + uts = nsproxy->uts_ns;
19145 + length += sprintf(buffer + length,
19146 + "SysName:\t%.*s\n"
19147 + "NodeName:\t%.*s\n"
19148 + "Release:\t%.*s\n"
19149 + "Version:\t%.*s\n"
19150 + "Machine:\t%.*s\n"
19151 + "DomainName:\t%.*s\n",
19152 + __NEW_UTS_LEN, uts->name.sysname,
19153 + __NEW_UTS_LEN, uts->name.nodename,
19154 + __NEW_UTS_LEN, uts->name.release,
19155 + __NEW_UTS_LEN, uts->name.version,
19156 + __NEW_UTS_LEN, uts->name.machine,
19157 + __NEW_UTS_LEN, uts->name.domainname);
19160 + ipc = nsproxy->ipc_ns;
19164 + length += sprintf(buffer + length,
19165 + "SEMS:\t\t%d %d %d %d %d\n"
19166 + "MSG:\t\t%d %d %d\n"
19167 + "SHM:\t\t%lu %lu %d %d\n",
19168 + ipc->sem_ctls[0], ipc->sem_ctls[1],
19169 + ipc->sem_ctls[2], ipc->sem_ctls[3],
19171 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19172 + (unsigned long)ipc->shm_ctlmax,
19173 + (unsigned long)ipc->shm_ctlall,
19174 + ipc->shm_ctlmni, ipc->shm_tot);
19181 +#include <linux/sched.h>
19183 +#define LOAD_INT(x) ((x) >> FSHIFT)
19184 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19187 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19192 + length += sprintf(buffer + length,
19193 + "BiasUptime:\t%lu.%02lu\n",
19194 + (unsigned long)cvirt->bias_uptime.tv_sec,
19195 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19197 + a = cvirt->load[0] + (FIXED_1 / 200);
19198 + b = cvirt->load[1] + (FIXED_1 / 200);
19199 + c = cvirt->load[2] + (FIXED_1 / 200);
19200 + length += sprintf(buffer + length,
19201 + "nr_threads:\t%d\n"
19202 + "nr_running:\t%d\n"
19203 + "nr_unintr:\t%d\n"
19204 + "nr_onhold:\t%d\n"
19205 + "load_updates:\t%d\n"
19206 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19207 + "total_forks:\t%d\n",
19208 + atomic_read(&cvirt->nr_threads),
19209 + atomic_read(&cvirt->nr_running),
19210 + atomic_read(&cvirt->nr_uninterruptible),
19211 + atomic_read(&cvirt->nr_onhold),
19212 + atomic_read(&cvirt->load_updates),
19213 + LOAD_INT(a), LOAD_FRAC(a),
19214 + LOAD_INT(b), LOAD_FRAC(b),
19215 + LOAD_INT(c), LOAD_FRAC(c),
19216 + atomic_read(&cvirt->total_forks));
19221 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19222 + char *buffer, int cpu)
19228 +#endif /* _VX_CVIRT_PROC_H */
19229 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/debug.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/debug.c
19230 --- linux-2.6.32.24/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
19231 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/debug.c 2009-12-03 20:04:56.000000000 +0100
19234 + * kernel/vserver/debug.c
19236 + * Copyright (C) 2005-2007 Herbert Pötzl
19238 + * V0.01 vx_info dump support
19242 +#include <linux/module.h>
19244 +#include <linux/vserver/context.h>
19247 +void dump_vx_info(struct vx_info *vxi, int level)
19249 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19250 + atomic_read(&vxi->vx_usecnt),
19251 + atomic_read(&vxi->vx_tasks),
19254 + __dump_vx_limit(&vxi->limit);
19255 + __dump_vx_sched(&vxi->sched);
19256 + __dump_vx_cvirt(&vxi->cvirt);
19257 + __dump_vx_cacct(&vxi->cacct);
19263 +EXPORT_SYMBOL_GPL(dump_vx_info);
19265 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/device.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/device.c
19266 --- linux-2.6.32.24/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
19267 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/device.c 2009-12-03 20:04:56.000000000 +0100
19270 + * linux/kernel/vserver/device.c
19272 + * Linux-VServer: Device Support
19274 + * Copyright (C) 2006 Herbert Pötzl
19275 + * Copyright (C) 2007 Daniel Hokka Zakrisson
19277 + * V0.01 device mapping basics
19278 + * V0.02 added defaults
19282 +#include <linux/slab.h>
19283 +#include <linux/rcupdate.h>
19284 +#include <linux/fs.h>
19285 +#include <linux/namei.h>
19286 +#include <linux/hash.h>
19288 +#include <asm/errno.h>
19289 +#include <asm/uaccess.h>
19290 +#include <linux/vserver/base.h>
19291 +#include <linux/vserver/debug.h>
19292 +#include <linux/vserver/context.h>
19293 +#include <linux/vserver/device.h>
19294 +#include <linux/vserver/device_cmd.h>
19297 +#define DMAP_HASH_BITS 4
19300 +struct vs_mapping {
19302 + struct hlist_node hlist;
19303 + struct list_head list;
19305 +#define dm_hlist u.hlist
19306 +#define dm_list u.list
19309 + struct vx_dmap_target target;
19313 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19315 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19317 +static struct vx_dmap_target dmap_defaults[2] = {
19318 + { .flags = DATTR_OPEN },
19319 + { .flags = DATTR_OPEN },
19323 +struct kmem_cache *dmap_cachep __read_mostly;
19325 +int __init dmap_cache_init(void)
19327 + dmap_cachep = kmem_cache_create("dmap_cache",
19328 + sizeof(struct vs_mapping), 0,
19329 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19333 +__initcall(dmap_cache_init);
19336 +static inline unsigned int __hashval(dev_t dev, int bits)
19338 + return hash_long((unsigned long)dev, bits);
19342 +/* __hash_mapping()
19343 + * add the mapping to the hash table
19345 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19347 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19348 + struct hlist_head *head, *hash = dmap_main_hash;
19349 + int device = vdm->device;
19351 + spin_lock(hash_lock);
19352 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19353 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19355 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
19356 + hlist_add_head(&vdm->dm_hlist, head);
19357 + spin_unlock(hash_lock);
19361 +static inline int __mode_to_default(umode_t mode)
19374 +/* __set_default()
19377 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19378 + struct vx_dmap_target *vdmt)
19380 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19381 + spin_lock(hash_lock);
19384 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19386 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
19389 + spin_unlock(hash_lock);
19391 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19392 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19396 +/* __remove_default()
19397 + * remove a default
19399 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19401 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19402 + spin_lock(hash_lock);
19405 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19406 + else /* remove == reset */
19407 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19409 + spin_unlock(hash_lock);
19414 +/* __find_mapping()
19415 + * find a mapping in the hash table
19417 + * caller must hold hash_lock
19419 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19420 + struct vs_mapping **local, struct vs_mapping **global)
19422 + struct hlist_head *hash = dmap_main_hash;
19423 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19424 + struct hlist_node *pos;
19425 + struct vs_mapping *vdm;
19431 + hlist_for_each(pos, head) {
19432 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19434 + if ((vdm->device == device) &&
19435 + !((vdm->target.flags ^ mode) & S_IFMT)) {
19436 + if (vdm->xid == xid) {
19439 + } else if (global && vdm->xid == 0)
19444 + if (global && *global)
19451 +/* __lookup_mapping()
19452 + * find a mapping and store the result in target and flags
19454 +static inline int __lookup_mapping(struct vx_info *vxi,
19455 + dev_t device, dev_t *target, int *flags, umode_t mode)
19457 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19458 + struct vs_mapping *vdm, *global;
19459 + struct vx_dmap_target *vdmt;
19461 + xid_t xid = vxi->vx_id;
19464 + spin_lock(hash_lock);
19465 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19467 + vdmt = &vdm->target;
19471 + index = __mode_to_default(mode);
19472 + if (vxi && vxi->dmap.targets[index].flags) {
19474 + vdmt = &vxi->dmap.targets[index];
19475 + } else if (global) {
19477 + vdmt = &global->target;
19481 + vdmt = &dmap_defaults[index];
19485 + if (target && (vdmt->flags & DATTR_REMAP))
19486 + *target = vdmt->target;
19488 + *target = device;
19490 + *flags = vdmt->flags;
19492 + spin_unlock(hash_lock);
19498 +/* __remove_mapping()
19499 + * remove a mapping from the hash table
19501 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19504 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19505 + struct vs_mapping *vdm = NULL;
19508 + spin_lock(hash_lock);
19510 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19512 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19513 + vxi, vxi ? vxi->vx_id : 0, device, mode);
19516 + hlist_del(&vdm->dm_hlist);
19519 + spin_unlock(hash_lock);
19521 + kmem_cache_free(dmap_cachep, vdm);
19527 +int vs_map_device(struct vx_info *vxi,
19528 + dev_t device, dev_t *target, umode_t mode)
19530 + int ret, flags = DATTR_MASK;
19534 + *target = device;
19537 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
19538 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19539 + device, target ? *target : 0, flags, mode, ret);
19541 + return (flags & DATTR_MASK);
19546 +static int do_set_mapping(struct vx_info *vxi,
19547 + dev_t device, dev_t target, int flags, umode_t mode)
19550 + struct vs_mapping *new;
19552 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19556 + INIT_HLIST_NODE(&new->dm_hlist);
19557 + new->device = device;
19558 + new->target.target = target;
19559 + new->target.flags = flags | mode;
19560 + new->xid = (vxi ? vxi->vx_id : 0);
19562 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19563 + __hash_mapping(vxi, new);
19565 + struct vx_dmap_target new = {
19566 + .target = target,
19567 + .flags = flags | mode,
19569 + __set_default(vxi, mode, &new);
19575 +static int do_unset_mapping(struct vx_info *vxi,
19576 + dev_t device, dev_t target, int flags, umode_t mode)
19578 + int ret = -EINVAL;
19581 + ret = __remove_mapping(vxi, device, mode);
19585 + ret = __remove_default(vxi, mode);
19595 +static inline int __user_device(const char __user *name, dev_t *dev,
19598 + struct nameidata nd;
19605 + ret = user_lpath(name, &nd.path);
19608 + if (nd.path.dentry->d_inode) {
19609 + *dev = nd.path.dentry->d_inode->i_rdev;
19610 + *mode = nd.path.dentry->d_inode->i_mode;
19612 + path_put(&nd.path);
19616 +static inline int __mapping_mode(dev_t device, dev_t target,
19617 + umode_t device_mode, umode_t target_mode, umode_t *mode)
19620 + *mode = device_mode & S_IFMT;
19622 + *mode = target_mode & S_IFMT;
19626 + /* if both given, device and target mode have to match */
19627 + if (device && target &&
19628 + ((device_mode ^ target_mode) & S_IFMT))
19634 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19635 + const char __user *target_path, int flags, int set)
19637 + dev_t device = ~0, target = ~0;
19638 + umode_t device_mode = 0, target_mode = 0, mode;
19641 + ret = __user_device(device_path, &device, &device_mode);
19644 + ret = __user_device(target_path, &target, &target_mode);
19648 + ret = __mapping_mode(device, target,
19649 + device_mode, target_mode, &mode);
19654 + return do_set_mapping(vxi, device, target,
19657 + return do_unset_mapping(vxi, device, target,
19662 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19664 + struct vcmd_set_mapping_v0 vc_data;
19666 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19669 + return do_mapping(vxi, vc_data.device, vc_data.target,
19670 + vc_data.flags, 1);
19673 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19675 + struct vcmd_set_mapping_v0 vc_data;
19677 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19680 + return do_mapping(vxi, vc_data.device, vc_data.target,
19681 + vc_data.flags, 0);
19685 +#ifdef CONFIG_COMPAT
19687 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19689 + struct vcmd_set_mapping_v0_x32 vc_data;
19691 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19694 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19695 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19698 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19700 + struct vcmd_set_mapping_v0_x32 vc_data;
19702 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19705 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19706 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19709 +#endif /* CONFIG_COMPAT */
19712 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/dlimit.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/dlimit.c
19713 --- linux-2.6.32.24/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19714 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/dlimit.c 2009-12-03 20:04:56.000000000 +0100
19717 + * linux/kernel/vserver/dlimit.c
19719 + * Virtual Server: Context Disk Limits
19721 + * Copyright (C) 2004-2009 Herbert Pötzl
19723 + * V0.01 initial version
19724 + * V0.02 compat32 splitup
19725 + * V0.03 extended interface
19729 +#include <linux/statfs.h>
19730 +#include <linux/sched.h>
19731 +#include <linux/namei.h>
19732 +#include <linux/vs_tag.h>
19733 +#include <linux/vs_dlimit.h>
19734 +#include <linux/vserver/dlimit_cmd.h>
19736 +#include <asm/uaccess.h>
19738 +/* __alloc_dl_info()
19740 + * allocate an initialized dl_info struct
19741 + * doesn't make it visible (hash) */
19743 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19745 + struct dl_info *new = NULL;
19747 + vxdprintk(VXD_CBIT(dlim, 5),
19748 + "alloc_dl_info(%p,%d)*", sb, tag);
19750 + /* would this benefit from a slab cache? */
19751 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19755 + memset(new, 0, sizeof(struct dl_info));
19756 + new->dl_tag = tag;
19758 + INIT_RCU_HEAD(&new->dl_rcu);
19759 + INIT_HLIST_NODE(&new->dl_hlist);
19760 + spin_lock_init(&new->dl_lock);
19761 + atomic_set(&new->dl_refcnt, 0);
19762 + atomic_set(&new->dl_usecnt, 0);
19764 + /* rest of init goes here */
19766 + vxdprintk(VXD_CBIT(dlim, 4),
19767 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19771 +/* __dealloc_dl_info()
19773 + * final disposal of dl_info */
19775 +static void __dealloc_dl_info(struct dl_info *dli)
19777 + vxdprintk(VXD_CBIT(dlim, 4),
19778 + "dealloc_dl_info(%p)", dli);
19780 + dli->dl_hlist.next = LIST_POISON1;
19781 + dli->dl_tag = -1;
19784 + BUG_ON(atomic_read(&dli->dl_usecnt));
19785 + BUG_ON(atomic_read(&dli->dl_refcnt));
19791 +/* hash table for dl_info hash */
19793 +#define DL_HASH_SIZE 13
19795 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19797 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19800 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19802 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19807 +/* __hash_dl_info()
19809 + * add the dli to the global hash table
19810 + * requires the hash_lock to be held */
19812 +static inline void __hash_dl_info(struct dl_info *dli)
19814 + struct hlist_head *head;
19816 + vxdprintk(VXD_CBIT(dlim, 6),
19817 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19818 + get_dl_info(dli);
19819 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19820 + hlist_add_head_rcu(&dli->dl_hlist, head);
19823 +/* __unhash_dl_info()
19825 + * remove the dli from the global hash table
19826 + * requires the hash_lock to be held */
19828 +static inline void __unhash_dl_info(struct dl_info *dli)
19830 + vxdprintk(VXD_CBIT(dlim, 6),
19831 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19832 + hlist_del_rcu(&dli->dl_hlist);
19833 + put_dl_info(dli);
19837 +/* __lookup_dl_info()
19839 + * requires the rcu_read_lock()
19840 + * doesn't increment the dl_refcnt */
19842 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19844 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19845 + struct hlist_node *pos;
19846 + struct dl_info *dli;
19848 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19850 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19858 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19860 + struct dl_info *dli;
19863 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19864 + vxdprintk(VXD_CBIT(dlim, 7),
19865 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19866 + rcu_read_unlock();
19870 +void rcu_free_dl_info(struct rcu_head *head)
19872 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19873 + int usecnt, refcnt;
19875 + BUG_ON(!dli || !head);
19877 + usecnt = atomic_read(&dli->dl_usecnt);
19878 + BUG_ON(usecnt < 0);
19880 + refcnt = atomic_read(&dli->dl_refcnt);
19881 + BUG_ON(refcnt < 0);
19883 + vxdprintk(VXD_CBIT(dlim, 3),
19884 + "rcu_free_dl_info(%p)", dli);
19886 + __dealloc_dl_info(dli);
19888 + printk("!!! rcu didn't free\n");
19894 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19895 + uint32_t flags, int add)
19897 + struct path path;
19900 + ret = user_lpath(name, &path);
19902 + struct super_block *sb;
19903 + struct dl_info *dli;
19906 + if (!path.dentry->d_inode)
19907 + goto out_release;
19908 + if (!(sb = path.dentry->d_inode->i_sb))
19909 + goto out_release;
19912 + dli = __alloc_dl_info(sb, id);
19913 + spin_lock(&dl_info_hash_lock);
19916 + if (__lookup_dl_info(sb, id))
19918 + __hash_dl_info(dli);
19921 + spin_lock(&dl_info_hash_lock);
19922 + dli = __lookup_dl_info(sb, id);
19927 + __unhash_dl_info(dli);
19931 + spin_unlock(&dl_info_hash_lock);
19933 + __dealloc_dl_info(dli);
19940 +int vc_add_dlimit(uint32_t id, void __user *data)
19942 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19944 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19947 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19950 +int vc_rem_dlimit(uint32_t id, void __user *data)
19952 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19954 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19957 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19960 +#ifdef CONFIG_COMPAT
19962 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19964 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19966 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19969 + return do_addrem_dlimit(id,
19970 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19973 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19975 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19977 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19980 + return do_addrem_dlimit(id,
19981 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19984 +#endif /* CONFIG_COMPAT */
19988 +int do_set_dlimit(uint32_t id, const char __user *name,
19989 + uint32_t space_used, uint32_t space_total,
19990 + uint32_t inodes_used, uint32_t inodes_total,
19991 + uint32_t reserved, uint32_t flags)
19993 + struct path path;
19996 + ret = user_lpath(name, &path);
19998 + struct super_block *sb;
19999 + struct dl_info *dli;
20002 + if (!path.dentry->d_inode)
20003 + goto out_release;
20004 + if (!(sb = path.dentry->d_inode->i_sb))
20005 + goto out_release;
20007 + /* sanity checks */
20008 + if ((reserved != CDLIM_KEEP &&
20009 + reserved > 100) ||
20010 + (inodes_used != CDLIM_KEEP &&
20011 + inodes_used > inodes_total) ||
20012 + (space_used != CDLIM_KEEP &&
20013 + space_used > space_total))
20014 + goto out_release;
20017 + dli = locate_dl_info(sb, id);
20019 + goto out_release;
20021 + spin_lock(&dli->dl_lock);
20023 + if (inodes_used != CDLIM_KEEP)
20024 + dli->dl_inodes_used = inodes_used;
20025 + if (inodes_total != CDLIM_KEEP)
20026 + dli->dl_inodes_total = inodes_total;
20027 + if (space_used != CDLIM_KEEP)
20028 + dli->dl_space_used = dlimit_space_32to64(
20029 + space_used, flags, DLIMS_USED);
20031 + if (space_total == CDLIM_INFINITY)
20032 + dli->dl_space_total = DLIM_INFINITY;
20033 + else if (space_total != CDLIM_KEEP)
20034 + dli->dl_space_total = dlimit_space_32to64(
20035 + space_total, flags, DLIMS_TOTAL);
20037 + if (reserved != CDLIM_KEEP)
20038 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20040 + spin_unlock(&dli->dl_lock);
20042 + put_dl_info(dli);
20051 +int vc_set_dlimit(uint32_t id, void __user *data)
20053 + struct vcmd_ctx_dlimit_v0 vc_data;
20055 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20058 + return do_set_dlimit(id, vc_data.name,
20059 + vc_data.space_used, vc_data.space_total,
20060 + vc_data.inodes_used, vc_data.inodes_total,
20061 + vc_data.reserved, vc_data.flags);
20064 +#ifdef CONFIG_COMPAT
20066 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20068 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20070 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20073 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20074 + vc_data.space_used, vc_data.space_total,
20075 + vc_data.inodes_used, vc_data.inodes_total,
20076 + vc_data.reserved, vc_data.flags);
20079 +#endif /* CONFIG_COMPAT */
20083 +int do_get_dlimit(uint32_t id, const char __user *name,
20084 + uint32_t *space_used, uint32_t *space_total,
20085 + uint32_t *inodes_used, uint32_t *inodes_total,
20086 + uint32_t *reserved, uint32_t *flags)
20088 + struct path path;
20091 + ret = user_lpath(name, &path);
20093 + struct super_block *sb;
20094 + struct dl_info *dli;
20097 + if (!path.dentry->d_inode)
20098 + goto out_release;
20099 + if (!(sb = path.dentry->d_inode->i_sb))
20100 + goto out_release;
20103 + dli = locate_dl_info(sb, id);
20105 + goto out_release;
20107 + spin_lock(&dli->dl_lock);
20108 + *inodes_used = dli->dl_inodes_used;
20109 + *inodes_total = dli->dl_inodes_total;
20111 + *space_used = dlimit_space_64to32(
20112 + dli->dl_space_used, flags, DLIMS_USED);
20114 + if (dli->dl_space_total == DLIM_INFINITY)
20115 + *space_total = CDLIM_INFINITY;
20117 + *space_total = dlimit_space_64to32(
20118 + dli->dl_space_total, flags, DLIMS_TOTAL);
20120 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20121 + spin_unlock(&dli->dl_lock);
20123 + put_dl_info(dli);
20134 +int vc_get_dlimit(uint32_t id, void __user *data)
20136 + struct vcmd_ctx_dlimit_v0 vc_data;
20139 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20142 + ret = do_get_dlimit(id, vc_data.name,
20143 + &vc_data.space_used, &vc_data.space_total,
20144 + &vc_data.inodes_used, &vc_data.inodes_total,
20145 + &vc_data.reserved, &vc_data.flags);
20149 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20154 +#ifdef CONFIG_COMPAT
20156 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20158 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20161 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20164 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20165 + &vc_data.space_used, &vc_data.space_total,
20166 + &vc_data.inodes_used, &vc_data.inodes_total,
20167 + &vc_data.reserved, &vc_data.flags);
20171 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20176 +#endif /* CONFIG_COMPAT */
20179 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20181 + struct dl_info *dli;
20182 + __u64 blimit, bfree, bavail;
20185 + dli = locate_dl_info(sb, dx_current_tag());
20189 + spin_lock(&dli->dl_lock);
20190 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20193 + /* reduce max inodes available to limit */
20194 + if (buf->f_files > dli->dl_inodes_total)
20195 + buf->f_files = dli->dl_inodes_total;
20197 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20198 + /* reduce free inodes to min */
20199 + if (ifree < buf->f_ffree)
20200 + buf->f_ffree = ifree;
20203 + if (dli->dl_space_total == DLIM_INFINITY)
20206 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20208 + if (dli->dl_space_total < dli->dl_space_used)
20211 + bfree = (dli->dl_space_total - dli->dl_space_used)
20212 + >> sb->s_blocksize_bits;
20214 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20215 + if (bavail < dli->dl_space_used)
20218 + bavail = (bavail - dli->dl_space_used)
20219 + >> sb->s_blocksize_bits;
20221 + /* reduce max space available to limit */
20222 + if (buf->f_blocks > blimit)
20223 + buf->f_blocks = blimit;
20225 + /* reduce free space to min */
20226 + if (bfree < buf->f_bfree)
20227 + buf->f_bfree = bfree;
20229 + /* reduce avail space to min */
20230 + if (bavail < buf->f_bavail)
20231 + buf->f_bavail = bavail;
20234 + spin_unlock(&dli->dl_lock);
20235 + put_dl_info(dli);
20240 +#include <linux/module.h>
20242 +EXPORT_SYMBOL_GPL(locate_dl_info);
20243 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20245 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/helper.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/helper.c
20246 --- linux-2.6.32.24/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
20247 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/helper.c 2009-12-03 22:20:22.000000000 +0100
20250 + * linux/kernel/vserver/helper.c
20252 + * Virtual Context Support
20254 + * Copyright (C) 2004-2007 Herbert Pötzl
20256 + * V0.01 basic helper
20260 +#include <linux/kmod.h>
20261 +#include <linux/reboot.h>
20262 +#include <linux/vs_context.h>
20263 +#include <linux/vs_network.h>
20264 +#include <linux/vserver/signal.h>
20267 +char vshelper_path[255] = "/sbin/vshelper";
20270 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20274 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20275 + printk( KERN_WARNING
20276 + "%s: (%s %s) returned %s with %d\n",
20277 + name, argv[1], argv[2],
20278 + sync ? "sync" : "async", ret);
20280 + vxdprintk(VXD_CBIT(switch, 4),
20281 + "%s: (%s %s) returned %s with %d",
20282 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
20287 + * vshelper path is set via /proc/sys
20288 + * invoked by vserver sys_reboot(), with
20289 + * the following arguments
20291 + * argv [0] = vshelper_path;
20292 + * argv [1] = action: "restart", "halt", "poweroff", ...
20293 + * argv [2] = context identifier
20295 + * envp [*] = type-specific parameters
20298 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20300 + char id_buf[8], cmd_buf[16];
20301 + char uid_buf[16], pid_buf[16];
20304 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20305 + char *envp[] = {"HOME=/", "TERM=linux",
20306 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20307 + uid_buf, pid_buf, cmd_buf, 0};
20309 + if (vx_info_state(vxi, VXS_HELPER))
20311 + vxi->vx_state |= VXS_HELPER;
20313 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20315 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20316 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20317 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20320 + case LINUX_REBOOT_CMD_RESTART:
20321 + argv[1] = "restart";
20324 + case LINUX_REBOOT_CMD_HALT:
20325 + argv[1] = "halt";
20328 + case LINUX_REBOOT_CMD_POWER_OFF:
20329 + argv[1] = "poweroff";
20332 + case LINUX_REBOOT_CMD_SW_SUSPEND:
20333 + argv[1] = "swsusp";
20336 + case LINUX_REBOOT_CMD_OOM:
20341 + vxi->vx_state &= ~VXS_HELPER;
20345 + ret = do_vshelper(vshelper_path, argv, envp, 0);
20346 + vxi->vx_state &= ~VXS_HELPER;
20347 + __wakeup_vx_info(vxi);
20348 + return (ret) ? -EPERM : 0;
20352 +long vs_reboot(unsigned int cmd, void __user *arg)
20354 + struct vx_info *vxi = current_vx_info();
20357 + vxdprintk(VXD_CBIT(misc, 5),
20358 + "vs_reboot(%p[#%d],%u)",
20359 + vxi, vxi ? vxi->vx_id : 0, cmd);
20361 + ret = vs_reboot_helper(vxi, cmd, arg);
20365 + vxi->reboot_cmd = cmd;
20366 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20368 + case LINUX_REBOOT_CMD_RESTART:
20369 + case LINUX_REBOOT_CMD_HALT:
20370 + case LINUX_REBOOT_CMD_POWER_OFF:
20371 + vx_info_kill(vxi, 0, SIGKILL);
20372 + vx_info_kill(vxi, 1, SIGKILL);
20380 +long vs_oom_action(unsigned int cmd)
20382 + struct vx_info *vxi = current_vx_info();
20385 + vxdprintk(VXD_CBIT(misc, 5),
20386 + "vs_oom_action(%p[#%d],%u)",
20387 + vxi, vxi ? vxi->vx_id : 0, cmd);
20389 + ret = vs_reboot_helper(vxi, cmd, NULL);
20393 + vxi->reboot_cmd = cmd;
20394 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20395 + vx_info_kill(vxi, 0, SIGKILL);
20396 + vx_info_kill(vxi, 1, SIGKILL);
20402 + * argv [0] = vshelper_path;
20403 + * argv [1] = action: "startup", "shutdown"
20404 + * argv [2] = context identifier
20406 + * envp [*] = type-specific parameters
20409 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20411 + char id_buf[8], cmd_buf[16];
20412 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20413 + char *envp[] = {"HOME=/", "TERM=linux",
20414 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20416 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20419 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20420 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20423 + case VSC_STARTUP:
20424 + argv[1] = "startup";
20426 + case VSC_SHUTDOWN:
20427 + argv[1] = "shutdown";
20433 + return do_vshelper(vshelper_path, argv, envp, 1);
20438 + * argv [0] = vshelper_path;
20439 + * argv [1] = action: "netup", "netdown"
20440 + * argv [2] = context identifier
20442 + * envp [*] = type-specific parameters
20445 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20447 + char id_buf[8], cmd_buf[16];
20448 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20449 + char *envp[] = {"HOME=/", "TERM=linux",
20450 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20452 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20455 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20456 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20460 + argv[1] = "netup";
20462 + case VSC_NETDOWN:
20463 + argv[1] = "netdown";
20469 + return do_vshelper(vshelper_path, argv, envp, 1);
20472 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/history.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/history.c
20473 --- linux-2.6.32.24/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
20474 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/history.c 2009-12-03 20:04:56.000000000 +0100
20477 + * kernel/vserver/history.c
20479 + * Virtual Context History Backtrace
20481 + * Copyright (C) 2004-2007 Herbert Pötzl
20483 + * V0.01 basic structure
20484 + * V0.02 hash/unhash and trace
20485 + * V0.03 preemption fixes
20489 +#include <linux/module.h>
20490 +#include <asm/uaccess.h>
20492 +#include <linux/vserver/context.h>
20493 +#include <linux/vserver/debug.h>
20494 +#include <linux/vserver/debug_cmd.h>
20495 +#include <linux/vserver/history.h>
20498 +#ifdef CONFIG_VSERVER_HISTORY
20499 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20501 +#define VXH_SIZE 64
20504 +struct _vx_history {
20505 + unsigned int counter;
20507 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20511 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20513 +unsigned volatile int vxh_active = 1;
20515 +static atomic_t sequence = ATOMIC_INIT(0);
20520 + * requires disabled preemption */
20522 +struct _vx_hist_entry *vxh_advance(void *loc)
20524 + unsigned int cpu = smp_processor_id();
20525 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20526 + struct _vx_hist_entry *entry;
20527 + unsigned int index;
20529 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20530 + entry = &hist->entry[index];
20532 + entry->seq = atomic_inc_return(&sequence);
20533 + entry->loc = loc;
20537 +EXPORT_SYMBOL_GPL(vxh_advance);
20540 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20542 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20545 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20547 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20548 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20549 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20550 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20552 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20554 + switch (e->type) {
20555 + case VXH_THROW_OOPS:
20556 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20559 + case VXH_GET_VX_INFO:
20560 + case VXH_PUT_VX_INFO:
20561 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20563 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20564 + VXH_VXI_ARGS(e));
20567 + case VXH_INIT_VX_INFO:
20568 + case VXH_SET_VX_INFO:
20569 + case VXH_CLR_VX_INFO:
20570 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20572 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20573 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20574 + VXH_VXI_ARGS(e), e->sc.data);
20577 + case VXH_CLAIM_VX_INFO:
20578 + case VXH_RELEASE_VX_INFO:
20579 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20581 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20582 + VXH_VXI_ARGS(e), e->sc.data);
20585 + case VXH_ALLOC_VX_INFO:
20586 + case VXH_DEALLOC_VX_INFO:
20587 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20589 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20590 + VXH_VXI_ARGS(e));
20593 + case VXH_HASH_VX_INFO:
20594 + case VXH_UNHASH_VX_INFO:
20595 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20597 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20598 + VXH_VXI_ARGS(e));
20601 + case VXH_LOC_VX_INFO:
20602 + case VXH_LOOKUP_VX_INFO:
20603 + case VXH_CREATE_VX_INFO:
20604 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20606 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20607 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20608 + e->ll.arg, VXH_VXI_ARGS(e));
20613 +static void __vxh_dump_history(void)
20615 + unsigned int i, cpu;
20617 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20618 + atomic_read(&sequence), NR_CPUS);
20620 + for (i = 0; i < VXH_SIZE; i++) {
20621 + for_each_online_cpu(cpu) {
20622 + struct _vx_history *hist =
20623 + &per_cpu(vx_history_buffer, cpu);
20624 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20625 + struct _vx_hist_entry *entry = &hist->entry[index];
20627 + vxh_dump_entry(entry, cpu);
20632 +void vxh_dump_history(void)
20636 + local_irq_enable();
20638 + local_irq_disable();
20640 + __vxh_dump_history();
20644 +/* vserver syscall commands below here */
20647 +int vc_dump_history(uint32_t id)
20650 + __vxh_dump_history();
20657 +int do_read_history(struct __user _vx_hist_entry *data,
20658 + int cpu, uint32_t *index, uint32_t *count)
20660 + int pos, ret = 0;
20661 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20662 + int end = hist->counter;
20663 + int start = end - VXH_SIZE + 2;
20664 + int idx = *index;
20666 + /* special case: get current pos */
20672 + /* have we lost some data? */
20676 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20677 + struct _vx_hist_entry *entry =
20678 + &hist->entry[idx % VXH_SIZE];
20680 + /* send entry to userspace */
20681 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20685 + /* save new index and count */
20688 + return ret ? ret : (*index < end);
20691 +int vc_read_history(uint32_t id, void __user *data)
20693 + struct vcmd_read_history_v0 vc_data;
20696 + if (id >= NR_CPUS)
20699 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20702 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20703 + id, &vc_data.index, &vc_data.count);
20705 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20710 +#ifdef CONFIG_COMPAT
20712 +int vc_read_history_x32(uint32_t id, void __user *data)
20714 + struct vcmd_read_history_v0_x32 vc_data;
20717 + if (id >= NR_CPUS)
20720 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20723 + ret = do_read_history((struct __user _vx_hist_entry *)
20724 + compat_ptr(vc_data.data_ptr),
20725 + id, &vc_data.index, &vc_data.count);
20727 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20732 +#endif /* CONFIG_COMPAT */
20734 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/inet.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/inet.c
20735 --- linux-2.6.32.24/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20736 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/inet.c 2009-12-03 20:04:56.000000000 +0100
20739 +#include <linux/in.h>
20740 +#include <linux/inetdevice.h>
20741 +#include <linux/vs_inet.h>
20742 +#include <linux/vs_inet6.h>
20743 +#include <linux/vserver/debug.h>
20744 +#include <net/route.h>
20745 +#include <net/addrconf.h>
20748 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20752 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20755 + struct nx_addr_v4 *ptr;
20757 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20758 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20765 + vxdprintk(VXD_CBIT(net, 2),
20766 + "nx_v4_addr_conflict(%p,%p): %d",
20767 + nxi1, nxi2, ret);
20773 +#ifdef CONFIG_IPV6
20775 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20779 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20782 + struct nx_addr_v6 *ptr;
20784 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20785 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20792 + vxdprintk(VXD_CBIT(net, 2),
20793 + "nx_v6_addr_conflict(%p,%p): %d",
20794 + nxi1, nxi2, ret);
20801 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20803 + struct in_device *in_dev;
20804 + struct in_ifaddr **ifap;
20805 + struct in_ifaddr *ifa;
20810 + in_dev = in_dev_get(dev);
20814 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20815 + ifap = &ifa->ifa_next) {
20816 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20821 + in_dev_put(in_dev);
20827 +#ifdef CONFIG_IPV6
20829 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20831 + struct inet6_dev *in_dev;
20832 + struct inet6_ifaddr **ifap;
20833 + struct inet6_ifaddr *ifa;
20838 + in_dev = in6_dev_get(dev);
20842 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20843 + ifap = &ifa->if_next) {
20844 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20849 + in6_dev_put(in_dev);
20856 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20862 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20864 +#ifdef CONFIG_IPV6
20866 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20871 + vxdprintk(VXD_CBIT(net, 3),
20872 + "dev_in_nx_info(%p,%p[#%d]) = %d",
20873 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
20877 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20878 + struct rtable **rp, struct flowi *fl)
20883 + /* FIXME: handle lback only case */
20884 + if (!NX_IPV4(nxi))
20887 + vxdprintk(VXD_CBIT(net, 4),
20888 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20889 + nxi, nxi ? nxi->nx_id : 0,
20890 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20892 + /* single IP is unconditional */
20893 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20894 + (fl->fl4_src == INADDR_ANY))
20895 + fl->fl4_src = nxi->v4.ip[0].s_addr;
20897 + if (fl->fl4_src == INADDR_ANY) {
20898 + struct nx_addr_v4 *ptr;
20899 + __be32 found = 0;
20902 + err = __ip_route_output_key(net, rp, fl);
20904 + found = (*rp)->rt_src;
20906 + vxdprintk(VXD_CBIT(net, 4),
20907 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20908 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20909 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20913 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20914 + __be32 primary = ptr->ip[0].s_addr;
20915 + __be32 mask = ptr->mask.s_addr;
20916 + __be32 neta = primary & mask;
20918 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20919 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20920 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20921 + NIPQUAD(mask), NIPQUAD(neta));
20922 + if ((found & mask) != neta)
20925 + fl->fl4_src = primary;
20926 + err = __ip_route_output_key(net, rp, fl);
20927 + vxdprintk(VXD_CBIT(net, 4),
20928 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20929 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20931 + found = (*rp)->rt_src;
20933 + if (found == primary)
20937 + /* still no source ip? */
20938 + found = ipv4_is_loopback(fl->fl4_dst)
20939 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20941 + /* assign src ip to flow */
20942 + fl->fl4_src = found;
20945 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20949 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20950 + if (ipv4_is_loopback(fl->fl4_dst))
20951 + fl->fl4_dst = nxi->v4_lback.s_addr;
20952 + if (ipv4_is_loopback(fl->fl4_src))
20953 + fl->fl4_src = nxi->v4_lback.s_addr;
20954 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
20955 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20961 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20963 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/init.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/init.c
20964 --- linux-2.6.32.24/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
20965 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/init.c 2009-12-03 20:04:56.000000000 +0100
20968 + * linux/kernel/init.c
20970 + * Virtual Server Init
20972 + * Copyright (C) 2004-2007 Herbert Pötzl
20974 + * V0.01 basic structure
20978 +#include <linux/init.h>
20980 +int vserver_register_sysctl(void);
20981 +void vserver_unregister_sysctl(void);
20984 +static int __init init_vserver(void)
20988 +#ifdef CONFIG_VSERVER_DEBUG
20989 + vserver_register_sysctl();
20995 +static void __exit exit_vserver(void)
20998 +#ifdef CONFIG_VSERVER_DEBUG
20999 + vserver_unregister_sysctl();
21004 +/* FIXME: GFP_ZONETYPES gone
21005 +long vx_slab[GFP_ZONETYPES]; */
21009 +module_init(init_vserver);
21010 +module_exit(exit_vserver);
21012 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/inode.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/inode.c
21013 --- linux-2.6.32.24/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
21014 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/inode.c 2009-12-03 20:04:56.000000000 +0100
21017 + * linux/kernel/vserver/inode.c
21019 + * Virtual Server: File System Support
21021 + * Copyright (C) 2004-2007 Herbert Pötzl
21023 + * V0.01 separated from vcontext V0.05
21024 + * V0.02 moved to tag (instead of xid)
21028 +#include <linux/tty.h>
21029 +#include <linux/proc_fs.h>
21030 +#include <linux/devpts_fs.h>
21031 +#include <linux/fs.h>
21032 +#include <linux/file.h>
21033 +#include <linux/mount.h>
21034 +#include <linux/parser.h>
21035 +#include <linux/namei.h>
21036 +#include <linux/vserver/inode.h>
21037 +#include <linux/vserver/inode_cmd.h>
21038 +#include <linux/vs_base.h>
21039 +#include <linux/vs_tag.h>
21041 +#include <asm/uaccess.h>
21044 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21046 + struct proc_dir_entry *entry;
21048 + if (!in || !in->i_sb)
21051 + *flags = IATTR_TAG
21052 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21053 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21054 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21055 + | (IS_COW(in) ? IATTR_COW : 0);
21056 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21058 + if (S_ISDIR(in->i_mode))
21059 + *mask |= IATTR_BARRIER;
21061 + if (IS_TAGGED(in)) {
21062 + *tag = in->i_tag;
21063 + *mask |= IATTR_TAG;
21066 + switch (in->i_sb->s_magic) {
21067 + case PROC_SUPER_MAGIC:
21068 + entry = PROC_I(in)->pde;
21070 + /* check for specific inodes? */
21072 + *mask |= IATTR_FLAGS;
21074 + *flags |= (entry->vx_flags & IATTR_FLAGS);
21076 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21079 + case DEVPTS_SUPER_MAGIC:
21080 + *tag = in->i_tag;
21081 + *mask |= IATTR_TAG;
21090 +int vc_get_iattr(void __user *data)
21092 + struct path path;
21093 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21096 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21099 + ret = user_lpath(vc_data.name, &path);
21101 + ret = __vc_get_iattr(path.dentry->d_inode,
21102 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21108 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21113 +#ifdef CONFIG_COMPAT
21115 +int vc_get_iattr_x32(void __user *data)
21117 + struct path path;
21118 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21121 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21124 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21126 + ret = __vc_get_iattr(path.dentry->d_inode,
21127 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21133 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21138 +#endif /* CONFIG_COMPAT */
21141 +int vc_fget_iattr(uint32_t fd, void __user *data)
21143 + struct file *filp;
21144 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21147 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21151 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21154 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
21155 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21159 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21165 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21167 + struct inode *in = de->d_inode;
21168 + int error = 0, is_proc = 0, has_tag = 0;
21169 + struct iattr attr = { 0 };
21171 + if (!in || !in->i_sb)
21174 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21175 + if ((*mask & IATTR_FLAGS) && !is_proc)
21178 + has_tag = IS_TAGGED(in) ||
21179 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21180 + if ((*mask & IATTR_TAG) && !has_tag)
21183 + mutex_lock(&in->i_mutex);
21184 + if (*mask & IATTR_TAG) {
21185 + attr.ia_tag = *tag;
21186 + attr.ia_valid |= ATTR_TAG;
21189 + if (*mask & IATTR_FLAGS) {
21190 + struct proc_dir_entry *entry = PROC_I(in)->pde;
21191 + unsigned int iflags = PROC_I(in)->vx_flags;
21193 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
21194 + | (*flags & IATTR_FLAGS);
21195 + PROC_I(in)->vx_flags = iflags;
21197 + entry->vx_flags = iflags;
21200 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21201 + IATTR_BARRIER | IATTR_COW)) {
21202 + int iflags = in->i_flags;
21203 + int vflags = in->i_vflags;
21205 + if (*mask & IATTR_IMMUTABLE) {
21206 + if (*flags & IATTR_IMMUTABLE)
21207 + iflags |= S_IMMUTABLE;
21209 + iflags &= ~S_IMMUTABLE;
21211 + if (*mask & IATTR_IXUNLINK) {
21212 + if (*flags & IATTR_IXUNLINK)
21213 + iflags |= S_IXUNLINK;
21215 + iflags &= ~S_IXUNLINK;
21217 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21218 + if (*flags & IATTR_BARRIER)
21219 + vflags |= V_BARRIER;
21221 + vflags &= ~V_BARRIER;
21223 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21224 + if (*flags & IATTR_COW)
21227 + vflags &= ~V_COW;
21229 + if (in->i_op && in->i_op->sync_flags) {
21230 + error = in->i_op->sync_flags(in, iflags, vflags);
21236 + if (attr.ia_valid) {
21237 + if (in->i_op && in->i_op->setattr)
21238 + error = in->i_op->setattr(de, &attr);
21240 + error = inode_change_ok(in, &attr);
21242 + error = inode_setattr(in, &attr);
21247 + mutex_unlock(&in->i_mutex);
21251 +int vc_set_iattr(void __user *data)
21253 + struct path path;
21254 + struct vcmd_ctx_iattr_v1 vc_data;
21257 + if (!capable(CAP_LINUX_IMMUTABLE))
21259 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21262 + ret = user_lpath(vc_data.name, &path);
21264 + ret = __vc_set_iattr(path.dentry,
21265 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21269 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21274 +#ifdef CONFIG_COMPAT
21276 +int vc_set_iattr_x32(void __user *data)
21278 + struct path path;
21279 + struct vcmd_ctx_iattr_v1_x32 vc_data;
21282 + if (!capable(CAP_LINUX_IMMUTABLE))
21284 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21287 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21289 + ret = __vc_set_iattr(path.dentry,
21290 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21294 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21299 +#endif /* CONFIG_COMPAT */
21301 +int vc_fset_iattr(uint32_t fd, void __user *data)
21303 + struct file *filp;
21304 + struct vcmd_ctx_fiattr_v0 vc_data;
21307 + if (!capable(CAP_LINUX_IMMUTABLE))
21309 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21313 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21316 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21317 + &vc_data.flags, &vc_data.mask);
21321 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21327 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21329 +static match_table_t tokens = {
21330 + {Opt_notagcheck, "notagcheck"},
21331 +#ifdef CONFIG_PROPAGATE
21332 + {Opt_notag, "notag"},
21333 + {Opt_tag, "tag"},
21334 + {Opt_tagid, "tagid=%u"},
21340 +static void __dx_parse_remove(char *string, char *opt)
21342 + char *p = strstr(string, opt);
21346 + while (*q != '\0' && *q != ',')
21355 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21356 + unsigned long *flags)
21359 + substring_t args[MAX_OPT_ARGS];
21360 + int token, option = 0;
21361 + char *s, *p, *opts;
21365 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21370 + while ((p = strsep(&opts, ",")) != NULL) {
21371 + token = match_token(p, tokens, args);
21373 + vxdprintk(VXD_CBIT(tag, 7),
21374 + "dx_parse_tag(»%s«): %d:#%d",
21375 + p, token, option);
21378 +#ifdef CONFIG_PROPAGATE
21383 + __dx_parse_remove(s, "tag");
21384 + *mnt_flags |= MNT_TAGID;
21385 + set |= MNT_TAGID;
21389 + __dx_parse_remove(s, "notag");
21390 + *mnt_flags |= MNT_NOTAG;
21391 + set |= MNT_NOTAG;
21394 + if (tag && !match_int(args, &option))
21397 + __dx_parse_remove(s, "tagid");
21398 + *mnt_flags |= MNT_TAGID;
21399 + set |= MNT_TAGID;
21402 + case Opt_notagcheck:
21404 + __dx_parse_remove(s, "notagcheck");
21405 + *flags |= MS_NOTAGCHECK;
21406 + set |= MS_NOTAGCHECK;
21411 + strcpy(string, s);
21416 +#ifdef CONFIG_PROPAGATE
21418 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21420 + tag_t new_tag = 0;
21421 + struct vfsmount *mnt;
21426 + mnt = nd->path.mnt;
21430 + propagate = (mnt->mnt_flags & MNT_TAGID);
21432 + new_tag = mnt->mnt_tag;
21434 + vxdprintk(VXD_CBIT(tag, 7),
21435 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21436 + inode, inode->i_ino, inode->i_tag,
21437 + new_tag, (propagate) ? 1 : 0);
21440 + inode->i_tag = new_tag;
21443 +#include <linux/module.h>
21445 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21447 +#endif /* CONFIG_PROPAGATE */
21449 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/Kconfig
21450 --- linux-2.6.32.24/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
21451 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/Kconfig 2010-02-14 01:02:13.000000000 +0100
21454 +# Linux VServer configuration
21457 +menu "Linux VServer"
21459 +config VSERVER_AUTO_LBACK
21460 + bool "Automatically Assign Loopback IP"
21463 + Automatically assign a guest specific loopback
21464 + IP and add it to the kernel network stack on
21467 +config VSERVER_AUTO_SINGLE
21468 + bool "Automatic Single IP Special Casing"
21469 + depends on EXPERIMENTAL
21472 + This allows network contexts with a single IP to
21473 + automatically remap 0.0.0.0 bindings to that IP,
21474 + avoiding further network checks and improving
21477 + (note: such guests do not allow to change the ip
21478 + on the fly and do not show loopback addresses)
21480 +config VSERVER_COWBL
21481 + bool "Enable COW Immutable Link Breaking"
21484 + This enables the COW (Copy-On-Write) link break code.
21485 + It allows you to treat unified files like normal files
21486 + when writing to them (which will implicitely break the
21487 + link and create a copy of the unified file)
21489 +config VSERVER_VTIME
21490 + bool "Enable Virtualized Guest Time"
21491 + depends on EXPERIMENTAL
21494 + This enables per guest time offsets to allow for
21495 + adjusting the system clock individually per guest.
21496 + this adds some overhead to the time functions and
21497 + therefore should not be enabled without good reason.
21499 +config VSERVER_DEVICE
21500 + bool "Enable Guest Device Mapping"
21501 + depends on EXPERIMENTAL
21504 + This enables generic device remapping.
21506 +config VSERVER_PROC_SECURE
21507 + bool "Enable Proc Security"
21508 + depends on PROC_FS
21511 + This configures ProcFS security to initially hide
21512 + non-process entries for all contexts except the main and
21513 + spectator context (i.e. for all guests), which is a secure
21516 + (note: on 1.2x the entries were visible by default)
21518 +config VSERVER_HARDCPU
21519 + bool "Enable Hard CPU Limits"
21522 + Activate the Hard CPU Limits
21524 + This will compile in code that allows the Token Bucket
21525 + Scheduler to put processes on hold when a context's
21526 + tokens are depleted (provided that its per-context
21527 + sched_hard flag is set).
21529 + Processes belonging to that context will not be able
21530 + to consume CPU resources again until a per-context
21531 + configured minimum of tokens has been reached.
21533 +config VSERVER_IDLETIME
21534 + bool "Avoid idle CPUs by skipping Time"
21535 + depends on VSERVER_HARDCPU
21538 + This option allows the scheduler to artificially
21539 + advance time (per cpu) when otherwise the idle
21540 + task would be scheduled, thus keeping the cpu
21541 + busy and sharing the available resources among
21542 + certain contexts.
21544 +config VSERVER_IDLELIMIT
21545 + bool "Limit the IDLE task"
21546 + depends on VSERVER_HARDCPU
21549 + Limit the idle slices, so the the next context
21550 + will be scheduled as soon as possible.
21552 + This might improve interactivity and latency, but
21553 + will also marginally increase scheduling overhead.
21556 + prompt "Persistent Inode Tagging"
21557 + default TAGGING_ID24
21559 + This adds persistent context information to filesystems
21560 + mounted with the tagxid option. Tagging is a requirement
21561 + for per-context disk limits and per-context quota.
21564 +config TAGGING_NONE
21567 + do not store per-context information in inodes.
21569 +config TAGGING_UID16
21570 + bool "UID16/GID32"
21572 + reduces UID to 16 bit, but leaves GID at 32 bit.
21574 +config TAGGING_GID16
21575 + bool "UID32/GID16"
21577 + reduces GID to 16 bit, but leaves UID at 32 bit.
21579 +config TAGGING_ID24
21580 + bool "UID24/GID24"
21582 + uses the upper 8bit from UID and GID for XID tagging
21583 + which leaves 24bit for UID/GID each, which should be
21584 + more than sufficient for normal use.
21586 +config TAGGING_INTERN
21587 + bool "UID32/GID32"
21589 + this uses otherwise reserved inode fields in the on
21590 + disk representation, which limits the use to a few
21591 + filesystems (currently ext2 and ext3)
21596 + bool "Tag NFSD User Auth and Files"
21599 + Enable this if you do want the in-kernel NFS
21600 + Server to use the tagging specified above.
21601 + (will require patched clients too)
21603 +config VSERVER_PRIVACY
21604 + bool "Honor Privacy Aspects of Guests"
21607 + When enabled, most context checks will disallow
21608 + access to structures assigned to a specific context,
21609 + like ptys or loop devices.
21611 +config VSERVER_CONTEXTS
21612 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
21614 + default "768" if 64BIT
21617 + This setting will optimize certain data structures
21618 + and memory allocations according to the expected
21621 + note: this is not a strict upper limit.
21623 +config VSERVER_WARN
21624 + bool "VServer Warnings"
21627 + This enables various runtime warnings, which will
21628 + notify about potential manipulation attempts or
21629 + resource shortage. It is generally considered to
21630 + be a good idea to have that enabled.
21632 +config VSERVER_DEBUG
21633 + bool "VServer Debugging Code"
21636 + Set this to yes if you want to be able to activate
21637 + debugging output at runtime. It adds a very small
21638 + overhead to all vserver related functions and
21639 + increases the kernel size by about 20k.
21641 +config VSERVER_HISTORY
21642 + bool "VServer History Tracing"
21643 + depends on VSERVER_DEBUG
21646 + Set this to yes if you want to record the history of
21647 + linux-vserver activities, so they can be replayed in
21648 + the event of a kernel panic or oops.
21650 +config VSERVER_HISTORY_SIZE
21651 + int "Per-CPU History Size (32-65536)"
21652 + depends on VSERVER_HISTORY
21656 + This allows you to specify the number of entries in
21657 + the per-CPU history buffer.
21659 +config VSERVER_MONITOR
21660 + bool "VServer Scheduling Monitor"
21661 + depends on VSERVER_DISABLED
21664 + Set this to yes if you want to record the scheduling
21665 + decisions, so that they can be relayed to userspace
21666 + for detailed analysis.
21668 +config VSERVER_MONITOR_SIZE
21669 + int "Per-CPU Monitor Queue Size (32-65536)"
21670 + depends on VSERVER_MONITOR
21674 + This allows you to specify the number of entries in
21675 + the per-CPU scheduling monitor buffer.
21677 +config VSERVER_MONITOR_SYNC
21678 + int "Per-CPU Monitor Sync Interval (0-65536)"
21679 + depends on VSERVER_MONITOR
21683 + This allows you to specify the interval in ticks
21684 + when a time sync entry is inserted.
21692 + select NAMESPACES
21698 +config VSERVER_SECURITY
21700 + depends on SECURITY
21702 + select SECURITY_CAPABILITIES
21704 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/limit.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/limit.c
21705 --- linux-2.6.32.24/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21706 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/limit.c 2010-04-05 21:24:21.000000000 +0200
21709 + * linux/kernel/vserver/limit.c
21711 + * Virtual Server: Context Limits
21713 + * Copyright (C) 2004-2010 Herbert Pötzl
21715 + * V0.01 broken out from vcontext V0.05
21716 + * V0.02 changed vcmds to vxi arg
21717 + * V0.03 added memory cgroup support
21721 +#include <linux/sched.h>
21722 +#include <linux/module.h>
21723 +#include <linux/memcontrol.h>
21724 +#include <linux/res_counter.h>
21725 +#include <linux/vs_limit.h>
21726 +#include <linux/vserver/limit.h>
21727 +#include <linux/vserver/limit_cmd.h>
21729 +#include <asm/uaccess.h>
21732 +const char *vlimit_name[NUM_LIMITS] = {
21733 + [RLIMIT_CPU] = "CPU",
21734 + [RLIMIT_RSS] = "RSS",
21735 + [RLIMIT_NPROC] = "NPROC",
21736 + [RLIMIT_NOFILE] = "NOFILE",
21737 + [RLIMIT_MEMLOCK] = "VML",
21738 + [RLIMIT_AS] = "VM",
21739 + [RLIMIT_LOCKS] = "LOCKS",
21740 + [RLIMIT_SIGPENDING] = "SIGP",
21741 + [RLIMIT_MSGQUEUE] = "MSGQ",
21743 + [VLIMIT_NSOCK] = "NSOCK",
21744 + [VLIMIT_OPENFD] = "OPENFD",
21745 + [VLIMIT_ANON] = "ANON",
21746 + [VLIMIT_SHMEM] = "SHMEM",
21747 + [VLIMIT_DENTRY] = "DENTRY",
21750 +EXPORT_SYMBOL_GPL(vlimit_name);
21752 +#define MASK_ENTRY(x) (1 << (x))
21754 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21757 + , /* softlimit */
21758 + MASK_ENTRY( RLIMIT_RSS ) |
21759 + MASK_ENTRY( VLIMIT_ANON ) |
21762 + MASK_ENTRY( RLIMIT_RSS ) |
21763 + MASK_ENTRY( RLIMIT_NPROC ) |
21764 + MASK_ENTRY( RLIMIT_NOFILE ) |
21765 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21766 + MASK_ENTRY( RLIMIT_AS ) |
21767 + MASK_ENTRY( RLIMIT_LOCKS ) |
21768 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21770 + MASK_ENTRY( VLIMIT_NSOCK ) |
21771 + MASK_ENTRY( VLIMIT_OPENFD ) |
21772 + MASK_ENTRY( VLIMIT_ANON ) |
21773 + MASK_ENTRY( VLIMIT_SHMEM ) |
21774 + MASK_ENTRY( VLIMIT_DENTRY ) |
21777 + /* accounting only */
21778 +uint32_t account_mask =
21779 + MASK_ENTRY( VLIMIT_SEMARY ) |
21780 + MASK_ENTRY( VLIMIT_NSEMS ) |
21781 + MASK_ENTRY( VLIMIT_MAPPED ) |
21785 +static int is_valid_vlimit(int id)
21787 + uint32_t mask = vlimit_mask.minimum |
21788 + vlimit_mask.softlimit | vlimit_mask.maximum;
21789 + return mask & (1 << id);
21792 +static int is_accounted_vlimit(int id)
21794 + if (is_valid_vlimit(id))
21796 + return account_mask & (1 << id);
21800 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21802 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21803 + return VX_VLIM(limit);
21806 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21808 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21809 + return VX_VLIM(limit);
21812 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21813 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21815 + if (!is_valid_vlimit(id))
21819 + *minimum = CRLIM_UNSET;
21821 + *softlimit = vc_get_soft(vxi, id);
21823 + *maximum = vc_get_hard(vxi, id);
21827 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21829 + struct vcmd_ctx_rlimit_v0 vc_data;
21832 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21835 + ret = do_get_rlimit(vxi, vc_data.id,
21836 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21840 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21845 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21846 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21848 + if (!is_valid_vlimit(id))
21851 + if (maximum != CRLIM_KEEP)
21852 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21853 + if (softlimit != CRLIM_KEEP)
21854 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21856 + /* clamp soft limit */
21857 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21858 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21863 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21865 + struct vcmd_ctx_rlimit_v0 vc_data;
21867 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21870 + return do_set_rlimit(vxi, vc_data.id,
21871 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21874 +#ifdef CONFIG_IA32_EMULATION
21876 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21878 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21880 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21883 + return do_set_rlimit(vxi, vc_data.id,
21884 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21887 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21889 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21892 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21895 + ret = do_get_rlimit(vxi, vc_data.id,
21896 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21900 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21905 +#endif /* CONFIG_IA32_EMULATION */
21908 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21910 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21916 +static inline void vx_reset_hits(struct _vx_limit *limit)
21920 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21921 + atomic_set(&__rlim_lhit(limit, lim), 0);
21925 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
21927 + vx_reset_hits(&vxi->limit);
21931 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21936 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21937 + value = __rlim_get(limit, lim);
21938 + __rlim_rmax(limit, lim) = value;
21939 + __rlim_rmin(limit, lim) = value;
21943 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21945 + vx_reset_minmax(&vxi->limit);
21950 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21952 + struct vcmd_rlimit_stat_v0 vc_data;
21953 + struct _vx_limit *limit = &vxi->limit;
21956 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21960 + if (!is_accounted_vlimit(id))
21963 + vx_limit_fixup(limit, id);
21964 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21965 + vc_data.value = __rlim_get(limit, id);
21966 + vc_data.minimum = __rlim_rmin(limit, id);
21967 + vc_data.maximum = __rlim_rmax(limit, id);
21969 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21975 +void vx_vsi_meminfo(struct sysinfo *val)
21977 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21978 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21979 + u64 res_limit, res_usage;
21984 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21985 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21987 + if (res_limit != RESOURCE_MAX)
21988 + val->totalram = (res_limit >> PAGE_SHIFT);
21989 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
21990 + val->bufferram = 0;
21991 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR */
21992 + struct vx_info *vxi = current_vx_info();
21993 + unsigned long totalram, freeram;
21996 + /* we blindly accept the max */
21997 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21998 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
22000 + /* total minus used equals free */
22001 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22002 + freeram = (v < totalram) ? totalram - v : 0;
22004 + val->totalram = totalram;
22005 + val->freeram = freeram;
22006 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22007 + val->totalhigh = 0;
22008 + val->freehigh = 0;
22012 +void vx_vsi_swapinfo(struct sysinfo *val)
22014 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22015 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
22016 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22017 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
22018 + s64 swap_limit, swap_usage;
22023 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22024 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22025 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
22026 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
22028 + if (res_limit == RESOURCE_MAX)
22031 + swap_limit = memsw_limit - res_limit;
22032 + if (memsw_limit != RESOURCE_MAX)
22033 + val->totalswap = swap_limit >> PAGE_SHIFT;
22035 + swap_usage = memsw_usage - res_usage;
22036 + val->freeswap = (swap_usage < swap_limit) ?
22037 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
22038 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22039 + val->totalswap = 0;
22040 + val->freeswap = 0;
22041 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22042 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR */
22043 + struct vx_info *vxi = current_vx_info();
22044 + unsigned long totalswap, freeswap;
22047 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22048 + if (v == RLIM_INFINITY) {
22049 + val->freeswap = val->totalswap;
22053 + /* we blindly accept the max */
22054 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
22055 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
22057 + /* currently 'used' swap */
22058 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22059 + w -= (w > v) ? v : w;
22061 + /* total minus used equals free */
22062 + freeswap = (w < totalswap) ? totalswap - w : 0;
22064 + val->totalswap = totalswap;
22065 + val->freeswap = freeswap;
22066 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22070 +long vx_vsi_cached(struct sysinfo *val)
22072 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22073 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22075 + return mem_cgroup_stat_read_cache(mcg);
22082 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22084 + struct vx_info *vxi = mm->mm_vx_info;
22085 + unsigned long points;
22091 + points = vxi->vx_badness_bias;
22093 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22094 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22095 + points += (v > w) ? (v - w) : 0;
22100 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/limit_init.h linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/limit_init.h
22101 --- linux-2.6.32.24/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
22102 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/limit_init.h 2009-12-03 20:04:56.000000000 +0100
22106 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22110 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22111 + __rlim_soft(limit, lim) = RLIM_INFINITY;
22112 + __rlim_hard(limit, lim) = RLIM_INFINITY;
22113 + __rlim_set(limit, lim, 0);
22114 + atomic_set(&__rlim_lhit(limit, lim), 0);
22115 + __rlim_rmin(limit, lim) = 0;
22116 + __rlim_rmax(limit, lim) = 0;
22120 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22125 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22126 + if ((1 << lim) & VLIM_NOCHECK)
22128 + value = __rlim_get(limit, lim);
22129 + vxwprintk_xid(value,
22130 + "!!! limit: %p[%s,%d] = %ld on exit.",
22131 + limit, vlimit_name[lim], lim, (long)value);
22135 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/limit_proc.h linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/limit_proc.h
22136 --- linux-2.6.32.24/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
22137 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/limit_proc.h 2009-12-03 20:04:56.000000000 +0100
22139 +#ifndef _VX_LIMIT_PROC_H
22140 +#define _VX_LIMIT_PROC_H
22142 +#include <linux/vserver/limit_int.h>
22145 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22146 +#define VX_LIMIT_TOP \
22147 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
22149 +#define VX_LIMIT_ARG(r) \
22150 + (unsigned long)__rlim_get(limit, r), \
22151 + (unsigned long)__rlim_rmin(limit, r), \
22152 + (unsigned long)__rlim_rmax(limit, r), \
22153 + VX_VLIM(__rlim_soft(limit, r)), \
22154 + VX_VLIM(__rlim_hard(limit, r)), \
22155 + atomic_read(&__rlim_lhit(limit, r))
22157 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22159 + vx_limit_fixup(limit, -1);
22160 + return sprintf(buffer, VX_LIMIT_TOP
22161 + "PROC" VX_LIMIT_FMT
22162 + "VM" VX_LIMIT_FMT
22163 + "VML" VX_LIMIT_FMT
22164 + "RSS" VX_LIMIT_FMT
22165 + "ANON" VX_LIMIT_FMT
22166 + "RMAP" VX_LIMIT_FMT
22167 + "FILES" VX_LIMIT_FMT
22168 + "OFD" VX_LIMIT_FMT
22169 + "LOCKS" VX_LIMIT_FMT
22170 + "SOCK" VX_LIMIT_FMT
22171 + "MSGQ" VX_LIMIT_FMT
22172 + "SHM" VX_LIMIT_FMT
22173 + "SEMA" VX_LIMIT_FMT
22174 + "SEMS" VX_LIMIT_FMT
22175 + "DENT" VX_LIMIT_FMT,
22176 + VX_LIMIT_ARG(RLIMIT_NPROC),
22177 + VX_LIMIT_ARG(RLIMIT_AS),
22178 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22179 + VX_LIMIT_ARG(RLIMIT_RSS),
22180 + VX_LIMIT_ARG(VLIMIT_ANON),
22181 + VX_LIMIT_ARG(VLIMIT_MAPPED),
22182 + VX_LIMIT_ARG(RLIMIT_NOFILE),
22183 + VX_LIMIT_ARG(VLIMIT_OPENFD),
22184 + VX_LIMIT_ARG(RLIMIT_LOCKS),
22185 + VX_LIMIT_ARG(VLIMIT_NSOCK),
22186 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22187 + VX_LIMIT_ARG(VLIMIT_SHMEM),
22188 + VX_LIMIT_ARG(VLIMIT_SEMARY),
22189 + VX_LIMIT_ARG(VLIMIT_NSEMS),
22190 + VX_LIMIT_ARG(VLIMIT_DENTRY));
22193 +#endif /* _VX_LIMIT_PROC_H */
22196 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/Makefile linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/Makefile
22197 --- linux-2.6.32.24/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
22198 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/Makefile 2009-12-03 20:04:56.000000000 +0100
22201 +# Makefile for the Linux vserver routines.
22205 +obj-y += vserver.o
22207 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
22208 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
22211 +vserver-$(CONFIG_INET) += inet.o
22212 +vserver-$(CONFIG_PROC_FS) += proc.o
22213 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
22214 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
22215 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
22216 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
22218 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/monitor.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/monitor.c
22219 --- linux-2.6.32.24/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
22220 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/monitor.c 2009-12-03 20:04:56.000000000 +0100
22223 + * kernel/vserver/monitor.c
22225 + * Virtual Context Scheduler Monitor
22227 + * Copyright (C) 2006-2007 Herbert Pötzl
22229 + * V0.01 basic design
22233 +#include <linux/module.h>
22234 +#include <linux/jiffies.h>
22235 +#include <asm/uaccess.h>
22236 +#include <asm/atomic.h>
22238 +#include <linux/vserver/monitor.h>
22239 +#include <linux/vserver/debug_cmd.h>
22242 +#ifdef CONFIG_VSERVER_MONITOR
22243 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
22245 +#define VXM_SIZE 64
22248 +struct _vx_monitor {
22249 + unsigned int counter;
22251 + struct _vx_mon_entry entry[VXM_SIZE+1];
22255 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22257 +unsigned volatile int vxm_active = 1;
22259 +static atomic_t sequence = ATOMIC_INIT(0);
22264 + * requires disabled preemption */
22266 +struct _vx_mon_entry *vxm_advance(int cpu)
22268 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22269 + struct _vx_mon_entry *entry;
22270 + unsigned int index;
22272 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22273 + entry = &mon->entry[index];
22275 + entry->ev.seq = atomic_inc_return(&sequence);
22276 + entry->ev.jif = jiffies;
22280 +EXPORT_SYMBOL_GPL(vxm_advance);
22283 +int do_read_monitor(struct __user _vx_mon_entry *data,
22284 + int cpu, uint32_t *index, uint32_t *count)
22286 + int pos, ret = 0;
22287 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22288 + int end = mon->counter;
22289 + int start = end - VXM_SIZE + 2;
22290 + int idx = *index;
22292 + /* special case: get current pos */
22298 + /* have we lost some data? */
22302 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22303 + struct _vx_mon_entry *entry =
22304 + &mon->entry[idx % VXM_SIZE];
22306 + /* send entry to userspace */
22307 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22311 + /* save new index and count */
22314 + return ret ? ret : (*index < end);
22317 +int vc_read_monitor(uint32_t id, void __user *data)
22319 + struct vcmd_read_monitor_v0 vc_data;
22322 + if (id >= NR_CPUS)
22325 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22328 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22329 + id, &vc_data.index, &vc_data.count);
22331 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22336 +#ifdef CONFIG_COMPAT
22338 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22340 + struct vcmd_read_monitor_v0_x32 vc_data;
22343 + if (id >= NR_CPUS)
22346 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22349 + ret = do_read_monitor((struct __user _vx_mon_entry *)
22350 + compat_ptr(vc_data.data_ptr),
22351 + id, &vc_data.index, &vc_data.count);
22353 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22358 +#endif /* CONFIG_COMPAT */
22360 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/network.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/network.c
22361 --- linux-2.6.32.24/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
22362 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/network.c 2009-12-03 20:04:56.000000000 +0100
22365 + * linux/kernel/vserver/network.c
22367 + * Virtual Server: Network Support
22369 + * Copyright (C) 2003-2007 Herbert Pötzl
22371 + * V0.01 broken out from vcontext V0.05
22372 + * V0.02 cleaned up implementation
22373 + * V0.03 added equiv nx commands
22374 + * V0.04 switch to RCU based hash
22375 + * V0.05 and back to locking again
22376 + * V0.06 changed vcmds to nxi arg
22377 + * V0.07 have __create claim() the nxi
22381 +#include <linux/err.h>
22382 +#include <linux/slab.h>
22383 +#include <linux/rcupdate.h>
22385 +#include <linux/vs_network.h>
22386 +#include <linux/vs_pid.h>
22387 +#include <linux/vserver/network_cmd.h>
22390 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
22391 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
22393 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22394 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22397 +static int __init init_network(void)
22399 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22400 + sizeof(struct nx_addr_v4), 0,
22401 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22402 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22403 + sizeof(struct nx_addr_v6), 0,
22404 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22409 +/* __alloc_nx_addr_v4() */
22411 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22413 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
22414 + nx_addr_v4_cachep, GFP_KERNEL);
22416 + if (!IS_ERR(nxa))
22417 + memset(nxa, 0, sizeof(*nxa));
22421 +/* __dealloc_nx_addr_v4() */
22423 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22425 + kmem_cache_free(nx_addr_v4_cachep, nxa);
22428 +/* __dealloc_nx_addr_v4_all() */
22430 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22433 + struct nx_addr_v4 *next = nxa->next;
22435 + __dealloc_nx_addr_v4(nxa);
22441 +#ifdef CONFIG_IPV6
22443 +/* __alloc_nx_addr_v6() */
22445 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22447 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
22448 + nx_addr_v6_cachep, GFP_KERNEL);
22450 + if (!IS_ERR(nxa))
22451 + memset(nxa, 0, sizeof(*nxa));
22455 +/* __dealloc_nx_addr_v6() */
22457 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22459 + kmem_cache_free(nx_addr_v6_cachep, nxa);
22462 +/* __dealloc_nx_addr_v6_all() */
22464 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22467 + struct nx_addr_v6 *next = nxa->next;
22469 + __dealloc_nx_addr_v6(nxa);
22474 +#endif /* CONFIG_IPV6 */
22476 +/* __alloc_nx_info()
22478 + * allocate an initialized nx_info struct
22479 + * doesn't make it visible (hash) */
22481 +static struct nx_info *__alloc_nx_info(nid_t nid)
22483 + struct nx_info *new = NULL;
22485 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22487 + /* would this benefit from a slab cache? */
22488 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22492 + memset(new, 0, sizeof(struct nx_info));
22493 + new->nx_id = nid;
22494 + INIT_HLIST_NODE(&new->nx_hlist);
22495 + atomic_set(&new->nx_usecnt, 0);
22496 + atomic_set(&new->nx_tasks, 0);
22497 + new->nx_state = 0;
22499 + new->nx_flags = NXF_INIT_SET;
22501 + /* rest of init goes here */
22503 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22504 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22506 + vxdprintk(VXD_CBIT(nid, 0),
22507 + "alloc_nx_info(%d) = %p", nid, new);
22508 + atomic_inc(&nx_global_ctotal);
22512 +/* __dealloc_nx_info()
22514 + * final disposal of nx_info */
22516 +static void __dealloc_nx_info(struct nx_info *nxi)
22518 + vxdprintk(VXD_CBIT(nid, 0),
22519 + "dealloc_nx_info(%p)", nxi);
22521 + nxi->nx_hlist.next = LIST_POISON1;
22524 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22525 + BUG_ON(atomic_read(&nxi->nx_tasks));
22527 + __dealloc_nx_addr_v4_all(nxi->v4.next);
22529 + nxi->nx_state |= NXS_RELEASED;
22531 + atomic_dec(&nx_global_ctotal);
22534 +static void __shutdown_nx_info(struct nx_info *nxi)
22536 + nxi->nx_state |= NXS_SHUTDOWN;
22537 + vs_net_change(nxi, VSC_NETDOWN);
22540 +/* exported stuff */
22542 +void free_nx_info(struct nx_info *nxi)
22544 + /* context shutdown is mandatory */
22545 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22547 + /* context must not be hashed */
22548 + BUG_ON(nxi->nx_state & NXS_HASHED);
22550 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22551 + BUG_ON(atomic_read(&nxi->nx_tasks));
22553 + __dealloc_nx_info(nxi);
22557 +void __nx_set_lback(struct nx_info *nxi)
22559 + int nid = nxi->nx_id;
22560 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22562 + nxi->v4_lback.s_addr = lback;
22565 +extern int __nx_inet_add_lback(__be32 addr);
22566 +extern int __nx_inet_del_lback(__be32 addr);
22569 +/* hash table for nx_info hash */
22571 +#define NX_HASH_SIZE 13
22573 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22575 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22578 +static inline unsigned int __hashval(nid_t nid)
22580 + return (nid % NX_HASH_SIZE);
22585 +/* __hash_nx_info()
22587 + * add the nxi to the global hash table
22588 + * requires the hash_lock to be held */
22590 +static inline void __hash_nx_info(struct nx_info *nxi)
22592 + struct hlist_head *head;
22594 + vxd_assert_lock(&nx_info_hash_lock);
22595 + vxdprintk(VXD_CBIT(nid, 4),
22596 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22598 + /* context must not be hashed */
22599 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22601 + nxi->nx_state |= NXS_HASHED;
22602 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22603 + hlist_add_head(&nxi->nx_hlist, head);
22604 + atomic_inc(&nx_global_cactive);
22607 +/* __unhash_nx_info()
22609 + * remove the nxi from the global hash table
22610 + * requires the hash_lock to be held */
22612 +static inline void __unhash_nx_info(struct nx_info *nxi)
22614 + vxd_assert_lock(&nx_info_hash_lock);
22615 + vxdprintk(VXD_CBIT(nid, 4),
22616 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22617 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22619 + /* context must be hashed */
22620 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22621 + /* but without tasks */
22622 + BUG_ON(atomic_read(&nxi->nx_tasks));
22624 + nxi->nx_state &= ~NXS_HASHED;
22625 + hlist_del(&nxi->nx_hlist);
22626 + atomic_dec(&nx_global_cactive);
22630 +/* __lookup_nx_info()
22632 + * requires the hash_lock to be held
22633 + * doesn't increment the nx_refcnt */
22635 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22637 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22638 + struct hlist_node *pos;
22639 + struct nx_info *nxi;
22641 + vxd_assert_lock(&nx_info_hash_lock);
22642 + hlist_for_each(pos, head) {
22643 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22645 + if (nxi->nx_id == nid)
22650 + vxdprintk(VXD_CBIT(nid, 0),
22651 + "__lookup_nx_info(#%u): %p[#%u]",
22652 + nid, nxi, nxi ? nxi->nx_id : 0);
22657 +/* __create_nx_info()
22659 + * create the requested context
22660 + * get(), claim() and hash it */
22662 +static struct nx_info *__create_nx_info(int id)
22664 + struct nx_info *new, *nxi = NULL;
22666 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22668 + if (!(new = __alloc_nx_info(id)))
22669 + return ERR_PTR(-ENOMEM);
22671 + /* required to make dynamic xids unique */
22672 + spin_lock(&nx_info_hash_lock);
22674 + /* static context requested */
22675 + if ((nxi = __lookup_nx_info(id))) {
22676 + vxdprintk(VXD_CBIT(nid, 0),
22677 + "create_nx_info(%d) = %p (already there)", id, nxi);
22678 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22679 + nxi = ERR_PTR(-EBUSY);
22681 + nxi = ERR_PTR(-EEXIST);
22684 + /* new context */
22685 + vxdprintk(VXD_CBIT(nid, 0),
22686 + "create_nx_info(%d) = %p (new)", id, new);
22687 + claim_nx_info(new, NULL);
22688 + __nx_set_lback(new);
22689 + __hash_nx_info(get_nx_info(new));
22690 + nxi = new, new = NULL;
22693 + spin_unlock(&nx_info_hash_lock);
22695 + __dealloc_nx_info(new);
22701 +/* exported stuff */
22704 +void unhash_nx_info(struct nx_info *nxi)
22706 + __shutdown_nx_info(nxi);
22707 + spin_lock(&nx_info_hash_lock);
22708 + __unhash_nx_info(nxi);
22709 + spin_unlock(&nx_info_hash_lock);
22712 +/* lookup_nx_info()
22714 + * search for a nx_info and get() it
22715 + * negative id means current */
22717 +struct nx_info *lookup_nx_info(int id)
22719 + struct nx_info *nxi = NULL;
22722 + nxi = get_nx_info(current_nx_info());
22723 + } else if (id > 1) {
22724 + spin_lock(&nx_info_hash_lock);
22725 + nxi = get_nx_info(__lookup_nx_info(id));
22726 + spin_unlock(&nx_info_hash_lock);
22731 +/* nid_is_hashed()
22733 + * verify that nid is still hashed */
22735 +int nid_is_hashed(nid_t nid)
22739 + spin_lock(&nx_info_hash_lock);
22740 + hashed = (__lookup_nx_info(nid) != NULL);
22741 + spin_unlock(&nx_info_hash_lock);
22746 +#ifdef CONFIG_PROC_FS
22750 + * get a subset of hashed nids for proc
22751 + * assumes size is at least one */
22753 +int get_nid_list(int index, unsigned int *nids, int size)
22755 + int hindex, nr_nids = 0;
22757 + /* only show current and children */
22758 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22761 + nids[nr_nids] = nx_current_nid();
22765 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22766 + struct hlist_head *head = &nx_info_hash[hindex];
22767 + struct hlist_node *pos;
22769 + spin_lock(&nx_info_hash_lock);
22770 + hlist_for_each(pos, head) {
22771 + struct nx_info *nxi;
22776 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22777 + nids[nr_nids] = nxi->nx_id;
22778 + if (++nr_nids >= size) {
22779 + spin_unlock(&nx_info_hash_lock);
22783 + /* keep the lock time short */
22784 + spin_unlock(&nx_info_hash_lock);
22793 + * migrate task to new network
22794 + * gets nxi, puts old_nxi on change
22797 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22799 + struct nx_info *old_nxi;
22805 + vxdprintk(VXD_CBIT(nid, 5),
22806 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22807 + p, nxi, nxi->nx_id,
22808 + atomic_read(&nxi->nx_usecnt),
22809 + atomic_read(&nxi->nx_tasks));
22811 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22812 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22815 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22818 + /* maybe disallow this completely? */
22819 + old_nxi = task_get_nx_info(p);
22820 + if (old_nxi == nxi)
22825 + clr_nx_info(&p->nx_info);
22826 + claim_nx_info(nxi, p);
22827 + set_nx_info(&p->nx_info, nxi);
22828 + p->nid = nxi->nx_id;
22831 + vxdprintk(VXD_CBIT(nid, 5),
22832 + "moved task %p into nxi:%p[#%d]",
22833 + p, nxi, nxi->nx_id);
22836 + release_nx_info(old_nxi, p);
22839 + put_nx_info(old_nxi);
22844 +void nx_set_persistent(struct nx_info *nxi)
22846 + vxdprintk(VXD_CBIT(nid, 6),
22847 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22849 + get_nx_info(nxi);
22850 + claim_nx_info(nxi, NULL);
22853 +void nx_clear_persistent(struct nx_info *nxi)
22855 + vxdprintk(VXD_CBIT(nid, 6),
22856 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22858 + release_nx_info(nxi, NULL);
22859 + put_nx_info(nxi);
22862 +void nx_update_persistent(struct nx_info *nxi)
22864 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22865 + nx_set_persistent(nxi);
22867 + nx_clear_persistent(nxi);
22870 +/* vserver syscall commands below here */
22872 +/* taks nid and nx_info functions */
22874 +#include <asm/uaccess.h>
22877 +int vc_task_nid(uint32_t id)
22882 + struct task_struct *tsk;
22884 + read_lock(&tasklist_lock);
22885 + tsk = find_task_by_real_pid(id);
22886 + nid = (tsk) ? tsk->nid : -ESRCH;
22887 + read_unlock(&tasklist_lock);
22889 + nid = nx_current_nid();
22894 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22896 + struct vcmd_nx_info_v0 vc_data;
22898 + vc_data.nid = nxi->nx_id;
22900 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22906 +/* network functions */
22908 +int vc_net_create(uint32_t nid, void __user *data)
22910 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22911 + struct nx_info *new_nxi;
22914 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22917 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22920 + new_nxi = __create_nx_info(nid);
22921 + if (IS_ERR(new_nxi))
22922 + return PTR_ERR(new_nxi);
22924 + /* initial flags */
22925 + new_nxi->nx_flags = vc_data.flagword;
22928 + if (vs_net_change(new_nxi, VSC_NETUP))
22931 + ret = nx_migrate_task(current, new_nxi);
22935 + /* return context id on success */
22936 + ret = new_nxi->nx_id;
22938 + /* get a reference for persistent contexts */
22939 + if ((vc_data.flagword & NXF_PERSISTENT))
22940 + nx_set_persistent(new_nxi);
22942 + release_nx_info(new_nxi, NULL);
22943 + put_nx_info(new_nxi);
22948 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22950 + return nx_migrate_task(current, nxi);
22955 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22956 + uint16_t type, uint16_t flags)
22958 + struct nx_addr_v4 *nxa = &nxi->v4;
22960 + if (NX_IPV4(nxi)) {
22961 + /* locate last entry */
22962 + for (; nxa->next; nxa = nxa->next);
22963 + nxa->next = __alloc_nx_addr_v4();
22967 + return PTR_ERR(nxa);
22970 + if (nxi->v4.next)
22971 + /* remove single ip for ip list */
22972 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22974 + nxa->ip[0].s_addr = ip;
22975 + nxa->ip[1].s_addr = ip2;
22976 + nxa->mask.s_addr = mask;
22977 + nxa->type = type;
22978 + nxa->flags = flags;
22983 +int vc_net_add(struct nx_info *nxi, void __user *data)
22985 + struct vcmd_net_addr_v0 vc_data;
22986 + int index, ret = 0;
22988 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22991 + switch (vc_data.type) {
22992 + case NXA_TYPE_IPV4:
22993 + if ((vc_data.count < 1) || (vc_data.count > 4))
22997 + while (index < vc_data.count) {
22998 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22999 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
23007 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
23008 + nxi->v4_bcast = vc_data.ip[0];
23012 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
23013 + nxi->v4_lback = vc_data.ip[0];
23024 +int vc_net_remove(struct nx_info *nxi, void __user *data)
23026 + struct vcmd_net_addr_v0 vc_data;
23028 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23031 + switch (vc_data.type) {
23032 + case NXA_TYPE_ANY:
23033 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23034 + memset(&nxi->v4, 0, sizeof(nxi->v4));
23044 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
23046 + struct vcmd_net_addr_ipv4_v1 vc_data;
23048 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23051 + switch (vc_data.type) {
23052 + case NXA_TYPE_ADDR:
23053 + case NXA_TYPE_RANGE:
23054 + case NXA_TYPE_MASK:
23055 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
23056 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23058 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
23059 + nxi->v4_bcast = vc_data.ip;
23062 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23063 + nxi->v4_lback = vc_data.ip;
23072 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
23074 + struct vcmd_net_addr_ipv4_v1 vc_data;
23076 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23079 + switch (vc_data.type) {
23080 +/* case NXA_TYPE_ADDR:
23083 + case NXA_TYPE_ANY:
23084 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23085 + memset(&nxi->v4, 0, sizeof(nxi->v4));
23095 +#ifdef CONFIG_IPV6
23097 +int do_add_v6_addr(struct nx_info *nxi,
23098 + struct in6_addr *ip, struct in6_addr *mask,
23099 + uint32_t prefix, uint16_t type, uint16_t flags)
23101 + struct nx_addr_v6 *nxa = &nxi->v6;
23103 + if (NX_IPV6(nxi)) {
23104 + /* locate last entry */
23105 + for (; nxa->next; nxa = nxa->next);
23106 + nxa->next = __alloc_nx_addr_v6();
23110 + return PTR_ERR(nxa);
23114 + nxa->mask = *mask;
23115 + nxa->prefix = prefix;
23116 + nxa->type = type;
23117 + nxa->flags = flags;
23122 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23124 + struct vcmd_net_addr_ipv6_v1 vc_data;
23126 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23129 + switch (vc_data.type) {
23130 + case NXA_TYPE_ADDR:
23131 + case NXA_TYPE_MASK:
23132 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23133 + vc_data.prefix, vc_data.type, vc_data.flags);
23140 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23142 + struct vcmd_net_addr_ipv6_v1 vc_data;
23144 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23147 + switch (vc_data.type) {
23148 + case NXA_TYPE_ANY:
23149 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23150 + memset(&nxi->v6, 0, sizeof(nxi->v6));
23159 +#endif /* CONFIG_IPV6 */
23162 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23164 + struct vcmd_net_flags_v0 vc_data;
23166 + vc_data.flagword = nxi->nx_flags;
23168 + /* special STATE flag handling */
23169 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23171 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23176 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23178 + struct vcmd_net_flags_v0 vc_data;
23179 + uint64_t mask, trigger;
23181 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23184 + /* special STATE flag handling */
23185 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23186 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23188 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23189 + vc_data.flagword, mask);
23190 + if (trigger & NXF_PERSISTENT)
23191 + nx_update_persistent(nxi);
23196 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23198 + struct vcmd_net_caps_v0 vc_data;
23200 + vc_data.ncaps = nxi->nx_ncaps;
23201 + vc_data.cmask = ~0ULL;
23203 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23208 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23210 + struct vcmd_net_caps_v0 vc_data;
23212 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23215 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23216 + vc_data.ncaps, vc_data.cmask);
23221 +#include <linux/module.h>
23223 +module_init(init_network);
23225 +EXPORT_SYMBOL_GPL(free_nx_info);
23226 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23228 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/proc.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/proc.c
23229 --- linux-2.6.32.24/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
23230 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/proc.c 2009-12-03 20:04:56.000000000 +0100
23233 + * linux/kernel/vserver/proc.c
23235 + * Virtual Context Support
23237 + * Copyright (C) 2003-2007 Herbert Pötzl
23239 + * V0.01 basic structure
23240 + * V0.02 adaptation vs1.3.0
23241 + * V0.03 proc permissions
23242 + * V0.04 locking/generic
23243 + * V0.05 next generation procfs
23244 + * V0.06 inode validation
23245 + * V0.07 generic rewrite vid
23246 + * V0.08 remove inode type
23250 +#include <linux/proc_fs.h>
23251 +#include <linux/fs_struct.h>
23252 +#include <linux/mount.h>
23253 +#include <asm/unistd.h>
23255 +#include <linux/vs_context.h>
23256 +#include <linux/vs_network.h>
23257 +#include <linux/vs_cvirt.h>
23259 +#include <linux/in.h>
23260 +#include <linux/inetdevice.h>
23261 +#include <linux/vs_inet.h>
23262 +#include <linux/vs_inet6.h>
23264 +#include <linux/vserver/global.h>
23266 +#include "cvirt_proc.h"
23267 +#include "cacct_proc.h"
23268 +#include "limit_proc.h"
23269 +#include "sched_proc.h"
23270 +#include "vci_config.h"
23273 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23277 + CAP_FOR_EACH_U32(__capi) {
23278 + buffer += sprintf(buffer, "%08x",
23279 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23285 +static struct proc_dir_entry *proc_virtual;
23287 +static struct proc_dir_entry *proc_virtnet;
23290 +/* first the actual feeds */
23293 +static int proc_vci(char *buffer)
23295 + return sprintf(buffer,
23296 + "VCIVersion:\t%04x:%04x\n"
23297 + "VCISyscall:\t%d\n"
23298 + "VCIKernel:\t%08x\n",
23299 + VCI_VERSION >> 16,
23300 + VCI_VERSION & 0xFFFF,
23302 + vci_kernel_config());
23305 +static int proc_virtual_info(char *buffer)
23307 + return proc_vci(buffer);
23310 +static int proc_virtual_status(char *buffer)
23312 + return sprintf(buffer,
23314 + "#CActive:\t%d\n"
23315 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23316 + "#InitTask:\t%d\t%d %d\n",
23317 + atomic_read(&vx_global_ctotal),
23318 + atomic_read(&vx_global_cactive),
23319 + atomic_read(&vs_global_nsproxy),
23320 + atomic_read(&vs_global_fs),
23321 + atomic_read(&vs_global_mnt_ns),
23322 + atomic_read(&vs_global_uts_ns),
23323 + atomic_read(&nr_ipc_ns),
23324 + atomic_read(&vs_global_user_ns),
23325 + atomic_read(&vs_global_pid_ns),
23326 + atomic_read(&init_task.usage),
23327 + atomic_read(&init_task.nsproxy->count),
23328 + init_task.fs->users);
23332 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23336 + length = sprintf(buffer,
23344 + vxi->vx_badness_bias);
23348 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23350 + char *orig = buffer;
23352 + buffer += sprintf(buffer,
23355 + "Flags:\t%016llx\n",
23356 + atomic_read(&vxi->vx_usecnt),
23357 + atomic_read(&vxi->vx_tasks),
23358 + (unsigned long long)vxi->vx_flags);
23360 + buffer += sprintf(buffer, "BCaps:\t");
23361 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23362 + buffer += sprintf(buffer, "\n");
23364 + buffer += sprintf(buffer,
23365 + "CCaps:\t%016llx\n"
23366 + "Spaces:\t%08lx %08lx\n",
23367 + (unsigned long long)vxi->vx_ccaps,
23368 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23369 + return buffer - orig;
23372 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23374 + return vx_info_proc_limit(&vxi->limit, buffer);
23377 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23381 + length = vx_info_proc_sched(&vxi->sched, buffer);
23382 + for_each_online_cpu(cpu) {
23383 + length += vx_info_proc_sched_pc(
23384 + &vx_per_cpu(vxi, sched_pc, cpu),
23385 + buffer + length, cpu);
23390 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23392 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23395 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23397 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23400 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23404 + vx_update_load(vxi);
23405 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23406 + for_each_online_cpu(cpu) {
23407 + length += vx_info_proc_cvirt_pc(
23408 + &vx_per_cpu(vxi, cvirt_pc, cpu),
23409 + buffer + length, cpu);
23414 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23416 + return vx_info_proc_cacct(&vxi->cacct, buffer);
23420 +static int proc_virtnet_info(char *buffer)
23422 + return proc_vci(buffer);
23425 +static int proc_virtnet_status(char *buffer)
23427 + return sprintf(buffer,
23429 + "#CActive:\t%d\n",
23430 + atomic_read(&nx_global_ctotal),
23431 + atomic_read(&nx_global_cactive));
23434 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23436 + struct nx_addr_v4 *v4a;
23437 +#ifdef CONFIG_IPV6
23438 + struct nx_addr_v6 *v6a;
23442 + length = sprintf(buffer,
23445 + "Bcast:\t" NIPQUAD_FMT "\n"
23446 + "Lback:\t" NIPQUAD_FMT "\n",
23449 + NIPQUAD(nxi->v4_bcast.s_addr),
23450 + NIPQUAD(nxi->v4_lback.s_addr));
23452 + if (!NX_IPV4(nxi))
23454 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23455 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23458 +#ifdef CONFIG_IPV6
23459 + if (!NX_IPV6(nxi))
23461 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23462 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23469 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23473 + length = sprintf(buffer,
23476 + "Flags:\t%016llx\n"
23477 + "NCaps:\t%016llx\n",
23478 + atomic_read(&nxi->nx_usecnt),
23479 + atomic_read(&nxi->nx_tasks),
23480 + (unsigned long long)nxi->nx_flags,
23481 + (unsigned long long)nxi->nx_ncaps);
23487 +/* here the inode helpers */
23493 + struct inode_operations *iop;
23494 + struct file_operations *fop;
23495 + union proc_op op;
23498 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23500 + struct inode *inode = new_inode(sb);
23505 + inode->i_mode = p->mode;
23507 + inode->i_op = p->iop;
23509 + inode->i_fop = p->fop;
23511 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23512 + inode->i_flags |= S_IMMUTABLE;
23514 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23516 + inode->i_uid = 0;
23517 + inode->i_gid = 0;
23518 + inode->i_tag = 0;
23523 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23524 + struct dentry *dentry, int id, void *ptr)
23526 + struct vs_entry *p = ptr;
23527 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23528 + struct dentry *error = ERR_PTR(-EINVAL);
23533 + PROC_I(inode)->op = p->op;
23534 + PROC_I(inode)->fd = id;
23535 + d_add(dentry, inode);
23543 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23546 + * Fill a directory entry.
23548 + * If possible create the dcache entry and derive our inode number and
23549 + * file type from dcache entry.
23551 + * Since all of the proc inode numbers are dynamically generated, the inode
23552 + * numbers do not exist until the inode is cache. This means creating the
23553 + * the dcache entry in readdir is necessary to keep the inode numbers
23554 + * reported by readdir in sync with the inode numbers reported
23557 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23558 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23560 + struct dentry *child, *dir = filp->f_dentry;
23561 + struct inode *inode;
23562 + struct qstr qname;
23564 + unsigned type = DT_UNKNOWN;
23566 + qname.name = name;
23568 + qname.hash = full_name_hash(name, len);
23570 + child = d_lookup(dir, &qname);
23572 + struct dentry *new;
23573 + new = d_alloc(dir, &qname);
23575 + child = instantiate(dir->d_inode, new, id, ptr);
23582 + if (!child || IS_ERR(child) || !child->d_inode)
23583 + goto end_instantiate;
23584 + inode = child->d_inode;
23586 + ino = inode->i_ino;
23587 + type = inode->i_mode >> 12;
23592 + ino = find_inode_number(dir, &qname);
23595 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23600 +/* get and revalidate vx_info/xid */
23603 +struct vx_info *get_proc_vx_info(struct inode *inode)
23605 + return lookup_vx_info(PROC_I(inode)->fd);
23608 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23610 + struct inode *inode = dentry->d_inode;
23611 + xid_t xid = PROC_I(inode)->fd;
23613 + if (!xid || xid_is_hashed(xid))
23620 +/* get and revalidate nx_info/nid */
23622 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23624 + struct inode *inode = dentry->d_inode;
23625 + nid_t nid = PROC_I(inode)->fd;
23627 + if (!nid || nid_is_hashed(nid))
23635 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23637 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23638 + size_t count, loff_t *ppos)
23640 + struct inode *inode = file->f_dentry->d_inode;
23641 + unsigned long page;
23642 + ssize_t length = 0;
23644 + if (count > PROC_BLOCK_SIZE)
23645 + count = PROC_BLOCK_SIZE;
23647 + /* fade that out as soon as stable */
23648 + WARN_ON(PROC_I(inode)->fd);
23650 + if (!(page = __get_free_page(GFP_KERNEL)))
23653 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23654 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23657 + length = simple_read_from_buffer(buf, count, ppos,
23658 + (char *)page, length);
23664 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23665 + size_t count, loff_t *ppos)
23667 + struct inode *inode = file->f_dentry->d_inode;
23668 + struct vx_info *vxi = NULL;
23669 + xid_t xid = PROC_I(inode)->fd;
23670 + unsigned long page;
23671 + ssize_t length = 0;
23673 + if (count > PROC_BLOCK_SIZE)
23674 + count = PROC_BLOCK_SIZE;
23676 + /* fade that out as soon as stable */
23678 + vxi = lookup_vx_info(xid);
23682 + length = -ENOMEM;
23683 + if (!(page = __get_free_page(GFP_KERNEL)))
23686 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23687 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23690 + length = simple_read_from_buffer(buf, count, ppos,
23691 + (char *)page, length);
23695 + put_vx_info(vxi);
23700 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23701 + size_t count, loff_t *ppos)
23703 + struct inode *inode = file->f_dentry->d_inode;
23704 + struct nx_info *nxi = NULL;
23705 + nid_t nid = PROC_I(inode)->fd;
23706 + unsigned long page;
23707 + ssize_t length = 0;
23709 + if (count > PROC_BLOCK_SIZE)
23710 + count = PROC_BLOCK_SIZE;
23712 + /* fade that out as soon as stable */
23714 + nxi = lookup_nx_info(nid);
23718 + length = -ENOMEM;
23719 + if (!(page = __get_free_page(GFP_KERNEL)))
23722 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23723 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23726 + length = simple_read_from_buffer(buf, count, ppos,
23727 + (char *)page, length);
23731 + put_nx_info(nxi);
23738 +/* here comes the lower level */
23741 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23742 + .len = sizeof(NAME) - 1, \
23743 + .name = (NAME), \
23751 +#define DIR(NAME, MODE, OTYPE) \
23752 + NOD(NAME, (S_IFDIR | (MODE)), \
23753 + &proc_ ## OTYPE ## _inode_operations, \
23754 + &proc_ ## OTYPE ## _file_operations, { } )
23756 +#define INF(NAME, MODE, OTYPE) \
23757 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23758 + &proc_vs_info_file_operations, \
23759 + { .proc_vs_read = &proc_##OTYPE } )
23761 +#define VINF(NAME, MODE, OTYPE) \
23762 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23763 + &proc_vx_info_file_operations, \
23764 + { .proc_vxi_read = &proc_##OTYPE } )
23766 +#define NINF(NAME, MODE, OTYPE) \
23767 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23768 + &proc_nx_info_file_operations, \
23769 + { .proc_nxi_read = &proc_##OTYPE } )
23772 +static struct file_operations proc_vs_info_file_operations = {
23773 + .read = proc_vs_info_read,
23776 +static struct file_operations proc_vx_info_file_operations = {
23777 + .read = proc_vx_info_read,
23780 +static struct dentry_operations proc_xid_dentry_operations = {
23781 + .d_revalidate = proc_xid_revalidate,
23784 +static struct vs_entry vx_base_stuff[] = {
23785 + VINF("info", S_IRUGO, vxi_info),
23786 + VINF("status", S_IRUGO, vxi_status),
23787 + VINF("limit", S_IRUGO, vxi_limit),
23788 + VINF("sched", S_IRUGO, vxi_sched),
23789 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23790 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23791 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23792 + VINF("cacct", S_IRUGO, vxi_cacct),
23799 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23800 + struct dentry *dentry, int id, void *ptr)
23802 + dentry->d_op = &proc_xid_dentry_operations;
23803 + return vs_proc_instantiate(dir, dentry, id, ptr);
23806 +static struct dentry *proc_xid_lookup(struct inode *dir,
23807 + struct dentry *dentry, struct nameidata *nd)
23809 + struct vs_entry *p = vx_base_stuff;
23810 + struct dentry *error = ERR_PTR(-ENOENT);
23812 + for (; p->name; p++) {
23813 + if (p->len != dentry->d_name.len)
23815 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23821 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23826 +static int proc_xid_readdir(struct file *filp,
23827 + void *dirent, filldir_t filldir)
23829 + struct dentry *dentry = filp->f_dentry;
23830 + struct inode *inode = dentry->d_inode;
23831 + struct vs_entry *p = vx_base_stuff;
23832 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23836 + pos = filp->f_pos;
23839 + ino = inode->i_ino;
23840 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23843 + /* fall through */
23845 + ino = parent_ino(dentry);
23846 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23849 + /* fall through */
23852 + if (index >= size)
23854 + for (p += index; p->name; p++) {
23855 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23856 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23862 + filp->f_pos = pos;
23868 +static struct file_operations proc_nx_info_file_operations = {
23869 + .read = proc_nx_info_read,
23872 +static struct dentry_operations proc_nid_dentry_operations = {
23873 + .d_revalidate = proc_nid_revalidate,
23876 +static struct vs_entry nx_base_stuff[] = {
23877 + NINF("info", S_IRUGO, nxi_info),
23878 + NINF("status", S_IRUGO, nxi_status),
23883 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23884 + struct dentry *dentry, int id, void *ptr)
23886 + dentry->d_op = &proc_nid_dentry_operations;
23887 + return vs_proc_instantiate(dir, dentry, id, ptr);
23890 +static struct dentry *proc_nid_lookup(struct inode *dir,
23891 + struct dentry *dentry, struct nameidata *nd)
23893 + struct vs_entry *p = nx_base_stuff;
23894 + struct dentry *error = ERR_PTR(-ENOENT);
23896 + for (; p->name; p++) {
23897 + if (p->len != dentry->d_name.len)
23899 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23905 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23910 +static int proc_nid_readdir(struct file *filp,
23911 + void *dirent, filldir_t filldir)
23913 + struct dentry *dentry = filp->f_dentry;
23914 + struct inode *inode = dentry->d_inode;
23915 + struct vs_entry *p = nx_base_stuff;
23916 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23920 + pos = filp->f_pos;
23923 + ino = inode->i_ino;
23924 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23927 + /* fall through */
23929 + ino = parent_ino(dentry);
23930 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23933 + /* fall through */
23936 + if (index >= size)
23938 + for (p += index; p->name; p++) {
23939 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23940 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23946 + filp->f_pos = pos;
23951 +#define MAX_MULBY10 ((~0U - 9) / 10)
23953 +static inline int atovid(const char *str, int len)
23958 + while (len-- > 0) {
23963 + if (vid >= MAX_MULBY10)
23973 +/* now the upper level (virtual) */
23976 +static struct file_operations proc_xid_file_operations = {
23977 + .read = generic_read_dir,
23978 + .readdir = proc_xid_readdir,
23981 +static struct inode_operations proc_xid_inode_operations = {
23982 + .lookup = proc_xid_lookup,
23985 +static struct vs_entry vx_virtual_stuff[] = {
23986 + INF("info", S_IRUGO, virtual_info),
23987 + INF("status", S_IRUGO, virtual_status),
23988 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23992 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23993 + struct dentry *dentry, struct nameidata *nd)
23995 + struct vs_entry *p = vx_virtual_stuff;
23996 + struct dentry *error = ERR_PTR(-ENOENT);
23999 + for (; p->name; p++) {
24000 + if (p->len != dentry->d_name.len)
24002 + if (!memcmp(dentry->d_name.name, p->name, p->len))
24006 + goto instantiate;
24008 + id = atovid(dentry->d_name.name, dentry->d_name.len);
24009 + if ((id < 0) || !xid_is_hashed(id))
24013 + error = proc_xid_instantiate(dir, dentry, id, p);
24018 +static struct file_operations proc_nid_file_operations = {
24019 + .read = generic_read_dir,
24020 + .readdir = proc_nid_readdir,
24023 +static struct inode_operations proc_nid_inode_operations = {
24024 + .lookup = proc_nid_lookup,
24027 +static struct vs_entry nx_virtnet_stuff[] = {
24028 + INF("info", S_IRUGO, virtnet_info),
24029 + INF("status", S_IRUGO, virtnet_status),
24030 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
24034 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
24035 + struct dentry *dentry, struct nameidata *nd)
24037 + struct vs_entry *p = nx_virtnet_stuff;
24038 + struct dentry *error = ERR_PTR(-ENOENT);
24041 + for (; p->name; p++) {
24042 + if (p->len != dentry->d_name.len)
24044 + if (!memcmp(dentry->d_name.name, p->name, p->len))
24048 + goto instantiate;
24050 + id = atovid(dentry->d_name.name, dentry->d_name.len);
24051 + if ((id < 0) || !nid_is_hashed(id))
24055 + error = proc_nid_instantiate(dir, dentry, id, p);
24061 +#define PROC_MAXVIDS 32
24063 +int proc_virtual_readdir(struct file *filp,
24064 + void *dirent, filldir_t filldir)
24066 + struct dentry *dentry = filp->f_dentry;
24067 + struct inode *inode = dentry->d_inode;
24068 + struct vs_entry *p = vx_virtual_stuff;
24069 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24071 + unsigned int xid_array[PROC_MAXVIDS];
24072 + char buf[PROC_NUMBUF];
24073 + unsigned int nr_xids, i;
24076 + pos = filp->f_pos;
24079 + ino = inode->i_ino;
24080 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24083 + /* fall through */
24085 + ino = parent_ino(dentry);
24086 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24089 + /* fall through */
24092 + if (index >= size)
24094 + for (p += index; p->name; p++) {
24095 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24096 + vs_proc_instantiate, 0, p))
24101 + index = pos - size;
24102 + p = &vx_virtual_stuff[size - 1];
24103 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24104 + for (i = 0; i < nr_xids; i++) {
24105 + int n, xid = xid_array[i];
24106 + unsigned int j = PROC_NUMBUF;
24110 + buf[--j] = '0' + (n % 10);
24113 + if (proc_fill_cache(filp, dirent, filldir,
24114 + buf + j, PROC_NUMBUF - j,
24115 + vs_proc_instantiate, xid, p))
24121 + filp->f_pos = pos;
24125 +static int proc_virtual_getattr(struct vfsmount *mnt,
24126 + struct dentry *dentry, struct kstat *stat)
24128 + struct inode *inode = dentry->d_inode;
24130 + generic_fillattr(inode, stat);
24131 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
24135 +static struct file_operations proc_virtual_dir_operations = {
24136 + .read = generic_read_dir,
24137 + .readdir = proc_virtual_readdir,
24140 +static struct inode_operations proc_virtual_dir_inode_operations = {
24141 + .getattr = proc_virtual_getattr,
24142 + .lookup = proc_virtual_lookup,
24149 +int proc_virtnet_readdir(struct file *filp,
24150 + void *dirent, filldir_t filldir)
24152 + struct dentry *dentry = filp->f_dentry;
24153 + struct inode *inode = dentry->d_inode;
24154 + struct vs_entry *p = nx_virtnet_stuff;
24155 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24157 + unsigned int nid_array[PROC_MAXVIDS];
24158 + char buf[PROC_NUMBUF];
24159 + unsigned int nr_nids, i;
24162 + pos = filp->f_pos;
24165 + ino = inode->i_ino;
24166 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24169 + /* fall through */
24171 + ino = parent_ino(dentry);
24172 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24175 + /* fall through */
24178 + if (index >= size)
24180 + for (p += index; p->name; p++) {
24181 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24182 + vs_proc_instantiate, 0, p))
24187 + index = pos - size;
24188 + p = &nx_virtnet_stuff[size - 1];
24189 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24190 + for (i = 0; i < nr_nids; i++) {
24191 + int n, nid = nid_array[i];
24192 + unsigned int j = PROC_NUMBUF;
24196 + buf[--j] = '0' + (n % 10);
24199 + if (proc_fill_cache(filp, dirent, filldir,
24200 + buf + j, PROC_NUMBUF - j,
24201 + vs_proc_instantiate, nid, p))
24207 + filp->f_pos = pos;
24211 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24212 + struct dentry *dentry, struct kstat *stat)
24214 + struct inode *inode = dentry->d_inode;
24216 + generic_fillattr(inode, stat);
24217 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
24221 +static struct file_operations proc_virtnet_dir_operations = {
24222 + .read = generic_read_dir,
24223 + .readdir = proc_virtnet_readdir,
24226 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24227 + .getattr = proc_virtnet_getattr,
24228 + .lookup = proc_virtnet_lookup,
24233 +void proc_vx_init(void)
24235 + struct proc_dir_entry *ent;
24237 + ent = proc_mkdir("virtual", 0);
24239 + ent->proc_fops = &proc_virtual_dir_operations;
24240 + ent->proc_iops = &proc_virtual_dir_inode_operations;
24242 + proc_virtual = ent;
24244 + ent = proc_mkdir("virtnet", 0);
24246 + ent->proc_fops = &proc_virtnet_dir_operations;
24247 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
24249 + proc_virtnet = ent;
24255 +/* per pid info */
24258 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24260 + struct vx_info *vxi;
24261 + char *orig = buffer;
24263 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24265 + vxi = task_get_vx_info(p);
24269 + buffer += sprintf(buffer, "BCaps:\t");
24270 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24271 + buffer += sprintf(buffer, "\n");
24272 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24273 + (unsigned long long)vxi->vx_ccaps);
24274 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24275 + (unsigned long long)vxi->vx_flags);
24276 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24278 + put_vx_info(vxi);
24280 + return buffer - orig;
24284 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24286 + struct nx_info *nxi;
24287 + struct nx_addr_v4 *v4a;
24288 +#ifdef CONFIG_IPV6
24289 + struct nx_addr_v6 *v6a;
24291 + char *orig = buffer;
24294 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24296 + nxi = task_get_nx_info(p);
24300 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24301 + (unsigned long long)nxi->nx_ncaps);
24302 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24303 + (unsigned long long)nxi->nx_flags);
24305 + buffer += sprintf(buffer,
24306 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24307 + NIPQUAD(nxi->v4_bcast.s_addr));
24308 + buffer += sprintf (buffer,
24309 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24310 + NIPQUAD(nxi->v4_lback.s_addr));
24311 + if (!NX_IPV4(nxi))
24313 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24314 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24317 +#ifdef CONFIG_IPV6
24318 + if (!NX_IPV6(nxi))
24320 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24321 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24325 + put_nx_info(nxi);
24327 + return buffer - orig;
24330 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/sched.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/sched.c
24331 --- linux-2.6.32.24/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
24332 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/sched.c 2009-12-03 20:04:56.000000000 +0100
24335 + * linux/kernel/vserver/sched.c
24337 + * Virtual Server: Scheduler Support
24339 + * Copyright (C) 2004-2007 Herbert Pötzl
24341 + * V0.01 adapted Sam Vilains version to 2.6.3
24342 + * V0.02 removed legacy interface
24343 + * V0.03 changed vcmds to vxi arg
24344 + * V0.04 removed older and legacy interfaces
24348 +#include <linux/vs_context.h>
24349 +#include <linux/vs_sched.h>
24350 +#include <linux/vserver/sched_cmd.h>
24352 +#include <asm/uaccess.h>
24355 +#define vxd_check_range(val, min, max) do { \
24356 + vxlprintk((val < min) || (val > max), \
24357 + "check_range(%ld,%ld,%ld)", \
24358 + (long)val, (long)min, (long)max, \
24359 + __FILE__, __LINE__); \
24363 +void vx_update_sched_param(struct _vx_sched *sched,
24364 + struct _vx_sched_pc *sched_pc)
24366 + unsigned int set_mask = sched->update_mask;
24368 + if (set_mask & VXSM_FILL_RATE)
24369 + sched_pc->fill_rate[0] = sched->fill_rate[0];
24370 + if (set_mask & VXSM_INTERVAL)
24371 + sched_pc->interval[0] = sched->interval[0];
24372 + if (set_mask & VXSM_FILL_RATE2)
24373 + sched_pc->fill_rate[1] = sched->fill_rate[1];
24374 + if (set_mask & VXSM_INTERVAL2)
24375 + sched_pc->interval[1] = sched->interval[1];
24376 + if (set_mask & VXSM_TOKENS)
24377 + sched_pc->tokens = sched->tokens;
24378 + if (set_mask & VXSM_TOKENS_MIN)
24379 + sched_pc->tokens_min = sched->tokens_min;
24380 + if (set_mask & VXSM_TOKENS_MAX)
24381 + sched_pc->tokens_max = sched->tokens_max;
24382 + if (set_mask & VXSM_PRIO_BIAS)
24383 + sched_pc->prio_bias = sched->prio_bias;
24385 + if (set_mask & VXSM_IDLE_TIME)
24386 + sched_pc->flags |= VXSF_IDLE_TIME;
24388 + sched_pc->flags &= ~VXSF_IDLE_TIME;
24391 + sched_pc->norm_time = jiffies;
24396 + * recalculate the context's scheduling tokens
24398 + * ret > 0 : number of tokens available
24399 + * ret < 0 : on hold, check delta_min[]
24400 + * -1 only jiffies
24401 + * -2 also idle time
24404 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24405 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24409 + int flags = sched_pc->flags;
24411 + /* how much time did pass? */
24412 + delta = *norm_time - sched_pc->norm_time;
24413 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24414 + vxd_check_range(delta, 0, INT_MAX);
24416 + if (delta >= sched_pc->interval[0]) {
24417 + long tokens, integral;
24419 + /* calc integral token part */
24420 + tokens = delta / sched_pc->interval[0];
24421 + integral = tokens * sched_pc->interval[0];
24422 + tokens *= sched_pc->fill_rate[0];
24423 +#ifdef CONFIG_VSERVER_HARDCPU
24424 + delta_min[0] = delta - integral;
24425 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24427 + /* advance time */
24428 + sched_pc->norm_time += delta;
24431 + sched_pc->tokens += tokens;
24432 + sched_pc->token_time += tokens;
24434 + delta_min[0] = delta;
24436 +#ifdef CONFIG_VSERVER_IDLETIME
24437 + if (!(flags & VXSF_IDLE_TIME))
24440 + /* how much was the idle skip? */
24441 + delta = *idle_time - sched_pc->idle_time;
24442 + vxd_check_range(delta, 0, INT_MAX);
24444 + if (delta >= sched_pc->interval[1]) {
24445 + long tokens, integral;
24447 + /* calc fair share token part */
24448 + tokens = delta / sched_pc->interval[1];
24449 + integral = tokens * sched_pc->interval[1];
24450 + tokens *= sched_pc->fill_rate[1];
24451 + delta_min[1] = delta - integral;
24452 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24454 + /* advance idle time */
24455 + sched_pc->idle_time += integral;
24458 + sched_pc->tokens += tokens;
24459 + sched_pc->token_time += tokens;
24461 + delta_min[1] = delta;
24465 + /* clip at maximum */
24466 + if (sched_pc->tokens > sched_pc->tokens_max)
24467 + sched_pc->tokens = sched_pc->tokens_max;
24468 + tokens = sched_pc->tokens;
24470 + if ((flags & VXSF_ONHOLD)) {
24471 + /* can we unhold? */
24472 + if (tokens >= sched_pc->tokens_min) {
24473 + flags &= ~VXSF_ONHOLD;
24474 + sched_pc->hold_ticks +=
24475 + *norm_time - sched_pc->onhold;
24479 + /* put on hold? */
24480 + if (tokens <= 0) {
24481 + flags |= VXSF_ONHOLD;
24482 + sched_pc->onhold = *norm_time;
24486 + sched_pc->flags = flags;
24490 + tokens = sched_pc->tokens_min - tokens;
24491 + sched_pc->flags = flags;
24492 + // BUG_ON(tokens < 0); probably doesn't hold anymore
24494 +#ifdef CONFIG_VSERVER_HARDCPU
24495 + /* next interval? */
24496 + if (!sched_pc->fill_rate[0])
24497 + delta_min[0] = HZ;
24498 + else if (tokens > sched_pc->fill_rate[0])
24499 + delta_min[0] += sched_pc->interval[0] *
24500 + tokens / sched_pc->fill_rate[0];
24502 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
24503 + vxd_check_range(delta_min[0], 0, INT_MAX);
24505 +#ifdef CONFIG_VSERVER_IDLETIME
24506 + if (!(flags & VXSF_IDLE_TIME))
24509 + /* next interval? */
24510 + if (!sched_pc->fill_rate[1])
24511 + delta_min[1] = HZ;
24512 + else if (tokens > sched_pc->fill_rate[1])
24513 + delta_min[1] += sched_pc->interval[1] *
24514 + tokens / sched_pc->fill_rate[1];
24516 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
24517 + vxd_check_range(delta_min[1], 0, INT_MAX);
24522 +#endif /* CONFIG_VSERVER_IDLETIME */
24525 +#endif /* CONFIG_VSERVER_HARDCPU */
24528 +static inline unsigned long msec_to_ticks(unsigned long msec)
24530 + return msecs_to_jiffies(msec);
24533 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24535 + return jiffies_to_msecs(ticks);
24538 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24540 + return jiffies_to_usecs(ticks);
24544 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24546 + unsigned int set_mask = data->mask;
24547 + unsigned int update_mask;
24550 + /* Sanity check data values */
24551 + if (data->tokens_max <= 0)
24552 + data->tokens_max = HZ;
24553 + if (data->tokens_min < 0)
24554 + data->tokens_min = HZ / 3;
24555 + if (data->tokens_min >= data->tokens_max)
24556 + data->tokens_min = data->tokens_max;
24558 + if (data->prio_bias > MAX_PRIO_BIAS)
24559 + data->prio_bias = MAX_PRIO_BIAS;
24560 + if (data->prio_bias < MIN_PRIO_BIAS)
24561 + data->prio_bias = MIN_PRIO_BIAS;
24563 + spin_lock(&vxi->sched.tokens_lock);
24565 + /* sync up on delayed updates */
24566 + for_each_cpu_mask(cpu, vxi->sched.update)
24567 + vx_update_sched_param(&vxi->sched,
24568 + &vx_per_cpu(vxi, sched_pc, cpu));
24570 + if (set_mask & VXSM_FILL_RATE)
24571 + vxi->sched.fill_rate[0] = data->fill_rate[0];
24572 + if (set_mask & VXSM_FILL_RATE2)
24573 + vxi->sched.fill_rate[1] = data->fill_rate[1];
24574 + if (set_mask & VXSM_INTERVAL)
24575 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24576 + msec_to_ticks(data->interval[0]) : data->interval[0];
24577 + if (set_mask & VXSM_INTERVAL2)
24578 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24579 + msec_to_ticks(data->interval[1]) : data->interval[1];
24580 + if (set_mask & VXSM_TOKENS)
24581 + vxi->sched.tokens = data->tokens;
24582 + if (set_mask & VXSM_TOKENS_MIN)
24583 + vxi->sched.tokens_min = data->tokens_min;
24584 + if (set_mask & VXSM_TOKENS_MAX)
24585 + vxi->sched.tokens_max = data->tokens_max;
24586 + if (set_mask & VXSM_PRIO_BIAS)
24587 + vxi->sched.prio_bias = data->prio_bias;
24589 + /* Sanity check rate/interval */
24590 + for (i = 0; i < 2; i++) {
24591 + if (data->fill_rate[i] < 0)
24592 + data->fill_rate[i] = 0;
24593 + if (data->interval[i] <= 0)
24594 + data->interval[i] = HZ;
24597 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24598 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24599 + vxi->sched.update_mask = update_mask;
24603 + if (set_mask & VXSM_CPU_ID) {
24604 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24605 + cpus_and(vxi->sched.update, cpu_online_map,
24606 + vxi->sched.update);
24608 + vxi->sched.update = cpu_online_map;
24610 + /* forced reload? */
24611 + if (set_mask & VXSM_FORCE) {
24612 + for_each_cpu_mask(cpu, vxi->sched.update)
24613 + vx_update_sched_param(&vxi->sched,
24614 + &vx_per_cpu(vxi, sched_pc, cpu));
24615 + vxi->sched.update = CPU_MASK_NONE;
24618 + /* on UP we update immediately */
24619 + vx_update_sched_param(&vxi->sched,
24620 + &vx_per_cpu(vxi, sched_pc, 0));
24623 + spin_unlock(&vxi->sched.tokens_lock);
24628 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24629 +#define COPY_PRI(C) C(prio_bias)
24630 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24631 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24632 + C(fill_rate[1]); C(interval[1]);
24634 +#define COPY_VALUE(name) vc_data.name = data->name
24636 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24638 + struct vcmd_sched_v5 vc_data;
24640 + vc_data.mask = data->set_mask;
24641 + COPY_IDS(COPY_VALUE);
24642 + COPY_PRI(COPY_VALUE);
24643 + COPY_TOK(COPY_VALUE);
24644 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24645 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
24646 + return do_set_sched(vxi, &vc_data);
24649 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24651 + struct vcmd_set_sched_v4 vc_data;
24653 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24656 + return do_set_sched_v4(vxi, &vc_data);
24659 + /* latest interface is v5 */
24661 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24663 + struct vcmd_sched_v5 vc_data;
24665 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24668 + return do_set_sched(vxi, &vc_data);
24672 +#define COPY_PRI(C) C(prio_bias)
24673 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24674 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24675 + C(fill_rate[1]); C(interval[1]);
24677 +#define COPY_VALUE(name) vc_data.name = data->name
24680 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24682 + struct vcmd_sched_v5 vc_data;
24684 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24687 + if (vc_data.mask & VXSM_CPU_ID) {
24688 + int cpu = vc_data.cpu_id;
24689 + struct _vx_sched_pc *data;
24691 + if (!cpu_possible(cpu))
24694 + data = &vx_per_cpu(vxi, sched_pc, cpu);
24695 + COPY_TOK(COPY_VALUE);
24696 + COPY_PRI(COPY_VALUE);
24697 + COPY_FRI(COPY_VALUE);
24699 + if (data->flags & VXSF_IDLE_TIME)
24700 + vc_data.mask |= VXSM_IDLE_TIME;
24702 + struct _vx_sched *data = &vxi->sched;
24704 + COPY_TOK(COPY_VALUE);
24705 + COPY_PRI(COPY_VALUE);
24706 + COPY_FRI(COPY_VALUE);
24709 + if (vc_data.mask & VXSM_MSEC) {
24710 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24711 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24714 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24720 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24722 + struct vcmd_sched_info vc_data;
24725 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24728 + cpu = vc_data.cpu_id;
24729 + if (!cpu_possible(cpu))
24733 + struct _vx_sched_pc *sched_pc =
24734 + &vx_per_cpu(vxi, sched_pc, cpu);
24736 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24737 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24738 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24739 + vc_data.vavavoom = sched_pc->vavavoom;
24741 + vc_data.token_usec = ticks_to_usec(1);
24743 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24748 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/sched_init.h linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/sched_init.h
24749 --- linux-2.6.32.24/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24750 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/sched_init.h 2009-12-03 20:04:56.000000000 +0100
24753 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24755 + static struct lock_class_key tokens_lock_key;
24757 + /* scheduling; hard code starting values as constants */
24758 + sched->fill_rate[0] = 1;
24759 + sched->interval[0] = 4;
24760 + sched->fill_rate[1] = 1;
24761 + sched->interval[1] = 8;
24762 + sched->tokens = HZ >> 2;
24763 + sched->tokens_min = HZ >> 4;
24764 + sched->tokens_max = HZ >> 1;
24765 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24766 + sched->prio_bias = 0;
24768 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24772 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24774 + sched_pc->fill_rate[0] = 1;
24775 + sched_pc->interval[0] = 4;
24776 + sched_pc->fill_rate[1] = 1;
24777 + sched_pc->interval[1] = 8;
24778 + sched_pc->tokens = HZ >> 2;
24779 + sched_pc->tokens_min = HZ >> 4;
24780 + sched_pc->tokens_max = HZ >> 1;
24781 + sched_pc->prio_bias = 0;
24782 + sched_pc->vavavoom = 0;
24783 + sched_pc->token_time = 0;
24784 + sched_pc->idle_time = 0;
24785 + sched_pc->norm_time = jiffies;
24787 + sched_pc->user_ticks = 0;
24788 + sched_pc->sys_ticks = 0;
24789 + sched_pc->hold_ticks = 0;
24792 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24798 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24802 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/sched_proc.h linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/sched_proc.h
24803 --- linux-2.6.32.24/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24804 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/sched_proc.h 2009-12-03 20:04:56.000000000 +0100
24806 +#ifndef _VX_SCHED_PROC_H
24807 +#define _VX_SCHED_PROC_H
24811 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24815 + length += sprintf(buffer,
24816 + "FillRate:\t%8d,%d\n"
24817 + "Interval:\t%8d,%d\n"
24818 + "TokensMin:\t%8d\n"
24819 + "TokensMax:\t%8d\n"
24820 + "PrioBias:\t%8d\n",
24821 + sched->fill_rate[0],
24822 + sched->fill_rate[1],
24823 + sched->interval[0],
24824 + sched->interval[1],
24825 + sched->tokens_min,
24826 + sched->tokens_max,
24827 + sched->prio_bias);
24832 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24833 + char *buffer, int cpu)
24837 + length += sprintf(buffer + length,
24838 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24839 + (unsigned long long)sched_pc->user_ticks,
24840 + (unsigned long long)sched_pc->sys_ticks,
24841 + (unsigned long long)sched_pc->hold_ticks,
24842 + sched_pc->token_time,
24843 + sched_pc->idle_time);
24844 + length += sprintf(buffer + length,
24845 + " %c%c %d %d %d %d/%d %d/%d",
24846 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24847 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24848 + sched_pc->tokens,
24849 + sched_pc->tokens_min,
24850 + sched_pc->tokens_max,
24851 + sched_pc->fill_rate[0],
24852 + sched_pc->interval[0],
24853 + sched_pc->fill_rate[1],
24854 + sched_pc->interval[1]);
24855 + length += sprintf(buffer + length,
24857 + sched_pc->prio_bias,
24858 + sched_pc->vavavoom);
24862 +#endif /* _VX_SCHED_PROC_H */
24863 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/signal.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/signal.c
24864 --- linux-2.6.32.24/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24865 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/signal.c 2009-12-03 20:04:56.000000000 +0100
24868 + * linux/kernel/vserver/signal.c
24870 + * Virtual Server: Signal Support
24872 + * Copyright (C) 2003-2007 Herbert Pötzl
24874 + * V0.01 broken out from vcontext V0.05
24875 + * V0.02 changed vcmds to vxi arg
24876 + * V0.03 adjusted siginfo for kill
24880 +#include <asm/uaccess.h>
24882 +#include <linux/vs_context.h>
24883 +#include <linux/vs_pid.h>
24884 +#include <linux/vserver/signal_cmd.h>
24887 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24889 + int retval, count = 0;
24890 + struct task_struct *p;
24891 + struct siginfo *sip = SEND_SIG_PRIV;
24894 + vxdprintk(VXD_CBIT(misc, 4),
24895 + "vx_info_kill(%p[#%d],%d,%d)*",
24896 + vxi, vxi->vx_id, pid, sig);
24897 + read_lock(&tasklist_lock);
24901 + for_each_process(p) {
24904 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24905 + (pid && vxi->vx_initpid == p->pid))
24908 + err = group_send_sig_info(sig, sip, p);
24910 + if (err != -EPERM)
24916 + if (vxi->vx_initpid) {
24917 + pid = vxi->vx_initpid;
24918 + /* for now, only SIGINT to private init ... */
24919 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24920 + /* ... as long as there are tasks left */
24921 + (atomic_read(&vxi->vx_tasks) > 1))
24924 + /* fallthrough */
24926 + p = find_task_by_real_pid(pid);
24928 + if (vx_task_xid(p) == vxi->vx_id)
24929 + retval = group_send_sig_info(sig, sip, p);
24933 + read_unlock(&tasklist_lock);
24934 + vxdprintk(VXD_CBIT(misc, 4),
24935 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24936 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24940 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24942 + struct vcmd_ctx_kill_v0 vc_data;
24944 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24947 + /* special check to allow guest shutdown */
24948 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24949 + /* forbid killall pid=0 when init is present */
24950 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24951 + (vc_data.pid > 1)))
24954 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24958 +static int __wait_exit(struct vx_info *vxi)
24960 + DECLARE_WAITQUEUE(wait, current);
24963 + add_wait_queue(&vxi->vx_wait, &wait);
24964 + set_current_state(TASK_INTERRUPTIBLE);
24967 + if (vx_info_state(vxi,
24968 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24970 + if (signal_pending(current)) {
24971 + ret = -ERESTARTSYS;
24978 + set_current_state(TASK_RUNNING);
24979 + remove_wait_queue(&vxi->vx_wait, &wait);
24985 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24987 + struct vcmd_wait_exit_v0 vc_data;
24990 + ret = __wait_exit(vxi);
24991 + vc_data.reboot_cmd = vxi->reboot_cmd;
24992 + vc_data.exit_code = vxi->exit_code;
24994 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24999 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/space.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/space.c
25000 --- linux-2.6.32.24/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
25001 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/space.c 2009-12-03 20:04:56.000000000 +0100
25004 + * linux/kernel/vserver/space.c
25006 + * Virtual Server: Context Space Support
25008 + * Copyright (C) 2003-2007 Herbert Pötzl
25010 + * V0.01 broken out from context.c 0.07
25011 + * V0.02 added task locking for namespace
25012 + * V0.03 broken out vx_enter_namespace
25013 + * V0.04 added *space support and commands
25017 +#include <linux/utsname.h>
25018 +#include <linux/nsproxy.h>
25019 +#include <linux/err.h>
25020 +#include <linux/fs_struct.h>
25021 +#include <asm/uaccess.h>
25023 +#include <linux/vs_context.h>
25024 +#include <linux/vserver/space.h>
25025 +#include <linux/vserver/space_cmd.h>
25027 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
25028 +atomic_t vs_global_fs = ATOMIC_INIT(0);
25029 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
25030 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
25031 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
25032 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
25035 +/* namespace functions */
25037 +#include <linux/mnt_namespace.h>
25038 +#include <linux/user_namespace.h>
25039 +#include <linux/pid_namespace.h>
25040 +#include <linux/ipc_namespace.h>
25041 +#include <net/net_namespace.h>
25044 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
25045 + .mask = CLONE_FS |
25053 +static const struct vcmd_space_mask_v1 space_mask = {
25054 + .mask = CLONE_FS |
25059 +#ifdef CONFIG_PID_NS
25062 +#ifdef CONFIG_NET_NS
25068 +static const struct vcmd_space_mask_v1 default_space_mask = {
25069 + .mask = CLONE_FS |
25074 +#ifdef CONFIG_PID_NS
25081 + * build a new nsproxy mix
25082 + * assumes that both proxies are 'const'
25083 + * does not touch nsproxy refcounts
25084 + * will hold a reference on the result.
25087 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25088 + struct nsproxy *new_nsproxy, unsigned long mask)
25090 + struct mnt_namespace *old_ns;
25091 + struct uts_namespace *old_uts;
25092 + struct ipc_namespace *old_ipc;
25093 +#ifdef CONFIG_PID_NS
25094 + struct pid_namespace *old_pid;
25096 +#ifdef CONFIG_NET_NS
25097 + struct net *old_net;
25099 + struct nsproxy *nsproxy;
25101 + nsproxy = copy_nsproxy(old_nsproxy);
25105 + if (mask & CLONE_NEWNS) {
25106 + old_ns = nsproxy->mnt_ns;
25107 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25108 + if (nsproxy->mnt_ns)
25109 + get_mnt_ns(nsproxy->mnt_ns);
25113 + if (mask & CLONE_NEWUTS) {
25114 + old_uts = nsproxy->uts_ns;
25115 + nsproxy->uts_ns = new_nsproxy->uts_ns;
25116 + if (nsproxy->uts_ns)
25117 + get_uts_ns(nsproxy->uts_ns);
25121 + if (mask & CLONE_NEWIPC) {
25122 + old_ipc = nsproxy->ipc_ns;
25123 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25124 + if (nsproxy->ipc_ns)
25125 + get_ipc_ns(nsproxy->ipc_ns);
25129 +#ifdef CONFIG_PID_NS
25130 + if (mask & CLONE_NEWPID) {
25131 + old_pid = nsproxy->pid_ns;
25132 + nsproxy->pid_ns = new_nsproxy->pid_ns;
25133 + if (nsproxy->pid_ns)
25134 + get_pid_ns(nsproxy->pid_ns);
25138 +#ifdef CONFIG_NET_NS
25139 + if (mask & CLONE_NEWNET) {
25140 + old_net = nsproxy->net_ns;
25141 + nsproxy->net_ns = new_nsproxy->net_ns;
25142 + if (nsproxy->net_ns)
25143 + get_net(nsproxy->net_ns);
25148 + put_mnt_ns(old_ns);
25150 + put_uts_ns(old_uts);
25152 + put_ipc_ns(old_ipc);
25153 +#ifdef CONFIG_PID_NS
25155 + put_pid_ns(old_pid);
25157 +#ifdef CONFIG_NET_NS
25159 + put_net(old_net);
25167 + * merge two nsproxy structs into a new one.
25168 + * will hold a reference on the result.
25172 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25173 + struct nsproxy *proxy, unsigned long mask)
25175 + struct nsproxy null_proxy = { .mnt_ns = NULL };
25181 + /* vs_mix_nsproxy returns with reference */
25182 + return vs_mix_nsproxy(old ? old : &null_proxy,
25185 + get_nsproxy(proxy);
25190 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25192 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
25193 + struct fs_struct *fs_cur, *fs = NULL;
25194 + int ret, kill = 0;
25196 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
25197 + vxi, vxi->vx_id, mask, index);
25199 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25203 + mask = vxi->vx_nsmask[index];
25205 + if ((mask & vxi->vx_nsmask[index]) != mask)
25208 + if (mask & CLONE_FS) {
25209 + fs = copy_fs_struct(vxi->vx_fs[index]);
25213 + proxy = vxi->vx_nsproxy[index];
25215 + vxdprintk(VXD_CBIT(space, 9),
25216 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
25217 + vxi, vxi->vx_id, mask, index, proxy, fs);
25219 + task_lock(current);
25220 + fs_cur = current->fs;
25222 + if (mask & CLONE_FS) {
25223 + write_lock(&fs_cur->lock);
25224 + current->fs = fs;
25225 + kill = !--fs_cur->users;
25226 + write_unlock(&fs_cur->lock);
25229 + proxy_cur = current->nsproxy;
25230 + get_nsproxy(proxy_cur);
25231 + task_unlock(current);
25234 + free_fs_struct(fs_cur);
25236 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25237 + if (IS_ERR(proxy_new)) {
25238 + ret = PTR_ERR(proxy_new);
25242 + proxy_new = xchg(¤t->nsproxy, proxy_new);
25246 + put_nsproxy(proxy_new);
25249 + put_nsproxy(proxy_cur);
25254 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25256 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25257 + struct fs_struct *fs_vxi, *fs;
25258 + int ret, kill = 0;
25260 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25261 + vxi, vxi->vx_id, mask, index);
25264 + mask = default_space_mask.mask;
25266 + if ((mask & space_mask.mask) != mask)
25269 + proxy_vxi = vxi->vx_nsproxy[index];
25270 + fs_vxi = vxi->vx_fs[index];
25272 + if (mask & CLONE_FS) {
25273 + fs = copy_fs_struct(current->fs);
25278 + task_lock(current);
25280 + if (mask & CLONE_FS) {
25281 + write_lock(&fs_vxi->lock);
25282 + vxi->vx_fs[index] = fs;
25283 + kill = !--fs_vxi->users;
25284 + write_unlock(&fs_vxi->lock);
25287 + proxy_cur = current->nsproxy;
25288 + get_nsproxy(proxy_cur);
25289 + task_unlock(current);
25292 + free_fs_struct(fs_vxi);
25294 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25295 + if (IS_ERR(proxy_new)) {
25296 + ret = PTR_ERR(proxy_new);
25300 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25301 + vxi->vx_nsmask[index] |= mask;
25305 + put_nsproxy(proxy_new);
25308 + put_nsproxy(proxy_cur);
25313 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25315 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25317 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25320 + return vx_enter_space(vxi, vc_data.mask, 0);
25323 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25325 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25327 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25330 + if (vc_data.index >= VX_SPACES)
25333 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25336 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25338 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25340 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25343 + return vx_set_space(vxi, vc_data.mask, 0);
25346 +int vc_set_space(struct vx_info *vxi, void __user *data)
25348 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25350 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25353 + if (vc_data.index >= VX_SPACES)
25356 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
25359 +int vc_get_space_mask(void __user *data, int type)
25361 + const struct vcmd_space_mask_v1 *mask;
25364 + mask = &space_mask_v0;
25365 + else if (type == 1)
25366 + mask = &space_mask;
25368 + mask = &default_space_mask;
25370 + vxdprintk(VXD_CBIT(space, 10),
25371 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25373 + if (copy_to_user(data, mask, sizeof(*mask)))
25378 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/switch.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/switch.c
25379 --- linux-2.6.32.24/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
25380 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/switch.c 2009-12-03 20:04:56.000000000 +0100
25383 + * linux/kernel/vserver/switch.c
25385 + * Virtual Server: Syscall Switch
25387 + * Copyright (C) 2003-2007 Herbert Pötzl
25389 + * V0.01 syscall switch
25390 + * V0.02 added signal to context
25391 + * V0.03 added rlimit functions
25392 + * V0.04 added iattr, task/xid functions
25393 + * V0.05 added debug/history stuff
25394 + * V0.06 added compat32 layer
25395 + * V0.07 vcmd args and perms
25396 + * V0.08 added status commands
25397 + * V0.09 added tag commands
25398 + * V0.10 added oom bias
25399 + * V0.11 added device commands
25403 +#include <linux/vs_context.h>
25404 +#include <linux/vs_network.h>
25405 +#include <linux/vserver/switch.h>
25407 +#include "vci_config.h"
25411 +int vc_get_version(uint32_t id)
25413 + return VCI_VERSION;
25417 +int vc_get_vci(uint32_t id)
25419 + return vci_kernel_config();
25422 +#include <linux/vserver/context_cmd.h>
25423 +#include <linux/vserver/cvirt_cmd.h>
25424 +#include <linux/vserver/cacct_cmd.h>
25425 +#include <linux/vserver/limit_cmd.h>
25426 +#include <linux/vserver/network_cmd.h>
25427 +#include <linux/vserver/sched_cmd.h>
25428 +#include <linux/vserver/debug_cmd.h>
25429 +#include <linux/vserver/inode_cmd.h>
25430 +#include <linux/vserver/dlimit_cmd.h>
25431 +#include <linux/vserver/signal_cmd.h>
25432 +#include <linux/vserver/space_cmd.h>
25433 +#include <linux/vserver/tag_cmd.h>
25434 +#include <linux/vserver/device_cmd.h>
25436 +#include <linux/vserver/inode.h>
25437 +#include <linux/vserver/dlimit.h>
25440 +#ifdef CONFIG_COMPAT
25441 +#define __COMPAT(name, id, data, compat) \
25442 + (compat) ? name ## _x32(id, data) : name(id, data)
25443 +#define __COMPAT_NO_ID(name, data, compat) \
25444 + (compat) ? name ## _x32(data) : name(data)
25446 +#define __COMPAT(name, id, data, compat) \
25448 +#define __COMPAT_NO_ID(name, data, compat) \
25454 +long do_vcmd(uint32_t cmd, uint32_t id,
25455 + struct vx_info *vxi, struct nx_info *nxi,
25456 + void __user *data, int compat)
25460 + case VCMD_get_version:
25461 + return vc_get_version(id);
25462 + case VCMD_get_vci:
25463 + return vc_get_vci(id);
25465 + case VCMD_task_xid:
25466 + return vc_task_xid(id);
25467 + case VCMD_vx_info:
25468 + return vc_vx_info(vxi, data);
25470 + case VCMD_task_nid:
25471 + return vc_task_nid(id);
25472 + case VCMD_nx_info:
25473 + return vc_nx_info(nxi, data);
25475 + case VCMD_task_tag:
25476 + return vc_task_tag(id);
25478 + case VCMD_set_space_v1:
25479 + return vc_set_space_v1(vxi, data);
25480 + /* this is version 2 */
25481 + case VCMD_set_space:
25482 + return vc_set_space(vxi, data);
25484 + case VCMD_get_space_mask_v0:
25485 + return vc_get_space_mask(data, 0);
25486 + /* this is version 1 */
25487 + case VCMD_get_space_mask:
25488 + return vc_get_space_mask(data, 1);
25490 + case VCMD_get_space_default:
25491 + return vc_get_space_mask(data, -1);
25493 +#ifdef CONFIG_IA32_EMULATION
25494 + case VCMD_get_rlimit:
25495 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
25496 + case VCMD_set_rlimit:
25497 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
25499 + case VCMD_get_rlimit:
25500 + return vc_get_rlimit(vxi, data);
25501 + case VCMD_set_rlimit:
25502 + return vc_set_rlimit(vxi, data);
25504 + case VCMD_get_rlimit_mask:
25505 + return vc_get_rlimit_mask(id, data);
25506 + case VCMD_reset_hits:
25507 + return vc_reset_hits(vxi, data);
25508 + case VCMD_reset_minmax:
25509 + return vc_reset_minmax(vxi, data);
25511 + case VCMD_get_vhi_name:
25512 + return vc_get_vhi_name(vxi, data);
25513 + case VCMD_set_vhi_name:
25514 + return vc_set_vhi_name(vxi, data);
25516 + case VCMD_ctx_stat:
25517 + return vc_ctx_stat(vxi, data);
25518 + case VCMD_virt_stat:
25519 + return vc_virt_stat(vxi, data);
25520 + case VCMD_sock_stat:
25521 + return vc_sock_stat(vxi, data);
25522 + case VCMD_rlimit_stat:
25523 + return vc_rlimit_stat(vxi, data);
25525 + case VCMD_set_cflags:
25526 + return vc_set_cflags(vxi, data);
25527 + case VCMD_get_cflags:
25528 + return vc_get_cflags(vxi, data);
25530 + /* this is version 1 */
25531 + case VCMD_set_ccaps:
25532 + return vc_set_ccaps(vxi, data);
25533 + /* this is version 1 */
25534 + case VCMD_get_ccaps:
25535 + return vc_get_ccaps(vxi, data);
25536 + case VCMD_set_bcaps:
25537 + return vc_set_bcaps(vxi, data);
25538 + case VCMD_get_bcaps:
25539 + return vc_get_bcaps(vxi, data);
25541 + case VCMD_set_badness:
25542 + return vc_set_badness(vxi, data);
25543 + case VCMD_get_badness:
25544 + return vc_get_badness(vxi, data);
25546 + case VCMD_set_nflags:
25547 + return vc_set_nflags(nxi, data);
25548 + case VCMD_get_nflags:
25549 + return vc_get_nflags(nxi, data);
25551 + case VCMD_set_ncaps:
25552 + return vc_set_ncaps(nxi, data);
25553 + case VCMD_get_ncaps:
25554 + return vc_get_ncaps(nxi, data);
25556 + case VCMD_set_sched_v4:
25557 + return vc_set_sched_v4(vxi, data);
25558 + /* this is version 5 */
25559 + case VCMD_set_sched:
25560 + return vc_set_sched(vxi, data);
25561 + case VCMD_get_sched:
25562 + return vc_get_sched(vxi, data);
25563 + case VCMD_sched_info:
25564 + return vc_sched_info(vxi, data);
25566 + case VCMD_add_dlimit:
25567 + return __COMPAT(vc_add_dlimit, id, data, compat);
25568 + case VCMD_rem_dlimit:
25569 + return __COMPAT(vc_rem_dlimit, id, data, compat);
25570 + case VCMD_set_dlimit:
25571 + return __COMPAT(vc_set_dlimit, id, data, compat);
25572 + case VCMD_get_dlimit:
25573 + return __COMPAT(vc_get_dlimit, id, data, compat);
25575 + case VCMD_ctx_kill:
25576 + return vc_ctx_kill(vxi, data);
25578 + case VCMD_wait_exit:
25579 + return vc_wait_exit(vxi, data);
25581 + case VCMD_get_iattr:
25582 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25583 + case VCMD_set_iattr:
25584 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25586 + case VCMD_fget_iattr:
25587 + return vc_fget_iattr(id, data);
25588 + case VCMD_fset_iattr:
25589 + return vc_fset_iattr(id, data);
25591 + case VCMD_enter_space_v0:
25592 + return vc_enter_space_v1(vxi, NULL);
25593 + case VCMD_enter_space_v1:
25594 + return vc_enter_space_v1(vxi, data);
25595 + /* this is version 2 */
25596 + case VCMD_enter_space:
25597 + return vc_enter_space(vxi, data);
25599 + case VCMD_ctx_create_v0:
25600 + return vc_ctx_create(id, NULL);
25601 + case VCMD_ctx_create:
25602 + return vc_ctx_create(id, data);
25603 + case VCMD_ctx_migrate_v0:
25604 + return vc_ctx_migrate(vxi, NULL);
25605 + case VCMD_ctx_migrate:
25606 + return vc_ctx_migrate(vxi, data);
25608 + case VCMD_net_create_v0:
25609 + return vc_net_create(id, NULL);
25610 + case VCMD_net_create:
25611 + return vc_net_create(id, data);
25612 + case VCMD_net_migrate:
25613 + return vc_net_migrate(nxi, data);
25615 + case VCMD_tag_migrate:
25616 + return vc_tag_migrate(id);
25618 + case VCMD_net_add:
25619 + return vc_net_add(nxi, data);
25620 + case VCMD_net_remove:
25621 + return vc_net_remove(nxi, data);
25623 + case VCMD_net_add_ipv4:
25624 + return vc_net_add_ipv4(nxi, data);
25625 + case VCMD_net_remove_ipv4:
25626 + return vc_net_remove_ipv4(nxi, data);
25627 +#ifdef CONFIG_IPV6
25628 + case VCMD_net_add_ipv6:
25629 + return vc_net_add_ipv6(nxi, data);
25630 + case VCMD_net_remove_ipv6:
25631 + return vc_net_remove_ipv6(nxi, data);
25633 +/* case VCMD_add_match_ipv4:
25634 + return vc_add_match_ipv4(nxi, data);
25635 + case VCMD_get_match_ipv4:
25636 + return vc_get_match_ipv4(nxi, data);
25637 +#ifdef CONFIG_IPV6
25638 + case VCMD_add_match_ipv6:
25639 + return vc_add_match_ipv6(nxi, data);
25640 + case VCMD_get_match_ipv6:
25641 + return vc_get_match_ipv6(nxi, data);
25644 +#ifdef CONFIG_VSERVER_DEVICE
25645 + case VCMD_set_mapping:
25646 + return __COMPAT(vc_set_mapping, vxi, data, compat);
25647 + case VCMD_unset_mapping:
25648 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
25650 +#ifdef CONFIG_VSERVER_HISTORY
25651 + case VCMD_dump_history:
25652 + return vc_dump_history(id);
25653 + case VCMD_read_history:
25654 + return __COMPAT(vc_read_history, id, data, compat);
25656 +#ifdef CONFIG_VSERVER_MONITOR
25657 + case VCMD_read_monitor:
25658 + return __COMPAT(vc_read_monitor, id, data, compat);
25661 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25662 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25668 +#define __VCMD(vcmd, _perm, _args, _flags) \
25669 + case VCMD_ ## vcmd: perm = _perm; \
25670 + args = _args; flags = _flags; break
25673 +#define VCA_NONE 0x00
25674 +#define VCA_VXI 0x01
25675 +#define VCA_NXI 0x02
25677 +#define VCF_NONE 0x00
25678 +#define VCF_INFO 0x01
25679 +#define VCF_ADMIN 0x02
25680 +#define VCF_ARES 0x06 /* includes admin */
25681 +#define VCF_SETUP 0x08
25683 +#define VCF_ZIDOK 0x10 /* zero id okay */
25687 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25690 + int permit = -1, state = 0;
25691 + int perm = -1, args = 0, flags = 0;
25692 + struct vx_info *vxi = NULL;
25693 + struct nx_info *nxi = NULL;
25696 + /* unpriviledged commands */
25697 + __VCMD(get_version, 0, VCA_NONE, 0);
25698 + __VCMD(get_vci, 0, VCA_NONE, 0);
25699 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25700 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
25701 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25702 + __VCMD(get_space_default,0, VCA_NONE, 0);
25704 + /* info commands */
25705 + __VCMD(task_xid, 2, VCA_NONE, 0);
25706 + __VCMD(reset_hits, 2, VCA_VXI, 0);
25707 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25708 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25709 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25710 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25711 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25712 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
25713 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25714 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25716 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25717 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25718 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25719 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25721 + __VCMD(task_nid, 2, VCA_NONE, 0);
25722 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25723 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25724 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25726 + __VCMD(task_tag, 2, VCA_NONE, 0);
25728 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25729 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25730 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25731 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
25732 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
25734 + /* lower admin commands */
25735 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25736 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25737 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25738 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25739 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25740 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25741 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25742 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25744 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25745 + __VCMD(net_create, 5, VCA_NONE, 0);
25746 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25748 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25750 + /* higher admin commands */
25751 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25752 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25753 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25755 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25756 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25757 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25758 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25760 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25761 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25762 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25763 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25765 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25766 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25767 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25768 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25769 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25770 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25771 +#ifdef CONFIG_IPV6
25772 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25773 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25775 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25776 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25777 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25778 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25779 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25781 +#ifdef CONFIG_VSERVER_DEVICE
25782 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25783 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25785 + /* debug level admin commands */
25786 +#ifdef CONFIG_VSERVER_HISTORY
25787 + __VCMD(dump_history, 9, VCA_NONE, 0);
25788 + __VCMD(read_history, 9, VCA_NONE, 0);
25790 +#ifdef CONFIG_VSERVER_MONITOR
25791 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25798 + vxdprintk(VXD_CBIT(switch, 0),
25799 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25800 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25801 + VC_VERSION(cmd), id, data, compat,
25802 + perm, args, flags);
25809 + if (!capable(CAP_CONTEXT))
25813 + /* moved here from the individual commands */
25815 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25819 + /* vcmd involves resource management */
25821 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25825 + /* various legacy exceptions */
25827 + /* will go away when spectator is a cap */
25828 + case VCMD_ctx_migrate_v0:
25829 + case VCMD_ctx_migrate:
25831 + current->xid = 1;
25837 + /* will go away when spectator is a cap */
25838 + case VCMD_net_migrate:
25840 + current->nid = 1;
25847 + /* vcmds are fine by default */
25850 + /* admin type vcmds require admin ... */
25851 + if (flags & VCF_ADMIN)
25852 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25854 + /* ... but setup type vcmds override that */
25855 + if (!permit && (flags & VCF_SETUP))
25856 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25864 + if (!id && (flags & VCF_ZIDOK))
25868 + if (args & VCA_VXI) {
25869 + vxi = lookup_vx_info(id);
25873 + if ((flags & VCF_ADMIN) &&
25874 + /* special case kill for shutdown */
25875 + (cmd != VCMD_ctx_kill) &&
25876 + /* can context be administrated? */
25877 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25883 + if (args & VCA_NXI) {
25884 + nxi = lookup_nx_info(id);
25888 + if ((flags & VCF_ADMIN) &&
25889 + /* can context be administrated? */
25890 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25897 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25900 + if ((args & VCA_NXI) && nxi)
25901 + put_nx_info(nxi);
25903 + if ((args & VCA_VXI) && vxi)
25904 + put_vx_info(vxi);
25906 + vxdprintk(VXD_CBIT(switch, 1),
25907 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25908 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25909 + VC_VERSION(cmd), ret, ret, state, permit);
25914 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25916 + return do_vserver(cmd, id, data, 0);
25919 +#ifdef CONFIG_COMPAT
25922 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25924 + return do_vserver(cmd, id, data, 1);
25927 +#endif /* CONFIG_COMPAT */
25928 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/sysctl.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/sysctl.c
25929 --- linux-2.6.32.24/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25930 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/sysctl.c 2010-01-13 15:21:01.000000000 +0100
25933 + * kernel/vserver/sysctl.c
25935 + * Virtual Context Support
25937 + * Copyright (C) 2004-2007 Herbert Pötzl
25939 + * V0.01 basic structure
25943 +#include <linux/module.h>
25944 +#include <linux/ctype.h>
25945 +#include <linux/sysctl.h>
25946 +#include <linux/parser.h>
25947 +#include <asm/uaccess.h>
25951 + CTL_DEBUG_ERROR = 0,
25952 + CTL_DEBUG_SWITCH = 1,
25967 +unsigned int vx_debug_switch = 0;
25968 +unsigned int vx_debug_xid = 0;
25969 +unsigned int vx_debug_nid = 0;
25970 +unsigned int vx_debug_tag = 0;
25971 +unsigned int vx_debug_net = 0;
25972 +unsigned int vx_debug_limit = 0;
25973 +unsigned int vx_debug_cres = 0;
25974 +unsigned int vx_debug_dlim = 0;
25975 +unsigned int vx_debug_quota = 0;
25976 +unsigned int vx_debug_cvirt = 0;
25977 +unsigned int vx_debug_space = 0;
25978 +unsigned int vx_debug_misc = 0;
25981 +static struct ctl_table_header *vserver_table_header;
25982 +static ctl_table vserver_root_table[];
25985 +void vserver_register_sysctl(void)
25987 + if (!vserver_table_header) {
25988 + vserver_table_header = register_sysctl_table(vserver_root_table);
25993 +void vserver_unregister_sysctl(void)
25995 + if (vserver_table_header) {
25996 + unregister_sysctl_table(vserver_table_header);
25997 + vserver_table_header = NULL;
26002 +static int proc_dodebug(ctl_table *table, int write,
26003 + void __user *buffer, size_t *lenp, loff_t *ppos)
26005 + char tmpbuf[20], *p, c;
26006 + unsigned int value;
26007 + size_t left, len;
26009 + if ((*ppos && !write) || !*lenp) {
26017 + if (!access_ok(VERIFY_READ, buffer, left))
26019 + p = (char *)buffer;
26020 + while (left && __get_user(c, p) >= 0 && isspace(c))
26025 + if (left > sizeof(tmpbuf) - 1)
26027 + if (copy_from_user(tmpbuf, p, left))
26029 + tmpbuf[left] = '\0';
26031 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
26032 + value = 10 * value + (*p - '0');
26033 + if (*p && !isspace(*p))
26035 + while (left && isspace(*p))
26037 + *(unsigned int *)table->data = value;
26039 + if (!access_ok(VERIFY_WRITE, buffer, left))
26041 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
26044 + if (__copy_to_user(buffer, tmpbuf, len))
26046 + if ((left -= len) > 0) {
26047 + if (put_user('\n', (char *)buffer + len))
26061 +#define CTL_ENTRY(ctl, name) \
26063 + .ctl_name = ctl, \
26064 + .procname = #name, \
26065 + .data = &vx_ ## name, \
26066 + .maxlen = sizeof(int), \
26068 + .proc_handler = &proc_dodebug, \
26069 + .strategy = &sysctl_intvec, \
26070 + .extra1 = &zero, \
26071 + .extra2 = &zero, \
26074 +static ctl_table vserver_debug_table[] = {
26075 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
26076 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
26077 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
26078 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
26079 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
26080 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
26081 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
26082 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
26083 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
26084 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
26085 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
26086 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
26087 + { .ctl_name = 0 }
26090 +static ctl_table vserver_root_table[] = {
26092 + .ctl_name = CTL_VSERVER,
26093 + .procname = "vserver",
26095 + .child = vserver_debug_table
26097 + { .ctl_name = 0 }
26101 +static match_table_t tokens = {
26102 + { CTL_DEBUG_SWITCH, "switch=%x" },
26103 + { CTL_DEBUG_XID, "xid=%x" },
26104 + { CTL_DEBUG_NID, "nid=%x" },
26105 + { CTL_DEBUG_TAG, "tag=%x" },
26106 + { CTL_DEBUG_NET, "net=%x" },
26107 + { CTL_DEBUG_LIMIT, "limit=%x" },
26108 + { CTL_DEBUG_CRES, "cres=%x" },
26109 + { CTL_DEBUG_DLIM, "dlim=%x" },
26110 + { CTL_DEBUG_QUOTA, "quota=%x" },
26111 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
26112 + { CTL_DEBUG_SPACE, "space=%x" },
26113 + { CTL_DEBUG_MISC, "misc=%x" },
26114 + { CTL_DEBUG_ERROR, NULL }
26117 +#define HANDLE_CASE(id, name, val) \
26118 + case CTL_DEBUG_ ## id: \
26119 + vx_debug_ ## name = val; \
26120 + printk("vs_debug_" #name "=0x%x\n", val); \
26124 +static int __init vs_debug_setup(char *str)
26129 + printk("vs_debug_setup(%s)\n", str);
26130 + while ((p = strsep(&str, ",")) != NULL) {
26131 + substring_t args[MAX_OPT_ARGS];
26132 + unsigned int value;
26137 + token = match_token(p, tokens, args);
26138 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
26141 + HANDLE_CASE(SWITCH, switch, value);
26142 + HANDLE_CASE(XID, xid, value);
26143 + HANDLE_CASE(NID, nid, value);
26144 + HANDLE_CASE(TAG, tag, value);
26145 + HANDLE_CASE(NET, net, value);
26146 + HANDLE_CASE(LIMIT, limit, value);
26147 + HANDLE_CASE(CRES, cres, value);
26148 + HANDLE_CASE(DLIM, dlim, value);
26149 + HANDLE_CASE(QUOTA, quota, value);
26150 + HANDLE_CASE(CVIRT, cvirt, value);
26151 + HANDLE_CASE(SPACE, space, value);
26152 + HANDLE_CASE(MISC, misc, value);
26161 +__setup("vsdebug=", vs_debug_setup);
26165 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26166 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26167 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26168 +EXPORT_SYMBOL_GPL(vx_debug_net);
26169 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26170 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26171 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26172 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26173 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26174 +EXPORT_SYMBOL_GPL(vx_debug_space);
26175 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26177 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/tag.c linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/tag.c
26178 --- linux-2.6.32.24/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
26179 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/tag.c 2009-12-03 20:04:56.000000000 +0100
26182 + * linux/kernel/vserver/tag.c
26184 + * Virtual Server: Shallow Tag Space
26186 + * Copyright (C) 2007 Herbert Pötzl
26188 + * V0.01 basic implementation
26192 +#include <linux/sched.h>
26193 +#include <linux/vserver/debug.h>
26194 +#include <linux/vs_pid.h>
26195 +#include <linux/vs_tag.h>
26197 +#include <linux/vserver/tag_cmd.h>
26200 +int dx_migrate_task(struct task_struct *p, tag_t tag)
26205 + vxdprintk(VXD_CBIT(tag, 5),
26206 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
26212 + vxdprintk(VXD_CBIT(tag, 5),
26213 + "moved task %p into [#%d]", p, tag);
26217 +/* vserver syscall commands below here */
26219 +/* taks xid and vx_info functions */
26222 +int vc_task_tag(uint32_t id)
26227 + struct task_struct *tsk;
26228 + read_lock(&tasklist_lock);
26229 + tsk = find_task_by_real_pid(id);
26230 + tag = (tsk) ? tsk->tag : -ESRCH;
26231 + read_unlock(&tasklist_lock);
26233 + tag = dx_current_tag();
26238 +int vc_tag_migrate(uint32_t tag)
26240 + return dx_migrate_task(current, tag & 0xFFFF);
26244 diff -NurpP --minimal linux-2.6.32.24/kernel/vserver/vci_config.h linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/vci_config.h
26245 --- linux-2.6.32.24/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
26246 +++ linux-2.6.32.24-vs2.3.0.36.29.6/kernel/vserver/vci_config.h 2009-12-03 20:04:56.000000000 +0100
26249 +/* interface version */
26251 +#define VCI_VERSION 0x00020305
26255 + VCI_KCBIT_NO_DYNAMIC = 0,
26257 + VCI_KCBIT_PROC_SECURE = 4,
26258 + VCI_KCBIT_HARDCPU = 5,
26259 + VCI_KCBIT_IDLELIMIT = 6,
26260 + VCI_KCBIT_IDLETIME = 7,
26262 + VCI_KCBIT_COWBL = 8,
26263 + VCI_KCBIT_FULLCOWBL = 9,
26264 + VCI_KCBIT_SPACES = 10,
26265 + VCI_KCBIT_NETV2 = 11,
26267 + VCI_KCBIT_DEBUG = 16,
26268 + VCI_KCBIT_HISTORY = 20,
26269 + VCI_KCBIT_TAGGED = 24,
26270 + VCI_KCBIT_PPTAG = 28,
26272 + VCI_KCBIT_MORE = 31,
26276 +static inline uint32_t vci_kernel_config(void)
26279 + (1 << VCI_KCBIT_NO_DYNAMIC) |
26281 + /* configured features */
26282 +#ifdef CONFIG_VSERVER_PROC_SECURE
26283 + (1 << VCI_KCBIT_PROC_SECURE) |
26285 +#ifdef CONFIG_VSERVER_HARDCPU
26286 + (1 << VCI_KCBIT_HARDCPU) |
26288 +#ifdef CONFIG_VSERVER_IDLELIMIT
26289 + (1 << VCI_KCBIT_IDLELIMIT) |
26291 +#ifdef CONFIG_VSERVER_IDLETIME
26292 + (1 << VCI_KCBIT_IDLETIME) |
26294 +#ifdef CONFIG_VSERVER_COWBL
26295 + (1 << VCI_KCBIT_COWBL) |
26296 + (1 << VCI_KCBIT_FULLCOWBL) |
26298 + (1 << VCI_KCBIT_SPACES) |
26299 + (1 << VCI_KCBIT_NETV2) |
26301 + /* debug options */
26302 +#ifdef CONFIG_VSERVER_DEBUG
26303 + (1 << VCI_KCBIT_DEBUG) |
26305 +#ifdef CONFIG_VSERVER_HISTORY
26306 + (1 << VCI_KCBIT_HISTORY) |
26309 + /* inode context tagging */
26310 +#if defined(CONFIG_TAGGING_NONE)
26311 + (0 << VCI_KCBIT_TAGGED) |
26312 +#elif defined(CONFIG_TAGGING_UID16)
26313 + (1 << VCI_KCBIT_TAGGED) |
26314 +#elif defined(CONFIG_TAGGING_GID16)
26315 + (2 << VCI_KCBIT_TAGGED) |
26316 +#elif defined(CONFIG_TAGGING_ID24)
26317 + (3 << VCI_KCBIT_TAGGED) |
26318 +#elif defined(CONFIG_TAGGING_INTERN)
26319 + (4 << VCI_KCBIT_TAGGED) |
26320 +#elif defined(CONFIG_TAGGING_RUNTIME)
26321 + (5 << VCI_KCBIT_TAGGED) |
26323 + (7 << VCI_KCBIT_TAGGED) |
26325 + (1 << VCI_KCBIT_PPTAG) |
26329 diff -NurpP --minimal linux-2.6.32.24/mm/allocpercpu.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/allocpercpu.c
26330 --- linux-2.6.32.24/mm/allocpercpu.c 2009-12-03 20:02:58.000000000 +0100
26331 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/allocpercpu.c 2009-12-03 20:04:56.000000000 +0100
26332 @@ -160,12 +160,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
26334 void __init setup_per_cpu_areas(void)
26336 - unsigned long size, i;
26337 + unsigned long size, vspc, i;
26339 unsigned long nr_possible_cpus = num_possible_cpus();
26341 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
26343 /* Copy section for each CPU (we discard the original) */
26344 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
26345 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
26346 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
26348 for_each_possible_cpu(i) {
26349 diff -NurpP --minimal linux-2.6.32.24/mm/filemap_xip.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/filemap_xip.c
26350 --- linux-2.6.32.24/mm/filemap_xip.c 2009-12-03 20:02:58.000000000 +0100
26351 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/filemap_xip.c 2009-12-03 20:04:56.000000000 +0100
26353 #include <linux/sched.h>
26354 #include <linux/seqlock.h>
26355 #include <linux/mutex.h>
26356 +#include <linux/vs_memory.h>
26357 #include <asm/tlbflush.h>
26358 #include <asm/io.h>
26360 diff -NurpP --minimal linux-2.6.32.24/mm/fremap.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/fremap.c
26361 --- linux-2.6.32.24/mm/fremap.c 2009-03-24 14:22:45.000000000 +0100
26362 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/fremap.c 2009-12-03 20:04:56.000000000 +0100
26364 #include <linux/module.h>
26365 #include <linux/syscalls.h>
26366 #include <linux/mmu_notifier.h>
26367 +#include <linux/vs_memory.h>
26369 #include <asm/mmu_context.h>
26370 #include <asm/cacheflush.h>
26371 diff -NurpP --minimal linux-2.6.32.24/mm/hugetlb.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/hugetlb.c
26372 --- linux-2.6.32.24/mm/hugetlb.c 2010-10-04 08:56:18.000000000 +0200
26373 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/hugetlb.c 2010-07-08 02:22:31.000000000 +0200
26375 #include <asm/io.h>
26377 #include <linux/hugetlb.h>
26378 +#include <linux/vs_memory.h>
26379 #include "internal.h"
26381 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26382 diff -NurpP --minimal linux-2.6.32.24/mm/memcontrol.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/memcontrol.c
26383 --- linux-2.6.32.24/mm/memcontrol.c 2010-10-04 08:56:18.000000000 +0200
26384 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/memcontrol.c 2010-05-21 13:20:19.000000000 +0200
26385 @@ -549,6 +549,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26386 struct mem_cgroup, css);
26389 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26391 + return res_counter_read_u64(&mem->res, member);
26394 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26396 + return res_counter_read_u64(&mem->memsw, member);
26399 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26401 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_CACHE);
26404 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26406 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
26409 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26411 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_MAPPED_FILE);
26414 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26416 struct mem_cgroup *mem = NULL;
26417 diff -NurpP --minimal linux-2.6.32.24/mm/memory.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/memory.c
26418 --- linux-2.6.32.24/mm/memory.c 2010-10-04 08:56:18.000000000 +0200
26419 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/memory.c 2010-10-04 10:04:57.000000000 +0200
26421 #include <linux/kallsyms.h>
26422 #include <linux/swapops.h>
26423 #include <linux/elf.h>
26424 +// #include <linux/vs_memory.h>
26426 #include <asm/io.h>
26427 #include <asm/pgalloc.h>
26428 @@ -647,6 +648,9 @@ static int copy_pte_range(struct mm_stru
26432 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
26436 rss[1] = rss[0] = 0;
26437 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
26438 @@ -2678,10 +2682,13 @@ static int do_anonymous_page(struct mm_s
26440 pte_unmap(page_table);
26442 + if (!vx_rss_avail(mm, 1))
26445 /* Check if we need to add a guard page to the stack */
26446 if (check_stack_guard_page(vma, address) < 0)
26447 return VM_FAULT_SIGBUS;
26450 /* Use the zero-page for reads */
26451 if (!(flags & FAULT_FLAG_WRITE)) {
26452 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
26453 @@ -2984,6 +2991,7 @@ static inline int handle_pte_fault(struc
26457 + int ret = 0, type = VXPT_UNKNOWN;
26460 if (!pte_present(entry)) {
26461 @@ -3008,9 +3016,12 @@ static inline int handle_pte_fault(struc
26462 if (unlikely(!pte_same(*pte, entry)))
26464 if (flags & FAULT_FLAG_WRITE) {
26465 - if (!pte_write(entry))
26466 - return do_wp_page(mm, vma, address,
26467 + if (!pte_write(entry)) {
26468 + ret = do_wp_page(mm, vma, address,
26469 pte, pmd, ptl, entry);
26470 + type = VXPT_WRITE;
26473 entry = pte_mkdirty(entry);
26475 entry = pte_mkyoung(entry);
26476 @@ -3028,7 +3039,10 @@ static inline int handle_pte_fault(struc
26479 pte_unmap_unlock(pte, ptl);
26483 + vx_page_fault(mm, vma, type, ret);
26488 diff -NurpP --minimal linux-2.6.32.24/mm/mlock.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/mlock.c
26489 --- linux-2.6.32.24/mm/mlock.c 2010-10-04 08:56:18.000000000 +0200
26490 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/mlock.c 2010-09-05 21:24:17.000000000 +0200
26492 #include <linux/rmap.h>
26493 #include <linux/mmzone.h>
26494 #include <linux/hugetlb.h>
26495 +#include <linux/vs_memory.h>
26497 #include "internal.h"
26499 @@ -420,7 +421,7 @@ success:
26500 nr_pages = (end - start) >> PAGE_SHIFT;
26502 nr_pages = -nr_pages;
26503 - mm->locked_vm += nr_pages;
26504 + vx_vmlocked_add(mm, nr_pages);
26507 * vm_flags is protected by the mmap_sem held in write mode.
26508 @@ -493,7 +494,7 @@ static int do_mlock(unsigned long start,
26510 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26512 - unsigned long locked;
26513 + unsigned long locked, grow;
26514 unsigned long lock_limit;
26515 int error = -ENOMEM;
26517 @@ -506,8 +507,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26518 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
26519 start &= PAGE_MASK;
26521 - locked = len >> PAGE_SHIFT;
26522 - locked += current->mm->locked_vm;
26523 + grow = len >> PAGE_SHIFT;
26524 + if (!vx_vmlocked_avail(current->mm, grow))
26526 + locked = current->mm->locked_vm + grow;
26528 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
26529 lock_limit >>= PAGE_SHIFT;
26530 @@ -515,6 +518,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26531 /* check against resource limits */
26532 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26533 error = do_mlock(start, len, 1);
26535 up_write(¤t->mm->mmap_sem);
26538 @@ -576,6 +580,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
26539 lock_limit >>= PAGE_SHIFT;
26542 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
26544 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
26545 capable(CAP_IPC_LOCK))
26546 ret = do_mlockall(flags);
26547 @@ -650,8 +656,10 @@ int account_locked_memory(struct mm_stru
26551 - mm->total_vm += pgsz;
26552 - mm->locked_vm += pgsz;
26553 + // mm->total_vm += pgsz;
26554 + vx_vmpages_add(mm, pgsz);
26555 + // mm->locked_vm += pgsz;
26556 + vx_vmlocked_add(mm, pgsz);
26560 @@ -665,8 +673,10 @@ void refund_locked_memory(struct mm_stru
26562 down_write(&mm->mmap_sem);
26564 - mm->total_vm -= pgsz;
26565 - mm->locked_vm -= pgsz;
26566 + // mm->total_vm -= pgsz;
26567 + vx_vmpages_sub(mm, pgsz);
26568 + // mm->locked_vm -= pgsz;
26569 + vx_vmlocked_sub(mm, pgsz);
26571 up_write(&mm->mmap_sem);
26573 diff -NurpP --minimal linux-2.6.32.24/mm/mmap.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/mmap.c
26574 --- linux-2.6.32.24/mm/mmap.c 2010-10-04 08:56:18.000000000 +0200
26575 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/mmap.c 2010-10-04 10:04:57.000000000 +0200
26576 @@ -1224,7 +1224,8 @@ munmap_back:
26578 perf_event_mmap(vma);
26580 - mm->total_vm += len >> PAGE_SHIFT;
26581 + // mm->total_vm += len >> PAGE_SHIFT;
26582 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26583 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
26584 if (vm_flags & VM_LOCKED) {
26586 @@ -1233,7 +1234,8 @@ out:
26587 long nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
26589 return nr_pages; /* vma gone! */
26590 - mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
26591 + // mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
26592 + vx_vmlocked_add(mm, (len >> PAGE_SHIFT) - nr_pages);
26593 } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
26594 make_pages_present(addr, addr + len);
26596 @@ -1588,9 +1590,9 @@ static int acct_stack_growth(struct vm_a
26599 /* Ok, everything looks good - let it rip */
26600 - mm->total_vm += grow;
26601 + vx_vmpages_add(mm, grow);
26602 if (vma->vm_flags & VM_LOCKED)
26603 - mm->locked_vm += grow;
26604 + vx_vmlocked_add(mm, grow);
26605 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
26608 @@ -1762,7 +1764,8 @@ static void remove_vma_list(struct mm_st
26610 long nrpages = vma_pages(vma);
26612 - mm->total_vm -= nrpages;
26613 + // mm->total_vm -= nrpages;
26614 + vx_vmpages_sub(mm, nrpages);
26615 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
26616 vma = remove_vma(vma);
26618 @@ -1937,7 +1940,8 @@ int do_munmap(struct mm_struct *mm, unsi
26619 struct vm_area_struct *tmp = vma;
26620 while (tmp && tmp->vm_start < end) {
26621 if (tmp->vm_flags & VM_LOCKED) {
26622 - mm->locked_vm -= vma_pages(tmp);
26623 + // mm->locked_vm -= vma_pages(tmp);
26624 + vx_vmlocked_sub(mm, vma_pages(tmp));
26625 munlock_vma_pages_all(tmp);
26627 tmp = tmp->vm_next;
26628 @@ -2020,6 +2024,8 @@ unsigned long do_brk(unsigned long addr,
26629 lock_limit >>= PAGE_SHIFT;
26630 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26632 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
26637 @@ -2046,7 +2052,8 @@ unsigned long do_brk(unsigned long addr,
26638 if (mm->map_count > sysctl_max_map_count)
26641 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
26642 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
26643 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
26646 /* Can we just expand an old private anonymous mapping? */
26647 @@ -2072,10 +2079,13 @@ unsigned long do_brk(unsigned long addr,
26648 vma->vm_page_prot = vm_get_page_prot(flags);
26649 vma_link(mm, vma, prev, rb_link, rb_parent);
26651 - mm->total_vm += len >> PAGE_SHIFT;
26652 + // mm->total_vm += len >> PAGE_SHIFT;
26653 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26655 if (flags & VM_LOCKED) {
26656 if (!mlock_vma_pages_range(vma, addr, addr + len))
26657 - mm->locked_vm += (len >> PAGE_SHIFT);
26658 + // mm->locked_vm += (len >> PAGE_SHIFT);
26659 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26663 @@ -2119,6 +2129,11 @@ void exit_mmap(struct mm_struct *mm)
26664 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
26665 tlb_finish_mmu(tlb, 0, end);
26667 + set_mm_counter(mm, file_rss, 0);
26668 + set_mm_counter(mm, anon_rss, 0);
26669 + vx_vmpages_sub(mm, mm->total_vm);
26670 + vx_vmlocked_sub(mm, mm->locked_vm);
26673 * Walk the list again, actually closing and freeing it,
26674 * with preemption enabled, without holding any MM locks.
26675 @@ -2158,7 +2173,8 @@ int insert_vm_struct(struct mm_struct *
26676 if (__vma && __vma->vm_start < vma->vm_end)
26678 if ((vma->vm_flags & VM_ACCOUNT) &&
26679 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
26680 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
26681 + !vx_vmpages_avail(mm, vma_pages(vma))))
26683 vma_link(mm, vma, prev, rb_link, rb_parent);
26685 @@ -2234,6 +2250,8 @@ int may_expand_vm(struct mm_struct *mm,
26687 if (cur + npages > lim)
26689 + if (!vx_vmpages_avail(mm, npages))
26694 @@ -2311,7 +2329,7 @@ int install_special_mapping(struct mm_st
26698 - mm->total_vm += len >> PAGE_SHIFT;
26699 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26701 perf_event_mmap(vma);
26703 diff -NurpP --minimal linux-2.6.32.24/mm/mremap.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/mremap.c
26704 --- linux-2.6.32.24/mm/mremap.c 2010-10-04 08:56:18.000000000 +0200
26705 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/mremap.c 2010-01-20 04:28:22.000000000 +0100
26707 #include <linux/security.h>
26708 #include <linux/syscalls.h>
26709 #include <linux/mmu_notifier.h>
26710 +#include <linux/vs_memory.h>
26712 #include <asm/uaccess.h>
26713 #include <asm/cacheflush.h>
26714 @@ -234,7 +235,7 @@ static unsigned long move_vma(struct vm_
26715 * If this were a serious issue, we'd add a flag to do_munmap().
26717 hiwater_vm = mm->hiwater_vm;
26718 - mm->total_vm += new_len >> PAGE_SHIFT;
26719 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
26720 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
26722 if (do_munmap(mm, old_addr, old_len) < 0) {
26723 @@ -252,7 +253,7 @@ static unsigned long move_vma(struct vm_
26726 if (vm_flags & VM_LOCKED) {
26727 - mm->locked_vm += new_len >> PAGE_SHIFT;
26728 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
26729 if (new_len > old_len)
26730 mlock_vma_pages_range(new_vma, new_addr + old_len,
26731 new_addr + new_len);
26732 @@ -463,10 +464,12 @@ unsigned long do_mremap(unsigned long ad
26733 vma_adjust(vma, vma->vm_start,
26734 addr + new_len, vma->vm_pgoff, NULL);
26736 - mm->total_vm += pages;
26737 + // mm->total_vm += pages;
26738 + vx_vmpages_add(mm, pages);
26739 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
26740 if (vma->vm_flags & VM_LOCKED) {
26741 - mm->locked_vm += pages;
26742 + // mm->locked_vm += pages;
26743 + vx_vmlocked_add(mm, pages);
26744 mlock_vma_pages_range(vma, addr + old_len,
26747 diff -NurpP --minimal linux-2.6.32.24/mm/nommu.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/nommu.c
26748 --- linux-2.6.32.24/mm/nommu.c 2010-10-04 08:56:18.000000000 +0200
26749 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/nommu.c 2010-09-05 21:24:17.000000000 +0200
26750 @@ -1349,7 +1349,7 @@ unsigned long do_mmap_pgoff(struct file
26751 /* okay... we have a mapping; now we have to register it */
26752 result = vma->vm_start;
26754 - current->mm->total_vm += len >> PAGE_SHIFT;
26755 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
26758 add_vma_to_mm(current->mm, vma);
26759 @@ -1609,7 +1609,7 @@ void exit_mmap(struct mm_struct *mm)
26763 - mm->total_vm = 0;
26764 + vx_vmpages_sub(mm, mm->total_vm);
26766 while ((vma = mm->mmap)) {
26767 mm->mmap = vma->vm_next;
26768 diff -NurpP --minimal linux-2.6.32.24/mm/oom_kill.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/oom_kill.c
26769 --- linux-2.6.32.24/mm/oom_kill.c 2010-10-04 08:56:18.000000000 +0200
26770 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/oom_kill.c 2010-03-18 16:53:06.000000000 +0100
26772 #include <linux/notifier.h>
26773 #include <linux/memcontrol.h>
26774 #include <linux/security.h>
26775 +#include <linux/reboot.h>
26776 +#include <linux/vs_memory.h>
26777 +#include <linux/vs_context.h>
26779 int sysctl_panic_on_oom;
26780 int sysctl_oom_kill_allocating_task;
26781 @@ -186,9 +189,21 @@ unsigned long badness(struct task_struct
26782 points >>= -(oom_adj);
26786 + * add points for context badness and
26787 + * reduce badness for processes belonging to
26788 + * a different context
26791 + points += vx_badness(p, mm);
26793 + if ((vx_current_xid() > 1) &&
26794 + vx_current_xid() != vx_task_xid(p))
26798 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26799 - p->pid, p->comm, points);
26800 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26801 + task_pid_nr(p), p->xid, p->comm, points);
26805 @@ -230,6 +245,7 @@ static struct task_struct *select_bad_pr
26806 struct task_struct *p;
26807 struct task_struct *chosen = NULL;
26808 struct timespec uptime;
26809 + unsigned xid = vx_current_xid();
26812 do_posix_clock_monotonic_gettime(&uptime);
26813 @@ -242,11 +258,14 @@ static struct task_struct *select_bad_pr
26817 - /* skip the init task */
26818 - if (is_global_init(p))
26819 + /* skip the init task, global and per guest */
26820 + if (task_is_init(p))
26822 if (mem && !task_in_mem_cgroup(p, mem))
26824 + /* skip other guest and host processes if oom in guest */
26825 + if (xid && vx_task_xid(p) != xid)
26829 * This task already has access to memory reserves and is
26830 @@ -357,8 +376,8 @@ static void __oom_kill_task(struct task_
26834 - printk(KERN_ERR "Killed process %d (%s)\n",
26835 - task_pid_nr(p), p->comm);
26836 + printk(KERN_ERR "Killed process %s(%d:#%u)\n",
26837 + p->comm, task_pid_nr(p), p->xid);
26840 * We give our sacrificial lamb high priority and access to
26841 @@ -419,8 +438,8 @@ static int oom_kill_process(struct task_
26845 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26846 - message, task_pid_nr(p), p->comm, points);
26847 + printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
26848 + message, p->comm, task_pid_nr(p), p->xid, points);
26850 /* Try to kill a child first */
26851 list_for_each_entry(c, &p->children, sibling) {
26852 @@ -521,6 +540,8 @@ void clear_zonelist_oom(struct zonelist
26853 spin_unlock(&zone_scan_lock);
26856 +long vs_oom_action(unsigned int);
26859 * Must be called with tasklist_lock held for read.
26861 @@ -546,7 +567,11 @@ retry:
26862 /* Found nothing?!?! Either we hang forever, or we panic. */
26864 read_unlock(&tasklist_lock);
26865 - panic("Out of memory and no killable processes...\n");
26866 + /* avoid panic for guest OOM */
26867 + if (current->xid)
26868 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
26870 + panic("Out of memory and no killable processes...\n");
26873 if (oom_kill_process(p, gfp_mask, order, points, NULL,
26874 diff -NurpP --minimal linux-2.6.32.24/mm/page_alloc.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/page_alloc.c
26875 --- linux-2.6.32.24/mm/page_alloc.c 2010-10-04 08:56:18.000000000 +0200
26876 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/page_alloc.c 2010-10-04 10:04:57.000000000 +0200
26878 #include <linux/page_cgroup.h>
26879 #include <linux/debugobjects.h>
26880 #include <linux/kmemleak.h>
26881 +#include <linux/vs_base.h>
26882 +#include <linux/vs_limit.h>
26883 #include <trace/events/kmem.h>
26885 #include <asm/tlbflush.h>
26886 @@ -2144,6 +2146,9 @@ void si_meminfo(struct sysinfo *val)
26887 val->totalhigh = totalhigh_pages;
26888 val->freehigh = nr_free_highpages();
26889 val->mem_unit = PAGE_SIZE;
26891 + if (vx_flags(VXF_VIRT_MEM, 0))
26892 + vx_vsi_meminfo(val);
26895 EXPORT_SYMBOL(si_meminfo);
26896 @@ -2164,6 +2169,9 @@ void si_meminfo_node(struct sysinfo *val
26899 val->mem_unit = PAGE_SIZE;
26901 + if (vx_flags(VXF_VIRT_MEM, 0))
26902 + vx_vsi_meminfo(val);
26906 diff -NurpP --minimal linux-2.6.32.24/mm/rmap.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/rmap.c
26907 --- linux-2.6.32.24/mm/rmap.c 2009-12-03 20:02:58.000000000 +0100
26908 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/rmap.c 2009-12-03 20:04:56.000000000 +0100
26910 #include <linux/memcontrol.h>
26911 #include <linux/mmu_notifier.h>
26912 #include <linux/migrate.h>
26913 +#include <linux/vs_memory.h>
26915 #include <asm/tlbflush.h>
26917 diff -NurpP --minimal linux-2.6.32.24/mm/shmem.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/shmem.c
26918 --- linux-2.6.32.24/mm/shmem.c 2009-12-03 20:02:58.000000000 +0100
26919 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/shmem.c 2009-12-03 20:04:56.000000000 +0100
26920 @@ -1781,7 +1781,7 @@ static int shmem_statfs(struct dentry *d
26922 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26924 - buf->f_type = TMPFS_MAGIC;
26925 + buf->f_type = TMPFS_SUPER_MAGIC;
26926 buf->f_bsize = PAGE_CACHE_SIZE;
26927 buf->f_namelen = NAME_MAX;
26928 spin_lock(&sbinfo->stat_lock);
26929 @@ -2346,7 +2346,7 @@ int shmem_fill_super(struct super_block
26930 sb->s_maxbytes = SHMEM_MAX_BYTES;
26931 sb->s_blocksize = PAGE_CACHE_SIZE;
26932 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26933 - sb->s_magic = TMPFS_MAGIC;
26934 + sb->s_magic = TMPFS_SUPER_MAGIC;
26935 sb->s_op = &shmem_ops;
26936 sb->s_time_gran = 1;
26937 #ifdef CONFIG_TMPFS_POSIX_ACL
26938 diff -NurpP --minimal linux-2.6.32.24/mm/slab.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/slab.c
26939 --- linux-2.6.32.24/mm/slab.c 2010-10-04 08:56:18.000000000 +0200
26940 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/slab.c 2010-09-05 21:24:17.000000000 +0200
26941 @@ -431,6 +431,8 @@ static void kmem_list3_init(struct kmem_
26942 #define STATS_INC_FREEMISS(x) do { } while (0)
26945 +#include "slab_vs.h"
26950 @@ -3251,6 +3253,7 @@ retry:
26952 obj = slab_get_obj(cachep, slabp, nodeid);
26953 check_slabp(cachep, slabp);
26954 + vx_slab_alloc(cachep, flags);
26955 l3->free_objects--;
26956 /* move slabp to correct slabp list: */
26957 list_del(&slabp->list);
26958 @@ -3327,6 +3330,7 @@ __cache_alloc_node(struct kmem_cache *ca
26959 /* ___cache_alloc_node can fall back to other nodes */
26960 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26962 + vx_slab_alloc(cachep, flags);
26963 local_irq_restore(save_flags);
26964 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26965 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26966 @@ -3513,6 +3517,7 @@ static inline void __cache_free(struct k
26968 kmemleak_free_recursive(objp, cachep->flags);
26969 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26970 + vx_slab_free(cachep);
26972 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26974 diff -NurpP --minimal linux-2.6.32.24/mm/slab_vs.h linux-2.6.32.24-vs2.3.0.36.29.6/mm/slab_vs.h
26975 --- linux-2.6.32.24/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26976 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/slab_vs.h 2009-12-03 20:04:56.000000000 +0100
26979 +#include <linux/vserver/context.h>
26981 +#include <linux/vs_context.h>
26984 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26986 + int what = gfp_zone(cachep->gfpflags);
26987 + struct vx_info *vxi = current_vx_info();
26992 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26996 +void vx_slab_free(struct kmem_cache *cachep)
26998 + int what = gfp_zone(cachep->gfpflags);
26999 + struct vx_info *vxi = current_vx_info();
27004 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
27007 diff -NurpP --minimal linux-2.6.32.24/mm/swapfile.c linux-2.6.32.24-vs2.3.0.36.29.6/mm/swapfile.c
27008 --- linux-2.6.32.24/mm/swapfile.c 2010-10-04 08:56:18.000000000 +0200
27009 +++ linux-2.6.32.24-vs2.3.0.36.29.6/mm/swapfile.c 2010-08-19 17:35:34.000000000 +0200
27011 #include <asm/tlbflush.h>
27012 #include <linux/swapops.h>
27013 #include <linux/page_cgroup.h>
27014 +#include <linux/vs_base.h>
27015 +#include <linux/vs_memory.h>
27017 static DEFINE_SPINLOCK(swap_lock);
27018 static unsigned int nr_swapfiles;
27019 @@ -1682,6 +1684,8 @@ static void *swap_next(struct seq_file *
27020 if (v == SEQ_START_TOKEN)
27023 + if (vx_flags(VXF_VIRT_MEM, 0))
27028 @@ -1709,6 +1713,16 @@ static int swap_show(struct seq_file *sw
27030 if (ptr == SEQ_START_TOKEN) {
27031 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
27032 + if (vx_flags(VXF_VIRT_MEM, 0)) {
27033 + struct sysinfo si;
27035 + vx_vsi_swapinfo(&si);
27036 + if (si.totalswap < (1 << 10))
27038 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
27039 + "hdv0", "partition", si.totalswap >> 10,
27040 + (si.totalswap - si.freeswap) >> 10, -1);
27045 @@ -2066,6 +2080,8 @@ void si_swapinfo(struct sysinfo *val)
27046 val->freeswap = nr_swap_pages + nr_to_be_unused;
27047 val->totalswap = total_swap_pages + nr_to_be_unused;
27048 spin_unlock(&swap_lock);
27049 + if (vx_flags(VXF_VIRT_MEM, 0))
27050 + vx_vsi_swapinfo(val);
27054 diff -NurpP --minimal linux-2.6.32.24/net/core/dev.c linux-2.6.32.24-vs2.3.0.36.29.6/net/core/dev.c
27055 --- linux-2.6.32.24/net/core/dev.c 2010-10-04 08:56:19.000000000 +0200
27056 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/core/dev.c 2010-09-05 21:24:17.000000000 +0200
27057 @@ -126,6 +126,7 @@
27058 #include <linux/in.h>
27059 #include <linux/jhash.h>
27060 #include <linux/random.h>
27061 +#include <linux/vs_inet.h>
27062 #include <trace/events/napi.h>
27064 #include "net-sysfs.h"
27065 @@ -591,7 +592,8 @@ struct net_device *__dev_get_by_name(str
27066 hlist_for_each(p, dev_name_hash(net, name)) {
27067 struct net_device *dev
27068 = hlist_entry(p, struct net_device, name_hlist);
27069 - if (!strncmp(dev->name, name, IFNAMSIZ))
27070 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
27071 + nx_dev_visible(current_nx_info(), dev))
27075 @@ -642,7 +644,8 @@ struct net_device *__dev_get_by_index(st
27076 hlist_for_each(p, dev_index_hash(net, ifindex)) {
27077 struct net_device *dev
27078 = hlist_entry(p, struct net_device, index_hlist);
27079 - if (dev->ifindex == ifindex)
27080 + if ((dev->ifindex == ifindex) &&
27081 + nx_dev_visible(current_nx_info(), dev))
27085 @@ -695,10 +698,12 @@ struct net_device *dev_getbyhwaddr(struc
27089 - for_each_netdev(net, dev)
27090 + for_each_netdev(net, dev) {
27091 if (dev->type == type &&
27092 - !memcmp(dev->dev_addr, ha, dev->addr_len))
27093 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
27094 + nx_dev_visible(current_nx_info(), dev))
27100 @@ -709,9 +714,11 @@ struct net_device *__dev_getfirstbyhwtyp
27101 struct net_device *dev;
27104 - for_each_netdev(net, dev)
27105 - if (dev->type == type)
27106 + for_each_netdev(net, dev) {
27107 + if ((dev->type == type) &&
27108 + nx_dev_visible(current_nx_info(), dev))
27114 @@ -830,6 +837,8 @@ static int __dev_alloc_name(struct net *
27116 if (i < 0 || i >= max_netdevices)
27118 + if (!nx_dev_visible(current_nx_info(), d))
27121 /* avoid cases where sscanf is not exact inverse of printf */
27122 snprintf(buf, IFNAMSIZ, name, i);
27123 @@ -2984,6 +2993,8 @@ static int dev_ifconf(struct net *net, c
27126 for_each_netdev(net, dev) {
27127 + if (!nx_dev_visible(current_nx_info(), dev))
27129 for (i = 0; i < NPROTO; i++) {
27130 if (gifconf_list[i]) {
27132 @@ -3052,6 +3063,9 @@ static void dev_seq_printf_stats(struct
27134 const struct net_device_stats *stats = dev_get_stats(dev);
27136 + if (!nx_dev_visible(current_nx_info(), dev))
27139 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
27140 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
27141 dev->name, stats->rx_bytes, stats->rx_packets,
27142 @@ -5317,7 +5331,6 @@ int dev_change_net_namespace(struct net_
27143 if (dev->dev.parent)
27147 /* Ensure the device has been registrered */
27149 if (dev->reg_state != NETREG_REGISTERED)
27150 diff -NurpP --minimal linux-2.6.32.24/net/core/rtnetlink.c linux-2.6.32.24-vs2.3.0.36.29.6/net/core/rtnetlink.c
27151 --- linux-2.6.32.24/net/core/rtnetlink.c 2010-10-04 08:56:19.000000000 +0200
27152 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/core/rtnetlink.c 2009-12-29 00:36:26.000000000 +0100
27153 @@ -688,6 +688,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
27156 for_each_netdev(net, dev) {
27157 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
27161 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
27162 @@ -1222,6 +1224,9 @@ void rtmsg_ifinfo(int type, struct net_d
27163 struct sk_buff *skb;
27164 int err = -ENOBUFS;
27166 + if (!nx_dev_visible(current_nx_info(), dev))
27169 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
27172 diff -NurpP --minimal linux-2.6.32.24/net/core/sock.c linux-2.6.32.24-vs2.3.0.36.29.6/net/core/sock.c
27173 --- linux-2.6.32.24/net/core/sock.c 2010-10-04 08:56:19.000000000 +0200
27174 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/core/sock.c 2010-02-12 10:59:55.000000000 +0100
27175 @@ -125,6 +125,10 @@
27176 #include <linux/ipsec.h>
27178 #include <linux/filter.h>
27179 +#include <linux/vs_socket.h>
27180 +#include <linux/vs_limit.h>
27181 +#include <linux/vs_context.h>
27182 +#include <linux/vs_network.h>
27185 #include <net/tcp.h>
27186 @@ -984,6 +988,8 @@ static struct sock *sk_prot_alloc(struct
27187 if (!try_module_get(prot->owner))
27190 + sock_vx_init(sk);
27191 + sock_nx_init(sk);
27195 @@ -1063,6 +1069,11 @@ static void __sk_free(struct sock *sk)
27196 __func__, atomic_read(&sk->sk_omem_alloc));
27198 put_net(sock_net(sk));
27200 + clr_vx_info(&sk->sk_vx_info);
27202 + clr_nx_info(&sk->sk_nx_info);
27204 sk_prot_free(sk->sk_prot_creator, sk);
27207 @@ -1110,6 +1121,8 @@ struct sock *sk_clone(const struct sock
27210 get_net(sock_net(newsk));
27211 + sock_vx_init(newsk);
27212 + sock_nx_init(newsk);
27213 sk_node_init(&newsk->sk_node);
27214 sock_lock_init(newsk);
27215 bh_lock_sock(newsk);
27216 @@ -1164,6 +1177,12 @@ struct sock *sk_clone(const struct sock
27218 atomic_set(&newsk->sk_refcnt, 2);
27220 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
27221 + newsk->sk_xid = sk->sk_xid;
27222 + vx_sock_inc(newsk);
27223 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
27224 + newsk->sk_nid = sk->sk_nid;
27227 * Increment the counter in the same struct proto as the master
27228 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
27229 @@ -1886,6 +1905,12 @@ void sock_init_data(struct socket *sock,
27231 sk->sk_stamp = ktime_set(-1L, 0);
27233 + set_vx_info(&sk->sk_vx_info, current_vx_info());
27234 + sk->sk_xid = vx_current_xid();
27236 + set_nx_info(&sk->sk_nx_info, current_nx_info());
27237 + sk->sk_nid = nx_current_nid();
27240 * Before updating sk_refcnt, we must commit prior changes to memory
27241 * (Documentation/RCU/rculist_nulls.txt for details)
27242 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/af_inet.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/af_inet.c
27243 --- linux-2.6.32.24/net/ipv4/af_inet.c 2009-12-03 20:02:59.000000000 +0100
27244 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/af_inet.c 2009-12-03 20:04:56.000000000 +0100
27245 @@ -115,6 +115,7 @@
27246 #ifdef CONFIG_IP_MROUTE
27247 #include <linux/mroute.h>
27249 +#include <linux/vs_limit.h>
27252 /* The inetsw table contains everything that inet_create needs to
27253 @@ -325,9 +326,12 @@ lookup_protocol:
27257 + if ((protocol == IPPROTO_ICMP) &&
27258 + nx_capable(answer->capability, NXC_RAW_ICMP))
27260 if (answer->capability > 0 && !capable(answer->capability))
27261 goto out_rcu_unlock;
27264 err = -EAFNOSUPPORT;
27265 if (!inet_netns_ok(net, protocol))
27266 goto out_rcu_unlock;
27267 @@ -447,6 +451,7 @@ int inet_bind(struct socket *sock, struc
27268 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
27269 struct sock *sk = sock->sk;
27270 struct inet_sock *inet = inet_sk(sk);
27271 + struct nx_v4_sock_addr nsa;
27272 unsigned short snum;
27275 @@ -460,7 +465,11 @@ int inet_bind(struct socket *sock, struc
27276 if (addr_len < sizeof(struct sockaddr_in))
27279 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27280 + err = v4_map_sock_addr(inet, addr, &nsa);
27284 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27286 /* Not specified by any standard per-se, however it breaks too
27287 * many applications when removed. It is unfortunate since
27288 @@ -472,7 +481,7 @@ int inet_bind(struct socket *sock, struc
27289 err = -EADDRNOTAVAIL;
27290 if (!sysctl_ip_nonlocal_bind &&
27291 !(inet->freebind || inet->transparent) &&
27292 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
27293 + nsa.saddr != htonl(INADDR_ANY) &&
27294 chk_addr_ret != RTN_LOCAL &&
27295 chk_addr_ret != RTN_MULTICAST &&
27296 chk_addr_ret != RTN_BROADCAST)
27297 @@ -497,7 +506,7 @@ int inet_bind(struct socket *sock, struc
27298 if (sk->sk_state != TCP_CLOSE || inet->num)
27299 goto out_release_sock;
27301 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
27302 + v4_set_sock_addr(inet, &nsa);
27303 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27304 inet->saddr = 0; /* Use device */
27306 @@ -694,11 +703,13 @@ int inet_getname(struct socket *sock, st
27309 sin->sin_port = inet->dport;
27310 - sin->sin_addr.s_addr = inet->daddr;
27311 + sin->sin_addr.s_addr =
27312 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
27314 __be32 addr = inet->rcv_saddr;
27316 addr = inet->saddr;
27317 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
27318 sin->sin_port = inet->sport;
27319 sin->sin_addr.s_addr = addr;
27321 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/devinet.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/devinet.c
27322 --- linux-2.6.32.24/net/ipv4/devinet.c 2010-10-04 08:56:19.000000000 +0200
27323 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/devinet.c 2010-08-19 17:35:34.000000000 +0200
27324 @@ -413,6 +413,7 @@ struct in_device *inetdev_by_index(struc
27329 /* Called only from RTNL semaphored context. No locks. */
27331 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
27332 @@ -653,6 +654,8 @@ int devinet_ioctl(struct net *net, unsig
27335 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
27336 + struct nx_info *nxi = current_nx_info();
27338 if (tryaddrmatch) {
27339 /* Matthias Andree */
27340 /* compare label and address (4.4BSD style) */
27341 @@ -661,6 +664,8 @@ int devinet_ioctl(struct net *net, unsig
27342 This is checked above. */
27343 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27344 ifap = &ifa->ifa_next) {
27345 + if (!nx_v4_ifa_visible(nxi, ifa))
27347 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
27348 sin_orig.sin_addr.s_addr ==
27349 ifa->ifa_address) {
27350 @@ -673,9 +678,12 @@ int devinet_ioctl(struct net *net, unsig
27351 comparing just the label */
27353 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27354 - ifap = &ifa->ifa_next)
27355 + ifap = &ifa->ifa_next) {
27356 + if (!nx_v4_ifa_visible(nxi, ifa))
27358 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
27364 @@ -826,6 +834,8 @@ static int inet_gifconf(struct net_devic
27367 for (; ifa; ifa = ifa->ifa_next) {
27368 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
27371 done += sizeof(ifr);
27373 @@ -1175,6 +1185,7 @@ static int inet_dump_ifaddr(struct sk_bu
27374 struct net_device *dev;
27375 struct in_device *in_dev;
27376 struct in_ifaddr *ifa;
27377 + struct sock *sk = skb->sk;
27378 int s_ip_idx, s_idx = cb->args[0];
27380 s_ip_idx = ip_idx = cb->args[1];
27381 @@ -1189,6 +1200,8 @@ static int inet_dump_ifaddr(struct sk_bu
27383 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
27384 ifa = ifa->ifa_next, ip_idx++) {
27385 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
27387 if (ip_idx < s_ip_idx)
27389 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
27390 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/fib_hash.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/fib_hash.c
27391 --- linux-2.6.32.24/net/ipv4/fib_hash.c 2009-09-10 15:26:29.000000000 +0200
27392 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/fib_hash.c 2009-12-03 20:04:56.000000000 +0100
27393 @@ -1021,7 +1021,7 @@ static int fib_seq_show(struct seq_file
27394 prefix = f->fn_key;
27395 mask = FZ_MASK(iter->zone);
27396 flags = fib_flag_trans(fa->fa_type, mask, fi);
27398 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
27400 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
27401 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27402 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/inet_connection_sock.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/inet_connection_sock.c
27403 --- linux-2.6.32.24/net/ipv4/inet_connection_sock.c 2009-12-03 20:02:59.000000000 +0100
27404 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/inet_connection_sock.c 2009-12-03 20:04:56.000000000 +0100
27405 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
27407 EXPORT_SYMBOL(inet_get_local_port_range);
27409 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27411 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
27412 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
27414 + if (inet_v6_ipv6only(sk2))
27417 + if (sk1_rcv_saddr &&
27419 + sk1_rcv_saddr == sk2_rcv_saddr)
27422 + if (sk1_rcv_saddr &&
27423 + !sk2_rcv_saddr &&
27424 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
27427 + if (sk2_rcv_saddr &&
27428 + !sk1_rcv_saddr &&
27429 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
27432 + if (!sk1_rcv_saddr &&
27433 + !sk2_rcv_saddr &&
27434 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
27440 int inet_csk_bind_conflict(const struct sock *sk,
27441 const struct inet_bind_bucket *tb)
27443 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27445 struct hlist_node *node;
27446 int reuse = sk->sk_reuse;
27447 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct
27448 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27449 if (!reuse || !sk2->sk_reuse ||
27450 sk2->sk_state == TCP_LISTEN) {
27451 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27452 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27453 - sk2_rcv_saddr == sk_rcv_saddr)
27454 + if (ipv4_rcv_saddr_equal(sk, sk2))
27458 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/inet_diag.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/inet_diag.c
27459 --- linux-2.6.32.24/net/ipv4/inet_diag.c 2009-09-10 15:26:29.000000000 +0200
27460 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/inet_diag.c 2009-12-03 20:04:56.000000000 +0100
27462 #include <linux/stddef.h>
27464 #include <linux/inet_diag.h>
27465 +#include <linux/vs_network.h>
27466 +#include <linux/vs_inet.h>
27468 static const struct inet_diag_handler **inet_diag_table;
27470 @@ -118,8 +120,8 @@ static int inet_csk_diag_fill(struct soc
27472 r->id.idiag_sport = inet->sport;
27473 r->id.idiag_dport = inet->dport;
27474 - r->id.idiag_src[0] = inet->rcv_saddr;
27475 - r->id.idiag_dst[0] = inet->daddr;
27476 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
27477 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
27479 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27480 if (r->idiag_family == AF_INET6) {
27481 @@ -204,8 +206,8 @@ static int inet_twsk_diag_fill(struct in
27482 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27483 r->id.idiag_sport = tw->tw_sport;
27484 r->id.idiag_dport = tw->tw_dport;
27485 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
27486 - r->id.idiag_dst[0] = tw->tw_daddr;
27487 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27488 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27489 r->idiag_state = tw->tw_substate;
27490 r->idiag_timer = 3;
27491 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
27492 @@ -262,6 +264,7 @@ static int inet_diag_get_exact(struct sk
27495 if (req->idiag_family == AF_INET) {
27496 + /* TODO: lback */
27497 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27498 req->id.idiag_dport, req->id.idiag_src[0],
27499 req->id.idiag_sport, req->id.idiag_if);
27500 @@ -504,6 +507,7 @@ static int inet_csk_diag_dump(struct soc
27504 + /* TODO: lback */
27505 entry.saddr = &inet->rcv_saddr;
27506 entry.daddr = &inet->daddr;
27508 @@ -540,6 +544,7 @@ static int inet_twsk_diag_dump(struct in
27512 + /* TODO: lback */
27513 entry.saddr = &tw->tw_rcv_saddr;
27514 entry.daddr = &tw->tw_daddr;
27516 @@ -586,8 +591,8 @@ static int inet_diag_fill_req(struct sk_
27518 r->id.idiag_sport = inet->sport;
27519 r->id.idiag_dport = ireq->rmt_port;
27520 - r->id.idiag_src[0] = ireq->loc_addr;
27521 - r->id.idiag_dst[0] = ireq->rmt_addr;
27522 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
27523 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
27524 r->idiag_expires = jiffies_to_msecs(tmo);
27525 r->idiag_rqueue = 0;
27526 r->idiag_wqueue = 0;
27527 @@ -657,6 +662,7 @@ static int inet_diag_dump_reqs(struct sk
27531 + /* TODO: lback */
27533 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27534 (entry.family == AF_INET6) ?
27535 @@ -727,6 +733,8 @@ static int inet_diag_dump(struct sk_buff
27536 sk_nulls_for_each(sk, node, &ilb->head) {
27537 struct inet_sock *inet = inet_sk(sk);
27539 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27544 @@ -793,6 +801,8 @@ skip_listen_ht:
27545 sk_nulls_for_each(sk, node, &head->chain) {
27546 struct inet_sock *inet = inet_sk(sk);
27548 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27552 if (!(r->idiag_states & (1 << sk->sk_state)))
27553 @@ -817,6 +827,8 @@ next_normal:
27554 inet_twsk_for_each(tw, node,
27557 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27561 if (r->id.idiag_sport != tw->tw_sport &&
27562 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/inet_hashtables.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/inet_hashtables.c
27563 --- linux-2.6.32.24/net/ipv4/inet_hashtables.c 2009-06-11 17:13:29.000000000 +0200
27564 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/inet_hashtables.c 2009-12-03 20:04:56.000000000 +0100
27567 #include <net/inet_connection_sock.h>
27568 #include <net/inet_hashtables.h>
27569 +#include <net/route.h>
27570 #include <net/ip.h>
27573 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
27574 if (rcv_saddr != daddr)
27578 + /* block non nx_info ips */
27579 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27580 + daddr, NXA_MASK_BIND))
27583 if (sk->sk_bound_dev_if) {
27584 if (sk->sk_bound_dev_if != dif)
27585 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
27586 * wildcarded during the search since they can never be otherwise.
27590 struct sock *__inet_lookup_listener(struct net *net,
27591 struct inet_hashinfo *hashinfo,
27592 const __be32 daddr, const unsigned short hnum,
27593 @@ -174,6 +179,7 @@ begin:
27599 * if the nulls value we got at the end of this lookup is
27600 * not the expected one, we must restart lookup.
27601 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/netfilter/nf_nat_helper.c
27602 --- linux-2.6.32.24/net/ipv4/netfilter/nf_nat_helper.c 2009-12-03 20:02:59.000000000 +0100
27603 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/netfilter/nf_nat_helper.c 2009-12-03 20:04:56.000000000 +0100
27605 #include <net/route.h>
27607 #include <linux/netfilter_ipv4.h>
27608 +#include <net/route.h>
27609 #include <net/netfilter/nf_conntrack.h>
27610 #include <net/netfilter/nf_conntrack_helper.h>
27611 #include <net/netfilter/nf_conntrack_ecache.h>
27612 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/netfilter.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/netfilter.c
27613 --- linux-2.6.32.24/net/ipv4/netfilter.c 2009-09-10 15:26:29.000000000 +0200
27614 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/netfilter.c 2009-12-03 20:04:56.000000000 +0100
27616 #include <linux/netfilter_ipv4.h>
27617 #include <linux/ip.h>
27618 #include <linux/skbuff.h>
27619 -#include <net/route.h>
27620 +// #include <net/route.h>
27621 #include <net/xfrm.h>
27622 #include <net/ip.h>
27623 #include <net/netfilter/nf_queue.h>
27624 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/raw.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/raw.c
27625 --- linux-2.6.32.24/net/ipv4/raw.c 2009-12-03 20:02:59.000000000 +0100
27626 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/raw.c 2009-12-03 20:04:56.000000000 +0100
27627 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
27629 if (net_eq(sock_net(sk), net) && inet->num == num &&
27630 !(inet->daddr && inet->daddr != raddr) &&
27631 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
27632 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
27633 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27634 goto found; /* gotcha */
27636 @@ -383,6 +383,12 @@ static int raw_send_hdrinc(struct sock *
27637 icmp_out_count(net, ((struct icmphdr *)
27638 skb_transport_header(skb))->type);
27641 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27642 + sk->sk_nx_info &&
27643 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27646 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
27649 @@ -563,6 +569,13 @@ static int raw_sendmsg(struct kiocb *ioc
27652 security_sk_classify_flow(sk, &fl);
27653 + if (sk->sk_nx_info) {
27654 + err = ip_v4_find_src(sock_net(sk),
27655 + sk->sk_nx_info, &rt, &fl);
27660 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27663 @@ -635,17 +648,19 @@ static int raw_bind(struct sock *sk, str
27665 struct inet_sock *inet = inet_sk(sk);
27666 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27667 + struct nx_v4_sock_addr nsa = { 0 };
27671 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27673 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27674 + v4_map_sock_addr(inet, addr, &nsa);
27675 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27676 ret = -EADDRNOTAVAIL;
27677 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27678 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27679 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27681 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
27682 + v4_set_sock_addr(inet, &nsa);
27683 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27684 inet->saddr = 0; /* Use device */
27686 @@ -697,7 +712,8 @@ static int raw_recvmsg(struct kiocb *ioc
27687 /* Copy the address. */
27689 sin->sin_family = AF_INET;
27690 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27691 + sin->sin_addr.s_addr =
27692 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27694 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27696 @@ -875,7 +891,8 @@ static struct sock *raw_get_first(struct
27697 struct hlist_node *node;
27699 sk_for_each(sk, node, &state->h->ht[state->bucket])
27700 - if (sock_net(sk) == seq_file_net(seq))
27701 + if ((sock_net(sk) == seq_file_net(seq)) &&
27702 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27706 @@ -891,7 +908,8 @@ static struct sock *raw_get_next(struct
27710 - } while (sk && sock_net(sk) != seq_file_net(seq));
27711 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27712 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27714 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27715 sk = sk_head(&state->h->ht[state->bucket]);
27716 @@ -950,7 +968,10 @@ static void raw_sock_seq_show(struct seq
27718 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27719 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27720 - i, src, srcp, dest, destp, sp->sk_state,
27722 + nx_map_sock_lback(current_nx_info(), src), srcp,
27723 + nx_map_sock_lback(current_nx_info(), dest), destp,
27725 sk_wmem_alloc_get(sp),
27726 sk_rmem_alloc_get(sp),
27727 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27728 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/tcp.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/tcp.c
27729 --- linux-2.6.32.24/net/ipv4/tcp.c 2010-10-04 08:56:19.000000000 +0200
27730 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/tcp.c 2010-10-04 10:04:57.000000000 +0200
27731 @@ -264,6 +264,7 @@
27732 #include <linux/cache.h>
27733 #include <linux/err.h>
27734 #include <linux/crypto.h>
27735 +#include <linux/in.h>
27737 #include <net/icmp.h>
27738 #include <net/tcp.h>
27739 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/tcp_ipv4.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/tcp_ipv4.c
27740 --- linux-2.6.32.24/net/ipv4/tcp_ipv4.c 2009-12-03 20:03:00.000000000 +0100
27741 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/tcp_ipv4.c 2009-12-03 20:04:56.000000000 +0100
27742 @@ -1925,6 +1925,12 @@ static void *listening_get_next(struct s
27743 req = req->dl_next;
27746 + vxdprintk(VXD_CBIT(net, 6),
27747 + "sk,req: %p [#%d] (from %d)", req->sk,
27748 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27750 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27752 if (req->rsk_ops->family == st->family) {
27755 @@ -1949,6 +1955,10 @@ get_req:
27758 sk_nulls_for_each_from(sk, node) {
27759 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27760 + sk, sk->sk_nid, nx_current_nid());
27761 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27763 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27766 @@ -2012,6 +2022,11 @@ static void *established_get_first(struc
27768 spin_lock_bh(lock);
27769 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27770 + vxdprintk(VXD_CBIT(net, 6),
27771 + "sk,egf: %p [#%d] (from %d)",
27772 + sk, sk->sk_nid, nx_current_nid());
27773 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27775 if (sk->sk_family != st->family ||
27776 !net_eq(sock_net(sk), net)) {
27778 @@ -2022,6 +2037,11 @@ static void *established_get_first(struc
27779 st->state = TCP_SEQ_STATE_TIME_WAIT;
27780 inet_twsk_for_each(tw, node,
27781 &tcp_hashinfo.ehash[st->bucket].twchain) {
27782 + vxdprintk(VXD_CBIT(net, 6),
27783 + "tw: %p [#%d] (from %d)",
27784 + tw, tw->tw_nid, nx_current_nid());
27785 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27787 if (tw->tw_family != st->family ||
27788 !net_eq(twsk_net(tw), net)) {
27790 @@ -2050,7 +2070,9 @@ static void *established_get_next(struct
27794 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27795 + while (tw && (tw->tw_family != st->family ||
27796 + !net_eq(twsk_net(tw), net) ||
27797 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27801 @@ -2073,6 +2095,11 @@ get_tw:
27802 sk = sk_nulls_next(sk);
27804 sk_nulls_for_each_from(sk, node) {
27805 + vxdprintk(VXD_CBIT(net, 6),
27806 + "sk,egn: %p [#%d] (from %d)",
27807 + sk, sk->sk_nid, nx_current_nid());
27808 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27810 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27813 @@ -2224,9 +2251,9 @@ static void get_openreq4(struct sock *sk
27814 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27815 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27818 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27819 ntohs(inet_sk(sk)->sport),
27821 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27822 ntohs(ireq->rmt_port),
27824 0, 0, /* could print option size, but that is af dependent. */
27825 @@ -2269,7 +2296,10 @@ static void get_tcp4_sock(struct sock *s
27827 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27828 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27829 - i, src, srcp, dest, destp, sk->sk_state,
27831 + nx_map_sock_lback(current_nx_info(), src), srcp,
27832 + nx_map_sock_lback(current_nx_info(), dest), destp,
27834 tp->write_seq - tp->snd_una,
27835 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
27836 (tp->rcv_nxt - tp->copied_seq),
27837 @@ -2305,7 +2335,10 @@ static void get_timewait4_sock(struct in
27839 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27840 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27841 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27843 + nx_map_sock_lback(current_nx_info(), src), srcp,
27844 + nx_map_sock_lback(current_nx_info(), dest), destp,
27845 + tw->tw_substate, 0, 0,
27846 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27847 atomic_read(&tw->tw_refcnt), tw, len);
27849 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/tcp_minisocks.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/tcp_minisocks.c
27850 --- linux-2.6.32.24/net/ipv4/tcp_minisocks.c 2009-12-03 20:03:00.000000000 +0100
27851 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/tcp_minisocks.c 2009-12-03 20:04:56.000000000 +0100
27853 #include <net/inet_common.h>
27854 #include <net/xfrm.h>
27856 +#include <linux/vs_limit.h>
27857 +#include <linux/vs_socket.h>
27858 +#include <linux/vs_context.h>
27860 #ifdef CONFIG_SYSCTL
27861 #define SYNC_INIT 0 /* let the user enable it */
27863 @@ -294,6 +298,11 @@ void tcp_time_wait(struct sock *sk, int
27864 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
27865 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27867 + tw->tw_xid = sk->sk_xid;
27868 + tw->tw_vx_info = NULL;
27869 + tw->tw_nid = sk->sk_nid;
27870 + tw->tw_nx_info = NULL;
27872 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27873 if (tw->tw_family == PF_INET6) {
27874 struct ipv6_pinfo *np = inet6_sk(sk);
27875 diff -NurpP --minimal linux-2.6.32.24/net/ipv4/udp.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/udp.c
27876 --- linux-2.6.32.24/net/ipv4/udp.c 2010-10-04 08:56:19.000000000 +0200
27877 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv4/udp.c 2010-05-27 19:21:36.000000000 +0200
27878 @@ -224,14 +224,7 @@ fail:
27880 EXPORT_SYMBOL(udp_lib_get_port);
27882 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27884 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27886 - return (!ipv6_only_sock(sk2) &&
27887 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
27888 - inet1->rcv_saddr == inet2->rcv_saddr));
27890 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27892 int udp_v4_get_port(struct sock *sk, unsigned short snum)
27894 @@ -253,6 +246,11 @@ static inline int compute_score(struct s
27895 if (inet->rcv_saddr != daddr)
27899 + /* block non nx_info ips */
27900 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27901 + daddr, NXA_MASK_BIND))
27905 if (inet->daddr != saddr)
27906 @@ -273,6 +271,7 @@ static inline int compute_score(struct s
27911 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27912 * harder than this. -DaveM
27914 @@ -294,6 +293,11 @@ begin:
27915 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27916 score = compute_score(sk, net, saddr, hnum, sport,
27917 daddr, dport, dif);
27918 + /* FIXME: disabled?
27919 + if (score == 9) {
27923 if (score > badness) {
27926 @@ -307,6 +311,7 @@ begin:
27927 if (get_nulls_value(node) != hash)
27932 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
27934 @@ -316,6 +321,7 @@ begin:
27942 @@ -358,7 +364,7 @@ static inline struct sock *udp_v4_mcast_
27943 s->sk_hash != hnum ||
27944 (inet->daddr && inet->daddr != rmt_addr) ||
27945 (inet->dport != rmt_port && inet->dport) ||
27946 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
27947 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27948 ipv6_only_sock(s) ||
27949 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27951 @@ -707,8 +713,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27952 { .sport = inet->sport,
27953 .dport = dport } } };
27954 struct net *net = sock_net(sk);
27955 + struct nx_info *nxi = sk->sk_nx_info;
27957 security_sk_classify_flow(sk, &fl);
27958 + err = ip_v4_find_src(net, nxi, &rt, &fl);
27962 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27964 if (err == -ENETUNREACH)
27965 @@ -988,7 +999,8 @@ try_again:
27967 sin->sin_family = AF_INET;
27968 sin->sin_port = udp_hdr(skb)->source;
27969 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27970 + sin->sin_addr.s_addr = nx_map_sock_lback(
27971 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27972 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27974 if (inet->cmsg_flags)
27975 @@ -1627,6 +1639,8 @@ static struct sock *udp_get_first(struct
27976 sk_nulls_for_each(sk, node, &hslot->head) {
27977 if (!net_eq(sock_net(sk), net))
27979 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27981 if (sk->sk_family == state->family)
27984 @@ -1644,7 +1658,9 @@ static struct sock *udp_get_next(struct
27987 sk = sk_nulls_next(sk);
27988 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27989 + } while (sk && (!net_eq(sock_net(sk), net) ||
27990 + sk->sk_family != state->family ||
27991 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27994 if (state->bucket < UDP_HTABLE_SIZE)
27995 @@ -1751,7 +1767,10 @@ static void udp4_format_sock(struct sock
27997 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27998 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27999 - bucket, src, srcp, dest, destp, sp->sk_state,
28001 + nx_map_sock_lback(current_nx_info(), src), srcp,
28002 + nx_map_sock_lback(current_nx_info(), dest), destp,
28004 sk_wmem_alloc_get(sp),
28005 sk_rmem_alloc_get(sp),
28006 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
28007 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/addrconf.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/addrconf.c
28008 --- linux-2.6.32.24/net/ipv6/addrconf.c 2010-10-04 08:56:19.000000000 +0200
28009 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/addrconf.c 2010-03-18 16:53:06.000000000 +0100
28012 #include <linux/proc_fs.h>
28013 #include <linux/seq_file.h>
28014 +#include <linux/vs_network.h>
28015 +#include <linux/vs_inet6.h>
28017 /* Set to 3 to get tracing... */
28018 #define ACONF_DEBUG 2
28019 @@ -1122,7 +1124,7 @@ out:
28021 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
28022 const struct in6_addr *daddr, unsigned int prefs,
28023 - struct in6_addr *saddr)
28024 + struct in6_addr *saddr, struct nx_info *nxi)
28026 struct ipv6_saddr_score scores[2],
28027 *score = &scores[0], *hiscore = &scores[1];
28028 @@ -1195,6 +1197,8 @@ int ipv6_dev_get_saddr(struct net *net,
28032 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
28036 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
28037 @@ -3003,7 +3007,10 @@ static void if6_seq_stop(struct seq_file
28038 static int if6_seq_show(struct seq_file *seq, void *v)
28040 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
28041 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28043 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
28044 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
28045 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28047 ifp->idev->dev->ifindex,
28049 @@ -3500,6 +3507,12 @@ static int inet6_dump_addr(struct sk_buf
28050 struct ifmcaddr6 *ifmca;
28051 struct ifacaddr6 *ifaca;
28052 struct net *net = sock_net(skb->sk);
28053 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28055 + /* disable ipv6 on non v6 guests */
28056 + if (nxi && !nx_info_has_v6(nxi))
28060 s_idx = cb->args[0];
28061 s_ip_idx = ip_idx = cb->args[1];
28062 @@ -3521,6 +3534,8 @@ static int inet6_dump_addr(struct sk_buf
28063 ifa = ifa->if_next, ip_idx++) {
28064 if (ip_idx < s_ip_idx)
28066 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
28068 err = inet6_fill_ifaddr(skb, ifa,
28069 NETLINK_CB(cb->skb).pid,
28070 cb->nlh->nlmsg_seq,
28071 @@ -3534,6 +3549,8 @@ static int inet6_dump_addr(struct sk_buf
28072 ifmca = ifmca->next, ip_idx++) {
28073 if (ip_idx < s_ip_idx)
28075 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
28077 err = inet6_fill_ifmcaddr(skb, ifmca,
28078 NETLINK_CB(cb->skb).pid,
28079 cb->nlh->nlmsg_seq,
28080 @@ -3547,6 +3564,8 @@ static int inet6_dump_addr(struct sk_buf
28081 ifaca = ifaca->aca_next, ip_idx++) {
28082 if (ip_idx < s_ip_idx)
28084 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
28086 err = inet6_fill_ifacaddr(skb, ifaca,
28087 NETLINK_CB(cb->skb).pid,
28088 cb->nlh->nlmsg_seq,
28089 @@ -3833,12 +3852,19 @@ static int inet6_dump_ifinfo(struct sk_b
28090 int s_idx = cb->args[0];
28091 struct net_device *dev;
28092 struct inet6_dev *idev;
28093 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28095 + /* FIXME: maybe disable ipv6 on non v6 guests?
28096 + if (skb->sk && skb->sk->sk_vx_info)
28097 + return skb->len; */
28099 read_lock(&dev_base_lock);
28101 for_each_netdev(net, dev) {
28104 + if (!v6_dev_in_nx_info(dev, nxi))
28106 if ((idev = in6_dev_get(dev)) == NULL)
28108 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
28109 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/af_inet6.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/af_inet6.c
28110 --- linux-2.6.32.24/net/ipv6/af_inet6.c 2009-12-03 20:03:00.000000000 +0100
28111 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/af_inet6.c 2009-12-03 20:04:56.000000000 +0100
28113 #include <linux/netdevice.h>
28114 #include <linux/icmpv6.h>
28115 #include <linux/netfilter_ipv6.h>
28116 +#include <linux/vs_inet.h>
28117 +#include <linux/vs_inet6.h>
28119 #include <net/ip.h>
28120 #include <net/ipv6.h>
28121 @@ -158,9 +160,12 @@ lookup_protocol:
28125 + if ((protocol == IPPROTO_ICMPV6) &&
28126 + nx_capable(answer->capability, NXC_RAW_ICMP))
28128 if (answer->capability > 0 && !capable(answer->capability))
28129 goto out_rcu_unlock;
28132 sock->ops = answer->ops;
28133 answer_prot = answer->prot;
28134 answer_no_check = answer->no_check;
28135 @@ -259,6 +264,7 @@ int inet6_bind(struct socket *sock, stru
28136 struct inet_sock *inet = inet_sk(sk);
28137 struct ipv6_pinfo *np = inet6_sk(sk);
28138 struct net *net = sock_net(sk);
28139 + struct nx_v6_sock_addr nsa;
28141 unsigned short snum;
28143 @@ -270,6 +276,11 @@ int inet6_bind(struct socket *sock, stru
28145 if (addr_len < SIN6_LEN_RFC2133)
28148 + err = v6_map_sock_addr(inet, addr, &nsa);
28152 addr_type = ipv6_addr_type(&addr->sin6_addr);
28153 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
28155 @@ -301,6 +312,7 @@ int inet6_bind(struct socket *sock, stru
28156 /* Reproduce AF_INET checks to make the bindings consitant */
28157 v4addr = addr->sin6_addr.s6_addr32[3];
28158 chk_addr_ret = inet_addr_type(net, v4addr);
28160 if (!sysctl_ip_nonlocal_bind &&
28161 !(inet->freebind || inet->transparent) &&
28162 v4addr != htonl(INADDR_ANY) &&
28163 @@ -310,6 +322,10 @@ int inet6_bind(struct socket *sock, stru
28164 err = -EADDRNOTAVAIL;
28167 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
28168 + err = -EADDRNOTAVAIL;
28172 if (addr_type != IPV6_ADDR_ANY) {
28173 struct net_device *dev = NULL;
28174 @@ -335,6 +351,11 @@ int inet6_bind(struct socket *sock, stru
28178 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28179 + err = -EADDRNOTAVAIL;
28183 /* ipv4 addr of the socket is invalid. Only the
28184 * unspecified and mapped address have a v4 equivalent.
28186 @@ -353,6 +374,8 @@ int inet6_bind(struct socket *sock, stru
28190 + v6_set_sock_addr(inet, &nsa);
28192 inet->rcv_saddr = v4addr;
28193 inet->saddr = v4addr;
28195 @@ -448,9 +471,11 @@ int inet6_getname(struct socket *sock, s
28197 sin->sin6_port = inet->dport;
28198 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
28199 + /* FIXME: remap lback? */
28201 sin->sin6_flowinfo = np->flow_label;
28203 + /* FIXME: remap lback? */
28204 if (ipv6_addr_any(&np->rcv_saddr))
28205 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
28207 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/fib6_rules.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/fib6_rules.c
28208 --- linux-2.6.32.24/net/ipv6/fib6_rules.c 2009-09-10 15:26:30.000000000 +0200
28209 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/fib6_rules.c 2009-12-03 20:04:56.000000000 +0100
28210 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
28211 if (ipv6_dev_get_saddr(net,
28212 ip6_dst_idev(&rt->u.dst)->dev,
28213 &flp->fl6_dst, srcprefs,
28217 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
28219 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/inet6_hashtables.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/inet6_hashtables.c
28220 --- linux-2.6.32.24/net/ipv6/inet6_hashtables.c 2009-03-24 14:22:46.000000000 +0100
28221 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/inet6_hashtables.c 2009-12-03 20:04:56.000000000 +0100
28224 #include <linux/module.h>
28225 #include <linux/random.h>
28226 +#include <linux/vs_inet6.h>
28228 #include <net/inet_connection_sock.h>
28229 #include <net/inet_hashtables.h>
28230 @@ -76,7 +77,6 @@ struct sock *__inet6_lookup_established(
28231 unsigned int slot = hash & (hashinfo->ehash_size - 1);
28232 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
28237 sk_nulls_for_each_rcu(sk, node, &head->chain) {
28238 @@ -88,7 +88,7 @@ begin:
28246 if (get_nulls_value(node) != slot)
28247 @@ -134,6 +134,9 @@ static int inline compute_score(struct s
28248 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28252 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28255 if (sk->sk_bound_dev_if) {
28256 if (sk->sk_bound_dev_if != dif)
28257 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/ip6_output.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/ip6_output.c
28258 --- linux-2.6.32.24/net/ipv6/ip6_output.c 2009-12-03 20:03:00.000000000 +0100
28259 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/ip6_output.c 2009-12-03 20:04:56.000000000 +0100
28260 @@ -934,7 +934,7 @@ static int ip6_dst_lookup_tail(struct so
28261 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
28263 sk ? inet6_sk(sk)->srcprefs : 0,
28265 + &fl->fl6_src, sk->sk_nx_info);
28267 goto out_err_release;
28269 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/Kconfig linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/Kconfig
28270 --- linux-2.6.32.24/net/ipv6/Kconfig 2009-09-10 15:26:30.000000000 +0200
28271 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/Kconfig 2009-12-03 20:04:56.000000000 +0100
28274 # IPv6 as module will cause a CRASH if you try to unload it
28276 - tristate "The IPv6 protocol"
28278 + bool "The IPv6 protocol"
28281 This is complemental support for the IP version 6.
28282 You will still be able to do traditional IPv4 networking as well.
28283 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/ndisc.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/ndisc.c
28284 --- linux-2.6.32.24/net/ipv6/ndisc.c 2009-12-03 20:03:00.000000000 +0100
28285 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/ndisc.c 2009-12-03 20:04:56.000000000 +0100
28286 @@ -589,7 +589,7 @@ static void ndisc_send_na(struct net_dev
28288 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
28289 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
28291 + &tmpaddr, NULL /* FIXME: ? */ ))
28293 src_addr = &tmpaddr;
28295 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/raw.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/raw.c
28296 --- linux-2.6.32.24/net/ipv6/raw.c 2009-12-03 20:03:00.000000000 +0100
28297 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/raw.c 2009-12-03 20:04:56.000000000 +0100
28299 #include <linux/icmpv6.h>
28300 #include <linux/netfilter.h>
28301 #include <linux/netfilter_ipv6.h>
28302 +#include <linux/vs_inet6.h>
28303 #include <linux/skbuff.h>
28304 #include <asm/uaccess.h>
28305 #include <asm/ioctls.h>
28306 @@ -281,6 +282,13 @@ static int rawv6_bind(struct sock *sk, s
28310 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28311 + err = -EADDRNOTAVAIL;
28317 /* ipv4 addr of the socket is invalid. Only the
28318 * unspecified and mapped address have a v4 equivalent.
28320 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/route.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/route.c
28321 --- linux-2.6.32.24/net/ipv6/route.c 2009-12-03 20:03:00.000000000 +0100
28322 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/route.c 2009-12-03 20:04:56.000000000 +0100
28323 @@ -2257,7 +2257,8 @@ static int rt6_fill_node(struct net *net
28324 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
28325 struct in6_addr saddr_buf;
28326 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
28327 - dst, 0, &saddr_buf) == 0)
28328 + dst, 0, &saddr_buf,
28329 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
28330 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
28333 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/tcp_ipv6.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/tcp_ipv6.c
28334 --- linux-2.6.32.24/net/ipv6/tcp_ipv6.c 2009-12-03 20:03:00.000000000 +0100
28335 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/tcp_ipv6.c 2009-12-03 20:04:56.000000000 +0100
28338 #include <linux/crypto.h>
28339 #include <linux/scatterlist.h>
28340 +#include <linux/vs_inet6.h>
28342 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
28343 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
28344 @@ -156,8 +157,15 @@ static int tcp_v6_connect(struct sock *s
28345 * connect() to INADDR_ANY means loopback (BSD'ism).
28348 - if(ipv6_addr_any(&usin->sin6_addr))
28349 - usin->sin6_addr.s6_addr[15] = 0x1;
28350 + if(ipv6_addr_any(&usin->sin6_addr)) {
28351 + struct nx_info *nxi = sk->sk_nx_info;
28353 + if (nxi && nx_info_has_v6(nxi))
28354 + /* FIXME: remap lback? */
28355 + usin->sin6_addr = nxi->v6.ip;
28357 + usin->sin6_addr.s6_addr[15] = 0x1;
28360 addr_type = ipv6_addr_type(&usin->sin6_addr);
28362 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/udp.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/udp.c
28363 --- linux-2.6.32.24/net/ipv6/udp.c 2009-12-03 20:03:00.000000000 +0100
28364 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/udp.c 2009-12-03 20:04:56.000000000 +0100
28367 #include <linux/proc_fs.h>
28368 #include <linux/seq_file.h>
28369 +#include <linux/vs_inet6.h>
28370 #include "udp_impl.h"
28372 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
28373 @@ -61,24 +62,49 @@ int ipv6_rcv_saddr_equal(const struct so
28374 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
28376 /* if both are mapped, treat as IPv4 */
28377 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
28378 - return (!sk2_ipv6only &&
28379 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
28380 + if (!sk2_ipv6only &&
28381 (!sk_rcv_saddr || !sk2_rcv_saddr ||
28382 - sk_rcv_saddr == sk2_rcv_saddr));
28383 + sk_rcv_saddr == sk2_rcv_saddr))
28389 if (addr_type2 == IPV6_ADDR_ANY &&
28390 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
28394 if (addr_type == IPV6_ADDR_ANY &&
28395 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
28399 if (sk2_rcv_saddr6 &&
28400 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
28407 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
28408 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28409 + if (!sk2_rcv_saddr)
28410 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
28411 + if (!sk_rcv_saddr)
28412 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
28415 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
28416 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28417 + else if (addr_type2 == IPV6_ADDR_ANY)
28418 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
28419 + else if (addr_type == IPV6_ADDR_ANY) {
28420 + if (addr_type2 == IPV6_ADDR_MAPPED)
28421 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28423 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
28428 int udp_v6_get_port(struct sock *sk, unsigned short snum)
28429 @@ -109,6 +135,10 @@ static inline int compute_score(struct s
28430 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28434 + /* block non nx_info ips */
28435 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28438 if (!ipv6_addr_any(&np->daddr)) {
28439 if (!ipv6_addr_equal(&np->daddr, saddr))
28440 diff -NurpP --minimal linux-2.6.32.24/net/ipv6/xfrm6_policy.c linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/xfrm6_policy.c
28441 --- linux-2.6.32.24/net/ipv6/xfrm6_policy.c 2009-12-03 20:03:00.000000000 +0100
28442 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/ipv6/xfrm6_policy.c 2009-12-03 20:04:56.000000000 +0100
28443 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
28444 dev = ip6_dst_idev(dst)->dev;
28445 ipv6_dev_get_saddr(dev_net(dev), dev,
28446 (struct in6_addr *)&daddr->a6, 0,
28447 - (struct in6_addr *)&saddr->a6);
28448 + (struct in6_addr *)&saddr->a6, NULL);
28452 diff -NurpP --minimal linux-2.6.32.24/net/netlink/af_netlink.c linux-2.6.32.24-vs2.3.0.36.29.6/net/netlink/af_netlink.c
28453 --- linux-2.6.32.24/net/netlink/af_netlink.c 2010-10-04 08:56:19.000000000 +0200
28454 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/netlink/af_netlink.c 2010-09-05 21:24:17.000000000 +0200
28456 #include <linux/types.h>
28457 #include <linux/audit.h>
28458 #include <linux/mutex.h>
28459 +#include <linux/vs_context.h>
28460 +#include <linux/vs_network.h>
28461 +#include <linux/vs_limit.h>
28463 #include <net/net_namespace.h>
28464 #include <net/sock.h>
28465 @@ -1885,6 +1888,8 @@ static struct sock *netlink_seq_socket_i
28466 sk_for_each(s, node, &hash->table[j]) {
28467 if (sock_net(s) != seq_file_net(seq))
28469 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28473 iter->hash_idx = j;
28474 @@ -1919,7 +1924,8 @@ static void *netlink_seq_next(struct seq
28478 - } while (s && sock_net(s) != seq_file_net(seq));
28479 + } while (s && (sock_net(s) != seq_file_net(seq) ||
28480 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28484 @@ -1931,7 +1937,8 @@ static void *netlink_seq_next(struct seq
28486 for (; j <= hash->mask; j++) {
28487 s = sk_head(&hash->table[j]);
28488 - while (s && sock_net(s) != seq_file_net(seq))
28489 + while (s && (sock_net(s) != seq_file_net(seq) ||
28490 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28494 diff -NurpP --minimal linux-2.6.32.24/net/sctp/ipv6.c linux-2.6.32.24-vs2.3.0.36.29.6/net/sctp/ipv6.c
28495 --- linux-2.6.32.24/net/sctp/ipv6.c 2009-12-03 20:03:01.000000000 +0100
28496 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/sctp/ipv6.c 2009-12-03 20:04:56.000000000 +0100
28497 @@ -316,7 +316,8 @@ static void sctp_v6_get_saddr(struct sct
28498 dst ? ip6_dst_idev(dst)->dev : NULL,
28499 &daddr->v6.sin6_addr,
28500 inet6_sk(&sk->inet.sk)->srcprefs,
28501 - &saddr->v6.sin6_addr);
28502 + &saddr->v6.sin6_addr,
28503 + asoc->base.sk->sk_nx_info);
28504 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
28505 &saddr->v6.sin6_addr);
28507 diff -NurpP --minimal linux-2.6.32.24/net/socket.c linux-2.6.32.24-vs2.3.0.36.29.6/net/socket.c
28508 --- linux-2.6.32.24/net/socket.c 2009-12-03 20:03:01.000000000 +0100
28509 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/socket.c 2009-12-03 20:04:56.000000000 +0100
28512 #include <net/sock.h>
28513 #include <linux/netfilter.h>
28514 +#include <linux/vs_base.h>
28515 +#include <linux/vs_socket.h>
28516 +#include <linux/vs_inet.h>
28517 +#include <linux/vs_inet6.h>
28519 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
28520 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
28521 @@ -559,7 +563,7 @@ static inline int __sock_sendmsg(struct
28522 struct msghdr *msg, size_t size)
28524 struct sock_iocb *si = kiocb_to_siocb(iocb);
28530 @@ -570,7 +574,22 @@ static inline int __sock_sendmsg(struct
28534 - return sock->ops->sendmsg(iocb, sock, msg, size);
28535 + len = sock->ops->sendmsg(iocb, sock, msg, size);
28538 + vx_sock_send(sock->sk, size);
28540 + vx_sock_fail(sock->sk, size);
28542 + vxdprintk(VXD_CBIT(net, 7),
28543 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28545 + (sock->sk)?sock->sk->sk_nx_info:0,
28546 + (sock->sk)?sock->sk->sk_vx_info:0,
28547 + (sock->sk)?sock->sk->sk_xid:0,
28548 + (sock->sk)?sock->sk->sk_nid:0,
28549 + (unsigned int)size, len);
28553 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
28554 @@ -671,7 +690,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
28555 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
28556 struct msghdr *msg, size_t size, int flags)
28560 struct sock_iocb *si = kiocb_to_siocb(iocb);
28563 @@ -684,7 +703,18 @@ static inline int __sock_recvmsg(struct
28567 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
28568 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
28569 + if ((len >= 0) && sock->sk)
28570 + vx_sock_recv(sock->sk, len);
28571 + vxdprintk(VXD_CBIT(net, 7),
28572 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28574 + (sock->sk)?sock->sk->sk_nx_info:0,
28575 + (sock->sk)?sock->sk->sk_vx_info:0,
28576 + (sock->sk)?sock->sk->sk_xid:0,
28577 + (sock->sk)?sock->sk->sk_nid:0,
28578 + (unsigned int)size, len);
28582 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
28583 @@ -1155,6 +1185,13 @@ static int __sock_create(struct net *net
28584 if (type < 0 || type >= SOCK_MAX)
28587 + if (!nx_check(0, VS_ADMIN)) {
28588 + if (family == PF_INET && !current_nx_info_has_v4())
28589 + return -EAFNOSUPPORT;
28590 + if (family == PF_INET6 && !current_nx_info_has_v6())
28591 + return -EAFNOSUPPORT;
28596 This uglymoron is moved from INET layer to here to avoid
28597 @@ -1287,6 +1324,7 @@ SYSCALL_DEFINE3(socket, int, family, int
28601 + set_bit(SOCK_USER_SOCKET, &sock->flags);
28602 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
28605 @@ -1328,10 +1366,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
28606 err = sock_create(family, type, protocol, &sock1);
28609 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
28611 err = sock_create(family, type, protocol, &sock2);
28613 goto out_release_1;
28614 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
28616 err = sock1->ops->socketpair(sock1, sock2);
28618 diff -NurpP --minimal linux-2.6.32.24/net/sunrpc/auth.c linux-2.6.32.24-vs2.3.0.36.29.6/net/sunrpc/auth.c
28619 --- linux-2.6.32.24/net/sunrpc/auth.c 2009-12-03 20:03:01.000000000 +0100
28620 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/sunrpc/auth.c 2009-12-03 20:04:56.000000000 +0100
28622 #include <linux/hash.h>
28623 #include <linux/sunrpc/clnt.h>
28624 #include <linux/spinlock.h>
28625 +#include <linux/vs_tag.h>
28628 # define RPCDBG_FACILITY RPCDBG_AUTH
28629 @@ -360,6 +361,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28630 memset(&acred, 0, sizeof(acred));
28631 acred.uid = cred->fsuid;
28632 acred.gid = cred->fsgid;
28633 + acred.tag = dx_current_tag();
28634 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
28636 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
28637 @@ -400,6 +402,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28638 struct auth_cred acred = {
28641 + .tag = dx_current_tag(),
28643 struct rpc_cred *ret;
28645 diff -NurpP --minimal linux-2.6.32.24/net/sunrpc/auth_unix.c linux-2.6.32.24-vs2.3.0.36.29.6/net/sunrpc/auth_unix.c
28646 --- linux-2.6.32.24/net/sunrpc/auth_unix.c 2008-12-25 00:26:37.000000000 +0100
28647 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/sunrpc/auth_unix.c 2009-12-03 20:04:56.000000000 +0100
28648 @@ -11,12 +11,14 @@
28649 #include <linux/module.h>
28650 #include <linux/sunrpc/clnt.h>
28651 #include <linux/sunrpc/auth.h>
28652 +#include <linux/vs_tag.h>
28654 #define NFS_NGROUPS 16
28657 struct rpc_cred uc_base;
28660 gid_t uc_gids[NFS_NGROUPS];
28662 #define uc_uid uc_base.cr_uid
28663 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
28664 groups = NFS_NGROUPS;
28666 cred->uc_gid = acred->gid;
28667 + cred->uc_tag = acred->tag;
28668 for (i = 0; i < groups; i++)
28669 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28670 if (i < NFS_NGROUPS)
28671 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
28675 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28676 + if (cred->uc_uid != acred->uid ||
28677 + cred->uc_gid != acred->gid ||
28678 + cred->uc_tag != acred->tag)
28681 if (acred->group_info != NULL)
28682 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
28683 struct rpc_clnt *clnt = task->tk_client;
28684 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28685 __be32 *base, *hold;
28689 *p++ = htonl(RPC_AUTH_UNIX);
28691 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
28692 * Copy the UTS nodename captured when the client was created.
28694 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28695 + tag = task->tk_client->cl_tag;
28697 - *p++ = htonl((u32) cred->uc_uid);
28698 - *p++ = htonl((u32) cred->uc_gid);
28699 + *p++ = htonl((u32) TAGINO_UID(tag,
28700 + cred->uc_uid, cred->uc_tag));
28701 + *p++ = htonl((u32) TAGINO_GID(tag,
28702 + cred->uc_gid, cred->uc_tag));
28704 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28705 *p++ = htonl((u32) cred->uc_gids[i]);
28706 diff -NurpP --minimal linux-2.6.32.24/net/sunrpc/clnt.c linux-2.6.32.24-vs2.3.0.36.29.6/net/sunrpc/clnt.c
28707 --- linux-2.6.32.24/net/sunrpc/clnt.c 2009-12-03 20:03:01.000000000 +0100
28708 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/sunrpc/clnt.c 2009-12-03 20:04:56.000000000 +0100
28710 #include <linux/utsname.h>
28711 #include <linux/workqueue.h>
28712 #include <linux/in6.h>
28713 +#include <linux/vs_cvirt.h>
28715 #include <linux/sunrpc/clnt.h>
28716 #include <linux/sunrpc/rpc_pipe_fs.h>
28717 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28718 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28719 clnt->cl_chatty = 1;
28721 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
28722 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
28723 + clnt->cl_tag = 1; */
28726 EXPORT_SYMBOL_GPL(rpc_create);
28727 diff -NurpP --minimal linux-2.6.32.24/net/unix/af_unix.c linux-2.6.32.24-vs2.3.0.36.29.6/net/unix/af_unix.c
28728 --- linux-2.6.32.24/net/unix/af_unix.c 2010-10-04 08:56:20.000000000 +0200
28729 +++ linux-2.6.32.24-vs2.3.0.36.29.6/net/unix/af_unix.c 2010-10-04 10:04:57.000000000 +0200
28730 @@ -114,6 +114,8 @@
28731 #include <linux/mount.h>
28732 #include <net/checksum.h>
28733 #include <linux/security.h>
28734 +#include <linux/vs_context.h>
28735 +#include <linux/vs_limit.h>
28737 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28738 static DEFINE_SPINLOCK(unix_table_lock);
28739 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28740 if (!net_eq(sock_net(s), net))
28743 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28745 if (u->addr->len == len &&
28746 !memcmp(u->addr->name, sunname, len))
28748 @@ -2123,6 +2127,8 @@ static struct sock *unix_seq_idx(struct
28749 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28750 if (sock_net(s) != seq_file_net(seq))
28752 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28757 @@ -2147,7 +2153,8 @@ static void *unix_seq_next(struct seq_fi
28758 sk = first_unix_socket(&iter->i);
28760 sk = next_unix_socket(&iter->i, sk);
28761 - while (sk && (sock_net(sk) != seq_file_net(seq)))
28762 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
28763 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28764 sk = next_unix_socket(&iter->i, sk);
28767 diff -NurpP --minimal linux-2.6.32.24/scripts/checksyscalls.sh linux-2.6.32.24-vs2.3.0.36.29.6/scripts/checksyscalls.sh
28768 --- linux-2.6.32.24/scripts/checksyscalls.sh 2009-09-10 15:26:31.000000000 +0200
28769 +++ linux-2.6.32.24-vs2.3.0.36.29.6/scripts/checksyscalls.sh 2009-12-03 20:04:56.000000000 +0100
28770 @@ -194,7 +194,6 @@ cat << EOF
28771 #define __IGNORE_afs_syscall
28772 #define __IGNORE_getpmsg
28773 #define __IGNORE_putpmsg
28774 -#define __IGNORE_vserver
28778 diff -NurpP --minimal linux-2.6.32.24/security/commoncap.c linux-2.6.32.24-vs2.3.0.36.29.6/security/commoncap.c
28779 --- linux-2.6.32.24/security/commoncap.c 2009-12-03 20:03:02.000000000 +0100
28780 +++ linux-2.6.32.24-vs2.3.0.36.29.6/security/commoncap.c 2010-03-13 21:50:18.000000000 +0100
28782 #include <linux/sched.h>
28783 #include <linux/prctl.h>
28784 #include <linux/securebits.h>
28785 +#include <linux/vs_context.h>
28788 * If a non-root user executes a setuid-root binary in
28789 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
28791 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28793 - NETLINK_CB(skb).eff_cap = current_cap();
28794 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
28798 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
28803 EXPORT_SYMBOL(cap_netlink_recv);
28806 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
28807 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
28810 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
28811 + struct vx_info *vxi = tsk->vx_info;
28814 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28815 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28816 + cap_raised(tsk->cap_effective, cap),
28817 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28820 + /* special case SETUP */
28821 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28822 + /* FIXME: maybe use cred instead? */
28823 + cap_raised(tsk->cred->cap_effective, cap))
28826 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
28830 @@ -618,7 +635,7 @@ int cap_inode_setxattr(struct dentry *de
28832 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28833 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28834 - !capable(CAP_SYS_ADMIN))
28835 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28839 @@ -644,7 +661,7 @@ int cap_inode_removexattr(struct dentry
28841 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28842 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28843 - !capable(CAP_SYS_ADMIN))
28844 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28848 @@ -962,7 +979,8 @@ error:
28850 int cap_syslog(int type)
28852 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
28853 + if ((type != 3 && type != 10) &&
28854 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28858 diff -NurpP --minimal linux-2.6.32.24/security/selinux/hooks.c linux-2.6.32.24-vs2.3.0.36.29.6/security/selinux/hooks.c
28859 --- linux-2.6.32.24/security/selinux/hooks.c 2010-10-04 08:56:20.000000000 +0200
28860 +++ linux-2.6.32.24-vs2.3.0.36.29.6/security/selinux/hooks.c 2010-02-12 10:59:55.000000000 +0100
28862 #include <linux/dccp.h>
28863 #include <linux/quota.h>
28864 #include <linux/un.h> /* for Unix socket types */
28865 -#include <net/af_unix.h> /* for Unix socket types */
28866 #include <linux/parser.h>
28867 #include <linux/nfs_mount.h>
28868 #include <net/ipv6.h>
28869 diff -NurpP --minimal linux-2.6.32.24/security/selinux/include/av_permissions.h linux-2.6.32.24-vs2.3.0.36.29.6/security/selinux/include/av_permissions.h
28870 --- linux-2.6.32.24/security/selinux/include/av_permissions.h 2009-12-03 20:03:02.000000000 +0100
28871 +++ linux-2.6.32.24-vs2.3.0.36.29.6/security/selinux/include/av_permissions.h 2009-12-03 20:04:56.000000000 +0100
28872 @@ -565,6 +565,7 @@
28873 #define CAPABILITY__SETFCAP 0x80000000UL
28874 #define CAPABILITY2__MAC_OVERRIDE 0x00000001UL
28875 #define CAPABILITY2__MAC_ADMIN 0x00000002UL
28876 +#define CAPABILITY2__CONTEXT 0x00000004UL
28877 #define NETLINK_ROUTE_SOCKET__IOCTL 0x00000001UL
28878 #define NETLINK_ROUTE_SOCKET__READ 0x00000002UL
28879 #define NETLINK_ROUTE_SOCKET__WRITE 0x00000004UL
28880 diff -NurpP --minimal linux-2.6.32.24/security/selinux/include/av_perm_to_string.h linux-2.6.32.24-vs2.3.0.36.29.6/security/selinux/include/av_perm_to_string.h
28881 --- linux-2.6.32.24/security/selinux/include/av_perm_to_string.h 2009-12-03 20:03:02.000000000 +0100
28882 +++ linux-2.6.32.24-vs2.3.0.36.29.6/security/selinux/include/av_perm_to_string.h 2009-12-03 20:04:56.000000000 +0100
28883 @@ -142,6 +142,7 @@
28884 S_(SECCLASS_CAPABILITY, CAPABILITY__SETFCAP, "setfcap")
28885 S_(SECCLASS_CAPABILITY2, CAPABILITY2__MAC_OVERRIDE, "mac_override")
28886 S_(SECCLASS_CAPABILITY2, CAPABILITY2__MAC_ADMIN, "mac_admin")
28887 + S_(SECCLASS_CAPABILITY2, CAPABILITY2__CONTEXT, "context")
28888 S_(SECCLASS_NETLINK_ROUTE_SOCKET, NETLINK_ROUTE_SOCKET__NLMSG_READ, "nlmsg_read")
28889 S_(SECCLASS_NETLINK_ROUTE_SOCKET, NETLINK_ROUTE_SOCKET__NLMSG_WRITE, "nlmsg_write")
28890 S_(SECCLASS_NETLINK_FIREWALL_SOCKET, NETLINK_FIREWALL_SOCKET__NLMSG_READ, "nlmsg_read")