diff options
524 files changed, 8476 insertions, 3738 deletions
diff --git a/Documentation/flexible-arrays.txt b/Documentation/flexible-arrays.txt index cb8a3a00cc9..df904aec990 100644 --- a/Documentation/flexible-arrays.txt +++ b/Documentation/flexible-arrays.txt | |||
@@ -66,10 +66,10 @@ trick is to ensure that any needed memory allocations are done before | |||
66 | entering atomic context, using: | 66 | entering atomic context, using: |
67 | 67 | ||
68 | int flex_array_prealloc(struct flex_array *array, unsigned int start, | 68 | int flex_array_prealloc(struct flex_array *array, unsigned int start, |
69 | unsigned int end, gfp_t flags); | 69 | unsigned int nr_elements, gfp_t flags); |
70 | 70 | ||
71 | This function will ensure that memory for the elements indexed in the range | 71 | This function will ensure that memory for the elements indexed in the range |
72 | defined by start and end has been allocated. Thereafter, a | 72 | defined by start and nr_elements has been allocated. Thereafter, a |
73 | flex_array_put() call on an element in that range is guaranteed not to | 73 | flex_array_put() call on an element in that range is guaranteed not to |
74 | block. | 74 | block. |
75 | 75 | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 2199ba1323d..69f19f10314 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -2813,38 +2813,19 @@ F: Documentation/gpio.txt | |||
2813 | F: drivers/gpio/ | 2813 | F: drivers/gpio/ |
2814 | F: include/linux/gpio* | 2814 | F: include/linux/gpio* |
2815 | 2815 | ||
2816 | GRE DEMULTIPLEXER DRIVER | ||
2817 | M: Dmitry Kozlov <xeb@mail.ru> | ||
2818 | L: netdev@vger.kernel.org | ||
2819 | S: Maintained | ||
2820 | F: net/ipv4/gre.c | ||
2821 | F: include/net/gre.h | ||
2822 | |||
2816 | GRETH 10/100/1G Ethernet MAC device driver | 2823 | GRETH 10/100/1G Ethernet MAC device driver |
2817 | M: Kristoffer Glembo <kristoffer@gaisler.com> | 2824 | M: Kristoffer Glembo <kristoffer@gaisler.com> |
2818 | L: netdev@vger.kernel.org | 2825 | L: netdev@vger.kernel.org |
2819 | S: Maintained | 2826 | S: Maintained |
2820 | F: drivers/net/greth* | 2827 | F: drivers/net/greth* |
2821 | 2828 | ||
2822 | HARD DRIVE ACTIVE PROTECTION SYSTEM (HDAPS) DRIVER | ||
2823 | M: Frank Seidel <frank@f-seidel.de> | ||
2824 | L: platform-driver-x86@vger.kernel.org | ||
2825 | W: http://www.kernel.org/pub/linux/kernel/people/fseidel/hdaps/ | ||
2826 | S: Maintained | ||
2827 | F: drivers/platform/x86/hdaps.c | ||
2828 | |||
2829 | HWPOISON MEMORY FAILURE HANDLING | ||
2830 | M: Andi Kleen <andi@firstfloor.org> | ||
2831 | L: linux-mm@kvack.org | ||
2832 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-mce-2.6.git hwpoison | ||
2833 | S: Maintained | ||
2834 | F: mm/memory-failure.c | ||
2835 | F: mm/hwpoison-inject.c | ||
2836 | |||
2837 | HYPERVISOR VIRTUAL CONSOLE DRIVER | ||
2838 | L: linuxppc-dev@lists.ozlabs.org | ||
2839 | S: Odd Fixes | ||
2840 | F: drivers/tty/hvc/ | ||
2841 | |||
2842 | iSCSI BOOT FIRMWARE TABLE (iBFT) DRIVER | ||
2843 | M: Peter Jones <pjones@redhat.com> | ||
2844 | M: Konrad Rzeszutek Wilk <konrad@kernel.org> | ||
2845 | S: Maintained | ||
2846 | F: drivers/firmware/iscsi_ibft* | ||
2847 | |||
2848 | GSPCA FINEPIX SUBDRIVER | 2829 | GSPCA FINEPIX SUBDRIVER |
2849 | M: Frank Zago <frank@zago.net> | 2830 | M: Frank Zago <frank@zago.net> |
2850 | L: linux-media@vger.kernel.org | 2831 | L: linux-media@vger.kernel.org |
@@ -2895,6 +2876,26 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6.git | |||
2895 | S: Maintained | 2876 | S: Maintained |
2896 | F: drivers/media/video/gspca/ | 2877 | F: drivers/media/video/gspca/ |
2897 | 2878 | ||
2879 | HARD DRIVE ACTIVE PROTECTION SYSTEM (HDAPS) DRIVER | ||
2880 | M: Frank Seidel <frank@f-seidel.de> | ||
2881 | L: platform-driver-x86@vger.kernel.org | ||
2882 | W: http://www.kernel.org/pub/linux/kernel/people/fseidel/hdaps/ | ||
2883 | S: Maintained | ||
2884 | F: drivers/platform/x86/hdaps.c | ||
2885 | |||
2886 | HWPOISON MEMORY FAILURE HANDLING | ||
2887 | M: Andi Kleen <andi@firstfloor.org> | ||
2888 | L: linux-mm@kvack.org | ||
2889 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-mce-2.6.git hwpoison | ||
2890 | S: Maintained | ||
2891 | F: mm/memory-failure.c | ||
2892 | F: mm/hwpoison-inject.c | ||
2893 | |||
2894 | HYPERVISOR VIRTUAL CONSOLE DRIVER | ||
2895 | L: linuxppc-dev@lists.ozlabs.org | ||
2896 | S: Odd Fixes | ||
2897 | F: drivers/tty/hvc/ | ||
2898 | |||
2898 | HARDWARE MONITORING | 2899 | HARDWARE MONITORING |
2899 | M: Jean Delvare <khali@linux-fr.org> | 2900 | M: Jean Delvare <khali@linux-fr.org> |
2900 | M: Guenter Roeck <guenter.roeck@ericsson.com> | 2901 | M: Guenter Roeck <guenter.roeck@ericsson.com> |
@@ -3478,6 +3479,12 @@ F: Documentation/isapnp.txt | |||
3478 | F: drivers/pnp/isapnp/ | 3479 | F: drivers/pnp/isapnp/ |
3479 | F: include/linux/isapnp.h | 3480 | F: include/linux/isapnp.h |
3480 | 3481 | ||
3482 | iSCSI BOOT FIRMWARE TABLE (iBFT) DRIVER | ||
3483 | M: Peter Jones <pjones@redhat.com> | ||
3484 | M: Konrad Rzeszutek Wilk <konrad@kernel.org> | ||
3485 | S: Maintained | ||
3486 | F: drivers/firmware/iscsi_ibft* | ||
3487 | |||
3481 | ISCSI | 3488 | ISCSI |
3482 | M: Mike Christie <michaelc@cs.wisc.edu> | 3489 | M: Mike Christie <michaelc@cs.wisc.edu> |
3483 | L: open-iscsi@googlegroups.com | 3490 | L: open-iscsi@googlegroups.com |
@@ -4989,6 +4996,13 @@ F: Documentation/pps/ | |||
4989 | F: drivers/pps/ | 4996 | F: drivers/pps/ |
4990 | F: include/linux/pps*.h | 4997 | F: include/linux/pps*.h |
4991 | 4998 | ||
4999 | PPTP DRIVER | ||
5000 | M: Dmitry Kozlov <xeb@mail.ru> | ||
5001 | L: netdev@vger.kernel.org | ||
5002 | S: Maintained | ||
5003 | F: drivers/net/pptp.c | ||
5004 | W: http://sourceforge.net/projects/accel-pptp | ||
5005 | |||
4992 | PREEMPTIBLE KERNEL | 5006 | PREEMPTIBLE KERNEL |
4993 | M: Robert Love <rml@tech9.net> | 5007 | M: Robert Love <rml@tech9.net> |
4994 | L: kpreempt-tech@lists.sourceforge.net | 5008 | L: kpreempt-tech@lists.sourceforge.net |
@@ -6556,7 +6570,7 @@ S: Maintained | |||
6556 | F: drivers/usb/host/uhci* | 6570 | F: drivers/usb/host/uhci* |
6557 | 6571 | ||
6558 | USB "USBNET" DRIVER FRAMEWORK | 6572 | USB "USBNET" DRIVER FRAMEWORK |
6559 | M: David Brownell <dbrownell@users.sourceforge.net> | 6573 | M: Oliver Neukum <oneukum@suse.de> |
6560 | L: netdev@vger.kernel.org | 6574 | L: netdev@vger.kernel.org |
6561 | W: http://www.linux-usb.org/usbnet | 6575 | W: http://www.linux-usb.org/usbnet |
6562 | S: Maintained | 6576 | S: Maintained |
@@ -7024,20 +7038,6 @@ M: "Maciej W. Rozycki" <macro@linux-mips.org> | |||
7024 | S: Maintained | 7038 | S: Maintained |
7025 | F: drivers/tty/serial/zs.* | 7039 | F: drivers/tty/serial/zs.* |
7026 | 7040 | ||
7027 | GRE DEMULTIPLEXER DRIVER | ||
7028 | M: Dmitry Kozlov <xeb@mail.ru> | ||
7029 | L: netdev@vger.kernel.org | ||
7030 | S: Maintained | ||
7031 | F: net/ipv4/gre.c | ||
7032 | F: include/net/gre.h | ||
7033 | |||
7034 | PPTP DRIVER | ||
7035 | M: Dmitry Kozlov <xeb@mail.ru> | ||
7036 | L: netdev@vger.kernel.org | ||
7037 | S: Maintained | ||
7038 | F: drivers/net/pptp.c | ||
7039 | W: http://sourceforge.net/projects/accel-pptp | ||
7040 | |||
7041 | THE REST | 7041 | THE REST |
7042 | M: Linus Torvalds <torvalds@linux-foundation.org> | 7042 | M: Linus Torvalds <torvalds@linux-foundation.org> |
7043 | L: linux-kernel@vger.kernel.org | 7043 | L: linux-kernel@vger.kernel.org |
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 2 | 1 | VERSION = 2 |
2 | PATCHLEVEL = 6 | 2 | PATCHLEVEL = 6 |
3 | SUBLEVEL = 39 | 3 | SUBLEVEL = 39 |
4 | EXTRAVERSION = -rc5 | 4 | EXTRAVERSION = |
5 | NAME = Flesh-Eating Bats with Fangs | 5 | NAME = Flesh-Eating Bats with Fangs |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h index 058937bf5a7..b1834166922 100644 --- a/arch/alpha/include/asm/unistd.h +++ b/arch/alpha/include/asm/unistd.h | |||
@@ -452,10 +452,14 @@ | |||
452 | #define __NR_fanotify_init 494 | 452 | #define __NR_fanotify_init 494 |
453 | #define __NR_fanotify_mark 495 | 453 | #define __NR_fanotify_mark 495 |
454 | #define __NR_prlimit64 496 | 454 | #define __NR_prlimit64 496 |
455 | #define __NR_name_to_handle_at 497 | ||
456 | #define __NR_open_by_handle_at 498 | ||
457 | #define __NR_clock_adjtime 499 | ||
458 | #define __NR_syncfs 500 | ||
455 | 459 | ||
456 | #ifdef __KERNEL__ | 460 | #ifdef __KERNEL__ |
457 | 461 | ||
458 | #define NR_SYSCALLS 497 | 462 | #define NR_SYSCALLS 501 |
459 | 463 | ||
460 | #define __ARCH_WANT_IPC_PARSE_VERSION | 464 | #define __ARCH_WANT_IPC_PARSE_VERSION |
461 | #define __ARCH_WANT_OLD_READDIR | 465 | #define __ARCH_WANT_OLD_READDIR |
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S index a6a1de9db16..15f999d41c7 100644 --- a/arch/alpha/kernel/systbls.S +++ b/arch/alpha/kernel/systbls.S | |||
@@ -498,23 +498,27 @@ sys_call_table: | |||
498 | .quad sys_ni_syscall /* sys_timerfd */ | 498 | .quad sys_ni_syscall /* sys_timerfd */ |
499 | .quad sys_eventfd | 499 | .quad sys_eventfd |
500 | .quad sys_recvmmsg | 500 | .quad sys_recvmmsg |
501 | .quad sys_fallocate /* 480 */ | 501 | .quad sys_fallocate /* 480 */ |
502 | .quad sys_timerfd_create | 502 | .quad sys_timerfd_create |
503 | .quad sys_timerfd_settime | 503 | .quad sys_timerfd_settime |
504 | .quad sys_timerfd_gettime | 504 | .quad sys_timerfd_gettime |
505 | .quad sys_signalfd4 | 505 | .quad sys_signalfd4 |
506 | .quad sys_eventfd2 /* 485 */ | 506 | .quad sys_eventfd2 /* 485 */ |
507 | .quad sys_epoll_create1 | 507 | .quad sys_epoll_create1 |
508 | .quad sys_dup3 | 508 | .quad sys_dup3 |
509 | .quad sys_pipe2 | 509 | .quad sys_pipe2 |
510 | .quad sys_inotify_init1 | 510 | .quad sys_inotify_init1 |
511 | .quad sys_preadv /* 490 */ | 511 | .quad sys_preadv /* 490 */ |
512 | .quad sys_pwritev | 512 | .quad sys_pwritev |
513 | .quad sys_rt_tgsigqueueinfo | 513 | .quad sys_rt_tgsigqueueinfo |
514 | .quad sys_perf_event_open | 514 | .quad sys_perf_event_open |
515 | .quad sys_fanotify_init | 515 | .quad sys_fanotify_init |
516 | .quad sys_fanotify_mark /* 495 */ | 516 | .quad sys_fanotify_mark /* 495 */ |
517 | .quad sys_prlimit64 | 517 | .quad sys_prlimit64 |
518 | .quad sys_name_to_handle_at | ||
519 | .quad sys_open_by_handle_at | ||
520 | .quad sys_clock_adjtime | ||
521 | .quad sys_syncfs /* 500 */ | ||
518 | 522 | ||
519 | .size sys_call_table, . - sys_call_table | 523 | .size sys_call_table, . - sys_call_table |
520 | .type sys_call_table, @object | 524 | .type sys_call_table, @object |
diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c index 918e8e0b72f..818e74ed45d 100644 --- a/arch/alpha/kernel/time.c +++ b/arch/alpha/kernel/time.c | |||
@@ -375,8 +375,7 @@ static struct clocksource clocksource_rpcc = { | |||
375 | 375 | ||
376 | static inline void register_rpcc_clocksource(long cycle_freq) | 376 | static inline void register_rpcc_clocksource(long cycle_freq) |
377 | { | 377 | { |
378 | clocksource_calc_mult_shift(&clocksource_rpcc, cycle_freq, 4); | 378 | clocksource_register_hz(&clocksource_rpcc, cycle_freq); |
379 | clocksource_register(&clocksource_rpcc); | ||
380 | } | 379 | } |
381 | #else /* !CONFIG_SMP */ | 380 | #else /* !CONFIG_SMP */ |
382 | static inline void register_rpcc_clocksource(long cycle_freq) | 381 | static inline void register_rpcc_clocksource(long cycle_freq) |
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 8ebbb511c78..0c6852d9350 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile | |||
@@ -74,7 +74,7 @@ ZTEXTADDR := $(CONFIG_ZBOOT_ROM_TEXT) | |||
74 | ZBSSADDR := $(CONFIG_ZBOOT_ROM_BSS) | 74 | ZBSSADDR := $(CONFIG_ZBOOT_ROM_BSS) |
75 | else | 75 | else |
76 | ZTEXTADDR := 0 | 76 | ZTEXTADDR := 0 |
77 | ZBSSADDR := ALIGN(4) | 77 | ZBSSADDR := ALIGN(8) |
78 | endif | 78 | endif |
79 | 79 | ||
80 | SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/ | 80 | SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/ |
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index adf583cd0c3..49f5b2eaaa8 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S | |||
@@ -179,15 +179,14 @@ not_angel: | |||
179 | bl cache_on | 179 | bl cache_on |
180 | 180 | ||
181 | restart: adr r0, LC0 | 181 | restart: adr r0, LC0 |
182 | ldmia r0, {r1, r2, r3, r5, r6, r9, r11, r12} | 182 | ldmia r0, {r1, r2, r3, r6, r9, r11, r12} |
183 | ldr sp, [r0, #32] | 183 | ldr sp, [r0, #28] |
184 | 184 | ||
185 | /* | 185 | /* |
186 | * We might be running at a different address. We need | 186 | * We might be running at a different address. We need |
187 | * to fix up various pointers. | 187 | * to fix up various pointers. |
188 | */ | 188 | */ |
189 | sub r0, r0, r1 @ calculate the delta offset | 189 | sub r0, r0, r1 @ calculate the delta offset |
190 | add r5, r5, r0 @ _start | ||
191 | add r6, r6, r0 @ _edata | 190 | add r6, r6, r0 @ _edata |
192 | 191 | ||
193 | #ifndef CONFIG_ZBOOT_ROM | 192 | #ifndef CONFIG_ZBOOT_ROM |
@@ -206,31 +205,40 @@ restart: adr r0, LC0 | |||
206 | /* | 205 | /* |
207 | * Check to see if we will overwrite ourselves. | 206 | * Check to see if we will overwrite ourselves. |
208 | * r4 = final kernel address | 207 | * r4 = final kernel address |
209 | * r5 = start of this image | ||
210 | * r9 = size of decompressed image | 208 | * r9 = size of decompressed image |
211 | * r10 = end of this image, including bss/stack/malloc space if non XIP | 209 | * r10 = end of this image, including bss/stack/malloc space if non XIP |
212 | * We basically want: | 210 | * We basically want: |
213 | * r4 >= r10 -> OK | 211 | * r4 - 16k page directory >= r10 -> OK |
214 | * r4 + image length <= r5 -> OK | 212 | * r4 + image length <= current position (pc) -> OK |
215 | */ | 213 | */ |
214 | add r10, r10, #16384 | ||
216 | cmp r4, r10 | 215 | cmp r4, r10 |
217 | bhs wont_overwrite | 216 | bhs wont_overwrite |
218 | add r10, r4, r9 | 217 | add r10, r4, r9 |
219 | cmp r10, r5 | 218 | ARM( cmp r10, pc ) |
219 | THUMB( mov lr, pc ) | ||
220 | THUMB( cmp r10, lr ) | ||
220 | bls wont_overwrite | 221 | bls wont_overwrite |
221 | 222 | ||
222 | /* | 223 | /* |
223 | * Relocate ourselves past the end of the decompressed kernel. | 224 | * Relocate ourselves past the end of the decompressed kernel. |
224 | * r5 = start of this image | ||
225 | * r6 = _edata | 225 | * r6 = _edata |
226 | * r10 = end of the decompressed kernel | 226 | * r10 = end of the decompressed kernel |
227 | * Because we always copy ahead, we need to do it from the end and go | 227 | * Because we always copy ahead, we need to do it from the end and go |
228 | * backward in case the source and destination overlap. | 228 | * backward in case the source and destination overlap. |
229 | */ | 229 | */ |
230 | /* Round up to next 256-byte boundary. */ | 230 | /* |
231 | add r10, r10, #256 | 231 | * Bump to the next 256-byte boundary with the size of |
232 | * the relocation code added. This avoids overwriting | ||
233 | * ourself when the offset is small. | ||
234 | */ | ||
235 | add r10, r10, #((reloc_code_end - restart + 256) & ~255) | ||
232 | bic r10, r10, #255 | 236 | bic r10, r10, #255 |
233 | 237 | ||
238 | /* Get start of code we want to copy and align it down. */ | ||
239 | adr r5, restart | ||
240 | bic r5, r5, #31 | ||
241 | |||
234 | sub r9, r6, r5 @ size to copy | 242 | sub r9, r6, r5 @ size to copy |
235 | add r9, r9, #31 @ rounded up to a multiple | 243 | add r9, r9, #31 @ rounded up to a multiple |
236 | bic r9, r9, #31 @ ... of 32 bytes | 244 | bic r9, r9, #31 @ ... of 32 bytes |
@@ -245,6 +253,11 @@ restart: adr r0, LC0 | |||
245 | /* Preserve offset to relocated code. */ | 253 | /* Preserve offset to relocated code. */ |
246 | sub r6, r9, r6 | 254 | sub r6, r9, r6 |
247 | 255 | ||
256 | #ifndef CONFIG_ZBOOT_ROM | ||
257 | /* cache_clean_flush may use the stack, so relocate it */ | ||
258 | add sp, sp, r6 | ||
259 | #endif | ||
260 | |||
248 | bl cache_clean_flush | 261 | bl cache_clean_flush |
249 | 262 | ||
250 | adr r0, BSYM(restart) | 263 | adr r0, BSYM(restart) |
@@ -333,7 +346,6 @@ not_relocated: mov r0, #0 | |||
333 | LC0: .word LC0 @ r1 | 346 | LC0: .word LC0 @ r1 |
334 | .word __bss_start @ r2 | 347 | .word __bss_start @ r2 |
335 | .word _end @ r3 | 348 | .word _end @ r3 |
336 | .word _start @ r5 | ||
337 | .word _edata @ r6 | 349 | .word _edata @ r6 |
338 | .word _image_size @ r9 | 350 | .word _image_size @ r9 |
339 | .word _got_start @ r11 | 351 | .word _got_start @ r11 |
@@ -1062,6 +1074,7 @@ memdump: mov r12, r0 | |||
1062 | #endif | 1074 | #endif |
1063 | 1075 | ||
1064 | .ltorg | 1076 | .ltorg |
1077 | reloc_code_end: | ||
1065 | 1078 | ||
1066 | .align | 1079 | .align |
1067 | .section ".stack", "aw", %nobits | 1080 | .section ".stack", "aw", %nobits |
diff --git a/arch/arm/boot/compressed/vmlinux.lds.in b/arch/arm/boot/compressed/vmlinux.lds.in index 5309909d728..ea80abe7884 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.in +++ b/arch/arm/boot/compressed/vmlinux.lds.in | |||
@@ -54,6 +54,7 @@ SECTIONS | |||
54 | .bss : { *(.bss) } | 54 | .bss : { *(.bss) } |
55 | _end = .; | 55 | _end = .; |
56 | 56 | ||
57 | . = ALIGN(8); /* the stack must be 64-bit aligned */ | ||
57 | .stack : { *(.stack) } | 58 | .stack : { *(.stack) } |
58 | 59 | ||
59 | .stab 0 : { *(.stab) } | 60 | .stab 0 : { *(.stab) } |
diff --git a/arch/arm/configs/at91x40_defconfig b/arch/arm/configs/at91x40_defconfig new file mode 100644 index 00000000000..c55e9212fcb --- /dev/null +++ b/arch/arm/configs/at91x40_defconfig | |||
@@ -0,0 +1,48 @@ | |||
1 | CONFIG_EXPERIMENTAL=y | ||
2 | CONFIG_LOG_BUF_SHIFT=14 | ||
3 | CONFIG_EMBEDDED=y | ||
4 | # CONFIG_HOTPLUG is not set | ||
5 | # CONFIG_ELF_CORE is not set | ||
6 | # CONFIG_FUTEX is not set | ||
7 | # CONFIG_TIMERFD is not set | ||
8 | # CONFIG_VM_EVENT_COUNTERS is not set | ||
9 | # CONFIG_COMPAT_BRK is not set | ||
10 | CONFIG_SLAB=y | ||
11 | # CONFIG_LBDAF is not set | ||
12 | # CONFIG_BLK_DEV_BSG is not set | ||
13 | # CONFIG_IOSCHED_DEADLINE is not set | ||
14 | # CONFIG_IOSCHED_CFQ is not set | ||
15 | # CONFIG_MMU is not set | ||
16 | CONFIG_ARCH_AT91=y | ||
17 | CONFIG_ARCH_AT91X40=y | ||
18 | CONFIG_MACH_AT91EB01=y | ||
19 | CONFIG_AT91_EARLY_USART0=y | ||
20 | CONFIG_CPU_ARM7TDMI=y | ||
21 | CONFIG_SET_MEM_PARAM=y | ||
22 | CONFIG_DRAM_BASE=0x01000000 | ||
23 | CONFIG_DRAM_SIZE=0x00400000 | ||
24 | CONFIG_FLASH_MEM_BASE=0x01400000 | ||
25 | CONFIG_PROCESSOR_ID=0x14000040 | ||
26 | CONFIG_ZBOOT_ROM_TEXT=0x0 | ||
27 | CONFIG_ZBOOT_ROM_BSS=0x0 | ||
28 | CONFIG_BINFMT_FLAT=y | ||
29 | # CONFIG_SUSPEND is not set | ||
30 | # CONFIG_FW_LOADER is not set | ||
31 | CONFIG_MTD=y | ||
32 | CONFIG_MTD_PARTITIONS=y | ||
33 | CONFIG_MTD_CHAR=y | ||
34 | CONFIG_MTD_BLOCK=y | ||
35 | CONFIG_MTD_RAM=y | ||
36 | CONFIG_MTD_ROM=y | ||
37 | CONFIG_BLK_DEV_RAM=y | ||
38 | # CONFIG_INPUT is not set | ||
39 | # CONFIG_SERIO is not set | ||
40 | # CONFIG_VT is not set | ||
41 | # CONFIG_DEVKMEM is not set | ||
42 | # CONFIG_HW_RANDOM is not set | ||
43 | # CONFIG_HWMON is not set | ||
44 | # CONFIG_USB_SUPPORT is not set | ||
45 | CONFIG_EXT2_FS=y | ||
46 | # CONFIG_DNOTIFY is not set | ||
47 | CONFIG_ROMFS_FS=y | ||
48 | # CONFIG_ENABLE_MUST_CHECK is not set | ||
diff --git a/arch/arm/include/asm/kprobes.h b/arch/arm/include/asm/kprobes.h index bb8a19bd582..e46bdd0097e 100644 --- a/arch/arm/include/asm/kprobes.h +++ b/arch/arm/include/asm/kprobes.h | |||
@@ -39,10 +39,13 @@ typedef u32 kprobe_opcode_t; | |||
39 | struct kprobe; | 39 | struct kprobe; |
40 | typedef void (kprobe_insn_handler_t)(struct kprobe *, struct pt_regs *); | 40 | typedef void (kprobe_insn_handler_t)(struct kprobe *, struct pt_regs *); |
41 | 41 | ||
42 | typedef unsigned long (kprobe_check_cc)(unsigned long); | ||
43 | |||
42 | /* Architecture specific copy of original instruction. */ | 44 | /* Architecture specific copy of original instruction. */ |
43 | struct arch_specific_insn { | 45 | struct arch_specific_insn { |
44 | kprobe_opcode_t *insn; | 46 | kprobe_opcode_t *insn; |
45 | kprobe_insn_handler_t *insn_handler; | 47 | kprobe_insn_handler_t *insn_handler; |
48 | kprobe_check_cc *insn_check_cc; | ||
46 | }; | 49 | }; |
47 | 50 | ||
48 | struct prev_kprobe { | 51 | struct prev_kprobe { |
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h index 885be097769..832888d0c20 100644 --- a/arch/arm/include/asm/system.h +++ b/arch/arm/include/asm/system.h | |||
@@ -159,7 +159,7 @@ extern unsigned int user_debug; | |||
159 | #include <mach/barriers.h> | 159 | #include <mach/barriers.h> |
160 | #elif defined(CONFIG_ARM_DMA_MEM_BUFFERABLE) || defined(CONFIG_SMP) | 160 | #elif defined(CONFIG_ARM_DMA_MEM_BUFFERABLE) || defined(CONFIG_SMP) |
161 | #define mb() do { dsb(); outer_sync(); } while (0) | 161 | #define mb() do { dsb(); outer_sync(); } while (0) |
162 | #define rmb() dmb() | 162 | #define rmb() dsb() |
163 | #define wmb() mb() | 163 | #define wmb() mb() |
164 | #else | 164 | #else |
165 | #include <asm/memory.h> | 165 | #include <asm/memory.h> |
diff --git a/arch/arm/kernel/kprobes-decode.c b/arch/arm/kernel/kprobes-decode.c index 23891317dc4..15eeff6aea0 100644 --- a/arch/arm/kernel/kprobes-decode.c +++ b/arch/arm/kernel/kprobes-decode.c | |||
@@ -34,9 +34,6 @@ | |||
34 | * | 34 | * |
35 | * *) If the PC is written to by the instruction, the | 35 | * *) If the PC is written to by the instruction, the |
36 | * instruction must be fully simulated in software. | 36 | * instruction must be fully simulated in software. |
37 | * If it is a conditional instruction, the handler | ||
38 | * will use insn[0] to copy its condition code to | ||
39 | * set r0 to 1 and insn[1] to "mov pc, lr" to return. | ||
40 | * | 37 | * |
41 | * *) Otherwise, a modified form of the instruction is | 38 | * *) Otherwise, a modified form of the instruction is |
42 | * directly executed. Its handler calls the | 39 | * directly executed. Its handler calls the |
@@ -68,13 +65,17 @@ | |||
68 | 65 | ||
69 | #define branch_displacement(insn) sign_extend(((insn) & 0xffffff) << 2, 25) | 66 | #define branch_displacement(insn) sign_extend(((insn) & 0xffffff) << 2, 25) |
70 | 67 | ||
68 | #define is_r15(insn, bitpos) (((insn) & (0xf << bitpos)) == (0xf << bitpos)) | ||
69 | |||
70 | /* | ||
71 | * Test if load/store instructions writeback the address register. | ||
72 | * if P (bit 24) == 0 or W (bit 21) == 1 | ||
73 | */ | ||
74 | #define is_writeback(insn) ((insn ^ 0x01000000) & 0x01200000) | ||
75 | |||
71 | #define PSR_fs (PSR_f|PSR_s) | 76 | #define PSR_fs (PSR_f|PSR_s) |
72 | 77 | ||
73 | #define KPROBE_RETURN_INSTRUCTION 0xe1a0f00e /* mov pc, lr */ | 78 | #define KPROBE_RETURN_INSTRUCTION 0xe1a0f00e /* mov pc, lr */ |
74 | #define SET_R0_TRUE_INSTRUCTION 0xe3a00001 /* mov r0, #1 */ | ||
75 | |||
76 | #define truecc_insn(insn) (((insn) & 0xf0000000) | \ | ||
77 | (SET_R0_TRUE_INSTRUCTION & 0x0fffffff)) | ||
78 | 79 | ||
79 | typedef long (insn_0arg_fn_t)(void); | 80 | typedef long (insn_0arg_fn_t)(void); |
80 | typedef long (insn_1arg_fn_t)(long); | 81 | typedef long (insn_1arg_fn_t)(long); |
@@ -419,14 +420,10 @@ insnslot_llret_4arg_rwflags(long r0, long r1, long r2, long r3, long *cpsr, | |||
419 | 420 | ||
420 | static void __kprobes simulate_bbl(struct kprobe *p, struct pt_regs *regs) | 421 | static void __kprobes simulate_bbl(struct kprobe *p, struct pt_regs *regs) |
421 | { | 422 | { |
422 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; | ||
423 | kprobe_opcode_t insn = p->opcode; | 423 | kprobe_opcode_t insn = p->opcode; |
424 | long iaddr = (long)p->addr; | 424 | long iaddr = (long)p->addr; |
425 | int disp = branch_displacement(insn); | 425 | int disp = branch_displacement(insn); |
426 | 426 | ||
427 | if (!insnslot_1arg_rflags(0, regs->ARM_cpsr, i_fn)) | ||
428 | return; | ||
429 | |||
430 | if (insn & (1 << 24)) | 427 | if (insn & (1 << 24)) |
431 | regs->ARM_lr = iaddr + 4; | 428 | regs->ARM_lr = iaddr + 4; |
432 | 429 | ||
@@ -446,14 +443,10 @@ static void __kprobes simulate_blx1(struct kprobe *p, struct pt_regs *regs) | |||
446 | 443 | ||
447 | static void __kprobes simulate_blx2bx(struct kprobe *p, struct pt_regs *regs) | 444 | static void __kprobes simulate_blx2bx(struct kprobe *p, struct pt_regs *regs) |
448 | { | 445 | { |
449 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; | ||
450 | kprobe_opcode_t insn = p->opcode; | 446 | kprobe_opcode_t insn = p->opcode; |
451 | int rm = insn & 0xf; | 447 | int rm = insn & 0xf; |
452 | long rmv = regs->uregs[rm]; | 448 | long rmv = regs->uregs[rm]; |
453 | 449 | ||
454 | if (!insnslot_1arg_rflags(0, regs->ARM_cpsr, i_fn)) | ||
455 | return; | ||
456 | |||
457 | if (insn & (1 << 5)) | 450 | if (insn & (1 << 5)) |
458 | regs->ARM_lr = (long)p->addr + 4; | 451 | regs->ARM_lr = (long)p->addr + 4; |
459 | 452 | ||
@@ -463,9 +456,16 @@ static void __kprobes simulate_blx2bx(struct kprobe *p, struct pt_regs *regs) | |||
463 | regs->ARM_cpsr |= PSR_T_BIT; | 456 | regs->ARM_cpsr |= PSR_T_BIT; |
464 | } | 457 | } |
465 | 458 | ||
459 | static void __kprobes simulate_mrs(struct kprobe *p, struct pt_regs *regs) | ||
460 | { | ||
461 | kprobe_opcode_t insn = p->opcode; | ||
462 | int rd = (insn >> 12) & 0xf; | ||
463 | unsigned long mask = 0xf8ff03df; /* Mask out execution state */ | ||
464 | regs->uregs[rd] = regs->ARM_cpsr & mask; | ||
465 | } | ||
466 | |||
466 | static void __kprobes simulate_ldm1stm1(struct kprobe *p, struct pt_regs *regs) | 467 | static void __kprobes simulate_ldm1stm1(struct kprobe *p, struct pt_regs *regs) |
467 | { | 468 | { |
468 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; | ||
469 | kprobe_opcode_t insn = p->opcode; | 469 | kprobe_opcode_t insn = p->opcode; |
470 | int rn = (insn >> 16) & 0xf; | 470 | int rn = (insn >> 16) & 0xf; |
471 | int lbit = insn & (1 << 20); | 471 | int lbit = insn & (1 << 20); |
@@ -476,9 +476,6 @@ static void __kprobes simulate_ldm1stm1(struct kprobe *p, struct pt_regs *regs) | |||
476 | int reg_bit_vector; | 476 | int reg_bit_vector; |
477 | int reg_count; | 477 | int reg_count; |
478 | 478 | ||
479 | if (!insnslot_1arg_rflags(0, regs->ARM_cpsr, i_fn)) | ||
480 | return; | ||
481 | |||
482 | reg_count = 0; | 479 | reg_count = 0; |
483 | reg_bit_vector = insn & 0xffff; | 480 | reg_bit_vector = insn & 0xffff; |
484 | while (reg_bit_vector) { | 481 | while (reg_bit_vector) { |
@@ -510,11 +507,6 @@ static void __kprobes simulate_ldm1stm1(struct kprobe *p, struct pt_regs *regs) | |||
510 | 507 | ||
511 | static void __kprobes simulate_stm1_pc(struct kprobe *p, struct pt_regs *regs) | 508 | static void __kprobes simulate_stm1_pc(struct kprobe *p, struct pt_regs *regs) |
512 | { | 509 | { |
513 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; | ||
514 | |||
515 | if (!insnslot_1arg_rflags(0, regs->ARM_cpsr, i_fn)) | ||
516 | return; | ||
517 | |||
518 | regs->ARM_pc = (long)p->addr + str_pc_offset; | 510 | regs->ARM_pc = (long)p->addr + str_pc_offset; |
519 | simulate_ldm1stm1(p, regs); | 511 | simulate_ldm1stm1(p, regs); |
520 | regs->ARM_pc = (long)p->addr + 4; | 512 | regs->ARM_pc = (long)p->addr + 4; |
@@ -525,24 +517,16 @@ static void __kprobes simulate_mov_ipsp(struct kprobe *p, struct pt_regs *regs) | |||
525 | regs->uregs[12] = regs->uregs[13]; | 517 | regs->uregs[12] = regs->uregs[13]; |
526 | } | 518 | } |
527 | 519 | ||
528 | static void __kprobes emulate_ldcstc(struct kprobe *p, struct pt_regs *regs) | ||
529 | { | ||
530 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; | ||
531 | kprobe_opcode_t insn = p->opcode; | ||
532 | int rn = (insn >> 16) & 0xf; | ||
533 | long rnv = regs->uregs[rn]; | ||
534 | |||
535 | /* Save Rn in case of writeback. */ | ||
536 | regs->uregs[rn] = insnslot_1arg_rflags(rnv, regs->ARM_cpsr, i_fn); | ||
537 | } | ||
538 | |||
539 | static void __kprobes emulate_ldrd(struct kprobe *p, struct pt_regs *regs) | 520 | static void __kprobes emulate_ldrd(struct kprobe *p, struct pt_regs *regs) |
540 | { | 521 | { |
541 | insn_2arg_fn_t *i_fn = (insn_2arg_fn_t *)&p->ainsn.insn[0]; | 522 | insn_2arg_fn_t *i_fn = (insn_2arg_fn_t *)&p->ainsn.insn[0]; |
542 | kprobe_opcode_t insn = p->opcode; | 523 | kprobe_opcode_t insn = p->opcode; |
524 | long ppc = (long)p->addr + 8; | ||
543 | int rd = (insn >> 12) & 0xf; | 525 | int rd = (insn >> 12) & 0xf; |
544 | int rn = (insn >> 16) & 0xf; | 526 | int rn = (insn >> 16) & 0xf; |
545 | int rm = insn & 0xf; /* rm may be invalid, don't care. */ | 527 | int rm = insn & 0xf; /* rm may be invalid, don't care. */ |
528 | long rmv = (rm == 15) ? ppc : regs->uregs[rm]; | ||
529 | long rnv = (rn == 15) ? ppc : regs->uregs[rn]; | ||
546 | 530 | ||
547 | /* Not following the C calling convention here, so need asm(). */ | 531 | /* Not following the C calling convention here, so need asm(). */ |
548 | __asm__ __volatile__ ( | 532 | __asm__ __volatile__ ( |
@@ -554,29 +538,36 @@ static void __kprobes emulate_ldrd(struct kprobe *p, struct pt_regs *regs) | |||
554 | "str r0, %[rn] \n\t" /* in case of writeback */ | 538 | "str r0, %[rn] \n\t" /* in case of writeback */ |
555 | "str r2, %[rd0] \n\t" | 539 | "str r2, %[rd0] \n\t" |
556 | "str r3, %[rd1] \n\t" | 540 | "str r3, %[rd1] \n\t" |
557 | : [rn] "+m" (regs->uregs[rn]), | 541 | : [rn] "+m" (rnv), |
558 | [rd0] "=m" (regs->uregs[rd]), | 542 | [rd0] "=m" (regs->uregs[rd]), |
559 | [rd1] "=m" (regs->uregs[rd+1]) | 543 | [rd1] "=m" (regs->uregs[rd+1]) |
560 | : [rm] "m" (regs->uregs[rm]), | 544 | : [rm] "m" (rmv), |
561 | [cpsr] "r" (regs->ARM_cpsr), | 545 | [cpsr] "r" (regs->ARM_cpsr), |
562 | [i_fn] "r" (i_fn) | 546 | [i_fn] "r" (i_fn) |
563 | : "r0", "r1", "r2", "r3", "lr", "cc" | 547 | : "r0", "r1", "r2", "r3", "lr", "cc" |
564 | ); | 548 | ); |
549 | if (is_writeback(insn)) | ||
550 | regs->uregs[rn] = rnv; | ||
565 | } | 551 | } |
566 | 552 | ||
567 | static void __kprobes emulate_strd(struct kprobe *p, struct pt_regs *regs) | 553 | static void __kprobes emulate_strd(struct kprobe *p, struct pt_regs *regs) |
568 | { | 554 | { |
569 | insn_4arg_fn_t *i_fn = (insn_4arg_fn_t *)&p->ainsn.insn[0]; | 555 | insn_4arg_fn_t *i_fn = (insn_4arg_fn_t *)&p->ainsn.insn[0]; |
570 | kprobe_opcode_t insn = p->opcode; | 556 | kprobe_opcode_t insn = p->opcode; |
557 | long ppc = (long)p->addr + 8; | ||
571 | int rd = (insn >> 12) & 0xf; | 558 | int rd = (insn >> 12) & 0xf; |
572 | int rn = (insn >> 16) & 0xf; | 559 | int rn = (insn >> 16) & 0xf; |
573 | int rm = insn & 0xf; | 560 | int rm = insn & 0xf; |
574 | long rnv = regs->uregs[rn]; | 561 | long rnv = (rn == 15) ? ppc : regs->uregs[rn]; |
575 | long rmv = regs->uregs[rm]; /* rm/rmv may be invalid, don't care. */ | 562 | /* rm/rmv may be invalid, don't care. */ |
563 | long rmv = (rm == 15) ? ppc : regs->uregs[rm]; | ||
564 | long rnv_wb; | ||
576 | 565 | ||
577 | regs->uregs[rn] = insnslot_4arg_rflags(rnv, rmv, regs->uregs[rd], | 566 | rnv_wb = insnslot_4arg_rflags(rnv, rmv, regs->uregs[rd], |
578 | regs->uregs[rd+1], | 567 | regs->uregs[rd+1], |
579 | regs->ARM_cpsr, i_fn); | 568 | regs->ARM_cpsr, i_fn); |
569 | if (is_writeback(insn)) | ||
570 | regs->uregs[rn] = rnv_wb; | ||
580 | } | 571 | } |
581 | 572 | ||
582 | static void __kprobes emulate_ldr(struct kprobe *p, struct pt_regs *regs) | 573 | static void __kprobes emulate_ldr(struct kprobe *p, struct pt_regs *regs) |
@@ -630,31 +621,6 @@ static void __kprobes emulate_str(struct kprobe *p, struct pt_regs *regs) | |||
630 | regs->uregs[rn] = rnv_wb; /* Save Rn in case of writeback. */ | 621 | regs->uregs[rn] = rnv_wb; /* Save Rn in case of writeback. */ |
631 | } | 622 | } |
632 | 623 | ||
633 | static void __kprobes emulate_mrrc(struct kprobe *p, struct pt_regs *regs) | ||
634 | { | ||
635 | insn_llret_0arg_fn_t *i_fn = (insn_llret_0arg_fn_t *)&p->ainsn.insn[0]; | ||
636 | kprobe_opcode_t insn = p->opcode; | ||
637 | union reg_pair fnr; | ||
638 | int rd = (insn >> 12) & 0xf; | ||
639 | int rn = (insn >> 16) & 0xf; | ||
640 | |||
641 | fnr.dr = insnslot_llret_0arg_rflags(regs->ARM_cpsr, i_fn); | ||
642 | regs->uregs[rn] = fnr.r0; | ||
643 | regs->uregs[rd] = fnr.r1; | ||
644 | } | ||
645 | |||
646 | static void __kprobes emulate_mcrr(struct kprobe *p, struct pt_regs *regs) | ||
647 | { | ||
648 | insn_2arg_fn_t *i_fn = (insn_2arg_fn_t *)&p->ainsn.insn[0]; | ||
649 | kprobe_opcode_t insn = p->opcode; | ||
650 | int rd = (insn >> 12) & 0xf; | ||
651 | int rn = (insn >> 16) & 0xf; | ||
652 | long rnv = regs->uregs[rn]; | ||
653 | long rdv = regs->uregs[rd]; | ||
654 | |||
655 | insnslot_2arg_rflags(rnv, rdv, regs->ARM_cpsr, i_fn); | ||
656 | } | ||
657 | |||
658 | static void __kprobes emulate_sat(struct kprobe *p, struct pt_regs *regs) | 624 | static void __kprobes emulate_sat(struct kprobe *p, struct pt_regs *regs) |
659 | { | 625 | { |
660 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; | 626 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; |
@@ -688,32 +654,32 @@ static void __kprobes emulate_none(struct kprobe *p, struct pt_regs *regs) | |||
688 | insnslot_0arg_rflags(regs->ARM_cpsr, i_fn); | 654 | insnslot_0arg_rflags(regs->ARM_cpsr, i_fn); |
689 | } | 655 | } |
690 | 656 | ||
691 | static void __kprobes emulate_rd12(struct kprobe *p, struct pt_regs *regs) | 657 | static void __kprobes emulate_nop(struct kprobe *p, struct pt_regs *regs) |
692 | { | 658 | { |
693 | insn_0arg_fn_t *i_fn = (insn_0arg_fn_t *)&p->ainsn.insn[0]; | ||
694 | kprobe_opcode_t insn = p->opcode; | ||
695 | int rd = (insn >> 12) & 0xf; | ||
696 | |||
697 | regs->uregs[rd] = insnslot_0arg_rflags(regs->ARM_cpsr, i_fn); | ||
698 | } | 659 | } |
699 | 660 | ||
700 | static void __kprobes emulate_ird12(struct kprobe *p, struct pt_regs *regs) | 661 | static void __kprobes |
662 | emulate_rd12_modify(struct kprobe *p, struct pt_regs *regs) | ||
701 | { | 663 | { |
702 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; | 664 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; |
703 | kprobe_opcode_t insn = p->opcode; | 665 | kprobe_opcode_t insn = p->opcode; |
704 | int ird = (insn >> 12) & 0xf; | 666 | int rd = (insn >> 12) & 0xf; |
667 | long rdv = regs->uregs[rd]; | ||
705 | 668 | ||
706 | insnslot_1arg_rflags(regs->uregs[ird], regs->ARM_cpsr, i_fn); | 669 | regs->uregs[rd] = insnslot_1arg_rflags(rdv, regs->ARM_cpsr, i_fn); |
707 | } | 670 | } |
708 | 671 | ||
709 | static void __kprobes emulate_rn16(struct kprobe *p, struct pt_regs *regs) | 672 | static void __kprobes |
673 | emulate_rd12rn0_modify(struct kprobe *p, struct pt_regs *regs) | ||
710 | { | 674 | { |
711 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; | 675 | insn_2arg_fn_t *i_fn = (insn_2arg_fn_t *)&p->ainsn.insn[0]; |
712 | kprobe_opcode_t insn = p->opcode; | 676 | kprobe_opcode_t insn = p->opcode; |
713 | int rn = (insn >> 16) & 0xf; | 677 | int rd = (insn >> 12) & 0xf; |
678 | int rn = insn & 0xf; | ||
679 | long rdv = regs->uregs[rd]; | ||
714 | long rnv = regs->uregs[rn]; | 680 | long rnv = regs->uregs[rn]; |
715 | 681 | ||
716 | insnslot_1arg_rflags(rnv, regs->ARM_cpsr, i_fn); | 682 | regs->uregs[rd] = insnslot_2arg_rflags(rdv, rnv, regs->ARM_cpsr, i_fn); |
717 | } | 683 | } |
718 | 684 | ||
719 | static void __kprobes emulate_rd12rm0(struct kprobe *p, struct pt_regs *regs) | 685 | static void __kprobes emulate_rd12rm0(struct kprobe *p, struct pt_regs *regs) |
@@ -819,6 +785,17 @@ emulate_alu_imm_rwflags(struct kprobe *p, struct pt_regs *regs) | |||
819 | } | 785 | } |
820 | 786 | ||
821 | static void __kprobes | 787 | static void __kprobes |
788 | emulate_alu_tests_imm(struct kprobe *p, struct pt_regs *regs) | ||
789 | { | ||
790 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; | ||
791 | kprobe_opcode_t insn = p->opcode; | ||
792 | int rn = (insn >> 16) & 0xf; | ||
793 | long rnv = (rn == 15) ? (long)p->addr + 8 : regs->uregs[rn]; | ||
794 | |||
795 | insnslot_1arg_rwflags(rnv, ®s->ARM_cpsr, i_fn); | ||
796 | } | ||
797 | |||
798 | static void __kprobes | ||
822 | emulate_alu_rflags(struct kprobe *p, struct pt_regs *regs) | 799 | emulate_alu_rflags(struct kprobe *p, struct pt_regs *regs) |
823 | { | 800 | { |
824 | insn_3arg_fn_t *i_fn = (insn_3arg_fn_t *)&p->ainsn.insn[0]; | 801 | insn_3arg_fn_t *i_fn = (insn_3arg_fn_t *)&p->ainsn.insn[0]; |
@@ -854,14 +831,34 @@ emulate_alu_rwflags(struct kprobe *p, struct pt_regs *regs) | |||
854 | insnslot_3arg_rwflags(rnv, rmv, rsv, ®s->ARM_cpsr, i_fn); | 831 | insnslot_3arg_rwflags(rnv, rmv, rsv, ®s->ARM_cpsr, i_fn); |
855 | } | 832 | } |
856 | 833 | ||
834 | static void __kprobes | ||
835 | emulate_alu_tests(struct kprobe *p, struct pt_regs *regs) | ||
836 | { | ||
837 | insn_3arg_fn_t *i_fn = (insn_3arg_fn_t *)&p->ainsn.insn[0]; | ||
838 | kprobe_opcode_t insn = p->opcode; | ||
839 | long ppc = (long)p->addr + 8; | ||
840 | int rn = (insn >> 16) & 0xf; | ||
841 | int rs = (insn >> 8) & 0xf; /* rs/rsv may be invalid, don't care. */ | ||
842 | int rm = insn & 0xf; | ||
843 | long rnv = (rn == 15) ? ppc : regs->uregs[rn]; | ||
844 | long rmv = (rm == 15) ? ppc : regs->uregs[rm]; | ||
845 | long rsv = regs->uregs[rs]; | ||
846 | |||
847 | insnslot_3arg_rwflags(rnv, rmv, rsv, ®s->ARM_cpsr, i_fn); | ||
848 | } | ||
849 | |||
857 | static enum kprobe_insn __kprobes | 850 | static enum kprobe_insn __kprobes |
858 | prep_emulate_ldr_str(kprobe_opcode_t insn, struct arch_specific_insn *asi) | 851 | prep_emulate_ldr_str(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
859 | { | 852 | { |
860 | int ibit = (insn & (1 << 26)) ? 25 : 22; | 853 | int not_imm = (insn & (1 << 26)) ? (insn & (1 << 25)) |
854 | : (~insn & (1 << 22)); | ||
855 | |||
856 | if (is_writeback(insn) && is_r15(insn, 16)) | ||
857 | return INSN_REJECTED; /* Writeback to PC */ | ||
861 | 858 | ||
862 | insn &= 0xfff00fff; | 859 | insn &= 0xfff00fff; |
863 | insn |= 0x00001000; /* Rn = r0, Rd = r1 */ | 860 | insn |= 0x00001000; /* Rn = r0, Rd = r1 */ |
864 | if (insn & (1 << ibit)) { | 861 | if (not_imm) { |
865 | insn &= ~0xf; | 862 | insn &= ~0xf; |
866 | insn |= 2; /* Rm = r2 */ | 863 | insn |= 2; /* Rm = r2 */ |
867 | } | 864 | } |
@@ -871,20 +868,40 @@ prep_emulate_ldr_str(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
871 | } | 868 | } |
872 | 869 | ||
873 | static enum kprobe_insn __kprobes | 870 | static enum kprobe_insn __kprobes |
874 | prep_emulate_rd12rm0(kprobe_opcode_t insn, struct arch_specific_insn *asi) | 871 | prep_emulate_rd12_modify(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
875 | { | 872 | { |
876 | insn &= 0xffff0ff0; /* Rd = r0, Rm = r0 */ | 873 | if (is_r15(insn, 12)) |
874 | return INSN_REJECTED; /* Rd is PC */ | ||
875 | |||
876 | insn &= 0xffff0fff; /* Rd = r0 */ | ||
877 | asi->insn[0] = insn; | 877 | asi->insn[0] = insn; |
878 | asi->insn_handler = emulate_rd12rm0; | 878 | asi->insn_handler = emulate_rd12_modify; |
879 | return INSN_GOOD; | 879 | return INSN_GOOD; |
880 | } | 880 | } |
881 | 881 | ||
882 | static enum kprobe_insn __kprobes | 882 | static enum kprobe_insn __kprobes |
883 | prep_emulate_rd12(kprobe_opcode_t insn, struct arch_specific_insn *asi) | 883 | prep_emulate_rd12rn0_modify(kprobe_opcode_t insn, |
884 | struct arch_specific_insn *asi) | ||
884 | { | 885 | { |
885 | insn &= 0xffff0fff; /* Rd = r0 */ | 886 | if (is_r15(insn, 12)) |
887 | return INSN_REJECTED; /* Rd is PC */ | ||
888 | |||
889 | insn &= 0xffff0ff0; /* Rd = r0 */ | ||
890 | insn |= 0x00000001; /* Rn = r1 */ | ||
891 | asi->insn[0] = insn; | ||
892 | asi->insn_handler = emulate_rd12rn0_modify; | ||
893 | return INSN_GOOD; | ||
894 | } | ||
895 | |||
896 | static enum kprobe_insn __kprobes | ||
897 | prep_emulate_rd12rm0(kprobe_opcode_t insn, struct arch_specific_insn *asi) | ||
898 | { | ||
899 | if (is_r15(insn, 12)) | ||
900 | return INSN_REJECTED; /* Rd is PC */ | ||
901 | |||
902 | insn &= 0xffff0ff0; /* Rd = r0, Rm = r0 */ | ||
886 | asi->insn[0] = insn; | 903 | asi->insn[0] = insn; |
887 | asi->insn_handler = emulate_rd12; | 904 | asi->insn_handler = emulate_rd12rm0; |
888 | return INSN_GOOD; | 905 | return INSN_GOOD; |
889 | } | 906 | } |
890 | 907 | ||
@@ -892,6 +909,9 @@ static enum kprobe_insn __kprobes | |||
892 | prep_emulate_rd12rn16rm0_wflags(kprobe_opcode_t insn, | 909 | prep_emulate_rd12rn16rm0_wflags(kprobe_opcode_t insn, |
893 | struct arch_specific_insn *asi) | 910 | struct arch_specific_insn *asi) |
894 | { | 911 | { |
912 | if (is_r15(insn, 12)) | ||
913 | return INSN_REJECTED; /* Rd is PC */ | ||
914 | |||
895 | insn &= 0xfff00ff0; /* Rd = r0, Rn = r0 */ | 915 | insn &= 0xfff00ff0; /* Rd = r0, Rn = r0 */ |
896 | insn |= 0x00000001; /* Rm = r1 */ | 916 | insn |= 0x00000001; /* Rm = r1 */ |
897 | asi->insn[0] = insn; | 917 | asi->insn[0] = insn; |
@@ -903,6 +923,9 @@ static enum kprobe_insn __kprobes | |||
903 | prep_emulate_rd16rs8rm0_wflags(kprobe_opcode_t insn, | 923 | prep_emulate_rd16rs8rm0_wflags(kprobe_opcode_t insn, |
904 | struct arch_specific_insn *asi) | 924 | struct arch_specific_insn *asi) |
905 | { | 925 | { |
926 | if (is_r15(insn, 16)) | ||
927 | return INSN_REJECTED; /* Rd is PC */ | ||
928 | |||
906 | insn &= 0xfff0f0f0; /* Rd = r0, Rs = r0 */ | 929 | insn &= 0xfff0f0f0; /* Rd = r0, Rs = r0 */ |
907 | insn |= 0x00000001; /* Rm = r1 */ | 930 | insn |= 0x00000001; /* Rm = r1 */ |
908 | asi->insn[0] = insn; | 931 | asi->insn[0] = insn; |
@@ -914,6 +937,9 @@ static enum kprobe_insn __kprobes | |||
914 | prep_emulate_rd16rn12rs8rm0_wflags(kprobe_opcode_t insn, | 937 | prep_emulate_rd16rn12rs8rm0_wflags(kprobe_opcode_t insn, |
915 | struct arch_specific_insn *asi) | 938 | struct arch_specific_insn *asi) |
916 | { | 939 | { |
940 | if (is_r15(insn, 16)) | ||
941 | return INSN_REJECTED; /* Rd is PC */ | ||
942 | |||
917 | insn &= 0xfff000f0; /* Rd = r0, Rn = r0 */ | 943 | insn &= 0xfff000f0; /* Rd = r0, Rn = r0 */ |
918 | insn |= 0x00000102; /* Rs = r1, Rm = r2 */ | 944 | insn |= 0x00000102; /* Rs = r1, Rm = r2 */ |
919 | asi->insn[0] = insn; | 945 | asi->insn[0] = insn; |
@@ -925,6 +951,9 @@ static enum kprobe_insn __kprobes | |||
925 | prep_emulate_rdhi16rdlo12rs8rm0_wflags(kprobe_opcode_t insn, | 951 | prep_emulate_rdhi16rdlo12rs8rm0_wflags(kprobe_opcode_t insn, |
926 | struct arch_specific_insn *asi) | 952 | struct arch_specific_insn *asi) |
927 | { | 953 | { |
954 | if (is_r15(insn, 16) || is_r15(insn, 12)) | ||
955 | return INSN_REJECTED; /* RdHi or RdLo is PC */ | ||
956 | |||
928 | insn &= 0xfff000f0; /* RdHi = r0, RdLo = r1 */ | 957 | insn &= 0xfff000f0; /* RdHi = r0, RdLo = r1 */ |
929 | insn |= 0x00001203; /* Rs = r2, Rm = r3 */ | 958 | insn |= 0x00001203; /* Rs = r2, Rm = r3 */ |
930 | asi->insn[0] = insn; | 959 | asi->insn[0] = insn; |
@@ -945,20 +974,13 @@ prep_emulate_rdhi16rdlo12rs8rm0_wflags(kprobe_opcode_t insn, | |||
945 | static enum kprobe_insn __kprobes | 974 | static enum kprobe_insn __kprobes |
946 | space_1111(kprobe_opcode_t insn, struct arch_specific_insn *asi) | 975 | space_1111(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
947 | { | 976 | { |
948 | /* CPS mmod == 1 : 1111 0001 0000 xx10 xxxx xxxx xx0x xxxx */ | 977 | /* memory hint : 1111 0100 x001 xxxx xxxx xxxx xxxx xxxx : */ |
949 | /* RFE : 1111 100x x0x1 xxxx xxxx 1010 xxxx xxxx */ | 978 | /* PLDI : 1111 0100 x101 xxxx xxxx xxxx xxxx xxxx : */ |
950 | /* SRS : 1111 100x x1x0 1101 xxxx 0101 xxxx xxxx */ | 979 | /* PLDW : 1111 0101 x001 xxxx xxxx xxxx xxxx xxxx : */ |
951 | if ((insn & 0xfff30020) == 0xf1020000 || | 980 | /* PLD : 1111 0101 x101 xxxx xxxx xxxx xxxx xxxx : */ |
952 | (insn & 0xfe500f00) == 0xf8100a00 || | 981 | if ((insn & 0xfe300000) == 0xf4100000) { |
953 | (insn & 0xfe5f0f00) == 0xf84d0500) | 982 | asi->insn_handler = emulate_nop; |
954 | return INSN_REJECTED; | 983 | return INSN_GOOD_NO_SLOT; |
955 | |||
956 | /* PLD : 1111 01x1 x101 xxxx xxxx xxxx xxxx xxxx : */ | ||
957 | if ((insn & 0xfd700000) == 0xf4500000) { | ||
958 | insn &= 0xfff0ffff; /* Rn = r0 */ | ||
959 | asi->insn[0] = insn; | ||
960 | asi->insn_handler = emulate_rn16; | ||
961 | return INSN_GOOD; | ||
962 | } | 984 | } |
963 | 985 | ||
964 | /* BLX(1) : 1111 101x xxxx xxxx xxxx xxxx xxxx xxxx : */ | 986 | /* BLX(1) : 1111 101x xxxx xxxx xxxx xxxx xxxx xxxx : */ |
@@ -967,41 +989,22 @@ space_1111(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
967 | return INSN_GOOD_NO_SLOT; | 989 | return INSN_GOOD_NO_SLOT; |
968 | } | 990 | } |
969 | 991 | ||
970 | /* SETEND : 1111 0001 0000 0001 xxxx xxxx 0000 xxxx */ | 992 | /* CPS : 1111 0001 0000 xxx0 xxxx xxxx xx0x xxxx */ |
971 | /* CDP2 : 1111 1110 xxxx xxxx xxxx xxxx xxx0 xxxx */ | 993 | /* SETEND: 1111 0001 0000 0001 xxxx xxxx 0000 xxxx */ |
972 | if ((insn & 0xffff00f0) == 0xf1010000 || | ||
973 | (insn & 0xff000010) == 0xfe000000) { | ||
974 | asi->insn[0] = insn; | ||
975 | asi->insn_handler = emulate_none; | ||
976 | return INSN_GOOD; | ||
977 | } | ||
978 | 994 | ||
995 | /* SRS : 1111 100x x1x0 xxxx xxxx xxxx xxxx xxxx */ | ||
996 | /* RFE : 1111 100x x0x1 xxxx xxxx xxxx xxxx xxxx */ | ||
997 | |||
998 | /* Coprocessor instructions... */ | ||
979 | /* MCRR2 : 1111 1100 0100 xxxx xxxx xxxx xxxx xxxx : (Rd != Rn) */ | 999 | /* MCRR2 : 1111 1100 0100 xxxx xxxx xxxx xxxx xxxx : (Rd != Rn) */ |
980 | /* MRRC2 : 1111 1100 0101 xxxx xxxx xxxx xxxx xxxx : (Rd != Rn) */ | 1000 | /* MRRC2 : 1111 1100 0101 xxxx xxxx xxxx xxxx xxxx : (Rd != Rn) */ |
981 | if ((insn & 0xffe00000) == 0xfc400000) { | 1001 | /* LDC2 : 1111 110x xxx1 xxxx xxxx xxxx xxxx xxxx */ |
982 | insn &= 0xfff00fff; /* Rn = r0 */ | 1002 | /* STC2 : 1111 110x xxx0 xxxx xxxx xxxx xxxx xxxx */ |
983 | insn |= 0x00001000; /* Rd = r1 */ | 1003 | /* CDP2 : 1111 1110 xxxx xxxx xxxx xxxx xxx0 xxxx */ |
984 | asi->insn[0] = insn; | 1004 | /* MCR2 : 1111 1110 xxx0 xxxx xxxx xxxx xxx1 xxxx */ |
985 | asi->insn_handler = | 1005 | /* MRC2 : 1111 1110 xxx1 xxxx xxxx xxxx xxx1 xxxx */ |
986 | (insn & (1 << 20)) ? emulate_mrrc : emulate_mcrr; | ||
987 | return INSN_GOOD; | ||
988 | } | ||
989 | 1006 | ||
990 | /* LDC2 : 1111 110x xxx1 xxxx xxxx xxxx xxxx xxxx */ | 1007 | return INSN_REJECTED; |
991 | /* STC2 : 1111 110x xxx0 xxxx xxxx xxxx xxxx xxxx */ | ||
992 | if ((insn & 0xfe000000) == 0xfc000000) { | ||
993 | insn &= 0xfff0ffff; /* Rn = r0 */ | ||
994 | asi->insn[0] = insn; | ||
995 | asi->insn_handler = emulate_ldcstc; | ||
996 | return INSN_GOOD; | ||
997 | } | ||
998 | |||
999 | /* MCR2 : 1111 1110 xxx0 xxxx xxxx xxxx xxx1 xxxx */ | ||
1000 | /* MRC2 : 1111 1110 xxx1 xxxx xxxx xxxx xxx1 xxxx */ | ||
1001 | insn &= 0xffff0fff; /* Rd = r0 */ | ||
1002 | asi->insn[0] = insn; | ||
1003 | asi->insn_handler = (insn & (1 << 20)) ? emulate_rd12 : emulate_ird12; | ||
1004 | return INSN_GOOD; | ||
1005 | } | 1008 | } |
1006 | 1009 | ||
1007 | static enum kprobe_insn __kprobes | 1010 | static enum kprobe_insn __kprobes |
@@ -1010,19 +1013,18 @@ space_cccc_000x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1010 | /* cccc 0001 0xx0 xxxx xxxx xxxx xxxx xxx0 xxxx */ | 1013 | /* cccc 0001 0xx0 xxxx xxxx xxxx xxxx xxx0 xxxx */ |
1011 | if ((insn & 0x0f900010) == 0x01000000) { | 1014 | if ((insn & 0x0f900010) == 0x01000000) { |
1012 | 1015 | ||
1013 | /* BXJ : cccc 0001 0010 xxxx xxxx xxxx 0010 xxxx */ | 1016 | /* MRS cpsr : cccc 0001 0000 xxxx xxxx xxxx 0000 xxxx */ |
1014 | /* MSR : cccc 0001 0x10 xxxx xxxx xxxx 0000 xxxx */ | 1017 | if ((insn & 0x0ff000f0) == 0x01000000) { |
1015 | if ((insn & 0x0ff000f0) == 0x01200020 || | 1018 | if (is_r15(insn, 12)) |
1016 | (insn & 0x0fb000f0) == 0x01200000) | 1019 | return INSN_REJECTED; /* Rd is PC */ |
1017 | return INSN_REJECTED; | 1020 | asi->insn_handler = simulate_mrs; |
1018 | 1021 | return INSN_GOOD_NO_SLOT; | |
1019 | /* MRS : cccc 0001 0x00 xxxx xxxx xxxx 0000 xxxx */ | 1022 | } |
1020 | if ((insn & 0x0fb00010) == 0x01000000) | ||
1021 | return prep_emulate_rd12(insn, asi); | ||
1022 | 1023 | ||
1023 | /* SMLALxy : cccc 0001 0100 xxxx xxxx xxxx 1xx0 xxxx */ | 1024 | /* SMLALxy : cccc 0001 0100 xxxx xxxx xxxx 1xx0 xxxx */ |
1024 | if ((insn & 0x0ff00090) == 0x01400080) | 1025 | if ((insn & 0x0ff00090) == 0x01400080) |
1025 | return prep_emulate_rdhi16rdlo12rs8rm0_wflags(insn, asi); | 1026 | return prep_emulate_rdhi16rdlo12rs8rm0_wflags(insn, |
1027 | asi); | ||
1026 | 1028 | ||
1027 | /* SMULWy : cccc 0001 0010 xxxx xxxx xxxx 1x10 xxxx */ | 1029 | /* SMULWy : cccc 0001 0010 xxxx xxxx xxxx 1x10 xxxx */ |
1028 | /* SMULxy : cccc 0001 0110 xxxx xxxx xxxx 1xx0 xxxx */ | 1030 | /* SMULxy : cccc 0001 0110 xxxx xxxx xxxx 1xx0 xxxx */ |
@@ -1031,24 +1033,29 @@ space_cccc_000x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1031 | return prep_emulate_rd16rs8rm0_wflags(insn, asi); | 1033 | return prep_emulate_rd16rs8rm0_wflags(insn, asi); |
1032 | 1034 | ||
1033 | /* SMLAxy : cccc 0001 0000 xxxx xxxx xxxx 1xx0 xxxx : Q */ | 1035 | /* SMLAxy : cccc 0001 0000 xxxx xxxx xxxx 1xx0 xxxx : Q */ |
1034 | /* SMLAWy : cccc 0001 0010 xxxx xxxx xxxx 0x00 xxxx : Q */ | 1036 | /* SMLAWy : cccc 0001 0010 xxxx xxxx xxxx 1x00 xxxx : Q */ |
1035 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); | 1037 | if ((insn & 0x0ff00090) == 0x01000080 || |
1038 | (insn & 0x0ff000b0) == 0x01200080) | ||
1039 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); | ||
1040 | |||
1041 | /* BXJ : cccc 0001 0010 xxxx xxxx xxxx 0010 xxxx */ | ||
1042 | /* MSR : cccc 0001 0x10 xxxx xxxx xxxx 0000 xxxx */ | ||
1043 | /* MRS spsr : cccc 0001 0100 xxxx xxxx xxxx 0000 xxxx */ | ||
1036 | 1044 | ||
1045 | /* Other instruction encodings aren't yet defined */ | ||
1046 | return INSN_REJECTED; | ||
1037 | } | 1047 | } |
1038 | 1048 | ||
1039 | /* cccc 0001 0xx0 xxxx xxxx xxxx xxxx 0xx1 xxxx */ | 1049 | /* cccc 0001 0xx0 xxxx xxxx xxxx xxxx 0xx1 xxxx */ |
1040 | else if ((insn & 0x0f900090) == 0x01000010) { | 1050 | else if ((insn & 0x0f900090) == 0x01000010) { |
1041 | 1051 | ||
1042 | /* BKPT : 1110 0001 0010 xxxx xxxx xxxx 0111 xxxx */ | ||
1043 | if ((insn & 0xfff000f0) == 0xe1200070) | ||
1044 | return INSN_REJECTED; | ||
1045 | |||
1046 | /* BLX(2) : cccc 0001 0010 xxxx xxxx xxxx 0011 xxxx */ | 1052 | /* BLX(2) : cccc 0001 0010 xxxx xxxx xxxx 0011 xxxx */ |
1047 | /* BX : cccc 0001 0010 xxxx xxxx xxxx 0001 xxxx */ | 1053 | /* BX : cccc 0001 0010 xxxx xxxx xxxx 0001 xxxx */ |
1048 | if ((insn & 0x0ff000d0) == 0x01200010) { | 1054 | if ((insn & 0x0ff000d0) == 0x01200010) { |
1049 | asi->insn[0] = truecc_insn(insn); | 1055 | if ((insn & 0x0ff000ff) == 0x0120003f) |
1056 | return INSN_REJECTED; /* BLX pc */ | ||
1050 | asi->insn_handler = simulate_blx2bx; | 1057 | asi->insn_handler = simulate_blx2bx; |
1051 | return INSN_GOOD; | 1058 | return INSN_GOOD_NO_SLOT; |
1052 | } | 1059 | } |
1053 | 1060 | ||
1054 | /* CLZ : cccc 0001 0110 xxxx xxxx xxxx 0001 xxxx */ | 1061 | /* CLZ : cccc 0001 0110 xxxx xxxx xxxx 0001 xxxx */ |
@@ -1059,17 +1066,27 @@ space_cccc_000x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1059 | /* QSUB : cccc 0001 0010 xxxx xxxx xxxx 0101 xxxx :Q */ | 1066 | /* QSUB : cccc 0001 0010 xxxx xxxx xxxx 0101 xxxx :Q */ |
1060 | /* QDADD : cccc 0001 0100 xxxx xxxx xxxx 0101 xxxx :Q */ | 1067 | /* QDADD : cccc 0001 0100 xxxx xxxx xxxx 0101 xxxx :Q */ |
1061 | /* QDSUB : cccc 0001 0110 xxxx xxxx xxxx 0101 xxxx :Q */ | 1068 | /* QDSUB : cccc 0001 0110 xxxx xxxx xxxx 0101 xxxx :Q */ |
1062 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); | 1069 | if ((insn & 0x0f9000f0) == 0x01000050) |
1070 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); | ||
1071 | |||
1072 | /* BKPT : 1110 0001 0010 xxxx xxxx xxxx 0111 xxxx */ | ||
1073 | /* SMC : cccc 0001 0110 xxxx xxxx xxxx 0111 xxxx */ | ||
1074 | |||
1075 | /* Other instruction encodings aren't yet defined */ | ||
1076 | return INSN_REJECTED; | ||
1063 | } | 1077 | } |
1064 | 1078 | ||
1065 | /* cccc 0000 xxxx xxxx xxxx xxxx xxxx 1001 xxxx */ | 1079 | /* cccc 0000 xxxx xxxx xxxx xxxx xxxx 1001 xxxx */ |
1066 | else if ((insn & 0x0f000090) == 0x00000090) { | 1080 | else if ((insn & 0x0f0000f0) == 0x00000090) { |
1067 | 1081 | ||
1068 | /* MUL : cccc 0000 0000 xxxx xxxx xxxx 1001 xxxx : */ | 1082 | /* MUL : cccc 0000 0000 xxxx xxxx xxxx 1001 xxxx : */ |
1069 | /* MULS : cccc 0000 0001 xxxx xxxx xxxx 1001 xxxx :cc */ | 1083 | /* MULS : cccc 0000 0001 xxxx xxxx xxxx 1001 xxxx :cc */ |
1070 | /* MLA : cccc 0000 0010 xxxx xxxx xxxx 1001 xxxx : */ | 1084 | /* MLA : cccc 0000 0010 xxxx xxxx xxxx 1001 xxxx : */ |
1071 | /* MLAS : cccc 0000 0011 xxxx xxxx xxxx 1001 xxxx :cc */ | 1085 | /* MLAS : cccc 0000 0011 xxxx xxxx xxxx 1001 xxxx :cc */ |
1072 | /* UMAAL : cccc 0000 0100 xxxx xxxx xxxx 1001 xxxx : */ | 1086 | /* UMAAL : cccc 0000 0100 xxxx xxxx xxxx 1001 xxxx : */ |
1087 | /* undef : cccc 0000 0101 xxxx xxxx xxxx 1001 xxxx : */ | ||
1088 | /* MLS : cccc 0000 0110 xxxx xxxx xxxx 1001 xxxx : */ | ||
1089 | /* undef : cccc 0000 0111 xxxx xxxx xxxx 1001 xxxx : */ | ||
1073 | /* UMULL : cccc 0000 1000 xxxx xxxx xxxx 1001 xxxx : */ | 1090 | /* UMULL : cccc 0000 1000 xxxx xxxx xxxx 1001 xxxx : */ |
1074 | /* UMULLS : cccc 0000 1001 xxxx xxxx xxxx 1001 xxxx :cc */ | 1091 | /* UMULLS : cccc 0000 1001 xxxx xxxx xxxx 1001 xxxx :cc */ |
1075 | /* UMLAL : cccc 0000 1010 xxxx xxxx xxxx 1001 xxxx : */ | 1092 | /* UMLAL : cccc 0000 1010 xxxx xxxx xxxx 1001 xxxx : */ |
@@ -1078,13 +1095,15 @@ space_cccc_000x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1078 | /* SMULLS : cccc 0000 1101 xxxx xxxx xxxx 1001 xxxx :cc */ | 1095 | /* SMULLS : cccc 0000 1101 xxxx xxxx xxxx 1001 xxxx :cc */ |
1079 | /* SMLAL : cccc 0000 1110 xxxx xxxx xxxx 1001 xxxx : */ | 1096 | /* SMLAL : cccc 0000 1110 xxxx xxxx xxxx 1001 xxxx : */ |
1080 | /* SMLALS : cccc 0000 1111 xxxx xxxx xxxx 1001 xxxx :cc */ | 1097 | /* SMLALS : cccc 0000 1111 xxxx xxxx xxxx 1001 xxxx :cc */ |
1081 | if ((insn & 0x0fe000f0) == 0x00000090) { | 1098 | if ((insn & 0x00d00000) == 0x00500000) |
1082 | return prep_emulate_rd16rs8rm0_wflags(insn, asi); | 1099 | return INSN_REJECTED; |
1083 | } else if ((insn & 0x0fe000f0) == 0x00200090) { | 1100 | else if ((insn & 0x00e00000) == 0x00000000) |
1084 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); | 1101 | return prep_emulate_rd16rs8rm0_wflags(insn, asi); |
1085 | } else { | 1102 | else if ((insn & 0x00a00000) == 0x00200000) |
1086 | return prep_emulate_rdhi16rdlo12rs8rm0_wflags(insn, asi); | 1103 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); |
1087 | } | 1104 | else |
1105 | return prep_emulate_rdhi16rdlo12rs8rm0_wflags(insn, | ||
1106 | asi); | ||
1088 | } | 1107 | } |
1089 | 1108 | ||
1090 | /* cccc 000x xxxx xxxx xxxx xxxx xxxx 1xx1 xxxx */ | 1109 | /* cccc 000x xxxx xxxx xxxx xxxx xxxx 1xx1 xxxx */ |
@@ -1092,23 +1111,45 @@ space_cccc_000x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1092 | 1111 | ||
1093 | /* SWP : cccc 0001 0000 xxxx xxxx xxxx 1001 xxxx */ | 1112 | /* SWP : cccc 0001 0000 xxxx xxxx xxxx 1001 xxxx */ |
1094 | /* SWPB : cccc 0001 0100 xxxx xxxx xxxx 1001 xxxx */ | 1113 | /* SWPB : cccc 0001 0100 xxxx xxxx xxxx 1001 xxxx */ |
1095 | /* LDRD : cccc 000x xxx0 xxxx xxxx xxxx 1101 xxxx */ | 1114 | /* ??? : cccc 0001 0x01 xxxx xxxx xxxx 1001 xxxx */ |
1096 | /* STRD : cccc 000x xxx0 xxxx xxxx xxxx 1111 xxxx */ | 1115 | /* ??? : cccc 0001 0x10 xxxx xxxx xxxx 1001 xxxx */ |
1116 | /* ??? : cccc 0001 0x11 xxxx xxxx xxxx 1001 xxxx */ | ||
1097 | /* STREX : cccc 0001 1000 xxxx xxxx xxxx 1001 xxxx */ | 1117 | /* STREX : cccc 0001 1000 xxxx xxxx xxxx 1001 xxxx */ |
1098 | /* LDREX : cccc 0001 1001 xxxx xxxx xxxx 1001 xxxx */ | 1118 | /* LDREX : cccc 0001 1001 xxxx xxxx xxxx 1001 xxxx */ |
1119 | /* STREXD: cccc 0001 1010 xxxx xxxx xxxx 1001 xxxx */ | ||
1120 | /* LDREXD: cccc 0001 1011 xxxx xxxx xxxx 1001 xxxx */ | ||
1121 | /* STREXB: cccc 0001 1100 xxxx xxxx xxxx 1001 xxxx */ | ||
1122 | /* LDREXB: cccc 0001 1101 xxxx xxxx xxxx 1001 xxxx */ | ||
1123 | /* STREXH: cccc 0001 1110 xxxx xxxx xxxx 1001 xxxx */ | ||
1124 | /* LDREXH: cccc 0001 1111 xxxx xxxx xxxx 1001 xxxx */ | ||
1125 | |||
1126 | /* LDRD : cccc 000x xxx0 xxxx xxxx xxxx 1101 xxxx */ | ||
1127 | /* STRD : cccc 000x xxx0 xxxx xxxx xxxx 1111 xxxx */ | ||
1099 | /* LDRH : cccc 000x xxx1 xxxx xxxx xxxx 1011 xxxx */ | 1128 | /* LDRH : cccc 000x xxx1 xxxx xxxx xxxx 1011 xxxx */ |
1100 | /* STRH : cccc 000x xxx0 xxxx xxxx xxxx 1011 xxxx */ | 1129 | /* STRH : cccc 000x xxx0 xxxx xxxx xxxx 1011 xxxx */ |
1101 | /* LDRSB : cccc 000x xxx1 xxxx xxxx xxxx 1101 xxxx */ | 1130 | /* LDRSB : cccc 000x xxx1 xxxx xxxx xxxx 1101 xxxx */ |
1102 | /* LDRSH : cccc 000x xxx1 xxxx xxxx xxxx 1111 xxxx */ | 1131 | /* LDRSH : cccc 000x xxx1 xxxx xxxx xxxx 1111 xxxx */ |
1103 | if ((insn & 0x0fb000f0) == 0x01000090) { | 1132 | if ((insn & 0x0f0000f0) == 0x01000090) { |
1104 | /* SWP/SWPB */ | 1133 | if ((insn & 0x0fb000f0) == 0x01000090) { |
1105 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); | 1134 | /* SWP/SWPB */ |
1135 | return prep_emulate_rd12rn16rm0_wflags(insn, | ||
1136 | asi); | ||
1137 | } else { | ||
1138 | /* STREX/LDREX variants and unallocaed space */ | ||
1139 | return INSN_REJECTED; | ||
1140 | } | ||
1141 | |||
1106 | } else if ((insn & 0x0e1000d0) == 0x00000d0) { | 1142 | } else if ((insn & 0x0e1000d0) == 0x00000d0) { |
1107 | /* STRD/LDRD */ | 1143 | /* STRD/LDRD */ |
1144 | if ((insn & 0x0000e000) == 0x0000e000) | ||
1145 | return INSN_REJECTED; /* Rd is LR or PC */ | ||
1146 | if (is_writeback(insn) && is_r15(insn, 16)) | ||
1147 | return INSN_REJECTED; /* Writeback to PC */ | ||
1148 | |||
1108 | insn &= 0xfff00fff; | 1149 | insn &= 0xfff00fff; |
1109 | insn |= 0x00002000; /* Rn = r0, Rd = r2 */ | 1150 | insn |= 0x00002000; /* Rn = r0, Rd = r2 */ |
1110 | if (insn & (1 << 22)) { | 1151 | if (!(insn & (1 << 22))) { |
1111 | /* I bit */ | 1152 | /* Register index */ |
1112 | insn &= ~0xf; | 1153 | insn &= ~0xf; |
1113 | insn |= 1; /* Rm = r1 */ | 1154 | insn |= 1; /* Rm = r1 */ |
1114 | } | 1155 | } |
@@ -1118,6 +1159,9 @@ space_cccc_000x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1118 | return INSN_GOOD; | 1159 | return INSN_GOOD; |
1119 | } | 1160 | } |
1120 | 1161 | ||
1162 | /* LDRH/STRH/LDRSB/LDRSH */ | ||
1163 | if (is_r15(insn, 12)) | ||
1164 | return INSN_REJECTED; /* Rd is PC */ | ||
1121 | return prep_emulate_ldr_str(insn, asi); | 1165 | return prep_emulate_ldr_str(insn, asi); |
1122 | } | 1166 | } |
1123 | 1167 | ||
@@ -1125,7 +1169,7 @@ space_cccc_000x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1125 | 1169 | ||
1126 | /* | 1170 | /* |
1127 | * ALU op with S bit and Rd == 15 : | 1171 | * ALU op with S bit and Rd == 15 : |
1128 | * cccc 000x xxx1 xxxx 1111 xxxx xxxx xxxx | 1172 | * cccc 000x xxx1 xxxx 1111 xxxx xxxx xxxx |
1129 | */ | 1173 | */ |
1130 | if ((insn & 0x0e10f000) == 0x0010f000) | 1174 | if ((insn & 0x0e10f000) == 0x0010f000) |
1131 | return INSN_REJECTED; | 1175 | return INSN_REJECTED; |
@@ -1154,22 +1198,61 @@ space_cccc_000x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1154 | insn |= 0x00000200; /* Rs = r2 */ | 1198 | insn |= 0x00000200; /* Rs = r2 */ |
1155 | } | 1199 | } |
1156 | asi->insn[0] = insn; | 1200 | asi->insn[0] = insn; |
1157 | asi->insn_handler = (insn & (1 << 20)) ? /* S-bit */ | 1201 | |
1202 | if ((insn & 0x0f900000) == 0x01100000) { | ||
1203 | /* | ||
1204 | * TST : cccc 0001 0001 xxxx xxxx xxxx xxxx xxxx | ||
1205 | * TEQ : cccc 0001 0011 xxxx xxxx xxxx xxxx xxxx | ||
1206 | * CMP : cccc 0001 0101 xxxx xxxx xxxx xxxx xxxx | ||
1207 | * CMN : cccc 0001 0111 xxxx xxxx xxxx xxxx xxxx | ||
1208 | */ | ||
1209 | asi->insn_handler = emulate_alu_tests; | ||
1210 | } else { | ||
1211 | /* ALU ops which write to Rd */ | ||
1212 | asi->insn_handler = (insn & (1 << 20)) ? /* S-bit */ | ||
1158 | emulate_alu_rwflags : emulate_alu_rflags; | 1213 | emulate_alu_rwflags : emulate_alu_rflags; |
1214 | } | ||
1159 | return INSN_GOOD; | 1215 | return INSN_GOOD; |
1160 | } | 1216 | } |
1161 | 1217 | ||
1162 | static enum kprobe_insn __kprobes | 1218 | static enum kprobe_insn __kprobes |
1163 | space_cccc_001x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | 1219 | space_cccc_001x(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
1164 | { | 1220 | { |
1221 | /* MOVW : cccc 0011 0000 xxxx xxxx xxxx xxxx xxxx */ | ||
1222 | /* MOVT : cccc 0011 0100 xxxx xxxx xxxx xxxx xxxx */ | ||
1223 | if ((insn & 0x0fb00000) == 0x03000000) | ||
1224 | return prep_emulate_rd12_modify(insn, asi); | ||
1225 | |||
1226 | /* hints : cccc 0011 0010 0000 xxxx xxxx xxxx xxxx */ | ||
1227 | if ((insn & 0x0fff0000) == 0x03200000) { | ||
1228 | unsigned op2 = insn & 0x000000ff; | ||
1229 | if (op2 == 0x01 || op2 == 0x04) { | ||
1230 | /* YIELD : cccc 0011 0010 0000 xxxx xxxx 0000 0001 */ | ||
1231 | /* SEV : cccc 0011 0010 0000 xxxx xxxx 0000 0100 */ | ||
1232 | asi->insn[0] = insn; | ||
1233 | asi->insn_handler = emulate_none; | ||
1234 | return INSN_GOOD; | ||
1235 | } else if (op2 <= 0x03) { | ||
1236 | /* NOP : cccc 0011 0010 0000 xxxx xxxx 0000 0000 */ | ||
1237 | /* WFE : cccc 0011 0010 0000 xxxx xxxx 0000 0010 */ | ||
1238 | /* WFI : cccc 0011 0010 0000 xxxx xxxx 0000 0011 */ | ||
1239 | /* | ||
1240 | * We make WFE and WFI true NOPs to avoid stalls due | ||
1241 | * to missing events whilst processing the probe. | ||
1242 | */ | ||
1243 | asi->insn_handler = emulate_nop; | ||
1244 | return INSN_GOOD_NO_SLOT; | ||
1245 | } | ||
1246 | /* For DBG and unallocated hints it's safest to reject them */ | ||
1247 | return INSN_REJECTED; | ||
1248 | } | ||
1249 | |||
1165 | /* | 1250 | /* |
1166 | * MSR : cccc 0011 0x10 xxxx xxxx xxxx xxxx xxxx | 1251 | * MSR : cccc 0011 0x10 xxxx xxxx xxxx xxxx xxxx |
1167 | * Undef : cccc 0011 0100 xxxx xxxx xxxx xxxx xxxx | ||
1168 | * ALU op with S bit and Rd == 15 : | 1252 | * ALU op with S bit and Rd == 15 : |
1169 | * cccc 001x xxx1 xxxx 1111 xxxx xxxx xxxx | 1253 | * cccc 001x xxx1 xxxx 1111 xxxx xxxx xxxx |
1170 | */ | 1254 | */ |
1171 | if ((insn & 0x0fb00000) == 0x03200000 || /* MSR */ | 1255 | if ((insn & 0x0fb00000) == 0x03200000 || /* MSR */ |
1172 | (insn & 0x0ff00000) == 0x03400000 || /* Undef */ | ||
1173 | (insn & 0x0e10f000) == 0x0210f000) /* ALU s-bit, R15 */ | 1256 | (insn & 0x0e10f000) == 0x0210f000) /* ALU s-bit, R15 */ |
1174 | return INSN_REJECTED; | 1257 | return INSN_REJECTED; |
1175 | 1258 | ||
@@ -1180,10 +1263,22 @@ space_cccc_001x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1180 | * *S (bit 20) updates condition codes | 1263 | * *S (bit 20) updates condition codes |
1181 | * ADC/SBC/RSC reads the C flag | 1264 | * ADC/SBC/RSC reads the C flag |
1182 | */ | 1265 | */ |
1183 | insn &= 0xffff0fff; /* Rd = r0 */ | 1266 | insn &= 0xfff00fff; /* Rn = r0 and Rd = r0 */ |
1184 | asi->insn[0] = insn; | 1267 | asi->insn[0] = insn; |
1185 | asi->insn_handler = (insn & (1 << 20)) ? /* S-bit */ | 1268 | |
1269 | if ((insn & 0x0f900000) == 0x03100000) { | ||
1270 | /* | ||
1271 | * TST : cccc 0011 0001 xxxx xxxx xxxx xxxx xxxx | ||
1272 | * TEQ : cccc 0011 0011 xxxx xxxx xxxx xxxx xxxx | ||
1273 | * CMP : cccc 0011 0101 xxxx xxxx xxxx xxxx xxxx | ||
1274 | * CMN : cccc 0011 0111 xxxx xxxx xxxx xxxx xxxx | ||
1275 | */ | ||
1276 | asi->insn_handler = emulate_alu_tests_imm; | ||
1277 | } else { | ||
1278 | /* ALU ops which write to Rd */ | ||
1279 | asi->insn_handler = (insn & (1 << 20)) ? /* S-bit */ | ||
1186 | emulate_alu_imm_rwflags : emulate_alu_imm_rflags; | 1280 | emulate_alu_imm_rwflags : emulate_alu_imm_rflags; |
1281 | } | ||
1187 | return INSN_GOOD; | 1282 | return INSN_GOOD; |
1188 | } | 1283 | } |
1189 | 1284 | ||
@@ -1192,6 +1287,8 @@ space_cccc_0110__1(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1192 | { | 1287 | { |
1193 | /* SEL : cccc 0110 1000 xxxx xxxx xxxx 1011 xxxx GE: !!! */ | 1288 | /* SEL : cccc 0110 1000 xxxx xxxx xxxx 1011 xxxx GE: !!! */ |
1194 | if ((insn & 0x0ff000f0) == 0x068000b0) { | 1289 | if ((insn & 0x0ff000f0) == 0x068000b0) { |
1290 | if (is_r15(insn, 12)) | ||
1291 | return INSN_REJECTED; /* Rd is PC */ | ||
1195 | insn &= 0xfff00ff0; /* Rd = r0, Rn = r0 */ | 1292 | insn &= 0xfff00ff0; /* Rd = r0, Rn = r0 */ |
1196 | insn |= 0x00000001; /* Rm = r1 */ | 1293 | insn |= 0x00000001; /* Rm = r1 */ |
1197 | asi->insn[0] = insn; | 1294 | asi->insn[0] = insn; |
@@ -1205,6 +1302,8 @@ space_cccc_0110__1(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1205 | /* USAT16 : cccc 0110 1110 xxxx xxxx xxxx 0011 xxxx :Q */ | 1302 | /* USAT16 : cccc 0110 1110 xxxx xxxx xxxx 0011 xxxx :Q */ |
1206 | if ((insn & 0x0fa00030) == 0x06a00010 || | 1303 | if ((insn & 0x0fa00030) == 0x06a00010 || |
1207 | (insn & 0x0fb000f0) == 0x06a00030) { | 1304 | (insn & 0x0fb000f0) == 0x06a00030) { |
1305 | if (is_r15(insn, 12)) | ||
1306 | return INSN_REJECTED; /* Rd is PC */ | ||
1208 | insn &= 0xffff0ff0; /* Rd = r0, Rm = r0 */ | 1307 | insn &= 0xffff0ff0; /* Rd = r0, Rm = r0 */ |
1209 | asi->insn[0] = insn; | 1308 | asi->insn[0] = insn; |
1210 | asi->insn_handler = emulate_sat; | 1309 | asi->insn_handler = emulate_sat; |
@@ -1213,57 +1312,101 @@ space_cccc_0110__1(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1213 | 1312 | ||
1214 | /* REV : cccc 0110 1011 xxxx xxxx xxxx 0011 xxxx */ | 1313 | /* REV : cccc 0110 1011 xxxx xxxx xxxx 0011 xxxx */ |
1215 | /* REV16 : cccc 0110 1011 xxxx xxxx xxxx 1011 xxxx */ | 1314 | /* REV16 : cccc 0110 1011 xxxx xxxx xxxx 1011 xxxx */ |
1315 | /* RBIT : cccc 0110 1111 xxxx xxxx xxxx 0011 xxxx */ | ||
1216 | /* REVSH : cccc 0110 1111 xxxx xxxx xxxx 1011 xxxx */ | 1316 | /* REVSH : cccc 0110 1111 xxxx xxxx xxxx 1011 xxxx */ |
1217 | if ((insn & 0x0ff00070) == 0x06b00030 || | 1317 | if ((insn & 0x0ff00070) == 0x06b00030 || |
1218 | (insn & 0x0ff000f0) == 0x06f000b0) | 1318 | (insn & 0x0ff00070) == 0x06f00030) |
1219 | return prep_emulate_rd12rm0(insn, asi); | 1319 | return prep_emulate_rd12rm0(insn, asi); |
1220 | 1320 | ||
1321 | /* ??? : cccc 0110 0000 xxxx xxxx xxxx xxx1 xxxx : */ | ||
1221 | /* SADD16 : cccc 0110 0001 xxxx xxxx xxxx 0001 xxxx :GE */ | 1322 | /* SADD16 : cccc 0110 0001 xxxx xxxx xxxx 0001 xxxx :GE */ |
1222 | /* SADDSUBX : cccc 0110 0001 xxxx xxxx xxxx 0011 xxxx :GE */ | 1323 | /* SADDSUBX : cccc 0110 0001 xxxx xxxx xxxx 0011 xxxx :GE */ |
1223 | /* SSUBADDX : cccc 0110 0001 xxxx xxxx xxxx 0101 xxxx :GE */ | 1324 | /* SSUBADDX : cccc 0110 0001 xxxx xxxx xxxx 0101 xxxx :GE */ |
1224 | /* SSUB16 : cccc 0110 0001 xxxx xxxx xxxx 0111 xxxx :GE */ | 1325 | /* SSUB16 : cccc 0110 0001 xxxx xxxx xxxx 0111 xxxx :GE */ |
1225 | /* SADD8 : cccc 0110 0001 xxxx xxxx xxxx 1001 xxxx :GE */ | 1326 | /* SADD8 : cccc 0110 0001 xxxx xxxx xxxx 1001 xxxx :GE */ |
1327 | /* ??? : cccc 0110 0001 xxxx xxxx xxxx 1011 xxxx : */ | ||
1328 | /* ??? : cccc 0110 0001 xxxx xxxx xxxx 1101 xxxx : */ | ||
1226 | /* SSUB8 : cccc 0110 0001 xxxx xxxx xxxx 1111 xxxx :GE */ | 1329 | /* SSUB8 : cccc 0110 0001 xxxx xxxx xxxx 1111 xxxx :GE */ |
1227 | /* QADD16 : cccc 0110 0010 xxxx xxxx xxxx 0001 xxxx : */ | 1330 | /* QADD16 : cccc 0110 0010 xxxx xxxx xxxx 0001 xxxx : */ |
1228 | /* QADDSUBX : cccc 0110 0010 xxxx xxxx xxxx 0011 xxxx : */ | 1331 | /* QADDSUBX : cccc 0110 0010 xxxx xxxx xxxx 0011 xxxx : */ |
1229 | /* QSUBADDX : cccc 0110 0010 xxxx xxxx xxxx 0101 xxxx : */ | 1332 | /* QSUBADDX : cccc 0110 0010 xxxx xxxx xxxx 0101 xxxx : */ |
1230 | /* QSUB16 : cccc 0110 0010 xxxx xxxx xxxx 0111 xxxx : */ | 1333 | /* QSUB16 : cccc 0110 0010 xxxx xxxx xxxx 0111 xxxx : */ |
1231 | /* QADD8 : cccc 0110 0010 xxxx xxxx xxxx 1001 xxxx : */ | 1334 | /* QADD8 : cccc 0110 0010 xxxx xxxx xxxx 1001 xxxx : */ |
1335 | /* ??? : cccc 0110 0010 xxxx xxxx xxxx 1011 xxxx : */ | ||
1336 | /* ??? : cccc 0110 0010 xxxx xxxx xxxx 1101 xxxx : */ | ||
1232 | /* QSUB8 : cccc 0110 0010 xxxx xxxx xxxx 1111 xxxx : */ | 1337 | /* QSUB8 : cccc 0110 0010 xxxx xxxx xxxx 1111 xxxx : */ |
1233 | /* SHADD16 : cccc 0110 0011 xxxx xxxx xxxx 0001 xxxx : */ | 1338 | /* SHADD16 : cccc 0110 0011 xxxx xxxx xxxx 0001 xxxx : */ |
1234 | /* SHADDSUBX : cccc 0110 0011 xxxx xxxx xxxx 0011 xxxx : */ | 1339 | /* SHADDSUBX : cccc 0110 0011 xxxx xxxx xxxx 0011 xxxx : */ |
1235 | /* SHSUBADDX : cccc 0110 0011 xxxx xxxx xxxx 0101 xxxx : */ | 1340 | /* SHSUBADDX : cccc 0110 0011 xxxx xxxx xxxx 0101 xxxx : */ |
1236 | /* SHSUB16 : cccc 0110 0011 xxxx xxxx xxxx 0111 xxxx : */ | 1341 | /* SHSUB16 : cccc 0110 0011 xxxx xxxx xxxx 0111 xxxx : */ |
1237 | /* SHADD8 : cccc 0110 0011 xxxx xxxx xxxx 1001 xxxx : */ | 1342 | /* SHADD8 : cccc 0110 0011 xxxx xxxx xxxx 1001 xxxx : */ |
1343 | /* ??? : cccc 0110 0011 xxxx xxxx xxxx 1011 xxxx : */ | ||
1344 | /* ??? : cccc 0110 0011 xxxx xxxx xxxx 1101 xxxx : */ | ||
1238 | /* SHSUB8 : cccc 0110 0011 xxxx xxxx xxxx 1111 xxxx : */ | 1345 | /* SHSUB8 : cccc 0110 0011 xxxx xxxx xxxx 1111 xxxx : */ |
1346 | /* ??? : cccc 0110 0100 xxxx xxxx xxxx xxx1 xxxx : */ | ||
1239 | /* UADD16 : cccc 0110 0101 xxxx xxxx xxxx 0001 xxxx :GE */ | 1347 | /* UADD16 : cccc 0110 0101 xxxx xxxx xxxx 0001 xxxx :GE */ |
1240 | /* UADDSUBX : cccc 0110 0101 xxxx xxxx xxxx 0011 xxxx :GE */ | 1348 | /* UADDSUBX : cccc 0110 0101 xxxx xxxx xxxx 0011 xxxx :GE */ |
1241 | /* USUBADDX : cccc 0110 0101 xxxx xxxx xxxx 0101 xxxx :GE */ | 1349 | /* USUBADDX : cccc 0110 0101 xxxx xxxx xxxx 0101 xxxx :GE */ |
1242 | /* USUB16 : cccc 0110 0101 xxxx xxxx xxxx 0111 xxxx :GE */ | 1350 | /* USUB16 : cccc 0110 0101 xxxx xxxx xxxx 0111 xxxx :GE */ |
1243 | /* UADD8 : cccc 0110 0101 xxxx xxxx xxxx 1001 xxxx :GE */ | 1351 | /* UADD8 : cccc 0110 0101 xxxx xxxx xxxx 1001 xxxx :GE */ |
1352 | /* ??? : cccc 0110 0101 xxxx xxxx xxxx 1011 xxxx : */ | ||
1353 | /* ??? : cccc 0110 0101 xxxx xxxx xxxx 1101 xxxx : */ | ||
1244 | /* USUB8 : cccc 0110 0101 xxxx xxxx xxxx 1111 xxxx :GE */ | 1354 | /* USUB8 : cccc 0110 0101 xxxx xxxx xxxx 1111 xxxx :GE */ |
1245 | /* UQADD16 : cccc 0110 0110 xxxx xxxx xxxx 0001 xxxx : */ | 1355 | /* UQADD16 : cccc 0110 0110 xxxx xxxx xxxx 0001 xxxx : */ |
1246 | /* UQADDSUBX : cccc 0110 0110 xxxx xxxx xxxx 0011 xxxx : */ | 1356 | /* UQADDSUBX : cccc 0110 0110 xxxx xxxx xxxx 0011 xxxx : */ |
1247 | /* UQSUBADDX : cccc 0110 0110 xxxx xxxx xxxx 0101 xxxx : */ | 1357 | /* UQSUBADDX : cccc 0110 0110 xxxx xxxx xxxx 0101 xxxx : */ |
1248 | /* UQSUB16 : cccc 0110 0110 xxxx xxxx xxxx 0111 xxxx : */ | 1358 | /* UQSUB16 : cccc 0110 0110 xxxx xxxx xxxx 0111 xxxx : */ |
1249 | /* UQADD8 : cccc 0110 0110 xxxx xxxx xxxx 1001 xxxx : */ | 1359 | /* UQADD8 : cccc 0110 0110 xxxx xxxx xxxx 1001 xxxx : */ |
1360 | /* ??? : cccc 0110 0110 xxxx xxxx xxxx 1011 xxxx : */ | ||
1361 | /* ??? : cccc 0110 0110 xxxx xxxx xxxx 1101 xxxx : */ | ||
1250 | /* UQSUB8 : cccc 0110 0110 xxxx xxxx xxxx 1111 xxxx : */ | 1362 | /* UQSUB8 : cccc 0110 0110 xxxx xxxx xxxx 1111 xxxx : */ |
1251 | /* UHADD16 : cccc 0110 0111 xxxx xxxx xxxx 0001 xxxx : */ | 1363 | /* UHADD16 : cccc 0110 0111 xxxx xxxx xxxx 0001 xxxx : */ |
1252 | /* UHADDSUBX : cccc 0110 0111 xxxx xxxx xxxx 0011 xxxx : */ | 1364 | /* UHADDSUBX : cccc 0110 0111 xxxx xxxx xxxx 0011 xxxx : */ |
1253 | /* UHSUBADDX : cccc 0110 0111 xxxx xxxx xxxx 0101 xxxx : */ | 1365 | /* UHSUBADDX : cccc 0110 0111 xxxx xxxx xxxx 0101 xxxx : */ |
1254 | /* UHSUB16 : cccc 0110 0111 xxxx xxxx xxxx 0111 xxxx : */ | 1366 | /* UHSUB16 : cccc 0110 0111 xxxx xxxx xxxx 0111 xxxx : */ |
1255 | /* UHADD8 : cccc 0110 0111 xxxx xxxx xxxx 1001 xxxx : */ | 1367 | /* UHADD8 : cccc 0110 0111 xxxx xxxx xxxx 1001 xxxx : */ |
1368 | /* ??? : cccc 0110 0111 xxxx xxxx xxxx 1011 xxxx : */ | ||
1369 | /* ??? : cccc 0110 0111 xxxx xxxx xxxx 1101 xxxx : */ | ||
1256 | /* UHSUB8 : cccc 0110 0111 xxxx xxxx xxxx 1111 xxxx : */ | 1370 | /* UHSUB8 : cccc 0110 0111 xxxx xxxx xxxx 1111 xxxx : */ |
1371 | if ((insn & 0x0f800010) == 0x06000010) { | ||
1372 | if ((insn & 0x00300000) == 0x00000000 || | ||
1373 | (insn & 0x000000e0) == 0x000000a0 || | ||
1374 | (insn & 0x000000e0) == 0x000000c0) | ||
1375 | return INSN_REJECTED; /* Unallocated space */ | ||
1376 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); | ||
1377 | } | ||
1378 | |||
1257 | /* PKHBT : cccc 0110 1000 xxxx xxxx xxxx x001 xxxx : */ | 1379 | /* PKHBT : cccc 0110 1000 xxxx xxxx xxxx x001 xxxx : */ |
1258 | /* PKHTB : cccc 0110 1000 xxxx xxxx xxxx x101 xxxx : */ | 1380 | /* PKHTB : cccc 0110 1000 xxxx xxxx xxxx x101 xxxx : */ |
1381 | if ((insn & 0x0ff00030) == 0x06800010) | ||
1382 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); | ||
1383 | |||
1259 | /* SXTAB16 : cccc 0110 1000 xxxx xxxx xxxx 0111 xxxx : */ | 1384 | /* SXTAB16 : cccc 0110 1000 xxxx xxxx xxxx 0111 xxxx : */ |
1260 | /* SXTB : cccc 0110 1010 xxxx xxxx xxxx 0111 xxxx : */ | 1385 | /* SXTB16 : cccc 0110 1000 1111 xxxx xxxx 0111 xxxx : */ |
1386 | /* ??? : cccc 0110 1001 xxxx xxxx xxxx 0111 xxxx : */ | ||
1261 | /* SXTAB : cccc 0110 1010 xxxx xxxx xxxx 0111 xxxx : */ | 1387 | /* SXTAB : cccc 0110 1010 xxxx xxxx xxxx 0111 xxxx : */ |
1388 | /* SXTB : cccc 0110 1010 1111 xxxx xxxx 0111 xxxx : */ | ||
1262 | /* SXTAH : cccc 0110 1011 xxxx xxxx xxxx 0111 xxxx : */ | 1389 | /* SXTAH : cccc 0110 1011 xxxx xxxx xxxx 0111 xxxx : */ |
1390 | /* SXTH : cccc 0110 1011 1111 xxxx xxxx 0111 xxxx : */ | ||
1263 | /* UXTAB16 : cccc 0110 1100 xxxx xxxx xxxx 0111 xxxx : */ | 1391 | /* UXTAB16 : cccc 0110 1100 xxxx xxxx xxxx 0111 xxxx : */ |
1392 | /* UXTB16 : cccc 0110 1100 1111 xxxx xxxx 0111 xxxx : */ | ||
1393 | /* ??? : cccc 0110 1101 xxxx xxxx xxxx 0111 xxxx : */ | ||
1264 | /* UXTAB : cccc 0110 1110 xxxx xxxx xxxx 0111 xxxx : */ | 1394 | /* UXTAB : cccc 0110 1110 xxxx xxxx xxxx 0111 xxxx : */ |
1395 | /* UXTB : cccc 0110 1110 1111 xxxx xxxx 0111 xxxx : */ | ||
1265 | /* UXTAH : cccc 0110 1111 xxxx xxxx xxxx 0111 xxxx : */ | 1396 | /* UXTAH : cccc 0110 1111 xxxx xxxx xxxx 0111 xxxx : */ |
1266 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); | 1397 | /* UXTH : cccc 0110 1111 1111 xxxx xxxx 0111 xxxx : */ |
1398 | if ((insn & 0x0f8000f0) == 0x06800070) { | ||
1399 | if ((insn & 0x00300000) == 0x00100000) | ||
1400 | return INSN_REJECTED; /* Unallocated space */ | ||
1401 | |||
1402 | if ((insn & 0x000f0000) == 0x000f0000) | ||
1403 | return prep_emulate_rd12rm0(insn, asi); | ||
1404 | else | ||
1405 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); | ||
1406 | } | ||
1407 | |||
1408 | /* Other instruction encodings aren't yet defined */ | ||
1409 | return INSN_REJECTED; | ||
1267 | } | 1410 | } |
1268 | 1411 | ||
1269 | static enum kprobe_insn __kprobes | 1412 | static enum kprobe_insn __kprobes |
@@ -1273,29 +1416,49 @@ space_cccc_0111__1(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1273 | if ((insn & 0x0ff000f0) == 0x03f000f0) | 1416 | if ((insn & 0x0ff000f0) == 0x03f000f0) |
1274 | return INSN_REJECTED; | 1417 | return INSN_REJECTED; |
1275 | 1418 | ||
1276 | /* USADA8 : cccc 0111 1000 xxxx xxxx xxxx 0001 xxxx */ | ||
1277 | /* USAD8 : cccc 0111 1000 xxxx 1111 xxxx 0001 xxxx */ | ||
1278 | if ((insn & 0x0ff000f0) == 0x07800010) | ||
1279 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); | ||
1280 | |||
1281 | /* SMLALD : cccc 0111 0100 xxxx xxxx xxxx 00x1 xxxx */ | 1419 | /* SMLALD : cccc 0111 0100 xxxx xxxx xxxx 00x1 xxxx */ |
1282 | /* SMLSLD : cccc 0111 0100 xxxx xxxx xxxx 01x1 xxxx */ | 1420 | /* SMLSLD : cccc 0111 0100 xxxx xxxx xxxx 01x1 xxxx */ |
1283 | if ((insn & 0x0ff00090) == 0x07400010) | 1421 | if ((insn & 0x0ff00090) == 0x07400010) |
1284 | return prep_emulate_rdhi16rdlo12rs8rm0_wflags(insn, asi); | 1422 | return prep_emulate_rdhi16rdlo12rs8rm0_wflags(insn, asi); |
1285 | 1423 | ||
1286 | /* SMLAD : cccc 0111 0000 xxxx xxxx xxxx 00x1 xxxx :Q */ | 1424 | /* SMLAD : cccc 0111 0000 xxxx xxxx xxxx 00x1 xxxx :Q */ |
1425 | /* SMUAD : cccc 0111 0000 xxxx 1111 xxxx 00x1 xxxx :Q */ | ||
1287 | /* SMLSD : cccc 0111 0000 xxxx xxxx xxxx 01x1 xxxx :Q */ | 1426 | /* SMLSD : cccc 0111 0000 xxxx xxxx xxxx 01x1 xxxx :Q */ |
1427 | /* SMUSD : cccc 0111 0000 xxxx 1111 xxxx 01x1 xxxx : */ | ||
1288 | /* SMMLA : cccc 0111 0101 xxxx xxxx xxxx 00x1 xxxx : */ | 1428 | /* SMMLA : cccc 0111 0101 xxxx xxxx xxxx 00x1 xxxx : */ |
1289 | /* SMMLS : cccc 0111 0101 xxxx xxxx xxxx 11x1 xxxx : */ | 1429 | /* SMMUL : cccc 0111 0101 xxxx 1111 xxxx 00x1 xxxx : */ |
1430 | /* USADA8 : cccc 0111 1000 xxxx xxxx xxxx 0001 xxxx : */ | ||
1431 | /* USAD8 : cccc 0111 1000 xxxx 1111 xxxx 0001 xxxx : */ | ||
1290 | if ((insn & 0x0ff00090) == 0x07000010 || | 1432 | if ((insn & 0x0ff00090) == 0x07000010 || |
1291 | (insn & 0x0ff000d0) == 0x07500010 || | 1433 | (insn & 0x0ff000d0) == 0x07500010 || |
1292 | (insn & 0x0ff000d0) == 0x075000d0) | 1434 | (insn & 0x0ff000f0) == 0x07800010) { |
1435 | |||
1436 | if ((insn & 0x0000f000) == 0x0000f000) | ||
1437 | return prep_emulate_rd16rs8rm0_wflags(insn, asi); | ||
1438 | else | ||
1439 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); | ||
1440 | } | ||
1441 | |||
1442 | /* SMMLS : cccc 0111 0101 xxxx xxxx xxxx 11x1 xxxx : */ | ||
1443 | if ((insn & 0x0ff000d0) == 0x075000d0) | ||
1293 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); | 1444 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); |
1294 | 1445 | ||
1295 | /* SMUSD : cccc 0111 0000 xxxx xxxx xxxx 01x1 xxxx : */ | 1446 | /* SBFX : cccc 0111 101x xxxx xxxx xxxx x101 xxxx : */ |
1296 | /* SMUAD : cccc 0111 0000 xxxx 1111 xxxx 00x1 xxxx :Q */ | 1447 | /* UBFX : cccc 0111 111x xxxx xxxx xxxx x101 xxxx : */ |
1297 | /* SMMUL : cccc 0111 0101 xxxx 1111 xxxx 00x1 xxxx : */ | 1448 | if ((insn & 0x0fa00070) == 0x07a00050) |
1298 | return prep_emulate_rd16rs8rm0_wflags(insn, asi); | 1449 | return prep_emulate_rd12rm0(insn, asi); |
1450 | |||
1451 | /* BFI : cccc 0111 110x xxxx xxxx xxxx x001 xxxx : */ | ||
1452 | /* BFC : cccc 0111 110x xxxx xxxx xxxx x001 1111 : */ | ||
1453 | if ((insn & 0x0fe00070) == 0x07c00010) { | ||
1454 | |||
1455 | if ((insn & 0x0000000f) == 0x0000000f) | ||
1456 | return prep_emulate_rd12_modify(insn, asi); | ||
1457 | else | ||
1458 | return prep_emulate_rd12rn0_modify(insn, asi); | ||
1459 | } | ||
1460 | |||
1461 | return INSN_REJECTED; | ||
1299 | } | 1462 | } |
1300 | 1463 | ||
1301 | static enum kprobe_insn __kprobes | 1464 | static enum kprobe_insn __kprobes |
@@ -1309,6 +1472,10 @@ space_cccc_01xx(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1309 | /* STRB : cccc 01xx x1x0 xxxx xxxx xxxx xxxx xxxx */ | 1472 | /* STRB : cccc 01xx x1x0 xxxx xxxx xxxx xxxx xxxx */ |
1310 | /* STRBT : cccc 01x0 x110 xxxx xxxx xxxx xxxx xxxx */ | 1473 | /* STRBT : cccc 01x0 x110 xxxx xxxx xxxx xxxx xxxx */ |
1311 | /* STRT : cccc 01x0 x010 xxxx xxxx xxxx xxxx xxxx */ | 1474 | /* STRT : cccc 01x0 x010 xxxx xxxx xxxx xxxx xxxx */ |
1475 | |||
1476 | if ((insn & 0x00500000) == 0x00500000 && is_r15(insn, 12)) | ||
1477 | return INSN_REJECTED; /* LDRB into PC */ | ||
1478 | |||
1312 | return prep_emulate_ldr_str(insn, asi); | 1479 | return prep_emulate_ldr_str(insn, asi); |
1313 | } | 1480 | } |
1314 | 1481 | ||
@@ -1323,10 +1490,9 @@ space_cccc_100x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1323 | 1490 | ||
1324 | /* LDM(1) : cccc 100x x0x1 xxxx xxxx xxxx xxxx xxxx */ | 1491 | /* LDM(1) : cccc 100x x0x1 xxxx xxxx xxxx xxxx xxxx */ |
1325 | /* STM(1) : cccc 100x x0x0 xxxx xxxx xxxx xxxx xxxx */ | 1492 | /* STM(1) : cccc 100x x0x0 xxxx xxxx xxxx xxxx xxxx */ |
1326 | asi->insn[0] = truecc_insn(insn); | ||
1327 | asi->insn_handler = ((insn & 0x108000) == 0x008000) ? /* STM & R15 */ | 1493 | asi->insn_handler = ((insn & 0x108000) == 0x008000) ? /* STM & R15 */ |
1328 | simulate_stm1_pc : simulate_ldm1stm1; | 1494 | simulate_stm1_pc : simulate_ldm1stm1; |
1329 | return INSN_GOOD; | 1495 | return INSN_GOOD_NO_SLOT; |
1330 | } | 1496 | } |
1331 | 1497 | ||
1332 | static enum kprobe_insn __kprobes | 1498 | static enum kprobe_insn __kprobes |
@@ -1334,58 +1500,117 @@ space_cccc_101x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1334 | { | 1500 | { |
1335 | /* B : cccc 1010 xxxx xxxx xxxx xxxx xxxx xxxx */ | 1501 | /* B : cccc 1010 xxxx xxxx xxxx xxxx xxxx xxxx */ |
1336 | /* BL : cccc 1011 xxxx xxxx xxxx xxxx xxxx xxxx */ | 1502 | /* BL : cccc 1011 xxxx xxxx xxxx xxxx xxxx xxxx */ |
1337 | asi->insn[0] = truecc_insn(insn); | ||
1338 | asi->insn_handler = simulate_bbl; | 1503 | asi->insn_handler = simulate_bbl; |
1339 | return INSN_GOOD; | 1504 | return INSN_GOOD_NO_SLOT; |
1340 | } | 1505 | } |
1341 | 1506 | ||
1342 | static enum kprobe_insn __kprobes | 1507 | static enum kprobe_insn __kprobes |
1343 | space_cccc_1100_010x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | 1508 | space_cccc_11xx(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
1344 | { | 1509 | { |
1510 | /* Coprocessor instructions... */ | ||
1345 | /* MCRR : cccc 1100 0100 xxxx xxxx xxxx xxxx xxxx : (Rd!=Rn) */ | 1511 | /* MCRR : cccc 1100 0100 xxxx xxxx xxxx xxxx xxxx : (Rd!=Rn) */ |
1346 | /* MRRC : cccc 1100 0101 xxxx xxxx xxxx xxxx xxxx : (Rd!=Rn) */ | 1512 | /* MRRC : cccc 1100 0101 xxxx xxxx xxxx xxxx xxxx : (Rd!=Rn) */ |
1347 | insn &= 0xfff00fff; | 1513 | /* LDC : cccc 110x xxx1 xxxx xxxx xxxx xxxx xxxx */ |
1348 | insn |= 0x00001000; /* Rn = r0, Rd = r1 */ | 1514 | /* STC : cccc 110x xxx0 xxxx xxxx xxxx xxxx xxxx */ |
1349 | asi->insn[0] = insn; | 1515 | /* CDP : cccc 1110 xxxx xxxx xxxx xxxx xxx0 xxxx */ |
1350 | asi->insn_handler = (insn & (1 << 20)) ? emulate_mrrc : emulate_mcrr; | 1516 | /* MCR : cccc 1110 xxx0 xxxx xxxx xxxx xxx1 xxxx */ |
1351 | return INSN_GOOD; | 1517 | /* MRC : cccc 1110 xxx1 xxxx xxxx xxxx xxx1 xxxx */ |
1518 | |||
1519 | /* SVC : cccc 1111 xxxx xxxx xxxx xxxx xxxx xxxx */ | ||
1520 | |||
1521 | return INSN_REJECTED; | ||
1352 | } | 1522 | } |
1353 | 1523 | ||
1354 | static enum kprobe_insn __kprobes | 1524 | static unsigned long __kprobes __check_eq(unsigned long cpsr) |
1355 | space_cccc_110x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | ||
1356 | { | 1525 | { |
1357 | /* LDC : cccc 110x xxx1 xxxx xxxx xxxx xxxx xxxx */ | 1526 | return cpsr & PSR_Z_BIT; |
1358 | /* STC : cccc 110x xxx0 xxxx xxxx xxxx xxxx xxxx */ | ||
1359 | insn &= 0xfff0ffff; /* Rn = r0 */ | ||
1360 | asi->insn[0] = insn; | ||
1361 | asi->insn_handler = emulate_ldcstc; | ||
1362 | return INSN_GOOD; | ||
1363 | } | 1527 | } |
1364 | 1528 | ||
1365 | static enum kprobe_insn __kprobes | 1529 | static unsigned long __kprobes __check_ne(unsigned long cpsr) |
1366 | space_cccc_111x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | ||
1367 | { | 1530 | { |
1368 | /* BKPT : 1110 0001 0010 xxxx xxxx xxxx 0111 xxxx */ | 1531 | return (~cpsr) & PSR_Z_BIT; |
1369 | /* SWI : cccc 1111 xxxx xxxx xxxx xxxx xxxx xxxx */ | 1532 | } |
1370 | if ((insn & 0xfff000f0) == 0xe1200070 || | ||
1371 | (insn & 0x0f000000) == 0x0f000000) | ||
1372 | return INSN_REJECTED; | ||
1373 | 1533 | ||
1374 | /* CDP : cccc 1110 xxxx xxxx xxxx xxxx xxx0 xxxx */ | 1534 | static unsigned long __kprobes __check_cs(unsigned long cpsr) |
1375 | if ((insn & 0x0f000010) == 0x0e000000) { | 1535 | { |
1376 | asi->insn[0] = insn; | 1536 | return cpsr & PSR_C_BIT; |
1377 | asi->insn_handler = emulate_none; | 1537 | } |
1378 | return INSN_GOOD; | ||
1379 | } | ||
1380 | 1538 | ||
1381 | /* MCR : cccc 1110 xxx0 xxxx xxxx xxxx xxx1 xxxx */ | 1539 | static unsigned long __kprobes __check_cc(unsigned long cpsr) |
1382 | /* MRC : cccc 1110 xxx1 xxxx xxxx xxxx xxx1 xxxx */ | 1540 | { |
1383 | insn &= 0xffff0fff; /* Rd = r0 */ | 1541 | return (~cpsr) & PSR_C_BIT; |
1384 | asi->insn[0] = insn; | 1542 | } |
1385 | asi->insn_handler = (insn & (1 << 20)) ? emulate_rd12 : emulate_ird12; | 1543 | |
1386 | return INSN_GOOD; | 1544 | static unsigned long __kprobes __check_mi(unsigned long cpsr) |
1545 | { | ||
1546 | return cpsr & PSR_N_BIT; | ||
1547 | } | ||
1548 | |||
1549 | static unsigned long __kprobes __check_pl(unsigned long cpsr) | ||
1550 | { | ||
1551 | return (~cpsr) & PSR_N_BIT; | ||
1552 | } | ||
1553 | |||
1554 | static unsigned long __kprobes __check_vs(unsigned long cpsr) | ||
1555 | { | ||
1556 | return cpsr & PSR_V_BIT; | ||
1557 | } | ||
1558 | |||
1559 | static unsigned long __kprobes __check_vc(unsigned long cpsr) | ||
1560 | { | ||
1561 | return (~cpsr) & PSR_V_BIT; | ||
1562 | } | ||
1563 | |||
1564 | static unsigned long __kprobes __check_hi(unsigned long cpsr) | ||
1565 | { | ||
1566 | cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ | ||
1567 | return cpsr & PSR_C_BIT; | ||
1387 | } | 1568 | } |
1388 | 1569 | ||
1570 | static unsigned long __kprobes __check_ls(unsigned long cpsr) | ||
1571 | { | ||
1572 | cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ | ||
1573 | return (~cpsr) & PSR_C_BIT; | ||
1574 | } | ||
1575 | |||
1576 | static unsigned long __kprobes __check_ge(unsigned long cpsr) | ||
1577 | { | ||
1578 | cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
1579 | return (~cpsr) & PSR_N_BIT; | ||
1580 | } | ||
1581 | |||
1582 | static unsigned long __kprobes __check_lt(unsigned long cpsr) | ||
1583 | { | ||
1584 | cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
1585 | return cpsr & PSR_N_BIT; | ||
1586 | } | ||
1587 | |||
1588 | static unsigned long __kprobes __check_gt(unsigned long cpsr) | ||
1589 | { | ||
1590 | unsigned long temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
1591 | temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */ | ||
1592 | return (~temp) & PSR_N_BIT; | ||
1593 | } | ||
1594 | |||
1595 | static unsigned long __kprobes __check_le(unsigned long cpsr) | ||
1596 | { | ||
1597 | unsigned long temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
1598 | temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */ | ||
1599 | return temp & PSR_N_BIT; | ||
1600 | } | ||
1601 | |||
1602 | static unsigned long __kprobes __check_al(unsigned long cpsr) | ||
1603 | { | ||
1604 | return true; | ||
1605 | } | ||
1606 | |||
1607 | static kprobe_check_cc * const condition_checks[16] = { | ||
1608 | &__check_eq, &__check_ne, &__check_cs, &__check_cc, | ||
1609 | &__check_mi, &__check_pl, &__check_vs, &__check_vc, | ||
1610 | &__check_hi, &__check_ls, &__check_ge, &__check_lt, | ||
1611 | &__check_gt, &__check_le, &__check_al, &__check_al | ||
1612 | }; | ||
1613 | |||
1389 | /* Return: | 1614 | /* Return: |
1390 | * INSN_REJECTED If instruction is one not allowed to kprobe, | 1615 | * INSN_REJECTED If instruction is one not allowed to kprobe, |
1391 | * INSN_GOOD If instruction is supported and uses instruction slot, | 1616 | * INSN_GOOD If instruction is supported and uses instruction slot, |
@@ -1401,133 +1626,45 @@ space_cccc_111x(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1401 | enum kprobe_insn __kprobes | 1626 | enum kprobe_insn __kprobes |
1402 | arm_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi) | 1627 | arm_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
1403 | { | 1628 | { |
1629 | asi->insn_check_cc = condition_checks[insn>>28]; | ||
1404 | asi->insn[1] = KPROBE_RETURN_INSTRUCTION; | 1630 | asi->insn[1] = KPROBE_RETURN_INSTRUCTION; |
1405 | 1631 | ||
1406 | if ((insn & 0xf0000000) == 0xf0000000) { | 1632 | if ((insn & 0xf0000000) == 0xf0000000) |
1407 | 1633 | ||
1408 | return space_1111(insn, asi); | 1634 | return space_1111(insn, asi); |
1409 | 1635 | ||
1410 | } else if ((insn & 0x0e000000) == 0x00000000) { | 1636 | else if ((insn & 0x0e000000) == 0x00000000) |
1411 | 1637 | ||
1412 | return space_cccc_000x(insn, asi); | 1638 | return space_cccc_000x(insn, asi); |
1413 | 1639 | ||
1414 | } else if ((insn & 0x0e000000) == 0x02000000) { | 1640 | else if ((insn & 0x0e000000) == 0x02000000) |
1415 | 1641 | ||
1416 | return space_cccc_001x(insn, asi); | 1642 | return space_cccc_001x(insn, asi); |
1417 | 1643 | ||
1418 | } else if ((insn & 0x0f000010) == 0x06000010) { | 1644 | else if ((insn & 0x0f000010) == 0x06000010) |
1419 | 1645 | ||
1420 | return space_cccc_0110__1(insn, asi); | 1646 | return space_cccc_0110__1(insn, asi); |
1421 | 1647 | ||
1422 | } else if ((insn & 0x0f000010) == 0x07000010) { | 1648 | else if ((insn & 0x0f000010) == 0x07000010) |
1423 | 1649 | ||
1424 | return space_cccc_0111__1(insn, asi); | 1650 | return space_cccc_0111__1(insn, asi); |
1425 | 1651 | ||
1426 | } else if ((insn & 0x0c000000) == 0x04000000) { | 1652 | else if ((insn & 0x0c000000) == 0x04000000) |
1427 | 1653 | ||
1428 | return space_cccc_01xx(insn, asi); | 1654 | return space_cccc_01xx(insn, asi); |
1429 | 1655 | ||
1430 | } else if ((insn & 0x0e000000) == 0x08000000) { | 1656 | else if ((insn & 0x0e000000) == 0x08000000) |
1431 | 1657 | ||
1432 | return space_cccc_100x(insn, asi); | 1658 | return space_cccc_100x(insn, asi); |
1433 | 1659 | ||
1434 | } else if ((insn & 0x0e000000) == 0x0a000000) { | 1660 | else if ((insn & 0x0e000000) == 0x0a000000) |
1435 | 1661 | ||
1436 | return space_cccc_101x(insn, asi); | 1662 | return space_cccc_101x(insn, asi); |
1437 | 1663 | ||
1438 | } else if ((insn & 0x0fe00000) == 0x0c400000) { | 1664 | return space_cccc_11xx(insn, asi); |
1439 | |||
1440 | return space_cccc_1100_010x(insn, asi); | ||
1441 | |||
1442 | } else if ((insn & 0x0e000000) == 0x0c000000) { | ||
1443 | |||
1444 | return space_cccc_110x(insn, asi); | ||
1445 | |||
1446 | } | ||
1447 | |||
1448 | return space_cccc_111x(insn, asi); | ||
1449 | } | 1665 | } |
1450 | 1666 | ||
1451 | void __init arm_kprobe_decode_init(void) | 1667 | void __init arm_kprobe_decode_init(void) |
1452 | { | 1668 | { |
1453 | find_str_pc_offset(); | 1669 | find_str_pc_offset(); |
1454 | } | 1670 | } |
1455 | |||
1456 | |||
1457 | /* | ||
1458 | * All ARM instructions listed below. | ||
1459 | * | ||
1460 | * Instructions and their general purpose registers are given. | ||
1461 | * If a particular register may not use R15, it is prefixed with a "!". | ||
1462 | * If marked with a "*" means the value returned by reading R15 | ||
1463 | * is implementation defined. | ||
1464 | * | ||
1465 | * ADC/ADD/AND/BIC/CMN/CMP/EOR/MOV/MVN/ORR/RSB/RSC/SBC/SUB/TEQ | ||
1466 | * TST: Rd, Rn, Rm, !Rs | ||
1467 | * BX: Rm | ||
1468 | * BLX(2): !Rm | ||
1469 | * BX: Rm (R15 legal, but discouraged) | ||
1470 | * BXJ: !Rm, | ||
1471 | * CLZ: !Rd, !Rm | ||
1472 | * CPY: Rd, Rm | ||
1473 | * LDC/2,STC/2 immediate offset & unindex: Rn | ||
1474 | * LDC/2,STC/2 immediate pre/post-indexed: !Rn | ||
1475 | * LDM(1/3): !Rn, register_list | ||
1476 | * LDM(2): !Rn, !register_list | ||
1477 | * LDR,STR,PLD immediate offset: Rd, Rn | ||
1478 | * LDR,STR,PLD register offset: Rd, Rn, !Rm | ||
1479 | * LDR,STR,PLD scaled register offset: Rd, !Rn, !Rm | ||
1480 | * LDR,STR immediate pre/post-indexed: Rd, !Rn | ||
1481 | * LDR,STR register pre/post-indexed: Rd, !Rn, !Rm | ||
1482 | * LDR,STR scaled register pre/post-indexed: Rd, !Rn, !Rm | ||
1483 | * LDRB,STRB immediate offset: !Rd, Rn | ||
1484 | * LDRB,STRB register offset: !Rd, Rn, !Rm | ||
1485 | * LDRB,STRB scaled register offset: !Rd, !Rn, !Rm | ||
1486 | * LDRB,STRB immediate pre/post-indexed: !Rd, !Rn | ||
1487 | * LDRB,STRB register pre/post-indexed: !Rd, !Rn, !Rm | ||
1488 | * LDRB,STRB scaled register pre/post-indexed: !Rd, !Rn, !Rm | ||
1489 | * LDRT,LDRBT,STRBT immediate pre/post-indexed: !Rd, !Rn | ||
1490 | * LDRT,LDRBT,STRBT register pre/post-indexed: !Rd, !Rn, !Rm | ||
1491 | * LDRT,LDRBT,STRBT scaled register pre/post-indexed: !Rd, !Rn, !Rm | ||
1492 | * LDRH/SH/SB/D,STRH/SH/SB/D immediate offset: !Rd, Rn | ||
1493 | * LDRH/SH/SB/D,STRH/SH/SB/D register offset: !Rd, Rn, !Rm | ||
1494 | * LDRH/SH/SB/D,STRH/SH/SB/D immediate pre/post-indexed: !Rd, !Rn | ||
1495 | * LDRH/SH/SB/D,STRH/SH/SB/D register pre/post-indexed: !Rd, !Rn, !Rm | ||
1496 | * LDREX: !Rd, !Rn | ||
1497 | * MCR/2: !Rd | ||
1498 | * MCRR/2,MRRC/2: !Rd, !Rn | ||
1499 | * MLA: !Rd, !Rn, !Rm, !Rs | ||
1500 | * MOV: Rd | ||
1501 | * MRC/2: !Rd (if Rd==15, only changes cond codes, not the register) | ||
1502 | * MRS,MSR: !Rd | ||
1503 | * MUL: !Rd, !Rm, !Rs | ||
1504 | * PKH{BT,TB}: !Rd, !Rn, !Rm | ||
1505 | * QDADD,[U]QADD/16/8/SUBX: !Rd, !Rm, !Rn | ||
1506 | * QDSUB,[U]QSUB/16/8/ADDX: !Rd, !Rm, !Rn | ||
1507 | * REV/16/SH: !Rd, !Rm | ||
1508 | * RFE: !Rn | ||
1509 | * {S,U}[H]ADD{16,8,SUBX},{S,U}[H]SUB{16,8,ADDX}: !Rd, !Rn, !Rm | ||
1510 | * SEL: !Rd, !Rn, !Rm | ||
1511 | * SMLA<x><y>,SMLA{D,W<y>},SMLSD,SMML{A,S}: !Rd, !Rn, !Rm, !Rs | ||
1512 | * SMLAL<x><y>,SMLA{D,LD},SMLSLD,SMMULL,SMULW<y>: !RdHi, !RdLo, !Rm, !Rs | ||
1513 | * SMMUL,SMUAD,SMUL<x><y>,SMUSD: !Rd, !Rm, !Rs | ||
1514 | * SSAT/16: !Rd, !Rm | ||
1515 | * STM(1/2): !Rn, register_list* (R15 in reg list not recommended) | ||
1516 | * STRT immediate pre/post-indexed: Rd*, !Rn | ||
1517 | * STRT register pre/post-indexed: Rd*, !Rn, !Rm | ||
1518 | * STRT scaled register pre/post-indexed: Rd*, !Rn, !Rm | ||
1519 | * STREX: !Rd, !Rn, !Rm | ||
1520 | * SWP/B: !Rd, !Rn, !Rm | ||
1521 | * {S,U}XTA{B,B16,H}: !Rd, !Rn, !Rm | ||
1522 | * {S,U}XT{B,B16,H}: !Rd, !Rm | ||
1523 | * UM{AA,LA,UL}L: !RdHi, !RdLo, !Rm, !Rs | ||
1524 | * USA{D8,A8,T,T16}: !Rd, !Rm, !Rs | ||
1525 | * | ||
1526 | * May transfer control by writing R15 (possible mode changes or alternate | ||
1527 | * mode accesses marked by "*"): | ||
1528 | * ALU op (* with s-bit), B, BL, BKPT, BLX(1/2), BX, BXJ, CPS*, CPY, | ||
1529 | * LDM(1), LDM(2/3)*, LDR, MOV, RFE*, SWI* | ||
1530 | * | ||
1531 | * Instructions that do not take general registers, nor transfer control: | ||
1532 | * CDP/2, SETEND, SRS* | ||
1533 | */ | ||
diff --git a/arch/arm/kernel/kprobes.c b/arch/arm/kernel/kprobes.c index 2ba7deb3072..1656c87501c 100644 --- a/arch/arm/kernel/kprobes.c +++ b/arch/arm/kernel/kprobes.c | |||
@@ -134,7 +134,8 @@ static void __kprobes singlestep(struct kprobe *p, struct pt_regs *regs, | |||
134 | struct kprobe_ctlblk *kcb) | 134 | struct kprobe_ctlblk *kcb) |
135 | { | 135 | { |
136 | regs->ARM_pc += 4; | 136 | regs->ARM_pc += 4; |
137 | p->ainsn.insn_handler(p, regs); | 137 | if (p->ainsn.insn_check_cc(regs->ARM_cpsr)) |
138 | p->ainsn.insn_handler(p, regs); | ||
138 | } | 139 | } |
139 | 140 | ||
140 | /* | 141 | /* |
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c index 979da3947f4..139e3c82736 100644 --- a/arch/arm/kernel/perf_event.c +++ b/arch/arm/kernel/perf_event.c | |||
@@ -746,7 +746,8 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs) | |||
746 | 746 | ||
747 | tail = (struct frame_tail __user *)regs->ARM_fp - 1; | 747 | tail = (struct frame_tail __user *)regs->ARM_fp - 1; |
748 | 748 | ||
749 | while (tail && !((unsigned long)tail & 0x3)) | 749 | while ((entry->nr < PERF_MAX_STACK_DEPTH) && |
750 | tail && !((unsigned long)tail & 0x3)) | ||
750 | tail = user_backtrace(tail, entry); | 751 | tail = user_backtrace(tail, entry); |
751 | } | 752 | } |
752 | 753 | ||
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index 2bf27f364d0..8182f45ca49 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c | |||
@@ -767,12 +767,20 @@ long arch_ptrace(struct task_struct *child, long request, | |||
767 | 767 | ||
768 | #ifdef CONFIG_HAVE_HW_BREAKPOINT | 768 | #ifdef CONFIG_HAVE_HW_BREAKPOINT |
769 | case PTRACE_GETHBPREGS: | 769 | case PTRACE_GETHBPREGS: |
770 | if (ptrace_get_breakpoints(child) < 0) | ||
771 | return -ESRCH; | ||
772 | |||
770 | ret = ptrace_gethbpregs(child, addr, | 773 | ret = ptrace_gethbpregs(child, addr, |
771 | (unsigned long __user *)data); | 774 | (unsigned long __user *)data); |
775 | ptrace_put_breakpoints(child); | ||
772 | break; | 776 | break; |
773 | case PTRACE_SETHBPREGS: | 777 | case PTRACE_SETHBPREGS: |
778 | if (ptrace_get_breakpoints(child) < 0) | ||
779 | return -ESRCH; | ||
780 | |||
774 | ret = ptrace_sethbpregs(child, addr, | 781 | ret = ptrace_sethbpregs(child, addr, |
775 | (unsigned long __user *)data); | 782 | (unsigned long __user *)data); |
783 | ptrace_put_breakpoints(child); | ||
776 | break; | 784 | break; |
777 | #endif | 785 | #endif |
778 | 786 | ||
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index cb839831764..0340224cf73 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c | |||
@@ -597,19 +597,13 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | |||
597 | return err; | 597 | return err; |
598 | } | 598 | } |
599 | 599 | ||
600 | static inline void setup_syscall_restart(struct pt_regs *regs) | ||
601 | { | ||
602 | regs->ARM_r0 = regs->ARM_ORIG_r0; | ||
603 | regs->ARM_pc -= thumb_mode(regs) ? 2 : 4; | ||
604 | } | ||
605 | |||
606 | /* | 600 | /* |
607 | * OK, we're invoking a handler | 601 | * OK, we're invoking a handler |
608 | */ | 602 | */ |
609 | static int | 603 | static int |
610 | handle_signal(unsigned long sig, struct k_sigaction *ka, | 604 | handle_signal(unsigned long sig, struct k_sigaction *ka, |
611 | siginfo_t *info, sigset_t *oldset, | 605 | siginfo_t *info, sigset_t *oldset, |
612 | struct pt_regs * regs, int syscall) | 606 | struct pt_regs * regs) |
613 | { | 607 | { |
614 | struct thread_info *thread = current_thread_info(); | 608 | struct thread_info *thread = current_thread_info(); |
615 | struct task_struct *tsk = current; | 609 | struct task_struct *tsk = current; |
@@ -617,26 +611,6 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
617 | int ret; | 611 | int ret; |
618 | 612 | ||
619 | /* | 613 | /* |
620 | * If we were from a system call, check for system call restarting... | ||
621 | */ | ||
622 | if (syscall) { | ||
623 | switch (regs->ARM_r0) { | ||
624 | case -ERESTART_RESTARTBLOCK: | ||
625 | case -ERESTARTNOHAND: | ||
626 | regs->ARM_r0 = -EINTR; | ||
627 | break; | ||
628 | case -ERESTARTSYS: | ||
629 | if (!(ka->sa.sa_flags & SA_RESTART)) { | ||
630 | regs->ARM_r0 = -EINTR; | ||
631 | break; | ||
632 | } | ||
633 | /* fallthrough */ | ||
634 | case -ERESTARTNOINTR: | ||
635 | setup_syscall_restart(regs); | ||
636 | } | ||
637 | } | ||
638 | |||
639 | /* | ||
640 | * translate the signal | 614 | * translate the signal |
641 | */ | 615 | */ |
642 | if (usig < 32 && thread->exec_domain && thread->exec_domain->signal_invmap) | 616 | if (usig < 32 && thread->exec_domain && thread->exec_domain->signal_invmap) |
@@ -685,6 +659,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
685 | */ | 659 | */ |
686 | static void do_signal(struct pt_regs *regs, int syscall) | 660 | static void do_signal(struct pt_regs *regs, int syscall) |
687 | { | 661 | { |
662 | unsigned int retval = 0, continue_addr = 0, restart_addr = 0; | ||
688 | struct k_sigaction ka; | 663 | struct k_sigaction ka; |
689 | siginfo_t info; | 664 | siginfo_t info; |
690 | int signr; | 665 | int signr; |
@@ -698,18 +673,61 @@ static void do_signal(struct pt_regs *regs, int syscall) | |||
698 | if (!user_mode(regs)) | 673 | if (!user_mode(regs)) |
699 | return; | 674 | return; |
700 | 675 | ||
676 | /* | ||
677 | * If we were from a system call, check for system call restarting... | ||
678 | */ | ||
679 | if (syscall) { | ||
680 | continue_addr = regs->ARM_pc; | ||
681 | restart_addr = continue_addr - (thumb_mode(regs) ? 2 : 4); | ||
682 | retval = regs->ARM_r0; | ||
683 | |||
684 | /* | ||
685 | * Prepare for system call restart. We do this here so that a | ||
686 | * debugger will see the already changed PSW. | ||
687 | */ | ||
688 | switch (retval) { | ||
689 | case -ERESTARTNOHAND: | ||
690 | case -ERESTARTSYS: | ||
691 | case -ERESTARTNOINTR: | ||
692 | regs->ARM_r0 = regs->ARM_ORIG_r0; | ||
693 | regs->ARM_pc = restart_addr; | ||
694 | break; | ||
695 | case -ERESTART_RESTARTBLOCK: | ||
696 | regs->ARM_r0 = -EINTR; | ||
697 | break; | ||
698 | } | ||
699 | } | ||
700 | |||
701 | if (try_to_freeze()) | 701 | if (try_to_freeze()) |
702 | goto no_signal; | 702 | goto no_signal; |
703 | 703 | ||
704 | /* | ||
705 | * Get the signal to deliver. When running under ptrace, at this | ||
706 | * point the debugger may change all our registers ... | ||
707 | */ | ||
704 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 708 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
705 | if (signr > 0) { | 709 | if (signr > 0) { |
706 | sigset_t *oldset; | 710 | sigset_t *oldset; |
707 | 711 | ||
712 | /* | ||
713 | * Depending on the signal settings we may need to revert the | ||
714 | * decision to restart the system call. But skip this if a | ||
715 | * debugger has chosen to restart at a different PC. | ||
716 | */ | ||
717 | if (regs->ARM_pc == restart_addr) { | ||
718 | if (retval == -ERESTARTNOHAND | ||
719 | || (retval == -ERESTARTSYS | ||
720 | && !(ka.sa.sa_flags & SA_RESTART))) { | ||
721 | regs->ARM_r0 = -EINTR; | ||
722 | regs->ARM_pc = continue_addr; | ||
723 | } | ||
724 | } | ||
725 | |||
708 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) | 726 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) |
709 | oldset = ¤t->saved_sigmask; | 727 | oldset = ¤t->saved_sigmask; |
710 | else | 728 | else |
711 | oldset = ¤t->blocked; | 729 | oldset = ¤t->blocked; |
712 | if (handle_signal(signr, &ka, &info, oldset, regs, syscall) == 0) { | 730 | if (handle_signal(signr, &ka, &info, oldset, regs) == 0) { |
713 | /* | 731 | /* |
714 | * A signal was successfully delivered; the saved | 732 | * A signal was successfully delivered; the saved |
715 | * sigmask will have been stored in the signal frame, | 733 | * sigmask will have been stored in the signal frame, |
@@ -723,11 +741,14 @@ static void do_signal(struct pt_regs *regs, int syscall) | |||
723 | } | 741 | } |
724 | 742 | ||
725 | no_signal: | 743 | no_signal: |
726 | /* | ||
727 | * No signal to deliver to the process - restart the syscall. | ||
728 | */ | ||
729 | if (syscall) { | 744 | if (syscall) { |
730 | if (regs->ARM_r0 == -ERESTART_RESTARTBLOCK) { | 745 | /* |
746 | * Handle restarting a different system call. As above, | ||
747 | * if a debugger has chosen to restart at a different PC, | ||
748 | * ignore the restart. | ||
749 | */ | ||
750 | if (retval == -ERESTART_RESTARTBLOCK | ||
751 | && regs->ARM_pc == continue_addr) { | ||
731 | if (thumb_mode(regs)) { | 752 | if (thumb_mode(regs)) { |
732 | regs->ARM_r7 = __NR_restart_syscall - __NR_SYSCALL_BASE; | 753 | regs->ARM_r7 = __NR_restart_syscall - __NR_SYSCALL_BASE; |
733 | regs->ARM_pc -= 2; | 754 | regs->ARM_pc -= 2; |
@@ -750,11 +771,6 @@ static void do_signal(struct pt_regs *regs, int syscall) | |||
750 | #endif | 771 | #endif |
751 | } | 772 | } |
752 | } | 773 | } |
753 | if (regs->ARM_r0 == -ERESTARTNOHAND || | ||
754 | regs->ARM_r0 == -ERESTARTSYS || | ||
755 | regs->ARM_r0 == -ERESTARTNOINTR) { | ||
756 | setup_syscall_restart(regs); | ||
757 | } | ||
758 | 774 | ||
759 | /* If there's no signal to deliver, we just put the saved sigmask | 775 | /* If there's no signal to deliver, we just put the saved sigmask |
760 | * back. | 776 | * back. |
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 8fe05ad932e..f29b8a29b17 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c | |||
@@ -479,7 +479,7 @@ static void broadcast_timer_set_mode(enum clock_event_mode mode, | |||
479 | { | 479 | { |
480 | } | 480 | } |
481 | 481 | ||
482 | static void broadcast_timer_setup(struct clock_event_device *evt) | 482 | static void __cpuinit broadcast_timer_setup(struct clock_event_device *evt) |
483 | { | 483 | { |
484 | evt->name = "dummy_timer"; | 484 | evt->name = "dummy_timer"; |
485 | evt->features = CLOCK_EVT_FEAT_ONESHOT | | 485 | evt->features = CLOCK_EVT_FEAT_ONESHOT | |
diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c index 4ad8da15ef2..af0aaebf4de 100644 --- a/arch/arm/kernel/sys_oabi-compat.c +++ b/arch/arm/kernel/sys_oabi-compat.c | |||
@@ -311,7 +311,7 @@ asmlinkage long sys_oabi_semtimedop(int semid, | |||
311 | long err; | 311 | long err; |
312 | int i; | 312 | int i; |
313 | 313 | ||
314 | if (nsops < 1) | 314 | if (nsops < 1 || nsops > SEMOPM) |
315 | return -EINVAL; | 315 | return -EINVAL; |
316 | sops = kmalloc(sizeof(*sops) * nsops, GFP_KERNEL); | 316 | sops = kmalloc(sizeof(*sops) * nsops, GFP_KERNEL); |
317 | if (!sops) | 317 | if (!sops) |
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 19390231a0e..2d299bf5d72 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig | |||
@@ -83,6 +83,7 @@ config ARCH_AT91CAP9 | |||
83 | select CPU_ARM926T | 83 | select CPU_ARM926T |
84 | select GENERIC_CLOCKEVENTS | 84 | select GENERIC_CLOCKEVENTS |
85 | select HAVE_FB_ATMEL | 85 | select HAVE_FB_ATMEL |
86 | select HAVE_NET_MACB | ||
86 | 87 | ||
87 | config ARCH_AT572D940HF | 88 | config ARCH_AT572D940HF |
88 | bool "AT572D940HF" | 89 | bool "AT572D940HF" |
diff --git a/arch/arm/mach-at91/board-eb01.c b/arch/arm/mach-at91/board-eb01.c index 1f9d3cb64c5..d8df59a3426 100644 --- a/arch/arm/mach-at91/board-eb01.c +++ b/arch/arm/mach-at91/board-eb01.c | |||
@@ -30,6 +30,11 @@ | |||
30 | #include <mach/board.h> | 30 | #include <mach/board.h> |
31 | #include "generic.h" | 31 | #include "generic.h" |
32 | 32 | ||
33 | static void __init at91eb01_init_irq(void) | ||
34 | { | ||
35 | at91x40_init_interrupts(NULL); | ||
36 | } | ||
37 | |||
33 | static void __init at91eb01_map_io(void) | 38 | static void __init at91eb01_map_io(void) |
34 | { | 39 | { |
35 | at91x40_initialize(40000000); | 40 | at91x40_initialize(40000000); |
@@ -38,7 +43,7 @@ static void __init at91eb01_map_io(void) | |||
38 | MACHINE_START(AT91EB01, "Atmel AT91 EB01") | 43 | MACHINE_START(AT91EB01, "Atmel AT91 EB01") |
39 | /* Maintainer: Greg Ungerer <gerg@snapgear.com> */ | 44 | /* Maintainer: Greg Ungerer <gerg@snapgear.com> */ |
40 | .timer = &at91x40_timer, | 45 | .timer = &at91x40_timer, |
41 | .init_irq = at91x40_init_interrupts, | 46 | .init_irq = at91eb01_init_irq, |
42 | .map_io = at91eb01_map_io, | 47 | .map_io = at91eb01_map_io, |
43 | MACHINE_END | 48 | MACHINE_END |
44 | 49 | ||
diff --git a/arch/arm/mach-at91/include/mach/cpu.h b/arch/arm/mach-at91/include/mach/cpu.h index 3bef931d0b1..0700f212530 100644 --- a/arch/arm/mach-at91/include/mach/cpu.h +++ b/arch/arm/mach-at91/include/mach/cpu.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define ARCH_ID_AT91SAM9G45 0x819b05a0 | 27 | #define ARCH_ID_AT91SAM9G45 0x819b05a0 |
28 | #define ARCH_ID_AT91SAM9G45MRL 0x819b05a2 /* aka 9G45-ES2 & non ES lots */ | 28 | #define ARCH_ID_AT91SAM9G45MRL 0x819b05a2 /* aka 9G45-ES2 & non ES lots */ |
29 | #define ARCH_ID_AT91SAM9G45ES 0x819b05a1 /* 9G45-ES (Engineering Sample) */ | 29 | #define ARCH_ID_AT91SAM9G45ES 0x819b05a1 /* 9G45-ES (Engineering Sample) */ |
30 | #define ARCH_ID_AT91SAM9X5 0x819a05a0 | ||
30 | #define ARCH_ID_AT91CAP9 0x039A03A0 | 31 | #define ARCH_ID_AT91CAP9 0x039A03A0 |
31 | 32 | ||
32 | #define ARCH_ID_AT91SAM9XE128 0x329973a0 | 33 | #define ARCH_ID_AT91SAM9XE128 0x329973a0 |
@@ -55,6 +56,12 @@ static inline unsigned long at91_cpu_fully_identify(void) | |||
55 | #define ARCH_EXID_AT91SAM9G46 0x00000003 | 56 | #define ARCH_EXID_AT91SAM9G46 0x00000003 |
56 | #define ARCH_EXID_AT91SAM9G45 0x00000004 | 57 | #define ARCH_EXID_AT91SAM9G45 0x00000004 |
57 | 58 | ||
59 | #define ARCH_EXID_AT91SAM9G15 0x00000000 | ||
60 | #define ARCH_EXID_AT91SAM9G35 0x00000001 | ||
61 | #define ARCH_EXID_AT91SAM9X35 0x00000002 | ||
62 | #define ARCH_EXID_AT91SAM9G25 0x00000003 | ||
63 | #define ARCH_EXID_AT91SAM9X25 0x00000004 | ||
64 | |||
58 | static inline unsigned long at91_exid_identify(void) | 65 | static inline unsigned long at91_exid_identify(void) |
59 | { | 66 | { |
60 | return at91_sys_read(AT91_DBGU_EXID); | 67 | return at91_sys_read(AT91_DBGU_EXID); |
@@ -143,6 +150,27 @@ static inline unsigned long at91cap9_rev_identify(void) | |||
143 | #define cpu_is_at91sam9m11() (0) | 150 | #define cpu_is_at91sam9m11() (0) |
144 | #endif | 151 | #endif |
145 | 152 | ||
153 | #ifdef CONFIG_ARCH_AT91SAM9X5 | ||
154 | #define cpu_is_at91sam9x5() (at91_cpu_identify() == ARCH_ID_AT91SAM9X5) | ||
155 | #define cpu_is_at91sam9g15() (cpu_is_at91sam9x5() && \ | ||
156 | (at91_exid_identify() == ARCH_EXID_AT91SAM9G15)) | ||
157 | #define cpu_is_at91sam9g35() (cpu_is_at91sam9x5() && \ | ||
158 | (at91_exid_identify() == ARCH_EXID_AT91SAM9G35)) | ||
159 | #define cpu_is_at91sam9x35() (cpu_is_at91sam9x5() && \ | ||
160 | (at91_exid_identify() == ARCH_EXID_AT91SAM9X35)) | ||
161 | #define cpu_is_at91sam9g25() (cpu_is_at91sam9x5() && \ | ||
162 | (at91_exid_identify() == ARCH_EXID_AT91SAM9G25)) | ||
163 | #define cpu_is_at91sam9x25() (cpu_is_at91sam9x5() && \ | ||
164 | (at91_exid_identify() == ARCH_EXID_AT91SAM9X25)) | ||
165 | #else | ||
166 | #define cpu_is_at91sam9x5() (0) | ||
167 | #define cpu_is_at91sam9g15() (0) | ||
168 | #define cpu_is_at91sam9g35() (0) | ||
169 | #define cpu_is_at91sam9x35() (0) | ||
170 | #define cpu_is_at91sam9g25() (0) | ||
171 | #define cpu_is_at91sam9x25() (0) | ||
172 | #endif | ||
173 | |||
146 | #ifdef CONFIG_ARCH_AT91CAP9 | 174 | #ifdef CONFIG_ARCH_AT91CAP9 |
147 | #define cpu_is_at91cap9() (at91_cpu_identify() == ARCH_ID_AT91CAP9) | 175 | #define cpu_is_at91cap9() (at91_cpu_identify() == ARCH_ID_AT91CAP9) |
148 | #define cpu_is_at91cap9_revB() (at91cap9_rev_identify() == ARCH_REVISION_CAP9_B) | 176 | #define cpu_is_at91cap9_revB() (at91cap9_rev_identify() == ARCH_REVISION_CAP9_B) |
diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig index 32f147998cd..c0deacae778 100644 --- a/arch/arm/mach-davinci/Kconfig +++ b/arch/arm/mach-davinci/Kconfig | |||
@@ -63,6 +63,7 @@ config MACH_DAVINCI_EVM | |||
63 | depends on ARCH_DAVINCI_DM644x | 63 | depends on ARCH_DAVINCI_DM644x |
64 | select MISC_DEVICES | 64 | select MISC_DEVICES |
65 | select EEPROM_AT24 | 65 | select EEPROM_AT24 |
66 | select I2C | ||
66 | help | 67 | help |
67 | Configure this option to specify the whether the board used | 68 | Configure this option to specify the whether the board used |
68 | for development is a DM644x EVM | 69 | for development is a DM644x EVM |
@@ -72,6 +73,7 @@ config MACH_SFFSDR | |||
72 | depends on ARCH_DAVINCI_DM644x | 73 | depends on ARCH_DAVINCI_DM644x |
73 | select MISC_DEVICES | 74 | select MISC_DEVICES |
74 | select EEPROM_AT24 | 75 | select EEPROM_AT24 |
76 | select I2C | ||
75 | help | 77 | help |
76 | Say Y here to select the Lyrtech Small Form Factor | 78 | Say Y here to select the Lyrtech Small Form Factor |
77 | Software Defined Radio (SFFSDR) board. | 79 | Software Defined Radio (SFFSDR) board. |
@@ -105,6 +107,7 @@ config MACH_DAVINCI_DM6467_EVM | |||
105 | select MACH_DAVINCI_DM6467TEVM | 107 | select MACH_DAVINCI_DM6467TEVM |
106 | select MISC_DEVICES | 108 | select MISC_DEVICES |
107 | select EEPROM_AT24 | 109 | select EEPROM_AT24 |
110 | select I2C | ||
108 | help | 111 | help |
109 | Configure this option to specify the whether the board used | 112 | Configure this option to specify the whether the board used |
110 | for development is a DM6467 EVM | 113 | for development is a DM6467 EVM |
@@ -118,6 +121,7 @@ config MACH_DAVINCI_DM365_EVM | |||
118 | depends on ARCH_DAVINCI_DM365 | 121 | depends on ARCH_DAVINCI_DM365 |
119 | select MISC_DEVICES | 122 | select MISC_DEVICES |
120 | select EEPROM_AT24 | 123 | select EEPROM_AT24 |
124 | select I2C | ||
121 | help | 125 | help |
122 | Configure this option to specify whether the board used | 126 | Configure this option to specify whether the board used |
123 | for development is a DM365 EVM | 127 | for development is a DM365 EVM |
@@ -129,6 +133,7 @@ config MACH_DAVINCI_DA830_EVM | |||
129 | select GPIO_PCF857X | 133 | select GPIO_PCF857X |
130 | select MISC_DEVICES | 134 | select MISC_DEVICES |
131 | select EEPROM_AT24 | 135 | select EEPROM_AT24 |
136 | select I2C | ||
132 | help | 137 | help |
133 | Say Y here to select the TI DA830/OMAP-L137/AM17x Evaluation Module. | 138 | Say Y here to select the TI DA830/OMAP-L137/AM17x Evaluation Module. |
134 | 139 | ||
@@ -205,6 +210,7 @@ config MACH_MITYOMAPL138 | |||
205 | depends on ARCH_DAVINCI_DA850 | 210 | depends on ARCH_DAVINCI_DA850 |
206 | select MISC_DEVICES | 211 | select MISC_DEVICES |
207 | select EEPROM_AT24 | 212 | select EEPROM_AT24 |
213 | select I2C | ||
208 | help | 214 | help |
209 | Say Y here to select the Critical Link MityDSP-L138/MityARM-1808 | 215 | Say Y here to select the Critical Link MityDSP-L138/MityARM-1808 |
210 | System on Module. Information on this SoM may be found at | 216 | System on Module. Information on this SoM may be found at |
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c index 2aa79c54f98..606a6f27ed6 100644 --- a/arch/arm/mach-davinci/board-mityomapl138.c +++ b/arch/arm/mach-davinci/board-mityomapl138.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <mach/mux.h> | 29 | #include <mach/mux.h> |
30 | #include <mach/spi.h> | 30 | #include <mach/spi.h> |
31 | 31 | ||
32 | #define MITYOMAPL138_PHY_ID "0:03" | 32 | #define MITYOMAPL138_PHY_ID "" |
33 | 33 | ||
34 | #define FACTORY_CONFIG_MAGIC 0x012C0138 | 34 | #define FACTORY_CONFIG_MAGIC 0x012C0138 |
35 | #define FACTORY_CONFIG_VERSION 0x00010001 | 35 | #define FACTORY_CONFIG_VERSION 0x00010001 |
@@ -414,7 +414,7 @@ static struct resource mityomapl138_nandflash_resource[] = { | |||
414 | 414 | ||
415 | static struct platform_device mityomapl138_nandflash_device = { | 415 | static struct platform_device mityomapl138_nandflash_device = { |
416 | .name = "davinci_nand", | 416 | .name = "davinci_nand", |
417 | .id = 0, | 417 | .id = 1, |
418 | .dev = { | 418 | .dev = { |
419 | .platform_data = &mityomapl138_nandflash_data, | 419 | .platform_data = &mityomapl138_nandflash_data, |
420 | }, | 420 | }, |
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index 625d4b66718..58a02dc7b15 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c | |||
@@ -39,7 +39,8 @@ | |||
39 | #define DA8XX_GPIO_BASE 0x01e26000 | 39 | #define DA8XX_GPIO_BASE 0x01e26000 |
40 | #define DA8XX_I2C1_BASE 0x01e28000 | 40 | #define DA8XX_I2C1_BASE 0x01e28000 |
41 | #define DA8XX_SPI0_BASE 0x01c41000 | 41 | #define DA8XX_SPI0_BASE 0x01c41000 |
42 | #define DA8XX_SPI1_BASE 0x01f0e000 | 42 | #define DA830_SPI1_BASE 0x01e12000 |
43 | #define DA850_SPI1_BASE 0x01f0e000 | ||
43 | 44 | ||
44 | #define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000 | 45 | #define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000 |
45 | #define DA8XX_EMAC_MOD_REG_OFFSET 0x2000 | 46 | #define DA8XX_EMAC_MOD_REG_OFFSET 0x2000 |
@@ -762,8 +763,8 @@ static struct resource da8xx_spi0_resources[] = { | |||
762 | 763 | ||
763 | static struct resource da8xx_spi1_resources[] = { | 764 | static struct resource da8xx_spi1_resources[] = { |
764 | [0] = { | 765 | [0] = { |
765 | .start = DA8XX_SPI1_BASE, | 766 | .start = DA830_SPI1_BASE, |
766 | .end = DA8XX_SPI1_BASE + SZ_4K - 1, | 767 | .end = DA830_SPI1_BASE + SZ_4K - 1, |
767 | .flags = IORESOURCE_MEM, | 768 | .flags = IORESOURCE_MEM, |
768 | }, | 769 | }, |
769 | [1] = { | 770 | [1] = { |
@@ -832,5 +833,10 @@ int __init da8xx_register_spi(int instance, struct spi_board_info *info, | |||
832 | 833 | ||
833 | da8xx_spi_pdata[instance].num_chipselect = len; | 834 | da8xx_spi_pdata[instance].num_chipselect = len; |
834 | 835 | ||
836 | if (instance == 1 && cpu_is_davinci_da850()) { | ||
837 | da8xx_spi1_resources[0].start = DA850_SPI1_BASE; | ||
838 | da8xx_spi1_resources[0].end = DA850_SPI1_BASE + SZ_4K - 1; | ||
839 | } | ||
840 | |||
835 | return platform_device_register(&da8xx_spi_device[instance]); | 841 | return platform_device_register(&da8xx_spi_device[instance]); |
836 | } | 842 | } |
diff --git a/arch/arm/mach-davinci/include/mach/debug-macro.S b/arch/arm/mach-davinci/include/mach/debug-macro.S index 9f1befc5ac3..f8b7ea4f623 100644 --- a/arch/arm/mach-davinci/include/mach/debug-macro.S +++ b/arch/arm/mach-davinci/include/mach/debug-macro.S | |||
@@ -24,6 +24,9 @@ | |||
24 | 24 | ||
25 | #define UART_SHIFT 2 | 25 | #define UART_SHIFT 2 |
26 | 26 | ||
27 | #define davinci_uart_v2p(x) ((x) - PAGE_OFFSET + PLAT_PHYS_OFFSET) | ||
28 | #define davinci_uart_p2v(x) ((x) - PLAT_PHYS_OFFSET + PAGE_OFFSET) | ||
29 | |||
27 | .pushsection .data | 30 | .pushsection .data |
28 | davinci_uart_phys: .word 0 | 31 | davinci_uart_phys: .word 0 |
29 | davinci_uart_virt: .word 0 | 32 | davinci_uart_virt: .word 0 |
@@ -34,7 +37,7 @@ davinci_uart_virt: .word 0 | |||
34 | /* Use davinci_uart_phys/virt if already configured */ | 37 | /* Use davinci_uart_phys/virt if already configured */ |
35 | 10: mrc p15, 0, \rp, c1, c0 | 38 | 10: mrc p15, 0, \rp, c1, c0 |
36 | tst \rp, #1 @ MMU enabled? | 39 | tst \rp, #1 @ MMU enabled? |
37 | ldreq \rp, =__virt_to_phys(davinci_uart_phys) | 40 | ldreq \rp, =davinci_uart_v2p(davinci_uart_phys) |
38 | ldrne \rp, =davinci_uart_phys | 41 | ldrne \rp, =davinci_uart_phys |
39 | add \rv, \rp, #4 @ davinci_uart_virt | 42 | add \rv, \rp, #4 @ davinci_uart_virt |
40 | ldr \rp, [\rp, #0] | 43 | ldr \rp, [\rp, #0] |
@@ -48,18 +51,18 @@ davinci_uart_virt: .word 0 | |||
48 | tst \rp, #1 @ MMU enabled? | 51 | tst \rp, #1 @ MMU enabled? |
49 | 52 | ||
50 | /* Copy uart phys address from decompressor uart info */ | 53 | /* Copy uart phys address from decompressor uart info */ |
51 | ldreq \rv, =__virt_to_phys(davinci_uart_phys) | 54 | ldreq \rv, =davinci_uart_v2p(davinci_uart_phys) |
52 | ldrne \rv, =davinci_uart_phys | 55 | ldrne \rv, =davinci_uart_phys |
53 | ldreq \rp, =DAVINCI_UART_INFO | 56 | ldreq \rp, =DAVINCI_UART_INFO |
54 | ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO) | 57 | ldrne \rp, =davinci_uart_p2v(DAVINCI_UART_INFO) |
55 | ldr \rp, [\rp, #0] | 58 | ldr \rp, [\rp, #0] |
56 | str \rp, [\rv] | 59 | str \rp, [\rv] |
57 | 60 | ||
58 | /* Copy uart virt address from decompressor uart info */ | 61 | /* Copy uart virt address from decompressor uart info */ |
59 | ldreq \rv, =__virt_to_phys(davinci_uart_virt) | 62 | ldreq \rv, =davinci_uart_v2p(davinci_uart_virt) |
60 | ldrne \rv, =davinci_uart_virt | 63 | ldrne \rv, =davinci_uart_virt |
61 | ldreq \rp, =DAVINCI_UART_INFO | 64 | ldreq \rp, =DAVINCI_UART_INFO |
62 | ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO) | 65 | ldrne \rp, =davinci_uart_p2v(DAVINCI_UART_INFO) |
63 | ldr \rp, [\rp, #4] | 66 | ldr \rp, [\rp, #4] |
64 | str \rp, [\rv] | 67 | str \rp, [\rv] |
65 | 68 | ||
diff --git a/arch/arm/mach-davinci/include/mach/serial.h b/arch/arm/mach-davinci/include/mach/serial.h index 8051110b8ac..c9e6ce185a6 100644 --- a/arch/arm/mach-davinci/include/mach/serial.h +++ b/arch/arm/mach-davinci/include/mach/serial.h | |||
@@ -22,7 +22,7 @@ | |||
22 | * | 22 | * |
23 | * This area sits just below the page tables (see arch/arm/kernel/head.S). | 23 | * This area sits just below the page tables (see arch/arm/kernel/head.S). |
24 | */ | 24 | */ |
25 | #define DAVINCI_UART_INFO (PHYS_OFFSET + 0x3ff8) | 25 | #define DAVINCI_UART_INFO (PLAT_PHYS_OFFSET + 0x3ff8) |
26 | 26 | ||
27 | #define DAVINCI_UART0_BASE (IO_PHYS + 0x20000) | 27 | #define DAVINCI_UART0_BASE (IO_PHYS + 0x20000) |
28 | #define DAVINCI_UART1_BASE (IO_PHYS + 0x20400) | 28 | #define DAVINCI_UART1_BASE (IO_PHYS + 0x20400) |
diff --git a/arch/arm/mach-mx3/mach-vpr200.c b/arch/arm/mach-mx3/mach-vpr200.c index 2cf390fbd98..47a69cbc31a 100644 --- a/arch/arm/mach-mx3/mach-vpr200.c +++ b/arch/arm/mach-mx3/mach-vpr200.c | |||
@@ -257,11 +257,16 @@ static const struct fsl_usb2_platform_data otg_device_pdata __initconst = { | |||
257 | .workaround = FLS_USB2_WORKAROUND_ENGCM09152, | 257 | .workaround = FLS_USB2_WORKAROUND_ENGCM09152, |
258 | }; | 258 | }; |
259 | 259 | ||
260 | static int vpr200_usbh_init(struct platform_device *pdev) | ||
261 | { | ||
262 | return mx35_initialize_usb_hw(pdev->id, | ||
263 | MXC_EHCI_INTERFACE_SINGLE_UNI | MXC_EHCI_INTERNAL_PHY); | ||
264 | } | ||
265 | |||
260 | /* USB HOST config */ | 266 | /* USB HOST config */ |
261 | static const struct mxc_usbh_platform_data usb_host_pdata __initconst = { | 267 | static const struct mxc_usbh_platform_data usb_host_pdata __initconst = { |
262 | .portsc = MXC_EHCI_MODE_SERIAL, | 268 | .init = vpr200_usbh_init, |
263 | .flags = MXC_EHCI_INTERFACE_SINGLE_UNI | | 269 | .portsc = MXC_EHCI_MODE_SERIAL, |
264 | MXC_EHCI_INTERNAL_PHY, | ||
265 | }; | 270 | }; |
266 | 271 | ||
267 | static struct platform_device *devices[] __initdata = { | 272 | static struct platform_device *devices[] __initdata = { |
diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c index 10a1bea1054..6206b1191fe 100644 --- a/arch/arm/mach-mx5/board-mx53_loco.c +++ b/arch/arm/mach-mx5/board-mx53_loco.c | |||
@@ -193,7 +193,7 @@ static iomux_v3_cfg_t mx53_loco_pads[] = { | |||
193 | .wakeup = wake, \ | 193 | .wakeup = wake, \ |
194 | } | 194 | } |
195 | 195 | ||
196 | static const struct gpio_keys_button loco_buttons[] __initconst = { | 196 | static struct gpio_keys_button loco_buttons[] = { |
197 | GPIO_BUTTON(MX53_LOCO_POWER, KEY_POWER, 1, "power", 0), | 197 | GPIO_BUTTON(MX53_LOCO_POWER, KEY_POWER, 1, "power", 0), |
198 | GPIO_BUTTON(MX53_LOCO_UI1, KEY_VOLUMEUP, 1, "volume-up", 0), | 198 | GPIO_BUTTON(MX53_LOCO_UI1, KEY_VOLUMEUP, 1, "volume-up", 0), |
199 | GPIO_BUTTON(MX53_LOCO_UI2, KEY_VOLUMEDOWN, 1, "volume-down", 0), | 199 | GPIO_BUTTON(MX53_LOCO_UI2, KEY_VOLUMEDOWN, 1, "volume-down", 0), |
diff --git a/arch/arm/mach-mxs/clock-mx28.c b/arch/arm/mach-mxs/clock-mx28.c index 1ad97fed1e9..5dcc59d5b9e 100644 --- a/arch/arm/mach-mxs/clock-mx28.c +++ b/arch/arm/mach-mxs/clock-mx28.c | |||
@@ -295,11 +295,11 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \ | |||
295 | unsigned long diff, parent_rate, calc_rate; \ | 295 | unsigned long diff, parent_rate, calc_rate; \ |
296 | int i; \ | 296 | int i; \ |
297 | \ | 297 | \ |
298 | parent_rate = clk_get_rate(clk->parent); \ | ||
299 | div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ | 298 | div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ |
300 | bm_busy = BM_CLKCTRL_##dr##_BUSY; \ | 299 | bm_busy = BM_CLKCTRL_##dr##_BUSY; \ |
301 | \ | 300 | \ |
302 | if (clk->parent == &ref_xtal_clk) { \ | 301 | if (clk->parent == &ref_xtal_clk) { \ |
302 | parent_rate = clk_get_rate(clk->parent); \ | ||
303 | div = DIV_ROUND_UP(parent_rate, rate); \ | 303 | div = DIV_ROUND_UP(parent_rate, rate); \ |
304 | if (clk == &cpu_clk) { \ | 304 | if (clk == &cpu_clk) { \ |
305 | div_max = BM_CLKCTRL_CPU_DIV_XTAL >> \ | 305 | div_max = BM_CLKCTRL_CPU_DIV_XTAL >> \ |
@@ -309,6 +309,11 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \ | |||
309 | if (div == 0 || div > div_max) \ | 309 | if (div == 0 || div > div_max) \ |
310 | return -EINVAL; \ | 310 | return -EINVAL; \ |
311 | } else { \ | 311 | } else { \ |
312 | /* \ | ||
313 | * hack alert: this block modifies clk->parent, too, \ | ||
314 | * so the base to use it the grand parent. \ | ||
315 | */ \ | ||
316 | parent_rate = clk_get_rate(clk->parent->parent); \ | ||
312 | rate >>= PARENT_RATE_SHIFT; \ | 317 | rate >>= PARENT_RATE_SHIFT; \ |
313 | parent_rate >>= PARENT_RATE_SHIFT; \ | 318 | parent_rate >>= PARENT_RATE_SHIFT; \ |
314 | diff = parent_rate; \ | 319 | diff = parent_rate; \ |
diff --git a/arch/arm/mach-omap2/clkt34xx_dpll3m2.c b/arch/arm/mach-omap2/clkt34xx_dpll3m2.c index b2b1e37bb6b..d6e34dd9e7e 100644 --- a/arch/arm/mach-omap2/clkt34xx_dpll3m2.c +++ b/arch/arm/mach-omap2/clkt34xx_dpll3m2.c | |||
@@ -115,6 +115,7 @@ int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate) | |||
115 | sdrc_cs0->rfr_ctrl, sdrc_cs0->actim_ctrla, | 115 | sdrc_cs0->rfr_ctrl, sdrc_cs0->actim_ctrla, |
116 | sdrc_cs0->actim_ctrlb, sdrc_cs0->mr, | 116 | sdrc_cs0->actim_ctrlb, sdrc_cs0->mr, |
117 | 0, 0, 0, 0); | 117 | 0, 0, 0, 0); |
118 | clk->rate = rate; | ||
118 | 119 | ||
119 | return 0; | 120 | return 0; |
120 | } | 121 | } |
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c index 6de0ad0eea6..9cdcca59792 100644 --- a/arch/arm/mach-pxa/hx4700.c +++ b/arch/arm/mach-pxa/hx4700.c | |||
@@ -711,7 +711,7 @@ static struct regulator_consumer_supply bq24022_consumers[] = { | |||
711 | static struct regulator_init_data bq24022_init_data = { | 711 | static struct regulator_init_data bq24022_init_data = { |
712 | .constraints = { | 712 | .constraints = { |
713 | .max_uA = 500000, | 713 | .max_uA = 500000, |
714 | .valid_ops_mask = REGULATOR_CHANGE_CURRENT, | 714 | .valid_ops_mask = REGULATOR_CHANGE_CURRENT|REGULATOR_CHANGE_STATUS, |
715 | }, | 715 | }, |
716 | .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers), | 716 | .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers), |
717 | .consumer_supplies = bq24022_consumers, | 717 | .consumer_supplies = bq24022_consumers, |
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index a72993dde2b..9984ef70bd7 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c | |||
@@ -599,7 +599,7 @@ static struct regulator_consumer_supply bq24022_consumers[] = { | |||
599 | static struct regulator_init_data bq24022_init_data = { | 599 | static struct regulator_init_data bq24022_init_data = { |
600 | .constraints = { | 600 | .constraints = { |
601 | .max_uA = 500000, | 601 | .max_uA = 500000, |
602 | .valid_ops_mask = REGULATOR_CHANGE_CURRENT, | 602 | .valid_ops_mask = REGULATOR_CHANGE_CURRENT | REGULATOR_CHANGE_STATUS, |
603 | }, | 603 | }, |
604 | .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers), | 604 | .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers), |
605 | .consumer_supplies = bq24022_consumers, | 605 | .consumer_supplies = bq24022_consumers, |
diff --git a/arch/arm/mach-realview/include/mach/barriers.h b/arch/arm/mach-realview/include/mach/barriers.h index 0c5d749d7b5..9a732195aa1 100644 --- a/arch/arm/mach-realview/include/mach/barriers.h +++ b/arch/arm/mach-realview/include/mach/barriers.h | |||
@@ -4,5 +4,5 @@ | |||
4 | * operation to deadlock the system. | 4 | * operation to deadlock the system. |
5 | */ | 5 | */ |
6 | #define mb() dsb() | 6 | #define mb() dsb() |
7 | #define rmb() dmb() | 7 | #define rmb() dsb() |
8 | #define wmb() mb() | 8 | #define wmb() mb() |
diff --git a/arch/arm/mach-tegra/include/mach/barriers.h b/arch/arm/mach-tegra/include/mach/barriers.h index cc115174899..425b42e91ef 100644 --- a/arch/arm/mach-tegra/include/mach/barriers.h +++ b/arch/arm/mach-tegra/include/mach/barriers.h | |||
@@ -23,7 +23,7 @@ | |||
23 | 23 | ||
24 | #include <asm/outercache.h> | 24 | #include <asm/outercache.h> |
25 | 25 | ||
26 | #define rmb() dmb() | 26 | #define rmb() dsb() |
27 | #define wmb() do { dsb(); outer_sync(); } while (0) | 27 | #define wmb() do { dsb(); outer_sync(); } while (0) |
28 | #define mb() wmb() | 28 | #define mb() wmb() |
29 | 29 | ||
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index e5f6fc42834..e591513bb53 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -392,7 +392,7 @@ free_memmap(unsigned long start_pfn, unsigned long end_pfn) | |||
392 | * Convert start_pfn/end_pfn to a struct page pointer. | 392 | * Convert start_pfn/end_pfn to a struct page pointer. |
393 | */ | 393 | */ |
394 | start_pg = pfn_to_page(start_pfn - 1) + 1; | 394 | start_pg = pfn_to_page(start_pfn - 1) + 1; |
395 | end_pg = pfn_to_page(end_pfn); | 395 | end_pg = pfn_to_page(end_pfn - 1) + 1; |
396 | 396 | ||
397 | /* | 397 | /* |
398 | * Convert to physical addresses, and | 398 | * Convert to physical addresses, and |
@@ -426,6 +426,14 @@ static void __init free_unused_memmap(struct meminfo *mi) | |||
426 | 426 | ||
427 | bank_start = bank_pfn_start(bank); | 427 | bank_start = bank_pfn_start(bank); |
428 | 428 | ||
429 | #ifdef CONFIG_SPARSEMEM | ||
430 | /* | ||
431 | * Take care not to free memmap entries that don't exist | ||
432 | * due to SPARSEMEM sections which aren't present. | ||
433 | */ | ||
434 | bank_start = min(bank_start, | ||
435 | ALIGN(prev_bank_end, PAGES_PER_SECTION)); | ||
436 | #endif | ||
429 | /* | 437 | /* |
430 | * If we had a previous bank, and there is a space | 438 | * If we had a previous bank, and there is a space |
431 | * between the current bank and the previous, free it. | 439 | * between the current bank and the previous, free it. |
@@ -440,6 +448,12 @@ static void __init free_unused_memmap(struct meminfo *mi) | |||
440 | */ | 448 | */ |
441 | prev_bank_end = ALIGN(bank_pfn_end(bank), MAX_ORDER_NR_PAGES); | 449 | prev_bank_end = ALIGN(bank_pfn_end(bank), MAX_ORDER_NR_PAGES); |
442 | } | 450 | } |
451 | |||
452 | #ifdef CONFIG_SPARSEMEM | ||
453 | if (!IS_ALIGNED(prev_bank_end, PAGES_PER_SECTION)) | ||
454 | free_memmap(prev_bank_end, | ||
455 | ALIGN(prev_bank_end, PAGES_PER_SECTION)); | ||
456 | #endif | ||
443 | } | 457 | } |
444 | 458 | ||
445 | static void __init free_highpages(void) | 459 | static void __init free_highpages(void) |
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S index ce233bcbf50..42af97664c9 100644 --- a/arch/arm/mm/proc-xscale.S +++ b/arch/arm/mm/proc-xscale.S | |||
@@ -395,7 +395,7 @@ ENTRY(xscale_dma_a0_map_area) | |||
395 | teq r2, #DMA_TO_DEVICE | 395 | teq r2, #DMA_TO_DEVICE |
396 | beq xscale_dma_clean_range | 396 | beq xscale_dma_clean_range |
397 | b xscale_dma_flush_range | 397 | b xscale_dma_flush_range |
398 | ENDPROC(xscsale_dma_a0_map_area) | 398 | ENDPROC(xscale_dma_a0_map_area) |
399 | 399 | ||
400 | /* | 400 | /* |
401 | * dma_unmap_area(start, size, dir) | 401 | * dma_unmap_area(start, size, dir) |
diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c index 7a107246fd9..6cd6d7f686f 100644 --- a/arch/arm/plat-mxc/gpio.c +++ b/arch/arm/plat-mxc/gpio.c | |||
@@ -295,6 +295,12 @@ static int mxc_gpio_direction_output(struct gpio_chip *chip, | |||
295 | return 0; | 295 | return 0; |
296 | } | 296 | } |
297 | 297 | ||
298 | /* | ||
299 | * This lock class tells lockdep that GPIO irqs are in a different | ||
300 | * category than their parents, so it won't report false recursion. | ||
301 | */ | ||
302 | static struct lock_class_key gpio_lock_class; | ||
303 | |||
298 | int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt) | 304 | int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt) |
299 | { | 305 | { |
300 | int i, j; | 306 | int i, j; |
@@ -311,6 +317,7 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt) | |||
311 | __raw_writel(~0, port[i].base + GPIO_ISR); | 317 | __raw_writel(~0, port[i].base + GPIO_ISR); |
312 | for (j = port[i].virtual_irq_start; | 318 | for (j = port[i].virtual_irq_start; |
313 | j < port[i].virtual_irq_start + 32; j++) { | 319 | j < port[i].virtual_irq_start + 32; j++) { |
320 | irq_set_lockdep_class(j, &gpio_lock_class); | ||
314 | irq_set_chip_and_handler(j, &gpio_irq_chip, | 321 | irq_set_chip_and_handler(j, &gpio_irq_chip, |
315 | handle_level_irq); | 322 | handle_level_irq); |
316 | set_irq_flags(j, IRQF_VALID); | 323 | set_irq_flags(j, IRQF_VALID); |
diff --git a/arch/arm/plat-mxc/ssi-fiq.S b/arch/arm/plat-mxc/ssi-fiq.S index 4ddce565b35..8397a2dd19f 100644 --- a/arch/arm/plat-mxc/ssi-fiq.S +++ b/arch/arm/plat-mxc/ssi-fiq.S | |||
@@ -124,6 +124,8 @@ imx_ssi_fiq_start: | |||
124 | 1: | 124 | 1: |
125 | @ return from FIQ | 125 | @ return from FIQ |
126 | subs pc, lr, #4 | 126 | subs pc, lr, #4 |
127 | |||
128 | .align | ||
127 | imx_ssi_fiq_base: | 129 | imx_ssi_fiq_base: |
128 | .word 0x0 | 130 | .word 0x0 |
129 | imx_ssi_fiq_rx_buffer: | 131 | imx_ssi_fiq_rx_buffer: |
diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c index 8a51fd58f65..34fc31ee908 100644 --- a/arch/arm/plat-omap/iommu.c +++ b/arch/arm/plat-omap/iommu.c | |||
@@ -793,6 +793,8 @@ static irqreturn_t iommu_fault_handler(int irq, void *data) | |||
793 | clk_enable(obj->clk); | 793 | clk_enable(obj->clk); |
794 | errs = iommu_report_fault(obj, &da); | 794 | errs = iommu_report_fault(obj, &da); |
795 | clk_disable(obj->clk); | 795 | clk_disable(obj->clk); |
796 | if (errs == 0) | ||
797 | return IRQ_HANDLED; | ||
796 | 798 | ||
797 | /* Fault callback or TLB/PTE Dynamic loading */ | 799 | /* Fault callback or TLB/PTE Dynamic loading */ |
798 | if (obj->isr && !obj->isr(obj, da, errs, obj->isr_priv)) | 800 | if (obj->isr && !obj->isr(obj, da, errs, obj->isr_priv)) |
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 8e256cc5dcd..351c80fbba7 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -997,9 +997,6 @@ config IRQ_GT641XX | |||
997 | config IRQ_GIC | 997 | config IRQ_GIC |
998 | bool | 998 | bool |
999 | 999 | ||
1000 | config IRQ_CPU_OCTEON | ||
1001 | bool | ||
1002 | |||
1003 | config MIPS_BOARDS_GEN | 1000 | config MIPS_BOARDS_GEN |
1004 | bool | 1001 | bool |
1005 | 1002 | ||
@@ -1359,8 +1356,6 @@ config CPU_SB1 | |||
1359 | config CPU_CAVIUM_OCTEON | 1356 | config CPU_CAVIUM_OCTEON |
1360 | bool "Cavium Octeon processor" | 1357 | bool "Cavium Octeon processor" |
1361 | depends on SYS_HAS_CPU_CAVIUM_OCTEON | 1358 | depends on SYS_HAS_CPU_CAVIUM_OCTEON |
1362 | select IRQ_CPU | ||
1363 | select IRQ_CPU_OCTEON | ||
1364 | select CPU_HAS_PREFETCH | 1359 | select CPU_HAS_PREFETCH |
1365 | select CPU_SUPPORTS_64BIT_KERNEL | 1360 | select CPU_SUPPORTS_64BIT_KERNEL |
1366 | select SYS_SUPPORTS_SMP | 1361 | select SYS_SUPPORTS_SMP |
diff --git a/arch/mips/alchemy/devboards/db1x00/board_setup.c b/arch/mips/alchemy/devboards/db1x00/board_setup.c index 05f120ff90f..5c956fe8760 100644 --- a/arch/mips/alchemy/devboards/db1x00/board_setup.c +++ b/arch/mips/alchemy/devboards/db1x00/board_setup.c | |||
@@ -127,13 +127,10 @@ const char *get_system_type(void) | |||
127 | void __init board_setup(void) | 127 | void __init board_setup(void) |
128 | { | 128 | { |
129 | unsigned long bcsr1, bcsr2; | 129 | unsigned long bcsr1, bcsr2; |
130 | u32 pin_func; | ||
131 | 130 | ||
132 | bcsr1 = DB1000_BCSR_PHYS_ADDR; | 131 | bcsr1 = DB1000_BCSR_PHYS_ADDR; |
133 | bcsr2 = DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS; | 132 | bcsr2 = DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS; |
134 | 133 | ||
135 | pin_func = 0; | ||
136 | |||
137 | #ifdef CONFIG_MIPS_DB1000 | 134 | #ifdef CONFIG_MIPS_DB1000 |
138 | printk(KERN_INFO "AMD Alchemy Au1000/Db1000 Board\n"); | 135 | printk(KERN_INFO "AMD Alchemy Au1000/Db1000 Board\n"); |
139 | #endif | 136 | #endif |
@@ -164,12 +161,16 @@ void __init board_setup(void) | |||
164 | /* Not valid for Au1550 */ | 161 | /* Not valid for Au1550 */ |
165 | #if defined(CONFIG_IRDA) && \ | 162 | #if defined(CONFIG_IRDA) && \ |
166 | (defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100)) | 163 | (defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100)) |
167 | /* Set IRFIRSEL instead of GPIO15 */ | 164 | { |
168 | pin_func = au_readl(SYS_PINFUNC) | SYS_PF_IRF; | 165 | u32 pin_func; |
169 | au_writel(pin_func, SYS_PINFUNC); | 166 | |
170 | /* Power off until the driver is in use */ | 167 | /* Set IRFIRSEL instead of GPIO15 */ |
171 | bcsr_mod(BCSR_RESETS, BCSR_RESETS_IRDA_MODE_MASK, | 168 | pin_func = au_readl(SYS_PINFUNC) | SYS_PF_IRF; |
172 | BCSR_RESETS_IRDA_MODE_OFF); | 169 | au_writel(pin_func, SYS_PINFUNC); |
170 | /* Power off until the driver is in use */ | ||
171 | bcsr_mod(BCSR_RESETS, BCSR_RESETS_IRDA_MODE_MASK, | ||
172 | BCSR_RESETS_IRDA_MODE_OFF); | ||
173 | } | ||
173 | #endif | 174 | #endif |
174 | bcsr_write(BCSR_PCMCIA, 0); /* turn off PCMCIA power */ | 175 | bcsr_write(BCSR_PCMCIA, 0); /* turn off PCMCIA power */ |
175 | 176 | ||
@@ -177,31 +178,35 @@ void __init board_setup(void) | |||
177 | alchemy_gpio1_input_enable(); | 178 | alchemy_gpio1_input_enable(); |
178 | 179 | ||
179 | #ifdef CONFIG_MIPS_MIRAGE | 180 | #ifdef CONFIG_MIPS_MIRAGE |
180 | /* GPIO[20] is output */ | 181 | { |
181 | alchemy_gpio_direction_output(20, 0); | 182 | u32 pin_func; |
182 | 183 | ||
183 | /* Set GPIO[210:208] instead of SSI_0 */ | 184 | /* GPIO[20] is output */ |
184 | pin_func = au_readl(SYS_PINFUNC) | SYS_PF_S0; | 185 | alchemy_gpio_direction_output(20, 0); |
185 | 186 | ||
186 | /* Set GPIO[215:211] for LEDs */ | 187 | /* Set GPIO[210:208] instead of SSI_0 */ |
187 | pin_func |= 5 << 2; | 188 | pin_func = au_readl(SYS_PINFUNC) | SYS_PF_S0; |
188 | 189 | ||
189 | /* Set GPIO[214:213] for more LEDs */ | 190 | /* Set GPIO[215:211] for LEDs */ |
190 | pin_func |= 5 << 12; | 191 | pin_func |= 5 << 2; |
191 | 192 | ||
192 | /* Set GPIO[207:200] instead of PCMCIA/LCD */ | 193 | /* Set GPIO[214:213] for more LEDs */ |
193 | pin_func |= SYS_PF_LCD | SYS_PF_PC; | 194 | pin_func |= 5 << 12; |
194 | au_writel(pin_func, SYS_PINFUNC); | ||
195 | 195 | ||
196 | /* | 196 | /* Set GPIO[207:200] instead of PCMCIA/LCD */ |
197 | * Enable speaker amplifier. This should | 197 | pin_func |= SYS_PF_LCD | SYS_PF_PC; |
198 | * be part of the audio driver. | 198 | au_writel(pin_func, SYS_PINFUNC); |
199 | */ | ||
200 | alchemy_gpio_direction_output(209, 1); | ||
201 | 199 | ||
202 | pm_power_off = mirage_power_off; | 200 | /* |
203 | _machine_halt = mirage_power_off; | 201 | * Enable speaker amplifier. This should |
204 | _machine_restart = (void(*)(char *))mips_softreset; | 202 | * be part of the audio driver. |
203 | */ | ||
204 | alchemy_gpio_direction_output(209, 1); | ||
205 | |||
206 | pm_power_off = mirage_power_off; | ||
207 | _machine_halt = mirage_power_off; | ||
208 | _machine_restart = (void(*)(char *))mips_softreset; | ||
209 | } | ||
205 | #endif | 210 | #endif |
206 | 211 | ||
207 | #ifdef CONFIG_MIPS_BOSPORUS | 212 | #ifdef CONFIG_MIPS_BOSPORUS |
diff --git a/arch/mips/alchemy/xxs1500/init.c b/arch/mips/alchemy/xxs1500/init.c index 15125c2fda7..34a90a4bb6f 100644 --- a/arch/mips/alchemy/xxs1500/init.c +++ b/arch/mips/alchemy/xxs1500/init.c | |||
@@ -51,10 +51,9 @@ void __init prom_init(void) | |||
51 | prom_init_cmdline(); | 51 | prom_init_cmdline(); |
52 | 52 | ||
53 | memsize_str = prom_getenv("memsize"); | 53 | memsize_str = prom_getenv("memsize"); |
54 | if (!memsize_str) | 54 | if (!memsize_str || strict_strtoul(memsize_str, 0, &memsize)) |
55 | memsize = 0x04000000; | 55 | memsize = 0x04000000; |
56 | else | 56 | |
57 | strict_strtoul(memsize_str, 0, &memsize); | ||
58 | add_memory_region(0, memsize, BOOT_MEM_RAM); | 57 | add_memory_region(0, memsize, BOOT_MEM_RAM); |
59 | } | 58 | } |
60 | 59 | ||
diff --git a/arch/mips/ar7/gpio.c b/arch/mips/ar7/gpio.c index 425dfa5d6e1..bb571bcdb8f 100644 --- a/arch/mips/ar7/gpio.c +++ b/arch/mips/ar7/gpio.c | |||
@@ -325,9 +325,7 @@ int __init ar7_gpio_init(void) | |||
325 | size = 0x1f; | 325 | size = 0x1f; |
326 | } | 326 | } |
327 | 327 | ||
328 | gpch->regs = ioremap_nocache(AR7_REGS_GPIO, | 328 | gpch->regs = ioremap_nocache(AR7_REGS_GPIO, size); |
329 | AR7_REGS_GPIO + 0x10); | ||
330 | |||
331 | if (!gpch->regs) { | 329 | if (!gpch->regs) { |
332 | printk(KERN_ERR "%s: failed to ioremap regs\n", | 330 | printk(KERN_ERR "%s: failed to ioremap regs\n", |
333 | gpch->chip.label); | 331 | gpch->chip.label); |
diff --git a/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c b/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c index 88c9d963be8..9a6243676e2 100644 --- a/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c +++ b/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c | |||
@@ -16,8 +16,8 @@ | |||
16 | 16 | ||
17 | int main(int argc, char *argv[]) | 17 | int main(int argc, char *argv[]) |
18 | { | 18 | { |
19 | unsigned long long vmlinux_size, vmlinux_load_addr, vmlinuz_load_addr; | ||
19 | struct stat sb; | 20 | struct stat sb; |
20 | uint64_t vmlinux_size, vmlinux_load_addr, vmlinuz_load_addr; | ||
21 | 21 | ||
22 | if (argc != 3) { | 22 | if (argc != 3) { |
23 | fprintf(stderr, "Usage: %s <pathname> <vmlinux_load_addr>\n", | 23 | fprintf(stderr, "Usage: %s <pathname> <vmlinux_load_addr>\n", |
diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig index caae2285816..cad555ebeca 100644 --- a/arch/mips/cavium-octeon/Kconfig +++ b/arch/mips/cavium-octeon/Kconfig | |||
@@ -1,11 +1,7 @@ | |||
1 | config CAVIUM_OCTEON_SPECIFIC_OPTIONS | 1 | if CPU_CAVIUM_OCTEON |
2 | bool "Enable Octeon specific options" | ||
3 | depends on CPU_CAVIUM_OCTEON | ||
4 | default "y" | ||
5 | 2 | ||
6 | config CAVIUM_CN63XXP1 | 3 | config CAVIUM_CN63XXP1 |
7 | bool "Enable CN63XXP1 errata worarounds" | 4 | bool "Enable CN63XXP1 errata worarounds" |
8 | depends on CAVIUM_OCTEON_SPECIFIC_OPTIONS | ||
9 | default "n" | 5 | default "n" |
10 | help | 6 | help |
11 | The CN63XXP1 chip requires build time workarounds to | 7 | The CN63XXP1 chip requires build time workarounds to |
@@ -16,7 +12,6 @@ config CAVIUM_CN63XXP1 | |||
16 | 12 | ||
17 | config CAVIUM_OCTEON_2ND_KERNEL | 13 | config CAVIUM_OCTEON_2ND_KERNEL |
18 | bool "Build the kernel to be used as a 2nd kernel on the same chip" | 14 | bool "Build the kernel to be used as a 2nd kernel on the same chip" |
19 | depends on CAVIUM_OCTEON_SPECIFIC_OPTIONS | ||
20 | default "n" | 15 | default "n" |
21 | help | 16 | help |
22 | This option configures this kernel to be linked at a different | 17 | This option configures this kernel to be linked at a different |
@@ -26,7 +21,6 @@ config CAVIUM_OCTEON_2ND_KERNEL | |||
26 | 21 | ||
27 | config CAVIUM_OCTEON_HW_FIX_UNALIGNED | 22 | config CAVIUM_OCTEON_HW_FIX_UNALIGNED |
28 | bool "Enable hardware fixups of unaligned loads and stores" | 23 | bool "Enable hardware fixups of unaligned loads and stores" |
29 | depends on CAVIUM_OCTEON_SPECIFIC_OPTIONS | ||
30 | default "y" | 24 | default "y" |
31 | help | 25 | help |
32 | Configure the Octeon hardware to automatically fix unaligned loads | 26 | Configure the Octeon hardware to automatically fix unaligned loads |
@@ -38,7 +32,6 @@ config CAVIUM_OCTEON_HW_FIX_UNALIGNED | |||
38 | 32 | ||
39 | config CAVIUM_OCTEON_CVMSEG_SIZE | 33 | config CAVIUM_OCTEON_CVMSEG_SIZE |
40 | int "Number of L1 cache lines reserved for CVMSEG memory" | 34 | int "Number of L1 cache lines reserved for CVMSEG memory" |
41 | depends on CAVIUM_OCTEON_SPECIFIC_OPTIONS | ||
42 | range 0 54 | 35 | range 0 54 |
43 | default 1 | 36 | default 1 |
44 | help | 37 | help |
@@ -50,7 +43,6 @@ config CAVIUM_OCTEON_CVMSEG_SIZE | |||
50 | 43 | ||
51 | config CAVIUM_OCTEON_LOCK_L2 | 44 | config CAVIUM_OCTEON_LOCK_L2 |
52 | bool "Lock often used kernel code in the L2" | 45 | bool "Lock often used kernel code in the L2" |
53 | depends on CAVIUM_OCTEON_SPECIFIC_OPTIONS | ||
54 | default "y" | 46 | default "y" |
55 | help | 47 | help |
56 | Enable locking parts of the kernel into the L2 cache. | 48 | Enable locking parts of the kernel into the L2 cache. |
@@ -93,7 +85,6 @@ config CAVIUM_OCTEON_LOCK_L2_MEMCPY | |||
93 | config ARCH_SPARSEMEM_ENABLE | 85 | config ARCH_SPARSEMEM_ENABLE |
94 | def_bool y | 86 | def_bool y |
95 | select SPARSEMEM_STATIC | 87 | select SPARSEMEM_STATIC |
96 | depends on CPU_CAVIUM_OCTEON | ||
97 | 88 | ||
98 | config CAVIUM_OCTEON_HELPER | 89 | config CAVIUM_OCTEON_HELPER |
99 | def_bool y | 90 | def_bool y |
@@ -107,6 +98,8 @@ config NEED_SG_DMA_LENGTH | |||
107 | 98 | ||
108 | config SWIOTLB | 99 | config SWIOTLB |
109 | def_bool y | 100 | def_bool y |
110 | depends on CPU_CAVIUM_OCTEON | ||
111 | select IOMMU_HELPER | 101 | select IOMMU_HELPER |
112 | select NEED_SG_DMA_LENGTH | 102 | select NEED_SG_DMA_LENGTH |
103 | |||
104 | |||
105 | endif # CPU_CAVIUM_OCTEON | ||
diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h index 650ac9ba734..b4db69fbc40 100644 --- a/arch/mips/include/asm/cache.h +++ b/arch/mips/include/asm/cache.h | |||
@@ -17,6 +17,6 @@ | |||
17 | #define SMP_CACHE_SHIFT L1_CACHE_SHIFT | 17 | #define SMP_CACHE_SHIFT L1_CACHE_SHIFT |
18 | #define SMP_CACHE_BYTES L1_CACHE_BYTES | 18 | #define SMP_CACHE_BYTES L1_CACHE_BYTES |
19 | 19 | ||
20 | #define __read_mostly __attribute__((__section__(".data.read_mostly"))) | 20 | #define __read_mostly __attribute__((__section__(".data..read_mostly"))) |
21 | 21 | ||
22 | #endif /* _ASM_CACHE_H */ | 22 | #endif /* _ASM_CACHE_H */ |
diff --git a/arch/mips/include/asm/cevt-r4k.h b/arch/mips/include/asm/cevt-r4k.h index fa4328f9124..65f9bdd02f1 100644 --- a/arch/mips/include/asm/cevt-r4k.h +++ b/arch/mips/include/asm/cevt-r4k.h | |||
@@ -14,6 +14,9 @@ | |||
14 | #ifndef __ASM_CEVT_R4K_H | 14 | #ifndef __ASM_CEVT_R4K_H |
15 | #define __ASM_CEVT_R4K_H | 15 | #define __ASM_CEVT_R4K_H |
16 | 16 | ||
17 | #include <linux/clockchips.h> | ||
18 | #include <asm/time.h> | ||
19 | |||
17 | DECLARE_PER_CPU(struct clock_event_device, mips_clockevent_device); | 20 | DECLARE_PER_CPU(struct clock_event_device, mips_clockevent_device); |
18 | 21 | ||
19 | void mips_event_handler(struct clock_event_device *dev); | 22 | void mips_event_handler(struct clock_event_device *dev); |
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h index 655f849bd08..7aa37ddfca4 100644 --- a/arch/mips/include/asm/dma-mapping.h +++ b/arch/mips/include/asm/dma-mapping.h | |||
@@ -5,7 +5,9 @@ | |||
5 | #include <asm/cache.h> | 5 | #include <asm/cache.h> |
6 | #include <asm-generic/dma-coherent.h> | 6 | #include <asm-generic/dma-coherent.h> |
7 | 7 | ||
8 | #ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */ | ||
8 | #include <dma-coherence.h> | 9 | #include <dma-coherence.h> |
10 | #endif | ||
9 | 11 | ||
10 | extern struct dma_map_ops *mips_dma_map_ops; | 12 | extern struct dma_map_ops *mips_dma_map_ops; |
11 | 13 | ||
diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h index f5e85601532..c565b7c3f0b 100644 --- a/arch/mips/include/asm/hugetlb.h +++ b/arch/mips/include/asm/hugetlb.h | |||
@@ -70,6 +70,7 @@ static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, | |||
70 | static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, | 70 | static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, |
71 | unsigned long addr, pte_t *ptep) | 71 | unsigned long addr, pte_t *ptep) |
72 | { | 72 | { |
73 | flush_tlb_mm(vma->vm_mm); | ||
73 | } | 74 | } |
74 | 75 | ||
75 | static inline int huge_pte_none(pte_t pte) | 76 | static inline int huge_pte_none(pte_t pte) |
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h b/arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h index 32978d32561..ed72e6a26b7 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h | |||
@@ -88,7 +88,7 @@ struct bcm_tag { | |||
88 | char kernel_crc[CRC_LEN]; | 88 | char kernel_crc[CRC_LEN]; |
89 | /* 228-235: Unused at present */ | 89 | /* 228-235: Unused at present */ |
90 | char reserved1[8]; | 90 | char reserved1[8]; |
91 | /* 236-239: CRC32 of header excluding tagVersion */ | 91 | /* 236-239: CRC32 of header excluding last 20 bytes */ |
92 | char header_crc[CRC_LEN]; | 92 | char header_crc[CRC_LEN]; |
93 | /* 240-255: Unused at present */ | 93 | /* 240-255: Unused at present */ |
94 | char reserved2[16]; | 94 | char reserved2[16]; |
diff --git a/arch/mips/jazz/jazzdma.c b/arch/mips/jazz/jazzdma.c index 9ce9f64cb76..2d8e447cb82 100644 --- a/arch/mips/jazz/jazzdma.c +++ b/arch/mips/jazz/jazzdma.c | |||
@@ -211,7 +211,7 @@ EXPORT_SYMBOL(vdma_free); | |||
211 | */ | 211 | */ |
212 | int vdma_remap(unsigned long laddr, unsigned long paddr, unsigned long size) | 212 | int vdma_remap(unsigned long laddr, unsigned long paddr, unsigned long size) |
213 | { | 213 | { |
214 | int first, pages, npages; | 214 | int first, pages; |
215 | 215 | ||
216 | if (laddr > 0xffffff) { | 216 | if (laddr > 0xffffff) { |
217 | if (vdma_debug) | 217 | if (vdma_debug) |
@@ -228,8 +228,7 @@ int vdma_remap(unsigned long laddr, unsigned long paddr, unsigned long size) | |||
228 | return -EINVAL; /* invalid physical address */ | 228 | return -EINVAL; /* invalid physical address */ |
229 | } | 229 | } |
230 | 230 | ||
231 | npages = pages = | 231 | pages = (((paddr & (VDMA_PAGESIZE - 1)) + size) >> 12) + 1; |
232 | (((paddr & (VDMA_PAGESIZE - 1)) + size) >> 12) + 1; | ||
233 | first = laddr >> 12; | 232 | first = laddr >> 12; |
234 | if (vdma_debug) | 233 | if (vdma_debug) |
235 | printk("vdma_remap: first=%x, pages=%x\n", first, pages); | 234 | printk("vdma_remap: first=%x, pages=%x\n", first, pages); |
diff --git a/arch/mips/jz4740/dma.c b/arch/mips/jz4740/dma.c index 5ebe75a6835..d7feb898692 100644 --- a/arch/mips/jz4740/dma.c +++ b/arch/mips/jz4740/dma.c | |||
@@ -242,9 +242,7 @@ EXPORT_SYMBOL_GPL(jz4740_dma_get_residue); | |||
242 | 242 | ||
243 | static void jz4740_dma_chan_irq(struct jz4740_dma_chan *dma) | 243 | static void jz4740_dma_chan_irq(struct jz4740_dma_chan *dma) |
244 | { | 244 | { |
245 | uint32_t status; | 245 | (void) jz4740_dma_read(JZ_REG_DMA_STATUS_CTRL(dma->id)); |
246 | |||
247 | status = jz4740_dma_read(JZ_REG_DMA_STATUS_CTRL(dma->id)); | ||
248 | 246 | ||
249 | jz4740_dma_write_mask(JZ_REG_DMA_STATUS_CTRL(dma->id), 0, | 247 | jz4740_dma_write_mask(JZ_REG_DMA_STATUS_CTRL(dma->id), 0, |
250 | JZ_DMA_STATUS_CTRL_ENABLE | JZ_DMA_STATUS_CTRL_TRANSFER_DONE); | 248 | JZ_DMA_STATUS_CTRL_ENABLE | JZ_DMA_STATUS_CTRL_TRANSFER_DONE); |
diff --git a/arch/mips/jz4740/time.c b/arch/mips/jz4740/time.c index fe01678d94f..eaa853a54af 100644 --- a/arch/mips/jz4740/time.c +++ b/arch/mips/jz4740/time.c | |||
@@ -89,7 +89,7 @@ static int jz4740_clockevent_set_next(unsigned long evt, | |||
89 | 89 | ||
90 | static struct clock_event_device jz4740_clockevent = { | 90 | static struct clock_event_device jz4740_clockevent = { |
91 | .name = "jz4740-timer", | 91 | .name = "jz4740-timer", |
92 | .features = CLOCK_EVT_FEAT_PERIODIC, | 92 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, |
93 | .set_next_event = jz4740_clockevent_set_next, | 93 | .set_next_event = jz4740_clockevent_set_next, |
94 | .set_mode = jz4740_clockevent_set_mode, | 94 | .set_mode = jz4740_clockevent_set_mode, |
95 | .rating = 200, | 95 | .rating = 200, |
diff --git a/arch/mips/jz4740/timer.c b/arch/mips/jz4740/timer.c index b2c01512905..654d5c3900b 100644 --- a/arch/mips/jz4740/timer.c +++ b/arch/mips/jz4740/timer.c | |||
@@ -27,11 +27,13 @@ void jz4740_timer_enable_watchdog(void) | |||
27 | { | 27 | { |
28 | writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_CLEAR); | 28 | writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_CLEAR); |
29 | } | 29 | } |
30 | EXPORT_SYMBOL_GPL(jz4740_timer_enable_watchdog); | ||
30 | 31 | ||
31 | void jz4740_timer_disable_watchdog(void) | 32 | void jz4740_timer_disable_watchdog(void) |
32 | { | 33 | { |
33 | writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_SET); | 34 | writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_SET); |
34 | } | 35 | } |
36 | EXPORT_SYMBOL_GPL(jz4740_timer_disable_watchdog); | ||
35 | 37 | ||
36 | void __init jz4740_timer_init(void) | 38 | void __init jz4740_timer_init(void) |
37 | { | 39 | { |
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c index 94ca2b018af..feb8021a305 100644 --- a/arch/mips/kernel/ftrace.c +++ b/arch/mips/kernel/ftrace.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #define JAL 0x0c000000 /* jump & link: ip --> ra, jump to target */ | 24 | #define JAL 0x0c000000 /* jump & link: ip --> ra, jump to target */ |
25 | #define ADDR_MASK 0x03ffffff /* op_code|addr : 31...26|25 ....0 */ | 25 | #define ADDR_MASK 0x03ffffff /* op_code|addr : 31...26|25 ....0 */ |
26 | #define JUMP_RANGE_MASK ((1UL << 28) - 1) | ||
26 | 27 | ||
27 | #define INSN_NOP 0x00000000 /* nop */ | 28 | #define INSN_NOP 0x00000000 /* nop */ |
28 | #define INSN_JAL(addr) \ | 29 | #define INSN_JAL(addr) \ |
@@ -44,12 +45,12 @@ static inline void ftrace_dyn_arch_init_insns(void) | |||
44 | 45 | ||
45 | /* jal (ftrace_caller + 8), jump over the first two instruction */ | 46 | /* jal (ftrace_caller + 8), jump over the first two instruction */ |
46 | buf = (u32 *)&insn_jal_ftrace_caller; | 47 | buf = (u32 *)&insn_jal_ftrace_caller; |
47 | uasm_i_jal(&buf, (FTRACE_ADDR + 8)); | 48 | uasm_i_jal(&buf, (FTRACE_ADDR + 8) & JUMP_RANGE_MASK); |
48 | 49 | ||
49 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 50 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
50 | /* j ftrace_graph_caller */ | 51 | /* j ftrace_graph_caller */ |
51 | buf = (u32 *)&insn_j_ftrace_graph_caller; | 52 | buf = (u32 *)&insn_j_ftrace_graph_caller; |
52 | uasm_i_j(&buf, (unsigned long)ftrace_graph_caller); | 53 | uasm_i_j(&buf, (unsigned long)ftrace_graph_caller & JUMP_RANGE_MASK); |
53 | #endif | 54 | #endif |
54 | } | 55 | } |
55 | 56 | ||
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index d21c388c011..584e6b55c86 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c | |||
@@ -540,8 +540,8 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit) | |||
540 | secure_computing(regs->regs[2]); | 540 | secure_computing(regs->regs[2]); |
541 | 541 | ||
542 | if (unlikely(current->audit_context) && entryexit) | 542 | if (unlikely(current->audit_context) && entryexit) |
543 | audit_syscall_exit(AUDITSC_RESULT(regs->regs[2]), | 543 | audit_syscall_exit(AUDITSC_RESULT(regs->regs[7]), |
544 | regs->regs[2]); | 544 | -regs->regs[2]); |
545 | 545 | ||
546 | if (!(current->ptrace & PT_PTRACED)) | 546 | if (!(current->ptrace & PT_PTRACED)) |
547 | goto out; | 547 | goto out; |
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S index 7f5468b38d4..7f1377eb22d 100644 --- a/arch/mips/kernel/scall32-o32.S +++ b/arch/mips/kernel/scall32-o32.S | |||
@@ -565,7 +565,7 @@ einval: li v0, -ENOSYS | |||
565 | sys sys_ioprio_get 2 /* 4315 */ | 565 | sys sys_ioprio_get 2 /* 4315 */ |
566 | sys sys_utimensat 4 | 566 | sys sys_utimensat 4 |
567 | sys sys_signalfd 3 | 567 | sys sys_signalfd 3 |
568 | sys sys_ni_syscall 0 | 568 | sys sys_ni_syscall 0 /* was timerfd */ |
569 | sys sys_eventfd 1 | 569 | sys sys_eventfd 1 |
570 | sys sys_fallocate 6 /* 4320 */ | 570 | sys sys_fallocate 6 /* 4320 */ |
571 | sys sys_timerfd_create 2 | 571 | sys sys_timerfd_create 2 |
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S index a2e1fcbc41d..7c0ef7f128b 100644 --- a/arch/mips/kernel/scall64-64.S +++ b/arch/mips/kernel/scall64-64.S | |||
@@ -404,7 +404,7 @@ sys_call_table: | |||
404 | PTR sys_ioprio_get | 404 | PTR sys_ioprio_get |
405 | PTR sys_utimensat /* 5275 */ | 405 | PTR sys_utimensat /* 5275 */ |
406 | PTR sys_signalfd | 406 | PTR sys_signalfd |
407 | PTR sys_ni_syscall | 407 | PTR sys_ni_syscall /* was timerfd */ |
408 | PTR sys_eventfd | 408 | PTR sys_eventfd |
409 | PTR sys_fallocate | 409 | PTR sys_fallocate |
410 | PTR sys_timerfd_create /* 5280 */ | 410 | PTR sys_timerfd_create /* 5280 */ |
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S index b2c7624995b..de6c5563bea 100644 --- a/arch/mips/kernel/scall64-n32.S +++ b/arch/mips/kernel/scall64-n32.S | |||
@@ -403,7 +403,7 @@ EXPORT(sysn32_call_table) | |||
403 | PTR sys_ioprio_get | 403 | PTR sys_ioprio_get |
404 | PTR compat_sys_utimensat | 404 | PTR compat_sys_utimensat |
405 | PTR compat_sys_signalfd /* 6280 */ | 405 | PTR compat_sys_signalfd /* 6280 */ |
406 | PTR sys_ni_syscall | 406 | PTR sys_ni_syscall /* was timerfd */ |
407 | PTR sys_eventfd | 407 | PTR sys_eventfd |
408 | PTR sys_fallocate | 408 | PTR sys_fallocate |
409 | PTR sys_timerfd_create | 409 | PTR sys_timerfd_create |
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S index 049a9c8c49a..b0541dda883 100644 --- a/arch/mips/kernel/scall64-o32.S +++ b/arch/mips/kernel/scall64-o32.S | |||
@@ -522,7 +522,7 @@ sys_call_table: | |||
522 | PTR sys_ioprio_get /* 4315 */ | 522 | PTR sys_ioprio_get /* 4315 */ |
523 | PTR compat_sys_utimensat | 523 | PTR compat_sys_utimensat |
524 | PTR compat_sys_signalfd | 524 | PTR compat_sys_signalfd |
525 | PTR sys_ni_syscall | 525 | PTR sys_ni_syscall /* was timerfd */ |
526 | PTR sys_eventfd | 526 | PTR sys_eventfd |
527 | PTR sys32_fallocate /* 4320 */ | 527 | PTR sys32_fallocate /* 4320 */ |
528 | PTR sys_timerfd_create | 528 | PTR sys_timerfd_create |
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 71350f7f2d8..e9b3af27d84 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c | |||
@@ -374,7 +374,8 @@ void __noreturn die(const char *str, struct pt_regs *regs) | |||
374 | unsigned long dvpret = dvpe(); | 374 | unsigned long dvpret = dvpe(); |
375 | #endif /* CONFIG_MIPS_MT_SMTC */ | 375 | #endif /* CONFIG_MIPS_MT_SMTC */ |
376 | 376 | ||
377 | notify_die(DIE_OOPS, str, regs, 0, regs_to_trapnr(regs), SIGSEGV); | 377 | if (notify_die(DIE_OOPS, str, regs, 0, regs_to_trapnr(regs), SIGSEGV) == NOTIFY_STOP) |
378 | sig = 0; | ||
378 | 379 | ||
379 | console_verbose(); | 380 | console_verbose(); |
380 | spin_lock_irq(&die_lock); | 381 | spin_lock_irq(&die_lock); |
@@ -383,9 +384,6 @@ void __noreturn die(const char *str, struct pt_regs *regs) | |||
383 | mips_mt_regdump(dvpret); | 384 | mips_mt_regdump(dvpret); |
384 | #endif /* CONFIG_MIPS_MT_SMTC */ | 385 | #endif /* CONFIG_MIPS_MT_SMTC */ |
385 | 386 | ||
386 | if (notify_die(DIE_OOPS, str, regs, 0, regs_to_trapnr(regs), SIGSEGV) == NOTIFY_STOP) | ||
387 | sig = 0; | ||
388 | |||
389 | printk("%s[#%d]:\n", str, ++die_counter); | 387 | printk("%s[#%d]:\n", str, ++die_counter); |
390 | show_registers(regs); | 388 | show_registers(regs); |
391 | add_taint(TAINT_DIE); | 389 | add_taint(TAINT_DIE); |
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 832afbb8758..e4b0b0bec03 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S | |||
@@ -74,6 +74,7 @@ SECTIONS | |||
74 | INIT_TASK_DATA(PAGE_SIZE) | 74 | INIT_TASK_DATA(PAGE_SIZE) |
75 | NOSAVE_DATA | 75 | NOSAVE_DATA |
76 | CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) | 76 | CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) |
77 | READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) | ||
77 | DATA_DATA | 78 | DATA_DATA |
78 | CONSTRUCTORS | 79 | CONSTRUCTORS |
79 | } | 80 | } |
diff --git a/arch/mips/loongson/common/env.c b/arch/mips/loongson/common/env.c index 11b193f848f..d93830ad611 100644 --- a/arch/mips/loongson/common/env.c +++ b/arch/mips/loongson/common/env.c | |||
@@ -29,9 +29,10 @@ unsigned long memsize, highmemsize; | |||
29 | 29 | ||
30 | #define parse_even_earlier(res, option, p) \ | 30 | #define parse_even_earlier(res, option, p) \ |
31 | do { \ | 31 | do { \ |
32 | int ret; \ | 32 | unsigned int tmp __maybe_unused; \ |
33 | \ | ||
33 | if (strncmp(option, (char *)p, strlen(option)) == 0) \ | 34 | if (strncmp(option, (char *)p, strlen(option)) == 0) \ |
34 | ret = strict_strtol((char *)p + strlen(option"="), 10, &res); \ | 35 | tmp = strict_strtol((char *)p + strlen(option"="), 10, &res); \ |
35 | } while (0) | 36 | } while (0) |
36 | 37 | ||
37 | void __init prom_init_env(void) | 38 | void __init prom_init_env(void) |
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index b4923a75cb4..71bddf8f7d2 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c | |||
@@ -1075,7 +1075,6 @@ static int __cpuinit probe_scache(void) | |||
1075 | unsigned long flags, addr, begin, end, pow2; | 1075 | unsigned long flags, addr, begin, end, pow2; |
1076 | unsigned int config = read_c0_config(); | 1076 | unsigned int config = read_c0_config(); |
1077 | struct cpuinfo_mips *c = ¤t_cpu_data; | 1077 | struct cpuinfo_mips *c = ¤t_cpu_data; |
1078 | int tmp; | ||
1079 | 1078 | ||
1080 | if (config & CONF_SC) | 1079 | if (config & CONF_SC) |
1081 | return 0; | 1080 | return 0; |
@@ -1108,7 +1107,6 @@ static int __cpuinit probe_scache(void) | |||
1108 | 1107 | ||
1109 | /* Now search for the wrap around point. */ | 1108 | /* Now search for the wrap around point. */ |
1110 | pow2 = (128 * 1024); | 1109 | pow2 = (128 * 1024); |
1111 | tmp = 0; | ||
1112 | for (addr = begin + (128 * 1024); addr < end; addr = begin + pow2) { | 1110 | for (addr = begin + (128 * 1024); addr < end; addr = begin + pow2) { |
1113 | cache_op(Index_Load_Tag_SD, addr); | 1111 | cache_op(Index_Load_Tag_SD, addr); |
1114 | __asm__ __volatile__("nop; nop; nop; nop;"); /* hazard... */ | 1112 | __asm__ __volatile__("nop; nop; nop; nop;"); /* hazard... */ |
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 5ef294fbb6e..f5734c2c809 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c | |||
@@ -1151,8 +1151,8 @@ static void __cpuinit build_r4000_tlb_refill_handler(void) | |||
1151 | struct uasm_reloc *r = relocs; | 1151 | struct uasm_reloc *r = relocs; |
1152 | u32 *f; | 1152 | u32 *f; |
1153 | unsigned int final_len; | 1153 | unsigned int final_len; |
1154 | struct mips_huge_tlb_info htlb_info; | 1154 | struct mips_huge_tlb_info htlb_info __maybe_unused; |
1155 | enum vmalloc64_mode vmalloc_mode; | 1155 | enum vmalloc64_mode vmalloc_mode __maybe_unused; |
1156 | 1156 | ||
1157 | memset(tlb_handler, 0, sizeof(tlb_handler)); | 1157 | memset(tlb_handler, 0, sizeof(tlb_handler)); |
1158 | memset(labels, 0, sizeof(labels)); | 1158 | memset(labels, 0, sizeof(labels)); |
diff --git a/arch/mips/mti-malta/malta-init.c b/arch/mips/mti-malta/malta-init.c index 414f0c99b19..31180c321a1 100644 --- a/arch/mips/mti-malta/malta-init.c +++ b/arch/mips/mti-malta/malta-init.c | |||
@@ -193,8 +193,6 @@ extern struct plat_smp_ops msmtc_smp_ops; | |||
193 | 193 | ||
194 | void __init prom_init(void) | 194 | void __init prom_init(void) |
195 | { | 195 | { |
196 | int result; | ||
197 | |||
198 | prom_argc = fw_arg0; | 196 | prom_argc = fw_arg0; |
199 | _prom_argv = (int *) fw_arg1; | 197 | _prom_argv = (int *) fw_arg1; |
200 | _prom_envp = (int *) fw_arg2; | 198 | _prom_envp = (int *) fw_arg2; |
@@ -360,20 +358,14 @@ void __init prom_init(void) | |||
360 | #ifdef CONFIG_SERIAL_8250_CONSOLE | 358 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
361 | console_config(); | 359 | console_config(); |
362 | #endif | 360 | #endif |
363 | /* Early detection of CMP support */ | ||
364 | result = gcmp_probe(GCMP_BASE_ADDR, GCMP_ADDRSPACE_SZ); | ||
365 | |||
366 | #ifdef CONFIG_MIPS_CMP | 361 | #ifdef CONFIG_MIPS_CMP |
367 | if (result) | 362 | /* Early detection of CMP support */ |
363 | if (gcmp_probe(GCMP_BASE_ADDR, GCMP_ADDRSPACE_SZ)) | ||
368 | register_smp_ops(&cmp_smp_ops); | 364 | register_smp_ops(&cmp_smp_ops); |
365 | else | ||
369 | #endif | 366 | #endif |
370 | #ifdef CONFIG_MIPS_MT_SMP | 367 | #ifdef CONFIG_MIPS_MT_SMP |
371 | #ifdef CONFIG_MIPS_CMP | ||
372 | if (!result) | ||
373 | register_smp_ops(&vsmp_smp_ops); | 368 | register_smp_ops(&vsmp_smp_ops); |
374 | #else | ||
375 | register_smp_ops(&vsmp_smp_ops); | ||
376 | #endif | ||
377 | #endif | 369 | #endif |
378 | #ifdef CONFIG_MIPS_MT_SMTC | 370 | #ifdef CONFIG_MIPS_MT_SMTC |
379 | register_smp_ops(&msmtc_smp_ops); | 371 | register_smp_ops(&msmtc_smp_ops); |
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c index 9027061f0ea..e85c977328d 100644 --- a/arch/mips/mti-malta/malta-int.c +++ b/arch/mips/mti-malta/malta-int.c | |||
@@ -56,7 +56,6 @@ static DEFINE_RAW_SPINLOCK(mips_irq_lock); | |||
56 | static inline int mips_pcibios_iack(void) | 56 | static inline int mips_pcibios_iack(void) |
57 | { | 57 | { |
58 | int irq; | 58 | int irq; |
59 | u32 dummy; | ||
60 | 59 | ||
61 | /* | 60 | /* |
62 | * Determine highest priority pending interrupt by performing | 61 | * Determine highest priority pending interrupt by performing |
@@ -83,7 +82,7 @@ static inline int mips_pcibios_iack(void) | |||
83 | BONITO_PCIMAP_CFG = 0x20000; | 82 | BONITO_PCIMAP_CFG = 0x20000; |
84 | 83 | ||
85 | /* Flush Bonito register block */ | 84 | /* Flush Bonito register block */ |
86 | dummy = BONITO_PCIMAP_CFG; | 85 | (void) BONITO_PCIMAP_CFG; |
87 | iob(); /* sync */ | 86 | iob(); /* sync */ |
88 | 87 | ||
89 | irq = __raw_readl((u32 *)_pcictrl_bonito_pcicfg); | 88 | irq = __raw_readl((u32 *)_pcictrl_bonito_pcicfg); |
diff --git a/arch/mips/pmc-sierra/msp71xx/msp_irq_per.c b/arch/mips/pmc-sierra/msp71xx/msp_irq_per.c index f9b9dcdfa9d..98fd0099d96 100644 --- a/arch/mips/pmc-sierra/msp71xx/msp_irq_per.c +++ b/arch/mips/pmc-sierra/msp71xx/msp_irq_per.c | |||
@@ -97,7 +97,7 @@ static int msp_per_irq_set_affinity(struct irq_data *d, | |||
97 | 97 | ||
98 | static struct irq_chip msp_per_irq_controller = { | 98 | static struct irq_chip msp_per_irq_controller = { |
99 | .name = "MSP_PER", | 99 | .name = "MSP_PER", |
100 | .irq_enable = unmask_per_irq. | 100 | .irq_enable = unmask_per_irq, |
101 | .irq_disable = mask_per_irq, | 101 | .irq_disable = mask_per_irq, |
102 | .irq_ack = msp_per_irq_ack, | 102 | .irq_ack = msp_per_irq_ack, |
103 | #ifdef CONFIG_SMP | 103 | #ifdef CONFIG_SMP |
diff --git a/arch/mips/power/hibernate.S b/arch/mips/power/hibernate.S index dbb5c7b4b70..f8a751c0328 100644 --- a/arch/mips/power/hibernate.S +++ b/arch/mips/power/hibernate.S | |||
@@ -35,7 +35,7 @@ LEAF(swsusp_arch_resume) | |||
35 | 0: | 35 | 0: |
36 | PTR_L t1, PBE_ADDRESS(t0) /* source */ | 36 | PTR_L t1, PBE_ADDRESS(t0) /* source */ |
37 | PTR_L t2, PBE_ORIG_ADDRESS(t0) /* destination */ | 37 | PTR_L t2, PBE_ORIG_ADDRESS(t0) /* destination */ |
38 | PTR_ADDIU t3, t1, PAGE_SIZE | 38 | PTR_ADDU t3, t1, PAGE_SIZE |
39 | 1: | 39 | 1: |
40 | REG_L t8, (t1) | 40 | REG_L t8, (t1) |
41 | REG_S t8, (t2) | 41 | REG_S t8, (t2) |
diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c index 37de05d595e..6c47dfeb7be 100644 --- a/arch/mips/rb532/gpio.c +++ b/arch/mips/rb532/gpio.c | |||
@@ -185,7 +185,7 @@ int __init rb532_gpio_init(void) | |||
185 | struct resource *r; | 185 | struct resource *r; |
186 | 186 | ||
187 | r = rb532_gpio_reg0_res; | 187 | r = rb532_gpio_reg0_res; |
188 | rb532_gpio_chip->regbase = ioremap_nocache(r->start, r->end - r->start); | 188 | rb532_gpio_chip->regbase = ioremap_nocache(r->start, resource_size(r)); |
189 | 189 | ||
190 | if (!rb532_gpio_chip->regbase) { | 190 | if (!rb532_gpio_chip->regbase) { |
191 | printk(KERN_ERR "rb532: cannot remap GPIO register 0\n"); | 191 | printk(KERN_ERR "rb532: cannot remap GPIO register 0\n"); |
diff --git a/arch/mips/sgi-ip22/ip22-platform.c b/arch/mips/sgi-ip22/ip22-platform.c index deddbf0ebe5..698904daf90 100644 --- a/arch/mips/sgi-ip22/ip22-platform.c +++ b/arch/mips/sgi-ip22/ip22-platform.c | |||
@@ -132,7 +132,7 @@ static struct platform_device eth1_device = { | |||
132 | */ | 132 | */ |
133 | static int __init sgiseeq_devinit(void) | 133 | static int __init sgiseeq_devinit(void) |
134 | { | 134 | { |
135 | unsigned int tmp; | 135 | unsigned int pbdma __maybe_unused; |
136 | int res, i; | 136 | int res, i; |
137 | 137 | ||
138 | eth0_pd.hpc = hpc3c0; | 138 | eth0_pd.hpc = hpc3c0; |
@@ -151,7 +151,7 @@ static int __init sgiseeq_devinit(void) | |||
151 | 151 | ||
152 | /* Second HPC is missing? */ | 152 | /* Second HPC is missing? */ |
153 | if (ip22_is_fullhouse() || | 153 | if (ip22_is_fullhouse() || |
154 | get_dbe(tmp, (unsigned int *)&hpc3c1->pbdma[1])) | 154 | get_dbe(pbdma, (unsigned int *)&hpc3c1->pbdma[1])) |
155 | return 0; | 155 | return 0; |
156 | 156 | ||
157 | sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 | | 157 | sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 | |
diff --git a/arch/mips/sgi-ip22/ip22-time.c b/arch/mips/sgi-ip22/ip22-time.c index 603fc91c103..1a94c989418 100644 --- a/arch/mips/sgi-ip22/ip22-time.c +++ b/arch/mips/sgi-ip22/ip22-time.c | |||
@@ -32,7 +32,7 @@ | |||
32 | static unsigned long dosample(void) | 32 | static unsigned long dosample(void) |
33 | { | 33 | { |
34 | u32 ct0, ct1; | 34 | u32 ct0, ct1; |
35 | u8 msb, lsb; | 35 | u8 msb; |
36 | 36 | ||
37 | /* Start the counter. */ | 37 | /* Start the counter. */ |
38 | sgint->tcword = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL | | 38 | sgint->tcword = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL | |
@@ -46,7 +46,7 @@ static unsigned long dosample(void) | |||
46 | /* Latch and spin until top byte of counter2 is zero */ | 46 | /* Latch and spin until top byte of counter2 is zero */ |
47 | do { | 47 | do { |
48 | writeb(SGINT_TCWORD_CNT2 | SGINT_TCWORD_CLAT, &sgint->tcword); | 48 | writeb(SGINT_TCWORD_CNT2 | SGINT_TCWORD_CLAT, &sgint->tcword); |
49 | lsb = readb(&sgint->tcnt2); | 49 | (void) readb(&sgint->tcnt2); |
50 | msb = readb(&sgint->tcnt2); | 50 | msb = readb(&sgint->tcnt2); |
51 | ct1 = read_c0_count(); | 51 | ct1 = read_c0_count(); |
52 | } while (msb); | 52 | } while (msb); |
diff --git a/arch/mips/sgi-ip27/ip27-hubio.c b/arch/mips/sgi-ip27/ip27-hubio.c index a1fa4abb3f6..cd0d5b06cd8 100644 --- a/arch/mips/sgi-ip27/ip27-hubio.c +++ b/arch/mips/sgi-ip27/ip27-hubio.c | |||
@@ -29,7 +29,6 @@ unsigned long hub_pio_map(cnodeid_t cnode, xwidgetnum_t widget, | |||
29 | unsigned long xtalk_addr, size_t size) | 29 | unsigned long xtalk_addr, size_t size) |
30 | { | 30 | { |
31 | nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode); | 31 | nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode); |
32 | volatile hubreg_t junk; | ||
33 | unsigned i; | 32 | unsigned i; |
34 | 33 | ||
35 | /* use small-window mapping if possible */ | 34 | /* use small-window mapping if possible */ |
@@ -64,7 +63,7 @@ unsigned long hub_pio_map(cnodeid_t cnode, xwidgetnum_t widget, | |||
64 | * after we write it. | 63 | * after we write it. |
65 | */ | 64 | */ |
66 | IIO_ITTE_PUT(nasid, i, HUB_PIO_MAP_TO_MEM, widget, xtalk_addr); | 65 | IIO_ITTE_PUT(nasid, i, HUB_PIO_MAP_TO_MEM, widget, xtalk_addr); |
67 | junk = HUB_L(IIO_ITTE_GET(nasid, i)); | 66 | (void) HUB_L(IIO_ITTE_GET(nasid, i)); |
68 | 67 | ||
69 | return NODE_BWIN_BASE(nasid, widget) + (xtalk_addr % BWIN_SIZE); | 68 | return NODE_BWIN_BASE(nasid, widget) + (xtalk_addr % BWIN_SIZE); |
70 | } | 69 | } |
diff --git a/arch/mips/sgi-ip27/ip27-klnuma.c b/arch/mips/sgi-ip27/ip27-klnuma.c index c3d30a88daf..1d1919a44e8 100644 --- a/arch/mips/sgi-ip27/ip27-klnuma.c +++ b/arch/mips/sgi-ip27/ip27-klnuma.c | |||
@@ -54,11 +54,8 @@ void __init setup_replication_mask(void) | |||
54 | 54 | ||
55 | static __init void set_ktext_source(nasid_t client_nasid, nasid_t server_nasid) | 55 | static __init void set_ktext_source(nasid_t client_nasid, nasid_t server_nasid) |
56 | { | 56 | { |
57 | cnodeid_t client_cnode; | ||
58 | kern_vars_t *kvp; | 57 | kern_vars_t *kvp; |
59 | 58 | ||
60 | client_cnode = NASID_TO_COMPACT_NODEID(client_nasid); | ||
61 | |||
62 | kvp = &hub_data(client_nasid)->kern_vars; | 59 | kvp = &hub_data(client_nasid)->kern_vars; |
63 | 60 | ||
64 | KERN_VARS_ADDR(client_nasid) = (unsigned long)kvp; | 61 | KERN_VARS_ADDR(client_nasid) = (unsigned long)kvp; |
diff --git a/arch/mips/sni/time.c b/arch/mips/sni/time.c index c76151b5656..0904d4d30cb 100644 --- a/arch/mips/sni/time.c +++ b/arch/mips/sni/time.c | |||
@@ -95,7 +95,7 @@ static void __init sni_a20r_timer_setup(void) | |||
95 | static __init unsigned long dosample(void) | 95 | static __init unsigned long dosample(void) |
96 | { | 96 | { |
97 | u32 ct0, ct1; | 97 | u32 ct0, ct1; |
98 | volatile u8 msb, lsb; | 98 | volatile u8 msb; |
99 | 99 | ||
100 | /* Start the counter. */ | 100 | /* Start the counter. */ |
101 | outb_p(0x34, 0x43); | 101 | outb_p(0x34, 0x43); |
@@ -108,7 +108,7 @@ static __init unsigned long dosample(void) | |||
108 | /* Latch and spin until top byte of counter0 is zero */ | 108 | /* Latch and spin until top byte of counter0 is zero */ |
109 | do { | 109 | do { |
110 | outb(0x00, 0x43); | 110 | outb(0x00, 0x43); |
111 | lsb = inb(0x40); | 111 | (void) inb(0x40); |
112 | msb = inb(0x40); | 112 | msb = inb(0x40); |
113 | ct1 = read_c0_count(); | 113 | ct1 = read_c0_count(); |
114 | } while (msb); | 114 | } while (msb); |
diff --git a/arch/powerpc/include/asm/8xx_immap.h b/arch/powerpc/include/asm/8xx_immap.h index 6b6dc20b0be..bdf0563ba42 100644 --- a/arch/powerpc/include/asm/8xx_immap.h +++ b/arch/powerpc/include/asm/8xx_immap.h | |||
@@ -393,8 +393,8 @@ typedef struct fec { | |||
393 | uint fec_addr_low; /* lower 32 bits of station address */ | 393 | uint fec_addr_low; /* lower 32 bits of station address */ |
394 | ushort fec_addr_high; /* upper 16 bits of station address */ | 394 | ushort fec_addr_high; /* upper 16 bits of station address */ |
395 | ushort res1; /* reserved */ | 395 | ushort res1; /* reserved */ |
396 | uint fec_hash_table_high; /* upper 32-bits of hash table */ | 396 | uint fec_grp_hash_table_high; /* upper 32-bits of hash table */ |
397 | uint fec_hash_table_low; /* lower 32-bits of hash table */ | 397 | uint fec_grp_hash_table_low; /* lower 32-bits of hash table */ |
398 | uint fec_r_des_start; /* beginning of Rx descriptor ring */ | 398 | uint fec_r_des_start; /* beginning of Rx descriptor ring */ |
399 | uint fec_x_des_start; /* beginning of Tx descriptor ring */ | 399 | uint fec_x_des_start; /* beginning of Tx descriptor ring */ |
400 | uint fec_r_buff_size; /* Rx buffer size */ | 400 | uint fec_r_buff_size; /* Rx buffer size */ |
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 55613e33e26..a6ae1cfad86 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c | |||
@@ -933,12 +933,16 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, | |||
933 | if (data && !(data & DABR_TRANSLATION)) | 933 | if (data && !(data & DABR_TRANSLATION)) |
934 | return -EIO; | 934 | return -EIO; |
935 | #ifdef CONFIG_HAVE_HW_BREAKPOINT | 935 | #ifdef CONFIG_HAVE_HW_BREAKPOINT |
936 | if (ptrace_get_breakpoints(task) < 0) | ||
937 | return -ESRCH; | ||
938 | |||
936 | bp = thread->ptrace_bps[0]; | 939 | bp = thread->ptrace_bps[0]; |
937 | if ((!data) || !(data & (DABR_DATA_WRITE | DABR_DATA_READ))) { | 940 | if ((!data) || !(data & (DABR_DATA_WRITE | DABR_DATA_READ))) { |
938 | if (bp) { | 941 | if (bp) { |
939 | unregister_hw_breakpoint(bp); | 942 | unregister_hw_breakpoint(bp); |
940 | thread->ptrace_bps[0] = NULL; | 943 | thread->ptrace_bps[0] = NULL; |
941 | } | 944 | } |
945 | ptrace_put_breakpoints(task); | ||
942 | return 0; | 946 | return 0; |
943 | } | 947 | } |
944 | if (bp) { | 948 | if (bp) { |
@@ -948,9 +952,12 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, | |||
948 | (DABR_DATA_WRITE | DABR_DATA_READ), | 952 | (DABR_DATA_WRITE | DABR_DATA_READ), |
949 | &attr.bp_type); | 953 | &attr.bp_type); |
950 | ret = modify_user_hw_breakpoint(bp, &attr); | 954 | ret = modify_user_hw_breakpoint(bp, &attr); |
951 | if (ret) | 955 | if (ret) { |
956 | ptrace_put_breakpoints(task); | ||
952 | return ret; | 957 | return ret; |
958 | } | ||
953 | thread->ptrace_bps[0] = bp; | 959 | thread->ptrace_bps[0] = bp; |
960 | ptrace_put_breakpoints(task); | ||
954 | thread->dabr = data; | 961 | thread->dabr = data; |
955 | return 0; | 962 | return 0; |
956 | } | 963 | } |
@@ -965,9 +972,12 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, | |||
965 | ptrace_triggered, task); | 972 | ptrace_triggered, task); |
966 | if (IS_ERR(bp)) { | 973 | if (IS_ERR(bp)) { |
967 | thread->ptrace_bps[0] = NULL; | 974 | thread->ptrace_bps[0] = NULL; |
975 | ptrace_put_breakpoints(task); | ||
968 | return PTR_ERR(bp); | 976 | return PTR_ERR(bp); |
969 | } | 977 | } |
970 | 978 | ||
979 | ptrace_put_breakpoints(task); | ||
980 | |||
971 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */ | 981 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */ |
972 | 982 | ||
973 | /* Move contents to the DABR register */ | 983 | /* Move contents to the DABR register */ |
diff --git a/arch/powerpc/platforms/83xx/suspend.c b/arch/powerpc/platforms/83xx/suspend.c index 188272934cf..104faa8aa23 100644 --- a/arch/powerpc/platforms/83xx/suspend.c +++ b/arch/powerpc/platforms/83xx/suspend.c | |||
@@ -318,17 +318,20 @@ static const struct platform_suspend_ops mpc83xx_suspend_ops = { | |||
318 | .end = mpc83xx_suspend_end, | 318 | .end = mpc83xx_suspend_end, |
319 | }; | 319 | }; |
320 | 320 | ||
321 | static struct of_device_id pmc_match[]; | ||
321 | static int pmc_probe(struct platform_device *ofdev) | 322 | static int pmc_probe(struct platform_device *ofdev) |
322 | { | 323 | { |
324 | const struct of_device_id *match; | ||
323 | struct device_node *np = ofdev->dev.of_node; | 325 | struct device_node *np = ofdev->dev.of_node; |
324 | struct resource res; | 326 | struct resource res; |
325 | struct pmc_type *type; | 327 | struct pmc_type *type; |
326 | int ret = 0; | 328 | int ret = 0; |
327 | 329 | ||
328 | if (!ofdev->dev.of_match) | 330 | match = of_match_device(pmc_match, &ofdev->dev); |
331 | if (!match) | ||
329 | return -EINVAL; | 332 | return -EINVAL; |
330 | 333 | ||
331 | type = ofdev->dev.of_match->data; | 334 | type = match->data; |
332 | 335 | ||
333 | if (!of_device_is_available(np)) | 336 | if (!of_device_is_available(np)) |
334 | return -ENODEV; | 337 | return -ENODEV; |
diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c index d5679dc1e20..01cd2f08951 100644 --- a/arch/powerpc/sysdev/fsl_msi.c +++ b/arch/powerpc/sysdev/fsl_msi.c | |||
@@ -304,8 +304,10 @@ static int __devinit fsl_msi_setup_hwirq(struct fsl_msi *msi, | |||
304 | return 0; | 304 | return 0; |
305 | } | 305 | } |
306 | 306 | ||
307 | static const struct of_device_id fsl_of_msi_ids[]; | ||
307 | static int __devinit fsl_of_msi_probe(struct platform_device *dev) | 308 | static int __devinit fsl_of_msi_probe(struct platform_device *dev) |
308 | { | 309 | { |
310 | const struct of_device_id *match; | ||
309 | struct fsl_msi *msi; | 311 | struct fsl_msi *msi; |
310 | struct resource res; | 312 | struct resource res; |
311 | int err, i, j, irq_index, count; | 313 | int err, i, j, irq_index, count; |
@@ -316,9 +318,10 @@ static int __devinit fsl_of_msi_probe(struct platform_device *dev) | |||
316 | u32 offset; | 318 | u32 offset; |
317 | static const u32 all_avail[] = { 0, NR_MSI_IRQS }; | 319 | static const u32 all_avail[] = { 0, NR_MSI_IRQS }; |
318 | 320 | ||
319 | if (!dev->dev.of_match) | 321 | match = of_match_device(fsl_of_msi_ids, &dev->dev); |
322 | if (!match) | ||
320 | return -EINVAL; | 323 | return -EINVAL; |
321 | features = dev->dev.of_match->data; | 324 | features = match->data; |
322 | 325 | ||
323 | printk(KERN_DEBUG "Setting up Freescale MSI support\n"); | 326 | printk(KERN_DEBUG "Setting up Freescale MSI support\n"); |
324 | 327 | ||
diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c index 44bca3f994b..8b16c479585 100644 --- a/arch/s390/crypto/prng.c +++ b/arch/s390/crypto/prng.c | |||
@@ -76,7 +76,7 @@ static void prng_seed(int nbytes) | |||
76 | 76 | ||
77 | /* Add the entropy */ | 77 | /* Add the entropy */ |
78 | while (nbytes >= 8) { | 78 | while (nbytes >= 8) { |
79 | *((__u64 *)parm_block) ^= *((__u64 *)buf+i); | 79 | *((__u64 *)parm_block) ^= *((__u64 *)(buf+i)); |
80 | prng_add_entropy(); | 80 | prng_add_entropy(); |
81 | i += 8; | 81 | i += 8; |
82 | nbytes -= 8; | 82 | nbytes -= 8; |
diff --git a/arch/s390/include/asm/diag.h b/arch/s390/include/asm/diag.h index 72b2e2f2d32..7e91c58072e 100644 --- a/arch/s390/include/asm/diag.h +++ b/arch/s390/include/asm/diag.h | |||
@@ -9,9 +9,22 @@ | |||
9 | #define _ASM_S390_DIAG_H | 9 | #define _ASM_S390_DIAG_H |
10 | 10 | ||
11 | /* | 11 | /* |
12 | * Diagnose 10: Release pages | 12 | * Diagnose 10: Release page range |
13 | */ | 13 | */ |
14 | extern void diag10(unsigned long addr); | 14 | static inline void diag10_range(unsigned long start_pfn, unsigned long num_pfn) |
15 | { | ||
16 | unsigned long start_addr, end_addr; | ||
17 | |||
18 | start_addr = start_pfn << PAGE_SHIFT; | ||
19 | end_addr = (start_pfn + num_pfn - 1) << PAGE_SHIFT; | ||
20 | |||
21 | asm volatile( | ||
22 | "0: diag %0,%1,0x10\n" | ||
23 | "1:\n" | ||
24 | EX_TABLE(0b, 1b) | ||
25 | EX_TABLE(1b, 1b) | ||
26 | : : "a" (start_addr), "a" (end_addr)); | ||
27 | } | ||
15 | 28 | ||
16 | /* | 29 | /* |
17 | * Diagnose 14: Input spool file manipulation | 30 | * Diagnose 14: Input spool file manipulation |
diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h index a6f0e7cc9cd..8c277caa8d3 100644 --- a/arch/s390/include/asm/mmu_context.h +++ b/arch/s390/include/asm/mmu_context.h | |||
@@ -23,7 +23,7 @@ static inline int init_new_context(struct task_struct *tsk, | |||
23 | #ifdef CONFIG_64BIT | 23 | #ifdef CONFIG_64BIT |
24 | mm->context.asce_bits |= _ASCE_TYPE_REGION3; | 24 | mm->context.asce_bits |= _ASCE_TYPE_REGION3; |
25 | #endif | 25 | #endif |
26 | if (current->mm->context.alloc_pgste) { | 26 | if (current->mm && current->mm->context.alloc_pgste) { |
27 | /* | 27 | /* |
28 | * alloc_pgste indicates, that any NEW context will be created | 28 | * alloc_pgste indicates, that any NEW context will be created |
29 | * with extended page tables. The old context is unchanged. The | 29 | * with extended page tables. The old context is unchanged. The |
diff --git a/arch/s390/kernel/diag.c b/arch/s390/kernel/diag.c index c032d11da8a..8237fc07ac7 100644 --- a/arch/s390/kernel/diag.c +++ b/arch/s390/kernel/diag.c | |||
@@ -9,27 +9,6 @@ | |||
9 | #include <asm/diag.h> | 9 | #include <asm/diag.h> |
10 | 10 | ||
11 | /* | 11 | /* |
12 | * Diagnose 10: Release pages | ||
13 | */ | ||
14 | void diag10(unsigned long addr) | ||
15 | { | ||
16 | if (addr >= 0x7ff00000) | ||
17 | return; | ||
18 | asm volatile( | ||
19 | #ifdef CONFIG_64BIT | ||
20 | " sam31\n" | ||
21 | " diag %0,%0,0x10\n" | ||
22 | "0: sam64\n" | ||
23 | #else | ||
24 | " diag %0,%0,0x10\n" | ||
25 | "0:\n" | ||
26 | #endif | ||
27 | EX_TABLE(0b, 0b) | ||
28 | : : "a" (addr)); | ||
29 | } | ||
30 | EXPORT_SYMBOL(diag10); | ||
31 | |||
32 | /* | ||
33 | * Diagnose 14: Input spool file manipulation | 12 | * Diagnose 14: Input spool file manipulation |
34 | */ | 13 | */ |
35 | int diag14(unsigned long rx, unsigned long ry1, unsigned long subcode) | 14 | int diag14(unsigned long rx, unsigned long ry1, unsigned long subcode) |
diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c index c83726c9fe0..3d4a78fc1ad 100644 --- a/arch/s390/kernel/dis.c +++ b/arch/s390/kernel/dis.c | |||
@@ -672,6 +672,7 @@ static struct insn opcode_b2[] = { | |||
672 | { "rp", 0x77, INSTR_S_RD }, | 672 | { "rp", 0x77, INSTR_S_RD }, |
673 | { "stcke", 0x78, INSTR_S_RD }, | 673 | { "stcke", 0x78, INSTR_S_RD }, |
674 | { "sacf", 0x79, INSTR_S_RD }, | 674 | { "sacf", 0x79, INSTR_S_RD }, |
675 | { "spp", 0x80, INSTR_S_RD }, | ||
675 | { "stsi", 0x7d, INSTR_S_RD }, | 676 | { "stsi", 0x7d, INSTR_S_RD }, |
676 | { "srnm", 0x99, INSTR_S_RD }, | 677 | { "srnm", 0x99, INSTR_S_RD }, |
677 | { "stfpc", 0x9c, INSTR_S_RD }, | 678 | { "stfpc", 0x9c, INSTR_S_RD }, |
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S index 648f64239a9..1b67fc6ebdc 100644 --- a/arch/s390/kernel/entry.S +++ b/arch/s390/kernel/entry.S | |||
@@ -836,7 +836,7 @@ restart_base: | |||
836 | stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on | 836 | stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on |
837 | basr %r14,0 | 837 | basr %r14,0 |
838 | l %r14,restart_addr-.(%r14) | 838 | l %r14,restart_addr-.(%r14) |
839 | br %r14 # branch to start_secondary | 839 | basr %r14,%r14 # branch to start_secondary |
840 | restart_addr: | 840 | restart_addr: |
841 | .long start_secondary | 841 | .long start_secondary |
842 | .align 8 | 842 | .align 8 |
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S index 9d3603d6c51..9fd86456349 100644 --- a/arch/s390/kernel/entry64.S +++ b/arch/s390/kernel/entry64.S | |||
@@ -841,7 +841,7 @@ restart_base: | |||
841 | mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1) | 841 | mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1) |
842 | xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER | 842 | xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER |
843 | stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on | 843 | stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on |
844 | jg start_secondary | 844 | brasl %r14,start_secondary |
845 | .align 8 | 845 | .align 8 |
846 | restart_vtime: | 846 | restart_vtime: |
847 | .long 0x7fffffff,0xffffffff | 847 | .long 0x7fffffff,0xffffffff |
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c index c66ffd8dbbb..1f1dba9dcf5 100644 --- a/arch/s390/mm/cmm.c +++ b/arch/s390/mm/cmm.c | |||
@@ -91,7 +91,7 @@ static long cmm_alloc_pages(long nr, long *counter, | |||
91 | } else | 91 | } else |
92 | free_page((unsigned long) npa); | 92 | free_page((unsigned long) npa); |
93 | } | 93 | } |
94 | diag10(addr); | 94 | diag10_range(addr >> PAGE_SHIFT, 1); |
95 | pa->pages[pa->index++] = addr; | 95 | pa->pages[pa->index++] = addr; |
96 | (*counter)++; | 96 | (*counter)++; |
97 | spin_unlock(&cmm_lock); | 97 | spin_unlock(&cmm_lock); |
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 4cf85fef407..ab988135e5c 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c | |||
@@ -543,7 +543,6 @@ static void pfault_interrupt(unsigned int ext_int_code, | |||
543 | struct task_struct *tsk; | 543 | struct task_struct *tsk; |
544 | __u16 subcode; | 544 | __u16 subcode; |
545 | 545 | ||
546 | kstat_cpu(smp_processor_id()).irqs[EXTINT_PFL]++; | ||
547 | /* | 546 | /* |
548 | * Get the external interruption subcode & pfault | 547 | * Get the external interruption subcode & pfault |
549 | * initial/completion signal bit. VM stores this | 548 | * initial/completion signal bit. VM stores this |
@@ -553,6 +552,7 @@ static void pfault_interrupt(unsigned int ext_int_code, | |||
553 | subcode = ext_int_code >> 16; | 552 | subcode = ext_int_code >> 16; |
554 | if ((subcode & 0xff00) != __SUBCODE_MASK) | 553 | if ((subcode & 0xff00) != __SUBCODE_MASK) |
555 | return; | 554 | return; |
555 | kstat_cpu(smp_processor_id()).irqs[EXTINT_PFL]++; | ||
556 | 556 | ||
557 | /* | 557 | /* |
558 | * Get the token (= address of the task structure of the affected task). | 558 | * Get the token (= address of the task structure of the affected task). |
diff --git a/arch/s390/oprofile/hwsampler.c b/arch/s390/oprofile/hwsampler.c index 4952872d6f0..33cbd373cce 100644 --- a/arch/s390/oprofile/hwsampler.c +++ b/arch/s390/oprofile/hwsampler.c | |||
@@ -1021,20 +1021,14 @@ deallocate_exit: | |||
1021 | return rc; | 1021 | return rc; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | long hwsampler_query_min_interval(void) | 1024 | unsigned long hwsampler_query_min_interval(void) |
1025 | { | 1025 | { |
1026 | if (min_sampler_rate) | 1026 | return min_sampler_rate; |
1027 | return min_sampler_rate; | ||
1028 | else | ||
1029 | return -EINVAL; | ||
1030 | } | 1027 | } |
1031 | 1028 | ||
1032 | long hwsampler_query_max_interval(void) | 1029 | unsigned long hwsampler_query_max_interval(void) |
1033 | { | 1030 | { |
1034 | if (max_sampler_rate) | 1031 | return max_sampler_rate; |
1035 | return max_sampler_rate; | ||
1036 | else | ||
1037 | return -EINVAL; | ||
1038 | } | 1032 | } |
1039 | 1033 | ||
1040 | unsigned long hwsampler_get_sample_overflow_count(unsigned int cpu) | 1034 | unsigned long hwsampler_get_sample_overflow_count(unsigned int cpu) |
diff --git a/arch/s390/oprofile/hwsampler.h b/arch/s390/oprofile/hwsampler.h index 8c72b59316b..1912f3bb190 100644 --- a/arch/s390/oprofile/hwsampler.h +++ b/arch/s390/oprofile/hwsampler.h | |||
@@ -102,8 +102,8 @@ int hwsampler_setup(void); | |||
102 | int hwsampler_shutdown(void); | 102 | int hwsampler_shutdown(void); |
103 | int hwsampler_allocate(unsigned long sdbt, unsigned long sdb); | 103 | int hwsampler_allocate(unsigned long sdbt, unsigned long sdb); |
104 | int hwsampler_deallocate(void); | 104 | int hwsampler_deallocate(void); |
105 | long hwsampler_query_min_interval(void); | 105 | unsigned long hwsampler_query_min_interval(void); |
106 | long hwsampler_query_max_interval(void); | 106 | unsigned long hwsampler_query_max_interval(void); |
107 | int hwsampler_start_all(unsigned long interval); | 107 | int hwsampler_start_all(unsigned long interval); |
108 | int hwsampler_stop_all(void); | 108 | int hwsampler_stop_all(void); |
109 | int hwsampler_deactivate(unsigned int cpu); | 109 | int hwsampler_deactivate(unsigned int cpu); |
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c index c63d7e58352..5995e9bc72d 100644 --- a/arch/s390/oprofile/init.c +++ b/arch/s390/oprofile/init.c | |||
@@ -145,15 +145,11 @@ static int oprofile_hwsampler_init(struct oprofile_operations *ops) | |||
145 | * create hwsampler files only if hwsampler_setup() succeeds. | 145 | * create hwsampler files only if hwsampler_setup() succeeds. |
146 | */ | 146 | */ |
147 | oprofile_min_interval = hwsampler_query_min_interval(); | 147 | oprofile_min_interval = hwsampler_query_min_interval(); |
148 | if (oprofile_min_interval < 0) { | 148 | if (oprofile_min_interval == 0) |
149 | oprofile_min_interval = 0; | ||
150 | return -ENODEV; | 149 | return -ENODEV; |
151 | } | ||
152 | oprofile_max_interval = hwsampler_query_max_interval(); | 150 | oprofile_max_interval = hwsampler_query_max_interval(); |
153 | if (oprofile_max_interval < 0) { | 151 | if (oprofile_max_interval == 0) |
154 | oprofile_max_interval = 0; | ||
155 | return -ENODEV; | 152 | return -ENODEV; |
156 | } | ||
157 | 153 | ||
158 | if (oprofile_timer_init(ops)) | 154 | if (oprofile_timer_init(ops)) |
159 | return -ENODEV; | 155 | return -ENODEV; |
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c index 2130ca674e9..3d7b209b217 100644 --- a/arch/sh/kernel/ptrace_32.c +++ b/arch/sh/kernel/ptrace_32.c | |||
@@ -117,7 +117,11 @@ void user_enable_single_step(struct task_struct *child) | |||
117 | 117 | ||
118 | set_tsk_thread_flag(child, TIF_SINGLESTEP); | 118 | set_tsk_thread_flag(child, TIF_SINGLESTEP); |
119 | 119 | ||
120 | if (ptrace_get_breakpoints(child) < 0) | ||
121 | return; | ||
122 | |||
120 | set_single_step(child, pc); | 123 | set_single_step(child, pc); |
124 | ptrace_put_breakpoints(child); | ||
121 | } | 125 | } |
122 | 126 | ||
123 | void user_disable_single_step(struct task_struct *child) | 127 | void user_disable_single_step(struct task_struct *child) |
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c index f679c57644d..1e34f29e58b 100644 --- a/arch/sparc/kernel/apc.c +++ b/arch/sparc/kernel/apc.c | |||
@@ -165,7 +165,7 @@ static int __devinit apc_probe(struct platform_device *op) | |||
165 | return 0; | 165 | return 0; |
166 | } | 166 | } |
167 | 167 | ||
168 | static struct of_device_id __initdata apc_match[] = { | 168 | static struct of_device_id apc_match[] = { |
169 | { | 169 | { |
170 | .name = APC_OBPNAME, | 170 | .name = APC_OBPNAME, |
171 | }, | 171 | }, |
diff --git a/arch/sparc/kernel/pci_sabre.c b/arch/sparc/kernel/pci_sabre.c index 948068a083f..d1840dbdaa2 100644 --- a/arch/sparc/kernel/pci_sabre.c +++ b/arch/sparc/kernel/pci_sabre.c | |||
@@ -452,8 +452,10 @@ static void __devinit sabre_pbm_init(struct pci_pbm_info *pbm, | |||
452 | sabre_scan_bus(pbm, &op->dev); | 452 | sabre_scan_bus(pbm, &op->dev); |
453 | } | 453 | } |
454 | 454 | ||
455 | static const struct of_device_id sabre_match[]; | ||
455 | static int __devinit sabre_probe(struct platform_device *op) | 456 | static int __devinit sabre_probe(struct platform_device *op) |
456 | { | 457 | { |
458 | const struct of_device_id *match; | ||
457 | const struct linux_prom64_registers *pr_regs; | 459 | const struct linux_prom64_registers *pr_regs; |
458 | struct device_node *dp = op->dev.of_node; | 460 | struct device_node *dp = op->dev.of_node; |
459 | struct pci_pbm_info *pbm; | 461 | struct pci_pbm_info *pbm; |
@@ -463,7 +465,8 @@ static int __devinit sabre_probe(struct platform_device *op) | |||
463 | const u32 *vdma; | 465 | const u32 *vdma; |
464 | u64 clear_irq; | 466 | u64 clear_irq; |
465 | 467 | ||
466 | hummingbird_p = op->dev.of_match && (op->dev.of_match->data != NULL); | 468 | match = of_match_device(sabre_match, &op->dev); |
469 | hummingbird_p = match && (match->data != NULL); | ||
467 | if (!hummingbird_p) { | 470 | if (!hummingbird_p) { |
468 | struct device_node *cpu_dp; | 471 | struct device_node *cpu_dp; |
469 | 472 | ||
diff --git a/arch/sparc/kernel/pci_schizo.c b/arch/sparc/kernel/pci_schizo.c index fecfcb2063c..283fbc329a4 100644 --- a/arch/sparc/kernel/pci_schizo.c +++ b/arch/sparc/kernel/pci_schizo.c | |||
@@ -1458,11 +1458,15 @@ out_err: | |||
1458 | return err; | 1458 | return err; |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | static const struct of_device_id schizo_match[]; | ||
1461 | static int __devinit schizo_probe(struct platform_device *op) | 1462 | static int __devinit schizo_probe(struct platform_device *op) |
1462 | { | 1463 | { |
1463 | if (!op->dev.of_match) | 1464 | const struct of_device_id *match; |
1465 | |||
1466 | match = of_match_device(schizo_match, &op->dev); | ||
1467 | if (!match) | ||
1464 | return -EINVAL; | 1468 | return -EINVAL; |
1465 | return __schizo_init(op, (unsigned long) op->dev.of_match->data); | 1469 | return __schizo_init(op, (unsigned long)match->data); |
1466 | } | 1470 | } |
1467 | 1471 | ||
1468 | /* The ordering of this table is very important. Some Tomatillo | 1472 | /* The ordering of this table is very important. Some Tomatillo |
diff --git a/arch/sparc/kernel/pmc.c b/arch/sparc/kernel/pmc.c index 93d7b4465f8..6a585d39358 100644 --- a/arch/sparc/kernel/pmc.c +++ b/arch/sparc/kernel/pmc.c | |||
@@ -69,7 +69,7 @@ static int __devinit pmc_probe(struct platform_device *op) | |||
69 | return 0; | 69 | return 0; |
70 | } | 70 | } |
71 | 71 | ||
72 | static struct of_device_id __initdata pmc_match[] = { | 72 | static struct of_device_id pmc_match[] = { |
73 | { | 73 | { |
74 | .name = PMC_OBPNAME, | 74 | .name = PMC_OBPNAME, |
75 | }, | 75 | }, |
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index 91c10fb7085..850a1360c0d 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c | |||
@@ -53,6 +53,7 @@ cpumask_t smp_commenced_mask = CPU_MASK_NONE; | |||
53 | void __cpuinit smp_store_cpu_info(int id) | 53 | void __cpuinit smp_store_cpu_info(int id) |
54 | { | 54 | { |
55 | int cpu_node; | 55 | int cpu_node; |
56 | int mid; | ||
56 | 57 | ||
57 | cpu_data(id).udelay_val = loops_per_jiffy; | 58 | cpu_data(id).udelay_val = loops_per_jiffy; |
58 | 59 | ||
@@ -60,10 +61,13 @@ void __cpuinit smp_store_cpu_info(int id) | |||
60 | cpu_data(id).clock_tick = prom_getintdefault(cpu_node, | 61 | cpu_data(id).clock_tick = prom_getintdefault(cpu_node, |
61 | "clock-frequency", 0); | 62 | "clock-frequency", 0); |
62 | cpu_data(id).prom_node = cpu_node; | 63 | cpu_data(id).prom_node = cpu_node; |
63 | cpu_data(id).mid = cpu_get_hwmid(cpu_node); | 64 | mid = cpu_get_hwmid(cpu_node); |
64 | 65 | ||
65 | if (cpu_data(id).mid < 0) | 66 | if (mid < 0) { |
66 | panic("No MID found for CPU%d at node 0x%08d", id, cpu_node); | 67 | printk(KERN_NOTICE "No MID found for CPU%d at node 0x%08d", id, cpu_node); |
68 | mid = 0; | ||
69 | } | ||
70 | cpu_data(id).mid = mid; | ||
67 | } | 71 | } |
68 | 72 | ||
69 | void __init smp_cpus_done(unsigned int max_cpus) | 73 | void __init smp_cpus_done(unsigned int max_cpus) |
diff --git a/arch/sparc/kernel/time_32.c b/arch/sparc/kernel/time_32.c index 4e236391b63..96046a4024c 100644 --- a/arch/sparc/kernel/time_32.c +++ b/arch/sparc/kernel/time_32.c | |||
@@ -168,7 +168,7 @@ static int __devinit clock_probe(struct platform_device *op) | |||
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | 170 | ||
171 | static struct of_device_id __initdata clock_match[] = { | 171 | static struct of_device_id clock_match[] = { |
172 | { | 172 | { |
173 | .name = "eeprom", | 173 | .name = "eeprom", |
174 | }, | 174 | }, |
diff --git a/arch/sparc/lib/checksum_32.S b/arch/sparc/lib/checksum_32.S index 3632cb34e91..0084c3361e1 100644 --- a/arch/sparc/lib/checksum_32.S +++ b/arch/sparc/lib/checksum_32.S | |||
@@ -289,10 +289,16 @@ cc_end_cruft: | |||
289 | 289 | ||
290 | /* Also, handle the alignment code out of band. */ | 290 | /* Also, handle the alignment code out of band. */ |
291 | cc_dword_align: | 291 | cc_dword_align: |
292 | cmp %g1, 6 | 292 | cmp %g1, 16 |
293 | bl,a ccte | 293 | bge 1f |
294 | srl %g1, 1, %o3 | ||
295 | 2: cmp %o3, 0 | ||
296 | be,a ccte | ||
294 | andcc %g1, 0xf, %o3 | 297 | andcc %g1, 0xf, %o3 |
295 | andcc %o0, 0x1, %g0 | 298 | andcc %o3, %o0, %g0 ! Check %o0 only (%o1 has the same last 2 bits) |
299 | be,a 2b | ||
300 | srl %o3, 1, %o3 | ||
301 | 1: andcc %o0, 0x1, %g0 | ||
296 | bne ccslow | 302 | bne ccslow |
297 | andcc %o0, 0x2, %g0 | 303 | andcc %o0, 0x2, %g0 |
298 | be 1f | 304 | be 1f |
diff --git a/arch/um/os-Linux/util.c b/arch/um/os-Linux/util.c index 6ea77979531..42827cafa6a 100644 --- a/arch/um/os-Linux/util.c +++ b/arch/um/os-Linux/util.c | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <unistd.h> | ||
8 | #include <errno.h> | 9 | #include <errno.h> |
9 | #include <signal.h> | 10 | #include <signal.h> |
10 | #include <string.h> | 11 | #include <string.h> |
@@ -75,6 +76,26 @@ void setup_hostinfo(char *buf, int len) | |||
75 | host.release, host.version, host.machine); | 76 | host.release, host.version, host.machine); |
76 | } | 77 | } |
77 | 78 | ||
79 | /* | ||
80 | * We cannot use glibc's abort(). It makes use of tgkill() which | ||
81 | * has no effect within UML's kernel threads. | ||
82 | * After that glibc would execute an invalid instruction to kill | ||
83 | * the calling process and UML crashes with SIGSEGV. | ||
84 | */ | ||
85 | static inline void __attribute__ ((noreturn)) uml_abort(void) | ||
86 | { | ||
87 | sigset_t sig; | ||
88 | |||
89 | fflush(NULL); | ||
90 | |||
91 | if (!sigemptyset(&sig) && !sigaddset(&sig, SIGABRT)) | ||
92 | sigprocmask(SIG_UNBLOCK, &sig, 0); | ||
93 | |||
94 | for (;;) | ||
95 | if (kill(getpid(), SIGABRT) < 0) | ||
96 | exit(127); | ||
97 | } | ||
98 | |||
78 | void os_dump_core(void) | 99 | void os_dump_core(void) |
79 | { | 100 | { |
80 | int pid; | 101 | int pid; |
@@ -116,5 +137,5 @@ void os_dump_core(void) | |||
116 | while ((pid = waitpid(-1, NULL, WNOHANG | __WALL)) > 0) | 137 | while ((pid = waitpid(-1, NULL, WNOHANG | __WALL)) > 0) |
117 | os_kill_ptraced_process(pid, 0); | 138 | os_kill_ptraced_process(pid, 0); |
118 | 139 | ||
119 | abort(); | 140 | uml_abort(); |
120 | } | 141 | } |
diff --git a/arch/x86/include/asm/apicdef.h b/arch/x86/include/asm/apicdef.h index d87988bacf3..34595d5e103 100644 --- a/arch/x86/include/asm/apicdef.h +++ b/arch/x86/include/asm/apicdef.h | |||
@@ -78,6 +78,7 @@ | |||
78 | #define APIC_DEST_LOGICAL 0x00800 | 78 | #define APIC_DEST_LOGICAL 0x00800 |
79 | #define APIC_DEST_PHYSICAL 0x00000 | 79 | #define APIC_DEST_PHYSICAL 0x00000 |
80 | #define APIC_DM_FIXED 0x00000 | 80 | #define APIC_DM_FIXED 0x00000 |
81 | #define APIC_DM_FIXED_MASK 0x00700 | ||
81 | #define APIC_DM_LOWEST 0x00100 | 82 | #define APIC_DM_LOWEST 0x00100 |
82 | #define APIC_DM_SMI 0x00200 | 83 | #define APIC_DM_SMI 0x00200 |
83 | #define APIC_DM_REMRD 0x00300 | 84 | #define APIC_DM_REMRD 0x00300 |
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index 7db7723d1f3..d56187c6b83 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h | |||
@@ -299,6 +299,7 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, | |||
299 | /* Install a pte for a particular vaddr in kernel space. */ | 299 | /* Install a pte for a particular vaddr in kernel space. */ |
300 | void set_pte_vaddr(unsigned long vaddr, pte_t pte); | 300 | void set_pte_vaddr(unsigned long vaddr, pte_t pte); |
301 | 301 | ||
302 | extern void native_pagetable_reserve(u64 start, u64 end); | ||
302 | #ifdef CONFIG_X86_32 | 303 | #ifdef CONFIG_X86_32 |
303 | extern void native_pagetable_setup_start(pgd_t *base); | 304 | extern void native_pagetable_setup_start(pgd_t *base); |
304 | extern void native_pagetable_setup_done(pgd_t *base); | 305 | extern void native_pagetable_setup_done(pgd_t *base); |
diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h index 3e094af443c..130f1eeee5f 100644 --- a/arch/x86/include/asm/uv/uv_bau.h +++ b/arch/x86/include/asm/uv/uv_bau.h | |||
@@ -94,6 +94,8 @@ | |||
94 | /* after this # consecutive successes, bump up the throttle if it was lowered */ | 94 | /* after this # consecutive successes, bump up the throttle if it was lowered */ |
95 | #define COMPLETE_THRESHOLD 5 | 95 | #define COMPLETE_THRESHOLD 5 |
96 | 96 | ||
97 | #define UV_LB_SUBNODEID 0x10 | ||
98 | |||
97 | /* | 99 | /* |
98 | * number of entries in the destination side payload queue | 100 | * number of entries in the destination side payload queue |
99 | */ | 101 | */ |
@@ -124,7 +126,7 @@ | |||
124 | * The distribution specification (32 bytes) is interpreted as a 256-bit | 126 | * The distribution specification (32 bytes) is interpreted as a 256-bit |
125 | * distribution vector. Adjacent bits correspond to consecutive even numbered | 127 | * distribution vector. Adjacent bits correspond to consecutive even numbered |
126 | * nodeIDs. The result of adding the index of a given bit to the 15-bit | 128 | * nodeIDs. The result of adding the index of a given bit to the 15-bit |
127 | * 'base_dest_nodeid' field of the header corresponds to the | 129 | * 'base_dest_nasid' field of the header corresponds to the |
128 | * destination nodeID associated with that specified bit. | 130 | * destination nodeID associated with that specified bit. |
129 | */ | 131 | */ |
130 | struct bau_target_uvhubmask { | 132 | struct bau_target_uvhubmask { |
@@ -176,7 +178,7 @@ struct bau_msg_payload { | |||
176 | struct bau_msg_header { | 178 | struct bau_msg_header { |
177 | unsigned int dest_subnodeid:6; /* must be 0x10, for the LB */ | 179 | unsigned int dest_subnodeid:6; /* must be 0x10, for the LB */ |
178 | /* bits 5:0 */ | 180 | /* bits 5:0 */ |
179 | unsigned int base_dest_nodeid:15; /* nasid of the */ | 181 | unsigned int base_dest_nasid:15; /* nasid of the */ |
180 | /* bits 20:6 */ /* first bit in uvhub map */ | 182 | /* bits 20:6 */ /* first bit in uvhub map */ |
181 | unsigned int command:8; /* message type */ | 183 | unsigned int command:8; /* message type */ |
182 | /* bits 28:21 */ | 184 | /* bits 28:21 */ |
@@ -378,6 +380,10 @@ struct ptc_stats { | |||
378 | unsigned long d_rcanceled; /* number of messages canceled by resets */ | 380 | unsigned long d_rcanceled; /* number of messages canceled by resets */ |
379 | }; | 381 | }; |
380 | 382 | ||
383 | struct hub_and_pnode { | ||
384 | short uvhub; | ||
385 | short pnode; | ||
386 | }; | ||
381 | /* | 387 | /* |
382 | * one per-cpu; to locate the software tables | 388 | * one per-cpu; to locate the software tables |
383 | */ | 389 | */ |
@@ -399,10 +405,12 @@ struct bau_control { | |||
399 | int baudisabled; | 405 | int baudisabled; |
400 | int set_bau_off; | 406 | int set_bau_off; |
401 | short cpu; | 407 | short cpu; |
408 | short osnode; | ||
402 | short uvhub_cpu; | 409 | short uvhub_cpu; |
403 | short uvhub; | 410 | short uvhub; |
404 | short cpus_in_socket; | 411 | short cpus_in_socket; |
405 | short cpus_in_uvhub; | 412 | short cpus_in_uvhub; |
413 | short partition_base_pnode; | ||
406 | unsigned short message_number; | 414 | unsigned short message_number; |
407 | unsigned short uvhub_quiesce; | 415 | unsigned short uvhub_quiesce; |
408 | short socket_acknowledge_count[DEST_Q_SIZE]; | 416 | short socket_acknowledge_count[DEST_Q_SIZE]; |
@@ -422,15 +430,16 @@ struct bau_control { | |||
422 | int congested_period; | 430 | int congested_period; |
423 | cycles_t period_time; | 431 | cycles_t period_time; |
424 | long period_requests; | 432 | long period_requests; |
433 | struct hub_and_pnode *target_hub_and_pnode; | ||
425 | }; | 434 | }; |
426 | 435 | ||
427 | static inline int bau_uvhub_isset(int uvhub, struct bau_target_uvhubmask *dstp) | 436 | static inline int bau_uvhub_isset(int uvhub, struct bau_target_uvhubmask *dstp) |
428 | { | 437 | { |
429 | return constant_test_bit(uvhub, &dstp->bits[0]); | 438 | return constant_test_bit(uvhub, &dstp->bits[0]); |
430 | } | 439 | } |
431 | static inline void bau_uvhub_set(int uvhub, struct bau_target_uvhubmask *dstp) | 440 | static inline void bau_uvhub_set(int pnode, struct bau_target_uvhubmask *dstp) |
432 | { | 441 | { |
433 | __set_bit(uvhub, &dstp->bits[0]); | 442 | __set_bit(pnode, &dstp->bits[0]); |
434 | } | 443 | } |
435 | static inline void bau_uvhubs_clear(struct bau_target_uvhubmask *dstp, | 444 | static inline void bau_uvhubs_clear(struct bau_target_uvhubmask *dstp, |
436 | int nbits) | 445 | int nbits) |
diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h index a501741c233..4298002d0c8 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h | |||
@@ -398,6 +398,8 @@ struct uv_blade_info { | |||
398 | unsigned short nr_online_cpus; | 398 | unsigned short nr_online_cpus; |
399 | unsigned short pnode; | 399 | unsigned short pnode; |
400 | short memory_nid; | 400 | short memory_nid; |
401 | spinlock_t nmi_lock; | ||
402 | unsigned long nmi_count; | ||
401 | }; | 403 | }; |
402 | extern struct uv_blade_info *uv_blade_info; | 404 | extern struct uv_blade_info *uv_blade_info; |
403 | extern short *uv_node_to_blade; | 405 | extern short *uv_node_to_blade; |
diff --git a/arch/x86/include/asm/uv/uv_mmrs.h b/arch/x86/include/asm/uv/uv_mmrs.h index 20cafeac745..f5bb64a823d 100644 --- a/arch/x86/include/asm/uv/uv_mmrs.h +++ b/arch/x86/include/asm/uv/uv_mmrs.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * SGI UV MMR definitions | 6 | * SGI UV MMR definitions |
7 | * | 7 | * |
8 | * Copyright (C) 2007-2010 Silicon Graphics, Inc. All rights reserved. | 8 | * Copyright (C) 2007-2011 Silicon Graphics, Inc. All rights reserved. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #ifndef _ASM_X86_UV_UV_MMRS_H | 11 | #ifndef _ASM_X86_UV_UV_MMRS_H |
@@ -1099,5 +1099,19 @@ union uvh_rtc1_int_config_u { | |||
1099 | } s; | 1099 | } s; |
1100 | }; | 1100 | }; |
1101 | 1101 | ||
1102 | /* ========================================================================= */ | ||
1103 | /* UVH_SCRATCH5 */ | ||
1104 | /* ========================================================================= */ | ||
1105 | #define UVH_SCRATCH5 0x2d0200UL | ||
1106 | #define UVH_SCRATCH5_32 0x00778 | ||
1107 | |||
1108 | #define UVH_SCRATCH5_SCRATCH5_SHFT 0 | ||
1109 | #define UVH_SCRATCH5_SCRATCH5_MASK 0xffffffffffffffffUL | ||
1110 | union uvh_scratch5_u { | ||
1111 | unsigned long v; | ||
1112 | struct uvh_scratch5_s { | ||
1113 | unsigned long scratch5 : 64; /* RW, W1CS */ | ||
1114 | } s; | ||
1115 | }; | ||
1102 | 1116 | ||
1103 | #endif /* __ASM_UV_MMRS_X86_H__ */ | 1117 | #endif /* __ASM_UV_MMRS_X86_H__ */ |
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h index 643ebf2e2ad..d3d859035af 100644 --- a/arch/x86/include/asm/x86_init.h +++ b/arch/x86/include/asm/x86_init.h | |||
@@ -68,6 +68,17 @@ struct x86_init_oem { | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * struct x86_init_mapping - platform specific initial kernel pagetable setup | ||
72 | * @pagetable_reserve: reserve a range of addresses for kernel pagetable usage | ||
73 | * | ||
74 | * For more details on the purpose of this hook, look in | ||
75 | * init_memory_mapping and the commit that added it. | ||
76 | */ | ||
77 | struct x86_init_mapping { | ||
78 | void (*pagetable_reserve)(u64 start, u64 end); | ||
79 | }; | ||
80 | |||
81 | /** | ||
71 | * struct x86_init_paging - platform specific paging functions | 82 | * struct x86_init_paging - platform specific paging functions |
72 | * @pagetable_setup_start: platform specific pre paging_init() call | 83 | * @pagetable_setup_start: platform specific pre paging_init() call |
73 | * @pagetable_setup_done: platform specific post paging_init() call | 84 | * @pagetable_setup_done: platform specific post paging_init() call |
@@ -123,6 +134,7 @@ struct x86_init_ops { | |||
123 | struct x86_init_mpparse mpparse; | 134 | struct x86_init_mpparse mpparse; |
124 | struct x86_init_irqs irqs; | 135 | struct x86_init_irqs irqs; |
125 | struct x86_init_oem oem; | 136 | struct x86_init_oem oem; |
137 | struct x86_init_mapping mapping; | ||
126 | struct x86_init_paging paging; | 138 | struct x86_init_paging paging; |
127 | struct x86_init_timers timers; | 139 | struct x86_init_timers timers; |
128 | struct x86_init_iommu iommu; | 140 | struct x86_init_iommu iommu; |
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index 33b10a0fc09..7acd2d2ac96 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c | |||
@@ -37,6 +37,13 @@ | |||
37 | #include <asm/smp.h> | 37 | #include <asm/smp.h> |
38 | #include <asm/x86_init.h> | 38 | #include <asm/x86_init.h> |
39 | #include <asm/emergency-restart.h> | 39 | #include <asm/emergency-restart.h> |
40 | #include <asm/nmi.h> | ||
41 | |||
42 | /* BMC sets a bit this MMR non-zero before sending an NMI */ | ||
43 | #define UVH_NMI_MMR UVH_SCRATCH5 | ||
44 | #define UVH_NMI_MMR_CLEAR (UVH_NMI_MMR + 8) | ||
45 | #define UV_NMI_PENDING_MASK (1UL << 63) | ||
46 | DEFINE_PER_CPU(unsigned long, cpu_last_nmi_count); | ||
40 | 47 | ||
41 | DEFINE_PER_CPU(int, x2apic_extra_bits); | 48 | DEFINE_PER_CPU(int, x2apic_extra_bits); |
42 | 49 | ||
@@ -642,18 +649,46 @@ void __cpuinit uv_cpu_init(void) | |||
642 | */ | 649 | */ |
643 | int uv_handle_nmi(struct notifier_block *self, unsigned long reason, void *data) | 650 | int uv_handle_nmi(struct notifier_block *self, unsigned long reason, void *data) |
644 | { | 651 | { |
652 | unsigned long real_uv_nmi; | ||
653 | int bid; | ||
654 | |||
645 | if (reason != DIE_NMIUNKNOWN) | 655 | if (reason != DIE_NMIUNKNOWN) |
646 | return NOTIFY_OK; | 656 | return NOTIFY_OK; |
647 | 657 | ||
648 | if (in_crash_kexec) | 658 | if (in_crash_kexec) |
649 | /* do nothing if entering the crash kernel */ | 659 | /* do nothing if entering the crash kernel */ |
650 | return NOTIFY_OK; | 660 | return NOTIFY_OK; |
661 | |||
651 | /* | 662 | /* |
652 | * Use a lock so only one cpu prints at a time | 663 | * Each blade has an MMR that indicates when an NMI has been sent |
653 | * to prevent intermixed output. | 664 | * to cpus on the blade. If an NMI is detected, atomically |
665 | * clear the MMR and update a per-blade NMI count used to | ||
666 | * cause each cpu on the blade to notice a new NMI. | ||
667 | */ | ||
668 | bid = uv_numa_blade_id(); | ||
669 | real_uv_nmi = (uv_read_local_mmr(UVH_NMI_MMR) & UV_NMI_PENDING_MASK); | ||
670 | |||
671 | if (unlikely(real_uv_nmi)) { | ||
672 | spin_lock(&uv_blade_info[bid].nmi_lock); | ||
673 | real_uv_nmi = (uv_read_local_mmr(UVH_NMI_MMR) & UV_NMI_PENDING_MASK); | ||
674 | if (real_uv_nmi) { | ||
675 | uv_blade_info[bid].nmi_count++; | ||
676 | uv_write_local_mmr(UVH_NMI_MMR_CLEAR, UV_NMI_PENDING_MASK); | ||
677 | } | ||
678 | spin_unlock(&uv_blade_info[bid].nmi_lock); | ||
679 | } | ||
680 | |||
681 | if (likely(__get_cpu_var(cpu_last_nmi_count) == uv_blade_info[bid].nmi_count)) | ||
682 | return NOTIFY_DONE; | ||
683 | |||
684 | __get_cpu_var(cpu_last_nmi_count) = uv_blade_info[bid].nmi_count; | ||
685 | |||
686 | /* | ||
687 | * Use a lock so only one cpu prints at a time. | ||
688 | * This prevents intermixed output. | ||
654 | */ | 689 | */ |
655 | spin_lock(&uv_nmi_lock); | 690 | spin_lock(&uv_nmi_lock); |
656 | pr_info("NMI stack dump cpu %u:\n", smp_processor_id()); | 691 | pr_info("UV NMI stack dump cpu %u:\n", smp_processor_id()); |
657 | dump_stack(); | 692 | dump_stack(); |
658 | spin_unlock(&uv_nmi_lock); | 693 | spin_unlock(&uv_nmi_lock); |
659 | 694 | ||
@@ -661,7 +696,8 @@ int uv_handle_nmi(struct notifier_block *self, unsigned long reason, void *data) | |||
661 | } | 696 | } |
662 | 697 | ||
663 | static struct notifier_block uv_dump_stack_nmi_nb = { | 698 | static struct notifier_block uv_dump_stack_nmi_nb = { |
664 | .notifier_call = uv_handle_nmi | 699 | .notifier_call = uv_handle_nmi, |
700 | .priority = NMI_LOCAL_LOW_PRIOR - 1, | ||
665 | }; | 701 | }; |
666 | 702 | ||
667 | void uv_register_nmi_notifier(void) | 703 | void uv_register_nmi_notifier(void) |
@@ -720,8 +756,9 @@ void __init uv_system_init(void) | |||
720 | printk(KERN_DEBUG "UV: Found %d blades\n", uv_num_possible_blades()); | 756 | printk(KERN_DEBUG "UV: Found %d blades\n", uv_num_possible_blades()); |
721 | 757 | ||
722 | bytes = sizeof(struct uv_blade_info) * uv_num_possible_blades(); | 758 | bytes = sizeof(struct uv_blade_info) * uv_num_possible_blades(); |
723 | uv_blade_info = kmalloc(bytes, GFP_KERNEL); | 759 | uv_blade_info = kzalloc(bytes, GFP_KERNEL); |
724 | BUG_ON(!uv_blade_info); | 760 | BUG_ON(!uv_blade_info); |
761 | |||
725 | for (blade = 0; blade < uv_num_possible_blades(); blade++) | 762 | for (blade = 0; blade < uv_num_possible_blades(); blade++) |
726 | uv_blade_info[blade].memory_nid = -1; | 763 | uv_blade_info[blade].memory_nid = -1; |
727 | 764 | ||
@@ -747,6 +784,7 @@ void __init uv_system_init(void) | |||
747 | uv_blade_info[blade].pnode = pnode; | 784 | uv_blade_info[blade].pnode = pnode; |
748 | uv_blade_info[blade].nr_possible_cpus = 0; | 785 | uv_blade_info[blade].nr_possible_cpus = 0; |
749 | uv_blade_info[blade].nr_online_cpus = 0; | 786 | uv_blade_info[blade].nr_online_cpus = 0; |
787 | spin_lock_init(&uv_blade_info[blade].nmi_lock); | ||
750 | max_pnode = max(pnode, max_pnode); | 788 | max_pnode = max(pnode, max_pnode); |
751 | blade++; | 789 | blade++; |
752 | } | 790 | } |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 3532d3bf810..6f9d1f6063e 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
@@ -613,7 +613,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c) | |||
613 | #endif | 613 | #endif |
614 | 614 | ||
615 | /* As a rule processors have APIC timer running in deep C states */ | 615 | /* As a rule processors have APIC timer running in deep C states */ |
616 | if (c->x86 >= 0xf && !cpu_has_amd_erratum(amd_erratum_400)) | 616 | if (c->x86 > 0xf && !cpu_has_amd_erratum(amd_erratum_400)) |
617 | set_cpu_cap(c, X86_FEATURE_ARAT); | 617 | set_cpu_cap(c, X86_FEATURE_ARAT); |
618 | 618 | ||
619 | /* | 619 | /* |
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 167f97b5596..bb0adad3514 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c | |||
@@ -509,6 +509,7 @@ recurse: | |||
509 | out_free: | 509 | out_free: |
510 | if (b) { | 510 | if (b) { |
511 | kobject_put(&b->kobj); | 511 | kobject_put(&b->kobj); |
512 | list_del(&b->miscj); | ||
512 | kfree(b); | 513 | kfree(b); |
513 | } | 514 | } |
514 | return err; | 515 | return err; |
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c index 6f8c5e9da97..0f034460260 100644 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c | |||
@@ -446,18 +446,20 @@ void intel_init_thermal(struct cpuinfo_x86 *c) | |||
446 | */ | 446 | */ |
447 | rdmsr(MSR_IA32_MISC_ENABLE, l, h); | 447 | rdmsr(MSR_IA32_MISC_ENABLE, l, h); |
448 | 448 | ||
449 | h = lvtthmr_init; | ||
449 | /* | 450 | /* |
450 | * The initial value of thermal LVT entries on all APs always reads | 451 | * The initial value of thermal LVT entries on all APs always reads |
451 | * 0x10000 because APs are woken up by BSP issuing INIT-SIPI-SIPI | 452 | * 0x10000 because APs are woken up by BSP issuing INIT-SIPI-SIPI |
452 | * sequence to them and LVT registers are reset to 0s except for | 453 | * sequence to them and LVT registers are reset to 0s except for |
453 | * the mask bits which are set to 1s when APs receive INIT IPI. | 454 | * the mask bits which are set to 1s when APs receive INIT IPI. |
454 | * Always restore the value that BIOS has programmed on AP based on | 455 | * If BIOS takes over the thermal interrupt and sets its interrupt |
455 | * BSP's info we saved since BIOS is always setting the same value | 456 | * delivery mode to SMI (not fixed), it restores the value that the |
456 | * for all threads/cores | 457 | * BIOS has programmed on AP based on BSP's info we saved since BIOS |
458 | * is always setting the same value for all threads/cores. | ||
457 | */ | 459 | */ |
458 | apic_write(APIC_LVTTHMR, lvtthmr_init); | 460 | if ((h & APIC_DM_FIXED_MASK) != APIC_DM_FIXED) |
461 | apic_write(APIC_LVTTHMR, lvtthmr_init); | ||
459 | 462 | ||
460 | h = lvtthmr_init; | ||
461 | 463 | ||
462 | if ((l & MSR_IA32_MISC_ENABLE_TM1) && (h & APIC_DM_SMI)) { | 464 | if ((l & MSR_IA32_MISC_ENABLE_TM1) && (h & APIC_DM_SMI)) { |
463 | printk(KERN_DEBUG | 465 | printk(KERN_DEBUG |
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c index e61539b07d2..447a28de6f0 100644 --- a/arch/x86/kernel/cpu/perf_event_intel.c +++ b/arch/x86/kernel/cpu/perf_event_intel.c | |||
@@ -184,26 +184,23 @@ static __initconst const u64 snb_hw_cache_event_ids | |||
184 | }, | 184 | }, |
185 | }, | 185 | }, |
186 | [ C(LL ) ] = { | 186 | [ C(LL ) ] = { |
187 | /* | ||
188 | * TBD: Need Off-core Response Performance Monitoring support | ||
189 | */ | ||
190 | [ C(OP_READ) ] = { | 187 | [ C(OP_READ) ] = { |
191 | /* OFFCORE_RESPONSE_0.ANY_DATA.LOCAL_CACHE */ | 188 | /* OFFCORE_RESPONSE.ANY_DATA.LOCAL_CACHE */ |
192 | [ C(RESULT_ACCESS) ] = 0x01b7, | 189 | [ C(RESULT_ACCESS) ] = 0x01b7, |
193 | /* OFFCORE_RESPONSE_1.ANY_DATA.ANY_LLC_MISS */ | 190 | /* OFFCORE_RESPONSE.ANY_DATA.ANY_LLC_MISS */ |
194 | [ C(RESULT_MISS) ] = 0x01bb, | 191 | [ C(RESULT_MISS) ] = 0x01b7, |
195 | }, | 192 | }, |
196 | [ C(OP_WRITE) ] = { | 193 | [ C(OP_WRITE) ] = { |
197 | /* OFFCORE_RESPONSE_0.ANY_RFO.LOCAL_CACHE */ | 194 | /* OFFCORE_RESPONSE.ANY_RFO.LOCAL_CACHE */ |
198 | [ C(RESULT_ACCESS) ] = 0x01b7, | 195 | [ C(RESULT_ACCESS) ] = 0x01b7, |
199 | /* OFFCORE_RESPONSE_1.ANY_RFO.ANY_LLC_MISS */ | 196 | /* OFFCORE_RESPONSE.ANY_RFO.ANY_LLC_MISS */ |
200 | [ C(RESULT_MISS) ] = 0x01bb, | 197 | [ C(RESULT_MISS) ] = 0x01b7, |
201 | }, | 198 | }, |
202 | [ C(OP_PREFETCH) ] = { | 199 | [ C(OP_PREFETCH) ] = { |
203 | /* OFFCORE_RESPONSE_0.PREFETCH.LOCAL_CACHE */ | 200 | /* OFFCORE_RESPONSE.PREFETCH.LOCAL_CACHE */ |
204 | [ C(RESULT_ACCESS) ] = 0x01b7, | 201 | [ C(RESULT_ACCESS) ] = 0x01b7, |
205 | /* OFFCORE_RESPONSE_1.PREFETCH.ANY_LLC_MISS */ | 202 | /* OFFCORE_RESPONSE.PREFETCH.ANY_LLC_MISS */ |
206 | [ C(RESULT_MISS) ] = 0x01bb, | 203 | [ C(RESULT_MISS) ] = 0x01b7, |
207 | }, | 204 | }, |
208 | }, | 205 | }, |
209 | [ C(DTLB) ] = { | 206 | [ C(DTLB) ] = { |
@@ -285,26 +282,26 @@ static __initconst const u64 westmere_hw_cache_event_ids | |||
285 | }, | 282 | }, |
286 | [ C(LL ) ] = { | 283 | [ C(LL ) ] = { |
287 | [ C(OP_READ) ] = { | 284 | [ C(OP_READ) ] = { |
288 | /* OFFCORE_RESPONSE_0.ANY_DATA.LOCAL_CACHE */ | 285 | /* OFFCORE_RESPONSE.ANY_DATA.LOCAL_CACHE */ |
289 | [ C(RESULT_ACCESS) ] = 0x01b7, | 286 | [ C(RESULT_ACCESS) ] = 0x01b7, |
290 | /* OFFCORE_RESPONSE_1.ANY_DATA.ANY_LLC_MISS */ | 287 | /* OFFCORE_RESPONSE.ANY_DATA.ANY_LLC_MISS */ |
291 | [ C(RESULT_MISS) ] = 0x01bb, | 288 | [ C(RESULT_MISS) ] = 0x01b7, |
292 | }, | 289 | }, |
293 | /* | 290 | /* |
294 | * Use RFO, not WRITEBACK, because a write miss would typically occur | 291 | * Use RFO, not WRITEBACK, because a write miss would typically occur |
295 | * on RFO. | 292 | * on RFO. |
296 | */ | 293 | */ |
297 | [ C(OP_WRITE) ] = { | 294 | [ C(OP_WRITE) ] = { |
298 | /* OFFCORE_RESPONSE_1.ANY_RFO.LOCAL_CACHE */ | 295 | /* OFFCORE_RESPONSE.ANY_RFO.LOCAL_CACHE */ |
299 | [ C(RESULT_ACCESS) ] = 0x01bb, | 296 | [ C(RESULT_ACCESS) ] = 0x01b7, |
300 | /* OFFCORE_RESPONSE_0.ANY_RFO.ANY_LLC_MISS */ | 297 | /* OFFCORE_RESPONSE.ANY_RFO.ANY_LLC_MISS */ |
301 | [ C(RESULT_MISS) ] = 0x01b7, | 298 | [ C(RESULT_MISS) ] = 0x01b7, |
302 | }, | 299 | }, |
303 | [ C(OP_PREFETCH) ] = { | 300 | [ C(OP_PREFETCH) ] = { |
304 | /* OFFCORE_RESPONSE_0.PREFETCH.LOCAL_CACHE */ | 301 | /* OFFCORE_RESPONSE.PREFETCH.LOCAL_CACHE */ |
305 | [ C(RESULT_ACCESS) ] = 0x01b7, | 302 | [ C(RESULT_ACCESS) ] = 0x01b7, |
306 | /* OFFCORE_RESPONSE_1.PREFETCH.ANY_LLC_MISS */ | 303 | /* OFFCORE_RESPONSE.PREFETCH.ANY_LLC_MISS */ |
307 | [ C(RESULT_MISS) ] = 0x01bb, | 304 | [ C(RESULT_MISS) ] = 0x01b7, |
308 | }, | 305 | }, |
309 | }, | 306 | }, |
310 | [ C(DTLB) ] = { | 307 | [ C(DTLB) ] = { |
@@ -352,16 +349,36 @@ static __initconst const u64 westmere_hw_cache_event_ids | |||
352 | }; | 349 | }; |
353 | 350 | ||
354 | /* | 351 | /* |
355 | * OFFCORE_RESPONSE MSR bits (subset), See IA32 SDM Vol 3 30.6.1.3 | 352 | * Nehalem/Westmere MSR_OFFCORE_RESPONSE bits; |
353 | * See IA32 SDM Vol 3B 30.6.1.3 | ||
356 | */ | 354 | */ |
357 | 355 | ||
358 | #define DMND_DATA_RD (1 << 0) | 356 | #define NHM_DMND_DATA_RD (1 << 0) |
359 | #define DMND_RFO (1 << 1) | 357 | #define NHM_DMND_RFO (1 << 1) |
360 | #define DMND_WB (1 << 3) | 358 | #define NHM_DMND_IFETCH (1 << 2) |
361 | #define PF_DATA_RD (1 << 4) | 359 | #define NHM_DMND_WB (1 << 3) |
362 | #define PF_DATA_RFO (1 << 5) | 360 | #define NHM_PF_DATA_RD (1 << 4) |
363 | #define RESP_UNCORE_HIT (1 << 8) | 361 | #define NHM_PF_DATA_RFO (1 << 5) |
364 | #define RESP_MISS (0xf600) /* non uncore hit */ | 362 | #define NHM_PF_IFETCH (1 << 6) |
363 | #define NHM_OFFCORE_OTHER (1 << 7) | ||
364 | #define NHM_UNCORE_HIT (1 << 8) | ||
365 | #define NHM_OTHER_CORE_HIT_SNP (1 << 9) | ||
366 | #define NHM_OTHER_CORE_HITM (1 << 10) | ||
367 | /* reserved */ | ||
368 | #define NHM_REMOTE_CACHE_FWD (1 << 12) | ||
369 | #define NHM_REMOTE_DRAM (1 << 13) | ||
370 | #define NHM_LOCAL_DRAM (1 << 14) | ||
371 | #define NHM_NON_DRAM (1 << 15) | ||
372 | |||
373 | #define NHM_ALL_DRAM (NHM_REMOTE_DRAM|NHM_LOCAL_DRAM) | ||
374 | |||
375 | #define NHM_DMND_READ (NHM_DMND_DATA_RD) | ||
376 | #define NHM_DMND_WRITE (NHM_DMND_RFO|NHM_DMND_WB) | ||
377 | #define NHM_DMND_PREFETCH (NHM_PF_DATA_RD|NHM_PF_DATA_RFO) | ||
378 | |||
379 | #define NHM_L3_HIT (NHM_UNCORE_HIT|NHM_OTHER_CORE_HIT_SNP|NHM_OTHER_CORE_HITM) | ||
380 | #define NHM_L3_MISS (NHM_NON_DRAM|NHM_ALL_DRAM|NHM_REMOTE_CACHE_FWD) | ||
381 | #define NHM_L3_ACCESS (NHM_L3_HIT|NHM_L3_MISS) | ||
365 | 382 | ||
366 | static __initconst const u64 nehalem_hw_cache_extra_regs | 383 | static __initconst const u64 nehalem_hw_cache_extra_regs |
367 | [PERF_COUNT_HW_CACHE_MAX] | 384 | [PERF_COUNT_HW_CACHE_MAX] |
@@ -370,16 +387,16 @@ static __initconst const u64 nehalem_hw_cache_extra_regs | |||
370 | { | 387 | { |
371 | [ C(LL ) ] = { | 388 | [ C(LL ) ] = { |
372 | [ C(OP_READ) ] = { | 389 | [ C(OP_READ) ] = { |
373 | [ C(RESULT_ACCESS) ] = DMND_DATA_RD|RESP_UNCORE_HIT, | 390 | [ C(RESULT_ACCESS) ] = NHM_DMND_READ|NHM_L3_ACCESS, |
374 | [ C(RESULT_MISS) ] = DMND_DATA_RD|RESP_MISS, | 391 | [ C(RESULT_MISS) ] = NHM_DMND_READ|NHM_L3_MISS, |
375 | }, | 392 | }, |
376 | [ C(OP_WRITE) ] = { | 393 | [ C(OP_WRITE) ] = { |
377 | [ C(RESULT_ACCESS) ] = DMND_RFO|DMND_WB|RESP_UNCORE_HIT, | 394 | [ C(RESULT_ACCESS) ] = NHM_DMND_WRITE|NHM_L3_ACCESS, |
378 | [ C(RESULT_MISS) ] = DMND_RFO|DMND_WB|RESP_MISS, | 395 | [ C(RESULT_MISS) ] = NHM_DMND_WRITE|NHM_L3_MISS, |
379 | }, | 396 | }, |
380 | [ C(OP_PREFETCH) ] = { | 397 | [ C(OP_PREFETCH) ] = { |
381 | [ C(RESULT_ACCESS) ] = PF_DATA_RD|PF_DATA_RFO|RESP_UNCORE_HIT, | 398 | [ C(RESULT_ACCESS) ] = NHM_DMND_PREFETCH|NHM_L3_ACCESS, |
382 | [ C(RESULT_MISS) ] = PF_DATA_RD|PF_DATA_RFO|RESP_MISS, | 399 | [ C(RESULT_MISS) ] = NHM_DMND_PREFETCH|NHM_L3_MISS, |
383 | }, | 400 | }, |
384 | } | 401 | } |
385 | }; | 402 | }; |
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c index c969fd9d156..f1a6244d7d9 100644 --- a/arch/x86/kernel/kprobes.c +++ b/arch/x86/kernel/kprobes.c | |||
@@ -1183,12 +1183,13 @@ static void __kprobes optimized_callback(struct optimized_kprobe *op, | |||
1183 | struct pt_regs *regs) | 1183 | struct pt_regs *regs) |
1184 | { | 1184 | { |
1185 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); | 1185 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); |
1186 | unsigned long flags; | ||
1186 | 1187 | ||
1187 | /* This is possible if op is under delayed unoptimizing */ | 1188 | /* This is possible if op is under delayed unoptimizing */ |
1188 | if (kprobe_disabled(&op->kp)) | 1189 | if (kprobe_disabled(&op->kp)) |
1189 | return; | 1190 | return; |
1190 | 1191 | ||
1191 | preempt_disable(); | 1192 | local_irq_save(flags); |
1192 | if (kprobe_running()) { | 1193 | if (kprobe_running()) { |
1193 | kprobes_inc_nmissed_count(&op->kp); | 1194 | kprobes_inc_nmissed_count(&op->kp); |
1194 | } else { | 1195 | } else { |
@@ -1207,7 +1208,7 @@ static void __kprobes optimized_callback(struct optimized_kprobe *op, | |||
1207 | opt_pre_handler(&op->kp, regs); | 1208 | opt_pre_handler(&op->kp, regs); |
1208 | __this_cpu_write(current_kprobe, NULL); | 1209 | __this_cpu_write(current_kprobe, NULL); |
1209 | } | 1210 | } |
1210 | preempt_enable_no_resched(); | 1211 | local_irq_restore(flags); |
1211 | } | 1212 | } |
1212 | 1213 | ||
1213 | static int __kprobes copy_optimized_instructions(u8 *dest, u8 *src) | 1214 | static int __kprobes copy_optimized_instructions(u8 *dest, u8 *src) |
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 45892dc4b72..f65e5b521db 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c | |||
@@ -608,6 +608,9 @@ static int ptrace_write_dr7(struct task_struct *tsk, unsigned long data) | |||
608 | unsigned len, type; | 608 | unsigned len, type; |
609 | struct perf_event *bp; | 609 | struct perf_event *bp; |
610 | 610 | ||
611 | if (ptrace_get_breakpoints(tsk) < 0) | ||
612 | return -ESRCH; | ||
613 | |||
611 | data &= ~DR_CONTROL_RESERVED; | 614 | data &= ~DR_CONTROL_RESERVED; |
612 | old_dr7 = ptrace_get_dr7(thread->ptrace_bps); | 615 | old_dr7 = ptrace_get_dr7(thread->ptrace_bps); |
613 | restore: | 616 | restore: |
@@ -655,6 +658,9 @@ restore: | |||
655 | } | 658 | } |
656 | goto restore; | 659 | goto restore; |
657 | } | 660 | } |
661 | |||
662 | ptrace_put_breakpoints(tsk); | ||
663 | |||
658 | return ((orig_ret < 0) ? orig_ret : rc); | 664 | return ((orig_ret < 0) ? orig_ret : rc); |
659 | } | 665 | } |
660 | 666 | ||
@@ -668,10 +674,17 @@ static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n) | |||
668 | 674 | ||
669 | if (n < HBP_NUM) { | 675 | if (n < HBP_NUM) { |
670 | struct perf_event *bp; | 676 | struct perf_event *bp; |
677 | |||
678 | if (ptrace_get_breakpoints(tsk) < 0) | ||
679 | return -ESRCH; | ||
680 | |||
671 | bp = thread->ptrace_bps[n]; | 681 | bp = thread->ptrace_bps[n]; |
672 | if (!bp) | 682 | if (!bp) |
673 | return 0; | 683 | val = 0; |
674 | val = bp->hw.info.address; | 684 | else |
685 | val = bp->hw.info.address; | ||
686 | |||
687 | ptrace_put_breakpoints(tsk); | ||
675 | } else if (n == 6) { | 688 | } else if (n == 6) { |
676 | val = thread->debugreg6; | 689 | val = thread->debugreg6; |
677 | } else if (n == 7) { | 690 | } else if (n == 7) { |
@@ -686,6 +699,10 @@ static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr, | |||
686 | struct perf_event *bp; | 699 | struct perf_event *bp; |
687 | struct thread_struct *t = &tsk->thread; | 700 | struct thread_struct *t = &tsk->thread; |
688 | struct perf_event_attr attr; | 701 | struct perf_event_attr attr; |
702 | int err = 0; | ||
703 | |||
704 | if (ptrace_get_breakpoints(tsk) < 0) | ||
705 | return -ESRCH; | ||
689 | 706 | ||
690 | if (!t->ptrace_bps[nr]) { | 707 | if (!t->ptrace_bps[nr]) { |
691 | ptrace_breakpoint_init(&attr); | 708 | ptrace_breakpoint_init(&attr); |
@@ -709,24 +726,23 @@ static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr, | |||
709 | * writing for the user. And anyway this is the previous | 726 | * writing for the user. And anyway this is the previous |
710 | * behaviour. | 727 | * behaviour. |
711 | */ | 728 | */ |
712 | if (IS_ERR(bp)) | 729 | if (IS_ERR(bp)) { |
713 | return PTR_ERR(bp); | 730 | err = PTR_ERR(bp); |
731 | goto put; | ||
732 | } | ||
714 | 733 | ||
715 | t->ptrace_bps[nr] = bp; | 734 | t->ptrace_bps[nr] = bp; |
716 | } else { | 735 | } else { |
717 | int err; | ||
718 | |||
719 | bp = t->ptrace_bps[nr]; | 736 | bp = t->ptrace_bps[nr]; |
720 | 737 | ||
721 | attr = bp->attr; | 738 | attr = bp->attr; |
722 | attr.bp_addr = addr; | 739 | attr.bp_addr = addr; |
723 | err = modify_user_hw_breakpoint(bp, &attr); | 740 | err = modify_user_hw_breakpoint(bp, &attr); |
724 | if (err) | ||
725 | return err; | ||
726 | } | 741 | } |
727 | 742 | ||
728 | 743 | put: | |
729 | return 0; | 744 | ptrace_put_breakpoints(tsk); |
745 | return err; | ||
730 | } | 746 | } |
731 | 747 | ||
732 | /* | 748 | /* |
diff --git a/arch/x86/kernel/reboot_32.S b/arch/x86/kernel/reboot_32.S index 29092b38d81..1d5c46df0d7 100644 --- a/arch/x86/kernel/reboot_32.S +++ b/arch/x86/kernel/reboot_32.S | |||
@@ -21,26 +21,26 @@ r_base = . | |||
21 | /* Get our own relocated address */ | 21 | /* Get our own relocated address */ |
22 | call 1f | 22 | call 1f |
23 | 1: popl %ebx | 23 | 1: popl %ebx |
24 | subl $1b, %ebx | 24 | subl $(1b - r_base), %ebx |
25 | 25 | ||
26 | /* Compute the equivalent real-mode segment */ | 26 | /* Compute the equivalent real-mode segment */ |
27 | movl %ebx, %ecx | 27 | movl %ebx, %ecx |
28 | shrl $4, %ecx | 28 | shrl $4, %ecx |
29 | 29 | ||
30 | /* Patch post-real-mode segment jump */ | 30 | /* Patch post-real-mode segment jump */ |
31 | movw dispatch_table(%ebx,%eax,2),%ax | 31 | movw (dispatch_table - r_base)(%ebx,%eax,2),%ax |
32 | movw %ax, 101f(%ebx) | 32 | movw %ax, (101f - r_base)(%ebx) |
33 | movw %cx, 102f(%ebx) | 33 | movw %cx, (102f - r_base)(%ebx) |
34 | 34 | ||
35 | /* Set up the IDT for real mode. */ | 35 | /* Set up the IDT for real mode. */ |
36 | lidtl machine_real_restart_idt(%ebx) | 36 | lidtl (machine_real_restart_idt - r_base)(%ebx) |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Set up a GDT from which we can load segment descriptors for real | 39 | * Set up a GDT from which we can load segment descriptors for real |
40 | * mode. The GDT is not used in real mode; it is just needed here to | 40 | * mode. The GDT is not used in real mode; it is just needed here to |
41 | * prepare the descriptors. | 41 | * prepare the descriptors. |
42 | */ | 42 | */ |
43 | lgdtl machine_real_restart_gdt(%ebx) | 43 | lgdtl (machine_real_restart_gdt - r_base)(%ebx) |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * Load the data segment registers with 16-bit compatible values | 46 | * Load the data segment registers with 16-bit compatible values |
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index c11514e9128..75ef4b18e9b 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c | |||
@@ -61,6 +61,10 @@ struct x86_init_ops x86_init __initdata = { | |||
61 | .banner = default_banner, | 61 | .banner = default_banner, |
62 | }, | 62 | }, |
63 | 63 | ||
64 | .mapping = { | ||
65 | .pagetable_reserve = native_pagetable_reserve, | ||
66 | }, | ||
67 | |||
64 | .paging = { | 68 | .paging = { |
65 | .pagetable_setup_start = native_pagetable_setup_start, | 69 | .pagetable_setup_start = native_pagetable_setup_start, |
66 | .pagetable_setup_done = native_pagetable_setup_done, | 70 | .pagetable_setup_done = native_pagetable_setup_done, |
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 286d289b039..37b8b0fe832 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
@@ -81,6 +81,11 @@ static void __init find_early_table_space(unsigned long end, int use_pse, | |||
81 | end, pgt_buf_start << PAGE_SHIFT, pgt_buf_top << PAGE_SHIFT); | 81 | end, pgt_buf_start << PAGE_SHIFT, pgt_buf_top << PAGE_SHIFT); |
82 | } | 82 | } |
83 | 83 | ||
84 | void __init native_pagetable_reserve(u64 start, u64 end) | ||
85 | { | ||
86 | memblock_x86_reserve_range(start, end, "PGTABLE"); | ||
87 | } | ||
88 | |||
84 | struct map_range { | 89 | struct map_range { |
85 | unsigned long start; | 90 | unsigned long start; |
86 | unsigned long end; | 91 | unsigned long end; |
@@ -272,9 +277,24 @@ unsigned long __init_refok init_memory_mapping(unsigned long start, | |||
272 | 277 | ||
273 | __flush_tlb_all(); | 278 | __flush_tlb_all(); |
274 | 279 | ||
280 | /* | ||
281 | * Reserve the kernel pagetable pages we used (pgt_buf_start - | ||
282 | * pgt_buf_end) and free the other ones (pgt_buf_end - pgt_buf_top) | ||
283 | * so that they can be reused for other purposes. | ||
284 | * | ||
285 | * On native it just means calling memblock_x86_reserve_range, on Xen it | ||
286 | * also means marking RW the pagetable pages that we allocated before | ||
287 | * but that haven't been used. | ||
288 | * | ||
289 | * In fact on xen we mark RO the whole range pgt_buf_start - | ||
290 | * pgt_buf_top, because we have to make sure that when | ||
291 | * init_memory_mapping reaches the pagetable pages area, it maps | ||
292 | * RO all the pagetable pages, including the ones that are beyond | ||
293 | * pgt_buf_end at that time. | ||
294 | */ | ||
275 | if (!after_bootmem && pgt_buf_end > pgt_buf_start) | 295 | if (!after_bootmem && pgt_buf_end > pgt_buf_start) |
276 | memblock_x86_reserve_range(pgt_buf_start << PAGE_SHIFT, | 296 | x86_init.mapping.pagetable_reserve(PFN_PHYS(pgt_buf_start), |
277 | pgt_buf_end << PAGE_SHIFT, "PGTABLE"); | 297 | PFN_PHYS(pgt_buf_end)); |
278 | 298 | ||
279 | if (!after_bootmem) | 299 | if (!after_bootmem) |
280 | early_memtest(start, end); | 300 | early_memtest(start, end); |
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c index e8c00cc7203..85b52fc0308 100644 --- a/arch/x86/mm/numa_64.c +++ b/arch/x86/mm/numa_64.c | |||
@@ -306,7 +306,7 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi) | |||
306 | bi->end = min(bi->end, high); | 306 | bi->end = min(bi->end, high); |
307 | 307 | ||
308 | /* and there's no empty block */ | 308 | /* and there's no empty block */ |
309 | if (bi->start == bi->end) { | 309 | if (bi->start >= bi->end) { |
310 | numa_remove_memblk_from(i--, mi); | 310 | numa_remove_memblk_from(i--, mi); |
311 | continue; | 311 | continue; |
312 | } | 312 | } |
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c index 7cb6424317f..c58e0ea39ef 100644 --- a/arch/x86/platform/uv/tlb_uv.c +++ b/arch/x86/platform/uv/tlb_uv.c | |||
@@ -699,16 +699,17 @@ const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, | |||
699 | struct mm_struct *mm, | 699 | struct mm_struct *mm, |
700 | unsigned long va, unsigned int cpu) | 700 | unsigned long va, unsigned int cpu) |
701 | { | 701 | { |
702 | int tcpu; | ||
703 | int uvhub; | ||
704 | int locals = 0; | 702 | int locals = 0; |
705 | int remotes = 0; | 703 | int remotes = 0; |
706 | int hubs = 0; | 704 | int hubs = 0; |
705 | int tcpu; | ||
706 | int tpnode; | ||
707 | struct bau_desc *bau_desc; | 707 | struct bau_desc *bau_desc; |
708 | struct cpumask *flush_mask; | 708 | struct cpumask *flush_mask; |
709 | struct ptc_stats *stat; | 709 | struct ptc_stats *stat; |
710 | struct bau_control *bcp; | 710 | struct bau_control *bcp; |
711 | struct bau_control *tbcp; | 711 | struct bau_control *tbcp; |
712 | struct hub_and_pnode *hpp; | ||
712 | 713 | ||
713 | /* kernel was booted 'nobau' */ | 714 | /* kernel was booted 'nobau' */ |
714 | if (nobau) | 715 | if (nobau) |
@@ -750,11 +751,18 @@ const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, | |||
750 | bau_desc += UV_ITEMS_PER_DESCRIPTOR * bcp->uvhub_cpu; | 751 | bau_desc += UV_ITEMS_PER_DESCRIPTOR * bcp->uvhub_cpu; |
751 | bau_uvhubs_clear(&bau_desc->distribution, UV_DISTRIBUTION_SIZE); | 752 | bau_uvhubs_clear(&bau_desc->distribution, UV_DISTRIBUTION_SIZE); |
752 | 753 | ||
753 | /* cpu statistics */ | ||
754 | for_each_cpu(tcpu, flush_mask) { | 754 | for_each_cpu(tcpu, flush_mask) { |
755 | uvhub = uv_cpu_to_blade_id(tcpu); | 755 | /* |
756 | bau_uvhub_set(uvhub, &bau_desc->distribution); | 756 | * The distribution vector is a bit map of pnodes, relative |
757 | if (uvhub == bcp->uvhub) | 757 | * to the partition base pnode (and the partition base nasid |
758 | * in the header). | ||
759 | * Translate cpu to pnode and hub using an array stored | ||
760 | * in local memory. | ||
761 | */ | ||
762 | hpp = &bcp->socket_master->target_hub_and_pnode[tcpu]; | ||
763 | tpnode = hpp->pnode - bcp->partition_base_pnode; | ||
764 | bau_uvhub_set(tpnode, &bau_desc->distribution); | ||
765 | if (hpp->uvhub == bcp->uvhub) | ||
758 | locals++; | 766 | locals++; |
759 | else | 767 | else |
760 | remotes++; | 768 | remotes++; |
@@ -855,7 +863,7 @@ void uv_bau_message_interrupt(struct pt_regs *regs) | |||
855 | * an interrupt, but causes an error message to be returned to | 863 | * an interrupt, but causes an error message to be returned to |
856 | * the sender. | 864 | * the sender. |
857 | */ | 865 | */ |
858 | static void uv_enable_timeouts(void) | 866 | static void __init uv_enable_timeouts(void) |
859 | { | 867 | { |
860 | int uvhub; | 868 | int uvhub; |
861 | int nuvhubs; | 869 | int nuvhubs; |
@@ -1326,10 +1334,10 @@ static int __init uv_ptc_init(void) | |||
1326 | } | 1334 | } |
1327 | 1335 | ||
1328 | /* | 1336 | /* |
1329 | * initialize the sending side's sending buffers | 1337 | * Initialize the sending side's sending buffers. |
1330 | */ | 1338 | */ |
1331 | static void | 1339 | static void |
1332 | uv_activation_descriptor_init(int node, int pnode) | 1340 | uv_activation_descriptor_init(int node, int pnode, int base_pnode) |
1333 | { | 1341 | { |
1334 | int i; | 1342 | int i; |
1335 | int cpu; | 1343 | int cpu; |
@@ -1352,11 +1360,11 @@ uv_activation_descriptor_init(int node, int pnode) | |||
1352 | n = pa >> uv_nshift; | 1360 | n = pa >> uv_nshift; |
1353 | m = pa & uv_mmask; | 1361 | m = pa & uv_mmask; |
1354 | 1362 | ||
1363 | /* the 14-bit pnode */ | ||
1355 | uv_write_global_mmr64(pnode, UVH_LB_BAU_SB_DESCRIPTOR_BASE, | 1364 | uv_write_global_mmr64(pnode, UVH_LB_BAU_SB_DESCRIPTOR_BASE, |
1356 | (n << UV_DESC_BASE_PNODE_SHIFT | m)); | 1365 | (n << UV_DESC_BASE_PNODE_SHIFT | m)); |
1357 | |||
1358 | /* | 1366 | /* |
1359 | * initializing all 8 (UV_ITEMS_PER_DESCRIPTOR) descriptors for each | 1367 | * Initializing all 8 (UV_ITEMS_PER_DESCRIPTOR) descriptors for each |
1360 | * cpu even though we only use the first one; one descriptor can | 1368 | * cpu even though we only use the first one; one descriptor can |
1361 | * describe a broadcast to 256 uv hubs. | 1369 | * describe a broadcast to 256 uv hubs. |
1362 | */ | 1370 | */ |
@@ -1365,12 +1373,13 @@ uv_activation_descriptor_init(int node, int pnode) | |||
1365 | memset(bd2, 0, sizeof(struct bau_desc)); | 1373 | memset(bd2, 0, sizeof(struct bau_desc)); |
1366 | bd2->header.sw_ack_flag = 1; | 1374 | bd2->header.sw_ack_flag = 1; |
1367 | /* | 1375 | /* |
1368 | * base_dest_nodeid is the nasid of the first uvhub | 1376 | * The base_dest_nasid set in the message header is the nasid |
1369 | * in the partition. The bit map will indicate uvhub numbers, | 1377 | * of the first uvhub in the partition. The bit map will |
1370 | * which are 0-N in a partition. Pnodes are unique system-wide. | 1378 | * indicate destination pnode numbers relative to that base. |
1379 | * They may not be consecutive if nasid striding is being used. | ||
1371 | */ | 1380 | */ |
1372 | bd2->header.base_dest_nodeid = UV_PNODE_TO_NASID(uv_partition_base_pnode); | 1381 | bd2->header.base_dest_nasid = UV_PNODE_TO_NASID(base_pnode); |
1373 | bd2->header.dest_subnodeid = 0x10; /* the LB */ | 1382 | bd2->header.dest_subnodeid = UV_LB_SUBNODEID; |
1374 | bd2->header.command = UV_NET_ENDPOINT_INTD; | 1383 | bd2->header.command = UV_NET_ENDPOINT_INTD; |
1375 | bd2->header.int_both = 1; | 1384 | bd2->header.int_both = 1; |
1376 | /* | 1385 | /* |
@@ -1442,7 +1451,7 @@ uv_payload_queue_init(int node, int pnode) | |||
1442 | /* | 1451 | /* |
1443 | * Initialization of each UV hub's structures | 1452 | * Initialization of each UV hub's structures |
1444 | */ | 1453 | */ |
1445 | static void __init uv_init_uvhub(int uvhub, int vector) | 1454 | static void __init uv_init_uvhub(int uvhub, int vector, int base_pnode) |
1446 | { | 1455 | { |
1447 | int node; | 1456 | int node; |
1448 | int pnode; | 1457 | int pnode; |
@@ -1450,11 +1459,11 @@ static void __init uv_init_uvhub(int uvhub, int vector) | |||
1450 | 1459 | ||
1451 | node = uvhub_to_first_node(uvhub); | 1460 | node = uvhub_to_first_node(uvhub); |
1452 | pnode = uv_blade_to_pnode(uvhub); | 1461 | pnode = uv_blade_to_pnode(uvhub); |
1453 | uv_activation_descriptor_init(node, pnode); | 1462 | uv_activation_descriptor_init(node, pnode, base_pnode); |
1454 | uv_payload_queue_init(node, pnode); | 1463 | uv_payload_queue_init(node, pnode); |
1455 | /* | 1464 | /* |
1456 | * the below initialization can't be in firmware because the | 1465 | * The below initialization can't be in firmware because the |
1457 | * messaging IRQ will be determined by the OS | 1466 | * messaging IRQ will be determined by the OS. |
1458 | */ | 1467 | */ |
1459 | apicid = uvhub_to_first_apicid(uvhub) | uv_apicid_hibits; | 1468 | apicid = uvhub_to_first_apicid(uvhub) | uv_apicid_hibits; |
1460 | uv_write_global_mmr64(pnode, UVH_BAU_DATA_CONFIG, | 1469 | uv_write_global_mmr64(pnode, UVH_BAU_DATA_CONFIG, |
@@ -1491,10 +1500,11 @@ calculate_destination_timeout(void) | |||
1491 | /* | 1500 | /* |
1492 | * initialize the bau_control structure for each cpu | 1501 | * initialize the bau_control structure for each cpu |
1493 | */ | 1502 | */ |
1494 | static int __init uv_init_per_cpu(int nuvhubs) | 1503 | static int __init uv_init_per_cpu(int nuvhubs, int base_part_pnode) |
1495 | { | 1504 | { |
1496 | int i; | 1505 | int i; |
1497 | int cpu; | 1506 | int cpu; |
1507 | int tcpu; | ||
1498 | int pnode; | 1508 | int pnode; |
1499 | int uvhub; | 1509 | int uvhub; |
1500 | int have_hmaster; | 1510 | int have_hmaster; |
@@ -1528,6 +1538,15 @@ static int __init uv_init_per_cpu(int nuvhubs) | |||
1528 | bcp = &per_cpu(bau_control, cpu); | 1538 | bcp = &per_cpu(bau_control, cpu); |
1529 | memset(bcp, 0, sizeof(struct bau_control)); | 1539 | memset(bcp, 0, sizeof(struct bau_control)); |
1530 | pnode = uv_cpu_hub_info(cpu)->pnode; | 1540 | pnode = uv_cpu_hub_info(cpu)->pnode; |
1541 | if ((pnode - base_part_pnode) >= UV_DISTRIBUTION_SIZE) { | ||
1542 | printk(KERN_EMERG | ||
1543 | "cpu %d pnode %d-%d beyond %d; BAU disabled\n", | ||
1544 | cpu, pnode, base_part_pnode, | ||
1545 | UV_DISTRIBUTION_SIZE); | ||
1546 | return 1; | ||
1547 | } | ||
1548 | bcp->osnode = cpu_to_node(cpu); | ||
1549 | bcp->partition_base_pnode = uv_partition_base_pnode; | ||
1531 | uvhub = uv_cpu_hub_info(cpu)->numa_blade_id; | 1550 | uvhub = uv_cpu_hub_info(cpu)->numa_blade_id; |
1532 | *(uvhub_mask + (uvhub/8)) |= (1 << (uvhub%8)); | 1551 | *(uvhub_mask + (uvhub/8)) |= (1 << (uvhub%8)); |
1533 | bdp = &uvhub_descs[uvhub]; | 1552 | bdp = &uvhub_descs[uvhub]; |
@@ -1536,7 +1555,7 @@ static int __init uv_init_per_cpu(int nuvhubs) | |||
1536 | bdp->pnode = pnode; | 1555 | bdp->pnode = pnode; |
1537 | /* kludge: 'assuming' one node per socket, and assuming that | 1556 | /* kludge: 'assuming' one node per socket, and assuming that |
1538 | disabling a socket just leaves a gap in node numbers */ | 1557 | disabling a socket just leaves a gap in node numbers */ |
1539 | socket = (cpu_to_node(cpu) & 1); | 1558 | socket = bcp->osnode & 1; |
1540 | bdp->socket_mask |= (1 << socket); | 1559 | bdp->socket_mask |= (1 << socket); |
1541 | sdp = &bdp->socket[socket]; | 1560 | sdp = &bdp->socket[socket]; |
1542 | sdp->cpu_number[sdp->num_cpus] = cpu; | 1561 | sdp->cpu_number[sdp->num_cpus] = cpu; |
@@ -1585,6 +1604,20 @@ static int __init uv_init_per_cpu(int nuvhubs) | |||
1585 | nextsocket: | 1604 | nextsocket: |
1586 | socket++; | 1605 | socket++; |
1587 | socket_mask = (socket_mask >> 1); | 1606 | socket_mask = (socket_mask >> 1); |
1607 | /* each socket gets a local array of pnodes/hubs */ | ||
1608 | bcp = smaster; | ||
1609 | bcp->target_hub_and_pnode = kmalloc_node( | ||
1610 | sizeof(struct hub_and_pnode) * | ||
1611 | num_possible_cpus(), GFP_KERNEL, bcp->osnode); | ||
1612 | memset(bcp->target_hub_and_pnode, 0, | ||
1613 | sizeof(struct hub_and_pnode) * | ||
1614 | num_possible_cpus()); | ||
1615 | for_each_present_cpu(tcpu) { | ||
1616 | bcp->target_hub_and_pnode[tcpu].pnode = | ||
1617 | uv_cpu_hub_info(tcpu)->pnode; | ||
1618 | bcp->target_hub_and_pnode[tcpu].uvhub = | ||
1619 | uv_cpu_hub_info(tcpu)->numa_blade_id; | ||
1620 | } | ||
1588 | } | 1621 | } |
1589 | } | 1622 | } |
1590 | kfree(uvhub_descs); | 1623 | kfree(uvhub_descs); |
@@ -1637,21 +1670,22 @@ static int __init uv_bau_init(void) | |||
1637 | spin_lock_init(&disable_lock); | 1670 | spin_lock_init(&disable_lock); |
1638 | congested_cycles = microsec_2_cycles(congested_response_us); | 1671 | congested_cycles = microsec_2_cycles(congested_response_us); |
1639 | 1672 | ||
1640 | if (uv_init_per_cpu(nuvhubs)) { | ||
1641 | nobau = 1; | ||
1642 | return 0; | ||
1643 | } | ||
1644 | |||
1645 | uv_partition_base_pnode = 0x7fffffff; | 1673 | uv_partition_base_pnode = 0x7fffffff; |
1646 | for (uvhub = 0; uvhub < nuvhubs; uvhub++) | 1674 | for (uvhub = 0; uvhub < nuvhubs; uvhub++) { |
1647 | if (uv_blade_nr_possible_cpus(uvhub) && | 1675 | if (uv_blade_nr_possible_cpus(uvhub) && |
1648 | (uv_blade_to_pnode(uvhub) < uv_partition_base_pnode)) | 1676 | (uv_blade_to_pnode(uvhub) < uv_partition_base_pnode)) |
1649 | uv_partition_base_pnode = uv_blade_to_pnode(uvhub); | 1677 | uv_partition_base_pnode = uv_blade_to_pnode(uvhub); |
1678 | } | ||
1679 | |||
1680 | if (uv_init_per_cpu(nuvhubs, uv_partition_base_pnode)) { | ||
1681 | nobau = 1; | ||
1682 | return 0; | ||
1683 | } | ||
1650 | 1684 | ||
1651 | vector = UV_BAU_MESSAGE; | 1685 | vector = UV_BAU_MESSAGE; |
1652 | for_each_possible_blade(uvhub) | 1686 | for_each_possible_blade(uvhub) |
1653 | if (uv_blade_nr_possible_cpus(uvhub)) | 1687 | if (uv_blade_nr_possible_cpus(uvhub)) |
1654 | uv_init_uvhub(uvhub, vector); | 1688 | uv_init_uvhub(uvhub, vector, uv_partition_base_pnode); |
1655 | 1689 | ||
1656 | uv_enable_timeouts(); | 1690 | uv_enable_timeouts(); |
1657 | alloc_intr_gate(vector, uv_bau_message_intr1); | 1691 | alloc_intr_gate(vector, uv_bau_message_intr1); |
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index aef7af92b28..0684f3c74d5 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -1275,6 +1275,20 @@ static __init void xen_pagetable_setup_start(pgd_t *base) | |||
1275 | { | 1275 | { |
1276 | } | 1276 | } |
1277 | 1277 | ||
1278 | static __init void xen_mapping_pagetable_reserve(u64 start, u64 end) | ||
1279 | { | ||
1280 | /* reserve the range used */ | ||
1281 | native_pagetable_reserve(start, end); | ||
1282 | |||
1283 | /* set as RW the rest */ | ||
1284 | printk(KERN_DEBUG "xen: setting RW the range %llx - %llx\n", end, | ||
1285 | PFN_PHYS(pgt_buf_top)); | ||
1286 | while (end < PFN_PHYS(pgt_buf_top)) { | ||
1287 | make_lowmem_page_readwrite(__va(end)); | ||
1288 | end += PAGE_SIZE; | ||
1289 | } | ||
1290 | } | ||
1291 | |||
1278 | static void xen_post_allocator_init(void); | 1292 | static void xen_post_allocator_init(void); |
1279 | 1293 | ||
1280 | static __init void xen_pagetable_setup_done(pgd_t *base) | 1294 | static __init void xen_pagetable_setup_done(pgd_t *base) |
@@ -1495,7 +1509,7 @@ static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte) | |||
1495 | * it is RO. | 1509 | * it is RO. |
1496 | */ | 1510 | */ |
1497 | if (((!is_early_ioremap_ptep(ptep) && | 1511 | if (((!is_early_ioremap_ptep(ptep) && |
1498 | pfn >= pgt_buf_start && pfn < pgt_buf_end)) || | 1512 | pfn >= pgt_buf_start && pfn < pgt_buf_top)) || |
1499 | (is_early_ioremap_ptep(ptep) && pfn != (pgt_buf_end - 1))) | 1513 | (is_early_ioremap_ptep(ptep) && pfn != (pgt_buf_end - 1))) |
1500 | pte = pte_wrprotect(pte); | 1514 | pte = pte_wrprotect(pte); |
1501 | 1515 | ||
@@ -2105,6 +2119,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = { | |||
2105 | 2119 | ||
2106 | void __init xen_init_mmu_ops(void) | 2120 | void __init xen_init_mmu_ops(void) |
2107 | { | 2121 | { |
2122 | x86_init.mapping.pagetable_reserve = xen_mapping_pagetable_reserve; | ||
2108 | x86_init.paging.pagetable_setup_start = xen_pagetable_setup_start; | 2123 | x86_init.paging.pagetable_setup_start = xen_pagetable_setup_start; |
2109 | x86_init.paging.pagetable_setup_done = xen_pagetable_setup_done; | 2124 | x86_init.paging.pagetable_setup_done = xen_pagetable_setup_done; |
2110 | pv_mmu_ops = xen_mmu_ops; | 2125 | pv_mmu_ops = xen_mmu_ops; |
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index f0605ab2a76..471fdcc5df8 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -114,6 +114,13 @@ struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup) | |||
114 | } | 114 | } |
115 | EXPORT_SYMBOL_GPL(cgroup_to_blkio_cgroup); | 115 | EXPORT_SYMBOL_GPL(cgroup_to_blkio_cgroup); |
116 | 116 | ||
117 | struct blkio_cgroup *task_blkio_cgroup(struct task_struct *tsk) | ||
118 | { | ||
119 | return container_of(task_subsys_state(tsk, blkio_subsys_id), | ||
120 | struct blkio_cgroup, css); | ||
121 | } | ||
122 | EXPORT_SYMBOL_GPL(task_blkio_cgroup); | ||
123 | |||
117 | static inline void | 124 | static inline void |
118 | blkio_update_group_weight(struct blkio_group *blkg, unsigned int weight) | 125 | blkio_update_group_weight(struct blkio_group *blkg, unsigned int weight) |
119 | { | 126 | { |
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index 10919fae2d3..c774930cc20 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h | |||
@@ -291,6 +291,7 @@ static inline void blkiocg_set_start_empty_time(struct blkio_group *blkg) {} | |||
291 | #if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE) | 291 | #if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE) |
292 | extern struct blkio_cgroup blkio_root_cgroup; | 292 | extern struct blkio_cgroup blkio_root_cgroup; |
293 | extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); | 293 | extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); |
294 | extern struct blkio_cgroup *task_blkio_cgroup(struct task_struct *tsk); | ||
294 | extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | 295 | extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, |
295 | struct blkio_group *blkg, void *key, dev_t dev, | 296 | struct blkio_group *blkg, void *key, dev_t dev, |
296 | enum blkio_policy_id plid); | 297 | enum blkio_policy_id plid); |
@@ -314,6 +315,8 @@ void blkiocg_update_io_remove_stats(struct blkio_group *blkg, | |||
314 | struct cgroup; | 315 | struct cgroup; |
315 | static inline struct blkio_cgroup * | 316 | static inline struct blkio_cgroup * |
316 | cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } | 317 | cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } |
318 | static inline struct blkio_cgroup * | ||
319 | task_blkio_cgroup(struct task_struct *tsk) { return NULL; } | ||
317 | 320 | ||
318 | static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | 321 | static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, |
319 | struct blkio_group *blkg, void *key, dev_t dev, | 322 | struct blkio_group *blkg, void *key, dev_t dev, |
diff --git a/block/blk-core.c b/block/blk-core.c index a2e58eeb354..3fe00a14822 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -316,8 +316,10 @@ EXPORT_SYMBOL(__blk_run_queue); | |||
316 | */ | 316 | */ |
317 | void blk_run_queue_async(struct request_queue *q) | 317 | void blk_run_queue_async(struct request_queue *q) |
318 | { | 318 | { |
319 | if (likely(!blk_queue_stopped(q))) | 319 | if (likely(!blk_queue_stopped(q))) { |
320 | __cancel_delayed_work(&q->delay_work); | ||
320 | queue_delayed_work(kblockd_workqueue, &q->delay_work, 0); | 321 | queue_delayed_work(kblockd_workqueue, &q->delay_work, 0); |
322 | } | ||
321 | } | 323 | } |
322 | EXPORT_SYMBOL(blk_run_queue_async); | 324 | EXPORT_SYMBOL(blk_run_queue_async); |
323 | 325 | ||
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 0475a22a420..252a81a306f 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c | |||
@@ -160,9 +160,8 @@ static void throtl_put_tg(struct throtl_grp *tg) | |||
160 | } | 160 | } |
161 | 161 | ||
162 | static struct throtl_grp * throtl_find_alloc_tg(struct throtl_data *td, | 162 | static struct throtl_grp * throtl_find_alloc_tg(struct throtl_data *td, |
163 | struct cgroup *cgroup) | 163 | struct blkio_cgroup *blkcg) |
164 | { | 164 | { |
165 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgroup); | ||
166 | struct throtl_grp *tg = NULL; | 165 | struct throtl_grp *tg = NULL; |
167 | void *key = td; | 166 | void *key = td; |
168 | struct backing_dev_info *bdi = &td->queue->backing_dev_info; | 167 | struct backing_dev_info *bdi = &td->queue->backing_dev_info; |
@@ -229,12 +228,12 @@ done: | |||
229 | 228 | ||
230 | static struct throtl_grp * throtl_get_tg(struct throtl_data *td) | 229 | static struct throtl_grp * throtl_get_tg(struct throtl_data *td) |
231 | { | 230 | { |
232 | struct cgroup *cgroup; | ||
233 | struct throtl_grp *tg = NULL; | 231 | struct throtl_grp *tg = NULL; |
232 | struct blkio_cgroup *blkcg; | ||
234 | 233 | ||
235 | rcu_read_lock(); | 234 | rcu_read_lock(); |
236 | cgroup = task_cgroup(current, blkio_subsys_id); | 235 | blkcg = task_blkio_cgroup(current); |
237 | tg = throtl_find_alloc_tg(td, cgroup); | 236 | tg = throtl_find_alloc_tg(td, blkcg); |
238 | if (!tg) | 237 | if (!tg) |
239 | tg = &td->root_tg; | 238 | tg = &td->root_tg; |
240 | rcu_read_unlock(); | 239 | rcu_read_unlock(); |
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 5b52011e3a4..ab7a9e6a9b1 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c | |||
@@ -1014,10 +1014,9 @@ void cfq_update_blkio_group_weight(void *key, struct blkio_group *blkg, | |||
1014 | cfqg->needs_update = true; | 1014 | cfqg->needs_update = true; |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | static struct cfq_group * | 1017 | static struct cfq_group * cfq_find_alloc_cfqg(struct cfq_data *cfqd, |
1018 | cfq_find_alloc_cfqg(struct cfq_data *cfqd, struct cgroup *cgroup, int create) | 1018 | struct blkio_cgroup *blkcg, int create) |
1019 | { | 1019 | { |
1020 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgroup); | ||
1021 | struct cfq_group *cfqg = NULL; | 1020 | struct cfq_group *cfqg = NULL; |
1022 | void *key = cfqd; | 1021 | void *key = cfqd; |
1023 | int i, j; | 1022 | int i, j; |
@@ -1079,12 +1078,12 @@ done: | |||
1079 | */ | 1078 | */ |
1080 | static struct cfq_group *cfq_get_cfqg(struct cfq_data *cfqd, int create) | 1079 | static struct cfq_group *cfq_get_cfqg(struct cfq_data *cfqd, int create) |
1081 | { | 1080 | { |
1082 | struct cgroup *cgroup; | 1081 | struct blkio_cgroup *blkcg; |
1083 | struct cfq_group *cfqg = NULL; | 1082 | struct cfq_group *cfqg = NULL; |
1084 | 1083 | ||
1085 | rcu_read_lock(); | 1084 | rcu_read_lock(); |
1086 | cgroup = task_cgroup(current, blkio_subsys_id); | 1085 | blkcg = task_blkio_cgroup(current); |
1087 | cfqg = cfq_find_alloc_cfqg(cfqd, cgroup, create); | 1086 | cfqg = cfq_find_alloc_cfqg(cfqd, blkcg, create); |
1088 | if (!cfqg && create) | 1087 | if (!cfqg && create) |
1089 | cfqg = &cfqd->root_group; | 1088 | cfqg = &cfqd->root_group; |
1090 | rcu_read_unlock(); | 1089 | rcu_read_unlock(); |
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index ff9d832a163..d38c40fe4dd 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c | |||
@@ -561,27 +561,6 @@ void ahci_start_engine(struct ata_port *ap) | |||
561 | { | 561 | { |
562 | void __iomem *port_mmio = ahci_port_base(ap); | 562 | void __iomem *port_mmio = ahci_port_base(ap); |
563 | u32 tmp; | 563 | u32 tmp; |
564 | u8 status; | ||
565 | |||
566 | status = readl(port_mmio + PORT_TFDATA) & 0xFF; | ||
567 | |||
568 | /* | ||
569 | * At end of section 10.1 of AHCI spec (rev 1.3), it states | ||
570 | * Software shall not set PxCMD.ST to 1 until it is determined | ||
571 | * that a functoinal device is present on the port as determined by | ||
572 | * PxTFD.STS.BSY=0, PxTFD.STS.DRQ=0 and PxSSTS.DET=3h | ||
573 | * | ||
574 | * Even though most AHCI host controllers work without this check, | ||
575 | * specific controller will fail under this condition | ||
576 | */ | ||
577 | if (status & (ATA_BUSY | ATA_DRQ)) | ||
578 | return; | ||
579 | else { | ||
580 | ahci_scr_read(&ap->link, SCR_STATUS, &tmp); | ||
581 | |||
582 | if ((tmp & 0xf) != 0x3) | ||
583 | return; | ||
584 | } | ||
585 | 564 | ||
586 | /* start DMA */ | 565 | /* start DMA */ |
587 | tmp = readl(port_mmio + PORT_CMD); | 566 | tmp = readl(port_mmio + PORT_CMD); |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index f26f2fe3480..dad9fd660f3 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -3316,7 +3316,7 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, | |||
3316 | struct ata_eh_context *ehc = &link->eh_context; | 3316 | struct ata_eh_context *ehc = &link->eh_context; |
3317 | struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL; | 3317 | struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL; |
3318 | enum ata_lpm_policy old_policy = link->lpm_policy; | 3318 | enum ata_lpm_policy old_policy = link->lpm_policy; |
3319 | bool no_dipm = ap->flags & ATA_FLAG_NO_DIPM; | 3319 | bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; |
3320 | unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM; | 3320 | unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM; |
3321 | unsigned int err_mask; | 3321 | unsigned int err_mask; |
3322 | int rc; | 3322 | int rc; |
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index bdd2719f3f6..bc9e702186d 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c | |||
@@ -2643,16 +2643,19 @@ fore200e_init(struct fore200e* fore200e, struct device *parent) | |||
2643 | } | 2643 | } |
2644 | 2644 | ||
2645 | #ifdef CONFIG_SBUS | 2645 | #ifdef CONFIG_SBUS |
2646 | static const struct of_device_id fore200e_sba_match[]; | ||
2646 | static int __devinit fore200e_sba_probe(struct platform_device *op) | 2647 | static int __devinit fore200e_sba_probe(struct platform_device *op) |
2647 | { | 2648 | { |
2649 | const struct of_device_id *match; | ||
2648 | const struct fore200e_bus *bus; | 2650 | const struct fore200e_bus *bus; |
2649 | struct fore200e *fore200e; | 2651 | struct fore200e *fore200e; |
2650 | static int index = 0; | 2652 | static int index = 0; |
2651 | int err; | 2653 | int err; |
2652 | 2654 | ||
2653 | if (!op->dev.of_match) | 2655 | match = of_match_device(fore200e_sba_match, &op->dev); |
2656 | if (!match) | ||
2654 | return -EINVAL; | 2657 | return -EINVAL; |
2655 | bus = op->dev.of_match->data; | 2658 | bus = match->data; |
2656 | 2659 | ||
2657 | fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL); | 2660 | fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL); |
2658 | if (!fore200e) | 2661 | if (!fore200e) |
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 8066d086578..e086fbbbe85 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c | |||
@@ -2547,7 +2547,6 @@ static bool DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller) | |||
2547 | disk->major = MajorNumber; | 2547 | disk->major = MajorNumber; |
2548 | disk->first_minor = n << DAC960_MaxPartitionsBits; | 2548 | disk->first_minor = n << DAC960_MaxPartitionsBits; |
2549 | disk->fops = &DAC960_BlockDeviceOperations; | 2549 | disk->fops = &DAC960_BlockDeviceOperations; |
2550 | disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
2551 | } | 2550 | } |
2552 | /* | 2551 | /* |
2553 | Indicate the Block Device Registration completed successfully, | 2552 | Indicate the Block Device Registration completed successfully, |
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 456c0cc90dc..8eba86bba59 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c | |||
@@ -1736,7 +1736,6 @@ static int __init fd_probe_drives(void) | |||
1736 | disk->major = FLOPPY_MAJOR; | 1736 | disk->major = FLOPPY_MAJOR; |
1737 | disk->first_minor = drive; | 1737 | disk->first_minor = drive; |
1738 | disk->fops = &floppy_fops; | 1738 | disk->fops = &floppy_fops; |
1739 | disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
1740 | sprintf(disk->disk_name, "fd%d", drive); | 1739 | sprintf(disk->disk_name, "fd%d", drive); |
1741 | disk->private_data = &unit[drive]; | 1740 | disk->private_data = &unit[drive]; |
1742 | set_capacity(disk, 880*2); | 1741 | set_capacity(disk, 880*2); |
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index c871eae1412..ede16c64ff0 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c | |||
@@ -1964,7 +1964,6 @@ static int __init atari_floppy_init (void) | |||
1964 | unit[i].disk->first_minor = i; | 1964 | unit[i].disk->first_minor = i; |
1965 | sprintf(unit[i].disk->disk_name, "fd%d", i); | 1965 | sprintf(unit[i].disk->disk_name, "fd%d", i); |
1966 | unit[i].disk->fops = &floppy_fops; | 1966 | unit[i].disk->fops = &floppy_fops; |
1967 | unit[i].disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
1968 | unit[i].disk->private_data = &unit[i]; | 1967 | unit[i].disk->private_data = &unit[i]; |
1969 | unit[i].disk->queue = blk_init_queue(do_fd_request, | 1968 | unit[i].disk->queue = blk_init_queue(do_fd_request, |
1970 | &ataflop_lock); | 1969 | &ataflop_lock); |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 301d7a9a41a..db8f88586c8 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -4205,7 +4205,6 @@ static int __init floppy_init(void) | |||
4205 | disks[dr]->major = FLOPPY_MAJOR; | 4205 | disks[dr]->major = FLOPPY_MAJOR; |
4206 | disks[dr]->first_minor = TOMINOR(dr); | 4206 | disks[dr]->first_minor = TOMINOR(dr); |
4207 | disks[dr]->fops = &floppy_fops; | 4207 | disks[dr]->fops = &floppy_fops; |
4208 | disks[dr]->events = DISK_EVENT_MEDIA_CHANGE; | ||
4209 | sprintf(disks[dr]->disk_name, "fd%d", dr); | 4208 | sprintf(disks[dr]->disk_name, "fd%d", dr); |
4210 | 4209 | ||
4211 | init_timer(&motor_off_timer[dr]); | 4210 | init_timer(&motor_off_timer[dr]); |
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index 2f2ccf68625..8690e31d993 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c | |||
@@ -320,7 +320,6 @@ static void pcd_init_units(void) | |||
320 | disk->first_minor = unit; | 320 | disk->first_minor = unit; |
321 | strcpy(disk->disk_name, cd->name); /* umm... */ | 321 | strcpy(disk->disk_name, cd->name); /* umm... */ |
322 | disk->fops = &pcd_bdops; | 322 | disk->fops = &pcd_bdops; |
323 | disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
324 | } | 323 | } |
325 | } | 324 | } |
326 | 325 | ||
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 21dfdb77686..869e7676d46 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c | |||
@@ -837,7 +837,6 @@ static void pd_probe_drive(struct pd_unit *disk) | |||
837 | p->fops = &pd_fops; | 837 | p->fops = &pd_fops; |
838 | p->major = major; | 838 | p->major = major; |
839 | p->first_minor = (disk - pd) << PD_BITS; | 839 | p->first_minor = (disk - pd) << PD_BITS; |
840 | p->events = DISK_EVENT_MEDIA_CHANGE; | ||
841 | disk->gd = p; | 840 | disk->gd = p; |
842 | p->private_data = disk; | 841 | p->private_data = disk; |
843 | p->queue = pd_queue; | 842 | p->queue = pd_queue; |
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index 7adeb1edbf4..f21b520ef41 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c | |||
@@ -294,7 +294,6 @@ static void __init pf_init_units(void) | |||
294 | disk->first_minor = unit; | 294 | disk->first_minor = unit; |
295 | strcpy(disk->disk_name, pf->name); | 295 | strcpy(disk->disk_name, pf->name); |
296 | disk->fops = &pf_fops; | 296 | disk->fops = &pf_fops; |
297 | disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
298 | if (!(*drives[unit])[D_PRT]) | 297 | if (!(*drives[unit])[D_PRT]) |
299 | pf_drive_count++; | 298 | pf_drive_count++; |
300 | } | 299 | } |
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 16dc3645291..9712fad82bc 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -92,6 +92,8 @@ struct rbd_client { | |||
92 | struct list_head node; | 92 | struct list_head node; |
93 | }; | 93 | }; |
94 | 94 | ||
95 | struct rbd_req_coll; | ||
96 | |||
95 | /* | 97 | /* |
96 | * a single io request | 98 | * a single io request |
97 | */ | 99 | */ |
@@ -100,6 +102,24 @@ struct rbd_request { | |||
100 | struct bio *bio; /* cloned bio */ | 102 | struct bio *bio; /* cloned bio */ |
101 | struct page **pages; /* list of used pages */ | 103 | struct page **pages; /* list of used pages */ |
102 | u64 len; | 104 | u64 len; |
105 | int coll_index; | ||
106 | struct rbd_req_coll *coll; | ||
107 | }; | ||
108 | |||
109 | struct rbd_req_status { | ||
110 | int done; | ||
111 | int rc; | ||
112 | u64 bytes; | ||
113 | }; | ||
114 | |||
115 | /* | ||
116 | * a collection of requests | ||
117 | */ | ||
118 | struct rbd_req_coll { | ||
119 | int total; | ||
120 | int num_done; | ||
121 | struct kref kref; | ||
122 | struct rbd_req_status status[0]; | ||
103 | }; | 123 | }; |
104 | 124 | ||
105 | struct rbd_snap { | 125 | struct rbd_snap { |
@@ -416,6 +436,17 @@ static void rbd_put_client(struct rbd_device *rbd_dev) | |||
416 | rbd_dev->client = NULL; | 436 | rbd_dev->client = NULL; |
417 | } | 437 | } |
418 | 438 | ||
439 | /* | ||
440 | * Destroy requests collection | ||
441 | */ | ||
442 | static void rbd_coll_release(struct kref *kref) | ||
443 | { | ||
444 | struct rbd_req_coll *coll = | ||
445 | container_of(kref, struct rbd_req_coll, kref); | ||
446 | |||
447 | dout("rbd_coll_release %p\n", coll); | ||
448 | kfree(coll); | ||
449 | } | ||
419 | 450 | ||
420 | /* | 451 | /* |
421 | * Create a new header structure, translate header format from the on-disk | 452 | * Create a new header structure, translate header format from the on-disk |
@@ -590,6 +621,14 @@ static u64 rbd_get_segment(struct rbd_image_header *header, | |||
590 | return len; | 621 | return len; |
591 | } | 622 | } |
592 | 623 | ||
624 | static int rbd_get_num_segments(struct rbd_image_header *header, | ||
625 | u64 ofs, u64 len) | ||
626 | { | ||
627 | u64 start_seg = ofs >> header->obj_order; | ||
628 | u64 end_seg = (ofs + len - 1) >> header->obj_order; | ||
629 | return end_seg - start_seg + 1; | ||
630 | } | ||
631 | |||
593 | /* | 632 | /* |
594 | * bio helpers | 633 | * bio helpers |
595 | */ | 634 | */ |
@@ -735,6 +774,50 @@ static void rbd_destroy_ops(struct ceph_osd_req_op *ops) | |||
735 | kfree(ops); | 774 | kfree(ops); |
736 | } | 775 | } |
737 | 776 | ||
777 | static void rbd_coll_end_req_index(struct request *rq, | ||
778 | struct rbd_req_coll *coll, | ||
779 | int index, | ||
780 | int ret, u64 len) | ||
781 | { | ||
782 | struct request_queue *q; | ||
783 | int min, max, i; | ||
784 | |||
785 | dout("rbd_coll_end_req_index %p index %d ret %d len %lld\n", | ||
786 | coll, index, ret, len); | ||
787 | |||
788 | if (!rq) | ||
789 | return; | ||
790 | |||
791 | if (!coll) { | ||
792 | blk_end_request(rq, ret, len); | ||
793 | return; | ||
794 | } | ||
795 | |||
796 | q = rq->q; | ||
797 | |||
798 | spin_lock_irq(q->queue_lock); | ||
799 | coll->status[index].done = 1; | ||
800 | coll->status[index].rc = ret; | ||
801 | coll->status[index].bytes = len; | ||
802 | max = min = coll->num_done; | ||
803 | while (max < coll->total && coll->status[max].done) | ||
804 | max++; | ||
805 | |||
806 | for (i = min; i<max; i++) { | ||
807 | __blk_end_request(rq, coll->status[i].rc, | ||
808 | coll->status[i].bytes); | ||
809 | coll->num_done++; | ||
810 | kref_put(&coll->kref, rbd_coll_release); | ||
811 | } | ||
812 | spin_unlock_irq(q->queue_lock); | ||
813 | } | ||
814 | |||
815 | static void rbd_coll_end_req(struct rbd_request *req, | ||
816 | int ret, u64 len) | ||
817 | { | ||
818 | rbd_coll_end_req_index(req->rq, req->coll, req->coll_index, ret, len); | ||
819 | } | ||
820 | |||
738 | /* | 821 | /* |
739 | * Send ceph osd request | 822 | * Send ceph osd request |
740 | */ | 823 | */ |
@@ -749,6 +832,8 @@ static int rbd_do_request(struct request *rq, | |||
749 | int flags, | 832 | int flags, |
750 | struct ceph_osd_req_op *ops, | 833 | struct ceph_osd_req_op *ops, |
751 | int num_reply, | 834 | int num_reply, |
835 | struct rbd_req_coll *coll, | ||
836 | int coll_index, | ||
752 | void (*rbd_cb)(struct ceph_osd_request *req, | 837 | void (*rbd_cb)(struct ceph_osd_request *req, |
753 | struct ceph_msg *msg), | 838 | struct ceph_msg *msg), |
754 | struct ceph_osd_request **linger_req, | 839 | struct ceph_osd_request **linger_req, |
@@ -763,12 +848,20 @@ static int rbd_do_request(struct request *rq, | |||
763 | struct ceph_osd_request_head *reqhead; | 848 | struct ceph_osd_request_head *reqhead; |
764 | struct rbd_image_header *header = &dev->header; | 849 | struct rbd_image_header *header = &dev->header; |
765 | 850 | ||
766 | ret = -ENOMEM; | ||
767 | req_data = kzalloc(sizeof(*req_data), GFP_NOIO); | 851 | req_data = kzalloc(sizeof(*req_data), GFP_NOIO); |
768 | if (!req_data) | 852 | if (!req_data) { |
769 | goto done; | 853 | if (coll) |
854 | rbd_coll_end_req_index(rq, coll, coll_index, | ||
855 | -ENOMEM, len); | ||
856 | return -ENOMEM; | ||
857 | } | ||
770 | 858 | ||
771 | dout("rbd_do_request len=%lld ofs=%lld\n", len, ofs); | 859 | if (coll) { |
860 | req_data->coll = coll; | ||
861 | req_data->coll_index = coll_index; | ||
862 | } | ||
863 | |||
864 | dout("rbd_do_request obj=%s ofs=%lld len=%lld\n", obj, len, ofs); | ||
772 | 865 | ||
773 | down_read(&header->snap_rwsem); | 866 | down_read(&header->snap_rwsem); |
774 | 867 | ||
@@ -777,9 +870,9 @@ static int rbd_do_request(struct request *rq, | |||
777 | ops, | 870 | ops, |
778 | false, | 871 | false, |
779 | GFP_NOIO, pages, bio); | 872 | GFP_NOIO, pages, bio); |
780 | if (IS_ERR(req)) { | 873 | if (!req) { |
781 | up_read(&header->snap_rwsem); | 874 | up_read(&header->snap_rwsem); |
782 | ret = PTR_ERR(req); | 875 | ret = -ENOMEM; |
783 | goto done_pages; | 876 | goto done_pages; |
784 | } | 877 | } |
785 | 878 | ||
@@ -828,7 +921,8 @@ static int rbd_do_request(struct request *rq, | |||
828 | ret = ceph_osdc_wait_request(&dev->client->osdc, req); | 921 | ret = ceph_osdc_wait_request(&dev->client->osdc, req); |
829 | if (ver) | 922 | if (ver) |
830 | *ver = le64_to_cpu(req->r_reassert_version.version); | 923 | *ver = le64_to_cpu(req->r_reassert_version.version); |
831 | dout("reassert_ver=%lld\n", le64_to_cpu(req->r_reassert_version.version)); | 924 | dout("reassert_ver=%lld\n", |
925 | le64_to_cpu(req->r_reassert_version.version)); | ||
832 | ceph_osdc_put_request(req); | 926 | ceph_osdc_put_request(req); |
833 | } | 927 | } |
834 | return ret; | 928 | return ret; |
@@ -837,10 +931,8 @@ done_err: | |||
837 | bio_chain_put(req_data->bio); | 931 | bio_chain_put(req_data->bio); |
838 | ceph_osdc_put_request(req); | 932 | ceph_osdc_put_request(req); |
839 | done_pages: | 933 | done_pages: |
934 | rbd_coll_end_req(req_data, ret, len); | ||
840 | kfree(req_data); | 935 | kfree(req_data); |
841 | done: | ||
842 | if (rq) | ||
843 | blk_end_request(rq, ret, len); | ||
844 | return ret; | 936 | return ret; |
845 | } | 937 | } |
846 | 938 | ||
@@ -874,7 +966,7 @@ static void rbd_req_cb(struct ceph_osd_request *req, struct ceph_msg *msg) | |||
874 | bytes = req_data->len; | 966 | bytes = req_data->len; |
875 | } | 967 | } |
876 | 968 | ||
877 | blk_end_request(req_data->rq, rc, bytes); | 969 | rbd_coll_end_req(req_data, rc, bytes); |
878 | 970 | ||
879 | if (req_data->bio) | 971 | if (req_data->bio) |
880 | bio_chain_put(req_data->bio); | 972 | bio_chain_put(req_data->bio); |
@@ -934,6 +1026,7 @@ static int rbd_req_sync_op(struct rbd_device *dev, | |||
934 | flags, | 1026 | flags, |
935 | ops, | 1027 | ops, |
936 | 2, | 1028 | 2, |
1029 | NULL, 0, | ||
937 | NULL, | 1030 | NULL, |
938 | linger_req, ver); | 1031 | linger_req, ver); |
939 | if (ret < 0) | 1032 | if (ret < 0) |
@@ -959,7 +1052,9 @@ static int rbd_do_op(struct request *rq, | |||
959 | u64 snapid, | 1052 | u64 snapid, |
960 | int opcode, int flags, int num_reply, | 1053 | int opcode, int flags, int num_reply, |
961 | u64 ofs, u64 len, | 1054 | u64 ofs, u64 len, |
962 | struct bio *bio) | 1055 | struct bio *bio, |
1056 | struct rbd_req_coll *coll, | ||
1057 | int coll_index) | ||
963 | { | 1058 | { |
964 | char *seg_name; | 1059 | char *seg_name; |
965 | u64 seg_ofs; | 1060 | u64 seg_ofs; |
@@ -995,7 +1090,10 @@ static int rbd_do_op(struct request *rq, | |||
995 | flags, | 1090 | flags, |
996 | ops, | 1091 | ops, |
997 | num_reply, | 1092 | num_reply, |
1093 | coll, coll_index, | ||
998 | rbd_req_cb, 0, NULL); | 1094 | rbd_req_cb, 0, NULL); |
1095 | |||
1096 | rbd_destroy_ops(ops); | ||
999 | done: | 1097 | done: |
1000 | kfree(seg_name); | 1098 | kfree(seg_name); |
1001 | return ret; | 1099 | return ret; |
@@ -1008,13 +1106,15 @@ static int rbd_req_write(struct request *rq, | |||
1008 | struct rbd_device *rbd_dev, | 1106 | struct rbd_device *rbd_dev, |
1009 | struct ceph_snap_context *snapc, | 1107 | struct ceph_snap_context *snapc, |
1010 | u64 ofs, u64 len, | 1108 | u64 ofs, u64 len, |
1011 | struct bio *bio) | 1109 | struct bio *bio, |
1110 | struct rbd_req_coll *coll, | ||
1111 | int coll_index) | ||
1012 | { | 1112 | { |
1013 | return rbd_do_op(rq, rbd_dev, snapc, CEPH_NOSNAP, | 1113 | return rbd_do_op(rq, rbd_dev, snapc, CEPH_NOSNAP, |
1014 | CEPH_OSD_OP_WRITE, | 1114 | CEPH_OSD_OP_WRITE, |
1015 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, | 1115 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, |
1016 | 2, | 1116 | 2, |
1017 | ofs, len, bio); | 1117 | ofs, len, bio, coll, coll_index); |
1018 | } | 1118 | } |
1019 | 1119 | ||
1020 | /* | 1120 | /* |
@@ -1024,14 +1124,16 @@ static int rbd_req_read(struct request *rq, | |||
1024 | struct rbd_device *rbd_dev, | 1124 | struct rbd_device *rbd_dev, |
1025 | u64 snapid, | 1125 | u64 snapid, |
1026 | u64 ofs, u64 len, | 1126 | u64 ofs, u64 len, |
1027 | struct bio *bio) | 1127 | struct bio *bio, |
1128 | struct rbd_req_coll *coll, | ||
1129 | int coll_index) | ||
1028 | { | 1130 | { |
1029 | return rbd_do_op(rq, rbd_dev, NULL, | 1131 | return rbd_do_op(rq, rbd_dev, NULL, |
1030 | (snapid ? snapid : CEPH_NOSNAP), | 1132 | (snapid ? snapid : CEPH_NOSNAP), |
1031 | CEPH_OSD_OP_READ, | 1133 | CEPH_OSD_OP_READ, |
1032 | CEPH_OSD_FLAG_READ, | 1134 | CEPH_OSD_FLAG_READ, |
1033 | 2, | 1135 | 2, |
1034 | ofs, len, bio); | 1136 | ofs, len, bio, coll, coll_index); |
1035 | } | 1137 | } |
1036 | 1138 | ||
1037 | /* | 1139 | /* |
@@ -1063,7 +1165,9 @@ static int rbd_req_sync_notify_ack(struct rbd_device *dev, | |||
1063 | { | 1165 | { |
1064 | struct ceph_osd_req_op *ops; | 1166 | struct ceph_osd_req_op *ops; |
1065 | struct page **pages = NULL; | 1167 | struct page **pages = NULL; |
1066 | int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_NOTIFY_ACK, 0); | 1168 | int ret; |
1169 | |||
1170 | ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_NOTIFY_ACK, 0); | ||
1067 | if (ret < 0) | 1171 | if (ret < 0) |
1068 | return ret; | 1172 | return ret; |
1069 | 1173 | ||
@@ -1077,6 +1181,7 @@ static int rbd_req_sync_notify_ack(struct rbd_device *dev, | |||
1077 | CEPH_OSD_FLAG_READ, | 1181 | CEPH_OSD_FLAG_READ, |
1078 | ops, | 1182 | ops, |
1079 | 1, | 1183 | 1, |
1184 | NULL, 0, | ||
1080 | rbd_simple_req_cb, 0, NULL); | 1185 | rbd_simple_req_cb, 0, NULL); |
1081 | 1186 | ||
1082 | rbd_destroy_ops(ops); | 1187 | rbd_destroy_ops(ops); |
@@ -1274,6 +1379,20 @@ static int rbd_req_sync_exec(struct rbd_device *dev, | |||
1274 | return ret; | 1379 | return ret; |
1275 | } | 1380 | } |
1276 | 1381 | ||
1382 | static struct rbd_req_coll *rbd_alloc_coll(int num_reqs) | ||
1383 | { | ||
1384 | struct rbd_req_coll *coll = | ||
1385 | kzalloc(sizeof(struct rbd_req_coll) + | ||
1386 | sizeof(struct rbd_req_status) * num_reqs, | ||
1387 | GFP_ATOMIC); | ||
1388 | |||
1389 | if (!coll) | ||
1390 | return NULL; | ||
1391 | coll->total = num_reqs; | ||
1392 | kref_init(&coll->kref); | ||
1393 | return coll; | ||
1394 | } | ||
1395 | |||
1277 | /* | 1396 | /* |
1278 | * block device queue callback | 1397 | * block device queue callback |
1279 | */ | 1398 | */ |
@@ -1291,6 +1410,8 @@ static void rbd_rq_fn(struct request_queue *q) | |||
1291 | bool do_write; | 1410 | bool do_write; |
1292 | int size, op_size = 0; | 1411 | int size, op_size = 0; |
1293 | u64 ofs; | 1412 | u64 ofs; |
1413 | int num_segs, cur_seg = 0; | ||
1414 | struct rbd_req_coll *coll; | ||
1294 | 1415 | ||
1295 | /* peek at request from block layer */ | 1416 | /* peek at request from block layer */ |
1296 | if (!rq) | 1417 | if (!rq) |
@@ -1321,6 +1442,14 @@ static void rbd_rq_fn(struct request_queue *q) | |||
1321 | do_write ? "write" : "read", | 1442 | do_write ? "write" : "read", |
1322 | size, blk_rq_pos(rq) * 512ULL); | 1443 | size, blk_rq_pos(rq) * 512ULL); |
1323 | 1444 | ||
1445 | num_segs = rbd_get_num_segments(&rbd_dev->header, ofs, size); | ||
1446 | coll = rbd_alloc_coll(num_segs); | ||
1447 | if (!coll) { | ||
1448 | spin_lock_irq(q->queue_lock); | ||
1449 | __blk_end_request_all(rq, -ENOMEM); | ||
1450 | goto next; | ||
1451 | } | ||
1452 | |||
1324 | do { | 1453 | do { |
1325 | /* a bio clone to be passed down to OSD req */ | 1454 | /* a bio clone to be passed down to OSD req */ |
1326 | dout("rq->bio->bi_vcnt=%d\n", rq->bio->bi_vcnt); | 1455 | dout("rq->bio->bi_vcnt=%d\n", rq->bio->bi_vcnt); |
@@ -1328,35 +1457,41 @@ static void rbd_rq_fn(struct request_queue *q) | |||
1328 | rbd_dev->header.block_name, | 1457 | rbd_dev->header.block_name, |
1329 | ofs, size, | 1458 | ofs, size, |
1330 | NULL, NULL); | 1459 | NULL, NULL); |
1460 | kref_get(&coll->kref); | ||
1331 | bio = bio_chain_clone(&rq_bio, &next_bio, &bp, | 1461 | bio = bio_chain_clone(&rq_bio, &next_bio, &bp, |
1332 | op_size, GFP_ATOMIC); | 1462 | op_size, GFP_ATOMIC); |
1333 | if (!bio) { | 1463 | if (!bio) { |
1334 | spin_lock_irq(q->queue_lock); | 1464 | rbd_coll_end_req_index(rq, coll, cur_seg, |
1335 | __blk_end_request_all(rq, -ENOMEM); | 1465 | -ENOMEM, op_size); |
1336 | goto next; | 1466 | goto next_seg; |
1337 | } | 1467 | } |
1338 | 1468 | ||
1469 | |||
1339 | /* init OSD command: write or read */ | 1470 | /* init OSD command: write or read */ |
1340 | if (do_write) | 1471 | if (do_write) |
1341 | rbd_req_write(rq, rbd_dev, | 1472 | rbd_req_write(rq, rbd_dev, |
1342 | rbd_dev->header.snapc, | 1473 | rbd_dev->header.snapc, |
1343 | ofs, | 1474 | ofs, |
1344 | op_size, bio); | 1475 | op_size, bio, |
1476 | coll, cur_seg); | ||
1345 | else | 1477 | else |
1346 | rbd_req_read(rq, rbd_dev, | 1478 | rbd_req_read(rq, rbd_dev, |
1347 | cur_snap_id(rbd_dev), | 1479 | cur_snap_id(rbd_dev), |
1348 | ofs, | 1480 | ofs, |
1349 | op_size, bio); | 1481 | op_size, bio, |
1482 | coll, cur_seg); | ||
1350 | 1483 | ||
1484 | next_seg: | ||
1351 | size -= op_size; | 1485 | size -= op_size; |
1352 | ofs += op_size; | 1486 | ofs += op_size; |
1353 | 1487 | ||
1488 | cur_seg++; | ||
1354 | rq_bio = next_bio; | 1489 | rq_bio = next_bio; |
1355 | } while (size > 0); | 1490 | } while (size > 0); |
1491 | kref_put(&coll->kref, rbd_coll_release); | ||
1356 | 1492 | ||
1357 | if (bp) | 1493 | if (bp) |
1358 | bio_pair_release(bp); | 1494 | bio_pair_release(bp); |
1359 | |||
1360 | spin_lock_irq(q->queue_lock); | 1495 | spin_lock_irq(q->queue_lock); |
1361 | next: | 1496 | next: |
1362 | rq = blk_fetch_request(q); | 1497 | rq = blk_fetch_request(q); |
diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 24a482f2fbd..fd5adcd5594 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c | |||
@@ -858,7 +858,6 @@ static int __devinit swim_floppy_init(struct swim_priv *swd) | |||
858 | swd->unit[drive].disk->first_minor = drive; | 858 | swd->unit[drive].disk->first_minor = drive; |
859 | sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive); | 859 | sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive); |
860 | swd->unit[drive].disk->fops = &floppy_fops; | 860 | swd->unit[drive].disk->fops = &floppy_fops; |
861 | swd->unit[drive].disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
862 | swd->unit[drive].disk->private_data = &swd->unit[drive]; | 861 | swd->unit[drive].disk->private_data = &swd->unit[drive]; |
863 | swd->unit[drive].disk->queue = swd->queue; | 862 | swd->unit[drive].disk->queue = swd->queue; |
864 | set_capacity(swd->unit[drive].disk, 2880); | 863 | set_capacity(swd->unit[drive].disk, 2880); |
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index 4c10f56facb..773bfa79277 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c | |||
@@ -1163,7 +1163,6 @@ static int __devinit swim3_attach(struct macio_dev *mdev, const struct of_device | |||
1163 | disk->major = FLOPPY_MAJOR; | 1163 | disk->major = FLOPPY_MAJOR; |
1164 | disk->first_minor = i; | 1164 | disk->first_minor = i; |
1165 | disk->fops = &floppy_fops; | 1165 | disk->fops = &floppy_fops; |
1166 | disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
1167 | disk->private_data = &floppy_states[i]; | 1166 | disk->private_data = &floppy_states[i]; |
1168 | disk->queue = swim3_queue; | 1167 | disk->queue = swim3_queue; |
1169 | disk->flags |= GENHD_FL_REMOVABLE; | 1168 | disk->flags |= GENHD_FL_REMOVABLE; |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 68b9430c7cf..0e376d46bdd 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -2334,7 +2334,6 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum) | |||
2334 | disk->major = UB_MAJOR; | 2334 | disk->major = UB_MAJOR; |
2335 | disk->first_minor = lun->id * UB_PARTS_PER_LUN; | 2335 | disk->first_minor = lun->id * UB_PARTS_PER_LUN; |
2336 | disk->fops = &ub_bd_fops; | 2336 | disk->fops = &ub_bd_fops; |
2337 | disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
2338 | disk->private_data = lun; | 2337 | disk->private_data = lun; |
2339 | disk->driverfs_dev = &sc->intf->dev; | 2338 | disk->driverfs_dev = &sc->intf->dev; |
2340 | 2339 | ||
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index 645ff765cd1..6c7fd7db6df 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c | |||
@@ -1005,7 +1005,6 @@ static int __devinit ace_setup(struct ace_device *ace) | |||
1005 | ace->gd->major = ace_major; | 1005 | ace->gd->major = ace_major; |
1006 | ace->gd->first_minor = ace->id * ACE_NUM_MINORS; | 1006 | ace->gd->first_minor = ace->id * ACE_NUM_MINORS; |
1007 | ace->gd->fops = &ace_fops; | 1007 | ace->gd->fops = &ace_fops; |
1008 | ace->gd->events = DISK_EVENT_MEDIA_CHANGE; | ||
1009 | ace->gd->queue = ace->queue; | 1008 | ace->gd->queue = ace->queue; |
1010 | ace->gd->private_data = ace; | 1009 | ace->gd->private_data = ace; |
1011 | snprintf(ace->gd->disk_name, 32, "xs%c", ace->id + 'a'); | 1010 | snprintf(ace->gd->disk_name, 32, "xs%c", ace->id + 'a'); |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 514dd8efaf7..75fb965b8f7 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -986,6 +986,9 @@ int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev, fmode_t | |||
986 | 986 | ||
987 | cdinfo(CD_OPEN, "entering cdrom_open\n"); | 987 | cdinfo(CD_OPEN, "entering cdrom_open\n"); |
988 | 988 | ||
989 | /* open is event synchronization point, check events first */ | ||
990 | check_disk_change(bdev); | ||
991 | |||
989 | /* if this was a O_NONBLOCK open and we should honor the flags, | 992 | /* if this was a O_NONBLOCK open and we should honor the flags, |
990 | * do a quick open without drive/disc integrity checks. */ | 993 | * do a quick open without drive/disc integrity checks. */ |
991 | cdi->use_count++; | 994 | cdi->use_count++; |
@@ -1012,9 +1015,6 @@ int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev, fmode_t | |||
1012 | 1015 | ||
1013 | cdinfo(CD_OPEN, "Use count for \"/dev/%s\" now %d\n", | 1016 | cdinfo(CD_OPEN, "Use count for \"/dev/%s\" now %d\n", |
1014 | cdi->name, cdi->use_count); | 1017 | cdi->name, cdi->use_count); |
1015 | /* Do this on open. Don't wait for mount, because they might | ||
1016 | not be mounting, but opening with O_NONBLOCK */ | ||
1017 | check_disk_change(bdev); | ||
1018 | return 0; | 1018 | return 0; |
1019 | err_release: | 1019 | err_release: |
1020 | if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK) { | 1020 | if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK) { |
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index b2b034fea34..3ceaf006e7f 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c | |||
@@ -803,7 +803,6 @@ static int __devinit probe_gdrom(struct platform_device *devptr) | |||
803 | goto probe_fail_cdrom_register; | 803 | goto probe_fail_cdrom_register; |
804 | } | 804 | } |
805 | gd.disk->fops = &gdrom_bdops; | 805 | gd.disk->fops = &gdrom_bdops; |
806 | gd.disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
807 | /* latch on to the interrupt */ | 806 | /* latch on to the interrupt */ |
808 | err = gdrom_set_interrupt_handlers(); | 807 | err = gdrom_set_interrupt_handlers(); |
809 | if (err) | 808 | if (err) |
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c index 4e874c5fa60..e427fbe4599 100644 --- a/drivers/cdrom/viocd.c +++ b/drivers/cdrom/viocd.c | |||
@@ -626,7 +626,6 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id) | |||
626 | gendisk->queue = q; | 626 | gendisk->queue = q; |
627 | gendisk->fops = &viocd_fops; | 627 | gendisk->fops = &viocd_fops; |
628 | gendisk->flags = GENHD_FL_CD|GENHD_FL_REMOVABLE; | 628 | gendisk->flags = GENHD_FL_CD|GENHD_FL_REMOVABLE; |
629 | gendisk->events = DISK_EVENT_MEDIA_CHANGE; | ||
630 | set_capacity(gendisk, 0); | 629 | set_capacity(gendisk, 0); |
631 | gendisk->private_data = d; | 630 | gendisk->private_data = d; |
632 | d->viocd_disk = gendisk; | 631 | d->viocd_disk = gendisk; |
diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c index 43ac61978d8..ac6739e085e 100644 --- a/drivers/char/hw_random/n2-drv.c +++ b/drivers/char/hw_random/n2-drv.c | |||
@@ -619,15 +619,18 @@ static void __devinit n2rng_driver_version(void) | |||
619 | pr_info("%s", version); | 619 | pr_info("%s", version); |
620 | } | 620 | } |
621 | 621 | ||
622 | static const struct of_device_id n2rng_match[]; | ||
622 | static int __devinit n2rng_probe(struct platform_device *op) | 623 | static int __devinit n2rng_probe(struct platform_device *op) |
623 | { | 624 | { |
625 | const struct of_device_id *match; | ||
624 | int victoria_falls; | 626 | int victoria_falls; |
625 | int err = -ENOMEM; | 627 | int err = -ENOMEM; |
626 | struct n2rng *np; | 628 | struct n2rng *np; |
627 | 629 | ||
628 | if (!op->dev.of_match) | 630 | match = of_match_device(n2rng_match, &op->dev); |
631 | if (!match) | ||
629 | return -EINVAL; | 632 | return -EINVAL; |
630 | victoria_falls = (op->dev.of_match->data != NULL); | 633 | victoria_falls = (match->data != NULL); |
631 | 634 | ||
632 | n2rng_driver_version(); | 635 | n2rng_driver_version(); |
633 | np = kzalloc(sizeof(*np), GFP_KERNEL); | 636 | np = kzalloc(sizeof(*np), GFP_KERNEL); |
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index cc6c9b2546a..64c6b853061 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -2554,9 +2554,11 @@ static struct pci_driver ipmi_pci_driver = { | |||
2554 | }; | 2554 | }; |
2555 | #endif /* CONFIG_PCI */ | 2555 | #endif /* CONFIG_PCI */ |
2556 | 2556 | ||
2557 | static struct of_device_id ipmi_match[]; | ||
2557 | static int __devinit ipmi_probe(struct platform_device *dev) | 2558 | static int __devinit ipmi_probe(struct platform_device *dev) |
2558 | { | 2559 | { |
2559 | #ifdef CONFIG_OF | 2560 | #ifdef CONFIG_OF |
2561 | const struct of_device_id *match; | ||
2560 | struct smi_info *info; | 2562 | struct smi_info *info; |
2561 | struct resource resource; | 2563 | struct resource resource; |
2562 | const __be32 *regsize, *regspacing, *regshift; | 2564 | const __be32 *regsize, *regspacing, *regshift; |
@@ -2566,7 +2568,8 @@ static int __devinit ipmi_probe(struct platform_device *dev) | |||
2566 | 2568 | ||
2567 | dev_info(&dev->dev, "probing via device tree\n"); | 2569 | dev_info(&dev->dev, "probing via device tree\n"); |
2568 | 2570 | ||
2569 | if (!dev->dev.of_match) | 2571 | match = of_match_device(ipmi_match, &dev->dev); |
2572 | if (!match) | ||
2570 | return -EINVAL; | 2573 | return -EINVAL; |
2571 | 2574 | ||
2572 | ret = of_address_to_resource(np, 0, &resource); | 2575 | ret = of_address_to_resource(np, 0, &resource); |
@@ -2601,7 +2604,7 @@ static int __devinit ipmi_probe(struct platform_device *dev) | |||
2601 | return -ENOMEM; | 2604 | return -ENOMEM; |
2602 | } | 2605 | } |
2603 | 2606 | ||
2604 | info->si_type = (enum si_type) dev->dev.of_match->data; | 2607 | info->si_type = (enum si_type) match->data; |
2605 | info->addr_source = SI_DEVICETREE; | 2608 | info->addr_source = SI_DEVICETREE; |
2606 | info->irq_setup = std_irq_setup; | 2609 | info->irq_setup = std_irq_setup; |
2607 | 2610 | ||
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index d6412c16385..39ccdeada79 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c | |||
@@ -715,13 +715,13 @@ static int __devexit hwicap_remove(struct device *dev) | |||
715 | } | 715 | } |
716 | 716 | ||
717 | #ifdef CONFIG_OF | 717 | #ifdef CONFIG_OF |
718 | static int __devinit hwicap_of_probe(struct platform_device *op) | 718 | static int __devinit hwicap_of_probe(struct platform_device *op, |
719 | const struct hwicap_driver_config *config) | ||
719 | { | 720 | { |
720 | struct resource res; | 721 | struct resource res; |
721 | const unsigned int *id; | 722 | const unsigned int *id; |
722 | const char *family; | 723 | const char *family; |
723 | int rc; | 724 | int rc; |
724 | const struct hwicap_driver_config *config = op->dev.of_match->data; | ||
725 | const struct config_registers *regs; | 725 | const struct config_registers *regs; |
726 | 726 | ||
727 | 727 | ||
@@ -751,20 +751,24 @@ static int __devinit hwicap_of_probe(struct platform_device *op) | |||
751 | regs); | 751 | regs); |
752 | } | 752 | } |
753 | #else | 753 | #else |
754 | static inline int hwicap_of_probe(struct platform_device *op) | 754 | static inline int hwicap_of_probe(struct platform_device *op, |
755 | const struct hwicap_driver_config *config) | ||
755 | { | 756 | { |
756 | return -EINVAL; | 757 | return -EINVAL; |
757 | } | 758 | } |
758 | #endif /* CONFIG_OF */ | 759 | #endif /* CONFIG_OF */ |
759 | 760 | ||
761 | static const struct of_device_id __devinitconst hwicap_of_match[]; | ||
760 | static int __devinit hwicap_drv_probe(struct platform_device *pdev) | 762 | static int __devinit hwicap_drv_probe(struct platform_device *pdev) |
761 | { | 763 | { |
764 | const struct of_device_id *match; | ||
762 | struct resource *res; | 765 | struct resource *res; |
763 | const struct config_registers *regs; | 766 | const struct config_registers *regs; |
764 | const char *family; | 767 | const char *family; |
765 | 768 | ||
766 | if (pdev->dev.of_match) | 769 | match = of_match_device(hwicap_of_match, &pdev->dev); |
767 | return hwicap_of_probe(pdev); | 770 | if (match) |
771 | return hwicap_of_probe(pdev, match->data); | ||
768 | 772 | ||
769 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 773 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
770 | if (!res) | 774 | if (!res) |
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 0fc0a79852d..6db161f64ae 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c | |||
@@ -32,10 +32,9 @@ static DEFINE_MUTEX(clocks_mutex); | |||
32 | * Then we take the most specific entry - with the following | 32 | * Then we take the most specific entry - with the following |
33 | * order of precedence: dev+con > dev only > con only. | 33 | * order of precedence: dev+con > dev only > con only. |
34 | */ | 34 | */ |
35 | static struct clk *clk_find(const char *dev_id, const char *con_id) | 35 | static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) |
36 | { | 36 | { |
37 | struct clk_lookup *p; | 37 | struct clk_lookup *p, *cl = NULL; |
38 | struct clk *clk = NULL; | ||
39 | int match, best = 0; | 38 | int match, best = 0; |
40 | 39 | ||
41 | list_for_each_entry(p, &clocks, node) { | 40 | list_for_each_entry(p, &clocks, node) { |
@@ -52,27 +51,27 @@ static struct clk *clk_find(const char *dev_id, const char *con_id) | |||
52 | } | 51 | } |
53 | 52 | ||
54 | if (match > best) { | 53 | if (match > best) { |
55 | clk = p->clk; | 54 | cl = p; |
56 | if (match != 3) | 55 | if (match != 3) |
57 | best = match; | 56 | best = match; |
58 | else | 57 | else |
59 | break; | 58 | break; |
60 | } | 59 | } |
61 | } | 60 | } |
62 | return clk; | 61 | return cl; |
63 | } | 62 | } |
64 | 63 | ||
65 | struct clk *clk_get_sys(const char *dev_id, const char *con_id) | 64 | struct clk *clk_get_sys(const char *dev_id, const char *con_id) |
66 | { | 65 | { |
67 | struct clk *clk; | 66 | struct clk_lookup *cl; |
68 | 67 | ||
69 | mutex_lock(&clocks_mutex); | 68 | mutex_lock(&clocks_mutex); |
70 | clk = clk_find(dev_id, con_id); | 69 | cl = clk_find(dev_id, con_id); |
71 | if (clk && !__clk_get(clk)) | 70 | if (cl && !__clk_get(cl->clk)) |
72 | clk = NULL; | 71 | cl = NULL; |
73 | mutex_unlock(&clocks_mutex); | 72 | mutex_unlock(&clocks_mutex); |
74 | 73 | ||
75 | return clk ? clk : ERR_PTR(-ENOENT); | 74 | return cl ? cl->clk : ERR_PTR(-ENOENT); |
76 | } | 75 | } |
77 | EXPORT_SYMBOL(clk_get_sys); | 76 | EXPORT_SYMBOL(clk_get_sys); |
78 | 77 | ||
diff --git a/drivers/edac/ppc4xx_edac.c b/drivers/edac/ppc4xx_edac.c index c1f0045ceb8..af8e7b1aa29 100644 --- a/drivers/edac/ppc4xx_edac.c +++ b/drivers/edac/ppc4xx_edac.c | |||
@@ -1019,7 +1019,7 @@ ppc4xx_edac_mc_init(struct mem_ctl_info *mci, | |||
1019 | struct ppc4xx_edac_pdata *pdata = NULL; | 1019 | struct ppc4xx_edac_pdata *pdata = NULL; |
1020 | const struct device_node *np = op->dev.of_node; | 1020 | const struct device_node *np = op->dev.of_node; |
1021 | 1021 | ||
1022 | if (op->dev.of_match == NULL) | 1022 | if (of_match_device(ppc4xx_edac_match, &op->dev) == NULL) |
1023 | return -EINVAL; | 1023 | return -EINVAL; |
1024 | 1024 | ||
1025 | /* Initial driver pointers and private data */ | 1025 | /* Initial driver pointers and private data */ |
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index f903d7b6f34..23d1468ad25 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -2199,7 +2199,6 @@ static int ohci_set_config_rom(struct fw_card *card, | |||
2199 | { | 2199 | { |
2200 | struct fw_ohci *ohci; | 2200 | struct fw_ohci *ohci; |
2201 | unsigned long flags; | 2201 | unsigned long flags; |
2202 | int ret = -EBUSY; | ||
2203 | __be32 *next_config_rom; | 2202 | __be32 *next_config_rom; |
2204 | dma_addr_t uninitialized_var(next_config_rom_bus); | 2203 | dma_addr_t uninitialized_var(next_config_rom_bus); |
2205 | 2204 | ||
@@ -2240,22 +2239,37 @@ static int ohci_set_config_rom(struct fw_card *card, | |||
2240 | 2239 | ||
2241 | spin_lock_irqsave(&ohci->lock, flags); | 2240 | spin_lock_irqsave(&ohci->lock, flags); |
2242 | 2241 | ||
2242 | /* | ||
2243 | * If there is not an already pending config_rom update, | ||
2244 | * push our new allocation into the ohci->next_config_rom | ||
2245 | * and then mark the local variable as null so that we | ||
2246 | * won't deallocate the new buffer. | ||
2247 | * | ||
2248 | * OTOH, if there is a pending config_rom update, just | ||
2249 | * use that buffer with the new config_rom data, and | ||
2250 | * let this routine free the unused DMA allocation. | ||
2251 | */ | ||
2252 | |||
2243 | if (ohci->next_config_rom == NULL) { | 2253 | if (ohci->next_config_rom == NULL) { |
2244 | ohci->next_config_rom = next_config_rom; | 2254 | ohci->next_config_rom = next_config_rom; |
2245 | ohci->next_config_rom_bus = next_config_rom_bus; | 2255 | ohci->next_config_rom_bus = next_config_rom_bus; |
2256 | next_config_rom = NULL; | ||
2257 | } | ||
2246 | 2258 | ||
2247 | copy_config_rom(ohci->next_config_rom, config_rom, length); | 2259 | copy_config_rom(ohci->next_config_rom, config_rom, length); |
2248 | 2260 | ||
2249 | ohci->next_header = config_rom[0]; | 2261 | ohci->next_header = config_rom[0]; |
2250 | ohci->next_config_rom[0] = 0; | 2262 | ohci->next_config_rom[0] = 0; |
2251 | 2263 | ||
2252 | reg_write(ohci, OHCI1394_ConfigROMmap, | 2264 | reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); |
2253 | ohci->next_config_rom_bus); | ||
2254 | ret = 0; | ||
2255 | } | ||
2256 | 2265 | ||
2257 | spin_unlock_irqrestore(&ohci->lock, flags); | 2266 | spin_unlock_irqrestore(&ohci->lock, flags); |
2258 | 2267 | ||
2268 | /* If we didn't use the DMA allocation, delete it. */ | ||
2269 | if (next_config_rom != NULL) | ||
2270 | dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, | ||
2271 | next_config_rom, next_config_rom_bus); | ||
2272 | |||
2259 | /* | 2273 | /* |
2260 | * Now initiate a bus reset to have the changes take | 2274 | * Now initiate a bus reset to have the changes take |
2261 | * effect. We clean up the old config rom memory and DMA | 2275 | * effect. We clean up the old config rom memory and DMA |
@@ -2263,13 +2277,10 @@ static int ohci_set_config_rom(struct fw_card *card, | |||
2263 | * controller could need to access it before the bus reset | 2277 | * controller could need to access it before the bus reset |
2264 | * takes effect. | 2278 | * takes effect. |
2265 | */ | 2279 | */ |
2266 | if (ret == 0) | ||
2267 | fw_schedule_bus_reset(&ohci->card, true, true); | ||
2268 | else | ||
2269 | dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, | ||
2270 | next_config_rom, next_config_rom_bus); | ||
2271 | 2280 | ||
2272 | return ret; | 2281 | fw_schedule_bus_reset(&ohci->card, true, true); |
2282 | |||
2283 | return 0; | ||
2273 | } | 2284 | } |
2274 | 2285 | ||
2275 | static void ohci_send_request(struct fw_card *card, struct fw_packet *packet) | 2286 | static void ohci_send_request(struct fw_card *card, struct fw_packet *packet) |
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 11d7a72c22d..140b9525b48 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c | |||
@@ -1516,17 +1516,33 @@ bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel) | |||
1516 | } | 1516 | } |
1517 | EXPORT_SYMBOL(drm_fb_helper_initial_config); | 1517 | EXPORT_SYMBOL(drm_fb_helper_initial_config); |
1518 | 1518 | ||
1519 | bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) | 1519 | /** |
1520 | * drm_fb_helper_hotplug_event - respond to a hotplug notification by | ||
1521 | * probing all the outputs attached to the fb. | ||
1522 | * @fb_helper: the drm_fb_helper | ||
1523 | * | ||
1524 | * LOCKING: | ||
1525 | * Called at runtime, must take mode config lock. | ||
1526 | * | ||
1527 | * Scan the connectors attached to the fb_helper and try to put together a | ||
1528 | * setup after *notification of a change in output configuration. | ||
1529 | * | ||
1530 | * RETURNS: | ||
1531 | * 0 on success and a non-zero error code otherwise. | ||
1532 | */ | ||
1533 | int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) | ||
1520 | { | 1534 | { |
1535 | struct drm_device *dev = fb_helper->dev; | ||
1521 | int count = 0; | 1536 | int count = 0; |
1522 | u32 max_width, max_height, bpp_sel; | 1537 | u32 max_width, max_height, bpp_sel; |
1523 | bool bound = false, crtcs_bound = false; | 1538 | bool bound = false, crtcs_bound = false; |
1524 | struct drm_crtc *crtc; | 1539 | struct drm_crtc *crtc; |
1525 | 1540 | ||
1526 | if (!fb_helper->fb) | 1541 | if (!fb_helper->fb) |
1527 | return false; | 1542 | return 0; |
1528 | 1543 | ||
1529 | list_for_each_entry(crtc, &fb_helper->dev->mode_config.crtc_list, head) { | 1544 | mutex_lock(&dev->mode_config.mutex); |
1545 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | ||
1530 | if (crtc->fb) | 1546 | if (crtc->fb) |
1531 | crtcs_bound = true; | 1547 | crtcs_bound = true; |
1532 | if (crtc->fb == fb_helper->fb) | 1548 | if (crtc->fb == fb_helper->fb) |
@@ -1535,7 +1551,8 @@ bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) | |||
1535 | 1551 | ||
1536 | if (!bound && crtcs_bound) { | 1552 | if (!bound && crtcs_bound) { |
1537 | fb_helper->delayed_hotplug = true; | 1553 | fb_helper->delayed_hotplug = true; |
1538 | return false; | 1554 | mutex_unlock(&dev->mode_config.mutex); |
1555 | return 0; | ||
1539 | } | 1556 | } |
1540 | DRM_DEBUG_KMS("\n"); | 1557 | DRM_DEBUG_KMS("\n"); |
1541 | 1558 | ||
@@ -1546,6 +1563,7 @@ bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) | |||
1546 | count = drm_fb_helper_probe_connector_modes(fb_helper, max_width, | 1563 | count = drm_fb_helper_probe_connector_modes(fb_helper, max_width, |
1547 | max_height); | 1564 | max_height); |
1548 | drm_setup_crtcs(fb_helper); | 1565 | drm_setup_crtcs(fb_helper); |
1566 | mutex_unlock(&dev->mode_config.mutex); | ||
1549 | 1567 | ||
1550 | return drm_fb_helper_single_fb_probe(fb_helper, bpp_sel); | 1568 | return drm_fb_helper_single_fb_probe(fb_helper, bpp_sel); |
1551 | } | 1569 | } |
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 741457bd1c4..a1f12cb043d 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c | |||
@@ -932,11 +932,34 @@ EXPORT_SYMBOL(drm_vblank_put); | |||
932 | 932 | ||
933 | void drm_vblank_off(struct drm_device *dev, int crtc) | 933 | void drm_vblank_off(struct drm_device *dev, int crtc) |
934 | { | 934 | { |
935 | struct drm_pending_vblank_event *e, *t; | ||
936 | struct timeval now; | ||
935 | unsigned long irqflags; | 937 | unsigned long irqflags; |
938 | unsigned int seq; | ||
936 | 939 | ||
937 | spin_lock_irqsave(&dev->vbl_lock, irqflags); | 940 | spin_lock_irqsave(&dev->vbl_lock, irqflags); |
938 | vblank_disable_and_save(dev, crtc); | 941 | vblank_disable_and_save(dev, crtc); |
939 | DRM_WAKEUP(&dev->vbl_queue[crtc]); | 942 | DRM_WAKEUP(&dev->vbl_queue[crtc]); |
943 | |||
944 | /* Send any queued vblank events, lest the natives grow disquiet */ | ||
945 | seq = drm_vblank_count_and_time(dev, crtc, &now); | ||
946 | list_for_each_entry_safe(e, t, &dev->vblank_event_list, base.link) { | ||
947 | if (e->pipe != crtc) | ||
948 | continue; | ||
949 | DRM_DEBUG("Sending premature vblank event on disable: \ | ||
950 | wanted %d, current %d\n", | ||
951 | e->event.sequence, seq); | ||
952 | |||
953 | e->event.sequence = seq; | ||
954 | e->event.tv_sec = now.tv_sec; | ||
955 | e->event.tv_usec = now.tv_usec; | ||
956 | drm_vblank_put(dev, e->pipe); | ||
957 | list_move_tail(&e->base.link, &e->base.file_priv->event_list); | ||
958 | wake_up_interruptible(&e->base.file_priv->event_wait); | ||
959 | trace_drm_vblank_event_delivered(e->base.pid, e->pipe, | ||
960 | e->event.sequence); | ||
961 | } | ||
962 | |||
940 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); | 963 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); |
941 | } | 964 | } |
942 | EXPORT_SYMBOL(drm_vblank_off); | 965 | EXPORT_SYMBOL(drm_vblank_off); |
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 5d00b0fc0d9..959186cbf32 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c | |||
@@ -431,7 +431,7 @@ EXPORT_SYMBOL(drm_mm_search_free_in_range); | |||
431 | void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new) | 431 | void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new) |
432 | { | 432 | { |
433 | list_replace(&old->node_list, &new->node_list); | 433 | list_replace(&old->node_list, &new->node_list); |
434 | list_replace(&old->node_list, &new->hole_stack); | 434 | list_replace(&old->hole_stack, &new->hole_stack); |
435 | new->hole_follows = old->hole_follows; | 435 | new->hole_follows = old->hole_follows; |
436 | new->mm = old->mm; | 436 | new->mm = old->mm; |
437 | new->start = old->start; | 437 | new->start = old->start; |
@@ -699,8 +699,8 @@ int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm) | |||
699 | entry->size); | 699 | entry->size); |
700 | total_used += entry->size; | 700 | total_used += entry->size; |
701 | if (entry->hole_follows) { | 701 | if (entry->hole_follows) { |
702 | hole_start = drm_mm_hole_node_start(&mm->head_node); | 702 | hole_start = drm_mm_hole_node_start(entry); |
703 | hole_end = drm_mm_hole_node_end(&mm->head_node); | 703 | hole_end = drm_mm_hole_node_end(entry); |
704 | hole_size = hole_end - hole_start; | 704 | hole_size = hole_end - hole_start; |
705 | seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n", | 705 | seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n", |
706 | hole_start, hole_end, hole_size); | 706 | hole_start, hole_end, hole_size); |
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index c34a8dd31d0..32d1b3e829c 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
@@ -49,7 +49,7 @@ module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600); | |||
49 | unsigned int i915_powersave = 1; | 49 | unsigned int i915_powersave = 1; |
50 | module_param_named(powersave, i915_powersave, int, 0600); | 50 | module_param_named(powersave, i915_powersave, int, 0600); |
51 | 51 | ||
52 | unsigned int i915_semaphores = 1; | 52 | unsigned int i915_semaphores = 0; |
53 | module_param_named(semaphores, i915_semaphores, int, 0600); | 53 | module_param_named(semaphores, i915_semaphores, int, 0600); |
54 | 54 | ||
55 | unsigned int i915_enable_rc6 = 0; | 55 | unsigned int i915_enable_rc6 = 0; |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index e522c702b04..2166ee071dd 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -5605,9 +5605,9 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc) | |||
5605 | intel_clock_t clock; | 5605 | intel_clock_t clock; |
5606 | 5606 | ||
5607 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) | 5607 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) |
5608 | fp = FP0(pipe); | 5608 | fp = I915_READ(FP0(pipe)); |
5609 | else | 5609 | else |
5610 | fp = FP1(pipe); | 5610 | fp = I915_READ(FP1(pipe)); |
5611 | 5611 | ||
5612 | clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT; | 5612 | clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT; |
5613 | if (IS_PINEVIEW(dev)) { | 5613 | if (IS_PINEVIEW(dev)) { |
@@ -6579,8 +6579,10 @@ intel_user_framebuffer_create(struct drm_device *dev, | |||
6579 | return ERR_PTR(-ENOENT); | 6579 | return ERR_PTR(-ENOENT); |
6580 | 6580 | ||
6581 | intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); | 6581 | intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); |
6582 | if (!intel_fb) | 6582 | if (!intel_fb) { |
6583 | drm_gem_object_unreference_unlocked(&obj->base); | ||
6583 | return ERR_PTR(-ENOMEM); | 6584 | return ERR_PTR(-ENOMEM); |
6585 | } | ||
6584 | 6586 | ||
6585 | ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); | 6587 | ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); |
6586 | if (ret) { | 6588 | if (ret) { |
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index cb8578b7e44..a4d80314e7f 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
@@ -1470,7 +1470,8 @@ intel_dp_link_down(struct intel_dp *intel_dp) | |||
1470 | 1470 | ||
1471 | if (!HAS_PCH_CPT(dev) && | 1471 | if (!HAS_PCH_CPT(dev) && |
1472 | I915_READ(intel_dp->output_reg) & DP_PIPEB_SELECT) { | 1472 | I915_READ(intel_dp->output_reg) & DP_PIPEB_SELECT) { |
1473 | struct intel_crtc *intel_crtc = to_intel_crtc(intel_dp->base.base.crtc); | 1473 | struct drm_crtc *crtc = intel_dp->base.base.crtc; |
1474 | |||
1474 | /* Hardware workaround: leaving our transcoder select | 1475 | /* Hardware workaround: leaving our transcoder select |
1475 | * set to transcoder B while it's off will prevent the | 1476 | * set to transcoder B while it's off will prevent the |
1476 | * corresponding HDMI output on transcoder A. | 1477 | * corresponding HDMI output on transcoder A. |
@@ -1485,7 +1486,19 @@ intel_dp_link_down(struct intel_dp *intel_dp) | |||
1485 | /* Changes to enable or select take place the vblank | 1486 | /* Changes to enable or select take place the vblank |
1486 | * after being written. | 1487 | * after being written. |
1487 | */ | 1488 | */ |
1488 | intel_wait_for_vblank(dev, intel_crtc->pipe); | 1489 | if (crtc == NULL) { |
1490 | /* We can arrive here never having been attached | ||
1491 | * to a CRTC, for instance, due to inheriting | ||
1492 | * random state from the BIOS. | ||
1493 | * | ||
1494 | * If the pipe is not running, play safe and | ||
1495 | * wait for the clocks to stabilise before | ||
1496 | * continuing. | ||
1497 | */ | ||
1498 | POSTING_READ(intel_dp->output_reg); | ||
1499 | msleep(50); | ||
1500 | } else | ||
1501 | intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe); | ||
1489 | } | 1502 | } |
1490 | 1503 | ||
1491 | I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN); | 1504 | I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN); |
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index a562bd2648c..67cb076d271 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c | |||
@@ -539,6 +539,9 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val, | |||
539 | struct drm_device *dev = dev_priv->dev; | 539 | struct drm_device *dev = dev_priv->dev; |
540 | struct drm_connector *connector = dev_priv->int_lvds_connector; | 540 | struct drm_connector *connector = dev_priv->int_lvds_connector; |
541 | 541 | ||
542 | if (dev->switch_power_state != DRM_SWITCH_POWER_ON) | ||
543 | return NOTIFY_OK; | ||
544 | |||
542 | /* | 545 | /* |
543 | * check and update the status of LVDS connector after receiving | 546 | * check and update the status of LVDS connector after receiving |
544 | * the LID nofication event. | 547 | * the LID nofication event. |
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c index 5045f8b921d..c3e953b0899 100644 --- a/drivers/gpu/drm/nouveau/nouveau_mem.c +++ b/drivers/gpu/drm/nouveau/nouveau_mem.c | |||
@@ -152,8 +152,6 @@ nouveau_mem_vram_fini(struct drm_device *dev) | |||
152 | { | 152 | { |
153 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 153 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
154 | 154 | ||
155 | nouveau_bo_ref(NULL, &dev_priv->vga_ram); | ||
156 | |||
157 | ttm_bo_device_release(&dev_priv->ttm.bdev); | 155 | ttm_bo_device_release(&dev_priv->ttm.bdev); |
158 | 156 | ||
159 | nouveau_ttm_global_release(dev_priv); | 157 | nouveau_ttm_global_release(dev_priv); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c index 4bce801bc58..c77111eca6a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c | |||
@@ -42,7 +42,8 @@ nouveau_sgdma_populate(struct ttm_backend *be, unsigned long num_pages, | |||
42 | 42 | ||
43 | nvbe->nr_pages = 0; | 43 | nvbe->nr_pages = 0; |
44 | while (num_pages--) { | 44 | while (num_pages--) { |
45 | if (dma_addrs[nvbe->nr_pages] != DMA_ERROR_CODE) { | 45 | /* this code path isn't called and is incorrect anyways */ |
46 | if (0) { /*dma_addrs[nvbe->nr_pages] != DMA_ERROR_CODE)*/ | ||
46 | nvbe->pages[nvbe->nr_pages] = | 47 | nvbe->pages[nvbe->nr_pages] = |
47 | dma_addrs[nvbe->nr_pages]; | 48 | dma_addrs[nvbe->nr_pages]; |
48 | nvbe->ttm_alloced[nvbe->nr_pages] = true; | 49 | nvbe->ttm_alloced[nvbe->nr_pages] = true; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c index a30adec5bea..915fbce8959 100644 --- a/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/drivers/gpu/drm/nouveau/nouveau_state.c | |||
@@ -768,6 +768,11 @@ static void nouveau_card_takedown(struct drm_device *dev) | |||
768 | engine->mc.takedown(dev); | 768 | engine->mc.takedown(dev); |
769 | engine->display.late_takedown(dev); | 769 | engine->display.late_takedown(dev); |
770 | 770 | ||
771 | if (dev_priv->vga_ram) { | ||
772 | nouveau_bo_unpin(dev_priv->vga_ram); | ||
773 | nouveau_bo_ref(NULL, &dev_priv->vga_ram); | ||
774 | } | ||
775 | |||
771 | mutex_lock(&dev->struct_mutex); | 776 | mutex_lock(&dev->struct_mutex); |
772 | ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM); | 777 | ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM); |
773 | ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_TT); | 778 | ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_TT); |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index e9bc135d918..9073e3bfb08 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c | |||
@@ -862,9 +862,15 @@ int evergreen_pcie_gart_enable(struct radeon_device *rdev) | |||
862 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | | 862 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
863 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU | | 863 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU | |
864 | EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); | 864 | EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); |
865 | WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); | 865 | if (rdev->flags & RADEON_IS_IGP) { |
866 | WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); | 866 | WREG32(FUS_MC_VM_MD_L1_TLB0_CNTL, tmp); |
867 | WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); | 867 | WREG32(FUS_MC_VM_MD_L1_TLB1_CNTL, tmp); |
868 | WREG32(FUS_MC_VM_MD_L1_TLB2_CNTL, tmp); | ||
869 | } else { | ||
870 | WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); | ||
871 | WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); | ||
872 | WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); | ||
873 | } | ||
868 | WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); | 874 | WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); |
869 | WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); | 875 | WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); |
870 | WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); | 876 | WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); |
@@ -1774,7 +1780,10 @@ static void evergreen_gpu_init(struct radeon_device *rdev) | |||
1774 | 1780 | ||
1775 | 1781 | ||
1776 | mc_shared_chmap = RREG32(MC_SHARED_CHMAP); | 1782 | mc_shared_chmap = RREG32(MC_SHARED_CHMAP); |
1777 | mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); | 1783 | if (rdev->flags & RADEON_IS_IGP) |
1784 | mc_arb_ramcfg = RREG32(FUS_MC_ARB_RAMCFG); | ||
1785 | else | ||
1786 | mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); | ||
1778 | 1787 | ||
1779 | switch (rdev->config.evergreen.max_tile_pipes) { | 1788 | switch (rdev->config.evergreen.max_tile_pipes) { |
1780 | case 1: | 1789 | case 1: |
@@ -2923,11 +2932,6 @@ static int evergreen_startup(struct radeon_device *rdev) | |||
2923 | rdev->asic->copy = NULL; | 2932 | rdev->asic->copy = NULL; |
2924 | dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r); | 2933 | dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r); |
2925 | } | 2934 | } |
2926 | /* XXX: ontario has problems blitting to gart at the moment */ | ||
2927 | if (rdev->family == CHIP_PALM) { | ||
2928 | rdev->asic->copy = NULL; | ||
2929 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); | ||
2930 | } | ||
2931 | 2935 | ||
2932 | /* allocate wb buffer */ | 2936 | /* allocate wb buffer */ |
2933 | r = radeon_wb_init(rdev); | 2937 | r = radeon_wb_init(rdev); |
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h index 9aaa3f0c937..fc40e0cc345 100644 --- a/drivers/gpu/drm/radeon/evergreend.h +++ b/drivers/gpu/drm/radeon/evergreend.h | |||
@@ -200,6 +200,7 @@ | |||
200 | #define BURSTLENGTH_SHIFT 9 | 200 | #define BURSTLENGTH_SHIFT 9 |
201 | #define BURSTLENGTH_MASK 0x00000200 | 201 | #define BURSTLENGTH_MASK 0x00000200 |
202 | #define CHANSIZE_OVERRIDE (1 << 11) | 202 | #define CHANSIZE_OVERRIDE (1 << 11) |
203 | #define FUS_MC_ARB_RAMCFG 0x2768 | ||
203 | #define MC_VM_AGP_TOP 0x2028 | 204 | #define MC_VM_AGP_TOP 0x2028 |
204 | #define MC_VM_AGP_BOT 0x202C | 205 | #define MC_VM_AGP_BOT 0x202C |
205 | #define MC_VM_AGP_BASE 0x2030 | 206 | #define MC_VM_AGP_BASE 0x2030 |
@@ -221,6 +222,11 @@ | |||
221 | #define MC_VM_MD_L1_TLB0_CNTL 0x2654 | 222 | #define MC_VM_MD_L1_TLB0_CNTL 0x2654 |
222 | #define MC_VM_MD_L1_TLB1_CNTL 0x2658 | 223 | #define MC_VM_MD_L1_TLB1_CNTL 0x2658 |
223 | #define MC_VM_MD_L1_TLB2_CNTL 0x265C | 224 | #define MC_VM_MD_L1_TLB2_CNTL 0x265C |
225 | |||
226 | #define FUS_MC_VM_MD_L1_TLB0_CNTL 0x265C | ||
227 | #define FUS_MC_VM_MD_L1_TLB1_CNTL 0x2660 | ||
228 | #define FUS_MC_VM_MD_L1_TLB2_CNTL 0x2664 | ||
229 | |||
224 | #define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203C | 230 | #define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203C |
225 | #define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038 | 231 | #define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038 |
226 | #define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034 | 232 | #define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034 |
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c index 7aade20f63a..3d8a7634bbe 100644 --- a/drivers/gpu/drm/radeon/ni.c +++ b/drivers/gpu/drm/radeon/ni.c | |||
@@ -674,7 +674,7 @@ static void cayman_gpu_init(struct radeon_device *rdev) | |||
674 | 674 | ||
675 | cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE); | 675 | cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE); |
676 | cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG); | 676 | cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG); |
677 | cgts_tcc_disable = RREG32(CGTS_TCC_DISABLE); | 677 | cgts_tcc_disable = 0xff000000; |
678 | gc_user_rb_backend_disable = RREG32(GC_USER_RB_BACKEND_DISABLE); | 678 | gc_user_rb_backend_disable = RREG32(GC_USER_RB_BACKEND_DISABLE); |
679 | gc_user_shader_pipe_config = RREG32(GC_USER_SHADER_PIPE_CONFIG); | 679 | gc_user_shader_pipe_config = RREG32(GC_USER_SHADER_PIPE_CONFIG); |
680 | cgts_user_tcc_disable = RREG32(CGTS_USER_TCC_DISABLE); | 680 | cgts_user_tcc_disable = RREG32(CGTS_USER_TCC_DISABLE); |
@@ -871,7 +871,7 @@ static void cayman_gpu_init(struct radeon_device *rdev) | |||
871 | 871 | ||
872 | smx_dc_ctl0 = RREG32(SMX_DC_CTL0); | 872 | smx_dc_ctl0 = RREG32(SMX_DC_CTL0); |
873 | smx_dc_ctl0 &= ~NUMBER_OF_SETS(0x1ff); | 873 | smx_dc_ctl0 &= ~NUMBER_OF_SETS(0x1ff); |
874 | smx_dc_ctl0 |= NUMBER_OF_SETS(rdev->config.evergreen.sx_num_of_sets); | 874 | smx_dc_ctl0 |= NUMBER_OF_SETS(rdev->config.cayman.sx_num_of_sets); |
875 | WREG32(SMX_DC_CTL0, smx_dc_ctl0); | 875 | WREG32(SMX_DC_CTL0, smx_dc_ctl0); |
876 | 876 | ||
877 | WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4) | CRC_SIMD_ID_WADDR_DISABLE); | 877 | WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4) | CRC_SIMD_ID_WADDR_DISABLE); |
@@ -887,20 +887,20 @@ static void cayman_gpu_init(struct radeon_device *rdev) | |||
887 | 887 | ||
888 | WREG32(TA_CNTL_AUX, DISABLE_CUBE_ANISO); | 888 | WREG32(TA_CNTL_AUX, DISABLE_CUBE_ANISO); |
889 | 889 | ||
890 | WREG32(SX_EXPORT_BUFFER_SIZES, (COLOR_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_size / 4) - 1) | | 890 | WREG32(SX_EXPORT_BUFFER_SIZES, (COLOR_BUFFER_SIZE((rdev->config.cayman.sx_max_export_size / 4) - 1) | |
891 | POSITION_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_pos_size / 4) - 1) | | 891 | POSITION_BUFFER_SIZE((rdev->config.cayman.sx_max_export_pos_size / 4) - 1) | |
892 | SMX_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_smx_size / 4) - 1))); | 892 | SMX_BUFFER_SIZE((rdev->config.cayman.sx_max_export_smx_size / 4) - 1))); |
893 | 893 | ||
894 | WREG32(PA_SC_FIFO_SIZE, (SC_PRIM_FIFO_SIZE(rdev->config.evergreen.sc_prim_fifo_size) | | 894 | WREG32(PA_SC_FIFO_SIZE, (SC_PRIM_FIFO_SIZE(rdev->config.cayman.sc_prim_fifo_size) | |
895 | SC_HIZ_TILE_FIFO_SIZE(rdev->config.evergreen.sc_hiz_tile_fifo_size) | | 895 | SC_HIZ_TILE_FIFO_SIZE(rdev->config.cayman.sc_hiz_tile_fifo_size) | |
896 | SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.evergreen.sc_earlyz_tile_fifo_size))); | 896 | SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.cayman.sc_earlyz_tile_fifo_size))); |
897 | 897 | ||
898 | 898 | ||
899 | WREG32(VGT_NUM_INSTANCES, 1); | 899 | WREG32(VGT_NUM_INSTANCES, 1); |
900 | 900 | ||
901 | WREG32(CP_PERFMON_CNTL, 0); | 901 | WREG32(CP_PERFMON_CNTL, 0); |
902 | 902 | ||
903 | WREG32(SQ_MS_FIFO_SIZES, (CACHE_FIFO_SIZE(16 * rdev->config.evergreen.sq_num_cf_insts) | | 903 | WREG32(SQ_MS_FIFO_SIZES, (CACHE_FIFO_SIZE(16 * rdev->config.cayman.sq_num_cf_insts) | |
904 | FETCH_FIFO_HIWATER(0x4) | | 904 | FETCH_FIFO_HIWATER(0x4) | |
905 | DONE_FIFO_HIWATER(0xe0) | | 905 | DONE_FIFO_HIWATER(0xe0) | |
906 | ALU_UPDATE_FIFO_HIWATER(0x8))); | 906 | ALU_UPDATE_FIFO_HIWATER(0x8))); |
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index f5d12fb103f..90dfb2b8cf0 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c | |||
@@ -431,7 +431,7 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev, | |||
431 | } | 431 | } |
432 | } | 432 | } |
433 | 433 | ||
434 | /* Acer laptop (Acer TravelMate 5730G) has an HDMI port | 434 | /* Acer laptop (Acer TravelMate 5730/5730G) has an HDMI port |
435 | * on the laptop and a DVI port on the docking station and | 435 | * on the laptop and a DVI port on the docking station and |
436 | * both share the same encoder, hpd pin, and ddc line. | 436 | * both share the same encoder, hpd pin, and ddc line. |
437 | * So while the bios table is technically correct, | 437 | * So while the bios table is technically correct, |
@@ -440,7 +440,7 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev, | |||
440 | * with different crtcs which isn't possible on the hardware | 440 | * with different crtcs which isn't possible on the hardware |
441 | * side and leaves no crtcs for LVDS or VGA. | 441 | * side and leaves no crtcs for LVDS or VGA. |
442 | */ | 442 | */ |
443 | if ((dev->pdev->device == 0x95c4) && | 443 | if (((dev->pdev->device == 0x95c4) || (dev->pdev->device == 0x9591)) && |
444 | (dev->pdev->subsystem_vendor == 0x1025) && | 444 | (dev->pdev->subsystem_vendor == 0x1025) && |
445 | (dev->pdev->subsystem_device == 0x013c)) { | 445 | (dev->pdev->subsystem_device == 0x013c)) { |
446 | if ((*connector_type == DRM_MODE_CONNECTOR_DVII) && | 446 | if ((*connector_type == DRM_MODE_CONNECTOR_DVII) && |
@@ -1574,9 +1574,17 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct | |||
1574 | ATOM_FAKE_EDID_PATCH_RECORD *fake_edid_record; | 1574 | ATOM_FAKE_EDID_PATCH_RECORD *fake_edid_record; |
1575 | ATOM_PANEL_RESOLUTION_PATCH_RECORD *panel_res_record; | 1575 | ATOM_PANEL_RESOLUTION_PATCH_RECORD *panel_res_record; |
1576 | bool bad_record = false; | 1576 | bool bad_record = false; |
1577 | u8 *record = (u8 *)(mode_info->atom_context->bios + | 1577 | u8 *record; |
1578 | data_offset + | 1578 | |
1579 | le16_to_cpu(lvds_info->info.usModePatchTableOffset)); | 1579 | if ((frev == 1) && (crev < 2)) |
1580 | /* absolute */ | ||
1581 | record = (u8 *)(mode_info->atom_context->bios + | ||
1582 | le16_to_cpu(lvds_info->info.usModePatchTableOffset)); | ||
1583 | else | ||
1584 | /* relative */ | ||
1585 | record = (u8 *)(mode_info->atom_context->bios + | ||
1586 | data_offset + | ||
1587 | le16_to_cpu(lvds_info->info.usModePatchTableOffset)); | ||
1580 | while (*record != ATOM_RECORD_END_TYPE) { | 1588 | while (*record != ATOM_RECORD_END_TYPE) { |
1581 | switch (*record) { | 1589 | switch (*record) { |
1582 | case LCD_MODE_PATCH_RECORD_MODE_TYPE: | 1590 | case LCD_MODE_PATCH_RECORD_MODE_TYPE: |
@@ -1599,9 +1607,10 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct | |||
1599 | memcpy((u8 *)edid, (u8 *)&fake_edid_record->ucFakeEDIDString[0], | 1607 | memcpy((u8 *)edid, (u8 *)&fake_edid_record->ucFakeEDIDString[0], |
1600 | fake_edid_record->ucFakeEDIDLength); | 1608 | fake_edid_record->ucFakeEDIDLength); |
1601 | 1609 | ||
1602 | if (drm_edid_is_valid(edid)) | 1610 | if (drm_edid_is_valid(edid)) { |
1603 | rdev->mode_info.bios_hardcoded_edid = edid; | 1611 | rdev->mode_info.bios_hardcoded_edid = edid; |
1604 | else | 1612 | rdev->mode_info.bios_hardcoded_edid_size = edid_size; |
1613 | } else | ||
1605 | kfree(edid); | 1614 | kfree(edid); |
1606 | } | 1615 | } |
1607 | } | 1616 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c index ed5dfe58f29..9d95792bea3 100644 --- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c +++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c | |||
@@ -15,6 +15,9 @@ | |||
15 | #define ATPX_VERSION 0 | 15 | #define ATPX_VERSION 0 |
16 | #define ATPX_GPU_PWR 2 | 16 | #define ATPX_GPU_PWR 2 |
17 | #define ATPX_MUX_SELECT 3 | 17 | #define ATPX_MUX_SELECT 3 |
18 | #define ATPX_I2C_MUX_SELECT 4 | ||
19 | #define ATPX_SWITCH_START 5 | ||
20 | #define ATPX_SWITCH_END 6 | ||
18 | 21 | ||
19 | #define ATPX_INTEGRATED 0 | 22 | #define ATPX_INTEGRATED 0 |
20 | #define ATPX_DISCRETE 1 | 23 | #define ATPX_DISCRETE 1 |
@@ -149,13 +152,35 @@ static int radeon_atpx_switch_mux(acpi_handle handle, int mux_id) | |||
149 | return radeon_atpx_execute(handle, ATPX_MUX_SELECT, mux_id); | 152 | return radeon_atpx_execute(handle, ATPX_MUX_SELECT, mux_id); |
150 | } | 153 | } |
151 | 154 | ||
155 | static int radeon_atpx_switch_i2c_mux(acpi_handle handle, int mux_id) | ||
156 | { | ||
157 | return radeon_atpx_execute(handle, ATPX_I2C_MUX_SELECT, mux_id); | ||
158 | } | ||
159 | |||
160 | static int radeon_atpx_switch_start(acpi_handle handle, int gpu_id) | ||
161 | { | ||
162 | return radeon_atpx_execute(handle, ATPX_SWITCH_START, gpu_id); | ||
163 | } | ||
164 | |||
165 | static int radeon_atpx_switch_end(acpi_handle handle, int gpu_id) | ||
166 | { | ||
167 | return radeon_atpx_execute(handle, ATPX_SWITCH_END, gpu_id); | ||
168 | } | ||
152 | 169 | ||
153 | static int radeon_atpx_switchto(enum vga_switcheroo_client_id id) | 170 | static int radeon_atpx_switchto(enum vga_switcheroo_client_id id) |
154 | { | 171 | { |
172 | int gpu_id; | ||
173 | |||
155 | if (id == VGA_SWITCHEROO_IGD) | 174 | if (id == VGA_SWITCHEROO_IGD) |
156 | radeon_atpx_switch_mux(radeon_atpx_priv.atpx_handle, 0); | 175 | gpu_id = ATPX_INTEGRATED; |
157 | else | 176 | else |
158 | radeon_atpx_switch_mux(radeon_atpx_priv.atpx_handle, 1); | 177 | gpu_id = ATPX_DISCRETE; |
178 | |||
179 | radeon_atpx_switch_start(radeon_atpx_priv.atpx_handle, gpu_id); | ||
180 | radeon_atpx_switch_mux(radeon_atpx_priv.atpx_handle, gpu_id); | ||
181 | radeon_atpx_switch_i2c_mux(radeon_atpx_priv.atpx_handle, gpu_id); | ||
182 | radeon_atpx_switch_end(radeon_atpx_priv.atpx_handle, gpu_id); | ||
183 | |||
159 | return 0; | 184 | return 0; |
160 | } | 185 | } |
161 | 186 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c index bdf2fa1189a..3189a7efb2e 100644 --- a/drivers/gpu/drm/radeon/radeon_cursor.c +++ b/drivers/gpu/drm/radeon/radeon_cursor.c | |||
@@ -167,9 +167,6 @@ int radeon_crtc_cursor_set(struct drm_crtc *crtc, | |||
167 | return -EINVAL; | 167 | return -EINVAL; |
168 | } | 168 | } |
169 | 169 | ||
170 | radeon_crtc->cursor_width = width; | ||
171 | radeon_crtc->cursor_height = height; | ||
172 | |||
173 | obj = drm_gem_object_lookup(crtc->dev, file_priv, handle); | 170 | obj = drm_gem_object_lookup(crtc->dev, file_priv, handle); |
174 | if (!obj) { | 171 | if (!obj) { |
175 | DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, radeon_crtc->crtc_id); | 172 | DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, radeon_crtc->crtc_id); |
@@ -180,6 +177,9 @@ int radeon_crtc_cursor_set(struct drm_crtc *crtc, | |||
180 | if (ret) | 177 | if (ret) |
181 | goto fail; | 178 | goto fail; |
182 | 179 | ||
180 | radeon_crtc->cursor_width = width; | ||
181 | radeon_crtc->cursor_height = height; | ||
182 | |||
183 | radeon_lock_cursor(crtc, true); | 183 | radeon_lock_cursor(crtc, true); |
184 | /* XXX only 27 bit offset for legacy cursor */ | 184 | /* XXX only 27 bit offset for legacy cursor */ |
185 | radeon_set_cursor(crtc, obj, gpu_addr); | 185 | radeon_set_cursor(crtc, obj, gpu_addr); |
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index 8a955bbdb60..a533f52fd16 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c | |||
@@ -181,9 +181,9 @@ int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, | |||
181 | p = t / (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); | 181 | p = t / (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); |
182 | 182 | ||
183 | for (i = 0; i < pages; i++, p++) { | 183 | for (i = 0; i < pages; i++, p++) { |
184 | /* On TTM path, we only use the DMA API if TTM_PAGE_FLAG_DMA32 | 184 | /* we reverted the patch using dma_addr in TTM for now but this |
185 | * is requested. */ | 185 | * code stops building on alpha so just comment it out for now */ |
186 | if (dma_addr[i] != DMA_ERROR_CODE) { | 186 | if (0) { /*dma_addr[i] != DMA_ERROR_CODE) */ |
187 | rdev->gart.ttm_alloced[p] = true; | 187 | rdev->gart.ttm_alloced[p] = true; |
188 | rdev->gart.pages_addr[p] = dma_addr[i]; | 188 | rdev->gart.pages_addr[p] = dma_addr[i]; |
189 | } else { | 189 | } else { |
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index 871df0376b1..bd58af65858 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -234,6 +234,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
234 | return -EINVAL; | 234 | return -EINVAL; |
235 | } | 235 | } |
236 | break; | 236 | break; |
237 | case RADEON_INFO_FUSION_GART_WORKING: | ||
238 | value = 1; | ||
239 | break; | ||
237 | default: | 240 | default: |
238 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); | 241 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); |
239 | return -EINVAL; | 242 | return -EINVAL; |
diff --git a/drivers/gpu/drm/radeon/reg_srcs/cayman b/drivers/gpu/drm/radeon/reg_srcs/cayman index 6334f8ac120..0aa8e85a945 100644 --- a/drivers/gpu/drm/radeon/reg_srcs/cayman +++ b/drivers/gpu/drm/radeon/reg_srcs/cayman | |||
@@ -33,6 +33,7 @@ cayman 0x9400 | |||
33 | 0x00008E48 SQ_EX_ALLOC_TABLE_SLOTS | 33 | 0x00008E48 SQ_EX_ALLOC_TABLE_SLOTS |
34 | 0x00009100 SPI_CONFIG_CNTL | 34 | 0x00009100 SPI_CONFIG_CNTL |
35 | 0x0000913C SPI_CONFIG_CNTL_1 | 35 | 0x0000913C SPI_CONFIG_CNTL_1 |
36 | 0x00009508 TA_CNTL_AUX | ||
36 | 0x00009830 DB_DEBUG | 37 | 0x00009830 DB_DEBUG |
37 | 0x00009834 DB_DEBUG2 | 38 | 0x00009834 DB_DEBUG2 |
38 | 0x00009838 DB_DEBUG3 | 39 | 0x00009838 DB_DEBUG3 |
diff --git a/drivers/gpu/drm/radeon/reg_srcs/evergreen b/drivers/gpu/drm/radeon/reg_srcs/evergreen index 7e1637176e0..0e28cae7ea4 100644 --- a/drivers/gpu/drm/radeon/reg_srcs/evergreen +++ b/drivers/gpu/drm/radeon/reg_srcs/evergreen | |||
@@ -46,6 +46,7 @@ evergreen 0x9400 | |||
46 | 0x00008E48 SQ_EX_ALLOC_TABLE_SLOTS | 46 | 0x00008E48 SQ_EX_ALLOC_TABLE_SLOTS |
47 | 0x00009100 SPI_CONFIG_CNTL | 47 | 0x00009100 SPI_CONFIG_CNTL |
48 | 0x0000913C SPI_CONFIG_CNTL_1 | 48 | 0x0000913C SPI_CONFIG_CNTL_1 |
49 | 0x00009508 TA_CNTL_AUX | ||
49 | 0x00009700 VC_CNTL | 50 | 0x00009700 VC_CNTL |
50 | 0x00009714 VC_ENHANCE | 51 | 0x00009714 VC_ENHANCE |
51 | 0x00009830 DB_DEBUG | 52 | 0x00009830 DB_DEBUG |
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index e01cacba685..498b284e5ef 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c | |||
@@ -219,9 +219,6 @@ static int vga_switchto_stage1(struct vga_switcheroo_client *new_client) | |||
219 | int i; | 219 | int i; |
220 | struct vga_switcheroo_client *active = NULL; | 220 | struct vga_switcheroo_client *active = NULL; |
221 | 221 | ||
222 | if (new_client->active == true) | ||
223 | return 0; | ||
224 | |||
225 | for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) { | 222 | for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) { |
226 | if (vgasr_priv.clients[i].active == true) { | 223 | if (vgasr_priv.clients[i].active == true) { |
227 | active = &vgasr_priv.clients[i]; | 224 | active = &vgasr_priv.clients[i]; |
@@ -372,6 +369,9 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf, | |||
372 | goto out; | 369 | goto out; |
373 | } | 370 | } |
374 | 371 | ||
372 | if (client->active == true) | ||
373 | goto out; | ||
374 | |||
375 | /* okay we want a switch - test if devices are willing to switch */ | 375 | /* okay we want a switch - test if devices are willing to switch */ |
376 | can_switch = true; | 376 | can_switch = true; |
377 | for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) { | 377 | for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) { |
diff --git a/drivers/hwmon/twl4030-madc-hwmon.c b/drivers/hwmon/twl4030-madc-hwmon.c index de5819199e2..57240740b16 100644 --- a/drivers/hwmon/twl4030-madc-hwmon.c +++ b/drivers/hwmon/twl4030-madc-hwmon.c | |||
@@ -98,7 +98,6 @@ static const struct attribute_group twl4030_madc_group = { | |||
98 | static int __devinit twl4030_madc_hwmon_probe(struct platform_device *pdev) | 98 | static int __devinit twl4030_madc_hwmon_probe(struct platform_device *pdev) |
99 | { | 99 | { |
100 | int ret; | 100 | int ret; |
101 | int status; | ||
102 | struct device *hwmon; | 101 | struct device *hwmon; |
103 | 102 | ||
104 | ret = sysfs_create_group(&pdev->dev.kobj, &twl4030_madc_group); | 103 | ret = sysfs_create_group(&pdev->dev.kobj, &twl4030_madc_group); |
@@ -107,7 +106,7 @@ static int __devinit twl4030_madc_hwmon_probe(struct platform_device *pdev) | |||
107 | hwmon = hwmon_device_register(&pdev->dev); | 106 | hwmon = hwmon_device_register(&pdev->dev); |
108 | if (IS_ERR(hwmon)) { | 107 | if (IS_ERR(hwmon)) { |
109 | dev_err(&pdev->dev, "hwmon_device_register failed.\n"); | 108 | dev_err(&pdev->dev, "hwmon_device_register failed.\n"); |
110 | status = PTR_ERR(hwmon); | 109 | ret = PTR_ERR(hwmon); |
111 | goto err_reg; | 110 | goto err_reg; |
112 | } | 111 | } |
113 | 112 | ||
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 72c0415f6f9..455e909bc76 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -134,10 +134,15 @@ | |||
134 | SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | \ | 134 | SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | \ |
135 | SMBHSTSTS_INTR) | 135 | SMBHSTSTS_INTR) |
136 | 136 | ||
137 | /* Older devices have their ID defined in <linux/pci_ids.h> */ | ||
138 | #define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22 | ||
139 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS 0x1d22 | ||
137 | /* Patsburg also has three 'Integrated Device Function' SMBus controllers */ | 140 | /* Patsburg also has three 'Integrated Device Function' SMBus controllers */ |
138 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0 0x1d70 | 141 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0 0x1d70 |
139 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1 0x1d71 | 142 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1 0x1d71 |
140 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2 0x1d72 | 143 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2 0x1d72 |
144 | #define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330 | ||
145 | #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30 | ||
141 | 146 | ||
142 | struct i801_priv { | 147 | struct i801_priv { |
143 | struct i2c_adapter adapter; | 148 | struct i2c_adapter adapter; |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 75b984c519a..107397a606b 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -560,15 +560,18 @@ static struct i2c_adapter mpc_ops = { | |||
560 | .timeout = HZ, | 560 | .timeout = HZ, |
561 | }; | 561 | }; |
562 | 562 | ||
563 | static const struct of_device_id mpc_i2c_of_match[]; | ||
563 | static int __devinit fsl_i2c_probe(struct platform_device *op) | 564 | static int __devinit fsl_i2c_probe(struct platform_device *op) |
564 | { | 565 | { |
566 | const struct of_device_id *match; | ||
565 | struct mpc_i2c *i2c; | 567 | struct mpc_i2c *i2c; |
566 | const u32 *prop; | 568 | const u32 *prop; |
567 | u32 clock = MPC_I2C_CLOCK_LEGACY; | 569 | u32 clock = MPC_I2C_CLOCK_LEGACY; |
568 | int result = 0; | 570 | int result = 0; |
569 | int plen; | 571 | int plen; |
570 | 572 | ||
571 | if (!op->dev.of_match) | 573 | match = of_match_device(mpc_i2c_of_match, &op->dev); |
574 | if (!match) | ||
572 | return -EINVAL; | 575 | return -EINVAL; |
573 | 576 | ||
574 | i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); | 577 | i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); |
@@ -605,8 +608,8 @@ static int __devinit fsl_i2c_probe(struct platform_device *op) | |||
605 | clock = *prop; | 608 | clock = *prop; |
606 | } | 609 | } |
607 | 610 | ||
608 | if (op->dev.of_match->data) { | 611 | if (match->data) { |
609 | struct mpc_i2c_data *data = op->dev.of_match->data; | 612 | struct mpc_i2c_data *data = match->data; |
610 | data->setup(op->dev.of_node, i2c, clock, data->prescaler); | 613 | data->setup(op->dev.of_node, i2c, clock, data->prescaler); |
611 | } else { | 614 | } else { |
612 | /* Backwards compatibility */ | 615 | /* Backwards compatibility */ |
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 0eb1515541e..2dbba163b10 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* ------------------------------------------------------------------------ * | 1 | /* ------------------------------------------------------------------------ * |
2 | * i2c-parport.c I2C bus over parallel port * | 2 | * i2c-parport.c I2C bus over parallel port * |
3 | * ------------------------------------------------------------------------ * | 3 | * ------------------------------------------------------------------------ * |
4 | Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org> | 4 | Copyright (C) 2003-2011 Jean Delvare <khali@linux-fr.org> |
5 | 5 | ||
6 | Based on older i2c-philips-par.c driver | 6 | Based on older i2c-philips-par.c driver |
7 | Copyright (C) 1995-2000 Simon G. Vogl | 7 | Copyright (C) 1995-2000 Simon G. Vogl |
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/i2c-algo-bit.h> | 33 | #include <linux/i2c-algo-bit.h> |
34 | #include <linux/i2c-smbus.h> | 34 | #include <linux/i2c-smbus.h> |
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | #include <linux/list.h> | ||
37 | #include <linux/mutex.h> | ||
36 | #include "i2c-parport.h" | 38 | #include "i2c-parport.h" |
37 | 39 | ||
38 | /* ----- Device list ------------------------------------------------------ */ | 40 | /* ----- Device list ------------------------------------------------------ */ |
@@ -43,10 +45,11 @@ struct i2c_par { | |||
43 | struct i2c_algo_bit_data algo_data; | 45 | struct i2c_algo_bit_data algo_data; |
44 | struct i2c_smbus_alert_setup alert_data; | 46 | struct i2c_smbus_alert_setup alert_data; |
45 | struct i2c_client *ara; | 47 | struct i2c_client *ara; |
46 | struct i2c_par *next; | 48 | struct list_head node; |
47 | }; | 49 | }; |
48 | 50 | ||
49 | static struct i2c_par *adapter_list; | 51 | static LIST_HEAD(adapter_list); |
52 | static DEFINE_MUTEX(adapter_list_lock); | ||
50 | 53 | ||
51 | /* ----- Low-level parallel port access ----------------------------------- */ | 54 | /* ----- Low-level parallel port access ----------------------------------- */ |
52 | 55 | ||
@@ -228,8 +231,9 @@ static void i2c_parport_attach (struct parport *port) | |||
228 | } | 231 | } |
229 | 232 | ||
230 | /* Add the new adapter to the list */ | 233 | /* Add the new adapter to the list */ |
231 | adapter->next = adapter_list; | 234 | mutex_lock(&adapter_list_lock); |
232 | adapter_list = adapter; | 235 | list_add_tail(&adapter->node, &adapter_list); |
236 | mutex_unlock(&adapter_list_lock); | ||
233 | return; | 237 | return; |
234 | 238 | ||
235 | ERROR1: | 239 | ERROR1: |
@@ -241,11 +245,11 @@ ERROR0: | |||
241 | 245 | ||
242 | static void i2c_parport_detach (struct parport *port) | 246 | static void i2c_parport_detach (struct parport *port) |
243 | { | 247 | { |
244 | struct i2c_par *adapter, *prev; | 248 | struct i2c_par *adapter, *_n; |
245 | 249 | ||
246 | /* Walk the list */ | 250 | /* Walk the list */ |
247 | for (prev = NULL, adapter = adapter_list; adapter; | 251 | mutex_lock(&adapter_list_lock); |
248 | prev = adapter, adapter = adapter->next) { | 252 | list_for_each_entry_safe(adapter, _n, &adapter_list, node) { |
249 | if (adapter->pdev->port == port) { | 253 | if (adapter->pdev->port == port) { |
250 | if (adapter->ara) { | 254 | if (adapter->ara) { |
251 | parport_disable_irq(port); | 255 | parport_disable_irq(port); |
@@ -259,14 +263,11 @@ static void i2c_parport_detach (struct parport *port) | |||
259 | 263 | ||
260 | parport_release(adapter->pdev); | 264 | parport_release(adapter->pdev); |
261 | parport_unregister_device(adapter->pdev); | 265 | parport_unregister_device(adapter->pdev); |
262 | if (prev) | 266 | list_del(&adapter->node); |
263 | prev->next = adapter->next; | ||
264 | else | ||
265 | adapter_list = adapter->next; | ||
266 | kfree(adapter); | 267 | kfree(adapter); |
267 | return; | ||
268 | } | 268 | } |
269 | } | 269 | } |
270 | mutex_unlock(&adapter_list_lock); | ||
270 | } | 271 | } |
271 | 272 | ||
272 | static struct parport_driver i2c_parport_driver = { | 273 | static struct parport_driver i2c_parport_driver = { |
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index a97e3fec814..04be9f82e14 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -65,7 +65,7 @@ static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data) | |||
65 | jiffies, expires); | 65 | jiffies, expires); |
66 | 66 | ||
67 | timer->expires = jiffies + expires; | 67 | timer->expires = jiffies + expires; |
68 | timer->data = (unsigned long)&alg_data; | 68 | timer->data = (unsigned long)alg_data; |
69 | 69 | ||
70 | add_timer(timer); | 70 | add_timer(timer); |
71 | } | 71 | } |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index c24946f5125..1de1c19dad3 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -281,17 +281,24 @@ struct ser_req { | |||
281 | u8 command; | 281 | u8 command; |
282 | u8 ref_off; | 282 | u8 ref_off; |
283 | u16 scratch; | 283 | u16 scratch; |
284 | __be16 sample; | ||
285 | struct spi_message msg; | 284 | struct spi_message msg; |
286 | struct spi_transfer xfer[6]; | 285 | struct spi_transfer xfer[6]; |
286 | /* | ||
287 | * DMA (thus cache coherency maintenance) requires the | ||
288 | * transfer buffers to live in their own cache lines. | ||
289 | */ | ||
290 | __be16 sample ____cacheline_aligned; | ||
287 | }; | 291 | }; |
288 | 292 | ||
289 | struct ads7845_ser_req { | 293 | struct ads7845_ser_req { |
290 | u8 command[3]; | 294 | u8 command[3]; |
291 | u8 pwrdown[3]; | ||
292 | u8 sample[3]; | ||
293 | struct spi_message msg; | 295 | struct spi_message msg; |
294 | struct spi_transfer xfer[2]; | 296 | struct spi_transfer xfer[2]; |
297 | /* | ||
298 | * DMA (thus cache coherency maintenance) requires the | ||
299 | * transfer buffers to live in their own cache lines. | ||
300 | */ | ||
301 | u8 sample[3] ____cacheline_aligned; | ||
295 | }; | 302 | }; |
296 | 303 | ||
297 | static int ads7846_read12_ser(struct device *dev, unsigned command) | 304 | static int ads7846_read12_ser(struct device *dev, unsigned command) |
diff --git a/drivers/input/touchscreen/wm831x-ts.c b/drivers/input/touchscreen/wm831x-ts.c index 6ae054f8e0a..9175d49d254 100644 --- a/drivers/input/touchscreen/wm831x-ts.c +++ b/drivers/input/touchscreen/wm831x-ts.c | |||
@@ -68,8 +68,23 @@ struct wm831x_ts { | |||
68 | unsigned int pd_irq; | 68 | unsigned int pd_irq; |
69 | bool pressure; | 69 | bool pressure; |
70 | bool pen_down; | 70 | bool pen_down; |
71 | struct work_struct pd_data_work; | ||
71 | }; | 72 | }; |
72 | 73 | ||
74 | static void wm831x_pd_data_work(struct work_struct *work) | ||
75 | { | ||
76 | struct wm831x_ts *wm831x_ts = | ||
77 | container_of(work, struct wm831x_ts, pd_data_work); | ||
78 | |||
79 | if (wm831x_ts->pen_down) { | ||
80 | enable_irq(wm831x_ts->data_irq); | ||
81 | dev_dbg(wm831x_ts->wm831x->dev, "IRQ PD->DATA done\n"); | ||
82 | } else { | ||
83 | enable_irq(wm831x_ts->pd_irq); | ||
84 | dev_dbg(wm831x_ts->wm831x->dev, "IRQ DATA->PD done\n"); | ||
85 | } | ||
86 | } | ||
87 | |||
73 | static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) | 88 | static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) |
74 | { | 89 | { |
75 | struct wm831x_ts *wm831x_ts = irq_data; | 90 | struct wm831x_ts *wm831x_ts = irq_data; |
@@ -110,6 +125,9 @@ static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) | |||
110 | } | 125 | } |
111 | 126 | ||
112 | if (!wm831x_ts->pen_down) { | 127 | if (!wm831x_ts->pen_down) { |
128 | /* Switch from data to pen down */ | ||
129 | dev_dbg(wm831x->dev, "IRQ DATA->PD\n"); | ||
130 | |||
113 | disable_irq_nosync(wm831x_ts->data_irq); | 131 | disable_irq_nosync(wm831x_ts->data_irq); |
114 | 132 | ||
115 | /* Don't need data any more */ | 133 | /* Don't need data any more */ |
@@ -128,6 +146,10 @@ static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) | |||
128 | ABS_PRESSURE, 0); | 146 | ABS_PRESSURE, 0); |
129 | 147 | ||
130 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 0); | 148 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 0); |
149 | |||
150 | schedule_work(&wm831x_ts->pd_data_work); | ||
151 | } else { | ||
152 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 1); | ||
131 | } | 153 | } |
132 | 154 | ||
133 | input_sync(wm831x_ts->input_dev); | 155 | input_sync(wm831x_ts->input_dev); |
@@ -141,6 +163,11 @@ static irqreturn_t wm831x_ts_pen_down_irq(int irq, void *irq_data) | |||
141 | struct wm831x *wm831x = wm831x_ts->wm831x; | 163 | struct wm831x *wm831x = wm831x_ts->wm831x; |
142 | int ena = 0; | 164 | int ena = 0; |
143 | 165 | ||
166 | if (wm831x_ts->pen_down) | ||
167 | return IRQ_HANDLED; | ||
168 | |||
169 | disable_irq_nosync(wm831x_ts->pd_irq); | ||
170 | |||
144 | /* Start collecting data */ | 171 | /* Start collecting data */ |
145 | if (wm831x_ts->pressure) | 172 | if (wm831x_ts->pressure) |
146 | ena |= WM831X_TCH_Z_ENA; | 173 | ena |= WM831X_TCH_Z_ENA; |
@@ -149,14 +176,14 @@ static irqreturn_t wm831x_ts_pen_down_irq(int irq, void *irq_data) | |||
149 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA, | 176 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA, |
150 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | ena); | 177 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | ena); |
151 | 178 | ||
152 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 1); | ||
153 | input_sync(wm831x_ts->input_dev); | ||
154 | |||
155 | wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1, | 179 | wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1, |
156 | WM831X_TCHPD_EINT, WM831X_TCHPD_EINT); | 180 | WM831X_TCHPD_EINT, WM831X_TCHPD_EINT); |
157 | 181 | ||
158 | wm831x_ts->pen_down = true; | 182 | wm831x_ts->pen_down = true; |
159 | enable_irq(wm831x_ts->data_irq); | 183 | |
184 | /* Switch from pen down to data */ | ||
185 | dev_dbg(wm831x->dev, "IRQ PD->DATA\n"); | ||
186 | schedule_work(&wm831x_ts->pd_data_work); | ||
160 | 187 | ||
161 | return IRQ_HANDLED; | 188 | return IRQ_HANDLED; |
162 | } | 189 | } |
@@ -182,13 +209,28 @@ static void wm831x_ts_input_close(struct input_dev *idev) | |||
182 | struct wm831x_ts *wm831x_ts = input_get_drvdata(idev); | 209 | struct wm831x_ts *wm831x_ts = input_get_drvdata(idev); |
183 | struct wm831x *wm831x = wm831x_ts->wm831x; | 210 | struct wm831x *wm831x = wm831x_ts->wm831x; |
184 | 211 | ||
212 | /* Shut the controller down, disabling all other functionality too */ | ||
185 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | 213 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, |
186 | WM831X_TCH_ENA | WM831X_TCH_CVT_ENA | | 214 | WM831X_TCH_ENA | WM831X_TCH_X_ENA | |
187 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | | 215 | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA, 0); |
188 | WM831X_TCH_Z_ENA, 0); | ||
189 | 216 | ||
190 | if (wm831x_ts->pen_down) | 217 | /* Make sure any pending IRQs are done, the above will prevent |
218 | * new ones firing. | ||
219 | */ | ||
220 | synchronize_irq(wm831x_ts->data_irq); | ||
221 | synchronize_irq(wm831x_ts->pd_irq); | ||
222 | |||
223 | /* Make sure the IRQ completion work is quiesced */ | ||
224 | flush_work_sync(&wm831x_ts->pd_data_work); | ||
225 | |||
226 | /* If we ended up with the pen down then make sure we revert back | ||
227 | * to pen detection state for the next time we start up. | ||
228 | */ | ||
229 | if (wm831x_ts->pen_down) { | ||
191 | disable_irq(wm831x_ts->data_irq); | 230 | disable_irq(wm831x_ts->data_irq); |
231 | enable_irq(wm831x_ts->pd_irq); | ||
232 | wm831x_ts->pen_down = false; | ||
233 | } | ||
192 | } | 234 | } |
193 | 235 | ||
194 | static __devinit int wm831x_ts_probe(struct platform_device *pdev) | 236 | static __devinit int wm831x_ts_probe(struct platform_device *pdev) |
@@ -198,7 +240,7 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev) | |||
198 | struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent); | 240 | struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent); |
199 | struct wm831x_touch_pdata *pdata = NULL; | 241 | struct wm831x_touch_pdata *pdata = NULL; |
200 | struct input_dev *input_dev; | 242 | struct input_dev *input_dev; |
201 | int error; | 243 | int error, irqf; |
202 | 244 | ||
203 | if (core_pdata) | 245 | if (core_pdata) |
204 | pdata = core_pdata->touch; | 246 | pdata = core_pdata->touch; |
@@ -212,6 +254,7 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev) | |||
212 | 254 | ||
213 | wm831x_ts->wm831x = wm831x; | 255 | wm831x_ts->wm831x = wm831x; |
214 | wm831x_ts->input_dev = input_dev; | 256 | wm831x_ts->input_dev = input_dev; |
257 | INIT_WORK(&wm831x_ts->pd_data_work, wm831x_pd_data_work); | ||
215 | 258 | ||
216 | /* | 259 | /* |
217 | * If we have a direct IRQ use it, otherwise use the interrupt | 260 | * If we have a direct IRQ use it, otherwise use the interrupt |
@@ -270,9 +313,14 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev) | |||
270 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | 313 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, |
271 | WM831X_TCH_RATE_MASK, 6); | 314 | WM831X_TCH_RATE_MASK, 6); |
272 | 315 | ||
316 | if (pdata && pdata->data_irqf) | ||
317 | irqf = pdata->data_irqf; | ||
318 | else | ||
319 | irqf = IRQF_TRIGGER_HIGH; | ||
320 | |||
273 | error = request_threaded_irq(wm831x_ts->data_irq, | 321 | error = request_threaded_irq(wm831x_ts->data_irq, |
274 | NULL, wm831x_ts_data_irq, | 322 | NULL, wm831x_ts_data_irq, |
275 | IRQF_ONESHOT, | 323 | irqf | IRQF_ONESHOT, |
276 | "Touchscreen data", wm831x_ts); | 324 | "Touchscreen data", wm831x_ts); |
277 | if (error) { | 325 | if (error) { |
278 | dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n", | 326 | dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n", |
@@ -281,9 +329,14 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev) | |||
281 | } | 329 | } |
282 | disable_irq(wm831x_ts->data_irq); | 330 | disable_irq(wm831x_ts->data_irq); |
283 | 331 | ||
332 | if (pdata && pdata->pd_irqf) | ||
333 | irqf = pdata->pd_irqf; | ||
334 | else | ||
335 | irqf = IRQF_TRIGGER_HIGH; | ||
336 | |||
284 | error = request_threaded_irq(wm831x_ts->pd_irq, | 337 | error = request_threaded_irq(wm831x_ts->pd_irq, |
285 | NULL, wm831x_ts_pen_down_irq, | 338 | NULL, wm831x_ts_pen_down_irq, |
286 | IRQF_ONESHOT, | 339 | irqf | IRQF_ONESHOT, |
287 | "Touchscreen pen down", wm831x_ts); | 340 | "Touchscreen pen down", wm831x_ts); |
288 | if (error) { | 341 | if (error) { |
289 | dev_err(&pdev->dev, "Failed to request pen down IRQ %d: %d\n", | 342 | dev_err(&pdev->dev, "Failed to request pen down IRQ %d: %d\n", |
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index e7089a1f6cb..b37e6186d0f 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c | |||
@@ -349,6 +349,7 @@ static const struct i2c_device_id lm3530_id[] = { | |||
349 | {LM3530_NAME, 0}, | 349 | {LM3530_NAME, 0}, |
350 | {} | 350 | {} |
351 | }; | 351 | }; |
352 | MODULE_DEVICE_TABLE(i2c, lm3530_id); | ||
352 | 353 | ||
353 | static struct i2c_driver lm3530_i2c_driver = { | 354 | static struct i2c_driver lm3530_i2c_driver = { |
354 | .probe = lm3530_probe, | 355 | .probe = lm3530_probe, |
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index ccbd39a38c4..c545039287a 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -356,6 +356,8 @@ config DVB_USB_LME2510 | |||
356 | select DVB_TDA826X if !DVB_FE_CUSTOMISE | 356 | select DVB_TDA826X if !DVB_FE_CUSTOMISE |
357 | select DVB_STV0288 if !DVB_FE_CUSTOMISE | 357 | select DVB_STV0288 if !DVB_FE_CUSTOMISE |
358 | select DVB_IX2505V if !DVB_FE_CUSTOMISE | 358 | select DVB_IX2505V if !DVB_FE_CUSTOMISE |
359 | select DVB_STV0299 if !DVB_FE_CUSTOMISE | ||
360 | select DVB_PLL if !DVB_FE_CUSTOMISE | ||
359 | help | 361 | help |
360 | Say Y here to support the LME DM04/QQBOX DVB-S USB2.0 . | 362 | Say Y here to support the LME DM04/QQBOX DVB-S USB2.0 . |
361 | 363 | ||
diff --git a/drivers/media/dvb/ngene/ngene-core.c b/drivers/media/dvb/ngene/ngene-core.c index ccc2d1af49d..6927c726ce3 100644 --- a/drivers/media/dvb/ngene/ngene-core.c +++ b/drivers/media/dvb/ngene/ngene-core.c | |||
@@ -1520,6 +1520,7 @@ static int init_channel(struct ngene_channel *chan) | |||
1520 | if (dev->ci.en && (io & NGENE_IO_TSOUT)) { | 1520 | if (dev->ci.en && (io & NGENE_IO_TSOUT)) { |
1521 | dvb_ca_en50221_init(adapter, dev->ci.en, 0, 1); | 1521 | dvb_ca_en50221_init(adapter, dev->ci.en, 0, 1); |
1522 | set_transfer(chan, 1); | 1522 | set_transfer(chan, 1); |
1523 | chan->dev->channel[2].DataFormatFlags = DF_SWAP32; | ||
1523 | set_transfer(&chan->dev->channel[2], 1); | 1524 | set_transfer(&chan->dev->channel[2], 1); |
1524 | dvb_register_device(adapter, &chan->ci_dev, | 1525 | dvb_register_device(adapter, &chan->ci_dev, |
1525 | &ngene_dvbdev_ci, (void *) chan, | 1526 | &ngene_dvbdev_ci, (void *) chan, |
diff --git a/drivers/media/radio/saa7706h.c b/drivers/media/radio/saa7706h.c index 585680ffbfb..b1193dfc508 100644 --- a/drivers/media/radio/saa7706h.c +++ b/drivers/media/radio/saa7706h.c | |||
@@ -376,7 +376,7 @@ static int __devinit saa7706h_probe(struct i2c_client *client, | |||
376 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | 376 | v4l_info(client, "chip found @ 0x%02x (%s)\n", |
377 | client->addr << 1, client->adapter->name); | 377 | client->addr << 1, client->adapter->name); |
378 | 378 | ||
379 | state = kmalloc(sizeof(struct saa7706h_state), GFP_KERNEL); | 379 | state = kzalloc(sizeof(struct saa7706h_state), GFP_KERNEL); |
380 | if (state == NULL) | 380 | if (state == NULL) |
381 | return -ENOMEM; | 381 | return -ENOMEM; |
382 | sd = &state->sd; | 382 | sd = &state->sd; |
diff --git a/drivers/media/radio/tef6862.c b/drivers/media/radio/tef6862.c index 7c0d77751f6..0991e197367 100644 --- a/drivers/media/radio/tef6862.c +++ b/drivers/media/radio/tef6862.c | |||
@@ -176,7 +176,7 @@ static int __devinit tef6862_probe(struct i2c_client *client, | |||
176 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | 176 | v4l_info(client, "chip found @ 0x%02x (%s)\n", |
177 | client->addr << 1, client->adapter->name); | 177 | client->addr << 1, client->adapter->name); |
178 | 178 | ||
179 | state = kmalloc(sizeof(struct tef6862_state), GFP_KERNEL); | 179 | state = kzalloc(sizeof(struct tef6862_state), GFP_KERNEL); |
180 | if (state == NULL) | 180 | if (state == NULL) |
181 | return -ENOMEM; | 181 | return -ENOMEM; |
182 | state->freq = TEF6862_LO_FREQ; | 182 | state->freq = TEF6862_LO_FREQ; |
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index ebd68edf5b2..8fc0f081b47 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>" | 46 | #define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>" |
47 | #define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display" | 47 | #define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display" |
48 | #define MOD_NAME "imon" | 48 | #define MOD_NAME "imon" |
49 | #define MOD_VERSION "0.9.2" | 49 | #define MOD_VERSION "0.9.3" |
50 | 50 | ||
51 | #define DISPLAY_MINOR_BASE 144 | 51 | #define DISPLAY_MINOR_BASE 144 |
52 | #define DEVICE_NAME "lcd%d" | 52 | #define DEVICE_NAME "lcd%d" |
@@ -460,8 +460,9 @@ static int display_close(struct inode *inode, struct file *file) | |||
460 | } | 460 | } |
461 | 461 | ||
462 | /** | 462 | /** |
463 | * Sends a packet to the device -- this function must be called | 463 | * Sends a packet to the device -- this function must be called with |
464 | * with ictx->lock held. | 464 | * ictx->lock held, or its unlock/lock sequence while waiting for tx |
465 | * to complete can/will lead to a deadlock. | ||
465 | */ | 466 | */ |
466 | static int send_packet(struct imon_context *ictx) | 467 | static int send_packet(struct imon_context *ictx) |
467 | { | 468 | { |
@@ -991,12 +992,21 @@ static void imon_touch_display_timeout(unsigned long data) | |||
991 | * the iMON remotes, and those used by the Windows MCE remotes (which is | 992 | * the iMON remotes, and those used by the Windows MCE remotes (which is |
992 | * really just RC-6), but only one or the other at a time, as the signals | 993 | * really just RC-6), but only one or the other at a time, as the signals |
993 | * are decoded onboard the receiver. | 994 | * are decoded onboard the receiver. |
995 | * | ||
996 | * This function gets called two different ways, one way is from | ||
997 | * rc_register_device, for initial protocol selection/setup, and the other is | ||
998 | * via a userspace-initiated protocol change request, either by direct sysfs | ||
999 | * prodding or by something like ir-keytable. In the rc_register_device case, | ||
1000 | * the imon context lock is already held, but when initiated from userspace, | ||
1001 | * it is not, so we must acquire it prior to calling send_packet, which | ||
1002 | * requires that the lock is held. | ||
994 | */ | 1003 | */ |
995 | static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type) | 1004 | static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type) |
996 | { | 1005 | { |
997 | int retval; | 1006 | int retval; |
998 | struct imon_context *ictx = rc->priv; | 1007 | struct imon_context *ictx = rc->priv; |
999 | struct device *dev = ictx->dev; | 1008 | struct device *dev = ictx->dev; |
1009 | bool unlock = false; | ||
1000 | unsigned char ir_proto_packet[] = { | 1010 | unsigned char ir_proto_packet[] = { |
1001 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; | 1011 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; |
1002 | 1012 | ||
@@ -1029,6 +1039,11 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type) | |||
1029 | 1039 | ||
1030 | memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet)); | 1040 | memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet)); |
1031 | 1041 | ||
1042 | if (!mutex_is_locked(&ictx->lock)) { | ||
1043 | unlock = true; | ||
1044 | mutex_lock(&ictx->lock); | ||
1045 | } | ||
1046 | |||
1032 | retval = send_packet(ictx); | 1047 | retval = send_packet(ictx); |
1033 | if (retval) | 1048 | if (retval) |
1034 | goto out; | 1049 | goto out; |
@@ -1037,6 +1052,9 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type) | |||
1037 | ictx->pad_mouse = false; | 1052 | ictx->pad_mouse = false; |
1038 | 1053 | ||
1039 | out: | 1054 | out: |
1055 | if (unlock) | ||
1056 | mutex_unlock(&ictx->lock); | ||
1057 | |||
1040 | return retval; | 1058 | return retval; |
1041 | } | 1059 | } |
1042 | 1060 | ||
@@ -2134,6 +2152,7 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf) | |||
2134 | goto rdev_setup_failed; | 2152 | goto rdev_setup_failed; |
2135 | } | 2153 | } |
2136 | 2154 | ||
2155 | mutex_unlock(&ictx->lock); | ||
2137 | return ictx; | 2156 | return ictx; |
2138 | 2157 | ||
2139 | rdev_setup_failed: | 2158 | rdev_setup_failed: |
@@ -2205,6 +2224,7 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf, | |||
2205 | goto urb_submit_failed; | 2224 | goto urb_submit_failed; |
2206 | } | 2225 | } |
2207 | 2226 | ||
2227 | mutex_unlock(&ictx->lock); | ||
2208 | return ictx; | 2228 | return ictx; |
2209 | 2229 | ||
2210 | urb_submit_failed: | 2230 | urb_submit_failed: |
@@ -2299,6 +2319,8 @@ static int __devinit imon_probe(struct usb_interface *interface, | |||
2299 | usb_set_intfdata(interface, ictx); | 2319 | usb_set_intfdata(interface, ictx); |
2300 | 2320 | ||
2301 | if (ifnum == 0) { | 2321 | if (ifnum == 0) { |
2322 | mutex_lock(&ictx->lock); | ||
2323 | |||
2302 | if (product == 0xffdc && ictx->rf_device) { | 2324 | if (product == 0xffdc && ictx->rf_device) { |
2303 | sysfs_err = sysfs_create_group(&interface->dev.kobj, | 2325 | sysfs_err = sysfs_create_group(&interface->dev.kobj, |
2304 | &imon_rf_attr_group); | 2326 | &imon_rf_attr_group); |
@@ -2309,13 +2331,14 @@ static int __devinit imon_probe(struct usb_interface *interface, | |||
2309 | 2331 | ||
2310 | if (ictx->display_supported) | 2332 | if (ictx->display_supported) |
2311 | imon_init_display(ictx, interface); | 2333 | imon_init_display(ictx, interface); |
2334 | |||
2335 | mutex_unlock(&ictx->lock); | ||
2312 | } | 2336 | } |
2313 | 2337 | ||
2314 | dev_info(dev, "iMON device (%04x:%04x, intf%d) on " | 2338 | dev_info(dev, "iMON device (%04x:%04x, intf%d) on " |
2315 | "usb<%d:%d> initialized\n", vendor, product, ifnum, | 2339 | "usb<%d:%d> initialized\n", vendor, product, ifnum, |
2316 | usbdev->bus->busnum, usbdev->devnum); | 2340 | usbdev->bus->busnum, usbdev->devnum); |
2317 | 2341 | ||
2318 | mutex_unlock(&ictx->lock); | ||
2319 | mutex_unlock(&driver_lock); | 2342 | mutex_unlock(&driver_lock); |
2320 | 2343 | ||
2321 | return 0; | 2344 | return 0; |
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c index accaf6c9789..43908a70bd8 100644 --- a/drivers/media/rc/ite-cir.c +++ b/drivers/media/rc/ite-cir.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/io.h> | 36 | #include <linux/io.h> |
37 | #include <linux/interrupt.h> | 37 | #include <linux/interrupt.h> |
38 | #include <linux/sched.h> | 38 | #include <linux/sched.h> |
39 | #include <linux/delay.h> | ||
39 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
40 | #include <linux/input.h> | 41 | #include <linux/input.h> |
41 | #include <linux/bitops.h> | 42 | #include <linux/bitops.h> |
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index 044fb7a382d..0c273ec465c 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c | |||
@@ -220,6 +220,8 @@ static struct usb_device_id mceusb_dev_table[] = { | |||
220 | { USB_DEVICE(VENDOR_PHILIPS, 0x206c) }, | 220 | { USB_DEVICE(VENDOR_PHILIPS, 0x206c) }, |
221 | /* Philips/Spinel plus IR transceiver for ASUS */ | 221 | /* Philips/Spinel plus IR transceiver for ASUS */ |
222 | { USB_DEVICE(VENDOR_PHILIPS, 0x2088) }, | 222 | { USB_DEVICE(VENDOR_PHILIPS, 0x2088) }, |
223 | /* Philips IR transceiver (Dell branded) */ | ||
224 | { USB_DEVICE(VENDOR_PHILIPS, 0x2093) }, | ||
223 | /* Realtek MCE IR Receiver and card reader */ | 225 | /* Realtek MCE IR Receiver and card reader */ |
224 | { USB_DEVICE(VENDOR_REALTEK, 0x0161), | 226 | { USB_DEVICE(VENDOR_REALTEK, 0x0161), |
225 | .driver_info = MULTIFUNCTION }, | 227 | .driver_info = MULTIFUNCTION }, |
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index f53f9c68d38..a2706648e36 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
@@ -707,7 +707,8 @@ static void ir_close(struct input_dev *idev) | |||
707 | { | 707 | { |
708 | struct rc_dev *rdev = input_get_drvdata(idev); | 708 | struct rc_dev *rdev = input_get_drvdata(idev); |
709 | 709 | ||
710 | rdev->close(rdev); | 710 | if (rdev) |
711 | rdev->close(rdev); | ||
711 | } | 712 | } |
712 | 713 | ||
713 | /* class for /sys/class/rc */ | 714 | /* class for /sys/class/rc */ |
@@ -733,6 +734,7 @@ static struct { | |||
733 | { RC_TYPE_SONY, "sony" }, | 734 | { RC_TYPE_SONY, "sony" }, |
734 | { RC_TYPE_RC5_SZ, "rc-5-sz" }, | 735 | { RC_TYPE_RC5_SZ, "rc-5-sz" }, |
735 | { RC_TYPE_LIRC, "lirc" }, | 736 | { RC_TYPE_LIRC, "lirc" }, |
737 | { RC_TYPE_OTHER, "other" }, | ||
736 | }; | 738 | }; |
737 | 739 | ||
738 | #define PROTO_NONE "none" | 740 | #define PROTO_NONE "none" |
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index c820e2f5352..3f442003623 100644 --- a/drivers/media/video/cx88/cx88-input.c +++ b/drivers/media/video/cx88/cx88-input.c | |||
@@ -524,7 +524,7 @@ void cx88_ir_irq(struct cx88_core *core) | |||
524 | for (todo = 32; todo > 0; todo -= bits) { | 524 | for (todo = 32; todo > 0; todo -= bits) { |
525 | ev.pulse = samples & 0x80000000 ? false : true; | 525 | ev.pulse = samples & 0x80000000 ? false : true; |
526 | bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples)); | 526 | bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples)); |
527 | ev.duration = (bits * NSEC_PER_SEC) / (1000 * ir_samplerate); | 527 | ev.duration = (bits * (NSEC_PER_SEC / 1000)) / ir_samplerate; |
528 | ir_raw_event_store_with_filter(ir->dev, &ev); | 528 | ir_raw_event_store_with_filter(ir->dev, &ev); |
529 | samples <<= bits; | 529 | samples <<= bits; |
530 | } | 530 | } |
diff --git a/drivers/media/video/m52790.c b/drivers/media/video/m52790.c index 5e1c9a81984..303ffa7df4a 100644 --- a/drivers/media/video/m52790.c +++ b/drivers/media/video/m52790.c | |||
@@ -174,7 +174,7 @@ static int m52790_probe(struct i2c_client *client, | |||
174 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 174 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
175 | client->addr << 1, client->adapter->name); | 175 | client->addr << 1, client->adapter->name); |
176 | 176 | ||
177 | state = kmalloc(sizeof(struct m52790_state), GFP_KERNEL); | 177 | state = kzalloc(sizeof(struct m52790_state), GFP_KERNEL); |
178 | if (state == NULL) | 178 | if (state == NULL) |
179 | return -ENOMEM; | 179 | return -ENOMEM; |
180 | 180 | ||
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 3973f9a9475..ddb4c091ded 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -136,11 +136,50 @@ unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl, | |||
136 | } | 136 | } |
137 | EXPORT_SYMBOL(soc_camera_apply_sensor_flags); | 137 | EXPORT_SYMBOL(soc_camera_apply_sensor_flags); |
138 | 138 | ||
139 | #define pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, \ | ||
140 | ((x) >> 24) & 0xff | ||
141 | |||
142 | static int soc_camera_try_fmt(struct soc_camera_device *icd, | ||
143 | struct v4l2_format *f) | ||
144 | { | ||
145 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
146 | struct v4l2_pix_format *pix = &f->fmt.pix; | ||
147 | int ret; | ||
148 | |||
149 | dev_dbg(&icd->dev, "TRY_FMT(%c%c%c%c, %ux%u)\n", | ||
150 | pixfmtstr(pix->pixelformat), pix->width, pix->height); | ||
151 | |||
152 | pix->bytesperline = 0; | ||
153 | pix->sizeimage = 0; | ||
154 | |||
155 | ret = ici->ops->try_fmt(icd, f); | ||
156 | if (ret < 0) | ||
157 | return ret; | ||
158 | |||
159 | if (!pix->sizeimage) { | ||
160 | if (!pix->bytesperline) { | ||
161 | const struct soc_camera_format_xlate *xlate; | ||
162 | |||
163 | xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); | ||
164 | if (!xlate) | ||
165 | return -EINVAL; | ||
166 | |||
167 | ret = soc_mbus_bytes_per_line(pix->width, | ||
168 | xlate->host_fmt); | ||
169 | if (ret > 0) | ||
170 | pix->bytesperline = ret; | ||
171 | } | ||
172 | if (pix->bytesperline) | ||
173 | pix->sizeimage = pix->bytesperline * pix->height; | ||
174 | } | ||
175 | |||
176 | return 0; | ||
177 | } | ||
178 | |||
139 | static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv, | 179 | static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv, |
140 | struct v4l2_format *f) | 180 | struct v4l2_format *f) |
141 | { | 181 | { |
142 | struct soc_camera_device *icd = file->private_data; | 182 | struct soc_camera_device *icd = file->private_data; |
143 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
144 | 183 | ||
145 | WARN_ON(priv != file->private_data); | 184 | WARN_ON(priv != file->private_data); |
146 | 185 | ||
@@ -149,7 +188,7 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv, | |||
149 | return -EINVAL; | 188 | return -EINVAL; |
150 | 189 | ||
151 | /* limit format to hardware capabilities */ | 190 | /* limit format to hardware capabilities */ |
152 | return ici->ops->try_fmt(icd, f); | 191 | return soc_camera_try_fmt(icd, f); |
153 | } | 192 | } |
154 | 193 | ||
155 | static int soc_camera_enum_input(struct file *file, void *priv, | 194 | static int soc_camera_enum_input(struct file *file, void *priv, |
@@ -362,9 +401,6 @@ static void soc_camera_free_user_formats(struct soc_camera_device *icd) | |||
362 | icd->user_formats = NULL; | 401 | icd->user_formats = NULL; |
363 | } | 402 | } |
364 | 403 | ||
365 | #define pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, \ | ||
366 | ((x) >> 24) & 0xff | ||
367 | |||
368 | /* Called with .vb_lock held, or from the first open(2), see comment there */ | 404 | /* Called with .vb_lock held, or from the first open(2), see comment there */ |
369 | static int soc_camera_set_fmt(struct soc_camera_device *icd, | 405 | static int soc_camera_set_fmt(struct soc_camera_device *icd, |
370 | struct v4l2_format *f) | 406 | struct v4l2_format *f) |
@@ -377,7 +413,7 @@ static int soc_camera_set_fmt(struct soc_camera_device *icd, | |||
377 | pixfmtstr(pix->pixelformat), pix->width, pix->height); | 413 | pixfmtstr(pix->pixelformat), pix->width, pix->height); |
378 | 414 | ||
379 | /* We always call try_fmt() before set_fmt() or set_crop() */ | 415 | /* We always call try_fmt() before set_fmt() or set_crop() */ |
380 | ret = ici->ops->try_fmt(icd, f); | 416 | ret = soc_camera_try_fmt(icd, f); |
381 | if (ret < 0) | 417 | if (ret < 0) |
382 | return ret; | 418 | return ret; |
383 | 419 | ||
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index 5d4cf3b3d43..22fa8202d5c 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c | |||
@@ -171,7 +171,7 @@ static int tda9840_probe(struct i2c_client *client, | |||
171 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 171 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
172 | client->addr << 1, client->adapter->name); | 172 | client->addr << 1, client->adapter->name); |
173 | 173 | ||
174 | sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | 174 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); |
175 | if (sd == NULL) | 175 | if (sd == NULL) |
176 | return -ENOMEM; | 176 | return -ENOMEM; |
177 | v4l2_i2c_subdev_init(sd, client, &tda9840_ops); | 177 | v4l2_i2c_subdev_init(sd, client, &tda9840_ops); |
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index 19621ed523e..827425c5b86 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c | |||
@@ -152,7 +152,7 @@ static int tea6415c_probe(struct i2c_client *client, | |||
152 | 152 | ||
153 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 153 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
154 | client->addr << 1, client->adapter->name); | 154 | client->addr << 1, client->adapter->name); |
155 | sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | 155 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); |
156 | if (sd == NULL) | 156 | if (sd == NULL) |
157 | return -ENOMEM; | 157 | return -ENOMEM; |
158 | v4l2_i2c_subdev_init(sd, client, &tea6415c_ops); | 158 | v4l2_i2c_subdev_init(sd, client, &tea6415c_ops); |
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index 5ea840401f2..f350b6c2450 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c | |||
@@ -125,7 +125,7 @@ static int tea6420_probe(struct i2c_client *client, | |||
125 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 125 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
126 | client->addr << 1, client->adapter->name); | 126 | client->addr << 1, client->adapter->name); |
127 | 127 | ||
128 | sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | 128 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); |
129 | if (sd == NULL) | 129 | if (sd == NULL) |
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | v4l2_i2c_subdev_init(sd, client, &tea6420_ops); | 131 | v4l2_i2c_subdev_init(sd, client, &tea6420_ops); |
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c index f8138c75be8..1aab96a8820 100644 --- a/drivers/media/video/upd64031a.c +++ b/drivers/media/video/upd64031a.c | |||
@@ -230,7 +230,7 @@ static int upd64031a_probe(struct i2c_client *client, | |||
230 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 230 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
231 | client->addr << 1, client->adapter->name); | 231 | client->addr << 1, client->adapter->name); |
232 | 232 | ||
233 | state = kmalloc(sizeof(struct upd64031a_state), GFP_KERNEL); | 233 | state = kzalloc(sizeof(struct upd64031a_state), GFP_KERNEL); |
234 | if (state == NULL) | 234 | if (state == NULL) |
235 | return -ENOMEM; | 235 | return -ENOMEM; |
236 | sd = &state->sd; | 236 | sd = &state->sd; |
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c index 28e0e6b6ca8..9bbe61700fd 100644 --- a/drivers/media/video/upd64083.c +++ b/drivers/media/video/upd64083.c | |||
@@ -202,7 +202,7 @@ static int upd64083_probe(struct i2c_client *client, | |||
202 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 202 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
203 | client->addr << 1, client->adapter->name); | 203 | client->addr << 1, client->adapter->name); |
204 | 204 | ||
205 | state = kmalloc(sizeof(struct upd64083_state), GFP_KERNEL); | 205 | state = kzalloc(sizeof(struct upd64083_state), GFP_KERNEL); |
206 | if (state == NULL) | 206 | if (state == NULL) |
207 | return -ENOMEM; | 207 | return -ENOMEM; |
208 | sd = &state->sd; | 208 | sd = &state->sd; |
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c index 5aeaf876ba9..4aae501f02d 100644 --- a/drivers/media/video/v4l2-device.c +++ b/drivers/media/video/v4l2-device.c | |||
@@ -155,8 +155,10 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, | |||
155 | sd->v4l2_dev = v4l2_dev; | 155 | sd->v4l2_dev = v4l2_dev; |
156 | if (sd->internal_ops && sd->internal_ops->registered) { | 156 | if (sd->internal_ops && sd->internal_ops->registered) { |
157 | err = sd->internal_ops->registered(sd); | 157 | err = sd->internal_ops->registered(sd); |
158 | if (err) | 158 | if (err) { |
159 | module_put(sd->owner); | ||
159 | return err; | 160 | return err; |
161 | } | ||
160 | } | 162 | } |
161 | 163 | ||
162 | /* This just returns 0 if either of the two args is NULL */ | 164 | /* This just returns 0 if either of the two args is NULL */ |
@@ -164,6 +166,7 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, | |||
164 | if (err) { | 166 | if (err) { |
165 | if (sd->internal_ops && sd->internal_ops->unregistered) | 167 | if (sd->internal_ops && sd->internal_ops->unregistered) |
166 | sd->internal_ops->unregistered(sd); | 168 | sd->internal_ops->unregistered(sd); |
169 | module_put(sd->owner); | ||
167 | return err; | 170 | return err; |
168 | } | 171 | } |
169 | 172 | ||
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c index 0b806449067..812729ebf09 100644 --- a/drivers/media/video/v4l2-subdev.c +++ b/drivers/media/video/v4l2-subdev.c | |||
@@ -155,25 +155,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
155 | 155 | ||
156 | switch (cmd) { | 156 | switch (cmd) { |
157 | case VIDIOC_QUERYCTRL: | 157 | case VIDIOC_QUERYCTRL: |
158 | return v4l2_subdev_queryctrl(sd, arg); | 158 | return v4l2_queryctrl(sd->ctrl_handler, arg); |
159 | 159 | ||
160 | case VIDIOC_QUERYMENU: | 160 | case VIDIOC_QUERYMENU: |
161 | return v4l2_subdev_querymenu(sd, arg); | 161 | return v4l2_querymenu(sd->ctrl_handler, arg); |
162 | 162 | ||
163 | case VIDIOC_G_CTRL: | 163 | case VIDIOC_G_CTRL: |
164 | return v4l2_subdev_g_ctrl(sd, arg); | 164 | return v4l2_g_ctrl(sd->ctrl_handler, arg); |
165 | 165 | ||
166 | case VIDIOC_S_CTRL: | 166 | case VIDIOC_S_CTRL: |
167 | return v4l2_subdev_s_ctrl(sd, arg); | 167 | return v4l2_s_ctrl(sd->ctrl_handler, arg); |
168 | 168 | ||
169 | case VIDIOC_G_EXT_CTRLS: | 169 | case VIDIOC_G_EXT_CTRLS: |
170 | return v4l2_subdev_g_ext_ctrls(sd, arg); | 170 | return v4l2_g_ext_ctrls(sd->ctrl_handler, arg); |
171 | 171 | ||
172 | case VIDIOC_S_EXT_CTRLS: | 172 | case VIDIOC_S_EXT_CTRLS: |
173 | return v4l2_subdev_s_ext_ctrls(sd, arg); | 173 | return v4l2_s_ext_ctrls(sd->ctrl_handler, arg); |
174 | 174 | ||
175 | case VIDIOC_TRY_EXT_CTRLS: | 175 | case VIDIOC_TRY_EXT_CTRLS: |
176 | return v4l2_subdev_try_ext_ctrls(sd, arg); | 176 | return v4l2_try_ext_ctrls(sd->ctrl_handler, arg); |
177 | 177 | ||
178 | case VIDIOC_DQEVENT: | 178 | case VIDIOC_DQEVENT: |
179 | if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) | 179 | if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) |
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index 643ad52e3ca..4796bbf0ae4 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c | |||
@@ -1000,7 +1000,6 @@ static struct i2o_block_device *i2o_block_device_alloc(void) | |||
1000 | gd->major = I2O_MAJOR; | 1000 | gd->major = I2O_MAJOR; |
1001 | gd->queue = queue; | 1001 | gd->queue = queue; |
1002 | gd->fops = &i2o_block_fops; | 1002 | gd->fops = &i2o_block_fops; |
1003 | gd->events = DISK_EVENT_MEDIA_CHANGE; | ||
1004 | gd->private_data = dev; | 1003 | gd->private_data = dev; |
1005 | 1004 | ||
1006 | dev->gd = gd; | 1005 | dev->gd = gd; |
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index d4a851c6b5b..0b4d5b23bec 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c | |||
@@ -144,7 +144,7 @@ static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc) | |||
144 | int iter, i; | 144 | int iter, i; |
145 | unsigned long flags; | 145 | unsigned long flags; |
146 | 146 | ||
147 | data->chip->irq_ack(irq_data); | 147 | data->chip->irq_ack(data); |
148 | 148 | ||
149 | for (iter = 0 ; iter < MAX_ASIC_ISR_LOOPS; iter++) { | 149 | for (iter = 0 ; iter < MAX_ASIC_ISR_LOOPS; iter++) { |
150 | u32 status; | 150 | u32 status; |
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 53450f433f1..3ab9ffa00aa 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
26 | #include <linux/spinlock.h> | 26 | #include <linux/spinlock.h> |
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <linux/regulator/consumer.h> | ||
29 | #include <plat/usb.h> | 28 | #include <plat/usb.h> |
30 | 29 | ||
31 | #define USBHS_DRIVER_NAME "usbhs-omap" | 30 | #define USBHS_DRIVER_NAME "usbhs-omap" |
@@ -700,8 +699,7 @@ static int usbhs_enable(struct device *dev) | |||
700 | dev_dbg(dev, "starting TI HSUSB Controller\n"); | 699 | dev_dbg(dev, "starting TI HSUSB Controller\n"); |
701 | if (!pdata) { | 700 | if (!pdata) { |
702 | dev_dbg(dev, "missing platform_data\n"); | 701 | dev_dbg(dev, "missing platform_data\n"); |
703 | ret = -ENODEV; | 702 | return -ENODEV; |
704 | goto end_enable; | ||
705 | } | 703 | } |
706 | 704 | ||
707 | spin_lock_irqsave(&omap->lock, flags); | 705 | spin_lock_irqsave(&omap->lock, flags); |
@@ -719,14 +717,14 @@ static int usbhs_enable(struct device *dev) | |||
719 | gpio_request(pdata->ehci_data->reset_gpio_port[0], | 717 | gpio_request(pdata->ehci_data->reset_gpio_port[0], |
720 | "USB1 PHY reset"); | 718 | "USB1 PHY reset"); |
721 | gpio_direction_output | 719 | gpio_direction_output |
722 | (pdata->ehci_data->reset_gpio_port[0], 1); | 720 | (pdata->ehci_data->reset_gpio_port[0], 0); |
723 | } | 721 | } |
724 | 722 | ||
725 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) { | 723 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) { |
726 | gpio_request(pdata->ehci_data->reset_gpio_port[1], | 724 | gpio_request(pdata->ehci_data->reset_gpio_port[1], |
727 | "USB2 PHY reset"); | 725 | "USB2 PHY reset"); |
728 | gpio_direction_output | 726 | gpio_direction_output |
729 | (pdata->ehci_data->reset_gpio_port[1], 1); | 727 | (pdata->ehci_data->reset_gpio_port[1], 0); |
730 | } | 728 | } |
731 | 729 | ||
732 | /* Hold the PHY in RESET for enough time till DIR is high */ | 730 | /* Hold the PHY in RESET for enough time till DIR is high */ |
@@ -906,16 +904,17 @@ static int usbhs_enable(struct device *dev) | |||
906 | 904 | ||
907 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) | 905 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) |
908 | gpio_set_value | 906 | gpio_set_value |
909 | (pdata->ehci_data->reset_gpio_port[0], 0); | 907 | (pdata->ehci_data->reset_gpio_port[0], 1); |
910 | 908 | ||
911 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) | 909 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) |
912 | gpio_set_value | 910 | gpio_set_value |
913 | (pdata->ehci_data->reset_gpio_port[1], 0); | 911 | (pdata->ehci_data->reset_gpio_port[1], 1); |
914 | } | 912 | } |
915 | 913 | ||
916 | end_count: | 914 | end_count: |
917 | omap->count++; | 915 | omap->count++; |
918 | goto end_enable; | 916 | spin_unlock_irqrestore(&omap->lock, flags); |
917 | return 0; | ||
919 | 918 | ||
920 | err_tll: | 919 | err_tll: |
921 | if (pdata->ehci_data->phy_reset) { | 920 | if (pdata->ehci_data->phy_reset) { |
@@ -931,8 +930,6 @@ err_tll: | |||
931 | clk_disable(omap->usbhost_fs_fck); | 930 | clk_disable(omap->usbhost_fs_fck); |
932 | clk_disable(omap->usbhost_hs_fck); | 931 | clk_disable(omap->usbhost_hs_fck); |
933 | clk_disable(omap->usbhost_ick); | 932 | clk_disable(omap->usbhost_ick); |
934 | |||
935 | end_enable: | ||
936 | spin_unlock_irqrestore(&omap->lock, flags); | 933 | spin_unlock_irqrestore(&omap->lock, flags); |
937 | return ret; | 934 | return ret; |
938 | } | 935 | } |
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c index 16422de0823..2c0d4d16491 100644 --- a/drivers/mfd/twl4030-power.c +++ b/drivers/mfd/twl4030-power.c | |||
@@ -447,12 +447,13 @@ static int __init load_twl4030_script(struct twl4030_script *tscript, | |||
447 | if (err) | 447 | if (err) |
448 | goto out; | 448 | goto out; |
449 | } | 449 | } |
450 | if (tscript->flags & TWL4030_SLEEP_SCRIPT) | 450 | if (tscript->flags & TWL4030_SLEEP_SCRIPT) { |
451 | if (order) | 451 | if (order) |
452 | pr_warning("TWL4030: Bad order of scripts (sleep "\ | 452 | pr_warning("TWL4030: Bad order of scripts (sleep "\ |
453 | "script before wakeup) Leads to boot"\ | 453 | "script before wakeup) Leads to boot"\ |
454 | "failure on some boards\n"); | 454 | "failure on some boards\n"); |
455 | err = twl4030_config_sleep_sequence(address); | 455 | err = twl4030_config_sleep_sequence(address); |
456 | } | ||
456 | out: | 457 | out: |
457 | return err; | 458 | return err; |
458 | } | 459 | } |
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 63667a8f140..d6d62fd07ee 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c | |||
@@ -284,6 +284,7 @@ int mmc_add_card(struct mmc_card *card) | |||
284 | type = "SD-combo"; | 284 | type = "SD-combo"; |
285 | if (mmc_card_blockaddr(card)) | 285 | if (mmc_card_blockaddr(card)) |
286 | type = "SDHC-combo"; | 286 | type = "SDHC-combo"; |
287 | break; | ||
287 | default: | 288 | default: |
288 | type = "?"; | 289 | type = "?"; |
289 | break; | 290 | break; |
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 2e032f0e8cf..a6c32904014 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c | |||
@@ -832,7 +832,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id) | |||
832 | return IRQ_HANDLED; | 832 | return IRQ_HANDLED; |
833 | } | 833 | } |
834 | 834 | ||
835 | if (end_command) | 835 | if (end_command && host->cmd) |
836 | mmc_omap_cmd_done(host, host->cmd); | 836 | mmc_omap_cmd_done(host, host->cmd); |
837 | if (host->data != NULL) { | 837 | if (host->data != NULL) { |
838 | if (transfer_error) | 838 | if (transfer_error) |
diff --git a/drivers/mmc/host/sdhci-of-core.c b/drivers/mmc/host/sdhci-of-core.c index f9b611fc773..60e4186a434 100644 --- a/drivers/mmc/host/sdhci-of-core.c +++ b/drivers/mmc/host/sdhci-of-core.c | |||
@@ -124,8 +124,10 @@ static bool __devinit sdhci_of_wp_inverted(struct device_node *np) | |||
124 | #endif | 124 | #endif |
125 | } | 125 | } |
126 | 126 | ||
127 | static const struct of_device_id sdhci_of_match[]; | ||
127 | static int __devinit sdhci_of_probe(struct platform_device *ofdev) | 128 | static int __devinit sdhci_of_probe(struct platform_device *ofdev) |
128 | { | 129 | { |
130 | const struct of_device_id *match; | ||
129 | struct device_node *np = ofdev->dev.of_node; | 131 | struct device_node *np = ofdev->dev.of_node; |
130 | struct sdhci_of_data *sdhci_of_data; | 132 | struct sdhci_of_data *sdhci_of_data; |
131 | struct sdhci_host *host; | 133 | struct sdhci_host *host; |
@@ -134,9 +136,10 @@ static int __devinit sdhci_of_probe(struct platform_device *ofdev) | |||
134 | int size; | 136 | int size; |
135 | int ret; | 137 | int ret; |
136 | 138 | ||
137 | if (!ofdev->dev.of_match) | 139 | match = of_match_device(sdhci_of_match, &ofdev->dev); |
140 | if (!match) | ||
138 | return -EINVAL; | 141 | return -EINVAL; |
139 | sdhci_of_data = ofdev->dev.of_match->data; | 142 | sdhci_of_data = match->data; |
140 | 143 | ||
141 | if (!of_device_is_available(np)) | 144 | if (!of_device_is_available(np)) |
142 | return -ENODEV; | 145 | return -ENODEV; |
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index a136be70634..f8b5f37007b 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
@@ -957,6 +957,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( | |||
957 | host->ioaddr = pci_ioremap_bar(pdev, bar); | 957 | host->ioaddr = pci_ioremap_bar(pdev, bar); |
958 | if (!host->ioaddr) { | 958 | if (!host->ioaddr) { |
959 | dev_err(&pdev->dev, "failed to remap registers\n"); | 959 | dev_err(&pdev->dev, "failed to remap registers\n"); |
960 | ret = -ENOMEM; | ||
960 | goto release; | 961 | goto release; |
961 | } | 962 | } |
962 | 963 | ||
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9e15f41f87b..5d20661bc35 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -1334,6 +1334,13 @@ static void sdhci_tasklet_finish(unsigned long param) | |||
1334 | 1334 | ||
1335 | host = (struct sdhci_host*)param; | 1335 | host = (struct sdhci_host*)param; |
1336 | 1336 | ||
1337 | /* | ||
1338 | * If this tasklet gets rescheduled while running, it will | ||
1339 | * be run again afterwards but without any active request. | ||
1340 | */ | ||
1341 | if (!host->mrq) | ||
1342 | return; | ||
1343 | |||
1337 | spin_lock_irqsave(&host->lock, flags); | 1344 | spin_lock_irqsave(&host->lock, flags); |
1338 | 1345 | ||
1339 | del_timer(&host->timer); | 1346 | del_timer(&host->timer); |
@@ -1345,7 +1352,7 @@ static void sdhci_tasklet_finish(unsigned long param) | |||
1345 | * upon error conditions. | 1352 | * upon error conditions. |
1346 | */ | 1353 | */ |
1347 | if (!(host->flags & SDHCI_DEVICE_DEAD) && | 1354 | if (!(host->flags & SDHCI_DEVICE_DEAD) && |
1348 | (mrq->cmd->error || | 1355 | ((mrq->cmd && mrq->cmd->error) || |
1349 | (mrq->data && (mrq->data->error || | 1356 | (mrq->data && (mrq->data->error || |
1350 | (mrq->data->stop && mrq->data->stop->error))) || | 1357 | (mrq->data->stop && mrq->data->stop->error))) || |
1351 | (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) { | 1358 | (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) { |
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index 62d37de6de7..710339a85c8 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c | |||
@@ -728,15 +728,15 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
728 | tmio_mmc_set_clock(host, ios->clock); | 728 | tmio_mmc_set_clock(host, ios->clock); |
729 | 729 | ||
730 | /* Power sequence - OFF -> UP -> ON */ | 730 | /* Power sequence - OFF -> UP -> ON */ |
731 | if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { | 731 | if (ios->power_mode == MMC_POWER_UP) { |
732 | /* power up SD bus */ | ||
733 | if (host->set_pwr) | ||
734 | host->set_pwr(host->pdev, 1); | ||
735 | } else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { | ||
732 | /* power down SD bus */ | 736 | /* power down SD bus */ |
733 | if (ios->power_mode == MMC_POWER_OFF && host->set_pwr) | 737 | if (ios->power_mode == MMC_POWER_OFF && host->set_pwr) |
734 | host->set_pwr(host->pdev, 0); | 738 | host->set_pwr(host->pdev, 0); |
735 | tmio_mmc_clk_stop(host); | 739 | tmio_mmc_clk_stop(host); |
736 | } else if (ios->power_mode == MMC_POWER_UP) { | ||
737 | /* power up SD bus */ | ||
738 | if (host->set_pwr) | ||
739 | host->set_pwr(host->pdev, 1); | ||
740 | } else { | 740 | } else { |
741 | /* start bus clock */ | 741 | /* start bus clock */ |
742 | tmio_mmc_clk_start(host); | 742 | tmio_mmc_clk_start(host); |
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c index bd483f0c57e..c1d33464aee 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c | |||
@@ -214,11 +214,13 @@ static void __devinit of_free_probes(const char **probes) | |||
214 | } | 214 | } |
215 | #endif | 215 | #endif |
216 | 216 | ||
217 | static struct of_device_id of_flash_match[]; | ||
217 | static int __devinit of_flash_probe(struct platform_device *dev) | 218 | static int __devinit of_flash_probe(struct platform_device *dev) |
218 | { | 219 | { |
219 | #ifdef CONFIG_MTD_PARTITIONS | 220 | #ifdef CONFIG_MTD_PARTITIONS |
220 | const char **part_probe_types; | 221 | const char **part_probe_types; |
221 | #endif | 222 | #endif |
223 | const struct of_device_id *match; | ||
222 | struct device_node *dp = dev->dev.of_node; | 224 | struct device_node *dp = dev->dev.of_node; |
223 | struct resource res; | 225 | struct resource res; |
224 | struct of_flash *info; | 226 | struct of_flash *info; |
@@ -232,9 +234,10 @@ static int __devinit of_flash_probe(struct platform_device *dev) | |||
232 | struct mtd_info **mtd_list = NULL; | 234 | struct mtd_info **mtd_list = NULL; |
233 | resource_size_t res_size; | 235 | resource_size_t res_size; |
234 | 236 | ||
235 | if (!dev->dev.of_match) | 237 | match = of_match_device(of_flash_match, &dev->dev); |
238 | if (!match) | ||
236 | return -EINVAL; | 239 | return -EINVAL; |
237 | probe_type = dev->dev.of_match->data; | 240 | probe_type = match->data; |
238 | 241 | ||
239 | reg_tuple_size = (of_n_addr_cells(dp) + of_n_size_cells(dp)) * sizeof(u32); | 242 | reg_tuple_size = (of_n_addr_cells(dp) + of_n_size_cells(dp)) * sizeof(u32); |
240 | 243 | ||
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index dc280bc8eba..6c884ef1b06 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -2536,7 +2536,7 @@ config S6GMAC | |||
2536 | source "drivers/net/stmmac/Kconfig" | 2536 | source "drivers/net/stmmac/Kconfig" |
2537 | 2537 | ||
2538 | config PCH_GBE | 2538 | config PCH_GBE |
2539 | tristate "PCH Gigabit Ethernet" | 2539 | tristate "Intel EG20T PCH / OKI SEMICONDUCTOR ML7223 IOH GbE" |
2540 | depends on PCI | 2540 | depends on PCI |
2541 | select MII | 2541 | select MII |
2542 | ---help--- | 2542 | ---help--- |
@@ -2548,6 +2548,12 @@ config PCH_GBE | |||
2548 | to Gigabit Ethernet. | 2548 | to Gigabit Ethernet. |
2549 | This driver enables Gigabit Ethernet function. | 2549 | This driver enables Gigabit Ethernet function. |
2550 | 2550 | ||
2551 | This driver also can be used for OKI SEMICONDUCTOR IOH(Input/ | ||
2552 | Output Hub), ML7223. | ||
2553 | ML7223 IOH is for MP(Media Phone) use. | ||
2554 | ML7223 is companion chip for Intel Atom E6xx series. | ||
2555 | ML7223 is completely compatible for Intel EG20T PCH. | ||
2556 | |||
2551 | endif # NETDEV_1000 | 2557 | endif # NETDEV_1000 |
2552 | 2558 | ||
2553 | # | 2559 | # |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 01b604ad155..e5a7375685a 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -144,7 +144,7 @@ obj-$(CONFIG_NE3210) += ne3210.o 8390.o | |||
144 | obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o | 144 | obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o |
145 | obj-$(CONFIG_B44) += b44.o | 145 | obj-$(CONFIG_B44) += b44.o |
146 | obj-$(CONFIG_FORCEDETH) += forcedeth.o | 146 | obj-$(CONFIG_FORCEDETH) += forcedeth.o |
147 | obj-$(CONFIG_NE_H8300) += ne-h8300.o 8390.o | 147 | obj-$(CONFIG_NE_H8300) += ne-h8300.o |
148 | obj-$(CONFIG_AX88796) += ax88796.o | 148 | obj-$(CONFIG_AX88796) += ax88796.o |
149 | obj-$(CONFIG_BCM63XX_ENET) += bcm63xx_enet.o | 149 | obj-$(CONFIG_BCM63XX_ENET) += bcm63xx_enet.o |
150 | obj-$(CONFIG_FTMAC100) += ftmac100.o | 150 | obj-$(CONFIG_FTMAC100) += ftmac100.o |
@@ -219,7 +219,7 @@ obj-$(CONFIG_SC92031) += sc92031.o | |||
219 | obj-$(CONFIG_LP486E) += lp486e.o | 219 | obj-$(CONFIG_LP486E) += lp486e.o |
220 | 220 | ||
221 | obj-$(CONFIG_ETH16I) += eth16i.o | 221 | obj-$(CONFIG_ETH16I) += eth16i.o |
222 | obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o | 222 | obj-$(CONFIG_ZORRO8390) += zorro8390.o |
223 | obj-$(CONFIG_HPLANCE) += hplance.o 7990.o | 223 | obj-$(CONFIG_HPLANCE) += hplance.o 7990.o |
224 | obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o | 224 | obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o |
225 | obj-$(CONFIG_EQUALIZER) += eql.o | 225 | obj-$(CONFIG_EQUALIZER) += eql.o |
@@ -231,7 +231,7 @@ obj-$(CONFIG_SGI_IOC3_ETH) += ioc3-eth.o | |||
231 | obj-$(CONFIG_DECLANCE) += declance.o | 231 | obj-$(CONFIG_DECLANCE) += declance.o |
232 | obj-$(CONFIG_ATARILANCE) += atarilance.o | 232 | obj-$(CONFIG_ATARILANCE) += atarilance.o |
233 | obj-$(CONFIG_A2065) += a2065.o | 233 | obj-$(CONFIG_A2065) += a2065.o |
234 | obj-$(CONFIG_HYDRA) += hydra.o 8390.o | 234 | obj-$(CONFIG_HYDRA) += hydra.o |
235 | obj-$(CONFIG_ARIADNE) += ariadne.o | 235 | obj-$(CONFIG_ARIADNE) += ariadne.o |
236 | obj-$(CONFIG_CS89x0) += cs89x0.o | 236 | obj-$(CONFIG_CS89x0) += cs89x0.o |
237 | obj-$(CONFIG_MACSONIC) += macsonic.o | 237 | obj-$(CONFIG_MACSONIC) += macsonic.o |
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c index 88495c48a81..241b185e656 100644 --- a/drivers/net/amd8111e.c +++ b/drivers/net/amd8111e.c | |||
@@ -106,7 +106,7 @@ MODULE_DESCRIPTION ("AMD8111 based 10/100 Ethernet Controller. Driver Version "M | |||
106 | MODULE_LICENSE("GPL"); | 106 | MODULE_LICENSE("GPL"); |
107 | MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl); | 107 | MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl); |
108 | module_param_array(speed_duplex, int, NULL, 0); | 108 | module_param_array(speed_duplex, int, NULL, 0); |
109 | MODULE_PARM_DESC(speed_duplex, "Set device speed and duplex modes, 0: Auto Negotitate, 1: 10Mbps Half Duplex, 2: 10Mbps Full Duplex, 3: 100Mbps Half Duplex, 4: 100Mbps Full Duplex"); | 109 | MODULE_PARM_DESC(speed_duplex, "Set device speed and duplex modes, 0: Auto Negotiate, 1: 10Mbps Half Duplex, 2: 10Mbps Full Duplex, 3: 100Mbps Half Duplex, 4: 100Mbps Full Duplex"); |
110 | module_param_array(coalesce, bool, NULL, 0); | 110 | module_param_array(coalesce, bool, NULL, 0); |
111 | MODULE_PARM_DESC(coalesce, "Enable or Disable interrupt coalescing, 1: Enable, 0: Disable"); | 111 | MODULE_PARM_DESC(coalesce, "Enable or Disable interrupt coalescing, 1: Enable, 0: Disable"); |
112 | module_param_array(dynamic_ipg, bool, NULL, 0); | 112 | module_param_array(dynamic_ipg, bool, NULL, 0); |
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c index 4af235d41fd..fbfb5b47c50 100644 --- a/drivers/net/arm/etherh.c +++ b/drivers/net/arm/etherh.c | |||
@@ -527,7 +527,7 @@ static void __init etherh_banner(void) | |||
527 | * Read the ethernet address string from the on board rom. | 527 | * Read the ethernet address string from the on board rom. |
528 | * This is an ascii string... | 528 | * This is an ascii string... |
529 | */ | 529 | */ |
530 | static int __init etherh_addr(char *addr, struct expansion_card *ec) | 530 | static int __devinit etherh_addr(char *addr, struct expansion_card *ec) |
531 | { | 531 | { |
532 | struct in_chunk_dir cd; | 532 | struct in_chunk_dir cd; |
533 | char *s; | 533 | char *s; |
@@ -655,7 +655,7 @@ static const struct net_device_ops etherh_netdev_ops = { | |||
655 | static u32 etherh_regoffsets[16]; | 655 | static u32 etherh_regoffsets[16]; |
656 | static u32 etherm_regoffsets[16]; | 656 | static u32 etherm_regoffsets[16]; |
657 | 657 | ||
658 | static int __init | 658 | static int __devinit |
659 | etherh_probe(struct expansion_card *ec, const struct ecard_id *id) | 659 | etherh_probe(struct expansion_card *ec, const struct ecard_id *id) |
660 | { | 660 | { |
661 | const struct etherh_data *data = id->data; | 661 | const struct etherh_data *data = id->data; |
diff --git a/drivers/net/atl1c/atl1c.h b/drivers/net/atl1c/atl1c.h index 7cb375e0e29..925929d764c 100644 --- a/drivers/net/atl1c/atl1c.h +++ b/drivers/net/atl1c/atl1c.h | |||
@@ -566,9 +566,9 @@ struct atl1c_adapter { | |||
566 | #define __AT_TESTING 0x0001 | 566 | #define __AT_TESTING 0x0001 |
567 | #define __AT_RESETTING 0x0002 | 567 | #define __AT_RESETTING 0x0002 |
568 | #define __AT_DOWN 0x0003 | 568 | #define __AT_DOWN 0x0003 |
569 | u8 work_event; | 569 | unsigned long work_event; |
570 | #define ATL1C_WORK_EVENT_RESET 0x01 | 570 | #define ATL1C_WORK_EVENT_RESET 0 |
571 | #define ATL1C_WORK_EVENT_LINK_CHANGE 0x02 | 571 | #define ATL1C_WORK_EVENT_LINK_CHANGE 1 |
572 | u32 msg_enable; | 572 | u32 msg_enable; |
573 | 573 | ||
574 | bool have_msi; | 574 | bool have_msi; |
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c index 7d9d5067a65..a6e1c36e48e 100644 --- a/drivers/net/atl1c/atl1c_main.c +++ b/drivers/net/atl1c/atl1c_main.c | |||
@@ -325,7 +325,7 @@ static void atl1c_link_chg_event(struct atl1c_adapter *adapter) | |||
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | adapter->work_event |= ATL1C_WORK_EVENT_LINK_CHANGE; | 328 | set_bit(ATL1C_WORK_EVENT_LINK_CHANGE, &adapter->work_event); |
329 | schedule_work(&adapter->common_task); | 329 | schedule_work(&adapter->common_task); |
330 | } | 330 | } |
331 | 331 | ||
@@ -337,20 +337,16 @@ static void atl1c_common_task(struct work_struct *work) | |||
337 | adapter = container_of(work, struct atl1c_adapter, common_task); | 337 | adapter = container_of(work, struct atl1c_adapter, common_task); |
338 | netdev = adapter->netdev; | 338 | netdev = adapter->netdev; |
339 | 339 | ||
340 | if (adapter->work_event & ATL1C_WORK_EVENT_RESET) { | 340 | if (test_and_clear_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event)) { |
341 | adapter->work_event &= ~ATL1C_WORK_EVENT_RESET; | ||
342 | netif_device_detach(netdev); | 341 | netif_device_detach(netdev); |
343 | atl1c_down(adapter); | 342 | atl1c_down(adapter); |
344 | atl1c_up(adapter); | 343 | atl1c_up(adapter); |
345 | netif_device_attach(netdev); | 344 | netif_device_attach(netdev); |
346 | return; | ||
347 | } | 345 | } |
348 | 346 | ||
349 | if (adapter->work_event & ATL1C_WORK_EVENT_LINK_CHANGE) { | 347 | if (test_and_clear_bit(ATL1C_WORK_EVENT_LINK_CHANGE, |
350 | adapter->work_event &= ~ATL1C_WORK_EVENT_LINK_CHANGE; | 348 | &adapter->work_event)) |
351 | atl1c_check_link_status(adapter); | 349 | atl1c_check_link_status(adapter); |
352 | } | ||
353 | return; | ||
354 | } | 350 | } |
355 | 351 | ||
356 | 352 | ||
@@ -369,7 +365,7 @@ static void atl1c_tx_timeout(struct net_device *netdev) | |||
369 | struct atl1c_adapter *adapter = netdev_priv(netdev); | 365 | struct atl1c_adapter *adapter = netdev_priv(netdev); |
370 | 366 | ||
371 | /* Do the reset outside of interrupt context */ | 367 | /* Do the reset outside of interrupt context */ |
372 | adapter->work_event |= ATL1C_WORK_EVENT_RESET; | 368 | set_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event); |
373 | schedule_work(&adapter->common_task); | 369 | schedule_work(&adapter->common_task); |
374 | } | 370 | } |
375 | 371 | ||
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h index 66823eded7a..2353eca3259 100644 --- a/drivers/net/benet/be.h +++ b/drivers/net/benet/be.h | |||
@@ -213,7 +213,7 @@ struct be_rx_stats { | |||
213 | 213 | ||
214 | struct be_rx_compl_info { | 214 | struct be_rx_compl_info { |
215 | u32 rss_hash; | 215 | u32 rss_hash; |
216 | u16 vid; | 216 | u16 vlan_tag; |
217 | u16 pkt_size; | 217 | u16 pkt_size; |
218 | u16 rxq_idx; | 218 | u16 rxq_idx; |
219 | u16 mac_id; | 219 | u16 mac_id; |
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index 1e2d825bb94..9dc9394fd4c 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -132,7 +132,7 @@ static void be_async_grp5_pvid_state_process(struct be_adapter *adapter, | |||
132 | struct be_async_event_grp5_pvid_state *evt) | 132 | struct be_async_event_grp5_pvid_state *evt) |
133 | { | 133 | { |
134 | if (evt->enabled) | 134 | if (evt->enabled) |
135 | adapter->pvid = evt->tag; | 135 | adapter->pvid = le16_to_cpu(evt->tag); |
136 | else | 136 | else |
137 | adapter->pvid = 0; | 137 | adapter->pvid = 0; |
138 | } | 138 | } |
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index 7cb5a114c73..9187fb4e08f 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -1018,7 +1018,8 @@ static void be_rx_compl_process(struct be_adapter *adapter, | |||
1018 | kfree_skb(skb); | 1018 | kfree_skb(skb); |
1019 | return; | 1019 | return; |
1020 | } | 1020 | } |
1021 | vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, rxcp->vid); | 1021 | vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, |
1022 | rxcp->vlan_tag); | ||
1022 | } else { | 1023 | } else { |
1023 | netif_receive_skb(skb); | 1024 | netif_receive_skb(skb); |
1024 | } | 1025 | } |
@@ -1076,7 +1077,8 @@ static void be_rx_compl_process_gro(struct be_adapter *adapter, | |||
1076 | if (likely(!rxcp->vlanf)) | 1077 | if (likely(!rxcp->vlanf)) |
1077 | napi_gro_frags(&eq_obj->napi); | 1078 | napi_gro_frags(&eq_obj->napi); |
1078 | else | 1079 | else |
1079 | vlan_gro_frags(&eq_obj->napi, adapter->vlan_grp, rxcp->vid); | 1080 | vlan_gro_frags(&eq_obj->napi, adapter->vlan_grp, |
1081 | rxcp->vlan_tag); | ||
1080 | } | 1082 | } |
1081 | 1083 | ||
1082 | static void be_parse_rx_compl_v1(struct be_adapter *adapter, | 1084 | static void be_parse_rx_compl_v1(struct be_adapter *adapter, |
@@ -1102,7 +1104,8 @@ static void be_parse_rx_compl_v1(struct be_adapter *adapter, | |||
1102 | rxcp->pkt_type = | 1104 | rxcp->pkt_type = |
1103 | AMAP_GET_BITS(struct amap_eth_rx_compl_v1, cast_enc, compl); | 1105 | AMAP_GET_BITS(struct amap_eth_rx_compl_v1, cast_enc, compl); |
1104 | rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vtm, compl); | 1106 | rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vtm, compl); |
1105 | rxcp->vid = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vlan_tag, compl); | 1107 | rxcp->vlan_tag = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vlan_tag, |
1108 | compl); | ||
1106 | } | 1109 | } |
1107 | 1110 | ||
1108 | static void be_parse_rx_compl_v0(struct be_adapter *adapter, | 1111 | static void be_parse_rx_compl_v0(struct be_adapter *adapter, |
@@ -1128,7 +1131,8 @@ static void be_parse_rx_compl_v0(struct be_adapter *adapter, | |||
1128 | rxcp->pkt_type = | 1131 | rxcp->pkt_type = |
1129 | AMAP_GET_BITS(struct amap_eth_rx_compl_v0, cast_enc, compl); | 1132 | AMAP_GET_BITS(struct amap_eth_rx_compl_v0, cast_enc, compl); |
1130 | rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vtm, compl); | 1133 | rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vtm, compl); |
1131 | rxcp->vid = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vlan_tag, compl); | 1134 | rxcp->vlan_tag = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vlan_tag, |
1135 | compl); | ||
1132 | } | 1136 | } |
1133 | 1137 | ||
1134 | static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo) | 1138 | static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo) |
@@ -1155,9 +1159,11 @@ static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo) | |||
1155 | rxcp->vlanf = 0; | 1159 | rxcp->vlanf = 0; |
1156 | 1160 | ||
1157 | if (!lancer_chip(adapter)) | 1161 | if (!lancer_chip(adapter)) |
1158 | rxcp->vid = swab16(rxcp->vid); | 1162 | rxcp->vlan_tag = swab16(rxcp->vlan_tag); |
1159 | 1163 | ||
1160 | if ((adapter->pvid == rxcp->vid) && !adapter->vlan_tag[rxcp->vid]) | 1164 | if (((adapter->pvid & VLAN_VID_MASK) == |
1165 | (rxcp->vlan_tag & VLAN_VID_MASK)) && | ||
1166 | !adapter->vlan_tag[rxcp->vlan_tag]) | ||
1161 | rxcp->vlanf = 0; | 1167 | rxcp->vlanf = 0; |
1162 | 1168 | ||
1163 | /* As the compl has been parsed, reset it; we wont touch it again */ | 1169 | /* As the compl has been parsed, reset it; we wont touch it again */ |
@@ -1873,6 +1879,7 @@ static void be_worker(struct work_struct *work) | |||
1873 | be_detect_dump_ue(adapter); | 1879 | be_detect_dump_ue(adapter); |
1874 | 1880 | ||
1875 | reschedule: | 1881 | reschedule: |
1882 | adapter->work_counter++; | ||
1876 | schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000)); | 1883 | schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000)); |
1877 | } | 1884 | } |
1878 | 1885 | ||
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 8e6d618b530..d8383a9af9a 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -8413,6 +8413,8 @@ bnx2_remove_one(struct pci_dev *pdev) | |||
8413 | 8413 | ||
8414 | unregister_netdev(dev); | 8414 | unregister_netdev(dev); |
8415 | 8415 | ||
8416 | del_timer_sync(&bp->timer); | ||
8417 | |||
8416 | if (bp->mips_firmware) | 8418 | if (bp->mips_firmware) |
8417 | release_firmware(bp->mips_firmware); | 8419 | release_firmware(bp->mips_firmware); |
8418 | if (bp->rv2p_firmware) | 8420 | if (bp->rv2p_firmware) |
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c index e83ac6dd6fc..16581df5ee4 100644 --- a/drivers/net/bnx2x/bnx2x_cmn.c +++ b/drivers/net/bnx2x/bnx2x_cmn.c | |||
@@ -2019,15 +2019,23 @@ static inline void bnx2x_set_pbd_gso(struct sk_buff *skb, | |||
2019 | static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb, | 2019 | static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb, |
2020 | u32 *parsing_data, u32 xmit_type) | 2020 | u32 *parsing_data, u32 xmit_type) |
2021 | { | 2021 | { |
2022 | *parsing_data |= ((tcp_hdrlen(skb)/4) << | 2022 | *parsing_data |= |
2023 | ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW_SHIFT) & | 2023 | ((((u8 *)skb_transport_header(skb) - skb->data) >> 1) << |
2024 | ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW; | 2024 | ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W_SHIFT) & |
2025 | ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W; | ||
2025 | 2026 | ||
2026 | *parsing_data |= ((((u8 *)tcp_hdr(skb) - skb->data) / 2) << | 2027 | if (xmit_type & XMIT_CSUM_TCP) { |
2027 | ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W_SHIFT) & | 2028 | *parsing_data |= ((tcp_hdrlen(skb) / 4) << |
2028 | ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W; | 2029 | ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW_SHIFT) & |
2030 | ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW; | ||
2029 | 2031 | ||
2030 | return skb_transport_header(skb) + tcp_hdrlen(skb) - skb->data; | 2032 | return skb_transport_header(skb) + tcp_hdrlen(skb) - skb->data; |
2033 | } else | ||
2034 | /* We support checksum offload for TCP and UDP only. | ||
2035 | * No need to pass the UDP header length - it's a constant. | ||
2036 | */ | ||
2037 | return skb_transport_header(skb) + | ||
2038 | sizeof(struct udphdr) - skb->data; | ||
2031 | } | 2039 | } |
2032 | 2040 | ||
2033 | /** | 2041 | /** |
@@ -2043,7 +2051,7 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb, | |||
2043 | struct eth_tx_parse_bd_e1x *pbd, | 2051 | struct eth_tx_parse_bd_e1x *pbd, |
2044 | u32 xmit_type) | 2052 | u32 xmit_type) |
2045 | { | 2053 | { |
2046 | u8 hlen = (skb_network_header(skb) - skb->data) / 2; | 2054 | u8 hlen = (skb_network_header(skb) - skb->data) >> 1; |
2047 | 2055 | ||
2048 | /* for now NS flag is not used in Linux */ | 2056 | /* for now NS flag is not used in Linux */ |
2049 | pbd->global_data = | 2057 | pbd->global_data = |
@@ -2051,9 +2059,15 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb, | |||
2051 | ETH_TX_PARSE_BD_E1X_LLC_SNAP_EN_SHIFT)); | 2059 | ETH_TX_PARSE_BD_E1X_LLC_SNAP_EN_SHIFT)); |
2052 | 2060 | ||
2053 | pbd->ip_hlen_w = (skb_transport_header(skb) - | 2061 | pbd->ip_hlen_w = (skb_transport_header(skb) - |
2054 | skb_network_header(skb)) / 2; | 2062 | skb_network_header(skb)) >> 1; |
2055 | 2063 | ||
2056 | hlen += pbd->ip_hlen_w + tcp_hdrlen(skb) / 2; | 2064 | hlen += pbd->ip_hlen_w; |
2065 | |||
2066 | /* We support checksum offload for TCP and UDP only */ | ||
2067 | if (xmit_type & XMIT_CSUM_TCP) | ||
2068 | hlen += tcp_hdrlen(skb) / 2; | ||
2069 | else | ||
2070 | hlen += sizeof(struct udphdr) / 2; | ||
2057 | 2071 | ||
2058 | pbd->total_hlen_w = cpu_to_le16(hlen); | 2072 | pbd->total_hlen_w = cpu_to_le16(hlen); |
2059 | hlen = hlen*2; | 2073 | hlen = hlen*2; |
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 494bf960442..31912f17653 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -1482,8 +1482,11 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best, | |||
1482 | 1482 | ||
1483 | static int agg_device_up(const struct aggregator *agg) | 1483 | static int agg_device_up(const struct aggregator *agg) |
1484 | { | 1484 | { |
1485 | return (netif_running(agg->slave->dev) && | 1485 | struct port *port = agg->lag_ports; |
1486 | netif_carrier_ok(agg->slave->dev)); | 1486 | if (!port) |
1487 | return 0; | ||
1488 | return (netif_running(port->slave->dev) && | ||
1489 | netif_carrier_ok(port->slave->dev)); | ||
1487 | } | 1490 | } |
1488 | 1491 | ||
1489 | /** | 1492 | /** |
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h index b28baff7086..01b8a6af275 100644 --- a/drivers/net/bonding/bond_3ad.h +++ b/drivers/net/bonding/bond_3ad.h | |||
@@ -39,7 +39,7 @@ | |||
39 | 39 | ||
40 | typedef struct mac_addr { | 40 | typedef struct mac_addr { |
41 | u8 mac_addr_value[ETH_ALEN]; | 41 | u8 mac_addr_value[ETH_ALEN]; |
42 | } mac_addr_t; | 42 | } __packed mac_addr_t; |
43 | 43 | ||
44 | enum { | 44 | enum { |
45 | BOND_AD_STABLE = 0, | 45 | BOND_AD_STABLE = 0, |
@@ -134,12 +134,12 @@ typedef struct lacpdu { | |||
134 | u8 tlv_type_terminator; // = terminator | 134 | u8 tlv_type_terminator; // = terminator |
135 | u8 terminator_length; // = 0 | 135 | u8 terminator_length; // = 0 |
136 | u8 reserved_50[50]; // = 0 | 136 | u8 reserved_50[50]; // = 0 |
137 | } lacpdu_t; | 137 | } __packed lacpdu_t; |
138 | 138 | ||
139 | typedef struct lacpdu_header { | 139 | typedef struct lacpdu_header { |
140 | struct ethhdr hdr; | 140 | struct ethhdr hdr; |
141 | struct lacpdu lacpdu; | 141 | struct lacpdu lacpdu; |
142 | } lacpdu_header_t; | 142 | } __packed lacpdu_header_t; |
143 | 143 | ||
144 | // Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) | 144 | // Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) |
145 | typedef struct bond_marker { | 145 | typedef struct bond_marker { |
@@ -155,12 +155,12 @@ typedef struct bond_marker { | |||
155 | u8 tlv_type_terminator; // = 0x00 | 155 | u8 tlv_type_terminator; // = 0x00 |
156 | u8 terminator_length; // = 0x00 | 156 | u8 terminator_length; // = 0x00 |
157 | u8 reserved_90[90]; // = 0 | 157 | u8 reserved_90[90]; // = 0 |
158 | } bond_marker_t; | 158 | } __packed bond_marker_t; |
159 | 159 | ||
160 | typedef struct bond_marker_header { | 160 | typedef struct bond_marker_header { |
161 | struct ethhdr hdr; | 161 | struct ethhdr hdr; |
162 | struct bond_marker marker; | 162 | struct bond_marker marker; |
163 | } bond_marker_header_t; | 163 | } __packed bond_marker_header_t; |
164 | 164 | ||
165 | #pragma pack() | 165 | #pragma pack() |
166 | 166 | ||
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c index bd1d811c204..5fedc337556 100644 --- a/drivers/net/can/mscan/mpc5xxx_can.c +++ b/drivers/net/can/mscan/mpc5xxx_can.c | |||
@@ -247,8 +247,10 @@ static u32 __devinit mpc512x_can_get_clock(struct platform_device *ofdev, | |||
247 | } | 247 | } |
248 | #endif /* CONFIG_PPC_MPC512x */ | 248 | #endif /* CONFIG_PPC_MPC512x */ |
249 | 249 | ||
250 | static struct of_device_id mpc5xxx_can_table[]; | ||
250 | static int __devinit mpc5xxx_can_probe(struct platform_device *ofdev) | 251 | static int __devinit mpc5xxx_can_probe(struct platform_device *ofdev) |
251 | { | 252 | { |
253 | const struct of_device_id *match; | ||
252 | struct mpc5xxx_can_data *data; | 254 | struct mpc5xxx_can_data *data; |
253 | struct device_node *np = ofdev->dev.of_node; | 255 | struct device_node *np = ofdev->dev.of_node; |
254 | struct net_device *dev; | 256 | struct net_device *dev; |
@@ -258,9 +260,10 @@ static int __devinit mpc5xxx_can_probe(struct platform_device *ofdev) | |||
258 | int irq, mscan_clksrc = 0; | 260 | int irq, mscan_clksrc = 0; |
259 | int err = -ENOMEM; | 261 | int err = -ENOMEM; |
260 | 262 | ||
261 | if (!ofdev->dev.of_match) | 263 | match = of_match_device(mpc5xxx_can_table, &ofdev->dev); |
264 | if (!match) | ||
262 | return -EINVAL; | 265 | return -EINVAL; |
263 | data = (struct mpc5xxx_can_data *)ofdev->dev.of_match->data; | 266 | data = match->data; |
264 | 267 | ||
265 | base = of_iomap(np, 0); | 268 | base = of_iomap(np, 0); |
266 | if (!base) { | 269 | if (!base) { |
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index a358ea9445a..f501bba1fc6 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c | |||
@@ -346,10 +346,10 @@ static void sja1000_rx(struct net_device *dev) | |||
346 | | (priv->read_reg(priv, REG_ID2) >> 5); | 346 | | (priv->read_reg(priv, REG_ID2) >> 5); |
347 | } | 347 | } |
348 | 348 | ||
349 | cf->can_dlc = get_can_dlc(fi & 0x0F); | ||
349 | if (fi & FI_RTR) { | 350 | if (fi & FI_RTR) { |
350 | id |= CAN_RTR_FLAG; | 351 | id |= CAN_RTR_FLAG; |
351 | } else { | 352 | } else { |
352 | cf->can_dlc = get_can_dlc(fi & 0x0F); | ||
353 | for (i = 0; i < cf->can_dlc; i++) | 353 | for (i = 0; i < cf->can_dlc; i++) |
354 | cf->data[i] = priv->read_reg(priv, dreg++); | 354 | cf->data[i] = priv->read_reg(priv, dreg++); |
355 | } | 355 | } |
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index b423965a78d..1b49df6b247 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c | |||
@@ -583,7 +583,9 @@ static int slcan_open(struct tty_struct *tty) | |||
583 | /* Done. We have linked the TTY line to a channel. */ | 583 | /* Done. We have linked the TTY line to a channel. */ |
584 | rtnl_unlock(); | 584 | rtnl_unlock(); |
585 | tty->receive_room = 65536; /* We don't flow control */ | 585 | tty->receive_room = 65536; /* We don't flow control */ |
586 | return sl->dev->base_addr; | 586 | |
587 | /* TTY layer expects 0 on success */ | ||
588 | return 0; | ||
587 | 589 | ||
588 | err_free_chan: | 590 | err_free_chan: |
589 | sl->tty = NULL; | 591 | sl->tty = NULL; |
diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c index 3e2e734fecb..f3bbdcef338 100644 --- a/drivers/net/ehea/ehea_ethtool.c +++ b/drivers/net/ehea/ehea_ethtool.c | |||
@@ -55,15 +55,20 @@ static int ehea_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
55 | cmd->duplex = -1; | 55 | cmd->duplex = -1; |
56 | } | 56 | } |
57 | 57 | ||
58 | cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full | 58 | if (cmd->speed == SPEED_10000) { |
59 | | SUPPORTED_100baseT_Full | SUPPORTED_100baseT_Half | 59 | cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); |
60 | | SUPPORTED_10baseT_Full | SUPPORTED_10baseT_Half | 60 | cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE); |
61 | | SUPPORTED_Autoneg | SUPPORTED_FIBRE); | 61 | cmd->port = PORT_FIBRE; |
62 | 62 | } else { | |
63 | cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_Autoneg | 63 | cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full |
64 | | ADVERTISED_FIBRE); | 64 | | SUPPORTED_100baseT_Half | SUPPORTED_10baseT_Full |
65 | | SUPPORTED_10baseT_Half | SUPPORTED_Autoneg | ||
66 | | SUPPORTED_TP); | ||
67 | cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg | ||
68 | | ADVERTISED_TP); | ||
69 | cmd->port = PORT_TP; | ||
70 | } | ||
65 | 71 | ||
66 | cmd->port = PORT_FIBRE; | ||
67 | cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE; | 72 | cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE; |
68 | 73 | ||
69 | return 0; | 74 | return 0; |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index f75d3144b8a..cf79cf759e1 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -2688,9 +2688,6 @@ static int ehea_open(struct net_device *dev) | |||
2688 | netif_start_queue(dev); | 2688 | netif_start_queue(dev); |
2689 | } | 2689 | } |
2690 | 2690 | ||
2691 | init_waitqueue_head(&port->swqe_avail_wq); | ||
2692 | init_waitqueue_head(&port->restart_wq); | ||
2693 | |||
2694 | mutex_unlock(&port->port_lock); | 2691 | mutex_unlock(&port->port_lock); |
2695 | 2692 | ||
2696 | return ret; | 2693 | return ret; |
@@ -3040,11 +3037,14 @@ static void ehea_rereg_mrs(void) | |||
3040 | 3037 | ||
3041 | if (dev->flags & IFF_UP) { | 3038 | if (dev->flags & IFF_UP) { |
3042 | mutex_lock(&port->port_lock); | 3039 | mutex_lock(&port->port_lock); |
3043 | port_napi_enable(port); | ||
3044 | ret = ehea_restart_qps(dev); | 3040 | ret = ehea_restart_qps(dev); |
3045 | check_sqs(port); | 3041 | if (!ret) { |
3046 | if (!ret) | 3042 | check_sqs(port); |
3043 | port_napi_enable(port); | ||
3047 | netif_wake_queue(dev); | 3044 | netif_wake_queue(dev); |
3045 | } else { | ||
3046 | netdev_err(dev, "Unable to restart QPS\n"); | ||
3047 | } | ||
3048 | mutex_unlock(&port->port_lock); | 3048 | mutex_unlock(&port->port_lock); |
3049 | } | 3049 | } |
3050 | } | 3050 | } |
@@ -3273,6 +3273,9 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter, | |||
3273 | 3273 | ||
3274 | INIT_WORK(&port->reset_task, ehea_reset_port); | 3274 | INIT_WORK(&port->reset_task, ehea_reset_port); |
3275 | 3275 | ||
3276 | init_waitqueue_head(&port->swqe_avail_wq); | ||
3277 | init_waitqueue_head(&port->restart_wq); | ||
3278 | |||
3276 | ret = register_netdev(dev); | 3279 | ret = register_netdev(dev); |
3277 | if (ret) { | 3280 | if (ret) { |
3278 | pr_err("register_netdev failed. ret=%d\n", ret); | 3281 | pr_err("register_netdev failed. ret=%d\n", ret); |
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index 24cb953900d..5131e61c358 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c | |||
@@ -998,8 +998,10 @@ static const struct net_device_ops fs_enet_netdev_ops = { | |||
998 | #endif | 998 | #endif |
999 | }; | 999 | }; |
1000 | 1000 | ||
1001 | static struct of_device_id fs_enet_match[]; | ||
1001 | static int __devinit fs_enet_probe(struct platform_device *ofdev) | 1002 | static int __devinit fs_enet_probe(struct platform_device *ofdev) |
1002 | { | 1003 | { |
1004 | const struct of_device_id *match; | ||
1003 | struct net_device *ndev; | 1005 | struct net_device *ndev; |
1004 | struct fs_enet_private *fep; | 1006 | struct fs_enet_private *fep; |
1005 | struct fs_platform_info *fpi; | 1007 | struct fs_platform_info *fpi; |
@@ -1007,14 +1009,15 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev) | |||
1007 | const u8 *mac_addr; | 1009 | const u8 *mac_addr; |
1008 | int privsize, len, ret = -ENODEV; | 1010 | int privsize, len, ret = -ENODEV; |
1009 | 1011 | ||
1010 | if (!ofdev->dev.of_match) | 1012 | match = of_match_device(fs_enet_match, &ofdev->dev); |
1013 | if (!match) | ||
1011 | return -EINVAL; | 1014 | return -EINVAL; |
1012 | 1015 | ||
1013 | fpi = kzalloc(sizeof(*fpi), GFP_KERNEL); | 1016 | fpi = kzalloc(sizeof(*fpi), GFP_KERNEL); |
1014 | if (!fpi) | 1017 | if (!fpi) |
1015 | return -ENOMEM; | 1018 | return -ENOMEM; |
1016 | 1019 | ||
1017 | if (!IS_FEC(ofdev->dev.of_match)) { | 1020 | if (!IS_FEC(match)) { |
1018 | data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len); | 1021 | data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len); |
1019 | if (!data || len != 4) | 1022 | if (!data || len != 4) |
1020 | goto out_free_fpi; | 1023 | goto out_free_fpi; |
@@ -1049,7 +1052,7 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev) | |||
1049 | fep->dev = &ofdev->dev; | 1052 | fep->dev = &ofdev->dev; |
1050 | fep->ndev = ndev; | 1053 | fep->ndev = ndev; |
1051 | fep->fpi = fpi; | 1054 | fep->fpi = fpi; |
1052 | fep->ops = ofdev->dev.of_match->data; | 1055 | fep->ops = match->data; |
1053 | 1056 | ||
1054 | ret = fep->ops->setup_data(ndev); | 1057 | ret = fep->ops->setup_data(ndev); |
1055 | if (ret) | 1058 | if (ret) |
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c index 61035fc5599..b9fbc83d64a 100644 --- a/drivers/net/fs_enet/mac-fec.c +++ b/drivers/net/fs_enet/mac-fec.c | |||
@@ -226,8 +226,8 @@ static void set_multicast_finish(struct net_device *dev) | |||
226 | } | 226 | } |
227 | 227 | ||
228 | FC(fecp, r_cntrl, FEC_RCNTRL_PROM); | 228 | FC(fecp, r_cntrl, FEC_RCNTRL_PROM); |
229 | FW(fecp, hash_table_high, fep->fec.hthi); | 229 | FW(fecp, grp_hash_table_high, fep->fec.hthi); |
230 | FW(fecp, hash_table_low, fep->fec.htlo); | 230 | FW(fecp, grp_hash_table_low, fep->fec.htlo); |
231 | } | 231 | } |
232 | 232 | ||
233 | static void set_multicast_list(struct net_device *dev) | 233 | static void set_multicast_list(struct net_device *dev) |
@@ -273,8 +273,8 @@ static void restart(struct net_device *dev) | |||
273 | /* | 273 | /* |
274 | * Reset all multicast. | 274 | * Reset all multicast. |
275 | */ | 275 | */ |
276 | FW(fecp, hash_table_high, fep->fec.hthi); | 276 | FW(fecp, grp_hash_table_high, fep->fec.hthi); |
277 | FW(fecp, hash_table_low, fep->fec.htlo); | 277 | FW(fecp, grp_hash_table_low, fep->fec.htlo); |
278 | 278 | ||
279 | /* | 279 | /* |
280 | * Set maximum receive buffer size. | 280 | * Set maximum receive buffer size. |
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c index 7e840d373ab..6a2e150e75b 100644 --- a/drivers/net/fs_enet/mii-fec.c +++ b/drivers/net/fs_enet/mii-fec.c | |||
@@ -101,17 +101,20 @@ static int fs_enet_fec_mii_reset(struct mii_bus *bus) | |||
101 | return 0; | 101 | return 0; |
102 | } | 102 | } |
103 | 103 | ||
104 | static struct of_device_id fs_enet_mdio_fec_match[]; | ||
104 | static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev) | 105 | static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev) |
105 | { | 106 | { |
107 | const struct of_device_id *match; | ||
106 | struct resource res; | 108 | struct resource res; |
107 | struct mii_bus *new_bus; | 109 | struct mii_bus *new_bus; |
108 | struct fec_info *fec; | 110 | struct fec_info *fec; |
109 | int (*get_bus_freq)(struct device_node *); | 111 | int (*get_bus_freq)(struct device_node *); |
110 | int ret = -ENOMEM, clock, speed; | 112 | int ret = -ENOMEM, clock, speed; |
111 | 113 | ||
112 | if (!ofdev->dev.of_match) | 114 | match = of_match_device(fs_enet_mdio_fec_match, &ofdev->dev); |
115 | if (!match) | ||
113 | return -EINVAL; | 116 | return -EINVAL; |
114 | get_bus_freq = ofdev->dev.of_match->data; | 117 | get_bus_freq = match->data; |
115 | 118 | ||
116 | new_bus = mdiobus_alloc(); | 119 | new_bus = mdiobus_alloc(); |
117 | if (!new_bus) | 120 | if (!new_bus) |
diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index a31661948c4..9bd7746cbfc 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c | |||
@@ -139,11 +139,11 @@ static int ftmac100_reset(struct ftmac100 *priv) | |||
139 | * that hardware reset completed (what the f*ck). | 139 | * that hardware reset completed (what the f*ck). |
140 | * We still need to wait for a while. | 140 | * We still need to wait for a while. |
141 | */ | 141 | */ |
142 | usleep_range(500, 1000); | 142 | udelay(500); |
143 | return 0; | 143 | return 0; |
144 | } | 144 | } |
145 | 145 | ||
146 | usleep_range(1000, 10000); | 146 | udelay(1000); |
147 | } | 147 | } |
148 | 148 | ||
149 | netdev_err(netdev, "software reset failed\n"); | 149 | netdev_err(netdev, "software reset failed\n"); |
@@ -772,7 +772,7 @@ static int ftmac100_mdio_read(struct net_device *netdev, int phy_id, int reg) | |||
772 | if ((phycr & FTMAC100_PHYCR_MIIRD) == 0) | 772 | if ((phycr & FTMAC100_PHYCR_MIIRD) == 0) |
773 | return phycr & FTMAC100_PHYCR_MIIRDATA; | 773 | return phycr & FTMAC100_PHYCR_MIIRDATA; |
774 | 774 | ||
775 | usleep_range(100, 1000); | 775 | udelay(100); |
776 | } | 776 | } |
777 | 777 | ||
778 | netdev_err(netdev, "mdio read timed out\n"); | 778 | netdev_err(netdev, "mdio read timed out\n"); |
@@ -801,7 +801,7 @@ static void ftmac100_mdio_write(struct net_device *netdev, int phy_id, int reg, | |||
801 | if ((phycr & FTMAC100_PHYCR_MIIWR) == 0) | 801 | if ((phycr & FTMAC100_PHYCR_MIIWR) == 0) |
802 | return; | 802 | return; |
803 | 803 | ||
804 | usleep_range(100, 1000); | 804 | udelay(100); |
805 | } | 805 | } |
806 | 806 | ||
807 | netdev_err(netdev, "mdio write timed out\n"); | 807 | netdev_err(netdev, "mdio write timed out\n"); |
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c index c5ef62ceb84..1cd481c0420 100644 --- a/drivers/net/hydra.c +++ b/drivers/net/hydra.c | |||
@@ -98,15 +98,15 @@ static const struct net_device_ops hydra_netdev_ops = { | |||
98 | .ndo_open = hydra_open, | 98 | .ndo_open = hydra_open, |
99 | .ndo_stop = hydra_close, | 99 | .ndo_stop = hydra_close, |
100 | 100 | ||
101 | .ndo_start_xmit = ei_start_xmit, | 101 | .ndo_start_xmit = __ei_start_xmit, |
102 | .ndo_tx_timeout = ei_tx_timeout, | 102 | .ndo_tx_timeout = __ei_tx_timeout, |
103 | .ndo_get_stats = ei_get_stats, | 103 | .ndo_get_stats = __ei_get_stats, |
104 | .ndo_set_multicast_list = ei_set_multicast_list, | 104 | .ndo_set_multicast_list = __ei_set_multicast_list, |
105 | .ndo_validate_addr = eth_validate_addr, | 105 | .ndo_validate_addr = eth_validate_addr, |
106 | .ndo_set_mac_address = eth_mac_addr, | 106 | .ndo_set_mac_address = eth_mac_addr, |
107 | .ndo_change_mtu = eth_change_mtu, | 107 | .ndo_change_mtu = eth_change_mtu, |
108 | #ifdef CONFIG_NET_POLL_CONTROLLER | 108 | #ifdef CONFIG_NET_POLL_CONTROLLER |
109 | .ndo_poll_controller = ei_poll, | 109 | .ndo_poll_controller = __ei_poll, |
110 | #endif | 110 | #endif |
111 | }; | 111 | }; |
112 | 112 | ||
@@ -125,7 +125,7 @@ static int __devinit hydra_init(struct zorro_dev *z) | |||
125 | 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, | 125 | 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, |
126 | }; | 126 | }; |
127 | 127 | ||
128 | dev = alloc_ei_netdev(); | 128 | dev = ____alloc_ei_netdev(0); |
129 | if (!dev) | 129 | if (!dev) |
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | 131 | ||
diff --git a/drivers/net/mii.c b/drivers/net/mii.c index 0a6c6a2e755..d4fc00b1ff9 100644 --- a/drivers/net/mii.c +++ b/drivers/net/mii.c | |||
@@ -49,6 +49,10 @@ static u32 mii_get_an(struct mii_if_info *mii, u16 addr) | |||
49 | result |= ADVERTISED_100baseT_Half; | 49 | result |= ADVERTISED_100baseT_Half; |
50 | if (advert & ADVERTISE_100FULL) | 50 | if (advert & ADVERTISE_100FULL) |
51 | result |= ADVERTISED_100baseT_Full; | 51 | result |= ADVERTISED_100baseT_Full; |
52 | if (advert & ADVERTISE_PAUSE_CAP) | ||
53 | result |= ADVERTISED_Pause; | ||
54 | if (advert & ADVERTISE_PAUSE_ASYM) | ||
55 | result |= ADVERTISED_Asym_Pause; | ||
52 | 56 | ||
53 | return result; | 57 | return result; |
54 | } | 58 | } |
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c index 30be8c634eb..7298a34bc79 100644 --- a/drivers/net/ne-h8300.c +++ b/drivers/net/ne-h8300.c | |||
@@ -167,7 +167,7 @@ static void cleanup_card(struct net_device *dev) | |||
167 | #ifndef MODULE | 167 | #ifndef MODULE |
168 | struct net_device * __init ne_probe(int unit) | 168 | struct net_device * __init ne_probe(int unit) |
169 | { | 169 | { |
170 | struct net_device *dev = alloc_ei_netdev(); | 170 | struct net_device *dev = ____alloc_ei_netdev(0); |
171 | int err; | 171 | int err; |
172 | 172 | ||
173 | if (!dev) | 173 | if (!dev) |
@@ -197,15 +197,15 @@ static const struct net_device_ops ne_netdev_ops = { | |||
197 | .ndo_open = ne_open, | 197 | .ndo_open = ne_open, |
198 | .ndo_stop = ne_close, | 198 | .ndo_stop = ne_close, |
199 | 199 | ||
200 | .ndo_start_xmit = ei_start_xmit, | 200 | .ndo_start_xmit = __ei_start_xmit, |
201 | .ndo_tx_timeout = ei_tx_timeout, | 201 | .ndo_tx_timeout = __ei_tx_timeout, |
202 | .ndo_get_stats = ei_get_stats, | 202 | .ndo_get_stats = __ei_get_stats, |
203 | .ndo_set_multicast_list = ei_set_multicast_list, | 203 | .ndo_set_multicast_list = __ei_set_multicast_list, |
204 | .ndo_validate_addr = eth_validate_addr, | 204 | .ndo_validate_addr = eth_validate_addr, |
205 | .ndo_set_mac_address = eth_mac_addr, | 205 | .ndo_set_mac_address = eth_mac_addr, |
206 | .ndo_change_mtu = eth_change_mtu, | 206 | .ndo_change_mtu = eth_change_mtu, |
207 | #ifdef CONFIG_NET_POLL_CONTROLLER | 207 | #ifdef CONFIG_NET_POLL_CONTROLLER |
208 | .ndo_poll_controller = ei_poll, | 208 | .ndo_poll_controller = __ei_poll, |
209 | #endif | 209 | #endif |
210 | }; | 210 | }; |
211 | 211 | ||
@@ -637,7 +637,7 @@ int init_module(void) | |||
637 | int err; | 637 | int err; |
638 | 638 | ||
639 | for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { | 639 | for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { |
640 | struct net_device *dev = alloc_ei_netdev(); | 640 | struct net_device *dev = ____alloc_ei_netdev(0); |
641 | if (!dev) | 641 | if (!dev) |
642 | break; | 642 | break; |
643 | if (io[this_dev]) { | 643 | if (io[this_dev]) { |
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index dfb67eb2a94..eb41e44921e 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c | |||
@@ -671,6 +671,7 @@ static int netconsole_netdev_event(struct notifier_block *this, | |||
671 | goto done; | 671 | goto done; |
672 | 672 | ||
673 | spin_lock_irqsave(&target_list_lock, flags); | 673 | spin_lock_irqsave(&target_list_lock, flags); |
674 | restart: | ||
674 | list_for_each_entry(nt, &target_list, list) { | 675 | list_for_each_entry(nt, &target_list, list) { |
675 | netconsole_target_get(nt); | 676 | netconsole_target_get(nt); |
676 | if (nt->np.dev == dev) { | 677 | if (nt->np.dev == dev) { |
@@ -683,9 +684,16 @@ static int netconsole_netdev_event(struct notifier_block *this, | |||
683 | * rtnl_lock already held | 684 | * rtnl_lock already held |
684 | */ | 685 | */ |
685 | if (nt->np.dev) { | 686 | if (nt->np.dev) { |
687 | spin_unlock_irqrestore( | ||
688 | &target_list_lock, | ||
689 | flags); | ||
686 | __netpoll_cleanup(&nt->np); | 690 | __netpoll_cleanup(&nt->np); |
691 | spin_lock_irqsave(&target_list_lock, | ||
692 | flags); | ||
687 | dev_put(nt->np.dev); | 693 | dev_put(nt->np.dev); |
688 | nt->np.dev = NULL; | 694 | nt->np.dev = NULL; |
695 | netconsole_target_put(nt); | ||
696 | goto restart; | ||
689 | } | 697 | } |
690 | /* Fall through */ | 698 | /* Fall through */ |
691 | case NETDEV_GOING_DOWN: | 699 | case NETDEV_GOING_DOWN: |
diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c index 2ef2f9cdefa..56d049a472d 100644 --- a/drivers/net/pch_gbe/pch_gbe_main.c +++ b/drivers/net/pch_gbe/pch_gbe_main.c | |||
@@ -34,6 +34,10 @@ const char pch_driver_version[] = DRV_VERSION; | |||
34 | #define PCH_GBE_COPYBREAK_DEFAULT 256 | 34 | #define PCH_GBE_COPYBREAK_DEFAULT 256 |
35 | #define PCH_GBE_PCI_BAR 1 | 35 | #define PCH_GBE_PCI_BAR 1 |
36 | 36 | ||
37 | /* Macros for ML7223 */ | ||
38 | #define PCI_VENDOR_ID_ROHM 0x10db | ||
39 | #define PCI_DEVICE_ID_ROHM_ML7223_GBE 0x8013 | ||
40 | |||
37 | #define PCH_GBE_TX_WEIGHT 64 | 41 | #define PCH_GBE_TX_WEIGHT 64 |
38 | #define PCH_GBE_RX_WEIGHT 64 | 42 | #define PCH_GBE_RX_WEIGHT 64 |
39 | #define PCH_GBE_RX_BUFFER_WRITE 16 | 43 | #define PCH_GBE_RX_BUFFER_WRITE 16 |
@@ -43,8 +47,7 @@ const char pch_driver_version[] = DRV_VERSION; | |||
43 | 47 | ||
44 | #define PCH_GBE_MAC_RGMII_CTRL_SETTING ( \ | 48 | #define PCH_GBE_MAC_RGMII_CTRL_SETTING ( \ |
45 | PCH_GBE_CHIP_TYPE_INTERNAL | \ | 49 | PCH_GBE_CHIP_TYPE_INTERNAL | \ |
46 | PCH_GBE_RGMII_MODE_RGMII | \ | 50 | PCH_GBE_RGMII_MODE_RGMII \ |
47 | PCH_GBE_CRS_SEL \ | ||
48 | ) | 51 | ) |
49 | 52 | ||
50 | /* Ethertype field values */ | 53 | /* Ethertype field values */ |
@@ -1494,12 +1497,11 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter, | |||
1494 | /* Write meta date of skb */ | 1497 | /* Write meta date of skb */ |
1495 | skb_put(skb, length); | 1498 | skb_put(skb, length); |
1496 | skb->protocol = eth_type_trans(skb, netdev); | 1499 | skb->protocol = eth_type_trans(skb, netdev); |
1497 | if ((tcp_ip_status & PCH_GBE_RXD_ACC_STAT_TCPIPOK) == | 1500 | if (tcp_ip_status & PCH_GBE_RXD_ACC_STAT_TCPIPOK) |
1498 | PCH_GBE_RXD_ACC_STAT_TCPIPOK) { | ||
1499 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
1500 | } else { | ||
1501 | skb->ip_summed = CHECKSUM_NONE; | 1501 | skb->ip_summed = CHECKSUM_NONE; |
1502 | } | 1502 | else |
1503 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
1504 | |||
1503 | napi_gro_receive(&adapter->napi, skb); | 1505 | napi_gro_receive(&adapter->napi, skb); |
1504 | (*work_done)++; | 1506 | (*work_done)++; |
1505 | pr_debug("Receive skb->ip_summed: %d length: %d\n", | 1507 | pr_debug("Receive skb->ip_summed: %d length: %d\n", |
@@ -2420,6 +2422,13 @@ static DEFINE_PCI_DEVICE_TABLE(pch_gbe_pcidev_id) = { | |||
2420 | .class = (PCI_CLASS_NETWORK_ETHERNET << 8), | 2422 | .class = (PCI_CLASS_NETWORK_ETHERNET << 8), |
2421 | .class_mask = (0xFFFF00) | 2423 | .class_mask = (0xFFFF00) |
2422 | }, | 2424 | }, |
2425 | {.vendor = PCI_VENDOR_ID_ROHM, | ||
2426 | .device = PCI_DEVICE_ID_ROHM_ML7223_GBE, | ||
2427 | .subvendor = PCI_ANY_ID, | ||
2428 | .subdevice = PCI_ANY_ID, | ||
2429 | .class = (PCI_CLASS_NETWORK_ETHERNET << 8), | ||
2430 | .class_mask = (0xFFFF00) | ||
2431 | }, | ||
2423 | /* required last entry */ | 2432 | /* required last entry */ |
2424 | {0} | 2433 | {0} |
2425 | }; | 2434 | }; |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 493b0de3848..397c36810a1 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -170,6 +170,16 @@ static const struct { | |||
170 | }; | 170 | }; |
171 | #undef _R | 171 | #undef _R |
172 | 172 | ||
173 | static const struct rtl_firmware_info { | ||
174 | int mac_version; | ||
175 | const char *fw_name; | ||
176 | } rtl_firmware_infos[] = { | ||
177 | { .mac_version = RTL_GIGA_MAC_VER_25, .fw_name = FIRMWARE_8168D_1 }, | ||
178 | { .mac_version = RTL_GIGA_MAC_VER_26, .fw_name = FIRMWARE_8168D_2 }, | ||
179 | { .mac_version = RTL_GIGA_MAC_VER_29, .fw_name = FIRMWARE_8105E_1 }, | ||
180 | { .mac_version = RTL_GIGA_MAC_VER_30, .fw_name = FIRMWARE_8105E_1 } | ||
181 | }; | ||
182 | |||
173 | enum cfg_version { | 183 | enum cfg_version { |
174 | RTL_CFG_0 = 0x00, | 184 | RTL_CFG_0 = 0x00, |
175 | RTL_CFG_1, | 185 | RTL_CFG_1, |
@@ -565,6 +575,7 @@ struct rtl8169_private { | |||
565 | u32 saved_wolopts; | 575 | u32 saved_wolopts; |
566 | 576 | ||
567 | const struct firmware *fw; | 577 | const struct firmware *fw; |
578 | #define RTL_FIRMWARE_UNKNOWN ERR_PTR(-EAGAIN); | ||
568 | }; | 579 | }; |
569 | 580 | ||
570 | MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); | 581 | MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); |
@@ -1789,25 +1800,26 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | |||
1789 | 1800 | ||
1790 | static void rtl_release_firmware(struct rtl8169_private *tp) | 1801 | static void rtl_release_firmware(struct rtl8169_private *tp) |
1791 | { | 1802 | { |
1792 | release_firmware(tp->fw); | 1803 | if (!IS_ERR_OR_NULL(tp->fw)) |
1793 | tp->fw = NULL; | 1804 | release_firmware(tp->fw); |
1805 | tp->fw = RTL_FIRMWARE_UNKNOWN; | ||
1794 | } | 1806 | } |
1795 | 1807 | ||
1796 | static int rtl_apply_firmware(struct rtl8169_private *tp, const char *fw_name) | 1808 | static void rtl_apply_firmware(struct rtl8169_private *tp) |
1797 | { | 1809 | { |
1798 | const struct firmware **fw = &tp->fw; | 1810 | const struct firmware *fw = tp->fw; |
1799 | int rc = !*fw; | ||
1800 | |||
1801 | if (rc) { | ||
1802 | rc = request_firmware(fw, fw_name, &tp->pci_dev->dev); | ||
1803 | if (rc < 0) | ||
1804 | goto out; | ||
1805 | } | ||
1806 | 1811 | ||
1807 | /* TODO: release firmware once rtl_phy_write_fw signals failures. */ | 1812 | /* TODO: release firmware once rtl_phy_write_fw signals failures. */ |
1808 | rtl_phy_write_fw(tp, *fw); | 1813 | if (!IS_ERR_OR_NULL(fw)) |
1809 | out: | 1814 | rtl_phy_write_fw(tp, fw); |
1810 | return rc; | 1815 | } |
1816 | |||
1817 | static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val) | ||
1818 | { | ||
1819 | if (rtl_readphy(tp, reg) != val) | ||
1820 | netif_warn(tp, hw, tp->dev, "chipset not ready for firmware\n"); | ||
1821 | else | ||
1822 | rtl_apply_firmware(tp); | ||
1811 | } | 1823 | } |
1812 | 1824 | ||
1813 | static void rtl8169s_hw_phy_config(struct rtl8169_private *tp) | 1825 | static void rtl8169s_hw_phy_config(struct rtl8169_private *tp) |
@@ -2246,10 +2258,8 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp) | |||
2246 | 2258 | ||
2247 | rtl_writephy(tp, 0x1f, 0x0005); | 2259 | rtl_writephy(tp, 0x1f, 0x0005); |
2248 | rtl_writephy(tp, 0x05, 0x001b); | 2260 | rtl_writephy(tp, 0x05, 0x001b); |
2249 | if ((rtl_readphy(tp, 0x06) != 0xbf00) || | 2261 | |
2250 | (rtl_apply_firmware(tp, FIRMWARE_8168D_1) < 0)) { | 2262 | rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xbf00); |
2251 | netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); | ||
2252 | } | ||
2253 | 2263 | ||
2254 | rtl_writephy(tp, 0x1f, 0x0000); | 2264 | rtl_writephy(tp, 0x1f, 0x0000); |
2255 | } | 2265 | } |
@@ -2351,10 +2361,8 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp) | |||
2351 | 2361 | ||
2352 | rtl_writephy(tp, 0x1f, 0x0005); | 2362 | rtl_writephy(tp, 0x1f, 0x0005); |
2353 | rtl_writephy(tp, 0x05, 0x001b); | 2363 | rtl_writephy(tp, 0x05, 0x001b); |
2354 | if ((rtl_readphy(tp, 0x06) != 0xb300) || | 2364 | |
2355 | (rtl_apply_firmware(tp, FIRMWARE_8168D_2) < 0)) { | 2365 | rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xb300); |
2356 | netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); | ||
2357 | } | ||
2358 | 2366 | ||
2359 | rtl_writephy(tp, 0x1f, 0x0000); | 2367 | rtl_writephy(tp, 0x1f, 0x0000); |
2360 | } | 2368 | } |
@@ -2474,8 +2482,7 @@ static void rtl8105e_hw_phy_config(struct rtl8169_private *tp) | |||
2474 | rtl_writephy(tp, 0x18, 0x0310); | 2482 | rtl_writephy(tp, 0x18, 0x0310); |
2475 | msleep(100); | 2483 | msleep(100); |
2476 | 2484 | ||
2477 | if (rtl_apply_firmware(tp, FIRMWARE_8105E_1) < 0) | 2485 | rtl_apply_firmware(tp); |
2478 | netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); | ||
2479 | 2486 | ||
2480 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | 2487 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); |
2481 | } | 2488 | } |
@@ -3237,6 +3244,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3237 | tp->timer.data = (unsigned long) dev; | 3244 | tp->timer.data = (unsigned long) dev; |
3238 | tp->timer.function = rtl8169_phy_timer; | 3245 | tp->timer.function = rtl8169_phy_timer; |
3239 | 3246 | ||
3247 | tp->fw = RTL_FIRMWARE_UNKNOWN; | ||
3248 | |||
3240 | rc = register_netdev(dev); | 3249 | rc = register_netdev(dev); |
3241 | if (rc < 0) | 3250 | if (rc < 0) |
3242 | goto err_out_msi_4; | 3251 | goto err_out_msi_4; |
@@ -3288,10 +3297,10 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3288 | 3297 | ||
3289 | cancel_delayed_work_sync(&tp->task); | 3298 | cancel_delayed_work_sync(&tp->task); |
3290 | 3299 | ||
3291 | rtl_release_firmware(tp); | ||
3292 | |||
3293 | unregister_netdev(dev); | 3300 | unregister_netdev(dev); |
3294 | 3301 | ||
3302 | rtl_release_firmware(tp); | ||
3303 | |||
3295 | if (pci_dev_run_wake(pdev)) | 3304 | if (pci_dev_run_wake(pdev)) |
3296 | pm_runtime_get_noresume(&pdev->dev); | 3305 | pm_runtime_get_noresume(&pdev->dev); |
3297 | 3306 | ||
@@ -3303,6 +3312,37 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3303 | pci_set_drvdata(pdev, NULL); | 3312 | pci_set_drvdata(pdev, NULL); |
3304 | } | 3313 | } |
3305 | 3314 | ||
3315 | static void rtl_request_firmware(struct rtl8169_private *tp) | ||
3316 | { | ||
3317 | int i; | ||
3318 | |||
3319 | /* Return early if the firmware is already loaded / cached. */ | ||
3320 | if (!IS_ERR(tp->fw)) | ||
3321 | goto out; | ||
3322 | |||
3323 | for (i = 0; i < ARRAY_SIZE(rtl_firmware_infos); i++) { | ||
3324 | const struct rtl_firmware_info *info = rtl_firmware_infos + i; | ||
3325 | |||
3326 | if (info->mac_version == tp->mac_version) { | ||
3327 | const char *name = info->fw_name; | ||
3328 | int rc; | ||
3329 | |||
3330 | rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev); | ||
3331 | if (rc < 0) { | ||
3332 | netif_warn(tp, ifup, tp->dev, "unable to load " | ||
3333 | "firmware patch %s (%d)\n", name, rc); | ||
3334 | goto out_disable_request_firmware; | ||
3335 | } | ||
3336 | goto out; | ||
3337 | } | ||
3338 | } | ||
3339 | |||
3340 | out_disable_request_firmware: | ||
3341 | tp->fw = NULL; | ||
3342 | out: | ||
3343 | return; | ||
3344 | } | ||
3345 | |||
3306 | static int rtl8169_open(struct net_device *dev) | 3346 | static int rtl8169_open(struct net_device *dev) |
3307 | { | 3347 | { |
3308 | struct rtl8169_private *tp = netdev_priv(dev); | 3348 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -3334,11 +3374,13 @@ static int rtl8169_open(struct net_device *dev) | |||
3334 | 3374 | ||
3335 | smp_mb(); | 3375 | smp_mb(); |
3336 | 3376 | ||
3377 | rtl_request_firmware(tp); | ||
3378 | |||
3337 | retval = request_irq(dev->irq, rtl8169_interrupt, | 3379 | retval = request_irq(dev->irq, rtl8169_interrupt, |
3338 | (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, | 3380 | (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, |
3339 | dev->name, dev); | 3381 | dev->name, dev); |
3340 | if (retval < 0) | 3382 | if (retval < 0) |
3341 | goto err_release_ring_2; | 3383 | goto err_release_fw_2; |
3342 | 3384 | ||
3343 | napi_enable(&tp->napi); | 3385 | napi_enable(&tp->napi); |
3344 | 3386 | ||
@@ -3359,7 +3401,8 @@ static int rtl8169_open(struct net_device *dev) | |||
3359 | out: | 3401 | out: |
3360 | return retval; | 3402 | return retval; |
3361 | 3403 | ||
3362 | err_release_ring_2: | 3404 | err_release_fw_2: |
3405 | rtl_release_firmware(tp); | ||
3363 | rtl8169_rx_clear(tp); | 3406 | rtl8169_rx_clear(tp); |
3364 | err_free_rx_1: | 3407 | err_free_rx_1: |
3365 | dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, | 3408 | dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, |
diff --git a/drivers/net/sfc/mcdi.c b/drivers/net/sfc/mcdi.c index d98479030ef..3dd45ed61f0 100644 --- a/drivers/net/sfc/mcdi.c +++ b/drivers/net/sfc/mcdi.c | |||
@@ -50,6 +50,20 @@ static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx) | |||
50 | return &nic_data->mcdi; | 50 | return &nic_data->mcdi; |
51 | } | 51 | } |
52 | 52 | ||
53 | static inline void | ||
54 | efx_mcdi_readd(struct efx_nic *efx, efx_dword_t *value, unsigned reg) | ||
55 | { | ||
56 | struct siena_nic_data *nic_data = efx->nic_data; | ||
57 | value->u32[0] = (__force __le32)__raw_readl(nic_data->mcdi_smem + reg); | ||
58 | } | ||
59 | |||
60 | static inline void | ||
61 | efx_mcdi_writed(struct efx_nic *efx, const efx_dword_t *value, unsigned reg) | ||
62 | { | ||
63 | struct siena_nic_data *nic_data = efx->nic_data; | ||
64 | __raw_writel((__force u32)value->u32[0], nic_data->mcdi_smem + reg); | ||
65 | } | ||
66 | |||
53 | void efx_mcdi_init(struct efx_nic *efx) | 67 | void efx_mcdi_init(struct efx_nic *efx) |
54 | { | 68 | { |
55 | struct efx_mcdi_iface *mcdi; | 69 | struct efx_mcdi_iface *mcdi; |
@@ -70,8 +84,8 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd, | |||
70 | const u8 *inbuf, size_t inlen) | 84 | const u8 *inbuf, size_t inlen) |
71 | { | 85 | { |
72 | struct efx_mcdi_iface *mcdi = efx_mcdi(efx); | 86 | struct efx_mcdi_iface *mcdi = efx_mcdi(efx); |
73 | unsigned pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx); | 87 | unsigned pdu = MCDI_PDU(efx); |
74 | unsigned doorbell = FR_CZ_MC_TREG_SMEM + MCDI_DOORBELL(efx); | 88 | unsigned doorbell = MCDI_DOORBELL(efx); |
75 | unsigned int i; | 89 | unsigned int i; |
76 | efx_dword_t hdr; | 90 | efx_dword_t hdr; |
77 | u32 xflags, seqno; | 91 | u32 xflags, seqno; |
@@ -92,30 +106,28 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd, | |||
92 | MCDI_HEADER_SEQ, seqno, | 106 | MCDI_HEADER_SEQ, seqno, |
93 | MCDI_HEADER_XFLAGS, xflags); | 107 | MCDI_HEADER_XFLAGS, xflags); |
94 | 108 | ||
95 | efx_writed(efx, &hdr, pdu); | 109 | efx_mcdi_writed(efx, &hdr, pdu); |
96 | 110 | ||
97 | for (i = 0; i < inlen; i += 4) { | 111 | for (i = 0; i < inlen; i += 4) |
98 | _efx_writed(efx, *((__le32 *)(inbuf + i)), pdu + 4 + i); | 112 | efx_mcdi_writed(efx, (const efx_dword_t *)(inbuf + i), |
99 | /* use wmb() within loop to inhibit write combining */ | 113 | pdu + 4 + i); |
100 | wmb(); | ||
101 | } | ||
102 | 114 | ||
103 | /* ring the doorbell with a distinctive value */ | 115 | /* ring the doorbell with a distinctive value */ |
104 | _efx_writed(efx, (__force __le32) 0x45789abc, doorbell); | 116 | EFX_POPULATE_DWORD_1(hdr, EFX_DWORD_0, 0x45789abc); |
105 | wmb(); | 117 | efx_mcdi_writed(efx, &hdr, doorbell); |
106 | } | 118 | } |
107 | 119 | ||
108 | static void efx_mcdi_copyout(struct efx_nic *efx, u8 *outbuf, size_t outlen) | 120 | static void efx_mcdi_copyout(struct efx_nic *efx, u8 *outbuf, size_t outlen) |
109 | { | 121 | { |
110 | struct efx_mcdi_iface *mcdi = efx_mcdi(efx); | 122 | struct efx_mcdi_iface *mcdi = efx_mcdi(efx); |
111 | unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx); | 123 | unsigned int pdu = MCDI_PDU(efx); |
112 | int i; | 124 | int i; |
113 | 125 | ||
114 | BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT); | 126 | BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT); |
115 | BUG_ON(outlen & 3 || outlen >= 0x100); | 127 | BUG_ON(outlen & 3 || outlen >= 0x100); |
116 | 128 | ||
117 | for (i = 0; i < outlen; i += 4) | 129 | for (i = 0; i < outlen; i += 4) |
118 | *((__le32 *)(outbuf + i)) = _efx_readd(efx, pdu + 4 + i); | 130 | efx_mcdi_readd(efx, (efx_dword_t *)(outbuf + i), pdu + 4 + i); |
119 | } | 131 | } |
120 | 132 | ||
121 | static int efx_mcdi_poll(struct efx_nic *efx) | 133 | static int efx_mcdi_poll(struct efx_nic *efx) |
@@ -123,7 +135,7 @@ static int efx_mcdi_poll(struct efx_nic *efx) | |||
123 | struct efx_mcdi_iface *mcdi = efx_mcdi(efx); | 135 | struct efx_mcdi_iface *mcdi = efx_mcdi(efx); |
124 | unsigned int time, finish; | 136 | unsigned int time, finish; |
125 | unsigned int respseq, respcmd, error; | 137 | unsigned int respseq, respcmd, error; |
126 | unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx); | 138 | unsigned int pdu = MCDI_PDU(efx); |
127 | unsigned int rc, spins; | 139 | unsigned int rc, spins; |
128 | efx_dword_t reg; | 140 | efx_dword_t reg; |
129 | 141 | ||
@@ -149,8 +161,7 @@ static int efx_mcdi_poll(struct efx_nic *efx) | |||
149 | 161 | ||
150 | time = get_seconds(); | 162 | time = get_seconds(); |
151 | 163 | ||
152 | rmb(); | 164 | efx_mcdi_readd(efx, ®, pdu); |
153 | efx_readd(efx, ®, pdu); | ||
154 | 165 | ||
155 | /* All 1's indicates that shared memory is in reset (and is | 166 | /* All 1's indicates that shared memory is in reset (and is |
156 | * not a valid header). Wait for it to come out reset before | 167 | * not a valid header). Wait for it to come out reset before |
@@ -177,7 +188,7 @@ static int efx_mcdi_poll(struct efx_nic *efx) | |||
177 | respseq, mcdi->seqno); | 188 | respseq, mcdi->seqno); |
178 | rc = EIO; | 189 | rc = EIO; |
179 | } else if (error) { | 190 | } else if (error) { |
180 | efx_readd(efx, ®, pdu + 4); | 191 | efx_mcdi_readd(efx, ®, pdu + 4); |
181 | switch (EFX_DWORD_FIELD(reg, EFX_DWORD_0)) { | 192 | switch (EFX_DWORD_FIELD(reg, EFX_DWORD_0)) { |
182 | #define TRANSLATE_ERROR(name) \ | 193 | #define TRANSLATE_ERROR(name) \ |
183 | case MC_CMD_ERR_ ## name: \ | 194 | case MC_CMD_ERR_ ## name: \ |
@@ -211,21 +222,21 @@ out: | |||
211 | /* Test and clear MC-rebooted flag for this port/function */ | 222 | /* Test and clear MC-rebooted flag for this port/function */ |
212 | int efx_mcdi_poll_reboot(struct efx_nic *efx) | 223 | int efx_mcdi_poll_reboot(struct efx_nic *efx) |
213 | { | 224 | { |
214 | unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_REBOOT_FLAG(efx); | 225 | unsigned int addr = MCDI_REBOOT_FLAG(efx); |
215 | efx_dword_t reg; | 226 | efx_dword_t reg; |
216 | uint32_t value; | 227 | uint32_t value; |
217 | 228 | ||
218 | if (efx_nic_rev(efx) < EFX_REV_SIENA_A0) | 229 | if (efx_nic_rev(efx) < EFX_REV_SIENA_A0) |
219 | return false; | 230 | return false; |
220 | 231 | ||
221 | efx_readd(efx, ®, addr); | 232 | efx_mcdi_readd(efx, ®, addr); |
222 | value = EFX_DWORD_FIELD(reg, EFX_DWORD_0); | 233 | value = EFX_DWORD_FIELD(reg, EFX_DWORD_0); |
223 | 234 | ||
224 | if (value == 0) | 235 | if (value == 0) |
225 | return 0; | 236 | return 0; |
226 | 237 | ||
227 | EFX_ZERO_DWORD(reg); | 238 | EFX_ZERO_DWORD(reg); |
228 | efx_writed(efx, ®, addr); | 239 | efx_mcdi_writed(efx, ®, addr); |
229 | 240 | ||
230 | if (value == MC_STATUS_DWORD_ASSERT) | 241 | if (value == MC_STATUS_DWORD_ASSERT) |
231 | return -EINTR; | 242 | return -EINTR; |
diff --git a/drivers/net/sfc/nic.c b/drivers/net/sfc/nic.c index 10f1cb79c14..9b29a8d7c44 100644 --- a/drivers/net/sfc/nic.c +++ b/drivers/net/sfc/nic.c | |||
@@ -1937,6 +1937,13 @@ void efx_nic_get_regs(struct efx_nic *efx, void *buf) | |||
1937 | 1937 | ||
1938 | size = min_t(size_t, table->step, 16); | 1938 | size = min_t(size_t, table->step, 16); |
1939 | 1939 | ||
1940 | if (table->offset >= efx->type->mem_map_size) { | ||
1941 | /* No longer mapped; return dummy data */ | ||
1942 | memcpy(buf, "\xde\xc0\xad\xde", 4); | ||
1943 | buf += table->rows * size; | ||
1944 | continue; | ||
1945 | } | ||
1946 | |||
1940 | for (i = 0; i < table->rows; i++) { | 1947 | for (i = 0; i < table->rows; i++) { |
1941 | switch (table->step) { | 1948 | switch (table->step) { |
1942 | case 4: /* 32-bit register or SRAM */ | 1949 | case 4: /* 32-bit register or SRAM */ |
diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h index a42db6e35be..d91701abd33 100644 --- a/drivers/net/sfc/nic.h +++ b/drivers/net/sfc/nic.h | |||
@@ -143,10 +143,12 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx) | |||
143 | /** | 143 | /** |
144 | * struct siena_nic_data - Siena NIC state | 144 | * struct siena_nic_data - Siena NIC state |
145 | * @mcdi: Management-Controller-to-Driver Interface | 145 | * @mcdi: Management-Controller-to-Driver Interface |
146 | * @mcdi_smem: MCDI shared memory mapping. The mapping is always uncacheable. | ||
146 | * @wol_filter_id: Wake-on-LAN packet filter id | 147 | * @wol_filter_id: Wake-on-LAN packet filter id |
147 | */ | 148 | */ |
148 | struct siena_nic_data { | 149 | struct siena_nic_data { |
149 | struct efx_mcdi_iface mcdi; | 150 | struct efx_mcdi_iface mcdi; |
151 | void __iomem *mcdi_smem; | ||
150 | int wol_filter_id; | 152 | int wol_filter_id; |
151 | }; | 153 | }; |
152 | 154 | ||
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c index e4dd8986b1f..837869b71db 100644 --- a/drivers/net/sfc/siena.c +++ b/drivers/net/sfc/siena.c | |||
@@ -220,12 +220,26 @@ static int siena_probe_nic(struct efx_nic *efx) | |||
220 | efx_reado(efx, ®, FR_AZ_CS_DEBUG); | 220 | efx_reado(efx, ®, FR_AZ_CS_DEBUG); |
221 | efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1; | 221 | efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1; |
222 | 222 | ||
223 | /* Initialise MCDI */ | ||
224 | nic_data->mcdi_smem = ioremap_nocache(efx->membase_phys + | ||
225 | FR_CZ_MC_TREG_SMEM, | ||
226 | FR_CZ_MC_TREG_SMEM_STEP * | ||
227 | FR_CZ_MC_TREG_SMEM_ROWS); | ||
228 | if (!nic_data->mcdi_smem) { | ||
229 | netif_err(efx, probe, efx->net_dev, | ||
230 | "could not map MCDI at %llx+%x\n", | ||
231 | (unsigned long long)efx->membase_phys + | ||
232 | FR_CZ_MC_TREG_SMEM, | ||
233 | FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS); | ||
234 | rc = -ENOMEM; | ||
235 | goto fail1; | ||
236 | } | ||
223 | efx_mcdi_init(efx); | 237 | efx_mcdi_init(efx); |
224 | 238 | ||
225 | /* Recover from a failed assertion before probing */ | 239 | /* Recover from a failed assertion before probing */ |
226 | rc = efx_mcdi_handle_assertion(efx); | 240 | rc = efx_mcdi_handle_assertion(efx); |
227 | if (rc) | 241 | if (rc) |
228 | goto fail1; | 242 | goto fail2; |
229 | 243 | ||
230 | /* Let the BMC know that the driver is now in charge of link and | 244 | /* Let the BMC know that the driver is now in charge of link and |
231 | * filter settings. We must do this before we reset the NIC */ | 245 | * filter settings. We must do this before we reset the NIC */ |
@@ -280,6 +294,7 @@ fail4: | |||
280 | fail3: | 294 | fail3: |
281 | efx_mcdi_drv_attach(efx, false, NULL); | 295 | efx_mcdi_drv_attach(efx, false, NULL); |
282 | fail2: | 296 | fail2: |
297 | iounmap(nic_data->mcdi_smem); | ||
283 | fail1: | 298 | fail1: |
284 | kfree(efx->nic_data); | 299 | kfree(efx->nic_data); |
285 | return rc; | 300 | return rc; |
@@ -359,6 +374,8 @@ static int siena_init_nic(struct efx_nic *efx) | |||
359 | 374 | ||
360 | static void siena_remove_nic(struct efx_nic *efx) | 375 | static void siena_remove_nic(struct efx_nic *efx) |
361 | { | 376 | { |
377 | struct siena_nic_data *nic_data = efx->nic_data; | ||
378 | |||
362 | efx_nic_free_buffer(efx, &efx->irq_status); | 379 | efx_nic_free_buffer(efx, &efx->irq_status); |
363 | 380 | ||
364 | siena_reset_hw(efx, RESET_TYPE_ALL); | 381 | siena_reset_hw(efx, RESET_TYPE_ALL); |
@@ -368,7 +385,8 @@ static void siena_remove_nic(struct efx_nic *efx) | |||
368 | efx_mcdi_drv_attach(efx, false, NULL); | 385 | efx_mcdi_drv_attach(efx, false, NULL); |
369 | 386 | ||
370 | /* Tear down the private nic state */ | 387 | /* Tear down the private nic state */ |
371 | kfree(efx->nic_data); | 388 | iounmap(nic_data->mcdi_smem); |
389 | kfree(nic_data); | ||
372 | efx->nic_data = NULL; | 390 | efx->nic_data = NULL; |
373 | } | 391 | } |
374 | 392 | ||
@@ -606,8 +624,7 @@ struct efx_nic_type siena_a0_nic_type = { | |||
606 | .default_mac_ops = &efx_mcdi_mac_operations, | 624 | .default_mac_ops = &efx_mcdi_mac_operations, |
607 | 625 | ||
608 | .revision = EFX_REV_SIENA_A0, | 626 | .revision = EFX_REV_SIENA_A0, |
609 | .mem_map_size = (FR_CZ_MC_TREG_SMEM + | 627 | .mem_map_size = FR_CZ_MC_TREG_SMEM, /* MC_TREG_SMEM mapped separately */ |
610 | FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS), | ||
611 | .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, | 628 | .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, |
612 | .rxd_ptr_tbl_base = FR_BZ_RX_DESC_PTR_TBL, | 629 | .rxd_ptr_tbl_base = FR_BZ_RX_DESC_PTR_TBL, |
613 | .buf_tbl_base = FR_BZ_BUF_FULL_TBL, | 630 | .buf_tbl_base = FR_BZ_BUF_FULL_TBL, |
diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 86cbb9ea2f2..8ec1a9a0bb9 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c | |||
@@ -853,7 +853,9 @@ static int slip_open(struct tty_struct *tty) | |||
853 | /* Done. We have linked the TTY line to a channel. */ | 853 | /* Done. We have linked the TTY line to a channel. */ |
854 | rtnl_unlock(); | 854 | rtnl_unlock(); |
855 | tty->receive_room = 65536; /* We don't flow control */ | 855 | tty->receive_room = 65536; /* We don't flow control */ |
856 | return sl->dev->base_addr; | 856 | |
857 | /* TTY layer expects 0 on success */ | ||
858 | return 0; | ||
857 | 859 | ||
858 | err_free_bufs: | 860 | err_free_bufs: |
859 | sl_free_bufs(sl); | 861 | sl_free_bufs(sl); |
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index eb4f59fb01e..bff2f7999ff 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
@@ -3237,15 +3237,18 @@ static void happy_meal_pci_exit(void) | |||
3237 | #endif | 3237 | #endif |
3238 | 3238 | ||
3239 | #ifdef CONFIG_SBUS | 3239 | #ifdef CONFIG_SBUS |
3240 | static const struct of_device_id hme_sbus_match[]; | ||
3240 | static int __devinit hme_sbus_probe(struct platform_device *op) | 3241 | static int __devinit hme_sbus_probe(struct platform_device *op) |
3241 | { | 3242 | { |
3243 | const struct of_device_id *match; | ||
3242 | struct device_node *dp = op->dev.of_node; | 3244 | struct device_node *dp = op->dev.of_node; |
3243 | const char *model = of_get_property(dp, "model", NULL); | 3245 | const char *model = of_get_property(dp, "model", NULL); |
3244 | int is_qfe; | 3246 | int is_qfe; |
3245 | 3247 | ||
3246 | if (!op->dev.of_match) | 3248 | match = of_match_device(hme_sbus_match, &op->dev); |
3249 | if (!match) | ||
3247 | return -EINVAL; | 3250 | return -EINVAL; |
3248 | is_qfe = (op->dev.of_match->data != NULL); | 3251 | is_qfe = (match->data != NULL); |
3249 | 3252 | ||
3250 | if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) | 3253 | if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) |
3251 | is_qfe = 1; | 3254 | is_qfe = 1; |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index b8c5f35577e..7a5daefb6f3 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -12327,8 +12327,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
12327 | if (val & VCPU_CFGSHDW_ASPM_DBNC) | 12327 | if (val & VCPU_CFGSHDW_ASPM_DBNC) |
12328 | tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND; | 12328 | tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND; |
12329 | if ((val & VCPU_CFGSHDW_WOL_ENABLE) && | 12329 | if ((val & VCPU_CFGSHDW_WOL_ENABLE) && |
12330 | (val & VCPU_CFGSHDW_WOL_MAGPKT)) | 12330 | (val & VCPU_CFGSHDW_WOL_MAGPKT)) { |
12331 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; | 12331 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; |
12332 | device_set_wakeup_enable(&tp->pdev->dev, true); | ||
12333 | } | ||
12332 | goto done; | 12334 | goto done; |
12333 | } | 12335 | } |
12334 | 12336 | ||
@@ -12461,8 +12463,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
12461 | tp->tg3_flags &= ~TG3_FLAG_WOL_CAP; | 12463 | tp->tg3_flags &= ~TG3_FLAG_WOL_CAP; |
12462 | 12464 | ||
12463 | if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) && | 12465 | if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) && |
12464 | (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE)) | 12466 | (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE)) { |
12465 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; | 12467 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; |
12468 | device_set_wakeup_enable(&tp->pdev->dev, true); | ||
12469 | } | ||
12466 | 12470 | ||
12467 | if (cfg2 & (1 << 17)) | 12471 | if (cfg2 & (1 << 17)) |
12468 | tp->phy_flags |= TG3_PHYFLG_CAPACITIVE_COUPLING; | 12472 | tp->phy_flags |= TG3_PHYFLG_CAPACITIVE_COUPLING; |
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 341f7056a80..c924ea2bce0 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
@@ -460,7 +460,7 @@ static const struct driver_info cdc_info = { | |||
460 | .manage_power = cdc_manage_power, | 460 | .manage_power = cdc_manage_power, |
461 | }; | 461 | }; |
462 | 462 | ||
463 | static const struct driver_info mbm_info = { | 463 | static const struct driver_info wwan_info = { |
464 | .description = "Mobile Broadband Network Device", | 464 | .description = "Mobile Broadband Network Device", |
465 | .flags = FLAG_WWAN, | 465 | .flags = FLAG_WWAN, |
466 | .bind = usbnet_cdc_bind, | 466 | .bind = usbnet_cdc_bind, |
@@ -471,6 +471,7 @@ static const struct driver_info mbm_info = { | |||
471 | 471 | ||
472 | /*-------------------------------------------------------------------------*/ | 472 | /*-------------------------------------------------------------------------*/ |
473 | 473 | ||
474 | #define HUAWEI_VENDOR_ID 0x12D1 | ||
474 | 475 | ||
475 | static const struct usb_device_id products [] = { | 476 | static const struct usb_device_id products [] = { |
476 | /* | 477 | /* |
@@ -566,7 +567,7 @@ static const struct usb_device_id products [] = { | |||
566 | { | 567 | { |
567 | USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM, | 568 | USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM, |
568 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | 569 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
569 | .driver_info = 0, | 570 | .driver_info = (unsigned long)&wwan_info, |
570 | }, | 571 | }, |
571 | 572 | ||
572 | /* | 573 | /* |
@@ -587,8 +588,17 @@ static const struct usb_device_id products [] = { | |||
587 | }, { | 588 | }, { |
588 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, | 589 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, |
589 | USB_CDC_PROTO_NONE), | 590 | USB_CDC_PROTO_NONE), |
590 | .driver_info = (unsigned long)&mbm_info, | 591 | .driver_info = (unsigned long)&wwan_info, |
591 | 592 | ||
593 | }, { | ||
594 | /* Various Huawei modems with a network port like the UMG1831 */ | ||
595 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | ||
596 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
597 | .idVendor = HUAWEI_VENDOR_ID, | ||
598 | .bInterfaceClass = USB_CLASS_COMM, | ||
599 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | ||
600 | .bInterfaceProtocol = 255, | ||
601 | .driver_info = (unsigned long)&wwan_info, | ||
592 | }, | 602 | }, |
593 | { }, // END | 603 | { }, // END |
594 | }; | 604 | }; |
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 967371f0445..1033ef6476a 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c | |||
@@ -54,13 +54,13 @@ | |||
54 | #include <linux/usb/usbnet.h> | 54 | #include <linux/usb/usbnet.h> |
55 | #include <linux/usb/cdc.h> | 55 | #include <linux/usb/cdc.h> |
56 | 56 | ||
57 | #define DRIVER_VERSION "7-Feb-2011" | 57 | #define DRIVER_VERSION "23-Apr-2011" |
58 | 58 | ||
59 | /* CDC NCM subclass 3.2.1 */ | 59 | /* CDC NCM subclass 3.2.1 */ |
60 | #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 | 60 | #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 |
61 | 61 | ||
62 | /* Maximum NTB length */ | 62 | /* Maximum NTB length */ |
63 | #define CDC_NCM_NTB_MAX_SIZE_TX 16384 /* bytes */ | 63 | #define CDC_NCM_NTB_MAX_SIZE_TX (16384 + 4) /* bytes, must be short terminated */ |
64 | #define CDC_NCM_NTB_MAX_SIZE_RX 16384 /* bytes */ | 64 | #define CDC_NCM_NTB_MAX_SIZE_RX 16384 /* bytes */ |
65 | 65 | ||
66 | /* Minimum value for MaxDatagramSize, ch. 6.2.9 */ | 66 | /* Minimum value for MaxDatagramSize, ch. 6.2.9 */ |
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index 7d42f9a2c06..81126ff85e0 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c | |||
@@ -65,6 +65,7 @@ | |||
65 | #define IPHETH_USBINTF_PROTO 1 | 65 | #define IPHETH_USBINTF_PROTO 1 |
66 | 66 | ||
67 | #define IPHETH_BUF_SIZE 1516 | 67 | #define IPHETH_BUF_SIZE 1516 |
68 | #define IPHETH_IP_ALIGN 2 /* padding at front of URB */ | ||
68 | #define IPHETH_TX_TIMEOUT (5 * HZ) | 69 | #define IPHETH_TX_TIMEOUT (5 * HZ) |
69 | 70 | ||
70 | #define IPHETH_INTFNUM 2 | 71 | #define IPHETH_INTFNUM 2 |
@@ -202,18 +203,21 @@ static void ipheth_rcvbulk_callback(struct urb *urb) | |||
202 | return; | 203 | return; |
203 | } | 204 | } |
204 | 205 | ||
205 | len = urb->actual_length; | 206 | if (urb->actual_length <= IPHETH_IP_ALIGN) { |
206 | buf = urb->transfer_buffer; | 207 | dev->net->stats.rx_length_errors++; |
208 | return; | ||
209 | } | ||
210 | len = urb->actual_length - IPHETH_IP_ALIGN; | ||
211 | buf = urb->transfer_buffer + IPHETH_IP_ALIGN; | ||
207 | 212 | ||
208 | skb = dev_alloc_skb(NET_IP_ALIGN + len); | 213 | skb = dev_alloc_skb(len); |
209 | if (!skb) { | 214 | if (!skb) { |
210 | err("%s: dev_alloc_skb: -ENOMEM", __func__); | 215 | err("%s: dev_alloc_skb: -ENOMEM", __func__); |
211 | dev->net->stats.rx_dropped++; | 216 | dev->net->stats.rx_dropped++; |
212 | return; | 217 | return; |
213 | } | 218 | } |
214 | 219 | ||
215 | skb_reserve(skb, NET_IP_ALIGN); | 220 | memcpy(skb_put(skb, len), buf, len); |
216 | memcpy(skb_put(skb, len), buf + NET_IP_ALIGN, len - NET_IP_ALIGN); | ||
217 | skb->dev = dev->net; | 221 | skb->dev = dev->net; |
218 | skb->protocol = eth_type_trans(skb, dev->net); | 222 | skb->protocol = eth_type_trans(skb, dev->net); |
219 | 223 | ||
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 47a6c870b51..48d4efdb495 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
@@ -730,7 +730,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) | |||
730 | msleep(10); | 730 | msleep(10); |
731 | bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); | 731 | bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); |
732 | timeout++; | 732 | timeout++; |
733 | } while ((bmcr & MII_BMCR) && (timeout < 100)); | 733 | } while ((bmcr & BMCR_RESET) && (timeout < 100)); |
734 | 734 | ||
735 | if (timeout >= 100) { | 735 | if (timeout >= 100) { |
736 | netdev_warn(dev->net, "timeout on PHY Reset"); | 736 | netdev_warn(dev->net, "timeout on PHY Reset"); |
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 069c1cf0fdf..9ab439d144e 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
@@ -645,6 +645,7 @@ int usbnet_stop (struct net_device *net) | |||
645 | struct driver_info *info = dev->driver_info; | 645 | struct driver_info *info = dev->driver_info; |
646 | int retval; | 646 | int retval; |
647 | 647 | ||
648 | clear_bit(EVENT_DEV_OPEN, &dev->flags); | ||
648 | netif_stop_queue (net); | 649 | netif_stop_queue (net); |
649 | 650 | ||
650 | netif_info(dev, ifdown, dev->net, | 651 | netif_info(dev, ifdown, dev->net, |
@@ -736,6 +737,7 @@ int usbnet_open (struct net_device *net) | |||
736 | } | 737 | } |
737 | } | 738 | } |
738 | 739 | ||
740 | set_bit(EVENT_DEV_OPEN, &dev->flags); | ||
739 | netif_start_queue (net); | 741 | netif_start_queue (net); |
740 | netif_info(dev, ifup, dev->net, | 742 | netif_info(dev, ifup, dev->net, |
741 | "open: enable queueing (rx %d, tx %d) mtu %d %s framing\n", | 743 | "open: enable queueing (rx %d, tx %d) mtu %d %s framing\n", |
@@ -1259,6 +1261,9 @@ void usbnet_disconnect (struct usb_interface *intf) | |||
1259 | if (dev->driver_info->unbind) | 1261 | if (dev->driver_info->unbind) |
1260 | dev->driver_info->unbind (dev, intf); | 1262 | dev->driver_info->unbind (dev, intf); |
1261 | 1263 | ||
1264 | usb_kill_urb(dev->interrupt); | ||
1265 | usb_free_urb(dev->interrupt); | ||
1266 | |||
1262 | free_netdev(net); | 1267 | free_netdev(net); |
1263 | usb_put_dev (xdev); | 1268 | usb_put_dev (xdev); |
1264 | } | 1269 | } |
@@ -1498,6 +1503,10 @@ int usbnet_resume (struct usb_interface *intf) | |||
1498 | int retval; | 1503 | int retval; |
1499 | 1504 | ||
1500 | if (!--dev->suspend_count) { | 1505 | if (!--dev->suspend_count) { |
1506 | /* resume interrupt URBs */ | ||
1507 | if (dev->interrupt && test_bit(EVENT_DEV_OPEN, &dev->flags)) | ||
1508 | usb_submit_urb(dev->interrupt, GFP_NOIO); | ||
1509 | |||
1501 | spin_lock_irq(&dev->txq.lock); | 1510 | spin_lock_irq(&dev->txq.lock); |
1502 | while ((res = usb_get_from_anchor(&dev->deferred))) { | 1511 | while ((res = usb_get_from_anchor(&dev->deferred))) { |
1503 | 1512 | ||
@@ -1516,9 +1525,12 @@ int usbnet_resume (struct usb_interface *intf) | |||
1516 | smp_mb(); | 1525 | smp_mb(); |
1517 | clear_bit(EVENT_DEV_ASLEEP, &dev->flags); | 1526 | clear_bit(EVENT_DEV_ASLEEP, &dev->flags); |
1518 | spin_unlock_irq(&dev->txq.lock); | 1527 | spin_unlock_irq(&dev->txq.lock); |
1519 | if (!(dev->txq.qlen >= TX_QLEN(dev))) | 1528 | |
1520 | netif_start_queue(dev->net); | 1529 | if (test_bit(EVENT_DEV_OPEN, &dev->flags)) { |
1521 | tasklet_schedule (&dev->bh); | 1530 | if (!(dev->txq.qlen >= TX_QLEN(dev))) |
1531 | netif_start_queue(dev->net); | ||
1532 | tasklet_schedule (&dev->bh); | ||
1533 | } | ||
1522 | } | 1534 | } |
1523 | return 0; | 1535 | return 0; |
1524 | } | 1536 | } |
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 2de9b90c5f8..3b99f64104f 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c | |||
@@ -403,6 +403,17 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, | |||
403 | if (tb[IFLA_ADDRESS] == NULL) | 403 | if (tb[IFLA_ADDRESS] == NULL) |
404 | random_ether_addr(dev->dev_addr); | 404 | random_ether_addr(dev->dev_addr); |
405 | 405 | ||
406 | if (tb[IFLA_IFNAME]) | ||
407 | nla_strlcpy(dev->name, tb[IFLA_IFNAME], IFNAMSIZ); | ||
408 | else | ||
409 | snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d"); | ||
410 | |||
411 | if (strchr(dev->name, '%')) { | ||
412 | err = dev_alloc_name(dev, dev->name); | ||
413 | if (err < 0) | ||
414 | goto err_alloc_name; | ||
415 | } | ||
416 | |||
406 | err = register_netdevice(dev); | 417 | err = register_netdevice(dev); |
407 | if (err < 0) | 418 | if (err < 0) |
408 | goto err_register_dev; | 419 | goto err_register_dev; |
@@ -422,6 +433,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, | |||
422 | 433 | ||
423 | err_register_dev: | 434 | err_register_dev: |
424 | /* nothing to do */ | 435 | /* nothing to do */ |
436 | err_alloc_name: | ||
425 | err_configure_peer: | 437 | err_configure_peer: |
426 | unregister_netdevice(peer); | 438 | unregister_netdevice(peer); |
427 | return err; | 439 | return err; |
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index 0d47c3a0530..c16ed961153 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c | |||
@@ -178,6 +178,7 @@ static void | |||
178 | vmxnet3_process_events(struct vmxnet3_adapter *adapter) | 178 | vmxnet3_process_events(struct vmxnet3_adapter *adapter) |
179 | { | 179 | { |
180 | int i; | 180 | int i; |
181 | unsigned long flags; | ||
181 | u32 events = le32_to_cpu(adapter->shared->ecr); | 182 | u32 events = le32_to_cpu(adapter->shared->ecr); |
182 | if (!events) | 183 | if (!events) |
183 | return; | 184 | return; |
@@ -190,10 +191,10 @@ vmxnet3_process_events(struct vmxnet3_adapter *adapter) | |||
190 | 191 | ||
191 | /* Check if there is an error on xmit/recv queues */ | 192 | /* Check if there is an error on xmit/recv queues */ |
192 | if (events & (VMXNET3_ECR_TQERR | VMXNET3_ECR_RQERR)) { | 193 | if (events & (VMXNET3_ECR_TQERR | VMXNET3_ECR_RQERR)) { |
193 | spin_lock(&adapter->cmd_lock); | 194 | spin_lock_irqsave(&adapter->cmd_lock, flags); |
194 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | 195 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, |
195 | VMXNET3_CMD_GET_QUEUE_STATUS); | 196 | VMXNET3_CMD_GET_QUEUE_STATUS); |
196 | spin_unlock(&adapter->cmd_lock); | 197 | spin_unlock_irqrestore(&adapter->cmd_lock, flags); |
197 | 198 | ||
198 | for (i = 0; i < adapter->num_tx_queues; i++) | 199 | for (i = 0; i < adapter->num_tx_queues; i++) |
199 | if (adapter->tqd_start[i].status.stopped) | 200 | if (adapter->tqd_start[i].status.stopped) |
@@ -2733,13 +2734,14 @@ static void | |||
2733 | vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter) | 2734 | vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter) |
2734 | { | 2735 | { |
2735 | u32 cfg; | 2736 | u32 cfg; |
2737 | unsigned long flags; | ||
2736 | 2738 | ||
2737 | /* intr settings */ | 2739 | /* intr settings */ |
2738 | spin_lock(&adapter->cmd_lock); | 2740 | spin_lock_irqsave(&adapter->cmd_lock, flags); |
2739 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | 2741 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, |
2740 | VMXNET3_CMD_GET_CONF_INTR); | 2742 | VMXNET3_CMD_GET_CONF_INTR); |
2741 | cfg = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); | 2743 | cfg = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); |
2742 | spin_unlock(&adapter->cmd_lock); | 2744 | spin_unlock_irqrestore(&adapter->cmd_lock, flags); |
2743 | adapter->intr.type = cfg & 0x3; | 2745 | adapter->intr.type = cfg & 0x3; |
2744 | adapter->intr.mask_mode = (cfg >> 2) & 0x3; | 2746 | adapter->intr.mask_mode = (cfg >> 2) & 0x3; |
2745 | 2747 | ||
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c index 51f2ef142a5..976467253d2 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c | |||
@@ -311,6 +311,9 @@ vmxnet3_set_flags(struct net_device *netdev, u32 data) | |||
311 | /* toggle the LRO feature*/ | 311 | /* toggle the LRO feature*/ |
312 | netdev->features ^= NETIF_F_LRO; | 312 | netdev->features ^= NETIF_F_LRO; |
313 | 313 | ||
314 | /* Update private LRO flag */ | ||
315 | adapter->lro = lro_requested; | ||
316 | |||
314 | /* update harware LRO capability accordingly */ | 317 | /* update harware LRO capability accordingly */ |
315 | if (lro_requested) | 318 | if (lro_requested) |
316 | adapter->shared->devRead.misc.uptFeatures |= | 319 | adapter->shared->devRead.misc.uptFeatures |= |
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 17d04ff8d67..1482fa65083 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -2141,6 +2141,8 @@ static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class) | |||
2141 | static void ath9k_flush(struct ieee80211_hw *hw, bool drop) | 2141 | static void ath9k_flush(struct ieee80211_hw *hw, bool drop) |
2142 | { | 2142 | { |
2143 | struct ath_softc *sc = hw->priv; | 2143 | struct ath_softc *sc = hw->priv; |
2144 | struct ath_hw *ah = sc->sc_ah; | ||
2145 | struct ath_common *common = ath9k_hw_common(ah); | ||
2144 | int timeout = 200; /* ms */ | 2146 | int timeout = 200; /* ms */ |
2145 | int i, j; | 2147 | int i, j; |
2146 | 2148 | ||
@@ -2149,6 +2151,12 @@ static void ath9k_flush(struct ieee80211_hw *hw, bool drop) | |||
2149 | 2151 | ||
2150 | cancel_delayed_work_sync(&sc->tx_complete_work); | 2152 | cancel_delayed_work_sync(&sc->tx_complete_work); |
2151 | 2153 | ||
2154 | if (sc->sc_flags & SC_OP_INVALID) { | ||
2155 | ath_dbg(common, ATH_DBG_ANY, "Device not present\n"); | ||
2156 | mutex_unlock(&sc->mutex); | ||
2157 | return; | ||
2158 | } | ||
2159 | |||
2152 | if (drop) | 2160 | if (drop) |
2153 | timeout = 1; | 2161 | timeout = 1; |
2154 | 2162 | ||
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index dcd19bc337d..b29c80def35 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c | |||
@@ -506,7 +506,7 @@ bool ath_stoprecv(struct ath_softc *sc) | |||
506 | "confusing the DMA engine when we start RX up\n"); | 506 | "confusing the DMA engine when we start RX up\n"); |
507 | ATH_DBG_WARN_ON_ONCE(!stopped); | 507 | ATH_DBG_WARN_ON_ONCE(!stopped); |
508 | } | 508 | } |
509 | return stopped || reset; | 509 | return stopped && !reset; |
510 | } | 510 | } |
511 | 511 | ||
512 | void ath_flushrecv(struct ath_softc *sc) | 512 | void ath_flushrecv(struct ath_softc *sc) |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index d59b0168c14..5af40d9170a 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -72,6 +72,7 @@ MODULE_FIRMWARE("b43/ucode11.fw"); | |||
72 | MODULE_FIRMWARE("b43/ucode13.fw"); | 72 | MODULE_FIRMWARE("b43/ucode13.fw"); |
73 | MODULE_FIRMWARE("b43/ucode14.fw"); | 73 | MODULE_FIRMWARE("b43/ucode14.fw"); |
74 | MODULE_FIRMWARE("b43/ucode15.fw"); | 74 | MODULE_FIRMWARE("b43/ucode15.fw"); |
75 | MODULE_FIRMWARE("b43/ucode16_mimo.fw"); | ||
75 | MODULE_FIRMWARE("b43/ucode5.fw"); | 76 | MODULE_FIRMWARE("b43/ucode5.fw"); |
76 | MODULE_FIRMWARE("b43/ucode9.fw"); | 77 | MODULE_FIRMWARE("b43/ucode9.fw"); |
77 | 78 | ||
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 5c40502f869..79ac081832f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c | |||
@@ -316,12 +316,18 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | |||
316 | 316 | ||
317 | hdr_len = ieee80211_hdrlen(fc); | 317 | hdr_len = ieee80211_hdrlen(fc); |
318 | 318 | ||
319 | /* Find index into station table for destination station */ | 319 | /* For management frames use broadcast id to do not break aggregation */ |
320 | sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, info->control.sta); | 320 | if (!ieee80211_is_data(fc)) |
321 | if (sta_id == IWL_INVALID_STATION) { | 321 | sta_id = ctx->bcast_sta_id; |
322 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | 322 | else { |
323 | hdr->addr1); | 323 | /* Find index into station table for destination station */ |
324 | goto drop_unlock; | 324 | sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, info->control.sta); |
325 | |||
326 | if (sta_id == IWL_INVALID_STATION) { | ||
327 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | ||
328 | hdr->addr1); | ||
329 | goto drop_unlock; | ||
330 | } | ||
325 | } | 331 | } |
326 | 332 | ||
327 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); | 333 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); |
@@ -1127,12 +1133,16 @@ int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | |||
1127 | q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { | 1133 | q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { |
1128 | 1134 | ||
1129 | tx_info = &txq->txb[txq->q.read_ptr]; | 1135 | tx_info = &txq->txb[txq->q.read_ptr]; |
1130 | iwl4965_tx_status(priv, tx_info, | 1136 | |
1131 | txq_id >= IWL4965_FIRST_AMPDU_QUEUE); | 1137 | if (WARN_ON_ONCE(tx_info->skb == NULL)) |
1138 | continue; | ||
1132 | 1139 | ||
1133 | hdr = (struct ieee80211_hdr *)tx_info->skb->data; | 1140 | hdr = (struct ieee80211_hdr *)tx_info->skb->data; |
1134 | if (hdr && ieee80211_is_data_qos(hdr->frame_control)) | 1141 | if (ieee80211_is_data_qos(hdr->frame_control)) |
1135 | nfreed++; | 1142 | nfreed++; |
1143 | |||
1144 | iwl4965_tx_status(priv, tx_info, | ||
1145 | txq_id >= IWL4965_FIRST_AMPDU_QUEUE); | ||
1136 | tx_info->skb = NULL; | 1146 | tx_info->skb = NULL; |
1137 | 1147 | ||
1138 | priv->cfg->ops->lib->txq_free_tfd(priv, txq); | 1148 | priv->cfg->ops->lib->txq_free_tfd(priv, txq); |
diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index c1511b14b23..42db0fc8b92 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c | |||
@@ -2155,6 +2155,13 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) | |||
2155 | goto set_ch_out; | 2155 | goto set_ch_out; |
2156 | } | 2156 | } |
2157 | 2157 | ||
2158 | if (priv->iw_mode == NL80211_IFTYPE_ADHOC && | ||
2159 | !iwl_legacy_is_channel_ibss(ch_info)) { | ||
2160 | IWL_DEBUG_MAC80211(priv, "leave - not IBSS channel\n"); | ||
2161 | ret = -EINVAL; | ||
2162 | goto set_ch_out; | ||
2163 | } | ||
2164 | |||
2158 | spin_lock_irqsave(&priv->lock, flags); | 2165 | spin_lock_irqsave(&priv->lock, flags); |
2159 | 2166 | ||
2160 | for_each_context(priv, ctx) { | 2167 | for_each_context(priv, ctx) { |
diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 9ee849d669f..f43ac1eb901 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h | |||
@@ -1411,6 +1411,12 @@ iwl_legacy_is_channel_passive(const struct iwl_channel_info *ch) | |||
1411 | return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; | 1411 | return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; |
1412 | } | 1412 | } |
1413 | 1413 | ||
1414 | static inline int | ||
1415 | iwl_legacy_is_channel_ibss(const struct iwl_channel_info *ch) | ||
1416 | { | ||
1417 | return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; | ||
1418 | } | ||
1419 | |||
1414 | static inline void | 1420 | static inline void |
1415 | __iwl_legacy_free_pages(struct iwl_priv *priv, struct page *page) | 1421 | __iwl_legacy_free_pages(struct iwl_priv *priv, struct page *page) |
1416 | { | 1422 | { |
diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index 15eb8b70715..bda0d61b2c0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c | |||
@@ -48,8 +48,21 @@ module_param(led_mode, int, S_IRUGO); | |||
48 | MODULE_PARM_DESC(led_mode, "0=system default, " | 48 | MODULE_PARM_DESC(led_mode, "0=system default, " |
49 | "1=On(RF On)/Off(RF Off), 2=blinking"); | 49 | "1=On(RF On)/Off(RF Off), 2=blinking"); |
50 | 50 | ||
51 | /* Throughput OFF time(ms) ON time (ms) | ||
52 | * >300 25 25 | ||
53 | * >200 to 300 40 40 | ||
54 | * >100 to 200 55 55 | ||
55 | * >70 to 100 65 65 | ||
56 | * >50 to 70 75 75 | ||
57 | * >20 to 50 85 85 | ||
58 | * >10 to 20 95 95 | ||
59 | * >5 to 10 110 110 | ||
60 | * >1 to 5 130 130 | ||
61 | * >0 to 1 167 167 | ||
62 | * <=0 SOLID ON | ||
63 | */ | ||
51 | static const struct ieee80211_tpt_blink iwl_blink[] = { | 64 | static const struct ieee80211_tpt_blink iwl_blink[] = { |
52 | { .throughput = 0 * 1024 - 1, .blink_time = 334 }, | 65 | { .throughput = 0, .blink_time = 334 }, |
53 | { .throughput = 1 * 1024 - 1, .blink_time = 260 }, | 66 | { .throughput = 1 * 1024 - 1, .blink_time = 260 }, |
54 | { .throughput = 5 * 1024 - 1, .blink_time = 220 }, | 67 | { .throughput = 5 * 1024 - 1, .blink_time = 220 }, |
55 | { .throughput = 10 * 1024 - 1, .blink_time = 190 }, | 68 | { .throughput = 10 * 1024 - 1, .blink_time = 190 }, |
@@ -101,6 +114,11 @@ static int iwl_legacy_led_cmd(struct iwl_priv *priv, | |||
101 | if (priv->blink_on == on && priv->blink_off == off) | 114 | if (priv->blink_on == on && priv->blink_off == off) |
102 | return 0; | 115 | return 0; |
103 | 116 | ||
117 | if (off == 0) { | ||
118 | /* led is SOLID_ON */ | ||
119 | on = IWL_LED_SOLID; | ||
120 | } | ||
121 | |||
104 | IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n", | 122 | IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n", |
105 | priv->cfg->base_params->led_compensation); | 123 | priv->cfg->base_params->led_compensation); |
106 | led_cmd.on = iwl_legacy_blink_compensation(priv, on, | 124 | led_cmd.on = iwl_legacy_blink_compensation(priv, on, |
diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index d484c367816..a62fe24ee59 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c | |||
@@ -2984,15 +2984,15 @@ static void iwl4965_bg_txpower_work(struct work_struct *work) | |||
2984 | struct iwl_priv *priv = container_of(work, struct iwl_priv, | 2984 | struct iwl_priv *priv = container_of(work, struct iwl_priv, |
2985 | txpower_work); | 2985 | txpower_work); |
2986 | 2986 | ||
2987 | mutex_lock(&priv->mutex); | ||
2988 | |||
2987 | /* If a scan happened to start before we got here | 2989 | /* If a scan happened to start before we got here |
2988 | * then just return; the statistics notification will | 2990 | * then just return; the statistics notification will |
2989 | * kick off another scheduled work to compensate for | 2991 | * kick off another scheduled work to compensate for |
2990 | * any temperature delta we missed here. */ | 2992 | * any temperature delta we missed here. */ |
2991 | if (test_bit(STATUS_EXIT_PENDING, &priv->status) || | 2993 | if (test_bit(STATUS_EXIT_PENDING, &priv->status) || |
2992 | test_bit(STATUS_SCANNING, &priv->status)) | 2994 | test_bit(STATUS_SCANNING, &priv->status)) |
2993 | return; | 2995 | goto out; |
2994 | |||
2995 | mutex_lock(&priv->mutex); | ||
2996 | 2996 | ||
2997 | /* Regardless of if we are associated, we must reconfigure the | 2997 | /* Regardless of if we are associated, we must reconfigure the |
2998 | * TX power since frames can be sent on non-radar channels while | 2998 | * TX power since frames can be sent on non-radar channels while |
@@ -3002,7 +3002,7 @@ static void iwl4965_bg_txpower_work(struct work_struct *work) | |||
3002 | /* Update last_temperature to keep is_calib_needed from running | 3002 | /* Update last_temperature to keep is_calib_needed from running |
3003 | * when it isn't needed... */ | 3003 | * when it isn't needed... */ |
3004 | priv->last_temperature = priv->temperature; | 3004 | priv->last_temperature = priv->temperature; |
3005 | 3005 | out: | |
3006 | mutex_unlock(&priv->mutex); | 3006 | mutex_unlock(&priv->mutex); |
3007 | } | 3007 | } |
3008 | 3008 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index dfdbea6e8f9..fbbde0712fa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | |||
@@ -335,7 +335,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) | |||
335 | struct ieee80211_channel *channel = conf->channel; | 335 | struct ieee80211_channel *channel = conf->channel; |
336 | const struct iwl_channel_info *ch_info; | 336 | const struct iwl_channel_info *ch_info; |
337 | int ret = 0; | 337 | int ret = 0; |
338 | bool ht_changed[NUM_IWL_RXON_CTX] = {}; | ||
339 | 338 | ||
340 | IWL_DEBUG_MAC80211(priv, "changed %#x", changed); | 339 | IWL_DEBUG_MAC80211(priv, "changed %#x", changed); |
341 | 340 | ||
@@ -383,10 +382,8 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) | |||
383 | 382 | ||
384 | for_each_context(priv, ctx) { | 383 | for_each_context(priv, ctx) { |
385 | /* Configure HT40 channels */ | 384 | /* Configure HT40 channels */ |
386 | if (ctx->ht.enabled != conf_is_ht(conf)) { | 385 | if (ctx->ht.enabled != conf_is_ht(conf)) |
387 | ctx->ht.enabled = conf_is_ht(conf); | 386 | ctx->ht.enabled = conf_is_ht(conf); |
388 | ht_changed[ctx->ctxid] = true; | ||
389 | } | ||
390 | 387 | ||
391 | if (ctx->ht.enabled) { | 388 | if (ctx->ht.enabled) { |
392 | if (conf_is_ht40_minus(conf)) { | 389 | if (conf_is_ht40_minus(conf)) { |
@@ -455,8 +452,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) | |||
455 | if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) | 452 | if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) |
456 | continue; | 453 | continue; |
457 | iwlagn_commit_rxon(priv, ctx); | 454 | iwlagn_commit_rxon(priv, ctx); |
458 | if (ht_changed[ctx->ctxid]) | ||
459 | iwlagn_update_qos(priv, ctx); | ||
460 | } | 455 | } |
461 | out: | 456 | out: |
462 | mutex_unlock(&priv->mutex); | 457 | mutex_unlock(&priv->mutex); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index a709d05c586..0712b67283a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c | |||
@@ -568,12 +568,17 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | |||
568 | 568 | ||
569 | hdr_len = ieee80211_hdrlen(fc); | 569 | hdr_len = ieee80211_hdrlen(fc); |
570 | 570 | ||
571 | /* Find index into station table for destination station */ | 571 | /* For management frames use broadcast id to do not break aggregation */ |
572 | sta_id = iwl_sta_id_or_broadcast(priv, ctx, info->control.sta); | 572 | if (!ieee80211_is_data(fc)) |
573 | if (sta_id == IWL_INVALID_STATION) { | 573 | sta_id = ctx->bcast_sta_id; |
574 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | 574 | else { |
575 | hdr->addr1); | 575 | /* Find index into station table for destination station */ |
576 | goto drop_unlock; | 576 | sta_id = iwl_sta_id_or_broadcast(priv, ctx, info->control.sta); |
577 | if (sta_id == IWL_INVALID_STATION) { | ||
578 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | ||
579 | hdr->addr1); | ||
580 | goto drop_unlock; | ||
581 | } | ||
577 | } | 582 | } |
578 | 583 | ||
579 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); | 584 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); |
@@ -1224,12 +1229,16 @@ int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | |||
1224 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { | 1229 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { |
1225 | 1230 | ||
1226 | tx_info = &txq->txb[txq->q.read_ptr]; | 1231 | tx_info = &txq->txb[txq->q.read_ptr]; |
1227 | iwlagn_tx_status(priv, tx_info, | 1232 | |
1228 | txq_id >= IWLAGN_FIRST_AMPDU_QUEUE); | 1233 | if (WARN_ON_ONCE(tx_info->skb == NULL)) |
1234 | continue; | ||
1229 | 1235 | ||
1230 | hdr = (struct ieee80211_hdr *)tx_info->skb->data; | 1236 | hdr = (struct ieee80211_hdr *)tx_info->skb->data; |
1231 | if (hdr && ieee80211_is_data_qos(hdr->frame_control)) | 1237 | if (ieee80211_is_data_qos(hdr->frame_control)) |
1232 | nfreed++; | 1238 | nfreed++; |
1239 | |||
1240 | iwlagn_tx_status(priv, tx_info, | ||
1241 | txq_id >= IWLAGN_FIRST_AMPDU_QUEUE); | ||
1233 | tx_info->skb = NULL; | 1242 | tx_info->skb = NULL; |
1234 | 1243 | ||
1235 | if (priv->cfg->ops->lib->txq_inval_byte_cnt_tbl) | 1244 | if (priv->cfg->ops->lib->txq_inval_byte_cnt_tbl) |
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 7e8a658b767..f3ac62431a3 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -1339,8 +1339,8 @@ int lbs_execute_next_command(struct lbs_private *priv) | |||
1339 | cpu_to_le16(PS_MODE_ACTION_EXIT_PS)) { | 1339 | cpu_to_le16(PS_MODE_ACTION_EXIT_PS)) { |
1340 | lbs_deb_host( | 1340 | lbs_deb_host( |
1341 | "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n"); | 1341 | "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n"); |
1342 | list_del(&cmdnode->list); | ||
1343 | spin_lock_irqsave(&priv->driver_lock, flags); | 1342 | spin_lock_irqsave(&priv->driver_lock, flags); |
1343 | list_del(&cmdnode->list); | ||
1344 | lbs_complete_command(priv, cmdnode, 0); | 1344 | lbs_complete_command(priv, cmdnode, 0); |
1345 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 1345 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
1346 | 1346 | ||
@@ -1352,8 +1352,8 @@ int lbs_execute_next_command(struct lbs_private *priv) | |||
1352 | (priv->psstate == PS_STATE_PRE_SLEEP)) { | 1352 | (priv->psstate == PS_STATE_PRE_SLEEP)) { |
1353 | lbs_deb_host( | 1353 | lbs_deb_host( |
1354 | "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); | 1354 | "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); |
1355 | list_del(&cmdnode->list); | ||
1356 | spin_lock_irqsave(&priv->driver_lock, flags); | 1355 | spin_lock_irqsave(&priv->driver_lock, flags); |
1356 | list_del(&cmdnode->list); | ||
1357 | lbs_complete_command(priv, cmdnode, 0); | 1357 | lbs_complete_command(priv, cmdnode, 0); |
1358 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 1358 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
1359 | priv->needtowakeup = 1; | 1359 | priv->needtowakeup = 1; |
@@ -1366,7 +1366,9 @@ int lbs_execute_next_command(struct lbs_private *priv) | |||
1366 | "EXEC_NEXT_CMD: sending EXIT_PS\n"); | 1366 | "EXEC_NEXT_CMD: sending EXIT_PS\n"); |
1367 | } | 1367 | } |
1368 | } | 1368 | } |
1369 | spin_lock_irqsave(&priv->driver_lock, flags); | ||
1369 | list_del(&cmdnode->list); | 1370 | list_del(&cmdnode->list); |
1371 | spin_unlock_irqrestore(&priv->driver_lock, flags); | ||
1370 | lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n", | 1372 | lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n", |
1371 | le16_to_cpu(cmd->command)); | 1373 | le16_to_cpu(cmd->command)); |
1372 | lbs_submit_command(priv, cmdnode); | 1374 | lbs_submit_command(priv, cmdnode); |
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c index b78a38d9172..8c7c522a056 100644 --- a/drivers/net/zorro8390.c +++ b/drivers/net/zorro8390.c | |||
@@ -126,7 +126,7 @@ static int __devinit zorro8390_init_one(struct zorro_dev *z, | |||
126 | 126 | ||
127 | board = z->resource.start; | 127 | board = z->resource.start; |
128 | ioaddr = board+cards[i].offset; | 128 | ioaddr = board+cards[i].offset; |
129 | dev = alloc_ei_netdev(); | 129 | dev = ____alloc_ei_netdev(0); |
130 | if (!dev) | 130 | if (!dev) |
131 | return -ENOMEM; | 131 | return -ENOMEM; |
132 | if (!request_mem_region(ioaddr, NE_IO_EXTENT*2, DRV_NAME)) { | 132 | if (!request_mem_region(ioaddr, NE_IO_EXTENT*2, DRV_NAME)) { |
@@ -146,15 +146,15 @@ static int __devinit zorro8390_init_one(struct zorro_dev *z, | |||
146 | static const struct net_device_ops zorro8390_netdev_ops = { | 146 | static const struct net_device_ops zorro8390_netdev_ops = { |
147 | .ndo_open = zorro8390_open, | 147 | .ndo_open = zorro8390_open, |
148 | .ndo_stop = zorro8390_close, | 148 | .ndo_stop = zorro8390_close, |
149 | .ndo_start_xmit = ei_start_xmit, | 149 | .ndo_start_xmit = __ei_start_xmit, |
150 | .ndo_tx_timeout = ei_tx_timeout, | 150 | .ndo_tx_timeout = __ei_tx_timeout, |
151 | .ndo_get_stats = ei_get_stats, | 151 | .ndo_get_stats = __ei_get_stats, |
152 | .ndo_set_multicast_list = ei_set_multicast_list, | 152 | .ndo_set_multicast_list = __ei_set_multicast_list, |
153 | .ndo_validate_addr = eth_validate_addr, | 153 | .ndo_validate_addr = eth_validate_addr, |
154 | .ndo_set_mac_address = eth_mac_addr, | 154 | .ndo_set_mac_address = eth_mac_addr, |
155 | .ndo_change_mtu = eth_change_mtu, | 155 | .ndo_change_mtu = eth_change_mtu, |
156 | #ifdef CONFIG_NET_POLL_CONTROLLER | 156 | #ifdef CONFIG_NET_POLL_CONTROLLER |
157 | .ndo_poll_controller = ei_poll, | 157 | .ndo_poll_controller = __ei_poll, |
158 | #endif | 158 | #endif |
159 | }; | 159 | }; |
160 | 160 | ||
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index ebf51ad1b71..a806cb321d2 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -579,7 +579,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, | |||
579 | } | 579 | } |
580 | size0 = calculate_iosize(size, min_size, size1, | 580 | size0 = calculate_iosize(size, min_size, size1, |
581 | resource_size(b_res), 4096); | 581 | resource_size(b_res), 4096); |
582 | size1 = !add_size? size0: | 582 | size1 = (!add_head || (add_head && !add_size)) ? size0 : |
583 | calculate_iosize(size, min_size+add_size, size1, | 583 | calculate_iosize(size, min_size+add_size, size1, |
584 | resource_size(b_res), 4096); | 584 | resource_size(b_res), 4096); |
585 | if (!size0 && !size1) { | 585 | if (!size0 && !size1) { |
@@ -677,7 +677,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
677 | align += aligns[order]; | 677 | align += aligns[order]; |
678 | } | 678 | } |
679 | size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align); | 679 | size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align); |
680 | size1 = !add_size ? size : | 680 | size1 = (!add_head || (add_head && !add_size)) ? size0 : |
681 | calculate_memsize(size, min_size+add_size, 0, | 681 | calculate_memsize(size, min_size+add_size, 0, |
682 | resource_size(b_res), min_align); | 682 | resource_size(b_res), min_align); |
683 | if (!size0 && !size1) { | 683 | if (!size0 && !size1) { |
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index 5f2dd386152..2c1abf63957 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -585,8 +585,9 @@ static bool eeepc_wlan_rfkill_blocked(struct eeepc_laptop *eeepc) | |||
585 | return true; | 585 | return true; |
586 | } | 586 | } |
587 | 587 | ||
588 | static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc) | 588 | static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle) |
589 | { | 589 | { |
590 | struct pci_dev *port; | ||
590 | struct pci_dev *dev; | 591 | struct pci_dev *dev; |
591 | struct pci_bus *bus; | 592 | struct pci_bus *bus; |
592 | bool blocked = eeepc_wlan_rfkill_blocked(eeepc); | 593 | bool blocked = eeepc_wlan_rfkill_blocked(eeepc); |
@@ -599,9 +600,16 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc) | |||
599 | mutex_lock(&eeepc->hotplug_lock); | 600 | mutex_lock(&eeepc->hotplug_lock); |
600 | 601 | ||
601 | if (eeepc->hotplug_slot) { | 602 | if (eeepc->hotplug_slot) { |
602 | bus = pci_find_bus(0, 1); | 603 | port = acpi_get_pci_dev(handle); |
604 | if (!port) { | ||
605 | pr_warning("Unable to find port\n"); | ||
606 | goto out_unlock; | ||
607 | } | ||
608 | |||
609 | bus = port->subordinate; | ||
610 | |||
603 | if (!bus) { | 611 | if (!bus) { |
604 | pr_warning("Unable to find PCI bus 1?\n"); | 612 | pr_warning("Unable to find PCI bus?\n"); |
605 | goto out_unlock; | 613 | goto out_unlock; |
606 | } | 614 | } |
607 | 615 | ||
@@ -609,6 +617,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc) | |||
609 | pr_err("Unable to read PCI config space?\n"); | 617 | pr_err("Unable to read PCI config space?\n"); |
610 | goto out_unlock; | 618 | goto out_unlock; |
611 | } | 619 | } |
620 | |||
612 | absent = (l == 0xffffffff); | 621 | absent = (l == 0xffffffff); |
613 | 622 | ||
614 | if (blocked != absent) { | 623 | if (blocked != absent) { |
@@ -647,6 +656,17 @@ out_unlock: | |||
647 | mutex_unlock(&eeepc->hotplug_lock); | 656 | mutex_unlock(&eeepc->hotplug_lock); |
648 | } | 657 | } |
649 | 658 | ||
659 | static void eeepc_rfkill_hotplug_update(struct eeepc_laptop *eeepc, char *node) | ||
660 | { | ||
661 | acpi_status status = AE_OK; | ||
662 | acpi_handle handle; | ||
663 | |||
664 | status = acpi_get_handle(NULL, node, &handle); | ||
665 | |||
666 | if (ACPI_SUCCESS(status)) | ||
667 | eeepc_rfkill_hotplug(eeepc, handle); | ||
668 | } | ||
669 | |||
650 | static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) | 670 | static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) |
651 | { | 671 | { |
652 | struct eeepc_laptop *eeepc = data; | 672 | struct eeepc_laptop *eeepc = data; |
@@ -654,7 +674,7 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) | |||
654 | if (event != ACPI_NOTIFY_BUS_CHECK) | 674 | if (event != ACPI_NOTIFY_BUS_CHECK) |
655 | return; | 675 | return; |
656 | 676 | ||
657 | eeepc_rfkill_hotplug(eeepc); | 677 | eeepc_rfkill_hotplug(eeepc, handle); |
658 | } | 678 | } |
659 | 679 | ||
660 | static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc, | 680 | static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc, |
@@ -672,6 +692,11 @@ static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc, | |||
672 | eeepc); | 692 | eeepc); |
673 | if (ACPI_FAILURE(status)) | 693 | if (ACPI_FAILURE(status)) |
674 | pr_warning("Failed to register notify on %s\n", node); | 694 | pr_warning("Failed to register notify on %s\n", node); |
695 | /* | ||
696 | * Refresh pci hotplug in case the rfkill state was | ||
697 | * changed during setup. | ||
698 | */ | ||
699 | eeepc_rfkill_hotplug(eeepc, handle); | ||
675 | } else | 700 | } else |
676 | return -ENODEV; | 701 | return -ENODEV; |
677 | 702 | ||
@@ -693,6 +718,12 @@ static void eeepc_unregister_rfkill_notifier(struct eeepc_laptop *eeepc, | |||
693 | if (ACPI_FAILURE(status)) | 718 | if (ACPI_FAILURE(status)) |
694 | pr_err("Error removing rfkill notify handler %s\n", | 719 | pr_err("Error removing rfkill notify handler %s\n", |
695 | node); | 720 | node); |
721 | /* | ||
722 | * Refresh pci hotplug in case the rfkill | ||
723 | * state was changed after | ||
724 | * eeepc_unregister_rfkill_notifier() | ||
725 | */ | ||
726 | eeepc_rfkill_hotplug(eeepc, handle); | ||
696 | } | 727 | } |
697 | } | 728 | } |
698 | 729 | ||
@@ -816,11 +847,7 @@ static void eeepc_rfkill_exit(struct eeepc_laptop *eeepc) | |||
816 | rfkill_destroy(eeepc->wlan_rfkill); | 847 | rfkill_destroy(eeepc->wlan_rfkill); |
817 | eeepc->wlan_rfkill = NULL; | 848 | eeepc->wlan_rfkill = NULL; |
818 | } | 849 | } |
819 | /* | 850 | |
820 | * Refresh pci hotplug in case the rfkill state was changed after | ||
821 | * eeepc_unregister_rfkill_notifier() | ||
822 | */ | ||
823 | eeepc_rfkill_hotplug(eeepc); | ||
824 | if (eeepc->hotplug_slot) | 851 | if (eeepc->hotplug_slot) |
825 | pci_hp_deregister(eeepc->hotplug_slot); | 852 | pci_hp_deregister(eeepc->hotplug_slot); |
826 | 853 | ||
@@ -889,11 +916,6 @@ static int eeepc_rfkill_init(struct eeepc_laptop *eeepc) | |||
889 | eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5"); | 916 | eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5"); |
890 | eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6"); | 917 | eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6"); |
891 | eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7"); | 918 | eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7"); |
892 | /* | ||
893 | * Refresh pci hotplug in case the rfkill state was changed during | ||
894 | * setup. | ||
895 | */ | ||
896 | eeepc_rfkill_hotplug(eeepc); | ||
897 | 919 | ||
898 | exit: | 920 | exit: |
899 | if (result && result != -ENODEV) | 921 | if (result && result != -ENODEV) |
@@ -928,8 +950,11 @@ static int eeepc_hotk_restore(struct device *device) | |||
928 | struct eeepc_laptop *eeepc = dev_get_drvdata(device); | 950 | struct eeepc_laptop *eeepc = dev_get_drvdata(device); |
929 | 951 | ||
930 | /* Refresh both wlan rfkill state and pci hotplug */ | 952 | /* Refresh both wlan rfkill state and pci hotplug */ |
931 | if (eeepc->wlan_rfkill) | 953 | if (eeepc->wlan_rfkill) { |
932 | eeepc_rfkill_hotplug(eeepc); | 954 | eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P5"); |
955 | eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P6"); | ||
956 | eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P7"); | ||
957 | } | ||
933 | 958 | ||
934 | if (eeepc->bluetooth_rfkill) | 959 | if (eeepc->bluetooth_rfkill) |
935 | rfkill_set_sw_state(eeepc->bluetooth_rfkill, | 960 | rfkill_set_sw_state(eeepc->bluetooth_rfkill, |
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index 8f709aec4da..6fe8cd6e23b 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c | |||
@@ -934,6 +934,14 @@ static ssize_t sony_nc_sysfs_store(struct device *dev, | |||
934 | /* | 934 | /* |
935 | * Backlight device | 935 | * Backlight device |
936 | */ | 936 | */ |
937 | struct sony_backlight_props { | ||
938 | struct backlight_device *dev; | ||
939 | int handle; | ||
940 | u8 offset; | ||
941 | u8 maxlvl; | ||
942 | }; | ||
943 | struct sony_backlight_props sony_bl_props; | ||
944 | |||
937 | static int sony_backlight_update_status(struct backlight_device *bd) | 945 | static int sony_backlight_update_status(struct backlight_device *bd) |
938 | { | 946 | { |
939 | return acpi_callsetfunc(sony_nc_acpi_handle, "SBRT", | 947 | return acpi_callsetfunc(sony_nc_acpi_handle, "SBRT", |
@@ -954,21 +962,26 @@ static int sony_nc_get_brightness_ng(struct backlight_device *bd) | |||
954 | { | 962 | { |
955 | int result; | 963 | int result; |
956 | int *handle = (int *)bl_get_data(bd); | 964 | int *handle = (int *)bl_get_data(bd); |
965 | struct sony_backlight_props *sdev = | ||
966 | (struct sony_backlight_props *)bl_get_data(bd); | ||
957 | 967 | ||
958 | sony_call_snc_handle(*handle, 0x0200, &result); | 968 | sony_call_snc_handle(sdev->handle, 0x0200, &result); |
959 | 969 | ||
960 | return result & 0xff; | 970 | return (result & 0xff) - sdev->offset; |
961 | } | 971 | } |
962 | 972 | ||
963 | static int sony_nc_update_status_ng(struct backlight_device *bd) | 973 | static int sony_nc_update_status_ng(struct backlight_device *bd) |
964 | { | 974 | { |
965 | int value, result; | 975 | int value, result; |
966 | int *handle = (int *)bl_get_data(bd); | 976 | int *handle = (int *)bl_get_data(bd); |
977 | struct sony_backlight_props *sdev = | ||
978 | (struct sony_backlight_props *)bl_get_data(bd); | ||
967 | 979 | ||
968 | value = bd->props.brightness; | 980 | value = bd->props.brightness + sdev->offset; |
969 | sony_call_snc_handle(*handle, 0x0100 | (value << 16), &result); | 981 | if (sony_call_snc_handle(sdev->handle, 0x0100 | (value << 16), &result)) |
982 | return -EIO; | ||
970 | 983 | ||
971 | return sony_nc_get_brightness_ng(bd); | 984 | return value; |
972 | } | 985 | } |
973 | 986 | ||
974 | static const struct backlight_ops sony_backlight_ops = { | 987 | static const struct backlight_ops sony_backlight_ops = { |
@@ -981,8 +994,6 @@ static const struct backlight_ops sony_backlight_ng_ops = { | |||
981 | .update_status = sony_nc_update_status_ng, | 994 | .update_status = sony_nc_update_status_ng, |
982 | .get_brightness = sony_nc_get_brightness_ng, | 995 | .get_brightness = sony_nc_get_brightness_ng, |
983 | }; | 996 | }; |
984 | static int backlight_ng_handle; | ||
985 | static struct backlight_device *sony_backlight_device; | ||
986 | 997 | ||
987 | /* | 998 | /* |
988 | * New SNC-only Vaios event mapping to driver known keys | 999 | * New SNC-only Vaios event mapping to driver known keys |
@@ -1549,6 +1560,75 @@ static void sony_nc_kbd_backlight_resume(void) | |||
1549 | &ignore); | 1560 | &ignore); |
1550 | } | 1561 | } |
1551 | 1562 | ||
1563 | static void sony_nc_backlight_ng_read_limits(int handle, | ||
1564 | struct sony_backlight_props *props) | ||
1565 | { | ||
1566 | int offset; | ||
1567 | acpi_status status; | ||
1568 | u8 brlvl, i; | ||
1569 | u8 min = 0xff, max = 0x00; | ||
1570 | struct acpi_object_list params; | ||
1571 | union acpi_object in_obj; | ||
1572 | union acpi_object *lvl_enum; | ||
1573 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
1574 | |||
1575 | props->handle = handle; | ||
1576 | props->offset = 0; | ||
1577 | props->maxlvl = 0xff; | ||
1578 | |||
1579 | offset = sony_find_snc_handle(handle); | ||
1580 | if (offset < 0) | ||
1581 | return; | ||
1582 | |||
1583 | /* try to read the boundaries from ACPI tables, if we fail the above | ||
1584 | * defaults should be reasonable | ||
1585 | */ | ||
1586 | params.count = 1; | ||
1587 | params.pointer = &in_obj; | ||
1588 | in_obj.type = ACPI_TYPE_INTEGER; | ||
1589 | in_obj.integer.value = offset; | ||
1590 | status = acpi_evaluate_object(sony_nc_acpi_handle, "SN06", ¶ms, | ||
1591 | &buffer); | ||
1592 | if (ACPI_FAILURE(status)) | ||
1593 | return; | ||
1594 | |||
1595 | lvl_enum = (union acpi_object *) buffer.pointer; | ||
1596 | if (!lvl_enum) { | ||
1597 | pr_err("No SN06 return object."); | ||
1598 | return; | ||
1599 | } | ||
1600 | if (lvl_enum->type != ACPI_TYPE_BUFFER) { | ||
1601 | pr_err("Invalid SN06 return object 0x%.2x\n", | ||
1602 | lvl_enum->type); | ||
1603 | goto out_invalid; | ||
1604 | } | ||
1605 | |||
1606 | /* the buffer lists brightness levels available, brightness levels are | ||
1607 | * from 0 to 8 in the array, other values are used by ALS control. | ||
1608 | */ | ||
1609 | for (i = 0; i < 9 && i < lvl_enum->buffer.length; i++) { | ||
1610 | |||
1611 | brlvl = *(lvl_enum->buffer.pointer + i); | ||
1612 | dprintk("Brightness level: %d\n", brlvl); | ||
1613 | |||
1614 | if (!brlvl) | ||
1615 | break; | ||
1616 | |||
1617 | if (brlvl > max) | ||
1618 | max = brlvl; | ||
1619 | if (brlvl < min) | ||
1620 | min = brlvl; | ||
1621 | } | ||
1622 | props->offset = min; | ||
1623 | props->maxlvl = max; | ||
1624 | dprintk("Brightness levels: min=%d max=%d\n", props->offset, | ||
1625 | props->maxlvl); | ||
1626 | |||
1627 | out_invalid: | ||
1628 | kfree(buffer.pointer); | ||
1629 | return; | ||
1630 | } | ||
1631 | |||
1552 | static void sony_nc_backlight_setup(void) | 1632 | static void sony_nc_backlight_setup(void) |
1553 | { | 1633 | { |
1554 | acpi_handle unused; | 1634 | acpi_handle unused; |
@@ -1557,14 +1637,14 @@ static void sony_nc_backlight_setup(void) | |||
1557 | struct backlight_properties props; | 1637 | struct backlight_properties props; |
1558 | 1638 | ||
1559 | if (sony_find_snc_handle(0x12f) != -1) { | 1639 | if (sony_find_snc_handle(0x12f) != -1) { |
1560 | backlight_ng_handle = 0x12f; | ||
1561 | ops = &sony_backlight_ng_ops; | 1640 | ops = &sony_backlight_ng_ops; |
1562 | max_brightness = 0xff; | 1641 | sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props); |
1642 | max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; | ||
1563 | 1643 | ||
1564 | } else if (sony_find_snc_handle(0x137) != -1) { | 1644 | } else if (sony_find_snc_handle(0x137) != -1) { |
1565 | backlight_ng_handle = 0x137; | ||
1566 | ops = &sony_backlight_ng_ops; | 1645 | ops = &sony_backlight_ng_ops; |
1567 | max_brightness = 0xff; | 1646 | sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props); |
1647 | max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; | ||
1568 | 1648 | ||
1569 | } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", | 1649 | } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", |
1570 | &unused))) { | 1650 | &unused))) { |
@@ -1577,22 +1657,22 @@ static void sony_nc_backlight_setup(void) | |||
1577 | memset(&props, 0, sizeof(struct backlight_properties)); | 1657 | memset(&props, 0, sizeof(struct backlight_properties)); |
1578 | props.type = BACKLIGHT_PLATFORM; | 1658 | props.type = BACKLIGHT_PLATFORM; |
1579 | props.max_brightness = max_brightness; | 1659 | props.max_brightness = max_brightness; |
1580 | sony_backlight_device = backlight_device_register("sony", NULL, | 1660 | sony_bl_props.dev = backlight_device_register("sony", NULL, |
1581 | &backlight_ng_handle, | 1661 | &sony_bl_props, |
1582 | ops, &props); | 1662 | ops, &props); |
1583 | 1663 | ||
1584 | if (IS_ERR(sony_backlight_device)) { | 1664 | if (IS_ERR(sony_bl_props.dev)) { |
1585 | pr_warning(DRV_PFX "unable to register backlight device\n"); | 1665 | pr_warn(DRV_PFX "unable to register backlight device\n"); |
1586 | sony_backlight_device = NULL; | 1666 | sony_bl_props.dev = NULL; |
1587 | } else | 1667 | } else |
1588 | sony_backlight_device->props.brightness = | 1668 | sony_bl_props.dev->props.brightness = |
1589 | ops->get_brightness(sony_backlight_device); | 1669 | ops->get_brightness(sony_bl_props.dev); |
1590 | } | 1670 | } |
1591 | 1671 | ||
1592 | static void sony_nc_backlight_cleanup(void) | 1672 | static void sony_nc_backlight_cleanup(void) |
1593 | { | 1673 | { |
1594 | if (sony_backlight_device) | 1674 | if (sony_bl_props.dev) |
1595 | backlight_device_unregister(sony_backlight_device); | 1675 | backlight_device_unregister(sony_bl_props.dev); |
1596 | } | 1676 | } |
1597 | 1677 | ||
1598 | static int sony_nc_add(struct acpi_device *device) | 1678 | static int sony_nc_add(struct acpi_device *device) |
@@ -2590,7 +2670,7 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd, | |||
2590 | mutex_lock(&spic_dev.lock); | 2670 | mutex_lock(&spic_dev.lock); |
2591 | switch (cmd) { | 2671 | switch (cmd) { |
2592 | case SONYPI_IOCGBRT: | 2672 | case SONYPI_IOCGBRT: |
2593 | if (sony_backlight_device == NULL) { | 2673 | if (sony_bl_props.dev == NULL) { |
2594 | ret = -EIO; | 2674 | ret = -EIO; |
2595 | break; | 2675 | break; |
2596 | } | 2676 | } |
@@ -2603,7 +2683,7 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd, | |||
2603 | ret = -EFAULT; | 2683 | ret = -EFAULT; |
2604 | break; | 2684 | break; |
2605 | case SONYPI_IOCSBRT: | 2685 | case SONYPI_IOCSBRT: |
2606 | if (sony_backlight_device == NULL) { | 2686 | if (sony_bl_props.dev == NULL) { |
2607 | ret = -EIO; | 2687 | ret = -EIO; |
2608 | break; | 2688 | break; |
2609 | } | 2689 | } |
@@ -2617,8 +2697,8 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd, | |||
2617 | break; | 2697 | break; |
2618 | } | 2698 | } |
2619 | /* sync the backlight device status */ | 2699 | /* sync the backlight device status */ |
2620 | sony_backlight_device->props.brightness = | 2700 | sony_bl_props.dev->props.brightness = |
2621 | sony_backlight_get_brightness(sony_backlight_device); | 2701 | sony_backlight_get_brightness(sony_bl_props.dev); |
2622 | break; | 2702 | break; |
2623 | case SONYPI_IOCGBAT1CAP: | 2703 | case SONYPI_IOCGBAT1CAP: |
2624 | if (ec_read16(SONYPI_BAT1_FULL, &val16)) { | 2704 | if (ec_read16(SONYPI_BAT1_FULL, &val16)) { |
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index efb3b6b9bcd..562fcf0dd2b 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
@@ -128,7 +128,8 @@ enum { | |||
128 | }; | 128 | }; |
129 | 129 | ||
130 | /* ACPI HIDs */ | 130 | /* ACPI HIDs */ |
131 | #define TPACPI_ACPI_HKEY_HID "IBM0068" | 131 | #define TPACPI_ACPI_IBM_HKEY_HID "IBM0068" |
132 | #define TPACPI_ACPI_LENOVO_HKEY_HID "LEN0068" | ||
132 | #define TPACPI_ACPI_EC_HID "PNP0C09" | 133 | #define TPACPI_ACPI_EC_HID "PNP0C09" |
133 | 134 | ||
134 | /* Input IDs */ | 135 | /* Input IDs */ |
@@ -3879,7 +3880,8 @@ errexit: | |||
3879 | } | 3880 | } |
3880 | 3881 | ||
3881 | static const struct acpi_device_id ibm_htk_device_ids[] = { | 3882 | static const struct acpi_device_id ibm_htk_device_ids[] = { |
3882 | {TPACPI_ACPI_HKEY_HID, 0}, | 3883 | {TPACPI_ACPI_IBM_HKEY_HID, 0}, |
3884 | {TPACPI_ACPI_LENOVO_HKEY_HID, 0}, | ||
3883 | {"", 0}, | 3885 | {"", 0}, |
3884 | }; | 3886 | }; |
3885 | 3887 | ||
diff --git a/drivers/rapidio/switches/idt_gen2.c b/drivers/rapidio/switches/idt_gen2.c index ac2701b22e7..043ee3136e4 100644 --- a/drivers/rapidio/switches/idt_gen2.c +++ b/drivers/rapidio/switches/idt_gen2.c | |||
@@ -95,6 +95,9 @@ idtg2_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, | |||
95 | else | 95 | else |
96 | table++; | 96 | table++; |
97 | 97 | ||
98 | if (route_port == RIO_INVALID_ROUTE) | ||
99 | route_port = IDT_DEFAULT_ROUTE; | ||
100 | |||
98 | rio_mport_write_config_32(mport, destid, hopcount, | 101 | rio_mport_write_config_32(mport, destid, hopcount, |
99 | LOCAL_RTE_CONF_DESTID_SEL, table); | 102 | LOCAL_RTE_CONF_DESTID_SEL, table); |
100 | 103 | ||
@@ -411,6 +414,12 @@ static int idtg2_switch_init(struct rio_dev *rdev, int do_enum) | |||
411 | rdev->rswitch->em_handle = idtg2_em_handler; | 414 | rdev->rswitch->em_handle = idtg2_em_handler; |
412 | rdev->rswitch->sw_sysfs = idtg2_sysfs; | 415 | rdev->rswitch->sw_sysfs = idtg2_sysfs; |
413 | 416 | ||
417 | if (do_enum) { | ||
418 | /* Ensure that default routing is disabled on startup */ | ||
419 | rio_write_config_32(rdev, | ||
420 | RIO_STD_RTE_DEFAULT_PORT, IDT_NO_ROUTE); | ||
421 | } | ||
422 | |||
414 | return 0; | 423 | return 0; |
415 | } | 424 | } |
416 | 425 | ||
diff --git a/drivers/rapidio/switches/idtcps.c b/drivers/rapidio/switches/idtcps.c index 3a971077e7b..d06ee2d44b4 100644 --- a/drivers/rapidio/switches/idtcps.c +++ b/drivers/rapidio/switches/idtcps.c | |||
@@ -26,6 +26,9 @@ idtcps_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, | |||
26 | { | 26 | { |
27 | u32 result; | 27 | u32 result; |
28 | 28 | ||
29 | if (route_port == RIO_INVALID_ROUTE) | ||
30 | route_port = CPS_DEFAULT_ROUTE; | ||
31 | |||
29 | if (table == RIO_GLOBAL_TABLE) { | 32 | if (table == RIO_GLOBAL_TABLE) { |
30 | rio_mport_write_config_32(mport, destid, hopcount, | 33 | rio_mport_write_config_32(mport, destid, hopcount, |
31 | RIO_STD_RTE_CONF_DESTID_SEL_CSR, route_destid); | 34 | RIO_STD_RTE_CONF_DESTID_SEL_CSR, route_destid); |
@@ -130,6 +133,9 @@ static int idtcps_switch_init(struct rio_dev *rdev, int do_enum) | |||
130 | /* set TVAL = ~50us */ | 133 | /* set TVAL = ~50us */ |
131 | rio_write_config_32(rdev, | 134 | rio_write_config_32(rdev, |
132 | rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); | 135 | rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); |
136 | /* Ensure that default routing is disabled on startup */ | ||
137 | rio_write_config_32(rdev, | ||
138 | RIO_STD_RTE_DEFAULT_PORT, CPS_NO_ROUTE); | ||
133 | } | 139 | } |
134 | 140 | ||
135 | return 0; | 141 | return 0; |
diff --git a/drivers/rapidio/switches/tsi57x.c b/drivers/rapidio/switches/tsi57x.c index 1a62934bfeb..db8b8028988 100644 --- a/drivers/rapidio/switches/tsi57x.c +++ b/drivers/rapidio/switches/tsi57x.c | |||
@@ -303,6 +303,12 @@ static int tsi57x_switch_init(struct rio_dev *rdev, int do_enum) | |||
303 | rdev->rswitch->em_init = tsi57x_em_init; | 303 | rdev->rswitch->em_init = tsi57x_em_init; |
304 | rdev->rswitch->em_handle = tsi57x_em_handler; | 304 | rdev->rswitch->em_handle = tsi57x_em_handler; |
305 | 305 | ||
306 | if (do_enum) { | ||
307 | /* Ensure that default routing is disabled on startup */ | ||
308 | rio_write_config_32(rdev, RIO_STD_RTE_DEFAULT_PORT, | ||
309 | RIO_INVALID_ROUTE); | ||
310 | } | ||
311 | |||
306 | return 0; | 312 | return 0; |
307 | } | 313 | } |
308 | 314 | ||
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c index 8d46838dff8..755e1fe914a 100644 --- a/drivers/rtc/rtc-davinci.c +++ b/drivers/rtc/rtc-davinci.c | |||
@@ -524,6 +524,8 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
524 | goto fail2; | 524 | goto fail2; |
525 | } | 525 | } |
526 | 526 | ||
527 | platform_set_drvdata(pdev, davinci_rtc); | ||
528 | |||
527 | davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 529 | davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, |
528 | &davinci_rtc_ops, THIS_MODULE); | 530 | &davinci_rtc_ops, THIS_MODULE); |
529 | if (IS_ERR(davinci_rtc->rtc)) { | 531 | if (IS_ERR(davinci_rtc->rtc)) { |
@@ -553,8 +555,6 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
553 | 555 | ||
554 | rtcss_write(davinci_rtc, PRTCSS_RTC_CCTRL_CAEN, PRTCSS_RTC_CCTRL); | 556 | rtcss_write(davinci_rtc, PRTCSS_RTC_CCTRL_CAEN, PRTCSS_RTC_CCTRL); |
555 | 557 | ||
556 | platform_set_drvdata(pdev, davinci_rtc); | ||
557 | |||
558 | device_init_wakeup(&pdev->dev, 0); | 558 | device_init_wakeup(&pdev->dev, 0); |
559 | 559 | ||
560 | return 0; | 560 | return 0; |
@@ -562,6 +562,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
562 | fail4: | 562 | fail4: |
563 | rtc_device_unregister(davinci_rtc->rtc); | 563 | rtc_device_unregister(davinci_rtc->rtc); |
564 | fail3: | 564 | fail3: |
565 | platform_set_drvdata(pdev, NULL); | ||
565 | iounmap(davinci_rtc->base); | 566 | iounmap(davinci_rtc->base); |
566 | fail2: | 567 | fail2: |
567 | release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); | 568 | release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); |
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c index 60ce6960082..47e681df31e 100644 --- a/drivers/rtc/rtc-ds1286.c +++ b/drivers/rtc/rtc-ds1286.c | |||
@@ -355,6 +355,7 @@ static int __devinit ds1286_probe(struct platform_device *pdev) | |||
355 | goto out; | 355 | goto out; |
356 | } | 356 | } |
357 | spin_lock_init(&priv->lock); | 357 | spin_lock_init(&priv->lock); |
358 | platform_set_drvdata(pdev, priv); | ||
358 | rtc = rtc_device_register("ds1286", &pdev->dev, | 359 | rtc = rtc_device_register("ds1286", &pdev->dev, |
359 | &ds1286_ops, THIS_MODULE); | 360 | &ds1286_ops, THIS_MODULE); |
360 | if (IS_ERR(rtc)) { | 361 | if (IS_ERR(rtc)) { |
@@ -362,7 +363,6 @@ static int __devinit ds1286_probe(struct platform_device *pdev) | |||
362 | goto out; | 363 | goto out; |
363 | } | 364 | } |
364 | priv->rtc = rtc; | 365 | priv->rtc = rtc; |
365 | platform_set_drvdata(pdev, priv); | ||
366 | return 0; | 366 | return 0; |
367 | 367 | ||
368 | out: | 368 | out: |
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 11ae64dcbf3..335551d333b 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c | |||
@@ -151,6 +151,7 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
151 | return -ENXIO; | 151 | return -ENXIO; |
152 | 152 | ||
153 | pdev->dev.platform_data = ep93xx_rtc; | 153 | pdev->dev.platform_data = ep93xx_rtc; |
154 | platform_set_drvdata(pdev, rtc); | ||
154 | 155 | ||
155 | rtc = rtc_device_register(pdev->name, | 156 | rtc = rtc_device_register(pdev->name, |
156 | &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); | 157 | &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); |
@@ -159,8 +160,6 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
159 | goto exit; | 160 | goto exit; |
160 | } | 161 | } |
161 | 162 | ||
162 | platform_set_drvdata(pdev, rtc); | ||
163 | |||
164 | err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); | 163 | err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); |
165 | if (err) | 164 | if (err) |
166 | goto fail; | 165 | goto fail; |
@@ -168,9 +167,9 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
168 | return 0; | 167 | return 0; |
169 | 168 | ||
170 | fail: | 169 | fail: |
171 | platform_set_drvdata(pdev, NULL); | ||
172 | rtc_device_unregister(rtc); | 170 | rtc_device_unregister(rtc); |
173 | exit: | 171 | exit: |
172 | platform_set_drvdata(pdev, NULL); | ||
174 | pdev->dev.platform_data = NULL; | 173 | pdev->dev.platform_data = NULL; |
175 | return err; | 174 | return err; |
176 | } | 175 | } |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 69fe664a222..eda128fc1d3 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -783,6 +783,9 @@ static int m41t80_probe(struct i2c_client *client, | |||
783 | goto exit; | 783 | goto exit; |
784 | } | 784 | } |
785 | 785 | ||
786 | clientdata->features = id->driver_data; | ||
787 | i2c_set_clientdata(client, clientdata); | ||
788 | |||
786 | rtc = rtc_device_register(client->name, &client->dev, | 789 | rtc = rtc_device_register(client->name, &client->dev, |
787 | &m41t80_rtc_ops, THIS_MODULE); | 790 | &m41t80_rtc_ops, THIS_MODULE); |
788 | if (IS_ERR(rtc)) { | 791 | if (IS_ERR(rtc)) { |
@@ -792,8 +795,6 @@ static int m41t80_probe(struct i2c_client *client, | |||
792 | } | 795 | } |
793 | 796 | ||
794 | clientdata->rtc = rtc; | 797 | clientdata->rtc = rtc; |
795 | clientdata->features = id->driver_data; | ||
796 | i2c_set_clientdata(client, clientdata); | ||
797 | 798 | ||
798 | /* Make sure HT (Halt Update) bit is cleared */ | 799 | /* Make sure HT (Halt Update) bit is cleared */ |
799 | rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR); | 800 | rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR); |
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index 20494b5edc3..3bc046f427e 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c | |||
@@ -258,6 +258,8 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) | |||
258 | } | 258 | } |
259 | 259 | ||
260 | dev_set_drvdata(&pdev->dev, info); | 260 | dev_set_drvdata(&pdev->dev, info); |
261 | /* XXX - isn't this redundant? */ | ||
262 | platform_set_drvdata(pdev, info); | ||
261 | 263 | ||
262 | info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, | 264 | info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, |
263 | &max8925_rtc_ops, THIS_MODULE); | 265 | &max8925_rtc_ops, THIS_MODULE); |
@@ -267,10 +269,9 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) | |||
267 | goto out_rtc; | 269 | goto out_rtc; |
268 | } | 270 | } |
269 | 271 | ||
270 | platform_set_drvdata(pdev, info); | ||
271 | |||
272 | return 0; | 272 | return 0; |
273 | out_rtc: | 273 | out_rtc: |
274 | platform_set_drvdata(pdev, NULL); | ||
274 | free_irq(chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info); | 275 | free_irq(chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info); |
275 | out_irq: | 276 | out_irq: |
276 | kfree(info); | 277 | kfree(info); |
diff --git a/drivers/rtc/rtc-max8998.c b/drivers/rtc/rtc-max8998.c index 3f7bc6b9fef..2e48aa60427 100644 --- a/drivers/rtc/rtc-max8998.c +++ b/drivers/rtc/rtc-max8998.c | |||
@@ -265,6 +265,8 @@ static int __devinit max8998_rtc_probe(struct platform_device *pdev) | |||
265 | info->rtc = max8998->rtc; | 265 | info->rtc = max8998->rtc; |
266 | info->irq = max8998->irq_base + MAX8998_IRQ_ALARM0; | 266 | info->irq = max8998->irq_base + MAX8998_IRQ_ALARM0; |
267 | 267 | ||
268 | platform_set_drvdata(pdev, info); | ||
269 | |||
268 | info->rtc_dev = rtc_device_register("max8998-rtc", &pdev->dev, | 270 | info->rtc_dev = rtc_device_register("max8998-rtc", &pdev->dev, |
269 | &max8998_rtc_ops, THIS_MODULE); | 271 | &max8998_rtc_ops, THIS_MODULE); |
270 | 272 | ||
@@ -274,8 +276,6 @@ static int __devinit max8998_rtc_probe(struct platform_device *pdev) | |||
274 | goto out_rtc; | 276 | goto out_rtc; |
275 | } | 277 | } |
276 | 278 | ||
277 | platform_set_drvdata(pdev, info); | ||
278 | |||
279 | ret = request_threaded_irq(info->irq, NULL, max8998_rtc_alarm_irq, 0, | 279 | ret = request_threaded_irq(info->irq, NULL, max8998_rtc_alarm_irq, 0, |
280 | "rtc-alarm0", info); | 280 | "rtc-alarm0", info); |
281 | 281 | ||
@@ -293,6 +293,7 @@ static int __devinit max8998_rtc_probe(struct platform_device *pdev) | |||
293 | return 0; | 293 | return 0; |
294 | 294 | ||
295 | out_rtc: | 295 | out_rtc: |
296 | platform_set_drvdata(pdev, NULL); | ||
296 | kfree(info); | 297 | kfree(info); |
297 | return ret; | 298 | return ret; |
298 | } | 299 | } |
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c index c5ac03793e7..a1a278bc340 100644 --- a/drivers/rtc/rtc-mc13xxx.c +++ b/drivers/rtc/rtc-mc13xxx.c | |||
@@ -349,11 +349,15 @@ static int __devinit mc13xxx_rtc_probe(struct platform_device *pdev) | |||
349 | if (ret) | 349 | if (ret) |
350 | goto err_alarm_irq_request; | 350 | goto err_alarm_irq_request; |
351 | 351 | ||
352 | mc13xxx_unlock(mc13xxx); | ||
353 | |||
352 | priv->rtc = rtc_device_register(pdev->name, | 354 | priv->rtc = rtc_device_register(pdev->name, |
353 | &pdev->dev, &mc13xxx_rtc_ops, THIS_MODULE); | 355 | &pdev->dev, &mc13xxx_rtc_ops, THIS_MODULE); |
354 | if (IS_ERR(priv->rtc)) { | 356 | if (IS_ERR(priv->rtc)) { |
355 | ret = PTR_ERR(priv->rtc); | 357 | ret = PTR_ERR(priv->rtc); |
356 | 358 | ||
359 | mc13xxx_lock(mc13xxx); | ||
360 | |||
357 | mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_TODA, priv); | 361 | mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_TODA, priv); |
358 | err_alarm_irq_request: | 362 | err_alarm_irq_request: |
359 | 363 | ||
@@ -365,12 +369,12 @@ err_reset_irq_status: | |||
365 | mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_RTCRST, priv); | 369 | mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_RTCRST, priv); |
366 | err_reset_irq_request: | 370 | err_reset_irq_request: |
367 | 371 | ||
372 | mc13xxx_unlock(mc13xxx); | ||
373 | |||
368 | platform_set_drvdata(pdev, NULL); | 374 | platform_set_drvdata(pdev, NULL); |
369 | kfree(priv); | 375 | kfree(priv); |
370 | } | 376 | } |
371 | 377 | ||
372 | mc13xxx_unlock(mc13xxx); | ||
373 | |||
374 | return ret; | 378 | return ret; |
375 | } | 379 | } |
376 | 380 | ||
diff --git a/drivers/rtc/rtc-msm6242.c b/drivers/rtc/rtc-msm6242.c index 67820626e18..fcb113c1112 100644 --- a/drivers/rtc/rtc-msm6242.c +++ b/drivers/rtc/rtc-msm6242.c | |||
@@ -214,6 +214,7 @@ static int __init msm6242_rtc_probe(struct platform_device *dev) | |||
214 | error = -ENOMEM; | 214 | error = -ENOMEM; |
215 | goto out_free_priv; | 215 | goto out_free_priv; |
216 | } | 216 | } |
217 | platform_set_drvdata(dev, priv); | ||
217 | 218 | ||
218 | rtc = rtc_device_register("rtc-msm6242", &dev->dev, &msm6242_rtc_ops, | 219 | rtc = rtc_device_register("rtc-msm6242", &dev->dev, &msm6242_rtc_ops, |
219 | THIS_MODULE); | 220 | THIS_MODULE); |
@@ -223,10 +224,10 @@ static int __init msm6242_rtc_probe(struct platform_device *dev) | |||
223 | } | 224 | } |
224 | 225 | ||
225 | priv->rtc = rtc; | 226 | priv->rtc = rtc; |
226 | platform_set_drvdata(dev, priv); | ||
227 | return 0; | 227 | return 0; |
228 | 228 | ||
229 | out_unmap: | 229 | out_unmap: |
230 | platform_set_drvdata(dev, NULL); | ||
230 | iounmap(priv->regs); | 231 | iounmap(priv->regs); |
231 | out_free_priv: | 232 | out_free_priv: |
232 | kfree(priv); | 233 | kfree(priv); |
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 826ab64a8fa..d814417bee8 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
@@ -418,14 +418,6 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
418 | goto exit_put_clk; | 418 | goto exit_put_clk; |
419 | } | 419 | } |
420 | 420 | ||
421 | rtc = rtc_device_register(pdev->name, &pdev->dev, &mxc_rtc_ops, | ||
422 | THIS_MODULE); | ||
423 | if (IS_ERR(rtc)) { | ||
424 | ret = PTR_ERR(rtc); | ||
425 | goto exit_put_clk; | ||
426 | } | ||
427 | |||
428 | pdata->rtc = rtc; | ||
429 | platform_set_drvdata(pdev, pdata); | 421 | platform_set_drvdata(pdev, pdata); |
430 | 422 | ||
431 | /* Configure and enable the RTC */ | 423 | /* Configure and enable the RTC */ |
@@ -438,8 +430,19 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
438 | pdata->irq = -1; | 430 | pdata->irq = -1; |
439 | } | 431 | } |
440 | 432 | ||
433 | rtc = rtc_device_register(pdev->name, &pdev->dev, &mxc_rtc_ops, | ||
434 | THIS_MODULE); | ||
435 | if (IS_ERR(rtc)) { | ||
436 | ret = PTR_ERR(rtc); | ||
437 | goto exit_clr_drvdata; | ||
438 | } | ||
439 | |||
440 | pdata->rtc = rtc; | ||
441 | |||
441 | return 0; | 442 | return 0; |
442 | 443 | ||
444 | exit_clr_drvdata: | ||
445 | platform_set_drvdata(pdev, NULL); | ||
443 | exit_put_clk: | 446 | exit_put_clk: |
444 | clk_disable(pdata->clk); | 447 | clk_disable(pdata->clk); |
445 | clk_put(pdata->clk); | 448 | clk_put(pdata->clk); |
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c index a633abc4289..cd4f198cc2e 100644 --- a/drivers/rtc/rtc-pcap.c +++ b/drivers/rtc/rtc-pcap.c | |||
@@ -151,6 +151,8 @@ static int __devinit pcap_rtc_probe(struct platform_device *pdev) | |||
151 | 151 | ||
152 | pcap_rtc->pcap = dev_get_drvdata(pdev->dev.parent); | 152 | pcap_rtc->pcap = dev_get_drvdata(pdev->dev.parent); |
153 | 153 | ||
154 | platform_set_drvdata(pdev, pcap_rtc); | ||
155 | |||
154 | pcap_rtc->rtc = rtc_device_register("pcap", &pdev->dev, | 156 | pcap_rtc->rtc = rtc_device_register("pcap", &pdev->dev, |
155 | &pcap_rtc_ops, THIS_MODULE); | 157 | &pcap_rtc_ops, THIS_MODULE); |
156 | if (IS_ERR(pcap_rtc->rtc)) { | 158 | if (IS_ERR(pcap_rtc->rtc)) { |
@@ -158,7 +160,6 @@ static int __devinit pcap_rtc_probe(struct platform_device *pdev) | |||
158 | goto fail_rtc; | 160 | goto fail_rtc; |
159 | } | 161 | } |
160 | 162 | ||
161 | platform_set_drvdata(pdev, pcap_rtc); | ||
162 | 163 | ||
163 | timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); | 164 | timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); |
164 | alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); | 165 | alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); |
@@ -177,6 +178,7 @@ fail_alarm: | |||
177 | fail_timer: | 178 | fail_timer: |
178 | rtc_device_unregister(pcap_rtc->rtc); | 179 | rtc_device_unregister(pcap_rtc->rtc); |
179 | fail_rtc: | 180 | fail_rtc: |
181 | platform_set_drvdata(pdev, NULL); | ||
180 | kfree(pcap_rtc); | 182 | kfree(pcap_rtc); |
181 | return err; | 183 | return err; |
182 | } | 184 | } |
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c index 694da39b6dd..359da6d020b 100644 --- a/drivers/rtc/rtc-rp5c01.c +++ b/drivers/rtc/rtc-rp5c01.c | |||
@@ -249,15 +249,15 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev) | |||
249 | 249 | ||
250 | spin_lock_init(&priv->lock); | 250 | spin_lock_init(&priv->lock); |
251 | 251 | ||
252 | platform_set_drvdata(dev, priv); | ||
253 | |||
252 | rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops, | 254 | rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops, |
253 | THIS_MODULE); | 255 | THIS_MODULE); |
254 | if (IS_ERR(rtc)) { | 256 | if (IS_ERR(rtc)) { |
255 | error = PTR_ERR(rtc); | 257 | error = PTR_ERR(rtc); |
256 | goto out_unmap; | 258 | goto out_unmap; |
257 | } | 259 | } |
258 | |||
259 | priv->rtc = rtc; | 260 | priv->rtc = rtc; |
260 | platform_set_drvdata(dev, priv); | ||
261 | 261 | ||
262 | error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); | 262 | error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); |
263 | if (error) | 263 | if (error) |
@@ -268,6 +268,7 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev) | |||
268 | out_unregister: | 268 | out_unregister: |
269 | rtc_device_unregister(rtc); | 269 | rtc_device_unregister(rtc); |
270 | out_unmap: | 270 | out_unmap: |
271 | platform_set_drvdata(dev, NULL); | ||
271 | iounmap(priv->regs); | 272 | iounmap(priv->regs); |
272 | out_free_priv: | 273 | out_free_priv: |
273 | kfree(priv); | 274 | kfree(priv); |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index b3466c491cd..16512ecae31 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -46,6 +46,7 @@ static struct clk *rtc_clk; | |||
46 | static void __iomem *s3c_rtc_base; | 46 | static void __iomem *s3c_rtc_base; |
47 | static int s3c_rtc_alarmno = NO_IRQ; | 47 | static int s3c_rtc_alarmno = NO_IRQ; |
48 | static int s3c_rtc_tickno = NO_IRQ; | 48 | static int s3c_rtc_tickno = NO_IRQ; |
49 | static bool wake_en; | ||
49 | static enum s3c_cpu_type s3c_rtc_cpu_type; | 50 | static enum s3c_cpu_type s3c_rtc_cpu_type; |
50 | 51 | ||
51 | static DEFINE_SPINLOCK(s3c_rtc_pie_lock); | 52 | static DEFINE_SPINLOCK(s3c_rtc_pie_lock); |
@@ -562,8 +563,12 @@ static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
562 | } | 563 | } |
563 | s3c_rtc_enable(pdev, 0); | 564 | s3c_rtc_enable(pdev, 0); |
564 | 565 | ||
565 | if (device_may_wakeup(&pdev->dev)) | 566 | if (device_may_wakeup(&pdev->dev) && !wake_en) { |
566 | enable_irq_wake(s3c_rtc_alarmno); | 567 | if (enable_irq_wake(s3c_rtc_alarmno) == 0) |
568 | wake_en = true; | ||
569 | else | ||
570 | dev_err(&pdev->dev, "enable_irq_wake failed\n"); | ||
571 | } | ||
567 | 572 | ||
568 | return 0; | 573 | return 0; |
569 | } | 574 | } |
@@ -579,8 +584,10 @@ static int s3c_rtc_resume(struct platform_device *pdev) | |||
579 | writew(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON); | 584 | writew(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON); |
580 | } | 585 | } |
581 | 586 | ||
582 | if (device_may_wakeup(&pdev->dev)) | 587 | if (device_may_wakeup(&pdev->dev) && wake_en) { |
583 | disable_irq_wake(s3c_rtc_alarmno); | 588 | disable_irq_wake(s3c_rtc_alarmno); |
589 | wake_en = false; | ||
590 | } | ||
584 | 591 | ||
585 | return 0; | 592 | return 0; |
586 | } | 593 | } |
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 475e603fc58..86b6f1cc1b1 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c | |||
@@ -1742,11 +1742,20 @@ int dasd_sleep_on_interruptible(struct dasd_ccw_req *cqr) | |||
1742 | static inline int _dasd_term_running_cqr(struct dasd_device *device) | 1742 | static inline int _dasd_term_running_cqr(struct dasd_device *device) |
1743 | { | 1743 | { |
1744 | struct dasd_ccw_req *cqr; | 1744 | struct dasd_ccw_req *cqr; |
1745 | int rc; | ||
1745 | 1746 | ||
1746 | if (list_empty(&device->ccw_queue)) | 1747 | if (list_empty(&device->ccw_queue)) |
1747 | return 0; | 1748 | return 0; |
1748 | cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); | 1749 | cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); |
1749 | return device->discipline->term_IO(cqr); | 1750 | rc = device->discipline->term_IO(cqr); |
1751 | if (!rc) | ||
1752 | /* | ||
1753 | * CQR terminated because a more important request is pending. | ||
1754 | * Undo decreasing of retry counter because this is | ||
1755 | * not an error case. | ||
1756 | */ | ||
1757 | cqr->retries++; | ||
1758 | return rc; | ||
1750 | } | 1759 | } |
1751 | 1760 | ||
1752 | int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr) | 1761 | int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr) |
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c index 29143eda9dd..85dddb1e412 100644 --- a/drivers/s390/block/dasd_diag.c +++ b/drivers/s390/block/dasd_diag.c | |||
@@ -239,7 +239,6 @@ static void dasd_ext_handler(unsigned int ext_int_code, | |||
239 | addr_t ip; | 239 | addr_t ip; |
240 | int rc; | 240 | int rc; |
241 | 241 | ||
242 | kstat_cpu(smp_processor_id()).irqs[EXTINT_DSD]++; | ||
243 | switch (ext_int_code >> 24) { | 242 | switch (ext_int_code >> 24) { |
244 | case DASD_DIAG_CODE_31BIT: | 243 | case DASD_DIAG_CODE_31BIT: |
245 | ip = (addr_t) param32; | 244 | ip = (addr_t) param32; |
@@ -250,6 +249,7 @@ static void dasd_ext_handler(unsigned int ext_int_code, | |||
250 | default: | 249 | default: |
251 | return; | 250 | return; |
252 | } | 251 | } |
252 | kstat_cpu(smp_processor_id()).irqs[EXTINT_DSD]++; | ||
253 | if (!ip) { /* no intparm: unsolicited interrupt */ | 253 | if (!ip) { /* no intparm: unsolicited interrupt */ |
254 | DBF_EVENT(DBF_NOTICE, "%s", "caught unsolicited " | 254 | DBF_EVENT(DBF_NOTICE, "%s", "caught unsolicited " |
255 | "interrupt"); | 255 | "interrupt"); |
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c index 4b60ede07f0..be55fb2b1b1 100644 --- a/drivers/s390/char/sclp_cmd.c +++ b/drivers/s390/char/sclp_cmd.c | |||
@@ -518,6 +518,8 @@ static void __init insert_increment(u16 rn, int standby, int assigned) | |||
518 | return; | 518 | return; |
519 | new_incr->rn = rn; | 519 | new_incr->rn = rn; |
520 | new_incr->standby = standby; | 520 | new_incr->standby = standby; |
521 | if (!standby) | ||
522 | new_incr->usecount = 1; | ||
521 | last_rn = 0; | 523 | last_rn = 0; |
522 | prev = &sclp_mem_list; | 524 | prev = &sclp_mem_list; |
523 | list_for_each_entry(incr, &sclp_mem_list, list) { | 525 | list_for_each_entry(incr, &sclp_mem_list, list) { |
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c index 83cea9a55e2..1b3924c2fff 100644 --- a/drivers/s390/char/tape_block.c +++ b/drivers/s390/char/tape_block.c | |||
@@ -236,7 +236,6 @@ tapeblock_setup_device(struct tape_device * device) | |||
236 | disk->major = tapeblock_major; | 236 | disk->major = tapeblock_major; |
237 | disk->first_minor = device->first_minor; | 237 | disk->first_minor = device->first_minor; |
238 | disk->fops = &tapeblock_fops; | 238 | disk->fops = &tapeblock_fops; |
239 | disk->events = DISK_EVENT_MEDIA_CHANGE; | ||
240 | disk->private_data = tape_get_device(device); | 239 | disk->private_data = tape_get_device(device); |
241 | disk->queue = blkdat->request_queue; | 240 | disk->queue = blkdat->request_queue; |
242 | set_capacity(disk, 0); | 241 | set_capacity(disk, 0); |
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c index 414427d64a8..607998f0b7d 100644 --- a/drivers/s390/kvm/kvm_virtio.c +++ b/drivers/s390/kvm/kvm_virtio.c | |||
@@ -381,10 +381,10 @@ static void kvm_extint_handler(unsigned int ext_int_code, | |||
381 | u16 subcode; | 381 | u16 subcode; |
382 | u32 param; | 382 | u32 param; |
383 | 383 | ||
384 | kstat_cpu(smp_processor_id()).irqs[EXTINT_VRT]++; | ||
385 | subcode = ext_int_code >> 16; | 384 | subcode = ext_int_code >> 16; |
386 | if ((subcode & 0xff00) != VIRTIO_SUBCODE_64) | 385 | if ((subcode & 0xff00) != VIRTIO_SUBCODE_64) |
387 | return; | 386 | return; |
387 | kstat_cpu(smp_processor_id()).irqs[EXTINT_VRT]++; | ||
388 | 388 | ||
389 | /* The LSB might be overloaded, we have to mask it */ | 389 | /* The LSB might be overloaded, we have to mask it */ |
390 | vq = (struct virtqueue *)(param64 & ~1UL); | 390 | vq = (struct virtqueue *)(param64 & ~1UL); |
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index e2d45c91b8e..9689d41c788 100644 --- a/drivers/scsi/qlogicpti.c +++ b/drivers/scsi/qlogicpti.c | |||
@@ -1292,8 +1292,10 @@ static struct scsi_host_template qpti_template = { | |||
1292 | .use_clustering = ENABLE_CLUSTERING, | 1292 | .use_clustering = ENABLE_CLUSTERING, |
1293 | }; | 1293 | }; |
1294 | 1294 | ||
1295 | static const struct of_device_id qpti_match[]; | ||
1295 | static int __devinit qpti_sbus_probe(struct platform_device *op) | 1296 | static int __devinit qpti_sbus_probe(struct platform_device *op) |
1296 | { | 1297 | { |
1298 | const struct of_device_id *match; | ||
1297 | struct scsi_host_template *tpnt; | 1299 | struct scsi_host_template *tpnt; |
1298 | struct device_node *dp = op->dev.of_node; | 1300 | struct device_node *dp = op->dev.of_node; |
1299 | struct Scsi_Host *host; | 1301 | struct Scsi_Host *host; |
@@ -1301,9 +1303,10 @@ static int __devinit qpti_sbus_probe(struct platform_device *op) | |||
1301 | static int nqptis; | 1303 | static int nqptis; |
1302 | const char *fcode; | 1304 | const char *fcode; |
1303 | 1305 | ||
1304 | if (!op->dev.of_match) | 1306 | match = of_match_device(qpti_match, &op->dev); |
1307 | if (!match) | ||
1305 | return -EINVAL; | 1308 | return -EINVAL; |
1306 | tpnt = op->dev.of_match->data; | 1309 | tpnt = match->data; |
1307 | 1310 | ||
1308 | /* Sometimes Antares cards come up not completely | 1311 | /* Sometimes Antares cards come up not completely |
1309 | * setup, and we get a report of a zero IRQ. | 1312 | * setup, and we get a report of a zero IRQ. |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index e9901b8f844..ec1803a4872 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -74,8 +74,6 @@ struct kmem_cache *scsi_sdb_cache; | |||
74 | */ | 74 | */ |
75 | #define SCSI_QUEUE_DELAY 3 | 75 | #define SCSI_QUEUE_DELAY 3 |
76 | 76 | ||
77 | static void scsi_run_queue(struct request_queue *q); | ||
78 | |||
79 | /* | 77 | /* |
80 | * Function: scsi_unprep_request() | 78 | * Function: scsi_unprep_request() |
81 | * | 79 | * |
@@ -161,7 +159,7 @@ static int __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy) | |||
161 | blk_requeue_request(q, cmd->request); | 159 | blk_requeue_request(q, cmd->request); |
162 | spin_unlock_irqrestore(q->queue_lock, flags); | 160 | spin_unlock_irqrestore(q->queue_lock, flags); |
163 | 161 | ||
164 | scsi_run_queue(q); | 162 | kblockd_schedule_work(q, &device->requeue_work); |
165 | 163 | ||
166 | return 0; | 164 | return 0; |
167 | } | 165 | } |
@@ -400,10 +398,15 @@ static inline int scsi_host_is_busy(struct Scsi_Host *shost) | |||
400 | static void scsi_run_queue(struct request_queue *q) | 398 | static void scsi_run_queue(struct request_queue *q) |
401 | { | 399 | { |
402 | struct scsi_device *sdev = q->queuedata; | 400 | struct scsi_device *sdev = q->queuedata; |
403 | struct Scsi_Host *shost = sdev->host; | 401 | struct Scsi_Host *shost; |
404 | LIST_HEAD(starved_list); | 402 | LIST_HEAD(starved_list); |
405 | unsigned long flags; | 403 | unsigned long flags; |
406 | 404 | ||
405 | /* if the device is dead, sdev will be NULL, so no queue to run */ | ||
406 | if (!sdev) | ||
407 | return; | ||
408 | |||
409 | shost = sdev->host; | ||
407 | if (scsi_target(sdev)->single_lun) | 410 | if (scsi_target(sdev)->single_lun) |
408 | scsi_single_lun_run(sdev); | 411 | scsi_single_lun_run(sdev); |
409 | 412 | ||
@@ -433,7 +436,11 @@ static void scsi_run_queue(struct request_queue *q) | |||
433 | continue; | 436 | continue; |
434 | } | 437 | } |
435 | 438 | ||
436 | blk_run_queue_async(sdev->request_queue); | 439 | spin_unlock(shost->host_lock); |
440 | spin_lock(sdev->request_queue->queue_lock); | ||
441 | __blk_run_queue(sdev->request_queue); | ||
442 | spin_unlock(sdev->request_queue->queue_lock); | ||
443 | spin_lock(shost->host_lock); | ||
437 | } | 444 | } |
438 | /* put any unprocessed entries back */ | 445 | /* put any unprocessed entries back */ |
439 | list_splice(&starved_list, &shost->starved_list); | 446 | list_splice(&starved_list, &shost->starved_list); |
@@ -442,6 +449,16 @@ static void scsi_run_queue(struct request_queue *q) | |||
442 | blk_run_queue(q); | 449 | blk_run_queue(q); |
443 | } | 450 | } |
444 | 451 | ||
452 | void scsi_requeue_run_queue(struct work_struct *work) | ||
453 | { | ||
454 | struct scsi_device *sdev; | ||
455 | struct request_queue *q; | ||
456 | |||
457 | sdev = container_of(work, struct scsi_device, requeue_work); | ||
458 | q = sdev->request_queue; | ||
459 | scsi_run_queue(q); | ||
460 | } | ||
461 | |||
445 | /* | 462 | /* |
446 | * Function: scsi_requeue_command() | 463 | * Function: scsi_requeue_command() |
447 | * | 464 | * |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 087821fac8f..58584dc0724 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -242,6 +242,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, | |||
242 | int display_failure_msg = 1, ret; | 242 | int display_failure_msg = 1, ret; |
243 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 243 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
244 | extern void scsi_evt_thread(struct work_struct *work); | 244 | extern void scsi_evt_thread(struct work_struct *work); |
245 | extern void scsi_requeue_run_queue(struct work_struct *work); | ||
245 | 246 | ||
246 | sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size, | 247 | sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size, |
247 | GFP_ATOMIC); | 248 | GFP_ATOMIC); |
@@ -264,6 +265,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, | |||
264 | INIT_LIST_HEAD(&sdev->event_list); | 265 | INIT_LIST_HEAD(&sdev->event_list); |
265 | spin_lock_init(&sdev->list_lock); | 266 | spin_lock_init(&sdev->list_lock); |
266 | INIT_WORK(&sdev->event_work, scsi_evt_thread); | 267 | INIT_WORK(&sdev->event_work, scsi_evt_thread); |
268 | INIT_WORK(&sdev->requeue_work, scsi_requeue_run_queue); | ||
267 | 269 | ||
268 | sdev->sdev_gendev.parent = get_device(&starget->dev); | 270 | sdev->sdev_gendev.parent = get_device(&starget->dev); |
269 | sdev->sdev_target = starget; | 271 | sdev->sdev_target = starget; |
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index eeb7dd43f9a..830822f86e4 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | |||
@@ -2288,7 +2288,3 @@ err_dev: | |||
2288 | free_netdev(dev); | 2288 | free_netdev(dev); |
2289 | return NULL; | 2289 | return NULL; |
2290 | } | 2290 | } |
2291 | |||
2292 | EXPORT_SYMBOL(init_ft1000_card); | ||
2293 | EXPORT_SYMBOL(stop_ft1000_card); | ||
2294 | EXPORT_SYMBOL(flarion_ft1000_cnt); | ||
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c index 935608e7200..bdfb1aec58d 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c | |||
@@ -214,6 +214,3 @@ void ft1000CleanupProc(struct net_device *dev) | |||
214 | remove_proc_entry(FT1000_PROC, init_net.proc_net); | 214 | remove_proc_entry(FT1000_PROC, init_net.proc_net); |
215 | unregister_netdevice_notifier(&ft1000_netdev_notifier); | 215 | unregister_netdevice_notifier(&ft1000_netdev_notifier); |
216 | } | 216 | } |
217 | |||
218 | EXPORT_SYMBOL(ft1000InitProc); | ||
219 | EXPORT_SYMBOL(ft1000CleanupProc); | ||
diff --git a/drivers/staging/gma500/Kconfig b/drivers/staging/gma500/Kconfig index 5501eb9b335..ce8bedaeaac 100644 --- a/drivers/staging/gma500/Kconfig +++ b/drivers/staging/gma500/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config DRM_PSB | 1 | config DRM_PSB |
2 | tristate "Intel GMA500 KMS Framebuffer" | 2 | tristate "Intel GMA500 KMS Framebuffer" |
3 | depends on DRM && PCI | 3 | depends on DRM && PCI && X86 |
4 | select FB_CFB_COPYAREA | 4 | select FB_CFB_COPYAREA |
5 | select FB_CFB_FILLRECT | 5 | select FB_CFB_FILLRECT |
6 | select FB_CFB_IMAGEBLIT | 6 | select FB_CFB_IMAGEBLIT |
diff --git a/drivers/staging/intel_sst/intelmid_v1_control.c b/drivers/staging/intel_sst/intelmid_v1_control.c index 9cc15c1c18d..1ea81421805 100644 --- a/drivers/staging/intel_sst/intelmid_v1_control.c +++ b/drivers/staging/intel_sst/intelmid_v1_control.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 28 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
29 | 29 | ||
30 | #include <linux/pci.h> | 30 | #include <linux/pci.h> |
31 | #include <linux/delay.h> | ||
31 | #include <linux/file.h> | 32 | #include <linux/file.h> |
32 | #include <asm/mrst.h> | 33 | #include <asm/mrst.h> |
33 | #include <sound/pcm.h> | 34 | #include <sound/pcm.h> |
diff --git a/drivers/staging/intel_sst/intelmid_v2_control.c b/drivers/staging/intel_sst/intelmid_v2_control.c index 26d815a67eb..3c6b3abff3c 100644 --- a/drivers/staging/intel_sst/intelmid_v2_control.c +++ b/drivers/staging/intel_sst/intelmid_v2_control.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 29 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
30 | 30 | ||
31 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
32 | #include <linux/delay.h> | ||
32 | #include <linux/file.h> | 33 | #include <linux/file.h> |
33 | #include "intel_sst.h" | 34 | #include "intel_sst.h" |
34 | #include "intelmid_snd_control.h" | 35 | #include "intelmid_snd_control.h" |
diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c index b5d21f6497f..22c04eabed4 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c +++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c | |||
@@ -12,6 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | #include <linux/cs5535.h> | 13 | #include <linux/cs5535.h> |
14 | #include <linux/gpio.h> | 14 | #include <linux/gpio.h> |
15 | #include <linux/delay.h> | ||
15 | #include <asm/olpc.h> | 16 | #include <asm/olpc.h> |
16 | 17 | ||
17 | #include "olpc_dcon.h" | 18 | #include "olpc_dcon.h" |
diff --git a/drivers/staging/rts_pstor/debug.h b/drivers/staging/rts_pstor/debug.h index e1408b0e7ae..ab305be96fb 100644 --- a/drivers/staging/rts_pstor/debug.h +++ b/drivers/staging/rts_pstor/debug.h | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #define RTSX_STOR "rts_pstor: " | 29 | #define RTSX_STOR "rts_pstor: " |
30 | 30 | ||
31 | #if CONFIG_RTS_PSTOR_DEBUG | 31 | #ifdef CONFIG_RTS_PSTOR_DEBUG |
32 | #define RTSX_DEBUGP(x...) printk(KERN_DEBUG RTSX_STOR x) | 32 | #define RTSX_DEBUGP(x...) printk(KERN_DEBUG RTSX_STOR x) |
33 | #define RTSX_DEBUGPN(x...) printk(KERN_DEBUG x) | 33 | #define RTSX_DEBUGPN(x...) printk(KERN_DEBUG x) |
34 | #define RTSX_DEBUGPX(x...) printk(x) | 34 | #define RTSX_DEBUGPX(x...) printk(x) |
diff --git a/drivers/staging/rts_pstor/ms.c b/drivers/staging/rts_pstor/ms.c index 810e170894f..d89795c6a3a 100644 --- a/drivers/staging/rts_pstor/ms.c +++ b/drivers/staging/rts_pstor/ms.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/blkdev.h> | 23 | #include <linux/blkdev.h> |
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
26 | #include <linux/vmalloc.h> | ||
26 | 27 | ||
27 | #include "rtsx.h" | 28 | #include "rtsx.h" |
28 | #include "rtsx_transport.h" | 29 | #include "rtsx_transport.h" |
diff --git a/drivers/staging/rts_pstor/rtsx_chip.c b/drivers/staging/rts_pstor/rtsx_chip.c index d2f1c715a68..4e60780ea80 100644 --- a/drivers/staging/rts_pstor/rtsx_chip.c +++ b/drivers/staging/rts_pstor/rtsx_chip.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
26 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
27 | #include <linux/vmalloc.h> | ||
27 | 28 | ||
28 | #include "rtsx.h" | 29 | #include "rtsx.h" |
29 | #include "rtsx_transport.h" | 30 | #include "rtsx_transport.h" |
@@ -1311,11 +1312,11 @@ void rtsx_polling_func(struct rtsx_chip *chip) | |||
1311 | 1312 | ||
1312 | #ifdef SUPPORT_OCP | 1313 | #ifdef SUPPORT_OCP |
1313 | if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) { | 1314 | if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) { |
1314 | #if CONFIG_RTS_PSTOR_DEBUG | 1315 | #ifdef CONFIG_RTS_PSTOR_DEBUG |
1315 | if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER | MS_OC_NOW | MS_OC_EVER)) { | 1316 | if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER | MS_OC_NOW | MS_OC_EVER)) { |
1316 | RTSX_DEBUGP("Over current, OCPSTAT is 0x%x\n", chip->ocp_stat); | 1317 | RTSX_DEBUGP("Over current, OCPSTAT is 0x%x\n", chip->ocp_stat); |
1317 | } | 1318 | } |
1318 | #endif | 1319 | #endif |
1319 | 1320 | ||
1320 | if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) { | 1321 | if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) { |
1321 | if (chip->card_exist & SD_CARD) { | 1322 | if (chip->card_exist & SD_CARD) { |
diff --git a/drivers/staging/rts_pstor/rtsx_scsi.c b/drivers/staging/rts_pstor/rtsx_scsi.c index 20c2464a20f..7de1fae443f 100644 --- a/drivers/staging/rts_pstor/rtsx_scsi.c +++ b/drivers/staging/rts_pstor/rtsx_scsi.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/blkdev.h> | 23 | #include <linux/blkdev.h> |
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
26 | #include <linux/vmalloc.h> | ||
26 | 27 | ||
27 | #include "rtsx.h" | 28 | #include "rtsx.h" |
28 | #include "rtsx_transport.h" | 29 | #include "rtsx_transport.h" |
diff --git a/drivers/staging/rts_pstor/sd.c b/drivers/staging/rts_pstor/sd.c index 8d066bd428c..b1277a6c7a8 100644 --- a/drivers/staging/rts_pstor/sd.c +++ b/drivers/staging/rts_pstor/sd.c | |||
@@ -909,7 +909,7 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir) | |||
909 | RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, PHASE_NOT_RESET); | 909 | RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, PHASE_NOT_RESET); |
910 | RTSX_WRITE_REG(chip, CLK_CTL, CHANGE_CLK, 0); | 910 | RTSX_WRITE_REG(chip, CLK_CTL, CHANGE_CLK, 0); |
911 | } else { | 911 | } else { |
912 | #if CONFIG_RTS_PSTOR_DEBUG | 912 | #ifdef CONFIG_RTS_PSTOR_DEBUG |
913 | rtsx_read_register(chip, SD_VP_CTL, &val); | 913 | rtsx_read_register(chip, SD_VP_CTL, &val); |
914 | RTSX_DEBUGP("SD_VP_CTL: 0x%x\n", val); | 914 | RTSX_DEBUGP("SD_VP_CTL: 0x%x\n", val); |
915 | rtsx_read_register(chip, SD_DCMPS_CTL, &val); | 915 | rtsx_read_register(chip, SD_DCMPS_CTL, &val); |
@@ -958,7 +958,7 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir) | |||
958 | return STATUS_SUCCESS; | 958 | return STATUS_SUCCESS; |
959 | 959 | ||
960 | Fail: | 960 | Fail: |
961 | #if CONFIG_RTS_PSTOR_DEBUG | 961 | #ifdef CONFIG_RTS_PSTOR_DEBUG |
962 | rtsx_read_register(chip, SD_VP_CTL, &val); | 962 | rtsx_read_register(chip, SD_VP_CTL, &val); |
963 | RTSX_DEBUGP("SD_VP_CTL: 0x%x\n", val); | 963 | RTSX_DEBUGP("SD_VP_CTL: 0x%x\n", val); |
964 | rtsx_read_register(chip, SD_DCMPS_CTL, &val); | 964 | rtsx_read_register(chip, SD_DCMPS_CTL, &val); |
diff --git a/drivers/staging/rts_pstor/trace.h b/drivers/staging/rts_pstor/trace.h index 2c668bae6ff..bc83b49a4eb 100644 --- a/drivers/staging/rts_pstor/trace.h +++ b/drivers/staging/rts_pstor/trace.h | |||
@@ -82,7 +82,7 @@ do { \ | |||
82 | #define TRACE_GOTO(chip, label) goto label | 82 | #define TRACE_GOTO(chip, label) goto label |
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | #if CONFIG_RTS_PSTOR_DEBUG | 85 | #ifdef CONFIG_RTS_PSTOR_DEBUG |
86 | static inline void rtsx_dump(u8 *buf, int buf_len) | 86 | static inline void rtsx_dump(u8 *buf, int buf_len) |
87 | { | 87 | { |
88 | int i; | 88 | int i; |
diff --git a/drivers/staging/rts_pstor/xd.c b/drivers/staging/rts_pstor/xd.c index 7bcd468b8f2..9f3add1e8f5 100644 --- a/drivers/staging/rts_pstor/xd.c +++ b/drivers/staging/rts_pstor/xd.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/blkdev.h> | 23 | #include <linux/blkdev.h> |
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
26 | #include <linux/vmalloc.h> | ||
26 | 27 | ||
27 | #include "rtsx.h" | 28 | #include "rtsx.h" |
28 | #include "rtsx_transport.h" | 29 | #include "rtsx_transport.h" |
diff --git a/drivers/staging/solo6x10/Kconfig b/drivers/staging/solo6x10/Kconfig index 2cf77c94086..03dcac4ea4d 100644 --- a/drivers/staging/solo6x10/Kconfig +++ b/drivers/staging/solo6x10/Kconfig | |||
@@ -2,6 +2,7 @@ config SOLO6X10 | |||
2 | tristate "Softlogic 6x10 MPEG codec cards" | 2 | tristate "Softlogic 6x10 MPEG codec cards" |
3 | depends on PCI && VIDEO_DEV && SND && I2C | 3 | depends on PCI && VIDEO_DEV && SND && I2C |
4 | select VIDEOBUF_DMA_SG | 4 | select VIDEOBUF_DMA_SG |
5 | select SND_PCM | ||
5 | ---help--- | 6 | ---help--- |
6 | This driver supports the Softlogic based MPEG-4 and h.264 codec | 7 | This driver supports the Softlogic based MPEG-4 and h.264 codec |
7 | codec cards. | 8 | codec cards. |
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 0f02a4b12ae..4f4f13321f4 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c | |||
@@ -876,8 +876,10 @@ static void vhci_shutdown_connection(struct usbip_device *ud) | |||
876 | } | 876 | } |
877 | 877 | ||
878 | /* kill threads related to this sdev, if v.c. exists */ | 878 | /* kill threads related to this sdev, if v.c. exists */ |
879 | kthread_stop(vdev->ud.tcp_rx); | 879 | if (vdev->ud.tcp_rx) |
880 | kthread_stop(vdev->ud.tcp_tx); | 880 | kthread_stop(vdev->ud.tcp_rx); |
881 | if (vdev->ud.tcp_tx) | ||
882 | kthread_stop(vdev->ud.tcp_tx); | ||
881 | 883 | ||
882 | usbip_uinfo("stop threads\n"); | 884 | usbip_uinfo("stop threads\n"); |
883 | 885 | ||
@@ -949,9 +951,6 @@ static void vhci_device_init(struct vhci_device *vdev) | |||
949 | { | 951 | { |
950 | memset(vdev, 0, sizeof(*vdev)); | 952 | memset(vdev, 0, sizeof(*vdev)); |
951 | 953 | ||
952 | vdev->ud.tcp_rx = kthread_create(vhci_rx_loop, &vdev->ud, "vhci_rx"); | ||
953 | vdev->ud.tcp_tx = kthread_create(vhci_tx_loop, &vdev->ud, "vhci_tx"); | ||
954 | |||
955 | vdev->ud.side = USBIP_VHCI; | 954 | vdev->ud.side = USBIP_VHCI; |
956 | vdev->ud.status = VDEV_ST_NULL; | 955 | vdev->ud.status = VDEV_ST_NULL; |
957 | /* vdev->ud.lock = SPIN_LOCK_UNLOCKED; */ | 956 | /* vdev->ud.lock = SPIN_LOCK_UNLOCKED; */ |
@@ -1139,7 +1138,7 @@ static int vhci_hcd_probe(struct platform_device *pdev) | |||
1139 | usbip_uerr("create hcd failed\n"); | 1138 | usbip_uerr("create hcd failed\n"); |
1140 | return -ENOMEM; | 1139 | return -ENOMEM; |
1141 | } | 1140 | } |
1142 | 1141 | hcd->has_tt = 1; | |
1143 | 1142 | ||
1144 | /* this is private data for vhci_hcd */ | 1143 | /* this is private data for vhci_hcd */ |
1145 | the_controller = hcd_to_vhci(hcd); | 1144 | the_controller = hcd_to_vhci(hcd); |
diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c index 3f2459f3041..e2dadbd5ef1 100644 --- a/drivers/staging/usbip/vhci_sysfs.c +++ b/drivers/staging/usbip/vhci_sysfs.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "vhci.h" | 21 | #include "vhci.h" |
22 | 22 | ||
23 | #include <linux/in.h> | 23 | #include <linux/in.h> |
24 | #include <linux/kthread.h> | ||
24 | 25 | ||
25 | /* TODO: refine locking ?*/ | 26 | /* TODO: refine locking ?*/ |
26 | 27 | ||
@@ -220,13 +221,13 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, | |||
220 | vdev->ud.tcp_socket = socket; | 221 | vdev->ud.tcp_socket = socket; |
221 | vdev->ud.status = VDEV_ST_NOTASSIGNED; | 222 | vdev->ud.status = VDEV_ST_NOTASSIGNED; |
222 | 223 | ||
223 | wake_up_process(vdev->ud.tcp_rx); | ||
224 | wake_up_process(vdev->ud.tcp_tx); | ||
225 | |||
226 | spin_unlock(&vdev->ud.lock); | 224 | spin_unlock(&vdev->ud.lock); |
227 | spin_unlock(&the_controller->lock); | 225 | spin_unlock(&the_controller->lock); |
228 | /* end the lock */ | 226 | /* end the lock */ |
229 | 227 | ||
228 | vdev->ud.tcp_rx = kthread_run(vhci_rx_loop, &vdev->ud, "vhci_rx"); | ||
229 | vdev->ud.tcp_tx = kthread_run(vhci_tx_loop, &vdev->ud, "vhci_tx"); | ||
230 | |||
230 | rh_port_connect(rhport, speed); | 231 | rh_port_connect(rhport, speed); |
231 | 232 | ||
232 | return count; | 233 | return count; |
diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 6a71f52c59b..76378397b76 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c | |||
@@ -273,7 +273,7 @@ exit: | |||
273 | } | 273 | } |
274 | 274 | ||
275 | int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, | 275 | int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, |
276 | u8 key_index) | 276 | u8 key_index, bool unicast, bool multicast) |
277 | { | 277 | { |
278 | wlandevice_t *wlandev = dev->ml_priv; | 278 | wlandevice_t *wlandev = dev->ml_priv; |
279 | 279 | ||
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c index 0e8eec516df..c911b2419ab 100644 --- a/drivers/tty/serial/of_serial.c +++ b/drivers/tty/serial/of_serial.c | |||
@@ -80,14 +80,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev, | |||
80 | /* | 80 | /* |
81 | * Try to register a serial port | 81 | * Try to register a serial port |
82 | */ | 82 | */ |
83 | static struct of_device_id of_platform_serial_table[]; | ||
83 | static int __devinit of_platform_serial_probe(struct platform_device *ofdev) | 84 | static int __devinit of_platform_serial_probe(struct platform_device *ofdev) |
84 | { | 85 | { |
86 | const struct of_device_id *match; | ||
85 | struct of_serial_info *info; | 87 | struct of_serial_info *info; |
86 | struct uart_port port; | 88 | struct uart_port port; |
87 | int port_type; | 89 | int port_type; |
88 | int ret; | 90 | int ret; |
89 | 91 | ||
90 | if (!ofdev->dev.of_match) | 92 | match = of_match_device(of_platform_serial_table, &ofdev->dev); |
93 | if (!match) | ||
91 | return -EINVAL; | 94 | return -EINVAL; |
92 | 95 | ||
93 | if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) | 96 | if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) |
@@ -97,7 +100,7 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev) | |||
97 | if (info == NULL) | 100 | if (info == NULL) |
98 | return -ENOMEM; | 101 | return -ENOMEM; |
99 | 102 | ||
100 | port_type = (unsigned long)ofdev->dev.of_match->data; | 103 | port_type = (unsigned long)match->data; |
101 | ret = of_platform_serial_setup(ofdev, port_type, &port); | 104 | ret = of_platform_serial_setup(ofdev, port_type, &port); |
102 | if (ret) | 105 | if (ret) |
103 | goto out; | 106 | goto out; |
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 36613b37c50..3a68e09309f 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c | |||
@@ -2539,15 +2539,18 @@ static void qe_udc_release(struct device *dev) | |||
2539 | } | 2539 | } |
2540 | 2540 | ||
2541 | /* Driver probe functions */ | 2541 | /* Driver probe functions */ |
2542 | static const struct of_device_id qe_udc_match[]; | ||
2542 | static int __devinit qe_udc_probe(struct platform_device *ofdev) | 2543 | static int __devinit qe_udc_probe(struct platform_device *ofdev) |
2543 | { | 2544 | { |
2545 | const struct of_device_id *match; | ||
2544 | struct device_node *np = ofdev->dev.of_node; | 2546 | struct device_node *np = ofdev->dev.of_node; |
2545 | struct qe_ep *ep; | 2547 | struct qe_ep *ep; |
2546 | unsigned int ret = 0; | 2548 | unsigned int ret = 0; |
2547 | unsigned int i; | 2549 | unsigned int i; |
2548 | const void *prop; | 2550 | const void *prop; |
2549 | 2551 | ||
2550 | if (!ofdev->dev.of_match) | 2552 | match = of_match_device(qe_udc_match, &ofdev->dev); |
2553 | if (!match) | ||
2551 | return -EINVAL; | 2554 | return -EINVAL; |
2552 | 2555 | ||
2553 | prop = of_get_property(np, "mode", NULL); | 2556 | prop = of_get_property(np, "mode", NULL); |
@@ -2561,7 +2564,7 @@ static int __devinit qe_udc_probe(struct platform_device *ofdev) | |||
2561 | return -ENOMEM; | 2564 | return -ENOMEM; |
2562 | } | 2565 | } |
2563 | 2566 | ||
2564 | udc_controller->soc_type = (unsigned long)ofdev->dev.of_match->data; | 2567 | udc_controller->soc_type = (unsigned long)match->data; |
2565 | udc_controller->usb_regs = of_iomap(np, 0); | 2568 | udc_controller->usb_regs = of_iomap(np, 0); |
2566 | if (!udc_controller->usb_regs) { | 2569 | if (!udc_controller->usb_regs) { |
2567 | ret = -ENOMEM; | 2570 | ret = -ENOMEM; |
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 7e41a95c5ce..627f3a67875 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/usb/ulpi.h> | 41 | #include <linux/usb/ulpi.h> |
42 | #include <plat/usb.h> | 42 | #include <plat/usb.h> |
43 | #include <linux/regulator/consumer.h> | ||
43 | 44 | ||
44 | /* EHCI Register Set */ | 45 | /* EHCI Register Set */ |
45 | #define EHCI_INSNREG04 (0xA0) | 46 | #define EHCI_INSNREG04 (0xA0) |
@@ -118,6 +119,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev) | |||
118 | struct ehci_hcd *omap_ehci; | 119 | struct ehci_hcd *omap_ehci; |
119 | int ret = -ENODEV; | 120 | int ret = -ENODEV; |
120 | int irq; | 121 | int irq; |
122 | int i; | ||
123 | char supply[7]; | ||
121 | 124 | ||
122 | if (usb_disabled()) | 125 | if (usb_disabled()) |
123 | return -ENODEV; | 126 | return -ENODEV; |
@@ -158,6 +161,23 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev) | |||
158 | hcd->rsrc_len = resource_size(res); | 161 | hcd->rsrc_len = resource_size(res); |
159 | hcd->regs = regs; | 162 | hcd->regs = regs; |
160 | 163 | ||
164 | /* get ehci regulator and enable */ | ||
165 | for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) { | ||
166 | if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) { | ||
167 | pdata->regulator[i] = NULL; | ||
168 | continue; | ||
169 | } | ||
170 | snprintf(supply, sizeof(supply), "hsusb%d", i); | ||
171 | pdata->regulator[i] = regulator_get(dev, supply); | ||
172 | if (IS_ERR(pdata->regulator[i])) { | ||
173 | pdata->regulator[i] = NULL; | ||
174 | dev_dbg(dev, | ||
175 | "failed to get ehci port%d regulator\n", i); | ||
176 | } else { | ||
177 | regulator_enable(pdata->regulator[i]); | ||
178 | } | ||
179 | } | ||
180 | |||
161 | ret = omap_usbhs_enable(dev); | 181 | ret = omap_usbhs_enable(dev); |
162 | if (ret) { | 182 | if (ret) { |
163 | dev_err(dev, "failed to start usbhs with err %d\n", ret); | 183 | dev_err(dev, "failed to start usbhs with err %d\n", ret); |
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index 795345ad45e..7b2e69aa2e9 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c | |||
@@ -1633,6 +1633,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1633 | ints[i].qh = NULL; | 1633 | ints[i].qh = NULL; |
1634 | ints[i].qtd = NULL; | 1634 | ints[i].qtd = NULL; |
1635 | 1635 | ||
1636 | urb->status = status; | ||
1636 | isp1760_urb_done(hcd, urb); | 1637 | isp1760_urb_done(hcd, urb); |
1637 | if (qtd) | 1638 | if (qtd) |
1638 | pe(hcd, qh, qtd); | 1639 | pe(hcd, qh, qtd); |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index a78f2ebd11b..73f75d26436 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -777,7 +777,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd) | |||
777 | if (t1 != t2) | 777 | if (t1 != t2) |
778 | xhci_writel(xhci, t2, port_array[port_index]); | 778 | xhci_writel(xhci, t2, port_array[port_index]); |
779 | 779 | ||
780 | if (DEV_HIGHSPEED(t1)) { | 780 | if (hcd->speed != HCD_USB3) { |
781 | /* enable remote wake up for USB 2.0 */ | 781 | /* enable remote wake up for USB 2.0 */ |
782 | u32 __iomem *addr; | 782 | u32 __iomem *addr; |
783 | u32 tmp; | 783 | u32 tmp; |
@@ -866,6 +866,21 @@ int xhci_bus_resume(struct usb_hcd *hcd) | |||
866 | temp |= PORT_LINK_STROBE | XDEV_U0; | 866 | temp |= PORT_LINK_STROBE | XDEV_U0; |
867 | xhci_writel(xhci, temp, port_array[port_index]); | 867 | xhci_writel(xhci, temp, port_array[port_index]); |
868 | } | 868 | } |
869 | /* wait for the port to enter U0 and report port link | ||
870 | * state change. | ||
871 | */ | ||
872 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
873 | msleep(20); | ||
874 | spin_lock_irqsave(&xhci->lock, flags); | ||
875 | |||
876 | /* Clear PLC */ | ||
877 | temp = xhci_readl(xhci, port_array[port_index]); | ||
878 | if (temp & PORT_PLC) { | ||
879 | temp = xhci_port_state_to_neutral(temp); | ||
880 | temp |= PORT_PLC; | ||
881 | xhci_writel(xhci, temp, port_array[port_index]); | ||
882 | } | ||
883 | |||
869 | slot_id = xhci_find_slot_id_by_port(hcd, | 884 | slot_id = xhci_find_slot_id_by_port(hcd, |
870 | xhci, port_index + 1); | 885 | xhci, port_index + 1); |
871 | if (slot_id) | 886 | if (slot_id) |
@@ -873,7 +888,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) | |||
873 | } else | 888 | } else |
874 | xhci_writel(xhci, temp, port_array[port_index]); | 889 | xhci_writel(xhci, temp, port_array[port_index]); |
875 | 890 | ||
876 | if (DEV_HIGHSPEED(temp)) { | 891 | if (hcd->speed != HCD_USB3) { |
877 | /* disable remote wake up for USB 2.0 */ | 892 | /* disable remote wake up for USB 2.0 */ |
878 | u32 __iomem *addr; | 893 | u32 __iomem *addr; |
879 | u32 tmp; | 894 | u32 tmp; |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 6dfbf9ffd7a..f47c20197c6 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -1887,11 +1887,9 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver, | |||
1887 | otg_set_vbus(musb->xceiv, 1); | 1887 | otg_set_vbus(musb->xceiv, 1); |
1888 | 1888 | ||
1889 | hcd->self.uses_pio_for_control = 1; | 1889 | hcd->self.uses_pio_for_control = 1; |
1890 | |||
1891 | if (musb->xceiv->last_event == USB_EVENT_NONE) | ||
1892 | pm_runtime_put(musb->controller); | ||
1893 | |||
1894 | } | 1890 | } |
1891 | if (musb->xceiv->last_event == USB_EVENT_NONE) | ||
1892 | pm_runtime_put(musb->controller); | ||
1895 | 1893 | ||
1896 | return 0; | 1894 | return 0; |
1897 | 1895 | ||
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 57a27fa954b..e9e60b6e058 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -270,7 +270,7 @@ static int musb_otg_notifications(struct notifier_block *nb, | |||
270 | DBG(4, "VBUS Disconnect\n"); | 270 | DBG(4, "VBUS Disconnect\n"); |
271 | 271 | ||
272 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC | 272 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC |
273 | if (is_otg_enabled(musb)) | 273 | if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) |
274 | if (musb->gadget_driver) | 274 | if (musb->gadget_driver) |
275 | #endif | 275 | #endif |
276 | { | 276 | { |
diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c index 82acb8dc4aa..6183a57eb69 100644 --- a/drivers/video/acornfb.c +++ b/drivers/video/acornfb.c | |||
@@ -66,7 +66,7 @@ | |||
66 | * have. Allow 1% either way on the nominal for TVs. | 66 | * have. Allow 1% either way on the nominal for TVs. |
67 | */ | 67 | */ |
68 | #define NR_MONTYPES 6 | 68 | #define NR_MONTYPES 6 |
69 | static struct fb_monspecs monspecs[NR_MONTYPES] __initdata = { | 69 | static struct fb_monspecs monspecs[NR_MONTYPES] __devinitdata = { |
70 | { /* TV */ | 70 | { /* TV */ |
71 | .hfmin = 15469, | 71 | .hfmin = 15469, |
72 | .hfmax = 15781, | 72 | .hfmax = 15781, |
@@ -873,7 +873,7 @@ static struct fb_ops acornfb_ops = { | |||
873 | /* | 873 | /* |
874 | * Everything after here is initialisation!!! | 874 | * Everything after here is initialisation!!! |
875 | */ | 875 | */ |
876 | static struct fb_videomode modedb[] __initdata = { | 876 | static struct fb_videomode modedb[] __devinitdata = { |
877 | { /* 320x256 @ 50Hz */ | 877 | { /* 320x256 @ 50Hz */ |
878 | NULL, 50, 320, 256, 125000, 92, 62, 35, 19, 38, 2, | 878 | NULL, 50, 320, 256, 125000, 92, 62, 35, 19, 38, 2, |
879 | FB_SYNC_COMP_HIGH_ACT, | 879 | FB_SYNC_COMP_HIGH_ACT, |
@@ -925,8 +925,7 @@ static struct fb_videomode modedb[] __initdata = { | |||
925 | } | 925 | } |
926 | }; | 926 | }; |
927 | 927 | ||
928 | static struct fb_videomode __initdata | 928 | static struct fb_videomode acornfb_default_mode __devinitdata = { |
929 | acornfb_default_mode = { | ||
930 | .name = NULL, | 929 | .name = NULL, |
931 | .refresh = 60, | 930 | .refresh = 60, |
932 | .xres = 640, | 931 | .xres = 640, |
@@ -942,7 +941,7 @@ acornfb_default_mode = { | |||
942 | .vmode = FB_VMODE_NONINTERLACED | 941 | .vmode = FB_VMODE_NONINTERLACED |
943 | }; | 942 | }; |
944 | 943 | ||
945 | static void __init acornfb_init_fbinfo(void) | 944 | static void __devinit acornfb_init_fbinfo(void) |
946 | { | 945 | { |
947 | static int first = 1; | 946 | static int first = 1; |
948 | 947 | ||
@@ -1018,8 +1017,7 @@ static void __init acornfb_init_fbinfo(void) | |||
1018 | * size can optionally be followed by 'M' or 'K' for | 1017 | * size can optionally be followed by 'M' or 'K' for |
1019 | * MB or KB respectively. | 1018 | * MB or KB respectively. |
1020 | */ | 1019 | */ |
1021 | static void __init | 1020 | static void __devinit acornfb_parse_mon(char *opt) |
1022 | acornfb_parse_mon(char *opt) | ||
1023 | { | 1021 | { |
1024 | char *p = opt; | 1022 | char *p = opt; |
1025 | 1023 | ||
@@ -1066,8 +1064,7 @@ bad: | |||
1066 | current_par.montype = -1; | 1064 | current_par.montype = -1; |
1067 | } | 1065 | } |
1068 | 1066 | ||
1069 | static void __init | 1067 | static void __devinit acornfb_parse_montype(char *opt) |
1070 | acornfb_parse_montype(char *opt) | ||
1071 | { | 1068 | { |
1072 | current_par.montype = -2; | 1069 | current_par.montype = -2; |
1073 | 1070 | ||
@@ -1108,8 +1105,7 @@ acornfb_parse_montype(char *opt) | |||
1108 | } | 1105 | } |
1109 | } | 1106 | } |
1110 | 1107 | ||
1111 | static void __init | 1108 | static void __devinit acornfb_parse_dram(char *opt) |
1112 | acornfb_parse_dram(char *opt) | ||
1113 | { | 1109 | { |
1114 | unsigned int size; | 1110 | unsigned int size; |
1115 | 1111 | ||
@@ -1134,15 +1130,14 @@ acornfb_parse_dram(char *opt) | |||
1134 | static struct options { | 1130 | static struct options { |
1135 | char *name; | 1131 | char *name; |
1136 | void (*parse)(char *opt); | 1132 | void (*parse)(char *opt); |
1137 | } opt_table[] __initdata = { | 1133 | } opt_table[] __devinitdata = { |
1138 | { "mon", acornfb_parse_mon }, | 1134 | { "mon", acornfb_parse_mon }, |
1139 | { "montype", acornfb_parse_montype }, | 1135 | { "montype", acornfb_parse_montype }, |
1140 | { "dram", acornfb_parse_dram }, | 1136 | { "dram", acornfb_parse_dram }, |
1141 | { NULL, NULL } | 1137 | { NULL, NULL } |
1142 | }; | 1138 | }; |
1143 | 1139 | ||
1144 | int __init | 1140 | static int __devinit acornfb_setup(char *options) |
1145 | acornfb_setup(char *options) | ||
1146 | { | 1141 | { |
1147 | struct options *optp; | 1142 | struct options *optp; |
1148 | char *opt; | 1143 | char *opt; |
@@ -1179,8 +1174,7 @@ acornfb_setup(char *options) | |||
1179 | * Detect type of monitor connected | 1174 | * Detect type of monitor connected |
1180 | * For now, we just assume SVGA | 1175 | * For now, we just assume SVGA |
1181 | */ | 1176 | */ |
1182 | static int __init | 1177 | static int __devinit acornfb_detect_monitortype(void) |
1183 | acornfb_detect_monitortype(void) | ||
1184 | { | 1178 | { |
1185 | return 4; | 1179 | return 4; |
1186 | } | 1180 | } |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index e0c2284924b..5aac00eb183 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -42,9 +42,34 @@ | |||
42 | 42 | ||
43 | #define FBPIXMAPSIZE (1024 * 8) | 43 | #define FBPIXMAPSIZE (1024 * 8) |
44 | 44 | ||
45 | static DEFINE_MUTEX(registration_lock); | ||
45 | struct fb_info *registered_fb[FB_MAX] __read_mostly; | 46 | struct fb_info *registered_fb[FB_MAX] __read_mostly; |
46 | int num_registered_fb __read_mostly; | 47 | int num_registered_fb __read_mostly; |
47 | 48 | ||
49 | static struct fb_info *get_fb_info(unsigned int idx) | ||
50 | { | ||
51 | struct fb_info *fb_info; | ||
52 | |||
53 | if (idx >= FB_MAX) | ||
54 | return ERR_PTR(-ENODEV); | ||
55 | |||
56 | mutex_lock(®istration_lock); | ||
57 | fb_info = registered_fb[idx]; | ||
58 | if (fb_info) | ||
59 | atomic_inc(&fb_info->count); | ||
60 | mutex_unlock(®istration_lock); | ||
61 | |||
62 | return fb_info; | ||
63 | } | ||
64 | |||
65 | static void put_fb_info(struct fb_info *fb_info) | ||
66 | { | ||
67 | if (!atomic_dec_and_test(&fb_info->count)) | ||
68 | return; | ||
69 | if (fb_info->fbops->fb_destroy) | ||
70 | fb_info->fbops->fb_destroy(fb_info); | ||
71 | } | ||
72 | |||
48 | int lock_fb_info(struct fb_info *info) | 73 | int lock_fb_info(struct fb_info *info) |
49 | { | 74 | { |
50 | mutex_lock(&info->lock); | 75 | mutex_lock(&info->lock); |
@@ -647,6 +672,7 @@ int fb_show_logo(struct fb_info *info, int rotate) { return 0; } | |||
647 | 672 | ||
648 | static void *fb_seq_start(struct seq_file *m, loff_t *pos) | 673 | static void *fb_seq_start(struct seq_file *m, loff_t *pos) |
649 | { | 674 | { |
675 | mutex_lock(®istration_lock); | ||
650 | return (*pos < FB_MAX) ? pos : NULL; | 676 | return (*pos < FB_MAX) ? pos : NULL; |
651 | } | 677 | } |
652 | 678 | ||
@@ -658,6 +684,7 @@ static void *fb_seq_next(struct seq_file *m, void *v, loff_t *pos) | |||
658 | 684 | ||
659 | static void fb_seq_stop(struct seq_file *m, void *v) | 685 | static void fb_seq_stop(struct seq_file *m, void *v) |
660 | { | 686 | { |
687 | mutex_unlock(®istration_lock); | ||
661 | } | 688 | } |
662 | 689 | ||
663 | static int fb_seq_show(struct seq_file *m, void *v) | 690 | static int fb_seq_show(struct seq_file *m, void *v) |
@@ -690,13 +717,30 @@ static const struct file_operations fb_proc_fops = { | |||
690 | .release = seq_release, | 717 | .release = seq_release, |
691 | }; | 718 | }; |
692 | 719 | ||
693 | static ssize_t | 720 | /* |
694 | fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | 721 | * We hold a reference to the fb_info in file->private_data, |
722 | * but if the current registered fb has changed, we don't | ||
723 | * actually want to use it. | ||
724 | * | ||
725 | * So look up the fb_info using the inode minor number, | ||
726 | * and just verify it against the reference we have. | ||
727 | */ | ||
728 | static struct fb_info *file_fb_info(struct file *file) | ||
695 | { | 729 | { |
696 | unsigned long p = *ppos; | ||
697 | struct inode *inode = file->f_path.dentry->d_inode; | 730 | struct inode *inode = file->f_path.dentry->d_inode; |
698 | int fbidx = iminor(inode); | 731 | int fbidx = iminor(inode); |
699 | struct fb_info *info = registered_fb[fbidx]; | 732 | struct fb_info *info = registered_fb[fbidx]; |
733 | |||
734 | if (info != file->private_data) | ||
735 | info = NULL; | ||
736 | return info; | ||
737 | } | ||
738 | |||
739 | static ssize_t | ||
740 | fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | ||
741 | { | ||
742 | unsigned long p = *ppos; | ||
743 | struct fb_info *info = file_fb_info(file); | ||
700 | u8 *buffer, *dst; | 744 | u8 *buffer, *dst; |
701 | u8 __iomem *src; | 745 | u8 __iomem *src; |
702 | int c, cnt = 0, err = 0; | 746 | int c, cnt = 0, err = 0; |
@@ -761,9 +805,7 @@ static ssize_t | |||
761 | fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | 805 | fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) |
762 | { | 806 | { |
763 | unsigned long p = *ppos; | 807 | unsigned long p = *ppos; |
764 | struct inode *inode = file->f_path.dentry->d_inode; | 808 | struct fb_info *info = file_fb_info(file); |
765 | int fbidx = iminor(inode); | ||
766 | struct fb_info *info = registered_fb[fbidx]; | ||
767 | u8 *buffer, *src; | 809 | u8 *buffer, *src; |
768 | u8 __iomem *dst; | 810 | u8 __iomem *dst; |
769 | int c, cnt = 0, err = 0; | 811 | int c, cnt = 0, err = 0; |
@@ -1141,10 +1183,10 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, | |||
1141 | 1183 | ||
1142 | static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 1184 | static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
1143 | { | 1185 | { |
1144 | struct inode *inode = file->f_path.dentry->d_inode; | 1186 | struct fb_info *info = file_fb_info(file); |
1145 | int fbidx = iminor(inode); | ||
1146 | struct fb_info *info = registered_fb[fbidx]; | ||
1147 | 1187 | ||
1188 | if (!info) | ||
1189 | return -ENODEV; | ||
1148 | return do_fb_ioctl(info, cmd, arg); | 1190 | return do_fb_ioctl(info, cmd, arg); |
1149 | } | 1191 | } |
1150 | 1192 | ||
@@ -1265,12 +1307,13 @@ static int fb_get_fscreeninfo(struct fb_info *info, unsigned int cmd, | |||
1265 | static long fb_compat_ioctl(struct file *file, unsigned int cmd, | 1307 | static long fb_compat_ioctl(struct file *file, unsigned int cmd, |
1266 | unsigned long arg) | 1308 | unsigned long arg) |
1267 | { | 1309 | { |
1268 | struct inode *inode = file->f_path.dentry->d_inode; | 1310 | struct fb_info *info = file_fb_info(file); |
1269 | int fbidx = iminor(inode); | 1311 | struct fb_ops *fb; |
1270 | struct fb_info *info = registered_fb[fbidx]; | ||
1271 | struct fb_ops *fb = info->fbops; | ||
1272 | long ret = -ENOIOCTLCMD; | 1312 | long ret = -ENOIOCTLCMD; |
1273 | 1313 | ||
1314 | if (!info) | ||
1315 | return -ENODEV; | ||
1316 | fb = info->fbops; | ||
1274 | switch(cmd) { | 1317 | switch(cmd) { |
1275 | case FBIOGET_VSCREENINFO: | 1318 | case FBIOGET_VSCREENINFO: |
1276 | case FBIOPUT_VSCREENINFO: | 1319 | case FBIOPUT_VSCREENINFO: |
@@ -1303,16 +1346,18 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd, | |||
1303 | static int | 1346 | static int |
1304 | fb_mmap(struct file *file, struct vm_area_struct * vma) | 1347 | fb_mmap(struct file *file, struct vm_area_struct * vma) |
1305 | { | 1348 | { |
1306 | int fbidx = iminor(file->f_path.dentry->d_inode); | 1349 | struct fb_info *info = file_fb_info(file); |
1307 | struct fb_info *info = registered_fb[fbidx]; | 1350 | struct fb_ops *fb; |
1308 | struct fb_ops *fb = info->fbops; | ||
1309 | unsigned long off; | 1351 | unsigned long off; |
1310 | unsigned long start; | 1352 | unsigned long start; |
1311 | u32 len; | 1353 | u32 len; |
1312 | 1354 | ||
1355 | if (!info) | ||
1356 | return -ENODEV; | ||
1313 | if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) | 1357 | if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) |
1314 | return -EINVAL; | 1358 | return -EINVAL; |
1315 | off = vma->vm_pgoff << PAGE_SHIFT; | 1359 | off = vma->vm_pgoff << PAGE_SHIFT; |
1360 | fb = info->fbops; | ||
1316 | if (!fb) | 1361 | if (!fb) |
1317 | return -ENODEV; | 1362 | return -ENODEV; |
1318 | mutex_lock(&info->mm_lock); | 1363 | mutex_lock(&info->mm_lock); |
@@ -1361,14 +1406,16 @@ __releases(&info->lock) | |||
1361 | struct fb_info *info; | 1406 | struct fb_info *info; |
1362 | int res = 0; | 1407 | int res = 0; |
1363 | 1408 | ||
1364 | if (fbidx >= FB_MAX) | 1409 | info = get_fb_info(fbidx); |
1365 | return -ENODEV; | 1410 | if (!info) { |
1366 | info = registered_fb[fbidx]; | ||
1367 | if (!info) | ||
1368 | request_module("fb%d", fbidx); | 1411 | request_module("fb%d", fbidx); |
1369 | info = registered_fb[fbidx]; | 1412 | info = get_fb_info(fbidx); |
1370 | if (!info) | 1413 | if (!info) |
1371 | return -ENODEV; | 1414 | return -ENODEV; |
1415 | } | ||
1416 | if (IS_ERR(info)) | ||
1417 | return PTR_ERR(info); | ||
1418 | |||
1372 | mutex_lock(&info->lock); | 1419 | mutex_lock(&info->lock); |
1373 | if (!try_module_get(info->fbops->owner)) { | 1420 | if (!try_module_get(info->fbops->owner)) { |
1374 | res = -ENODEV; | 1421 | res = -ENODEV; |
@@ -1386,6 +1433,8 @@ __releases(&info->lock) | |||
1386 | #endif | 1433 | #endif |
1387 | out: | 1434 | out: |
1388 | mutex_unlock(&info->lock); | 1435 | mutex_unlock(&info->lock); |
1436 | if (res) | ||
1437 | put_fb_info(info); | ||
1389 | return res; | 1438 | return res; |
1390 | } | 1439 | } |
1391 | 1440 | ||
@@ -1401,6 +1450,7 @@ __releases(&info->lock) | |||
1401 | info->fbops->fb_release(info,1); | 1450 | info->fbops->fb_release(info,1); |
1402 | module_put(info->fbops->owner); | 1451 | module_put(info->fbops->owner); |
1403 | mutex_unlock(&info->lock); | 1452 | mutex_unlock(&info->lock); |
1453 | put_fb_info(info); | ||
1404 | return 0; | 1454 | return 0; |
1405 | } | 1455 | } |
1406 | 1456 | ||
@@ -1487,8 +1537,10 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena, | |||
1487 | return false; | 1537 | return false; |
1488 | } | 1538 | } |
1489 | 1539 | ||
1540 | static int do_unregister_framebuffer(struct fb_info *fb_info); | ||
1541 | |||
1490 | #define VGA_FB_PHYS 0xA0000 | 1542 | #define VGA_FB_PHYS 0xA0000 |
1491 | void remove_conflicting_framebuffers(struct apertures_struct *a, | 1543 | static void do_remove_conflicting_framebuffers(struct apertures_struct *a, |
1492 | const char *name, bool primary) | 1544 | const char *name, bool primary) |
1493 | { | 1545 | { |
1494 | int i; | 1546 | int i; |
@@ -1510,43 +1562,32 @@ void remove_conflicting_framebuffers(struct apertures_struct *a, | |||
1510 | printk(KERN_INFO "fb: conflicting fb hw usage " | 1562 | printk(KERN_INFO "fb: conflicting fb hw usage " |
1511 | "%s vs %s - removing generic driver\n", | 1563 | "%s vs %s - removing generic driver\n", |
1512 | name, registered_fb[i]->fix.id); | 1564 | name, registered_fb[i]->fix.id); |
1513 | unregister_framebuffer(registered_fb[i]); | 1565 | do_unregister_framebuffer(registered_fb[i]); |
1514 | } | 1566 | } |
1515 | } | 1567 | } |
1516 | } | 1568 | } |
1517 | EXPORT_SYMBOL(remove_conflicting_framebuffers); | ||
1518 | 1569 | ||
1519 | /** | 1570 | static int do_register_framebuffer(struct fb_info *fb_info) |
1520 | * register_framebuffer - registers a frame buffer device | ||
1521 | * @fb_info: frame buffer info structure | ||
1522 | * | ||
1523 | * Registers a frame buffer device @fb_info. | ||
1524 | * | ||
1525 | * Returns negative errno on error, or zero for success. | ||
1526 | * | ||
1527 | */ | ||
1528 | |||
1529 | int | ||
1530 | register_framebuffer(struct fb_info *fb_info) | ||
1531 | { | 1571 | { |
1532 | int i; | 1572 | int i; |
1533 | struct fb_event event; | 1573 | struct fb_event event; |
1534 | struct fb_videomode mode; | 1574 | struct fb_videomode mode; |
1535 | 1575 | ||
1536 | if (num_registered_fb == FB_MAX) | ||
1537 | return -ENXIO; | ||
1538 | |||
1539 | if (fb_check_foreignness(fb_info)) | 1576 | if (fb_check_foreignness(fb_info)) |
1540 | return -ENOSYS; | 1577 | return -ENOSYS; |
1541 | 1578 | ||
1542 | remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id, | 1579 | do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id, |
1543 | fb_is_primary_device(fb_info)); | 1580 | fb_is_primary_device(fb_info)); |
1544 | 1581 | ||
1582 | if (num_registered_fb == FB_MAX) | ||
1583 | return -ENXIO; | ||
1584 | |||
1545 | num_registered_fb++; | 1585 | num_registered_fb++; |
1546 | for (i = 0 ; i < FB_MAX; i++) | 1586 | for (i = 0 ; i < FB_MAX; i++) |
1547 | if (!registered_fb[i]) | 1587 | if (!registered_fb[i]) |
1548 | break; | 1588 | break; |
1549 | fb_info->node = i; | 1589 | fb_info->node = i; |
1590 | atomic_set(&fb_info->count, 1); | ||
1550 | mutex_init(&fb_info->lock); | 1591 | mutex_init(&fb_info->lock); |
1551 | mutex_init(&fb_info->mm_lock); | 1592 | mutex_init(&fb_info->mm_lock); |
1552 | 1593 | ||
@@ -1592,36 +1633,14 @@ register_framebuffer(struct fb_info *fb_info) | |||
1592 | return 0; | 1633 | return 0; |
1593 | } | 1634 | } |
1594 | 1635 | ||
1595 | 1636 | static int do_unregister_framebuffer(struct fb_info *fb_info) | |
1596 | /** | ||
1597 | * unregister_framebuffer - releases a frame buffer device | ||
1598 | * @fb_info: frame buffer info structure | ||
1599 | * | ||
1600 | * Unregisters a frame buffer device @fb_info. | ||
1601 | * | ||
1602 | * Returns negative errno on error, or zero for success. | ||
1603 | * | ||
1604 | * This function will also notify the framebuffer console | ||
1605 | * to release the driver. | ||
1606 | * | ||
1607 | * This is meant to be called within a driver's module_exit() | ||
1608 | * function. If this is called outside module_exit(), ensure | ||
1609 | * that the driver implements fb_open() and fb_release() to | ||
1610 | * check that no processes are using the device. | ||
1611 | */ | ||
1612 | |||
1613 | int | ||
1614 | unregister_framebuffer(struct fb_info *fb_info) | ||
1615 | { | 1637 | { |
1616 | struct fb_event event; | 1638 | struct fb_event event; |
1617 | int i, ret = 0; | 1639 | int i, ret = 0; |
1618 | 1640 | ||
1619 | i = fb_info->node; | 1641 | i = fb_info->node; |
1620 | if (!registered_fb[i]) { | 1642 | if (i < 0 || i >= FB_MAX || registered_fb[i] != fb_info) |
1621 | ret = -EINVAL; | 1643 | return -EINVAL; |
1622 | goto done; | ||
1623 | } | ||
1624 | |||
1625 | 1644 | ||
1626 | if (!lock_fb_info(fb_info)) | 1645 | if (!lock_fb_info(fb_info)) |
1627 | return -ENODEV; | 1646 | return -ENODEV; |
@@ -1629,16 +1648,14 @@ unregister_framebuffer(struct fb_info *fb_info) | |||
1629 | ret = fb_notifier_call_chain(FB_EVENT_FB_UNBIND, &event); | 1648 | ret = fb_notifier_call_chain(FB_EVENT_FB_UNBIND, &event); |
1630 | unlock_fb_info(fb_info); | 1649 | unlock_fb_info(fb_info); |
1631 | 1650 | ||
1632 | if (ret) { | 1651 | if (ret) |
1633 | ret = -EINVAL; | 1652 | return -EINVAL; |
1634 | goto done; | ||
1635 | } | ||
1636 | 1653 | ||
1637 | if (fb_info->pixmap.addr && | 1654 | if (fb_info->pixmap.addr && |
1638 | (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT)) | 1655 | (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT)) |
1639 | kfree(fb_info->pixmap.addr); | 1656 | kfree(fb_info->pixmap.addr); |
1640 | fb_destroy_modelist(&fb_info->modelist); | 1657 | fb_destroy_modelist(&fb_info->modelist); |
1641 | registered_fb[i]=NULL; | 1658 | registered_fb[i] = NULL; |
1642 | num_registered_fb--; | 1659 | num_registered_fb--; |
1643 | fb_cleanup_device(fb_info); | 1660 | fb_cleanup_device(fb_info); |
1644 | device_destroy(fb_class, MKDEV(FB_MAJOR, i)); | 1661 | device_destroy(fb_class, MKDEV(FB_MAJOR, i)); |
@@ -1646,9 +1663,65 @@ unregister_framebuffer(struct fb_info *fb_info) | |||
1646 | fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event); | 1663 | fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event); |
1647 | 1664 | ||
1648 | /* this may free fb info */ | 1665 | /* this may free fb info */ |
1649 | if (fb_info->fbops->fb_destroy) | 1666 | put_fb_info(fb_info); |
1650 | fb_info->fbops->fb_destroy(fb_info); | 1667 | return 0; |
1651 | done: | 1668 | } |
1669 | |||
1670 | void remove_conflicting_framebuffers(struct apertures_struct *a, | ||
1671 | const char *name, bool primary) | ||
1672 | { | ||
1673 | mutex_lock(®istration_lock); | ||
1674 | do_remove_conflicting_framebuffers(a, name, primary); | ||
1675 | mutex_unlock(®istration_lock); | ||
1676 | } | ||
1677 | EXPORT_SYMBOL(remove_conflicting_framebuffers); | ||
1678 | |||
1679 | /** | ||
1680 | * register_framebuffer - registers a frame buffer device | ||
1681 | * @fb_info: frame buffer info structure | ||
1682 | * | ||
1683 | * Registers a frame buffer device @fb_info. | ||
1684 | * | ||
1685 | * Returns negative errno on error, or zero for success. | ||
1686 | * | ||
1687 | */ | ||
1688 | int | ||
1689 | register_framebuffer(struct fb_info *fb_info) | ||
1690 | { | ||
1691 | int ret; | ||
1692 | |||
1693 | mutex_lock(®istration_lock); | ||
1694 | ret = do_register_framebuffer(fb_info); | ||
1695 | mutex_unlock(®istration_lock); | ||
1696 | |||
1697 | return ret; | ||
1698 | } | ||
1699 | |||
1700 | /** | ||
1701 | * unregister_framebuffer - releases a frame buffer device | ||
1702 | * @fb_info: frame buffer info structure | ||
1703 | * | ||
1704 | * Unregisters a frame buffer device @fb_info. | ||
1705 | * | ||
1706 | * Returns negative errno on error, or zero for success. | ||
1707 | * | ||
1708 | * This function will also notify the framebuffer console | ||
1709 | * to release the driver. | ||
1710 | * | ||
1711 | * This is meant to be called within a driver's module_exit() | ||
1712 | * function. If this is called outside module_exit(), ensure | ||
1713 | * that the driver implements fb_open() and fb_release() to | ||
1714 | * check that no processes are using the device. | ||
1715 | */ | ||
1716 | int | ||
1717 | unregister_framebuffer(struct fb_info *fb_info) | ||
1718 | { | ||
1719 | int ret; | ||
1720 | |||
1721 | mutex_lock(®istration_lock); | ||
1722 | ret = do_unregister_framebuffer(fb_info); | ||
1723 | mutex_unlock(®istration_lock); | ||
1724 | |||
1652 | return ret; | 1725 | return ret; |
1653 | } | 1726 | } |
1654 | 1727 | ||
diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c index 528bceb220f..eed5436ffb5 100644 --- a/drivers/watchdog/mpc8xxx_wdt.c +++ b/drivers/watchdog/mpc8xxx_wdt.c | |||
@@ -185,17 +185,20 @@ static struct miscdevice mpc8xxx_wdt_miscdev = { | |||
185 | .fops = &mpc8xxx_wdt_fops, | 185 | .fops = &mpc8xxx_wdt_fops, |
186 | }; | 186 | }; |
187 | 187 | ||
188 | static const struct of_device_id mpc8xxx_wdt_match[]; | ||
188 | static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev) | 189 | static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev) |
189 | { | 190 | { |
190 | int ret; | 191 | int ret; |
192 | const struct of_device_id *match; | ||
191 | struct device_node *np = ofdev->dev.of_node; | 193 | struct device_node *np = ofdev->dev.of_node; |
192 | struct mpc8xxx_wdt_type *wdt_type; | 194 | struct mpc8xxx_wdt_type *wdt_type; |
193 | u32 freq = fsl_get_sys_freq(); | 195 | u32 freq = fsl_get_sys_freq(); |
194 | bool enabled; | 196 | bool enabled; |
195 | 197 | ||
196 | if (!ofdev->dev.of_match) | 198 | match = of_match_device(mpc8xxx_wdt_match, &ofdev->dev); |
199 | if (!match) | ||
197 | return -EINVAL; | 200 | return -EINVAL; |
198 | wdt_type = ofdev->dev.of_match->data; | 201 | wdt_type = match->data; |
199 | 202 | ||
200 | if (!freq || freq == -1) | 203 | if (!freq || freq == -1) |
201 | return -EINVAL; | 204 | return -EINVAL; |
diff --git a/fs/block_dev.c b/fs/block_dev.c index 5147bdd3b8e..257b00e9842 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1102,6 +1102,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1102 | if (!bdev->bd_part) | 1102 | if (!bdev->bd_part) |
1103 | goto out_clear; | 1103 | goto out_clear; |
1104 | 1104 | ||
1105 | ret = 0; | ||
1105 | if (disk->fops->open) { | 1106 | if (disk->fops->open) { |
1106 | ret = disk->fops->open(bdev, mode); | 1107 | ret = disk->fops->open(bdev, mode); |
1107 | if (ret == -ERESTARTSYS) { | 1108 | if (ret == -ERESTARTSYS) { |
@@ -1118,9 +1119,18 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1118 | put_disk(disk); | 1119 | put_disk(disk); |
1119 | goto restart; | 1120 | goto restart; |
1120 | } | 1121 | } |
1121 | if (ret) | ||
1122 | goto out_clear; | ||
1123 | } | 1122 | } |
1123 | /* | ||
1124 | * If the device is invalidated, rescan partition | ||
1125 | * if open succeeded or failed with -ENOMEDIUM. | ||
1126 | * The latter is necessary to prevent ghost | ||
1127 | * partitions on a removed medium. | ||
1128 | */ | ||
1129 | if (bdev->bd_invalidated && (!ret || ret == -ENOMEDIUM)) | ||
1130 | rescan_partitions(disk, bdev); | ||
1131 | if (ret) | ||
1132 | goto out_clear; | ||
1133 | |||
1124 | if (!bdev->bd_openers) { | 1134 | if (!bdev->bd_openers) { |
1125 | bd_set_size(bdev,(loff_t)get_capacity(disk)<<9); | 1135 | bd_set_size(bdev,(loff_t)get_capacity(disk)<<9); |
1126 | bdi = blk_get_backing_dev_info(bdev); | 1136 | bdi = blk_get_backing_dev_info(bdev); |
@@ -1128,8 +1138,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1128 | bdi = &default_backing_dev_info; | 1138 | bdi = &default_backing_dev_info; |
1129 | bdev_inode_switch_bdi(bdev->bd_inode, bdi); | 1139 | bdev_inode_switch_bdi(bdev->bd_inode, bdi); |
1130 | } | 1140 | } |
1131 | if (bdev->bd_invalidated) | ||
1132 | rescan_partitions(disk, bdev); | ||
1133 | } else { | 1141 | } else { |
1134 | struct block_device *whole; | 1142 | struct block_device *whole; |
1135 | whole = bdget_disk(disk, 0); | 1143 | whole = bdget_disk(disk, 0); |
@@ -1153,13 +1161,14 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1153 | } | 1161 | } |
1154 | } else { | 1162 | } else { |
1155 | if (bdev->bd_contains == bdev) { | 1163 | if (bdev->bd_contains == bdev) { |
1156 | if (bdev->bd_disk->fops->open) { | 1164 | ret = 0; |
1165 | if (bdev->bd_disk->fops->open) | ||
1157 | ret = bdev->bd_disk->fops->open(bdev, mode); | 1166 | ret = bdev->bd_disk->fops->open(bdev, mode); |
1158 | if (ret) | 1167 | /* the same as first opener case, read comment there */ |
1159 | goto out_unlock_bdev; | 1168 | if (bdev->bd_invalidated && (!ret || ret == -ENOMEDIUM)) |
1160 | } | ||
1161 | if (bdev->bd_invalidated) | ||
1162 | rescan_partitions(bdev->bd_disk, bdev); | 1169 | rescan_partitions(bdev->bd_disk, bdev); |
1170 | if (ret) | ||
1171 | goto out_unlock_bdev; | ||
1163 | } | 1172 | } |
1164 | /* only one opener holds refs to the module and disk */ | 1173 | /* only one opener holds refs to the module and disk */ |
1165 | module_put(disk->fops->owner); | 1174 | module_put(disk->fops->owner); |
diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile index 31610ea73ae..a8411c22313 100644 --- a/fs/btrfs/Makefile +++ b/fs/btrfs/Makefile | |||
@@ -7,4 +7,4 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \ | |||
7 | extent_map.o sysfs.o struct-funcs.o xattr.o ordered-data.o \ | 7 | extent_map.o sysfs.o struct-funcs.o xattr.o ordered-data.o \ |
8 | extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \ | 8 | extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \ |
9 | export.o tree-log.o acl.o free-space-cache.o zlib.o lzo.o \ | 9 | export.o tree-log.o acl.o free-space-cache.o zlib.o lzo.o \ |
10 | compression.o delayed-ref.o relocation.o | 10 | compression.o delayed-ref.o relocation.o delayed-inode.o |
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 1a21c99a91b..f66fc995973 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
@@ -178,12 +178,13 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, | |||
178 | 178 | ||
179 | if (value) { | 179 | if (value) { |
180 | acl = posix_acl_from_xattr(value, size); | 180 | acl = posix_acl_from_xattr(value, size); |
181 | if (IS_ERR(acl)) | ||
182 | return PTR_ERR(acl); | ||
183 | |||
181 | if (acl) { | 184 | if (acl) { |
182 | ret = posix_acl_valid(acl); | 185 | ret = posix_acl_valid(acl); |
183 | if (ret) | 186 | if (ret) |
184 | goto out; | 187 | goto out; |
185 | } else if (IS_ERR(acl)) { | ||
186 | return PTR_ERR(acl); | ||
187 | } | 188 | } |
188 | } | 189 | } |
189 | 190 | ||
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 57c3bb2884c..d0b0e43a6a8 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "extent_map.h" | 22 | #include "extent_map.h" |
23 | #include "extent_io.h" | 23 | #include "extent_io.h" |
24 | #include "ordered-data.h" | 24 | #include "ordered-data.h" |
25 | #include "delayed-inode.h" | ||
25 | 26 | ||
26 | /* in memory btrfs inode */ | 27 | /* in memory btrfs inode */ |
27 | struct btrfs_inode { | 28 | struct btrfs_inode { |
@@ -158,14 +159,27 @@ struct btrfs_inode { | |||
158 | */ | 159 | */ |
159 | unsigned force_compress:4; | 160 | unsigned force_compress:4; |
160 | 161 | ||
162 | struct btrfs_delayed_node *delayed_node; | ||
163 | |||
161 | struct inode vfs_inode; | 164 | struct inode vfs_inode; |
162 | }; | 165 | }; |
163 | 166 | ||
167 | extern unsigned char btrfs_filetype_table[]; | ||
168 | |||
164 | static inline struct btrfs_inode *BTRFS_I(struct inode *inode) | 169 | static inline struct btrfs_inode *BTRFS_I(struct inode *inode) |
165 | { | 170 | { |
166 | return container_of(inode, struct btrfs_inode, vfs_inode); | 171 | return container_of(inode, struct btrfs_inode, vfs_inode); |
167 | } | 172 | } |
168 | 173 | ||
174 | static inline u64 btrfs_ino(struct inode *inode) | ||
175 | { | ||
176 | u64 ino = BTRFS_I(inode)->location.objectid; | ||
177 | |||
178 | if (ino <= BTRFS_FIRST_FREE_OBJECTID) | ||
179 | ino = inode->i_ino; | ||
180 | return ino; | ||
181 | } | ||
182 | |||
169 | static inline void btrfs_i_size_write(struct inode *inode, u64 size) | 183 | static inline void btrfs_i_size_write(struct inode *inode, u64 size) |
170 | { | 184 | { |
171 | i_size_write(inode, size); | 185 | i_size_write(inode, size); |
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index d4cd0f0cd69..bfe42b03eaf 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c | |||
@@ -125,9 +125,10 @@ static int check_compressed_csum(struct inode *inode, | |||
125 | kunmap_atomic(kaddr, KM_USER0); | 125 | kunmap_atomic(kaddr, KM_USER0); |
126 | 126 | ||
127 | if (csum != *cb_sum) { | 127 | if (csum != *cb_sum) { |
128 | printk(KERN_INFO "btrfs csum failed ino %lu " | 128 | printk(KERN_INFO "btrfs csum failed ino %llu " |
129 | "extent %llu csum %u " | 129 | "extent %llu csum %u " |
130 | "wanted %u mirror %d\n", inode->i_ino, | 130 | "wanted %u mirror %d\n", |
131 | (unsigned long long)btrfs_ino(inode), | ||
131 | (unsigned long long)disk_start, | 132 | (unsigned long long)disk_start, |
132 | csum, *cb_sum, cb->mirror_num); | 133 | csum, *cb_sum, cb->mirror_num); |
133 | ret = -EIO; | 134 | ret = -EIO; |
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index fad8f23d70f..b6cbeed226b 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -38,11 +38,6 @@ static int balance_node_right(struct btrfs_trans_handle *trans, | |||
38 | struct extent_buffer *src_buf); | 38 | struct extent_buffer *src_buf); |
39 | static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 39 | static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
40 | struct btrfs_path *path, int level, int slot); | 40 | struct btrfs_path *path, int level, int slot); |
41 | static int setup_items_for_insert(struct btrfs_trans_handle *trans, | ||
42 | struct btrfs_root *root, struct btrfs_path *path, | ||
43 | struct btrfs_key *cpu_key, u32 *data_size, | ||
44 | u32 total_data, u32 total_size, int nr); | ||
45 | |||
46 | 41 | ||
47 | struct btrfs_path *btrfs_alloc_path(void) | 42 | struct btrfs_path *btrfs_alloc_path(void) |
48 | { | 43 | { |
@@ -74,8 +69,8 @@ noinline void btrfs_set_path_blocking(struct btrfs_path *p) | |||
74 | * retake all the spinlocks in the path. You can safely use NULL | 69 | * retake all the spinlocks in the path. You can safely use NULL |
75 | * for held | 70 | * for held |
76 | */ | 71 | */ |
77 | static noinline void btrfs_clear_path_blocking(struct btrfs_path *p, | 72 | noinline void btrfs_clear_path_blocking(struct btrfs_path *p, |
78 | struct extent_buffer *held) | 73 | struct extent_buffer *held) |
79 | { | 74 | { |
80 | int i; | 75 | int i; |
81 | 76 | ||
@@ -3559,11 +3554,10 @@ out: | |||
3559 | * to save stack depth by doing the bulk of the work in a function | 3554 | * to save stack depth by doing the bulk of the work in a function |
3560 | * that doesn't call btrfs_search_slot | 3555 | * that doesn't call btrfs_search_slot |
3561 | */ | 3556 | */ |
3562 | static noinline_for_stack int | 3557 | int setup_items_for_insert(struct btrfs_trans_handle *trans, |
3563 | setup_items_for_insert(struct btrfs_trans_handle *trans, | 3558 | struct btrfs_root *root, struct btrfs_path *path, |
3564 | struct btrfs_root *root, struct btrfs_path *path, | 3559 | struct btrfs_key *cpu_key, u32 *data_size, |
3565 | struct btrfs_key *cpu_key, u32 *data_size, | 3560 | u32 total_data, u32 total_size, int nr) |
3566 | u32 total_data, u32 total_size, int nr) | ||
3567 | { | 3561 | { |
3568 | struct btrfs_item *item; | 3562 | struct btrfs_item *item; |
3569 | int i; | 3563 | int i; |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 343304dec6d..e7d40791ec9 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -105,6 +105,12 @@ struct btrfs_ordered_sum; | |||
105 | /* For storing free space cache */ | 105 | /* For storing free space cache */ |
106 | #define BTRFS_FREE_SPACE_OBJECTID -11ULL | 106 | #define BTRFS_FREE_SPACE_OBJECTID -11ULL |
107 | 107 | ||
108 | /* | ||
109 | * The inode number assigned to the special inode for sotring | ||
110 | * free ino cache | ||
111 | */ | ||
112 | #define BTRFS_FREE_INO_OBJECTID -12ULL | ||
113 | |||
108 | /* dummy objectid represents multiple objectids */ | 114 | /* dummy objectid represents multiple objectids */ |
109 | #define BTRFS_MULTIPLE_OBJECTIDS -255ULL | 115 | #define BTRFS_MULTIPLE_OBJECTIDS -255ULL |
110 | 116 | ||
@@ -830,9 +836,6 @@ struct btrfs_block_group_cache { | |||
830 | u64 bytes_super; | 836 | u64 bytes_super; |
831 | u64 flags; | 837 | u64 flags; |
832 | u64 sectorsize; | 838 | u64 sectorsize; |
833 | int extents_thresh; | ||
834 | int free_extents; | ||
835 | int total_bitmaps; | ||
836 | unsigned int ro:1; | 839 | unsigned int ro:1; |
837 | unsigned int dirty:1; | 840 | unsigned int dirty:1; |
838 | unsigned int iref:1; | 841 | unsigned int iref:1; |
@@ -847,9 +850,7 @@ struct btrfs_block_group_cache { | |||
847 | struct btrfs_space_info *space_info; | 850 | struct btrfs_space_info *space_info; |
848 | 851 | ||
849 | /* free space cache stuff */ | 852 | /* free space cache stuff */ |
850 | spinlock_t tree_lock; | 853 | struct btrfs_free_space_ctl *free_space_ctl; |
851 | struct rb_root free_space_offset; | ||
852 | u64 free_space; | ||
853 | 854 | ||
854 | /* block group cache stuff */ | 855 | /* block group cache stuff */ |
855 | struct rb_node cache_node; | 856 | struct rb_node cache_node; |
@@ -869,6 +870,7 @@ struct btrfs_block_group_cache { | |||
869 | struct reloc_control; | 870 | struct reloc_control; |
870 | struct btrfs_device; | 871 | struct btrfs_device; |
871 | struct btrfs_fs_devices; | 872 | struct btrfs_fs_devices; |
873 | struct btrfs_delayed_root; | ||
872 | struct btrfs_fs_info { | 874 | struct btrfs_fs_info { |
873 | u8 fsid[BTRFS_FSID_SIZE]; | 875 | u8 fsid[BTRFS_FSID_SIZE]; |
874 | u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; | 876 | u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; |
@@ -895,7 +897,10 @@ struct btrfs_fs_info { | |||
895 | /* logical->physical extent mapping */ | 897 | /* logical->physical extent mapping */ |
896 | struct btrfs_mapping_tree mapping_tree; | 898 | struct btrfs_mapping_tree mapping_tree; |
897 | 899 | ||
898 | /* block reservation for extent, checksum and root tree */ | 900 | /* |
901 | * block reservation for extent, checksum, root tree and | ||
902 | * delayed dir index item | ||
903 | */ | ||
899 | struct btrfs_block_rsv global_block_rsv; | 904 | struct btrfs_block_rsv global_block_rsv; |
900 | /* block reservation for delay allocation */ | 905 | /* block reservation for delay allocation */ |
901 | struct btrfs_block_rsv delalloc_block_rsv; | 906 | struct btrfs_block_rsv delalloc_block_rsv; |
@@ -1022,6 +1027,7 @@ struct btrfs_fs_info { | |||
1022 | * for the sys_munmap function call path | 1027 | * for the sys_munmap function call path |
1023 | */ | 1028 | */ |
1024 | struct btrfs_workers fixup_workers; | 1029 | struct btrfs_workers fixup_workers; |
1030 | struct btrfs_workers delayed_workers; | ||
1025 | struct task_struct *transaction_kthread; | 1031 | struct task_struct *transaction_kthread; |
1026 | struct task_struct *cleaner_kthread; | 1032 | struct task_struct *cleaner_kthread; |
1027 | int thread_pool_size; | 1033 | int thread_pool_size; |
@@ -1079,6 +1085,8 @@ struct btrfs_fs_info { | |||
1079 | 1085 | ||
1080 | /* filesystem state */ | 1086 | /* filesystem state */ |
1081 | u64 fs_state; | 1087 | u64 fs_state; |
1088 | |||
1089 | struct btrfs_delayed_root *delayed_root; | ||
1082 | }; | 1090 | }; |
1083 | 1091 | ||
1084 | /* | 1092 | /* |
@@ -1107,6 +1115,16 @@ struct btrfs_root { | |||
1107 | spinlock_t accounting_lock; | 1115 | spinlock_t accounting_lock; |
1108 | struct btrfs_block_rsv *block_rsv; | 1116 | struct btrfs_block_rsv *block_rsv; |
1109 | 1117 | ||
1118 | /* free ino cache stuff */ | ||
1119 | struct mutex fs_commit_mutex; | ||
1120 | struct btrfs_free_space_ctl *free_ino_ctl; | ||
1121 | enum btrfs_caching_type cached; | ||
1122 | spinlock_t cache_lock; | ||
1123 | wait_queue_head_t cache_wait; | ||
1124 | struct btrfs_free_space_ctl *free_ino_pinned; | ||
1125 | u64 cache_progress; | ||
1126 | struct inode *cache_inode; | ||
1127 | |||
1110 | struct mutex log_mutex; | 1128 | struct mutex log_mutex; |
1111 | wait_queue_head_t log_writer_wait; | 1129 | wait_queue_head_t log_writer_wait; |
1112 | wait_queue_head_t log_commit_wait[2]; | 1130 | wait_queue_head_t log_commit_wait[2]; |
@@ -1162,6 +1180,11 @@ struct btrfs_root { | |||
1162 | struct rb_root inode_tree; | 1180 | struct rb_root inode_tree; |
1163 | 1181 | ||
1164 | /* | 1182 | /* |
1183 | * radix tree that keeps track of delayed nodes of every inode, | ||
1184 | * protected by inode_lock | ||
1185 | */ | ||
1186 | struct radix_tree_root delayed_nodes_tree; | ||
1187 | /* | ||
1165 | * right now this just gets used so that a root has its own devid | 1188 | * right now this just gets used so that a root has its own devid |
1166 | * for stat. It may be used for more later | 1189 | * for stat. It may be used for more later |
1167 | */ | 1190 | */ |
@@ -2034,6 +2057,13 @@ static inline bool btrfs_mixed_space_info(struct btrfs_space_info *space_info) | |||
2034 | } | 2057 | } |
2035 | 2058 | ||
2036 | /* extent-tree.c */ | 2059 | /* extent-tree.c */ |
2060 | static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root, | ||
2061 | int num_items) | ||
2062 | { | ||
2063 | return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) * | ||
2064 | 3 * num_items; | ||
2065 | } | ||
2066 | |||
2037 | void btrfs_put_block_group(struct btrfs_block_group_cache *cache); | 2067 | void btrfs_put_block_group(struct btrfs_block_group_cache *cache); |
2038 | int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, | 2068 | int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, |
2039 | struct btrfs_root *root, unsigned long count); | 2069 | struct btrfs_root *root, unsigned long count); |
@@ -2226,6 +2256,8 @@ void btrfs_release_path(struct btrfs_path *p); | |||
2226 | struct btrfs_path *btrfs_alloc_path(void); | 2256 | struct btrfs_path *btrfs_alloc_path(void); |
2227 | void btrfs_free_path(struct btrfs_path *p); | 2257 | void btrfs_free_path(struct btrfs_path *p); |
2228 | void btrfs_set_path_blocking(struct btrfs_path *p); | 2258 | void btrfs_set_path_blocking(struct btrfs_path *p); |
2259 | void btrfs_clear_path_blocking(struct btrfs_path *p, | ||
2260 | struct extent_buffer *held); | ||
2229 | void btrfs_unlock_up_safe(struct btrfs_path *p, int level); | 2261 | void btrfs_unlock_up_safe(struct btrfs_path *p, int level); |
2230 | 2262 | ||
2231 | int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 2263 | int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
@@ -2237,6 +2269,10 @@ static inline int btrfs_del_item(struct btrfs_trans_handle *trans, | |||
2237 | return btrfs_del_items(trans, root, path, path->slots[0], 1); | 2269 | return btrfs_del_items(trans, root, path, path->slots[0], 1); |
2238 | } | 2270 | } |
2239 | 2271 | ||
2272 | int setup_items_for_insert(struct btrfs_trans_handle *trans, | ||
2273 | struct btrfs_root *root, struct btrfs_path *path, | ||
2274 | struct btrfs_key *cpu_key, u32 *data_size, | ||
2275 | u32 total_data, u32 total_size, int nr); | ||
2240 | int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root | 2276 | int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root |
2241 | *root, struct btrfs_key *key, void *data, u32 data_size); | 2277 | *root, struct btrfs_key *key, void *data, u32 data_size); |
2242 | int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, | 2278 | int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, |
@@ -2293,7 +2329,7 @@ void btrfs_check_and_init_root_item(struct btrfs_root_item *item); | |||
2293 | /* dir-item.c */ | 2329 | /* dir-item.c */ |
2294 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, | 2330 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, |
2295 | struct btrfs_root *root, const char *name, | 2331 | struct btrfs_root *root, const char *name, |
2296 | int name_len, u64 dir, | 2332 | int name_len, struct inode *dir, |
2297 | struct btrfs_key *location, u8 type, u64 index); | 2333 | struct btrfs_key *location, u8 type, u64 index); |
2298 | struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, | 2334 | struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, |
2299 | struct btrfs_root *root, | 2335 | struct btrfs_root *root, |
@@ -2338,12 +2374,6 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans, | |||
2338 | struct btrfs_root *root, u64 offset); | 2374 | struct btrfs_root *root, u64 offset); |
2339 | int btrfs_find_orphan_item(struct btrfs_root *root, u64 offset); | 2375 | int btrfs_find_orphan_item(struct btrfs_root *root, u64 offset); |
2340 | 2376 | ||
2341 | /* inode-map.c */ | ||
2342 | int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, | ||
2343 | struct btrfs_root *fs_root, | ||
2344 | u64 dirid, u64 *objectid); | ||
2345 | int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid); | ||
2346 | |||
2347 | /* inode-item.c */ | 2377 | /* inode-item.c */ |
2348 | int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, | 2378 | int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, |
2349 | struct btrfs_root *root, | 2379 | struct btrfs_root *root, |
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c new file mode 100644 index 00000000000..01e29503a54 --- /dev/null +++ b/fs/btrfs/delayed-inode.c | |||
@@ -0,0 +1,1695 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Fujitsu. All rights reserved. | ||
3 | * Written by Miao Xie <miaox@cn.fujitsu.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License v2 as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public | ||
15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | * Boston, MA 021110-1307, USA. | ||
18 | */ | ||
19 | |||
20 | #include <linux/slab.h> | ||
21 | #include "delayed-inode.h" | ||
22 | #include "disk-io.h" | ||
23 | #include "transaction.h" | ||
24 | |||
25 | #define BTRFS_DELAYED_WRITEBACK 400 | ||
26 | #define BTRFS_DELAYED_BACKGROUND 100 | ||
27 | |||
28 | static struct kmem_cache *delayed_node_cache; | ||
29 | |||
30 | int __init btrfs_delayed_inode_init(void) | ||
31 | { | ||
32 | delayed_node_cache = kmem_cache_create("delayed_node", | ||
33 | sizeof(struct btrfs_delayed_node), | ||
34 | 0, | ||
35 | SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, | ||
36 | NULL); | ||
37 | if (!delayed_node_cache) | ||
38 | return -ENOMEM; | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | void btrfs_delayed_inode_exit(void) | ||
43 | { | ||
44 | if (delayed_node_cache) | ||
45 | kmem_cache_destroy(delayed_node_cache); | ||
46 | } | ||
47 | |||
48 | static inline void btrfs_init_delayed_node( | ||
49 | struct btrfs_delayed_node *delayed_node, | ||
50 | struct btrfs_root *root, u64 inode_id) | ||
51 | { | ||
52 | delayed_node->root = root; | ||
53 | delayed_node->inode_id = inode_id; | ||
54 | atomic_set(&delayed_node->refs, 0); | ||
55 | delayed_node->count = 0; | ||
56 | delayed_node->in_list = 0; | ||
57 | delayed_node->inode_dirty = 0; | ||
58 | delayed_node->ins_root = RB_ROOT; | ||
59 | delayed_node->del_root = RB_ROOT; | ||
60 | mutex_init(&delayed_node->mutex); | ||
61 | delayed_node->index_cnt = 0; | ||
62 | INIT_LIST_HEAD(&delayed_node->n_list); | ||
63 | INIT_LIST_HEAD(&delayed_node->p_list); | ||
64 | delayed_node->bytes_reserved = 0; | ||
65 | } | ||
66 | |||
67 | static inline int btrfs_is_continuous_delayed_item( | ||
68 | struct btrfs_delayed_item *item1, | ||
69 | struct btrfs_delayed_item *item2) | ||
70 | { | ||
71 | if (item1->key.type == BTRFS_DIR_INDEX_KEY && | ||
72 | item1->key.objectid == item2->key.objectid && | ||
73 | item1->key.type == item2->key.type && | ||
74 | item1->key.offset + 1 == item2->key.offset) | ||
75 | return 1; | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static inline struct btrfs_delayed_root *btrfs_get_delayed_root( | ||
80 | struct btrfs_root *root) | ||
81 | { | ||
82 | return root->fs_info->delayed_root; | ||
83 | } | ||
84 | |||
85 | static struct btrfs_delayed_node *btrfs_get_or_create_delayed_node( | ||
86 | struct inode *inode) | ||
87 | { | ||
88 | struct btrfs_delayed_node *node; | ||
89 | struct btrfs_inode *btrfs_inode = BTRFS_I(inode); | ||
90 | struct btrfs_root *root = btrfs_inode->root; | ||
91 | u64 ino = btrfs_ino(inode); | ||
92 | int ret; | ||
93 | |||
94 | again: | ||
95 | node = ACCESS_ONCE(btrfs_inode->delayed_node); | ||
96 | if (node) { | ||
97 | atomic_inc(&node->refs); /* can be accessed */ | ||
98 | return node; | ||
99 | } | ||
100 | |||
101 | spin_lock(&root->inode_lock); | ||
102 | node = radix_tree_lookup(&root->delayed_nodes_tree, ino); | ||
103 | if (node) { | ||
104 | if (btrfs_inode->delayed_node) { | ||
105 | spin_unlock(&root->inode_lock); | ||
106 | goto again; | ||
107 | } | ||
108 | btrfs_inode->delayed_node = node; | ||
109 | atomic_inc(&node->refs); /* can be accessed */ | ||
110 | atomic_inc(&node->refs); /* cached in the inode */ | ||
111 | spin_unlock(&root->inode_lock); | ||
112 | return node; | ||
113 | } | ||
114 | spin_unlock(&root->inode_lock); | ||
115 | |||
116 | node = kmem_cache_alloc(delayed_node_cache, GFP_NOFS); | ||
117 | if (!node) | ||
118 | return ERR_PTR(-ENOMEM); | ||
119 | btrfs_init_delayed_node(node, root, ino); | ||
120 | |||
121 | atomic_inc(&node->refs); /* cached in the btrfs inode */ | ||
122 | atomic_inc(&node->refs); /* can be accessed */ | ||
123 | |||
124 | ret = radix_tree_preload(GFP_NOFS & ~__GFP_HIGHMEM); | ||
125 | if (ret) { | ||
126 | kmem_cache_free(delayed_node_cache, node); | ||
127 | return ERR_PTR(ret); | ||
128 | } | ||
129 | |||
130 | spin_lock(&root->inode_lock); | ||
131 | ret = radix_tree_insert(&root->delayed_nodes_tree, ino, node); | ||
132 | if (ret == -EEXIST) { | ||
133 | kmem_cache_free(delayed_node_cache, node); | ||
134 | spin_unlock(&root->inode_lock); | ||
135 | radix_tree_preload_end(); | ||
136 | goto again; | ||
137 | } | ||
138 | btrfs_inode->delayed_node = node; | ||
139 | spin_unlock(&root->inode_lock); | ||
140 | radix_tree_preload_end(); | ||
141 | |||
142 | return node; | ||
143 | } | ||
144 | |||
145 | /* | ||
146 | * Call it when holding delayed_node->mutex | ||
147 | * | ||
148 | * If mod = 1, add this node into the prepared list. | ||
149 | */ | ||
150 | static void btrfs_queue_delayed_node(struct btrfs_delayed_root *root, | ||
151 | struct btrfs_delayed_node *node, | ||
152 | int mod) | ||
153 | { | ||
154 | spin_lock(&root->lock); | ||
155 | if (node->in_list) { | ||
156 | if (!list_empty(&node->p_list)) | ||
157 | list_move_tail(&node->p_list, &root->prepare_list); | ||
158 | else if (mod) | ||
159 | list_add_tail(&node->p_list, &root->prepare_list); | ||
160 | } else { | ||
161 | list_add_tail(&node->n_list, &root->node_list); | ||
162 | list_add_tail(&node->p_list, &root->prepare_list); | ||
163 | atomic_inc(&node->refs); /* inserted into list */ | ||
164 | root->nodes++; | ||
165 | node->in_list = 1; | ||
166 | } | ||
167 | spin_unlock(&root->lock); | ||
168 | } | ||
169 | |||
170 | /* Call it when holding delayed_node->mutex */ | ||
171 | static void btrfs_dequeue_delayed_node(struct btrfs_delayed_root *root, | ||
172 | struct btrfs_delayed_node *node) | ||
173 | { | ||
174 | spin_lock(&root->lock); | ||
175 | if (node->in_list) { | ||
176 | root->nodes--; | ||
177 | atomic_dec(&node->refs); /* not in the list */ | ||
178 | list_del_init(&node->n_list); | ||
179 | if (!list_empty(&node->p_list)) | ||
180 | list_del_init(&node->p_list); | ||
181 | node->in_list = 0; | ||
182 | } | ||
183 | spin_unlock(&root->lock); | ||
184 | } | ||
185 | |||
186 | struct btrfs_delayed_node *btrfs_first_delayed_node( | ||
187 | struct btrfs_delayed_root *delayed_root) | ||
188 | { | ||
189 | struct list_head *p; | ||
190 | struct btrfs_delayed_node *node = NULL; | ||
191 | |||
192 | spin_lock(&delayed_root->lock); | ||
193 | if (list_empty(&delayed_root->node_list)) | ||
194 | goto out; | ||
195 | |||
196 | p = delayed_root->node_list.next; | ||
197 | node = list_entry(p, struct btrfs_delayed_node, n_list); | ||
198 | atomic_inc(&node->refs); | ||
199 | out: | ||
200 | spin_unlock(&delayed_root->lock); | ||
201 | |||
202 | return node; | ||
203 | } | ||
204 | |||
205 | struct btrfs_delayed_node *btrfs_next_delayed_node( | ||
206 | struct btrfs_delayed_node *node) | ||
207 | { | ||
208 | struct btrfs_delayed_root *delayed_root; | ||
209 | struct list_head *p; | ||
210 | struct btrfs_delayed_node *next = NULL; | ||
211 | |||
212 | delayed_root = node->root->fs_info->delayed_root; | ||
213 | spin_lock(&delayed_root->lock); | ||
214 | if (!node->in_list) { /* not in the list */ | ||
215 | if (list_empty(&delayed_root->node_list)) | ||
216 | goto out; | ||
217 | p = delayed_root->node_list.next; | ||
218 | } else if (list_is_last(&node->n_list, &delayed_root->node_list)) | ||
219 | goto out; | ||
220 | else | ||
221 | p = node->n_list.next; | ||
222 | |||
223 | next = list_entry(p, struct btrfs_delayed_node, n_list); | ||
224 | atomic_inc(&next->refs); | ||
225 | out: | ||
226 | spin_unlock(&delayed_root->lock); | ||
227 | |||
228 | return next; | ||
229 | } | ||
230 | |||
231 | static void __btrfs_release_delayed_node( | ||
232 | struct btrfs_delayed_node *delayed_node, | ||
233 | int mod) | ||
234 | { | ||
235 | struct btrfs_delayed_root *delayed_root; | ||
236 | |||
237 | if (!delayed_node) | ||
238 | return; | ||
239 | |||
240 | delayed_root = delayed_node->root->fs_info->delayed_root; | ||
241 | |||
242 | mutex_lock(&delayed_node->mutex); | ||
243 | if (delayed_node->count) | ||
244 | btrfs_queue_delayed_node(delayed_root, delayed_node, mod); | ||
245 | else | ||
246 | btrfs_dequeue_delayed_node(delayed_root, delayed_node); | ||
247 | mutex_unlock(&delayed_node->mutex); | ||
248 | |||
249 | if (atomic_dec_and_test(&delayed_node->refs)) { | ||
250 | struct btrfs_root *root = delayed_node->root; | ||
251 | spin_lock(&root->inode_lock); | ||
252 | if (atomic_read(&delayed_node->refs) == 0) { | ||
253 | radix_tree_delete(&root->delayed_nodes_tree, | ||
254 | delayed_node->inode_id); | ||
255 | kmem_cache_free(delayed_node_cache, delayed_node); | ||
256 | } | ||
257 | spin_unlock(&root->inode_lock); | ||
258 | } | ||
259 | } | ||
260 | |||
261 | static inline void btrfs_release_delayed_node(struct btrfs_delayed_node *node) | ||
262 | { | ||
263 | __btrfs_release_delayed_node(node, 0); | ||
264 | } | ||
265 | |||
266 | struct btrfs_delayed_node *btrfs_first_prepared_delayed_node( | ||
267 | struct btrfs_delayed_root *delayed_root) | ||
268 | { | ||
269 | struct list_head *p; | ||
270 | struct btrfs_delayed_node *node = NULL; | ||
271 | |||
272 | spin_lock(&delayed_root->lock); | ||
273 | if (list_empty(&delayed_root->prepare_list)) | ||
274 | goto out; | ||
275 | |||
276 | p = delayed_root->prepare_list.next; | ||
277 | list_del_init(p); | ||
278 | node = list_entry(p, struct btrfs_delayed_node, p_list); | ||
279 | atomic_inc(&node->refs); | ||
280 | out: | ||
281 | spin_unlock(&delayed_root->lock); | ||
282 | |||
283 | return node; | ||
284 | } | ||
285 | |||
286 | static inline void btrfs_release_prepared_delayed_node( | ||
287 | struct btrfs_delayed_node *node) | ||
288 | { | ||
289 | __btrfs_release_delayed_node(node, 1); | ||
290 | } | ||
291 | |||
292 | struct btrfs_delayed_item *btrfs_alloc_delayed_item(u32 data_len) | ||
293 | { | ||
294 | struct btrfs_delayed_item *item; | ||
295 | item = kmalloc(sizeof(*item) + data_len, GFP_NOFS); | ||
296 | if (item) { | ||
297 | item->data_len = data_len; | ||
298 | item->ins_or_del = 0; | ||
299 | item->bytes_reserved = 0; | ||
300 | item->block_rsv = NULL; | ||
301 | item->delayed_node = NULL; | ||
302 | atomic_set(&item->refs, 1); | ||
303 | } | ||
304 | return item; | ||
305 | } | ||
306 | |||
307 | /* | ||
308 | * __btrfs_lookup_delayed_item - look up the delayed item by key | ||
309 | * @delayed_node: pointer to the delayed node | ||
310 | * @key: the key to look up | ||
311 | * @prev: used to store the prev item if the right item isn't found | ||
312 | * @next: used to store the next item if the right item isn't found | ||
313 | * | ||
314 | * Note: if we don't find the right item, we will return the prev item and | ||
315 | * the next item. | ||
316 | */ | ||
317 | static struct btrfs_delayed_item *__btrfs_lookup_delayed_item( | ||
318 | struct rb_root *root, | ||
319 | struct btrfs_key *key, | ||
320 | struct btrfs_delayed_item **prev, | ||
321 | struct btrfs_delayed_item **next) | ||
322 | { | ||
323 | struct rb_node *node, *prev_node = NULL; | ||
324 | struct btrfs_delayed_item *delayed_item = NULL; | ||
325 | int ret = 0; | ||
326 | |||
327 | node = root->rb_node; | ||
328 | |||
329 | while (node) { | ||
330 | delayed_item = rb_entry(node, struct btrfs_delayed_item, | ||
331 | rb_node); | ||
332 | prev_node = node; | ||
333 | ret = btrfs_comp_cpu_keys(&delayed_item->key, key); | ||
334 | if (ret < 0) | ||
335 | node = node->rb_right; | ||
336 | else if (ret > 0) | ||
337 | node = node->rb_left; | ||
338 | else | ||
339 | return delayed_item; | ||
340 | } | ||
341 | |||
342 | if (prev) { | ||
343 | if (!prev_node) | ||
344 | *prev = NULL; | ||
345 | else if (ret < 0) | ||
346 | *prev = delayed_item; | ||
347 | else if ((node = rb_prev(prev_node)) != NULL) { | ||
348 | *prev = rb_entry(node, struct btrfs_delayed_item, | ||
349 | rb_node); | ||
350 | } else | ||
351 | *prev = NULL; | ||
352 | } | ||
353 | |||
354 | if (next) { | ||
355 | if (!prev_node) | ||
356 | *next = NULL; | ||
357 | else if (ret > 0) | ||
358 | *next = delayed_item; | ||
359 | else if ((node = rb_next(prev_node)) != NULL) { | ||
360 | *next = rb_entry(node, struct btrfs_delayed_item, | ||
361 | rb_node); | ||
362 | } else | ||
363 | *next = NULL; | ||
364 | } | ||
365 | return NULL; | ||
366 | } | ||
367 | |||
368 | struct btrfs_delayed_item *__btrfs_lookup_delayed_insertion_item( | ||
369 | struct btrfs_delayed_node *delayed_node, | ||
370 | struct btrfs_key *key) | ||
371 | { | ||
372 | struct btrfs_delayed_item *item; | ||
373 | |||
374 | item = __btrfs_lookup_delayed_item(&delayed_node->ins_root, key, | ||
375 | NULL, NULL); | ||
376 | return item; | ||
377 | } | ||
378 | |||
379 | struct btrfs_delayed_item *__btrfs_lookup_delayed_deletion_item( | ||
380 | struct btrfs_delayed_node *delayed_node, | ||
381 | struct btrfs_key *key) | ||
382 | { | ||
383 | struct btrfs_delayed_item *item; | ||
384 | |||
385 | item = __btrfs_lookup_delayed_item(&delayed_node->del_root, key, | ||
386 | NULL, NULL); | ||
387 | return item; | ||
388 | } | ||
389 | |||
390 | struct btrfs_delayed_item *__btrfs_search_delayed_insertion_item( | ||
391 | struct btrfs_delayed_node *delayed_node, | ||
392 | struct btrfs_key *key) | ||
393 | { | ||
394 | struct btrfs_delayed_item *item, *next; | ||
395 | |||
396 | item = __btrfs_lookup_delayed_item(&delayed_node->ins_root, key, | ||
397 | NULL, &next); | ||
398 | if (!item) | ||
399 | item = next; | ||
400 | |||
401 | return item; | ||
402 | } | ||
403 | |||
404 | struct btrfs_delayed_item *__btrfs_search_delayed_deletion_item( | ||
405 | struct btrfs_delayed_node *delayed_node, | ||
406 | struct btrfs_key *key) | ||
407 | { | ||
408 | struct btrfs_delayed_item *item, *next; | ||
409 | |||
410 | item = __btrfs_lookup_delayed_item(&delayed_node->del_root, key, | ||
411 | NULL, &next); | ||
412 | if (!item) | ||
413 | item = next; | ||
414 | |||
415 | return item; | ||
416 | } | ||
417 | |||
418 | static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node, | ||
419 | struct btrfs_delayed_item *ins, | ||
420 | int action) | ||
421 | { | ||
422 | struct rb_node **p, *node; | ||
423 | struct rb_node *parent_node = NULL; | ||
424 | struct rb_root *root; | ||
425 | struct btrfs_delayed_item *item; | ||
426 | int cmp; | ||
427 | |||
428 | if (action == BTRFS_DELAYED_INSERTION_ITEM) | ||
429 | root = &delayed_node->ins_root; | ||
430 | else if (action == BTRFS_DELAYED_DELETION_ITEM) | ||
431 | root = &delayed_node->del_root; | ||
432 | else | ||
433 | BUG(); | ||
434 | p = &root->rb_node; | ||
435 | node = &ins->rb_node; | ||
436 | |||
437 | while (*p) { | ||
438 | parent_node = *p; | ||
439 | item = rb_entry(parent_node, struct btrfs_delayed_item, | ||
440 | rb_node); | ||
441 | |||
442 | cmp = btrfs_comp_cpu_keys(&item->key, &ins->key); | ||
443 | if (cmp < 0) | ||
444 | p = &(*p)->rb_right; | ||
445 | else if (cmp > 0) | ||
446 | p = &(*p)->rb_left; | ||
447 | else | ||
448 | return -EEXIST; | ||
449 | } | ||
450 | |||
451 | rb_link_node(node, parent_node, p); | ||
452 | rb_insert_color(node, root); | ||
453 | ins->delayed_node = delayed_node; | ||
454 | ins->ins_or_del = action; | ||
455 | |||
456 | if (ins->key.type == BTRFS_DIR_INDEX_KEY && | ||
457 | action == BTRFS_DELAYED_INSERTION_ITEM && | ||
458 | ins->key.offset >= delayed_node->index_cnt) | ||
459 | delayed_node->index_cnt = ins->key.offset + 1; | ||
460 | |||
461 | delayed_node->count++; | ||
462 | atomic_inc(&delayed_node->root->fs_info->delayed_root->items); | ||
463 | return 0; | ||
464 | } | ||
465 | |||
466 | static int __btrfs_add_delayed_insertion_item(struct btrfs_delayed_node *node, | ||
467 | struct btrfs_delayed_item *item) | ||
468 | { | ||
469 | return __btrfs_add_delayed_item(node, item, | ||
470 | BTRFS_DELAYED_INSERTION_ITEM); | ||
471 | } | ||
472 | |||
473 | static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node, | ||
474 | struct btrfs_delayed_item *item) | ||
475 | { | ||
476 | return __btrfs_add_delayed_item(node, item, | ||
477 | BTRFS_DELAYED_DELETION_ITEM); | ||
478 | } | ||
479 | |||
480 | static void __btrfs_remove_delayed_item(struct btrfs_delayed_item *delayed_item) | ||
481 | { | ||
482 | struct rb_root *root; | ||
483 | struct btrfs_delayed_root *delayed_root; | ||
484 | |||
485 | delayed_root = delayed_item->delayed_node->root->fs_info->delayed_root; | ||
486 | |||
487 | BUG_ON(!delayed_root); | ||
488 | BUG_ON(delayed_item->ins_or_del != BTRFS_DELAYED_DELETION_ITEM && | ||
489 | delayed_item->ins_or_del != BTRFS_DELAYED_INSERTION_ITEM); | ||
490 | |||
491 | if (delayed_item->ins_or_del == BTRFS_DELAYED_INSERTION_ITEM) | ||
492 | root = &delayed_item->delayed_node->ins_root; | ||
493 | else | ||
494 | root = &delayed_item->delayed_node->del_root; | ||
495 | |||
496 | rb_erase(&delayed_item->rb_node, root); | ||
497 | delayed_item->delayed_node->count--; | ||
498 | atomic_dec(&delayed_root->items); | ||
499 | if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND && | ||
500 | waitqueue_active(&delayed_root->wait)) | ||
501 | wake_up(&delayed_root->wait); | ||
502 | } | ||
503 | |||
504 | static void btrfs_release_delayed_item(struct btrfs_delayed_item *item) | ||
505 | { | ||
506 | if (item) { | ||
507 | __btrfs_remove_delayed_item(item); | ||
508 | if (atomic_dec_and_test(&item->refs)) | ||
509 | kfree(item); | ||
510 | } | ||
511 | } | ||
512 | |||
513 | struct btrfs_delayed_item *__btrfs_first_delayed_insertion_item( | ||
514 | struct btrfs_delayed_node *delayed_node) | ||
515 | { | ||
516 | struct rb_node *p; | ||
517 | struct btrfs_delayed_item *item = NULL; | ||
518 | |||
519 | p = rb_first(&delayed_node->ins_root); | ||
520 | if (p) | ||
521 | item = rb_entry(p, struct btrfs_delayed_item, rb_node); | ||
522 | |||
523 | return item; | ||
524 | } | ||
525 | |||
526 | struct btrfs_delayed_item *__btrfs_first_delayed_deletion_item( | ||
527 | struct btrfs_delayed_node *delayed_node) | ||
528 | { | ||
529 | struct rb_node *p; | ||
530 | struct btrfs_delayed_item *item = NULL; | ||
531 | |||
532 | p = rb_first(&delayed_node->del_root); | ||
533 | if (p) | ||
534 | item = rb_entry(p, struct btrfs_delayed_item, rb_node); | ||
535 | |||
536 | return item; | ||
537 | } | ||
538 | |||
539 | struct btrfs_delayed_item *__btrfs_next_delayed_item( | ||
540 | struct btrfs_delayed_item *item) | ||
541 | { | ||
542 | struct rb_node *p; | ||
543 | struct btrfs_delayed_item *next = NULL; | ||
544 | |||
545 | p = rb_next(&item->rb_node); | ||
546 | if (p) | ||
547 | next = rb_entry(p, struct btrfs_delayed_item, rb_node); | ||
548 | |||
549 | return next; | ||
550 | } | ||
551 | |||
552 | static inline struct btrfs_delayed_node *btrfs_get_delayed_node( | ||
553 | struct inode *inode) | ||
554 | { | ||
555 | struct btrfs_inode *btrfs_inode = BTRFS_I(inode); | ||
556 | struct btrfs_delayed_node *delayed_node; | ||
557 | |||
558 | delayed_node = btrfs_inode->delayed_node; | ||
559 | if (delayed_node) | ||
560 | atomic_inc(&delayed_node->refs); | ||
561 | |||
562 | return delayed_node; | ||
563 | } | ||
564 | |||
565 | static inline struct btrfs_root *btrfs_get_fs_root(struct btrfs_root *root, | ||
566 | u64 root_id) | ||
567 | { | ||
568 | struct btrfs_key root_key; | ||
569 | |||
570 | if (root->objectid == root_id) | ||
571 | return root; | ||
572 | |||
573 | root_key.objectid = root_id; | ||
574 | root_key.type = BTRFS_ROOT_ITEM_KEY; | ||
575 | root_key.offset = (u64)-1; | ||
576 | return btrfs_read_fs_root_no_name(root->fs_info, &root_key); | ||
577 | } | ||
578 | |||
579 | static int btrfs_delayed_item_reserve_metadata(struct btrfs_trans_handle *trans, | ||
580 | struct btrfs_root *root, | ||
581 | struct btrfs_delayed_item *item) | ||
582 | { | ||
583 | struct btrfs_block_rsv *src_rsv; | ||
584 | struct btrfs_block_rsv *dst_rsv; | ||
585 | u64 num_bytes; | ||
586 | int ret; | ||
587 | |||
588 | if (!trans->bytes_reserved) | ||
589 | return 0; | ||
590 | |||
591 | src_rsv = trans->block_rsv; | ||
592 | dst_rsv = &root->fs_info->global_block_rsv; | ||
593 | |||
594 | num_bytes = btrfs_calc_trans_metadata_size(root, 1); | ||
595 | ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes); | ||
596 | if (!ret) { | ||
597 | item->bytes_reserved = num_bytes; | ||
598 | item->block_rsv = dst_rsv; | ||
599 | } | ||
600 | |||
601 | return ret; | ||
602 | } | ||
603 | |||
604 | static void btrfs_delayed_item_release_metadata(struct btrfs_root *root, | ||
605 | struct btrfs_delayed_item *item) | ||
606 | { | ||
607 | if (!item->bytes_reserved) | ||
608 | return; | ||
609 | |||
610 | btrfs_block_rsv_release(root, item->block_rsv, | ||
611 | item->bytes_reserved); | ||
612 | } | ||
613 | |||
614 | static int btrfs_delayed_inode_reserve_metadata( | ||
615 | struct btrfs_trans_handle *trans, | ||
616 | struct btrfs_root *root, | ||
617 | struct btrfs_delayed_node *node) | ||
618 | { | ||
619 | struct btrfs_block_rsv *src_rsv; | ||
620 | struct btrfs_block_rsv *dst_rsv; | ||
621 | u64 num_bytes; | ||
622 | int ret; | ||
623 | |||
624 | if (!trans->bytes_reserved) | ||
625 | return 0; | ||
626 | |||
627 | src_rsv = trans->block_rsv; | ||
628 | dst_rsv = &root->fs_info->global_block_rsv; | ||
629 | |||
630 | num_bytes = btrfs_calc_trans_metadata_size(root, 1); | ||
631 | ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes); | ||
632 | if (!ret) | ||
633 | node->bytes_reserved = num_bytes; | ||
634 | |||
635 | return ret; | ||
636 | } | ||
637 | |||
638 | static void btrfs_delayed_inode_release_metadata(struct btrfs_root *root, | ||
639 | struct btrfs_delayed_node *node) | ||
640 | { | ||
641 | struct btrfs_block_rsv *rsv; | ||
642 | |||
643 | if (!node->bytes_reserved) | ||
644 | return; | ||
645 | |||
646 | rsv = &root->fs_info->global_block_rsv; | ||
647 | btrfs_block_rsv_release(root, rsv, | ||
648 | node->bytes_reserved); | ||
649 | node->bytes_reserved = 0; | ||
650 | } | ||
651 | |||
652 | /* | ||
653 | * This helper will insert some continuous items into the same leaf according | ||
654 | * to the free space of the leaf. | ||
655 | */ | ||
656 | static int btrfs_batch_insert_items(struct btrfs_trans_handle *trans, | ||
657 | struct btrfs_root *root, | ||
658 | struct btrfs_path *path, | ||
659 | struct btrfs_delayed_item *item) | ||
660 | { | ||
661 | struct btrfs_delayed_item *curr, *next; | ||
662 | int free_space; | ||
663 | int total_data_size = 0, total_size = 0; | ||
664 | struct extent_buffer *leaf; | ||
665 | char *data_ptr; | ||
666 | struct btrfs_key *keys; | ||
667 | u32 *data_size; | ||
668 | struct list_head head; | ||
669 | int slot; | ||
670 | int nitems; | ||
671 | int i; | ||
672 | int ret = 0; | ||
673 | |||
674 | BUG_ON(!path->nodes[0]); | ||
675 | |||
676 | leaf = path->nodes[0]; | ||
677 | free_space = btrfs_leaf_free_space(root, leaf); | ||
678 | INIT_LIST_HEAD(&head); | ||
679 | |||
680 | next = item; | ||
681 | |||
682 | /* | ||
683 | * count the number of the continuous items that we can insert in batch | ||
684 | */ | ||
685 | while (total_size + next->data_len + sizeof(struct btrfs_item) <= | ||
686 | free_space) { | ||
687 | total_data_size += next->data_len; | ||
688 | total_size += next->data_len + sizeof(struct btrfs_item); | ||
689 | list_add_tail(&next->tree_list, &head); | ||
690 | nitems++; | ||
691 | |||
692 | curr = next; | ||
693 | next = __btrfs_next_delayed_item(curr); | ||
694 | if (!next) | ||
695 | break; | ||
696 | |||
697 | if (!btrfs_is_continuous_delayed_item(curr, next)) | ||
698 | break; | ||
699 | } | ||
700 | |||
701 | if (!nitems) { | ||
702 | ret = 0; | ||
703 | goto out; | ||
704 | } | ||
705 | |||
706 | /* | ||
707 | * we need allocate some memory space, but it might cause the task | ||
708 | * to sleep, so we set all locked nodes in the path to blocking locks | ||
709 | * first. | ||
710 | */ | ||
711 | btrfs_set_path_blocking(path); | ||
712 | |||
713 | keys = kmalloc(sizeof(struct btrfs_key) * nitems, GFP_NOFS); | ||
714 | if (!keys) { | ||
715 | ret = -ENOMEM; | ||
716 | goto out; | ||
717 | } | ||
718 | |||
719 | data_size = kmalloc(sizeof(u32) * nitems, GFP_NOFS); | ||
720 | if (!data_size) { | ||
721 | ret = -ENOMEM; | ||
722 | goto error; | ||
723 | } | ||
724 | |||
725 | /* get keys of all the delayed items */ | ||
726 | i = 0; | ||
727 | list_for_each_entry(next, &head, tree_list) { | ||
728 | keys[i] = next->key; | ||
729 | data_size[i] = next->data_len; | ||
730 | i++; | ||
731 | } | ||
732 | |||
733 | /* reset all the locked nodes in the patch to spinning locks. */ | ||
734 | btrfs_clear_path_blocking(path, NULL); | ||
735 | |||
736 | /* insert the keys of the items */ | ||
737 | ret = setup_items_for_insert(trans, root, path, keys, data_size, | ||
738 | total_data_size, total_size, nitems); | ||
739 | if (ret) | ||
740 | goto error; | ||
741 | |||
742 | /* insert the dir index items */ | ||
743 | slot = path->slots[0]; | ||
744 | list_for_each_entry_safe(curr, next, &head, tree_list) { | ||
745 | data_ptr = btrfs_item_ptr(leaf, slot, char); | ||
746 | write_extent_buffer(leaf, &curr->data, | ||
747 | (unsigned long)data_ptr, | ||
748 | curr->data_len); | ||
749 | slot++; | ||
750 | |||
751 | btrfs_delayed_item_release_metadata(root, curr); | ||
752 | |||
753 | list_del(&curr->tree_list); | ||
754 | btrfs_release_delayed_item(curr); | ||
755 | } | ||
756 | |||
757 | error: | ||
758 | kfree(data_size); | ||
759 | kfree(keys); | ||
760 | out: | ||
761 | return ret; | ||
762 | } | ||
763 | |||
764 | /* | ||
765 | * This helper can just do simple insertion that needn't extend item for new | ||
766 | * data, such as directory name index insertion, inode insertion. | ||
767 | */ | ||
768 | static int btrfs_insert_delayed_item(struct btrfs_trans_handle *trans, | ||
769 | struct btrfs_root *root, | ||
770 | struct btrfs_path *path, | ||
771 | struct btrfs_delayed_item *delayed_item) | ||
772 | { | ||
773 | struct extent_buffer *leaf; | ||
774 | struct btrfs_item *item; | ||
775 | char *ptr; | ||
776 | int ret; | ||
777 | |||
778 | ret = btrfs_insert_empty_item(trans, root, path, &delayed_item->key, | ||
779 | delayed_item->data_len); | ||
780 | if (ret < 0 && ret != -EEXIST) | ||
781 | return ret; | ||
782 | |||
783 | leaf = path->nodes[0]; | ||
784 | |||
785 | item = btrfs_item_nr(leaf, path->slots[0]); | ||
786 | ptr = btrfs_item_ptr(leaf, path->slots[0], char); | ||
787 | |||
788 | write_extent_buffer(leaf, delayed_item->data, (unsigned long)ptr, | ||
789 | delayed_item->data_len); | ||
790 | btrfs_mark_buffer_dirty(leaf); | ||
791 | |||
792 | btrfs_delayed_item_release_metadata(root, delayed_item); | ||
793 | return 0; | ||
794 | } | ||
795 | |||
796 | /* | ||
797 | * we insert an item first, then if there are some continuous items, we try | ||
798 | * to insert those items into the same leaf. | ||
799 | */ | ||
800 | static int btrfs_insert_delayed_items(struct btrfs_trans_handle *trans, | ||
801 | struct btrfs_path *path, | ||
802 | struct btrfs_root *root, | ||
803 | struct btrfs_delayed_node *node) | ||
804 | { | ||
805 | struct btrfs_delayed_item *curr, *prev; | ||
806 | int ret = 0; | ||
807 | |||
808 | do_again: | ||
809 | mutex_lock(&node->mutex); | ||
810 | curr = __btrfs_first_delayed_insertion_item(node); | ||
811 | if (!curr) | ||
812 | goto insert_end; | ||
813 | |||
814 | ret = btrfs_insert_delayed_item(trans, root, path, curr); | ||
815 | if (ret < 0) { | ||
816 | btrfs_release_path(path); | ||
817 | goto insert_end; | ||
818 | } | ||
819 | |||
820 | prev = curr; | ||
821 | curr = __btrfs_next_delayed_item(prev); | ||
822 | if (curr && btrfs_is_continuous_delayed_item(prev, curr)) { | ||
823 | /* insert the continuous items into the same leaf */ | ||
824 | path->slots[0]++; | ||
825 | btrfs_batch_insert_items(trans, root, path, curr); | ||
826 | } | ||
827 | btrfs_release_delayed_item(prev); | ||
828 | btrfs_mark_buffer_dirty(path->nodes[0]); | ||
829 | |||
830 | btrfs_release_path(path); | ||
831 | mutex_unlock(&node->mutex); | ||
832 | goto do_again; | ||
833 | |||
834 | insert_end: | ||
835 | mutex_unlock(&node->mutex); | ||
836 | return ret; | ||
837 | } | ||
838 | |||
839 | static int btrfs_batch_delete_items(struct btrfs_trans_handle *trans, | ||
840 | struct btrfs_root *root, | ||
841 | struct btrfs_path *path, | ||
842 | struct btrfs_delayed_item *item) | ||
843 | { | ||
844 | struct btrfs_delayed_item *curr, *next; | ||
845 | struct extent_buffer *leaf; | ||
846 | struct btrfs_key key; | ||
847 | struct list_head head; | ||
848 | int nitems, i, last_item; | ||
849 | int ret = 0; | ||
850 | |||
851 | BUG_ON(!path->nodes[0]); | ||
852 | |||
853 | leaf = path->nodes[0]; | ||
854 | |||
855 | i = path->slots[0]; | ||
856 | last_item = btrfs_header_nritems(leaf) - 1; | ||
857 | if (i > last_item) | ||
858 | return -ENOENT; /* FIXME: Is errno suitable? */ | ||
859 | |||
860 | next = item; | ||
861 | INIT_LIST_HEAD(&head); | ||
862 | btrfs_item_key_to_cpu(leaf, &key, i); | ||
863 | nitems = 0; | ||
864 | /* | ||
865 | * count the number of the dir index items that we can delete in batch | ||
866 | */ | ||
867 | while (btrfs_comp_cpu_keys(&next->key, &key) == 0) { | ||
868 | list_add_tail(&next->tree_list, &head); | ||
869 | nitems++; | ||
870 | |||
871 | curr = next; | ||
872 | next = __btrfs_next_delayed_item(curr); | ||
873 | if (!next) | ||
874 | break; | ||
875 | |||
876 | if (!btrfs_is_continuous_delayed_item(curr, next)) | ||
877 | break; | ||
878 | |||
879 | i++; | ||
880 | if (i > last_item) | ||
881 | break; | ||
882 | btrfs_item_key_to_cpu(leaf, &key, i); | ||
883 | } | ||
884 | |||
885 | if (!nitems) | ||
886 | return 0; | ||
887 | |||
888 | ret = btrfs_del_items(trans, root, path, path->slots[0], nitems); | ||
889 | if (ret) | ||
890 | goto out; | ||
891 | |||
892 | list_for_each_entry_safe(curr, next, &head, tree_list) { | ||
893 | btrfs_delayed_item_release_metadata(root, curr); | ||
894 | list_del(&curr->tree_list); | ||
895 | btrfs_release_delayed_item(curr); | ||
896 | } | ||
897 | |||
898 | out: | ||
899 | return ret; | ||
900 | } | ||
901 | |||
902 | static int btrfs_delete_delayed_items(struct btrfs_trans_handle *trans, | ||
903 | struct btrfs_path *path, | ||
904 | struct btrfs_root *root, | ||
905 | struct btrfs_delayed_node *node) | ||
906 | { | ||
907 | struct btrfs_delayed_item *curr, *prev; | ||
908 | int ret = 0; | ||
909 | |||
910 | do_again: | ||
911 | mutex_lock(&node->mutex); | ||
912 | curr = __btrfs_first_delayed_deletion_item(node); | ||
913 | if (!curr) | ||
914 | goto delete_fail; | ||
915 | |||
916 | ret = btrfs_search_slot(trans, root, &curr->key, path, -1, 1); | ||
917 | if (ret < 0) | ||
918 | goto delete_fail; | ||
919 | else if (ret > 0) { | ||
920 | /* | ||
921 | * can't find the item which the node points to, so this node | ||
922 | * is invalid, just drop it. | ||
923 | */ | ||
924 | prev = curr; | ||
925 | curr = __btrfs_next_delayed_item(prev); | ||
926 | btrfs_release_delayed_item(prev); | ||
927 | ret = 0; | ||
928 | btrfs_release_path(path); | ||
929 | if (curr) | ||
930 | goto do_again; | ||
931 | else | ||
932 | goto delete_fail; | ||
933 | } | ||
934 | |||
935 | btrfs_batch_delete_items(trans, root, path, curr); | ||
936 | btrfs_release_path(path); | ||
937 | mutex_unlock(&node->mutex); | ||
938 | goto do_again; | ||
939 | |||
940 | delete_fail: | ||
941 | btrfs_release_path(path); | ||
942 | mutex_unlock(&node->mutex); | ||
943 | return ret; | ||
944 | } | ||
945 | |||
946 | static void btrfs_release_delayed_inode(struct btrfs_delayed_node *delayed_node) | ||
947 | { | ||
948 | struct btrfs_delayed_root *delayed_root; | ||
949 | |||
950 | if (delayed_node && delayed_node->inode_dirty) { | ||
951 | BUG_ON(!delayed_node->root); | ||
952 | delayed_node->inode_dirty = 0; | ||
953 | delayed_node->count--; | ||
954 | |||
955 | delayed_root = delayed_node->root->fs_info->delayed_root; | ||
956 | atomic_dec(&delayed_root->items); | ||
957 | if (atomic_read(&delayed_root->items) < | ||
958 | BTRFS_DELAYED_BACKGROUND && | ||
959 | waitqueue_active(&delayed_root->wait)) | ||
960 | wake_up(&delayed_root->wait); | ||
961 | } | ||
962 | } | ||
963 | |||
964 | static int btrfs_update_delayed_inode(struct btrfs_trans_handle *trans, | ||
965 | struct btrfs_root *root, | ||
966 | struct btrfs_path *path, | ||
967 | struct btrfs_delayed_node *node) | ||
968 | { | ||
969 | struct btrfs_key key; | ||
970 | struct btrfs_inode_item *inode_item; | ||
971 | struct extent_buffer *leaf; | ||
972 | int ret; | ||
973 | |||
974 | mutex_lock(&node->mutex); | ||
975 | if (!node->inode_dirty) { | ||
976 | mutex_unlock(&node->mutex); | ||
977 | return 0; | ||
978 | } | ||
979 | |||
980 | key.objectid = node->inode_id; | ||
981 | btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); | ||
982 | key.offset = 0; | ||
983 | ret = btrfs_lookup_inode(trans, root, path, &key, 1); | ||
984 | if (ret > 0) { | ||
985 | btrfs_release_path(path); | ||
986 | mutex_unlock(&node->mutex); | ||
987 | return -ENOENT; | ||
988 | } else if (ret < 0) { | ||
989 | mutex_unlock(&node->mutex); | ||
990 | return ret; | ||
991 | } | ||
992 | |||
993 | btrfs_unlock_up_safe(path, 1); | ||
994 | leaf = path->nodes[0]; | ||
995 | inode_item = btrfs_item_ptr(leaf, path->slots[0], | ||
996 | struct btrfs_inode_item); | ||
997 | write_extent_buffer(leaf, &node->inode_item, (unsigned long)inode_item, | ||
998 | sizeof(struct btrfs_inode_item)); | ||
999 | btrfs_mark_buffer_dirty(leaf); | ||
1000 | btrfs_release_path(path); | ||
1001 | |||
1002 | btrfs_delayed_inode_release_metadata(root, node); | ||
1003 | btrfs_release_delayed_inode(node); | ||
1004 | mutex_unlock(&node->mutex); | ||
1005 | |||
1006 | return 0; | ||
1007 | } | ||
1008 | |||
1009 | /* Called when committing the transaction. */ | ||
1010 | int btrfs_run_delayed_items(struct btrfs_trans_handle *trans, | ||
1011 | struct btrfs_root *root) | ||
1012 | { | ||
1013 | struct btrfs_delayed_root *delayed_root; | ||
1014 | struct btrfs_delayed_node *curr_node, *prev_node; | ||
1015 | struct btrfs_path *path; | ||
1016 | int ret = 0; | ||
1017 | |||
1018 | path = btrfs_alloc_path(); | ||
1019 | if (!path) | ||
1020 | return -ENOMEM; | ||
1021 | path->leave_spinning = 1; | ||
1022 | |||
1023 | delayed_root = btrfs_get_delayed_root(root); | ||
1024 | |||
1025 | curr_node = btrfs_first_delayed_node(delayed_root); | ||
1026 | while (curr_node) { | ||
1027 | root = curr_node->root; | ||
1028 | ret = btrfs_insert_delayed_items(trans, path, root, | ||
1029 | curr_node); | ||
1030 | if (!ret) | ||
1031 | ret = btrfs_delete_delayed_items(trans, path, root, | ||
1032 | curr_node); | ||
1033 | if (!ret) | ||
1034 | ret = btrfs_update_delayed_inode(trans, root, path, | ||
1035 | curr_node); | ||
1036 | if (ret) { | ||
1037 | btrfs_release_delayed_node(curr_node); | ||
1038 | break; | ||
1039 | } | ||
1040 | |||
1041 | prev_node = curr_node; | ||
1042 | curr_node = btrfs_next_delayed_node(curr_node); | ||
1043 | btrfs_release_delayed_node(prev_node); | ||
1044 | } | ||
1045 | |||
1046 | btrfs_free_path(path); | ||
1047 | return ret; | ||
1048 | } | ||
1049 | |||
1050 | static int __btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans, | ||
1051 | struct btrfs_delayed_node *node) | ||
1052 | { | ||
1053 | struct btrfs_path *path; | ||
1054 | int ret; | ||
1055 | |||
1056 | path = btrfs_alloc_path(); | ||
1057 | if (!path) | ||
1058 | return -ENOMEM; | ||
1059 | path->leave_spinning = 1; | ||
1060 | |||
1061 | ret = btrfs_insert_delayed_items(trans, path, node->root, node); | ||
1062 | if (!ret) | ||
1063 | ret = btrfs_delete_delayed_items(trans, path, node->root, node); | ||
1064 | if (!ret) | ||
1065 | ret = btrfs_update_delayed_inode(trans, node->root, path, node); | ||
1066 | btrfs_free_path(path); | ||
1067 | |||
1068 | return ret; | ||
1069 | } | ||
1070 | |||
1071 | int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans, | ||
1072 | struct inode *inode) | ||
1073 | { | ||
1074 | struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode); | ||
1075 | int ret; | ||
1076 | |||
1077 | if (!delayed_node) | ||
1078 | return 0; | ||
1079 | |||
1080 | mutex_lock(&delayed_node->mutex); | ||
1081 | if (!delayed_node->count) { | ||
1082 | mutex_unlock(&delayed_node->mutex); | ||
1083 | btrfs_release_delayed_node(delayed_node); | ||
1084 | return 0; | ||
1085 | } | ||
1086 | mutex_unlock(&delayed_node->mutex); | ||
1087 | |||
1088 | ret = __btrfs_commit_inode_delayed_items(trans, delayed_node); | ||
1089 | btrfs_release_delayed_node(delayed_node); | ||
1090 | return ret; | ||
1091 | } | ||
1092 | |||
1093 | void btrfs_remove_delayed_node(struct inode *inode) | ||
1094 | { | ||
1095 | struct btrfs_delayed_node *delayed_node; | ||
1096 | |||
1097 | delayed_node = ACCESS_ONCE(BTRFS_I(inode)->delayed_node); | ||
1098 | if (!delayed_node) | ||
1099 | return; | ||
1100 | |||
1101 | BTRFS_I(inode)->delayed_node = NULL; | ||
1102 | btrfs_release_delayed_node(delayed_node); | ||
1103 | } | ||
1104 | |||
1105 | struct btrfs_async_delayed_node { | ||
1106 | struct btrfs_root *root; | ||
1107 | struct btrfs_delayed_node *delayed_node; | ||
1108 | struct btrfs_work work; | ||
1109 | }; | ||
1110 | |||
1111 | static void btrfs_async_run_delayed_node_done(struct btrfs_work *work) | ||
1112 | { | ||
1113 | struct btrfs_async_delayed_node *async_node; | ||
1114 | struct btrfs_trans_handle *trans; | ||
1115 | struct btrfs_path *path; | ||
1116 | struct btrfs_delayed_node *delayed_node = NULL; | ||
1117 | struct btrfs_root *root; | ||
1118 | unsigned long nr = 0; | ||
1119 | int need_requeue = 0; | ||
1120 | int ret; | ||
1121 | |||
1122 | async_node = container_of(work, struct btrfs_async_delayed_node, work); | ||
1123 | |||
1124 | path = btrfs_alloc_path(); | ||
1125 | if (!path) | ||
1126 | goto out; | ||
1127 | path->leave_spinning = 1; | ||
1128 | |||
1129 | delayed_node = async_node->delayed_node; | ||
1130 | root = delayed_node->root; | ||
1131 | |||
1132 | trans = btrfs_join_transaction(root, 0); | ||
1133 | if (IS_ERR(trans)) | ||
1134 | goto free_path; | ||
1135 | |||
1136 | ret = btrfs_insert_delayed_items(trans, path, root, delayed_node); | ||
1137 | if (!ret) | ||
1138 | ret = btrfs_delete_delayed_items(trans, path, root, | ||
1139 | delayed_node); | ||
1140 | |||
1141 | if (!ret) | ||
1142 | btrfs_update_delayed_inode(trans, root, path, delayed_node); | ||
1143 | |||
1144 | /* | ||
1145 | * Maybe new delayed items have been inserted, so we need requeue | ||
1146 | * the work. Besides that, we must dequeue the empty delayed nodes | ||
1147 | * to avoid the race between delayed items balance and the worker. | ||
1148 | * The race like this: | ||
1149 | * Task1 Worker thread | ||
1150 | * count == 0, needn't requeue | ||
1151 | * also needn't insert the | ||
1152 | * delayed node into prepare | ||
1153 | * list again. | ||
1154 | * add lots of delayed items | ||
1155 | * queue the delayed node | ||
1156 | * already in the list, | ||
1157 | * and not in the prepare | ||
1158 | * list, it means the delayed | ||
1159 | * node is being dealt with | ||
1160 | * by the worker. | ||
1161 | * do delayed items balance | ||
1162 | * the delayed node is being | ||
1163 | * dealt with by the worker | ||
1164 | * now, just wait. | ||
1165 | * the worker goto idle. | ||
1166 | * Task1 will sleep until the transaction is commited. | ||
1167 | */ | ||
1168 | mutex_lock(&delayed_node->mutex); | ||
1169 | if (delayed_node->count) | ||
1170 | need_requeue = 1; | ||
1171 | else | ||
1172 | btrfs_dequeue_delayed_node(root->fs_info->delayed_root, | ||
1173 | delayed_node); | ||
1174 | mutex_unlock(&delayed_node->mutex); | ||
1175 | |||
1176 | nr = trans->blocks_used; | ||
1177 | |||
1178 | btrfs_end_transaction_dmeta(trans, root); | ||
1179 | __btrfs_btree_balance_dirty(root, nr); | ||
1180 | free_path: | ||
1181 | btrfs_free_path(path); | ||
1182 | out: | ||
1183 | if (need_requeue) | ||
1184 | btrfs_requeue_work(&async_node->work); | ||
1185 | else { | ||
1186 | btrfs_release_prepared_delayed_node(delayed_node); | ||
1187 | kfree(async_node); | ||
1188 | } | ||
1189 | } | ||
1190 | |||
1191 | static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root, | ||
1192 | struct btrfs_root *root, int all) | ||
1193 | { | ||
1194 | struct btrfs_async_delayed_node *async_node; | ||
1195 | struct btrfs_delayed_node *curr; | ||
1196 | int count = 0; | ||
1197 | |||
1198 | again: | ||
1199 | curr = btrfs_first_prepared_delayed_node(delayed_root); | ||
1200 | if (!curr) | ||
1201 | return 0; | ||
1202 | |||
1203 | async_node = kmalloc(sizeof(*async_node), GFP_NOFS); | ||
1204 | if (!async_node) { | ||
1205 | btrfs_release_prepared_delayed_node(curr); | ||
1206 | return -ENOMEM; | ||
1207 | } | ||
1208 | |||
1209 | async_node->root = root; | ||
1210 | async_node->delayed_node = curr; | ||
1211 | |||
1212 | async_node->work.func = btrfs_async_run_delayed_node_done; | ||
1213 | async_node->work.flags = 0; | ||
1214 | |||
1215 | btrfs_queue_worker(&root->fs_info->delayed_workers, &async_node->work); | ||
1216 | count++; | ||
1217 | |||
1218 | if (all || count < 4) | ||
1219 | goto again; | ||
1220 | |||
1221 | return 0; | ||
1222 | } | ||
1223 | |||
1224 | void btrfs_balance_delayed_items(struct btrfs_root *root) | ||
1225 | { | ||
1226 | struct btrfs_delayed_root *delayed_root; | ||
1227 | |||
1228 | delayed_root = btrfs_get_delayed_root(root); | ||
1229 | |||
1230 | if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND) | ||
1231 | return; | ||
1232 | |||
1233 | if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) { | ||
1234 | int ret; | ||
1235 | ret = btrfs_wq_run_delayed_node(delayed_root, root, 1); | ||
1236 | if (ret) | ||
1237 | return; | ||
1238 | |||
1239 | wait_event_interruptible_timeout( | ||
1240 | delayed_root->wait, | ||
1241 | (atomic_read(&delayed_root->items) < | ||
1242 | BTRFS_DELAYED_BACKGROUND), | ||
1243 | HZ); | ||
1244 | return; | ||
1245 | } | ||
1246 | |||
1247 | btrfs_wq_run_delayed_node(delayed_root, root, 0); | ||
1248 | } | ||
1249 | |||
1250 | int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans, | ||
1251 | struct btrfs_root *root, const char *name, | ||
1252 | int name_len, struct inode *dir, | ||
1253 | struct btrfs_disk_key *disk_key, u8 type, | ||
1254 | u64 index) | ||
1255 | { | ||
1256 | struct btrfs_delayed_node *delayed_node; | ||
1257 | struct btrfs_delayed_item *delayed_item; | ||
1258 | struct btrfs_dir_item *dir_item; | ||
1259 | int ret; | ||
1260 | |||
1261 | delayed_node = btrfs_get_or_create_delayed_node(dir); | ||
1262 | if (IS_ERR(delayed_node)) | ||
1263 | return PTR_ERR(delayed_node); | ||
1264 | |||
1265 | delayed_item = btrfs_alloc_delayed_item(sizeof(*dir_item) + name_len); | ||
1266 | if (!delayed_item) { | ||
1267 | ret = -ENOMEM; | ||
1268 | goto release_node; | ||
1269 | } | ||
1270 | |||
1271 | ret = btrfs_delayed_item_reserve_metadata(trans, root, delayed_item); | ||
1272 | /* | ||
1273 | * we have reserved enough space when we start a new transaction, | ||
1274 | * so reserving metadata failure is impossible | ||
1275 | */ | ||
1276 | BUG_ON(ret); | ||
1277 | |||
1278 | delayed_item->key.objectid = btrfs_ino(dir); | ||
1279 | btrfs_set_key_type(&delayed_item->key, BTRFS_DIR_INDEX_KEY); | ||
1280 | delayed_item->key.offset = index; | ||
1281 | |||
1282 | dir_item = (struct btrfs_dir_item *)delayed_item->data; | ||
1283 | dir_item->location = *disk_key; | ||
1284 | dir_item->transid = cpu_to_le64(trans->transid); | ||
1285 | dir_item->data_len = 0; | ||
1286 | dir_item->name_len = cpu_to_le16(name_len); | ||
1287 | dir_item->type = type; | ||
1288 | memcpy((char *)(dir_item + 1), name, name_len); | ||
1289 | |||
1290 | mutex_lock(&delayed_node->mutex); | ||
1291 | ret = __btrfs_add_delayed_insertion_item(delayed_node, delayed_item); | ||
1292 | if (unlikely(ret)) { | ||
1293 | printk(KERN_ERR "err add delayed dir index item(name: %s) into " | ||
1294 | "the insertion tree of the delayed node" | ||
1295 | "(root id: %llu, inode id: %llu, errno: %d)\n", | ||
1296 | name, | ||
1297 | (unsigned long long)delayed_node->root->objectid, | ||
1298 | (unsigned long long)delayed_node->inode_id, | ||
1299 | ret); | ||
1300 | BUG(); | ||
1301 | } | ||
1302 | mutex_unlock(&delayed_node->mutex); | ||
1303 | |||
1304 | release_node: | ||
1305 | btrfs_release_delayed_node(delayed_node); | ||
1306 | return ret; | ||
1307 | } | ||
1308 | |||
1309 | static int btrfs_delete_delayed_insertion_item(struct btrfs_root *root, | ||
1310 | struct btrfs_delayed_node *node, | ||
1311 | struct btrfs_key *key) | ||
1312 | { | ||
1313 | struct btrfs_delayed_item *item; | ||
1314 | |||
1315 | mutex_lock(&node->mutex); | ||
1316 | item = __btrfs_lookup_delayed_insertion_item(node, key); | ||
1317 | if (!item) { | ||
1318 | mutex_unlock(&node->mutex); | ||
1319 | return 1; | ||
1320 | } | ||
1321 | |||
1322 | btrfs_delayed_item_release_metadata(root, item); | ||
1323 | btrfs_release_delayed_item(item); | ||
1324 | mutex_unlock(&node->mutex); | ||
1325 | return 0; | ||
1326 | } | ||
1327 | |||
1328 | int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans, | ||
1329 | struct btrfs_root *root, struct inode *dir, | ||
1330 | u64 index) | ||
1331 | { | ||
1332 | struct btrfs_delayed_node *node; | ||
1333 | struct btrfs_delayed_item *item; | ||
1334 | struct btrfs_key item_key; | ||
1335 | int ret; | ||
1336 | |||
1337 | node = btrfs_get_or_create_delayed_node(dir); | ||
1338 | if (IS_ERR(node)) | ||
1339 | return PTR_ERR(node); | ||
1340 | |||
1341 | item_key.objectid = btrfs_ino(dir); | ||
1342 | btrfs_set_key_type(&item_key, BTRFS_DIR_INDEX_KEY); | ||
1343 | item_key.offset = index; | ||
1344 | |||
1345 | ret = btrfs_delete_delayed_insertion_item(root, node, &item_key); | ||
1346 | if (!ret) | ||
1347 | goto end; | ||
1348 | |||
1349 | item = btrfs_alloc_delayed_item(0); | ||
1350 | if (!item) { | ||
1351 | ret = -ENOMEM; | ||
1352 | goto end; | ||
1353 | } | ||
1354 | |||
1355 | item->key = item_key; | ||
1356 | |||
1357 | ret = btrfs_delayed_item_reserve_metadata(trans, root, item); | ||
1358 | /* | ||
1359 | * we have reserved enough space when we start a new transaction, | ||
1360 | * so reserving metadata failure is impossible. | ||
1361 | */ | ||
1362 | BUG_ON(ret); | ||
1363 | |||
1364 | mutex_lock(&node->mutex); | ||
1365 | ret = __btrfs_add_delayed_deletion_item(node, item); | ||
1366 | if (unlikely(ret)) { | ||
1367 | printk(KERN_ERR "err add delayed dir index item(index: %llu) " | ||
1368 | "into the deletion tree of the delayed node" | ||
1369 | "(root id: %llu, inode id: %llu, errno: %d)\n", | ||
1370 | (unsigned long long)index, | ||
1371 | (unsigned long long)node->root->objectid, | ||
1372 | (unsigned long long)node->inode_id, | ||
1373 | ret); | ||
1374 | BUG(); | ||
1375 | } | ||
1376 | mutex_unlock(&node->mutex); | ||
1377 | end: | ||
1378 | btrfs_release_delayed_node(node); | ||
1379 | return ret; | ||
1380 | } | ||
1381 | |||
1382 | int btrfs_inode_delayed_dir_index_count(struct inode *inode) | ||
1383 | { | ||
1384 | struct btrfs_delayed_node *delayed_node = BTRFS_I(inode)->delayed_node; | ||
1385 | int ret = 0; | ||
1386 | |||
1387 | if (!delayed_node) | ||
1388 | return -ENOENT; | ||
1389 | |||
1390 | /* | ||
1391 | * Since we have held i_mutex of this directory, it is impossible that | ||
1392 | * a new directory index is added into the delayed node and index_cnt | ||
1393 | * is updated now. So we needn't lock the delayed node. | ||
1394 | */ | ||
1395 | if (!delayed_node->index_cnt) | ||
1396 | return -EINVAL; | ||
1397 | |||
1398 | BTRFS_I(inode)->index_cnt = delayed_node->index_cnt; | ||
1399 | return ret; | ||
1400 | } | ||
1401 | |||
1402 | void btrfs_get_delayed_items(struct inode *inode, struct list_head *ins_list, | ||
1403 | struct list_head *del_list) | ||
1404 | { | ||
1405 | struct btrfs_delayed_node *delayed_node; | ||
1406 | struct btrfs_delayed_item *item; | ||
1407 | |||
1408 | delayed_node = btrfs_get_delayed_node(inode); | ||
1409 | if (!delayed_node) | ||
1410 | return; | ||
1411 | |||
1412 | mutex_lock(&delayed_node->mutex); | ||
1413 | item = __btrfs_first_delayed_insertion_item(delayed_node); | ||
1414 | while (item) { | ||
1415 | atomic_inc(&item->refs); | ||
1416 | list_add_tail(&item->readdir_list, ins_list); | ||
1417 | item = __btrfs_next_delayed_item(item); | ||
1418 | } | ||
1419 | |||
1420 | item = __btrfs_first_delayed_deletion_item(delayed_node); | ||
1421 | while (item) { | ||
1422 | atomic_inc(&item->refs); | ||
1423 | list_add_tail(&item->readdir_list, del_list); | ||
1424 | item = __btrfs_next_delayed_item(item); | ||
1425 | } | ||
1426 | mutex_unlock(&delayed_node->mutex); | ||
1427 | /* | ||
1428 | * This delayed node is still cached in the btrfs inode, so refs | ||
1429 | * must be > 1 now, and we needn't check it is going to be freed | ||
1430 | * or not. | ||
1431 | * | ||
1432 | * Besides that, this function is used to read dir, we do not | ||
1433 | * insert/delete delayed items in this period. So we also needn't | ||
1434 | * requeue or dequeue this delayed node. | ||
1435 | */ | ||
1436 | atomic_dec(&delayed_node->refs); | ||
1437 | } | ||
1438 | |||
1439 | void btrfs_put_delayed_items(struct list_head *ins_list, | ||
1440 | struct list_head *del_list) | ||
1441 | { | ||
1442 | struct btrfs_delayed_item *curr, *next; | ||
1443 | |||
1444 | list_for_each_entry_safe(curr, next, ins_list, readdir_list) { | ||
1445 | list_del(&curr->readdir_list); | ||
1446 | if (atomic_dec_and_test(&curr->refs)) | ||
1447 | kfree(curr); | ||
1448 | } | ||
1449 | |||
1450 | list_for_each_entry_safe(curr, next, del_list, readdir_list) { | ||
1451 | list_del(&curr->readdir_list); | ||
1452 | if (atomic_dec_and_test(&curr->refs)) | ||
1453 | kfree(curr); | ||
1454 | } | ||
1455 | } | ||
1456 | |||
1457 | int btrfs_should_delete_dir_index(struct list_head *del_list, | ||
1458 | u64 index) | ||
1459 | { | ||
1460 | struct btrfs_delayed_item *curr, *next; | ||
1461 | int ret; | ||
1462 | |||
1463 | if (list_empty(del_list)) | ||
1464 | return 0; | ||
1465 | |||
1466 | list_for_each_entry_safe(curr, next, del_list, readdir_list) { | ||
1467 | if (curr->key.offset > index) | ||
1468 | break; | ||
1469 | |||
1470 | list_del(&curr->readdir_list); | ||
1471 | ret = (curr->key.offset == index); | ||
1472 | |||
1473 | if (atomic_dec_and_test(&curr->refs)) | ||
1474 | kfree(curr); | ||
1475 | |||
1476 | if (ret) | ||
1477 | return 1; | ||
1478 | else | ||
1479 | continue; | ||
1480 | } | ||
1481 | return 0; | ||
1482 | } | ||
1483 | |||
1484 | /* | ||
1485 | * btrfs_readdir_delayed_dir_index - read dir info stored in the delayed tree | ||
1486 | * | ||
1487 | */ | ||
1488 | int btrfs_readdir_delayed_dir_index(struct file *filp, void *dirent, | ||
1489 | filldir_t filldir, | ||
1490 | struct list_head *ins_list) | ||
1491 | { | ||
1492 | struct btrfs_dir_item *di; | ||
1493 | struct btrfs_delayed_item *curr, *next; | ||
1494 | struct btrfs_key location; | ||
1495 | char *name; | ||
1496 | int name_len; | ||
1497 | int over = 0; | ||
1498 | unsigned char d_type; | ||
1499 | |||
1500 | if (list_empty(ins_list)) | ||
1501 | return 0; | ||
1502 | |||
1503 | /* | ||
1504 | * Changing the data of the delayed item is impossible. So | ||
1505 | * we needn't lock them. And we have held i_mutex of the | ||
1506 | * directory, nobody can delete any directory indexes now. | ||
1507 | */ | ||
1508 | list_for_each_entry_safe(curr, next, ins_list, readdir_list) { | ||
1509 | list_del(&curr->readdir_list); | ||
1510 | |||
1511 | if (curr->key.offset < filp->f_pos) { | ||
1512 | if (atomic_dec_and_test(&curr->refs)) | ||
1513 | kfree(curr); | ||
1514 | continue; | ||
1515 | } | ||
1516 | |||
1517 | filp->f_pos = curr->key.offset; | ||
1518 | |||
1519 | di = (struct btrfs_dir_item *)curr->data; | ||
1520 | name = (char *)(di + 1); | ||
1521 | name_len = le16_to_cpu(di->name_len); | ||
1522 | |||
1523 | d_type = btrfs_filetype_table[di->type]; | ||
1524 | btrfs_disk_key_to_cpu(&location, &di->location); | ||
1525 | |||
1526 | over = filldir(dirent, name, name_len, curr->key.offset, | ||
1527 | location.objectid, d_type); | ||
1528 | |||
1529 | if (atomic_dec_and_test(&curr->refs)) | ||
1530 | kfree(curr); | ||
1531 | |||
1532 | if (over) | ||
1533 | return 1; | ||
1534 | } | ||
1535 | return 0; | ||
1536 | } | ||
1537 | |||
1538 | BTRFS_SETGET_STACK_FUNCS(stack_inode_generation, struct btrfs_inode_item, | ||
1539 | generation, 64); | ||
1540 | BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence, struct btrfs_inode_item, | ||
1541 | sequence, 64); | ||
1542 | BTRFS_SETGET_STACK_FUNCS(stack_inode_transid, struct btrfs_inode_item, | ||
1543 | transid, 64); | ||
1544 | BTRFS_SETGET_STACK_FUNCS(stack_inode_size, struct btrfs_inode_item, size, 64); | ||
1545 | BTRFS_SETGET_STACK_FUNCS(stack_inode_nbytes, struct btrfs_inode_item, | ||
1546 | nbytes, 64); | ||
1547 | BTRFS_SETGET_STACK_FUNCS(stack_inode_block_group, struct btrfs_inode_item, | ||
1548 | block_group, 64); | ||
1549 | BTRFS_SETGET_STACK_FUNCS(stack_inode_nlink, struct btrfs_inode_item, nlink, 32); | ||
1550 | BTRFS_SETGET_STACK_FUNCS(stack_inode_uid, struct btrfs_inode_item, uid, 32); | ||
1551 | BTRFS_SETGET_STACK_FUNCS(stack_inode_gid, struct btrfs_inode_item, gid, 32); | ||
1552 | BTRFS_SETGET_STACK_FUNCS(stack_inode_mode, struct btrfs_inode_item, mode, 32); | ||
1553 | BTRFS_SETGET_STACK_FUNCS(stack_inode_rdev, struct btrfs_inode_item, rdev, 64); | ||
1554 | BTRFS_SETGET_STACK_FUNCS(stack_inode_flags, struct btrfs_inode_item, flags, 64); | ||
1555 | |||
1556 | BTRFS_SETGET_STACK_FUNCS(stack_timespec_sec, struct btrfs_timespec, sec, 64); | ||
1557 | BTRFS_SETGET_STACK_FUNCS(stack_timespec_nsec, struct btrfs_timespec, nsec, 32); | ||
1558 | |||
1559 | static void fill_stack_inode_item(struct btrfs_trans_handle *trans, | ||
1560 | struct btrfs_inode_item *inode_item, | ||
1561 | struct inode *inode) | ||
1562 | { | ||
1563 | btrfs_set_stack_inode_uid(inode_item, inode->i_uid); | ||
1564 | btrfs_set_stack_inode_gid(inode_item, inode->i_gid); | ||
1565 | btrfs_set_stack_inode_size(inode_item, BTRFS_I(inode)->disk_i_size); | ||
1566 | btrfs_set_stack_inode_mode(inode_item, inode->i_mode); | ||
1567 | btrfs_set_stack_inode_nlink(inode_item, inode->i_nlink); | ||
1568 | btrfs_set_stack_inode_nbytes(inode_item, inode_get_bytes(inode)); | ||
1569 | btrfs_set_stack_inode_generation(inode_item, | ||
1570 | BTRFS_I(inode)->generation); | ||
1571 | btrfs_set_stack_inode_sequence(inode_item, BTRFS_I(inode)->sequence); | ||
1572 | btrfs_set_stack_inode_transid(inode_item, trans->transid); | ||
1573 | btrfs_set_stack_inode_rdev(inode_item, inode->i_rdev); | ||
1574 | btrfs_set_stack_inode_flags(inode_item, BTRFS_I(inode)->flags); | ||
1575 | btrfs_set_stack_inode_block_group(inode_item, | ||
1576 | BTRFS_I(inode)->block_group); | ||
1577 | |||
1578 | btrfs_set_stack_timespec_sec(btrfs_inode_atime(inode_item), | ||
1579 | inode->i_atime.tv_sec); | ||
1580 | btrfs_set_stack_timespec_nsec(btrfs_inode_atime(inode_item), | ||
1581 | inode->i_atime.tv_nsec); | ||
1582 | |||
1583 | btrfs_set_stack_timespec_sec(btrfs_inode_mtime(inode_item), | ||
1584 | inode->i_mtime.tv_sec); | ||
1585 | btrfs_set_stack_timespec_nsec(btrfs_inode_mtime(inode_item), | ||
1586 | inode->i_mtime.tv_nsec); | ||
1587 | |||
1588 | btrfs_set_stack_timespec_sec(btrfs_inode_ctime(inode_item), | ||
1589 | inode->i_ctime.tv_sec); | ||
1590 | btrfs_set_stack_timespec_nsec(btrfs_inode_ctime(inode_item), | ||
1591 | inode->i_ctime.tv_nsec); | ||
1592 | } | ||
1593 | |||
1594 | int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans, | ||
1595 | struct btrfs_root *root, struct inode *inode) | ||
1596 | { | ||
1597 | struct btrfs_delayed_node *delayed_node; | ||
1598 | int ret; | ||
1599 | |||
1600 | delayed_node = btrfs_get_or_create_delayed_node(inode); | ||
1601 | if (IS_ERR(delayed_node)) | ||
1602 | return PTR_ERR(delayed_node); | ||
1603 | |||
1604 | mutex_lock(&delayed_node->mutex); | ||
1605 | if (delayed_node->inode_dirty) { | ||
1606 | fill_stack_inode_item(trans, &delayed_node->inode_item, inode); | ||
1607 | goto release_node; | ||
1608 | } | ||
1609 | |||
1610 | ret = btrfs_delayed_inode_reserve_metadata(trans, root, delayed_node); | ||
1611 | /* | ||
1612 | * we must reserve enough space when we start a new transaction, | ||
1613 | * so reserving metadata failure is impossible | ||
1614 | */ | ||
1615 | BUG_ON(ret); | ||
1616 | |||
1617 | fill_stack_inode_item(trans, &delayed_node->inode_item, inode); | ||
1618 | delayed_node->inode_dirty = 1; | ||
1619 | delayed_node->count++; | ||
1620 | atomic_inc(&root->fs_info->delayed_root->items); | ||
1621 | release_node: | ||
1622 | mutex_unlock(&delayed_node->mutex); | ||
1623 | btrfs_release_delayed_node(delayed_node); | ||
1624 | return ret; | ||
1625 | } | ||
1626 | |||
1627 | static void __btrfs_kill_delayed_node(struct btrfs_delayed_node *delayed_node) | ||
1628 | { | ||
1629 | struct btrfs_root *root = delayed_node->root; | ||
1630 | struct btrfs_delayed_item *curr_item, *prev_item; | ||
1631 | |||
1632 | mutex_lock(&delayed_node->mutex); | ||
1633 | curr_item = __btrfs_first_delayed_insertion_item(delayed_node); | ||
1634 | while (curr_item) { | ||
1635 | btrfs_delayed_item_release_metadata(root, curr_item); | ||
1636 | prev_item = curr_item; | ||
1637 | curr_item = __btrfs_next_delayed_item(prev_item); | ||
1638 | btrfs_release_delayed_item(prev_item); | ||
1639 | } | ||
1640 | |||
1641 | curr_item = __btrfs_first_delayed_deletion_item(delayed_node); | ||
1642 | while (curr_item) { | ||
1643 | btrfs_delayed_item_release_metadata(root, curr_item); | ||
1644 | prev_item = curr_item; | ||
1645 | curr_item = __btrfs_next_delayed_item(prev_item); | ||
1646 | btrfs_release_delayed_item(prev_item); | ||
1647 | } | ||
1648 | |||
1649 | if (delayed_node->inode_dirty) { | ||
1650 | btrfs_delayed_inode_release_metadata(root, delayed_node); | ||
1651 | btrfs_release_delayed_inode(delayed_node); | ||
1652 | } | ||
1653 | mutex_unlock(&delayed_node->mutex); | ||
1654 | } | ||
1655 | |||
1656 | void btrfs_kill_delayed_inode_items(struct inode *inode) | ||
1657 | { | ||
1658 | struct btrfs_delayed_node *delayed_node; | ||
1659 | |||
1660 | delayed_node = btrfs_get_delayed_node(inode); | ||
1661 | if (!delayed_node) | ||
1662 | return; | ||
1663 | |||
1664 | __btrfs_kill_delayed_node(delayed_node); | ||
1665 | btrfs_release_delayed_node(delayed_node); | ||
1666 | } | ||
1667 | |||
1668 | void btrfs_kill_all_delayed_nodes(struct btrfs_root *root) | ||
1669 | { | ||
1670 | u64 inode_id = 0; | ||
1671 | struct btrfs_delayed_node *delayed_nodes[8]; | ||
1672 | int i, n; | ||
1673 | |||
1674 | while (1) { | ||
1675 | spin_lock(&root->inode_lock); | ||
1676 | n = radix_tree_gang_lookup(&root->delayed_nodes_tree, | ||
1677 | (void **)delayed_nodes, inode_id, | ||
1678 | ARRAY_SIZE(delayed_nodes)); | ||
1679 | if (!n) { | ||
1680 | spin_unlock(&root->inode_lock); | ||
1681 | break; | ||
1682 | } | ||
1683 | |||
1684 | inode_id = delayed_nodes[n - 1]->inode_id + 1; | ||
1685 | |||
1686 | for (i = 0; i < n; i++) | ||
1687 | atomic_inc(&delayed_nodes[i]->refs); | ||
1688 | spin_unlock(&root->inode_lock); | ||
1689 | |||
1690 | for (i = 0; i < n; i++) { | ||
1691 | __btrfs_kill_delayed_node(delayed_nodes[i]); | ||
1692 | btrfs_release_delayed_node(delayed_nodes[i]); | ||
1693 | } | ||
1694 | } | ||
1695 | } | ||
diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h new file mode 100644 index 00000000000..eb7d240aa64 --- /dev/null +++ b/fs/btrfs/delayed-inode.h | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Fujitsu. All rights reserved. | ||
3 | * Written by Miao Xie <miaox@cn.fujitsu.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License v2 as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public | ||
15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | * Boston, MA 021110-1307, USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef __DELAYED_TREE_OPERATION_H | ||
21 | #define __DELAYED_TREE_OPERATION_H | ||
22 | |||
23 | #include <linux/rbtree.h> | ||
24 | #include <linux/spinlock.h> | ||
25 | #include <linux/mutex.h> | ||
26 | #include <linux/list.h> | ||
27 | #include <linux/wait.h> | ||
28 | #include <asm/atomic.h> | ||
29 | |||
30 | #include "ctree.h" | ||
31 | |||
32 | /* types of the delayed item */ | ||
33 | #define BTRFS_DELAYED_INSERTION_ITEM 1 | ||
34 | #define BTRFS_DELAYED_DELETION_ITEM 2 | ||
35 | |||
36 | struct btrfs_delayed_root { | ||
37 | spinlock_t lock; | ||
38 | struct list_head node_list; | ||
39 | /* | ||
40 | * Used for delayed nodes which is waiting to be dealt with by the | ||
41 | * worker. If the delayed node is inserted into the work queue, we | ||
42 | * drop it from this list. | ||
43 | */ | ||
44 | struct list_head prepare_list; | ||
45 | atomic_t items; /* for delayed items */ | ||
46 | int nodes; /* for delayed nodes */ | ||
47 | wait_queue_head_t wait; | ||
48 | }; | ||
49 | |||
50 | struct btrfs_delayed_node { | ||
51 | u64 inode_id; | ||
52 | u64 bytes_reserved; | ||
53 | struct btrfs_root *root; | ||
54 | /* Used to add the node into the delayed root's node list. */ | ||
55 | struct list_head n_list; | ||
56 | /* | ||
57 | * Used to add the node into the prepare list, the nodes in this list | ||
58 | * is waiting to be dealt with by the async worker. | ||
59 | */ | ||
60 | struct list_head p_list; | ||
61 | struct rb_root ins_root; | ||
62 | struct rb_root del_root; | ||
63 | struct mutex mutex; | ||
64 | struct btrfs_inode_item inode_item; | ||
65 | atomic_t refs; | ||
66 | u64 index_cnt; | ||
67 | bool in_list; | ||
68 | bool inode_dirty; | ||
69 | int count; | ||
70 | }; | ||
71 | |||
72 | struct btrfs_delayed_item { | ||
73 | struct rb_node rb_node; | ||
74 | struct btrfs_key key; | ||
75 | struct list_head tree_list; /* used for batch insert/delete items */ | ||
76 | struct list_head readdir_list; /* used for readdir items */ | ||
77 | u64 bytes_reserved; | ||
78 | struct btrfs_block_rsv *block_rsv; | ||
79 | struct btrfs_delayed_node *delayed_node; | ||
80 | atomic_t refs; | ||
81 | int ins_or_del; | ||
82 | u32 data_len; | ||
83 | char data[0]; | ||
84 | }; | ||
85 | |||
86 | static inline void btrfs_init_delayed_root( | ||
87 | struct btrfs_delayed_root *delayed_root) | ||
88 | { | ||
89 | atomic_set(&delayed_root->items, 0); | ||
90 | delayed_root->nodes = 0; | ||
91 | spin_lock_init(&delayed_root->lock); | ||
92 | init_waitqueue_head(&delayed_root->wait); | ||
93 | INIT_LIST_HEAD(&delayed_root->node_list); | ||
94 | INIT_LIST_HEAD(&delayed_root->prepare_list); | ||
95 | } | ||
96 | |||
97 | int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans, | ||
98 | struct btrfs_root *root, const char *name, | ||
99 | int name_len, struct inode *dir, | ||
100 | struct btrfs_disk_key *disk_key, u8 type, | ||
101 | u64 index); | ||
102 | |||
103 | int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans, | ||
104 | struct btrfs_root *root, struct inode *dir, | ||
105 | u64 index); | ||
106 | |||
107 | int btrfs_inode_delayed_dir_index_count(struct inode *inode); | ||
108 | |||
109 | int btrfs_run_delayed_items(struct btrfs_trans_handle *trans, | ||
110 | struct btrfs_root *root); | ||
111 | |||
112 | void btrfs_balance_delayed_items(struct btrfs_root *root); | ||
113 | |||
114 | int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans, | ||
115 | struct inode *inode); | ||
116 | /* Used for evicting the inode. */ | ||
117 | void btrfs_remove_delayed_node(struct inode *inode); | ||
118 | void btrfs_kill_delayed_inode_items(struct inode *inode); | ||
119 | |||
120 | |||
121 | int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans, | ||
122 | struct btrfs_root *root, struct inode *inode); | ||
123 | |||
124 | /* Used for drop dead root */ | ||
125 | void btrfs_kill_all_delayed_nodes(struct btrfs_root *root); | ||
126 | |||
127 | /* Used for readdir() */ | ||
128 | void btrfs_get_delayed_items(struct inode *inode, struct list_head *ins_list, | ||
129 | struct list_head *del_list); | ||
130 | void btrfs_put_delayed_items(struct list_head *ins_list, | ||
131 | struct list_head *del_list); | ||
132 | int btrfs_should_delete_dir_index(struct list_head *del_list, | ||
133 | u64 index); | ||
134 | int btrfs_readdir_delayed_dir_index(struct file *filp, void *dirent, | ||
135 | filldir_t filldir, | ||
136 | struct list_head *ins_list); | ||
137 | |||
138 | /* for init */ | ||
139 | int __init btrfs_delayed_inode_init(void); | ||
140 | void btrfs_delayed_inode_exit(void); | ||
141 | #endif | ||
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index ab8afed671a..1ddfca78e91 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c | |||
@@ -124,8 +124,9 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, | |||
124 | * to use for the second index (if one is created). | 124 | * to use for the second index (if one is created). |
125 | */ | 125 | */ |
126 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | 126 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root |
127 | *root, const char *name, int name_len, u64 dir, | 127 | *root, const char *name, int name_len, |
128 | struct btrfs_key *location, u8 type, u64 index) | 128 | struct inode *dir, struct btrfs_key *location, |
129 | u8 type, u64 index) | ||
129 | { | 130 | { |
130 | int ret = 0; | 131 | int ret = 0; |
131 | int ret2 = 0; | 132 | int ret2 = 0; |
@@ -137,13 +138,17 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
137 | struct btrfs_disk_key disk_key; | 138 | struct btrfs_disk_key disk_key; |
138 | u32 data_size; | 139 | u32 data_size; |
139 | 140 | ||
140 | key.objectid = dir; | 141 | key.objectid = btrfs_ino(dir); |
141 | btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); | 142 | btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); |
142 | key.offset = btrfs_name_hash(name, name_len); | 143 | key.offset = btrfs_name_hash(name, name_len); |
143 | 144 | ||
144 | path = btrfs_alloc_path(); | 145 | path = btrfs_alloc_path(); |
146 | if (!path) | ||
147 | return -ENOMEM; | ||
145 | path->leave_spinning = 1; | 148 | path->leave_spinning = 1; |
146 | 149 | ||
150 | btrfs_cpu_key_to_disk(&disk_key, location); | ||
151 | |||
147 | data_size = sizeof(*dir_item) + name_len; | 152 | data_size = sizeof(*dir_item) + name_len; |
148 | dir_item = insert_with_overflow(trans, root, path, &key, data_size, | 153 | dir_item = insert_with_overflow(trans, root, path, &key, data_size, |
149 | name, name_len); | 154 | name, name_len); |
@@ -155,7 +160,6 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
155 | } | 160 | } |
156 | 161 | ||
157 | leaf = path->nodes[0]; | 162 | leaf = path->nodes[0]; |
158 | btrfs_cpu_key_to_disk(&disk_key, location); | ||
159 | btrfs_set_dir_item_key(leaf, dir_item, &disk_key); | 163 | btrfs_set_dir_item_key(leaf, dir_item, &disk_key); |
160 | btrfs_set_dir_type(leaf, dir_item, type); | 164 | btrfs_set_dir_type(leaf, dir_item, type); |
161 | btrfs_set_dir_data_len(leaf, dir_item, 0); | 165 | btrfs_set_dir_data_len(leaf, dir_item, 0); |
@@ -174,27 +178,9 @@ second_insert: | |||
174 | } | 178 | } |
175 | btrfs_release_path(path); | 179 | btrfs_release_path(path); |
176 | 180 | ||
177 | btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); | 181 | ret2 = btrfs_insert_delayed_dir_index(trans, root, name, name_len, dir, |
178 | key.offset = index; | 182 | &disk_key, type, index); |
179 | dir_item = insert_with_overflow(trans, root, path, &key, data_size, | ||
180 | name, name_len); | ||
181 | if (IS_ERR(dir_item)) { | ||
182 | ret2 = PTR_ERR(dir_item); | ||
183 | goto out_free; | ||
184 | } | ||
185 | leaf = path->nodes[0]; | ||
186 | btrfs_cpu_key_to_disk(&disk_key, location); | ||
187 | btrfs_set_dir_item_key(leaf, dir_item, &disk_key); | ||
188 | btrfs_set_dir_type(leaf, dir_item, type); | ||
189 | btrfs_set_dir_data_len(leaf, dir_item, 0); | ||
190 | btrfs_set_dir_name_len(leaf, dir_item, name_len); | ||
191 | btrfs_set_dir_transid(leaf, dir_item, trans->transid); | ||
192 | name_ptr = (unsigned long)(dir_item + 1); | ||
193 | write_extent_buffer(leaf, name, name_ptr, name_len); | ||
194 | btrfs_mark_buffer_dirty(leaf); | ||
195 | |||
196 | out_free: | 183 | out_free: |
197 | |||
198 | btrfs_free_path(path); | 184 | btrfs_free_path(path); |
199 | if (ret) | 185 | if (ret) |
200 | return ret; | 186 | return ret; |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index cb9d1b8bfe7..a2eb3a3755d 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include "locking.h" | 42 | #include "locking.h" |
43 | #include "tree-log.h" | 43 | #include "tree-log.h" |
44 | #include "free-space-cache.h" | 44 | #include "free-space-cache.h" |
45 | #include "inode-map.h" | ||
45 | 46 | ||
46 | static struct extent_io_ops btree_extent_io_ops; | 47 | static struct extent_io_ops btree_extent_io_ops; |
47 | static void end_workqueue_fn(struct btrfs_work *work); | 48 | static void end_workqueue_fn(struct btrfs_work *work); |
@@ -1045,6 +1046,7 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, | |||
1045 | root->name = NULL; | 1046 | root->name = NULL; |
1046 | root->in_sysfs = 0; | 1047 | root->in_sysfs = 0; |
1047 | root->inode_tree = RB_ROOT; | 1048 | root->inode_tree = RB_ROOT; |
1049 | INIT_RADIX_TREE(&root->delayed_nodes_tree, GFP_ATOMIC); | ||
1048 | root->block_rsv = NULL; | 1050 | root->block_rsv = NULL; |
1049 | root->orphan_block_rsv = NULL; | 1051 | root->orphan_block_rsv = NULL; |
1050 | 1052 | ||
@@ -1298,6 +1300,19 @@ again: | |||
1298 | if (IS_ERR(root)) | 1300 | if (IS_ERR(root)) |
1299 | return root; | 1301 | return root; |
1300 | 1302 | ||
1303 | root->free_ino_ctl = kzalloc(sizeof(*root->free_ino_ctl), GFP_NOFS); | ||
1304 | if (!root->free_ino_ctl) | ||
1305 | goto fail; | ||
1306 | root->free_ino_pinned = kzalloc(sizeof(*root->free_ino_pinned), | ||
1307 | GFP_NOFS); | ||
1308 | if (!root->free_ino_pinned) | ||
1309 | goto fail; | ||
1310 | |||
1311 | btrfs_init_free_ino_ctl(root); | ||
1312 | mutex_init(&root->fs_commit_mutex); | ||
1313 | spin_lock_init(&root->cache_lock); | ||
1314 | init_waitqueue_head(&root->cache_wait); | ||
1315 | |||
1301 | set_anon_super(&root->anon_super, NULL); | 1316 | set_anon_super(&root->anon_super, NULL); |
1302 | 1317 | ||
1303 | if (btrfs_root_refs(&root->root_item) == 0) { | 1318 | if (btrfs_root_refs(&root->root_item) == 0) { |
@@ -1631,6 +1646,13 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1631 | 1646 | ||
1632 | INIT_LIST_HEAD(&fs_info->ordered_extents); | 1647 | INIT_LIST_HEAD(&fs_info->ordered_extents); |
1633 | spin_lock_init(&fs_info->ordered_extent_lock); | 1648 | spin_lock_init(&fs_info->ordered_extent_lock); |
1649 | fs_info->delayed_root = kmalloc(sizeof(struct btrfs_delayed_root), | ||
1650 | GFP_NOFS); | ||
1651 | if (!fs_info->delayed_root) { | ||
1652 | err = -ENOMEM; | ||
1653 | goto fail_iput; | ||
1654 | } | ||
1655 | btrfs_init_delayed_root(fs_info->delayed_root); | ||
1634 | 1656 | ||
1635 | sb->s_blocksize = 4096; | 1657 | sb->s_blocksize = 4096; |
1636 | sb->s_blocksize_bits = blksize_bits(4096); | 1658 | sb->s_blocksize_bits = blksize_bits(4096); |
@@ -1696,7 +1718,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1696 | bh = btrfs_read_dev_super(fs_devices->latest_bdev); | 1718 | bh = btrfs_read_dev_super(fs_devices->latest_bdev); |
1697 | if (!bh) { | 1719 | if (!bh) { |
1698 | err = -EINVAL; | 1720 | err = -EINVAL; |
1699 | goto fail_iput; | 1721 | goto fail_alloc; |
1700 | } | 1722 | } |
1701 | 1723 | ||
1702 | memcpy(&fs_info->super_copy, bh->b_data, sizeof(fs_info->super_copy)); | 1724 | memcpy(&fs_info->super_copy, bh->b_data, sizeof(fs_info->super_copy)); |
@@ -1708,7 +1730,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1708 | 1730 | ||
1709 | disk_super = &fs_info->super_copy; | 1731 | disk_super = &fs_info->super_copy; |
1710 | if (!btrfs_super_root(disk_super)) | 1732 | if (!btrfs_super_root(disk_super)) |
1711 | goto fail_iput; | 1733 | goto fail_alloc; |
1712 | 1734 | ||
1713 | /* check FS state, whether FS is broken. */ | 1735 | /* check FS state, whether FS is broken. */ |
1714 | fs_info->fs_state |= btrfs_super_flags(disk_super); | 1736 | fs_info->fs_state |= btrfs_super_flags(disk_super); |
@@ -1724,7 +1746,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1724 | ret = btrfs_parse_options(tree_root, options); | 1746 | ret = btrfs_parse_options(tree_root, options); |
1725 | if (ret) { | 1747 | if (ret) { |
1726 | err = ret; | 1748 | err = ret; |
1727 | goto fail_iput; | 1749 | goto fail_alloc; |
1728 | } | 1750 | } |
1729 | 1751 | ||
1730 | features = btrfs_super_incompat_flags(disk_super) & | 1752 | features = btrfs_super_incompat_flags(disk_super) & |
@@ -1734,7 +1756,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1734 | "unsupported optional features (%Lx).\n", | 1756 | "unsupported optional features (%Lx).\n", |
1735 | (unsigned long long)features); | 1757 | (unsigned long long)features); |
1736 | err = -EINVAL; | 1758 | err = -EINVAL; |
1737 | goto fail_iput; | 1759 | goto fail_alloc; |
1738 | } | 1760 | } |
1739 | 1761 | ||
1740 | features = btrfs_super_incompat_flags(disk_super); | 1762 | features = btrfs_super_incompat_flags(disk_super); |
@@ -1750,7 +1772,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1750 | "unsupported option features (%Lx).\n", | 1772 | "unsupported option features (%Lx).\n", |
1751 | (unsigned long long)features); | 1773 | (unsigned long long)features); |
1752 | err = -EINVAL; | 1774 | err = -EINVAL; |
1753 | goto fail_iput; | 1775 | goto fail_alloc; |
1754 | } | 1776 | } |
1755 | 1777 | ||
1756 | btrfs_init_workers(&fs_info->generic_worker, | 1778 | btrfs_init_workers(&fs_info->generic_worker, |
@@ -1797,6 +1819,9 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1797 | &fs_info->generic_worker); | 1819 | &fs_info->generic_worker); |
1798 | btrfs_init_workers(&fs_info->endio_freespace_worker, "freespace-write", | 1820 | btrfs_init_workers(&fs_info->endio_freespace_worker, "freespace-write", |
1799 | 1, &fs_info->generic_worker); | 1821 | 1, &fs_info->generic_worker); |
1822 | btrfs_init_workers(&fs_info->delayed_workers, "delayed-meta", | ||
1823 | fs_info->thread_pool_size, | ||
1824 | &fs_info->generic_worker); | ||
1800 | 1825 | ||
1801 | /* | 1826 | /* |
1802 | * endios are largely parallel and should have a very | 1827 | * endios are largely parallel and should have a very |
@@ -1818,6 +1843,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1818 | btrfs_start_workers(&fs_info->endio_meta_write_workers, 1); | 1843 | btrfs_start_workers(&fs_info->endio_meta_write_workers, 1); |
1819 | btrfs_start_workers(&fs_info->endio_write_workers, 1); | 1844 | btrfs_start_workers(&fs_info->endio_write_workers, 1); |
1820 | btrfs_start_workers(&fs_info->endio_freespace_worker, 1); | 1845 | btrfs_start_workers(&fs_info->endio_freespace_worker, 1); |
1846 | btrfs_start_workers(&fs_info->delayed_workers, 1); | ||
1821 | 1847 | ||
1822 | fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); | 1848 | fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); |
1823 | fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, | 1849 | fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, |
@@ -2074,6 +2100,9 @@ fail_sb_buffer: | |||
2074 | btrfs_stop_workers(&fs_info->endio_write_workers); | 2100 | btrfs_stop_workers(&fs_info->endio_write_workers); |
2075 | btrfs_stop_workers(&fs_info->endio_freespace_worker); | 2101 | btrfs_stop_workers(&fs_info->endio_freespace_worker); |
2076 | btrfs_stop_workers(&fs_info->submit_workers); | 2102 | btrfs_stop_workers(&fs_info->submit_workers); |
2103 | btrfs_stop_workers(&fs_info->delayed_workers); | ||
2104 | fail_alloc: | ||
2105 | kfree(fs_info->delayed_root); | ||
2077 | fail_iput: | 2106 | fail_iput: |
2078 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); | 2107 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); |
2079 | iput(fs_info->btree_inode); | 2108 | iput(fs_info->btree_inode); |
@@ -2338,12 +2367,15 @@ int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root) | |||
2338 | if (btrfs_root_refs(&root->root_item) == 0) | 2367 | if (btrfs_root_refs(&root->root_item) == 0) |
2339 | synchronize_srcu(&fs_info->subvol_srcu); | 2368 | synchronize_srcu(&fs_info->subvol_srcu); |
2340 | 2369 | ||
2370 | __btrfs_remove_free_space_cache(root->free_ino_pinned); | ||
2371 | __btrfs_remove_free_space_cache(root->free_ino_ctl); | ||
2341 | free_fs_root(root); | 2372 | free_fs_root(root); |
2342 | return 0; | 2373 | return 0; |
2343 | } | 2374 | } |
2344 | 2375 | ||
2345 | static void free_fs_root(struct btrfs_root *root) | 2376 | static void free_fs_root(struct btrfs_root *root) |
2346 | { | 2377 | { |
2378 | iput(root->cache_inode); | ||
2347 | WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); | 2379 | WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); |
2348 | if (root->anon_super.s_dev) { | 2380 | if (root->anon_super.s_dev) { |
2349 | down_write(&root->anon_super.s_umount); | 2381 | down_write(&root->anon_super.s_umount); |
@@ -2351,6 +2383,8 @@ static void free_fs_root(struct btrfs_root *root) | |||
2351 | } | 2383 | } |
2352 | free_extent_buffer(root->node); | 2384 | free_extent_buffer(root->node); |
2353 | free_extent_buffer(root->commit_root); | 2385 | free_extent_buffer(root->commit_root); |
2386 | kfree(root->free_ino_ctl); | ||
2387 | kfree(root->free_ino_pinned); | ||
2354 | kfree(root->name); | 2388 | kfree(root->name); |
2355 | kfree(root); | 2389 | kfree(root); |
2356 | } | 2390 | } |
@@ -2512,6 +2546,7 @@ int close_ctree(struct btrfs_root *root) | |||
2512 | del_fs_roots(fs_info); | 2546 | del_fs_roots(fs_info); |
2513 | 2547 | ||
2514 | iput(fs_info->btree_inode); | 2548 | iput(fs_info->btree_inode); |
2549 | kfree(fs_info->delayed_root); | ||
2515 | 2550 | ||
2516 | btrfs_stop_workers(&fs_info->generic_worker); | 2551 | btrfs_stop_workers(&fs_info->generic_worker); |
2517 | btrfs_stop_workers(&fs_info->fixup_workers); | 2552 | btrfs_stop_workers(&fs_info->fixup_workers); |
@@ -2523,6 +2558,7 @@ int close_ctree(struct btrfs_root *root) | |||
2523 | btrfs_stop_workers(&fs_info->endio_write_workers); | 2558 | btrfs_stop_workers(&fs_info->endio_write_workers); |
2524 | btrfs_stop_workers(&fs_info->endio_freespace_worker); | 2559 | btrfs_stop_workers(&fs_info->endio_freespace_worker); |
2525 | btrfs_stop_workers(&fs_info->submit_workers); | 2560 | btrfs_stop_workers(&fs_info->submit_workers); |
2561 | btrfs_stop_workers(&fs_info->delayed_workers); | ||
2526 | 2562 | ||
2527 | btrfs_close_devices(fs_info->fs_devices); | 2563 | btrfs_close_devices(fs_info->fs_devices); |
2528 | btrfs_mapping_tree_free(&fs_info->mapping_tree); | 2564 | btrfs_mapping_tree_free(&fs_info->mapping_tree); |
@@ -2599,6 +2635,29 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr) | |||
2599 | if (current->flags & PF_MEMALLOC) | 2635 | if (current->flags & PF_MEMALLOC) |
2600 | return; | 2636 | return; |
2601 | 2637 | ||
2638 | btrfs_balance_delayed_items(root); | ||
2639 | |||
2640 | num_dirty = root->fs_info->dirty_metadata_bytes; | ||
2641 | |||
2642 | if (num_dirty > thresh) { | ||
2643 | balance_dirty_pages_ratelimited_nr( | ||
2644 | root->fs_info->btree_inode->i_mapping, 1); | ||
2645 | } | ||
2646 | return; | ||
2647 | } | ||
2648 | |||
2649 | void __btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr) | ||
2650 | { | ||
2651 | /* | ||
2652 | * looks as though older kernels can get into trouble with | ||
2653 | * this code, they end up stuck in balance_dirty_pages forever | ||
2654 | */ | ||
2655 | u64 num_dirty; | ||
2656 | unsigned long thresh = 32 * 1024 * 1024; | ||
2657 | |||
2658 | if (current->flags & PF_MEMALLOC) | ||
2659 | return; | ||
2660 | |||
2602 | num_dirty = root->fs_info->dirty_metadata_bytes; | 2661 | num_dirty = root->fs_info->dirty_metadata_bytes; |
2603 | 2662 | ||
2604 | if (num_dirty > thresh) { | 2663 | if (num_dirty > thresh) { |
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 2d75f9e896f..a0b610a67aa 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h | |||
@@ -61,6 +61,7 @@ struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info, | |||
61 | struct btrfs_key *location); | 61 | struct btrfs_key *location); |
62 | int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info); | 62 | int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info); |
63 | void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr); | 63 | void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr); |
64 | void __btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr); | ||
64 | int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root); | 65 | int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root); |
65 | void btrfs_mark_buffer_dirty(struct extent_buffer *buf); | 66 | void btrfs_mark_buffer_dirty(struct extent_buffer *buf); |
66 | int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid); | 67 | int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid); |
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c index b4ffad859ad..1b8dc33778f 100644 --- a/fs/btrfs/export.c +++ b/fs/btrfs/export.c | |||
@@ -32,7 +32,7 @@ static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len, | |||
32 | len = BTRFS_FID_SIZE_NON_CONNECTABLE; | 32 | len = BTRFS_FID_SIZE_NON_CONNECTABLE; |
33 | type = FILEID_BTRFS_WITHOUT_PARENT; | 33 | type = FILEID_BTRFS_WITHOUT_PARENT; |
34 | 34 | ||
35 | fid->objectid = inode->i_ino; | 35 | fid->objectid = btrfs_ino(inode); |
36 | fid->root_objectid = BTRFS_I(inode)->root->objectid; | 36 | fid->root_objectid = BTRFS_I(inode)->root->objectid; |
37 | fid->gen = inode->i_generation; | 37 | fid->gen = inode->i_generation; |
38 | 38 | ||
@@ -178,13 +178,13 @@ static struct dentry *btrfs_get_parent(struct dentry *child) | |||
178 | if (!path) | 178 | if (!path) |
179 | return ERR_PTR(-ENOMEM); | 179 | return ERR_PTR(-ENOMEM); |
180 | 180 | ||
181 | if (dir->i_ino == BTRFS_FIRST_FREE_OBJECTID) { | 181 | if (btrfs_ino(dir) == BTRFS_FIRST_FREE_OBJECTID) { |
182 | key.objectid = root->root_key.objectid; | 182 | key.objectid = root->root_key.objectid; |
183 | key.type = BTRFS_ROOT_BACKREF_KEY; | 183 | key.type = BTRFS_ROOT_BACKREF_KEY; |
184 | key.offset = (u64)-1; | 184 | key.offset = (u64)-1; |
185 | root = root->fs_info->tree_root; | 185 | root = root->fs_info->tree_root; |
186 | } else { | 186 | } else { |
187 | key.objectid = dir->i_ino; | 187 | key.objectid = btrfs_ino(dir); |
188 | key.type = BTRFS_INODE_REF_KEY; | 188 | key.type = BTRFS_INODE_REF_KEY; |
189 | key.offset = (u64)-1; | 189 | key.offset = (u64)-1; |
190 | } | 190 | } |
@@ -244,6 +244,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, | |||
244 | struct btrfs_key key; | 244 | struct btrfs_key key; |
245 | int name_len; | 245 | int name_len; |
246 | int ret; | 246 | int ret; |
247 | u64 ino; | ||
247 | 248 | ||
248 | if (!dir || !inode) | 249 | if (!dir || !inode) |
249 | return -EINVAL; | 250 | return -EINVAL; |
@@ -251,19 +252,21 @@ static int btrfs_get_name(struct dentry *parent, char *name, | |||
251 | if (!S_ISDIR(dir->i_mode)) | 252 | if (!S_ISDIR(dir->i_mode)) |
252 | return -EINVAL; | 253 | return -EINVAL; |
253 | 254 | ||
255 | ino = btrfs_ino(inode); | ||
256 | |||
254 | path = btrfs_alloc_path(); | 257 | path = btrfs_alloc_path(); |
255 | if (!path) | 258 | if (!path) |
256 | return -ENOMEM; | 259 | return -ENOMEM; |
257 | path->leave_spinning = 1; | 260 | path->leave_spinning = 1; |
258 | 261 | ||
259 | if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { | 262 | if (ino == BTRFS_FIRST_FREE_OBJECTID) { |
260 | key.objectid = BTRFS_I(inode)->root->root_key.objectid; | 263 | key.objectid = BTRFS_I(inode)->root->root_key.objectid; |
261 | key.type = BTRFS_ROOT_BACKREF_KEY; | 264 | key.type = BTRFS_ROOT_BACKREF_KEY; |
262 | key.offset = (u64)-1; | 265 | key.offset = (u64)-1; |
263 | root = root->fs_info->tree_root; | 266 | root = root->fs_info->tree_root; |
264 | } else { | 267 | } else { |
265 | key.objectid = inode->i_ino; | 268 | key.objectid = ino; |
266 | key.offset = dir->i_ino; | 269 | key.offset = btrfs_ino(dir); |
267 | key.type = BTRFS_INODE_REF_KEY; | 270 | key.type = BTRFS_INODE_REF_KEY; |
268 | } | 271 | } |
269 | 272 | ||
@@ -272,7 +275,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, | |||
272 | btrfs_free_path(path); | 275 | btrfs_free_path(path); |
273 | return ret; | 276 | return ret; |
274 | } else if (ret > 0) { | 277 | } else if (ret > 0) { |
275 | if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { | 278 | if (ino == BTRFS_FIRST_FREE_OBJECTID) { |
276 | path->slots[0]--; | 279 | path->slots[0]--; |
277 | } else { | 280 | } else { |
278 | btrfs_free_path(path); | 281 | btrfs_free_path(path); |
@@ -281,11 +284,11 @@ static int btrfs_get_name(struct dentry *parent, char *name, | |||
281 | } | 284 | } |
282 | leaf = path->nodes[0]; | 285 | leaf = path->nodes[0]; |
283 | 286 | ||
284 | if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { | 287 | if (ino == BTRFS_FIRST_FREE_OBJECTID) { |
285 | rref = btrfs_item_ptr(leaf, path->slots[0], | 288 | rref = btrfs_item_ptr(leaf, path->slots[0], |
286 | struct btrfs_root_ref); | 289 | struct btrfs_root_ref); |
287 | name_ptr = (unsigned long)(rref + 1); | 290 | name_ptr = (unsigned long)(rref + 1); |
288 | name_len = btrfs_root_ref_name_len(leaf, rref); | 291 | name_len = btrfs_root_ref_name_len(leaf, rref); |
289 | } else { | 292 | } else { |
290 | iref = btrfs_item_ptr(leaf, path->slots[0], | 293 | iref = btrfs_item_ptr(leaf, path->slots[0], |
291 | struct btrfs_inode_ref); | 294 | struct btrfs_inode_ref); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index b457f195636..98ca149bdbc 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -105,6 +105,7 @@ void btrfs_put_block_group(struct btrfs_block_group_cache *cache) | |||
105 | WARN_ON(cache->pinned > 0); | 105 | WARN_ON(cache->pinned > 0); |
106 | WARN_ON(cache->reserved > 0); | 106 | WARN_ON(cache->reserved > 0); |
107 | WARN_ON(cache->reserved_pinned > 0); | 107 | WARN_ON(cache->reserved_pinned > 0); |
108 | kfree(cache->free_space_ctl); | ||
108 | kfree(cache); | 109 | kfree(cache); |
109 | } | 110 | } |
110 | } | 111 | } |
@@ -3036,7 +3037,8 @@ int btrfs_check_data_free_space(struct inode *inode, u64 bytes) | |||
3036 | /* make sure bytes are sectorsize aligned */ | 3037 | /* make sure bytes are sectorsize aligned */ |
3037 | bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1); | 3038 | bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1); |
3038 | 3039 | ||
3039 | if (root == root->fs_info->tree_root) { | 3040 | if (root == root->fs_info->tree_root || |
3041 | BTRFS_I(inode)->location.objectid == BTRFS_FREE_INO_OBJECTID) { | ||
3040 | alloc_chunk = 0; | 3042 | alloc_chunk = 0; |
3041 | committed = 1; | 3043 | committed = 1; |
3042 | } | 3044 | } |
@@ -3834,12 +3836,6 @@ static void release_global_block_rsv(struct btrfs_fs_info *fs_info) | |||
3834 | WARN_ON(fs_info->chunk_block_rsv.reserved > 0); | 3836 | WARN_ON(fs_info->chunk_block_rsv.reserved > 0); |
3835 | } | 3837 | } |
3836 | 3838 | ||
3837 | static u64 calc_trans_metadata_size(struct btrfs_root *root, int num_items) | ||
3838 | { | ||
3839 | return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) * | ||
3840 | 3 * num_items; | ||
3841 | } | ||
3842 | |||
3843 | int btrfs_trans_reserve_metadata(struct btrfs_trans_handle *trans, | 3839 | int btrfs_trans_reserve_metadata(struct btrfs_trans_handle *trans, |
3844 | struct btrfs_root *root, | 3840 | struct btrfs_root *root, |
3845 | int num_items) | 3841 | int num_items) |
@@ -3850,7 +3846,7 @@ int btrfs_trans_reserve_metadata(struct btrfs_trans_handle *trans, | |||
3850 | if (num_items == 0 || root->fs_info->chunk_root == root) | 3846 | if (num_items == 0 || root->fs_info->chunk_root == root) |
3851 | return 0; | 3847 | return 0; |
3852 | 3848 | ||
3853 | num_bytes = calc_trans_metadata_size(root, num_items); | 3849 | num_bytes = btrfs_calc_trans_metadata_size(root, num_items); |
3854 | ret = btrfs_block_rsv_add(trans, root, &root->fs_info->trans_block_rsv, | 3850 | ret = btrfs_block_rsv_add(trans, root, &root->fs_info->trans_block_rsv, |
3855 | num_bytes); | 3851 | num_bytes); |
3856 | if (!ret) { | 3852 | if (!ret) { |
@@ -3889,14 +3885,14 @@ int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans, | |||
3889 | * If all of the metadata space is used, we can commit | 3885 | * If all of the metadata space is used, we can commit |
3890 | * transaction and use space it freed. | 3886 | * transaction and use space it freed. |
3891 | */ | 3887 | */ |
3892 | u64 num_bytes = calc_trans_metadata_size(root, 4); | 3888 | u64 num_bytes = btrfs_calc_trans_metadata_size(root, 4); |
3893 | return block_rsv_migrate_bytes(src_rsv, dst_rsv, num_bytes); | 3889 | return block_rsv_migrate_bytes(src_rsv, dst_rsv, num_bytes); |
3894 | } | 3890 | } |
3895 | 3891 | ||
3896 | void btrfs_orphan_release_metadata(struct inode *inode) | 3892 | void btrfs_orphan_release_metadata(struct inode *inode) |
3897 | { | 3893 | { |
3898 | struct btrfs_root *root = BTRFS_I(inode)->root; | 3894 | struct btrfs_root *root = BTRFS_I(inode)->root; |
3899 | u64 num_bytes = calc_trans_metadata_size(root, 4); | 3895 | u64 num_bytes = btrfs_calc_trans_metadata_size(root, 4); |
3900 | btrfs_block_rsv_release(root, root->orphan_block_rsv, num_bytes); | 3896 | btrfs_block_rsv_release(root, root->orphan_block_rsv, num_bytes); |
3901 | } | 3897 | } |
3902 | 3898 | ||
@@ -3910,7 +3906,7 @@ int btrfs_snap_reserve_metadata(struct btrfs_trans_handle *trans, | |||
3910 | * two for root back/forward refs, two for directory entries | 3906 | * two for root back/forward refs, two for directory entries |
3911 | * and one for root of the snapshot. | 3907 | * and one for root of the snapshot. |
3912 | */ | 3908 | */ |
3913 | u64 num_bytes = calc_trans_metadata_size(root, 5); | 3909 | u64 num_bytes = btrfs_calc_trans_metadata_size(root, 5); |
3914 | dst_rsv->space_info = src_rsv->space_info; | 3910 | dst_rsv->space_info = src_rsv->space_info; |
3915 | return block_rsv_migrate_bytes(src_rsv, dst_rsv, num_bytes); | 3911 | return block_rsv_migrate_bytes(src_rsv, dst_rsv, num_bytes); |
3916 | } | 3912 | } |
@@ -3939,7 +3935,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) | |||
3939 | 3935 | ||
3940 | if (nr_extents > reserved_extents) { | 3936 | if (nr_extents > reserved_extents) { |
3941 | nr_extents -= reserved_extents; | 3937 | nr_extents -= reserved_extents; |
3942 | to_reserve = calc_trans_metadata_size(root, nr_extents); | 3938 | to_reserve = btrfs_calc_trans_metadata_size(root, nr_extents); |
3943 | } else { | 3939 | } else { |
3944 | nr_extents = 0; | 3940 | nr_extents = 0; |
3945 | to_reserve = 0; | 3941 | to_reserve = 0; |
@@ -3993,7 +3989,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes) | |||
3993 | 3989 | ||
3994 | to_free = calc_csum_metadata_size(inode, num_bytes); | 3990 | to_free = calc_csum_metadata_size(inode, num_bytes); |
3995 | if (nr_extents > 0) | 3991 | if (nr_extents > 0) |
3996 | to_free += calc_trans_metadata_size(root, nr_extents); | 3992 | to_free += btrfs_calc_trans_metadata_size(root, nr_extents); |
3997 | 3993 | ||
3998 | btrfs_block_rsv_release(root, &root->fs_info->delalloc_block_rsv, | 3994 | btrfs_block_rsv_release(root, &root->fs_info->delalloc_block_rsv, |
3999 | to_free); | 3995 | to_free); |
@@ -4754,7 +4750,7 @@ wait_block_group_cache_progress(struct btrfs_block_group_cache *cache, | |||
4754 | return 0; | 4750 | return 0; |
4755 | 4751 | ||
4756 | wait_event(caching_ctl->wait, block_group_cache_done(cache) || | 4752 | wait_event(caching_ctl->wait, block_group_cache_done(cache) || |
4757 | (cache->free_space >= num_bytes)); | 4753 | (cache->free_space_ctl->free_space >= num_bytes)); |
4758 | 4754 | ||
4759 | put_caching_control(caching_ctl); | 4755 | put_caching_control(caching_ctl); |
4760 | return 0; | 4756 | return 0; |
@@ -6908,10 +6904,16 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
6908 | ret = -ENOMEM; | 6904 | ret = -ENOMEM; |
6909 | goto error; | 6905 | goto error; |
6910 | } | 6906 | } |
6907 | cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl), | ||
6908 | GFP_NOFS); | ||
6909 | if (!cache->free_space_ctl) { | ||
6910 | kfree(cache); | ||
6911 | ret = -ENOMEM; | ||
6912 | goto error; | ||
6913 | } | ||
6911 | 6914 | ||
6912 | atomic_set(&cache->count, 1); | 6915 | atomic_set(&cache->count, 1); |
6913 | spin_lock_init(&cache->lock); | 6916 | spin_lock_init(&cache->lock); |
6914 | spin_lock_init(&cache->tree_lock); | ||
6915 | cache->fs_info = info; | 6917 | cache->fs_info = info; |
6916 | INIT_LIST_HEAD(&cache->list); | 6918 | INIT_LIST_HEAD(&cache->list); |
6917 | INIT_LIST_HEAD(&cache->cluster_list); | 6919 | INIT_LIST_HEAD(&cache->cluster_list); |
@@ -6919,14 +6921,6 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
6919 | if (need_clear) | 6921 | if (need_clear) |
6920 | cache->disk_cache_state = BTRFS_DC_CLEAR; | 6922 | cache->disk_cache_state = BTRFS_DC_CLEAR; |
6921 | 6923 | ||
6922 | /* | ||
6923 | * we only want to have 32k of ram per block group for keeping | ||
6924 | * track of free space, and if we pass 1/2 of that we want to | ||
6925 | * start converting things over to using bitmaps | ||
6926 | */ | ||
6927 | cache->extents_thresh = ((1024 * 32) / 2) / | ||
6928 | sizeof(struct btrfs_free_space); | ||
6929 | |||
6930 | read_extent_buffer(leaf, &cache->item, | 6924 | read_extent_buffer(leaf, &cache->item, |
6931 | btrfs_item_ptr_offset(leaf, path->slots[0]), | 6925 | btrfs_item_ptr_offset(leaf, path->slots[0]), |
6932 | sizeof(cache->item)); | 6926 | sizeof(cache->item)); |
@@ -6937,6 +6931,8 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
6937 | cache->flags = btrfs_block_group_flags(&cache->item); | 6931 | cache->flags = btrfs_block_group_flags(&cache->item); |
6938 | cache->sectorsize = root->sectorsize; | 6932 | cache->sectorsize = root->sectorsize; |
6939 | 6933 | ||
6934 | btrfs_init_free_space_ctl(cache); | ||
6935 | |||
6940 | /* | 6936 | /* |
6941 | * We need to exclude the super stripes now so that the space | 6937 | * We need to exclude the super stripes now so that the space |
6942 | * info has super bytes accounted for, otherwise we'll think | 6938 | * info has super bytes accounted for, otherwise we'll think |
@@ -7023,6 +7019,12 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, | |||
7023 | cache = kzalloc(sizeof(*cache), GFP_NOFS); | 7019 | cache = kzalloc(sizeof(*cache), GFP_NOFS); |
7024 | if (!cache) | 7020 | if (!cache) |
7025 | return -ENOMEM; | 7021 | return -ENOMEM; |
7022 | cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl), | ||
7023 | GFP_NOFS); | ||
7024 | if (!cache->free_space_ctl) { | ||
7025 | kfree(cache); | ||
7026 | return -ENOMEM; | ||
7027 | } | ||
7026 | 7028 | ||
7027 | cache->key.objectid = chunk_offset; | 7029 | cache->key.objectid = chunk_offset; |
7028 | cache->key.offset = size; | 7030 | cache->key.offset = size; |
@@ -7030,19 +7032,13 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, | |||
7030 | cache->sectorsize = root->sectorsize; | 7032 | cache->sectorsize = root->sectorsize; |
7031 | cache->fs_info = root->fs_info; | 7033 | cache->fs_info = root->fs_info; |
7032 | 7034 | ||
7033 | /* | ||
7034 | * we only want to have 32k of ram per block group for keeping track | ||
7035 | * of free space, and if we pass 1/2 of that we want to start | ||
7036 | * converting things over to using bitmaps | ||
7037 | */ | ||
7038 | cache->extents_thresh = ((1024 * 32) / 2) / | ||
7039 | sizeof(struct btrfs_free_space); | ||
7040 | atomic_set(&cache->count, 1); | 7035 | atomic_set(&cache->count, 1); |
7041 | spin_lock_init(&cache->lock); | 7036 | spin_lock_init(&cache->lock); |
7042 | spin_lock_init(&cache->tree_lock); | ||
7043 | INIT_LIST_HEAD(&cache->list); | 7037 | INIT_LIST_HEAD(&cache->list); |
7044 | INIT_LIST_HEAD(&cache->cluster_list); | 7038 | INIT_LIST_HEAD(&cache->cluster_list); |
7045 | 7039 | ||
7040 | btrfs_init_free_space_ctl(cache); | ||
7041 | |||
7046 | btrfs_set_block_group_used(&cache->item, bytes_used); | 7042 | btrfs_set_block_group_used(&cache->item, bytes_used); |
7047 | btrfs_set_block_group_chunk_objectid(&cache->item, chunk_objectid); | 7043 | btrfs_set_block_group_chunk_objectid(&cache->item, chunk_objectid); |
7048 | cache->flags = type; | 7044 | cache->flags = type; |
@@ -7209,23 +7205,38 @@ out: | |||
7209 | int btrfs_init_space_info(struct btrfs_fs_info *fs_info) | 7205 | int btrfs_init_space_info(struct btrfs_fs_info *fs_info) |
7210 | { | 7206 | { |
7211 | struct btrfs_space_info *space_info; | 7207 | struct btrfs_space_info *space_info; |
7208 | struct btrfs_super_block *disk_super; | ||
7209 | u64 features; | ||
7210 | u64 flags; | ||
7211 | int mixed = 0; | ||
7212 | int ret; | 7212 | int ret; |
7213 | 7213 | ||
7214 | ret = update_space_info(fs_info, BTRFS_BLOCK_GROUP_SYSTEM, 0, 0, | 7214 | disk_super = &fs_info->super_copy; |
7215 | &space_info); | 7215 | if (!btrfs_super_root(disk_super)) |
7216 | if (ret) | 7216 | return 1; |
7217 | return ret; | ||
7218 | 7217 | ||
7219 | ret = update_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA, 0, 0, | 7218 | features = btrfs_super_incompat_flags(disk_super); |
7220 | &space_info); | 7219 | if (features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS) |
7221 | if (ret) | 7220 | mixed = 1; |
7222 | return ret; | ||
7223 | 7221 | ||
7224 | ret = update_space_info(fs_info, BTRFS_BLOCK_GROUP_DATA, 0, 0, | 7222 | flags = BTRFS_BLOCK_GROUP_SYSTEM; |
7225 | &space_info); | 7223 | ret = update_space_info(fs_info, flags, 0, 0, &space_info); |
7226 | if (ret) | 7224 | if (ret) |
7227 | return ret; | 7225 | goto out; |
7228 | 7226 | ||
7227 | if (mixed) { | ||
7228 | flags = BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA; | ||
7229 | ret = update_space_info(fs_info, flags, 0, 0, &space_info); | ||
7230 | } else { | ||
7231 | flags = BTRFS_BLOCK_GROUP_METADATA; | ||
7232 | ret = update_space_info(fs_info, flags, 0, 0, &space_info); | ||
7233 | if (ret) | ||
7234 | goto out; | ||
7235 | |||
7236 | flags = BTRFS_BLOCK_GROUP_DATA; | ||
7237 | ret = update_space_info(fs_info, flags, 0, 0, &space_info); | ||
7238 | } | ||
7239 | out: | ||
7229 | return ret; | 7240 | return ret; |
7230 | } | 7241 | } |
7231 | 7242 | ||
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 91208296ff2..64c8b361b53 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -2810,7 +2810,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | |||
2810 | * because there might be preallocation past i_size | 2810 | * because there might be preallocation past i_size |
2811 | */ | 2811 | */ |
2812 | ret = btrfs_lookup_file_extent(NULL, BTRFS_I(inode)->root, | 2812 | ret = btrfs_lookup_file_extent(NULL, BTRFS_I(inode)->root, |
2813 | path, inode->i_ino, -1, 0); | 2813 | path, btrfs_ino(inode), -1, 0); |
2814 | if (ret < 0) { | 2814 | if (ret < 0) { |
2815 | btrfs_free_path(path); | 2815 | btrfs_free_path(path); |
2816 | return ret; | 2816 | return ret; |
@@ -2823,7 +2823,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | |||
2823 | found_type = btrfs_key_type(&found_key); | 2823 | found_type = btrfs_key_type(&found_key); |
2824 | 2824 | ||
2825 | /* No extents, but there might be delalloc bits */ | 2825 | /* No extents, but there might be delalloc bits */ |
2826 | if (found_key.objectid != inode->i_ino || | 2826 | if (found_key.objectid != btrfs_ino(inode) || |
2827 | found_type != BTRFS_EXTENT_DATA_KEY) { | 2827 | found_type != BTRFS_EXTENT_DATA_KEY) { |
2828 | /* have to trust i_size as the end */ | 2828 | /* have to trust i_size as the end */ |
2829 | last = (u64)-1; | 2829 | last = (u64)-1; |
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index f47e43d855a..29e014984f6 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c | |||
@@ -208,8 +208,9 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root, | |||
208 | EXTENT_NODATASUM, GFP_NOFS); | 208 | EXTENT_NODATASUM, GFP_NOFS); |
209 | } else { | 209 | } else { |
210 | printk(KERN_INFO "btrfs no csum found " | 210 | printk(KERN_INFO "btrfs no csum found " |
211 | "for inode %lu start %llu\n", | 211 | "for inode %llu start %llu\n", |
212 | inode->i_ino, | 212 | (unsigned long long) |
213 | btrfs_ino(inode), | ||
213 | (unsigned long long)offset); | 214 | (unsigned long long)offset); |
214 | } | 215 | } |
215 | item = NULL; | 216 | item = NULL; |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 566bdf298ea..58ddc444215 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -298,6 +298,7 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode, | |||
298 | struct btrfs_path *path; | 298 | struct btrfs_path *path; |
299 | struct btrfs_key key; | 299 | struct btrfs_key key; |
300 | struct btrfs_key new_key; | 300 | struct btrfs_key new_key; |
301 | u64 ino = btrfs_ino(inode); | ||
301 | u64 search_start = start; | 302 | u64 search_start = start; |
302 | u64 disk_bytenr = 0; | 303 | u64 disk_bytenr = 0; |
303 | u64 num_bytes = 0; | 304 | u64 num_bytes = 0; |
@@ -318,14 +319,14 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode, | |||
318 | 319 | ||
319 | while (1) { | 320 | while (1) { |
320 | recow = 0; | 321 | recow = 0; |
321 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, | 322 | ret = btrfs_lookup_file_extent(trans, root, path, ino, |
322 | search_start, -1); | 323 | search_start, -1); |
323 | if (ret < 0) | 324 | if (ret < 0) |
324 | break; | 325 | break; |
325 | if (ret > 0 && path->slots[0] > 0 && search_start == start) { | 326 | if (ret > 0 && path->slots[0] > 0 && search_start == start) { |
326 | leaf = path->nodes[0]; | 327 | leaf = path->nodes[0]; |
327 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0] - 1); | 328 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0] - 1); |
328 | if (key.objectid == inode->i_ino && | 329 | if (key.objectid == ino && |
329 | key.type == BTRFS_EXTENT_DATA_KEY) | 330 | key.type == BTRFS_EXTENT_DATA_KEY) |
330 | path->slots[0]--; | 331 | path->slots[0]--; |
331 | } | 332 | } |
@@ -346,7 +347,7 @@ next_slot: | |||
346 | } | 347 | } |
347 | 348 | ||
348 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); | 349 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); |
349 | if (key.objectid > inode->i_ino || | 350 | if (key.objectid > ino || |
350 | key.type > BTRFS_EXTENT_DATA_KEY || key.offset >= end) | 351 | key.type > BTRFS_EXTENT_DATA_KEY || key.offset >= end) |
351 | break; | 352 | break; |
352 | 353 | ||
@@ -592,6 +593,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, | |||
592 | int del_slot = 0; | 593 | int del_slot = 0; |
593 | int recow; | 594 | int recow; |
594 | int ret; | 595 | int ret; |
596 | u64 ino = btrfs_ino(inode); | ||
595 | 597 | ||
596 | btrfs_drop_extent_cache(inode, start, end - 1, 0); | 598 | btrfs_drop_extent_cache(inode, start, end - 1, 0); |
597 | 599 | ||
@@ -600,7 +602,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, | |||
600 | again: | 602 | again: |
601 | recow = 0; | 603 | recow = 0; |
602 | split = start; | 604 | split = start; |
603 | key.objectid = inode->i_ino; | 605 | key.objectid = ino; |
604 | key.type = BTRFS_EXTENT_DATA_KEY; | 606 | key.type = BTRFS_EXTENT_DATA_KEY; |
605 | key.offset = split; | 607 | key.offset = split; |
606 | 608 | ||
@@ -612,8 +614,7 @@ again: | |||
612 | 614 | ||
613 | leaf = path->nodes[0]; | 615 | leaf = path->nodes[0]; |
614 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); | 616 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); |
615 | BUG_ON(key.objectid != inode->i_ino || | 617 | BUG_ON(key.objectid != ino || key.type != BTRFS_EXTENT_DATA_KEY); |
616 | key.type != BTRFS_EXTENT_DATA_KEY); | ||
617 | fi = btrfs_item_ptr(leaf, path->slots[0], | 618 | fi = btrfs_item_ptr(leaf, path->slots[0], |
618 | struct btrfs_file_extent_item); | 619 | struct btrfs_file_extent_item); |
619 | BUG_ON(btrfs_file_extent_type(leaf, fi) != | 620 | BUG_ON(btrfs_file_extent_type(leaf, fi) != |
@@ -630,7 +631,7 @@ again: | |||
630 | other_start = 0; | 631 | other_start = 0; |
631 | other_end = start; | 632 | other_end = start; |
632 | if (extent_mergeable(leaf, path->slots[0] - 1, | 633 | if (extent_mergeable(leaf, path->slots[0] - 1, |
633 | inode->i_ino, bytenr, orig_offset, | 634 | ino, bytenr, orig_offset, |
634 | &other_start, &other_end)) { | 635 | &other_start, &other_end)) { |
635 | new_key.offset = end; | 636 | new_key.offset = end; |
636 | btrfs_set_item_key_safe(trans, root, path, &new_key); | 637 | btrfs_set_item_key_safe(trans, root, path, &new_key); |
@@ -653,7 +654,7 @@ again: | |||
653 | other_start = end; | 654 | other_start = end; |
654 | other_end = 0; | 655 | other_end = 0; |
655 | if (extent_mergeable(leaf, path->slots[0] + 1, | 656 | if (extent_mergeable(leaf, path->slots[0] + 1, |
656 | inode->i_ino, bytenr, orig_offset, | 657 | ino, bytenr, orig_offset, |
657 | &other_start, &other_end)) { | 658 | &other_start, &other_end)) { |
658 | fi = btrfs_item_ptr(leaf, path->slots[0], | 659 | fi = btrfs_item_ptr(leaf, path->slots[0], |
659 | struct btrfs_file_extent_item); | 660 | struct btrfs_file_extent_item); |
@@ -702,7 +703,7 @@ again: | |||
702 | 703 | ||
703 | ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0, | 704 | ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0, |
704 | root->root_key.objectid, | 705 | root->root_key.objectid, |
705 | inode->i_ino, orig_offset); | 706 | ino, orig_offset); |
706 | BUG_ON(ret); | 707 | BUG_ON(ret); |
707 | 708 | ||
708 | if (split == start) { | 709 | if (split == start) { |
@@ -718,7 +719,7 @@ again: | |||
718 | other_start = end; | 719 | other_start = end; |
719 | other_end = 0; | 720 | other_end = 0; |
720 | if (extent_mergeable(leaf, path->slots[0] + 1, | 721 | if (extent_mergeable(leaf, path->slots[0] + 1, |
721 | inode->i_ino, bytenr, orig_offset, | 722 | ino, bytenr, orig_offset, |
722 | &other_start, &other_end)) { | 723 | &other_start, &other_end)) { |
723 | if (recow) { | 724 | if (recow) { |
724 | btrfs_release_path(path); | 725 | btrfs_release_path(path); |
@@ -729,13 +730,13 @@ again: | |||
729 | del_nr++; | 730 | del_nr++; |
730 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, | 731 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, |
731 | 0, root->root_key.objectid, | 732 | 0, root->root_key.objectid, |
732 | inode->i_ino, orig_offset); | 733 | ino, orig_offset); |
733 | BUG_ON(ret); | 734 | BUG_ON(ret); |
734 | } | 735 | } |
735 | other_start = 0; | 736 | other_start = 0; |
736 | other_end = start; | 737 | other_end = start; |
737 | if (extent_mergeable(leaf, path->slots[0] - 1, | 738 | if (extent_mergeable(leaf, path->slots[0] - 1, |
738 | inode->i_ino, bytenr, orig_offset, | 739 | ino, bytenr, orig_offset, |
739 | &other_start, &other_end)) { | 740 | &other_start, &other_end)) { |
740 | if (recow) { | 741 | if (recow) { |
741 | btrfs_release_path(path); | 742 | btrfs_release_path(path); |
@@ -746,7 +747,7 @@ again: | |||
746 | del_nr++; | 747 | del_nr++; |
747 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, | 748 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, |
748 | 0, root->root_key.objectid, | 749 | 0, root->root_key.objectid, |
749 | inode->i_ino, orig_offset); | 750 | ino, orig_offset); |
750 | BUG_ON(ret); | 751 | BUG_ON(ret); |
751 | } | 752 | } |
752 | if (del_nr == 0) { | 753 | if (del_nr == 0) { |
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 0290b0c7b00..70d45795d75 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -25,18 +25,17 @@ | |||
25 | #include "transaction.h" | 25 | #include "transaction.h" |
26 | #include "disk-io.h" | 26 | #include "disk-io.h" |
27 | #include "extent_io.h" | 27 | #include "extent_io.h" |
28 | #include "inode-map.h" | ||
28 | 29 | ||
29 | #define BITS_PER_BITMAP (PAGE_CACHE_SIZE * 8) | 30 | #define BITS_PER_BITMAP (PAGE_CACHE_SIZE * 8) |
30 | #define MAX_CACHE_BYTES_PER_GIG (32 * 1024) | 31 | #define MAX_CACHE_BYTES_PER_GIG (32 * 1024) |
31 | 32 | ||
32 | static void recalculate_thresholds(struct btrfs_block_group_cache | 33 | static int link_free_space(struct btrfs_free_space_ctl *ctl, |
33 | *block_group); | ||
34 | static int link_free_space(struct btrfs_block_group_cache *block_group, | ||
35 | struct btrfs_free_space *info); | 34 | struct btrfs_free_space *info); |
36 | 35 | ||
37 | struct inode *lookup_free_space_inode(struct btrfs_root *root, | 36 | static struct inode *__lookup_free_space_inode(struct btrfs_root *root, |
38 | struct btrfs_block_group_cache | 37 | struct btrfs_path *path, |
39 | *block_group, struct btrfs_path *path) | 38 | u64 offset) |
40 | { | 39 | { |
41 | struct btrfs_key key; | 40 | struct btrfs_key key; |
42 | struct btrfs_key location; | 41 | struct btrfs_key location; |
@@ -46,15 +45,8 @@ struct inode *lookup_free_space_inode(struct btrfs_root *root, | |||
46 | struct inode *inode = NULL; | 45 | struct inode *inode = NULL; |
47 | int ret; | 46 | int ret; |
48 | 47 | ||
49 | spin_lock(&block_group->lock); | ||
50 | if (block_group->inode) | ||
51 | inode = igrab(block_group->inode); | ||
52 | spin_unlock(&block_group->lock); | ||
53 | if (inode) | ||
54 | return inode; | ||
55 | |||
56 | key.objectid = BTRFS_FREE_SPACE_OBJECTID; | 48 | key.objectid = BTRFS_FREE_SPACE_OBJECTID; |
57 | key.offset = block_group->key.objectid; | 49 | key.offset = offset; |
58 | key.type = 0; | 50 | key.type = 0; |
59 | 51 | ||
60 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | 52 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
@@ -84,6 +76,27 @@ struct inode *lookup_free_space_inode(struct btrfs_root *root, | |||
84 | 76 | ||
85 | inode->i_mapping->flags &= ~__GFP_FS; | 77 | inode->i_mapping->flags &= ~__GFP_FS; |
86 | 78 | ||
79 | return inode; | ||
80 | } | ||
81 | |||
82 | struct inode *lookup_free_space_inode(struct btrfs_root *root, | ||
83 | struct btrfs_block_group_cache | ||
84 | *block_group, struct btrfs_path *path) | ||
85 | { | ||
86 | struct inode *inode = NULL; | ||
87 | |||
88 | spin_lock(&block_group->lock); | ||
89 | if (block_group->inode) | ||
90 | inode = igrab(block_group->inode); | ||
91 | spin_unlock(&block_group->lock); | ||
92 | if (inode) | ||
93 | return inode; | ||
94 | |||
95 | inode = __lookup_free_space_inode(root, path, | ||
96 | block_group->key.objectid); | ||
97 | if (IS_ERR(inode)) | ||
98 | return inode; | ||
99 | |||
87 | spin_lock(&block_group->lock); | 100 | spin_lock(&block_group->lock); |
88 | if (!root->fs_info->closing) { | 101 | if (!root->fs_info->closing) { |
89 | block_group->inode = igrab(inode); | 102 | block_group->inode = igrab(inode); |
@@ -94,24 +107,18 @@ struct inode *lookup_free_space_inode(struct btrfs_root *root, | |||
94 | return inode; | 107 | return inode; |
95 | } | 108 | } |
96 | 109 | ||
97 | int create_free_space_inode(struct btrfs_root *root, | 110 | int __create_free_space_inode(struct btrfs_root *root, |
98 | struct btrfs_trans_handle *trans, | 111 | struct btrfs_trans_handle *trans, |
99 | struct btrfs_block_group_cache *block_group, | 112 | struct btrfs_path *path, u64 ino, u64 offset) |
100 | struct btrfs_path *path) | ||
101 | { | 113 | { |
102 | struct btrfs_key key; | 114 | struct btrfs_key key; |
103 | struct btrfs_disk_key disk_key; | 115 | struct btrfs_disk_key disk_key; |
104 | struct btrfs_free_space_header *header; | 116 | struct btrfs_free_space_header *header; |
105 | struct btrfs_inode_item *inode_item; | 117 | struct btrfs_inode_item *inode_item; |
106 | struct extent_buffer *leaf; | 118 | struct extent_buffer *leaf; |
107 | u64 objectid; | ||
108 | int ret; | 119 | int ret; |
109 | 120 | ||
110 | ret = btrfs_find_free_objectid(trans, root, 0, &objectid); | 121 | ret = btrfs_insert_empty_inode(trans, root, path, ino); |
111 | if (ret < 0) | ||
112 | return ret; | ||
113 | |||
114 | ret = btrfs_insert_empty_inode(trans, root, path, objectid); | ||
115 | if (ret) | 122 | if (ret) |
116 | return ret; | 123 | return ret; |
117 | 124 | ||
@@ -131,13 +138,12 @@ int create_free_space_inode(struct btrfs_root *root, | |||
131 | BTRFS_INODE_PREALLOC | BTRFS_INODE_NODATASUM); | 138 | BTRFS_INODE_PREALLOC | BTRFS_INODE_NODATASUM); |
132 | btrfs_set_inode_nlink(leaf, inode_item, 1); | 139 | btrfs_set_inode_nlink(leaf, inode_item, 1); |
133 | btrfs_set_inode_transid(leaf, inode_item, trans->transid); | 140 | btrfs_set_inode_transid(leaf, inode_item, trans->transid); |
134 | btrfs_set_inode_block_group(leaf, inode_item, | 141 | btrfs_set_inode_block_group(leaf, inode_item, offset); |
135 | block_group->key.objectid); | ||
136 | btrfs_mark_buffer_dirty(leaf); | 142 | btrfs_mark_buffer_dirty(leaf); |
137 | btrfs_release_path(path); | 143 | btrfs_release_path(path); |
138 | 144 | ||
139 | key.objectid = BTRFS_FREE_SPACE_OBJECTID; | 145 | key.objectid = BTRFS_FREE_SPACE_OBJECTID; |
140 | key.offset = block_group->key.objectid; | 146 | key.offset = offset; |
141 | key.type = 0; | 147 | key.type = 0; |
142 | 148 | ||
143 | ret = btrfs_insert_empty_item(trans, root, path, &key, | 149 | ret = btrfs_insert_empty_item(trans, root, path, &key, |
@@ -157,6 +163,22 @@ int create_free_space_inode(struct btrfs_root *root, | |||
157 | return 0; | 163 | return 0; |
158 | } | 164 | } |
159 | 165 | ||
166 | int create_free_space_inode(struct btrfs_root *root, | ||
167 | struct btrfs_trans_handle *trans, | ||
168 | struct btrfs_block_group_cache *block_group, | ||
169 | struct btrfs_path *path) | ||
170 | { | ||
171 | int ret; | ||
172 | u64 ino; | ||
173 | |||
174 | ret = btrfs_find_free_objectid(root, &ino); | ||
175 | if (ret < 0) | ||
176 | return ret; | ||
177 | |||
178 | return __create_free_space_inode(root, trans, path, ino, | ||
179 | block_group->key.objectid); | ||
180 | } | ||
181 | |||
160 | int btrfs_truncate_free_space_cache(struct btrfs_root *root, | 182 | int btrfs_truncate_free_space_cache(struct btrfs_root *root, |
161 | struct btrfs_trans_handle *trans, | 183 | struct btrfs_trans_handle *trans, |
162 | struct btrfs_path *path, | 184 | struct btrfs_path *path, |
@@ -187,7 +209,8 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, | |||
187 | return ret; | 209 | return ret; |
188 | } | 210 | } |
189 | 211 | ||
190 | return btrfs_update_inode(trans, root, inode); | 212 | ret = btrfs_update_inode(trans, root, inode); |
213 | return ret; | ||
191 | } | 214 | } |
192 | 215 | ||
193 | static int readahead_cache(struct inode *inode) | 216 | static int readahead_cache(struct inode *inode) |
@@ -209,15 +232,13 @@ static int readahead_cache(struct inode *inode) | |||
209 | return 0; | 232 | return 0; |
210 | } | 233 | } |
211 | 234 | ||
212 | int load_free_space_cache(struct btrfs_fs_info *fs_info, | 235 | int __load_free_space_cache(struct btrfs_root *root, struct inode *inode, |
213 | struct btrfs_block_group_cache *block_group) | 236 | struct btrfs_free_space_ctl *ctl, |
237 | struct btrfs_path *path, u64 offset) | ||
214 | { | 238 | { |
215 | struct btrfs_root *root = fs_info->tree_root; | ||
216 | struct inode *inode; | ||
217 | struct btrfs_free_space_header *header; | 239 | struct btrfs_free_space_header *header; |
218 | struct extent_buffer *leaf; | 240 | struct extent_buffer *leaf; |
219 | struct page *page; | 241 | struct page *page; |
220 | struct btrfs_path *path; | ||
221 | u32 *checksums = NULL, *crc; | 242 | u32 *checksums = NULL, *crc; |
222 | char *disk_crcs = NULL; | 243 | char *disk_crcs = NULL; |
223 | struct btrfs_key key; | 244 | struct btrfs_key key; |
@@ -225,76 +246,47 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
225 | u64 num_entries; | 246 | u64 num_entries; |
226 | u64 num_bitmaps; | 247 | u64 num_bitmaps; |
227 | u64 generation; | 248 | u64 generation; |
228 | u64 used = btrfs_block_group_used(&block_group->item); | ||
229 | u32 cur_crc = ~(u32)0; | 249 | u32 cur_crc = ~(u32)0; |
230 | pgoff_t index = 0; | 250 | pgoff_t index = 0; |
231 | unsigned long first_page_offset; | 251 | unsigned long first_page_offset; |
232 | int num_checksums; | 252 | int num_checksums; |
233 | int ret = 0; | 253 | int ret = 0, ret2; |
234 | |||
235 | /* | ||
236 | * If we're unmounting then just return, since this does a search on the | ||
237 | * normal root and not the commit root and we could deadlock. | ||
238 | */ | ||
239 | smp_mb(); | ||
240 | if (fs_info->closing) | ||
241 | return 0; | ||
242 | |||
243 | /* | ||
244 | * If this block group has been marked to be cleared for one reason or | ||
245 | * another then we can't trust the on disk cache, so just return. | ||
246 | */ | ||
247 | spin_lock(&block_group->lock); | ||
248 | if (block_group->disk_cache_state != BTRFS_DC_WRITTEN) { | ||
249 | spin_unlock(&block_group->lock); | ||
250 | return 0; | ||
251 | } | ||
252 | spin_unlock(&block_group->lock); | ||
253 | 254 | ||
254 | INIT_LIST_HEAD(&bitmaps); | 255 | INIT_LIST_HEAD(&bitmaps); |
255 | 256 | ||
256 | path = btrfs_alloc_path(); | ||
257 | if (!path) | ||
258 | return 0; | ||
259 | |||
260 | inode = lookup_free_space_inode(root, block_group, path); | ||
261 | if (IS_ERR(inode)) { | ||
262 | btrfs_free_path(path); | ||
263 | return 0; | ||
264 | } | ||
265 | |||
266 | /* Nothing in the space cache, goodbye */ | 257 | /* Nothing in the space cache, goodbye */ |
267 | if (!i_size_read(inode)) { | 258 | if (!i_size_read(inode)) |
268 | btrfs_free_path(path); | ||
269 | goto out; | 259 | goto out; |
270 | } | ||
271 | 260 | ||
272 | key.objectid = BTRFS_FREE_SPACE_OBJECTID; | 261 | key.objectid = BTRFS_FREE_SPACE_OBJECTID; |
273 | key.offset = block_group->key.objectid; | 262 | key.offset = offset; |
274 | key.type = 0; | 263 | key.type = 0; |
275 | 264 | ||
276 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | 265 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
277 | if (ret) { | 266 | if (ret < 0) |
278 | btrfs_free_path(path); | 267 | goto out; |
268 | else if (ret > 0) { | ||
269 | btrfs_release_path(path); | ||
270 | ret = 0; | ||
279 | goto out; | 271 | goto out; |
280 | } | 272 | } |
281 | 273 | ||
274 | ret = -1; | ||
275 | |||
282 | leaf = path->nodes[0]; | 276 | leaf = path->nodes[0]; |
283 | header = btrfs_item_ptr(leaf, path->slots[0], | 277 | header = btrfs_item_ptr(leaf, path->slots[0], |
284 | struct btrfs_free_space_header); | 278 | struct btrfs_free_space_header); |
285 | num_entries = btrfs_free_space_entries(leaf, header); | 279 | num_entries = btrfs_free_space_entries(leaf, header); |
286 | num_bitmaps = btrfs_free_space_bitmaps(leaf, header); | 280 | num_bitmaps = btrfs_free_space_bitmaps(leaf, header); |
287 | generation = btrfs_free_space_generation(leaf, header); | 281 | generation = btrfs_free_space_generation(leaf, header); |
288 | btrfs_free_path(path); | 282 | btrfs_release_path(path); |
289 | 283 | ||
290 | if (BTRFS_I(inode)->generation != generation) { | 284 | if (BTRFS_I(inode)->generation != generation) { |
291 | printk(KERN_ERR "btrfs: free space inode generation (%llu) did" | 285 | printk(KERN_ERR "btrfs: free space inode generation (%llu) did" |
292 | " not match free space cache generation (%llu) for " | 286 | " not match free space cache generation (%llu)\n", |
293 | "block group %llu\n", | ||
294 | (unsigned long long)BTRFS_I(inode)->generation, | 287 | (unsigned long long)BTRFS_I(inode)->generation, |
295 | (unsigned long long)generation, | 288 | (unsigned long long)generation); |
296 | (unsigned long long)block_group->key.objectid); | 289 | goto out; |
297 | goto free_cache; | ||
298 | } | 290 | } |
299 | 291 | ||
300 | if (!num_entries) | 292 | if (!num_entries) |
@@ -311,10 +303,8 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
311 | goto out; | 303 | goto out; |
312 | 304 | ||
313 | ret = readahead_cache(inode); | 305 | ret = readahead_cache(inode); |
314 | if (ret) { | 306 | if (ret) |
315 | ret = 0; | ||
316 | goto out; | 307 | goto out; |
317 | } | ||
318 | 308 | ||
319 | while (1) { | 309 | while (1) { |
320 | struct btrfs_free_space_entry *entry; | 310 | struct btrfs_free_space_entry *entry; |
@@ -333,10 +323,8 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
333 | } | 323 | } |
334 | 324 | ||
335 | page = grab_cache_page(inode->i_mapping, index); | 325 | page = grab_cache_page(inode->i_mapping, index); |
336 | if (!page) { | 326 | if (!page) |
337 | ret = 0; | ||
338 | goto free_cache; | 327 | goto free_cache; |
339 | } | ||
340 | 328 | ||
341 | if (!PageUptodate(page)) { | 329 | if (!PageUptodate(page)) { |
342 | btrfs_readpage(NULL, page); | 330 | btrfs_readpage(NULL, page); |
@@ -345,9 +333,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
345 | unlock_page(page); | 333 | unlock_page(page); |
346 | page_cache_release(page); | 334 | page_cache_release(page); |
347 | printk(KERN_ERR "btrfs: error reading free " | 335 | printk(KERN_ERR "btrfs: error reading free " |
348 | "space cache: %llu\n", | 336 | "space cache\n"); |
349 | (unsigned long long) | ||
350 | block_group->key.objectid); | ||
351 | goto free_cache; | 337 | goto free_cache; |
352 | } | 338 | } |
353 | } | 339 | } |
@@ -360,13 +346,10 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
360 | gen = addr + (sizeof(u32) * num_checksums); | 346 | gen = addr + (sizeof(u32) * num_checksums); |
361 | if (*gen != BTRFS_I(inode)->generation) { | 347 | if (*gen != BTRFS_I(inode)->generation) { |
362 | printk(KERN_ERR "btrfs: space cache generation" | 348 | printk(KERN_ERR "btrfs: space cache generation" |
363 | " (%llu) does not match inode (%llu) " | 349 | " (%llu) does not match inode (%llu)\n", |
364 | "for block group %llu\n", | ||
365 | (unsigned long long)*gen, | 350 | (unsigned long long)*gen, |
366 | (unsigned long long) | 351 | (unsigned long long) |
367 | BTRFS_I(inode)->generation, | 352 | BTRFS_I(inode)->generation); |
368 | (unsigned long long) | ||
369 | block_group->key.objectid); | ||
370 | kunmap(page); | 353 | kunmap(page); |
371 | unlock_page(page); | 354 | unlock_page(page); |
372 | page_cache_release(page); | 355 | page_cache_release(page); |
@@ -382,9 +365,8 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
382 | PAGE_CACHE_SIZE - start_offset); | 365 | PAGE_CACHE_SIZE - start_offset); |
383 | btrfs_csum_final(cur_crc, (char *)&cur_crc); | 366 | btrfs_csum_final(cur_crc, (char *)&cur_crc); |
384 | if (cur_crc != *crc) { | 367 | if (cur_crc != *crc) { |
385 | printk(KERN_ERR "btrfs: crc mismatch for page %lu in " | 368 | printk(KERN_ERR "btrfs: crc mismatch for page %lu\n", |
386 | "block group %llu\n", index, | 369 | index); |
387 | (unsigned long long)block_group->key.objectid); | ||
388 | kunmap(page); | 370 | kunmap(page); |
389 | unlock_page(page); | 371 | unlock_page(page); |
390 | page_cache_release(page); | 372 | page_cache_release(page); |
@@ -417,9 +399,9 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
417 | } | 399 | } |
418 | 400 | ||
419 | if (entry->type == BTRFS_FREE_SPACE_EXTENT) { | 401 | if (entry->type == BTRFS_FREE_SPACE_EXTENT) { |
420 | spin_lock(&block_group->tree_lock); | 402 | spin_lock(&ctl->tree_lock); |
421 | ret = link_free_space(block_group, e); | 403 | ret = link_free_space(ctl, e); |
422 | spin_unlock(&block_group->tree_lock); | 404 | spin_unlock(&ctl->tree_lock); |
423 | BUG_ON(ret); | 405 | BUG_ON(ret); |
424 | } else { | 406 | } else { |
425 | e->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); | 407 | e->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); |
@@ -431,11 +413,11 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
431 | page_cache_release(page); | 413 | page_cache_release(page); |
432 | goto free_cache; | 414 | goto free_cache; |
433 | } | 415 | } |
434 | spin_lock(&block_group->tree_lock); | 416 | spin_lock(&ctl->tree_lock); |
435 | ret = link_free_space(block_group, e); | 417 | ret2 = link_free_space(ctl, e); |
436 | block_group->total_bitmaps++; | 418 | ctl->total_bitmaps++; |
437 | recalculate_thresholds(block_group); | 419 | ctl->op->recalc_thresholds(ctl); |
438 | spin_unlock(&block_group->tree_lock); | 420 | spin_unlock(&ctl->tree_lock); |
439 | list_add_tail(&e->list, &bitmaps); | 421 | list_add_tail(&e->list, &bitmaps); |
440 | } | 422 | } |
441 | 423 | ||
@@ -471,41 +453,97 @@ next: | |||
471 | index++; | 453 | index++; |
472 | } | 454 | } |
473 | 455 | ||
474 | spin_lock(&block_group->tree_lock); | ||
475 | if (block_group->free_space != (block_group->key.offset - used - | ||
476 | block_group->bytes_super)) { | ||
477 | spin_unlock(&block_group->tree_lock); | ||
478 | printk(KERN_ERR "block group %llu has an wrong amount of free " | ||
479 | "space\n", block_group->key.objectid); | ||
480 | ret = 0; | ||
481 | goto free_cache; | ||
482 | } | ||
483 | spin_unlock(&block_group->tree_lock); | ||
484 | |||
485 | ret = 1; | 456 | ret = 1; |
486 | out: | 457 | out: |
487 | kfree(checksums); | 458 | kfree(checksums); |
488 | kfree(disk_crcs); | 459 | kfree(disk_crcs); |
489 | iput(inode); | ||
490 | return ret; | 460 | return ret; |
491 | |||
492 | free_cache: | 461 | free_cache: |
493 | /* This cache is bogus, make sure it gets cleared */ | 462 | __btrfs_remove_free_space_cache(ctl); |
463 | goto out; | ||
464 | } | ||
465 | |||
466 | int load_free_space_cache(struct btrfs_fs_info *fs_info, | ||
467 | struct btrfs_block_group_cache *block_group) | ||
468 | { | ||
469 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
470 | struct btrfs_root *root = fs_info->tree_root; | ||
471 | struct inode *inode; | ||
472 | struct btrfs_path *path; | ||
473 | int ret; | ||
474 | bool matched; | ||
475 | u64 used = btrfs_block_group_used(&block_group->item); | ||
476 | |||
477 | /* | ||
478 | * If we're unmounting then just return, since this does a search on the | ||
479 | * normal root and not the commit root and we could deadlock. | ||
480 | */ | ||
481 | smp_mb(); | ||
482 | if (fs_info->closing) | ||
483 | return 0; | ||
484 | |||
485 | /* | ||
486 | * If this block group has been marked to be cleared for one reason or | ||
487 | * another then we can't trust the on disk cache, so just return. | ||
488 | */ | ||
494 | spin_lock(&block_group->lock); | 489 | spin_lock(&block_group->lock); |
495 | block_group->disk_cache_state = BTRFS_DC_CLEAR; | 490 | if (block_group->disk_cache_state != BTRFS_DC_WRITTEN) { |
491 | spin_unlock(&block_group->lock); | ||
492 | return 0; | ||
493 | } | ||
496 | spin_unlock(&block_group->lock); | 494 | spin_unlock(&block_group->lock); |
497 | btrfs_remove_free_space_cache(block_group); | 495 | |
498 | goto out; | 496 | path = btrfs_alloc_path(); |
497 | if (!path) | ||
498 | return 0; | ||
499 | |||
500 | inode = lookup_free_space_inode(root, block_group, path); | ||
501 | if (IS_ERR(inode)) { | ||
502 | btrfs_free_path(path); | ||
503 | return 0; | ||
504 | } | ||
505 | |||
506 | ret = __load_free_space_cache(fs_info->tree_root, inode, ctl, | ||
507 | path, block_group->key.objectid); | ||
508 | btrfs_free_path(path); | ||
509 | if (ret <= 0) | ||
510 | goto out; | ||
511 | |||
512 | spin_lock(&ctl->tree_lock); | ||
513 | matched = (ctl->free_space == (block_group->key.offset - used - | ||
514 | block_group->bytes_super)); | ||
515 | spin_unlock(&ctl->tree_lock); | ||
516 | |||
517 | if (!matched) { | ||
518 | __btrfs_remove_free_space_cache(ctl); | ||
519 | printk(KERN_ERR "block group %llu has an wrong amount of free " | ||
520 | "space\n", block_group->key.objectid); | ||
521 | ret = -1; | ||
522 | } | ||
523 | out: | ||
524 | if (ret < 0) { | ||
525 | /* This cache is bogus, make sure it gets cleared */ | ||
526 | spin_lock(&block_group->lock); | ||
527 | block_group->disk_cache_state = BTRFS_DC_CLEAR; | ||
528 | spin_unlock(&block_group->lock); | ||
529 | ret = 0; | ||
530 | |||
531 | printk(KERN_ERR "btrfs: failed to load free space cache " | ||
532 | "for block group %llu\n", block_group->key.objectid); | ||
533 | } | ||
534 | |||
535 | iput(inode); | ||
536 | return ret; | ||
499 | } | 537 | } |
500 | 538 | ||
501 | int btrfs_write_out_cache(struct btrfs_root *root, | 539 | int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, |
502 | struct btrfs_trans_handle *trans, | 540 | struct btrfs_free_space_ctl *ctl, |
503 | struct btrfs_block_group_cache *block_group, | 541 | struct btrfs_block_group_cache *block_group, |
504 | struct btrfs_path *path) | 542 | struct btrfs_trans_handle *trans, |
543 | struct btrfs_path *path, u64 offset) | ||
505 | { | 544 | { |
506 | struct btrfs_free_space_header *header; | 545 | struct btrfs_free_space_header *header; |
507 | struct extent_buffer *leaf; | 546 | struct extent_buffer *leaf; |
508 | struct inode *inode; | ||
509 | struct rb_node *node; | 547 | struct rb_node *node; |
510 | struct list_head *pos, *n; | 548 | struct list_head *pos, *n; |
511 | struct page **pages; | 549 | struct page **pages; |
@@ -522,35 +560,18 @@ int btrfs_write_out_cache(struct btrfs_root *root, | |||
522 | int index = 0, num_pages = 0; | 560 | int index = 0, num_pages = 0; |
523 | int entries = 0; | 561 | int entries = 0; |
524 | int bitmaps = 0; | 562 | int bitmaps = 0; |
525 | int ret = 0; | 563 | int ret = -1; |
526 | bool next_page = false; | 564 | bool next_page = false; |
527 | bool out_of_space = false; | 565 | bool out_of_space = false; |
528 | 566 | ||
529 | root = root->fs_info->tree_root; | ||
530 | |||
531 | INIT_LIST_HEAD(&bitmap_list); | 567 | INIT_LIST_HEAD(&bitmap_list); |
532 | 568 | ||
533 | spin_lock(&block_group->lock); | 569 | node = rb_first(&ctl->free_space_offset); |
534 | if (block_group->disk_cache_state < BTRFS_DC_SETUP) { | 570 | if (!node) |
535 | spin_unlock(&block_group->lock); | ||
536 | return 0; | ||
537 | } | ||
538 | spin_unlock(&block_group->lock); | ||
539 | |||
540 | inode = lookup_free_space_inode(root, block_group, path); | ||
541 | if (IS_ERR(inode)) | ||
542 | return 0; | ||
543 | |||
544 | if (!i_size_read(inode)) { | ||
545 | iput(inode); | ||
546 | return 0; | 571 | return 0; |
547 | } | ||
548 | 572 | ||
549 | node = rb_first(&block_group->free_space_offset); | 573 | if (!i_size_read(inode)) |
550 | if (!node) { | 574 | return -1; |
551 | iput(inode); | ||
552 | return 0; | ||
553 | } | ||
554 | 575 | ||
555 | num_pages = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> | 576 | num_pages = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> |
556 | PAGE_CACHE_SHIFT; | 577 | PAGE_CACHE_SHIFT; |
@@ -560,16 +581,13 @@ int btrfs_write_out_cache(struct btrfs_root *root, | |||
560 | 581 | ||
561 | /* We need a checksum per page. */ | 582 | /* We need a checksum per page. */ |
562 | crc = checksums = kzalloc(sizeof(u32) * num_pages, GFP_NOFS); | 583 | crc = checksums = kzalloc(sizeof(u32) * num_pages, GFP_NOFS); |
563 | if (!crc) { | 584 | if (!crc) |
564 | iput(inode); | 585 | return -1; |
565 | return 0; | ||
566 | } | ||
567 | 586 | ||
568 | pages = kzalloc(sizeof(struct page *) * num_pages, GFP_NOFS); | 587 | pages = kzalloc(sizeof(struct page *) * num_pages, GFP_NOFS); |
569 | if (!pages) { | 588 | if (!pages) { |
570 | kfree(crc); | 589 | kfree(crc); |
571 | iput(inode); | 590 | return -1; |
572 | return 0; | ||
573 | } | 591 | } |
574 | 592 | ||
575 | /* Since the first page has all of our checksums and our generation we | 593 | /* Since the first page has all of our checksums and our generation we |
@@ -579,7 +597,7 @@ int btrfs_write_out_cache(struct btrfs_root *root, | |||
579 | first_page_offset = (sizeof(u32) * num_pages) + sizeof(u64); | 597 | first_page_offset = (sizeof(u32) * num_pages) + sizeof(u64); |
580 | 598 | ||
581 | /* Get the cluster for this block_group if it exists */ | 599 | /* Get the cluster for this block_group if it exists */ |
582 | if (!list_empty(&block_group->cluster_list)) | 600 | if (block_group && !list_empty(&block_group->cluster_list)) |
583 | cluster = list_entry(block_group->cluster_list.next, | 601 | cluster = list_entry(block_group->cluster_list.next, |
584 | struct btrfs_free_cluster, | 602 | struct btrfs_free_cluster, |
585 | block_group_list); | 603 | block_group_list); |
@@ -621,7 +639,8 @@ int btrfs_write_out_cache(struct btrfs_root *root, | |||
621 | * When searching for pinned extents, we need to start at our start | 639 | * When searching for pinned extents, we need to start at our start |
622 | * offset. | 640 | * offset. |
623 | */ | 641 | */ |
624 | start = block_group->key.objectid; | 642 | if (block_group) |
643 | start = block_group->key.objectid; | ||
625 | 644 | ||
626 | /* Write out the extent entries */ | 645 | /* Write out the extent entries */ |
627 | do { | 646 | do { |
@@ -679,8 +698,9 @@ int btrfs_write_out_cache(struct btrfs_root *root, | |||
679 | * We want to add any pinned extents to our free space cache | 698 | * We want to add any pinned extents to our free space cache |
680 | * so we don't leak the space | 699 | * so we don't leak the space |
681 | */ | 700 | */ |
682 | while (!next_page && (start < block_group->key.objectid + | 701 | while (block_group && !next_page && |
683 | block_group->key.offset)) { | 702 | (start < block_group->key.objectid + |
703 | block_group->key.offset)) { | ||
684 | ret = find_first_extent_bit(unpin, start, &start, &end, | 704 | ret = find_first_extent_bit(unpin, start, &start, &end, |
685 | EXTENT_DIRTY); | 705 | EXTENT_DIRTY); |
686 | if (ret) { | 706 | if (ret) { |
@@ -798,12 +818,12 @@ int btrfs_write_out_cache(struct btrfs_root *root, | |||
798 | filemap_write_and_wait(inode->i_mapping); | 818 | filemap_write_and_wait(inode->i_mapping); |
799 | 819 | ||
800 | key.objectid = BTRFS_FREE_SPACE_OBJECTID; | 820 | key.objectid = BTRFS_FREE_SPACE_OBJECTID; |
801 | key.offset = block_group->key.objectid; | 821 | key.offset = offset; |
802 | key.type = 0; | 822 | key.type = 0; |
803 | 823 | ||
804 | ret = btrfs_search_slot(trans, root, &key, path, 1, 1); | 824 | ret = btrfs_search_slot(trans, root, &key, path, 1, 1); |
805 | if (ret < 0) { | 825 | if (ret < 0) { |
806 | ret = 0; | 826 | ret = -1; |
807 | clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, bytes - 1, | 827 | clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, bytes - 1, |
808 | EXTENT_DIRTY | EXTENT_DELALLOC | | 828 | EXTENT_DIRTY | EXTENT_DELALLOC | |
809 | EXTENT_DO_ACCOUNTING, 0, 0, NULL, GFP_NOFS); | 829 | EXTENT_DO_ACCOUNTING, 0, 0, NULL, GFP_NOFS); |
@@ -816,8 +836,8 @@ int btrfs_write_out_cache(struct btrfs_root *root, | |||
816 | path->slots[0]--; | 836 | path->slots[0]--; |
817 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); | 837 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); |
818 | if (found_key.objectid != BTRFS_FREE_SPACE_OBJECTID || | 838 | if (found_key.objectid != BTRFS_FREE_SPACE_OBJECTID || |
819 | found_key.offset != block_group->key.objectid) { | 839 | found_key.offset != offset) { |
820 | ret = 0; | 840 | ret = -1; |
821 | clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, bytes - 1, | 841 | clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, bytes - 1, |
822 | EXTENT_DIRTY | EXTENT_DELALLOC | | 842 | EXTENT_DIRTY | EXTENT_DELALLOC | |
823 | EXTENT_DO_ACCOUNTING, 0, 0, NULL, | 843 | EXTENT_DO_ACCOUNTING, 0, 0, NULL, |
@@ -837,44 +857,78 @@ int btrfs_write_out_cache(struct btrfs_root *root, | |||
837 | ret = 1; | 857 | ret = 1; |
838 | 858 | ||
839 | out_free: | 859 | out_free: |
840 | if (ret == 0) { | 860 | if (ret != 1) { |
841 | invalidate_inode_pages2_range(inode->i_mapping, 0, index); | 861 | invalidate_inode_pages2_range(inode->i_mapping, 0, index); |
842 | spin_lock(&block_group->lock); | ||
843 | block_group->disk_cache_state = BTRFS_DC_ERROR; | ||
844 | spin_unlock(&block_group->lock); | ||
845 | BTRFS_I(inode)->generation = 0; | 862 | BTRFS_I(inode)->generation = 0; |
846 | } | 863 | } |
847 | kfree(checksums); | 864 | kfree(checksums); |
848 | kfree(pages); | 865 | kfree(pages); |
849 | btrfs_update_inode(trans, root, inode); | 866 | btrfs_update_inode(trans, root, inode); |
867 | return ret; | ||
868 | } | ||
869 | |||
870 | int btrfs_write_out_cache(struct btrfs_root *root, | ||
871 | struct btrfs_trans_handle *trans, | ||
872 | struct btrfs_block_group_cache *block_group, | ||
873 | struct btrfs_path *path) | ||
874 | { | ||
875 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
876 | struct inode *inode; | ||
877 | int ret = 0; | ||
878 | |||
879 | root = root->fs_info->tree_root; | ||
880 | |||
881 | spin_lock(&block_group->lock); | ||
882 | if (block_group->disk_cache_state < BTRFS_DC_SETUP) { | ||
883 | spin_unlock(&block_group->lock); | ||
884 | return 0; | ||
885 | } | ||
886 | spin_unlock(&block_group->lock); | ||
887 | |||
888 | inode = lookup_free_space_inode(root, block_group, path); | ||
889 | if (IS_ERR(inode)) | ||
890 | return 0; | ||
891 | |||
892 | ret = __btrfs_write_out_cache(root, inode, ctl, block_group, trans, | ||
893 | path, block_group->key.objectid); | ||
894 | if (ret < 0) { | ||
895 | spin_lock(&block_group->lock); | ||
896 | block_group->disk_cache_state = BTRFS_DC_ERROR; | ||
897 | spin_unlock(&block_group->lock); | ||
898 | ret = 0; | ||
899 | |||
900 | printk(KERN_ERR "btrfs: failed to write free space cace " | ||
901 | "for block group %llu\n", block_group->key.objectid); | ||
902 | } | ||
903 | |||
850 | iput(inode); | 904 | iput(inode); |
851 | return ret; | 905 | return ret; |
852 | } | 906 | } |
853 | 907 | ||
854 | static inline unsigned long offset_to_bit(u64 bitmap_start, u64 sectorsize, | 908 | static inline unsigned long offset_to_bit(u64 bitmap_start, u32 unit, |
855 | u64 offset) | 909 | u64 offset) |
856 | { | 910 | { |
857 | BUG_ON(offset < bitmap_start); | 911 | BUG_ON(offset < bitmap_start); |
858 | offset -= bitmap_start; | 912 | offset -= bitmap_start; |
859 | return (unsigned long)(div64_u64(offset, sectorsize)); | 913 | return (unsigned long)(div_u64(offset, unit)); |
860 | } | 914 | } |
861 | 915 | ||
862 | static inline unsigned long bytes_to_bits(u64 bytes, u64 sectorsize) | 916 | static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) |
863 | { | 917 | { |
864 | return (unsigned long)(div64_u64(bytes, sectorsize)); | 918 | return (unsigned long)(div_u64(bytes, unit)); |
865 | } | 919 | } |
866 | 920 | ||
867 | static inline u64 offset_to_bitmap(struct btrfs_block_group_cache *block_group, | 921 | static inline u64 offset_to_bitmap(struct btrfs_free_space_ctl *ctl, |
868 | u64 offset) | 922 | u64 offset) |
869 | { | 923 | { |
870 | u64 bitmap_start; | 924 | u64 bitmap_start; |
871 | u64 bytes_per_bitmap; | 925 | u64 bytes_per_bitmap; |
872 | 926 | ||
873 | bytes_per_bitmap = BITS_PER_BITMAP * block_group->sectorsize; | 927 | bytes_per_bitmap = BITS_PER_BITMAP * ctl->unit; |
874 | bitmap_start = offset - block_group->key.objectid; | 928 | bitmap_start = offset - ctl->start; |
875 | bitmap_start = div64_u64(bitmap_start, bytes_per_bitmap); | 929 | bitmap_start = div64_u64(bitmap_start, bytes_per_bitmap); |
876 | bitmap_start *= bytes_per_bitmap; | 930 | bitmap_start *= bytes_per_bitmap; |
877 | bitmap_start += block_group->key.objectid; | 931 | bitmap_start += ctl->start; |
878 | 932 | ||
879 | return bitmap_start; | 933 | return bitmap_start; |
880 | } | 934 | } |
@@ -932,10 +986,10 @@ static int tree_insert_offset(struct rb_root *root, u64 offset, | |||
932 | * offset. | 986 | * offset. |
933 | */ | 987 | */ |
934 | static struct btrfs_free_space * | 988 | static struct btrfs_free_space * |
935 | tree_search_offset(struct btrfs_block_group_cache *block_group, | 989 | tree_search_offset(struct btrfs_free_space_ctl *ctl, |
936 | u64 offset, int bitmap_only, int fuzzy) | 990 | u64 offset, int bitmap_only, int fuzzy) |
937 | { | 991 | { |
938 | struct rb_node *n = block_group->free_space_offset.rb_node; | 992 | struct rb_node *n = ctl->free_space_offset.rb_node; |
939 | struct btrfs_free_space *entry, *prev = NULL; | 993 | struct btrfs_free_space *entry, *prev = NULL; |
940 | 994 | ||
941 | /* find entry that is closest to the 'offset' */ | 995 | /* find entry that is closest to the 'offset' */ |
@@ -1031,8 +1085,7 @@ tree_search_offset(struct btrfs_block_group_cache *block_group, | |||
1031 | break; | 1085 | break; |
1032 | } | 1086 | } |
1033 | } | 1087 | } |
1034 | if (entry->offset + BITS_PER_BITMAP * | 1088 | if (entry->offset + BITS_PER_BITMAP * ctl->unit > offset) |
1035 | block_group->sectorsize > offset) | ||
1036 | return entry; | 1089 | return entry; |
1037 | } else if (entry->offset + entry->bytes > offset) | 1090 | } else if (entry->offset + entry->bytes > offset) |
1038 | return entry; | 1091 | return entry; |
@@ -1043,7 +1096,7 @@ tree_search_offset(struct btrfs_block_group_cache *block_group, | |||
1043 | while (1) { | 1096 | while (1) { |
1044 | if (entry->bitmap) { | 1097 | if (entry->bitmap) { |
1045 | if (entry->offset + BITS_PER_BITMAP * | 1098 | if (entry->offset + BITS_PER_BITMAP * |
1046 | block_group->sectorsize > offset) | 1099 | ctl->unit > offset) |
1047 | break; | 1100 | break; |
1048 | } else { | 1101 | } else { |
1049 | if (entry->offset + entry->bytes > offset) | 1102 | if (entry->offset + entry->bytes > offset) |
@@ -1059,42 +1112,47 @@ tree_search_offset(struct btrfs_block_group_cache *block_group, | |||
1059 | } | 1112 | } |
1060 | 1113 | ||
1061 | static inline void | 1114 | static inline void |
1062 | __unlink_free_space(struct btrfs_block_group_cache *block_group, | 1115 | __unlink_free_space(struct btrfs_free_space_ctl *ctl, |
1063 | struct btrfs_free_space *info) | 1116 | struct btrfs_free_space *info) |
1064 | { | 1117 | { |
1065 | rb_erase(&info->offset_index, &block_group->free_space_offset); | 1118 | rb_erase(&info->offset_index, &ctl->free_space_offset); |
1066 | block_group->free_extents--; | 1119 | ctl->free_extents--; |
1067 | } | 1120 | } |
1068 | 1121 | ||
1069 | static void unlink_free_space(struct btrfs_block_group_cache *block_group, | 1122 | static void unlink_free_space(struct btrfs_free_space_ctl *ctl, |
1070 | struct btrfs_free_space *info) | 1123 | struct btrfs_free_space *info) |
1071 | { | 1124 | { |
1072 | __unlink_free_space(block_group, info); | 1125 | __unlink_free_space(ctl, info); |
1073 | block_group->free_space -= info->bytes; | 1126 | ctl->free_space -= info->bytes; |
1074 | } | 1127 | } |
1075 | 1128 | ||
1076 | static int link_free_space(struct btrfs_block_group_cache *block_group, | 1129 | static int link_free_space(struct btrfs_free_space_ctl *ctl, |
1077 | struct btrfs_free_space *info) | 1130 | struct btrfs_free_space *info) |
1078 | { | 1131 | { |
1079 | int ret = 0; | 1132 | int ret = 0; |
1080 | 1133 | ||
1081 | BUG_ON(!info->bitmap && !info->bytes); | 1134 | BUG_ON(!info->bitmap && !info->bytes); |
1082 | ret = tree_insert_offset(&block_group->free_space_offset, info->offset, | 1135 | ret = tree_insert_offset(&ctl->free_space_offset, info->offset, |
1083 | &info->offset_index, (info->bitmap != NULL)); | 1136 | &info->offset_index, (info->bitmap != NULL)); |
1084 | if (ret) | 1137 | if (ret) |
1085 | return ret; | 1138 | return ret; |
1086 | 1139 | ||
1087 | block_group->free_space += info->bytes; | 1140 | ctl->free_space += info->bytes; |
1088 | block_group->free_extents++; | 1141 | ctl->free_extents++; |
1089 | return ret; | 1142 | return ret; |
1090 | } | 1143 | } |
1091 | 1144 | ||
1092 | static void recalculate_thresholds(struct btrfs_block_group_cache *block_group) | 1145 | static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) |
1093 | { | 1146 | { |
1147 | struct btrfs_block_group_cache *block_group = ctl->private; | ||
1094 | u64 max_bytes; | 1148 | u64 max_bytes; |
1095 | u64 bitmap_bytes; | 1149 | u64 bitmap_bytes; |
1096 | u64 extent_bytes; | 1150 | u64 extent_bytes; |
1097 | u64 size = block_group->key.offset; | 1151 | u64 size = block_group->key.offset; |
1152 | u64 bytes_per_bg = BITS_PER_BITMAP * block_group->sectorsize; | ||
1153 | int max_bitmaps = div64_u64(size + bytes_per_bg - 1, bytes_per_bg); | ||
1154 | |||
1155 | BUG_ON(ctl->total_bitmaps > max_bitmaps); | ||
1098 | 1156 | ||
1099 | /* | 1157 | /* |
1100 | * The goal is to keep the total amount of memory used per 1gb of space | 1158 | * The goal is to keep the total amount of memory used per 1gb of space |
@@ -1112,10 +1170,10 @@ static void recalculate_thresholds(struct btrfs_block_group_cache *block_group) | |||
1112 | * sure we don't go over our overall goal of MAX_CACHE_BYTES_PER_GIG as | 1170 | * sure we don't go over our overall goal of MAX_CACHE_BYTES_PER_GIG as |
1113 | * we add more bitmaps. | 1171 | * we add more bitmaps. |
1114 | */ | 1172 | */ |
1115 | bitmap_bytes = (block_group->total_bitmaps + 1) * PAGE_CACHE_SIZE; | 1173 | bitmap_bytes = (ctl->total_bitmaps + 1) * PAGE_CACHE_SIZE; |
1116 | 1174 | ||
1117 | if (bitmap_bytes >= max_bytes) { | 1175 | if (bitmap_bytes >= max_bytes) { |
1118 | block_group->extents_thresh = 0; | 1176 | ctl->extents_thresh = 0; |
1119 | return; | 1177 | return; |
1120 | } | 1178 | } |
1121 | 1179 | ||
@@ -1126,47 +1184,43 @@ static void recalculate_thresholds(struct btrfs_block_group_cache *block_group) | |||
1126 | extent_bytes = max_bytes - bitmap_bytes; | 1184 | extent_bytes = max_bytes - bitmap_bytes; |
1127 | extent_bytes = min_t(u64, extent_bytes, div64_u64(max_bytes, 2)); | 1185 | extent_bytes = min_t(u64, extent_bytes, div64_u64(max_bytes, 2)); |
1128 | 1186 | ||
1129 | block_group->extents_thresh = | 1187 | ctl->extents_thresh = |
1130 | div64_u64(extent_bytes, (sizeof(struct btrfs_free_space))); | 1188 | div64_u64(extent_bytes, (sizeof(struct btrfs_free_space))); |
1131 | } | 1189 | } |
1132 | 1190 | ||
1133 | static void bitmap_clear_bits(struct btrfs_block_group_cache *block_group, | 1191 | static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, |
1134 | struct btrfs_free_space *info, u64 offset, | 1192 | struct btrfs_free_space *info, u64 offset, |
1135 | u64 bytes) | 1193 | u64 bytes) |
1136 | { | 1194 | { |
1137 | unsigned long start, end; | 1195 | unsigned long start, count; |
1138 | unsigned long i; | ||
1139 | 1196 | ||
1140 | start = offset_to_bit(info->offset, block_group->sectorsize, offset); | 1197 | start = offset_to_bit(info->offset, ctl->unit, offset); |
1141 | end = start + bytes_to_bits(bytes, block_group->sectorsize); | 1198 | count = bytes_to_bits(bytes, ctl->unit); |
1142 | BUG_ON(end > BITS_PER_BITMAP); | 1199 | BUG_ON(start + count > BITS_PER_BITMAP); |
1143 | 1200 | ||
1144 | for (i = start; i < end; i++) | 1201 | bitmap_clear(info->bitmap, start, count); |
1145 | clear_bit(i, info->bitmap); | ||
1146 | 1202 | ||
1147 | info->bytes -= bytes; | 1203 | info->bytes -= bytes; |
1148 | block_group->free_space -= bytes; | 1204 | ctl->free_space -= bytes; |
1149 | } | 1205 | } |
1150 | 1206 | ||
1151 | static void bitmap_set_bits(struct btrfs_block_group_cache *block_group, | 1207 | static void bitmap_set_bits(struct btrfs_free_space_ctl *ctl, |
1152 | struct btrfs_free_space *info, u64 offset, | 1208 | struct btrfs_free_space *info, u64 offset, |
1153 | u64 bytes) | 1209 | u64 bytes) |
1154 | { | 1210 | { |
1155 | unsigned long start, end; | 1211 | unsigned long start, count; |
1156 | unsigned long i; | ||
1157 | 1212 | ||
1158 | start = offset_to_bit(info->offset, block_group->sectorsize, offset); | 1213 | start = offset_to_bit(info->offset, ctl->unit, offset); |
1159 | end = start + bytes_to_bits(bytes, block_group->sectorsize); | 1214 | count = bytes_to_bits(bytes, ctl->unit); |
1160 | BUG_ON(end > BITS_PER_BITMAP); | 1215 | BUG_ON(start + count > BITS_PER_BITMAP); |
1161 | 1216 | ||
1162 | for (i = start; i < end; i++) | 1217 | bitmap_set(info->bitmap, start, count); |
1163 | set_bit(i, info->bitmap); | ||
1164 | 1218 | ||
1165 | info->bytes += bytes; | 1219 | info->bytes += bytes; |
1166 | block_group->free_space += bytes; | 1220 | ctl->free_space += bytes; |
1167 | } | 1221 | } |
1168 | 1222 | ||
1169 | static int search_bitmap(struct btrfs_block_group_cache *block_group, | 1223 | static int search_bitmap(struct btrfs_free_space_ctl *ctl, |
1170 | struct btrfs_free_space *bitmap_info, u64 *offset, | 1224 | struct btrfs_free_space *bitmap_info, u64 *offset, |
1171 | u64 *bytes) | 1225 | u64 *bytes) |
1172 | { | 1226 | { |
@@ -1174,9 +1228,9 @@ static int search_bitmap(struct btrfs_block_group_cache *block_group, | |||
1174 | unsigned long bits, i; | 1228 | unsigned long bits, i; |
1175 | unsigned long next_zero; | 1229 | unsigned long next_zero; |
1176 | 1230 | ||
1177 | i = offset_to_bit(bitmap_info->offset, block_group->sectorsize, | 1231 | i = offset_to_bit(bitmap_info->offset, ctl->unit, |
1178 | max_t(u64, *offset, bitmap_info->offset)); | 1232 | max_t(u64, *offset, bitmap_info->offset)); |
1179 | bits = bytes_to_bits(*bytes, block_group->sectorsize); | 1233 | bits = bytes_to_bits(*bytes, ctl->unit); |
1180 | 1234 | ||
1181 | for (i = find_next_bit(bitmap_info->bitmap, BITS_PER_BITMAP, i); | 1235 | for (i = find_next_bit(bitmap_info->bitmap, BITS_PER_BITMAP, i); |
1182 | i < BITS_PER_BITMAP; | 1236 | i < BITS_PER_BITMAP; |
@@ -1191,29 +1245,25 @@ static int search_bitmap(struct btrfs_block_group_cache *block_group, | |||
1191 | } | 1245 | } |
1192 | 1246 | ||
1193 | if (found_bits) { | 1247 | if (found_bits) { |
1194 | *offset = (u64)(i * block_group->sectorsize) + | 1248 | *offset = (u64)(i * ctl->unit) + bitmap_info->offset; |
1195 | bitmap_info->offset; | 1249 | *bytes = (u64)(found_bits) * ctl->unit; |
1196 | *bytes = (u64)(found_bits) * block_group->sectorsize; | ||
1197 | return 0; | 1250 | return 0; |
1198 | } | 1251 | } |
1199 | 1252 | ||
1200 | return -1; | 1253 | return -1; |
1201 | } | 1254 | } |
1202 | 1255 | ||
1203 | static struct btrfs_free_space *find_free_space(struct btrfs_block_group_cache | 1256 | static struct btrfs_free_space * |
1204 | *block_group, u64 *offset, | 1257 | find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes) |
1205 | u64 *bytes, int debug) | ||
1206 | { | 1258 | { |
1207 | struct btrfs_free_space *entry; | 1259 | struct btrfs_free_space *entry; |
1208 | struct rb_node *node; | 1260 | struct rb_node *node; |
1209 | int ret; | 1261 | int ret; |
1210 | 1262 | ||
1211 | if (!block_group->free_space_offset.rb_node) | 1263 | if (!ctl->free_space_offset.rb_node) |
1212 | return NULL; | 1264 | return NULL; |
1213 | 1265 | ||
1214 | entry = tree_search_offset(block_group, | 1266 | entry = tree_search_offset(ctl, offset_to_bitmap(ctl, *offset), 0, 1); |
1215 | offset_to_bitmap(block_group, *offset), | ||
1216 | 0, 1); | ||
1217 | if (!entry) | 1267 | if (!entry) |
1218 | return NULL; | 1268 | return NULL; |
1219 | 1269 | ||
@@ -1223,7 +1273,7 @@ static struct btrfs_free_space *find_free_space(struct btrfs_block_group_cache | |||
1223 | continue; | 1273 | continue; |
1224 | 1274 | ||
1225 | if (entry->bitmap) { | 1275 | if (entry->bitmap) { |
1226 | ret = search_bitmap(block_group, entry, offset, bytes); | 1276 | ret = search_bitmap(ctl, entry, offset, bytes); |
1227 | if (!ret) | 1277 | if (!ret) |
1228 | return entry; | 1278 | return entry; |
1229 | continue; | 1279 | continue; |
@@ -1237,33 +1287,28 @@ static struct btrfs_free_space *find_free_space(struct btrfs_block_group_cache | |||
1237 | return NULL; | 1287 | return NULL; |
1238 | } | 1288 | } |
1239 | 1289 | ||
1240 | static void add_new_bitmap(struct btrfs_block_group_cache *block_group, | 1290 | static void add_new_bitmap(struct btrfs_free_space_ctl *ctl, |
1241 | struct btrfs_free_space *info, u64 offset) | 1291 | struct btrfs_free_space *info, u64 offset) |
1242 | { | 1292 | { |
1243 | u64 bytes_per_bg = BITS_PER_BITMAP * block_group->sectorsize; | 1293 | info->offset = offset_to_bitmap(ctl, offset); |
1244 | int max_bitmaps = (int)div64_u64(block_group->key.offset + | ||
1245 | bytes_per_bg - 1, bytes_per_bg); | ||
1246 | BUG_ON(block_group->total_bitmaps >= max_bitmaps); | ||
1247 | |||
1248 | info->offset = offset_to_bitmap(block_group, offset); | ||
1249 | info->bytes = 0; | 1294 | info->bytes = 0; |
1250 | link_free_space(block_group, info); | 1295 | link_free_space(ctl, info); |
1251 | block_group->total_bitmaps++; | 1296 | ctl->total_bitmaps++; |
1252 | 1297 | ||
1253 | recalculate_thresholds(block_group); | 1298 | ctl->op->recalc_thresholds(ctl); |
1254 | } | 1299 | } |
1255 | 1300 | ||
1256 | static void free_bitmap(struct btrfs_block_group_cache *block_group, | 1301 | static void free_bitmap(struct btrfs_free_space_ctl *ctl, |
1257 | struct btrfs_free_space *bitmap_info) | 1302 | struct btrfs_free_space *bitmap_info) |
1258 | { | 1303 | { |
1259 | unlink_free_space(block_group, bitmap_info); | 1304 | unlink_free_space(ctl, bitmap_info); |
1260 | kfree(bitmap_info->bitmap); | 1305 | kfree(bitmap_info->bitmap); |
1261 | kmem_cache_free(btrfs_free_space_cachep, bitmap_info); | 1306 | kmem_cache_free(btrfs_free_space_cachep, bitmap_info); |
1262 | block_group->total_bitmaps--; | 1307 | ctl->total_bitmaps--; |
1263 | recalculate_thresholds(block_group); | 1308 | ctl->op->recalc_thresholds(ctl); |
1264 | } | 1309 | } |
1265 | 1310 | ||
1266 | static noinline int remove_from_bitmap(struct btrfs_block_group_cache *block_group, | 1311 | static noinline int remove_from_bitmap(struct btrfs_free_space_ctl *ctl, |
1267 | struct btrfs_free_space *bitmap_info, | 1312 | struct btrfs_free_space *bitmap_info, |
1268 | u64 *offset, u64 *bytes) | 1313 | u64 *offset, u64 *bytes) |
1269 | { | 1314 | { |
@@ -1272,8 +1317,7 @@ static noinline int remove_from_bitmap(struct btrfs_block_group_cache *block_gro | |||
1272 | int ret; | 1317 | int ret; |
1273 | 1318 | ||
1274 | again: | 1319 | again: |
1275 | end = bitmap_info->offset + | 1320 | end = bitmap_info->offset + (u64)(BITS_PER_BITMAP * ctl->unit) - 1; |
1276 | (u64)(BITS_PER_BITMAP * block_group->sectorsize) - 1; | ||
1277 | 1321 | ||
1278 | /* | 1322 | /* |
1279 | * XXX - this can go away after a few releases. | 1323 | * XXX - this can go away after a few releases. |
@@ -1288,24 +1332,22 @@ again: | |||
1288 | search_start = *offset; | 1332 | search_start = *offset; |
1289 | search_bytes = *bytes; | 1333 | search_bytes = *bytes; |
1290 | search_bytes = min(search_bytes, end - search_start + 1); | 1334 | search_bytes = min(search_bytes, end - search_start + 1); |
1291 | ret = search_bitmap(block_group, bitmap_info, &search_start, | 1335 | ret = search_bitmap(ctl, bitmap_info, &search_start, &search_bytes); |
1292 | &search_bytes); | ||
1293 | BUG_ON(ret < 0 || search_start != *offset); | 1336 | BUG_ON(ret < 0 || search_start != *offset); |
1294 | 1337 | ||
1295 | if (*offset > bitmap_info->offset && *offset + *bytes > end) { | 1338 | if (*offset > bitmap_info->offset && *offset + *bytes > end) { |
1296 | bitmap_clear_bits(block_group, bitmap_info, *offset, | 1339 | bitmap_clear_bits(ctl, bitmap_info, *offset, end - *offset + 1); |
1297 | end - *offset + 1); | ||
1298 | *bytes -= end - *offset + 1; | 1340 | *bytes -= end - *offset + 1; |
1299 | *offset = end + 1; | 1341 | *offset = end + 1; |
1300 | } else if (*offset >= bitmap_info->offset && *offset + *bytes <= end) { | 1342 | } else if (*offset >= bitmap_info->offset && *offset + *bytes <= end) { |
1301 | bitmap_clear_bits(block_group, bitmap_info, *offset, *bytes); | 1343 | bitmap_clear_bits(ctl, bitmap_info, *offset, *bytes); |
1302 | *bytes = 0; | 1344 | *bytes = 0; |
1303 | } | 1345 | } |
1304 | 1346 | ||
1305 | if (*bytes) { | 1347 | if (*bytes) { |
1306 | struct rb_node *next = rb_next(&bitmap_info->offset_index); | 1348 | struct rb_node *next = rb_next(&bitmap_info->offset_index); |
1307 | if (!bitmap_info->bytes) | 1349 | if (!bitmap_info->bytes) |
1308 | free_bitmap(block_group, bitmap_info); | 1350 | free_bitmap(ctl, bitmap_info); |
1309 | 1351 | ||
1310 | /* | 1352 | /* |
1311 | * no entry after this bitmap, but we still have bytes to | 1353 | * no entry after this bitmap, but we still have bytes to |
@@ -1332,31 +1374,28 @@ again: | |||
1332 | */ | 1374 | */ |
1333 | search_start = *offset; | 1375 | search_start = *offset; |
1334 | search_bytes = *bytes; | 1376 | search_bytes = *bytes; |
1335 | ret = search_bitmap(block_group, bitmap_info, &search_start, | 1377 | ret = search_bitmap(ctl, bitmap_info, &search_start, |
1336 | &search_bytes); | 1378 | &search_bytes); |
1337 | if (ret < 0 || search_start != *offset) | 1379 | if (ret < 0 || search_start != *offset) |
1338 | return -EAGAIN; | 1380 | return -EAGAIN; |
1339 | 1381 | ||
1340 | goto again; | 1382 | goto again; |
1341 | } else if (!bitmap_info->bytes) | 1383 | } else if (!bitmap_info->bytes) |
1342 | free_bitmap(block_group, bitmap_info); | 1384 | free_bitmap(ctl, bitmap_info); |
1343 | 1385 | ||
1344 | return 0; | 1386 | return 0; |
1345 | } | 1387 | } |
1346 | 1388 | ||
1347 | static int insert_into_bitmap(struct btrfs_block_group_cache *block_group, | 1389 | static bool use_bitmap(struct btrfs_free_space_ctl *ctl, |
1348 | struct btrfs_free_space *info) | 1390 | struct btrfs_free_space *info) |
1349 | { | 1391 | { |
1350 | struct btrfs_free_space *bitmap_info; | 1392 | struct btrfs_block_group_cache *block_group = ctl->private; |
1351 | int added = 0; | ||
1352 | u64 bytes, offset, end; | ||
1353 | int ret; | ||
1354 | 1393 | ||
1355 | /* | 1394 | /* |
1356 | * If we are below the extents threshold then we can add this as an | 1395 | * If we are below the extents threshold then we can add this as an |
1357 | * extent, and don't have to deal with the bitmap | 1396 | * extent, and don't have to deal with the bitmap |
1358 | */ | 1397 | */ |
1359 | if (block_group->free_extents < block_group->extents_thresh) { | 1398 | if (ctl->free_extents < ctl->extents_thresh) { |
1360 | /* | 1399 | /* |
1361 | * If this block group has some small extents we don't want to | 1400 | * If this block group has some small extents we don't want to |
1362 | * use up all of our free slots in the cache with them, we want | 1401 | * use up all of our free slots in the cache with them, we want |
@@ -1365,11 +1404,10 @@ static int insert_into_bitmap(struct btrfs_block_group_cache *block_group, | |||
1365 | * the overhead of a bitmap if we don't have to. | 1404 | * the overhead of a bitmap if we don't have to. |
1366 | */ | 1405 | */ |
1367 | if (info->bytes <= block_group->sectorsize * 4) { | 1406 | if (info->bytes <= block_group->sectorsize * 4) { |
1368 | if (block_group->free_extents * 2 <= | 1407 | if (ctl->free_extents * 2 <= ctl->extents_thresh) |
1369 | block_group->extents_thresh) | 1408 | return false; |
1370 | return 0; | ||
1371 | } else { | 1409 | } else { |
1372 | return 0; | 1410 | return false; |
1373 | } | 1411 | } |
1374 | } | 1412 | } |
1375 | 1413 | ||
@@ -1379,31 +1417,42 @@ static int insert_into_bitmap(struct btrfs_block_group_cache *block_group, | |||
1379 | */ | 1417 | */ |
1380 | if (BITS_PER_BITMAP * block_group->sectorsize > | 1418 | if (BITS_PER_BITMAP * block_group->sectorsize > |
1381 | block_group->key.offset) | 1419 | block_group->key.offset) |
1382 | return 0; | 1420 | return false; |
1421 | |||
1422 | return true; | ||
1423 | } | ||
1424 | |||
1425 | static int insert_into_bitmap(struct btrfs_free_space_ctl *ctl, | ||
1426 | struct btrfs_free_space *info) | ||
1427 | { | ||
1428 | struct btrfs_free_space *bitmap_info; | ||
1429 | int added = 0; | ||
1430 | u64 bytes, offset, end; | ||
1431 | int ret; | ||
1383 | 1432 | ||
1384 | bytes = info->bytes; | 1433 | bytes = info->bytes; |
1385 | offset = info->offset; | 1434 | offset = info->offset; |
1386 | 1435 | ||
1436 | if (!ctl->op->use_bitmap(ctl, info)) | ||
1437 | return 0; | ||
1438 | |||
1387 | again: | 1439 | again: |
1388 | bitmap_info = tree_search_offset(block_group, | 1440 | bitmap_info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset), |
1389 | offset_to_bitmap(block_group, offset), | ||
1390 | 1, 0); | 1441 | 1, 0); |
1391 | if (!bitmap_info) { | 1442 | if (!bitmap_info) { |
1392 | BUG_ON(added); | 1443 | BUG_ON(added); |
1393 | goto new_bitmap; | 1444 | goto new_bitmap; |
1394 | } | 1445 | } |
1395 | 1446 | ||
1396 | end = bitmap_info->offset + | 1447 | end = bitmap_info->offset + (u64)(BITS_PER_BITMAP * ctl->unit); |
1397 | (u64)(BITS_PER_BITMAP * block_group->sectorsize); | ||
1398 | 1448 | ||
1399 | if (offset >= bitmap_info->offset && offset + bytes > end) { | 1449 | if (offset >= bitmap_info->offset && offset + bytes > end) { |
1400 | bitmap_set_bits(block_group, bitmap_info, offset, | 1450 | bitmap_set_bits(ctl, bitmap_info, offset, end - offset); |
1401 | end - offset); | ||
1402 | bytes -= end - offset; | 1451 | bytes -= end - offset; |
1403 | offset = end; | 1452 | offset = end; |
1404 | added = 0; | 1453 | added = 0; |
1405 | } else if (offset >= bitmap_info->offset && offset + bytes <= end) { | 1454 | } else if (offset >= bitmap_info->offset && offset + bytes <= end) { |
1406 | bitmap_set_bits(block_group, bitmap_info, offset, bytes); | 1455 | bitmap_set_bits(ctl, bitmap_info, offset, bytes); |
1407 | bytes = 0; | 1456 | bytes = 0; |
1408 | } else { | 1457 | } else { |
1409 | BUG(); | 1458 | BUG(); |
@@ -1417,19 +1466,19 @@ again: | |||
1417 | 1466 | ||
1418 | new_bitmap: | 1467 | new_bitmap: |
1419 | if (info && info->bitmap) { | 1468 | if (info && info->bitmap) { |
1420 | add_new_bitmap(block_group, info, offset); | 1469 | add_new_bitmap(ctl, info, offset); |
1421 | added = 1; | 1470 | added = 1; |
1422 | info = NULL; | 1471 | info = NULL; |
1423 | goto again; | 1472 | goto again; |
1424 | } else { | 1473 | } else { |
1425 | spin_unlock(&block_group->tree_lock); | 1474 | spin_unlock(&ctl->tree_lock); |
1426 | 1475 | ||
1427 | /* no pre-allocated info, allocate a new one */ | 1476 | /* no pre-allocated info, allocate a new one */ |
1428 | if (!info) { | 1477 | if (!info) { |
1429 | info = kmem_cache_zalloc(btrfs_free_space_cachep, | 1478 | info = kmem_cache_zalloc(btrfs_free_space_cachep, |
1430 | GFP_NOFS); | 1479 | GFP_NOFS); |
1431 | if (!info) { | 1480 | if (!info) { |
1432 | spin_lock(&block_group->tree_lock); | 1481 | spin_lock(&ctl->tree_lock); |
1433 | ret = -ENOMEM; | 1482 | ret = -ENOMEM; |
1434 | goto out; | 1483 | goto out; |
1435 | } | 1484 | } |
@@ -1437,7 +1486,7 @@ new_bitmap: | |||
1437 | 1486 | ||
1438 | /* allocate the bitmap */ | 1487 | /* allocate the bitmap */ |
1439 | info->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); | 1488 | info->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); |
1440 | spin_lock(&block_group->tree_lock); | 1489 | spin_lock(&ctl->tree_lock); |
1441 | if (!info->bitmap) { | 1490 | if (!info->bitmap) { |
1442 | ret = -ENOMEM; | 1491 | ret = -ENOMEM; |
1443 | goto out; | 1492 | goto out; |
@@ -1455,8 +1504,8 @@ out: | |||
1455 | return ret; | 1504 | return ret; |
1456 | } | 1505 | } |
1457 | 1506 | ||
1458 | static bool try_merge_free_space(struct btrfs_block_group_cache *block_group, | 1507 | static bool try_merge_free_space(struct btrfs_free_space_ctl *ctl, |
1459 | struct btrfs_free_space *info, bool update_stat) | 1508 | struct btrfs_free_space *info, bool update_stat) |
1460 | { | 1509 | { |
1461 | struct btrfs_free_space *left_info; | 1510 | struct btrfs_free_space *left_info; |
1462 | struct btrfs_free_space *right_info; | 1511 | struct btrfs_free_space *right_info; |
@@ -1469,18 +1518,18 @@ static bool try_merge_free_space(struct btrfs_block_group_cache *block_group, | |||
1469 | * are adding, if there is remove that struct and add a new one to | 1518 | * are adding, if there is remove that struct and add a new one to |
1470 | * cover the entire range | 1519 | * cover the entire range |
1471 | */ | 1520 | */ |
1472 | right_info = tree_search_offset(block_group, offset + bytes, 0, 0); | 1521 | right_info = tree_search_offset(ctl, offset + bytes, 0, 0); |
1473 | if (right_info && rb_prev(&right_info->offset_index)) | 1522 | if (right_info && rb_prev(&right_info->offset_index)) |
1474 | left_info = rb_entry(rb_prev(&right_info->offset_index), | 1523 | left_info = rb_entry(rb_prev(&right_info->offset_index), |
1475 | struct btrfs_free_space, offset_index); | 1524 | struct btrfs_free_space, offset_index); |
1476 | else | 1525 | else |
1477 | left_info = tree_search_offset(block_group, offset - 1, 0, 0); | 1526 | left_info = tree_search_offset(ctl, offset - 1, 0, 0); |
1478 | 1527 | ||
1479 | if (right_info && !right_info->bitmap) { | 1528 | if (right_info && !right_info->bitmap) { |
1480 | if (update_stat) | 1529 | if (update_stat) |
1481 | unlink_free_space(block_group, right_info); | 1530 | unlink_free_space(ctl, right_info); |
1482 | else | 1531 | else |
1483 | __unlink_free_space(block_group, right_info); | 1532 | __unlink_free_space(ctl, right_info); |
1484 | info->bytes += right_info->bytes; | 1533 | info->bytes += right_info->bytes; |
1485 | kmem_cache_free(btrfs_free_space_cachep, right_info); | 1534 | kmem_cache_free(btrfs_free_space_cachep, right_info); |
1486 | merged = true; | 1535 | merged = true; |
@@ -1489,9 +1538,9 @@ static bool try_merge_free_space(struct btrfs_block_group_cache *block_group, | |||
1489 | if (left_info && !left_info->bitmap && | 1538 | if (left_info && !left_info->bitmap && |
1490 | left_info->offset + left_info->bytes == offset) { | 1539 | left_info->offset + left_info->bytes == offset) { |
1491 | if (update_stat) | 1540 | if (update_stat) |
1492 | unlink_free_space(block_group, left_info); | 1541 | unlink_free_space(ctl, left_info); |
1493 | else | 1542 | else |
1494 | __unlink_free_space(block_group, left_info); | 1543 | __unlink_free_space(ctl, left_info); |
1495 | info->offset = left_info->offset; | 1544 | info->offset = left_info->offset; |
1496 | info->bytes += left_info->bytes; | 1545 | info->bytes += left_info->bytes; |
1497 | kmem_cache_free(btrfs_free_space_cachep, left_info); | 1546 | kmem_cache_free(btrfs_free_space_cachep, left_info); |
@@ -1501,8 +1550,8 @@ static bool try_merge_free_space(struct btrfs_block_group_cache *block_group, | |||
1501 | return merged; | 1550 | return merged; |
1502 | } | 1551 | } |
1503 | 1552 | ||
1504 | int btrfs_add_free_space(struct btrfs_block_group_cache *block_group, | 1553 | int __btrfs_add_free_space(struct btrfs_free_space_ctl *ctl, |
1505 | u64 offset, u64 bytes) | 1554 | u64 offset, u64 bytes) |
1506 | { | 1555 | { |
1507 | struct btrfs_free_space *info; | 1556 | struct btrfs_free_space *info; |
1508 | int ret = 0; | 1557 | int ret = 0; |
@@ -1514,9 +1563,9 @@ int btrfs_add_free_space(struct btrfs_block_group_cache *block_group, | |||
1514 | info->offset = offset; | 1563 | info->offset = offset; |
1515 | info->bytes = bytes; | 1564 | info->bytes = bytes; |
1516 | 1565 | ||
1517 | spin_lock(&block_group->tree_lock); | 1566 | spin_lock(&ctl->tree_lock); |
1518 | 1567 | ||
1519 | if (try_merge_free_space(block_group, info, true)) | 1568 | if (try_merge_free_space(ctl, info, true)) |
1520 | goto link; | 1569 | goto link; |
1521 | 1570 | ||
1522 | /* | 1571 | /* |
@@ -1524,7 +1573,7 @@ int btrfs_add_free_space(struct btrfs_block_group_cache *block_group, | |||
1524 | * extent then we know we're going to have to allocate a new extent, so | 1573 | * extent then we know we're going to have to allocate a new extent, so |
1525 | * before we do that see if we need to drop this into a bitmap | 1574 | * before we do that see if we need to drop this into a bitmap |
1526 | */ | 1575 | */ |
1527 | ret = insert_into_bitmap(block_group, info); | 1576 | ret = insert_into_bitmap(ctl, info); |
1528 | if (ret < 0) { | 1577 | if (ret < 0) { |
1529 | goto out; | 1578 | goto out; |
1530 | } else if (ret) { | 1579 | } else if (ret) { |
@@ -1532,11 +1581,11 @@ int btrfs_add_free_space(struct btrfs_block_group_cache *block_group, | |||
1532 | goto out; | 1581 | goto out; |
1533 | } | 1582 | } |
1534 | link: | 1583 | link: |
1535 | ret = link_free_space(block_group, info); | 1584 | ret = link_free_space(ctl, info); |
1536 | if (ret) | 1585 | if (ret) |
1537 | kmem_cache_free(btrfs_free_space_cachep, info); | 1586 | kmem_cache_free(btrfs_free_space_cachep, info); |
1538 | out: | 1587 | out: |
1539 | spin_unlock(&block_group->tree_lock); | 1588 | spin_unlock(&ctl->tree_lock); |
1540 | 1589 | ||
1541 | if (ret) { | 1590 | if (ret) { |
1542 | printk(KERN_CRIT "btrfs: unable to add free space :%d\n", ret); | 1591 | printk(KERN_CRIT "btrfs: unable to add free space :%d\n", ret); |
@@ -1549,21 +1598,21 @@ out: | |||
1549 | int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, | 1598 | int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, |
1550 | u64 offset, u64 bytes) | 1599 | u64 offset, u64 bytes) |
1551 | { | 1600 | { |
1601 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
1552 | struct btrfs_free_space *info; | 1602 | struct btrfs_free_space *info; |
1553 | struct btrfs_free_space *next_info = NULL; | 1603 | struct btrfs_free_space *next_info = NULL; |
1554 | int ret = 0; | 1604 | int ret = 0; |
1555 | 1605 | ||
1556 | spin_lock(&block_group->tree_lock); | 1606 | spin_lock(&ctl->tree_lock); |
1557 | 1607 | ||
1558 | again: | 1608 | again: |
1559 | info = tree_search_offset(block_group, offset, 0, 0); | 1609 | info = tree_search_offset(ctl, offset, 0, 0); |
1560 | if (!info) { | 1610 | if (!info) { |
1561 | /* | 1611 | /* |
1562 | * oops didn't find an extent that matched the space we wanted | 1612 | * oops didn't find an extent that matched the space we wanted |
1563 | * to remove, look for a bitmap instead | 1613 | * to remove, look for a bitmap instead |
1564 | */ | 1614 | */ |
1565 | info = tree_search_offset(block_group, | 1615 | info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset), |
1566 | offset_to_bitmap(block_group, offset), | ||
1567 | 1, 0); | 1616 | 1, 0); |
1568 | if (!info) { | 1617 | if (!info) { |
1569 | WARN_ON(1); | 1618 | WARN_ON(1); |
@@ -1578,8 +1627,8 @@ again: | |||
1578 | offset_index); | 1627 | offset_index); |
1579 | 1628 | ||
1580 | if (next_info->bitmap) | 1629 | if (next_info->bitmap) |
1581 | end = next_info->offset + BITS_PER_BITMAP * | 1630 | end = next_info->offset + |
1582 | block_group->sectorsize - 1; | 1631 | BITS_PER_BITMAP * ctl->unit - 1; |
1583 | else | 1632 | else |
1584 | end = next_info->offset + next_info->bytes; | 1633 | end = next_info->offset + next_info->bytes; |
1585 | 1634 | ||
@@ -1599,20 +1648,20 @@ again: | |||
1599 | } | 1648 | } |
1600 | 1649 | ||
1601 | if (info->bytes == bytes) { | 1650 | if (info->bytes == bytes) { |
1602 | unlink_free_space(block_group, info); | 1651 | unlink_free_space(ctl, info); |
1603 | if (info->bitmap) { | 1652 | if (info->bitmap) { |
1604 | kfree(info->bitmap); | 1653 | kfree(info->bitmap); |
1605 | block_group->total_bitmaps--; | 1654 | ctl->total_bitmaps--; |
1606 | } | 1655 | } |
1607 | kmem_cache_free(btrfs_free_space_cachep, info); | 1656 | kmem_cache_free(btrfs_free_space_cachep, info); |
1608 | goto out_lock; | 1657 | goto out_lock; |
1609 | } | 1658 | } |
1610 | 1659 | ||
1611 | if (!info->bitmap && info->offset == offset) { | 1660 | if (!info->bitmap && info->offset == offset) { |
1612 | unlink_free_space(block_group, info); | 1661 | unlink_free_space(ctl, info); |
1613 | info->offset += bytes; | 1662 | info->offset += bytes; |
1614 | info->bytes -= bytes; | 1663 | info->bytes -= bytes; |
1615 | link_free_space(block_group, info); | 1664 | link_free_space(ctl, info); |
1616 | goto out_lock; | 1665 | goto out_lock; |
1617 | } | 1666 | } |
1618 | 1667 | ||
@@ -1626,13 +1675,13 @@ again: | |||
1626 | * first unlink the old info and then | 1675 | * first unlink the old info and then |
1627 | * insert it again after the hole we're creating | 1676 | * insert it again after the hole we're creating |
1628 | */ | 1677 | */ |
1629 | unlink_free_space(block_group, info); | 1678 | unlink_free_space(ctl, info); |
1630 | if (offset + bytes < info->offset + info->bytes) { | 1679 | if (offset + bytes < info->offset + info->bytes) { |
1631 | u64 old_end = info->offset + info->bytes; | 1680 | u64 old_end = info->offset + info->bytes; |
1632 | 1681 | ||
1633 | info->offset = offset + bytes; | 1682 | info->offset = offset + bytes; |
1634 | info->bytes = old_end - info->offset; | 1683 | info->bytes = old_end - info->offset; |
1635 | ret = link_free_space(block_group, info); | 1684 | ret = link_free_space(ctl, info); |
1636 | WARN_ON(ret); | 1685 | WARN_ON(ret); |
1637 | if (ret) | 1686 | if (ret) |
1638 | goto out_lock; | 1687 | goto out_lock; |
@@ -1642,7 +1691,7 @@ again: | |||
1642 | */ | 1691 | */ |
1643 | kmem_cache_free(btrfs_free_space_cachep, info); | 1692 | kmem_cache_free(btrfs_free_space_cachep, info); |
1644 | } | 1693 | } |
1645 | spin_unlock(&block_group->tree_lock); | 1694 | spin_unlock(&ctl->tree_lock); |
1646 | 1695 | ||
1647 | /* step two, insert a new info struct to cover | 1696 | /* step two, insert a new info struct to cover |
1648 | * anything before the hole | 1697 | * anything before the hole |
@@ -1653,12 +1702,12 @@ again: | |||
1653 | goto out; | 1702 | goto out; |
1654 | } | 1703 | } |
1655 | 1704 | ||
1656 | ret = remove_from_bitmap(block_group, info, &offset, &bytes); | 1705 | ret = remove_from_bitmap(ctl, info, &offset, &bytes); |
1657 | if (ret == -EAGAIN) | 1706 | if (ret == -EAGAIN) |
1658 | goto again; | 1707 | goto again; |
1659 | BUG_ON(ret); | 1708 | BUG_ON(ret); |
1660 | out_lock: | 1709 | out_lock: |
1661 | spin_unlock(&block_group->tree_lock); | 1710 | spin_unlock(&ctl->tree_lock); |
1662 | out: | 1711 | out: |
1663 | return ret; | 1712 | return ret; |
1664 | } | 1713 | } |
@@ -1666,11 +1715,12 @@ out: | |||
1666 | void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group, | 1715 | void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group, |
1667 | u64 bytes) | 1716 | u64 bytes) |
1668 | { | 1717 | { |
1718 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
1669 | struct btrfs_free_space *info; | 1719 | struct btrfs_free_space *info; |
1670 | struct rb_node *n; | 1720 | struct rb_node *n; |
1671 | int count = 0; | 1721 | int count = 0; |
1672 | 1722 | ||
1673 | for (n = rb_first(&block_group->free_space_offset); n; n = rb_next(n)) { | 1723 | for (n = rb_first(&ctl->free_space_offset); n; n = rb_next(n)) { |
1674 | info = rb_entry(n, struct btrfs_free_space, offset_index); | 1724 | info = rb_entry(n, struct btrfs_free_space, offset_index); |
1675 | if (info->bytes >= bytes) | 1725 | if (info->bytes >= bytes) |
1676 | count++; | 1726 | count++; |
@@ -1685,6 +1735,30 @@ void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group, | |||
1685 | "\n", count); | 1735 | "\n", count); |
1686 | } | 1736 | } |
1687 | 1737 | ||
1738 | static struct btrfs_free_space_op free_space_op = { | ||
1739 | .recalc_thresholds = recalculate_thresholds, | ||
1740 | .use_bitmap = use_bitmap, | ||
1741 | }; | ||
1742 | |||
1743 | void btrfs_init_free_space_ctl(struct btrfs_block_group_cache *block_group) | ||
1744 | { | ||
1745 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
1746 | |||
1747 | spin_lock_init(&ctl->tree_lock); | ||
1748 | ctl->unit = block_group->sectorsize; | ||
1749 | ctl->start = block_group->key.objectid; | ||
1750 | ctl->private = block_group; | ||
1751 | ctl->op = &free_space_op; | ||
1752 | |||
1753 | /* | ||
1754 | * we only want to have 32k of ram per block group for keeping | ||
1755 | * track of free space, and if we pass 1/2 of that we want to | ||
1756 | * start converting things over to using bitmaps | ||
1757 | */ | ||
1758 | ctl->extents_thresh = ((1024 * 32) / 2) / | ||
1759 | sizeof(struct btrfs_free_space); | ||
1760 | } | ||
1761 | |||
1688 | /* | 1762 | /* |
1689 | * for a given cluster, put all of its extents back into the free | 1763 | * for a given cluster, put all of its extents back into the free |
1690 | * space cache. If the block group passed doesn't match the block group | 1764 | * space cache. If the block group passed doesn't match the block group |
@@ -1696,6 +1770,7 @@ __btrfs_return_cluster_to_free_space( | |||
1696 | struct btrfs_block_group_cache *block_group, | 1770 | struct btrfs_block_group_cache *block_group, |
1697 | struct btrfs_free_cluster *cluster) | 1771 | struct btrfs_free_cluster *cluster) |
1698 | { | 1772 | { |
1773 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
1699 | struct btrfs_free_space *entry; | 1774 | struct btrfs_free_space *entry; |
1700 | struct rb_node *node; | 1775 | struct rb_node *node; |
1701 | 1776 | ||
@@ -1717,8 +1792,8 @@ __btrfs_return_cluster_to_free_space( | |||
1717 | 1792 | ||
1718 | bitmap = (entry->bitmap != NULL); | 1793 | bitmap = (entry->bitmap != NULL); |
1719 | if (!bitmap) | 1794 | if (!bitmap) |
1720 | try_merge_free_space(block_group, entry, false); | 1795 | try_merge_free_space(ctl, entry, false); |
1721 | tree_insert_offset(&block_group->free_space_offset, | 1796 | tree_insert_offset(&ctl->free_space_offset, |
1722 | entry->offset, &entry->offset_index, bitmap); | 1797 | entry->offset, &entry->offset_index, bitmap); |
1723 | } | 1798 | } |
1724 | cluster->root = RB_ROOT; | 1799 | cluster->root = RB_ROOT; |
@@ -1729,14 +1804,38 @@ out: | |||
1729 | return 0; | 1804 | return 0; |
1730 | } | 1805 | } |
1731 | 1806 | ||
1732 | void btrfs_remove_free_space_cache(struct btrfs_block_group_cache *block_group) | 1807 | void __btrfs_remove_free_space_cache_locked(struct btrfs_free_space_ctl *ctl) |
1733 | { | 1808 | { |
1734 | struct btrfs_free_space *info; | 1809 | struct btrfs_free_space *info; |
1735 | struct rb_node *node; | 1810 | struct rb_node *node; |
1811 | |||
1812 | while ((node = rb_last(&ctl->free_space_offset)) != NULL) { | ||
1813 | info = rb_entry(node, struct btrfs_free_space, offset_index); | ||
1814 | unlink_free_space(ctl, info); | ||
1815 | kfree(info->bitmap); | ||
1816 | kmem_cache_free(btrfs_free_space_cachep, info); | ||
1817 | if (need_resched()) { | ||
1818 | spin_unlock(&ctl->tree_lock); | ||
1819 | cond_resched(); | ||
1820 | spin_lock(&ctl->tree_lock); | ||
1821 | } | ||
1822 | } | ||
1823 | } | ||
1824 | |||
1825 | void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl) | ||
1826 | { | ||
1827 | spin_lock(&ctl->tree_lock); | ||
1828 | __btrfs_remove_free_space_cache_locked(ctl); | ||
1829 | spin_unlock(&ctl->tree_lock); | ||
1830 | } | ||
1831 | |||
1832 | void btrfs_remove_free_space_cache(struct btrfs_block_group_cache *block_group) | ||
1833 | { | ||
1834 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
1736 | struct btrfs_free_cluster *cluster; | 1835 | struct btrfs_free_cluster *cluster; |
1737 | struct list_head *head; | 1836 | struct list_head *head; |
1738 | 1837 | ||
1739 | spin_lock(&block_group->tree_lock); | 1838 | spin_lock(&ctl->tree_lock); |
1740 | while ((head = block_group->cluster_list.next) != | 1839 | while ((head = block_group->cluster_list.next) != |
1741 | &block_group->cluster_list) { | 1840 | &block_group->cluster_list) { |
1742 | cluster = list_entry(head, struct btrfs_free_cluster, | 1841 | cluster = list_entry(head, struct btrfs_free_cluster, |
@@ -1745,60 +1844,46 @@ void btrfs_remove_free_space_cache(struct btrfs_block_group_cache *block_group) | |||
1745 | WARN_ON(cluster->block_group != block_group); | 1844 | WARN_ON(cluster->block_group != block_group); |
1746 | __btrfs_return_cluster_to_free_space(block_group, cluster); | 1845 | __btrfs_return_cluster_to_free_space(block_group, cluster); |
1747 | if (need_resched()) { | 1846 | if (need_resched()) { |
1748 | spin_unlock(&block_group->tree_lock); | 1847 | spin_unlock(&ctl->tree_lock); |
1749 | cond_resched(); | 1848 | cond_resched(); |
1750 | spin_lock(&block_group->tree_lock); | 1849 | spin_lock(&ctl->tree_lock); |
1751 | } | 1850 | } |
1752 | } | 1851 | } |
1852 | __btrfs_remove_free_space_cache_locked(ctl); | ||
1853 | spin_unlock(&ctl->tree_lock); | ||
1753 | 1854 | ||
1754 | while ((node = rb_last(&block_group->free_space_offset)) != NULL) { | ||
1755 | info = rb_entry(node, struct btrfs_free_space, offset_index); | ||
1756 | if (!info->bitmap) { | ||
1757 | unlink_free_space(block_group, info); | ||
1758 | kmem_cache_free(btrfs_free_space_cachep, info); | ||
1759 | } else { | ||
1760 | free_bitmap(block_group, info); | ||
1761 | } | ||
1762 | |||
1763 | if (need_resched()) { | ||
1764 | spin_unlock(&block_group->tree_lock); | ||
1765 | cond_resched(); | ||
1766 | spin_lock(&block_group->tree_lock); | ||
1767 | } | ||
1768 | } | ||
1769 | |||
1770 | spin_unlock(&block_group->tree_lock); | ||
1771 | } | 1855 | } |
1772 | 1856 | ||
1773 | u64 btrfs_find_space_for_alloc(struct btrfs_block_group_cache *block_group, | 1857 | u64 btrfs_find_space_for_alloc(struct btrfs_block_group_cache *block_group, |
1774 | u64 offset, u64 bytes, u64 empty_size) | 1858 | u64 offset, u64 bytes, u64 empty_size) |
1775 | { | 1859 | { |
1860 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
1776 | struct btrfs_free_space *entry = NULL; | 1861 | struct btrfs_free_space *entry = NULL; |
1777 | u64 bytes_search = bytes + empty_size; | 1862 | u64 bytes_search = bytes + empty_size; |
1778 | u64 ret = 0; | 1863 | u64 ret = 0; |
1779 | 1864 | ||
1780 | spin_lock(&block_group->tree_lock); | 1865 | spin_lock(&ctl->tree_lock); |
1781 | entry = find_free_space(block_group, &offset, &bytes_search, 0); | 1866 | entry = find_free_space(ctl, &offset, &bytes_search); |
1782 | if (!entry) | 1867 | if (!entry) |
1783 | goto out; | 1868 | goto out; |
1784 | 1869 | ||
1785 | ret = offset; | 1870 | ret = offset; |
1786 | if (entry->bitmap) { | 1871 | if (entry->bitmap) { |
1787 | bitmap_clear_bits(block_group, entry, offset, bytes); | 1872 | bitmap_clear_bits(ctl, entry, offset, bytes); |
1788 | if (!entry->bytes) | 1873 | if (!entry->bytes) |
1789 | free_bitmap(block_group, entry); | 1874 | free_bitmap(ctl, entry); |
1790 | } else { | 1875 | } else { |
1791 | unlink_free_space(block_group, entry); | 1876 | unlink_free_space(ctl, entry); |
1792 | entry->offset += bytes; | 1877 | entry->offset += bytes; |
1793 | entry->bytes -= bytes; | 1878 | entry->bytes -= bytes; |
1794 | if (!entry->bytes) | 1879 | if (!entry->bytes) |
1795 | kmem_cache_free(btrfs_free_space_cachep, entry); | 1880 | kmem_cache_free(btrfs_free_space_cachep, entry); |
1796 | else | 1881 | else |
1797 | link_free_space(block_group, entry); | 1882 | link_free_space(ctl, entry); |
1798 | } | 1883 | } |
1799 | 1884 | ||
1800 | out: | 1885 | out: |
1801 | spin_unlock(&block_group->tree_lock); | 1886 | spin_unlock(&ctl->tree_lock); |
1802 | 1887 | ||
1803 | return ret; | 1888 | return ret; |
1804 | } | 1889 | } |
@@ -1815,6 +1900,7 @@ int btrfs_return_cluster_to_free_space( | |||
1815 | struct btrfs_block_group_cache *block_group, | 1900 | struct btrfs_block_group_cache *block_group, |
1816 | struct btrfs_free_cluster *cluster) | 1901 | struct btrfs_free_cluster *cluster) |
1817 | { | 1902 | { |
1903 | struct btrfs_free_space_ctl *ctl; | ||
1818 | int ret; | 1904 | int ret; |
1819 | 1905 | ||
1820 | /* first, get a safe pointer to the block group */ | 1906 | /* first, get a safe pointer to the block group */ |
@@ -1833,10 +1919,12 @@ int btrfs_return_cluster_to_free_space( | |||
1833 | atomic_inc(&block_group->count); | 1919 | atomic_inc(&block_group->count); |
1834 | spin_unlock(&cluster->lock); | 1920 | spin_unlock(&cluster->lock); |
1835 | 1921 | ||
1922 | ctl = block_group->free_space_ctl; | ||
1923 | |||
1836 | /* now return any extents the cluster had on it */ | 1924 | /* now return any extents the cluster had on it */ |
1837 | spin_lock(&block_group->tree_lock); | 1925 | spin_lock(&ctl->tree_lock); |
1838 | ret = __btrfs_return_cluster_to_free_space(block_group, cluster); | 1926 | ret = __btrfs_return_cluster_to_free_space(block_group, cluster); |
1839 | spin_unlock(&block_group->tree_lock); | 1927 | spin_unlock(&ctl->tree_lock); |
1840 | 1928 | ||
1841 | /* finally drop our ref */ | 1929 | /* finally drop our ref */ |
1842 | btrfs_put_block_group(block_group); | 1930 | btrfs_put_block_group(block_group); |
@@ -1848,6 +1936,7 @@ static u64 btrfs_alloc_from_bitmap(struct btrfs_block_group_cache *block_group, | |||
1848 | struct btrfs_free_space *entry, | 1936 | struct btrfs_free_space *entry, |
1849 | u64 bytes, u64 min_start) | 1937 | u64 bytes, u64 min_start) |
1850 | { | 1938 | { |
1939 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
1851 | int err; | 1940 | int err; |
1852 | u64 search_start = cluster->window_start; | 1941 | u64 search_start = cluster->window_start; |
1853 | u64 search_bytes = bytes; | 1942 | u64 search_bytes = bytes; |
@@ -1856,13 +1945,12 @@ static u64 btrfs_alloc_from_bitmap(struct btrfs_block_group_cache *block_group, | |||
1856 | search_start = min_start; | 1945 | search_start = min_start; |
1857 | search_bytes = bytes; | 1946 | search_bytes = bytes; |
1858 | 1947 | ||
1859 | err = search_bitmap(block_group, entry, &search_start, | 1948 | err = search_bitmap(ctl, entry, &search_start, &search_bytes); |
1860 | &search_bytes); | ||
1861 | if (err) | 1949 | if (err) |
1862 | return 0; | 1950 | return 0; |
1863 | 1951 | ||
1864 | ret = search_start; | 1952 | ret = search_start; |
1865 | bitmap_clear_bits(block_group, entry, ret, bytes); | 1953 | bitmap_clear_bits(ctl, entry, ret, bytes); |
1866 | 1954 | ||
1867 | return ret; | 1955 | return ret; |
1868 | } | 1956 | } |
@@ -1876,6 +1964,7 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group, | |||
1876 | struct btrfs_free_cluster *cluster, u64 bytes, | 1964 | struct btrfs_free_cluster *cluster, u64 bytes, |
1877 | u64 min_start) | 1965 | u64 min_start) |
1878 | { | 1966 | { |
1967 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
1879 | struct btrfs_free_space *entry = NULL; | 1968 | struct btrfs_free_space *entry = NULL; |
1880 | struct rb_node *node; | 1969 | struct rb_node *node; |
1881 | u64 ret = 0; | 1970 | u64 ret = 0; |
@@ -1933,20 +2022,20 @@ out: | |||
1933 | if (!ret) | 2022 | if (!ret) |
1934 | return 0; | 2023 | return 0; |
1935 | 2024 | ||
1936 | spin_lock(&block_group->tree_lock); | 2025 | spin_lock(&ctl->tree_lock); |
1937 | 2026 | ||
1938 | block_group->free_space -= bytes; | 2027 | ctl->free_space -= bytes; |
1939 | if (entry->bytes == 0) { | 2028 | if (entry->bytes == 0) { |
1940 | block_group->free_extents--; | 2029 | ctl->free_extents--; |
1941 | if (entry->bitmap) { | 2030 | if (entry->bitmap) { |
1942 | kfree(entry->bitmap); | 2031 | kfree(entry->bitmap); |
1943 | block_group->total_bitmaps--; | 2032 | ctl->total_bitmaps--; |
1944 | recalculate_thresholds(block_group); | 2033 | ctl->op->recalc_thresholds(ctl); |
1945 | } | 2034 | } |
1946 | kmem_cache_free(btrfs_free_space_cachep, entry); | 2035 | kmem_cache_free(btrfs_free_space_cachep, entry); |
1947 | } | 2036 | } |
1948 | 2037 | ||
1949 | spin_unlock(&block_group->tree_lock); | 2038 | spin_unlock(&ctl->tree_lock); |
1950 | 2039 | ||
1951 | return ret; | 2040 | return ret; |
1952 | } | 2041 | } |
@@ -1956,6 +2045,7 @@ static int btrfs_bitmap_cluster(struct btrfs_block_group_cache *block_group, | |||
1956 | struct btrfs_free_cluster *cluster, | 2045 | struct btrfs_free_cluster *cluster, |
1957 | u64 offset, u64 bytes, u64 min_bytes) | 2046 | u64 offset, u64 bytes, u64 min_bytes) |
1958 | { | 2047 | { |
2048 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
1959 | unsigned long next_zero; | 2049 | unsigned long next_zero; |
1960 | unsigned long i; | 2050 | unsigned long i; |
1961 | unsigned long search_bits; | 2051 | unsigned long search_bits; |
@@ -2010,7 +2100,7 @@ again: | |||
2010 | 2100 | ||
2011 | cluster->window_start = start * block_group->sectorsize + | 2101 | cluster->window_start = start * block_group->sectorsize + |
2012 | entry->offset; | 2102 | entry->offset; |
2013 | rb_erase(&entry->offset_index, &block_group->free_space_offset); | 2103 | rb_erase(&entry->offset_index, &ctl->free_space_offset); |
2014 | ret = tree_insert_offset(&cluster->root, entry->offset, | 2104 | ret = tree_insert_offset(&cluster->root, entry->offset, |
2015 | &entry->offset_index, 1); | 2105 | &entry->offset_index, 1); |
2016 | BUG_ON(ret); | 2106 | BUG_ON(ret); |
@@ -2025,6 +2115,7 @@ static int setup_cluster_no_bitmap(struct btrfs_block_group_cache *block_group, | |||
2025 | struct btrfs_free_cluster *cluster, | 2115 | struct btrfs_free_cluster *cluster, |
2026 | u64 offset, u64 bytes, u64 min_bytes) | 2116 | u64 offset, u64 bytes, u64 min_bytes) |
2027 | { | 2117 | { |
2118 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
2028 | struct btrfs_free_space *first = NULL; | 2119 | struct btrfs_free_space *first = NULL; |
2029 | struct btrfs_free_space *entry = NULL; | 2120 | struct btrfs_free_space *entry = NULL; |
2030 | struct btrfs_free_space *prev = NULL; | 2121 | struct btrfs_free_space *prev = NULL; |
@@ -2035,7 +2126,7 @@ static int setup_cluster_no_bitmap(struct btrfs_block_group_cache *block_group, | |||
2035 | u64 max_extent; | 2126 | u64 max_extent; |
2036 | u64 max_gap = 128 * 1024; | 2127 | u64 max_gap = 128 * 1024; |
2037 | 2128 | ||
2038 | entry = tree_search_offset(block_group, offset, 0, 1); | 2129 | entry = tree_search_offset(ctl, offset, 0, 1); |
2039 | if (!entry) | 2130 | if (!entry) |
2040 | return -ENOSPC; | 2131 | return -ENOSPC; |
2041 | 2132 | ||
@@ -2101,7 +2192,7 @@ static int setup_cluster_no_bitmap(struct btrfs_block_group_cache *block_group, | |||
2101 | if (entry->bitmap) | 2192 | if (entry->bitmap) |
2102 | continue; | 2193 | continue; |
2103 | 2194 | ||
2104 | rb_erase(&entry->offset_index, &block_group->free_space_offset); | 2195 | rb_erase(&entry->offset_index, &ctl->free_space_offset); |
2105 | ret = tree_insert_offset(&cluster->root, entry->offset, | 2196 | ret = tree_insert_offset(&cluster->root, entry->offset, |
2106 | &entry->offset_index, 0); | 2197 | &entry->offset_index, 0); |
2107 | BUG_ON(ret); | 2198 | BUG_ON(ret); |
@@ -2120,16 +2211,15 @@ static int setup_cluster_bitmap(struct btrfs_block_group_cache *block_group, | |||
2120 | struct btrfs_free_cluster *cluster, | 2211 | struct btrfs_free_cluster *cluster, |
2121 | u64 offset, u64 bytes, u64 min_bytes) | 2212 | u64 offset, u64 bytes, u64 min_bytes) |
2122 | { | 2213 | { |
2214 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
2123 | struct btrfs_free_space *entry; | 2215 | struct btrfs_free_space *entry; |
2124 | struct rb_node *node; | 2216 | struct rb_node *node; |
2125 | int ret = -ENOSPC; | 2217 | int ret = -ENOSPC; |
2126 | 2218 | ||
2127 | if (block_group->total_bitmaps == 0) | 2219 | if (ctl->total_bitmaps == 0) |
2128 | return -ENOSPC; | 2220 | return -ENOSPC; |
2129 | 2221 | ||
2130 | entry = tree_search_offset(block_group, | 2222 | entry = tree_search_offset(ctl, offset_to_bitmap(ctl, offset), 0, 1); |
2131 | offset_to_bitmap(block_group, offset), | ||
2132 | 0, 1); | ||
2133 | if (!entry) | 2223 | if (!entry) |
2134 | return -ENOSPC; | 2224 | return -ENOSPC; |
2135 | 2225 | ||
@@ -2162,6 +2252,7 @@ int btrfs_find_space_cluster(struct btrfs_trans_handle *trans, | |||
2162 | struct btrfs_free_cluster *cluster, | 2252 | struct btrfs_free_cluster *cluster, |
2163 | u64 offset, u64 bytes, u64 empty_size) | 2253 | u64 offset, u64 bytes, u64 empty_size) |
2164 | { | 2254 | { |
2255 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
2165 | u64 min_bytes; | 2256 | u64 min_bytes; |
2166 | int ret; | 2257 | int ret; |
2167 | 2258 | ||
@@ -2181,14 +2272,14 @@ int btrfs_find_space_cluster(struct btrfs_trans_handle *trans, | |||
2181 | } else | 2272 | } else |
2182 | min_bytes = max(bytes, (bytes + empty_size) >> 2); | 2273 | min_bytes = max(bytes, (bytes + empty_size) >> 2); |
2183 | 2274 | ||
2184 | spin_lock(&block_group->tree_lock); | 2275 | spin_lock(&ctl->tree_lock); |
2185 | 2276 | ||
2186 | /* | 2277 | /* |
2187 | * If we know we don't have enough space to make a cluster don't even | 2278 | * If we know we don't have enough space to make a cluster don't even |
2188 | * bother doing all the work to try and find one. | 2279 | * bother doing all the work to try and find one. |
2189 | */ | 2280 | */ |
2190 | if (block_group->free_space < min_bytes) { | 2281 | if (ctl->free_space < min_bytes) { |
2191 | spin_unlock(&block_group->tree_lock); | 2282 | spin_unlock(&ctl->tree_lock); |
2192 | return -ENOSPC; | 2283 | return -ENOSPC; |
2193 | } | 2284 | } |
2194 | 2285 | ||
@@ -2214,7 +2305,7 @@ int btrfs_find_space_cluster(struct btrfs_trans_handle *trans, | |||
2214 | } | 2305 | } |
2215 | out: | 2306 | out: |
2216 | spin_unlock(&cluster->lock); | 2307 | spin_unlock(&cluster->lock); |
2217 | spin_unlock(&block_group->tree_lock); | 2308 | spin_unlock(&ctl->tree_lock); |
2218 | 2309 | ||
2219 | return ret; | 2310 | return ret; |
2220 | } | 2311 | } |
@@ -2235,6 +2326,7 @@ void btrfs_init_free_cluster(struct btrfs_free_cluster *cluster) | |||
2235 | int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group, | 2326 | int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group, |
2236 | u64 *trimmed, u64 start, u64 end, u64 minlen) | 2327 | u64 *trimmed, u64 start, u64 end, u64 minlen) |
2237 | { | 2328 | { |
2329 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | ||
2238 | struct btrfs_free_space *entry = NULL; | 2330 | struct btrfs_free_space *entry = NULL; |
2239 | struct btrfs_fs_info *fs_info = block_group->fs_info; | 2331 | struct btrfs_fs_info *fs_info = block_group->fs_info; |
2240 | u64 bytes = 0; | 2332 | u64 bytes = 0; |
@@ -2244,52 +2336,50 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group, | |||
2244 | *trimmed = 0; | 2336 | *trimmed = 0; |
2245 | 2337 | ||
2246 | while (start < end) { | 2338 | while (start < end) { |
2247 | spin_lock(&block_group->tree_lock); | 2339 | spin_lock(&ctl->tree_lock); |
2248 | 2340 | ||
2249 | if (block_group->free_space < minlen) { | 2341 | if (ctl->free_space < minlen) { |
2250 | spin_unlock(&block_group->tree_lock); | 2342 | spin_unlock(&ctl->tree_lock); |
2251 | break; | 2343 | break; |
2252 | } | 2344 | } |
2253 | 2345 | ||
2254 | entry = tree_search_offset(block_group, start, 0, 1); | 2346 | entry = tree_search_offset(ctl, start, 0, 1); |
2255 | if (!entry) | 2347 | if (!entry) |
2256 | entry = tree_search_offset(block_group, | 2348 | entry = tree_search_offset(ctl, |
2257 | offset_to_bitmap(block_group, | 2349 | offset_to_bitmap(ctl, start), |
2258 | start), | ||
2259 | 1, 1); | 2350 | 1, 1); |
2260 | 2351 | ||
2261 | if (!entry || entry->offset >= end) { | 2352 | if (!entry || entry->offset >= end) { |
2262 | spin_unlock(&block_group->tree_lock); | 2353 | spin_unlock(&ctl->tree_lock); |
2263 | break; | 2354 | break; |
2264 | } | 2355 | } |
2265 | 2356 | ||
2266 | if (entry->bitmap) { | 2357 | if (entry->bitmap) { |
2267 | ret = search_bitmap(block_group, entry, &start, &bytes); | 2358 | ret = search_bitmap(ctl, entry, &start, &bytes); |
2268 | if (!ret) { | 2359 | if (!ret) { |
2269 | if (start >= end) { | 2360 | if (start >= end) { |
2270 | spin_unlock(&block_group->tree_lock); | 2361 | spin_unlock(&ctl->tree_lock); |
2271 | break; | 2362 | break; |
2272 | } | 2363 | } |
2273 | bytes = min(bytes, end - start); | 2364 | bytes = min(bytes, end - start); |
2274 | bitmap_clear_bits(block_group, entry, | 2365 | bitmap_clear_bits(ctl, entry, start, bytes); |
2275 | start, bytes); | ||
2276 | if (entry->bytes == 0) | 2366 | if (entry->bytes == 0) |
2277 | free_bitmap(block_group, entry); | 2367 | free_bitmap(ctl, entry); |
2278 | } else { | 2368 | } else { |
2279 | start = entry->offset + BITS_PER_BITMAP * | 2369 | start = entry->offset + BITS_PER_BITMAP * |
2280 | block_group->sectorsize; | 2370 | block_group->sectorsize; |
2281 | spin_unlock(&block_group->tree_lock); | 2371 | spin_unlock(&ctl->tree_lock); |
2282 | ret = 0; | 2372 | ret = 0; |
2283 | continue; | 2373 | continue; |
2284 | } | 2374 | } |
2285 | } else { | 2375 | } else { |
2286 | start = entry->offset; | 2376 | start = entry->offset; |
2287 | bytes = min(entry->bytes, end - start); | 2377 | bytes = min(entry->bytes, end - start); |
2288 | unlink_free_space(block_group, entry); | 2378 | unlink_free_space(ctl, entry); |
2289 | kmem_cache_free(btrfs_free_space_cachep, entry); | 2379 | kmem_cache_free(btrfs_free_space_cachep, entry); |
2290 | } | 2380 | } |
2291 | 2381 | ||
2292 | spin_unlock(&block_group->tree_lock); | 2382 | spin_unlock(&ctl->tree_lock); |
2293 | 2383 | ||
2294 | if (bytes >= minlen) { | 2384 | if (bytes >= minlen) { |
2295 | int update_ret; | 2385 | int update_ret; |
@@ -2301,8 +2391,7 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group, | |||
2301 | bytes, | 2391 | bytes, |
2302 | &actually_trimmed); | 2392 | &actually_trimmed); |
2303 | 2393 | ||
2304 | btrfs_add_free_space(block_group, | 2394 | btrfs_add_free_space(block_group, start, bytes); |
2305 | start, bytes); | ||
2306 | if (!update_ret) | 2395 | if (!update_ret) |
2307 | btrfs_update_reserved_bytes(block_group, | 2396 | btrfs_update_reserved_bytes(block_group, |
2308 | bytes, 0, 1); | 2397 | bytes, 0, 1); |
@@ -2324,3 +2413,145 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group, | |||
2324 | 2413 | ||
2325 | return ret; | 2414 | return ret; |
2326 | } | 2415 | } |
2416 | |||
2417 | /* | ||
2418 | * Find the left-most item in the cache tree, and then return the | ||
2419 | * smallest inode number in the item. | ||
2420 | * | ||
2421 | * Note: the returned inode number may not be the smallest one in | ||
2422 | * the tree, if the left-most item is a bitmap. | ||
2423 | */ | ||
2424 | u64 btrfs_find_ino_for_alloc(struct btrfs_root *fs_root) | ||
2425 | { | ||
2426 | struct btrfs_free_space_ctl *ctl = fs_root->free_ino_ctl; | ||
2427 | struct btrfs_free_space *entry = NULL; | ||
2428 | u64 ino = 0; | ||
2429 | |||
2430 | spin_lock(&ctl->tree_lock); | ||
2431 | |||
2432 | if (RB_EMPTY_ROOT(&ctl->free_space_offset)) | ||
2433 | goto out; | ||
2434 | |||
2435 | entry = rb_entry(rb_first(&ctl->free_space_offset), | ||
2436 | struct btrfs_free_space, offset_index); | ||
2437 | |||
2438 | if (!entry->bitmap) { | ||
2439 | ino = entry->offset; | ||
2440 | |||
2441 | unlink_free_space(ctl, entry); | ||
2442 | entry->offset++; | ||
2443 | entry->bytes--; | ||
2444 | if (!entry->bytes) | ||
2445 | kmem_cache_free(btrfs_free_space_cachep, entry); | ||
2446 | else | ||
2447 | link_free_space(ctl, entry); | ||
2448 | } else { | ||
2449 | u64 offset = 0; | ||
2450 | u64 count = 1; | ||
2451 | int ret; | ||
2452 | |||
2453 | ret = search_bitmap(ctl, entry, &offset, &count); | ||
2454 | BUG_ON(ret); | ||
2455 | |||
2456 | ino = offset; | ||
2457 | bitmap_clear_bits(ctl, entry, offset, 1); | ||
2458 | if (entry->bytes == 0) | ||
2459 | free_bitmap(ctl, entry); | ||
2460 | } | ||
2461 | out: | ||
2462 | spin_unlock(&ctl->tree_lock); | ||
2463 | |||
2464 | return ino; | ||
2465 | } | ||
2466 | |||
2467 | struct inode *lookup_free_ino_inode(struct btrfs_root *root, | ||
2468 | struct btrfs_path *path) | ||
2469 | { | ||
2470 | struct inode *inode = NULL; | ||
2471 | |||
2472 | spin_lock(&root->cache_lock); | ||
2473 | if (root->cache_inode) | ||
2474 | inode = igrab(root->cache_inode); | ||
2475 | spin_unlock(&root->cache_lock); | ||
2476 | if (inode) | ||
2477 | return inode; | ||
2478 | |||
2479 | inode = __lookup_free_space_inode(root, path, 0); | ||
2480 | if (IS_ERR(inode)) | ||
2481 | return inode; | ||
2482 | |||
2483 | spin_lock(&root->cache_lock); | ||
2484 | if (!root->fs_info->closing) | ||
2485 | root->cache_inode = igrab(inode); | ||
2486 | spin_unlock(&root->cache_lock); | ||
2487 | |||
2488 | return inode; | ||
2489 | } | ||
2490 | |||
2491 | int create_free_ino_inode(struct btrfs_root *root, | ||
2492 | struct btrfs_trans_handle *trans, | ||
2493 | struct btrfs_path *path) | ||
2494 | { | ||
2495 | return __create_free_space_inode(root, trans, path, | ||
2496 | BTRFS_FREE_INO_OBJECTID, 0); | ||
2497 | } | ||
2498 | |||
2499 | int load_free_ino_cache(struct btrfs_fs_info *fs_info, struct btrfs_root *root) | ||
2500 | { | ||
2501 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | ||
2502 | struct btrfs_path *path; | ||
2503 | struct inode *inode; | ||
2504 | int ret = 0; | ||
2505 | u64 root_gen = btrfs_root_generation(&root->root_item); | ||
2506 | |||
2507 | /* | ||
2508 | * If we're unmounting then just return, since this does a search on the | ||
2509 | * normal root and not the commit root and we could deadlock. | ||
2510 | */ | ||
2511 | smp_mb(); | ||
2512 | if (fs_info->closing) | ||
2513 | return 0; | ||
2514 | |||
2515 | path = btrfs_alloc_path(); | ||
2516 | if (!path) | ||
2517 | return 0; | ||
2518 | |||
2519 | inode = lookup_free_ino_inode(root, path); | ||
2520 | if (IS_ERR(inode)) | ||
2521 | goto out; | ||
2522 | |||
2523 | if (root_gen != BTRFS_I(inode)->generation) | ||
2524 | goto out_put; | ||
2525 | |||
2526 | ret = __load_free_space_cache(root, inode, ctl, path, 0); | ||
2527 | |||
2528 | if (ret < 0) | ||
2529 | printk(KERN_ERR "btrfs: failed to load free ino cache for " | ||
2530 | "root %llu\n", root->root_key.objectid); | ||
2531 | out_put: | ||
2532 | iput(inode); | ||
2533 | out: | ||
2534 | btrfs_free_path(path); | ||
2535 | return ret; | ||
2536 | } | ||
2537 | |||
2538 | int btrfs_write_out_ino_cache(struct btrfs_root *root, | ||
2539 | struct btrfs_trans_handle *trans, | ||
2540 | struct btrfs_path *path) | ||
2541 | { | ||
2542 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | ||
2543 | struct inode *inode; | ||
2544 | int ret; | ||
2545 | |||
2546 | inode = lookup_free_ino_inode(root, path); | ||
2547 | if (IS_ERR(inode)) | ||
2548 | return 0; | ||
2549 | |||
2550 | ret = __btrfs_write_out_cache(root, inode, ctl, NULL, trans, path, 0); | ||
2551 | if (ret < 0) | ||
2552 | printk(KERN_ERR "btrfs: failed to write free ino cache " | ||
2553 | "for root %llu\n", root->root_key.objectid); | ||
2554 | |||
2555 | iput(inode); | ||
2556 | return ret; | ||
2557 | } | ||
diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h index 12b2b5165f8..8f2613f779e 100644 --- a/fs/btrfs/free-space-cache.h +++ b/fs/btrfs/free-space-cache.h | |||
@@ -27,6 +27,25 @@ struct btrfs_free_space { | |||
27 | struct list_head list; | 27 | struct list_head list; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | struct btrfs_free_space_ctl { | ||
31 | spinlock_t tree_lock; | ||
32 | struct rb_root free_space_offset; | ||
33 | u64 free_space; | ||
34 | int extents_thresh; | ||
35 | int free_extents; | ||
36 | int total_bitmaps; | ||
37 | int unit; | ||
38 | u64 start; | ||
39 | struct btrfs_free_space_op *op; | ||
40 | void *private; | ||
41 | }; | ||
42 | |||
43 | struct btrfs_free_space_op { | ||
44 | void (*recalc_thresholds)(struct btrfs_free_space_ctl *ctl); | ||
45 | bool (*use_bitmap)(struct btrfs_free_space_ctl *ctl, | ||
46 | struct btrfs_free_space *info); | ||
47 | }; | ||
48 | |||
30 | struct inode *lookup_free_space_inode(struct btrfs_root *root, | 49 | struct inode *lookup_free_space_inode(struct btrfs_root *root, |
31 | struct btrfs_block_group_cache | 50 | struct btrfs_block_group_cache |
32 | *block_group, struct btrfs_path *path); | 51 | *block_group, struct btrfs_path *path); |
@@ -45,14 +64,36 @@ int btrfs_write_out_cache(struct btrfs_root *root, | |||
45 | struct btrfs_trans_handle *trans, | 64 | struct btrfs_trans_handle *trans, |
46 | struct btrfs_block_group_cache *block_group, | 65 | struct btrfs_block_group_cache *block_group, |
47 | struct btrfs_path *path); | 66 | struct btrfs_path *path); |
48 | int btrfs_add_free_space(struct btrfs_block_group_cache *block_group, | 67 | |
49 | u64 bytenr, u64 size); | 68 | struct inode *lookup_free_ino_inode(struct btrfs_root *root, |
69 | struct btrfs_path *path); | ||
70 | int create_free_ino_inode(struct btrfs_root *root, | ||
71 | struct btrfs_trans_handle *trans, | ||
72 | struct btrfs_path *path); | ||
73 | int load_free_ino_cache(struct btrfs_fs_info *fs_info, | ||
74 | struct btrfs_root *root); | ||
75 | int btrfs_write_out_ino_cache(struct btrfs_root *root, | ||
76 | struct btrfs_trans_handle *trans, | ||
77 | struct btrfs_path *path); | ||
78 | |||
79 | void btrfs_init_free_space_ctl(struct btrfs_block_group_cache *block_group); | ||
80 | int __btrfs_add_free_space(struct btrfs_free_space_ctl *ctl, | ||
81 | u64 bytenr, u64 size); | ||
82 | static inline int | ||
83 | btrfs_add_free_space(struct btrfs_block_group_cache *block_group, | ||
84 | u64 bytenr, u64 size) | ||
85 | { | ||
86 | return __btrfs_add_free_space(block_group->free_space_ctl, | ||
87 | bytenr, size); | ||
88 | } | ||
50 | int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, | 89 | int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, |
51 | u64 bytenr, u64 size); | 90 | u64 bytenr, u64 size); |
91 | void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl); | ||
52 | void btrfs_remove_free_space_cache(struct btrfs_block_group_cache | 92 | void btrfs_remove_free_space_cache(struct btrfs_block_group_cache |
53 | *block_group); | 93 | *block_group); |
54 | u64 btrfs_find_space_for_alloc(struct btrfs_block_group_cache *block_group, | 94 | u64 btrfs_find_space_for_alloc(struct btrfs_block_group_cache *block_group, |
55 | u64 offset, u64 bytes, u64 empty_size); | 95 | u64 offset, u64 bytes, u64 empty_size); |
96 | u64 btrfs_find_ino_for_alloc(struct btrfs_root *fs_root); | ||
56 | void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group, | 97 | void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group, |
57 | u64 bytes); | 98 | u64 bytes); |
58 | int btrfs_find_space_cluster(struct btrfs_trans_handle *trans, | 99 | int btrfs_find_space_cluster(struct btrfs_trans_handle *trans, |
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index c05a08f4c41..00097051262 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c | |||
@@ -16,11 +16,430 @@ | |||
16 | * Boston, MA 021110-1307, USA. | 16 | * Boston, MA 021110-1307, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/kthread.h> | ||
21 | #include <linux/pagemap.h> | ||
22 | |||
19 | #include "ctree.h" | 23 | #include "ctree.h" |
20 | #include "disk-io.h" | 24 | #include "disk-io.h" |
25 | #include "free-space-cache.h" | ||
26 | #include "inode-map.h" | ||
21 | #include "transaction.h" | 27 | #include "transaction.h" |
22 | 28 | ||
23 | int btrfs_find_highest_inode(struct btrfs_root *root, u64 *objectid) | 29 | static int caching_kthread(void *data) |
30 | { | ||
31 | struct btrfs_root *root = data; | ||
32 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
33 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | ||
34 | struct btrfs_key key; | ||
35 | struct btrfs_path *path; | ||
36 | struct extent_buffer *leaf; | ||
37 | u64 last = (u64)-1; | ||
38 | int slot; | ||
39 | int ret; | ||
40 | |||
41 | path = btrfs_alloc_path(); | ||
42 | if (!path) | ||
43 | return -ENOMEM; | ||
44 | |||
45 | /* Since the commit root is read-only, we can safely skip locking. */ | ||
46 | path->skip_locking = 1; | ||
47 | path->search_commit_root = 1; | ||
48 | path->reada = 2; | ||
49 | |||
50 | key.objectid = BTRFS_FIRST_FREE_OBJECTID; | ||
51 | key.offset = 0; | ||
52 | key.type = BTRFS_INODE_ITEM_KEY; | ||
53 | again: | ||
54 | /* need to make sure the commit_root doesn't disappear */ | ||
55 | mutex_lock(&root->fs_commit_mutex); | ||
56 | |||
57 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | ||
58 | if (ret < 0) | ||
59 | goto out; | ||
60 | |||
61 | while (1) { | ||
62 | smp_mb(); | ||
63 | if (fs_info->closing > 1) | ||
64 | goto out; | ||
65 | |||
66 | leaf = path->nodes[0]; | ||
67 | slot = path->slots[0]; | ||
68 | if (path->slots[0] >= btrfs_header_nritems(leaf)) { | ||
69 | ret = btrfs_next_leaf(root, path); | ||
70 | if (ret < 0) | ||
71 | goto out; | ||
72 | else if (ret > 0) | ||
73 | break; | ||
74 | |||
75 | if (need_resched() || | ||
76 | btrfs_transaction_in_commit(fs_info)) { | ||
77 | leaf = path->nodes[0]; | ||
78 | |||
79 | if (btrfs_header_nritems(leaf) == 0) { | ||
80 | WARN_ON(1); | ||
81 | break; | ||
82 | } | ||
83 | |||
84 | /* | ||
85 | * Save the key so we can advances forward | ||
86 | * in the next search. | ||
87 | */ | ||
88 | btrfs_item_key_to_cpu(leaf, &key, 0); | ||
89 | btrfs_release_path(path); | ||
90 | root->cache_progress = last; | ||
91 | mutex_unlock(&root->fs_commit_mutex); | ||
92 | schedule_timeout(1); | ||
93 | goto again; | ||
94 | } else | ||
95 | continue; | ||
96 | } | ||
97 | |||
98 | btrfs_item_key_to_cpu(leaf, &key, slot); | ||
99 | |||
100 | if (key.type != BTRFS_INODE_ITEM_KEY) | ||
101 | goto next; | ||
102 | |||
103 | if (key.objectid >= BTRFS_LAST_FREE_OBJECTID) | ||
104 | break; | ||
105 | |||
106 | if (last != (u64)-1 && last + 1 != key.objectid) { | ||
107 | __btrfs_add_free_space(ctl, last + 1, | ||
108 | key.objectid - last - 1); | ||
109 | wake_up(&root->cache_wait); | ||
110 | } | ||
111 | |||
112 | last = key.objectid; | ||
113 | next: | ||
114 | path->slots[0]++; | ||
115 | } | ||
116 | |||
117 | if (last < BTRFS_LAST_FREE_OBJECTID - 1) { | ||
118 | __btrfs_add_free_space(ctl, last + 1, | ||
119 | BTRFS_LAST_FREE_OBJECTID - last - 1); | ||
120 | } | ||
121 | |||
122 | spin_lock(&root->cache_lock); | ||
123 | root->cached = BTRFS_CACHE_FINISHED; | ||
124 | spin_unlock(&root->cache_lock); | ||
125 | |||
126 | root->cache_progress = (u64)-1; | ||
127 | btrfs_unpin_free_ino(root); | ||
128 | out: | ||
129 | wake_up(&root->cache_wait); | ||
130 | mutex_unlock(&root->fs_commit_mutex); | ||
131 | |||
132 | btrfs_free_path(path); | ||
133 | |||
134 | return ret; | ||
135 | } | ||
136 | |||
137 | static void start_caching(struct btrfs_root *root) | ||
138 | { | ||
139 | struct task_struct *tsk; | ||
140 | int ret; | ||
141 | |||
142 | spin_lock(&root->cache_lock); | ||
143 | if (root->cached != BTRFS_CACHE_NO) { | ||
144 | spin_unlock(&root->cache_lock); | ||
145 | return; | ||
146 | } | ||
147 | |||
148 | root->cached = BTRFS_CACHE_STARTED; | ||
149 | spin_unlock(&root->cache_lock); | ||
150 | |||
151 | ret = load_free_ino_cache(root->fs_info, root); | ||
152 | if (ret == 1) { | ||
153 | spin_lock(&root->cache_lock); | ||
154 | root->cached = BTRFS_CACHE_FINISHED; | ||
155 | spin_unlock(&root->cache_lock); | ||
156 | return; | ||
157 | } | ||
158 | |||
159 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu\n", | ||
160 | root->root_key.objectid); | ||
161 | BUG_ON(IS_ERR(tsk)); | ||
162 | } | ||
163 | |||
164 | int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) | ||
165 | { | ||
166 | again: | ||
167 | *objectid = btrfs_find_ino_for_alloc(root); | ||
168 | |||
169 | if (*objectid != 0) | ||
170 | return 0; | ||
171 | |||
172 | start_caching(root); | ||
173 | |||
174 | wait_event(root->cache_wait, | ||
175 | root->cached == BTRFS_CACHE_FINISHED || | ||
176 | root->free_ino_ctl->free_space > 0); | ||
177 | |||
178 | if (root->cached == BTRFS_CACHE_FINISHED && | ||
179 | root->free_ino_ctl->free_space == 0) | ||
180 | return -ENOSPC; | ||
181 | else | ||
182 | goto again; | ||
183 | } | ||
184 | |||
185 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid) | ||
186 | { | ||
187 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | ||
188 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; | ||
189 | again: | ||
190 | if (root->cached == BTRFS_CACHE_FINISHED) { | ||
191 | __btrfs_add_free_space(ctl, objectid, 1); | ||
192 | } else { | ||
193 | /* | ||
194 | * If we are in the process of caching free ino chunks, | ||
195 | * to avoid adding the same inode number to the free_ino | ||
196 | * tree twice due to cross transaction, we'll leave it | ||
197 | * in the pinned tree until a transaction is committed | ||
198 | * or the caching work is done. | ||
199 | */ | ||
200 | |||
201 | mutex_lock(&root->fs_commit_mutex); | ||
202 | spin_lock(&root->cache_lock); | ||
203 | if (root->cached == BTRFS_CACHE_FINISHED) { | ||
204 | spin_unlock(&root->cache_lock); | ||
205 | mutex_unlock(&root->fs_commit_mutex); | ||
206 | goto again; | ||
207 | } | ||
208 | spin_unlock(&root->cache_lock); | ||
209 | |||
210 | start_caching(root); | ||
211 | |||
212 | if (objectid <= root->cache_progress) | ||
213 | __btrfs_add_free_space(ctl, objectid, 1); | ||
214 | else | ||
215 | __btrfs_add_free_space(pinned, objectid, 1); | ||
216 | |||
217 | mutex_unlock(&root->fs_commit_mutex); | ||
218 | } | ||
219 | } | ||
220 | |||
221 | /* | ||
222 | * When a transaction is committed, we'll move those inode numbers which | ||
223 | * are smaller than root->cache_progress from pinned tree to free_ino tree, | ||
224 | * and others will just be dropped, because the commit root we were | ||
225 | * searching has changed. | ||
226 | * | ||
227 | * Must be called with root->fs_commit_mutex held | ||
228 | */ | ||
229 | void btrfs_unpin_free_ino(struct btrfs_root *root) | ||
230 | { | ||
231 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | ||
232 | struct rb_root *rbroot = &root->free_ino_pinned->free_space_offset; | ||
233 | struct btrfs_free_space *info; | ||
234 | struct rb_node *n; | ||
235 | u64 count; | ||
236 | |||
237 | while (1) { | ||
238 | n = rb_first(rbroot); | ||
239 | if (!n) | ||
240 | break; | ||
241 | |||
242 | info = rb_entry(n, struct btrfs_free_space, offset_index); | ||
243 | BUG_ON(info->bitmap); | ||
244 | |||
245 | if (info->offset > root->cache_progress) | ||
246 | goto free; | ||
247 | else if (info->offset + info->bytes > root->cache_progress) | ||
248 | count = root->cache_progress - info->offset + 1; | ||
249 | else | ||
250 | count = info->bytes; | ||
251 | |||
252 | __btrfs_add_free_space(ctl, info->offset, count); | ||
253 | free: | ||
254 | rb_erase(&info->offset_index, rbroot); | ||
255 | kfree(info); | ||
256 | } | ||
257 | } | ||
258 | |||
259 | #define INIT_THRESHOLD (((1024 * 32) / 2) / sizeof(struct btrfs_free_space)) | ||
260 | #define INODES_PER_BITMAP (PAGE_CACHE_SIZE * 8) | ||
261 | |||
262 | /* | ||
263 | * The goal is to keep the memory used by the free_ino tree won't | ||
264 | * exceed the memory if we use bitmaps only. | ||
265 | */ | ||
266 | static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) | ||
267 | { | ||
268 | struct btrfs_free_space *info; | ||
269 | struct rb_node *n; | ||
270 | int max_ino; | ||
271 | int max_bitmaps; | ||
272 | |||
273 | n = rb_last(&ctl->free_space_offset); | ||
274 | if (!n) { | ||
275 | ctl->extents_thresh = INIT_THRESHOLD; | ||
276 | return; | ||
277 | } | ||
278 | info = rb_entry(n, struct btrfs_free_space, offset_index); | ||
279 | |||
280 | /* | ||
281 | * Find the maximum inode number in the filesystem. Note we | ||
282 | * ignore the fact that this can be a bitmap, because we are | ||
283 | * not doing precise calculation. | ||
284 | */ | ||
285 | max_ino = info->bytes - 1; | ||
286 | |||
287 | max_bitmaps = ALIGN(max_ino, INODES_PER_BITMAP) / INODES_PER_BITMAP; | ||
288 | if (max_bitmaps <= ctl->total_bitmaps) { | ||
289 | ctl->extents_thresh = 0; | ||
290 | return; | ||
291 | } | ||
292 | |||
293 | ctl->extents_thresh = (max_bitmaps - ctl->total_bitmaps) * | ||
294 | PAGE_CACHE_SIZE / sizeof(*info); | ||
295 | } | ||
296 | |||
297 | /* | ||
298 | * We don't fall back to bitmap, if we are below the extents threshold | ||
299 | * or this chunk of inode numbers is a big one. | ||
300 | */ | ||
301 | static bool use_bitmap(struct btrfs_free_space_ctl *ctl, | ||
302 | struct btrfs_free_space *info) | ||
303 | { | ||
304 | if (ctl->free_extents < ctl->extents_thresh || | ||
305 | info->bytes > INODES_PER_BITMAP / 10) | ||
306 | return false; | ||
307 | |||
308 | return true; | ||
309 | } | ||
310 | |||
311 | static struct btrfs_free_space_op free_ino_op = { | ||
312 | .recalc_thresholds = recalculate_thresholds, | ||
313 | .use_bitmap = use_bitmap, | ||
314 | }; | ||
315 | |||
316 | static void pinned_recalc_thresholds(struct btrfs_free_space_ctl *ctl) | ||
317 | { | ||
318 | } | ||
319 | |||
320 | static bool pinned_use_bitmap(struct btrfs_free_space_ctl *ctl, | ||
321 | struct btrfs_free_space *info) | ||
322 | { | ||
323 | /* | ||
324 | * We always use extents for two reasons: | ||
325 | * | ||
326 | * - The pinned tree is only used during the process of caching | ||
327 | * work. | ||
328 | * - Make code simpler. See btrfs_unpin_free_ino(). | ||
329 | */ | ||
330 | return false; | ||
331 | } | ||
332 | |||
333 | static struct btrfs_free_space_op pinned_free_ino_op = { | ||
334 | .recalc_thresholds = pinned_recalc_thresholds, | ||
335 | .use_bitmap = pinned_use_bitmap, | ||
336 | }; | ||
337 | |||
338 | void btrfs_init_free_ino_ctl(struct btrfs_root *root) | ||
339 | { | ||
340 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | ||
341 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; | ||
342 | |||
343 | spin_lock_init(&ctl->tree_lock); | ||
344 | ctl->unit = 1; | ||
345 | ctl->start = 0; | ||
346 | ctl->private = NULL; | ||
347 | ctl->op = &free_ino_op; | ||
348 | |||
349 | /* | ||
350 | * Initially we allow to use 16K of ram to cache chunks of | ||
351 | * inode numbers before we resort to bitmaps. This is somewhat | ||
352 | * arbitrary, but it will be adjusted in runtime. | ||
353 | */ | ||
354 | ctl->extents_thresh = INIT_THRESHOLD; | ||
355 | |||
356 | spin_lock_init(&pinned->tree_lock); | ||
357 | pinned->unit = 1; | ||
358 | pinned->start = 0; | ||
359 | pinned->private = NULL; | ||
360 | pinned->extents_thresh = 0; | ||
361 | pinned->op = &pinned_free_ino_op; | ||
362 | } | ||
363 | |||
364 | int btrfs_save_ino_cache(struct btrfs_root *root, | ||
365 | struct btrfs_trans_handle *trans) | ||
366 | { | ||
367 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | ||
368 | struct btrfs_path *path; | ||
369 | struct inode *inode; | ||
370 | u64 alloc_hint = 0; | ||
371 | int ret; | ||
372 | int prealloc; | ||
373 | bool retry = false; | ||
374 | |||
375 | path = btrfs_alloc_path(); | ||
376 | if (!path) | ||
377 | return -ENOMEM; | ||
378 | again: | ||
379 | inode = lookup_free_ino_inode(root, path); | ||
380 | if (IS_ERR(inode) && PTR_ERR(inode) != -ENOENT) { | ||
381 | ret = PTR_ERR(inode); | ||
382 | goto out; | ||
383 | } | ||
384 | |||
385 | if (IS_ERR(inode)) { | ||
386 | BUG_ON(retry); | ||
387 | retry = true; | ||
388 | |||
389 | ret = create_free_ino_inode(root, trans, path); | ||
390 | if (ret) | ||
391 | goto out; | ||
392 | goto again; | ||
393 | } | ||
394 | |||
395 | BTRFS_I(inode)->generation = 0; | ||
396 | ret = btrfs_update_inode(trans, root, inode); | ||
397 | WARN_ON(ret); | ||
398 | |||
399 | if (i_size_read(inode) > 0) { | ||
400 | ret = btrfs_truncate_free_space_cache(root, trans, path, inode); | ||
401 | if (ret) | ||
402 | goto out_put; | ||
403 | } | ||
404 | |||
405 | spin_lock(&root->cache_lock); | ||
406 | if (root->cached != BTRFS_CACHE_FINISHED) { | ||
407 | ret = -1; | ||
408 | spin_unlock(&root->cache_lock); | ||
409 | goto out_put; | ||
410 | } | ||
411 | spin_unlock(&root->cache_lock); | ||
412 | |||
413 | spin_lock(&ctl->tree_lock); | ||
414 | prealloc = sizeof(struct btrfs_free_space) * ctl->free_extents; | ||
415 | prealloc = ALIGN(prealloc, PAGE_CACHE_SIZE); | ||
416 | prealloc += ctl->total_bitmaps * PAGE_CACHE_SIZE; | ||
417 | spin_unlock(&ctl->tree_lock); | ||
418 | |||
419 | /* Just to make sure we have enough space */ | ||
420 | prealloc += 8 * PAGE_CACHE_SIZE; | ||
421 | |||
422 | ret = btrfs_check_data_free_space(inode, prealloc); | ||
423 | if (ret) | ||
424 | goto out_put; | ||
425 | |||
426 | ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, prealloc, | ||
427 | prealloc, prealloc, &alloc_hint); | ||
428 | if (ret) | ||
429 | goto out_put; | ||
430 | btrfs_free_reserved_data_space(inode, prealloc); | ||
431 | |||
432 | out_put: | ||
433 | iput(inode); | ||
434 | out: | ||
435 | if (ret == 0) | ||
436 | ret = btrfs_write_out_ino_cache(root, trans, path); | ||
437 | |||
438 | btrfs_free_path(path); | ||
439 | return ret; | ||
440 | } | ||
441 | |||
442 | static int btrfs_find_highest_objectid(struct btrfs_root *root, u64 *objectid) | ||
24 | { | 443 | { |
25 | struct btrfs_path *path; | 444 | struct btrfs_path *path; |
26 | int ret; | 445 | int ret; |
@@ -55,15 +474,14 @@ error: | |||
55 | return ret; | 474 | return ret; |
56 | } | 475 | } |
57 | 476 | ||
58 | int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, | 477 | int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid) |
59 | struct btrfs_root *root, | ||
60 | u64 dirid, u64 *objectid) | ||
61 | { | 478 | { |
62 | int ret; | 479 | int ret; |
63 | mutex_lock(&root->objectid_mutex); | 480 | mutex_lock(&root->objectid_mutex); |
64 | 481 | ||
65 | if (unlikely(root->highest_objectid < BTRFS_FIRST_FREE_OBJECTID)) { | 482 | if (unlikely(root->highest_objectid < BTRFS_FIRST_FREE_OBJECTID)) { |
66 | ret = btrfs_find_highest_inode(root, &root->highest_objectid); | 483 | ret = btrfs_find_highest_objectid(root, |
484 | &root->highest_objectid); | ||
67 | if (ret) | 485 | if (ret) |
68 | goto out; | 486 | goto out; |
69 | } | 487 | } |
diff --git a/fs/btrfs/inode-map.h b/fs/btrfs/inode-map.h new file mode 100644 index 00000000000..ddb347bfee2 --- /dev/null +++ b/fs/btrfs/inode-map.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __BTRFS_INODE_MAP | ||
2 | #define __BTRFS_INODE_MAP | ||
3 | |||
4 | void btrfs_init_free_ino_ctl(struct btrfs_root *root); | ||
5 | void btrfs_unpin_free_ino(struct btrfs_root *root); | ||
6 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid); | ||
7 | int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid); | ||
8 | int btrfs_save_ino_cache(struct btrfs_root *root, | ||
9 | struct btrfs_trans_handle *trans); | ||
10 | |||
11 | int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid); | ||
12 | |||
13 | #endif | ||
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 1d1017f9155..8ae72c3eedb 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include "compression.h" | 52 | #include "compression.h" |
53 | #include "locking.h" | 53 | #include "locking.h" |
54 | #include "free-space-cache.h" | 54 | #include "free-space-cache.h" |
55 | #include "inode-map.h" | ||
55 | 56 | ||
56 | struct btrfs_iget_args { | 57 | struct btrfs_iget_args { |
57 | u64 ino; | 58 | u64 ino; |
@@ -139,7 +140,7 @@ static noinline int insert_inline_extent(struct btrfs_trans_handle *trans, | |||
139 | path->leave_spinning = 1; | 140 | path->leave_spinning = 1; |
140 | btrfs_set_trans_block_group(trans, inode); | 141 | btrfs_set_trans_block_group(trans, inode); |
141 | 142 | ||
142 | key.objectid = inode->i_ino; | 143 | key.objectid = btrfs_ino(inode); |
143 | key.offset = start; | 144 | key.offset = start; |
144 | btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY); | 145 | btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY); |
145 | datasize = btrfs_file_extent_calc_inline_size(cur_size); | 146 | datasize = btrfs_file_extent_calc_inline_size(cur_size); |
@@ -746,6 +747,15 @@ static u64 get_extent_allocation_hint(struct inode *inode, u64 start, | |||
746 | return alloc_hint; | 747 | return alloc_hint; |
747 | } | 748 | } |
748 | 749 | ||
750 | static inline bool is_free_space_inode(struct btrfs_root *root, | ||
751 | struct inode *inode) | ||
752 | { | ||
753 | if (root == root->fs_info->tree_root || | ||
754 | BTRFS_I(inode)->location.objectid == BTRFS_FREE_INO_OBJECTID) | ||
755 | return true; | ||
756 | return false; | ||
757 | } | ||
758 | |||
749 | /* | 759 | /* |
750 | * when extent_io.c finds a delayed allocation range in the file, | 760 | * when extent_io.c finds a delayed allocation range in the file, |
751 | * the call backs end up in this code. The basic idea is to | 761 | * the call backs end up in this code. The basic idea is to |
@@ -778,7 +788,7 @@ static noinline int cow_file_range(struct inode *inode, | |||
778 | struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; | 788 | struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; |
779 | int ret = 0; | 789 | int ret = 0; |
780 | 790 | ||
781 | BUG_ON(root == root->fs_info->tree_root); | 791 | BUG_ON(is_free_space_inode(root, inode)); |
782 | trans = btrfs_join_transaction(root, 1); | 792 | trans = btrfs_join_transaction(root, 1); |
783 | BUG_ON(IS_ERR(trans)); | 793 | BUG_ON(IS_ERR(trans)); |
784 | btrfs_set_trans_block_group(trans, inode); | 794 | btrfs_set_trans_block_group(trans, inode); |
@@ -1050,29 +1060,31 @@ static noinline int run_delalloc_nocow(struct inode *inode, | |||
1050 | int type; | 1060 | int type; |
1051 | int nocow; | 1061 | int nocow; |
1052 | int check_prev = 1; | 1062 | int check_prev = 1; |
1053 | bool nolock = false; | 1063 | bool nolock; |
1064 | u64 ino = btrfs_ino(inode); | ||
1054 | 1065 | ||
1055 | path = btrfs_alloc_path(); | 1066 | path = btrfs_alloc_path(); |
1056 | BUG_ON(!path); | 1067 | BUG_ON(!path); |
1057 | if (root == root->fs_info->tree_root) { | 1068 | |
1058 | nolock = true; | 1069 | nolock = is_free_space_inode(root, inode); |
1070 | |||
1071 | if (nolock) | ||
1059 | trans = btrfs_join_transaction_nolock(root, 1); | 1072 | trans = btrfs_join_transaction_nolock(root, 1); |
1060 | } else { | 1073 | else |
1061 | trans = btrfs_join_transaction(root, 1); | 1074 | trans = btrfs_join_transaction(root, 1); |
1062 | } | ||
1063 | BUG_ON(IS_ERR(trans)); | 1075 | BUG_ON(IS_ERR(trans)); |
1064 | 1076 | ||
1065 | cow_start = (u64)-1; | 1077 | cow_start = (u64)-1; |
1066 | cur_offset = start; | 1078 | cur_offset = start; |
1067 | while (1) { | 1079 | while (1) { |
1068 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, | 1080 | ret = btrfs_lookup_file_extent(trans, root, path, ino, |
1069 | cur_offset, 0); | 1081 | cur_offset, 0); |
1070 | BUG_ON(ret < 0); | 1082 | BUG_ON(ret < 0); |
1071 | if (ret > 0 && path->slots[0] > 0 && check_prev) { | 1083 | if (ret > 0 && path->slots[0] > 0 && check_prev) { |
1072 | leaf = path->nodes[0]; | 1084 | leaf = path->nodes[0]; |
1073 | btrfs_item_key_to_cpu(leaf, &found_key, | 1085 | btrfs_item_key_to_cpu(leaf, &found_key, |
1074 | path->slots[0] - 1); | 1086 | path->slots[0] - 1); |
1075 | if (found_key.objectid == inode->i_ino && | 1087 | if (found_key.objectid == ino && |
1076 | found_key.type == BTRFS_EXTENT_DATA_KEY) | 1088 | found_key.type == BTRFS_EXTENT_DATA_KEY) |
1077 | path->slots[0]--; | 1089 | path->slots[0]--; |
1078 | } | 1090 | } |
@@ -1093,7 +1105,7 @@ next_slot: | |||
1093 | num_bytes = 0; | 1105 | num_bytes = 0; |
1094 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); | 1106 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); |
1095 | 1107 | ||
1096 | if (found_key.objectid > inode->i_ino || | 1108 | if (found_key.objectid > ino || |
1097 | found_key.type > BTRFS_EXTENT_DATA_KEY || | 1109 | found_key.type > BTRFS_EXTENT_DATA_KEY || |
1098 | found_key.offset > end) | 1110 | found_key.offset > end) |
1099 | break; | 1111 | break; |
@@ -1128,7 +1140,7 @@ next_slot: | |||
1128 | goto out_check; | 1140 | goto out_check; |
1129 | if (btrfs_extent_readonly(root, disk_bytenr)) | 1141 | if (btrfs_extent_readonly(root, disk_bytenr)) |
1130 | goto out_check; | 1142 | goto out_check; |
1131 | if (btrfs_cross_ref_exist(trans, root, inode->i_ino, | 1143 | if (btrfs_cross_ref_exist(trans, root, ino, |
1132 | found_key.offset - | 1144 | found_key.offset - |
1133 | extent_offset, disk_bytenr)) | 1145 | extent_offset, disk_bytenr)) |
1134 | goto out_check; | 1146 | goto out_check; |
@@ -1317,8 +1329,7 @@ static int btrfs_set_bit_hook(struct inode *inode, | |||
1317 | if (!(state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { | 1329 | if (!(state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { |
1318 | struct btrfs_root *root = BTRFS_I(inode)->root; | 1330 | struct btrfs_root *root = BTRFS_I(inode)->root; |
1319 | u64 len = state->end + 1 - state->start; | 1331 | u64 len = state->end + 1 - state->start; |
1320 | int do_list = (root->root_key.objectid != | 1332 | bool do_list = !is_free_space_inode(root, inode); |
1321 | BTRFS_ROOT_TREE_OBJECTID); | ||
1322 | 1333 | ||
1323 | if (*bits & EXTENT_FIRST_DELALLOC) | 1334 | if (*bits & EXTENT_FIRST_DELALLOC) |
1324 | *bits &= ~EXTENT_FIRST_DELALLOC; | 1335 | *bits &= ~EXTENT_FIRST_DELALLOC; |
@@ -1351,8 +1362,7 @@ static int btrfs_clear_bit_hook(struct inode *inode, | |||
1351 | if ((state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { | 1362 | if ((state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { |
1352 | struct btrfs_root *root = BTRFS_I(inode)->root; | 1363 | struct btrfs_root *root = BTRFS_I(inode)->root; |
1353 | u64 len = state->end + 1 - state->start; | 1364 | u64 len = state->end + 1 - state->start; |
1354 | int do_list = (root->root_key.objectid != | 1365 | bool do_list = !is_free_space_inode(root, inode); |
1355 | BTRFS_ROOT_TREE_OBJECTID); | ||
1356 | 1366 | ||
1357 | if (*bits & EXTENT_FIRST_DELALLOC) | 1367 | if (*bits & EXTENT_FIRST_DELALLOC) |
1358 | *bits &= ~EXTENT_FIRST_DELALLOC; | 1368 | *bits &= ~EXTENT_FIRST_DELALLOC; |
@@ -1459,7 +1469,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, | |||
1459 | 1469 | ||
1460 | skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; | 1470 | skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; |
1461 | 1471 | ||
1462 | if (root == root->fs_info->tree_root) | 1472 | if (is_free_space_inode(root, inode)) |
1463 | ret = btrfs_bio_wq_end_io(root->fs_info, bio, 2); | 1473 | ret = btrfs_bio_wq_end_io(root->fs_info, bio, 2); |
1464 | else | 1474 | else |
1465 | ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); | 1475 | ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); |
@@ -1645,7 +1655,7 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, | |||
1645 | &hint, 0); | 1655 | &hint, 0); |
1646 | BUG_ON(ret); | 1656 | BUG_ON(ret); |
1647 | 1657 | ||
1648 | ins.objectid = inode->i_ino; | 1658 | ins.objectid = btrfs_ino(inode); |
1649 | ins.offset = file_pos; | 1659 | ins.offset = file_pos; |
1650 | ins.type = BTRFS_EXTENT_DATA_KEY; | 1660 | ins.type = BTRFS_EXTENT_DATA_KEY; |
1651 | ret = btrfs_insert_empty_item(trans, root, path, &ins, sizeof(*fi)); | 1661 | ret = btrfs_insert_empty_item(trans, root, path, &ins, sizeof(*fi)); |
@@ -1676,7 +1686,7 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, | |||
1676 | ins.type = BTRFS_EXTENT_ITEM_KEY; | 1686 | ins.type = BTRFS_EXTENT_ITEM_KEY; |
1677 | ret = btrfs_alloc_reserved_file_extent(trans, root, | 1687 | ret = btrfs_alloc_reserved_file_extent(trans, root, |
1678 | root->root_key.objectid, | 1688 | root->root_key.objectid, |
1679 | inode->i_ino, file_pos, &ins); | 1689 | btrfs_ino(inode), file_pos, &ins); |
1680 | BUG_ON(ret); | 1690 | BUG_ON(ret); |
1681 | btrfs_free_path(path); | 1691 | btrfs_free_path(path); |
1682 | 1692 | ||
@@ -1702,7 +1712,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
1702 | struct extent_state *cached_state = NULL; | 1712 | struct extent_state *cached_state = NULL; |
1703 | int compress_type = 0; | 1713 | int compress_type = 0; |
1704 | int ret; | 1714 | int ret; |
1705 | bool nolock = false; | 1715 | bool nolock; |
1706 | 1716 | ||
1707 | ret = btrfs_dec_test_ordered_pending(inode, &ordered_extent, start, | 1717 | ret = btrfs_dec_test_ordered_pending(inode, &ordered_extent, start, |
1708 | end - start + 1); | 1718 | end - start + 1); |
@@ -1710,7 +1720,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
1710 | return 0; | 1720 | return 0; |
1711 | BUG_ON(!ordered_extent); | 1721 | BUG_ON(!ordered_extent); |
1712 | 1722 | ||
1713 | nolock = (root == root->fs_info->tree_root); | 1723 | nolock = is_free_space_inode(root, inode); |
1714 | 1724 | ||
1715 | if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { | 1725 | if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { |
1716 | BUG_ON(!list_empty(&ordered_extent->list)); | 1726 | BUG_ON(!list_empty(&ordered_extent->list)); |
@@ -2005,8 +2015,9 @@ good: | |||
2005 | return 0; | 2015 | return 0; |
2006 | 2016 | ||
2007 | zeroit: | 2017 | zeroit: |
2008 | printk_ratelimited(KERN_INFO "btrfs csum failed ino %lu off %llu csum %u " | 2018 | printk_ratelimited(KERN_INFO "btrfs csum failed ino %llu off %llu csum %u " |
2009 | "private %llu\n", page->mapping->host->i_ino, | 2019 | "private %llu\n", |
2020 | (unsigned long long)btrfs_ino(page->mapping->host), | ||
2010 | (unsigned long long)start, csum, | 2021 | (unsigned long long)start, csum, |
2011 | (unsigned long long)private); | 2022 | (unsigned long long)private); |
2012 | memset(kaddr + offset, 1, end - start + 1); | 2023 | memset(kaddr + offset, 1, end - start + 1); |
@@ -2243,7 +2254,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) | |||
2243 | 2254 | ||
2244 | /* insert an orphan item to track this unlinked/truncated file */ | 2255 | /* insert an orphan item to track this unlinked/truncated file */ |
2245 | if (insert >= 1) { | 2256 | if (insert >= 1) { |
2246 | ret = btrfs_insert_orphan_item(trans, root, inode->i_ino); | 2257 | ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode)); |
2247 | BUG_ON(ret); | 2258 | BUG_ON(ret); |
2248 | } | 2259 | } |
2249 | 2260 | ||
@@ -2280,7 +2291,7 @@ int btrfs_orphan_del(struct btrfs_trans_handle *trans, struct inode *inode) | |||
2280 | spin_unlock(&root->orphan_lock); | 2291 | spin_unlock(&root->orphan_lock); |
2281 | 2292 | ||
2282 | if (trans && delete_item) { | 2293 | if (trans && delete_item) { |
2283 | ret = btrfs_del_orphan_item(trans, root, inode->i_ino); | 2294 | ret = btrfs_del_orphan_item(trans, root, btrfs_ino(inode)); |
2284 | BUG_ON(ret); | 2295 | BUG_ON(ret); |
2285 | } | 2296 | } |
2286 | 2297 | ||
@@ -2542,7 +2553,8 @@ static void btrfs_read_locked_inode(struct inode *inode) | |||
2542 | * try to precache a NULL acl entry for files that don't have | 2553 | * try to precache a NULL acl entry for files that don't have |
2543 | * any xattrs or acls | 2554 | * any xattrs or acls |
2544 | */ | 2555 | */ |
2545 | maybe_acls = acls_after_inode_item(leaf, path->slots[0], inode->i_ino); | 2556 | maybe_acls = acls_after_inode_item(leaf, path->slots[0], |
2557 | btrfs_ino(inode)); | ||
2546 | if (!maybe_acls) | 2558 | if (!maybe_acls) |
2547 | cache_no_acl(inode); | 2559 | cache_no_acl(inode); |
2548 | 2560 | ||
@@ -2646,11 +2658,26 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans, | |||
2646 | struct extent_buffer *leaf; | 2658 | struct extent_buffer *leaf; |
2647 | int ret; | 2659 | int ret; |
2648 | 2660 | ||
2661 | /* | ||
2662 | * If root is tree root, it means this inode is used to | ||
2663 | * store free space information. And these inodes are updated | ||
2664 | * when committing the transaction, so they needn't delaye to | ||
2665 | * be updated, or deadlock will occured. | ||
2666 | */ | ||
2667 | if (!is_free_space_inode(root, inode)) { | ||
2668 | ret = btrfs_delayed_update_inode(trans, root, inode); | ||
2669 | if (!ret) | ||
2670 | btrfs_set_inode_last_trans(trans, inode); | ||
2671 | return ret; | ||
2672 | } | ||
2673 | |||
2649 | path = btrfs_alloc_path(); | 2674 | path = btrfs_alloc_path(); |
2650 | BUG_ON(!path); | 2675 | if (!path) |
2676 | return -ENOMEM; | ||
2677 | |||
2651 | path->leave_spinning = 1; | 2678 | path->leave_spinning = 1; |
2652 | ret = btrfs_lookup_inode(trans, root, path, | 2679 | ret = btrfs_lookup_inode(trans, root, path, &BTRFS_I(inode)->location, |
2653 | &BTRFS_I(inode)->location, 1); | 2680 | 1); |
2654 | if (ret) { | 2681 | if (ret) { |
2655 | if (ret > 0) | 2682 | if (ret > 0) |
2656 | ret = -ENOENT; | 2683 | ret = -ENOENT; |
@@ -2660,7 +2687,7 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans, | |||
2660 | btrfs_unlock_up_safe(path, 1); | 2687 | btrfs_unlock_up_safe(path, 1); |
2661 | leaf = path->nodes[0]; | 2688 | leaf = path->nodes[0]; |
2662 | inode_item = btrfs_item_ptr(leaf, path->slots[0], | 2689 | inode_item = btrfs_item_ptr(leaf, path->slots[0], |
2663 | struct btrfs_inode_item); | 2690 | struct btrfs_inode_item); |
2664 | 2691 | ||
2665 | fill_inode_item(trans, leaf, inode_item, inode); | 2692 | fill_inode_item(trans, leaf, inode_item, inode); |
2666 | btrfs_mark_buffer_dirty(leaf); | 2693 | btrfs_mark_buffer_dirty(leaf); |
@@ -2671,7 +2698,6 @@ failed: | |||
2671 | return ret; | 2698 | return ret; |
2672 | } | 2699 | } |
2673 | 2700 | ||
2674 | |||
2675 | /* | 2701 | /* |
2676 | * unlink helper that gets used here in inode.c and in the tree logging | 2702 | * unlink helper that gets used here in inode.c and in the tree logging |
2677 | * recovery code. It remove a link in a directory with a given name, and | 2703 | * recovery code. It remove a link in a directory with a given name, and |
@@ -2688,6 +2714,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, | |||
2688 | struct btrfs_dir_item *di; | 2714 | struct btrfs_dir_item *di; |
2689 | struct btrfs_key key; | 2715 | struct btrfs_key key; |
2690 | u64 index; | 2716 | u64 index; |
2717 | u64 ino = btrfs_ino(inode); | ||
2718 | u64 dir_ino = btrfs_ino(dir); | ||
2691 | 2719 | ||
2692 | path = btrfs_alloc_path(); | 2720 | path = btrfs_alloc_path(); |
2693 | if (!path) { | 2721 | if (!path) { |
@@ -2696,7 +2724,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, | |||
2696 | } | 2724 | } |
2697 | 2725 | ||
2698 | path->leave_spinning = 1; | 2726 | path->leave_spinning = 1; |
2699 | di = btrfs_lookup_dir_item(trans, root, path, dir->i_ino, | 2727 | di = btrfs_lookup_dir_item(trans, root, path, dir_ino, |
2700 | name, name_len, -1); | 2728 | name, name_len, -1); |
2701 | if (IS_ERR(di)) { | 2729 | if (IS_ERR(di)) { |
2702 | ret = PTR_ERR(di); | 2730 | ret = PTR_ERR(di); |
@@ -2713,31 +2741,21 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, | |||
2713 | goto err; | 2741 | goto err; |
2714 | btrfs_release_path(path); | 2742 | btrfs_release_path(path); |
2715 | 2743 | ||
2716 | ret = btrfs_del_inode_ref(trans, root, name, name_len, | 2744 | ret = btrfs_del_inode_ref(trans, root, name, name_len, ino, |
2717 | inode->i_ino, | 2745 | dir_ino, &index); |
2718 | dir->i_ino, &index); | ||
2719 | if (ret) { | 2746 | if (ret) { |
2720 | printk(KERN_INFO "btrfs failed to delete reference to %.*s, " | 2747 | printk(KERN_INFO "btrfs failed to delete reference to %.*s, " |
2721 | "inode %lu parent %lu\n", name_len, name, | 2748 | "inode %llu parent %llu\n", name_len, name, |
2722 | inode->i_ino, dir->i_ino); | 2749 | (unsigned long long)ino, (unsigned long long)dir_ino); |
2723 | goto err; | 2750 | goto err; |
2724 | } | 2751 | } |
2725 | 2752 | ||
2726 | di = btrfs_lookup_dir_index_item(trans, root, path, dir->i_ino, | 2753 | ret = btrfs_delete_delayed_dir_index(trans, root, dir, index); |
2727 | index, name, name_len, -1); | 2754 | if (ret) |
2728 | if (IS_ERR(di)) { | ||
2729 | ret = PTR_ERR(di); | ||
2730 | goto err; | ||
2731 | } | ||
2732 | if (!di) { | ||
2733 | ret = -ENOENT; | ||
2734 | goto err; | 2755 | goto err; |
2735 | } | ||
2736 | ret = btrfs_delete_one_dir_name(trans, root, path, di); | ||
2737 | btrfs_release_path(path); | ||
2738 | 2756 | ||
2739 | ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len, | 2757 | ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len, |
2740 | inode, dir->i_ino); | 2758 | inode, dir_ino); |
2741 | BUG_ON(ret != 0 && ret != -ENOENT); | 2759 | BUG_ON(ret != 0 && ret != -ENOENT); |
2742 | 2760 | ||
2743 | ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len, | 2761 | ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len, |
@@ -2815,12 +2833,14 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir, | |||
2815 | int check_link = 1; | 2833 | int check_link = 1; |
2816 | int err = -ENOSPC; | 2834 | int err = -ENOSPC; |
2817 | int ret; | 2835 | int ret; |
2836 | u64 ino = btrfs_ino(inode); | ||
2837 | u64 dir_ino = btrfs_ino(dir); | ||
2818 | 2838 | ||
2819 | trans = btrfs_start_transaction(root, 10); | 2839 | trans = btrfs_start_transaction(root, 10); |
2820 | if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC) | 2840 | if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC) |
2821 | return trans; | 2841 | return trans; |
2822 | 2842 | ||
2823 | if (inode->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) | 2843 | if (ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) |
2824 | return ERR_PTR(-ENOSPC); | 2844 | return ERR_PTR(-ENOSPC); |
2825 | 2845 | ||
2826 | /* check if there is someone else holds reference */ | 2846 | /* check if there is someone else holds reference */ |
@@ -2879,7 +2899,7 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir, | |||
2879 | 2899 | ||
2880 | if (ret == 0 && S_ISREG(inode->i_mode)) { | 2900 | if (ret == 0 && S_ISREG(inode->i_mode)) { |
2881 | ret = btrfs_lookup_file_extent(trans, root, path, | 2901 | ret = btrfs_lookup_file_extent(trans, root, path, |
2882 | inode->i_ino, (u64)-1, 0); | 2902 | ino, (u64)-1, 0); |
2883 | if (ret < 0) { | 2903 | if (ret < 0) { |
2884 | err = ret; | 2904 | err = ret; |
2885 | goto out; | 2905 | goto out; |
@@ -2895,7 +2915,7 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir, | |||
2895 | goto out; | 2915 | goto out; |
2896 | } | 2916 | } |
2897 | 2917 | ||
2898 | di = btrfs_lookup_dir_item(trans, root, path, dir->i_ino, | 2918 | di = btrfs_lookup_dir_item(trans, root, path, dir_ino, |
2899 | dentry->d_name.name, dentry->d_name.len, 0); | 2919 | dentry->d_name.name, dentry->d_name.len, 0); |
2900 | if (IS_ERR(di)) { | 2920 | if (IS_ERR(di)) { |
2901 | err = PTR_ERR(di); | 2921 | err = PTR_ERR(di); |
@@ -2912,7 +2932,7 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir, | |||
2912 | 2932 | ||
2913 | ref = btrfs_lookup_inode_ref(trans, root, path, | 2933 | ref = btrfs_lookup_inode_ref(trans, root, path, |
2914 | dentry->d_name.name, dentry->d_name.len, | 2934 | dentry->d_name.name, dentry->d_name.len, |
2915 | inode->i_ino, dir->i_ino, 0); | 2935 | ino, dir_ino, 0); |
2916 | if (IS_ERR(ref)) { | 2936 | if (IS_ERR(ref)) { |
2917 | err = PTR_ERR(ref); | 2937 | err = PTR_ERR(ref); |
2918 | goto out; | 2938 | goto out; |
@@ -2923,7 +2943,15 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir, | |||
2923 | index = btrfs_inode_ref_index(path->nodes[0], ref); | 2943 | index = btrfs_inode_ref_index(path->nodes[0], ref); |
2924 | btrfs_release_path(path); | 2944 | btrfs_release_path(path); |
2925 | 2945 | ||
2926 | di = btrfs_lookup_dir_index_item(trans, root, path, dir->i_ino, index, | 2946 | /* |
2947 | * This is a commit root search, if we can lookup inode item and other | ||
2948 | * relative items in the commit root, it means the transaction of | ||
2949 | * dir/file creation has been committed, and the dir index item that we | ||
2950 | * delay to insert has also been inserted into the commit root. So | ||
2951 | * we needn't worry about the delayed insertion of the dir index item | ||
2952 | * here. | ||
2953 | */ | ||
2954 | di = btrfs_lookup_dir_index_item(trans, root, path, dir_ino, index, | ||
2927 | dentry->d_name.name, dentry->d_name.len, 0); | 2955 | dentry->d_name.name, dentry->d_name.len, 0); |
2928 | if (IS_ERR(di)) { | 2956 | if (IS_ERR(di)) { |
2929 | err = PTR_ERR(di); | 2957 | err = PTR_ERR(di); |
@@ -2998,12 +3026,13 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, | |||
2998 | struct btrfs_key key; | 3026 | struct btrfs_key key; |
2999 | u64 index; | 3027 | u64 index; |
3000 | int ret; | 3028 | int ret; |
3029 | u64 dir_ino = btrfs_ino(dir); | ||
3001 | 3030 | ||
3002 | path = btrfs_alloc_path(); | 3031 | path = btrfs_alloc_path(); |
3003 | if (!path) | 3032 | if (!path) |
3004 | return -ENOMEM; | 3033 | return -ENOMEM; |
3005 | 3034 | ||
3006 | di = btrfs_lookup_dir_item(trans, root, path, dir->i_ino, | 3035 | di = btrfs_lookup_dir_item(trans, root, path, dir_ino, |
3007 | name, name_len, -1); | 3036 | name, name_len, -1); |
3008 | BUG_ON(IS_ERR_OR_NULL(di)); | 3037 | BUG_ON(IS_ERR_OR_NULL(di)); |
3009 | 3038 | ||
@@ -3016,10 +3045,10 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, | |||
3016 | 3045 | ||
3017 | ret = btrfs_del_root_ref(trans, root->fs_info->tree_root, | 3046 | ret = btrfs_del_root_ref(trans, root->fs_info->tree_root, |
3018 | objectid, root->root_key.objectid, | 3047 | objectid, root->root_key.objectid, |
3019 | dir->i_ino, &index, name, name_len); | 3048 | dir_ino, &index, name, name_len); |
3020 | if (ret < 0) { | 3049 | if (ret < 0) { |
3021 | BUG_ON(ret != -ENOENT); | 3050 | BUG_ON(ret != -ENOENT); |
3022 | di = btrfs_search_dir_index_item(root, path, dir->i_ino, | 3051 | di = btrfs_search_dir_index_item(root, path, dir_ino, |
3023 | name, name_len); | 3052 | name, name_len); |
3024 | BUG_ON(IS_ERR_OR_NULL(di)); | 3053 | BUG_ON(IS_ERR_OR_NULL(di)); |
3025 | 3054 | ||
@@ -3028,24 +3057,16 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, | |||
3028 | btrfs_release_path(path); | 3057 | btrfs_release_path(path); |
3029 | index = key.offset; | 3058 | index = key.offset; |
3030 | } | 3059 | } |
3060 | btrfs_release_path(path); | ||
3031 | 3061 | ||
3032 | di = btrfs_lookup_dir_index_item(trans, root, path, dir->i_ino, | 3062 | ret = btrfs_delete_delayed_dir_index(trans, root, dir, index); |
3033 | index, name, name_len, -1); | ||
3034 | BUG_ON(IS_ERR_OR_NULL(di)); | ||
3035 | |||
3036 | leaf = path->nodes[0]; | ||
3037 | btrfs_dir_item_key_to_cpu(leaf, di, &key); | ||
3038 | WARN_ON(key.type != BTRFS_ROOT_ITEM_KEY || key.objectid != objectid); | ||
3039 | ret = btrfs_delete_one_dir_name(trans, root, path, di); | ||
3040 | BUG_ON(ret); | 3063 | BUG_ON(ret); |
3041 | btrfs_release_path(path); | ||
3042 | 3064 | ||
3043 | btrfs_i_size_write(dir, dir->i_size - name_len * 2); | 3065 | btrfs_i_size_write(dir, dir->i_size - name_len * 2); |
3044 | dir->i_mtime = dir->i_ctime = CURRENT_TIME; | 3066 | dir->i_mtime = dir->i_ctime = CURRENT_TIME; |
3045 | ret = btrfs_update_inode(trans, root, dir); | 3067 | ret = btrfs_update_inode(trans, root, dir); |
3046 | BUG_ON(ret); | 3068 | BUG_ON(ret); |
3047 | 3069 | ||
3048 | btrfs_free_path(path); | ||
3049 | return 0; | 3070 | return 0; |
3050 | } | 3071 | } |
3051 | 3072 | ||
@@ -3058,7 +3079,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
3058 | unsigned long nr = 0; | 3079 | unsigned long nr = 0; |
3059 | 3080 | ||
3060 | if (inode->i_size > BTRFS_EMPTY_DIR_SIZE || | 3081 | if (inode->i_size > BTRFS_EMPTY_DIR_SIZE || |
3061 | inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) | 3082 | btrfs_ino(inode) == BTRFS_FIRST_FREE_OBJECTID) |
3062 | return -ENOTEMPTY; | 3083 | return -ENOTEMPTY; |
3063 | 3084 | ||
3064 | trans = __unlink_start_trans(dir, dentry); | 3085 | trans = __unlink_start_trans(dir, dentry); |
@@ -3067,7 +3088,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
3067 | 3088 | ||
3068 | btrfs_set_trans_block_group(trans, dir); | 3089 | btrfs_set_trans_block_group(trans, dir); |
3069 | 3090 | ||
3070 | if (unlikely(inode->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { | 3091 | if (unlikely(btrfs_ino(inode) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { |
3071 | err = btrfs_unlink_subvol(trans, root, dir, | 3092 | err = btrfs_unlink_subvol(trans, root, dir, |
3072 | BTRFS_I(inode)->location.objectid, | 3093 | BTRFS_I(inode)->location.objectid, |
3073 | dentry->d_name.name, | 3094 | dentry->d_name.name, |
@@ -3127,17 +3148,27 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, | |||
3127 | int encoding; | 3148 | int encoding; |
3128 | int ret; | 3149 | int ret; |
3129 | int err = 0; | 3150 | int err = 0; |
3151 | u64 ino = btrfs_ino(inode); | ||
3130 | 3152 | ||
3131 | BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY); | 3153 | BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY); |
3132 | 3154 | ||
3133 | if (root->ref_cows || root == root->fs_info->tree_root) | 3155 | if (root->ref_cows || root == root->fs_info->tree_root) |
3134 | btrfs_drop_extent_cache(inode, new_size & (~mask), (u64)-1, 0); | 3156 | btrfs_drop_extent_cache(inode, new_size & (~mask), (u64)-1, 0); |
3135 | 3157 | ||
3158 | /* | ||
3159 | * This function is also used to drop the items in the log tree before | ||
3160 | * we relog the inode, so if root != BTRFS_I(inode)->root, it means | ||
3161 | * it is used to drop the loged items. So we shouldn't kill the delayed | ||
3162 | * items. | ||
3163 | */ | ||
3164 | if (min_type == 0 && root == BTRFS_I(inode)->root) | ||
3165 | btrfs_kill_delayed_inode_items(inode); | ||
3166 | |||
3136 | path = btrfs_alloc_path(); | 3167 | path = btrfs_alloc_path(); |
3137 | BUG_ON(!path); | 3168 | BUG_ON(!path); |
3138 | path->reada = -1; | 3169 | path->reada = -1; |
3139 | 3170 | ||
3140 | key.objectid = inode->i_ino; | 3171 | key.objectid = ino; |
3141 | key.offset = (u64)-1; | 3172 | key.offset = (u64)-1; |
3142 | key.type = (u8)-1; | 3173 | key.type = (u8)-1; |
3143 | 3174 | ||
@@ -3165,7 +3196,7 @@ search_again: | |||
3165 | found_type = btrfs_key_type(&found_key); | 3196 | found_type = btrfs_key_type(&found_key); |
3166 | encoding = 0; | 3197 | encoding = 0; |
3167 | 3198 | ||
3168 | if (found_key.objectid != inode->i_ino) | 3199 | if (found_key.objectid != ino) |
3169 | break; | 3200 | break; |
3170 | 3201 | ||
3171 | if (found_type < min_type) | 3202 | if (found_type < min_type) |
@@ -3284,7 +3315,7 @@ delete: | |||
3284 | ret = btrfs_free_extent(trans, root, extent_start, | 3315 | ret = btrfs_free_extent(trans, root, extent_start, |
3285 | extent_num_bytes, 0, | 3316 | extent_num_bytes, 0, |
3286 | btrfs_header_owner(leaf), | 3317 | btrfs_header_owner(leaf), |
3287 | inode->i_ino, extent_offset); | 3318 | ino, extent_offset); |
3288 | BUG_ON(ret); | 3319 | BUG_ON(ret); |
3289 | } | 3320 | } |
3290 | 3321 | ||
@@ -3293,7 +3324,9 @@ delete: | |||
3293 | 3324 | ||
3294 | if (path->slots[0] == 0 || | 3325 | if (path->slots[0] == 0 || |
3295 | path->slots[0] != pending_del_slot) { | 3326 | path->slots[0] != pending_del_slot) { |
3296 | if (root->ref_cows) { | 3327 | if (root->ref_cows && |
3328 | BTRFS_I(inode)->location.objectid != | ||
3329 | BTRFS_FREE_INO_OBJECTID) { | ||
3297 | err = -EAGAIN; | 3330 | err = -EAGAIN; |
3298 | goto out; | 3331 | goto out; |
3299 | } | 3332 | } |
@@ -3483,7 +3516,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size) | |||
3483 | break; | 3516 | break; |
3484 | 3517 | ||
3485 | err = btrfs_insert_file_extent(trans, root, | 3518 | err = btrfs_insert_file_extent(trans, root, |
3486 | inode->i_ino, cur_offset, 0, | 3519 | btrfs_ino(inode), cur_offset, 0, |
3487 | 0, hole_size, 0, hole_size, | 3520 | 0, hole_size, 0, hole_size, |
3488 | 0, 0, 0); | 3521 | 0, 0, 0); |
3489 | if (err) | 3522 | if (err) |
@@ -3585,7 +3618,7 @@ void btrfs_evict_inode(struct inode *inode) | |||
3585 | 3618 | ||
3586 | truncate_inode_pages(&inode->i_data, 0); | 3619 | truncate_inode_pages(&inode->i_data, 0); |
3587 | if (inode->i_nlink && (btrfs_root_refs(&root->root_item) != 0 || | 3620 | if (inode->i_nlink && (btrfs_root_refs(&root->root_item) != 0 || |
3588 | root == root->fs_info->tree_root)) | 3621 | is_free_space_inode(root, inode))) |
3589 | goto no_delete; | 3622 | goto no_delete; |
3590 | 3623 | ||
3591 | if (is_bad_inode(inode)) { | 3624 | if (is_bad_inode(inode)) { |
@@ -3638,6 +3671,10 @@ void btrfs_evict_inode(struct inode *inode) | |||
3638 | BUG_ON(ret); | 3671 | BUG_ON(ret); |
3639 | } | 3672 | } |
3640 | 3673 | ||
3674 | if (!(root == root->fs_info->tree_root || | ||
3675 | root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)) | ||
3676 | btrfs_return_ino(root, btrfs_ino(inode)); | ||
3677 | |||
3641 | nr = trans->blocks_used; | 3678 | nr = trans->blocks_used; |
3642 | btrfs_end_transaction(trans, root); | 3679 | btrfs_end_transaction(trans, root); |
3643 | btrfs_btree_balance_dirty(root, nr); | 3680 | btrfs_btree_balance_dirty(root, nr); |
@@ -3663,7 +3700,7 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry, | |||
3663 | path = btrfs_alloc_path(); | 3700 | path = btrfs_alloc_path(); |
3664 | BUG_ON(!path); | 3701 | BUG_ON(!path); |
3665 | 3702 | ||
3666 | di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name, | 3703 | di = btrfs_lookup_dir_item(NULL, root, path, btrfs_ino(dir), name, |
3667 | namelen, 0); | 3704 | namelen, 0); |
3668 | if (IS_ERR(di)) | 3705 | if (IS_ERR(di)) |
3669 | ret = PTR_ERR(di); | 3706 | ret = PTR_ERR(di); |
@@ -3716,7 +3753,7 @@ static int fixup_tree_root_location(struct btrfs_root *root, | |||
3716 | 3753 | ||
3717 | leaf = path->nodes[0]; | 3754 | leaf = path->nodes[0]; |
3718 | ref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref); | 3755 | ref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref); |
3719 | if (btrfs_root_ref_dirid(leaf, ref) != dir->i_ino || | 3756 | if (btrfs_root_ref_dirid(leaf, ref) != btrfs_ino(dir) || |
3720 | btrfs_root_ref_name_len(leaf, ref) != dentry->d_name.len) | 3757 | btrfs_root_ref_name_len(leaf, ref) != dentry->d_name.len) |
3721 | goto out; | 3758 | goto out; |
3722 | 3759 | ||
@@ -3755,6 +3792,7 @@ static void inode_tree_add(struct inode *inode) | |||
3755 | struct btrfs_inode *entry; | 3792 | struct btrfs_inode *entry; |
3756 | struct rb_node **p; | 3793 | struct rb_node **p; |
3757 | struct rb_node *parent; | 3794 | struct rb_node *parent; |
3795 | u64 ino = btrfs_ino(inode); | ||
3758 | again: | 3796 | again: |
3759 | p = &root->inode_tree.rb_node; | 3797 | p = &root->inode_tree.rb_node; |
3760 | parent = NULL; | 3798 | parent = NULL; |
@@ -3767,9 +3805,9 @@ again: | |||
3767 | parent = *p; | 3805 | parent = *p; |
3768 | entry = rb_entry(parent, struct btrfs_inode, rb_node); | 3806 | entry = rb_entry(parent, struct btrfs_inode, rb_node); |
3769 | 3807 | ||
3770 | if (inode->i_ino < entry->vfs_inode.i_ino) | 3808 | if (ino < btrfs_ino(&entry->vfs_inode)) |
3771 | p = &parent->rb_left; | 3809 | p = &parent->rb_left; |
3772 | else if (inode->i_ino > entry->vfs_inode.i_ino) | 3810 | else if (ino > btrfs_ino(&entry->vfs_inode)) |
3773 | p = &parent->rb_right; | 3811 | p = &parent->rb_right; |
3774 | else { | 3812 | else { |
3775 | WARN_ON(!(entry->vfs_inode.i_state & | 3813 | WARN_ON(!(entry->vfs_inode.i_state & |
@@ -3833,9 +3871,9 @@ again: | |||
3833 | prev = node; | 3871 | prev = node; |
3834 | entry = rb_entry(node, struct btrfs_inode, rb_node); | 3872 | entry = rb_entry(node, struct btrfs_inode, rb_node); |
3835 | 3873 | ||
3836 | if (objectid < entry->vfs_inode.i_ino) | 3874 | if (objectid < btrfs_ino(&entry->vfs_inode)) |
3837 | node = node->rb_left; | 3875 | node = node->rb_left; |
3838 | else if (objectid > entry->vfs_inode.i_ino) | 3876 | else if (objectid > btrfs_ino(&entry->vfs_inode)) |
3839 | node = node->rb_right; | 3877 | node = node->rb_right; |
3840 | else | 3878 | else |
3841 | break; | 3879 | break; |
@@ -3843,7 +3881,7 @@ again: | |||
3843 | if (!node) { | 3881 | if (!node) { |
3844 | while (prev) { | 3882 | while (prev) { |
3845 | entry = rb_entry(prev, struct btrfs_inode, rb_node); | 3883 | entry = rb_entry(prev, struct btrfs_inode, rb_node); |
3846 | if (objectid <= entry->vfs_inode.i_ino) { | 3884 | if (objectid <= btrfs_ino(&entry->vfs_inode)) { |
3847 | node = prev; | 3885 | node = prev; |
3848 | break; | 3886 | break; |
3849 | } | 3887 | } |
@@ -3852,7 +3890,7 @@ again: | |||
3852 | } | 3890 | } |
3853 | while (node) { | 3891 | while (node) { |
3854 | entry = rb_entry(node, struct btrfs_inode, rb_node); | 3892 | entry = rb_entry(node, struct btrfs_inode, rb_node); |
3855 | objectid = entry->vfs_inode.i_ino + 1; | 3893 | objectid = btrfs_ino(&entry->vfs_inode) + 1; |
3856 | inode = igrab(&entry->vfs_inode); | 3894 | inode = igrab(&entry->vfs_inode); |
3857 | if (inode) { | 3895 | if (inode) { |
3858 | spin_unlock(&root->inode_lock); | 3896 | spin_unlock(&root->inode_lock); |
@@ -3890,7 +3928,7 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p) | |||
3890 | static int btrfs_find_actor(struct inode *inode, void *opaque) | 3928 | static int btrfs_find_actor(struct inode *inode, void *opaque) |
3891 | { | 3929 | { |
3892 | struct btrfs_iget_args *args = opaque; | 3930 | struct btrfs_iget_args *args = opaque; |
3893 | return args->ino == inode->i_ino && | 3931 | return args->ino == btrfs_ino(inode) && |
3894 | args->root == BTRFS_I(inode)->root; | 3932 | args->root == BTRFS_I(inode)->root; |
3895 | } | 3933 | } |
3896 | 3934 | ||
@@ -4035,7 +4073,7 @@ static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry, | |||
4035 | return d_splice_alias(inode, dentry); | 4073 | return d_splice_alias(inode, dentry); |
4036 | } | 4074 | } |
4037 | 4075 | ||
4038 | static unsigned char btrfs_filetype_table[] = { | 4076 | unsigned char btrfs_filetype_table[] = { |
4039 | DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK | 4077 | DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK |
4040 | }; | 4078 | }; |
4041 | 4079 | ||
@@ -4049,6 +4087,8 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4049 | struct btrfs_key key; | 4087 | struct btrfs_key key; |
4050 | struct btrfs_key found_key; | 4088 | struct btrfs_key found_key; |
4051 | struct btrfs_path *path; | 4089 | struct btrfs_path *path; |
4090 | struct list_head ins_list; | ||
4091 | struct list_head del_list; | ||
4052 | int ret; | 4092 | int ret; |
4053 | struct extent_buffer *leaf; | 4093 | struct extent_buffer *leaf; |
4054 | int slot; | 4094 | int slot; |
@@ -4061,6 +4101,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4061 | char tmp_name[32]; | 4101 | char tmp_name[32]; |
4062 | char *name_ptr; | 4102 | char *name_ptr; |
4063 | int name_len; | 4103 | int name_len; |
4104 | int is_curr = 0; /* filp->f_pos points to the current index? */ | ||
4064 | 4105 | ||
4065 | /* FIXME, use a real flag for deciding about the key type */ | 4106 | /* FIXME, use a real flag for deciding about the key type */ |
4066 | if (root->fs_info->tree_root == root) | 4107 | if (root->fs_info->tree_root == root) |
@@ -4068,9 +4109,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4068 | 4109 | ||
4069 | /* special case for "." */ | 4110 | /* special case for "." */ |
4070 | if (filp->f_pos == 0) { | 4111 | if (filp->f_pos == 0) { |
4071 | over = filldir(dirent, ".", 1, | 4112 | over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR); |
4072 | 1, inode->i_ino, | ||
4073 | DT_DIR); | ||
4074 | if (over) | 4113 | if (over) |
4075 | return 0; | 4114 | return 0; |
4076 | filp->f_pos = 1; | 4115 | filp->f_pos = 1; |
@@ -4085,11 +4124,19 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4085 | filp->f_pos = 2; | 4124 | filp->f_pos = 2; |
4086 | } | 4125 | } |
4087 | path = btrfs_alloc_path(); | 4126 | path = btrfs_alloc_path(); |
4127 | if (!path) | ||
4128 | return -ENOMEM; | ||
4088 | path->reada = 2; | 4129 | path->reada = 2; |
4089 | 4130 | ||
4131 | if (key_type == BTRFS_DIR_INDEX_KEY) { | ||
4132 | INIT_LIST_HEAD(&ins_list); | ||
4133 | INIT_LIST_HEAD(&del_list); | ||
4134 | btrfs_get_delayed_items(inode, &ins_list, &del_list); | ||
4135 | } | ||
4136 | |||
4090 | btrfs_set_key_type(&key, key_type); | 4137 | btrfs_set_key_type(&key, key_type); |
4091 | key.offset = filp->f_pos; | 4138 | key.offset = filp->f_pos; |
4092 | key.objectid = inode->i_ino; | 4139 | key.objectid = btrfs_ino(inode); |
4093 | 4140 | ||
4094 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | 4141 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
4095 | if (ret < 0) | 4142 | if (ret < 0) |
@@ -4116,8 +4163,13 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4116 | break; | 4163 | break; |
4117 | if (found_key.offset < filp->f_pos) | 4164 | if (found_key.offset < filp->f_pos) |
4118 | goto next; | 4165 | goto next; |
4166 | if (key_type == BTRFS_DIR_INDEX_KEY && | ||
4167 | btrfs_should_delete_dir_index(&del_list, | ||
4168 | found_key.offset)) | ||
4169 | goto next; | ||
4119 | 4170 | ||
4120 | filp->f_pos = found_key.offset; | 4171 | filp->f_pos = found_key.offset; |
4172 | is_curr = 1; | ||
4121 | 4173 | ||
4122 | di = btrfs_item_ptr(leaf, slot, struct btrfs_dir_item); | 4174 | di = btrfs_item_ptr(leaf, slot, struct btrfs_dir_item); |
4123 | di_cur = 0; | 4175 | di_cur = 0; |
@@ -4172,6 +4224,15 @@ next: | |||
4172 | path->slots[0]++; | 4224 | path->slots[0]++; |
4173 | } | 4225 | } |
4174 | 4226 | ||
4227 | if (key_type == BTRFS_DIR_INDEX_KEY) { | ||
4228 | if (is_curr) | ||
4229 | filp->f_pos++; | ||
4230 | ret = btrfs_readdir_delayed_dir_index(filp, dirent, filldir, | ||
4231 | &ins_list); | ||
4232 | if (ret) | ||
4233 | goto nopos; | ||
4234 | } | ||
4235 | |||
4175 | /* Reached end of directory/root. Bump pos past the last item. */ | 4236 | /* Reached end of directory/root. Bump pos past the last item. */ |
4176 | if (key_type == BTRFS_DIR_INDEX_KEY) | 4237 | if (key_type == BTRFS_DIR_INDEX_KEY) |
4177 | /* | 4238 | /* |
@@ -4184,6 +4245,8 @@ next: | |||
4184 | nopos: | 4245 | nopos: |
4185 | ret = 0; | 4246 | ret = 0; |
4186 | err: | 4247 | err: |
4248 | if (key_type == BTRFS_DIR_INDEX_KEY) | ||
4249 | btrfs_put_delayed_items(&ins_list, &del_list); | ||
4187 | btrfs_free_path(path); | 4250 | btrfs_free_path(path); |
4188 | return ret; | 4251 | return ret; |
4189 | } | 4252 | } |
@@ -4199,7 +4262,8 @@ int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
4199 | return 0; | 4262 | return 0; |
4200 | 4263 | ||
4201 | smp_mb(); | 4264 | smp_mb(); |
4202 | nolock = (root->fs_info->closing && root == root->fs_info->tree_root); | 4265 | if (root->fs_info->closing && is_free_space_inode(root, inode)) |
4266 | nolock = true; | ||
4203 | 4267 | ||
4204 | if (wbc->sync_mode == WB_SYNC_ALL) { | 4268 | if (wbc->sync_mode == WB_SYNC_ALL) { |
4205 | if (nolock) | 4269 | if (nolock) |
@@ -4243,8 +4307,9 @@ void btrfs_dirty_inode(struct inode *inode) | |||
4243 | trans = btrfs_start_transaction(root, 1); | 4307 | trans = btrfs_start_transaction(root, 1); |
4244 | if (IS_ERR(trans)) { | 4308 | if (IS_ERR(trans)) { |
4245 | printk_ratelimited(KERN_ERR "btrfs: fail to " | 4309 | printk_ratelimited(KERN_ERR "btrfs: fail to " |
4246 | "dirty inode %lu error %ld\n", | 4310 | "dirty inode %llu error %ld\n", |
4247 | inode->i_ino, PTR_ERR(trans)); | 4311 | (unsigned long long)btrfs_ino(inode), |
4312 | PTR_ERR(trans)); | ||
4248 | return; | 4313 | return; |
4249 | } | 4314 | } |
4250 | btrfs_set_trans_block_group(trans, inode); | 4315 | btrfs_set_trans_block_group(trans, inode); |
@@ -4252,11 +4317,14 @@ void btrfs_dirty_inode(struct inode *inode) | |||
4252 | ret = btrfs_update_inode(trans, root, inode); | 4317 | ret = btrfs_update_inode(trans, root, inode); |
4253 | if (ret) { | 4318 | if (ret) { |
4254 | printk_ratelimited(KERN_ERR "btrfs: fail to " | 4319 | printk_ratelimited(KERN_ERR "btrfs: fail to " |
4255 | "dirty inode %lu error %d\n", | 4320 | "dirty inode %llu error %d\n", |
4256 | inode->i_ino, ret); | 4321 | (unsigned long long)btrfs_ino(inode), |
4322 | ret); | ||
4257 | } | 4323 | } |
4258 | } | 4324 | } |
4259 | btrfs_end_transaction(trans, root); | 4325 | btrfs_end_transaction(trans, root); |
4326 | if (BTRFS_I(inode)->delayed_node) | ||
4327 | btrfs_balance_delayed_items(root); | ||
4260 | } | 4328 | } |
4261 | 4329 | ||
4262 | /* | 4330 | /* |
@@ -4272,7 +4340,7 @@ static int btrfs_set_inode_index_count(struct inode *inode) | |||
4272 | struct extent_buffer *leaf; | 4340 | struct extent_buffer *leaf; |
4273 | int ret; | 4341 | int ret; |
4274 | 4342 | ||
4275 | key.objectid = inode->i_ino; | 4343 | key.objectid = btrfs_ino(inode); |
4276 | btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); | 4344 | btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); |
4277 | key.offset = (u64)-1; | 4345 | key.offset = (u64)-1; |
4278 | 4346 | ||
@@ -4304,7 +4372,7 @@ static int btrfs_set_inode_index_count(struct inode *inode) | |||
4304 | leaf = path->nodes[0]; | 4372 | leaf = path->nodes[0]; |
4305 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); | 4373 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); |
4306 | 4374 | ||
4307 | if (found_key.objectid != inode->i_ino || | 4375 | if (found_key.objectid != btrfs_ino(inode) || |
4308 | btrfs_key_type(&found_key) != BTRFS_DIR_INDEX_KEY) { | 4376 | btrfs_key_type(&found_key) != BTRFS_DIR_INDEX_KEY) { |
4309 | BTRFS_I(inode)->index_cnt = 2; | 4377 | BTRFS_I(inode)->index_cnt = 2; |
4310 | goto out; | 4378 | goto out; |
@@ -4325,9 +4393,12 @@ int btrfs_set_inode_index(struct inode *dir, u64 *index) | |||
4325 | int ret = 0; | 4393 | int ret = 0; |
4326 | 4394 | ||
4327 | if (BTRFS_I(dir)->index_cnt == (u64)-1) { | 4395 | if (BTRFS_I(dir)->index_cnt == (u64)-1) { |
4328 | ret = btrfs_set_inode_index_count(dir); | 4396 | ret = btrfs_inode_delayed_dir_index_count(dir); |
4329 | if (ret) | 4397 | if (ret) { |
4330 | return ret; | 4398 | ret = btrfs_set_inode_index_count(dir); |
4399 | if (ret) | ||
4400 | return ret; | ||
4401 | } | ||
4331 | } | 4402 | } |
4332 | 4403 | ||
4333 | *index = BTRFS_I(dir)->index_cnt; | 4404 | *index = BTRFS_I(dir)->index_cnt; |
@@ -4363,6 +4434,12 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
4363 | return ERR_PTR(-ENOMEM); | 4434 | return ERR_PTR(-ENOMEM); |
4364 | } | 4435 | } |
4365 | 4436 | ||
4437 | /* | ||
4438 | * we have to initialize this early, so we can reclaim the inode | ||
4439 | * number if we fail afterwards in this function. | ||
4440 | */ | ||
4441 | inode->i_ino = objectid; | ||
4442 | |||
4366 | if (dir) { | 4443 | if (dir) { |
4367 | trace_btrfs_inode_request(dir); | 4444 | trace_btrfs_inode_request(dir); |
4368 | 4445 | ||
@@ -4408,7 +4485,6 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
4408 | goto fail; | 4485 | goto fail; |
4409 | 4486 | ||
4410 | inode_init_owner(inode, dir, mode); | 4487 | inode_init_owner(inode, dir, mode); |
4411 | inode->i_ino = objectid; | ||
4412 | inode_set_bytes(inode, 0); | 4488 | inode_set_bytes(inode, 0); |
4413 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 4489 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
4414 | inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0], | 4490 | inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0], |
@@ -4472,29 +4548,29 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, | |||
4472 | int ret = 0; | 4548 | int ret = 0; |
4473 | struct btrfs_key key; | 4549 | struct btrfs_key key; |
4474 | struct btrfs_root *root = BTRFS_I(parent_inode)->root; | 4550 | struct btrfs_root *root = BTRFS_I(parent_inode)->root; |
4551 | u64 ino = btrfs_ino(inode); | ||
4552 | u64 parent_ino = btrfs_ino(parent_inode); | ||
4475 | 4553 | ||
4476 | if (unlikely(inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) { | 4554 | if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) { |
4477 | memcpy(&key, &BTRFS_I(inode)->root->root_key, sizeof(key)); | 4555 | memcpy(&key, &BTRFS_I(inode)->root->root_key, sizeof(key)); |
4478 | } else { | 4556 | } else { |
4479 | key.objectid = inode->i_ino; | 4557 | key.objectid = ino; |
4480 | btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); | 4558 | btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); |
4481 | key.offset = 0; | 4559 | key.offset = 0; |
4482 | } | 4560 | } |
4483 | 4561 | ||
4484 | if (unlikely(inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) { | 4562 | if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) { |
4485 | ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, | 4563 | ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, |
4486 | key.objectid, root->root_key.objectid, | 4564 | key.objectid, root->root_key.objectid, |
4487 | parent_inode->i_ino, | 4565 | parent_ino, index, name, name_len); |
4488 | index, name, name_len); | ||
4489 | } else if (add_backref) { | 4566 | } else if (add_backref) { |
4490 | ret = btrfs_insert_inode_ref(trans, root, | 4567 | ret = btrfs_insert_inode_ref(trans, root, name, name_len, ino, |
4491 | name, name_len, inode->i_ino, | 4568 | parent_ino, index); |
4492 | parent_inode->i_ino, index); | ||
4493 | } | 4569 | } |
4494 | 4570 | ||
4495 | if (ret == 0) { | 4571 | if (ret == 0) { |
4496 | ret = btrfs_insert_dir_item(trans, root, name, name_len, | 4572 | ret = btrfs_insert_dir_item(trans, root, name, name_len, |
4497 | parent_inode->i_ino, &key, | 4573 | parent_inode, &key, |
4498 | btrfs_inode_type(inode), index); | 4574 | btrfs_inode_type(inode), index); |
4499 | BUG_ON(ret); | 4575 | BUG_ON(ret); |
4500 | 4576 | ||
@@ -4537,10 +4613,6 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
4537 | if (!new_valid_dev(rdev)) | 4613 | if (!new_valid_dev(rdev)) |
4538 | return -EINVAL; | 4614 | return -EINVAL; |
4539 | 4615 | ||
4540 | err = btrfs_find_free_objectid(NULL, root, dir->i_ino, &objectid); | ||
4541 | if (err) | ||
4542 | return err; | ||
4543 | |||
4544 | /* | 4616 | /* |
4545 | * 2 for inode item and ref | 4617 | * 2 for inode item and ref |
4546 | * 2 for dir items | 4618 | * 2 for dir items |
@@ -4552,8 +4624,12 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
4552 | 4624 | ||
4553 | btrfs_set_trans_block_group(trans, dir); | 4625 | btrfs_set_trans_block_group(trans, dir); |
4554 | 4626 | ||
4627 | err = btrfs_find_free_ino(root, &objectid); | ||
4628 | if (err) | ||
4629 | goto out_unlock; | ||
4630 | |||
4555 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, | 4631 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, |
4556 | dentry->d_name.len, dir->i_ino, objectid, | 4632 | dentry->d_name.len, btrfs_ino(dir), objectid, |
4557 | BTRFS_I(dir)->block_group, mode, &index); | 4633 | BTRFS_I(dir)->block_group, mode, &index); |
4558 | if (IS_ERR(inode)) { | 4634 | if (IS_ERR(inode)) { |
4559 | err = PTR_ERR(inode); | 4635 | err = PTR_ERR(inode); |
@@ -4600,9 +4676,6 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
4600 | u64 objectid; | 4676 | u64 objectid; |
4601 | u64 index = 0; | 4677 | u64 index = 0; |
4602 | 4678 | ||
4603 | err = btrfs_find_free_objectid(NULL, root, dir->i_ino, &objectid); | ||
4604 | if (err) | ||
4605 | return err; | ||
4606 | /* | 4679 | /* |
4607 | * 2 for inode item and ref | 4680 | * 2 for inode item and ref |
4608 | * 2 for dir items | 4681 | * 2 for dir items |
@@ -4614,8 +4687,12 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
4614 | 4687 | ||
4615 | btrfs_set_trans_block_group(trans, dir); | 4688 | btrfs_set_trans_block_group(trans, dir); |
4616 | 4689 | ||
4690 | err = btrfs_find_free_ino(root, &objectid); | ||
4691 | if (err) | ||
4692 | goto out_unlock; | ||
4693 | |||
4617 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, | 4694 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, |
4618 | dentry->d_name.len, dir->i_ino, objectid, | 4695 | dentry->d_name.len, btrfs_ino(dir), objectid, |
4619 | BTRFS_I(dir)->block_group, mode, &index); | 4696 | BTRFS_I(dir)->block_group, mode, &index); |
4620 | if (IS_ERR(inode)) { | 4697 | if (IS_ERR(inode)) { |
4621 | err = PTR_ERR(inode); | 4698 | err = PTR_ERR(inode); |
@@ -4726,10 +4803,6 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
4726 | u64 index = 0; | 4803 | u64 index = 0; |
4727 | unsigned long nr = 1; | 4804 | unsigned long nr = 1; |
4728 | 4805 | ||
4729 | err = btrfs_find_free_objectid(NULL, root, dir->i_ino, &objectid); | ||
4730 | if (err) | ||
4731 | return err; | ||
4732 | |||
4733 | /* | 4806 | /* |
4734 | * 2 items for inode and ref | 4807 | * 2 items for inode and ref |
4735 | * 2 items for dir items | 4808 | * 2 items for dir items |
@@ -4740,8 +4813,12 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
4740 | return PTR_ERR(trans); | 4813 | return PTR_ERR(trans); |
4741 | btrfs_set_trans_block_group(trans, dir); | 4814 | btrfs_set_trans_block_group(trans, dir); |
4742 | 4815 | ||
4816 | err = btrfs_find_free_ino(root, &objectid); | ||
4817 | if (err) | ||
4818 | goto out_fail; | ||
4819 | |||
4743 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, | 4820 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, |
4744 | dentry->d_name.len, dir->i_ino, objectid, | 4821 | dentry->d_name.len, btrfs_ino(dir), objectid, |
4745 | BTRFS_I(dir)->block_group, S_IFDIR | mode, | 4822 | BTRFS_I(dir)->block_group, S_IFDIR | mode, |
4746 | &index); | 4823 | &index); |
4747 | if (IS_ERR(inode)) { | 4824 | if (IS_ERR(inode)) { |
@@ -4864,7 +4941,7 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page, | |||
4864 | u64 bytenr; | 4941 | u64 bytenr; |
4865 | u64 extent_start = 0; | 4942 | u64 extent_start = 0; |
4866 | u64 extent_end = 0; | 4943 | u64 extent_end = 0; |
4867 | u64 objectid = inode->i_ino; | 4944 | u64 objectid = btrfs_ino(inode); |
4868 | u32 found_type; | 4945 | u32 found_type; |
4869 | struct btrfs_path *path = NULL; | 4946 | struct btrfs_path *path = NULL; |
4870 | struct btrfs_root *root = BTRFS_I(inode)->root; | 4947 | struct btrfs_root *root = BTRFS_I(inode)->root; |
@@ -5372,7 +5449,7 @@ static noinline int can_nocow_odirect(struct btrfs_trans_handle *trans, | |||
5372 | if (!path) | 5449 | if (!path) |
5373 | return -ENOMEM; | 5450 | return -ENOMEM; |
5374 | 5451 | ||
5375 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, | 5452 | ret = btrfs_lookup_file_extent(trans, root, path, btrfs_ino(inode), |
5376 | offset, 0); | 5453 | offset, 0); |
5377 | if (ret < 0) | 5454 | if (ret < 0) |
5378 | goto out; | 5455 | goto out; |
@@ -5389,7 +5466,7 @@ static noinline int can_nocow_odirect(struct btrfs_trans_handle *trans, | |||
5389 | ret = 0; | 5466 | ret = 0; |
5390 | leaf = path->nodes[0]; | 5467 | leaf = path->nodes[0]; |
5391 | btrfs_item_key_to_cpu(leaf, &key, slot); | 5468 | btrfs_item_key_to_cpu(leaf, &key, slot); |
5392 | if (key.objectid != inode->i_ino || | 5469 | if (key.objectid != btrfs_ino(inode) || |
5393 | key.type != BTRFS_EXTENT_DATA_KEY) { | 5470 | key.type != BTRFS_EXTENT_DATA_KEY) { |
5394 | /* not our file or wrong item type, must cow */ | 5471 | /* not our file or wrong item type, must cow */ |
5395 | goto out; | 5472 | goto out; |
@@ -5423,7 +5500,7 @@ static noinline int can_nocow_odirect(struct btrfs_trans_handle *trans, | |||
5423 | * look for other files referencing this extent, if we | 5500 | * look for other files referencing this extent, if we |
5424 | * find any we must cow | 5501 | * find any we must cow |
5425 | */ | 5502 | */ |
5426 | if (btrfs_cross_ref_exist(trans, root, inode->i_ino, | 5503 | if (btrfs_cross_ref_exist(trans, root, btrfs_ino(inode), |
5427 | key.offset - backref_offset, disk_bytenr)) | 5504 | key.offset - backref_offset, disk_bytenr)) |
5428 | goto out; | 5505 | goto out; |
5429 | 5506 | ||
@@ -5613,9 +5690,10 @@ static void btrfs_endio_direct_read(struct bio *bio, int err) | |||
5613 | 5690 | ||
5614 | flush_dcache_page(bvec->bv_page); | 5691 | flush_dcache_page(bvec->bv_page); |
5615 | if (csum != *private) { | 5692 | if (csum != *private) { |
5616 | printk(KERN_ERR "btrfs csum failed ino %lu off" | 5693 | printk(KERN_ERR "btrfs csum failed ino %llu off" |
5617 | " %llu csum %u private %u\n", | 5694 | " %llu csum %u private %u\n", |
5618 | inode->i_ino, (unsigned long long)start, | 5695 | (unsigned long long)btrfs_ino(inode), |
5696 | (unsigned long long)start, | ||
5619 | csum, *private); | 5697 | csum, *private); |
5620 | err = -EIO; | 5698 | err = -EIO; |
5621 | } | 5699 | } |
@@ -5762,9 +5840,9 @@ static void btrfs_end_dio_bio(struct bio *bio, int err) | |||
5762 | struct btrfs_dio_private *dip = bio->bi_private; | 5840 | struct btrfs_dio_private *dip = bio->bi_private; |
5763 | 5841 | ||
5764 | if (err) { | 5842 | if (err) { |
5765 | printk(KERN_ERR "btrfs direct IO failed ino %lu rw %lu " | 5843 | printk(KERN_ERR "btrfs direct IO failed ino %llu rw %lu " |
5766 | "sector %#Lx len %u err no %d\n", | 5844 | "sector %#Lx len %u err no %d\n", |
5767 | dip->inode->i_ino, bio->bi_rw, | 5845 | (unsigned long long)btrfs_ino(dip->inode), bio->bi_rw, |
5768 | (unsigned long long)bio->bi_sector, bio->bi_size, err); | 5846 | (unsigned long long)bio->bi_sector, bio->bi_size, err); |
5769 | dip->errors = 1; | 5847 | dip->errors = 1; |
5770 | 5848 | ||
@@ -6607,6 +6685,8 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) | |||
6607 | ei->dummy_inode = 0; | 6685 | ei->dummy_inode = 0; |
6608 | ei->force_compress = BTRFS_COMPRESS_NONE; | 6686 | ei->force_compress = BTRFS_COMPRESS_NONE; |
6609 | 6687 | ||
6688 | ei->delayed_node = NULL; | ||
6689 | |||
6610 | inode = &ei->vfs_inode; | 6690 | inode = &ei->vfs_inode; |
6611 | extent_map_tree_init(&ei->extent_tree); | 6691 | extent_map_tree_init(&ei->extent_tree); |
6612 | extent_io_tree_init(&ei->io_tree, &inode->i_data); | 6692 | extent_io_tree_init(&ei->io_tree, &inode->i_data); |
@@ -6674,8 +6754,8 @@ void btrfs_destroy_inode(struct inode *inode) | |||
6674 | 6754 | ||
6675 | spin_lock(&root->orphan_lock); | 6755 | spin_lock(&root->orphan_lock); |
6676 | if (!list_empty(&BTRFS_I(inode)->i_orphan)) { | 6756 | if (!list_empty(&BTRFS_I(inode)->i_orphan)) { |
6677 | printk(KERN_INFO "BTRFS: inode %lu still on the orphan list\n", | 6757 | printk(KERN_INFO "BTRFS: inode %llu still on the orphan list\n", |
6678 | inode->i_ino); | 6758 | (unsigned long long)btrfs_ino(inode)); |
6679 | list_del_init(&BTRFS_I(inode)->i_orphan); | 6759 | list_del_init(&BTRFS_I(inode)->i_orphan); |
6680 | } | 6760 | } |
6681 | spin_unlock(&root->orphan_lock); | 6761 | spin_unlock(&root->orphan_lock); |
@@ -6697,6 +6777,7 @@ void btrfs_destroy_inode(struct inode *inode) | |||
6697 | inode_tree_del(inode); | 6777 | inode_tree_del(inode); |
6698 | btrfs_drop_extent_cache(inode, 0, (u64)-1, 0); | 6778 | btrfs_drop_extent_cache(inode, 0, (u64)-1, 0); |
6699 | free: | 6779 | free: |
6780 | btrfs_remove_delayed_node(inode); | ||
6700 | call_rcu(&inode->i_rcu, btrfs_i_callback); | 6781 | call_rcu(&inode->i_rcu, btrfs_i_callback); |
6701 | } | 6782 | } |
6702 | 6783 | ||
@@ -6705,7 +6786,7 @@ int btrfs_drop_inode(struct inode *inode) | |||
6705 | struct btrfs_root *root = BTRFS_I(inode)->root; | 6786 | struct btrfs_root *root = BTRFS_I(inode)->root; |
6706 | 6787 | ||
6707 | if (btrfs_root_refs(&root->root_item) == 0 && | 6788 | if (btrfs_root_refs(&root->root_item) == 0 && |
6708 | root != root->fs_info->tree_root) | 6789 | !is_free_space_inode(root, inode)) |
6709 | return 1; | 6790 | return 1; |
6710 | else | 6791 | else |
6711 | return generic_drop_inode(inode); | 6792 | return generic_drop_inode(inode); |
@@ -6808,38 +6889,39 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
6808 | struct btrfs_trans_handle *trans; | 6889 | struct btrfs_trans_handle *trans; |
6809 | struct btrfs_root *root = BTRFS_I(old_dir)->root; | 6890 | struct btrfs_root *root = BTRFS_I(old_dir)->root; |
6810 | struct btrfs_root *dest = BTRFS_I(new_dir)->root; | 6891 | struct btrfs_root *dest = BTRFS_I(new_dir)->root; |
6811 | struct inode *newinode = new_dentry->d_inode; | 6892 | struct inode *new_inode = new_dentry->d_inode; |
6812 | struct inode *old_inode = old_dentry->d_inode; | 6893 | struct inode *old_inode = old_dentry->d_inode; |
6813 | struct timespec ctime = CURRENT_TIME; | 6894 | struct timespec ctime = CURRENT_TIME; |
6814 | u64 index = 0; | 6895 | u64 index = 0; |
6815 | u64 root_objectid; | 6896 | u64 root_objectid; |
6816 | int ret; | 6897 | int ret; |
6898 | u64 old_ino = btrfs_ino(old_inode); | ||
6817 | 6899 | ||
6818 | if (new_dir->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) | 6900 | if (btrfs_ino(new_dir) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) |
6819 | return -EPERM; | 6901 | return -EPERM; |
6820 | 6902 | ||
6821 | /* we only allow rename subvolume link between subvolumes */ | 6903 | /* we only allow rename subvolume link between subvolumes */ |
6822 | if (old_inode->i_ino != BTRFS_FIRST_FREE_OBJECTID && root != dest) | 6904 | if (old_ino != BTRFS_FIRST_FREE_OBJECTID && root != dest) |
6823 | return -EXDEV; | 6905 | return -EXDEV; |
6824 | 6906 | ||
6825 | if (old_inode->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID || | 6907 | if (old_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID || |
6826 | (newinode && newinode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) | 6908 | (new_inode && btrfs_ino(new_inode) == BTRFS_FIRST_FREE_OBJECTID)) |
6827 | return -ENOTEMPTY; | 6909 | return -ENOTEMPTY; |
6828 | 6910 | ||
6829 | if (S_ISDIR(old_inode->i_mode) && newinode && | 6911 | if (S_ISDIR(old_inode->i_mode) && new_inode && |
6830 | newinode->i_size > BTRFS_EMPTY_DIR_SIZE) | 6912 | new_inode->i_size > BTRFS_EMPTY_DIR_SIZE) |
6831 | return -ENOTEMPTY; | 6913 | return -ENOTEMPTY; |
6832 | /* | 6914 | /* |
6833 | * we're using rename to replace one file with another. | 6915 | * we're using rename to replace one file with another. |
6834 | * and the replacement file is large. Start IO on it now so | 6916 | * and the replacement file is large. Start IO on it now so |
6835 | * we don't add too much work to the end of the transaction | 6917 | * we don't add too much work to the end of the transaction |
6836 | */ | 6918 | */ |
6837 | if (newinode && S_ISREG(old_inode->i_mode) && newinode->i_size && | 6919 | if (new_inode && S_ISREG(old_inode->i_mode) && new_inode->i_size && |
6838 | old_inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT) | 6920 | old_inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT) |
6839 | filemap_flush(old_inode->i_mapping); | 6921 | filemap_flush(old_inode->i_mapping); |
6840 | 6922 | ||
6841 | /* close the racy window with snapshot create/destroy ioctl */ | 6923 | /* close the racy window with snapshot create/destroy ioctl */ |
6842 | if (old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) | 6924 | if (old_ino == BTRFS_FIRST_FREE_OBJECTID) |
6843 | down_read(&root->fs_info->subvol_sem); | 6925 | down_read(&root->fs_info->subvol_sem); |
6844 | /* | 6926 | /* |
6845 | * We want to reserve the absolute worst case amount of items. So if | 6927 | * We want to reserve the absolute worst case amount of items. So if |
@@ -6864,15 +6946,15 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
6864 | if (ret) | 6946 | if (ret) |
6865 | goto out_fail; | 6947 | goto out_fail; |
6866 | 6948 | ||
6867 | if (unlikely(old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) { | 6949 | if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) { |
6868 | /* force full log commit if subvolume involved. */ | 6950 | /* force full log commit if subvolume involved. */ |
6869 | root->fs_info->last_trans_log_full_commit = trans->transid; | 6951 | root->fs_info->last_trans_log_full_commit = trans->transid; |
6870 | } else { | 6952 | } else { |
6871 | ret = btrfs_insert_inode_ref(trans, dest, | 6953 | ret = btrfs_insert_inode_ref(trans, dest, |
6872 | new_dentry->d_name.name, | 6954 | new_dentry->d_name.name, |
6873 | new_dentry->d_name.len, | 6955 | new_dentry->d_name.len, |
6874 | old_inode->i_ino, | 6956 | old_ino, |
6875 | new_dir->i_ino, index); | 6957 | btrfs_ino(new_dir), index); |
6876 | if (ret) | 6958 | if (ret) |
6877 | goto out_fail; | 6959 | goto out_fail; |
6878 | /* | 6960 | /* |
@@ -6888,10 +6970,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
6888 | * make sure the inode gets flushed if it is replacing | 6970 | * make sure the inode gets flushed if it is replacing |
6889 | * something. | 6971 | * something. |
6890 | */ | 6972 | */ |
6891 | if (newinode && newinode->i_size && | 6973 | if (new_inode && new_inode->i_size && S_ISREG(old_inode->i_mode)) |
6892 | old_inode && S_ISREG(old_inode->i_mode)) { | ||
6893 | btrfs_add_ordered_operation(trans, root, old_inode); | 6974 | btrfs_add_ordered_operation(trans, root, old_inode); |
6894 | } | ||
6895 | 6975 | ||
6896 | old_dir->i_ctime = old_dir->i_mtime = ctime; | 6976 | old_dir->i_ctime = old_dir->i_mtime = ctime; |
6897 | new_dir->i_ctime = new_dir->i_mtime = ctime; | 6977 | new_dir->i_ctime = new_dir->i_mtime = ctime; |
@@ -6900,7 +6980,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
6900 | if (old_dentry->d_parent != new_dentry->d_parent) | 6980 | if (old_dentry->d_parent != new_dentry->d_parent) |
6901 | btrfs_record_unlink_dir(trans, old_dir, old_inode, 1); | 6981 | btrfs_record_unlink_dir(trans, old_dir, old_inode, 1); |
6902 | 6982 | ||
6903 | if (unlikely(old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) { | 6983 | if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) { |
6904 | root_objectid = BTRFS_I(old_inode)->root->root_key.objectid; | 6984 | root_objectid = BTRFS_I(old_inode)->root->root_key.objectid; |
6905 | ret = btrfs_unlink_subvol(trans, root, old_dir, root_objectid, | 6985 | ret = btrfs_unlink_subvol(trans, root, old_dir, root_objectid, |
6906 | old_dentry->d_name.name, | 6986 | old_dentry->d_name.name, |
@@ -6915,16 +6995,16 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
6915 | } | 6995 | } |
6916 | BUG_ON(ret); | 6996 | BUG_ON(ret); |
6917 | 6997 | ||
6918 | if (newinode) { | 6998 | if (new_inode) { |
6919 | newinode->i_ctime = CURRENT_TIME; | 6999 | new_inode->i_ctime = CURRENT_TIME; |
6920 | if (unlikely(newinode->i_ino == | 7000 | if (unlikely(btrfs_ino(new_inode) == |
6921 | BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { | 7001 | BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { |
6922 | root_objectid = BTRFS_I(newinode)->location.objectid; | 7002 | root_objectid = BTRFS_I(new_inode)->location.objectid; |
6923 | ret = btrfs_unlink_subvol(trans, dest, new_dir, | 7003 | ret = btrfs_unlink_subvol(trans, dest, new_dir, |
6924 | root_objectid, | 7004 | root_objectid, |
6925 | new_dentry->d_name.name, | 7005 | new_dentry->d_name.name, |
6926 | new_dentry->d_name.len); | 7006 | new_dentry->d_name.len); |
6927 | BUG_ON(newinode->i_nlink == 0); | 7007 | BUG_ON(new_inode->i_nlink == 0); |
6928 | } else { | 7008 | } else { |
6929 | ret = btrfs_unlink_inode(trans, dest, new_dir, | 7009 | ret = btrfs_unlink_inode(trans, dest, new_dir, |
6930 | new_dentry->d_inode, | 7010 | new_dentry->d_inode, |
@@ -6932,7 +7012,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
6932 | new_dentry->d_name.len); | 7012 | new_dentry->d_name.len); |
6933 | } | 7013 | } |
6934 | BUG_ON(ret); | 7014 | BUG_ON(ret); |
6935 | if (newinode->i_nlink == 0) { | 7015 | if (new_inode->i_nlink == 0) { |
6936 | ret = btrfs_orphan_add(trans, new_dentry->d_inode); | 7016 | ret = btrfs_orphan_add(trans, new_dentry->d_inode); |
6937 | BUG_ON(ret); | 7017 | BUG_ON(ret); |
6938 | } | 7018 | } |
@@ -6945,7 +7025,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
6945 | new_dentry->d_name.len, 0, index); | 7025 | new_dentry->d_name.len, 0, index); |
6946 | BUG_ON(ret); | 7026 | BUG_ON(ret); |
6947 | 7027 | ||
6948 | if (old_inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) { | 7028 | if (old_ino != BTRFS_FIRST_FREE_OBJECTID) { |
6949 | struct dentry *parent = dget_parent(new_dentry); | 7029 | struct dentry *parent = dget_parent(new_dentry); |
6950 | btrfs_log_new_name(trans, old_inode, old_dir, parent); | 7030 | btrfs_log_new_name(trans, old_inode, old_dir, parent); |
6951 | dput(parent); | 7031 | dput(parent); |
@@ -6954,7 +7034,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
6954 | out_fail: | 7034 | out_fail: |
6955 | btrfs_end_transaction_throttle(trans, root); | 7035 | btrfs_end_transaction_throttle(trans, root); |
6956 | out_notrans: | 7036 | out_notrans: |
6957 | if (old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) | 7037 | if (old_ino == BTRFS_FIRST_FREE_OBJECTID) |
6958 | up_read(&root->fs_info->subvol_sem); | 7038 | up_read(&root->fs_info->subvol_sem); |
6959 | 7039 | ||
6960 | return ret; | 7040 | return ret; |
@@ -7031,9 +7111,6 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
7031 | if (name_len > BTRFS_MAX_INLINE_DATA_SIZE(root)) | 7111 | if (name_len > BTRFS_MAX_INLINE_DATA_SIZE(root)) |
7032 | return -ENAMETOOLONG; | 7112 | return -ENAMETOOLONG; |
7033 | 7113 | ||
7034 | err = btrfs_find_free_objectid(NULL, root, dir->i_ino, &objectid); | ||
7035 | if (err) | ||
7036 | return err; | ||
7037 | /* | 7114 | /* |
7038 | * 2 items for inode item and ref | 7115 | * 2 items for inode item and ref |
7039 | * 2 items for dir items | 7116 | * 2 items for dir items |
@@ -7045,8 +7122,12 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
7045 | 7122 | ||
7046 | btrfs_set_trans_block_group(trans, dir); | 7123 | btrfs_set_trans_block_group(trans, dir); |
7047 | 7124 | ||
7125 | err = btrfs_find_free_ino(root, &objectid); | ||
7126 | if (err) | ||
7127 | goto out_unlock; | ||
7128 | |||
7048 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, | 7129 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, |
7049 | dentry->d_name.len, dir->i_ino, objectid, | 7130 | dentry->d_name.len, btrfs_ino(dir), objectid, |
7050 | BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO, | 7131 | BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO, |
7051 | &index); | 7132 | &index); |
7052 | if (IS_ERR(inode)) { | 7133 | if (IS_ERR(inode)) { |
@@ -7078,7 +7159,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
7078 | 7159 | ||
7079 | path = btrfs_alloc_path(); | 7160 | path = btrfs_alloc_path(); |
7080 | BUG_ON(!path); | 7161 | BUG_ON(!path); |
7081 | key.objectid = inode->i_ino; | 7162 | key.objectid = btrfs_ino(inode); |
7082 | key.offset = 0; | 7163 | key.offset = 0; |
7083 | btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY); | 7164 | btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY); |
7084 | datasize = btrfs_file_extent_calc_inline_size(name_len); | 7165 | datasize = btrfs_file_extent_calc_inline_size(name_len); |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index d11fc6548e1..ed8c055ab70 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include "print-tree.h" | 50 | #include "print-tree.h" |
51 | #include "volumes.h" | 51 | #include "volumes.h" |
52 | #include "locking.h" | 52 | #include "locking.h" |
53 | #include "inode-map.h" | ||
53 | 54 | ||
54 | /* Mask out flags that are inappropriate for the given type of inode. */ | 55 | /* Mask out flags that are inappropriate for the given type of inode. */ |
55 | static inline __u32 btrfs_mask_flags(umode_t mode, __u32 flags) | 56 | static inline __u32 btrfs_mask_flags(umode_t mode, __u32 flags) |
@@ -81,6 +82,13 @@ static unsigned int btrfs_flags_to_ioctl(unsigned int flags) | |||
81 | iflags |= FS_NOATIME_FL; | 82 | iflags |= FS_NOATIME_FL; |
82 | if (flags & BTRFS_INODE_DIRSYNC) | 83 | if (flags & BTRFS_INODE_DIRSYNC) |
83 | iflags |= FS_DIRSYNC_FL; | 84 | iflags |= FS_DIRSYNC_FL; |
85 | if (flags & BTRFS_INODE_NODATACOW) | ||
86 | iflags |= FS_NOCOW_FL; | ||
87 | |||
88 | if ((flags & BTRFS_INODE_COMPRESS) && !(flags & BTRFS_INODE_NOCOMPRESS)) | ||
89 | iflags |= FS_COMPR_FL; | ||
90 | else if (flags & BTRFS_INODE_NOCOMPRESS) | ||
91 | iflags |= FS_NOCOMP_FL; | ||
84 | 92 | ||
85 | return iflags; | 93 | return iflags; |
86 | } | 94 | } |
@@ -144,16 +152,13 @@ static int check_flags(unsigned int flags) | |||
144 | if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \ | 152 | if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \ |
145 | FS_NOATIME_FL | FS_NODUMP_FL | \ | 153 | FS_NOATIME_FL | FS_NODUMP_FL | \ |
146 | FS_SYNC_FL | FS_DIRSYNC_FL | \ | 154 | FS_SYNC_FL | FS_DIRSYNC_FL | \ |
147 | FS_NOCOMP_FL | FS_COMPR_FL | \ | 155 | FS_NOCOMP_FL | FS_COMPR_FL | |
148 | FS_NOCOW_FL | FS_COW_FL)) | 156 | FS_NOCOW_FL)) |
149 | return -EOPNOTSUPP; | 157 | return -EOPNOTSUPP; |
150 | 158 | ||
151 | if ((flags & FS_NOCOMP_FL) && (flags & FS_COMPR_FL)) | 159 | if ((flags & FS_NOCOMP_FL) && (flags & FS_COMPR_FL)) |
152 | return -EINVAL; | 160 | return -EINVAL; |
153 | 161 | ||
154 | if ((flags & FS_NOCOW_FL) && (flags & FS_COW_FL)) | ||
155 | return -EINVAL; | ||
156 | |||
157 | return 0; | 162 | return 0; |
158 | } | 163 | } |
159 | 164 | ||
@@ -218,6 +223,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) | |||
218 | ip->flags |= BTRFS_INODE_DIRSYNC; | 223 | ip->flags |= BTRFS_INODE_DIRSYNC; |
219 | else | 224 | else |
220 | ip->flags &= ~BTRFS_INODE_DIRSYNC; | 225 | ip->flags &= ~BTRFS_INODE_DIRSYNC; |
226 | if (flags & FS_NOCOW_FL) | ||
227 | ip->flags |= BTRFS_INODE_NODATACOW; | ||
228 | else | ||
229 | ip->flags &= ~BTRFS_INODE_NODATACOW; | ||
221 | 230 | ||
222 | /* | 231 | /* |
223 | * The COMPRESS flag can only be changed by users, while the NOCOMPRESS | 232 | * The COMPRESS flag can only be changed by users, while the NOCOMPRESS |
@@ -230,11 +239,9 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) | |||
230 | } else if (flags & FS_COMPR_FL) { | 239 | } else if (flags & FS_COMPR_FL) { |
231 | ip->flags |= BTRFS_INODE_COMPRESS; | 240 | ip->flags |= BTRFS_INODE_COMPRESS; |
232 | ip->flags &= ~BTRFS_INODE_NOCOMPRESS; | 241 | ip->flags &= ~BTRFS_INODE_NOCOMPRESS; |
242 | } else { | ||
243 | ip->flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS); | ||
233 | } | 244 | } |
234 | if (flags & FS_NOCOW_FL) | ||
235 | ip->flags |= BTRFS_INODE_NODATACOW; | ||
236 | else if (flags & FS_COW_FL) | ||
237 | ip->flags &= ~BTRFS_INODE_NODATACOW; | ||
238 | 245 | ||
239 | trans = btrfs_join_transaction(root, 1); | 246 | trans = btrfs_join_transaction(root, 1); |
240 | BUG_ON(IS_ERR(trans)); | 247 | BUG_ON(IS_ERR(trans)); |
@@ -323,8 +330,7 @@ static noinline int create_subvol(struct btrfs_root *root, | |||
323 | u64 new_dirid = BTRFS_FIRST_FREE_OBJECTID; | 330 | u64 new_dirid = BTRFS_FIRST_FREE_OBJECTID; |
324 | u64 index = 0; | 331 | u64 index = 0; |
325 | 332 | ||
326 | ret = btrfs_find_free_objectid(NULL, root->fs_info->tree_root, | 333 | ret = btrfs_find_free_objectid(root->fs_info->tree_root, &objectid); |
327 | 0, &objectid); | ||
328 | if (ret) { | 334 | if (ret) { |
329 | dput(parent); | 335 | dput(parent); |
330 | return ret; | 336 | return ret; |
@@ -416,7 +422,7 @@ static noinline int create_subvol(struct btrfs_root *root, | |||
416 | BUG_ON(ret); | 422 | BUG_ON(ret); |
417 | 423 | ||
418 | ret = btrfs_insert_dir_item(trans, root, | 424 | ret = btrfs_insert_dir_item(trans, root, |
419 | name, namelen, dir->i_ino, &key, | 425 | name, namelen, dir, &key, |
420 | BTRFS_FT_DIR, index); | 426 | BTRFS_FT_DIR, index); |
421 | if (ret) | 427 | if (ret) |
422 | goto fail; | 428 | goto fail; |
@@ -427,7 +433,7 @@ static noinline int create_subvol(struct btrfs_root *root, | |||
427 | 433 | ||
428 | ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, | 434 | ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, |
429 | objectid, root->root_key.objectid, | 435 | objectid, root->root_key.objectid, |
430 | dir->i_ino, index, name, namelen); | 436 | btrfs_ino(dir), index, name, namelen); |
431 | 437 | ||
432 | BUG_ON(ret); | 438 | BUG_ON(ret); |
433 | 439 | ||
@@ -1123,7 +1129,7 @@ static noinline int btrfs_ioctl_subvol_getflags(struct file *file, | |||
1123 | int ret = 0; | 1129 | int ret = 0; |
1124 | u64 flags = 0; | 1130 | u64 flags = 0; |
1125 | 1131 | ||
1126 | if (inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) | 1132 | if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) |
1127 | return -EINVAL; | 1133 | return -EINVAL; |
1128 | 1134 | ||
1129 | down_read(&root->fs_info->subvol_sem); | 1135 | down_read(&root->fs_info->subvol_sem); |
@@ -1150,7 +1156,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file, | |||
1150 | if (root->fs_info->sb->s_flags & MS_RDONLY) | 1156 | if (root->fs_info->sb->s_flags & MS_RDONLY) |
1151 | return -EROFS; | 1157 | return -EROFS; |
1152 | 1158 | ||
1153 | if (inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) | 1159 | if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) |
1154 | return -EINVAL; | 1160 | return -EINVAL; |
1155 | 1161 | ||
1156 | if (copy_from_user(&flags, arg, sizeof(flags))) | 1162 | if (copy_from_user(&flags, arg, sizeof(flags))) |
@@ -1633,7 +1639,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, | |||
1633 | goto out_dput; | 1639 | goto out_dput; |
1634 | } | 1640 | } |
1635 | 1641 | ||
1636 | if (inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) { | 1642 | if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) { |
1637 | err = -EINVAL; | 1643 | err = -EINVAL; |
1638 | goto out_dput; | 1644 | goto out_dput; |
1639 | } | 1645 | } |
@@ -1919,7 +1925,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
1919 | } | 1925 | } |
1920 | 1926 | ||
1921 | /* clone data */ | 1927 | /* clone data */ |
1922 | key.objectid = src->i_ino; | 1928 | key.objectid = btrfs_ino(src); |
1923 | key.type = BTRFS_EXTENT_DATA_KEY; | 1929 | key.type = BTRFS_EXTENT_DATA_KEY; |
1924 | key.offset = 0; | 1930 | key.offset = 0; |
1925 | 1931 | ||
@@ -1946,7 +1952,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
1946 | 1952 | ||
1947 | btrfs_item_key_to_cpu(leaf, &key, slot); | 1953 | btrfs_item_key_to_cpu(leaf, &key, slot); |
1948 | if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY || | 1954 | if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY || |
1949 | key.objectid != src->i_ino) | 1955 | key.objectid != btrfs_ino(src)) |
1950 | break; | 1956 | break; |
1951 | 1957 | ||
1952 | if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY) { | 1958 | if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY) { |
@@ -1989,7 +1995,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
1989 | goto next; | 1995 | goto next; |
1990 | 1996 | ||
1991 | memcpy(&new_key, &key, sizeof(new_key)); | 1997 | memcpy(&new_key, &key, sizeof(new_key)); |
1992 | new_key.objectid = inode->i_ino; | 1998 | new_key.objectid = btrfs_ino(inode); |
1993 | if (off <= key.offset) | 1999 | if (off <= key.offset) |
1994 | new_key.offset = key.offset + destoff - off; | 2000 | new_key.offset = key.offset + destoff - off; |
1995 | else | 2001 | else |
@@ -2043,7 +2049,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2043 | ret = btrfs_inc_extent_ref(trans, root, | 2049 | ret = btrfs_inc_extent_ref(trans, root, |
2044 | disko, diskl, 0, | 2050 | disko, diskl, 0, |
2045 | root->root_key.objectid, | 2051 | root->root_key.objectid, |
2046 | inode->i_ino, | 2052 | btrfs_ino(inode), |
2047 | new_key.offset - datao); | 2053 | new_key.offset - datao); |
2048 | BUG_ON(ret); | 2054 | BUG_ON(ret); |
2049 | } | 2055 | } |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index f726e72dd36..051992c7fcc 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "btrfs_inode.h" | 30 | #include "btrfs_inode.h" |
31 | #include "async-thread.h" | 31 | #include "async-thread.h" |
32 | #include "free-space-cache.h" | 32 | #include "free-space-cache.h" |
33 | #include "inode-map.h" | ||
33 | 34 | ||
34 | /* | 35 | /* |
35 | * backref_node, mapping_node and tree_block start with this | 36 | * backref_node, mapping_node and tree_block start with this |
@@ -1409,9 +1410,9 @@ again: | |||
1409 | prev = node; | 1410 | prev = node; |
1410 | entry = rb_entry(node, struct btrfs_inode, rb_node); | 1411 | entry = rb_entry(node, struct btrfs_inode, rb_node); |
1411 | 1412 | ||
1412 | if (objectid < entry->vfs_inode.i_ino) | 1413 | if (objectid < btrfs_ino(&entry->vfs_inode)) |
1413 | node = node->rb_left; | 1414 | node = node->rb_left; |
1414 | else if (objectid > entry->vfs_inode.i_ino) | 1415 | else if (objectid > btrfs_ino(&entry->vfs_inode)) |
1415 | node = node->rb_right; | 1416 | node = node->rb_right; |
1416 | else | 1417 | else |
1417 | break; | 1418 | break; |
@@ -1419,7 +1420,7 @@ again: | |||
1419 | if (!node) { | 1420 | if (!node) { |
1420 | while (prev) { | 1421 | while (prev) { |
1421 | entry = rb_entry(prev, struct btrfs_inode, rb_node); | 1422 | entry = rb_entry(prev, struct btrfs_inode, rb_node); |
1422 | if (objectid <= entry->vfs_inode.i_ino) { | 1423 | if (objectid <= btrfs_ino(&entry->vfs_inode)) { |
1423 | node = prev; | 1424 | node = prev; |
1424 | break; | 1425 | break; |
1425 | } | 1426 | } |
@@ -1434,7 +1435,7 @@ again: | |||
1434 | return inode; | 1435 | return inode; |
1435 | } | 1436 | } |
1436 | 1437 | ||
1437 | objectid = entry->vfs_inode.i_ino + 1; | 1438 | objectid = btrfs_ino(&entry->vfs_inode) + 1; |
1438 | if (cond_resched_lock(&root->inode_lock)) | 1439 | if (cond_resched_lock(&root->inode_lock)) |
1439 | goto again; | 1440 | goto again; |
1440 | 1441 | ||
@@ -1470,7 +1471,7 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr, | |||
1470 | return -ENOMEM; | 1471 | return -ENOMEM; |
1471 | 1472 | ||
1472 | bytenr -= BTRFS_I(reloc_inode)->index_cnt; | 1473 | bytenr -= BTRFS_I(reloc_inode)->index_cnt; |
1473 | ret = btrfs_lookup_file_extent(NULL, root, path, reloc_inode->i_ino, | 1474 | ret = btrfs_lookup_file_extent(NULL, root, path, btrfs_ino(reloc_inode), |
1474 | bytenr, 0); | 1475 | bytenr, 0); |
1475 | if (ret < 0) | 1476 | if (ret < 0) |
1476 | goto out; | 1477 | goto out; |
@@ -1558,11 +1559,11 @@ int replace_file_extents(struct btrfs_trans_handle *trans, | |||
1558 | if (first) { | 1559 | if (first) { |
1559 | inode = find_next_inode(root, key.objectid); | 1560 | inode = find_next_inode(root, key.objectid); |
1560 | first = 0; | 1561 | first = 0; |
1561 | } else if (inode && inode->i_ino < key.objectid) { | 1562 | } else if (inode && btrfs_ino(inode) < key.objectid) { |
1562 | btrfs_add_delayed_iput(inode); | 1563 | btrfs_add_delayed_iput(inode); |
1563 | inode = find_next_inode(root, key.objectid); | 1564 | inode = find_next_inode(root, key.objectid); |
1564 | } | 1565 | } |
1565 | if (inode && inode->i_ino == key.objectid) { | 1566 | if (inode && btrfs_ino(inode) == key.objectid) { |
1566 | end = key.offset + | 1567 | end = key.offset + |
1567 | btrfs_file_extent_num_bytes(leaf, fi); | 1568 | btrfs_file_extent_num_bytes(leaf, fi); |
1568 | WARN_ON(!IS_ALIGNED(key.offset, | 1569 | WARN_ON(!IS_ALIGNED(key.offset, |
@@ -1893,6 +1894,7 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
1893 | struct inode *inode = NULL; | 1894 | struct inode *inode = NULL; |
1894 | u64 objectid; | 1895 | u64 objectid; |
1895 | u64 start, end; | 1896 | u64 start, end; |
1897 | u64 ino; | ||
1896 | 1898 | ||
1897 | objectid = min_key->objectid; | 1899 | objectid = min_key->objectid; |
1898 | while (1) { | 1900 | while (1) { |
@@ -1905,17 +1907,18 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
1905 | inode = find_next_inode(root, objectid); | 1907 | inode = find_next_inode(root, objectid); |
1906 | if (!inode) | 1908 | if (!inode) |
1907 | break; | 1909 | break; |
1910 | ino = btrfs_ino(inode); | ||
1908 | 1911 | ||
1909 | if (inode->i_ino > max_key->objectid) { | 1912 | if (ino > max_key->objectid) { |
1910 | iput(inode); | 1913 | iput(inode); |
1911 | break; | 1914 | break; |
1912 | } | 1915 | } |
1913 | 1916 | ||
1914 | objectid = inode->i_ino + 1; | 1917 | objectid = ino + 1; |
1915 | if (!S_ISREG(inode->i_mode)) | 1918 | if (!S_ISREG(inode->i_mode)) |
1916 | continue; | 1919 | continue; |
1917 | 1920 | ||
1918 | if (unlikely(min_key->objectid == inode->i_ino)) { | 1921 | if (unlikely(min_key->objectid == ino)) { |
1919 | if (min_key->type > BTRFS_EXTENT_DATA_KEY) | 1922 | if (min_key->type > BTRFS_EXTENT_DATA_KEY) |
1920 | continue; | 1923 | continue; |
1921 | if (min_key->type < BTRFS_EXTENT_DATA_KEY) | 1924 | if (min_key->type < BTRFS_EXTENT_DATA_KEY) |
@@ -1928,7 +1931,7 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
1928 | start = 0; | 1931 | start = 0; |
1929 | } | 1932 | } |
1930 | 1933 | ||
1931 | if (unlikely(max_key->objectid == inode->i_ino)) { | 1934 | if (unlikely(max_key->objectid == ino)) { |
1932 | if (max_key->type < BTRFS_EXTENT_DATA_KEY) | 1935 | if (max_key->type < BTRFS_EXTENT_DATA_KEY) |
1933 | continue; | 1936 | continue; |
1934 | if (max_key->type > BTRFS_EXTENT_DATA_KEY) { | 1937 | if (max_key->type > BTRFS_EXTENT_DATA_KEY) { |
@@ -3897,7 +3900,7 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info, | |||
3897 | if (IS_ERR(trans)) | 3900 | if (IS_ERR(trans)) |
3898 | return ERR_CAST(trans); | 3901 | return ERR_CAST(trans); |
3899 | 3902 | ||
3900 | err = btrfs_find_free_objectid(trans, root, objectid, &objectid); | 3903 | err = btrfs_find_free_objectid(root, &objectid); |
3901 | if (err) | 3904 | if (err) |
3902 | goto out; | 3905 | goto out; |
3903 | 3906 | ||
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 3e28521643f..fb72e2bea88 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/magic.h> | 40 | #include <linux/magic.h> |
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include "compat.h" | 42 | #include "compat.h" |
43 | #include "delayed-inode.h" | ||
43 | #include "ctree.h" | 44 | #include "ctree.h" |
44 | #include "disk-io.h" | 45 | #include "disk-io.h" |
45 | #include "transaction.h" | 46 | #include "transaction.h" |
@@ -1206,10 +1207,14 @@ static int __init init_btrfs_fs(void) | |||
1206 | if (err) | 1207 | if (err) |
1207 | goto free_extent_io; | 1208 | goto free_extent_io; |
1208 | 1209 | ||
1209 | err = btrfs_interface_init(); | 1210 | err = btrfs_delayed_inode_init(); |
1210 | if (err) | 1211 | if (err) |
1211 | goto free_extent_map; | 1212 | goto free_extent_map; |
1212 | 1213 | ||
1214 | err = btrfs_interface_init(); | ||
1215 | if (err) | ||
1216 | goto free_delayed_inode; | ||
1217 | |||
1213 | err = register_filesystem(&btrfs_fs_type); | 1218 | err = register_filesystem(&btrfs_fs_type); |
1214 | if (err) | 1219 | if (err) |
1215 | goto unregister_ioctl; | 1220 | goto unregister_ioctl; |
@@ -1219,6 +1224,8 @@ static int __init init_btrfs_fs(void) | |||
1219 | 1224 | ||
1220 | unregister_ioctl: | 1225 | unregister_ioctl: |
1221 | btrfs_interface_exit(); | 1226 | btrfs_interface_exit(); |
1227 | free_delayed_inode: | ||
1228 | btrfs_delayed_inode_exit(); | ||
1222 | free_extent_map: | 1229 | free_extent_map: |
1223 | extent_map_exit(); | 1230 | extent_map_exit(); |
1224 | free_extent_io: | 1231 | free_extent_io: |
@@ -1235,6 +1242,7 @@ free_sysfs: | |||
1235 | static void __exit exit_btrfs_fs(void) | 1242 | static void __exit exit_btrfs_fs(void) |
1236 | { | 1243 | { |
1237 | btrfs_destroy_cachep(); | 1244 | btrfs_destroy_cachep(); |
1245 | btrfs_delayed_inode_exit(); | ||
1238 | extent_map_exit(); | 1246 | extent_map_exit(); |
1239 | extent_io_exit(); | 1247 | extent_io_exit(); |
1240 | btrfs_interface_exit(); | 1248 | btrfs_interface_exit(); |
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index ab9633fd72a..c3c223ae669 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c | |||
@@ -174,18 +174,6 @@ static const struct sysfs_ops btrfs_root_attr_ops = { | |||
174 | .store = btrfs_root_attr_store, | 174 | .store = btrfs_root_attr_store, |
175 | }; | 175 | }; |
176 | 176 | ||
177 | static struct kobj_type btrfs_root_ktype = { | ||
178 | .default_attrs = btrfs_root_attrs, | ||
179 | .sysfs_ops = &btrfs_root_attr_ops, | ||
180 | .release = btrfs_root_release, | ||
181 | }; | ||
182 | |||
183 | static struct kobj_type btrfs_super_ktype = { | ||
184 | .default_attrs = btrfs_super_attrs, | ||
185 | .sysfs_ops = &btrfs_super_attr_ops, | ||
186 | .release = btrfs_super_release, | ||
187 | }; | ||
188 | |||
189 | /* /sys/fs/btrfs/ entry */ | 177 | /* /sys/fs/btrfs/ entry */ |
190 | static struct kset *btrfs_kset; | 178 | static struct kset *btrfs_kset; |
191 | 179 | ||
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 211aceeb9ea..33679fc710c 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "transaction.h" | 27 | #include "transaction.h" |
28 | #include "locking.h" | 28 | #include "locking.h" |
29 | #include "tree-log.h" | 29 | #include "tree-log.h" |
30 | #include "inode-map.h" | ||
30 | 31 | ||
31 | #define BTRFS_ROOT_TRANS_TAG 0 | 32 | #define BTRFS_ROOT_TRANS_TAG 0 |
32 | 33 | ||
@@ -443,19 +444,40 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, | |||
443 | int btrfs_end_transaction(struct btrfs_trans_handle *trans, | 444 | int btrfs_end_transaction(struct btrfs_trans_handle *trans, |
444 | struct btrfs_root *root) | 445 | struct btrfs_root *root) |
445 | { | 446 | { |
446 | return __btrfs_end_transaction(trans, root, 0, 1); | 447 | int ret; |
448 | |||
449 | ret = __btrfs_end_transaction(trans, root, 0, 1); | ||
450 | if (ret) | ||
451 | return ret; | ||
452 | return 0; | ||
447 | } | 453 | } |
448 | 454 | ||
449 | int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, | 455 | int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, |
450 | struct btrfs_root *root) | 456 | struct btrfs_root *root) |
451 | { | 457 | { |
452 | return __btrfs_end_transaction(trans, root, 1, 1); | 458 | int ret; |
459 | |||
460 | ret = __btrfs_end_transaction(trans, root, 1, 1); | ||
461 | if (ret) | ||
462 | return ret; | ||
463 | return 0; | ||
453 | } | 464 | } |
454 | 465 | ||
455 | int btrfs_end_transaction_nolock(struct btrfs_trans_handle *trans, | 466 | int btrfs_end_transaction_nolock(struct btrfs_trans_handle *trans, |
456 | struct btrfs_root *root) | 467 | struct btrfs_root *root) |
457 | { | 468 | { |
458 | return __btrfs_end_transaction(trans, root, 0, 0); | 469 | int ret; |
470 | |||
471 | ret = __btrfs_end_transaction(trans, root, 0, 0); | ||
472 | if (ret) | ||
473 | return ret; | ||
474 | return 0; | ||
475 | } | ||
476 | |||
477 | int btrfs_end_transaction_dmeta(struct btrfs_trans_handle *trans, | ||
478 | struct btrfs_root *root) | ||
479 | { | ||
480 | return __btrfs_end_transaction(trans, root, 1, 1); | ||
459 | } | 481 | } |
460 | 482 | ||
461 | /* | 483 | /* |
@@ -716,8 +738,14 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans, | |||
716 | btrfs_update_reloc_root(trans, root); | 738 | btrfs_update_reloc_root(trans, root); |
717 | btrfs_orphan_commit_root(trans, root); | 739 | btrfs_orphan_commit_root(trans, root); |
718 | 740 | ||
741 | btrfs_save_ino_cache(root, trans); | ||
742 | |||
719 | if (root->commit_root != root->node) { | 743 | if (root->commit_root != root->node) { |
744 | mutex_lock(&root->fs_commit_mutex); | ||
720 | switch_commit_root(root); | 745 | switch_commit_root(root); |
746 | btrfs_unpin_free_ino(root); | ||
747 | mutex_unlock(&root->fs_commit_mutex); | ||
748 | |||
721 | btrfs_set_root_node(&root->root_item, | 749 | btrfs_set_root_node(&root->root_item, |
722 | root->node); | 750 | root->node); |
723 | } | 751 | } |
@@ -795,7 +823,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
795 | goto fail; | 823 | goto fail; |
796 | } | 824 | } |
797 | 825 | ||
798 | ret = btrfs_find_free_objectid(trans, tree_root, 0, &objectid); | 826 | ret = btrfs_find_free_objectid(tree_root, &objectid); |
799 | if (ret) { | 827 | if (ret) { |
800 | pending->error = ret; | 828 | pending->error = ret; |
801 | goto fail; | 829 | goto fail; |
@@ -832,7 +860,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
832 | BUG_ON(ret); | 860 | BUG_ON(ret); |
833 | ret = btrfs_insert_dir_item(trans, parent_root, | 861 | ret = btrfs_insert_dir_item(trans, parent_root, |
834 | dentry->d_name.name, dentry->d_name.len, | 862 | dentry->d_name.name, dentry->d_name.len, |
835 | parent_inode->i_ino, &key, | 863 | parent_inode, &key, |
836 | BTRFS_FT_DIR, index); | 864 | BTRFS_FT_DIR, index); |
837 | BUG_ON(ret); | 865 | BUG_ON(ret); |
838 | 866 | ||
@@ -874,7 +902,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
874 | */ | 902 | */ |
875 | ret = btrfs_add_root_ref(trans, tree_root, objectid, | 903 | ret = btrfs_add_root_ref(trans, tree_root, objectid, |
876 | parent_root->root_key.objectid, | 904 | parent_root->root_key.objectid, |
877 | parent_inode->i_ino, index, | 905 | btrfs_ino(parent_inode), index, |
878 | dentry->d_name.name, dentry->d_name.len); | 906 | dentry->d_name.name, dentry->d_name.len); |
879 | BUG_ON(ret); | 907 | BUG_ON(ret); |
880 | dput(parent); | 908 | dput(parent); |
@@ -902,6 +930,14 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans, | |||
902 | int ret; | 930 | int ret; |
903 | 931 | ||
904 | list_for_each_entry(pending, head, list) { | 932 | list_for_each_entry(pending, head, list) { |
933 | /* | ||
934 | * We must deal with the delayed items before creating | ||
935 | * snapshots, or we will create a snapthot with inconsistent | ||
936 | * information. | ||
937 | */ | ||
938 | ret = btrfs_run_delayed_items(trans, fs_info->fs_root); | ||
939 | BUG_ON(ret); | ||
940 | |||
905 | ret = create_pending_snapshot(trans, fs_info, pending); | 941 | ret = create_pending_snapshot(trans, fs_info, pending); |
906 | BUG_ON(ret); | 942 | BUG_ON(ret); |
907 | } | 943 | } |
@@ -1155,6 +1191,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
1155 | BUG_ON(ret); | 1191 | BUG_ON(ret); |
1156 | } | 1192 | } |
1157 | 1193 | ||
1194 | ret = btrfs_run_delayed_items(trans, root); | ||
1195 | BUG_ON(ret); | ||
1196 | |||
1158 | /* | 1197 | /* |
1159 | * rename don't use btrfs_join_transaction, so, once we | 1198 | * rename don't use btrfs_join_transaction, so, once we |
1160 | * set the transaction to blocked above, we aren't going | 1199 | * set the transaction to blocked above, we aren't going |
@@ -1181,6 +1220,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
1181 | ret = create_pending_snapshots(trans, root->fs_info); | 1220 | ret = create_pending_snapshots(trans, root->fs_info); |
1182 | BUG_ON(ret); | 1221 | BUG_ON(ret); |
1183 | 1222 | ||
1223 | ret = btrfs_run_delayed_items(trans, root); | ||
1224 | BUG_ON(ret); | ||
1225 | |||
1184 | ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); | 1226 | ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); |
1185 | BUG_ON(ret); | 1227 | BUG_ON(ret); |
1186 | 1228 | ||
@@ -1297,6 +1339,8 @@ int btrfs_clean_old_snapshots(struct btrfs_root *root) | |||
1297 | root = list_entry(list.next, struct btrfs_root, root_list); | 1339 | root = list_entry(list.next, struct btrfs_root, root_list); |
1298 | list_del(&root->root_list); | 1340 | list_del(&root->root_list); |
1299 | 1341 | ||
1342 | btrfs_kill_all_delayed_nodes(root); | ||
1343 | |||
1300 | if (btrfs_header_backref_rev(root->node) < | 1344 | if (btrfs_header_backref_rev(root->node) < |
1301 | BTRFS_MIXED_BACKREF_REV) | 1345 | BTRFS_MIXED_BACKREF_REV) |
1302 | btrfs_drop_snapshot(root, NULL, 0); | 1346 | btrfs_drop_snapshot(root, NULL, 0); |
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 000a41008c3..804c88639e5 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h | |||
@@ -112,6 +112,8 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, | |||
112 | int wait_for_unblock); | 112 | int wait_for_unblock); |
113 | int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, | 113 | int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, |
114 | struct btrfs_root *root); | 114 | struct btrfs_root *root); |
115 | int btrfs_end_transaction_dmeta(struct btrfs_trans_handle *trans, | ||
116 | struct btrfs_root *root); | ||
115 | int btrfs_should_end_transaction(struct btrfs_trans_handle *trans, | 117 | int btrfs_should_end_transaction(struct btrfs_trans_handle *trans, |
116 | struct btrfs_root *root); | 118 | struct btrfs_root *root); |
117 | void btrfs_throttle(struct btrfs_root *root); | 119 | void btrfs_throttle(struct btrfs_root *root); |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index c599e8c2a53..a794b9f6013 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -519,7 +519,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, | |||
519 | * file. This must be done before the btrfs_drop_extents run | 519 | * file. This must be done before the btrfs_drop_extents run |
520 | * so we don't try to drop this extent. | 520 | * so we don't try to drop this extent. |
521 | */ | 521 | */ |
522 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, | 522 | ret = btrfs_lookup_file_extent(trans, root, path, btrfs_ino(inode), |
523 | start, 0); | 523 | start, 0); |
524 | 524 | ||
525 | if (ret == 0 && | 525 | if (ret == 0 && |
@@ -832,7 +832,7 @@ again: | |||
832 | read_extent_buffer(eb, name, (unsigned long)(ref + 1), namelen); | 832 | read_extent_buffer(eb, name, (unsigned long)(ref + 1), namelen); |
833 | 833 | ||
834 | /* if we already have a perfect match, we're done */ | 834 | /* if we already have a perfect match, we're done */ |
835 | if (inode_in_dir(root, path, dir->i_ino, inode->i_ino, | 835 | if (inode_in_dir(root, path, btrfs_ino(dir), btrfs_ino(inode), |
836 | btrfs_inode_ref_index(eb, ref), | 836 | btrfs_inode_ref_index(eb, ref), |
837 | name, namelen)) { | 837 | name, namelen)) { |
838 | goto out; | 838 | goto out; |
@@ -960,8 +960,9 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
960 | unsigned long ptr; | 960 | unsigned long ptr; |
961 | unsigned long ptr_end; | 961 | unsigned long ptr_end; |
962 | int name_len; | 962 | int name_len; |
963 | u64 ino = btrfs_ino(inode); | ||
963 | 964 | ||
964 | key.objectid = inode->i_ino; | 965 | key.objectid = ino; |
965 | key.type = BTRFS_INODE_REF_KEY; | 966 | key.type = BTRFS_INODE_REF_KEY; |
966 | key.offset = (u64)-1; | 967 | key.offset = (u64)-1; |
967 | 968 | ||
@@ -980,7 +981,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
980 | } | 981 | } |
981 | btrfs_item_key_to_cpu(path->nodes[0], &key, | 982 | btrfs_item_key_to_cpu(path->nodes[0], &key, |
982 | path->slots[0]); | 983 | path->slots[0]); |
983 | if (key.objectid != inode->i_ino || | 984 | if (key.objectid != ino || |
984 | key.type != BTRFS_INODE_REF_KEY) | 985 | key.type != BTRFS_INODE_REF_KEY) |
985 | break; | 986 | break; |
986 | ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]); | 987 | ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]); |
@@ -1011,10 +1012,10 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
1011 | if (inode->i_nlink == 0) { | 1012 | if (inode->i_nlink == 0) { |
1012 | if (S_ISDIR(inode->i_mode)) { | 1013 | if (S_ISDIR(inode->i_mode)) { |
1013 | ret = replay_dir_deletes(trans, root, NULL, path, | 1014 | ret = replay_dir_deletes(trans, root, NULL, path, |
1014 | inode->i_ino, 1); | 1015 | ino, 1); |
1015 | BUG_ON(ret); | 1016 | BUG_ON(ret); |
1016 | } | 1017 | } |
1017 | ret = insert_orphan_item(trans, root, inode->i_ino); | 1018 | ret = insert_orphan_item(trans, root, ino); |
1018 | BUG_ON(ret); | 1019 | BUG_ON(ret); |
1019 | } | 1020 | } |
1020 | btrfs_free_path(path); | 1021 | btrfs_free_path(path); |
@@ -2197,6 +2198,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, | |||
2197 | int ret; | 2198 | int ret; |
2198 | int err = 0; | 2199 | int err = 0; |
2199 | int bytes_del = 0; | 2200 | int bytes_del = 0; |
2201 | u64 dir_ino = btrfs_ino(dir); | ||
2200 | 2202 | ||
2201 | if (BTRFS_I(dir)->logged_trans < trans->transid) | 2203 | if (BTRFS_I(dir)->logged_trans < trans->transid) |
2202 | return 0; | 2204 | return 0; |
@@ -2214,7 +2216,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, | |||
2214 | goto out_unlock; | 2216 | goto out_unlock; |
2215 | } | 2217 | } |
2216 | 2218 | ||
2217 | di = btrfs_lookup_dir_item(trans, log, path, dir->i_ino, | 2219 | di = btrfs_lookup_dir_item(trans, log, path, dir_ino, |
2218 | name, name_len, -1); | 2220 | name, name_len, -1); |
2219 | if (IS_ERR(di)) { | 2221 | if (IS_ERR(di)) { |
2220 | err = PTR_ERR(di); | 2222 | err = PTR_ERR(di); |
@@ -2226,7 +2228,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, | |||
2226 | BUG_ON(ret); | 2228 | BUG_ON(ret); |
2227 | } | 2229 | } |
2228 | btrfs_release_path(path); | 2230 | btrfs_release_path(path); |
2229 | di = btrfs_lookup_dir_index_item(trans, log, path, dir->i_ino, | 2231 | di = btrfs_lookup_dir_index_item(trans, log, path, dir_ino, |
2230 | index, name, name_len, -1); | 2232 | index, name, name_len, -1); |
2231 | if (IS_ERR(di)) { | 2233 | if (IS_ERR(di)) { |
2232 | err = PTR_ERR(di); | 2234 | err = PTR_ERR(di); |
@@ -2244,7 +2246,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, | |||
2244 | if (bytes_del) { | 2246 | if (bytes_del) { |
2245 | struct btrfs_key key; | 2247 | struct btrfs_key key; |
2246 | 2248 | ||
2247 | key.objectid = dir->i_ino; | 2249 | key.objectid = dir_ino; |
2248 | key.offset = 0; | 2250 | key.offset = 0; |
2249 | key.type = BTRFS_INODE_ITEM_KEY; | 2251 | key.type = BTRFS_INODE_ITEM_KEY; |
2250 | btrfs_release_path(path); | 2252 | btrfs_release_path(path); |
@@ -2303,7 +2305,7 @@ int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans, | |||
2303 | log = root->log_root; | 2305 | log = root->log_root; |
2304 | mutex_lock(&BTRFS_I(inode)->log_mutex); | 2306 | mutex_lock(&BTRFS_I(inode)->log_mutex); |
2305 | 2307 | ||
2306 | ret = btrfs_del_inode_ref(trans, log, name, name_len, inode->i_ino, | 2308 | ret = btrfs_del_inode_ref(trans, log, name, name_len, btrfs_ino(inode), |
2307 | dirid, &index); | 2309 | dirid, &index); |
2308 | mutex_unlock(&BTRFS_I(inode)->log_mutex); | 2310 | mutex_unlock(&BTRFS_I(inode)->log_mutex); |
2309 | if (ret == -ENOSPC) { | 2311 | if (ret == -ENOSPC) { |
@@ -2369,13 +2371,14 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2369 | int nritems; | 2371 | int nritems; |
2370 | u64 first_offset = min_offset; | 2372 | u64 first_offset = min_offset; |
2371 | u64 last_offset = (u64)-1; | 2373 | u64 last_offset = (u64)-1; |
2374 | u64 ino = btrfs_ino(inode); | ||
2372 | 2375 | ||
2373 | log = root->log_root; | 2376 | log = root->log_root; |
2374 | max_key.objectid = inode->i_ino; | 2377 | max_key.objectid = ino; |
2375 | max_key.offset = (u64)-1; | 2378 | max_key.offset = (u64)-1; |
2376 | max_key.type = key_type; | 2379 | max_key.type = key_type; |
2377 | 2380 | ||
2378 | min_key.objectid = inode->i_ino; | 2381 | min_key.objectid = ino; |
2379 | min_key.type = key_type; | 2382 | min_key.type = key_type; |
2380 | min_key.offset = min_offset; | 2383 | min_key.offset = min_offset; |
2381 | 2384 | ||
@@ -2388,9 +2391,8 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2388 | * we didn't find anything from this transaction, see if there | 2391 | * we didn't find anything from this transaction, see if there |
2389 | * is anything at all | 2392 | * is anything at all |
2390 | */ | 2393 | */ |
2391 | if (ret != 0 || min_key.objectid != inode->i_ino || | 2394 | if (ret != 0 || min_key.objectid != ino || min_key.type != key_type) { |
2392 | min_key.type != key_type) { | 2395 | min_key.objectid = ino; |
2393 | min_key.objectid = inode->i_ino; | ||
2394 | min_key.type = key_type; | 2396 | min_key.type = key_type; |
2395 | min_key.offset = (u64)-1; | 2397 | min_key.offset = (u64)-1; |
2396 | btrfs_release_path(path); | 2398 | btrfs_release_path(path); |
@@ -2399,7 +2401,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2399 | btrfs_release_path(path); | 2401 | btrfs_release_path(path); |
2400 | return ret; | 2402 | return ret; |
2401 | } | 2403 | } |
2402 | ret = btrfs_previous_item(root, path, inode->i_ino, key_type); | 2404 | ret = btrfs_previous_item(root, path, ino, key_type); |
2403 | 2405 | ||
2404 | /* if ret == 0 there are items for this type, | 2406 | /* if ret == 0 there are items for this type, |
2405 | * create a range to tell us the last key of this type. | 2407 | * create a range to tell us the last key of this type. |
@@ -2417,7 +2419,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2417 | } | 2419 | } |
2418 | 2420 | ||
2419 | /* go backward to find any previous key */ | 2421 | /* go backward to find any previous key */ |
2420 | ret = btrfs_previous_item(root, path, inode->i_ino, key_type); | 2422 | ret = btrfs_previous_item(root, path, ino, key_type); |
2421 | if (ret == 0) { | 2423 | if (ret == 0) { |
2422 | struct btrfs_key tmp; | 2424 | struct btrfs_key tmp; |
2423 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); | 2425 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); |
@@ -2452,8 +2454,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2452 | for (i = path->slots[0]; i < nritems; i++) { | 2454 | for (i = path->slots[0]; i < nritems; i++) { |
2453 | btrfs_item_key_to_cpu(src, &min_key, i); | 2455 | btrfs_item_key_to_cpu(src, &min_key, i); |
2454 | 2456 | ||
2455 | if (min_key.objectid != inode->i_ino || | 2457 | if (min_key.objectid != ino || min_key.type != key_type) |
2456 | min_key.type != key_type) | ||
2457 | goto done; | 2458 | goto done; |
2458 | ret = overwrite_item(trans, log, dst_path, src, i, | 2459 | ret = overwrite_item(trans, log, dst_path, src, i, |
2459 | &min_key); | 2460 | &min_key); |
@@ -2474,7 +2475,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2474 | goto done; | 2475 | goto done; |
2475 | } | 2476 | } |
2476 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); | 2477 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); |
2477 | if (tmp.objectid != inode->i_ino || tmp.type != key_type) { | 2478 | if (tmp.objectid != ino || tmp.type != key_type) { |
2478 | last_offset = (u64)-1; | 2479 | last_offset = (u64)-1; |
2479 | goto done; | 2480 | goto done; |
2480 | } | 2481 | } |
@@ -2500,8 +2501,7 @@ done: | |||
2500 | * is valid | 2501 | * is valid |
2501 | */ | 2502 | */ |
2502 | ret = insert_dir_log_key(trans, log, path, key_type, | 2503 | ret = insert_dir_log_key(trans, log, path, key_type, |
2503 | inode->i_ino, first_offset, | 2504 | ino, first_offset, last_offset); |
2504 | last_offset); | ||
2505 | if (ret) | 2505 | if (ret) |
2506 | err = ret; | 2506 | err = ret; |
2507 | } | 2507 | } |
@@ -2745,6 +2745,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2745 | int nritems; | 2745 | int nritems; |
2746 | int ins_start_slot = 0; | 2746 | int ins_start_slot = 0; |
2747 | int ins_nr; | 2747 | int ins_nr; |
2748 | u64 ino = btrfs_ino(inode); | ||
2748 | 2749 | ||
2749 | log = root->log_root; | 2750 | log = root->log_root; |
2750 | 2751 | ||
@@ -2757,11 +2758,11 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2757 | return -ENOMEM; | 2758 | return -ENOMEM; |
2758 | } | 2759 | } |
2759 | 2760 | ||
2760 | min_key.objectid = inode->i_ino; | 2761 | min_key.objectid = ino; |
2761 | min_key.type = BTRFS_INODE_ITEM_KEY; | 2762 | min_key.type = BTRFS_INODE_ITEM_KEY; |
2762 | min_key.offset = 0; | 2763 | min_key.offset = 0; |
2763 | 2764 | ||
2764 | max_key.objectid = inode->i_ino; | 2765 | max_key.objectid = ino; |
2765 | 2766 | ||
2766 | /* today the code can only do partial logging of directories */ | 2767 | /* today the code can only do partial logging of directories */ |
2767 | if (!S_ISDIR(inode->i_mode)) | 2768 | if (!S_ISDIR(inode->i_mode)) |
@@ -2773,6 +2774,13 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2773 | max_key.type = (u8)-1; | 2774 | max_key.type = (u8)-1; |
2774 | max_key.offset = (u64)-1; | 2775 | max_key.offset = (u64)-1; |
2775 | 2776 | ||
2777 | ret = btrfs_commit_inode_delayed_items(trans, inode); | ||
2778 | if (ret) { | ||
2779 | btrfs_free_path(path); | ||
2780 | btrfs_free_path(dst_path); | ||
2781 | return ret; | ||
2782 | } | ||
2783 | |||
2776 | mutex_lock(&BTRFS_I(inode)->log_mutex); | 2784 | mutex_lock(&BTRFS_I(inode)->log_mutex); |
2777 | 2785 | ||
2778 | /* | 2786 | /* |
@@ -2784,8 +2792,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2784 | 2792 | ||
2785 | if (inode_only == LOG_INODE_EXISTS) | 2793 | if (inode_only == LOG_INODE_EXISTS) |
2786 | max_key_type = BTRFS_XATTR_ITEM_KEY; | 2794 | max_key_type = BTRFS_XATTR_ITEM_KEY; |
2787 | ret = drop_objectid_items(trans, log, path, | 2795 | ret = drop_objectid_items(trans, log, path, ino, max_key_type); |
2788 | inode->i_ino, max_key_type); | ||
2789 | } else { | 2796 | } else { |
2790 | ret = btrfs_truncate_inode_items(trans, log, inode, 0, 0); | 2797 | ret = btrfs_truncate_inode_items(trans, log, inode, 0, 0); |
2791 | } | 2798 | } |
@@ -2803,7 +2810,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2803 | break; | 2810 | break; |
2804 | again: | 2811 | again: |
2805 | /* note, ins_nr might be > 0 here, cleanup outside the loop */ | 2812 | /* note, ins_nr might be > 0 here, cleanup outside the loop */ |
2806 | if (min_key.objectid != inode->i_ino) | 2813 | if (min_key.objectid != ino) |
2807 | break; | 2814 | break; |
2808 | if (min_key.type > max_key.type) | 2815 | if (min_key.type > max_key.type) |
2809 | break; | 2816 | break; |
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 4ca88d1e18e..f3107e4b4d5 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -44,7 +44,7 @@ ssize_t __btrfs_getxattr(struct inode *inode, const char *name, | |||
44 | return -ENOMEM; | 44 | return -ENOMEM; |
45 | 45 | ||
46 | /* lookup the xattr by name */ | 46 | /* lookup the xattr by name */ |
47 | di = btrfs_lookup_xattr(NULL, root, path, inode->i_ino, name, | 47 | di = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode), name, |
48 | strlen(name), 0); | 48 | strlen(name), 0); |
49 | if (!di) { | 49 | if (!di) { |
50 | ret = -ENODATA; | 50 | ret = -ENODATA; |
@@ -103,7 +103,7 @@ static int do_setxattr(struct btrfs_trans_handle *trans, | |||
103 | return -ENOMEM; | 103 | return -ENOMEM; |
104 | 104 | ||
105 | /* first lets see if we already have this xattr */ | 105 | /* first lets see if we already have this xattr */ |
106 | di = btrfs_lookup_xattr(trans, root, path, inode->i_ino, name, | 106 | di = btrfs_lookup_xattr(trans, root, path, btrfs_ino(inode), name, |
107 | strlen(name), -1); | 107 | strlen(name), -1); |
108 | if (IS_ERR(di)) { | 108 | if (IS_ERR(di)) { |
109 | ret = PTR_ERR(di); | 109 | ret = PTR_ERR(di); |
@@ -136,7 +136,7 @@ static int do_setxattr(struct btrfs_trans_handle *trans, | |||
136 | } | 136 | } |
137 | 137 | ||
138 | /* ok we have to create a completely new xattr */ | 138 | /* ok we have to create a completely new xattr */ |
139 | ret = btrfs_insert_xattr_item(trans, root, path, inode->i_ino, | 139 | ret = btrfs_insert_xattr_item(trans, root, path, btrfs_ino(inode), |
140 | name, name_len, value, size); | 140 | name, name_len, value, size); |
141 | BUG_ON(ret); | 141 | BUG_ON(ret); |
142 | out: | 142 | out: |
@@ -190,7 +190,7 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
190 | * NOTE: we set key.offset = 0; because we want to start with the | 190 | * NOTE: we set key.offset = 0; because we want to start with the |
191 | * first xattr that we find and walk forward | 191 | * first xattr that we find and walk forward |
192 | */ | 192 | */ |
193 | key.objectid = inode->i_ino; | 193 | key.objectid = btrfs_ino(inode); |
194 | btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); | 194 | btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); |
195 | key.offset = 0; | 195 | key.offset = 0; |
196 | 196 | ||
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index e159c529fd2..38b8ab55492 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c | |||
@@ -775,6 +775,13 @@ get_more_pages: | |||
775 | ci->i_truncate_seq, | 775 | ci->i_truncate_seq, |
776 | ci->i_truncate_size, | 776 | ci->i_truncate_size, |
777 | &inode->i_mtime, true, 1, 0); | 777 | &inode->i_mtime, true, 1, 0); |
778 | |||
779 | if (!req) { | ||
780 | rc = -ENOMEM; | ||
781 | unlock_page(page); | ||
782 | break; | ||
783 | } | ||
784 | |||
778 | max_pages = req->r_num_pages; | 785 | max_pages = req->r_num_pages; |
779 | 786 | ||
780 | alloc_page_vec(fsc, req); | 787 | alloc_page_vec(fsc, req); |
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 5323c330bbf..2a5404c1c42 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -819,7 +819,7 @@ int __ceph_caps_used(struct ceph_inode_info *ci) | |||
819 | used |= CEPH_CAP_FILE_CACHE; | 819 | used |= CEPH_CAP_FILE_CACHE; |
820 | if (ci->i_wr_ref) | 820 | if (ci->i_wr_ref) |
821 | used |= CEPH_CAP_FILE_WR; | 821 | used |= CEPH_CAP_FILE_WR; |
822 | if (ci->i_wrbuffer_ref) | 822 | if (ci->i_wb_ref || ci->i_wrbuffer_ref) |
823 | used |= CEPH_CAP_FILE_BUFFER; | 823 | used |= CEPH_CAP_FILE_BUFFER; |
824 | return used; | 824 | return used; |
825 | } | 825 | } |
@@ -1331,10 +1331,11 @@ static void ceph_flush_snaps(struct ceph_inode_info *ci) | |||
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | /* | 1333 | /* |
1334 | * Mark caps dirty. If inode is newly dirty, add to the global dirty | 1334 | * Mark caps dirty. If inode is newly dirty, return the dirty flags. |
1335 | * list. | 1335 | * Caller is then responsible for calling __mark_inode_dirty with the |
1336 | * returned flags value. | ||
1336 | */ | 1337 | */ |
1337 | void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask) | 1338 | int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask) |
1338 | { | 1339 | { |
1339 | struct ceph_mds_client *mdsc = | 1340 | struct ceph_mds_client *mdsc = |
1340 | ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; | 1341 | ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; |
@@ -1357,7 +1358,7 @@ void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask) | |||
1357 | list_add(&ci->i_dirty_item, &mdsc->cap_dirty); | 1358 | list_add(&ci->i_dirty_item, &mdsc->cap_dirty); |
1358 | spin_unlock(&mdsc->cap_dirty_lock); | 1359 | spin_unlock(&mdsc->cap_dirty_lock); |
1359 | if (ci->i_flushing_caps == 0) { | 1360 | if (ci->i_flushing_caps == 0) { |
1360 | igrab(inode); | 1361 | ihold(inode); |
1361 | dirty |= I_DIRTY_SYNC; | 1362 | dirty |= I_DIRTY_SYNC; |
1362 | } | 1363 | } |
1363 | } | 1364 | } |
@@ -1365,9 +1366,8 @@ void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask) | |||
1365 | if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && | 1366 | if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && |
1366 | (mask & CEPH_CAP_FILE_BUFFER)) | 1367 | (mask & CEPH_CAP_FILE_BUFFER)) |
1367 | dirty |= I_DIRTY_DATASYNC; | 1368 | dirty |= I_DIRTY_DATASYNC; |
1368 | if (dirty) | ||
1369 | __mark_inode_dirty(inode, dirty); | ||
1370 | __cap_delay_requeue(mdsc, ci); | 1369 | __cap_delay_requeue(mdsc, ci); |
1370 | return dirty; | ||
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | /* | 1373 | /* |
@@ -1990,11 +1990,11 @@ static void __take_cap_refs(struct ceph_inode_info *ci, int got) | |||
1990 | if (got & CEPH_CAP_FILE_WR) | 1990 | if (got & CEPH_CAP_FILE_WR) |
1991 | ci->i_wr_ref++; | 1991 | ci->i_wr_ref++; |
1992 | if (got & CEPH_CAP_FILE_BUFFER) { | 1992 | if (got & CEPH_CAP_FILE_BUFFER) { |
1993 | if (ci->i_wrbuffer_ref == 0) | 1993 | if (ci->i_wb_ref == 0) |
1994 | igrab(&ci->vfs_inode); | 1994 | ihold(&ci->vfs_inode); |
1995 | ci->i_wrbuffer_ref++; | 1995 | ci->i_wb_ref++; |
1996 | dout("__take_cap_refs %p wrbuffer %d -> %d (?)\n", | 1996 | dout("__take_cap_refs %p wb %d -> %d (?)\n", |
1997 | &ci->vfs_inode, ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref); | 1997 | &ci->vfs_inode, ci->i_wb_ref-1, ci->i_wb_ref); |
1998 | } | 1998 | } |
1999 | } | 1999 | } |
2000 | 2000 | ||
@@ -2169,12 +2169,12 @@ void ceph_put_cap_refs(struct ceph_inode_info *ci, int had) | |||
2169 | if (--ci->i_rdcache_ref == 0) | 2169 | if (--ci->i_rdcache_ref == 0) |
2170 | last++; | 2170 | last++; |
2171 | if (had & CEPH_CAP_FILE_BUFFER) { | 2171 | if (had & CEPH_CAP_FILE_BUFFER) { |
2172 | if (--ci->i_wrbuffer_ref == 0) { | 2172 | if (--ci->i_wb_ref == 0) { |
2173 | last++; | 2173 | last++; |
2174 | put++; | 2174 | put++; |
2175 | } | 2175 | } |
2176 | dout("put_cap_refs %p wrbuffer %d -> %d (?)\n", | 2176 | dout("put_cap_refs %p wb %d -> %d (?)\n", |
2177 | inode, ci->i_wrbuffer_ref+1, ci->i_wrbuffer_ref); | 2177 | inode, ci->i_wb_ref+1, ci->i_wb_ref); |
2178 | } | 2178 | } |
2179 | if (had & CEPH_CAP_FILE_WR) | 2179 | if (had & CEPH_CAP_FILE_WR) |
2180 | if (--ci->i_wr_ref == 0) { | 2180 | if (--ci->i_wr_ref == 0) { |
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 159b512d5a2..203252d88d9 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -734,9 +734,12 @@ retry_snap: | |||
734 | } | 734 | } |
735 | } | 735 | } |
736 | if (ret >= 0) { | 736 | if (ret >= 0) { |
737 | int dirty; | ||
737 | spin_lock(&inode->i_lock); | 738 | spin_lock(&inode->i_lock); |
738 | __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR); | 739 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR); |
739 | spin_unlock(&inode->i_lock); | 740 | spin_unlock(&inode->i_lock); |
741 | if (dirty) | ||
742 | __mark_inode_dirty(inode, dirty); | ||
740 | } | 743 | } |
741 | 744 | ||
742 | out: | 745 | out: |
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index b54c97da1c4..70b6a4839c3 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -355,6 +355,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) | |||
355 | ci->i_rd_ref = 0; | 355 | ci->i_rd_ref = 0; |
356 | ci->i_rdcache_ref = 0; | 356 | ci->i_rdcache_ref = 0; |
357 | ci->i_wr_ref = 0; | 357 | ci->i_wr_ref = 0; |
358 | ci->i_wb_ref = 0; | ||
358 | ci->i_wrbuffer_ref = 0; | 359 | ci->i_wrbuffer_ref = 0; |
359 | ci->i_wrbuffer_ref_head = 0; | 360 | ci->i_wrbuffer_ref_head = 0; |
360 | ci->i_shared_gen = 0; | 361 | ci->i_shared_gen = 0; |
@@ -1567,6 +1568,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) | |||
1567 | int release = 0, dirtied = 0; | 1568 | int release = 0, dirtied = 0; |
1568 | int mask = 0; | 1569 | int mask = 0; |
1569 | int err = 0; | 1570 | int err = 0; |
1571 | int inode_dirty_flags = 0; | ||
1570 | 1572 | ||
1571 | if (ceph_snap(inode) != CEPH_NOSNAP) | 1573 | if (ceph_snap(inode) != CEPH_NOSNAP) |
1572 | return -EROFS; | 1574 | return -EROFS; |
@@ -1725,13 +1727,16 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) | |||
1725 | dout("setattr %p ATTR_FILE ... hrm!\n", inode); | 1727 | dout("setattr %p ATTR_FILE ... hrm!\n", inode); |
1726 | 1728 | ||
1727 | if (dirtied) { | 1729 | if (dirtied) { |
1728 | __ceph_mark_dirty_caps(ci, dirtied); | 1730 | inode_dirty_flags = __ceph_mark_dirty_caps(ci, dirtied); |
1729 | inode->i_ctime = CURRENT_TIME; | 1731 | inode->i_ctime = CURRENT_TIME; |
1730 | } | 1732 | } |
1731 | 1733 | ||
1732 | release &= issued; | 1734 | release &= issued; |
1733 | spin_unlock(&inode->i_lock); | 1735 | spin_unlock(&inode->i_lock); |
1734 | 1736 | ||
1737 | if (inode_dirty_flags) | ||
1738 | __mark_inode_dirty(inode, inode_dirty_flags); | ||
1739 | |||
1735 | if (mask) { | 1740 | if (mask) { |
1736 | req->r_inode = igrab(inode); | 1741 | req->r_inode = igrab(inode); |
1737 | req->r_inode_drop = release; | 1742 | req->r_inode_drop = release; |
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index f60b07b0feb..d0fae4ce9ba 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -3304,8 +3304,8 @@ static void con_put(struct ceph_connection *con) | |||
3304 | { | 3304 | { |
3305 | struct ceph_mds_session *s = con->private; | 3305 | struct ceph_mds_session *s = con->private; |
3306 | 3306 | ||
3307 | dout("mdsc con_put %p (%d)\n", s, atomic_read(&s->s_ref) - 1); | ||
3307 | ceph_put_mds_session(s); | 3308 | ceph_put_mds_session(s); |
3308 | dout("mdsc con_put %p (%d)\n", s, atomic_read(&s->s_ref)); | ||
3309 | } | 3309 | } |
3310 | 3310 | ||
3311 | /* | 3311 | /* |
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c index e86ec1155f8..24067d68a55 100644 --- a/fs/ceph/snap.c +++ b/fs/ceph/snap.c | |||
@@ -206,7 +206,7 @@ void ceph_put_snap_realm(struct ceph_mds_client *mdsc, | |||
206 | up_write(&mdsc->snap_rwsem); | 206 | up_write(&mdsc->snap_rwsem); |
207 | } else { | 207 | } else { |
208 | spin_lock(&mdsc->snap_empty_lock); | 208 | spin_lock(&mdsc->snap_empty_lock); |
209 | list_add(&mdsc->snap_empty, &realm->empty_item); | 209 | list_add(&realm->empty_item, &mdsc->snap_empty); |
210 | spin_unlock(&mdsc->snap_empty_lock); | 210 | spin_unlock(&mdsc->snap_empty_lock); |
211 | } | 211 | } |
212 | } | 212 | } |
diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 619fe719968..f5cabefa98d 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h | |||
@@ -293,7 +293,7 @@ struct ceph_inode_info { | |||
293 | 293 | ||
294 | /* held references to caps */ | 294 | /* held references to caps */ |
295 | int i_pin_ref; | 295 | int i_pin_ref; |
296 | int i_rd_ref, i_rdcache_ref, i_wr_ref; | 296 | int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref; |
297 | int i_wrbuffer_ref, i_wrbuffer_ref_head; | 297 | int i_wrbuffer_ref, i_wrbuffer_ref_head; |
298 | u32 i_shared_gen; /* increment each time we get FILE_SHARED */ | 298 | u32 i_shared_gen; /* increment each time we get FILE_SHARED */ |
299 | u32 i_rdcache_gen; /* incremented each time we get FILE_CACHE. */ | 299 | u32 i_rdcache_gen; /* incremented each time we get FILE_CACHE. */ |
@@ -506,7 +506,7 @@ static inline int __ceph_caps_dirty(struct ceph_inode_info *ci) | |||
506 | { | 506 | { |
507 | return ci->i_dirty_caps | ci->i_flushing_caps; | 507 | return ci->i_dirty_caps | ci->i_flushing_caps; |
508 | } | 508 | } |
509 | extern void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask); | 509 | extern int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask); |
510 | 510 | ||
511 | extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask); | 511 | extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask); |
512 | extern int __ceph_caps_used(struct ceph_inode_info *ci); | 512 | extern int __ceph_caps_used(struct ceph_inode_info *ci); |
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 8c9eba6ef9d..f2b62869618 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c | |||
@@ -703,6 +703,7 @@ int ceph_setxattr(struct dentry *dentry, const char *name, | |||
703 | struct ceph_inode_xattr *xattr = NULL; | 703 | struct ceph_inode_xattr *xattr = NULL; |
704 | int issued; | 704 | int issued; |
705 | int required_blob_size; | 705 | int required_blob_size; |
706 | int dirty; | ||
706 | 707 | ||
707 | if (ceph_snap(inode) != CEPH_NOSNAP) | 708 | if (ceph_snap(inode) != CEPH_NOSNAP) |
708 | return -EROFS; | 709 | return -EROFS; |
@@ -763,11 +764,12 @@ retry: | |||
763 | dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued)); | 764 | dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued)); |
764 | err = __set_xattr(ci, newname, name_len, newval, | 765 | err = __set_xattr(ci, newname, name_len, newval, |
765 | val_len, 1, 1, 1, &xattr); | 766 | val_len, 1, 1, 1, &xattr); |
766 | __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); | 767 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); |
767 | ci->i_xattrs.dirty = true; | 768 | ci->i_xattrs.dirty = true; |
768 | inode->i_ctime = CURRENT_TIME; | 769 | inode->i_ctime = CURRENT_TIME; |
769 | spin_unlock(&inode->i_lock); | 770 | spin_unlock(&inode->i_lock); |
770 | 771 | if (dirty) | |
772 | __mark_inode_dirty(inode, dirty); | ||
771 | return err; | 773 | return err; |
772 | 774 | ||
773 | do_sync: | 775 | do_sync: |
@@ -810,6 +812,7 @@ int ceph_removexattr(struct dentry *dentry, const char *name) | |||
810 | struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode); | 812 | struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode); |
811 | int issued; | 813 | int issued; |
812 | int err; | 814 | int err; |
815 | int dirty; | ||
813 | 816 | ||
814 | if (ceph_snap(inode) != CEPH_NOSNAP) | 817 | if (ceph_snap(inode) != CEPH_NOSNAP) |
815 | return -EROFS; | 818 | return -EROFS; |
@@ -833,12 +836,13 @@ int ceph_removexattr(struct dentry *dentry, const char *name) | |||
833 | goto do_sync; | 836 | goto do_sync; |
834 | 837 | ||
835 | err = __remove_xattr_by_name(ceph_inode(inode), name); | 838 | err = __remove_xattr_by_name(ceph_inode(inode), name); |
836 | __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); | 839 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); |
837 | ci->i_xattrs.dirty = true; | 840 | ci->i_xattrs.dirty = true; |
838 | inode->i_ctime = CURRENT_TIME; | 841 | inode->i_ctime = CURRENT_TIME; |
839 | 842 | ||
840 | spin_unlock(&inode->i_lock); | 843 | spin_unlock(&inode->i_lock); |
841 | 844 | if (dirty) | |
845 | __mark_inode_dirty(inode, dirty); | ||
842 | return err; | 846 | return err; |
843 | do_sync: | 847 | do_sync: |
844 | spin_unlock(&inode->i_lock); | 848 | spin_unlock(&inode->i_lock); |
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c index 23d43cde430..1b2e180b018 100644 --- a/fs/cifs/cifs_unicode.c +++ b/fs/cifs/cifs_unicode.c | |||
@@ -277,6 +277,7 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen, | |||
277 | 277 | ||
278 | for (i = 0, j = 0; i < srclen; j++) { | 278 | for (i = 0, j = 0; i < srclen; j++) { |
279 | src_char = source[i]; | 279 | src_char = source[i]; |
280 | charlen = 1; | ||
280 | switch (src_char) { | 281 | switch (src_char) { |
281 | case 0: | 282 | case 0: |
282 | put_unaligned(0, &target[j]); | 283 | put_unaligned(0, &target[j]); |
@@ -316,16 +317,13 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen, | |||
316 | dst_char = cpu_to_le16(0x003f); | 317 | dst_char = cpu_to_le16(0x003f); |
317 | charlen = 1; | 318 | charlen = 1; |
318 | } | 319 | } |
319 | /* | ||
320 | * character may take more than one byte in the source | ||
321 | * string, but will take exactly two bytes in the | ||
322 | * target string | ||
323 | */ | ||
324 | i += charlen; | ||
325 | continue; | ||
326 | } | 320 | } |
321 | /* | ||
322 | * character may take more than one byte in the source string, | ||
323 | * but will take exactly two bytes in the target string | ||
324 | */ | ||
325 | i += charlen; | ||
327 | put_unaligned(dst_char, &target[j]); | 326 | put_unaligned(dst_char, &target[j]); |
328 | i++; /* move to next char in source string */ | ||
329 | } | 327 | } |
330 | 328 | ||
331 | ctoUCS_out: | 329 | ctoUCS_out: |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 4bc862a80ef..277262a8e82 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -274,7 +274,8 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
274 | char *data_area_of_target; | 274 | char *data_area_of_target; |
275 | char *data_area_of_buf2; | 275 | char *data_area_of_buf2; |
276 | int remaining; | 276 | int remaining; |
277 | __u16 byte_count, total_data_size, total_in_buf, total_in_buf2; | 277 | unsigned int byte_count, total_in_buf; |
278 | __u16 total_data_size, total_in_buf2; | ||
278 | 279 | ||
279 | total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); | 280 | total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); |
280 | 281 | ||
@@ -287,7 +288,7 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
287 | remaining = total_data_size - total_in_buf; | 288 | remaining = total_data_size - total_in_buf; |
288 | 289 | ||
289 | if (remaining < 0) | 290 | if (remaining < 0) |
290 | return -EINVAL; | 291 | return -EPROTO; |
291 | 292 | ||
292 | if (remaining == 0) /* nothing to do, ignore */ | 293 | if (remaining == 0) /* nothing to do, ignore */ |
293 | return 0; | 294 | return 0; |
@@ -308,20 +309,29 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
308 | data_area_of_target += total_in_buf; | 309 | data_area_of_target += total_in_buf; |
309 | 310 | ||
310 | /* copy second buffer into end of first buffer */ | 311 | /* copy second buffer into end of first buffer */ |
311 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); | ||
312 | total_in_buf += total_in_buf2; | 312 | total_in_buf += total_in_buf2; |
313 | /* is the result too big for the field? */ | ||
314 | if (total_in_buf > USHRT_MAX) | ||
315 | return -EPROTO; | ||
313 | put_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount); | 316 | put_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount); |
317 | |||
318 | /* fix up the BCC */ | ||
314 | byte_count = get_bcc_le(pTargetSMB); | 319 | byte_count = get_bcc_le(pTargetSMB); |
315 | byte_count += total_in_buf2; | 320 | byte_count += total_in_buf2; |
321 | /* is the result too big for the field? */ | ||
322 | if (byte_count > USHRT_MAX) | ||
323 | return -EPROTO; | ||
316 | put_bcc_le(byte_count, pTargetSMB); | 324 | put_bcc_le(byte_count, pTargetSMB); |
317 | 325 | ||
318 | byte_count = pTargetSMB->smb_buf_length; | 326 | byte_count = pTargetSMB->smb_buf_length; |
319 | byte_count += total_in_buf2; | 327 | byte_count += total_in_buf2; |
320 | 328 | /* don't allow buffer to overflow */ | |
321 | /* BB also add check that we are not beyond maximum buffer size */ | 329 | if (byte_count > CIFSMaxBufSize) |
322 | 330 | return -ENOBUFS; | |
323 | pTargetSMB->smb_buf_length = byte_count; | 331 | pTargetSMB->smb_buf_length = byte_count; |
324 | 332 | ||
333 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); | ||
334 | |||
325 | if (remaining == total_in_buf2) { | 335 | if (remaining == total_in_buf2) { |
326 | cFYI(1, "found the last secondary response"); | 336 | cFYI(1, "found the last secondary response"); |
327 | return 0; /* we are done */ | 337 | return 0; /* we are done */ |
@@ -607,59 +617,63 @@ incomplete_rcv: | |||
607 | list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { | 617 | list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { |
608 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); | 618 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); |
609 | 619 | ||
610 | if ((mid_entry->mid == smb_buffer->Mid) && | 620 | if (mid_entry->mid != smb_buffer->Mid || |
611 | (mid_entry->midState == MID_REQUEST_SUBMITTED) && | 621 | mid_entry->midState != MID_REQUEST_SUBMITTED || |
612 | (mid_entry->command == smb_buffer->Command)) { | 622 | mid_entry->command != smb_buffer->Command) { |
613 | if (length == 0 && | 623 | mid_entry = NULL; |
614 | check2ndT2(smb_buffer, server->maxBuf) > 0) { | 624 | continue; |
615 | /* We have a multipart transact2 resp */ | 625 | } |
616 | isMultiRsp = true; | 626 | |
617 | if (mid_entry->resp_buf) { | 627 | if (length == 0 && |
618 | /* merge response - fix up 1st*/ | 628 | check2ndT2(smb_buffer, server->maxBuf) > 0) { |
619 | if (coalesce_t2(smb_buffer, | 629 | /* We have a multipart transact2 resp */ |
620 | mid_entry->resp_buf)) { | 630 | isMultiRsp = true; |
621 | mid_entry->multiRsp = | 631 | if (mid_entry->resp_buf) { |
622 | true; | 632 | /* merge response - fix up 1st*/ |
623 | break; | 633 | length = coalesce_t2(smb_buffer, |
624 | } else { | 634 | mid_entry->resp_buf); |
625 | /* all parts received */ | 635 | if (length > 0) { |
626 | mid_entry->multiEnd = | 636 | length = 0; |
627 | true; | 637 | mid_entry->multiRsp = true; |
628 | goto multi_t2_fnd; | 638 | break; |
629 | } | ||
630 | } else { | 639 | } else { |
631 | if (!isLargeBuf) { | 640 | /* all parts received or |
632 | cERROR(1, "1st trans2 resp needs bigbuf"); | 641 | * packet is malformed |
633 | /* BB maybe we can fix this up, switch | 642 | */ |
634 | to already allocated large buffer? */ | 643 | mid_entry->multiEnd = true; |
635 | } else { | 644 | goto multi_t2_fnd; |
636 | /* Have first buffer */ | 645 | } |
637 | mid_entry->resp_buf = | 646 | } else { |
638 | smb_buffer; | 647 | if (!isLargeBuf) { |
639 | mid_entry->largeBuf = | 648 | /* |
640 | true; | 649 | * FIXME: switch to already |
641 | bigbuf = NULL; | 650 | * allocated largebuf? |
642 | } | 651 | */ |
652 | cERROR(1, "1st trans2 resp " | ||
653 | "needs bigbuf"); | ||
654 | } else { | ||
655 | /* Have first buffer */ | ||
656 | mid_entry->resp_buf = | ||
657 | smb_buffer; | ||
658 | mid_entry->largeBuf = true; | ||
659 | bigbuf = NULL; | ||
643 | } | 660 | } |
644 | break; | ||
645 | } | 661 | } |
646 | mid_entry->resp_buf = smb_buffer; | 662 | break; |
647 | mid_entry->largeBuf = isLargeBuf; | 663 | } |
664 | mid_entry->resp_buf = smb_buffer; | ||
665 | mid_entry->largeBuf = isLargeBuf; | ||
648 | multi_t2_fnd: | 666 | multi_t2_fnd: |
649 | if (length == 0) | 667 | if (length == 0) |
650 | mid_entry->midState = | 668 | mid_entry->midState = MID_RESPONSE_RECEIVED; |
651 | MID_RESPONSE_RECEIVED; | 669 | else |
652 | else | 670 | mid_entry->midState = MID_RESPONSE_MALFORMED; |
653 | mid_entry->midState = | ||
654 | MID_RESPONSE_MALFORMED; | ||
655 | #ifdef CONFIG_CIFS_STATS2 | 671 | #ifdef CONFIG_CIFS_STATS2 |
656 | mid_entry->when_received = jiffies; | 672 | mid_entry->when_received = jiffies; |
657 | #endif | 673 | #endif |
658 | list_del_init(&mid_entry->qhead); | 674 | list_del_init(&mid_entry->qhead); |
659 | mid_entry->callback(mid_entry); | 675 | mid_entry->callback(mid_entry); |
660 | break; | 676 | break; |
661 | } | ||
662 | mid_entry = NULL; | ||
663 | } | 677 | } |
664 | spin_unlock(&GlobalMid_Lock); | 678 | spin_unlock(&GlobalMid_Lock); |
665 | 679 | ||
@@ -2659,6 +2673,11 @@ is_path_accessible(int xid, struct cifsTconInfo *tcon, | |||
2659 | 0 /* not legacy */, cifs_sb->local_nls, | 2673 | 0 /* not legacy */, cifs_sb->local_nls, |
2660 | cifs_sb->mnt_cifs_flags & | 2674 | cifs_sb->mnt_cifs_flags & |
2661 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 2675 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
2676 | |||
2677 | if (rc == -EOPNOTSUPP || rc == -EINVAL) | ||
2678 | rc = SMBQueryInformation(xid, tcon, full_path, pfile_info, | ||
2679 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & | ||
2680 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
2662 | kfree(pfile_info); | 2681 | kfree(pfile_info); |
2663 | return rc; | 2682 | return rc; |
2664 | } | 2683 | } |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index f6728eb6f4b..645114ad0a1 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -276,7 +276,7 @@ static void ascii_ssetup_strings(char **pbcc_area, struct cifsSesInfo *ses, | |||
276 | } | 276 | } |
277 | 277 | ||
278 | static void | 278 | static void |
279 | decode_unicode_ssetup(char **pbcc_area, __u16 bleft, struct cifsSesInfo *ses, | 279 | decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifsSesInfo *ses, |
280 | const struct nls_table *nls_cp) | 280 | const struct nls_table *nls_cp) |
281 | { | 281 | { |
282 | int len; | 282 | int len; |
@@ -284,19 +284,6 @@ decode_unicode_ssetup(char **pbcc_area, __u16 bleft, struct cifsSesInfo *ses, | |||
284 | 284 | ||
285 | cFYI(1, "bleft %d", bleft); | 285 | cFYI(1, "bleft %d", bleft); |
286 | 286 | ||
287 | /* | ||
288 | * Windows servers do not always double null terminate their final | ||
289 | * Unicode string. Check to see if there are an uneven number of bytes | ||
290 | * left. If so, then add an extra NULL pad byte to the end of the | ||
291 | * response. | ||
292 | * | ||
293 | * See section 2.7.2 in "Implementing CIFS" for details | ||
294 | */ | ||
295 | if (bleft % 2) { | ||
296 | data[bleft] = 0; | ||
297 | ++bleft; | ||
298 | } | ||
299 | |||
300 | kfree(ses->serverOS); | 287 | kfree(ses->serverOS); |
301 | ses->serverOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp); | 288 | ses->serverOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp); |
302 | cFYI(1, "serverOS=%s", ses->serverOS); | 289 | cFYI(1, "serverOS=%s", ses->serverOS); |
@@ -929,7 +916,9 @@ ssetup_ntlmssp_authenticate: | |||
929 | } | 916 | } |
930 | 917 | ||
931 | /* BB check if Unicode and decode strings */ | 918 | /* BB check if Unicode and decode strings */ |
932 | if (smb_buf->Flags2 & SMBFLG2_UNICODE) { | 919 | if (bytes_remaining == 0) { |
920 | /* no string area to decode, do nothing */ | ||
921 | } else if (smb_buf->Flags2 & SMBFLG2_UNICODE) { | ||
933 | /* unicode string area must be word-aligned */ | 922 | /* unicode string area must be word-aligned */ |
934 | if (((unsigned long) bcc_ptr - (unsigned long) smb_buf) % 2) { | 923 | if (((unsigned long) bcc_ptr - (unsigned long) smb_buf) % 2) { |
935 | ++bcc_ptr; | 924 | ++bcc_ptr; |
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 3313dd19f54..9a37a9b6de3 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -53,11 +53,14 @@ DEFINE_SPINLOCK(configfs_dirent_lock); | |||
53 | static void configfs_d_iput(struct dentry * dentry, | 53 | static void configfs_d_iput(struct dentry * dentry, |
54 | struct inode * inode) | 54 | struct inode * inode) |
55 | { | 55 | { |
56 | struct configfs_dirent * sd = dentry->d_fsdata; | 56 | struct configfs_dirent *sd = dentry->d_fsdata; |
57 | 57 | ||
58 | if (sd) { | 58 | if (sd) { |
59 | BUG_ON(sd->s_dentry != dentry); | 59 | BUG_ON(sd->s_dentry != dentry); |
60 | /* Coordinate with configfs_readdir */ | ||
61 | spin_lock(&configfs_dirent_lock); | ||
60 | sd->s_dentry = NULL; | 62 | sd->s_dentry = NULL; |
63 | spin_unlock(&configfs_dirent_lock); | ||
61 | configfs_put(sd); | 64 | configfs_put(sd); |
62 | } | 65 | } |
63 | iput(inode); | 66 | iput(inode); |
@@ -689,7 +692,8 @@ static int create_default_group(struct config_group *parent_group, | |||
689 | sd = child->d_fsdata; | 692 | sd = child->d_fsdata; |
690 | sd->s_type |= CONFIGFS_USET_DEFAULT; | 693 | sd->s_type |= CONFIGFS_USET_DEFAULT; |
691 | } else { | 694 | } else { |
692 | d_delete(child); | 695 | BUG_ON(child->d_inode); |
696 | d_drop(child); | ||
693 | dput(child); | 697 | dput(child); |
694 | } | 698 | } |
695 | } | 699 | } |
@@ -1545,7 +1549,7 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir | |||
1545 | struct configfs_dirent * parent_sd = dentry->d_fsdata; | 1549 | struct configfs_dirent * parent_sd = dentry->d_fsdata; |
1546 | struct configfs_dirent *cursor = filp->private_data; | 1550 | struct configfs_dirent *cursor = filp->private_data; |
1547 | struct list_head *p, *q = &cursor->s_sibling; | 1551 | struct list_head *p, *q = &cursor->s_sibling; |
1548 | ino_t ino; | 1552 | ino_t ino = 0; |
1549 | int i = filp->f_pos; | 1553 | int i = filp->f_pos; |
1550 | 1554 | ||
1551 | switch (i) { | 1555 | switch (i) { |
@@ -1573,6 +1577,7 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir | |||
1573 | struct configfs_dirent *next; | 1577 | struct configfs_dirent *next; |
1574 | const char * name; | 1578 | const char * name; |
1575 | int len; | 1579 | int len; |
1580 | struct inode *inode = NULL; | ||
1576 | 1581 | ||
1577 | next = list_entry(p, struct configfs_dirent, | 1582 | next = list_entry(p, struct configfs_dirent, |
1578 | s_sibling); | 1583 | s_sibling); |
@@ -1581,9 +1586,28 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir | |||
1581 | 1586 | ||
1582 | name = configfs_get_name(next); | 1587 | name = configfs_get_name(next); |
1583 | len = strlen(name); | 1588 | len = strlen(name); |
1584 | if (next->s_dentry) | 1589 | |
1585 | ino = next->s_dentry->d_inode->i_ino; | 1590 | /* |
1586 | else | 1591 | * We'll have a dentry and an inode for |
1592 | * PINNED items and for open attribute | ||
1593 | * files. We lock here to prevent a race | ||
1594 | * with configfs_d_iput() clearing | ||
1595 | * s_dentry before calling iput(). | ||
1596 | * | ||
1597 | * Why do we go to the trouble? If | ||
1598 | * someone has an attribute file open, | ||
1599 | * the inode number should match until | ||
1600 | * they close it. Beyond that, we don't | ||
1601 | * care. | ||
1602 | */ | ||
1603 | spin_lock(&configfs_dirent_lock); | ||
1604 | dentry = next->s_dentry; | ||
1605 | if (dentry) | ||
1606 | inode = dentry->d_inode; | ||
1607 | if (inode) | ||
1608 | ino = inode->i_ino; | ||
1609 | spin_unlock(&configfs_dirent_lock); | ||
1610 | if (!inode) | ||
1587 | ino = iunique(configfs_sb, 2); | 1611 | ino = iunique(configfs_sb, 2); |
1588 | 1612 | ||
1589 | if (filldir(dirent, name, len, filp->f_pos, ino, | 1613 | if (filldir(dirent, name, len, filp->f_pos, ino, |
@@ -1683,7 +1707,8 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) | |||
1683 | err = configfs_attach_group(sd->s_element, &group->cg_item, | 1707 | err = configfs_attach_group(sd->s_element, &group->cg_item, |
1684 | dentry); | 1708 | dentry); |
1685 | if (err) { | 1709 | if (err) { |
1686 | d_delete(dentry); | 1710 | BUG_ON(dentry->d_inode); |
1711 | d_drop(dentry); | ||
1687 | dput(dentry); | 1712 | dput(dentry); |
1688 | } else { | 1713 | } else { |
1689 | spin_lock(&configfs_dirent_lock); | 1714 | spin_lock(&configfs_dirent_lock); |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index c6ba49bd95b..b32eb29a4e6 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -174,7 +174,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) | |||
174 | if (!inode) | 174 | if (!inode) |
175 | return 0; | 175 | return 0; |
176 | 176 | ||
177 | if (nd->flags & LOOKUP_RCU) | 177 | if (nd && (nd->flags & LOOKUP_RCU)) |
178 | return -ECHILD; | 178 | return -ECHILD; |
179 | 179 | ||
180 | fc = get_fuse_conn(inode); | 180 | fc = get_fuse_conn(inode); |
diff --git a/fs/hpfs/Kconfig b/fs/hpfs/Kconfig index 0c39dc3ef7d..56bd15c5bf6 100644 --- a/fs/hpfs/Kconfig +++ b/fs/hpfs/Kconfig | |||
@@ -1,7 +1,6 @@ | |||
1 | config HPFS_FS | 1 | config HPFS_FS |
2 | tristate "OS/2 HPFS file system support" | 2 | tristate "OS/2 HPFS file system support" |
3 | depends on BLOCK | 3 | depends on BLOCK |
4 | depends on BROKEN || !PREEMPT | ||
5 | help | 4 | help |
6 | OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS | 5 | OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS |
7 | is the file system used for organizing files on OS/2 hard disk | 6 | is the file system used for organizing files on OS/2 hard disk |
diff --git a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c index 5503e2c2891..7a5eb2c718c 100644 --- a/fs/hpfs/alloc.c +++ b/fs/hpfs/alloc.c | |||
@@ -8,8 +8,6 @@ | |||
8 | 8 | ||
9 | #include "hpfs_fn.h" | 9 | #include "hpfs_fn.h" |
10 | 10 | ||
11 | static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec); | ||
12 | |||
13 | /* | 11 | /* |
14 | * Check if a sector is allocated in bitmap | 12 | * Check if a sector is allocated in bitmap |
15 | * This is really slow. Turned on only if chk==2 | 13 | * This is really slow. Turned on only if chk==2 |
@@ -18,9 +16,9 @@ static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec); | |||
18 | static int chk_if_allocated(struct super_block *s, secno sec, char *msg) | 16 | static int chk_if_allocated(struct super_block *s, secno sec, char *msg) |
19 | { | 17 | { |
20 | struct quad_buffer_head qbh; | 18 | struct quad_buffer_head qbh; |
21 | unsigned *bmp; | 19 | u32 *bmp; |
22 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "chk"))) goto fail; | 20 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "chk"))) goto fail; |
23 | if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f)) & 1) { | 21 | if ((cpu_to_le32(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f)) & 1) { |
24 | hpfs_error(s, "sector '%s' - %08x not allocated in bitmap", msg, sec); | 22 | hpfs_error(s, "sector '%s' - %08x not allocated in bitmap", msg, sec); |
25 | goto fail1; | 23 | goto fail1; |
26 | } | 24 | } |
@@ -28,7 +26,7 @@ static int chk_if_allocated(struct super_block *s, secno sec, char *msg) | |||
28 | if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) { | 26 | if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) { |
29 | unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4; | 27 | unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4; |
30 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto fail; | 28 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto fail; |
31 | if ((bmp[ssec >> 5] >> (ssec & 0x1f)) & 1) { | 29 | if ((le32_to_cpu(bmp[ssec >> 5]) >> (ssec & 0x1f)) & 1) { |
32 | hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec); | 30 | hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec); |
33 | goto fail1; | 31 | goto fail1; |
34 | } | 32 | } |
@@ -75,7 +73,6 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
75 | hpfs_error(s, "Bad allocation size: %d", n); | 73 | hpfs_error(s, "Bad allocation size: %d", n); |
76 | return 0; | 74 | return 0; |
77 | } | 75 | } |
78 | lock_super(s); | ||
79 | if (bs != ~0x3fff) { | 76 | if (bs != ~0x3fff) { |
80 | if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; | 77 | if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; |
81 | } else { | 78 | } else { |
@@ -85,10 +82,6 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
85 | ret = bs + nr; | 82 | ret = bs + nr; |
86 | goto rt; | 83 | goto rt; |
87 | } | 84 | } |
88 | /*if (!tstbits(bmp, nr + n, n + forward)) { | ||
89 | ret = bs + nr + n; | ||
90 | goto rt; | ||
91 | }*/ | ||
92 | q = nr + n; b = 0; | 85 | q = nr + n; b = 0; |
93 | while ((a = tstbits(bmp, q, n + forward)) != 0) { | 86 | while ((a = tstbits(bmp, q, n + forward)) != 0) { |
94 | q += a; | 87 | q += a; |
@@ -105,14 +98,14 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
105 | goto rt; | 98 | goto rt; |
106 | } | 99 | } |
107 | nr >>= 5; | 100 | nr >>= 5; |
108 | /*for (i = nr + 1; i != nr; i++, i &= 0x1ff) {*/ | 101 | /*for (i = nr + 1; i != nr; i++, i &= 0x1ff) */ |
109 | i = nr; | 102 | i = nr; |
110 | do { | 103 | do { |
111 | if (!bmp[i]) goto cont; | 104 | if (!le32_to_cpu(bmp[i])) goto cont; |
112 | if (n + forward >= 0x3f && bmp[i] != -1) goto cont; | 105 | if (n + forward >= 0x3f && le32_to_cpu(bmp[i]) != 0xffffffff) goto cont; |
113 | q = i<<5; | 106 | q = i<<5; |
114 | if (i > 0) { | 107 | if (i > 0) { |
115 | unsigned k = bmp[i-1]; | 108 | unsigned k = le32_to_cpu(bmp[i-1]); |
116 | while (k & 0x80000000) { | 109 | while (k & 0x80000000) { |
117 | q--; k <<= 1; | 110 | q--; k <<= 1; |
118 | } | 111 | } |
@@ -132,18 +125,17 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
132 | } while (i != nr); | 125 | } while (i != nr); |
133 | rt: | 126 | rt: |
134 | if (ret) { | 127 | if (ret) { |
135 | if (hpfs_sb(s)->sb_chk && ((ret >> 14) != (bs >> 14) || (bmp[(ret & 0x3fff) >> 5] | ~(((1 << n) - 1) << (ret & 0x1f))) != 0xffffffff)) { | 128 | if (hpfs_sb(s)->sb_chk && ((ret >> 14) != (bs >> 14) || (le32_to_cpu(bmp[(ret & 0x3fff) >> 5]) | ~(((1 << n) - 1) << (ret & 0x1f))) != 0xffffffff)) { |
136 | hpfs_error(s, "Allocation doesn't work! Wanted %d, allocated at %08x", n, ret); | 129 | hpfs_error(s, "Allocation doesn't work! Wanted %d, allocated at %08x", n, ret); |
137 | ret = 0; | 130 | ret = 0; |
138 | goto b; | 131 | goto b; |
139 | } | 132 | } |
140 | bmp[(ret & 0x3fff) >> 5] &= ~(((1 << n) - 1) << (ret & 0x1f)); | 133 | bmp[(ret & 0x3fff) >> 5] &= cpu_to_le32(~(((1 << n) - 1) << (ret & 0x1f))); |
141 | hpfs_mark_4buffers_dirty(&qbh); | 134 | hpfs_mark_4buffers_dirty(&qbh); |
142 | } | 135 | } |
143 | b: | 136 | b: |
144 | hpfs_brelse4(&qbh); | 137 | hpfs_brelse4(&qbh); |
145 | uls: | 138 | uls: |
146 | unlock_super(s); | ||
147 | return ret; | 139 | return ret; |
148 | } | 140 | } |
149 | 141 | ||
@@ -155,7 +147,7 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
155 | * sectors | 147 | * sectors |
156 | */ | 148 | */ |
157 | 149 | ||
158 | secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward, int lock) | 150 | secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward) |
159 | { | 151 | { |
160 | secno sec; | 152 | secno sec; |
161 | int i; | 153 | int i; |
@@ -167,7 +159,6 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa | |||
167 | forward = -forward; | 159 | forward = -forward; |
168 | f_p = 1; | 160 | f_p = 1; |
169 | } | 161 | } |
170 | if (lock) hpfs_lock_creation(s); | ||
171 | n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14; | 162 | n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14; |
172 | if (near && near < sbi->sb_fs_size) { | 163 | if (near && near < sbi->sb_fs_size) { |
173 | if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; | 164 | if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; |
@@ -214,18 +205,17 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa | |||
214 | ret: | 205 | ret: |
215 | if (sec && f_p) { | 206 | if (sec && f_p) { |
216 | for (i = 0; i < forward; i++) { | 207 | for (i = 0; i < forward; i++) { |
217 | if (!hpfs_alloc_if_possible_nolock(s, sec + i + 1)) { | 208 | if (!hpfs_alloc_if_possible(s, sec + i + 1)) { |
218 | hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i); | 209 | hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i); |
219 | sec = 0; | 210 | sec = 0; |
220 | break; | 211 | break; |
221 | } | 212 | } |
222 | } | 213 | } |
223 | } | 214 | } |
224 | if (lock) hpfs_unlock_creation(s); | ||
225 | return sec; | 215 | return sec; |
226 | } | 216 | } |
227 | 217 | ||
228 | static secno alloc_in_dirband(struct super_block *s, secno near, int lock) | 218 | static secno alloc_in_dirband(struct super_block *s, secno near) |
229 | { | 219 | { |
230 | unsigned nr = near; | 220 | unsigned nr = near; |
231 | secno sec; | 221 | secno sec; |
@@ -236,49 +226,35 @@ static secno alloc_in_dirband(struct super_block *s, secno near, int lock) | |||
236 | nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4; | 226 | nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4; |
237 | nr -= sbi->sb_dirband_start; | 227 | nr -= sbi->sb_dirband_start; |
238 | nr >>= 2; | 228 | nr >>= 2; |
239 | if (lock) hpfs_lock_creation(s); | ||
240 | sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); | 229 | sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); |
241 | if (lock) hpfs_unlock_creation(s); | ||
242 | if (!sec) return 0; | 230 | if (!sec) return 0; |
243 | return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start; | 231 | return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start; |
244 | } | 232 | } |
245 | 233 | ||
246 | /* Alloc sector if it's free */ | 234 | /* Alloc sector if it's free */ |
247 | 235 | ||
248 | static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec) | 236 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) |
249 | { | 237 | { |
250 | struct quad_buffer_head qbh; | 238 | struct quad_buffer_head qbh; |
251 | unsigned *bmp; | 239 | u32 *bmp; |
252 | lock_super(s); | ||
253 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; | 240 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; |
254 | if (bmp[(sec & 0x3fff) >> 5] & (1 << (sec & 0x1f))) { | 241 | if (le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) & (1 << (sec & 0x1f))) { |
255 | bmp[(sec & 0x3fff) >> 5] &= ~(1 << (sec & 0x1f)); | 242 | bmp[(sec & 0x3fff) >> 5] &= cpu_to_le32(~(1 << (sec & 0x1f))); |
256 | hpfs_mark_4buffers_dirty(&qbh); | 243 | hpfs_mark_4buffers_dirty(&qbh); |
257 | hpfs_brelse4(&qbh); | 244 | hpfs_brelse4(&qbh); |
258 | unlock_super(s); | ||
259 | return 1; | 245 | return 1; |
260 | } | 246 | } |
261 | hpfs_brelse4(&qbh); | 247 | hpfs_brelse4(&qbh); |
262 | end: | 248 | end: |
263 | unlock_super(s); | ||
264 | return 0; | 249 | return 0; |
265 | } | 250 | } |
266 | 251 | ||
267 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) | ||
268 | { | ||
269 | int r; | ||
270 | hpfs_lock_creation(s); | ||
271 | r = hpfs_alloc_if_possible_nolock(s, sec); | ||
272 | hpfs_unlock_creation(s); | ||
273 | return r; | ||
274 | } | ||
275 | |||
276 | /* Free sectors in bitmaps */ | 252 | /* Free sectors in bitmaps */ |
277 | 253 | ||
278 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | 254 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) |
279 | { | 255 | { |
280 | struct quad_buffer_head qbh; | 256 | struct quad_buffer_head qbh; |
281 | unsigned *bmp; | 257 | u32 *bmp; |
282 | struct hpfs_sb_info *sbi = hpfs_sb(s); | 258 | struct hpfs_sb_info *sbi = hpfs_sb(s); |
283 | /*printk("2 - ");*/ | 259 | /*printk("2 - ");*/ |
284 | if (!n) return; | 260 | if (!n) return; |
@@ -286,26 +262,22 @@ void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | |||
286 | hpfs_error(s, "Trying to free reserved sector %08x", sec); | 262 | hpfs_error(s, "Trying to free reserved sector %08x", sec); |
287 | return; | 263 | return; |
288 | } | 264 | } |
289 | lock_super(s); | ||
290 | sbi->sb_max_fwd_alloc += n > 0xffff ? 0xffff : n; | 265 | sbi->sb_max_fwd_alloc += n > 0xffff ? 0xffff : n; |
291 | if (sbi->sb_max_fwd_alloc > 0xffffff) sbi->sb_max_fwd_alloc = 0xffffff; | 266 | if (sbi->sb_max_fwd_alloc > 0xffffff) sbi->sb_max_fwd_alloc = 0xffffff; |
292 | new_map: | 267 | new_map: |
293 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { | 268 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { |
294 | unlock_super(s); | ||
295 | return; | 269 | return; |
296 | } | 270 | } |
297 | new_tst: | 271 | new_tst: |
298 | if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f) & 1)) { | 272 | if ((le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f) & 1)) { |
299 | hpfs_error(s, "sector %08x not allocated", sec); | 273 | hpfs_error(s, "sector %08x not allocated", sec); |
300 | hpfs_brelse4(&qbh); | 274 | hpfs_brelse4(&qbh); |
301 | unlock_super(s); | ||
302 | return; | 275 | return; |
303 | } | 276 | } |
304 | bmp[(sec & 0x3fff) >> 5] |= 1 << (sec & 0x1f); | 277 | bmp[(sec & 0x3fff) >> 5] |= cpu_to_le32(1 << (sec & 0x1f)); |
305 | if (!--n) { | 278 | if (!--n) { |
306 | hpfs_mark_4buffers_dirty(&qbh); | 279 | hpfs_mark_4buffers_dirty(&qbh); |
307 | hpfs_brelse4(&qbh); | 280 | hpfs_brelse4(&qbh); |
308 | unlock_super(s); | ||
309 | return; | 281 | return; |
310 | } | 282 | } |
311 | if (!(++sec & 0x3fff)) { | 283 | if (!(++sec & 0x3fff)) { |
@@ -327,13 +299,13 @@ int hpfs_check_free_dnodes(struct super_block *s, int n) | |||
327 | int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14; | 299 | int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14; |
328 | int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff; | 300 | int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff; |
329 | int i, j; | 301 | int i, j; |
330 | unsigned *bmp; | 302 | u32 *bmp; |
331 | struct quad_buffer_head qbh; | 303 | struct quad_buffer_head qbh; |
332 | if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) { | 304 | if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) { |
333 | for (j = 0; j < 512; j++) { | 305 | for (j = 0; j < 512; j++) { |
334 | unsigned k; | 306 | unsigned k; |
335 | if (!bmp[j]) continue; | 307 | if (!le32_to_cpu(bmp[j])) continue; |
336 | for (k = bmp[j]; k; k >>= 1) if (k & 1) if (!--n) { | 308 | for (k = le32_to_cpu(bmp[j]); k; k >>= 1) if (k & 1) if (!--n) { |
337 | hpfs_brelse4(&qbh); | 309 | hpfs_brelse4(&qbh); |
338 | return 0; | 310 | return 0; |
339 | } | 311 | } |
@@ -352,10 +324,10 @@ int hpfs_check_free_dnodes(struct super_block *s, int n) | |||
352 | chk_bmp: | 324 | chk_bmp: |
353 | if (bmp) { | 325 | if (bmp) { |
354 | for (j = 0; j < 512; j++) { | 326 | for (j = 0; j < 512; j++) { |
355 | unsigned k; | 327 | u32 k; |
356 | if (!bmp[j]) continue; | 328 | if (!le32_to_cpu(bmp[j])) continue; |
357 | for (k = 0xf; k; k <<= 4) | 329 | for (k = 0xf; k; k <<= 4) |
358 | if ((bmp[j] & k) == k) { | 330 | if ((le32_to_cpu(bmp[j]) & k) == k) { |
359 | if (!--n) { | 331 | if (!--n) { |
360 | hpfs_brelse4(&qbh); | 332 | hpfs_brelse4(&qbh); |
361 | return 0; | 333 | return 0; |
@@ -379,44 +351,40 @@ void hpfs_free_dnode(struct super_block *s, dnode_secno dno) | |||
379 | hpfs_free_sectors(s, dno, 4); | 351 | hpfs_free_sectors(s, dno, 4); |
380 | } else { | 352 | } else { |
381 | struct quad_buffer_head qbh; | 353 | struct quad_buffer_head qbh; |
382 | unsigned *bmp; | 354 | u32 *bmp; |
383 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; | 355 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; |
384 | lock_super(s); | ||
385 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { | 356 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { |
386 | unlock_super(s); | ||
387 | return; | 357 | return; |
388 | } | 358 | } |
389 | bmp[ssec >> 5] |= 1 << (ssec & 0x1f); | 359 | bmp[ssec >> 5] |= cpu_to_le32(1 << (ssec & 0x1f)); |
390 | hpfs_mark_4buffers_dirty(&qbh); | 360 | hpfs_mark_4buffers_dirty(&qbh); |
391 | hpfs_brelse4(&qbh); | 361 | hpfs_brelse4(&qbh); |
392 | unlock_super(s); | ||
393 | } | 362 | } |
394 | } | 363 | } |
395 | 364 | ||
396 | struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, | 365 | struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, |
397 | dnode_secno *dno, struct quad_buffer_head *qbh, | 366 | dnode_secno *dno, struct quad_buffer_head *qbh) |
398 | int lock) | ||
399 | { | 367 | { |
400 | struct dnode *d; | 368 | struct dnode *d; |
401 | if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) { | 369 | if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) { |
402 | if (!(*dno = alloc_in_dirband(s, near, lock))) | 370 | if (!(*dno = alloc_in_dirband(s, near))) |
403 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) return NULL; | 371 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) return NULL; |
404 | } else { | 372 | } else { |
405 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) | 373 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) |
406 | if (!(*dno = alloc_in_dirband(s, near, lock))) return NULL; | 374 | if (!(*dno = alloc_in_dirband(s, near))) return NULL; |
407 | } | 375 | } |
408 | if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { | 376 | if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { |
409 | hpfs_free_dnode(s, *dno); | 377 | hpfs_free_dnode(s, *dno); |
410 | return NULL; | 378 | return NULL; |
411 | } | 379 | } |
412 | memset(d, 0, 2048); | 380 | memset(d, 0, 2048); |
413 | d->magic = DNODE_MAGIC; | 381 | d->magic = cpu_to_le32(DNODE_MAGIC); |
414 | d->first_free = 52; | 382 | d->first_free = cpu_to_le32(52); |
415 | d->dirent[0] = 32; | 383 | d->dirent[0] = 32; |
416 | d->dirent[2] = 8; | 384 | d->dirent[2] = 8; |
417 | d->dirent[30] = 1; | 385 | d->dirent[30] = 1; |
418 | d->dirent[31] = 255; | 386 | d->dirent[31] = 255; |
419 | d->self = *dno; | 387 | d->self = cpu_to_le32(*dno); |
420 | return d; | 388 | return d; |
421 | } | 389 | } |
422 | 390 | ||
@@ -424,16 +392,16 @@ struct fnode *hpfs_alloc_fnode(struct super_block *s, secno near, fnode_secno *f | |||
424 | struct buffer_head **bh) | 392 | struct buffer_head **bh) |
425 | { | 393 | { |
426 | struct fnode *f; | 394 | struct fnode *f; |
427 | if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD, 1))) return NULL; | 395 | if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD))) return NULL; |
428 | if (!(f = hpfs_get_sector(s, *fno, bh))) { | 396 | if (!(f = hpfs_get_sector(s, *fno, bh))) { |
429 | hpfs_free_sectors(s, *fno, 1); | 397 | hpfs_free_sectors(s, *fno, 1); |
430 | return NULL; | 398 | return NULL; |
431 | } | 399 | } |
432 | memset(f, 0, 512); | 400 | memset(f, 0, 512); |
433 | f->magic = FNODE_MAGIC; | 401 | f->magic = cpu_to_le32(FNODE_MAGIC); |
434 | f->ea_offs = 0xc4; | 402 | f->ea_offs = cpu_to_le16(0xc4); |
435 | f->btree.n_free_nodes = 8; | 403 | f->btree.n_free_nodes = 8; |
436 | f->btree.first_free = 8; | 404 | f->btree.first_free = cpu_to_le16(8); |
437 | return f; | 405 | return f; |
438 | } | 406 | } |
439 | 407 | ||
@@ -441,16 +409,16 @@ struct anode *hpfs_alloc_anode(struct super_block *s, secno near, anode_secno *a | |||
441 | struct buffer_head **bh) | 409 | struct buffer_head **bh) |
442 | { | 410 | { |
443 | struct anode *a; | 411 | struct anode *a; |
444 | if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD, 1))) return NULL; | 412 | if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD))) return NULL; |
445 | if (!(a = hpfs_get_sector(s, *ano, bh))) { | 413 | if (!(a = hpfs_get_sector(s, *ano, bh))) { |
446 | hpfs_free_sectors(s, *ano, 1); | 414 | hpfs_free_sectors(s, *ano, 1); |
447 | return NULL; | 415 | return NULL; |
448 | } | 416 | } |
449 | memset(a, 0, 512); | 417 | memset(a, 0, 512); |
450 | a->magic = ANODE_MAGIC; | 418 | a->magic = cpu_to_le32(ANODE_MAGIC); |
451 | a->self = *ano; | 419 | a->self = cpu_to_le32(*ano); |
452 | a->btree.n_free_nodes = 40; | 420 | a->btree.n_free_nodes = 40; |
453 | a->btree.n_used_nodes = 0; | 421 | a->btree.n_used_nodes = 0; |
454 | a->btree.first_free = 8; | 422 | a->btree.first_free = cpu_to_le16(8); |
455 | return a; | 423 | return a; |
456 | } | 424 | } |
diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c index 6a2f04bf3df..08b503e8ed2 100644 --- a/fs/hpfs/anode.c +++ b/fs/hpfs/anode.c | |||
@@ -22,8 +22,8 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode, | |||
22 | if (hpfs_sb(s)->sb_chk) if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_bplus_lookup")) return -1; | 22 | if (hpfs_sb(s)->sb_chk) if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_bplus_lookup")) return -1; |
23 | if (btree->internal) { | 23 | if (btree->internal) { |
24 | for (i = 0; i < btree->n_used_nodes; i++) | 24 | for (i = 0; i < btree->n_used_nodes; i++) |
25 | if (btree->u.internal[i].file_secno > sec) { | 25 | if (le32_to_cpu(btree->u.internal[i].file_secno) > sec) { |
26 | a = btree->u.internal[i].down; | 26 | a = le32_to_cpu(btree->u.internal[i].down); |
27 | brelse(bh); | 27 | brelse(bh); |
28 | if (!(anode = hpfs_map_anode(s, a, &bh))) return -1; | 28 | if (!(anode = hpfs_map_anode(s, a, &bh))) return -1; |
29 | btree = &anode->btree; | 29 | btree = &anode->btree; |
@@ -34,18 +34,18 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode, | |||
34 | return -1; | 34 | return -1; |
35 | } | 35 | } |
36 | for (i = 0; i < btree->n_used_nodes; i++) | 36 | for (i = 0; i < btree->n_used_nodes; i++) |
37 | if (btree->u.external[i].file_secno <= sec && | 37 | if (le32_to_cpu(btree->u.external[i].file_secno) <= sec && |
38 | btree->u.external[i].file_secno + btree->u.external[i].length > sec) { | 38 | le32_to_cpu(btree->u.external[i].file_secno) + le32_to_cpu(btree->u.external[i].length) > sec) { |
39 | a = btree->u.external[i].disk_secno + sec - btree->u.external[i].file_secno; | 39 | a = le32_to_cpu(btree->u.external[i].disk_secno) + sec - le32_to_cpu(btree->u.external[i].file_secno); |
40 | if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, a, 1, "data")) { | 40 | if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, a, 1, "data")) { |
41 | brelse(bh); | 41 | brelse(bh); |
42 | return -1; | 42 | return -1; |
43 | } | 43 | } |
44 | if (inode) { | 44 | if (inode) { |
45 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); | 45 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); |
46 | hpfs_inode->i_file_sec = btree->u.external[i].file_secno; | 46 | hpfs_inode->i_file_sec = le32_to_cpu(btree->u.external[i].file_secno); |
47 | hpfs_inode->i_disk_sec = btree->u.external[i].disk_secno; | 47 | hpfs_inode->i_disk_sec = le32_to_cpu(btree->u.external[i].disk_secno); |
48 | hpfs_inode->i_n_secs = btree->u.external[i].length; | 48 | hpfs_inode->i_n_secs = le32_to_cpu(btree->u.external[i].length); |
49 | } | 49 | } |
50 | brelse(bh); | 50 | brelse(bh); |
51 | return a; | 51 | return a; |
@@ -83,8 +83,8 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
83 | return -1; | 83 | return -1; |
84 | } | 84 | } |
85 | if (btree->internal) { | 85 | if (btree->internal) { |
86 | a = btree->u.internal[n].down; | 86 | a = le32_to_cpu(btree->u.internal[n].down); |
87 | btree->u.internal[n].file_secno = -1; | 87 | btree->u.internal[n].file_secno = cpu_to_le32(-1); |
88 | mark_buffer_dirty(bh); | 88 | mark_buffer_dirty(bh); |
89 | brelse(bh); | 89 | brelse(bh); |
90 | if (hpfs_sb(s)->sb_chk) | 90 | if (hpfs_sb(s)->sb_chk) |
@@ -94,15 +94,15 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
94 | goto go_down; | 94 | goto go_down; |
95 | } | 95 | } |
96 | if (n >= 0) { | 96 | if (n >= 0) { |
97 | if (btree->u.external[n].file_secno + btree->u.external[n].length != fsecno) { | 97 | if (le32_to_cpu(btree->u.external[n].file_secno) + le32_to_cpu(btree->u.external[n].length) != fsecno) { |
98 | hpfs_error(s, "allocated size %08x, trying to add sector %08x, %cnode %08x", | 98 | hpfs_error(s, "allocated size %08x, trying to add sector %08x, %cnode %08x", |
99 | btree->u.external[n].file_secno + btree->u.external[n].length, fsecno, | 99 | le32_to_cpu(btree->u.external[n].file_secno) + le32_to_cpu(btree->u.external[n].length), fsecno, |
100 | fnod?'f':'a', node); | 100 | fnod?'f':'a', node); |
101 | brelse(bh); | 101 | brelse(bh); |
102 | return -1; | 102 | return -1; |
103 | } | 103 | } |
104 | if (hpfs_alloc_if_possible(s, se = btree->u.external[n].disk_secno + btree->u.external[n].length)) { | 104 | if (hpfs_alloc_if_possible(s, se = le32_to_cpu(btree->u.external[n].disk_secno) + le32_to_cpu(btree->u.external[n].length))) { |
105 | btree->u.external[n].length++; | 105 | btree->u.external[n].length = cpu_to_le32(le32_to_cpu(btree->u.external[n].length) + 1); |
106 | mark_buffer_dirty(bh); | 106 | mark_buffer_dirty(bh); |
107 | brelse(bh); | 107 | brelse(bh); |
108 | return se; | 108 | return se; |
@@ -115,20 +115,20 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
115 | } | 115 | } |
116 | se = !fnod ? node : (node + 16384) & ~16383; | 116 | se = !fnod ? node : (node + 16384) & ~16383; |
117 | } | 117 | } |
118 | if (!(se = hpfs_alloc_sector(s, se, 1, fsecno*ALLOC_M>ALLOC_FWD_MAX ? ALLOC_FWD_MAX : fsecno*ALLOC_M<ALLOC_FWD_MIN ? ALLOC_FWD_MIN : fsecno*ALLOC_M, 1))) { | 118 | if (!(se = hpfs_alloc_sector(s, se, 1, fsecno*ALLOC_M>ALLOC_FWD_MAX ? ALLOC_FWD_MAX : fsecno*ALLOC_M<ALLOC_FWD_MIN ? ALLOC_FWD_MIN : fsecno*ALLOC_M))) { |
119 | brelse(bh); | 119 | brelse(bh); |
120 | return -1; | 120 | return -1; |
121 | } | 121 | } |
122 | fs = n < 0 ? 0 : btree->u.external[n].file_secno + btree->u.external[n].length; | 122 | fs = n < 0 ? 0 : le32_to_cpu(btree->u.external[n].file_secno) + le32_to_cpu(btree->u.external[n].length); |
123 | if (!btree->n_free_nodes) { | 123 | if (!btree->n_free_nodes) { |
124 | up = a != node ? anode->up : -1; | 124 | up = a != node ? le32_to_cpu(anode->up) : -1; |
125 | if (!(anode = hpfs_alloc_anode(s, a, &na, &bh1))) { | 125 | if (!(anode = hpfs_alloc_anode(s, a, &na, &bh1))) { |
126 | brelse(bh); | 126 | brelse(bh); |
127 | hpfs_free_sectors(s, se, 1); | 127 | hpfs_free_sectors(s, se, 1); |
128 | return -1; | 128 | return -1; |
129 | } | 129 | } |
130 | if (a == node && fnod) { | 130 | if (a == node && fnod) { |
131 | anode->up = node; | 131 | anode->up = cpu_to_le32(node); |
132 | anode->btree.fnode_parent = 1; | 132 | anode->btree.fnode_parent = 1; |
133 | anode->btree.n_used_nodes = btree->n_used_nodes; | 133 | anode->btree.n_used_nodes = btree->n_used_nodes; |
134 | anode->btree.first_free = btree->first_free; | 134 | anode->btree.first_free = btree->first_free; |
@@ -137,9 +137,9 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
137 | btree->internal = 1; | 137 | btree->internal = 1; |
138 | btree->n_free_nodes = 11; | 138 | btree->n_free_nodes = 11; |
139 | btree->n_used_nodes = 1; | 139 | btree->n_used_nodes = 1; |
140 | btree->first_free = (char *)&(btree->u.internal[1]) - (char *)btree; | 140 | btree->first_free = cpu_to_le16((char *)&(btree->u.internal[1]) - (char *)btree); |
141 | btree->u.internal[0].file_secno = -1; | 141 | btree->u.internal[0].file_secno = cpu_to_le32(-1); |
142 | btree->u.internal[0].down = na; | 142 | btree->u.internal[0].down = cpu_to_le32(na); |
143 | mark_buffer_dirty(bh); | 143 | mark_buffer_dirty(bh); |
144 | } else if (!(ranode = hpfs_alloc_anode(s, /*a*/0, &ra, &bh2))) { | 144 | } else if (!(ranode = hpfs_alloc_anode(s, /*a*/0, &ra, &bh2))) { |
145 | brelse(bh); | 145 | brelse(bh); |
@@ -153,15 +153,15 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
153 | btree = &anode->btree; | 153 | btree = &anode->btree; |
154 | } | 154 | } |
155 | btree->n_free_nodes--; n = btree->n_used_nodes++; | 155 | btree->n_free_nodes--; n = btree->n_used_nodes++; |
156 | btree->first_free += 12; | 156 | btree->first_free = cpu_to_le16(le16_to_cpu(btree->first_free) + 12); |
157 | btree->u.external[n].disk_secno = se; | 157 | btree->u.external[n].disk_secno = cpu_to_le32(se); |
158 | btree->u.external[n].file_secno = fs; | 158 | btree->u.external[n].file_secno = cpu_to_le32(fs); |
159 | btree->u.external[n].length = 1; | 159 | btree->u.external[n].length = cpu_to_le32(1); |
160 | mark_buffer_dirty(bh); | 160 | mark_buffer_dirty(bh); |
161 | brelse(bh); | 161 | brelse(bh); |
162 | if ((a == node && fnod) || na == -1) return se; | 162 | if ((a == node && fnod) || na == -1) return se; |
163 | c2 = 0; | 163 | c2 = 0; |
164 | while (up != -1) { | 164 | while (up != (anode_secno)-1) { |
165 | struct anode *new_anode; | 165 | struct anode *new_anode; |
166 | if (hpfs_sb(s)->sb_chk) | 166 | if (hpfs_sb(s)->sb_chk) |
167 | if (hpfs_stop_cycles(s, up, &c1, &c2, "hpfs_add_sector_to_btree #2")) return -1; | 167 | if (hpfs_stop_cycles(s, up, &c1, &c2, "hpfs_add_sector_to_btree #2")) return -1; |
@@ -174,47 +174,47 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
174 | } | 174 | } |
175 | if (btree->n_free_nodes) { | 175 | if (btree->n_free_nodes) { |
176 | btree->n_free_nodes--; n = btree->n_used_nodes++; | 176 | btree->n_free_nodes--; n = btree->n_used_nodes++; |
177 | btree->first_free += 8; | 177 | btree->first_free = cpu_to_le16(le16_to_cpu(btree->first_free) + 8); |
178 | btree->u.internal[n].file_secno = -1; | 178 | btree->u.internal[n].file_secno = cpu_to_le32(-1); |
179 | btree->u.internal[n].down = na; | 179 | btree->u.internal[n].down = cpu_to_le32(na); |
180 | btree->u.internal[n-1].file_secno = fs; | 180 | btree->u.internal[n-1].file_secno = cpu_to_le32(fs); |
181 | mark_buffer_dirty(bh); | 181 | mark_buffer_dirty(bh); |
182 | brelse(bh); | 182 | brelse(bh); |
183 | brelse(bh2); | 183 | brelse(bh2); |
184 | hpfs_free_sectors(s, ra, 1); | 184 | hpfs_free_sectors(s, ra, 1); |
185 | if ((anode = hpfs_map_anode(s, na, &bh))) { | 185 | if ((anode = hpfs_map_anode(s, na, &bh))) { |
186 | anode->up = up; | 186 | anode->up = cpu_to_le32(up); |
187 | anode->btree.fnode_parent = up == node && fnod; | 187 | anode->btree.fnode_parent = up == node && fnod; |
188 | mark_buffer_dirty(bh); | 188 | mark_buffer_dirty(bh); |
189 | brelse(bh); | 189 | brelse(bh); |
190 | } | 190 | } |
191 | return se; | 191 | return se; |
192 | } | 192 | } |
193 | up = up != node ? anode->up : -1; | 193 | up = up != node ? le32_to_cpu(anode->up) : -1; |
194 | btree->u.internal[btree->n_used_nodes - 1].file_secno = /*fs*/-1; | 194 | btree->u.internal[btree->n_used_nodes - 1].file_secno = cpu_to_le32(/*fs*/-1); |
195 | mark_buffer_dirty(bh); | 195 | mark_buffer_dirty(bh); |
196 | brelse(bh); | 196 | brelse(bh); |
197 | a = na; | 197 | a = na; |
198 | if ((new_anode = hpfs_alloc_anode(s, a, &na, &bh))) { | 198 | if ((new_anode = hpfs_alloc_anode(s, a, &na, &bh))) { |
199 | anode = new_anode; | 199 | anode = new_anode; |
200 | /*anode->up = up != -1 ? up : ra;*/ | 200 | /*anode->up = cpu_to_le32(up != -1 ? up : ra);*/ |
201 | anode->btree.internal = 1; | 201 | anode->btree.internal = 1; |
202 | anode->btree.n_used_nodes = 1; | 202 | anode->btree.n_used_nodes = 1; |
203 | anode->btree.n_free_nodes = 59; | 203 | anode->btree.n_free_nodes = 59; |
204 | anode->btree.first_free = 16; | 204 | anode->btree.first_free = cpu_to_le16(16); |
205 | anode->btree.u.internal[0].down = a; | 205 | anode->btree.u.internal[0].down = cpu_to_le32(a); |
206 | anode->btree.u.internal[0].file_secno = -1; | 206 | anode->btree.u.internal[0].file_secno = cpu_to_le32(-1); |
207 | mark_buffer_dirty(bh); | 207 | mark_buffer_dirty(bh); |
208 | brelse(bh); | 208 | brelse(bh); |
209 | if ((anode = hpfs_map_anode(s, a, &bh))) { | 209 | if ((anode = hpfs_map_anode(s, a, &bh))) { |
210 | anode->up = na; | 210 | anode->up = cpu_to_le32(na); |
211 | mark_buffer_dirty(bh); | 211 | mark_buffer_dirty(bh); |
212 | brelse(bh); | 212 | brelse(bh); |
213 | } | 213 | } |
214 | } else na = a; | 214 | } else na = a; |
215 | } | 215 | } |
216 | if ((anode = hpfs_map_anode(s, na, &bh))) { | 216 | if ((anode = hpfs_map_anode(s, na, &bh))) { |
217 | anode->up = node; | 217 | anode->up = cpu_to_le32(node); |
218 | if (fnod) anode->btree.fnode_parent = 1; | 218 | if (fnod) anode->btree.fnode_parent = 1; |
219 | mark_buffer_dirty(bh); | 219 | mark_buffer_dirty(bh); |
220 | brelse(bh); | 220 | brelse(bh); |
@@ -232,14 +232,14 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
232 | } | 232 | } |
233 | btree = &fnode->btree; | 233 | btree = &fnode->btree; |
234 | } | 234 | } |
235 | ranode->up = node; | 235 | ranode->up = cpu_to_le32(node); |
236 | memcpy(&ranode->btree, btree, btree->first_free); | 236 | memcpy(&ranode->btree, btree, le16_to_cpu(btree->first_free)); |
237 | if (fnod) ranode->btree.fnode_parent = 1; | 237 | if (fnod) ranode->btree.fnode_parent = 1; |
238 | ranode->btree.n_free_nodes = (ranode->btree.internal ? 60 : 40) - ranode->btree.n_used_nodes; | 238 | ranode->btree.n_free_nodes = (ranode->btree.internal ? 60 : 40) - ranode->btree.n_used_nodes; |
239 | if (ranode->btree.internal) for (n = 0; n < ranode->btree.n_used_nodes; n++) { | 239 | if (ranode->btree.internal) for (n = 0; n < ranode->btree.n_used_nodes; n++) { |
240 | struct anode *unode; | 240 | struct anode *unode; |
241 | if ((unode = hpfs_map_anode(s, ranode->u.internal[n].down, &bh1))) { | 241 | if ((unode = hpfs_map_anode(s, le32_to_cpu(ranode->u.internal[n].down), &bh1))) { |
242 | unode->up = ra; | 242 | unode->up = cpu_to_le32(ra); |
243 | unode->btree.fnode_parent = 0; | 243 | unode->btree.fnode_parent = 0; |
244 | mark_buffer_dirty(bh1); | 244 | mark_buffer_dirty(bh1); |
245 | brelse(bh1); | 245 | brelse(bh1); |
@@ -248,11 +248,11 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
248 | btree->internal = 1; | 248 | btree->internal = 1; |
249 | btree->n_free_nodes = fnod ? 10 : 58; | 249 | btree->n_free_nodes = fnod ? 10 : 58; |
250 | btree->n_used_nodes = 2; | 250 | btree->n_used_nodes = 2; |
251 | btree->first_free = (char *)&btree->u.internal[2] - (char *)btree; | 251 | btree->first_free = cpu_to_le16((char *)&btree->u.internal[2] - (char *)btree); |
252 | btree->u.internal[0].file_secno = fs; | 252 | btree->u.internal[0].file_secno = cpu_to_le32(fs); |
253 | btree->u.internal[0].down = ra; | 253 | btree->u.internal[0].down = cpu_to_le32(ra); |
254 | btree->u.internal[1].file_secno = -1; | 254 | btree->u.internal[1].file_secno = cpu_to_le32(-1); |
255 | btree->u.internal[1].down = na; | 255 | btree->u.internal[1].down = cpu_to_le32(na); |
256 | mark_buffer_dirty(bh); | 256 | mark_buffer_dirty(bh); |
257 | brelse(bh); | 257 | brelse(bh); |
258 | mark_buffer_dirty(bh2); | 258 | mark_buffer_dirty(bh2); |
@@ -279,7 +279,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree) | |||
279 | go_down: | 279 | go_down: |
280 | d2 = 0; | 280 | d2 = 0; |
281 | while (btree1->internal) { | 281 | while (btree1->internal) { |
282 | ano = btree1->u.internal[pos].down; | 282 | ano = le32_to_cpu(btree1->u.internal[pos].down); |
283 | if (level) brelse(bh); | 283 | if (level) brelse(bh); |
284 | if (hpfs_sb(s)->sb_chk) | 284 | if (hpfs_sb(s)->sb_chk) |
285 | if (hpfs_stop_cycles(s, ano, &d1, &d2, "hpfs_remove_btree #1")) | 285 | if (hpfs_stop_cycles(s, ano, &d1, &d2, "hpfs_remove_btree #1")) |
@@ -290,7 +290,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree) | |||
290 | pos = 0; | 290 | pos = 0; |
291 | } | 291 | } |
292 | for (i = 0; i < btree1->n_used_nodes; i++) | 292 | for (i = 0; i < btree1->n_used_nodes; i++) |
293 | hpfs_free_sectors(s, btree1->u.external[i].disk_secno, btree1->u.external[i].length); | 293 | hpfs_free_sectors(s, le32_to_cpu(btree1->u.external[i].disk_secno), le32_to_cpu(btree1->u.external[i].length)); |
294 | go_up: | 294 | go_up: |
295 | if (!level) return; | 295 | if (!level) return; |
296 | brelse(bh); | 296 | brelse(bh); |
@@ -298,13 +298,13 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree) | |||
298 | if (hpfs_stop_cycles(s, ano, &c1, &c2, "hpfs_remove_btree #2")) return; | 298 | if (hpfs_stop_cycles(s, ano, &c1, &c2, "hpfs_remove_btree #2")) return; |
299 | hpfs_free_sectors(s, ano, 1); | 299 | hpfs_free_sectors(s, ano, 1); |
300 | oano = ano; | 300 | oano = ano; |
301 | ano = anode->up; | 301 | ano = le32_to_cpu(anode->up); |
302 | if (--level) { | 302 | if (--level) { |
303 | if (!(anode = hpfs_map_anode(s, ano, &bh))) return; | 303 | if (!(anode = hpfs_map_anode(s, ano, &bh))) return; |
304 | btree1 = &anode->btree; | 304 | btree1 = &anode->btree; |
305 | } else btree1 = btree; | 305 | } else btree1 = btree; |
306 | for (i = 0; i < btree1->n_used_nodes; i++) { | 306 | for (i = 0; i < btree1->n_used_nodes; i++) { |
307 | if (btree1->u.internal[i].down == oano) { | 307 | if (le32_to_cpu(btree1->u.internal[i].down) == oano) { |
308 | if ((pos = i + 1) < btree1->n_used_nodes) | 308 | if ((pos = i + 1) < btree1->n_used_nodes) |
309 | goto go_down; | 309 | goto go_down; |
310 | else | 310 | else |
@@ -411,7 +411,7 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs) | |||
411 | if (fno) { | 411 | if (fno) { |
412 | btree->n_free_nodes = 8; | 412 | btree->n_free_nodes = 8; |
413 | btree->n_used_nodes = 0; | 413 | btree->n_used_nodes = 0; |
414 | btree->first_free = 8; | 414 | btree->first_free = cpu_to_le16(8); |
415 | btree->internal = 0; | 415 | btree->internal = 0; |
416 | mark_buffer_dirty(bh); | 416 | mark_buffer_dirty(bh); |
417 | } else hpfs_free_sectors(s, f, 1); | 417 | } else hpfs_free_sectors(s, f, 1); |
@@ -421,22 +421,22 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs) | |||
421 | while (btree->internal) { | 421 | while (btree->internal) { |
422 | nodes = btree->n_used_nodes + btree->n_free_nodes; | 422 | nodes = btree->n_used_nodes + btree->n_free_nodes; |
423 | for (i = 0; i < btree->n_used_nodes; i++) | 423 | for (i = 0; i < btree->n_used_nodes; i++) |
424 | if (btree->u.internal[i].file_secno >= secs) goto f; | 424 | if (le32_to_cpu(btree->u.internal[i].file_secno) >= secs) goto f; |
425 | brelse(bh); | 425 | brelse(bh); |
426 | hpfs_error(s, "internal btree %08x doesn't end with -1", node); | 426 | hpfs_error(s, "internal btree %08x doesn't end with -1", node); |
427 | return; | 427 | return; |
428 | f: | 428 | f: |
429 | for (j = i + 1; j < btree->n_used_nodes; j++) | 429 | for (j = i + 1; j < btree->n_used_nodes; j++) |
430 | hpfs_ea_remove(s, btree->u.internal[j].down, 1, 0); | 430 | hpfs_ea_remove(s, le32_to_cpu(btree->u.internal[j].down), 1, 0); |
431 | btree->n_used_nodes = i + 1; | 431 | btree->n_used_nodes = i + 1; |
432 | btree->n_free_nodes = nodes - btree->n_used_nodes; | 432 | btree->n_free_nodes = nodes - btree->n_used_nodes; |
433 | btree->first_free = 8 + 8 * btree->n_used_nodes; | 433 | btree->first_free = cpu_to_le16(8 + 8 * btree->n_used_nodes); |
434 | mark_buffer_dirty(bh); | 434 | mark_buffer_dirty(bh); |
435 | if (btree->u.internal[i].file_secno == secs) { | 435 | if (btree->u.internal[i].file_secno == cpu_to_le32(secs)) { |
436 | brelse(bh); | 436 | brelse(bh); |
437 | return; | 437 | return; |
438 | } | 438 | } |
439 | node = btree->u.internal[i].down; | 439 | node = le32_to_cpu(btree->u.internal[i].down); |
440 | brelse(bh); | 440 | brelse(bh); |
441 | if (hpfs_sb(s)->sb_chk) | 441 | if (hpfs_sb(s)->sb_chk) |
442 | if (hpfs_stop_cycles(s, node, &c1, &c2, "hpfs_truncate_btree")) | 442 | if (hpfs_stop_cycles(s, node, &c1, &c2, "hpfs_truncate_btree")) |
@@ -446,25 +446,25 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs) | |||
446 | } | 446 | } |
447 | nodes = btree->n_used_nodes + btree->n_free_nodes; | 447 | nodes = btree->n_used_nodes + btree->n_free_nodes; |
448 | for (i = 0; i < btree->n_used_nodes; i++) | 448 | for (i = 0; i < btree->n_used_nodes; i++) |
449 | if (btree->u.external[i].file_secno + btree->u.external[i].length >= secs) goto ff; | 449 | if (le32_to_cpu(btree->u.external[i].file_secno) + le32_to_cpu(btree->u.external[i].length) >= secs) goto ff; |
450 | brelse(bh); | 450 | brelse(bh); |
451 | return; | 451 | return; |
452 | ff: | 452 | ff: |
453 | if (secs <= btree->u.external[i].file_secno) { | 453 | if (secs <= le32_to_cpu(btree->u.external[i].file_secno)) { |
454 | hpfs_error(s, "there is an allocation error in file %08x, sector %08x", f, secs); | 454 | hpfs_error(s, "there is an allocation error in file %08x, sector %08x", f, secs); |
455 | if (i) i--; | 455 | if (i) i--; |
456 | } | 456 | } |
457 | else if (btree->u.external[i].file_secno + btree->u.external[i].length > secs) { | 457 | else if (le32_to_cpu(btree->u.external[i].file_secno) + le32_to_cpu(btree->u.external[i].length) > secs) { |
458 | hpfs_free_sectors(s, btree->u.external[i].disk_secno + secs - | 458 | hpfs_free_sectors(s, le32_to_cpu(btree->u.external[i].disk_secno) + secs - |
459 | btree->u.external[i].file_secno, btree->u.external[i].length | 459 | le32_to_cpu(btree->u.external[i].file_secno), le32_to_cpu(btree->u.external[i].length) |
460 | - secs + btree->u.external[i].file_secno); /* I hope gcc optimizes this :-) */ | 460 | - secs + le32_to_cpu(btree->u.external[i].file_secno)); /* I hope gcc optimizes this :-) */ |
461 | btree->u.external[i].length = secs - btree->u.external[i].file_secno; | 461 | btree->u.external[i].length = cpu_to_le32(secs - le32_to_cpu(btree->u.external[i].file_secno)); |
462 | } | 462 | } |
463 | for (j = i + 1; j < btree->n_used_nodes; j++) | 463 | for (j = i + 1; j < btree->n_used_nodes; j++) |
464 | hpfs_free_sectors(s, btree->u.external[j].disk_secno, btree->u.external[j].length); | 464 | hpfs_free_sectors(s, le32_to_cpu(btree->u.external[j].disk_secno), le32_to_cpu(btree->u.external[j].length)); |
465 | btree->n_used_nodes = i + 1; | 465 | btree->n_used_nodes = i + 1; |
466 | btree->n_free_nodes = nodes - btree->n_used_nodes; | 466 | btree->n_free_nodes = nodes - btree->n_used_nodes; |
467 | btree->first_free = 8 + 12 * btree->n_used_nodes; | 467 | btree->first_free = cpu_to_le16(8 + 12 * btree->n_used_nodes); |
468 | mark_buffer_dirty(bh); | 468 | mark_buffer_dirty(bh); |
469 | brelse(bh); | 469 | brelse(bh); |
470 | } | 470 | } |
@@ -480,12 +480,12 @@ void hpfs_remove_fnode(struct super_block *s, fnode_secno fno) | |||
480 | struct extended_attribute *ea_end; | 480 | struct extended_attribute *ea_end; |
481 | if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return; | 481 | if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return; |
482 | if (!fnode->dirflag) hpfs_remove_btree(s, &fnode->btree); | 482 | if (!fnode->dirflag) hpfs_remove_btree(s, &fnode->btree); |
483 | else hpfs_remove_dtree(s, fnode->u.external[0].disk_secno); | 483 | else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno)); |
484 | ea_end = fnode_end_ea(fnode); | 484 | ea_end = fnode_end_ea(fnode); |
485 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 485 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
486 | if (ea->indirect) | 486 | if (ea->indirect) |
487 | hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); | 487 | hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); |
488 | hpfs_ea_ext_remove(s, fnode->ea_secno, fnode->ea_anode, fnode->ea_size_l); | 488 | hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l)); |
489 | brelse(bh); | 489 | brelse(bh); |
490 | hpfs_free_sectors(s, fno, 1); | 490 | hpfs_free_sectors(s, fno, 1); |
491 | } | 491 | } |
diff --git a/fs/hpfs/buffer.c b/fs/hpfs/buffer.c index 793cb9d943d..9ecde27d1e2 100644 --- a/fs/hpfs/buffer.c +++ b/fs/hpfs/buffer.c | |||
@@ -9,22 +9,6 @@ | |||
9 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
10 | #include "hpfs_fn.h" | 10 | #include "hpfs_fn.h" |
11 | 11 | ||
12 | void hpfs_lock_creation(struct super_block *s) | ||
13 | { | ||
14 | #ifdef DEBUG_LOCKS | ||
15 | printk("lock creation\n"); | ||
16 | #endif | ||
17 | mutex_lock(&hpfs_sb(s)->hpfs_creation_de); | ||
18 | } | ||
19 | |||
20 | void hpfs_unlock_creation(struct super_block *s) | ||
21 | { | ||
22 | #ifdef DEBUG_LOCKS | ||
23 | printk("unlock creation\n"); | ||
24 | #endif | ||
25 | mutex_unlock(&hpfs_sb(s)->hpfs_creation_de); | ||
26 | } | ||
27 | |||
28 | /* Map a sector into a buffer and return pointers to it and to the buffer. */ | 12 | /* Map a sector into a buffer and return pointers to it and to the buffer. */ |
29 | 13 | ||
30 | void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp, | 14 | void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp, |
@@ -32,6 +16,8 @@ void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head | |||
32 | { | 16 | { |
33 | struct buffer_head *bh; | 17 | struct buffer_head *bh; |
34 | 18 | ||
19 | hpfs_lock_assert(s); | ||
20 | |||
35 | cond_resched(); | 21 | cond_resched(); |
36 | 22 | ||
37 | *bhp = bh = sb_bread(s, secno); | 23 | *bhp = bh = sb_bread(s, secno); |
@@ -50,6 +36,8 @@ void *hpfs_get_sector(struct super_block *s, unsigned secno, struct buffer_head | |||
50 | struct buffer_head *bh; | 36 | struct buffer_head *bh; |
51 | /*return hpfs_map_sector(s, secno, bhp, 0);*/ | 37 | /*return hpfs_map_sector(s, secno, bhp, 0);*/ |
52 | 38 | ||
39 | hpfs_lock_assert(s); | ||
40 | |||
53 | cond_resched(); | 41 | cond_resched(); |
54 | 42 | ||
55 | if ((*bhp = bh = sb_getblk(s, secno)) != NULL) { | 43 | if ((*bhp = bh = sb_getblk(s, secno)) != NULL) { |
@@ -70,6 +58,8 @@ void *hpfs_map_4sectors(struct super_block *s, unsigned secno, struct quad_buffe | |||
70 | struct buffer_head *bh; | 58 | struct buffer_head *bh; |
71 | char *data; | 59 | char *data; |
72 | 60 | ||
61 | hpfs_lock_assert(s); | ||
62 | |||
73 | cond_resched(); | 63 | cond_resched(); |
74 | 64 | ||
75 | if (secno & 3) { | 65 | if (secno & 3) { |
@@ -125,6 +115,8 @@ void *hpfs_get_4sectors(struct super_block *s, unsigned secno, | |||
125 | { | 115 | { |
126 | cond_resched(); | 116 | cond_resched(); |
127 | 117 | ||
118 | hpfs_lock_assert(s); | ||
119 | |||
128 | if (secno & 3) { | 120 | if (secno & 3) { |
129 | printk("HPFS: hpfs_get_4sectors: unaligned read\n"); | 121 | printk("HPFS: hpfs_get_4sectors: unaligned read\n"); |
130 | return NULL; | 122 | return NULL; |
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c index b3d7c0ddb60..f46ae025bfb 100644 --- a/fs/hpfs/dir.c +++ b/fs/hpfs/dir.c | |||
@@ -88,9 +88,9 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
88 | hpfs_error(inode->i_sb, "not a directory, fnode %08lx", | 88 | hpfs_error(inode->i_sb, "not a directory, fnode %08lx", |
89 | (unsigned long)inode->i_ino); | 89 | (unsigned long)inode->i_ino); |
90 | } | 90 | } |
91 | if (hpfs_inode->i_dno != fno->u.external[0].disk_secno) { | 91 | if (hpfs_inode->i_dno != le32_to_cpu(fno->u.external[0].disk_secno)) { |
92 | e = 1; | 92 | e = 1; |
93 | hpfs_error(inode->i_sb, "corrupted inode: i_dno == %08x, fnode -> dnode == %08x", hpfs_inode->i_dno, fno->u.external[0].disk_secno); | 93 | hpfs_error(inode->i_sb, "corrupted inode: i_dno == %08x, fnode -> dnode == %08x", hpfs_inode->i_dno, le32_to_cpu(fno->u.external[0].disk_secno)); |
94 | } | 94 | } |
95 | brelse(bh); | 95 | brelse(bh); |
96 | if (e) { | 96 | if (e) { |
@@ -156,7 +156,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
156 | goto again; | 156 | goto again; |
157 | } | 157 | } |
158 | tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3); | 158 | tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3); |
159 | if (filldir(dirent, tempname, de->namelen, old_pos, de->fnode, DT_UNKNOWN) < 0) { | 159 | if (filldir(dirent, tempname, de->namelen, old_pos, le32_to_cpu(de->fnode), DT_UNKNOWN) < 0) { |
160 | filp->f_pos = old_pos; | 160 | filp->f_pos = old_pos; |
161 | if (tempname != de->name) kfree(tempname); | 161 | if (tempname != de->name) kfree(tempname); |
162 | hpfs_brelse4(&qbh); | 162 | hpfs_brelse4(&qbh); |
@@ -221,7 +221,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name | |||
221 | * Get inode number, what we're after. | 221 | * Get inode number, what we're after. |
222 | */ | 222 | */ |
223 | 223 | ||
224 | ino = de->fnode; | 224 | ino = le32_to_cpu(de->fnode); |
225 | 225 | ||
226 | /* | 226 | /* |
227 | * Go find or make an inode. | 227 | * Go find or make an inode. |
@@ -236,7 +236,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name | |||
236 | hpfs_init_inode(result); | 236 | hpfs_init_inode(result); |
237 | if (de->directory) | 237 | if (de->directory) |
238 | hpfs_read_inode(result); | 238 | hpfs_read_inode(result); |
239 | else if (de->ea_size && hpfs_sb(dir->i_sb)->sb_eas) | 239 | else if (le32_to_cpu(de->ea_size) && hpfs_sb(dir->i_sb)->sb_eas) |
240 | hpfs_read_inode(result); | 240 | hpfs_read_inode(result); |
241 | else { | 241 | else { |
242 | result->i_mode |= S_IFREG; | 242 | result->i_mode |= S_IFREG; |
@@ -250,8 +250,6 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name | |||
250 | hpfs_result = hpfs_i(result); | 250 | hpfs_result = hpfs_i(result); |
251 | if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino; | 251 | if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino; |
252 | 252 | ||
253 | hpfs_decide_conv(result, name, len); | ||
254 | |||
255 | if (de->has_acl || de->has_xtd_perm) if (!(dir->i_sb->s_flags & MS_RDONLY)) { | 253 | if (de->has_acl || de->has_xtd_perm) if (!(dir->i_sb->s_flags & MS_RDONLY)) { |
256 | hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures"); | 254 | hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures"); |
257 | goto bail1; | 255 | goto bail1; |
@@ -263,19 +261,19 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name | |||
263 | */ | 261 | */ |
264 | 262 | ||
265 | if (!result->i_ctime.tv_sec) { | 263 | if (!result->i_ctime.tv_sec) { |
266 | if (!(result->i_ctime.tv_sec = local_to_gmt(dir->i_sb, de->creation_date))) | 264 | if (!(result->i_ctime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->creation_date)))) |
267 | result->i_ctime.tv_sec = 1; | 265 | result->i_ctime.tv_sec = 1; |
268 | result->i_ctime.tv_nsec = 0; | 266 | result->i_ctime.tv_nsec = 0; |
269 | result->i_mtime.tv_sec = local_to_gmt(dir->i_sb, de->write_date); | 267 | result->i_mtime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->write_date)); |
270 | result->i_mtime.tv_nsec = 0; | 268 | result->i_mtime.tv_nsec = 0; |
271 | result->i_atime.tv_sec = local_to_gmt(dir->i_sb, de->read_date); | 269 | result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->read_date)); |
272 | result->i_atime.tv_nsec = 0; | 270 | result->i_atime.tv_nsec = 0; |
273 | hpfs_result->i_ea_size = de->ea_size; | 271 | hpfs_result->i_ea_size = le32_to_cpu(de->ea_size); |
274 | if (!hpfs_result->i_ea_mode && de->read_only) | 272 | if (!hpfs_result->i_ea_mode && de->read_only) |
275 | result->i_mode &= ~0222; | 273 | result->i_mode &= ~0222; |
276 | if (!de->directory) { | 274 | if (!de->directory) { |
277 | if (result->i_size == -1) { | 275 | if (result->i_size == -1) { |
278 | result->i_size = de->file_size; | 276 | result->i_size = le32_to_cpu(de->file_size); |
279 | result->i_data.a_ops = &hpfs_aops; | 277 | result->i_data.a_ops = &hpfs_aops; |
280 | hpfs_i(result)->mmu_private = result->i_size; | 278 | hpfs_i(result)->mmu_private = result->i_size; |
281 | /* | 279 | /* |
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index 9b2ffadfc8c..1e0e2ac30fd 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
@@ -14,11 +14,11 @@ static loff_t get_pos(struct dnode *d, struct hpfs_dirent *fde) | |||
14 | struct hpfs_dirent *de_end = dnode_end_de(d); | 14 | struct hpfs_dirent *de_end = dnode_end_de(d); |
15 | int i = 1; | 15 | int i = 1; |
16 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { | 16 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { |
17 | if (de == fde) return ((loff_t) d->self << 4) | (loff_t)i; | 17 | if (de == fde) return ((loff_t) le32_to_cpu(d->self) << 4) | (loff_t)i; |
18 | i++; | 18 | i++; |
19 | } | 19 | } |
20 | printk("HPFS: get_pos: not_found\n"); | 20 | printk("HPFS: get_pos: not_found\n"); |
21 | return ((loff_t)d->self << 4) | (loff_t)1; | 21 | return ((loff_t)le32_to_cpu(d->self) << 4) | (loff_t)1; |
22 | } | 22 | } |
23 | 23 | ||
24 | void hpfs_add_pos(struct inode *inode, loff_t *pos) | 24 | void hpfs_add_pos(struct inode *inode, loff_t *pos) |
@@ -130,29 +130,30 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno | |||
130 | { | 130 | { |
131 | struct hpfs_dirent *de; | 131 | struct hpfs_dirent *de; |
132 | if (!(de = dnode_last_de(d))) { | 132 | if (!(de = dnode_last_de(d))) { |
133 | hpfs_error(s, "set_last_pointer: empty dnode %08x", d->self); | 133 | hpfs_error(s, "set_last_pointer: empty dnode %08x", le32_to_cpu(d->self)); |
134 | return; | 134 | return; |
135 | } | 135 | } |
136 | if (hpfs_sb(s)->sb_chk) { | 136 | if (hpfs_sb(s)->sb_chk) { |
137 | if (de->down) { | 137 | if (de->down) { |
138 | hpfs_error(s, "set_last_pointer: dnode %08x has already last pointer %08x", | 138 | hpfs_error(s, "set_last_pointer: dnode %08x has already last pointer %08x", |
139 | d->self, de_down_pointer(de)); | 139 | le32_to_cpu(d->self), de_down_pointer(de)); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | if (de->length != 32) { | 142 | if (le16_to_cpu(de->length) != 32) { |
143 | hpfs_error(s, "set_last_pointer: bad last dirent in dnode %08x", d->self); | 143 | hpfs_error(s, "set_last_pointer: bad last dirent in dnode %08x", le32_to_cpu(d->self)); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | } | 146 | } |
147 | if (ptr) { | 147 | if (ptr) { |
148 | if ((d->first_free += 4) > 2048) { | 148 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + 4); |
149 | hpfs_error(s,"set_last_pointer: too long dnode %08x", d->self); | 149 | if (le32_to_cpu(d->first_free) > 2048) { |
150 | d->first_free -= 4; | 150 | hpfs_error(s, "set_last_pointer: too long dnode %08x", le32_to_cpu(d->self)); |
151 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - 4); | ||
151 | return; | 152 | return; |
152 | } | 153 | } |
153 | de->length = 36; | 154 | de->length = cpu_to_le16(36); |
154 | de->down = 1; | 155 | de->down = 1; |
155 | *(dnode_secno *)((char *)de + 32) = ptr; | 156 | *(dnode_secno *)((char *)de + 32) = cpu_to_le32(ptr); |
156 | } | 157 | } |
157 | } | 158 | } |
158 | 159 | ||
@@ -168,7 +169,7 @@ struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, | |||
168 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { | 169 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { |
169 | int c = hpfs_compare_names(s, name, namelen, de->name, de->namelen, de->last); | 170 | int c = hpfs_compare_names(s, name, namelen, de->name, de->namelen, de->last); |
170 | if (!c) { | 171 | if (!c) { |
171 | hpfs_error(s, "name (%c,%d) already exists in dnode %08x", *name, namelen, d->self); | 172 | hpfs_error(s, "name (%c,%d) already exists in dnode %08x", *name, namelen, le32_to_cpu(d->self)); |
172 | return NULL; | 173 | return NULL; |
173 | } | 174 | } |
174 | if (c < 0) break; | 175 | if (c < 0) break; |
@@ -176,15 +177,14 @@ struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, | |||
176 | memmove((char *)de + d_size, de, (char *)de_end - (char *)de); | 177 | memmove((char *)de + d_size, de, (char *)de_end - (char *)de); |
177 | memset(de, 0, d_size); | 178 | memset(de, 0, d_size); |
178 | if (down_ptr) { | 179 | if (down_ptr) { |
179 | *(int *)((char *)de + d_size - 4) = down_ptr; | 180 | *(dnode_secno *)((char *)de + d_size - 4) = cpu_to_le32(down_ptr); |
180 | de->down = 1; | 181 | de->down = 1; |
181 | } | 182 | } |
182 | de->length = d_size; | 183 | de->length = cpu_to_le16(d_size); |
183 | if (down_ptr) de->down = 1; | ||
184 | de->not_8x3 = hpfs_is_name_long(name, namelen); | 184 | de->not_8x3 = hpfs_is_name_long(name, namelen); |
185 | de->namelen = namelen; | 185 | de->namelen = namelen; |
186 | memcpy(de->name, name, namelen); | 186 | memcpy(de->name, name, namelen); |
187 | d->first_free += d_size; | 187 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + d_size); |
188 | return de; | 188 | return de; |
189 | } | 189 | } |
190 | 190 | ||
@@ -194,25 +194,25 @@ static void hpfs_delete_de(struct super_block *s, struct dnode *d, | |||
194 | struct hpfs_dirent *de) | 194 | struct hpfs_dirent *de) |
195 | { | 195 | { |
196 | if (de->last) { | 196 | if (de->last) { |
197 | hpfs_error(s, "attempt to delete last dirent in dnode %08x", d->self); | 197 | hpfs_error(s, "attempt to delete last dirent in dnode %08x", le32_to_cpu(d->self)); |
198 | return; | 198 | return; |
199 | } | 199 | } |
200 | d->first_free -= de->length; | 200 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - le16_to_cpu(de->length)); |
201 | memmove(de, de_next_de(de), d->first_free + (char *)d - (char *)de); | 201 | memmove(de, de_next_de(de), le32_to_cpu(d->first_free) + (char *)d - (char *)de); |
202 | } | 202 | } |
203 | 203 | ||
204 | static void fix_up_ptrs(struct super_block *s, struct dnode *d) | 204 | static void fix_up_ptrs(struct super_block *s, struct dnode *d) |
205 | { | 205 | { |
206 | struct hpfs_dirent *de; | 206 | struct hpfs_dirent *de; |
207 | struct hpfs_dirent *de_end = dnode_end_de(d); | 207 | struct hpfs_dirent *de_end = dnode_end_de(d); |
208 | dnode_secno dno = d->self; | 208 | dnode_secno dno = le32_to_cpu(d->self); |
209 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) | 209 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) |
210 | if (de->down) { | 210 | if (de->down) { |
211 | struct quad_buffer_head qbh; | 211 | struct quad_buffer_head qbh; |
212 | struct dnode *dd; | 212 | struct dnode *dd; |
213 | if ((dd = hpfs_map_dnode(s, de_down_pointer(de), &qbh))) { | 213 | if ((dd = hpfs_map_dnode(s, de_down_pointer(de), &qbh))) { |
214 | if (dd->up != dno || dd->root_dnode) { | 214 | if (le32_to_cpu(dd->up) != dno || dd->root_dnode) { |
215 | dd->up = dno; | 215 | dd->up = cpu_to_le32(dno); |
216 | dd->root_dnode = 0; | 216 | dd->root_dnode = 0; |
217 | hpfs_mark_4buffers_dirty(&qbh); | 217 | hpfs_mark_4buffers_dirty(&qbh); |
218 | } | 218 | } |
@@ -262,7 +262,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
262 | kfree(nname); | 262 | kfree(nname); |
263 | return 1; | 263 | return 1; |
264 | } | 264 | } |
265 | if (d->first_free + de_size(namelen, down_ptr) <= 2048) { | 265 | if (le32_to_cpu(d->first_free) + de_size(namelen, down_ptr) <= 2048) { |
266 | loff_t t; | 266 | loff_t t; |
267 | copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de); | 267 | copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de); |
268 | t = get_pos(d, de); | 268 | t = get_pos(d, de); |
@@ -286,11 +286,11 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
286 | kfree(nname); | 286 | kfree(nname); |
287 | return 1; | 287 | return 1; |
288 | } | 288 | } |
289 | memcpy(nd, d, d->first_free); | 289 | memcpy(nd, d, le32_to_cpu(d->first_free)); |
290 | copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); | 290 | copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); |
291 | for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); | 291 | for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); |
292 | h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; | 292 | h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; |
293 | if (!(ad = hpfs_alloc_dnode(i->i_sb, d->up, &adno, &qbh1, 0))) { | 293 | if (!(ad = hpfs_alloc_dnode(i->i_sb, le32_to_cpu(d->up), &adno, &qbh1))) { |
294 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); | 294 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); |
295 | hpfs_brelse4(&qbh); | 295 | hpfs_brelse4(&qbh); |
296 | kfree(nd); | 296 | kfree(nd); |
@@ -313,20 +313,21 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
313 | down_ptr = adno; | 313 | down_ptr = adno; |
314 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); | 314 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); |
315 | de = de_next_de(de); | 315 | de = de_next_de(de); |
316 | memmove((char *)nd + 20, de, nd->first_free + (char *)nd - (char *)de); | 316 | memmove((char *)nd + 20, de, le32_to_cpu(nd->first_free) + (char *)nd - (char *)de); |
317 | nd->first_free -= (char *)de - (char *)nd - 20; | 317 | nd->first_free = cpu_to_le32(le32_to_cpu(nd->first_free) - ((char *)de - (char *)nd - 20)); |
318 | memcpy(d, nd, nd->first_free); | 318 | memcpy(d, nd, le32_to_cpu(nd->first_free)); |
319 | for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); | 319 | for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); |
320 | fix_up_ptrs(i->i_sb, ad); | 320 | fix_up_ptrs(i->i_sb, ad); |
321 | if (!d->root_dnode) { | 321 | if (!d->root_dnode) { |
322 | dno = ad->up = d->up; | 322 | ad->up = d->up; |
323 | dno = le32_to_cpu(ad->up); | ||
323 | hpfs_mark_4buffers_dirty(&qbh); | 324 | hpfs_mark_4buffers_dirty(&qbh); |
324 | hpfs_brelse4(&qbh); | 325 | hpfs_brelse4(&qbh); |
325 | hpfs_mark_4buffers_dirty(&qbh1); | 326 | hpfs_mark_4buffers_dirty(&qbh1); |
326 | hpfs_brelse4(&qbh1); | 327 | hpfs_brelse4(&qbh1); |
327 | goto go_up; | 328 | goto go_up; |
328 | } | 329 | } |
329 | if (!(rd = hpfs_alloc_dnode(i->i_sb, d->up, &rdno, &qbh2, 0))) { | 330 | if (!(rd = hpfs_alloc_dnode(i->i_sb, le32_to_cpu(d->up), &rdno, &qbh2))) { |
330 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); | 331 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); |
331 | hpfs_brelse4(&qbh); | 332 | hpfs_brelse4(&qbh); |
332 | hpfs_brelse4(&qbh1); | 333 | hpfs_brelse4(&qbh1); |
@@ -338,7 +339,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
338 | i->i_blocks += 4; | 339 | i->i_blocks += 4; |
339 | rd->root_dnode = 1; | 340 | rd->root_dnode = 1; |
340 | rd->up = d->up; | 341 | rd->up = d->up; |
341 | if (!(fnode = hpfs_map_fnode(i->i_sb, d->up, &bh))) { | 342 | if (!(fnode = hpfs_map_fnode(i->i_sb, le32_to_cpu(d->up), &bh))) { |
342 | hpfs_free_dnode(i->i_sb, rdno); | 343 | hpfs_free_dnode(i->i_sb, rdno); |
343 | hpfs_brelse4(&qbh); | 344 | hpfs_brelse4(&qbh); |
344 | hpfs_brelse4(&qbh1); | 345 | hpfs_brelse4(&qbh1); |
@@ -347,10 +348,11 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
347 | kfree(nname); | 348 | kfree(nname); |
348 | return 1; | 349 | return 1; |
349 | } | 350 | } |
350 | fnode->u.external[0].disk_secno = rdno; | 351 | fnode->u.external[0].disk_secno = cpu_to_le32(rdno); |
351 | mark_buffer_dirty(bh); | 352 | mark_buffer_dirty(bh); |
352 | brelse(bh); | 353 | brelse(bh); |
353 | d->up = ad->up = hpfs_i(i)->i_dno = rdno; | 354 | hpfs_i(i)->i_dno = rdno; |
355 | d->up = ad->up = cpu_to_le32(rdno); | ||
354 | d->root_dnode = ad->root_dnode = 0; | 356 | d->root_dnode = ad->root_dnode = 0; |
355 | hpfs_mark_4buffers_dirty(&qbh); | 357 | hpfs_mark_4buffers_dirty(&qbh); |
356 | hpfs_brelse4(&qbh); | 358 | hpfs_brelse4(&qbh); |
@@ -373,7 +375,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
373 | 375 | ||
374 | int hpfs_add_dirent(struct inode *i, | 376 | int hpfs_add_dirent(struct inode *i, |
375 | const unsigned char *name, unsigned namelen, | 377 | const unsigned char *name, unsigned namelen, |
376 | struct hpfs_dirent *new_de, int cdepth) | 378 | struct hpfs_dirent *new_de) |
377 | { | 379 | { |
378 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); | 380 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); |
379 | struct dnode *d; | 381 | struct dnode *d; |
@@ -403,7 +405,6 @@ int hpfs_add_dirent(struct inode *i, | |||
403 | } | 405 | } |
404 | } | 406 | } |
405 | hpfs_brelse4(&qbh); | 407 | hpfs_brelse4(&qbh); |
406 | if (!cdepth) hpfs_lock_creation(i->i_sb); | ||
407 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) { | 408 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) { |
408 | c = 1; | 409 | c = 1; |
409 | goto ret; | 410 | goto ret; |
@@ -411,7 +412,6 @@ int hpfs_add_dirent(struct inode *i, | |||
411 | i->i_version++; | 412 | i->i_version++; |
412 | c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); | 413 | c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); |
413 | ret: | 414 | ret: |
414 | if (!cdepth) hpfs_unlock_creation(i->i_sb); | ||
415 | return c; | 415 | return c; |
416 | } | 416 | } |
417 | 417 | ||
@@ -437,9 +437,9 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
437 | return 0; | 437 | return 0; |
438 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 0; | 438 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 0; |
439 | if (hpfs_sb(i->i_sb)->sb_chk) { | 439 | if (hpfs_sb(i->i_sb)->sb_chk) { |
440 | if (dnode->up != chk_up) { | 440 | if (le32_to_cpu(dnode->up) != chk_up) { |
441 | hpfs_error(i->i_sb, "move_to_top: up pointer from %08x should be %08x, is %08x", | 441 | hpfs_error(i->i_sb, "move_to_top: up pointer from %08x should be %08x, is %08x", |
442 | dno, chk_up, dnode->up); | 442 | dno, chk_up, le32_to_cpu(dnode->up)); |
443 | hpfs_brelse4(&qbh); | 443 | hpfs_brelse4(&qbh); |
444 | return 0; | 444 | return 0; |
445 | } | 445 | } |
@@ -455,7 +455,7 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
455 | hpfs_brelse4(&qbh); | 455 | hpfs_brelse4(&qbh); |
456 | } | 456 | } |
457 | while (!(de = dnode_pre_last_de(dnode))) { | 457 | while (!(de = dnode_pre_last_de(dnode))) { |
458 | dnode_secno up = dnode->up; | 458 | dnode_secno up = le32_to_cpu(dnode->up); |
459 | hpfs_brelse4(&qbh); | 459 | hpfs_brelse4(&qbh); |
460 | hpfs_free_dnode(i->i_sb, dno); | 460 | hpfs_free_dnode(i->i_sb, dno); |
461 | i->i_size -= 2048; | 461 | i->i_size -= 2048; |
@@ -474,8 +474,8 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
474 | hpfs_brelse4(&qbh); | 474 | hpfs_brelse4(&qbh); |
475 | return 0; | 475 | return 0; |
476 | } | 476 | } |
477 | dnode->first_free -= 4; | 477 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); |
478 | de->length -= 4; | 478 | de->length = cpu_to_le16(le16_to_cpu(de->length) - 4); |
479 | de->down = 0; | 479 | de->down = 0; |
480 | hpfs_mark_4buffers_dirty(&qbh); | 480 | hpfs_mark_4buffers_dirty(&qbh); |
481 | dno = up; | 481 | dno = up; |
@@ -483,12 +483,12 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
483 | t = get_pos(dnode, de); | 483 | t = get_pos(dnode, de); |
484 | for_all_poss(i, hpfs_pos_subst, t, 4); | 484 | for_all_poss(i, hpfs_pos_subst, t, 4); |
485 | for_all_poss(i, hpfs_pos_subst, t + 1, 5); | 485 | for_all_poss(i, hpfs_pos_subst, t + 1, 5); |
486 | if (!(nde = kmalloc(de->length, GFP_NOFS))) { | 486 | if (!(nde = kmalloc(le16_to_cpu(de->length), GFP_NOFS))) { |
487 | hpfs_error(i->i_sb, "out of memory for dirent - directory will be corrupted"); | 487 | hpfs_error(i->i_sb, "out of memory for dirent - directory will be corrupted"); |
488 | hpfs_brelse4(&qbh); | 488 | hpfs_brelse4(&qbh); |
489 | return 0; | 489 | return 0; |
490 | } | 490 | } |
491 | memcpy(nde, de, de->length); | 491 | memcpy(nde, de, le16_to_cpu(de->length)); |
492 | ddno = de->down ? de_down_pointer(de) : 0; | 492 | ddno = de->down ? de_down_pointer(de) : 0; |
493 | hpfs_delete_de(i->i_sb, dnode, de); | 493 | hpfs_delete_de(i->i_sb, dnode, de); |
494 | set_last_pointer(i->i_sb, dnode, ddno); | 494 | set_last_pointer(i->i_sb, dnode, ddno); |
@@ -517,11 +517,11 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
517 | try_it_again: | 517 | try_it_again: |
518 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return; | 518 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return; |
519 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return; | 519 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return; |
520 | if (dnode->first_free > 56) goto end; | 520 | if (le32_to_cpu(dnode->first_free) > 56) goto end; |
521 | if (dnode->first_free == 52 || dnode->first_free == 56) { | 521 | if (le32_to_cpu(dnode->first_free) == 52 || le32_to_cpu(dnode->first_free) == 56) { |
522 | struct hpfs_dirent *de_end; | 522 | struct hpfs_dirent *de_end; |
523 | int root = dnode->root_dnode; | 523 | int root = dnode->root_dnode; |
524 | up = dnode->up; | 524 | up = le32_to_cpu(dnode->up); |
525 | de = dnode_first_de(dnode); | 525 | de = dnode_first_de(dnode); |
526 | down = de->down ? de_down_pointer(de) : 0; | 526 | down = de->down ? de_down_pointer(de) : 0; |
527 | if (hpfs_sb(i->i_sb)->sb_chk) if (root && !down) { | 527 | if (hpfs_sb(i->i_sb)->sb_chk) if (root && !down) { |
@@ -545,13 +545,13 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
545 | return; | 545 | return; |
546 | } | 546 | } |
547 | if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { | 547 | if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { |
548 | d1->up = up; | 548 | d1->up = cpu_to_le32(up); |
549 | d1->root_dnode = 1; | 549 | d1->root_dnode = 1; |
550 | hpfs_mark_4buffers_dirty(&qbh1); | 550 | hpfs_mark_4buffers_dirty(&qbh1); |
551 | hpfs_brelse4(&qbh1); | 551 | hpfs_brelse4(&qbh1); |
552 | } | 552 | } |
553 | if ((fnode = hpfs_map_fnode(i->i_sb, up, &bh))) { | 553 | if ((fnode = hpfs_map_fnode(i->i_sb, up, &bh))) { |
554 | fnode->u.external[0].disk_secno = down; | 554 | fnode->u.external[0].disk_secno = cpu_to_le32(down); |
555 | mark_buffer_dirty(bh); | 555 | mark_buffer_dirty(bh); |
556 | brelse(bh); | 556 | brelse(bh); |
557 | } | 557 | } |
@@ -570,22 +570,22 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
570 | for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | 1, ((loff_t)up << 4) | p); | 570 | for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | 1, ((loff_t)up << 4) | p); |
571 | if (!down) { | 571 | if (!down) { |
572 | de->down = 0; | 572 | de->down = 0; |
573 | de->length -= 4; | 573 | de->length = cpu_to_le16(le16_to_cpu(de->length) - 4); |
574 | dnode->first_free -= 4; | 574 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); |
575 | memmove(de_next_de(de), (char *)de_next_de(de) + 4, | 575 | memmove(de_next_de(de), (char *)de_next_de(de) + 4, |
576 | (char *)dnode + dnode->first_free - (char *)de_next_de(de)); | 576 | (char *)dnode + le32_to_cpu(dnode->first_free) - (char *)de_next_de(de)); |
577 | } else { | 577 | } else { |
578 | struct dnode *d1; | 578 | struct dnode *d1; |
579 | struct quad_buffer_head qbh1; | 579 | struct quad_buffer_head qbh1; |
580 | *(dnode_secno *) ((void *) de + de->length - 4) = down; | 580 | *(dnode_secno *) ((void *) de + le16_to_cpu(de->length) - 4) = down; |
581 | if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { | 581 | if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { |
582 | d1->up = up; | 582 | d1->up = cpu_to_le32(up); |
583 | hpfs_mark_4buffers_dirty(&qbh1); | 583 | hpfs_mark_4buffers_dirty(&qbh1); |
584 | hpfs_brelse4(&qbh1); | 584 | hpfs_brelse4(&qbh1); |
585 | } | 585 | } |
586 | } | 586 | } |
587 | } else { | 587 | } else { |
588 | hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, dnode->first_free); | 588 | hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, le32_to_cpu(dnode->first_free)); |
589 | goto end; | 589 | goto end; |
590 | } | 590 | } |
591 | 591 | ||
@@ -596,18 +596,18 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
596 | struct quad_buffer_head qbh1; | 596 | struct quad_buffer_head qbh1; |
597 | if (!de_next->down) goto endm; | 597 | if (!de_next->down) goto endm; |
598 | ndown = de_down_pointer(de_next); | 598 | ndown = de_down_pointer(de_next); |
599 | if (!(de_cp = kmalloc(de->length, GFP_NOFS))) { | 599 | if (!(de_cp = kmalloc(le16_to_cpu(de->length), GFP_NOFS))) { |
600 | printk("HPFS: out of memory for dtree balancing\n"); | 600 | printk("HPFS: out of memory for dtree balancing\n"); |
601 | goto endm; | 601 | goto endm; |
602 | } | 602 | } |
603 | memcpy(de_cp, de, de->length); | 603 | memcpy(de_cp, de, le16_to_cpu(de->length)); |
604 | hpfs_delete_de(i->i_sb, dnode, de); | 604 | hpfs_delete_de(i->i_sb, dnode, de); |
605 | hpfs_mark_4buffers_dirty(&qbh); | 605 | hpfs_mark_4buffers_dirty(&qbh); |
606 | hpfs_brelse4(&qbh); | 606 | hpfs_brelse4(&qbh); |
607 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, 4); | 607 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, 4); |
608 | for_all_poss(i, hpfs_pos_del, ((loff_t)up << 4) | p, 1); | 608 | for_all_poss(i, hpfs_pos_del, ((loff_t)up << 4) | p, 1); |
609 | if (de_cp->down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de_cp), &qbh1))) { | 609 | if (de_cp->down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de_cp), &qbh1))) { |
610 | d1->up = ndown; | 610 | d1->up = cpu_to_le32(ndown); |
611 | hpfs_mark_4buffers_dirty(&qbh1); | 611 | hpfs_mark_4buffers_dirty(&qbh1); |
612 | hpfs_brelse4(&qbh1); | 612 | hpfs_brelse4(&qbh1); |
613 | } | 613 | } |
@@ -635,7 +635,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
635 | struct hpfs_dirent *del = dnode_last_de(d1); | 635 | struct hpfs_dirent *del = dnode_last_de(d1); |
636 | dlp = del->down ? de_down_pointer(del) : 0; | 636 | dlp = del->down ? de_down_pointer(del) : 0; |
637 | if (!dlp && down) { | 637 | if (!dlp && down) { |
638 | if (d1->first_free > 2044) { | 638 | if (le32_to_cpu(d1->first_free) > 2044) { |
639 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { | 639 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { |
640 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); | 640 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); |
641 | printk("HPFS: warning: terminating balancing operation\n"); | 641 | printk("HPFS: warning: terminating balancing operation\n"); |
@@ -647,38 +647,38 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
647 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); | 647 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); |
648 | printk("HPFS: warning: goin'on\n"); | 648 | printk("HPFS: warning: goin'on\n"); |
649 | } | 649 | } |
650 | del->length += 4; | 650 | del->length = cpu_to_le16(le16_to_cpu(del->length) + 4); |
651 | del->down = 1; | 651 | del->down = 1; |
652 | d1->first_free += 4; | 652 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) + 4); |
653 | } | 653 | } |
654 | if (dlp && !down) { | 654 | if (dlp && !down) { |
655 | del->length -= 4; | 655 | del->length = cpu_to_le16(le16_to_cpu(del->length) - 4); |
656 | del->down = 0; | 656 | del->down = 0; |
657 | d1->first_free -= 4; | 657 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) - 4); |
658 | } else if (down) | 658 | } else if (down) |
659 | *(dnode_secno *) ((void *) del + del->length - 4) = down; | 659 | *(dnode_secno *) ((void *) del + le16_to_cpu(del->length) - 4) = cpu_to_le32(down); |
660 | } else goto endm; | 660 | } else goto endm; |
661 | if (!(de_cp = kmalloc(de_prev->length, GFP_NOFS))) { | 661 | if (!(de_cp = kmalloc(le16_to_cpu(de_prev->length), GFP_NOFS))) { |
662 | printk("HPFS: out of memory for dtree balancing\n"); | 662 | printk("HPFS: out of memory for dtree balancing\n"); |
663 | hpfs_brelse4(&qbh1); | 663 | hpfs_brelse4(&qbh1); |
664 | goto endm; | 664 | goto endm; |
665 | } | 665 | } |
666 | hpfs_mark_4buffers_dirty(&qbh1); | 666 | hpfs_mark_4buffers_dirty(&qbh1); |
667 | hpfs_brelse4(&qbh1); | 667 | hpfs_brelse4(&qbh1); |
668 | memcpy(de_cp, de_prev, de_prev->length); | 668 | memcpy(de_cp, de_prev, le16_to_cpu(de_prev->length)); |
669 | hpfs_delete_de(i->i_sb, dnode, de_prev); | 669 | hpfs_delete_de(i->i_sb, dnode, de_prev); |
670 | if (!de_prev->down) { | 670 | if (!de_prev->down) { |
671 | de_prev->length += 4; | 671 | de_prev->length = cpu_to_le16(le16_to_cpu(de_prev->length) + 4); |
672 | de_prev->down = 1; | 672 | de_prev->down = 1; |
673 | dnode->first_free += 4; | 673 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) + 4); |
674 | } | 674 | } |
675 | *(dnode_secno *) ((void *) de_prev + de_prev->length - 4) = ndown; | 675 | *(dnode_secno *) ((void *) de_prev + le16_to_cpu(de_prev->length) - 4) = cpu_to_le32(ndown); |
676 | hpfs_mark_4buffers_dirty(&qbh); | 676 | hpfs_mark_4buffers_dirty(&qbh); |
677 | hpfs_brelse4(&qbh); | 677 | hpfs_brelse4(&qbh); |
678 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | (p - 1), 4); | 678 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | (p - 1), 4); |
679 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, ((loff_t)up << 4) | (p - 1)); | 679 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, ((loff_t)up << 4) | (p - 1)); |
680 | if (down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de), &qbh1))) { | 680 | if (down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de), &qbh1))) { |
681 | d1->up = ndown; | 681 | d1->up = cpu_to_le32(ndown); |
682 | hpfs_mark_4buffers_dirty(&qbh1); | 682 | hpfs_mark_4buffers_dirty(&qbh1); |
683 | hpfs_brelse4(&qbh1); | 683 | hpfs_brelse4(&qbh1); |
684 | } | 684 | } |
@@ -701,7 +701,6 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
701 | { | 701 | { |
702 | struct dnode *dnode = qbh->data; | 702 | struct dnode *dnode = qbh->data; |
703 | dnode_secno down = 0; | 703 | dnode_secno down = 0; |
704 | int lock = 0; | ||
705 | loff_t t; | 704 | loff_t t; |
706 | if (de->first || de->last) { | 705 | if (de->first || de->last) { |
707 | hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno); | 706 | hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno); |
@@ -710,11 +709,8 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
710 | } | 709 | } |
711 | if (de->down) down = de_down_pointer(de); | 710 | if (de->down) down = de_down_pointer(de); |
712 | if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) { | 711 | if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) { |
713 | lock = 1; | ||
714 | hpfs_lock_creation(i->i_sb); | ||
715 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) { | 712 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) { |
716 | hpfs_brelse4(qbh); | 713 | hpfs_brelse4(qbh); |
717 | hpfs_unlock_creation(i->i_sb); | ||
718 | return 2; | 714 | return 2; |
719 | } | 715 | } |
720 | } | 716 | } |
@@ -727,11 +723,9 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
727 | dnode_secno a = move_to_top(i, down, dno); | 723 | dnode_secno a = move_to_top(i, down, dno); |
728 | for_all_poss(i, hpfs_pos_subst, 5, t); | 724 | for_all_poss(i, hpfs_pos_subst, 5, t); |
729 | if (a) delete_empty_dnode(i, a); | 725 | if (a) delete_empty_dnode(i, a); |
730 | if (lock) hpfs_unlock_creation(i->i_sb); | ||
731 | return !a; | 726 | return !a; |
732 | } | 727 | } |
733 | delete_empty_dnode(i, dno); | 728 | delete_empty_dnode(i, dno); |
734 | if (lock) hpfs_unlock_creation(i->i_sb); | ||
735 | return 0; | 729 | return 0; |
736 | } | 730 | } |
737 | 731 | ||
@@ -751,8 +745,8 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes, | |||
751 | ptr = 0; | 745 | ptr = 0; |
752 | go_up: | 746 | go_up: |
753 | if (!(dnode = hpfs_map_dnode(s, dno, &qbh))) return; | 747 | if (!(dnode = hpfs_map_dnode(s, dno, &qbh))) return; |
754 | if (hpfs_sb(s)->sb_chk) if (odno && odno != -1 && dnode->up != odno) | 748 | if (hpfs_sb(s)->sb_chk) if (odno && odno != -1 && le32_to_cpu(dnode->up) != odno) |
755 | hpfs_error(s, "hpfs_count_dnodes: bad up pointer; dnode %08x, down %08x points to %08x", odno, dno, dnode->up); | 749 | hpfs_error(s, "hpfs_count_dnodes: bad up pointer; dnode %08x, down %08x points to %08x", odno, dno, le32_to_cpu(dnode->up)); |
756 | de = dnode_first_de(dnode); | 750 | de = dnode_first_de(dnode); |
757 | if (ptr) while(1) { | 751 | if (ptr) while(1) { |
758 | if (de->down) if (de_down_pointer(de) == ptr) goto process_de; | 752 | if (de->down) if (de_down_pointer(de) == ptr) goto process_de; |
@@ -776,7 +770,7 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes, | |||
776 | if (!de->first && !de->last && n_items) (*n_items)++; | 770 | if (!de->first && !de->last && n_items) (*n_items)++; |
777 | if ((de = de_next_de(de)) < dnode_end_de(dnode)) goto next_de; | 771 | if ((de = de_next_de(de)) < dnode_end_de(dnode)) goto next_de; |
778 | ptr = dno; | 772 | ptr = dno; |
779 | dno = dnode->up; | 773 | dno = le32_to_cpu(dnode->up); |
780 | if (dnode->root_dnode) { | 774 | if (dnode->root_dnode) { |
781 | hpfs_brelse4(&qbh); | 775 | hpfs_brelse4(&qbh); |
782 | return; | 776 | return; |
@@ -824,8 +818,8 @@ dnode_secno hpfs_de_as_down_as_possible(struct super_block *s, dnode_secno dno) | |||
824 | return d; | 818 | return d; |
825 | if (!(de = map_nth_dirent(s, d, 1, &qbh, NULL))) return dno; | 819 | if (!(de = map_nth_dirent(s, d, 1, &qbh, NULL))) return dno; |
826 | if (hpfs_sb(s)->sb_chk) | 820 | if (hpfs_sb(s)->sb_chk) |
827 | if (up && ((struct dnode *)qbh.data)->up != up) | 821 | if (up && le32_to_cpu(((struct dnode *)qbh.data)->up) != up) |
828 | hpfs_error(s, "hpfs_de_as_down_as_possible: bad up pointer; dnode %08x, down %08x points to %08x", up, d, ((struct dnode *)qbh.data)->up); | 822 | hpfs_error(s, "hpfs_de_as_down_as_possible: bad up pointer; dnode %08x, down %08x points to %08x", up, d, le32_to_cpu(((struct dnode *)qbh.data)->up)); |
829 | if (!de->down) { | 823 | if (!de->down) { |
830 | hpfs_brelse4(&qbh); | 824 | hpfs_brelse4(&qbh); |
831 | return d; | 825 | return d; |
@@ -874,7 +868,7 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp, | |||
874 | /* Going up */ | 868 | /* Going up */ |
875 | if (dnode->root_dnode) goto bail; | 869 | if (dnode->root_dnode) goto bail; |
876 | 870 | ||
877 | if (!(up_dnode = hpfs_map_dnode(inode->i_sb, dnode->up, &qbh0))) | 871 | if (!(up_dnode = hpfs_map_dnode(inode->i_sb, le32_to_cpu(dnode->up), &qbh0))) |
878 | goto bail; | 872 | goto bail; |
879 | 873 | ||
880 | end_up_de = dnode_end_de(up_dnode); | 874 | end_up_de = dnode_end_de(up_dnode); |
@@ -882,16 +876,16 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp, | |||
882 | for (up_de = dnode_first_de(up_dnode); up_de < end_up_de; | 876 | for (up_de = dnode_first_de(up_dnode); up_de < end_up_de; |
883 | up_de = de_next_de(up_de)) { | 877 | up_de = de_next_de(up_de)) { |
884 | if (!(++c & 077)) hpfs_error(inode->i_sb, | 878 | if (!(++c & 077)) hpfs_error(inode->i_sb, |
885 | "map_pos_dirent: pos crossed dnode boundary; dnode = %08x", dnode->up); | 879 | "map_pos_dirent: pos crossed dnode boundary; dnode = %08x", le32_to_cpu(dnode->up)); |
886 | if (up_de->down && de_down_pointer(up_de) == dno) { | 880 | if (up_de->down && de_down_pointer(up_de) == dno) { |
887 | *posp = ((loff_t) dnode->up << 4) + c; | 881 | *posp = ((loff_t) le32_to_cpu(dnode->up) << 4) + c; |
888 | hpfs_brelse4(&qbh0); | 882 | hpfs_brelse4(&qbh0); |
889 | return de; | 883 | return de; |
890 | } | 884 | } |
891 | } | 885 | } |
892 | 886 | ||
893 | hpfs_error(inode->i_sb, "map_pos_dirent: pointer to dnode %08x not found in parent dnode %08x", | 887 | hpfs_error(inode->i_sb, "map_pos_dirent: pointer to dnode %08x not found in parent dnode %08x", |
894 | dno, dnode->up); | 888 | dno, le32_to_cpu(dnode->up)); |
895 | hpfs_brelse4(&qbh0); | 889 | hpfs_brelse4(&qbh0); |
896 | 890 | ||
897 | bail: | 891 | bail: |
@@ -1017,17 +1011,17 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1017 | /*name2[15] = 0xff;*/ | 1011 | /*name2[15] = 0xff;*/ |
1018 | name1len = 15; name2len = 256; | 1012 | name1len = 15; name2len = 256; |
1019 | } | 1013 | } |
1020 | if (!(upf = hpfs_map_fnode(s, f->up, &bh))) { | 1014 | if (!(upf = hpfs_map_fnode(s, le32_to_cpu(f->up), &bh))) { |
1021 | kfree(name2); | 1015 | kfree(name2); |
1022 | return NULL; | 1016 | return NULL; |
1023 | } | 1017 | } |
1024 | if (!upf->dirflag) { | 1018 | if (!upf->dirflag) { |
1025 | brelse(bh); | 1019 | brelse(bh); |
1026 | hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, f->up); | 1020 | hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up)); |
1027 | kfree(name2); | 1021 | kfree(name2); |
1028 | return NULL; | 1022 | return NULL; |
1029 | } | 1023 | } |
1030 | dno = upf->u.external[0].disk_secno; | 1024 | dno = le32_to_cpu(upf->u.external[0].disk_secno); |
1031 | brelse(bh); | 1025 | brelse(bh); |
1032 | go_down: | 1026 | go_down: |
1033 | downd = 0; | 1027 | downd = 0; |
@@ -1049,7 +1043,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1049 | return NULL; | 1043 | return NULL; |
1050 | } | 1044 | } |
1051 | next_de: | 1045 | next_de: |
1052 | if (de->fnode == fno) { | 1046 | if (le32_to_cpu(de->fnode) == fno) { |
1053 | kfree(name2); | 1047 | kfree(name2); |
1054 | return de; | 1048 | return de; |
1055 | } | 1049 | } |
@@ -1065,7 +1059,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1065 | goto go_down; | 1059 | goto go_down; |
1066 | } | 1060 | } |
1067 | f: | 1061 | f: |
1068 | if (de->fnode == fno) { | 1062 | if (le32_to_cpu(de->fnode) == fno) { |
1069 | kfree(name2); | 1063 | kfree(name2); |
1070 | return de; | 1064 | return de; |
1071 | } | 1065 | } |
@@ -1074,7 +1068,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1074 | if ((de = de_next_de(de)) < de_end) goto next_de; | 1068 | if ((de = de_next_de(de)) < de_end) goto next_de; |
1075 | if (d->root_dnode) goto not_found; | 1069 | if (d->root_dnode) goto not_found; |
1076 | downd = dno; | 1070 | downd = dno; |
1077 | dno = d->up; | 1071 | dno = le32_to_cpu(d->up); |
1078 | hpfs_brelse4(qbh); | 1072 | hpfs_brelse4(qbh); |
1079 | if (hpfs_sb(s)->sb_chk) | 1073 | if (hpfs_sb(s)->sb_chk) |
1080 | if (hpfs_stop_cycles(s, downd, &d1, &d2, "map_fnode_dirent #2")) { | 1074 | if (hpfs_stop_cycles(s, downd, &d1, &d2, "map_fnode_dirent #2")) { |
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c index 45e53d972b4..d8b84d113c8 100644 --- a/fs/hpfs/ea.c +++ b/fs/hpfs/ea.c | |||
@@ -24,7 +24,7 @@ void hpfs_ea_ext_remove(struct super_block *s, secno a, int ano, unsigned len) | |||
24 | } | 24 | } |
25 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; | 25 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; |
26 | if (ea->indirect) { | 26 | if (ea->indirect) { |
27 | if (ea->valuelen != 8) { | 27 | if (ea_valuelen(ea) != 8) { |
28 | hpfs_error(s, "ea->indirect set while ea->valuelen!=8, %s %08x, pos %08x", | 28 | hpfs_error(s, "ea->indirect set while ea->valuelen!=8, %s %08x, pos %08x", |
29 | ano ? "anode" : "sectors", a, pos); | 29 | ano ? "anode" : "sectors", a, pos); |
30 | return; | 30 | return; |
@@ -33,7 +33,7 @@ void hpfs_ea_ext_remove(struct super_block *s, secno a, int ano, unsigned len) | |||
33 | return; | 33 | return; |
34 | hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); | 34 | hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); |
35 | } | 35 | } |
36 | pos += ea->namelen + ea->valuelen + 5; | 36 | pos += ea->namelen + ea_valuelen(ea) + 5; |
37 | } | 37 | } |
38 | if (!ano) hpfs_free_sectors(s, a, (len+511) >> 9); | 38 | if (!ano) hpfs_free_sectors(s, a, (len+511) >> 9); |
39 | else { | 39 | else { |
@@ -76,24 +76,24 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, | |||
76 | unsigned pos; | 76 | unsigned pos; |
77 | int ano, len; | 77 | int ano, len; |
78 | secno a; | 78 | secno a; |
79 | char ex[4 + 255 + 1 + 8]; | ||
79 | struct extended_attribute *ea; | 80 | struct extended_attribute *ea; |
80 | struct extended_attribute *ea_end = fnode_end_ea(fnode); | 81 | struct extended_attribute *ea_end = fnode_end_ea(fnode); |
81 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 82 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
82 | if (!strcmp(ea->name, key)) { | 83 | if (!strcmp(ea->name, key)) { |
83 | if (ea->indirect) | 84 | if (ea->indirect) |
84 | goto indirect; | 85 | goto indirect; |
85 | if (ea->valuelen >= size) | 86 | if (ea_valuelen(ea) >= size) |
86 | return -EINVAL; | 87 | return -EINVAL; |
87 | memcpy(buf, ea_data(ea), ea->valuelen); | 88 | memcpy(buf, ea_data(ea), ea_valuelen(ea)); |
88 | buf[ea->valuelen] = 0; | 89 | buf[ea_valuelen(ea)] = 0; |
89 | return 0; | 90 | return 0; |
90 | } | 91 | } |
91 | a = fnode->ea_secno; | 92 | a = le32_to_cpu(fnode->ea_secno); |
92 | len = fnode->ea_size_l; | 93 | len = le32_to_cpu(fnode->ea_size_l); |
93 | ano = fnode->ea_anode; | 94 | ano = fnode->ea_anode; |
94 | pos = 0; | 95 | pos = 0; |
95 | while (pos < len) { | 96 | while (pos < len) { |
96 | char ex[4 + 255 + 1 + 8]; | ||
97 | ea = (struct extended_attribute *)ex; | 97 | ea = (struct extended_attribute *)ex; |
98 | if (pos + 4 > len) { | 98 | if (pos + 4 > len) { |
99 | hpfs_error(s, "EAs don't end correctly, %s %08x, len %08x", | 99 | hpfs_error(s, "EAs don't end correctly, %s %08x, len %08x", |
@@ -106,14 +106,14 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, | |||
106 | if (!strcmp(ea->name, key)) { | 106 | if (!strcmp(ea->name, key)) { |
107 | if (ea->indirect) | 107 | if (ea->indirect) |
108 | goto indirect; | 108 | goto indirect; |
109 | if (ea->valuelen >= size) | 109 | if (ea_valuelen(ea) >= size) |
110 | return -EINVAL; | 110 | return -EINVAL; |
111 | if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, ea->valuelen, buf)) | 111 | if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, ea_valuelen(ea), buf)) |
112 | return -EIO; | 112 | return -EIO; |
113 | buf[ea->valuelen] = 0; | 113 | buf[ea_valuelen(ea)] = 0; |
114 | return 0; | 114 | return 0; |
115 | } | 115 | } |
116 | pos += ea->namelen + ea->valuelen + 5; | 116 | pos += ea->namelen + ea_valuelen(ea) + 5; |
117 | } | 117 | } |
118 | return -ENOENT; | 118 | return -ENOENT; |
119 | indirect: | 119 | indirect: |
@@ -138,16 +138,16 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
138 | if (!strcmp(ea->name, key)) { | 138 | if (!strcmp(ea->name, key)) { |
139 | if (ea->indirect) | 139 | if (ea->indirect) |
140 | return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); | 140 | return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); |
141 | if (!(ret = kmalloc((*size = ea->valuelen) + 1, GFP_NOFS))) { | 141 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { |
142 | printk("HPFS: out of memory for EA\n"); | 142 | printk("HPFS: out of memory for EA\n"); |
143 | return NULL; | 143 | return NULL; |
144 | } | 144 | } |
145 | memcpy(ret, ea_data(ea), ea->valuelen); | 145 | memcpy(ret, ea_data(ea), ea_valuelen(ea)); |
146 | ret[ea->valuelen] = 0; | 146 | ret[ea_valuelen(ea)] = 0; |
147 | return ret; | 147 | return ret; |
148 | } | 148 | } |
149 | a = fnode->ea_secno; | 149 | a = le32_to_cpu(fnode->ea_secno); |
150 | len = fnode->ea_size_l; | 150 | len = le32_to_cpu(fnode->ea_size_l); |
151 | ano = fnode->ea_anode; | 151 | ano = fnode->ea_anode; |
152 | pos = 0; | 152 | pos = 0; |
153 | while (pos < len) { | 153 | while (pos < len) { |
@@ -164,18 +164,18 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
164 | if (!strcmp(ea->name, key)) { | 164 | if (!strcmp(ea->name, key)) { |
165 | if (ea->indirect) | 165 | if (ea->indirect) |
166 | return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); | 166 | return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); |
167 | if (!(ret = kmalloc((*size = ea->valuelen) + 1, GFP_NOFS))) { | 167 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { |
168 | printk("HPFS: out of memory for EA\n"); | 168 | printk("HPFS: out of memory for EA\n"); |
169 | return NULL; | 169 | return NULL; |
170 | } | 170 | } |
171 | if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, ea->valuelen, ret)) { | 171 | if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, ea_valuelen(ea), ret)) { |
172 | kfree(ret); | 172 | kfree(ret); |
173 | return NULL; | 173 | return NULL; |
174 | } | 174 | } |
175 | ret[ea->valuelen] = 0; | 175 | ret[ea_valuelen(ea)] = 0; |
176 | return ret; | 176 | return ret; |
177 | } | 177 | } |
178 | pos += ea->namelen + ea->valuelen + 5; | 178 | pos += ea->namelen + ea_valuelen(ea) + 5; |
179 | } | 179 | } |
180 | return NULL; | 180 | return NULL; |
181 | } | 181 | } |
@@ -202,13 +202,13 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
202 | if (ea->indirect) { | 202 | if (ea->indirect) { |
203 | if (ea_len(ea) == size) | 203 | if (ea_len(ea) == size) |
204 | set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); | 204 | set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); |
205 | } else if (ea->valuelen == size) { | 205 | } else if (ea_valuelen(ea) == size) { |
206 | memcpy(ea_data(ea), data, size); | 206 | memcpy(ea_data(ea), data, size); |
207 | } | 207 | } |
208 | return; | 208 | return; |
209 | } | 209 | } |
210 | a = fnode->ea_secno; | 210 | a = le32_to_cpu(fnode->ea_secno); |
211 | len = fnode->ea_size_l; | 211 | len = le32_to_cpu(fnode->ea_size_l); |
212 | ano = fnode->ea_anode; | 212 | ano = fnode->ea_anode; |
213 | pos = 0; | 213 | pos = 0; |
214 | while (pos < len) { | 214 | while (pos < len) { |
@@ -228,68 +228,70 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
228 | set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); | 228 | set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); |
229 | } | 229 | } |
230 | else { | 230 | else { |
231 | if (ea->valuelen == size) | 231 | if (ea_valuelen(ea) == size) |
232 | hpfs_ea_write(s, a, ano, pos + 4 + ea->namelen + 1, size, data); | 232 | hpfs_ea_write(s, a, ano, pos + 4 + ea->namelen + 1, size, data); |
233 | } | 233 | } |
234 | return; | 234 | return; |
235 | } | 235 | } |
236 | pos += ea->namelen + ea->valuelen + 5; | 236 | pos += ea->namelen + ea_valuelen(ea) + 5; |
237 | } | 237 | } |
238 | if (!fnode->ea_offs) { | 238 | if (!le16_to_cpu(fnode->ea_offs)) { |
239 | /*if (fnode->ea_size_s) { | 239 | /*if (le16_to_cpu(fnode->ea_size_s)) { |
240 | hpfs_error(s, "fnode %08x: ea_size_s == %03x, ea_offs == 0", | 240 | hpfs_error(s, "fnode %08x: ea_size_s == %03x, ea_offs == 0", |
241 | inode->i_ino, fnode->ea_size_s); | 241 | inode->i_ino, le16_to_cpu(fnode->ea_size_s)); |
242 | return; | 242 | return; |
243 | }*/ | 243 | }*/ |
244 | fnode->ea_offs = 0xc4; | 244 | fnode->ea_offs = cpu_to_le16(0xc4); |
245 | } | 245 | } |
246 | if (fnode->ea_offs < 0xc4 || fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200) { | 246 | if (le16_to_cpu(fnode->ea_offs) < 0xc4 || le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) > 0x200) { |
247 | hpfs_error(s, "fnode %08lx: ea_offs == %03x, ea_size_s == %03x", | 247 | hpfs_error(s, "fnode %08lx: ea_offs == %03x, ea_size_s == %03x", |
248 | (unsigned long)inode->i_ino, | 248 | (unsigned long)inode->i_ino, |
249 | fnode->ea_offs, fnode->ea_size_s); | 249 | le32_to_cpu(fnode->ea_offs), le16_to_cpu(fnode->ea_size_s)); |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | if ((fnode->ea_size_s || !fnode->ea_size_l) && | 252 | if ((le16_to_cpu(fnode->ea_size_s) || !le32_to_cpu(fnode->ea_size_l)) && |
253 | fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s + strlen(key) + size + 5 <= 0x200) { | 253 | le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) + strlen(key) + size + 5 <= 0x200) { |
254 | ea = fnode_end_ea(fnode); | 254 | ea = fnode_end_ea(fnode); |
255 | *(char *)ea = 0; | 255 | *(char *)ea = 0; |
256 | ea->namelen = strlen(key); | 256 | ea->namelen = strlen(key); |
257 | ea->valuelen = size; | 257 | ea->valuelen_lo = size; |
258 | ea->valuelen_hi = size >> 8; | ||
258 | strcpy(ea->name, key); | 259 | strcpy(ea->name, key); |
259 | memcpy(ea_data(ea), data, size); | 260 | memcpy(ea_data(ea), data, size); |
260 | fnode->ea_size_s += strlen(key) + size + 5; | 261 | fnode->ea_size_s = cpu_to_le16(le16_to_cpu(fnode->ea_size_s) + strlen(key) + size + 5); |
261 | goto ret; | 262 | goto ret; |
262 | } | 263 | } |
263 | /* Most the code here is 99.9993422% unused. I hope there are no bugs. | 264 | /* Most the code here is 99.9993422% unused. I hope there are no bugs. |
264 | But what .. HPFS.IFS has also bugs in ea management. */ | 265 | But what .. HPFS.IFS has also bugs in ea management. */ |
265 | if (fnode->ea_size_s && !fnode->ea_size_l) { | 266 | if (le16_to_cpu(fnode->ea_size_s) && !le32_to_cpu(fnode->ea_size_l)) { |
266 | secno n; | 267 | secno n; |
267 | struct buffer_head *bh; | 268 | struct buffer_head *bh; |
268 | char *data; | 269 | char *data; |
269 | if (!(n = hpfs_alloc_sector(s, fno, 1, 0, 1))) return; | 270 | if (!(n = hpfs_alloc_sector(s, fno, 1, 0))) return; |
270 | if (!(data = hpfs_get_sector(s, n, &bh))) { | 271 | if (!(data = hpfs_get_sector(s, n, &bh))) { |
271 | hpfs_free_sectors(s, n, 1); | 272 | hpfs_free_sectors(s, n, 1); |
272 | return; | 273 | return; |
273 | } | 274 | } |
274 | memcpy(data, fnode_ea(fnode), fnode->ea_size_s); | 275 | memcpy(data, fnode_ea(fnode), le16_to_cpu(fnode->ea_size_s)); |
275 | fnode->ea_size_l = fnode->ea_size_s; | 276 | fnode->ea_size_l = cpu_to_le32(le16_to_cpu(fnode->ea_size_s)); |
276 | fnode->ea_size_s = 0; | 277 | fnode->ea_size_s = cpu_to_le16(0); |
277 | fnode->ea_secno = n; | 278 | fnode->ea_secno = cpu_to_le32(n); |
278 | fnode->ea_anode = 0; | 279 | fnode->ea_anode = cpu_to_le32(0); |
279 | mark_buffer_dirty(bh); | 280 | mark_buffer_dirty(bh); |
280 | brelse(bh); | 281 | brelse(bh); |
281 | } | 282 | } |
282 | pos = fnode->ea_size_l + 5 + strlen(key) + size; | 283 | pos = le32_to_cpu(fnode->ea_size_l) + 5 + strlen(key) + size; |
283 | len = (fnode->ea_size_l + 511) >> 9; | 284 | len = (le32_to_cpu(fnode->ea_size_l) + 511) >> 9; |
284 | if (pos >= 30000) goto bail; | 285 | if (pos >= 30000) goto bail; |
285 | while (((pos + 511) >> 9) > len) { | 286 | while (((pos + 511) >> 9) > len) { |
286 | if (!len) { | 287 | if (!len) { |
287 | if (!(fnode->ea_secno = hpfs_alloc_sector(s, fno, 1, 0, 1))) | 288 | secno q = hpfs_alloc_sector(s, fno, 1, 0); |
288 | goto bail; | 289 | if (!q) goto bail; |
290 | fnode->ea_secno = cpu_to_le32(q); | ||
289 | fnode->ea_anode = 0; | 291 | fnode->ea_anode = 0; |
290 | len++; | 292 | len++; |
291 | } else if (!fnode->ea_anode) { | 293 | } else if (!fnode->ea_anode) { |
292 | if (hpfs_alloc_if_possible(s, fnode->ea_secno + len)) { | 294 | if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) { |
293 | len++; | 295 | len++; |
294 | } else { | 296 | } else { |
295 | /* Aargh... don't know how to create ea anodes :-( */ | 297 | /* Aargh... don't know how to create ea anodes :-( */ |
@@ -298,26 +300,26 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
298 | anode_secno a_s; | 300 | anode_secno a_s; |
299 | if (!(anode = hpfs_alloc_anode(s, fno, &a_s, &bh))) | 301 | if (!(anode = hpfs_alloc_anode(s, fno, &a_s, &bh))) |
300 | goto bail; | 302 | goto bail; |
301 | anode->up = fno; | 303 | anode->up = cpu_to_le32(fno); |
302 | anode->btree.fnode_parent = 1; | 304 | anode->btree.fnode_parent = 1; |
303 | anode->btree.n_free_nodes--; | 305 | anode->btree.n_free_nodes--; |
304 | anode->btree.n_used_nodes++; | 306 | anode->btree.n_used_nodes++; |
305 | anode->btree.first_free += 12; | 307 | anode->btree.first_free = cpu_to_le16(le16_to_cpu(anode->btree.first_free) + 12); |
306 | anode->u.external[0].disk_secno = fnode->ea_secno; | 308 | anode->u.external[0].disk_secno = cpu_to_le32(le32_to_cpu(fnode->ea_secno)); |
307 | anode->u.external[0].file_secno = 0; | 309 | anode->u.external[0].file_secno = cpu_to_le32(0); |
308 | anode->u.external[0].length = len; | 310 | anode->u.external[0].length = cpu_to_le32(len); |
309 | mark_buffer_dirty(bh); | 311 | mark_buffer_dirty(bh); |
310 | brelse(bh); | 312 | brelse(bh); |
311 | fnode->ea_anode = 1; | 313 | fnode->ea_anode = 1; |
312 | fnode->ea_secno = a_s;*/ | 314 | fnode->ea_secno = cpu_to_le32(a_s);*/ |
313 | secno new_sec; | 315 | secno new_sec; |
314 | int i; | 316 | int i; |
315 | if (!(new_sec = hpfs_alloc_sector(s, fno, 1, 1 - ((pos + 511) >> 9), 1))) | 317 | if (!(new_sec = hpfs_alloc_sector(s, fno, 1, 1 - ((pos + 511) >> 9)))) |
316 | goto bail; | 318 | goto bail; |
317 | for (i = 0; i < len; i++) { | 319 | for (i = 0; i < len; i++) { |
318 | struct buffer_head *bh1, *bh2; | 320 | struct buffer_head *bh1, *bh2; |
319 | void *b1, *b2; | 321 | void *b1, *b2; |
320 | if (!(b1 = hpfs_map_sector(s, fnode->ea_secno + i, &bh1, len - i - 1))) { | 322 | if (!(b1 = hpfs_map_sector(s, le32_to_cpu(fnode->ea_secno) + i, &bh1, len - i - 1))) { |
321 | hpfs_free_sectors(s, new_sec, (pos + 511) >> 9); | 323 | hpfs_free_sectors(s, new_sec, (pos + 511) >> 9); |
322 | goto bail; | 324 | goto bail; |
323 | } | 325 | } |
@@ -331,13 +333,13 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
331 | mark_buffer_dirty(bh2); | 333 | mark_buffer_dirty(bh2); |
332 | brelse(bh2); | 334 | brelse(bh2); |
333 | } | 335 | } |
334 | hpfs_free_sectors(s, fnode->ea_secno, len); | 336 | hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno), len); |
335 | fnode->ea_secno = new_sec; | 337 | fnode->ea_secno = cpu_to_le32(new_sec); |
336 | len = (pos + 511) >> 9; | 338 | len = (pos + 511) >> 9; |
337 | } | 339 | } |
338 | } | 340 | } |
339 | if (fnode->ea_anode) { | 341 | if (fnode->ea_anode) { |
340 | if (hpfs_add_sector_to_btree(s, fnode->ea_secno, | 342 | if (hpfs_add_sector_to_btree(s, le32_to_cpu(fnode->ea_secno), |
341 | 0, len) != -1) { | 343 | 0, len) != -1) { |
342 | len++; | 344 | len++; |
343 | } else { | 345 | } else { |
@@ -349,17 +351,17 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
349 | h[1] = strlen(key); | 351 | h[1] = strlen(key); |
350 | h[2] = size & 0xff; | 352 | h[2] = size & 0xff; |
351 | h[3] = size >> 8; | 353 | h[3] = size >> 8; |
352 | if (hpfs_ea_write(s, fnode->ea_secno, fnode->ea_anode, fnode->ea_size_l, 4, h)) goto bail; | 354 | if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail; |
353 | if (hpfs_ea_write(s, fnode->ea_secno, fnode->ea_anode, fnode->ea_size_l + 4, h[1] + 1, key)) goto bail; | 355 | if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 4, h[1] + 1, key)) goto bail; |
354 | if (hpfs_ea_write(s, fnode->ea_secno, fnode->ea_anode, fnode->ea_size_l + 5 + h[1], size, data)) goto bail; | 356 | if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail; |
355 | fnode->ea_size_l = pos; | 357 | fnode->ea_size_l = cpu_to_le32(pos); |
356 | ret: | 358 | ret: |
357 | hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size; | 359 | hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size; |
358 | return; | 360 | return; |
359 | bail: | 361 | bail: |
360 | if (fnode->ea_secno) | 362 | if (le32_to_cpu(fnode->ea_secno)) |
361 | if (fnode->ea_anode) hpfs_truncate_btree(s, fnode->ea_secno, 1, (fnode->ea_size_l + 511) >> 9); | 363 | if (fnode->ea_anode) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9); |
362 | else hpfs_free_sectors(s, fnode->ea_secno + ((fnode->ea_size_l + 511) >> 9), len - ((fnode->ea_size_l + 511) >> 9)); | 364 | else hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno) + ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9), len - ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9)); |
363 | else fnode->ea_secno = fnode->ea_size_l = 0; | 365 | else fnode->ea_secno = fnode->ea_size_l = cpu_to_le32(0); |
364 | } | 366 | } |
365 | 367 | ||
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c index 9b9eb6933e4..89c500ee521 100644 --- a/fs/hpfs/file.c +++ b/fs/hpfs/file.c | |||
@@ -20,8 +20,8 @@ static int hpfs_file_release(struct inode *inode, struct file *file) | |||
20 | 20 | ||
21 | int hpfs_file_fsync(struct file *file, int datasync) | 21 | int hpfs_file_fsync(struct file *file, int datasync) |
22 | { | 22 | { |
23 | /*return file_fsync(file, datasync);*/ | 23 | struct inode *inode = file->f_mapping->host; |
24 | return 0; /* Don't fsync :-) */ | 24 | return sync_blockdev(inode->i_sb->s_bdev); |
25 | } | 25 | } |
26 | 26 | ||
27 | /* | 27 | /* |
@@ -48,38 +48,46 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno) | |||
48 | static void hpfs_truncate(struct inode *i) | 48 | static void hpfs_truncate(struct inode *i) |
49 | { | 49 | { |
50 | if (IS_IMMUTABLE(i)) return /*-EPERM*/; | 50 | if (IS_IMMUTABLE(i)) return /*-EPERM*/; |
51 | hpfs_lock(i->i_sb); | 51 | hpfs_lock_assert(i->i_sb); |
52 | |||
52 | hpfs_i(i)->i_n_secs = 0; | 53 | hpfs_i(i)->i_n_secs = 0; |
53 | i->i_blocks = 1 + ((i->i_size + 511) >> 9); | 54 | i->i_blocks = 1 + ((i->i_size + 511) >> 9); |
54 | hpfs_i(i)->mmu_private = i->i_size; | 55 | hpfs_i(i)->mmu_private = i->i_size; |
55 | hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9)); | 56 | hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9)); |
56 | hpfs_write_inode(i); | 57 | hpfs_write_inode(i); |
57 | hpfs_i(i)->i_n_secs = 0; | 58 | hpfs_i(i)->i_n_secs = 0; |
58 | hpfs_unlock(i->i_sb); | ||
59 | } | 59 | } |
60 | 60 | ||
61 | static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) | 61 | static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) |
62 | { | 62 | { |
63 | int r; | ||
63 | secno s; | 64 | secno s; |
65 | hpfs_lock(inode->i_sb); | ||
64 | s = hpfs_bmap(inode, iblock); | 66 | s = hpfs_bmap(inode, iblock); |
65 | if (s) { | 67 | if (s) { |
66 | map_bh(bh_result, inode->i_sb, s); | 68 | map_bh(bh_result, inode->i_sb, s); |
67 | return 0; | 69 | goto ret_0; |
68 | } | 70 | } |
69 | if (!create) return 0; | 71 | if (!create) goto ret_0; |
70 | if (iblock<<9 != hpfs_i(inode)->mmu_private) { | 72 | if (iblock<<9 != hpfs_i(inode)->mmu_private) { |
71 | BUG(); | 73 | BUG(); |
72 | return -EIO; | 74 | r = -EIO; |
75 | goto ret_r; | ||
73 | } | 76 | } |
74 | if ((s = hpfs_add_sector_to_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1)) == -1) { | 77 | if ((s = hpfs_add_sector_to_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1)) == -1) { |
75 | hpfs_truncate_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1); | 78 | hpfs_truncate_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1); |
76 | return -ENOSPC; | 79 | r = -ENOSPC; |
80 | goto ret_r; | ||
77 | } | 81 | } |
78 | inode->i_blocks++; | 82 | inode->i_blocks++; |
79 | hpfs_i(inode)->mmu_private += 512; | 83 | hpfs_i(inode)->mmu_private += 512; |
80 | set_buffer_new(bh_result); | 84 | set_buffer_new(bh_result); |
81 | map_bh(bh_result, inode->i_sb, s); | 85 | map_bh(bh_result, inode->i_sb, s); |
82 | return 0; | 86 | ret_0: |
87 | r = 0; | ||
88 | ret_r: | ||
89 | hpfs_unlock(inode->i_sb); | ||
90 | return r; | ||
83 | } | 91 | } |
84 | 92 | ||
85 | static int hpfs_writepage(struct page *page, struct writeback_control *wbc) | 93 | static int hpfs_writepage(struct page *page, struct writeback_control *wbc) |
@@ -130,8 +138,11 @@ static ssize_t hpfs_file_write(struct file *file, const char __user *buf, | |||
130 | ssize_t retval; | 138 | ssize_t retval; |
131 | 139 | ||
132 | retval = do_sync_write(file, buf, count, ppos); | 140 | retval = do_sync_write(file, buf, count, ppos); |
133 | if (retval > 0) | 141 | if (retval > 0) { |
142 | hpfs_lock(file->f_path.dentry->d_sb); | ||
134 | hpfs_i(file->f_path.dentry->d_inode)->i_dirty = 1; | 143 | hpfs_i(file->f_path.dentry->d_inode)->i_dirty = 1; |
144 | hpfs_unlock(file->f_path.dentry->d_sb); | ||
145 | } | ||
135 | return retval; | 146 | return retval; |
136 | } | 147 | } |
137 | 148 | ||
diff --git a/fs/hpfs/hpfs.h b/fs/hpfs/hpfs.h index 0e84c73cd9c..8b0650aae32 100644 --- a/fs/hpfs/hpfs.h +++ b/fs/hpfs/hpfs.h | |||
@@ -19,9 +19,13 @@ | |||
19 | For definitive information on HPFS, ask somebody else -- this is guesswork. | 19 | For definitive information on HPFS, ask somebody else -- this is guesswork. |
20 | There are certain to be many mistakes. */ | 20 | There are certain to be many mistakes. */ |
21 | 21 | ||
22 | #if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN) | ||
23 | #error unknown endian | ||
24 | #endif | ||
25 | |||
22 | /* Notation */ | 26 | /* Notation */ |
23 | 27 | ||
24 | typedef unsigned secno; /* sector number, partition relative */ | 28 | typedef u32 secno; /* sector number, partition relative */ |
25 | 29 | ||
26 | typedef secno dnode_secno; /* sector number of a dnode */ | 30 | typedef secno dnode_secno; /* sector number of a dnode */ |
27 | typedef secno fnode_secno; /* sector number of an fnode */ | 31 | typedef secno fnode_secno; /* sector number of an fnode */ |
@@ -38,28 +42,28 @@ typedef u32 time32_t; /* 32-bit time_t type */ | |||
38 | 42 | ||
39 | struct hpfs_boot_block | 43 | struct hpfs_boot_block |
40 | { | 44 | { |
41 | unsigned char jmp[3]; | 45 | u8 jmp[3]; |
42 | unsigned char oem_id[8]; | 46 | u8 oem_id[8]; |
43 | unsigned char bytes_per_sector[2]; /* 512 */ | 47 | u8 bytes_per_sector[2]; /* 512 */ |
44 | unsigned char sectors_per_cluster; | 48 | u8 sectors_per_cluster; |
45 | unsigned char n_reserved_sectors[2]; | 49 | u8 n_reserved_sectors[2]; |
46 | unsigned char n_fats; | 50 | u8 n_fats; |
47 | unsigned char n_rootdir_entries[2]; | 51 | u8 n_rootdir_entries[2]; |
48 | unsigned char n_sectors_s[2]; | 52 | u8 n_sectors_s[2]; |
49 | unsigned char media_byte; | 53 | u8 media_byte; |
50 | unsigned short sectors_per_fat; | 54 | u16 sectors_per_fat; |
51 | unsigned short sectors_per_track; | 55 | u16 sectors_per_track; |
52 | unsigned short heads_per_cyl; | 56 | u16 heads_per_cyl; |
53 | unsigned int n_hidden_sectors; | 57 | u32 n_hidden_sectors; |
54 | unsigned int n_sectors_l; /* size of partition */ | 58 | u32 n_sectors_l; /* size of partition */ |
55 | unsigned char drive_number; | 59 | u8 drive_number; |
56 | unsigned char mbz; | 60 | u8 mbz; |
57 | unsigned char sig_28h; /* 28h */ | 61 | u8 sig_28h; /* 28h */ |
58 | unsigned char vol_serno[4]; | 62 | u8 vol_serno[4]; |
59 | unsigned char vol_label[11]; | 63 | u8 vol_label[11]; |
60 | unsigned char sig_hpfs[8]; /* "HPFS " */ | 64 | u8 sig_hpfs[8]; /* "HPFS " */ |
61 | unsigned char pad[448]; | 65 | u8 pad[448]; |
62 | unsigned short magic; /* aa55 */ | 66 | u16 magic; /* aa55 */ |
63 | }; | 67 | }; |
64 | 68 | ||
65 | 69 | ||
@@ -71,31 +75,29 @@ struct hpfs_boot_block | |||
71 | 75 | ||
72 | struct hpfs_super_block | 76 | struct hpfs_super_block |
73 | { | 77 | { |
74 | unsigned magic; /* f995 e849 */ | 78 | u32 magic; /* f995 e849 */ |
75 | unsigned magic1; /* fa53 e9c5, more magic? */ | 79 | u32 magic1; /* fa53 e9c5, more magic? */ |
76 | /*unsigned huh202;*/ /* ?? 202 = N. of B. in 1.00390625 S.*/ | 80 | u8 version; /* version of a filesystem usually 2 */ |
77 | char version; /* version of a filesystem usually 2 */ | 81 | u8 funcversion; /* functional version - oldest version |
78 | char funcversion; /* functional version - oldest version | ||
79 | of filesystem that can understand | 82 | of filesystem that can understand |
80 | this disk */ | 83 | this disk */ |
81 | unsigned short int zero; /* 0 */ | 84 | u16 zero; /* 0 */ |
82 | fnode_secno root; /* fnode of root directory */ | 85 | fnode_secno root; /* fnode of root directory */ |
83 | secno n_sectors; /* size of filesystem */ | 86 | secno n_sectors; /* size of filesystem */ |
84 | unsigned n_badblocks; /* number of bad blocks */ | 87 | u32 n_badblocks; /* number of bad blocks */ |
85 | secno bitmaps; /* pointers to free space bit maps */ | 88 | secno bitmaps; /* pointers to free space bit maps */ |
86 | unsigned zero1; /* 0 */ | 89 | u32 zero1; /* 0 */ |
87 | secno badblocks; /* bad block list */ | 90 | secno badblocks; /* bad block list */ |
88 | unsigned zero3; /* 0 */ | 91 | u32 zero3; /* 0 */ |
89 | time32_t last_chkdsk; /* date last checked, 0 if never */ | 92 | time32_t last_chkdsk; /* date last checked, 0 if never */ |
90 | /*unsigned zero4;*/ /* 0 */ | 93 | time32_t last_optimize; /* date last optimized, 0 if never */ |
91 | time32_t last_optimize; /* date last optimized, 0 if never */ | ||
92 | secno n_dir_band; /* number of sectors in dir band */ | 94 | secno n_dir_band; /* number of sectors in dir band */ |
93 | secno dir_band_start; /* first sector in dir band */ | 95 | secno dir_band_start; /* first sector in dir band */ |
94 | secno dir_band_end; /* last sector in dir band */ | 96 | secno dir_band_end; /* last sector in dir band */ |
95 | secno dir_band_bitmap; /* free space map, 1 dnode per bit */ | 97 | secno dir_band_bitmap; /* free space map, 1 dnode per bit */ |
96 | char volume_name[32]; /* not used */ | 98 | u8 volume_name[32]; /* not used */ |
97 | secno user_id_table; /* 8 preallocated sectors - user id */ | 99 | secno user_id_table; /* 8 preallocated sectors - user id */ |
98 | unsigned zero6[103]; /* 0 */ | 100 | u32 zero6[103]; /* 0 */ |
99 | }; | 101 | }; |
100 | 102 | ||
101 | 103 | ||
@@ -107,44 +109,65 @@ struct hpfs_super_block | |||
107 | 109 | ||
108 | struct hpfs_spare_block | 110 | struct hpfs_spare_block |
109 | { | 111 | { |
110 | unsigned magic; /* f991 1849 */ | 112 | u32 magic; /* f991 1849 */ |
111 | unsigned magic1; /* fa52 29c5, more magic? */ | 113 | u32 magic1; /* fa52 29c5, more magic? */ |
112 | 114 | ||
113 | unsigned dirty: 1; /* 0 clean, 1 "improperly stopped" */ | 115 | #ifdef __LITTLE_ENDIAN |
114 | /*unsigned flag1234: 4;*/ /* unknown flags */ | 116 | u8 dirty: 1; /* 0 clean, 1 "improperly stopped" */ |
115 | unsigned sparedir_used: 1; /* spare dirblks used */ | 117 | u8 sparedir_used: 1; /* spare dirblks used */ |
116 | unsigned hotfixes_used: 1; /* hotfixes used */ | 118 | u8 hotfixes_used: 1; /* hotfixes used */ |
117 | unsigned bad_sector: 1; /* bad sector, corrupted disk (???) */ | 119 | u8 bad_sector: 1; /* bad sector, corrupted disk (???) */ |
118 | unsigned bad_bitmap: 1; /* bad bitmap */ | 120 | u8 bad_bitmap: 1; /* bad bitmap */ |
119 | unsigned fast: 1; /* partition was fast formatted */ | 121 | u8 fast: 1; /* partition was fast formatted */ |
120 | unsigned old_wrote: 1; /* old version wrote to partion */ | 122 | u8 old_wrote: 1; /* old version wrote to partion */ |
121 | unsigned old_wrote_1: 1; /* old version wrote to partion (?) */ | 123 | u8 old_wrote_1: 1; /* old version wrote to partion (?) */ |
122 | unsigned install_dasd_limits: 1; /* HPFS386 flags */ | 124 | #else |
123 | unsigned resynch_dasd_limits: 1; | 125 | u8 old_wrote_1: 1; /* old version wrote to partion (?) */ |
124 | unsigned dasd_limits_operational: 1; | 126 | u8 old_wrote: 1; /* old version wrote to partion */ |
125 | unsigned multimedia_active: 1; | 127 | u8 fast: 1; /* partition was fast formatted */ |
126 | unsigned dce_acls_active: 1; | 128 | u8 bad_bitmap: 1; /* bad bitmap */ |
127 | unsigned dasd_limits_dirty: 1; | 129 | u8 bad_sector: 1; /* bad sector, corrupted disk (???) */ |
128 | unsigned flag67: 2; | 130 | u8 hotfixes_used: 1; /* hotfixes used */ |
129 | unsigned char mm_contlgulty; | 131 | u8 sparedir_used: 1; /* spare dirblks used */ |
130 | unsigned char unused; | 132 | u8 dirty: 1; /* 0 clean, 1 "improperly stopped" */ |
133 | #endif | ||
134 | |||
135 | #ifdef __LITTLE_ENDIAN | ||
136 | u8 install_dasd_limits: 1; /* HPFS386 flags */ | ||
137 | u8 resynch_dasd_limits: 1; | ||
138 | u8 dasd_limits_operational: 1; | ||
139 | u8 multimedia_active: 1; | ||
140 | u8 dce_acls_active: 1; | ||
141 | u8 dasd_limits_dirty: 1; | ||
142 | u8 flag67: 2; | ||
143 | #else | ||
144 | u8 flag67: 2; | ||
145 | u8 dasd_limits_dirty: 1; | ||
146 | u8 dce_acls_active: 1; | ||
147 | u8 multimedia_active: 1; | ||
148 | u8 dasd_limits_operational: 1; | ||
149 | u8 resynch_dasd_limits: 1; | ||
150 | u8 install_dasd_limits: 1; /* HPFS386 flags */ | ||
151 | #endif | ||
152 | |||
153 | u8 mm_contlgulty; | ||
154 | u8 unused; | ||
131 | 155 | ||
132 | secno hotfix_map; /* info about remapped bad sectors */ | 156 | secno hotfix_map; /* info about remapped bad sectors */ |
133 | unsigned n_spares_used; /* number of hotfixes */ | 157 | u32 n_spares_used; /* number of hotfixes */ |
134 | unsigned n_spares; /* number of spares in hotfix map */ | 158 | u32 n_spares; /* number of spares in hotfix map */ |
135 | unsigned n_dnode_spares_free; /* spare dnodes unused */ | 159 | u32 n_dnode_spares_free; /* spare dnodes unused */ |
136 | unsigned n_dnode_spares; /* length of spare_dnodes[] list, | 160 | u32 n_dnode_spares; /* length of spare_dnodes[] list, |
137 | follows in this block*/ | 161 | follows in this block*/ |
138 | secno code_page_dir; /* code page directory block */ | 162 | secno code_page_dir; /* code page directory block */ |
139 | unsigned n_code_pages; /* number of code pages */ | 163 | u32 n_code_pages; /* number of code pages */ |
140 | /*unsigned large_numbers[2];*/ /* ?? */ | 164 | u32 super_crc; /* on HPFS386 and LAN Server this is |
141 | unsigned super_crc; /* on HPFS386 and LAN Server this is | ||
142 | checksum of superblock, on normal | 165 | checksum of superblock, on normal |
143 | OS/2 unused */ | 166 | OS/2 unused */ |
144 | unsigned spare_crc; /* on HPFS386 checksum of spareblock */ | 167 | u32 spare_crc; /* on HPFS386 checksum of spareblock */ |
145 | unsigned zero1[15]; /* unused */ | 168 | u32 zero1[15]; /* unused */ |
146 | dnode_secno spare_dnodes[100]; /* emergency free dnode list */ | 169 | dnode_secno spare_dnodes[100]; /* emergency free dnode list */ |
147 | unsigned zero2[1]; /* room for more? */ | 170 | u32 zero2[1]; /* room for more? */ |
148 | }; | 171 | }; |
149 | 172 | ||
150 | /* The bad block list is 4 sectors long. The first word must be zero, | 173 | /* The bad block list is 4 sectors long. The first word must be zero, |
@@ -179,18 +202,18 @@ struct hpfs_spare_block | |||
179 | 202 | ||
180 | struct code_page_directory | 203 | struct code_page_directory |
181 | { | 204 | { |
182 | unsigned magic; /* 4945 21f7 */ | 205 | u32 magic; /* 4945 21f7 */ |
183 | unsigned n_code_pages; /* number of pointers following */ | 206 | u32 n_code_pages; /* number of pointers following */ |
184 | unsigned zero1[2]; | 207 | u32 zero1[2]; |
185 | struct { | 208 | struct { |
186 | unsigned short ix; /* index */ | 209 | u16 ix; /* index */ |
187 | unsigned short code_page_number; /* code page number */ | 210 | u16 code_page_number; /* code page number */ |
188 | unsigned bounds; /* matches corresponding word | 211 | u32 bounds; /* matches corresponding word |
189 | in data block */ | 212 | in data block */ |
190 | secno code_page_data; /* sector number of a code_page_data | 213 | secno code_page_data; /* sector number of a code_page_data |
191 | containing c.p. array */ | 214 | containing c.p. array */ |
192 | unsigned short index; /* index in c.p. array in that sector*/ | 215 | u16 index; /* index in c.p. array in that sector*/ |
193 | unsigned short unknown; /* some unknown value; usually 0; | 216 | u16 unknown; /* some unknown value; usually 0; |
194 | 2 in Japanese version */ | 217 | 2 in Japanese version */ |
195 | } array[31]; /* unknown length */ | 218 | } array[31]; /* unknown length */ |
196 | }; | 219 | }; |
@@ -201,21 +224,21 @@ struct code_page_directory | |||
201 | 224 | ||
202 | struct code_page_data | 225 | struct code_page_data |
203 | { | 226 | { |
204 | unsigned magic; /* 8945 21f7 */ | 227 | u32 magic; /* 8945 21f7 */ |
205 | unsigned n_used; /* # elements used in c_p_data[] */ | 228 | u32 n_used; /* # elements used in c_p_data[] */ |
206 | unsigned bounds[3]; /* looks a bit like | 229 | u32 bounds[3]; /* looks a bit like |
207 | (beg1,end1), (beg2,end2) | 230 | (beg1,end1), (beg2,end2) |
208 | one byte each */ | 231 | one byte each */ |
209 | unsigned short offs[3]; /* offsets from start of sector | 232 | u16 offs[3]; /* offsets from start of sector |
210 | to start of c_p_data[ix] */ | 233 | to start of c_p_data[ix] */ |
211 | struct { | 234 | struct { |
212 | unsigned short ix; /* index */ | 235 | u16 ix; /* index */ |
213 | unsigned short code_page_number; /* code page number */ | 236 | u16 code_page_number; /* code page number */ |
214 | unsigned short unknown; /* the same as in cp directory */ | 237 | u16 unknown; /* the same as in cp directory */ |
215 | unsigned char map[128]; /* upcase table for chars 80..ff */ | 238 | u8 map[128]; /* upcase table for chars 80..ff */ |
216 | unsigned short zero2; | 239 | u16 zero2; |
217 | } code_page[3]; | 240 | } code_page[3]; |
218 | unsigned char incognita[78]; | 241 | u8 incognita[78]; |
219 | }; | 242 | }; |
220 | 243 | ||
221 | 244 | ||
@@ -255,50 +278,84 @@ struct code_page_data | |||
255 | #define DNODE_MAGIC 0x77e40aae | 278 | #define DNODE_MAGIC 0x77e40aae |
256 | 279 | ||
257 | struct dnode { | 280 | struct dnode { |
258 | unsigned magic; /* 77e4 0aae */ | 281 | u32 magic; /* 77e4 0aae */ |
259 | unsigned first_free; /* offset from start of dnode to | 282 | u32 first_free; /* offset from start of dnode to |
260 | first free dir entry */ | 283 | first free dir entry */ |
261 | unsigned root_dnode:1; /* Is it root dnode? */ | 284 | #ifdef __LITTLE_ENDIAN |
262 | unsigned increment_me:31; /* some kind of activity counter? | 285 | u8 root_dnode: 1; /* Is it root dnode? */ |
263 | Neither HPFS.IFS nor CHKDSK cares | 286 | u8 increment_me: 7; /* some kind of activity counter? */ |
287 | /* Neither HPFS.IFS nor CHKDSK cares | ||
288 | if you change this word */ | ||
289 | #else | ||
290 | u8 increment_me: 7; /* some kind of activity counter? */ | ||
291 | /* Neither HPFS.IFS nor CHKDSK cares | ||
264 | if you change this word */ | 292 | if you change this word */ |
293 | u8 root_dnode: 1; /* Is it root dnode? */ | ||
294 | #endif | ||
295 | u8 increment_me2[3]; | ||
265 | secno up; /* (root dnode) directory's fnode | 296 | secno up; /* (root dnode) directory's fnode |
266 | (nonroot) parent dnode */ | 297 | (nonroot) parent dnode */ |
267 | dnode_secno self; /* pointer to this dnode */ | 298 | dnode_secno self; /* pointer to this dnode */ |
268 | unsigned char dirent[2028]; /* one or more dirents */ | 299 | u8 dirent[2028]; /* one or more dirents */ |
269 | }; | 300 | }; |
270 | 301 | ||
271 | struct hpfs_dirent { | 302 | struct hpfs_dirent { |
272 | unsigned short length; /* offset to next dirent */ | 303 | u16 length; /* offset to next dirent */ |
273 | unsigned first: 1; /* set on phony ^A^A (".") entry */ | 304 | |
274 | unsigned has_acl: 1; | 305 | #ifdef __LITTLE_ENDIAN |
275 | unsigned down: 1; /* down pointer present (after name) */ | 306 | u8 first: 1; /* set on phony ^A^A (".") entry */ |
276 | unsigned last: 1; /* set on phony \377 entry */ | 307 | u8 has_acl: 1; |
277 | unsigned has_ea: 1; /* entry has EA */ | 308 | u8 down: 1; /* down pointer present (after name) */ |
278 | unsigned has_xtd_perm: 1; /* has extended perm list (???) */ | 309 | u8 last: 1; /* set on phony \377 entry */ |
279 | unsigned has_explicit_acl: 1; | 310 | u8 has_ea: 1; /* entry has EA */ |
280 | unsigned has_needea: 1; /* ?? some EA has NEEDEA set | 311 | u8 has_xtd_perm: 1; /* has extended perm list (???) */ |
312 | u8 has_explicit_acl: 1; | ||
313 | u8 has_needea: 1; /* ?? some EA has NEEDEA set | ||
314 | I have no idea why this is | ||
315 | interesting in a dir entry */ | ||
316 | #else | ||
317 | u8 has_needea: 1; /* ?? some EA has NEEDEA set | ||
281 | I have no idea why this is | 318 | I have no idea why this is |
282 | interesting in a dir entry */ | 319 | interesting in a dir entry */ |
283 | unsigned read_only: 1; /* dos attrib */ | 320 | u8 has_explicit_acl: 1; |
284 | unsigned hidden: 1; /* dos attrib */ | 321 | u8 has_xtd_perm: 1; /* has extended perm list (???) */ |
285 | unsigned system: 1; /* dos attrib */ | 322 | u8 has_ea: 1; /* entry has EA */ |
286 | unsigned flag11: 1; /* would be volume label dos attrib */ | 323 | u8 last: 1; /* set on phony \377 entry */ |
287 | unsigned directory: 1; /* dos attrib */ | 324 | u8 down: 1; /* down pointer present (after name) */ |
288 | unsigned archive: 1; /* dos attrib */ | 325 | u8 has_acl: 1; |
289 | unsigned not_8x3: 1; /* name is not 8.3 */ | 326 | u8 first: 1; /* set on phony ^A^A (".") entry */ |
290 | unsigned flag15: 1; | 327 | #endif |
328 | |||
329 | #ifdef __LITTLE_ENDIAN | ||
330 | u8 read_only: 1; /* dos attrib */ | ||
331 | u8 hidden: 1; /* dos attrib */ | ||
332 | u8 system: 1; /* dos attrib */ | ||
333 | u8 flag11: 1; /* would be volume label dos attrib */ | ||
334 | u8 directory: 1; /* dos attrib */ | ||
335 | u8 archive: 1; /* dos attrib */ | ||
336 | u8 not_8x3: 1; /* name is not 8.3 */ | ||
337 | u8 flag15: 1; | ||
338 | #else | ||
339 | u8 flag15: 1; | ||
340 | u8 not_8x3: 1; /* name is not 8.3 */ | ||
341 | u8 archive: 1; /* dos attrib */ | ||
342 | u8 directory: 1; /* dos attrib */ | ||
343 | u8 flag11: 1; /* would be volume label dos attrib */ | ||
344 | u8 system: 1; /* dos attrib */ | ||
345 | u8 hidden: 1; /* dos attrib */ | ||
346 | u8 read_only: 1; /* dos attrib */ | ||
347 | #endif | ||
348 | |||
291 | fnode_secno fnode; /* fnode giving allocation info */ | 349 | fnode_secno fnode; /* fnode giving allocation info */ |
292 | time32_t write_date; /* mtime */ | 350 | time32_t write_date; /* mtime */ |
293 | unsigned file_size; /* file length, bytes */ | 351 | u32 file_size; /* file length, bytes */ |
294 | time32_t read_date; /* atime */ | 352 | time32_t read_date; /* atime */ |
295 | time32_t creation_date; /* ctime */ | 353 | time32_t creation_date; /* ctime */ |
296 | unsigned ea_size; /* total EA length, bytes */ | 354 | u32 ea_size; /* total EA length, bytes */ |
297 | unsigned char no_of_acls : 3; /* number of ACL's */ | 355 | u8 no_of_acls; /* number of ACL's (low 3 bits) */ |
298 | unsigned char reserver : 5; | 356 | u8 ix; /* code page index (of filename), see |
299 | unsigned char ix; /* code page index (of filename), see | ||
300 | struct code_page_data */ | 357 | struct code_page_data */ |
301 | unsigned char namelen, name[1]; /* file name */ | 358 | u8 namelen, name[1]; /* file name */ |
302 | /* dnode_secno down; btree down pointer, if present, | 359 | /* dnode_secno down; btree down pointer, if present, |
303 | follows name on next word boundary, or maybe it | 360 | follows name on next word boundary, or maybe it |
304 | precedes next dirent, which is on a word boundary. */ | 361 | precedes next dirent, which is on a word boundary. */ |
@@ -318,38 +375,50 @@ struct hpfs_dirent { | |||
318 | 375 | ||
319 | struct bplus_leaf_node | 376 | struct bplus_leaf_node |
320 | { | 377 | { |
321 | unsigned file_secno; /* first file sector in extent */ | 378 | u32 file_secno; /* first file sector in extent */ |
322 | unsigned length; /* length, sectors */ | 379 | u32 length; /* length, sectors */ |
323 | secno disk_secno; /* first corresponding disk sector */ | 380 | secno disk_secno; /* first corresponding disk sector */ |
324 | }; | 381 | }; |
325 | 382 | ||
326 | struct bplus_internal_node | 383 | struct bplus_internal_node |
327 | { | 384 | { |
328 | unsigned file_secno; /* subtree maps sectors < this */ | 385 | u32 file_secno; /* subtree maps sectors < this */ |
329 | anode_secno down; /* pointer to subtree */ | 386 | anode_secno down; /* pointer to subtree */ |
330 | }; | 387 | }; |
331 | 388 | ||
332 | struct bplus_header | 389 | struct bplus_header |
333 | { | 390 | { |
334 | unsigned hbff: 1; /* high bit of first free entry offset */ | 391 | #ifdef __LITTLE_ENDIAN |
335 | unsigned flag1: 1; | 392 | u8 hbff: 1; /* high bit of first free entry offset */ |
336 | unsigned flag2: 1; | 393 | u8 flag1234: 4; |
337 | unsigned flag3: 1; | 394 | u8 fnode_parent: 1; /* ? we're pointed to by an fnode, |
338 | unsigned flag4: 1; | ||
339 | unsigned fnode_parent: 1; /* ? we're pointed to by an fnode, | ||
340 | the data btree or some ea or the | 395 | the data btree or some ea or the |
341 | main ea bootage pointer ea_secno */ | 396 | main ea bootage pointer ea_secno */ |
342 | /* also can get set in fnodes, which | 397 | /* also can get set in fnodes, which |
343 | may be a chkdsk glitch or may mean | 398 | may be a chkdsk glitch or may mean |
344 | this bit is irrelevant in fnodes, | 399 | this bit is irrelevant in fnodes, |
345 | or this interpretation is all wet */ | 400 | or this interpretation is all wet */ |
346 | unsigned binary_search: 1; /* suggest binary search (unused) */ | 401 | u8 binary_search: 1; /* suggest binary search (unused) */ |
347 | unsigned internal: 1; /* 1 -> (internal) tree of anodes | 402 | u8 internal: 1; /* 1 -> (internal) tree of anodes |
403 | 0 -> (leaf) list of extents */ | ||
404 | #else | ||
405 | u8 internal: 1; /* 1 -> (internal) tree of anodes | ||
348 | 0 -> (leaf) list of extents */ | 406 | 0 -> (leaf) list of extents */ |
349 | unsigned char fill[3]; | 407 | u8 binary_search: 1; /* suggest binary search (unused) */ |
350 | unsigned char n_free_nodes; /* free nodes in following array */ | 408 | u8 fnode_parent: 1; /* ? we're pointed to by an fnode, |
351 | unsigned char n_used_nodes; /* used nodes in following array */ | 409 | the data btree or some ea or the |
352 | unsigned short first_free; /* offset from start of header to | 410 | main ea bootage pointer ea_secno */ |
411 | /* also can get set in fnodes, which | ||
412 | may be a chkdsk glitch or may mean | ||
413 | this bit is irrelevant in fnodes, | ||
414 | or this interpretation is all wet */ | ||
415 | u8 flag1234: 4; | ||
416 | u8 hbff: 1; /* high bit of first free entry offset */ | ||
417 | #endif | ||
418 | u8 fill[3]; | ||
419 | u8 n_free_nodes; /* free nodes in following array */ | ||
420 | u8 n_used_nodes; /* used nodes in following array */ | ||
421 | u16 first_free; /* offset from start of header to | ||
353 | first free node in array */ | 422 | first free node in array */ |
354 | union { | 423 | union { |
355 | struct bplus_internal_node internal[0]; /* (internal) 2-word entries giving | 424 | struct bplus_internal_node internal[0]; /* (internal) 2-word entries giving |
@@ -369,37 +438,38 @@ struct bplus_header | |||
369 | 438 | ||
370 | struct fnode | 439 | struct fnode |
371 | { | 440 | { |
372 | unsigned magic; /* f7e4 0aae */ | 441 | u32 magic; /* f7e4 0aae */ |
373 | unsigned zero1[2]; /* read history */ | 442 | u32 zero1[2]; /* read history */ |
374 | unsigned char len, name[15]; /* true length, truncated name */ | 443 | u8 len, name[15]; /* true length, truncated name */ |
375 | fnode_secno up; /* pointer to file's directory fnode */ | 444 | fnode_secno up; /* pointer to file's directory fnode */ |
376 | /*unsigned zero2[3];*/ | ||
377 | secno acl_size_l; | 445 | secno acl_size_l; |
378 | secno acl_secno; | 446 | secno acl_secno; |
379 | unsigned short acl_size_s; | 447 | u16 acl_size_s; |
380 | char acl_anode; | 448 | u8 acl_anode; |
381 | char zero2; /* history bit count */ | 449 | u8 zero2; /* history bit count */ |
382 | unsigned ea_size_l; /* length of disk-resident ea's */ | 450 | u32 ea_size_l; /* length of disk-resident ea's */ |
383 | secno ea_secno; /* first sector of disk-resident ea's*/ | 451 | secno ea_secno; /* first sector of disk-resident ea's*/ |
384 | unsigned short ea_size_s; /* length of fnode-resident ea's */ | 452 | u16 ea_size_s; /* length of fnode-resident ea's */ |
385 | 453 | ||
386 | unsigned flag0: 1; | 454 | #ifdef __LITTLE_ENDIAN |
387 | unsigned ea_anode: 1; /* 1 -> ea_secno is an anode */ | 455 | u8 flag0: 1; |
388 | unsigned flag2: 1; | 456 | u8 ea_anode: 1; /* 1 -> ea_secno is an anode */ |
389 | unsigned flag3: 1; | 457 | u8 flag234567: 6; |
390 | unsigned flag4: 1; | 458 | #else |
391 | unsigned flag5: 1; | 459 | u8 flag234567: 6; |
392 | unsigned flag6: 1; | 460 | u8 ea_anode: 1; /* 1 -> ea_secno is an anode */ |
393 | unsigned flag7: 1; | 461 | u8 flag0: 1; |
394 | unsigned dirflag: 1; /* 1 -> directory. first & only extent | 462 | #endif |
463 | |||
464 | #ifdef __LITTLE_ENDIAN | ||
465 | u8 dirflag: 1; /* 1 -> directory. first & only extent | ||
395 | points to dnode. */ | 466 | points to dnode. */ |
396 | unsigned flag9: 1; | 467 | u8 flag9012345: 7; |
397 | unsigned flag10: 1; | 468 | #else |
398 | unsigned flag11: 1; | 469 | u8 flag9012345: 7; |
399 | unsigned flag12: 1; | 470 | u8 dirflag: 1; /* 1 -> directory. first & only extent |
400 | unsigned flag13: 1; | 471 | points to dnode. */ |
401 | unsigned flag14: 1; | 472 | #endif |
402 | unsigned flag15: 1; | ||
403 | 473 | ||
404 | struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */ | 474 | struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */ |
405 | union { | 475 | union { |
@@ -407,17 +477,16 @@ struct fnode | |||
407 | struct bplus_internal_node internal[12]; | 477 | struct bplus_internal_node internal[12]; |
408 | } u; | 478 | } u; |
409 | 479 | ||
410 | unsigned file_size; /* file length, bytes */ | 480 | u32 file_size; /* file length, bytes */ |
411 | unsigned n_needea; /* number of EA's with NEEDEA set */ | 481 | u32 n_needea; /* number of EA's with NEEDEA set */ |
412 | char user_id[16]; /* unused */ | 482 | u8 user_id[16]; /* unused */ |
413 | unsigned short ea_offs; /* offset from start of fnode | 483 | u16 ea_offs; /* offset from start of fnode |
414 | to first fnode-resident ea */ | 484 | to first fnode-resident ea */ |
415 | char dasd_limit_treshhold; | 485 | u8 dasd_limit_treshhold; |
416 | char dasd_limit_delta; | 486 | u8 dasd_limit_delta; |
417 | unsigned dasd_limit; | 487 | u32 dasd_limit; |
418 | unsigned dasd_usage; | 488 | u32 dasd_usage; |
419 | /*unsigned zero5[2];*/ | 489 | u8 ea[316]; /* zero or more EA's, packed together |
420 | unsigned char ea[316]; /* zero or more EA's, packed together | ||
421 | with no alignment padding. | 490 | with no alignment padding. |
422 | (Do not use this name, get here | 491 | (Do not use this name, get here |
423 | via fnode + ea_offs. I think.) */ | 492 | via fnode + ea_offs. I think.) */ |
@@ -430,7 +499,7 @@ struct fnode | |||
430 | 499 | ||
431 | struct anode | 500 | struct anode |
432 | { | 501 | { |
433 | unsigned magic; /* 37e4 0aae */ | 502 | u32 magic; /* 37e4 0aae */ |
434 | anode_secno self; /* pointer to this anode */ | 503 | anode_secno self; /* pointer to this anode */ |
435 | secno up; /* parent anode or fnode */ | 504 | secno up; /* parent anode or fnode */ |
436 | 505 | ||
@@ -440,7 +509,7 @@ struct anode | |||
440 | struct bplus_internal_node internal[60]; | 509 | struct bplus_internal_node internal[60]; |
441 | } u; | 510 | } u; |
442 | 511 | ||
443 | unsigned fill[3]; /* unused */ | 512 | u32 fill[3]; /* unused */ |
444 | }; | 513 | }; |
445 | 514 | ||
446 | 515 | ||
@@ -461,25 +530,31 @@ struct anode | |||
461 | 530 | ||
462 | struct extended_attribute | 531 | struct extended_attribute |
463 | { | 532 | { |
464 | unsigned indirect: 1; /* 1 -> value gives sector number | 533 | #ifdef __LITTLE_ENDIAN |
534 | u8 indirect: 1; /* 1 -> value gives sector number | ||
465 | where real value starts */ | 535 | where real value starts */ |
466 | unsigned anode: 1; /* 1 -> sector is an anode | 536 | u8 anode: 1; /* 1 -> sector is an anode |
537 | that points to fragmented value */ | ||
538 | u8 flag23456: 5; | ||
539 | u8 needea: 1; /* required ea */ | ||
540 | #else | ||
541 | u8 needea: 1; /* required ea */ | ||
542 | u8 flag23456: 5; | ||
543 | u8 anode: 1; /* 1 -> sector is an anode | ||
467 | that points to fragmented value */ | 544 | that points to fragmented value */ |
468 | unsigned flag2: 1; | 545 | u8 indirect: 1; /* 1 -> value gives sector number |
469 | unsigned flag3: 1; | 546 | where real value starts */ |
470 | unsigned flag4: 1; | 547 | #endif |
471 | unsigned flag5: 1; | 548 | u8 namelen; /* length of name, bytes */ |
472 | unsigned flag6: 1; | 549 | u8 valuelen_lo; /* length of value, bytes */ |
473 | unsigned needea: 1; /* required ea */ | 550 | u8 valuelen_hi; /* length of value, bytes */ |
474 | unsigned char namelen; /* length of name, bytes */ | 551 | u8 name[0]; |
475 | unsigned short valuelen; /* length of value, bytes */ | ||
476 | unsigned char name[0]; | ||
477 | /* | 552 | /* |
478 | unsigned char name[namelen]; ascii attrib name | 553 | u8 name[namelen]; ascii attrib name |
479 | unsigned char nul; terminating '\0', not counted | 554 | u8 nul; terminating '\0', not counted |
480 | unsigned char value[valuelen]; value, arbitrary | 555 | u8 value[valuelen]; value, arbitrary |
481 | if this.indirect, valuelen is 8 and the value is | 556 | if this.indirect, valuelen is 8 and the value is |
482 | unsigned length; real length of value, bytes | 557 | u32 length; real length of value, bytes |
483 | secno secno; sector address where it starts | 558 | secno secno; sector address where it starts |
484 | if this.anode, the above sector number is the root of an anode tree | 559 | if this.anode, the above sector number is the root of an anode tree |
485 | which points to the value. | 560 | which points to the value. |
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h index c15adbca07f..dd552f862c8 100644 --- a/fs/hpfs/hpfs_fn.h +++ b/fs/hpfs/hpfs_fn.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/pagemap.h> | 13 | #include <linux/pagemap.h> |
14 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <asm/unaligned.h> | ||
16 | 17 | ||
17 | #include "hpfs.h" | 18 | #include "hpfs.h" |
18 | 19 | ||
@@ -51,18 +52,16 @@ struct hpfs_inode_info { | |||
51 | unsigned i_disk_sec; /* (files) minimalist cache of alloc info */ | 52 | unsigned i_disk_sec; /* (files) minimalist cache of alloc info */ |
52 | unsigned i_n_secs; /* (files) minimalist cache of alloc info */ | 53 | unsigned i_n_secs; /* (files) minimalist cache of alloc info */ |
53 | unsigned i_ea_size; /* size of extended attributes */ | 54 | unsigned i_ea_size; /* size of extended attributes */ |
54 | unsigned i_conv : 2; /* (files) crlf->newline hackery */ | ||
55 | unsigned i_ea_mode : 1; /* file's permission is stored in ea */ | 55 | unsigned i_ea_mode : 1; /* file's permission is stored in ea */ |
56 | unsigned i_ea_uid : 1; /* file's uid is stored in ea */ | 56 | unsigned i_ea_uid : 1; /* file's uid is stored in ea */ |
57 | unsigned i_ea_gid : 1; /* file's gid is stored in ea */ | 57 | unsigned i_ea_gid : 1; /* file's gid is stored in ea */ |
58 | unsigned i_dirty : 1; | 58 | unsigned i_dirty : 1; |
59 | struct mutex i_mutex; | ||
60 | struct mutex i_parent_mutex; | ||
61 | loff_t **i_rddir_off; | 59 | loff_t **i_rddir_off; |
62 | struct inode vfs_inode; | 60 | struct inode vfs_inode; |
63 | }; | 61 | }; |
64 | 62 | ||
65 | struct hpfs_sb_info { | 63 | struct hpfs_sb_info { |
64 | struct mutex hpfs_mutex; /* global hpfs lock */ | ||
66 | ino_t sb_root; /* inode number of root dir */ | 65 | ino_t sb_root; /* inode number of root dir */ |
67 | unsigned sb_fs_size; /* file system size, sectors */ | 66 | unsigned sb_fs_size; /* file system size, sectors */ |
68 | unsigned sb_bitmaps; /* sector number of bitmap list */ | 67 | unsigned sb_bitmaps; /* sector number of bitmap list */ |
@@ -74,7 +73,6 @@ struct hpfs_sb_info { | |||
74 | uid_t sb_uid; /* uid from mount options */ | 73 | uid_t sb_uid; /* uid from mount options */ |
75 | gid_t sb_gid; /* gid from mount options */ | 74 | gid_t sb_gid; /* gid from mount options */ |
76 | umode_t sb_mode; /* mode from mount options */ | 75 | umode_t sb_mode; /* mode from mount options */ |
77 | unsigned sb_conv : 2; /* crlf->newline hackery */ | ||
78 | unsigned sb_eas : 2; /* eas: 0-ignore, 1-ro, 2-rw */ | 76 | unsigned sb_eas : 2; /* eas: 0-ignore, 1-ro, 2-rw */ |
79 | unsigned sb_err : 2; /* on errs: 0-cont, 1-ro, 2-panic */ | 77 | unsigned sb_err : 2; /* on errs: 0-cont, 1-ro, 2-panic */ |
80 | unsigned sb_chk : 2; /* checks: 0-no, 1-normal, 2-strict */ | 78 | unsigned sb_chk : 2; /* checks: 0-no, 1-normal, 2-strict */ |
@@ -87,20 +85,9 @@ struct hpfs_sb_info { | |||
87 | unsigned *sb_bmp_dir; /* main bitmap directory */ | 85 | unsigned *sb_bmp_dir; /* main bitmap directory */ |
88 | unsigned sb_c_bitmap; /* current bitmap */ | 86 | unsigned sb_c_bitmap; /* current bitmap */ |
89 | unsigned sb_max_fwd_alloc; /* max forwad allocation */ | 87 | unsigned sb_max_fwd_alloc; /* max forwad allocation */ |
90 | struct mutex hpfs_creation_de; /* when creating dirents, nobody else | ||
91 | can alloc blocks */ | ||
92 | /*unsigned sb_mounting : 1;*/ | ||
93 | int sb_timeshift; | 88 | int sb_timeshift; |
94 | }; | 89 | }; |
95 | 90 | ||
96 | /* | ||
97 | * conv= options | ||
98 | */ | ||
99 | |||
100 | #define CONV_BINARY 0 /* no conversion */ | ||
101 | #define CONV_TEXT 1 /* crlf->newline */ | ||
102 | #define CONV_AUTO 2 /* decide based on file contents */ | ||
103 | |||
104 | /* Four 512-byte buffers and the 2k block obtained by concatenating them */ | 91 | /* Four 512-byte buffers and the 2k block obtained by concatenating them */ |
105 | 92 | ||
106 | struct quad_buffer_head { | 93 | struct quad_buffer_head { |
@@ -113,7 +100,7 @@ struct quad_buffer_head { | |||
113 | static inline dnode_secno de_down_pointer (struct hpfs_dirent *de) | 100 | static inline dnode_secno de_down_pointer (struct hpfs_dirent *de) |
114 | { | 101 | { |
115 | CHKCOND(de->down,("HPFS: de_down_pointer: !de->down\n")); | 102 | CHKCOND(de->down,("HPFS: de_down_pointer: !de->down\n")); |
116 | return *(dnode_secno *) ((void *) de + de->length - 4); | 103 | return le32_to_cpu(*(dnode_secno *) ((void *) de + le16_to_cpu(de->length) - 4)); |
117 | } | 104 | } |
118 | 105 | ||
119 | /* The first dir entry in a dnode */ | 106 | /* The first dir entry in a dnode */ |
@@ -127,41 +114,46 @@ static inline struct hpfs_dirent *dnode_first_de (struct dnode *dnode) | |||
127 | 114 | ||
128 | static inline struct hpfs_dirent *dnode_end_de (struct dnode *dnode) | 115 | static inline struct hpfs_dirent *dnode_end_de (struct dnode *dnode) |
129 | { | 116 | { |
130 | CHKCOND(dnode->first_free>=0x14 && dnode->first_free<=0xa00,("HPFS: dnode_end_de: dnode->first_free = %d\n",(int)dnode->first_free)); | 117 | CHKCOND(le32_to_cpu(dnode->first_free)>=0x14 && le32_to_cpu(dnode->first_free)<=0xa00,("HPFS: dnode_end_de: dnode->first_free = %x\n",(unsigned)le32_to_cpu(dnode->first_free))); |
131 | return (void *) dnode + dnode->first_free; | 118 | return (void *) dnode + le32_to_cpu(dnode->first_free); |
132 | } | 119 | } |
133 | 120 | ||
134 | /* The dir entry after dir entry de */ | 121 | /* The dir entry after dir entry de */ |
135 | 122 | ||
136 | static inline struct hpfs_dirent *de_next_de (struct hpfs_dirent *de) | 123 | static inline struct hpfs_dirent *de_next_de (struct hpfs_dirent *de) |
137 | { | 124 | { |
138 | CHKCOND(de->length>=0x20 && de->length<0x800,("HPFS: de_next_de: de->length = %d\n",(int)de->length)); | 125 | CHKCOND(le16_to_cpu(de->length)>=0x20 && le16_to_cpu(de->length)<0x800,("HPFS: de_next_de: de->length = %x\n",(unsigned)le16_to_cpu(de->length))); |
139 | return (void *) de + de->length; | 126 | return (void *) de + le16_to_cpu(de->length); |
140 | } | 127 | } |
141 | 128 | ||
142 | static inline struct extended_attribute *fnode_ea(struct fnode *fnode) | 129 | static inline struct extended_attribute *fnode_ea(struct fnode *fnode) |
143 | { | 130 | { |
144 | return (struct extended_attribute *)((char *)fnode + fnode->ea_offs + fnode->acl_size_s); | 131 | return (struct extended_attribute *)((char *)fnode + le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s)); |
145 | } | 132 | } |
146 | 133 | ||
147 | static inline struct extended_attribute *fnode_end_ea(struct fnode *fnode) | 134 | static inline struct extended_attribute *fnode_end_ea(struct fnode *fnode) |
148 | { | 135 | { |
149 | return (struct extended_attribute *)((char *)fnode + fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s); | 136 | return (struct extended_attribute *)((char *)fnode + le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s)); |
137 | } | ||
138 | |||
139 | static unsigned ea_valuelen(struct extended_attribute *ea) | ||
140 | { | ||
141 | return ea->valuelen_lo + 256 * ea->valuelen_hi; | ||
150 | } | 142 | } |
151 | 143 | ||
152 | static inline struct extended_attribute *next_ea(struct extended_attribute *ea) | 144 | static inline struct extended_attribute *next_ea(struct extended_attribute *ea) |
153 | { | 145 | { |
154 | return (struct extended_attribute *)((char *)ea + 5 + ea->namelen + ea->valuelen); | 146 | return (struct extended_attribute *)((char *)ea + 5 + ea->namelen + ea_valuelen(ea)); |
155 | } | 147 | } |
156 | 148 | ||
157 | static inline secno ea_sec(struct extended_attribute *ea) | 149 | static inline secno ea_sec(struct extended_attribute *ea) |
158 | { | 150 | { |
159 | return *(secno *)((char *)ea + 9 + ea->namelen); | 151 | return le32_to_cpu(get_unaligned((secno *)((char *)ea + 9 + ea->namelen))); |
160 | } | 152 | } |
161 | 153 | ||
162 | static inline secno ea_len(struct extended_attribute *ea) | 154 | static inline secno ea_len(struct extended_attribute *ea) |
163 | { | 155 | { |
164 | return *(secno *)((char *)ea + 5 + ea->namelen); | 156 | return le32_to_cpu(get_unaligned((secno *)((char *)ea + 5 + ea->namelen))); |
165 | } | 157 | } |
166 | 158 | ||
167 | static inline char *ea_data(struct extended_attribute *ea) | 159 | static inline char *ea_data(struct extended_attribute *ea) |
@@ -186,13 +178,13 @@ static inline void copy_de(struct hpfs_dirent *dst, struct hpfs_dirent *src) | |||
186 | dst->not_8x3 = n; | 178 | dst->not_8x3 = n; |
187 | } | 179 | } |
188 | 180 | ||
189 | static inline unsigned tstbits(unsigned *bmp, unsigned b, unsigned n) | 181 | static inline unsigned tstbits(u32 *bmp, unsigned b, unsigned n) |
190 | { | 182 | { |
191 | int i; | 183 | int i; |
192 | if ((b >= 0x4000) || (b + n - 1 >= 0x4000)) return n; | 184 | if ((b >= 0x4000) || (b + n - 1 >= 0x4000)) return n; |
193 | if (!((bmp[(b & 0x3fff) >> 5] >> (b & 0x1f)) & 1)) return 1; | 185 | if (!((le32_to_cpu(bmp[(b & 0x3fff) >> 5]) >> (b & 0x1f)) & 1)) return 1; |
194 | for (i = 1; i < n; i++) | 186 | for (i = 1; i < n; i++) |
195 | if (/*b+i < 0x4000 &&*/ !((bmp[((b+i) & 0x3fff) >> 5] >> ((b+i) & 0x1f)) & 1)) | 187 | if (!((le32_to_cpu(bmp[((b+i) & 0x3fff) >> 5]) >> ((b+i) & 0x1f)) & 1)) |
196 | return i + 1; | 188 | return i + 1; |
197 | return 0; | 189 | return 0; |
198 | } | 190 | } |
@@ -200,12 +192,12 @@ static inline unsigned tstbits(unsigned *bmp, unsigned b, unsigned n) | |||
200 | /* alloc.c */ | 192 | /* alloc.c */ |
201 | 193 | ||
202 | int hpfs_chk_sectors(struct super_block *, secno, int, char *); | 194 | int hpfs_chk_sectors(struct super_block *, secno, int, char *); |
203 | secno hpfs_alloc_sector(struct super_block *, secno, unsigned, int, int); | 195 | secno hpfs_alloc_sector(struct super_block *, secno, unsigned, int); |
204 | int hpfs_alloc_if_possible(struct super_block *, secno); | 196 | int hpfs_alloc_if_possible(struct super_block *, secno); |
205 | void hpfs_free_sectors(struct super_block *, secno, unsigned); | 197 | void hpfs_free_sectors(struct super_block *, secno, unsigned); |
206 | int hpfs_check_free_dnodes(struct super_block *, int); | 198 | int hpfs_check_free_dnodes(struct super_block *, int); |
207 | void hpfs_free_dnode(struct super_block *, secno); | 199 | void hpfs_free_dnode(struct super_block *, secno); |
208 | struct dnode *hpfs_alloc_dnode(struct super_block *, secno, dnode_secno *, struct quad_buffer_head *, int); | 200 | struct dnode *hpfs_alloc_dnode(struct super_block *, secno, dnode_secno *, struct quad_buffer_head *); |
209 | struct fnode *hpfs_alloc_fnode(struct super_block *, secno, fnode_secno *, struct buffer_head **); | 201 | struct fnode *hpfs_alloc_fnode(struct super_block *, secno, fnode_secno *, struct buffer_head **); |
210 | struct anode *hpfs_alloc_anode(struct super_block *, secno, anode_secno *, struct buffer_head **); | 202 | struct anode *hpfs_alloc_anode(struct super_block *, secno, anode_secno *, struct buffer_head **); |
211 | 203 | ||
@@ -222,8 +214,6 @@ void hpfs_remove_fnode(struct super_block *, fnode_secno fno); | |||
222 | 214 | ||
223 | /* buffer.c */ | 215 | /* buffer.c */ |
224 | 216 | ||
225 | void hpfs_lock_creation(struct super_block *); | ||
226 | void hpfs_unlock_creation(struct super_block *); | ||
227 | void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int); | 217 | void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int); |
228 | void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **); | 218 | void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **); |
229 | void *hpfs_map_4sectors(struct super_block *, unsigned, struct quad_buffer_head *, int); | 219 | void *hpfs_map_4sectors(struct super_block *, unsigned, struct quad_buffer_head *, int); |
@@ -247,7 +237,7 @@ void hpfs_del_pos(struct inode *, loff_t *); | |||
247 | struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, | 237 | struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, |
248 | const unsigned char *, unsigned, secno); | 238 | const unsigned char *, unsigned, secno); |
249 | int hpfs_add_dirent(struct inode *, const unsigned char *, unsigned, | 239 | int hpfs_add_dirent(struct inode *, const unsigned char *, unsigned, |
250 | struct hpfs_dirent *, int); | 240 | struct hpfs_dirent *); |
251 | int hpfs_remove_dirent(struct inode *, dnode_secno, struct hpfs_dirent *, struct quad_buffer_head *, int); | 241 | int hpfs_remove_dirent(struct inode *, dnode_secno, struct hpfs_dirent *, struct quad_buffer_head *, int); |
252 | void hpfs_count_dnodes(struct super_block *, dnode_secno, int *, int *, int *); | 242 | void hpfs_count_dnodes(struct super_block *, dnode_secno, int *, int *, int *); |
253 | dnode_secno hpfs_de_as_down_as_possible(struct super_block *, dnode_secno dno); | 243 | dnode_secno hpfs_de_as_down_as_possible(struct super_block *, dnode_secno dno); |
@@ -303,7 +293,6 @@ int hpfs_compare_names(struct super_block *, const unsigned char *, unsigned, | |||
303 | const unsigned char *, unsigned, int); | 293 | const unsigned char *, unsigned, int); |
304 | int hpfs_is_name_long(const unsigned char *, unsigned); | 294 | int hpfs_is_name_long(const unsigned char *, unsigned); |
305 | void hpfs_adjust_length(const unsigned char *, unsigned *); | 295 | void hpfs_adjust_length(const unsigned char *, unsigned *); |
306 | void hpfs_decide_conv(struct inode *, const unsigned char *, unsigned); | ||
307 | 296 | ||
308 | /* namei.c */ | 297 | /* namei.c */ |
309 | 298 | ||
@@ -346,21 +335,26 @@ static inline time32_t gmt_to_local(struct super_block *s, time_t t) | |||
346 | /* | 335 | /* |
347 | * Locking: | 336 | * Locking: |
348 | * | 337 | * |
349 | * hpfs_lock() is a leftover from the big kernel lock. | 338 | * hpfs_lock() locks the whole filesystem. It must be taken |
350 | * Right now, these functions are empty and only left | 339 | * on any method called by the VFS. |
351 | * for documentation purposes. The file system no longer | ||
352 | * works on SMP systems, so the lock is not needed | ||
353 | * any more. | ||
354 | * | 340 | * |
355 | * If someone is interested in making it work again, this | 341 | * We don't do any per-file locking anymore, it is hard to |
356 | * would be the place to start by adding a per-superblock | 342 | * review and HPFS is not performance-sensitive anyway. |
357 | * mutex and fixing all the bugs and performance issues | ||
358 | * caused by that. | ||
359 | */ | 343 | */ |
360 | static inline void hpfs_lock(struct super_block *s) | 344 | static inline void hpfs_lock(struct super_block *s) |
361 | { | 345 | { |
346 | struct hpfs_sb_info *sbi = hpfs_sb(s); | ||
347 | mutex_lock(&sbi->hpfs_mutex); | ||
362 | } | 348 | } |
363 | 349 | ||
364 | static inline void hpfs_unlock(struct super_block *s) | 350 | static inline void hpfs_unlock(struct super_block *s) |
365 | { | 351 | { |
352 | struct hpfs_sb_info *sbi = hpfs_sb(s); | ||
353 | mutex_unlock(&sbi->hpfs_mutex); | ||
354 | } | ||
355 | |||
356 | static inline void hpfs_lock_assert(struct super_block *s) | ||
357 | { | ||
358 | struct hpfs_sb_info *sbi = hpfs_sb(s); | ||
359 | WARN_ON(!mutex_is_locked(&sbi->hpfs_mutex)); | ||
366 | } | 360 | } |
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index 87f1f787e76..338cd836845 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c | |||
@@ -17,7 +17,6 @@ void hpfs_init_inode(struct inode *i) | |||
17 | i->i_uid = hpfs_sb(sb)->sb_uid; | 17 | i->i_uid = hpfs_sb(sb)->sb_uid; |
18 | i->i_gid = hpfs_sb(sb)->sb_gid; | 18 | i->i_gid = hpfs_sb(sb)->sb_gid; |
19 | i->i_mode = hpfs_sb(sb)->sb_mode; | 19 | i->i_mode = hpfs_sb(sb)->sb_mode; |
20 | hpfs_inode->i_conv = hpfs_sb(sb)->sb_conv; | ||
21 | i->i_size = -1; | 20 | i->i_size = -1; |
22 | i->i_blocks = -1; | 21 | i->i_blocks = -1; |
23 | 22 | ||
@@ -116,8 +115,8 @@ void hpfs_read_inode(struct inode *i) | |||
116 | i->i_mode |= S_IFDIR; | 115 | i->i_mode |= S_IFDIR; |
117 | i->i_op = &hpfs_dir_iops; | 116 | i->i_op = &hpfs_dir_iops; |
118 | i->i_fop = &hpfs_dir_ops; | 117 | i->i_fop = &hpfs_dir_ops; |
119 | hpfs_inode->i_parent_dir = fnode->up; | 118 | hpfs_inode->i_parent_dir = le32_to_cpu(fnode->up); |
120 | hpfs_inode->i_dno = fnode->u.external[0].disk_secno; | 119 | hpfs_inode->i_dno = le32_to_cpu(fnode->u.external[0].disk_secno); |
121 | if (hpfs_sb(sb)->sb_chk >= 2) { | 120 | if (hpfs_sb(sb)->sb_chk >= 2) { |
122 | struct buffer_head *bh0; | 121 | struct buffer_head *bh0; |
123 | if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0); | 122 | if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0); |
@@ -133,7 +132,7 @@ void hpfs_read_inode(struct inode *i) | |||
133 | i->i_op = &hpfs_file_iops; | 132 | i->i_op = &hpfs_file_iops; |
134 | i->i_fop = &hpfs_file_ops; | 133 | i->i_fop = &hpfs_file_ops; |
135 | i->i_nlink = 1; | 134 | i->i_nlink = 1; |
136 | i->i_size = fnode->file_size; | 135 | i->i_size = le32_to_cpu(fnode->file_size); |
137 | i->i_blocks = ((i->i_size + 511) >> 9) + 1; | 136 | i->i_blocks = ((i->i_size + 511) >> 9) + 1; |
138 | i->i_data.a_ops = &hpfs_aops; | 137 | i->i_data.a_ops = &hpfs_aops; |
139 | hpfs_i(i)->mmu_private = i->i_size; | 138 | hpfs_i(i)->mmu_private = i->i_size; |
@@ -144,7 +143,7 @@ void hpfs_read_inode(struct inode *i) | |||
144 | static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode) | 143 | static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode) |
145 | { | 144 | { |
146 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); | 145 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); |
147 | /*if (fnode->acl_size_l || fnode->acl_size_s) { | 146 | /*if (le32_to_cpu(fnode->acl_size_l) || le16_to_cpu(fnode->acl_size_s)) { |
148 | Some unknown structures like ACL may be in fnode, | 147 | Some unknown structures like ACL may be in fnode, |
149 | we'd better not overwrite them | 148 | we'd better not overwrite them |
150 | hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino); | 149 | hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino); |
@@ -187,9 +186,7 @@ void hpfs_write_inode(struct inode *i) | |||
187 | kfree(hpfs_inode->i_rddir_off); | 186 | kfree(hpfs_inode->i_rddir_off); |
188 | hpfs_inode->i_rddir_off = NULL; | 187 | hpfs_inode->i_rddir_off = NULL; |
189 | } | 188 | } |
190 | mutex_lock(&hpfs_inode->i_parent_mutex); | ||
191 | if (!i->i_nlink) { | 189 | if (!i->i_nlink) { |
192 | mutex_unlock(&hpfs_inode->i_parent_mutex); | ||
193 | return; | 190 | return; |
194 | } | 191 | } |
195 | parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir); | 192 | parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir); |
@@ -200,14 +197,9 @@ void hpfs_write_inode(struct inode *i) | |||
200 | hpfs_read_inode(parent); | 197 | hpfs_read_inode(parent); |
201 | unlock_new_inode(parent); | 198 | unlock_new_inode(parent); |
202 | } | 199 | } |
203 | mutex_lock(&hpfs_inode->i_mutex); | ||
204 | hpfs_write_inode_nolock(i); | 200 | hpfs_write_inode_nolock(i); |
205 | mutex_unlock(&hpfs_inode->i_mutex); | ||
206 | iput(parent); | 201 | iput(parent); |
207 | } else { | ||
208 | mark_inode_dirty(i); | ||
209 | } | 202 | } |
210 | mutex_unlock(&hpfs_inode->i_parent_mutex); | ||
211 | } | 203 | } |
212 | 204 | ||
213 | void hpfs_write_inode_nolock(struct inode *i) | 205 | void hpfs_write_inode_nolock(struct inode *i) |
@@ -226,30 +218,30 @@ void hpfs_write_inode_nolock(struct inode *i) | |||
226 | } | 218 | } |
227 | } else de = NULL; | 219 | } else de = NULL; |
228 | if (S_ISREG(i->i_mode)) { | 220 | if (S_ISREG(i->i_mode)) { |
229 | fnode->file_size = i->i_size; | 221 | fnode->file_size = cpu_to_le32(i->i_size); |
230 | if (de) de->file_size = i->i_size; | 222 | if (de) de->file_size = cpu_to_le32(i->i_size); |
231 | } else if (S_ISDIR(i->i_mode)) { | 223 | } else if (S_ISDIR(i->i_mode)) { |
232 | fnode->file_size = 0; | 224 | fnode->file_size = cpu_to_le32(0); |
233 | if (de) de->file_size = 0; | 225 | if (de) de->file_size = cpu_to_le32(0); |
234 | } | 226 | } |
235 | hpfs_write_inode_ea(i, fnode); | 227 | hpfs_write_inode_ea(i, fnode); |
236 | if (de) { | 228 | if (de) { |
237 | de->write_date = gmt_to_local(i->i_sb, i->i_mtime.tv_sec); | 229 | de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec)); |
238 | de->read_date = gmt_to_local(i->i_sb, i->i_atime.tv_sec); | 230 | de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec)); |
239 | de->creation_date = gmt_to_local(i->i_sb, i->i_ctime.tv_sec); | 231 | de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec)); |
240 | de->read_only = !(i->i_mode & 0222); | 232 | de->read_only = !(i->i_mode & 0222); |
241 | de->ea_size = hpfs_inode->i_ea_size; | 233 | de->ea_size = cpu_to_le32(hpfs_inode->i_ea_size); |
242 | hpfs_mark_4buffers_dirty(&qbh); | 234 | hpfs_mark_4buffers_dirty(&qbh); |
243 | hpfs_brelse4(&qbh); | 235 | hpfs_brelse4(&qbh); |
244 | } | 236 | } |
245 | if (S_ISDIR(i->i_mode)) { | 237 | if (S_ISDIR(i->i_mode)) { |
246 | if ((de = map_dirent(i, hpfs_inode->i_dno, "\001\001", 2, NULL, &qbh))) { | 238 | if ((de = map_dirent(i, hpfs_inode->i_dno, "\001\001", 2, NULL, &qbh))) { |
247 | de->write_date = gmt_to_local(i->i_sb, i->i_mtime.tv_sec); | 239 | de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec)); |
248 | de->read_date = gmt_to_local(i->i_sb, i->i_atime.tv_sec); | 240 | de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec)); |
249 | de->creation_date = gmt_to_local(i->i_sb, i->i_ctime.tv_sec); | 241 | de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec)); |
250 | de->read_only = !(i->i_mode & 0222); | 242 | de->read_only = !(i->i_mode & 0222); |
251 | de->ea_size = /*hpfs_inode->i_ea_size*/0; | 243 | de->ea_size = cpu_to_le32(/*hpfs_inode->i_ea_size*/0); |
252 | de->file_size = 0; | 244 | de->file_size = cpu_to_le32(0); |
253 | hpfs_mark_4buffers_dirty(&qbh); | 245 | hpfs_mark_4buffers_dirty(&qbh); |
254 | hpfs_brelse4(&qbh); | 246 | hpfs_brelse4(&qbh); |
255 | } else | 247 | } else |
@@ -269,6 +261,10 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
269 | hpfs_lock(inode->i_sb); | 261 | hpfs_lock(inode->i_sb); |
270 | if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root) | 262 | if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root) |
271 | goto out_unlock; | 263 | goto out_unlock; |
264 | if ((attr->ia_valid & ATTR_UID) && attr->ia_uid >= 0x10000) | ||
265 | goto out_unlock; | ||
266 | if ((attr->ia_valid & ATTR_GID) && attr->ia_gid >= 0x10000) | ||
267 | goto out_unlock; | ||
272 | if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) | 268 | if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) |
273 | goto out_unlock; | 269 | goto out_unlock; |
274 | 270 | ||
@@ -284,7 +280,6 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
284 | } | 280 | } |
285 | 281 | ||
286 | setattr_copy(inode, attr); | 282 | setattr_copy(inode, attr); |
287 | mark_inode_dirty(inode); | ||
288 | 283 | ||
289 | hpfs_write_inode(inode); | 284 | hpfs_write_inode(inode); |
290 | 285 | ||
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c index 840d033ecee..a790821366a 100644 --- a/fs/hpfs/map.c +++ b/fs/hpfs/map.c | |||
@@ -21,7 +21,7 @@ unsigned int *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, | |||
21 | hpfs_error(s, "hpfs_map_bitmap called with bad parameter: %08x at %s", bmp_block, id); | 21 | hpfs_error(s, "hpfs_map_bitmap called with bad parameter: %08x at %s", bmp_block, id); |
22 | return NULL; | 22 | return NULL; |
23 | } | 23 | } |
24 | sec = hpfs_sb(s)->sb_bmp_dir[bmp_block]; | 24 | sec = le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[bmp_block]); |
25 | if (!sec || sec > hpfs_sb(s)->sb_fs_size-4) { | 25 | if (!sec || sec > hpfs_sb(s)->sb_fs_size-4) { |
26 | hpfs_error(s, "invalid bitmap block pointer %08x -> %08x at %s", bmp_block, sec, id); | 26 | hpfs_error(s, "invalid bitmap block pointer %08x -> %08x at %s", bmp_block, sec, id); |
27 | return NULL; | 27 | return NULL; |
@@ -46,18 +46,18 @@ unsigned char *hpfs_load_code_page(struct super_block *s, secno cps) | |||
46 | struct code_page_data *cpd; | 46 | struct code_page_data *cpd; |
47 | struct code_page_directory *cp = hpfs_map_sector(s, cps, &bh, 0); | 47 | struct code_page_directory *cp = hpfs_map_sector(s, cps, &bh, 0); |
48 | if (!cp) return NULL; | 48 | if (!cp) return NULL; |
49 | if (cp->magic != CP_DIR_MAGIC) { | 49 | if (le32_to_cpu(cp->magic) != CP_DIR_MAGIC) { |
50 | printk("HPFS: Code page directory magic doesn't match (magic = %08x)\n", cp->magic); | 50 | printk("HPFS: Code page directory magic doesn't match (magic = %08x)\n", le32_to_cpu(cp->magic)); |
51 | brelse(bh); | 51 | brelse(bh); |
52 | return NULL; | 52 | return NULL; |
53 | } | 53 | } |
54 | if (!cp->n_code_pages) { | 54 | if (!le32_to_cpu(cp->n_code_pages)) { |
55 | printk("HPFS: n_code_pages == 0\n"); | 55 | printk("HPFS: n_code_pages == 0\n"); |
56 | brelse(bh); | 56 | brelse(bh); |
57 | return NULL; | 57 | return NULL; |
58 | } | 58 | } |
59 | cpds = cp->array[0].code_page_data; | 59 | cpds = le32_to_cpu(cp->array[0].code_page_data); |
60 | cpi = cp->array[0].index; | 60 | cpi = le16_to_cpu(cp->array[0].index); |
61 | brelse(bh); | 61 | brelse(bh); |
62 | 62 | ||
63 | if (cpi >= 3) { | 63 | if (cpi >= 3) { |
@@ -66,12 +66,12 @@ unsigned char *hpfs_load_code_page(struct super_block *s, secno cps) | |||
66 | } | 66 | } |
67 | 67 | ||
68 | if (!(cpd = hpfs_map_sector(s, cpds, &bh, 0))) return NULL; | 68 | if (!(cpd = hpfs_map_sector(s, cpds, &bh, 0))) return NULL; |
69 | if ((unsigned)cpd->offs[cpi] > 0x178) { | 69 | if (le16_to_cpu(cpd->offs[cpi]) > 0x178) { |
70 | printk("HPFS: Code page index out of sector\n"); | 70 | printk("HPFS: Code page index out of sector\n"); |
71 | brelse(bh); | 71 | brelse(bh); |
72 | return NULL; | 72 | return NULL; |
73 | } | 73 | } |
74 | ptr = (unsigned char *)cpd + cpd->offs[cpi] + 6; | 74 | ptr = (unsigned char *)cpd + le16_to_cpu(cpd->offs[cpi]) + 6; |
75 | if (!(cp_table = kmalloc(256, GFP_KERNEL))) { | 75 | if (!(cp_table = kmalloc(256, GFP_KERNEL))) { |
76 | printk("HPFS: out of memory for code page table\n"); | 76 | printk("HPFS: out of memory for code page table\n"); |
77 | brelse(bh); | 77 | brelse(bh); |
@@ -125,7 +125,7 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea | |||
125 | if (hpfs_sb(s)->sb_chk) { | 125 | if (hpfs_sb(s)->sb_chk) { |
126 | struct extended_attribute *ea; | 126 | struct extended_attribute *ea; |
127 | struct extended_attribute *ea_end; | 127 | struct extended_attribute *ea_end; |
128 | if (fnode->magic != FNODE_MAGIC) { | 128 | if (le32_to_cpu(fnode->magic) != FNODE_MAGIC) { |
129 | hpfs_error(s, "bad magic on fnode %08lx", | 129 | hpfs_error(s, "bad magic on fnode %08lx", |
130 | (unsigned long)ino); | 130 | (unsigned long)ino); |
131 | goto bail; | 131 | goto bail; |
@@ -138,7 +138,7 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea | |||
138 | (unsigned long)ino); | 138 | (unsigned long)ino); |
139 | goto bail; | 139 | goto bail; |
140 | } | 140 | } |
141 | if (fnode->btree.first_free != | 141 | if (le16_to_cpu(fnode->btree.first_free) != |
142 | 8 + fnode->btree.n_used_nodes * (fnode->btree.internal ? 8 : 12)) { | 142 | 8 + fnode->btree.n_used_nodes * (fnode->btree.internal ? 8 : 12)) { |
143 | hpfs_error(s, | 143 | hpfs_error(s, |
144 | "bad first_free pointer in fnode %08lx", | 144 | "bad first_free pointer in fnode %08lx", |
@@ -146,12 +146,12 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea | |||
146 | goto bail; | 146 | goto bail; |
147 | } | 147 | } |
148 | } | 148 | } |
149 | if (fnode->ea_size_s && ((signed int)fnode->ea_offs < 0xc4 || | 149 | if (le16_to_cpu(fnode->ea_size_s) && (le16_to_cpu(fnode->ea_offs) < 0xc4 || |
150 | (signed int)fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200)) { | 150 | le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) > 0x200)) { |
151 | hpfs_error(s, | 151 | hpfs_error(s, |
152 | "bad EA info in fnode %08lx: ea_offs == %04x ea_size_s == %04x", | 152 | "bad EA info in fnode %08lx: ea_offs == %04x ea_size_s == %04x", |
153 | (unsigned long)ino, | 153 | (unsigned long)ino, |
154 | fnode->ea_offs, fnode->ea_size_s); | 154 | le16_to_cpu(fnode->ea_offs), le16_to_cpu(fnode->ea_size_s)); |
155 | goto bail; | 155 | goto bail; |
156 | } | 156 | } |
157 | ea = fnode_ea(fnode); | 157 | ea = fnode_ea(fnode); |
@@ -178,16 +178,20 @@ struct anode *hpfs_map_anode(struct super_block *s, anode_secno ano, struct buff | |||
178 | if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, ano, 1, "anode")) return NULL; | 178 | if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, ano, 1, "anode")) return NULL; |
179 | if ((anode = hpfs_map_sector(s, ano, bhp, ANODE_RD_AHEAD))) | 179 | if ((anode = hpfs_map_sector(s, ano, bhp, ANODE_RD_AHEAD))) |
180 | if (hpfs_sb(s)->sb_chk) { | 180 | if (hpfs_sb(s)->sb_chk) { |
181 | if (anode->magic != ANODE_MAGIC || anode->self != ano) { | 181 | if (le32_to_cpu(anode->magic) != ANODE_MAGIC) { |
182 | hpfs_error(s, "bad magic on anode %08x", ano); | 182 | hpfs_error(s, "bad magic on anode %08x", ano); |
183 | goto bail; | 183 | goto bail; |
184 | } | 184 | } |
185 | if (le32_to_cpu(anode->self) != ano) { | ||
186 | hpfs_error(s, "self pointer invalid on anode %08x", ano); | ||
187 | goto bail; | ||
188 | } | ||
185 | if ((unsigned)anode->btree.n_used_nodes + (unsigned)anode->btree.n_free_nodes != | 189 | if ((unsigned)anode->btree.n_used_nodes + (unsigned)anode->btree.n_free_nodes != |
186 | (anode->btree.internal ? 60 : 40)) { | 190 | (anode->btree.internal ? 60 : 40)) { |
187 | hpfs_error(s, "bad number of nodes in anode %08x", ano); | 191 | hpfs_error(s, "bad number of nodes in anode %08x", ano); |
188 | goto bail; | 192 | goto bail; |
189 | } | 193 | } |
190 | if (anode->btree.first_free != | 194 | if (le16_to_cpu(anode->btree.first_free) != |
191 | 8 + anode->btree.n_used_nodes * (anode->btree.internal ? 8 : 12)) { | 195 | 8 + anode->btree.n_used_nodes * (anode->btree.internal ? 8 : 12)) { |
192 | hpfs_error(s, "bad first_free pointer in anode %08x", ano); | 196 | hpfs_error(s, "bad first_free pointer in anode %08x", ano); |
193 | goto bail; | 197 | goto bail; |
@@ -219,26 +223,26 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno, | |||
219 | unsigned p, pp = 0; | 223 | unsigned p, pp = 0; |
220 | unsigned char *d = (unsigned char *)dnode; | 224 | unsigned char *d = (unsigned char *)dnode; |
221 | int b = 0; | 225 | int b = 0; |
222 | if (dnode->magic != DNODE_MAGIC) { | 226 | if (le32_to_cpu(dnode->magic) != DNODE_MAGIC) { |
223 | hpfs_error(s, "bad magic on dnode %08x", secno); | 227 | hpfs_error(s, "bad magic on dnode %08x", secno); |
224 | goto bail; | 228 | goto bail; |
225 | } | 229 | } |
226 | if (dnode->self != secno) | 230 | if (le32_to_cpu(dnode->self) != secno) |
227 | hpfs_error(s, "bad self pointer on dnode %08x self = %08x", secno, dnode->self); | 231 | hpfs_error(s, "bad self pointer on dnode %08x self = %08x", secno, le32_to_cpu(dnode->self)); |
228 | /* Check dirents - bad dirents would cause infinite | 232 | /* Check dirents - bad dirents would cause infinite |
229 | loops or shooting to memory */ | 233 | loops or shooting to memory */ |
230 | if (dnode->first_free > 2048/* || dnode->first_free < 84*/) { | 234 | if (le32_to_cpu(dnode->first_free) > 2048) { |
231 | hpfs_error(s, "dnode %08x has first_free == %08x", secno, dnode->first_free); | 235 | hpfs_error(s, "dnode %08x has first_free == %08x", secno, le32_to_cpu(dnode->first_free)); |
232 | goto bail; | 236 | goto bail; |
233 | } | 237 | } |
234 | for (p = 20; p < dnode->first_free; p += d[p] + (d[p+1] << 8)) { | 238 | for (p = 20; p < le32_to_cpu(dnode->first_free); p += d[p] + (d[p+1] << 8)) { |
235 | struct hpfs_dirent *de = (struct hpfs_dirent *)((char *)dnode + p); | 239 | struct hpfs_dirent *de = (struct hpfs_dirent *)((char *)dnode + p); |
236 | if (de->length > 292 || (de->length < 32) || (de->length & 3) || p + de->length > 2048) { | 240 | if (le16_to_cpu(de->length) > 292 || (le16_to_cpu(de->length) < 32) || (le16_to_cpu(de->length) & 3) || p + le16_to_cpu(de->length) > 2048) { |
237 | hpfs_error(s, "bad dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp); | 241 | hpfs_error(s, "bad dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp); |
238 | goto bail; | 242 | goto bail; |
239 | } | 243 | } |
240 | if (((31 + de->namelen + de->down*4 + 3) & ~3) != de->length) { | 244 | if (((31 + de->namelen + de->down*4 + 3) & ~3) != le16_to_cpu(de->length)) { |
241 | if (((31 + de->namelen + de->down*4 + 3) & ~3) < de->length && s->s_flags & MS_RDONLY) goto ok; | 245 | if (((31 + de->namelen + de->down*4 + 3) & ~3) < le16_to_cpu(de->length) && s->s_flags & MS_RDONLY) goto ok; |
242 | hpfs_error(s, "namelen does not match dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp); | 246 | hpfs_error(s, "namelen does not match dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp); |
243 | goto bail; | 247 | goto bail; |
244 | } | 248 | } |
@@ -251,7 +255,7 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno, | |||
251 | pp = p; | 255 | pp = p; |
252 | 256 | ||
253 | } | 257 | } |
254 | if (p != dnode->first_free) { | 258 | if (p != le32_to_cpu(dnode->first_free)) { |
255 | hpfs_error(s, "size on last dirent does not match first_free; dnode %08x", secno); | 259 | hpfs_error(s, "size on last dirent does not match first_free; dnode %08x", secno); |
256 | goto bail; | 260 | goto bail; |
257 | } | 261 | } |
@@ -277,7 +281,7 @@ dnode_secno hpfs_fnode_dno(struct super_block *s, ino_t ino) | |||
277 | if (!fnode) | 281 | if (!fnode) |
278 | return 0; | 282 | return 0; |
279 | 283 | ||
280 | dno = fnode->u.external[0].disk_secno; | 284 | dno = le32_to_cpu(fnode->u.external[0].disk_secno); |
281 | brelse(bh); | 285 | brelse(bh); |
282 | return dno; | 286 | return dno; |
283 | } | 287 | } |
diff --git a/fs/hpfs/name.c b/fs/hpfs/name.c index f24736d7a43..9acdf338def 100644 --- a/fs/hpfs/name.c +++ b/fs/hpfs/name.c | |||
@@ -8,39 +8,6 @@ | |||
8 | 8 | ||
9 | #include "hpfs_fn.h" | 9 | #include "hpfs_fn.h" |
10 | 10 | ||
11 | static const char *text_postfix[]={ | ||
12 | ".ASM", ".BAS", ".BAT", ".C", ".CC", ".CFG", ".CMD", ".CON", ".CPP", ".DEF", | ||
13 | ".DOC", ".DPR", ".ERX", ".H", ".HPP", ".HTM", ".HTML", ".JAVA", ".LOG", ".PAS", | ||
14 | ".RC", ".TEX", ".TXT", ".Y", ""}; | ||
15 | |||
16 | static const char *text_prefix[]={ | ||
17 | "AUTOEXEC.", "CHANGES", "COPYING", "CONFIG.", "CREDITS", "FAQ", "FILE_ID.DIZ", | ||
18 | "MAKEFILE", "READ.ME", "README", "TERMCAP", ""}; | ||
19 | |||
20 | void hpfs_decide_conv(struct inode *inode, const unsigned char *name, unsigned len) | ||
21 | { | ||
22 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); | ||
23 | int i; | ||
24 | if (hpfs_inode->i_conv != CONV_AUTO) return; | ||
25 | for (i = 0; *text_postfix[i]; i++) { | ||
26 | int l = strlen(text_postfix[i]); | ||
27 | if (l <= len) | ||
28 | if (!hpfs_compare_names(inode->i_sb, text_postfix[i], l, name + len - l, l, 0)) | ||
29 | goto text; | ||
30 | } | ||
31 | for (i = 0; *text_prefix[i]; i++) { | ||
32 | int l = strlen(text_prefix[i]); | ||
33 | if (l <= len) | ||
34 | if (!hpfs_compare_names(inode->i_sb, text_prefix[i], l, name, l, 0)) | ||
35 | goto text; | ||
36 | } | ||
37 | hpfs_inode->i_conv = CONV_BINARY; | ||
38 | return; | ||
39 | text: | ||
40 | hpfs_inode->i_conv = CONV_TEXT; | ||
41 | return; | ||
42 | } | ||
43 | |||
44 | static inline int not_allowed_char(unsigned char c) | 11 | static inline int not_allowed_char(unsigned char c) |
45 | { | 12 | { |
46 | return c<' ' || c=='"' || c=='*' || c=='/' || c==':' || c=='<' || | 13 | return c<' ' || c=='"' || c=='*' || c=='/' || c==':' || c=='<' || |
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index d5f8c8a1902..1f05839c27a 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c | |||
@@ -29,7 +29,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
29 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); | 29 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); |
30 | if (!fnode) | 30 | if (!fnode) |
31 | goto bail; | 31 | goto bail; |
32 | dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0, 1); | 32 | dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0); |
33 | if (!dnode) | 33 | if (!dnode) |
34 | goto bail1; | 34 | goto bail1; |
35 | memset(&dee, 0, sizeof dee); | 35 | memset(&dee, 0, sizeof dee); |
@@ -37,8 +37,8 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
37 | if (!(mode & 0222)) dee.read_only = 1; | 37 | if (!(mode & 0222)) dee.read_only = 1; |
38 | /*dee.archive = 0;*/ | 38 | /*dee.archive = 0;*/ |
39 | dee.hidden = name[0] == '.'; | 39 | dee.hidden = name[0] == '.'; |
40 | dee.fnode = fno; | 40 | dee.fnode = cpu_to_le32(fno); |
41 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); | 41 | dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
42 | result = new_inode(dir->i_sb); | 42 | result = new_inode(dir->i_sb); |
43 | if (!result) | 43 | if (!result) |
44 | goto bail2; | 44 | goto bail2; |
@@ -46,7 +46,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
46 | result->i_ino = fno; | 46 | result->i_ino = fno; |
47 | hpfs_i(result)->i_parent_dir = dir->i_ino; | 47 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
48 | hpfs_i(result)->i_dno = dno; | 48 | hpfs_i(result)->i_dno = dno; |
49 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); | 49 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)); |
50 | result->i_ctime.tv_nsec = 0; | 50 | result->i_ctime.tv_nsec = 0; |
51 | result->i_mtime.tv_nsec = 0; | 51 | result->i_mtime.tv_nsec = 0; |
52 | result->i_atime.tv_nsec = 0; | 52 | result->i_atime.tv_nsec = 0; |
@@ -60,8 +60,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
60 | if (dee.read_only) | 60 | if (dee.read_only) |
61 | result->i_mode &= ~0222; | 61 | result->i_mode &= ~0222; |
62 | 62 | ||
63 | mutex_lock(&hpfs_i(dir)->i_mutex); | 63 | r = hpfs_add_dirent(dir, name, len, &dee); |
64 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
65 | if (r == 1) | 64 | if (r == 1) |
66 | goto bail3; | 65 | goto bail3; |
67 | if (r == -1) { | 66 | if (r == -1) { |
@@ -70,21 +69,21 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
70 | } | 69 | } |
71 | fnode->len = len; | 70 | fnode->len = len; |
72 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 71 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
73 | fnode->up = dir->i_ino; | 72 | fnode->up = cpu_to_le32(dir->i_ino); |
74 | fnode->dirflag = 1; | 73 | fnode->dirflag = 1; |
75 | fnode->btree.n_free_nodes = 7; | 74 | fnode->btree.n_free_nodes = 7; |
76 | fnode->btree.n_used_nodes = 1; | 75 | fnode->btree.n_used_nodes = 1; |
77 | fnode->btree.first_free = 0x14; | 76 | fnode->btree.first_free = cpu_to_le16(0x14); |
78 | fnode->u.external[0].disk_secno = dno; | 77 | fnode->u.external[0].disk_secno = cpu_to_le32(dno); |
79 | fnode->u.external[0].file_secno = -1; | 78 | fnode->u.external[0].file_secno = cpu_to_le32(-1); |
80 | dnode->root_dnode = 1; | 79 | dnode->root_dnode = 1; |
81 | dnode->up = fno; | 80 | dnode->up = cpu_to_le32(fno); |
82 | de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0); | 81 | de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0); |
83 | de->creation_date = de->write_date = de->read_date = gmt_to_local(dir->i_sb, get_seconds()); | 82 | de->creation_date = de->write_date = de->read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
84 | if (!(mode & 0222)) de->read_only = 1; | 83 | if (!(mode & 0222)) de->read_only = 1; |
85 | de->first = de->directory = 1; | 84 | de->first = de->directory = 1; |
86 | /*de->hidden = de->system = 0;*/ | 85 | /*de->hidden = de->system = 0;*/ |
87 | de->fnode = fno; | 86 | de->fnode = cpu_to_le32(fno); |
88 | mark_buffer_dirty(bh); | 87 | mark_buffer_dirty(bh); |
89 | brelse(bh); | 88 | brelse(bh); |
90 | hpfs_mark_4buffers_dirty(&qbh0); | 89 | hpfs_mark_4buffers_dirty(&qbh0); |
@@ -101,11 +100,9 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
101 | hpfs_write_inode_nolock(result); | 100 | hpfs_write_inode_nolock(result); |
102 | } | 101 | } |
103 | d_instantiate(dentry, result); | 102 | d_instantiate(dentry, result); |
104 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
105 | hpfs_unlock(dir->i_sb); | 103 | hpfs_unlock(dir->i_sb); |
106 | return 0; | 104 | return 0; |
107 | bail3: | 105 | bail3: |
108 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
109 | iput(result); | 106 | iput(result); |
110 | bail2: | 107 | bail2: |
111 | hpfs_brelse4(&qbh0); | 108 | hpfs_brelse4(&qbh0); |
@@ -140,8 +137,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
140 | if (!(mode & 0222)) dee.read_only = 1; | 137 | if (!(mode & 0222)) dee.read_only = 1; |
141 | dee.archive = 1; | 138 | dee.archive = 1; |
142 | dee.hidden = name[0] == '.'; | 139 | dee.hidden = name[0] == '.'; |
143 | dee.fnode = fno; | 140 | dee.fnode = cpu_to_le32(fno); |
144 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); | 141 | dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
145 | 142 | ||
146 | result = new_inode(dir->i_sb); | 143 | result = new_inode(dir->i_sb); |
147 | if (!result) | 144 | if (!result) |
@@ -154,9 +151,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
154 | result->i_op = &hpfs_file_iops; | 151 | result->i_op = &hpfs_file_iops; |
155 | result->i_fop = &hpfs_file_ops; | 152 | result->i_fop = &hpfs_file_ops; |
156 | result->i_nlink = 1; | 153 | result->i_nlink = 1; |
157 | hpfs_decide_conv(result, name, len); | ||
158 | hpfs_i(result)->i_parent_dir = dir->i_ino; | 154 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
159 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); | 155 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)); |
160 | result->i_ctime.tv_nsec = 0; | 156 | result->i_ctime.tv_nsec = 0; |
161 | result->i_mtime.tv_nsec = 0; | 157 | result->i_mtime.tv_nsec = 0; |
162 | result->i_atime.tv_nsec = 0; | 158 | result->i_atime.tv_nsec = 0; |
@@ -168,8 +164,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
168 | result->i_data.a_ops = &hpfs_aops; | 164 | result->i_data.a_ops = &hpfs_aops; |
169 | hpfs_i(result)->mmu_private = 0; | 165 | hpfs_i(result)->mmu_private = 0; |
170 | 166 | ||
171 | mutex_lock(&hpfs_i(dir)->i_mutex); | 167 | r = hpfs_add_dirent(dir, name, len, &dee); |
172 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
173 | if (r == 1) | 168 | if (r == 1) |
174 | goto bail2; | 169 | goto bail2; |
175 | if (r == -1) { | 170 | if (r == -1) { |
@@ -178,7 +173,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
178 | } | 173 | } |
179 | fnode->len = len; | 174 | fnode->len = len; |
180 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 175 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
181 | fnode->up = dir->i_ino; | 176 | fnode->up = cpu_to_le32(dir->i_ino); |
182 | mark_buffer_dirty(bh); | 177 | mark_buffer_dirty(bh); |
183 | brelse(bh); | 178 | brelse(bh); |
184 | 179 | ||
@@ -193,12 +188,10 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
193 | hpfs_write_inode_nolock(result); | 188 | hpfs_write_inode_nolock(result); |
194 | } | 189 | } |
195 | d_instantiate(dentry, result); | 190 | d_instantiate(dentry, result); |
196 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
197 | hpfs_unlock(dir->i_sb); | 191 | hpfs_unlock(dir->i_sb); |
198 | return 0; | 192 | return 0; |
199 | 193 | ||
200 | bail2: | 194 | bail2: |
201 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
202 | iput(result); | 195 | iput(result); |
203 | bail1: | 196 | bail1: |
204 | brelse(bh); | 197 | brelse(bh); |
@@ -232,8 +225,8 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
232 | if (!(mode & 0222)) dee.read_only = 1; | 225 | if (!(mode & 0222)) dee.read_only = 1; |
233 | dee.archive = 1; | 226 | dee.archive = 1; |
234 | dee.hidden = name[0] == '.'; | 227 | dee.hidden = name[0] == '.'; |
235 | dee.fnode = fno; | 228 | dee.fnode = cpu_to_le32(fno); |
236 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); | 229 | dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
237 | 230 | ||
238 | result = new_inode(dir->i_sb); | 231 | result = new_inode(dir->i_sb); |
239 | if (!result) | 232 | if (!result) |
@@ -242,7 +235,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
242 | hpfs_init_inode(result); | 235 | hpfs_init_inode(result); |
243 | result->i_ino = fno; | 236 | result->i_ino = fno; |
244 | hpfs_i(result)->i_parent_dir = dir->i_ino; | 237 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
245 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); | 238 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)); |
246 | result->i_ctime.tv_nsec = 0; | 239 | result->i_ctime.tv_nsec = 0; |
247 | result->i_mtime.tv_nsec = 0; | 240 | result->i_mtime.tv_nsec = 0; |
248 | result->i_atime.tv_nsec = 0; | 241 | result->i_atime.tv_nsec = 0; |
@@ -254,8 +247,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
254 | result->i_blocks = 1; | 247 | result->i_blocks = 1; |
255 | init_special_inode(result, mode, rdev); | 248 | init_special_inode(result, mode, rdev); |
256 | 249 | ||
257 | mutex_lock(&hpfs_i(dir)->i_mutex); | 250 | r = hpfs_add_dirent(dir, name, len, &dee); |
258 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
259 | if (r == 1) | 251 | if (r == 1) |
260 | goto bail2; | 252 | goto bail2; |
261 | if (r == -1) { | 253 | if (r == -1) { |
@@ -264,19 +256,17 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
264 | } | 256 | } |
265 | fnode->len = len; | 257 | fnode->len = len; |
266 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 258 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
267 | fnode->up = dir->i_ino; | 259 | fnode->up = cpu_to_le32(dir->i_ino); |
268 | mark_buffer_dirty(bh); | 260 | mark_buffer_dirty(bh); |
269 | 261 | ||
270 | insert_inode_hash(result); | 262 | insert_inode_hash(result); |
271 | 263 | ||
272 | hpfs_write_inode_nolock(result); | 264 | hpfs_write_inode_nolock(result); |
273 | d_instantiate(dentry, result); | 265 | d_instantiate(dentry, result); |
274 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
275 | brelse(bh); | 266 | brelse(bh); |
276 | hpfs_unlock(dir->i_sb); | 267 | hpfs_unlock(dir->i_sb); |
277 | return 0; | 268 | return 0; |
278 | bail2: | 269 | bail2: |
279 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
280 | iput(result); | 270 | iput(result); |
281 | bail1: | 271 | bail1: |
282 | brelse(bh); | 272 | brelse(bh); |
@@ -310,8 +300,8 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
310 | memset(&dee, 0, sizeof dee); | 300 | memset(&dee, 0, sizeof dee); |
311 | dee.archive = 1; | 301 | dee.archive = 1; |
312 | dee.hidden = name[0] == '.'; | 302 | dee.hidden = name[0] == '.'; |
313 | dee.fnode = fno; | 303 | dee.fnode = cpu_to_le32(fno); |
314 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); | 304 | dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
315 | 305 | ||
316 | result = new_inode(dir->i_sb); | 306 | result = new_inode(dir->i_sb); |
317 | if (!result) | 307 | if (!result) |
@@ -319,7 +309,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
319 | result->i_ino = fno; | 309 | result->i_ino = fno; |
320 | hpfs_init_inode(result); | 310 | hpfs_init_inode(result); |
321 | hpfs_i(result)->i_parent_dir = dir->i_ino; | 311 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
322 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); | 312 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)); |
323 | result->i_ctime.tv_nsec = 0; | 313 | result->i_ctime.tv_nsec = 0; |
324 | result->i_mtime.tv_nsec = 0; | 314 | result->i_mtime.tv_nsec = 0; |
325 | result->i_atime.tv_nsec = 0; | 315 | result->i_atime.tv_nsec = 0; |
@@ -333,8 +323,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
333 | result->i_op = &page_symlink_inode_operations; | 323 | result->i_op = &page_symlink_inode_operations; |
334 | result->i_data.a_ops = &hpfs_symlink_aops; | 324 | result->i_data.a_ops = &hpfs_symlink_aops; |
335 | 325 | ||
336 | mutex_lock(&hpfs_i(dir)->i_mutex); | 326 | r = hpfs_add_dirent(dir, name, len, &dee); |
337 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
338 | if (r == 1) | 327 | if (r == 1) |
339 | goto bail2; | 328 | goto bail2; |
340 | if (r == -1) { | 329 | if (r == -1) { |
@@ -343,7 +332,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
343 | } | 332 | } |
344 | fnode->len = len; | 333 | fnode->len = len; |
345 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 334 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
346 | fnode->up = dir->i_ino; | 335 | fnode->up = cpu_to_le32(dir->i_ino); |
347 | hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink)); | 336 | hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink)); |
348 | mark_buffer_dirty(bh); | 337 | mark_buffer_dirty(bh); |
349 | brelse(bh); | 338 | brelse(bh); |
@@ -352,11 +341,9 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
352 | 341 | ||
353 | hpfs_write_inode_nolock(result); | 342 | hpfs_write_inode_nolock(result); |
354 | d_instantiate(dentry, result); | 343 | d_instantiate(dentry, result); |
355 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
356 | hpfs_unlock(dir->i_sb); | 344 | hpfs_unlock(dir->i_sb); |
357 | return 0; | 345 | return 0; |
358 | bail2: | 346 | bail2: |
359 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
360 | iput(result); | 347 | iput(result); |
361 | bail1: | 348 | bail1: |
362 | brelse(bh); | 349 | brelse(bh); |
@@ -374,7 +361,6 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) | |||
374 | struct hpfs_dirent *de; | 361 | struct hpfs_dirent *de; |
375 | struct inode *inode = dentry->d_inode; | 362 | struct inode *inode = dentry->d_inode; |
376 | dnode_secno dno; | 363 | dnode_secno dno; |
377 | fnode_secno fno; | ||
378 | int r; | 364 | int r; |
379 | int rep = 0; | 365 | int rep = 0; |
380 | int err; | 366 | int err; |
@@ -382,8 +368,6 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) | |||
382 | hpfs_lock(dir->i_sb); | 368 | hpfs_lock(dir->i_sb); |
383 | hpfs_adjust_length(name, &len); | 369 | hpfs_adjust_length(name, &len); |
384 | again: | 370 | again: |
385 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); | ||
386 | mutex_lock(&hpfs_i(dir)->i_mutex); | ||
387 | err = -ENOENT; | 371 | err = -ENOENT; |
388 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); | 372 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
389 | if (!de) | 373 | if (!de) |
@@ -397,7 +381,6 @@ again: | |||
397 | if (de->directory) | 381 | if (de->directory) |
398 | goto out1; | 382 | goto out1; |
399 | 383 | ||
400 | fno = de->fnode; | ||
401 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); | 384 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); |
402 | switch (r) { | 385 | switch (r) { |
403 | case 1: | 386 | case 1: |
@@ -410,8 +393,6 @@ again: | |||
410 | if (rep++) | 393 | if (rep++) |
411 | break; | 394 | break; |
412 | 395 | ||
413 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
414 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | ||
415 | dentry_unhash(dentry); | 396 | dentry_unhash(dentry); |
416 | if (!d_unhashed(dentry)) { | 397 | if (!d_unhashed(dentry)) { |
417 | dput(dentry); | 398 | dput(dentry); |
@@ -445,8 +426,6 @@ again: | |||
445 | out1: | 426 | out1: |
446 | hpfs_brelse4(&qbh); | 427 | hpfs_brelse4(&qbh); |
447 | out: | 428 | out: |
448 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
449 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | ||
450 | hpfs_unlock(dir->i_sb); | 429 | hpfs_unlock(dir->i_sb); |
451 | return err; | 430 | return err; |
452 | } | 431 | } |
@@ -459,15 +438,12 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
459 | struct hpfs_dirent *de; | 438 | struct hpfs_dirent *de; |
460 | struct inode *inode = dentry->d_inode; | 439 | struct inode *inode = dentry->d_inode; |
461 | dnode_secno dno; | 440 | dnode_secno dno; |
462 | fnode_secno fno; | ||
463 | int n_items = 0; | 441 | int n_items = 0; |
464 | int err; | 442 | int err; |
465 | int r; | 443 | int r; |
466 | 444 | ||
467 | hpfs_adjust_length(name, &len); | 445 | hpfs_adjust_length(name, &len); |
468 | hpfs_lock(dir->i_sb); | 446 | hpfs_lock(dir->i_sb); |
469 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); | ||
470 | mutex_lock(&hpfs_i(dir)->i_mutex); | ||
471 | err = -ENOENT; | 447 | err = -ENOENT; |
472 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); | 448 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
473 | if (!de) | 449 | if (!de) |
@@ -486,7 +462,6 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
486 | if (n_items) | 462 | if (n_items) |
487 | goto out1; | 463 | goto out1; |
488 | 464 | ||
489 | fno = de->fnode; | ||
490 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); | 465 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); |
491 | switch (r) { | 466 | switch (r) { |
492 | case 1: | 467 | case 1: |
@@ -505,8 +480,6 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
505 | out1: | 480 | out1: |
506 | hpfs_brelse4(&qbh); | 481 | hpfs_brelse4(&qbh); |
507 | out: | 482 | out: |
508 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
509 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | ||
510 | hpfs_unlock(dir->i_sb); | 483 | hpfs_unlock(dir->i_sb); |
511 | return err; | 484 | return err; |
512 | } | 485 | } |
@@ -568,12 +541,6 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
568 | 541 | ||
569 | hpfs_lock(i->i_sb); | 542 | hpfs_lock(i->i_sb); |
570 | /* order doesn't matter, due to VFS exclusion */ | 543 | /* order doesn't matter, due to VFS exclusion */ |
571 | mutex_lock(&hpfs_i(i)->i_parent_mutex); | ||
572 | if (new_inode) | ||
573 | mutex_lock(&hpfs_i(new_inode)->i_parent_mutex); | ||
574 | mutex_lock(&hpfs_i(old_dir)->i_mutex); | ||
575 | if (new_dir != old_dir) | ||
576 | mutex_lock(&hpfs_i(new_dir)->i_mutex); | ||
577 | 544 | ||
578 | /* Erm? Moving over the empty non-busy directory is perfectly legal */ | 545 | /* Erm? Moving over the empty non-busy directory is perfectly legal */ |
579 | if (new_inode && S_ISDIR(new_inode->i_mode)) { | 546 | if (new_inode && S_ISDIR(new_inode->i_mode)) { |
@@ -610,9 +577,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
610 | 577 | ||
611 | if (new_dir == old_dir) hpfs_brelse4(&qbh); | 578 | if (new_dir == old_dir) hpfs_brelse4(&qbh); |
612 | 579 | ||
613 | hpfs_lock_creation(i->i_sb); | 580 | if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de))) { |
614 | if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de, 1))) { | ||
615 | hpfs_unlock_creation(i->i_sb); | ||
616 | if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!"); | 581 | if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!"); |
617 | err = r == 1 ? -ENOSPC : -EFSERROR; | 582 | err = r == 1 ? -ENOSPC : -EFSERROR; |
618 | if (new_dir != old_dir) hpfs_brelse4(&qbh); | 583 | if (new_dir != old_dir) hpfs_brelse4(&qbh); |
@@ -621,20 +586,17 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
621 | 586 | ||
622 | if (new_dir == old_dir) | 587 | if (new_dir == old_dir) |
623 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { | 588 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { |
624 | hpfs_unlock_creation(i->i_sb); | ||
625 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); | 589 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); |
626 | err = -ENOENT; | 590 | err = -ENOENT; |
627 | goto end1; | 591 | goto end1; |
628 | } | 592 | } |
629 | 593 | ||
630 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) { | 594 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) { |
631 | hpfs_unlock_creation(i->i_sb); | ||
632 | hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent"); | 595 | hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent"); |
633 | err = r == 2 ? -ENOSPC : -EFSERROR; | 596 | err = r == 2 ? -ENOSPC : -EFSERROR; |
634 | goto end1; | 597 | goto end1; |
635 | } | 598 | } |
636 | hpfs_unlock_creation(i->i_sb); | 599 | |
637 | |||
638 | end: | 600 | end: |
639 | hpfs_i(i)->i_parent_dir = new_dir->i_ino; | 601 | hpfs_i(i)->i_parent_dir = new_dir->i_ino; |
640 | if (S_ISDIR(i->i_mode)) { | 602 | if (S_ISDIR(i->i_mode)) { |
@@ -642,22 +604,14 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
642 | drop_nlink(old_dir); | 604 | drop_nlink(old_dir); |
643 | } | 605 | } |
644 | if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) { | 606 | if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) { |
645 | fnode->up = new_dir->i_ino; | 607 | fnode->up = cpu_to_le32(new_dir->i_ino); |
646 | fnode->len = new_len; | 608 | fnode->len = new_len; |
647 | memcpy(fnode->name, new_name, new_len>15?15:new_len); | 609 | memcpy(fnode->name, new_name, new_len>15?15:new_len); |
648 | if (new_len < 15) memset(&fnode->name[new_len], 0, 15 - new_len); | 610 | if (new_len < 15) memset(&fnode->name[new_len], 0, 15 - new_len); |
649 | mark_buffer_dirty(bh); | 611 | mark_buffer_dirty(bh); |
650 | brelse(bh); | 612 | brelse(bh); |
651 | } | 613 | } |
652 | hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv; | ||
653 | hpfs_decide_conv(i, new_name, new_len); | ||
654 | end1: | 614 | end1: |
655 | if (old_dir != new_dir) | ||
656 | mutex_unlock(&hpfs_i(new_dir)->i_mutex); | ||
657 | mutex_unlock(&hpfs_i(old_dir)->i_mutex); | ||
658 | mutex_unlock(&hpfs_i(i)->i_parent_mutex); | ||
659 | if (new_inode) | ||
660 | mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex); | ||
661 | hpfs_unlock(i->i_sb); | 615 | hpfs_unlock(i->i_sb); |
662 | return err; | 616 | return err; |
663 | } | 617 | } |
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index c89b4080858..98580a3b500 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
@@ -18,15 +18,16 @@ | |||
18 | 18 | ||
19 | /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */ | 19 | /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */ |
20 | 20 | ||
21 | static void mark_dirty(struct super_block *s) | 21 | static void mark_dirty(struct super_block *s, int remount) |
22 | { | 22 | { |
23 | if (hpfs_sb(s)->sb_chkdsk && !(s->s_flags & MS_RDONLY)) { | 23 | if (hpfs_sb(s)->sb_chkdsk && (remount || !(s->s_flags & MS_RDONLY))) { |
24 | struct buffer_head *bh; | 24 | struct buffer_head *bh; |
25 | struct hpfs_spare_block *sb; | 25 | struct hpfs_spare_block *sb; |
26 | if ((sb = hpfs_map_sector(s, 17, &bh, 0))) { | 26 | if ((sb = hpfs_map_sector(s, 17, &bh, 0))) { |
27 | sb->dirty = 1; | 27 | sb->dirty = 1; |
28 | sb->old_wrote = 0; | 28 | sb->old_wrote = 0; |
29 | mark_buffer_dirty(bh); | 29 | mark_buffer_dirty(bh); |
30 | sync_dirty_buffer(bh); | ||
30 | brelse(bh); | 31 | brelse(bh); |
31 | } | 32 | } |
32 | } | 33 | } |
@@ -40,10 +41,12 @@ static void unmark_dirty(struct super_block *s) | |||
40 | struct buffer_head *bh; | 41 | struct buffer_head *bh; |
41 | struct hpfs_spare_block *sb; | 42 | struct hpfs_spare_block *sb; |
42 | if (s->s_flags & MS_RDONLY) return; | 43 | if (s->s_flags & MS_RDONLY) return; |
44 | sync_blockdev(s->s_bdev); | ||
43 | if ((sb = hpfs_map_sector(s, 17, &bh, 0))) { | 45 | if ((sb = hpfs_map_sector(s, 17, &bh, 0))) { |
44 | sb->dirty = hpfs_sb(s)->sb_chkdsk > 1 - hpfs_sb(s)->sb_was_error; | 46 | sb->dirty = hpfs_sb(s)->sb_chkdsk > 1 - hpfs_sb(s)->sb_was_error; |
45 | sb->old_wrote = hpfs_sb(s)->sb_chkdsk >= 2 && !hpfs_sb(s)->sb_was_error; | 47 | sb->old_wrote = hpfs_sb(s)->sb_chkdsk >= 2 && !hpfs_sb(s)->sb_was_error; |
46 | mark_buffer_dirty(bh); | 48 | mark_buffer_dirty(bh); |
49 | sync_dirty_buffer(bh); | ||
47 | brelse(bh); | 50 | brelse(bh); |
48 | } | 51 | } |
49 | } | 52 | } |
@@ -63,13 +66,13 @@ void hpfs_error(struct super_block *s, const char *fmt, ...) | |||
63 | if (!hpfs_sb(s)->sb_was_error) { | 66 | if (!hpfs_sb(s)->sb_was_error) { |
64 | if (hpfs_sb(s)->sb_err == 2) { | 67 | if (hpfs_sb(s)->sb_err == 2) { |
65 | printk("; crashing the system because you wanted it\n"); | 68 | printk("; crashing the system because you wanted it\n"); |
66 | mark_dirty(s); | 69 | mark_dirty(s, 0); |
67 | panic("HPFS panic"); | 70 | panic("HPFS panic"); |
68 | } else if (hpfs_sb(s)->sb_err == 1) { | 71 | } else if (hpfs_sb(s)->sb_err == 1) { |
69 | if (s->s_flags & MS_RDONLY) printk("; already mounted read-only\n"); | 72 | if (s->s_flags & MS_RDONLY) printk("; already mounted read-only\n"); |
70 | else { | 73 | else { |
71 | printk("; remounting read-only\n"); | 74 | printk("; remounting read-only\n"); |
72 | mark_dirty(s); | 75 | mark_dirty(s, 0); |
73 | s->s_flags |= MS_RDONLY; | 76 | s->s_flags |= MS_RDONLY; |
74 | } | 77 | } |
75 | } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); | 78 | } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); |
@@ -102,9 +105,12 @@ static void hpfs_put_super(struct super_block *s) | |||
102 | { | 105 | { |
103 | struct hpfs_sb_info *sbi = hpfs_sb(s); | 106 | struct hpfs_sb_info *sbi = hpfs_sb(s); |
104 | 107 | ||
108 | hpfs_lock(s); | ||
109 | unmark_dirty(s); | ||
110 | hpfs_unlock(s); | ||
111 | |||
105 | kfree(sbi->sb_cp_table); | 112 | kfree(sbi->sb_cp_table); |
106 | kfree(sbi->sb_bmp_dir); | 113 | kfree(sbi->sb_bmp_dir); |
107 | unmark_dirty(s); | ||
108 | s->s_fs_info = NULL; | 114 | s->s_fs_info = NULL; |
109 | kfree(sbi); | 115 | kfree(sbi); |
110 | } | 116 | } |
@@ -129,7 +135,7 @@ static unsigned count_bitmaps(struct super_block *s) | |||
129 | n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; | 135 | n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; |
130 | count = 0; | 136 | count = 0; |
131 | for (n = 0; n < n_bands; n++) | 137 | for (n = 0; n < n_bands; n++) |
132 | count += hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_bmp_dir[n]); | 138 | count += hpfs_count_one_bitmap(s, le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[n])); |
133 | return count; | 139 | return count; |
134 | } | 140 | } |
135 | 141 | ||
@@ -188,8 +194,6 @@ static void init_once(void *foo) | |||
188 | { | 194 | { |
189 | struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; | 195 | struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; |
190 | 196 | ||
191 | mutex_init(&ei->i_mutex); | ||
192 | mutex_init(&ei->i_parent_mutex); | ||
193 | inode_init_once(&ei->vfs_inode); | 197 | inode_init_once(&ei->vfs_inode); |
194 | } | 198 | } |
195 | 199 | ||
@@ -218,7 +222,6 @@ static void destroy_inodecache(void) | |||
218 | 222 | ||
219 | enum { | 223 | enum { |
220 | Opt_help, Opt_uid, Opt_gid, Opt_umask, Opt_case_lower, Opt_case_asis, | 224 | Opt_help, Opt_uid, Opt_gid, Opt_umask, Opt_case_lower, Opt_case_asis, |
221 | Opt_conv_binary, Opt_conv_text, Opt_conv_auto, | ||
222 | Opt_check_none, Opt_check_normal, Opt_check_strict, | 225 | Opt_check_none, Opt_check_normal, Opt_check_strict, |
223 | Opt_err_cont, Opt_err_ro, Opt_err_panic, | 226 | Opt_err_cont, Opt_err_ro, Opt_err_panic, |
224 | Opt_eas_no, Opt_eas_ro, Opt_eas_rw, | 227 | Opt_eas_no, Opt_eas_ro, Opt_eas_rw, |
@@ -233,9 +236,6 @@ static const match_table_t tokens = { | |||
233 | {Opt_umask, "umask=%o"}, | 236 | {Opt_umask, "umask=%o"}, |
234 | {Opt_case_lower, "case=lower"}, | 237 | {Opt_case_lower, "case=lower"}, |
235 | {Opt_case_asis, "case=asis"}, | 238 | {Opt_case_asis, "case=asis"}, |
236 | {Opt_conv_binary, "conv=binary"}, | ||
237 | {Opt_conv_text, "conv=text"}, | ||
238 | {Opt_conv_auto, "conv=auto"}, | ||
239 | {Opt_check_none, "check=none"}, | 239 | {Opt_check_none, "check=none"}, |
240 | {Opt_check_normal, "check=normal"}, | 240 | {Opt_check_normal, "check=normal"}, |
241 | {Opt_check_strict, "check=strict"}, | 241 | {Opt_check_strict, "check=strict"}, |
@@ -253,7 +253,7 @@ static const match_table_t tokens = { | |||
253 | }; | 253 | }; |
254 | 254 | ||
255 | static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask, | 255 | static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask, |
256 | int *lowercase, int *conv, int *eas, int *chk, int *errs, | 256 | int *lowercase, int *eas, int *chk, int *errs, |
257 | int *chkdsk, int *timeshift) | 257 | int *chkdsk, int *timeshift) |
258 | { | 258 | { |
259 | char *p; | 259 | char *p; |
@@ -295,15 +295,6 @@ static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask, | |||
295 | case Opt_case_asis: | 295 | case Opt_case_asis: |
296 | *lowercase = 0; | 296 | *lowercase = 0; |
297 | break; | 297 | break; |
298 | case Opt_conv_binary: | ||
299 | *conv = CONV_BINARY; | ||
300 | break; | ||
301 | case Opt_conv_text: | ||
302 | *conv = CONV_TEXT; | ||
303 | break; | ||
304 | case Opt_conv_auto: | ||
305 | *conv = CONV_AUTO; | ||
306 | break; | ||
307 | case Opt_check_none: | 298 | case Opt_check_none: |
308 | *chk = 0; | 299 | *chk = 0; |
309 | break; | 300 | break; |
@@ -370,9 +361,6 @@ HPFS filesystem options:\n\ | |||
370 | umask=xxx set mode of files that don't have mode specified in eas\n\ | 361 | umask=xxx set mode of files that don't have mode specified in eas\n\ |
371 | case=lower lowercase all files\n\ | 362 | case=lower lowercase all files\n\ |
372 | case=asis do not lowercase files (default)\n\ | 363 | case=asis do not lowercase files (default)\n\ |
373 | conv=binary do not convert CR/LF -> LF (default)\n\ | ||
374 | conv=auto convert only files with known text extensions\n\ | ||
375 | conv=text convert all files\n\ | ||
376 | check=none no fs checks - kernel may crash on corrupted filesystem\n\ | 364 | check=none no fs checks - kernel may crash on corrupted filesystem\n\ |
377 | check=normal do some checks - it should not crash (default)\n\ | 365 | check=normal do some checks - it should not crash (default)\n\ |
378 | check=strict do extra time-consuming checks, used for debugging\n\ | 366 | check=strict do extra time-consuming checks, used for debugging\n\ |
@@ -394,7 +382,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) | |||
394 | uid_t uid; | 382 | uid_t uid; |
395 | gid_t gid; | 383 | gid_t gid; |
396 | umode_t umask; | 384 | umode_t umask; |
397 | int lowercase, conv, eas, chk, errs, chkdsk, timeshift; | 385 | int lowercase, eas, chk, errs, chkdsk, timeshift; |
398 | int o; | 386 | int o; |
399 | struct hpfs_sb_info *sbi = hpfs_sb(s); | 387 | struct hpfs_sb_info *sbi = hpfs_sb(s); |
400 | char *new_opts = kstrdup(data, GFP_KERNEL); | 388 | char *new_opts = kstrdup(data, GFP_KERNEL); |
@@ -405,11 +393,11 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) | |||
405 | lock_super(s); | 393 | lock_super(s); |
406 | uid = sbi->sb_uid; gid = sbi->sb_gid; | 394 | uid = sbi->sb_uid; gid = sbi->sb_gid; |
407 | umask = 0777 & ~sbi->sb_mode; | 395 | umask = 0777 & ~sbi->sb_mode; |
408 | lowercase = sbi->sb_lowercase; conv = sbi->sb_conv; | 396 | lowercase = sbi->sb_lowercase; |
409 | eas = sbi->sb_eas; chk = sbi->sb_chk; chkdsk = sbi->sb_chkdsk; | 397 | eas = sbi->sb_eas; chk = sbi->sb_chk; chkdsk = sbi->sb_chkdsk; |
410 | errs = sbi->sb_err; timeshift = sbi->sb_timeshift; | 398 | errs = sbi->sb_err; timeshift = sbi->sb_timeshift; |
411 | 399 | ||
412 | if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase, &conv, | 400 | if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase, |
413 | &eas, &chk, &errs, &chkdsk, ×hift))) { | 401 | &eas, &chk, &errs, &chkdsk, ×hift))) { |
414 | printk("HPFS: bad mount options.\n"); | 402 | printk("HPFS: bad mount options.\n"); |
415 | goto out_err; | 403 | goto out_err; |
@@ -427,11 +415,11 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) | |||
427 | 415 | ||
428 | sbi->sb_uid = uid; sbi->sb_gid = gid; | 416 | sbi->sb_uid = uid; sbi->sb_gid = gid; |
429 | sbi->sb_mode = 0777 & ~umask; | 417 | sbi->sb_mode = 0777 & ~umask; |
430 | sbi->sb_lowercase = lowercase; sbi->sb_conv = conv; | 418 | sbi->sb_lowercase = lowercase; |
431 | sbi->sb_eas = eas; sbi->sb_chk = chk; sbi->sb_chkdsk = chkdsk; | 419 | sbi->sb_eas = eas; sbi->sb_chk = chk; sbi->sb_chkdsk = chkdsk; |
432 | sbi->sb_err = errs; sbi->sb_timeshift = timeshift; | 420 | sbi->sb_err = errs; sbi->sb_timeshift = timeshift; |
433 | 421 | ||
434 | if (!(*flags & MS_RDONLY)) mark_dirty(s); | 422 | if (!(*flags & MS_RDONLY)) mark_dirty(s, 1); |
435 | 423 | ||
436 | replace_mount_options(s, new_opts); | 424 | replace_mount_options(s, new_opts); |
437 | 425 | ||
@@ -471,7 +459,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
471 | uid_t uid; | 459 | uid_t uid; |
472 | gid_t gid; | 460 | gid_t gid; |
473 | umode_t umask; | 461 | umode_t umask; |
474 | int lowercase, conv, eas, chk, errs, chkdsk, timeshift; | 462 | int lowercase, eas, chk, errs, chkdsk, timeshift; |
475 | 463 | ||
476 | dnode_secno root_dno; | 464 | dnode_secno root_dno; |
477 | struct hpfs_dirent *de = NULL; | 465 | struct hpfs_dirent *de = NULL; |
@@ -479,11 +467,6 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
479 | 467 | ||
480 | int o; | 468 | int o; |
481 | 469 | ||
482 | if (num_possible_cpus() > 1) { | ||
483 | printk(KERN_ERR "HPFS is not SMP safe\n"); | ||
484 | return -EINVAL; | ||
485 | } | ||
486 | |||
487 | save_mount_options(s, options); | 470 | save_mount_options(s, options); |
488 | 471 | ||
489 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 472 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
@@ -495,20 +478,20 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
495 | sbi->sb_bmp_dir = NULL; | 478 | sbi->sb_bmp_dir = NULL; |
496 | sbi->sb_cp_table = NULL; | 479 | sbi->sb_cp_table = NULL; |
497 | 480 | ||
498 | mutex_init(&sbi->hpfs_creation_de); | 481 | mutex_init(&sbi->hpfs_mutex); |
482 | hpfs_lock(s); | ||
499 | 483 | ||
500 | uid = current_uid(); | 484 | uid = current_uid(); |
501 | gid = current_gid(); | 485 | gid = current_gid(); |
502 | umask = current_umask(); | 486 | umask = current_umask(); |
503 | lowercase = 0; | 487 | lowercase = 0; |
504 | conv = CONV_BINARY; | ||
505 | eas = 2; | 488 | eas = 2; |
506 | chk = 1; | 489 | chk = 1; |
507 | errs = 1; | 490 | errs = 1; |
508 | chkdsk = 1; | 491 | chkdsk = 1; |
509 | timeshift = 0; | 492 | timeshift = 0; |
510 | 493 | ||
511 | if (!(o = parse_opts(options, &uid, &gid, &umask, &lowercase, &conv, | 494 | if (!(o = parse_opts(options, &uid, &gid, &umask, &lowercase, |
512 | &eas, &chk, &errs, &chkdsk, ×hift))) { | 495 | &eas, &chk, &errs, &chkdsk, ×hift))) { |
513 | printk("HPFS: bad mount options.\n"); | 496 | printk("HPFS: bad mount options.\n"); |
514 | goto bail0; | 497 | goto bail0; |
@@ -526,9 +509,9 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
526 | if (!(spareblock = hpfs_map_sector(s, 17, &bh2, 0))) goto bail3; | 509 | if (!(spareblock = hpfs_map_sector(s, 17, &bh2, 0))) goto bail3; |
527 | 510 | ||
528 | /* Check magics */ | 511 | /* Check magics */ |
529 | if (/*bootblock->magic != BB_MAGIC | 512 | if (/*le16_to_cpu(bootblock->magic) != BB_MAGIC |
530 | ||*/ superblock->magic != SB_MAGIC | 513 | ||*/ le32_to_cpu(superblock->magic) != SB_MAGIC |
531 | || spareblock->magic != SP_MAGIC) { | 514 | || le32_to_cpu(spareblock->magic) != SP_MAGIC) { |
532 | if (!silent) printk("HPFS: Bad magic ... probably not HPFS\n"); | 515 | if (!silent) printk("HPFS: Bad magic ... probably not HPFS\n"); |
533 | goto bail4; | 516 | goto bail4; |
534 | } | 517 | } |
@@ -549,19 +532,18 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
549 | s->s_op = &hpfs_sops; | 532 | s->s_op = &hpfs_sops; |
550 | s->s_d_op = &hpfs_dentry_operations; | 533 | s->s_d_op = &hpfs_dentry_operations; |
551 | 534 | ||
552 | sbi->sb_root = superblock->root; | 535 | sbi->sb_root = le32_to_cpu(superblock->root); |
553 | sbi->sb_fs_size = superblock->n_sectors; | 536 | sbi->sb_fs_size = le32_to_cpu(superblock->n_sectors); |
554 | sbi->sb_bitmaps = superblock->bitmaps; | 537 | sbi->sb_bitmaps = le32_to_cpu(superblock->bitmaps); |
555 | sbi->sb_dirband_start = superblock->dir_band_start; | 538 | sbi->sb_dirband_start = le32_to_cpu(superblock->dir_band_start); |
556 | sbi->sb_dirband_size = superblock->n_dir_band; | 539 | sbi->sb_dirband_size = le32_to_cpu(superblock->n_dir_band); |
557 | sbi->sb_dmap = superblock->dir_band_bitmap; | 540 | sbi->sb_dmap = le32_to_cpu(superblock->dir_band_bitmap); |
558 | sbi->sb_uid = uid; | 541 | sbi->sb_uid = uid; |
559 | sbi->sb_gid = gid; | 542 | sbi->sb_gid = gid; |
560 | sbi->sb_mode = 0777 & ~umask; | 543 | sbi->sb_mode = 0777 & ~umask; |
561 | sbi->sb_n_free = -1; | 544 | sbi->sb_n_free = -1; |
562 | sbi->sb_n_free_dnodes = -1; | 545 | sbi->sb_n_free_dnodes = -1; |
563 | sbi->sb_lowercase = lowercase; | 546 | sbi->sb_lowercase = lowercase; |
564 | sbi->sb_conv = conv; | ||
565 | sbi->sb_eas = eas; | 547 | sbi->sb_eas = eas; |
566 | sbi->sb_chk = chk; | 548 | sbi->sb_chk = chk; |
567 | sbi->sb_chkdsk = chkdsk; | 549 | sbi->sb_chkdsk = chkdsk; |
@@ -573,7 +555,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
573 | sbi->sb_max_fwd_alloc = 0xffffff; | 555 | sbi->sb_max_fwd_alloc = 0xffffff; |
574 | 556 | ||
575 | /* Load bitmap directory */ | 557 | /* Load bitmap directory */ |
576 | if (!(sbi->sb_bmp_dir = hpfs_load_bitmap_directory(s, superblock->bitmaps))) | 558 | if (!(sbi->sb_bmp_dir = hpfs_load_bitmap_directory(s, le32_to_cpu(superblock->bitmaps)))) |
577 | goto bail4; | 559 | goto bail4; |
578 | 560 | ||
579 | /* Check for general fs errors*/ | 561 | /* Check for general fs errors*/ |
@@ -591,20 +573,20 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
591 | mark_buffer_dirty(bh2); | 573 | mark_buffer_dirty(bh2); |
592 | } | 574 | } |
593 | 575 | ||
594 | if (spareblock->hotfixes_used || spareblock->n_spares_used) { | 576 | if (le32_to_cpu(spareblock->hotfixes_used) || le32_to_cpu(spareblock->n_spares_used)) { |
595 | if (errs >= 2) { | 577 | if (errs >= 2) { |
596 | printk("HPFS: Hotfixes not supported here, try chkdsk\n"); | 578 | printk("HPFS: Hotfixes not supported here, try chkdsk\n"); |
597 | mark_dirty(s); | 579 | mark_dirty(s, 0); |
598 | goto bail4; | 580 | goto bail4; |
599 | } | 581 | } |
600 | hpfs_error(s, "hotfixes not supported here, try chkdsk"); | 582 | hpfs_error(s, "hotfixes not supported here, try chkdsk"); |
601 | if (errs == 0) printk("HPFS: Proceeding, but your filesystem will be probably corrupted by this driver...\n"); | 583 | if (errs == 0) printk("HPFS: Proceeding, but your filesystem will be probably corrupted by this driver...\n"); |
602 | else printk("HPFS: This driver may read bad files or crash when operating on disk with hotfixes.\n"); | 584 | else printk("HPFS: This driver may read bad files or crash when operating on disk with hotfixes.\n"); |
603 | } | 585 | } |
604 | if (spareblock->n_dnode_spares != spareblock->n_dnode_spares_free) { | 586 | if (le32_to_cpu(spareblock->n_dnode_spares) != le32_to_cpu(spareblock->n_dnode_spares_free)) { |
605 | if (errs >= 2) { | 587 | if (errs >= 2) { |
606 | printk("HPFS: Spare dnodes used, try chkdsk\n"); | 588 | printk("HPFS: Spare dnodes used, try chkdsk\n"); |
607 | mark_dirty(s); | 589 | mark_dirty(s, 0); |
608 | goto bail4; | 590 | goto bail4; |
609 | } | 591 | } |
610 | hpfs_error(s, "warning: spare dnodes used, try chkdsk"); | 592 | hpfs_error(s, "warning: spare dnodes used, try chkdsk"); |
@@ -612,26 +594,26 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
612 | } | 594 | } |
613 | if (chk) { | 595 | if (chk) { |
614 | unsigned a; | 596 | unsigned a; |
615 | if (superblock->dir_band_end - superblock->dir_band_start + 1 != superblock->n_dir_band || | 597 | if (le32_to_cpu(superblock->dir_band_end) - le32_to_cpu(superblock->dir_band_start) + 1 != le32_to_cpu(superblock->n_dir_band) || |
616 | superblock->dir_band_end < superblock->dir_band_start || superblock->n_dir_band > 0x4000) { | 598 | le32_to_cpu(superblock->dir_band_end) < le32_to_cpu(superblock->dir_band_start) || le32_to_cpu(superblock->n_dir_band) > 0x4000) { |
617 | hpfs_error(s, "dir band size mismatch: dir_band_start==%08x, dir_band_end==%08x, n_dir_band==%08x", | 599 | hpfs_error(s, "dir band size mismatch: dir_band_start==%08x, dir_band_end==%08x, n_dir_band==%08x", |
618 | superblock->dir_band_start, superblock->dir_band_end, superblock->n_dir_band); | 600 | le32_to_cpu(superblock->dir_band_start), le32_to_cpu(superblock->dir_band_end), le32_to_cpu(superblock->n_dir_band)); |
619 | goto bail4; | 601 | goto bail4; |
620 | } | 602 | } |
621 | a = sbi->sb_dirband_size; | 603 | a = sbi->sb_dirband_size; |
622 | sbi->sb_dirband_size = 0; | 604 | sbi->sb_dirband_size = 0; |
623 | if (hpfs_chk_sectors(s, superblock->dir_band_start, superblock->n_dir_band, "dir_band") || | 605 | if (hpfs_chk_sectors(s, le32_to_cpu(superblock->dir_band_start), le32_to_cpu(superblock->n_dir_band), "dir_band") || |
624 | hpfs_chk_sectors(s, superblock->dir_band_bitmap, 4, "dir_band_bitmap") || | 606 | hpfs_chk_sectors(s, le32_to_cpu(superblock->dir_band_bitmap), 4, "dir_band_bitmap") || |
625 | hpfs_chk_sectors(s, superblock->bitmaps, 4, "bitmaps")) { | 607 | hpfs_chk_sectors(s, le32_to_cpu(superblock->bitmaps), 4, "bitmaps")) { |
626 | mark_dirty(s); | 608 | mark_dirty(s, 0); |
627 | goto bail4; | 609 | goto bail4; |
628 | } | 610 | } |
629 | sbi->sb_dirband_size = a; | 611 | sbi->sb_dirband_size = a; |
630 | } else printk("HPFS: You really don't want any checks? You are crazy...\n"); | 612 | } else printk("HPFS: You really don't want any checks? You are crazy...\n"); |
631 | 613 | ||
632 | /* Load code page table */ | 614 | /* Load code page table */ |
633 | if (spareblock->n_code_pages) | 615 | if (le32_to_cpu(spareblock->n_code_pages)) |
634 | if (!(sbi->sb_cp_table = hpfs_load_code_page(s, spareblock->code_page_dir))) | 616 | if (!(sbi->sb_cp_table = hpfs_load_code_page(s, le32_to_cpu(spareblock->code_page_dir)))) |
635 | printk("HPFS: Warning: code page support is disabled\n"); | 617 | printk("HPFS: Warning: code page support is disabled\n"); |
636 | 618 | ||
637 | brelse(bh2); | 619 | brelse(bh2); |
@@ -660,13 +642,13 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
660 | if (!de) | 642 | if (!de) |
661 | hpfs_error(s, "unable to find root dir"); | 643 | hpfs_error(s, "unable to find root dir"); |
662 | else { | 644 | else { |
663 | root->i_atime.tv_sec = local_to_gmt(s, de->read_date); | 645 | root->i_atime.tv_sec = local_to_gmt(s, le32_to_cpu(de->read_date)); |
664 | root->i_atime.tv_nsec = 0; | 646 | root->i_atime.tv_nsec = 0; |
665 | root->i_mtime.tv_sec = local_to_gmt(s, de->write_date); | 647 | root->i_mtime.tv_sec = local_to_gmt(s, le32_to_cpu(de->write_date)); |
666 | root->i_mtime.tv_nsec = 0; | 648 | root->i_mtime.tv_nsec = 0; |
667 | root->i_ctime.tv_sec = local_to_gmt(s, de->creation_date); | 649 | root->i_ctime.tv_sec = local_to_gmt(s, le32_to_cpu(de->creation_date)); |
668 | root->i_ctime.tv_nsec = 0; | 650 | root->i_ctime.tv_nsec = 0; |
669 | hpfs_i(root)->i_ea_size = de->ea_size; | 651 | hpfs_i(root)->i_ea_size = le16_to_cpu(de->ea_size); |
670 | hpfs_i(root)->i_parent_dir = root->i_ino; | 652 | hpfs_i(root)->i_parent_dir = root->i_ino; |
671 | if (root->i_size == -1) | 653 | if (root->i_size == -1) |
672 | root->i_size = 2048; | 654 | root->i_size = 2048; |
@@ -674,6 +656,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
674 | root->i_blocks = 5; | 656 | root->i_blocks = 5; |
675 | hpfs_brelse4(&qbh); | 657 | hpfs_brelse4(&qbh); |
676 | } | 658 | } |
659 | hpfs_unlock(s); | ||
677 | return 0; | 660 | return 0; |
678 | 661 | ||
679 | bail4: brelse(bh2); | 662 | bail4: brelse(bh2); |
@@ -681,6 +664,7 @@ bail3: brelse(bh1); | |||
681 | bail2: brelse(bh0); | 664 | bail2: brelse(bh0); |
682 | bail1: | 665 | bail1: |
683 | bail0: | 666 | bail0: |
667 | hpfs_unlock(s); | ||
684 | kfree(sbi->sb_bmp_dir); | 668 | kfree(sbi->sb_bmp_dir); |
685 | kfree(sbi->sb_cp_table); | 669 | kfree(sbi->sb_cp_table); |
686 | s->s_fs_info = NULL; | 670 | s->s_fs_info = NULL; |
diff --git a/fs/logfs/super.c b/fs/logfs/super.c index 33435e4b14d..ce03a182c77 100644 --- a/fs/logfs/super.c +++ b/fs/logfs/super.c | |||
@@ -480,10 +480,6 @@ static int logfs_read_sb(struct super_block *sb, int read_only) | |||
480 | !read_only) | 480 | !read_only) |
481 | return -EIO; | 481 | return -EIO; |
482 | 482 | ||
483 | mutex_init(&super->s_dirop_mutex); | ||
484 | mutex_init(&super->s_object_alias_mutex); | ||
485 | INIT_LIST_HEAD(&super->s_freeing_list); | ||
486 | |||
487 | ret = logfs_init_rw(sb); | 483 | ret = logfs_init_rw(sb); |
488 | if (ret) | 484 | if (ret) |
489 | return ret; | 485 | return ret; |
@@ -601,6 +597,10 @@ static struct dentry *logfs_mount(struct file_system_type *type, int flags, | |||
601 | if (!super) | 597 | if (!super) |
602 | return ERR_PTR(-ENOMEM); | 598 | return ERR_PTR(-ENOMEM); |
603 | 599 | ||
600 | mutex_init(&super->s_dirop_mutex); | ||
601 | mutex_init(&super->s_object_alias_mutex); | ||
602 | INIT_LIST_HEAD(&super->s_freeing_list); | ||
603 | |||
604 | if (!devname) | 604 | if (!devname) |
605 | err = logfs_get_sb_bdev(super, type, devname); | 605 | err = logfs_get_sb_bdev(super, type, devname); |
606 | else if (strncmp(devname, "mtd", 3)) | 606 | else if (strncmp(devname, "mtd", 3)) |
diff --git a/fs/namei.c b/fs/namei.c index 54fc993e302..e3c4f112ebf 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -179,7 +179,7 @@ EXPORT_SYMBOL(putname); | |||
179 | static int acl_permission_check(struct inode *inode, int mask, unsigned int flags, | 179 | static int acl_permission_check(struct inode *inode, int mask, unsigned int flags, |
180 | int (*check_acl)(struct inode *inode, int mask, unsigned int flags)) | 180 | int (*check_acl)(struct inode *inode, int mask, unsigned int flags)) |
181 | { | 181 | { |
182 | umode_t mode = inode->i_mode; | 182 | unsigned int mode = inode->i_mode; |
183 | 183 | ||
184 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; | 184 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; |
185 | 185 | ||
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c index 6f8192f4cfc..be79dc9f386 100644 --- a/fs/nfs/nfs4filelayout.c +++ b/fs/nfs/nfs4filelayout.c | |||
@@ -117,6 +117,8 @@ static int filelayout_async_handle_error(struct rpc_task *task, | |||
117 | case -EKEYEXPIRED: | 117 | case -EKEYEXPIRED: |
118 | rpc_delay(task, FILELAYOUT_POLL_RETRY_MAX); | 118 | rpc_delay(task, FILELAYOUT_POLL_RETRY_MAX); |
119 | break; | 119 | break; |
120 | case -NFS4ERR_RETRY_UNCACHED_REP: | ||
121 | break; | ||
120 | default: | 122 | default: |
121 | dprintk("%s DS error. Retry through MDS %d\n", __func__, | 123 | dprintk("%s DS error. Retry through MDS %d\n", __func__, |
122 | task->tk_status); | 124 | task->tk_status); |
@@ -416,7 +418,8 @@ static int | |||
416 | filelayout_check_layout(struct pnfs_layout_hdr *lo, | 418 | filelayout_check_layout(struct pnfs_layout_hdr *lo, |
417 | struct nfs4_filelayout_segment *fl, | 419 | struct nfs4_filelayout_segment *fl, |
418 | struct nfs4_layoutget_res *lgr, | 420 | struct nfs4_layoutget_res *lgr, |
419 | struct nfs4_deviceid *id) | 421 | struct nfs4_deviceid *id, |
422 | gfp_t gfp_flags) | ||
420 | { | 423 | { |
421 | struct nfs4_file_layout_dsaddr *dsaddr; | 424 | struct nfs4_file_layout_dsaddr *dsaddr; |
422 | int status = -EINVAL; | 425 | int status = -EINVAL; |
@@ -439,7 +442,7 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo, | |||
439 | /* find and reference the deviceid */ | 442 | /* find and reference the deviceid */ |
440 | dsaddr = nfs4_fl_find_get_deviceid(id); | 443 | dsaddr = nfs4_fl_find_get_deviceid(id); |
441 | if (dsaddr == NULL) { | 444 | if (dsaddr == NULL) { |
442 | dsaddr = get_device_info(lo->plh_inode, id); | 445 | dsaddr = get_device_info(lo->plh_inode, id, gfp_flags); |
443 | if (dsaddr == NULL) | 446 | if (dsaddr == NULL) |
444 | goto out; | 447 | goto out; |
445 | } | 448 | } |
@@ -500,7 +503,8 @@ static int | |||
500 | filelayout_decode_layout(struct pnfs_layout_hdr *flo, | 503 | filelayout_decode_layout(struct pnfs_layout_hdr *flo, |
501 | struct nfs4_filelayout_segment *fl, | 504 | struct nfs4_filelayout_segment *fl, |
502 | struct nfs4_layoutget_res *lgr, | 505 | struct nfs4_layoutget_res *lgr, |
503 | struct nfs4_deviceid *id) | 506 | struct nfs4_deviceid *id, |
507 | gfp_t gfp_flags) | ||
504 | { | 508 | { |
505 | struct xdr_stream stream; | 509 | struct xdr_stream stream; |
506 | struct xdr_buf buf = { | 510 | struct xdr_buf buf = { |
@@ -516,7 +520,7 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo, | |||
516 | 520 | ||
517 | dprintk("%s: set_layout_map Begin\n", __func__); | 521 | dprintk("%s: set_layout_map Begin\n", __func__); |
518 | 522 | ||
519 | scratch = alloc_page(GFP_KERNEL); | 523 | scratch = alloc_page(gfp_flags); |
520 | if (!scratch) | 524 | if (!scratch) |
521 | return -ENOMEM; | 525 | return -ENOMEM; |
522 | 526 | ||
@@ -554,13 +558,13 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo, | |||
554 | goto out_err; | 558 | goto out_err; |
555 | 559 | ||
556 | fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *), | 560 | fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *), |
557 | GFP_KERNEL); | 561 | gfp_flags); |
558 | if (!fl->fh_array) | 562 | if (!fl->fh_array) |
559 | goto out_err; | 563 | goto out_err; |
560 | 564 | ||
561 | for (i = 0; i < fl->num_fh; i++) { | 565 | for (i = 0; i < fl->num_fh; i++) { |
562 | /* Do we want to use a mempool here? */ | 566 | /* Do we want to use a mempool here? */ |
563 | fl->fh_array[i] = kmalloc(sizeof(struct nfs_fh), GFP_KERNEL); | 567 | fl->fh_array[i] = kmalloc(sizeof(struct nfs_fh), gfp_flags); |
564 | if (!fl->fh_array[i]) | 568 | if (!fl->fh_array[i]) |
565 | goto out_err_free; | 569 | goto out_err_free; |
566 | 570 | ||
@@ -605,19 +609,20 @@ filelayout_free_lseg(struct pnfs_layout_segment *lseg) | |||
605 | 609 | ||
606 | static struct pnfs_layout_segment * | 610 | static struct pnfs_layout_segment * |
607 | filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid, | 611 | filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid, |
608 | struct nfs4_layoutget_res *lgr) | 612 | struct nfs4_layoutget_res *lgr, |
613 | gfp_t gfp_flags) | ||
609 | { | 614 | { |
610 | struct nfs4_filelayout_segment *fl; | 615 | struct nfs4_filelayout_segment *fl; |
611 | int rc; | 616 | int rc; |
612 | struct nfs4_deviceid id; | 617 | struct nfs4_deviceid id; |
613 | 618 | ||
614 | dprintk("--> %s\n", __func__); | 619 | dprintk("--> %s\n", __func__); |
615 | fl = kzalloc(sizeof(*fl), GFP_KERNEL); | 620 | fl = kzalloc(sizeof(*fl), gfp_flags); |
616 | if (!fl) | 621 | if (!fl) |
617 | return NULL; | 622 | return NULL; |
618 | 623 | ||
619 | rc = filelayout_decode_layout(layoutid, fl, lgr, &id); | 624 | rc = filelayout_decode_layout(layoutid, fl, lgr, &id, gfp_flags); |
620 | if (rc != 0 || filelayout_check_layout(layoutid, fl, lgr, &id)) { | 625 | if (rc != 0 || filelayout_check_layout(layoutid, fl, lgr, &id, gfp_flags)) { |
621 | _filelayout_free_lseg(fl); | 626 | _filelayout_free_lseg(fl); |
622 | return NULL; | 627 | return NULL; |
623 | } | 628 | } |
@@ -633,7 +638,7 @@ filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid, | |||
633 | int size = (fl->stripe_type == STRIPE_SPARSE) ? | 638 | int size = (fl->stripe_type == STRIPE_SPARSE) ? |
634 | fl->dsaddr->ds_num : fl->dsaddr->stripe_count; | 639 | fl->dsaddr->ds_num : fl->dsaddr->stripe_count; |
635 | 640 | ||
636 | fl->commit_buckets = kcalloc(size, sizeof(struct list_head), GFP_KERNEL); | 641 | fl->commit_buckets = kcalloc(size, sizeof(struct list_head), gfp_flags); |
637 | if (!fl->commit_buckets) { | 642 | if (!fl->commit_buckets) { |
638 | filelayout_free_lseg(&fl->generic_hdr); | 643 | filelayout_free_lseg(&fl->generic_hdr); |
639 | return NULL; | 644 | return NULL; |
diff --git a/fs/nfs/nfs4filelayout.h b/fs/nfs/nfs4filelayout.h index 7c44579f583..2b461d77b43 100644 --- a/fs/nfs/nfs4filelayout.h +++ b/fs/nfs/nfs4filelayout.h | |||
@@ -104,6 +104,6 @@ extern struct nfs4_file_layout_dsaddr * | |||
104 | nfs4_fl_find_get_deviceid(struct nfs4_deviceid *dev_id); | 104 | nfs4_fl_find_get_deviceid(struct nfs4_deviceid *dev_id); |
105 | extern void nfs4_fl_put_deviceid(struct nfs4_file_layout_dsaddr *dsaddr); | 105 | extern void nfs4_fl_put_deviceid(struct nfs4_file_layout_dsaddr *dsaddr); |
106 | struct nfs4_file_layout_dsaddr * | 106 | struct nfs4_file_layout_dsaddr * |
107 | get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id); | 107 | get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_flags); |
108 | 108 | ||
109 | #endif /* FS_NFS_NFS4FILELAYOUT_H */ | 109 | #endif /* FS_NFS_NFS4FILELAYOUT_H */ |
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c index de5350f2b24..db07c7af139 100644 --- a/fs/nfs/nfs4filelayoutdev.c +++ b/fs/nfs/nfs4filelayoutdev.c | |||
@@ -225,11 +225,11 @@ nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr) | |||
225 | } | 225 | } |
226 | 226 | ||
227 | static struct nfs4_pnfs_ds * | 227 | static struct nfs4_pnfs_ds * |
228 | nfs4_pnfs_ds_add(struct inode *inode, u32 ip_addr, u32 port) | 228 | nfs4_pnfs_ds_add(struct inode *inode, u32 ip_addr, u32 port, gfp_t gfp_flags) |
229 | { | 229 | { |
230 | struct nfs4_pnfs_ds *tmp_ds, *ds; | 230 | struct nfs4_pnfs_ds *tmp_ds, *ds; |
231 | 231 | ||
232 | ds = kzalloc(sizeof(*tmp_ds), GFP_KERNEL); | 232 | ds = kzalloc(sizeof(*tmp_ds), gfp_flags); |
233 | if (!ds) | 233 | if (!ds) |
234 | goto out; | 234 | goto out; |
235 | 235 | ||
@@ -261,7 +261,7 @@ out: | |||
261 | * Currently only support ipv4, and one multi-path address. | 261 | * Currently only support ipv4, and one multi-path address. |
262 | */ | 262 | */ |
263 | static struct nfs4_pnfs_ds * | 263 | static struct nfs4_pnfs_ds * |
264 | decode_and_add_ds(struct xdr_stream *streamp, struct inode *inode) | 264 | decode_and_add_ds(struct xdr_stream *streamp, struct inode *inode, gfp_t gfp_flags) |
265 | { | 265 | { |
266 | struct nfs4_pnfs_ds *ds = NULL; | 266 | struct nfs4_pnfs_ds *ds = NULL; |
267 | char *buf; | 267 | char *buf; |
@@ -303,7 +303,7 @@ decode_and_add_ds(struct xdr_stream *streamp, struct inode *inode) | |||
303 | rlen); | 303 | rlen); |
304 | goto out_err; | 304 | goto out_err; |
305 | } | 305 | } |
306 | buf = kmalloc(rlen + 1, GFP_KERNEL); | 306 | buf = kmalloc(rlen + 1, gfp_flags); |
307 | if (!buf) { | 307 | if (!buf) { |
308 | dprintk("%s: Not enough memory\n", __func__); | 308 | dprintk("%s: Not enough memory\n", __func__); |
309 | goto out_err; | 309 | goto out_err; |
@@ -333,7 +333,7 @@ decode_and_add_ds(struct xdr_stream *streamp, struct inode *inode) | |||
333 | sscanf(pstr, "-%d-%d", &tmp[0], &tmp[1]); | 333 | sscanf(pstr, "-%d-%d", &tmp[0], &tmp[1]); |
334 | port = htons((tmp[0] << 8) | (tmp[1])); | 334 | port = htons((tmp[0] << 8) | (tmp[1])); |
335 | 335 | ||
336 | ds = nfs4_pnfs_ds_add(inode, ip_addr, port); | 336 | ds = nfs4_pnfs_ds_add(inode, ip_addr, port, gfp_flags); |
337 | dprintk("%s: Decoded address and port %s\n", __func__, buf); | 337 | dprintk("%s: Decoded address and port %s\n", __func__, buf); |
338 | out_free: | 338 | out_free: |
339 | kfree(buf); | 339 | kfree(buf); |
@@ -343,7 +343,7 @@ out_err: | |||
343 | 343 | ||
344 | /* Decode opaque device data and return the result */ | 344 | /* Decode opaque device data and return the result */ |
345 | static struct nfs4_file_layout_dsaddr* | 345 | static struct nfs4_file_layout_dsaddr* |
346 | decode_device(struct inode *ino, struct pnfs_device *pdev) | 346 | decode_device(struct inode *ino, struct pnfs_device *pdev, gfp_t gfp_flags) |
347 | { | 347 | { |
348 | int i; | 348 | int i; |
349 | u32 cnt, num; | 349 | u32 cnt, num; |
@@ -362,7 +362,7 @@ decode_device(struct inode *ino, struct pnfs_device *pdev) | |||
362 | struct page *scratch; | 362 | struct page *scratch; |
363 | 363 | ||
364 | /* set up xdr stream */ | 364 | /* set up xdr stream */ |
365 | scratch = alloc_page(GFP_KERNEL); | 365 | scratch = alloc_page(gfp_flags); |
366 | if (!scratch) | 366 | if (!scratch) |
367 | goto out_err; | 367 | goto out_err; |
368 | 368 | ||
@@ -384,7 +384,7 @@ decode_device(struct inode *ino, struct pnfs_device *pdev) | |||
384 | } | 384 | } |
385 | 385 | ||
386 | /* read stripe indices */ | 386 | /* read stripe indices */ |
387 | stripe_indices = kcalloc(cnt, sizeof(u8), GFP_KERNEL); | 387 | stripe_indices = kcalloc(cnt, sizeof(u8), gfp_flags); |
388 | if (!stripe_indices) | 388 | if (!stripe_indices) |
389 | goto out_err_free_scratch; | 389 | goto out_err_free_scratch; |
390 | 390 | ||
@@ -423,7 +423,7 @@ decode_device(struct inode *ino, struct pnfs_device *pdev) | |||
423 | 423 | ||
424 | dsaddr = kzalloc(sizeof(*dsaddr) + | 424 | dsaddr = kzalloc(sizeof(*dsaddr) + |
425 | (sizeof(struct nfs4_pnfs_ds *) * (num - 1)), | 425 | (sizeof(struct nfs4_pnfs_ds *) * (num - 1)), |
426 | GFP_KERNEL); | 426 | gfp_flags); |
427 | if (!dsaddr) | 427 | if (!dsaddr) |
428 | goto out_err_free_stripe_indices; | 428 | goto out_err_free_stripe_indices; |
429 | 429 | ||
@@ -452,7 +452,7 @@ decode_device(struct inode *ino, struct pnfs_device *pdev) | |||
452 | for (j = 0; j < mp_count; j++) { | 452 | for (j = 0; j < mp_count; j++) { |
453 | if (j == 0) { | 453 | if (j == 0) { |
454 | dsaddr->ds_list[i] = decode_and_add_ds(&stream, | 454 | dsaddr->ds_list[i] = decode_and_add_ds(&stream, |
455 | ino); | 455 | ino, gfp_flags); |
456 | if (dsaddr->ds_list[i] == NULL) | 456 | if (dsaddr->ds_list[i] == NULL) |
457 | goto out_err_free_deviceid; | 457 | goto out_err_free_deviceid; |
458 | } else { | 458 | } else { |
@@ -503,12 +503,12 @@ out_err: | |||
503 | * available devices. | 503 | * available devices. |
504 | */ | 504 | */ |
505 | static struct nfs4_file_layout_dsaddr * | 505 | static struct nfs4_file_layout_dsaddr * |
506 | decode_and_add_device(struct inode *inode, struct pnfs_device *dev) | 506 | decode_and_add_device(struct inode *inode, struct pnfs_device *dev, gfp_t gfp_flags) |
507 | { | 507 | { |
508 | struct nfs4_file_layout_dsaddr *d, *new; | 508 | struct nfs4_file_layout_dsaddr *d, *new; |
509 | long hash; | 509 | long hash; |
510 | 510 | ||
511 | new = decode_device(inode, dev); | 511 | new = decode_device(inode, dev, gfp_flags); |
512 | if (!new) { | 512 | if (!new) { |
513 | printk(KERN_WARNING "%s: Could not decode or add device\n", | 513 | printk(KERN_WARNING "%s: Could not decode or add device\n", |
514 | __func__); | 514 | __func__); |
@@ -537,7 +537,7 @@ decode_and_add_device(struct inode *inode, struct pnfs_device *dev) | |||
537 | * of available devices, and return it. | 537 | * of available devices, and return it. |
538 | */ | 538 | */ |
539 | struct nfs4_file_layout_dsaddr * | 539 | struct nfs4_file_layout_dsaddr * |
540 | get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id) | 540 | get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_flags) |
541 | { | 541 | { |
542 | struct pnfs_device *pdev = NULL; | 542 | struct pnfs_device *pdev = NULL; |
543 | u32 max_resp_sz; | 543 | u32 max_resp_sz; |
@@ -556,17 +556,17 @@ get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id) | |||
556 | dprintk("%s inode %p max_resp_sz %u max_pages %d\n", | 556 | dprintk("%s inode %p max_resp_sz %u max_pages %d\n", |
557 | __func__, inode, max_resp_sz, max_pages); | 557 | __func__, inode, max_resp_sz, max_pages); |
558 | 558 | ||
559 | pdev = kzalloc(sizeof(struct pnfs_device), GFP_KERNEL); | 559 | pdev = kzalloc(sizeof(struct pnfs_device), gfp_flags); |
560 | if (pdev == NULL) | 560 | if (pdev == NULL) |
561 | return NULL; | 561 | return NULL; |
562 | 562 | ||
563 | pages = kzalloc(max_pages * sizeof(struct page *), GFP_KERNEL); | 563 | pages = kzalloc(max_pages * sizeof(struct page *), gfp_flags); |
564 | if (pages == NULL) { | 564 | if (pages == NULL) { |
565 | kfree(pdev); | 565 | kfree(pdev); |
566 | return NULL; | 566 | return NULL; |
567 | } | 567 | } |
568 | for (i = 0; i < max_pages; i++) { | 568 | for (i = 0; i < max_pages; i++) { |
569 | pages[i] = alloc_page(GFP_KERNEL); | 569 | pages[i] = alloc_page(gfp_flags); |
570 | if (!pages[i]) | 570 | if (!pages[i]) |
571 | goto out_free; | 571 | goto out_free; |
572 | } | 572 | } |
@@ -587,7 +587,7 @@ get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id) | |||
587 | * Found new device, need to decode it and then add it to the | 587 | * Found new device, need to decode it and then add it to the |
588 | * list of known devices for this mountpoint. | 588 | * list of known devices for this mountpoint. |
589 | */ | 589 | */ |
590 | dsaddr = decode_and_add_device(inode, pdev); | 590 | dsaddr = decode_and_add_device(inode, pdev, gfp_flags); |
591 | out_free: | 591 | out_free: |
592 | for (i = 0; i < max_pages; i++) | 592 | for (i = 0; i < max_pages; i++) |
593 | __free_page(pages[i]); | 593 | __free_page(pages[i]); |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 69c0f3c5ee7..cf1b339c393 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -300,6 +300,7 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc | |||
300 | ret = nfs4_delay(server->client, &exception->timeout); | 300 | ret = nfs4_delay(server->client, &exception->timeout); |
301 | if (ret != 0) | 301 | if (ret != 0) |
302 | break; | 302 | break; |
303 | case -NFS4ERR_RETRY_UNCACHED_REP: | ||
303 | case -NFS4ERR_OLD_STATEID: | 304 | case -NFS4ERR_OLD_STATEID: |
304 | exception->retry = 1; | 305 | exception->retry = 1; |
305 | break; | 306 | break; |
@@ -3695,6 +3696,7 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, | |||
3695 | rpc_delay(task, NFS4_POLL_RETRY_MAX); | 3696 | rpc_delay(task, NFS4_POLL_RETRY_MAX); |
3696 | task->tk_status = 0; | 3697 | task->tk_status = 0; |
3697 | return -EAGAIN; | 3698 | return -EAGAIN; |
3699 | case -NFS4ERR_RETRY_UNCACHED_REP: | ||
3698 | case -NFS4ERR_OLD_STATEID: | 3700 | case -NFS4ERR_OLD_STATEID: |
3699 | task->tk_status = 0; | 3701 | task->tk_status = 0; |
3700 | return -EAGAIN; | 3702 | return -EAGAIN; |
@@ -4844,6 +4846,8 @@ static void nfs4_get_lease_time_done(struct rpc_task *task, void *calldata) | |||
4844 | dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status); | 4846 | dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status); |
4845 | rpc_delay(task, NFS4_POLL_RETRY_MIN); | 4847 | rpc_delay(task, NFS4_POLL_RETRY_MIN); |
4846 | task->tk_status = 0; | 4848 | task->tk_status = 0; |
4849 | /* fall through */ | ||
4850 | case -NFS4ERR_RETRY_UNCACHED_REP: | ||
4847 | nfs_restart_rpc(task, data->clp); | 4851 | nfs_restart_rpc(task, data->clp); |
4848 | return; | 4852 | return; |
4849 | } | 4853 | } |
@@ -5479,6 +5483,8 @@ static int nfs41_reclaim_complete_handle_errors(struct rpc_task *task, struct nf | |||
5479 | break; | 5483 | break; |
5480 | case -NFS4ERR_DELAY: | 5484 | case -NFS4ERR_DELAY: |
5481 | rpc_delay(task, NFS4_POLL_RETRY_MAX); | 5485 | rpc_delay(task, NFS4_POLL_RETRY_MAX); |
5486 | /* fall through */ | ||
5487 | case -NFS4ERR_RETRY_UNCACHED_REP: | ||
5482 | return -EAGAIN; | 5488 | return -EAGAIN; |
5483 | default: | 5489 | default: |
5484 | nfs4_schedule_lease_recovery(clp); | 5490 | nfs4_schedule_lease_recovery(clp); |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index ff681ab65d3..f57f5281a52 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -383,6 +383,7 @@ pnfs_destroy_all_layouts(struct nfs_client *clp) | |||
383 | plh_layouts); | 383 | plh_layouts); |
384 | dprintk("%s freeing layout for inode %lu\n", __func__, | 384 | dprintk("%s freeing layout for inode %lu\n", __func__, |
385 | lo->plh_inode->i_ino); | 385 | lo->plh_inode->i_ino); |
386 | list_del_init(&lo->plh_layouts); | ||
386 | pnfs_destroy_layout(NFS_I(lo->plh_inode)); | 387 | pnfs_destroy_layout(NFS_I(lo->plh_inode)); |
387 | } | 388 | } |
388 | } | 389 | } |
@@ -466,7 +467,8 @@ pnfs_choose_layoutget_stateid(nfs4_stateid *dst, struct pnfs_layout_hdr *lo, | |||
466 | static struct pnfs_layout_segment * | 467 | static struct pnfs_layout_segment * |
467 | send_layoutget(struct pnfs_layout_hdr *lo, | 468 | send_layoutget(struct pnfs_layout_hdr *lo, |
468 | struct nfs_open_context *ctx, | 469 | struct nfs_open_context *ctx, |
469 | u32 iomode) | 470 | u32 iomode, |
471 | gfp_t gfp_flags) | ||
470 | { | 472 | { |
471 | struct inode *ino = lo->plh_inode; | 473 | struct inode *ino = lo->plh_inode; |
472 | struct nfs_server *server = NFS_SERVER(ino); | 474 | struct nfs_server *server = NFS_SERVER(ino); |
@@ -479,7 +481,7 @@ send_layoutget(struct pnfs_layout_hdr *lo, | |||
479 | dprintk("--> %s\n", __func__); | 481 | dprintk("--> %s\n", __func__); |
480 | 482 | ||
481 | BUG_ON(ctx == NULL); | 483 | BUG_ON(ctx == NULL); |
482 | lgp = kzalloc(sizeof(*lgp), GFP_KERNEL); | 484 | lgp = kzalloc(sizeof(*lgp), gfp_flags); |
483 | if (lgp == NULL) | 485 | if (lgp == NULL) |
484 | return NULL; | 486 | return NULL; |
485 | 487 | ||
@@ -487,12 +489,12 @@ send_layoutget(struct pnfs_layout_hdr *lo, | |||
487 | max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz; | 489 | max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz; |
488 | max_pages = max_resp_sz >> PAGE_SHIFT; | 490 | max_pages = max_resp_sz >> PAGE_SHIFT; |
489 | 491 | ||
490 | pages = kzalloc(max_pages * sizeof(struct page *), GFP_KERNEL); | 492 | pages = kzalloc(max_pages * sizeof(struct page *), gfp_flags); |
491 | if (!pages) | 493 | if (!pages) |
492 | goto out_err_free; | 494 | goto out_err_free; |
493 | 495 | ||
494 | for (i = 0; i < max_pages; i++) { | 496 | for (i = 0; i < max_pages; i++) { |
495 | pages[i] = alloc_page(GFP_KERNEL); | 497 | pages[i] = alloc_page(gfp_flags); |
496 | if (!pages[i]) | 498 | if (!pages[i]) |
497 | goto out_err_free; | 499 | goto out_err_free; |
498 | } | 500 | } |
@@ -508,6 +510,7 @@ send_layoutget(struct pnfs_layout_hdr *lo, | |||
508 | lgp->args.layout.pages = pages; | 510 | lgp->args.layout.pages = pages; |
509 | lgp->args.layout.pglen = max_pages * PAGE_SIZE; | 511 | lgp->args.layout.pglen = max_pages * PAGE_SIZE; |
510 | lgp->lsegpp = &lseg; | 512 | lgp->lsegpp = &lseg; |
513 | lgp->gfp_flags = gfp_flags; | ||
511 | 514 | ||
512 | /* Synchronously retrieve layout information from server and | 515 | /* Synchronously retrieve layout information from server and |
513 | * store in lseg. | 516 | * store in lseg. |
@@ -665,11 +668,11 @@ pnfs_insert_layout(struct pnfs_layout_hdr *lo, | |||
665 | } | 668 | } |
666 | 669 | ||
667 | static struct pnfs_layout_hdr * | 670 | static struct pnfs_layout_hdr * |
668 | alloc_init_layout_hdr(struct inode *ino) | 671 | alloc_init_layout_hdr(struct inode *ino, gfp_t gfp_flags) |
669 | { | 672 | { |
670 | struct pnfs_layout_hdr *lo; | 673 | struct pnfs_layout_hdr *lo; |
671 | 674 | ||
672 | lo = kzalloc(sizeof(struct pnfs_layout_hdr), GFP_KERNEL); | 675 | lo = kzalloc(sizeof(struct pnfs_layout_hdr), gfp_flags); |
673 | if (!lo) | 676 | if (!lo) |
674 | return NULL; | 677 | return NULL; |
675 | atomic_set(&lo->plh_refcount, 1); | 678 | atomic_set(&lo->plh_refcount, 1); |
@@ -681,7 +684,7 @@ alloc_init_layout_hdr(struct inode *ino) | |||
681 | } | 684 | } |
682 | 685 | ||
683 | static struct pnfs_layout_hdr * | 686 | static struct pnfs_layout_hdr * |
684 | pnfs_find_alloc_layout(struct inode *ino) | 687 | pnfs_find_alloc_layout(struct inode *ino, gfp_t gfp_flags) |
685 | { | 688 | { |
686 | struct nfs_inode *nfsi = NFS_I(ino); | 689 | struct nfs_inode *nfsi = NFS_I(ino); |
687 | struct pnfs_layout_hdr *new = NULL; | 690 | struct pnfs_layout_hdr *new = NULL; |
@@ -696,7 +699,7 @@ pnfs_find_alloc_layout(struct inode *ino) | |||
696 | return nfsi->layout; | 699 | return nfsi->layout; |
697 | } | 700 | } |
698 | spin_unlock(&ino->i_lock); | 701 | spin_unlock(&ino->i_lock); |
699 | new = alloc_init_layout_hdr(ino); | 702 | new = alloc_init_layout_hdr(ino, gfp_flags); |
700 | spin_lock(&ino->i_lock); | 703 | spin_lock(&ino->i_lock); |
701 | 704 | ||
702 | if (likely(nfsi->layout == NULL)) /* Won the race? */ | 705 | if (likely(nfsi->layout == NULL)) /* Won the race? */ |
@@ -756,7 +759,8 @@ pnfs_find_lseg(struct pnfs_layout_hdr *lo, u32 iomode) | |||
756 | struct pnfs_layout_segment * | 759 | struct pnfs_layout_segment * |
757 | pnfs_update_layout(struct inode *ino, | 760 | pnfs_update_layout(struct inode *ino, |
758 | struct nfs_open_context *ctx, | 761 | struct nfs_open_context *ctx, |
759 | enum pnfs_iomode iomode) | 762 | enum pnfs_iomode iomode, |
763 | gfp_t gfp_flags) | ||
760 | { | 764 | { |
761 | struct nfs_inode *nfsi = NFS_I(ino); | 765 | struct nfs_inode *nfsi = NFS_I(ino); |
762 | struct nfs_client *clp = NFS_SERVER(ino)->nfs_client; | 766 | struct nfs_client *clp = NFS_SERVER(ino)->nfs_client; |
@@ -767,7 +771,7 @@ pnfs_update_layout(struct inode *ino, | |||
767 | if (!pnfs_enabled_sb(NFS_SERVER(ino))) | 771 | if (!pnfs_enabled_sb(NFS_SERVER(ino))) |
768 | return NULL; | 772 | return NULL; |
769 | spin_lock(&ino->i_lock); | 773 | spin_lock(&ino->i_lock); |
770 | lo = pnfs_find_alloc_layout(ino); | 774 | lo = pnfs_find_alloc_layout(ino, gfp_flags); |
771 | if (lo == NULL) { | 775 | if (lo == NULL) { |
772 | dprintk("%s ERROR: can't get pnfs_layout_hdr\n", __func__); | 776 | dprintk("%s ERROR: can't get pnfs_layout_hdr\n", __func__); |
773 | goto out_unlock; | 777 | goto out_unlock; |
@@ -807,7 +811,7 @@ pnfs_update_layout(struct inode *ino, | |||
807 | spin_unlock(&clp->cl_lock); | 811 | spin_unlock(&clp->cl_lock); |
808 | } | 812 | } |
809 | 813 | ||
810 | lseg = send_layoutget(lo, ctx, iomode); | 814 | lseg = send_layoutget(lo, ctx, iomode, gfp_flags); |
811 | if (!lseg && first) { | 815 | if (!lseg && first) { |
812 | spin_lock(&clp->cl_lock); | 816 | spin_lock(&clp->cl_lock); |
813 | list_del_init(&lo->plh_layouts); | 817 | list_del_init(&lo->plh_layouts); |
@@ -846,7 +850,7 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) | |||
846 | goto out; | 850 | goto out; |
847 | } | 851 | } |
848 | /* Inject layout blob into I/O device driver */ | 852 | /* Inject layout blob into I/O device driver */ |
849 | lseg = NFS_SERVER(ino)->pnfs_curr_ld->alloc_lseg(lo, res); | 853 | lseg = NFS_SERVER(ino)->pnfs_curr_ld->alloc_lseg(lo, res, lgp->gfp_flags); |
850 | if (!lseg || IS_ERR(lseg)) { | 854 | if (!lseg || IS_ERR(lseg)) { |
851 | if (!lseg) | 855 | if (!lseg) |
852 | status = -ENOMEM; | 856 | status = -ENOMEM; |
@@ -899,7 +903,8 @@ static int pnfs_read_pg_test(struct nfs_pageio_descriptor *pgio, | |||
899 | /* This is first coelesce call for a series of nfs_pages */ | 903 | /* This is first coelesce call for a series of nfs_pages */ |
900 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 904 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, |
901 | prev->wb_context, | 905 | prev->wb_context, |
902 | IOMODE_READ); | 906 | IOMODE_READ, |
907 | GFP_KERNEL); | ||
903 | } | 908 | } |
904 | return NFS_SERVER(pgio->pg_inode)->pnfs_curr_ld->pg_test(pgio, prev, req); | 909 | return NFS_SERVER(pgio->pg_inode)->pnfs_curr_ld->pg_test(pgio, prev, req); |
905 | } | 910 | } |
@@ -921,7 +926,8 @@ static int pnfs_write_pg_test(struct nfs_pageio_descriptor *pgio, | |||
921 | /* This is first coelesce call for a series of nfs_pages */ | 926 | /* This is first coelesce call for a series of nfs_pages */ |
922 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 927 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, |
923 | prev->wb_context, | 928 | prev->wb_context, |
924 | IOMODE_RW); | 929 | IOMODE_RW, |
930 | GFP_NOFS); | ||
925 | } | 931 | } |
926 | return NFS_SERVER(pgio->pg_inode)->pnfs_curr_ld->pg_test(pgio, prev, req); | 932 | return NFS_SERVER(pgio->pg_inode)->pnfs_curr_ld->pg_test(pgio, prev, req); |
927 | } | 933 | } |
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index bc4827202e7..0c015bad9e7 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -70,7 +70,7 @@ struct pnfs_layoutdriver_type { | |||
70 | const u32 id; | 70 | const u32 id; |
71 | const char *name; | 71 | const char *name; |
72 | struct module *owner; | 72 | struct module *owner; |
73 | struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr); | 73 | struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags); |
74 | void (*free_lseg) (struct pnfs_layout_segment *lseg); | 74 | void (*free_lseg) (struct pnfs_layout_segment *lseg); |
75 | 75 | ||
76 | /* test for nfs page cache coalescing */ | 76 | /* test for nfs page cache coalescing */ |
@@ -126,7 +126,7 @@ void get_layout_hdr(struct pnfs_layout_hdr *lo); | |||
126 | void put_lseg(struct pnfs_layout_segment *lseg); | 126 | void put_lseg(struct pnfs_layout_segment *lseg); |
127 | struct pnfs_layout_segment * | 127 | struct pnfs_layout_segment * |
128 | pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx, | 128 | pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx, |
129 | enum pnfs_iomode access_type); | 129 | enum pnfs_iomode access_type, gfp_t gfp_flags); |
130 | void set_pnfs_layoutdriver(struct nfs_server *, u32 id); | 130 | void set_pnfs_layoutdriver(struct nfs_server *, u32 id); |
131 | void unset_pnfs_layoutdriver(struct nfs_server *); | 131 | void unset_pnfs_layoutdriver(struct nfs_server *); |
132 | enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *, | 132 | enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *, |
@@ -245,7 +245,7 @@ static inline void put_lseg(struct pnfs_layout_segment *lseg) | |||
245 | 245 | ||
246 | static inline struct pnfs_layout_segment * | 246 | static inline struct pnfs_layout_segment * |
247 | pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx, | 247 | pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx, |
248 | enum pnfs_iomode access_type) | 248 | enum pnfs_iomode access_type, gfp_t gfp_flags) |
249 | { | 249 | { |
250 | return NULL; | 250 | return NULL; |
251 | } | 251 | } |
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 7cded2b12a0..2bcf0dc306a 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -288,7 +288,7 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc) | |||
288 | atomic_set(&req->wb_complete, requests); | 288 | atomic_set(&req->wb_complete, requests); |
289 | 289 | ||
290 | BUG_ON(desc->pg_lseg != NULL); | 290 | BUG_ON(desc->pg_lseg != NULL); |
291 | lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_READ); | 291 | lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_READ, GFP_KERNEL); |
292 | ClearPageError(page); | 292 | ClearPageError(page); |
293 | offset = 0; | 293 | offset = 0; |
294 | nbytes = desc->pg_count; | 294 | nbytes = desc->pg_count; |
@@ -351,7 +351,7 @@ static int nfs_pagein_one(struct nfs_pageio_descriptor *desc) | |||
351 | } | 351 | } |
352 | req = nfs_list_entry(data->pages.next); | 352 | req = nfs_list_entry(data->pages.next); |
353 | if ((!lseg) && list_is_singular(&data->pages)) | 353 | if ((!lseg) && list_is_singular(&data->pages)) |
354 | lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_READ); | 354 | lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_READ, GFP_KERNEL); |
355 | 355 | ||
356 | ret = nfs_read_rpcsetup(req, data, &nfs_read_full_ops, desc->pg_count, | 356 | ret = nfs_read_rpcsetup(req, data, &nfs_read_full_ops, desc->pg_count, |
357 | 0, lseg); | 357 | 0, lseg); |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 3bd5d7e80f6..49c715b4ac9 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -939,7 +939,7 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc) | |||
939 | atomic_set(&req->wb_complete, requests); | 939 | atomic_set(&req->wb_complete, requests); |
940 | 940 | ||
941 | BUG_ON(desc->pg_lseg); | 941 | BUG_ON(desc->pg_lseg); |
942 | lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_RW); | 942 | lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_RW, GFP_NOFS); |
943 | ClearPageError(page); | 943 | ClearPageError(page); |
944 | offset = 0; | 944 | offset = 0; |
945 | nbytes = desc->pg_count; | 945 | nbytes = desc->pg_count; |
@@ -1013,7 +1013,7 @@ static int nfs_flush_one(struct nfs_pageio_descriptor *desc) | |||
1013 | } | 1013 | } |
1014 | req = nfs_list_entry(data->pages.next); | 1014 | req = nfs_list_entry(data->pages.next); |
1015 | if ((!lseg) && list_is_singular(&data->pages)) | 1015 | if ((!lseg) && list_is_singular(&data->pages)) |
1016 | lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_RW); | 1016 | lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_RW, GFP_NOFS); |
1017 | 1017 | ||
1018 | if ((desc->pg_ioflags & FLUSH_COND_STABLE) && | 1018 | if ((desc->pg_ioflags & FLUSH_COND_STABLE) && |
1019 | (desc->pg_moreio || NFS_I(desc->pg_inode)->ncommit)) | 1019 | (desc->pg_moreio || NFS_I(desc->pg_inode)->ncommit)) |
diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c index 0a0a66d98cc..f7684483785 100644 --- a/fs/nilfs2/alloc.c +++ b/fs/nilfs2/alloc.c | |||
@@ -646,7 +646,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems) | |||
646 | unsigned long group, group_offset; | 646 | unsigned long group, group_offset; |
647 | int i, j, n, ret; | 647 | int i, j, n, ret; |
648 | 648 | ||
649 | for (i = 0; i < nitems; i += n) { | 649 | for (i = 0; i < nitems; i = j) { |
650 | group = nilfs_palloc_group(inode, entry_nrs[i], &group_offset); | 650 | group = nilfs_palloc_group(inode, entry_nrs[i], &group_offset); |
651 | ret = nilfs_palloc_get_desc_block(inode, group, 0, &desc_bh); | 651 | ret = nilfs_palloc_get_desc_block(inode, group, 0, &desc_bh); |
652 | if (ret < 0) | 652 | if (ret < 0) |
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 643720209a9..9a3e6bbff27 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
@@ -539,25 +539,41 @@ static int o2hb_verify_crc(struct o2hb_region *reg, | |||
539 | 539 | ||
540 | /* We want to make sure that nobody is heartbeating on top of us -- | 540 | /* We want to make sure that nobody is heartbeating on top of us -- |
541 | * this will help detect an invalid configuration. */ | 541 | * this will help detect an invalid configuration. */ |
542 | static int o2hb_check_last_timestamp(struct o2hb_region *reg) | 542 | static void o2hb_check_last_timestamp(struct o2hb_region *reg) |
543 | { | 543 | { |
544 | int node_num, ret; | ||
545 | struct o2hb_disk_slot *slot; | 544 | struct o2hb_disk_slot *slot; |
546 | struct o2hb_disk_heartbeat_block *hb_block; | 545 | struct o2hb_disk_heartbeat_block *hb_block; |
546 | char *errstr; | ||
547 | 547 | ||
548 | node_num = o2nm_this_node(); | 548 | slot = ®->hr_slots[o2nm_this_node()]; |
549 | |||
550 | ret = 1; | ||
551 | slot = ®->hr_slots[node_num]; | ||
552 | /* Don't check on our 1st timestamp */ | 549 | /* Don't check on our 1st timestamp */ |
553 | if (slot->ds_last_time) { | 550 | if (!slot->ds_last_time) |
554 | hb_block = slot->ds_raw_block; | 551 | return; |
555 | 552 | ||
556 | if (le64_to_cpu(hb_block->hb_seq) != slot->ds_last_time) | 553 | hb_block = slot->ds_raw_block; |
557 | ret = 0; | 554 | if (le64_to_cpu(hb_block->hb_seq) == slot->ds_last_time && |
558 | } | 555 | le64_to_cpu(hb_block->hb_generation) == slot->ds_last_generation && |
556 | hb_block->hb_node == slot->ds_node_num) | ||
557 | return; | ||
559 | 558 | ||
560 | return ret; | 559 | #define ERRSTR1 "Another node is heartbeating on device" |
560 | #define ERRSTR2 "Heartbeat generation mismatch on device" | ||
561 | #define ERRSTR3 "Heartbeat sequence mismatch on device" | ||
562 | |||
563 | if (hb_block->hb_node != slot->ds_node_num) | ||
564 | errstr = ERRSTR1; | ||
565 | else if (le64_to_cpu(hb_block->hb_generation) != | ||
566 | slot->ds_last_generation) | ||
567 | errstr = ERRSTR2; | ||
568 | else | ||
569 | errstr = ERRSTR3; | ||
570 | |||
571 | mlog(ML_ERROR, "%s (%s): expected(%u:0x%llx, 0x%llx), " | ||
572 | "ondisk(%u:0x%llx, 0x%llx)\n", errstr, reg->hr_dev_name, | ||
573 | slot->ds_node_num, (unsigned long long)slot->ds_last_generation, | ||
574 | (unsigned long long)slot->ds_last_time, hb_block->hb_node, | ||
575 | (unsigned long long)le64_to_cpu(hb_block->hb_generation), | ||
576 | (unsigned long long)le64_to_cpu(hb_block->hb_seq)); | ||
561 | } | 577 | } |
562 | 578 | ||
563 | static inline void o2hb_prepare_block(struct o2hb_region *reg, | 579 | static inline void o2hb_prepare_block(struct o2hb_region *reg, |
@@ -983,9 +999,7 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) | |||
983 | /* With an up to date view of the slots, we can check that no | 999 | /* With an up to date view of the slots, we can check that no |
984 | * other node has been improperly configured to heartbeat in | 1000 | * other node has been improperly configured to heartbeat in |
985 | * our slot. */ | 1001 | * our slot. */ |
986 | if (!o2hb_check_last_timestamp(reg)) | 1002 | o2hb_check_last_timestamp(reg); |
987 | mlog(ML_ERROR, "Device \"%s\": another node is heartbeating " | ||
988 | "in our slot!\n", reg->hr_dev_name); | ||
989 | 1003 | ||
990 | /* fill in the proper info for our next heartbeat */ | 1004 | /* fill in the proper info for our next heartbeat */ |
991 | o2hb_prepare_block(reg, reg->hr_generation); | 1005 | o2hb_prepare_block(reg, reg->hr_generation); |
@@ -999,8 +1013,8 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) | |||
999 | } | 1013 | } |
1000 | 1014 | ||
1001 | i = -1; | 1015 | i = -1; |
1002 | while((i = find_next_bit(configured_nodes, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) { | 1016 | while((i = find_next_bit(configured_nodes, |
1003 | 1017 | O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) { | |
1004 | change |= o2hb_check_slot(reg, ®->hr_slots[i]); | 1018 | change |= o2hb_check_slot(reg, ®->hr_slots[i]); |
1005 | } | 1019 | } |
1006 | 1020 | ||
@@ -1690,6 +1704,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, | |||
1690 | struct file *filp = NULL; | 1704 | struct file *filp = NULL; |
1691 | struct inode *inode = NULL; | 1705 | struct inode *inode = NULL; |
1692 | ssize_t ret = -EINVAL; | 1706 | ssize_t ret = -EINVAL; |
1707 | int live_threshold; | ||
1693 | 1708 | ||
1694 | if (reg->hr_bdev) | 1709 | if (reg->hr_bdev) |
1695 | goto out; | 1710 | goto out; |
@@ -1766,8 +1781,18 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, | |||
1766 | * A node is considered live after it has beat LIVE_THRESHOLD | 1781 | * A node is considered live after it has beat LIVE_THRESHOLD |
1767 | * times. We're not steady until we've given them a chance | 1782 | * times. We're not steady until we've given them a chance |
1768 | * _after_ our first read. | 1783 | * _after_ our first read. |
1784 | * The default threshold is bare minimum so as to limit the delay | ||
1785 | * during mounts. For global heartbeat, the threshold doubled for the | ||
1786 | * first region. | ||
1769 | */ | 1787 | */ |
1770 | atomic_set(®->hr_steady_iterations, O2HB_LIVE_THRESHOLD + 1); | 1788 | live_threshold = O2HB_LIVE_THRESHOLD; |
1789 | if (o2hb_global_heartbeat_active()) { | ||
1790 | spin_lock(&o2hb_live_lock); | ||
1791 | if (o2hb_pop_count(&o2hb_region_bitmap, O2NM_MAX_REGIONS) == 1) | ||
1792 | live_threshold <<= 1; | ||
1793 | spin_unlock(&o2hb_live_lock); | ||
1794 | } | ||
1795 | atomic_set(®->hr_steady_iterations, live_threshold + 1); | ||
1771 | 1796 | ||
1772 | hb_task = kthread_run(o2hb_thread, reg, "o2hb-%s", | 1797 | hb_task = kthread_run(o2hb_thread, reg, "o2hb-%s", |
1773 | reg->hr_item.ci_name); | 1798 | reg->hr_item.ci_name); |
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 9fe5b8fd658..8582e3f4f12 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -2868,7 +2868,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, | |||
2868 | bytes = blocks_wanted << sb->s_blocksize_bits; | 2868 | bytes = blocks_wanted << sb->s_blocksize_bits; |
2869 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); | 2869 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); |
2870 | struct ocfs2_inode_info *oi = OCFS2_I(dir); | 2870 | struct ocfs2_inode_info *oi = OCFS2_I(dir); |
2871 | struct ocfs2_alloc_context *data_ac; | 2871 | struct ocfs2_alloc_context *data_ac = NULL; |
2872 | struct ocfs2_alloc_context *meta_ac = NULL; | 2872 | struct ocfs2_alloc_context *meta_ac = NULL; |
2873 | struct buffer_head *dirdata_bh = NULL; | 2873 | struct buffer_head *dirdata_bh = NULL; |
2874 | struct buffer_head *dx_root_bh = NULL; | 2874 | struct buffer_head *dx_root_bh = NULL; |
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 7540a492eab..3b179d6cbde 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c | |||
@@ -1614,7 +1614,8 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm) | |||
1614 | spin_unlock(&dlm->spinlock); | 1614 | spin_unlock(&dlm->spinlock); |
1615 | 1615 | ||
1616 | /* Support for global heartbeat and node info was added in 1.1 */ | 1616 | /* Support for global heartbeat and node info was added in 1.1 */ |
1617 | if (dlm_protocol.pv_major > 1 || dlm_protocol.pv_minor > 0) { | 1617 | if (dlm->dlm_locking_proto.pv_major > 1 || |
1618 | dlm->dlm_locking_proto.pv_minor > 0) { | ||
1618 | status = dlm_send_nodeinfo(dlm, ctxt->yes_resp_map); | 1619 | status = dlm_send_nodeinfo(dlm, ctxt->yes_resp_map); |
1619 | if (status) { | 1620 | if (status) { |
1620 | mlog_errno(status); | 1621 | mlog_errno(status); |
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index fede57ed005..84d166328cf 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
@@ -2574,6 +2574,9 @@ fail: | |||
2574 | res->state &= ~DLM_LOCK_RES_MIGRATING; | 2574 | res->state &= ~DLM_LOCK_RES_MIGRATING; |
2575 | wake = 1; | 2575 | wake = 1; |
2576 | spin_unlock(&res->spinlock); | 2576 | spin_unlock(&res->spinlock); |
2577 | if (dlm_is_host_down(ret)) | ||
2578 | dlm_wait_for_node_death(dlm, target, | ||
2579 | DLM_NODE_DEATH_WAIT_MAX); | ||
2577 | goto leave; | 2580 | goto leave; |
2578 | } | 2581 | } |
2579 | 2582 | ||
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 41565ae5285..89659d6dc20 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -1607,6 +1607,9 @@ static void ocfs2_calc_trunc_pos(struct inode *inode, | |||
1607 | range = le32_to_cpu(rec->e_cpos) + ocfs2_rec_clusters(el, rec); | 1607 | range = le32_to_cpu(rec->e_cpos) + ocfs2_rec_clusters(el, rec); |
1608 | 1608 | ||
1609 | if (le32_to_cpu(rec->e_cpos) >= trunc_start) { | 1609 | if (le32_to_cpu(rec->e_cpos) >= trunc_start) { |
1610 | /* | ||
1611 | * remove an entire extent record. | ||
1612 | */ | ||
1610 | *trunc_cpos = le32_to_cpu(rec->e_cpos); | 1613 | *trunc_cpos = le32_to_cpu(rec->e_cpos); |
1611 | /* | 1614 | /* |
1612 | * Skip holes if any. | 1615 | * Skip holes if any. |
@@ -1617,7 +1620,16 @@ static void ocfs2_calc_trunc_pos(struct inode *inode, | |||
1617 | *blkno = le64_to_cpu(rec->e_blkno); | 1620 | *blkno = le64_to_cpu(rec->e_blkno); |
1618 | *trunc_end = le32_to_cpu(rec->e_cpos); | 1621 | *trunc_end = le32_to_cpu(rec->e_cpos); |
1619 | } else if (range > trunc_start) { | 1622 | } else if (range > trunc_start) { |
1623 | /* | ||
1624 | * remove a partial extent record, which means we're | ||
1625 | * removing the last extent record. | ||
1626 | */ | ||
1620 | *trunc_cpos = trunc_start; | 1627 | *trunc_cpos = trunc_start; |
1628 | /* | ||
1629 | * skip hole if any. | ||
1630 | */ | ||
1631 | if (range < *trunc_end) | ||
1632 | *trunc_end = range; | ||
1621 | *trunc_len = *trunc_end - trunc_start; | 1633 | *trunc_len = *trunc_end - trunc_start; |
1622 | coff = trunc_start - le32_to_cpu(rec->e_cpos); | 1634 | coff = trunc_start - le32_to_cpu(rec->e_cpos); |
1623 | *blkno = le64_to_cpu(rec->e_blkno) + | 1635 | *blkno = le64_to_cpu(rec->e_blkno) + |
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index b141a44605c..295d56454e8 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
@@ -1260,6 +1260,9 @@ void ocfs2_complete_mount_recovery(struct ocfs2_super *osb) | |||
1260 | { | 1260 | { |
1261 | struct ocfs2_journal *journal = osb->journal; | 1261 | struct ocfs2_journal *journal = osb->journal; |
1262 | 1262 | ||
1263 | if (ocfs2_is_hard_readonly(osb)) | ||
1264 | return; | ||
1265 | |||
1263 | /* No need to queue up our truncate_log as regular cleanup will catch | 1266 | /* No need to queue up our truncate_log as regular cleanup will catch |
1264 | * that */ | 1267 | * that */ |
1265 | ocfs2_queue_recovery_completion(journal, osb->slot_num, | 1268 | ocfs2_queue_recovery_completion(journal, osb->slot_num, |
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c index ac0ccb5026a..19d6750d1d6 100644 --- a/fs/partitions/efi.c +++ b/fs/partitions/efi.c | |||
@@ -348,6 +348,12 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba, | |||
348 | goto fail; | 348 | goto fail; |
349 | } | 349 | } |
350 | 350 | ||
351 | /* Check that sizeof_partition_entry has the correct value */ | ||
352 | if (le32_to_cpu((*gpt)->sizeof_partition_entry) != sizeof(gpt_entry)) { | ||
353 | pr_debug("GUID Partitition Entry Size check failed.\n"); | ||
354 | goto fail; | ||
355 | } | ||
356 | |||
351 | if (!(*ptes = alloc_read_gpt_entries(state, *gpt))) | 357 | if (!(*ptes = alloc_read_gpt_entries(state, *gpt))) |
352 | goto fail; | 358 | goto fail; |
353 | 359 | ||
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 2e7addfd980..318d8654989 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -214,7 +214,7 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma) | |||
214 | int flags = vma->vm_flags; | 214 | int flags = vma->vm_flags; |
215 | unsigned long ino = 0; | 215 | unsigned long ino = 0; |
216 | unsigned long long pgoff = 0; | 216 | unsigned long long pgoff = 0; |
217 | unsigned long start; | 217 | unsigned long start, end; |
218 | dev_t dev = 0; | 218 | dev_t dev = 0; |
219 | int len; | 219 | int len; |
220 | 220 | ||
@@ -227,13 +227,15 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma) | |||
227 | 227 | ||
228 | /* We don't show the stack guard page in /proc/maps */ | 228 | /* We don't show the stack guard page in /proc/maps */ |
229 | start = vma->vm_start; | 229 | start = vma->vm_start; |
230 | if (vma->vm_flags & VM_GROWSDOWN) | 230 | if (stack_guard_page_start(vma, start)) |
231 | if (!vma_stack_continue(vma->vm_prev, vma->vm_start)) | 231 | start += PAGE_SIZE; |
232 | start += PAGE_SIZE; | 232 | end = vma->vm_end; |
233 | if (stack_guard_page_end(vma, end)) | ||
234 | end -= PAGE_SIZE; | ||
233 | 235 | ||
234 | seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", | 236 | seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", |
235 | start, | 237 | start, |
236 | vma->vm_end, | 238 | end, |
237 | flags & VM_READ ? 'r' : '-', | 239 | flags & VM_READ ? 'r' : '-', |
238 | flags & VM_WRITE ? 'w' : '-', | 240 | flags & VM_WRITE ? 'w' : '-', |
239 | flags & VM_EXEC ? 'x' : '-', | 241 | flags & VM_EXEC ? 'x' : '-', |
diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c index 4d0cb124146..40fa780ebea 100644 --- a/fs/ubifs/log.c +++ b/fs/ubifs/log.c | |||
@@ -175,26 +175,6 @@ void ubifs_add_bud(struct ubifs_info *c, struct ubifs_bud *bud) | |||
175 | } | 175 | } |
176 | 176 | ||
177 | /** | 177 | /** |
178 | * ubifs_create_buds_lists - create journal head buds lists for remount rw. | ||
179 | * @c: UBIFS file-system description object | ||
180 | */ | ||
181 | void ubifs_create_buds_lists(struct ubifs_info *c) | ||
182 | { | ||
183 | struct rb_node *p; | ||
184 | |||
185 | spin_lock(&c->buds_lock); | ||
186 | p = rb_first(&c->buds); | ||
187 | while (p) { | ||
188 | struct ubifs_bud *bud = rb_entry(p, struct ubifs_bud, rb); | ||
189 | struct ubifs_jhead *jhead = &c->jheads[bud->jhead]; | ||
190 | |||
191 | list_add_tail(&bud->list, &jhead->buds_list); | ||
192 | p = rb_next(p); | ||
193 | } | ||
194 | spin_unlock(&c->buds_lock); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * ubifs_add_bud_to_log - add a new bud to the log. | 178 | * ubifs_add_bud_to_log - add a new bud to the log. |
199 | * @c: UBIFS file-system description object | 179 | * @c: UBIFS file-system description object |
200 | * @jhead: journal head the bud belongs to | 180 | * @jhead: journal head the bud belongs to |
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c index eed0fcff8d7..d3d6d365bfc 100644 --- a/fs/ubifs/replay.c +++ b/fs/ubifs/replay.c | |||
@@ -59,6 +59,7 @@ enum { | |||
59 | * @new_size: truncation new size | 59 | * @new_size: truncation new size |
60 | * @free: amount of free space in a bud | 60 | * @free: amount of free space in a bud |
61 | * @dirty: amount of dirty space in a bud from padding and deletion nodes | 61 | * @dirty: amount of dirty space in a bud from padding and deletion nodes |
62 | * @jhead: journal head number of the bud | ||
62 | * | 63 | * |
63 | * UBIFS journal replay must compare node sequence numbers, which means it must | 64 | * UBIFS journal replay must compare node sequence numbers, which means it must |
64 | * build a tree of node information to insert into the TNC. | 65 | * build a tree of node information to insert into the TNC. |
@@ -80,6 +81,7 @@ struct replay_entry { | |||
80 | struct { | 81 | struct { |
81 | int free; | 82 | int free; |
82 | int dirty; | 83 | int dirty; |
84 | int jhead; | ||
83 | }; | 85 | }; |
84 | }; | 86 | }; |
85 | }; | 87 | }; |
@@ -159,6 +161,11 @@ static int set_bud_lprops(struct ubifs_info *c, struct replay_entry *r) | |||
159 | err = PTR_ERR(lp); | 161 | err = PTR_ERR(lp); |
160 | goto out; | 162 | goto out; |
161 | } | 163 | } |
164 | |||
165 | /* Make sure the journal head points to the latest bud */ | ||
166 | err = ubifs_wbuf_seek_nolock(&c->jheads[r->jhead].wbuf, r->lnum, | ||
167 | c->leb_size - r->free, UBI_SHORTTERM); | ||
168 | |||
162 | out: | 169 | out: |
163 | ubifs_release_lprops(c); | 170 | ubifs_release_lprops(c); |
164 | return err; | 171 | return err; |
@@ -627,10 +634,6 @@ static int replay_bud(struct ubifs_info *c, int lnum, int offs, int jhead, | |||
627 | ubifs_assert(sleb->endpt - offs >= used); | 634 | ubifs_assert(sleb->endpt - offs >= used); |
628 | ubifs_assert(sleb->endpt % c->min_io_size == 0); | 635 | ubifs_assert(sleb->endpt % c->min_io_size == 0); |
629 | 636 | ||
630 | if (sleb->endpt + c->min_io_size <= c->leb_size && !c->ro_mount) | ||
631 | err = ubifs_wbuf_seek_nolock(&c->jheads[jhead].wbuf, lnum, | ||
632 | sleb->endpt, UBI_SHORTTERM); | ||
633 | |||
634 | *dirty = sleb->endpt - offs - used; | 637 | *dirty = sleb->endpt - offs - used; |
635 | *free = c->leb_size - sleb->endpt; | 638 | *free = c->leb_size - sleb->endpt; |
636 | 639 | ||
@@ -653,12 +656,14 @@ out_dump: | |||
653 | * @sqnum: sequence number | 656 | * @sqnum: sequence number |
654 | * @free: amount of free space in bud | 657 | * @free: amount of free space in bud |
655 | * @dirty: amount of dirty space from padding and deletion nodes | 658 | * @dirty: amount of dirty space from padding and deletion nodes |
659 | * @jhead: journal head number for the bud | ||
656 | * | 660 | * |
657 | * This function inserts a reference node to the replay tree and returns zero | 661 | * This function inserts a reference node to the replay tree and returns zero |
658 | * in case of success or a negative error code in case of failure. | 662 | * in case of success or a negative error code in case of failure. |
659 | */ | 663 | */ |
660 | static int insert_ref_node(struct ubifs_info *c, int lnum, int offs, | 664 | static int insert_ref_node(struct ubifs_info *c, int lnum, int offs, |
661 | unsigned long long sqnum, int free, int dirty) | 665 | unsigned long long sqnum, int free, int dirty, |
666 | int jhead) | ||
662 | { | 667 | { |
663 | struct rb_node **p = &c->replay_tree.rb_node, *parent = NULL; | 668 | struct rb_node **p = &c->replay_tree.rb_node, *parent = NULL; |
664 | struct replay_entry *r; | 669 | struct replay_entry *r; |
@@ -688,6 +693,7 @@ static int insert_ref_node(struct ubifs_info *c, int lnum, int offs, | |||
688 | r->flags = REPLAY_REF; | 693 | r->flags = REPLAY_REF; |
689 | r->free = free; | 694 | r->free = free; |
690 | r->dirty = dirty; | 695 | r->dirty = dirty; |
696 | r->jhead = jhead; | ||
691 | 697 | ||
692 | rb_link_node(&r->rb, parent, p); | 698 | rb_link_node(&r->rb, parent, p); |
693 | rb_insert_color(&r->rb, &c->replay_tree); | 699 | rb_insert_color(&r->rb, &c->replay_tree); |
@@ -712,7 +718,7 @@ static int replay_buds(struct ubifs_info *c) | |||
712 | if (err) | 718 | if (err) |
713 | return err; | 719 | return err; |
714 | err = insert_ref_node(c, b->bud->lnum, b->bud->start, b->sqnum, | 720 | err = insert_ref_node(c, b->bud->lnum, b->bud->start, b->sqnum, |
715 | free, dirty); | 721 | free, dirty, b->bud->jhead); |
716 | if (err) | 722 | if (err) |
717 | return err; | 723 | return err; |
718 | } | 724 | } |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index be6c7b008f3..04ad07f4fcc 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -1257,12 +1257,12 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1257 | goto out_free; | 1257 | goto out_free; |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | err = alloc_wbufs(c); | ||
1261 | if (err) | ||
1262 | goto out_cbuf; | ||
1263 | |||
1260 | sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id); | 1264 | sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id); |
1261 | if (!c->ro_mount) { | 1265 | if (!c->ro_mount) { |
1262 | err = alloc_wbufs(c); | ||
1263 | if (err) | ||
1264 | goto out_cbuf; | ||
1265 | |||
1266 | /* Create background thread */ | 1266 | /* Create background thread */ |
1267 | c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name); | 1267 | c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name); |
1268 | if (IS_ERR(c->bgt)) { | 1268 | if (IS_ERR(c->bgt)) { |
@@ -1631,12 +1631,6 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1631 | if (err) | 1631 | if (err) |
1632 | goto out; | 1632 | goto out; |
1633 | 1633 | ||
1634 | err = alloc_wbufs(c); | ||
1635 | if (err) | ||
1636 | goto out; | ||
1637 | |||
1638 | ubifs_create_buds_lists(c); | ||
1639 | |||
1640 | /* Create background thread */ | 1634 | /* Create background thread */ |
1641 | c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name); | 1635 | c->bgt = kthread_create(ubifs_bg_thread, c, "%s", c->bgt_name); |
1642 | if (IS_ERR(c->bgt)) { | 1636 | if (IS_ERR(c->bgt)) { |
@@ -1744,7 +1738,6 @@ static void ubifs_remount_ro(struct ubifs_info *c) | |||
1744 | if (err) | 1738 | if (err) |
1745 | ubifs_ro_mode(c, err); | 1739 | ubifs_ro_mode(c, err); |
1746 | 1740 | ||
1747 | free_wbufs(c); | ||
1748 | vfree(c->orph_buf); | 1741 | vfree(c->orph_buf); |
1749 | c->orph_buf = NULL; | 1742 | c->orph_buf = NULL; |
1750 | kfree(c->write_reserve_buf); | 1743 | kfree(c->write_reserve_buf); |
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c index e4f9c1b0836..3e898a48122 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/linux-2.6/xfs_sync.c | |||
@@ -926,6 +926,7 @@ restart: | |||
926 | XFS_LOOKUP_BATCH, | 926 | XFS_LOOKUP_BATCH, |
927 | XFS_ICI_RECLAIM_TAG); | 927 | XFS_ICI_RECLAIM_TAG); |
928 | if (!nr_found) { | 928 | if (!nr_found) { |
929 | done = 1; | ||
929 | rcu_read_unlock(); | 930 | rcu_read_unlock(); |
930 | break; | 931 | break; |
931 | } | 932 | } |
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index acdb92f14d5..5fc2380092c 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c | |||
@@ -346,20 +346,23 @@ xfs_ail_delete( | |||
346 | */ | 346 | */ |
347 | STATIC void | 347 | STATIC void |
348 | xfs_ail_worker( | 348 | xfs_ail_worker( |
349 | struct work_struct *work) | 349 | struct work_struct *work) |
350 | { | 350 | { |
351 | struct xfs_ail *ailp = container_of(to_delayed_work(work), | 351 | struct xfs_ail *ailp = container_of(to_delayed_work(work), |
352 | struct xfs_ail, xa_work); | 352 | struct xfs_ail, xa_work); |
353 | long tout; | 353 | xfs_mount_t *mp = ailp->xa_mount; |
354 | xfs_lsn_t target = ailp->xa_target; | ||
355 | xfs_lsn_t lsn; | ||
356 | xfs_log_item_t *lip; | ||
357 | int flush_log, count, stuck; | ||
358 | xfs_mount_t *mp = ailp->xa_mount; | ||
359 | struct xfs_ail_cursor *cur = &ailp->xa_cursors; | 354 | struct xfs_ail_cursor *cur = &ailp->xa_cursors; |
360 | int push_xfsbufd = 0; | 355 | xfs_log_item_t *lip; |
356 | xfs_lsn_t lsn; | ||
357 | xfs_lsn_t target; | ||
358 | long tout = 10; | ||
359 | int flush_log = 0; | ||
360 | int stuck = 0; | ||
361 | int count = 0; | ||
362 | int push_xfsbufd = 0; | ||
361 | 363 | ||
362 | spin_lock(&ailp->xa_lock); | 364 | spin_lock(&ailp->xa_lock); |
365 | target = ailp->xa_target; | ||
363 | xfs_trans_ail_cursor_init(ailp, cur); | 366 | xfs_trans_ail_cursor_init(ailp, cur); |
364 | lip = xfs_trans_ail_cursor_first(ailp, cur, ailp->xa_last_pushed_lsn); | 367 | lip = xfs_trans_ail_cursor_first(ailp, cur, ailp->xa_last_pushed_lsn); |
365 | if (!lip || XFS_FORCED_SHUTDOWN(mp)) { | 368 | if (!lip || XFS_FORCED_SHUTDOWN(mp)) { |
@@ -368,8 +371,7 @@ xfs_ail_worker( | |||
368 | */ | 371 | */ |
369 | xfs_trans_ail_cursor_done(ailp, cur); | 372 | xfs_trans_ail_cursor_done(ailp, cur); |
370 | spin_unlock(&ailp->xa_lock); | 373 | spin_unlock(&ailp->xa_lock); |
371 | ailp->xa_last_pushed_lsn = 0; | 374 | goto out_done; |
372 | return; | ||
373 | } | 375 | } |
374 | 376 | ||
375 | XFS_STATS_INC(xs_push_ail); | 377 | XFS_STATS_INC(xs_push_ail); |
@@ -386,8 +388,7 @@ xfs_ail_worker( | |||
386 | * lots of contention on the AIL lists. | 388 | * lots of contention on the AIL lists. |
387 | */ | 389 | */ |
388 | lsn = lip->li_lsn; | 390 | lsn = lip->li_lsn; |
389 | flush_log = stuck = count = 0; | 391 | while ((XFS_LSN_CMP(lip->li_lsn, target) <= 0)) { |
390 | while ((XFS_LSN_CMP(lip->li_lsn, target) < 0)) { | ||
391 | int lock_result; | 392 | int lock_result; |
392 | /* | 393 | /* |
393 | * If we can lock the item without sleeping, unlock the AIL | 394 | * If we can lock the item without sleeping, unlock the AIL |
@@ -480,21 +481,25 @@ xfs_ail_worker( | |||
480 | } | 481 | } |
481 | 482 | ||
482 | /* assume we have more work to do in a short while */ | 483 | /* assume we have more work to do in a short while */ |
483 | tout = 10; | 484 | out_done: |
484 | if (!count) { | 485 | if (!count) { |
485 | /* We're past our target or empty, so idle */ | 486 | /* We're past our target or empty, so idle */ |
486 | ailp->xa_last_pushed_lsn = 0; | 487 | ailp->xa_last_pushed_lsn = 0; |
487 | 488 | ||
488 | /* | 489 | /* |
489 | * Check for an updated push target before clearing the | 490 | * We clear the XFS_AIL_PUSHING_BIT first before checking |
490 | * XFS_AIL_PUSHING_BIT. If the target changed, we've got more | 491 | * whether the target has changed. If the target has changed, |
491 | * work to do. Wait a bit longer before starting that work. | 492 | * this pushes the requeue race directly onto the result of the |
493 | * atomic test/set bit, so we are guaranteed that either the | ||
494 | * the pusher that changed the target or ourselves will requeue | ||
495 | * the work (but not both). | ||
492 | */ | 496 | */ |
497 | clear_bit(XFS_AIL_PUSHING_BIT, &ailp->xa_flags); | ||
493 | smp_rmb(); | 498 | smp_rmb(); |
494 | if (ailp->xa_target == target) { | 499 | if (XFS_LSN_CMP(ailp->xa_target, target) == 0 || |
495 | clear_bit(XFS_AIL_PUSHING_BIT, &ailp->xa_flags); | 500 | test_and_set_bit(XFS_AIL_PUSHING_BIT, &ailp->xa_flags)) |
496 | return; | 501 | return; |
497 | } | 502 | |
498 | tout = 50; | 503 | tout = 50; |
499 | } else if (XFS_LSN_CMP(lsn, target) >= 0) { | 504 | } else if (XFS_LSN_CMP(lsn, target) >= 0) { |
500 | /* | 505 | /* |
@@ -553,7 +558,7 @@ xfs_ail_push( | |||
553 | * the XFS_AIL_PUSHING_BIT. | 558 | * the XFS_AIL_PUSHING_BIT. |
554 | */ | 559 | */ |
555 | smp_wmb(); | 560 | smp_wmb(); |
556 | ailp->xa_target = threshold_lsn; | 561 | xfs_trans_ail_copy_lsn(ailp, &ailp->xa_target, &threshold_lsn); |
557 | if (!test_and_set_bit(XFS_AIL_PUSHING_BIT, &ailp->xa_flags)) | 562 | if (!test_and_set_bit(XFS_AIL_PUSHING_BIT, &ailp->xa_flags)) |
558 | queue_delayed_work(xfs_syncd_wq, &ailp->xa_work, 0); | 563 | queue_delayed_work(xfs_syncd_wq, &ailp->xa_work, 0); |
559 | } | 564 | } |
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index ade09d7b427..c99c3d3e781 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h | |||
@@ -127,7 +127,7 @@ void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, | |||
127 | 127 | ||
128 | int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info); | 128 | int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info); |
129 | 129 | ||
130 | bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper); | 130 | int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper); |
131 | bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel); | 131 | bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel); |
132 | int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper); | 132 | int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper); |
133 | int drm_fb_helper_debug_enter(struct fb_info *info); | 133 | int drm_fb_helper_debug_enter(struct fb_info *info); |
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h index c2f93a8ae2e..564b14aa7e1 100644 --- a/include/drm/drm_mm.h +++ b/include/drm/drm_mm.h | |||
@@ -86,7 +86,7 @@ static inline bool drm_mm_initialized(struct drm_mm *mm) | |||
86 | } | 86 | } |
87 | #define drm_mm_for_each_node(entry, mm) list_for_each_entry(entry, \ | 87 | #define drm_mm_for_each_node(entry, mm) list_for_each_entry(entry, \ |
88 | &(mm)->head_node.node_list, \ | 88 | &(mm)->head_node.node_list, \ |
89 | node_list); | 89 | node_list) |
90 | #define drm_mm_for_each_scanned_node_reverse(entry, n, mm) \ | 90 | #define drm_mm_for_each_scanned_node_reverse(entry, n, mm) \ |
91 | for (entry = (mm)->prev_scanned_node, \ | 91 | for (entry = (mm)->prev_scanned_node, \ |
92 | next = entry ? list_entry(entry->node_list.next, \ | 92 | next = entry ? list_entry(entry->node_list.next, \ |
diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h index 816e30cbd96..f04b2a3b0f4 100644 --- a/include/drm/drm_pciids.h +++ b/include/drm/drm_pciids.h | |||
@@ -155,6 +155,7 @@ | |||
155 | {0x1002, 0x6719, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ | 155 | {0x1002, 0x6719, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ |
156 | {0x1002, 0x671c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ | 156 | {0x1002, 0x671c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ |
157 | {0x1002, 0x671d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ | 157 | {0x1002, 0x671d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ |
158 | {0x1002, 0x671f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ | ||
158 | {0x1002, 0x6720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 159 | {0x1002, 0x6720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
159 | {0x1002, 0x6721, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 160 | {0x1002, 0x6721, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
160 | {0x1002, 0x6722, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ | 161 | {0x1002, 0x6722, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ |
@@ -167,6 +168,7 @@ | |||
167 | {0x1002, 0x6729, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ | 168 | {0x1002, 0x6729, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ |
168 | {0x1002, 0x6738, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ | 169 | {0x1002, 0x6738, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ |
169 | {0x1002, 0x6739, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ | 170 | {0x1002, 0x6739, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ |
171 | {0x1002, 0x673e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ | ||
170 | {0x1002, 0x6740, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 172 | {0x1002, 0x6740, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
171 | {0x1002, 0x6741, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 173 | {0x1002, 0x6741, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
172 | {0x1002, 0x6742, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 174 | {0x1002, 0x6742, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
@@ -199,6 +201,7 @@ | |||
199 | {0x1002, 0x688D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ | 201 | {0x1002, 0x688D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ |
200 | {0x1002, 0x6898, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ | 202 | {0x1002, 0x6898, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ |
201 | {0x1002, 0x6899, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ | 203 | {0x1002, 0x6899, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ |
204 | {0x1002, 0x689b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ | ||
202 | {0x1002, 0x689c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \ | 205 | {0x1002, 0x689c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \ |
203 | {0x1002, 0x689d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \ | 206 | {0x1002, 0x689d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \ |
204 | {0x1002, 0x689e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ | 207 | {0x1002, 0x689e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ |
@@ -209,7 +212,9 @@ | |||
209 | {0x1002, 0x68b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 212 | {0x1002, 0x68b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
210 | {0x1002, 0x68b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ | 213 | {0x1002, 0x68b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ |
211 | {0x1002, 0x68b9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ | 214 | {0x1002, 0x68b9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ |
215 | {0x1002, 0x68ba, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ | ||
212 | {0x1002, 0x68be, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ | 216 | {0x1002, 0x68be, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ |
217 | {0x1002, 0x68bf, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ | ||
213 | {0x1002, 0x68c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 218 | {0x1002, 0x68c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
214 | {0x1002, 0x68c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 219 | {0x1002, 0x68c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
215 | {0x1002, 0x68c7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 220 | {0x1002, 0x68c7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
diff --git a/include/drm/radeon_drm.h b/include/drm/radeon_drm.h index 7aa5dddb209..787f7b6fd62 100644 --- a/include/drm/radeon_drm.h +++ b/include/drm/radeon_drm.h | |||
@@ -910,6 +910,7 @@ struct drm_radeon_cs { | |||
910 | #define RADEON_INFO_CLOCK_CRYSTAL_FREQ 0x09 /* clock crystal frequency */ | 910 | #define RADEON_INFO_CLOCK_CRYSTAL_FREQ 0x09 /* clock crystal frequency */ |
911 | #define RADEON_INFO_NUM_BACKENDS 0x0a /* DB/backends for r600+ - need for OQ */ | 911 | #define RADEON_INFO_NUM_BACKENDS 0x0a /* DB/backends for r600+ - need for OQ */ |
912 | #define RADEON_INFO_NUM_TILE_PIPES 0x0b /* tile pipes for r600+ */ | 912 | #define RADEON_INFO_NUM_TILE_PIPES 0x0b /* tile pipes for r600+ */ |
913 | #define RADEON_INFO_FUSION_GART_WORKING 0x0c /* fusion writes to GTT were broken before this */ | ||
913 | 914 | ||
914 | struct drm_radeon_info { | 915 | struct drm_radeon_info { |
915 | uint32_t request; | 916 | uint32_t request; |
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index b8613e806aa..01eca1794e1 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h | |||
@@ -111,6 +111,8 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat, | |||
111 | __alloc_bootmem_nopanic(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) | 111 | __alloc_bootmem_nopanic(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) |
112 | #define alloc_bootmem_node(pgdat, x) \ | 112 | #define alloc_bootmem_node(pgdat, x) \ |
113 | __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) | 113 | __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) |
114 | #define alloc_bootmem_node_nopanic(pgdat, x) \ | ||
115 | __alloc_bootmem_node_nopanic(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) | ||
114 | #define alloc_bootmem_pages_node(pgdat, x) \ | 116 | #define alloc_bootmem_pages_node(pgdat, x) \ |
115 | __alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) | 117 | __alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) |
116 | #define alloc_bootmem_pages_node_nopanic(pgdat, x) \ | 118 | #define alloc_bootmem_pages_node_nopanic(pgdat, x) \ |
diff --git a/include/linux/capability.h b/include/linux/capability.h index 16ee8b49a20..d4675af963f 100644 --- a/include/linux/capability.h +++ b/include/linux/capability.h | |||
@@ -546,18 +546,7 @@ extern bool has_capability_noaudit(struct task_struct *t, int cap); | |||
546 | extern bool capable(int cap); | 546 | extern bool capable(int cap); |
547 | extern bool ns_capable(struct user_namespace *ns, int cap); | 547 | extern bool ns_capable(struct user_namespace *ns, int cap); |
548 | extern bool task_ns_capable(struct task_struct *t, int cap); | 548 | extern bool task_ns_capable(struct task_struct *t, int cap); |
549 | 549 | extern bool nsown_capable(int cap); | |
550 | /** | ||
551 | * nsown_capable - Check superior capability to one's own user_ns | ||
552 | * @cap: The capability in question | ||
553 | * | ||
554 | * Return true if the current task has the given superior capability | ||
555 | * targeted at its own user namespace. | ||
556 | */ | ||
557 | static inline bool nsown_capable(int cap) | ||
558 | { | ||
559 | return ns_capable(current_user_ns(), cap); | ||
560 | } | ||
561 | 550 | ||
562 | /* audit system wants to get cap info from files as well */ | 551 | /* audit system wants to get cap info from files as well */ |
563 | extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps); | 552 | extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps); |
diff --git a/include/linux/cred.h b/include/linux/cred.h index 9aeeb0ba200..be16b61283c 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
@@ -146,6 +146,7 @@ struct cred { | |||
146 | void *security; /* subjective LSM security */ | 146 | void *security; /* subjective LSM security */ |
147 | #endif | 147 | #endif |
148 | struct user_struct *user; /* real user ID subscription */ | 148 | struct user_struct *user; /* real user ID subscription */ |
149 | struct user_namespace *user_ns; /* cached user->user_ns */ | ||
149 | struct group_info *group_info; /* supplementary groups for euid/fsgid */ | 150 | struct group_info *group_info; /* supplementary groups for euid/fsgid */ |
150 | struct rcu_head rcu; /* RCU deletion hook */ | 151 | struct rcu_head rcu; /* RCU deletion hook */ |
151 | }; | 152 | }; |
@@ -354,10 +355,15 @@ static inline void put_cred(const struct cred *_cred) | |||
354 | #define current_fsgid() (current_cred_xxx(fsgid)) | 355 | #define current_fsgid() (current_cred_xxx(fsgid)) |
355 | #define current_cap() (current_cred_xxx(cap_effective)) | 356 | #define current_cap() (current_cred_xxx(cap_effective)) |
356 | #define current_user() (current_cred_xxx(user)) | 357 | #define current_user() (current_cred_xxx(user)) |
357 | #define _current_user_ns() (current_cred_xxx(user)->user_ns) | ||
358 | #define current_security() (current_cred_xxx(security)) | 358 | #define current_security() (current_cred_xxx(security)) |
359 | 359 | ||
360 | extern struct user_namespace *current_user_ns(void); | 360 | #ifdef CONFIG_USER_NS |
361 | #define current_user_ns() (current_cred_xxx(user_ns)) | ||
362 | #else | ||
363 | extern struct user_namespace init_user_ns; | ||
364 | #define current_user_ns() (&init_user_ns) | ||
365 | #endif | ||
366 | |||
361 | 367 | ||
362 | #define current_uid_gid(_uid, _gid) \ | 368 | #define current_uid_gid(_uid, _gid) \ |
363 | do { \ | 369 | do { \ |
diff --git a/include/linux/device.h b/include/linux/device.h index ab8dfc09570..d08399db6e2 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -442,7 +442,6 @@ struct device { | |||
442 | struct dev_archdata archdata; | 442 | struct dev_archdata archdata; |
443 | 443 | ||
444 | struct device_node *of_node; /* associated device tree node */ | 444 | struct device_node *of_node; /* associated device tree node */ |
445 | const struct of_device_id *of_match; /* matching of_device_id from driver */ | ||
446 | 445 | ||
447 | dev_t devt; /* dev_t, creates the sysfs "dev" */ | 446 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
448 | 447 | ||
diff --git a/include/linux/fb.h b/include/linux/fb.h index df728c1c29e..6a827487717 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h | |||
@@ -832,6 +832,7 @@ struct fb_tile_ops { | |||
832 | #define FBINFO_CAN_FORCE_OUTPUT 0x200000 | 832 | #define FBINFO_CAN_FORCE_OUTPUT 0x200000 |
833 | 833 | ||
834 | struct fb_info { | 834 | struct fb_info { |
835 | atomic_t count; | ||
835 | int node; | 836 | int node; |
836 | int flags; | 837 | int flags; |
837 | struct mutex lock; /* Lock for open/release/ioctl funcs */ | 838 | struct mutex lock; /* Lock for open/release/ioctl funcs */ |
diff --git a/include/linux/flex_array.h b/include/linux/flex_array.h index 70e4efabe0f..ebeb2f3ad06 100644 --- a/include/linux/flex_array.h +++ b/include/linux/flex_array.h | |||
@@ -61,7 +61,7 @@ struct flex_array { | |||
61 | struct flex_array *flex_array_alloc(int element_size, unsigned int total, | 61 | struct flex_array *flex_array_alloc(int element_size, unsigned int total, |
62 | gfp_t flags); | 62 | gfp_t flags); |
63 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, | 63 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, |
64 | unsigned int end, gfp_t flags); | 64 | unsigned int nr_elements, gfp_t flags); |
65 | void flex_array_free(struct flex_array *fa); | 65 | void flex_array_free(struct flex_array *fa); |
66 | void flex_array_free_parts(struct flex_array *fa); | 66 | void flex_array_free_parts(struct flex_array *fa); |
67 | int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src, | 67 | int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src, |
diff --git a/include/linux/fs.h b/include/linux/fs.h index dbd860af080..cdf9495df20 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -358,7 +358,6 @@ struct inodes_stat_t { | |||
358 | #define FS_EXTENT_FL 0x00080000 /* Extents */ | 358 | #define FS_EXTENT_FL 0x00080000 /* Extents */ |
359 | #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */ | 359 | #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */ |
360 | #define FS_NOCOW_FL 0x00800000 /* Do not cow file */ | 360 | #define FS_NOCOW_FL 0x00800000 /* Do not cow file */ |
361 | #define FS_COW_FL 0x02000000 /* Cow file */ | ||
362 | #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ | 361 | #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ |
363 | 362 | ||
364 | #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ | 363 | #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ |
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 22b32af1b5e..b5a550a39a7 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h | |||
@@ -37,6 +37,7 @@ struct trace_entry { | |||
37 | unsigned char flags; | 37 | unsigned char flags; |
38 | unsigned char preempt_count; | 38 | unsigned char preempt_count; |
39 | int pid; | 39 | int pid; |
40 | int padding; | ||
40 | }; | 41 | }; |
41 | 42 | ||
42 | #define FTRACE_MAX_EVENT \ | 43 | #define FTRACE_MAX_EVENT \ |
diff --git a/include/linux/gfp.h b/include/linux/gfp.h index bfb8f934521..56d8fc87fbb 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h | |||
@@ -353,6 +353,8 @@ extern unsigned long get_zeroed_page(gfp_t gfp_mask); | |||
353 | 353 | ||
354 | void *alloc_pages_exact(size_t size, gfp_t gfp_mask); | 354 | void *alloc_pages_exact(size_t size, gfp_t gfp_mask); |
355 | void free_pages_exact(void *virt, size_t size); | 355 | void free_pages_exact(void *virt, size_t size); |
356 | /* This is different from alloc_pages_exact_node !!! */ | ||
357 | void *alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask); | ||
356 | 358 | ||
357 | #define __get_free_page(gfp_mask) \ | 359 | #define __get_free_page(gfp_mask) \ |
358 | __get_free_pages((gfp_mask), 0) | 360 | __get_free_pages((gfp_mask), 0) |
diff --git a/include/linux/mfd/wm831x/pdata.h b/include/linux/mfd/wm831x/pdata.h index afe4db49402..632d1567a1b 100644 --- a/include/linux/mfd/wm831x/pdata.h +++ b/include/linux/mfd/wm831x/pdata.h | |||
@@ -81,7 +81,9 @@ struct wm831x_touch_pdata { | |||
81 | int rpu; /** Pen down sensitivity resistor divider */ | 81 | int rpu; /** Pen down sensitivity resistor divider */ |
82 | int pressure; /** Report pressure (boolean) */ | 82 | int pressure; /** Report pressure (boolean) */ |
83 | unsigned int data_irq; /** Touch data ready IRQ */ | 83 | unsigned int data_irq; /** Touch data ready IRQ */ |
84 | int data_irqf; /** IRQ flags for data ready IRQ */ | ||
84 | unsigned int pd_irq; /** Touch pendown detect IRQ */ | 85 | unsigned int pd_irq; /** Touch pendown detect IRQ */ |
86 | int pd_irqf; /** IRQ flags for pen down IRQ */ | ||
85 | }; | 87 | }; |
86 | 88 | ||
87 | enum wm831x_watchdog_action { | 89 | enum wm831x_watchdog_action { |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 2348db26bc3..6507dde38b1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1011,11 +1011,33 @@ int set_page_dirty_lock(struct page *page); | |||
1011 | int clear_page_dirty_for_io(struct page *page); | 1011 | int clear_page_dirty_for_io(struct page *page); |
1012 | 1012 | ||
1013 | /* Is the vma a continuation of the stack vma above it? */ | 1013 | /* Is the vma a continuation of the stack vma above it? */ |
1014 | static inline int vma_stack_continue(struct vm_area_struct *vma, unsigned long addr) | 1014 | static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr) |
1015 | { | 1015 | { |
1016 | return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN); | 1016 | return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN); |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | static inline int stack_guard_page_start(struct vm_area_struct *vma, | ||
1020 | unsigned long addr) | ||
1021 | { | ||
1022 | return (vma->vm_flags & VM_GROWSDOWN) && | ||
1023 | (vma->vm_start == addr) && | ||
1024 | !vma_growsdown(vma->vm_prev, addr); | ||
1025 | } | ||
1026 | |||
1027 | /* Is the vma a continuation of the stack vma below it? */ | ||
1028 | static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr) | ||
1029 | { | ||
1030 | return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP); | ||
1031 | } | ||
1032 | |||
1033 | static inline int stack_guard_page_end(struct vm_area_struct *vma, | ||
1034 | unsigned long addr) | ||
1035 | { | ||
1036 | return (vma->vm_flags & VM_GROWSUP) && | ||
1037 | (vma->vm_end == addr) && | ||
1038 | !vma_growsup(vma->vm_next, addr); | ||
1039 | } | ||
1040 | |||
1019 | extern unsigned long move_page_tables(struct vm_area_struct *vma, | 1041 | extern unsigned long move_page_tables(struct vm_area_struct *vma, |
1020 | unsigned long old_addr, struct vm_area_struct *new_vma, | 1042 | unsigned long old_addr, struct vm_area_struct *new_vma, |
1021 | unsigned long new_addr, unsigned long len); | 1043 | unsigned long new_addr, unsigned long len); |
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 890dce24263..7e371f7df9c 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -233,6 +233,7 @@ struct nfs4_layoutget { | |||
233 | struct nfs4_layoutget_args args; | 233 | struct nfs4_layoutget_args args; |
234 | struct nfs4_layoutget_res res; | 234 | struct nfs4_layoutget_res res; |
235 | struct pnfs_layout_segment **lsegpp; | 235 | struct pnfs_layout_segment **lsegpp; |
236 | gfp_t gfp_flags; | ||
236 | }; | 237 | }; |
237 | 238 | ||
238 | struct nfs4_getdeviceinfo_args { | 239 | struct nfs4_getdeviceinfo_args { |
diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 8bfe6c1d436..ae5638480ef 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h | |||
@@ -21,8 +21,7 @@ extern void of_device_make_bus_id(struct device *dev); | |||
21 | static inline int of_driver_match_device(struct device *dev, | 21 | static inline int of_driver_match_device(struct device *dev, |
22 | const struct device_driver *drv) | 22 | const struct device_driver *drv) |
23 | { | 23 | { |
24 | dev->of_match = of_match_device(drv->of_match_table, dev); | 24 | return of_match_device(drv->of_match_table, dev) != NULL; |
25 | return dev->of_match != NULL; | ||
26 | } | 25 | } |
27 | 26 | ||
28 | extern struct platform_device *of_dev_get(struct platform_device *dev); | 27 | extern struct platform_device *of_dev_get(struct platform_device *dev); |
@@ -58,6 +57,11 @@ static inline int of_device_uevent(struct device *dev, | |||
58 | 57 | ||
59 | static inline void of_device_node_put(struct device *dev) { } | 58 | static inline void of_device_node_put(struct device *dev) { } |
60 | 59 | ||
60 | static inline const struct of_device_id *of_match_device( | ||
61 | const struct of_device_id *matches, const struct device *dev) | ||
62 | { | ||
63 | return NULL; | ||
64 | } | ||
61 | #endif /* CONFIG_OF_DEVICE */ | 65 | #endif /* CONFIG_OF_DEVICE */ |
62 | 66 | ||
63 | #endif /* _LINUX_OF_DEVICE_H */ | 67 | #endif /* _LINUX_OF_DEVICE_H */ |
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 4e2c9150a78..8abe8d78c4b 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -2477,15 +2477,12 @@ | |||
2477 | #define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21 | 2477 | #define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21 |
2478 | #define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30 | 2478 | #define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30 |
2479 | #define PCI_DEVICE_ID_INTEL_IOAT 0x1a38 | 2479 | #define PCI_DEVICE_ID_INTEL_IOAT 0x1a38 |
2480 | #define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22 | ||
2481 | #define PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MIN 0x1c41 | 2480 | #define PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MIN 0x1c41 |
2482 | #define PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MAX 0x1c5f | 2481 | #define PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MAX 0x1c5f |
2483 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS 0x1d22 | ||
2484 | #define PCI_DEVICE_ID_INTEL_PATSBURG_LPC_0 0x1d40 | 2482 | #define PCI_DEVICE_ID_INTEL_PATSBURG_LPC_0 0x1d40 |
2485 | #define PCI_DEVICE_ID_INTEL_PATSBURG_LPC_1 0x1d41 | 2483 | #define PCI_DEVICE_ID_INTEL_PATSBURG_LPC_1 0x1d41 |
2486 | #define PCI_DEVICE_ID_INTEL_DH89XXCC_LPC_MIN 0x2310 | 2484 | #define PCI_DEVICE_ID_INTEL_DH89XXCC_LPC_MIN 0x2310 |
2487 | #define PCI_DEVICE_ID_INTEL_DH89XXCC_LPC_MAX 0x231f | 2485 | #define PCI_DEVICE_ID_INTEL_DH89XXCC_LPC_MAX 0x231f |
2488 | #define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330 | ||
2489 | #define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410 | 2486 | #define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410 |
2490 | #define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411 | 2487 | #define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411 |
2491 | #define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 | 2488 | #define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 |
@@ -2696,7 +2693,6 @@ | |||
2696 | #define PCI_DEVICE_ID_INTEL_ICH10_5 0x3a60 | 2693 | #define PCI_DEVICE_ID_INTEL_ICH10_5 0x3a60 |
2697 | #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MIN 0x3b00 | 2694 | #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MIN 0x3b00 |
2698 | #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MAX 0x3b1f | 2695 | #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MAX 0x3b1f |
2699 | #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30 | ||
2700 | #define PCI_DEVICE_ID_INTEL_IOAT_SNB 0x402f | 2696 | #define PCI_DEVICE_ID_INTEL_IOAT_SNB 0x402f |
2701 | #define PCI_DEVICE_ID_INTEL_5100_16 0x65f0 | 2697 | #define PCI_DEVICE_ID_INTEL_5100_16 0x65f0 |
2702 | #define PCI_DEVICE_ID_INTEL_5100_21 0x65f5 | 2698 | #define PCI_DEVICE_ID_INTEL_5100_21 0x65f5 |
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 3a5c4449fd3..8b97308e65d 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
@@ -948,7 +948,7 @@ do { \ | |||
948 | irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) | 948 | irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) |
949 | # endif | 949 | # endif |
950 | # define irqsafe_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \ | 950 | # define irqsafe_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
951 | __pcpu_double_call_return_int(irqsafe_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2)) | 951 | __pcpu_double_call_return_bool(irqsafe_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2)) |
952 | #endif | 952 | #endif |
953 | 953 | ||
954 | #endif /* __LINUX_PERCPU_H */ | 954 | #endif /* __LINUX_PERCPU_H */ |
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 838c1149251..eaf4350c0f9 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h | |||
@@ -208,6 +208,8 @@ static inline struct proc_dir_entry *proc_symlink(const char *name, | |||
208 | struct proc_dir_entry *parent,const char *dest) {return NULL;} | 208 | struct proc_dir_entry *parent,const char *dest) {return NULL;} |
209 | static inline struct proc_dir_entry *proc_mkdir(const char *name, | 209 | static inline struct proc_dir_entry *proc_mkdir(const char *name, |
210 | struct proc_dir_entry *parent) {return NULL;} | 210 | struct proc_dir_entry *parent) {return NULL;} |
211 | static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, | ||
212 | mode_t mode, struct proc_dir_entry *parent) { return NULL; } | ||
211 | 213 | ||
212 | static inline struct proc_dir_entry *create_proc_read_entry(const char *name, | 214 | static inline struct proc_dir_entry *create_proc_read_entry(const char *name, |
213 | mode_t mode, struct proc_dir_entry *base, | 215 | mode_t mode, struct proc_dir_entry *base, |
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index a1147e5dd24..9178d5cc0b0 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h | |||
@@ -189,6 +189,10 @@ static inline void ptrace_init_task(struct task_struct *child, bool ptrace) | |||
189 | child->ptrace = current->ptrace; | 189 | child->ptrace = current->ptrace; |
190 | __ptrace_link(child, current->parent); | 190 | __ptrace_link(child, current->parent); |
191 | } | 191 | } |
192 | |||
193 | #ifdef CONFIG_HAVE_HW_BREAKPOINT | ||
194 | atomic_set(&child->ptrace_bp_refcnt, 1); | ||
195 | #endif | ||
192 | } | 196 | } |
193 | 197 | ||
194 | /** | 198 | /** |
@@ -350,6 +354,13 @@ extern int task_current_syscall(struct task_struct *target, long *callno, | |||
350 | unsigned long args[6], unsigned int maxargs, | 354 | unsigned long args[6], unsigned int maxargs, |
351 | unsigned long *sp, unsigned long *pc); | 355 | unsigned long *sp, unsigned long *pc); |
352 | 356 | ||
353 | #endif | 357 | #ifdef CONFIG_HAVE_HW_BREAKPOINT |
358 | extern int ptrace_get_breakpoints(struct task_struct *tsk); | ||
359 | extern void ptrace_put_breakpoints(struct task_struct *tsk); | ||
360 | #else | ||
361 | static inline void ptrace_put_breakpoints(struct task_struct *tsk) { } | ||
362 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */ | ||
363 | |||
364 | #endif /* __KERNEL */ | ||
354 | 365 | ||
355 | #endif | 366 | #endif |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 18d63cea284..781abd13767 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1537,6 +1537,9 @@ struct task_struct { | |||
1537 | unsigned long memsw_nr_pages; /* uncharged mem+swap usage */ | 1537 | unsigned long memsw_nr_pages; /* uncharged mem+swap usage */ |
1538 | } memcg_batch; | 1538 | } memcg_batch; |
1539 | #endif | 1539 | #endif |
1540 | #ifdef CONFIG_HAVE_HW_BREAKPOINT | ||
1541 | atomic_t ptrace_bp_refcnt; | ||
1542 | #endif | ||
1540 | }; | 1543 | }; |
1541 | 1544 | ||
1542 | /* Future-safe accessor for struct task_struct's cpus_allowed. */ | 1545 | /* Future-safe accessor for struct task_struct's cpus_allowed. */ |
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index 0e1855079fb..605b0aa8d85 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h | |||
@@ -68,6 +68,7 @@ struct usbnet { | |||
68 | # define EVENT_RX_PAUSED 5 | 68 | # define EVENT_RX_PAUSED 5 |
69 | # define EVENT_DEV_WAKING 6 | 69 | # define EVENT_DEV_WAKING 6 |
70 | # define EVENT_DEV_ASLEEP 7 | 70 | # define EVENT_DEV_ASLEEP 7 |
71 | # define EVENT_DEV_OPEN 8 | ||
71 | }; | 72 | }; |
72 | 73 | ||
73 | static inline struct usb_driver *driver_of(struct usb_interface *intf) | 74 | static inline struct usb_driver *driver_of(struct usb_interface *intf) |
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h index 88bdd010d65..2fa8d1341a0 100644 --- a/include/net/inet_ecn.h +++ b/include/net/inet_ecn.h | |||
@@ -38,9 +38,19 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner) | |||
38 | return outer; | 38 | return outer; |
39 | } | 39 | } |
40 | 40 | ||
41 | #define INET_ECN_xmit(sk) do { inet_sk(sk)->tos |= INET_ECN_ECT_0; } while (0) | 41 | static inline void INET_ECN_xmit(struct sock *sk) |
42 | #define INET_ECN_dontxmit(sk) \ | 42 | { |
43 | do { inet_sk(sk)->tos &= ~INET_ECN_MASK; } while (0) | 43 | inet_sk(sk)->tos |= INET_ECN_ECT_0; |
44 | if (inet6_sk(sk) != NULL) | ||
45 | inet6_sk(sk)->tclass |= INET_ECN_ECT_0; | ||
46 | } | ||
47 | |||
48 | static inline void INET_ECN_dontxmit(struct sock *sk) | ||
49 | { | ||
50 | inet_sk(sk)->tos &= ~INET_ECN_MASK; | ||
51 | if (inet6_sk(sk) != NULL) | ||
52 | inet6_sk(sk)->tclass &= ~INET_ECN_MASK; | ||
53 | } | ||
44 | 54 | ||
45 | #define IP6_ECN_flow_init(label) do { \ | 55 | #define IP6_ECN_flow_init(label) do { \ |
46 | (label) &= ~htonl(INET_ECN_MASK << 20); \ | 56 | (label) &= ~htonl(INET_ECN_MASK << 20); \ |
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index d516f00c8e0..86aefed6140 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -791,6 +791,7 @@ struct ip_vs_app { | |||
791 | /* IPVS in network namespace */ | 791 | /* IPVS in network namespace */ |
792 | struct netns_ipvs { | 792 | struct netns_ipvs { |
793 | int gen; /* Generation */ | 793 | int gen; /* Generation */ |
794 | int enable; /* enable like nf_hooks do */ | ||
794 | /* | 795 | /* |
795 | * Hash table: for real service lookups | 796 | * Hash table: for real service lookups |
796 | */ | 797 | */ |
@@ -1089,6 +1090,22 @@ ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp) | |||
1089 | atomic_inc(&ctl_cp->n_control); | 1090 | atomic_inc(&ctl_cp->n_control); |
1090 | } | 1091 | } |
1091 | 1092 | ||
1093 | /* | ||
1094 | * IPVS netns init & cleanup functions | ||
1095 | */ | ||
1096 | extern int __ip_vs_estimator_init(struct net *net); | ||
1097 | extern int __ip_vs_control_init(struct net *net); | ||
1098 | extern int __ip_vs_protocol_init(struct net *net); | ||
1099 | extern int __ip_vs_app_init(struct net *net); | ||
1100 | extern int __ip_vs_conn_init(struct net *net); | ||
1101 | extern int __ip_vs_sync_init(struct net *net); | ||
1102 | extern void __ip_vs_conn_cleanup(struct net *net); | ||
1103 | extern void __ip_vs_app_cleanup(struct net *net); | ||
1104 | extern void __ip_vs_protocol_cleanup(struct net *net); | ||
1105 | extern void __ip_vs_control_cleanup(struct net *net); | ||
1106 | extern void __ip_vs_estimator_cleanup(struct net *net); | ||
1107 | extern void __ip_vs_sync_cleanup(struct net *net); | ||
1108 | extern void __ip_vs_service_cleanup(struct net *net); | ||
1092 | 1109 | ||
1093 | /* | 1110 | /* |
1094 | * IPVS application functions | 1111 | * IPVS application functions |
diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h index 75b8e2968c9..f57e7d46a45 100644 --- a/include/net/llc_pdu.h +++ b/include/net/llc_pdu.h | |||
@@ -199,7 +199,7 @@ struct llc_pdu_sn { | |||
199 | u8 ssap; | 199 | u8 ssap; |
200 | u8 ctrl_1; | 200 | u8 ctrl_1; |
201 | u8 ctrl_2; | 201 | u8 ctrl_2; |
202 | }; | 202 | } __packed; |
203 | 203 | ||
204 | static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb) | 204 | static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb) |
205 | { | 205 | { |
@@ -211,7 +211,7 @@ struct llc_pdu_un { | |||
211 | u8 dsap; | 211 | u8 dsap; |
212 | u8 ssap; | 212 | u8 ssap; |
213 | u8 ctrl_1; | 213 | u8 ctrl_1; |
214 | }; | 214 | } __packed; |
215 | 215 | ||
216 | static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb) | 216 | static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb) |
217 | { | 217 | { |
@@ -359,7 +359,7 @@ struct llc_xid_info { | |||
359 | u8 fmt_id; /* always 0x81 for LLC */ | 359 | u8 fmt_id; /* always 0x81 for LLC */ |
360 | u8 type; /* different if NULL/non-NULL LSAP */ | 360 | u8 type; /* different if NULL/non-NULL LSAP */ |
361 | u8 rw; /* sender receive window */ | 361 | u8 rw; /* sender receive window */ |
362 | }; | 362 | } __packed; |
363 | 363 | ||
364 | /** | 364 | /** |
365 | * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID | 365 | * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID |
@@ -415,7 +415,7 @@ struct llc_frmr_info { | |||
415 | u8 curr_ssv; /* current send state variable val */ | 415 | u8 curr_ssv; /* current send state variable val */ |
416 | u8 curr_rsv; /* current receive state variable */ | 416 | u8 curr_rsv; /* current receive state variable */ |
417 | u8 ind_bits; /* indicator bits set with macro */ | 417 | u8 ind_bits; /* indicator bits set with macro */ |
418 | }; | 418 | } __packed; |
419 | 419 | ||
420 | extern void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 type); | 420 | extern void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 type); |
421 | extern void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value); | 421 | extern void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value); |
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 6ae4bc5ce8a..20afeaa3939 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -324,6 +324,7 @@ struct xfrm_state_afinfo { | |||
324 | int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); | 324 | int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); |
325 | int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); | 325 | int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); |
326 | int (*output)(struct sk_buff *skb); | 326 | int (*output)(struct sk_buff *skb); |
327 | int (*output_finish)(struct sk_buff *skb); | ||
327 | int (*extract_input)(struct xfrm_state *x, | 328 | int (*extract_input)(struct xfrm_state *x, |
328 | struct sk_buff *skb); | 329 | struct sk_buff *skb); |
329 | int (*extract_output)(struct xfrm_state *x, | 330 | int (*extract_output)(struct xfrm_state *x, |
@@ -1454,6 +1455,7 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) | |||
1454 | extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb); | 1455 | extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb); |
1455 | extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb); | 1456 | extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb); |
1456 | extern int xfrm4_output(struct sk_buff *skb); | 1457 | extern int xfrm4_output(struct sk_buff *skb); |
1458 | extern int xfrm4_output_finish(struct sk_buff *skb); | ||
1457 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); | 1459 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); |
1458 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); | 1460 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); |
1459 | extern int xfrm6_extract_header(struct sk_buff *skb); | 1461 | extern int xfrm6_extract_header(struct sk_buff *skb); |
@@ -1470,6 +1472,7 @@ extern __be32 xfrm6_tunnel_spi_lookup(struct net *net, xfrm_address_t *saddr); | |||
1470 | extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb); | 1472 | extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb); |
1471 | extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb); | 1473 | extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb); |
1472 | extern int xfrm6_output(struct sk_buff *skb); | 1474 | extern int xfrm6_output(struct sk_buff *skb); |
1475 | extern int xfrm6_output_finish(struct sk_buff *skb); | ||
1473 | extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, | 1476 | extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, |
1474 | u8 **prevhdr); | 1477 | u8 **prevhdr); |
1475 | 1478 | ||
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 2d3ec509468..dd82e02ddde 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h | |||
@@ -169,6 +169,7 @@ struct scsi_device { | |||
169 | sdev_dev; | 169 | sdev_dev; |
170 | 170 | ||
171 | struct execute_work ew; /* used to get process context on put */ | 171 | struct execute_work ew; /* used to get process context on put */ |
172 | struct work_struct requeue_work; | ||
172 | 173 | ||
173 | struct scsi_dh_data *scsi_dh_data; | 174 | struct scsi_dh_data *scsi_dh_data; |
174 | enum scsi_device_state sdev_state; | 175 | enum scsi_device_state sdev_state; |
diff --git a/include/trace/events/gfpflags.h b/include/trace/events/gfpflags.h index e3615c09374..9fe3a36646e 100644 --- a/include/trace/events/gfpflags.h +++ b/include/trace/events/gfpflags.h | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | #define show_gfp_flags(flags) \ | 11 | #define show_gfp_flags(flags) \ |
12 | (flags) ? __print_flags(flags, "|", \ | 12 | (flags) ? __print_flags(flags, "|", \ |
13 | {(unsigned long)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \ | ||
13 | {(unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"}, \ | 14 | {(unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"}, \ |
14 | {(unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \ | 15 | {(unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \ |
15 | {(unsigned long)GFP_USER, "GFP_USER"}, \ | 16 | {(unsigned long)GFP_USER, "GFP_USER"}, \ |
@@ -32,6 +33,9 @@ | |||
32 | {(unsigned long)__GFP_HARDWALL, "GFP_HARDWALL"}, \ | 33 | {(unsigned long)__GFP_HARDWALL, "GFP_HARDWALL"}, \ |
33 | {(unsigned long)__GFP_THISNODE, "GFP_THISNODE"}, \ | 34 | {(unsigned long)__GFP_THISNODE, "GFP_THISNODE"}, \ |
34 | {(unsigned long)__GFP_RECLAIMABLE, "GFP_RECLAIMABLE"}, \ | 35 | {(unsigned long)__GFP_RECLAIMABLE, "GFP_RECLAIMABLE"}, \ |
35 | {(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"} \ | 36 | {(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"}, \ |
37 | {(unsigned long)__GFP_NOTRACK, "GFP_NOTRACK"}, \ | ||
38 | {(unsigned long)__GFP_NO_KSWAPD, "GFP_NO_KSWAPD"}, \ | ||
39 | {(unsigned long)__GFP_OTHER_NODE, "GFP_OTHER_NODE"} \ | ||
36 | ) : "GFP_NOWAIT" | 40 | ) : "GFP_NOWAIT" |
37 | 41 | ||
diff --git a/init/Kconfig b/init/Kconfig index d886b1e9278..7a71e0a9992 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -1226,7 +1226,6 @@ config SLAB | |||
1226 | per cpu and per node queues. | 1226 | per cpu and per node queues. |
1227 | 1227 | ||
1228 | config SLUB | 1228 | config SLUB |
1229 | depends on BROKEN || NUMA || !DISCONTIGMEM | ||
1230 | bool "SLUB (Unqueued Allocator)" | 1229 | bool "SLUB (Unqueued Allocator)" |
1231 | help | 1230 | help |
1232 | SLUB is a slab allocator that minimizes cache line usage | 1231 | SLUB is a slab allocator that minimizes cache line usage |
diff --git a/kernel/capability.c b/kernel/capability.c index bf0c734d0c1..32a80e08ff4 100644 --- a/kernel/capability.c +++ b/kernel/capability.c | |||
@@ -399,3 +399,15 @@ bool task_ns_capable(struct task_struct *t, int cap) | |||
399 | return ns_capable(task_cred_xxx(t, user)->user_ns, cap); | 399 | return ns_capable(task_cred_xxx(t, user)->user_ns, cap); |
400 | } | 400 | } |
401 | EXPORT_SYMBOL(task_ns_capable); | 401 | EXPORT_SYMBOL(task_ns_capable); |
402 | |||
403 | /** | ||
404 | * nsown_capable - Check superior capability to one's own user_ns | ||
405 | * @cap: The capability in question | ||
406 | * | ||
407 | * Return true if the current task has the given superior capability | ||
408 | * targeted at its own user namespace. | ||
409 | */ | ||
410 | bool nsown_capable(int cap) | ||
411 | { | ||
412 | return ns_capable(current_user_ns(), cap); | ||
413 | } | ||
diff --git a/kernel/cred.c b/kernel/cred.c index 5557b55048d..8093c16b84b 100644 --- a/kernel/cred.c +++ b/kernel/cred.c | |||
@@ -54,6 +54,7 @@ struct cred init_cred = { | |||
54 | .cap_effective = CAP_INIT_EFF_SET, | 54 | .cap_effective = CAP_INIT_EFF_SET, |
55 | .cap_bset = CAP_INIT_BSET, | 55 | .cap_bset = CAP_INIT_BSET, |
56 | .user = INIT_USER, | 56 | .user = INIT_USER, |
57 | .user_ns = &init_user_ns, | ||
57 | .group_info = &init_groups, | 58 | .group_info = &init_groups, |
58 | #ifdef CONFIG_KEYS | 59 | #ifdef CONFIG_KEYS |
59 | .tgcred = &init_tgcred, | 60 | .tgcred = &init_tgcred, |
@@ -410,6 +411,11 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags) | |||
410 | goto error_put; | 411 | goto error_put; |
411 | } | 412 | } |
412 | 413 | ||
414 | /* cache user_ns in cred. Doesn't need a refcount because it will | ||
415 | * stay pinned by cred->user | ||
416 | */ | ||
417 | new->user_ns = new->user->user_ns; | ||
418 | |||
413 | #ifdef CONFIG_KEYS | 419 | #ifdef CONFIG_KEYS |
414 | /* new threads get their own thread keyrings if their parent already | 420 | /* new threads get their own thread keyrings if their parent already |
415 | * had one */ | 421 | * had one */ |
@@ -741,12 +747,6 @@ int set_create_files_as(struct cred *new, struct inode *inode) | |||
741 | } | 747 | } |
742 | EXPORT_SYMBOL(set_create_files_as); | 748 | EXPORT_SYMBOL(set_create_files_as); |
743 | 749 | ||
744 | struct user_namespace *current_user_ns(void) | ||
745 | { | ||
746 | return _current_user_ns(); | ||
747 | } | ||
748 | EXPORT_SYMBOL(current_user_ns); | ||
749 | |||
750 | #ifdef CONFIG_DEBUG_CREDENTIALS | 750 | #ifdef CONFIG_DEBUG_CREDENTIALS |
751 | 751 | ||
752 | bool creds_are_invalid(const struct cred *cred) | 752 | bool creds_are_invalid(const struct cred *cred) |
diff --git a/kernel/exit.c b/kernel/exit.c index f5d2f63bae0..8dd87418154 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -1016,7 +1016,7 @@ NORET_TYPE void do_exit(long code) | |||
1016 | /* | 1016 | /* |
1017 | * FIXME: do that only when needed, using sched_exit tracepoint | 1017 | * FIXME: do that only when needed, using sched_exit tracepoint |
1018 | */ | 1018 | */ |
1019 | flush_ptrace_hw_breakpoint(tsk); | 1019 | ptrace_put_breakpoints(tsk); |
1020 | 1020 | ||
1021 | exit_notify(tsk, group_dead); | 1021 | exit_notify(tsk, group_dead); |
1022 | #ifdef CONFIG_NUMA | 1022 | #ifdef CONFIG_NUMA |
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index dd201bd3510..834899f2500 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c | |||
@@ -419,7 +419,7 @@ int show_interrupts(struct seq_file *p, void *v) | |||
419 | } else { | 419 | } else { |
420 | seq_printf(p, " %8s", "None"); | 420 | seq_printf(p, " %8s", "None"); |
421 | } | 421 | } |
422 | #ifdef CONFIG_GENIRC_IRQ_SHOW_LEVEL | 422 | #ifdef CONFIG_GENERIC_IRQ_SHOW_LEVEL |
423 | seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "Edge"); | 423 | seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "Edge"); |
424 | #endif | 424 | #endif |
425 | if (desc->name) | 425 | if (desc->name) |
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 8935369d503..6275970b218 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
@@ -216,7 +216,6 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
216 | goto Close; | 216 | goto Close; |
217 | } | 217 | } |
218 | suspend_console(); | 218 | suspend_console(); |
219 | pm_restrict_gfp_mask(); | ||
220 | suspend_test_start(); | 219 | suspend_test_start(); |
221 | error = dpm_suspend_start(PMSG_SUSPEND); | 220 | error = dpm_suspend_start(PMSG_SUSPEND); |
222 | if (error) { | 221 | if (error) { |
@@ -233,7 +232,6 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
233 | suspend_test_start(); | 232 | suspend_test_start(); |
234 | dpm_resume_end(PMSG_RESUME); | 233 | dpm_resume_end(PMSG_RESUME); |
235 | suspend_test_finish("resume devices"); | 234 | suspend_test_finish("resume devices"); |
236 | pm_restore_gfp_mask(); | ||
237 | resume_console(); | 235 | resume_console(); |
238 | Close: | 236 | Close: |
239 | if (suspend_ops->end) | 237 | if (suspend_ops->end) |
@@ -294,7 +292,9 @@ int enter_state(suspend_state_t state) | |||
294 | goto Finish; | 292 | goto Finish; |
295 | 293 | ||
296 | pr_debug("PM: Entering %s sleep\n", pm_states[state]); | 294 | pr_debug("PM: Entering %s sleep\n", pm_states[state]); |
295 | pm_restrict_gfp_mask(); | ||
297 | error = suspend_devices_and_enter(state); | 296 | error = suspend_devices_and_enter(state); |
297 | pm_restore_gfp_mask(); | ||
298 | 298 | ||
299 | Finish: | 299 | Finish: |
300 | pr_debug("PM: Finishing wakeup.\n"); | 300 | pr_debug("PM: Finishing wakeup.\n"); |
diff --git a/kernel/power/user.c b/kernel/power/user.c index c36c3b9e8a8..7d02d33be69 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -135,8 +135,10 @@ static int snapshot_release(struct inode *inode, struct file *filp) | |||
135 | free_basic_memory_bitmaps(); | 135 | free_basic_memory_bitmaps(); |
136 | data = filp->private_data; | 136 | data = filp->private_data; |
137 | free_all_swap_pages(data->swap); | 137 | free_all_swap_pages(data->swap); |
138 | if (data->frozen) | 138 | if (data->frozen) { |
139 | pm_restore_gfp_mask(); | ||
139 | thaw_processes(); | 140 | thaw_processes(); |
141 | } | ||
140 | pm_notifier_call_chain(data->mode == O_RDONLY ? | 142 | pm_notifier_call_chain(data->mode == O_RDONLY ? |
141 | PM_POST_HIBERNATION : PM_POST_RESTORE); | 143 | PM_POST_HIBERNATION : PM_POST_RESTORE); |
142 | atomic_inc(&snapshot_device_available); | 144 | atomic_inc(&snapshot_device_available); |
@@ -379,6 +381,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
379 | * PM_HIBERNATION_PREPARE | 381 | * PM_HIBERNATION_PREPARE |
380 | */ | 382 | */ |
381 | error = suspend_devices_and_enter(PM_SUSPEND_MEM); | 383 | error = suspend_devices_and_enter(PM_SUSPEND_MEM); |
384 | data->ready = 0; | ||
382 | break; | 385 | break; |
383 | 386 | ||
384 | case SNAPSHOT_PLATFORM_SUPPORT: | 387 | case SNAPSHOT_PLATFORM_SUPPORT: |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 0fc1eed28d2..dc7ab65f3b3 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/syscalls.h> | 22 | #include <linux/syscalls.h> |
23 | #include <linux/uaccess.h> | 23 | #include <linux/uaccess.h> |
24 | #include <linux/regset.h> | 24 | #include <linux/regset.h> |
25 | #include <linux/hw_breakpoint.h> | ||
25 | 26 | ||
26 | 27 | ||
27 | /* | 28 | /* |
@@ -879,3 +880,19 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, | |||
879 | return ret; | 880 | return ret; |
880 | } | 881 | } |
881 | #endif /* CONFIG_COMPAT */ | 882 | #endif /* CONFIG_COMPAT */ |
883 | |||
884 | #ifdef CONFIG_HAVE_HW_BREAKPOINT | ||
885 | int ptrace_get_breakpoints(struct task_struct *tsk) | ||
886 | { | ||
887 | if (atomic_inc_not_zero(&tsk->ptrace_bp_refcnt)) | ||
888 | return 0; | ||
889 | |||
890 | return -1; | ||
891 | } | ||
892 | |||
893 | void ptrace_put_breakpoints(struct task_struct *tsk) | ||
894 | { | ||
895 | if (atomic_dec_and_test(&tsk->ptrace_bp_refcnt)) | ||
896 | flush_ptrace_hw_breakpoint(tsk); | ||
897 | } | ||
898 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */ | ||
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 6519cf62d9c..0e17c10f8a9 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c | |||
@@ -685,8 +685,8 @@ int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) | |||
685 | /* Add clocksource to the clcoksource list */ | 685 | /* Add clocksource to the clcoksource list */ |
686 | mutex_lock(&clocksource_mutex); | 686 | mutex_lock(&clocksource_mutex); |
687 | clocksource_enqueue(cs); | 687 | clocksource_enqueue(cs); |
688 | clocksource_select(); | ||
689 | clocksource_enqueue_watchdog(cs); | 688 | clocksource_enqueue_watchdog(cs); |
689 | clocksource_select(); | ||
690 | mutex_unlock(&clocksource_mutex); | 690 | mutex_unlock(&clocksource_mutex); |
691 | return 0; | 691 | return 0; |
692 | } | 692 | } |
@@ -706,8 +706,8 @@ int clocksource_register(struct clocksource *cs) | |||
706 | 706 | ||
707 | mutex_lock(&clocksource_mutex); | 707 | mutex_lock(&clocksource_mutex); |
708 | clocksource_enqueue(cs); | 708 | clocksource_enqueue(cs); |
709 | clocksource_select(); | ||
710 | clocksource_enqueue_watchdog(cs); | 709 | clocksource_enqueue_watchdog(cs); |
710 | clocksource_select(); | ||
711 | mutex_unlock(&clocksource_mutex); | 711 | mutex_unlock(&clocksource_mutex); |
712 | return 0; | 712 | return 0; |
713 | } | 713 | } |
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index da800ffa810..723c7637e55 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c | |||
@@ -522,10 +522,11 @@ static void tick_broadcast_init_next_event(struct cpumask *mask, | |||
522 | */ | 522 | */ |
523 | void tick_broadcast_setup_oneshot(struct clock_event_device *bc) | 523 | void tick_broadcast_setup_oneshot(struct clock_event_device *bc) |
524 | { | 524 | { |
525 | int cpu = smp_processor_id(); | ||
526 | |||
525 | /* Set it up only once ! */ | 527 | /* Set it up only once ! */ |
526 | if (bc->event_handler != tick_handle_oneshot_broadcast) { | 528 | if (bc->event_handler != tick_handle_oneshot_broadcast) { |
527 | int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC; | 529 | int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC; |
528 | int cpu = smp_processor_id(); | ||
529 | 530 | ||
530 | bc->event_handler = tick_handle_oneshot_broadcast; | 531 | bc->event_handler = tick_handle_oneshot_broadcast; |
531 | clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT); | 532 | clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT); |
@@ -551,6 +552,15 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc) | |||
551 | tick_broadcast_set_event(tick_next_period, 1); | 552 | tick_broadcast_set_event(tick_next_period, 1); |
552 | } else | 553 | } else |
553 | bc->next_event.tv64 = KTIME_MAX; | 554 | bc->next_event.tv64 = KTIME_MAX; |
555 | } else { | ||
556 | /* | ||
557 | * The first cpu which switches to oneshot mode sets | ||
558 | * the bit for all other cpus which are in the general | ||
559 | * (periodic) broadcast mask. So the bit is set and | ||
560 | * would prevent the first broadcast enter after this | ||
561 | * to program the bc device. | ||
562 | */ | ||
563 | tick_broadcast_clear_oneshot(cpu); | ||
554 | } | 564 | } |
555 | } | 565 | } |
556 | 566 | ||
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index d38c16a06a6..1cb49be7c7f 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -1110,6 +1110,7 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags, | |||
1110 | 1110 | ||
1111 | entry->preempt_count = pc & 0xff; | 1111 | entry->preempt_count = pc & 0xff; |
1112 | entry->pid = (tsk) ? tsk->pid : 0; | 1112 | entry->pid = (tsk) ? tsk->pid : 0; |
1113 | entry->padding = 0; | ||
1113 | entry->flags = | 1114 | entry->flags = |
1114 | #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT | 1115 | #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT |
1115 | (irqs_disabled_flags(flags) ? TRACE_FLAG_IRQS_OFF : 0) | | 1116 | (irqs_disabled_flags(flags) ? TRACE_FLAG_IRQS_OFF : 0) | |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index e88f74fe1d4..2fe11034135 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -116,6 +116,7 @@ static int trace_define_common_fields(void) | |||
116 | __common_field(unsigned char, flags); | 116 | __common_field(unsigned char, flags); |
117 | __common_field(unsigned char, preempt_count); | 117 | __common_field(unsigned char, preempt_count); |
118 | __common_field(int, pid); | 118 | __common_field(int, pid); |
119 | __common_field(int, padding); | ||
119 | 120 | ||
120 | return ret; | 121 | return ret; |
121 | } | 122 | } |
diff --git a/lib/flex_array.c b/lib/flex_array.c index c0ea40ba208..854b57bd7d9 100644 --- a/lib/flex_array.c +++ b/lib/flex_array.c | |||
@@ -232,10 +232,10 @@ EXPORT_SYMBOL(flex_array_clear); | |||
232 | 232 | ||
233 | /** | 233 | /** |
234 | * flex_array_prealloc - guarantee that array space exists | 234 | * flex_array_prealloc - guarantee that array space exists |
235 | * @fa: the flex array for which to preallocate parts | 235 | * @fa: the flex array for which to preallocate parts |
236 | * @start: index of first array element for which space is allocated | 236 | * @start: index of first array element for which space is allocated |
237 | * @end: index of last (inclusive) element for which space is allocated | 237 | * @nr_elements: number of elements for which space is allocated |
238 | * @flags: page allocation flags | 238 | * @flags: page allocation flags |
239 | * | 239 | * |
240 | * This will guarantee that no future calls to flex_array_put() | 240 | * This will guarantee that no future calls to flex_array_put() |
241 | * will allocate memory. It can be used if you are expecting to | 241 | * will allocate memory. It can be used if you are expecting to |
@@ -245,14 +245,24 @@ EXPORT_SYMBOL(flex_array_clear); | |||
245 | * Locking must be provided by the caller. | 245 | * Locking must be provided by the caller. |
246 | */ | 246 | */ |
247 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, | 247 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, |
248 | unsigned int end, gfp_t flags) | 248 | unsigned int nr_elements, gfp_t flags) |
249 | { | 249 | { |
250 | int start_part; | 250 | int start_part; |
251 | int end_part; | 251 | int end_part; |
252 | int part_nr; | 252 | int part_nr; |
253 | unsigned int end; | ||
253 | struct flex_array_part *part; | 254 | struct flex_array_part *part; |
254 | 255 | ||
255 | if (start >= fa->total_nr_elements || end >= fa->total_nr_elements) | 256 | if (!start && !nr_elements) |
257 | return 0; | ||
258 | if (start >= fa->total_nr_elements) | ||
259 | return -ENOSPC; | ||
260 | if (!nr_elements) | ||
261 | return 0; | ||
262 | |||
263 | end = start + nr_elements - 1; | ||
264 | |||
265 | if (end >= fa->total_nr_elements) | ||
256 | return -ENOSPC; | 266 | return -ENOSPC; |
257 | if (elements_fit_in_base(fa)) | 267 | if (elements_fit_in_base(fa)) |
258 | return 0; | 268 | return 0; |
@@ -343,6 +353,8 @@ int flex_array_shrink(struct flex_array *fa) | |||
343 | int part_nr; | 353 | int part_nr; |
344 | int ret = 0; | 354 | int ret = 0; |
345 | 355 | ||
356 | if (!fa->total_nr_elements) | ||
357 | return 0; | ||
346 | if (elements_fit_in_base(fa)) | 358 | if (elements_fit_in_base(fa)) |
347 | return ret; | 359 | return ret; |
348 | for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) { | 360 | for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) { |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index bc0ac6b333d..dfd60192bc2 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -797,7 +797,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr, | |||
797 | return string(buf, end, uuid, spec); | 797 | return string(buf, end, uuid, spec); |
798 | } | 798 | } |
799 | 799 | ||
800 | int kptr_restrict = 1; | 800 | int kptr_restrict __read_mostly; |
801 | 801 | ||
802 | /* | 802 | /* |
803 | * Show a '%p' thing. A kernel extension is that the '%p' is followed | 803 | * Show a '%p' thing. A kernel extension is that the '%p' is followed |
diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c index ea5fa4fe9d6..a6cdc969ea4 100644 --- a/lib/xz/xz_dec_lzma2.c +++ b/lib/xz/xz_dec_lzma2.c | |||
@@ -969,6 +969,9 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, | |||
969 | */ | 969 | */ |
970 | tmp = b->in[b->in_pos++]; | 970 | tmp = b->in[b->in_pos++]; |
971 | 971 | ||
972 | if (tmp == 0x00) | ||
973 | return XZ_STREAM_END; | ||
974 | |||
972 | if (tmp >= 0xE0 || tmp == 0x01) { | 975 | if (tmp >= 0xE0 || tmp == 0x01) { |
973 | s->lzma2.need_props = true; | 976 | s->lzma2.need_props = true; |
974 | s->lzma2.need_dict_reset = false; | 977 | s->lzma2.need_dict_reset = false; |
@@ -1001,9 +1004,6 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, | |||
1001 | lzma_reset(s); | 1004 | lzma_reset(s); |
1002 | } | 1005 | } |
1003 | } else { | 1006 | } else { |
1004 | if (tmp == 0x00) | ||
1005 | return XZ_STREAM_END; | ||
1006 | |||
1007 | if (tmp > 0x02) | 1007 | if (tmp > 0x02) |
1008 | return XZ_DATA_ERROR; | 1008 | return XZ_DATA_ERROR; |
1009 | 1009 | ||
diff --git a/mm/memory.c b/mm/memory.c index 607098d47e7..61e66f02656 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -1359,7 +1359,7 @@ split_fallthrough: | |||
1359 | */ | 1359 | */ |
1360 | mark_page_accessed(page); | 1360 | mark_page_accessed(page); |
1361 | } | 1361 | } |
1362 | if (flags & FOLL_MLOCK) { | 1362 | if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) { |
1363 | /* | 1363 | /* |
1364 | * The preliminary mapping check is mainly to avoid the | 1364 | * The preliminary mapping check is mainly to avoid the |
1365 | * pointless overhead of lock_page on the ZERO_PAGE | 1365 | * pointless overhead of lock_page on the ZERO_PAGE |
@@ -1412,9 +1412,8 @@ no_page_table: | |||
1412 | 1412 | ||
1413 | static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr) | 1413 | static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr) |
1414 | { | 1414 | { |
1415 | return (vma->vm_flags & VM_GROWSDOWN) && | 1415 | return stack_guard_page_start(vma, addr) || |
1416 | (vma->vm_start == addr) && | 1416 | stack_guard_page_end(vma, addr+PAGE_SIZE); |
1417 | !vma_stack_continue(vma->vm_prev, addr); | ||
1418 | } | 1417 | } |
1419 | 1418 | ||
1420 | /** | 1419 | /** |
@@ -1551,13 +1550,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, | |||
1551 | continue; | 1550 | continue; |
1552 | } | 1551 | } |
1553 | 1552 | ||
1554 | /* | ||
1555 | * If we don't actually want the page itself, | ||
1556 | * and it's the stack guard page, just skip it. | ||
1557 | */ | ||
1558 | if (!pages && stack_guard_page(vma, start)) | ||
1559 | goto next_page; | ||
1560 | |||
1561 | do { | 1553 | do { |
1562 | struct page *page; | 1554 | struct page *page; |
1563 | unsigned int foll_flags = gup_flags; | 1555 | unsigned int foll_flags = gup_flags; |
@@ -1574,6 +1566,11 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, | |||
1574 | int ret; | 1566 | int ret; |
1575 | unsigned int fault_flags = 0; | 1567 | unsigned int fault_flags = 0; |
1576 | 1568 | ||
1569 | /* For mlock, just skip the stack guard page. */ | ||
1570 | if (foll_flags & FOLL_MLOCK) { | ||
1571 | if (stack_guard_page(vma, start)) | ||
1572 | goto next_page; | ||
1573 | } | ||
1577 | if (foll_flags & FOLL_WRITE) | 1574 | if (foll_flags & FOLL_WRITE) |
1578 | fault_flags |= FAULT_FLAG_WRITE; | 1575 | fault_flags |= FAULT_FLAG_WRITE; |
1579 | if (nonblocking) | 1576 | if (nonblocking) |
diff --git a/mm/mlock.c b/mm/mlock.c index 6b55e3efe0d..516b2c2ddd5 100644 --- a/mm/mlock.c +++ b/mm/mlock.c | |||
@@ -162,7 +162,7 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma, | |||
162 | VM_BUG_ON(end > vma->vm_end); | 162 | VM_BUG_ON(end > vma->vm_end); |
163 | VM_BUG_ON(!rwsem_is_locked(&mm->mmap_sem)); | 163 | VM_BUG_ON(!rwsem_is_locked(&mm->mmap_sem)); |
164 | 164 | ||
165 | gup_flags = FOLL_TOUCH; | 165 | gup_flags = FOLL_TOUCH | FOLL_MLOCK; |
166 | /* | 166 | /* |
167 | * We want to touch writable mappings with a write fault in order | 167 | * We want to touch writable mappings with a write fault in order |
168 | * to break COW, except for shared mappings because these don't COW | 168 | * to break COW, except for shared mappings because these don't COW |
@@ -178,9 +178,6 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma, | |||
178 | if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) | 178 | if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) |
179 | gup_flags |= FOLL_FORCE; | 179 | gup_flags |= FOLL_FORCE; |
180 | 180 | ||
181 | if (vma->vm_flags & VM_LOCKED) | ||
182 | gup_flags |= FOLL_MLOCK; | ||
183 | |||
184 | return __get_user_pages(current, mm, addr, nr_pages, gup_flags, | 181 | return __get_user_pages(current, mm, addr, nr_pages, gup_flags, |
185 | NULL, NULL, nonblocking); | 182 | NULL, NULL, nonblocking); |
186 | } | 183 | } |
@@ -1767,10 +1767,13 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address) | |||
1767 | size = address - vma->vm_start; | 1767 | size = address - vma->vm_start; |
1768 | grow = (address - vma->vm_end) >> PAGE_SHIFT; | 1768 | grow = (address - vma->vm_end) >> PAGE_SHIFT; |
1769 | 1769 | ||
1770 | error = acct_stack_growth(vma, size, grow); | 1770 | error = -ENOMEM; |
1771 | if (!error) { | 1771 | if (vma->vm_pgoff + (size >> PAGE_SHIFT) >= vma->vm_pgoff) { |
1772 | vma->vm_end = address; | 1772 | error = acct_stack_growth(vma, size, grow); |
1773 | perf_event_mmap(vma); | 1773 | if (!error) { |
1774 | vma->vm_end = address; | ||
1775 | perf_event_mmap(vma); | ||
1776 | } | ||
1774 | } | 1777 | } |
1775 | } | 1778 | } |
1776 | vma_unlock_anon_vma(vma); | 1779 | vma_unlock_anon_vma(vma); |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 9f8a97b9a35..3f8bce264df 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -2317,6 +2317,21 @@ void free_pages(unsigned long addr, unsigned int order) | |||
2317 | 2317 | ||
2318 | EXPORT_SYMBOL(free_pages); | 2318 | EXPORT_SYMBOL(free_pages); |
2319 | 2319 | ||
2320 | static void *make_alloc_exact(unsigned long addr, unsigned order, size_t size) | ||
2321 | { | ||
2322 | if (addr) { | ||
2323 | unsigned long alloc_end = addr + (PAGE_SIZE << order); | ||
2324 | unsigned long used = addr + PAGE_ALIGN(size); | ||
2325 | |||
2326 | split_page(virt_to_page((void *)addr), order); | ||
2327 | while (used < alloc_end) { | ||
2328 | free_page(used); | ||
2329 | used += PAGE_SIZE; | ||
2330 | } | ||
2331 | } | ||
2332 | return (void *)addr; | ||
2333 | } | ||
2334 | |||
2320 | /** | 2335 | /** |
2321 | * alloc_pages_exact - allocate an exact number physically-contiguous pages. | 2336 | * alloc_pages_exact - allocate an exact number physically-contiguous pages. |
2322 | * @size: the number of bytes to allocate | 2337 | * @size: the number of bytes to allocate |
@@ -2336,22 +2351,33 @@ void *alloc_pages_exact(size_t size, gfp_t gfp_mask) | |||
2336 | unsigned long addr; | 2351 | unsigned long addr; |
2337 | 2352 | ||
2338 | addr = __get_free_pages(gfp_mask, order); | 2353 | addr = __get_free_pages(gfp_mask, order); |
2339 | if (addr) { | 2354 | return make_alloc_exact(addr, order, size); |
2340 | unsigned long alloc_end = addr + (PAGE_SIZE << order); | ||
2341 | unsigned long used = addr + PAGE_ALIGN(size); | ||
2342 | |||
2343 | split_page(virt_to_page((void *)addr), order); | ||
2344 | while (used < alloc_end) { | ||
2345 | free_page(used); | ||
2346 | used += PAGE_SIZE; | ||
2347 | } | ||
2348 | } | ||
2349 | |||
2350 | return (void *)addr; | ||
2351 | } | 2355 | } |
2352 | EXPORT_SYMBOL(alloc_pages_exact); | 2356 | EXPORT_SYMBOL(alloc_pages_exact); |
2353 | 2357 | ||
2354 | /** | 2358 | /** |
2359 | * alloc_pages_exact_nid - allocate an exact number of physically-contiguous | ||
2360 | * pages on a node. | ||
2361 | * @nid: the preferred node ID where memory should be allocated | ||
2362 | * @size: the number of bytes to allocate | ||
2363 | * @gfp_mask: GFP flags for the allocation | ||
2364 | * | ||
2365 | * Like alloc_pages_exact(), but try to allocate on node nid first before falling | ||
2366 | * back. | ||
2367 | * Note this is not alloc_pages_exact_node() which allocates on a specific node, | ||
2368 | * but is not exact. | ||
2369 | */ | ||
2370 | void *alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask) | ||
2371 | { | ||
2372 | unsigned order = get_order(size); | ||
2373 | struct page *p = alloc_pages_node(nid, gfp_mask, order); | ||
2374 | if (!p) | ||
2375 | return NULL; | ||
2376 | return make_alloc_exact((unsigned long)page_address(p), order, size); | ||
2377 | } | ||
2378 | EXPORT_SYMBOL(alloc_pages_exact_nid); | ||
2379 | |||
2380 | /** | ||
2355 | * free_pages_exact - release memory allocated via alloc_pages_exact() | 2381 | * free_pages_exact - release memory allocated via alloc_pages_exact() |
2356 | * @virt: the value returned by alloc_pages_exact. | 2382 | * @virt: the value returned by alloc_pages_exact. |
2357 | * @size: size of allocation, same value as passed to alloc_pages_exact(). | 2383 | * @size: size of allocation, same value as passed to alloc_pages_exact(). |
@@ -3564,7 +3590,7 @@ int zone_wait_table_init(struct zone *zone, unsigned long zone_size_pages) | |||
3564 | 3590 | ||
3565 | if (!slab_is_available()) { | 3591 | if (!slab_is_available()) { |
3566 | zone->wait_table = (wait_queue_head_t *) | 3592 | zone->wait_table = (wait_queue_head_t *) |
3567 | alloc_bootmem_node(pgdat, alloc_size); | 3593 | alloc_bootmem_node_nopanic(pgdat, alloc_size); |
3568 | } else { | 3594 | } else { |
3569 | /* | 3595 | /* |
3570 | * This case means that a zone whose size was 0 gets new memory | 3596 | * This case means that a zone whose size was 0 gets new memory |
@@ -4141,7 +4167,8 @@ static void __init setup_usemap(struct pglist_data *pgdat, | |||
4141 | unsigned long usemapsize = usemap_size(zonesize); | 4167 | unsigned long usemapsize = usemap_size(zonesize); |
4142 | zone->pageblock_flags = NULL; | 4168 | zone->pageblock_flags = NULL; |
4143 | if (usemapsize) | 4169 | if (usemapsize) |
4144 | zone->pageblock_flags = alloc_bootmem_node(pgdat, usemapsize); | 4170 | zone->pageblock_flags = alloc_bootmem_node_nopanic(pgdat, |
4171 | usemapsize); | ||
4145 | } | 4172 | } |
4146 | #else | 4173 | #else |
4147 | static inline void setup_usemap(struct pglist_data *pgdat, | 4174 | static inline void setup_usemap(struct pglist_data *pgdat, |
@@ -4307,7 +4334,7 @@ static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat) | |||
4307 | size = (end - start) * sizeof(struct page); | 4334 | size = (end - start) * sizeof(struct page); |
4308 | map = alloc_remap(pgdat->node_id, size); | 4335 | map = alloc_remap(pgdat->node_id, size); |
4309 | if (!map) | 4336 | if (!map) |
4310 | map = alloc_bootmem_node(pgdat, size); | 4337 | map = alloc_bootmem_node_nopanic(pgdat, size); |
4311 | pgdat->node_mem_map = map + (pgdat->node_start_pfn - start); | 4338 | pgdat->node_mem_map = map + (pgdat->node_start_pfn - start); |
4312 | } | 4339 | } |
4313 | #ifndef CONFIG_NEED_MULTIPLE_NODES | 4340 | #ifndef CONFIG_NEED_MULTIPLE_NODES |
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c index 99055010cec..2daadc322ba 100644 --- a/mm/page_cgroup.c +++ b/mm/page_cgroup.c | |||
@@ -134,7 +134,7 @@ static void *__init_refok alloc_page_cgroup(size_t size, int nid) | |||
134 | { | 134 | { |
135 | void *addr = NULL; | 135 | void *addr = NULL; |
136 | 136 | ||
137 | addr = alloc_pages_exact(size, GFP_KERNEL | __GFP_NOWARN); | 137 | addr = alloc_pages_exact_nid(nid, size, GFP_KERNEL | __GFP_NOWARN); |
138 | if (addr) | 138 | if (addr) |
139 | return addr; | 139 | return addr; |
140 | 140 | ||
diff --git a/mm/shmem.c b/mm/shmem.c index 8fa27e4e582..dfc7069102e 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -852,7 +852,7 @@ static inline int shmem_find_swp(swp_entry_t entry, swp_entry_t *dir, swp_entry_ | |||
852 | 852 | ||
853 | static int shmem_unuse_inode(struct shmem_inode_info *info, swp_entry_t entry, struct page *page) | 853 | static int shmem_unuse_inode(struct shmem_inode_info *info, swp_entry_t entry, struct page *page) |
854 | { | 854 | { |
855 | struct inode *inode; | 855 | struct address_space *mapping; |
856 | unsigned long idx; | 856 | unsigned long idx; |
857 | unsigned long size; | 857 | unsigned long size; |
858 | unsigned long limit; | 858 | unsigned long limit; |
@@ -875,8 +875,10 @@ static int shmem_unuse_inode(struct shmem_inode_info *info, swp_entry_t entry, s | |||
875 | if (size > SHMEM_NR_DIRECT) | 875 | if (size > SHMEM_NR_DIRECT) |
876 | size = SHMEM_NR_DIRECT; | 876 | size = SHMEM_NR_DIRECT; |
877 | offset = shmem_find_swp(entry, ptr, ptr+size); | 877 | offset = shmem_find_swp(entry, ptr, ptr+size); |
878 | if (offset >= 0) | 878 | if (offset >= 0) { |
879 | shmem_swp_balance_unmap(); | ||
879 | goto found; | 880 | goto found; |
881 | } | ||
880 | if (!info->i_indirect) | 882 | if (!info->i_indirect) |
881 | goto lost2; | 883 | goto lost2; |
882 | 884 | ||
@@ -914,11 +916,11 @@ static int shmem_unuse_inode(struct shmem_inode_info *info, swp_entry_t entry, s | |||
914 | if (size > ENTRIES_PER_PAGE) | 916 | if (size > ENTRIES_PER_PAGE) |
915 | size = ENTRIES_PER_PAGE; | 917 | size = ENTRIES_PER_PAGE; |
916 | offset = shmem_find_swp(entry, ptr, ptr+size); | 918 | offset = shmem_find_swp(entry, ptr, ptr+size); |
917 | shmem_swp_unmap(ptr); | ||
918 | if (offset >= 0) { | 919 | if (offset >= 0) { |
919 | shmem_dir_unmap(dir); | 920 | shmem_dir_unmap(dir); |
920 | goto found; | 921 | goto found; |
921 | } | 922 | } |
923 | shmem_swp_unmap(ptr); | ||
922 | } | 924 | } |
923 | } | 925 | } |
924 | lost1: | 926 | lost1: |
@@ -928,8 +930,7 @@ lost2: | |||
928 | return 0; | 930 | return 0; |
929 | found: | 931 | found: |
930 | idx += offset; | 932 | idx += offset; |
931 | inode = igrab(&info->vfs_inode); | 933 | ptr += offset; |
932 | spin_unlock(&info->lock); | ||
933 | 934 | ||
934 | /* | 935 | /* |
935 | * Move _head_ to start search for next from here. | 936 | * Move _head_ to start search for next from here. |
@@ -940,37 +941,18 @@ found: | |||
940 | */ | 941 | */ |
941 | if (shmem_swaplist.next != &info->swaplist) | 942 | if (shmem_swaplist.next != &info->swaplist) |
942 | list_move_tail(&shmem_swaplist, &info->swaplist); | 943 | list_move_tail(&shmem_swaplist, &info->swaplist); |
943 | mutex_unlock(&shmem_swaplist_mutex); | ||
944 | 944 | ||
945 | error = 1; | ||
946 | if (!inode) | ||
947 | goto out; | ||
948 | /* | 945 | /* |
949 | * Charge page using GFP_KERNEL while we can wait. | 946 | * We rely on shmem_swaplist_mutex, not only to protect the swaplist, |
950 | * Charged back to the user(not to caller) when swap account is used. | 947 | * but also to hold up shmem_evict_inode(): so inode cannot be freed |
951 | * add_to_page_cache() will be called with GFP_NOWAIT. | 948 | * beneath us (pagelock doesn't help until the page is in pagecache). |
952 | */ | 949 | */ |
953 | error = mem_cgroup_cache_charge(page, current->mm, GFP_KERNEL); | 950 | mapping = info->vfs_inode.i_mapping; |
954 | if (error) | 951 | error = add_to_page_cache_locked(page, mapping, idx, GFP_NOWAIT); |
955 | goto out; | 952 | /* which does mem_cgroup_uncharge_cache_page on error */ |
956 | error = radix_tree_preload(GFP_KERNEL); | ||
957 | if (error) { | ||
958 | mem_cgroup_uncharge_cache_page(page); | ||
959 | goto out; | ||
960 | } | ||
961 | error = 1; | ||
962 | |||
963 | spin_lock(&info->lock); | ||
964 | ptr = shmem_swp_entry(info, idx, NULL); | ||
965 | if (ptr && ptr->val == entry.val) { | ||
966 | error = add_to_page_cache_locked(page, inode->i_mapping, | ||
967 | idx, GFP_NOWAIT); | ||
968 | /* does mem_cgroup_uncharge_cache_page on error */ | ||
969 | } else /* we must compensate for our precharge above */ | ||
970 | mem_cgroup_uncharge_cache_page(page); | ||
971 | 953 | ||
972 | if (error == -EEXIST) { | 954 | if (error == -EEXIST) { |
973 | struct page *filepage = find_get_page(inode->i_mapping, idx); | 955 | struct page *filepage = find_get_page(mapping, idx); |
974 | error = 1; | 956 | error = 1; |
975 | if (filepage) { | 957 | if (filepage) { |
976 | /* | 958 | /* |
@@ -990,14 +972,8 @@ found: | |||
990 | swap_free(entry); | 972 | swap_free(entry); |
991 | error = 1; /* not an error, but entry was found */ | 973 | error = 1; /* not an error, but entry was found */ |
992 | } | 974 | } |
993 | if (ptr) | 975 | shmem_swp_unmap(ptr); |
994 | shmem_swp_unmap(ptr); | ||
995 | spin_unlock(&info->lock); | 976 | spin_unlock(&info->lock); |
996 | radix_tree_preload_end(); | ||
997 | out: | ||
998 | unlock_page(page); | ||
999 | page_cache_release(page); | ||
1000 | iput(inode); /* allows for NULL */ | ||
1001 | return error; | 977 | return error; |
1002 | } | 978 | } |
1003 | 979 | ||
@@ -1009,6 +985,26 @@ int shmem_unuse(swp_entry_t entry, struct page *page) | |||
1009 | struct list_head *p, *next; | 985 | struct list_head *p, *next; |
1010 | struct shmem_inode_info *info; | 986 | struct shmem_inode_info *info; |
1011 | int found = 0; | 987 | int found = 0; |
988 | int error; | ||
989 | |||
990 | /* | ||
991 | * Charge page using GFP_KERNEL while we can wait, before taking | ||
992 | * the shmem_swaplist_mutex which might hold up shmem_writepage(). | ||
993 | * Charged back to the user (not to caller) when swap account is used. | ||
994 | * add_to_page_cache() will be called with GFP_NOWAIT. | ||
995 | */ | ||
996 | error = mem_cgroup_cache_charge(page, current->mm, GFP_KERNEL); | ||
997 | if (error) | ||
998 | goto out; | ||
999 | /* | ||
1000 | * Try to preload while we can wait, to not make a habit of | ||
1001 | * draining atomic reserves; but don't latch on to this cpu, | ||
1002 | * it's okay if sometimes we get rescheduled after this. | ||
1003 | */ | ||
1004 | error = radix_tree_preload(GFP_KERNEL); | ||
1005 | if (error) | ||
1006 | goto uncharge; | ||
1007 | radix_tree_preload_end(); | ||
1012 | 1008 | ||
1013 | mutex_lock(&shmem_swaplist_mutex); | 1009 | mutex_lock(&shmem_swaplist_mutex); |
1014 | list_for_each_safe(p, next, &shmem_swaplist) { | 1010 | list_for_each_safe(p, next, &shmem_swaplist) { |
@@ -1016,17 +1012,19 @@ int shmem_unuse(swp_entry_t entry, struct page *page) | |||
1016 | found = shmem_unuse_inode(info, entry, page); | 1012 | found = shmem_unuse_inode(info, entry, page); |
1017 | cond_resched(); | 1013 | cond_resched(); |
1018 | if (found) | 1014 | if (found) |
1019 | goto out; | 1015 | break; |
1020 | } | 1016 | } |
1021 | mutex_unlock(&shmem_swaplist_mutex); | 1017 | mutex_unlock(&shmem_swaplist_mutex); |
1022 | /* | 1018 | |
1023 | * Can some race bring us here? We've been holding page lock, | 1019 | uncharge: |
1024 | * so I think not; but would rather try again later than BUG() | 1020 | if (!found) |
1025 | */ | 1021 | mem_cgroup_uncharge_cache_page(page); |
1022 | if (found < 0) | ||
1023 | error = found; | ||
1024 | out: | ||
1026 | unlock_page(page); | 1025 | unlock_page(page); |
1027 | page_cache_release(page); | 1026 | page_cache_release(page); |
1028 | out: | 1027 | return error; |
1029 | return (found < 0) ? found : 0; | ||
1030 | } | 1028 | } |
1031 | 1029 | ||
1032 | /* | 1030 | /* |
@@ -1064,7 +1062,25 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) | |||
1064 | else | 1062 | else |
1065 | swap.val = 0; | 1063 | swap.val = 0; |
1066 | 1064 | ||
1065 | /* | ||
1066 | * Add inode to shmem_unuse()'s list of swapped-out inodes, | ||
1067 | * if it's not already there. Do it now because we cannot take | ||
1068 | * mutex while holding spinlock, and must do so before the page | ||
1069 | * is moved to swap cache, when its pagelock no longer protects | ||
1070 | * the inode from eviction. But don't unlock the mutex until | ||
1071 | * we've taken the spinlock, because shmem_unuse_inode() will | ||
1072 | * prune a !swapped inode from the swaplist under both locks. | ||
1073 | */ | ||
1074 | if (swap.val) { | ||
1075 | mutex_lock(&shmem_swaplist_mutex); | ||
1076 | if (list_empty(&info->swaplist)) | ||
1077 | list_add_tail(&info->swaplist, &shmem_swaplist); | ||
1078 | } | ||
1079 | |||
1067 | spin_lock(&info->lock); | 1080 | spin_lock(&info->lock); |
1081 | if (swap.val) | ||
1082 | mutex_unlock(&shmem_swaplist_mutex); | ||
1083 | |||
1068 | if (index >= info->next_index) { | 1084 | if (index >= info->next_index) { |
1069 | BUG_ON(!(info->flags & SHMEM_TRUNCATE)); | 1085 | BUG_ON(!(info->flags & SHMEM_TRUNCATE)); |
1070 | goto unlock; | 1086 | goto unlock; |
@@ -1084,21 +1100,10 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) | |||
1084 | delete_from_page_cache(page); | 1100 | delete_from_page_cache(page); |
1085 | shmem_swp_set(info, entry, swap.val); | 1101 | shmem_swp_set(info, entry, swap.val); |
1086 | shmem_swp_unmap(entry); | 1102 | shmem_swp_unmap(entry); |
1087 | if (list_empty(&info->swaplist)) | ||
1088 | inode = igrab(inode); | ||
1089 | else | ||
1090 | inode = NULL; | ||
1091 | spin_unlock(&info->lock); | 1103 | spin_unlock(&info->lock); |
1092 | swap_shmem_alloc(swap); | 1104 | swap_shmem_alloc(swap); |
1093 | BUG_ON(page_mapped(page)); | 1105 | BUG_ON(page_mapped(page)); |
1094 | swap_writepage(page, wbc); | 1106 | swap_writepage(page, wbc); |
1095 | if (inode) { | ||
1096 | mutex_lock(&shmem_swaplist_mutex); | ||
1097 | /* move instead of add in case we're racing */ | ||
1098 | list_move_tail(&info->swaplist, &shmem_swaplist); | ||
1099 | mutex_unlock(&shmem_swaplist_mutex); | ||
1100 | iput(inode); | ||
1101 | } | ||
1102 | return 0; | 1107 | return 0; |
1103 | } | 1108 | } |
1104 | 1109 | ||
@@ -1400,20 +1405,14 @@ repeat: | |||
1400 | if (sbinfo->max_blocks) { | 1405 | if (sbinfo->max_blocks) { |
1401 | if (percpu_counter_compare(&sbinfo->used_blocks, | 1406 | if (percpu_counter_compare(&sbinfo->used_blocks, |
1402 | sbinfo->max_blocks) >= 0 || | 1407 | sbinfo->max_blocks) >= 0 || |
1403 | shmem_acct_block(info->flags)) { | 1408 | shmem_acct_block(info->flags)) |
1404 | spin_unlock(&info->lock); | 1409 | goto nospace; |
1405 | error = -ENOSPC; | ||
1406 | goto failed; | ||
1407 | } | ||
1408 | percpu_counter_inc(&sbinfo->used_blocks); | 1410 | percpu_counter_inc(&sbinfo->used_blocks); |
1409 | spin_lock(&inode->i_lock); | 1411 | spin_lock(&inode->i_lock); |
1410 | inode->i_blocks += BLOCKS_PER_PAGE; | 1412 | inode->i_blocks += BLOCKS_PER_PAGE; |
1411 | spin_unlock(&inode->i_lock); | 1413 | spin_unlock(&inode->i_lock); |
1412 | } else if (shmem_acct_block(info->flags)) { | 1414 | } else if (shmem_acct_block(info->flags)) |
1413 | spin_unlock(&info->lock); | 1415 | goto nospace; |
1414 | error = -ENOSPC; | ||
1415 | goto failed; | ||
1416 | } | ||
1417 | 1416 | ||
1418 | if (!filepage) { | 1417 | if (!filepage) { |
1419 | int ret; | 1418 | int ret; |
@@ -1493,6 +1492,24 @@ done: | |||
1493 | error = 0; | 1492 | error = 0; |
1494 | goto out; | 1493 | goto out; |
1495 | 1494 | ||
1495 | nospace: | ||
1496 | /* | ||
1497 | * Perhaps the page was brought in from swap between find_lock_page | ||
1498 | * and taking info->lock? We allow for that at add_to_page_cache_lru, | ||
1499 | * but must also avoid reporting a spurious ENOSPC while working on a | ||
1500 | * full tmpfs. (When filepage has been passed in to shmem_getpage, it | ||
1501 | * is already in page cache, which prevents this race from occurring.) | ||
1502 | */ | ||
1503 | if (!filepage) { | ||
1504 | struct page *page = find_get_page(mapping, idx); | ||
1505 | if (page) { | ||
1506 | spin_unlock(&info->lock); | ||
1507 | page_cache_release(page); | ||
1508 | goto repeat; | ||
1509 | } | ||
1510 | } | ||
1511 | spin_unlock(&info->lock); | ||
1512 | error = -ENOSPC; | ||
1496 | failed: | 1513 | failed: |
1497 | if (*pagep != filepage) { | 1514 | if (*pagep != filepage) { |
1498 | unlock_page(filepage); | 1515 | unlock_page(filepage); |
@@ -1940,7 +1940,7 @@ redo: | |||
1940 | * Since this is without lock semantics the protection is only against | 1940 | * Since this is without lock semantics the protection is only against |
1941 | * code executing on this cpu *not* from access by other cpus. | 1941 | * code executing on this cpu *not* from access by other cpus. |
1942 | */ | 1942 | */ |
1943 | if (unlikely(!this_cpu_cmpxchg_double( | 1943 | if (unlikely(!irqsafe_cpu_cmpxchg_double( |
1944 | s->cpu_slab->freelist, s->cpu_slab->tid, | 1944 | s->cpu_slab->freelist, s->cpu_slab->tid, |
1945 | object, tid, | 1945 | object, tid, |
1946 | get_freepointer(s, object), next_tid(tid)))) { | 1946 | get_freepointer(s, object), next_tid(tid)))) { |
@@ -2145,7 +2145,7 @@ redo: | |||
2145 | set_freepointer(s, object, c->freelist); | 2145 | set_freepointer(s, object, c->freelist); |
2146 | 2146 | ||
2147 | #ifdef CONFIG_CMPXCHG_LOCAL | 2147 | #ifdef CONFIG_CMPXCHG_LOCAL |
2148 | if (unlikely(!this_cpu_cmpxchg_double( | 2148 | if (unlikely(!irqsafe_cpu_cmpxchg_double( |
2149 | s->cpu_slab->freelist, s->cpu_slab->tid, | 2149 | s->cpu_slab->freelist, s->cpu_slab->tid, |
2150 | c->freelist, tid, | 2150 | c->freelist, tid, |
2151 | object, next_tid(tid)))) { | 2151 | object, next_tid(tid)))) { |
@@ -396,6 +396,9 @@ static void lru_deactivate_fn(struct page *page, void *arg) | |||
396 | if (!PageLRU(page)) | 396 | if (!PageLRU(page)) |
397 | return; | 397 | return; |
398 | 398 | ||
399 | if (PageUnevictable(page)) | ||
400 | return; | ||
401 | |||
399 | /* Some processes are using the page */ | 402 | /* Some processes are using the page */ |
400 | if (page_mapped(page)) | 403 | if (page_mapped(page)) |
401 | return; | 404 | return; |
diff --git a/mm/vmscan.c b/mm/vmscan.c index f6b435c8007..8bfd45050a6 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -937,7 +937,7 @@ keep_lumpy: | |||
937 | * back off and wait for congestion to clear because further reclaim | 937 | * back off and wait for congestion to clear because further reclaim |
938 | * will encounter the same problem | 938 | * will encounter the same problem |
939 | */ | 939 | */ |
940 | if (nr_dirty == nr_congested && nr_dirty != 0) | 940 | if (nr_dirty && nr_dirty == nr_congested && scanning_global_lru(sc)) |
941 | zone_set_flag(zone, ZONE_CONGESTED); | 941 | zone_set_flag(zone, ZONE_CONGESTED); |
942 | 942 | ||
943 | free_page_list(&free_pages); | 943 | free_page_list(&free_pages); |
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 7850412f52b..0eb1a886b37 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -124,6 +124,9 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head) | |||
124 | 124 | ||
125 | grp->nr_vlans--; | 125 | grp->nr_vlans--; |
126 | 126 | ||
127 | if (vlan->flags & VLAN_FLAG_GVRP) | ||
128 | vlan_gvrp_request_leave(dev); | ||
129 | |||
127 | vlan_group_set_device(grp, vlan_id, NULL); | 130 | vlan_group_set_device(grp, vlan_id, NULL); |
128 | if (!grp->killall) | 131 | if (!grp->killall) |
129 | synchronize_net(); | 132 | synchronize_net(); |
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index e34ea9e5e28..b2ff6c8d360 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -487,9 +487,6 @@ static int vlan_dev_stop(struct net_device *dev) | |||
487 | struct vlan_dev_info *vlan = vlan_dev_info(dev); | 487 | struct vlan_dev_info *vlan = vlan_dev_info(dev); |
488 | struct net_device *real_dev = vlan->real_dev; | 488 | struct net_device *real_dev = vlan->real_dev; |
489 | 489 | ||
490 | if (vlan->flags & VLAN_FLAG_GVRP) | ||
491 | vlan_gvrp_request_leave(dev); | ||
492 | |||
493 | dev_mc_unsync(real_dev, dev); | 490 | dev_mc_unsync(real_dev, dev); |
494 | dev_uc_unsync(real_dev, dev); | 491 | dev_uc_unsync(real_dev, dev); |
495 | if (dev->flags & IFF_ALLMULTI) | 492 | if (dev->flags & IFF_ALLMULTI) |
diff --git a/net/9p/client.c b/net/9p/client.c index 77367745be9..a9aa2dd6648 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -614,7 +614,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) | |||
614 | 614 | ||
615 | err = c->trans_mod->request(c, req); | 615 | err = c->trans_mod->request(c, req); |
616 | if (err < 0) { | 616 | if (err < 0) { |
617 | if (err != -ERESTARTSYS) | 617 | if (err != -ERESTARTSYS && err != -EFAULT) |
618 | c->status = Disconnected; | 618 | c->status = Disconnected; |
619 | goto reterr; | 619 | goto reterr; |
620 | } | 620 | } |
diff --git a/net/9p/protocol.c b/net/9p/protocol.c index b58a501cf3d..a873277cb99 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c | |||
@@ -674,6 +674,7 @@ int p9dirent_read(char *buf, int len, struct p9_dirent *dirent, | |||
674 | } | 674 | } |
675 | 675 | ||
676 | strcpy(dirent->d_name, nameptr); | 676 | strcpy(dirent->d_name, nameptr); |
677 | kfree(nameptr); | ||
677 | 678 | ||
678 | out: | 679 | out: |
679 | return fake_pdu.offset; | 680 | return fake_pdu.offset; |
diff --git a/net/9p/trans_common.c b/net/9p/trans_common.c index e883172f9aa..9a70ebdec56 100644 --- a/net/9p/trans_common.c +++ b/net/9p/trans_common.c | |||
@@ -63,7 +63,7 @@ p9_payload_gup(struct p9_req_t *req, size_t *pdata_off, int *pdata_len, | |||
63 | int nr_pages, u8 rw) | 63 | int nr_pages, u8 rw) |
64 | { | 64 | { |
65 | uint32_t first_page_bytes = 0; | 65 | uint32_t first_page_bytes = 0; |
66 | uint32_t pdata_mapped_pages; | 66 | int32_t pdata_mapped_pages; |
67 | struct trans_rpage_info *rpinfo; | 67 | struct trans_rpage_info *rpinfo; |
68 | 68 | ||
69 | *pdata_off = (__force size_t)req->tc->pubuf & (PAGE_SIZE-1); | 69 | *pdata_off = (__force size_t)req->tc->pubuf & (PAGE_SIZE-1); |
@@ -75,14 +75,9 @@ p9_payload_gup(struct p9_req_t *req, size_t *pdata_off, int *pdata_len, | |||
75 | rpinfo = req->tc->private; | 75 | rpinfo = req->tc->private; |
76 | pdata_mapped_pages = get_user_pages_fast((unsigned long)req->tc->pubuf, | 76 | pdata_mapped_pages = get_user_pages_fast((unsigned long)req->tc->pubuf, |
77 | nr_pages, rw, &rpinfo->rp_data[0]); | 77 | nr_pages, rw, &rpinfo->rp_data[0]); |
78 | if (pdata_mapped_pages <= 0) | ||
79 | return pdata_mapped_pages; | ||
78 | 80 | ||
79 | if (pdata_mapped_pages < 0) { | ||
80 | printk(KERN_ERR "get_user_pages_fast failed:%d udata:%p" | ||
81 | "nr_pages:%d\n", pdata_mapped_pages, | ||
82 | req->tc->pubuf, nr_pages); | ||
83 | pdata_mapped_pages = 0; | ||
84 | return -EIO; | ||
85 | } | ||
86 | rpinfo->rp_nr_pages = pdata_mapped_pages; | 81 | rpinfo->rp_nr_pages = pdata_mapped_pages; |
87 | if (*pdata_off) { | 82 | if (*pdata_off) { |
88 | *pdata_len = first_page_bytes; | 83 | *pdata_len = first_page_bytes; |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index c83f618282f..b5a8afc2be3 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -587,10 +587,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
587 | hci_req_cancel(hdev, ENODEV); | 587 | hci_req_cancel(hdev, ENODEV); |
588 | hci_req_lock(hdev); | 588 | hci_req_lock(hdev); |
589 | 589 | ||
590 | /* Stop timer, it might be running */ | ||
591 | del_timer_sync(&hdev->cmd_timer); | ||
592 | |||
593 | if (!test_and_clear_bit(HCI_UP, &hdev->flags)) { | 590 | if (!test_and_clear_bit(HCI_UP, &hdev->flags)) { |
591 | del_timer_sync(&hdev->cmd_timer); | ||
594 | hci_req_unlock(hdev); | 592 | hci_req_unlock(hdev); |
595 | return 0; | 593 | return 0; |
596 | } | 594 | } |
@@ -629,6 +627,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
629 | 627 | ||
630 | /* Drop last sent command */ | 628 | /* Drop last sent command */ |
631 | if (hdev->sent_cmd) { | 629 | if (hdev->sent_cmd) { |
630 | del_timer_sync(&hdev->cmd_timer); | ||
632 | kfree_skb(hdev->sent_cmd); | 631 | kfree_skb(hdev->sent_cmd); |
633 | hdev->sent_cmd = NULL; | 632 | hdev->sent_cmd = NULL; |
634 | } | 633 | } |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index cebe7588469..b2570159a04 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -2387,8 +2387,6 @@ static inline void hci_io_capa_reply_evt(struct hci_dev *hdev, struct sk_buff *s | |||
2387 | if (!conn) | 2387 | if (!conn) |
2388 | goto unlock; | 2388 | goto unlock; |
2389 | 2389 | ||
2390 | hci_conn_hold(conn); | ||
2391 | |||
2392 | conn->remote_cap = ev->capability; | 2390 | conn->remote_cap = ev->capability; |
2393 | conn->remote_oob = ev->oob_data; | 2391 | conn->remote_oob = ev->oob_data; |
2394 | conn->remote_auth = ev->authentication; | 2392 | conn->remote_auth = ev->authentication; |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ca27f3a4153..2c8dd4494c6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -1051,6 +1051,7 @@ static void l2cap_retransmit_one_frame(struct sock *sk, u8 tx_seq) | |||
1051 | tx_skb = skb_clone(skb, GFP_ATOMIC); | 1051 | tx_skb = skb_clone(skb, GFP_ATOMIC); |
1052 | bt_cb(skb)->retries++; | 1052 | bt_cb(skb)->retries++; |
1053 | control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); | 1053 | control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); |
1054 | control &= L2CAP_CTRL_SAR; | ||
1054 | 1055 | ||
1055 | if (pi->conn_state & L2CAP_CONN_SEND_FBIT) { | 1056 | if (pi->conn_state & L2CAP_CONN_SEND_FBIT) { |
1056 | control |= L2CAP_CTRL_FINAL; | 1057 | control |= L2CAP_CTRL_FINAL; |
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index e2160792e1b..0c7badad62a 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c | |||
@@ -164,7 +164,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb) | |||
164 | goto drop; | 164 | goto drop; |
165 | 165 | ||
166 | /* If STP is turned off, then forward */ | 166 | /* If STP is turned off, then forward */ |
167 | if (p->br->stp_enabled == BR_NO_STP) | 167 | if (p->br->stp_enabled == BR_NO_STP && dest[5] == 0) |
168 | goto forward; | 168 | goto forward; |
169 | 169 | ||
170 | if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, | 170 | if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, |
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c index f3bc322c589..74ef4d4846a 100644 --- a/net/bridge/br_netfilter.c +++ b/net/bridge/br_netfilter.c | |||
@@ -737,7 +737,7 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb, | |||
737 | nf_bridge->mask |= BRNF_PKT_TYPE; | 737 | nf_bridge->mask |= BRNF_PKT_TYPE; |
738 | } | 738 | } |
739 | 739 | ||
740 | if (br_parse_ip_options(skb)) | 740 | if (pf == PF_INET && br_parse_ip_options(skb)) |
741 | return NF_DROP; | 741 | return NF_DROP; |
742 | 742 | ||
743 | /* The physdev module checks on this */ | 743 | /* The physdev module checks on this */ |
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 893669caa8d..1a92b369c82 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c | |||
@@ -1766,7 +1766,7 @@ static int compat_table_info(const struct ebt_table_info *info, | |||
1766 | 1766 | ||
1767 | newinfo->entries_size = size; | 1767 | newinfo->entries_size = size; |
1768 | 1768 | ||
1769 | xt_compat_init_offsets(AF_INET, info->nentries); | 1769 | xt_compat_init_offsets(NFPROTO_BRIDGE, info->nentries); |
1770 | return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info, | 1770 | return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info, |
1771 | entries, newinfo); | 1771 | entries, newinfo); |
1772 | } | 1772 | } |
@@ -1882,7 +1882,7 @@ static int compat_mtw_from_user(struct compat_ebt_entry_mwt *mwt, | |||
1882 | struct xt_match *match; | 1882 | struct xt_match *match; |
1883 | struct xt_target *wt; | 1883 | struct xt_target *wt; |
1884 | void *dst = NULL; | 1884 | void *dst = NULL; |
1885 | int off, pad = 0, ret = 0; | 1885 | int off, pad = 0; |
1886 | unsigned int size_kern, entry_offset, match_size = mwt->match_size; | 1886 | unsigned int size_kern, entry_offset, match_size = mwt->match_size; |
1887 | 1887 | ||
1888 | strlcpy(name, mwt->u.name, sizeof(name)); | 1888 | strlcpy(name, mwt->u.name, sizeof(name)); |
@@ -1935,13 +1935,6 @@ static int compat_mtw_from_user(struct compat_ebt_entry_mwt *mwt, | |||
1935 | break; | 1935 | break; |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | if (!dst) { | ||
1939 | ret = xt_compat_add_offset(NFPROTO_BRIDGE, entry_offset, | ||
1940 | off + ebt_compat_entry_padsize()); | ||
1941 | if (ret < 0) | ||
1942 | return ret; | ||
1943 | } | ||
1944 | |||
1945 | state->buf_kern_offset += match_size + off; | 1938 | state->buf_kern_offset += match_size + off; |
1946 | state->buf_user_offset += match_size; | 1939 | state->buf_user_offset += match_size; |
1947 | pad = XT_ALIGN(size_kern) - size_kern; | 1940 | pad = XT_ALIGN(size_kern) - size_kern; |
@@ -2016,50 +2009,6 @@ static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32, | |||
2016 | return growth; | 2009 | return growth; |
2017 | } | 2010 | } |
2018 | 2011 | ||
2019 | #define EBT_COMPAT_WATCHER_ITERATE(e, fn, args...) \ | ||
2020 | ({ \ | ||
2021 | unsigned int __i; \ | ||
2022 | int __ret = 0; \ | ||
2023 | struct compat_ebt_entry_mwt *__watcher; \ | ||
2024 | \ | ||
2025 | for (__i = e->watchers_offset; \ | ||
2026 | __i < (e)->target_offset; \ | ||
2027 | __i += __watcher->watcher_size + \ | ||
2028 | sizeof(struct compat_ebt_entry_mwt)) { \ | ||
2029 | __watcher = (void *)(e) + __i; \ | ||
2030 | __ret = fn(__watcher , ## args); \ | ||
2031 | if (__ret != 0) \ | ||
2032 | break; \ | ||
2033 | } \ | ||
2034 | if (__ret == 0) { \ | ||
2035 | if (__i != (e)->target_offset) \ | ||
2036 | __ret = -EINVAL; \ | ||
2037 | } \ | ||
2038 | __ret; \ | ||
2039 | }) | ||
2040 | |||
2041 | #define EBT_COMPAT_MATCH_ITERATE(e, fn, args...) \ | ||
2042 | ({ \ | ||
2043 | unsigned int __i; \ | ||
2044 | int __ret = 0; \ | ||
2045 | struct compat_ebt_entry_mwt *__match; \ | ||
2046 | \ | ||
2047 | for (__i = sizeof(struct ebt_entry); \ | ||
2048 | __i < (e)->watchers_offset; \ | ||
2049 | __i += __match->match_size + \ | ||
2050 | sizeof(struct compat_ebt_entry_mwt)) { \ | ||
2051 | __match = (void *)(e) + __i; \ | ||
2052 | __ret = fn(__match , ## args); \ | ||
2053 | if (__ret != 0) \ | ||
2054 | break; \ | ||
2055 | } \ | ||
2056 | if (__ret == 0) { \ | ||
2057 | if (__i != (e)->watchers_offset) \ | ||
2058 | __ret = -EINVAL; \ | ||
2059 | } \ | ||
2060 | __ret; \ | ||
2061 | }) | ||
2062 | |||
2063 | /* called for all ebt_entry structures. */ | 2012 | /* called for all ebt_entry structures. */ |
2064 | static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base, | 2013 | static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base, |
2065 | unsigned int *total, | 2014 | unsigned int *total, |
@@ -2132,6 +2081,14 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base, | |||
2132 | } | 2081 | } |
2133 | } | 2082 | } |
2134 | 2083 | ||
2084 | if (state->buf_kern_start == NULL) { | ||
2085 | unsigned int offset = buf_start - (char *) base; | ||
2086 | |||
2087 | ret = xt_compat_add_offset(NFPROTO_BRIDGE, offset, new_offset); | ||
2088 | if (ret < 0) | ||
2089 | return ret; | ||
2090 | } | ||
2091 | |||
2135 | startoff = state->buf_user_offset - startoff; | 2092 | startoff = state->buf_user_offset - startoff; |
2136 | 2093 | ||
2137 | BUG_ON(*total < startoff); | 2094 | BUG_ON(*total < startoff); |
@@ -2240,6 +2197,7 @@ static int compat_do_replace(struct net *net, void __user *user, | |||
2240 | 2197 | ||
2241 | xt_compat_lock(NFPROTO_BRIDGE); | 2198 | xt_compat_lock(NFPROTO_BRIDGE); |
2242 | 2199 | ||
2200 | xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries); | ||
2243 | ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state); | 2201 | ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state); |
2244 | if (ret < 0) | 2202 | if (ret < 0) |
2245 | goto out_unlock; | 2203 | goto out_unlock; |
diff --git a/net/can/bcm.c b/net/can/bcm.c index 57b1aed7901..8a6a05e7c3c 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c | |||
@@ -1427,9 +1427,14 @@ static int bcm_init(struct sock *sk) | |||
1427 | static int bcm_release(struct socket *sock) | 1427 | static int bcm_release(struct socket *sock) |
1428 | { | 1428 | { |
1429 | struct sock *sk = sock->sk; | 1429 | struct sock *sk = sock->sk; |
1430 | struct bcm_sock *bo = bcm_sk(sk); | 1430 | struct bcm_sock *bo; |
1431 | struct bcm_op *op, *next; | 1431 | struct bcm_op *op, *next; |
1432 | 1432 | ||
1433 | if (sk == NULL) | ||
1434 | return 0; | ||
1435 | |||
1436 | bo = bcm_sk(sk); | ||
1437 | |||
1433 | /* remove bcm_ops, timer, rx_unregister(), etc. */ | 1438 | /* remove bcm_ops, timer, rx_unregister(), etc. */ |
1434 | 1439 | ||
1435 | unregister_netdevice_notifier(&bo->notifier); | 1440 | unregister_netdevice_notifier(&bo->notifier); |
diff --git a/net/can/raw.c b/net/can/raw.c index 649acfa7c70..0eb39a7fdf6 100644 --- a/net/can/raw.c +++ b/net/can/raw.c | |||
@@ -305,7 +305,12 @@ static int raw_init(struct sock *sk) | |||
305 | static int raw_release(struct socket *sock) | 305 | static int raw_release(struct socket *sock) |
306 | { | 306 | { |
307 | struct sock *sk = sock->sk; | 307 | struct sock *sk = sock->sk; |
308 | struct raw_sock *ro = raw_sk(sk); | 308 | struct raw_sock *ro; |
309 | |||
310 | if (!sk) | ||
311 | return 0; | ||
312 | |||
313 | ro = raw_sk(sk); | ||
309 | 314 | ||
310 | unregister_netdevice_notifier(&ro->notifier); | 315 | unregister_netdevice_notifier(&ro->notifier); |
311 | 316 | ||
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 05f357828a2..e15a82ccc05 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -2267,6 +2267,19 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags) | |||
2267 | m->more_to_follow = false; | 2267 | m->more_to_follow = false; |
2268 | m->pool = NULL; | 2268 | m->pool = NULL; |
2269 | 2269 | ||
2270 | /* middle */ | ||
2271 | m->middle = NULL; | ||
2272 | |||
2273 | /* data */ | ||
2274 | m->nr_pages = 0; | ||
2275 | m->page_alignment = 0; | ||
2276 | m->pages = NULL; | ||
2277 | m->pagelist = NULL; | ||
2278 | m->bio = NULL; | ||
2279 | m->bio_iter = NULL; | ||
2280 | m->bio_seg = 0; | ||
2281 | m->trail = NULL; | ||
2282 | |||
2270 | /* front */ | 2283 | /* front */ |
2271 | if (front_len) { | 2284 | if (front_len) { |
2272 | if (front_len > PAGE_CACHE_SIZE) { | 2285 | if (front_len > PAGE_CACHE_SIZE) { |
@@ -2286,19 +2299,6 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags) | |||
2286 | } | 2299 | } |
2287 | m->front.iov_len = front_len; | 2300 | m->front.iov_len = front_len; |
2288 | 2301 | ||
2289 | /* middle */ | ||
2290 | m->middle = NULL; | ||
2291 | |||
2292 | /* data */ | ||
2293 | m->nr_pages = 0; | ||
2294 | m->page_alignment = 0; | ||
2295 | m->pages = NULL; | ||
2296 | m->pagelist = NULL; | ||
2297 | m->bio = NULL; | ||
2298 | m->bio_iter = NULL; | ||
2299 | m->bio_seg = 0; | ||
2300 | m->trail = NULL; | ||
2301 | |||
2302 | dout("ceph_msg_new %p front %d\n", m, front_len); | 2302 | dout("ceph_msg_new %p front %d\n", m, front_len); |
2303 | return m; | 2303 | return m; |
2304 | 2304 | ||
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 5a80f41c0cb..6b5dda1cb5d 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -470,8 +470,8 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
470 | snapc, ops, | 470 | snapc, ops, |
471 | use_mempool, | 471 | use_mempool, |
472 | GFP_NOFS, NULL, NULL); | 472 | GFP_NOFS, NULL, NULL); |
473 | if (IS_ERR(req)) | 473 | if (!req) |
474 | return req; | 474 | return NULL; |
475 | 475 | ||
476 | /* calculate max write size */ | 476 | /* calculate max write size */ |
477 | calc_layout(osdc, vino, layout, off, plen, req, ops); | 477 | calc_layout(osdc, vino, layout, off, plen, req, ops); |
diff --git a/net/core/dev.c b/net/core/dev.c index c2ac599fa0f..b624fe4d9bd 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1284,11 +1284,13 @@ static int dev_close_many(struct list_head *head) | |||
1284 | */ | 1284 | */ |
1285 | int dev_close(struct net_device *dev) | 1285 | int dev_close(struct net_device *dev) |
1286 | { | 1286 | { |
1287 | LIST_HEAD(single); | 1287 | if (dev->flags & IFF_UP) { |
1288 | LIST_HEAD(single); | ||
1288 | 1289 | ||
1289 | list_add(&dev->unreg_list, &single); | 1290 | list_add(&dev->unreg_list, &single); |
1290 | dev_close_many(&single); | 1291 | dev_close_many(&single); |
1291 | list_del(&single); | 1292 | list_del(&single); |
1293 | } | ||
1292 | return 0; | 1294 | return 0; |
1293 | } | 1295 | } |
1294 | EXPORT_SYMBOL(dev_close); | 1296 | EXPORT_SYMBOL(dev_close); |
@@ -4773,7 +4775,7 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm | |||
4773 | * is never reached | 4775 | * is never reached |
4774 | */ | 4776 | */ |
4775 | WARN_ON(1); | 4777 | WARN_ON(1); |
4776 | err = -EINVAL; | 4778 | err = -ENOTTY; |
4777 | break; | 4779 | break; |
4778 | 4780 | ||
4779 | } | 4781 | } |
@@ -5041,7 +5043,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) | |||
5041 | /* Set the per device memory buffer space. | 5043 | /* Set the per device memory buffer space. |
5042 | * Not applicable in our case */ | 5044 | * Not applicable in our case */ |
5043 | case SIOCSIFLINK: | 5045 | case SIOCSIFLINK: |
5044 | return -EINVAL; | 5046 | return -ENOTTY; |
5045 | 5047 | ||
5046 | /* | 5048 | /* |
5047 | * Unknown or private ioctl. | 5049 | * Unknown or private ioctl. |
@@ -5062,7 +5064,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) | |||
5062 | /* Take care of Wireless Extensions */ | 5064 | /* Take care of Wireless Extensions */ |
5063 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) | 5065 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) |
5064 | return wext_handle_ioctl(net, &ifr, cmd, arg); | 5066 | return wext_handle_ioctl(net, &ifr, cmd, arg); |
5065 | return -EINVAL; | 5067 | return -ENOTTY; |
5066 | } | 5068 | } |
5067 | } | 5069 | } |
5068 | 5070 | ||
@@ -5184,27 +5186,27 @@ u32 netdev_fix_features(struct net_device *dev, u32 features) | |||
5184 | /* Fix illegal checksum combinations */ | 5186 | /* Fix illegal checksum combinations */ |
5185 | if ((features & NETIF_F_HW_CSUM) && | 5187 | if ((features & NETIF_F_HW_CSUM) && |
5186 | (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { | 5188 | (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { |
5187 | netdev_info(dev, "mixed HW and IP checksum settings.\n"); | 5189 | netdev_warn(dev, "mixed HW and IP checksum settings.\n"); |
5188 | features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); | 5190 | features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); |
5189 | } | 5191 | } |
5190 | 5192 | ||
5191 | if ((features & NETIF_F_NO_CSUM) && | 5193 | if ((features & NETIF_F_NO_CSUM) && |
5192 | (features & (NETIF_F_HW_CSUM|NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { | 5194 | (features & (NETIF_F_HW_CSUM|NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { |
5193 | netdev_info(dev, "mixed no checksumming and other settings.\n"); | 5195 | netdev_warn(dev, "mixed no checksumming and other settings.\n"); |
5194 | features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM|NETIF_F_HW_CSUM); | 5196 | features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM|NETIF_F_HW_CSUM); |
5195 | } | 5197 | } |
5196 | 5198 | ||
5197 | /* Fix illegal SG+CSUM combinations. */ | 5199 | /* Fix illegal SG+CSUM combinations. */ |
5198 | if ((features & NETIF_F_SG) && | 5200 | if ((features & NETIF_F_SG) && |
5199 | !(features & NETIF_F_ALL_CSUM)) { | 5201 | !(features & NETIF_F_ALL_CSUM)) { |
5200 | netdev_info(dev, | 5202 | netdev_dbg(dev, |
5201 | "Dropping NETIF_F_SG since no checksum feature.\n"); | 5203 | "Dropping NETIF_F_SG since no checksum feature.\n"); |
5202 | features &= ~NETIF_F_SG; | 5204 | features &= ~NETIF_F_SG; |
5203 | } | 5205 | } |
5204 | 5206 | ||
5205 | /* TSO requires that SG is present as well. */ | 5207 | /* TSO requires that SG is present as well. */ |
5206 | if ((features & NETIF_F_ALL_TSO) && !(features & NETIF_F_SG)) { | 5208 | if ((features & NETIF_F_ALL_TSO) && !(features & NETIF_F_SG)) { |
5207 | netdev_info(dev, "Dropping TSO features since no SG feature.\n"); | 5209 | netdev_dbg(dev, "Dropping TSO features since no SG feature.\n"); |
5208 | features &= ~NETIF_F_ALL_TSO; | 5210 | features &= ~NETIF_F_ALL_TSO; |
5209 | } | 5211 | } |
5210 | 5212 | ||
@@ -5214,7 +5216,7 @@ u32 netdev_fix_features(struct net_device *dev, u32 features) | |||
5214 | 5216 | ||
5215 | /* Software GSO depends on SG. */ | 5217 | /* Software GSO depends on SG. */ |
5216 | if ((features & NETIF_F_GSO) && !(features & NETIF_F_SG)) { | 5218 | if ((features & NETIF_F_GSO) && !(features & NETIF_F_SG)) { |
5217 | netdev_info(dev, "Dropping NETIF_F_GSO since no SG feature.\n"); | 5219 | netdev_dbg(dev, "Dropping NETIF_F_GSO since no SG feature.\n"); |
5218 | features &= ~NETIF_F_GSO; | 5220 | features &= ~NETIF_F_GSO; |
5219 | } | 5221 | } |
5220 | 5222 | ||
@@ -5224,13 +5226,13 @@ u32 netdev_fix_features(struct net_device *dev, u32 features) | |||
5224 | if (!((features & NETIF_F_GEN_CSUM) || | 5226 | if (!((features & NETIF_F_GEN_CSUM) || |
5225 | (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) | 5227 | (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) |
5226 | == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { | 5228 | == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { |
5227 | netdev_info(dev, | 5229 | netdev_dbg(dev, |
5228 | "Dropping NETIF_F_UFO since no checksum offload features.\n"); | 5230 | "Dropping NETIF_F_UFO since no checksum offload features.\n"); |
5229 | features &= ~NETIF_F_UFO; | 5231 | features &= ~NETIF_F_UFO; |
5230 | } | 5232 | } |
5231 | 5233 | ||
5232 | if (!(features & NETIF_F_SG)) { | 5234 | if (!(features & NETIF_F_SG)) { |
5233 | netdev_info(dev, | 5235 | netdev_dbg(dev, |
5234 | "Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n"); | 5236 | "Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n"); |
5235 | features &= ~NETIF_F_UFO; | 5237 | features &= ~NETIF_F_UFO; |
5236 | } | 5238 | } |
@@ -5412,12 +5414,6 @@ int register_netdevice(struct net_device *dev) | |||
5412 | dev->features |= NETIF_F_SOFT_FEATURES; | 5414 | dev->features |= NETIF_F_SOFT_FEATURES; |
5413 | dev->wanted_features = dev->features & dev->hw_features; | 5415 | dev->wanted_features = dev->features & dev->hw_features; |
5414 | 5416 | ||
5415 | /* Avoid warning from netdev_fix_features() for GSO without SG */ | ||
5416 | if (!(dev->wanted_features & NETIF_F_SG)) { | ||
5417 | dev->wanted_features &= ~NETIF_F_GSO; | ||
5418 | dev->features &= ~NETIF_F_GSO; | ||
5419 | } | ||
5420 | |||
5421 | /* Enable GRO and NETIF_F_HIGHDMA for vlans by default, | 5417 | /* Enable GRO and NETIF_F_HIGHDMA for vlans by default, |
5422 | * vlan_dev_init() will do the dev->features check, so these features | 5418 | * vlan_dev_init() will do the dev->features check, so these features |
5423 | * are enabled only if supported by underlying device. | 5419 | * are enabled only if supported by underlying device. |
diff --git a/net/dccp/options.c b/net/dccp/options.c index f06ffcfc8d7..4b2ab657ac8 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c | |||
@@ -123,6 +123,8 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq, | |||
123 | case DCCPO_CHANGE_L ... DCCPO_CONFIRM_R: | 123 | case DCCPO_CHANGE_L ... DCCPO_CONFIRM_R: |
124 | if (pkt_type == DCCP_PKT_DATA) /* RFC 4340, 6 */ | 124 | if (pkt_type == DCCP_PKT_DATA) /* RFC 4340, 6 */ |
125 | break; | 125 | break; |
126 | if (len == 0) | ||
127 | goto out_invalid_option; | ||
126 | rc = dccp_feat_parse_options(sk, dreq, mandatory, opt, | 128 | rc = dccp_feat_parse_options(sk, dreq, mandatory, opt, |
127 | *value, value + 1, len - 1); | 129 | *value, value + 1, len - 1); |
128 | if (rc) | 130 | if (rc) |
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig index 87bb5f4de0e..c53ded2a98d 100644 --- a/net/dsa/Kconfig +++ b/net/dsa/Kconfig | |||
@@ -41,12 +41,12 @@ config NET_DSA_MV88E6XXX_NEED_PPU | |||
41 | default n | 41 | default n |
42 | 42 | ||
43 | config NET_DSA_MV88E6131 | 43 | config NET_DSA_MV88E6131 |
44 | bool "Marvell 88E6095/6095F/6131 ethernet switch chip support" | 44 | bool "Marvell 88E6085/6095/6095F/6131 ethernet switch chip support" |
45 | select NET_DSA_MV88E6XXX | 45 | select NET_DSA_MV88E6XXX |
46 | select NET_DSA_MV88E6XXX_NEED_PPU | 46 | select NET_DSA_MV88E6XXX_NEED_PPU |
47 | select NET_DSA_TAG_DSA | 47 | select NET_DSA_TAG_DSA |
48 | ---help--- | 48 | ---help--- |
49 | This enables support for the Marvell 88E6095/6095F/6131 | 49 | This enables support for the Marvell 88E6085/6095/6095F/6131 |
50 | ethernet switch chips. | 50 | ethernet switch chips. |
51 | 51 | ||
52 | config NET_DSA_MV88E6123_61_65 | 52 | config NET_DSA_MV88E6123_61_65 |
diff --git a/net/dsa/mv88e6131.c b/net/dsa/mv88e6131.c index 3da418894ef..45f7411e90b 100644 --- a/net/dsa/mv88e6131.c +++ b/net/dsa/mv88e6131.c | |||
@@ -207,8 +207,15 @@ static int mv88e6131_setup_port(struct dsa_switch *ds, int p) | |||
207 | * mode, but do not enable forwarding of unknown unicasts. | 207 | * mode, but do not enable forwarding of unknown unicasts. |
208 | */ | 208 | */ |
209 | val = 0x0433; | 209 | val = 0x0433; |
210 | if (p == dsa_upstream_port(ds)) | 210 | if (p == dsa_upstream_port(ds)) { |
211 | val |= 0x0104; | 211 | val |= 0x0104; |
212 | /* | ||
213 | * On 6085, unknown multicast forward is controlled | ||
214 | * here rather than in Port Control 2 register. | ||
215 | */ | ||
216 | if (ps->id == ID_6085) | ||
217 | val |= 0x0008; | ||
218 | } | ||
212 | if (ds->dsa_port_mask & (1 << p)) | 219 | if (ds->dsa_port_mask & (1 << p)) |
213 | val |= 0x0100; | 220 | val |= 0x0100; |
214 | REG_WRITE(addr, 0x04, val); | 221 | REG_WRITE(addr, 0x04, val); |
@@ -251,10 +258,19 @@ static int mv88e6131_setup_port(struct dsa_switch *ds, int p) | |||
251 | * If this is the upstream port for this switch, enable | 258 | * If this is the upstream port for this switch, enable |
252 | * forwarding of unknown multicast addresses. | 259 | * forwarding of unknown multicast addresses. |
253 | */ | 260 | */ |
254 | val = 0x0080 | dsa_upstream_port(ds); | 261 | if (ps->id == ID_6085) |
255 | if (p == dsa_upstream_port(ds)) | 262 | /* |
256 | val |= 0x0040; | 263 | * on 6085, bits 3:0 are reserved, bit 6 control ARP |
257 | REG_WRITE(addr, 0x08, val); | 264 | * mirroring, and multicast forward is handled in |
265 | * Port Control register. | ||
266 | */ | ||
267 | REG_WRITE(addr, 0x08, 0x0080); | ||
268 | else { | ||
269 | val = 0x0080 | dsa_upstream_port(ds); | ||
270 | if (p == dsa_upstream_port(ds)) | ||
271 | val |= 0x0040; | ||
272 | REG_WRITE(addr, 0x08, val); | ||
273 | } | ||
258 | 274 | ||
259 | /* | 275 | /* |
260 | * Rate Control: disable ingress rate limiting. | 276 | * Rate Control: disable ingress rate limiting. |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 5345b0bee6d..cd9ca0811cf 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -1680,7 +1680,7 @@ static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf) | |||
1680 | return; | 1680 | return; |
1681 | 1681 | ||
1682 | cnf->sysctl = NULL; | 1682 | cnf->sysctl = NULL; |
1683 | unregister_sysctl_table(t->sysctl_header); | 1683 | unregister_net_sysctl_table(t->sysctl_header); |
1684 | kfree(t->dev_name); | 1684 | kfree(t->dev_name); |
1685 | kfree(t); | 1685 | kfree(t); |
1686 | } | 1686 | } |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index e9013d6c1f5..5fe9b8b41df 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -1978,9 +1978,6 @@ struct fib_table *fib_trie_table(u32 id) | |||
1978 | t = (struct trie *) tb->tb_data; | 1978 | t = (struct trie *) tb->tb_data; |
1979 | memset(t, 0, sizeof(*t)); | 1979 | memset(t, 0, sizeof(*t)); |
1980 | 1980 | ||
1981 | if (id == RT_TABLE_LOCAL) | ||
1982 | pr_info("IPv4 FIB: Using LC-trie version %s\n", VERSION); | ||
1983 | |||
1984 | return tb; | 1981 | return tb; |
1985 | } | 1982 | } |
1986 | 1983 | ||
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index a1151b8adf3..b1d282f11be 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
@@ -223,31 +223,30 @@ static void ip_expire(unsigned long arg) | |||
223 | 223 | ||
224 | if ((qp->q.last_in & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) { | 224 | if ((qp->q.last_in & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) { |
225 | struct sk_buff *head = qp->q.fragments; | 225 | struct sk_buff *head = qp->q.fragments; |
226 | const struct iphdr *iph; | ||
227 | int err; | ||
226 | 228 | ||
227 | rcu_read_lock(); | 229 | rcu_read_lock(); |
228 | head->dev = dev_get_by_index_rcu(net, qp->iif); | 230 | head->dev = dev_get_by_index_rcu(net, qp->iif); |
229 | if (!head->dev) | 231 | if (!head->dev) |
230 | goto out_rcu_unlock; | 232 | goto out_rcu_unlock; |
231 | 233 | ||
234 | /* skb dst is stale, drop it, and perform route lookup again */ | ||
235 | skb_dst_drop(head); | ||
236 | iph = ip_hdr(head); | ||
237 | err = ip_route_input_noref(head, iph->daddr, iph->saddr, | ||
238 | iph->tos, head->dev); | ||
239 | if (err) | ||
240 | goto out_rcu_unlock; | ||
241 | |||
232 | /* | 242 | /* |
233 | * Only search router table for the head fragment, | 243 | * Only an end host needs to send an ICMP |
234 | * when defraging timeout at PRE_ROUTING HOOK. | 244 | * "Fragment Reassembly Timeout" message, per RFC792. |
235 | */ | 245 | */ |
236 | if (qp->user == IP_DEFRAG_CONNTRACK_IN && !skb_dst(head)) { | 246 | if (qp->user == IP_DEFRAG_CONNTRACK_IN && |
237 | const struct iphdr *iph = ip_hdr(head); | 247 | skb_rtable(head)->rt_type != RTN_LOCAL) |
238 | int err = ip_route_input(head, iph->daddr, iph->saddr, | 248 | goto out_rcu_unlock; |
239 | iph->tos, head->dev); | ||
240 | if (unlikely(err)) | ||
241 | goto out_rcu_unlock; | ||
242 | |||
243 | /* | ||
244 | * Only an end host needs to send an ICMP | ||
245 | * "Fragment Reassembly Timeout" message, per RFC792. | ||
246 | */ | ||
247 | if (skb_rtable(head)->rt_type != RTN_LOCAL) | ||
248 | goto out_rcu_unlock; | ||
249 | 249 | ||
250 | } | ||
251 | 250 | ||
252 | /* Send an ICMP "Fragment Reassembly Timeout" message. */ | 251 | /* Send an ICMP "Fragment Reassembly Timeout" message. */ |
253 | icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); | 252 | icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index c1acf69858f..99e6e4bb1c7 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2690,6 +2690,12 @@ static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
2690 | { | 2690 | { |
2691 | } | 2691 | } |
2692 | 2692 | ||
2693 | static u32 *ipv4_rt_blackhole_cow_metrics(struct dst_entry *dst, | ||
2694 | unsigned long old) | ||
2695 | { | ||
2696 | return NULL; | ||
2697 | } | ||
2698 | |||
2693 | static struct dst_ops ipv4_dst_blackhole_ops = { | 2699 | static struct dst_ops ipv4_dst_blackhole_ops = { |
2694 | .family = AF_INET, | 2700 | .family = AF_INET, |
2695 | .protocol = cpu_to_be16(ETH_P_IP), | 2701 | .protocol = cpu_to_be16(ETH_P_IP), |
@@ -2698,6 +2704,7 @@ static struct dst_ops ipv4_dst_blackhole_ops = { | |||
2698 | .default_mtu = ipv4_blackhole_default_mtu, | 2704 | .default_mtu = ipv4_blackhole_default_mtu, |
2699 | .default_advmss = ipv4_default_advmss, | 2705 | .default_advmss = ipv4_default_advmss, |
2700 | .update_pmtu = ipv4_rt_blackhole_update_pmtu, | 2706 | .update_pmtu = ipv4_rt_blackhole_update_pmtu, |
2707 | .cow_metrics = ipv4_rt_blackhole_cow_metrics, | ||
2701 | }; | 2708 | }; |
2702 | 2709 | ||
2703 | struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_orig) | 2710 | struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_orig) |
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index 34340c9c95f..f376b05cca8 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c | |||
@@ -93,6 +93,7 @@ struct bictcp { | |||
93 | u32 ack_cnt; /* number of acks */ | 93 | u32 ack_cnt; /* number of acks */ |
94 | u32 tcp_cwnd; /* estimated tcp cwnd */ | 94 | u32 tcp_cwnd; /* estimated tcp cwnd */ |
95 | #define ACK_RATIO_SHIFT 4 | 95 | #define ACK_RATIO_SHIFT 4 |
96 | #define ACK_RATIO_LIMIT (32u << ACK_RATIO_SHIFT) | ||
96 | u16 delayed_ack; /* estimate the ratio of Packets/ACKs << 4 */ | 97 | u16 delayed_ack; /* estimate the ratio of Packets/ACKs << 4 */ |
97 | u8 sample_cnt; /* number of samples to decide curr_rtt */ | 98 | u8 sample_cnt; /* number of samples to decide curr_rtt */ |
98 | u8 found; /* the exit point is found? */ | 99 | u8 found; /* the exit point is found? */ |
@@ -398,8 +399,12 @@ static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us) | |||
398 | u32 delay; | 399 | u32 delay; |
399 | 400 | ||
400 | if (icsk->icsk_ca_state == TCP_CA_Open) { | 401 | if (icsk->icsk_ca_state == TCP_CA_Open) { |
401 | cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT; | 402 | u32 ratio = ca->delayed_ack; |
402 | ca->delayed_ack += cnt; | 403 | |
404 | ratio -= ca->delayed_ack >> ACK_RATIO_SHIFT; | ||
405 | ratio += cnt; | ||
406 | |||
407 | ca->delayed_ack = min(ratio, ACK_RATIO_LIMIT); | ||
403 | } | 408 | } |
404 | 409 | ||
405 | /* Some calls are for duplicates without timetamps */ | 410 | /* Some calls are for duplicates without timetamps */ |
diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c index 571aa96a175..2d51840e53a 100644 --- a/net/ipv4/xfrm4_output.c +++ b/net/ipv4/xfrm4_output.c | |||
@@ -69,7 +69,7 @@ int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb) | |||
69 | } | 69 | } |
70 | EXPORT_SYMBOL(xfrm4_prepare_output); | 70 | EXPORT_SYMBOL(xfrm4_prepare_output); |
71 | 71 | ||
72 | static int xfrm4_output_finish(struct sk_buff *skb) | 72 | int xfrm4_output_finish(struct sk_buff *skb) |
73 | { | 73 | { |
74 | #ifdef CONFIG_NETFILTER | 74 | #ifdef CONFIG_NETFILTER |
75 | if (!skb_dst(skb)->xfrm) { | 75 | if (!skb_dst(skb)->xfrm) { |
@@ -86,7 +86,11 @@ static int xfrm4_output_finish(struct sk_buff *skb) | |||
86 | 86 | ||
87 | int xfrm4_output(struct sk_buff *skb) | 87 | int xfrm4_output(struct sk_buff *skb) |
88 | { | 88 | { |
89 | struct dst_entry *dst = skb_dst(skb); | ||
90 | struct xfrm_state *x = dst->xfrm; | ||
91 | |||
89 | return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, skb, | 92 | return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, skb, |
90 | NULL, skb_dst(skb)->dev, xfrm4_output_finish, | 93 | NULL, dst->dev, |
94 | x->outer_mode->afinfo->output_finish, | ||
91 | !(IPCB(skb)->flags & IPSKB_REROUTED)); | 95 | !(IPCB(skb)->flags & IPSKB_REROUTED)); |
92 | } | 96 | } |
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c index 1717c64628d..805d63ef434 100644 --- a/net/ipv4/xfrm4_state.c +++ b/net/ipv4/xfrm4_state.c | |||
@@ -78,6 +78,7 @@ static struct xfrm_state_afinfo xfrm4_state_afinfo = { | |||
78 | .init_tempsel = __xfrm4_init_tempsel, | 78 | .init_tempsel = __xfrm4_init_tempsel, |
79 | .init_temprop = xfrm4_init_temprop, | 79 | .init_temprop = xfrm4_init_temprop, |
80 | .output = xfrm4_output, | 80 | .output = xfrm4_output, |
81 | .output_finish = xfrm4_output_finish, | ||
81 | .extract_input = xfrm4_extract_input, | 82 | .extract_input = xfrm4_extract_input, |
82 | .extract_output = xfrm4_extract_output, | 83 | .extract_output = xfrm4_extract_output, |
83 | .transport_finish = xfrm4_transport_finish, | 84 | .transport_finish = xfrm4_transport_finish, |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 1493534116d..a7bda075705 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -4537,7 +4537,7 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p) | |||
4537 | 4537 | ||
4538 | t = p->sysctl; | 4538 | t = p->sysctl; |
4539 | p->sysctl = NULL; | 4539 | p->sysctl = NULL; |
4540 | unregister_sysctl_table(t->sysctl_header); | 4540 | unregister_net_sysctl_table(t->sysctl_header); |
4541 | kfree(t->dev_name); | 4541 | kfree(t->dev_name); |
4542 | kfree(t); | 4542 | kfree(t); |
4543 | } | 4543 | } |
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index 5aa8ec88f19..59dccfbb5b1 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c | |||
@@ -371,7 +371,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
371 | iv = esp_tmp_iv(aead, tmp, seqhilen); | 371 | iv = esp_tmp_iv(aead, tmp, seqhilen); |
372 | req = esp_tmp_req(aead, iv); | 372 | req = esp_tmp_req(aead, iv); |
373 | asg = esp_req_sg(aead, req); | 373 | asg = esp_req_sg(aead, req); |
374 | sg = asg + 1; | 374 | sg = asg + sglists; |
375 | 375 | ||
376 | skb->ip_summed = CHECKSUM_NONE; | 376 | skb->ip_summed = CHECKSUM_NONE; |
377 | 377 | ||
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index 28e74488a32..a5a4c5dd539 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c | |||
@@ -45,6 +45,8 @@ static void send_reset(struct net *net, struct sk_buff *oldskb) | |||
45 | int tcphoff, needs_ack; | 45 | int tcphoff, needs_ack; |
46 | const struct ipv6hdr *oip6h = ipv6_hdr(oldskb); | 46 | const struct ipv6hdr *oip6h = ipv6_hdr(oldskb); |
47 | struct ipv6hdr *ip6h; | 47 | struct ipv6hdr *ip6h; |
48 | #define DEFAULT_TOS_VALUE 0x0U | ||
49 | const __u8 tclass = DEFAULT_TOS_VALUE; | ||
48 | struct dst_entry *dst = NULL; | 50 | struct dst_entry *dst = NULL; |
49 | u8 proto; | 51 | u8 proto; |
50 | struct flowi6 fl6; | 52 | struct flowi6 fl6; |
@@ -124,7 +126,7 @@ static void send_reset(struct net *net, struct sk_buff *oldskb) | |||
124 | skb_put(nskb, sizeof(struct ipv6hdr)); | 126 | skb_put(nskb, sizeof(struct ipv6hdr)); |
125 | skb_reset_network_header(nskb); | 127 | skb_reset_network_header(nskb); |
126 | ip6h = ipv6_hdr(nskb); | 128 | ip6h = ipv6_hdr(nskb); |
127 | ip6h->version = 6; | 129 | *(__be32 *)ip6h = htonl(0x60000000 | (tclass << 20)); |
128 | ip6h->hop_limit = ip6_dst_hoplimit(dst); | 130 | ip6h->hop_limit = ip6_dst_hoplimit(dst); |
129 | ip6h->nexthdr = IPPROTO_TCP; | 131 | ip6h->nexthdr = IPPROTO_TCP; |
130 | ipv6_addr_copy(&ip6h->saddr, &oip6h->daddr); | 132 | ipv6_addr_copy(&ip6h->saddr, &oip6h->daddr); |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 843406f14d7..fd0eec6f88c 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -153,6 +153,12 @@ static void ip6_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
153 | { | 153 | { |
154 | } | 154 | } |
155 | 155 | ||
156 | static u32 *ip6_rt_blackhole_cow_metrics(struct dst_entry *dst, | ||
157 | unsigned long old) | ||
158 | { | ||
159 | return NULL; | ||
160 | } | ||
161 | |||
156 | static struct dst_ops ip6_dst_blackhole_ops = { | 162 | static struct dst_ops ip6_dst_blackhole_ops = { |
157 | .family = AF_INET6, | 163 | .family = AF_INET6, |
158 | .protocol = cpu_to_be16(ETH_P_IPV6), | 164 | .protocol = cpu_to_be16(ETH_P_IPV6), |
@@ -161,6 +167,7 @@ static struct dst_ops ip6_dst_blackhole_ops = { | |||
161 | .default_mtu = ip6_blackhole_default_mtu, | 167 | .default_mtu = ip6_blackhole_default_mtu, |
162 | .default_advmss = ip6_default_advmss, | 168 | .default_advmss = ip6_default_advmss, |
163 | .update_pmtu = ip6_rt_blackhole_update_pmtu, | 169 | .update_pmtu = ip6_rt_blackhole_update_pmtu, |
170 | .cow_metrics = ip6_rt_blackhole_cow_metrics, | ||
164 | }; | 171 | }; |
165 | 172 | ||
166 | static const u32 ip6_template_metrics[RTAX_MAX] = { | 173 | static const u32 ip6_template_metrics[RTAX_MAX] = { |
@@ -2012,7 +2019,6 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
2012 | rt->dst.output = ip6_output; | 2019 | rt->dst.output = ip6_output; |
2013 | rt->rt6i_dev = net->loopback_dev; | 2020 | rt->rt6i_dev = net->loopback_dev; |
2014 | rt->rt6i_idev = idev; | 2021 | rt->rt6i_idev = idev; |
2015 | dst_metric_set(&rt->dst, RTAX_HOPLIMIT, -1); | ||
2016 | rt->dst.obsolete = -1; | 2022 | rt->dst.obsolete = -1; |
2017 | 2023 | ||
2018 | rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP; | 2024 | rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP; |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 15c37746845..9e305d74b3d 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -1335,7 +1335,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, u32 features) | |||
1335 | skb->ip_summed = CHECKSUM_NONE; | 1335 | skb->ip_summed = CHECKSUM_NONE; |
1336 | 1336 | ||
1337 | /* Check if there is enough headroom to insert fragment header. */ | 1337 | /* Check if there is enough headroom to insert fragment header. */ |
1338 | if ((skb_headroom(skb) < frag_hdr_sz) && | 1338 | if ((skb_mac_header(skb) < skb->head + frag_hdr_sz) && |
1339 | pskb_expand_head(skb, frag_hdr_sz, 0, GFP_ATOMIC)) | 1339 | pskb_expand_head(skb, frag_hdr_sz, 0, GFP_ATOMIC)) |
1340 | goto out; | 1340 | goto out; |
1341 | 1341 | ||
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c index 8e688b3de9a..49a91c5f562 100644 --- a/net/ipv6/xfrm6_output.c +++ b/net/ipv6/xfrm6_output.c | |||
@@ -79,7 +79,7 @@ int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb) | |||
79 | } | 79 | } |
80 | EXPORT_SYMBOL(xfrm6_prepare_output); | 80 | EXPORT_SYMBOL(xfrm6_prepare_output); |
81 | 81 | ||
82 | static int xfrm6_output_finish(struct sk_buff *skb) | 82 | int xfrm6_output_finish(struct sk_buff *skb) |
83 | { | 83 | { |
84 | #ifdef CONFIG_NETFILTER | 84 | #ifdef CONFIG_NETFILTER |
85 | IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED; | 85 | IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED; |
@@ -97,9 +97,9 @@ static int __xfrm6_output(struct sk_buff *skb) | |||
97 | if ((x && x->props.mode == XFRM_MODE_TUNNEL) && | 97 | if ((x && x->props.mode == XFRM_MODE_TUNNEL) && |
98 | ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || | 98 | ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || |
99 | dst_allfrag(skb_dst(skb)))) { | 99 | dst_allfrag(skb_dst(skb)))) { |
100 | return ip6_fragment(skb, xfrm6_output_finish); | 100 | return ip6_fragment(skb, x->outer_mode->afinfo->output_finish); |
101 | } | 101 | } |
102 | return xfrm6_output_finish(skb); | 102 | return x->outer_mode->afinfo->output_finish(skb); |
103 | } | 103 | } |
104 | 104 | ||
105 | int xfrm6_output(struct sk_buff *skb) | 105 | int xfrm6_output(struct sk_buff *skb) |
diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c index afe941e9415..248f0b2a7ee 100644 --- a/net/ipv6/xfrm6_state.c +++ b/net/ipv6/xfrm6_state.c | |||
@@ -178,6 +178,7 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = { | |||
178 | .tmpl_sort = __xfrm6_tmpl_sort, | 178 | .tmpl_sort = __xfrm6_tmpl_sort, |
179 | .state_sort = __xfrm6_state_sort, | 179 | .state_sort = __xfrm6_state_sort, |
180 | .output = xfrm6_output, | 180 | .output = xfrm6_output, |
181 | .output_finish = xfrm6_output_finish, | ||
181 | .extract_input = xfrm6_extract_input, | 182 | .extract_input = xfrm6_extract_input, |
182 | .extract_output = xfrm6_extract_output, | 183 | .extract_output = xfrm6_extract_output, |
183 | .transport_finish = xfrm6_transport_finish, | 184 | .transport_finish = xfrm6_transport_finish, |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 334213571ad..44049733c4e 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -1504,6 +1504,8 @@ int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, | |||
1504 | enum ieee80211_smps_mode old_req; | 1504 | enum ieee80211_smps_mode old_req; |
1505 | int err; | 1505 | int err; |
1506 | 1506 | ||
1507 | lockdep_assert_held(&sdata->u.mgd.mtx); | ||
1508 | |||
1507 | old_req = sdata->u.mgd.req_smps; | 1509 | old_req = sdata->u.mgd.req_smps; |
1508 | sdata->u.mgd.req_smps = smps_mode; | 1510 | sdata->u.mgd.req_smps = smps_mode; |
1509 | 1511 | ||
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index dacace6b139..9ea7c0d0103 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c | |||
@@ -177,9 +177,9 @@ static int ieee80211_set_smps(struct ieee80211_sub_if_data *sdata, | |||
177 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | 177 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
178 | return -EOPNOTSUPP; | 178 | return -EOPNOTSUPP; |
179 | 179 | ||
180 | mutex_lock(&local->iflist_mtx); | 180 | mutex_lock(&sdata->u.mgd.mtx); |
181 | err = __ieee80211_request_smps(sdata, smps_mode); | 181 | err = __ieee80211_request_smps(sdata, smps_mode); |
182 | mutex_unlock(&local->iflist_mtx); | 182 | mutex_unlock(&sdata->u.mgd.mtx); |
183 | 183 | ||
184 | return err; | 184 | return err; |
185 | } | 185 | } |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index ce4596ed126..bd1224fd216 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -237,6 +237,10 @@ ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx) | |||
237 | &local->dynamic_ps_disable_work); | 237 | &local->dynamic_ps_disable_work); |
238 | } | 238 | } |
239 | 239 | ||
240 | /* Don't restart the timer if we're not disassociated */ | ||
241 | if (!ifmgd->associated) | ||
242 | return TX_CONTINUE; | ||
243 | |||
240 | mod_timer(&local->dynamic_ps_timer, jiffies + | 244 | mod_timer(&local->dynamic_ps_timer, jiffies + |
241 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); | 245 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); |
242 | 246 | ||
diff --git a/net/netfilter/ipvs/ip_vs_app.c b/net/netfilter/ipvs/ip_vs_app.c index 2dc6de13ac1..059af3120be 100644 --- a/net/netfilter/ipvs/ip_vs_app.c +++ b/net/netfilter/ipvs/ip_vs_app.c | |||
@@ -572,11 +572,11 @@ static const struct file_operations ip_vs_app_fops = { | |||
572 | .open = ip_vs_app_open, | 572 | .open = ip_vs_app_open, |
573 | .read = seq_read, | 573 | .read = seq_read, |
574 | .llseek = seq_lseek, | 574 | .llseek = seq_lseek, |
575 | .release = seq_release, | 575 | .release = seq_release_net, |
576 | }; | 576 | }; |
577 | #endif | 577 | #endif |
578 | 578 | ||
579 | static int __net_init __ip_vs_app_init(struct net *net) | 579 | int __net_init __ip_vs_app_init(struct net *net) |
580 | { | 580 | { |
581 | struct netns_ipvs *ipvs = net_ipvs(net); | 581 | struct netns_ipvs *ipvs = net_ipvs(net); |
582 | 582 | ||
@@ -585,26 +585,17 @@ static int __net_init __ip_vs_app_init(struct net *net) | |||
585 | return 0; | 585 | return 0; |
586 | } | 586 | } |
587 | 587 | ||
588 | static void __net_exit __ip_vs_app_cleanup(struct net *net) | 588 | void __net_exit __ip_vs_app_cleanup(struct net *net) |
589 | { | 589 | { |
590 | proc_net_remove(net, "ip_vs_app"); | 590 | proc_net_remove(net, "ip_vs_app"); |
591 | } | 591 | } |
592 | 592 | ||
593 | static struct pernet_operations ip_vs_app_ops = { | ||
594 | .init = __ip_vs_app_init, | ||
595 | .exit = __ip_vs_app_cleanup, | ||
596 | }; | ||
597 | |||
598 | int __init ip_vs_app_init(void) | 593 | int __init ip_vs_app_init(void) |
599 | { | 594 | { |
600 | int rv; | 595 | return 0; |
601 | |||
602 | rv = register_pernet_subsys(&ip_vs_app_ops); | ||
603 | return rv; | ||
604 | } | 596 | } |
605 | 597 | ||
606 | 598 | ||
607 | void ip_vs_app_cleanup(void) | 599 | void ip_vs_app_cleanup(void) |
608 | { | 600 | { |
609 | unregister_pernet_subsys(&ip_vs_app_ops); | ||
610 | } | 601 | } |
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index c97bd45975b..bf28ac2fc99 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c | |||
@@ -1046,7 +1046,7 @@ static const struct file_operations ip_vs_conn_fops = { | |||
1046 | .open = ip_vs_conn_open, | 1046 | .open = ip_vs_conn_open, |
1047 | .read = seq_read, | 1047 | .read = seq_read, |
1048 | .llseek = seq_lseek, | 1048 | .llseek = seq_lseek, |
1049 | .release = seq_release, | 1049 | .release = seq_release_net, |
1050 | }; | 1050 | }; |
1051 | 1051 | ||
1052 | static const char *ip_vs_origin_name(unsigned flags) | 1052 | static const char *ip_vs_origin_name(unsigned flags) |
@@ -1114,7 +1114,7 @@ static const struct file_operations ip_vs_conn_sync_fops = { | |||
1114 | .open = ip_vs_conn_sync_open, | 1114 | .open = ip_vs_conn_sync_open, |
1115 | .read = seq_read, | 1115 | .read = seq_read, |
1116 | .llseek = seq_lseek, | 1116 | .llseek = seq_lseek, |
1117 | .release = seq_release, | 1117 | .release = seq_release_net, |
1118 | }; | 1118 | }; |
1119 | 1119 | ||
1120 | #endif | 1120 | #endif |
@@ -1258,22 +1258,17 @@ int __net_init __ip_vs_conn_init(struct net *net) | |||
1258 | return 0; | 1258 | return 0; |
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | static void __net_exit __ip_vs_conn_cleanup(struct net *net) | 1261 | void __net_exit __ip_vs_conn_cleanup(struct net *net) |
1262 | { | 1262 | { |
1263 | /* flush all the connection entries first */ | 1263 | /* flush all the connection entries first */ |
1264 | ip_vs_conn_flush(net); | 1264 | ip_vs_conn_flush(net); |
1265 | proc_net_remove(net, "ip_vs_conn"); | 1265 | proc_net_remove(net, "ip_vs_conn"); |
1266 | proc_net_remove(net, "ip_vs_conn_sync"); | 1266 | proc_net_remove(net, "ip_vs_conn_sync"); |
1267 | } | 1267 | } |
1268 | static struct pernet_operations ipvs_conn_ops = { | ||
1269 | .init = __ip_vs_conn_init, | ||
1270 | .exit = __ip_vs_conn_cleanup, | ||
1271 | }; | ||
1272 | 1268 | ||
1273 | int __init ip_vs_conn_init(void) | 1269 | int __init ip_vs_conn_init(void) |
1274 | { | 1270 | { |
1275 | int idx; | 1271 | int idx; |
1276 | int retc; | ||
1277 | 1272 | ||
1278 | /* Compute size and mask */ | 1273 | /* Compute size and mask */ |
1279 | ip_vs_conn_tab_size = 1 << ip_vs_conn_tab_bits; | 1274 | ip_vs_conn_tab_size = 1 << ip_vs_conn_tab_bits; |
@@ -1309,17 +1304,14 @@ int __init ip_vs_conn_init(void) | |||
1309 | rwlock_init(&__ip_vs_conntbl_lock_array[idx].l); | 1304 | rwlock_init(&__ip_vs_conntbl_lock_array[idx].l); |
1310 | } | 1305 | } |
1311 | 1306 | ||
1312 | retc = register_pernet_subsys(&ipvs_conn_ops); | ||
1313 | |||
1314 | /* calculate the random value for connection hash */ | 1307 | /* calculate the random value for connection hash */ |
1315 | get_random_bytes(&ip_vs_conn_rnd, sizeof(ip_vs_conn_rnd)); | 1308 | get_random_bytes(&ip_vs_conn_rnd, sizeof(ip_vs_conn_rnd)); |
1316 | 1309 | ||
1317 | return retc; | 1310 | return 0; |
1318 | } | 1311 | } |
1319 | 1312 | ||
1320 | void ip_vs_conn_cleanup(void) | 1313 | void ip_vs_conn_cleanup(void) |
1321 | { | 1314 | { |
1322 | unregister_pernet_subsys(&ipvs_conn_ops); | ||
1323 | /* Release the empty cache */ | 1315 | /* Release the empty cache */ |
1324 | kmem_cache_destroy(ip_vs_conn_cachep); | 1316 | kmem_cache_destroy(ip_vs_conn_cachep); |
1325 | vfree(ip_vs_conn_tab); | 1317 | vfree(ip_vs_conn_tab); |
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c index 07accf6b240..a74dae6c5db 100644 --- a/net/netfilter/ipvs/ip_vs_core.c +++ b/net/netfilter/ipvs/ip_vs_core.c | |||
@@ -1113,6 +1113,9 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb, int af) | |||
1113 | return NF_ACCEPT; | 1113 | return NF_ACCEPT; |
1114 | 1114 | ||
1115 | net = skb_net(skb); | 1115 | net = skb_net(skb); |
1116 | if (!net_ipvs(net)->enable) | ||
1117 | return NF_ACCEPT; | ||
1118 | |||
1116 | ip_vs_fill_iphdr(af, skb_network_header(skb), &iph); | 1119 | ip_vs_fill_iphdr(af, skb_network_header(skb), &iph); |
1117 | #ifdef CONFIG_IP_VS_IPV6 | 1120 | #ifdef CONFIG_IP_VS_IPV6 |
1118 | if (af == AF_INET6) { | 1121 | if (af == AF_INET6) { |
@@ -1343,6 +1346,7 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum) | |||
1343 | return NF_ACCEPT; /* The packet looks wrong, ignore */ | 1346 | return NF_ACCEPT; /* The packet looks wrong, ignore */ |
1344 | 1347 | ||
1345 | net = skb_net(skb); | 1348 | net = skb_net(skb); |
1349 | |||
1346 | pd = ip_vs_proto_data_get(net, cih->protocol); | 1350 | pd = ip_vs_proto_data_get(net, cih->protocol); |
1347 | if (!pd) | 1351 | if (!pd) |
1348 | return NF_ACCEPT; | 1352 | return NF_ACCEPT; |
@@ -1529,6 +1533,11 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af) | |||
1529 | IP_VS_DBG_ADDR(af, &iph.daddr), hooknum); | 1533 | IP_VS_DBG_ADDR(af, &iph.daddr), hooknum); |
1530 | return NF_ACCEPT; | 1534 | return NF_ACCEPT; |
1531 | } | 1535 | } |
1536 | /* ipvs enabled in this netns ? */ | ||
1537 | net = skb_net(skb); | ||
1538 | if (!net_ipvs(net)->enable) | ||
1539 | return NF_ACCEPT; | ||
1540 | |||
1532 | ip_vs_fill_iphdr(af, skb_network_header(skb), &iph); | 1541 | ip_vs_fill_iphdr(af, skb_network_header(skb), &iph); |
1533 | 1542 | ||
1534 | /* Bad... Do not break raw sockets */ | 1543 | /* Bad... Do not break raw sockets */ |
@@ -1562,7 +1571,6 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af) | |||
1562 | ip_vs_fill_iphdr(af, skb_network_header(skb), &iph); | 1571 | ip_vs_fill_iphdr(af, skb_network_header(skb), &iph); |
1563 | } | 1572 | } |
1564 | 1573 | ||
1565 | net = skb_net(skb); | ||
1566 | /* Protocol supported? */ | 1574 | /* Protocol supported? */ |
1567 | pd = ip_vs_proto_data_get(net, iph.protocol); | 1575 | pd = ip_vs_proto_data_get(net, iph.protocol); |
1568 | if (unlikely(!pd)) | 1576 | if (unlikely(!pd)) |
@@ -1588,7 +1596,6 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af) | |||
1588 | } | 1596 | } |
1589 | 1597 | ||
1590 | IP_VS_DBG_PKT(11, af, pp, skb, 0, "Incoming packet"); | 1598 | IP_VS_DBG_PKT(11, af, pp, skb, 0, "Incoming packet"); |
1591 | net = skb_net(skb); | ||
1592 | ipvs = net_ipvs(net); | 1599 | ipvs = net_ipvs(net); |
1593 | /* Check the server status */ | 1600 | /* Check the server status */ |
1594 | if (cp->dest && !(cp->dest->flags & IP_VS_DEST_F_AVAILABLE)) { | 1601 | if (cp->dest && !(cp->dest->flags & IP_VS_DEST_F_AVAILABLE)) { |
@@ -1743,10 +1750,16 @@ ip_vs_forward_icmp(unsigned int hooknum, struct sk_buff *skb, | |||
1743 | int (*okfn)(struct sk_buff *)) | 1750 | int (*okfn)(struct sk_buff *)) |
1744 | { | 1751 | { |
1745 | int r; | 1752 | int r; |
1753 | struct net *net; | ||
1746 | 1754 | ||
1747 | if (ip_hdr(skb)->protocol != IPPROTO_ICMP) | 1755 | if (ip_hdr(skb)->protocol != IPPROTO_ICMP) |
1748 | return NF_ACCEPT; | 1756 | return NF_ACCEPT; |
1749 | 1757 | ||
1758 | /* ipvs enabled in this netns ? */ | ||
1759 | net = skb_net(skb); | ||
1760 | if (!net_ipvs(net)->enable) | ||
1761 | return NF_ACCEPT; | ||
1762 | |||
1750 | return ip_vs_in_icmp(skb, &r, hooknum); | 1763 | return ip_vs_in_icmp(skb, &r, hooknum); |
1751 | } | 1764 | } |
1752 | 1765 | ||
@@ -1757,10 +1770,16 @@ ip_vs_forward_icmp_v6(unsigned int hooknum, struct sk_buff *skb, | |||
1757 | int (*okfn)(struct sk_buff *)) | 1770 | int (*okfn)(struct sk_buff *)) |
1758 | { | 1771 | { |
1759 | int r; | 1772 | int r; |
1773 | struct net *net; | ||
1760 | 1774 | ||
1761 | if (ipv6_hdr(skb)->nexthdr != IPPROTO_ICMPV6) | 1775 | if (ipv6_hdr(skb)->nexthdr != IPPROTO_ICMPV6) |
1762 | return NF_ACCEPT; | 1776 | return NF_ACCEPT; |
1763 | 1777 | ||
1778 | /* ipvs enabled in this netns ? */ | ||
1779 | net = skb_net(skb); | ||
1780 | if (!net_ipvs(net)->enable) | ||
1781 | return NF_ACCEPT; | ||
1782 | |||
1764 | return ip_vs_in_icmp_v6(skb, &r, hooknum); | 1783 | return ip_vs_in_icmp_v6(skb, &r, hooknum); |
1765 | } | 1784 | } |
1766 | #endif | 1785 | #endif |
@@ -1884,19 +1903,70 @@ static int __net_init __ip_vs_init(struct net *net) | |||
1884 | pr_err("%s(): no memory.\n", __func__); | 1903 | pr_err("%s(): no memory.\n", __func__); |
1885 | return -ENOMEM; | 1904 | return -ENOMEM; |
1886 | } | 1905 | } |
1906 | /* Hold the beast until a service is registerd */ | ||
1907 | ipvs->enable = 0; | ||
1887 | ipvs->net = net; | 1908 | ipvs->net = net; |
1888 | /* Counters used for creating unique names */ | 1909 | /* Counters used for creating unique names */ |
1889 | ipvs->gen = atomic_read(&ipvs_netns_cnt); | 1910 | ipvs->gen = atomic_read(&ipvs_netns_cnt); |
1890 | atomic_inc(&ipvs_netns_cnt); | 1911 | atomic_inc(&ipvs_netns_cnt); |
1891 | net->ipvs = ipvs; | 1912 | net->ipvs = ipvs; |
1913 | |||
1914 | if (__ip_vs_estimator_init(net) < 0) | ||
1915 | goto estimator_fail; | ||
1916 | |||
1917 | if (__ip_vs_control_init(net) < 0) | ||
1918 | goto control_fail; | ||
1919 | |||
1920 | if (__ip_vs_protocol_init(net) < 0) | ||
1921 | goto protocol_fail; | ||
1922 | |||
1923 | if (__ip_vs_app_init(net) < 0) | ||
1924 | goto app_fail; | ||
1925 | |||
1926 | if (__ip_vs_conn_init(net) < 0) | ||
1927 | goto conn_fail; | ||
1928 | |||
1929 | if (__ip_vs_sync_init(net) < 0) | ||
1930 | goto sync_fail; | ||
1931 | |||
1892 | printk(KERN_INFO "IPVS: Creating netns size=%zu id=%d\n", | 1932 | printk(KERN_INFO "IPVS: Creating netns size=%zu id=%d\n", |
1893 | sizeof(struct netns_ipvs), ipvs->gen); | 1933 | sizeof(struct netns_ipvs), ipvs->gen); |
1894 | return 0; | 1934 | return 0; |
1935 | /* | ||
1936 | * Error handling | ||
1937 | */ | ||
1938 | |||
1939 | sync_fail: | ||
1940 | __ip_vs_conn_cleanup(net); | ||
1941 | conn_fail: | ||
1942 | __ip_vs_app_cleanup(net); | ||
1943 | app_fail: | ||
1944 | __ip_vs_protocol_cleanup(net); | ||
1945 | protocol_fail: | ||
1946 | __ip_vs_control_cleanup(net); | ||
1947 | control_fail: | ||
1948 | __ip_vs_estimator_cleanup(net); | ||
1949 | estimator_fail: | ||
1950 | return -ENOMEM; | ||
1895 | } | 1951 | } |
1896 | 1952 | ||
1897 | static void __net_exit __ip_vs_cleanup(struct net *net) | 1953 | static void __net_exit __ip_vs_cleanup(struct net *net) |
1898 | { | 1954 | { |
1899 | IP_VS_DBG(10, "ipvs netns %d released\n", net_ipvs(net)->gen); | 1955 | __ip_vs_service_cleanup(net); /* ip_vs_flush() with locks */ |
1956 | __ip_vs_conn_cleanup(net); | ||
1957 | __ip_vs_app_cleanup(net); | ||
1958 | __ip_vs_protocol_cleanup(net); | ||
1959 | __ip_vs_control_cleanup(net); | ||
1960 | __ip_vs_estimator_cleanup(net); | ||
1961 | IP_VS_DBG(2, "ipvs netns %d released\n", net_ipvs(net)->gen); | ||
1962 | } | ||
1963 | |||
1964 | static void __net_exit __ip_vs_dev_cleanup(struct net *net) | ||
1965 | { | ||
1966 | EnterFunction(2); | ||
1967 | net_ipvs(net)->enable = 0; /* Disable packet reception */ | ||
1968 | __ip_vs_sync_cleanup(net); | ||
1969 | LeaveFunction(2); | ||
1900 | } | 1970 | } |
1901 | 1971 | ||
1902 | static struct pernet_operations ipvs_core_ops = { | 1972 | static struct pernet_operations ipvs_core_ops = { |
@@ -1906,6 +1976,10 @@ static struct pernet_operations ipvs_core_ops = { | |||
1906 | .size = sizeof(struct netns_ipvs), | 1976 | .size = sizeof(struct netns_ipvs), |
1907 | }; | 1977 | }; |
1908 | 1978 | ||
1979 | static struct pernet_operations ipvs_core_dev_ops = { | ||
1980 | .exit = __ip_vs_dev_cleanup, | ||
1981 | }; | ||
1982 | |||
1909 | /* | 1983 | /* |
1910 | * Initialize IP Virtual Server | 1984 | * Initialize IP Virtual Server |
1911 | */ | 1985 | */ |
@@ -1913,10 +1987,6 @@ static int __init ip_vs_init(void) | |||
1913 | { | 1987 | { |
1914 | int ret; | 1988 | int ret; |
1915 | 1989 | ||
1916 | ret = register_pernet_subsys(&ipvs_core_ops); /* Alloc ip_vs struct */ | ||
1917 | if (ret < 0) | ||
1918 | return ret; | ||
1919 | |||
1920 | ip_vs_estimator_init(); | 1990 | ip_vs_estimator_init(); |
1921 | ret = ip_vs_control_init(); | 1991 | ret = ip_vs_control_init(); |
1922 | if (ret < 0) { | 1992 | if (ret < 0) { |
@@ -1944,15 +2014,28 @@ static int __init ip_vs_init(void) | |||
1944 | goto cleanup_conn; | 2014 | goto cleanup_conn; |
1945 | } | 2015 | } |
1946 | 2016 | ||
2017 | ret = register_pernet_subsys(&ipvs_core_ops); /* Alloc ip_vs struct */ | ||
2018 | if (ret < 0) | ||
2019 | goto cleanup_sync; | ||
2020 | |||
2021 | ret = register_pernet_device(&ipvs_core_dev_ops); | ||
2022 | if (ret < 0) | ||
2023 | goto cleanup_sub; | ||
2024 | |||
1947 | ret = nf_register_hooks(ip_vs_ops, ARRAY_SIZE(ip_vs_ops)); | 2025 | ret = nf_register_hooks(ip_vs_ops, ARRAY_SIZE(ip_vs_ops)); |
1948 | if (ret < 0) { | 2026 | if (ret < 0) { |
1949 | pr_err("can't register hooks.\n"); | 2027 | pr_err("can't register hooks.\n"); |
1950 | goto cleanup_sync; | 2028 | goto cleanup_dev; |
1951 | } | 2029 | } |
1952 | 2030 | ||
1953 | pr_info("ipvs loaded.\n"); | 2031 | pr_info("ipvs loaded.\n"); |
2032 | |||
1954 | return ret; | 2033 | return ret; |
1955 | 2034 | ||
2035 | cleanup_dev: | ||
2036 | unregister_pernet_device(&ipvs_core_dev_ops); | ||
2037 | cleanup_sub: | ||
2038 | unregister_pernet_subsys(&ipvs_core_ops); | ||
1956 | cleanup_sync: | 2039 | cleanup_sync: |
1957 | ip_vs_sync_cleanup(); | 2040 | ip_vs_sync_cleanup(); |
1958 | cleanup_conn: | 2041 | cleanup_conn: |
@@ -1964,20 +2047,20 @@ cleanup_sync: | |||
1964 | ip_vs_control_cleanup(); | 2047 | ip_vs_control_cleanup(); |
1965 | cleanup_estimator: | 2048 | cleanup_estimator: |
1966 | ip_vs_estimator_cleanup(); | 2049 | ip_vs_estimator_cleanup(); |
1967 | unregister_pernet_subsys(&ipvs_core_ops); /* free ip_vs struct */ | ||
1968 | return ret; | 2050 | return ret; |
1969 | } | 2051 | } |
1970 | 2052 | ||
1971 | static void __exit ip_vs_cleanup(void) | 2053 | static void __exit ip_vs_cleanup(void) |
1972 | { | 2054 | { |
1973 | nf_unregister_hooks(ip_vs_ops, ARRAY_SIZE(ip_vs_ops)); | 2055 | nf_unregister_hooks(ip_vs_ops, ARRAY_SIZE(ip_vs_ops)); |
2056 | unregister_pernet_device(&ipvs_core_dev_ops); | ||
2057 | unregister_pernet_subsys(&ipvs_core_ops); /* free ip_vs struct */ | ||
1974 | ip_vs_sync_cleanup(); | 2058 | ip_vs_sync_cleanup(); |
1975 | ip_vs_conn_cleanup(); | 2059 | ip_vs_conn_cleanup(); |
1976 | ip_vs_app_cleanup(); | 2060 | ip_vs_app_cleanup(); |
1977 | ip_vs_protocol_cleanup(); | 2061 | ip_vs_protocol_cleanup(); |
1978 | ip_vs_control_cleanup(); | 2062 | ip_vs_control_cleanup(); |
1979 | ip_vs_estimator_cleanup(); | 2063 | ip_vs_estimator_cleanup(); |
1980 | unregister_pernet_subsys(&ipvs_core_ops); /* free ip_vs struct */ | ||
1981 | pr_info("ipvs unloaded.\n"); | 2064 | pr_info("ipvs unloaded.\n"); |
1982 | } | 2065 | } |
1983 | 2066 | ||
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index ae47090bf45..37890f228b1 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c | |||
@@ -69,6 +69,11 @@ int ip_vs_get_debug_level(void) | |||
69 | } | 69 | } |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | |||
73 | /* Protos */ | ||
74 | static void __ip_vs_del_service(struct ip_vs_service *svc); | ||
75 | |||
76 | |||
72 | #ifdef CONFIG_IP_VS_IPV6 | 77 | #ifdef CONFIG_IP_VS_IPV6 |
73 | /* Taken from rt6_fill_node() in net/ipv6/route.c, is there a better way? */ | 78 | /* Taken from rt6_fill_node() in net/ipv6/route.c, is there a better way? */ |
74 | static int __ip_vs_addr_is_local_v6(struct net *net, | 79 | static int __ip_vs_addr_is_local_v6(struct net *net, |
@@ -1214,6 +1219,8 @@ ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u, | |||
1214 | write_unlock_bh(&__ip_vs_svc_lock); | 1219 | write_unlock_bh(&__ip_vs_svc_lock); |
1215 | 1220 | ||
1216 | *svc_p = svc; | 1221 | *svc_p = svc; |
1222 | /* Now there is a service - full throttle */ | ||
1223 | ipvs->enable = 1; | ||
1217 | return 0; | 1224 | return 0; |
1218 | 1225 | ||
1219 | 1226 | ||
@@ -1472,6 +1479,84 @@ static int ip_vs_flush(struct net *net) | |||
1472 | return 0; | 1479 | return 0; |
1473 | } | 1480 | } |
1474 | 1481 | ||
1482 | /* | ||
1483 | * Delete service by {netns} in the service table. | ||
1484 | * Called by __ip_vs_cleanup() | ||
1485 | */ | ||
1486 | void __ip_vs_service_cleanup(struct net *net) | ||
1487 | { | ||
1488 | EnterFunction(2); | ||
1489 | /* Check for "full" addressed entries */ | ||
1490 | mutex_lock(&__ip_vs_mutex); | ||
1491 | ip_vs_flush(net); | ||
1492 | mutex_unlock(&__ip_vs_mutex); | ||
1493 | LeaveFunction(2); | ||
1494 | } | ||
1495 | /* | ||
1496 | * Release dst hold by dst_cache | ||
1497 | */ | ||
1498 | static inline void | ||
1499 | __ip_vs_dev_reset(struct ip_vs_dest *dest, struct net_device *dev) | ||
1500 | { | ||
1501 | spin_lock_bh(&dest->dst_lock); | ||
1502 | if (dest->dst_cache && dest->dst_cache->dev == dev) { | ||
1503 | IP_VS_DBG_BUF(3, "Reset dev:%s dest %s:%u ,dest->refcnt=%d\n", | ||
1504 | dev->name, | ||
1505 | IP_VS_DBG_ADDR(dest->af, &dest->addr), | ||
1506 | ntohs(dest->port), | ||
1507 | atomic_read(&dest->refcnt)); | ||
1508 | ip_vs_dst_reset(dest); | ||
1509 | } | ||
1510 | spin_unlock_bh(&dest->dst_lock); | ||
1511 | |||
1512 | } | ||
1513 | /* | ||
1514 | * Netdev event receiver | ||
1515 | * Currently only NETDEV_UNREGISTER is handled, i.e. if we hold a reference to | ||
1516 | * a device that is "unregister" it must be released. | ||
1517 | */ | ||
1518 | static int ip_vs_dst_event(struct notifier_block *this, unsigned long event, | ||
1519 | void *ptr) | ||
1520 | { | ||
1521 | struct net_device *dev = ptr; | ||
1522 | struct net *net = dev_net(dev); | ||
1523 | struct ip_vs_service *svc; | ||
1524 | struct ip_vs_dest *dest; | ||
1525 | unsigned int idx; | ||
1526 | |||
1527 | if (event != NETDEV_UNREGISTER) | ||
1528 | return NOTIFY_DONE; | ||
1529 | IP_VS_DBG(3, "%s() dev=%s\n", __func__, dev->name); | ||
1530 | EnterFunction(2); | ||
1531 | mutex_lock(&__ip_vs_mutex); | ||
1532 | for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { | ||
1533 | list_for_each_entry(svc, &ip_vs_svc_table[idx], s_list) { | ||
1534 | if (net_eq(svc->net, net)) { | ||
1535 | list_for_each_entry(dest, &svc->destinations, | ||
1536 | n_list) { | ||
1537 | __ip_vs_dev_reset(dest, dev); | ||
1538 | } | ||
1539 | } | ||
1540 | } | ||
1541 | |||
1542 | list_for_each_entry(svc, &ip_vs_svc_fwm_table[idx], f_list) { | ||
1543 | if (net_eq(svc->net, net)) { | ||
1544 | list_for_each_entry(dest, &svc->destinations, | ||
1545 | n_list) { | ||
1546 | __ip_vs_dev_reset(dest, dev); | ||
1547 | } | ||
1548 | } | ||
1549 | |||
1550 | } | ||
1551 | } | ||
1552 | |||
1553 | list_for_each_entry(dest, &net_ipvs(net)->dest_trash, n_list) { | ||
1554 | __ip_vs_dev_reset(dest, dev); | ||
1555 | } | ||
1556 | mutex_unlock(&__ip_vs_mutex); | ||
1557 | LeaveFunction(2); | ||
1558 | return NOTIFY_DONE; | ||
1559 | } | ||
1475 | 1560 | ||
1476 | /* | 1561 | /* |
1477 | * Zero counters in a service or all services | 1562 | * Zero counters in a service or all services |
@@ -1981,7 +2066,7 @@ static const struct file_operations ip_vs_info_fops = { | |||
1981 | .open = ip_vs_info_open, | 2066 | .open = ip_vs_info_open, |
1982 | .read = seq_read, | 2067 | .read = seq_read, |
1983 | .llseek = seq_lseek, | 2068 | .llseek = seq_lseek, |
1984 | .release = seq_release_private, | 2069 | .release = seq_release_net, |
1985 | }; | 2070 | }; |
1986 | 2071 | ||
1987 | #endif | 2072 | #endif |
@@ -2024,7 +2109,7 @@ static const struct file_operations ip_vs_stats_fops = { | |||
2024 | .open = ip_vs_stats_seq_open, | 2109 | .open = ip_vs_stats_seq_open, |
2025 | .read = seq_read, | 2110 | .read = seq_read, |
2026 | .llseek = seq_lseek, | 2111 | .llseek = seq_lseek, |
2027 | .release = single_release, | 2112 | .release = single_release_net, |
2028 | }; | 2113 | }; |
2029 | 2114 | ||
2030 | static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v) | 2115 | static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v) |
@@ -2093,7 +2178,7 @@ static const struct file_operations ip_vs_stats_percpu_fops = { | |||
2093 | .open = ip_vs_stats_percpu_seq_open, | 2178 | .open = ip_vs_stats_percpu_seq_open, |
2094 | .read = seq_read, | 2179 | .read = seq_read, |
2095 | .llseek = seq_lseek, | 2180 | .llseek = seq_lseek, |
2096 | .release = single_release, | 2181 | .release = single_release_net, |
2097 | }; | 2182 | }; |
2098 | #endif | 2183 | #endif |
2099 | 2184 | ||
@@ -3588,6 +3673,10 @@ void __net_init __ip_vs_control_cleanup_sysctl(struct net *net) { } | |||
3588 | 3673 | ||
3589 | #endif | 3674 | #endif |
3590 | 3675 | ||
3676 | static struct notifier_block ip_vs_dst_notifier = { | ||
3677 | .notifier_call = ip_vs_dst_event, | ||
3678 | }; | ||
3679 | |||
3591 | int __net_init __ip_vs_control_init(struct net *net) | 3680 | int __net_init __ip_vs_control_init(struct net *net) |
3592 | { | 3681 | { |
3593 | int idx; | 3682 | int idx; |
@@ -3626,7 +3715,7 @@ err: | |||
3626 | return -ENOMEM; | 3715 | return -ENOMEM; |
3627 | } | 3716 | } |
3628 | 3717 | ||
3629 | static void __net_exit __ip_vs_control_cleanup(struct net *net) | 3718 | void __net_exit __ip_vs_control_cleanup(struct net *net) |
3630 | { | 3719 | { |
3631 | struct netns_ipvs *ipvs = net_ipvs(net); | 3720 | struct netns_ipvs *ipvs = net_ipvs(net); |
3632 | 3721 | ||
@@ -3639,11 +3728,6 @@ static void __net_exit __ip_vs_control_cleanup(struct net *net) | |||
3639 | free_percpu(ipvs->tot_stats.cpustats); | 3728 | free_percpu(ipvs->tot_stats.cpustats); |
3640 | } | 3729 | } |
3641 | 3730 | ||
3642 | static struct pernet_operations ipvs_control_ops = { | ||
3643 | .init = __ip_vs_control_init, | ||
3644 | .exit = __ip_vs_control_cleanup, | ||
3645 | }; | ||
3646 | |||
3647 | int __init ip_vs_control_init(void) | 3731 | int __init ip_vs_control_init(void) |
3648 | { | 3732 | { |
3649 | int idx; | 3733 | int idx; |
@@ -3657,33 +3741,32 @@ int __init ip_vs_control_init(void) | |||
3657 | INIT_LIST_HEAD(&ip_vs_svc_fwm_table[idx]); | 3741 | INIT_LIST_HEAD(&ip_vs_svc_fwm_table[idx]); |
3658 | } | 3742 | } |
3659 | 3743 | ||
3660 | ret = register_pernet_subsys(&ipvs_control_ops); | ||
3661 | if (ret) { | ||
3662 | pr_err("cannot register namespace.\n"); | ||
3663 | goto err; | ||
3664 | } | ||
3665 | |||
3666 | smp_wmb(); /* Do we really need it now ? */ | 3744 | smp_wmb(); /* Do we really need it now ? */ |
3667 | 3745 | ||
3668 | ret = nf_register_sockopt(&ip_vs_sockopts); | 3746 | ret = nf_register_sockopt(&ip_vs_sockopts); |
3669 | if (ret) { | 3747 | if (ret) { |
3670 | pr_err("cannot register sockopt.\n"); | 3748 | pr_err("cannot register sockopt.\n"); |
3671 | goto err_net; | 3749 | goto err_sock; |
3672 | } | 3750 | } |
3673 | 3751 | ||
3674 | ret = ip_vs_genl_register(); | 3752 | ret = ip_vs_genl_register(); |
3675 | if (ret) { | 3753 | if (ret) { |
3676 | pr_err("cannot register Generic Netlink interface.\n"); | 3754 | pr_err("cannot register Generic Netlink interface.\n"); |
3677 | nf_unregister_sockopt(&ip_vs_sockopts); | 3755 | goto err_genl; |
3678 | goto err_net; | ||
3679 | } | 3756 | } |
3680 | 3757 | ||
3758 | ret = register_netdevice_notifier(&ip_vs_dst_notifier); | ||
3759 | if (ret < 0) | ||
3760 | goto err_notf; | ||
3761 | |||
3681 | LeaveFunction(2); | 3762 | LeaveFunction(2); |
3682 | return 0; | 3763 | return 0; |
3683 | 3764 | ||
3684 | err_net: | 3765 | err_notf: |
3685 | unregister_pernet_subsys(&ipvs_control_ops); | 3766 | ip_vs_genl_unregister(); |
3686 | err: | 3767 | err_genl: |
3768 | nf_unregister_sockopt(&ip_vs_sockopts); | ||
3769 | err_sock: | ||
3687 | return ret; | 3770 | return ret; |
3688 | } | 3771 | } |
3689 | 3772 | ||
@@ -3691,7 +3774,6 @@ err: | |||
3691 | void ip_vs_control_cleanup(void) | 3774 | void ip_vs_control_cleanup(void) |
3692 | { | 3775 | { |
3693 | EnterFunction(2); | 3776 | EnterFunction(2); |
3694 | unregister_pernet_subsys(&ipvs_control_ops); | ||
3695 | ip_vs_genl_unregister(); | 3777 | ip_vs_genl_unregister(); |
3696 | nf_unregister_sockopt(&ip_vs_sockopts); | 3778 | nf_unregister_sockopt(&ip_vs_sockopts); |
3697 | LeaveFunction(2); | 3779 | LeaveFunction(2); |
diff --git a/net/netfilter/ipvs/ip_vs_est.c b/net/netfilter/ipvs/ip_vs_est.c index 8c8766ca56a..508cce98777 100644 --- a/net/netfilter/ipvs/ip_vs_est.c +++ b/net/netfilter/ipvs/ip_vs_est.c | |||
@@ -192,7 +192,7 @@ void ip_vs_read_estimator(struct ip_vs_stats_user *dst, | |||
192 | dst->outbps = (e->outbps + 0xF) >> 5; | 192 | dst->outbps = (e->outbps + 0xF) >> 5; |
193 | } | 193 | } |
194 | 194 | ||
195 | static int __net_init __ip_vs_estimator_init(struct net *net) | 195 | int __net_init __ip_vs_estimator_init(struct net *net) |
196 | { | 196 | { |
197 | struct netns_ipvs *ipvs = net_ipvs(net); | 197 | struct netns_ipvs *ipvs = net_ipvs(net); |
198 | 198 | ||
@@ -203,24 +203,16 @@ static int __net_init __ip_vs_estimator_init(struct net *net) | |||
203 | return 0; | 203 | return 0; |
204 | } | 204 | } |
205 | 205 | ||
206 | static void __net_exit __ip_vs_estimator_exit(struct net *net) | 206 | void __net_exit __ip_vs_estimator_cleanup(struct net *net) |
207 | { | 207 | { |
208 | del_timer_sync(&net_ipvs(net)->est_timer); | 208 | del_timer_sync(&net_ipvs(net)->est_timer); |
209 | } | 209 | } |
210 | static struct pernet_operations ip_vs_app_ops = { | ||
211 | .init = __ip_vs_estimator_init, | ||
212 | .exit = __ip_vs_estimator_exit, | ||
213 | }; | ||
214 | 210 | ||
215 | int __init ip_vs_estimator_init(void) | 211 | int __init ip_vs_estimator_init(void) |
216 | { | 212 | { |
217 | int rv; | 213 | return 0; |
218 | |||
219 | rv = register_pernet_subsys(&ip_vs_app_ops); | ||
220 | return rv; | ||
221 | } | 214 | } |
222 | 215 | ||
223 | void ip_vs_estimator_cleanup(void) | 216 | void ip_vs_estimator_cleanup(void) |
224 | { | 217 | { |
225 | unregister_pernet_subsys(&ip_vs_app_ops); | ||
226 | } | 218 | } |
diff --git a/net/netfilter/ipvs/ip_vs_proto.c b/net/netfilter/ipvs/ip_vs_proto.c index 17484a4416e..eb86028536f 100644 --- a/net/netfilter/ipvs/ip_vs_proto.c +++ b/net/netfilter/ipvs/ip_vs_proto.c | |||
@@ -316,7 +316,7 @@ ip_vs_tcpudp_debug_packet(int af, struct ip_vs_protocol *pp, | |||
316 | /* | 316 | /* |
317 | * per network name-space init | 317 | * per network name-space init |
318 | */ | 318 | */ |
319 | static int __net_init __ip_vs_protocol_init(struct net *net) | 319 | int __net_init __ip_vs_protocol_init(struct net *net) |
320 | { | 320 | { |
321 | #ifdef CONFIG_IP_VS_PROTO_TCP | 321 | #ifdef CONFIG_IP_VS_PROTO_TCP |
322 | register_ip_vs_proto_netns(net, &ip_vs_protocol_tcp); | 322 | register_ip_vs_proto_netns(net, &ip_vs_protocol_tcp); |
@@ -336,7 +336,7 @@ static int __net_init __ip_vs_protocol_init(struct net *net) | |||
336 | return 0; | 336 | return 0; |
337 | } | 337 | } |
338 | 338 | ||
339 | static void __net_exit __ip_vs_protocol_cleanup(struct net *net) | 339 | void __net_exit __ip_vs_protocol_cleanup(struct net *net) |
340 | { | 340 | { |
341 | struct netns_ipvs *ipvs = net_ipvs(net); | 341 | struct netns_ipvs *ipvs = net_ipvs(net); |
342 | struct ip_vs_proto_data *pd; | 342 | struct ip_vs_proto_data *pd; |
@@ -349,11 +349,6 @@ static void __net_exit __ip_vs_protocol_cleanup(struct net *net) | |||
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
352 | static struct pernet_operations ipvs_proto_ops = { | ||
353 | .init = __ip_vs_protocol_init, | ||
354 | .exit = __ip_vs_protocol_cleanup, | ||
355 | }; | ||
356 | |||
357 | int __init ip_vs_protocol_init(void) | 352 | int __init ip_vs_protocol_init(void) |
358 | { | 353 | { |
359 | char protocols[64]; | 354 | char protocols[64]; |
@@ -382,7 +377,6 @@ int __init ip_vs_protocol_init(void) | |||
382 | REGISTER_PROTOCOL(&ip_vs_protocol_esp); | 377 | REGISTER_PROTOCOL(&ip_vs_protocol_esp); |
383 | #endif | 378 | #endif |
384 | pr_info("Registered protocols (%s)\n", &protocols[2]); | 379 | pr_info("Registered protocols (%s)\n", &protocols[2]); |
385 | return register_pernet_subsys(&ipvs_proto_ops); | ||
386 | 380 | ||
387 | return 0; | 381 | return 0; |
388 | } | 382 | } |
@@ -393,7 +387,6 @@ void ip_vs_protocol_cleanup(void) | |||
393 | struct ip_vs_protocol *pp; | 387 | struct ip_vs_protocol *pp; |
394 | int i; | 388 | int i; |
395 | 389 | ||
396 | unregister_pernet_subsys(&ipvs_proto_ops); | ||
397 | /* unregister all the ipvs protocols */ | 390 | /* unregister all the ipvs protocols */ |
398 | for (i = 0; i < IP_VS_PROTO_TAB_SIZE; i++) { | 391 | for (i = 0; i < IP_VS_PROTO_TAB_SIZE; i++) { |
399 | while ((pp = ip_vs_proto_table[i]) != NULL) | 392 | while ((pp = ip_vs_proto_table[i]) != NULL) |
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c index 3e7961e85e9..e292e5bddc7 100644 --- a/net/netfilter/ipvs/ip_vs_sync.c +++ b/net/netfilter/ipvs/ip_vs_sync.c | |||
@@ -1303,13 +1303,18 @@ static struct socket *make_send_sock(struct net *net) | |||
1303 | struct socket *sock; | 1303 | struct socket *sock; |
1304 | int result; | 1304 | int result; |
1305 | 1305 | ||
1306 | /* First create a socket */ | 1306 | /* First create a socket move it to right name space later */ |
1307 | result = __sock_create(net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock, 1); | 1307 | result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); |
1308 | if (result < 0) { | 1308 | if (result < 0) { |
1309 | pr_err("Error during creation of socket; terminating\n"); | 1309 | pr_err("Error during creation of socket; terminating\n"); |
1310 | return ERR_PTR(result); | 1310 | return ERR_PTR(result); |
1311 | } | 1311 | } |
1312 | 1312 | /* | |
1313 | * Kernel sockets that are a part of a namespace, should not | ||
1314 | * hold a reference to a namespace in order to allow to stop it. | ||
1315 | * After sk_change_net should be released using sk_release_kernel. | ||
1316 | */ | ||
1317 | sk_change_net(sock->sk, net); | ||
1313 | result = set_mcast_if(sock->sk, ipvs->master_mcast_ifn); | 1318 | result = set_mcast_if(sock->sk, ipvs->master_mcast_ifn); |
1314 | if (result < 0) { | 1319 | if (result < 0) { |
1315 | pr_err("Error setting outbound mcast interface\n"); | 1320 | pr_err("Error setting outbound mcast interface\n"); |
@@ -1334,8 +1339,8 @@ static struct socket *make_send_sock(struct net *net) | |||
1334 | 1339 | ||
1335 | return sock; | 1340 | return sock; |
1336 | 1341 | ||
1337 | error: | 1342 | error: |
1338 | sock_release(sock); | 1343 | sk_release_kernel(sock->sk); |
1339 | return ERR_PTR(result); | 1344 | return ERR_PTR(result); |
1340 | } | 1345 | } |
1341 | 1346 | ||
@@ -1350,12 +1355,17 @@ static struct socket *make_receive_sock(struct net *net) | |||
1350 | int result; | 1355 | int result; |
1351 | 1356 | ||
1352 | /* First create a socket */ | 1357 | /* First create a socket */ |
1353 | result = __sock_create(net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock, 1); | 1358 | result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); |
1354 | if (result < 0) { | 1359 | if (result < 0) { |
1355 | pr_err("Error during creation of socket; terminating\n"); | 1360 | pr_err("Error during creation of socket; terminating\n"); |
1356 | return ERR_PTR(result); | 1361 | return ERR_PTR(result); |
1357 | } | 1362 | } |
1358 | 1363 | /* | |
1364 | * Kernel sockets that are a part of a namespace, should not | ||
1365 | * hold a reference to a namespace in order to allow to stop it. | ||
1366 | * After sk_change_net should be released using sk_release_kernel. | ||
1367 | */ | ||
1368 | sk_change_net(sock->sk, net); | ||
1359 | /* it is equivalent to the REUSEADDR option in user-space */ | 1369 | /* it is equivalent to the REUSEADDR option in user-space */ |
1360 | sock->sk->sk_reuse = 1; | 1370 | sock->sk->sk_reuse = 1; |
1361 | 1371 | ||
@@ -1377,8 +1387,8 @@ static struct socket *make_receive_sock(struct net *net) | |||
1377 | 1387 | ||
1378 | return sock; | 1388 | return sock; |
1379 | 1389 | ||
1380 | error: | 1390 | error: |
1381 | sock_release(sock); | 1391 | sk_release_kernel(sock->sk); |
1382 | return ERR_PTR(result); | 1392 | return ERR_PTR(result); |
1383 | } | 1393 | } |
1384 | 1394 | ||
@@ -1473,7 +1483,7 @@ static int sync_thread_master(void *data) | |||
1473 | ip_vs_sync_buff_release(sb); | 1483 | ip_vs_sync_buff_release(sb); |
1474 | 1484 | ||
1475 | /* release the sending multicast socket */ | 1485 | /* release the sending multicast socket */ |
1476 | sock_release(tinfo->sock); | 1486 | sk_release_kernel(tinfo->sock->sk); |
1477 | kfree(tinfo); | 1487 | kfree(tinfo); |
1478 | 1488 | ||
1479 | return 0; | 1489 | return 0; |
@@ -1513,7 +1523,7 @@ static int sync_thread_backup(void *data) | |||
1513 | } | 1523 | } |
1514 | 1524 | ||
1515 | /* release the sending multicast socket */ | 1525 | /* release the sending multicast socket */ |
1516 | sock_release(tinfo->sock); | 1526 | sk_release_kernel(tinfo->sock->sk); |
1517 | kfree(tinfo->buf); | 1527 | kfree(tinfo->buf); |
1518 | kfree(tinfo); | 1528 | kfree(tinfo); |
1519 | 1529 | ||
@@ -1601,7 +1611,7 @@ outtinfo: | |||
1601 | outbuf: | 1611 | outbuf: |
1602 | kfree(buf); | 1612 | kfree(buf); |
1603 | outsocket: | 1613 | outsocket: |
1604 | sock_release(sock); | 1614 | sk_release_kernel(sock->sk); |
1605 | out: | 1615 | out: |
1606 | return result; | 1616 | return result; |
1607 | } | 1617 | } |
@@ -1610,6 +1620,7 @@ out: | |||
1610 | int stop_sync_thread(struct net *net, int state) | 1620 | int stop_sync_thread(struct net *net, int state) |
1611 | { | 1621 | { |
1612 | struct netns_ipvs *ipvs = net_ipvs(net); | 1622 | struct netns_ipvs *ipvs = net_ipvs(net); |
1623 | int retc = -EINVAL; | ||
1613 | 1624 | ||
1614 | IP_VS_DBG(7, "%s(): pid %d\n", __func__, task_pid_nr(current)); | 1625 | IP_VS_DBG(7, "%s(): pid %d\n", __func__, task_pid_nr(current)); |
1615 | 1626 | ||
@@ -1629,7 +1640,7 @@ int stop_sync_thread(struct net *net, int state) | |||
1629 | spin_lock_bh(&ipvs->sync_lock); | 1640 | spin_lock_bh(&ipvs->sync_lock); |
1630 | ipvs->sync_state &= ~IP_VS_STATE_MASTER; | 1641 | ipvs->sync_state &= ~IP_VS_STATE_MASTER; |
1631 | spin_unlock_bh(&ipvs->sync_lock); | 1642 | spin_unlock_bh(&ipvs->sync_lock); |
1632 | kthread_stop(ipvs->master_thread); | 1643 | retc = kthread_stop(ipvs->master_thread); |
1633 | ipvs->master_thread = NULL; | 1644 | ipvs->master_thread = NULL; |
1634 | } else if (state == IP_VS_STATE_BACKUP) { | 1645 | } else if (state == IP_VS_STATE_BACKUP) { |
1635 | if (!ipvs->backup_thread) | 1646 | if (!ipvs->backup_thread) |
@@ -1639,22 +1650,20 @@ int stop_sync_thread(struct net *net, int state) | |||
1639 | task_pid_nr(ipvs->backup_thread)); | 1650 | task_pid_nr(ipvs->backup_thread)); |
1640 | 1651 | ||
1641 | ipvs->sync_state &= ~IP_VS_STATE_BACKUP; | 1652 | ipvs->sync_state &= ~IP_VS_STATE_BACKUP; |
1642 | kthread_stop(ipvs->backup_thread); | 1653 | retc = kthread_stop(ipvs->backup_thread); |
1643 | ipvs->backup_thread = NULL; | 1654 | ipvs->backup_thread = NULL; |
1644 | } else { | ||
1645 | return -EINVAL; | ||
1646 | } | 1655 | } |
1647 | 1656 | ||
1648 | /* decrease the module use count */ | 1657 | /* decrease the module use count */ |
1649 | ip_vs_use_count_dec(); | 1658 | ip_vs_use_count_dec(); |
1650 | 1659 | ||
1651 | return 0; | 1660 | return retc; |
1652 | } | 1661 | } |
1653 | 1662 | ||
1654 | /* | 1663 | /* |
1655 | * Initialize data struct for each netns | 1664 | * Initialize data struct for each netns |
1656 | */ | 1665 | */ |
1657 | static int __net_init __ip_vs_sync_init(struct net *net) | 1666 | int __net_init __ip_vs_sync_init(struct net *net) |
1658 | { | 1667 | { |
1659 | struct netns_ipvs *ipvs = net_ipvs(net); | 1668 | struct netns_ipvs *ipvs = net_ipvs(net); |
1660 | 1669 | ||
@@ -1668,24 +1677,24 @@ static int __net_init __ip_vs_sync_init(struct net *net) | |||
1668 | return 0; | 1677 | return 0; |
1669 | } | 1678 | } |
1670 | 1679 | ||
1671 | static void __ip_vs_sync_cleanup(struct net *net) | 1680 | void __ip_vs_sync_cleanup(struct net *net) |
1672 | { | 1681 | { |
1673 | stop_sync_thread(net, IP_VS_STATE_MASTER); | 1682 | int retc; |
1674 | stop_sync_thread(net, IP_VS_STATE_BACKUP); | ||
1675 | } | ||
1676 | 1683 | ||
1677 | static struct pernet_operations ipvs_sync_ops = { | 1684 | retc = stop_sync_thread(net, IP_VS_STATE_MASTER); |
1678 | .init = __ip_vs_sync_init, | 1685 | if (retc && retc != -ESRCH) |
1679 | .exit = __ip_vs_sync_cleanup, | 1686 | pr_err("Failed to stop Master Daemon\n"); |
1680 | }; | ||
1681 | 1687 | ||
1688 | retc = stop_sync_thread(net, IP_VS_STATE_BACKUP); | ||
1689 | if (retc && retc != -ESRCH) | ||
1690 | pr_err("Failed to stop Backup Daemon\n"); | ||
1691 | } | ||
1682 | 1692 | ||
1683 | int __init ip_vs_sync_init(void) | 1693 | int __init ip_vs_sync_init(void) |
1684 | { | 1694 | { |
1685 | return register_pernet_subsys(&ipvs_sync_ops); | 1695 | return 0; |
1686 | } | 1696 | } |
1687 | 1697 | ||
1688 | void ip_vs_sync_cleanup(void) | 1698 | void ip_vs_sync_cleanup(void) |
1689 | { | 1699 | { |
1690 | unregister_pernet_subsys(&ipvs_sync_ops); | ||
1691 | } | 1700 | } |
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 30bf8a167fc..482e90c6185 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -1334,6 +1334,7 @@ ctnetlink_create_conntrack(struct net *net, u16 zone, | |||
1334 | struct nf_conn *ct; | 1334 | struct nf_conn *ct; |
1335 | int err = -EINVAL; | 1335 | int err = -EINVAL; |
1336 | struct nf_conntrack_helper *helper; | 1336 | struct nf_conntrack_helper *helper; |
1337 | struct nf_conn_tstamp *tstamp; | ||
1337 | 1338 | ||
1338 | ct = nf_conntrack_alloc(net, zone, otuple, rtuple, GFP_ATOMIC); | 1339 | ct = nf_conntrack_alloc(net, zone, otuple, rtuple, GFP_ATOMIC); |
1339 | if (IS_ERR(ct)) | 1340 | if (IS_ERR(ct)) |
@@ -1451,6 +1452,9 @@ ctnetlink_create_conntrack(struct net *net, u16 zone, | |||
1451 | __set_bit(IPS_EXPECTED_BIT, &ct->status); | 1452 | __set_bit(IPS_EXPECTED_BIT, &ct->status); |
1452 | ct->master = master_ct; | 1453 | ct->master = master_ct; |
1453 | } | 1454 | } |
1455 | tstamp = nf_conn_tstamp_find(ct); | ||
1456 | if (tstamp) | ||
1457 | tstamp->start = ktime_to_ns(ktime_get_real()); | ||
1454 | 1458 | ||
1455 | add_timer(&ct->timeout); | 1459 | add_timer(&ct->timeout); |
1456 | nf_conntrack_hash_insert(ct); | 1460 | nf_conntrack_hash_insert(ct); |
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index a9adf4c6b29..8a025a585d2 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
@@ -455,6 +455,7 @@ void xt_compat_flush_offsets(u_int8_t af) | |||
455 | vfree(xt[af].compat_tab); | 455 | vfree(xt[af].compat_tab); |
456 | xt[af].compat_tab = NULL; | 456 | xt[af].compat_tab = NULL; |
457 | xt[af].number = 0; | 457 | xt[af].number = 0; |
458 | xt[af].cur = 0; | ||
458 | } | 459 | } |
459 | } | 460 | } |
460 | EXPORT_SYMBOL_GPL(xt_compat_flush_offsets); | 461 | EXPORT_SYMBOL_GPL(xt_compat_flush_offsets); |
@@ -473,8 +474,7 @@ int xt_compat_calc_jump(u_int8_t af, unsigned int offset) | |||
473 | else | 474 | else |
474 | return mid ? tmp[mid - 1].delta : 0; | 475 | return mid ? tmp[mid - 1].delta : 0; |
475 | } | 476 | } |
476 | WARN_ON_ONCE(1); | 477 | return left ? tmp[left - 1].delta : 0; |
477 | return 0; | ||
478 | } | 478 | } |
479 | EXPORT_SYMBOL_GPL(xt_compat_calc_jump); | 479 | EXPORT_SYMBOL_GPL(xt_compat_calc_jump); |
480 | 480 | ||
diff --git a/net/netfilter/xt_DSCP.c b/net/netfilter/xt_DSCP.c index 0a229191e55..ae8271652ef 100644 --- a/net/netfilter/xt_DSCP.c +++ b/net/netfilter/xt_DSCP.c | |||
@@ -99,7 +99,7 @@ tos_tg6(struct sk_buff *skb, const struct xt_action_param *par) | |||
99 | u_int8_t orig, nv; | 99 | u_int8_t orig, nv; |
100 | 100 | ||
101 | orig = ipv6_get_dsfield(iph); | 101 | orig = ipv6_get_dsfield(iph); |
102 | nv = (orig & info->tos_mask) ^ info->tos_value; | 102 | nv = (orig & ~info->tos_mask) ^ info->tos_value; |
103 | 103 | ||
104 | if (orig != nv) { | 104 | if (orig != nv) { |
105 | if (!skb_make_writable(skb, sizeof(struct iphdr))) | 105 | if (!skb_make_writable(skb, sizeof(struct iphdr))) |
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c index 481a86fdc40..61805d7b38a 100644 --- a/net/netfilter/xt_conntrack.c +++ b/net/netfilter/xt_conntrack.c | |||
@@ -272,11 +272,6 @@ static int conntrack_mt_check(const struct xt_mtchk_param *par) | |||
272 | { | 272 | { |
273 | int ret; | 273 | int ret; |
274 | 274 | ||
275 | if (strcmp(par->table, "raw") == 0) { | ||
276 | pr_info("state is undetermined at the time of raw table\n"); | ||
277 | return -EINVAL; | ||
278 | } | ||
279 | |||
280 | ret = nf_ct_l3proto_try_module_get(par->family); | 275 | ret = nf_ct_l3proto_try_module_get(par->family); |
281 | if (ret < 0) | 276 | if (ret < 0) |
282 | pr_info("cannot load conntrack support for proto=%u\n", | 277 | pr_info("cannot load conntrack support for proto=%u\n", |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 3a43a830476..b1d75beb7e2 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -524,6 +524,8 @@ static int unix_dgram_connect(struct socket *, struct sockaddr *, | |||
524 | int, int); | 524 | int, int); |
525 | static int unix_seqpacket_sendmsg(struct kiocb *, struct socket *, | 525 | static int unix_seqpacket_sendmsg(struct kiocb *, struct socket *, |
526 | struct msghdr *, size_t); | 526 | struct msghdr *, size_t); |
527 | static int unix_seqpacket_recvmsg(struct kiocb *, struct socket *, | ||
528 | struct msghdr *, size_t, int); | ||
527 | 529 | ||
528 | static const struct proto_ops unix_stream_ops = { | 530 | static const struct proto_ops unix_stream_ops = { |
529 | .family = PF_UNIX, | 531 | .family = PF_UNIX, |
@@ -583,7 +585,7 @@ static const struct proto_ops unix_seqpacket_ops = { | |||
583 | .setsockopt = sock_no_setsockopt, | 585 | .setsockopt = sock_no_setsockopt, |
584 | .getsockopt = sock_no_getsockopt, | 586 | .getsockopt = sock_no_getsockopt, |
585 | .sendmsg = unix_seqpacket_sendmsg, | 587 | .sendmsg = unix_seqpacket_sendmsg, |
586 | .recvmsg = unix_dgram_recvmsg, | 588 | .recvmsg = unix_seqpacket_recvmsg, |
587 | .mmap = sock_no_mmap, | 589 | .mmap = sock_no_mmap, |
588 | .sendpage = sock_no_sendpage, | 590 | .sendpage = sock_no_sendpage, |
589 | }; | 591 | }; |
@@ -1699,6 +1701,18 @@ static int unix_seqpacket_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1699 | return unix_dgram_sendmsg(kiocb, sock, msg, len); | 1701 | return unix_dgram_sendmsg(kiocb, sock, msg, len); |
1700 | } | 1702 | } |
1701 | 1703 | ||
1704 | static int unix_seqpacket_recvmsg(struct kiocb *iocb, struct socket *sock, | ||
1705 | struct msghdr *msg, size_t size, | ||
1706 | int flags) | ||
1707 | { | ||
1708 | struct sock *sk = sock->sk; | ||
1709 | |||
1710 | if (sk->sk_state != TCP_ESTABLISHED) | ||
1711 | return -ENOTCONN; | ||
1712 | |||
1713 | return unix_dgram_recvmsg(iocb, sock, msg, size, flags); | ||
1714 | } | ||
1715 | |||
1702 | static void unix_copy_addr(struct msghdr *msg, struct sock *sk) | 1716 | static void unix_copy_addr(struct msghdr *msg, struct sock *sk) |
1703 | { | 1717 | { |
1704 | struct unix_sock *u = unix_sk(sk); | 1718 | struct unix_sock *u = unix_sk(sk); |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 15792d8b627..b4d745ea8ee 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -1406,6 +1406,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, | |||
1406 | struct net *net = xp_net(policy); | 1406 | struct net *net = xp_net(policy); |
1407 | unsigned long now = jiffies; | 1407 | unsigned long now = jiffies; |
1408 | struct net_device *dev; | 1408 | struct net_device *dev; |
1409 | struct xfrm_mode *inner_mode; | ||
1409 | struct dst_entry *dst_prev = NULL; | 1410 | struct dst_entry *dst_prev = NULL; |
1410 | struct dst_entry *dst0 = NULL; | 1411 | struct dst_entry *dst0 = NULL; |
1411 | int i = 0; | 1412 | int i = 0; |
@@ -1436,6 +1437,17 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, | |||
1436 | goto put_states; | 1437 | goto put_states; |
1437 | } | 1438 | } |
1438 | 1439 | ||
1440 | if (xfrm[i]->sel.family == AF_UNSPEC) { | ||
1441 | inner_mode = xfrm_ip2inner_mode(xfrm[i], | ||
1442 | xfrm_af2proto(family)); | ||
1443 | if (!inner_mode) { | ||
1444 | err = -EAFNOSUPPORT; | ||
1445 | dst_release(dst); | ||
1446 | goto put_states; | ||
1447 | } | ||
1448 | } else | ||
1449 | inner_mode = xfrm[i]->inner_mode; | ||
1450 | |||
1439 | if (!dst_prev) | 1451 | if (!dst_prev) |
1440 | dst0 = dst1; | 1452 | dst0 = dst1; |
1441 | else { | 1453 | else { |
@@ -1464,7 +1476,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, | |||
1464 | dst1->lastuse = now; | 1476 | dst1->lastuse = now; |
1465 | 1477 | ||
1466 | dst1->input = dst_discard; | 1478 | dst1->input = dst_discard; |
1467 | dst1->output = xfrm[i]->outer_mode->afinfo->output; | 1479 | dst1->output = inner_mode->afinfo->output; |
1468 | 1480 | ||
1469 | dst1->next = dst_prev; | 1481 | dst1->next = dst_prev; |
1470 | dst_prev = dst1; | 1482 | dst_prev = dst1; |
diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c index f218385950c..47f1b8638df 100644 --- a/net/xfrm/xfrm_replay.c +++ b/net/xfrm/xfrm_replay.c | |||
@@ -532,9 +532,12 @@ int xfrm_init_replay(struct xfrm_state *x) | |||
532 | 532 | ||
533 | if (replay_esn) { | 533 | if (replay_esn) { |
534 | if (replay_esn->replay_window > | 534 | if (replay_esn->replay_window > |
535 | replay_esn->bmp_len * sizeof(__u32)) | 535 | replay_esn->bmp_len * sizeof(__u32) * 8) |
536 | return -EINVAL; | 536 | return -EINVAL; |
537 | 537 | ||
538 | if ((x->props.flags & XFRM_STATE_ESN) && replay_esn->replay_window == 0) | ||
539 | return -EINVAL; | ||
540 | |||
538 | if ((x->props.flags & XFRM_STATE_ESN) && x->replay_esn) | 541 | if ((x->props.flags & XFRM_STATE_ESN) && x->replay_esn) |
539 | x->repl = &xfrm_replay_esn; | 542 | x->repl = &xfrm_replay_esn; |
540 | else | 543 | else |
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 5d1d60d3ca8..c658cb3bc7c 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -124,6 +124,9 @@ static inline int verify_replay(struct xfrm_usersa_info *p, | |||
124 | { | 124 | { |
125 | struct nlattr *rt = attrs[XFRMA_REPLAY_ESN_VAL]; | 125 | struct nlattr *rt = attrs[XFRMA_REPLAY_ESN_VAL]; |
126 | 126 | ||
127 | if ((p->flags & XFRM_STATE_ESN) && !rt) | ||
128 | return -EINVAL; | ||
129 | |||
127 | if (!rt) | 130 | if (!rt) |
128 | return 0; | 131 | return 0; |
129 | 132 | ||
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index f7cf0ea6fae..8fb24884300 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -1578,7 +1578,8 @@ static int may_create(struct inode *dir, | |||
1578 | return rc; | 1578 | return rc; |
1579 | 1579 | ||
1580 | if (!newsid || !(sbsec->flags & SE_SBLABELSUPP)) { | 1580 | if (!newsid || !(sbsec->flags & SE_SBLABELSUPP)) { |
1581 | rc = security_transition_sid(sid, dsec->sid, tclass, NULL, &newsid); | 1581 | rc = security_transition_sid(sid, dsec->sid, tclass, |
1582 | &dentry->d_name, &newsid); | ||
1582 | if (rc) | 1583 | if (rc) |
1583 | return rc; | 1584 | return rc; |
1584 | } | 1585 | } |
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index e7b850ad57e..7102457661d 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c | |||
@@ -502,7 +502,7 @@ static int policydb_index(struct policydb *p) | |||
502 | goto out; | 502 | goto out; |
503 | 503 | ||
504 | rc = flex_array_prealloc(p->type_val_to_struct_array, 0, | 504 | rc = flex_array_prealloc(p->type_val_to_struct_array, 0, |
505 | p->p_types.nprim - 1, GFP_KERNEL | __GFP_ZERO); | 505 | p->p_types.nprim, GFP_KERNEL | __GFP_ZERO); |
506 | if (rc) | 506 | if (rc) |
507 | goto out; | 507 | goto out; |
508 | 508 | ||
@@ -519,7 +519,7 @@ static int policydb_index(struct policydb *p) | |||
519 | goto out; | 519 | goto out; |
520 | 520 | ||
521 | rc = flex_array_prealloc(p->sym_val_to_name[i], | 521 | rc = flex_array_prealloc(p->sym_val_to_name[i], |
522 | 0, p->symtab[i].nprim - 1, | 522 | 0, p->symtab[i].nprim, |
523 | GFP_KERNEL | __GFP_ZERO); | 523 | GFP_KERNEL | __GFP_ZERO); |
524 | if (rc) | 524 | if (rc) |
525 | goto out; | 525 | goto out; |
@@ -1819,8 +1819,6 @@ static int filename_trans_read(struct policydb *p, void *fp) | |||
1819 | goto out; | 1819 | goto out; |
1820 | nel = le32_to_cpu(buf[0]); | 1820 | nel = le32_to_cpu(buf[0]); |
1821 | 1821 | ||
1822 | printk(KERN_ERR "%s: nel=%d\n", __func__, nel); | ||
1823 | |||
1824 | last = p->filename_trans; | 1822 | last = p->filename_trans; |
1825 | while (last && last->next) | 1823 | while (last && last->next) |
1826 | last = last->next; | 1824 | last = last->next; |
@@ -1857,8 +1855,6 @@ static int filename_trans_read(struct policydb *p, void *fp) | |||
1857 | goto out; | 1855 | goto out; |
1858 | name[len] = 0; | 1856 | name[len] = 0; |
1859 | 1857 | ||
1860 | printk(KERN_ERR "%s: ft=%p ft->name=%p ft->name=%s\n", __func__, ft, ft->name, ft->name); | ||
1861 | |||
1862 | rc = next_entry(buf, fp, sizeof(u32) * 4); | 1858 | rc = next_entry(buf, fp, sizeof(u32) * 4); |
1863 | if (rc) | 1859 | if (rc) |
1864 | goto out; | 1860 | goto out; |
@@ -2375,7 +2371,7 @@ int policydb_read(struct policydb *p, void *fp) | |||
2375 | goto bad; | 2371 | goto bad; |
2376 | 2372 | ||
2377 | /* preallocate so we don't have to worry about the put ever failing */ | 2373 | /* preallocate so we don't have to worry about the put ever failing */ |
2378 | rc = flex_array_prealloc(p->type_attr_map_array, 0, p->p_types.nprim - 1, | 2374 | rc = flex_array_prealloc(p->type_attr_map_array, 0, p->p_types.nprim, |
2379 | GFP_KERNEL | __GFP_ZERO); | 2375 | GFP_KERNEL | __GFP_ZERO); |
2380 | if (rc) | 2376 | if (rc) |
2381 | goto bad; | 2377 | goto bad; |
diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index 33f0ba5559a..62e959120c4 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c | |||
@@ -44,10 +44,10 @@ static struct snd_pcm_hardware snd_vortex_playback_hw_adb = { | |||
44 | .channels_min = 1, | 44 | .channels_min = 1, |
45 | .channels_max = 2, | 45 | .channels_max = 2, |
46 | .buffer_bytes_max = 0x10000, | 46 | .buffer_bytes_max = 0x10000, |
47 | .period_bytes_min = 0x1, | 47 | .period_bytes_min = 0x20, |
48 | .period_bytes_max = 0x1000, | 48 | .period_bytes_max = 0x1000, |
49 | .periods_min = 2, | 49 | .periods_min = 2, |
50 | .periods_max = 32, | 50 | .periods_max = 1024, |
51 | }; | 51 | }; |
52 | 52 | ||
53 | #ifndef CHIP_AU8820 | 53 | #ifndef CHIP_AU8820 |
@@ -140,6 +140,9 @@ static int snd_vortex_pcm_open(struct snd_pcm_substream *substream) | |||
140 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES)) < 0) | 140 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES)) < 0) |
141 | return err; | 141 | return err; |
142 | 142 | ||
143 | snd_pcm_hw_constraint_step(runtime, 0, | ||
144 | SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 64); | ||
145 | |||
143 | if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT) { | 146 | if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT) { |
144 | #ifndef CHIP_AU8820 | 147 | #ifndef CHIP_AU8820 |
145 | if (VORTEX_PCM_TYPE(substream->pcm) == VORTEX_PCM_A3D) { | 148 | if (VORTEX_PCM_TYPE(substream->pcm) == VORTEX_PCM_A3D) { |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index d3bd2c10180..c82979a8cd0 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -1704,11 +1704,11 @@ static void alc_apply_fixup(struct hda_codec *codec, int action) | |||
1704 | codec->chip_name, fix->type); | 1704 | codec->chip_name, fix->type); |
1705 | break; | 1705 | break; |
1706 | } | 1706 | } |
1707 | if (!fix[id].chained) | 1707 | if (!fix->chained) |
1708 | break; | 1708 | break; |
1709 | if (++depth > 10) | 1709 | if (++depth > 10) |
1710 | break; | 1710 | break; |
1711 | id = fix[id].chain_id; | 1711 | id = fix->chain_id; |
1712 | } | 1712 | } |
1713 | } | 1713 | } |
1714 | 1714 | ||
@@ -5645,6 +5645,7 @@ static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids, | |||
5645 | static struct snd_pci_quirk beep_white_list[] = { | 5645 | static struct snd_pci_quirk beep_white_list[] = { |
5646 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), | 5646 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
5647 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), | 5647 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
5648 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), | ||
5648 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), | 5649 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
5649 | {} | 5650 | {} |
5650 | }; | 5651 | }; |
@@ -9863,6 +9864,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = { | |||
9863 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | 9864 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), |
9864 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), | 9865 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), |
9865 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), | 9866 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
9867 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), | ||
9866 | 9868 | ||
9867 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), | 9869 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
9868 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), | 9870 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
@@ -10699,7 +10701,6 @@ enum { | |||
10699 | PINFIX_LENOVO_Y530, | 10701 | PINFIX_LENOVO_Y530, |
10700 | PINFIX_PB_M5210, | 10702 | PINFIX_PB_M5210, |
10701 | PINFIX_ACER_ASPIRE_7736, | 10703 | PINFIX_ACER_ASPIRE_7736, |
10702 | PINFIX_GIGABYTE_880GM, | ||
10703 | }; | 10704 | }; |
10704 | 10705 | ||
10705 | static const struct alc_fixup alc882_fixups[] = { | 10706 | static const struct alc_fixup alc882_fixups[] = { |
@@ -10731,13 +10732,6 @@ static const struct alc_fixup alc882_fixups[] = { | |||
10731 | .type = ALC_FIXUP_SKU, | 10732 | .type = ALC_FIXUP_SKU, |
10732 | .v.sku = ALC_FIXUP_SKU_IGNORE, | 10733 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
10733 | }, | 10734 | }, |
10734 | [PINFIX_GIGABYTE_880GM] = { | ||
10735 | .type = ALC_FIXUP_PINS, | ||
10736 | .v.pins = (const struct alc_pincfg[]) { | ||
10737 | { 0x14, 0x1114410 }, /* set as speaker */ | ||
10738 | { } | ||
10739 | } | ||
10740 | }, | ||
10741 | }; | 10735 | }; |
10742 | 10736 | ||
10743 | static struct snd_pci_quirk alc882_fixup_tbl[] = { | 10737 | static struct snd_pci_quirk alc882_fixup_tbl[] = { |
@@ -10745,7 +10739,6 @@ static struct snd_pci_quirk alc882_fixup_tbl[] = { | |||
10745 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530), | 10739 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530), |
10746 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | 10740 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), |
10747 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736), | 10741 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736), |
10748 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", PINFIX_GIGABYTE_880GM), | ||
10749 | {} | 10742 | {} |
10750 | }; | 10743 | }; |
10751 | 10744 | ||
@@ -18805,6 +18798,8 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = { | |||
18805 | ALC662_3ST_6ch_DIG), | 18798 | ALC662_3ST_6ch_DIG), |
18806 | SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO), | 18799 | SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO), |
18807 | SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10), | 18800 | SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10), |
18801 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", | ||
18802 | ALC662_3ST_6ch_DIG), | ||
18808 | SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13), | 18803 | SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13), |
18809 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), | 18804 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), |
18810 | SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA), | 18805 | SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA), |
@@ -19478,7 +19473,7 @@ enum { | |||
19478 | ALC662_FIXUP_IDEAPAD, | 19473 | ALC662_FIXUP_IDEAPAD, |
19479 | ALC272_FIXUP_MARIO, | 19474 | ALC272_FIXUP_MARIO, |
19480 | ALC662_FIXUP_CZC_P10T, | 19475 | ALC662_FIXUP_CZC_P10T, |
19481 | ALC662_FIXUP_GIGABYTE, | 19476 | ALC662_FIXUP_SKU_IGNORE, |
19482 | }; | 19477 | }; |
19483 | 19478 | ||
19484 | static const struct alc_fixup alc662_fixups[] = { | 19479 | static const struct alc_fixup alc662_fixups[] = { |
@@ -19507,20 +19502,17 @@ static const struct alc_fixup alc662_fixups[] = { | |||
19507 | {} | 19502 | {} |
19508 | } | 19503 | } |
19509 | }, | 19504 | }, |
19510 | [ALC662_FIXUP_GIGABYTE] = { | 19505 | [ALC662_FIXUP_SKU_IGNORE] = { |
19511 | .type = ALC_FIXUP_PINS, | 19506 | .type = ALC_FIXUP_SKU, |
19512 | .v.pins = (const struct alc_pincfg[]) { | 19507 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
19513 | { 0x14, 0x1114410 }, /* set as speaker */ | ||
19514 | { } | ||
19515 | } | ||
19516 | }, | 19508 | }, |
19517 | }; | 19509 | }; |
19518 | 19510 | ||
19519 | static struct snd_pci_quirk alc662_fixup_tbl[] = { | 19511 | static struct snd_pci_quirk alc662_fixup_tbl[] = { |
19520 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), | 19512 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
19513 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), | ||
19521 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), | 19514 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
19522 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), | 19515 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
19523 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", ALC662_FIXUP_GIGABYTE), | ||
19524 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), | 19516 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
19525 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), | 19517 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
19526 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), | 19518 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 1371b57c11e..0997031c48d 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -1292,14 +1292,18 @@ static void notify_aa_path_ctls(struct hda_codec *codec) | |||
1292 | { | 1292 | { |
1293 | int i; | 1293 | int i; |
1294 | struct snd_ctl_elem_id id; | 1294 | struct snd_ctl_elem_id id; |
1295 | const char *labels[] = {"Mic", "Front Mic", "Line"}; | 1295 | const char *labels[] = {"Mic", "Front Mic", "Line", "Rear Mic"}; |
1296 | struct snd_kcontrol *ctl; | ||
1296 | 1297 | ||
1297 | memset(&id, 0, sizeof(id)); | 1298 | memset(&id, 0, sizeof(id)); |
1298 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | 1299 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
1299 | for (i = 0; i < ARRAY_SIZE(labels); i++) { | 1300 | for (i = 0; i < ARRAY_SIZE(labels); i++) { |
1300 | sprintf(id.name, "%s Playback Volume", labels[i]); | 1301 | sprintf(id.name, "%s Playback Volume", labels[i]); |
1301 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE, | 1302 | ctl = snd_hda_find_mixer_ctl(codec, id.name); |
1302 | &id); | 1303 | if (ctl) |
1304 | snd_ctl_notify(codec->bus->card, | ||
1305 | SNDRV_CTL_EVENT_MASK_VALUE, | ||
1306 | &ctl->id); | ||
1303 | } | 1307 | } |
1304 | } | 1308 | } |
1305 | 1309 | ||
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 2727befd158..b04d28039c1 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c | |||
@@ -139,7 +139,7 @@ SOC_DOUBLE_R("Capture Volume", SSM2602_LINVOL, SSM2602_RINVOL, 0, 31, 0), | |||
139 | SOC_DOUBLE_R("Capture Switch", SSM2602_LINVOL, SSM2602_RINVOL, 7, 1, 1), | 139 | SOC_DOUBLE_R("Capture Switch", SSM2602_LINVOL, SSM2602_RINVOL, 7, 1, 1), |
140 | 140 | ||
141 | SOC_SINGLE("Mic Boost (+20dB)", SSM2602_APANA, 0, 1, 0), | 141 | SOC_SINGLE("Mic Boost (+20dB)", SSM2602_APANA, 0, 1, 0), |
142 | SOC_SINGLE("Mic Boost2 (+20dB)", SSM2602_APANA, 7, 1, 0), | 142 | SOC_SINGLE("Mic Boost2 (+20dB)", SSM2602_APANA, 8, 1, 0), |
143 | SOC_SINGLE("Mic Switch", SSM2602_APANA, 1, 1, 1), | 143 | SOC_SINGLE("Mic Switch", SSM2602_APANA, 1, 1, 1), |
144 | 144 | ||
145 | SOC_SINGLE("Sidetone Playback Volume", SSM2602_APANA, 6, 3, 1), | 145 | SOC_SINGLE("Sidetone Playback Volume", SSM2602_APANA, 6, 3, 1), |
@@ -602,7 +602,7 @@ static struct snd_soc_codec_driver soc_codec_dev_ssm2602 = { | |||
602 | .read = ssm2602_read_reg_cache, | 602 | .read = ssm2602_read_reg_cache, |
603 | .write = ssm2602_write, | 603 | .write = ssm2602_write, |
604 | .set_bias_level = ssm2602_set_bias_level, | 604 | .set_bias_level = ssm2602_set_bias_level, |
605 | .reg_cache_size = sizeof(ssm2602_reg), | 605 | .reg_cache_size = ARRAY_SIZE(ssm2602_reg), |
606 | .reg_word_size = sizeof(u16), | 606 | .reg_word_size = sizeof(u16), |
607 | .reg_cache_default = ssm2602_reg, | 607 | .reg_cache_default = ssm2602_reg, |
608 | }; | 608 | }; |
@@ -614,7 +614,7 @@ static struct snd_soc_codec_driver soc_codec_dev_ssm2602 = { | |||
614 | * low = 0x1a | 614 | * low = 0x1a |
615 | * high = 0x1b | 615 | * high = 0x1b |
616 | */ | 616 | */ |
617 | static int ssm2602_i2c_probe(struct i2c_client *i2c, | 617 | static int __devinit ssm2602_i2c_probe(struct i2c_client *i2c, |
618 | const struct i2c_device_id *id) | 618 | const struct i2c_device_id *id) |
619 | { | 619 | { |
620 | struct ssm2602_priv *ssm2602; | 620 | struct ssm2602_priv *ssm2602; |
@@ -635,7 +635,7 @@ static int ssm2602_i2c_probe(struct i2c_client *i2c, | |||
635 | return ret; | 635 | return ret; |
636 | } | 636 | } |
637 | 637 | ||
638 | static int ssm2602_i2c_remove(struct i2c_client *client) | 638 | static int __devexit ssm2602_i2c_remove(struct i2c_client *client) |
639 | { | 639 | { |
640 | snd_soc_unregister_codec(&client->dev); | 640 | snd_soc_unregister_codec(&client->dev); |
641 | kfree(i2c_get_clientdata(client)); | 641 | kfree(i2c_get_clientdata(client)); |
@@ -655,7 +655,7 @@ static struct i2c_driver ssm2602_i2c_driver = { | |||
655 | .owner = THIS_MODULE, | 655 | .owner = THIS_MODULE, |
656 | }, | 656 | }, |
657 | .probe = ssm2602_i2c_probe, | 657 | .probe = ssm2602_i2c_probe, |
658 | .remove = ssm2602_i2c_remove, | 658 | .remove = __devexit_p(ssm2602_i2c_remove), |
659 | .id_table = ssm2602_i2c_id, | 659 | .id_table = ssm2602_i2c_id, |
660 | }; | 660 | }; |
661 | #endif | 661 | #endif |
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index 48ffd406a71..a7b8f301bad 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c | |||
@@ -601,9 +601,7 @@ static struct snd_soc_codec_driver soc_codec_dev_uda134x = { | |||
601 | .reg_cache_step = 1, | 601 | .reg_cache_step = 1, |
602 | .read = uda134x_read_reg_cache, | 602 | .read = uda134x_read_reg_cache, |
603 | .write = uda134x_write, | 603 | .write = uda134x_write, |
604 | #ifdef POWER_OFF_ON_STANDBY | ||
605 | .set_bias_level = uda134x_set_bias_level, | 604 | .set_bias_level = uda134x_set_bias_level, |
606 | #endif | ||
607 | }; | 605 | }; |
608 | 606 | ||
609 | static int __devinit uda134x_codec_probe(struct platform_device *pdev) | 607 | static int __devinit uda134x_codec_probe(struct platform_device *pdev) |
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index f52b623bb69..824d1c8c8a3 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -692,7 +692,7 @@ SOC_ENUM("DRC Smoothing Threshold", drc_smoothing), | |||
692 | SOC_SINGLE_TLV("DRC Startup Volume", WM8903_DRC_0, 6, 18, 0, drc_tlv_startup), | 692 | SOC_SINGLE_TLV("DRC Startup Volume", WM8903_DRC_0, 6, 18, 0, drc_tlv_startup), |
693 | 693 | ||
694 | SOC_DOUBLE_R_TLV("Digital Capture Volume", WM8903_ADC_DIGITAL_VOLUME_LEFT, | 694 | SOC_DOUBLE_R_TLV("Digital Capture Volume", WM8903_ADC_DIGITAL_VOLUME_LEFT, |
695 | WM8903_ADC_DIGITAL_VOLUME_RIGHT, 1, 96, 0, digital_tlv), | 695 | WM8903_ADC_DIGITAL_VOLUME_RIGHT, 1, 120, 0, digital_tlv), |
696 | SOC_ENUM("ADC Companding Mode", adc_companding), | 696 | SOC_ENUM("ADC Companding Mode", adc_companding), |
697 | SOC_SINGLE("ADC Companding Switch", WM8903_AUDIO_INTERFACE_0, 3, 1, 0), | 697 | SOC_SINGLE("ADC Companding Switch", WM8903_AUDIO_INTERFACE_0, 3, 1, 0), |
698 | 698 | ||
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index a5af834c8ef..4ddc6d3b667 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
@@ -434,17 +434,21 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
434 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); | 434 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); |
435 | mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); | 435 | mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); |
436 | 436 | ||
437 | mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, (0x7 << 26)); | 437 | mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, |
438 | ACLKX | AHCLKX | AFSX); | ||
438 | break; | 439 | break; |
439 | case SND_SOC_DAIFMT_CBM_CFS: | 440 | case SND_SOC_DAIFMT_CBM_CFS: |
440 | /* codec is clock master and frame slave */ | 441 | /* codec is clock master and frame slave */ |
441 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); | 442 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); |
442 | mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE); | 443 | mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE); |
443 | 444 | ||
444 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); | 445 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); |
445 | mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); | 446 | mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); |
446 | 447 | ||
447 | mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, (0x2d << 26)); | 448 | mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG, |
449 | ACLKX | ACLKR); | ||
450 | mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, | ||
451 | AFSX | AFSR); | ||
448 | break; | 452 | break; |
449 | case SND_SOC_DAIFMT_CBM_CFM: | 453 | case SND_SOC_DAIFMT_CBM_CFM: |
450 | /* codec is clock and frame master */ | 454 | /* codec is clock and frame master */ |
@@ -454,7 +458,8 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
454 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); | 458 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); |
455 | mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); | 459 | mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); |
456 | 460 | ||
457 | mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG, (0x3f << 26)); | 461 | mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG, |
462 | ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR); | ||
458 | break; | 463 | break; |
459 | 464 | ||
460 | default: | 465 | default: |
@@ -644,7 +649,7 @@ static void davinci_hw_param(struct davinci_audio_dev *dev, int stream) | |||
644 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask); | 649 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask); |
645 | mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD); | 650 | mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD); |
646 | 651 | ||
647 | if ((dev->tdm_slots >= 2) || (dev->tdm_slots <= 32)) | 652 | if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32)) |
648 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, | 653 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, |
649 | FSXMOD(dev->tdm_slots), FSXMOD(0x1FF)); | 654 | FSXMOD(dev->tdm_slots), FSXMOD(0x1FF)); |
650 | else | 655 | else |
@@ -660,7 +665,7 @@ static void davinci_hw_param(struct davinci_audio_dev *dev, int stream) | |||
660 | AHCLKRE); | 665 | AHCLKRE); |
661 | mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask); | 666 | mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask); |
662 | 667 | ||
663 | if ((dev->tdm_slots >= 2) || (dev->tdm_slots <= 32)) | 668 | if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32)) |
664 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, | 669 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, |
665 | FSRMOD(dev->tdm_slots), FSRMOD(0x1FF)); | 670 | FSRMOD(dev->tdm_slots), FSRMOD(0x1FF)); |
666 | else | 671 | else |
diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 419bf4f5534..cd22a54b2f1 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c | |||
@@ -133,7 +133,7 @@ static void jz4740_i2s_shutdown(struct snd_pcm_substream *substream, | |||
133 | struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); | 133 | struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); |
134 | uint32_t conf; | 134 | uint32_t conf; |
135 | 135 | ||
136 | if (!dai->active) | 136 | if (dai->active) |
137 | return; | 137 | return; |
138 | 138 | ||
139 | conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); | 139 | conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); |
diff --git a/sound/soc/mid-x86/sst_platform.c b/sound/soc/mid-x86/sst_platform.c index d567c322a2f..6b1f9d3bf34 100644 --- a/sound/soc/mid-x86/sst_platform.c +++ b/sound/soc/mid-x86/sst_platform.c | |||
@@ -376,6 +376,11 @@ static int sst_platform_pcm_hw_params(struct snd_pcm_substream *substream, | |||
376 | return 0; | 376 | return 0; |
377 | } | 377 | } |
378 | 378 | ||
379 | static int sst_platform_pcm_hw_free(struct snd_pcm_substream *substream) | ||
380 | { | ||
381 | return snd_pcm_lib_free_pages(substream); | ||
382 | } | ||
383 | |||
379 | static struct snd_pcm_ops sst_platform_ops = { | 384 | static struct snd_pcm_ops sst_platform_ops = { |
380 | .open = sst_platform_open, | 385 | .open = sst_platform_open, |
381 | .close = sst_platform_close, | 386 | .close = sst_platform_close, |
@@ -384,6 +389,7 @@ static struct snd_pcm_ops sst_platform_ops = { | |||
384 | .trigger = sst_platform_pcm_trigger, | 389 | .trigger = sst_platform_pcm_trigger, |
385 | .pointer = sst_platform_pcm_pointer, | 390 | .pointer = sst_platform_pcm_pointer, |
386 | .hw_params = sst_platform_pcm_hw_params, | 391 | .hw_params = sst_platform_pcm_hw_params, |
392 | .hw_free = sst_platform_pcm_hw_free, | ||
387 | }; | 393 | }; |
388 | 394 | ||
389 | static void sst_pcm_free(struct snd_pcm *pcm) | 395 | static void sst_pcm_free(struct snd_pcm *pcm) |
diff --git a/sound/soc/samsung/goni_wm8994.c b/sound/soc/samsung/goni_wm8994.c index f6b3a3ce591..0e80daee8b6 100644 --- a/sound/soc/samsung/goni_wm8994.c +++ b/sound/soc/samsung/goni_wm8994.c | |||
@@ -236,18 +236,18 @@ static struct snd_soc_dai_link goni_dai[] = { | |||
236 | .name = "WM8994", | 236 | .name = "WM8994", |
237 | .stream_name = "WM8994 HiFi", | 237 | .stream_name = "WM8994 HiFi", |
238 | .cpu_dai_name = "samsung-i2s.0", | 238 | .cpu_dai_name = "samsung-i2s.0", |
239 | .codec_dai_name = "wm8994-hifi", | 239 | .codec_dai_name = "wm8994-aif1", |
240 | .platform_name = "samsung-audio", | 240 | .platform_name = "samsung-audio", |
241 | .codec_name = "wm8994-codec.0-0x1a", | 241 | .codec_name = "wm8994-codec.0-001a", |
242 | .init = goni_wm8994_init, | 242 | .init = goni_wm8994_init, |
243 | .ops = &goni_hifi_ops, | 243 | .ops = &goni_hifi_ops, |
244 | }, { | 244 | }, { |
245 | .name = "WM8994 Voice", | 245 | .name = "WM8994 Voice", |
246 | .stream_name = "Voice", | 246 | .stream_name = "Voice", |
247 | .cpu_dai_name = "goni-voice-dai", | 247 | .cpu_dai_name = "goni-voice-dai", |
248 | .codec_dai_name = "wm8994-voice", | 248 | .codec_dai_name = "wm8994-aif2", |
249 | .platform_name = "samsung-audio", | 249 | .platform_name = "samsung-audio", |
250 | .codec_name = "wm8994-codec.0-0x1a", | 250 | .codec_name = "wm8994-codec.0-001a", |
251 | .ops = &goni_voice_ops, | 251 | .ops = &goni_voice_ops, |
252 | }, | 252 | }, |
253 | }; | 253 | }; |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d8562ce4de7..dd55d106946 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -3291,6 +3291,8 @@ int snd_soc_register_card(struct snd_soc_card *card) | |||
3291 | if (!card->name || !card->dev) | 3291 | if (!card->name || !card->dev) |
3292 | return -EINVAL; | 3292 | return -EINVAL; |
3293 | 3293 | ||
3294 | dev_set_drvdata(card->dev, card); | ||
3295 | |||
3294 | snd_soc_initialize_card_lists(card); | 3296 | snd_soc_initialize_card_lists(card); |
3295 | 3297 | ||
3296 | soc_init_card_debugfs(card); | 3298 | soc_init_card_debugfs(card); |
diff --git a/sound/usb/format.c b/sound/usb/format.c index 5b792d2c806..f079b5e2ab2 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c | |||
@@ -176,9 +176,11 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof | |||
176 | if (!rate) | 176 | if (!rate) |
177 | continue; | 177 | continue; |
178 | /* C-Media CM6501 mislabels its 96 kHz altsetting */ | 178 | /* C-Media CM6501 mislabels its 96 kHz altsetting */ |
179 | /* Terratec Aureon 7.1 USB C-Media 6206, too */ | ||
179 | if (rate == 48000 && nr_rates == 1 && | 180 | if (rate == 48000 && nr_rates == 1 && |
180 | (chip->usb_id == USB_ID(0x0d8c, 0x0201) || | 181 | (chip->usb_id == USB_ID(0x0d8c, 0x0201) || |
181 | chip->usb_id == USB_ID(0x0d8c, 0x0102)) && | 182 | chip->usb_id == USB_ID(0x0d8c, 0x0102) || |
183 | chip->usb_id == USB_ID(0x0ccd, 0x00b1)) && | ||
182 | fp->altsetting == 5 && fp->maxpacksize == 392) | 184 | fp->altsetting == 5 && fp->maxpacksize == 392) |
183 | rate = 96000; | 185 | rate = 96000; |
184 | /* Creative VF0470 Live Cam reports 16 kHz instead of 8kHz */ | 186 | /* Creative VF0470 Live Cam reports 16 kHz instead of 8kHz */ |
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index ec07e62e53f..1b94ec3a336 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c | |||
@@ -533,6 +533,7 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev, | |||
533 | 533 | ||
534 | case USB_ID(0x0d8c, 0x0102): | 534 | case USB_ID(0x0d8c, 0x0102): |
535 | /* C-Media CM6206 / CM106-Like Sound Device */ | 535 | /* C-Media CM6206 / CM106-Like Sound Device */ |
536 | case USB_ID(0x0ccd, 0x00b1): /* Terratec Aureon 7.1 USB */ | ||
536 | return snd_usb_cm6206_boot_quirk(dev); | 537 | return snd_usb_cm6206_boot_quirk(dev); |
537 | 538 | ||
538 | case USB_ID(0x133e, 0x0815): | 539 | case USB_ID(0x133e, 0x0815): |
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 207dee5c5b1..0c542563ea6 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -35,15 +35,21 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ | |||
35 | -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ | 35 | -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ |
36 | -e s/sh[234].*/sh/ ) | 36 | -e s/sh[234].*/sh/ ) |
37 | 37 | ||
38 | CC = $(CROSS_COMPILE)gcc | ||
39 | AR = $(CROSS_COMPILE)ar | ||
40 | |||
38 | # Additional ARCH settings for x86 | 41 | # Additional ARCH settings for x86 |
39 | ifeq ($(ARCH),i386) | 42 | ifeq ($(ARCH),i386) |
40 | ARCH := x86 | 43 | ARCH := x86 |
41 | endif | 44 | endif |
42 | ifeq ($(ARCH),x86_64) | 45 | ifeq ($(ARCH),x86_64) |
43 | RAW_ARCH := x86_64 | 46 | ARCH := x86 |
44 | ARCH := x86 | 47 | IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1) |
45 | ARCH_CFLAGS := -DARCH_X86_64 | 48 | ifeq (${IS_X86_64}, 1) |
46 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S | 49 | RAW_ARCH := x86_64 |
50 | ARCH_CFLAGS := -DARCH_X86_64 | ||
51 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S | ||
52 | endif | ||
47 | endif | 53 | endif |
48 | 54 | ||
49 | # | 55 | # |
@@ -119,8 +125,6 @@ lib = lib | |||
119 | 125 | ||
120 | export prefix bindir sharedir sysconfdir | 126 | export prefix bindir sharedir sysconfdir |
121 | 127 | ||
122 | CC = $(CROSS_COMPILE)gcc | ||
123 | AR = $(CROSS_COMPILE)ar | ||
124 | RM = rm -f | 128 | RM = rm -f |
125 | MKDIR = mkdir | 129 | MKDIR = mkdir |
126 | FIND = find | 130 | FIND = find |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 416538248a4..0974f957b8f 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -427,7 +427,7 @@ static void mmap_read_all(void) | |||
427 | { | 427 | { |
428 | int i; | 428 | int i; |
429 | 429 | ||
430 | for (i = 0; i < evsel_list->cpus->nr; i++) { | 430 | for (i = 0; i < evsel_list->nr_mmaps; i++) { |
431 | if (evsel_list->mmap[i].base) | 431 | if (evsel_list->mmap[i].base) |
432 | mmap_read(&evsel_list->mmap[i]); | 432 | mmap_read(&evsel_list->mmap[i]); |
433 | } | 433 | } |
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 11e3c845836..2f9a337b182 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -549,7 +549,7 @@ static int test__basic_mmap(void) | |||
549 | ++foo; | 549 | ++foo; |
550 | } | 550 | } |
551 | 551 | ||
552 | while ((event = perf_evlist__read_on_cpu(evlist, 0)) != NULL) { | 552 | while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) { |
553 | struct perf_sample sample; | 553 | struct perf_sample sample; |
554 | 554 | ||
555 | if (event->header.type != PERF_RECORD_SAMPLE) { | 555 | if (event->header.type != PERF_RECORD_SAMPLE) { |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 7e3d6e310bf..ebfc7cf5f63 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -801,12 +801,12 @@ static void perf_event__process_sample(const union perf_event *event, | |||
801 | } | 801 | } |
802 | } | 802 | } |
803 | 803 | ||
804 | static void perf_session__mmap_read_cpu(struct perf_session *self, int cpu) | 804 | static void perf_session__mmap_read_idx(struct perf_session *self, int idx) |
805 | { | 805 | { |
806 | struct perf_sample sample; | 806 | struct perf_sample sample; |
807 | union perf_event *event; | 807 | union perf_event *event; |
808 | 808 | ||
809 | while ((event = perf_evlist__read_on_cpu(top.evlist, cpu)) != NULL) { | 809 | while ((event = perf_evlist__mmap_read(top.evlist, idx)) != NULL) { |
810 | perf_session__parse_sample(self, event, &sample); | 810 | perf_session__parse_sample(self, event, &sample); |
811 | 811 | ||
812 | if (event->header.type == PERF_RECORD_SAMPLE) | 812 | if (event->header.type == PERF_RECORD_SAMPLE) |
@@ -820,8 +820,8 @@ static void perf_session__mmap_read(struct perf_session *self) | |||
820 | { | 820 | { |
821 | int i; | 821 | int i; |
822 | 822 | ||
823 | for (i = 0; i < top.evlist->cpus->nr; i++) | 823 | for (i = 0; i < top.evlist->nr_mmaps; i++) |
824 | perf_session__mmap_read_cpu(self, i); | 824 | perf_session__mmap_read_idx(self, i); |
825 | } | 825 | } |
826 | 826 | ||
827 | static void start_counters(struct perf_evlist *evlist) | 827 | static void start_counters(struct perf_evlist *evlist) |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 45da8d186b4..23eb22b05d2 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -166,11 +166,11 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) | |||
166 | return NULL; | 166 | return NULL; |
167 | } | 167 | } |
168 | 168 | ||
169 | union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) | 169 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx) |
170 | { | 170 | { |
171 | /* XXX Move this to perf.c, making it generally available */ | 171 | /* XXX Move this to perf.c, making it generally available */ |
172 | unsigned int page_size = sysconf(_SC_PAGE_SIZE); | 172 | unsigned int page_size = sysconf(_SC_PAGE_SIZE); |
173 | struct perf_mmap *md = &evlist->mmap[cpu]; | 173 | struct perf_mmap *md = &evlist->mmap[idx]; |
174 | unsigned int head = perf_mmap__read_head(md); | 174 | unsigned int head = perf_mmap__read_head(md); |
175 | unsigned int old = md->prev; | 175 | unsigned int old = md->prev; |
176 | unsigned char *data = md->base + page_size; | 176 | unsigned char *data = md->base + page_size; |
@@ -235,31 +235,37 @@ union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) | |||
235 | 235 | ||
236 | void perf_evlist__munmap(struct perf_evlist *evlist) | 236 | void perf_evlist__munmap(struct perf_evlist *evlist) |
237 | { | 237 | { |
238 | int cpu; | 238 | int i; |
239 | 239 | ||
240 | for (cpu = 0; cpu < evlist->cpus->nr; cpu++) { | 240 | for (i = 0; i < evlist->nr_mmaps; i++) { |
241 | if (evlist->mmap[cpu].base != NULL) { | 241 | if (evlist->mmap[i].base != NULL) { |
242 | munmap(evlist->mmap[cpu].base, evlist->mmap_len); | 242 | munmap(evlist->mmap[i].base, evlist->mmap_len); |
243 | evlist->mmap[cpu].base = NULL; | 243 | evlist->mmap[i].base = NULL; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | |||
247 | free(evlist->mmap); | ||
248 | evlist->mmap = NULL; | ||
246 | } | 249 | } |
247 | 250 | ||
248 | int perf_evlist__alloc_mmap(struct perf_evlist *evlist) | 251 | int perf_evlist__alloc_mmap(struct perf_evlist *evlist) |
249 | { | 252 | { |
250 | evlist->mmap = zalloc(evlist->cpus->nr * sizeof(struct perf_mmap)); | 253 | evlist->nr_mmaps = evlist->cpus->nr; |
254 | if (evlist->cpus->map[0] == -1) | ||
255 | evlist->nr_mmaps = evlist->threads->nr; | ||
256 | evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap)); | ||
251 | return evlist->mmap != NULL ? 0 : -ENOMEM; | 257 | return evlist->mmap != NULL ? 0 : -ENOMEM; |
252 | } | 258 | } |
253 | 259 | ||
254 | static int __perf_evlist__mmap(struct perf_evlist *evlist, struct perf_evsel *evsel, | 260 | static int __perf_evlist__mmap(struct perf_evlist *evlist, struct perf_evsel *evsel, |
255 | int cpu, int prot, int mask, int fd) | 261 | int idx, int prot, int mask, int fd) |
256 | { | 262 | { |
257 | evlist->mmap[cpu].prev = 0; | 263 | evlist->mmap[idx].prev = 0; |
258 | evlist->mmap[cpu].mask = mask; | 264 | evlist->mmap[idx].mask = mask; |
259 | evlist->mmap[cpu].base = mmap(NULL, evlist->mmap_len, prot, | 265 | evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot, |
260 | MAP_SHARED, fd, 0); | 266 | MAP_SHARED, fd, 0); |
261 | if (evlist->mmap[cpu].base == MAP_FAILED) { | 267 | if (evlist->mmap[idx].base == MAP_FAILED) { |
262 | if (evlist->cpus->map[cpu] == -1 && evsel->attr.inherit) | 268 | if (evlist->cpus->map[idx] == -1 && evsel->attr.inherit) |
263 | ui__warning("Inherit is not allowed on per-task " | 269 | ui__warning("Inherit is not allowed on per-task " |
264 | "events using mmap.\n"); | 270 | "events using mmap.\n"); |
265 | return -1; | 271 | return -1; |
@@ -269,6 +275,86 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, struct perf_evsel *ev | |||
269 | return 0; | 275 | return 0; |
270 | } | 276 | } |
271 | 277 | ||
278 | static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int mask) | ||
279 | { | ||
280 | struct perf_evsel *evsel; | ||
281 | int cpu, thread; | ||
282 | |||
283 | for (cpu = 0; cpu < evlist->cpus->nr; cpu++) { | ||
284 | int output = -1; | ||
285 | |||
286 | for (thread = 0; thread < evlist->threads->nr; thread++) { | ||
287 | list_for_each_entry(evsel, &evlist->entries, node) { | ||
288 | int fd = FD(evsel, cpu, thread); | ||
289 | |||
290 | if (output == -1) { | ||
291 | output = fd; | ||
292 | if (__perf_evlist__mmap(evlist, evsel, cpu, | ||
293 | prot, mask, output) < 0) | ||
294 | goto out_unmap; | ||
295 | } else { | ||
296 | if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, output) != 0) | ||
297 | goto out_unmap; | ||
298 | } | ||
299 | |||
300 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && | ||
301 | perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0) | ||
302 | goto out_unmap; | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | |||
307 | return 0; | ||
308 | |||
309 | out_unmap: | ||
310 | for (cpu = 0; cpu < evlist->cpus->nr; cpu++) { | ||
311 | if (evlist->mmap[cpu].base != NULL) { | ||
312 | munmap(evlist->mmap[cpu].base, evlist->mmap_len); | ||
313 | evlist->mmap[cpu].base = NULL; | ||
314 | } | ||
315 | } | ||
316 | return -1; | ||
317 | } | ||
318 | |||
319 | static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, int mask) | ||
320 | { | ||
321 | struct perf_evsel *evsel; | ||
322 | int thread; | ||
323 | |||
324 | for (thread = 0; thread < evlist->threads->nr; thread++) { | ||
325 | int output = -1; | ||
326 | |||
327 | list_for_each_entry(evsel, &evlist->entries, node) { | ||
328 | int fd = FD(evsel, 0, thread); | ||
329 | |||
330 | if (output == -1) { | ||
331 | output = fd; | ||
332 | if (__perf_evlist__mmap(evlist, evsel, thread, | ||
333 | prot, mask, output) < 0) | ||
334 | goto out_unmap; | ||
335 | } else { | ||
336 | if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, output) != 0) | ||
337 | goto out_unmap; | ||
338 | } | ||
339 | |||
340 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && | ||
341 | perf_evlist__id_add_fd(evlist, evsel, 0, thread, fd) < 0) | ||
342 | goto out_unmap; | ||
343 | } | ||
344 | } | ||
345 | |||
346 | return 0; | ||
347 | |||
348 | out_unmap: | ||
349 | for (thread = 0; thread < evlist->threads->nr; thread++) { | ||
350 | if (evlist->mmap[thread].base != NULL) { | ||
351 | munmap(evlist->mmap[thread].base, evlist->mmap_len); | ||
352 | evlist->mmap[thread].base = NULL; | ||
353 | } | ||
354 | } | ||
355 | return -1; | ||
356 | } | ||
357 | |||
272 | /** perf_evlist__mmap - Create per cpu maps to receive events | 358 | /** perf_evlist__mmap - Create per cpu maps to receive events |
273 | * | 359 | * |
274 | * @evlist - list of events | 360 | * @evlist - list of events |
@@ -287,11 +373,11 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, struct perf_evsel *ev | |||
287 | int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite) | 373 | int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite) |
288 | { | 374 | { |
289 | unsigned int page_size = sysconf(_SC_PAGE_SIZE); | 375 | unsigned int page_size = sysconf(_SC_PAGE_SIZE); |
290 | int mask = pages * page_size - 1, cpu; | 376 | int mask = pages * page_size - 1; |
291 | struct perf_evsel *first_evsel, *evsel; | 377 | struct perf_evsel *evsel; |
292 | const struct cpu_map *cpus = evlist->cpus; | 378 | const struct cpu_map *cpus = evlist->cpus; |
293 | const struct thread_map *threads = evlist->threads; | 379 | const struct thread_map *threads = evlist->threads; |
294 | int thread, prot = PROT_READ | (overwrite ? 0 : PROT_WRITE); | 380 | int prot = PROT_READ | (overwrite ? 0 : PROT_WRITE); |
295 | 381 | ||
296 | if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist) < 0) | 382 | if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist) < 0) |
297 | return -ENOMEM; | 383 | return -ENOMEM; |
@@ -301,43 +387,18 @@ int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite) | |||
301 | 387 | ||
302 | evlist->overwrite = overwrite; | 388 | evlist->overwrite = overwrite; |
303 | evlist->mmap_len = (pages + 1) * page_size; | 389 | evlist->mmap_len = (pages + 1) * page_size; |
304 | first_evsel = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
305 | 390 | ||
306 | list_for_each_entry(evsel, &evlist->entries, node) { | 391 | list_for_each_entry(evsel, &evlist->entries, node) { |
307 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && | 392 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && |
308 | evsel->sample_id == NULL && | 393 | evsel->sample_id == NULL && |
309 | perf_evsel__alloc_id(evsel, cpus->nr, threads->nr) < 0) | 394 | perf_evsel__alloc_id(evsel, cpus->nr, threads->nr) < 0) |
310 | return -ENOMEM; | 395 | return -ENOMEM; |
311 | |||
312 | for (cpu = 0; cpu < cpus->nr; cpu++) { | ||
313 | for (thread = 0; thread < threads->nr; thread++) { | ||
314 | int fd = FD(evsel, cpu, thread); | ||
315 | |||
316 | if (evsel->idx || thread) { | ||
317 | if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, | ||
318 | FD(first_evsel, cpu, 0)) != 0) | ||
319 | goto out_unmap; | ||
320 | } else if (__perf_evlist__mmap(evlist, evsel, cpu, | ||
321 | prot, mask, fd) < 0) | ||
322 | goto out_unmap; | ||
323 | |||
324 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && | ||
325 | perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0) | ||
326 | goto out_unmap; | ||
327 | } | ||
328 | } | ||
329 | } | 396 | } |
330 | 397 | ||
331 | return 0; | 398 | if (evlist->cpus->map[0] == -1) |
399 | return perf_evlist__mmap_per_thread(evlist, prot, mask); | ||
332 | 400 | ||
333 | out_unmap: | 401 | return perf_evlist__mmap_per_cpu(evlist, prot, mask); |
334 | for (cpu = 0; cpu < cpus->nr; cpu++) { | ||
335 | if (evlist->mmap[cpu].base != NULL) { | ||
336 | munmap(evlist->mmap[cpu].base, evlist->mmap_len); | ||
337 | evlist->mmap[cpu].base = NULL; | ||
338 | } | ||
339 | } | ||
340 | return -1; | ||
341 | } | 402 | } |
342 | 403 | ||
343 | int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid, | 404 | int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid, |
@@ -348,7 +409,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid, | |||
348 | if (evlist->threads == NULL) | 409 | if (evlist->threads == NULL) |
349 | return -1; | 410 | return -1; |
350 | 411 | ||
351 | if (target_tid != -1) | 412 | if (cpu_list == NULL && target_tid != -1) |
352 | evlist->cpus = cpu_map__dummy_new(); | 413 | evlist->cpus = cpu_map__dummy_new(); |
353 | else | 414 | else |
354 | evlist->cpus = cpu_map__new(cpu_list); | 415 | evlist->cpus = cpu_map__new(cpu_list); |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 8b1cb7a4c5f..7109d7add14 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -17,6 +17,7 @@ struct perf_evlist { | |||
17 | struct hlist_head heads[PERF_EVLIST__HLIST_SIZE]; | 17 | struct hlist_head heads[PERF_EVLIST__HLIST_SIZE]; |
18 | int nr_entries; | 18 | int nr_entries; |
19 | int nr_fds; | 19 | int nr_fds; |
20 | int nr_mmaps; | ||
20 | int mmap_len; | 21 | int mmap_len; |
21 | bool overwrite; | 22 | bool overwrite; |
22 | union perf_event event_copy; | 23 | union perf_event event_copy; |
@@ -46,7 +47,7 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); | |||
46 | 47 | ||
47 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); | 48 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); |
48 | 49 | ||
49 | union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu); | 50 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx); |
50 | 51 | ||
51 | int perf_evlist__alloc_mmap(struct perf_evlist *evlist); | 52 | int perf_evlist__alloc_mmap(struct perf_evlist *evlist); |
52 | int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite); | 53 | int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite); |
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index f5e38451fdc..99c722672f8 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -680,7 +680,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, | |||
680 | &cpu, &sample_id_all)) | 680 | &cpu, &sample_id_all)) |
681 | return NULL; | 681 | return NULL; |
682 | 682 | ||
683 | event = perf_evlist__read_on_cpu(evlist, cpu); | 683 | event = perf_evlist__mmap_read(evlist, cpu); |
684 | if (event != NULL) { | 684 | if (event != NULL) { |
685 | struct perf_evsel *first; | 685 | struct perf_evsel *first; |
686 | PyObject *pyevent = pyrf_event__new(event); | 686 | PyObject *pyevent = pyrf_event__new(event); |