Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'v3.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into for-linus

+2397 -1230
+4 -1
Documentation/kernel-parameters.txt
··· 999 999 With this option on every unmap_single operation will 1000 1000 result in a hardware IOTLB flush operation as opposed 1001 1001 to batching them for performance. 1002 - 1002 + sp_off [Default Off] 1003 + By default, super page will be supported if Intel IOMMU 1004 + has the capability. With this option, super page will 1005 + not be supported. 1003 1006 intremap= [X86-64, Intel-IOMMU] 1004 1007 Format: { on (default) | off | nosid } 1005 1008 on enable Interrupt Remapping (default)
+1 -1
Documentation/virtual/lguest/Makefile
··· 1 1 # This creates the demonstration utility "lguest" which runs a Linux guest. 2 - # Missing headers? Add "-I../../include -I../../arch/x86/include" 2 + # Missing headers? Add "-I../../../include -I../../../arch/x86/include" 3 3 CFLAGS:=-m32 -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -U_FORTIFY_SOURCE 4 4 5 5 all: lguest
+2 -20
Documentation/virtual/lguest/lguest.c
··· 49 49 #include <linux/virtio_rng.h> 50 50 #include <linux/virtio_ring.h> 51 51 #include <asm/bootparam.h> 52 - #include "../../include/linux/lguest_launcher.h" 52 + #include "../../../include/linux/lguest_launcher.h" 53 53 /*L:110 54 54 * We can ignore the 42 include files we need for this program, but I do want 55 55 * to draw attention to the use of kernel-style types. ··· 134 134 135 135 /* Is it operational */ 136 136 bool running; 137 - 138 - /* Does Guest want an intrrupt on empty? */ 139 - bool irq_on_empty; 140 137 141 138 /* Device-specific data. */ 142 139 void *priv; ··· 634 637 635 638 /* If they don't want an interrupt, don't send one... */ 636 639 if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) { 637 - /* ... unless they've asked us to force one on empty. */ 638 - if (!vq->dev->irq_on_empty 639 - || lg_last_avail(vq) != vq->vring.avail->idx) 640 - return; 640 + return; 641 641 } 642 642 643 643 /* Send the Guest an interrupt tell them we used something up. */ ··· 1051 1057 close(vq->eventfd); 1052 1058 } 1053 1059 1054 - static bool accepted_feature(struct device *dev, unsigned int bit) 1055 - { 1056 - const u8 *features = get_feature_bits(dev) + dev->feature_len; 1057 - 1058 - if (dev->feature_len < bit / CHAR_BIT) 1059 - return false; 1060 - return features[bit / CHAR_BIT] & (1 << (bit % CHAR_BIT)); 1061 - } 1062 - 1063 1060 static void start_device(struct device *dev) 1064 1061 { 1065 1062 unsigned int i; ··· 1063 1078 for (i = 0; i < dev->feature_len; i++) 1064 1079 verbose(" %02x", get_feature_bits(dev) 1065 1080 [dev->feature_len+i]); 1066 - 1067 - dev->irq_on_empty = accepted_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY); 1068 1081 1069 1082 for (vq = dev->vq; vq; vq = vq->next) { 1070 1083 if (vq->service) ··· 1547 1564 /* Set up the tun device. */ 1548 1565 configure_device(ipfd, tapif, ip); 1549 1566 1550 - add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY); 1551 1567 /* Expect Guest to handle everything except UFO */ 1552 1568 add_feature(dev, VIRTIO_NET_F_CSUM); 1553 1569 add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
+1 -1
Makefile
··· 1 1 VERSION = 3 2 2 PATCHLEVEL = 0 3 3 SUBLEVEL = 0 4 - EXTRAVERSION = -rc1 4 + EXTRAVERSION = -rc2 5 5 NAME = Sneaky Weasel 6 6 7 7 # *DOCUMENTATION*
+56
arch/arm/mach-shmobile/board-ap4evb.c
··· 249 249 { 250 250 return !gpio_get_value(GPIO_PORT41); 251 251 } 252 + /* MERAM */ 253 + static struct sh_mobile_meram_info meram_info = { 254 + .addr_mode = SH_MOBILE_MERAM_MODE1, 255 + }; 256 + 257 + static struct resource meram_resources[] = { 258 + [0] = { 259 + .name = "MERAM", 260 + .start = 0xe8000000, 261 + .end = 0xe81fffff, 262 + .flags = IORESOURCE_MEM, 263 + }, 264 + }; 265 + 266 + static struct platform_device meram_device = { 267 + .name = "sh_mobile_meram", 268 + .id = 0, 269 + .num_resources = ARRAY_SIZE(meram_resources), 270 + .resource = meram_resources, 271 + .dev = { 272 + .platform_data = &meram_info, 273 + }, 274 + }; 252 275 253 276 /* SH_MMCIF */ 254 277 static struct resource sh_mmcif_resources[] = { ··· 470 447 #endif 471 448 }, 472 449 }; 450 + static struct sh_mobile_meram_cfg lcd_meram_cfg = { 451 + .icb[0] = { 452 + .marker_icb = 28, 453 + .cache_icb = 24, 454 + .meram_offset = 0x0, 455 + .meram_size = 0x40, 456 + }, 457 + .icb[1] = { 458 + .marker_icb = 29, 459 + .cache_icb = 25, 460 + .meram_offset = 0x40, 461 + .meram_size = 0x40, 462 + }, 463 + }; 473 464 474 465 static struct sh_mobile_lcdc_info lcdc_info = { 466 + .meram_dev = &meram_info, 475 467 .ch[0] = { 476 468 .chan = LCDC_CHAN_MAINLCD, 477 469 .bpp = 16, 478 470 .lcd_cfg = ap4evb_lcdc_modes, 479 471 .num_cfg = ARRAY_SIZE(ap4evb_lcdc_modes), 472 + .meram_cfg = &lcd_meram_cfg, 480 473 } 481 474 }; 482 475 ··· 763 724 static struct platform_device fsi_ak4643_device = { 764 725 .name = "sh_fsi2_a_ak4643", 765 726 }; 727 + static struct sh_mobile_meram_cfg hdmi_meram_cfg = { 728 + .icb[0] = { 729 + .marker_icb = 30, 730 + .cache_icb = 26, 731 + .meram_offset = 0x80, 732 + .meram_size = 0x100, 733 + }, 734 + .icb[1] = { 735 + .marker_icb = 31, 736 + .cache_icb = 27, 737 + .meram_offset = 0x180, 738 + .meram_size = 0x100, 739 + }, 740 + }; 766 741 767 742 static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = { 768 743 .clock_source = LCDC_CLK_EXTERNAL, 744 + .meram_dev = &meram_info, 769 745 .ch[0] = { 770 746 .chan = LCDC_CHAN_MAINLCD, 771 747 .bpp = 16, 772 748 .interface_type = RGB24, 773 749 .clock_divider = 1, 774 750 .flags = LCDC_FLAGS_DWPOL, 751 + .meram_cfg = &hdmi_meram_cfg, 775 752 } 776 753 }; 777 754 ··· 1016 961 &csi2_device, 1017 962 &ceu_device, 1018 963 &ap4evb_camera, 964 + &meram_device, 1019 965 }; 1020 966 1021 967 static void __init hdmi_init_pm_clock(void)
+78
arch/arm/mach-shmobile/board-mackerel.c
··· 39 39 #include <linux/mtd/mtd.h> 40 40 #include <linux/mtd/partitions.h> 41 41 #include <linux/mtd/physmap.h> 42 + #include <linux/pm_runtime.h> 42 43 #include <linux/smsc911x.h> 43 44 #include <linux/sh_intc.h> 44 45 #include <linux/tca6416_keypad.h> ··· 315 314 }, 316 315 }; 317 316 317 + /* MERAM */ 318 + static struct sh_mobile_meram_info mackerel_meram_info = { 319 + .addr_mode = SH_MOBILE_MERAM_MODE1, 320 + }; 321 + 322 + static struct resource meram_resources[] = { 323 + [0] = { 324 + .name = "MERAM", 325 + .start = 0xe8000000, 326 + .end = 0xe81fffff, 327 + .flags = IORESOURCE_MEM, 328 + }, 329 + }; 330 + 331 + static struct platform_device meram_device = { 332 + .name = "sh_mobile_meram", 333 + .id = 0, 334 + .num_resources = ARRAY_SIZE(meram_resources), 335 + .resource = meram_resources, 336 + .dev = { 337 + .platform_data = &mackerel_meram_info, 338 + }, 339 + }; 340 + 318 341 /* LCDC */ 319 342 static struct fb_videomode mackerel_lcdc_modes[] = { 320 343 { ··· 367 342 return gpio_get_value(GPIO_PORT31); 368 343 } 369 344 345 + static struct sh_mobile_meram_cfg lcd_meram_cfg = { 346 + .icb[0] = { 347 + .marker_icb = 28, 348 + .cache_icb = 24, 349 + .meram_offset = 0x0, 350 + .meram_size = 0x40, 351 + }, 352 + .icb[1] = { 353 + .marker_icb = 29, 354 + .cache_icb = 25, 355 + .meram_offset = 0x40, 356 + .meram_size = 0x40, 357 + }, 358 + }; 359 + 370 360 static struct sh_mobile_lcdc_info lcdc_info = { 361 + .meram_dev = &mackerel_meram_info, 371 362 .clock_source = LCDC_CLK_BUS, 372 363 .ch[0] = { 373 364 .chan = LCDC_CHAN_MAINLCD, ··· 403 362 .name = "sh_mobile_lcdc_bl", 404 363 .max_brightness = 1, 405 364 }, 365 + .meram_cfg = &lcd_meram_cfg, 406 366 } 407 367 }; 408 368 ··· 430 388 }, 431 389 }; 432 390 391 + static struct sh_mobile_meram_cfg hdmi_meram_cfg = { 392 + .icb[0] = { 393 + .marker_icb = 30, 394 + .cache_icb = 26, 395 + .meram_offset = 0x80, 396 + .meram_size = 0x100, 397 + }, 398 + .icb[1] = { 399 + .marker_icb = 31, 400 + .cache_icb = 27, 401 + .meram_offset = 0x180, 402 + .meram_size = 0x100, 403 + }, 404 + }; 433 405 /* HDMI */ 434 406 static struct sh_mobile_lcdc_info hdmi_lcdc_info = { 407 + .meram_dev = &mackerel_meram_info, 435 408 .clock_source = LCDC_CLK_EXTERNAL, 436 409 .ch[0] = { 437 410 .chan = LCDC_CHAN_MAINLCD, ··· 454 397 .interface_type = RGB24, 455 398 .clock_divider = 1, 456 399 .flags = LCDC_FLAGS_DWPOL, 400 + .meram_cfg = &hdmi_meram_cfg, 457 401 } 458 402 }; 459 403 ··· 914 856 } 915 857 916 858 /* SDHI0 */ 859 + static irqreturn_t mackerel_sdhi0_gpio_cd(int irq, void *arg) 860 + { 861 + struct device *dev = arg; 862 + struct sh_mobile_sdhi_info *info = dev->platform_data; 863 + struct tmio_mmc_data *pdata = info->pdata; 864 + 865 + tmio_mmc_cd_wakeup(pdata); 866 + 867 + return IRQ_HANDLED; 868 + } 869 + 917 870 static struct sh_mobile_sdhi_info sdhi0_info = { 918 871 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, 919 872 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, ··· 1219 1150 &mackerel_camera, 1220 1151 &hdmi_lcdc_device, 1221 1152 &hdmi_device, 1153 + &meram_device, 1222 1154 }; 1223 1155 1224 1156 /* Keypad Initialization */ ··· 1308 1238 { 1309 1239 u32 srcr4; 1310 1240 struct clk *clk; 1241 + int ret; 1311 1242 1312 1243 sh7372_pinmux_init(); 1313 1244 ··· 1413 1342 gpio_request(GPIO_FN_SDHID0_2, NULL); 1414 1343 gpio_request(GPIO_FN_SDHID0_1, NULL); 1415 1344 gpio_request(GPIO_FN_SDHID0_0, NULL); 1345 + 1346 + ret = request_irq(evt2irq(0x3340), mackerel_sdhi0_gpio_cd, 1347 + IRQF_TRIGGER_FALLING, "sdhi0 cd", &sdhi0_device.dev); 1348 + if (!ret) 1349 + sdhi0_info.tmio_flags |= TMIO_MMC_HAS_COLD_CD; 1350 + else 1351 + pr_err("Cannot get IRQ #%d: %d\n", evt2irq(0x3340), ret); 1416 1352 1417 1353 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 1418 1354 /* enable SDHI1 */
+7
arch/arm/mach-shmobile/clock-sh7372.c
··· 509 509 MSTP118, MSTP117, MSTP116, MSTP113, 510 510 MSTP106, MSTP101, MSTP100, 511 511 MSTP223, 512 + MSTP218, MSTP217, MSTP216, 512 513 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 513 514 MSTP329, MSTP328, MSTP323, MSTP322, MSTP314, MSTP313, MSTP312, 514 515 MSTP423, MSTP415, MSTP413, MSTP411, MSTP410, MSTP406, MSTP403, ··· 535 534 [MSTP101] = MSTP(&div4_clks[DIV4_M1], SMSTPCR1, 1, 0), /* VPU */ 536 535 [MSTP100] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */ 537 536 [MSTP223] = MSTP(&div6_clks[DIV6_SPU], SMSTPCR2, 23, 0), /* SPU2 */ 537 + [MSTP218] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* DMAC1 */ 538 + [MSTP217] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 17, 0), /* DMAC2 */ 539 + [MSTP216] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 16, 0), /* DMAC3 */ 538 540 [MSTP207] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */ 539 541 [MSTP206] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */ 540 542 [MSTP204] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */ ··· 630 626 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[MSTP100]), /* LCDC0 */ 631 627 CLKDEV_DEV_ID("uio_pdrv_genirq.6", &mstp_clks[MSTP223]), /* SPU2DSP0 */ 632 628 CLKDEV_DEV_ID("uio_pdrv_genirq.7", &mstp_clks[MSTP223]), /* SPU2DSP1 */ 629 + CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]), /* DMAC1 */ 630 + CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[MSTP217]), /* DMAC2 */ 631 + CLKDEV_DEV_ID("sh-dma-engine.2", &mstp_clks[MSTP216]), /* DMAC3 */ 633 632 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), /* SCIFA5 */ 634 633 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP206]), /* SCIFB */ 635 634 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), /* SCIFA0 */
+3 -1
arch/arm/mach-tegra/board-harmony-power.c
··· 24 24 25 25 #include <mach/irqs.h> 26 26 27 + #include "board-harmony.h" 28 + 27 29 #define PMC_CTRL 0x0 28 30 #define PMC_CTRL_INTR_LOW (1 << 17) 29 31 ··· 100 98 .irq_base = TEGRA_NR_IRQS, 101 99 .num_subdevs = ARRAY_SIZE(tps_devs), 102 100 .subdevs = tps_devs, 103 - .gpio_base = TEGRA_NR_GPIOS, 101 + .gpio_base = HARMONY_GPIO_TPS6586X(0), 104 102 }; 105 103 106 104 static struct i2c_board_info __initdata harmony_regulators[] = {
+2 -1
arch/arm/mach-tegra/board-harmony.h
··· 17 17 #ifndef _MACH_TEGRA_BOARD_HARMONY_H 18 18 #define _MACH_TEGRA_BOARD_HARMONY_H 19 19 20 - #define HARMONY_GPIO_WM8903(_x_) (TEGRA_NR_GPIOS + (_x_)) 20 + #define HARMONY_GPIO_TPS6586X(_x_) (TEGRA_NR_GPIOS + (_x_)) 21 + #define HARMONY_GPIO_WM8903(_x_) (HARMONY_GPIO_TPS6586X(4) + (_x_)) 21 22 22 23 #define TEGRA_GPIO_SD2_CD TEGRA_GPIO_PI5 23 24 #define TEGRA_GPIO_SD2_WP TEGRA_GPIO_PH1
+1 -1
arch/blackfin/lib/strncpy.S
··· 25 25 26 26 ENTRY(_strncpy) 27 27 CC = R2 == 0; 28 - if CC JUMP 4f; 28 + if CC JUMP 6f; 29 29 30 30 P2 = R2 ; /* size */ 31 31 P0 = R0 ; /* dst*/
+2 -1
arch/ia64/include/asm/unistd.h
··· 320 320 #define __NR_clock_adjtime 1328 321 321 #define __NR_syncfs 1329 322 322 #define __NR_setns 1330 323 + #define __NR_sendmmsg 1331 323 324 324 325 #ifdef __KERNEL__ 325 326 326 327 327 - #define NR_syscalls 307 /* length of syscall table */ 328 + #define NR_syscalls 308 /* length of syscall table */ 328 329 329 330 /* 330 331 * The following defines stop scripts/checksyscalls.sh from complaining about
+1
arch/ia64/kernel/entry.S
··· 1776 1776 data8 sys_clock_adjtime 1777 1777 data8 sys_syncfs 1778 1778 data8 sys_setns // 1330 1779 + data8 sys_sendmmsg 1779 1780 1780 1781 .org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls 1781 1782 #endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */
+2 -1
arch/powerpc/platforms/powermac/pic.c
··· 715 715 716 716 static int __init init_pmacpic_syscore(void) 717 717 { 718 - register_syscore_ops(&pmacpic_syscore_ops); 718 + if (pmac_irq_hw[0]) 719 + register_syscore_ops(&pmacpic_syscore_ops); 719 720 return 0; 720 721 } 721 722
+1 -1
arch/sh/Kconfig
··· 161 161 162 162 config NO_IOPORT 163 163 def_bool !PCI 164 - depends on !SH_CAYMAN && !SH_SH4202_MICRODEV 164 + depends on !SH_CAYMAN && !SH_SH4202_MICRODEV && !SH_SHMIN 165 165 166 166 config IO_TRAPPED 167 167 bool
+14 -20
arch/sh/boards/mach-ap325rxa/setup.c
··· 359 359 .priv = &camera_info, 360 360 }; 361 361 362 - static void dummy_release(struct device *dev) 363 - { 364 - } 362 + static struct platform_device *camera_device; 365 363 366 - static struct platform_device camera_device = { 367 - .name = "soc_camera_platform", 368 - .dev = { 369 - .platform_data = &camera_info, 370 - .release = dummy_release, 371 - }, 372 - }; 364 + static void ap325rxa_camera_release(struct device *dev) 365 + { 366 + soc_camera_platform_release(&camera_device); 367 + } 373 368 374 369 static int ap325rxa_camera_add(struct soc_camera_link *icl, 375 370 struct device *dev) 376 371 { 377 - if (icl != &camera_link || camera_probe() <= 0) 378 - return -ENODEV; 372 + int ret = soc_camera_platform_add(icl, dev, &camera_device, &camera_link, 373 + ap325rxa_camera_release, 0); 374 + if (ret < 0) 375 + return ret; 379 376 380 - camera_info.dev = dev; 377 + ret = camera_probe(); 378 + if (ret < 0) 379 + soc_camera_platform_del(icl, camera_device, &camera_link); 381 380 382 - return platform_device_register(&camera_device); 381 + return ret; 383 382 } 384 383 385 384 static void ap325rxa_camera_del(struct soc_camera_link *icl) 386 385 { 387 - if (icl != &camera_link) 388 - return; 389 - 390 - platform_device_unregister(&camera_device); 391 - memset(&camera_device.dev.kobj, 0, 392 - sizeof(camera_device.dev.kobj)); 386 + soc_camera_platform_del(icl, camera_device, &camera_link); 393 387 } 394 388 #endif /* CONFIG_I2C */ 395 389
+3
arch/sh/boards/mach-ecovec24/setup.c
··· 885 885 }, 886 886 .num_resources = ARRAY_SIZE(sh_mmcif_resources), 887 887 .resource = sh_mmcif_resources, 888 + .archdata = { 889 + .hwblk_id = HWBLK_MMC, 890 + }, 888 891 }; 889 892 #endif 890 893
+1
arch/sh/include/asm/pgtable.h
··· 18 18 #include <asm/pgtable-2level.h> 19 19 #endif 20 20 #include <asm/page.h> 21 + #include <asm/mmu.h> 21 22 22 23 #ifndef __ASSEMBLY__ 23 24 #include <asm/addrspace.h>
+4 -2
arch/sh/include/asm/ptrace.h
··· 41 41 42 42 #define user_mode(regs) (((regs)->sr & 0x40000000)==0) 43 43 #define kernel_stack_pointer(_regs) ((unsigned long)(_regs)->regs[15]) 44 - #define GET_USP(regs) ((regs)->regs[15]) 44 + 45 + #define GET_FP(regs) ((regs)->regs[14]) 46 + #define GET_USP(regs) ((regs)->regs[15]) 45 47 46 48 extern void show_regs(struct pt_regs *); 47 49 ··· 133 131 134 132 static inline unsigned long profile_pc(struct pt_regs *regs) 135 133 { 136 - unsigned long pc = instruction_pointer(regs); 134 + unsigned long pc = regs->pc; 137 135 138 136 if (virt_addr_uncached(pc)) 139 137 return CAC_ADDR(pc);
+1
arch/sh/include/asm/tlb.h
··· 9 9 #include <linux/pagemap.h> 10 10 11 11 #ifdef CONFIG_MMU 12 + #include <linux/swap.h> 12 13 #include <asm/pgalloc.h> 13 14 #include <asm/tlbflush.h> 14 15 #include <asm/mmu_context.h>
+1
arch/sh/include/cpu-sh4/cpu/sh7722.h
··· 236 236 }; 237 237 238 238 enum { 239 + SHDMA_SLAVE_INVALID, 239 240 SHDMA_SLAVE_SCIF0_TX, 240 241 SHDMA_SLAVE_SCIF0_RX, 241 242 SHDMA_SLAVE_SCIF1_TX,
+1
arch/sh/include/cpu-sh4/cpu/sh7724.h
··· 285 285 }; 286 286 287 287 enum { 288 + SHDMA_SLAVE_INVALID, 288 289 SHDMA_SLAVE_SCIF0_TX, 289 290 SHDMA_SLAVE_SCIF0_RX, 290 291 SHDMA_SLAVE_SCIF1_TX,
+1
arch/sh/include/cpu-sh4/cpu/sh7757.h
··· 252 252 }; 253 253 254 254 enum { 255 + SHDMA_SLAVE_INVALID, 255 256 SHDMA_SLAVE_SDHI_TX, 256 257 SHDMA_SLAVE_SDHI_RX, 257 258 SHDMA_SLAVE_MMCIF_TX,
+1
arch/sh/kernel/process_32.c
··· 21 21 #include <linux/fs.h> 22 22 #include <linux/ftrace.h> 23 23 #include <linux/hw_breakpoint.h> 24 + #include <linux/prefetch.h> 24 25 #include <asm/uaccess.h> 25 26 #include <asm/mmu_context.h> 26 27 #include <asm/system.h>
+1 -1
arch/sh/mm/consistent.c
··· 82 82 void *addr; 83 83 84 84 addr = __in_29bit_mode() ? 85 - (void *)P1SEGADDR((unsigned long)vaddr) : vaddr; 85 + (void *)CAC_ADDR((unsigned long)vaddr) : vaddr; 86 86 87 87 switch (direction) { 88 88 case DMA_FROM_DEVICE: /* invalidate only */
+2
arch/x86/kernel/Makefile
··· 8 8 9 9 ifdef CONFIG_FUNCTION_TRACER 10 10 # Do not profile debug and lowlevel utilities 11 + CFLAGS_REMOVE_tsc.o = -pg 11 12 CFLAGS_REMOVE_rtc.o = -pg 12 13 CFLAGS_REMOVE_paravirt-spinlocks.o = -pg 13 14 CFLAGS_REMOVE_pvclock.o = -pg ··· 29 28 GCOV_PROFILE_vsyscall_64.o := n 30 29 GCOV_PROFILE_hpet.o := n 31 30 GCOV_PROFILE_tsc.o := n 31 + GCOV_PROFILE_vread_tsc_64.o := n 32 32 GCOV_PROFILE_paravirt.o := n 33 33 34 34 # vread_tsc_64 is hot and should be fully optimized:
+1 -1
arch/x86/kernel/process.c
··· 642 642 boot_option_idle_override = IDLE_POLL; 643 643 } else if (!strcmp(str, "mwait")) { 644 644 boot_option_idle_override = IDLE_FORCE_MWAIT; 645 - WARN_ONCE(1, "\idle=mwait\" will be removed in 2012\"\n"); 645 + WARN_ONCE(1, "\"idle=mwait\" will be removed in 2012\n"); 646 646 } else if (!strcmp(str, "halt")) { 647 647 /* 648 648 * When the boot option of idle=halt is added, halt is
+1 -1
arch/x86/kernel/smpboot.c
··· 1332 1332 void *mwait_ptr; 1333 1333 struct cpuinfo_x86 *c = __this_cpu_ptr(&cpu_info); 1334 1334 1335 - if (!this_cpu_has(X86_FEATURE_MWAIT) && mwait_usable(c)) 1335 + if (!(this_cpu_has(X86_FEATURE_MWAIT) && mwait_usable(c))) 1336 1336 return; 1337 1337 if (!this_cpu_has(X86_FEATURE_CLFLSH)) 1338 1338 return;
+1
arch/x86/lguest/boot.c
··· 993 993 static void lguest_time_init(void) 994 994 { 995 995 /* Set up the timer interrupt (0) to go to our simple timer routine */ 996 + lguest_setup_irq(0); 996 997 irq_set_handler(0, lguest_time_irq); 997 998 998 999 clocksource_register_hz(&lguest_clock, NSEC_PER_SEC);
+2 -2
block/blk-ioc.c
··· 21 21 if (!hlist_empty(&ioc->cic_list)) { 22 22 struct cfq_io_context *cic; 23 23 24 - cic = list_entry(ioc->cic_list.first, struct cfq_io_context, 24 + cic = hlist_entry(ioc->cic_list.first, struct cfq_io_context, 25 25 cic_list); 26 26 cic->dtor(ioc); 27 27 } ··· 57 57 if (!hlist_empty(&ioc->cic_list)) { 58 58 struct cfq_io_context *cic; 59 59 60 - cic = list_entry(ioc->cic_list.first, struct cfq_io_context, 60 + cic = hlist_entry(ioc->cic_list.first, struct cfq_io_context, 61 61 cic_list); 62 62 cic->exit(ioc); 63 63 }
+4 -7
block/cfq-iosched.c
··· 185 185 int nr_cfqq; 186 186 187 187 /* 188 - * Per group busy queus average. Useful for workload slice calc. We 188 + * Per group busy queues average. Useful for workload slice calc. We 189 189 * create the array for each prio class but at run time it is used 190 190 * only for RT and BE class and slot for IDLE class remains unused. 191 191 * This is primarily done to avoid confusion and a gcc warning. ··· 369 369 #define cfq_log_cfqq(cfqd, cfqq, fmt, args...) \ 370 370 blk_add_trace_msg((cfqd)->queue, "cfq%d%c %s " fmt, (cfqq)->pid, \ 371 371 cfq_cfqq_sync((cfqq)) ? 'S' : 'A', \ 372 - blkg_path(&(cfqq)->cfqg->blkg), ##args); 372 + blkg_path(&(cfqq)->cfqg->blkg), ##args) 373 373 374 374 #define cfq_log_cfqg(cfqd, cfqg, fmt, args...) \ 375 375 blk_add_trace_msg((cfqd)->queue, "%s " fmt, \ 376 - blkg_path(&(cfqg)->blkg), ##args); \ 376 + blkg_path(&(cfqg)->blkg), ##args) \ 377 377 378 378 #else 379 379 #define cfq_log_cfqq(cfqd, cfqq, fmt, args...) \ 380 380 blk_add_trace_msg((cfqd)->queue, "cfq%d " fmt, (cfqq)->pid, ##args) 381 - #define cfq_log_cfqg(cfqd, cfqg, fmt, args...) do {} while (0); 381 + #define cfq_log_cfqg(cfqd, cfqg, fmt, args...) do {} while (0) 382 382 #endif 383 383 #define cfq_log(cfqd, fmt, args...) \ 384 384 blk_add_trace_msg((cfqd)->queue, "cfq " fmt, ##args) ··· 3786 3786 return 0; 3787 3787 3788 3788 queue_fail: 3789 - if (cic) 3790 - put_io_context(cic->ioc); 3791 - 3792 3789 cfq_schedule_dispatch(cfqd); 3793 3790 spin_unlock_irqrestore(q->queue_lock, flags); 3794 3791 cfq_log(cfqd, "set_request fail");
+20 -2
drivers/block/nbd.c
··· 192 192 if (lo->xmit_timeout) 193 193 del_timer_sync(&ti); 194 194 } else 195 - result = kernel_recvmsg(sock, &msg, &iov, 1, size, 0); 195 + result = kernel_recvmsg(sock, &msg, &iov, 1, size, 196 + msg.msg_flags); 196 197 197 198 if (signal_pending(current)) { 198 199 siginfo_t info; ··· 754 753 return -ENOMEM; 755 754 756 755 part_shift = 0; 757 - if (max_part > 0) 756 + if (max_part > 0) { 758 757 part_shift = fls(max_part); 758 + 759 + /* 760 + * Adjust max_part according to part_shift as it is exported 761 + * to user space so that user can know the max number of 762 + * partition kernel should be able to manage. 763 + * 764 + * Note that -1 is required because partition 0 is reserved 765 + * for the whole disk. 766 + */ 767 + max_part = (1UL << part_shift) - 1; 768 + } 769 + 770 + if ((1UL << part_shift) > DISK_MAX_PARTS) 771 + return -EINVAL; 772 + 773 + if (nbds_max > 1UL << (MINORBITS - part_shift)) 774 + return -EINVAL; 759 775 760 776 for (i = 0; i < nbds_max; i++) { 761 777 struct gendisk *disk = alloc_disk(1 << part_shift);
-1
drivers/block/paride/pcd.c
··· 321 321 strcpy(disk->disk_name, cd->name); /* umm... */ 322 322 disk->fops = &pcd_bdops; 323 323 disk->flags = GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE; 324 - disk->events = DISK_EVENT_MEDIA_CHANGE; 325 324 } 326 325 } 327 326
+80 -11
drivers/block/virtio_blk.c
··· 6 6 #include <linux/virtio.h> 7 7 #include <linux/virtio_blk.h> 8 8 #include <linux/scatterlist.h> 9 + #include <linux/string_helpers.h> 10 + #include <scsi/scsi_cmnd.h> 9 11 10 12 #define PART_BITS 4 11 13 12 14 static int major, index; 15 + struct workqueue_struct *virtblk_wq; 13 16 14 17 struct virtio_blk 15 18 { ··· 28 25 struct list_head reqs; 29 26 30 27 mempool_t *pool; 28 + 29 + /* Process context for config space updates */ 30 + struct work_struct config_work; 31 31 32 32 /* What host tells us, plus 2 for header & tailer. */ 33 33 unsigned int sg_elems; ··· 147 141 num = blk_rq_map_sg(q, vbr->req, vblk->sg + out); 148 142 149 143 if (vbr->req->cmd_type == REQ_TYPE_BLOCK_PC) { 150 - sg_set_buf(&vblk->sg[num + out + in++], vbr->req->sense, 96); 144 + sg_set_buf(&vblk->sg[num + out + in++], vbr->req->sense, SCSI_SENSE_BUFFERSIZE); 151 145 sg_set_buf(&vblk->sg[num + out + in++], &vbr->in_hdr, 152 146 sizeof(vbr->in_hdr)); 153 147 } ··· 297 291 } 298 292 DEVICE_ATTR(serial, S_IRUGO, virtblk_serial_show, NULL); 299 293 294 + static void virtblk_config_changed_work(struct work_struct *work) 295 + { 296 + struct virtio_blk *vblk = 297 + container_of(work, struct virtio_blk, config_work); 298 + struct virtio_device *vdev = vblk->vdev; 299 + struct request_queue *q = vblk->disk->queue; 300 + char cap_str_2[10], cap_str_10[10]; 301 + u64 capacity, size; 302 + 303 + /* Host must always specify the capacity. */ 304 + vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity), 305 + &capacity, sizeof(capacity)); 306 + 307 + /* If capacity is too big, truncate with warning. */ 308 + if ((sector_t)capacity != capacity) { 309 + dev_warn(&vdev->dev, "Capacity %llu too large: truncating\n", 310 + (unsigned long long)capacity); 311 + capacity = (sector_t)-1; 312 + } 313 + 314 + size = capacity * queue_logical_block_size(q); 315 + string_get_size(size, STRING_UNITS_2, cap_str_2, sizeof(cap_str_2)); 316 + string_get_size(size, STRING_UNITS_10, cap_str_10, sizeof(cap_str_10)); 317 + 318 + dev_notice(&vdev->dev, 319 + "new size: %llu %d-byte logical blocks (%s/%s)\n", 320 + (unsigned long long)capacity, 321 + queue_logical_block_size(q), 322 + cap_str_10, cap_str_2); 323 + 324 + set_capacity(vblk->disk, capacity); 325 + } 326 + 327 + static void virtblk_config_changed(struct virtio_device *vdev) 328 + { 329 + struct virtio_blk *vblk = vdev->priv; 330 + 331 + queue_work(virtblk_wq, &vblk->config_work); 332 + } 333 + 300 334 static int __devinit virtblk_probe(struct virtio_device *vdev) 301 335 { 302 336 struct virtio_blk *vblk; ··· 373 327 vblk->vdev = vdev; 374 328 vblk->sg_elems = sg_elems; 375 329 sg_init_table(vblk->sg, vblk->sg_elems); 330 + INIT_WORK(&vblk->config_work, virtblk_config_changed_work); 376 331 377 332 /* We expect one virtqueue, for output. */ 378 333 vblk->vq = virtio_find_single_vq(vdev, blk_done, "requests"); ··· 524 477 { 525 478 struct virtio_blk *vblk = vdev->priv; 526 479 480 + flush_work(&vblk->config_work); 481 + 527 482 /* Nothing should be pending. */ 528 483 BUG_ON(!list_empty(&vblk->reqs)); 529 484 ··· 557 508 * Use __refdata to avoid this warning. 558 509 */ 559 510 static struct virtio_driver __refdata virtio_blk = { 560 - .feature_table = features, 561 - .feature_table_size = ARRAY_SIZE(features), 562 - .driver.name = KBUILD_MODNAME, 563 - .driver.owner = THIS_MODULE, 564 - .id_table = id_table, 565 - .probe = virtblk_probe, 566 - .remove = __devexit_p(virtblk_remove), 511 + .feature_table = features, 512 + .feature_table_size = ARRAY_SIZE(features), 513 + .driver.name = KBUILD_MODNAME, 514 + .driver.owner = THIS_MODULE, 515 + .id_table = id_table, 516 + .probe = virtblk_probe, 517 + .remove = __devexit_p(virtblk_remove), 518 + .config_changed = virtblk_config_changed, 567 519 }; 568 520 569 521 static int __init init(void) 570 522 { 523 + int error; 524 + 525 + virtblk_wq = alloc_workqueue("virtio-blk", 0, 0); 526 + if (!virtblk_wq) 527 + return -ENOMEM; 528 + 571 529 major = register_blkdev(0, "virtblk"); 572 - if (major < 0) 573 - return major; 574 - return register_virtio_driver(&virtio_blk); 530 + if (major < 0) { 531 + error = major; 532 + goto out_destroy_workqueue; 533 + } 534 + 535 + error = register_virtio_driver(&virtio_blk); 536 + if (error) 537 + goto out_unregister_blkdev; 538 + return 0; 539 + 540 + out_unregister_blkdev: 541 + unregister_blkdev(major, "virtblk"); 542 + out_destroy_workqueue: 543 + destroy_workqueue(virtblk_wq); 544 + return error; 575 545 } 576 546 577 547 static void __exit fini(void) 578 548 { 579 549 unregister_blkdev(major, "virtblk"); 580 550 unregister_virtio_driver(&virtio_blk); 551 + destroy_workqueue(virtblk_wq); 581 552 } 582 553 module_init(init); 583 554 module_exit(fini);
+6 -4
drivers/block/xen-blkback/blkback.c
··· 809 809 failed_init: 810 810 kfree(blkbk->pending_reqs); 811 811 kfree(blkbk->pending_grant_handles); 812 - for (i = 0; i < mmap_pages; i++) { 813 - if (blkbk->pending_pages[i]) 814 - __free_page(blkbk->pending_pages[i]); 812 + if (blkbk->pending_pages) { 813 + for (i = 0; i < mmap_pages; i++) { 814 + if (blkbk->pending_pages[i]) 815 + __free_page(blkbk->pending_pages[i]); 816 + } 817 + kfree(blkbk->pending_pages); 815 818 } 816 - kfree(blkbk->pending_pages); 817 819 kfree(blkbk); 818 820 blkbk = NULL; 819 821 return rc;
+1 -2
drivers/block/xen-blkback/xenbus.c
··· 357 357 } 358 358 359 359 vbd->bdev = bdev; 360 - vbd->size = vbd_sz(vbd); 361 - 362 360 if (vbd->bdev->bd_disk == NULL) { 363 361 DPRINTK("xen_vbd_create: device %08x doesn't exist.\n", 364 362 vbd->pdevice); 365 363 xen_vbd_free(vbd); 366 364 return -ENOENT; 367 365 } 366 + vbd->size = vbd_sz(vbd); 368 367 369 368 if (vbd->bdev->bd_disk->flags & GENHD_FL_CD || cdrom) 370 369 vbd->type |= VDISK_CDROM;
+6 -11
drivers/bluetooth/hci_ldisc.c
··· 355 355 * flags pointer to flags for data 356 356 * count count of received data in bytes 357 357 * 358 - * Return Value: Number of bytes received 358 + * Return Value: None 359 359 */ 360 - static unsigned int hci_uart_tty_receive(struct tty_struct *tty, 361 - const u8 *data, char *flags, int count) 360 + static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count) 362 361 { 363 362 struct hci_uart *hu = (void *)tty->disc_data; 364 - int received; 365 363 366 364 if (!hu || tty != hu->tty) 367 - return -ENODEV; 365 + return; 368 366 369 367 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags)) 370 - return -EINVAL; 368 + return; 371 369 372 370 spin_lock(&hu->rx_lock); 373 - received = hu->proto->recv(hu, (void *) data, count); 374 - if (received > 0) 375 - hu->hdev->stat.byte_rx += received; 371 + hu->proto->recv(hu, (void *) data, count); 372 + hu->hdev->stat.byte_rx += count; 376 373 spin_unlock(&hu->rx_lock); 377 374 378 375 tty_unthrottle(tty); 379 - 380 - return received; 381 376 } 382 377 383 378 static int hci_uart_register_dev(struct hci_uart *hu)
-1
drivers/cdrom/viocd.c
··· 627 627 gendisk->fops = &viocd_fops; 628 628 gendisk->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE | 629 629 GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE; 630 - gendisk->events = DISK_EVENT_MEDIA_CHANGE; 631 630 set_capacity(gendisk, 0); 632 631 gendisk->private_data = d; 633 632 d->viocd_disk = gendisk;
-5
drivers/char/virtio_console.c
··· 1677 1677 portdev->config.max_nr_ports = 1; 1678 1678 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) { 1679 1679 multiport = true; 1680 - vdev->features[0] |= 1 << VIRTIO_CONSOLE_F_MULTIPORT; 1681 - 1682 1680 vdev->config->get(vdev, offsetof(struct virtio_console_config, 1683 1681 max_nr_ports), 1684 1682 &portdev->config.max_nr_ports, 1685 1683 sizeof(portdev->config.max_nr_ports)); 1686 1684 } 1687 - 1688 - /* Let the Host know we support multiple ports.*/ 1689 - vdev->config->finalize_features(vdev); 1690 1685 1691 1686 err = init_vqs(portdev); 1692 1687 if (err < 0) {
+2 -10
drivers/clocksource/sh_cmt.c
··· 24 24 #include <linux/ioport.h> 25 25 #include <linux/io.h> 26 26 #include <linux/clk.h> 27 - #include <linux/pm_runtime.h> 28 27 #include <linux/irq.h> 29 28 #include <linux/err.h> 30 29 #include <linux/clocksource.h> ··· 152 153 { 153 154 int ret; 154 155 155 - /* wake up device and enable clock */ 156 - pm_runtime_get_sync(&p->pdev->dev); 156 + /* enable clock */ 157 157 ret = clk_enable(p->clk); 158 158 if (ret) { 159 159 dev_err(&p->pdev->dev, "cannot enable clock\n"); 160 - pm_runtime_put_sync(&p->pdev->dev); 161 160 return ret; 162 161 } 163 162 ··· 187 190 /* disable interrupts in CMT block */ 188 191 sh_cmt_write(p, CMCSR, 0); 189 192 190 - /* stop clock and mark device as idle */ 193 + /* stop clock */ 191 194 clk_disable(p->clk); 192 - pm_runtime_put_sync(&p->pdev->dev); 193 195 } 194 196 195 197 /* private flags */ ··· 660 664 661 665 if (p) { 662 666 dev_info(&pdev->dev, "kept as earlytimer\n"); 663 - pm_runtime_enable(&pdev->dev); 664 667 return 0; 665 668 } 666 669 ··· 674 679 kfree(p); 675 680 platform_set_drvdata(pdev, NULL); 676 681 } 677 - 678 - if (!is_early_platform_device(pdev)) 679 - pm_runtime_enable(&pdev->dev); 680 682 return ret; 681 683 } 682 684
+2 -10
drivers/clocksource/sh_tmu.c
··· 25 25 #include <linux/delay.h> 26 26 #include <linux/io.h> 27 27 #include <linux/clk.h> 28 - #include <linux/pm_runtime.h> 29 28 #include <linux/irq.h> 30 29 #include <linux/err.h> 31 30 #include <linux/clocksource.h> ··· 109 110 { 110 111 int ret; 111 112 112 - /* wake up device and enable clock */ 113 - pm_runtime_get_sync(&p->pdev->dev); 113 + /* enable clock */ 114 114 ret = clk_enable(p->clk); 115 115 if (ret) { 116 116 dev_err(&p->pdev->dev, "cannot enable clock\n"); 117 - pm_runtime_put_sync(&p->pdev->dev); 118 117 return ret; 119 118 } 120 119 ··· 141 144 /* disable interrupts in TMU block */ 142 145 sh_tmu_write(p, TCR, 0x0000); 143 146 144 - /* stop clock and mark device as idle */ 147 + /* stop clock */ 145 148 clk_disable(p->clk); 146 - pm_runtime_put_sync(&p->pdev->dev); 147 149 } 148 150 149 151 static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta, ··· 411 415 412 416 if (p) { 413 417 dev_info(&pdev->dev, "kept as earlytimer\n"); 414 - pm_runtime_enable(&pdev->dev); 415 418 return 0; 416 419 } 417 420 ··· 425 430 kfree(p); 426 431 platform_set_drvdata(pdev, NULL); 427 432 } 428 - 429 - if (!is_early_platform_device(pdev)) 430 - pm_runtime_enable(&pdev->dev); 431 433 return ret; 432 434 } 433 435
+7 -2
drivers/dma/shdma.c
··· 343 343 344 344 dmae_set_dmars(sh_chan, cfg->mid_rid); 345 345 dmae_set_chcr(sh_chan, cfg->chcr); 346 - } else if ((sh_dmae_readl(sh_chan, CHCR) & 0xf00) != 0x400) { 346 + } else { 347 347 dmae_init(sh_chan); 348 348 } 349 349 ··· 1144 1144 /* platform data */ 1145 1145 shdev->pdata = pdata; 1146 1146 1147 + platform_set_drvdata(pdev, shdev); 1148 + 1147 1149 pm_runtime_enable(&pdev->dev); 1148 1150 pm_runtime_get_sync(&pdev->dev); 1149 1151 ··· 1258 1256 1259 1257 pm_runtime_put(&pdev->dev); 1260 1258 1261 - platform_set_drvdata(pdev, shdev); 1262 1259 dma_async_device_register(&shdev->common); 1263 1260 1264 1261 return err; ··· 1279 1278 1280 1279 if (dmars) 1281 1280 iounmap(shdev->dmars); 1281 + 1282 + platform_set_drvdata(pdev, NULL); 1282 1283 emapdmars: 1283 1284 iounmap(shdev->chan_reg); 1284 1285 synchronize_rcu(); ··· 1318 1315 if (shdev->dmars) 1319 1316 iounmap(shdev->dmars); 1320 1317 iounmap(shdev->chan_reg); 1318 + 1319 + platform_set_drvdata(pdev, NULL); 1321 1320 1322 1321 synchronize_rcu(); 1323 1322 kfree(shdev);
+4 -19
drivers/hwmon/coretemp.c
··· 296 296 * If the TjMax is not plausible, an assumption 297 297 * will be used 298 298 */ 299 - if (val > 80 && val < 120) { 299 + if (val) { 300 300 dev_info(dev, "TjMax is %d C.\n", val); 301 301 return val * 1000; 302 302 } ··· 304 304 305 305 /* 306 306 * An assumption is made for early CPUs and unreadable MSR. 307 - * NOTE: the given value may not be correct. 307 + * NOTE: the calculated value may not be correct. 308 308 */ 309 - 310 - switch (c->x86_model) { 311 - case 0xe: 312 - case 0xf: 313 - case 0x16: 314 - case 0x1a: 315 - dev_warn(dev, "TjMax is assumed as 100 C!\n"); 316 - return 100000; 317 - case 0x17: 318 - case 0x1c: /* Atom CPUs */ 319 - return adjust_tjmax(c, id, dev); 320 - default: 321 - dev_warn(dev, "CPU (model=0x%x) is not supported yet," 322 - " using default TjMax of 100C.\n", c->x86_model); 323 - return 100000; 324 - } 309 + return adjust_tjmax(c, id, dev); 325 310 } 326 311 327 312 static void __devinit get_ucode_rev_on_cpu(void *edx) ··· 326 341 err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx); 327 342 if (!err) { 328 343 val = (eax >> 16) & 0xff; 329 - if (val > 80 && val < 120) 344 + if (val) 330 345 return val * 1000; 331 346 } 332 347 dev_warn(dev, "Unable to read Pkg-TjMax from CPU:%u\n", cpu);
+18 -4
drivers/hwmon/max6642.c
··· 136 136 if (man_id != 0x4D) 137 137 return -ENODEV; 138 138 139 + /* sanity check */ 140 + if (i2c_smbus_read_byte_data(client, 0x04) != 0x4D 141 + || i2c_smbus_read_byte_data(client, 0x06) != 0x4D 142 + || i2c_smbus_read_byte_data(client, 0xff) != 0x4D) 143 + return -ENODEV; 144 + 139 145 /* 140 146 * We read the config and status register, the 4 lower bits in the 141 147 * config register should be zero and bit 5, 3, 1 and 0 should be 142 148 * zero in the status register. 143 149 */ 144 150 reg_config = i2c_smbus_read_byte_data(client, MAX6642_REG_R_CONFIG); 151 + if ((reg_config & 0x0f) != 0x00) 152 + return -ENODEV; 153 + 154 + /* in between, another round of sanity checks */ 155 + if (i2c_smbus_read_byte_data(client, 0x04) != reg_config 156 + || i2c_smbus_read_byte_data(client, 0x06) != reg_config 157 + || i2c_smbus_read_byte_data(client, 0xff) != reg_config) 158 + return -ENODEV; 159 + 145 160 reg_status = i2c_smbus_read_byte_data(client, MAX6642_REG_R_STATUS); 146 - if (((reg_config & 0x0f) != 0x00) || 147 - ((reg_status & 0x2b) != 0x00)) 161 + if ((reg_status & 0x2b) != 0x00) 148 162 return -ENODEV; 149 163 150 164 strlcpy(info->type, "max6642", I2C_NAME_SIZE); ··· 260 246 set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH); 261 247 static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, 262 248 set_temp_max, 1, MAX6642_REG_W_REMOTE_HIGH); 263 - static SENSOR_DEVICE_ATTR(temp_fault, S_IRUGO, show_alarm, NULL, 2); 249 + static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); 264 250 static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); 265 251 static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); 266 252 ··· 270 256 &sensor_dev_attr_temp1_max.dev_attr.attr, 271 257 &sensor_dev_attr_temp2_max.dev_attr.attr, 272 258 273 - &sensor_dev_attr_temp_fault.dev_attr.attr, 259 + &sensor_dev_attr_temp2_fault.dev_attr.attr, 274 260 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, 275 261 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, 276 262 NULL
-1
drivers/ide/ide-cd.c
··· 1782 1782 ide_cd_read_toc(drive, &sense); 1783 1783 g->fops = &idecd_ops; 1784 1784 g->flags |= GENHD_FL_REMOVABLE | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE; 1785 - g->events = DISK_EVENT_MEDIA_CHANGE; 1786 1785 add_disk(g); 1787 1786 return 0; 1788 1787
+2 -8
drivers/input/serio/serport.c
··· 120 120 * 'interrupt' routine. 121 121 */ 122 122 123 - static unsigned int serport_ldisc_receive(struct tty_struct *tty, 124 - const unsigned char *cp, char *fp, int count) 123 + static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) 125 124 { 126 125 struct serport *serport = (struct serport*) tty->disc_data; 127 126 unsigned long flags; 128 127 unsigned int ch_flags; 129 - int ret = 0; 130 128 int i; 131 129 132 130 spin_lock_irqsave(&serport->lock, flags); 133 131 134 - if (!test_bit(SERPORT_ACTIVE, &serport->flags)) { 135 - ret = -EINVAL; 132 + if (!test_bit(SERPORT_ACTIVE, &serport->flags)) 136 133 goto out; 137 - } 138 134 139 135 for (i = 0; i < count; i++) { 140 136 switch (fp[i]) { ··· 152 156 153 157 out: 154 158 spin_unlock_irqrestore(&serport->lock, flags); 155 - 156 - return ret == 0 ? count : ret; 157 159 } 158 160 159 161 /*
+3 -5
drivers/isdn/gigaset/ser-gigaset.c
··· 674 674 * cflags buffer containing error flags for received characters (ignored) 675 675 * count number of received characters 676 676 */ 677 - static unsigned int 677 + static void 678 678 gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf, 679 679 char *cflags, int count) 680 680 { ··· 683 683 struct inbuf_t *inbuf; 684 684 685 685 if (!cs) 686 - return -ENODEV; 686 + return; 687 687 inbuf = cs->inbuf; 688 688 if (!inbuf) { 689 689 dev_err(cs->dev, "%s: no inbuf\n", __func__); 690 690 cs_put(cs); 691 - return -EINVAL; 691 + return; 692 692 } 693 693 694 694 tail = inbuf->tail; ··· 725 725 gig_dbg(DEBUG_INTR, "%s-->BH", __func__); 726 726 gigaset_schedule_event(cs); 727 727 cs_put(cs); 728 - 729 - return count; 730 728 } 731 729 732 730 /*
+4 -1
drivers/misc/kgdbts.c
··· 304 304 return 1; 305 305 } 306 306 /* Readjust the instruction pointer if needed */ 307 - instruction_pointer_set(&kgdbts_regs, ip + offset); 307 + ip += offset; 308 + #ifdef GDB_ADJUSTS_BREAK_OFFSET 309 + instruction_pointer_set(&kgdbts_regs, ip); 310 + #endif 308 311 return 0; 309 312 } 310 313
+2 -4
drivers/misc/ti-st/st_core.c
··· 747 747 pr_debug("%s: done ", __func__); 748 748 } 749 749 750 - static unsigned int st_tty_receive(struct tty_struct *tty, 751 - const unsigned char *data, char *tty_flags, int count) 750 + static void st_tty_receive(struct tty_struct *tty, const unsigned char *data, 751 + char *tty_flags, int count) 752 752 { 753 753 #ifdef VERBOSE 754 754 print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE, ··· 761 761 */ 762 762 st_recv(tty->disc_data, data, count); 763 763 pr_debug("done %s", __func__); 764 - 765 - return count; 766 764 } 767 765 768 766 /* wake-up function called in from the TTY layer
+7 -7
drivers/net/3c509.c
··· 185 185 static int nopnp; 186 186 #endif 187 187 188 - static int el3_common_init(struct net_device *dev); 188 + static int __devinit el3_common_init(struct net_device *dev); 189 189 static void el3_common_remove(struct net_device *dev); 190 190 static ushort id_read_eeprom(int index); 191 191 static ushort read_eeprom(int ioaddr, int index); ··· 395 395 static int isa_registered; 396 396 397 397 #ifdef CONFIG_PNP 398 - static const struct pnp_device_id el3_pnp_ids[] __devinitconst = { 398 + static struct pnp_device_id el3_pnp_ids[] = { 399 399 { .id = "TCM5090" }, /* 3Com Etherlink III (TP) */ 400 400 { .id = "TCM5091" }, /* 3Com Etherlink III */ 401 401 { .id = "TCM5094" }, /* 3Com Etherlink III (combo) */ ··· 478 478 #endif /* CONFIG_PNP */ 479 479 480 480 #ifdef CONFIG_EISA 481 - static const struct eisa_device_id el3_eisa_ids[] __devinitconst = { 481 + static struct eisa_device_id el3_eisa_ids[] = { 482 482 { "TCM5090" }, 483 483 { "TCM5091" }, 484 484 { "TCM5092" }, ··· 508 508 #ifdef CONFIG_MCA 509 509 static int el3_mca_probe(struct device *dev); 510 510 511 - static const short el3_mca_adapter_ids[] __devinitconst = { 511 + static short el3_mca_adapter_ids[] __initdata = { 512 512 0x627c, 513 513 0x627d, 514 514 0x62db, ··· 517 517 0x0000 518 518 }; 519 519 520 - static const char *const el3_mca_adapter_names[] __devinitconst = { 520 + static char *el3_mca_adapter_names[] __initdata = { 521 521 "3Com 3c529 EtherLink III (10base2)", 522 522 "3Com 3c529 EtherLink III (10baseT)", 523 523 "3Com 3c529 EtherLink III (test mode)", ··· 601 601 } 602 602 603 603 #ifdef CONFIG_MCA 604 - static int __devinit el3_mca_probe(struct device *device) 604 + static int __init el3_mca_probe(struct device *device) 605 605 { 606 606 /* Based on Erik Nygren's (nygren@mit.edu) 3c529 patch, 607 607 * heavily modified by Chris Beauregard ··· 671 671 #endif /* CONFIG_MCA */ 672 672 673 673 #ifdef CONFIG_EISA 674 - static int __devinit el3_eisa_probe (struct device *device) 674 + static int __init el3_eisa_probe (struct device *device) 675 675 { 676 676 short i; 677 677 int ioaddr, irq, if_port;
+2 -2
drivers/net/3c59x.c
··· 901 901 #endif /* !CONFIG_PM */ 902 902 903 903 #ifdef CONFIG_EISA 904 - static const struct eisa_device_id vortex_eisa_ids[] __devinitconst = { 904 + static struct eisa_device_id vortex_eisa_ids[] = { 905 905 { "TCM5920", CH_3C592 }, 906 906 { "TCM5970", CH_3C597 }, 907 907 { "" } 908 908 }; 909 909 MODULE_DEVICE_TABLE(eisa, vortex_eisa_ids); 910 910 911 - static int __devinit vortex_eisa_probe(struct device *device) 911 + static int __init vortex_eisa_probe(struct device *device) 912 912 { 913 913 void __iomem *ioaddr; 914 914 struct eisa_device *edev;
+2 -4
drivers/net/caif/caif_serial.c
··· 167 167 168 168 #endif 169 169 170 - static unsigned int ldisc_receive(struct tty_struct *tty, 171 - const u8 *data, char *flags, int count) 170 + static void ldisc_receive(struct tty_struct *tty, const u8 *data, 171 + char *flags, int count) 172 172 { 173 173 struct sk_buff *skb = NULL; 174 174 struct ser_device *ser; ··· 215 215 } else 216 216 ++ser->dev->stats.rx_dropped; 217 217 update_tty_status(ser); 218 - 219 - return count; 220 218 } 221 219 222 220 static int handle_tx(struct ser_device *ser)
+2 -3
drivers/net/can/flexcan.c
··· 923 923 mem_size = resource_size(mem); 924 924 if (!request_mem_region(mem->start, mem_size, pdev->name)) { 925 925 err = -EBUSY; 926 - goto failed_req; 926 + goto failed_get; 927 927 } 928 928 929 929 base = ioremap(mem->start, mem_size); ··· 977 977 iounmap(base); 978 978 failed_map: 979 979 release_mem_region(mem->start, mem_size); 980 - failed_req: 981 - clk_put(clk); 982 980 failed_get: 981 + clk_put(clk); 983 982 failed_clock: 984 983 return err; 985 984 }
+3 -6
drivers/net/can/slcan.c
··· 425 425 * in parallel 426 426 */ 427 427 428 - static unsigned int slcan_receive_buf(struct tty_struct *tty, 428 + static void slcan_receive_buf(struct tty_struct *tty, 429 429 const unsigned char *cp, char *fp, int count) 430 430 { 431 431 struct slcan *sl = (struct slcan *) tty->disc_data; 432 - int bytes = count; 433 432 434 433 if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev)) 435 - return -ENODEV; 434 + return; 436 435 437 436 /* Read the characters out of the buffer */ 438 - while (bytes--) { 437 + while (count--) { 439 438 if (fp && *fp++) { 440 439 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) 441 440 sl->dev->stats.rx_errors++; ··· 443 444 } 444 445 slcan_unesc(sl, *cp++); 445 446 } 446 - 447 - return count; 448 447 } 449 448 450 449 /************************************
+6 -4
drivers/net/davinci_emac.c
··· 1781 1781 ndev = alloc_etherdev(sizeof(struct emac_priv)); 1782 1782 if (!ndev) { 1783 1783 dev_err(&pdev->dev, "error allocating net_device\n"); 1784 - clk_put(emac_clk); 1785 - return -ENOMEM; 1784 + rc = -ENOMEM; 1785 + goto free_clk; 1786 1786 } 1787 1787 1788 1788 platform_set_drvdata(pdev, ndev); ··· 1796 1796 pdata = pdev->dev.platform_data; 1797 1797 if (!pdata) { 1798 1798 dev_err(&pdev->dev, "no platform data\n"); 1799 - return -ENODEV; 1799 + rc = -ENODEV; 1800 + goto probe_quit; 1800 1801 } 1801 1802 1802 1803 /* MAC addr and PHY mask , RMII enable info from platform_data */ ··· 1930 1929 iounmap(priv->remap_addr); 1931 1930 1932 1931 probe_quit: 1933 - clk_put(emac_clk); 1934 1932 free_netdev(ndev); 1933 + free_clk: 1934 + clk_put(emac_clk); 1935 1935 return rc; 1936 1936 } 1937 1937
+17 -18
drivers/net/depca.c
··· 331 331 "DE422",\ 332 332 ""} 333 333 334 - static const char* const depca_signature[] __devinitconst = DEPCA_SIGNATURE; 334 + static char* __initdata depca_signature[] = DEPCA_SIGNATURE; 335 335 336 336 enum depca_type { 337 337 DEPCA, de100, de101, de200, de201, de202, de210, de212, de422, unknown 338 338 }; 339 339 340 - static const char depca_string[] = "depca"; 340 + static char depca_string[] = "depca"; 341 341 342 342 static int depca_device_remove (struct device *device); 343 343 344 344 #ifdef CONFIG_EISA 345 - static const struct eisa_device_id depca_eisa_ids[] __devinitconst = { 345 + static struct eisa_device_id depca_eisa_ids[] = { 346 346 { "DEC4220", de422 }, 347 347 { "" } 348 348 }; ··· 367 367 #define DE210_ID 0x628d 368 368 #define DE212_ID 0x6def 369 369 370 - static const short depca_mca_adapter_ids[] __devinitconst = { 370 + static short depca_mca_adapter_ids[] = { 371 371 DE210_ID, 372 372 DE212_ID, 373 373 0x0000 374 374 }; 375 375 376 - static const char *depca_mca_adapter_name[] = { 376 + static char *depca_mca_adapter_name[] = { 377 377 "DEC EtherWORKS MC Adapter (DE210)", 378 378 "DEC EtherWORKS MC Adapter (DE212)", 379 379 NULL 380 380 }; 381 381 382 - static const enum depca_type depca_mca_adapter_type[] = { 382 + static enum depca_type depca_mca_adapter_type[] = { 383 383 de210, 384 384 de212, 385 385 0 ··· 541 541 static int load_packet(struct net_device *dev, struct sk_buff *skb); 542 542 static void depca_dbg_open(struct net_device *dev); 543 543 544 - static const u_char de1xx_irq[] __devinitconst = { 2, 3, 4, 5, 7, 9, 0 }; 545 - static const u_char de2xx_irq[] __devinitconst = { 5, 9, 10, 11, 15, 0 }; 546 - static const u_char de422_irq[] __devinitconst = { 5, 9, 10, 11, 0 }; 544 + static u_char de1xx_irq[] __initdata = { 2, 3, 4, 5, 7, 9, 0 }; 545 + static u_char de2xx_irq[] __initdata = { 5, 9, 10, 11, 15, 0 }; 546 + static u_char de422_irq[] __initdata = { 5, 9, 10, 11, 0 }; 547 + static u_char *depca_irq; 547 548 548 549 static int irq; 549 550 static int io; ··· 580 579 .ndo_validate_addr = eth_validate_addr, 581 580 }; 582 581 583 - static int __devinit depca_hw_init (struct net_device *dev, struct device *device) 582 + static int __init depca_hw_init (struct net_device *dev, struct device *device) 584 583 { 585 584 struct depca_private *lp; 586 585 int i, j, offset, netRAM, mem_len, status = 0; ··· 748 747 if (dev->irq < 2) { 749 748 unsigned char irqnum; 750 749 unsigned long irq_mask, delay; 751 - const u_char *depca_irq; 752 750 753 751 irq_mask = probe_irq_on(); 754 752 ··· 770 770 break; 771 771 772 772 default: 773 - depca_irq = NULL; 774 773 break; /* Not reached */ 775 774 } 776 775 ··· 1302 1303 } 1303 1304 } 1304 1305 1305 - static int __devinit depca_common_init (u_long ioaddr, struct net_device **devp) 1306 + static int __init depca_common_init (u_long ioaddr, struct net_device **devp) 1306 1307 { 1307 1308 int status = 0; 1308 1309 ··· 1333 1334 /* 1334 1335 ** Microchannel bus I/O device probe 1335 1336 */ 1336 - static int __devinit depca_mca_probe(struct device *device) 1337 + static int __init depca_mca_probe(struct device *device) 1337 1338 { 1338 1339 unsigned char pos[2]; 1339 1340 unsigned char where; ··· 1457 1458 ** ISA bus I/O device probe 1458 1459 */ 1459 1460 1460 - static void __devinit depca_platform_probe (void) 1461 + static void __init depca_platform_probe (void) 1461 1462 { 1462 1463 int i; 1463 1464 struct platform_device *pldev; ··· 1497 1498 } 1498 1499 } 1499 1500 1500 - static enum depca_type __devinit depca_shmem_probe (ulong *mem_start) 1501 + static enum depca_type __init depca_shmem_probe (ulong *mem_start) 1501 1502 { 1502 1503 u_long mem_base[] = DEPCA_RAM_BASE_ADDRESSES; 1503 1504 enum depca_type adapter = unknown; ··· 1558 1559 */ 1559 1560 1560 1561 #ifdef CONFIG_EISA 1561 - static int __devinit depca_eisa_probe (struct device *device) 1562 + static int __init depca_eisa_probe (struct device *device) 1562 1563 { 1563 1564 enum depca_type adapter = unknown; 1564 1565 struct eisa_device *edev; ··· 1629 1630 ** and Boot (readb) ROM. This will also give us a clue to the network RAM 1630 1631 ** base address. 1631 1632 */ 1632 - static int __devinit DepcaSignature(char *name, u_long base_addr) 1633 + static int __init DepcaSignature(char *name, u_long base_addr) 1633 1634 { 1634 1635 u_int i, j, k; 1635 1636 void __iomem *ptr;
+3 -3
drivers/net/dm9000.c
··· 1157 1157 1158 1158 irqflags |= IRQF_SHARED; 1159 1159 1160 - if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev)) 1161 - return -EAGAIN; 1162 - 1163 1160 /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */ 1164 1161 iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */ 1165 1162 mdelay(1); /* delay needs by DM9000B */ ··· 1164 1167 /* Initialize DM9000 board */ 1165 1168 dm9000_reset(db); 1166 1169 dm9000_init_dm9000(dev); 1170 + 1171 + if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev)) 1172 + return -EAGAIN; 1167 1173 1168 1174 /* Init driver variable */ 1169 1175 db->dbug_cnt = 0;
+3 -5
drivers/net/hamradio/6pack.c
··· 456 456 * a block of 6pack data has been received, which can now be decapsulated 457 457 * and sent on to some IP layer for further processing. 458 458 */ 459 - static unsigned int sixpack_receive_buf(struct tty_struct *tty, 459 + static void sixpack_receive_buf(struct tty_struct *tty, 460 460 const unsigned char *cp, char *fp, int count) 461 461 { 462 462 struct sixpack *sp; ··· 464 464 int count1; 465 465 466 466 if (!count) 467 - return 0; 467 + return; 468 468 469 469 sp = sp_get(tty); 470 470 if (!sp) 471 - return -ENODEV; 471 + return; 472 472 473 473 memcpy(buf, cp, count < sizeof(buf) ? count : sizeof(buf)); 474 474 ··· 487 487 488 488 sp_put(sp); 489 489 tty_unthrottle(tty); 490 - 491 - return count1; 492 490 } 493 491 494 492 /*
+4 -7
drivers/net/hamradio/mkiss.c
··· 923 923 * a block of data has been received, which can now be decapsulated 924 924 * and sent on to the AX.25 layer for further processing. 925 925 */ 926 - static unsigned int mkiss_receive_buf(struct tty_struct *tty, 927 - const unsigned char *cp, char *fp, int count) 926 + static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp, 927 + char *fp, int count) 928 928 { 929 929 struct mkiss *ax = mkiss_get(tty); 930 - int bytes = count; 931 930 932 931 if (!ax) 933 - return -ENODEV; 932 + return; 934 933 935 934 /* 936 935 * Argh! mtu change time! - costs us the packet part received ··· 939 940 ax_changedmtu(ax); 940 941 941 942 /* Read the characters out of the buffer */ 942 - while (bytes--) { 943 + while (count--) { 943 944 if (fp != NULL && *fp++) { 944 945 if (!test_and_set_bit(AXF_ERROR, &ax->flags)) 945 946 ax->dev->stats.rx_errors++; ··· 952 953 953 954 mkiss_put(ax); 954 955 tty_unthrottle(tty); 955 - 956 - return count; 957 956 } 958 957 959 958 /*
+6 -6
drivers/net/hp100.c
··· 188 188 * variables 189 189 */ 190 190 #ifdef CONFIG_ISA 191 - static const char *const hp100_isa_tbl[] __devinitconst = { 191 + static const char *hp100_isa_tbl[] = { 192 192 "HWPF150", /* HP J2573 rev A */ 193 193 "HWP1950", /* HP J2573 */ 194 194 }; 195 195 #endif 196 196 197 197 #ifdef CONFIG_EISA 198 - static const struct eisa_device_id hp100_eisa_tbl[] __devinitconst = { 198 + static struct eisa_device_id hp100_eisa_tbl[] = { 199 199 { "HWPF180" }, /* HP J2577 rev A */ 200 200 { "HWP1920" }, /* HP 27248B */ 201 201 { "HWP1940" }, /* HP J2577 */ ··· 336 336 } 337 337 338 338 #ifdef CONFIG_ISA 339 - static __devinit int hp100_isa_probe1(struct net_device *dev, int ioaddr) 339 + static __init int hp100_isa_probe1(struct net_device *dev, int ioaddr) 340 340 { 341 341 const char *sig; 342 342 int i; ··· 372 372 * EISA and PCI are handled by device infrastructure. 373 373 */ 374 374 375 - static int __devinit hp100_isa_probe(struct net_device *dev, int addr) 375 + static int __init hp100_isa_probe(struct net_device *dev, int addr) 376 376 { 377 377 int err = -ENODEV; 378 378 ··· 396 396 #endif /* CONFIG_ISA */ 397 397 398 398 #if !defined(MODULE) && defined(CONFIG_ISA) 399 - struct net_device * __devinit hp100_probe(int unit) 399 + struct net_device * __init hp100_probe(int unit) 400 400 { 401 401 struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private)); 402 402 int err; ··· 2843 2843 } 2844 2844 2845 2845 #ifdef CONFIG_EISA 2846 - static int __devinit hp100_eisa_probe (struct device *gendev) 2846 + static int __init hp100_eisa_probe (struct device *gendev) 2847 2847 { 2848 2848 struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private)); 2849 2849 struct eisa_device *edev = to_eisa_device(gendev);
+2 -2
drivers/net/ibmlana.c
··· 895 895 static int ibmlana_io; 896 896 static int startslot; /* counts through slots when probing multiple devices */ 897 897 898 - static const short ibmlana_adapter_ids[] __devinitconst = { 898 + static short ibmlana_adapter_ids[] __initdata = { 899 899 IBM_LANA_ID, 900 900 0x0000 901 901 }; 902 902 903 - static const char *const ibmlana_adapter_names[] __devinitconst = { 903 + static char *ibmlana_adapter_names[] __devinitdata = { 904 904 "IBM LAN Adapter/A", 905 905 NULL 906 906 };
+7 -9
drivers/net/irda/irtty-sir.c
··· 216 216 * usbserial: urb-complete-interrupt / softint 217 217 */ 218 218 219 - static unsigned int irtty_receive_buf(struct tty_struct *tty, 220 - const unsigned char *cp, char *fp, int count) 219 + static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp, 220 + char *fp, int count) 221 221 { 222 222 struct sir_dev *dev; 223 223 struct sirtty_cb *priv = tty->disc_data; 224 224 int i; 225 225 226 - IRDA_ASSERT(priv != NULL, return -ENODEV;); 227 - IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -EINVAL;); 226 + IRDA_ASSERT(priv != NULL, return;); 227 + IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;); 228 228 229 229 if (unlikely(count==0)) /* yes, this happens */ 230 - return 0; 230 + return; 231 231 232 232 dev = priv->dev; 233 233 if (!dev) { 234 234 IRDA_WARNING("%s(), not ready yet!\n", __func__); 235 - return -ENODEV; 235 + return; 236 236 } 237 237 238 238 for (i = 0; i < count; i++) { ··· 242 242 if (fp && *fp++) { 243 243 IRDA_DEBUG(0, "Framing or parity error!\n"); 244 244 sirdev_receive(dev, NULL, 0); /* notify sir_dev (updating stats) */ 245 - return -EINVAL; 245 + return; 246 246 } 247 247 } 248 248 249 249 sirdev_receive(dev, cp, count); 250 - 251 - return count; 252 250 } 253 251 254 252 /*
+22 -22
drivers/net/irda/smsc-ircc2.c
··· 222 222 static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self); 223 223 224 224 /* Probing */ 225 - static int smsc_ircc_look_for_chips(void); 226 - static const struct smsc_chip * smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type); 227 - static int smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type); 228 - static int smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type); 229 - static int smsc_superio_fdc(unsigned short cfg_base); 230 - static int smsc_superio_lpc(unsigned short cfg_base); 225 + static int __init smsc_ircc_look_for_chips(void); 226 + static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type); 227 + static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type); 228 + static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type); 229 + static int __init smsc_superio_fdc(unsigned short cfg_base); 230 + static int __init smsc_superio_lpc(unsigned short cfg_base); 231 231 #ifdef CONFIG_PCI 232 - static int preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf); 233 - static int preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); 234 - static void preconfigure_ali_port(struct pci_dev *dev, 232 + static int __init preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf); 233 + static int __init preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); 234 + static void __init preconfigure_ali_port(struct pci_dev *dev, 235 235 unsigned short port); 236 - static int preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); 237 - static int smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg, 236 + static int __init preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); 237 + static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg, 238 238 unsigned short ircc_fir, 239 239 unsigned short ircc_sir, 240 240 unsigned char ircc_dma, ··· 366 366 } 367 367 368 368 /* PNP hotplug support */ 369 - static const struct pnp_device_id smsc_ircc_pnp_table[] __devinitconst = { 369 + static const struct pnp_device_id smsc_ircc_pnp_table[] = { 370 370 { .id = "SMCf010", .driver_data = 0 }, 371 371 /* and presumably others */ 372 372 { } ··· 515 515 * Try to open driver instance 516 516 * 517 517 */ 518 - static int __devinit smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq) 518 + static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq) 519 519 { 520 520 struct smsc_ircc_cb *self; 521 521 struct net_device *dev; ··· 2273 2273 } 2274 2274 2275 2275 2276 - static int __devinit smsc_access(unsigned short cfg_base, unsigned char reg) 2276 + static int __init smsc_access(unsigned short cfg_base, unsigned char reg) 2277 2277 { 2278 2278 IRDA_DEBUG(1, "%s\n", __func__); 2279 2279 ··· 2281 2281 return inb(cfg_base) != reg ? -1 : 0; 2282 2282 } 2283 2283 2284 - static const struct smsc_chip * __devinit smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type) 2284 + static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type) 2285 2285 { 2286 2286 u8 devid, xdevid, rev; 2287 2287 ··· 2406 2406 #ifdef CONFIG_PCI 2407 2407 #define PCIID_VENDOR_INTEL 0x8086 2408 2408 #define PCIID_VENDOR_ALI 0x10b9 2409 - static const struct smsc_ircc_subsystem_configuration subsystem_configurations[] __devinitconst = { 2409 + static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __initdata = { 2410 2410 /* 2411 2411 * Subsystems needing entries: 2412 2412 * 0x10b9:0x1533 0x103c:0x0850 HP nx9010 family ··· 2532 2532 * (FIR port, SIR port, FIR DMA, FIR IRQ) 2533 2533 * through the chip configuration port. 2534 2534 */ 2535 - static int __devinit preconfigure_smsc_chip(struct 2535 + static int __init preconfigure_smsc_chip(struct 2536 2536 smsc_ircc_subsystem_configuration 2537 2537 *conf) 2538 2538 { ··· 2633 2633 * or Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge. 2634 2634 * They all work the same way! 2635 2635 */ 2636 - static int __devinit preconfigure_through_82801(struct pci_dev *dev, 2636 + static int __init preconfigure_through_82801(struct pci_dev *dev, 2637 2637 struct 2638 2638 smsc_ircc_subsystem_configuration 2639 2639 *conf) ··· 2786 2786 * This is based on reverse-engineering since ALi does not 2787 2787 * provide any data sheet for the 1533 chip. 2788 2788 */ 2789 - static void __devinit preconfigure_ali_port(struct pci_dev *dev, 2789 + static void __init preconfigure_ali_port(struct pci_dev *dev, 2790 2790 unsigned short port) 2791 2791 { 2792 2792 unsigned char reg; ··· 2824 2824 IRDA_MESSAGE("Activated ALi 1533 ISA bridge port 0x%04x.\n", port); 2825 2825 } 2826 2826 2827 - static int __devinit preconfigure_through_ali(struct pci_dev *dev, 2827 + static int __init preconfigure_through_ali(struct pci_dev *dev, 2828 2828 struct 2829 2829 smsc_ircc_subsystem_configuration 2830 2830 *conf) ··· 2837 2837 return preconfigure_smsc_chip(conf); 2838 2838 } 2839 2839 2840 - static int __devinit smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg, 2840 + static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg, 2841 2841 unsigned short ircc_fir, 2842 2842 unsigned short ircc_sir, 2843 2843 unsigned char ircc_dma, ··· 2849 2849 int ret = 0; 2850 2850 2851 2851 for_each_pci_dev(dev) { 2852 - const struct smsc_ircc_subsystem_configuration *conf; 2852 + struct smsc_ircc_subsystem_configuration *conf; 2853 2853 2854 2854 /* 2855 2855 * Cache the subsystem vendor/device:
+1 -1
drivers/net/ks8842.c
··· 661 661 662 662 /* check the status */ 663 663 if ((status & RXSR_VALID) && !(status & RXSR_ERROR)) { 664 - struct sk_buff *skb = netdev_alloc_skb_ip_align(netdev, len); 664 + struct sk_buff *skb = netdev_alloc_skb_ip_align(netdev, len + 3); 665 665 666 666 if (skb) { 667 667
+6 -9
drivers/net/ne3210.c
··· 80 80 81 81 #define NE3210_DEBUG 0x0 82 82 83 - static const unsigned char irq_map[] __devinitconst = 84 - { 15, 12, 11, 10, 9, 7, 5, 3 }; 85 - static const unsigned int shmem_map[] __devinitconst = 86 - { 0xff0, 0xfe0, 0xfff0, 0xd8, 0xffe0, 0xffc0, 0xd0, 0x0 }; 87 - static const char *const ifmap[] __devinitconst = 88 - { "UTP", "?", "BNC", "AUI" }; 89 - static const int ifmap_val[] __devinitconst = { 83 + static unsigned char irq_map[] __initdata = {15, 12, 11, 10, 9, 7, 5, 3}; 84 + static unsigned int shmem_map[] __initdata = {0xff0, 0xfe0, 0xfff0, 0xd8, 0xffe0, 0xffc0, 0xd0, 0x0}; 85 + static const char *ifmap[] __initdata = {"UTP", "?", "BNC", "AUI"}; 86 + static int ifmap_val[] __initdata = { 90 87 IF_PORT_10BASET, 91 88 IF_PORT_UNKNOWN, 92 89 IF_PORT_10BASE2, 93 90 IF_PORT_AUI, 94 91 }; 95 92 96 - static int __devinit ne3210_eisa_probe (struct device *device) 93 + static int __init ne3210_eisa_probe (struct device *device) 97 94 { 98 95 unsigned long ioaddr, phys_mem; 99 96 int i, retval, port_index; ··· 313 316 memcpy_toio(shmem, buf, count); 314 317 } 315 318 316 - static const struct eisa_device_id ne3210_ids[] __devinitconst = { 319 + static struct eisa_device_id ne3210_ids[] = { 317 320 { "EGL0101" }, 318 321 { "NVL1801" }, 319 322 { "" },
+2 -4
drivers/net/ppp_async.c
··· 340 340 } 341 341 342 342 /* May sleep, don't call from interrupt level or with interrupts disabled */ 343 - static unsigned int 343 + static void 344 344 ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf, 345 345 char *cflags, int count) 346 346 { ··· 348 348 unsigned long flags; 349 349 350 350 if (!ap) 351 - return -ENODEV; 351 + return; 352 352 spin_lock_irqsave(&ap->recv_lock, flags); 353 353 ppp_async_input(ap, buf, cflags, count); 354 354 spin_unlock_irqrestore(&ap->recv_lock, flags); ··· 356 356 tasklet_schedule(&ap->tsk); 357 357 ap_put(ap); 358 358 tty_unthrottle(tty); 359 - 360 - return count; 361 359 } 362 360 363 361 static void
+2 -4
drivers/net/ppp_synctty.c
··· 381 381 } 382 382 383 383 /* May sleep, don't call from interrupt level or with interrupts disabled */ 384 - static unsigned int 384 + static void 385 385 ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf, 386 386 char *cflags, int count) 387 387 { ··· 389 389 unsigned long flags; 390 390 391 391 if (!ap) 392 - return -ENODEV; 392 + return; 393 393 spin_lock_irqsave(&ap->recv_lock, flags); 394 394 ppp_sync_input(ap, buf, cflags, count); 395 395 spin_unlock_irqrestore(&ap->recv_lock, flags); ··· 397 397 tasklet_schedule(&ap->tsk); 398 398 sp_put(ap); 399 399 tty_unthrottle(tty); 400 - 401 - return count; 402 400 } 403 401 404 402 static void
+4 -7
drivers/net/slip.c
··· 670 670 * in parallel 671 671 */ 672 672 673 - static unsigned int slip_receive_buf(struct tty_struct *tty, 674 - const unsigned char *cp, char *fp, int count) 673 + static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp, 674 + char *fp, int count) 675 675 { 676 676 struct slip *sl = tty->disc_data; 677 - int bytes = count; 678 677 679 678 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) 680 - return -ENODEV; 679 + return; 681 680 682 681 /* Read the characters out of the buffer */ 683 - while (bytes--) { 682 + while (count--) { 684 683 if (fp && *fp++) { 685 684 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) 686 685 sl->dev->stats.rx_errors++; ··· 693 694 #endif 694 695 slip_unesc(sl, *cp++); 695 696 } 696 - 697 - return count; 698 697 } 699 698 700 699 /************************************
+3 -3
drivers/net/smc-mca.c
··· 156 156 { 14, 15 } 157 157 }; 158 158 159 - static const short smc_mca_adapter_ids[] __devinitconst = { 159 + static short smc_mca_adapter_ids[] __initdata = { 160 160 0x61c8, 161 161 0x61c9, 162 162 0x6fc0, ··· 168 168 0x0000 169 169 }; 170 170 171 - static const char *const smc_mca_adapter_names[] __devinitconst = { 171 + static char *smc_mca_adapter_names[] __initdata = { 172 172 "SMC Ethercard PLUS Elite/A BNC/AUI (WD8013EP/A)", 173 173 "SMC Ethercard PLUS Elite/A UTP/AUI (WD8013WP/A)", 174 174 "WD Ethercard PLUS/A (WD8003E/A or WD8003ET/A)", ··· 199 199 #endif 200 200 }; 201 201 202 - static int __devinit ultramca_probe(struct device *gen_dev) 202 + static int __init ultramca_probe(struct device *gen_dev) 203 203 { 204 204 unsigned short ioaddr; 205 205 struct net_device *dev;
+1 -1
drivers/net/tg3.c
··· 5774 5774 dma_unmap_addr(txb, mapping), 5775 5775 skb_headlen(skb), 5776 5776 PCI_DMA_TODEVICE); 5777 - for (i = 0; i <= last; i++) { 5777 + for (i = 0; i < last; i++) { 5778 5778 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 5779 5779 5780 5780 entry = NEXT_TX(entry);
+1 -1
drivers/net/tokenring/madgemc.c
··· 727 727 return 0; 728 728 } 729 729 730 - static const short madgemc_adapter_ids[] __devinitconst = { 730 + static short madgemc_adapter_ids[] __initdata = { 731 731 0x002d, 732 732 0x0000 733 733 };
+2 -2
drivers/net/tulip/de4x5.c
··· 1995 1995 1996 1996 static u_char de4x5_irq[] = EISA_ALLOWED_IRQ_LIST; 1997 1997 1998 - static int __devinit de4x5_eisa_probe (struct device *gendev) 1998 + static int __init de4x5_eisa_probe (struct device *gendev) 1999 1999 { 2000 2000 struct eisa_device *edev; 2001 2001 u_long iobase; ··· 2097 2097 return 0; 2098 2098 } 2099 2099 2100 - static const struct eisa_device_id de4x5_eisa_ids[] __devinitconst = { 2100 + static struct eisa_device_id de4x5_eisa_ids[] = { 2101 2101 { "DEC4250", 0 }, /* 0 is the board name index... */ 2102 2102 { "" } 2103 2103 };
+1 -1
drivers/net/usb/catc.c
··· 495 495 if (!q->dir && q->buf && q->len) 496 496 memcpy(catc->ctrl_buf, q->buf, q->len); 497 497 498 - if ((status = usb_submit_urb(catc->ctrl_urb, GFP_KERNEL))) 498 + if ((status = usb_submit_urb(catc->ctrl_urb, GFP_ATOMIC))) 499 499 err("submit(ctrl_urb) status %d", status); 500 500 } 501 501
+2 -1
drivers/net/usb/cdc_ncm.c
··· 54 54 #include <linux/usb/usbnet.h> 55 55 #include <linux/usb/cdc.h> 56 56 57 - #define DRIVER_VERSION "24-May-2011" 57 + #define DRIVER_VERSION "01-June-2011" 58 58 59 59 /* CDC NCM subclass 3.2.1 */ 60 60 #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 ··· 1234 1234 .disconnect = cdc_ncm_disconnect, 1235 1235 .suspend = usbnet_suspend, 1236 1236 .resume = usbnet_resume, 1237 + .reset_resume = usbnet_resume, 1237 1238 .supports_autosuspend = 1, 1238 1239 }; 1239 1240
+1 -1
drivers/net/virtio_net.c
··· 609 609 * before it gets out of hand. Naturally, this wastes entries. */ 610 610 if (capacity < 2+MAX_SKB_FRAGS) { 611 611 netif_stop_queue(dev); 612 - if (unlikely(!virtqueue_enable_cb(vi->svq))) { 612 + if (unlikely(!virtqueue_enable_cb_delayed(vi->svq))) { 613 613 /* More just got used, free them then recheck. */ 614 614 capacity += free_old_xmit_skbs(vi); 615 615 if (capacity >= 2+MAX_SKB_FRAGS) {
+2 -5
drivers/net/wan/x25_asy.c
··· 517 517 * and sent on to some IP layer for further processing. 518 518 */ 519 519 520 - static unsigned int x25_asy_receive_buf(struct tty_struct *tty, 520 + static void x25_asy_receive_buf(struct tty_struct *tty, 521 521 const unsigned char *cp, char *fp, int count) 522 522 { 523 523 struct x25_asy *sl = tty->disc_data; 524 - int bytes = count; 525 524 526 525 if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev)) 527 526 return; 528 527 529 528 530 529 /* Read the characters out of the buffer */ 531 - while (bytes--) { 530 + while (count--) { 532 531 if (fp && *fp++) { 533 532 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) 534 533 sl->dev->stats.rx_errors++; ··· 536 537 } 537 538 x25_asy_unesc(sl, *cp++); 538 539 } 539 - 540 - return count; 541 540 } 542 541 543 542 /*
-1
drivers/net/wireless/ath/ath9k/Kconfig
··· 26 26 config ATH9K_PCI 27 27 bool "Atheros ath9k PCI/PCIe bus support" 28 28 depends on ATH9K && PCI 29 - default PCI 30 29 ---help--- 31 30 This option enables the PCI bus support in ath9k. 32 31
+1 -1
drivers/net/wireless/ath/ath9k/ar9002_calib.c
··· 829 829 if (AR_SREV_9271(ah)) { 830 830 if (!ar9285_hw_cl_cal(ah, chan)) 831 831 return false; 832 - } else if (AR_SREV_9285_12_OR_LATER(ah)) { 832 + } else if (AR_SREV_9285(ah) && AR_SREV_9285_12_OR_LATER(ah)) { 833 833 if (!ar9285_hw_clc(ah, chan)) 834 834 return false; 835 835 } else {
+8 -2
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
··· 4645 4645 case 1: 4646 4646 break; 4647 4647 case 2: 4648 - scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; 4648 + if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN) 4649 + scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; 4650 + else 4651 + scaledPower = 0; 4649 4652 break; 4650 4653 case 3: 4651 - scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; 4654 + if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN) 4655 + scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; 4656 + else 4657 + scaledPower = 0; 4652 4658 break; 4653 4659 } 4654 4660
+22
drivers/net/wireless/ath/ath9k/ar9003_phy.c
··· 1381 1381 "==== BB update: done ====\n\n"); 1382 1382 } 1383 1383 EXPORT_SYMBOL(ar9003_hw_bb_watchdog_dbg_info); 1384 + 1385 + void ar9003_hw_disable_phy_restart(struct ath_hw *ah) 1386 + { 1387 + u32 val; 1388 + 1389 + /* While receiving unsupported rate frame rx state machine 1390 + * gets into a state 0xb and if phy_restart happens in that 1391 + * state, BB would go hang. If RXSM is in 0xb state after 1392 + * first bb panic, ensure to disable the phy_restart. 1393 + */ 1394 + if (!((MS(ah->bb_watchdog_last_status, 1395 + AR_PHY_WATCHDOG_RX_OFDM_SM) == 0xb) || 1396 + ah->bb_hang_rx_ofdm)) 1397 + return; 1398 + 1399 + ah->bb_hang_rx_ofdm = true; 1400 + val = REG_READ(ah, AR_PHY_RESTART); 1401 + val &= ~AR_PHY_RESTART_ENA; 1402 + 1403 + REG_WRITE(ah, AR_PHY_RESTART, val); 1404 + } 1405 + EXPORT_SYMBOL(ar9003_hw_disable_phy_restart);
+8 -2
drivers/net/wireless/ath/ath9k/eeprom_9287.c
··· 524 524 case 1: 525 525 break; 526 526 case 2: 527 - scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; 527 + if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN) 528 + scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; 529 + else 530 + scaledPower = 0; 528 531 break; 529 532 case 3: 530 - scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; 533 + if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN) 534 + scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; 535 + else 536 + scaledPower = 0; 531 537 break; 532 538 } 533 539 scaledPower = max((u16)0, scaledPower);
+4 -1
drivers/net/wireless/ath/ath9k/hw.c
··· 1555 1555 if (ah->btcoex_hw.enabled) 1556 1556 ath9k_hw_btcoex_enable(ah); 1557 1557 1558 - if (AR_SREV_9300_20_OR_LATER(ah)) 1558 + if (AR_SREV_9300_20_OR_LATER(ah)) { 1559 1559 ar9003_hw_bb_watchdog_config(ah); 1560 + 1561 + ar9003_hw_disable_phy_restart(ah); 1562 + } 1560 1563 1561 1564 ath9k_hw_apply_gpio_override(ah); 1562 1565
+2
drivers/net/wireless/ath/ath9k/hw.h
··· 842 842 843 843 u32 bb_watchdog_last_status; 844 844 u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */ 845 + u8 bb_hang_rx_ofdm; /* true if bb hang due to rx_ofdm */ 845 846 846 847 unsigned int paprd_target_power; 847 848 unsigned int paprd_training_power; ··· 991 990 void ar9003_hw_bb_watchdog_config(struct ath_hw *ah); 992 991 void ar9003_hw_bb_watchdog_read(struct ath_hw *ah); 993 992 void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah); 993 + void ar9003_hw_disable_phy_restart(struct ath_hw *ah); 994 994 void ar9003_paprd_enable(struct ath_hw *ah, bool val); 995 995 void ar9003_paprd_populate_single_table(struct ath_hw *ah, 996 996 struct ath9k_hw_cal_data *caldata,
+3 -1
drivers/net/wireless/ath/ath9k/main.c
··· 670 670 u32 status = sc->intrstatus; 671 671 u32 rxmask; 672 672 673 - if (status & ATH9K_INT_FATAL) { 673 + if ((status & ATH9K_INT_FATAL) || 674 + (status & ATH9K_INT_BB_WATCHDOG)) { 674 675 ath_reset(sc, true); 675 676 return; 676 677 } ··· 738 737 { 739 738 #define SCHED_INTR ( \ 740 739 ATH9K_INT_FATAL | \ 740 + ATH9K_INT_BB_WATCHDOG | \ 741 741 ATH9K_INT_RXORN | \ 742 742 ATH9K_INT_RXEOL | \ 743 743 ATH9K_INT_RX | \
+2 -1
drivers/net/wireless/ath/ath9k/rc.c
··· 689 689 690 690 if (WLAN_RC_PHY_HT(rate_table->info[rix].phy)) { 691 691 rate->flags |= IEEE80211_TX_RC_MCS; 692 - if (WLAN_RC_PHY_40(rate_table->info[rix].phy)) 692 + if (WLAN_RC_PHY_40(rate_table->info[rix].phy) && 693 + conf_is_ht40(&txrc->hw->conf)) 693 694 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; 694 695 if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy)) 695 696 rate->flags |= IEEE80211_TX_RC_SHORT_GI;
+1 -1
drivers/net/wireless/b43/phy_n.c
··· 3093 3093 int freq; 3094 3094 bool avoid = false; 3095 3095 u8 length; 3096 - u16 tmp, core, type, count, max, numb, last, cmd; 3096 + u16 tmp, core, type, count, max, numb, last = 0, cmd; 3097 3097 const u16 *table; 3098 3098 bool phy6or5x; 3099 3099
+2 -2
drivers/net/wireless/iwlegacy/iwl-4965-lib.c
··· 628 628 629 629 /* rx_status carries information about the packet to mac80211 */ 630 630 rx_status.mactime = le64_to_cpu(phy_res->timestamp); 631 + rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 632 + IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 631 633 rx_status.freq = 632 634 ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), 633 635 rx_status.band); 634 - rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 635 - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 636 636 rx_status.rate_idx = 637 637 iwl4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); 638 638 rx_status.flag = 0;
+1 -1
drivers/net/wireless/iwlegacy/iwl-4965.c
··· 1543 1543 s32 temp; 1544 1544 1545 1545 temp = iwl4965_hw_get_temperature(priv); 1546 - if (temp < 0) 1546 + if (IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) 1547 1547 return; 1548 1548 1549 1549 if (priv->temperature != temp) {
+18 -10
drivers/net/wireless/iwlwifi/iwl-6000.c
··· 603 603 IWL_DEVICE_6050, 604 604 }; 605 605 606 + #define IWL_DEVICE_6150 \ 607 + .fw_name_pre = IWL6050_FW_PRE, \ 608 + .ucode_api_max = IWL6050_UCODE_API_MAX, \ 609 + .ucode_api_min = IWL6050_UCODE_API_MIN, \ 610 + .ops = &iwl6150_ops, \ 611 + .eeprom_ver = EEPROM_6150_EEPROM_VERSION, \ 612 + .eeprom_calib_ver = EEPROM_6150_TX_POWER_VERSION, \ 613 + .base_params = &iwl6050_base_params, \ 614 + .need_dc_calib = true, \ 615 + .led_mode = IWL_LED_BLINK, \ 616 + .internal_wimax_coex = true 617 + 606 618 struct iwl_cfg iwl6150_bgn_cfg = { 607 619 .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BGN", 608 - .fw_name_pre = IWL6050_FW_PRE, 609 - .ucode_api_max = IWL6050_UCODE_API_MAX, 610 - .ucode_api_min = IWL6050_UCODE_API_MIN, 611 - .eeprom_ver = EEPROM_6150_EEPROM_VERSION, 612 - .eeprom_calib_ver = EEPROM_6150_TX_POWER_VERSION, 613 - .ops = &iwl6150_ops, 614 - .base_params = &iwl6050_base_params, 620 + IWL_DEVICE_6150, 615 621 .ht_params = &iwl6000_ht_params, 616 - .need_dc_calib = true, 617 - .led_mode = IWL_LED_RF_STATE, 618 - .internal_wimax_coex = true, 622 + }; 623 + 624 + struct iwl_cfg iwl6150_bg_cfg = { 625 + .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BG", 626 + IWL_DEVICE_6150, 619 627 }; 620 628 621 629 struct iwl_cfg iwl6000_3agn_cfg = {
+3 -3
drivers/net/wireless/iwlwifi/iwl-agn.c
··· 3831 3831 3832 3832 /* 6150 WiFi/WiMax Series */ 3833 3833 {IWL_PCI_DEVICE(0x0885, 0x1305, iwl6150_bgn_cfg)}, 3834 - {IWL_PCI_DEVICE(0x0885, 0x1306, iwl6150_bgn_cfg)}, 3834 + {IWL_PCI_DEVICE(0x0885, 0x1307, iwl6150_bg_cfg)}, 3835 3835 {IWL_PCI_DEVICE(0x0885, 0x1325, iwl6150_bgn_cfg)}, 3836 - {IWL_PCI_DEVICE(0x0885, 0x1326, iwl6150_bgn_cfg)}, 3836 + {IWL_PCI_DEVICE(0x0885, 0x1327, iwl6150_bg_cfg)}, 3837 3837 {IWL_PCI_DEVICE(0x0886, 0x1315, iwl6150_bgn_cfg)}, 3838 - {IWL_PCI_DEVICE(0x0886, 0x1316, iwl6150_bgn_cfg)}, 3838 + {IWL_PCI_DEVICE(0x0886, 0x1317, iwl6150_bg_cfg)}, 3839 3839 3840 3840 /* 1000 Series WiFi */ 3841 3841 {IWL_PCI_DEVICE(0x0083, 0x1205, iwl1000_bgn_cfg)},
+1
drivers/net/wireless/iwlwifi/iwl-agn.h
··· 89 89 extern struct iwl_cfg iwl6050_2agn_cfg; 90 90 extern struct iwl_cfg iwl6050_2abg_cfg; 91 91 extern struct iwl_cfg iwl6150_bgn_cfg; 92 + extern struct iwl_cfg iwl6150_bg_cfg; 92 93 extern struct iwl_cfg iwl1000_bgn_cfg; 93 94 extern struct iwl_cfg iwl1000_bg_cfg; 94 95 extern struct iwl_cfg iwl100_bgn_cfg;
+3 -3
drivers/net/wireless/libertas/cmd.c
··· 994 994 cmd = cmdnode->cmdbuf; 995 995 996 996 spin_lock_irqsave(&priv->driver_lock, flags); 997 + priv->seqnum++; 998 + cmd->seqnum = cpu_to_le16(priv->seqnum); 997 999 priv->cur_cmd = cmdnode; 998 1000 spin_unlock_irqrestore(&priv->driver_lock, flags); 999 1001 ··· 1623 1621 /* Copy the incoming command to the buffer */ 1624 1622 memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size); 1625 1623 1626 - /* Set sequence number, clean result, move to buffer */ 1627 - priv->seqnum++; 1624 + /* Set command, clean result, move to buffer */ 1628 1625 cmdnode->cmdbuf->command = cpu_to_le16(command); 1629 1626 cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size); 1630 - cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum); 1631 1627 cmdnode->cmdbuf->result = 0; 1632 1628 1633 1629 lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
+2 -2
drivers/net/wireless/mwifiex/sdio.h
··· 167 167 /* Rx unit register */ 168 168 #define CARD_RX_UNIT_REG 0x63 169 169 170 - /* Event header Len*/ 171 - #define MWIFIEX_EVENT_HEADER_LEN 8 170 + /* Event header len w/o 4 bytes of interface header */ 171 + #define MWIFIEX_EVENT_HEADER_LEN 4 172 172 173 173 /* Max retry number of CMD53 write */ 174 174 #define MAX_WRITE_IOMEM_RETRY 2
-1
drivers/net/wireless/rt2x00/Kconfig
··· 166 166 config RT2800USB_RT53XX 167 167 bool "rt2800usb - Include support for rt53xx devices (EXPERIMENTAL)" 168 168 depends on EXPERIMENTAL 169 - default y 170 169 ---help--- 171 170 This adds support for rt53xx wireless chipset family to the 172 171 rt2800pci driver.
+22 -13
drivers/net/wireless/rtlwifi/pci.c
··· 669 669 &rx_status, 670 670 (u8 *) pdesc, skb); 671 671 672 - pci_unmap_single(rtlpci->pdev, 673 - *((dma_addr_t *) skb->cb), 674 - rtlpci->rxbuffersize, 675 - PCI_DMA_FROMDEVICE); 676 - 677 672 skb_put(skb, rtlpriv->cfg->ops->get_desc((u8 *) pdesc, 678 673 false, 679 674 HW_DESC_RXPKT_LEN)); ··· 684 689 685 690 hdr = rtl_get_hdr(skb); 686 691 fc = rtl_get_fc(skb); 692 + 693 + /* try for new buffer - if allocation fails, drop 694 + * frame and reuse old buffer 695 + */ 696 + new_skb = dev_alloc_skb(rtlpci->rxbuffersize); 697 + if (unlikely(!new_skb)) { 698 + RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV), 699 + DBG_DMESG, 700 + ("can't alloc skb for rx\n")); 701 + goto done; 702 + } 703 + pci_unmap_single(rtlpci->pdev, 704 + *((dma_addr_t *) skb->cb), 705 + rtlpci->rxbuffersize, 706 + PCI_DMA_FROMDEVICE); 687 707 688 708 if (!stats.crc || !stats.hwerror) { 689 709 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, ··· 768 758 rtl_lps_leave(hw); 769 759 } 770 760 771 - new_skb = dev_alloc_skb(rtlpci->rxbuffersize); 772 - if (unlikely(!new_skb)) { 773 - RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV), 774 - DBG_DMESG, 775 - ("can't alloc skb for rx\n")); 776 - goto done; 777 - } 778 761 skb = new_skb; 779 - /*skb->dev = dev; */ 780 762 781 763 rtlpci->rx_ring[rx_queue_idx].rx_buf[rtlpci-> 782 764 rx_ring ··· 1114 1112 rtlpci->rxringcount); 1115 1113 1116 1114 rtlpci->rx_ring[rx_queue_idx].idx = 0; 1115 + 1116 + /* If amsdu_8k is disabled, set buffersize to 4096. This 1117 + * change will reduce memory fragmentation. 1118 + */ 1119 + if (rtlpci->rxbuffersize > 4096 && 1120 + rtlpriv->rtlhal.disable_amsdu_8k) 1121 + rtlpci->rxbuffersize = 4096; 1117 1122 1118 1123 for (i = 0; i < rtlpci->rxringcount; i++) { 1119 1124 struct sk_buff *skb =
+3
drivers/net/wireless/wl12xx/conf.h
··· 1157 1157 /* time to wait on the channel for passive scans (in TUs) */ 1158 1158 u32 dwell_time_passive; 1159 1159 1160 + /* time to wait on the channel for DFS scans (in TUs) */ 1161 + u32 dwell_time_dfs; 1162 + 1160 1163 /* number of probe requests to send on each channel in active scans */ 1161 1164 u8 num_probe_reqs; 1162 1165
+1
drivers/net/wireless/wl12xx/main.c
··· 311 311 .min_dwell_time_active = 8, 312 312 .max_dwell_time_active = 30, 313 313 .dwell_time_passive = 100, 314 + .dwell_time_dfs = 150, 314 315 .num_probe_reqs = 2, 315 316 .rssi_threshold = -90, 316 317 .snr_threshold = 0,
+34 -17
drivers/net/wireless/wl12xx/scan.c
··· 331 331 struct conf_sched_scan_settings *c = &wl->conf.sched_scan; 332 332 int i, j; 333 333 u32 flags; 334 + bool force_passive = !req->n_ssids; 334 335 335 336 for (i = 0, j = start; 336 337 i < req->n_channels && j < MAX_CHANNELS_ALL_BANDS; 337 338 i++) { 338 339 flags = req->channels[i]->flags; 339 340 340 - if (!(flags & IEEE80211_CHAN_DISABLED) && 341 - ((flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive) && 342 - ((flags & IEEE80211_CHAN_RADAR) == radar) && 343 - (req->channels[i]->band == band)) { 341 + if (force_passive) 342 + flags |= IEEE80211_CHAN_PASSIVE_SCAN; 343 + 344 + if ((req->channels[i]->band == band) && 345 + !(flags & IEEE80211_CHAN_DISABLED) && 346 + (!!(flags & IEEE80211_CHAN_RADAR) == radar) && 347 + /* if radar is set, we ignore the passive flag */ 348 + (radar || 349 + !!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) { 344 350 wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ", 345 351 req->channels[i]->band, 346 352 req->channels[i]->center_freq); ··· 356 350 wl1271_debug(DEBUG_SCAN, "max_power %d", 357 351 req->channels[i]->max_power); 358 352 359 - if (flags & IEEE80211_CHAN_PASSIVE_SCAN) { 353 + if (flags & IEEE80211_CHAN_RADAR) { 354 + channels[j].flags |= SCAN_CHANNEL_FLAGS_DFS; 355 + channels[j].passive_duration = 356 + cpu_to_le16(c->dwell_time_dfs); 357 + } 358 + else if (flags & IEEE80211_CHAN_PASSIVE_SCAN) { 360 359 channels[j].passive_duration = 361 360 cpu_to_le16(c->dwell_time_passive); 362 361 } else { ··· 370 359 channels[j].max_duration = 371 360 cpu_to_le16(c->max_dwell_time_active); 372 361 } 373 - channels[j].tx_power_att = req->channels[j]->max_power; 362 + channels[j].tx_power_att = req->channels[i]->max_power; 374 363 channels[j].channel = req->channels[i]->hw_value; 375 364 376 365 j++; ··· 397 386 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, 398 387 IEEE80211_BAND_2GHZ, 399 388 false, false, idx); 400 - idx += cfg->active[0]; 389 + /* 390 + * 5GHz channels always start at position 14, not immediately 391 + * after the last 2.4GHz channel 392 + */ 393 + idx = 14; 401 394 402 395 cfg->passive[1] = 403 396 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, ··· 409 394 false, true, idx); 410 395 idx += cfg->passive[1]; 411 396 412 - cfg->active[1] = 413 - wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, 414 - IEEE80211_BAND_5GHZ, 415 - false, false, 14); 416 - idx += cfg->active[1]; 417 - 418 397 cfg->dfs = 419 398 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, 420 399 IEEE80211_BAND_5GHZ, 421 - true, false, idx); 400 + true, true, idx); 422 401 idx += cfg->dfs; 402 + 403 + cfg->active[1] = 404 + wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, 405 + IEEE80211_BAND_5GHZ, 406 + false, false, idx); 407 + idx += cfg->active[1]; 423 408 424 409 wl1271_debug(DEBUG_SCAN, " 2.4GHz: active %d passive %d", 425 410 cfg->active[0], cfg->passive[0]); 426 411 wl1271_debug(DEBUG_SCAN, " 5GHz: active %d passive %d", 427 412 cfg->active[1], cfg->passive[1]); 413 + wl1271_debug(DEBUG_SCAN, " DFS: %d", cfg->dfs); 428 414 429 415 return idx; 430 416 } ··· 437 421 struct wl1271_cmd_sched_scan_config *cfg = NULL; 438 422 struct conf_sched_scan_settings *c = &wl->conf.sched_scan; 439 423 int i, total_channels, ret; 424 + bool force_passive = !req->n_ssids; 440 425 441 426 wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config"); 442 427 ··· 461 444 for (i = 0; i < SCAN_MAX_CYCLE_INTERVALS; i++) 462 445 cfg->intervals[i] = cpu_to_le32(req->interval); 463 446 464 - if (req->ssids[0].ssid_len && req->ssids[0].ssid) { 447 + if (!force_passive && req->ssids[0].ssid_len && req->ssids[0].ssid) { 465 448 cfg->filter_type = SCAN_SSID_FILTER_SPECIFIC; 466 449 cfg->ssid_len = req->ssids[0].ssid_len; 467 450 memcpy(cfg->ssid, req->ssids[0].ssid, ··· 478 461 goto out; 479 462 } 480 463 481 - if (cfg->active[0]) { 464 + if (!force_passive && cfg->active[0]) { 482 465 ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid, 483 466 req->ssids[0].ssid_len, 484 467 ies->ie[IEEE80211_BAND_2GHZ], ··· 490 473 } 491 474 } 492 475 493 - if (cfg->active[1]) { 476 + if (!force_passive && cfg->active[1]) { 494 477 ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid, 495 478 req->ssids[0].ssid_len, 496 479 ies->ie[IEEE80211_BAND_5GHZ],
+3
drivers/net/wireless/wl12xx/scan.h
··· 137 137 SCAN_BSS_TYPE_ANY, 138 138 }; 139 139 140 + #define SCAN_CHANNEL_FLAGS_DFS BIT(0) 141 + #define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1) 142 + 140 143 struct conn_scan_ch_params { 141 144 __le16 min_duration; 142 145 __le16 max_duration;
+42 -11
drivers/net/wireless/zd1211rw/zd_usb.c
··· 1533 1533 module_init(usb_init); 1534 1534 module_exit(usb_exit); 1535 1535 1536 + static int zd_ep_regs_out_msg(struct usb_device *udev, void *data, int len, 1537 + int *actual_length, int timeout) 1538 + { 1539 + /* In USB 2.0 mode EP_REGS_OUT endpoint is interrupt type. However in 1540 + * USB 1.1 mode endpoint is bulk. Select correct type URB by endpoint 1541 + * descriptor. 1542 + */ 1543 + struct usb_host_endpoint *ep; 1544 + unsigned int pipe; 1545 + 1546 + pipe = usb_sndintpipe(udev, EP_REGS_OUT); 1547 + ep = usb_pipe_endpoint(udev, pipe); 1548 + if (!ep) 1549 + return -EINVAL; 1550 + 1551 + if (usb_endpoint_xfer_int(&ep->desc)) { 1552 + return usb_interrupt_msg(udev, pipe, data, len, 1553 + actual_length, timeout); 1554 + } else { 1555 + pipe = usb_sndbulkpipe(udev, EP_REGS_OUT); 1556 + return usb_bulk_msg(udev, pipe, data, len, actual_length, 1557 + timeout); 1558 + } 1559 + } 1560 + 1536 1561 static int usb_int_regs_length(unsigned int count) 1537 1562 { 1538 1563 return sizeof(struct usb_int_regs) + count * sizeof(struct reg_data); ··· 1673 1648 1674 1649 udev = zd_usb_to_usbdev(usb); 1675 1650 prepare_read_regs_int(usb); 1676 - r = usb_interrupt_msg(udev, usb_sndintpipe(udev, EP_REGS_OUT), 1677 - req, req_len, &actual_req_len, 50 /* ms */); 1651 + r = zd_ep_regs_out_msg(udev, req, req_len, &actual_req_len, 50 /*ms*/); 1678 1652 if (r) { 1679 1653 dev_dbg_f(zd_usb_dev(usb), 1680 - "error in usb_interrupt_msg(). Error number %d\n", r); 1654 + "error in zd_ep_regs_out_msg(). Error number %d\n", r); 1681 1655 goto error; 1682 1656 } 1683 1657 if (req_len != actual_req_len) { 1684 - dev_dbg_f(zd_usb_dev(usb), "error in usb_interrupt_msg()\n" 1658 + dev_dbg_f(zd_usb_dev(usb), "error in zd_ep_regs_out_msg()\n" 1685 1659 " req_len %d != actual_req_len %d\n", 1686 1660 req_len, actual_req_len); 1687 1661 r = -EIO; ··· 1842 1818 rw->value = cpu_to_le16(ioreqs[i].value); 1843 1819 } 1844 1820 1845 - usb_fill_int_urb(urb, udev, usb_sndintpipe(udev, EP_REGS_OUT), 1846 - req, req_len, iowrite16v_urb_complete, usb, 1847 - ep->desc.bInterval); 1821 + /* In USB 2.0 mode endpoint is interrupt type. However in USB 1.1 mode 1822 + * endpoint is bulk. Select correct type URB by endpoint descriptor. 1823 + */ 1824 + if (usb_endpoint_xfer_int(&ep->desc)) 1825 + usb_fill_int_urb(urb, udev, usb_sndintpipe(udev, EP_REGS_OUT), 1826 + req, req_len, iowrite16v_urb_complete, usb, 1827 + ep->desc.bInterval); 1828 + else 1829 + usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_REGS_OUT), 1830 + req, req_len, iowrite16v_urb_complete, usb); 1831 + 1848 1832 urb->transfer_flags |= URB_FREE_BUFFER; 1849 1833 1850 1834 /* Submit previous URB */ ··· 1956 1924 } 1957 1925 1958 1926 udev = zd_usb_to_usbdev(usb); 1959 - r = usb_interrupt_msg(udev, usb_sndintpipe(udev, EP_REGS_OUT), 1960 - req, req_len, &actual_req_len, 50 /* ms */); 1927 + r = zd_ep_regs_out_msg(udev, req, req_len, &actual_req_len, 50 /*ms*/); 1961 1928 if (r) { 1962 1929 dev_dbg_f(zd_usb_dev(usb), 1963 - "error in usb_interrupt_msg(). Error number %d\n", r); 1930 + "error in zd_ep_regs_out_msg(). Error number %d\n", r); 1964 1931 goto out; 1965 1932 } 1966 1933 if (req_len != actual_req_len) { 1967 - dev_dbg_f(zd_usb_dev(usb), "error in usb_interrupt_msg()" 1934 + dev_dbg_f(zd_usb_dev(usb), "error in zd_ep_regs_out_msg()" 1968 1935 " req_len %d != actual_req_len %d\n", 1969 1936 req_len, actual_req_len); 1970 1937 r = -EIO;
+1 -6
drivers/pci/dmar.c
··· 698 698 { 699 699 #ifdef CONFIG_INTR_REMAP 700 700 struct acpi_table_dmar *dmar; 701 - /* 702 - * for now we will disable dma-remapping when interrupt 703 - * remapping is enabled. 704 - * When support for queued invalidation for IOTLB invalidation 705 - * is added, we will not need this any more. 706 - */ 701 + 707 702 dmar = (struct acpi_table_dmar *) dmar_tbl; 708 703 if (ret && cpu_has_x2apic && dmar->flags & 0x1) 709 704 printk(KERN_INFO
+201 -39
drivers/pci/intel-iommu.c
··· 47 47 #define ROOT_SIZE VTD_PAGE_SIZE 48 48 #define CONTEXT_SIZE VTD_PAGE_SIZE 49 49 50 + #define IS_BRIDGE_HOST_DEVICE(pdev) \ 51 + ((pdev->class >> 8) == PCI_CLASS_BRIDGE_HOST) 50 52 #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) 51 53 #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) 52 54 #define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e) ··· 118 116 return (pfn + level_size(level) - 1) & level_mask(level); 119 117 } 120 118 119 + static inline unsigned long lvl_to_nr_pages(unsigned int lvl) 120 + { 121 + return 1 << ((lvl - 1) * LEVEL_STRIDE); 122 + } 123 + 121 124 /* VT-d pages must always be _smaller_ than MM pages. Otherwise things 122 125 are never going to work. */ 123 126 static inline unsigned long dma_to_mm_pfn(unsigned long dma_pfn) ··· 148 141 149 142 static void __init check_tylersburg_isoch(void); 150 143 static int rwbf_quirk; 144 + 145 + /* 146 + * set to 1 to panic kernel if can't successfully enable VT-d 147 + * (used when kernel is launched w/ TXT) 148 + */ 149 + static int force_on = 0; 151 150 152 151 /* 153 152 * 0: Present ··· 351 338 int iommu_coherency;/* indicate coherency of iommu access */ 352 339 int iommu_snooping; /* indicate snooping control feature*/ 353 340 int iommu_count; /* reference count of iommu */ 341 + int iommu_superpage;/* Level of superpages supported: 342 + 0 == 4KiB (no superpages), 1 == 2MiB, 343 + 2 == 1GiB, 3 == 512GiB, 4 == 1TiB */ 354 344 spinlock_t iommu_lock; /* protect iommu set in domain */ 355 345 u64 max_addr; /* maximum mapped address */ 356 346 }; ··· 403 387 static int dmar_map_gfx = 1; 404 388 static int dmar_forcedac; 405 389 static int intel_iommu_strict; 390 + static int intel_iommu_superpage = 1; 406 391 407 392 #define DUMMY_DEVICE_DOMAIN_INFO ((struct device_domain_info *)(-1)) 408 393 static DEFINE_SPINLOCK(device_domain_lock); ··· 434 417 printk(KERN_INFO 435 418 "Intel-IOMMU: disable batched IOTLB flush\n"); 436 419 intel_iommu_strict = 1; 420 + } else if (!strncmp(str, "sp_off", 6)) { 421 + printk(KERN_INFO 422 + "Intel-IOMMU: disable supported super page\n"); 423 + intel_iommu_superpage = 0; 437 424 } 438 425 439 426 str += strcspn(str, ","); ··· 576 555 } 577 556 } 578 557 558 + static void domain_update_iommu_superpage(struct dmar_domain *domain) 559 + { 560 + int i, mask = 0xf; 561 + 562 + if (!intel_iommu_superpage) { 563 + domain->iommu_superpage = 0; 564 + return; 565 + } 566 + 567 + domain->iommu_superpage = 4; /* 1TiB */ 568 + 569 + for_each_set_bit(i, &domain->iommu_bmp, g_num_of_iommus) { 570 + mask |= cap_super_page_val(g_iommus[i]->cap); 571 + if (!mask) { 572 + break; 573 + } 574 + } 575 + domain->iommu_superpage = fls(mask); 576 + } 577 + 579 578 /* Some capabilities may be different across iommus */ 580 579 static void domain_update_iommu_cap(struct dmar_domain *domain) 581 580 { 582 581 domain_update_iommu_coherency(domain); 583 582 domain_update_iommu_snooping(domain); 583 + domain_update_iommu_superpage(domain); 584 584 } 585 585 586 586 static struct intel_iommu *device_to_iommu(int segment, u8 bus, u8 devfn) ··· 731 689 } 732 690 733 691 static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, 734 - unsigned long pfn) 692 + unsigned long pfn, int large_level) 735 693 { 736 694 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT; 737 695 struct dma_pte *parent, *pte = NULL; 738 696 int level = agaw_to_level(domain->agaw); 739 - int offset; 697 + int offset, target_level; 740 698 741 699 BUG_ON(!domain->pgd); 742 700 BUG_ON(addr_width < BITS_PER_LONG && pfn >> addr_width); 743 701 parent = domain->pgd; 702 + 703 + /* Search pte */ 704 + if (!large_level) 705 + target_level = 1; 706 + else 707 + target_level = large_level; 744 708 745 709 while (level > 0) { 746 710 void *tmp_page; 747 711 748 712 offset = pfn_level_offset(pfn, level); 749 713 pte = &parent[offset]; 750 - if (level == 1) 714 + if (!large_level && (pte->val & DMA_PTE_LARGE_PAGE)) 715 + break; 716 + if (level == target_level) 751 717 break; 752 718 753 719 if (!dma_pte_present(pte)) { ··· 783 733 return pte; 784 734 } 785 735 736 + 786 737 /* return address's pte at specific level */ 787 738 static struct dma_pte *dma_pfn_level_pte(struct dmar_domain *domain, 788 739 unsigned long pfn, 789 - int level) 740 + int level, int *large_page) 790 741 { 791 742 struct dma_pte *parent, *pte = NULL; 792 743 int total = agaw_to_level(domain->agaw); ··· 800 749 if (level == total) 801 750 return pte; 802 751 803 - if (!dma_pte_present(pte)) 752 + if (!dma_pte_present(pte)) { 753 + *large_page = total; 804 754 break; 755 + } 756 + 757 + if (pte->val & DMA_PTE_LARGE_PAGE) { 758 + *large_page = total; 759 + return pte; 760 + } 761 + 805 762 parent = phys_to_virt(dma_pte_addr(pte)); 806 763 total--; 807 764 } ··· 822 763 unsigned long last_pfn) 823 764 { 824 765 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT; 766 + unsigned int large_page = 1; 825 767 struct dma_pte *first_pte, *pte; 826 768 827 769 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width); ··· 831 771 832 772 /* we don't need lock here; nobody else touches the iova range */ 833 773 do { 834 - first_pte = pte = dma_pfn_level_pte(domain, start_pfn, 1); 774 + large_page = 1; 775 + first_pte = pte = dma_pfn_level_pte(domain, start_pfn, 1, &large_page); 835 776 if (!pte) { 836 - start_pfn = align_to_level(start_pfn + 1, 2); 777 + start_pfn = align_to_level(start_pfn + 1, large_page + 1); 837 778 continue; 838 779 } 839 - do { 780 + do { 840 781 dma_clear_pte(pte); 841 - start_pfn++; 782 + start_pfn += lvl_to_nr_pages(large_page); 842 783 pte++; 843 784 } while (start_pfn <= last_pfn && !first_pte_in_page(pte)); 844 785 ··· 859 798 int total = agaw_to_level(domain->agaw); 860 799 int level; 861 800 unsigned long tmp; 801 + int large_page = 2; 862 802 863 803 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width); 864 804 BUG_ON(addr_width < BITS_PER_LONG && last_pfn >> addr_width); ··· 875 813 return; 876 814 877 815 do { 878 - first_pte = pte = dma_pfn_level_pte(domain, tmp, level); 816 + large_page = level; 817 + first_pte = pte = dma_pfn_level_pte(domain, tmp, level, &large_page); 818 + if (large_page > level) 819 + level = large_page + 1; 879 820 if (!pte) { 880 821 tmp = align_to_level(tmp + 1, level + 1); 881 822 continue; ··· 1462 1397 else 1463 1398 domain->iommu_snooping = 0; 1464 1399 1400 + domain->iommu_superpage = fls(cap_super_page_val(iommu->cap)); 1465 1401 domain->iommu_count = 1; 1466 1402 domain->nid = iommu->node; 1467 1403 ··· 1482 1416 /* Domain 0 is reserved, so dont process it */ 1483 1417 if (!domain) 1484 1418 return; 1419 + 1420 + /* Flush any lazy unmaps that may reference this domain */ 1421 + if (!intel_iommu_strict) 1422 + flush_unmaps_timeout(0); 1485 1423 1486 1424 domain_remove_dev_info(domain); 1487 1425 /* destroy iovas */ ··· 1718 1648 return PAGE_ALIGN(host_addr + size) >> VTD_PAGE_SHIFT; 1719 1649 } 1720 1650 1651 + /* Return largest possible superpage level for a given mapping */ 1652 + static inline int hardware_largepage_caps(struct dmar_domain *domain, 1653 + unsigned long iov_pfn, 1654 + unsigned long phy_pfn, 1655 + unsigned long pages) 1656 + { 1657 + int support, level = 1; 1658 + unsigned long pfnmerge; 1659 + 1660 + support = domain->iommu_superpage; 1661 + 1662 + /* To use a large page, the virtual *and* physical addresses 1663 + must be aligned to 2MiB/1GiB/etc. Lower bits set in either 1664 + of them will mean we have to use smaller pages. So just 1665 + merge them and check both at once. */ 1666 + pfnmerge = iov_pfn | phy_pfn; 1667 + 1668 + while (support && !(pfnmerge & ~VTD_STRIDE_MASK)) { 1669 + pages >>= VTD_STRIDE_SHIFT; 1670 + if (!pages) 1671 + break; 1672 + pfnmerge >>= VTD_STRIDE_SHIFT; 1673 + level++; 1674 + support--; 1675 + } 1676 + return level; 1677 + } 1678 + 1721 1679 static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn, 1722 1680 struct scatterlist *sg, unsigned long phys_pfn, 1723 1681 unsigned long nr_pages, int prot) ··· 1754 1656 phys_addr_t uninitialized_var(pteval); 1755 1657 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT; 1756 1658 unsigned long sg_res; 1659 + unsigned int largepage_lvl = 0; 1660 + unsigned long lvl_pages = 0; 1757 1661 1758 1662 BUG_ON(addr_width < BITS_PER_LONG && (iov_pfn + nr_pages - 1) >> addr_width); 1759 1663 ··· 1771 1671 pteval = ((phys_addr_t)phys_pfn << VTD_PAGE_SHIFT) | prot; 1772 1672 } 1773 1673 1774 - while (nr_pages--) { 1674 + while (nr_pages > 0) { 1775 1675 uint64_t tmp; 1776 1676 1777 1677 if (!sg_res) { ··· 1779 1679 sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset; 1780 1680 sg->dma_length = sg->length; 1781 1681 pteval = page_to_phys(sg_page(sg)) | prot; 1682 + phys_pfn = pteval >> VTD_PAGE_SHIFT; 1782 1683 } 1684 + 1783 1685 if (!pte) { 1784 - first_pte = pte = pfn_to_dma_pte(domain, iov_pfn); 1686 + largepage_lvl = hardware_largepage_caps(domain, iov_pfn, phys_pfn, sg_res); 1687 + 1688 + first_pte = pte = pfn_to_dma_pte(domain, iov_pfn, largepage_lvl); 1785 1689 if (!pte) 1786 1690 return -ENOMEM; 1691 + /* It is large page*/ 1692 + if (largepage_lvl > 1) 1693 + pteval |= DMA_PTE_LARGE_PAGE; 1694 + else 1695 + pteval &= ~(uint64_t)DMA_PTE_LARGE_PAGE; 1696 + 1787 1697 } 1788 1698 /* We don't need lock here, nobody else 1789 1699 * touches the iova range ··· 1809 1699 } 1810 1700 WARN_ON(1); 1811 1701 } 1702 + 1703 + lvl_pages = lvl_to_nr_pages(largepage_lvl); 1704 + 1705 + BUG_ON(nr_pages < lvl_pages); 1706 + BUG_ON(sg_res < lvl_pages); 1707 + 1708 + nr_pages -= lvl_pages; 1709 + iov_pfn += lvl_pages; 1710 + phys_pfn += lvl_pages; 1711 + pteval += lvl_pages * VTD_PAGE_SIZE; 1712 + sg_res -= lvl_pages; 1713 + 1714 + /* If the next PTE would be the first in a new page, then we 1715 + need to flush the cache on the entries we've just written. 1716 + And then we'll need to recalculate 'pte', so clear it and 1717 + let it get set again in the if (!pte) block above. 1718 + 1719 + If we're done (!nr_pages) we need to flush the cache too. 1720 + 1721 + Also if we've been setting superpages, we may need to 1722 + recalculate 'pte' and switch back to smaller pages for the 1723 + end of the mapping, if the trailing size is not enough to 1724 + use another superpage (i.e. sg_res < lvl_pages). */ 1812 1725 pte++; 1813 - if (!nr_pages || first_pte_in_page(pte)) { 1726 + if (!nr_pages || first_pte_in_page(pte) || 1727 + (largepage_lvl > 1 && sg_res < lvl_pages)) { 1814 1728 domain_flush_cache(domain, first_pte, 1815 1729 (void *)pte - (void *)first_pte); 1816 1730 pte = NULL; 1817 1731 } 1818 - iov_pfn++; 1819 - pteval += VTD_PAGE_SIZE; 1820 - sg_res--; 1821 - if (!sg_res) 1732 + 1733 + if (!sg_res && nr_pages) 1822 1734 sg = sg_next(sg); 1823 1735 } 1824 1736 return 0; ··· 2148 2016 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) 2149 2017 return 0; 2150 2018 return iommu_prepare_identity_map(pdev, rmrr->base_address, 2151 - rmrr->end_address + 1); 2019 + rmrr->end_address); 2152 2020 } 2153 2021 2154 2022 #ifdef CONFIG_DMAR_FLOPPY_WA ··· 2162 2030 return; 2163 2031 2164 2032 printk(KERN_INFO "IOMMU: Prepare 0-16MiB unity mapping for LPC\n"); 2165 - ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024); 2033 + ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024 - 1); 2166 2034 2167 2035 if (ret) 2168 2036 printk(KERN_ERR "IOMMU: Failed to create 0-16MiB identity map; " ··· 2238 2106 if (likely(!iommu_identity_mapping)) 2239 2107 return 0; 2240 2108 2109 + info = pdev->dev.archdata.iommu; 2110 + if (info && info != DUMMY_DEVICE_DOMAIN_INFO) 2111 + return (info->domain == si_domain); 2241 2112 2242 - list_for_each_entry(info, &si_domain->devices, link) 2243 - if (info->dev == pdev) 2244 - return 1; 2245 2113 return 0; 2246 2114 } 2247 2115 ··· 2319 2187 * Assume that they will -- if they turn out not to be, then we can 2320 2188 * take them out of the 1:1 domain later. 2321 2189 */ 2322 - if (!startup) 2323 - return pdev->dma_mask > DMA_BIT_MASK(32); 2190 + if (!startup) { 2191 + /* 2192 + * If the device's dma_mask is less than the system's memory 2193 + * size then this is not a candidate for identity mapping. 2194 + */ 2195 + u64 dma_mask = pdev->dma_mask; 2196 + 2197 + if (pdev->dev.coherent_dma_mask && 2198 + pdev->dev.coherent_dma_mask < dma_mask) 2199 + dma_mask = pdev->dev.coherent_dma_mask; 2200 + 2201 + return dma_mask >= dma_get_required_mask(&pdev->dev); 2202 + } 2324 2203 2325 2204 return 1; 2326 2205 } ··· 2346 2203 return -EFAULT; 2347 2204 2348 2205 for_each_pci_dev(pdev) { 2206 + /* Skip Host/PCI Bridge devices */ 2207 + if (IS_BRIDGE_HOST_DEVICE(pdev)) 2208 + continue; 2349 2209 if (iommu_should_identity_map(pdev, 1)) { 2350 2210 printk(KERN_INFO "IOMMU: %s identity mapping for device %s\n", 2351 2211 hw ? "hardware" : "software", pci_name(pdev)); ··· 2364 2218 return 0; 2365 2219 } 2366 2220 2367 - static int __init init_dmars(int force_on) 2221 + static int __init init_dmars(void) 2368 2222 { 2369 2223 struct dmar_drhd_unit *drhd; 2370 2224 struct dmar_rmrr_unit *rmrr; ··· 2738 2592 iommu = domain_get_iommu(domain); 2739 2593 size = aligned_nrpages(paddr, size); 2740 2594 2741 - iova = intel_alloc_iova(hwdev, domain, dma_to_mm_pfn(size), 2742 - pdev->dma_mask); 2595 + iova = intel_alloc_iova(hwdev, domain, dma_to_mm_pfn(size), dma_mask); 2743 2596 if (!iova) 2744 2597 goto error; 2745 2598 ··· 3263 3118 if (iommu->qi) 3264 3119 dmar_reenable_qi(iommu); 3265 3120 3266 - for_each_active_iommu(iommu, drhd) { 3121 + for_each_iommu(iommu, drhd) { 3122 + if (drhd->ignored) { 3123 + /* 3124 + * we always have to disable PMRs or DMA may fail on 3125 + * this device 3126 + */ 3127 + if (force_on) 3128 + iommu_disable_protect_mem_regions(iommu); 3129 + continue; 3130 + } 3131 + 3267 3132 iommu_flush_write_buffer(iommu); 3268 3133 3269 3134 iommu_set_root_entry(iommu); ··· 3282 3127 DMA_CCMD_GLOBAL_INVL); 3283 3128 iommu->flush.flush_iotlb(iommu, 0, 0, 0, 3284 3129 DMA_TLB_GLOBAL_FLUSH); 3285 - iommu_enable_translation(iommu); 3130 + if (iommu_enable_translation(iommu)) 3131 + return 1; 3286 3132 iommu_disable_protect_mem_regions(iommu); 3287 3133 } 3288 3134 ··· 3350 3194 unsigned long flag; 3351 3195 3352 3196 if (init_iommu_hw()) { 3353 - WARN(1, "IOMMU setup failed, DMAR can not resume!\n"); 3197 + if (force_on) 3198 + panic("tboot: IOMMU setup failed, DMAR can not resume!\n"); 3199 + else 3200 + WARN(1, "IOMMU setup failed, DMAR can not resume!\n"); 3354 3201 return; 3355 3202 } 3356 3203 ··· 3430 3271 int __init intel_iommu_init(void) 3431 3272 { 3432 3273 int ret = 0; 3433 - int force_on = 0; 3434 3274 3435 3275 /* VT-d is required for a TXT/tboot launch, so enforce that */ 3436 3276 force_on = tboot_force_iommu(); ··· 3467 3309 3468 3310 init_no_remapping_devices(); 3469 3311 3470 - ret = init_dmars(force_on); 3312 + ret = init_dmars(); 3471 3313 if (ret) { 3472 3314 if (force_on) 3473 3315 panic("tboot: Failed to initialize DMARs\n"); ··· 3538 3380 spin_lock_irqsave(&device_domain_lock, flags); 3539 3381 list_for_each_safe(entry, tmp, &domain->devices) { 3540 3382 info = list_entry(entry, struct device_domain_info, link); 3541 - /* No need to compare PCI domain; it has to be the same */ 3542 - if (info->bus == pdev->bus->number && 3383 + if (info->segment == pci_domain_nr(pdev->bus) && 3384 + info->bus == pdev->bus->number && 3543 3385 info->devfn == pdev->devfn) { 3544 3386 list_del(&info->link); 3545 3387 list_del(&info->global); ··· 3577 3419 domain_update_iommu_cap(domain); 3578 3420 spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags); 3579 3421 3580 - spin_lock_irqsave(&iommu->lock, tmp_flags); 3581 - clear_bit(domain->id, iommu->domain_ids); 3582 - iommu->domains[domain->id] = NULL; 3583 - spin_unlock_irqrestore(&iommu->lock, tmp_flags); 3422 + if (!(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) && 3423 + !(domain->flags & DOMAIN_FLAG_STATIC_IDENTITY)) { 3424 + spin_lock_irqsave(&iommu->lock, tmp_flags); 3425 + clear_bit(domain->id, iommu->domain_ids); 3426 + iommu->domains[domain->id] = NULL; 3427 + spin_unlock_irqrestore(&iommu->lock, tmp_flags); 3428 + } 3584 3429 } 3585 3430 3586 3431 spin_unlock_irqrestore(&device_domain_lock, flags); ··· 3666 3505 domain->iommu_count = 0; 3667 3506 domain->iommu_coherency = 0; 3668 3507 domain->iommu_snooping = 0; 3508 + domain->iommu_superpage = 0; 3669 3509 domain->max_addr = 0; 3670 3510 domain->nid = -1; 3671 3511 ··· 3882 3720 struct dma_pte *pte; 3883 3721 u64 phys = 0; 3884 3722 3885 - pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT); 3723 + pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, 0); 3886 3724 if (pte) 3887 3725 phys = dma_pte_addr(pte); 3888 3726
+10 -2
drivers/pci/iova.c
··· 63 63 curr = iovad->cached32_node; 64 64 cached_iova = container_of(curr, struct iova, node); 65 65 66 - if (free->pfn_lo >= cached_iova->pfn_lo) 67 - iovad->cached32_node = rb_next(&free->node); 66 + if (free->pfn_lo >= cached_iova->pfn_lo) { 67 + struct rb_node *node = rb_next(&free->node); 68 + struct iova *iova = container_of(node, struct iova, node); 69 + 70 + /* only cache if it's below 32bit pfn */ 71 + if (node && iova->pfn_lo < iovad->dma_32bit_pfn) 72 + iovad->cached32_node = node; 73 + else 74 + iovad->cached32_node = NULL; 75 + } 68 76 } 69 77 70 78 /* Computes the padding size required, to make the
+1 -1
drivers/scsi/scsi_scan.c
··· 297 297 kfree(sdev); 298 298 goto out; 299 299 } 300 - 300 + blk_get_queue(sdev->request_queue); 301 301 sdev->request_queue->queuedata = sdev; 302 302 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); 303 303
+1
drivers/scsi/scsi_sysfs.c
··· 322 322 kfree(evt); 323 323 } 324 324 325 + blk_put_queue(sdev->request_queue); 325 326 /* NULL queue means the device can't be used */ 326 327 sdev->request_queue = NULL; 327 328
+2 -4
drivers/tty/n_gsm.c
··· 2128 2128 gsm->tty = NULL; 2129 2129 } 2130 2130 2131 - static unsigned int gsmld_receive_buf(struct tty_struct *tty, 2132 - const unsigned char *cp, char *fp, int count) 2131 + static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp, 2132 + char *fp, int count) 2133 2133 { 2134 2134 struct gsm_mux *gsm = tty->disc_data; 2135 2135 const unsigned char *dp; ··· 2162 2162 } 2163 2163 /* FASYNC if needed ? */ 2164 2164 /* If clogged call tty_throttle(tty); */ 2165 - 2166 - return count; 2167 2165 } 2168 2166 2169 2167 /**
+8 -10
drivers/tty/n_hdlc.c
··· 188 188 poll_table *wait); 189 189 static int n_hdlc_tty_open(struct tty_struct *tty); 190 190 static void n_hdlc_tty_close(struct tty_struct *tty); 191 - static unsigned int n_hdlc_tty_receive(struct tty_struct *tty, 192 - const __u8 *cp, char *fp, int count); 191 + static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *cp, 192 + char *fp, int count); 193 193 static void n_hdlc_tty_wakeup(struct tty_struct *tty); 194 194 195 195 #define bset(p,b) ((p)[(b) >> 5] |= (1 << ((b) & 0x1f))) ··· 509 509 * Called by tty low level driver when receive data is available. Data is 510 510 * interpreted as one HDLC frame. 511 511 */ 512 - static unsigned int n_hdlc_tty_receive(struct tty_struct *tty, 513 - const __u8 *data, char *flags, int count) 512 + static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data, 513 + char *flags, int count) 514 514 { 515 515 register struct n_hdlc *n_hdlc = tty2n_hdlc (tty); 516 516 register struct n_hdlc_buf *buf; ··· 521 521 522 522 /* This can happen if stuff comes in on the backup tty */ 523 523 if (!n_hdlc || tty != n_hdlc->tty) 524 - return -ENODEV; 524 + return; 525 525 526 526 /* verify line is using HDLC discipline */ 527 527 if (n_hdlc->magic != HDLC_MAGIC) { 528 528 printk("%s(%d) line not using HDLC discipline\n", 529 529 __FILE__,__LINE__); 530 - return -EINVAL; 530 + return; 531 531 } 532 532 533 533 if ( count>maxframe ) { 534 534 if (debuglevel >= DEBUG_LEVEL_INFO) 535 535 printk("%s(%d) rx count>maxframesize, data discarded\n", 536 536 __FILE__,__LINE__); 537 - return -EINVAL; 537 + return; 538 538 } 539 539 540 540 /* get a free HDLC buffer */ ··· 550 550 if (debuglevel >= DEBUG_LEVEL_INFO) 551 551 printk("%s(%d) no more rx buffers, data discarded\n", 552 552 __FILE__,__LINE__); 553 - return -EINVAL; 553 + return; 554 554 } 555 555 556 556 /* copy received data to HDLC buffer */ ··· 564 564 wake_up_interruptible (&tty->read_wait); 565 565 if (n_hdlc->tty->fasync != NULL) 566 566 kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN); 567 - 568 - return count; 569 567 570 568 } /* end of n_hdlc_tty_receive() */ 571 569
+4 -6
drivers/tty/n_r3964.c
··· 139 139 static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old); 140 140 static unsigned int r3964_poll(struct tty_struct *tty, struct file *file, 141 141 struct poll_table_struct *wait); 142 - static unsigned int r3964_receive_buf(struct tty_struct *tty, 143 - const unsigned char *cp, char *fp, int count); 142 + static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, 143 + char *fp, int count); 144 144 145 145 static struct tty_ldisc_ops tty_ldisc_N_R3964 = { 146 146 .owner = THIS_MODULE, ··· 1239 1239 return result; 1240 1240 } 1241 1241 1242 - static unsigned int r3964_receive_buf(struct tty_struct *tty, 1243 - const unsigned char *cp, char *fp, int count) 1242 + static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, 1243 + char *fp, int count) 1244 1244 { 1245 1245 struct r3964_info *pInfo = tty->disc_data; 1246 1246 const unsigned char *p; ··· 1257 1257 } 1258 1258 1259 1259 } 1260 - 1261 - return count; 1262 1260 } 1263 1261 1264 1262 MODULE_LICENSE("GPL");
+47 -14
drivers/tty/n_tty.c
··· 81 81 return put_user(x, ptr); 82 82 } 83 83 84 + /** 85 + * n_tty_set__room - receive space 86 + * @tty: terminal 87 + * 88 + * Called by the driver to find out how much data it is 89 + * permitted to feed to the line discipline without any being lost 90 + * and thus to manage flow control. Not serialized. Answers for the 91 + * "instant". 92 + */ 93 + 94 + static void n_tty_set_room(struct tty_struct *tty) 95 + { 96 + /* tty->read_cnt is not read locked ? */ 97 + int left = N_TTY_BUF_SIZE - tty->read_cnt - 1; 98 + int old_left; 99 + 100 + /* 101 + * If we are doing input canonicalization, and there are no 102 + * pending newlines, let characters through without limit, so 103 + * that erase characters will be handled. Other excess 104 + * characters will be beeped. 105 + */ 106 + if (left <= 0) 107 + left = tty->icanon && !tty->canon_data; 108 + old_left = tty->receive_room; 109 + tty->receive_room = left; 110 + 111 + /* Did this open up the receive buffer? We may need to flip */ 112 + if (left && !old_left) 113 + schedule_work(&tty->buf.work); 114 + } 115 + 84 116 static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty) 85 117 { 86 118 if (tty->read_cnt < N_TTY_BUF_SIZE) { ··· 184 152 185 153 tty->canon_head = tty->canon_data = tty->erasing = 0; 186 154 memset(&tty->read_flags, 0, sizeof tty->read_flags); 155 + n_tty_set_room(tty); 187 156 check_unthrottle(tty); 188 157 } 189 158 ··· 1360 1327 * calls one at a time and in order (or using flush_to_ldisc) 1361 1328 */ 1362 1329 1363 - static unsigned int n_tty_receive_buf(struct tty_struct *tty, 1364 - const unsigned char *cp, char *fp, int count) 1330 + static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, 1331 + char *fp, int count) 1365 1332 { 1366 1333 const unsigned char *p; 1367 1334 char *f, flags = TTY_NORMAL; 1368 1335 int i; 1369 1336 char buf[64]; 1370 1337 unsigned long cpuflags; 1371 - int left; 1372 - int ret = 0; 1373 1338 1374 1339 if (!tty->read_buf) 1375 - return 0; 1340 + return; 1376 1341 1377 1342 if (tty->real_raw) { 1378 1343 spin_lock_irqsave(&tty->read_lock, cpuflags); ··· 1380 1349 memcpy(tty->read_buf + tty->read_head, cp, i); 1381 1350 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); 1382 1351 tty->read_cnt += i; 1383 - ret += i; 1384 1352 cp += i; 1385 1353 count -= i; 1386 1354 ··· 1389 1359 memcpy(tty->read_buf + tty->read_head, cp, i); 1390 1360 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); 1391 1361 tty->read_cnt += i; 1392 - ret += i; 1393 1362 spin_unlock_irqrestore(&tty->read_lock, cpuflags); 1394 1363 } else { 1395 - ret = count; 1396 1364 for (i = count, p = cp, f = fp; i; i--, p++) { 1397 1365 if (f) 1398 1366 flags = *f++; ··· 1418 1390 tty->ops->flush_chars(tty); 1419 1391 } 1420 1392 1393 + n_tty_set_room(tty); 1394 + 1421 1395 if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) || 1422 1396 L_EXTPROC(tty)) { 1423 1397 kill_fasync(&tty->fasync, SIGIO, POLL_IN); ··· 1432 1402 * mode. We don't want to throttle the driver if we're in 1433 1403 * canonical mode and don't have a newline yet! 1434 1404 */ 1435 - left = N_TTY_BUF_SIZE - tty->read_cnt - 1; 1436 - 1437 - if (left < TTY_THRESHOLD_THROTTLE) 1405 + if (tty->receive_room < TTY_THRESHOLD_THROTTLE) 1438 1406 tty_throttle(tty); 1439 - 1440 - return ret; 1441 1407 } 1442 1408 1443 1409 int is_ignored(int sig) ··· 1477 1451 if (test_bit(TTY_HW_COOK_IN, &tty->flags)) { 1478 1452 tty->raw = 1; 1479 1453 tty->real_raw = 1; 1454 + n_tty_set_room(tty); 1480 1455 return; 1481 1456 } 1482 1457 if (I_ISTRIP(tty) || I_IUCLC(tty) || I_IGNCR(tty) || ··· 1530 1503 else 1531 1504 tty->real_raw = 0; 1532 1505 } 1506 + n_tty_set_room(tty); 1533 1507 /* The termios change make the tty ready for I/O */ 1534 1508 wake_up_interruptible(&tty->write_wait); 1535 1509 wake_up_interruptible(&tty->read_wait); ··· 1812 1784 retval = -ERESTARTSYS; 1813 1785 break; 1814 1786 } 1787 + /* FIXME: does n_tty_set_room need locking ? */ 1788 + n_tty_set_room(tty); 1815 1789 timeout = schedule_timeout(timeout); 1816 1790 continue; 1817 1791 } ··· 1885 1855 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode, 1886 1856 * we won't get any more characters. 1887 1857 */ 1888 - if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) 1858 + if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) { 1859 + n_tty_set_room(tty); 1889 1860 check_unthrottle(tty); 1861 + } 1890 1862 1891 1863 if (b - buf >= minimum) 1892 1864 break; ··· 1910 1878 } else if (test_and_clear_bit(TTY_PUSH, &tty->flags)) 1911 1879 goto do_it_again; 1912 1880 1881 + n_tty_set_room(tty); 1913 1882 return retval; 1914 1883 } 1915 1884
+6 -9
drivers/tty/tty_buffer.c
··· 416 416 struct tty_buffer *head, *tail = tty->buf.tail; 417 417 int seen_tail = 0; 418 418 while ((head = tty->buf.head) != NULL) { 419 - int copied; 420 419 int count; 421 420 char *char_buf; 422 421 unsigned char *flag_buf; ··· 442 443 line discipline as we want to empty the queue */ 443 444 if (test_bit(TTY_FLUSHPENDING, &tty->flags)) 444 445 break; 446 + if (!tty->receive_room || seen_tail) 447 + break; 448 + if (count > tty->receive_room) 449 + count = tty->receive_room; 445 450 char_buf = head->char_buf_ptr + head->read; 446 451 flag_buf = head->flag_buf_ptr + head->read; 452 + head->read += count; 447 453 spin_unlock_irqrestore(&tty->buf.lock, flags); 448 - copied = disc->ops->receive_buf(tty, char_buf, 454 + disc->ops->receive_buf(tty, char_buf, 449 455 flag_buf, count); 450 456 spin_lock_irqsave(&tty->buf.lock, flags); 451 - 452 - head->read += copied; 453 - 454 - if (copied == 0 || seen_tail) { 455 - schedule_work(&tty->buf.work); 456 - break; 457 - } 458 457 } 459 458 clear_bit(TTY_FLUSHING, &tty->flags); 460 459 }
+2 -1
drivers/tty/vt/selection.c
··· 332 332 continue; 333 333 } 334 334 count = sel_buffer_lth - pasted; 335 - count = tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted, 335 + count = min(count, tty->receive_room); 336 + tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted, 336 337 NULL, count); 337 338 pasted += count; 338 339 }
+6 -6
drivers/vhost/net.c
··· 144 144 } 145 145 146 146 mutex_lock(&vq->mutex); 147 - vhost_disable_notify(vq); 147 + vhost_disable_notify(&net->dev, vq); 148 148 149 149 if (wmem < sock->sk->sk_sndbuf / 2) 150 150 tx_poll_stop(net); ··· 166 166 set_bit(SOCK_ASYNC_NOSPACE, &sock->flags); 167 167 break; 168 168 } 169 - if (unlikely(vhost_enable_notify(vq))) { 170 - vhost_disable_notify(vq); 169 + if (unlikely(vhost_enable_notify(&net->dev, vq))) { 170 + vhost_disable_notify(&net->dev, vq); 171 171 continue; 172 172 } 173 173 break; ··· 315 315 return; 316 316 317 317 mutex_lock(&vq->mutex); 318 - vhost_disable_notify(vq); 318 + vhost_disable_notify(&net->dev, vq); 319 319 vhost_hlen = vq->vhost_hlen; 320 320 sock_hlen = vq->sock_hlen; 321 321 ··· 334 334 break; 335 335 /* OK, now we need to know about added descriptors. */ 336 336 if (!headcount) { 337 - if (unlikely(vhost_enable_notify(vq))) { 337 + if (unlikely(vhost_enable_notify(&net->dev, vq))) { 338 338 /* They have slipped one in as we were 339 339 * doing that: check again. */ 340 - vhost_disable_notify(vq); 340 + vhost_disable_notify(&net->dev, vq); 341 341 continue; 342 342 } 343 343 /* Nothing new? Wait for eventfd to tell us
+3 -3
drivers/vhost/test.c
··· 49 49 return; 50 50 51 51 mutex_lock(&vq->mutex); 52 - vhost_disable_notify(vq); 52 + vhost_disable_notify(&n->dev, vq); 53 53 54 54 for (;;) { 55 55 head = vhost_get_vq_desc(&n->dev, vq, vq->iov, ··· 61 61 break; 62 62 /* Nothing new? Wait for eventfd to tell us they refilled. */ 63 63 if (head == vq->num) { 64 - if (unlikely(vhost_enable_notify(vq))) { 65 - vhost_disable_notify(vq); 64 + if (unlikely(vhost_enable_notify(&n->dev, vq))) { 65 + vhost_disable_notify(&n->dev, vq); 66 66 continue; 67 67 } 68 68 break;
+104 -34
drivers/vhost/vhost.c
··· 37 37 VHOST_MEMORY_F_LOG = 0x1, 38 38 }; 39 39 40 + #define vhost_used_event(vq) ((u16 __user *)&vq->avail->ring[vq->num]) 41 + #define vhost_avail_event(vq) ((u16 __user *)&vq->used->ring[vq->num]) 42 + 40 43 static void vhost_poll_func(struct file *file, wait_queue_head_t *wqh, 41 44 poll_table *pt) 42 45 { ··· 164 161 vq->last_avail_idx = 0; 165 162 vq->avail_idx = 0; 166 163 vq->last_used_idx = 0; 164 + vq->signalled_used = 0; 165 + vq->signalled_used_valid = false; 167 166 vq->used_flags = 0; 168 167 vq->log_used = false; 169 168 vq->log_addr = -1ull; ··· 494 489 return 1; 495 490 } 496 491 497 - static int vq_access_ok(unsigned int num, 492 + static int vq_access_ok(struct vhost_dev *d, unsigned int num, 498 493 struct vring_desc __user *desc, 499 494 struct vring_avail __user *avail, 500 495 struct vring_used __user *used) 501 496 { 497 + size_t s = vhost_has_feature(d, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0; 502 498 return access_ok(VERIFY_READ, desc, num * sizeof *desc) && 503 499 access_ok(VERIFY_READ, avail, 504 - sizeof *avail + num * sizeof *avail->ring) && 500 + sizeof *avail + num * sizeof *avail->ring + s) && 505 501 access_ok(VERIFY_WRITE, used, 506 - sizeof *used + num * sizeof *used->ring); 502 + sizeof *used + num * sizeof *used->ring + s); 507 503 } 508 504 509 505 /* Can we log writes? */ ··· 520 514 521 515 /* Verify access for write logging. */ 522 516 /* Caller should have vq mutex and device mutex */ 523 - static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base) 517 + static int vq_log_access_ok(struct vhost_dev *d, struct vhost_virtqueue *vq, 518 + void __user *log_base) 524 519 { 525 520 struct vhost_memory *mp; 521 + size_t s = vhost_has_feature(d, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0; 526 522 527 523 mp = rcu_dereference_protected(vq->dev->memory, 528 524 lockdep_is_held(&vq->mutex)); ··· 532 524 vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) && 533 525 (!vq->log_used || log_access_ok(log_base, vq->log_addr, 534 526 sizeof *vq->used + 535 - vq->num * sizeof *vq->used->ring)); 527 + vq->num * sizeof *vq->used->ring + s)); 536 528 } 537 529 538 530 /* Can we start vq? */ 539 531 /* Caller should have vq mutex and device mutex */ 540 532 int vhost_vq_access_ok(struct vhost_virtqueue *vq) 541 533 { 542 - return vq_access_ok(vq->num, vq->desc, vq->avail, vq->used) && 543 - vq_log_access_ok(vq, vq->log_base); 534 + return vq_access_ok(vq->dev, vq->num, vq->desc, vq->avail, vq->used) && 535 + vq_log_access_ok(vq->dev, vq, vq->log_base); 544 536 } 545 537 546 538 static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) ··· 585 577 586 578 if (r) 587 579 return r; 580 + vq->signalled_used_valid = false; 588 581 return get_user(vq->last_used_idx, &used->idx); 589 582 } 590 583 ··· 683 674 * If it is not, we don't as size might not have been setup. 684 675 * We will verify when backend is configured. */ 685 676 if (vq->private_data) { 686 - if (!vq_access_ok(vq->num, 677 + if (!vq_access_ok(d, vq->num, 687 678 (void __user *)(unsigned long)a.desc_user_addr, 688 679 (void __user *)(unsigned long)a.avail_user_addr, 689 680 (void __user *)(unsigned long)a.used_user_addr)) { ··· 827 818 vq = d->vqs + i; 828 819 mutex_lock(&vq->mutex); 829 820 /* If ring is inactive, will check when it's enabled. */ 830 - if (vq->private_data && !vq_log_access_ok(vq, base)) 821 + if (vq->private_data && !vq_log_access_ok(d, vq, base)) 831 822 r = -EFAULT; 832 823 else 833 824 vq->log_base = base; ··· 1228 1219 1229 1220 /* On success, increment avail index. */ 1230 1221 vq->last_avail_idx++; 1222 + 1223 + /* Assume notifications from guest are disabled at this point, 1224 + * if they aren't we would need to update avail_event index. */ 1225 + BUG_ON(!(vq->used_flags & VRING_USED_F_NO_NOTIFY)); 1231 1226 return head; 1232 1227 } 1233 1228 ··· 1280 1267 eventfd_signal(vq->log_ctx, 1); 1281 1268 } 1282 1269 vq->last_used_idx++; 1270 + /* If the driver never bothers to signal in a very long while, 1271 + * used index might wrap around. If that happens, invalidate 1272 + * signalled_used index we stored. TODO: make sure driver 1273 + * signals at least once in 2^16 and remove this. */ 1274 + if (unlikely(vq->last_used_idx == vq->signalled_used)) 1275 + vq->signalled_used_valid = false; 1283 1276 return 0; 1284 1277 } 1285 1278 ··· 1294 1275 unsigned count) 1295 1276 { 1296 1277 struct vring_used_elem __user *used; 1278 + u16 old, new; 1297 1279 int start; 1298 1280 1299 1281 start = vq->last_used_idx % vq->num; ··· 1312 1292 ((void __user *)used - (void __user *)vq->used), 1313 1293 count * sizeof *used); 1314 1294 } 1315 - vq->last_used_idx += count; 1295 + old = vq->last_used_idx; 1296 + new = (vq->last_used_idx += count); 1297 + /* If the driver never bothers to signal in a very long while, 1298 + * used index might wrap around. If that happens, invalidate 1299 + * signalled_used index we stored. TODO: make sure driver 1300 + * signals at least once in 2^16 and remove this. */ 1301 + if (unlikely((u16)(new - vq->signalled_used) < (u16)(new - old))) 1302 + vq->signalled_used_valid = false; 1316 1303 return 0; 1317 1304 } 1318 1305 ··· 1358 1331 return r; 1359 1332 } 1360 1333 1361 - /* This actually signals the guest, using eventfd. */ 1362 - void vhost_signal(struct vhost_dev *dev, struct vhost_virtqueue *vq) 1334 + static bool vhost_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq) 1363 1335 { 1364 - __u16 flags; 1365 - 1336 + __u16 old, new, event; 1337 + bool v; 1366 1338 /* Flush out used index updates. This is paired 1367 1339 * with the barrier that the Guest executes when enabling 1368 1340 * interrupts. */ 1369 1341 smp_mb(); 1370 1342 1371 - if (__get_user(flags, &vq->avail->flags)) { 1372 - vq_err(vq, "Failed to get flags"); 1373 - return; 1343 + if (vhost_has_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY) && 1344 + unlikely(vq->avail_idx == vq->last_avail_idx)) 1345 + return true; 1346 + 1347 + if (!vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { 1348 + __u16 flags; 1349 + if (__get_user(flags, &vq->avail->flags)) { 1350 + vq_err(vq, "Failed to get flags"); 1351 + return true; 1352 + } 1353 + return !(flags & VRING_AVAIL_F_NO_INTERRUPT); 1374 1354 } 1355 + old = vq->signalled_used; 1356 + v = vq->signalled_used_valid; 1357 + new = vq->signalled_used = vq->last_used_idx; 1358 + vq->signalled_used_valid = true; 1375 1359 1376 - /* If they don't want an interrupt, don't signal, unless empty. */ 1377 - if ((flags & VRING_AVAIL_F_NO_INTERRUPT) && 1378 - (vq->avail_idx != vq->last_avail_idx || 1379 - !vhost_has_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY))) 1380 - return; 1360 + if (unlikely(!v)) 1361 + return true; 1381 1362 1363 + if (get_user(event, vhost_used_event(vq))) { 1364 + vq_err(vq, "Failed to get used event idx"); 1365 + return true; 1366 + } 1367 + return vring_need_event(event, new, old); 1368 + } 1369 + 1370 + /* This actually signals the guest, using eventfd. */ 1371 + void vhost_signal(struct vhost_dev *dev, struct vhost_virtqueue *vq) 1372 + { 1382 1373 /* Signal the Guest tell them we used something up. */ 1383 - if (vq->call_ctx) 1374 + if (vq->call_ctx && vhost_notify(dev, vq)) 1384 1375 eventfd_signal(vq->call_ctx, 1); 1385 1376 } 1386 1377 ··· 1421 1376 } 1422 1377 1423 1378 /* OK, now we need to know about added descriptors. */ 1424 - bool vhost_enable_notify(struct vhost_virtqueue *vq) 1379 + bool vhost_enable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq) 1425 1380 { 1426 1381 u16 avail_idx; 1427 1382 int r; ··· 1429 1384 if (!(vq->used_flags & VRING_USED_F_NO_NOTIFY)) 1430 1385 return false; 1431 1386 vq->used_flags &= ~VRING_USED_F_NO_NOTIFY; 1432 - r = put_user(vq->used_flags, &vq->used->flags); 1433 - if (r) { 1434 - vq_err(vq, "Failed to enable notification at %p: %d\n", 1435 - &vq->used->flags, r); 1436 - return false; 1387 + if (!vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { 1388 + r = put_user(vq->used_flags, &vq->used->flags); 1389 + if (r) { 1390 + vq_err(vq, "Failed to enable notification at %p: %d\n", 1391 + &vq->used->flags, r); 1392 + return false; 1393 + } 1394 + } else { 1395 + r = put_user(vq->avail_idx, vhost_avail_event(vq)); 1396 + if (r) { 1397 + vq_err(vq, "Failed to update avail event index at %p: %d\n", 1398 + vhost_avail_event(vq), r); 1399 + return false; 1400 + } 1401 + } 1402 + if (unlikely(vq->log_used)) { 1403 + void __user *used; 1404 + /* Make sure data is seen before log. */ 1405 + smp_wmb(); 1406 + used = vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX) ? 1407 + &vq->used->flags : vhost_avail_event(vq); 1408 + /* Log used flags or event index entry write. Both are 16 bit 1409 + * fields. */ 1410 + log_write(vq->log_base, vq->log_addr + 1411 + (used - (void __user *)vq->used), 1412 + sizeof(u16)); 1413 + if (vq->log_ctx) 1414 + eventfd_signal(vq->log_ctx, 1); 1437 1415 } 1438 1416 /* They could have slipped one in as we were doing that: make 1439 1417 * sure it's written, then check again. */ ··· 1472 1404 } 1473 1405 1474 1406 /* We don't need to be notified again. */ 1475 - void vhost_disable_notify(struct vhost_virtqueue *vq) 1407 + void vhost_disable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq) 1476 1408 { 1477 1409 int r; 1478 1410 1479 1411 if (vq->used_flags & VRING_USED_F_NO_NOTIFY) 1480 1412 return; 1481 1413 vq->used_flags |= VRING_USED_F_NO_NOTIFY; 1482 - r = put_user(vq->used_flags, &vq->used->flags); 1483 - if (r) 1484 - vq_err(vq, "Failed to enable notification at %p: %d\n", 1485 - &vq->used->flags, r); 1414 + if (!vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { 1415 + r = put_user(vq->used_flags, &vq->used->flags); 1416 + if (r) 1417 + vq_err(vq, "Failed to enable notification at %p: %d\n", 1418 + &vq->used->flags, r); 1419 + } 1486 1420 }
+14 -7
drivers/vhost/vhost.h
··· 84 84 /* Used flags */ 85 85 u16 used_flags; 86 86 87 + /* Last used index value we have signalled on */ 88 + u16 signalled_used; 89 + 90 + /* Last used index value we have signalled on */ 91 + bool signalled_used_valid; 92 + 87 93 /* Log writes to used structure. */ 88 94 bool log_used; 89 95 u64 log_addr; ··· 155 149 void vhost_add_used_and_signal_n(struct vhost_dev *, struct vhost_virtqueue *, 156 150 struct vring_used_elem *heads, unsigned count); 157 151 void vhost_signal(struct vhost_dev *, struct vhost_virtqueue *); 158 - void vhost_disable_notify(struct vhost_virtqueue *); 159 - bool vhost_enable_notify(struct vhost_virtqueue *); 152 + void vhost_disable_notify(struct vhost_dev *, struct vhost_virtqueue *); 153 + bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *); 160 154 161 155 int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, 162 156 unsigned int log_num, u64 len); ··· 168 162 } while (0) 169 163 170 164 enum { 171 - VHOST_FEATURES = (1 << VIRTIO_F_NOTIFY_ON_EMPTY) | 172 - (1 << VIRTIO_RING_F_INDIRECT_DESC) | 173 - (1 << VHOST_F_LOG_ALL) | 174 - (1 << VHOST_NET_F_VIRTIO_NET_HDR) | 175 - (1 << VIRTIO_NET_F_MRG_RXBUF), 165 + VHOST_FEATURES = (1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | 166 + (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | 167 + (1ULL << VIRTIO_RING_F_EVENT_IDX) | 168 + (1ULL << VHOST_F_LOG_ALL) | 169 + (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) | 170 + (1ULL << VIRTIO_NET_F_MRG_RXBUF), 176 171 }; 177 172 178 173 static inline int vhost_has_feature(struct vhost_dev *dev, int bit)
+8 -13
drivers/virtio/virtio_balloon.c
··· 40 40 /* Waiting for host to ack the pages we released. */ 41 41 struct completion acked; 42 42 43 - /* Do we have to tell Host *before* we reuse pages? */ 44 - bool tell_host_first; 45 - 46 43 /* The pages we've told the Host we're not using. */ 47 44 unsigned int num_pages; 48 45 struct list_head pages; ··· 148 151 vb->num_pages--; 149 152 } 150 153 151 - if (vb->tell_host_first) { 152 - tell_host(vb, vb->deflate_vq); 153 - release_pages_by_pfn(vb->pfns, vb->num_pfns); 154 - } else { 155 - release_pages_by_pfn(vb->pfns, vb->num_pfns); 156 - tell_host(vb, vb->deflate_vq); 157 - } 154 + 155 + /* 156 + * Note that if 157 + * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST); 158 + * is true, we *have* to do it in this order 159 + */ 160 + tell_host(vb, vb->deflate_vq); 161 + release_pages_by_pfn(vb->pfns, vb->num_pfns); 158 162 } 159 163 160 164 static inline void update_stat(struct virtio_balloon *vb, int idx, ··· 322 324 err = PTR_ERR(vb->thread); 323 325 goto out_del_vqs; 324 326 } 325 - 326 - vb->tell_host_first 327 - = virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST); 328 327 329 328 return 0; 330 329
+51 -2
drivers/virtio/virtio_ring.c
··· 82 82 /* Host supports indirect buffers */ 83 83 bool indirect; 84 84 85 + /* Host publishes avail event idx */ 86 + bool event; 87 + 85 88 /* Number of free buffers */ 86 89 unsigned int num_free; 87 90 /* Head of free buffer list. */ ··· 240 237 void virtqueue_kick(struct virtqueue *_vq) 241 238 { 242 239 struct vring_virtqueue *vq = to_vvq(_vq); 240 + u16 new, old; 243 241 START_USE(vq); 244 242 /* Descriptors and available array need to be set before we expose the 245 243 * new available array entries. */ 246 244 virtio_wmb(); 247 245 248 - vq->vring.avail->idx += vq->num_added; 246 + old = vq->vring.avail->idx; 247 + new = vq->vring.avail->idx = old + vq->num_added; 249 248 vq->num_added = 0; 250 249 251 250 /* Need to update avail index before checking if we should notify */ 252 251 virtio_mb(); 253 252 254 - if (!(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY)) 253 + if (vq->event ? 254 + vring_need_event(vring_avail_event(&vq->vring), new, old) : 255 + !(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY)) 255 256 /* Prod other side to tell it about changes. */ 256 257 vq->notify(&vq->vq); 257 258 ··· 331 324 ret = vq->data[i]; 332 325 detach_buf(vq, i); 333 326 vq->last_used_idx++; 327 + /* If we expect an interrupt for the next entry, tell host 328 + * by writing event index and flush out the write before 329 + * the read in the next get_buf call. */ 330 + if (!(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) { 331 + vring_used_event(&vq->vring) = vq->last_used_idx; 332 + virtio_mb(); 333 + } 334 + 334 335 END_USE(vq); 335 336 return ret; 336 337 } ··· 360 345 361 346 /* We optimistically turn back on interrupts, then check if there was 362 347 * more to do. */ 348 + /* Depending on the VIRTIO_RING_F_EVENT_IDX feature, we need to 349 + * either clear the flags bit or point the event index at the next 350 + * entry. Always do both to keep code simple. */ 363 351 vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT; 352 + vring_used_event(&vq->vring) = vq->last_used_idx; 364 353 virtio_mb(); 365 354 if (unlikely(more_used(vq))) { 366 355 END_USE(vq); ··· 375 356 return true; 376 357 } 377 358 EXPORT_SYMBOL_GPL(virtqueue_enable_cb); 359 + 360 + bool virtqueue_enable_cb_delayed(struct virtqueue *_vq) 361 + { 362 + struct vring_virtqueue *vq = to_vvq(_vq); 363 + u16 bufs; 364 + 365 + START_USE(vq); 366 + 367 + /* We optimistically turn back on interrupts, then check if there was 368 + * more to do. */ 369 + /* Depending on the VIRTIO_RING_F_USED_EVENT_IDX feature, we need to 370 + * either clear the flags bit or point the event index at the next 371 + * entry. Always do both to keep code simple. */ 372 + vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT; 373 + /* TODO: tune this threshold */ 374 + bufs = (u16)(vq->vring.avail->idx - vq->last_used_idx) * 3 / 4; 375 + vring_used_event(&vq->vring) = vq->last_used_idx + bufs; 376 + virtio_mb(); 377 + if (unlikely((u16)(vq->vring.used->idx - vq->last_used_idx) > bufs)) { 378 + END_USE(vq); 379 + return false; 380 + } 381 + 382 + END_USE(vq); 383 + return true; 384 + } 385 + EXPORT_SYMBOL_GPL(virtqueue_enable_cb_delayed); 378 386 379 387 void *virtqueue_detach_unused_buf(struct virtqueue *_vq) 380 388 { ··· 484 438 #endif 485 439 486 440 vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC); 441 + vq->event = virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX); 487 442 488 443 /* No callback? Tell other side not to bother us. */ 489 444 if (!callback) ··· 518 471 for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) { 519 472 switch (i) { 520 473 case VIRTIO_RING_F_INDIRECT_DESC: 474 + break; 475 + case VIRTIO_RING_F_EVENT_IDX: 521 476 break; 522 477 default: 523 478 /* We don't understand this bit. */
-2
fs/autofs4/root.c
··· 583 583 if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) 584 584 return -EACCES; 585 585 586 - dentry_unhash(dentry); 587 - 588 586 if (atomic_dec_and_test(&ino->count)) { 589 587 p_ino = autofs4_dentry_ino(dentry->d_parent); 590 588 if (p_ino && dentry->d_parent != dentry)
+2 -2
fs/block_dev.c
··· 1272 1272 * individual writeable reference is too fragile given the 1273 1273 * way @mode is used in blkdev_get/put(). 1274 1274 */ 1275 - if ((disk->flags & GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE) && 1276 - !res && (mode & FMODE_WRITE) && !bdev->bd_write_holder) { 1275 + if (!res && (mode & FMODE_WRITE) && !bdev->bd_write_holder && 1276 + (disk->flags & GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE)) { 1277 1277 bdev->bd_write_holder = true; 1278 1278 disk_block_events(disk); 1279 1279 }
-3
fs/btrfs/btrfs_inode.h
··· 121 121 */ 122 122 u64 index_cnt; 123 123 124 - /* the start of block group preferred for allocations. */ 125 - u64 block_group; 126 - 127 124 /* the fsync log has some corner cases that mean we have to check 128 125 * directories to see if any unlinks have been done before 129 126 * the directory was logged. See tree-log.c for all the
+21 -7
fs/btrfs/ctree.c
··· 43 43 { 44 44 struct btrfs_path *path; 45 45 path = kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS); 46 - if (path) 47 - path->reada = 1; 48 46 return path; 49 47 } 50 48 ··· 1222 1224 u64 search; 1223 1225 u64 target; 1224 1226 u64 nread = 0; 1227 + u64 gen; 1225 1228 int direction = path->reada; 1226 1229 struct extent_buffer *eb; 1227 1230 u32 nr; ··· 1250 1251 nritems = btrfs_header_nritems(node); 1251 1252 nr = slot; 1252 1253 while (1) { 1254 + if (!node->map_token) { 1255 + unsigned long offset = btrfs_node_key_ptr_offset(nr); 1256 + map_private_extent_buffer(node, offset, 1257 + sizeof(struct btrfs_key_ptr), 1258 + &node->map_token, 1259 + &node->kaddr, 1260 + &node->map_start, 1261 + &node->map_len, KM_USER1); 1262 + } 1253 1263 if (direction < 0) { 1254 1264 if (nr == 0) 1255 1265 break; ··· 1276 1268 search = btrfs_node_blockptr(node, nr); 1277 1269 if ((search <= target && target - search <= 65536) || 1278 1270 (search > target && search - target <= 65536)) { 1279 - readahead_tree_block(root, search, blocksize, 1280 - btrfs_node_ptr_generation(node, nr)); 1271 + gen = btrfs_node_ptr_generation(node, nr); 1272 + if (node->map_token) { 1273 + unmap_extent_buffer(node, node->map_token, 1274 + KM_USER1); 1275 + node->map_token = NULL; 1276 + } 1277 + readahead_tree_block(root, search, blocksize, gen); 1281 1278 nread += blocksize; 1282 1279 } 1283 1280 nscan++; 1284 1281 if ((nread > 65536 || nscan > 32)) 1285 1282 break; 1283 + } 1284 + if (node->map_token) { 1285 + unmap_extent_buffer(node, node->map_token, KM_USER1); 1286 + node->map_token = NULL; 1286 1287 } 1287 1288 } 1288 1289 ··· 1665 1648 } 1666 1649 cow_done: 1667 1650 BUG_ON(!cow && ins_len); 1668 - if (level != btrfs_header_level(b)) 1669 - WARN_ON(1); 1670 - level = btrfs_header_level(b); 1671 1651 1672 1652 p->nodes[level] = b; 1673 1653 if (!p->skip_locking)
+17 -5
fs/btrfs/ctree.h
··· 930 930 * is required instead of the faster short fsync log commits 931 931 */ 932 932 u64 last_trans_log_full_commit; 933 - u64 open_ioctl_trans; 934 933 unsigned long mount_opt:20; 935 934 unsigned long compress_type:4; 936 935 u64 max_inline; ··· 946 947 struct super_block *sb; 947 948 struct inode *btree_inode; 948 949 struct backing_dev_info bdi; 949 - struct mutex trans_mutex; 950 950 struct mutex tree_log_mutex; 951 951 struct mutex transaction_kthread_mutex; 952 952 struct mutex cleaner_mutex; ··· 966 968 struct rw_semaphore subvol_sem; 967 969 struct srcu_struct subvol_srcu; 968 970 971 + spinlock_t trans_lock; 969 972 struct list_head trans_list; 970 973 struct list_head hashers; 971 974 struct list_head dead_roots; ··· 979 980 atomic_t async_submit_draining; 980 981 atomic_t nr_async_bios; 981 982 atomic_t async_delalloc_pages; 983 + atomic_t open_ioctl_trans; 982 984 983 985 /* 984 986 * this is used by the balancing code to wait for all the pending ··· 1044 1044 int closing; 1045 1045 int log_root_recovering; 1046 1046 int enospc_unlink; 1047 + int trans_no_join; 1047 1048 1048 1049 u64 total_pinned; 1049 1050 ··· 1066 1065 struct reloc_control *reloc_ctl; 1067 1066 1068 1067 spinlock_t delalloc_lock; 1069 - spinlock_t new_trans_lock; 1070 1068 u64 delalloc_bytes; 1071 1069 1072 1070 /* data_alloc_cluster is only used in ssd mode */ ··· 1340 1340 #define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14) 1341 1341 #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15) 1342 1342 #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) 1343 + #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) 1343 1344 1344 1345 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) 1345 1346 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) ··· 2239 2238 void btrfs_block_rsv_release(struct btrfs_root *root, 2240 2239 struct btrfs_block_rsv *block_rsv, 2241 2240 u64 num_bytes); 2241 + int btrfs_truncate_reserve_metadata(struct btrfs_trans_handle *trans, 2242 + struct btrfs_root *root, 2243 + struct btrfs_block_rsv *rsv); 2242 2244 int btrfs_set_block_group_ro(struct btrfs_root *root, 2243 2245 struct btrfs_block_group_cache *cache); 2244 2246 int btrfs_set_block_group_rw(struct btrfs_root *root, ··· 2354 2350 struct btrfs_root *root, 2355 2351 struct extent_buffer *node, 2356 2352 struct extent_buffer *parent); 2353 + static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info) 2354 + { 2355 + /* 2356 + * Get synced with close_ctree() 2357 + */ 2358 + smp_mb(); 2359 + return fs_info->closing; 2360 + } 2361 + 2357 2362 /* root-item.c */ 2358 2363 int btrfs_find_root_ref(struct btrfs_root *tree_root, 2359 2364 struct btrfs_path *path, ··· 2525 2512 int btrfs_writepages(struct address_space *mapping, 2526 2513 struct writeback_control *wbc); 2527 2514 int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, 2528 - struct btrfs_root *new_root, 2529 - u64 new_dirid, u64 alloc_hint); 2515 + struct btrfs_root *new_root, u64 new_dirid); 2530 2516 int btrfs_merge_bio_hook(struct page *page, unsigned long offset, 2531 2517 size_t size, struct bio *bio, unsigned long bio_flags); 2532 2518
+4 -4
fs/btrfs/delayed-inode.c
··· 678 678 INIT_LIST_HEAD(&head); 679 679 680 680 next = item; 681 + nitems = 0; 681 682 682 683 /* 683 684 * count the number of the continuous items that we can insert in batch ··· 1130 1129 delayed_node = async_node->delayed_node; 1131 1130 root = delayed_node->root; 1132 1131 1133 - trans = btrfs_join_transaction(root, 0); 1132 + trans = btrfs_join_transaction(root); 1134 1133 if (IS_ERR(trans)) 1135 1134 goto free_path; 1136 1135 ··· 1573 1572 btrfs_set_stack_inode_transid(inode_item, trans->transid); 1574 1573 btrfs_set_stack_inode_rdev(inode_item, inode->i_rdev); 1575 1574 btrfs_set_stack_inode_flags(inode_item, BTRFS_I(inode)->flags); 1576 - btrfs_set_stack_inode_block_group(inode_item, 1577 - BTRFS_I(inode)->block_group); 1575 + btrfs_set_stack_inode_block_group(inode_item, 0); 1578 1576 1579 1577 btrfs_set_stack_timespec_sec(btrfs_inode_atime(inode_item), 1580 1578 inode->i_atime.tv_sec); ··· 1595 1595 struct btrfs_root *root, struct inode *inode) 1596 1596 { 1597 1597 struct btrfs_delayed_node *delayed_node; 1598 - int ret; 1598 + int ret = 0; 1599 1599 1600 1600 delayed_node = btrfs_get_or_create_delayed_node(inode); 1601 1601 if (IS_ERR(delayed_node))
+18 -18
fs/btrfs/disk-io.c
··· 1505 1505 vfs_check_frozen(root->fs_info->sb, SB_FREEZE_WRITE); 1506 1506 mutex_lock(&root->fs_info->transaction_kthread_mutex); 1507 1507 1508 - spin_lock(&root->fs_info->new_trans_lock); 1508 + spin_lock(&root->fs_info->trans_lock); 1509 1509 cur = root->fs_info->running_transaction; 1510 1510 if (!cur) { 1511 - spin_unlock(&root->fs_info->new_trans_lock); 1511 + spin_unlock(&root->fs_info->trans_lock); 1512 1512 goto sleep; 1513 1513 } 1514 1514 1515 1515 now = get_seconds(); 1516 1516 if (!cur->blocked && 1517 1517 (now < cur->start_time || now - cur->start_time < 30)) { 1518 - spin_unlock(&root->fs_info->new_trans_lock); 1518 + spin_unlock(&root->fs_info->trans_lock); 1519 1519 delay = HZ * 5; 1520 1520 goto sleep; 1521 1521 } 1522 1522 transid = cur->transid; 1523 - spin_unlock(&root->fs_info->new_trans_lock); 1523 + spin_unlock(&root->fs_info->trans_lock); 1524 1524 1525 - trans = btrfs_join_transaction(root, 1); 1525 + trans = btrfs_join_transaction(root); 1526 1526 BUG_ON(IS_ERR(trans)); 1527 1527 if (transid == trans->transid) { 1528 1528 ret = btrfs_commit_transaction(trans, root); ··· 1613 1613 INIT_LIST_HEAD(&fs_info->ordered_operations); 1614 1614 INIT_LIST_HEAD(&fs_info->caching_block_groups); 1615 1615 spin_lock_init(&fs_info->delalloc_lock); 1616 - spin_lock_init(&fs_info->new_trans_lock); 1616 + spin_lock_init(&fs_info->trans_lock); 1617 1617 spin_lock_init(&fs_info->ref_cache_lock); 1618 1618 spin_lock_init(&fs_info->fs_roots_radix_lock); 1619 1619 spin_lock_init(&fs_info->delayed_iput_lock); ··· 1645 1645 fs_info->max_inline = 8192 * 1024; 1646 1646 fs_info->metadata_ratio = 0; 1647 1647 fs_info->defrag_inodes = RB_ROOT; 1648 + fs_info->trans_no_join = 0; 1648 1649 1649 1650 fs_info->thread_pool_size = min_t(unsigned long, 1650 1651 num_online_cpus() + 2, 8); ··· 1710 1709 fs_info->do_barriers = 1; 1711 1710 1712 1711 1713 - mutex_init(&fs_info->trans_mutex); 1714 1712 mutex_init(&fs_info->ordered_operations_mutex); 1715 1713 mutex_init(&fs_info->tree_log_mutex); 1716 1714 mutex_init(&fs_info->chunk_mutex); ··· 2479 2479 down_write(&root->fs_info->cleanup_work_sem); 2480 2480 up_write(&root->fs_info->cleanup_work_sem); 2481 2481 2482 - trans = btrfs_join_transaction(root, 1); 2482 + trans = btrfs_join_transaction(root); 2483 2483 if (IS_ERR(trans)) 2484 2484 return PTR_ERR(trans); 2485 2485 ret = btrfs_commit_transaction(trans, root); 2486 2486 BUG_ON(ret); 2487 2487 /* run commit again to drop the original snapshot */ 2488 - trans = btrfs_join_transaction(root, 1); 2488 + trans = btrfs_join_transaction(root); 2489 2489 if (IS_ERR(trans)) 2490 2490 return PTR_ERR(trans); 2491 2491 btrfs_commit_transaction(trans, root); ··· 3024 3024 3025 3025 WARN_ON(1); 3026 3026 3027 - mutex_lock(&root->fs_info->trans_mutex); 3028 3027 mutex_lock(&root->fs_info->transaction_kthread_mutex); 3029 3028 3029 + spin_lock(&root->fs_info->trans_lock); 3030 3030 list_splice_init(&root->fs_info->trans_list, &list); 3031 + root->fs_info->trans_no_join = 1; 3032 + spin_unlock(&root->fs_info->trans_lock); 3033 + 3031 3034 while (!list_empty(&list)) { 3032 3035 t = list_entry(list.next, struct btrfs_transaction, list); 3033 3036 if (!t) ··· 3055 3052 t->blocked = 0; 3056 3053 if (waitqueue_active(&root->fs_info->transaction_wait)) 3057 3054 wake_up(&root->fs_info->transaction_wait); 3058 - mutex_unlock(&root->fs_info->trans_mutex); 3059 3055 3060 - mutex_lock(&root->fs_info->trans_mutex); 3061 3056 t->commit_done = 1; 3062 3057 if (waitqueue_active(&t->commit_wait)) 3063 3058 wake_up(&t->commit_wait); 3064 - mutex_unlock(&root->fs_info->trans_mutex); 3065 - 3066 - mutex_lock(&root->fs_info->trans_mutex); 3067 3059 3068 3060 btrfs_destroy_pending_snapshots(t); 3069 3061 3070 3062 btrfs_destroy_delalloc_inodes(root); 3071 3063 3072 - spin_lock(&root->fs_info->new_trans_lock); 3064 + spin_lock(&root->fs_info->trans_lock); 3073 3065 root->fs_info->running_transaction = NULL; 3074 - spin_unlock(&root->fs_info->new_trans_lock); 3066 + spin_unlock(&root->fs_info->trans_lock); 3075 3067 3076 3068 btrfs_destroy_marked_extents(root, &t->dirty_pages, 3077 3069 EXTENT_DIRTY); ··· 3080 3082 kmem_cache_free(btrfs_transaction_cachep, t); 3081 3083 } 3082 3084 3085 + spin_lock(&root->fs_info->trans_lock); 3086 + root->fs_info->trans_no_join = 0; 3087 + spin_unlock(&root->fs_info->trans_lock); 3083 3088 mutex_unlock(&root->fs_info->transaction_kthread_mutex); 3084 - mutex_unlock(&root->fs_info->trans_mutex); 3085 3089 3086 3090 return 0; 3087 3091 }
+68 -35
fs/btrfs/extent-tree.c
··· 348 348 */ 349 349 path->skip_locking = 1; 350 350 path->search_commit_root = 1; 351 - path->reada = 2; 351 + path->reada = 1; 352 352 353 353 key.objectid = last; 354 354 key.offset = 0; ··· 366 366 nritems = btrfs_header_nritems(leaf); 367 367 368 368 while (1) { 369 - smp_mb(); 370 - if (fs_info->closing > 1) { 369 + if (btrfs_fs_closing(fs_info) > 1) { 371 370 last = (u64)-1; 372 371 break; 373 372 } ··· 378 379 if (ret) 379 380 break; 380 381 381 - caching_ctl->progress = last; 382 - btrfs_release_path(path); 383 - up_read(&fs_info->extent_commit_sem); 384 - mutex_unlock(&caching_ctl->mutex); 385 - if (btrfs_transaction_in_commit(fs_info)) 386 - schedule_timeout(1); 387 - else 382 + if (need_resched() || 383 + btrfs_next_leaf(extent_root, path)) { 384 + caching_ctl->progress = last; 385 + btrfs_release_path(path); 386 + up_read(&fs_info->extent_commit_sem); 387 + mutex_unlock(&caching_ctl->mutex); 388 388 cond_resched(); 389 - goto again; 389 + goto again; 390 + } 391 + leaf = path->nodes[0]; 392 + nritems = btrfs_header_nritems(leaf); 393 + continue; 390 394 } 391 395 392 396 if (key.objectid < block_group->key.objectid) { ··· 3067 3065 spin_unlock(&data_sinfo->lock); 3068 3066 alloc: 3069 3067 alloc_target = btrfs_get_alloc_profile(root, 1); 3070 - trans = btrfs_join_transaction(root, 1); 3068 + trans = btrfs_join_transaction(root); 3071 3069 if (IS_ERR(trans)) 3072 3070 return PTR_ERR(trans); 3073 3071 ··· 3093 3091 3094 3092 /* commit the current transaction and try again */ 3095 3093 commit_trans: 3096 - if (!committed && !root->fs_info->open_ioctl_trans) { 3094 + if (!committed && 3095 + !atomic_read(&root->fs_info->open_ioctl_trans)) { 3097 3096 committed = 1; 3098 - trans = btrfs_join_transaction(root, 1); 3097 + trans = btrfs_join_transaction(root); 3099 3098 if (IS_ERR(trans)) 3100 3099 return PTR_ERR(trans); 3101 3100 ret = btrfs_commit_transaction(trans, root); ··· 3475 3472 goto out; 3476 3473 3477 3474 ret = -ENOSPC; 3478 - trans = btrfs_join_transaction(root, 1); 3475 + trans = btrfs_join_transaction(root); 3479 3476 if (IS_ERR(trans)) 3480 3477 goto out; 3481 3478 ret = btrfs_commit_transaction(trans, root); ··· 3702 3699 if (trans) 3703 3700 return -EAGAIN; 3704 3701 3705 - trans = btrfs_join_transaction(root, 1); 3702 + trans = btrfs_join_transaction(root); 3706 3703 BUG_ON(IS_ERR(trans)); 3707 3704 ret = btrfs_commit_transaction(trans, root); 3708 3705 return 0; ··· 3840 3837 WARN_ON(fs_info->chunk_block_rsv.reserved > 0); 3841 3838 } 3842 3839 3840 + int btrfs_truncate_reserve_metadata(struct btrfs_trans_handle *trans, 3841 + struct btrfs_root *root, 3842 + struct btrfs_block_rsv *rsv) 3843 + { 3844 + struct btrfs_block_rsv *trans_rsv = &root->fs_info->trans_block_rsv; 3845 + u64 num_bytes; 3846 + int ret; 3847 + 3848 + /* 3849 + * Truncate should be freeing data, but give us 2 items just in case it 3850 + * needs to use some space. We may want to be smarter about this in the 3851 + * future. 3852 + */ 3853 + num_bytes = btrfs_calc_trans_metadata_size(root, 2); 3854 + 3855 + /* We already have enough bytes, just return */ 3856 + if (rsv->reserved >= num_bytes) 3857 + return 0; 3858 + 3859 + num_bytes -= rsv->reserved; 3860 + 3861 + /* 3862 + * You should have reserved enough space before hand to do this, so this 3863 + * should not fail. 3864 + */ 3865 + ret = block_rsv_migrate_bytes(trans_rsv, rsv, num_bytes); 3866 + BUG_ON(ret); 3867 + 3868 + return 0; 3869 + } 3870 + 3843 3871 int btrfs_trans_reserve_metadata(struct btrfs_trans_handle *trans, 3844 3872 struct btrfs_root *root, 3845 3873 int num_items) ··· 3911 3877 struct btrfs_block_rsv *dst_rsv = root->orphan_block_rsv; 3912 3878 3913 3879 /* 3914 - * one for deleting orphan item, one for updating inode and 3915 - * two for calling btrfs_truncate_inode_items. 3916 - * 3917 - * btrfs_truncate_inode_items is a delete operation, it frees 3918 - * more space than it uses in most cases. So two units of 3919 - * metadata space should be enough for calling it many times. 3920 - * If all of the metadata space is used, we can commit 3921 - * transaction and use space it freed. 3880 + * We need to hold space in order to delete our orphan item once we've 3881 + * added it, so this takes the reservation so we can release it later 3882 + * when we are truly done with the orphan item. 3922 3883 */ 3923 - u64 num_bytes = btrfs_calc_trans_metadata_size(root, 4); 3884 + u64 num_bytes = btrfs_calc_trans_metadata_size(root, 1); 3924 3885 return block_rsv_migrate_bytes(src_rsv, dst_rsv, num_bytes); 3925 3886 } 3926 3887 3927 3888 void btrfs_orphan_release_metadata(struct inode *inode) 3928 3889 { 3929 3890 struct btrfs_root *root = BTRFS_I(inode)->root; 3930 - u64 num_bytes = btrfs_calc_trans_metadata_size(root, 4); 3891 + u64 num_bytes = btrfs_calc_trans_metadata_size(root, 1); 3931 3892 btrfs_block_rsv_release(root, root->orphan_block_rsv, num_bytes); 3932 3893 } 3933 3894 ··· 5016 4987 if (unlikely(block_group->ro)) 5017 4988 goto loop; 5018 4989 4990 + spin_lock(&block_group->free_space_ctl->tree_lock); 4991 + if (cached && 4992 + block_group->free_space_ctl->free_space < 4993 + num_bytes + empty_size) { 4994 + spin_unlock(&block_group->free_space_ctl->tree_lock); 4995 + goto loop; 4996 + } 4997 + spin_unlock(&block_group->free_space_ctl->tree_lock); 4998 + 5019 4999 /* 5020 5000 * Ok we want to try and use the cluster allocator, so lets look 5021 5001 * there, unless we are on LOOP_NO_EMPTY_SIZE, since we will ··· 5188 5150 btrfs_add_free_space(block_group, offset, 5189 5151 search_start - offset); 5190 5152 BUG_ON(offset > search_start); 5153 + btrfs_put_block_group(block_group); 5191 5154 break; 5192 5155 loop: 5193 5156 failed_cluster_refill = false; ··· 5281 5242 ret = -ENOSPC; 5282 5243 } else if (!ins->objectid) { 5283 5244 ret = -ENOSPC; 5284 - } 5285 - 5286 - /* we found what we needed */ 5287 - if (ins->objectid) { 5288 - if (!(data & BTRFS_BLOCK_GROUP_DATA)) 5289 - trans->block_group = block_group->key.objectid; 5290 - 5291 - btrfs_put_block_group(block_group); 5245 + } else if (ins->objectid) { 5292 5246 ret = 0; 5293 5247 } 5294 5248 ··· 6558 6526 6559 6527 BUG_ON(cache->ro); 6560 6528 6561 - trans = btrfs_join_transaction(root, 1); 6529 + trans = btrfs_join_transaction(root); 6562 6530 BUG_ON(IS_ERR(trans)); 6563 6531 6564 6532 alloc_flags = update_block_group_flags(root, cache->flags); ··· 6914 6882 path = btrfs_alloc_path(); 6915 6883 if (!path) 6916 6884 return -ENOMEM; 6885 + path->reada = 1; 6917 6886 6918 6887 cache_gen = btrfs_super_cache_generation(&root->fs_info->super_copy); 6919 6888 if (cache_gen != 0 &&
+1 -1
fs/btrfs/extent_io.c
··· 1476 1476 if (total_bytes >= max_bytes) 1477 1477 break; 1478 1478 if (!found) { 1479 - *start = state->start; 1479 + *start = max(cur_start, state->start); 1480 1480 found = 1; 1481 1481 } 1482 1482 last = state->end;
+4 -6
fs/btrfs/file.c
··· 129 129 if (!btrfs_test_opt(root, AUTO_DEFRAG)) 130 130 return 0; 131 131 132 - if (root->fs_info->closing) 132 + if (btrfs_fs_closing(root->fs_info)) 133 133 return 0; 134 134 135 135 if (BTRFS_I(inode)->in_defrag) ··· 144 144 if (!defrag) 145 145 return -ENOMEM; 146 146 147 - defrag->ino = inode->i_ino; 147 + defrag->ino = btrfs_ino(inode); 148 148 defrag->transid = transid; 149 149 defrag->root = root->root_key.objectid; 150 150 ··· 229 229 first_ino = defrag->ino + 1; 230 230 rb_erase(&defrag->rb_node, &fs_info->defrag_inodes); 231 231 232 - if (fs_info->closing) 232 + if (btrfs_fs_closing(fs_info)) 233 233 goto next_free; 234 234 235 235 spin_unlock(&fs_info->defrag_inodes_lock); ··· 1480 1480 * the current transaction, we can bail out now without any 1481 1481 * syncing 1482 1482 */ 1483 - mutex_lock(&root->fs_info->trans_mutex); 1483 + smp_mb(); 1484 1484 if (BTRFS_I(inode)->last_trans <= 1485 1485 root->fs_info->last_trans_committed) { 1486 1486 BTRFS_I(inode)->last_trans = 0; 1487 - mutex_unlock(&root->fs_info->trans_mutex); 1488 1487 goto out; 1489 1488 } 1490 - mutex_unlock(&root->fs_info->trans_mutex); 1491 1489 1492 1490 /* 1493 1491 * ok we haven't committed the transaction yet, lets do a commit
+53 -17
fs/btrfs/free-space-cache.c
··· 98 98 return inode; 99 99 100 100 spin_lock(&block_group->lock); 101 - if (!root->fs_info->closing) { 101 + if (!btrfs_fs_closing(root->fs_info)) { 102 102 block_group->inode = igrab(inode); 103 103 block_group->iref = 1; 104 104 } ··· 402 402 spin_lock(&ctl->tree_lock); 403 403 ret = link_free_space(ctl, e); 404 404 spin_unlock(&ctl->tree_lock); 405 - BUG_ON(ret); 405 + if (ret) { 406 + printk(KERN_ERR "Duplicate entries in " 407 + "free space cache, dumping\n"); 408 + kunmap(page); 409 + unlock_page(page); 410 + page_cache_release(page); 411 + goto free_cache; 412 + } 406 413 } else { 407 414 e->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); 408 415 if (!e->bitmap) { ··· 426 419 ctl->op->recalc_thresholds(ctl); 427 420 spin_unlock(&ctl->tree_lock); 428 421 list_add_tail(&e->list, &bitmaps); 422 + if (ret) { 423 + printk(KERN_ERR "Duplicate entries in " 424 + "free space cache, dumping\n"); 425 + kunmap(page); 426 + unlock_page(page); 427 + page_cache_release(page); 428 + goto free_cache; 429 + } 429 430 } 430 431 431 432 num_entries--; ··· 493 478 * If we're unmounting then just return, since this does a search on the 494 479 * normal root and not the commit root and we could deadlock. 495 480 */ 496 - smp_mb(); 497 - if (fs_info->closing) 481 + if (btrfs_fs_closing(fs_info)) 498 482 return 0; 499 483 500 484 /* ··· 589 575 590 576 num_pages = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> 591 577 PAGE_CACHE_SHIFT; 578 + 579 + /* Since the first page has all of our checksums and our generation we 580 + * need to calculate the offset into the page that we can start writing 581 + * our entries. 582 + */ 583 + first_page_offset = (sizeof(u32) * num_pages) + sizeof(u64); 584 + 592 585 filemap_write_and_wait(inode->i_mapping); 593 586 btrfs_wait_ordered_range(inode, inode->i_size & 594 587 ~(root->sectorsize - 1), (u64)-1); 588 + 589 + /* make sure we don't overflow that first page */ 590 + if (first_page_offset + sizeof(struct btrfs_free_space_entry) >= PAGE_CACHE_SIZE) { 591 + /* this is really the same as running out of space, where we also return 0 */ 592 + printk(KERN_CRIT "Btrfs: free space cache was too big for the crc page\n"); 593 + ret = 0; 594 + goto out_update; 595 + } 595 596 596 597 /* We need a checksum per page. */ 597 598 crc = checksums = kzalloc(sizeof(u32) * num_pages, GFP_NOFS); ··· 618 589 kfree(crc); 619 590 return -1; 620 591 } 621 - 622 - /* Since the first page has all of our checksums and our generation we 623 - * need to calculate the offset into the page that we can start writing 624 - * our entries. 625 - */ 626 - first_page_offset = (sizeof(u32) * num_pages) + sizeof(u64); 627 592 628 593 /* Get the cluster for this block_group if it exists */ 629 594 if (block_group && !list_empty(&block_group->cluster_list)) ··· 880 857 ret = 1; 881 858 882 859 out_free: 860 + kfree(checksums); 861 + kfree(pages); 862 + 863 + out_update: 883 864 if (ret != 1) { 884 865 invalidate_inode_pages2_range(inode->i_mapping, 0, index); 885 866 BTRFS_I(inode)->generation = 0; 886 867 } 887 - kfree(checksums); 888 - kfree(pages); 889 868 btrfs_update_inode(trans, root, inode); 890 869 return ret; 891 870 } ··· 988 963 * logically. 989 964 */ 990 965 if (bitmap) { 991 - WARN_ON(info->bitmap); 966 + if (info->bitmap) { 967 + WARN_ON_ONCE(1); 968 + return -EEXIST; 969 + } 992 970 p = &(*p)->rb_right; 993 971 } else { 994 - WARN_ON(!info->bitmap); 972 + if (!info->bitmap) { 973 + WARN_ON_ONCE(1); 974 + return -EEXIST; 975 + } 995 976 p = &(*p)->rb_left; 996 977 } 997 978 } ··· 2512 2481 return inode; 2513 2482 2514 2483 spin_lock(&root->cache_lock); 2515 - if (!root->fs_info->closing) 2484 + if (!btrfs_fs_closing(root->fs_info)) 2516 2485 root->cache_inode = igrab(inode); 2517 2486 spin_unlock(&root->cache_lock); 2518 2487 ··· 2535 2504 int ret = 0; 2536 2505 u64 root_gen = btrfs_root_generation(&root->root_item); 2537 2506 2507 + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 2508 + return 0; 2509 + 2538 2510 /* 2539 2511 * If we're unmounting then just return, since this does a search on the 2540 2512 * normal root and not the commit root and we could deadlock. 2541 2513 */ 2542 - smp_mb(); 2543 - if (fs_info->closing) 2514 + if (btrfs_fs_closing(fs_info)) 2544 2515 return 0; 2545 2516 2546 2517 path = btrfs_alloc_path(); ··· 2575 2542 struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; 2576 2543 struct inode *inode; 2577 2544 int ret; 2545 + 2546 + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 2547 + return 0; 2578 2548 2579 2549 inode = lookup_free_ino_inode(root, path); 2580 2550 if (IS_ERR(inode))
+32 -2
fs/btrfs/inode-map.c
··· 38 38 int slot; 39 39 int ret; 40 40 41 + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 42 + return 0; 43 + 41 44 path = btrfs_alloc_path(); 42 45 if (!path) 43 46 return -ENOMEM; ··· 62 59 goto out; 63 60 64 61 while (1) { 65 - smp_mb(); 66 - if (fs_info->closing) 62 + if (btrfs_fs_closing(fs_info)) 67 63 goto out; 68 64 69 65 leaf = path->nodes[0]; ··· 143 141 int ret; 144 142 u64 objectid; 145 143 144 + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 145 + return; 146 + 146 147 spin_lock(&root->cache_lock); 147 148 if (root->cached != BTRFS_CACHE_NO) { 148 149 spin_unlock(&root->cache_lock); ··· 183 178 184 179 int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) 185 180 { 181 + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 182 + return btrfs_find_free_objectid(root, objectid); 183 + 186 184 again: 187 185 *objectid = btrfs_find_ino_for_alloc(root); 188 186 ··· 209 201 { 210 202 struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; 211 203 struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; 204 + 205 + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 206 + return; 207 + 212 208 again: 213 209 if (root->cached == BTRFS_CACHE_FINISHED) { 214 210 __btrfs_add_free_space(ctl, objectid, 1); ··· 261 249 struct btrfs_free_space *info; 262 250 struct rb_node *n; 263 251 u64 count; 252 + 253 + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 254 + return; 264 255 265 256 while (1) { 266 257 n = rb_first(rbroot); ··· 403 388 int prealloc; 404 389 bool retry = false; 405 390 391 + /* only fs tree and subvol/snap needs ino cache */ 392 + if (root->root_key.objectid != BTRFS_FS_TREE_OBJECTID && 393 + (root->root_key.objectid < BTRFS_FIRST_FREE_OBJECTID || 394 + root->root_key.objectid > BTRFS_LAST_FREE_OBJECTID)) 395 + return 0; 396 + 397 + /* Don't save inode cache if we are deleting this root */ 398 + if (btrfs_root_refs(&root->root_item) == 0 && 399 + root != root->fs_info->tree_root) 400 + return 0; 401 + 402 + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 403 + return 0; 404 + 406 405 path = btrfs_alloc_path(); 407 406 if (!path) 408 407 return -ENOMEM; 408 + 409 409 again: 410 410 inode = lookup_free_ino_inode(root, path); 411 411 if (IS_ERR(inode) && PTR_ERR(inode) != -ENOENT) {
+137 -124
fs/btrfs/inode.c
··· 138 138 return -ENOMEM; 139 139 140 140 path->leave_spinning = 1; 141 - btrfs_set_trans_block_group(trans, inode); 142 141 143 142 key.objectid = btrfs_ino(inode); 144 143 key.offset = start; ··· 425 426 } 426 427 } 427 428 if (start == 0) { 428 - trans = btrfs_join_transaction(root, 1); 429 + trans = btrfs_join_transaction(root); 429 430 BUG_ON(IS_ERR(trans)); 430 - btrfs_set_trans_block_group(trans, inode); 431 431 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 432 432 433 433 /* lets try to make an inline extent */ ··· 621 623 async_extent->start + async_extent->ram_size - 1, 622 624 GFP_NOFS); 623 625 624 - trans = btrfs_join_transaction(root, 1); 626 + trans = btrfs_join_transaction(root); 625 627 BUG_ON(IS_ERR(trans)); 628 + trans->block_rsv = &root->fs_info->delalloc_block_rsv; 626 629 ret = btrfs_reserve_extent(trans, root, 627 630 async_extent->compressed_size, 628 631 async_extent->compressed_size, ··· 792 793 int ret = 0; 793 794 794 795 BUG_ON(is_free_space_inode(root, inode)); 795 - trans = btrfs_join_transaction(root, 1); 796 + trans = btrfs_join_transaction(root); 796 797 BUG_ON(IS_ERR(trans)); 797 - btrfs_set_trans_block_group(trans, inode); 798 798 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 799 799 800 800 num_bytes = (end - start + blocksize) & ~(blocksize - 1); ··· 1075 1077 nolock = is_free_space_inode(root, inode); 1076 1078 1077 1079 if (nolock) 1078 - trans = btrfs_join_transaction_nolock(root, 1); 1080 + trans = btrfs_join_transaction_nolock(root); 1079 1081 else 1080 - trans = btrfs_join_transaction(root, 1); 1082 + trans = btrfs_join_transaction(root); 1083 + 1081 1084 BUG_ON(IS_ERR(trans)); 1085 + trans->block_rsv = &root->fs_info->delalloc_block_rsv; 1082 1086 1083 1087 cow_start = (u64)-1; 1084 1088 cur_offset = start; ··· 1519 1519 { 1520 1520 struct btrfs_ordered_sum *sum; 1521 1521 1522 - btrfs_set_trans_block_group(trans, inode); 1523 - 1524 1522 list_for_each_entry(sum, list, list) { 1525 1523 btrfs_csum_file_blocks(trans, 1526 1524 BTRFS_I(inode)->root->fs_info->csum_root, sum); ··· 1733 1735 ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent); 1734 1736 if (!ret) { 1735 1737 if (nolock) 1736 - trans = btrfs_join_transaction_nolock(root, 1); 1738 + trans = btrfs_join_transaction_nolock(root); 1737 1739 else 1738 - trans = btrfs_join_transaction(root, 1); 1740 + trans = btrfs_join_transaction(root); 1739 1741 BUG_ON(IS_ERR(trans)); 1740 - btrfs_set_trans_block_group(trans, inode); 1741 1742 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 1742 1743 ret = btrfs_update_inode(trans, root, inode); 1743 1744 BUG_ON(ret); ··· 1749 1752 0, &cached_state, GFP_NOFS); 1750 1753 1751 1754 if (nolock) 1752 - trans = btrfs_join_transaction_nolock(root, 1); 1755 + trans = btrfs_join_transaction_nolock(root); 1753 1756 else 1754 - trans = btrfs_join_transaction(root, 1); 1757 + trans = btrfs_join_transaction(root); 1755 1758 BUG_ON(IS_ERR(trans)); 1756 - btrfs_set_trans_block_group(trans, inode); 1757 1759 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 1758 1760 1759 1761 if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered_extent->flags)) ··· 2427 2431 (u64)-1); 2428 2432 2429 2433 if (root->orphan_block_rsv || root->orphan_item_inserted) { 2430 - trans = btrfs_join_transaction(root, 1); 2434 + trans = btrfs_join_transaction(root); 2431 2435 if (!IS_ERR(trans)) 2432 2436 btrfs_end_transaction(trans, root); 2433 2437 } ··· 2507 2511 struct btrfs_root *root = BTRFS_I(inode)->root; 2508 2512 struct btrfs_key location; 2509 2513 int maybe_acls; 2510 - u64 alloc_group_block; 2511 2514 u32 rdev; 2512 2515 int ret; 2513 2516 2514 2517 path = btrfs_alloc_path(); 2515 2518 BUG_ON(!path); 2519 + path->leave_spinning = 1; 2516 2520 memcpy(&location, &BTRFS_I(inode)->location, sizeof(location)); 2517 2521 2518 2522 ret = btrfs_lookup_inode(NULL, root, path, &location, 0); ··· 2522 2526 leaf = path->nodes[0]; 2523 2527 inode_item = btrfs_item_ptr(leaf, path->slots[0], 2524 2528 struct btrfs_inode_item); 2529 + if (!leaf->map_token) 2530 + map_private_extent_buffer(leaf, (unsigned long)inode_item, 2531 + sizeof(struct btrfs_inode_item), 2532 + &leaf->map_token, &leaf->kaddr, 2533 + &leaf->map_start, &leaf->map_len, 2534 + KM_USER1); 2525 2535 2526 2536 inode->i_mode = btrfs_inode_mode(leaf, inode_item); 2527 2537 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item); ··· 2557 2555 BTRFS_I(inode)->index_cnt = (u64)-1; 2558 2556 BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item); 2559 2557 2560 - alloc_group_block = btrfs_inode_block_group(leaf, inode_item); 2561 - 2562 2558 /* 2563 2559 * try to precache a NULL acl entry for files that don't have 2564 2560 * any xattrs or acls ··· 2566 2566 if (!maybe_acls) 2567 2567 cache_no_acl(inode); 2568 2568 2569 - BTRFS_I(inode)->block_group = btrfs_find_block_group(root, 0, 2570 - alloc_group_block, 0); 2569 + if (leaf->map_token) { 2570 + unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); 2571 + leaf->map_token = NULL; 2572 + } 2573 + 2571 2574 btrfs_free_path(path); 2572 2575 inode_item = NULL; 2573 2576 ··· 2650 2647 btrfs_set_inode_transid(leaf, item, trans->transid); 2651 2648 btrfs_set_inode_rdev(leaf, item, inode->i_rdev); 2652 2649 btrfs_set_inode_flags(leaf, item, BTRFS_I(inode)->flags); 2653 - btrfs_set_inode_block_group(leaf, item, BTRFS_I(inode)->block_group); 2650 + btrfs_set_inode_block_group(leaf, item, 0); 2654 2651 2655 2652 if (leaf->map_token) { 2656 2653 unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); ··· 3007 3004 if (IS_ERR(trans)) 3008 3005 return PTR_ERR(trans); 3009 3006 3010 - btrfs_set_trans_block_group(trans, dir); 3011 - 3012 3007 btrfs_record_unlink_dir(trans, dir, dentry->d_inode, 0); 3013 3008 3014 3009 ret = btrfs_unlink_inode(trans, root, dir, dentry->d_inode, ··· 3094 3093 trans = __unlink_start_trans(dir, dentry); 3095 3094 if (IS_ERR(trans)) 3096 3095 return PTR_ERR(trans); 3097 - 3098 - btrfs_set_trans_block_group(trans, dir); 3099 3096 3100 3097 if (unlikely(btrfs_ino(inode) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { 3101 3098 err = btrfs_unlink_subvol(trans, root, dir, ··· 3513 3514 err = PTR_ERR(trans); 3514 3515 break; 3515 3516 } 3516 - btrfs_set_trans_block_group(trans, inode); 3517 3517 3518 3518 err = btrfs_drop_extents(trans, inode, cur_offset, 3519 3519 cur_offset + hole_size, ··· 3648 3650 while (1) { 3649 3651 trans = btrfs_start_transaction(root, 0); 3650 3652 BUG_ON(IS_ERR(trans)); 3651 - btrfs_set_trans_block_group(trans, inode); 3652 3653 trans->block_rsv = root->orphan_block_rsv; 3653 3654 3654 3655 ret = btrfs_block_rsv_check(trans, root, ··· 4130 4133 path = btrfs_alloc_path(); 4131 4134 if (!path) 4132 4135 return -ENOMEM; 4133 - path->reada = 2; 4136 + 4137 + path->reada = 1; 4134 4138 4135 4139 if (key_type == BTRFS_DIR_INDEX_KEY) { 4136 4140 INIT_LIST_HEAD(&ins_list); ··· 4266 4268 if (BTRFS_I(inode)->dummy_inode) 4267 4269 return 0; 4268 4270 4269 - smp_mb(); 4270 - if (root->fs_info->closing && is_free_space_inode(root, inode)) 4271 + if (btrfs_fs_closing(root->fs_info) && is_free_space_inode(root, inode)) 4271 4272 nolock = true; 4272 4273 4273 4274 if (wbc->sync_mode == WB_SYNC_ALL) { 4274 4275 if (nolock) 4275 - trans = btrfs_join_transaction_nolock(root, 1); 4276 + trans = btrfs_join_transaction_nolock(root); 4276 4277 else 4277 - trans = btrfs_join_transaction(root, 1); 4278 + trans = btrfs_join_transaction(root); 4278 4279 if (IS_ERR(trans)) 4279 4280 return PTR_ERR(trans); 4280 - btrfs_set_trans_block_group(trans, inode); 4281 4281 if (nolock) 4282 4282 ret = btrfs_end_transaction_nolock(trans, root); 4283 4283 else ··· 4299 4303 if (BTRFS_I(inode)->dummy_inode) 4300 4304 return; 4301 4305 4302 - trans = btrfs_join_transaction(root, 1); 4306 + trans = btrfs_join_transaction(root); 4303 4307 BUG_ON(IS_ERR(trans)); 4304 - btrfs_set_trans_block_group(trans, inode); 4305 4308 4306 4309 ret = btrfs_update_inode(trans, root, inode); 4307 4310 if (ret && ret == -ENOSPC) { ··· 4314 4319 PTR_ERR(trans)); 4315 4320 return; 4316 4321 } 4317 - btrfs_set_trans_block_group(trans, inode); 4318 4322 4319 4323 ret = btrfs_update_inode(trans, root, inode); 4320 4324 if (ret) { ··· 4412 4418 struct btrfs_root *root, 4413 4419 struct inode *dir, 4414 4420 const char *name, int name_len, 4415 - u64 ref_objectid, u64 objectid, 4416 - u64 alloc_hint, int mode, u64 *index) 4421 + u64 ref_objectid, u64 objectid, int mode, 4422 + u64 *index) 4417 4423 { 4418 4424 struct inode *inode; 4419 4425 struct btrfs_inode_item *inode_item; ··· 4466 4472 owner = 0; 4467 4473 else 4468 4474 owner = 1; 4469 - BTRFS_I(inode)->block_group = 4470 - btrfs_find_block_group(root, 0, alloc_hint, owner); 4471 4475 4472 4476 key[0].objectid = objectid; 4473 4477 btrfs_set_key_type(&key[0], BTRFS_INODE_ITEM_KEY); ··· 4621 4629 if (IS_ERR(trans)) 4622 4630 return PTR_ERR(trans); 4623 4631 4624 - btrfs_set_trans_block_group(trans, dir); 4625 - 4626 4632 err = btrfs_find_free_ino(root, &objectid); 4627 4633 if (err) 4628 4634 goto out_unlock; 4629 4635 4630 4636 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 4631 4637 dentry->d_name.len, btrfs_ino(dir), objectid, 4632 - BTRFS_I(dir)->block_group, mode, &index); 4638 + mode, &index); 4633 4639 if (IS_ERR(inode)) { 4634 4640 err = PTR_ERR(inode); 4635 4641 goto out_unlock; ··· 4639 4649 goto out_unlock; 4640 4650 } 4641 4651 4642 - btrfs_set_trans_block_group(trans, inode); 4643 4652 err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); 4644 4653 if (err) 4645 4654 drop_inode = 1; ··· 4647 4658 init_special_inode(inode, inode->i_mode, rdev); 4648 4659 btrfs_update_inode(trans, root, inode); 4649 4660 } 4650 - btrfs_update_inode_block_group(trans, inode); 4651 - btrfs_update_inode_block_group(trans, dir); 4652 4661 out_unlock: 4653 4662 nr = trans->blocks_used; 4654 4663 btrfs_end_transaction_throttle(trans, root); ··· 4679 4692 if (IS_ERR(trans)) 4680 4693 return PTR_ERR(trans); 4681 4694 4682 - btrfs_set_trans_block_group(trans, dir); 4683 - 4684 4695 err = btrfs_find_free_ino(root, &objectid); 4685 4696 if (err) 4686 4697 goto out_unlock; 4687 4698 4688 4699 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 4689 4700 dentry->d_name.len, btrfs_ino(dir), objectid, 4690 - BTRFS_I(dir)->block_group, mode, &index); 4701 + mode, &index); 4691 4702 if (IS_ERR(inode)) { 4692 4703 err = PTR_ERR(inode); 4693 4704 goto out_unlock; ··· 4697 4712 goto out_unlock; 4698 4713 } 4699 4714 4700 - btrfs_set_trans_block_group(trans, inode); 4701 4715 err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); 4702 4716 if (err) 4703 4717 drop_inode = 1; ··· 4707 4723 inode->i_op = &btrfs_file_inode_operations; 4708 4724 BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; 4709 4725 } 4710 - btrfs_update_inode_block_group(trans, inode); 4711 - btrfs_update_inode_block_group(trans, dir); 4712 4726 out_unlock: 4713 4727 nr = trans->blocks_used; 4714 4728 btrfs_end_transaction_throttle(trans, root); ··· 4753 4771 4754 4772 btrfs_inc_nlink(inode); 4755 4773 inode->i_ctime = CURRENT_TIME; 4756 - 4757 - btrfs_set_trans_block_group(trans, dir); 4758 4774 ihold(inode); 4759 4775 4760 4776 err = btrfs_add_nondir(trans, dir, dentry, inode, 1, index); ··· 4761 4781 drop_inode = 1; 4762 4782 } else { 4763 4783 struct dentry *parent = dget_parent(dentry); 4764 - btrfs_update_inode_block_group(trans, dir); 4765 4784 err = btrfs_update_inode(trans, root, inode); 4766 4785 BUG_ON(err); 4767 4786 btrfs_log_new_name(trans, inode, NULL, parent); ··· 4797 4818 trans = btrfs_start_transaction(root, 5); 4798 4819 if (IS_ERR(trans)) 4799 4820 return PTR_ERR(trans); 4800 - btrfs_set_trans_block_group(trans, dir); 4801 4821 4802 4822 err = btrfs_find_free_ino(root, &objectid); 4803 4823 if (err) ··· 4804 4826 4805 4827 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 4806 4828 dentry->d_name.len, btrfs_ino(dir), objectid, 4807 - BTRFS_I(dir)->block_group, S_IFDIR | mode, 4808 - &index); 4829 + S_IFDIR | mode, &index); 4809 4830 if (IS_ERR(inode)) { 4810 4831 err = PTR_ERR(inode); 4811 4832 goto out_fail; ··· 4818 4841 4819 4842 inode->i_op = &btrfs_dir_inode_operations; 4820 4843 inode->i_fop = &btrfs_dir_file_operations; 4821 - btrfs_set_trans_block_group(trans, inode); 4822 4844 4823 4845 btrfs_i_size_write(inode, 0); 4824 4846 err = btrfs_update_inode(trans, root, inode); ··· 4831 4855 4832 4856 d_instantiate(dentry, inode); 4833 4857 drop_on_err = 0; 4834 - btrfs_update_inode_block_group(trans, inode); 4835 - btrfs_update_inode_block_group(trans, dir); 4836 4858 4837 4859 out_fail: 4838 4860 nr = trans->blocks_used; ··· 4963 4989 4964 4990 if (!path) { 4965 4991 path = btrfs_alloc_path(); 4966 - BUG_ON(!path); 4992 + if (!path) { 4993 + err = -ENOMEM; 4994 + goto out; 4995 + } 4996 + /* 4997 + * Chances are we'll be called again, so go ahead and do 4998 + * readahead 4999 + */ 5000 + path->reada = 1; 4967 5001 } 4968 5002 4969 5003 ret = btrfs_lookup_file_extent(trans, root, path, ··· 5112 5130 kunmap(page); 5113 5131 free_extent_map(em); 5114 5132 em = NULL; 5133 + 5115 5134 btrfs_release_path(path); 5116 - trans = btrfs_join_transaction(root, 1); 5135 + trans = btrfs_join_transaction(root); 5136 + 5117 5137 if (IS_ERR(trans)) 5118 5138 return ERR_CAST(trans); 5119 5139 goto again; ··· 5359 5375 btrfs_drop_extent_cache(inode, start, start + len - 1, 0); 5360 5376 } 5361 5377 5362 - trans = btrfs_join_transaction(root, 0); 5378 + trans = btrfs_join_transaction(root); 5363 5379 if (IS_ERR(trans)) 5364 5380 return ERR_CAST(trans); 5365 5381 ··· 5595 5611 * to make sure the current transaction stays open 5596 5612 * while we look for nocow cross refs 5597 5613 */ 5598 - trans = btrfs_join_transaction(root, 0); 5614 + trans = btrfs_join_transaction(root); 5599 5615 if (IS_ERR(trans)) 5600 5616 goto must_cow; 5601 5617 ··· 5734 5750 5735 5751 BUG_ON(!ordered); 5736 5752 5737 - trans = btrfs_join_transaction(root, 1); 5753 + trans = btrfs_join_transaction(root); 5738 5754 if (IS_ERR(trans)) { 5739 5755 err = -ENOMEM; 5740 5756 goto out; ··· 6484 6500 static int btrfs_truncate(struct inode *inode) 6485 6501 { 6486 6502 struct btrfs_root *root = BTRFS_I(inode)->root; 6503 + struct btrfs_block_rsv *rsv; 6487 6504 int ret; 6488 6505 int err = 0; 6489 6506 struct btrfs_trans_handle *trans; ··· 6498 6513 btrfs_wait_ordered_range(inode, inode->i_size & (~mask), (u64)-1); 6499 6514 btrfs_ordered_update_i_size(inode, inode->i_size, NULL); 6500 6515 6501 - trans = btrfs_start_transaction(root, 5); 6502 - if (IS_ERR(trans)) 6503 - return PTR_ERR(trans); 6516 + /* 6517 + * Yes ladies and gentelment, this is indeed ugly. The fact is we have 6518 + * 3 things going on here 6519 + * 6520 + * 1) We need to reserve space for our orphan item and the space to 6521 + * delete our orphan item. Lord knows we don't want to have a dangling 6522 + * orphan item because we didn't reserve space to remove it. 6523 + * 6524 + * 2) We need to reserve space to update our inode. 6525 + * 6526 + * 3) We need to have something to cache all the space that is going to 6527 + * be free'd up by the truncate operation, but also have some slack 6528 + * space reserved in case it uses space during the truncate (thank you 6529 + * very much snapshotting). 6530 + * 6531 + * And we need these to all be seperate. The fact is we can use alot of 6532 + * space doing the truncate, and we have no earthly idea how much space 6533 + * we will use, so we need the truncate reservation to be seperate so it 6534 + * doesn't end up using space reserved for updating the inode or 6535 + * removing the orphan item. We also need to be able to stop the 6536 + * transaction and start a new one, which means we need to be able to 6537 + * update the inode several times, and we have no idea of knowing how 6538 + * many times that will be, so we can't just reserve 1 item for the 6539 + * entirety of the opration, so that has to be done seperately as well. 6540 + * Then there is the orphan item, which does indeed need to be held on 6541 + * to for the whole operation, and we need nobody to touch this reserved 6542 + * space except the orphan code. 6543 + * 6544 + * So that leaves us with 6545 + * 6546 + * 1) root->orphan_block_rsv - for the orphan deletion. 6547 + * 2) rsv - for the truncate reservation, which we will steal from the 6548 + * transaction reservation. 6549 + * 3) fs_info->trans_block_rsv - this will have 1 items worth left for 6550 + * updating the inode. 6551 + */ 6552 + rsv = btrfs_alloc_block_rsv(root); 6553 + if (!rsv) 6554 + return -ENOMEM; 6555 + btrfs_add_durable_block_rsv(root->fs_info, rsv); 6504 6556 6505 - btrfs_set_trans_block_group(trans, inode); 6557 + trans = btrfs_start_transaction(root, 4); 6558 + if (IS_ERR(trans)) { 6559 + err = PTR_ERR(trans); 6560 + goto out; 6561 + } 6562 + 6563 + /* 6564 + * Reserve space for the truncate process. Truncate should be adding 6565 + * space, but if there are snapshots it may end up using space. 6566 + */ 6567 + ret = btrfs_truncate_reserve_metadata(trans, root, rsv); 6568 + BUG_ON(ret); 6506 6569 6507 6570 ret = btrfs_orphan_add(trans, inode); 6508 6571 if (ret) { 6509 6572 btrfs_end_transaction(trans, root); 6510 - return ret; 6573 + goto out; 6511 6574 } 6512 6575 6513 6576 nr = trans->blocks_used; 6514 6577 btrfs_end_transaction(trans, root); 6515 6578 btrfs_btree_balance_dirty(root, nr); 6516 6579 6517 - /* Now start a transaction for the truncate */ 6518 - trans = btrfs_start_transaction(root, 0); 6519 - if (IS_ERR(trans)) 6520 - return PTR_ERR(trans); 6521 - btrfs_set_trans_block_group(trans, inode); 6522 - trans->block_rsv = root->orphan_block_rsv; 6580 + /* 6581 + * Ok so we've already migrated our bytes over for the truncate, so here 6582 + * just reserve the one slot we need for updating the inode. 6583 + */ 6584 + trans = btrfs_start_transaction(root, 1); 6585 + if (IS_ERR(trans)) { 6586 + err = PTR_ERR(trans); 6587 + goto out; 6588 + } 6589 + trans->block_rsv = rsv; 6523 6590 6524 6591 /* 6525 6592 * setattr is responsible for setting the ordered_data_close flag, ··· 6595 6558 6596 6559 while (1) { 6597 6560 if (!trans) { 6598 - trans = btrfs_start_transaction(root, 0); 6599 - if (IS_ERR(trans)) 6600 - return PTR_ERR(trans); 6601 - btrfs_set_trans_block_group(trans, inode); 6602 - trans->block_rsv = root->orphan_block_rsv; 6603 - } 6561 + trans = btrfs_start_transaction(root, 3); 6562 + if (IS_ERR(trans)) { 6563 + err = PTR_ERR(trans); 6564 + goto out; 6565 + } 6604 6566 6605 - ret = btrfs_block_rsv_check(trans, root, 6606 - root->orphan_block_rsv, 0, 5); 6607 - if (ret == -EAGAIN) { 6608 - ret = btrfs_commit_transaction(trans, root); 6609 - if (ret) 6610 - return ret; 6611 - trans = NULL; 6612 - continue; 6613 - } else if (ret) { 6614 - err = ret; 6615 - break; 6567 + ret = btrfs_truncate_reserve_metadata(trans, root, 6568 + rsv); 6569 + BUG_ON(ret); 6570 + 6571 + trans->block_rsv = rsv; 6616 6572 } 6617 6573 6618 6574 ret = btrfs_truncate_inode_items(trans, root, inode, ··· 6616 6586 break; 6617 6587 } 6618 6588 6589 + trans->block_rsv = &root->fs_info->trans_block_rsv; 6619 6590 ret = btrfs_update_inode(trans, root, inode); 6620 6591 if (ret) { 6621 6592 err = ret; ··· 6630 6599 } 6631 6600 6632 6601 if (ret == 0 && inode->i_nlink > 0) { 6602 + trans->block_rsv = root->orphan_block_rsv; 6633 6603 ret = btrfs_orphan_del(trans, inode); 6634 6604 if (ret) 6635 6605 err = ret; ··· 6642 6610 ret = btrfs_orphan_del(NULL, inode); 6643 6611 } 6644 6612 6613 + trans->block_rsv = &root->fs_info->trans_block_rsv; 6645 6614 ret = btrfs_update_inode(trans, root, inode); 6646 6615 if (ret && !err) 6647 6616 err = ret; 6648 6617 6649 6618 nr = trans->blocks_used; 6650 6619 ret = btrfs_end_transaction_throttle(trans, root); 6620 + btrfs_btree_balance_dirty(root, nr); 6621 + 6622 + out: 6623 + btrfs_free_block_rsv(root, rsv); 6624 + 6651 6625 if (ret && !err) 6652 6626 err = ret; 6653 - btrfs_btree_balance_dirty(root, nr); 6654 6627 6655 6628 return err; 6656 6629 } ··· 6664 6627 * create a new subvolume directory/inode (helper for the ioctl). 6665 6628 */ 6666 6629 int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, 6667 - struct btrfs_root *new_root, 6668 - u64 new_dirid, u64 alloc_hint) 6630 + struct btrfs_root *new_root, u64 new_dirid) 6669 6631 { 6670 6632 struct inode *inode; 6671 6633 int err; 6672 6634 u64 index = 0; 6673 6635 6674 6636 inode = btrfs_new_inode(trans, new_root, NULL, "..", 2, new_dirid, 6675 - new_dirid, alloc_hint, S_IFDIR | 0700, &index); 6637 + new_dirid, S_IFDIR | 0700, &index); 6676 6638 if (IS_ERR(inode)) 6677 6639 return PTR_ERR(inode); 6678 6640 inode->i_op = &btrfs_dir_inode_operations; ··· 6782 6746 spin_lock(&root->fs_info->ordered_extent_lock); 6783 6747 list_del_init(&BTRFS_I(inode)->ordered_operations); 6784 6748 spin_unlock(&root->fs_info->ordered_extent_lock); 6785 - } 6786 - 6787 - if (root == root->fs_info->tree_root) { 6788 - struct btrfs_block_group_cache *block_group; 6789 - 6790 - block_group = btrfs_lookup_block_group(root->fs_info, 6791 - BTRFS_I(inode)->block_group); 6792 - if (block_group && block_group->inode == inode) { 6793 - spin_lock(&block_group->lock); 6794 - block_group->inode = NULL; 6795 - spin_unlock(&block_group->lock); 6796 - btrfs_put_block_group(block_group); 6797 - } else if (block_group) { 6798 - btrfs_put_block_group(block_group); 6799 - } 6800 6749 } 6801 6750 6802 6751 spin_lock(&root->orphan_lock); ··· 6969 6948 goto out_notrans; 6970 6949 } 6971 6950 6972 - btrfs_set_trans_block_group(trans, new_dir); 6973 - 6974 6951 if (dest != root) 6975 6952 btrfs_record_root_in_trans(trans, dest); 6976 6953 ··· 7150 7131 if (IS_ERR(trans)) 7151 7132 return PTR_ERR(trans); 7152 7133 7153 - btrfs_set_trans_block_group(trans, dir); 7154 - 7155 7134 err = btrfs_find_free_ino(root, &objectid); 7156 7135 if (err) 7157 7136 goto out_unlock; 7158 7137 7159 7138 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 7160 7139 dentry->d_name.len, btrfs_ino(dir), objectid, 7161 - BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO, 7162 - &index); 7140 + S_IFLNK|S_IRWXUGO, &index); 7163 7141 if (IS_ERR(inode)) { 7164 7142 err = PTR_ERR(inode); 7165 7143 goto out_unlock; ··· 7168 7152 goto out_unlock; 7169 7153 } 7170 7154 7171 - btrfs_set_trans_block_group(trans, inode); 7172 7155 err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); 7173 7156 if (err) 7174 7157 drop_inode = 1; ··· 7178 7163 inode->i_op = &btrfs_file_inode_operations; 7179 7164 BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; 7180 7165 } 7181 - btrfs_update_inode_block_group(trans, inode); 7182 - btrfs_update_inode_block_group(trans, dir); 7183 7166 if (drop_inode) 7184 7167 goto out_unlock; 7185 7168
+10 -16
fs/btrfs/ioctl.c
··· 243 243 ip->flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS); 244 244 } 245 245 246 - trans = btrfs_join_transaction(root, 1); 246 + trans = btrfs_join_transaction(root); 247 247 BUG_ON(IS_ERR(trans)); 248 248 249 249 ret = btrfs_update_inode(trans, root, inode); ··· 414 414 415 415 btrfs_record_root_in_trans(trans, new_root); 416 416 417 - ret = btrfs_create_subvol_root(trans, new_root, new_dirid, 418 - BTRFS_I(dir)->block_group); 417 + ret = btrfs_create_subvol_root(trans, new_root, new_dirid); 419 418 /* 420 419 * insert the directory item 421 420 */ ··· 706 707 struct btrfs_file_extent_item *extent; 707 708 int type; 708 709 int ret; 710 + u64 ino = btrfs_ino(inode); 709 711 710 712 path = btrfs_alloc_path(); 711 713 if (!path) 712 714 return -ENOMEM; 713 715 714 - min_key.objectid = inode->i_ino; 716 + min_key.objectid = ino; 715 717 min_key.type = BTRFS_EXTENT_DATA_KEY; 716 718 min_key.offset = *off; 717 719 718 - max_key.objectid = inode->i_ino; 720 + max_key.objectid = ino; 719 721 max_key.type = (u8)-1; 720 722 max_key.offset = (u64)-1; 721 723 ··· 727 727 path, 0, newer_than); 728 728 if (ret != 0) 729 729 goto none; 730 - if (min_key.objectid != inode->i_ino) 730 + if (min_key.objectid != ino) 731 731 goto none; 732 732 if (min_key.type != BTRFS_EXTENT_DATA_KEY) 733 733 goto none; ··· 2489 2489 if (ret) 2490 2490 goto out; 2491 2491 2492 - mutex_lock(&root->fs_info->trans_mutex); 2493 - root->fs_info->open_ioctl_trans++; 2494 - mutex_unlock(&root->fs_info->trans_mutex); 2492 + atomic_inc(&root->fs_info->open_ioctl_trans); 2495 2493 2496 2494 ret = -ENOMEM; 2497 - trans = btrfs_start_ioctl_transaction(root, 0); 2495 + trans = btrfs_start_ioctl_transaction(root); 2498 2496 if (IS_ERR(trans)) 2499 2497 goto out_drop; 2500 2498 ··· 2500 2502 return 0; 2501 2503 2502 2504 out_drop: 2503 - mutex_lock(&root->fs_info->trans_mutex); 2504 - root->fs_info->open_ioctl_trans--; 2505 - mutex_unlock(&root->fs_info->trans_mutex); 2505 + atomic_dec(&root->fs_info->open_ioctl_trans); 2506 2506 mnt_drop_write(file->f_path.mnt); 2507 2507 out: 2508 2508 return ret; ··· 2734 2738 2735 2739 btrfs_end_transaction(trans, root); 2736 2740 2737 - mutex_lock(&root->fs_info->trans_mutex); 2738 - root->fs_info->open_ioctl_trans--; 2739 - mutex_unlock(&root->fs_info->trans_mutex); 2741 + atomic_dec(&root->fs_info->open_ioctl_trans); 2740 2742 2741 2743 mnt_drop_write(file->f_path.mnt); 2742 2744 return 0;
+20 -14
fs/btrfs/relocation.c
··· 677 677 err = -ENOMEM; 678 678 goto out; 679 679 } 680 + path1->reada = 1; 681 + path2->reada = 2; 680 682 681 683 node = alloc_backref_node(cache); 682 684 if (!node) { ··· 2001 1999 path = btrfs_alloc_path(); 2002 2000 if (!path) 2003 2001 return -ENOMEM; 2002 + path->reada = 1; 2004 2003 2005 2004 reloc_root = root->reloc_root; 2006 2005 root_item = &reloc_root->root_item; ··· 2142 2139 u64 num_bytes = 0; 2143 2140 int ret; 2144 2141 2145 - mutex_lock(&root->fs_info->trans_mutex); 2142 + spin_lock(&root->fs_info->trans_lock); 2146 2143 rc->merging_rsv_size += root->nodesize * (BTRFS_MAX_LEVEL - 1) * 2; 2147 2144 rc->merging_rsv_size += rc->nodes_relocated * 2; 2148 - mutex_unlock(&root->fs_info->trans_mutex); 2145 + spin_unlock(&root->fs_info->trans_lock); 2149 2146 again: 2150 2147 if (!err) { 2151 2148 num_bytes = rc->merging_rsv_size; ··· 2155 2152 err = ret; 2156 2153 } 2157 2154 2158 - trans = btrfs_join_transaction(rc->extent_root, 1); 2155 + trans = btrfs_join_transaction(rc->extent_root); 2159 2156 if (IS_ERR(trans)) { 2160 2157 if (!err) 2161 2158 btrfs_block_rsv_release(rc->extent_root, ··· 2214 2211 int ret; 2215 2212 again: 2216 2213 root = rc->extent_root; 2217 - mutex_lock(&root->fs_info->trans_mutex); 2214 + spin_lock(&root->fs_info->trans_lock); 2218 2215 list_splice_init(&rc->reloc_roots, &reloc_roots); 2219 - mutex_unlock(&root->fs_info->trans_mutex); 2216 + spin_unlock(&root->fs_info->trans_lock); 2220 2217 2221 2218 while (!list_empty(&reloc_roots)) { 2222 2219 found = 1; ··· 3239 3236 goto out; 3240 3237 } 3241 3238 3242 - trans = btrfs_join_transaction(root, 0); 3239 + trans = btrfs_join_transaction(root); 3243 3240 if (IS_ERR(trans)) { 3244 3241 btrfs_free_path(path); 3245 3242 ret = PTR_ERR(trans); ··· 3303 3300 path = btrfs_alloc_path(); 3304 3301 if (!path) 3305 3302 return -ENOMEM; 3303 + path->reada = 1; 3306 3304 3307 3305 root = read_fs_root(rc->extent_root->fs_info, ref_root); 3308 3306 if (IS_ERR(root)) { ··· 3590 3586 static void set_reloc_control(struct reloc_control *rc) 3591 3587 { 3592 3588 struct btrfs_fs_info *fs_info = rc->extent_root->fs_info; 3593 - mutex_lock(&fs_info->trans_mutex); 3589 + spin_lock(&fs_info->trans_lock); 3594 3590 fs_info->reloc_ctl = rc; 3595 - mutex_unlock(&fs_info->trans_mutex); 3591 + spin_unlock(&fs_info->trans_lock); 3596 3592 } 3597 3593 3598 3594 static void unset_reloc_control(struct reloc_control *rc) 3599 3595 { 3600 3596 struct btrfs_fs_info *fs_info = rc->extent_root->fs_info; 3601 - mutex_lock(&fs_info->trans_mutex); 3597 + spin_lock(&fs_info->trans_lock); 3602 3598 fs_info->reloc_ctl = NULL; 3603 - mutex_unlock(&fs_info->trans_mutex); 3599 + spin_unlock(&fs_info->trans_lock); 3604 3600 } 3605 3601 3606 3602 static int check_extent_flags(u64 flags) ··· 3649 3645 rc->create_reloc_tree = 1; 3650 3646 set_reloc_control(rc); 3651 3647 3652 - trans = btrfs_join_transaction(rc->extent_root, 1); 3648 + trans = btrfs_join_transaction(rc->extent_root); 3653 3649 BUG_ON(IS_ERR(trans)); 3654 3650 btrfs_commit_transaction(trans, rc->extent_root); 3655 3651 return 0; ··· 3672 3668 path = btrfs_alloc_path(); 3673 3669 if (!path) 3674 3670 return -ENOMEM; 3671 + path->reada = 1; 3675 3672 3676 3673 ret = prepare_to_relocate(rc); 3677 3674 if (ret) { ··· 3839 3834 btrfs_block_rsv_release(rc->extent_root, rc->block_rsv, (u64)-1); 3840 3835 3841 3836 /* get rid of pinned extents */ 3842 - trans = btrfs_join_transaction(rc->extent_root, 1); 3837 + trans = btrfs_join_transaction(rc->extent_root); 3843 3838 if (IS_ERR(trans)) 3844 3839 err = PTR_ERR(trans); 3845 3840 else ··· 4098 4093 path = btrfs_alloc_path(); 4099 4094 if (!path) 4100 4095 return -ENOMEM; 4096 + path->reada = -1; 4101 4097 4102 4098 key.objectid = BTRFS_TREE_RELOC_OBJECTID; 4103 4099 key.type = BTRFS_ROOT_ITEM_KEY; ··· 4165 4159 4166 4160 set_reloc_control(rc); 4167 4161 4168 - trans = btrfs_join_transaction(rc->extent_root, 1); 4162 + trans = btrfs_join_transaction(rc->extent_root); 4169 4163 if (IS_ERR(trans)) { 4170 4164 unset_reloc_control(rc); 4171 4165 err = PTR_ERR(trans); ··· 4199 4193 4200 4194 unset_reloc_control(rc); 4201 4195 4202 - trans = btrfs_join_transaction(rc->extent_root, 1); 4196 + trans = btrfs_join_transaction(rc->extent_root); 4203 4197 if (IS_ERR(trans)) 4204 4198 err = PTR_ERR(trans); 4205 4199 else
+70 -53
fs/btrfs/scrub.c
··· 117 117 } 118 118 } 119 119 120 + static void scrub_free_bio(struct bio *bio) 121 + { 122 + int i; 123 + struct page *last_page = NULL; 124 + 125 + if (!bio) 126 + return; 127 + 128 + for (i = 0; i < bio->bi_vcnt; ++i) { 129 + if (bio->bi_io_vec[i].bv_page == last_page) 130 + continue; 131 + last_page = bio->bi_io_vec[i].bv_page; 132 + __free_page(last_page); 133 + } 134 + bio_put(bio); 135 + } 136 + 120 137 static noinline_for_stack void scrub_free_dev(struct scrub_dev *sdev) 121 138 { 122 139 int i; 123 - int j; 124 - struct page *last_page; 125 140 126 141 if (!sdev) 127 142 return; 128 143 129 144 for (i = 0; i < SCRUB_BIOS_PER_DEV; ++i) { 130 145 struct scrub_bio *sbio = sdev->bios[i]; 131 - struct bio *bio; 132 146 133 147 if (!sbio) 134 148 break; 135 149 136 - bio = sbio->bio; 137 - if (bio) { 138 - last_page = NULL; 139 - for (j = 0; j < bio->bi_vcnt; ++j) { 140 - if (bio->bi_io_vec[j].bv_page == last_page) 141 - continue; 142 - last_page = bio->bi_io_vec[j].bv_page; 143 - __free_page(last_page); 144 - } 145 - bio_put(bio); 146 - } 150 + scrub_free_bio(sbio->bio); 147 151 kfree(sbio); 148 152 } 149 153 ··· 160 156 { 161 157 struct scrub_dev *sdev; 162 158 int i; 163 - int j; 164 - int ret; 165 159 struct btrfs_fs_info *fs_info = dev->dev_root->fs_info; 166 160 167 161 sdev = kzalloc(sizeof(*sdev), GFP_NOFS); ··· 167 165 goto nomem; 168 166 sdev->dev = dev; 169 167 for (i = 0; i < SCRUB_BIOS_PER_DEV; ++i) { 170 - struct bio *bio; 171 168 struct scrub_bio *sbio; 172 169 173 170 sbio = kzalloc(sizeof(*sbio), GFP_NOFS); ··· 174 173 goto nomem; 175 174 sdev->bios[i] = sbio; 176 175 177 - bio = bio_kmalloc(GFP_NOFS, SCRUB_PAGES_PER_BIO); 178 - if (!bio) 179 - goto nomem; 180 - 181 176 sbio->index = i; 182 177 sbio->sdev = sdev; 183 - sbio->bio = bio; 184 178 sbio->count = 0; 185 179 sbio->work.func = scrub_checksum; 186 - bio->bi_private = sdev->bios[i]; 187 - bio->bi_end_io = scrub_bio_end_io; 188 - bio->bi_sector = 0; 189 - bio->bi_bdev = dev->bdev; 190 - bio->bi_size = 0; 191 - 192 - for (j = 0; j < SCRUB_PAGES_PER_BIO; ++j) { 193 - struct page *page; 194 - page = alloc_page(GFP_NOFS); 195 - if (!page) 196 - goto nomem; 197 - 198 - ret = bio_add_page(bio, page, PAGE_SIZE, 0); 199 - if (!ret) 200 - goto nomem; 201 - } 202 - WARN_ON(bio->bi_vcnt != SCRUB_PAGES_PER_BIO); 203 180 204 181 if (i != SCRUB_BIOS_PER_DEV-1) 205 182 sdev->bios[i]->next_free = i + 1; ··· 348 369 int ret; 349 370 DECLARE_COMPLETION_ONSTACK(complete); 350 371 351 - /* we are going to wait on this IO */ 352 - rw |= REQ_SYNC; 353 - 354 372 bio = bio_alloc(GFP_NOFS, 1); 355 373 bio->bi_bdev = bdev; 356 374 bio->bi_sector = sector; ··· 356 380 bio->bi_private = &complete; 357 381 submit_bio(rw, bio); 358 382 383 + /* this will also unplug the queue */ 359 384 wait_for_completion(&complete); 360 385 361 386 ret = !test_bit(BIO_UPTODATE, &bio->bi_flags); ··· 371 394 struct btrfs_fs_info *fs_info = sdev->dev->dev_root->fs_info; 372 395 373 396 sbio->err = err; 397 + sbio->bio = bio; 374 398 375 399 btrfs_queue_worker(&fs_info->scrub_workers, &sbio->work); 376 400 } ··· 431 453 } 432 454 433 455 out: 456 + scrub_free_bio(sbio->bio); 457 + sbio->bio = NULL; 434 458 spin_lock(&sdev->list_lock); 435 459 sbio->next_free = sdev->first_free; 436 460 sdev->first_free = sbio->index; ··· 563 583 static int scrub_submit(struct scrub_dev *sdev) 564 584 { 565 585 struct scrub_bio *sbio; 586 + struct bio *bio; 587 + int i; 566 588 567 589 if (sdev->curr == -1) 568 590 return 0; 569 591 570 592 sbio = sdev->bios[sdev->curr]; 571 593 572 - sbio->bio->bi_sector = sbio->physical >> 9; 573 - sbio->bio->bi_size = sbio->count * PAGE_SIZE; 574 - sbio->bio->bi_next = NULL; 575 - sbio->bio->bi_flags |= 1 << BIO_UPTODATE; 576 - sbio->bio->bi_comp_cpu = -1; 577 - sbio->bio->bi_bdev = sdev->dev->bdev; 594 + bio = bio_alloc(GFP_NOFS, sbio->count); 595 + if (!bio) 596 + goto nomem; 597 + 598 + bio->bi_private = sbio; 599 + bio->bi_end_io = scrub_bio_end_io; 600 + bio->bi_bdev = sdev->dev->bdev; 601 + bio->bi_sector = sbio->physical >> 9; 602 + 603 + for (i = 0; i < sbio->count; ++i) { 604 + struct page *page; 605 + int ret; 606 + 607 + page = alloc_page(GFP_NOFS); 608 + if (!page) 609 + goto nomem; 610 + 611 + ret = bio_add_page(bio, page, PAGE_SIZE, 0); 612 + if (!ret) { 613 + __free_page(page); 614 + goto nomem; 615 + } 616 + } 617 + 578 618 sbio->err = 0; 579 619 sdev->curr = -1; 580 620 atomic_inc(&sdev->in_flight); 581 621 582 - submit_bio(0, sbio->bio); 622 + submit_bio(READ, bio); 583 623 584 624 return 0; 625 + 626 + nomem: 627 + scrub_free_bio(bio); 628 + 629 + return -ENOMEM; 585 630 } 586 631 587 632 static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len, ··· 638 633 sbio->logical = logical; 639 634 } else if (sbio->physical + sbio->count * PAGE_SIZE != physical || 640 635 sbio->logical + sbio->count * PAGE_SIZE != logical) { 641 - scrub_submit(sdev); 636 + int ret; 637 + 638 + ret = scrub_submit(sdev); 639 + if (ret) 640 + return ret; 642 641 goto again; 643 642 } 644 643 sbio->spag[sbio->count].flags = flags; ··· 654 645 memcpy(sbio->spag[sbio->count].csum, csum, sdev->csum_size); 655 646 } 656 647 ++sbio->count; 657 - if (sbio->count == SCRUB_PAGES_PER_BIO || force) 658 - scrub_submit(sdev); 648 + if (sbio->count == SCRUB_PAGES_PER_BIO || force) { 649 + int ret; 650 + 651 + ret = scrub_submit(sdev); 652 + if (ret) 653 + return ret; 654 + } 659 655 660 656 return 0; 661 657 } ··· 741 727 struct btrfs_root *root = fs_info->extent_root; 742 728 struct btrfs_root *csum_root = fs_info->csum_root; 743 729 struct btrfs_extent_item *extent; 730 + struct blk_plug plug; 744 731 u64 flags; 745 732 int ret; 746 733 int slot; ··· 846 831 * the scrub. This might currently (crc32) end up to be about 1MB 847 832 */ 848 833 start_stripe = 0; 834 + blk_start_plug(&plug); 849 835 again: 850 836 logical = base + offset + start_stripe * increment; 851 837 for (i = start_stripe; i < nstripes; ++i) { ··· 988 972 scrub_submit(sdev); 989 973 990 974 out: 975 + blk_finish_plug(&plug); 991 976 btrfs_free_path(path); 992 977 return ret < 0 ? ret : 0; 993 978 } ··· 1183 1166 int ret; 1184 1167 struct btrfs_device *dev; 1185 1168 1186 - if (root->fs_info->closing) 1169 + if (btrfs_fs_closing(root->fs_info)) 1187 1170 return -EINVAL; 1188 1171 1189 1172 /*
+7 -1
fs/btrfs/super.c
··· 161 161 Opt_compress_type, Opt_compress_force, Opt_compress_force_type, 162 162 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard, 163 163 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed, 164 - Opt_enospc_debug, Opt_subvolrootid, Opt_defrag, Opt_err, 164 + Opt_enospc_debug, Opt_subvolrootid, Opt_defrag, 165 + Opt_inode_cache, Opt_err, 165 166 }; 166 167 167 168 static match_table_t tokens = { ··· 194 193 {Opt_enospc_debug, "enospc_debug"}, 195 194 {Opt_subvolrootid, "subvolrootid=%d"}, 196 195 {Opt_defrag, "autodefrag"}, 196 + {Opt_inode_cache, "inode_cache"}, 197 197 {Opt_err, NULL}, 198 198 }; 199 199 ··· 362 360 case Opt_space_cache: 363 361 printk(KERN_INFO "btrfs: enabling disk space caching\n"); 364 362 btrfs_set_opt(info->mount_opt, SPACE_CACHE); 363 + break; 364 + case Opt_inode_cache: 365 + printk(KERN_INFO "btrfs: enabling inode map caching\n"); 366 + btrfs_set_opt(info->mount_opt, INODE_MAP_CACHE); 365 367 break; 366 368 case Opt_clear_cache: 367 369 printk(KERN_INFO "btrfs: force clearing of disk cache\n");
+164 -138
fs/btrfs/transaction.c
··· 35 35 { 36 36 WARN_ON(atomic_read(&transaction->use_count) == 0); 37 37 if (atomic_dec_and_test(&transaction->use_count)) { 38 + BUG_ON(!list_empty(&transaction->list)); 38 39 memset(transaction, 0, sizeof(*transaction)); 39 40 kmem_cache_free(btrfs_transaction_cachep, transaction); 40 41 } ··· 50 49 /* 51 50 * either allocate a new transaction or hop into the existing one 52 51 */ 53 - static noinline int join_transaction(struct btrfs_root *root) 52 + static noinline int join_transaction(struct btrfs_root *root, int nofail) 54 53 { 55 54 struct btrfs_transaction *cur_trans; 55 + 56 + spin_lock(&root->fs_info->trans_lock); 57 + if (root->fs_info->trans_no_join) { 58 + if (!nofail) { 59 + spin_unlock(&root->fs_info->trans_lock); 60 + return -EBUSY; 61 + } 62 + } 63 + 56 64 cur_trans = root->fs_info->running_transaction; 57 - if (!cur_trans) { 58 - cur_trans = kmem_cache_alloc(btrfs_transaction_cachep, 59 - GFP_NOFS); 60 - if (!cur_trans) 61 - return -ENOMEM; 62 - root->fs_info->generation++; 63 - atomic_set(&cur_trans->num_writers, 1); 64 - cur_trans->num_joined = 0; 65 - cur_trans->transid = root->fs_info->generation; 66 - init_waitqueue_head(&cur_trans->writer_wait); 67 - init_waitqueue_head(&cur_trans->commit_wait); 68 - cur_trans->in_commit = 0; 69 - cur_trans->blocked = 0; 70 - atomic_set(&cur_trans->use_count, 1); 71 - cur_trans->commit_done = 0; 72 - cur_trans->start_time = get_seconds(); 73 - 74 - cur_trans->delayed_refs.root = RB_ROOT; 75 - cur_trans->delayed_refs.num_entries = 0; 76 - cur_trans->delayed_refs.num_heads_ready = 0; 77 - cur_trans->delayed_refs.num_heads = 0; 78 - cur_trans->delayed_refs.flushing = 0; 79 - cur_trans->delayed_refs.run_delayed_start = 0; 80 - spin_lock_init(&cur_trans->delayed_refs.lock); 81 - 82 - INIT_LIST_HEAD(&cur_trans->pending_snapshots); 83 - list_add_tail(&cur_trans->list, &root->fs_info->trans_list); 84 - extent_io_tree_init(&cur_trans->dirty_pages, 85 - root->fs_info->btree_inode->i_mapping); 86 - spin_lock(&root->fs_info->new_trans_lock); 87 - root->fs_info->running_transaction = cur_trans; 88 - spin_unlock(&root->fs_info->new_trans_lock); 89 - } else { 65 + if (cur_trans) { 66 + atomic_inc(&cur_trans->use_count); 90 67 atomic_inc(&cur_trans->num_writers); 91 68 cur_trans->num_joined++; 69 + spin_unlock(&root->fs_info->trans_lock); 70 + return 0; 92 71 } 72 + spin_unlock(&root->fs_info->trans_lock); 73 + 74 + cur_trans = kmem_cache_alloc(btrfs_transaction_cachep, GFP_NOFS); 75 + if (!cur_trans) 76 + return -ENOMEM; 77 + spin_lock(&root->fs_info->trans_lock); 78 + if (root->fs_info->running_transaction) { 79 + kmem_cache_free(btrfs_transaction_cachep, cur_trans); 80 + cur_trans = root->fs_info->running_transaction; 81 + atomic_inc(&cur_trans->use_count); 82 + atomic_inc(&cur_trans->num_writers); 83 + cur_trans->num_joined++; 84 + spin_unlock(&root->fs_info->trans_lock); 85 + return 0; 86 + } 87 + atomic_set(&cur_trans->num_writers, 1); 88 + cur_trans->num_joined = 0; 89 + init_waitqueue_head(&cur_trans->writer_wait); 90 + init_waitqueue_head(&cur_trans->commit_wait); 91 + cur_trans->in_commit = 0; 92 + cur_trans->blocked = 0; 93 + /* 94 + * One for this trans handle, one so it will live on until we 95 + * commit the transaction. 96 + */ 97 + atomic_set(&cur_trans->use_count, 2); 98 + cur_trans->commit_done = 0; 99 + cur_trans->start_time = get_seconds(); 100 + 101 + cur_trans->delayed_refs.root = RB_ROOT; 102 + cur_trans->delayed_refs.num_entries = 0; 103 + cur_trans->delayed_refs.num_heads_ready = 0; 104 + cur_trans->delayed_refs.num_heads = 0; 105 + cur_trans->delayed_refs.flushing = 0; 106 + cur_trans->delayed_refs.run_delayed_start = 0; 107 + spin_lock_init(&cur_trans->commit_lock); 108 + spin_lock_init(&cur_trans->delayed_refs.lock); 109 + 110 + INIT_LIST_HEAD(&cur_trans->pending_snapshots); 111 + list_add_tail(&cur_trans->list, &root->fs_info->trans_list); 112 + extent_io_tree_init(&cur_trans->dirty_pages, 113 + root->fs_info->btree_inode->i_mapping); 114 + root->fs_info->generation++; 115 + cur_trans->transid = root->fs_info->generation; 116 + root->fs_info->running_transaction = cur_trans; 117 + spin_unlock(&root->fs_info->trans_lock); 93 118 94 119 return 0; 95 120 } ··· 126 99 * to make sure the old root from before we joined the transaction is deleted 127 100 * when the transaction commits 128 101 */ 129 - static noinline int record_root_in_trans(struct btrfs_trans_handle *trans, 130 - struct btrfs_root *root) 102 + int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans, 103 + struct btrfs_root *root) 131 104 { 132 105 if (root->ref_cows && root->last_trans < trans->transid) { 133 106 WARN_ON(root == root->fs_info->extent_root); 134 107 WARN_ON(root->commit_root != root->node); 135 108 109 + spin_lock(&root->fs_info->fs_roots_radix_lock); 110 + if (root->last_trans == trans->transid) { 111 + spin_unlock(&root->fs_info->fs_roots_radix_lock); 112 + return 0; 113 + } 114 + root->last_trans = trans->transid; 136 115 radix_tree_tag_set(&root->fs_info->fs_roots_radix, 137 116 (unsigned long)root->root_key.objectid, 138 117 BTRFS_ROOT_TRANS_TAG); 139 - root->last_trans = trans->transid; 118 + spin_unlock(&root->fs_info->fs_roots_radix_lock); 140 119 btrfs_init_reloc_root(trans, root); 141 120 } 142 - return 0; 143 - } 144 - 145 - int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans, 146 - struct btrfs_root *root) 147 - { 148 - if (!root->ref_cows) 149 - return 0; 150 - 151 - mutex_lock(&root->fs_info->trans_mutex); 152 - if (root->last_trans == trans->transid) { 153 - mutex_unlock(&root->fs_info->trans_mutex); 154 - return 0; 155 - } 156 - 157 - record_root_in_trans(trans, root); 158 - mutex_unlock(&root->fs_info->trans_mutex); 159 121 return 0; 160 122 } 161 123 ··· 156 140 { 157 141 struct btrfs_transaction *cur_trans; 158 142 143 + spin_lock(&root->fs_info->trans_lock); 159 144 cur_trans = root->fs_info->running_transaction; 160 145 if (cur_trans && cur_trans->blocked) { 161 146 DEFINE_WAIT(wait); 162 147 atomic_inc(&cur_trans->use_count); 148 + spin_unlock(&root->fs_info->trans_lock); 163 149 while (1) { 164 150 prepare_to_wait(&root->fs_info->transaction_wait, &wait, 165 151 TASK_UNINTERRUPTIBLE); 166 152 if (!cur_trans->blocked) 167 153 break; 168 - mutex_unlock(&root->fs_info->trans_mutex); 169 154 schedule(); 170 - mutex_lock(&root->fs_info->trans_mutex); 171 155 } 172 156 finish_wait(&root->fs_info->transaction_wait, &wait); 173 157 put_transaction(cur_trans); 158 + } else { 159 + spin_unlock(&root->fs_info->trans_lock); 174 160 } 175 161 } 176 162 ··· 185 167 186 168 static int may_wait_transaction(struct btrfs_root *root, int type) 187 169 { 188 - if (!root->fs_info->log_root_recovering && 189 - ((type == TRANS_START && !root->fs_info->open_ioctl_trans) || 190 - type == TRANS_USERSPACE)) 170 + if (root->fs_info->log_root_recovering) 171 + return 0; 172 + 173 + if (type == TRANS_USERSPACE) 191 174 return 1; 175 + 176 + if (type == TRANS_START && 177 + !atomic_read(&root->fs_info->open_ioctl_trans)) 178 + return 1; 179 + 192 180 return 0; 193 181 } 194 182 ··· 208 184 209 185 if (root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) 210 186 return ERR_PTR(-EROFS); 187 + 188 + if (current->journal_info) { 189 + WARN_ON(type != TRANS_JOIN && type != TRANS_JOIN_NOLOCK); 190 + h = current->journal_info; 191 + h->use_count++; 192 + h->orig_rsv = h->block_rsv; 193 + h->block_rsv = NULL; 194 + goto got_it; 195 + } 211 196 again: 212 197 h = kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS); 213 198 if (!h) 214 199 return ERR_PTR(-ENOMEM); 215 200 216 - if (type != TRANS_JOIN_NOLOCK) 217 - mutex_lock(&root->fs_info->trans_mutex); 218 201 if (may_wait_transaction(root, type)) 219 202 wait_current_trans(root); 220 203 221 - ret = join_transaction(root); 204 + do { 205 + ret = join_transaction(root, type == TRANS_JOIN_NOLOCK); 206 + if (ret == -EBUSY) 207 + wait_current_trans(root); 208 + } while (ret == -EBUSY); 209 + 222 210 if (ret < 0) { 223 211 kmem_cache_free(btrfs_trans_handle_cachep, h); 224 - if (type != TRANS_JOIN_NOLOCK) 225 - mutex_unlock(&root->fs_info->trans_mutex); 226 212 return ERR_PTR(ret); 227 213 } 228 214 229 215 cur_trans = root->fs_info->running_transaction; 230 - atomic_inc(&cur_trans->use_count); 231 - if (type != TRANS_JOIN_NOLOCK) 232 - mutex_unlock(&root->fs_info->trans_mutex); 233 216 234 217 h->transid = cur_trans->transid; 235 218 h->transaction = cur_trans; 236 219 h->blocks_used = 0; 237 - h->block_group = 0; 238 220 h->bytes_reserved = 0; 239 221 h->delayed_ref_updates = 0; 222 + h->use_count = 1; 240 223 h->block_rsv = NULL; 224 + h->orig_rsv = NULL; 241 225 242 226 smp_mb(); 243 227 if (cur_trans->blocked && may_wait_transaction(root, type)) { ··· 273 241 } 274 242 } 275 243 276 - if (type != TRANS_JOIN_NOLOCK) 277 - mutex_lock(&root->fs_info->trans_mutex); 278 - record_root_in_trans(h, root); 279 - if (type != TRANS_JOIN_NOLOCK) 280 - mutex_unlock(&root->fs_info->trans_mutex); 244 + got_it: 245 + btrfs_record_root_in_trans(h, root); 281 246 282 247 if (!current->journal_info && type != TRANS_USERSPACE) 283 248 current->journal_info = h; ··· 286 257 { 287 258 return start_transaction(root, num_items, TRANS_START); 288 259 } 289 - struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root, 290 - int num_blocks) 260 + struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) 291 261 { 292 262 return start_transaction(root, 0, TRANS_JOIN); 293 263 } 294 264 295 - struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root, 296 - int num_blocks) 265 + struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root) 297 266 { 298 267 return start_transaction(root, 0, TRANS_JOIN_NOLOCK); 299 268 } 300 269 301 - struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *r, 302 - int num_blocks) 270 + struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root) 303 271 { 304 - return start_transaction(r, 0, TRANS_USERSPACE); 272 + return start_transaction(root, 0, TRANS_USERSPACE); 305 273 } 306 274 307 275 /* wait for a transaction commit to be fully complete */ ··· 306 280 struct btrfs_transaction *commit) 307 281 { 308 282 DEFINE_WAIT(wait); 309 - mutex_lock(&root->fs_info->trans_mutex); 310 283 while (!commit->commit_done) { 311 284 prepare_to_wait(&commit->commit_wait, &wait, 312 285 TASK_UNINTERRUPTIBLE); 313 286 if (commit->commit_done) 314 287 break; 315 - mutex_unlock(&root->fs_info->trans_mutex); 316 288 schedule(); 317 - mutex_lock(&root->fs_info->trans_mutex); 318 289 } 319 - mutex_unlock(&root->fs_info->trans_mutex); 320 290 finish_wait(&commit->commit_wait, &wait); 321 291 return 0; 322 292 } ··· 322 300 struct btrfs_transaction *cur_trans = NULL, *t; 323 301 int ret; 324 302 325 - mutex_lock(&root->fs_info->trans_mutex); 326 - 327 303 ret = 0; 328 304 if (transid) { 329 305 if (transid <= root->fs_info->last_trans_committed) 330 - goto out_unlock; 306 + goto out; 331 307 332 308 /* find specified transaction */ 309 + spin_lock(&root->fs_info->trans_lock); 333 310 list_for_each_entry(t, &root->fs_info->trans_list, list) { 334 311 if (t->transid == transid) { 335 312 cur_trans = t; 313 + atomic_inc(&cur_trans->use_count); 336 314 break; 337 315 } 338 316 if (t->transid > transid) 339 317 break; 340 318 } 319 + spin_unlock(&root->fs_info->trans_lock); 341 320 ret = -EINVAL; 342 321 if (!cur_trans) 343 - goto out_unlock; /* bad transid */ 322 + goto out; /* bad transid */ 344 323 } else { 345 324 /* find newest transaction that is committing | committed */ 325 + spin_lock(&root->fs_info->trans_lock); 346 326 list_for_each_entry_reverse(t, &root->fs_info->trans_list, 347 327 list) { 348 328 if (t->in_commit) { 349 329 if (t->commit_done) 350 - goto out_unlock; 330 + goto out; 351 331 cur_trans = t; 332 + atomic_inc(&cur_trans->use_count); 352 333 break; 353 334 } 354 335 } 336 + spin_unlock(&root->fs_info->trans_lock); 355 337 if (!cur_trans) 356 - goto out_unlock; /* nothing committing|committed */ 338 + goto out; /* nothing committing|committed */ 357 339 } 358 - 359 - atomic_inc(&cur_trans->use_count); 360 - mutex_unlock(&root->fs_info->trans_mutex); 361 340 362 341 wait_for_commit(root, cur_trans); 363 342 364 - mutex_lock(&root->fs_info->trans_mutex); 365 343 put_transaction(cur_trans); 366 344 ret = 0; 367 - out_unlock: 368 - mutex_unlock(&root->fs_info->trans_mutex); 345 + out: 369 346 return ret; 370 347 } 371 348 372 349 void btrfs_throttle(struct btrfs_root *root) 373 350 { 374 - mutex_lock(&root->fs_info->trans_mutex); 375 - if (!root->fs_info->open_ioctl_trans) 351 + if (!atomic_read(&root->fs_info->open_ioctl_trans)) 376 352 wait_current_trans(root); 377 - mutex_unlock(&root->fs_info->trans_mutex); 378 353 } 379 354 380 355 static int should_end_transaction(struct btrfs_trans_handle *trans, ··· 389 370 struct btrfs_transaction *cur_trans = trans->transaction; 390 371 int updates; 391 372 373 + smp_mb(); 392 374 if (cur_trans->blocked || cur_trans->delayed_refs.flushing) 393 375 return 1; 394 376 ··· 407 387 struct btrfs_transaction *cur_trans = trans->transaction; 408 388 struct btrfs_fs_info *info = root->fs_info; 409 389 int count = 0; 390 + 391 + if (--trans->use_count) { 392 + trans->block_rsv = trans->orig_rsv; 393 + return 0; 394 + } 410 395 411 396 while (count < 4) { 412 397 unsigned long cur = trans->delayed_ref_updates; ··· 435 410 436 411 btrfs_trans_release_metadata(trans, root); 437 412 438 - if (lock && !root->fs_info->open_ioctl_trans && 439 - should_end_transaction(trans, root)) 413 + if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) && 414 + should_end_transaction(trans, root)) { 440 415 trans->transaction->blocked = 1; 416 + smp_wmb(); 417 + } 441 418 442 419 if (lock && cur_trans->blocked && !cur_trans->in_commit) { 443 420 if (throttle) ··· 730 703 */ 731 704 int btrfs_add_dead_root(struct btrfs_root *root) 732 705 { 733 - mutex_lock(&root->fs_info->trans_mutex); 706 + spin_lock(&root->fs_info->trans_lock); 734 707 list_add(&root->root_list, &root->fs_info->dead_roots); 735 - mutex_unlock(&root->fs_info->trans_mutex); 708 + spin_unlock(&root->fs_info->trans_lock); 736 709 return 0; 737 710 } 738 711 ··· 748 721 int ret; 749 722 int err = 0; 750 723 724 + spin_lock(&fs_info->fs_roots_radix_lock); 751 725 while (1) { 752 726 ret = radix_tree_gang_lookup_tag(&fs_info->fs_roots_radix, 753 727 (void **)gang, 0, ··· 761 733 radix_tree_tag_clear(&fs_info->fs_roots_radix, 762 734 (unsigned long)root->root_key.objectid, 763 735 BTRFS_ROOT_TRANS_TAG); 736 + spin_unlock(&fs_info->fs_roots_radix_lock); 764 737 765 738 btrfs_free_log(trans, root); 766 739 btrfs_update_reloc_root(trans, root); ··· 782 753 err = btrfs_update_root(trans, fs_info->tree_root, 783 754 &root->root_key, 784 755 &root->root_item); 756 + spin_lock(&fs_info->fs_roots_radix_lock); 785 757 if (err) 786 758 break; 787 759 } 788 760 } 761 + spin_unlock(&fs_info->fs_roots_radix_lock); 789 762 return err; 790 763 } 791 764 ··· 817 786 btrfs_btree_balance_dirty(info->tree_root, nr); 818 787 cond_resched(); 819 788 820 - if (root->fs_info->closing || ret != -EAGAIN) 789 + if (btrfs_fs_closing(root->fs_info) || ret != -EAGAIN) 821 790 break; 822 791 } 823 792 root->defrag_running = 0; ··· 882 851 parent = dget_parent(dentry); 883 852 parent_inode = parent->d_inode; 884 853 parent_root = BTRFS_I(parent_inode)->root; 885 - record_root_in_trans(trans, parent_root); 854 + btrfs_record_root_in_trans(trans, parent_root); 886 855 887 856 /* 888 857 * insert the directory item ··· 900 869 ret = btrfs_update_inode(trans, parent_root, parent_inode); 901 870 BUG_ON(ret); 902 871 903 - record_root_in_trans(trans, root); 872 + btrfs_record_root_in_trans(trans, root); 904 873 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); 905 874 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); 906 875 btrfs_check_and_init_root_item(new_root_item); ··· 998 967 int btrfs_transaction_in_commit(struct btrfs_fs_info *info) 999 968 { 1000 969 int ret = 0; 1001 - spin_lock(&info->new_trans_lock); 970 + spin_lock(&info->trans_lock); 1002 971 if (info->running_transaction) 1003 972 ret = info->running_transaction->in_commit; 1004 - spin_unlock(&info->new_trans_lock); 973 + spin_unlock(&info->trans_lock); 1005 974 return ret; 1006 975 } 1007 976 1008 977 int btrfs_transaction_blocked(struct btrfs_fs_info *info) 1009 978 { 1010 979 int ret = 0; 1011 - spin_lock(&info->new_trans_lock); 980 + spin_lock(&info->trans_lock); 1012 981 if (info->running_transaction) 1013 982 ret = info->running_transaction->blocked; 1014 - spin_unlock(&info->new_trans_lock); 983 + spin_unlock(&info->trans_lock); 1015 984 return ret; 1016 985 } 1017 986 ··· 1035 1004 &wait); 1036 1005 break; 1037 1006 } 1038 - mutex_unlock(&root->fs_info->trans_mutex); 1039 1007 schedule(); 1040 - mutex_lock(&root->fs_info->trans_mutex); 1041 1008 finish_wait(&root->fs_info->transaction_blocked_wait, &wait); 1042 1009 } 1043 1010 } ··· 1061 1032 &wait); 1062 1033 break; 1063 1034 } 1064 - mutex_unlock(&root->fs_info->trans_mutex); 1065 1035 schedule(); 1066 - mutex_lock(&root->fs_info->trans_mutex); 1067 1036 finish_wait(&root->fs_info->transaction_wait, 1068 1037 &wait); 1069 1038 } ··· 1099 1072 1100 1073 INIT_DELAYED_WORK(&ac->work, do_async_commit); 1101 1074 ac->root = root; 1102 - ac->newtrans = btrfs_join_transaction(root, 0); 1075 + ac->newtrans = btrfs_join_transaction(root); 1103 1076 if (IS_ERR(ac->newtrans)) { 1104 1077 int err = PTR_ERR(ac->newtrans); 1105 1078 kfree(ac); ··· 1107 1080 } 1108 1081 1109 1082 /* take transaction reference */ 1110 - mutex_lock(&root->fs_info->trans_mutex); 1111 1083 cur_trans = trans->transaction; 1112 1084 atomic_inc(&cur_trans->use_count); 1113 - mutex_unlock(&root->fs_info->trans_mutex); 1114 1085 1115 1086 btrfs_end_transaction(trans, root); 1116 1087 schedule_delayed_work(&ac->work, 0); 1117 1088 1118 1089 /* wait for transaction to start and unblock */ 1119 - mutex_lock(&root->fs_info->trans_mutex); 1120 1090 if (wait_for_unblock) 1121 1091 wait_current_trans_commit_start_and_unblock(root, cur_trans); 1122 1092 else 1123 1093 wait_current_trans_commit_start(root, cur_trans); 1124 1094 put_transaction(cur_trans); 1125 - mutex_unlock(&root->fs_info->trans_mutex); 1126 1095 1127 1096 return 0; 1128 1097 } ··· 1162 1139 ret = btrfs_run_delayed_refs(trans, root, 0); 1163 1140 BUG_ON(ret); 1164 1141 1165 - mutex_lock(&root->fs_info->trans_mutex); 1142 + spin_lock(&cur_trans->commit_lock); 1166 1143 if (cur_trans->in_commit) { 1144 + spin_unlock(&cur_trans->commit_lock); 1167 1145 atomic_inc(&cur_trans->use_count); 1168 - mutex_unlock(&root->fs_info->trans_mutex); 1169 1146 btrfs_end_transaction(trans, root); 1170 1147 1171 1148 ret = wait_for_commit(root, cur_trans); 1172 1149 BUG_ON(ret); 1173 1150 1174 - mutex_lock(&root->fs_info->trans_mutex); 1175 1151 put_transaction(cur_trans); 1176 - mutex_unlock(&root->fs_info->trans_mutex); 1177 1152 1178 1153 return 0; 1179 1154 } 1180 1155 1181 1156 trans->transaction->in_commit = 1; 1182 1157 trans->transaction->blocked = 1; 1158 + spin_unlock(&cur_trans->commit_lock); 1183 1159 wake_up(&root->fs_info->transaction_blocked_wait); 1184 1160 1161 + spin_lock(&root->fs_info->trans_lock); 1185 1162 if (cur_trans->list.prev != &root->fs_info->trans_list) { 1186 1163 prev_trans = list_entry(cur_trans->list.prev, 1187 1164 struct btrfs_transaction, list); 1188 1165 if (!prev_trans->commit_done) { 1189 1166 atomic_inc(&prev_trans->use_count); 1190 - mutex_unlock(&root->fs_info->trans_mutex); 1167 + spin_unlock(&root->fs_info->trans_lock); 1191 1168 1192 1169 wait_for_commit(root, prev_trans); 1193 1170 1194 - mutex_lock(&root->fs_info->trans_mutex); 1195 1171 put_transaction(prev_trans); 1172 + } else { 1173 + spin_unlock(&root->fs_info->trans_lock); 1196 1174 } 1175 + } else { 1176 + spin_unlock(&root->fs_info->trans_lock); 1197 1177 } 1198 1178 1199 1179 if (now < cur_trans->start_time || now - cur_trans->start_time < 1) ··· 1204 1178 1205 1179 do { 1206 1180 int snap_pending = 0; 1181 + 1207 1182 joined = cur_trans->num_joined; 1208 1183 if (!list_empty(&trans->transaction->pending_snapshots)) 1209 1184 snap_pending = 1; 1210 1185 1211 1186 WARN_ON(cur_trans != trans->transaction); 1212 - mutex_unlock(&root->fs_info->trans_mutex); 1213 1187 1214 1188 if (flush_on_commit || snap_pending) { 1215 1189 btrfs_start_delalloc_inodes(root, 1); ··· 1232 1206 prepare_to_wait(&cur_trans->writer_wait, &wait, 1233 1207 TASK_UNINTERRUPTIBLE); 1234 1208 1235 - smp_mb(); 1236 1209 if (atomic_read(&cur_trans->num_writers) > 1) 1237 1210 schedule_timeout(MAX_SCHEDULE_TIMEOUT); 1238 1211 else if (should_grow) 1239 1212 schedule_timeout(1); 1240 1213 1241 - mutex_lock(&root->fs_info->trans_mutex); 1242 1214 finish_wait(&cur_trans->writer_wait, &wait); 1215 + spin_lock(&root->fs_info->trans_lock); 1216 + root->fs_info->trans_no_join = 1; 1217 + spin_unlock(&root->fs_info->trans_lock); 1243 1218 } while (atomic_read(&cur_trans->num_writers) > 1 || 1244 1219 (should_grow && cur_trans->num_joined != joined)); 1245 1220 ··· 1285 1258 btrfs_prepare_extent_commit(trans, root); 1286 1259 1287 1260 cur_trans = root->fs_info->running_transaction; 1288 - spin_lock(&root->fs_info->new_trans_lock); 1289 - root->fs_info->running_transaction = NULL; 1290 - spin_unlock(&root->fs_info->new_trans_lock); 1291 1261 1292 1262 btrfs_set_root_node(&root->fs_info->tree_root->root_item, 1293 1263 root->fs_info->tree_root->node); ··· 1305 1281 sizeof(root->fs_info->super_copy)); 1306 1282 1307 1283 trans->transaction->blocked = 0; 1284 + spin_lock(&root->fs_info->trans_lock); 1285 + root->fs_info->running_transaction = NULL; 1286 + root->fs_info->trans_no_join = 0; 1287 + spin_unlock(&root->fs_info->trans_lock); 1308 1288 1309 1289 wake_up(&root->fs_info->transaction_wait); 1310 1290 1311 - mutex_unlock(&root->fs_info->trans_mutex); 1312 1291 ret = btrfs_write_and_wait_transaction(trans, root); 1313 1292 BUG_ON(ret); 1314 1293 write_ctree_super(trans, root, 0); ··· 1324 1297 1325 1298 btrfs_finish_extent_commit(trans, root); 1326 1299 1327 - mutex_lock(&root->fs_info->trans_mutex); 1328 - 1329 1300 cur_trans->commit_done = 1; 1330 1301 1331 1302 root->fs_info->last_trans_committed = cur_trans->transid; 1332 1303 1333 1304 wake_up(&cur_trans->commit_wait); 1334 1305 1306 + spin_lock(&root->fs_info->trans_lock); 1335 1307 list_del_init(&cur_trans->list); 1308 + spin_unlock(&root->fs_info->trans_lock); 1309 + 1336 1310 put_transaction(cur_trans); 1337 1311 put_transaction(cur_trans); 1338 1312 1339 1313 trace_btrfs_transaction_commit(root); 1340 - 1341 - mutex_unlock(&root->fs_info->trans_mutex); 1342 1314 1343 1315 btrfs_scrub_continue(root); 1344 1316 ··· 1360 1334 LIST_HEAD(list); 1361 1335 struct btrfs_fs_info *fs_info = root->fs_info; 1362 1336 1363 - mutex_lock(&fs_info->trans_mutex); 1337 + spin_lock(&fs_info->trans_lock); 1364 1338 list_splice_init(&fs_info->dead_roots, &list); 1365 - mutex_unlock(&fs_info->trans_mutex); 1339 + spin_unlock(&fs_info->trans_lock); 1366 1340 1367 1341 while (!list_empty(&list)) { 1368 1342 root = list_entry(list.next, struct btrfs_root, root_list);
+8 -21
fs/btrfs/transaction.h
··· 28 28 * transaction can end 29 29 */ 30 30 atomic_t num_writers; 31 + atomic_t use_count; 31 32 32 33 unsigned long num_joined; 34 + 35 + spinlock_t commit_lock; 33 36 int in_commit; 34 - atomic_t use_count; 35 37 int commit_done; 36 38 int blocked; 37 39 struct list_head list; ··· 47 45 48 46 struct btrfs_trans_handle { 49 47 u64 transid; 50 - u64 block_group; 51 48 u64 bytes_reserved; 49 + unsigned long use_count; 52 50 unsigned long blocks_reserved; 53 51 unsigned long blocks_used; 54 52 unsigned long delayed_ref_updates; 55 53 struct btrfs_transaction *transaction; 56 54 struct btrfs_block_rsv *block_rsv; 55 + struct btrfs_block_rsv *orig_rsv; 57 56 }; 58 57 59 58 struct btrfs_pending_snapshot { ··· 69 66 struct list_head list; 70 67 }; 71 68 72 - static inline void btrfs_set_trans_block_group(struct btrfs_trans_handle *trans, 73 - struct inode *inode) 74 - { 75 - trans->block_group = BTRFS_I(inode)->block_group; 76 - } 77 - 78 - static inline void btrfs_update_inode_block_group( 79 - struct btrfs_trans_handle *trans, 80 - struct inode *inode) 81 - { 82 - BTRFS_I(inode)->block_group = trans->block_group; 83 - } 84 - 85 69 static inline void btrfs_set_inode_last_trans(struct btrfs_trans_handle *trans, 86 70 struct inode *inode) 87 71 { ··· 82 92 struct btrfs_root *root); 83 93 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, 84 94 int num_items); 85 - struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root, 86 - int num_blocks); 87 - struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root, 88 - int num_blocks); 89 - struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *r, 90 - int num_blocks); 95 + struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root); 96 + struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root); 97 + struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root); 91 98 int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid); 92 99 int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, 93 100 struct btrfs_root *root);
+1 -1
fs/btrfs/volumes.c
··· 504 504 BUG_ON(!new_device); 505 505 memcpy(new_device, device, sizeof(*new_device)); 506 506 new_device->name = kstrdup(device->name, GFP_NOFS); 507 - BUG_ON(!new_device->name); 507 + BUG_ON(device->name && !new_device->name); 508 508 new_device->bdev = NULL; 509 509 new_device->writeable = 0; 510 510 new_device->in_fs_metadata = 0;
-2
fs/btrfs/xattr.c
··· 158 158 if (IS_ERR(trans)) 159 159 return PTR_ERR(trans); 160 160 161 - btrfs_set_trans_block_group(trans, inode); 162 - 163 161 ret = do_setxattr(trans, inode, name, value, size, flags); 164 162 if (ret) 165 163 goto out;
+3
fs/namei.c
··· 2579 2579 if (error) 2580 2580 goto out; 2581 2581 2582 + shrink_dcache_parent(dentry); 2582 2583 error = dir->i_op->rmdir(dir, dentry); 2583 2584 if (error) 2584 2585 goto out; ··· 2994 2993 if (d_mountpoint(old_dentry) || d_mountpoint(new_dentry)) 2995 2994 goto out; 2996 2995 2996 + if (target) 2997 + shrink_dcache_parent(new_dentry); 2997 2998 error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); 2998 2999 if (error) 2999 3000 goto out;
+3 -7
fs/partitions/check.c
··· 255 255 struct device_attribute *attr, char *buf) 256 256 { 257 257 struct hd_struct *p = dev_to_part(dev); 258 - struct gendisk *disk = dev_to_disk(dev); 259 - unsigned int alignment = 0; 260 - 261 - if (disk->queue) 262 - alignment = queue_limit_discard_alignment(&disk->queue->limits, 263 - p->start_sect); 264 - return sprintf(buf, "%u\n", alignment); 258 + return sprintf(buf, "%u\n", p->discard_alignment); 265 259 } 266 260 267 261 ssize_t part_stat_show(struct device *dev, ··· 449 455 p->start_sect = start; 450 456 p->alignment_offset = 451 457 queue_limit_alignment_offset(&disk->queue->limits, start); 458 + p->discard_alignment = 459 + queue_limit_discard_alignment(&disk->queue->limits, start); 452 460 p->nr_sects = len; 453 461 p->partno = partno; 454 462 p->policy = get_disk_ro(disk);
+2
fs/ubifs/io.c
··· 581 581 ubifs_assert(wbuf->size % c->min_io_size == 0); 582 582 ubifs_assert(mutex_is_locked(&wbuf->io_mutex)); 583 583 ubifs_assert(!c->ro_media && !c->ro_mount); 584 + ubifs_assert(!c->space_fixup); 584 585 if (c->leb_size - wbuf->offs >= c->max_write_size) 585 586 ubifs_assert(!((wbuf->offs + wbuf->size) % c->max_write_size)); 586 587 ··· 760 759 ubifs_assert(lnum >= 0 && lnum < c->leb_cnt && offs >= 0); 761 760 ubifs_assert(offs % c->min_io_size == 0 && offs < c->leb_size); 762 761 ubifs_assert(!c->ro_media && !c->ro_mount); 762 + ubifs_assert(!c->space_fixup); 763 763 764 764 if (c->ro_error) 765 765 return -EROFS;
+1
fs/ubifs/journal.c
··· 669 669 670 670 out_release: 671 671 release_head(c, BASEHD); 672 + kfree(dent); 672 673 out_ro: 673 674 ubifs_ro_mode(c, err); 674 675 if (last_reference)
+1 -1
fs/ubifs/orphan.c
··· 674 674 if (IS_ERR(sleb)) { 675 675 if (PTR_ERR(sleb) == -EUCLEAN) 676 676 sleb = ubifs_recover_leb(c, lnum, 0, 677 - c->sbuf, 0); 677 + c->sbuf, -1); 678 678 if (IS_ERR(sleb)) { 679 679 err = PTR_ERR(sleb); 680 680 break;
+94 -70
fs/ubifs/recovery.c
··· 564 564 } 565 565 566 566 /** 567 - * drop_last_node - drop the last node or group of nodes. 567 + * drop_last_group - drop the last group of nodes. 568 568 * @sleb: scanned LEB information 569 569 * @offs: offset of dropped nodes is returned here 570 - * @grouped: non-zero if whole group of nodes have to be dropped 571 570 * 572 571 * This is a helper function for 'ubifs_recover_leb()' which drops the last 573 - * node of the scanned LEB or the last group of nodes if @grouped is not zero. 574 - * This function returns %1 if a node was dropped and %0 otherwise. 572 + * group of nodes of the scanned LEB. 575 573 */ 576 - static int drop_last_node(struct ubifs_scan_leb *sleb, int *offs, int grouped) 574 + static void drop_last_group(struct ubifs_scan_leb *sleb, int *offs) 577 575 { 578 - int dropped = 0; 579 - 580 576 while (!list_empty(&sleb->nodes)) { 581 577 struct ubifs_scan_node *snod; 582 578 struct ubifs_ch *ch; ··· 581 585 list); 582 586 ch = snod->node; 583 587 if (ch->group_type != UBIFS_IN_NODE_GROUP) 584 - return dropped; 585 - dbg_rcvry("dropping node at %d:%d", sleb->lnum, snod->offs); 588 + break; 589 + 590 + dbg_rcvry("dropping grouped node at %d:%d", 591 + sleb->lnum, snod->offs); 586 592 *offs = snod->offs; 587 593 list_del(&snod->list); 588 594 kfree(snod); 589 595 sleb->nodes_cnt -= 1; 590 - dropped = 1; 591 - if (!grouped) 592 - break; 593 596 } 594 - return dropped; 597 + } 598 + 599 + /** 600 + * drop_last_node - drop the last node. 601 + * @sleb: scanned LEB information 602 + * @offs: offset of dropped nodes is returned here 603 + * @grouped: non-zero if whole group of nodes have to be dropped 604 + * 605 + * This is a helper function for 'ubifs_recover_leb()' which drops the last 606 + * node of the scanned LEB. 607 + */ 608 + static void drop_last_node(struct ubifs_scan_leb *sleb, int *offs) 609 + { 610 + struct ubifs_scan_node *snod; 611 + 612 + if (!list_empty(&sleb->nodes)) { 613 + snod = list_entry(sleb->nodes.prev, struct ubifs_scan_node, 614 + list); 615 + 616 + dbg_rcvry("dropping last node at %d:%d", sleb->lnum, snod->offs); 617 + *offs = snod->offs; 618 + list_del(&snod->list); 619 + kfree(snod); 620 + sleb->nodes_cnt -= 1; 621 + } 595 622 } 596 623 597 624 /** ··· 623 604 * @lnum: LEB number 624 605 * @offs: offset 625 606 * @sbuf: LEB-sized buffer to use 626 - * @grouped: nodes may be grouped for recovery 607 + * @jhead: journal head number this LEB belongs to (%-1 if the LEB does not 608 + * belong to any journal head) 627 609 * 628 610 * This function does a scan of a LEB, but caters for errors that might have 629 611 * been caused by the unclean unmount from which we are attempting to recover. ··· 632 612 * found, and a negative error code in case of failure. 633 613 */ 634 614 struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, 635 - int offs, void *sbuf, int grouped) 615 + int offs, void *sbuf, int jhead) 636 616 { 637 617 int ret = 0, err, len = c->leb_size - offs, start = offs, min_io_unit; 618 + int grouped = jhead == -1 ? 0 : c->jheads[jhead].grouped; 638 619 struct ubifs_scan_leb *sleb; 639 620 void *buf = sbuf + offs; 640 621 641 - dbg_rcvry("%d:%d", lnum, offs); 622 + dbg_rcvry("%d:%d, jhead %d, grouped %d", lnum, offs, jhead, grouped); 642 623 643 624 sleb = ubifs_start_scan(c, lnum, offs, sbuf); 644 625 if (IS_ERR(sleb)) ··· 656 635 * Scan quietly until there is an error from which we cannot 657 636 * recover 658 637 */ 659 - ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 0); 638 + ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1); 660 639 if (ret == SCANNED_A_NODE) { 661 640 /* A valid node, and not a padding node */ 662 641 struct ubifs_ch *ch = buf; ··· 716 695 * If nodes are grouped, always drop the incomplete group at 717 696 * the end. 718 697 */ 719 - drop_last_node(sleb, &offs, 1); 698 + drop_last_group(sleb, &offs); 720 699 721 - /* 722 - * While we are in the middle of the same min. I/O unit keep dropping 723 - * nodes. So basically, what we want is to make sure that the last min. 724 - * I/O unit where we saw the corruption is dropped completely with all 725 - * the uncorrupted node which may possibly sit there. 726 - * 727 - * In other words, let's name the min. I/O unit where the corruption 728 - * starts B, and the previous min. I/O unit A. The below code tries to 729 - * deal with a situation when half of B contains valid nodes or the end 730 - * of a valid node, and the second half of B contains corrupted data or 731 - * garbage. This means that UBIFS had been writing to B just before the 732 - * power cut happened. I do not know how realistic is this scenario 733 - * that half of the min. I/O unit had been written successfully and the 734 - * other half not, but this is possible in our 'failure mode emulation' 735 - * infrastructure at least. 736 - * 737 - * So what is the problem, why we need to drop those nodes? Whey can't 738 - * we just clean-up the second half of B by putting a padding node 739 - * there? We can, and this works fine with one exception which was 740 - * reproduced with power cut emulation testing and happens extremely 741 - * rarely. The description follows, but it is worth noting that that is 742 - * only about the GC head, so we could do this trick only if the bud 743 - * belongs to the GC head, but it does not seem to be worth an 744 - * additional "if" statement. 745 - * 746 - * So, imagine the file-system is full, we run GC which is moving valid 747 - * nodes from LEB X to LEB Y (obviously, LEB Y is the current GC head 748 - * LEB). The @c->gc_lnum is -1, which means that GC will retain LEB X 749 - * and will try to continue. Imagine that LEB X is currently the 750 - * dirtiest LEB, and the amount of used space in LEB Y is exactly the 751 - * same as amount of free space in LEB X. 752 - * 753 - * And a power cut happens when nodes are moved from LEB X to LEB Y. We 754 - * are here trying to recover LEB Y which is the GC head LEB. We find 755 - * the min. I/O unit B as described above. Then we clean-up LEB Y by 756 - * padding min. I/O unit. And later 'ubifs_rcvry_gc_commit()' function 757 - * fails, because it cannot find a dirty LEB which could be GC'd into 758 - * LEB Y! Even LEB X does not match because the amount of valid nodes 759 - * there does not fit the free space in LEB Y any more! And this is 760 - * because of the padding node which we added to LEB Y. The 761 - * user-visible effect of this which I once observed and analysed is 762 - * that we cannot mount the file-system with -ENOSPC error. 763 - * 764 - * So obviously, to make sure that situation does not happen we should 765 - * free min. I/O unit B in LEB Y completely and the last used min. I/O 766 - * unit in LEB Y should be A. This is basically what the below code 767 - * tries to do. 768 - */ 769 - while (min_io_unit == round_down(offs, c->min_io_size) && 770 - min_io_unit != offs && 771 - drop_last_node(sleb, &offs, grouped)); 700 + if (jhead == GCHD) { 701 + /* 702 + * If this LEB belongs to the GC head then while we are in the 703 + * middle of the same min. I/O unit keep dropping nodes. So 704 + * basically, what we want is to make sure that the last min. 705 + * I/O unit where we saw the corruption is dropped completely 706 + * with all the uncorrupted nodes which may possibly sit there. 707 + * 708 + * In other words, let's name the min. I/O unit where the 709 + * corruption starts B, and the previous min. I/O unit A. The 710 + * below code tries to deal with a situation when half of B 711 + * contains valid nodes or the end of a valid node, and the 712 + * second half of B contains corrupted data or garbage. This 713 + * means that UBIFS had been writing to B just before the power 714 + * cut happened. I do not know how realistic is this scenario 715 + * that half of the min. I/O unit had been written successfully 716 + * and the other half not, but this is possible in our 'failure 717 + * mode emulation' infrastructure at least. 718 + * 719 + * So what is the problem, why we need to drop those nodes? Why 720 + * can't we just clean-up the second half of B by putting a 721 + * padding node there? We can, and this works fine with one 722 + * exception which was reproduced with power cut emulation 723 + * testing and happens extremely rarely. 724 + * 725 + * Imagine the file-system is full, we run GC which starts 726 + * moving valid nodes from LEB X to LEB Y (obviously, LEB Y is 727 + * the current GC head LEB). The @c->gc_lnum is -1, which means 728 + * that GC will retain LEB X and will try to continue. Imagine 729 + * that LEB X is currently the dirtiest LEB, and the amount of 730 + * used space in LEB Y is exactly the same as amount of free 731 + * space in LEB X. 732 + * 733 + * And a power cut happens when nodes are moved from LEB X to 734 + * LEB Y. We are here trying to recover LEB Y which is the GC 735 + * head LEB. We find the min. I/O unit B as described above. 736 + * Then we clean-up LEB Y by padding min. I/O unit. And later 737 + * 'ubifs_rcvry_gc_commit()' function fails, because it cannot 738 + * find a dirty LEB which could be GC'd into LEB Y! Even LEB X 739 + * does not match because the amount of valid nodes there does 740 + * not fit the free space in LEB Y any more! And this is 741 + * because of the padding node which we added to LEB Y. The 742 + * user-visible effect of this which I once observed and 743 + * analysed is that we cannot mount the file-system with 744 + * -ENOSPC error. 745 + * 746 + * So obviously, to make sure that situation does not happen we 747 + * should free min. I/O unit B in LEB Y completely and the last 748 + * used min. I/O unit in LEB Y should be A. This is basically 749 + * what the below code tries to do. 750 + */ 751 + while (offs > min_io_unit) 752 + drop_last_node(sleb, &offs); 753 + } 772 754 773 755 buf = sbuf + offs; 774 756 len = c->leb_size - offs; ··· 905 881 } 906 882 ubifs_scan_destroy(sleb); 907 883 } 908 - return ubifs_recover_leb(c, lnum, offs, sbuf, 0); 884 + return ubifs_recover_leb(c, lnum, offs, sbuf, -1); 909 885 } 910 886 911 887 /**
+1 -2
fs/ubifs/replay.c
··· 557 557 * these LEBs could possibly be written to at the power cut 558 558 * time. 559 559 */ 560 - sleb = ubifs_recover_leb(c, lnum, offs, c->sbuf, 561 - b->bud->jhead != GCHD); 560 + sleb = ubifs_recover_leb(c, lnum, offs, c->sbuf, b->bud->jhead); 562 561 else 563 562 sleb = ubifs_scan(c, lnum, offs, c->sbuf, 0); 564 563 if (IS_ERR(sleb))
+5 -1
fs/ubifs/shrinker.c
··· 284 284 long clean_zn_cnt = atomic_long_read(&ubifs_clean_zn_cnt); 285 285 286 286 if (nr == 0) 287 - return clean_zn_cnt; 287 + /* 288 + * Due to the way UBIFS updates the clean znode counter it may 289 + * temporarily be negative. 290 + */ 291 + return clean_zn_cnt >= 0 ? clean_zn_cnt : 1; 288 292 289 293 if (!clean_zn_cnt) { 290 294 /*
+24 -18
fs/ubifs/super.c
··· 811 811 812 812 c->jheads[i].wbuf.sync_callback = &bud_wbuf_callback; 813 813 c->jheads[i].wbuf.jhead = i; 814 + c->jheads[i].grouped = 1; 814 815 } 815 816 816 817 c->jheads[BASEHD].wbuf.dtype = UBI_SHORTTERM; 817 818 /* 818 819 * Garbage Collector head likely contains long-term data and 819 - * does not need to be synchronized by timer. 820 + * does not need to be synchronized by timer. Also GC head nodes are 821 + * not grouped. 820 822 */ 821 823 c->jheads[GCHD].wbuf.dtype = UBI_LONGTERM; 822 824 c->jheads[GCHD].wbuf.no_timer = 1; 825 + c->jheads[GCHD].grouped = 0; 823 826 824 827 return 0; 825 828 } ··· 1287 1284 if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) { 1288 1285 ubifs_msg("recovery needed"); 1289 1286 c->need_recovery = 1; 1290 - if (!c->ro_mount) { 1291 - err = ubifs_recover_inl_heads(c, c->sbuf); 1292 - if (err) 1293 - goto out_master; 1294 - } 1295 - } else if (!c->ro_mount) { 1287 + } 1288 + 1289 + if (c->need_recovery && !c->ro_mount) { 1290 + err = ubifs_recover_inl_heads(c, c->sbuf); 1291 + if (err) 1292 + goto out_master; 1293 + } 1294 + 1295 + err = ubifs_lpt_init(c, 1, !c->ro_mount); 1296 + if (err) 1297 + goto out_master; 1298 + 1299 + if (!c->ro_mount && c->space_fixup) { 1300 + err = ubifs_fixup_free_space(c); 1301 + if (err) 1302 + goto out_master; 1303 + } 1304 + 1305 + if (!c->ro_mount) { 1296 1306 /* 1297 1307 * Set the "dirty" flag so that if we reboot uncleanly we 1298 1308 * will notice this immediately on the next mount. ··· 1313 1297 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_DIRTY); 1314 1298 err = ubifs_write_master(c); 1315 1299 if (err) 1316 - goto out_master; 1300 + goto out_lpt; 1317 1301 } 1318 - 1319 - err = ubifs_lpt_init(c, 1, !c->ro_mount); 1320 - if (err) 1321 - goto out_lpt; 1322 1302 1323 1303 err = dbg_check_idx_size(c, c->bi.old_idx_sz); 1324 1304 if (err) ··· 1407 1395 } 1408 1396 } else 1409 1397 ubifs_assert(c->lst.taken_empty_lebs > 0); 1410 - 1411 - if (!c->ro_mount && c->space_fixup) { 1412 - err = ubifs_fixup_free_space(c); 1413 - if (err) 1414 - goto out_infos; 1415 - } 1416 1398 1417 1399 err = dbg_check_filesystem(c); 1418 1400 if (err)
+5 -4
fs/ubifs/tnc.c
··· 2876 2876 */ 2877 2877 void ubifs_tnc_close(struct ubifs_info *c) 2878 2878 { 2879 - long clean_freed; 2880 - 2881 2879 tnc_destroy_cnext(c); 2882 2880 if (c->zroot.znode) { 2883 - clean_freed = ubifs_destroy_tnc_subtree(c->zroot.znode); 2884 - atomic_long_sub(clean_freed, &ubifs_clean_zn_cnt); 2881 + long n; 2882 + 2883 + ubifs_destroy_tnc_subtree(c->zroot.znode); 2884 + n = atomic_long_read(&c->clean_zn_cnt); 2885 + atomic_long_sub(n, &ubifs_clean_zn_cnt); 2885 2886 } 2886 2887 kfree(c->gap_lebs); 2887 2888 kfree(c->ilebs);
+3 -1
fs/ubifs/ubifs.h
··· 722 722 * struct ubifs_jhead - journal head. 723 723 * @wbuf: head's write-buffer 724 724 * @buds_list: list of bud LEBs belonging to this journal head 725 + * @grouped: non-zero if UBIFS groups nodes when writing to this journal head 725 726 * 726 727 * Note, the @buds list is protected by the @c->buds_lock. 727 728 */ 728 729 struct ubifs_jhead { 729 730 struct ubifs_wbuf wbuf; 730 731 struct list_head buds_list; 732 + unsigned int grouped:1; 731 733 }; 732 734 733 735 /** ··· 1744 1742 int ubifs_recover_master_node(struct ubifs_info *c); 1745 1743 int ubifs_write_rcvrd_mst_node(struct ubifs_info *c); 1746 1744 struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, 1747 - int offs, void *sbuf, int grouped); 1745 + int offs, void *sbuf, int jhead); 1748 1746 struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum, 1749 1747 int offs, void *sbuf); 1750 1748 int ubifs_recover_inl_heads(const struct ubifs_info *c, void *sbuf);
+3 -1
include/asm-generic/unistd.h
··· 683 683 __SYSCALL(__NR_syncfs, sys_syncfs) 684 684 #define __NR_setns 268 685 685 __SYSCALL(__NR_setns, sys_setns) 686 + #define __NR_sendmmsg 269 687 + __SC_COMP(__NR_sendmmsg, sys_sendmmsg, compat_sys_sendmmsg) 686 688 687 689 #undef __NR_syscalls 688 - #define __NR_syscalls 269 690 + #define __NR_syscalls 270 689 691 690 692 /* 691 693 * All syscalls below here should go away really,
+2 -2
include/linux/blkdev.h
··· 1282 1282 #define blk_get_integrity(a) (0) 1283 1283 #define blk_integrity_compare(a, b) (0) 1284 1284 #define blk_integrity_register(a, b) (0) 1285 - #define blk_integrity_unregister(a) do { } while (0); 1286 - #define blk_queue_max_integrity_segments(a, b) do { } while (0); 1285 + #define blk_integrity_unregister(a) do { } while (0) 1286 + #define blk_queue_max_integrity_segments(a, b) do { } while (0) 1287 1287 #define queue_max_integrity_segments(a) (0) 1288 1288 #define blk_integrity_merge_rq(a, b, c) (0) 1289 1289 #define blk_integrity_merge_bio(a, b, c) (0)
+4
include/linux/dma_remapping.h
··· 9 9 #define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT) 10 10 #define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK) 11 11 12 + #define VTD_STRIDE_SHIFT (9) 13 + #define VTD_STRIDE_MASK (((u64)-1) << VTD_STRIDE_SHIFT) 14 + 12 15 #define DMA_PTE_READ (1) 13 16 #define DMA_PTE_WRITE (2) 17 + #define DMA_PTE_LARGE_PAGE (1 << 7) 14 18 #define DMA_PTE_SNP (1 << 11) 15 19 16 20 #define CONTEXT_TT_MULTI_LEVEL 0
+1
include/linux/genhd.h
··· 100 100 sector_t start_sect; 101 101 sector_t nr_sects; 102 102 sector_t alignment_offset; 103 + unsigned int discard_alignment; 103 104 struct device __dev; 104 105 struct kobject *holder_dir; 105 106 int policy, partno;
+6 -2
include/linux/ieee80211.h
··· 1003 1003 #define WLAN_CAPABILITY_ESS (1<<0) 1004 1004 #define WLAN_CAPABILITY_IBSS (1<<1) 1005 1005 1006 - /* A mesh STA sets the ESS and IBSS capability bits to zero */ 1007 - #define WLAN_CAPABILITY_IS_MBSS(cap) \ 1006 + /* 1007 + * A mesh STA sets the ESS and IBSS capability bits to zero. 1008 + * however, this holds true for p2p probe responses (in the p2p_find 1009 + * phase) as well. 1010 + */ 1011 + #define WLAN_CAPABILITY_IS_STA_BSS(cap) \ 1008 1012 (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS))) 1009 1013 1010 1014 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
+1
include/linux/if_packet.h
··· 70 70 #define TP_STATUS_COPY 0x2 71 71 #define TP_STATUS_LOSING 0x4 72 72 #define TP_STATUS_CSUMNOTREADY 0x8 73 + #define TP_STATUS_VLAN_VALID 0x10 /* auxdata has valid tp_vlan_tci */ 73 74 74 75 /* Tx ring - header status */ 75 76 #define TP_STATUS_AVAILABLE 0x0
+1
include/linux/mtd/physmap.h
··· 19 19 #include <linux/mtd/partitions.h> 20 20 21 21 struct map_info; 22 + struct platform_device; 22 23 23 24 struct physmap_flash_data { 24 25 unsigned int width;
+4 -5
include/linux/tty_ldisc.h
··· 76 76 * tty device. It is solely the responsibility of the line 77 77 * discipline to handle poll requests. 78 78 * 79 - * unsigned int (*receive_buf)(struct tty_struct *, const unsigned char *cp, 79 + * void (*receive_buf)(struct tty_struct *, const unsigned char *cp, 80 80 * char *fp, int count); 81 81 * 82 82 * This function is called by the low-level tty driver to send ··· 84 84 * processing. <cp> is a pointer to the buffer of input 85 85 * character received by the device. <fp> is a pointer to a 86 86 * pointer of flag bytes which indicate whether a character was 87 - * received with a parity error, etc. Returns the amount of bytes 88 - * received. 87 + * received with a parity error, etc. 89 88 * 90 89 * void (*write_wakeup)(struct tty_struct *); 91 90 * ··· 140 141 /* 141 142 * The following routines are called from below. 142 143 */ 143 - unsigned int (*receive_buf)(struct tty_struct *, 144 - const unsigned char *cp, char *fp, int count); 144 + void (*receive_buf)(struct tty_struct *, const unsigned char *cp, 145 + char *fp, int count); 145 146 void (*write_wakeup)(struct tty_struct *); 146 147 void (*dcd_change)(struct tty_struct *, unsigned int, 147 148 struct pps_event_time *);
+9
include/linux/virtio.h
··· 51 51 * This re-enables callbacks; it returns "false" if there are pending 52 52 * buffers in the queue, to detect a possible race between the driver 53 53 * checking for more work, and enabling callbacks. 54 + * virtqueue_enable_cb_delayed: restart callbacks after disable_cb. 55 + * vq: the struct virtqueue we're talking about. 56 + * This re-enables callbacks but hints to the other side to delay 57 + * interrupts until most of the available buffers have been processed; 58 + * it returns "false" if there are many pending buffers in the queue, 59 + * to detect a possible race between the driver checking for more work, 60 + * and enabling callbacks. 54 61 * virtqueue_detach_unused_buf: detach first unused buffer 55 62 * vq: the struct virtqueue we're talking about. 56 63 * Returns NULL or the "data" token handed to add_buf ··· 92 85 void virtqueue_disable_cb(struct virtqueue *vq); 93 86 94 87 bool virtqueue_enable_cb(struct virtqueue *vq); 88 + 89 + bool virtqueue_enable_cb_delayed(struct virtqueue *vq); 95 90 96 91 void *virtqueue_detach_unused_buf(struct virtqueue *vq); 97 92
+24 -1
include/linux/virtio_9p.h
··· 1 1 #ifndef _LINUX_VIRTIO_9P_H 2 2 #define _LINUX_VIRTIO_9P_H 3 3 /* This header is BSD licensed so anyone can use the definitions to implement 4 - * compatible drivers/servers. */ 4 + * compatible drivers/servers. 5 + * 6 + * Redistribution and use in source and binary forms, with or without 7 + * modification, are permitted provided that the following conditions 8 + * are met: 9 + * 1. Redistributions of source code must retain the above copyright 10 + * notice, this list of conditions and the following disclaimer. 11 + * 2. Redistributions in binary form must reproduce the above copyright 12 + * notice, this list of conditions and the following disclaimer in the 13 + * documentation and/or other materials provided with the distribution. 14 + * 3. Neither the name of IBM nor the names of its contributors 15 + * may be used to endorse or promote products derived from this software 16 + * without specific prior written permission. 17 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 + * SUCH DAMAGE. */ 5 28 #include <linux/types.h> 6 29 #include <linux/virtio_ids.h> 7 30 #include <linux/virtio_config.h>
+24 -1
include/linux/virtio_balloon.h
··· 1 1 #ifndef _LINUX_VIRTIO_BALLOON_H 2 2 #define _LINUX_VIRTIO_BALLOON_H 3 3 /* This header is BSD licensed so anyone can use the definitions to implement 4 - * compatible drivers/servers. */ 4 + * compatible drivers/servers. 5 + * 6 + * Redistribution and use in source and binary forms, with or without 7 + * modification, are permitted provided that the following conditions 8 + * are met: 9 + * 1. Redistributions of source code must retain the above copyright 10 + * notice, this list of conditions and the following disclaimer. 11 + * 2. Redistributions in binary form must reproduce the above copyright 12 + * notice, this list of conditions and the following disclaimer in the 13 + * documentation and/or other materials provided with the distribution. 14 + * 3. Neither the name of IBM nor the names of its contributors 15 + * may be used to endorse or promote products derived from this software 16 + * without specific prior written permission. 17 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 + * SUCH DAMAGE. */ 5 28 #include <linux/virtio_ids.h> 6 29 #include <linux/virtio_config.h> 7 30
+24 -1
include/linux/virtio_blk.h
··· 1 1 #ifndef _LINUX_VIRTIO_BLK_H 2 2 #define _LINUX_VIRTIO_BLK_H 3 3 /* This header is BSD licensed so anyone can use the definitions to implement 4 - * compatible drivers/servers. */ 4 + * compatible drivers/servers. 5 + * 6 + * Redistribution and use in source and binary forms, with or without 7 + * modification, are permitted provided that the following conditions 8 + * are met: 9 + * 1. Redistributions of source code must retain the above copyright 10 + * notice, this list of conditions and the following disclaimer. 11 + * 2. Redistributions in binary form must reproduce the above copyright 12 + * notice, this list of conditions and the following disclaimer in the 13 + * documentation and/or other materials provided with the distribution. 14 + * 3. Neither the name of IBM nor the names of its contributors 15 + * may be used to endorse or promote products derived from this software 16 + * without specific prior written permission. 17 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 + * SUCH DAMAGE. */ 5 28 #include <linux/types.h> 6 29 #include <linux/virtio_ids.h> 7 30 #include <linux/virtio_config.h>
+24 -1
include/linux/virtio_config.h
··· 1 1 #ifndef _LINUX_VIRTIO_CONFIG_H 2 2 #define _LINUX_VIRTIO_CONFIG_H 3 3 /* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so 4 - * anyone can use the definitions to implement compatible drivers/servers. */ 4 + * anyone can use the definitions to implement compatible drivers/servers. 5 + * 6 + * Redistribution and use in source and binary forms, with or without 7 + * modification, are permitted provided that the following conditions 8 + * are met: 9 + * 1. Redistributions of source code must retain the above copyright 10 + * notice, this list of conditions and the following disclaimer. 11 + * 2. Redistributions in binary form must reproduce the above copyright 12 + * notice, this list of conditions and the following disclaimer in the 13 + * documentation and/or other materials provided with the distribution. 14 + * 3. Neither the name of IBM nor the names of its contributors 15 + * may be used to endorse or promote products derived from this software 16 + * without specific prior written permission. 17 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 + * SUCH DAMAGE. */ 5 28 6 29 /* Virtio devices use a standardized configuration space to define their 7 30 * features and pass configuration information, but each implementation can
+25 -1
include/linux/virtio_console.h
··· 5 5 #include <linux/virtio_config.h> 6 6 /* 7 7 * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so 8 - * anyone can use the definitions to implement compatible drivers/servers. 8 + * anyone can use the definitions to implement compatible drivers/servers: 9 + * 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 1. Redistributions of source code must retain the above copyright 15 + * notice, this list of conditions and the following disclaimer. 16 + * 2. Redistributions in binary form must reproduce the above copyright 17 + * notice, this list of conditions and the following disclaimer in the 18 + * documentation and/or other materials provided with the distribution. 19 + * 3. Neither the name of IBM nor the names of its contributors 20 + * may be used to endorse or promote products derived from this software 21 + * without specific prior written permission. 22 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 23 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 + * SUCH DAMAGE. 9 33 * 10 34 * Copyright (C) Red Hat, Inc., 2009, 2010, 2011 11 35 * Copyright (C) Amit Shah <amit.shah@redhat.com>, 2009, 2010, 2011
+23 -1
include/linux/virtio_ids.h
··· 5 5 * 6 6 * This header is BSD licensed so anyone can use the definitions to implement 7 7 * compatible drivers/servers. 8 - */ 8 + * 9 + * Redistribution and use in source and binary forms, with or without 10 + * modification, are permitted provided that the following conditions 11 + * are met: 12 + * 1. Redistributions of source code must retain the above copyright 13 + * notice, this list of conditions and the following disclaimer. 14 + * 2. Redistributions in binary form must reproduce the above copyright 15 + * notice, this list of conditions and the following disclaimer in the 16 + * documentation and/or other materials provided with the distribution. 17 + * 3. Neither the name of IBM nor the names of its contributors 18 + * may be used to endorse or promote products derived from this software 19 + * without specific prior written permission. 20 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 21 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 24 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 + * SUCH DAMAGE. */ 9 31 10 32 #define VIRTIO_ID_NET 1 /* virtio net */ 11 33 #define VIRTIO_ID_BLOCK 2 /* virtio block */
+24 -1
include/linux/virtio_net.h
··· 1 1 #ifndef _LINUX_VIRTIO_NET_H 2 2 #define _LINUX_VIRTIO_NET_H 3 3 /* This header is BSD licensed so anyone can use the definitions to implement 4 - * compatible drivers/servers. */ 4 + * compatible drivers/servers. 5 + * 6 + * Redistribution and use in source and binary forms, with or without 7 + * modification, are permitted provided that the following conditions 8 + * are met: 9 + * 1. Redistributions of source code must retain the above copyright 10 + * notice, this list of conditions and the following disclaimer. 11 + * 2. Redistributions in binary form must reproduce the above copyright 12 + * notice, this list of conditions and the following disclaimer in the 13 + * documentation and/or other materials provided with the distribution. 14 + * 3. Neither the name of IBM nor the names of its contributors 15 + * may be used to endorse or promote products derived from this software 16 + * without specific prior written permission. 17 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 + * SUCH DAMAGE. */ 5 28 #include <linux/types.h> 6 29 #include <linux/virtio_ids.h> 7 30 #include <linux/virtio_config.h>
+23
include/linux/virtio_pci.h
··· 11 11 * 12 12 * This header is BSD licensed so anyone can use the definitions to implement 13 13 * compatible drivers/servers. 14 + * 15 + * Redistribution and use in source and binary forms, with or without 16 + * modification, are permitted provided that the following conditions 17 + * are met: 18 + * 1. Redistributions of source code must retain the above copyright 19 + * notice, this list of conditions and the following disclaimer. 20 + * 2. Redistributions in binary form must reproduce the above copyright 21 + * notice, this list of conditions and the following disclaimer in the 22 + * documentation and/or other materials provided with the distribution. 23 + * 3. Neither the name of IBM nor the names of its contributors 24 + * may be used to endorse or promote products derived from this software 25 + * without specific prior written permission. 26 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 27 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 30 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 + * SUCH DAMAGE. 14 37 */ 15 38 16 39 #ifndef _LINUX_VIRTIO_PCI_H
+51 -1
include/linux/virtio_ring.h
··· 7 7 * This header is BSD licensed so anyone can use the definitions to implement 8 8 * compatible drivers/servers. 9 9 * 10 + * Redistribution and use in source and binary forms, with or without 11 + * modification, are permitted provided that the following conditions 12 + * are met: 13 + * 1. Redistributions of source code must retain the above copyright 14 + * notice, this list of conditions and the following disclaimer. 15 + * 2. Redistributions in binary form must reproduce the above copyright 16 + * notice, this list of conditions and the following disclaimer in the 17 + * documentation and/or other materials provided with the distribution. 18 + * 3. Neither the name of IBM nor the names of its contributors 19 + * may be used to endorse or promote products derived from this software 20 + * without specific prior written permission. 21 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 22 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 25 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 + * SUCH DAMAGE. 32 + * 10 33 * Copyright Rusty Russell IBM Corporation 2007. */ 11 34 #include <linux/types.h> 12 35 ··· 51 28 52 29 /* We support indirect buffer descriptors */ 53 30 #define VIRTIO_RING_F_INDIRECT_DESC 28 31 + 32 + /* The Guest publishes the used index for which it expects an interrupt 33 + * at the end of the avail ring. Host should ignore the avail->flags field. */ 34 + /* The Host publishes the avail index for which it expects a kick 35 + * at the end of the used ring. Guest should ignore the used->flags field. */ 36 + #define VIRTIO_RING_F_EVENT_IDX 29 54 37 55 38 /* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ 56 39 struct vring_desc { ··· 112 83 * __u16 avail_flags; 113 84 * __u16 avail_idx; 114 85 * __u16 available[num]; 86 + * __u16 used_event_idx; 115 87 * 116 88 * // Padding to the next align boundary. 117 89 * char pad[]; ··· 121 91 * __u16 used_flags; 122 92 * __u16 used_idx; 123 93 * struct vring_used_elem used[num]; 94 + * __u16 avail_event_idx; 124 95 * }; 125 96 */ 97 + /* We publish the used event index at the end of the available ring, and vice 98 + * versa. They are at the end for backwards compatibility. */ 99 + #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) 100 + #define vring_avail_event(vr) (*(__u16 *)&(vr)->used->ring[(vr)->num]) 101 + 126 102 static inline void vring_init(struct vring *vr, unsigned int num, void *p, 127 103 unsigned long align) 128 104 { ··· 143 107 { 144 108 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) 145 109 + align - 1) & ~(align - 1)) 146 - + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num; 110 + + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num; 111 + } 112 + 113 + /* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */ 114 + /* Assuming a given event_idx value from the other size, if 115 + * we have just incremented index from old to new_idx, 116 + * should we trigger an event? */ 117 + static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old) 118 + { 119 + /* Note: Xen has similar logic for notification hold-off 120 + * in include/xen/interface/io/ring.h with req_event and req_prod 121 + * corresponding to event_idx + 1 and new_idx respectively. 122 + * Note also that req_event and req_prod in Xen start at 1, 123 + * event indexes in virtio start at 0. */ 124 + return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old); 147 125 } 148 126 149 127 #ifdef __KERNEL__
+1
include/net/sctp/command.h
··· 107 107 SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */ 108 108 SCTP_CMD_SEND_MSG, /* Send the whole use message */ 109 109 SCTP_CMD_SEND_NEXT_ASCONF, /* Send the next ASCONF after ACK */ 110 + SCTP_CMD_PURGE_ASCONF_QUEUE, /* Purge all asconf queues.*/ 110 111 SCTP_CMD_LAST 111 112 } sctp_verb_t; 112 113
+1 -1
include/net/sctp/structs.h
··· 1993 1993 struct sctp_chunk *sctp_assoc_lookup_asconf_ack( 1994 1994 const struct sctp_association *asoc, 1995 1995 __be32 serial); 1996 - 1996 + void sctp_asconf_queue_teardown(struct sctp_association *asoc); 1997 1997 1998 1998 int sctp_cmp_addr_exact(const union sctp_addr *ss1, 1999 1999 const union sctp_addr *ss2);
+7 -5
include/trace/events/net.h
··· 12 12 TRACE_EVENT(net_dev_xmit, 13 13 14 14 TP_PROTO(struct sk_buff *skb, 15 - int rc), 15 + int rc, 16 + struct net_device *dev, 17 + unsigned int skb_len), 16 18 17 - TP_ARGS(skb, rc), 19 + TP_ARGS(skb, rc, dev, skb_len), 18 20 19 21 TP_STRUCT__entry( 20 22 __field( void *, skbaddr ) 21 23 __field( unsigned int, len ) 22 24 __field( int, rc ) 23 - __string( name, skb->dev->name ) 25 + __string( name, dev->name ) 24 26 ), 25 27 26 28 TP_fast_assign( 27 29 __entry->skbaddr = skb; 28 - __entry->len = skb->len; 30 + __entry->len = skb_len; 29 31 __entry->rc = rc; 30 - __assign_str(name, skb->dev->name); 32 + __assign_str(name, dev->name); 31 33 ), 32 34 33 35 TP_printk("dev=%s skbaddr=%p len=%u rc=%d",
+46 -8
kernel/rcutree.c
··· 1648 1648 if (IS_ERR(t)) 1649 1649 return PTR_ERR(t); 1650 1650 kthread_bind(t, cpu); 1651 - set_task_state(t, TASK_INTERRUPTIBLE); 1652 1651 per_cpu(rcu_cpu_kthread_cpu, cpu) = cpu; 1653 1652 WARN_ON_ONCE(per_cpu(rcu_cpu_kthread_task, cpu) != NULL); 1654 1653 per_cpu(rcu_cpu_kthread_task, cpu) = t; ··· 1755 1756 if (IS_ERR(t)) 1756 1757 return PTR_ERR(t); 1757 1758 raw_spin_lock_irqsave(&rnp->lock, flags); 1758 - set_task_state(t, TASK_INTERRUPTIBLE); 1759 1759 rnp->node_kthread_task = t; 1760 1760 raw_spin_unlock_irqrestore(&rnp->lock, flags); 1761 1761 sp.sched_priority = 99; ··· 1763 1765 return rcu_spawn_one_boost_kthread(rsp, rnp, rnp_index); 1764 1766 } 1765 1767 1768 + static void rcu_wake_one_boost_kthread(struct rcu_node *rnp); 1769 + 1766 1770 /* 1767 1771 * Spawn all kthreads -- called as soon as the scheduler is running. 1768 1772 */ ··· 1772 1772 { 1773 1773 int cpu; 1774 1774 struct rcu_node *rnp; 1775 + struct task_struct *t; 1775 1776 1776 1777 rcu_kthreads_spawnable = 1; 1777 1778 for_each_possible_cpu(cpu) { 1778 1779 per_cpu(rcu_cpu_has_work, cpu) = 0; 1779 - if (cpu_online(cpu)) 1780 + if (cpu_online(cpu)) { 1780 1781 (void)rcu_spawn_one_cpu_kthread(cpu); 1782 + t = per_cpu(rcu_cpu_kthread_task, cpu); 1783 + if (t) 1784 + wake_up_process(t); 1785 + } 1781 1786 } 1782 1787 rnp = rcu_get_root(rcu_state); 1783 1788 (void)rcu_spawn_one_node_kthread(rcu_state, rnp); 1789 + if (rnp->node_kthread_task) 1790 + wake_up_process(rnp->node_kthread_task); 1784 1791 if (NUM_RCU_NODES > 1) { 1785 - rcu_for_each_leaf_node(rcu_state, rnp) 1792 + rcu_for_each_leaf_node(rcu_state, rnp) { 1786 1793 (void)rcu_spawn_one_node_kthread(rcu_state, rnp); 1794 + t = rnp->node_kthread_task; 1795 + if (t) 1796 + wake_up_process(t); 1797 + rcu_wake_one_boost_kthread(rnp); 1798 + } 1787 1799 } 1788 1800 return 0; 1789 1801 } ··· 2200 2188 raw_spin_unlock_irqrestore(&rsp->onofflock, flags); 2201 2189 } 2202 2190 2203 - static void __cpuinit rcu_online_cpu(int cpu) 2191 + static void __cpuinit rcu_prepare_cpu(int cpu) 2204 2192 { 2205 2193 rcu_init_percpu_data(cpu, &rcu_sched_state, 0); 2206 2194 rcu_init_percpu_data(cpu, &rcu_bh_state, 0); 2207 2195 rcu_preempt_init_percpu_data(cpu); 2208 2196 } 2209 2197 2210 - static void __cpuinit rcu_online_kthreads(int cpu) 2198 + static void __cpuinit rcu_prepare_kthreads(int cpu) 2211 2199 { 2212 2200 struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu); 2213 2201 struct rcu_node *rnp = rdp->mynode; ··· 2218 2206 if (rnp->node_kthread_task == NULL) 2219 2207 (void)rcu_spawn_one_node_kthread(rcu_state, rnp); 2220 2208 } 2209 + } 2210 + 2211 + /* 2212 + * kthread_create() creates threads in TASK_UNINTERRUPTIBLE state, 2213 + * but the RCU threads are woken on demand, and if demand is low this 2214 + * could be a while triggering the hung task watchdog. 2215 + * 2216 + * In order to avoid this, poke all tasks once the CPU is fully 2217 + * up and running. 2218 + */ 2219 + static void __cpuinit rcu_online_kthreads(int cpu) 2220 + { 2221 + struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu); 2222 + struct rcu_node *rnp = rdp->mynode; 2223 + struct task_struct *t; 2224 + 2225 + t = per_cpu(rcu_cpu_kthread_task, cpu); 2226 + if (t) 2227 + wake_up_process(t); 2228 + 2229 + t = rnp->node_kthread_task; 2230 + if (t) 2231 + wake_up_process(t); 2232 + 2233 + rcu_wake_one_boost_kthread(rnp); 2221 2234 } 2222 2235 2223 2236 /* ··· 2258 2221 switch (action) { 2259 2222 case CPU_UP_PREPARE: 2260 2223 case CPU_UP_PREPARE_FROZEN: 2261 - rcu_online_cpu(cpu); 2262 - rcu_online_kthreads(cpu); 2224 + rcu_prepare_cpu(cpu); 2225 + rcu_prepare_kthreads(cpu); 2263 2226 break; 2264 2227 case CPU_ONLINE: 2228 + rcu_online_kthreads(cpu); 2265 2229 case CPU_DOWN_FAILED: 2266 2230 rcu_node_kthread_setaffinity(rnp, -1); 2267 2231 rcu_cpu_kthread_setrt(cpu, 1);
+10 -1
kernel/rcutree_plugin.h
··· 1295 1295 if (IS_ERR(t)) 1296 1296 return PTR_ERR(t); 1297 1297 raw_spin_lock_irqsave(&rnp->lock, flags); 1298 - set_task_state(t, TASK_INTERRUPTIBLE); 1299 1298 rnp->boost_kthread_task = t; 1300 1299 raw_spin_unlock_irqrestore(&rnp->lock, flags); 1301 1300 sp.sched_priority = RCU_KTHREAD_PRIO; 1302 1301 sched_setscheduler_nocheck(t, SCHED_FIFO, &sp); 1303 1302 return 0; 1303 + } 1304 + 1305 + static void __cpuinit rcu_wake_one_boost_kthread(struct rcu_node *rnp) 1306 + { 1307 + if (rnp->boost_kthread_task) 1308 + wake_up_process(rnp->boost_kthread_task); 1304 1309 } 1305 1310 1306 1311 #else /* #ifdef CONFIG_RCU_BOOST */ ··· 1329 1324 int rnp_index) 1330 1325 { 1331 1326 return 0; 1327 + } 1328 + 1329 + static void __cpuinit rcu_wake_one_boost_kthread(struct rcu_node *rnp) 1330 + { 1332 1331 } 1333 1332 1334 1333 #endif /* #else #ifdef CONFIG_RCU_BOOST */
+1 -1
lib/Kconfig.debug
··· 697 697 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EXPERT 698 698 depends on BUG 699 699 depends on ARM || AVR32 || M32R || M68K || SPARC32 || SPARC64 || \ 700 - FRV || SUPERH || GENERIC_BUG || BLACKFIN || MN10300 700 + FRV || SUPERH || GENERIC_BUG || BLACKFIN || MN10300 || TILE 701 701 default y 702 702 help 703 703 Say Y here to make BUG() panics output the file name and line number
+2 -2
mm/hugetlb.c
··· 1033 1033 */ 1034 1034 chg = vma_needs_reservation(h, vma, addr); 1035 1035 if (chg < 0) 1036 - return ERR_PTR(chg); 1036 + return ERR_PTR(-VM_FAULT_OOM); 1037 1037 if (chg) 1038 1038 if (hugetlb_get_quota(inode->i_mapping, chg)) 1039 - return ERR_PTR(-ENOSPC); 1039 + return ERR_PTR(-VM_FAULT_SIGBUS); 1040 1040 1041 1041 spin_lock(&hugetlb_lock); 1042 1042 page = dequeue_huge_page_vma(h, vma, addr, avoid_reserve);
-4
mm/page_alloc.c
··· 2247 2247 2248 2248 if (should_fail_alloc_page(gfp_mask, order)) 2249 2249 return NULL; 2250 - #ifndef CONFIG_ZONE_DMA 2251 - if (WARN_ON_ONCE(gfp_mask & __GFP_DMA)) 2252 - return NULL; 2253 - #endif 2254 2250 2255 2251 /* 2256 2252 * Check the zones suitable for the gfp_mask contain at least one
+1 -1
net/8021q/vlan_dev.c
··· 165 165 u64_stats_update_begin(&stats->syncp); 166 166 stats->tx_packets++; 167 167 stats->tx_bytes += len; 168 - u64_stats_update_begin(&stats->syncp); 168 + u64_stats_update_end(&stats->syncp); 169 169 } else { 170 170 this_cpu_inc(vlan_dev_info(dev)->vlan_pcpu_stats->tx_dropped); 171 171 }
+1 -1
net/bluetooth/l2cap_core.c
··· 906 906 if (c->psm == psm) { 907 907 /* Exact match. */ 908 908 if (!bacmp(&bt_sk(sk)->src, src)) { 909 - read_unlock_bh(&chan_list_lock); 909 + read_unlock(&chan_list_lock); 910 910 return c; 911 911 } 912 912
+3 -6
net/caif/chnl_net.c
··· 139 139 struct chnl_net *dev = NULL; 140 140 struct list_head *list_node; 141 141 struct list_head *_tmp; 142 - /* May be called with or without RTNL lock held */ 143 - int islocked = rtnl_is_locked(); 144 - if (!islocked) 145 - rtnl_lock(); 142 + 143 + rtnl_lock(); 146 144 list_for_each_safe(list_node, _tmp, &chnl_net_list) { 147 145 dev = list_entry(list_node, struct chnl_net, list_field); 148 146 if (dev->state == CAIF_SHUTDOWN) 149 147 dev_close(dev->netdev); 150 148 } 151 - if (!islocked) 152 - rtnl_unlock(); 149 + rtnl_unlock(); 153 150 } 154 151 static DECLARE_WORK(close_worker, close_work); 155 152
+5 -2
net/core/dev.c
··· 2096 2096 { 2097 2097 const struct net_device_ops *ops = dev->netdev_ops; 2098 2098 int rc = NETDEV_TX_OK; 2099 + unsigned int skb_len; 2099 2100 2100 2101 if (likely(!skb->next)) { 2101 2102 u32 features; ··· 2147 2146 } 2148 2147 } 2149 2148 2149 + skb_len = skb->len; 2150 2150 rc = ops->ndo_start_xmit(skb, dev); 2151 - trace_net_dev_xmit(skb, rc); 2151 + trace_net_dev_xmit(skb, rc, dev, skb_len); 2152 2152 if (rc == NETDEV_TX_OK) 2153 2153 txq_trans_update(txq); 2154 2154 return rc; ··· 2169 2167 if (dev->priv_flags & IFF_XMIT_DST_RELEASE) 2170 2168 skb_dst_drop(nskb); 2171 2169 2170 + skb_len = nskb->len; 2172 2171 rc = ops->ndo_start_xmit(nskb, dev); 2173 - trace_net_dev_xmit(nskb, rc); 2172 + trace_net_dev_xmit(nskb, rc, dev, skb_len); 2174 2173 if (unlikely(rc != NETDEV_TX_OK)) { 2175 2174 if (rc & ~NETDEV_TX_MASK) 2176 2175 goto out_kfree_gso_skb;
+3
net/ipv4/af_inet.c
··· 465 465 if (addr_len < sizeof(struct sockaddr_in)) 466 466 goto out; 467 467 468 + if (addr->sin_family != AF_INET) 469 + goto out; 470 + 468 471 chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); 469 472 470 473 /* Not specified by any standard per-se, however it breaks too
+8 -7
net/ipv4/ip_options.c
··· 14 14 #include <linux/slab.h> 15 15 #include <linux/types.h> 16 16 #include <asm/uaccess.h> 17 + #include <asm/unaligned.h> 17 18 #include <linux/skbuff.h> 18 19 #include <linux/ip.h> 19 20 #include <linux/icmp.h> ··· 351 350 goto error; 352 351 } 353 352 if (optptr[2] <= optlen) { 354 - __be32 *timeptr = NULL; 353 + unsigned char *timeptr = NULL; 355 354 if (optptr[2]+3 > optptr[1]) { 356 355 pp_ptr = optptr + 2; 357 356 goto error; ··· 360 359 case IPOPT_TS_TSONLY: 361 360 opt->ts = optptr - iph; 362 361 if (skb) 363 - timeptr = (__be32*)&optptr[optptr[2]-1]; 362 + timeptr = &optptr[optptr[2]-1]; 364 363 opt->ts_needtime = 1; 365 364 optptr[2] += 4; 366 365 break; ··· 372 371 opt->ts = optptr - iph; 373 372 if (rt) { 374 373 memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4); 375 - timeptr = (__be32*)&optptr[optptr[2]+3]; 374 + timeptr = &optptr[optptr[2]+3]; 376 375 } 377 376 opt->ts_needaddr = 1; 378 377 opt->ts_needtime = 1; ··· 390 389 if (inet_addr_type(net, addr) == RTN_UNICAST) 391 390 break; 392 391 if (skb) 393 - timeptr = (__be32*)&optptr[optptr[2]+3]; 392 + timeptr = &optptr[optptr[2]+3]; 394 393 } 395 394 opt->ts_needtime = 1; 396 395 optptr[2] += 8; ··· 404 403 } 405 404 if (timeptr) { 406 405 struct timespec tv; 407 - __be32 midtime; 406 + u32 midtime; 408 407 getnstimeofday(&tv); 409 - midtime = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC); 410 - memcpy(timeptr, &midtime, sizeof(__be32)); 408 + midtime = (tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC; 409 + put_unaligned_be32(midtime, timeptr); 411 410 opt->is_changed = 1; 412 411 } 413 412 } else {
+7
net/mac80211/mlme.c
··· 232 232 WARN_ON(!ieee80211_set_channel_type(local, sdata, channel_type)); 233 233 } 234 234 235 + ieee80211_stop_queues_by_reason(&sdata->local->hw, 236 + IEEE80211_QUEUE_STOP_REASON_CSA); 237 + 235 238 /* channel_type change automatically detected */ 236 239 ieee80211_hw_config(local, 0); 237 240 ··· 247 244 channel_type); 248 245 rcu_read_unlock(); 249 246 } 247 + 248 + ieee80211_wake_queues_by_reason(&sdata->local->hw, 249 + IEEE80211_QUEUE_STOP_REASON_CSA); 250 250 251 251 ht_opmode = le16_to_cpu(hti->operation_mode); 252 252 ··· 1095 1089 local->hw.conf.flags &= ~IEEE80211_CONF_PS; 1096 1090 config_changed |= IEEE80211_CONF_CHANGE_PS; 1097 1091 } 1092 + local->ps_sdata = NULL; 1098 1093 1099 1094 ieee80211_hw_config(local, config_changed); 1100 1095
-1
net/mac80211/scan.c
··· 15 15 #include <linux/if_arp.h> 16 16 #include <linux/rtnetlink.h> 17 17 #include <linux/pm_qos_params.h> 18 - #include <linux/slab.h> 19 18 #include <net/sch_generic.h> 20 19 #include <linux/slab.h> 21 20 #include <net/mac80211.h>
+12 -3
net/packet/af_packet.c
··· 798 798 getnstimeofday(&ts); 799 799 h.h2->tp_sec = ts.tv_sec; 800 800 h.h2->tp_nsec = ts.tv_nsec; 801 - h.h2->tp_vlan_tci = vlan_tx_tag_get(skb); 801 + if (vlan_tx_tag_present(skb)) { 802 + h.h2->tp_vlan_tci = vlan_tx_tag_get(skb); 803 + status |= TP_STATUS_VLAN_VALID; 804 + } else { 805 + h.h2->tp_vlan_tci = 0; 806 + } 802 807 hdrlen = sizeof(*h.h2); 803 808 break; 804 809 default: ··· 1730 1725 aux.tp_snaplen = skb->len; 1731 1726 aux.tp_mac = 0; 1732 1727 aux.tp_net = skb_network_offset(skb); 1733 - aux.tp_vlan_tci = vlan_tx_tag_get(skb); 1734 - 1728 + if (vlan_tx_tag_present(skb)) { 1729 + aux.tp_vlan_tci = vlan_tx_tag_get(skb); 1730 + aux.tp_status |= TP_STATUS_VLAN_VALID; 1731 + } else { 1732 + aux.tp_vlan_tci = 0; 1733 + } 1735 1734 put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux); 1736 1735 } 1737 1736
+14 -9
net/sctp/associola.c
··· 444 444 445 445 asoc->peer.transport_count = 0; 446 446 447 - /* Free any cached ASCONF_ACK chunk. */ 448 - sctp_assoc_free_asconf_acks(asoc); 449 - 450 - /* Free the ASCONF queue. */ 451 - sctp_assoc_free_asconf_queue(asoc); 452 - 453 - /* Free any cached ASCONF chunk. */ 454 - if (asoc->addip_last_asconf) 455 - sctp_chunk_free(asoc->addip_last_asconf); 447 + sctp_asconf_queue_teardown(asoc); 456 448 457 449 /* AUTH - Free the endpoint shared keys */ 458 450 sctp_auth_destroy_keys(&asoc->endpoint_shared_keys); ··· 1637 1645 } 1638 1646 1639 1647 return NULL; 1648 + } 1649 + 1650 + void sctp_asconf_queue_teardown(struct sctp_association *asoc) 1651 + { 1652 + /* Free any cached ASCONF_ACK chunk. */ 1653 + sctp_assoc_free_asconf_acks(asoc); 1654 + 1655 + /* Free the ASCONF queue. */ 1656 + sctp_assoc_free_asconf_queue(asoc); 1657 + 1658 + /* Free any cached ASCONF chunk. */ 1659 + if (asoc->addip_last_asconf) 1660 + sctp_chunk_free(asoc->addip_last_asconf); 1640 1661 }
+3
net/sctp/sm_sideeffect.c
··· 1670 1670 case SCTP_CMD_SEND_NEXT_ASCONF: 1671 1671 sctp_cmd_send_asconf(asoc); 1672 1672 break; 1673 + case SCTP_CMD_PURGE_ASCONF_QUEUE: 1674 + sctp_asconf_queue_teardown(asoc); 1675 + break; 1673 1676 default: 1674 1677 pr_warn("Impossible command: %u, %p\n", 1675 1678 cmd->verb, cmd->obj.ptr);
+12 -2
net/sctp/sm_statefuns.c
··· 1718 1718 return SCTP_DISPOSITION_CONSUME; 1719 1719 } 1720 1720 1721 - /* For now, fail any unsent/unacked data. Consider the optional 1722 - * choice of resending of this data. 1721 + /* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked 1722 + * data. Consider the optional choice of resending of this data. 1723 1723 */ 1724 + sctp_add_cmd_sf(commands, SCTP_CMD_T3_RTX_TIMERS_STOP, SCTP_NULL()); 1725 + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 1726 + SCTP_TO(SCTP_EVENT_TIMEOUT_SACK)); 1724 1727 sctp_add_cmd_sf(commands, SCTP_CMD_PURGE_OUTQUEUE, SCTP_NULL()); 1728 + 1729 + /* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue 1730 + * and ASCONF-ACK cache. 1731 + */ 1732 + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 1733 + SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO)); 1734 + sctp_add_cmd_sf(commands, SCTP_CMD_PURGE_ASCONF_QUEUE, SCTP_NULL()); 1725 1735 1726 1736 repl = sctp_make_cookie_ack(new_asoc, chunk); 1727 1737 if (!repl)
+2 -2
net/wireless/nl80211.c
··· 3406 3406 i = 0; 3407 3407 if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) { 3408 3408 nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) { 3409 + request->ssids[i].ssid_len = nla_len(attr); 3409 3410 if (request->ssids[i].ssid_len > IEEE80211_MAX_SSID_LEN) { 3410 3411 err = -EINVAL; 3411 3412 goto out_free; 3412 3413 } 3413 3414 memcpy(request->ssids[i].ssid, nla_data(attr), nla_len(attr)); 3414 - request->ssids[i].ssid_len = nla_len(attr); 3415 3415 i++; 3416 3416 } 3417 3417 } ··· 3572 3572 if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) { 3573 3573 nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], 3574 3574 tmp) { 3575 + request->ssids[i].ssid_len = nla_len(attr); 3575 3576 if (request->ssids[i].ssid_len > 3576 3577 IEEE80211_MAX_SSID_LEN) { 3577 3578 err = -EINVAL; ··· 3580 3579 } 3581 3580 memcpy(request->ssids[i].ssid, nla_data(attr), 3582 3581 nla_len(attr)); 3583 - request->ssids[i].ssid_len = nla_len(attr); 3584 3582 i++; 3585 3583 } 3586 3584 }
+24 -19
net/wireless/scan.c
··· 267 267 return memcmp(ssidie + 2, ssid, ssid_len) == 0; 268 268 } 269 269 270 + static bool is_mesh_bss(struct cfg80211_bss *a) 271 + { 272 + const u8 *ie; 273 + 274 + if (!WLAN_CAPABILITY_IS_STA_BSS(a->capability)) 275 + return false; 276 + 277 + ie = cfg80211_find_ie(WLAN_EID_MESH_ID, 278 + a->information_elements, 279 + a->len_information_elements); 280 + if (!ie) 281 + return false; 282 + 283 + ie = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, 284 + a->information_elements, 285 + a->len_information_elements); 286 + if (!ie) 287 + return false; 288 + 289 + return true; 290 + } 291 + 270 292 static bool is_mesh(struct cfg80211_bss *a, 271 293 const u8 *meshid, size_t meshidlen, 272 294 const u8 *meshcfg) 273 295 { 274 296 const u8 *ie; 275 297 276 - if (!WLAN_CAPABILITY_IS_MBSS(a->capability)) 298 + if (!WLAN_CAPABILITY_IS_STA_BSS(a->capability)) 277 299 return false; 278 300 279 301 ie = cfg80211_find_ie(WLAN_EID_MESH_ID, ··· 333 311 if (a->channel != b->channel) 334 312 return b->channel->center_freq - a->channel->center_freq; 335 313 336 - if (WLAN_CAPABILITY_IS_MBSS(a->capability | b->capability)) { 314 + if (is_mesh_bss(a) && is_mesh_bss(b)) { 337 315 r = cmp_ies(WLAN_EID_MESH_ID, 338 316 a->information_elements, 339 317 a->len_information_elements, ··· 479 457 struct cfg80211_internal_bss *res) 480 458 { 481 459 struct cfg80211_internal_bss *found = NULL; 482 - const u8 *meshid, *meshcfg; 483 460 484 461 /* 485 462 * The reference to "res" is donated to this function. ··· 490 469 } 491 470 492 471 res->ts = jiffies; 493 - 494 - if (WLAN_CAPABILITY_IS_MBSS(res->pub.capability)) { 495 - /* must be mesh, verify */ 496 - meshid = cfg80211_find_ie(WLAN_EID_MESH_ID, 497 - res->pub.information_elements, 498 - res->pub.len_information_elements); 499 - meshcfg = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, 500 - res->pub.information_elements, 501 - res->pub.len_information_elements); 502 - if (!meshid || !meshcfg || 503 - meshcfg[1] != sizeof(struct ieee80211_meshconf_ie)) { 504 - /* bogus mesh */ 505 - kref_put(&res->ref, bss_release); 506 - return NULL; 507 - } 508 - } 509 472 510 473 spin_lock_bh(&dev->bss_lock); 511 474
+2 -1
security/apparmor/lsm.c
··· 593 593 sa.aad.op = OP_SETPROCATTR; 594 594 sa.aad.info = name; 595 595 sa.aad.error = -EINVAL; 596 - return aa_audit(AUDIT_APPARMOR_DENIED, NULL, GFP_KERNEL, 596 + return aa_audit(AUDIT_APPARMOR_DENIED, 597 + __aa_current_profile(), GFP_KERNEL, 597 598 &sa, NULL); 598 599 } 599 600 } else if (strcmp(name, "exec") == 0) {
+1 -1
sound/pci/asihpi/hpidspcd.c
··· 60 60 HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER))) 61 61 62 62 /***********************************************************************/ 63 - #include "linux/pci.h" 63 + #include <linux/pci.h> 64 64 /*-------------------------------------------------------------------*/ 65 65 short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code, 66 66 u32 *pos_error_code)
+11 -2
sound/pci/fm801.c
··· 1234 1234 sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci)); 1235 1235 if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 && 1236 1236 (tea575x_tuner & TUNER_TYPE_MASK) < 4) { 1237 - if (snd_tea575x_init(&chip->tea)) 1237 + if (snd_tea575x_init(&chip->tea)) { 1238 1238 snd_printk(KERN_ERR "TEA575x radio not found\n"); 1239 - } else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0) 1239 + snd_fm801_free(chip); 1240 + return -ENODEV; 1241 + } 1242 + } else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0) { 1240 1243 /* autodetect tuner connection */ 1241 1244 for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) { 1242 1245 chip->tea575x_tuner = tea575x_tuner; ··· 1249 1246 break; 1250 1247 } 1251 1248 } 1249 + if (tea575x_tuner == 4) { 1250 + snd_printk(KERN_ERR "TEA575x radio not found\n"); 1251 + snd_fm801_free(chip); 1252 + return -ENODEV; 1253 + } 1254 + } 1252 1255 strlcpy(chip->tea.card, snd_fm801_tea575x_gpios[(tea575x_tuner & TUNER_TYPE_MASK) - 1].name, sizeof(chip->tea.card)); 1253 1256 #endif 1254 1257
+8 -8
sound/pci/hda/patch_analog.c
··· 506 506 hda_nid_t hp) 507 507 { 508 508 struct ad198x_spec *spec = codec->spec; 509 - snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE, 509 + if (snd_hda_query_pin_caps(codec, front) & AC_PINCAP_EAPD) 510 + snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE, 510 511 !spec->inv_eapd ? 0x00 : 0x02); 511 - snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE, 512 + if (snd_hda_query_pin_caps(codec, hp) & AC_PINCAP_EAPD) 513 + snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE, 512 514 !spec->inv_eapd ? 0x00 : 0x02); 513 515 } 514 516 ··· 526 524 case 0x11d4184a: 527 525 case 0x11d4194a: 528 526 case 0x11d4194b: 527 + case 0x11d41988: 528 + case 0x11d4198b: 529 + case 0x11d4989a: 530 + case 0x11d4989b: 529 531 ad198x_power_eapd_write(codec, 0x12, 0x11); 530 532 break; 531 533 case 0x11d41981: ··· 538 532 break; 539 533 case 0x11d41986: 540 534 ad198x_power_eapd_write(codec, 0x1b, 0x1a); 541 - break; 542 - case 0x11d41988: 543 - case 0x11d4198b: 544 - case 0x11d4989a: 545 - case 0x11d4989b: 546 - ad198x_power_eapd_write(codec, 0x29, 0x22); 547 535 break; 548 536 } 549 537 }
+3 -5
sound/soc/codecs/cx20442.c
··· 262 262 } 263 263 264 264 /* Line discipline .receive_buf() */ 265 - static unsigned int v253_receive(struct tty_struct *tty, 266 - const unsigned char *cp, char *fp, int count) 265 + static void v253_receive(struct tty_struct *tty, 266 + const unsigned char *cp, char *fp, int count) 267 267 { 268 268 struct snd_soc_codec *codec = tty->disc_data; 269 269 struct cx20442_priv *cx20442; 270 270 271 271 if (!codec) 272 - return count; 272 + return; 273 273 274 274 cx20442 = snd_soc_codec_get_drvdata(codec); 275 275 ··· 281 281 codec->hw_write = (hw_write_t)tty->ops->write; 282 282 codec->card->pop_time = 1; 283 283 } 284 - 285 - return count; 286 284 } 287 285 288 286 /* Line discipline .write_wakeup() */
+4 -4
sound/soc/codecs/wm_hubs.c
··· 215 215 SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, 216 216 inpga_tlv), 217 217 SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), 218 - SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 0), 218 + SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 6, 1, 0), 219 219 220 220 SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, 221 221 inpga_tlv), 222 222 SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), 223 - SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 0), 223 + SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 6, 1, 0), 224 224 225 225 226 226 SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, 227 227 inpga_tlv), 228 228 SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), 229 - SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 0), 229 + SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 6, 1, 0), 230 230 231 231 SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, 232 232 inpga_tlv), 233 233 SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), 234 - SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 0), 234 + SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 6, 1, 0), 235 235 236 236 SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3, 7, 1, 0, 237 237 inmix_sw_tlv),
+4 -1
sound/soc/soc-dapm.c
··· 325 325 } 326 326 327 327 static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, 328 + struct snd_soc_dapm_widget *kcontrolw, 328 329 const struct snd_kcontrol_new *kcontrol_new, 329 330 struct snd_kcontrol **kcontrol) 330 331 { ··· 335 334 *kcontrol = NULL; 336 335 337 336 list_for_each_entry(w, &dapm->card->widgets, list) { 337 + if (w == kcontrolw || w->dapm != kcontrolw->dapm) 338 + continue; 338 339 for (i = 0; i < w->num_kcontrols; i++) { 339 340 if (&w->kcontrol_news[i] == kcontrol_new) { 340 341 if (w->kcontrols) ··· 471 468 return -EINVAL; 472 469 } 473 470 474 - shared = dapm_is_shared_kcontrol(dapm, &w->kcontrol_news[0], 471 + shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[0], 475 472 &kcontrol); 476 473 if (kcontrol) { 477 474 wlist = kcontrol->private_data;
+1
sound/usb/6fire/firmware.c
··· 227 227 ret = usb6fire_fw_ihex_init(fw, rec); 228 228 if (ret < 0) { 229 229 kfree(rec); 230 + release_firmware(fw); 230 231 snd_printk(KERN_ERR PREFIX "error validating ezusb " 231 232 "firmware %s.\n", fwname); 232 233 return ret;
+1 -1
sound/usb/quirks.c
··· 403 403 static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) 404 404 { 405 405 int err, reg; 406 - int val[] = {0x200c, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000}; 406 + int val[] = {0x2004, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000}; 407 407 408 408 for (reg = 0; reg < ARRAY_SIZE(val); reg++) { 409 409 err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]);
+4 -4
tools/testing/ktest/ktest.pl
··· 788 788 789 789 sub reboot_to { 790 790 if ($reboot_type eq "grub") { 791 - run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'"; 791 + run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch && reboot)'"; 792 792 return; 793 793 } 794 794 ··· 1480 1480 or dodie "Failed to read $config"; 1481 1481 1482 1482 while (<IN>) { 1483 - if (/^(.*?(CONFIG\S*)(=.*| is not set))/) { 1483 + if (/^((CONFIG\S*)=.*)/) { 1484 1484 $config_ignore{$2} = $1; 1485 1485 } 1486 1486 } ··· 1638 1638 if (!$found) { 1639 1639 # try the other half 1640 1640 doprint "Top half produced no set configs, trying bottom half\n"; 1641 - @tophalf = @start_list[$half .. $#start_list]; 1641 + @tophalf = @start_list[$half + 1 .. $#start_list]; 1642 1642 create_config @tophalf; 1643 1643 read_current_config \%current_config; 1644 1644 foreach my $config (@tophalf) { ··· 1690 1690 # remove half the configs we are looking at and see if 1691 1691 # they are good. 1692 1692 $half = int($#start_list / 2); 1693 - } while ($half > 0); 1693 + } while ($#start_list > 0); 1694 1694 1695 1695 # we found a single config, try it again unless we are running manually 1696 1696
+17 -2
tools/virtio/virtio_test.c
··· 198 198 .val = 'h', 199 199 }, 200 200 { 201 + .name = "event-idx", 202 + .val = 'E', 203 + }, 204 + { 205 + .name = "no-event-idx", 206 + .val = 'e', 207 + }, 208 + { 201 209 .name = "indirect", 202 210 .val = 'I', 203 211 }, ··· 219 211 220 212 static void help() 221 213 { 222 - fprintf(stderr, "Usage: virtio_test [--help] [--no-indirect]\n"); 214 + fprintf(stderr, "Usage: virtio_test [--help]" 215 + " [--no-indirect]" 216 + " [--no-event-idx]" 217 + "\n"); 223 218 } 224 219 225 220 int main(int argc, char **argv) 226 221 { 227 222 struct vdev_info dev; 228 - unsigned long long features = 1ULL << VIRTIO_RING_F_INDIRECT_DESC; 223 + unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | 224 + (1ULL << VIRTIO_RING_F_EVENT_IDX); 229 225 int o; 230 226 231 227 for (;;) { ··· 240 228 case '?': 241 229 help(); 242 230 exit(2); 231 + case 'e': 232 + features &= ~(1ULL << VIRTIO_RING_F_EVENT_IDX); 233 + break; 243 234 case 'h': 244 235 help(); 245 236 goto done;