aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/rtc/Kconfig6
-rw-r--r--drivers/rtc/interface.c54
-rw-r--r--drivers/rtc/rtc-dev.c51
-rw-r--r--drivers/video/via/viafbdev.c248
-rw-r--r--fs/affs/file.c2
-rw-r--r--fs/afs/write.c2
-rw-r--r--fs/buffer.c4
-rw-r--r--fs/cifs/file.c2
-rw-r--r--fs/ecryptfs/mmap.c2
-rw-r--r--fs/ext3/inode.c2
-rw-r--r--fs/ext3/namei.c3
-rw-r--r--fs/ext4/ext4_sb.h6
-rw-r--r--fs/ext4/inode.c4
-rw-r--r--fs/ext4/namei.c3
-rw-r--r--fs/fuse/file.c4
-rw-r--r--fs/gfs2/ops_address.c2
-rw-r--r--fs/hostfs/hostfs_kern.c2
-rw-r--r--fs/jffs2/file.c2
-rw-r--r--fs/libfs.c2
-rw-r--r--fs/namei.c13
-rw-r--r--fs/nfs/file.c2
-rw-r--r--fs/reiserfs/inode.c2
-rw-r--r--fs/smbfs/file.c2
-rw-r--r--fs/ubifs/file.c9
-rw-r--r--include/linux/blockgroup_lock.h7
-rw-r--r--include/linux/ext2_fs_sb.h6
-rw-r--r--include/linux/ext3_fs_sb.h6
-rw-r--r--include/linux/fs.h5
-rw-r--r--include/linux/pagemap.h3
-rw-r--r--include/linux/rtc.h8
-rw-r--r--include/linux/spi/spi.h2
-rw-r--r--kernel/cgroup.c6
-rw-r--r--mm/filemap.c13
-rw-r--r--mm/vmalloc.c5
34 files changed, 312 insertions, 178 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 123092d8a984..165a81843357 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -102,9 +102,13 @@ config RTC_INTF_DEV_UIE_EMUL
102 depends on RTC_INTF_DEV 102 depends on RTC_INTF_DEV
103 help 103 help
104 Provides an emulation for RTC_UIE if the underlying rtc chip 104 Provides an emulation for RTC_UIE if the underlying rtc chip
105 driver does not expose RTC_UIE ioctls. Those requests generate 105 driver does not expose RTC_UIE ioctls. Those requests generate
106 once-per-second update interrupts, used for synchronization. 106 once-per-second update interrupts, used for synchronization.
107 107
108 The emulation code will read the time from the hardware
109 clock several times per second, please enable this option
110 only if you know that you really need it.
111
108config RTC_DRV_TEST 112config RTC_DRV_TEST
109 tristate "Test driver/device" 113 tristate "Test driver/device"
110 help 114 help
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index a04c1b6b1575..fd2c652504ff 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -307,6 +307,60 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
307} 307}
308EXPORT_SYMBOL_GPL(rtc_set_alarm); 308EXPORT_SYMBOL_GPL(rtc_set_alarm);
309 309
310int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
311{
312 int err = mutex_lock_interruptible(&rtc->ops_lock);
313 if (err)
314 return err;
315
316 if (!rtc->ops)
317 err = -ENODEV;
318 else if (!rtc->ops->alarm_irq_enable)
319 err = -EINVAL;
320 else
321 err = rtc->ops->alarm_irq_enable(rtc->dev.parent, enabled);
322
323 mutex_unlock(&rtc->ops_lock);
324 return err;
325}
326EXPORT_SYMBOL_GPL(rtc_alarm_irq_enable);
327
328int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
329{
330 int err = mutex_lock_interruptible(&rtc->ops_lock);
331 if (err)
332 return err;
333
334#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
335 if (enabled == 0 && rtc->uie_irq_active) {
336 mutex_unlock(&rtc->ops_lock);
337 return rtc_dev_update_irq_enable_emul(rtc, enabled);
338 }
339#endif
340
341 if (!rtc->ops)
342 err = -ENODEV;
343 else if (!rtc->ops->update_irq_enable)
344 err = -EINVAL;
345 else
346 err = rtc->ops->update_irq_enable(rtc->dev.parent, enabled);
347
348 mutex_unlock(&rtc->ops_lock);
349
350#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
351 /*
352 * Enable emulation if the driver did not provide
353 * the update_irq_enable function pointer or if returned
354 * -EINVAL to signal that it has been configured without
355 * interrupts or that are not available at the moment.
356 */
357 if (err == -EINVAL)
358 err = rtc_dev_update_irq_enable_emul(rtc, enabled);
359#endif
360 return err;
361}
362EXPORT_SYMBOL_GPL(rtc_update_irq_enable);
363
310/** 364/**
311 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs 365 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs
312 * @rtc: the rtc device 366 * @rtc: the rtc device
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index ecdea44ae4e5..45152f4952d6 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -92,10 +92,10 @@ static void rtc_uie_timer(unsigned long data)
92 spin_unlock_irqrestore(&rtc->irq_lock, flags); 92 spin_unlock_irqrestore(&rtc->irq_lock, flags);
93} 93}
94 94
95static void clear_uie(struct rtc_device *rtc) 95static int clear_uie(struct rtc_device *rtc)
96{ 96{
97 spin_lock_irq(&rtc->irq_lock); 97 spin_lock_irq(&rtc->irq_lock);
98 if (rtc->irq_active) { 98 if (rtc->uie_irq_active) {
99 rtc->stop_uie_polling = 1; 99 rtc->stop_uie_polling = 1;
100 if (rtc->uie_timer_active) { 100 if (rtc->uie_timer_active) {
101 spin_unlock_irq(&rtc->irq_lock); 101 spin_unlock_irq(&rtc->irq_lock);
@@ -108,9 +108,10 @@ static void clear_uie(struct rtc_device *rtc)
108 flush_scheduled_work(); 108 flush_scheduled_work();
109 spin_lock_irq(&rtc->irq_lock); 109 spin_lock_irq(&rtc->irq_lock);
110 } 110 }
111 rtc->irq_active = 0; 111 rtc->uie_irq_active = 0;
112 } 112 }
113 spin_unlock_irq(&rtc->irq_lock); 113 spin_unlock_irq(&rtc->irq_lock);
114 return 0;
114} 115}
115 116
116static int set_uie(struct rtc_device *rtc) 117static int set_uie(struct rtc_device *rtc)
@@ -122,8 +123,8 @@ static int set_uie(struct rtc_device *rtc)
122 if (err) 123 if (err)
123 return err; 124 return err;
124 spin_lock_irq(&rtc->irq_lock); 125 spin_lock_irq(&rtc->irq_lock);
125 if (!rtc->irq_active) { 126 if (!rtc->uie_irq_active) {
126 rtc->irq_active = 1; 127 rtc->uie_irq_active = 1;
127 rtc->stop_uie_polling = 0; 128 rtc->stop_uie_polling = 0;
128 rtc->oldsecs = tm.tm_sec; 129 rtc->oldsecs = tm.tm_sec;
129 rtc->uie_task_active = 1; 130 rtc->uie_task_active = 1;
@@ -134,6 +135,16 @@ static int set_uie(struct rtc_device *rtc)
134 spin_unlock_irq(&rtc->irq_lock); 135 spin_unlock_irq(&rtc->irq_lock);
135 return 0; 136 return 0;
136} 137}
138
139int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc, unsigned int enabled)
140{
141 if (enabled)
142 return set_uie(rtc);
143 else
144 return clear_uie(rtc);
145}
146EXPORT_SYMBOL(rtc_dev_update_irq_enable_emul);
147
137#endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */ 148#endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */
138 149
139static ssize_t 150static ssize_t
@@ -357,6 +368,22 @@ static long rtc_dev_ioctl(struct file *file,
357 err = rtc_irq_set_state(rtc, NULL, 0); 368 err = rtc_irq_set_state(rtc, NULL, 0);
358 break; 369 break;
359 370
371 case RTC_AIE_ON:
372 mutex_unlock(&rtc->ops_lock);
373 return rtc_alarm_irq_enable(rtc, 1);
374
375 case RTC_AIE_OFF:
376 mutex_unlock(&rtc->ops_lock);
377 return rtc_alarm_irq_enable(rtc, 0);
378
379 case RTC_UIE_ON:
380 mutex_unlock(&rtc->ops_lock);
381 return rtc_update_irq_enable(rtc, 1);
382
383 case RTC_UIE_OFF:
384 mutex_unlock(&rtc->ops_lock);
385 return rtc_update_irq_enable(rtc, 0);
386
360 case RTC_IRQP_SET: 387 case RTC_IRQP_SET:
361 err = rtc_irq_set_freq(rtc, NULL, arg); 388 err = rtc_irq_set_freq(rtc, NULL, arg);
362 break; 389 break;
@@ -401,17 +428,6 @@ static long rtc_dev_ioctl(struct file *file,
401 err = -EFAULT; 428 err = -EFAULT;
402 return err; 429 return err;
403 430
404#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
405 case RTC_UIE_OFF:
406 mutex_unlock(&rtc->ops_lock);
407 clear_uie(rtc);
408 return 0;
409
410 case RTC_UIE_ON:
411 mutex_unlock(&rtc->ops_lock);
412 err = set_uie(rtc);
413 return err;
414#endif
415 default: 431 default:
416 err = -ENOTTY; 432 err = -ENOTTY;
417 break; 433 break;
@@ -440,7 +456,10 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
440 * Leave the alarm alone; it may be set to trigger a system wakeup 456 * Leave the alarm alone; it may be set to trigger a system wakeup
441 * later, or be used by kernel code, and is a one-shot event anyway. 457 * later, or be used by kernel code, and is a one-shot event anyway.
442 */ 458 */
459
460 /* Keep ioctl until all drivers are converted */
443 rtc_dev_ioctl(file, RTC_UIE_OFF, 0); 461 rtc_dev_ioctl(file, RTC_UIE_OFF, 0);
462 rtc_update_irq_enable(rtc, 0);
444 rtc_irq_set_state(rtc, NULL, 0); 463 rtc_irq_set_state(rtc, NULL, 0);
445 464
446 if (rtc->ops->release) 465 if (rtc->ops->release)
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 73ac754ad801..e21fe5b6f9ff 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -546,23 +546,25 @@ static int viafb_blank(int blank_mode, struct fb_info *info)
546 546
547static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) 547static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
548{ 548{
549 struct viafb_ioctl_mode viamode; 549 union {
550 struct viafb_ioctl_samm viasamm; 550 struct viafb_ioctl_mode viamode;
551 struct viafb_driver_version driver_version; 551 struct viafb_ioctl_samm viasamm;
552 struct fb_var_screeninfo sec_var; 552 struct viafb_driver_version driver_version;
553 struct _panel_size_pos_info panel_pos_size_para; 553 struct fb_var_screeninfo sec_var;
554 struct _panel_size_pos_info panel_pos_size_para;
555 struct viafb_ioctl_setting viafb_setting;
556 struct device_t active_dev;
557 } u;
554 u32 state_info = 0; 558 u32 state_info = 0;
555 u32 viainfo_size = sizeof(struct viafb_ioctl_info);
556 u32 *viafb_gamma_table; 559 u32 *viafb_gamma_table;
557 char driver_name[] = "viafb"; 560 char driver_name[] = "viafb";
558 561
559 u32 __user *argp = (u32 __user *) arg; 562 u32 __user *argp = (u32 __user *) arg;
560 u32 gpu32; 563 u32 gpu32;
561 u32 video_dev_info = 0; 564 u32 video_dev_info = 0;
562 struct viafb_ioctl_setting viafb_setting = {};
563 struct device_t active_dev = {};
564 565
565 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd); 566 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
567 memset(&u, 0, sizeof(u));
566 568
567 switch (cmd) { 569 switch (cmd) {
568 case VIAFB_GET_CHIP_INFO: 570 case VIAFB_GET_CHIP_INFO:
@@ -571,7 +573,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
571 return -EFAULT; 573 return -EFAULT;
572 break; 574 break;
573 case VIAFB_GET_INFO_SIZE: 575 case VIAFB_GET_INFO_SIZE:
574 return put_user(viainfo_size, argp); 576 return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
575 case VIAFB_GET_INFO: 577 case VIAFB_GET_INFO:
576 return viafb_ioctl_get_viafb_info(arg); 578 return viafb_ioctl_get_viafb_info(arg);
577 case VIAFB_HOTPLUG: 579 case VIAFB_HOTPLUG:
@@ -584,60 +586,60 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
584 viafb_hotplug = (gpu32) ? 1 : 0; 586 viafb_hotplug = (gpu32) ? 1 : 0;
585 break; 587 break;
586 case VIAFB_GET_RESOLUTION: 588 case VIAFB_GET_RESOLUTION:
587 viamode.xres = (u32) viafb_hotplug_Xres; 589 u.viamode.xres = (u32) viafb_hotplug_Xres;
588 viamode.yres = (u32) viafb_hotplug_Yres; 590 u.viamode.yres = (u32) viafb_hotplug_Yres;
589 viamode.refresh = (u32) viafb_hotplug_refresh; 591 u.viamode.refresh = (u32) viafb_hotplug_refresh;
590 viamode.bpp = (u32) viafb_hotplug_bpp; 592 u.viamode.bpp = (u32) viafb_hotplug_bpp;
591 if (viafb_SAMM_ON == 1) { 593 if (viafb_SAMM_ON == 1) {
592 viamode.xres_sec = viafb_second_xres; 594 u.viamode.xres_sec = viafb_second_xres;
593 viamode.yres_sec = viafb_second_yres; 595 u.viamode.yres_sec = viafb_second_yres;
594 viamode.virtual_xres_sec = viafb_second_virtual_xres; 596 u.viamode.virtual_xres_sec = viafb_second_virtual_xres;
595 viamode.virtual_yres_sec = viafb_second_virtual_yres; 597 u.viamode.virtual_yres_sec = viafb_second_virtual_yres;
596 viamode.refresh_sec = viafb_refresh1; 598 u.viamode.refresh_sec = viafb_refresh1;
597 viamode.bpp_sec = viafb_bpp1; 599 u.viamode.bpp_sec = viafb_bpp1;
598 } else { 600 } else {
599 viamode.xres_sec = 0; 601 u.viamode.xres_sec = 0;
600 viamode.yres_sec = 0; 602 u.viamode.yres_sec = 0;
601 viamode.virtual_xres_sec = 0; 603 u.viamode.virtual_xres_sec = 0;
602 viamode.virtual_yres_sec = 0; 604 u.viamode.virtual_yres_sec = 0;
603 viamode.refresh_sec = 0; 605 u.viamode.refresh_sec = 0;
604 viamode.bpp_sec = 0; 606 u.viamode.bpp_sec = 0;
605 } 607 }
606 if (copy_to_user(argp, &viamode, sizeof(viamode))) 608 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
607 return -EFAULT; 609 return -EFAULT;
608 break; 610 break;
609 case VIAFB_GET_SAMM_INFO: 611 case VIAFB_GET_SAMM_INFO:
610 viasamm.samm_status = viafb_SAMM_ON; 612 u.viasamm.samm_status = viafb_SAMM_ON;
611 613
612 if (viafb_SAMM_ON == 1) { 614 if (viafb_SAMM_ON == 1) {
613 if (viafb_dual_fb) { 615 if (viafb_dual_fb) {
614 viasamm.size_prim = viaparinfo->fbmem_free; 616 u.viasamm.size_prim = viaparinfo->fbmem_free;
615 viasamm.size_sec = viaparinfo1->fbmem_free; 617 u.viasamm.size_sec = viaparinfo1->fbmem_free;
616 } else { 618 } else {
617 if (viafb_second_size) { 619 if (viafb_second_size) {
618 viasamm.size_prim = 620 u.viasamm.size_prim =
619 viaparinfo->fbmem_free - 621 viaparinfo->fbmem_free -
620 viafb_second_size * 1024 * 1024; 622 viafb_second_size * 1024 * 1024;
621 viasamm.size_sec = 623 u.viasamm.size_sec =
622 viafb_second_size * 1024 * 1024; 624 viafb_second_size * 1024 * 1024;
623 } else { 625 } else {
624 viasamm.size_prim = 626 u.viasamm.size_prim =
625 viaparinfo->fbmem_free >> 1; 627 viaparinfo->fbmem_free >> 1;
626 viasamm.size_sec = 628 u.viasamm.size_sec =
627 (viaparinfo->fbmem_free >> 1); 629 (viaparinfo->fbmem_free >> 1);
628 } 630 }
629 } 631 }
630 viasamm.mem_base = viaparinfo->fbmem; 632 u.viasamm.mem_base = viaparinfo->fbmem;
631 viasamm.offset_sec = viafb_second_offset; 633 u.viasamm.offset_sec = viafb_second_offset;
632 } else { 634 } else {
633 viasamm.size_prim = 635 u.viasamm.size_prim =
634 viaparinfo->memsize - viaparinfo->fbmem_used; 636 viaparinfo->memsize - viaparinfo->fbmem_used;
635 viasamm.size_sec = 0; 637 u.viasamm.size_sec = 0;
636 viasamm.mem_base = viaparinfo->fbmem; 638 u.viasamm.mem_base = viaparinfo->fbmem;
637 viasamm.offset_sec = 0; 639 u.viasamm.offset_sec = 0;
638 } 640 }
639 641
640 if (copy_to_user(argp, &viasamm, sizeof(viasamm))) 642 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
641 return -EFAULT; 643 return -EFAULT;
642 644
643 break; 645 break;
@@ -662,74 +664,75 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
662 viafb_lcd_disable(); 664 viafb_lcd_disable();
663 break; 665 break;
664 case VIAFB_SET_DEVICE: 666 case VIAFB_SET_DEVICE:
665 if (copy_from_user(&active_dev, (void *)argp, 667 if (copy_from_user(&u.active_dev, (void *)argp,
666 sizeof(active_dev))) 668 sizeof(u.active_dev)))
667 return -EFAULT; 669 return -EFAULT;
668 viafb_set_device(active_dev); 670 viafb_set_device(u.active_dev);
669 viafb_set_par(info); 671 viafb_set_par(info);
670 break; 672 break;
671 case VIAFB_GET_DEVICE: 673 case VIAFB_GET_DEVICE:
672 active_dev.crt = viafb_CRT_ON; 674 u.active_dev.crt = viafb_CRT_ON;
673 active_dev.dvi = viafb_DVI_ON; 675 u.active_dev.dvi = viafb_DVI_ON;
674 active_dev.lcd = viafb_LCD_ON; 676 u.active_dev.lcd = viafb_LCD_ON;
675 active_dev.samm = viafb_SAMM_ON; 677 u.active_dev.samm = viafb_SAMM_ON;
676 active_dev.primary_dev = viafb_primary_dev; 678 u.active_dev.primary_dev = viafb_primary_dev;
677 679
678 active_dev.lcd_dsp_cent = viafb_lcd_dsp_method; 680 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
679 active_dev.lcd_panel_id = viafb_lcd_panel_id; 681 u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
680 active_dev.lcd_mode = viafb_lcd_mode; 682 u.active_dev.lcd_mode = viafb_lcd_mode;
681 683
682 active_dev.xres = viafb_hotplug_Xres; 684 u.active_dev.xres = viafb_hotplug_Xres;
683 active_dev.yres = viafb_hotplug_Yres; 685 u.active_dev.yres = viafb_hotplug_Yres;
684 686
685 active_dev.xres1 = viafb_second_xres; 687 u.active_dev.xres1 = viafb_second_xres;
686 active_dev.yres1 = viafb_second_yres; 688 u.active_dev.yres1 = viafb_second_yres;
687 689
688 active_dev.bpp = viafb_bpp; 690 u.active_dev.bpp = viafb_bpp;
689 active_dev.bpp1 = viafb_bpp1; 691 u.active_dev.bpp1 = viafb_bpp1;
690 active_dev.refresh = viafb_refresh; 692 u.active_dev.refresh = viafb_refresh;
691 active_dev.refresh1 = viafb_refresh1; 693 u.active_dev.refresh1 = viafb_refresh1;
692 694
693 active_dev.epia_dvi = viafb_platform_epia_dvi; 695 u.active_dev.epia_dvi = viafb_platform_epia_dvi;
694 active_dev.lcd_dual_edge = viafb_device_lcd_dualedge; 696 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
695 active_dev.bus_width = viafb_bus_width; 697 u.active_dev.bus_width = viafb_bus_width;
696 698
697 if (copy_to_user(argp, &active_dev, sizeof(active_dev))) 699 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
698 return -EFAULT; 700 return -EFAULT;
699 break; 701 break;
700 702
701 case VIAFB_GET_DRIVER_VERSION: 703 case VIAFB_GET_DRIVER_VERSION:
702 driver_version.iMajorNum = VERSION_MAJOR; 704 u.driver_version.iMajorNum = VERSION_MAJOR;
703 driver_version.iKernelNum = VERSION_KERNEL; 705 u.driver_version.iKernelNum = VERSION_KERNEL;
704 driver_version.iOSNum = VERSION_OS; 706 u.driver_version.iOSNum = VERSION_OS;
705 driver_version.iMinorNum = VERSION_MINOR; 707 u.driver_version.iMinorNum = VERSION_MINOR;
706 708
707 if (copy_to_user(argp, &driver_version, 709 if (copy_to_user(argp, &u.driver_version,
708 sizeof(driver_version))) 710 sizeof(u.driver_version)))
709 return -EFAULT; 711 return -EFAULT;
710 712
711 break; 713 break;
712 714
713 case VIAFB_SET_DEVICE_INFO: 715 case VIAFB_SET_DEVICE_INFO:
714 if (copy_from_user(&viafb_setting, 716 if (copy_from_user(&u.viafb_setting,
715 argp, sizeof(viafb_setting))) 717 argp, sizeof(u.viafb_setting)))
716 return -EFAULT; 718 return -EFAULT;
717 if (apply_device_setting(viafb_setting, info) < 0) 719 if (apply_device_setting(u.viafb_setting, info) < 0)
718 return -EINVAL; 720 return -EINVAL;
719 721
720 break; 722 break;
721 723
722 case VIAFB_SET_SECOND_MODE: 724 case VIAFB_SET_SECOND_MODE:
723 if (copy_from_user(&sec_var, argp, sizeof(sec_var))) 725 if (copy_from_user(&u.sec_var, argp, sizeof(u.sec_var)))
724 return -EFAULT; 726 return -EFAULT;
725 apply_second_mode_setting(&sec_var); 727 apply_second_mode_setting(&u.sec_var);
726 break; 728 break;
727 729
728 case VIAFB_GET_DEVICE_INFO: 730 case VIAFB_GET_DEVICE_INFO:
729 731
730 retrieve_device_setting(&viafb_setting); 732 retrieve_device_setting(&u.viafb_setting);
731 733
732 if (copy_to_user(argp, &viafb_setting, sizeof(viafb_setting))) 734 if (copy_to_user(argp, &u.viafb_setting,
735 sizeof(u.viafb_setting)))
733 return -EFAULT; 736 return -EFAULT;
734 737
735 break; 738 break;
@@ -806,51 +809,51 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
806 break; 809 break;
807 810
808 case VIAFB_GET_PANEL_MAX_SIZE: 811 case VIAFB_GET_PANEL_MAX_SIZE:
809 if (copy_from_user 812 if (copy_from_user(&u.panel_pos_size_para, argp,
810 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 813 sizeof(u.panel_pos_size_para)))
811 return -EFAULT; 814 return -EFAULT;
812 panel_pos_size_para.x = panel_pos_size_para.y = 0; 815 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
813 if (copy_to_user(argp, &panel_pos_size_para, 816 if (copy_to_user(argp, &u.panel_pos_size_para,
814 sizeof(panel_pos_size_para))) 817 sizeof(u.panel_pos_size_para)))
815 return -EFAULT; 818 return -EFAULT;
816 break; 819 break;
817 case VIAFB_GET_PANEL_MAX_POSITION: 820 case VIAFB_GET_PANEL_MAX_POSITION:
818 if (copy_from_user 821 if (copy_from_user(&u.panel_pos_size_para, argp,
819 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 822 sizeof(u.panel_pos_size_para)))
820 return -EFAULT; 823 return -EFAULT;
821 panel_pos_size_para.x = panel_pos_size_para.y = 0; 824 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
822 if (copy_to_user(argp, &panel_pos_size_para, 825 if (copy_to_user(argp, &u.panel_pos_size_para,
823 sizeof(panel_pos_size_para))) 826 sizeof(u.panel_pos_size_para)))
824 return -EFAULT; 827 return -EFAULT;
825 break; 828 break;
826 829
827 case VIAFB_GET_PANEL_POSITION: 830 case VIAFB_GET_PANEL_POSITION:
828 if (copy_from_user 831 if (copy_from_user(&u.panel_pos_size_para, argp,
829 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 832 sizeof(u.panel_pos_size_para)))
830 return -EFAULT; 833 return -EFAULT;
831 panel_pos_size_para.x = panel_pos_size_para.y = 0; 834 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
832 if (copy_to_user(argp, &panel_pos_size_para, 835 if (copy_to_user(argp, &u.panel_pos_size_para,
833 sizeof(panel_pos_size_para))) 836 sizeof(u.panel_pos_size_para)))
834 return -EFAULT; 837 return -EFAULT;
835 break; 838 break;
836 case VIAFB_GET_PANEL_SIZE: 839 case VIAFB_GET_PANEL_SIZE:
837 if (copy_from_user 840 if (copy_from_user(&u.panel_pos_size_para, argp,
838 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 841 sizeof(u.panel_pos_size_para)))
839 return -EFAULT; 842 return -EFAULT;
840 panel_pos_size_para.x = panel_pos_size_para.y = 0; 843 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
841 if (copy_to_user(argp, &panel_pos_size_para, 844 if (copy_to_user(argp, &u.panel_pos_size_para,
842 sizeof(panel_pos_size_para))) 845 sizeof(u.panel_pos_size_para)))
843 return -EFAULT; 846 return -EFAULT;
844 break; 847 break;
845 848
846 case VIAFB_SET_PANEL_POSITION: 849 case VIAFB_SET_PANEL_POSITION:
847 if (copy_from_user 850 if (copy_from_user(&u.panel_pos_size_para, argp,
848 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 851 sizeof(u.panel_pos_size_para)))
849 return -EFAULT; 852 return -EFAULT;
850 break; 853 break;
851 case VIAFB_SET_PANEL_SIZE: 854 case VIAFB_SET_PANEL_SIZE:
852 if (copy_from_user 855 if (copy_from_user(&u.panel_pos_size_para, argp,
853 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 856 sizeof(u.panel_pos_size_para)))
854 return -EFAULT; 857 return -EFAULT;
855 break; 858 break;
856 859
@@ -1052,10 +1055,8 @@ static void viafb_imageblit(struct fb_info *info,
1052 1055
1053static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor) 1056static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1054{ 1057{
1055 u8 data[CURSOR_SIZE / 8];
1056 u32 data_bak[CURSOR_SIZE / 32];
1057 u32 temp, xx, yy, bg_col = 0, fg_col = 0; 1058 u32 temp, xx, yy, bg_col = 0, fg_col = 0;
1058 int size, i, j = 0; 1059 int i, j = 0;
1059 static int hw_cursor; 1060 static int hw_cursor;
1060 struct viafb_par *p_viafb_par; 1061 struct viafb_par *p_viafb_par;
1061 1062
@@ -1178,22 +1179,29 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1178 } 1179 }
1179 1180
1180 if (cursor->set & FB_CUR_SETSHAPE) { 1181 if (cursor->set & FB_CUR_SETSHAPE) {
1181 size = 1182 struct {
1183 u8 data[CURSOR_SIZE / 8];
1184 u32 bak[CURSOR_SIZE / 32];
1185 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
1186 int size =
1182 ((viacursor.image.width + 7) >> 3) * 1187 ((viacursor.image.width + 7) >> 3) *
1183 viacursor.image.height; 1188 viacursor.image.height;
1184 1189
1190 if (cr_data == NULL)
1191 goto out;
1192
1185 if (MAX_CURS == 32) { 1193 if (MAX_CURS == 32) {
1186 for (i = 0; i < (CURSOR_SIZE / 32); i++) { 1194 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1187 data_bak[i] = 0x0; 1195 cr_data->bak[i] = 0x0;
1188 data_bak[i + 1] = 0xFFFFFFFF; 1196 cr_data->bak[i + 1] = 0xFFFFFFFF;
1189 i += 1; 1197 i += 1;
1190 } 1198 }
1191 } else if (MAX_CURS == 64) { 1199 } else if (MAX_CURS == 64) {
1192 for (i = 0; i < (CURSOR_SIZE / 32); i++) { 1200 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1193 data_bak[i] = 0x0; 1201 cr_data->bak[i] = 0x0;
1194 data_bak[i + 1] = 0x0; 1202 cr_data->bak[i + 1] = 0x0;
1195 data_bak[i + 2] = 0xFFFFFFFF; 1203 cr_data->bak[i + 2] = 0xFFFFFFFF;
1196 data_bak[i + 3] = 0xFFFFFFFF; 1204 cr_data->bak[i + 3] = 0xFFFFFFFF;
1197 i += 3; 1205 i += 3;
1198 } 1206 }
1199 } 1207 }
@@ -1201,12 +1209,12 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1201 switch (viacursor.rop) { 1209 switch (viacursor.rop) {
1202 case ROP_XOR: 1210 case ROP_XOR:
1203 for (i = 0; i < size; i++) 1211 for (i = 0; i < size; i++)
1204 data[i] = viacursor.mask[i]; 1212 cr_data->data[i] = viacursor.mask[i];
1205 break; 1213 break;
1206 case ROP_COPY: 1214 case ROP_COPY:
1207 1215
1208 for (i = 0; i < size; i++) 1216 for (i = 0; i < size; i++)
1209 data[i] = viacursor.mask[i]; 1217 cr_data->data[i] = viacursor.mask[i];
1210 break; 1218 break;
1211 default: 1219 default:
1212 break; 1220 break;
@@ -1214,23 +1222,25 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1214 1222
1215 if (MAX_CURS == 32) { 1223 if (MAX_CURS == 32) {
1216 for (i = 0; i < size; i++) { 1224 for (i = 0; i < size; i++) {
1217 data_bak[j] = (u32) data[i]; 1225 cr_data->bak[j] = (u32) cr_data->data[i];
1218 data_bak[j + 1] = ~data_bak[j]; 1226 cr_data->bak[j + 1] = ~cr_data->bak[j];
1219 j += 2; 1227 j += 2;
1220 } 1228 }
1221 } else if (MAX_CURS == 64) { 1229 } else if (MAX_CURS == 64) {
1222 for (i = 0; i < size; i++) { 1230 for (i = 0; i < size; i++) {
1223 data_bak[j] = (u32) data[i]; 1231 cr_data->bak[j] = (u32) cr_data->data[i];
1224 data_bak[j + 1] = 0x0; 1232 cr_data->bak[j + 1] = 0x0;
1225 data_bak[j + 2] = ~data_bak[j]; 1233 cr_data->bak[j + 2] = ~cr_data->bak[j];
1226 data_bak[j + 3] = ~data_bak[j + 1]; 1234 cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
1227 j += 4; 1235 j += 4;
1228 } 1236 }
1229 } 1237 }
1230 1238
1231 memcpy(((struct viafb_par *)(info->par))->fbmem_virt + 1239 memcpy(((struct viafb_par *)(info->par))->fbmem_virt +
1232 ((struct viafb_par *)(info->par))->cursor_start, 1240 ((struct viafb_par *)(info->par))->cursor_start,
1233 data_bak, CURSOR_SIZE); 1241 cr_data->bak, CURSOR_SIZE);
1242out:
1243 kfree(cr_data);
1234 } 1244 }
1235 1245
1236 if (viacursor.enable) 1246 if (viacursor.enable)
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 1377b1240b6e..9246cb4aa018 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -628,7 +628,7 @@ static int affs_write_begin_ofs(struct file *file, struct address_space *mapping
628 } 628 }
629 629
630 index = pos >> PAGE_CACHE_SHIFT; 630 index = pos >> PAGE_CACHE_SHIFT;
631 page = __grab_cache_page(mapping, index); 631 page = grab_cache_page_write_begin(mapping, index, flags);
632 if (!page) 632 if (!page)
633 return -ENOMEM; 633 return -ENOMEM;
634 *pagep = page; 634 *pagep = page;
diff --git a/fs/afs/write.c b/fs/afs/write.c
index d6b85dab35fc..3fb36d433621 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -144,7 +144,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
144 candidate->state = AFS_WBACK_PENDING; 144 candidate->state = AFS_WBACK_PENDING;
145 init_waitqueue_head(&candidate->waitq); 145 init_waitqueue_head(&candidate->waitq);
146 146
147 page = __grab_cache_page(mapping, index); 147 page = grab_cache_page_write_begin(mapping, index, flags);
148 if (!page) { 148 if (!page) {
149 kfree(candidate); 149 kfree(candidate);
150 return -ENOMEM; 150 return -ENOMEM;
diff --git a/fs/buffer.c b/fs/buffer.c
index 776ae091d3b0..a13f09b696f7 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1996,7 +1996,7 @@ int block_write_begin(struct file *file, struct address_space *mapping,
1996 page = *pagep; 1996 page = *pagep;
1997 if (page == NULL) { 1997 if (page == NULL) {
1998 ownpage = 1; 1998 ownpage = 1;
1999 page = __grab_cache_page(mapping, index); 1999 page = grab_cache_page_write_begin(mapping, index, flags);
2000 if (!page) { 2000 if (!page) {
2001 status = -ENOMEM; 2001 status = -ENOMEM;
2002 goto out; 2002 goto out;
@@ -2502,7 +2502,7 @@ int nobh_write_begin(struct file *file, struct address_space *mapping,
2502 from = pos & (PAGE_CACHE_SIZE - 1); 2502 from = pos & (PAGE_CACHE_SIZE - 1);
2503 to = from + len; 2503 to = from + len;
2504 2504
2505 page = __grab_cache_page(mapping, index); 2505 page = grab_cache_page_write_begin(mapping, index, flags);
2506 if (!page) 2506 if (!page)
2507 return -ENOMEM; 2507 return -ENOMEM;
2508 *pagep = page; 2508 *pagep = page;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index b1e1fc6a6e6a..12bb656fbe75 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2074,7 +2074,7 @@ static int cifs_write_begin(struct file *file, struct address_space *mapping,
2074 2074
2075 cFYI(1, ("write_begin from %lld len %d", (long long)pos, len)); 2075 cFYI(1, ("write_begin from %lld len %d", (long long)pos, len));
2076 2076
2077 page = __grab_cache_page(mapping, index); 2077 page = grab_cache_page_write_begin(mapping, index, flags);
2078 if (!page) { 2078 if (!page) {
2079 rc = -ENOMEM; 2079 rc = -ENOMEM;
2080 goto out; 2080 goto out;
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 04d7b3fa1ac6..46cec2b69796 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -288,7 +288,7 @@ static int ecryptfs_write_begin(struct file *file,
288 loff_t prev_page_end_size; 288 loff_t prev_page_end_size;
289 int rc = 0; 289 int rc = 0;
290 290
291 page = __grab_cache_page(mapping, index); 291 page = grab_cache_page_write_begin(mapping, index, flags);
292 if (!page) 292 if (!page)
293 return -ENOMEM; 293 return -ENOMEM;
294 *pagep = page; 294 *pagep = page;
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index c4bdccf976b5..5fa453b49a64 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1161,7 +1161,7 @@ static int ext3_write_begin(struct file *file, struct address_space *mapping,
1161 to = from + len; 1161 to = from + len;
1162 1162
1163retry: 1163retry:
1164 page = __grab_cache_page(mapping, index); 1164 page = grab_cache_page_write_begin(mapping, index, flags);
1165 if (!page) 1165 if (!page)
1166 return -ENOMEM; 1166 return -ENOMEM;
1167 *pagep = page; 1167 *pagep = page;
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 297ea8dfac7c..1dd2abe6313e 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -2175,8 +2175,7 @@ retry:
2175 * We have a transaction open. All is sweetness. It also sets 2175 * We have a transaction open. All is sweetness. It also sets
2176 * i_size in generic_commit_write(). 2176 * i_size in generic_commit_write().
2177 */ 2177 */
2178 err = __page_symlink(inode, symname, l, 2178 err = __page_symlink(inode, symname, l, 1);
2179 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
2180 if (err) { 2179 if (err) {
2181 drop_nlink(inode); 2180 drop_nlink(inode);
2182 unlock_new_inode(inode); 2181 unlock_new_inode(inode);
diff --git a/fs/ext4/ext4_sb.h b/fs/ext4/ext4_sb.h
index 445fde603df8..b21f16713db0 100644
--- a/fs/ext4/ext4_sb.h
+++ b/fs/ext4/ext4_sb.h
@@ -146,4 +146,10 @@ struct ext4_sb_info {
146 struct flex_groups *s_flex_groups; 146 struct flex_groups *s_flex_groups;
147}; 147};
148 148
149static inline spinlock_t *
150sb_bgl_lock(struct ext4_sb_info *sbi, unsigned int block_group)
151{
152 return bgl_lock_ptr(&sbi->s_blockgroup_lock, block_group);
153}
154
149#endif /* _EXT4_SB */ 155#endif /* _EXT4_SB */
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7c3325e0b005..6702a49992a6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1346,7 +1346,7 @@ retry:
1346 goto out; 1346 goto out;
1347 } 1347 }
1348 1348
1349 page = __grab_cache_page(mapping, index); 1349 page = grab_cache_page_write_begin(mapping, index, flags);
1350 if (!page) { 1350 if (!page) {
1351 ext4_journal_stop(handle); 1351 ext4_journal_stop(handle);
1352 ret = -ENOMEM; 1352 ret = -ENOMEM;
@@ -2550,7 +2550,7 @@ retry:
2550 goto out; 2550 goto out;
2551 } 2551 }
2552 2552
2553 page = __grab_cache_page(mapping, index); 2553 page = grab_cache_page_write_begin(mapping, index, flags);
2554 if (!page) { 2554 if (!page) {
2555 ext4_journal_stop(handle); 2555 ext4_journal_stop(handle);
2556 ret = -ENOMEM; 2556 ret = -ENOMEM;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index da98a9012fa5..9fd2a5e1be4d 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2212,8 +2212,7 @@ retry:
2212 * We have a transaction open. All is sweetness. It also sets 2212 * We have a transaction open. All is sweetness. It also sets
2213 * i_size in generic_commit_write(). 2213 * i_size in generic_commit_write().
2214 */ 2214 */
2215 err = __page_symlink(inode, symname, l, 2215 err = __page_symlink(inode, symname, l, 1);
2216 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
2217 if (err) { 2216 if (err) {
2218 clear_nlink(inode); 2217 clear_nlink(inode);
2219 unlock_new_inode(inode); 2218 unlock_new_inode(inode);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 34930a964b82..4c9ee7011265 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -646,7 +646,7 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping,
646{ 646{
647 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 647 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
648 648
649 *pagep = __grab_cache_page(mapping, index); 649 *pagep = grab_cache_page_write_begin(mapping, index, flags);
650 if (!*pagep) 650 if (!*pagep)
651 return -ENOMEM; 651 return -ENOMEM;
652 return 0; 652 return 0;
@@ -779,7 +779,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
779 break; 779 break;
780 780
781 err = -ENOMEM; 781 err = -ENOMEM;
782 page = __grab_cache_page(mapping, index); 782 page = grab_cache_page_write_begin(mapping, index, 0);
783 if (!page) 783 if (!page)
784 break; 784 break;
785 785
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index 27563816e1c5..15f710f2d4da 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -675,7 +675,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
675 goto out_trans_fail; 675 goto out_trans_fail;
676 676
677 error = -ENOMEM; 677 error = -ENOMEM;
678 page = __grab_cache_page(mapping, index); 678 page = grab_cache_page_write_begin(mapping, index, flags);
679 *pagep = page; 679 *pagep = page;
680 if (unlikely(!page)) 680 if (unlikely(!page))
681 goto out_endtrans; 681 goto out_endtrans;
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 3a31451ac170..5c538e0ec14b 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -501,7 +501,7 @@ int hostfs_write_begin(struct file *file, struct address_space *mapping,
501{ 501{
502 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 502 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
503 503
504 *pagep = __grab_cache_page(mapping, index); 504 *pagep = grab_cache_page_write_begin(mapping, index, flags);
505 if (!*pagep) 505 if (!*pagep)
506 return -ENOMEM; 506 return -ENOMEM;
507 return 0; 507 return 0;
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 5a98aa87c853..5edc2bf20581 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -132,7 +132,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
132 uint32_t pageofs = index << PAGE_CACHE_SHIFT; 132 uint32_t pageofs = index << PAGE_CACHE_SHIFT;
133 int ret = 0; 133 int ret = 0;
134 134
135 pg = __grab_cache_page(mapping, index); 135 pg = grab_cache_page_write_begin(mapping, index, flags);
136 if (!pg) 136 if (!pg)
137 return -ENOMEM; 137 return -ENOMEM;
138 *pagep = pg; 138 *pagep = pg;
diff --git a/fs/libfs.c b/fs/libfs.c
index e960a8321902..bdaec17fa388 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -360,7 +360,7 @@ int simple_write_begin(struct file *file, struct address_space *mapping,
360 index = pos >> PAGE_CACHE_SHIFT; 360 index = pos >> PAGE_CACHE_SHIFT;
361 from = pos & (PAGE_CACHE_SIZE - 1); 361 from = pos & (PAGE_CACHE_SIZE - 1);
362 362
363 page = __grab_cache_page(mapping, index); 363 page = grab_cache_page_write_begin(mapping, index, flags);
364 if (!page) 364 if (!page)
365 return -ENOMEM; 365 return -ENOMEM;
366 366
diff --git a/fs/namei.c b/fs/namei.c
index dd5c9f0bf829..df2d3df4f049 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2817,18 +2817,23 @@ void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
2817 } 2817 }
2818} 2818}
2819 2819
2820int __page_symlink(struct inode *inode, const char *symname, int len, 2820/*
2821 gfp_t gfp_mask) 2821 * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS
2822 */
2823int __page_symlink(struct inode *inode, const char *symname, int len, int nofs)
2822{ 2824{
2823 struct address_space *mapping = inode->i_mapping; 2825 struct address_space *mapping = inode->i_mapping;
2824 struct page *page; 2826 struct page *page;
2825 void *fsdata; 2827 void *fsdata;
2826 int err; 2828 int err;
2827 char *kaddr; 2829 char *kaddr;
2830 unsigned int flags = AOP_FLAG_UNINTERRUPTIBLE;
2831 if (nofs)
2832 flags |= AOP_FLAG_NOFS;
2828 2833
2829retry: 2834retry:
2830 err = pagecache_write_begin(NULL, mapping, 0, len-1, 2835 err = pagecache_write_begin(NULL, mapping, 0, len-1,
2831 AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata); 2836 flags, &page, &fsdata);
2832 if (err) 2837 if (err)
2833 goto fail; 2838 goto fail;
2834 2839
@@ -2852,7 +2857,7 @@ fail:
2852int page_symlink(struct inode *inode, const char *symname, int len) 2857int page_symlink(struct inode *inode, const char *symname, int len)
2853{ 2858{
2854 return __page_symlink(inode, symname, len, 2859 return __page_symlink(inode, symname, len,
2855 mapping_gfp_mask(inode->i_mapping)); 2860 !(mapping_gfp_mask(inode->i_mapping) & __GFP_FS));
2856} 2861}
2857 2862
2858const struct inode_operations page_symlink_inode_operations = { 2863const struct inode_operations page_symlink_inode_operations = {
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index d319b49f8f06..90f292b520d2 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -354,7 +354,7 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping,
354 file->f_path.dentry->d_name.name, 354 file->f_path.dentry->d_name.name,
355 mapping->host->i_ino, len, (long long) pos); 355 mapping->host->i_ino, len, (long long) pos);
356 356
357 page = __grab_cache_page(mapping, index); 357 page = grab_cache_page_write_begin(mapping, index, flags);
358 if (!page) 358 if (!page)
359 return -ENOMEM; 359 return -ENOMEM;
360 *pagep = page; 360 *pagep = page;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 145c2d3e5e01..ed04f47007f8 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2561,7 +2561,7 @@ static int reiserfs_write_begin(struct file *file,
2561 } 2561 }
2562 2562
2563 index = pos >> PAGE_CACHE_SHIFT; 2563 index = pos >> PAGE_CACHE_SHIFT;
2564 page = __grab_cache_page(mapping, index); 2564 page = grab_cache_page_write_begin(mapping, index, flags);
2565 if (!page) 2565 if (!page)
2566 return -ENOMEM; 2566 return -ENOMEM;
2567 *pagep = page; 2567 *pagep = page;
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index e4f8d51a5553..92d5e8ffb639 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -297,7 +297,7 @@ static int smb_write_begin(struct file *file, struct address_space *mapping,
297 struct page **pagep, void **fsdata) 297 struct page **pagep, void **fsdata)
298{ 298{
299 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 299 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
300 *pagep = __grab_cache_page(mapping, index); 300 *pagep = grab_cache_page_write_begin(mapping, index, flags);
301 if (!*pagep) 301 if (!*pagep)
302 return -ENOMEM; 302 return -ENOMEM;
303 return 0; 303 return 0;
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index fe82d2464d46..bf37374567fa 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -219,7 +219,8 @@ static void release_existing_page_budget(struct ubifs_info *c)
219} 219}
220 220
221static int write_begin_slow(struct address_space *mapping, 221static int write_begin_slow(struct address_space *mapping,
222 loff_t pos, unsigned len, struct page **pagep) 222 loff_t pos, unsigned len, struct page **pagep,
223 unsigned flags)
223{ 224{
224 struct inode *inode = mapping->host; 225 struct inode *inode = mapping->host;
225 struct ubifs_info *c = inode->i_sb->s_fs_info; 226 struct ubifs_info *c = inode->i_sb->s_fs_info;
@@ -247,7 +248,7 @@ static int write_begin_slow(struct address_space *mapping,
247 if (unlikely(err)) 248 if (unlikely(err))
248 return err; 249 return err;
249 250
250 page = __grab_cache_page(mapping, index); 251 page = grab_cache_page_write_begin(mapping, index, flags);
251 if (unlikely(!page)) { 252 if (unlikely(!page)) {
252 ubifs_release_budget(c, &req); 253 ubifs_release_budget(c, &req);
253 return -ENOMEM; 254 return -ENOMEM;
@@ -438,7 +439,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
438 return -EROFS; 439 return -EROFS;
439 440
440 /* Try out the fast-path part first */ 441 /* Try out the fast-path part first */
441 page = __grab_cache_page(mapping, index); 442 page = grab_cache_page_write_begin(mapping, index, flags);
442 if (unlikely(!page)) 443 if (unlikely(!page))
443 return -ENOMEM; 444 return -ENOMEM;
444 445
@@ -483,7 +484,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
483 unlock_page(page); 484 unlock_page(page);
484 page_cache_release(page); 485 page_cache_release(page);
485 486
486 return write_begin_slow(mapping, pos, len, pagep); 487 return write_begin_slow(mapping, pos, len, pagep, flags);
487 } 488 }
488 489
489 /* 490 /*
diff --git a/include/linux/blockgroup_lock.h b/include/linux/blockgroup_lock.h
index 8607312983bd..e44b88ba552b 100644
--- a/include/linux/blockgroup_lock.h
+++ b/include/linux/blockgroup_lock.h
@@ -53,7 +53,10 @@ static inline void bgl_lock_init(struct blockgroup_lock *bgl)
53 * The accessor is a macro so we can embed a blockgroup_lock into different 53 * The accessor is a macro so we can embed a blockgroup_lock into different
54 * superblock types 54 * superblock types
55 */ 55 */
56#define sb_bgl_lock(sb, block_group) \ 56static inline spinlock_t *
57 (&(sb)->s_blockgroup_lock.locks[(block_group) & (NR_BG_LOCKS-1)].lock) 57bgl_lock_ptr(struct blockgroup_lock *bgl, unsigned int block_group)
58{
59 return &bgl->locks[(block_group) & (NR_BG_LOCKS-1)].lock;
60}
58 61
59#endif 62#endif
diff --git a/include/linux/ext2_fs_sb.h b/include/linux/ext2_fs_sb.h
index f273415ab6f1..dc541f3653d1 100644
--- a/include/linux/ext2_fs_sb.h
+++ b/include/linux/ext2_fs_sb.h
@@ -108,4 +108,10 @@ struct ext2_sb_info {
108 struct ext2_reserve_window_node s_rsv_window_head; 108 struct ext2_reserve_window_node s_rsv_window_head;
109}; 109};
110 110
111static inline spinlock_t *
112sb_bgl_lock(struct ext2_sb_info *sbi, unsigned int block_group)
113{
114 return bgl_lock_ptr(&sbi->s_blockgroup_lock, block_group);
115}
116
111#endif /* _LINUX_EXT2_FS_SB */ 117#endif /* _LINUX_EXT2_FS_SB */
diff --git a/include/linux/ext3_fs_sb.h b/include/linux/ext3_fs_sb.h
index b65f0288b842..e024e38248ff 100644
--- a/include/linux/ext3_fs_sb.h
+++ b/include/linux/ext3_fs_sb.h
@@ -83,4 +83,10 @@ struct ext3_sb_info {
83#endif 83#endif
84}; 84};
85 85
86static inline spinlock_t *
87sb_bgl_lock(struct ext3_sb_info *sbi, unsigned int block_group)
88{
89 return bgl_lock_ptr(&sbi->s_blockgroup_lock, block_group);
90}
91
86#endif /* _LINUX_EXT3_FS_SB */ 92#endif /* _LINUX_EXT3_FS_SB */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e2170ee21e18..f2a3010140e3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -423,6 +423,9 @@ enum positive_aop_returns {
423 423
424#define AOP_FLAG_UNINTERRUPTIBLE 0x0001 /* will not do a short write */ 424#define AOP_FLAG_UNINTERRUPTIBLE 0x0001 /* will not do a short write */
425#define AOP_FLAG_CONT_EXPAND 0x0002 /* called from cont_expand */ 425#define AOP_FLAG_CONT_EXPAND 0x0002 /* called from cont_expand */
426#define AOP_FLAG_NOFS 0x0004 /* used by filesystem to direct
427 * helper code (eg buffer layer)
428 * to clear GFP_FS from alloc */
426 429
427/* 430/*
428 * oh the beauties of C type declarations. 431 * oh the beauties of C type declarations.
@@ -2035,7 +2038,7 @@ extern int page_readlink(struct dentry *, char __user *, int);
2035extern void *page_follow_link_light(struct dentry *, struct nameidata *); 2038extern void *page_follow_link_light(struct dentry *, struct nameidata *);
2036extern void page_put_link(struct dentry *, struct nameidata *, void *); 2039extern void page_put_link(struct dentry *, struct nameidata *, void *);
2037extern int __page_symlink(struct inode *inode, const char *symname, int len, 2040extern int __page_symlink(struct inode *inode, const char *symname, int len,
2038 gfp_t gfp_mask); 2041 int nofs);
2039extern int page_symlink(struct inode *inode, const char *symname, int len); 2042extern int page_symlink(struct inode *inode, const char *symname, int len);
2040extern const struct inode_operations page_symlink_inode_operations; 2043extern const struct inode_operations page_symlink_inode_operations;
2041extern int generic_readlink(struct dentry *, char __user *, int); 2044extern int generic_readlink(struct dentry *, char __user *, int);
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 709742be02f0..01ca0856caff 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -241,7 +241,8 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start,
241unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index, 241unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
242 int tag, unsigned int nr_pages, struct page **pages); 242 int tag, unsigned int nr_pages, struct page **pages);
243 243
244struct page *__grab_cache_page(struct address_space *mapping, pgoff_t index); 244struct page *grab_cache_page_write_begin(struct address_space *mapping,
245 pgoff_t index, unsigned flags);
245 246
246/* 247/*
247 * Returns locked page at given index in given cache, creating it if needed. 248 * Returns locked page at given index in given cache, creating it if needed.
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 91f597ad6acc..4046b75563c1 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -145,6 +145,8 @@ struct rtc_class_ops {
145 int (*irq_set_state)(struct device *, int enabled); 145 int (*irq_set_state)(struct device *, int enabled);
146 int (*irq_set_freq)(struct device *, int freq); 146 int (*irq_set_freq)(struct device *, int freq);
147 int (*read_callback)(struct device *, int data); 147 int (*read_callback)(struct device *, int data);
148 int (*alarm_irq_enable)(struct device *, unsigned int enabled);
149 int (*update_irq_enable)(struct device *, unsigned int enabled);
148}; 150};
149 151
150#define RTC_DEVICE_NAME_SIZE 20 152#define RTC_DEVICE_NAME_SIZE 20
@@ -181,7 +183,7 @@ struct rtc_device
181 struct timer_list uie_timer; 183 struct timer_list uie_timer;
182 /* Those fields are protected by rtc->irq_lock */ 184 /* Those fields are protected by rtc->irq_lock */
183 unsigned int oldsecs; 185 unsigned int oldsecs;
184 unsigned int irq_active:1; 186 unsigned int uie_irq_active:1;
185 unsigned int stop_uie_polling:1; 187 unsigned int stop_uie_polling:1;
186 unsigned int uie_task_active:1; 188 unsigned int uie_task_active:1;
187 unsigned int uie_timer_active:1; 189 unsigned int uie_timer_active:1;
@@ -216,6 +218,10 @@ extern int rtc_irq_set_state(struct rtc_device *rtc,
216 struct rtc_task *task, int enabled); 218 struct rtc_task *task, int enabled);
217extern int rtc_irq_set_freq(struct rtc_device *rtc, 219extern int rtc_irq_set_freq(struct rtc_device *rtc,
218 struct rtc_task *task, int freq); 220 struct rtc_task *task, int freq);
221extern int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled);
222extern int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled);
223extern int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc,
224 unsigned int enabled);
219 225
220typedef struct rtc_task { 226typedef struct rtc_task {
221 void (*func)(void *private_data); 227 void (*func)(void *private_data);
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 4be01bb44377..82229317753d 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -19,6 +19,8 @@
19#ifndef __LINUX_SPI_H 19#ifndef __LINUX_SPI_H
20#define __LINUX_SPI_H 20#define __LINUX_SPI_H
21 21
22#include <linux/device.h>
23
22/* 24/*
23 * INTERFACES between SPI master-side drivers and SPI infrastructure. 25 * INTERFACES between SPI master-side drivers and SPI infrastructure.
24 * (There's no SPI slave support for Linux yet...) 26 * (There's no SPI slave support for Linux yet...)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 48348dde6d81..891a84eb9d30 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2945,7 +2945,11 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
2945 parent = task_cgroup(tsk, subsys->subsys_id); 2945 parent = task_cgroup(tsk, subsys->subsys_id);
2946 2946
2947 /* Pin the hierarchy */ 2947 /* Pin the hierarchy */
2948 atomic_inc(&parent->root->sb->s_active); 2948 if (!atomic_inc_not_zero(&parent->root->sb->s_active)) {
2949 /* We race with the final deactivate_super() */
2950 mutex_unlock(&cgroup_mutex);
2951 return 0;
2952 }
2949 2953
2950 /* Keep the cgroup alive */ 2954 /* Keep the cgroup alive */
2951 get_css_set(cg); 2955 get_css_set(cg);
diff --git a/mm/filemap.c b/mm/filemap.c
index f3e5f8944d17..f8c69273c37f 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2140,19 +2140,24 @@ EXPORT_SYMBOL(generic_file_direct_write);
2140 * Find or create a page at the given pagecache position. Return the locked 2140 * Find or create a page at the given pagecache position. Return the locked
2141 * page. This function is specifically for buffered writes. 2141 * page. This function is specifically for buffered writes.
2142 */ 2142 */
2143struct page *__grab_cache_page(struct address_space *mapping, pgoff_t index) 2143struct page *grab_cache_page_write_begin(struct address_space *mapping,
2144 pgoff_t index, unsigned flags)
2144{ 2145{
2145 int status; 2146 int status;
2146 struct page *page; 2147 struct page *page;
2148 gfp_t gfp_notmask = 0;
2149 if (flags & AOP_FLAG_NOFS)
2150 gfp_notmask = __GFP_FS;
2147repeat: 2151repeat:
2148 page = find_lock_page(mapping, index); 2152 page = find_lock_page(mapping, index);
2149 if (likely(page)) 2153 if (likely(page))
2150 return page; 2154 return page;
2151 2155
2152 page = page_cache_alloc(mapping); 2156 page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~gfp_notmask);
2153 if (!page) 2157 if (!page)
2154 return NULL; 2158 return NULL;
2155 status = add_to_page_cache_lru(page, mapping, index, GFP_KERNEL); 2159 status = add_to_page_cache_lru(page, mapping, index,
2160 GFP_KERNEL & ~gfp_notmask);
2156 if (unlikely(status)) { 2161 if (unlikely(status)) {
2157 page_cache_release(page); 2162 page_cache_release(page);
2158 if (status == -EEXIST) 2163 if (status == -EEXIST)
@@ -2161,7 +2166,7 @@ repeat:
2161 } 2166 }
2162 return page; 2167 return page;
2163} 2168}
2164EXPORT_SYMBOL(__grab_cache_page); 2169EXPORT_SYMBOL(grab_cache_page_write_begin);
2165 2170
2166static ssize_t generic_perform_write(struct file *file, 2171static ssize_t generic_perform_write(struct file *file,
2167 struct iov_iter *i, loff_t pos) 2172 struct iov_iter *i, loff_t pos)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1ddb77ba3995..7465f22fec0c 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -151,11 +151,12 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
151 * 151 *
152 * Ie. pte at addr+N*PAGE_SIZE shall point to pfn corresponding to pages[N] 152 * Ie. pte at addr+N*PAGE_SIZE shall point to pfn corresponding to pages[N]
153 */ 153 */
154static int vmap_page_range(unsigned long addr, unsigned long end, 154static int vmap_page_range(unsigned long start, unsigned long end,
155 pgprot_t prot, struct page **pages) 155 pgprot_t prot, struct page **pages)
156{ 156{
157 pgd_t *pgd; 157 pgd_t *pgd;
158 unsigned long next; 158 unsigned long next;
159 unsigned long addr = start;
159 int err = 0; 160 int err = 0;
160 int nr = 0; 161 int nr = 0;
161 162
@@ -167,7 +168,7 @@ static int vmap_page_range(unsigned long addr, unsigned long end,
167 if (err) 168 if (err)
168 break; 169 break;
169 } while (pgd++, addr = next, addr != end); 170 } while (pgd++, addr = next, addr != end);
170 flush_cache_vmap(addr, end); 171 flush_cache_vmap(start, end);
171 172
172 if (unlikely(err)) 173 if (unlikely(err))
173 return err; 174 return err;